@toclocoinc/lattice-grid 1.74.0 → 1.75.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +44 -6
  5. package/docs/CHART-CODES.md +8 -0
  6. package/docs/api/adapters.html +1 -1
  7. package/docs/api/ai.html +1 -1
  8. package/docs/api/alarms.html +1 -1
  9. package/docs/api/charts.html +28 -2
  10. package/docs/api/data-router.html +1 -1
  11. package/docs/api/deckgl.html +2 -2
  12. package/docs/api/gantt.html +1 -1
  13. package/docs/api/geometry.html +1 -1
  14. package/docs/api/grid.html +2 -2
  15. package/docs/api/index.html +2 -2
  16. package/docs/api/kanban.html +1 -1
  17. package/docs/api/kpi.html +1 -1
  18. package/docs/api/layout.html +1 -1
  19. package/docs/api/list.html +1 -1
  20. package/docs/api/mock-socket.html +1 -1
  21. package/docs/api/tabs.html +1 -1
  22. package/docs/api/types.html +13 -1
  23. package/docs/api-detail.html +13 -4
  24. package/docs/warnings.json +36 -3
  25. package/lattice-grid.d.ts +37 -2
  26. package/lattice-grid.esm.min.js +3 -3
  27. package/lattice-grid.min.cjs +3 -3
  28. package/lattice-grid.min.js +3 -3
  29. package/modules/ai.d.ts +1 -1
  30. package/modules/ai.esm.min.js +2 -2
  31. package/modules/ai.min.cjs +2 -2
  32. package/modules/ai.min.js +2 -2
  33. package/modules/alarms.d.ts +1 -1
  34. package/modules/alarms.esm.min.js +2 -2
  35. package/modules/alarms.min.cjs +2 -2
  36. package/modules/alarms.min.js +2 -2
  37. package/modules/angular.d.ts +1 -1
  38. package/modules/angular.esm.min.js +2 -2
  39. package/modules/angular.min.cjs +2 -2
  40. package/modules/angular.min.js +2 -2
  41. package/modules/chart-alluvial.d.ts +1 -1
  42. package/modules/chart-alluvial.esm.min.js +1 -1
  43. package/modules/chart-alluvial.min.cjs +1 -1
  44. package/modules/chart-alluvial.min.js +1 -1
  45. package/modules/chart-arc.d.ts +1 -1
  46. package/modules/chart-arc.esm.min.js +1 -1
  47. package/modules/chart-arc.min.cjs +1 -1
  48. package/modules/chart-arc.min.js +1 -1
  49. package/modules/chart-bubblemap.d.ts +1 -1
  50. package/modules/chart-bubblemap.esm.min.js +1 -1
  51. package/modules/chart-bubblemap.min.cjs +1 -1
  52. package/modules/chart-bubblemap.min.js +1 -1
  53. package/modules/chart-bump.d.ts +1 -1
  54. package/modules/chart-bump.esm.min.js +1 -1
  55. package/modules/chart-bump.min.cjs +1 -1
  56. package/modules/chart-bump.min.js +1 -1
  57. package/modules/chart-calendar.d.ts +1 -1
  58. package/modules/chart-calendar.esm.min.js +2 -2
  59. package/modules/chart-calendar.esm.min.js.map +1 -1
  60. package/modules/chart-calendar.min.cjs +2 -2
  61. package/modules/chart-calendar.min.js +2 -2
  62. package/modules/chart-calendar.min.js.map +1 -1
  63. package/modules/chart-choropleth.d.ts +1 -1
  64. package/modules/chart-choropleth.esm.min.js +2 -2
  65. package/modules/chart-choropleth.esm.min.js.map +1 -1
  66. package/modules/chart-choropleth.min.cjs +2 -2
  67. package/modules/chart-choropleth.min.js +2 -2
  68. package/modules/chart-choropleth.min.js.map +1 -1
  69. package/modules/chart-decomposition.d.ts +1 -1
  70. package/modules/chart-decomposition.esm.min.js +1 -1
  71. package/modules/chart-decomposition.min.cjs +1 -1
  72. package/modules/chart-decomposition.min.js +1 -1
  73. package/modules/chart-diverging.d.ts +1 -1
  74. package/modules/chart-diverging.esm.min.js +1 -1
  75. package/modules/chart-diverging.min.cjs +1 -1
  76. package/modules/chart-diverging.min.js +1 -1
  77. package/modules/chart-dumbbell.d.ts +1 -1
  78. package/modules/chart-dumbbell.esm.min.js +1 -1
  79. package/modules/chart-dumbbell.min.cjs +1 -1
  80. package/modules/chart-dumbbell.min.js +1 -1
  81. package/modules/chart-fan.d.ts +1 -1
  82. package/modules/chart-fan.esm.min.js +1 -1
  83. package/modules/chart-fan.min.cjs +1 -1
  84. package/modules/chart-fan.min.js +1 -1
  85. package/modules/chart-hexbin.d.ts +1 -1
  86. package/modules/chart-hexbin.esm.min.js +2 -2
  87. package/modules/chart-hexbin.esm.min.js.map +1 -1
  88. package/modules/chart-hexbin.min.cjs +2 -2
  89. package/modules/chart-hexbin.min.js +2 -2
  90. package/modules/chart-hexbin.min.js.map +1 -1
  91. package/modules/chart-hexmap.d.ts +1 -1
  92. package/modules/chart-hexmap.esm.min.js +2 -2
  93. package/modules/chart-hexmap.esm.min.js.map +1 -1
  94. package/modules/chart-hexmap.min.cjs +2 -2
  95. package/modules/chart-hexmap.min.js +2 -2
  96. package/modules/chart-hexmap.min.js.map +1 -1
  97. package/modules/chart-icicle.d.ts +1 -1
  98. package/modules/chart-icicle.esm.min.js +1 -1
  99. package/modules/chart-icicle.min.cjs +1 -1
  100. package/modules/chart-icicle.min.js +1 -1
  101. package/modules/chart-markermap.d.ts +1 -1
  102. package/modules/chart-markermap.esm.min.js +1 -1
  103. package/modules/chart-markermap.min.cjs +1 -1
  104. package/modules/chart-markermap.min.js +1 -1
  105. package/modules/chart-parallel.d.ts +1 -1
  106. package/modules/chart-parallel.esm.min.js +1 -1
  107. package/modules/chart-parallel.min.cjs +1 -1
  108. package/modules/chart-parallel.min.js +1 -1
  109. package/modules/chart-ridgeline.d.ts +1 -1
  110. package/modules/chart-ridgeline.esm.min.js +1 -1
  111. package/modules/chart-ridgeline.min.cjs +1 -1
  112. package/modules/chart-ridgeline.min.js +1 -1
  113. package/modules/chart-roc.d.ts +1 -1
  114. package/modules/chart-roc.esm.min.js +1 -1
  115. package/modules/chart-roc.min.cjs +1 -1
  116. package/modules/chart-roc.min.js +1 -1
  117. package/modules/chart-slope.d.ts +1 -1
  118. package/modules/chart-slope.esm.min.js +1 -1
  119. package/modules/chart-slope.min.cjs +1 -1
  120. package/modules/chart-slope.min.js +1 -1
  121. package/modules/chart-splom.d.ts +1 -1
  122. package/modules/chart-splom.esm.min.js +1 -1
  123. package/modules/chart-splom.min.cjs +1 -1
  124. package/modules/chart-splom.min.js +1 -1
  125. package/modules/chart-waffle.d.ts +1 -1
  126. package/modules/chart-waffle.esm.min.js +1 -1
  127. package/modules/chart-waffle.min.cjs +1 -1
  128. package/modules/chart-waffle.min.js +1 -1
  129. package/modules/charts.d.ts +1 -1
  130. package/modules/charts.esm.min.js +185 -178
  131. package/modules/charts.esm.min.js.map +2 -2
  132. package/modules/charts.min.cjs +185 -178
  133. package/modules/charts.min.js +185 -178
  134. package/modules/charts.min.js.map +2 -2
  135. package/modules/data-router.d.ts +1 -1
  136. package/modules/data-router.esm.min.js +2 -2
  137. package/modules/data-router.min.cjs +2 -2
  138. package/modules/data-router.min.js +2 -2
  139. package/modules/deckgl.d.ts +9 -3
  140. package/modules/deckgl.esm.min.js +18 -11
  141. package/modules/deckgl.esm.min.js.map +2 -2
  142. package/modules/deckgl.min.cjs +18 -11
  143. package/modules/deckgl.min.js +18 -11
  144. package/modules/deckgl.min.js.map +2 -2
  145. package/modules/devtools.d.ts +1 -1
  146. package/modules/devtools.esm.min.js +1 -1
  147. package/modules/devtools.min.cjs +1 -1
  148. package/modules/devtools.min.js +1 -1
  149. package/modules/dhtmlx-compat.d.ts +1 -1
  150. package/modules/dhtmlx-compat.esm.min.js +2 -2
  151. package/modules/dhtmlx-compat.min.cjs +2 -2
  152. package/modules/dhtmlx-compat.min.js +2 -2
  153. package/modules/gantt.d.ts +1 -1
  154. package/modules/gantt.esm.min.js +2 -2
  155. package/modules/gantt.min.cjs +2 -2
  156. package/modules/gantt.min.js +2 -2
  157. package/modules/geo-europe-nuts.d.ts +1 -1
  158. package/modules/geo-europe-nuts.esm.min.js +1 -1
  159. package/modules/geo-europe-nuts.min.cjs +1 -1
  160. package/modules/geo-europe-nuts.min.js +1 -1
  161. package/modules/geo-uk.d.ts +1 -1
  162. package/modules/geo-uk.esm.min.js +1 -1
  163. package/modules/geo-uk.min.cjs +1 -1
  164. package/modules/geo-uk.min.js +1 -1
  165. package/modules/geo-us-states.d.ts +1 -1
  166. package/modules/geo-us-states.esm.min.js +1 -1
  167. package/modules/geo-us-states.min.cjs +1 -1
  168. package/modules/geo-us-states.min.js +1 -1
  169. package/modules/geo-world-110m.d.ts +1 -1
  170. package/modules/geo-world-110m.esm.min.js +1 -1
  171. package/modules/geo-world-110m.min.cjs +1 -1
  172. package/modules/geo-world-110m.min.js +1 -1
  173. package/modules/geo-world-50m.d.ts +1 -1
  174. package/modules/geo-world-50m.esm.min.js +1 -1
  175. package/modules/geo-world-50m.min.cjs +1 -1
  176. package/modules/geo-world-50m.min.js +1 -1
  177. package/modules/geometry.d.ts +1 -1
  178. package/modules/geometry.esm.min.js +2 -2
  179. package/modules/geometry.min.cjs +2 -2
  180. package/modules/geometry.min.js +2 -2
  181. package/modules/htmx.d.ts +1 -1
  182. package/modules/htmx.esm.min.js +3 -3
  183. package/modules/htmx.min.cjs +3 -3
  184. package/modules/htmx.min.js +3 -3
  185. package/modules/kanban.d.ts +1 -1
  186. package/modules/kanban.esm.min.js +2 -2
  187. package/modules/kanban.min.cjs +2 -2
  188. package/modules/kanban.min.js +2 -2
  189. package/modules/kpi.d.ts +1 -1
  190. package/modules/kpi.esm.min.js +2 -2
  191. package/modules/kpi.min.cjs +2 -2
  192. package/modules/kpi.min.js +2 -2
  193. package/modules/layout.d.ts +1 -1
  194. package/modules/layout.esm.min.js +2 -2
  195. package/modules/layout.min.cjs +2 -2
  196. package/modules/layout.min.js +2 -2
  197. package/modules/list.d.ts +1 -1
  198. package/modules/list.esm.min.js +2 -2
  199. package/modules/list.min.cjs +2 -2
  200. package/modules/list.min.js +2 -2
  201. package/modules/mock-socket.d.ts +1 -1
  202. package/modules/mock-socket.esm.min.js +1 -1
  203. package/modules/mock-socket.min.cjs +1 -1
  204. package/modules/mock-socket.min.js +1 -1
  205. package/modules/react.d.ts +1 -1
  206. package/modules/react.esm.min.js +2 -2
  207. package/modules/react.min.cjs +2 -2
  208. package/modules/react.min.js +2 -2
  209. package/modules/svelte.d.ts +1 -1
  210. package/modules/svelte.esm.min.js +2 -2
  211. package/modules/svelte.min.cjs +2 -2
  212. package/modules/svelte.min.js +2 -2
  213. package/modules/tabs.d.ts +1 -1
  214. package/modules/tabs.esm.min.js +2 -2
  215. package/modules/tabs.min.cjs +2 -2
  216. package/modules/tabs.min.js +2 -2
  217. package/modules/vue.d.ts +1 -1
  218. package/modules/vue.esm.min.js +2 -2
  219. package/modules/vue.min.cjs +2 -2
  220. package/modules/vue.min.js +2 -2
  221. package/modules/webcomponent.d.ts +1 -1
  222. package/modules/webcomponent.esm.min.js +3 -3
  223. package/modules/webcomponent.min.cjs +3 -3
  224. package/modules/webcomponent.min.js +3 -3
  225. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.74.0, core + DOM renderer
2
+ * Lattice Grid 1.75.0, core + DOM renderer
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var rr=Object.create(null),ir=Object.create(null);function Ce(e,G){rr[e]=G}function Un(e){var G=ir[e];if(G)return G;var _=Object.create(null);ir[e]=_;var M=rr[e];if(!M)throw new Error("[lattice] missing module: "+e);return M(_,Un),_}Ce("packages/core/src/internal/util.js",function(e,G){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return S}}),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 u}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const _="1.74.0";async function M(){return _}const $="1.74.0",R=new Set,W=2e3;function Z(ee){if(R.add(ee),R.size>W){const re=R.values().next().value;re!==void 0&&R.delete(re)}}const V=[],U=500;function D(ee,re,se){V.push({key:ee,level:re,message:se.map(de=>typeof de=="string"?de:I(de)).join(" "),at:Date.now()}),V.length>U&&V.shift()}function I(ee){if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return String(ee)}}function k(){return V.map(ee=>({...ee}))}function S(ee,...re){R.has(ee)||(Z(ee),D(ee,"warn",re),console.warn("[lattice]",...re))}function y(ee,...re){R.has(ee)||(Z(ee),D(ee,"info",re),console.info("[lattice]",...re))}function d(){R.clear(),V.length=0}function u(ee,re){const se=new Error(`[lattice] ${ee}`);throw re!==void 0&&(se.cause=re),se}function n(ee,re){ee||u(re)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(ee){return ee!==null&&typeof ee=="object"&&!Array.isArray(ee)}function s(ee){return typeof ee=="function"}function r(ee){return ee==null}function o(ee){return ee==null||ee===""}function l(ee){return typeof ee!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ee))?!0:!!(ee.prototype&&Object.getOwnPropertyNames(ee.prototype).length>1)}const a=new Map;function p(ee){let re=a.get(ee);if(re)return re;if(!ee.includes("."))re=se=>se?.[ee];else{const se=ee.split("."),de=se.length;re=ie=>{let oe=ie;for(let ue=0;ue<de;ue++){if(oe==null)return;oe=oe[se[ue]]}return oe}}return a.set(ee,re),re}const m=new Map;function b(ee){let re=m.get(ee);if(re)return re;if(!ee.includes("."))re=(se,de)=>{se!=null&&(se[ee]=de)};else{const se=ee.split("."),de=se.length-1;re=(ie,oe)=>{let ue=ie;for(let ce=0;ce<de;ce++){if(ue==null)return;const pe=se[ce];ue[pe]==null&&(ue[pe]={}),ue=ue[pe]}ue!=null&&(ue[se[de]]=oe)}}return m.set(ee,re),re}function g(ee,re){return p(re)(ee)}function f(ee,re,se){b(re)(ee,se)}function w(ee){return ee?(ee.includes(".")?ee.slice(ee.lastIndexOf(".")+1):ee).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,se=>se.toUpperCase()):""}const v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function h(ee){const re=ee==null?"":String(ee);return/[&<>"']/.test(re)?re.replace(/[&<>"']/g,se=>v[se]):re}function c(ee){return String(ee).replace(/\w\S*/g,re=>re[0].toUpperCase()+re.slice(1).toLowerCase())}function j(ee,re,se){if(ee!==void 0)return ee===!0?{enabled:!0,...se}:ee===!1?{enabled:!1}:i(ee)?ee:{[re]:ee,enabled:!0}}function E(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}const O=Object.freeze(new Set(["__proto__","constructor","prototype"]));function T(ee,re){if(!i(ee))return i(re)?{...re}:re;if(!i(re))return re===void 0?ee:re;const se={...ee};for(const de of Object.keys(re)){if(O.has(de))continue;const ie=re[de];ie!==void 0&&(se[de]=i(ie)&&i(se[de])?T(se[de],ie):ie)}return se}function A(ee,re){if(!i(ee)||!i(re)||ee===re)return re;const se=Object.create(Object.getPrototypeOf(ee));return Object.assign(se,ee,re),se}class P{#e;#t=new Map;#n;constructor(re=256,se=null){this.#e=re,this.#n=se}get size(){return this.#t.size}get max(){return this.#e}set max(re){this.#e=re,this.#r()}has(re){return this.#t.has(re)}get(re){const se=this.#t;if(!se.has(re))return;const de=se.get(re);return se.delete(re),se.set(re,de),de}peek(re){return this.#t.get(re)}set(re,se){const de=this.#t;return de.has(re)&&de.delete(re),de.set(re,se),this.#r(),se}delete(re){const se=this.#t.get(re);return this.#t.delete(re)&&this.#n&&this.#n(se,re),se}clear(){if(this.#n)for(const[re,se]of this.#t)this.#n(se,re);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const re=this.#t;for(;re.size>this.#e;){const se=re.keys().next().value,de=re.get(se);re.delete(se),this.#n&&this.#n(de,se)}}}const L=new Map;function z(ee,re){const se=`${ee||""}|${re?JSON.stringify(re):""}`;let de=L.get(se);return de||(de=new Intl.Collator(ee||void 0,{numeric:!0,sensitivity:"variant",...re}),L.set(se,de)),de}function H(ee,re){if(ee===re)return 0;if(ee==null)return 1;if(re==null)return-1;if(typeof ee=="number"&&typeof re=="number")return Number.isNaN(ee)?Number.isNaN(re)?0:1:Number.isNaN(re)||ee<re?-1:ee>re?1:0;const se=String(ee),de=String(re);return se<de?-1:se>de?1:0}function x(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const F=typeof requestAnimationFrame=="function";function C(ee){return F?requestAnimationFrame(ee):setTimeout(()=>ee(x()),16)}function B(ee){ee!=null&&(F?cancelAnimationFrame(ee):clearTimeout(ee))}function q(ee){let re=null,se=null;const de=()=>{re=null;const oe=se;se=null,ee(...oe||[])},ie=(...oe)=>{se=oe,re===null&&(re=C(de))};return ie.cancel=()=>{B(re),re=null,se=null},ie.flush=()=>{re!==null&&(B(re),de())},ie}function Q(ee,re){let se=null,de=null;const ie=()=>{if(se=null,de===null)return;const ce=de;de=null,ee(...ce),oe()},oe=()=>{se=setTimeout(ie,re),typeof se?.unref=="function"&&se.unref()},ue=(...ce)=>{se===null?(ee(...ce),oe()):(de=ce,clearTimeout(se),oe())};return ue.flush=()=>{if(se!==null&&clearTimeout(se),se=null,de===null)return;const ce=de;de=null,ee(...ce)},ue.cancel=()=>{se!==null&&clearTimeout(se),se=null,de=null},ue.pending=()=>se!==null||de!==null,ue}function Y(ee,re=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ee,{timeout:re}):setTimeout(()=>ee({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function te(ee="l"){return`${ee}${(++J).toString(36)}`}}),Ce("packages/core/src/formatting/rules.js",function(e,G){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return R}}),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 D}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return j}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,R=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Z=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function V(E,O){const T=Number(E),A=Number(O);if(E!==null&&E!==""&&O!==null&&O!==""&&Number.isFinite(T)&&Number.isFinite(A))return T<A?-1:T>A?1:0;const L=String(E??"").toLowerCase(),z=String(O??"").toLowerCase();return L<z?-1:L>z?1:0}function U(E){return E==null||E===""}function D(E,O){if(!O||typeof O!="object")return!1;const{op:T}=O,A=O.value,P=O.value2;switch(T){case"blank":return U(E);case"notBlank":return!U(E);case"true":return E===!0;case"false":return E===!1;default:break}if(U(E))return!1;switch(T){case"eq":return V(E,A)===0;case"ne":return V(E,A)!==0;case"gt":return V(E,A)>0;case"gte":return V(E,A)>=0;case"lt":return V(E,A)<0;case"lte":return V(E,A)<=0;case"between":return V(E,A)>=0&&V(E,P)<=0;case"outside":return V(E,A)<0||V(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(A??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(A??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(A??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(A??"").toLowerCase());default:return!1}}function I(E,O,T){const A=q=>{const Q=String(q).replace("#",""),Y=Q.length===3?Q.split("").map(J=>J+J).join(""):Q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,L,z]=A(E),[H,x,F]=A(O),C=Math.max(0,Math.min(1,T)),B=(q,Q)=>Math.round(q+(Q-q)*C);return`#${[B(P,H),B(L,x),B(z,F)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(E){const O=[];for(const H of E||[]){if(H==null||H==="")continue;const x=H instanceof Date?H.getTime():Number(H);Number.isFinite(x)&&O.push(x)}if(!O.length)return null;O.sort((H,x)=>H-x);let T=0,A=0,P=0;for(const H of O){T++;const x=H-A;A+=x/T,P+=x*(H-A)}const L=S(O,.25),z=S(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:A,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:S(O,.5),q1:L,q3:z,iqr:z-L,sorted:O}}function S(E,O){if(!E.length)return 0;const T=(E.length-1)*Math.max(0,Math.min(1,O)),A=Math.floor(T),P=Math.ceil(T);return A===P?E[A]:E[A]+(T-A)*(E[P]-E[A])}function y(E){for(const O of Array.isArray(E)?E:[])if(!(!O||typeof O!="object")&&(O.when&&W.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function d(E,O){const T=Number(E.value),A=P=>S(O.sorted,P);switch(E.op){case"topPercent":{const P=u(T,10);return{op:"gte",value:A(1-P)}}case"bottomPercent":{const P=u(T,10);return{op:"lte",value:A(P)}}case"topN":{const P=Math.max(1,Math.floor(T)||1),L=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const P=Math.max(1,Math.floor(T)||1),L=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(T)?T:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(T)?T:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(T)&&T>0?T:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function u(E,O){const T=Number.isFinite(E)?E:O,A=T>1?T/100:T;return Math.max(0,Math.min(1,A))}function n(E,O){if(E.from==="minmax")return{...E,min:O.min,max:O.max};if(E.from==="quantile")return{...E,min:S(O.sorted,u(Number(E.low),5)),max:S(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:O.mean-T*O.stddev,max:O.mean+T*O.stddev}}return E}function t(E,O){const T=Array.isArray(E)?E:[];return!O||!O.n?T.map(A=>A&&y([A])?{...A,enabled:!1}:A):T.map(A=>{if(!A||typeof A!="object")return A;if(A.scale&&A.scale.from)return{...A,scale:n(A.scale,O)};if(A.dataBar)return{...A,dataBar:i(A.dataBar,O)};if(A.iconSet)return{...A,iconSet:s(A.iconSet,O)};if(!A.when||!W.includes(A.when.op))return A;const P=d(A.when,O);return P?{...A,when:P}:{...A,enabled:!1}})}function i(E,O){const T=Number.isFinite(Number(E.min))?Number(E.min):void 0,A=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(T!==void 0&&A!==void 0)return{...E,min:T,max:A};if(E.from==="quantile")return{...E,min:T??S(O.sorted,u(Number(E.low),5)),max:A??S(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:T??O.mean-P*O.stddev,max:A??O.mean+P*O.stddev}}return{...E,min:T??O.min,max:A??O.max}}function s(E,O){if(Array.isArray(E.thresholds))return E;const T=r(E),A=[];for(let P=1;P<T;P++)A.push(S(O.sorted,P/T));return{...E,thresholds:A}}function r(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const O=g[E.set];return O?O.length:3}function o(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function l(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function a(E,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function p(E,O){const T="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const L=P<E?"#f5a623":"#d0d0d0";A+=`<path transform="translate(${P*16},0)" d="${T}" fill="${L}"/>`}return`${A}</svg>`}const m=Object.freeze([a("#c0392b","down"),a("#e0a800","right"),a("#2e7d32","up")]),b=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),g=Object.freeze({arrows:m,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>p(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(A=>/^\s*(url\(|data:|<)/.test(String(A))&&String(A).trim().startsWith("<")?o(String(A)):String(A));const O=E.set||"arrows";if(O==="ratings"){const A=r(E),P=[];for(let L=1;L<=A;L++)P.push(o(p(L,A)));return P}const T=g[O];return T?T.map(o):($(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),m.map(o))}function v(E){const O=Number(E.min),A=Number(E.max)-O,P=E.colour||E.color||"#5b9bd5",L=E.negativeColour||E.negativeColor||"#d13438",z=E.direction==="rtl"?"left":"right",H=F=>Math.max(0,Math.min(1,(F-O)/A))*100,x=A?Math.max(0,Math.min(100,(0-O)/A*100)):0;return F=>{if(U(F))return null;const C=Number(F);if(!Number.isFinite(C)||!A)return null;const B=H(C),q=Math.min(B,x),Q=Math.max(B,x),Y=C>=0?P:L;return{backgroundImage:`linear-gradient(to ${z}, transparent ${q}%, ${Y} ${q}%, ${Y} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function h(E){const O=w(E),T=E.reverse?[...O].reverse():O,A=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,L=E.set==="ratings"?P*r(E):P;return z=>{if(U(z))return null;const H=Number(z);if(!Number.isFinite(H))return null;let x=0;for(const C of A)H>=C&&x++;const F=T[Math.min(x,T.length-1)];return F?{backgroundImage:F,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${P}px`,paddingLeft:`${L+4}px`}:null}}function c(E){const O=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],T=Number(E.min),A=Number(E.max),P=A-T,L=O.length-1,z=[];for(let x=0;x<=L;x++)z.push(L?x/L:0);const H=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(O.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(H)&&P&&H>Math.min(T,A)&&H<Math.max(T,A)){const x=L/2,F=Math.max(0,Math.min(1,(H-T)/P));for(let C=0;C<=L;C++)z[C]=C<=x?x?C/x*F:F:F+(C-x)/(L-x)*(1-F)}else Number.isFinite(H)&&$("formatting.scale.mid.range",`a scale's "mid" (${H}) is outside its min..max range, so it was ignored.`);return x=>{const F=Number(x);if(!Number.isFinite(F)||!P)return null;const C=Math.max(0,Math.min(1,(F-T)/P));let B=0;for(;B<L-1&&C>z[B+1];)B++;const q=z[B+1]-z[B],Q=q>0?(C-z[B])/q:0;return{background:I(O[B],O[B+1],Math.max(0,Math.min(1,Q)))}}}function j(E,O=null){const T=y(E)?t(E,O):E,A=(Array.isArray(T)?T:[]).filter(L=>L&&typeof L=="object");if(!A.length)return()=>null;const P=A.map(L=>L.scale?{scale:c(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:v(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:h(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const z=L?L.value:void 0;let H=null;for(const x of P){if(!x.enabled)continue;if(x.scale){const C=x.scale(z);C&&(H={...H||{},...C});continue}if(!D(z,x.when))continue;const F=M(x.style)?x.style(L):x.style;if(F&&(H={...H||{},...F}),x.stop)break}return H}}}),Ce("packages/core/src/formula/parse.js",function(e,G){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const _="num",M="str",$="ref",R="name",W="op",Z="end",V=["<=",">=","<>","!="],U="+-*/^%(),<>=";class D extends Error{constructor(r,o){super(r),this.name="FormulaError",this.at=o}}function I(s){const r=[];let o=0;for(;o<s.length;){const l=s[o];if(l===" "||l===" "||l===`
6
+ var rr=Object.create(null),ir=Object.create(null);function Ce(e,G){rr[e]=G}function Un(e){var G=ir[e];if(G)return G;var _=Object.create(null);ir[e]=_;var M=rr[e];if(!M)throw new Error("[lattice] missing module: "+e);return M(_,Un),_}Ce("packages/core/src/internal/util.js",function(e,G){"use strict";Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"reportedWarnings",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"warnOnce",{enumerable:!0,get:function(){return S}}),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 u}}),Object.defineProperty(e,"invariant",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DEV",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"isNil",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"isBlank",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"isCtor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"pathGetter",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"pathSetter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"getPath",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"setPath",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"humanise",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"escapeHtml",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"titleCase",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"expand",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"toArray",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"merge",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"mergeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"Lru",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"collator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"defaultCompare",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"now",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"nextFrame",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"cancelFrame",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"frameBatched",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"settleDebounce",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(e,"whenIdle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"uid",{enumerable:!0,get:function(){return te}});const _="1.75.0";async function M(){return _}const $="1.75.0",R=new Set,W=2e3;function Z(ee){if(R.add(ee),R.size>W){const re=R.values().next().value;re!==void 0&&R.delete(re)}}const V=[],U=500;function D(ee,re,se){V.push({key:ee,level:re,message:se.map(de=>typeof de=="string"?de:I(de)).join(" "),at:Date.now()}),V.length>U&&V.shift()}function I(ee){if(ee instanceof Error)return ee.message;try{return JSON.stringify(ee)}catch{return String(ee)}}function k(){return V.map(ee=>({...ee}))}function S(ee,...re){R.has(ee)||(Z(ee),D(ee,"warn",re),console.warn("[lattice]",...re))}function y(ee,...re){R.has(ee)||(Z(ee),D(ee,"info",re),console.info("[lattice]",...re))}function d(){R.clear(),V.length=0}function u(ee,re){const se=new Error(`[lattice] ${ee}`);throw re!==void 0&&(se.cause=re),se}function n(ee,re){ee||u(re)}const t=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(ee){return ee!==null&&typeof ee=="object"&&!Array.isArray(ee)}function s(ee){return typeof ee=="function"}function r(ee){return ee==null}function o(ee){return ee==null||ee===""}function l(ee){return typeof ee!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(ee))?!0:!!(ee.prototype&&Object.getOwnPropertyNames(ee.prototype).length>1)}const a=new Map;function p(ee){let re=a.get(ee);if(re)return re;if(!ee.includes("."))re=se=>se?.[ee];else{const se=ee.split("."),de=se.length;re=ie=>{let oe=ie;for(let ue=0;ue<de;ue++){if(oe==null)return;oe=oe[se[ue]]}return oe}}return a.set(ee,re),re}const m=new Map;function b(ee){let re=m.get(ee);if(re)return re;if(!ee.includes("."))re=(se,de)=>{se!=null&&(se[ee]=de)};else{const se=ee.split("."),de=se.length-1;re=(ie,oe)=>{let ue=ie;for(let ce=0;ce<de;ce++){if(ue==null)return;const pe=se[ce];ue[pe]==null&&(ue[pe]={}),ue=ue[pe]}ue!=null&&(ue[se[de]]=oe)}}return m.set(ee,re),re}function g(ee,re){return p(re)(ee)}function f(ee,re,se){b(re)(ee,se)}function w(ee){return ee?(ee.includes(".")?ee.slice(ee.lastIndexOf(".")+1):ee).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,se=>se.toUpperCase()):""}const v={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function h(ee){const re=ee==null?"":String(ee);return/[&<>"']/.test(re)?re.replace(/[&<>"']/g,se=>v[se]):re}function c(ee){return String(ee).replace(/\w\S*/g,re=>re[0].toUpperCase()+re.slice(1).toLowerCase())}function j(ee,re,se){if(ee!==void 0)return ee===!0?{enabled:!0,...se}:ee===!1?{enabled:!1}:i(ee)?ee:{[re]:ee,enabled:!0}}function E(ee){return ee==null?[]:Array.isArray(ee)?ee:[ee]}const O=Object.freeze(new Set(["__proto__","constructor","prototype"]));function T(ee,re){if(!i(ee))return i(re)?{...re}:re;if(!i(re))return re===void 0?ee:re;const se={...ee};for(const de of Object.keys(re)){if(O.has(de))continue;const ie=re[de];ie!==void 0&&(se[de]=i(ie)&&i(se[de])?T(se[de],ie):ie)}return se}function A(ee,re){if(!i(ee)||!i(re)||ee===re)return re;const se=Object.create(Object.getPrototypeOf(ee));return Object.assign(se,ee,re),se}class P{#e;#t=new Map;#n;constructor(re=256,se=null){this.#e=re,this.#n=se}get size(){return this.#t.size}get max(){return this.#e}set max(re){this.#e=re,this.#r()}has(re){return this.#t.has(re)}get(re){const se=this.#t;if(!se.has(re))return;const de=se.get(re);return se.delete(re),se.set(re,de),de}peek(re){return this.#t.get(re)}set(re,se){const de=this.#t;return de.has(re)&&de.delete(re),de.set(re,se),this.#r(),se}delete(re){const se=this.#t.get(re);return this.#t.delete(re)&&this.#n&&this.#n(se,re),se}clear(){if(this.#n)for(const[re,se]of this.#t)this.#n(se,re);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const re=this.#t;for(;re.size>this.#e;){const se=re.keys().next().value,de=re.get(se);re.delete(se),this.#n&&this.#n(de,se)}}}const L=new Map;function z(ee,re){const se=`${ee||""}|${re?JSON.stringify(re):""}`;let de=L.get(se);return de||(de=new Intl.Collator(ee||void 0,{numeric:!0,sensitivity:"variant",...re}),L.set(se,de)),de}function H(ee,re){if(ee===re)return 0;if(ee==null)return 1;if(re==null)return-1;if(typeof ee=="number"&&typeof re=="number")return Number.isNaN(ee)?Number.isNaN(re)?0:1:Number.isNaN(re)||ee<re?-1:ee>re?1:0;const se=String(ee),de=String(re);return se<de?-1:se>de?1:0}function x(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const F=typeof requestAnimationFrame=="function";function C(ee){return F?requestAnimationFrame(ee):setTimeout(()=>ee(x()),16)}function B(ee){ee!=null&&(F?cancelAnimationFrame(ee):clearTimeout(ee))}function q(ee){let re=null,se=null;const de=()=>{re=null;const oe=se;se=null,ee(...oe||[])},ie=(...oe)=>{se=oe,re===null&&(re=C(de))};return ie.cancel=()=>{B(re),re=null,se=null},ie.flush=()=>{re!==null&&(B(re),de())},ie}function Q(ee,re){let se=null,de=null;const ie=()=>{if(se=null,de===null)return;const ce=de;de=null,ee(...ce),oe()},oe=()=>{se=setTimeout(ie,re),typeof se?.unref=="function"&&se.unref()},ue=(...ce)=>{se===null?(ee(...ce),oe()):(de=ce,clearTimeout(se),oe())};return ue.flush=()=>{if(se!==null&&clearTimeout(se),se=null,de===null)return;const ce=de;de=null,ee(...ce)},ue.cancel=()=>{se!==null&&clearTimeout(se),se=null,de=null},ue.pending=()=>se!==null||de!==null,ue}function Y(ee,re=50){return typeof requestIdleCallback=="function"?requestIdleCallback(ee,{timeout:re}):setTimeout(()=>ee({timeRemaining:()=>0,didTimeout:!0}),1)}let J=0;function te(ee="l"){return`${ee}${(++J).toString(36)}`}}),Ce("packages/core/src/formatting/rules.js",function(e,G){"use strict";Object.defineProperty(e,"RULE_OPS",{enumerable:!0,get:function(){return R}}),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 D}}),Object.defineProperty(e,"mixColour",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"summariseColumn",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"quantileOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"needsDistribution",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveDistribution",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ICON_SETS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return j}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,R=Object.freeze(["eq","ne","gt","gte","lt","lte","between","outside","contains","notContains","startsWith","endsWith","blank","notBlank","true","false"]),W=Object.freeze(["topPercent","bottomPercent","topN","bottomN","aboveMean","belowMean","aboveMedian","belowMedian","zAbove","zBelow","outlier"]),Z=Object.freeze({topPercent:"In the top %",bottomPercent:"In the bottom %",topN:"In the top N",bottomN:"In the bottom N",aboveMean:"Above average",belowMean:"Below average",aboveMedian:"Above the median",belowMedian:"Below the median",zAbove:"Standard deviations above the mean",zBelow:"Standard deviations below the mean",outlier:"An outlier"});function V(E,O){const T=Number(E),A=Number(O);if(E!==null&&E!==""&&O!==null&&O!==""&&Number.isFinite(T)&&Number.isFinite(A))return T<A?-1:T>A?1:0;const L=String(E??"").toLowerCase(),z=String(O??"").toLowerCase();return L<z?-1:L>z?1:0}function U(E){return E==null||E===""}function D(E,O){if(!O||typeof O!="object")return!1;const{op:T}=O,A=O.value,P=O.value2;switch(T){case"blank":return U(E);case"notBlank":return!U(E);case"true":return E===!0;case"false":return E===!1;default:break}if(U(E))return!1;switch(T){case"eq":return V(E,A)===0;case"ne":return V(E,A)!==0;case"gt":return V(E,A)>0;case"gte":return V(E,A)>=0;case"lt":return V(E,A)<0;case"lte":return V(E,A)<=0;case"between":return V(E,A)>=0&&V(E,P)<=0;case"outside":return V(E,A)<0||V(E,P)>0;case"contains":return String(E).toLowerCase().includes(String(A??"").toLowerCase());case"notContains":return!String(E).toLowerCase().includes(String(A??"").toLowerCase());case"startsWith":return String(E).toLowerCase().startsWith(String(A??"").toLowerCase());case"endsWith":return String(E).toLowerCase().endsWith(String(A??"").toLowerCase());default:return!1}}function I(E,O,T){const A=q=>{const Q=String(q).replace("#",""),Y=Q.length===3?Q.split("").map(J=>J+J).join(""):Q;return[0,2,4].map(J=>parseInt(Y.slice(J,J+2),16)||0)},[P,L,z]=A(E),[H,x,F]=A(O),C=Math.max(0,Math.min(1,T)),B=(q,Q)=>Math.round(q+(Q-q)*C);return`#${[B(P,H),B(L,x),B(z,F)].map(q=>q.toString(16).padStart(2,"0")).join("")}`}function k(E){const O=[];for(const H of E||[]){if(H==null||H==="")continue;const x=H instanceof Date?H.getTime():Number(H);Number.isFinite(x)&&O.push(x)}if(!O.length)return null;O.sort((H,x)=>H-x);let T=0,A=0,P=0;for(const H of O){T++;const x=H-A;A+=x/T,P+=x*(H-A)}const L=S(O,.25),z=S(O,.75);return{n:O.length,min:O[0],max:O[O.length-1],mean:A,stddev:O.length>1?Math.sqrt(P/(O.length-1)):0,median:S(O,.5),q1:L,q3:z,iqr:z-L,sorted:O}}function S(E,O){if(!E.length)return 0;const T=(E.length-1)*Math.max(0,Math.min(1,O)),A=Math.floor(T),P=Math.ceil(T);return A===P?E[A]:E[A]+(T-A)*(E[P]-E[A])}function y(E){for(const O of Array.isArray(E)?E:[])if(!(!O||typeof O!="object")&&(O.when&&W.includes(O.when.op)||O.scale&&O.scale.from||O.dataBar&&!(Number.isFinite(Number(O.dataBar.min))&&Number.isFinite(Number(O.dataBar.max)))||O.iconSet&&!Array.isArray(O.iconSet.thresholds)))return!0;return!1}function d(E,O){const T=Number(E.value),A=P=>S(O.sorted,P);switch(E.op){case"topPercent":{const P=u(T,10);return{op:"gte",value:A(1-P)}}case"bottomPercent":{const P=u(T,10);return{op:"lte",value:A(P)}}case"topN":{const P=Math.max(1,Math.floor(T)||1),L=Math.max(0,O.sorted.length-P);return{op:"gte",value:O.sorted[L]}}case"bottomN":{const P=Math.max(1,Math.floor(T)||1),L=Math.min(O.sorted.length-1,P-1);return{op:"lte",value:O.sorted[L]}}case"aboveMean":return{op:"gt",value:O.mean};case"belowMean":return{op:"lt",value:O.mean};case"aboveMedian":return{op:"gt",value:O.median};case"belowMedian":return{op:"lt",value:O.median};case"zAbove":return O.stddev?{op:"gte",value:O.mean+(Number.isFinite(T)?T:2)*O.stddev}:null;case"zBelow":return O.stddev?{op:"lte",value:O.mean-(Number.isFinite(T)?T:2)*O.stddev}:null;case"outlier":{const P=(Number.isFinite(T)&&T>0?T:1.5)*O.iqr;return O.iqr?{op:"outside",value:O.q1-P,value2:O.q3+P}:null}default:return null}}function u(E,O){const T=Number.isFinite(E)?E:O,A=T>1?T/100:T;return Math.max(0,Math.min(1,A))}function n(E,O){if(E.from==="minmax")return{...E,min:O.min,max:O.max};if(E.from==="quantile")return{...E,min:S(O.sorted,u(Number(E.low),5)),max:S(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const T=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:O.mean-T*O.stddev,max:O.mean+T*O.stddev}}return E}function t(E,O){const T=Array.isArray(E)?E:[];return!O||!O.n?T.map(A=>A&&y([A])?{...A,enabled:!1}:A):T.map(A=>{if(!A||typeof A!="object")return A;if(A.scale&&A.scale.from)return{...A,scale:n(A.scale,O)};if(A.dataBar)return{...A,dataBar:i(A.dataBar,O)};if(A.iconSet)return{...A,iconSet:s(A.iconSet,O)};if(!A.when||!W.includes(A.when.op))return A;const P=d(A.when,O);return P?{...A,when:P}:{...A,enabled:!1}})}function i(E,O){const T=Number.isFinite(Number(E.min))?Number(E.min):void 0,A=Number.isFinite(Number(E.max))?Number(E.max):void 0;if(T!==void 0&&A!==void 0)return{...E,min:T,max:A};if(E.from==="quantile")return{...E,min:T??S(O.sorted,u(Number(E.low),5)),max:A??S(O.sorted,u(Number(E.high),95))};if(E.from==="stddev"){const P=Number.isFinite(Number(E.deviations))?Number(E.deviations):2;return{...E,min:T??O.mean-P*O.stddev,max:A??O.mean+P*O.stddev}}return{...E,min:T??O.min,max:A??O.max}}function s(E,O){if(Array.isArray(E.thresholds))return E;const T=r(E),A=[];for(let P=1;P<T;P++)A.push(S(O.sorted,P/T));return{...E,thresholds:A}}function r(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.length;if(Number.isFinite(Number(E.count))&&Number(E.count)>=2)return Math.floor(Number(E.count));const O=g[E.set];return O?O.length:3}function o(E){return`url("data:image/svg+xml,${encodeURIComponent(E)}")`}function l(E){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="6" fill="${E}"/></svg>`}function a(E,O){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polygon points="${O==="up"?"8,2 14,13 2,13":O==="down"?"2,3 14,3 8,14":"4,2 14,8 4,14"}" fill="${E}"/></svg>`}function p(E,O){const T="M8 1l1.9 3.9 4.3.6-3.1 3 .7 4.3L8 13.8 4.2 15.8l.7-4.3-3.1-3 4.3-.6z";let A=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${O*16} 16">`;for(let P=0;P<O;P++){const L=P<E?"#f5a623":"#d0d0d0";A+=`<path transform="translate(${P*16},0)" d="${T}" fill="${L}"/>`}return`${A}</svg>`}const m=Object.freeze([a("#c0392b","down"),a("#e0a800","right"),a("#2e7d32","up")]),b=Object.freeze([l("#d13438"),l("#f5a623"),l("#2e9e44")]),g=Object.freeze({arrows:m,trafficLights:b,ratings:Object.freeze([1,2,3,4,5].map(E=>p(E,5)))}),f=Object.freeze({arrows:"Arrows",trafficLights:"Traffic lights",ratings:"Ratings"});function w(E){if(Array.isArray(E.icons)&&E.icons.length>=2)return E.icons.map(A=>/^\s*(url\(|data:|<)/.test(String(A))&&String(A).trim().startsWith("<")?o(String(A)):String(A));const O=E.set||"arrows";if(O==="ratings"){const A=r(E),P=[];for(let L=1;L<=A;L++)P.push(o(p(L,A)));return P}const T=g[O];return T?T.map(o):($(`iconSet:${O}`,`unknown icon set '${O}'; falling back to arrows.`),m.map(o))}function v(E){const O=Number(E.min),A=Number(E.max)-O,P=E.colour||E.color||"#5b9bd5",L=E.negativeColour||E.negativeColor||"#d13438",z=E.direction==="rtl"?"left":"right",H=F=>Math.max(0,Math.min(1,(F-O)/A))*100,x=A?Math.max(0,Math.min(100,(0-O)/A*100)):0;return F=>{if(U(F))return null;const C=Number(F);if(!Number.isFinite(C)||!A)return null;const B=H(C),q=Math.min(B,x),Q=Math.max(B,x),Y=C>=0?P:L;return{backgroundImage:`linear-gradient(to ${z}, transparent ${q}%, ${Y} ${q}%, ${Y} ${Q}%, transparent ${Q}%)`,backgroundRepeat:"no-repeat",backgroundPosition:"0 0"}}}function h(E){const O=w(E),T=E.reverse?[...O].reverse():O,A=(Array.isArray(E.thresholds)?E.thresholds:[]).map(Number).filter(Number.isFinite),P=Number.isFinite(Number(E.size))?Number(E.size):16,L=E.set==="ratings"?P*r(E):P;return z=>{if(U(z))return null;const H=Number(z);if(!Number.isFinite(H))return null;let x=0;for(const C of A)H>=C&&x++;const F=T[Math.min(x,T.length-1)];return F?{backgroundImage:F,backgroundRepeat:"no-repeat",backgroundPosition:"left center",backgroundSize:`${L}px ${P}px`,paddingLeft:`${L+4}px`}:null}}function c(E){const O=Array.isArray(E.colours)&&E.colours.length>=2?E.colours:["#f8f9fa","#1a6bc7"],T=Number(E.min),A=Number(E.max),P=A-T,L=O.length-1,z=[];for(let x=0;x<=L;x++)z.push(L?x/L:0);const H=Number(E.mid);if(E.mid!==void 0&&E.mid!==null)if(O.length%2===0)$("formatting.scale.mid.even",`a scale's "mid" needs an odd number of colours (a middle stop to pin); ${O.length} were given, so "mid" was ignored.`);else if(Number.isFinite(H)&&P&&H>Math.min(T,A)&&H<Math.max(T,A)){const x=L/2,F=Math.max(0,Math.min(1,(H-T)/P));for(let C=0;C<=L;C++)z[C]=C<=x?x?C/x*F:F:F+(C-x)/(L-x)*(1-F)}else Number.isFinite(H)&&$("formatting.scale.mid.range",`a scale's "mid" (${H}) is outside its min..max range, so it was ignored.`);return x=>{const F=Number(x);if(!Number.isFinite(F)||!P)return null;const C=Math.max(0,Math.min(1,(F-T)/P));let B=0;for(;B<L-1&&C>z[B+1];)B++;const q=z[B+1]-z[B],Q=q>0?(C-z[B])/q:0;return{background:I(O[B],O[B+1],Math.max(0,Math.min(1,Q)))}}}function j(E,O=null){const T=y(E)?t(E,O):E,A=(Array.isArray(T)?T:[]).filter(L=>L&&typeof L=="object");if(!A.length)return()=>null;const P=A.map(L=>L.scale?{scale:c(L.scale),enabled:L.enabled!==!1}:L.dataBar?{scale:v(L.dataBar),enabled:L.enabled!==!1}:L.iconSet?{scale:h(L.iconSet),enabled:L.enabled!==!1}:{when:L.when,style:L.style,stop:L.stopIfTrue!==!1,enabled:L.enabled!==!1});return L=>{const z=L?L.value:void 0;let H=null;for(const x of P){if(!x.enabled)continue;if(x.scale){const C=x.scale(z);C&&(H={...H||{},...C});continue}if(!D(z,x.when))continue;const F=M(x.style)?x.style(L):x.style;if(F&&(H={...H||{},...F}),x.stop)break}return H}}}),Ce("packages/core/src/formula/parse.js",function(e,G){"use strict";Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"tokenise",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return i}});const _="num",M="str",$="ref",R="name",W="op",Z="end",V=["<=",">=","<>","!="],U="+-*/^%(),<>=";class D extends Error{constructor(r,o){super(r),this.name="FormulaError",this.at=o}}function I(s){const r=[];let o=0;for(;o<s.length;){const l=s[o];if(l===" "||l===" "||l===`
7
7
  `||l==="\r"){o++;continue}if(l>="0"&&l<="9"){o=S(s,o,r);continue}if(l==="."&&s[o+1]>="0"&&s[o+1]<="9"){o=S(s,o,r);continue}if(l==='"'||l==="'"){o=y(s,o,r);continue}if(l==="["){const p=s.indexOf("]",o+1);if(p<0)throw new D("a [column reference] was opened and never closed",o);r.push({kind:$,value:s.slice(o+1,p).trim(),at:o}),o=p+1;continue}if(k(l)){o=d(s,o,r);continue}const a=s.slice(o,o+2);if(V.includes(a)){r.push({kind:W,value:a==="!="?"<>":a,at:o}),o+=2;continue}if(U.includes(l)){r.push({kind:W,value:l,at:o}),o++;continue}throw new D(`unexpected character ${JSON.stringify(l)}`,o)}return r.push({kind:Z,value:null,at:s.length}),r}function k(s){return/[A-Za-z_À-￿]/.test(s)}function S(s,r,o){let l=r,a=!1;for(;l<s.length;){const p=s[l];if(p>="0"&&p<="9"){l++;continue}if(p==="."&&!a){a=!0,l++;continue}if((p==="e"||p==="E")&&/[0-9+-]/.test(s[l+1]||"")){for(l+=2;l<s.length&&s[l]>="0"&&s[l]<="9";)l++;break}break}return o.push({kind:_,value:Number(s.slice(r,l)),at:r}),l}function y(s,r,o){const l=s[r];let a=r+1,p="";for(;a<s.length;){if(s[a]===l){if(s[a+1]===l){p+=l,a+=2;continue}return o.push({kind:M,value:p,at:r}),a+1}p+=s[a],a++}throw new D("a string was opened and never closed",r)}function d(s,r,o){let l=r;for(;l<s.length&&/[A-Za-z0-9_.À-￿]/.test(s[l]);)l++;const a=s.slice(r,l);let p=l;for(;p<s.length&&s[p]===" ";)p++;return o.push({kind:s[p]==="("?R:$,value:a,at:r}),l}const u={"=":1,"<>":1,"<":1,"<=":1,">":1,">=":1,"+":2,"-":2,"*":3,"/":3,"^":4};function n(s){const r=String(s??"").replace(/^\s*=/,"");if(!r.trim())throw new D("the formula is empty");const o=I(r);let l=0;const a=()=>o[l],p=()=>o[l++],m=c=>{const j=a();if(j.kind!==W||j.value!==c)throw new D(`expected ${JSON.stringify(c)}`,j.at);l++},b=c=>{let j=g();for(;;){const E=a();if(E.kind!==W)break;const O=u[E.value];if(!O||O<c)break;l++;const T=b(E.value==="^"?O:O+1);j={kind:"bin",op:E.value,left:j,right:T}}return j},g=()=>{const c=a();return c.kind===W&&(c.value==="-"||c.value==="+")?(l++,{kind:"unary",op:c.value,arg:g()}):f()},f=()=>{let c=w();for(;a().kind===W&&a().value==="%";)l++,c={kind:"unary",op:"%",arg:c};return c},w=()=>{const c=p();if(c.kind===_)return{kind:"num",value:c.value};if(c.kind===M)return{kind:"str",value:c.value};if(c.kind===$)return{kind:"ref",name:c.value};if(c.kind===R){m("(");const j=[];if(!(a().kind===W&&a().value===")"))for(;;){if(j.push(b(1)),a().kind===W&&a().value===","){l++;continue}break}return m(")"),{kind:"call",name:String(c.value).toUpperCase(),args:j}}if(c.kind===W&&c.value==="("){const j=b(1);return m(")"),j}throw c.kind===Z?new D("the formula ends unexpectedly",c.at):new D(`unexpected ${JSON.stringify(c.value)}`,c.at)},v=b(1),h=a();if(h.kind!==Z)throw new D(`unexpected ${JSON.stringify(h.value)}: is an operator missing?`,h.at);return v}function t(s){const r=new Set,o=l=>{if(!(!l||typeof l!="object")){if(l.kind==="ref"){r.add(String(l.name));return}if(l.kind==="bin"){o(l.left),o(l.right);return}if(l.kind==="unary"){o(l.arg);return}if(l.kind==="call")for(const a of l.args)o(a)}};return o(s),[...r]}function i(s){return typeof s=="string"&&/^\s*=/.test(s)&&s.trim()!=="="}}),Ce("packages/core/src/formula/evaluate.js",function(e,G){"use strict";Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateAst",{enumerable:!0,get:function(){return S}});const M=G("packages/core/src/formula/parse.js").FormulaError;function $(y){if(y==null||y==="")return 0;if(typeof y=="boolean")return y?1:0;if(y instanceof Date)return y.getTime();const d=typeof y=="number"?y:Number(String(y).replace(/[,\s]/g,""));if(!Number.isFinite(d))throw new M(`${JSON.stringify(y)} is not a number`);return d}function R(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 u of y){if(Array.isArray(u)){for(const n of u)n!=null&&n!==""&&d.push($(n));continue}u==null||u===""||d.push($(u))}return d}function V(y,d){const u=10**d,n=y*u;return Math.sign(n)*Math.round(Math.abs(n)+Number.EPSILON*Math.abs(n))/u}function U(y,d){if(!y.length)return 0;const u=y.slice().sort((s,r)=>s-r),n=(u.length-1)*Math.min(1,Math.max(0,d)),t=Math.floor(n),i=Math.ceil(n);return t===i?u[t]:u[t]+(n-t)*(u[i]-u[t])}function D(y,d){let u=0,n=0,t=0;for(const s of y){u++;const r=s-n;n+=r/u,t+=r*(s-n)}const i=d?u-1:u;return i>0?Math.sqrt(t/i):0}const I={SUM:y=>Z(y).reduce((d,u)=>d+u,0),AVERAGE:y=>{const d=Z(y);return d.length?d.reduce((u,n)=>u+n,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,u)=>d*u,1),ROUND:y=>V($(y[0]),y.length>1?$(y[1]):0),ROUNDDOWN:y=>{const d=10**(y.length>1?$(y[1]):0),u=$(y[0])*d;return(u<0?Math.ceil(u):Math.floor(u))/d},ROUNDUP:y=>{const d=10**(y.length>1?$(y[1]):0),u=$(y[0])*d;return(u<0?Math.floor(u):Math.ceil(u))/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 M("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(R).join(""),LEN:y=>R(y[0]).length,UPPER:y=>R(y[0]).toUpperCase(),LOWER:y=>R(y[0]).toLowerCase(),TRIM:y=>R(y[0]).trim(),LEFT:y=>R(y[0]).slice(0,y.length>1?$(y[1]):1),RIGHT:y=>{const d=y.length>1?$(y[1]):1;return d<=0?"":R(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=>D(Z(y),!0),STDEVP:y=>D(Z(y),!1),VAR:y=>{const d=D(Z(y),!0);return d*d},VARP:y=>{const d=D(Z(y),!1);return d*d},COUNTDISTINCT:y=>{const d=new Set;for(const u of y){const n=Array.isArray(u)?u:[u];for(const t of n)t!=null&&t!==""&&d.add(t)}return d.size},IQR:y=>{const d=Z(y);return U(d,.75)-U(d,.25)}};I.AVG=I.AVERAGE,I.CEIL=I.CEILING,I.POW=I.POWER,I.STDEVS=I.STDEV,I.PERCENTILEINC=I.PERCENTILE;function k(y,d){const u=Number(y),n=Number(d);if(y!==null&&y!==""&&d!==null&&d!==""&&Number.isFinite(u)&&Number.isFinite(n))return u<n?-1:u>n?1:0;const i=R(y).toLowerCase(),s=R(d).toLowerCase();return i<s?-1:i>s?1:0}function S(y,d={}){const u=typeof d.lookup=="function"?d.lookup:null,n=d.functions?{...I,...d.functions}:I,t=i=>{switch(i.kind){case"num":return i.value;case"str":return i.value;case"ref":{if(!u)throw new M(`there is no column called ${JSON.stringify(i.name)} here`);const s=u(String(i.name));if(s===void 0)throw new M(`there is no column called ${JSON.stringify(i.name)}`);return s}case"unary":{if(i.op==="%")return $(t(i.arg))/100;const s=$(t(i.arg));return i.op==="-"?-s:s}case"bin":{const s=i.op;if(s==="=")return k(t(i.left),t(i.right))===0;if(s==="<>")return k(t(i.left),t(i.right))!==0;if(s==="<")return k(t(i.left),t(i.right))<0;if(s==="<=")return k(t(i.left),t(i.right))<=0;if(s===">")return k(t(i.left),t(i.right))>0;if(s===">=")return k(t(i.left),t(i.right))>=0;const r=$(t(i.left)),o=$(t(i.right));if(s==="+")return r+o;if(s==="-")return r-o;if(s==="*")return r*o;if(s==="^")return r**o;if(s==="/"){if(o===0)throw new M("division by zero");return r/o}throw new M(`unknown operator ${JSON.stringify(s)}`)}case"call":{const s=n[i.name];if(typeof s!="function")throw new M(`there is no function called ${i.name}`);return s(i.args.map(t),d)}default:throw new M("the formula could not be read")}};return t(y)}}),Ce("packages/core/src/formula/index.js",function(e,G){"use strict";Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return R}}),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 D}}),Object.defineProperty(e,"rowLookup",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return k}});const _=G("packages/core/src/formula/parse.js"),M=_.parseFormula,$=_.referencesOf,R=_.looksLikeFormula,W=_.FormulaError,Z=_.tokenise,V=G("packages/core/src/formula/evaluate.js"),U=V.evaluateAst,D=V.FUNCTIONS;function I(S){const{grid:y,row:d,data:u}=S||{},n=o=>String(o).toLowerCase().replace(/[\s_-]/g,""),t=y&&y.columns&&typeof y.columns.all=="function"?y.columns.all():[],i=y&&y.permissions,s=i&&typeof i.isReadable=="function"?o=>i.isReadable(o):()=>!0,r=new Set;for(const o of t)s(o)||(r.add(n(o.id)),o.field&&r.add(n(o.field)),o.title&&r.add(n(o.title)));return o=>{const l=n(o);if(r.has(l))throw new W(`"${o}" cannot be read`);for(const a of t)if(n(a.id)===l||a.field&&n(a.field)===l||a.title&&n(a.title)===l)return d&&y.rows&&typeof y.rows.value=="function"?y.rows.value(d.key,a.id):u?u[a.field||a.id]:void 0;if(u&&typeof u=="object"){for(const a of Object.keys(u))if(n(a)===l){if(!s(a))throw new W(`"${o}" cannot be read`);return u[a]}}}}function k(S,y={}){try{const d=M(S);return{ok:!0,value:U(d,{lookup:I(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}}}}),Ce("packages/core/src/defaults.js",function(e,G){"use strict";Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"applyDefaults",{enumerable:!0,get:function(){return U}});const _=G("packages/core/src/internal/util.js"),M=_.isObject,$=_.merge,R=_.warnOnce;let W=null;function Z(D){if(Array.isArray(D))return D.map(Z);if(!M(D)||Object.getPrototypeOf(D)!==Object.prototype&&Object.getPrototypeOf(D)!==null)return D;const I={};for(const[k,S]of Object.entries(D))I[k]=Z(S);return I}function V(D){return D===void 0?Z(W??{}):D===null?(W=null,{}):M(D)?(W=Z(D),Z(W)):(R("defaults:type",`defaults() expects a configuration object, or null to clear it, but got ${Array.isArray(D)?"an array":typeof D}. The call was ignored and the defaults are unchanged.`),Z(W??{}))}function U(D){return W===null?D:$(Z(W),D)}}),Ce("packages/core/src/events/names.js",function(e,G){"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","detail:cell:edit:start","detail:cell:edit:end","detail:row:edit:start","detail:row:edit:end","detail:cell:changed","toolpanel:focus","highlight:changed","find:changed","tree:loading","tree:loaded","tree:loadFailed","tree:loadAborted","state:changed","state:reset","history:changed","history:applied","views:changed","view:applied","view:saved","view:removed","view:renamed","view:default","validation:failed","validation:cleared","formatting:changed","redaction:changed","permissions:changed","presentation:changed","presentation:started","presentation:ended","presentation:view","presentation:scale","presentation:spotlight","presentation:captured","comment:added","comment:edited","comment:deleted","comment:failed","comment:resolved","comment:unresolved","comment:threadOpened","comment:threadClosed","comment:indexLoaded","presence:published","presence:joined","presence:updated","presence:left","presence:failed","presence:lockRefused","diff:changed","diff:swapped","timeline:attached","timeline:detached","timeline:seek","timeline:seeking","annotation:changed","export:progress","export:request","export:done","shortcuts:opened","shortcuts:closed","print:before","print:after","beforeEdit","beforeSort","beforeFilter","beforeColumnMove","beforeColumnResize","beforeColumnHide","beforeSelect","beforeRowAdd","beforeDelete","beforeRowMove","beforeGroup","beforeRowReceive","edit:cancelled","sort:cancelled","filter:cancelled","columnMove:cancelled","columnResize:cancelled","columnHide:cancelled","selection:cancelled","rowAdd:cancelled","delete:cancelled","rowMove:cancelled","group:cancelled","rowReceive:cancelled"]),M=new Set(_);function $(R){return R==="*"||M.has(R)}}),Ce("packages/core/src/events/bus.js",function(e,G){"use strict";Object.defineProperty(e,"WILDCARD",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return d}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.uid,R=_.DEV,Z=G("packages/core/src/events/names.js").isKnownEvent,V="*";function U(u,n){!R||Z(n)||M(`bus.unknown:${n}`,`${u}('${n}') subscribes to an event the grid never raises, so the handler will never fire. Check the name against the EventName list — a common cause is a near miss such as 'row:click' for 'row:clicked'.`)}const D=new Set(["api","user","init","ai"]),I=new WeakMap;function k(u){let n=I.get(u);return n||(n=$("h"),I.set(u,n)),n}function S(){return typeof performance=="object"&&performance?performance.now():Date.now()}function y(u){if(!u||typeof u!="object")return{};const n={};for(const[t,i]of Object.entries(u))t!=="grid"&&(i==null?n[t]=String(i):Array.isArray(i)?n[t]=`[${i.length}]`:typeof i=="object"?n[t]=i.key?`row ${i.key}`:"{…}":typeof i=="function"?n[t]="[function]":n[t]=String(i).slice(0,60));return n}class d{#e=new Map;#t=!1;#n=[];#r=200;#o=new Map;#i=null;#s=!1;#l=0;constructor(n=null){this.#i=n}attach(n){this.#i=n}get grid(){return this.#i}get destroyed(){return this.#s}on(n,t){if(typeof t!="function")return M(`bus.handler:${n}`,`on('${n}') needs a function; ignored.`),()=>{};U("on",n);let i=this.#e.get(n);return i||(i=[],this.#e.set(n,i)),i.push(t),()=>this.off(n,t)}once(n,t){if(typeof t!="function")return M(`bus.handler:${n}`,`once('${n}') needs a function; ignored.`),()=>{};U("once",n);const i=s=>{this.off(n,t),t(s)};return this.#o.set(t,i),this.on(n,i)}off(n,t){if(t===void 0){this.#e.delete(n);return}const i=this.#e.get(n);if(!i)return;const s=this.#o.get(t),r=s&&i.includes(s)?s:t,o=i.indexOf(r);o>=0&&i.splice(o,1),s&&r===s&&this.#o.delete(t),i.length===0&&this.#e.delete(n)}count(n){const t=this.#e.get(n),i=n===V?null:this.#e.get(V);return(t?t.length:0)+(i?i.length:0)}#a(n,t,i,s,r){this.#n.push({type:n,origin:t,listeners:(s?s.length:0)+(r?r.length:0),payload:y(i),at:Date.now(),ms:0}),this.#n.length>this.#r&&this.#n.shift()}recordEvents(n,t){this.#t=!!n,Number.isFinite(t)&&t>0&&(this.#r=Math.floor(t)),n||(this.#n=[])}eventLog(){return this.#n.map(n=>({...n}))}clearEventLog(){this.#n=[]}counts(){const n={};for(const[t,i]of this.#e)n[t]=i.length;return n}emit(n,t,i){const s=i??(t&&t.origin),r=D.has(s)?s:"api",o={...t||null,type:n,origin:r,grid:this.#i};if(this.#s)return o;const l=this.#e.get(n),a=n===V?void 0:this.#e.get(V);if(this.#t&&this.#a(n,r,t,l,a),!l&&!a)return o;const p=this.#t?S():0;this.#l++;try{l&&this.#u(l.slice(),o,n),a&&this.#u(a.slice(),o,V)}finally{this.#l--,this.#t&&this.#n.length&&(this.#n[this.#n.length-1].ms=S()-p)}return o}emitBefore(n,t,i){const s=i??(t&&t.origin),r=D.has(s)?s:"user";let o=!1,l=null;const a=w=>{o=!0,w!=null&&l===null&&(l=String(w))},p={...t||null,type:n,origin:r,grid:this.#i,get defaultPrevented(){return o},get reason(){return l},preventDefault(w){a(w)}};if(this.#s)return!0;const m=this.#e.get(n);this.#t&&this.#a(n,r,t,m,void 0);const b=m?m.slice():[];if(b.length===0)return!0;const g=()=>(o&&l===null&&(l="prevented"),o&&t&&typeof t=="object"&&(t.reason=l),!o),f=[];for(const w of b)try{const v=w(p);v&&typeof v.then=="function"?f.push(v):v===!1&&a("prevented")}catch(v){a("error"),M(`bus.beforeThrow:${n}:${k(w)}`,`a '${n}' before-handler threw; the action was cancelled.`,v)}return f.length===0?g():Promise.allSettled(f).then(w=>{for(const v of w)v.status==="rejected"?(a("error"),M(`bus.beforeReject:${n}`,`a '${n}' before-handler rejected; the action was cancelled.`,v.reason)):v.value===!1&&a("prevented");return g()})}#u(n,t,i){for(let s=0;s<n.length;s++)try{n[s](t)}catch(r){M(`bus.throw:${i}:${k(n[s])}`,`a '${i}' handler threw; other handlers were unaffected.`,r)}}clear(){this.#e.clear(),this.#o.clear()}destroy(){this.clear(),this.#s=!0,this.#i=null}}}),Ce("packages/core/src/registry/licence.js",function(e,G){"use strict";Object.defineProperty(e,"PRODUCT",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"LICENCE_VERSION",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"PUBLIC_KEY",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"fromBase64Url",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"toBase64Url",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"asciiBytes",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"hasEd25519",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"currentHost",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return g}}),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 h}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"sharedLicence",{enumerable:!0,get:function(){return j}});const M=G("packages/core/src/internal/util.js").warnOnce,$="lattice-grid",R=1,W="LG1",Z=64,V="GwmaCOkGedHulqsa-DOV1TU8On1rsalWv519c_dW4j4",U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",D=(()=>{const E=new Int16Array(128).fill(-1);for(let O=0;O<U.length;O++)E[U.charCodeAt(O)]=O;return E[43]=62,E[47]=63,E})();function I(E){if(typeof E!="string")return null;let O="";for(let H=0;H<E.length;H++){const x=E.charCodeAt(H);if(x!==61){if(x>127||D[x]<0)return null;O+=E[H]}}const T=O.length;if(T%4===1)return null;const A=new Uint8Array(Math.floor(T*3/4));let P=0,L=0,z=0;for(let H=0;H<T;H++)P=P<<6|D[O.charCodeAt(H)],L+=6,L>=8&&(L-=8,A[z++]=P>>L&255);return z===A.length?A:A.subarray(0,z)}function k(E){let O="",T=0;for(;T+2<E.length;T+=3){const P=E[T]<<16|E[T+1]<<8|E[T+2];O+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]+U[P&63]}const A=E.length-T;if(A===1){const P=E[T]<<16;O+=U[P>>18&63]+U[P>>12&63]}else if(A===2){const P=E[T]<<16|E[T+1]<<8;O+=U[P>>18&63]+U[P>>12&63]+U[P>>6&63]}return O}function S(E){const O=new Uint8Array(E.length);for(let T=0;T<E.length;T++)O[T]=E.charCodeAt(T)&127;return O}function y(E){if(typeof TextDecoder=="function")return new TextDecoder().decode(E);let O="";for(let T=0;T<E.length;T++)O+=String.fromCharCode(E[T]);return O}function d(E){const O={ok:!1,reason:"malformed",product:null,issuedTo:null,expires:null,features:[],deployments:[],version:0,message:null,signature:null,raw:typeof E=="string"?E:""};if(typeof E!="string"||E.length===0)return{...O,reason:"missing"};const T=E.trim(),A=T.split(".");if(A.length!==3)return O;const[P,L,z]=A;if(P!==W)return{...O,reason:"prefix"};const H=I(L),x=I(z);if(!H||!x)return O;let F;try{F=JSON.parse(y(H))}catch{return O}return F===null||typeof F!="object"?O:{ok:!0,reason:null,product:typeof F.p=="string"?F.p:null,issuedTo:typeof F.t=="string"?F.t:null,expires:typeof F.e=="string"?F.e:null,features:Array.isArray(F.f)?F.f.slice():[],deployments:Array.isArray(F.d)?F.d.slice():[],version:typeof F.v=="number"?F.v:0,message:S(L),signature:x,raw:T}}function u(E,O){if(!E)return!1;const T=Date.parse(/^\d{4}-\d{2}-\d{2}$/.test(E)?`${E}T23:59:59.999Z`:E);return Number.isNaN(T)?!0:O>T}let n=null,t=null,i=null;function s(){const E=globalThis.crypto;return E&&E.subtle?E.subtle:null}async function r(E){if(n&&t===E)return n;const O=s();if(!O)return null;const T=I(E);if(!T)return null;try{const A=await O.importKey("raw",T,{name:"Ed25519"},!1,["verify"]);return n=A,t=E,A}catch{return null}}async function o(){return i!==null||(i=await r(V)!==null),i}async function l(E,O={}){const T=O.warn!==!1,A=O.product||$,P=O.publicKey||V,L=O.now??Date.now(),z=d(E);if(!z.ok){const q=z.reason==="missing"?"missing":"malformed";return T&&M(`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 H={product:z.product||void 0,issuedTo:z.issuedTo||void 0,expires:z.expires||void 0};if(z.product!==A)return T&&M("licence.product",`licence key is for '${z.product}', not '${A}'. The grid will render with a watermark.`),{valid:!1,...H,reason:"product"};if(u(z.expires,L))return T&&M("licence.expired",`licence expired on ${z.expires}. The grid will render with a watermark. Renew at latticegrid.dev.`),{valid:!1,...H,reason:"expired"};const x=O.host??p(),F=z.deployments||[];if(F.length&&x&&!a(x)&&!m(x,F))return T&&M("licence.domain",`licence key is not valid for ${x}; it covers ${F.join(", ")}. The grid will render with a watermark.`),{valid:!1,...H,reason:"domain"};const C=await r(P);if(!C){const q=!!z.signature&&z.signature.length===Z;return T&&M("licence.algorithm","this host does not provide crypto.subtle Ed25519, so the licence signature could not be verified. A structural check was used instead."),q?{valid:!0,...H,reason:"unverified"}:{valid:!1,...H,reason:"signature"}}let B=!1;try{B=await s().verify({name:"Ed25519"},C,z.signature,z.message)}catch{B=!1}return B?{valid:!0,...H}:(T&&M("licence.signature","licence signature is not valid. The grid will render with a watermark."),{valid:!1,...H,reason:"signature"})}function a(E){const O=String(E??p()??"").trim().toLowerCase().replace(/^\[/,"").replace(/\]$/,"");return!O||O==="localhost"||O.endsWith(".localhost")||O==="::1"||O==="0:0:0:0:0:0:0:1"?!0:/^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(O)}function p(){const E=globalThis.location;return E&&typeof E.hostname=="string"?E.hostname:null}function m(E,O){const T=b(E);return!T||!Array.isArray(O)?!1:O.some(A=>{const P=b(A);if(!P)return!1;if(P==="*")return!0;if(P.startsWith("*.")){const L=P.slice(2);return T===L||T.endsWith(`.${L}`)}return T===P})}function b(E){return String(E??"").trim().toLowerCase().replace(/\.$/,"")}class g{#e="";#t={valid:!1,reason:"missing"};#n=null;#r=null;#o;#i=new Set;constructor(O={}){this.#o=O}set(O){this.#e=typeof O=="string"?O.trim():"";const T=d(this.#e);return this.#t=T.ok?{valid:!u(T.expires,Date.now())&&T.product===(this.#o.product||$),product:T.product||void 0,issuedTo:T.issuedTo||void 0,expires:T.expires||void 0,reason:"pending"}:{valid:!1,reason:T.reason||"malformed"},this.#n=null,this.#e&&this.verify(),this.#t}verify(){if(this.#n)return this.#n;const O=this.#e;return this.#n=l(O,this.#o).then(T=>{if(this.#e===O){this.#t=T;for(const A of this.#i)A(T)}return T}),this.#n}onSettled(O){return this.#i.add(O),()=>this.#i.delete(O)}info(){return{...this.#t}}watermark(){return this.#t.valid?!1:!a(this.#r)}setHost(O){this.#r=O}state(){return this.#t.valid?"licensed":a(this.#r)?"localhost":"trial"}reset(){this.#e="",this.#t={valid:!1,reason:"missing"},this.#n=null,this.#i.clear()}}const f=new g;function w(E){return f.set(E)}function v(){return f.info()}function h(){return f.watermark()}function c(){return f.state()}function j(){return f}}),Ce("packages/core/src/registry/registry.js",function(e,G){"use strict";Object.defineProperty(e,"KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"REGIONS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return i}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.isFunction,R=_.DEV,W=G("packages/core/src/registry/licence.js"),Z=W.LicenceHolder,V=W.sharedLicence,U=["renderer","editor","filter","dataType","totalFn","pipe","component"],D=["all","header","body","totals","panels"];class I{#e=new Map;#t=new Map;#n=new Set;#r=new Set;#o;#i=null;#s=null;#l=new Set;#a=new Map;constructor(r={}){for(const o of U)this.#t.set(o,new Map);this.#o=r.holder||V(),this.#s=r.grid??null,this.#i=this.#o.onSettled(()=>{this.#d({reason:"licence",name:"licence",capabilities:this.capabilities(),regions:["all"]})}),r.licence&&this.setLicence(r.licence)}registerModules(r,o={}){o.licence&&this.setLicence(o.licence),o.grid!==void 0&&(this.#s=o.grid);const l=Array.isArray(r)?r:[r],a=[];for(const p of l){if(!p||typeof p!="object"||typeof p.name!="string"||!p.name){M("registry.module.shape","registerModules received something that is not a module; ignored.");continue}if(this.#e.has(p.name)){R&&this.#c(this.#e.get(p.name),p);continue}if(!$(p.install)){M(`registry.module.install:${p.name}`,`module '${p.name}' has no install() and was ignored.`);continue}const m={registry:this,grid:this.#s};try{p.install(m)}catch(b){M(`registry.module.throw:${p.name}`,`module '${p.name}' threw during install; it was not registered.`,b);continue}this.#e.set(p.name,p);for(const b of k(p))this.#n.add(b);a.push(p.name),this.#d({reason:"module",name:p.name,capabilities:this.capabilities(),regions:d(p)})}return a}unregisterModule(r){const o=this.#e.get(r);if(!o)return!1;if($(o.uninstall))try{o.uninstall({registry:this,grid:this.#s})}catch(l){M(`registry.module.uninstall:${r}`,`module '${r}' threw during uninstall.`,l)}return this.#e.delete(r),this.#u(),this.#d({reason:"unmodule",name:r,capabilities:this.capabilities(),regions:d(o)}),!0}modules(){return[...this.#e.values()]}has(r){return this.#e.has(r)}#u(){this.#n.clear();for(const r of this.#e.values())for(const o of k(r))this.#n.add(o)}#c(r,o){!r||r===o||S(r,o)||M(`registry.module.reconfigure:${o.name}`,`module '${o.name}' was re-registered with different options; the first registration is kept and this call was ignored. Unregister it first if you mean to replace it.`)}capabilities(){return[...this.#n].sort()}can(r){return this.#n.has(r)}onChange(r){return $(r)?(this.#r.add(r),this.#a.set(r,this.#s),()=>{this.#r.delete(r),this.#a.delete(r)}):()=>{}}#d(r){for(const o of[...this.#r])try{o(r)}catch(l){M("registry.onChange.throw","a registry change handler threw.",l)}}register(r,o,l){const a=this.#t.get(r);if(!a){M(`registry.kind:${r}`,`unknown registry kind '${r}'; expected one of ${U.join(", ")}.`);return}if(!o||typeof o!="string"){M(`registry.name:${r}`,`register('${r}', ...) needs a name.`);return}a.has(o)&&a.get(o)!==l&&M(`registry.replace:${r}:${o}`,`'${o}' was already registered as a ${r} and has been replaced.`),a.set(o,l),this.#d({reason:"register",name:o,kind:r,capabilities:this.capabilities(),regions:u(r)})}registerAll(r,o){if(o)for(const l of Object.keys(o))this.register(r,l,o[l])}get(r,o){const l=this.#t.get(r);return l?l.get(o):void 0}names(r){const o=this.#t.get(r);return o?[...o.keys()]:[]}#h(r,o){const l=this.#t.get(r).get(o);return l!==void 0?l:this.#t.get("component").get(o)}renderer(r){return this.#h("renderer",r)}editor(r){return this.#h("editor",r)}filter(r){return this.#h("filter",r)}dataType(r){return this.get("dataType",r)}totalFn(r){return this.get("totalFn",r)}pipe(r){return this.get("pipe",r)}setLicence(r){return this.#o.set(r)}licence(){return this.#o.info()}licenceVerified(){return this.#o.verify()}watermark(){return this.#o.watermark()}attach(r){r!=null&&(this.#l.add(r),this.#s=r)}detach(r){if(r!=null){this.#l.delete(r);for(const[o,l]of[...this.#a])l===r&&(this.#r.delete(o),this.#a.delete(o));if(this.#s===r){const o=this.#l.size?[...this.#l][this.#l.size-1]:null;this.#s=o}this.#l.size===0&&this.#i&&(this.#i(),this.#i=null)}}destroy(r){if(r!=null){this.detach(r);return}for(const o of[...this.#e.keys()])this.unregisterModule(o);this.#r.clear(),this.#a.clear(),this.#l.clear(),this.#i&&this.#i(),this.#i=null,this.#s=null}}function k(s){const r=s.capabilities,o=Array.isArray(r)?r.filter(l=>typeof l=="string"):[];return[s.name,...o]}function S(s,r){return s.install!==r.install||s.uninstall!==r.uninstall||(s.version||"")!==(r.version||"")?!1:y(k(s),k(r))&&y(d(s),d(r))}function y(s,r){const o=new Set(s),l=new Set(r);if(o.size!==l.size)return!1;for(const a of o)if(!l.has(a))return!1;return!0}function d(s){const r=s.regions;return!Array.isArray(r)||r.length===0?["all"]:r.filter(o=>D.includes(o))}function u(s){switch(s){case"filter":return["header"];case"totalFn":return["totals"];case"renderer":case"editor":case"pipe":return["body"];default:return["all"]}}const n=new I;function t(){return n}function i(s,r={}){return n.registerModules(s,r)}}),Ce("packages/core/src/format/number.js",function(e,G){"use strict";Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return $}});const M=G("packages/core/src/internal/util.js").isNil;function $(R,W){const Z=R||{},V=Z.locale||W||void 0,U=Z.style||"decimal",D=typeof Z.scale=="number"?Z.scale:1,I=Z.nullDisplay??"",k=Z.zeroDisplay,S=Z.prefix||"",y=Z.suffix||"",d=Z.negative||"minus",u=Z.signed===!0,n={style:U,notation:Z.notation||"standard"};U==="currency"&&(n.currency=Z.currency||"USD",Z.currencyDisplay&&(n.currencyDisplay=Z.currencyDisplay)),typeof Z.decimals=="number"?(n.minimumFractionDigits=Z.decimals,n.maximumFractionDigits=Z.decimals):(typeof Z.minDecimals=="number"&&(n.minimumFractionDigits=Z.minDecimals),typeof Z.maxDecimals=="number"&&(n.maximumFractionDigits=Z.maxDecimals),n.minimumFractionDigits>(n.maximumFractionDigits??20)&&(n.maximumFractionDigits=n.minimumFractionDigits)),Z.thousandsSeparator===!1&&(n.useGrouping=!1),n.notation==="compact"&&(n.compactDisplay=Z.compactDisplay||"short");const t=new Intl.NumberFormat(V,n),i=typeof Z.thousandsSeparator=="string"?Z.thousandsSeparator:null,s=typeof Z.decimalSeparator=="string"?Z.decimalSeparator:null;let r=",",o=".";if(i||s)for(const g of t.formatToParts(12345.6))g.type==="group"?r=g.value:g.type==="decimal"&&(o=g.value);const l=g=>{let f=g;return i&&(f=f.split(r).join("")),s&&(f=f.split(o).join("")),i&&(f=f.split("").join(i)),s&&(f=f.split("").join(s)),f},a=!!(i||s),p=S!==""&&U==="currency",m=g=>{let f;if(p){const w=t.formatToParts(g);let v=!1;f="";for(const h of w)f+=h.value,!v&&h.type==="currency"&&(f+=S,v=!0);v||(f=S+f)}else f=S+t.format(g);return a&&(f=l(f)),f+y},b=g=>{if(M(g)||g==="")return I;const f=typeof g=="number"?g:Number(g);if(Number.isNaN(f))return I;const w=D===1?f:f*D;return w===0&&k!==void 0?k:w<0?d==="parentheses"?`(${m(-w)})`:d==="suffix"?`${m(-w)}-`:m(w):u&&w>0?`+${m(w)}`:m(w)};return b.negativeClass=Z.negativeClass||null,b.spec=Z,b}}),Ce("packages/core/src/format/date.js",function(e,G){"use strict";Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return S}}),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 _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.warnOnce,R=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function W(i){const s=[];let r=0,o="";const l=()=>{o&&(s.push({token:null,text:o}),o="")};for(;r<i.length;){const a=i[r];if(a==="'"){if(i[r+1]==="'"){o+="'",r+=2;continue}const m=i.indexOf("'",r+1);if(m===-1){o+=i.slice(r+1),r=i.length;continue}o+=i.slice(r+1,m),r=m+1;continue}const p=R.find(m=>i.startsWith(m,r));if(p){l(),s.push({token:p,text:p}),r+=p.length;continue}/[A-Za-z]/.test(a)&&$(`date.pattern.token:${a}`,`the date pattern "${i}" contains '${a}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${R.join(" ")}.`),o+=a,r+=1}return l(),s}const Z=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function V(i){if(M(i)||i==="")return null;if(i instanceof Date)return Number.isNaN(i.getTime())?null:i;if(typeof i=="number")return Number.isNaN(i)?null:new Date(i);if(typeof i=="string"){const s=Z.exec(i.trim());if(s){const[,o,l,a,p="0",m="0",b="0"]=s;return new Date(+o,+l-1,+a,+p,+m,+b)}const r=new Date(i);return Number.isNaN(r.getTime())?null:r}return null}function U(i,s){return String(i).padStart(s,"0")}function D(i){if(!i)return o=>({year:o.getFullYear(),month:o.getMonth()+1,day:o.getDate(),hour:o.getHours(),minute:o.getMinutes(),second:o.getSeconds(),ms:o.getMilliseconds(),weekday:o.getDay()});const s=new Intl.DateTimeFormat("en-US",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),r={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return o=>{const l={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:o.getMilliseconds(),weekday:0};for(const a of s.formatToParts(o))switch(a.type){case"year":l.year=Number(a.value);break;case"month":l.month=Number(a.value);break;case"day":l.day=Number(a.value);break;case"hour":l.hour=Number(a.value)%24;break;case"minute":l.minute=Number(a.value);break;case"second":l.second=Number(a.value);break;case"weekday":l.weekday=r[a.value]??0;break;default:break}return l}}function I(i,s,r){const o=W(i),l=D(r),a=new Set(o.filter(f=>f.token).map(f=>f.token)),p=a.has("MMM")?new Intl.DateTimeFormat(s,{month:"short",timeZone:r}):null,m=a.has("MMMM")?new Intl.DateTimeFormat(s,{month:"long",timeZone:r}):null,b=a.has("EEE")?new Intl.DateTimeFormat(s,{weekday:"short",timeZone:r}):null,g=a.has("EEEE")?new Intl.DateTimeFormat(s,{weekday:"long",timeZone:r}):null;return f=>{const w=l(f);let v="";for(const h of o){if(!h.token){v+=h.text;continue}switch(h.token){case"yyyy":v+=U(w.year,4);break;case"yy":v+=U(w.year%100,2);break;case"MMMM":v+=m.format(f);break;case"MMM":v+=p.format(f);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+=g.format(f);break;case"EEE":v+=b.format(f);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+=h.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 S(i,s){const r=i||{},o=r.locale||s||void 0,l=r.nullDisplay??"",a=r.timeZone;let p;if(r.pattern)p=I(r.pattern,o,a);else if(r.dateStyle||r.timeStyle){const w={timeZone:a};r.dateStyle&&(w.dateStyle=r.dateStyle),r.timeStyle&&(w.timeStyle=r.timeStyle);const v=new Intl.DateTimeFormat(o,w);p=h=>v.format(h)}else{const w=new Intl.DateTimeFormat(o,{dateStyle:"medium",timeZone:a});p=v=>w.format(v)}const m=r.relative?new Intl.RelativeTimeFormat(o,{numeric:"auto"}):null,g=(typeof r.relative=="object"&&r.relative?r.relative.threshold??7:7)*24*36e5,f=(w,v)=>{const h=V(w);if(!h)return l;if(m){const c=v&&typeof v.now=="number"?v.now:Date.now(),j=h.getTime()-c;if(Math.abs(j)<g){for(const[E,O]of k)if(Math.abs(j)>=O||E==="second")return m.format(Math.round(j/O),E)}}return p(h)};return f.spec=r,f}function y(i){if(M(i)||i==="")return null;if(typeof i=="string"){const o=/^(\d{4}-\d{2}-\d{2})/.exec(i.trim());if(o)return o[1];const l=V(i);return l?y(l):null}const s=V(i);if(!s)return null;const r=o=>String(o).padStart(2,"0");return`${s.getFullYear()}-${r(s.getMonth()+1)}-${r(s.getDate())}`}function d(i,s){if(M(i)||i==="")return null;if(typeof i=="string"){const o=i.trim();if(u.test(o)){const p=V(o);return p?n(p,s):null}const l=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(o);if(l){const[,p,m,b,g]=l;return`${p}T${m}:${b}${g&&g!=="00"?`:${g}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(o))return`${o}T00:00`;const a=V(o);return a?d(a):null}const r=V(i);return r?n(r,s):null}const u=/(?:Z|[+-]\d{2}:?\d{2})$/i;function n(i,s){const r=p=>String(p).padStart(2,"0");if(s)try{const p=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(i).reduce((g,f)=>(f.type!=="literal"&&(g[f.type]=f.value),g),{}),m=p.hour==="24"?"00":p.hour,b=Number(p.second);return`${p.year}-${p.month}-${p.day}T${m}:${p.minute}`+(b?`:${p.second}`:"")}catch{}const o=`${i.getFullYear()}-${r(i.getMonth()+1)}-${r(i.getDate())}`,l=i.getSeconds(),a=`${r(i.getHours())}:${r(i.getMinutes())}${l?`:${r(l)}`:""}`;return`${o}T${a}`}function t(i,s){const r=M(i)||i===""?null:String(i),o=M(s)||s===""?null:String(s);return r===null?o===null?0:1:o===null||r<o?-1:r>o?1:0}}),Ce("packages/core/src/format/boolean.js",function(e,G){"use strict";Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isNil,$={true:"☑",false:"☐",null:""},R={true:"◉",false:"◯",null:""};function W(V){if(M(V)||V==="")return null;if(typeof V=="boolean")return V;if(typeof V=="number")return V!==0;const U=String(V).trim().toLowerCase();return U==="true"||U==="yes"||U==="y"||U==="1"?!0:U==="false"||U==="no"||U==="n"||U==="0"?!1:null}function Z(V,U){const D=V||{},I=D.display||"text",k=D.trueLabel??"Yes",S=D.falseLabel??"No",y=D.nullLabel??"";let d=k,u=S;const n=y;I==="checkbox"?(d=$.true,u=$.false):I==="switch"?(d=R.true,u=R.false):I==="icon"&&(d=D.trueIcon??k,u=D.falseIcon??S);const t=i=>{const s=W(i);return s===null?n:s?d:u};return t.display=I,t.labels={true:k,false:S,null:y},t.locale=U,t.spec=D,t}}),Ce("packages/core/src/format/text.js",function(e,G){"use strict";Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return R}});const _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.titleCase;function R(W,Z){const V=W||{},U=V.locale||Z||void 0,D=V.nullDisplay??"",I=V.emptyDisplay??"",k=V.transform||"none",S=typeof V.truncate=="number"?{chars:V.truncate}:V.truncate||null,y=S?S.chars:0,d=S?S.ellipsis??"…":"",u=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}},n=t=>{if(M(t))return D;let i=typeof t=="string"?t:String(t);return i===""?I:(k!=="none"&&(i=u(i)),y>0&&i.length>y&&(i=i.slice(0,y)+d),i)};return n.spec=V,n}}),Ce("packages/core/src/format/mask.js",function(e,G){"use strict";Object.defineProperty(e,"splitSections",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"parseSection",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return Z}});const _=new Set(["0","#","?",",","."]),M="\0";function $(U){const D=[];let I="",k=!1;for(let S=0;S<U.length;S++){const y=U[S];if(y==="\\"){I+=y+(U[S+1]??""),S+=1;continue}if(y==='"'){k=!k,I+=y;continue}if(y===";"&&!k){D.push(I),I="";continue}I+=y}return D.push(I),D}function R(U){let D="",I="",k="",S=1,y=!1,d=!1;const u=p=>{d?I+=p:D+=p};for(let p=0;p<U.length;p++){const m=U[p];if(m==="\\"){u(U[p+1]??""),p+=1;continue}if(m==='"'){const b=U.indexOf('"',p+1);u(b===-1?U.slice(p+1):U.slice(p+1,b)),p=b===-1?U.length:b;continue}if(m==="%"){S*=100,u("%");continue}if(m==="@"){y=!0,u("\0");continue}if(_.has(m)){k+=m,d=!0;continue}u(m)}let n=-1;for(let p=k.length-1;p>=0;p--){const m=k[p];if(m==="0"||m==="#"||m==="?"){n=p;break}}let t=!1,i="";for(let p=0;p<k.length;p++){const m=k[p];if(m===","){p>n?S/=1e3:t=!0;continue}i+=m}const s=i.indexOf("."),r=s===-1?i:i.slice(0,s),o=s===-1?"":i.slice(s+1);let l=0;for(const p of r)p==="0"&&(l+=1);let a=0;for(const p of o)p==="0"&&(a+=1);return{prefix:D,suffix:I,minInt:l,minDec:a,maxDec:o.length,grouping:t,scale:S,hasNumber:n!==-1,isText:y}}function W(U,D){const I=new Intl.NumberFormat(D,{minimumIntegerDigits:Math.max(U.minInt,1),minimumFractionDigits:U.minDec,maximumFractionDigits:Math.max(U.maxDec,U.minDec),useGrouping:U.grouping}),{prefix:k,suffix:S,scale:y,hasNumber:d}=U;return u=>{if(!d)return k+S;const n=y===1?u:u*y;return k+I.format(n)+S}}function Z(U,D){const k=$(String(U)).map(R),S=k.map(i=>W(i,D)),y=0,d=k.length>1?1:-1,u=k.length>2?2:-1,n=k.length>3?3:-1,t=i=>{if(i==null||i==="")return"";if(typeof i!="number"||Number.isNaN(i)){const s=Number(i);if(Number.isNaN(s))return n===-1?String(i):(k[n].prefix+k[n].suffix).split("\0").join(String(i));i=s}return i===0&&u!==-1?S[u](0):i<0&&d!==-1?S[d](-i):S[y](i)};return t.spec={mask:U},{format:t,ooxml:V(String(U))}}function V(U){return U.trim()}}),Ce("packages/core/src/format/shorthand.js",function(e,G){"use strict";Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseShorthand",{enumerable:!0,get:function(){return V}});const _=["currency","number","percent","date","boolean","text","relative"],M=/[#0?@;"\\]/,$=/(yyyy|yy|MMMM|MMM|MM|EEEE|EEE|dd|HH|hh|mm|ss|SSS)/;function R(U){return typeof U!="string"||U===""||Z(U)?!1:M.test(U)}function W(U){return typeof U!="string"||U===""||Z(U)?!1:$.test(U)}function Z(U){const D=U.indexOf(":"),I=D===-1?U:U.slice(0,D);return _.includes(I)?I:null}function V(U){const D=Z(U);if(!D)return null;const I=U.indexOf(":"),k=I===-1?"":U.slice(I+1),S=k===""?[]:k.split(":");switch(D){case"currency":{const y={type:"number",style:"currency",currency:S[0]||"USD"};return S[1]!==void 0&&S[1]!==""&&(y.decimals=Number(S[1])),y}case"number":{const y={type:"number",style:"decimal"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"percent":{const y={type:"number",style:"percent"};return S[0]!==void 0&&S[0]!==""&&(y.decimals=Number(S[0])),y}case"date":return{type:"date",pattern: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 S[0]&&(y.transform=S[0]),S[1]!==void 0&&S[1]!==""&&(y.truncate=Number(S[1])),y}default:return null}}}),Ce("packages/core/src/format/index.js",function(e,G){"use strict";Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return f}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.isObject,R=_.warnOnce,W=G("packages/core/src/format/number.js"),Z=W.compileNumber,V=G("packages/core/src/format/date.js"),U=V.compileDate,D=V.scanPattern,I=G("packages/core/src/format/boolean.js"),k=I.compileBoolean,S=G("packages/core/src/format/text.js"),y=S.compileText,d=G("packages/core/src/format/mask.js"),u=d.compileMask,n=G("packages/core/src/format/shorthand.js"),t=n.parseShorthand,i=n.looksLikeMask,s=n.looksLikeDatePattern;Object.defineProperty(e,"compileNumber",{enumerable:!0,get:function(){return W.compileNumber}}),Object.defineProperty(e,"compileDate",{enumerable:!0,get:function(){return V.compileDate}}),Object.defineProperty(e,"compilePattern",{enumerable:!0,get:function(){return V.compilePattern}}),Object.defineProperty(e,"scanPattern",{enumerable:!0,get:function(){return V.scanPattern}}),Object.defineProperty(e,"toDate",{enumerable:!0,get:function(){return V.toDate}}),Object.defineProperty(e,"compileBoolean",{enumerable:!0,get:function(){return I.compileBoolean}}),Object.defineProperty(e,"toTriState",{enumerable:!0,get:function(){return I.toTriState}}),Object.defineProperty(e,"compileText",{enumerable:!0,get:function(){return S.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 n.parseShorthand}}),Object.defineProperty(e,"looksLikeMask",{enumerable:!0,get:function(){return n.looksLikeMask}}),Object.defineProperty(e,"looksLikeDatePattern",{enumerable:!0,get:function(){return n.looksLikeDatePattern}});const r=new Set(["decimal","currency","percent","unit"]),o=new Set(["type","locale"]),l={number:new Set(["style","currency","currencyDisplay","decimals","minDecimals","maxDecimals","thousandsSeparator","decimalSeparator","notation","compactDisplay","negative","negativeClass","signed","prefix","suffix","zeroDisplay","nullDisplay","messages","scale"]),date:new Set(["pattern","dateStyle","timeStyle","timeZone","relative","nullDisplay"]),boolean:new Set(["display","trueLabel","falseLabel","nullLabel","trueIcon","falseIcon"]),text:new Set(["transform","truncate","nullDisplay","emptyDisplay"])};function a(c,j,E){const O=l[j],T=E?`"${E}"`:"with no id";for(const A of c){if(o.has(A)||O.has(A))continue;const P=Object.keys(l).find(L=>L!==j&&l[L].has(A));P?R(`format:inapplicable:${E||""}:${A}`,`column ${T} has format key "${A}", which applies to a ${P} column, not the ${j} column it was applied to; it is ignored.`):R(`format:unknown:${E||""}:${A}`,`column ${T} has an unrecognised format key "${A}" for its ${j} format; it is ignored.`)}}function p(c){if(c.type==="number"||c.type==="date"||c.type==="boolean"||c.type==="text")return!0;const j=r.has(String(c.style));return!!(c.pattern||c.dateStyle||c.timeStyle||c.relative||c.timeZone||c.trueLabel||c.falseLabel||c.display||c.trueIcon||c.falseIcon||c.transform||c.truncate||c.emptyDisplay||j||c.currency||c.decimals!==void 0||c.minDecimals!==void 0||c.maxDecimals!==void 0||c.notation||c.negative||c.scale!==void 0||c.prefix||c.suffix||c.zeroDisplay!==void 0)}function m(c,j){if(c.type==="number"||c.type==="date"||c.type==="boolean"||c.type==="text")return c.type;if(c.pattern||c.dateStyle||c.timeStyle||c.relative||c.timeZone)return"date";if(c.trueLabel||c.falseLabel||c.display||c.trueIcon||c.falseIcon)return"boolean";if(c.transform||c.truncate||c.emptyDisplay)return"text";if(c.style||c.currency||c.decimals!==void 0||c.minDecimals!==void 0||c.maxDecimals!==void 0||c.notation||c.negative||c.scale!==void 0||c.prefix||c.suffix||c.zeroDisplay!==void 0)return"number";const E=j&&j.base;return E==="number"?"number":E==="date"||E==="dateString"?"date":E==="boolean"?"boolean":"text"}function b(c,j=null,E=void 0,O=void 0,T=void 0){if(c==null||c==="")return null;const A=$(c)?Object.keys(c):null;if(typeof c=="function"){const z=(H,x)=>String(c({...x||{},value:H,locale:E})??"");return z.ooxml=j&&j.excel||"General",z}if(typeof c=="string"){if(i(c)){const{format:H,ooxml:x}=u(c,E);return H.ooxml=x,H}const z=t(c)||(s(c)?{type:"date",pattern:c}:null);return z?b(z,j,E,O,T):(R(`format:${c}`,`unrecognised format string "${c}"; the value will be stringified`),null)}if(!$(c))return R("format:shape","format must be a spec object or a string; ignoring",c),null;if(j&&M(j.format)&&!p(c)||j&&M(j.format)&&Array.isArray(j.formatPatterns)&&c.type===void 0)return null;const P=m(c,j);P==="date"&&O&&c.timeZone===void 0&&(c={...c,timeZone:O}),a(A||Object.keys(c),P,T);let L;switch(P){case"number":L=Z(c,E);break;case"date":L=U(c,E);break;case"boolean":L=k(c,E);break;default:L=y(c,E);break}return L.ooxml=f(c,P,E,j),L.kind=P,L}const g={yyyy:"yyyy",yy:"yy",MMMM:"mmmm",MMM:"mmm",MM:"mm",M:"m",dd:"dd",d:"d",EEEE:"dddd",EEE:"ddd",HH:"hh",H:"h",hh:"hh",h:"h",mm:"mm",m:"m",ss:"ss",s:"s",SSS:"000",a:"AM/PM"};function f(c,j,E=void 0,O=null){if(j==="date"){if(c.pattern){let z="";for(const H of D(c.pattern))z+=H.token?g[H.token]??H.text:H.text;return z}return O&&O.excel||"yyyy-mm-dd"}if(j==="boolean")return"General";if(j==="text")return"@";if(c.notation==="compact"||c.notation==="scientific")return"General";const T=typeof c.decimals=="number"?c.decimals:typeof c.minDecimals=="number"?c.minDecimals:c.style==="currency"?2:0;let P=`${c.thousandsSeparator===!1?"":"#,#"}#0${T>0?`.${"0".repeat(T)}`:""}`,L="";return c.style==="currency"&&(L+=w(h(c.currency||"USD",E))),c.prefix&&(L+=w(c.prefix)),P=L+P,c.style==="percent"&&(P=`${P}%`),c.suffix&&(P+=w(c.suffix)),c.negative==="parentheses"?`${P};(${P})`:c.negative==="suffix"?`${P};${P}-`:P}function w(c){return`"${String(c).split('"').join("")}"`}const v=new Map;function h(c,j){const E=`${c}|${j||""}`;let O=v.get(E);if(O!==void 0)return O;O=c;try{const A=new Intl.NumberFormat(j,{style:"currency",currency:c}).formatToParts(0).find(P=>P.type==="currency");A&&(O=A.value)}catch{}return v.set(E,O),O}}),Ce("packages/core/src/columns/types/temporal.js",function(e,G){"use strict";Object.defineProperty(e,"MS_SECOND",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MS_MINUTE",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"MS_HOUR",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"MS_DAY",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"MS_WEEK",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"toTimeMs",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"formatTime",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"zonedParts",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"zoneOffsetAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"instantFromParts",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"parseDateTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"toEpochMs",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"formatDateTime",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return re}}),Object.defineProperty(e,"toDurationMs",{enumerable:!0,get:function(){return se}}),Object.defineProperty(e,"formatDuration",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"zoneAbbrev",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"resolveZoneName",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"zoneLabel",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"formatInstant",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"bucketInstant",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"timestampGroupProjector",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"TEMPORAL_TYPES",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"TEMPORAL_INFERENCE_ORDER",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return nt}});const _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.isFunction,R=G("packages/core/src/format/date.js"),W=R.toDate,Z=R.compilePattern,V=R.compileDate,U=R.toIsoDateTime,D=R.compareIso,I=864e5,k=Object.freeze({}),S=1e3,y=60*S,d=60*y,u=24*d,n=7*u,t=new WeakMap;function i(Ae,Ke){const Ve=Ae&&Ae.locale||"",Xe=Ae&&Ae.column;if(!Xe)return Ve?{locale:Ve}:k;const st=t.get(Xe);if(st&&st.locale===Ve)return st.bag;const ht=Xe.typeOptions||Xe[Ke]||(s(Xe.format)?Xe.format:null),bt={...ht||k,locale:ht&&ht.locale||Ve||void 0};return t.set(Xe,{locale:Ve,bag:bt}),bt}function s(Ae){return Ae!==null&&typeof Ae=="object"&&!Array.isArray(Ae)&&!(Ae instanceof Date)}function r(Ae,Ke){const Ve=Ae===null||Number.isNaN(Ae)?null:Ae,Xe=Ke===null||Number.isNaN(Ke)?null:Ke;return Ve===null?Xe===null?0:1:Xe===null||Ve<Xe?-1:Ve>Xe?1:0}const o=/^(\d{1,2})(?:\s*[:.h]\s*(\d{1,2})(?:\s*[:.]\s*(\d{1,2})(?:[.,](\d{1,3}))?)?)?\s*(a\.?m\.?|p\.?m\.?|a|p)?$/i,l=/^(\d{3,6})$/;function a(Ae,Ke,Ve,Xe){return!(Ae>=0&&Ae<=23)||!(Ke>=0&&Ke<=59)||!(Ve>=0&&Ve<=59)||!(Xe>=0&&Xe<=999)?null:Ae*d+Ke*y+Ve*S+Xe}function p(Ae){if(M(Ae))return null;const Ke=String(Ae).trim();if(Ke==="")return null;const Ve=l.exec(Ke);if(Ve){const It=Ve[1];if(It.length===5)return null;const Dt=It.length===3?1:2;return a(Number(It.slice(0,Dt)),Number(It.slice(Dt,Dt+2)),Number(It.slice(Dt+2,Dt+4)||0),0)}const Xe=o.exec(Ke);if(!Xe)return null;let st=Number(Xe[1]);const ht=Number(Xe[2]||0),bt=Number(Xe[3]||0),At=Xe[4]?Number(Xe[4].padEnd(3,"0")):0,Tt=Xe[5]?Xe[5][0].toLowerCase():null;if(Tt){if(st<1||st>12)return null;st=st%12,Tt==="p"&&(st+=12)}return a(st,ht,bt,At)}function m(Ae){return M(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?(Ae%u+u)%u:null:Ae instanceof Date?Number.isNaN(Ae.getTime())?null:Ae.getHours()*d+Ae.getMinutes()*y+Ae.getSeconds()*S+Ae.getMilliseconds():p(Ae)}const b=new Map;function g(Ae){const Ke=Ae.pattern||"",Ve=Ae.timeStyle||(Ae.seconds?"medium":"short"),Xe=`${Ae.locale||""}|${Ke}|${Ve}`;let st=b.get(Xe);if(st)return st;if(Ke)st=Z(Ke,Ae.locale||void 0,"UTC");else{const ht=new Intl.DateTimeFormat(Ae.locale||void 0,{timeStyle:Ve,timeZone:"UTC"});st=bt=>ht.format(bt)}return b.set(Xe,st),st}function f(Ae,Ke){const Ve=Ke||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ve.nullDisplay??"";const Xe=(Ae%u+u)%u;return g(Ve)(new Date(Xe))}function w(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae=="number"?Number.isFinite(Ae)&&Ae>=0&&Ae<u:typeof Ae!="string"||!Ae.includes(":")?!1:p(Ae)!==null}function v(Ae){const Ke=m(Ae);return Ke==null?"":f(Ke,{pattern:Ke%S===0?"HH:mm:ss":"HH:mm:ss.SSS"})}const h=new Map;function c(Ae){const Ke=Ae||"";let Ve=h.get(Ke);return Ve||(Ve=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}),h.set(Ke,Ve)),Ve}function j(Ae,Ke){const Ve={year:1970,month:1,day:1,hour:0,minute:0,second:0};for(const Xe of c(Ke).formatToParts(new Date(Ae)))Xe.type==="year"?Ve.year=Number(Xe.value):Xe.type==="month"?Ve.month=Number(Xe.value):Xe.type==="day"?Ve.day=Number(Xe.value):Xe.type==="hour"?Ve.hour=Number(Xe.value)%24:Xe.type==="minute"?Ve.minute=Number(Xe.value):Xe.type==="second"&&(Ve.second=Number(Xe.value));return Ve}function E(Ae,Ke){const Ve=j(Ae,Ke);return Date.UTC(Ve.year,Ve.month-1,Ve.day,Ve.hour,Ve.minute,Ve.second,0)-Math.floor(Ae/1e3)*1e3}function O(Ae,Ke){const Ve=Ae.hour||0,Xe=Ae.minute||0,st=Ae.second||0,ht=Ae.ms||0;if(!Ke)return new Date(Ae.year,Ae.month-1,Ae.day,Ve,Xe,st,ht).getTime();const bt=Date.UTC(Ae.year,Ae.month-1,Ae.day,Ve,Xe,st,ht);let At=bt-E(bt,Ke);return At=bt-E(At,Ke),At}const T=/(?:Z|[+-]\d{2}:?\d{2})$/i,A=/^(\d{4})-(\d{1,2})-(\d{1,2})(?:[T\s]+(.*))?$/;function P(Ae,Ke){if(M(Ae))return null;const Ve=String(Ae).trim();if(Ve==="")return null;const Xe=Ke&&Ke.timeZone||void 0;if(!T.test(Ve)){const st=A.exec(Ve);if(st){const ht=(st[4]||"").trim(),bt=ht===""?0:p(ht);if(bt===null)return null;const At=O({year:Number(st[1]),month:Number(st[2]),day:Number(st[3]),hour:Math.floor(bt/d),minute:Math.floor(bt/y)%60,second:Math.floor(bt/S)%60,ms:bt%S},Xe);return Number.isNaN(At)?null:new Date(At)}}return W(Ve)}function L(Ae){if(typeof Ae=="number")return Number.isFinite(Ae)?Ae:null;const Ke=W(Ae);return Ke?Ke.getTime():null}const z=new Map;function H(Ae){const Ke=[Ae.locale||"",Ae.pattern||"",Ae.dateStyle||"",Ae.timeStyle||"",Ae.timeZone||"",Ae.seconds?"1":""].join("|");let Ve=z.get(Ke);if(Ve)return Ve;const Xe=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 Ve=V(Xe,Ae.locale||void 0),z.set(Ke,Ve),Ve}function x(Ae,Ke){const Ve=Ke||k,Xe=L(Ae);return Xe==null?Ve.nullDisplay??"":H(Ve)(Xe)}function F(Ae){return Ae instanceof Date?!Number.isNaN(Ae.getTime()):typeof Ae!="string"||!A.test(Ae.trim())?!1:P(Ae)!==null}const C=Object.freeze([{key:"w",ms:n,intl:"week",long:["week","weeks"],names:["w","wk","wks","week","weeks"]},{key:"d",ms:u,intl:"day",long:["day","days"],names:["d","dy","day","days"]},{key:"h",ms: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:S,intl:"second",long:["second","seconds"],names:["s","sec","secs","second","seconds"]},{key:"ms",ms:1,intl:"millisecond",long:["millisecond","milliseconds"],names:["ms","msec","msecs","milli","millis","millisecond","milliseconds"]}]),B=new Map;for(const Ae of C)for(const Ke of Ae.names)B.set(Ke,Ae);const q=Object.freeze(C.filter(Ae=>Ae.key!=="w")),Q=/^(\d+(?:\.\d+)?)\s*([a-z]+)\s*(?:,\s*)?/,Y=/^\d+(?:\.\d+)?$/,J=/^(\d+):([0-5]?\d)(?::([0-5]?\d))?(?:\.(\d{1,3}))?$/;function te(Ae){const Ke=Ae&&Ae.defaultUnit?B.get(String(Ae.defaultUnit).toLowerCase()):null;return Ke?Ke.ms:y}function ee(Ae){return(Ae&&Ae.defaultUnit?B.get(String(Ae.defaultUnit).toLowerCase()):null)||B.get("m")}function re(Ae,Ke){if(M(Ae))return null;let Ve=String(Ae).trim().toLowerCase();if(Ve==="")return null;let Xe=1;if(Ve[0]==="-"?(Xe=-1,Ve=Ve.slice(1).trim()):Ve[0]==="+"&&(Ve=Ve.slice(1).trim()),Ve==="")return null;const st=J.exec(Ve);if(st){const Tt=st[3]!==void 0,It=Number(st[1])*d+Number(st[2])*y+(Tt?Number(st[3])*S:0)+(st[4]?Number(st[4].padEnd(3,"0")):0);return Xe*It}if(Y.test(Ve))return Math.round(Xe*Number(Ve)*te(Ke||k));let ht=Ve,bt=0,At=0;for(;ht!=="";){const Tt=Q.exec(ht);if(!Tt)return null;const It=B.get(Tt[2]);if(!It)return null;bt+=Number(Tt[1])*It.ms,ht=ht.slice(Tt[0].length),At++}return At===0?null:Math.round(Xe*bt)}function se(Ae){return M(Ae)||Ae===""?null:typeof Ae=="number"?Number.isFinite(Ae)?Ae:null:re(Ae)}const de=new Map;function ie(Ae,Ke,Ve){const Xe=`${Ve||""}|${Ke.intl}`;let st=de.get(Xe);if(st===void 0){try{st=new Intl.NumberFormat(Ve||void 0,{style:"unit",unit:Ke.intl,unitDisplay:"long"})}catch{st=null}de.set(Xe,st)}return st?st.format(Ae):`${Ae} ${Ae===1?Ke.long[0]:Ke.long[1]}`}function oe(Ae,Ke){return String(Ae).padStart(Ke,"0")}function ue(Ae,Ke){const Ve=Ke||k;if(Ae==null||typeof Ae!="number"||!Number.isFinite(Ae))return Ve.nullDisplay??"";const Xe=Ve.style||"short",st=Ae<0;let ht=Math.round(Math.abs(Ae));const bt=st?"-":"";if(ht===0&&Ve.zeroDisplay!=null)return Ve.zeroDisplay;if(Xe==="clock"){const Dt=Math.floor(ht/d),Gt=Math.floor(ht/y)%60,Yt=Math.floor(ht/S)%60;return`${bt}${oe(Dt,2)}:${oe(Gt,2)}:${oe(Yt,2)}`}if(ht===0){const Dt=ee(Ve);return Xe==="long"?ie(0,Dt,Ve.locale):`0${Dt.key}`}const At=Ve.weeks===!0?C:q,Tt=typeof Ve.maxUnits=="number"&&Ve.maxUnits>0?Ve.maxUnits:Ve.maxUnits===void 0?2:1/0,It=[];for(const Dt of At){if(It.length>=Tt)break;const Gt=Math.floor(ht/Dt.ms);Gt!==0&&(ht-=Gt*Dt.ms,It.push(Xe==="long"?ie(Gt,Dt,Ve.locale):`${Gt}${Dt.key}`))}return bt+It.join(" ")}function ce(Ae){if(typeof Ae!="string")return!1;const Ke=Ae.trim();return Ke===""||J.test(Ke)||!/[a-z]/i.test(Ke)?!1:re(Ke)!==null}const pe=Date.UTC(1899,11,30),Me=new Map;function $e(Ae,Ke){const Ve=Ae||"";let Xe=Me.get(Ve);Xe||(Xe=new Intl.DateTimeFormat("en-GB",{timeZone:Ae||void 0,timeZoneName:"short",hour:"2-digit",hour12:!1}),Me.set(Ve,Xe));const st=typeof Ke=="number"?Ke:Date.now();for(const ht of Xe.formatToParts(new Date(st)))if(ht.type==="timeZoneName")return ht.value;return""}function je(Ae){if(Ae)return Ae;try{return new Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function ke(Ae,Ke){const Ve=je(Ae),Xe=$e(Ae,Ke);return Xe?`${Ve} (${Xe})`:Ve}function ge(Ae,Ke){if(Ae&&Ae.timeZone)return Ae.timeZone;const Ve=Ke&&Ke.grid;return(Ve&&$(Ve.get)?Ve.get("timeZone"):void 0)||void 0}function Ee(Ae,Ke){const Ve=Ke||k,Xe=L(Ae);if(Xe==null)return Ve.nullDisplay??"";const st=H(Ve)(Xe);if(!Ve.showOrigin)return st;const ht=Ve.originZone;return ht?ht===(Ve.timeZone||je(Ve.timeZone))?st:`${st} (${ke(ht,Xe)})`:`${st} (no origin recorded)`}function Ie(Ae,Ke,Ve,Xe){if(Ke==="instant"||!Ke)return Ae;const st=j(Ae,Ve);if(Ke==="month")return O({year:st.year,month:st.month,day:1},Ve);if(Ke==="week"){const ht=Xe>=1&&Xe<=7?Xe:1,At=((new Date(Date.UTC(st.year,st.month-1,st.day)).getUTCDay()+6)%7+1-ht+7)%7,Tt=new Date(Date.UTC(st.year,st.month-1,st.day-At));return O({year:Tt.getUTCFullYear(),month:Tt.getUTCMonth()+1,day:Tt.getUTCDate()},Ve)}return O({year:st.year,month:st.month,day:st.day},Ve)}function ze(Ae,Ke){const Ve=Ae&&Ae.group,Xe=Ve&&Ve.granularity||"day";if(Xe==="instant")return null;const st=Ve&&Ve.weekStart;return ht=>typeof ht=="number"?Ie(ht,Xe,Ke,st):ht}const _e={time:{base:"number",storage:"float64",matches:w,format:Ae=>f(m(Ae.value),i(Ae,"time")),parse:Ae=>p(Ae.text),compare:(Ae,Ke)=>r(m(Ae),m(Ke)),defaults:{filter:"number",editor:"time",align:"start"},excel:"hh:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ke=m(Ae);return Ke===null?null:Ke/I},toStorage:Ae=>m(Ae),toClipboard:v,fromClipboard:p},datetime:{base:"dateString",storage:"dictionary",matches:F,format:Ae=>x(Ae.value,i(Ae,"datetime")),parse:Ae=>U(P(Ae.text,i(Ae,"datetime"))??Ae.text),compare:D,defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",toStorage:(Ae,Ke)=>U(Ae,Ke&&Ke.timeZone),toClipboard:Ae=>M(Ae)?"":String(Ae),fromClipboard:Ae=>U(Ae)},duration:{base:"number",storage:"float64",matches:ce,format:Ae=>ue(se(Ae.value),i(Ae,"duration")),parse:Ae=>re(Ae.text,i(Ae,"duration")),compare:(Ae,Ke)=>r(se(Ae),se(Ke)),defaults:{filter:"number",editor:"duration",align:"end",total:"sum"},excel:"[h]:mm:ss",excelKind:"number",toExcelValue:Ae=>{const Ke=se(Ae);return Ke===null?null:Ke/I},toStorage:Ae=>se(Ae),toClipboard:Ae=>ue(se(Ae),{style:"short",maxUnits:-1}),fromClipboard:Ae=>re(Ae)},timestamp:{base:"number",storage:"float64",format:Ae=>{const Ke=i(Ae,"timestamp");return Ee(Ae.value,{...Ke,timeZone:ge(Ke,Ae)})},parse:Ae=>{const Ke=i(Ae,"timestamp"),Ve=P(Ae.text,{timeZone:ge(Ke,Ae)});return Ve?Ve.getTime():null},compare:(Ae,Ke)=>r(L(Ae),L(Ke)),groupProjector:(Ae,Ke)=>ze(Ae,Ke),defaults:{filter:"date",editor:"datetime",align:"start"},excel:"yyyy-mm-dd hh:mm",excelKind:"number",toExcelValue:(Ae,Ke)=>{const Ve=L(Ae);if(Ve==null)return null;const Xe=j(Ve,Ke&&Ke.timeZone||void 0);return(Date.UTC(Xe.year,Xe.month-1,Xe.day,Xe.hour,Xe.minute,Xe.second)-pe)/I},toStorage:Ae=>L(Ae),toClipboard:Ae=>{const Ke=L(Ae);return Ke==null?"":new Date(Ke).toISOString()},fromClipboard:Ae=>L(Ae)}},Qe=["datetime","time","duration"],nt=_e}),Ce("packages/core/src/columns/types/network.js",function(e,G){"use strict";Object.defineProperty(e,"toUint32",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"parseIpv4",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatIpv4",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"isIpv4",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"compareIpv4",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"packCidr",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"cidrParts",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"parseCidr",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"formatCidr",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isCidr",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"compareCidr",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"netmask",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"networkAddress",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"broadcastAddress",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"addressCount",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"hostCount",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"containsAddress",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"overlaps",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ipv6Groups",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"parseIpv6",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"formatIpv6",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"isIpv6",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"compareIpv6",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"NETWORK_TYPES",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return P}});const _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.Lru,R=4294967295,W=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/;function Z(L){if(M(L))return null;if(typeof L=="string")return V(L);const z=Number(L);return Number.isFinite(z)?z<0?z<-2147483648?null:z>>>0:z>R?null:Math.trunc(z)>>>0:null}function V(L){if(M(L))return null;const z=String(L).trim();if(z==="")return null;const H=W.exec(z);if(!H)return null;let x=0;for(let F=1;F<=4;F++){const C=H[F];if(C.length>1&&C.charCodeAt(0)===48)return null;const B=Number(C);if(B>255)return null;x=x*256+B}return x}function U(L){const z=Z(L);return z===null?"":`${z>>>24&255}.${z>>>16&255}.${z>>>8&255}.${z&255}`}function D(L){return typeof L=="string"&&V(L)!==null}function I(L,z){const H=Z(L),x=Z(z);return H===null?x===null?0:1:x===null||H<x?-1:H>x?1:0}const k=64,S=R*k+32,y=/^(?:0|[1-9]\d?)$/;function d(L,z){return L*k+z}function u(L){if(M(L))return null;if(typeof L=="string"){const x=n(L);return x===null?null:u(x)}if(typeof L=="object"){const x=Z(L.address),F=Number(L.prefix);return x===null||!Number.isInteger(F)||F<0||F>32?null:{address:x,prefix:F}}const z=Number(L);if(!Number.isInteger(z)||z<0||z>S)return null;const H=z%k;return H>32?null:{address:(z-H)/k,prefix:H}}function n(L){if(M(L))return null;const z=String(L).trim();if(z==="")return null;const H=z.indexOf("/");if(H<0)return null;const x=V(z.slice(0,H));if(x===null)return null;const F=z.slice(H+1).trim();if(!y.test(F))return null;const C=Number(F);return C>32?null:d(x,C)}function t(L){const z=u(L);return z?`${U(z.address)}/${z.prefix}`:""}function i(L){return typeof L=="string"&&n(L)!==null}function s(L,z){const H=u(L),x=u(z);return H?x?H.address!==x.address?H.address<x.address?-1:1:H.prefix-x.prefix:-1:x?1:0}function r(L){return L===0?0:4294967295<<32-L>>>0}function o(L){const z=u(L);return z?(z.address&r(z.prefix))>>>0:null}function l(L){const z=u(L);return z?(z.address&r(z.prefix)|~r(z.prefix)>>>0)>>>0:null}function a(L){const z=u(L);return z?2**(32-z.prefix):null}function p(L){const z=u(L);return z?z.prefix===32?1:z.prefix===31?2:2**(32-z.prefix)-2:null}function m(L,z){const H=u(L);if(!H)return!1;const x=Z(z);if(x===null)return!1;const F=r(H.prefix);return(x&F)>>>0===(H.address&F)>>>0}function b(L,z){const H=o(L),x=o(z);return H===null||x===null?!1:H<=l(z)&&x<=l(L)}const g=/^[0-9a-fA-F]{1,4}$/,f=new $(512);function w(L){if(M(L))return null;let z=String(L).trim();if(z==="")return null;const H=z.indexOf("%");if(H>=0&&(z=z.slice(0,H)),z==="")return null;if(z.indexOf(".")>=0){const Q=z.lastIndexOf(":");if(Q<0)return null;const Y=V(z.slice(Q+1));if(Y===null)return null;z=`${z.slice(0,Q+1)}${(Y>>>16&65535).toString(16)}:${(Y&65535).toString(16)}`}const x=z.split("::");if(x.length>2)return null;const F=v(x[0]);if(F===null)return null;if(x.length===1)return F.length===8?F:null;const C=v(x[1]);if(C===null)return null;const B=8-F.length-C.length;if(B<1)return null;const q=F.slice();for(let Q=0;Q<B;Q++)q.push(0);for(const Q of C)q.push(Q);return q}function v(L){if(L==="")return[];const z=[];for(const H of L.split(":")){if(!g.test(H))return null;z.push(parseInt(H,16))}return z}function h(L){if(typeof L!="string")return w(L);if(f.has(L))return f.get(L);const z=w(L);return f.set(L,z),z}function c(L){if(L[0]===0&&L[1]===0&&L[2]===0&&L[3]===0&&L[4]===0&&L[5]===65535)return`::ffff:${U((L[6]<<16|L[7])>>>0)}`;let z=-1,H=0,x=-1,F=0;for(let q=0;q<8;q++)L[q]===0?(x<0?(x=q,F=1):F++,F>H&&(H=F,z=x)):(x=-1,F=0);if(H<2)return L.map(q=>q.toString(16)).join(":");const C=L.slice(0,z).map(q=>q.toString(16)).join(":"),B=L.slice(z+H).map(q=>q.toString(16)).join(":");return`${C}::${B}`}function j(L){const z=w(L);return z===null?null:c(z)}function E(L){return j(L)??""}function O(L){return typeof L=="string"&&L.indexOf(":")>=0&&w(L)!==null}function T(L,z){const H=h(L),x=h(z);if(!H)return x?1:0;if(!x)return-1;for(let F=0;F<8;F++)if(H[F]!==x[F])return H[F]<x[F]?-1:1;return 0}const A=Object.freeze({ipv4:{base:"number",storage:"int32",unsignedInt32:!0,matches:D,parse:L=>V(L.text),compare:I,format:L=>U(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>Z(L),toClipboard:L=>U(L),fromClipboard:L=>V(L)},cidr:{base:"number",storage:"float64",matches:i,parse:L=>n(L.text),compare:s,format:L=>t(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",excelKind:"string",toStorage:L=>{const z=u(L);return z===null?null:d(z.address,z.prefix)},toClipboard:L=>t(L),fromClipboard:L=>n(L)},ipv6:{base:"text",storage:"dictionary",matches:O,parse:L=>j(L.text),compare:T,format:L=>E(L.value),defaults:{filter:"text",editor:"ipaddress",align:"start"},excel:"@",toStorage:L=>j(L),toClipboard:L=>E(L),fromClipboard:L=>j(L)}}),P=A}),Ce("packages/core/src/i18n/catalogue.js",function(e,G){"use strict";Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return M}});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.summaryEngine":"Figures computed by the data engine over every matching row","chart.summaryEngineViewport":"{count} points in this view, fetched from the data engine","chart.summaryEngineDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells counted by the data engine","chart.summaryClientDensity":"{count} rows in this view, more than the {cap} drawn as points, so shown as {cells} density cells computed in the browser","chart.viewportOverCap":"{count} rows in this view, more than the {cap} this map draws; zoom in or narrow the filter","chart.dataTable":"Chart data","chart.viewportFilter.label":"Map view","chart.annotate.rail":"Drawing tools","chart.annotate.select":"Select and move a drawing","chart.annotate.trendLine":"Trend line","chart.annotate.horizontalLine":"Horizontal line","chart.annotate.verticalLine":"Vertical line","chart.annotate.channel":"Parallel channel","chart.annotate.fibonacci":"Fibonacci retracement","chart.annotate.arrow":"Arrow","chart.annotate.measure-x":"Date range","chart.annotate.measure-y":"Price range","chart.annotate.measure-xy":"Date and price range","chart.annotate.measure.bars":{one:"{count} bar",other:"{count} bars"},"chart.annotate.measure.points":{one:"{count} point",other:"{count} points"},"chart.annotate.measure.volume":"Vol {value}","chart.annotate.measure.seconds":"{count}s","chart.annotate.measure.minutes":"{count}m","chart.annotate.measure.hours":"{count}h","chart.annotate.measure.days":"{count}d","chart.annotate.measure.weeks":"{count}w","chart.annotate.measure.months":"{count}mo","chart.annotate.measure.years":"{count}y","chart.annotate.text":"Text","chart.annotate.callout":"Callout","chart.annotate.note":"Note","chart.annotate.delete":"Delete the selected drawing","chart.annotate.editLabel":"Annotation text","chart.zoom.toolbar":"Zoom controls","chart.zoom.in":"Zoom in","chart.zoom.out":"Zoom out","chart.zoom.left":"Pan left","chart.zoom.right":"Pan right","chart.zoom.reset":"Reset the zoom","chart.legendMore":{one:"+{count} more",other:"+{count} more"},"chart.type.line":"Line","chart.type.area":"Area","chart.type.bar":"Bar","chart.type.pie":"Pie","chart.type.donut":"Donut","chart.type.sunburst":"Sunburst","chart.type.scatter":"Scatter","chart.type.step":"Step","chart.type.rangeArea":"Range","chart.type.horizontalBar":"Horizontal bar","chart.type.waterfall":"Waterfall","chart.type.bubble":"Bubble","chart.type.histogram":"Histogram","chart.type.boxplot":"Box plot","chart.type.forest":"Forest plot","chart.type.qq":"QQ plot","chart.type.ecdf":"ECDF","chart.type.lorenz":"Lorenz","chart.type.correlogram":"Correlogram","chart.type.control":"Control","chart.type.capability":"Capability","chart.type.movingRange":"Moving range","chart.type.treemap":"Treemap","chart.type.combo":"Combination","chart.type.pareto":"Pareto","chart.type.heatmap":"Heat map","chart.type.radar":"Radar","chart.type.gauge":"Gauge","chart.type.funnel":"Funnel","chart.type.candlestick":"Candlestick","chart.type.geomap":"Map","chart.type.sankey":"Sankey","chart.type.chord":"Chord","chart.type.network":"Network","chart.type.stream":"Stream","chart.type.marimekko":"Marimekko","chart.type.violin":"Violin","chart.type.gantt":"Gantt","chart.tasksDropped":{one:"{count} more task not shown",other:"{count} more tasks not shown"},"chart.geoUnmatched":{one:"{count} row could not be placed on the map",other:"{count} rows could not be placed on the map"},"chart.r2":"R² {value}","ai.insights":"Insights","ai.explainView":"Explain this view","ai.explain":"Explain","ai.ask":"Ask","ai.apply":"Apply","ai.discard":"Discard","ai.propose":"Propose","ai.approve":"Approve","ai.thinking":"Thinking…","ai.applying":"Applying…","ai.applied":"Applied: {what}","ai.couldNotApply":"Could not apply: {why}","ai.applyFailed":"it failed","ai.discarded":"Discarded.","ai.discardedNothingWritten":"Discarded. Nothing was written.","ai.nothingWritten":"Nothing was written.","ai.nothingWrittenVetoed":"Nothing was written — a before-handler vetoed it.","ai.scope":"Scope: {scope}","ai.unsafeQuery":"I could not turn that into a safe query: {why}","ai.nothingToDo":"nothing to do","ai.insightsFailed":"Could not generate insights right now. The grid is unaffected.","ai.modelUnreachable":"Could not reach the model right now. The grid is unaffected.","ai.flagged":{one:"{count} unverified figure was removed as ungrounded.",other:"{count} unverified figures were removed as ungrounded."},"ai.askPlaceholder":"Ask your data: “EMEA deals over 50k, biggest first”","ai.askLabel":"Ask your data","ai.actorPlaceholder":"Ask AI to change data: “set the Network Upgrade project to In Progress”","ai.actorLabel":"Ask AI to change data","editor.password.show":"Show value","editor.password.hide":"Hide value","editor.password.showField":"Show {column}","editor.password.hideField":"Hide {column}","facets.computing":"Computing…","facets.suppressed.cardinality":"Too many distinct values to chart","facets.suppressed.rows":"Too many rows to chart","facets.suppressed.streaming":"Paused while live data is streaming","facets.suppressed.noProvider":"No distribution available for this data source","facets.suppressed.type":"This column has no chartable distribution","facets.bucketOf":"{count} of {whole} rows","history.undo":"Undo","history.redo":"Redo","history.described":"{action} {label}","history.nothingToUndo":"Nothing to undo","history.nothingToRedo":"Nothing to redo","history.undoDisabled":"Undo (nothing to undo)","history.redoDisabled":"Redo (nothing to redo)","a11y.presence.joined":"{name} joined","a11y.presence.left":"{name} left","prompt.asking":"Asking…","prompt.moreNotes":{one:"and {count} more",other:"and {count} more"},"shortcuts.key.cmd":"Cmd","timeline.live":"Live","timeline.recording":"recording…","panel.zoneHint.group":"Drag a column here to group rows by its values","panel.zoneHint.values":"Drag a column here to total it","panel.zoneHint.pivot":"Drag a column here to pivot across its values","panel.zoneHint.any":"Drag a column here","panel.rowsOf":"{shown} of {total} rows","views.empty":"No saved views yet. Set the grid up as you want it, then save it below.","views.applied":"Applied","views.matchesGrid":"Matches the grid as it is","views.delete":"Delete","views.confirmDelete":"Delete {name}?","views.confirmDeleteLabel":"Confirm deleting {name}","gantt.row.expand":"Expand {name}","gantt.row.collapse":"Collapse {name}","gantt.resource.over":"{name} — over-allocated","kanban.board":"Board","kpi.status.good":"good","kpi.status.warn":"warn","kpi.status.critical":"critical","kpi.status.unknown":"No data","kpi.node.item":"{count} item","kpi.node.items":"{count} items","kpi.node.worst":"worst status {status}","kpi.node.unknown":"{count} unknown"}),M=Object.freeze(Object.keys(_))}),Ce("packages/core/src/i18n/format.js",function(e,G){"use strict";Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"formatMessage",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"lookup",{enumerable:!0,get:function(){return S}});const M=G("packages/core/src/internal/util.js").isFunction,$=/\{(\w+)\}/g,R=new Map,W=new Map;function Z(y){const d=y||"";if(R.has(d))return R.get(d);let u=null;try{u=new Intl.PluralRules(y||void 0)}catch{u=null}return R.set(d,u),u}function V(y,d,u="conjunction"){const n=Array.isArray(y)?y.filter(s=>s!=null&&s!==""):[];if(n.length===0)return"";if(n.length===1)return String(n[0]);const t=`${d||""}|${u}`;let i=W.get(t);if(i===void 0){try{i=new Intl.ListFormat(d||void 0,{style:"long",type:u})}catch{i=null}W.set(t,i)}return i?i.format(n.map(String)):n.map(String).join(", ")}function U(y,d){return y==null?"":typeof y=="number"?Number.isFinite(y)?y.toLocaleString(d||void 0,{maximumFractionDigits:20}):"":String(y)}function D(y,d,u){if(typeof y=="string")return y;if(!y||typeof y!="object")return"";const n=d&&typeof d.count=="number"?d.count:null;if(n===null)return y.other??"";const t=Z(u),i=t?t.select(n):n===1?"one":"other";return y[i]??y.other??""}function I(y,d={},u){const n=D(y,d,u);return n?n.replace($,(t,i)=>Object.prototype.hasOwnProperty.call(d,i)?U(d[i],u):t):""}function k(y,d,u="en-GB"){return typeof y=="string"&&y?y:typeof d=="string"&&d?d:u}function S(y,d){const u=y?y[d]:void 0;return u==null||M(u)?d:u}}),Ce("packages/core/src/i18n/index.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"defaultMessages",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return n}});const _=G("packages/core/src/i18n/catalogue.js"),M=_.EN_GB,$=_.MESSAGE_KEYS,R=G("packages/core/src/i18n/format.js"),W=R.formatMessage,Z=R.formatList,V=R.lookup,U=R.resolveLocale,D=G("packages/core/src/internal/util.js"),I=D.isFunction,k=D.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 R.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return R.resolveLocale}});const S="en-GB";class y{#e=S;#t=M;constructor(i={}){this.configure(i)}configure(i={}){this.#e=U(i.locale,i.declared,S);const s=i.messages;if(!s||typeof s!="object"){this.#t=M;return}const r=Object.keys(s).filter(o=>!(o in M));r.length&&k(`i18n:unknown:${r[0]}`,`message keys not in the catalogue and so ignored: ${r.slice(0,5).join(", ")}${r.length>5?`, and ${r.length-5} more`:""}`),this.#t={...M,...s}}get locale(){return this.#e}t(i,s){return W(V(this.#t,i),s||{},this.#e)}list(i,s){return Z(i,this.#e,s)}number(i,s){const r=Number(i);return Number.isFinite(r)?r.toLocaleString(this.#e,s||{maximumFractionDigits:20}):""}}const d=new y;function u(t){return t instanceof y?t:new y(t||{})}function n(t){const i=t&&typeof t=="object"?t:{},s=$.filter(o=>{const l=i[o];return l==null||l===""||I(l)}),r=Object.keys(i).filter(o=>!(o in M));return{missing:s,unknown:r}}}),Ce("packages/core/src/columns/types/structured.js",function(e,G){"use strict";Object.defineProperty(e,"MASK_DEFAULTS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"maskValue",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"summariseJson",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"canonicalJson",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"parseJsonText",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"STRUCTURED_TYPES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return n}});const _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.isObject,W=G("packages/core/src/i18n/index.js").defaultMessages,Z=Object.freeze({char:"•",length:8,fixedLength:!0,lastVisible:0,emptyDisplay:""});function V(t,i){const s=i||{},r=s.emptyDisplay??Z.emptyDisplay;if(M(t)||t==="")return r;const l=[...typeof s.char=="string"&&s.char!==""?s.char:Z.char][0]||Z.char,a=s.fixedLength??Z.fixedLength,p=Number.isFinite(s.length)&&Number(s.length)>0?Math.floor(Number(s.length)):Z.length,m=typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"||typeof t=="bigint"?String(t):null;let b=0;if(m!==null){const g=Number.isFinite(s.lastVisible)?Math.floor(Number(s.lastVisible)):Z.lastVisible,f=[...m];if(b=g>0&&g<f.length?g:0,b>0){const w=f.slice(f.length-b).join(""),v=Math.max(1,(a?p:f.length)-b);return l.repeat(v)+w}return l.repeat(a?p:Math.max(1,f.length))}return l.repeat(p)}const U=48;function D(t){try{const i=JSON.stringify(t);return i===void 0?null:i}catch{return null}}function I(t,i){if(M(t))return"";const s=Number.isFinite(i&&i.inlineLimit)?Number(i.inlineLimit):U;if(typeof t=="string")return t.length>s?`${t.slice(0,s-1)}…`:t;if(typeof t!="object")return String(t);const r=D(t);if(r!==null&&r.length<=s)return r;if(Array.isArray(t)){const l=t.length;return`[${W.t("count.items",{count:l})}]`}const o=Object.keys(t).length;return`{${W.t("count.keys",{count:o})}}`}function k(t,i){if(t==null)return"null";const s=typeof t;if(s==="number"||s==="boolean"||s==="bigint")return String(t);if(s==="string")return JSON.stringify(t);if(s!=="object")return JSON.stringify(String(t));const r=i||new WeakSet;return r.has(t)?'"[circular]"':(r.add(t),t instanceof Date?JSON.stringify(t.toISOString()):Array.isArray(t)?`[${t.map(a=>k(a,r)).join(",")}]`:`{${Object.keys(t).sort().map(a=>`${JSON.stringify(a)}:${k(t[a],r)}`).join(",")}}`)}function S(t,i){if(M(t))return M(i)?0:1;if(M(i))return-1;const s=k(t),r=k(i);return s<r?-1:s>r?1:0}function y(t){if(M(t))return null;const i=String(t);if(i.trim()==="")return null;try{return JSON.parse(i)}catch{return i}}function d(t){const i=t&&t.cell&&t.cell.props;return $(i)?i:{}}const u=Object.freeze({json:{base:"object",storage:"object",format:t=>I(t&&t.value,d(t&&t.column)),parse:t=>y(t&&t.text),compare:S,defaults:{editor:"code",filter:"text",align:"start"},excel:"@",toClipboard:t=>{if(M(t))return"";if(typeof t=="string")return t;try{const i=JSON.stringify(t,null,2);return i===void 0?String(t):i}catch{return String(t)}},fromClipboard:t=>y(t)},secret:{base:"text",storage:"object",format:t=>V(t&&t.value,d(t&&t.column)),parse:t=>{const i=t&&t.text;return M(i)||String(i)===""?null:String(i)},compare:(t,i)=>{const s=M(t)||t==="",r=M(i)||i==="";return s===r?0:s?1:-1},defaults:{editor:"password",filter:"none",align:"start"},excel:"@",export:{csv:!1,excel:!1},toClipboard:t=>V(t),fromClipboard:t=>M(t)||String(t)===""?null:String(t)}}),n=u}),Ce("packages/core/src/columns/types/unit.js",function(e,G){"use strict";Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return l}}),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 H}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return x}});const _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.warnOnce;function R(F,C,B,q){return Object.freeze({symbol:F,factor:C,aliases:Object.freeze(B||[]),binary:!!(q&&q.binary),prefix:q&&q.prefix||null,auto:!(q&&q.auto===!1)})}function W(F,C,B,q){return R(F,C,B,q)}const Z=Object.freeze({data:Object.freeze([R("B",1,["byte","bytes"]),R("kB",1e3,["kilobyte","kilobytes"],{prefix:"k"}),R("KiB",1024,["kibibyte","kibibytes"],{binary:!0,prefix:"k"}),R("MB",1e6,["megabyte","megabytes"],{prefix:"m"}),R("MiB",1024**2,["mebibyte","mebibytes"],{binary:!0,prefix:"m"}),R("GB",1e9,["gigabyte","gigabytes"],{prefix:"g"}),R("GiB",1024**3,["gibibyte","gibibytes"],{binary:!0,prefix:"g"}),R("TB",1e12,["terabyte","terabytes"],{prefix:"t"}),R("TiB",1024**4,["tebibyte","tebibytes"],{binary:!0,prefix:"t"}),R("PB",1e15,["petabyte","petabytes"],{prefix:"p"})]),bitrate:Object.freeze([R("bps",1,["bit","bits","bit/s","b/s"]),R("kbps",1e3,["kbit","kbits","kbit/s","kb/s","kilobit","kilobits"],{prefix:"k"}),R("Mbps",1e6,["mbit","mbits","mbit/s","mb/s","megabit","megabits"],{prefix:"m"}),R("Gbps",1e9,["gbit","gbits","gbit/s","gb/s","gigabit","gigabits"],{prefix:"g"}),R("Tbps",1e12,["tbit","tbits","tbit/s","tb/s","terabit","terabits"],{prefix:"t"})]),length:Object.freeze([R("nm",1e-9,["nanometre","nanometres","nanometer","nanometers"]),R("µm",1e-6,["um","micrometre","micrometres","micrometer","micrometers","micron","microns"]),R("mm",.001,["millimetre","millimetres","millimeter","millimeters"]),R("cm",.01,["centimetre","centimetres","centimeter","centimeters"]),R("in",.0254,["inch","inches"],{auto:!1}),R("ft",.3048,["foot","feet"],{auto:!1}),R("yd",.9144,["yard","yards"],{auto:!1}),R("m",1,["metre","metres","meter","meters"]),R("km",1e3,["kilometre","kilometres","kilometer","kilometers"]),R("mi",1609.344,["mile","miles"],{auto:!1}),R("nmi",1852,["nauticalmile","nauticalmiles"],{auto:!1})]),mass:Object.freeze([R("mg",.001,["milligram","milligrams"]),R("g",1,["gram","grams"]),R("oz",28.349523125,["ounce","ounces"],{auto:!1}),R("lb",453.59237,["pound","pounds","lbs"],{auto:!1}),R("kg",1e3,["kilogram","kilograms"]),R("st",6350.29318,["stone"],{auto:!1}),R("t",1e6,["tonne","tonnes","ton"],{auto:!1}),R("ton (US)",907184.74,["ton","shortton"],{auto:!1}),R("ton (UK)",10160469088e-4,["ton","longton"],{auto:!1})]),duration:Object.freeze([R("ns",1e-9,["nsec","nsecs","nanosecond","nanoseconds"]),R("µs",1e-6,["us","usec","usecs","microsecond","microseconds"]),R("ms",.001,["msec","msecs","millisecond","milliseconds"]),R("s",1,["sec","secs","second","seconds"]),R("m",60,["min","mins","minute","minutes"]),R("h",3600,["hr","hrs","hour","hours"]),R("d",86400,["day","days"])]),speed:Object.freeze([R("mm/s",.001,["millimetre/s","millimeter/s"]),R("ft/s",.3048,["fps","foot/s","feet/s"],{auto:!1}),R("km/h",1/3.6,["kph","kmh","kilometre/h","kilometer/h"],{auto:!1}),R("mph",.44704,["mile/h","miles/h"],{auto:!1}),R("kn",1852/3600,["knot","knots"],{auto:!1}),R("m/s",1,["metre/s","meter/s","mps"]),R("km/s",1e3,["kilometre/s","kilometer/s"])]),acceleration:Object.freeze([R("mm/s²",.001,["mm/s2"]),R("ft/s²",.3048,["ft/s2"],{auto:!1}),R("m/s²",1,["m/s2","metre/s2","meter/s2"]),R("g",9.80665,["gee","gravity"],{auto:!1})]),area:Object.freeze([R("mm²",1e-6,["mm2"]),R("cm²",1e-4,["cm2"]),R("in²",64516e-8,["in2","sqin"],{auto:!1}),R("ft²",.09290304,["ft2","sqft"],{auto:!1}),R("yd²",.83612736,["yd2","sqyd"],{auto:!1}),R("m²",1,["m2","sqm"]),R("ha",1e4,["hectare","hectares"],{auto:!1}),R("ac",4046.8564224,["acre","acres"],{auto:!1}),R("km²",1e6,["km2","sqkm"])]),volume:Object.freeze([R("µL",1e-6,["ul","microlitre","microliter"]),R("mL",.001,["millilitre","milliliter"]),R("fl oz (US)",.0295735295625,["fl oz","usfloz"],{auto:!1}),R("fl oz (imp)",.0284130625,["fl oz","impfloz"],{auto:!1}),R("L",1,["litre","litres","liter","liters"]),R("gal (US)",3.785411784,["gal","usgal","usgallon"],{auto:!1}),R("gal (imp)",4.54609,["gal","impgal","impgallon"],{auto:!1}),R("m³",1e3,["m3","cubicmetre","cubicmeter","kl"],{auto:!1}),R("bbl",158.987294928,["barrel","barrels"],{auto:!1})]),energy:Object.freeze([R("eV",1602176634e-28,["electronvolt","electronvolts"],{auto:!1}),R("J",1,["joule","joules"]),R("cal",4.184,["calorie","calories"],{auto:!1}),R("kJ",1e3,["kilojoule","kilojoules"]),R("BTU",1055.05585262,["btu"],{auto:!1}),R("kcal",4184,["kilocalorie","kilocalories","Cal"],{auto:!1}),R("MJ",1e6,["megajoule","megajoules"]),R("kWh",36e5,["kilowatthour","kilowatthours"],{auto:!1}),R("GJ",1e9,["gigajoule","gigajoules"]),R("MWh",36e8,["megawatthour","megawatthours"],{auto:!1})]),power:Object.freeze([R("mW",.001,["milliwatt","milliwatts"]),R("W",1,["watt","watts"]),R("BTU/h",1055.05585262/3600,["btuh","btu/h"],{auto:!1}),R("kW",1e3,["kilowatt","kilowatts"]),R("hp",745.6998715822702,["horsepower"],{auto:!1}),R("MW",1e6,["megawatt","megawatts"]),R("GW",1e9,["gigawatt","gigawatts"])]),force:Object.freeze([R("mN",.001,["millinewton","millinewtons"]),R("N",1,["newton","newtons"]),R("lbf",4.4482216152605,["poundforce"],{auto:!1}),R("kgf",9.80665,["kilogramforce"],{auto:!1}),R("kN",1e3,["kilonewton","kilonewtons"]),R("MN",1e6,["meganewton","meganewtons"])]),pressure:Object.freeze([R("Pa",1,["pascal","pascals"]),R("mbar",100,["millibar"],{auto:!1}),R("inH₂O",249.0889,["inh2o"],{auto:!1}),R("mmHg",133.322387415,["torr"],{auto:!1}),R("kPa",1e3,["kilopascal","kilopascals"]),R("inHg",3386.388640341,["inhg"],{auto:!1}),R("psi",6894.757293168361,["lbf/in2"],{auto:!1}),R("bar",1e5,[],{auto:!1}),R("atm",101325,["atmosphere","atmospheres"],{auto:!1}),R("MPa",1e6,["megapascal","megapascals"]),R("GPa",1e9,["gigapascal","gigapascals"])]),torque:Object.freeze([R("N·m",1,["nm","n.m","newtonmetre","newtonmeter"]),R("lbf·ft",1.3558179483314003,["lbfft","lbf.ft","ftlb","ft-lb"],{auto:!1}),R("kN·m",1e3,["knm","kn.m"],{auto:!1}),R("MN·m",1e6,["mnm","mn.m"],{auto:!1})]),density:Object.freeze([R("kg/m³",1,["kg/m3"]),R("lb/ft³",16.01846337396014,["lb/ft3","pcf"],{auto:!1}),R("g/cm³",1e3,["g/cm3","g/ml","kg/l"],{auto:!1}),R("t/m³",1e3,["t/m3"],{auto:!1})]),flow:Object.freeze([R("L/min",1/6e4,["lpm","l/min"],{auto:!1}),R("m³/h",1/3600,["m3/h","cmh"],{auto:!1}),R("gpm (US)",.003785411784/60,["gpm","usgpm"],{auto:!1}),R("gpm (imp)",.00454609/60,["gpm","impgpm"],{auto:!1}),R("cfm",.0004719474432,["ft3/min"],{auto:!1}),R("L/s",.001,["lps","l/s"],{auto:!1}),R("m³/s",1,["m3/s","cms"])]),angle:Object.freeze([R("″",Math.PI/648e3,["arcsec","arcsecond","arcseconds"],{auto:!1}),R("′",Math.PI/10800,["arcmin","arcminute","arcminutes"],{auto:!1}),R("mrad",.001,["milliradian","milliradians"],{auto:!1}),R("mil",Math.PI/3200,["nato-mil"],{auto:!1}),R("°",Math.PI/180,["deg","degree","degrees"],{auto:!1}),R("gon",Math.PI/200,["grad","gradian","gradians"],{auto:!1}),R("rad",1,["radian","radians"]),R("turn",2*Math.PI,["rev","revolution","revolutions"],{auto:!1})]),angularVelocity:Object.freeze([R("°/s",Math.PI/180,["degps","deg/s","degrees/s"],{auto:!1}),R("rad/s",1,["radps","radians/s"]),R("rpm",2*Math.PI/60,["rev/min","r/min","revolutions/min"],{auto:!1}),R("rps",2*Math.PI,["rev/s","r/s","revolutions/s"],{auto:!1})]),fraction:Object.freeze([R("ppt",1e-12,["partspertrillion"],{auto:!1}),R("ppb",1e-9,["partsperbillion"]),R("ppm",1e-6,["partspermillion"]),R("bp",1e-4,["bps-finance","basispoint","basispoints","bips"],{auto:!1}),R("‰",.001,["permille","permil"],{auto:!1}),R("%",.01,["pct","percent"]),R("×",1,["x","ratio","times"])]),molarity:Object.freeze([R("pM",1e-12,["picomolar","picomolarity"]),R("nM",1e-9,["nanomolar","nanomolarity"]),R("µM",1e-6,["um-molar","micromolar","micromolarity"]),R("mM",.001,["millimolar","millimolarity"]),R("M",1,["molar","mol/l","mol/L","molarity"]),R("mol/m³",.001,["mol/m3"],{auto:!1})]),massFlow:Object.freeze([R("mg/s",1e-6,["milligrams/s"]),R("g/s",.001,["grams/s"]),R("kg/h",1/3600,["kilograms/h","kgph"],{auto:!1}),R("kg/s",1,["kilograms/s","kgps"]),R("t/h",1e3/3600,["tonnes/h","tph"],{auto:!1}),R("lb/h",.45359237/3600,["pounds/h","pph"],{auto:!1}),R("t/s",1e3,["tonnes/s"],{auto:!1})]),viscosity:Object.freeze([R("µPa·s",1e-6,["upas","micropascalsecond"]),R("cP",.001,["centipoise"],{auto:!1}),R("mPa·s",.001,["mpas","millipascalsecond"]),R("P",.1,["poise"],{auto:!1}),R("Pa·s",1,["pas","pascalsecond"])]),kinematicViscosity:Object.freeze([R("cSt",1e-6,["centistokes","centistoke"]),R("mm²/s",1e-6,["mm2/s"],{auto:!1}),R("St",1e-4,["stokes","stoke"],{auto:!1}),R("m²/s",1,["m2/s"])]),thermalConductivity:Object.freeze([R("mW/(m·K)",.001,["mw/mk"]),R("W/(m·K)",1,["w/mk","wmk"]),R("kW/(m·K)",1e3,["kw/mk"],{auto:!1}),R("BTU/(hr·ft·°F)",1.730734666,["btu/hrftf"],{auto:!1})]),specificHeat:Object.freeze([R("J/(kg·K)",1,["j/kgk","jkgk"]),R("kJ/(kg·K)",1e3,["kj/kgk"]),R("cal/(g·°C)",4184,["cal/gc"],{auto:!1})]),doseRate:Object.freeze([R("nSv/h",1e-9,["nsvh"]),R("µSv/h",1e-6,["usv/h","usvh"]),R("mSv/h",.001,["msvh"]),R("Sv/h",1,["svh"]),R("mSv/a",.001/8766,["msv/year","msvpa"],{auto:!1})])}),V=Symbol("ambiguous"),U=new Map,D=new Map;function I(F,C){const B=String(F||"").trim();if(!B)throw new Error("[lattice] a unit system needs a name");if(Z[B]||D.has(B))throw new Error(`[lattice] unit system "${B}" already exists`);const q=[...C||[]];if(!q.length)throw new Error(`[lattice] unit system "${B}" has no units`);if(!q.some(Y=>Y.factor===1))throw new Error(`[lattice] unit system "${B}" has no base unit (none with factor 1)`);const Q=new Set;for(const Y of q){if(Q.has(Y.symbol))throw new Error(`[lattice] unit system "${B}" declares "${Y.symbol}" twice`);Q.add(Y.symbol)}return D.set(B,Object.freeze(q)),U.delete(B),B}function k(){return[...Object.keys(Z),...D.keys()]}function S(F){const C=y(F);return C?C.units:[]}function y(F){const C=String(F||""),B=U.get(C);if(B!==void 0)return B;const q=Z[C]||D.get(C);if(!q)return U.set(C,null),null;const Q=Object.freeze([...q].sort((re,se)=>re.factor-se.factor)),Y=new Map,J=new Map,te=(re,se)=>{const de=Y.get(re);de===void 0?Y.set(re,se):de!==se&&Y.set(re,V)};for(const re of Q){te(re.symbol.toLowerCase(),re);for(const se of re.aliases)te(se.toLowerCase(),re);if(re.prefix){const se=J.get(re.prefix)||[];se.push(re),J.set(re.prefix,se)}}const ee={units:Q,byToken:Y,byPrefix:J,decimal:Q.filter(re=>!re.binary&&re.auto),binary:Q.some(re=>re.binary)?Q.filter(re=>(re.binary||re.factor===1)&&re.auto):null};return U.set(C,ee),ee}function d(F,C){return C&&F.binary||F.decimal}function u(F,C){const B=y(F);if(!B||M(C))return null;const q=B.units.find(Y=>Y.symbol===String(C));if(q)return q;const Q=B.byToken.get(String(C).trim().toLowerCase());return Q&&Q!==V?Q:null}const n=new WeakMap;function t(F){const C=F||{};if(typeof C=="object"&&C!==null){const Y=n.get(C);if(Y!==void 0)return Y}const B=C.system||"data",q=y(B);let Q=null;if(!q)$(`unit:system:${B}`,`unknown unit system "${B}"; known systems are ${k().join(", ")}`);else{let Y=C.unit?u(B,C.unit):null;Y||(C.unit&&$(`unit:unit:${B}:${C.unit}`,`unknown unit "${C.unit}" in system "${B}"; falling back to ${q.units[0].symbol}`),Y=q.units.find(J=>J.factor===1)||q.units[0]),Q={index:q,base:Y,binary:C.binary===!0}}return typeof C=="object"&&C!==null&&n.set(C,Q),Q}const i=new WeakMap;function s(F,C){if(!F||!C||!Array.isArray(F.compound)||F.compound.length===0)return null;const B=i.get(F);if(B!==void 0)return B;const q=new Set,Q=[];for(const J of F.compound){const te=u(F.system||"data",J);if(!te){$(`unit:compound:${F.system}:${J}`,`unknown compound unit "${J}" in system "${F.system||"data"}"; ignoring it`);continue}q.has(te.symbol)||(q.add(te.symbol),Q.push(te))}Q.sort((J,te)=>te.factor-J.factor);const Y=Q.length>=2?Q:null;return i.set(F,Y),Y}function r(F,C,B){return C===B||C.factor===B.factor?F:F*C.factor/B.factor}const o=new Map;function l(F){const C=F||"",B=o.get(C);if(B)return B;const q={group:",",decimal:"."};try{for(const Q of new Intl.NumberFormat(F||void 0).formatToParts(12345.6))Q.type==="group"?q.group=Q.value:Q.type==="decimal"&&(q.decimal=Q.value)}catch{}return o.set(C,q),q}const a=/[\s   ]/g,p=/^[+-]?[\d   '’ .,]*(?:[eE][+-]?\d+)?/,m=/^[^\d+\-(.,\s]+\s*/,b=/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;function g(F,C){const{group:B,decimal:q}=l(C);let Q=String(F).replace(a,"");if(Q==="")return null;const Y=q?Q.indexOf(q):-1;if(B&&B!==q){if(Y>=0&&Q.indexOf(B,Y+q.length)>=0)return null;Q=Q.split(B).join("")}if(q&&q!=="."&&(Q=Q.split(q).join(".")),!b.test(Q))return null;const J=Number(Q);return Number.isFinite(J)?J:null}function f(F,C,B){const q=String(F).trim().replace(/\.$/,"");if(q==="")return null;const Q=C.units.find(se=>se.symbol===q);if(Q)return Q;const Y=q.toLowerCase(),J=C.byToken.get(Y);if(J===V)return null;if(J)return J;const te=C.byPrefix.get(Y);if(!te||!te.length)return null;const ee=d(C,B),re=te.filter(se=>ee.includes(se));return re.length===1?re[0]:null}function w(F,C,B,q){let Q=F,Y=0,J=!1,te=!1;for(;Q!=="";){const ee=p.exec(Q)[0];if(ee==="")return null;const re=g(ee,q&&q.locale);if(re===null)return null;Q=Q.slice(ee.length).trim();const se=Q.search(/[+-]?[\d]/),de=(se>=0?Q.slice(0,se):Q).trim();if(Q=se>=0?Q.slice(se).trim():"",de===""){if(J)return null;te=!0,Y+=r(re,B[0],C.base)}else{const ie=f(de,C.index,C.binary);if(!ie)return null;Y+=r(re,ie,C.base)}if(J=!0,te&&Q!=="")return null}return J?Y:null}function v(F,C){if(M(F))return null;if(typeof F=="number")return Number.isFinite(F)?F:null;const B=t(C);if(!B)return null;let q=String(F).trim();if(q==="")return null;let Q=!1;q.startsWith("(")&&q.endsWith(")")&&(Q=!0,q=q.slice(1,-1).trim());const Y=s(C,B);if(Y){q.startsWith("-")&&(Q=!0,q=q.slice(1).trim());const oe=w(q,B,Y,C);return oe===null?null:Q?-oe:oe}let J=null;const te=m.exec(q);if(te&&te[0]){const oe=f(te[0].trim(),B.index,B.binary);oe&&(J=oe,q=q.slice(te[0].length).trim())}const ee=p.exec(q)[0],re=g(ee,C&&C.locale);if(re===null)return null;const se=q.slice(ee.length).trim();if(J&&se!=="")return null;const de=J||(se===""?B.base:f(se,B.index,B.binary));if(!de)return null;const ie=r(re,de,B.base);return Q?-ie:ie}const h=new Map;function c(F,C,B,q){const Q=`${F||""}|${C}|${B}|${q?1:0}`;let Y=h.get(Q);return Y||(Y=new Intl.NumberFormat(F||void 0,{minimumFractionDigits:C,maximumFractionDigits:B,useGrouping:q}),h.set(Q,Y)),Y}function j(F,C){if(!Number.isFinite(F)||F===0)return Math.max(0,C-1);const B=Math.floor(Math.log10(Math.abs(F)));return Math.min(20,Math.max(0,C-1-B))}function E(F,C){if(!Number.isFinite(F)||F===0)return F;const B=Math.ceil(Math.log10(Math.abs(F))),q=10**(C-B);return Math.round(F*q)/q}function O(F,C,B){if(!B||B===C.base.symbol)return C.base;if(B!=="auto")return T(C,B);if(F===0||!Number.isFinite(F))return C.base;const q=Math.abs(F)*C.base.factor,Q=d(C.index,C.binary);let Y=Q[0];for(const ee of Q)q>=ee.factor&&(Y=ee);if(q>=Y.factor)return Y;let J=Y;for(const ee of C.index.units)ee.binary!==C.binary&&ee.factor!==1||ee.factor<=q&&ee.factor>(J===Y?0:J.factor)&&(J=ee);if(J!==Y)return J;let te=Y;for(const ee of C.index.units)ee.binary!==C.binary&&ee.factor!==1||ee.factor<te.factor&&(te=ee);return te.factor<C.base.factor?te:C.base}function T(F,C){const B=F.index.units.find(Q=>Q.symbol===C);if(B)return B;const q=F.index.byToken.get(String(C).toLowerCase());return q&&q!==V?q:($(`unit:display:${C}`,`unknown display unit "${C}"; rendering in ${F.base.symbol}`),F.base)}function A(F,C,B,q){const Q=F<0;let Y=Math.abs(F)*C.base.factor;const J=typeof q.decimals=="number"?q.decimals:q.minDecimals??0,te=typeof q.decimals=="number"?q.decimals:q.maxDecimals??Math.max(J,2),ee=q.space??" ",re=[];for(let de=0;de<B.length;de++){const ie=B[de],oe=de===B.length-1;let ue=oe?Y/ie.factor:Math.floor(Y/ie.factor);if(Y-=ue*ie.factor,oe){const pe=10**te;ue=Math.round(ue*pe)/pe+0}const ce=oe?c(q.locale,J,te,q.group!==!1):c(q.locale,0,0,q.group!==!1);re.push(`${ce.format(ue)}${ee}${ie.symbol}`)}const se=re.join(" ");return Q?`-${se}`:se}function P(F,C){const B=C||{},q=B.nullDisplay??"";if(M(F)||F==="")return q;const Q=typeof F=="number"?F:Number(F);if(!Number.isFinite(Q))return q;const Y=t(B);if(!Y)return String(Q);const J=s(B,Y);if(J)return A(Q,Y,J,B);const te=typeof B.significantFigures=="number"&&B.significantFigures>0?B.significantFigures:0,ee=te?E(Q,te):Q,re=O(ee,Y,B.display),se=r(ee,Y.base,re);let de=typeof B.decimals=="number"?B.decimals:B.minDecimals??0,ie=typeof B.decimals=="number"?B.decimals:B.maxDecimals??Math.max(de,2);te&&(de=j(se,te),ie=de);const oe=c(B.locale,de,ie,B.group!==!1).format(se),ue=B.space??" ";return B.placement==="prefix"?`${re.symbol}${B.space??""}${oe}`:`${oe}${ue}${re.symbol}`}function L(F,C){const B=M(F)||Number.isNaN(F)?null:Number(F),q=M(C)||Number.isNaN(C)?null:Number(C);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 z(F){const C=typeof F.decimals=="number"&&F.decimals>0?`.${"0".repeat(F.decimals)}`:"";return`${typeof F.decimals=="number"?`#,##0${C}`:"#,##0.##"}" ${F.symbol}"`}function H(F){const C={system:"data",...F||{}},B=t(C),q=B?B.base.symbol:String(C.unit||""),Q=Object.freeze({...C,unit:q}),Y=Object.freeze({...Q,display:q,decimals:void 0,minDecimals:0,maxDecimals:20,group:!1}),J=new Map([[Q.locale||"",Q]]),te=ee=>{const re=ee||"";let se=J.get(re);return se||(se=Object.freeze({...Q,locale:ee||void 0}),J.set(re,se)),se};return{base:"number",extends:"number",storage:"float64",unitConfig:Q,format:ee=>P(ee.value,ee.locale?te(ee.locale):Q),parse:ee=>v(ee.text,ee.locale?te(ee.locale):Q),compare:L,defaults:{filter:"number",editor:"unit",align:"end",total:C.total||"sum"},...C.totals?{totals:C.totals}:{},excel:C.excel||z({decimals:C.decimals,symbol:q}),toStorage:ee=>typeof ee=="number"?Number.isFinite(ee)?ee:null:typeof ee=="string"?v(ee,Q):M(ee)?null:v(String(ee),Q),toClipboard:ee=>P(ee,Y),fromClipboard:ee=>v(ee,Q)}}const x=H}),Ce("packages/core/src/columns/types/engineering.js",function(e,G){"use strict";Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return W}});const M=G("packages/core/src/internal/util.js").isNil,R=G("packages/core/src/columns/types/unit.js").createUnitType;function W(U){const D=2*Math.PI/U;return I=>{let k=0,S=0,y=0;for(const u of I||[]){if(M(u))continue;const n=Number(u);Number.isFinite(n)&&(k+=Math.cos(n*D),S+=Math.sin(n*D),y+=1)}return!y||Math.hypot(k,S)/y<1e-12?null:(Math.atan2(S,k)/D%U+U)%U}}function Z(U){return{supported:["sum","avg","min","max","count","countValues"],implement:{avg:W(U)}}}const V=Object.freeze({metres:R({system:"length",unit:"m",display:"auto",maxDecimals:3}),millimetres:R({system:"length",unit:"mm",maxDecimals:2}),kilometres:R({system:"length",unit:"km",maxDecimals:3}),grams:R({system:"mass",unit:"g",display:"auto",maxDecimals:3}),kilograms:R({system:"mass",unit:"kg",maxDecimals:3}),tonnes:R({system:"mass",unit:"t",maxDecimals:3}),seconds:R({system:"duration",unit:"s",display:"auto",maxDecimals:3}),milliseconds:R({system:"duration",unit:"ms",maxDecimals:3}),hours:R({system:"duration",unit:"h",maxDecimals:2}),speed:R({system:"speed",unit:"m/s",display:"auto",maxDecimals:2}),kph:R({system:"speed",unit:"km/h",maxDecimals:1}),mph:R({system:"speed",unit:"mph",maxDecimals:1}),knots:R({system:"speed",unit:"kn",maxDecimals:1}),acceleration:R({system:"acceleration",unit:"m/s²",maxDecimals:3}),area:R({system:"area",unit:"m²",display:"auto",maxDecimals:2}),hectares:R({system:"area",unit:"ha",maxDecimals:4}),volume:R({system:"volume",unit:"L",display:"auto",maxDecimals:3}),cubicMetres:R({system:"volume",unit:"m³",maxDecimals:3}),energy:R({system:"energy",unit:"J",display:"auto",maxDecimals:3}),kilowattHours:R({system:"energy",unit:"kWh",maxDecimals:2}),power:R({system:"power",unit:"W",display:"auto",maxDecimals:2}),kilowatts:R({system:"power",unit:"kW",maxDecimals:2}),force:R({system:"force",unit:"N",display:"auto",maxDecimals:2}),pressure:R({system:"pressure",unit:"Pa",display:"auto",maxDecimals:2}),bar:R({system:"pressure",unit:"bar",maxDecimals:3}),psi:R({system:"pressure",unit:"psi",maxDecimals:1}),torque:R({system:"torque",unit:"N·m",maxDecimals:2}),density:R({system:"density",unit:"kg/m³",maxDecimals:2}),flow:R({system:"flow",unit:"m³/s",maxDecimals:4}),litresPerMinute:R({system:"flow",unit:"L/min",maxDecimals:1}),radians:R({system:"angle",unit:"rad",maxDecimals:4,totals:Z(2*Math.PI)}),degrees:R({system:"angle",unit:"°",maxDecimals:2,totals:Z(360)}),rpm:R({system:"angularVelocity",unit:"rpm",maxDecimals:0}),angularVelocity:R({system:"angularVelocity",unit:"rad/s",maxDecimals:3}),ppm:R({system:"fraction",unit:"ppm",maxDecimals:2}),ppb:R({system:"fraction",unit:"ppb",maxDecimals:2}),basisPoints:R({system:"fraction",unit:"bp",maxDecimals:1}),molarity:R({system:"molarity",unit:"M",display:"auto",maxDecimals:3}),massFlow:R({system:"massFlow",unit:"kg/s",maxDecimals:3}),tonnesPerHour:R({system:"massFlow",unit:"t/h",maxDecimals:2}),viscosity:R({system:"viscosity",unit:"Pa·s",display:"auto",maxDecimals:3}),kinematicViscosity:R({system:"kinematicViscosity",unit:"cSt",maxDecimals:2}),thermalConductivity:R({system:"thermalConductivity",unit:"W/(m·K)",maxDecimals:3}),specificHeat:R({system:"specificHeat",unit:"J/(kg·K)",maxDecimals:1}),doseRate:R({system:"doseRate",unit:"µSv/h",display:"auto",maxDecimals:2})})}),Ce("packages/core/src/columns/types/si.js",function(e,G){"use strict";Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=G("packages/core/src/columns/types/unit.js"),M=_.defineUnit,$=_.registerUnitSystem,R=_.createUnitType,W=Object.freeze([Object.freeze({symbol:"f",name:"femto",factor:1e-15}),Object.freeze({symbol:"p",name:"pico",factor:1e-12}),Object.freeze({symbol:"n",name:"nano",factor:1e-9}),Object.freeze({symbol:"µ",name:"micro",factor:1e-6}),Object.freeze({symbol:"m",name:"milli",factor:.001}),Object.freeze({symbol:"c",name:"centi",factor:.01}),Object.freeze({symbol:"",name:"",factor:1}),Object.freeze({symbol:"k",name:"kilo",factor:1e3}),Object.freeze({symbol:"M",name:"mega",factor:1e6}),Object.freeze({symbol:"G",name:"giga",factor:1e9}),Object.freeze({symbol:"T",name:"tera",factor:1e12}),Object.freeze({symbol:"P",name:"peta",factor:1e15})]),Z=Object.freeze(["p","n","µ","m","","k","M","G"]);function V(S){const y=String(S.base),d=new Set([...S.prefixes||Z,""]),u=[];for(const n of W){if(!d.has(n.symbol))continue;const t=`${n.symbol}${y}`,i=[];if(S.name){i.push(`${n.name}${S.name}`,`${n.name}${S.name}s`);const s=n.name.slice(-1);if(s&&S.name.startsWith(s)){const r=`${n.name.slice(0,-1)}${S.name}`;i.push(r,`${r}s`)}}n.symbol==="µ"&&i.push(`u${y}`),n.factor===1&&S.aliases&&i.push(...S.aliases),u.push(M(t,n.factor,i))}for(const n of S.extra||[])u.push(n);return u}function U(S,y){const d=V(y);return $(S,d)}function D(S,y,d){return U(S,y),R({system:S,unit:y.base,display:"auto",maxDecimals:3,...d||{}})}const I=Object.freeze({voltage:D("voltage",{base:"V",name:"volt"}),current:D("current",{base:"A",name:"amp",aliases:["ampere","amperes"]}),resistance:D("resistance",{base:"Ω",name:"ohm",aliases:["ohm","ohms","R"],prefixes:["m","","k","M","G"]}),capacitance:D("capacitance",{base:"F",name:"farad",prefixes:["f","p","n","µ","m",""]}),inductance:D("inductance",{base:"H",name:"henry",prefixes:["p","n","µ","m",""]}),charge:D("charge",{base:"C",name:"coulomb",prefixes:["p","n","µ","m",""],extra:[M("mAh",3.6,["milliamphour","milliamphours"],{auto:!1}),M("Ah",3600,["amphour","amphours"],{auto:!1})]}),conductance:D("conductance",{base:"S",name:"siemens",prefixes:["n","µ","m","","k"]}),fluxDensity:D("fluxDensity",{base:"T",name:"tesla",prefixes:["n","µ","m",""],extra:[M("G",1e-4,["gauss"],{auto:!1})]}),luminousFlux:D("luminousFlux",{base:"lm",name:"lumen",prefixes:["m","","k"]}),illuminance:D("illuminance",{base:"lx",name:"lux",prefixes:["m","","k"]}),luminousIntensity:D("luminousIntensity",{base:"cd",name:"candela",prefixes:["m","","k"]}),substance:D("substance",{base:"mol",name:"mole",prefixes:["n","µ","m","","k"]}),absorbedDose:D("absorbedDose",{base:"Gy",name:"gray",prefixes:["µ","m",""]}),equivalentDose:D("equivalentDose",{base:"Sv",name:"sievert",prefixes:["n","µ","m",""]}),radioactivity:D("radioactivity",{base:"Bq",name:"becquerel",prefixes:["","k","M","G","T"],extra:[M("Ci",37e9,["curie","curies"],{auto:!1})]}),frequency:D("frequency",{base:"Hz",name:"hertz",prefixes:["m","","k","M","G","T"]})}),k=D}),Ce("packages/core/src/columns/types/temperature.js",function(e,G){"use strict";Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return R}}),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 S}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const M=G("packages/core/src/internal/util.js").isNil,$=Object.freeze({C:Object.freeze({symbol:"°C",aliases:["c","°c","celsius","centigrade"],toKelvin:u=>u+273.15,fromKelvin:u=>u-273.15}),F:Object.freeze({symbol:"°F",aliases:["f","°f","fahrenheit"],toKelvin:u=>(u+459.67)*(5/9),fromKelvin:u=>u*(9/5)-459.67}),K:Object.freeze({symbol:"K",aliases:["k","kelvin"],toKelvin:u=>u,fromKelvin:u=>u}),R:Object.freeze({symbol:"°R",aliases:["r","°r","rankine"],toKelvin:u=>u*(5/9),fromKelvin:u=>u*(9/5)})});function R(u){if(M(u))return null;const n=String(u).trim();if(n==="")return null;for(const[i,s]of Object.entries($))if(n===i||n===s.symbol)return{key:i,scale:s};const t=n.toLowerCase();for(const[i,s]of Object.entries($))if(s.aliases.includes(t))return{key:i,scale:s};return null}function W(u,n,t){const i=R(n),s=R(t);return!i||!s||!Number.isFinite(Number(u))?null:i.key===s.key?Number(u):s.scale.fromKelvin(i.scale.toKelvin(Number(u)))}const Z=new Map;function V(u,n,t){const i=`${u||""}|${n}|${t}`;let s=Z.get(i);return s||(s=new Intl.NumberFormat(u||void 0,{minimumFractionDigits:n,maximumFractionDigits:t}),Z.set(i,s)),s}function U(u,n){const t=n||{},i=t.nullDisplay??"";if(M(u)||u==="")return i;const s=Number(u);if(!Number.isFinite(s))return i;const r=R(t.scale||"C");if(!r)return String(s);const o=R(t.display||t.scale||"C")||r,l=o.key===r.key?s:o.scale.fromKelvin(r.scale.toKelvin(s)),a=typeof t.decimals=="number"?t.decimals:null,p=a??t.minDecimals??0,m=a??t.maxDecimals??1;return`${V(t.locale,p,m).format(l)}${t.space??" "}${o.scale.symbol}`}const D=/^[+-]?[\d\s.,  ]*\d/;function I(u,n){const t=String(u).trim();if(t==="")return null;const i=new Intl.NumberFormat(n||void 0).formatToParts(1.1).find(l=>l.type==="decimal")?.value||".",s=i===","?".":",",r=t.split(s).join("").split(/[\s  ]/).join("").replace(i,"."),o=Number(r);return Number.isFinite(o)?o:null}function k(u,n){if(M(u))return null;const t=n||{},i=R(t.scale||"C");if(!i)return null;if(typeof u=="number")return Number.isFinite(u)?u:null;let s=String(u).trim();if(s==="")return null;let r=!1;s.startsWith("(")&&s.endsWith(")")&&(r=!0,s=s.slice(1,-1).trim());const o=D.exec(s);if(!o)return null;const l=I(o[0],t.locale);if(l===null)return null;const a=s.slice(o[0].length).trim();if(a==="")return r?-l:l;const p=R(a);if(!p)return null;const m=p.key===i.key?l:i.scale.fromKelvin(p.scale.toKelvin(l));return r?-m:m}function S(u){const n=Object.freeze({scale:"C",...u||{}}),i=(R(n.scale)||R("C")).scale.symbol,s=Object.freeze({...n,display:n.scale,decimals:void 0,minDecimals:0,maxDecimals:20}),r=new Map([[n.locale||"",n]]),o=l=>{const a=l||"";let p=r.get(a);return p||(p=Object.freeze({...n,locale:l||void 0}),r.set(a,p)),p};return{base:"number",extends:"number",storage:"float64",temperatureConfig:n,format:l=>U(l.value,l.locale?o(l.locale):n),parse:l=>k(l.text,l.locale?o(l.locale):n),defaults:{filter:"number",editor:"temperature",align:"end",total:"avg"},totals:{supported:["avg","min","max","count","countValues"]},excel:n.excel||`#,##0${typeof n.decimals=="number"&&n.decimals>0?`.${"0".repeat(n.decimals)}`:".#"}" ${i}"`,toStorage:l=>typeof l=="number"?Number.isFinite(l)?l:null:typeof l=="string"?k(l,n):M(l)?null:k(String(l),n),toClipboard:l=>U(l,s),fromClipboard:l=>k(l,n)}}const y=Object.freeze({celsius:S({scale:"C"}),fahrenheit:S({scale:"F"}),kelvin:S({scale:"K"})}),d=S}),Ce("packages/core/src/columns/types/radix.js",function(e,G){"use strict";Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"digitsForWidth",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"radixRange",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"radixName",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"normaliseRadixOptions",{enumerable:!0,get:function(){return m}}),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 h}}),Object.defineProperty(e,"parseRadixResult",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return A}});const _=G("packages/core/src/internal/util.js"),M=_.isNil,$=_.warnOnce,R=Object.freeze({2:2,8:8,16:16,bin:2,binary:2,base2:2,oct:8,octal:8,base8:8,hex:16,hexadecimal:16,base16:16}),W=Object.freeze({2:1,8:3,16:4}),Z=Object.freeze({2:"0b",8:"0o",16:"0x"}),V=Object.freeze({2:4,8:3,16:2}),U=Object.freeze({2:/^[01]+$/,8:/^[0-7]+$/,16:/^[0-9a-f]+$/i}),D=Object.freeze({2:"binary",8:"octal",16:"hexadecimal"}),I=Object.freeze([[/^0x/i,16],[/^0b/i,2],[/^0o/i,8],[/^#/,16]]),k=/[\s\u00a0\u202f_,']/g,S=/^\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,y=Object.freeze([8,16,32,53]),d=new WeakSet,u=new WeakMap,n=new Map,t=new WeakMap,i=new WeakMap,s=Object.freeze({hex:Object.freeze({radix:16}),hex8:Object.freeze({radix:16,bitWidth:8,pad:!0,signed:!1}),hex16:Object.freeze({radix:16,bitWidth:16,pad:!0,signed:!1}),hex32:Object.freeze({radix:16,bitWidth:32,pad:!0,signed:!1}),binary:Object.freeze({radix:2}),binary8:Object.freeze({radix:2,bitWidth:8,pad:!0,signed:!1,group:4}),octal:Object.freeze({radix:8})});function r(P){if(P==null)return 16;const L=typeof P=="string"?P.toLowerCase():P,z=R[L];return z||($(`radix:base:${String(P)}`,`unsupported radix ${String(P)}; use 2, 8, 16, 'binary', 'octal' or 'hex'. Falling back to hex`),16)}function o(P,L){return Math.ceil(P/W[L])}function l(P,L){if(!P)return L?{min:-Number.MAX_SAFE_INTEGER,max:Number.MAX_SAFE_INTEGER}:{min:0,max:Number.MAX_SAFE_INTEGER};if(!L)return{min:0,max:2**P-1};const z=2**(P-1);return{min:-z,max:z-1}}function a(P){return D[P]||"hexadecimal"}function p(P){if(typeof P=="string"){const L=s[P];return L||$(`radix:preset:${P}`,`unknown radix preset "${P}"; known presets are ${Object.keys(s).join(", ")}`),{...L||{}}}if(P&&typeof P.preset=="string"){const L=s[P.preset];return L||$(`radix:preset:${P.preset}`,`unknown radix preset "${P.preset}"; known presets are ${Object.keys(s).join(", ")}`),{...L||{},...P}}return P||{}}function m(P){const L=p(P),z=r(L.radix),H=W[z];let x=null;if(L.bitWidth!==void 0&&L.bitWidth!==null&&L.bitWidth!==!1){const ee=Number(L.bitWidth);y.includes(ee)?x=ee:$(`radix:width:${String(L.bitWidth)}`,`unsupported bitWidth ${String(L.bitWidth)}; use 8, 16, 32 or 53. Ignoring it`)}let F=L.signed!==!1;!F&&x===null&&($("radix:unsigned:width","signed: false needs a bitWidth to render a two's-complement pattern; defaulting to 32"),x=32);const C=L.prefix===void 0||L.prefix===!0?Z[z]:L.prefix===!1?"":String(L.prefix);let B=0;L.pad===!0?B=x?o(x,z):0:typeof L.pad=="number"&&L.pad>0&&(B=Math.floor(L.pad));let q=0;L.group===!0?q=V[z]:typeof L.group=="number"&&L.group>0&&(q=Math.floor(L.group));const Q=l(x,F),Y=typeof L.min=="number"?Math.max(Q.min,L.min):Q.min,J=typeof L.max=="number"?Math.min(Q.max,L.max):Q.max,te=Object.freeze({radix:z,bits:H,prefix:C,uppercase:L.uppercase!==!1,pad:B,group:q,groupSeparator:typeof L.groupSeparator=="string"?L.groupSeparator:" ",bitWidth:x,signed:F,min:Y,max:J<Y?Y:J,nullDisplay:typeof L.nullDisplay=="string"?L.nullDisplay:"",name:a(z)});return d.add(te),te}function b(P){if(P&&d.has(P))return P;if(typeof P=="string"){let L=n.get(P);return L||(L=m(P),n.set(P,L)),L}if(P&&typeof P=="object"){let L=u.get(P);return L||(L=m(P),u.set(P,L)),L}return b("hex")}function g(P){return P<0?-Math.round(-P):Math.round(P)}function f(P,L,z){if(L<=0||P.length<=L)return P;const H=P.length%L||L,x=[P.slice(0,H)];for(let F=H;F<P.length;F+=L)x.push(P.slice(F,F+L));return x.join(z)}function w(P){const L=b(P),{radix:z,prefix:H,uppercase:x,pad:F,group:C,groupSeparator:B,signed:q,bitWidth:Q,nullDisplay:Y}=L,J=Q?2**Q:0,te=ee=>{if(M(ee)||ee==="")return Y;const re=typeof ee=="number"?ee:Number(ee);if(!Number.isFinite(re))return Y;const se=g(re);let de="",ie=se;se<0&&(q?(de="-",ie=-se):ie=(se%J+J)%J);let oe=ie.toString(z);return oe=x?oe.toUpperCase():oe.toLowerCase(),F>0&&oe.length<F&&(oe=oe.padStart(F,"0")),C>0&&(oe=f(oe,C,B)),de+H+oe};return te.options=L,te}function v(P,L){const z=b(L);let H=t.get(z);return H||(H=w(z),t.set(z,H)),H(P)}function h(P){const L=b(P),{radix:z,groupSeparator:H,signed:x,min:F,max:C}=L,B=U[z],q=Q=>{if(M(Q))return{ok:!0,value:null,reason:"blank"};let Y=String(Q);if(H&&H!==""&&(Y=Y.split(H).join("")),Y=Y.replace(k,""),Y==="")return{ok:!0,value:null,reason:"blank"};let J=!1;if((Y[0]==="-"||Y[0]==="+")&&(J=Y[0]==="-",Y=Y.slice(1)),Y==="")return{ok:!1,value:null,reason:"digits"};let te=null;for(const[re,se]of I){const de=re.exec(Y);if(!de)continue;const ie=Y.slice(de[0].length);if(ie==="")break;if(!U[se].test(ie))return{ok:!1,value:null,reason:"digits"};te=parseInt(ie,se);break}if(te===null)if(B.test(Y))te=parseInt(Y,z);else if(S.test(Y))te=Number(Y);else return{ok:!1,value:null,reason:"digits"};if(!Number.isFinite(te))return{ok:!1,value:null,reason:"digits"};const ee=g(J?-te:te);return!x&&ee<0?{ok:!1,value:ee,reason:"negative"}:ee<F||ee>C?{ok:!1,value:ee,reason:"range"}:{ok:!0,value:ee,reason:"ok"}};return q.options=L,q}function c(P,L){const z=b(L);let H=i.get(z);return H||(H=h(z),i.set(z,H)),H(P)}function j(P,L){const z=c(P,L);return z.ok?z.value:null}function E(P,L){const z=M(P)||Number.isNaN(P)?null:Number(P),H=M(L)||Number.isNaN(L)?null:Number(L);return z===null?H===null?0:1:H===null||z<H?-1:z>H?1:0}function O(P){const L=P.min>=-2147483648&&P.max<=2147483647;return P.bitWidth&&L?"int32":"float64"}function T(P){const L=m(P),z=w(L),H=h(L);return{base:"number",extends:"number",storage:O(L),matches:null,format:x=>z(x.value),parse:x=>{const F=H(x.text);return F.ok?F.value:null},compare:E,defaults:{filter:"number",editor:"radix",total:"sum",align:"end"},excel:"General",toClipboard:x=>z(x),fromClipboard:x=>{const F=H(x);return F.ok?F.value:null},radix:L,formatValue:z,parseText:H}}const A=T}),Ce("packages/core/src/columns/types/aggregable.js",function(e,G){"use strict";Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"AGGREGABLE_TYPES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"weightedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"logarithmicSum",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"logarithmicMean",{enumerable:!0,get:function(){return W}});const M=G("packages/core/src/internal/util.js").isNil;function $(I){const k=[];for(const S of I||[]){if(M(S))continue;const y=Number(S);Number.isFinite(y)&&k.push(y)}return k}function R(I){return k=>{const S=$(k);if(!S.length)return null;let y=0;for(const d of S)y+=10**(d/I);return I*Math.log10(y)}}function W(I){return k=>{const S=$(k);if(!S.length)return null;let y=0;for(const d of S)y+=10**(d/I);return I*Math.log10(y/S.length)}}function Z(I,k){const S=k&&k.column,d=(S&&S.typeOptions||{}).weight,u=k&&k.valueAt;if(!d||typeof u!="function")return null;let n=0,t=0;for(let i=0;i<I.length;i++){if(M(I[i]))continue;const s=Number(I[i]);if(!Number.isFinite(s))continue;const r=u(d,i);if(M(r))continue;const o=Number(r);!Number.isFinite(o)||o<=0||(n+=s*o,t+=o)}return t===0?null:n/t}function V(I={}){const k=I.factor===20?20:10,S=typeof I.suffix=="string"?I.suffix:"",y=Number.isInteger(I.decimals)?I.decimals:1;return{base:"number",storage:"float64",name:I.name||"logarithmic",format:d=>{const u=d&&d.value;return M(u)||!Number.isFinite(Number(u))?"":`${Number(u).toFixed(y)}${S}`},parse:d=>{const u=String((d&&d.text)??"").replace(S,"").trim();if(!u)return null;const n=Number(u);return Number.isFinite(n)?n:null},defaults:{align:"end",filter:"number"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:{sum:R(k),avg:W(k)}}}}function U(I={}){const k=Number.isInteger(I.decimals)?I.decimals:1,S=I.percent===!0;return{base:"number",storage:"float64",name:I.name||"ratio",format:y=>{const d=y&&y.value;return M(d)||!Number.isFinite(Number(d))?"":S?`${Number(d).toFixed(k)}%`:Number(d).toFixed(k)},parse:y=>{const d=String((y&&y.text)??"").replace("%","").trim();if(!d)return null;const u=Number(d);return Number.isFinite(u)?u:null},defaults:{align:"end",filter:"number"},totals:{supported:["avg","min","max","count","countValues"],implement:{avg:Z}}}}const D=Object.freeze({decibel:V({name:"decibel",factor:10,suffix:" dB"}),decibelAmplitude:V({name:"decibelAmplitude",factor:20,suffix:" dB"}),ratio:U({name:"ratio"}),percentRate:U({name:"percentRate",percent:!0})})}),Ce("packages/core/src/columns/types/currency.js",function(e,G){"use strict";Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normaliseCode",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"toMoney",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"moneyToText",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"moneyComparator",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"CURRENCY_TYPES",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const M=G("packages/core/src/internal/util.js").isNil,$="⚠ no rate";function R(l){if(M(l))return null;const a=String(l).trim().toUpperCase();return a===""?null:a}function W(l){if(M(l))return null;if(typeof l=="object"&&!Array.isArray(l)){const a=Number(l.amount),p=R(l.code);return!p||!Number.isFinite(a)?null:{amount:a,code:p}}if(Array.isArray(l)&&l.length===2){const a=Number(l[0]),p=R(l[1]);return!p||!Number.isFinite(a)?null:{amount:a,code:p}}return null}const Z=Object.freeze({$:"USD","€":"EUR","£":"GBP","¥":"JPY","₹":"INR","₩":"KRW","₽":"RUB","₺":"TRY","₴":"UAH","₪":"ILS"}),V=Object.freeze({USD:"$",EUR:"€",GBP:"£",JPY:"¥",INR:"₹",KRW:"₩",RUB:"₽",TRY:"₺",UAH:"₴",ILS:"₪"}),U=/[+-]?[\d\s., ]*\d/;function D(l,a){const p=String(l).trim();if(p==="")return null;const m=new Intl.NumberFormat(a||void 0).formatToParts(1.1).find(w=>w.type==="decimal")?.value||".",b=m===","?".":",",g=p.split(b).join("").split(/[\s ]/).join("").replace(m,"."),f=Number(g);return Number.isFinite(f)?f:null}function I(l,a){const p=a||{},m=R(p.code);if(M(l))return null;const b=W(l);if(b)return b;if(typeof l=="number")return Number.isFinite(l)&&m?{amount:l,code:m}:null;let g=String(l).trim();if(g==="")return null;let f=!1;g.startsWith("(")&&g.endsWith(")")&&(f=!0,g=g.slice(1,-1).trim());let w=null;for(const[O,T]of Object.entries(Z)){if(g.startsWith(O)){w=T,g=g.slice(O.length).trim();break}if(g.endsWith(O)){w=T,g=g.slice(0,-O.length).trim();break}}const v=U.exec(g);if(!v)return null;const h=D(v[0],p.locale);if(h===null)return null;const c=(g.slice(0,v.index)+" "+g.slice(v.index+v[0].length)).trim();!w&&c!==""&&(w=R(c));const j=w||m;return j?{amount:f?-h:h,code:j}:null}function k(l,a){if(typeof l=="function")return(p,m)=>{if(p===m)return 1;const b=l(p,m);return typeof b=="number"&&Number.isFinite(b)&&b>0?b:null};if(l&&typeof l=="object"){const p=l;return(m,b)=>{if(m===b)return 1;const g=Number(p[m]),f=Number(p[b]);return!Number.isFinite(g)||!Number.isFinite(f)||g<=0||f<=0?null:f/g}}return(p,m)=>p===m?1:null}function S(l,a,p){if(!l)return null;if(l.code===a)return l.amount;const m=p(l.code,a);return m===null?null:l.amount*m}const y=new Map;function d(l,a,p){const m=`${l||""}|${a}|${p??""}`;let b=y.get(m);if(!b){const g={style:"currency",currency:a};typeof p=="number"&&(g.minimumFractionDigits=p,g.maximumFractionDigits=p);try{b={fmt:new Intl.NumberFormat(l||void 0,g),currency:!0}}catch{b={fmt:new Intl.NumberFormat(l||void 0,typeof p=="number"?{minimumFractionDigits:p,maximumFractionDigits:p}:{}),currency:!1}}y.set(m,b)}return b}function u(l,a){const p=a||{},m=p.nullDisplay??"",b=W(l);if(!b)return m;const g=R(p.display)||b.code;let f=b.amount,w=b.code;if(g!==b.code){const c=p.rateFn||k(p.rates,p.rateBase),j=S(b,g,c);if(j===null)return`${p.missingRate??$} ${b.code}→${g}`;f=j,w=g}const{fmt:v,currency:h}=d(p.locale,w,p.decimals);return h?v.format(f):`${v.format(f)} ${w}`}function n(l){const a=W(l);return a?`${a.amount} ${a.code}`:""}function t(l){const a=l||{},p=R(a.display),m=a.rateFn||k(a.rates,a.rateBase);return(b,g)=>{const f=W(b),w=W(g);if(!f&&!w)return 0;if(!f)return 1;if(!w)return-1;if(p){const v=S(f,p,m),h=S(w,p,m);if(v!==null&&h!==null)return v===h?0:v<h?-1:1}return f.code===w.code?f.amount===w.amount?0:f.amount<w.amount?-1:1:f.code<w.code?-1:1}}function i(l){const a=l||{},p=(b,g)=>{const f=[];for(const j of b||[]){const E=W(j);E&&f.push(E)}if(!f.length)return null;if(new Set(f.map(j=>j.code)).size===1){const j=f[0].code;return{amount:g(f.map(E=>E.amount)),code:j}}const v=R(a.display);if(!v)return`${a.missingRate??$}: mixed currencies, no display currency set`;const h=a.rateFn||k(a.rates,a.rateBase),c=[];for(const j of f){const E=S(j,v,h);if(E===null)return`${a.missingRate??$}: ${j.code}→${v}`;c.push(E)}return{amount:g(c),code:v}},m=b=>b.reduce((g,f)=>g+f,0);return{sum:b=>p(b,m),avg:b=>p(b,g=>m(g)/g.length),min:b=>p(b,g=>Math.min(...g)),max:b=>p(b,g=>Math.max(...g))}}function s(l){const a=Object.freeze({code:"USD",...l||{}}),p=k(a.rates,a.rateBase),m=Object.freeze({...a,rateFn:p}),b=i(m),g=t(m),f=new Map([[a.locale||"",m]]),w=c=>{const j=c||"";let E=f.get(j);return E||(E=Object.freeze({...m,locale:c||void 0}),f.set(j,E)),E},v=V[R(a.display||a.code)]||"",h=typeof a.decimals=="number"&&a.decimals>0?`.${"0".repeat(a.decimals)}`:".00";return{base:"object",extends:"object",storage:"object",name:"currency",currencyConfig:m,format:c=>u(c.value,c.locale?w(c.locale):m),parse:c=>I(c.text,c.locale?w(c.locale):m),compare:g,defaults:{filter:"number",editor:"currency",align:"end",total:"sum"},totals:{supported:["sum","avg","min","max","count","countValues"],implement:b},excel:a.excel||(v?`"${v}"#,##0${h}`:`#,##0${h}`),toStorage:c=>{const j=W(c);return j||(typeof c=="string"||typeof c=="number"?I(c,m):null)},toClipboard:c=>n(c),fromClipboard:c=>I(c,m)}}const r=Object.freeze({currency:s({code:"USD"}),usd:s({code:"USD"}),eur:s({code:"EUR"}),gbp:s({code:"GBP"}),jpy:s({code:"JPY",decimals:0})}),o=s}),Ce("packages/core/src/columns/types/index.js",function(e,G){"use strict";Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return J}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"unitSystemNames",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"unitsOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"SI_TYPES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createSiType",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"createSiSystem",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"siUnits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"SI_PREFIXES",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return O}});const _=G("packages/core/src/columns/types/temporal.js"),M=_.TEMPORAL_TYPES,$=G("packages/core/src/columns/types/network.js"),R=$.NETWORK_TYPES,W=G("packages/core/src/columns/types/structured.js"),Z=W.STRUCTURED_TYPES,V=G("packages/core/src/columns/types/unit.js"),U=V.createUnitType,D=V.UNIT_SYSTEMS,I=V.parseUnit,k=V.formatUnit,S=V.registerUnitSystem,y=V.unitSystemNames,d=V.unitsOf,u=V.defineUnit,n=G("packages/core/src/columns/types/engineering.js"),t=n.ENGINEERING_TYPES,i=G("packages/core/src/columns/types/si.js"),s=i.SI_TYPES,r=i.createSiType,o=i.createSiSystem,l=i.siUnits,a=i.SI_PREFIXES,p=G("packages/core/src/columns/types/temperature.js"),m=p.TEMPERATURE_TYPES,b=p.createTemperatureType,g=p.convertTemperature,f=p.formatTemperature,w=p.parseTemperature,v=p.TEMPERATURE_SCALES,h=G("packages/core/src/columns/types/radix.js"),c=h.createRadixType,j=h.RADIX_PRESETS,E=h.parseRadix,O=h.formatRadix,T=G("packages/core/src/columns/types/aggregable.js"),A=T.AGGREGABLE_TYPES,P=G("packages/core/src/columns/types/currency.js"),L=P.CURRENCY_TYPES,z=P.createCurrencyType,H=P.parseMoney,x=P.formatMoney,F=P.convertMoney,C=P.toMoney,B=P.rateFunction,q=P.moneyComparator,Q=P.normaliseCode,Y=P.MISSING_RATE;Object.defineProperty(e,"findUnit",{enumerable:!0,get:function(){return V.findUnit}}),Object.defineProperty(e,"ENGINEERING_TYPES",{enumerable:!0,get:function(){return n.ENGINEERING_TYPES}}),Object.defineProperty(e,"circularMean",{enumerable:!0,get:function(){return n.circularMean}}),Object.defineProperty(e,"TEMPERATURE_TYPES",{enumerable:!0,get:function(){return p.TEMPERATURE_TYPES}}),Object.defineProperty(e,"createTemperatureType",{enumerable:!0,get:function(){return p.createTemperatureType}}),Object.defineProperty(e,"convertTemperature",{enumerable:!0,get:function(){return p.convertTemperature}}),Object.defineProperty(e,"formatTemperature",{enumerable:!0,get:function(){return p.formatTemperature}}),Object.defineProperty(e,"parseTemperature",{enumerable:!0,get:function(){return p.parseTemperature}}),Object.defineProperty(e,"TEMPERATURE_SCALES",{enumerable:!0,get:function(){return p.TEMPERATURE_SCALES}}),Object.defineProperty(e,"findScale",{enumerable:!0,get:function(){return p.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 T.AGGREGABLE_TYPES}}),Object.defineProperty(e,"createLogarithmicType",{enumerable:!0,get:function(){return T.createLogarithmicType}}),Object.defineProperty(e,"createRatioType",{enumerable:!0,get:function(){return T.createRatioType}}),Object.defineProperty(e,"parseTime",{enumerable:!0,get:function(){return _.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({...M,...R,...Z,...A,hex:c(j.hex),hex8:c(j.hex8),hex16:c(j.hex16),hex32:c(j.hex32),binary:c(j.binary),binary8:c(j.binary8),octal:c(j.octal),bytes:U({system:"data",unit:"B",display:"auto"}),megabytes:U({system:"data",unit:"MB"}),gigabytes:U({system:"data",unit:"GB"}),bitrate:U({system:"bitrate",unit:"Mbps"}),gigabits:U({system:"bitrate",unit:"Gbps"}),...t,...s,...m,...L});{const te=new Set;for(const ee of[M,R,Z,A,t,s,m,L])for(const re of Object.keys(ee)){if(te.has(re))throw new Error(`[lattice] data type "${re}" is declared twice`);te.add(re)}}}),Ce("packages/core/src/compute/handle.js",function(e,G){"use strict";Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return i}});const _=G("packages/core/src/internal/util.js"),M=_.collator,$=_.defaultCompare,R=_.warnOnce;function W(s){const r=new Uint32Array(s);for(let o=0;o<s;o++)r[o]=o;return r}function Z(s,r){if(r&&typeof r.count=="number")return r.count;if(!s)return 0;if(typeof s.count=="number")return s.count;if(typeof s.length=="number")return s.length;const o=s.values;return s.kind==="multi"&&s.offsets?Math.max(0,s.offsets.length-1):o?s.kind==="bitset"?typeof o.size=="number"?o.size:s.presence&&typeof s.presence.size=="number"?s.presence.size:(R(`count:${s.id}`,`column "${s.id}" is bitset-backed with no declared row count; assuming ${o.length*8}`),o.length*8):o.length:s.presence&&typeof s.presence.size=="number"?s.presence.size:0}const V=new WeakMap;function U(s){const r=s.constructor;if(!r)return"unknown";const o=V.get(r);if(o)return o;let l="unknown";try{let a=null;typeof r.from=="function"?a=r.from([!1,!0]):(a=new r(8),a.set(1));const p=a&&a.words;p&&p.length&&(p[0]===2?l="lsb":p[0]===64&&(l="msb"))}catch{l="unknown"}return V.set(r,l),l}function D(s){if(!s)return()=>0;const r=s instanceof Uint8Array?s:s.words;if(r instanceof Uint8Array){const o=s instanceof Uint8Array?"lsb":U(s);if(o==="lsb")return l=>r[l>>>3]>>>(l&7)&1;if(o==="msb")return l=>r[l>>>3]>>>7-(l&7)&1}return typeof s.get=="function"?o=>s.get(o)?1:0:()=>0}function I(s){return!s||!s.presence?null:D(s.presence)}function k(s){return s?typeof s.size=="number"?s.size:typeof s.values=="function"?s.values().length:0:0}function S(s,r){return s?typeof s.valueOf=="function"?s.valueOf(r):typeof s.values=="function"?s.values()[r]:null:null}function y(s,r){const o=s.offsets,l=s.values;if(!o||!l)return[];const a=o[r],p=o[r+1];if(!(p>a))return[];const m=s.dict,b=new Array(p-a);for(let g=a;g<p;g++)b[g-a]=m?S(m,l[g]):l[g];return b}function d(s){if(!s)return()=>{};const r=s.values,o=I(s),l=s.kind;if(l==="dictionary"){const a=s.dict;return o?p=>o(p)?S(a,r[p]):null:p=>S(a,r[p])}if(l==="bitset"){const a=D(r);return o?p=>o(p)?a(p)===1:null:p=>a(p)===1}if(l==="multi")return o?a=>o(a)?y(s,a):null:a=>y(s,a);if(!r&&typeof s.get=="function"){const a=s.get.bind(s);return p=>{const m=a(p);return m===void 0?null:m}}return o?a=>{if(!o(a))return null;const p=r[a];return p===void 0?null:p}:a=>{const p=r[a];return p===void 0?null:p}}function u(s,r){if(s<r)return-1;if(s>r)return 1;if(s===r){const a=Object.is(s,-0),p=Object.is(r,-0);return a===p?0:a?-1:1}const o=Number.isNaN(s),l=Number.isNaN(r);return o&&l?0:o?1:-1}function n(s){const r=M(s);return(o,l)=>{if(o===l)return 0;const a=typeof o,p=typeof l;if(a==="string"&&p==="string")return r.compare(o,l);if(a==="number"&&p==="number")return u(o,l);if(a==="boolean"&&p==="boolean")return o===l?0:o?1:-1;if(o instanceof Date||l instanceof Date){const m=o instanceof Date?o.getTime():Number(o),b=l instanceof Date?l.getTime():Number(l);return u(m,b)}return $(o,l)}}function t(s,r){if(s&&typeof s.ranks=="function")return s.ranks(r);const o=s&&typeof s.values=="function"?s.values():[],l=o.length,a=n(r),p=new Array(l);for(let b=0;b<l;b++)p[b]=b;p.sort((b,g)=>a(o[b],o[g])||b-g);const m=new Uint32Array(l);for(let b=0;b<l;b++)m[p[b]]=b;return m}function i(s){return s==null||typeof s=="number"&&Number.isNaN(s)}}),Ce("packages/core/src/compute/filter.js",function(e,G){"use strict";Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"itemwisePredicate",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"declareOperators",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"declaredOperator",{enumerable:!0,get:function(){return Q}});const _=G("packages/core/src/internal/util.js"),M=_.isBlank,$=_.toArray,R=_.warnOnce,Z=G("packages/core/src/format/date.js").toIsoDate,V=G("packages/core/src/compute/handle.js"),U=V.bitReader,D=V.dictSize,I=V.dictValue,k=V.presenceReader,S=V.valueComparator,y=V.valueReader,d=/^\d{4}-\d{2}-\d{2}$/,u="\0null\0";function n(Y,J){const te=Y&&Y.pool;if(te){const ee=te.mask||te.acquireMask||te.acquire||te.take;if(typeof ee=="function"){const re=ee.call(te,J);if(re&&re.length>=J)return re}}return new Uint8Array(J)}function t(Y,J){const te=Y&&Y.pool;if(!te||!J)return;const ee=te.release||te.releaseMask||te.free||te.recycle;typeof ee=="function"&&ee.call(te,J)}function i(Y,J,te){return Y.fill(te,0,J),Y}function s(Y){return Y==null||typeof Y=="number"&&Number.isNaN(Y)}function r(Y,J){if(Y==null)return Y;if(J==="number")return typeof Y=="number"?Y:Number(Y);if(J==="date"||J==="dateString"){const te=Z(Y);return te===null?o(Y):te}return J==="boolean"?typeof Y=="boolean"?Y:Y==="true"||Y===1?!0:Y==="false"||Y===0?!1:!!Y:Y}function o(Y){return Y instanceof Date?Y.getTime():typeof Y=="number"?Y:Date.parse(String(Y))}function l(Y){return typeof Y=="number"?Y:Y instanceof Date?Y.getTime():Y==null||Y===""?NaN:Number(Y)}function a(Y,J){const te=typeof Y=="string"?Y:String(Y);return J?te:te.toLowerCase()}function p(Y,J){return Y==null?u:typeof Y=="string"?J?Y:Y.toLowerCase():Y instanceof Date?Y.getTime():Y}function m(Y,J,te){const ee=new Set;for(const re of $(Y)){const se=r(re,te);ee.add(p(se,J)),typeof se=="string"&&se!==""&&Number.isFinite(Number(se))?ee.add(Number(se)):typeof se=="number"&&Number.isFinite(se)&&ee.add(p(String(se),J))}return ee}function b(Y,J,te){if(Y==null||J===null||J===void 0)return Y==null&&J==null;const ee=typeof Y,re=typeof J;return ee==="string"&&re==="string"?te?Y===J:Y.toLowerCase()===J.toLowerCase():Y instanceof Date||J instanceof Date?o(Y)===o(J):ee==="number"&&re==="number"?Y===J||Number.isNaN(Y)&&Number.isNaN(J):ee==="number"&&re==="string"?Y===Number(J):ee==="string"&&re==="number"?Number(Y)===J:ee==="boolean"||re==="boolean"?Y===J:Array.isArray(Y)&&Array.isArray(J)?Y.length===J.length&&Y.every((se,de)=>b(se,J[de],te)):Y===J}function g(Y,J){try{if(Y instanceof RegExp){const te=Y.flags.replace(/[gy]/g,"");return new RegExp(Y.source,J||te.includes("i")?te:`${te}i`)}return new RegExp(String(Y),J?"":"i")}catch(te){return R(`regex:${String(Y)}`,`filter operator "matches" received an invalid pattern: ${String(Y)}`,te),null}}function f(Y,J){const te=w(Y,J),ee=Y&&Y.type;return ee!=="date"&&ee!=="dateString"?te:re=>te(typeof re=="string"&&d.test(re)?re:Z(re)??re)}function w(Y,J){const te=Y&&Y.op,ee=!!(Y&&Y.caseSensitive),re=Y&&Y.type,se=S(J),de=ie=>oe=>!ie(oe);switch(te){case"eq":{const ie=r(Y.value,re);return oe=>b(oe,ie,ee)}case"ne":{const ie=r(Y.value,re);return oe=>!b(oe,ie,ee)}case"lt":case"lte":case"gt":case"gte":{const ie=r(Y.value,re);if(s(ie))return()=>!1;const oe=te==="lt"?-1:te==="lte"?0:te==="gt"?1:2;return ue=>{if(s(ue))return!1;const ce=se(ue,ie);return oe===-1?ce<0:oe===0?ce<=0:oe===1?ce>0:ce>=0}}case"between":case"notBetween":{const ie=$(Y.value),oe=r(ie[0],re),ue=r(ie[1],re),ce=Y.bounds||"[]",pe=ce.charAt(0)!=="(",Me=ce.charAt(1)!==")";if(s(oe)||s(ue))return te==="between"?()=>!1:()=>!0;const $e=je=>{if(s(je))return!1;const ke=se(je,oe),ge=se(je,ue);return(pe?ke>=0:ke>0)&&(Me?ge<=0:ge<0)};return te==="between"?$e:de($e)}case"in":case"notIn":{const ie=m(Y.value,ee,re),oe=ue=>ie.has(p(ue,ee));return te==="in"?oe:de(oe)}case"contains":case"notContains":{const ie=a(r(Y.value,re),ee),oe=ue=>ue==null?!1:a(ue,ee).includes(ie);return te==="contains"?oe:de(oe)}case"startsWith":{const ie=a(r(Y.value,re),ee);return oe=>oe==null?!1:a(oe,ee).startsWith(ie)}case"endsWith":{const ie=a(r(Y.value,re),ee);return oe=>oe==null?!1:a(oe,ee).endsWith(ie)}case"matches":{const ie=g(Y.value,ee);return ie?oe=>oe==null?!1:ie.test(String(oe)):()=>!1}case"blank":return ie=>M(ie)||Array.isArray(ie)&&ie.length===0;case"notBlank":return ie=>!(M(ie)||Array.isArray(ie)&&ie.length===0);case"containsAny":case"containsNone":{const ie=m(Y.value,ee,re),oe=ue=>{const ce=ue==null?[]:$(ue);for(let pe=0;pe<ce.length;pe++)if(ie.has(p(ce[pe],ee)))return!0;return!1};return te==="containsAny"?oe:de(oe)}case"containsAll":{const ie=$(Y.value).map(oe=>p(r(oe,re),ee));return oe=>{const ue=oe==null?[]:$(oe);if(ie.length===0)return!0;const ce=new Set(ue.map(pe=>p(pe,ee)));for(let pe=0;pe<ie.length;pe++)if(!ce.has(ie[pe]))return!1;return!0}}default:{const ie=Q(te);return ie?ie.compile(Y.value):(R(`op:${String(te)}`,`unknown filter operator "${String(te)}"; the condition is refused rather than matching every row`),()=>!1)}}}function v(Y,J,te){return f(J,te)(Y)}const h=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),c=new Set(["containsAny","containsAll","containsNone"]);function j(Y,J,te){const ee=Y&&Y.op,re=h[ee]||ee,se=f({...Y,op:re,type:J.type},te),de=J.items,ie=oe=>{const ue=de(oe);if(!ue)return!1;for(let ce=0;ce<ue.length;ce++)if(se(ue[ce]))return!0;return!1};return h[ee]?oe=>!ie(oe):ie}function E(Y,J,te,ee){const re=k(Y);if(re){const ie=J?1:0;for(let oe=0;oe<ee;oe++)te[oe]=re(oe)===ie?1:0;return te}const se=Y.kind;if(se==="float64"||se==="int32"||se==="bitset")return i(te,ee,J?1:0);const de=y(Y);for(let ie=0;ie<ee;ie++){const oe=de(ie),ue=M(oe)||Array.isArray(oe)&&oe.length===0;te[ie]=ue===J?0:1}return te}function O(Y,J,te,ee){const re=Y.dict,se=D(re),de=new Uint8Array(se);for(let ce=0;ce<se;ce++)de[ce]=J(I(re,ce))?1:0;const ie=Y.values,oe=k(Y);if(!oe){for(let ce=0;ce<ee;ce++)te[ce]=de[ie[ce]];return te}const ue=J(null)?1:0;for(let ce=0;ce<ee;ce++)te[ce]=oe(ce)===1?de[ie[ce]]:ue;return te}function T(Y,J,te,ee){const re=U(Y.values),se=J(!0)?1:0,de=J(!1)?1:0,ie=k(Y);if(!ie){for(let ue=0;ue<ee;ue++)te[ue]=re(ue)===1?se:de;return te}const oe=J(null)?1:0;for(let ue=0;ue<ee;ue++)te[ue]=ie(ue)===0?oe:re(ue)===1?se:de;return te}function A(Y,J,te,ee,re){const se=Y.values,de=J.type,ie=J.op;let oe=!0;switch(ie){case"eq":case"ne":{const ce=l(r(J.value,de)),pe=typeof J.value=="number"&&Number.isNaN(J.value),Me=ie==="ne"?1:0;if(pe)for(let $e=0;$e<re;$e++)ee[$e]=(Number.isNaN(se[$e])?1:0)^Me;else for(let $e=0;$e<re;$e++)ee[$e]=(se[$e]===ce?1:0)^Me;break}case"lt":{const ce=l(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]<ce?1:0;break}case"lte":{const ce=l(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]<=ce?1:0;break}case"gt":{const ce=l(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]>ce?1:0;break}case"gte":{const ce=l(r(J.value,de));for(let pe=0;pe<re;pe++)ee[pe]=se[pe]>=ce?1:0;break}case"between":case"notBetween":{const ce=$(J.value),pe=l(r(ce[0],de)),Me=l(r(ce[1],de)),$e=J.bounds||"[]",je=$e.charAt(0)!=="(",ke=$e.charAt(1)!==")",ge=ie==="notBetween"?1:0;if(je&&ke)for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>=pe&se[Ee]<=Me?1:0)^ge;else if(je)for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>=pe&se[Ee]<Me?1:0)^ge;else if(ke)for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>pe&se[Ee]<=Me?1:0)^ge;else for(let Ee=0;Ee<re;Ee++)ee[Ee]=(se[Ee]>pe&se[Ee]<Me?1:0)^ge;break}case"in":case"notIn":{const ce=new Set;for(const Me of $(J.value)){const $e=l(r(Me,de));Number.isNaN($e)||ce.add($e)}const pe=ie==="notIn"?1:0;for(let Me=0;Me<re;Me++)ee[Me]=(ce.has(se[Me])?1:0)^pe;break}default:oe=!1;break}if(!oe)return!1;const ue=k(Y);if(ue){const ce=te(null)?1:0;for(let pe=0;pe<re;pe++)ue(pe)===0&&(ee[pe]=ce)}return!0}function P(Y,J,te,ee){const re=y(Y);for(let se=0;se<ee;se++)te[se]=J(re(se))?1:0;return te}function L(Y,J,te){const ee=J.count|0,re=te||n(J,ee);if(!Y)return i(re,ee,1);const se=typeof J.handle=="function"?J.handle(Y.col):void 0,de=typeof J.custom=="function"?J.custom:null;if(!se){if(de){for(let ce=0;ce<ee;ce++)re[ce]=de(Y,ce)?1:0;return re}return R(`filter:col:${String(Y.col)}`,`filter references unknown column "${String(Y.col)}"; the condition is refused rather than matching every row`),i(re,ee,0)}const ie=Y.op;if(ie==="blank"||ie==="notBlank")return E(se,ie==="notBlank",re,ee);const oe=typeof J.itemwise=="function"?J.itemwise(Y.col):null;if(oe&&!Q(ie)&&!c.has(ie))return P(se,j(Y,oe,J.locale),re,ee);const ue=f(Y,J.locale);switch(se.kind){case"dictionary":return O(se,ue,re,ee);case"bitset":return T(se,ue,re,ee);case"float64":case"int32":return A(se,Y,ue,re,ee)?re:P(se,ue,re,ee);default:return P(se,ue,re,ee)}}function z(Y,J,te){if(!Y)return i(n(J,te),te,1);if(Array.isArray(Y.conditions)){const ee=Y.conditions.filter(de=>de!=null),re=Y.op==="or"?"or":Y.op==="not"?"not":"and";if(ee.length===0)return i(n(J,te),te,1);const se=z(ee[0],J,te);for(let de=1;de<ee.length;de++){const ie=z(ee[de],J,te);if(re==="or")for(let oe=0;oe<te;oe++)se[oe]|=ie[oe];else for(let oe=0;oe<te;oe++)se[oe]&=ie[oe];t(J,ie)}if(re==="not")for(let de=0;de<te;de++)se[de]^=1;return se}return L(Y,J,n(J,te))}function H(Y,J){return z(Y,J,J.count|0)}function x(Y,J){if(!Y||!J)return Y||null;const te=Y;if(Array.isArray(te.conditions)){if((te.op==="or"?"or":te.op==="not"?"not":"and")!=="and")return F(te,J)?null:Y;const re=[];for(const se of te.conditions){const de=x(se,J);de&&re.push(de)}return re.length?{...te,op:"and",conditions:re}:null}return te.col===J?null:Y}function F(Y,J){if(!Y||typeof Y!="object")return!1;const te=Y;if(te.col===J)return!0;if(Array.isArray(te.conditions)){for(const ee of te.conditions)if(F(ee,J))return!0}return!1}function C(Y,J,te){if(te&&te.length>=J){let de=0;for(let ie=0;ie<J;ie++)Y[ie]&&(te[de++]=ie);return te.subarray(0,de)}let ee=0;for(let de=0;de<J;de++)ee+=Y[de]?1:0;const re=new Uint32Array(ee);let se=0;for(let de=0;de<J;de++)Y[de]&&(re[se++]=de);return re}const B=new Map;function q(Y){if(!(!Y||typeof Y!="object"))for(const[J,te]of Object.entries(Y))te&&typeof te.compile=="function"&&B.set(J,te)}function Q(Y){return typeof Y=="string"?B.get(Y):void 0}}),Ce("packages/core/src/columns/datatypes.js",function(e,G){"use strict";Object.defineProperty(e,"localeSeparators",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"parseNumberText",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"BUILTIN_TYPES",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"INFERENCE_ORDER",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"createTypeRegistry",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"comparatorFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"storageKind",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"typeLabel",{enumerable:!0,get:function(){return L}});const _=G("packages/core/src/internal/util.js"),M=_.collator,$=_.defaultCompare,R=_.isNil,W=_.isObject,Z=_.isFunction,V=_.fail,U=_.titleCase,D=G("packages/core/src/format/date.js"),I=D.toDate,k=D.toIsoDate,S=D.compareIso,d=G("packages/core/src/format/boolean.js").toTriState,n=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,t=G("packages/core/src/formula/index.js"),i=t.evaluateFormula,s=t.looksLikeFormula,o=G("packages/core/src/compute/filter.js").declareOperators,l=/^\d{4}-\d{2}-\d{2}$/;function a(z){return z.getHours()===0&&z.getMinutes()===0&&z.getSeconds()===0&&z.getMilliseconds()===0}const p=new Map;function m(z){const H=z||"",x=p.get(H);if(x)return x;const F={group:",",decimal:"."};try{for(const C of new Intl.NumberFormat(z||void 0).formatToParts(12345.6))C.type==="group"?F.group=C.value:C.type==="decimal"&&(F.decimal=C.value)}catch{}return p.set(H,F),F}const b=/\d\s*[*/^]\s*[\d.(]/;function g(z,H){if(R(z))return null;let x=String(z).trim();if(x===""||x.startsWith("=")||b.test(x))return null;let F=1;x.startsWith("(")&&x.endsWith(")")&&(F=-1,x=x.slice(1,-1));const C=x.endsWith("%"),{group:B,decimal:q}=m(H);if(x=x.replace(/[\s\u00a0\u202f\u2009']/g,""),B&&B!=="."&&B!==","&&(x=x.split(B).join("")),x=x.replace(/[^0-9eE+\-.,]/g,""),q===","?x=x.split(".").join("").replace(",","."):x=x.split(",").join(""),x===""||x==="-"||x==="+")return null;const Q=Number(x);return Number.isNaN(Q)?null:F*(C?Q/100:Q)}function f(z,H){const x=R(z)||Number.isNaN(z)?null:Number(z),F=R(H)||Number.isNaN(H)?null:Number(H);return x===null?F===null?0:1:F===null||x<F?-1:x>F?1:0}function w(z,H){const x=d(z),F=d(H);return x===null?F===null?0:1:F===null?-1:x===F?0:x?1:-1}function v(z,H){const x=I(z),F=I(H);if(!x)return F?1:0;if(!F)return-1;const C=x.getTime(),B=F.getTime();return C<B?-1:C>B?1:0}const h=new Map;function c(z){const H=I(z.value);if(!H)return"";const x=z.locale||"";let F=h.get(x);return F||(F=new Intl.DateTimeFormat(z.locale||void 0,{dateStyle:"medium"}),h.set(x,F)),F.format(H)}const j={boolean:{base:"boolean",storage:"bitset",matches:z=>typeof z=="boolean",parse:z=>d(z.text),compare:w,format:z=>d(z.value)===null?"":d(z.value)?"Yes":"No",defaults:{filter:"set",editor:"checkbox",align:"center"},excel:"General",toClipboard:z=>d(z)===null?"":String(d(z)),fromClipboard:z=>d(z)},number:{base:"number",storage:"float64",matches:z=>typeof z=="number"&&!Number.isNaN(z),parse:z=>{if(s(z.text)){const H=i(z.text,z);if(!H.ok)return null;const x=Number(H.value);return Number.isFinite(x)?x:null}return g(z.text,z.locale)},compare:f,defaults:{filter:"number",editor:"number",align:"end"},excel:"General",toClipboard:z=>R(z)?"":String(z),fromClipboard:(z,H)=>g(z,H&&H.locale)},date:{base:"dateString",storage:"dictionary",matches:z=>typeof z=="string"&&l.test(z)&&!Number.isNaN(Date.parse(z))||z instanceof Date&&!Number.isNaN(z.getTime())&&a(z),parse:z=>k(z.text),compare:S,format:c,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:z=>k(z),toClipboard:z=>R(z)?"":String(z),fromClipboard:z=>k(z)},dateString:{base:"dateString",storage:"dictionary",matches:z=>typeof z=="string"&&l.test(z)&&!Number.isNaN(Date.parse(z)),parse:z=>k(z.text),compare:S,format:c,defaults:{filter:"date",editor:"date",align:"start"},excel:"yyyy-mm-dd",toStorage:z=>k(z),toClipboard:z=>R(z)?"":String(z),fromClipboard:z=>k(z)},text:{base:"text",storage:"dictionary",matches:z=>typeof z=="string",parse:z=>z.text===""?null:String(z.text),compare:(z,H)=>R(z)?R(H)?0:1:R(H)?-1:M().compare(String(z),String(H)),defaults:{filter:"text",editor:"text",align:"start"},excel:"@",toClipboard:z=>R(z)?"":String(z),fromClipboard:z=>z},image:{base:"text",storage:"dictionary",parse:z=>z.text===""||z.text==null?null:String(z.text).trim(),compare:(z,H)=>R(z)?R(H)?0:1:R(H)?-1:M().compare(String(z),String(H)),defaults:{filter:"text",editor:"text",align:"center",render:"image"},excel:"@",toClipboard:z=>R(z)?"":String(z),fromClipboard:z=>z},lookup:{base:"text",storage:"dictionary",parse:z=>{if(z.text===""||z.text==null)return null;const H=z.column&&z.column.lookup,x=H&&Z(H.options)?H.options():null;if(!x)return z.text;const F=String(z.text),C=x.find(Q=>String(Q.id)===F);if(C)return C.id;const B=F.trim().toLowerCase(),q=x.find(Q=>String(Q.label).toLowerCase()===B);return q?q.id:z.text},compare:$,defaults:{filter:"set",editor:"select",align:"start"},excel:"@",multiStorage:"multi",toClipboard:z=>R(z)?"":String(z),fromClipboard:z=>z},object:{base:"object",storage:"object",matches:z=>z!==null&&typeof z=="object"&&!(z instanceof Date),parse:z=>{try{return z.text===""?null:JSON.parse(z.text)}catch{return z.text}},compare:(z,H)=>$(z,H),format:z=>{const H=z.value;if(R(H))return"";if(typeof H=="string")return H;try{return JSON.stringify(H)}catch{return String(H)}},defaults:{filter:"none",editor:"none",align:"start"},excel:"@",toClipboard:z=>R(z)?"":typeof z=="string"?z:JSON.stringify(z),fromClipboard:z=>z}},E=["boolean","number","date","dateString","datetime","text","object"];function O(z,H,x,F){const C=x.get(z);if(C)return C;F.includes(z)&&V(`circular data type extends chain: ${[...F,z].join(" → ")}`);const B=H[z];B||V(`unknown data type "${z}"`);let q=null;B.extends&&(q=O(B.extends,H,x,[...F,z]));const Q={...q||{},...B,name:z,defaults:{...q&&q.defaults||{},...B.defaults||{}}};return Q.base||(Q.base=q&&q.base||"text"),Q.storage||(Q.storage=q&&q.storage||"object"),x.set(z,Q),Q}function T(z,H){const x={...j,...n};if(H&&typeof H.dataType=="function"&&typeof H.names=="function")for(const C of H.names("dataType")){const B=H.dataType(C);B&&(x[C]=B)}if(W(z))for(const[C,B]of Object.entries(z))x[C]=B;const F=new Map;for(const C of E)O(C,x,F,[]);O("lookup",x,F,[]);for(const C of Object.keys(x))O(C,x,F,[]);for(const C of F.values())o(C.operators);return F}function A(z,H){if(z.base==="text"&&(!z.compare||z.compare===j.text.compare)){const x=M(H);return(F,C)=>R(F)?R(C)?0:1:R(C)?-1:x.compare(String(F),String(C))}return z.compare||$}function P(z,H){return H?z.multiStorage||"multi":z.storage||"object"}function L(z){return U(String(z).replace(/([a-z])([A-Z])/g,"$1 $2"))}}),Ce("packages/core/src/columns/infer.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SAMPLE",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"inferFromValues",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"inferColumnType",{enumerable:!0,get:function(){return Z}});const _=G("packages/core/src/internal/util.js"),M=_.infoOnce,$=_.isNil,R=100;function W(V,U,D={}){const I=D.sampleSize??R,k=[];for(let S=0;S<V.length&&k.length<I;S++){const y=V[S];$(y)||typeof y=="number"&&Number.isNaN(y)||k.push(y)}if(k.length===0)return{type:"text",unanimous:!1,sampled:0};for(const[S,y]of U){if(typeof y.matches!="function")continue;let d=!0;for(let u=0;u<k.length;u++)if(!y.matches(k[u])){d=!1;break}if(d)return{type:S,unanimous:!0,sampled:k.length}}return D.quiet||M(`infer:${D.colId||"?"}`,`column "${D.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(V,U,D,I,k={}){const S=k.sampleSize??R,y=[];for(let d=0;d<U.length&&y.length<S;d++){const u=D(U[d]);$(u)||typeof u=="number"&&Number.isNaN(u)||y.push(u)}return W(y,I,{...k,colId:V}).type}}),Ce("packages/core/src/columns/graph.js",function(e,G){"use strict";Object.defineProperty(e,"WHOLE_ROW",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"declarationOf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"affectedBy",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"depsProxy",{enumerable:!0,get:function(){return I}});const _=G("packages/core/src/internal/util.js"),M=_.DEV,$=_.fail,R=_.isFunction,W=_.warnOnce,Z="*";function V(k){const S=k.value||{};if(!R(S.compute))return{computed:!1,wholeRow:!1,deps:[],pure:!0};const d=S.pure!==!1;return S.deps===Z?{computed:!0,wholeRow:!0,deps:[],pure:d}:Array.isArray(S.deps)?{computed:!0,wholeRow:!1,deps:S.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 S=new Map;for(const p of k)S.set(p.id,p);const y=new Map,d=new Map,u=new Set,n=new Set,t=new Set,i=new Set;for(const p of k){const m=V(p);if(!m.computed){y.set(p.id,[]);continue}n.add(p.id),(m.pure?t:i).add(p.id),m.wholeRow&&u.add(p.id);const b=[],g=[];for(const f of m.deps)(S.has(f)?b:g).push(f);y.set(p.id,b),g.length&&d.set(p.id,g)}for(const p of t)for(const m of y.get(p))i.has(m)&&$(`pure computed column "${p}" depends on impure column "${m}". Mark it \`value.pure: false\` or make the dependency pure.`);const s=[],r=new Map,o=[],l=p=>{const m=r.get(p);if(m!=="done"){if(m==="open"){const b=o.indexOf(p);$(`circular column dependency: ${[...o.slice(b),p].join(" → ")}`)}r.set(p,"open"),o.push(p);for(const b of y.get(p)||[])S.has(b)&&l(b);o.pop(),r.set(p,"done"),s.push(p)}};for(const p of k)l(p.id);const a=new Map;for(const p of k)a.set(p.id,[]);for(const p of k)for(const m of y.get(p.id)||[]){const b=a.get(m);b&&!b.includes(p.id)&&b.push(p.id)}if(u.size)for(const p of k){if(n.has(p.id))continue;const m=a.get(p.id);for(const b of u)m.includes(b)||m.push(b)}return{order:s,dependents:a,pure:t,impure:i,computed:n,deps:y,wholeRow:u,external:d,index:S}}function D(k,S){const y=Array.isArray(S)?S:[S],d=new Set,u=[...y];for(;u.length;){const n=u.shift();for(const t of k.dependents.get(n)||[])d.has(t)||(d.add(t),u.push(t))}for(const n of y)d.delete(n);return k.order.filter(n=>d.has(n))}function I(k,S,y){if(!M)return k;const d=S instanceof Set?S:new Set(S);return new Proxy(k,{get(u,n){return typeof n=="string"&&!d.has(n)&&!Object.hasOwn(u,n)&&W(`undeclared:${y}:${n}`,`computed column "${y}" read undeclared dependency "${n}". Add it to \`value.deps\` or the value will go stale.`),u[n]}})}}),Ce("packages/core/src/columns/lookup.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SEPARATOR",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normaliseOption",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"flattenOptions",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"toValueArray",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createLookup",{enumerable:!0,get:function(){return y}});const _=G("packages/core/src/internal/util.js"),M=_.collator,$=_.defaultCompare,R=_.isFunction,W=_.isNil,Z=_.warnOnce,V=", ",U="";function D(d,u,n,t){if(d===null||typeof d!="object")return{id:d,label:d==null?"":String(d)};const i=d[u],s=d[n],r={id:i,label:s==null?String(i??""):String(s)};d.disabled&&(r.disabled=!0),d.variant&&(r.variant=d.variant),d.icon&&(r.icon=d.icon);const o=t?d[t]:d.group;return o!==void 0&&(r.group=o),r}function I(d,u,n=0,t=[],i=[]){for(const s of d||[]){const r=s&&typeof s=="object"?s[u]:null;if(i.push({raw:s,depth:n,path:t}),Array.isArray(r)&&r.length){const o=String(s&&typeof s=="object"?s.label??s.name??s.id??"":s);I(r,u,n+1,[...t,o],i)}}return i}class k{#e;#t;#n;#r;#o=[];#i=new Map;#s=new Map;#l=0;#a="idle";#u=null;#c;constructor(u,n={}){this.#e=u||{},this.#t=n.colId||"?",this.#n=n.locale,this.#r=n.onChange||null,this.#c=M(this.#n),Array.isArray(this.#e.options)?this.#d(this.#e.options):this.#e.options===void 0&&(this.#a="ready")}get colId(){return this.#t}get version(){return this.#l}get state(){return this.#a}get ready(){return this.#a==="ready"}get multiple(){return this.#e.multiple===!0}get separator(){return this.#e.separator??V}get allowCustom(){return this.#e.allowCustom===!0}get sortBy(){return this.#e.sortBy||"label"}get spec(){return this.#e}options(){return this.#o}setLocale(u){this.#n=u,this.#c=M(u)}#d(u){const n=this.#e,t=n.valueKey||"id",i=n.labelKey||"label",s=n.childrenKey||"children";this.#o=I(u,s).map(r=>{const o=D(r.raw,t,i,n.groupKey);return r.depth&&(o.depth=r.depth,o.path=r.path),o}),this.#i=new Map,this.#s=new Map,this.#o.forEach((r,o)=>{this.#i.set(r.id,r),this.#s.set(r.id,o)}),this.#a="ready",this.#l+=1}load(){if(this.#u)return this.#u;const u=this.#e.options;if(Array.isArray(u)||u===void 0)return this.#u=Promise.resolve(this.#o),this.#u;if(!R(u))return Z(`lookup:options:${this.#t}`,`column "${this.#t}" has an invalid \`lookup.options\`; expected an array or a function`),this.#a="ready",this.#u=Promise.resolve([]),this.#u;this.#a="loading";let n;try{n=u()}catch(t){return this.#a="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),this.#u=Promise.resolve([]),this.#u}return!n||!R(n.then)?(this.#d(n),this.#u=Promise.resolve(this.#o),this.#r&&this.#r(this),this.#u):(this.#u=n.then(t=>(this.#d(t),this.#r&&this.#r(this),this.#o),t=>(this.#a="error",Z(`lookup:load:${this.#t}`,`column "${this.#t}" failed to load lookup options`,t),[])),this.#u)}refresh(){return this.#u=null,Array.isArray(this.#e.options)?(this.#d(this.#e.options),this.#r&&this.#r(this),Promise.resolve(this.#o)):this.load()}search(u,n){const t=this.#e;if(!R(t.search)){const r=String(u||"").toLowerCase();return Promise.resolve(r===""?this.#o:this.#o.filter(o=>o.label.toLowerCase().includes(r)))}const i=t.valueKey||"id",s=t.labelKey||"label";return Promise.resolve(t.search(u,n)).then(r=>(r||[]).map(o=>D(o,i,s,t.groupKey)))}option(u){return this.#i.get(u)}has(u){return this.#i.has(u)}label(u){if(W(u)||u==="")return"";const n=this.#i.get(u);if(n)return n.label;if(this.#a==="loading"||this.#a==="idle")return"";this.allowCustom||Z(`lookup:unknown:${this.#t}`,`column "${this.#t}" holds value ${JSON.stringify(u)} which is not in its lookup options. Showing the raw value; set \`lookup.unknownLabel\` or \`lookup.allowCustom\` to change that.`);const t=this.#e.unknownLabel;return R(t)?String(t(u)??""):typeof t=="string"?t:String(u)}text(u){if(this.multiple){const n=S(u);return n.length===0?"":n.map(t=>this.label(t)).join(this.separator)}return this.label(u)}dictionary(){return this.#o.map(u=>u.id)}sorted(){const u=this.sortBy;if(u==="optionOrder"||u==="count")return this.#o.slice();if(u==="value")return this.#o.slice().sort((t,i)=>$(t.id,i.id));const n=this.#c;return this.#o.slice().sort((t,i)=>n.compare(t.label,i.label))}comparator(){const u=this.sortBy,n=this.multiple,t=this.#c,i=this.#s;if(n&&u==="count")return(r,o)=>S(r).length-S(o).length;const s=n?r=>S(r)[0]:r=>r;return u==="value"?(r,o)=>$(s(r),s(o)):u==="optionOrder"?(r,o)=>{const l=i.has(s(r))?i.get(s(r)):Number.MAX_SAFE_INTEGER,a=i.has(s(o))?i.get(s(o)):Number.MAX_SAFE_INTEGER;return l-a}:(r,o)=>{const l=s(r),a=s(o);return W(l)?W(a)?0:1:W(a)?-1:t.compare(this.label(l),this.label(a))}}groupKey(u){return this.multiple?S(u).map(t=>String(t)).sort().join(U):W(u)?"":String(u)}countValues(u){return this.multiple?S(u).length:W(u)?0:1}contains(u,n,t){const i=this.multiple?S(u):W(u)?[]:[u],s=Array.isArray(n)?n:[n];switch(t){case"containsAll":return s.every(r=>i.includes(r));case"containsNone":return!s.some(r=>i.includes(r));default:return s.some(r=>i.includes(r))}}exportText(u,n="label"){return n==="value"?this.multiple?S(u).join(this.separator):W(u)?"":String(u):this.text(u)}exportColumns(){const u=this.multiple;return this.#o.map(n=>({id:n.id,label:n.label,has:t=>u?S(t).includes(n.id):t===n.id}))}}function S(d){return Array.isArray(d)?d:W(d)||d===""?[]:[d]}function y(d,u={}){const n=d.lookup;if(!n)return null;const t=new k(n,{colId:d.id,locale:u.locale,onChange:u.onChange});return!Array.isArray(n.options)&&n.options!==void 0&&t.load(),t}}),Ce("packages/core/src/columns/value.js",function(e,G){"use strict";Object.defineProperty(e,"compileDisplay",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"warnImpureUse",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"defaultRowKey",{enumerable:!0,get:function(){return y}});const _=G("packages/core/src/internal/util.js"),M=_.getPath,$=_.isFunction,R=_.isNil,W=_.Lru,Z=_.warnOnce,U=G("packages/core/src/columns/graph.js").depsProxy,D="\0";function I(t,i={}){const s=i.locale,r=i.grid??null,o=i.context,l=t.value&&t.value.format,a=t.formatter||null,p=t.dataType&&t.dataType.format,m=t.lookup||null,b=(g,f,w)=>({value:g,data:w,row:f,column:t,colId:t.id,grid:r,context:o,locale:s});if($(l))return(g,f,w)=>{const v=l(b(g,f,w));return v==null?"":String(v)};if(a){if(m){const g=a.kind==="text";return(f,w,v)=>a(g?m.text(f):f,b(f,w,v))}return(g,f,w)=>a(g,b(g,f,w))}return $(p)?(g,f,w)=>{const v=p(b(g,f,w));return v==null?"":String(v)}:m?g=>m.text(g):g=>R(g)?"":typeof g=="string"?g:String(g)}function k(t,i){!t||!t.value||t.value.pure!==!1||Z(`impure:${i}:${t.id}`,`column "${t.id}" is an impure computed column (\`value.pure: false\`) and is being used to ${i}. The result is not stable across passes.`)}class S{#e;#t;#n;#r;#o;#i;#s=new W(4096);constructor(i){this.#e=i.columns instanceof Map?i.columns:new Map((i.columns||[]).map(s=>[s.id,s])),this.#t=i.graph,this.#n=i.grid??null,this.#r=i.context,this.#i=i.stored||null,this.#o=i.rowKey||y}get graph(){return this.#t}setGraph(i){this.#t=i,this.#s.clear()}beginPass(){this.#s.clear()}endPass(){this.#s.clear()}invalidate(i){if(this.#s.size===0)return;const s=i&&i.rows?new Set([...i.rows].map(String)):null,r=i&&i.columns?[...i.columns]:null;if(!s&&!r){this.#s.clear();return}const o=r?this.#l(r):null;for(const l of[...this.#s.keys()]){const a=String(l).split(D);a.length===3&&(s&&!s.has(a[0])||o&&!o.has(a[2])||this.#s.delete(l))}}#l(i){const s=new Set,r=this.#t,o=[...i];for(;o.length;){const l=o.pop();if(!s.has(l)){s.add(l);for(const a of r?r.dependents.get(l)||[]:[])o.push(a)}}return s}value(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;if(!o)return;if(!o.computed)return this.#u(o,s,r);if(o.value.pure!==!1&&this.#i&&r&&r.physical!=null&&this.#i.has(o.id))return this.#i.get(o.id,r.physical);if(o.volatile)return this.compute(o,s,r);if(o.value.pure===!1)return this.compute(o,s,r);const l=`${this.#a(s,r)}${D}${o.id}`;if(this.#s.has(l))return this.#s.get(l);const a=this.compute(o,s,r);return this.#s.set(l,a),a}#a(i,s){return`${this.#o(i,s)}${D}${d(i)}`}#u(i,s,r){if(this.#i&&r&&r.physical!=null&&this.#i.has(i.id))return this.#i.get(i.id,r.physical);if(i.field)return i.read?i.read(s):M(s,i.field)}compute(i,s,r){const o=this.#t,l=o&&o.wholeRow.has(i.id);let a;if(l)a=s??{};else{a={};const m=o&&o.deps.get(i.id)||[];for(const g of m)a[g]=this.value(g,s,r);const b=o&&o.external.get(i.id)||[];for(const g of b)a[g]=M(s,g);a=U(a,[...m,...b],i.id)}const p={data:s,row:r,column:i,grid:this.#n,context:this.#r};return i.value.compute(a,p)}values(i,s){const r={},o=this.#t?this.#t.order:[...this.#e.keys()];for(const l of o)r[l]=this.value(l,i,s);return r}text(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;return o?o.formatValue(this.value(o,s,r),r,s):""}key(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;if(!o)return"";const l=this.value(o,s,r);return $(o.value.key)?String(o.value.key(this.#c(o,l,s,r))):o.lookup?o.lookup.groupKey(l):R(l)?"":String(l)}quickFilterText(i,s,r){const o=typeof i=="string"?this.#e.get(i):i;if(!o)return"";if($(o.value.quickFilterText)){const l=this.value(o,s,r);return String(o.value.quickFilterText(this.#c(o,l,s,r))??"")}return this.text(o,s,r)}#c(i,s,r,o){return{value:s,data:r,row:o,column:i,colId:i.id,grid:this.#n,context:this.#r}}parse(i,s,r,o){const l=typeof i=="string"?this.#e.get(i):i;if(!l)return s;const a={text:s,value:this.value(l,r,o),data:r,row:o,column:l,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 $(l.value.parse)?l.value.parse(a):l.dataType&&$(l.dataType.parse)?l.dataType.parse(a):s}validate(i,s,r,o,l){const a=typeof i=="string"?this.#e.get(i):i;if(!a||!$(a.edit.validate))return!0;const p=a.edit.validate({value:s,oldValue:r,data:o,row:l,column:a,grid:this.#n,context:this.#r});return p===!0||p===void 0?!0:String(p)}apply(i,s,r,o){const l=typeof i=="string"?this.#e.get(i):i;if(!l)return!1;const a=this.value(l,r,o);if($(l.value.apply)){const p=l.value.apply({value:s,oldValue:a,data:r,row:o,column:l,grid:this.#n,context:this.#r});return this.#d(l,r,o),p!==!1}return l.field?a===s?!1:(l.write(r,s),this.#d(l,r,o),!0):(Z(`apply:${l.id}`,`column "${l.id}" has no \`field\` and no \`value.apply\`, so an edit cannot be written back.`),!1)}commit(i,s,r,o){const l=typeof i=="string"?this.#e.get(i):i;if(!l)return{ok:!1,value:void 0,oldValue:void 0,changed:!1,error:"unknown column"};const a=this.value(l,r,o),p=this.parse(l,s,r,o),m=this.validate(l,p,a,r,o);if(m!==!0)return{ok:!1,value:p,oldValue:a,changed:!1,error:m};const b=this.apply(l,p,r,o);return{ok:!0,value:p,oldValue:a,changed:b}}#d(i,s,r){if(this.#s.size===0)return;const o=this.#a(s,r);this.#s.delete(`${o}${D}${i.id}`);for(const l of this.#t?this.#t.dependents.get(i.id)||[]:[])this.#s.delete(`${o}${D}${l}`)}}function y(t,i){return i&&i.key!=null?String(i.key):d(t)}function d(t){if(t&&typeof t=="object"){let i=u.get(t);return i===void 0&&(i=`#${n++}`,u.set(t,i)),i}return String(t)}const u=new WeakMap;let n=0}),Ce("packages/core/src/model/shadow.js",function(e,G){"use strict";Object.defineProperty(e,"MAX_TRACKED",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"DEFAULT_DEPTH",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"HISTORY_TICK_MAX_MS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"HISTORY_TICK_MIN_MS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"historyTickFor",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"SHADOW_KINDS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ROLLING_KINDS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"FIT_SHADOW_KINDS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"DEFAULT_ANOMALY_THRESHOLD",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SPEC_STATUS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"POSITIONAL_KINDS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"SHADOW_LABELS",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"specStatusOf",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ShadowTracker",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"shadowsIn",{enumerable:!0,get:function(){return a}});const M=G("packages/core/src/internal/util.js").warnOnce,$=2e5,R=20,W=1e3,Z=50;function V(p){return Math.min(W,Math.max(Z,Math.floor(p)))}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"]),D=Object.freeze(["rollingSum","rollingAvg","rollingMin","rollingMax","windowCoverage","cumulativeToDate","periodOverPeriod","rollingQuantile","windowApproximate","tsTrend","tsSeasonal","tsResidual","tsCoverage","tsSmoothed","tsSmoothingAlpha","tsSmoothingBeta"]),I=Object.freeze(["fitPredicted","fitResidual","fitInfluence","fitStdResidual","fitLeverage","fitCooksD"]),k=.6745,S=3.5,y=Object.freeze({PASS:"PASS",WARN:"WARN",FAIL:"FAIL"}),d=Object.freeze(["rank","rankAsc","rankChange","percentile","quartile","zScore","shareOfTotal","anomalyScore","anomalyFlag"]),u=Object.freeze({updates:"Updates",updatedAt:"Updated at",sinceUpdate:"Since update",delta:"Change",deltaPercent:"Change %",rate:"Rate of change",history:"History",firstValue:"Baseline",streak:"Streak",rank:"Rank",rankAsc:"Rank, ascending",rankChange:"Rank change",percentile:"Percentile",quartile:"Quartile",zScore:"Z-score",shareOfTotal:"Share of total",anomalyScore:"Anomaly score",anomalyFlag:"Anomaly",specStatus:"Spec status",rollingSum:"Rolling sum",rollingAvg:"Rolling average",rollingMin:"Rolling minimum",rollingMax:"Rolling maximum",windowCoverage:"Window coverage",cumulativeToDate:"Cumulative to date",periodOverPeriod:"Period over period",rollingQuantile:"Rolling quantile",windowApproximate:"Window approximate",tsTrend:"Trend",tsSeasonal:"Seasonal",tsResidual:"Seasonal residual",tsCoverage:"Decomposition coverage",tsSmoothed:"Smoothed",tsSmoothingAlpha:"Smoothing α",tsSmoothingBeta:"Smoothing β",fitPredicted:"Predicted",fitResidual:"Residual",fitInfluence:"Influence",fitStdResidual:"Std. residual",fitLeverage:"Leverage",fitCooksD:"Cook's D"});function n(p,m){if(!m)return null;const b=Number.isFinite(Number(m.lower))?Number(m.lower):null,g=Number.isFinite(Number(m.upper))?Number(m.upper):null;if(b===null&&g===null||!Number.isFinite(p))return null;if(b!==null&&p<b||g!==null&&p>g)return y.FAIL;const f=Number.isFinite(Number(m.warnLower))?Number(m.warnLower):null,w=Number.isFinite(Number(m.warnUpper))?Number(m.warnUpper):null;return f!==null&&p<f||w!==null&&p>w?y.WARN:y.PASS}function t(p,m,b){if(!m||typeof m!="object")return null;if(m.kind!=="time")return m.kind!==void 0&&M(`shadow.history.window.kind:${p}`,`a 'history' shadow's 'window' only accepts {kind: 'time', span}; '${m.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 g=m.minutes!=null?Number(m.minutes)*6e4:Number(m.span);if(!(g>0))return M(`shadow.history.window.span:${p}`,"a 'history' shadow's time window needs a positive 'span' (ms) or 'minutes'; it had none, so it reported the original, unwindowed history."),null;const f=Math.max(2,Math.floor(b)||R);return{span:g,bucketMs:Math.max(1,Math.floor(g/f))}}class i{#e;#t=new Map;#n=new Map;#r=new Map;#o=new Map;#i=new Map;#s=new Map;#l=0;#a;#u;#c;#d;#h=new Map;#f=null;#m=null;#p=null;constructor(m){this.#e=m.colId,this.#a=Math.max(2,m.depth||R),this.#u=Math.max(1,m.max||$),this.#c=m.now||(()=>Date.now()),this.#d=t(this.#e,m.historyWindow,this.#a),this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}get colId(){return this.#e}get forgotten(){return this.#l}get size(){return this.#n.size}get historyWindow(){return this.#d}observe(m,b){const g=l(b);if(g===null)return;if(!this.#n.has(m)){this.#m=null,this.#p=null,this.#g(),this.#t.set(m,g),this.#n.set(m,g),this.#r.set(m,0),this.#o.set(m,this.#c()),this.#i.set(m,[g]),this.#d&&this.#h.set(m,[g]),this.#s.set(m,0);return}const f=this.#n.get(m);if(f===g)return;this.#m=null,this.#p=null,this.#n.set(m,g),this.#r.set(m,(this.#r.get(m)||0)+1),this.#o.set(m,this.#c());const w=this.#i.get(m)||[];w.push(g),w.length>this.#a&&w.splice(0,w.length-this.#a),this.#i.set(m,w);const v=Math.sign(g-f),h=this.#s.get(m)||0;this.#s.set(m,Math.sign(h)===v?h+v:v)}#g(){if(this.#n.size<this.#u)return;const m=this.#n.keys().next().value;m!==void 0&&(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.#s.delete(m),this.#l++)}rebase(){for(const[m,b]of this.#n)this.#t.set(m,b);this.#m=null,this.#p=null}reset(){this.#t.clear(),this.#n.clear(),this.#r.clear(),this.#o.clear(),this.#i.clear(),this.#h.clear(),this.#s.clear(),this.#l=0,this.#m=null,this.#p=null,this.#d&&(this.#f=Math.floor(this.#c()/this.#d.bucketMs))}retain(m){const b=m instanceof Set?m:new Set(m);let g=0;for(const f of[...this.#n.keys()])b.has(f)||(this.#t.delete(f),this.#n.delete(f),this.#r.delete(f),this.#o.delete(f),this.#i.delete(f),this.#h.delete(f),this.#s.delete(f),g++);return g&&(this.#m=null,this.#p=null),g}advanceHistoryWindow(m=this.#c()){const b=this.#d;if(!b)return 0;const g=Math.floor(m/b.bucketMs),f=g-this.#f;if(!(f>0))return 0;const w=Math.min(f,this.#a);for(const[v,h]of this.#h){const c=this.#n.get(v);for(let j=0;j<w;j++)h.push(c);h.length>this.#a&&h.splice(0,h.length-this.#a)}return this.#f=g,f}read(m,b,g,f){switch(m){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 h=this.#c()-v,c=w[w.length-1]-w[w.length-2];return h>0?c/h*1e3:c}case"history":return this.#d?this.#h.has(b)?[...this.#h.get(b)]:null:this.#i.has(b)?[...this.#i.get(b)]:null;case"streak":return this.#s.has(b)?this.#s.get(b):0;case"specStatus":return this.#n.has(b)?n(this.#n.get(b),f):null;default:return d.includes(m)?this.#v(m,b,g,f):null}}#w(m){if(m){if(this.#p&&this.#p.only===m)return this.#p.view;const b=this.#b(m);return this.#p={only:m,view:b},b}return this.#m?this.#m:(this.#m=this.#b(null),this.#m)}#b(m){const b=[];for(const[T,A]of this.#n)m&&!m.has(T)||b.push(A);const g=b.sort((T,A)=>T-A);let f=0,w=0,v=0,h=0;for(const T of g){h+=T,f++;const A=T-w;w+=A/f,v+=A*(T-w)}const c=[];for(const[T,A]of this.#t)m&&!m.has(T)||c.push(A);const j=f?s(g):0,E=g.map(T=>Math.abs(T-j)).sort((T,A)=>T-A),O=f?s(E):0;return{sorted:g,baseline:c.sort((T,A)=>T-A),sum:h,mean:f?w:0,sd:f>1?Math.sqrt(v/(f-1)):0,median:j,mad:O}}#v(m,b,g,f){if(!this.#n.has(b)||g&&!g.has(b))return null;const w=this.#n.get(b),v=this.#w(g),h=v.sorted.length;if(!h)return null;switch(m){case"rank":return h-o(v.sorted,w)+1;case"rankAsc":return r(v.sorted,w)+1;case"rankChange":{if(!this.#t.has(b)||!v.baseline.length)return null;const c=v.baseline.length-o(v.baseline,this.#t.get(b))+1,j=h-o(v.sorted,w)+1;return c-j}case"percentile":return o(v.sorted,w)/h*100;case"quartile":{const c=o(v.sorted,w)/h;return Math.min(4,Math.max(1,Math.ceil(c*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 c=f&&Number.isFinite(Number(f.threshold))?Number(f.threshold):S;return Math.abs(k*(w-v.median)/v.mad)>c}case"shareOfTotal":return v.sum?w/v.sum*100:null;default:return null}}}function s(p){const m=p.length;if(!m)return 0;const b=(m-1)*.5,g=Math.floor(b),f=Math.ceil(b);return g===f?p[g]:p[g]+(b-g)*(p[f]-p[g])}function r(p,m){let b=0,g=p.length;for(;b<g;){const f=b+g>>1;p[f]<m?b=f+1:g=f}return b}function o(p,m){let b=0,g=p.length;for(;b<g;){const f=b+g>>1;p[f]<=m?b=f+1:g=f}return b}function l(p){if(p==null||p==="")return null;if(p instanceof Date){const b=p.getTime();return Number.isFinite(b)?b:null}const m=typeof p=="number"?p:Number(p);return Number.isFinite(m)?m:null}function a(p){const m=[];for(const b of p||[]){const g=b.shadow;if(!g)continue;const f=typeof g=="string"?{kind:g}:g,w=f.kind;U.includes(w)&&(D.includes(w)||I.includes(w)||m.push({colId:b.id||b.field,of:f.of||b.field||b.id,kind:w,depth:f.depth,historyWindow:w==="history"?f.window:void 0}))}return m}}),Ce("packages/core/src/columns/model.js",function(e,G){"use strict";Object.defineProperty(e,"BUILTIN_DEFAULTS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"normaliseAlign",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"normaliseVAlign",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"expandColumn",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"flattenTree",{enumerable:!0,get:function(){return re}});const _=G("packages/core/src/internal/util.js"),M=_.expand,$=_.fail,R=_.getPath,W=_.humanise,Z=_.isFunction,V=_.isObject,U=_.merge,D=_.pathGetter,I=_.pathSetter,k=_.toArray,S=_.uid,y=_.warnOnce,u=G("packages/core/src/format/index.js").compileFormat,n=G("packages/core/src/columns/datatypes.js"),t=n.comparatorFor,i=n.createTypeRegistry,s=n.storageKind,r=G("packages/core/src/columns/infer.js"),o=r.inferColumnType,l=r.DEFAULT_SAMPLE,a=G("packages/core/src/columns/graph.js"),p=a.buildGraph,m=a.affectedBy,g=G("packages/core/src/columns/lookup.js").createLookup,f=G("packages/core/src/columns/value.js"),w=f.compileDisplay,v=f.ValuePipeline,h=f.warnImpureUse,j=G("packages/core/src/model/shadow.js").FIT_SHADOW_KINDS,E=Object.freeze({geometry:"geometry",list:"list"}),O={value:{pure:!0},cell:{},edit:{enabled:!1},sort:{enabled:!0,direction:null,order:0,nullsFirst:!1},filter:{enabled:!0,type:"text"},group:{enabled:!1,index:-1,explode:!1},pivot:{enabled:!1,index:-1},total:null,layout:{width:150,min:40,max:null,flex:0,pin:null,hidden:!1,resizable:!0,movable:!0,lockVisible:!1,lockPosition:!1},header:{},facet:{},export:{lookup:"label",csv:!0,excel:!0},allowGroup:!0,allowPivot:!0,allowTotal:!0,nullable:!0,quickFilter:!0},T={centre:"center"},A=new Set(["start","center","end","left","right"]);function P(de){if(typeof de!="string")return;const ie=de.toLowerCase();return T[ie]?T[ie]:A.has(ie)?ie:void 0}function L(de){if(typeof de!="string")return;const ie=de.toLowerCase();return ie==="center"||ie==="centre"?"middle":ie==="top"||ie==="middle"||ie==="bottom"?ie:void 0}const z=["cell","layout","header"];function H(de){if(!V(de))return{};const ie={...de},oe=(ue,ce)=>{if(de[ue]===void 0)return;const pe=M(de[ue],ce);pe&&z.includes(ue)&&!V(de[ue])&&delete pe.enabled,ie[ue]=pe};return oe("sort","direction"),oe("filter","type"),oe("cell","render"),oe("edit","editor"),oe("layout","width"),oe("group","index"),oe("pivot","index"),oe("header","render"),oe("facet","strategy"),ie}function x(de,ie){const oe={...de||{}},ue=V(ie)&&V(ie.layout)&&ie.layout.width!==void 0;return oe.fit==="content"&&!ue&&delete oe.width,oe}const F=new Set(["allowGroup","allowPivot","allowTotal","cell","colSpan","contextMenu","edit","export","field","filter","filterRow","format","grandTotal","group","groupTotal","header","headerControls","id","layout","lookup","nullable","pivot","preset","quickFilter","rowSpan","running","shadow","showWhen","sort","spec","tags","title","total","type","typeOptions","validation","value","verticalAlign"]),C=new Set(["collapsible","columns","facet","header","id","marryChildren","openByDefault","showWhen","title"]);function B(de,ie,oe,ue){const ce=oe==="columnGroup"?"column group":"column";for(const pe of Object.keys(de))ie.has(pe)||y(`${oe}.unknown:${pe}`,`'${pe}' is not a configuration key this grid recognises, so it had no effect on ${ce} "${ue}". Check the spelling against the reference.`)}function q(de,ie){const oe=ie&&Z(de.defaultsFor)?de.defaultsFor(ie):null,ue={...de.defaults||{},...V(oe)?oe:{}},ce={};return ue.align&&(ce.align=ue.align,ce.cell={align:ue.align},ce.header={align:ue.align}),ue.filter&&(ce.filter=ue.filter==="none"?{enabled:!1,type:"none"}:{enabled:!0,type:ue.filter}),ue.editor&&(ce.edit=ue.editor==="none"?{editor:null}:{editor:ue.editor}),ue.total&&(ce.total=ue.total),ue.render&&(ce.cell={...ce.cell||{},render:ue.render}),de.export&&(ce.export={...de.export}),ce}function Q(de){if(typeof de=="string")return de.trim()?[de.trim()]:[];if(!Array.isArray(de))return[];const ie=[];for(const oe of de){if(typeof oe!="string")continue;const ue=oe.trim();ue&&!ie.includes(ue)&&ie.push(ue)}return ie}class Y{#e=new Map;#t=[];#n=[];#r;#o;#i;#s;#l;#a;#u(ie,oe,ue){const ce=this.#c(ie,oe,ue);if(typeof ce!="string"||!this.#d)return ce??null;const pe=oe&&oe.totals&&oe.totals.implement;if(pe&&Z(pe[ce])){const $e=pe[ce];return $e.totalName=ce,$e}const Me=this.#d.totalFn?.(ce);return Z(Me)?Me:ce}#c(ie,oe,ue){if(typeof ie!="string")return ie;const ce=oe&&oe.totals&&oe.totals.supported;if(!Array.isArray(ce)||ce.includes(ie))return ie;const pe=ce.length?ce.join(", "):"none";return $(`column "${ue}" is typed ${oe.name||"a type"}, for which the total "${ie}" is not meaningful. Supported: ${pe}. Aggregating it anyway would produce a confident wrong number.`),ie}#d;#h;#f;#m;#p;#g;#w=!1;#b;#v;constructor(ie={}){this.#o=H(ie.columnDefaults||{}),this.#i=ie.columnPresets||{},this.#l=ie.locale,this.#s=ie.timeZone,this.#a=L(ie.verticalAlign),this.#d=ie.registry||null,this.#h=ie.grid||null,this.#f=ie.context,this.#b=ie.sampleSize??l,this.#v=ie.onChange||null,this.#g=Z(ie.rowKey)?ie.rowKey:void 0,this.#r=i(ie.dataTypes,this.#d);const{leaves:oe,groups:ue}=re(ie.columns||[]);this.#n=ue;for(const ce of oe){const pe=this.#y(ce.def,null);if(pe.groupPath=ce.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}ce.column=pe,this.#e.set(pe.id,pe),this.#t.push(pe.id)}this.#O(ie.stored||null)}#y(ie,oe){B(ie,F,"column",ie.id||ie.field||"(unnamed)");const ue=H(ie),ce=k(ie.preset),pe=ce.map(nt=>{const Ae=this.#i[nt];return Ae?H(Ae):(y(`preset:${nt}`,`unknown column preset "${nt}"; ignoring`),{})}),Me=this.#j(ue,pe,oe),$e=this.#r.get(Me)||this.#r.get("text");if(!this.#r.has(Me)&&ie.type){const nt=E[Me];y(`type:${Me}`,`unknown data type "${Me}"; falling back to "text"`+(nt?`. It is registered by importing '@toclocoinc/lattice-grid/modules/${nt}'.`:""))}const je=Z($e.items)?this.#A(ue,pe,ie.id||ie.field||"(unnamed)"):null;let ke=O;ke=U(ke,this.#o),ie.type!==!1&&(ke=U(ke,q($e,je)));for(const nt of pe)ke=U(ke,nt);ke=U(ke,ue);const ge=ke.edit;ge&&ge.editor&&ge.enabled!==!0&&!Z(ge.enabled)&&(ie.edit||{}).editor&&y(`column.editor-not-enabled:${ie.id||ie.field}`,`column '${ie.id||ie.field}' names the editor '${ge.editor}' but does not enable editing, so it stays read-only. Add \`enabled: true\`, or use \`edit: true\` and set \`editor\` alongside it.`);const Ee=ie.id||ie.field||S("col");if(ie.shadow&&!Z(ke.value&&ke.value.compute)){const nt=typeof ie.shadow=="string"?{kind:ie.shadow}:ie.shadow,Ae=nt.of||ie.field||Ee,Ke=j.includes(nt.kind),Ve=Ke?nt.model||nt:null,Xe=Ke&&Ve?[...Array.isArray(Ve.predictors)?Ve.predictors:[],Ve.response].filter(Boolean):null;ke.value={...ke.value||{},deps:Xe&&Xe.length?Xe:nt.orderBy&&nt.orderBy!==Ae?[Ae,nt.orderBy]:[Ae],pure:!1,compute:(st,ht)=>{const bt=ht.grid&&ht.grid.statistics;if(!bt)return null;const At=ht.row&&ht.row.key||bt.keyOf(ht.data);if(!At)return null;if(Ke){if(!Z(bt.fitShadow))return null;const Tt=nt.model?{...nt.model,threshold:nt.threshold}:nt;return bt.fitShadow(nt.kind,At,Tt)}return bt.shadow(Ae,nt.kind,At,nt.scope,nt)}}}if(ie.running&&!Z(ke.value&&ke.value.compute)){const nt=typeof ie.running=="string"?{kind:ie.running}:ie.running,Ae=nt.of||ie.field||Ee;ke.value={...ke.value||{},deps:[Ae],pure:!1,compute:(Ke,Ve)=>{const Xe=Ve.grid&&Ve.grid.statistics;if(!Xe||!Z(Xe.running))return null;const st=Ve.row&&Ve.row.key||Xe.keyOf(Ve.data);return st?Xe.running(Ae,nt.kind||"total",st):null}},ie.sort===void 0&&(ke.sort={...ke.sort||{},enabled:!1})}const Ie=ie.field??(Z(ke.value&&ke.value.compute)?null:ie.id??null),ze=Z(ke.value&&ke.value.compute),_e={id:Ee,field:Ie,shadow:ie.shadow||null,running:ie.running||null,spec:ie.spec||null,validation:ie.validation||null,volatile:!!(ie.shadow||ie.running),title:ke.title??W(Ie||Ee),type:$e.name,dataType:$e,itemType:je,nullable:ke.nullable!==!1,align:P(ue.cell&&ue.cell.align||ue.align||ke.cell&&ke.cell.align||ke.align||$e.defaults&&$e.defaults.align)||"start",verticalAlign:L(ue.cell&&ue.cell.verticalAlign||ue.verticalAlign||ke.cell&&ke.cell.verticalAlign||ke.verticalAlign)||this.#a,rowSpan:Z(ke.rowSpan)?ke.rowSpan:null,colSpan:Z(ke.colSpan)?ke.colSpan:null,value:{pure:!0,...ke.value||{}},cell:{...ke.cell||{}},edit:{...ke.edit||{}},sort:{...ke.sort||{}},filter:{...ke.filter||{}},group:{enabled:!1,index:-1,explode:!1,...ke.group||{}},pivot:{enabled:!1,index:-1,...ke.pivot||{}},total:this.#u(ke.total,$e,ie.id||ie.field||"(unnamed)"),groupTotal:ke.groupTotal===void 0?null:this.#u(ke.groupTotal,$e,ie.id||ie.field||"(unnamed)"),grandTotal:ke.grandTotal===void 0?null:this.#u(ke.grandTotal,$e,ie.id||ie.field||"(unnamed)"),tags:Q(ke.tags),typeOptions:ke.typeOptions??null,...V(ke[Me])?{[Me]:ke[Me]}:{},layout:x(ke.layout,ue),header:{...ke.header||{}},contextMenu:ke.contextMenu===void 0?null:ke.contextMenu,facet:{...ke.facet||{}},export:{...ke.export||{}},allowGroup:ke.allowGroup!==!1,allowPivot:ke.allowPivot!==!1,allowTotal:ke.allowTotal!==!1,quickFilter:ke.quickFilter!==!1,def:ie,format:ke.format,presets:ce,inferred:oe!=null&&!ie.type,computed:ze,read:Ie?D(Ie):null,write:Ie?I(Ie):null};_e.cell.align=P(ue.cell&&ue.cell.align)||_e.align,_e.header.align=P(ue.header&&ue.header.align)||_e.align;const Qe=ke.lookup||null;return _e.lookup=Qe?g({id:Ee,lookup:Qe},{locale:this.#l,onChange:()=>{this.#v&&this.#v("lookup",{colId:Ee})}}):null,_e.group.explode&&_e.lookup&&_e.lookup.multiple&&y(`explode:${Ee}`,`column "${Ee}" has \`group.explode\`, so rows appear under each of their values and totals double-count. Group footers should be annotated accordingly.`),this.#S(_e),_e}#S(ie){ie.formatter=u(ie.format,ie.dataType,this.#l,this.#s,ie.id),ie.formatValue=w(ie,{locale:this.#l,grid:this.#h,context:this.#f}),ie.itemCompare=ie.itemType?t(ie.itemType,this.#l):null,ie.compare=Z(ie.value.compare)?ie.value.compare:ie.lookup?ie.lookup.comparator():Z(ie.dataType.compareFor)?ie.dataType.compareFor(ie):t(ie.dataType,this.#l),ie.excel=ie.formatter&&ie.formatter.ooxml||ie.dataType&&ie.dataType.excel||"General",ie.storeKind=s(ie.dataType,!!(ie.lookup&&ie.lookup.multiple))}#A(ie,oe,ue){let ce=V(ie.typeOptions)?ie.typeOptions:null;for(let je=oe.length-1;!ce&&je>=0;je--)V(oe[je].typeOptions)&&(ce=oe[je].typeOptions);!ce&&V(this.#o.typeOptions)&&(ce=this.#o.typeOptions);const pe=ce&&ce.of!==void 0?ce.of:"text",Me=typeof pe=="string"?this.#r.get(pe):void 0;return Me&&!Z(Me.items)&&Me.storage!=="object"?Me:(y(`type:of:${String(pe)}`,`column "${ue}" names "${String(pe)}" as its item type (typeOptions.of), which is not ${Me?"a scalar data type":"a known data type"}; its items are read as text.`),this.#r.get("text"))}#j(ie,oe,ue){if(ie.type===!1)return"text";if(ie.type)return ie.type;for(let ce=oe.length-1;ce>=0;ce--)if(oe[ce].type)return oe[ce].type;if(this.#o.type)return this.#o.type;if(ie.shadow){const ce=typeof ie.shadow=="string"?ie.shadow:ie.shadow.kind;if(ce==="fitInfluence")return"boolean";if(ce==="fitPredicted"||ce==="fitResidual"||ce==="fitStdResidual"||ce==="fitLeverage"||ce==="fitCooksD"||ce==="tsTrend"||ce==="tsSeasonal"||ce==="tsResidual"||ce==="tsCoverage"||ce==="tsSmoothed"||ce==="tsSmoothingAlpha"||ce==="tsSmoothingBeta")return"number"}return ue||(ie.lookup?"lookup":"text")}#O(ie){const oe=this.all();this.#m=p(oe),this.#p?this.#p.setGraph(this.#m):this.#p=new v({columns:this.#e,graph:this.#m,grid:this.#h,context:this.#f,stored:ie||null,rowKey:this.#g});const ue=this.#p;for(const ce of oe)ce.getValue=(pe,Me)=>ue.value(ce,pe,Me)}all(){return this.#t.map(ie=>this.#e.get(ie))}visible(){return this.all().filter(ie=>!ie.layout.hidden)}get(ie){return this.#e.get(ie)}groups(){const ie=oe=>{const ue=[];for(const ce of oe)Array.isArray(ce.columns)?ue.push({...ce,columns:ie(ce.columns)}):ce.column&&ue.push(ce.column);return ue};return ie(this.#n)}graph(){return this.#m}pipeline(){return this.#p}types(){return this.#r}affectedBy(ie){return m(this.#m,ie)}value(ie,oe,ue){return this.#p.value(ie,oe,ue)}text(ie,oe,ue){return this.#p.text(ie,oe,ue)}checkImpure(ie,oe){h(this.#e.get(ie),oe)}setLocale(ie){this.#l=ie;for(const oe of this.all())oe.lookup&&oe.lookup.setLocale(ie),this.#S(oe);this.#v&&this.#v("locale",{locale:ie})}infer(ie){const oe={};if(this.#w||!Array.isArray(ie)||ie.length===0)return oe;this.#w=!0;let ue=!1;for(const ce of this.all()){const pe=ce.def;if(pe.type!==void 0||!ce.field||ce.computed||ce.lookup||this.#E(ce))continue;const Me=ce.read||(ke=>R(ke,ce.field)),$e=o(ce.id,ie,Me,this.#r,{sampleSize:this.#b});if($e===ce.type)continue;oe[ce.id]=$e;const je=this.#y(pe,$e);je.groupPath=ce.groupPath,je.layout={...je.layout,...J(ce.layout)},this.#e.set(ce.id,je),se(this.#n,ce.id,je),ue=!0}return ue&&this.#O(null),oe}redecorate(ie,oe,ue={}){const ce=this.#e.get(ie);if(!ce){y(`redecorate:${ie}`,`columns.decorate('${ie}', …): no column with id '${ie}'.`);return}const pe=ce.def||{},Me={...V(pe.cell)?pe.cell:{}};Me.decoration=oe??void 0,ue&&"variant"in ue&&(Me.variant=ue.variant);const $e={...pe,cell:Me},je=this.#y($e,ce.type);return je.groupPath=ce.groupPath,je.layout={...je.layout,...J(ce.layout)},this.#e.set(ie,je),se(this.#n,ie,je),this.#O(null),this.#v&&this.#v("decorate",{colId:ie}),je}#E(ie){for(const oe of ie.presets){const ue=this.#i[oe];if(ue&&ue.type)return!0}return!!this.#o.type}#C(ie){return!ie.computed&&Z(ie.dataType&&ie.dataType.toStorage)}storeReader(ie){if(ie.computed)return oe=>this.#p.value(ie,oe,null);if(this.#C(ie)){const oe=ie.dataType.toStorage,ue={timeZone:ie.timeZone||this.#s,colId:ie.id,itemType:ie.itemType||null};return ce=>oe(ie.read(ce),ue)}return ie.read}storeValue(ie,oe){if(!(!ie||ie.computed)&&Z(ie.read))return this.storeReader(ie)(oe)}storeSchema(){const ie=[];for(const oe of this.all()){if(oe.computed&&oe.value.pure===!1||!oe.computed&&!oe.field)continue;const ue=this.storeReader(oe);let ce=null;!oe.computed&&!this.#C(oe)&&typeof oe.field=="string"&&!oe.lookup&&(ce=oe.field);const pe={id:oe.id,kind:oe.storeKind,nullable:oe.nullable,read:ue};ce!==null&&(pe.field=ce),oe.lookup&&(pe.dictionary=oe.lookup.dictionary()),ie.push(pe)}return ie}state(){return this.all().map(ie=>({id:ie.id,width:ie.layout.width,flex:ie.layout.flex||void 0,hidden:!!ie.layout.hidden,pin:ie.layout.pin??null,sort:ie.sort.direction??null,sortIndex:ie.sort.direction?ie.sort.order??0:null,groupIndex:ie.group.enabled?ie.group.index??0:null,pivotIndex:ie.pivot.enabled?ie.pivot.index??0:null,total:typeof ie.total=="string"?ie.total:null,groupTotal:typeof ie.groupTotal=="string"?ie.groupTotal:void 0,grandTotal:typeof ie.grandTotal=="string"?ie.grandTotal:void 0,decoration:ie.cell&&ie.cell.decoration!=null?te(ie.cell.decoration):void 0,variant:ie.cell&&ie.cell.variant!=null?te(ie.cell.variant):void 0}))}applyState(ie){const oe={applied:[],skipped:[]},ue=Array.isArray(ie)?ie:ie&&ie.columns||[],ce=!Array.isArray(ie)&&ie&&ie.columnOrder||null;for(const Me of ue){if(!Me||!Me.id){oe.skipped.push({key:"?",reason:"no id"});continue}let $e=this.#e.get(Me.id);if(!$e){oe.skipped.push({key:Me.id,reason:"unknown column"});continue}if(Object.hasOwn(Me,"decoration")||Object.hasOwn(Me,"variant")){const je=$e.cell?$e.cell.decoration:void 0,ke=Me.decoration??null,ge=Object.hasOwn(Me,"variant"),Ee=ge&&!ee($e.cell?$e.cell.variant:void 0,Me.variant);(!ee(je,ke)||Ee)&&(this.redecorate(Me.id,ke,ge?{variant:Me.variant??void 0}:{}),$e=this.#e.get(Me.id)||$e)}Me.width!=null&&($e.layout.width=Me.width),Me.flex!=null&&($e.layout.flex=Me.flex),Me.hidden!=null&&($e.layout.hidden=!!Me.hidden),Me.pin!==void 0&&($e.layout.pin=Me.pin),Me.sort!==void 0&&($e.sort.direction=Me.sort),Me.sortIndex!=null&&($e.sort.order=Me.sortIndex),Me.groupIndex!=null&&($e.group.enabled=!0,$e.group.index=Me.groupIndex),Me.pivotIndex!=null&&($e.pivot.enabled=!0,$e.pivot.index=Me.pivotIndex),Me.total!==void 0&&($e.total=Me.total),Me.groupTotal!==void 0&&($e.groupTotal=Me.groupTotal),Me.grandTotal!==void 0&&($e.grandTotal=Me.grandTotal),oe.applied.push(Me.id)}const pe=ce||ue.map(Me=>Me&&Me.id).filter(Boolean);if(pe.length){const Me=pe.filter(je=>this.#e.has(je)),$e=this.#t.filter(je=>!Me.includes(je));this.#t=[...Me,...$e]}return this.#v&&this.#v("state",oe),oe}move(ie,oe){const ue=this.#t.indexOf(ie);if(ue===-1)return;const ce=this.#e.get(ie);if(ce.layout.movable===!1||ce.layout.lockPosition){y(`move:${ie}`,`column "${ie}" is not movable; the move was ignored`);return}const pe=this.#T(ie,oe);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(oe,this.#t.length)),0,ie),this.#D(),this.#v&&this.#v("move",{id:ie,to:oe})}#T(ie,oe){if(!this.#n||!this.#n.length)return null;const ue=this.#t.filter($e=>$e!==ie),ce=Math.max(0,Math.min(oe,ue.length)),pe=($e,je)=>{if(Array.isArray($e.columns)){for(const ge of $e.columns)pe(ge,je);return je}const ke=$e.column?$e.column.id:$e.id;return ke&&je.push(ke),je},Me=$e=>{for(const je of $e){if(!Array.isArray(je.columns))continue;if(je.marryChildren===!0){const ge=pe(je,[]),Ee=ge.includes(ie),Ie=ge.map(ze=>ue.indexOf(ze)).filter(ze=>ze>=0);if(Ie.length){const ze=Math.min(...Ie),_e=Math.max(...Ie);if(Ee?ce<ze||ce>_e+1:ce>ze&&ce<=_e)return je.id}}const ke=Me(je.columns);if(ke)return ke}return null};return Me(this.#n)}#D(){const ie=new Map(this.#t.map((ce,pe)=>[ce,pe])),oe=ce=>{if(!Array.isArray(ce.columns)){const Me=ce.column?ce.column.id:ce.id;return ie.has(Me)?ie.get(Me):1/0}let pe=1/0;for(const Me of ce.columns)pe=Math.min(pe,oe(Me));return pe},ue=ce=>{ce.sort((pe,Me)=>oe(pe)-oe(Me));for(const pe of ce)Array.isArray(pe.columns)&&ue(pe.columns)};ue(this.#n)}#N(ie){const oe=ue=>{for(let ce=0;ce<ue.length;ce++){const pe=ue[ce];if(Array.isArray(pe.columns)){const Me=oe(pe.columns);if(Me)return Me}else if(pe.column&&pe.column.id===ie)return ue.splice(ce,1)[0]}return null};return oe(this.#n)}#I(ie){const oe=[];for(let ue=ie.length-1;ue>=0;ue--){const ce=ie[ue];Array.isArray(ce.columns)&&(oe.push(...this.#I(ce.columns)),ce.columns.length===0&&(oe.push(ce.id),ie.splice(ue,1)))}return oe}#M(){const ie=(oe,ue)=>{for(const ce of oe)Array.isArray(ce.columns)?ie(ce.columns,[...ue,ce.id]):ce.column&&(ce.column.groupPath=ue)};ie(this.#n,[])}#x(ie){const oe=new Set(ie),ue=this.#t.filter($e=>oe.has($e));if(!ue.length)return;const ce=Math.min(...ue.map($e=>this.#t.indexOf($e))),pe=this.#t.slice(0,ce).filter($e=>!oe.has($e)),Me=this.#t.slice(ce).filter($e=>!oe.has($e));this.#t=[...pe,...ue,...Me]}#W(ie){const oe=[],ue=ce=>{if(Array.isArray(ce.columns))for(const pe of ce.columns)ue(pe);else ce.column&&oe.push(ce.column.id)};return ue(ie),oe}#R(ie){const oe=ue=>{for(const ce of ue){if(!Array.isArray(ce.columns))continue;if(ce.id===ie)return{node:ce,parent:ue};const pe=oe(ce.columns);if(pe)return pe}return null};return oe(this.#n)}groupColumns(ie,oe={}){const ue=k(ie).filter(je=>this.#e.has(je));if(!ue.length)return y("columns.group.empty","groupColumns was given no known column ids; nothing was grouped."),null;for(const je of ue)if(this.#e.get(je).layout.lockPosition)return y(`columns.group.locked:${je}`,`column "${je}" is position-locked and cannot be grouped.`),null;const ce=oe.groupId?this.#R(oe.groupId):null;if(oe.groupId&&!ce)return y(`columns.group.unknown:${oe.groupId}`,`no band "${oe.groupId}" to add to; nothing was grouped.`),null;let pe=null;if(!ce&&oe.id!=null&&(pe=String(oe.id),this.#R(pe)||this.#e.has(pe)))return y(`columns.group.idtaken:${pe}`,`band id "${pe}" is already in use; nothing was grouped.`),null;const Me=ue.map(je=>this.#N(je)).filter(Boolean);if(!Me.length)return null;let $e;if(ce)ce.node.columns.push(...Me),$e=ce.node.id;else{const je={id:pe||S("grp"),title:oe.title||"",collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!1,header:{},def:{},columns:Me},ke=Number.isInteger(oe.at)?Math.max(0,Math.min(oe.at,this.#n.length)):this.#n.length;this.#n.splice(ke,0,je),$e=je.id}return this.#I(this.#n),this.#x(ue),this.#M(),this.#D(),this.#v&&this.#v("columngroup",{action:"formed",groupId:$e,ids:ue}),$e}ungroupColumn(ie){const oe=this.#e.get(ie);if(!oe){y(`columns.ungroup.unknown:${ie}`,`no column "${ie}" to ungroup.`);return}const ue=oe.groupPath||[];if(!ue.length)return;const ce=ue[ue.length-1],pe=this.#R(ce);if(!pe)return;const Me=this.#N(ie);if(!Me)return;const $e=pe.parent.indexOf(pe.node);pe.parent.splice($e+1,0,Me);const je=this.#I(this.#n),ke=this.#W(pe.node);if(ke.length){this.#x(ke);const ge=Math.max(...ke.map(Ie=>this.#t.indexOf(Ie))),Ee=this.#t.filter(Ie=>Ie!==ie);Ee.splice(ge+1,0,ie),this.#t=Ee}this.#M(),this.#D(),this.#v&&this.#v("columngroup",{action:"removed",id:ie,dissolved:je})}renameGroup(ie,oe){const ue=this.#R(ie);if(!ue){y(`columns.group.rename:${ie}`,`no band "${ie}" to rename.`);return}ue.node.title=String(oe??""),this.#v&&this.#v("columngroup",{action:"renamed",groupId:ie,title:ue.node.title})}dissolveGroup(ie){const oe=this.#R(ie);if(!oe){y(`columns.group.dissolve:${ie}`,`no band "${ie}" to dissolve.`);return}const ue=oe.parent.indexOf(oe.node);oe.parent.splice(ue,1,...oe.node.columns),this.#M(),this.#D(),this.#v&&this.#v("columngroup",{action:"dissolved",groupId:ie})}moveGroup(ie,oe){const ue=this.#R(ie);if(!ue){y(`columns.group.move:${ie}`,`no band "${ie}" to move.`);return}const ce=ue.parent,pe=ce.indexOf(ue.node);pe!==-1&&(ce.splice(pe,1),ce.splice(Math.max(0,Math.min(oe,ce.length)),0,ue.node),this.#_(),this.#M(),this.#v&&this.#v("columngroup",{action:"moved",groupId:ie,to:oe}))}#_(){const ie=[],oe=ce=>{for(const pe of ce)Array.isArray(pe.columns)?oe(pe.columns):pe.column&&ie.push(pe.column.id)};oe(this.#n);const ue=new Set(ie);this.#t=[...ie,...this.#t.filter(ce=>!ue.has(ce))]}groupTree(){const ie=ue=>ue.map(ce=>Array.isArray(ce.columns)?{id:ce.id,title:ce.title||"",collapsible:!!ce.collapsible,openByDefault:ce.openByDefault!==!1,columns:ie(ce.columns)}:ce.column?ce.column.id:null).filter(ce=>ce!==null),oe=ie(this.#n);return oe.some(ue=>ue&&typeof ue=="object")?oe:[]}applyGroupTree(ie){if(!Array.isArray(ie))return;const oe=new Set,ue=pe=>{const Me=[];for(const $e of pe)if($e&&typeof $e=="object"&&Array.isArray($e.columns)){const je=ue($e.columns);if(!je.length)continue;Me.push({id:$e.id||S("grp"),title:$e.title||"",collapsible:$e.collapsible===!0,openByDefault:$e.openByDefault!==!1,showWhen:"always",marryChildren:!1,header:{},def:{},columns:je})}else if(typeof $e=="string"){const je=this.#e.get($e);je&&!oe.has($e)&&(oe.add($e),Me.push({column:je,path:[]}))}return Me},ce=ue(ie);for(const pe of this.#t){if(oe.has(pe))continue;const Me=this.#e.get(pe);Me&&ce.push({column:Me,path:[]})}this.#n=ce,this.#M(),this.#D(),this.#v&&this.#v("columngroup",{action:"applied"})}show(ie){this.#B(ie,!1)}hide(ie){this.#B(ie,!0)}#B(ie,oe){const ue=[];for(const ce of k(ie)){const pe=this.#e.get(ce);if(pe){if(oe&&pe.layout.lockVisible){y(`lockVisible:${ce}`,`column "${ce}" is \`layout.lockVisible\` and cannot be hidden`);continue}pe.layout.hidden!==oe&&(pe.layout.hidden=oe,ue.push(ce))}}ue.length&&this.#v&&this.#v("visible",{ids:ue,hidden:oe})}pin(ie,oe){const ue=this.#e.get(ie);ue&&(ue.layout.pin=oe??null,this.#v&&this.#v("pin",{id:ie,side:ue.layout.pin}))}resize(ie,oe){const ue=this.#e.get(ie);if(!ue)return;if(ue.layout.resizable===!1){y(`resize:${ie}`,`column "${ie}" is not resizable; the resize was ignored`);return}const ce=ue.layout.min??0,pe=ue.layout.max;let Me=Math.max(ce,oe);pe!=null&&(Me=Math.min(pe,Me)),ue.layout.width=Me,ue.layout.flex=0,this.#v&&this.#v("resize",{id:ie,width:Me})}}function J(de){const ie={};return de.width!=null&&(ie.width=de.width),de.hidden!=null&&(ie.hidden=de.hidden),de.pin!==void 0&&(ie.pin=de.pin),ie}function te(de){if(de===null||typeof de!="object")return de;try{return structuredClone(de)}catch{}try{return JSON.parse(JSON.stringify(de))}catch{return de}}function ee(de,ie){const oe=de??null,ue=ie??null;if(oe===ue)return!0;if(oe===null||ue===null)return!1;if(typeof oe!="object"||typeof ue!="object")return oe===ue;try{return JSON.stringify(oe)===JSON.stringify(ue)}catch{return!1}}function re(de){const ie=[],oe=(ce,pe)=>{const Me=[];for(const $e of ce){if(!V($e)){$("a column definition must be an object");continue}if(Array.isArray($e.columns)){B($e,C,"columnGroup",$e.title||$e.id||"(unnamed)");const je={id:$e.id||S("grp"),title:$e.title||"",collapsible:$e.collapsible===!0,openByDefault:$e.openByDefault!==!1,showWhen:$e.showWhen||"always",marryChildren:$e.marryChildren===!0,header:$e.header||{},def:$e,columns:[]};je.columns=oe($e.columns,[...pe,je.id]),Me.push(je)}else{const je={def:$e,path:pe};ie.push(je),Me.push(je)}}return Me},ue=oe(de,[]);return{leaves:ie,groups:ue}}function se(de,ie,oe){for(const ue of de){if(ue.columns){if(se(ue.columns,ie,oe))return!0;continue}if(ue.column&&ue.column.id===ie)return ue.column=oe,!0}return!1}}),Ce("packages/core/src/columns/autogroup.js",function(e,G){"use strict";Object.defineProperty(e,"AUTO_GROUP_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAutoGroupColumn",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"warnOnAbsurdGrouping",{enumerable:!0,get:function(){return V}});const M=G("packages/core/src/internal/util.js").warnOnce,$="__lattice_group",R=240,W=.5;function Z(U){const{columns:D,groupBy:I}=U,k=I.map(d=>D.get(d)).filter(Boolean),S=k.length?k.map(d=>d.title||d.id).join(" > "):"Group",y=U.config&&U.config.autoGroupColumnWidth||R;return{id:$,field:null,title:S,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!0},groupedIds:I.slice(),group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:y,min:120,pin:U.config&&U.config.autoGroupColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(d,u){return u&&u.group?u.groupValue:null},formatValue(d,u){if(!u||!u.group)return"";if(u.grandTotal)return U.config&&U.config.grandTotalLabel||"Total";const n=k[Math.min(u.level||0,k.length-1)];return n&&typeof n.formatValue=="function"?n.formatValue(d,u):d==null?"":String(d)}}}function V(U,D,I){!U.length||I<100||D<I*W||M(`grouping.cardinality:${U.join(",")}`,`grouping by ${U.join(", ")} produced ${D} groups for ${I} rows: nearly one group per row. Grouping a continuous value such as a percentage or a timestamp rarely reads usefully; consider a computed banding column.`)}}),Ce("packages/core/src/columns/selectcolumn.js",function(e,G){"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 R}});const _="__lattice_select",M=44;function $(W){const Z=W.selection||{},V=W.config&&W.config.selectionColumnWidth||M;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:V,min:V,max:V,pin:W.config&&W.config.selectionColumnPin||"start",hidden:!1,resizable:!1,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,headerCheckbox:Z.headerCheckbox===!0,def:{},getValue(U,D){return D?D.selected:!1},formatValue(){return""}}}const R=$}),Ce("packages/core/src/columns/rownumbercolumn.js",function(e,G){"use strict";Object.defineProperty(e,"ROW_NUMBER_COLUMN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createRowNumberColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const M=G("packages/core/src/internal/util.js").isFunction,$="__lattice_rownumber",R=40,W=9,Z=22;function V(I){const k=String(Math.max(1,Math.trunc(Math.abs(I))||1)).length;return Math.max(R,k*W+Z)}function U(I){const k=I.rowNumbers,S=k&&typeof k=="object"?k:{},y=Number.isFinite(S.start)?S.start:1,d=Number.isFinite(S.width)?S.width:V((I.maxNumber||0)+y),u=M(I.rank)?I.rank:()=>null;return{id:$,field:null,title:typeof S.title=="string"?S.title:"",type:"number",dataType:{base:"number"},nullable:!0,align:"end",generated:!0,control:!0,value:{pure:!0},cell:{align:"end"},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:d,min:d,max:d,pin:"start",hidden:!1,resizable:S.width==null,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(n,t){const i=u(t);return i==null?null:i-1+y},formatValue(n){return n==null?"":String(n)}}}const D=U}),Ce("packages/core/src/model/detail.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_DETAIL_HEIGHT",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"DEFAULT_CACHE_LIMIT",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveDetail",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DetailModel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,R=240,W=10;function Z(D){if(!D)return null;const I=D===!0?{}:D;return I.enabled===!1?null:!M(I.rows)&&!I.render?($("detail.rows","detail is enabled but neither `rows` nor `render` was supplied; expanding a master would show an empty region, so it stays off."),null):{render:I.render||null,config:I.config||null,rows:M(I.rows)?I.rows:null,height:I.height??R,cacheLimit:Number.isFinite(I.cacheLimit)?Math.max(0,I.cacheLimit):W,isMaster:M(I.isMaster)?I.isMaster:null,target:I.target||null,onCreate:M(I.onCreate)?I.onCreate:null,path:typeof I.path=="string"?I.path:null}}class V{#e;#t=new Set;#n;#r=0;constructor(I){this.#e=I.config,this.#n=M(I.onChange)?I.onChange:()=>{}}get config(){return this.#e}get inline(){return!this.#e.target}isMaster(I){if(!I||I.group||I.detail)return!1;const k=this.#e.isMaster;return k?!!k(I.data,I):!0}isOpen(I){return this.#t.has(I)}keys(){return[...this.#t]}activeKey(){for(const I of this.#t)return I;return null}heightOf(I){const k=this.#e.height;return M(k)?Number(k(I))||R:k==="auto"?R:Number(k)||R}open(I){return this.#t.has(I)?!1:(this.inline||this.#t.clear(),this.#t.add(I),this.#o(),!0)}close(I){return this.#t.delete(I)?(this.#o(),!0):!1}toggle(I){return this.#t.has(I)?(this.close(I),!1):(this.open(I),!0)}closeAll(){this.#t.size&&(this.#t.clear(),this.#o())}prune(I){if(!this.#t.size||!M(I))return;let k=!1;for(const S of[...this.#t])I(S)||(this.#t.delete(S),k=!0);k&&this.#o()}signature(){return`${this.#r}`}set(I){this.#t.clear();const k=Array.isArray(I)?I:[];for(const S of this.inline?k:k.slice(0,1))this.#t.add(S);this.#o()}#o(){this.#r++,this.#n()}}const U=V}),Ce("packages/core/src/compute/special.js",function(e,G){"use strict";Object.defineProperty(e,"logGamma",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"incompleteBeta",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"normalQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"normalCdf",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"studentT",{enumerable:!0,get:function(){return I}}),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 u}}),Object.defineProperty(e,"chiSquareUpperTail",{enumerable:!0,get:function(){return n}});const _=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),M=3e-12,$=1e-300;function R(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-R(1-t);const i=t-1;let s=.9999999999998099;const r=i+7.5;for(let o=0;o<_.length;o++)s+=_[o]/(i+o+1);return .5*Math.log(2*Math.PI)+(i+.5)*Math.log(r)-r+Math.log(s)}function W(t,i,s){const r=t+i,o=t+1,l=t-1;let a=1,p=1-r*s/o;Math.abs(p)<$&&(p=$),p=1/p;let m=p;for(let b=1;b<=300;b++){const g=2*b;let f=b*(i-b)*s/((l+g)*(t+g));p=1+f*p,Math.abs(p)<$&&(p=$),a=1+f/a,Math.abs(a)<$&&(a=$),p=1/p,m*=p*a,f=-(t+b)*(r+b)*s/((t+g)*(o+g)),p=1+f*p,Math.abs(p)<$&&(p=$),a=1+f/a,Math.abs(a)<$&&(a=$),p=1/p;const w=p*a;if(m*=w,Math.abs(w-1)<M)break}return m}function Z(t,i,s){if(!(t>0)||!(i>0)||!Number.isFinite(s))return Number.NaN;if(s<=0)return 0;if(s>=1)return 1;const r=Math.exp(R(t+i)-R(t)-R(i)+t*Math.log(s)+i*Math.log(1-s));return s<(t+1)/(t+i+2)?r*W(t,i,s)/t:1-r*W(i,t,1-s)/i}function V(t){if(!(t>0)||!(t<1))return t===0?-1/0:t===1?1/0:Number.NaN;const i=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],s=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],r=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],o=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],l=.02425;let a,p,m;t<l?(a=Math.sqrt(-2*Math.log(t)),m=(((((r[0]*a+r[1])*a+r[2])*a+r[3])*a+r[4])*a+r[5])/((((o[0]*a+o[1])*a+o[2])*a+o[3])*a+1)):t<=1-l?(a=t-.5,p=a*a,m=(((((i[0]*p+i[1])*p+i[2])*p+i[3])*p+i[4])*p+i[5])*a/(((((s[0]*p+s[1])*p+s[2])*p+s[3])*p+s[4])*p+1)):(a=Math.sqrt(-2*Math.log(1-t)),m=-(((((r[0]*a+r[1])*a+r[2])*a+r[3])*a+r[4])*a+r[5])/((((o[0]*a+o[1])*a+o[2])*a+o[3])*a+1));const g=(.5*U(-m/Math.SQRT2)-t)*Math.sqrt(2*Math.PI)*Math.exp(m*m/2);return m-g/(1+m*g/2)}function U(t){const i=Math.abs(t),s=2/(2+i),r=4*s-2,o=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let l=0,a=0,p;for(let b=o.length-1;b>0;b--)p=a,a=r*a-l+o[b],l=p;const m=s*Math.exp(-i*i+.5*(o[0]+r*a)-l);return t>=0?m:2-m}function D(t){return .5*U(-t/Math.SQRT2)}function I(t,i){if(!(i>0)||!Number.isFinite(t))return Number.NaN;const s=.5*Z(i/2,.5,i/(i+t*t));return t>0?1-s:s}function k(t,i){if(!(t>0)||!(t<1)||!(i>0))return Number.NaN;if(i>1e7)return V(t);let s=-1e4,r=1e4,o=V(t);const l=R(i/2)+R(.5)-R((i+1)/2);for(let a=0;a<60;a++){const p=I(o,i);p<t?s=o:r=o;const m=Math.exp(-((i+1)/2)*Math.log(1+o*o/i)-l)/Math.sqrt(i),b=m>0?(p-t)/m:0;if(Math.abs(b)<1e-12)break;const g=o-b;if(o=g>s&&g<r&&Number.isFinite(g)?g:(s+r)/2,r-s<1e-12)break}return o}function S(t,i){let s=t,r=1/t,o=r;for(let l=0;l<300&&(s+=1,o*=i/s,r+=o,!(Math.abs(o)<Math.abs(r)*M));l++);return r*Math.exp(-i+t*Math.log(i)-R(t))}function y(t,i){let s=i+1-t,r=1/$,o=1/s,l=o;for(let a=1;a<=300;a++){const p=-a*(a-t);s+=2,o=p*o+s,Math.abs(o)<$&&(o=$),r=s+p/r,Math.abs(r)<$&&(r=$),o=1/o;const m=o*r;if(l*=m,Math.abs(m-1)<M)break}return Math.exp(-i+t*Math.log(i)-R(t))*l}function d(t,i){return!(t>0)||!(i>=0)||!Number.isFinite(i)?Number.NaN:i===0?0:i<t+1?S(t,i):1-y(t,i)}function u(t,i){return i>0?d(i/2,t/2):Number.NaN}function n(t,i){const s=u(t,i);return Number.isNaN(s)?Number.NaN:Math.min(1,Math.max(0,1-s))}}),Ce("packages/core/src/compute/linalg.js",function(e,G){"use strict";Object.defineProperty(e,"cholesky",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"choleskySolve",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"choleskyInverse",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"normalEquations",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"matVec",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"quadForm",{enumerable:!0,get:function(){return Z}});function _(V){const U=V.length,D=Array.from({length:U},()=>new Array(U).fill(0));for(let I=0;I<U;I++)for(let k=0;k<=I;k++){let S=V[I][k];for(let y=0;y<k;y++)S-=D[I][y]*D[k][y];if(I===k){if(!(S>0))return null;D[I][k]=Math.sqrt(S)}else D[I][k]=S/D[k][k]}return D}function M(V,U){const D=V.length,I=new Array(D).fill(0);for(let S=0;S<D;S++){let y=U[S];for(let d=0;d<S;d++)y-=V[S][d]*I[d];I[S]=y/V[S][S]}const k=new Array(D).fill(0);for(let S=D-1;S>=0;S--){let y=I[S];for(let d=S+1;d<D;d++)y-=V[d][S]*k[d];k[S]=y/V[S][S]}return k}function $(V){const U=V.length,D=Array.from({length:U},()=>new Array(U).fill(0));for(let I=0;I<U;I++){const k=new Array(U).fill(0);k[I]=1;const S=M(V,k);for(let y=0;y<U;y++)D[y][I]=S[y]}return D}function R(V,U,D){const I=V.length,k=I?V[0].length:0,S=Array.from({length:k},()=>new Array(k).fill(0)),y=new Array(k).fill(0);for(let d=0;d<I;d++){const u=D?D[d]:1,n=V[d];for(let t=0;t<k;t++){const i=u*n[t];y[t]+=i*U[d];for(let s=t;s<k;s++)S[t][s]+=i*n[s]}}for(let d=0;d<k;d++)for(let u=0;u<d;u++)S[d][u]=S[u][d];return{xtwx:S,xtwy:y}}function W(V,U){return V.map(D=>D.reduce((I,k,S)=>I+k*U[S],0))}function Z(V,U){let D=0;for(let I=0;I<V.length;I++){let k=0;for(let S=0;S<V.length;S++)k+=U[I][S]*V[S];D+=V[I]*k}return D}}),Ce("packages/core/src/compute/sketch.js",function(e,G){"use strict";Object.defineProperty(e,"Welford",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"Reservoir",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"hash32",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"HyperLogLog",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"SpaceSaving",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"KLL",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});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 u=d-this.#t;this.#t+=u/this.#e,this.#n+=u*(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 u=this.#e+d.#e,n=d.#t-this.#t;this.#t+=n*(d.#e/u),this.#n+=d.#n+n*n*(this.#e*d.#e/u),this.#e=u}mean(){return this.#e?this.#t:null}variance(){return this.#e>1?this.#n/(this.#e-1):null}varianceP(){return this.#e?this.#n/this.#e:null}stddev(){const d=this.variance();return d===null?null:Math.sqrt(d)}stddevP(){const d=this.varianceP();return d===null?null:Math.sqrt(d)}}class M{#e=[];#t=0;#n;#r;constructor(d,u=Math.random){if(!(d>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(d),this.#r=u}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#t}get size(){return this.#e.length}add(d){if(!Number.isFinite(d))return;if(this.#t++,this.#e.length<this.#n){this.#e.push(d);return}const u=Math.floor(this.#r()*this.#t);u<this.#n&&(this.#e[u]=d)}sample(){return this.#e.slice()}mean(){if(!this.#e.length)return null;let d=0;for(const u of this.#e)d+=u;return d/this.#e.length}quantile(d){const u=this.#e.length;if(!u)return null;const n=this.#e.slice().sort((r,o)=>r-o);if(u===1)return n[0];const t=(u-1)*Math.min(1,Math.max(0,d)),i=Math.floor(t),s=Math.ceil(t);return i===s?n[i]:n[i]+(t-i)*(n[s]-n[i])}}function $(y){return y^=y>>>16,y=Math.imul(y,2246822507),y^=y>>>13,y=Math.imul(y,3266489909),y^=y>>>15,y>>>0}function R(y){if(typeof y=="number"){const n=new DataView(new ArrayBuffer(8));return n.setFloat64(0,y===0?0:y),$(n.getUint32(0)^n.getUint32(4))}const d=typeof y=="string"?y:String(y);let u=2166136261;for(let n=0;n<d.length;n++)u^=d.charCodeAt(n),u=Math.imul(u,16777619);return $(u)}class W{#e;#t;#n;constructor(d=14){const u=Math.floor(d);if(u<4||u>16)throw new RangeError("HLL precision must be 4..16");this.#e=u,this.#t=1<<u,this.#n=new Uint8Array(this.#t)}static errorBoundFor(d=14){const u=1<<Math.floor(d),n=1.04/Math.sqrt(u);return Object.freeze({kind:"probabilistic",metric:"relative",value:n,statement:`distinct count within ~${(n*100).toFixed(2)}% relative standard error (m=${u} buckets)`})}errorBound(){return W.errorBoundFor(this.#e)}add(d){const u=R(d),n=u&this.#t-1,t=u>>>this.#e|1<<32-this.#e;let i=1,s=t;for(;(s&1)===0;)i++,s>>>=1;i>this.#n[n]&&(this.#n[n]=i)}count(){const d=this.#t,u=32-this.#e,n=new Float64Array(u+2);for(let s=0;s<d;s++)n[this.#n[s]]++;let t=d*U(1-n[u+1]/d);for(let s=u;s>=1;s--)t=.5*(t+n[s]);t+=d*V(n[0]/d);const i=Z*d*d/t;return Math.round(i)}}const Z=.5/Math.log(2);function V(y){if(y===1)return 1/0;let d=1,u=y,n;do y*=y,n=u,u+=y*d,d+=d;while(u!==n);return u}function U(y){if(y===0||y===1)return 0;let d=1,u=1-y,n;do y=Math.sqrt(y),n=u,d*=.5,u-=(1-y)**2*d;while(u!==n);return u/3}class D{#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 u=d/this.#t;return Object.freeze({kind:"deterministic",metric:"absolute",value:u,statement:`each count overestimates the truth by at most N/m = ${u.toFixed(2)} (N=${d}, m=${this.#t})`})}get seen(){return this.#n}add(d){this.#n++;const u=this.#e.get(d);if(u){u.count++;return}if(this.#e.size<this.#t){this.#e.set(d,{count:1,error:0});return}let n,t=1/0;for(const[i,s]of this.#e)s.count<t&&(t=s.count,n=i);this.#e.delete(n),this.#e.set(d,{count:t+1,error:t})}top(d=this.#t){return[...this.#e.entries()].map(([n,t])=>({item:n,count:t.count,error:t.error})).sort((n,t)=>t.count-n.count).slice(0,Math.max(0,Math.floor(d)))}}class I{#e;#t=[[]];#n=0;#r;#o;constructor(d=200,u=Math.random){this.#e=Math.max(8,Math.floor(d)),this.#r=u,this.#o=2/3}static errorBoundFor(d=200){const u=1/Math.max(8,Math.floor(d));return Object.freeze({kind:"probabilistic",metric:"rank",value:u,statement:`queried quantile's true rank within ~${(u*100).toFixed(2)}% of N of the requested rank (k=${d})`})}errorBound(){return I.errorBoundFor(this.#e)}get count(){return this.#n}#i(d){const n=this.#t.length-1-d,t=Math.ceil(this.#e*this.#o**n);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.#s(0))}#s(d){const u=this.#t[d];u.sort((i,s)=>i-s),d+1>=this.#t.length&&this.#t.push([]);const n=this.#t[d+1],t=this.#r()<.5?0:1;for(let i=t;i<u.length;i+=2)n.push(u[i]);this.#t[d]=[];for(let i=0;i<this.#t.length;i++)if(this.#t[i].length>=this.#i(i)){this.#s(i);return}}#l(){const d=[];for(let u=0;u<this.#t.length;u++){const n=1<<u;for(const t of this.#t[u])d.push({v:t,w:n})}return d}quantile(d){const u=this.#l();if(!u.length)return null;u.sort((s,r)=>s.v-r.v);let n=0;for(const s of u)n+=s.w;const t=Math.min(1,Math.max(0,d))*n;let i=0;for(const s of u)if(i+=s.w,i>=t)return s.v;return u[u.length-1].v}rank(d){let u=0;for(let n=0;n<this.#t.length;n++){const t=1<<n;for(const i of this.#t[n])i<=d&&(u+=t)}return u}}const k=Object.freeze({distinct:W.errorBoundFor(14),median:I.errorBoundFor(200),p25:I.errorBoundFor(200),p75:I.errorBoundFor(200),p90:I.errorBoundFor(200),p95:I.errorBoundFor(200),p99:I.errorBoundFor(200),iqr:I.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),S={Welford:_,Reservoir:M,HyperLogLog:W,SpaceSaving:D,KLL:I,hash32:R,SKETCH_BOUNDS:k}}),Ce("packages/core/src/compute/statistics.js",function(e,G){"use strict";Object.defineProperty(e,"KENDALL_LIMIT",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"numbers",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"frequencies",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"herfindahl",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"entropy",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"evenness",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"topShare",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"gini",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"moments",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"quantileSorted",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"quantile",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"STAT_FNS",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"STAT_LABELS",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"weightedAverage",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"extremeRow",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"correlation",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"trimmedMean",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"winsorizedMean",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"modifiedZOutliers",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"jarqueBera",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"weightedQuantile",{enumerable:!0,get:function(){return F}}),Object.defineProperty(e,"pairs",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"covariance",{enumerable:!0,get:function(){return B}}),Object.defineProperty(e,"regression",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"fitLinearModel",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(e,"augmentedDickeyFuller",{enumerable:!0,get:function(){return $e}}),Object.defineProperty(e,"autocorrelations",{enumerable:!0,get:function(){return je}}),Object.defineProperty(e,"spearman",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(e,"kendall",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(e,"seriesStats",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(e,"D2_N2",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(e,"D4_N2",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(e,"movingRanges",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(e,"withinSigma",{enumerable:!0,get:function(){return Qe}}),Object.defineProperty(e,"capability",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(e,"controlLimits",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(e,"westernElectricViolations",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(e,"nelsonViolations",{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(e,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return Xe}}),Object.defineProperty(e,"controlViolations",{enumerable:!0,get:function(){return st}}),Object.defineProperty(e,"countOutside",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(e,"histogram",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(e,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return At}}),Object.defineProperty(e,"meanInterval",{enumerable:!0,get:function(){return It}}),Object.defineProperty(e,"proportionInterval",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(e,"slopeInterval",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(e,"capabilityInterval",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(e,"standardizedMeanDifference",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(e,"normalTotalVariation",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(e,"frequencyMap",{enumerable:!0,get:function(){return be}}),Object.defineProperty(e,"categoricalDistance",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(e,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return We}}),Object.defineProperty(e,"compareColumn",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(e,"isNumericColumn",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(e,"populationRead",{enumerable:!0,get:function(){return gt}});const _=G("packages/core/src/compute/handle.js"),M=_.presenceReader,$=_.valueReader,R=G("packages/core/src/compute/special.js"),W=R.studentTQuantile,Z=R.studentT,V=R.normalQuantile,U=R.normalCdf,D=R.chiSquareUpperTail,I=G("packages/core/src/compute/linalg.js"),k=I.cholesky,S=I.choleskySolve,y=I.choleskyInverse,d=I.normalEquations,u=I.quadForm,t=G("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,i=5e3,s=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),r=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:t.distinct}),median:Object.freeze({sketch:"KLL",bound:t.median}),p25:Object.freeze({sketch:"KLL",bound:t.p25}),p75:Object.freeze({sketch:"KLL",bound:t.p75}),p90:Object.freeze({sketch:"KLL",bound:t.p90}),p95:Object.freeze({sketch:"KLL",bound:t.p95}),p99:Object.freeze({sketch:"KLL",bound:t.p99}),iqr:Object.freeze({sketch:"KLL",bound:t.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:t.topK})});function o(me){const Oe=me==="sum"||me==="avg"||me==="countValues"||me==="min"||me==="max"?"maintained":Object.prototype.hasOwnProperty.call(s,me)?s[me]:null,we=Object.prototype.hasOwnProperty.call(r,me)?r[me]:null;return{stat:me,exact:Oe,approximate:we}}function l(me,Oe){const we=Oe.length,Ne=new Float64Array(we);let he=0;if(me&&(me.kind==="float64"||me.kind==="int32")){const Pe=me.values,Re=M(me);for(let Ue=0;Ue<we;Ue++){const qe=Oe[Ue];if(Re&&Re(qe)!==1)continue;const ft=Pe[qe];Number.isNaN(ft)||(Ne[he++]=ft)}return Ne.subarray(0,he)}const Te=$(me);for(let Pe=0;Pe<we;Pe++){const Re=Te(Oe[Pe]);if(Re==null||Re==="")continue;const Ue=typeof Re=="number"?Re:Number(Re);Number.isFinite(Ue)&&(Ne[he++]=Ue)}return Ne.subarray(0,he)}function a(me,Oe){const we=new Map,Ne=$(me);let he=0;for(let Te=0;Te<Oe.length;Te++){const Pe=Ne(Oe[Te]);if(Pe==null||Pe===""||typeof Pe=="number"&&Number.isNaN(Pe))continue;const Re=typeof Pe=="object"?String(Pe):Pe;we.set(Re,(we.get(Re)||0)+1),he++}const ve=[...we.values()].sort((Te,Pe)=>Pe-Te);return{counts:ve,total:he,distinct:ve.length}}function p(me){return me.total>0?me.counts.map(Oe=>Oe/me.total):[]}function m(me,Oe){const we=a(me,Oe);if(!we.total)return null;let Ne=0;for(const he of p(we))Ne+=he*he;return Ne}function b(me,Oe){const we=a(me,Oe);if(!we.total)return null;let Ne=0;for(const he of p(we))he>0&&(Ne-=he*Math.log2(he));return Ne}function g(me,Oe){const we=a(me,Oe);if(!we.total||we.distinct<2)return we.total?1:null;let Ne=0;for(const he of p(we))he>0&&(Ne-=he*Math.log2(he));return Ne/Math.log2(we.distinct)}function f(me,Oe,we=3){const Ne=a(me,Oe);if(!Ne.total)return null;const he=Math.max(1,Math.floor(we));let ve=0;for(let Te=0;Te<Math.min(he,Ne.counts.length);Te++)ve+=Ne.counts[Te];return ve/Ne.total}function w(me,Oe){const we=l(me,Oe),Ne=we.length;if(!Ne)return null;const he=we.slice().sort();if(he[0]<0)return null;let ve=0,Te=0;for(let Pe=0;Pe<Ne;Pe++)ve+=he[Pe],Te+=(Pe+1)*he[Pe];return ve===0?0:2*Te/(Ne*ve)-(Ne+1)/Ne}function v(me){let Oe=0,we=0,Ne=0;for(let he=0;he<me.length;he++){const ve=me[he];Oe++;const Te=ve-we;we+=Te/Oe,Ne+=Te*(ve-we)}return{n:Oe,mean:we,m2:Ne}}function h(me,Oe){const we=me.length;if(!we)return NaN;if(we===1)return me[0];const Ne=(we-1)*Math.min(1,Math.max(0,Oe)),he=Math.floor(Ne),ve=Math.ceil(Ne);return he===ve?me[he]:me[he]+(Ne-he)*(me[ve]-me[he])}function c(me,Oe){if(!me.length)return NaN;const we=me.slice().sort();return h(we,Oe)}function j(me,Oe){const we=$(me);let Ne=0,he=0,ve=0;for(let Te=0;Te<Oe.length;Te++){const Pe=we(Oe[Te]);if(Pe==null||Pe==="")continue;const Re=String(Pe).toUpperCase();Re==="PASS"?Ne++:Re==="FAIL"?he++:Re==="WARN"&&ve++}return{pass:Ne+ve,fail:he,warn:ve,judged:Ne+ve+he}}const E=Object.freeze({hhi:(me,Oe)=>m(me,Oe),entropy:(me,Oe)=>b(me,Oe),evenness:(me,Oe)=>g(me,Oe),top3Share:(me,Oe)=>f(me,Oe,3),top10Share:(me,Oe)=>f(me,Oe,10),gini:(me,Oe)=>w(me,Oe),trimmedMean:(me,Oe)=>L(l(me,Oe),.1),winsorizedMean:(me,Oe)=>z(l(me,Oe),.1),robustOutliers:(me,Oe)=>H(l(me,Oe),3.5),jarqueBera:(me,Oe)=>x(l(me,Oe)),variance:(me,Oe)=>{const{n:we,m2:Ne}=v(l(me,Oe));return we>1?Ne/(we-1):null},varianceP:(me,Oe)=>{const{n:we,m2:Ne}=v(l(me,Oe));return we>0?Ne/we:null},stddev:(me,Oe)=>{const{n:we,m2:Ne}=v(l(me,Oe));return we>1?Math.sqrt(Ne/(we-1)):null},stddevP:(me,Oe)=>{const{n:we,m2:Ne}=v(l(me,Oe));return we>0?Math.sqrt(Ne/we):null},median:(me,Oe)=>{const we=l(me,Oe);return we.length?c(we,.5):null},p25:(me,Oe)=>{const we=l(me,Oe);return we.length?c(we,.25):null},p75:(me,Oe)=>{const we=l(me,Oe);return we.length?c(we,.75):null},p90:(me,Oe)=>{const we=l(me,Oe);return we.length?c(we,.9):null},p95:(me,Oe)=>{const we=l(me,Oe);return we.length?c(we,.95):null},p99:(me,Oe)=>{const we=l(me,Oe);return we.length?c(we,.99):null},iqr:(me,Oe)=>{const we=l(me,Oe);if(!we.length)return null;const Ne=we.slice().sort();return h(Ne,.75)-h(Ne,.25)},mad:(me,Oe)=>{const we=l(me,Oe);if(!we.length)return null;const Ne=c(we,.5),he=new Float64Array(we.length);for(let ve=0;ve<we.length;ve++)he[ve]=Math.abs(we[ve]-Ne);return c(he,.5)},range:(me,Oe)=>{const we=l(me,Oe);if(!we.length)return null;let Ne=1/0,he=-1/0;for(let ve=0;ve<we.length;ve++)we[ve]<Ne&&(Ne=we[ve]),we[ve]>he&&(he=we[ve]);return he-Ne},distinct:(me,Oe)=>{const we=$(me),Ne=new Set;for(let he=0;he<Oe.length;he++){const ve=we(Oe[he]);ve==null||ve===""||Ne.add(ve instanceof Date?ve.getTime():ve)}return Ne.size},mode:(me,Oe)=>{const we=$(me),Ne=new Map;for(let Te=0;Te<Oe.length;Te++){const Pe=we(Oe[Te]);if(Pe==null||Pe==="")continue;const Re=Pe instanceof Date?Pe.getTime():Pe;Ne.set(Re,(Ne.get(Re)||0)+1)}let he=null,ve=1;for(const[Te,Pe]of Ne)Pe>ve&&(ve=Pe,he=Te);return he},skewness:(me,Oe)=>{const we=l(me,Oe),{n:Ne,mean:he,m2:ve}=v(we);if(Ne<3||ve<=0)return null;const Te=Math.sqrt(ve/(Ne-1));let Pe=0;for(let Re=0;Re<we.length;Re++)Pe+=((we[Re]-he)/Te)**3;return Ne/((Ne-1)*(Ne-2))*Pe},kurtosis:(me,Oe)=>{const we=l(me,Oe),{n:Ne,mean:he,m2:ve}=v(we);if(Ne<4||ve<=0)return null;const Te=Math.sqrt(ve/(Ne-1));let Pe=0;for(let qe=0;qe<we.length;qe++)Pe+=((we[qe]-he)/Te)**4;const Re=Ne*(Ne+1)/((Ne-1)*(Ne-2)*(Ne-3)),Ue=3*(Ne-1)**2/((Ne-2)*(Ne-3));return Re*Pe-Ue},geomean:(me,Oe)=>{const we=l(me,Oe);if(!we.length)return null;let Ne=0;for(let he=0;he<we.length;he++){if(we[he]<=0)return null;Ne+=Math.log(we[he])}return Math.exp(Ne/we.length)},harmean:(me,Oe)=>{const we=l(me,Oe);if(!we.length)return null;let Ne=0;for(let he=0;he<we.length;he++){if(we[he]===0)return null;Ne+=1/we[he]}return we.length/Ne},sumSquares:(me,Oe)=>{const we=l(me,Oe);let Ne=0;for(let he=0;he<we.length;he++)Ne+=we[he]*we[he];return Ne},passRate:(me,Oe)=>{const{pass:we,judged:Ne}=j(me,Oe);return Ne?we/Ne:null},failureCount:(me,Oe)=>j(me,Oe).fail}),O=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function T(me,Oe,we){const Ne=$(me),he=$(Oe);let ve=0,Te=0;for(let Pe=0;Pe<we.length;Pe++){const Re=we[Pe],Ue=Number(Ne(Re)),qe=Number(he(Re));!Number.isFinite(Ue)||!Number.isFinite(qe)||(ve+=Ue*qe,Te+=qe)}return Te===0?null:ve/Te}function A(me,Oe,we){const Ne=$(me);let he=null,ve=we?-1/0:1/0;for(let Te=0;Te<Oe.length;Te++){const Pe=Oe[Te],Re=Number(Ne(Pe));Number.isFinite(Re)&&(we?Re>ve:Re<ve)&&(ve=Re,he=Pe)}return he}function P(me,Oe,we){const Ne=$(me),he=$(Oe);let ve=0,Te=0,Pe=0,Re=0,Ue=0,qe=0;for(let ct=0;ct<we.length;ct++){const vt=we[ct],St=Number(Ne(vt)),Le=Number(he(vt));!Number.isFinite(St)||!Number.isFinite(Le)||(ve++,Te+=St,Pe+=Le,Re+=St*St,Ue+=Le*Le,qe+=St*Le)}if(ve<2)return null;const ft=ve*qe-Te*Pe,at=Math.sqrt((ve*Re-Te*Te)*(ve*Ue-Pe*Pe));if(at===0)return null;const mt=ft/at;return Math.max(-1,Math.min(1,mt))}function L(me,Oe=.1){const we=me.length;if(!we)return null;const Ne=Array.from(me).sort((Pe,Re)=>Pe-Re),he=Math.floor(we*Math.min(.49,Math.max(0,Oe))),ve=Ne.slice(he,we-he);if(!ve.length)return h(Ne,.5);let Te=0;for(const Pe of ve)Te+=Pe;return Te/ve.length}function z(me,Oe=.1){const we=me.length;if(!we)return null;const Ne=Array.from(me).sort((Re,Ue)=>Re-Ue),he=Math.floor(we*Math.min(.49,Math.max(0,Oe))),ve=Ne[he],Te=Ne[we-1-he];let Pe=0;for(const Re of Ne)Pe+=Math.min(Te,Math.max(ve,Re));return Pe/we}function H(me,Oe=3.5){if(!me.length)return null;const Ne=Array.from(me).sort((Re,Ue)=>Re-Ue),he=h(Ne,.5),ve=Ne.map(Re=>Math.abs(Re-he)).sort((Re,Ue)=>Re-Ue),Te=h(ve,.5);if(Te===0)return null;let Pe=0;for(const Re of Ne)Math.abs(.6745*(Re-he)/Te)>Oe&&Pe++;return Pe}function x(me){const Oe=me.length;if(Oe<8)return null;let we=0;for(const Re of me)we+=Re;we/=Oe;let Ne=0,he=0,ve=0;for(const Re of me){const Ue=Re-we;Ne+=Ue*Ue,he+=Ue*Ue*Ue,ve+=Ue*Ue*Ue*Ue}if(Ne/=Oe,he/=Oe,ve/=Oe,Ne===0)return null;const Te=he/Ne**1.5,Pe=ve/(Ne*Ne)-3;return Oe/6*(Te*Te+Pe*Pe/4)}function F(me,Oe,we){const Ne=[];let he=0;for(let Re=0;Re<me.length;Re++){const Ue=Number(me[Re]),qe=Number(Oe[Re]);!Number.isFinite(Ue)||!Number.isFinite(qe)||qe<=0||(Ne.push([Ue,qe]),he+=qe)}if(!Ne.length||he<=0)return null;if(Ne.sort((Re,Ue)=>Re[0]-Ue[0]),Ne.length===1)return Ne[0][0];const ve=[];let Te=0;for(const[,Re]of Ne)ve.push((Te+Re/2)/he),Te+=Re;const Pe=Math.max(0,Math.min(1,we));if(Pe<=ve[0])return Ne[0][0];if(Pe>=ve[ve.length-1])return Ne[Ne.length-1][0];for(let Re=1;Re<ve.length;Re++){if(Pe>ve[Re])continue;const Ue=ve[Re]-ve[Re-1],qe=Ue>0?(Pe-ve[Re-1])/Ue:0;return Ne[Re-1][0]+(Ne[Re][0]-Ne[Re-1][0])*qe}return Ne[Ne.length-1][0]}function C(me,Oe,we){const Ne=$(me),he=$(Oe),ve=new Float64Array(we.length),Te=new Float64Array(we.length);let Pe=0;for(let Re=0;Re<we.length;Re++){const Ue=we[Re],qe=Number(Ne(Ue)),ft=Number(he(Ue));!Number.isFinite(qe)||!Number.isFinite(ft)||(ve[Pe]=qe,Te[Pe]=ft,Pe++)}return{xs:ve.subarray(0,Pe),ys:Te.subarray(0,Pe),n:Pe}}function B(me,Oe,we,Ne=!1){const{xs:he,ys:ve,n:Te}=C(me,Oe,we);if(Te<2)return null;let Pe=0,Re=0;for(let qe=0;qe<Te;qe++)Pe+=he[qe],Re+=ve[qe];Pe/=Te,Re/=Te;let Ue=0;for(let qe=0;qe<Te;qe++)Ue+=(he[qe]-Pe)*(ve[qe]-Re);return Ue/(Ne?Te:Te-1)}function q(me,Oe,we){const{xs:Ne,ys:he,n:ve}=C(me,Oe,we);if(ve<2)return null;let Te=0,Pe=0;for(let St=0;St<ve;St++)Te+=Ne[St],Pe+=he[St];Te/=ve,Pe/=ve;let Re=0,Ue=0,qe=0;for(let St=0;St<ve;St++){const Le=Ne[St]-Te,rt=he[St]-Pe;Re+=Le*Le,Ue+=Le*rt,qe+=rt*rt}if(Re===0)return null;const ft=Ue/Re,at=Pe-ft*Te,mt=qe===0?1:Math.max(0,Math.min(1,Ue*Ue/(Re*qe))),ct=Math.max(0,qe-ft*Ue),vt=ve>2?Math.sqrt(ct/(ve-2)/Re):0;return{slope:ft,intercept:at,r2:mt,stdError:vt,n:ve}}const Q=new Set(["ols","wls","robust"]),Y=new Set(["quantile"]),J=new Set(["ridge","lasso","elasticnet","mixed","gls"]),te=1.345;function ee(me,Oe,we){const{xtwx:Ne,xtwy:he}=d(me,Oe,we),ve=k(Ne);if(!ve)return null;const Te=S(ve,he),Pe=y(ve),Re=re(me,Te),Ue=Oe.map((qe,ft)=>qe-Re[ft]);return{beta:Te,cov:Pe,fitted:Re,residuals:Ue}}function re(me,Oe){return me.map(we=>we.reduce((Ne,he,ve)=>Ne+he*Oe[ve],0))}function se(me,Oe){const we=me.length,Ne=me.map(Ue=>Ue[Oe]),he=me.map(Ue=>[1,...Ue.filter((qe,ft)=>ft!==Oe)]),ve=ee(he,Ne,null);if(!ve)return 1;const Te=Ne.reduce((Ue,qe)=>Ue+qe,0)/we;let Pe=0,Re=0;for(let Ue=0;Ue<we;Ue++)Pe+=ve.residuals[Ue]**2,Re+=(Ne[Ue]-Te)**2;return Re===0?1:Math.max(0,Math.min(1,1-Pe/Re))}function de(me){const Oe=[...me].sort((he,ve)=>he-ve),we=ie(Oe),Ne=me.map(he=>Math.abs(he-we)).sort((he,ve)=>he-ve);return ie(Ne)/.6745}function ie(me){const Oe=me.length;if(!Oe)return 0;const we=Math.floor(Oe/2);return Oe%2?me[we]:(me[we-1]+me[we])/2}function oe(me,Oe,we={}){const Ne=we.method||"ols";if(J.has(Ne))throw new Error(`[lattice] regression method "${Ne}" is out of scope; use ols, wls or robust.`);if(Y.has(Ne))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!Q.has(Ne))throw new Error(`[lattice] unknown regression method "${Ne}"; use ols, wls or robust.`);const he=Array.isArray(Oe)?Oe.length:0,ve=he&&Array.isArray(me[0])?me[0].length:0,Te=ve+1;if(!(he>Te))return null;for(let jt=0;jt<he;jt++){if(!Number.isFinite(Oe[jt])||!Array.isArray(me[jt])||me[jt].length!==ve)return null;for(let Rt=0;Rt<ve;Rt++)if(!Number.isFinite(me[jt][Rt]))return null}let Pe=null;if(Ne==="wls"){if(Pe=we.weights,!Array.isArray(Pe)||Pe.length!==he)return null;for(let jt=0;jt<he;jt++)if(!(Pe[jt]>0)||!Number.isFinite(Pe[jt]))return null}const Re=me.map(jt=>[1,...jt]);let Ue,qe=null;if(Ne==="robust"){if(Ue=ee(Re,Oe,null),!Ue)return null;for(let jt=0;jt<50;jt++){const Rt=de(Ue.residuals);if(!(Rt>0))break;const Ft=Ue.residuals.map(qt=>{const Zt=Math.abs(qt/Rt);return Zt<=te?1:te/Zt}),Ut=ee(Re,Oe,Ft);if(!Ut)return null;const Qt=Ut.beta.reduce((qt,Zt,en)=>Math.max(qt,Math.abs(Zt-Ue.beta[en])),0);if(Ue=Ut,qe=Ft,Qt<1e-10)break}}else if(Ue=ee(Re,Oe,Pe),!Ue)return null;const ft=Ne==="robust"?qe:Pe,{beta:at,cov:mt,fitted:ct,residuals:vt}=Ue;let St=0,Le=0,rt=0;for(let jt=0;jt<he;jt++){const Rt=ft?ft[jt]:1;St+=Rt*vt[jt]**2,Le+=Rt,rt+=Rt*Oe[jt]}const et=rt/Le;let it=0;for(let jt=0;jt<he;jt++){const Rt=ft?ft[jt]:1;it+=Rt*(Oe[jt]-et)**2}const Et=he-Te,Nt=St/Et,dt=it===0?1:Math.max(0,Math.min(1,1-St/it)),Ot=1-(1-dt)*(he-1)/Et,Vt=Array.isArray(we.names)&&we.names.length===ve?we.names:me[0].map((jt,Rt)=>`x${Rt+1}`),Wt=Tt(we.confidence),sn=Et>0?W(1-(1-Wt)/2,Et):1/0,an=at.map((jt,Rt)=>{const Ft=Math.sqrt(Math.max(0,Nt*mt[Rt][Rt])),Ut=Ft>0?jt/Ft:jt===0?0:1/0,Qt=Number.isFinite(Ut)?2*(1-Z(Math.abs(Ut),Et)):0,qt=Number.isFinite(sn)?sn*Ft:null;return{name:Rt===0?"(intercept)":Vt[Rt-1],estimate:jt,stdError:Ft,t:Ut,p:Math.max(0,Math.min(1,Qt)),lower:qt===null?null:jt-qt,upper:qt===null?null:jt+qt}}),ln=new Array(he),zt=new Array(he);for(let jt=0;jt<he;jt++){const Rt=ft?ft[jt]:1,Ft=Math.max(0,Math.min(1,Rt*u(Re[jt],mt)));ln[jt]=Ft;const Ut=(1-Ft)**2;zt[jt]=Ut>0&&Nt>0?vt[jt]**2/(Te*Nt)*(Ft/Ut):null}const un=me[0].map((jt,Rt)=>{if(ve<2)return 1;const Ft=se(me,Rt);return Ft>=1?1/0:1/(1-Ft)});let cn=null;{const jt=vt.map(Ft=>Ft*Ft),Rt=ee(Re,jt,null);if(Rt){const Ft=jt.reduce((Xt,dn)=>Xt+dn,0)/he;let Ut=0,Qt=0;for(let Xt=0;Xt<he;Xt++)Ut+=Rt.residuals[Xt]**2,Qt+=(jt[Xt]-Ft)**2;const qt=Qt===0?0:Math.max(0,Math.min(1,1-Ut/Qt)),Zt=he*qt,en=D(Zt,ve);cn={statistic:Zt,df:ve,p:en,heteroscedastic:en<.05}}}let rn=null;if(ve===1){const jt=me.map((Rt,Ft)=>Ft).sort((Rt,Ft)=>me[Rt][0]-me[Ft][0]);rn={confidence:Wt,points:jt.map(Rt=>{const Ft=Re[Rt],Ut=Math.sqrt(Math.max(0,Nt*u(Ft,mt)));return{x:me[Rt][0],yhat:ct[Rt],lower:ct[Rt]-sn*Ut,upper:ct[Rt]+sn*Ut}})}}return{method:Ne,coefficients:an,r2:dt,adjR2:Ot,n:he,df:Et,sigma2:Nt,fitted:ct,residuals:vt,leverage:ln,cooksD:zt,vif:un,heteroscedasticity:cn,band:rn,weights:ft?[...ft]:null}}function ue(me){const Oe=me.length,we=Array.from({length:Oe},(ve,Te)=>Te).sort((ve,Te)=>me[ve]-me[Te]),Ne=new Float64Array(Oe);let he=0;for(;he<Oe;){let ve=he;for(;ve+1<Oe&&me[we[ve+1]]===me[we[he]];)ve++;const Te=(he+ve)/2+1;for(let Pe=he;Pe<=ve;Pe++)Ne[we[Pe]]=Te;he=ve+1}return Ne}const ce=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function pe(me){const Oe=[.01,.05,.1],we=[ce["1%"],ce["5%"],ce["10%"]];if(me<=we[0]){const ve=(Math.log(Oe[1])-Math.log(Oe[0]))/(we[1]-we[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(Oe[0])+ve*(me-we[0]))))}if(me>=we[2]){const ve=(Math.log(Oe[2])-Math.log(Oe[1]))/(we[2]-we[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(Oe[2])+ve*(me-we[2]))))}const Ne=me<we[1]?0:1,he=(me-we[Ne])/(we[Ne+1]-we[Ne]);return Math.exp(Math.log(Oe[Ne])+he*(Math.log(Oe[Ne+1])-Math.log(Oe[Ne])))}function Me(me,Oe,we,Ne){const he=we-Ne,ve=Ne+3,Te=new Array(he),Pe=new Array(he);let Re=!0,Ue=Ne;for(let ct=0;ct<he;ct++){const vt=Ne+ct,St=new Float64Array(ve);St[0]=1,St[1]=ct+1,St[2]=me[vt];for(let Le=1;Le<=Ne;Le++)St[2+Le]=Oe[vt-Le];for(let Le=1;Le<ve;Le++)Number.isFinite(St[Le])||(Ue=Math.min(Ue,Le-3));Te[ct]=St,Pe[ct]=Oe[vt],Number.isFinite(Pe[ct])||(Re=!1)}if(!Re)return 0;const{xtwx:qe,xtwy:ft}=d(Te,Pe,null);let at=0,mt=1/0;for(let ct=0;ct<=Ue;ct++){const vt=ct+3;if(!(he>vt))continue;const St=new Array(vt);for(let dt=0;dt<vt;dt++)St[dt]=qe[dt].slice(0,vt);const Le=k(St);if(!Le)continue;const rt=S(Le,ft.slice(0,vt));let et=0;for(let dt=0;dt<he;dt++){const Ot=Te[dt];let Vt=0;for(let Wt=0;Wt<vt;Wt++)Vt+=Ot[Wt]*rt[Wt];et+=(Pe[dt]-Vt)**2}const Et=et/(he-vt)*(he-vt);if(!(Et>0))continue;const Nt=he*Math.log(Et/he)+2*vt;Nt<mt&&(mt=Nt,at=ct)}return at}function $e(me,Oe={}){const we=[];for(let mt=0;mt<me.length;mt++){const ct=Number(me[mt]);Number.isFinite(ct)&&we.push(ct)}const Ne=we.length,he=Ne-1;if(Ne<8||he<6)return null;const ve=new Array(he);for(let mt=0;mt<he;mt++)ve[mt]=we[mt+1]-we[mt];let Te=Number.isFinite(Oe.maxlag)?Math.floor(Oe.maxlag):Math.ceil(12*(Ne/100)**.25);Te=Math.max(0,Math.min(Te,Math.floor((he-5)/2)));const Pe=(mt,ct)=>{const vt=[],St=[];for(let Le=ct;Le<he;Le++){const rt=[Le-ct+1,we[Le]];for(let et=1;et<=mt;et++)rt.push(ve[Le-et]);vt.push(rt),St.push(ve[Le])}return oe(vt,St,{method:"ols"})},Re=Me(we,ve,he,Te),Ue=Pe(Re,Re);if(!Ue||!Ue.coefficients[2])return null;const qe=Ue.coefficients[2].t,ft=pe(qe),at=qe<ce["5%"];return{statistic:qe,usedLag:Re,nobs:he-Re,criticalValues:{...ce},pValue:ft,pApproximate:!0,stationary:at,verdict:at?"stationary":"non-stationary",regression:"ct"}}function je(me,Oe={}){const we=[];for(let at=0;at<me.length;at++){const mt=Number(me[at]);Number.isFinite(mt)&&we.push(mt)}const Ne=we.length;if(Ne<3)return null;let he=Number.isFinite(Oe.maxlag)?Math.floor(Oe.maxlag):Math.min(10,Ne-1);he=Math.max(1,Math.min(he,Ne-1));let ve=0;for(const at of we)ve+=at;ve/=Ne;const Te=we.map(at=>at-ve);let Pe=0;for(const at of Te)Pe+=at*at;Pe/=Ne;const Re=new Array(he+1).fill(0);Re[0]=1;for(let at=1;at<=he;at++){let mt=0;for(let ct=at;ct<Ne;ct++)mt+=Te[ct]*Te[ct-at];Re[at]=Pe>0?mt/Ne/Pe:0}const Ue=new Array(he+1).fill(0);Ue[0]=1;let qe=[];for(let at=1;at<=he;at++){let mt=Re[at];for(let Le=1;Le<at;Le++)mt-=qe[Le-1]*Re[at-Le];let ct=1;for(let Le=1;Le<at;Le++)ct-=qe[Le-1]*Re[Le];const vt=ct!==0?mt/ct:0,St=new Array(at);for(let Le=1;Le<at;Le++)St[Le-1]=qe[Le-1]-vt*qe[at-1-Le];St[at-1]=vt,Ue[at]=vt,qe=St}const ft=1.96/Math.sqrt(Ne);return{acf:Re,pacf:Ue,bounds:{upper:ft,lower:-ft},n:Ne,nlags:he,approximate:!0}}function ke(me,Oe,we){const{xs:Ne,ys:he,n:ve}=C(me,Oe,we);if(ve<2)return null;const Te=ue(Ne),Pe=ue(he);let Re=0,Ue=0;for(let mt=0;mt<ve;mt++)Re+=Te[mt],Ue+=Pe[mt];Re/=ve,Ue/=ve;let qe=0,ft=0,at=0;for(let mt=0;mt<ve;mt++){const ct=Te[mt]-Re,vt=Pe[mt]-Ue;qe+=ct*vt,ft+=ct*ct,at+=vt*vt}return ft===0||at===0?null:Math.max(-1,Math.min(1,qe/Math.sqrt(ft*at)))}function ge(me,Oe,we){const{xs:Ne,ys:he,n:ve}=C(me,Oe,we);if(ve<2||ve>i)return null;let Te=0,Pe=0,Re=0,Ue=0;for(let at=0;at<ve;at++)for(let mt=at+1;mt<ve;mt++){const ct=Math.sign(Ne[at]-Ne[mt]),vt=Math.sign(he[at]-he[mt]),St=ct*vt;St>0?Te++:St<0?Pe++:ct===0&&vt===0||(ct===0?Re++:Ue++)}const qe=Te+Pe+Ue,ft=Te+Pe+Re;return qe===0||ft===0?null:(Te-Pe)/Math.sqrt(qe*ft)}function Ee(me,Oe={}){const we=me.length;if(we<2)return null;const Ne=me[0],he=me[we-1],ve=[];for(let Le=1;Le<we;Le++){const rt=me[Le-1];rt!==0&&ve.push((me[Le]-rt)/Math.abs(rt))}let Te=null;if(ve.length>1){let Le=0;for(const et of ve)Le+=et;Le/=ve.length;let rt=0;for(const et of ve)rt+=(et-Le)**2;Te=Math.sqrt(rt/(ve.length-1))}const Pe=Number(Oe.periodsPerYear)>0?Number(Oe.periodsPerYear):null;let Re=me[0],Ue=0,qe=0,ft=0,at=0;for(let Le=1;Le<we;Le++){if(me[Le]>Re){Re=me[Le],Ue=Le;continue}if(Re<=0)continue;const rt=(Re-me[Le])/Re;rt>qe&&(qe=rt,ft=Ue,at=Le)}let mt=null;if(we>2){let Le=0;for(let it=0;it<we;it++)Le+=me[it];Le/=we;let rt=0,et=0;for(let it=0;it<we;it++){const Et=me[it]-Le;et+=Et*Et,it>0&&(rt+=Et*(me[it-1]-Le))}mt=et>0?rt/et:null}let ct=0,vt=0;for(const Le of ve)Le>0?ct++:Le<0&&vt++;let St=null;if(Ne>0&&he>0){const Le=(he/Ne)**(1/(we-1))-1;St=Pe?(1+Le)**Pe-1:Le}return{n:we,first:Ne,last:he,change:he-Ne,changePercent:Ne===0?null:(he-Ne)/Math.abs(Ne)*100,volatility:Te,annualisedVolatility:Te!==null&&Pe?Te*Math.sqrt(Pe):null,growth:St,maxDrawdown:qe,maxDrawdownFrom:ft,maxDrawdownTo:at,autocorrelation:mt,upDays:ct,downDays:vt}}const Ie=1.128,ze=3.267;function _e(me){const Oe=me.length;if(Oe<2)return null;const we=[];for(let he=1;he<Oe;he++)we.push(Math.abs(me[he]-me[he-1]));const Ne=we.reduce((he,ve)=>he+ve,0)/we.length;return{ranges:we,centre:Ne,upper:ze*Ne,lower:0}}function Qe(me){const Oe=me.length;if(Oe<2)return null;let we=0;for(let he=1;he<Oe;he++)we+=Math.abs(me[he]-me[he-1]);const Ne=we/(Oe-1);return{sigma:Ne/Ie,meanRange:Ne}}function nt(me,Oe){const we=me.length;if(we<2||!Oe)return null;const Ne=Number.isFinite(Number(Oe.lower))?Number(Oe.lower):null,he=Number.isFinite(Number(Oe.upper))?Number(Oe.upper):null;if(Ne===null&&he===null)return null;let ve=0;for(let ct=0;ct<we;ct++)ve+=me[ct];ve/=we;let Te=0;for(let ct=0;ct<we;ct++)Te+=(me[ct]-ve)**2;const Pe=Math.sqrt(Te/(we-1)),Re=Qe(me),Ue=Re?Re.sigma:null,qe=ct=>{if(!ct||ct<=0)return{index:null,k:null};const St=Ne!==null&&he!==null?(he-Ne)/(6*ct):null,Le=he!==null?(he-ve)/(3*ct):1/0,rt=Ne!==null?(ve-Ne)/(3*ct):1/0;return{index:St,k:Math.min(Le,rt)}},ft=qe(Ue),at=qe(Pe);let mt=0;for(let ct=0;ct<we;ct++){if(Ne!==null&&me[ct]<Ne){mt++;continue}he!==null&&me[ct]>he&&mt++}return{n:we,mean:ve,lower:Ne,upper:he,target:Number.isFinite(Number(Oe.target))?Number(Oe.target):null,sigmaWithin:Ue,sigmaOverall:Pe,cp:ft.index,cpk:ft.k,pp:at.index,ppk:at.k,outOfSpec:mt,defectRate:we?mt/we:null}}function Ae(me){const Oe=me.length;if(Oe<2)return null;const we=Qe(me);if(!we||!(we.sigma>0))return null;let Ne=0;for(let he=0;he<Oe;he++)Ne+=me[he];return Ne/=Oe,{centre:Ne,sigma:we.sigma,upper:Ne+3*we.sigma,lower:Ne-3*we.sigma}}function Ke(me,Oe){if(!Oe||!(Oe.sigma>0))return[];const we=me.length,{centre:Ne,sigma:he}=Oe,ve=Pe=>(me[Pe]-Ne)/he,Te=[];for(let Pe=0;Pe<we;Pe++){if(Math.abs(ve(Pe))>3&&Te.push({index:Pe,rule:1,description:"beyond three sigma"}),Pe>=2)for(const Re of[1,-1]){let Ue=0;for(let qe=Pe-2;qe<=Pe;qe++)ve(qe)*Re>2&&Ue++;if(Ue>=2){Te.push({index:Pe,rule:2,description:"two of three past two sigma"});break}}if(Pe>=4)for(const Re of[1,-1]){let Ue=0;for(let qe=Pe-4;qe<=Pe;qe++)ve(qe)*Re>1&&Ue++;if(Ue>=4){Te.push({index:Pe,rule:3,description:"four of five past one sigma"});break}}if(Pe>=7)for(const Re of[1,-1]){let Ue=!0;for(let qe=Pe-7;qe<=Pe;qe++)if(ve(qe)*Re<=0){Ue=!1;break}if(Ue){Te.push({index:Pe,rule:4,description:"eight in a row on one side"});break}}}return Te}function Ve(me,Oe){if(!Oe||!(Oe.sigma>0))return[];const we=me.length,{centre:Ne,sigma:he}=Oe,ve=Re=>(me[Re]-Ne)/he,Te=(Re,Ue,qe,ft)=>{for(const at of[1,-1]){let mt=0;for(let ct=Re;ct<=Ue;ct++)ve(ct)*at>qe&&mt++;if(mt>=ft)return!0}return!1},Pe=[];for(let Re=0;Re<we;Re++){if(Math.abs(ve(Re))>3&&Pe.push({index:Re,rule:1,description:"beyond three sigma"}),Re>=8)for(const Ue of[1,-1]){let qe=!0;for(let ft=Re-8;ft<=Re;ft++)if(ve(ft)*Ue<=0){qe=!1;break}if(qe){Pe.push({index:Re,rule:2,description:"nine in a row on one side"});break}}if(Re>=5)for(const Ue of[1,-1]){let qe=!0;for(let ft=Re-4;ft<=Re;ft++)if((me[ft]-me[ft-1])*Ue<=0){qe=!1;break}if(qe){Pe.push({index:Re,rule:3,description:Ue>0?"six rising":"six falling"});break}}if(Re>=13){let Ue=!0;for(let qe=Re-12;qe<=Re;qe++){const ft=me[qe]-me[qe-1],at=me[qe+1<=Re?qe+1:qe]-me[qe];if(qe+1>Re)break;if(ft===0||at===0||ft>0==at>0){Ue=!1;break}}Ue&&Pe.push({index:Re,rule:4,description:"fourteen alternating"})}if(Re>=2&&Te(Re-2,Re,2,2)&&Pe.push({index:Re,rule:5,description:"two of three past two sigma"}),Re>=4&&Te(Re-4,Re,1,4)&&Pe.push({index:Re,rule:6,description:"four of five past one sigma"}),Re>=14){let Ue=!0;for(let qe=Re-14;qe<=Re;qe++)if(Math.abs(ve(qe))>=1){Ue=!1;break}Ue&&Pe.push({index:Re,rule:7,description:"fifteen within one sigma"})}if(Re>=7){let Ue=!0;for(let qe=Re-7;qe<=Re;qe++)if(Math.abs(ve(qe))<=1){Ue=!1;break}Ue&&Pe.push({index:Re,rule:8,description:"eight beyond one sigma"})}}return Pe}const Xe=Object.freeze(["westernElectric","nelson"]);function st(me,Oe,we="westernElectric"){return String(we)==="nelson"?Ve(me,Oe):Ke(me,Oe)}function ht(me,Oe,we){let Ne=0;for(let he=0;he<me.length;he++)(me[he]<Oe||me[he]>we)&&Ne++;return Ne}function bt(me,Oe,we,Ne=20){const he=me.length;if(!he)return[];const ve=me[0],Te=me[he-1];if(Te===ve)return[{from:ve,to:Te,count:he}];const Pe=we-Oe,Re=1.5*Pe;let Ue=Pe>0?Math.max(ve,Oe-Re):ve,qe=Pe>0?Math.min(Te,we+Re):Te;qe>Ue||(Ue=ve,qe=Te);const ft=Pe>0?2*Pe/Math.cbrt(he):(qe-Ue)/(Math.ceil(Math.log2(he))+1),at=ft>0?Math.min(Ne,Math.max(1,Math.ceil((qe-Ue)/ft))):1,mt=(qe-Ue)/at,ct=[];for(let vt=0;vt<at;vt++)ct.push({from:Ue+vt*mt,to:Ue+(vt+1)*mt,count:0});for(let vt=0;vt<he;vt++){const St=Math.min(at-1,Math.max(0,Math.floor((me[vt]-Ue)/mt)));ct[St].count++}return ct[0].from=ve,ct[at-1].to=Te,ct}const At=.95;function Tt(me){const Oe=Number(me);return Number.isFinite(Oe)&&Oe>0&&Oe<1?Oe:At}function It(me,Oe=At){const we=me.length;if(we<2)return null;let Ne=0;for(let qe=0;qe<we;qe++)Ne+=me[qe];const he=Ne/we;let ve=0;for(let qe=0;qe<we;qe++){const ft=me[qe]-he;ve+=ft*ft}const Te=Math.sqrt(ve/(we-1)),Pe=Tt(Oe),Ue=W(1-(1-Pe)/2,we-1)*Te/Math.sqrt(we);return{mean:he,lower:he-Ue,upper:he+Ue,margin:Ue,n:we,confidence:Pe}}function Dt(me,Oe,we=At){const Ne=Number(me),he=Number(Oe);if(!(he>0)||!(Ne>=0)||Ne>he)return null;const ve=Tt(we),Te=V(1-(1-ve)/2),Pe=Ne/he,Re=Te*Te,Ue=1+Re/he,qe=(Pe+Re/(2*he))/Ue,ft=Te/Ue*Math.sqrt(Pe*(1-Pe)/he+Re/(4*he*he));return{proportion:Pe,lower:Math.max(0,qe-ft),upper:Math.min(1,qe+ft),n:he,confidence:ve}}function Gt(me,Oe=At){if(!me||!(me.n>2)||!Number.isFinite(me.stdError))return null;const we=Tt(Oe),he=W(1-(1-we)/2,me.n-2)*me.stdError;return{slope:me.slope,lower:me.slope-he,upper:me.slope+he,margin:he,confidence:we}}function Yt(me,Oe,we=At){const Ne=Number(me),he=Number(Oe);if(!Number.isFinite(Ne)||!(he>1))return null;const ve=Tt(we),Pe=V(1-(1-ve)/2)*Math.sqrt(1/(9*he)+Ne*Ne/(2*(he-1)));return{index:Ne,lower:Ne-Pe,upper:Ne+Pe,margin:Pe,n:he,confidence:ve}}function wt(me,Oe){return!me||!(me.sd>0)||!Number.isFinite(Oe)||!Number.isFinite(me.mean)?null:(Oe-me.mean)/me.sd}function fe(me){return Number.isFinite(me)?Math.min(1,Math.max(0,2*U(Math.abs(me)/2)-1)):0}function be(me,Oe){const we=new Map,Ne=$(me);let he=0;for(let ve=0;ve<Oe.length;ve++){const Te=Ne(Oe[ve]);if(Te==null||Te===""||typeof Te=="number"&&Number.isNaN(Te))continue;const Pe=Te instanceof Date?Te.getTime():typeof Te=="object"?String(Te):Te;we.set(Pe,(we.get(Pe)||0)+1),he++}return{map:we,total:he}}function xe(me,Oe,we,Ne){if(!(Oe>0)||!(Ne>0))return null;let he=0;const ve=new Set(me.keys());for(const Te of we.keys())ve.add(Te);for(const Te of ve){const Pe=(me.get(Te)||0)/Oe,Re=(we.get(Te)||0)/Ne;he+=Math.abs(Pe-Re)}return he/2}const We=10;function Ze(me,Oe,we){if(we&&we.numeric){const Pe=l(me,Oe),{n:Re,mean:Ue}=v(Pe),qe=Re>0?wt({mean:we.mean,sd:we.sd},Ue):null;return{measure:"standardizedMeanDifference",magnitude:qe,distance:qe===null?0:fe(qe),direction:qe===null?0:Math.sign(qe),subsetN:Re,populationN:we.n||0,reliable:Re>=We}}const{map:he,total:ve}=be(me,Oe),Te=xe(he,ve,we.map,we.total);return{measure:"categoricalTotalVariation",magnitude:Te,distance:Te===null?0:Te,direction:0,subsetN:ve,populationN:we.total||0,reliable:ve>=We}}function ut(me,Oe){if(me&&(me.kind==="float64"||me.kind==="int32"))return!0;const we=$(me);let Ne=0,he=0;for(let ve=0;ve<Oe.length&&Ne<200;ve++){const Te=we(Oe[ve]);if(Te==null||Te==="")continue;if(Te instanceof Date)return!1;Ne++;const Pe=typeof Te=="number"?Te:Number(Te);Number.isFinite(Pe)&&he++}return Ne===0?!1:he/Ne>=.9}function gt(me,Oe){if(ut(me,Oe)){const he=l(me,Oe),{n:ve,mean:Te,m2:Pe}=v(he);return{numeric:!0,mean:Te,sd:ve>0?Math.sqrt(Pe/ve):0,n:ve}}const{map:we,total:Ne}=be(me,Oe);return{numeric:!1,map:we,total:Ne}}}),Ce("packages/core/src/compute/total.js",function(e,G){"use strict";Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"aggregatesFor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"aggregateAllowed",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return w}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,R=G("packages/core/src/compute/handle.js"),W=R.presenceReader,Z=R.valueComparator,V=R.valueReader,U=G("packages/core/src/compute/statistics.js"),D=U.STAT_FNS,I=U.STAT_LABELS;function k(v){return!!v&&(v.kind==="float64"||v.kind==="int32")}function S(v,h){const c=h.length;let j=0;if(k(v)){const O=v.values,T=W(v);if(!T){for(let A=0;A<c;A++){const P=O[h[A]];Number.isNaN(P)||(j+=P)}return j}for(let A=0;A<c;A++){const P=h[A];if(T(P)===1){const L=O[P];Number.isNaN(L)||(j+=L)}}return j}const E=V(v);for(let O=0;O<c;O++){const T=o(E(h[O]));T!==null&&(j+=T)}return j}S.kernel=!0;function y(v,h){const c=h.length;let j=0;if(k(v)){const O=v.values,T=W(v);if(!T){for(let A=0;A<c;A++)Number.isNaN(O[h[A]])||j++;return j}for(let A=0;A<c;A++){const P=h[A];T(P)===1&&!Number.isNaN(O[P])&&j++}return j}const E=V(v);for(let O=0;O<c;O++){const T=E(h[O]);T!=null&&!(typeof T=="number"&&Number.isNaN(T))&&j++}return j}y.kernel=!0;function d(v,h){return h.length}d.kernel=!0;function u(v,h){const c=y(v,h);return c===0?null:S(v,h)/c}u.kernel=!0;function n(v,h,c,j){const E=h.length;if(k(v)){const P=v.values,L=W(v);let z=null;if(!L){for(let H=0;H<E;H++){const x=P[h[H]];Number.isNaN(x)||(z===null||(c<0?x<z:x>z))&&(z=x)}return z}for(let H=0;H<E;H++){const x=h[H];if(L(x)===0)continue;const F=P[x];Number.isNaN(F)||(z===null||(c<0?F<z:F>z))&&(z=F)}return z}const O=V(v),T=Z(j);let A=null;for(let P=0;P<E;P++){const L=O(h[P]);L==null||typeof L=="number"&&Number.isNaN(L)||(A===null||(c<0?T(L,A)<0:T(L,A)>0))&&(A=L)}return A}function t(v,h,c){return n(v,h,-1,c&&c.locale)}t.kernel=!0;function i(v,h,c){return n(v,h,1,c&&c.locale)}i.kernel=!0;function s(v,h){return h.length===0?null:V(v)(h[0])}s.kernel=!0;function r(v,h){return h.length===0?null:V(v)(h[h.length-1])}r.kernel=!0;function o(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 h=Number(v);return Number.isNaN(h)?null:h}const l={sum:S,min:t,max:i,avg:u,count:d,first:s,last:r,countValues:y,...D},a=Object.freeze({...I,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function p(v){return v?typeof v=="string"?a[v]||v:"Total":""}const m=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function b(v){const h=v&&v.dataType&&v.dataType.totals&&v.dataType.totals.supported;if(Array.isArray(h))return h.slice();const c=m.filter(j=>j in l);for(const j of Object.keys(l))c.includes(j)||c.push(j);return c}function g(v,h){return typeof h!="string"?!0:b(v).includes(h)}function f(v,h){const c=V(v),j=[];for(let E=0;E<h.length;E++){const O=c(h[E]);O!=null&&j.push(O)}return j}function w(v,h,c,j){const E=h||[];if(typeof c=="string"){const O=l[c];return O?O(v,E,j):($(`total:${c}`,`unknown total function "${c}"; register it in config.totalFns`),null)}return M(c)?c.kernel===!0?c(v,E,j):c(f(v,E),j||{}):null}}),Ce("packages/core/src/compute/windowed.js",function(e,G){"use strict";Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/compute/sketch.js").Welford;class ${#e;#t;#n=[];#r;#o;constructor(U,D=0,I=Date.now){if(U!=="count"&&U!=="time"&&U!=="session")throw new RangeError(`unknown window kind: ${U}`);if((U==="count"||U==="time")&&!(D>0))throw new RangeError(`a ${U} window needs a positive span`);this.#e=U,this.#t=Math.floor(D),this.#r=I,this.#o=I()}get size(){return this.#n.length}push(U,D=this.#r()){Number.isFinite(U)&&(this.#n.push({t:D,v:U}),this.#i(D))}#i(U){if(this.#e==="count")for(;this.#n.length>this.#t;)this.#n.shift();else if(this.#e==="time"){const D=U-this.#t;for(;this.#n.length&&this.#n[0].t<D;)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 D=new M;let I=0,k=1/0,S=-1/0;for(const{v:y}of this.#n)I+=y,y<k&&(k=y),y>S&&(S=y),D.add(y);return{over:U,count:this.#n.length,sum:I,mean:D.mean(),min:k,max:S,variance:D.variance(),stddev:D.stddev()}}reduce(U){const D=this.aggregate(),I={sum:D.sum,avg:D.mean,mean:D.mean,min:D.min,max:D.max,count:D.count,variance:D.variance,stddev:D.stddev};if(!(U in I))throw new RangeError(`unknown windowed aggregate: ${U}`);return{value:I[U],over:D.over}}}const R=Object.freeze(["count","time","session"]);function W(V,U=Date.now){const D=V.kind==="time"&&V.minutes!=null?V.minutes*6e4:V.span??0;return new $(V.kind,D,U)}const Z={Window:$,WINDOW_KINDS:R,openWindow:W}}),Ce("packages/core/src/compute/rolling.js",function(e,G){"use strict";Object.defineProperty(e,"ROLLING_WINDOW_FIELDS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"rollingWindow",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"cumulativeToDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"periodOverPeriod",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"QUANTILE_SPAN_CAP",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"rollingQuantile",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"seasonalDecompose",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"exponentialSmoothing",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l}});const M=G("packages/core/src/compute/windowed.js").openWindow,R=G("packages/core/src/compute/sketch.js").KLL,W=Object.freeze({rollingSum:"sum",rollingAvg:"avg",rollingMin:"min",rollingMax:"max"});function Z(a,p,m,b){if(a.kind==="count"){const g=Math.max(1,Math.floor(a.span||0));return{coverage:Math.min(1,p/g),partial:p<g}}if(a.kind==="time"){const g=a.minutes!=null?a.minutes*6e4:a.span||0;if(!(g>0))return{coverage:1,partial:!1};const f=m-b;return{coverage:Math.min(1,f/g),partial:f<g}}return{coverage:null,partial:!1}}function V(a,p){const m=M(p),b=new Map,g=a.length?a[0].at:0;for(let f=0;f<a.length;f++){const{key:w,at:v,value:h}=a[f];Number.isFinite(h)&&m.push(h,v);const c=m.aggregate(),j=Z(p,c.count,v,g);w!=null&&b.set(String(w),{sum:c.sum,avg:c.mean,min:c.min,max:c.max,count:c.count,coverage:j.coverage,partial:j.partial})}return b}function U(a){const p=new Map;let m=0;for(const{key:b,value:g}of a)Number.isFinite(g)&&(m+=g),b!=null&&p.set(String(b),m);return p}function D(a,p=1){const m=new Map,b=Math.max(1,Math.floor(p));for(let g=0;g<a.length;g++){const{key:f,value:w}=a[g];if(f==null)continue;const v=g>=b?a[g-b].value:null,h=Number.isFinite(w)?w:null,c=Number.isFinite(v)?v:null;m.set(String(f),h!==null&&c!==null?h-c:null)}return m}const I=4096;function k(a){let p=a>>>0;return()=>{p+=1831565813;let m=p;return m=Math.imul(m^m>>>15,m|1),m^=m+Math.imul(m^m>>>7,m|61),((m^m>>>14)>>>0)/4294967296}}function S(a,p){const m=a.length;if(m===1)return a[0];const b=(m-1)*p,g=Math.floor(b),f=Math.ceil(b);return g===f?a[g]:a[g]+(b-g)*(a[f]-a[g])}function y(a,p,m={}){const b=Math.min(1,Math.max(0,m.q==null?.5:m.q)),g=Math.max(1,Math.floor(m.cap==null?I:m.cap)),f=k(m.seed==null?2654435769:m.seed),w=new Map,v=a.length?a[0].at:0;if(p.kind==="session"){const c=new R(200,f);let j=0;for(const{key:E,value:O}of a)Number.isFinite(O)&&(c.add(O),j++),E!=null&&w.set(String(E),{value:j?c.quantile(b):null,approx:j>0,count:j,coverage:null,partial:!1});return w}const h=M(p);for(const{key:c,at:j,value:E}of a){Number.isFinite(E)&&h.push(E,j);const O=h.values(),T=O.length;let A=null,P=!1;if(T)if(T<=g)A=S([...O].sort((z,H)=>z-H),b);else{const z=new R(200,f);for(const H of O)z.add(H);A=z.quantile(b),P=!0}const L=Z(p,T,j,v);c!=null&&w.set(String(c),{value:A,approx:P,count:T,coverage:L.coverage,partial:L.partial})}return w}function d(a,p){const m=a.length,b=new Array(m).fill(null),g=Math.floor(p/2),f=p%2===0;for(let w=0;w<m;w++){if(w-g<0||w+g>=m)continue;let v=0,h=!0;if(f)for(let c=-g;c<=g;c++){const j=a[w+c];if(!Number.isFinite(j)){h=!1;break}v+=c===-g||c===g?j*.5:j}else for(let c=-g;c<=g;c++){const j=a[w+c];if(!Number.isFinite(j)){h=!1;break}v+=j}h&&(b[w]=v/p)}return b}function u(a,p){const m=new Map,b=Math.floor(Number(p&&p.period));if(!(b>=2))return m;const g=p&&p.model==="multiplicative",f=a.length,w=a.map(P=>Number.isFinite(P.value)?P.value:null),v=d(w,b),h=new Array(f).fill(null);for(let P=0;P<f;P++){const L=v[P],z=w[P];L===null||z===null||(g?L!==0&&(h[P]=z/L):h[P]=z-L)}const c=new Array(b).fill(0),j=new Array(b).fill(0);for(let P=0;P<f;P++){if(h[P]===null)continue;const L=P%b;c[L]+=h[P],j[L]+=1}const E=g?1:0,O=c.map((P,L)=>j[L]?P/j[L]:E),T=O.reduce((P,L)=>P+L,0)/b,A=g?O.map(P=>T!==0?P/T:1):O.map(P=>P-T);for(let P=0;P<f;P++){const{key:L}=a[P];if(L==null)continue;const z=v[P],H=A[P%b],x=w[P];let F=null;z!==null&&x!==null&&(F=g?z*H!==0?x/(z*H):null:x-z-H),m.set(String(L),{trend:z,seasonal:x===null?null:H,residual:F,coverage:z===null?0:1,partial:z===null})}return m}function n(a,p,m,b=80){const g=(Math.sqrt(5)-1)/2;let f=p,w=m,v=w-g*(w-f),h=f+g*(w-f),c=a(v),j=a(h);for(let E=0;E<b;E++)c<j?(w=h,h=v,j=c,v=w-g*(w-f),c=a(v)):(f=v,v=h,c=j,h=f+g*(w-f),j=a(h));return(f+w)/2}const t=1e-4,i=1-1e-4;function s(a,p){const m=a.length,b=new Array(m).fill(null),g=new Array(m).fill(null);let f=null,w=0;for(let v=0;v<m;v++){const h=a[v];if(!Number.isFinite(h)){f!==null&&(g[v]=f,b[v]=f);continue}if(f===null){f=h,g[v]=h,b[v]=h;continue}g[v]=f,w+=(h-f)**2,f=p*h+(1-p)*f,b[v]=f}return{smoothed:b,fitted:g,sse:w}}function r(a,p,m){const b=a.length,g=new Array(b).fill(null),f=new Array(b).fill(null);let w=null,v=null,h=0;for(let c=0;c<b;c++){const j=a[c];if(!Number.isFinite(j)){w!==null&&(w+=v,g[c]=w);continue}if(w===null){w=j,g[c]=j;continue}if(v===null){v=j-w;const T=w+v;f[c]=T,h+=(j-T)**2;const A=w;w=p*j+(1-p)*(A+v),v=m*(w-A)+(1-m)*v,g[c]=w;continue}const E=w+v;f[c]=E,h+=(j-E)**2;const O=w;w=p*j+(1-p)*(O+v),v=m*(w-O)+(1-m)*v,g[c]=w}return{smoothed:g,fitted:f,sse:h}}function o(a,p={}){const m=new Map,b=p.method==="holt",g=a.map(E=>Number.isFinite(E.value)?E.value:null),f=g.filter(E=>E!==null).length,w=E=>Math.min(i,Math.max(t,E)),v=()=>{for(const{key:E}of a)E!=null&&m.set(String(E),{smoothed:null,fitted:null,alpha:null,beta:null,sse:null});return m};if(f<(b?2:1))return v();let h=Number.isFinite(p.alpha)?w(p.alpha):null,c=b&&Number.isFinite(p.beta)?w(p.beta):null;if(b){if(h===null||c===null){let E=h===null?.5:h,O=c===null?.5:c;for(let T=0;T<6;T++)h===null&&(E=n(A=>r(g,A,O).sse,t,i)),c===null&&(O=n(A=>r(g,E,A).sse,t,i));h=h===null?E:h,c=c===null?O:c}}else h===null&&(h=n(E=>s(g,E).sse,t,i));const j=b?r(g,h,c):s(g,h);for(let E=0;E<a.length;E++){const{key:O}=a[E];O!=null&&m.set(String(O),{smoothed:j.smoothed[E],fitted:j.fitted[E],alpha:h,beta:b?c:null,sse:j.sse})}return m}const l={ROLLING_WINDOW_FIELDS:W,QUANTILE_SPAN_CAP:I,rollingWindow:V,rollingQuantile:y,cumulativeToDate:U,periodOverPeriod:D,seasonalDecompose:u,exponentialSmoothing:o}}),Ce("packages/core/src/compute/compare.js",function(e,G){"use strict";Object.defineProperty(e,"COMPARE_MEASURES",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"pooledStandardMeanDifference",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"numericSummary",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"bothNumeric",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"compareColumnAcross",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"compareDatasets",{enumerable:!0,get:function(){return d}});const _=G("packages/core/src/compute/statistics.js"),M=_.numbers,$=_.moments,R=_.frequencyMap,W=_.categoricalDistance,Z=_.normalTotalVariation,V=_.isNumericColumn,U=_.SUBSET_RELIABILITY_FLOOR,D=Object.freeze({numeric:"pooledStandardMeanDifference",categorical:"categoricalTotalVariation",common:"totalVariationDistance"});function I(u,n){if(!u||!n||!(u.n>0)||!(n.n>0)||!Number.isFinite(u.mean)||!Number.isFinite(n.mean))return null;const t=(u.n*u.sd*u.sd+n.n*n.sd*n.sd)/(u.n+n.n);return t>0?(u.mean-n.mean)/Math.sqrt(t):null}function k(u,n){const t=M(u,n),{n:i,mean:s,m2:r}=$(t),o=i>0?Math.sqrt(r/i):0;return{mean:s,sd:o,n:i}}function S(u,n,t,i){return V(u,n)&&V(t,i)}function y(u,n,t,i){if(S(u,n,t,i)){const l=k(u,n),a=k(t,i),p=I(l,a);return{measure:D.numeric,magnitude:p,distance:p===null?0:Z(p),direction:p===null?0:Math.sign(p),nA:l.n,nB:a.n,reliable:l.n>=U&&a.n>=U}}const s=R(u,n),r=R(t,i),o=W(s.map,s.total,r.map,r.total);return{measure:D.categorical,magnitude:o,distance:o===null?0:o,direction:0,nA:s.total,nB:r.total,reliable:s.total>=U&&r.total>=U}}function d(u,n,t={}){const i=new Set(u.columns),s=new Set(n.columns),r=u.columns.filter(m=>s.has(m)),o=Array.isArray(t.columns)&&t.columns.length?r.filter(m=>t.columns.includes(m)):r,l=u.indices(),a=n.indices(),p=[];for(const m of o){const b=u.handle(m),g=n.handle(m);if(!b||!g)continue;const f=y(b,l,g,a);p.push({column:m,name:u.name&&u.name(m)||n.name&&n.name(m)||m,measure:f.measure,magnitude:f.magnitude,distance:f.distance,direction:f.direction,nA:f.nA,nB:f.nB,reliable:f.reliable})}return p.sort((m,b)=>b.distance-m.distance||Math.abs(b.magnitude||0)-Math.abs(m.magnitude||0)),{ranked:p,nA:l.length,nB:a.length,unmatched:{onlyA:u.columns.filter(m=>!s.has(m)),onlyB:n.columns.filter(m=>!i.has(m))},measures:D}}}),Ce("packages/core/src/compute/anomaly.js",function(e,G){"use strict";Object.defineProperty(e,"MAD_SCALE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"ANOMALY_METHODS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"robustSpread",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"modifiedZScores",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"iqrFences",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"chiSquareCdf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"chiSquareQuantile",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"mahalanobis",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"rollingAnomalies",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"anomalyCondition",{enumerable:!0,get:function(){return l}});const M=G("packages/core/src/compute/statistics.js").quantileSorted,R=G("packages/core/src/compute/special.js").logGamma,W=.6745,Z=3.5,V=1.5,U=.975,D=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function I(a){if(!a.length)return null;const m=Array.from(a,Number).sort((w,v)=>w-v),b=M(m,.5),g=m.map(w=>Math.abs(w-b)).sort((w,v)=>w-v),f=M(g,.5);return{median:b,mad:f}}function k(a,p={}){const m=Number.isFinite(p.threshold)?p.threshold:Z,b=a.length,g=new Array(b).fill(null),f=new Array(b).fill(!1),w=[];for(let c=0;c<b;c++){const j=Number(a[c]);Number.isFinite(j)&&w.push(j)}if(!w.length)return{median:null,mad:null,threshold:m,scores:g,flags:f,flagged:0};const v=I(w);if(v.mad===0)return{median:v.median,mad:0,threshold:m,scores:g,flags:f,flagged:0};let h=0;for(let c=0;c<b;c++){const j=Number(a[c]);if(!Number.isFinite(j))continue;const E=W*(j-v.median)/v.mad;g[c]=E,Math.abs(E)>m&&(f[c]=!0,h++)}return{median:v.median,mad:v.mad,threshold:m,scores:g,flags:f,flagged:h}}function S(a,p={}){const m=Number.isFinite(p.k)?p.k:V,b=[];for(let h=0;h<a.length;h++){const c=Number(a[h]);Number.isFinite(c)&&b.push(c)}if(!b.length)return null;const g=b.sort((h,c)=>h-c),f=M(g,.25),w=M(g,.75),v=w-f;return{q1:f,q3:w,iqr:v,lower:f-m*v,upper:w+m*v,k:m}}function y(a,p){if(p<=0)return 0;const m=R(a);if(p<a+1){let c=a,j=1/a,E=j;for(let O=0;O<1e3&&(c+=1,E*=p/c,j+=E,!(Math.abs(E)<Math.abs(j)*1e-15));O++);return j*Math.exp(-p+a*Math.log(p)-m)}const b=1e-300;let g=p+1-a,f=1/b,w=1/g,v=w;for(let c=1;c<1e3;c++){const j=-c*(c-a);g+=2,w=j*w+g,Math.abs(w)<b&&(w=b),f=g+j/f,Math.abs(f)<b&&(f=b),w=1/w;const E=w*f;if(v*=E,Math.abs(E-1)<1e-15)break}return 1-Math.exp(-p+a*Math.log(p)-m)*v}function d(a,p){return a<=0?0:y(p/2,a/2)}function u(a,p=U){if(!(p>0)||!(p<1))return NaN;let m=0,b=Math.max(1,a);for(;d(b,a)<p;)b*=2;for(let g=0;g<200;g++){const f=(m+b)/2;if(d(f,a)<p?m=f:b=f,b-m<1e-10)break}return(m+b)/2}function n(a){const p=a.length,m=a.map((b,g)=>{const f=b.slice();for(let w=0;w<p;w++)f.push(g===w?1:0);return f});for(let b=0;b<p;b++){let g=b;for(let w=b+1;w<p;w++)Math.abs(m[w][b])>Math.abs(m[g][b])&&(g=w);if(Math.abs(m[g][b])<1e-12)return null;if(g!==b){const w=m[g];m[g]=m[b],m[b]=w}const f=m[b][b];for(let w=0;w<2*p;w++)m[b][w]/=f;for(let w=0;w<p;w++){if(w===b)continue;const v=m[w][b];if(v!==0)for(let h=0;h<2*p;h++)m[w][h]-=v*m[b][h]}}return m.map(b=>b.slice(p))}function t(a,p){const m=a.length,b=new Array(p).fill(0);for(const w of a)for(let v=0;v<p;v++)b[v]+=w[v];for(let w=0;w<p;w++)b[w]/=m;const g=Array.from({length:p},()=>new Array(p).fill(0));for(const w of a)for(let v=0;v<p;v++){const h=w[v]-b[v];for(let c=v;c<p;c++)g[v][c]+=h*(w[c]-b[c])}const f=m>1?m-1:1;for(let w=0;w<p;w++)for(let v=w;v<p;v++)g[w][v]/=f,g[v][w]=g[w][v];return{mean:b,cov:g}}function i(a,p={}){const m=Number.isFinite(p.p)?p.p:U,b=Number.isFinite(p.ridge)?p.ridge:1e-6,g=a.length;if(!g)return null;const f=a[0].length;if(!f)return null;const w=new Array(g).fill(null),v=new Array(g).fill(null),h=new Array(g).fill(!1),c=[],j=[];for(let H=0;H<g;H++){const x=a[H];let F=x.length===f;const C=new Array(f);for(let B=0;F&&B<f;B++){const q=Number(x[B]);Number.isFinite(q)?C[B]=q:F=!1}F&&(c.push(H),j.push(C))}const E=f,O=u(E,m);if(j.length<=f)return{center:[],df:E,cutoff:O,singular:!0,used:j.length,distances:w,squared:v,flags:h,flagged:0};const{mean:T,cov:A}=t(j,f);let P=n(A),L=!1;if(!P){L=!0;let H=0;for(let C=0;C<f;C++)H+=A[C][C];const x=H/f*b||b,F=A.map((C,B)=>C.map((q,Q)=>B===Q?q+x:q));if(P=n(F),!P)return{center:T,df:E,cutoff:O,singular:!0,used:j.length,distances:w,squared:v,flags:h,flagged:0}}let z=0;for(let H=0;H<j.length;H++){const x=j[H],F=new Array(f);for(let q=0;q<f;q++)F[q]=x[q]-T[q];let C=0;for(let q=0;q<f;q++){let Q=0;for(let Y=0;Y<f;Y++)Q+=P[q][Y]*F[Y];C+=F[q]*Q}C<0&&(C=0);const B=c[H];v[B]=C,w[B]=Math.sqrt(C),C>O&&(h[B]=!0,z++)}return{center:T,df:E,cutoff:O,singular:L,used:j.length,distances:w,squared:v,flags:h,flagged:z}}const s=20,r=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function o(a,p={}){const m=p.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",b=Number.isFinite(p.windowLen)&&p.windowLen>=1?Math.floor(p.windowLen):s,g=Number.isFinite(p.threshold)?p.threshold:Z,f=Number.isFinite(p.k)?p.k:V,w=Number.isFinite(p.minPeriods)&&p.minPeriods>=1?Math.floor(p.minPeriods):b,v=a.length,h=new Array(v).fill(null),c=new Array(v).fill(!1);let j=0;for(let E=0;E<v;E++){const O=Number(a[E]);if(!Number.isFinite(O))continue;const T=Math.max(0,E-b+1),A=[];for(let P=T;P<=E;P++){const L=Number(a[P]);Number.isFinite(L)&&A.push(L)}if(!(A.length<w))if(m==="rollingIqr"){const P=S(A,{k:f});if(!P)continue;(O<P.lower||O>P.upper)&&(c[E]=!0,j++)}else{const P=I(A);if(!P||P.mad===0)continue;const L=W*(O-P.median)/P.mad;h[E]=L,Math.abs(L)>g&&(c[E]=!0,j++)}}return{method:m,windowLen:b,minPeriods:w,threshold:g,k:f,scores:h,flags:c,flagged:j}}function l(a={}){const p=a||{},m=p.field;if(typeof m!="string"||!m)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const b=p.method||"modifiedZScore";if(!(D.includes(b)||r.includes(b))||b==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method '${b}'`);const f=typeof p.orderBy=="string"?p.orderBy:null,w=p.latest===!0,v=r.includes(b),h=c=>Number(c==null?NaN:c[m]);return c=>{const j=Array.isArray(c)?c.slice():[...c];f&&j.sort((P,L)=>{const z=P?.[f],H=L?.[f];return z===H?0:z==null?-1:H==null?1:z<H?-1:1});const E=j.map(h);let O,T;if(v)({flags:O,scores:T}=o(E,{method:b,windowLen:p.windowLen,threshold:p.threshold,k:p.k,minPeriods:p.minPeriods}));else if(b==="iqr"){const P=S(E,{k:p.k});O=E.map(L=>P?Number.isFinite(L)&&(L<P.lower||L>P.upper):!1),T=E.map(()=>null)}else({flags:O,scores:T}=k(E,{threshold:p.threshold}));if(w){const P=O.length-1;return P<0||!O[P]?!1:{method:b,field:m,flagged:[{row:j[P],score:T[P]}]}}const A=[];for(let P=0;P<O.length;P++)O[P]&&A.push({row:j[P],score:T[P]});return A.length?{method:b,field:m,flagged:A}:!1}}}),Ce("packages/core/src/compute/forecast.js",function(e,G){"use strict";Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return a}});const _=G("packages/core/src/compute/special.js"),M=_.normalQuantile,$=_.studentTQuantile,W=G("packages/core/src/internal/util.js").warnOnce,Z=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),V=1e-4,U=1-1e-4;function D(p){const m=[];for(let b=0;b<p.length;b++){const g=p[b];if(g!==null&&typeof g=="object"){const f=Number.isFinite(g.at)?g.at:b,w=Number.isFinite(g.value)?g.value:null;m.push({at:f,value:w})}else m.push({at:b,value:Number.isFinite(g)?Number(g):null})}return m}function I(p){const m=p.filter(v=>v.value!==null),b=m[0],g=m[m.length-1],f=g.at-b.at,w=m.length>1&&f>0?f/(m.length-1):1;return{lastAt:g.at,step:w}}function k(p){return Math.min(U,Math.max(V,p))}function S(p,m=V,b=U,g=80){const f=(Math.sqrt(5)-1)/2;let w=m,v=b,h=v-f*(v-w),c=w+f*(v-w),j=p(h),E=p(c);for(let O=0;O<g;O++)j<E?(v=c,c=h,E=j,h=v-f*(v-w),j=p(h)):(w=h,h=c,j=E,c=w+f*(v-w),E=p(c));return(w+v)/2}function y(p,m){let b=null,g=0,f=0;for(let w=0;w<p.length;w++){const v=p[w];if(v!==null){if(b===null){b=v;continue}g+=(v-b)**2,f+=1,b=m*v+(1-m)*b}}return{level:b,sse:g,m:f}}function d(p,m,b){let g=null,f=null,w=0,v=0;for(let h=0;h<p.length;h++){const c=p[h];if(c===null){g!==null&&f!==null&&(g+=f);continue}if(g===null){g=c;continue}f===null&&(f=c-g);const j=g+f;w+=(c-j)**2,v+=1;const E=g;g=m*c+(1-m)*(E+f),f=b*(g-E)+(1-b)*f}return{level:g,trend:f,sse:w,m:v}}function u(p,m,b,g,f){const w=p.length;if(w<2*m)return null;const v=L=>{let z=0,H=0;for(let x=L;x<L+m&&x<w;x++)p[x]!==null&&(z+=p[x],H+=1);return H?z/H:null},h=v(0),c=v(m);if(h===null||c===null)return null;let j=h,E=(c-h)/m;const O=new Array(m).fill(0);for(let L=0;L<m;L++)O[L]=p[L]===null?0:p[L]-j;const T=O.reduce((L,z)=>L+z,0)/m;for(let L=0;L<m;L++)O[L]-=T;let A=0,P=0;for(let L=m;L<w;L++){const z=L%m,H=O[z],x=p[L];if(x===null){j+=E;continue}const F=j+E+H;A+=(x-F)**2,P+=1;const C=j;j=b*(x-H)+(1-b)*(j+E),E=g*(j-C)+(1-g)*E,O[z]=f*(x-j)+(1-f)*H}return{level:j,trend:E,season:O,phase:(w-1)%m,sse:A,count:P}}function n(p,m,b){let g=1;for(const w of m)g+=w*w;const f=Math.sqrt(p*g);return{se:f,margin:b*f}}function t(p,m={}){if(!p||typeof p.length!="number"||p.length===0)return null;const b=Z.includes(m.method)?m.method:"linear",g=Math.max(1,Math.floor(Number(m.horizon)||1)),f=Number.isFinite(m.confidence)&&m.confidence>0&&m.confidence<1?m.confidence:.95,w=1-(1-f)/2,v=D(p),h=v.map(A=>A.value),c=h.filter(A=>A!==null),j=c.length,{lastAt:E,step:O}=j?I(v):{lastAt:0,step:1},T=A=>E+A*O;return b==="linear"?i(v,j,g,f,w,T):b==="movingAverage"?s(c,j,g,f,w,m,T):b==="ses"?r(h,j,g,f,w,m,T):b==="holt"?o(h,j,g,f,w,m,T):l(h,j,g,f,w,m,T)}function i(p,m,b,g,f,w){if(m<2)return null;let v=0,h=0;for(const x of p)x.value!==null&&(v+=x.at,h+=x.value);v/=m,h/=m;let c=0,j=0,E=0;for(const x of p){if(x.value===null)continue;const F=x.at-v,C=x.value-h;c+=F*F,j+=F*C,E+=C*C}if(c===0)return null;const O=j/c,T=h-O*v,A=E===0?1:Math.max(0,Math.min(1,j*j/(c*E))),P=Math.max(0,E-O*j),L=m>2?Math.sqrt(P/(m-2)):null,z=m>2?$(f,m-2):null,H=[];for(let x=1;x<=b;x++){const F=w(x),C=T+O*F;let B=null,q=null,Q=null,Y=null,J=null;if(L!==null){const te=1/m+(F-v)**2/c,ee=L*Math.sqrt(1+te),re=L*Math.sqrt(te);J=ee,B=C-z*ee,q=C+z*ee,Q=C-z*re,Y=C+z*re}H.push({step:x,at:F,mean:C,lower:B,upper:q,lowerMean:Q,upperMean:Y,se:J})}return{method:"linear",horizon:b,confidence:g,n:m,sigma:L,r2:A,params:{slope:O,intercept:T},points:H}}function s(p,m,b,g,f,w,v){if(m<1)return null;const h=Math.max(1,Math.min(m,Math.floor(Number(w.windowLen)||m))),c=p.slice(m-h);let j=0;for(const L of c)j+=L;const E=j/h;let O=null,T=null;if(h>1){let L=0;for(const H of c)L+=(H-E)**2;O=Math.sqrt(L/(h-1))*Math.sqrt(1+1/h),T=$(f,h-1)}const A=O===null?null:T*O,P=[];for(let L=1;L<=b;L++)P.push({step:L,at:v(L),mean:E,lower:A===null?null:E-A,upper:A===null?null:E+A,se:O});return{method:"movingAverage",horizon:b,confidence:g,n:m,sigma:O===null?null:O,params:{windowLen:h},points:P}}function r(p,m,b,g,f,w,v){if(m<1)return null;let h=Number.isFinite(w.alpha)?k(w.alpha):null;h===null&&(h=S(T=>y(p,T).sse));const c=y(p,h),j=M(f),E=c.m>0?c.sse/c.m:null,O=[];for(let T=1;T<=b;T++){const A=c.level;let P=null,L=null,z=null;if(E!==null){const H=[];for(let F=1;F<T;F++)H.push(h);const x=n(E,H,j);z=x.se,P=A-x.margin,L=A+x.margin}O.push({step:T,at:v(T),mean:A,lower:P,upper:L,se:z})}return{method:"ses",horizon:b,confidence:g,n:m,sigma:E===null?null:Math.sqrt(E),params:{alpha:h},points:O}}function o(p,m,b,g,f,w,v){if(m<2)return null;let h=Number.isFinite(w.alpha)?k(w.alpha):null,c=Number.isFinite(w.beta)?k(w.beta):null;if(h===null||c===null){let P=h===null?.5:h,L=c===null?.5:c;for(let z=0;z<6;z++)h===null&&(P=S(H=>d(p,H,L).sse)),c===null&&(L=S(H=>d(p,P,H).sse));h=h===null?P:h,c=c===null?L:c}const j=d(p,h,c),E=M(f),O=j.m>0?j.sse/j.m:null,T=h*c,A=[];for(let P=1;P<=b;P++){const L=j.level+P*j.trend;let z=null,H=null,x=null;if(O!==null){const F=[];for(let B=1;B<P;B++)F.push(h+B*T);const C=n(O,F,E);x=C.se,z=L-C.margin,H=L+C.margin}A.push({step:P,at:v(P),mean:L,lower:z,upper:H,se:x})}return{method:"holt",horizon:b,confidence:g,n:m,sigma:O===null?null:Math.sqrt(O),params:{alpha:h,beta:c},points:A}}function l(p,m,b,g,f,w,v){const h=Math.floor(Number(w.period));if(!(h>=2))return W("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(m<2*h)return null;let c=Number.isFinite(w.alpha)?k(w.alpha):null,j=Number.isFinite(w.beta)?k(w.beta):null,E=Number.isFinite(w.gamma)?k(w.gamma):null;const O=(x,F,C)=>{const B=u(p,h,x,F,C);return B?B.sse:1/0};if(c===null||j===null||E===null){let x=c===null?.5:c,F=j===null?.5:j,C=E===null?.5:E;for(let B=0;B<8;B++)c===null&&(x=S(q=>O(q,F,C))),j===null&&(F=S(q=>O(x,q,C))),E===null&&(C=S(q=>O(x,F,q)));c=c===null?x:c,j=j===null?F:j,E=E===null?C:E}const T=u(p,h,c,j,E);if(!T)return null;const A=M(f),P=T.count>0?T.sse/T.count:null,L=c*j,z=E*(1-c),H=[];for(let x=1;x<=b;x++){const F=T.season[(T.phase+x)%h],C=T.level+x*T.trend+F;let B=null,q=null,Q=null;if(P!==null){const Y=[];for(let te=1;te<x;te++)Y.push(c+te*L+(te%h===0?z:0));const J=n(P,Y,A);Q=J.se,B=C-J.margin,q=C+J.margin}H.push({step:x,at:v(x),mean:C,lower:B,upper:q,se:Q})}return{method:"holtWinters",horizon:b,confidence:g,n:m,sigma:P===null?null:Math.sqrt(P),params:{alpha:c,beta:j,gamma:E,period:h},points:H}}const a={FORECAST_METHODS:Z,forecast:t}}),Ce("packages/core/src/compute/hypothesis.js",function(e,G){"use strict";Object.defineProperty(e,"GROUP_TESTS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"NORMALITY_ALPHA",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"HL_PAIR_LIMIT",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"welchTTest",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"mannWhitneyUTest",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"chiSquareTest",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"compareGroups",{enumerable:!0,get:function(){return A}});const M=G("packages/core/src/internal/util.js").warnOnce,R=G("packages/core/src/compute/handle.js").valueReader,W=G("packages/core/src/compute/statistics.js"),Z=W.numbers,V=W.moments,U=W.frequencyMap,D=W.categoricalDistance,I=W.isNumericColumn,k=W.jarqueBera,S=W.proportionInterval,y=W.SUBSET_RELIABILITY_FLOOR,u=G("packages/core/src/compute/compare.js").pooledStandardMeanDifference,n=G("packages/core/src/compute/special.js"),t=n.studentT,i=n.studentTQuantile,s=n.normalCdf,r=n.normalQuantile,o=n.chiSquareUpperTail,l=Object.freeze({WELCH:"welch",MANN_WHITNEY:"mannWhitney",CHI_SQUARE:"chiSquare"}),a=.05,p=2e6;function m(P){const L=Number(P);return Number.isFinite(L)&&L>0&&L<1?L:.95}function b(P){const{n:L,mean:z,m2:H}=V(P);return{mean:z,sd:L>0?Math.sqrt(H/L):0,n:L}}function g(P,L){const z=P.length;if(z<2)return 0;let H=0;for(let x=0;x<z;x++){const F=P[x]-L;H+=F*F}return H/(z-1)}function f(P,L){return{name:"pooledStandardMeanDifference",value:u(b(P),b(L))}}function w(P,L,z){const H=P.length,x=L.length;if(H<2||x<2)return null;const F=m(z),{mean:C}=V(P),{mean:B}=V(L),q=g(P,C),Q=g(L,B),Y=q/H+Q/x;if(!(Y>0))return null;const J=Math.sqrt(Y),te=(C-B)/J,ee=q/H*(q/H)/(H-1),re=Q/x*(Q/x)/(x-1),se=Y*Y/(ee+re),de=Math.min(1,Math.max(0,2*(1-t(Math.abs(te),se)))),ie=C-B,oe=i(1-(1-F)/2,se)*J;return{test:l.WELCH,statistic:te,statisticName:"t",df:se,pValue:de,interval:{estimate:ie,lower:ie-oe,upper:ie+oe,confidence:F,method:"welch-t (difference of means)"},effectSize:f(P,L),nA:H,nB:x,reliable:H>=y&&x>=y,method:"Welch's t-test (unequal variances; Welch–Satterthwaite df)"}}function v(P){const L=P.length;if(L===0)return Number.NaN;const z=L>>1;return L%2?P[z]:(P[z-1]+P[z])/2}function h(P,L,z){const H=P.length,x=L.length,F=H*x;if(F===0||F>p)return null;const C=new Float64Array(F);let B=0;for(let ee=0;ee<H;ee++)for(let re=0;re<x;re++)C[B++]=P[ee]-L[re];C.sort();const q=v(C),Q=Math.sqrt(H*x*(H+x+1)/12),Y=r(1-(1-z)/2);let J=Math.round(F/2-Y*Q);J>=0||(J=0);const te=Math.floor((F-1)/2);return J>te&&(J=te),{estimate:q,lower:C[J],upper:C[F-1-J],confidence:z,method:"hodges-lehmann (normal approximation)"}}function c(P,L,z){const H=P.length,x=L.length;if(H<1||x<1)return null;const F=m(z),C=H+x,B=new Array(C);for(let de=0;de<H;de++)B[de]={v:P[de],g:0};for(let de=0;de<x;de++)B[H+de]={v:L[de],g:1};B.sort((de,ie)=>de.v-ie.v);let q=0,Q=0,Y=0;for(;Y<C;){let de=Y;for(;de<C&&B[de].v===B[Y].v;)de++;const ie=de-Y,oe=(Y+1+de)/2;for(let ue=Y;ue<de;ue++)B[ue].g===0&&(q+=oe);Q+=ie*ie*ie-ie,Y=de}const J=q-H*(H+1)/2,te=H*x/2,ee=H*x/12*(C+1-Q/(C*(C-1)));let re=1;if(ee>0){const de=Math.max(0,Math.abs(J-te)-.5);re=Math.min(1,2*s(-de/Math.sqrt(ee)))}const se=h(P,L,F);return{test:l.MANN_WHITNEY,statistic:J,statisticName:"U",df:null,pValue:re,interval:se,effectSize:f(P,L),nA:H,nB:x,reliable:H>=y&&x>=y,method:"Mann-Whitney U (normal approximation, tie- and continuity-corrected)"}}function j(P,L,z,H,x){const F=S(P,L,x),C=S(z,H,x);if(!F||!C)return null;const B=F.proportion-C.proportion,q=B-Math.sqrt((F.proportion-F.lower)**2+(C.upper-C.proportion)**2),Q=B+Math.sqrt((F.upper-F.proportion)**2+(C.proportion-C.lower)**2);return{lower:q,upper:Q}}function E(P,L,z,H,x,F={}){if(!(L>0)||!(H>0))return null;const C=new Set([...P.keys(),...z.keys()]),B=C.size;if(B<2)return null;const q=L+H;let Q=0;for(const re of C){const se=P.get(re)||0,de=z.get(re)||0,ie=se+de,oe=L*ie/q,ue=H*ie/q;oe>0&&(Q+=(se-oe)*(se-oe)/oe),ue>0&&(Q+=(de-ue)*(de-ue)/ue)}const Y=B-1,J=o(Q,Y);let te=null;F.category!==void 0&&C.has(F.category)?te=F.category:B===2&&([te]=[...C]);let ee=null;if(te!==null){const re=j(P.get(te)||0,L,z.get(te)||0,H,m(x));re&&(ee={estimate:(P.get(te)||0)/L-(z.get(te)||0)/H,lower:re.lower,upper:re.upper,confidence:m(x),method:"newcombe (difference in this category's share)",category:te})}return{test:l.CHI_SQUARE,statistic:Q,statisticName:"chiSquare",df:Y,pValue:J,interval:ee,effectSize:{name:"categoricalTotalVariation",value:D(P,L,z,H)},nA:L,nB:H,reliable:L>=y&&H>=y,method:"Pearson chi-square test of independence (2×k, no continuity correction)"}}function O(P){return P==null||P===""||typeof P=="number"&&Number.isNaN(P)?null:P instanceof Date?P.getTime():typeof P=="object"?String(P):P}function T(P,L,z){if(z===l.WELCH||z===l.MANN_WHITNEY)return{test:z,chosenBy:"override",reason:`caller override: ${z}`};const H=k(P),x=k(L),F=H===null?null:Math.exp(-H/2),C=x===null?null:Math.exp(-x/2);return F!==null&&F<a||C!==null&&C<a?{test:l.MANN_WHITNEY,chosenBy:"auto",reason:`column family: numeric, non-normal by Jarque-Bera (p < ${a})`}:{test:l.WELCH,chosenBy:"auto",reason:F!==null||C!==null?"column family: numeric, no departure from normality detected":"column family: numeric (too few rows to screen normality)"}}function A(P,L,z,H={}){if(!P||!L)return null;const x=m(H.confidence),F=R(L);let C;if(Array.isArray(H.groups)&&H.groups.length===2)C=[O(H.groups[0]),O(H.groups[1])];else{const{map:de}=U(L,z),ie=[...de.entries()].sort((oe,ue)=>ue[1]-oe[1]).slice(0,2).map(oe=>oe[0]);if(ie.length<2)return M("compareGroups:groups",'[lattice] compareGroups: the "by" column has fewer than two distinct values to group by.'),null;C=ie}const[B,q]=C;if(B===null||q===null||B===q)return M("compareGroups:distinct","[lattice] compareGroups: the two groups must be two distinct, present values."),null;const Q=[],Y=[];for(let de=0;de<z.length;de++){const ie=O(F(z[de]));ie===B?Q.push(z[de]):ie===q&&Y.push(z[de])}if(Q.length===0||Y.length===0)return M("compareGroups:empty","[lattice] compareGroups: one of the two groups has no rows in the current set."),null;const J=H.test&&H.test!=="auto"?String(H.test):null,te=I(P,Q.concat(Y));let ee,re,se;if(J===l.CHI_SQUARE||!J&&!te){re=J?"override":"auto",se=J?"caller override: chiSquare":"column family: categorical";const de=U(P,Q),ie=U(P,Y);ee=E(de.map,de.total,ie.map,ie.total,x,{category:H.category})}else{if((J===l.WELCH||J===l.MANN_WHITNEY)&&!te)return M("compareGroups:numeric-override",`[lattice] compareGroups: ${J} needs a numeric column, but the column is not numeric.`),null;const de=Z(P,Q),ie=Z(P,Y),oe=T(de,ie,J);re=oe.chosenBy,se=oe.reason,ee=oe.test===l.MANN_WHITNEY?c(de,ie,x):w(de,ie,x)}return ee?{...ee,chosenBy:re,reason:se,groups:[B,q]}:(M("compareGroups:degenerate","[lattice] compareGroups: the chosen test had too little to work with (too few values, or no variation)."),null)}}),Ce("packages/core/src/columns/detailcolumn.js",function(e,G){"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 R}});const _="__lattice_detail",M=36;function $(W){const Z=W.config&&W.config.detailColumnWidth||M;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(V,U){return!!(U&&U.expanded)},formatValue(){return""}}}const R=$}),Ce("packages/core/src/columns/treecolumn.js",function(e,G){"use strict";Object.defineProperty(e,"TREE_COLUMN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createTreeColumn",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="__lattice_tree",R=260;function W(V){const U=V.tree||{},D=V.config&&V.config.treeColumnWidth||R,I=()=>(V.columns&&M(V.columns.visible)?V.columns.visible():[]).find(d=>!d.generated)||null,k=(y,d)=>{if(d&&d.group)return d.groupValue;if(M(U.label))return U.label(y,d);if(typeof U.label=="string")return y==null?null:y[U.label];const u=I();return u&&M(u.getValue)?u.getValue(y,d):null},S=()=>{if(U.title)return U.title;const y=typeof U.label=="string"?V.columns&&M(V.columns.get)?V.columns.get(U.label):null:I();return y&&(y.title||y.id)||"Hierarchy"};return{id:$,get title(){return S()},field:null,type:"text",dataType:{base:"text"},nullable:!0,align:"start",generated:!0,value:{pure:!0},cell:{render:"group"},edit:{enabled:!1},sort:{enabled:!0,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},pivot:{enabled:!1,index:0},total:null,lookup:null,layout:{width:D,min:140,pin:V.config&&V.config.treeColumnPin||null,hidden:!1,resizable:!0,movable:!1,lockPosition:!0},header:{},export:{csv:!1,excel:!1},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(y,d){return k(y,d)},formatValue(y,d){if(d&&d.grandTotal)return V.config&&V.config.grandTotalLabel||"Total";if(y==null)return"";if(!U.label){const u=I();if(u&&M(u.formatValue))return u.formatValue(y,d)}return String(y)}}}const Z=W}),Ce("packages/core/src/columns/pivotcolumns.js",function(e,G){"use strict";Object.defineProperty(e,"PIVOT_PREFIX",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createPivotColumns",{enumerable:!0,get:function(){return W}});const M=G("packages/core/src/internal/util.js").warnOnce,$="__lattice_pivot",R=500;function W(D){const{pivot:I,valueColumns:k,config:S}=D,y=I&&I.paths||[],d=D.separator||S&&S.pivot&&S.pivot.separator||" | ",u=S&&S.pivot&&S.pivot.maxColumns||R;if(!y.length||!k.length)return{tree:[],leaves:[],error:null};const n=Z(S),t=y.length*k.length+(n?k.length:0);if(t>u){const r=`pivot would generate ${t} columns, above the limit of ${u}. Pivot on a lower-cardinality column, or raise pivot.maxColumns.`;return M(`pivot.maxColumns:${t}`,r),{tree:[],leaves:[],error:r}}const i=[],s=[];for(const r of y){const o=[];for(const l of k){const a=U(r,l,d);o.push(a),s.push(a)}o.length===1?(o[0].title=String(r),i.push(o[0])):i.push({id:`${$}:group:${r}`,title:String(r),columns:o,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0})}if(n){const r=k.map(l=>V(l,S));s.push(...r);const o=S&&S.pivot&&S.pivot.totalsLabel||"Total";if(r.length===1)r[0].title=o,n==="before"?i.unshift(r[0]):i.push(r[0]);else{const l={id:`${$}:group:__totals`,title:o,columns:r,collapsible:!1,openByDefault:!0,showWhen:"always",marryChildren:!0,generated:!0};n==="before"?i.unshift(l):i.push(l)}}return{tree:i,leaves:s,error:null}}function Z(D){const I=D&&D.pivot&&D.pivot.groupTotals;return I==="before"||I==="after"?I:null}function V(D,I){return{id:`${$}:__total${I&&I.pivot&&I.pivot.separator||" | "}${D.id}`,field:null,title:D.title||D.id,type:D.type,dataType:D.dataType,nullable:!0,align:D.align,generated:!0,pivot:{enabled:!1,index:0,sourceId:D.id,total:!0},value:{pure:!0},cell:{align:D.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:D.total,lookup:null,layout:{width:D.layout&&D.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(k,S){const y=S&&S.totals;return y&&Object.hasOwn(y,D.id)?y[D.id]:null},formatValue(k,S){return k==null?"":D.formatValue?D.formatValue(k,S):String(k)}}}function U(D,I,k){return{id:`${$}:${D}${k}${I.id}`,field:null,title:I.title||I.id,type:I.type,dataType:I.dataType,nullable:!0,align:I.align,generated:!0,pivot:{enabled:!1,index:0,path:D,sourceId:I.id},value:{pure:!0},cell:{align:I.align},edit:{enabled:!1},sort:{enabled:!1,direction:null},filter:{enabled:!1},group:{enabled:!1,index:0,explode:!1},total:I.total,lookup:null,layout:{width:I.layout&&I.layout.width||120,min:80,pin:null,hidden:!1,resizable:!0,movable:!1},header:{},export:{csv:!0,excel:!0},allowGroup:!1,allowPivot:!1,allowTotal:!1,def:{},getValue(){return null},formatValue(S,y){return S==null?"":I.formatValue?I.formatValue(S,y):String(S)}}}}),Ce("packages/core/src/compute/group.js",function(e,G){"use strict";Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return S}});const _=G("packages/core/src/compute/handle.js"),M=_.dictSize,$=_.identity,R=_.presenceReader,W=_.rowCount,Z=_.valueReader,V="",U="\0",D=1<<20;function I(y,d,u,n){const t=y.length,i=y.map(p=>Z(p)),s=Array.isArray(n)&&n.some(Boolean),r=s?i.map((p,m)=>n[m]?b=>n[m](p(b)):p):i;if(!s&&t>0&&y.every(p=>p&&p.kind==="dictionary"&&p.dict)){const p=y.map(b=>M(b.dict)+1);let m=1;for(let b=0;b<t;b++)m*=p[b];if(m<=Number.MAX_SAFE_INTEGER){const b=y.map(v=>v.values),g=y.map(v=>R(v)),f=v=>{let h=0;for(let c=0;c<t;c++){const j=g[c],E=j&&j(v)===0?p[c]-1:b[c][v];h=h*p[c]+E}return h},w=new Float64Array(u);for(let v=0;v<u;v++)w[v]=f(d[v]);return{packed:w,strings:null,product:m,readers:r,keyOf:f}}}const l=p=>{let m="";for(let b=0;b<t;b++){const g=r[b](p);m+=(b===0?"":V)+(g==null?U:String(g))}return m},a=new Array(u);for(let p=0;p<u;p++)a[p]=l(d[p]);return{packed:null,strings:a,product:1/0,readers:r,keyOf:l}}function k(y,d,u,n){const t=new Uint32Array(n+1);for(let o=0;o<u;o++)t[d[o]+1]++;for(let o=0;o<n;o++)t[o+1]+=t[o];const i=new Uint32Array(u),s=t.slice(0,n);for(let o=0;o<u;o++)i[s[d[o]]++]=y[o];const r=new Array(n);for(let o=0;o<n;o++)r[o]=i.subarray(t[o],t[o+1]);return r}function S(y,d,u={}){const n=y||[],t=d||$(W(n[0],u)),i=t.length;if(n.length===0||i===0)return{keys:[],buckets:[]};const{packed:s,strings:r,product:o,readers:l}=I(n,t,i,u.project),a=new Uint32Array(i);let p=0,m=null;if(s&&o<=Math.max(1024,Math.min(D,i*4))){const w=o,v=new Int32Array(w).fill(-1);for(let h=0;h<i;h++)v[s[h]]=0;for(let h=0;h<w;h++)v[h]===0&&(v[h]=p++);for(let h=0;h<i;h++)a[h]=v[s[h]];m=new Float64Array(p);for(let h=0;h<w;h++)v[h]>=0&&(m[v[h]]=h)}else if(s){const w=new Map;for(let v=0;v<i;v++){const h=s[v];let c=w.get(h);c===void 0&&(c=p++,w.set(h,c)),a[v]=c}m=new Float64Array(p);for(const[v,h]of w)m[h]=v}else{const w=new Map;for(let v=0;v<i;v++){const h=r[v];let c=w.get(h);c===void 0&&(c=p++,w.set(h,c)),a[v]=c}}const b=k(t,a,i,p),g=new Array(p);for(let w=0;w<p;w++){const v=b[w][0],h=new Array(l.length);for(let c=0;c<l.length;c++)h[c]=l[c](v);g[w]=h}const f={keys:g,buckets:b};return m&&(f.packed=m),f}}),Ce("packages/core/src/compute/pivot.js",function(e,G){"use strict";Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return i}});const M=G("packages/core/src/internal/util.js").warnOnce,R=G("packages/core/src/compute/handle.js").valueComparator,Z=G("packages/core/src/compute/group.js").packKeys,U=G("packages/core/src/compute/total.js").total,D="|",I="/",k=2e3;function S(o,l,a){return`${o}${D}${l}${D}${a}`}function y(o,l){let a="";for(let p=0;p<o.length;p++){const m=o[p];a+=(p===0?"":l)+(m==null?"":String(m))}return a}function d(o,l,a={}){const p=a.separator||I,m=l.length,{keyOf:b,readers:g}=Z(o,l,0),f=new Map,w=[],v=[];for(let A=0;A<m;A++){const P=l[A],L=b(P);if(f.has(L))continue;f.set(L,w.length),v.push(L);const z=new Array(g.length);for(let H=0;H<g.length;H++)z[H]=g[H](P);w.push(z)}const h=R(a.locale),c=w.map((A,P)=>P);c.sort((A,P)=>{const L=w[A],z=w[P];for(let H=0;H<L.length;H++){const x=u(L[H],z[H],h);if(x!==0)return x}return A-P});const j=new Array(c.length),E=new Array(c.length),O=new Map;for(let A=0;A<c.length;A++){const P=c[A];j[A]=w[P],E[A]=y(w[P],p),O.set(v[P],A)}return{keys:j,paths:E,idOf:A=>{const P=O.get(b(A));return P===void 0?-1:P}}}function u(o,l,a){const p=o==null,m=l==null;return p||m?p&&m?0:p?1:-1:a(o,l)}function n(o){const l=o.values||o.totals||[];if(l.length&&typeof l[0]=="object"&&l[0]!==null)return l.filter(b=>b&&b.handle);const a=typeof o.handle=="function"?o.handle:null;if(!a)return l.length&&M("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const p=typeof o.totalOf=="function"?o.totalOf:null,m=[];for(const b of l){const g=a(b);g&&m.push({colId:b,handle:g,fn:p?p(b):"sum"})}return m}function t(o,l,a){if(Array.isArray(o)){const p=a||{};return{...p,pivotHandles:o,order:l||null,groups:p.groups||null}}return o||{}}function i(o,l,a){const p=t(o,l,a),m=p.separator||I,b=n(p),g=p.maxColumns===void 0?k:p.maxColumns,f=p.groups&&p.groups.buckets?p.groups:null,w=f?f.buckets:[p.order||new Uint32Array(0)],v=p.groupPaths||(f?f.keys.map(L=>y(L,m)):[""]),h=r(w),{keys:c,paths:j,idOf:E}=d(p.pivotHandles||[],h,p),O=j.length*Math.max(1,b.length),T=s(j,b,m);if(g&&O>g){const L=new Map;return{keys:c,paths:j,fields:T,groupPaths:v,columns:O,values:L,cells:L,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${O} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:O,maxColumns:g}}}const A=new Map,P=j.length;for(let L=0;L<w.length;L++){const z=w[L],H=v[L]===void 0?"":v[L],x=z.length;if(x===0)continue;const F=new Int32Array(x),C=new Uint32Array(P+1);for(let Q=0;Q<x;Q++){const Y=E(z[Q]);F[Q]=Y,Y>=0&&C[Y+1]++}for(let Q=0;Q<P;Q++)C[Q+1]+=C[Q];const B=new Uint32Array(x),q=C.slice(0,P);for(let Q=0;Q<x;Q++){const Y=F[Q];Y>=0&&(B[q[Y]++]=z[Q])}for(let Q=0;Q<P;Q++){const Y=C[Q],J=C[Q+1];if(J===Y)continue;const te=B.subarray(Y,J);for(let ee=0;ee<b.length;ee++){const re=b[ee],se=U(re.handle,te,re.fn,p.totalContext||{locale:p.locale});A.set(S(H,j[Q],re.colId),se)}}}return{keys:c,paths:j,fields:T,groupPaths:v,columns:O,values:A,cells:A,error:null}}function s(o,l,a){if(l.length===0)return o.slice();const p=[];for(const m of o)for(const b of l)p.push(`${m}${a}${b.colId}`);return p}function r(o){if(o.length===1)return o[0]||new Uint32Array(0);let l=0;for(const m of o)l+=m?m.length:0;const a=new Uint32Array(l);let p=0;for(const m of o)!m||m.length===0||(a.set(m,p),p+=m.length);return a}}),Ce("packages/core/src/store/bitset.js",function(e,G){"use strict";Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return M}});const _=8;class M{static#e=new Uint8Array(256);static{for(let R=1;R<256;R++)M.#e[R]=M.#e[R>>1]+(R&1)}#t;#n;constructor(R=0){const W=Math.max(0,R|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(R){return R<0||R>=this.#n?0:this.#t[R>>3]>>(R&7)&1}set(R){return R>=0&&R<this.#n&&(this.#t[R>>3]|=1<<(R&7)),this}clear(R){return R>=0&&R<this.#n&&(this.#t[R>>3]&=~(1<<(R&7))),this}assign(R,W){return W?this.set(R):this.clear(R)}fill(R=!1){return this.#t.fill(R?255:0),R&&this.#r(),this}grow(R){const W=Math.max(0,R|0);if(W<=this.#n)return this;const Z=Math.ceil(W/_);if(Z>this.#t.length){const V=new Uint8Array(Z);V.set(this.#t),this.#t=V}return this.#n=W,this}count(){const R=this.#t,W=M.#e;let Z=0;for(let V=0;V<R.length;V++)Z+=W[R[V]];return Z}and(R){const W=R instanceof M?R.words:R,Z=this.#t,V=Math.min(Z.length,W.length);for(let U=0;U<V;U++)Z[U]&=W[U];for(let U=V;U<Z.length;U++)Z[U]=0;return this}or(R){const W=R instanceof M?R.words:R,Z=this.#t,V=Math.min(Z.length,W.length);for(let U=0;U<V;U++)Z[U]|=W[U];return this}not(){const R=this.#t;for(let W=0;W<R.length;W++)R[W]=~R[W]&255;return this.#r(),this}clone(){const R=new M(this.#n);return R.words.set(this.#t.subarray(0,R.words.length)),R}release(){this.#t=new Uint8Array(0),this.#n=0}#r(){const R=this.#n&7;if(R===0)return;const W=this.#n>>3;W<this.#t.length&&(this.#t[W]&=(1<<R)-1)}static from(R){const W=Array.isArray(R)?R:Array.from(R),Z=new M(W.length);for(let V=0;V<W.length;V++)W[V]&&Z.set(V);return Z}}}),Ce("packages/core/src/store/dictionary.js",function(e,G){"use strict";Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return R}});const _=G("packages/core/src/internal/util.js"),M=_.collator,$=_.defaultCompare;class R{#e;#t=new Map;#n=0;#r=null;#o=-1;#i="\0";constructor(Z=[]){this.#e=[];for(let V=0;V<Z.length;V++){const U=Z[V];this.#t.has(U)||(this.#t.set(U,this.#e.length),this.#e.push(U))}}get size(){return this.#e.length}get version(){return this.#n}get bytes(){let Z=this.#e.length*8;for(let V=0;V<this.#e.length;V++){const U=this.#e[V];typeof U=="string"&&(Z+=U.length*2),Z+=16}return Z}codeOf(Z){const V=this.#t.get(Z);if(V!==void 0)return V;const U=this.#e.length;return this.#e.push(Z),this.#t.set(Z,U),this.#n++,U}lookup(Z){const V=this.#t.get(Z);return V===void 0?-1:V}has(Z){return this.#t.has(Z)}valueOf(Z){return this.#e[Z]}values(){return this.#e}ranks(Z){const V=Z||"";if(this.#r&&this.#o===this.#n&&this.#i===V)return this.#r;const U=this.#e.length,D=new Array(U);for(let y=0;y<U;y++)D[y]=y;const I=M(Z).compare,k=this.#e;D.sort((y,d)=>this.#s(k[y],k[d],I));const S=new Uint32Array(U);for(let y=0;y<U;y++)S[D[y]]=y;return this.#r=S,this.#o=this.#n,this.#i=V,S}#s(Z,V,U){return typeof Z=="string"&&typeof V=="string"?U(Z,V):$(Z,V)}}}),Ce("packages/core/src/store/multivalue.js",function(e,G){"use strict";Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return _}});class _{#e;#t;#n=0;#r=0;constructor($={}){const R=Math.max(1,$.rows??16),W=Math.max(1,$.values??R);this.#e=new Int32Array(W),this.#t=new Uint32Array(R+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($,R){if($<0||$>=this.#n)return!1;const W=this.#e,Z=this.#t[$+1];for(let V=this.#t[$];V<Z;V++)if(W[V]===R)return!0;return!1}hasAny($,R){for(let W=0;W<R.length;W++)if(this.has($,R[W]))return!0;return!1}hasAll($,R){for(let W=0;W<R.length;W++)if(!this.has($,R[W]))return!1;return!0}hasNone($,R){return!this.hasAny($,R)}push($){const R=this.#n,W=$.length;this.#o(R+1),this.#i(this.#r+W);const Z=this.#r;for(let V=0;V<W;V++)this.#e[Z+V]=$[V]|0;return this.#r+=W,this.#n=R+1,this.#t[R]=Z,this.#t[R+1]=this.#r,R}write($,R){if($===this.#n){this.push(R);return}if($<0||$>this.#n)return;const W=this.#t[$],Z=this.#t[$+1],V=R.length;if(Z-W===V){for(let U=0;U<V;U++)this.#e[W+U]=R[U]|0;return}this.#s($,R)}compact($,R,W){const Z=this.#e,V=this.#t,U=this.#n,D=new Int32Array(Math.max(1,this.#r)),I=new Uint32Array(R+1);let k=0;for(let S=0;S<U;S++){if($[S]===W)continue;const y=V[S],d=V[S+1];I[$[S]]=k;for(let u=y;u<d;u++)D[k++]=Z[u];I[$[S]+1]=k}this.#e=D,this.#t=I,this.#n=R,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 R=this.#t.length-1;for(;R<$;)R=R*2||16;const W=new Uint32Array(R+1);W.set(this.#t),this.#t=W}#i($){if($<=this.#e.length)return;let R=this.#e.length;for(;R<$;)R=R*2||16;const W=new Int32Array(R);W.set(this.#e),this.#e=W}#s($,R){const W=this.#e,Z=this.#t,V=this.#n,U=R.length-(Z[$+1]-Z[$]),D=new Int32Array(Math.max(1,this.#r+U)),I=new Uint32Array(Z.length);let k=0;for(let S=0;S<V;S++){if(I[S]=k,S===$)for(let y=0;y<R.length;y++)D[k++]=R[y]|0;else for(let y=Z[S];y<Z[S+1];y++)D[k++]=W[y];I[S+1]=k}this.#e=D,this.#t=I,this.#r=k}}}),Ce("packages/core/src/compute/sort.js",function(e,G){"use strict";Object.defineProperty(e,"radixSortFloat64",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"radixSortInt32",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"rankSortDictionary",{enumerable:!0,get:function(){return m}}),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 h}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return P}});const _=G("packages/core/src/compute/handle.js"),M=_.bitReader,$=_.dictRanks,R=_.dictSize,W=_.identity,Z=_.isMissing,V=_.presenceReader,U=_.rowCount,D=_.valueComparator,I=_.valueReader,k=new Uint32Array(0),S=new ArrayBuffer(8),y=new Float64Array(S),d=new Uint32Array(S),u=(y[0]=-1,(d[1]&2147483648)!==0?1:0),n=u===1?0:1;function t(z,H){y[0]=z;let x=d[u],F=d[n];(x&2147483648)!==0?(x=~x>>>0,F=~F>>>0):x=(x^2147483648)>>>0,H[0]=F,H[1]=x}function i(z,H,x,F){if(F<2)return z;const C=new Uint32Array(256*8);for(let re=0;re<F;re++){const se=H[re],de=x[re];C[se&255]++,C[256+(se>>>8&255)]++,C[512+(se>>>16&255)]++,C[768+(se>>>24&255)]++,C[1024+(de&255)]++,C[1280+(de>>>8&255)]++,C[1536+(de>>>16&255)]++,C[1792+(de>>>24&255)]++}let B=z,q=H,Q=x,Y=new Uint32Array(F),J=new Uint32Array(F),te=new Uint32Array(F);const ee=new Uint32Array(256);for(let re=0;re<8;re++){const se=re<<8,de=(re&3)<<3,ie=re>=4;let oe=!1;for(let pe=0;pe<256;pe++)if(C[se+pe]===F){oe=!0;break}if(oe)continue;let ue=0;for(let pe=0;pe<256;pe++)ee[pe]=ue,ue+=C[se+pe];for(let pe=0;pe<F;pe++){const Me=q[pe],$e=Q[pe],je=(ie?$e:Me)>>>de&255,ke=ee[je]++;Y[ke]=B[pe],J[ke]=Me,te[ke]=$e}let ce=B;B=Y,Y=ce,ce=q,q=J,J=ce,ce=Q,Q=te,te=ce}return B}function s(z,H,x){if(x<2)return z;const F=new Uint32Array(256*4);for(let J=0;J<x;J++){const te=H[J];F[te&255]++,F[256+(te>>>8&255)]++,F[512+(te>>>16&255)]++,F[768+(te>>>24&255)]++}let C=z,B=H,q=new Uint32Array(x),Q=new Uint32Array(x);const Y=new Uint32Array(256);for(let J=0;J<4;J++){const te=J<<8,ee=J<<3;let re=!1;for(let ie=0;ie<256;ie++)if(F[te+ie]===x){re=!0;break}if(re)continue;let se=0;for(let ie=0;ie<256;ie++)Y[ie]=se,se+=F[te+ie];for(let ie=0;ie<x;ie++){const oe=B[ie],ue=Y[oe>>>ee&255]++;q[ue]=C[ie],Q[ue]=oe}let de=C;C=q,q=de,de=B,B=Q,Q=de}return C}function r(z,H,x,F){const C=new Uint32Array(F+1);for(let Q=0;Q<x;Q++)C[H[Q]]++;let B=0;for(let Q=0;Q<=F;Q++){const Y=C[Q];C[Q]=B,B+=Y}const q=new Uint32Array(x);for(let Q=0;Q<x;Q++)q[C[H[Q]]++]=z[Q];return q}function o(z,H,x,F){return x<2?z:F<=65536||F<=x*2?r(z,H,x,F):s(z,H,x)}function l(z,H){return z.length===H&&z.byteOffset===0?z:Uint32Array.prototype.slice.call(z,0,H)}function a(z,H,x=!1){const F=H||W(z.length),C=F.length;if(C<2)return Uint32Array.from(F);const B=new Uint32Array(C),q=new Uint32Array(C),Q=new Uint32Array(C),Y=new Uint32Array(C),J=new Uint32Array(2);let te=0,ee=0;for(let de=0;de<C;de++){const ie=F[de],oe=z[ie];if(Number.isNaN(oe)){Y[ee++]=ie;continue}t(oe,J),x?(q[te]=~J[0]>>>0,Q[te]=~J[1]>>>0):(q[te]=J[0],Q[te]=J[1]),B[te++]=ie}const re=i(B.subarray(0,te),q.subarray(0,te),Q.subarray(0,te),te);if(ee===0)return l(re,te);const se=new Uint32Array(C);return se.set(re.subarray(0,te),0),se.set(Y.subarray(0,ee),te),se}function p(z,H,x=!1){const F=H||W(z.length),C=F.length;if(C<2)return Uint32Array.from(F);const B=Uint32Array.from(F),q=new Uint32Array(C);for(let Q=0;Q<C;Q++){const Y=(z[B[Q]]^2147483648)>>>0;q[Q]=x?~Y>>>0:Y}return l(s(B,q,C),C)}function m(z,H,x={}){const F=H||W(U(z,x)),C=F.length;if(C<2)return Uint32Array.from(F);const B=$(z.dict,x.locale),q=z.values,Q=V(z),Y=Math.max(R(z.dict),B.length),J=Y,te=Uint32Array.from(F),ee=new Uint32Array(C),re=!!x.descending;for(let se=0;se<C;se++){const de=te[se];let ie=Q&&Q(de)===0?J:B[q[de]];ie===void 0&&(ie=J),ee[se]=re?J-ie:ie}return l(o(te,ee,C,Y+1),C)}function b(z,H,x){const F=H.length;let C=Uint32Array.from(H);if(F<2)return C;let B=new Uint32Array(F);for(let q=1;q<F;q<<=1){for(let Y=0;Y<F;Y+=q<<1){const J=Math.min(Y+q,F),te=Math.min(Y+(q<<1),F);let ee=Y,re=J,se=Y;for(;ee<J&&re<te;)B[se++]=x(z[C[ee]],z[C[re]])<=0?C[ee++]:C[re++];for(;ee<J;)B[se++]=C[ee++];for(;re<te;)B[se++]=C[re++]}const Q=C;C=B,B=Q}return C}function g(z,H,x){const F=M(z.values),C=H.length,B=new Uint32Array(C),q=x?1:0;let Q=0;for(let Y=0;Y<C;Y++)F(H[Y])===q&&(B[Q++]=H[Y]);for(let Y=0;Y<C;Y++)F(H[Y])!==q&&(B[Q++]=H[Y]);return B}function f(z,H){const x=z.values,F=z.kind;if((F==="object"||F===void 0)&&(Array.isArray(x)||ArrayBuffer.isView(x))&&!z.presence)return x;const B=I(z),q=new Array(U(z)||0);for(let Q=0;Q<H.length;Q++){const Y=H[Q];q[Y]=B(Y)}return q}function w(z,H){for(let x=0;x<H.length;x++)if(typeof z[H[x]]!="string")return!1;return!0}function v(z,H,x,F,C){const B=z.length,q=Uint32Array.from(z);if(B<2||F<1)return q;const Q=new Uint32Array(B),Y=F-1;for(let J=0;J<B;J++){const te=x[H[J]];Q[J]=C?Y-te:te}return l(o(q,Q,B,F),B)}function h(z,H,x){const F=D(x),C=new Array(H);for(let q=0;q<H;q++)C[q]=q;C.sort((q,Q)=>F(z[q],z[Q])||q-Q);const B=new Uint32Array(H);for(let q=0;q<H;q++)B[C[q]]=q;return B}function c(z,H,x){const F=H.length,C=new Map,B=[],q=new Uint32Array(F);for(let J=0;J<F;J++){const te=z[H[J]];let ee=C.get(te);ee===void 0&&(ee=B.length,C.set(te,ee),B.push(te)),q[J]=ee}const Q=B.length,Y=h(B,Q,x.locale);return v(H,q,Y,Q,!!x.descending)}function j(z,H,x){const F=f(z,H);if(H.length>=2&&w(F,H)){const q=z.stringRank;return q&&q.version===z.version&&q.usable(H,F,x.locale)?q.sort(H,x):c(F,H,x)}const C=D(x.locale),B=x.descending?(q,Q)=>C(Q,q):C;return b(F,H,B)}function E(z,H,x){const F=f(z,H),C=x.compare,q=!!x.descending?(Q,Y)=>-C(Q,Y,void 0,void 0,!0):(Q,Y)=>C(Q,Y,void 0,void 0,!1);return b(F,H,q)}function O(z,H){const x=H.length,F=V(z),C=z.values,B=z.kind==="float64"&&!!C,q=z.kind==="object"||z.kind==="multi"||z.kind===void 0;if(!F&&!B&&!q)return{present:H,absent:k};const Q=new Uint32Array(x),Y=new Uint32Array(x);let J=0,te=0;if(F&&B)for(let ee=0;ee<x;ee++){const re=H[ee];F(re)===1&&!Number.isNaN(C[re])?Q[J++]=re:Y[te++]=re}else if(B&&!F)for(let ee=0;ee<x;ee++){const re=H[ee];Number.isNaN(C[re])?Y[te++]=re:Q[J++]=re}else if(F&&!q)for(let ee=0;ee<x;ee++){const re=H[ee];F(re)===1?Q[J++]=re:Y[te++]=re}else{const ee=I(z);for(let re=0;re<x;re++){const se=H[re];Z(ee(se))?Y[te++]=se:Q[J++]=se}}return te===0?{present:H,absent:k}:{present:Q.subarray(0,J),absent:Y.subarray(0,te)}}function T(z,H,x){if(H.length===0)return z;const F=new Uint32Array(z.length+H.length);return x?(F.set(H,0),F.set(z,H.length)):(F.set(z,0),F.set(H,z.length)),F}function A(z,H,x={}){const F=H||W(U(z,x));if(!z||F.length<2)return Uint32Array.from(F);const{present:C,absent:B}=O(z,F);if(C.length===0)return Uint32Array.from(F);const q=!!x.descending;let Q;if(typeof x.compare=="function")Q=E(z,C,x);else switch(z.kind){case"float64":Q=a(z.values,C,q);break;case"int32":Q=p(z.values,C,q);break;case"dictionary":Q=m(z,C,x);break;case"bitset":Q=g(z,C,q);break;default:Q=j(z,C,x);break}return T(Q,B,!!x.nullsFirst)}function P(z,H,x,F={}){const C=H||[],B=C.length&&(C[0].handle||L(z,C[0].col))||z&&z[0];let q=x||W(U(B,F));for(let Q=C.length-1;Q>=0;Q--){const Y=C[Q],J=Y.handle||L(z,Y.col)||z&&z[Q];J&&(q=A(J,q,{descending:Y.descending!==void 0?!!Y.descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:Y.locale!==void 0?Y.locale:F.locale,compare:Y.compare}))}return q instanceof Uint32Array?q:Uint32Array.from(q)}function L(z,H){if(!(!z||H===void 0)){for(let x=0;x<z.length;x++)if(z[x]&&z[x].id===H)return z[x]}}}),Ce("packages/core/src/store/stringrank.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"StringRankIndex",{enumerable:!0,get:function(){return W}});const _=G("packages/core/src/compute/sort.js"),M=_.collateStringRanks,$=_.rankSortStrings,R=1e5;class W{#e=[];#t=new Map;#n;#r=0;#o=0;#i=-1;#s;#l=!1;#a=null;#u=-1;#c="\0";constructor(V=R){this.#s=V>0?V:R,this.#n=new Uint32Array(0)}get version(){return this.#i}set version(V){this.#i=V}get generation(){return this.#o}get size(){return this.#e.length}get capped(){return this.#l}get length(){return this.#r}get bytes(){let V=this.#n.byteLength;const U=this.#e;for(let D=0;D<U.length;D++)V+=U[D].length*2+24;return V}#d(V,U){const D=this.#t.get(V);if(D!==void 0)return D;if(this.#l)return-1;if(U&&this.#e.length>=this.#s)return this.#l=!0,-1;const I=this.#e.length;return this.#e.push(V),this.#t.set(V,I),this.#o++,I}build(V,U){const D=U|0;this.#e=[],this.#t=new Map,this.#o=0,this.#l=!1,this.#a=null,this.#u=-1,this.#n=new Uint32Array(D);for(let I=0;I<D;I++){const k=V[I],S=typeof k=="string"?this.#d(k,!1):-1;this.#n[I]=S<0?0:S}this.#r=D}append(V,U,D){const I=(U|0)+(D|0);if(I>this.#n.length){const k=new Uint32Array(I);k.set(this.#n.subarray(0,this.#r)),this.#n=k}for(let k=U|0;k<I;k++){const S=V[k],y=typeof S=="string"?this.#d(S,!0):-1;this.#n[k]=y<0?0:y}this.#r=Math.max(this.#r,I)}ranks(V){const U=V||"";if(this.#a&&this.#u===this.#o&&this.#c===U)return this.#a;const D=M(this.#e,this.#e.length,V);return this.#a=D,this.#u=this.#o,this.#c=U,D}usable(V,U,D){if(this.#l||this.#e.length===0)return!1;const I=this.#n,k=this.#e,S=this.#r;for(let y=0;y<V.length;y++){const d=V[y];if(d>=S||k[I[d]]!==U[d])return!1}return!0}sort(V,U){const D=this.ranks(U.locale),I=this.#e.length,k=V.length,S=new Uint32Array(k),y=this.#n;for(let d=0;d<k;d++)S[d]=y[V[d]];return $(V,S,D,I,!!U.descending)}}}),Ce("packages/core/src/store/columnstore.js",function(e,G){"use strict";Object.defineProperty(e,"REMOVED",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"toFloat",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"ColumnHandle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return m}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.isFunction,R=_.pathGetter,Z=G("packages/core/src/store/bitset.js").Bitset,U=G("packages/core/src/store/dictionary.js").Dictionary,I=G("packages/core/src/store/multivalue.js").MultiValue,S=G("packages/core/src/store/stringrank.js").StringRankIndex,y=4294967295,d=1024,u=5e3,n=.2,t=new Set(["float64","int32","bitset","dictionary","object","multi"]);function i(b){return b==null}function s(b){if(typeof b=="number")return b;if(b instanceof Date)return b.getTime();if(typeof b=="boolean")return b?1:0;const g=Number(b);return Number.isNaN(g)&&typeof b=="string"?Date.parse(b):g}function r(b){const g=s(b);return Number.isFinite(g)?g|0:0}function o(b){return i(b)?[]:Array.isArray(b)?b:[b]}function l(b,g){switch(b.kind){case"float64":case"int32":return b.buf[g];case"bitset":return b.bits.get(g)===1;case"dictionary":return b.dict.valueOf(b.buf[g]);case"multi":{const f=b.mv.at(g),w=new Array(f.length);for(let v=0;v<f.length;v++)w[v]=b.dict.valueOf(f[v]);return w}default:return b.buf[g]}}function a(b,g){switch(b.kind){case"float64":case"int32":return b.values[g];case"bitset":return(b.values[g>>3]&1<<(g&7))!==0;case"dictionary":return(b.table||[])[b.values[g]];case"multi":{const f=b.offsets[g],w=b.offsets[g+1],v=b.table||[],h=new Array(w-f);for(let c=f;c<w;c++)h[c-f]=v[b.values[c]];return h}default:return b.values[g]}}class p{#e;#t;#n;#r;#o;#i;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f;#m;#p=-1;#g=null;#w=0;#b=0;#v=null;#y=null;#S=!1;constructor(g,f){this.#e=g.id;const w=t.has(g.kind)?g.kind:"object";g.kind&&!t.has(g.kind)&&M(`store.kind.${g.id}`,`column "${g.id}" declares unknown storage kind "${g.kind}"; falling back to object`),this.#n=w,this.#t=w,this.#r=g.nullable!==!1,this.#s=g.dictionary??null,this.#i=f,this.#o=$(g.read)?g.read:R(g.field||g.id),this.#f=g.stringRankIndex!=="off",this.#m=typeof g.stringRankMaxDistinct=="number"?g.stringRankMaxDistinct:0,this.#v=new Map}get id(){return this.#e}get kind(){return this.#l?this.#t:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#S?null:this.#l?this.#t==="bitset"?this.#u.words:this.#t==="multi"?this.#c.values:this.#a:this.#T().values}get presence(){return this.#S||!this.#r?null:this.#l?this.#g:this.#T().presence}get dict(){return this.#S||!this.#l?null:this.#t==="dictionary"||this.#t==="multi"?this.#d:null}get stringRank(){if(this.#S||!this.#f||this.kind!=="object")return null;const g=this.values,f=this.#i.physical();if(!g||f===0)return null;if(this.#h===null){if(typeof g[0]!="string")return null;const w=new S(this.#A());return w.build(g,f),w.version=this.#b,this.#h=w,this.#p=this.#b,w.capped?null:w}return this.#h.length<f&&this.#h.append(g,this.#h.length,f-this.#h.length),this.#h.version=this.#b,this.#p=this.#b,this.#h.capped?null:this.#h}#A(){return this.#m}#j(){this.#h=null,this.#p=-1}get offsets(){return this.#S||!this.#l||this.#t!=="multi"?null:this.#c.offsets}get version(){return this.#b}get bytes(){let g=0;return this.#a&&(g+=this.#a.byteLength??this.#a.length*8),this.#u&&(g+=this.#u.bytes),this.#c&&(g+=this.#c.bytes),this.#g&&(g+=this.#g.bytes),this.#d&&(g+=this.#d.bytes),this.#v&&(g+=this.#v.size*24),g}get(g){if(!this.#S&&!(g<0||g>=this.#i.physical())){if(!this.#l)return this.#C(g);if(this.#r&&this.#g.get(g)===0)return null;switch(this.#t){case"float64":case"int32":return this.#a[g];case"bitset":return this.#u.get(g)===1;case"dictionary":return this.#d.valueOf(this.#a[g]);case"multi":{const f=this.#c.at(g),w=new Array(f.length);for(let v=0;v<f.length;v++)w[v]=this.#d.valueOf(f[v]);return w}default:return this.#a[g]}}}set(g,f){this.#S||(this.#l?this.#E(g,f):this.#v.set(g,f===void 0?null:f),this.#h&&this.#j(),this.#b++)}read(g){return this.#o(g)}appendColumn(g,f,w){if(this.#S||w<=0)return;if(!this.#l){this.#b++;return}const v=this.#o,h=this.#r,c=this.#g;let j=!1;switch(this.#t){case"float64":{const E=this.#a;for(let O=0;O<w;O++){const T=v(g[O]);if(typeof T=="number"){h&&c.set(f+O),E[f+O]=T;continue}const A=T==null;h?c.assign(f+O,!A):A&&(j=!0),E[f+O]=A?NaN:s(T)}break}case"int32":{const E=this.#a;for(let O=0;O<w;O++){const T=v(g[O]),A=T==null;h?c.assign(f+O,!A):A&&(j=!0),E[f+O]=A?0:r(T)}break}case"bitset":{const E=this.#u;for(let O=0;O<w;O++){const T=v(g[O]),A=T==null;h?c.assign(f+O,!A):A&&(j=!0),E.assign(f+O,!A&&!!T)}break}case"dictionary":{const E=this.#a,O=this.#d;for(let T=0;T<w;T++){const A=v(g[T]),P=A==null;h?c.assign(f+T,!P):P&&(j=!0),E[f+T]=P?0:O.codeOf(A)}break}case"multi":{const E=this.#c,O=this.#d;for(let T=0;T<w;T++){const A=v(g[T]),P=A==null;h?c.assign(f+T,!P):P&&(j=!0);const L=o(A),z=new Array(L.length);for(let H=0;H<L.length;H++)z[H]=O.codeOf(L[H]);E.write(f+T,z)}break}default:{const E=this.#a;for(let O=0;O<w;O++){const T=v(g[O]),A=T==null;h?c.assign(f+O,!A):A&&(j=!0),E[f+O]=A?null:T}break}}j&&M(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#h&&this.#t==="object"&&(this.#h.append(this.#a,f,w),this.#h.version=this.#b+1,this.#p=this.#b+1),this.#b++}appendPacked(g,f,w){if(this.#S||w<=0||!g)return;if(!this.#l){this.#b++;return}const v=this.#g,h=g.presence;if(v)if(h)for(let j=0;j<w;j++)v.assign(f+j,(h[j>>3]&1<<(j&7))!==0);else for(let j=0;j<w;j++)v.set(f+j);const c=g.kind===this.#t;if(c&&(this.#t==="float64"||this.#t==="int32")){this.#a.set(g.values,f),this.#b++;return}if(c&&this.#t==="bitset"){const j=g.values;for(let E=0;E<w;E++)this.#u.assign(f+E,(j[E>>3]&1<<(E&7))!==0);this.#b++;return}if(c&&this.#t==="dictionary"){const j=g.table||[],E=new Uint32Array(j.length);for(let P=0;P<j.length;P++)E[P]=this.#d.codeOf(j[P]);const O=g.values,T=this.#a,A=v;for(let P=0;P<w;P++){if(A&&(h&&(h[P>>3]&1<<(P&7))===0)){T[f+P]=0;continue}T[f+P]=E[O[P]]??0}this.#b++;return}if(c&&this.#t==="multi"){const j=g.table||[],E=new Uint32Array(j.length);for(let A=0;A<j.length;A++)E[A]=this.#d.codeOf(j[A]);const O=g.values,T=g.offsets;for(let A=0;A<w;A++){const P=T[A],L=T[A+1],z=new Array(L-P);for(let H=P;H<L;H++)z[H-P]=E[O[H]]??0;this.#c.write(f+A,z)}this.#b++;return}for(let j=0;j<w;j++){const E=h?(h[j>>3]&1<<(j&7))===0:g.kind==="object"?g.values[j]===null:!1;this.#E(f+j,E?null:a(g,j))}this.#b++}touch(){this.#b++}columnarise(g,f){if(this.#l||this.#S)return;const w=new Array(f);for(let v=0;v<f;v++)w[v]=this.#C(v);this.#t=this.#n,this.#l=!0,this.#O(g);for(let v=0;v<f;v++)this.#E(v,w[v]);this.#v.clear(),this.#y=null,this.#j(),this.#b++}grow(g){if(!(!this.#l||this.#S||g<=this.#w)){switch(this.#t){case"float64":case"int32":case"dictionary":{const f=new this.#a.constructor(g);f.set(this.#a),this.#a=f;break}case"bitset":this.#u.grow(g);break;case"multi":break;default:this.#a.length=g;break}this.#g&&this.#g.grow(g),this.#w=g,this.#b++}}convert(g){if(this.#S||!t.has(g)||(this.#n=g,!this.#l||g===this.#t))return!1;const f={kind:this.#t,buf:this.#a,bits:this.#u,mv:this.#c,dict:this.#d},w=this.#i.physical(),v=this.#g;this.#t=g,this.#O(this.#w);for(let h=0;h<w;h++){const c=v!==null&&v.get(h)===0;c&&g!=="multi"||this.#E(h,c?null:l(f,h))}return this.#j(),this.#b++,!0}compact(g,f,w){if(!this.#S){if(this.#j(),!this.#l){const v=this.#v;if(v.size){const h=new Map;for(const[c,j]of v)g[c]!==y&&h.set(g[c],j);this.#v=h}this.#y=null,this.#b++;return}switch(this.#t){case"float64":case"int32":case"dictionary":case"object":{const v=this.#a;for(let h=0;h<f;h++)g[h]!==y&&(v[g[h]]=v[h]);if(this.#t==="object")for(let h=w;h<f;h++)v[h]=void 0;break}case"bitset":{const v=this.#u;for(let h=0;h<f;h++)g[h]!==y&&v.assign(g[h],v.get(h)===1);for(let h=w;h<f;h++)v.clear(h);break}case"multi":this.#c.compact(g,w,y);break;default:break}if(this.#g){const v=this.#g;for(let h=0;h<f;h++)g[h]!==y&&v.assign(g[h],v.get(h)===1);for(let h=w;h<f;h++)v.clear(h)}this.#b++}}release(){this.#S||(this.#S=!0,this.#a=null,this.#u&&this.#u.release(),this.#u=null,this.#c&&this.#c.release(),this.#c=null,this.#g&&this.#g.release(),this.#g=null,this.#d=null,this.#h=null,this.#v=new Map,this.#y=null,this.#w=0,this.#b++)}#O(g){const f=Math.max(1,g);switch(this.#a=null,this.#u=null,this.#c=null,this.#t){case"float64":this.#a=new Float64Array(f);break;case"int32":this.#a=new Int32Array(f);break;case"bitset":this.#u=new Z(f);break;case"dictionary":this.#a=new Uint32Array(f),this.#d=this.#d??new U(this.#s??[]);break;case"multi":this.#c=new I({rows:f,values:f}),this.#d=this.#d??new U(this.#s??[]);break;default:this.#a=new Array(f);break}this.#t!=="dictionary"&&this.#t!=="multi"&&(this.#d=null),this.#r&&(this.#g?this.#g.grow(f):this.#g=new Z(f)),this.#w=f}#E(g,f){const w=i(f);switch(this.#r?this.#g.assign(g,!w):w&&M(`store.null.${this.#e}`,`column "${this.#e}" is declared non-nullable but received null; storing a filler value`),this.#t){case"float64":this.#a[g]=w?NaN:s(f);break;case"int32":this.#a[g]=w?0:r(f);break;case"bitset":this.#u.assign(g,!w&&!!f);break;case"dictionary":this.#a[g]=w?0:this.#d.codeOf(f);break;case"multi":{const v=o(f),h=new Array(v.length);for(let c=0;c<v.length;c++)h[c]=this.#d.codeOf(v[c]);this.#c.write(g,h);break}default:this.#a[g]=w?null:f;break}}#C(g){if(this.#v.has(g))return this.#v.get(g);const f=this.#o(this.#i.rowAt(g));return f===void 0?null:f}#T(){if(this.#y&&this.#y.version===this.#b)return this.#y;const g=this.#i.physical(),f=new Array(g),w=this.#r?new Z(g):null;for(let v=0;v<g;v++){const h=this.#C(v);f[v]=h,w&&!i(h)&&w.set(v)}return this.#y={version:this.#b,values:f,presence:w},this.#y}}class m{#e;#t=new Map;#n=[];#r=[];#o=0;#i=0;#s=0;#l=0;#a=new Z(0);#u=!1;#c=!0;#d;#h;#f;#m=!1;constructor(g,f={}){this.#e=Array.isArray(g)?g:[],this.#h=Math.max(1,f.initialCapacity??d),this.#c=f.retainSource!==!1,this.#d=this.#c?f.columnarBelow??u:0,this.#f=f.compactRatio??n;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)){M(`store.dup.${v.id}`,`duplicate column id "${v.id}" in the store schema; ignoring the second`);continue}const h=new p(v,w);this.#t.set(v.id,h),this.#n.push(h)}this.#d<=0&&this.#w()}get count(){return this.#s}get physical(){return this.#o}get capacity(){return this.#u?this.#i:this.#r.length}get tombstones(){return this.#l}get columnar(){return this.#u}get destroyed(){return this.#m}get bytes(){let g=this.#a.bytes+this.#r.length*8;for(const f of this.#n)g+=f.bytes;return g}append(g){const f=this.#o;if(this.#m||!g)return{from:f,to:f};const w=g.length|0;if(w===0)return{from:f,to:f};if(this.#c)for(let h=0;h<w;h++)this.#r[f+h]=g[h];if(this.#o=f+w,this.#s+=w,this.#a.grow(this.#o),!this.#u){if(this.#o>=this.#d)this.#w();else for(const h of this.#n)h.touch();return{from:f,to:this.#o}}this.#p(this.#o);const v=this.#n;for(let h=0;h<v.length;h++)v[h].appendColumn(g,f,w);return{from:f,to:this.#o}}appendPacked(g,f){const w=this.#o;if(this.#m||!g)return{from:w,to:w};const v=g.count|0;if(v===0)return{from:w,to:w};if(this.#c&&f)for(let c=0;c<v;c++)this.#r[w+c]=f[c];this.#o=w+v,this.#s+=v,this.#a.grow(this.#o),this.#u||this.#w(),this.#p(this.#o);const h=new Map;for(const c of g.columns)h.set(c.id,c);for(const c of this.#n){const j=h.get(c.id);j?c.appendPacked(j,w,v):c.grow(this.#i)}return{from:w,to:this.#o}}source(g){if(this.#c)return this.#r[g];if(!(g<0||g>=this.#o))return this.#g(g)}setSource(g,f){this.#m||g<0||g>=this.#o||this.#c&&(this.#r[g]=f)}get(g,f){const w=this.#t.get(g);return w?w.get(f):void 0}set(g,f,w){if(this.#m||f<0||f>=this.#o)return;const v=this.#t.get(g);if(!v){M(`store.set.${g}`,`set() on unknown column "${g}"`);return}v.set(f,w)}remove(g){return this.#m||g<0||g>=this.#o||this.#a.get(g)===1?!1:(this.#a.set(g),this.#l++,this.#s--,!0)}live(g){return g<0||g>=this.#o?!1:this.#a.get(g)===0}compact(g={}){if(this.#m||this.#l===0||!g.force&&this.#l/this.#o<this.#f)return null;const f=this.#o,w=new Uint32Array(f);let v=0;for(let h=0;h<f;h++)w[h]=this.#a.get(h)===1?y:v++;for(const h of this.#n)h.compact(w,f,v);if(this.#c){const h=this.#r;for(let c=0;c<f;c++)w[c]!==y&&(h[w[c]]=h[c]);h.length=v}return this.#o=v,this.#s=v,this.#l=0,this.#a=new Z(Math.max(this.#i,v)),w}column(g){return this.#t.get(g)}columns(){return this.#n.slice()}liveIndices(){const g=new Uint32Array(this.#s);if(this.#l===0){for(let w=0;w<this.#o;w++)g[w]=w;return g}let f=0;for(let w=0;w<this.#o;w++)this.#a.get(w)===0&&(g[f++]=w);return g}convert(g,f){const w=this.#t.get(g);return w?w.convert(f):!1}destroy(){if(!this.#m){this.#m=!0;for(const g of this.#n)g.release();this.#t.clear(),this.#n.length=0,this.#r.length=0,this.#a.release(),this.#o=0,this.#s=0,this.#l=0,this.#i=0}}#p(g){if(g<=this.#i)return;let f=this.#i||this.#h;for(;f<g;)f*=2;for(const w of this.#n)w.grow(f);this.#a.grow(f),this.#i=f}#g(g){const f={};for(const w of this.#n)f[w.id]=w.get(g);return f}#w(){if(this.#u)return;let g=this.#h;for(;g<this.#o;)g*=2;this.#u=!0,this.#i=g,this.#a.grow(g);for(const f of this.#n)f.columnarise(g,this.#o)}}}),Ce("packages/core/src/store/pool.js",function(e,G){"use strict";Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"sharedPool",{enumerable:!0,get:function(){return W}});const _=64,M=8;function $(V){let U=_;for(;U<V;)U*=2;return U}class R{#e=new Map;#t=new WeakSet;#n;#r=0;#o={acquired:0,reused:0,released:0};constructor(U={}){this.#n=U.limit??M}get bytes(){return this.#r}mask(U){const D=new Uint8Array(this.#i(U),0,U);return D.fill(0),D}indices(U){return new Uint32Array(this.#i(U*4),0,U)}release(U){if(!U||!U.buffer)return!1;const D=U.buffer;if(!this.#t.has(D))return!1;this.#t.delete(D),this.#o.released++;const I=D.byteLength;let k=this.#e.get(I);return k||this.#e.set(I,k=[]),k.length>=this.#n||(k.push(D),this.#r+=I),!0}releaseAll(U){for(const D of U)this.release(D)}clear(){this.#e.clear(),this.#r=0}stats(){return{...this.#o,retained:this.#r}}#i(U){const D=$(U),I=this.#e.get(D);this.#o.acquired++;let k;return I&&I.length?(k=I.pop(),this.#r-=D,this.#o.reused++):k=new ArrayBuffer(D),this.#t.add(k),k}}function W(){return Z??=new R,Z}let Z=null}),Ce("packages/core/src/compute/sortspec.js",function(e,G){"use strict";Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return R}}),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 M(Z){return!!Z&&typeof Z.compare!="function"}function $(Z){if(!Z)return!0;for(let V=0;V<Z.length;V++)if(!M(Z[V]))return!1;return!0}function R(Z,V){const U=Z.col!==void 0?Z.col:Z.handle&&Z.handle.id,D=Z.locale!==void 0?Z.locale:V;return{col:U,descending:Z.descending!==void 0?!!Z.descending:Z.dir==="desc",nullsFirst:!!Z.nullsFirst,collation:_(D)}}function W(Z,V){const U=Z||[],D=new Array(U.length);for(let I=0;I<U.length;I++)D[I]=R(U[I],V);return D}}),Ce("packages/core/src/compute/facet.js",function(e,G){"use strict";Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"orderedReader",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"toNumeric",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return v}});const _=G("packages/core/src/compute/handle.js"),M=_.presenceReader,$=_.valueReader,R=_.dictSize,W=_.dictValue,Z=Object.freeze(["equal","quantile","log"]),V=Object.freeze(["hour","day","week","month","quarter","year"]),U=20,D=50,I=1e4;function k(h,c){if(!h)return"none";const j=c;if(j&&(j.multi===!0||typeof j.items=="function"))return"category";const E=c&&c.base;if(E==="date"||E==="datetime"||E==="time"||E==="dateString")return"date";switch(h.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return E==="number"?"numeric":E==="boolean"?"boolean":E==="text"?"category":"none"}}function S(h){const c=h.values,j=h.kind;if((j==="float64"||j==="int32")&&c)return O=>c[O];const E=$(h);return O=>y(E(O))}function y(h){if(typeof h=="number")return h;if(h instanceof Date)return h.getTime();if(h==null||h==="")return NaN;if(typeof h=="boolean")return h?1:0;if(typeof h=="string"){const c=Number(h);if(Number.isFinite(c))return c;const j=Date.parse(h);return Number.isFinite(j)?j:NaN}return NaN}function d(h,c,j,E=D){if(!h)return{cardinality:0,exact:!0};if(h.dict)return{cardinality:R(h.dict),exact:!0};if(h.kind==="bitset")return{cardinality:2,exact:!0};const O=$(h),T=c?c.length:j,A=new Set;for(let P=0;P<T;P++){const L=O(c?c[P]:P);if(L!=null&&(A.add(L),A.size>E))return{cardinality:A.size,exact:!1}}return{cardinality:A.size,exact:!0}}const u=36e5,n=864e5;function t(h,c=U){const j=Number.isFinite(h)&&h>0?h:0,E=Math.max(1,c)*2;return j/u<=E?"hour":j/n<=E?"day":j/(7*n)<=E?"week":j/(30*n)<=E?"month":j/(91*n)<=E?"quarter":"year"}function i(h,c){if(!Number.isFinite(h))return NaN;const j=new Date(h);switch(c){case"hour":return j.setMinutes(0,0,0),j.getTime();case"day":return j.setHours(0,0,0,0),j.getTime();case"week":{j.setHours(0,0,0,0);const E=(j.getDay()+6)%7;return j.setDate(j.getDate()-E),j.getTime()}case"month":return j.setDate(1),j.setHours(0,0,0,0),j.getTime();case"quarter":return j.setMonth(Math.floor(j.getMonth()/3)*3,1),j.setHours(0,0,0,0),j.getTime();default:return j.setMonth(0,1),j.setHours(0,0,0,0),j.getTime()}}function s(h,c){const j=new Date(h);switch(c){case"hour":j.setHours(j.getHours()+1);break;case"day":j.setDate(j.getDate()+1);break;case"week":j.setDate(j.getDate()+7);break;case"month":j.setMonth(j.getMonth()+1);break;case"quarter":j.setMonth(j.getMonth()+3);break;default:j.setFullYear(j.getFullYear()+1);break}return j.getTime()}function r(h,c,j){const E=S(h),O=M(h),T=c?c.length:j;let A=1/0,P=-1/0,L=0,z=0;for(let H=0;H<T;H++){const x=c?c[H]:H;if(O&&!O(x)){L++;continue}const F=E(x);if(!Number.isFinite(F)){L++;continue}F<A&&(A=F),F>P&&(P=F),z++}return{min:A,max:P,nulls:L,finite:z}}function o(h,c,j,E){const O=S(h),T=M(h),A=c?c.length:j,P=A>E?A/E:1,L=[];for(let H=0;H<A;H+=P){const x=c?c[Math.floor(H)]:Math.floor(H);if(T&&!T(x))continue;const F=O(x);Number.isFinite(F)&&L.push(F)}const z=Float64Array.from(L);return z.sort(),z}function l(h,c,j,E={}){const O=E.kind||k(h,E.type);return O==="none"||!h?{kind:"none",buckets:[],suppressed:"type"}:O==="boolean"?a(h,c,j):O==="category"?p(h,c,j,E):m(h,c,j,O,E)}function a(h,c,j){const E=M(h);let O=0;if(E){const A=c?c.length:j;for(let P=0;P<A;P++)E(c?c[P]:P)||O++}const T=[{value:!1,label:"false"},{value:!0,label:"true"}];return O>0&&T.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:T}}function p(h,c,j,E){const O=E.cardinalityLimit??D,{cardinality:T}=d(h,c,j,O);if(T>O&&(E.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:T};const A=$(h),P=c?c.length:j,L=new Map;let z=0;for(let B=0;B<P;B++){const q=A(c?c[B]:B);if(q==null||q===""){z++;continue}if(Array.isArray(q)){if(!q.length){z++;continue}for(const Q of q)L.set(Q,(L.get(Q)||0)+1);continue}L.set(q,(L.get(q)||0)+1)}let H=[...L.entries()];E.order==="alpha"?H.sort((B,q)=>String(B[0]).localeCompare(String(q[0]))):H.sort((B,q)=>q[1]-B[1]);let x=0,F=0;if(H.length>O){F=H.length-O;for(let B=O;B<H.length;B++)x+=H[B][1];H=H.slice(0,O)}const C=H.map(([B])=>({value:B,label:String(B)}));return x>0&&C.push({remainder:!0,label:`Other (${F} values)`}),z>0&&C.push({null:!0,label:"Empty"}),{kind:"category",buckets:C,cardinality:T}}function m(h,c,j,E,O){const{min:T,max:A,nulls:P,finite:L}=r(h,c,j);if(!L)return{kind:E,buckets:P?[{null:!0,label:"Empty"}]:[],empty:!0};const z=Math.max(1,Math.floor(O.buckets||U));let H=[];if(E==="date"){const F=V.includes(O.granularity)?O.granularity:t(A-T,z);let C=i(T,F);for(;C<=A&&H.length<4096;){const B=s(C,F);if(!(B>C))break;H.push({from:C,to:B}),C=B}return{kind:E,buckets:b(H,P),granularity:F}}const x=Z.includes(O.strategy)?O.strategy:"equal";if(x==="quantile"){const F=o(h,c,j,I);if(F.length){const C=[F[0]];for(let B=1;B<z;B++){const q=F[Math.min(F.length-1,Math.floor(B/z*F.length))];q>C[C.length-1]&&C.push(q)}C.push(A);for(let B=0;B<C.length-1;B++)H.push({from:C[B],to:C[B+1]})}}else if(x==="log"&&T>0){const F=Math.log10(T),B=(Math.log10(A)-F)/z||1;for(let q=0;q<z;q++)H.push({from:10**(F+q*B),to:10**(F+(q+1)*B)})}if(!H.length){const F=(A-T)/z||1;for(let C=0;C<z;C++)H.push({from:T+C*F,to:T+(C+1)*F})}return H[H.length-1].to=A,{kind:E,buckets:b(H,P),strategy:x,min:T,max:A}}function b(h,c){return c>0?[...h,{null:!0,label:"Empty"}]:h}function g(h,c,j,E,O){const T=E&&E.buckets||[],A=O&&O.length>=T.length?O.subarray(0,T.length):new Uint32Array(T.length);if(A.fill(0),!h||!T.length)return A;const P=T.length-1,L=!!T[P]&&T[P].null===!0,z=c?c.length:j;if(E.kind==="boolean"){const B=$(h);for(let q=0;q<z;q++){const Q=B(c?c[q]:q);if(Q==null){L&&A[P]++;continue}A[Q?1:0]++}return A}if(E.kind==="category"){const B=new Map;for(let Y=0;Y<T.length;Y++)!T[Y].null&&!T[Y].remainder&&B.set(T[Y].value,Y);const q=T.findIndex(Y=>Y.remainder),Q=$(h);for(let Y=0;Y<z;Y++){const J=Q(c?c[Y]:Y);if(J==null||J===""){L&&A[P]++;continue}if(Array.isArray(J)){if(!J.length){L&&A[P]++;continue}for(const ee of J){const re=B.get(ee);re!==void 0?A[re]++:q>=0&&A[q]++}continue}const te=B.get(J);te!==void 0?A[te]++:q>=0&&A[q]++}return A}const H=L?T.length-1:T.length,x=new Float64Array(H+1);for(let B=0;B<H;B++)x[B]=T[B].from;x[H]=H?T[H-1].to:0;const F=S(h),C=M(h);for(let B=0;B<z;B++){const q=c?c[B]:B;if(C&&!C(q)){L&&A[P]++;continue}const Q=F(q);if(!Number.isFinite(Q)){L&&A[P]++;continue}const Y=f(x,H,Q);Y>=0&&A[Y]++}return A}function f(h,c,j){if(!c||j<h[0])return-1;if(j>=h[c])return j===h[c]?c-1:-1;let E=0,O=c-1;for(;E<O;){const T=E+O+1>>>1;j>=h[T]?E=T:O=T-1}return E}function w(h,c,j,E={}){const O=E.bounds||l(h,E.boundsIndices??c,j,E);return{bounds:O,counts:g(h,c,j,O)}}const v=w}),Ce("packages/core/src/compute/pivotmatrix.js",function(e,G){"use strict";Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return i}});const M=G("packages/core/src/compute/handle.js").valueComparator,R=G("packages/core/src/compute/total.js").total,Z=G("packages/core/src/compute/group.js").packKeys,V=G("packages/core/src/compute/pivot.js"),U=V.joinPath,D=V.DEFAULT_PATH_SEPARATOR,I=V.DEFAULT_MAX_COLUMNS,k="";function S(s,r,o={}){const l=o.separator||D,a=s||[],p=r instanceof Uint32Array?r:Uint32Array.from(r||[]),m=p.length;if(a.length===0)return{tuples:[[]],paths:[k],buckets:[p]};const{keyOf:b,readers:g}=Z(a,p,0),f=new Map,w=[],v=[],h=[];for(let A=0;A<m;A++){const P=p[A],L=b(P);let z=f.get(L);if(z===void 0){z=w.length,f.set(L,z),v.push(L);const H=new Array(g.length);for(let x=0;x<g.length;x++)H[x]=g[x](P);w.push(H),h.push([])}h[z].push(P)}const c=M(o.locale),j=w.map((A,P)=>P);j.sort((A,P)=>{const L=w[A],z=w[P];for(let H=0;H<L.length;H++){const x=y(L[H],z[H],c);if(x!==0)return x}return A-P});const E=new Array(j.length),O=new Array(j.length),T=new Array(j.length);for(let A=0;A<j.length;A++){const P=j[A];E[A]=w[P],O[A]=U(w[P],l),T[A]=Uint32Array.from(h[P])}return{tuples:E,paths:O,buckets:T}}function y(s,r,o){const l=s==null,a=r==null;return l||a?l&&a?0:l?1:-1:o(s,r)}function d(s,r,o){const l=[];for(let a=0;a<s.length;a++)o.has(s[a])&&l.push(s[a]);return Uint32Array.from(l)}function u(s,r,o,l){return{value:r.length?R(s,r,o,l):null,leaves:r,count:r.length}}function n(s){const r=s&&s.opts||{},o=r.separator||D,l=r.totalContext||{locale:r.locale},a=(s.measures||[]).filter(O=>O&&O.handle),p=s.leaves instanceof Uint32Array?s.leaves:Uint32Array.from(s.leaves||[]),m=S(s.rowHandles||[],p,{...r,separator:o}),b=S(s.columnHandles||[],p,{...r,separator:o}),g=r.maxColumns===void 0?I:r.maxColumns,f=b.paths.length*Math.max(1,a.length),w=new Map;if(g&&f>g)return{rowAxis:m,columnAxis:b,measures:a.map(O=>({colId:O.colId,fn:O.fn})),body:w,rowMargin:w,columnMargin:w,grand:w,columns:f,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${f} columns, above pivot.maxColumns of ${g}. Narrow the pivot columns or raise the limit.`,columns:f,maxColumns:g}};const v=new Map,h=new Map,c=new Map,j=new Map,E=b.buckets.map(O=>new Set(O));for(let O=0;O<b.paths.length;O++){const T=b.buckets[O],A=b.paths[O];for(const P of a)c.set(i(A,P.colId),u(P.handle,T,P.fn,l))}for(let O=0;O<m.paths.length;O++){const T=m.buckets[O],A=m.paths[O];for(const P of a)h.set(i(A,P.colId),u(P.handle,T,P.fn,l));for(let P=0;P<b.paths.length;P++){const L=d(T,b.buckets[P],E[P]);if(L.length===0)continue;const z=b.paths[P];for(const H of a)v.set(t(A,z,H.colId),u(H.handle,L,H.fn,l))}}for(const O of a)j.set(O.colId,u(O.handle,p,O.fn,l));return{rowAxis:m,columnAxis:b,measures:a.map(O=>({colId:O.colId,fn:O.fn})),body:v,rowMargin:h,columnMargin:c,grand:j,columns:f,error:null}}function t(s,r,o){return`${s}\0${r}\0${o}`}function i(s,r){return`${s}\0${r}`}}),Ce("packages/core/src/compute/reference.js",function(e,G){"use strict";Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return 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 u}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return n}});const M=G("packages/core/src/internal/util.js").getPath,$=G("packages/core/src/compute/handle.js"),R=$.isMissing,W=$.valueComparator,V=G("packages/core/src/compute/filter.js").testValue,U="",D="\0";function I(s,r){const o=r.includes(".")?M(s,r):s?.[r];return o===void 0?null:o}function k(s,r,o={}){const l=r||[];let a=s.map((p,m)=>m);if(l.length===0)return a;for(let p=l.length-1;p>=0;p--)a=S(s,a,l[p],o);return a}function S(s,r,o,l){const a=o.locale!==void 0?o.locale:l.locale,p=W(a),m=o.descending!==void 0?!!o.descending:o.dir==="desc",b=[],g=[];for(const v of r){const h=I(s[v],o.col);R(h)?g.push(v):b.push(v)}const f=new Map;for(let v=0;v<b.length;v++)f.set(b[v],v);const w=(v,h)=>{const c=I(s[v],o.col),j=I(s[h],o.col);let E;return typeof o.compare=="function"?(E=o.compare(c,j,s[v],s[h],m),m&&(E=-E)):E=m?p(j,c):p(c,j),E!==0?E:f.get(v)-f.get(h)};return b.sort(w),o.nullsFirst?g.concat(b):b.concat(g)}function y(s,r,o={}){const l=[];for(let a=0;a<s.length;a++)d(s[a],r,o,a)&&l.push(a);return l}function d(s,r,o,l){if(!r)return!0;if(Array.isArray(r.conditions)){const a=r.conditions.filter(m=>m!=null);if(a.length===0)return!0;if(r.op==="or")return a.some(m=>d(s,m,o,l));const p=a.every(m=>d(s,m,o,l));return r.op==="not"?!p:p}return r.col===void 0&&typeof o.custom=="function"?!!o.custom(r,s,l):V(I(s,r.col),r,o.locale)}function u(s,r,o,l){const a=o||s.map((g,f)=>f),p=new Map,m=[],b=[];for(const g of a){const f=r.map((h,c)=>{const j=I(s[g],h);return l&&l[c]?l[c](j):j}),w=f.map(h=>h==null?D:String(h)).join(U);let v=p.get(w);v===void 0&&(v=m.length,p.set(w,v),m.push(f),b.push([])),b[v].push(g)}return{keys:m,buckets:b}}function n(s,r,o={}){const l=W(o.locale),a=s.filter(m=>!R(m)),p=a.map(t).filter(m=>m!==null);switch(r){case"count":return s.length;case"countValues":return a.length;case"sum":return p.reduce((m,b)=>m+b,0);case"avg":return a.length===0?null:p.reduce((m,b)=>m+b,0)/a.length;case"min":return a.length===0?null:a.reduce((m,b)=>l(b,m)<0?b:m);case"max":return a.length===0?null:a.reduce((m,b)=>l(b,m)>0?b:m);case"first":return s.length===0?null:i(s[0]);case"last":return s.length===0?null:i(s[s.length-1]);default:return null}}function t(s){if(typeof s=="number")return Number.isNaN(s)?null:s;if(s==null||s===""||typeof s=="boolean")return null;if(s instanceof Date)return s.getTime();const r=Number(s);return Number.isNaN(r)?null:r}function i(s){return s===void 0?null:s}}),Ce("packages/core/src/compute/index.js",function(e,G){"use strict";const _=G("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 M=G("packages/core/src/compute/sortspec.js");Object.defineProperty(e,"collationDescriptor",{enumerable:!0,get:function(){return M.collationDescriptor}}),Object.defineProperty(e,"isPortableSort",{enumerable:!0,get:function(){return M.isPortableSort}}),Object.defineProperty(e,"isPortableSortSet",{enumerable:!0,get:function(){return M.isPortableSortSet}}),Object.defineProperty(e,"describeSortEntry",{enumerable:!0,get:function(){return M.describeSortEntry}}),Object.defineProperty(e,"describeSort",{enumerable:!0,get:function(){return M.describeSort}});const $=G("packages/core/src/compute/filter.js");Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return $.evaluateFilters}}),Object.defineProperty(e,"evaluateCondition",{enumerable:!0,get:function(){return $.evaluateCondition}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return $.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return $.testValue}}),Object.defineProperty(e,"compilePredicate",{enumerable:!0,get:function(){return $.compilePredicate}}),Object.defineProperty(e,"releaseMask",{enumerable:!0,get:function(){return $.releaseMask}}),Object.defineProperty(e,"pruneColumn",{enumerable:!0,get:function(){return $.pruneColumn}}),Object.defineProperty(e,"mentionsColumn",{enumerable:!0,get:function(){return $.mentionsColumn}});const R=G("packages/core/src/compute/group.js");Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return R.groupByColumns}}),Object.defineProperty(e,"packKeys",{enumerable:!0,get:function(){return R.packKeys}});const W=G("packages/core/src/compute/facet.js");Object.defineProperty(e,"facet",{enumerable:!0,get:function(){return W.facet}}),Object.defineProperty(e,"computeBounds",{enumerable:!0,get:function(){return W.computeBounds}}),Object.defineProperty(e,"countInto",{enumerable:!0,get:function(){return W.countInto}}),Object.defineProperty(e,"bucketOf",{enumerable:!0,get:function(){return W.bucketOf}}),Object.defineProperty(e,"facetKind",{enumerable:!0,get:function(){return W.facetKind}}),Object.defineProperty(e,"cardinalityOf",{enumerable:!0,get:function(){return W.cardinalityOf}}),Object.defineProperty(e,"pickGranularity",{enumerable:!0,get:function(){return W.pickGranularity}}),Object.defineProperty(e,"floorTo",{enumerable:!0,get:function(){return W.floorTo}}),Object.defineProperty(e,"advance",{enumerable:!0,get:function(){return W.advance}}),Object.defineProperty(e,"STRATEGIES",{enumerable:!0,get:function(){return W.STRATEGIES}}),Object.defineProperty(e,"GRANULARITIES",{enumerable:!0,get:function(){return W.GRANULARITIES}}),Object.defineProperty(e,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return W.DEFAULT_BUCKETS}}),Object.defineProperty(e,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return W.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(e,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return W.QUANTILE_SAMPLE}});const Z=G("packages/core/src/compute/total.js");Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return Z.TOTAL_FNS}}),Object.defineProperty(e,"TOTAL_LABELS",{enumerable:!0,get:function(){return Z.TOTAL_LABELS}}),Object.defineProperty(e,"totalLabel",{enumerable:!0,get:function(){return Z.totalLabel}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return Z.total}}),Object.defineProperty(e,"collectValues",{enumerable:!0,get:function(){return Z.collectValues}});const V=G("packages/core/src/compute/pivot.js");Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return V.pivot}}),Object.defineProperty(e,"resolvePivotKeys",{enumerable:!0,get:function(){return V.resolvePivotKeys}}),Object.defineProperty(e,"pivotKey",{enumerable:!0,get:function(){return V.pivotKey}}),Object.defineProperty(e,"joinPath",{enumerable:!0,get:function(){return V.joinPath}}),Object.defineProperty(e,"KEY_DELIMITER",{enumerable:!0,get:function(){return V.KEY_DELIMITER}}),Object.defineProperty(e,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return V.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(e,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return V.DEFAULT_MAX_COLUMNS}});const U=G("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(e,"pivotMatrix",{enumerable:!0,get:function(){return U.pivotMatrix}}),Object.defineProperty(e,"resolveAxis",{enumerable:!0,get:function(){return U.resolveAxis}}),Object.defineProperty(e,"cellKey",{enumerable:!0,get:function(){return U.cellKey}}),Object.defineProperty(e,"marginKey",{enumerable:!0,get:function(){return U.marginKey}}),Object.defineProperty(e,"GRAND_PATH",{enumerable:!0,get:function(){return U.GRAND_PATH}});const D=G("packages/core/src/compute/reference.js");Object.defineProperty(e,"referenceSort",{enumerable:!0,get:function(){return D.referenceSort}}),Object.defineProperty(e,"referenceFilter",{enumerable:!0,get:function(){return D.referenceFilter}}),Object.defineProperty(e,"referenceGroup",{enumerable:!0,get:function(){return D.referenceGroup}}),Object.defineProperty(e,"referenceTotal",{enumerable:!0,get:function(){return D.referenceTotal}}),Object.defineProperty(e,"referencePasses",{enumerable:!0,get:function(){return D.referencePasses}}),Object.defineProperty(e,"referenceValue",{enumerable:!0,get:function(){return D.referenceValue}});const I=G("packages/core/src/compute/handle.js");Object.defineProperty(e,"identity",{enumerable:!0,get:function(){return I.identity}}),Object.defineProperty(e,"rowCount",{enumerable:!0,get:function(){return I.rowCount}}),Object.defineProperty(e,"presenceReader",{enumerable:!0,get:function(){return I.presenceReader}}),Object.defineProperty(e,"bitReader",{enumerable:!0,get:function(){return I.bitReader}}),Object.defineProperty(e,"valueReader",{enumerable:!0,get:function(){return I.valueReader}}),Object.defineProperty(e,"valueComparator",{enumerable:!0,get:function(){return I.valueComparator}}),Object.defineProperty(e,"numericTotalOrder",{enumerable:!0,get:function(){return I.numericTotalOrder}}),Object.defineProperty(e,"dictRanks",{enumerable:!0,get:function(){return I.dictRanks}}),Object.defineProperty(e,"dictSize",{enumerable:!0,get:function(){return I.dictSize}}),Object.defineProperty(e,"dictValue",{enumerable:!0,get:function(){return I.dictValue}}),Object.defineProperty(e,"multiValue",{enumerable:!0,get:function(){return I.multiValue}}),Object.defineProperty(e,"isMissing",{enumerable:!0,get:function(){return I.isMissing}});const k=G("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 S=G("packages/core/src/compute/windowed.js");Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return S.Window}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return S.WINDOW_KINDS}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return S.openWindow}});const y=G("packages/core/src/compute/statistics.js");Object.defineProperty(e,"MAINTENANCE",{enumerable:!0,get:function(){return y.MAINTENANCE}}),Object.defineProperty(e,"APPROXIMATE",{enumerable:!0,get:function(){return y.APPROXIMATE}}),Object.defineProperty(e,"maintenanceOf",{enumerable:!0,get:function(){return y.maintenanceOf}});const d=G("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 u=G("packages/core/src/compute/forecast.js");Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return u.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return u.forecast}})}),Ce("packages/core/src/source/rows.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_ROW_HEIGHT",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"KEY_SEP",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"createRowFactory",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"RowFactory",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"pinnedRow",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"lazyRowView",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"groupPathElement",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"groupKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"groupPrefixKeys",{enumerable:!0,get:function(){return d}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.isFunction,R=32,W="\0";function Z(u){return new V(u)}class V{#e;#t;constructor(n){this.#e=$(n&&n.rowKey)?n.rowKey:null;const t=n&&n.config?n.config.rowHeight:void 0;this.#t=typeof t=="number"||$(t)?t:R}get keyed(){return this.#e!==null}keyOf(n,t){if(this.#e){const i=this.#e(n);if(i!=null)return String(i)}else M("source.rowKey.missing","no config.rowKey; falling back to index identity.","Row changes, streaming dedupe, selection persistence and remote reload are disabled.");return`#${t}`}heightOf(n){return $(this.#t)?Number(this.#t(n))||R:this.#t}leaf(n,t,i=0,s=null){const r={key:this.keyOf(n,t),data:n,level:i,parent:s,group:!1,expanded:!1,leafCount:1,height:0,index:null,selected:!1,physical:t};return r.height=this.heightOf(r),r}group(n){const t={key:y(n.keyPath||n.path),data:null,level:n.level,parent:n.parent||null,children:[],group:!0,expanded:n.expanded!==!1,leafCount:n.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:n.column,groupValue:n.value,groupPath:n.path,hasChildren:n.hasChildren!==!1};return n.totals&&(t.totals=n.totals),t.height=this.heightOf(t),t}footer(n){const t={key:`${n.key}${W}footer`,data:null,level:n.level,parent:n,group:!0,footer:!0,expanded:!1,leafCount:n.leafCount||0,height:0,index:null,selected:!1,physical:null,groupColumn:n.groupColumn,groupValue:n.groupValue,groupPath:n.groupPath,hasChildren:!1,totals:n.totals};return t.height=this.heightOf(t),t}detail(n,t){return{key:`${n.key}${W}detail`,data:n.data,level:n.level+1,parent:n,group:!1,detail:!0,expanded:!1,leafCount:0,height:t,index:null,selected:!1,physical:null,hasChildren:!1,masterKey:n.key}}grandTotal(n,t){const i={key:`${W}grandTotal`,data:null,level:0,parent:null,group:!0,grandTotal:!0,expanded:!1,leafCount:t,height:0,index:null,selected:!1,physical:null,groupPath:[],hasChildren:!1,totals:n};return i.height=this.heightOf(i),i}skeleton(n,t=0){const i={key:`${W}pending${W}${n}`,data:null,level:t,parent:null,group:!1,expanded:!1,leafCount:1,height:0,index:n,selected:!1,physical:null};return i.height=this.heightOf(i),i}}function U(u,n,t,i){return{key:`${W}pinned${W}${t}${W}${n}`,data:u,level:0,parent:null,group:!1,expanded:!1,leafCount:0,height:i,index:null,selected:!1,physical:null,hasChildren:!1,pinned:t}}function D(u,n){return new Proxy([],{get(t,i,s){if(i==="length")return u();if(typeof i=="string"){const r=Number(i);if(Number.isInteger(r)&&r>=0)return n(r)}return Reflect.get(t,i,s)},has(t,i){if(typeof i=="string"){const s=Number(i);if(Number.isInteger(s)&&s>=0)return s<u()}return Reflect.has(t,i)}})}function I(u){return u==null?"":String(u)}const k="";function S(u){if(u==null)return k;const n=String(u);return n.startsWith(k)?k+n:n}function y(u){const n=u||[];let t="g";for(let i=0;i<n.length;i++)t+=W+S(n[i]);return t}function d(u){const n=new Array(u.length),t=[];for(let i=0;i<u.length;i++)t.push(u[i]),n[i]=y(t);return n}}),Ce("packages/core/src/source/handles.js",function(e,G){"use strict";Object.defineProperty(e,"HandleProvider",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"createHandleProvider",{enumerable:!0,get:function(){return W}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce;class R{#e;#t;#n;#r=new Map;#o=0;constructor(V,U,D){this.#e=V,this.#t=U,this.#n=M(D)?D:()=>!1}get store(){const V=this.#e.store;return V&&M(V.column)?V:null}invalidate(){this.#o++}handle(V){const U=this.store;if(U){const S=U.column(V);if(S)return S}const D=this.#r.get(V);if(D&&D.builtAt===this.#o)return D.handle;const I=this.#i(V);if(!I)return;if(U&&this.#n()){$(`source.dropped.${V}`,`column "${V}" cannot be served under ingest.dropSourceRows: it is an impure computed column (a shadow or a positional/rank column) that is never stored, so it can only be read from the caller's row objects — which dropSourceRows has released. Do not sort, filter, group or total on such a column with dropSourceRows enabled.`);return}const k=this.#s(I);return this.#r.set(V,{handle:k,builtAt:this.#o}),k}#i(V){const U=this.#e.columns;return U&&M(U.get)?U.get(V):void 0}#s(V){const U=this.#t()||[],D=U.length,I=new Array(D),k=M(V.getValue)?y=>V.getValue(y):y=>y?.[V.field||V.id];for(let y=0;y<D;y++)I[y]=U[y]===void 0?void 0:k(U[y]);const S=this.#o;return{id:V.id,kind:"object",nullable:!1,values:I,presence:null,dict:null,offsets:null,get(y){return I[y]},version:S}}}function W(Z,V,U){return new R(Z,V,U)}}),Ce("packages/core/src/compute/incremental.js",function(e,G){"use strict";Object.defineProperty(e,"INCREMENTAL_FNS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"INCREMENTAL_KINDS",{enumerable:!0,get:function(){return R}}),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 D}});const M=G("packages/core/src/store/columnstore.js").toFloat,$=Object.freeze(["sum","avg","countValues","min","max"]),R=Object.freeze(["float64"]),W=1e15;function Z(I,k){return typeof I!="string"||!$.includes(I)?!1:!!k&&R.includes(k.kind)}function V(I){if(I==null)return null;const k=M(I);return Number.isNaN(k)?null:k}class U{#e;#t=0;#n=0;#r=0;#o=1/0;#i=-1/0;#s=!1;#l=!1;constructor(k){this.#e=k}get valid(){return this.#s&&!this.#l}get fn(){return this.#e}seed(k){this.#a();for(let S=0;S<k.length;S++){const y=V(k[S]);y!==null&&this.#u(y)}this.#s=!0}seedColumn(k,S,y){this.#a();for(let d=0;d<y.length;d++){const u=y[d];if(S&&S(u)===0)continue;const n=k[u];Number.isNaN(n)||this.#u(n)}this.#s=!0}#a(){this.#t=0,this.#n=0,this.#r=0,this.#o=1/0,this.#i=-1/0,this.#l=!1}#u(k){if(!Number.isFinite(k)){this.#l=!0;return}const S=this.#t+k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-S+k:k-S+this.#t,this.#t=S,this.#r++,k<this.#o&&(this.#o=k),k>this.#i&&(this.#i=k)}#c(k){const S=this.#t-k;this.#n+=Math.abs(this.#t)>=Math.abs(k)?this.#t-S-k:-k-S+this.#t,this.#t=S,this.#r--}update(k,S){if(!this.#s)return!1;const y=V(k),d=V(S);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.#s=!1}}const D=U}),Ce("packages/core/src/source/filterwire.js",function(e,G){"use strict";Object.defineProperty(e,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"warnWherePageRelative",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"warnWhereNotApplied",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"warnWhereOverThreshold",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"parseRelativeToken",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"resolveRelativeRange",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"relativeTokenOf",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"relativeTokenHelp",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"isResolvableRelative",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"resolveRelativeCondition",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"isGroup",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"forEachCondition",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"mapConditions",{enumerable:!0,get:function(){return g}}),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 h}}),Object.defineProperty(e,"querySignature",{enumerable:!0,get:function(){return c}});const M=G("packages/core/src/internal/util.js").warnOnce,$="source.remote.hostFilter",R="source.where.pageRelative";function W(O,T){!Array.isArray(O)||!O.length||M(R,`filters.where (${O.join(", ")}) runs over the rows the ${T} source fetched,`,"not the whole dataset: match counts and totals are page-relative.","Give the predicate a { condition } twin so the engine can narrow the fetch itself.")}function Z(O){const T=(O||{}).config;!T||!T.hostFilter||M($,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const V="source.where.notApplied";function U(O,T){M(`${V}:${O}`,`filters.where("${O}") is registered but the ${T} source holds only its fetched window`,"and cannot run the predicate over it: the predicate is not applied there, and rows it would","exclude stay on screen.","Give it a { condition } twin so the engine can narrow the fetch itself — that is the","supported route for a paged or remote source.")}const D="source.where.overThreshold";function I(O,T,A,P){!Array.isArray(O)||!O.length||M(`${D}:${T}`,`filters.where (${O.join(", ")}) is not applied to the ${T} pushdown source:`,A===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${A.toLocaleString()} rows, at or past the whereRowLimit of ${P.toLocaleString()}.`,"Running the predicate needs every matching row fetched and held here, which is the whole","download a pushdown source exists to avoid, so it is refused and the rows the predicate","would exclude stay on screen.","Give the predicate a { condition } twin so the engine narrows the fetch itself — that is the","route that works at any size — or raise `whereRowLimit` on the source config if you want the","download.")}const k=new Map;function S(O){let T=k.get(O);return T||(T=new Intl.DateTimeFormat("en-US",{timeZone:O,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),k.set(O,T)),T}function y(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function d(O,T){const A=S(T).formatToParts(new Date(O)),P={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const L of A)L.type==="year"?P.y=+L.value:L.type==="month"?P.m=+L.value:L.type==="day"?P.d=+L.value:L.type==="hour"?P.h=+L.value%24:L.type==="minute"?P.mi=+L.value:L.type==="second"&&(P.s=+L.value);return P}function u(O,T){const A=d(O,T);return Date.UTC(A.y,A.m-1,A.d,A.h,A.mi,A.s)-Math.floor(O/1e3)*1e3}function n(O,T,A,P){const L=Date.UTC(O,T-1,A),z=L-u(L,P);return L-u(z,P)}function t(O,T,A){const P=new Date(Date.UTC(O.y,O.m-1,O.d+T));return n(P.getUTCFullYear(),P.getUTCMonth()+1,P.getUTCDate(),A)}const i=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function s(O,T){if(typeof O!="string")return null;const A=O.trim().toLowerCase().replace(/[\s_-]+/g,""),P=/^last(\d*|n)days?$/.exec(A);if(P){const L=P[1]==="n"?"":P[1],z=Number(L||T);return!Number.isFinite(z)||z<=0?null:{kind:"lastNDays",n:Math.floor(z)}}switch(A){case"today":return{kind:"today",n:0};case"yesterday":return{kind:"yesterday",n:0};case"thisweek":return{kind:"thisWeek",n:0};case"thismonth":return{kind:"thisMonth",n:0};case"thisquarter":return{kind:"thisQuarter",n:0};case"thisyear":return{kind:"thisYear",n:0};case"quartertodate":case"qtd":return{kind:"quarterToDate",n:0};case"yeartodate":case"ytd":return{kind:"yearToDate",n:0};default:return null}}function r(O,T={}){const A=s(O,T.n);if(!A)return null;const P=T.tz||y(),L=T.now instanceof Date?T.now.getTime():typeof T.now=="number"?T.now:Date.now(),z=d(L,P),H=n(z.y,z.m,z.d,P),x=t(z,1,P);let F=H,C=x;switch(A.kind){case"today":break;case"yesterday":F=t(z,-1,P),C=H;break;case"lastNDays":C=T.includeToday?x:H,F=t(z,T.includeToday?-(A.n-1):-A.n,P);break;case"thisWeek":{const B=Number.isFinite(T.weekStartsOn)?Number(T.weekStartsOn):1,Q=(new Date(Date.UTC(z.y,z.m-1,z.d)).getUTCDay()-B+7)%7;F=t(z,-Q,P),C=t(z,-Q+7,P);break}case"thisMonth":F=n(z.y,z.m,1,P),C=n(z.m===12?z.y+1:z.y,z.m===12?1:z.m+1,1,P);break;case"thisQuarter":case"quarterToDate":{const B=Math.floor((z.m-1)/3)*3+1;F=n(z.y,B,1,P),C=A.kind==="quarterToDate"?x:B===10?n(z.y+1,1,1,P):n(z.y,B+3,1,P);break}case"thisYear":case"yearToDate":F=n(z.y,1,1,P),C=A.kind==="yearToDate"?x:n(z.y+1,1,1,P);break;default:return null}return{from:new Date(F).toISOString(),to:new Date(C).toISOString(),bounds:"[)",tz:P,relative:A.kind==="lastNDays"?`last${A.n}Days`:A.kind,n:A.n}}function o(O){if(!O||typeof O!="object")return null;const T=O.value;if(T&&typeof T=="object"&&!Array.isArray(T)&&"relative"in T)return{token:String(T.relative),n:typeof T.n=="number"?T.n:void 0};if(O.op==="relative"&&typeof O.value=="string")return{token:O.value,n:void 0};const A=O.meta;return A&&typeof A.relative=="string"&&O.value===void 0?{token:A.relative,n:typeof A.n=="number"?A.n:void 0}:null}function l(){return`Known tokens: ${i.filter(T=>T!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function a(O){const T=o(O);return T?s(T.token,T.n)!==null:!1}function p(O,T={}){const A=o(O);if(!A)return O;const P=r(A.token,{...T,n:A.n});return P?{...O,type:O.type||"date",op:"between",value:[P.from,P.to],bounds:O.bounds||P.bounds,meta:{...O.meta||{},relative:P.relative,tz:P.tz}}:(M(`source.relative.${A.token}`,`unknown relative date token "${A.token}"; sending the condition unresolved.`,l()),O)}function m(O){return!!O&&typeof O=="object"&&Array.isArray(O.conditions)}function b(O,T){if(O){if(m(O)){for(const A of O.conditions)b(A,T);return}T(O)}}function g(O,T){if(!O)return null;if(!m(O))return T(O);const A=O;let P=!1;const L=[];for(const z of A.conditions){const H=g(z,T);H!==z&&(P=!0),H&&L.push(H)}return!P&&L.length===A.conditions.length?O:L.length?{...A,conditions:L}:null}function f(O){if(!O)return null;if(!m(O))return O;const T=O,A=[];for(const P of T.conditions){const L=f(P);L&&A.push(L)}return A.length?{op:T.op,conditions:A}:null}function w(O){const T=f(O);return T?m(T)&&T.op==="and"?T:{op:"and",conditions:[T]}:null}function v(O){const T=(O||[]).filter(Boolean);return T.length?{op:"and",conditions:T}:null}function h(O,T={}){const A=g(O,P=>p(P,T));return w(A)}function c(O){const T=j(O.filters??null);return JSON.stringify([T,O.sort??null,O.quick??"",O.groupBy??null,O.pivotBy??null,E(O.context)])}function j(O){if(!O)return null;if(m(O)){const P=O;return{op:P.op,conditions:P.conditions.map(j)}}const T=O,A=T.meta&&typeof T.meta.relative=="string"?T.meta.relative:o(T)?.token;return{col:T.col,op:T.op,bounds:T.bounds??null,caseSensitive:T.caseSensitive??!1,value:A?`rel:${A}`:T.value??null}}function E(O){if(O==null)return null;try{return JSON.parse(JSON.stringify(O))}catch{return M("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ce("packages/core/src/source/tree.js",function(e,G){"use strict";Object.defineProperty(e,"SYNTHETIC",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"buildFromPath",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"buildFromParentKey",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"assignLevels",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"resolveTree",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"buildTree",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"indexTree",{enumerable:!0,get:function(){return y}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,R="",W="\0tree:";function Z(d,u){return{physical:d,key:u,level:0,children:[],value:void 0}}function V(d,u){const n=[],t=new Map;for(let i=0;i<d.length;i++){const s=d[i],r=u.pathOf(s),o=Array.isArray(r)?r.map(a=>String(a)):[];if(!o.length){const a=Z(s,u.keyOf(s));n.push(a);continue}let l=null;for(let a=0;a<o.length;a++){const p=o.slice(0,a+1).join(R),m=a===o.length-1;let b=t.get(p);b&&m&&b.physical===-1&&(b.physical=s,b.key=u.keyOf(s)),b||(b=Z(m?s:-1,m?u.keyOf(s):W+p),b.level=a,b.value=o[a],t.set(p,b),l?l.children.push(b):n.push(b)),l=b}}return{roots:n,nodes:t}}function U(d,u){const n=new Map,t=[];for(let o=0;o<d.length;o++){const l=d[o],a=u.keyOf(l),p=Z(l,a);n.set(a,p);const m=u.parentOf(l);m!=null&&m!==""&&t.push({node:p,parent:String(m)})}let i=null;const s=new Map;for(const{node:o,parent:l}of t){const a=n.get(l);if(a){s.set(o.key,a);continue}u.orphans&&u.orphans!=="root"&&(i||(i=Z(-1,`${W}orphans`),i.value=u.orphans),s.set(o.key,i))}const r=[];for(const o of n.values()){const l=s.get(o.key);l?l.children.push(o):r.push(o)}return i&&i.children.length&&r.push(i),{roots:D(r,n,u.orphans,i),nodes:n}}function D(d,u,n,t){const i=new Set,s=[...d];for(;s.length;){const p=s.pop();if(!i.has(p.key)){i.add(p.key);for(const m of p.children)s.push(m)}}const r=[];for(const p of u.values())i.has(p.key)||r.push(p);if(!r.length)return d;const o=!!n&&n!=="root";$("tree.cycle",`tree.parentKey produced ${r.length} row(s) inside a parent cycle; `+(o?`they are shown under "${n}".`:"they are shown at the root."));for(const p of r)p.children=p.children.filter(m=>i.has(m.key));if(!o)return[...d,...r];let l=t;const a=[...d];return l||(l=Z(-1,`${W}orphans`),l.value=n,a.push(l)),l.children.push(...r),a}function I(d){let u=0;const n=(t,i)=>{for(const s of t)s.level=i,i>u&&(u=i),s.children.length&&n(s.children,i+1)};return n(d,0),u}function k(d,u){if(!d||typeof d!="object")return null;const n=d.path,t=d.parentKey,i=M(d.hasChildren)?s=>!!d.hasChildren(u.dataAt(s)):null;if(M(n))return{mode:"path",pathOf:s=>n(u.dataAt(s)),keyOf:u.keyOf,declaresChildren:i};if(t!=null){const s=M(t)?t:r=>r?.[t];return{mode:"parentKey",parentOf:r=>s(u.dataAt(r)),keyOf:u.keyOf,orphans:d.orphans||"root",declaresChildren:i}}return $("tree.shape","tree is configured with neither `path` nor `parentKey`; rows stay flat."),null}function S(d,u){const n=u.mode==="path"?V(d,u):U(d,u),t=I(n.roots);return{...n,depth:t}}function y(d,u){const n=new Map,t=i=>{for(let s=0;s<i.length;s++){const r=i[s];if(r.physical>=0){const o=u?u(r.physical):!1,l=o&&r.children.length===0;n.set(r.physical,{level:r.level,posinset:s+1,setsize:i.length,hasChildren:r.children.length>0||o,lazy:l})}r.children.length&&t(r.children)}};return t(d),n}}),Ce("packages/core/src/source/memory.js",function(e,G){"use strict";Object.defineProperty(e,"STAGES",{enumerable:!0,get:function(){return w}}),Object.defineProperty(e,"PIPELINE_SETTLE_REASONS",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"isPipelineSettle",{enumerable:!0,get:function(){return h}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"quickMatcher",{enumerable:!0,get:function(){return H}}),Object.defineProperty(e,"MemorySource",{enumerable:!0,get:function(){return x}});const _=G("packages/core/src/internal/util.js"),M=_.Lru,$=_.warnOnce,R=_.fail,W=_.isFunction,Z=_.defaultCompare,V=_.mergeRow,U=G("packages/core/src/source/rows.js"),D=U.createRowFactory,I=U.groupKey,k=U.groupPathElement,S=U.groupPrefixKeys,y=U.lazyRowView,u=G("packages/core/src/source/handles.js").createHandleProvider,n=G("packages/core/src/compute/incremental.js"),t=n.RunningTotal,i=n.isIncremental,r=G("packages/core/src/compute/handle.js").presenceReader,o=G("packages/core/src/source/filterwire.js"),l=o.querySignature,a=o.mapConditions,p=o.resolveRelativeCondition,m=G("packages/core/src/source/tree.js"),b=m.buildTree,g=m.resolveTree,f=m.indexTree,w=Object.freeze(["filter","sort","group","total","pivot","flatten"]),v=Object.freeze(["pipeline:sort","pipeline:sort:error"]);function h(F){const C=F&&typeof F=="object"?F.reason:null;return typeof C=="string"&&v.includes(C)}const c=Object.freeze([]);function j(F,C){if(!F)return null;const B=C==="grand"?F.grandTotal:F.groupTotal;return B??F.total}function E(F){return!!F&&!F.running}function O(F){if(F)return F.value&&W(F.value.compare)?F.value.compare:W(F.compare)?F.compare:void 0}function T(F){const C=F&&F.dataType;return!C||!W(C.items)?null:{items:C.items,type:F.itemType&&F.itemType.name||"text"}}function A(F){return!!F&&(typeof F=="object"||typeof F=="function")&&W(F.then)}const P=new Uint32Array(0),L=4096;function z(F,C){return new x(F,C)}function H(F,C){if(C==="regex")try{const B=new RegExp(F,"iu");return q=>B.test(q)}catch{return B=>B.includes(F)}if(C==="fuzzy"){const B=[...F].filter(q=>q!==" ");return B.length?q=>{let Q=0;for(let Y=0;Y<q.length&&Q<B.length;Y++)q[Y]===B[Q]&&Q++;return Q===B.length}:()=>!0}if(C==="words"){const B=F.split(/\s+/).filter(Boolean);return B.length?q=>B.every(Q=>q.includes(Q)):()=>!0}return B=>B.includes(F)}class x{mode="memory";#e;#t;#n;#r=!1;#o=null;#i;#s;#l=new Map;#a=!1;#u=0;#c=0;#d=new Map;#h=new Map;#f;#m=null;#p=x.#g();static#g(){return{slots:[],groupHeadings:c,unnumbered:c,pivot:null,inlineLeaves:null,matchCount:0,grand:null,grandLeaves:0,groupLeaves:null}}#w=new Map;#b=null;#v=new Map;#y=-1;#S=[];#A=new Map;#j=-1;#O=[];#E=null;#C=null;#T=null;#D=null;#N=null;#I=null;#M=null;#x=null;#W=Symbol("unset");#R=new Map;#_=null;get#B(){return this.#p.slots}set#B(C){this.#p.slots=C}get#H(){return this.#p.inlineLeaves}set#H(C){this.#p.inlineLeaves=C}get#ne(){return this.#p.groupHeadings}set#ne(C){this.#p.groupHeadings=C}get#ae(){return this.#p.unnumbered}set#ae(C){this.#p.unnumbered=C}get#le(){return this.#p.pivot}set#le(C){this.#p.pivot=C}constructor(C,B){this.#t=C||{mode:"memory"},this.#e=B||{};const q=this.#e.config||{};this.#n=this.#t.rows||q.rows||[],this.#i=D(this.#e),this.#s=u(this.#e,()=>this.#n,()=>this.#r),this.#f=new M(Number(q.rowCacheSize)||L);for(const Q of w)this.#l.set(Q,{key:null,result:null,id:0,computed:!1})}count(){this.#ee();const C=this.#de();return C?C.length:this.#B.length}#de(){const C=Number(this.#$("pageSize",0))||0;if(C<=0)return null;const B=this.#B.length,q=Math.max(1,Math.ceil(B/C)),Y=Math.min(Math.max(0,Number(this.#$("page",0))||0),q-1)*C;return{offset:Y,length:Math.max(0,Math.min(C,B-Y))}}pageInfo(){this.#ee();const C=Number(this.#$("pageSize",0))||0,B=this.#B.length;if(C<=0)return{page:0,pageSize:0,total:B,pageCount:1};const q=Math.max(1,Math.ceil(B/C));return{page:Math.min(Math.max(0,Number(this.#$("page",0))||0),q-1),pageSize:C,total:B,pageCount:q}}totalCount(){return this.#$e().length}matchCount(){return this.#ee(),this.#p.matchCount}at(C){this.#ee();const B=this.#de();if(B)return C<0||C>=B.length?void 0:this.#st(B.offset+C,C);if(!(C<0||C>=this.#B.length))return this.#st(C,C)}byKey(C){this.#ee(),this.#m||this.#G();const B=this.#m.get(C);if(B!==void 0)return this.#Ae(B);for(let q=0;q<this.#B.length;q++){const Q=this.#B[q];if(typeof Q!="number"&&Q&&Q.key===C)return this.#st(q)}}loaded(C){return C>=0&&C<this.count()}hint(C,B){}display(){return this.#ee(),this.#_||(this.#_=this.#wt()),this.#_}invalidateQuickText(){this.#R.clear(),this.invalidate("filter")}invalidate(C){const B=w.indexOf(C);B<0&&R(`unknown pipeline stage "${C}"; expected one of ${w.join(", ")}`);for(let q=B;q<w.length;q++){const Q=this.#l.get(w[q]);Q.key=null,Q.computed=!1}this.#_=null}apply(C){const B=[],q={added:[],updated:[],removed:[],rejected:B};if(!C)return q;let Q=!1;const Y=new Set;if(C.remove&&C.remove.length)for(const J of C.remove){const te=this.#q(J);if(te===void 0){B.push({operation:"remove",id:this.#z(J),reason:"unknown-id"});continue}q.removed.push(this.#i.keyOf(this.#r?this.#Ye(te):this.#n[te],te)),this.#r||(this.#n[te]=void 0),this.#f.delete(te),this.#R.delete(te),Q=!0}if(C.update&&C.update.length){const J=this.#v.size||this.#it()?this.#Xe():null,te=this.#A.size?this.#qe():null,ee=te&&te.length?this.#Xe():null;for(const re of C.update){const se=this.#q(re);if(se===void 0){B.push({operation:"update",id:this.#Z(re),reason:"unknown-id"});continue}const de=this.#r?this.#o&&this.#o.has(se)?this.#o.get(se):this.#Ye(se):this.#n[se],ie=V(de,re);for(const oe of this.#me(de,ie))Y.add(oe);if(this.#r||(this.#n[se]=ie),J&&this.#ke(J,se,de,ie),ee&&this.#yt(te,ee,se,de,ie),this.#m){const oe=this.#i.keyOf(de,se),ue=this.#i.keyOf(ie,se);oe!==ue&&(this.#m.delete(oe),this.#m.set(ue,se))}this.#f.delete(se),this.#R.delete(se),q.updated.push(this.#Ae(se))}}if(C.add&&C.add.length&&this.#r){typeof C.at=="number"&&C.at<this.#Ze()&&(this.#f.clear(),this.#R.clear()),this.#m=null;for(const J of C.add){const te=this.#K(this.#Z(J));te!==void 0&&q.added.push(this.#Ae(te))}Q=!0}else if(C.add&&C.add.length){const J=typeof C.at=="number"?C.at:this.#n.length,te=this.#n.length;let ee=C.add===this.#n?C.add.slice():C.add;if(this.#i.keyed){const re=[];for(const se of ee){const de=this.#Z(se);if(this.#q(de)!==void 0){B.push({operation:"add",id:de,reason:"duplicate-id"});continue}re.push(se)}re.length!==ee.length&&(ee=re)}if(!ee.length)return q;if(J>=te)for(let re=0;re<ee.length;re++)this.#n.push(ee[re]);else this.#n.splice(J,0,...ee),this.#f.clear(),this.#R.clear();for(let re=0;re<ee.length;re++)q.added.push(this.#Ae(J>=te?te+re:J+re));Q=!0}return this.#u++,Q&&(this.#m=null,this.#Je()),this.#s.invalidate(),this.#_=null,Q||this.#Me(Y)?(this.#c++,this.invalidate("filter")):this.invalidate("total"),this.#Ue("rows:changed",{companion:!0,added:q.added.length,updated:q.updated.length,removed:q.removed.length}),this.#o=null,q}groupHeadingsAt(C){this.#ee();const B=this.#ne;if(!B.length||!Number.isInteger(C)||C<0)return c;let q=0,Q=B.length-1,Y=-1;for(;q<=Q;){const te=q+Q>>1;B[te].at<=C?(Y=te,q=te+1):Q=te-1}if(Y<0)return c;const J=[];for(let te=B[Y].row;te;te=te.parent)J.push(te);return J.reverse(),J}unnumberedRowCount(C){this.#ee();const B=this.#ae;if(!B.length||!Number.isInteger(C)||C<0)return 0;let q=0,Q=B.length-1,Y=-1;for(;q<=Q;){const J=q+Q>>1;B[J].at<=C?(Y=J,q=J+1):Q=J-1}return Y+1}moveRow(C,B){if(this.#r)return $("source.moveRow.dropped","rows.move() is not supported under ingest.dropSourceRows: the source objects have been released and the store cannot reorder its columns in place. Enable retainSource (leave dropSourceRows off) to reorder rows."),!1;const q=this.#n;if(!Number.isInteger(C)||!Number.isInteger(B)||C<0||C>=q.length)return!1;const Q=Math.max(0,Math.min(q.length-1,B));if(Q===C)return!1;const[Y]=q.splice(C,1);return q.splice(Q,0,Y),this.#u++,this.#c++,this.#m=null,this.#f.clear(),this.#R.clear(),this.#Je(),this.#s.invalidate(),this.#_=null,this.invalidate("filter"),this.#Ue("rows:changed",{companion:!0,added:0,updated:0,removed:0,moved:1}),!0}reload(C){this.#ie(),this.#u++,this.#c++,this.#m=null,this.#R.clear(),this.#f.clear(),this.#Je(),this.#s.invalidate(),this.invalidate("filter"),this.#Ue("model:changed",{reason:"reload"})}destroy(){this.#ie(),this.#f.clear(),this.#R.clear(),this.#m=null,this.#B=[],this.#H=null,this.#_=null,this.#Je();for(const C of w)this.#l.set(C,{key:null,result:null,id:0,computed:!1})}#ie(){for(const{controller:C}of this.#w.values())try{C.abort()}catch{}this.#w.clear()}setRows(C){this.#n=C||[],this.#r=!1,this.#u++,this.#c++,this.#m=null,this.#R.clear(),this.#f.clear(),this.#Je(),this.#s.invalidate(),this.invalidate("filter")}notePriorRows(C){this.#o=C||null}releaseSource(){this.#r=!0,this.#n=[],this.#m=null,this.#f.clear(),this.#R.clear(),this.#s.invalidate()}data(){if(!this.#r)return this.#n;const C=this.#e.store;if(!C||!W(C.source))return this.#n;const B=C.physical||0,q=new Array(B);for(let Q=0;Q<B;Q++)q[Q]=C.live&&!C.live(Q)?void 0:C.source(Q);return q}#oe(){const C=this.#$("detail",null);return!C||!W(C.isOpen)||C.inline===!1?null:C}#te(){const C=(this.#e.config||{}).tree;return this.#W!==C&&(this.#W=C,this.#x=g(C,{dataAt:B=>this.#Ye(B),keyOf:B=>this.#i.keyOf(this.#Ye(B),B)})),this.#x}#V(){return(this.#e.config||{}).grandTotalRow==="bottom"}grandTotalRow(){if(!this.#V())return null;this.#ee();const C=this.#p.grand;return C?this.#i.grandTotal(C,this.#he(this.#p.grandLeaves)):null}pivot(){return this.#ee(),this.#le}pivotMatrix(){this.#ee();const C=this.#p.groupLeaves,B=(this.#e.compute||{}).pivotMatrix;if(!W(B))return null;const q=this.#$("groupBy",[]),Q=this.#$("pivotBy",[]);if(!q.length&&!Q.length)return null;const Y=this.#Xe().map(te=>({colId:te.id,handle:this.#s.handle(te.id),fn:j(te,"group")})).filter(te=>te.handle&&te.fn),J=this.#e.config||{};return B({rowHandles:q.map(te=>this.#s.handle(te)).filter(Boolean),columnHandles:Q.map(te=>this.#s.handle(te)).filter(Boolean),measures:Y,leaves:C||new Uint32Array(0),opts:{locale:J.locale,separator:(J.pivot||{}).separator,maxColumns:(J.pivot||{}).maxColumns}})}keysForLeaves(C){const B=[];if(!C)return B;for(let q=0;q<C.length;q++){const Q=this.#Ae(C[q]);Q&&Q.key!=null&&B.push(String(Q.key))}return B}leavesOf(C){this.#ee();const B=this.#l.get("group"),q=B&&B.result;if(!q||!q.nodes)return[];const Q=q.nodes.get(C);if(!Q)return[];const Y=[],J=te=>{const ee=te.row&&te.row.children;if(ee&&ee.length){for(const re of ee){const se=q.nodes.get(re.key);se&&J(se)}return}if(te.leaves)for(let re=0;re<te.leaves.length;re++)Y.push(this.#Ae(te.leaves[re]))};return J(Q),Y}#z(C){return typeof C=="string"?C:this.#Z(C)}#Z(C){try{return this.#i.keyOf(C,-1)}catch{return"(unkeyed)"}}#q(C){if(typeof C=="string")return this.#K(C);if(this.#i.keyed){const q=this.#i.keyOf(C,-1),Q=this.#K(q);if(Q!==void 0)return Q}if(this.#r)return;const B=this.#n.indexOf(C);return B>=0?B:void 0}#K(C){return this.#m||this.#G(),this.#m.get(C)}#G(){this.#m=new Map;const C=this.#Ze(),B=this.#e.store,q=B&&W(B.live)?Q=>B.live(Q):null;for(let Q=0;Q<C;Q++){if(q&&!q(Q))continue;const Y=this.#Ye(Q);Y!==void 0&&this.#m.set(this.#i.keyOf(Y,Q),Q)}}#me(C,B){const q=[];for(const Q of this.#we())this.#Le(Q)&&this.#be(Q,C,B,new Set)&&q.push(Q);return q}#be(C,B,q,Q){if(Q.has(C))return!1;Q.add(C);const Y=this.#Le(C);if(!Y)return!1;const J=Y.value&&Y.value.deps;return Array.isArray(J)&&J.length?J.some(te=>this.#be(String(te),B,q,Q)):W(Y.getValue)?!Object.is(Y.getValue(B),Y.getValue(q)):!1}#we(){const C=new Set;for(const q of this.#$("sort",[]))C.add(q.col);for(const q of this.#$("groupBy",[]))C.add(q);const B=q=>{if(q){if(Array.isArray(q.conditions)){q.conditions.forEach(B);return}q.col&&C.add(q.col)}};return B(this.#$("filters",null)),[...C]}#Me(C){if(!C.size)return!1;if(this.#$("quick",""))return!0;for(const B of this.#we())if(C.has(B))return!0;return!1}#ee(){if(!this.#a){this.#a=!0;try{this.#fe()}finally{this.#a=!1}}}pipelineRunning(){return this.#a}#fe(){const C=this.#Y("filter",()=>this.#Ee(),()=>this.#ve()),B=this.#pe(C),q=this.#Y("group",()=>this.#je(),()=>this.#Ne(B)),Q=this.#Y("total",()=>this.#xe(),()=>this.#Ke(q));this.#Y("pivot",()=>this.#Ie(),()=>this.#bt(q)),this.#Y("flatten",()=>this.#ze(),()=>this.#_e(q)),this.#se(q,Q)}#pe(C){const B=this.#l.get("sort"),q=this.#Te();if(B.computed&&B.key===q&&!this.#w.has("sort"))return B.result;const Q=this.#w.get("sort");return Q&&Q.key===q?B.result:B.result&&this.#U(C)?(this.#L(C,q),B.result):this.#Y("sort",()=>q,()=>this.#De(C))}#ge(){if(this.#b===null){const C=this.#e.pipelineWorker,B=W(C)?C():null;this.#b=B||!1}return this.#b||null}#ue(){const C=this.#$("sort",[]);if(!Array.isArray(C)||!C.length)return null;const B=(this.#e.config||{}).locale,q=[],Q=[];for(const Y of C){const J=this.#Le(Y.col);if(J&&J.running)continue;if(J&&J.value&&W(J.value.compare))return null;const te=this.#s.handle(Y.col);if(!te)return null;q.push({col:Y.col,descending:Y.dir==="desc",nullsFirst:!!Y.nullsFirst,locale:B}),Q.push(te)}return q.length?{entries:q,handles:Q,locale:B}:null}#U(C){const B=this.#ge();if(!B)return!1;const q=Number(B.threshold);return Number.isFinite(q)&&C.length<q?!1:!!this.#ue()}#L(C,B){const q=this.#ge(),Q=q&&this.#ue();if(!Q){this.#Y("sort",()=>B,()=>this.#De(C));return}const Y=new AbortController;this.#w.set("sort",{key:B,controller:Y});const J=Q.entries.length===1?q.sortColumn(Q.handles[0],C,{descending:Q.entries[0].descending,nullsFirst:Q.entries[0].nullsFirst,locale:Q.locale,signal:Y.signal,key:"sort"}):q.sortMulti(Q.handles,Q.entries.map((te,ee)=>({...te,handle:Q.handles[ee]})),C,{signal:Y.signal,key:"sort"});if(!A(J)){this.#w.delete("sort"),this.#Y("sort",()=>B,()=>J);return}J.then(te=>this.#Oe(B,te),te=>this.#re("sort",B,te))}#Oe(C,B){const q=this.#w.get("sort");if(!(!q||q.key!==C)){if(this.#Te()!==C){this.#w.delete("sort");return}this.#w.delete("sort"),this.#Y("sort",()=>C,()=>B),this.#_=null,this.#ee(),this.#Ue("model:changed",{reason:v[0]})}}#re(C,B,q){const Q=this.#w.get(C);if(!(!Q||Q.key!==B)&&(this.#w.delete(C),!(q&&q.name==="AbortError")&&C==="sort"&&this.#Te()===B)){const Y=this.#Y("filter",()=>this.#Ee(),()=>this.#ve());this.#Y("sort",()=>B,()=>this.#De(Y)),this.#_=null,this.#ee(),$("source.pipeline.sort","off-thread sort failed; recomputed on the main thread.",q),this.#Ue("model:changed",{reason:v[1]})}}#se(C,B){const q=C&&C.leaves?C.leaves.length:this.#p.slots.length;this.#p.matchCount=q,this.#p.grand=B&&B.grand||null,this.#p.grandLeaves=C&&C.leaves?C.leaves.length:0,this.#p.groupLeaves=C&&C.leaves?C.leaves:null}#Y(C,B,q){const Q=this.#l.get(C),Y=B();return Q.computed&&Q.key===Y||(Q.result=q(),Q.key=Y,Q.computed=!0,Q.id++,C==="flatten"&&(this.#_=null)),Q.result}#k(C){return this.#l.get(C).id}#Ee(){const C=(this.#e.config||{}).hostFilter,B=C&&W(C.active)&&C.active()?1:0,q=this.#$("where",null),Q=q?q.version:0,Y=this.#ut("filter.sig",`${this.#Qe()}`,()=>l({filters:this.#$("filters",null),quick:this.#$("quick",""),quickMode:this.#$("quickMode","contains")}));return`${this.#c}|${Y}|${B}|${Q}`}#Te(){return`${this.#k("filter")}|${JSON.stringify(this.#$("sort",[]))}`}#je(){return`${this.#k("sort")}|${JSON.stringify(this.#$("groupBy",[]))}`}#xe(){const C=this.#Se()?"f":"a",B=(this.#e.config||{}).totalOnlyChangedColumns?"n":"w";return`${this.#k("group")}|${JSON.stringify(this.#$("totals",[]))}|${C}${B}|${this.#u}`}#Ie(){return`${this.#k("group")}|${JSON.stringify(this.#$("pivotBy",[]))}`}#ze(){const B=this.#Ge()||!this.#V()?this.#k("total"):"x",q=`${this.#Qe()}`,Q=this.#ut("flatten.keys",q,()=>{const J=this.#$("expanded",null);return J?[...J].sort().join(""):"*"}),Y=this.#ut("flatten.detail",q,()=>{const J=this.#$("detail",null);return J&&W(J.signature)?J.signature():""});return`${B}|${this.#k("pivot")}|${Q}|${Y}`}#Ge(){const C=this.#$("groupBy",[]);return Array.isArray(C)&&C.length>0}stageState(){const C=[];for(const[B,q]of this.#l){const Q=q.result;C.push({stage:B,materialised:!!q.computed,bytes:Q&&typeof Q.byteLength=="number"?Q.byteLength:null,rows:Q&&typeof Q.length=="number"?Q.length:null,rebuilds:q.id})}return C}facetIndices(C){return this.#ve(C||null)}facetRows(C){const B=this.facetIndices(C),q=[];for(let Q=0;Q<B.length;Q++){const Y=this.#Ae(B[Q]);Y&&q.push(Y)}return q}invalidateRows(){this.#f.clear(),this.#R.clear(),this.#_=null}invalidateHandles(){this.#s.invalidate()}rows(){return this.#n}unfilteredIndices(){return this.#$e()}filteredIndices(){const C=this.#l.get("filter");if(C&&C.computed&&C.key===this.#Ee())return C.result||this.#$e();this.#ee();const B=this.#l.get("filter");return(B&&B.computed?B.result:null)||this.#$e()}unfilteredRows(){const C=this.#$e(),B=[];for(let q=0;q<C.length;q++){const Q=this.#Ae(C[q]);Q&&B.push(Q)}return B}#ve(C=null){const B=this.#$e(),q=this.#$("filters",null),Q=C?this.#tt("pruneColumn")(q,C):q,Y=this.#Tt(Q),J=String(this.#$("quick","")||"").trim().toLowerCase(),te=J?H(J,String(this.#$("quickMode","contains")||"contains")):null,ee=(this.#e.config||{}).hostFilter,re=!!(ee&&W(ee.active)&&ee.active()),se=this.#$("where",null),de=!!(se&&se.active);if(!Y&&!J&&!re&&!de)return B;let ie=null;Y&&(ie=this.#tt("evaluateFilters")(Y,{handle:pe=>this.#s.handle(pe),count:this.#Ze(),pool:this.#e.pool,locale:(this.#e.config||{}).locale,itemwise:pe=>T(this.#Le(pe))}));const oe=new Uint32Array(B.length);let ue=0;for(let ce=0;ce<B.length;ce++){const pe=B[ce];if(!(ie&&!ie[pe])&&!(te&&!this.#Et(pe,te))){if(re||de){const Me=this.#Ae(pe);if(re&&!ee.passes(Me)||de&&!se.passes(Me.data,Me.key))continue}oe[ue++]=pe}}if(ie){const ce=(this.#e.compute||{}).releaseMask;W(ce)&&ce({pool:this.#e.pool},ie)}return oe.subarray(0,ue)}handleFor(C){return this.#s.handle(C)}#De(C){const B=this.#$("sort",[]).filter(Y=>{const J=this.#Le(Y.col);return!J||!J.running?!0:($(`source.sort.running.${Y.col}`,`sort ignores "${Y.col}": a running total is a function of the sort order, so it cannot also decide it. Sort by the column it runs over instead.`),!1)});if(!B.length)return C;const q=(this.#e.config||{}).locale;if(B.length===1){const Y=B[0],J=this.#s.handle(Y.col);if(!J)return $(`source.sort.${Y.col}`,`sort ignores unknown column "${Y.col}".`),C;const te=this.#Le(Y.col);return this.#tt("sortColumn")(J,C,{descending:Y.dir==="desc",nullsFirst:Y.nullsFirst,locale:q,compare:O(te)})}const Q=[];for(const Y of B){const J=this.#s.handle(Y.col);if(!J){$(`source.sort.${Y.col}`,`sort ignores unknown column "${Y.col}".`);continue}Q.push({handle:J,descending:Y.dir==="desc",nullsFirst:Y.nullsFirst,locale:q,compare:O(this.#Le(Y.col))})}return Q.length?this.#tt("sortMulti")(Q.map(Y=>Y.handle),Q,C):C}#Ne(C){const B=this.#$("groupBy",[]),q=this.#te();if(q&&!B.length){const ce=b(C,q);return this.#I=f(ce.roots,q.declaresChildren),{roots:null,leaves:C,nodes:new Map,tree:ce}}if(this.#I=null,q&&B.length&&$("tree.grouped","grouping is active on a grid configured with `tree`; the grouping wins and the hierarchy is not shown."),!B.length)return{roots:null,leaves:C,nodes:new Map};const Q=(this.#e.config||{}).timeZone,Y=[],J=[];let te=!1;for(const ce of B){const pe=this.#s.handle(ce);if(!pe){$(`source.group.${ce}`,`grouping ignores unknown column "${ce}".`);continue}Y.push(pe);const Me=this.#Le(ce),$e=Me&&Me.dataType;if($e&&W($e.groupProjector)){const je=Me.typeOptions&&Me.typeOptions.timeZone||Me.timeZone||Q||void 0,ke=$e.groupProjector(Me,je);J.push(ke||null),ke&&(te=!0)}else J.push(null)}if(!Y.length)return{roots:null,leaves:C,nodes:new Map};const{keys:ee,buckets:re}=this.#tt("groupByColumns")(Y,C,{locale:(this.#e.config||{}).locale,project:te?J:void 0}),se=this.#$("pivotBy",[]).length>0,de=[],ie=new Map;for(let ce=0;ce<re.length;ce++){const pe=ee[ce];let Me=null;const $e=[];for(let je=0;je<pe.length;je++){$e.push(k(pe[je]));const ke=I($e),ge=je===pe.length-1;let Ee=ie.get(ke);if(!Ee){const Ie=this.#i.group({path:[...$e],column:B[je],value:pe[je],level:je,parent:Me,expanded:se&&ge?!1:this.#at(ke,{key:ke,column:B[je],value:pe[je],level:je,path:[...$e]}),hasChildren:!(se&&ge)});Ee={row:Ie,leaves:null},ie.set(ke,Ee),Me?Me.children.push(Ie):de.push(Ie)}Ee.row.leafCount+=re[ce].length,je===pe.length-1&&(Ee.leaves=re[ce]),Me=Ee.row}}const oe=this.#$("sort",[])||[],ue=(ce,pe)=>{if(!ce||ce.length<2){if(ce)for(const ke of ce)ue(ke.children,pe+1);return}const Me=B[pe],$e=oe.find(ke=>ke.col===Me),je=$e&&$e.dir==="desc"?-1:1;ce.sort((ke,ge)=>je*Z(ke.groupValue,ge.groupValue));for(const ke of ce)ue(ke.children,pe+1)};return ue(de,0),{roots:de,leaves:C,nodes:ie,keys:ee,buckets:re}}#X(C,B){const q=new Map,Q=new Map,Y=J=>{const te=J.physical>=0?[J.physical]:[];for(const ee of J.children)te.push(...Y(ee));if(J.children.length){const ee=this.#Re(B,Uint32Array.from(te),null);J.physical>=0?q.set(J.physical,ee):Q.set(J.key,ee)}return te};for(const J of C.roots)Y(J);return{byPhysical:q,byKey:Q}}#Ke(C){const B=this.#Xe();if(!B.length)return this.#C=null,this.#T=null,{grand:null};const q={id:this.#k("group"),columns:B.map(oe=>oe.id).join("")},Q=this.#C&&this.#C.id===q.id&&this.#C.columns===q.columns,Y=this.#it()&&Q?this.#E:null,J=Y?B.filter(oe=>Y.has(oe.id)):B,te=Q?this.#T:null,ee=this.#Se()?null:this.#rt(),re=this.#We(B),se=oe=>{const ue=C.nodes.get(oe.key);let ce=ue&&ue.leaves?ue.leaves:null;if(oe.children&&oe.children.length){const $e=oe.children.map(se);let je=0;for(const Ee of $e)je+=Ee.length;const ke=new Uint32Array(je);let ge=0;for(const Ee of $e)ke.set(Ee,ge),ge+=Ee.length;ce=ke}ce=ce||new Uint32Array(0);const pe=ee?ee.get(oe.key)||P:ce,Me=this.#ce(oe,Y?J:B,pe,re);return oe.totals=Y?{...oe.totals,...Me}:Me,ce};if(C.roots&&J.length)for(const oe of C.roots)se(oe);if(this.#M=C.tree?this.#X(C.tree,B):null,this.#C=q,this.#E=this.#it()?new Set:null,!(this.#e.config||{}).grandTotalRow)return this.#S.length=0,this.#T=null,{grand:null};const ie=ee?this.#Ce():C.leaves;return this.#T=this.#nt(B,ie,Y,te),{grand:this.#T}}#nt(C,B,q,Q){const Y={},J=this.#k("group");J!==this.#y&&(this.#ot(),this.#y=J);const te=this.#S;this.#S=[];for(const ee of C){if(!E(ee))continue;const re=this.#s.handle(ee.id);if(!re)continue;const se=j(ee,"grand");if(!i(se,re)){if(q&&!q.has(ee.id)&&Q&&ee.id in Q){Y[ee.id]=Q[ee.id];continue}Y[ee.id]=this.#Re([ee],B,null,"grand")[ee.id];continue}let de=this.#v.get(ee.id);if((!de||de.fn!==se)&&(de=new t(se),this.#v.set(ee.id,de)),de.valid){let ie=!0;for(const oe of te)if(oe.colId===ee.id&&!de.update(oe.before,oe.after)){ie=!1;break}if(ie){Y[ee.id]=de.value();continue}de.invalidate()}de.seedColumn(re.values,r(re),B),Y[ee.id]=de.valid?de.value():this.#Re([ee],B,null,"grand")[ee.id]}return Y}#We(C){const B=this.#k("group");B!==this.#j&&(this.#A.clear(),this.#j=B);const q=new Map;for(const Y of C){if(!E(Y))continue;const J=this.#s.handle(Y.id),te=j(Y,"group");i(te,J)&&q.set(Y.id,{fn:te})}if(!q.size)return this.#O.length=0,q;const Q=this.#O;this.#O=[];for(const Y of Q){const{beforeKeys:J,afterKeys:te,colDeltas:ee}=Y,re=J.length?new Set(J):null,se=te.length?new Set(te):null;for(const{colId:de,before:ie,after:oe}of ee)if(q.has(de)){for(const ue of J)se&&se.has(ue)||this.#Be(ue,de,ie,null);for(const ue of te)re&&re.has(ue)||this.#Be(ue,de,null,oe);for(const ue of J)se&&!se.has(ue)||this.#Be(ue,de,ie,oe)}}return q}#Be(C,B,q,Q){const Y=this.#A.get(C),J=Y&&Y.get(B);!J||!J.valid||J.update(q,Q)||J.invalidate()}#ce(C,B,q,Q){if(!Q||!Q.size)return this.#Re(B,q,C);const Y={};let J=null,te=this.#A.get(C.key);for(const ee of B){const re=Q.get(ee.id);if(!re){(J||(J=[])).push(ee);continue}const se=this.#s.handle(ee.id);if(!se)continue;te||(te=new Map,this.#A.set(C.key,te));let de=te.get(ee.id);if((!de||de.fn!==re.fn)&&(de=new t(re.fn),te.set(ee.id,de)),de.valid||de.seedColumn(se.values,r(se),q),de.valid){Y[ee.id]=de.value();continue}(J||(J=[])).push(ee)}return J&&Object.assign(Y,this.#Re(J,q,C)),Y}#ke(C,B,q,Q){const Y=!this.#Se()||this.#P(B);for(const J of C){const te=J.getValue;if(!W(te))continue;const ee=te(q),re=te(Q);Object.is(ee,re)||(this.#E&&this.#E.add(J.id),Y&&this.#v.has(J.id)&&this.#S.push({colId:J.id,before:ee,after:re}))}}#qe(){const C=this.#$("groupBy",[]),B=[];for(const q of C){const Q=this.#Le(q);Q&&B.push(Q)}return B}#mt(C,B){const q=new Array(C.length);for(let Q=0;Q<C.length;Q++){const Y=C[Q].getValue;q[Q]=k(W(Y)?Y(B):void 0)}return q}#yt(C,B,q,Q,Y){if(this.#Se()&&!this.#P(q))return;const J=S(this.#mt(C,Q)),te=S(this.#mt(C,Y)),ee=J.length!==te.length||J.some((se,de)=>se!==te[de]),re=[];for(const se of B){const de=se.getValue;if(!W(de))continue;const ie=de(Q),oe=de(Y);!ee&&Object.is(ie,oe)||re.push({colId:se.id,before:ie,after:oe})}!re.length&&!ee||this.#O.push({beforeKeys:J,afterKeys:te,colDeltas:re})}#P(C){const B=this.#l.get("filter"),q=B&&B.computed?B.result:null;if(!q)return!0;let Q=0,Y=q.length-1;for(;Q<=Y;){const J=Q+Y>>1,te=q[J];if(te===C)return!0;te<C?Q=J+1:Y=J-1}return!1}#Se(){return(this.#e.config||{}).totalFilteredOnly!==!1}#he(C){return this.#Se()?C:this.#Ce().length}#Ce(){return(!this.#D||this.#D.version!==this.#c)&&(this.#D={version:this.#c,indices:this.#$e()}),this.#D.indices}#rt(){const C=this.#$("groupBy",[]),B=`${this.#c}|${JSON.stringify(C)}`;if(this.#N&&this.#N.key===B)return this.#N.map;const q=new Map,Q=[];for(const Y of C){const J=this.#s.handle(Y);J&&Q.push(J)}if(Q.length){const Y=this.#Ce(),{keys:J,buckets:te}=this.#tt("groupByColumns")(Q,Y,{locale:(this.#e.config||{}).locale}),ee=new Map;for(let re=0;re<te.length;re++){const se=J[re],de=[];for(let ie=0;ie<se.length;ie++){de.push(k(se[ie]));const oe=I(de);let ue=ee.get(oe);ue||(ue=[],ee.set(oe,ue));for(let ce=0;ce<te[re].length;ce++)ue.push(te[re][ce])}}for(const[re,se]of ee)q.set(re,Uint32Array.from(se))}return this.#N={key:B,map:q},q}#it(){return!!(this.#e.config||{}).totalOnlyChangedColumns}#Je(){this.#ot(),this.#et(),this.#E=null,this.#C=null,this.#T=null}#ot(){this.#v.clear(),this.#S.length=0,this.#y=-1}#et(){this.#A.clear(),this.#O.length=0,this.#j=-1}#bt(C){const B=this.#$("pivotBy",[]);if(!B.length)return this.#le=null,null;const q=(this.#e.compute||{}).pivot;if(!W(q))return $("source.pivot.kernel","pivot requested but ctx.compute.pivot is not available; showing unpivoted rows."),this.#le=null,null;const Q=B.map(J=>this.#s.handle(J)).filter(Boolean),Y=this.#Xe();return this.#le=q(Q,C.leaves,{groups:C.keys&&C.buckets?{keys:C.keys,buckets:C.buckets}:null,totals:Y.map(J=>J.id),handle:J=>this.#s.handle(J),totalOf:J=>j(Y.find(te=>te.id===J),"group"),separator:((this.#e.config||{}).pivot||{}).separator,maxColumns:((this.#e.config||{}).pivot||{}).maxColumns})||null,this.#le}#_e(C){const B=this.#l.get("total").result,q=!!(this.#e.config||{}).groupFooter,Q=this.#oe();if(C.tree)return this.#Ct(C,B,Q);if(!C.roots&&!Q){if(B&&B.grand&&!this.#V()){const se=this.#i.grandTotal(B.grand,this.#he(C.leaves.length));if(this.#H===C.leaves&&Array.isArray(this.#B))this.#B[this.#B.length-1]=se;else{const de=Array.from(C.leaves);de.push(se),this.#B=de,this.#H=C.leaves}this.#ae=[{at:this.#B.length-1}]}else this.#H=null,this.#B=C.leaves,this.#ae=c;return this.#ne=c,this.#B}const Y=[],J=[],te=[],ee=se=>{if(Y.push(se),!Q)return;const de=this.#Ae(se);!de||!Q.isOpen(de.key)||(de.master=!0,de.expanded=!0,te.push({at:Y.length}),Y.push(this.#i.detail(de,Q.heightOf(de))))};if(!C.roots){for(let se=0;se<C.leaves.length;se++)ee(C.leaves[se]);return B&&B.grand&&!this.#V()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(B.grand,this.#he(C.leaves.length)))),this.#H=null,this.#ne=c,this.#ae=te.length?te:c,this.#B=Y,Y}const re=(se,de,ie)=>{if(se.expanded=se.hasChildren===!1?!1:this.#at(se.key,{key:se.key,column:se.groupColumn,value:se.groupValue,level:se.level,path:se.groupPath}),se.posinset=de+1,se.setsize=ie,J.push({at:Y.length,row:se}),te.push({at:Y.length}),Y.push(se),!!se.expanded){if(se.children&&se.children.length)for(let oe=0;oe<se.children.length;oe++)re(se.children[oe],oe,se.children.length);else{const oe=C.nodes.get(se.key),ue=oe&&oe.leaves?oe.leaves:null;if(ue)for(let ce=0;ce<ue.length;ce++)ee(ue[ce])}q&&se.totals&&(te.push({at:Y.length}),Y.push(this.#i.footer(se)))}};for(let se=0;se<C.roots.length;se++)re(C.roots[se],se,C.roots.length);return B&&B.grand&&!this.#V()&&(te.push({at:Y.length}),Y.push(this.#i.grandTotal(B.grand,this.#he(C.leaves.length)))),this.#ne=J,this.#ae=te,this.#B=Y,Y}#$e(){const C=this.#e.store;if(C&&W(C.liveIndices))return C.liveIndices();const B=new Uint32Array(this.#n.length);let q=0;for(let Q=0;Q<this.#n.length;Q++)this.#n[Q]!==void 0&&(B[q++]=Q);return B.subarray(0,q)}#Ze(){const C=this.#e.store;return C&&typeof C.physical=="number"?C.physical:this.#n.length}#Ye(C){const B=this.#e.store;return B&&W(B.source)?B.source(C):this.#n[C]}#st(C,B=C){const q=this.#B[C];if(typeof q!="number")return q.index=B,q;const Q=this.#Ae(q);return Q.index=B,Q}#Ae(C){let B=this.#f.get(C);B||(B=this.#i.leaf(this.#Ye(C),C),this.#f.set(C,B));const q=this.#I?this.#I.get(C):null;if(q){B.level=q.level,B.posinset=q.posinset,B.setsize=q.setsize,B.hasChildren=q.hasChildren,B.expanded=q.hasChildren&&!q.lazy&&this.#at(B.key);const Q=this.#M?this.#M.byPhysical.get(C):void 0;Q?B.totals=Q:B.totals&&(B.totals=null)}else B.hasChildren&&(B.level=0,B.hasChildren=!1,B.expanded=!1,B.posinset=void 0,B.setsize=void 0);return B}#Ct(C,B,q){const Q=[],Y=[],J=ee=>{if(ee.leafCount!==void 0)return ee.leafCount;let re=ee.physical>=0?1:0;for(const se of ee.children)re+=J(se);return ee.leafCount=re,re},te=ee=>{const re=this.#at(ee.key);if(ee.physical>=0){if(Q.push(ee.physical),q&&q.isOpen(this.#Ae(ee.physical).key)){const se=this.#Ae(ee.physical);Y.push({at:Q.length}),Q.push(this.#i.detail(se,q.heightOf(se)))}}else Q.push(this.#i.group({path:[ee.key],column:null,value:ee.value,level:ee.level,parent:null,expanded:re,hasChildren:ee.children.length>0,leafCount:J(ee),totals:this.#M?this.#M.byKey.get(ee.key):void 0}));if(re)for(const se of ee.children)te(se)};for(const ee of C.tree.roots)te(ee);return B&&B.grand&&!this.#V()&&(Y.push({at:Q.length}),Q.push(this.#i.grandTotal(B.grand,this.#he(C.leaves.length)))),this.#H=null,this.#ne=c,this.#ae=Y.length?Y:c,this.#B=Q,Q}#wt(){return y(()=>this.count(),C=>this.at(C))}#Et(C,B){let q=this.#R.get(C);if(q===void 0){const Q=this.#Ye(C),Y=this.#kt(),J=[],te=this.#e.columnHidden;for(const ee of Y){if(ee.quickFilter===!1||W(te)&&te(ee.id))continue;const re=ee.value&&W(ee.value.quickFilterText)?ee.value.quickFilterText({value:void 0,data:Q,row:null,column:ee,colId:ee.id,grid:null,context:this.#$("context",null)}):null,se=re??(W(ee.formatValue)?ee.formatValue(W(ee.getValue)?ee.getValue(Q):void 0):"");se!=null&&se!==""&&J.push(String(se))}q=J.join(" ").toLowerCase(),this.#R.set(C,q)}return B(q)}#Xe(){const C=this.#$("totals",[]),B=C&&C.length?new Set(C):null;return this.#kt().filter(q=>B?B.has(q.id):!!(q.total||q.groupTotal||q.grandTotal))}#Re(C,B,q,Q="group"){const Y={},J=(this.#e.compute||{}).total;for(const te of C){if(!E(te))continue;const ee=this.#s.handle(te.id);if(!ee)continue;const re=j(te,Q);if(re)if(W(re)){const se=new Array(B.length);for(let de=0;de<B.length;de++)se[de]=ee.get(B[de]);Y[te.id]=re(se,{row:q,column:te,grid:this.#e.grid||null,context:this.#$("context",null),valueAt:(de,ie)=>{const oe=this.#s.handle(de);return oe&&ie>=0&&ie<B.length?oe.get(B[ie]):null}})}else W(J)&&(Y[te.id]=J(ee,B,re))}return Y}#Tt(C){if(!C)return C;const B=this.#e.config||{},q={tz:B.timeZone,weekStartsOn:B.weekStartsOn};return a(C,Q=>{const Y=p(Q,q);if(Y&&Y.type)return Y;const J=this.#Le(Y&&Y.col),te=J&&(J.dataType?.base||J.type);return te?{...Y,type:te}:Y})}#at(C,B){const q=this.#$("expanded",null);return q?W(q.has)?q.has(C,B):Array.prototype.includes.call(q,C):!0}#$(C,B){if(C==="context"||!W(this.#e.stateVersion))return this.#lt(C,B);const q=this.#Mt(C),Q=this.#d.get(C);if(Q&&Q.version===q)return Q.value;const Y=this.#lt(C,B);return this.#d.set(C,{version:q,value:Y}),Y}#lt(C,B){const q=this.#e.state;if(q&&W(q[C])){const Q=q[C]();return Q??B}return B}#Qe(){const C=this.#e.stateVersion;return W(C)?C():0}#vt(){const C=this.#e.columnsVersion,B=this.#e.permissionsVersion;return`${W(C)?C():0}|${W(B)?B():0}`}#Mt(C){return C==="totals"?this.#vt():`${this.#Qe()}`}#ut(C,B,q){if(!W(this.#e.stateVersion))return q();const Q=this.#h.get(C);if(Q&&Q.version===B)return Q.key;const Y=q();return this.#h.set(C,{version:B,key:Y}),Y}#tt(C){const B=(this.#e.compute||{})[C];return W(B)||R(`ctx.compute.${C} is required by the memory source pipeline`),B}#kt(){const C=this.#e.columns;return C&&W(C.all)?C.all():[]}#Le(C){const B=this.#e.columns;return B&&W(B.get)?B.get(C):void 0}#Ue(C,B){const q=this.#e.emit;W(q)&&q(C,B)}}}),Ce("packages/core/src/source/abort.js",function(e,G){"use strict";Object.defineProperty(e,"SupersededError",{enumerable:!0,get:function(){return _}}),Object.defineProperty(e,"RequestToken",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"AbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"createAbortScope",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"isAbortError",{enumerable:!0,get:function(){return W}});class _ extends Error{constructor(V,U="superseded"){super(`[lattice] request ${V?`"${V}" `:""}${U}`),this.name="SupersededError",this.superseded=!0,this.key=V}}class M{#e;constructor(V,U,D,I){this.#e=V,this.key=U,this.controller=D,this.signal=D.signal,this.seq=I}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(V){this.signal.aborted||this.controller.abort(new _(this.key,V)),this.#e.settle(this)}}class ${#e=new Map;#t=0;begin(V="",U="superseded"){const D=this.#e.get(V);D&&!D.signal.aborted&&D.controller.abort(new _(V,U));const I=new M(this,V,new AbortController,++this.#t);return this.#e.set(V,I),I}tokenFor(V){return this.#e.get(V)}pending(V=""){const U=this.#e.get(V);return!!U&&!U.signal.aborted}get size(){return this.#e.size}settle(V){this.#e.get(V.key)===V&&this.#e.delete(V.key)}abort(V="",U="superseded"){const D=this.#e.get(V);D&&D.abort(U)}abortAll(V="superseded"){for(const U of[...this.#e.values()])U.abort(V);this.#e.clear()}}function R(){return new $}function W(Z){if(!Z||typeof Z!="object")return!1;const V=Z;return V.superseded===!0||V.name==="AbortError"||V.name==="SupersededError"}}),Ce("packages/core/src/source/blockcache.js",function(e,G){"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 M}}),Object.defineProperty(e,"BlockCache",{enumerable:!0,get:function(){return R}});const _=100,M=32;class ${constructor(Z){this.id=Z,this.rows=null,this.state="pending",this.token=null,this.error=null}}class R{#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)||M))}get pageSize(){return this.#t}get maxBlocks(){return this.#n}get size(){return this.#e.size}blockOf(Z){return Math.floor(Z/this.#t)}rangeOf(Z){return{start:Z*this.#t,end:(Z+1)*this.#t}}has(Z){return this.#e.has(Z)}pending(Z){const V=this.#e.get(Z);return!!V&&V.state==="pending"}loaded(Z){const V=this.#e.get(Z);return!!V&&V.state==="loaded"}begin(Z,V){let U=this.#e.get(Z);return U||(U=new $(Z)),U.state="pending",U.token=V,U.error=null,this.#i(Z,U),U}fill(Z,V){const U=this.#e.get(Z)||new $(Z);U.rows=V,U.state="loaded",U.token=null,this.#i(Z,U)}failed(Z,V){const U=this.#e.get(Z)||new $(Z);U.state="error",U.error=V,U.token=null,this.#i(Z,U)}delete(Z){return this.#e.delete(Z)}rowAt(Z){const V=this.blockOf(Z),U=this.#e.get(V);if(!(!U||U.state!=="loaded"||!U.rows))return this.#i(V,U),U.rows[Z-V*this.#t]}rowLoaded(Z){const V=this.blockOf(Z),U=this.#e.get(V);return!!U&&U.state==="loaded"&&!!U.rows&&Z-V*this.#t<U.rows.length}loadedExtent(){let Z=0;for(const V of this.#e.values()){if(V.state!=="loaded"||!V.rows)continue;const U=V.id*this.#t+V.rows.length;U>Z&&(Z=U)}return Z}fillOf(Z){const V=this.#e.get(Z);return V&&V.state==="loaded"&&V.rows?V.rows.length:null}protect(Z,V){this.#r=this.blockOf(Math.max(0,Z)),this.#o=this.blockOf(Math.max(0,V))}evict(){const Z=[];if(this.#e.size<=this.#n)return Z;for(const[V,U]of this.#e){if(this.#e.size-Z.length<=this.#n)break;V>=this.#r&&V<=this.#o||U.state!=="pending"&&Z.push(V)}for(const V of Z)this.#e.delete(V);return Z}ids(){return[...this.#e.keys()]}clear(){this.#e.clear()}#i(Z,V){this.#e.delete(Z),this.#e.set(Z,V)}}}),Ce("packages/core/src/source/paged.js",function(e,G){"use strict";Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"PagedSource",{enumerable:!0,get:function(){return o}});const _=G("packages/core/src/internal/util.js"),M=_.Lru,$=_.isFunction,R=_.warnOnce,W=_.settleDebounce,Z=G("packages/core/src/source/abort.js"),V=Z.createAbortScope,U=Z.isAbortError,D=G("packages/core/src/source/blockcache.js"),I=D.BlockCache,k=D.DEFAULT_PAGE_SIZE,S=D.DEFAULT_MAX_CACHED_PAGES,d=G("packages/core/src/source/rows.js").createRowFactory,u=G("packages/core/src/source/filterwire.js"),n=u.wireFilters,t=u.querySignature,i=u.warnHostFilterNotApplied,s=120;function r(l,a){return new o(l,a)}class o{mode="paged";#e;#t;#n;#r=V();#o;#i;#s=new Map;#l=null;#a=!1;#u=0;#c="";#d={start:0,end:0};#h;#f=!1;constructor(a,p){this.#e=a||{mode:"paged"},this.#t=p||{},this.#n=new I({pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||S}),this.#o=d(this.#t),this.#i=new M(this.#n.pageSize*4),this.#h=W((m,b)=>this.#m(m,b),s),this.#c=this.#v(),$(this.#e.fetch)||R("source.paged.fetch",'source.mode "paged" requires a fetch function; the grid will stay empty.'),i(this.#t)}count(){if(this.#w(),this.#l!==null)return this.#l;const a=Math.max(this.#u,this.#n.loadedExtent());return this.#a?a:a+this.#n.pageSize}at(a){if(this.#w(),a<0||a>=this.count())return;const p=this.#i.get(a);if(p&&(p.data!==null||!this.#n.rowLoaded(a)))return p;const m=this.#n.rowAt(a);if(m===void 0){const g=this.#o.skeleton(a);return this.#i.set(a,g),g}const b=this.#o.leaf(m,a);return b.index=a,this.#i.set(a,b),this.#s.set(b.key,a),b}byKey(a){const p=this.#s.get(a);return p===void 0?void 0:this.at(p)}loaded(a){return this.#n.rowLoaded(a)}hint(a,p){if(this.#f)return;const m=this.#w(),b=Math.max(0,Math.floor(a)),g=Math.max(b,Math.floor(p));this.#d={start:b,end:g},this.#n.protect(b,g);for(const f of this.#n.evict())this.#g(f);this.#h(b,g),m&&this.#h.flush()}#m(a,p){if(this.#f)return;this.#n.protect(a,p);const m=this.#n.blockOf(a),b=this.#n.blockOf(p);for(let g=m;g<=b&&!(this.#l!==null&&g*this.#n.pageSize>=this.#l);g++)this.#n.has(g)||this.#p(g)}apply(a){const p={added:[],updated:[],removed:[]};if(!a)return p;if(a.update)for(const m of a.update){const b=this.#o.keyOf(m,-1),g=this.#s.get(b);if(g===void 0)continue;const f=this.#o.leaf(m,g);f.index=g,this.#i.set(g,f),p.updated.push(f)}return(a.add&&a.add.length||a.remove&&a.remove.length)&&this.reload(),p}reload(a){this.#b("reload"),this.#h.cancel(),this.hint(this.#d.start,this.#d.end)}destroy(){this.#f=!0,this.#h.cancel(),this.#r.abortAll("destroyed"),this.#n.clear(),this.#i.clear(),this.#s.clear()}exact(){return this.#l!==null||this.#a}pending(){return this.#r.size}async#p(a){if(!$(this.#e.fetch))return;const p=this.#r.begin(`block:${a}`);this.#n.begin(a,p);const{start:m,end:b}=this.#n.rangeOf(a),g=this.#c;try{const f=await this.#e.fetch({range:{start:m,end:b},sort:this.#S("sort",[]),filters:n(this.#S("filters",null),this.#y()),quick:this.#S("quick","")||void 0,context:this.#S("context",null),signal:p.signal});if(!p.current||g!==this.#c||this.#f)return;p.settle();const w=f&&f.rows||[];this.#n.fill(a,w);for(let h=0;h<w.length;h++)this.#i.delete(m+h);const v=f&&typeof f.total=="number"?f.total:f&&typeof f.count=="number"?f.count:null;v!==null?(this.#l=v,this.#a=!0):w.length<this.#n.pageSize?(this.#a=!0,this.#l=m+w.length):this.#u=Math.max(this.#u,m+w.length),this.#A("model:changed",{reason:"page",block:a,from:m,to:m+w.length}),this.#A("rows:changed",{companion:!0,reason:"page",block:a,from:m,to:m+w.length})}catch(f){if(p.settle(),U(f))return;this.#n.failed(a,f),this.#A("source:error",{error:f,block:a,range:{start:m,end:b}})}}#g(a){const{start:p,end:m}=this.#n.rangeOf(a);for(let b=p;b<m;b++){const g=this.#i.peek(b);g&&this.#s.delete(g.key),this.#i.delete(b)}}#w(){const a=this.#v();return a===this.#c?!1:(this.#c=a,this.#b("query"),!0)}#b(a){this.#r.abortAll(a),this.#n.clear(),this.#i.clear(),this.#s.clear(),this.#l=null,this.#a=!1,this.#u=0,this.#A("model:changed",{reason:a})}#v(){return t({filters:this.#S("filters",null),sort:this.#S("sort",[]),quick:this.#S("quick",""),context:this.#S("context",null)})}#y(){const a=this.#t.config||{};return{tz:a.timeZone,weekStartsOn:a.weekStartsOn}}#S(a,p){const m=this.#t.state;if(m&&$(m[a])){const b=m[a]();return b??p}return p}#A(a,p){const m=this.#t.emit;$(m)&&m(a,p)}}}),Ce("packages/core/src/source/remote.js",function(e,G){"use strict";Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"HINT_SETTLE_MS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"RemoteSource",{enumerable:!0,get:function(){return b}});const _=G("packages/core/src/internal/util.js"),M=_.Lru,$=_.isFunction,R=_.warnOnce,W=_.settleDebounce,Z=G("packages/core/src/source/abort.js"),V=Z.createAbortScope,U=Z.isAbortError,D=G("packages/core/src/source/blockcache.js"),I=D.BlockCache,k=D.DEFAULT_PAGE_SIZE,S=D.DEFAULT_MAX_CACHED_PAGES,y=G("packages/core/src/source/rows.js"),d=y.createRowFactory,u=y.groupKey,n=G("packages/core/src/source/filterwire.js"),t=n.wireFilters,i=n.querySignature,s=n.warnHostFilterNotApplied,o=G("packages/core/src/source/memory.js").MemorySource,l=1,a=120;function p(g,f){return new b(g,f)}class m{constructor(f,w,v,h){this.path=f,this.keyPath=h||f,this.values=[],this.level=w,this.key=u(this.keyPath),this.cache=new I(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;#s=V();#l;#a;#u=new Map;#c=[];#d="";#h;#f=!1;#m=null;#p=-1;constructor(f,w){this.#e=f||{mode:"remote"},this.#t=w||{},$(this.#e.fullFrame)&&(this.filteredIndices=()=>this.#S(),this.unfilteredIndices=()=>this.#A(),this.handleFor=c=>this.#j(c),this.display=()=>this.#O(),this.grandTotalRow=()=>this.#C(),this.unfilteredRows=()=>this.#N(),this.facetIndices=c=>this.#E(c));const v=this.#e.counts;$(v)&&(this.matchCount=()=>this.#T("match"),this.totalCount=()=>this.#T("total"));const h=this.#e.grandTotals;$(h)&&(this.grandTotalRow=()=>this.#D()),this.#n={pageSize:this.#e.pageSize||k,maxCachedPages:this.#e.maxCachedPages||S},this.#l=d(this.#t),this.#a=new M(this.#n.pageSize*4),this.#h=W((c,j)=>this.#w(c,j),a),this.#r=new m([],0,this.#n),this.#o.set(this.#r.key,this.#r),this.#d=this.#ie(),$(this.#e.fetch)||R("source.remote.fetch",'source.mode "remote" requires a fetch function; the grid will stay empty.'),this.#Z()}count(){const f=this.#v();return f?f.count():(this.#le(),this.#R(this.#r))}at(f){const w=this.#v();if(w)return w.at(f);if(this.#le(),f<0||f>=this.count())return;const v=this.#B(this.#r,f);if(!v)return;const h=this.#H(v.node,v.local);return h&&(h.index=f),h||this.#l.skeleton(f,v.node.level)}byKey(f){const w=this.#v();if(w)return w.byKey(f);const v=this.#u.get(f);if(!v)return;const h=v.lastIndexOf(":"),c=this.#o.get(v.slice(0,h));return c&&this.#H(c,Number(v.slice(h+1)))||void 0}loaded(f){const w=this.#v();if(w)return w.loaded(f);if(f<0||f>=this.count())return!1;const v=this.#B(this.#r,f);return!!v&&v.node.cache.rowLoaded(v.local)}hint(f,w){if(this.#f)return;const v=this.#le(),h=Math.max(0,Math.floor(f)),c=Math.max(h,Math.floor(w));for(const[j,E]of this.#g(h,c)){j.cache.protect(E.min,E.max);for(const O of j.cache.evict())this.#ae(j,O)}this.#h(h,c),v&&this.#h.flush()}#g(f,w){const v=this.count(),h=new Map;for(let c=f;c<=w&&c<v;c++){const j=this.#B(this.#r,c);if(!j)continue;const E=h.get(j.node);E?(E.min=Math.min(E.min,j.local),E.max=Math.max(E.max,j.local)):h.set(j.node,{min:j.local,max:j.local})}return h.size||h.set(this.#r,{min:f,max:f}),h}#w(f,w){if(!this.#f)for(const[v,h]of this.#g(f,w)){v.cache.protect(h.min,h.max);const c=v.cache.blockOf(h.min),j=v.cache.blockOf(h.max);for(let E=c;E<=j&&!(v.count!==null&&E*v.cache.pageSize>=v.count);E++)v.cache.has(E)||this.#M(v,E)}}apply(f){const w={added:[],updated:[],removed:[]};if(!f)return w;if(f.update)for(const v of f.update){const h=this.#u.get(this.#l.keyOf(v,-1));if(!h)continue;this.#a.delete(h);const c=h.lastIndexOf(":"),j=this.#o.get(h.slice(0,c));if(!j)continue;const E=Number(h.slice(c+1)),O=j.cache.blockOf(E);if(!j.cache.loaded(O))continue;const{start:T}=j.cache.rangeOf(O),A=[];for(let L=T;L<T+j.cache.pageSize;L++){const z=j.cache.rowAt(L);if(z===void 0)break;A.push(L===E?v:z)}j.cache.fill(O,A);const P=this.#H(j,E);P&&w.updated.push(P)}return(f.add&&f.add.length||f.remove&&f.remove.length)&&this.reload({keepExpanded:!0}),w}reload(f){this.#s.abortAll("reload"),this.#h.cancel(),f&&f.keepExpanded===!1&&this.#i.clear(),this.#de(),this.#G("model:changed",{reason:"reload"})}destroy(){this.#f=!0,this.#h.cancel(),this.#s.abortAll("destroyed"),this.#de(),this.#o.clear(),this.#i.clear(),this.#m&&$(this.#m.destroy)&&this.#m.destroy(),this.#m=null}expand(f){this.#i.has(f)||(this.#i.add(f),this.#G("group:toggled",{key:f,expanded:!0}),this.#G("model:changed",{reason:"expand",key:f}))}collapse(f){this.#i.delete(f)&&(this.#G("group:toggled",{key:f,expanded:!1}),this.#G("model:changed",{reason:"collapse",key:f}))}expandedKeys(){return[...this.#i]}pivotFields(){return this.#c}invalidateHandles(){this.#m&&($(this.#m.invalidateHandles)&&this.#m.invalidateHandles(),$(this.#m.invalidate)&&this.#m.invalidate("filter"))}#b(){const f=this.#e.fullFrame;return $(f)?f():null}#v(){const f=this.#b();return f?(this.#m||(this.#m=new o({mode:"memory"},this.#y())),f.version!==this.#p&&(this.#m.setRows(f.rows),this.#p=f.version),this.#m):null}#y(){const f=this.#t,w=f.state||{};return{...f,state:{...w,page:()=>0,pageSize:()=>0}}}#S(){const f=this.#v();return f?f.filteredIndices():new Uint32Array(0)}#A(){const f=this.#v();return f?f.unfilteredIndices():new Uint32Array(0)}#j(f){const w=this.#v();return w?w.handleFor(f):void 0}#O(){const f=this.#v();return f?f.display():[]}#E(f){const w=this.#v();return w&&$(w.facetIndices)?w.facetIndices(f):new Uint32Array(0)}#C(){const f=this.#v();return f&&$(f.grandTotalRow)?f.grandTotalRow():null}#T(f){const w=this.#v();if(w){const j=f==="match"?w.matchCount:w.totalCount;if($(j))return j.call(w)}const v=this.#e.counts,h=$(v)?v():null,c=h?h[f]:null;return typeof c=="number"?c:this.count()}#D(){const f=this.#v();if(f&&$(f.grandTotalRow))return f.grandTotalRow();if((this.#t.config||{}).grandTotalRow!=="bottom")return null;const v=this.#e.grandTotals,h=$(v)?v():null;return!h||!h.totals?null:this.#l.grandTotal(h.totals,h.leafCount||0)}#N(){const f=this.#v();if(f&&$(f.unfilteredRows))return f.unfilteredRows();const w=[],v=this.count();for(let h=0;h<v;h++){const c=this.at(h);c&&w.push(c)}return w}#I(f,w,v){const{start:h,end:c}=f.cache.rangeOf(w),j=this.#K("groupBy",[]),E=this.#K("pivotBy",[]),O=this.#K("quick",""),T=this.#te(),A={protocol:l,range:{start:h,end:c},groupPath:f.path,groupValues:f.values,groupBy:j,totals:T,totalFns:this.#V(T),pivotBy:E,pivotMode:E.length>0,filters:t(this.#K("filters",null),this.#q()),sort:this.#K("sort",[]),context:this.#K("context",null),signal:v};O&&(A.quick=O);const P=this.#K("where",null);return P&&P.active&&(A.where=P),A}async#M(f,w){if(!$(this.#e.fetch))return;const v=this.#s.begin(`${f.key}:${w}`);f.cache.begin(w,v);const h=this.#d,{start:c}=f.cache.rangeOf(w);try{const j=await this.#e.fetch(this.#I(f,w,v.signal));if(!v.current||h!==this.#d||this.#f)return;v.settle();const E=j&&j.rows||[];f.cache.fill(w,E);for(let A=0;A<E.length;A++)this.#a.delete(`${f.key}:${c+A}`);const O=j&&typeof j.count=="number"?j.count:j&&typeof j.total=="number"?j.total:null,T=j&&$(j.pendingTotal?.then)?j.pendingTotal:null;O!==null?(f.count=O,f.complete=!0):E.length<f.cache.pageSize?(f.count=c+E.length,f.complete=!0):T&&(f.counting=!0),j&&Array.isArray(j.pivotFields)&&this.#W(j.pivotFields),this.#G("model:changed",{reason:"page",groupPath:f.path,block:w}),this.#G("rows:changed",{companion:!0,reason:"page",groupPath:f.path,block:w}),T&&this.#x(f,T,h)}catch(j){if(v.settle(),U(j))return;f.cache.failed(w,j),this.#G("source:error",{error:j,groupPath:f.path,block:w})}}async#x(f,w,v){let h;try{h=await w}catch(c){if(v!==this.#d||this.#f)return;f.counting=!1,U(c)||this.#G("source:error",{error:c,groupPath:f.path});return}v!==this.#d||this.#f||(f.counting=!1,typeof h=="number"&&(f.count=h,f.complete=!0,this.#G("source:total",{total:h,groupPath:f.path}),this.#G("model:changed",{reason:"total",count:h,groupPath:f.path})))}totalPending(){return this.#r.counting===!0}#W(f){f.length===this.#c.length&&f.every((w,v)=>w===this.#c[v])||(this.#c=f,this.#G("column:pivoted",{pivotFields:f,remote:!0}))}#R(f){let w=this.#_(f);for(const v of f.children.values())this.#oe(v.key)&&(w+=this.#R(v));return w}#_(f){if(f.count!==null)return f.count;const w=f.cache.loadedExtent();return f.complete?w:f.row&&f.row.leafCount>0?Math.max(w,f.row.leafCount):w+f.cache.pageSize}#B(f,w){let v=w,h=0;const c=[...f.children.entries()].filter(([,E])=>this.#oe(E.key)).sort((E,O)=>E[0]-O[0]);for(const[E,O]of c){const T=E-h+1;if(v<T)return{node:f,local:h+v};v-=T,h=E+1;const A=this.#R(O);if(v<A)return this.#B(O,v);v-=A}const j=this.#_(f);return h+v<j?{node:f,local:h+v}:null}#H(f,w){const v=`${f.key}:${w}`,h=this.#a.get(v);if(h)return h;const c=f.cache.rowAt(w);if(c===void 0)return null;const j=this.#K("groupBy",[]);let E;if(f.level<j.length){const O=j[f.level],T=this.#z(c,O),A=T==null,P=[...f.path,A?"":String(T)],L=[...f.keyPath,A?null:String(T)];E=this.#l.group({path:P,keyPath:L,column:O,value:T,level:f.level,parent:f.row,leafCount:Number(c.leafCount)||0,expanded:this.#oe(u(L))}),E.totals=this.#ne(c),E.data=c;let z=this.#o.get(E.key);z?z.row=E:(z=new m(P,f.level+1,this.#n,L),z.row=E,this.#o.set(z.key,z)),z.values=[...f.values,T],f.children.set(w,z)}else E=this.#l.leaf(c,w,f.level,f.row);return this.#a.set(v,E),this.#u.set(E.key,v),E}#ne(f){const w=f||{};if(w.totals&&typeof w.totals=="object")return w.totals;const v={};for(const h of this.#te())Object.hasOwn(w,h)&&(v[h]=w[h]);return v}#ae(f,w){const{start:v,end:h}=f.cache.rangeOf(w);for(let c=v;c<h;c++){const j=`${f.key}:${c}`,E=this.#a.peek(j);E&&this.#u.delete(E.key),this.#a.delete(j)}}#le(){const f=this.#ie();return f===this.#d?!1:(this.#d=f,this.#s.abortAll("query"),this.#de(),this.#G("model:changed",{reason:"query"}),!0)}#de(){for(const f of this.#o.values())f.cache.clear(),f.count=null,f.complete=!1,f.counting=!1,f.children.clear();this.#a.clear(),this.#u.clear()}#ie(){const f=this.#K("where",null);return`${i({filters:this.#K("filters",null),sort:this.#K("sort",[]),quick:this.#K("quick",""),groupBy:this.#K("groupBy",[]),pivotBy:this.#K("pivotBy",[]),context:this.#K("context",null)})}|${f?f.version:0}`}#oe(f){const w=this.#K("expanded",null);return w?$(w.has)?w.has(f):Array.prototype.includes.call(w,f):this.#i.has(f)}#te(){const f=this.#K("totals",[]);if(f&&f.length)return[...f];const w=this.#t.columns;return!w||!$(w.all)?[]:w.all().filter(v=>!!v.total).map(v=>v.id)}#V(f){const w=this.#t.columns,v={};if(!w||!$(w.get))return v;for(const h of f){const c=w.get(h);if(!c)continue;const j=c.groupTotal!=null?c.groupTotal:c.total;typeof j=="string"&&(v[h]=j)}return v}#z(f,w){const v=this.#t.columns,h=v&&$(v.get)?v.get(w):void 0;return h&&$(h.getValue)?h.getValue(f):f?.[w]}#Z(){s(this.#t)}#q(){const f=this.#t.config||{};return{tz:f.timeZone,weekStartsOn:f.weekStartsOn}}#K(f,w){const v=this.#t.state;if(v&&$(v[f])){const h=v[f]();return h??w}return w}#G(f,w){const v=this.#t.emit;$(v)&&v(f,w)}}}),Ce("packages/core/src/source/gapbuffer.js",function(e,G){"use strict";Object.defineProperty(e,"GapBuffer",{enumerable:!0,get:function(){return M}});const _=64;class M{#e;#t=0;#n=0;constructor(R=_){this.#e=new Uint32Array(Math.max(1,R)),this.#n=this.#e.length}static from(R,W=_){const Z=new M(R.length+Math.max(1,W));return Z.#e.set(R,0),Z.#t=R.length,Z.#n=Z.#e.length,Z}get length(){return this.#t+(this.#e.length-this.#n)}get capacity(){return this.#e.length}at(R){return R<0||R>=this.length?0:R<this.#t?this.#e[R]:this.#e[R+(this.#n-this.#t)]}insert(R,W){const Z=R<0?0:R>this.length?this.length:R;this.#r(Z),this.#t===this.#n&&this.#o(),this.#e[this.#t++]=W}push(R){this.insert(this.length,R)}removeAt(R){return!Number.isInteger(R)||R<0||R>=this.length?!1:(this.#r(R),this.#n++,!0)}toArray(){const R=new Uint32Array(this.length);return R.set(this.#e.subarray(0,this.#t),0),R.set(this.#e.subarray(this.#n),this.#t),R}clear(){this.#t=0,this.#n=this.#e.length}#r(R){if(R!==this.#t)if(R<this.#t){const W=this.#t-R;this.#e.copyWithin(this.#n-W,R,this.#t),this.#t=R,this.#n-=W}else{const W=R-this.#t;this.#e.copyWithin(this.#t,this.#n,this.#n+W),this.#t=R,this.#n+=W}}#o(){const R=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-R),this.#e=W,this.#n=W.length-R}}}),Ce("packages/core/src/store/ingest.js",function(e,G){"use strict";Object.defineProperty(e,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"inferKind",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"decideText",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"createReaders",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"Ingest",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return t}});const _=G("packages/core/src/internal/util.js"),M=_.now,$=_.nextFrame,R=_.infoOnce,W=_.warnOnce,Z=_.isFunction,V=_.pathGetter,D=G("packages/core/src/store/columnstore.js").ColumnStore,I=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function k(i,s={}){if(s.multi)return"multi";if(i.length===0)return"object";let r=0,o=0,l=0,a=0,p=0;for(let b=0;b<i.length;b++){const g=i[b];typeof g=="number"?r++:typeof g=="boolean"?o++:typeof g=="string"?l++:g instanceof Date?a++:Array.isArray(g)&&p++}const m=i.length;return r===m?"float64":o===m?"bitset":a===m?"float64":l===m?"text":p===m?"multi":"object"}function S(i,s,r){return s<=0||i<r*s?"dictionary":"object"}function y(i,s,r){const o=new Map,l=new Map;for(const c of i){if(c.computed)continue;const j=Z(c.read)?c.read:V(c.field||c.id);l.set(c.id,j),o.set(c.id,j)}const a=s?.order??[],p=s?.fns??{},m=s?.deps??{},b=s?.wrapDeps??null,g=a.filter(c=>Z(p[c])),f=g.some(c=>m[c]==="*");let w=new WeakMap;const v=c=>{const j={};if(f)for(const[E,O]of l)j[E]=O(c);for(const E of g){const O=m[E];let T;if(O==="*")T=j;else{T={};const A=O||[];for(let P=0;P<A.length;P++){const L=A[P];T[L]=L in j?j[L]:l.get(L)?.(c)}}j[E]=p[E](b?b(T,E):T,{data:c,row:null,column:null,grid:null,context:r})}return j},h=c=>{if(c===null||typeof c!="object"&&typeof c!="function")return v(c);let j=w.get(c);return j===void 0&&(j=v(c),w.set(c,j)),j};for(const c of g)o.set(c,j=>h(j)[c]);return{readers:o,reset(){w=new WeakMap}}}class d{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(s,r){this.spec=s,this.read=r,this.kind="object",this.inferred=!1,this.nullable=s.nullable!==!1}}class u{#e;#t=[];#n=null;#r;#o=0;#i;#s=!1;#l=!1;#a=0;#u;constructor(s,r={},o={}){this.#e=Array.isArray(s)?s:Array.from(s||[]),this.#i={...I,...o};const l=r.columns??[];this.#r=y(l,r.computed??null,r.context),this.#u=this.#e.length>=this.#i.columnarBelow,this.#c(l,r.computed??null),this.#n=new D(this.#t.map(a=>({id:a.spec.id,kind:a.kind,nullable:a.nullable,read:a.read,dictionary:a.spec.dictionary})),{initialCapacity:this.#i.initialCapacity,columnarBelow:this.#i.columnarBelow})}get store(){return this.#n}get done(){return this.#s||this.#l}get progress(){return this.#o}slice(){if(this.done)return!1;if(this.#i.signal?.aborted)return this.#l=!0,!1;const s=M(),{chunkMs:r,chunkRows:o}=this.#i,l=this.#e.length;do{const a=Math.min(this.#o+o,l);this.#n.append(this.#e.slice(this.#o,a)),this.#d(this.#o,a),this.#o=a,this.#r.reset(),this.#f(!1)}while(this.#o<l&&M()-s<r);return this.#a+=M()-s,this.#i.onProgress?.({loaded:this.#o,total:l}),this.#o>=l?(this.#f(!0),this.#s=!0,!1):!0}cancel(){this.#l=!0}result(){return{store:this.#n,schema:this.#t.map(s=>({id:s.spec.id,kind:s.kind,nullable:s.nullable,read:s.read,dictionary:s.spec.dictionary})),decisions:this.#t.map(s=>({id:s.spec.id,kind:s.kind,nullable:s.nullable,inferred:s.inferred,distinct:s.candidate||s.change?this.#h(s):null,change:s.change,reason:s.reason})),count:this.#n.count,elapsed:this.#a,cancelled:this.#l}}#c(s,r){const o=this.#e,l=Math.min(this.#i.sampleSize,o.length),a=this.#i.dictionaryRatio,p=r?.pure instanceof Set?r.pure:new Set(r?.pure??r?.order??[]);for(const m of s){if(!m||!m.id)continue;if(m.computed&&(m.pure===!1||r&&!p.has(m.id))){W(`ingest.impure.${m.id}`,`column "${m.id}" is an impure computed column and is not materialised into the store`);continue}const b=this.#r.readers.get(m.id)??(Z(m.read)?m.read:V(m.field||m.id)),g=new d(m,b);if(m.kind)g.kind=m.kind,g.reason="declared by the caller";else if(m.dictionary)g.kind=m.multi?"multi":"dictionary",g.reason="value table supplied (lookup column)";else{const f=[];for(let v=0;v<l&&f.length<this.#i.sampleSize;v++){const h=b(o[v]);h!=null&&f.push(h)}g.inferred=!0;const w=k(f,{multi:m.multi});if(w==="text"){const v=new Set(f).size;g.kind=S(v,f.length,a),g.candidate=this.#u,g.reason=`sampled ${v} distinct in ${f.length}`}else g.kind=w,g.reason=`inferred from ${f.length} sampled values`,w==="object"&&f.length&&R(`ingest.mixed.${m.id}`,`column "${m.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);g.kind==="object"&&g.candidate&&(g.distinct=new Set(f))}this.#t.push(g)}}#d(s,r){const o=this.#e;for(const l of this.#t){if(!l.candidate||!l.distinct)continue;const a=l.distinct;for(let p=s;p<r;p++){const m=l.read(o[p]);m!=null&&a.add(m)}}}#h(s){if(s.distinct)return s.distinct.size;const r=this.#n.column(s.spec.id);return r?.dict?r.dict.size:0}#f(s){const r=this.#i.dictionaryRatio,o=this.#e.length;for(const l of this.#t){if(!l.candidate)continue;const a=this.#h(l);if(l.kind==="dictionary"&&a>=r*o){const p=this.#n.column(l.spec.id);l.distinct=new Set(p?.dict?p.dict.values():[]),this.#n.convert(l.spec.id,"object"),l.kind="object",l.change="demoted",l.reason=`${a} distinct values is at or above ${r*100}% of ${o} rows`;continue}if(l.kind==="object"&&a>=r*o){l.candidate=!1,l.distinct=null,l.reason=`${a} distinct values is at or above ${r*100}% of ${o} rows`;continue}s&&l.kind==="object"&&a<r*o&&(this.#n.convert(l.spec.id,"dictionary"),l.kind="dictionary",l.change=l.change==="demoted"?null:"promoted",l.reason=`${a} distinct values is below ${r*100}% of ${o} rows`,l.distinct=null),s&&(l.candidate=!1)}}}async function n(i,s={},r={}){const o=new u(i,s,r),l=r.scheduler?.frame??$;for(;o.slice();)await new Promise(a=>{l(a)});return o.result()}function t(i,s={},r={}){const o=new u(i,s,{...r,chunkMs:1/0});for(;o.slice(););return o.result()}}),Ce("packages/core/src/store/columnpack.js",function(e,G){"use strict";Object.defineProperty(e,"isPortableSchema",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"packChunk",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"packedTransfers",{enumerable:!0,get:function(){return u}});const M=G("packages/core/src/internal/util.js").pathGetter,$=G("packages/core/src/store/ingest.js"),R=$.inferKind,W=$.decideText,Z=$.INGEST_DEFAULTS,U=G("packages/core/src/store/columnstore.js").toFloat,D=new Set(["float64","int32","bitset","dictionary","object","multi"]);function I(n){if(!Array.isArray(n)||n.length===0)return!1;for(const t of n)if(!t||typeof t.id!="string"||typeof t.field!="string"||t.field===""||t.kind&&!D.has(t.kind))return!1;return!0}function k(n){const t=U(n);return Number.isFinite(t)?t|0:0}function S(n){return n==null?[]:Array.isArray(n)?n:[n]}function y(n,t,i,s){if(n.kind)return n.kind;const r=[];for(let a=0;a<t.length&&r.length<Z.sampleSize;a++){const p=t[a];p!=null&&r.push(p)}const o=R(r,{multi:n.multi});if(o!=="text")return o;const l=new Set(r).size;return W(l,r.length,s)}function d(n,t,i={}){const s=t.length|0,r=i.dictionaryRatio??Z.dictionaryRatio,o=[];for(const l of n){const a=M(l.field||l.id),p=l.nullable!==!1,m=new Array(s);for(let v=0;v<s;v++){const h=a(t[v]);m[v]=h===void 0?null:h}const b=y(l,m,s,r),g=p?new Uint8Array(s+7>>3):null,f=v=>{g&&(g[v>>3]|=1<<(v&7))};let w;switch(b){case"float64":{const v=new Float64Array(s);for(let h=0;h<s;h++){const c=m[h],j=c===null;j||f(h),v[h]=j?NaN:U(c)}w={id:l.id,kind:b,nullable:p,values:v,presence:g,offsets:null,table:null};break}case"int32":{const v=new Int32Array(s);for(let h=0;h<s;h++){const c=m[h],j=c===null;j||f(h),v[h]=j?0:k(c)}w={id:l.id,kind:b,nullable:p,values:v,presence:g,offsets:null,table:null};break}case"bitset":{const v=new Uint8Array(s+7>>3);for(let h=0;h<s;h++){const c=m[h],j=c===null;j||f(h),!j&&c&&(v[h>>3]|=1<<(h&7))}w={id:l.id,kind:b,nullable:p,values:v,presence:g,offsets:null,table:null};break}case"dictionary":{const v=new Uint32Array(s),h=[],c=new Map;for(let j=0;j<s;j++){const E=m[j];if(E===null){v[j]=0;continue}f(j);let O=c.get(E);O===void 0&&(O=h.length,h.push(E),c.set(E,O)),v[j]=O}w={id:l.id,kind:b,nullable:p,values:v,presence:g,offsets:null,table:h};break}case"multi":{const v=[],h=new Map,c=new Uint32Array(s+1),j=[];for(let E=0;E<s;E++){const O=m[E];c[E]=j.length,O===null||f(E);const A=S(O);for(let P=0;P<A.length;P++){const L=A[P];let z=h.get(L);z===void 0&&(z=v.length,v.push(L),h.set(L,z)),j.push(z)}}c[s]=j.length,w={id:l.id,kind:b,nullable:p,values:Int32Array.from(j),presence:g,offsets:c,table:v};break}default:{const v=new Array(s);for(let h=0;h<s;h++){const c=m[h];c!==null&&f(h),v[h]=c}w={id:l.id,kind:"object",nullable:p,values:v,presence:g,offsets:null,table:null};break}}o.push(w)}return{count:s,columns:o}}function u(n){const t=[];if(!n||!Array.isArray(n.columns))return t;const i=s=>{ArrayBuffer.isView(s)&&s.buffer&&!t.includes(s.buffer)&&t.push(s.buffer)};for(const s of n.columns)i(s.values),i(s.presence),i(s.offsets);return t}}),Ce("packages/core/src/source/stream.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_PROMOTE_BELOW",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"StreamSource",{enumerable:!0,get:function(){return O}});const _=G("packages/core/src/internal/util.js"),M=_.Lru,$=_.isFunction,R=_.now,W=_.nextFrame,Z=_.cancelFrame,V=_.whenIdle,U=_.defaultCompare,D=_.warnOnce,I=_.infoOnce,k=_.getPath,S=G("packages/core/src/source/abort.js"),y=S.createAbortScope,d=S.isAbortError,u=G("packages/core/src/source/rows.js"),n=u.createRowFactory,t=u.lazyRowView,s=G("packages/core/src/source/gapbuffer.js").GapBuffer,o=G("packages/core/src/source/memory.js").createMemorySource,a=G("packages/core/src/source/filterwire.js").querySignature,m=G("packages/core/src/store/columnpack.js").isPortableSchema,b=25e4,g=Symbol("lattice.stream.storeBacked"),f=8,w=.1,v=1e3,h=50;function c(T){return Math.min(v,Math.max(h,Math.floor(T/4)))}function j(T){if(T instanceof Date)return T.getTime();if(typeof T=="number")return Number.isFinite(T)?T:NaN;if(typeof T=="string"){const A=T.trim();if(!A)return NaN;const P=Date.parse(A);return Number.isNaN(P)?Number(A):P}return NaN}function E(T,A){return new O(T,A)}class O{mode="stream";writesStore=!0;#e;#t;#n=[];#r=null;#o=[];#i=null;#s;#l;#a=new Map;#u=y();#c={loaded:0,estimated:void 0};#d=null;#h=0;#f=0;#m=0;#p=0;#g=null;#w=null;#b=null;#v=!1;#y=!1;#S=!1;#A=!1;#j="";#O=0;#E=0;#C=0;#T=null;#D=1/0;#N=!1;#I=null;#M=null;#x=null;#W=null;#R=!1;#_=0;#B=0;#H=!1;constructor(A,P){this.#e=A||{mode:"stream"},this.#t=P||{},this.#s=n(this.#t),this.#l=new M(4096),this.#j=this.#Be();const L=(this.#t.config||{}).ingest;this.#R=!!L&&L.retainSource===!1,$(this.#e.open)||D("source.stream.open",'source.mode "stream" requires an open function; the grid will stay empty.'),this.#e.autoStart!==!1&&queueMicrotask(()=>this.start());const z=Number(this.#e.poll);Number.isFinite(z)&&z>0&&(this.#W=setInterval(()=>{this.#A||this.reload()},z),this.#W&&$(this.#W.unref)&&this.#W.unref()),this.#ae()}#ne(){const A=Number(this.#e.maxAge);return Number.isFinite(A)&&A>0?A:0}#ae(){const A=this.#ne();if(!A)return;const P=this.#e.ageBy;$(P)?this.#M=P:typeof P=="string"&&P?this.#M=L=>k(L,P):this.#M=null,this.#T=[],this.#I=setInterval(()=>{this.#A||this.#le()&&(this.#pe(),this.#je())},c(A)),this.#I&&$(this.#I.unref)&&this.#I.unref()}#le(){const A=this.#ne();return!A||!this.#T?!1:this.#N?!0:this.#D<Date.now()-A*(1+w)}#de(A,P){if(!this.#T)return;const L=this.#M?j(this.#M(P)):Date.now();this.#T[A]=L,Number.isNaN(L)||(L<this.#D&&(this.#D=L),L<Date.now()-this.#ne()&&(this.#N=!0))}#ie(){return this.#ce("groupBy",[]).length>0?!0:!!this.#ce("pivotMode",!1)&&this.#ce("pivotBy",[]).length>0}#oe(){if(this.#g||this.#A)return;const A=this.#ie();if(A&&!this.#w){this.#w=o({mode:"memory",rows:this.#n},this.#te()),this.#v=!1;return}!A&&this.#w&&(this.#w.destroy(),this.#w=null)}#te(){if(this.#b)return this.#b;const A=this,P={liveIndices:()=>A.#V(),live:L=>A.#n[L]!==void 0,source:L=>A.#ve(L),get physical(){return A.#n.length}};return this.#R&&(P.column=L=>{const z=A.#t.store;return z&&$(z.column)?z.column(L):void 0}),this.#b=Object.create(this.#t,{store:{value:P,enumerable:!0,configurable:!0}}),this.#b}#V(){const A=new Uint32Array(this.#n.length);let P=0;for(let L=0;L<this.#n.length;L++)this.#n[L]!==void 0&&(A[P++]=L);return A.subarray(0,P)}#z(){return this.#g?this.#g:this.#w?(this.#v&&(this.#v=!1,this.#w.setRows(this.#n)),this.#w):null}invalidate(A="filter"){if(this.#g){this.#g.invalidate(A);return}this.#oe(),this.#w&&this.#w.invalidate(A),(A==="filter"||A==="sort")&&this.#L()}count(){const A=this.#z();return A?A.count():this.#r?this.#r.length:this.#O}matchCount(){const A=this.#z();return A&&$(A.matchCount)?A.matchCount():this.#r?this.#r.length:this.#O}totalCount(){const A=this.#z();return A&&$(A.totalCount)?A.totalCount():this.#O}unfilteredRows(){const A=this.#z();if(A&&$(A.unfilteredRows))return A.unfilteredRows();const P=[];for(let L=0;L<this.#n.length;L++){if(!this.#n[L])continue;const z=this.#Ne(L);z&&P.push(z)}return P}at(A){const P=this.#z();if(P)return P.at(A);if(A<0||A>=this.count())return;const L=this.#r?this.#r.at(A):A,z=this.#Ne(L);return z.index=A,z}byKey(A){const P=this.#z();if(P)return P.byKey(A);const L=this.#a.get(A);return L===void 0?void 0:this.#Ne(L)}leavesOf(A){const P=this.#z();return P&&$(P.leavesOf)?P.leavesOf(A):[]}loaded(A){return A>=0&&A<this.count()}hint(A,P){if(this.#g){this.#g.hint(A,P);return}this.#Z(),this.#m=Math.max(0,Math.floor(A))}#Z(){this.#A||this.#Be()===this.#j||this.reload()}display(){const A=this.#z();return A?A.display():t(()=>this.count(),P=>this.at(P))}apply(A){if(this.#g)return this.#g.apply(A);const P={added:[],updated:[],removed:[]};if(!A)return P;if(A.update){let L=!1;for(const z of A.update){const H=this.#a.get(this.#s.keyOf(z,-1));if(H===void 0)continue;const x=this.#se(H);this.#R?this.#De(H,z):this.#n[H]=z,this.#l.delete(H),this.#Y(H,x),this.#T&&(this.#de(H,z),L=!0),this.#v=!0,P.updated.push(this.#Ne(H))}L&&this.#pe()}if(A.add&&A.add.length){const L=this.#ee(A.add);for(const z of L)P.added.push(this.#Ne(z))}return A.remove&&A.remove.length&&D("source.stream.remove","removing rows from a live stream is not supported; reload instead."),this.#je(),P}reload(A){this.#u.abortAll("reload"),this.#We(),this.#w&&(this.#w.destroy(),this.#w=null),this.#v=!1,this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear(),this.#g=null,this.#O=0,this.#E=0,this.#C=0,this.#T&&(this.#T=[]),this.#D=1/0,this.#N=!1,this.#y=!1,this.#S=!1,this.#c={loaded:0,estimated:void 0},this.#j=this.#Be(),this.#ke("model:changed",{reason:"reload"}),this.start()}destroy(){this.#A=!0,this.#W!==null&&(clearInterval(this.#W),this.#W=null),this.#I!==null&&(clearInterval(this.#I),this.#I=null),this.#T=null,this.#u.abortAll("destroyed"),this.#We(),this.#d!==null&&(this.#Ge(this.#d),this.#d=null),this.#w&&(this.#w.destroy(),this.#w=null),this.#g&&this.#g.destroy(),this.#n=[],this.#r=null,this.#a.clear(),this.#l.clear()}async start(){if(this.#S||this.#A||!$(this.#e.open))return;this.#S=!0;const A=this.#u.begin("stream");this.#L(),this.#oe();let P;try{P=this.#e.open({sort:this.#ce("sort",[]),filters:this.#ce("filters",null),quick:this.#ce("quick","")||void 0,context:this.#ce("context",null),signal:A.signal})}catch(z){this.#ke("source:error",{error:z});return}const L=$(P[Symbol.asyncIterator])?P[Symbol.asyncIterator]():P[Symbol.iterator]();this.#x=L;try{for(;;){const z=await L.next();if(!A.current||this.#A)return;if(z.done){this.#Te();return}if(await this.#q(z.value,A),!A.current||this.#A)return;if(z.value&&z.value.done){this.#Te();return}if(await this.#xe(),!A.current||this.#A)return}}catch(z){if(d(z))return;this.#ke("source:error",{error:z})}finally{A.settle()}}progress(){return{loaded:this.#c.loaded,estimated:this.#c.estimated,done:this.#y,live:this.#O,evicted:this.#E}}promoted(){return this.#g!==null}memorySource(){return this.#g}invalidateHandles(){const A=this.#z();A&&($(A.invalidateHandles)&&A.invalidateHandles(),$(A.invalidate)&&A.invalidate("sort"))}renderCount(){return this.#h}ingestStats(){return{worker:this.#_,inline:this.#B,storeBacked:this.#R}}#q(A,P){if(!A)return;const L=A.rows;if(L&&L.length&&this.#G(L))return this.#be(A,P);const z=R();L&&L.length&&(this.#ee(L),this.#B++),this.#K(A),this.#f+=R()-z,this.#je()}#K(A){this.#c.loaded=A.progress&&typeof A.progress.loaded=="number"?A.progress.loaded:this.#n.length,A.progress&&typeof A.progress.estimated=="number"&&(this.#c.estimated=A.progress.estimated)}#G(A){if(this.#H||this.#g)return!1;const P=this.#we();if(!P)return!1;const L=this.#t.store;if(!L||!$(L.appendPacked))return!1;const z=this.#Me();return!z||!m(z)?(this.#H=!0,I("source.stream.ingest-worker","stream ingest.useWorker is on but a column reads through a closure (a computed or date column); columnizing on the main thread instead."),!1):A.length<P.threshold?!1:!this.#me(A)}#me(A){if(!this.#s.keyed)return!1;const P=new Set;for(let L=0;L<A.length;L++){const z=this.#s.keyOf(A[L],this.#n.length+L);if(z!=null){if(P.has(z)||this.#a.has(z))return!0;P.add(z)}}return!1}async#be(A,P){const L=A.rows,z=this.#we(),H=this.#Me();let x;try{x=await z.columnize(H,L,{key:"ingest:stream",signal:P&&P.signal})}catch(Q){if(d(Q)||(D("source.stream.columnize","worker columnization failed; columnizing on the main thread",Q),this.#H=!0,P&&(!P.current||this.#A)))return;this.#ee(L),this.#B++,this.#K(A),this.#je();return}if(P&&(!P.current||this.#A))return;const F=this.#t.store,C=this.#R?void 0:L,{from:B}=F.appendPacked(x,C),q=x.count|0;for(let Q=0;Q<q;Q++){const Y=B+Q,J=L[Q],te=this.#s.keyed?this.#s.keyOf(J,Y):null;if(this.#n[Y]=this.#R?g:J,this.#O++,this.#de(Y,J),te!==null&&this.#a.set(te,Y),!this.#r||!this.#Oe(Y))continue;const ee=this.#k(Y);this.#r.insert(ee,Y),ee<=this.#m&&this.#p++}this.#v=!0,this.#pe(),this.#_++,this.#K(A),this.#je()}#we(){const A=this.#t.ingestWorker;return $(A)?A():null}#Me(){const A=this.#t.storeSchema;return $(A)?A():null}#ee(A){const P=[],L=this.#t.store,z=new Array(A.length),H=[],x=new Set;for(let C=0;C<A.length;C++){const B=this.#s.keyed?this.#s.keyOf(A[C],this.#n.length+H.length):null;z[C]=B,!(B!==null&&(this.#a.has(B)||x.has(B)))&&(B!==null&&x.add(B),H.push(A[C]))}let F=H.length&&L&&$(L.append)?L.append(H).from:this.#n.length;for(let C=0;C<A.length;C++){const B=A[C],q=z[C];if(q!==null&&this.#a.has(q)){const J=this.#a.get(q),te=this.#se(J);this.#R||(this.#n[J]=B,L&&$(L.setSource)&&L.setSource(J,B)),this.#De(J,B),this.#l.delete(J),this.#de(J,B),this.#Y(J,te);continue}const Q=F++;if(this.#n[Q]=this.#R?g:B,this.#O++,this.#de(Q,B),q!==null&&this.#a.set(q,Q),P.push(Q),!this.#r||!this.#Oe(Q))continue;const Y=this.#k(Q);this.#r.insert(Y,Q),Y<=this.#m&&this.#p++}return this.#v=!0,this.#pe(),P}#fe(A){const P=this.#n[A];let L=!1;if(this.#r){const F=this.#U(A);F>=0&&F<=this.#m&&(L=!0)}else A<=this.#m&&(L=!0);const z=P===g?this.#ve(A):P,H=this.#s.keyed?this.#s.keyOf(z,A):null;H!==null&&this.#a.get(H)===A&&this.#a.delete(H),this.#n[A]=void 0,this.#T&&(this.#T[A]=NaN),this.#l.delete(A);const x=this.#t.store;return x&&$(x.remove)&&x.remove(A),this.#O--,L}#pe(){let A=0,P=0;const L=this.#ue();A+=L.dropped,P+=L.aboveAnchor;const z=this.#ge();A+=z.dropped,P+=z.aboveAnchor,A&&(this.#v=!0,this.#E+=A,this.#L(),this.#p-=P,this.#ke("stream:evicted",{evicted:A,total:this.#E,live:this.#O}))}#ge(){const A=this.#e.maxRows;if(!Number.isFinite(A)||A<=0||this.#O<=A)return{dropped:0,aboveAnchor:0};const P=Math.max(1,Math.floor(A*(1-w)));let L=0,z=0;for(;this.#O>P&&this.#C<this.#n.length;){const H=this.#C++;this.#n[H]!==void 0&&(this.#fe(H)&&z++,L++)}return{dropped:L,aboveAnchor:z}}#ue(){const A=this.#ne();if(!A||!this.#T||!this.#le())return{dropped:0,aboveAnchor:0};const P=Date.now()-A;let L=0,z=0,H=1/0;for(let x=this.#C;x<this.#n.length;x++){if(this.#n[x]===void 0)continue;const F=this.#T[x];if(!(Number.isNaN(F)||F===void 0)){if(F>=P){F<H&&(H=F);continue}this.#fe(x)&&z++,L++}}for(this.#D=H,this.#N=!1;this.#C<this.#n.length&&this.#n[this.#C]===void 0;)this.#C++;return{dropped:L,aboveAnchor:z}}#U(A){if(!this.#r)return A;for(let P=0;P<this.#r.length;P++)if(this.#r.at(P)===A)return P;return-1}#L(){this.#o=this.#ce("sort",[]),this.#i=this.#ce("filters",null);const A=Number.isFinite(this.#e.maxRows)&&this.#e.maxRows>0||this.#ne()>0,P=this.#ce("where",null),L=(this.#t.config||{}).hostFilter,z=!!(P&&P.active)||!!(L&&$(L.active)&&L.active());if(!(A||this.#o.length>0||!!this.#i||!!this.#ce("quick","")||z)){this.#r=null;return}this.#r=new s(Math.max(64,this.#n.length+64));for(let x=0;x<this.#n.length;x++)this.#n[x]!==void 0&&this.#Oe(x)&&this.#r.insert(this.#k(x),x)}#Oe(A){const P=this.#ve(A);if(this.#i&&!this.#re(this.#i,P))return!1;const L=String(this.#ce("quick","")||"").toLowerCase();if(L&&!this.#Ke(P).includes(L))return!1;const z=(this.#t.config||{}).hostFilter;if(z&&$(z.active)&&z.active()&&!z.passes(this.#Ne(A)))return!1;const H=this.#ce("where",null);if(H&&H.active){const x=this.#Ne(A);if(!H.passes(x.data,x.key))return!1}return!0}#re(A,P){if(!A)return!0;const L=A;if(Array.isArray(L.conditions))return L.op==="or"?L.conditions.some(x=>this.#re(x,P)):L.op==="not"?!L.conditions.some(x=>this.#re(x,P)):L.conditions.every(x=>this.#re(x,P));const z=A,H=(this.#t.compute||{}).testValue;return $(H)?!!H(this.#X(P,z.col),z,(this.#t.config||{}).locale):(D("source.stream.testValue","ctx.compute.testValue is unavailable; streamed rows are not filtered client-side."),!0)}#se(A){if(!this.#r)return-1;if(!this.#o.length)return this.#U(A);let P=0,L=this.#r.length;for(;P<L;){const z=P+L>>>1;this.#Ee(this.#r.at(z),A)<0?P=z+1:L=z}for(let z=P;z<this.#r.length;z++){const H=this.#r.at(z);if(H===A)return z;if(this.#Ee(H,A)>0)break}return this.#U(A)}#Y(A,P){if(!this.#r||!this.#o.length)return;const L=this.#Oe(A);if(P>=0&&this.#r.at(P)===A)this.#r.removeAt(P),P<=this.#m&&this.#p--;else if(P>=0)return;if(!L)return;const z=this.#k(A);this.#r.insert(z,A),z<=this.#m&&this.#p++}#k(A){if(!this.#r||!this.#o.length)return this.#r?this.#r.length:0;let P=0,L=this.#r.length;for(;P<L;){const z=P+L>>>1;this.#Ee(A,this.#r.at(z))<0?L=z:P=z+1}return P}#Ee(A,P){const L=this.#ve(A),z=this.#ve(P);for(const H of this.#o){const x=this.#nt(H.col),F=this.#X(L,H.col),C=this.#X(z,H.col),q=(x&&x.value&&$(x.value.compare)?x.value.compare:U)(F,C);if(q!==0)return H.dir==="desc"?-q:q}return 0}#Te(){this.#y=!0,this.#c.loaded=this.#c.loaded||this.#n.length;const A=typeof this.#e.promoteToMemoryBelow=="number"?this.#e.promoteToMemoryBelow:b;!this.#R&&this.#n.length<A&&(this.#g=o({mode:"memory",rows:this.#n},this.#t),this.#I!==null&&(clearInterval(this.#I),this.#I=null),this.#w&&(this.#w.destroy(),this.#w=null)),this.#je(),this.#ke("stream:end",{loaded:this.#n.length,promoted:this.#g!==null,threshold:A})}#je(){this.#d!==null||this.#A||(this.#d=this.#ze(()=>{this.#d=null,this.#h++;const A=this.#p;this.#p=0,this.#f=0,this.#ke("stream:chunk",{loaded:this.#c.loaded,estimated:this.#c.estimated,count:this.count(),renders:this.#h}),this.#ke("model:changed",{reason:"stream",shiftAboveViewport:A,anchor:this.#m}),this.#ke("rows:changed",{companion:!0,reason:"stream"})}))}#xe(){return this.#h===0||this.#f<this.#Ie()?Promise.resolve():(this.#f=0,new Promise(A=>{const P=(this.#t.scheduler||{}).idle;$(P)?P(()=>A()):V(()=>A())}))}#Ie(){return typeof this.#e.coalesceMs=="number"&&this.#e.coalesceMs>0?this.#e.coalesceMs:f}#ze(A){const P=this.#t.scheduler||{};return $(P.frame)?P.frame(A):W(A)}#Ge(A){const P=this.#t.scheduler||{};$(P.cancel)?P.cancel(A):Z(A)}#ve(A){const P=this.#n[A];if(P!==void 0&&P!==g)return P;if(P===void 0)return;const L=this.#t.store;return L&&$(L.source)?L.source(A):void 0}#De(A,P){const L=this.#t.store;if(!L||!$(L.set))return;const z=this.#Me();if(Array.isArray(z))for(const H of z){if(!H||!H.id)continue;const x=$(H.read)?H.read:F=>k(F,H.field||H.id);L.set(H.id,A,x(P))}}#Ne(A){let P=this.#l.get(A);return P||(P=this.#s.leaf(this.#ve(A),A),this.#l.set(A,P)),P}#X(A,P){const L=this.#nt(P);return L&&$(L.getValue)?L.getValue(A):A?.[P]}#Ke(A){const P=this.#t.columns,L=P&&$(P.all)?P.all():[],z=[];for(const H of L){const x=$(H.getValue)?H.getValue(A):void 0;x!=null&&x!==""&&z.push(String(x))}return z.join(" ").toLowerCase()}#nt(A){const P=this.#t.columns;return P&&$(P.get)?P.get(A):void 0}#We(){const A=this.#x;if(this.#x=null,A&&$(A.return))try{A.return()}catch{}}#Be(){return a({context:this.#ce("context",null)})}#ce(A,P){const L=this.#t.state;if(L&&$(L[A])){const z=L[A]();return z??P}return P}#ke(A,P){const L=this.#t.emit;$(L)&&L(A,P)}}}),Ce("packages/core/src/source/url.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_URL_BATCH",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return k}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.isObject,R=_.isFunction,W=_.getPath,V=G("packages/core/src/source/abort.js").isAbortError,U=500,D=new Set(["application/x-ndjson","application/ndjson","application/jsonlines","application/jsonl","application/x-jsonlines","text/x-ndjson"]),I=Symbol("lattice.url.skip");function k(m,b={}){const g=$(b)?b:{},f=R(g.fetch)?g.fetch:typeof globalThis<"u"&&R(globalThis.fetch)?globalThis.fetch:null,w=g.format==="json"||g.format==="ndjson"?g.format:void 0,v=typeof g.rowsPath=="string"&&g.rowsPath?g.rowsPath:void 0,h=R(g.map)?g.map:void 0,c=$(g.headers)?g.headers:void 0,j=Number.isFinite(g.batchSize)&&g.batchSize>0?Math.floor(g.batchSize):U,E=g.lenient===!0,O=Number.isFinite(g.poll)&&g.poll>0?Math.floor(g.poll):void 0,T=typeof m=="string"&&m.length>0;T||M("source.url.url","createUrlSource needs a URL string; the grid will stay empty.");async function*A(L={}){if(!T)return;if(!f)throw new Error("[lattice] createUrlSource: no fetch available — pass opts.fetch or run where globalThis.fetch exists.");const z=L&&L.signal;let H;try{H=await f(m,c?{signal:z,headers:c}:{signal:z})}catch(C){throw V(C)?C:new Error(`[lattice] createUrlSource: request to ${m} failed — ${C&&C.message||C}`)}if(!H||!H.ok){const C=H?H.status:"no response";throw new Error(`[lattice] createUrlSource: ${C} for ${m}`)}const x=S(m,w,H),F=H.body&&R(H.body.getReader)?H.body.getReader():null;try{if(!F){const q=await H.text();(x||u(q,m))==="ndjson"?yield*o(null,null,q,0,H,m,j,E):yield*r(q,m,v,h);return}const C=new TextDecoder("utf-8");if(x==="json"){yield*r(await s(F,C,""),m,v,h);return}if(x==="ndjson"){yield*o(F,C,"",0,H,m,j,E);return}const B=await n(F,C,m);B.format==="json"?yield*r(await s(F,C,B.seed),m,v,h):yield*o(F,C,B.seed,B.bytes,H,m,j,E)}finally{if(F&&R(F.cancel))try{await F.cancel()}catch{}}}const P={mode:"stream",open:A,autoStart:g.autoStart!==!1};return O!==void 0&&(P.poll=O),Number.isFinite(g.maxRows)&&(P.maxRows=g.maxRows),Number.isFinite(g.maxAge)&&(P.maxAge=g.maxAge),(typeof g.ageBy=="string"||R(g.ageBy))&&(P.ageBy=g.ageBy),Number.isFinite(g.coalesceMs)&&(P.coalesceMs=g.coalesceMs),Number.isFinite(g.promoteToMemoryBelow)&&(P.promoteToMemoryBelow=g.promoteToMemoryBelow),P}function S(m,b,g){if(b)return b;const f=y(m);if(f)return f;const w=g&&g.headers&&R(g.headers.get)?g.headers.get("content-type"):null;return d(w)}function y(m){const b=String(m).split(/[?#]/)[0].toLowerCase();if(b.endsWith(".ndjson")||b.endsWith(".jsonl"))return"ndjson";if(b.endsWith(".json"))return"json"}function d(m){if(!m)return;const b=m.split(";")[0].trim().toLowerCase();if(D.has(b))return"ndjson";if(b==="application/json"||b==="text/json"||b.endsWith("+json"))return"json"}function u(m,b){const g=m.replace(/^\s+/,""),f=t(g);if(f==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${b} — pass opts.format: 'json' | 'ndjson'.`);return f}async function n(m,b,g){let f="",w=0;for(;;){const{value:h,done:c}=await m.read();if(h&&(w+=h.byteLength,f+=b.decode(h,{stream:!0})),c){f+=b.decode();break}const j=f.replace(/^\s+/,"");if(j){if(j[0]==="[")return{format:"json",seed:f,bytes:w};if(j[0]!=="{"||f.indexOf(`
8
8
  `)!==-1)break}}const v=t(f.replace(/^\s+/,""));if(v==="error")throw new Error(`[lattice] createUrlSource: could not tell JSON from NDJSON for ${g} — pass opts.format: 'json' | 'ndjson'.`);return{format:v,seed:f,bytes:w}}function t(m){if(!m||m[0]==="[")return"json";if(m[0]!=="{")return"error";const b=m.indexOf(`
9
9
  `);if(b===-1)return"json";let g=m.slice(0,b);return g.endsWith("\r")&&(g=g.slice(0,-1)),i(g)?"ndjson":"json"}function i(m){try{return JSON.parse(m),!0}catch{return!1}}async function s(m,b,g){let f=g;for(;;){const{value:w,done:v}=await m.read();if(w&&(f+=b.decode(w,{stream:!0})),v)break}return f+=b.decode(),f}function*r(m,b,g,f){let w;try{w=JSON.parse(m)}catch(h){throw new Error(`[lattice] createUrlSource: ${b} is not valid JSON — ${h.message}`)}let v=g!==void 0?W(w,g):w;if(f&&(v=f(v)),!Array.isArray(v)){const h=g!==void 0||f?"":"; pass opts.rowsPath or opts.map to select the array";throw new Error(`[lattice] createUrlSource: ${b} did not resolve to an array${h}.`)}yield{rows:v,progress:{loaded:v.length,estimated:v.length}}}async function*o(m,b,g,f,w,v,h,c){const j=p(w);let E=g||"",O=f||0,T=0,A=0,P=[];function*L(){let H;for(;(H=E.indexOf(`
@@ -53,6 +53,6 @@ ${te}[data-heat-side="low"]{background-color:color-mix(in srgb, var(--lattice-va
53
53
  `,w),E=g.slice(c,j),O=E.split(`
54
54
  `);let T=0;const A=O.map(P=>{if(!m)return T+=v.length,v+P;if(P.startsWith(v))return T-=v.length,P.slice(v.length);const L=P.replace(/^[ \t]/,"");return T-=P.length-L.length,L}).join(`
55
55
  `);return A===E?!1:(b.value=g.slice(0,c)+A+g.slice(j),this.#r(Math.max(c,f+(m?-v.length:v.length)),Math.max(c,w+T)),this.revalidate(),!0)}#r(m,b){const g=this.input;g&&(g.selectionStart=m,g.selectionEnd=b===void 0?m:b,V(g.setSelectionRange)&&g.setSelectionRange(g.selectionStart,g.selectionEnd))}format(m){const b=this.input;if(!b||this.language!=="json")return!1;const g=n(b.value);if(!g.ok)return this.revalidate(),!1;if(g.value===null&&b.value.trim()==="")return!1;try{const f=JSON.stringify(g.value,null,m===void 0?this.indent:m);return f===void 0?!1:(b.value=f,this.#r(f.length),this.revalidate(),!0)}catch{return!1}}revalidate(){const m=this.input?this.input.value:"",b=r(m,this.language);this.lastResult=b;const g=this.errorNode;return g&&(g.textContent=b.ok?"":o(b),g.classList.toggle(k.errorOn,!b.ok)),this.input&&(b.ok?this.input.removeAttribute("aria-invalid"):this.input.setAttribute("aria-invalid","true"),b.ok||!g?this.input.removeAttribute("aria-errormessage"):(g.id||(g.id=U("lat-err")),this.input.setAttribute("aria-errormessage",g.id))),b}text(){return this.input?this.input.value:""}readValue(){const m=this.text();if(m.trim()==="")return null;if(this.language!=="json"||(this.props.parseOnCommit??!0)!==!0)return m;const g=n(m);return g.ok?g.value:m}checkValue(m){if(this.props.allowInvalid===!0)return!0;const b=this.revalidate();return b.ok?!0:o(b)}toClipboard(){return this.text()}fromClipboard(m){const b=m==null?"":String(m);return this.input&&(this.input.value=b),this.revalidate(),b.trim()===""?{ok:!0,value:null}:this.language!=="json"?{ok:!0,value:b}:{ok:!0,value:I(b)}}destroy(){for(const m of this.#e)m();this.#e.length=0,this.input=null,this.errorNode=null,this.formatButton=null,super.destroy()}}const a=l}),Ce("packages/dom/src/editors/unit.js",function(e,G){"use strict";Object.defineProperty(e,"presentUnit",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,V=G("packages/core/src/internal/util.js").isFunction,U=G("packages/core/src/columns/types/unit.js"),D=U.parseUnit,I=U.formatUnit,k=U.findUnit;function S(u,n){return I(u,n)}class y extends M{input=null;hint=null;opts=null;#e=[];buildOptions(){const n=this.props,t=this.params.column&&this.params.column.dataType||null,i=t&&t.unitConfig||{};return{system:n.system||i.system||"data",unit:n.unit??i.unit,binary:n.binary===!0||n.binary===void 0&&i.binary===!0,display:n.display??i.display,locale:this.params.locale,group:!1,minDecimals:0,maxDecimals:20}}build(){const n=this.props;this.opts=this.buildOptions();const t=this.symbol(),i=`${this.id}-unit`,s=R(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":t?i:null}});s.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(s.value=this.params.key),this.input=s;const r=typeof n.step=="number"?n.step:0;return r>0&&this.#e.push(W(s,"keydown",o=>{o.key==="ArrowUp"?(V(o.preventDefault)&&o.preventDefault(),this.nudge(r)):o.key==="ArrowDown"&&(V(o.preventDefault)&&o.preventDefault(),this.nudge(-r))})),this.hint=R(this.doc,"span",{class:`${$.editor}__suffix`,text:t,attrs:{id:i,"aria-hidden":"true"}}),R(this.doc,"div",{class:`${$.editor}__unit`,children:[s,this.hint]})}symbol(){const n=k(this.opts.system,this.opts.unit);return n?n.symbol:String(this.opts.unit||"")}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&V(n.select)&&n.select()}nudge(n){const t=D(this.input?this.input.value:"",this.opts);let i=(t??0)+n;const{min:s,max:r}=this.props;typeof s=="number"&&i<s&&(i=s),typeof r=="number"&&i>r&&(i=r),this.input&&(this.input.value=S(i,this.opts))}readValue(){const n=this.input?this.input.value:"";if(String(n).trim()==="")return null;const t=D(n,this.opts);if(t===null)return NaN;if(this.mode()!=="clamp")return t;const{min:i,max:s}=this.props;let r=t;return typeof i=="number"&&r<i&&(r=i),typeof s=="number"&&r>s&&(r=s),r}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}checkValue(n){if(n===null)return!0;if(typeof n!="number"||Number.isNaN(n)){const t=this.symbol();return t?`Enter a value such as 10 ${t}`:"Enter a value"}if(this.mode()==="reject"){const{min:t,max:i}=this.props;if(typeof t=="number"&&n<t)return`Must be ${this.describe(t)} or more`;if(typeof i=="number"&&n>i)return`Must be ${this.describe(i)} or less`}return!0}describe(n){return I(n,{...this.opts,display:this.opts.unit,group:!0,maxDecimals:4})}toClipboard(){return I(this.readValue(),{...this.opts,display:this.opts.unit})}fromClipboard(n){const t=n==null?"":String(n);if(t.trim()==="")return{ok:!0,value:null};const i=D(t,this.opts),s=i===null?NaN:i,r=this.checkValue(s);return r!==!0?{ok:!1,message:r}:{ok:!0,value:s}}destroy(){for(const n of this.#e)n();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const d=y}),Ce("packages/dom/src/editors/radix.js",function(e,G){"use strict";Object.defineProperty(e,"RADIX_CLS",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"mergeRadixOptions",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return r}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,Z=G("packages/core/src/internal/util.js"),V=Z.isFunction,U=Z.uid,D=G("packages/core/src/columns/types/radix.js"),I=D.compileRadixFormat,k=D.compileRadixParse,S=D.normaliseRadixOptions,y=D.radixRange,d=Object.freeze({root:"lat-editor__radix",hint:"lat-editor__hint",hintInvalid:"lat-editor__hint--invalid"}),u=Object.freeze(["preset","radix","prefix","uppercase","pad","group","groupSeparator","bitWidth","signed","nullDisplay"]),n=new Map;function t(o){const l=o||"";let a=n.get(l);if(a)return a;try{a=new Intl.NumberFormat(o||void 0,{maximumFractionDigits:0})}catch{a={format:p=>String(p)}}return n.set(l,a),a}function i(o,l){const a=l||{},p={};if(o){for(const b of u)o[b]!==void 0&&(p[b]=o[b]);const m=y(o.bitWidth??null,o.signed!==!1);typeof o.min=="number"&&o.min>m.min&&(p.min=o.min),typeof o.max=="number"&&o.max<m.max&&(p.max=o.max)}for(const m of u)a[m]!==void 0&&(p[m]=a[m]);return typeof a.min=="number"&&(p.min=a.min),typeof a.max=="number"&&(p.max=a.max),S(p)}class s extends M{input=null;hint=null;options=null;format=null;parse=null;#e=[];build(){const l=this.params.column&&this.params.column.dataType;this.options=i(l&&l.radix||null,this.props),this.format=I(this.options),this.parse=k(this.options);const a=R(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:this.options.radix===2?"numeric":"text",autocomplete:"off",autocapitalize:"off",spellcheck:"false",placeholder:this.props.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-valuemin":this.options.min,"aria-valuemax":this.options.max}});a.value=this.format(this.params.value),this.params.key&&this.#t(this.params.key)&&(a.value=this.params.key),this.input=a;const p=R(this.doc,"span",{class:d.hint,attrs:{"aria-live":"polite"}});this.hint=p,this.#e.push(W(a,"input",()=>this.refresh())),this.#e.push(W(a,"keydown",b=>this.#n(b)));const m=R(this.doc,"div",{class:d.root,children:[a,p]});return this.refresh(),m}focusTarget(){return this.input}attached(){super.attached();const l=this.input;l&&!this.params.key&&this.props.selectOnFocus!==!1&&V(l.select)&&l.select()}#t(l){return l.length===1&&/[0-9a-fA-FxXbBoO#+\-.]/.test(l)}#n(l){const a=typeof this.props.step=="number"&&this.props.step!==0?this.props.step:1;l.key==="ArrowUp"?(V(l.preventDefault)&&l.preventDefault(),this.nudge(a)):l.key==="ArrowDown"&&(V(l.preventDefault)&&l.preventDefault(),this.nudge(-a))}mode(){return this.props.outOfRange==="clamp"||this.props.clamp===!0?"clamp":"reject"}clamp(l){const{min:a,max:p}=this.options;return l<a?a:l>p?p:l}evaluate(){const l=this.input?String(this.input.value):"";if(l.trim()==="")return{value:null,message:null};const a=this.parse(l);return a.ok?{value:this.mode()==="clamp"?this.clamp(a.value):a.value,message:null}:this.mode()==="clamp"&&typeof a.value=="number"&&(a.reason==="range"||a.reason==="negative")?{value:this.clamp(a.value),message:null}:{value:NaN,message:this.messageFor(a.reason)}}messageFor(l){const a=this.options;return l==="negative"?`This column holds an unsigned ${a.bitWidth}-bit pattern; enter ${this.format(0)} or more`:l==="range"?`Must be between ${this.format(a.min)} and ${this.format(a.max)}`:`Enter a ${a.name} value, e.g. ${this.format(a.radix===2?5:26)}`}refresh(){const{value:l,message:a}=this.evaluate();if(this.input&&this.input.classList&&(a?this.input.classList.add($.invalid):this.input.classList.remove($.invalid),this.input.setAttribute("aria-invalid",a?"true":"false"),a&&this.hint?(this.hint.id||(this.hint.id=U("lat-err")),this.input.setAttribute("aria-errormessage",this.hint.id)):this.input.removeAttribute("aria-errormessage")),!!this.hint){if(a){this.hint.textContent=a,this.hint.classList&&this.hint.classList.add(d.hintInvalid);return}this.hint.classList&&this.hint.classList.remove(d.hintInvalid),this.hint.textContent=l===null?"":`= ${t(this.params.locale).format(l)}`}}nudge(l){if(!this.input)return;const a=this.parse(this.input.value);let p;typeof a.value=="number"?p=a.value:typeof this.params.value=="number"?p=this.params.value:p=0,this.input.value=this.format(this.clamp(p+l)),this.refresh()}readValue(){return this.evaluate().value}checkValue(l){return l===null?!0:typeof l!="number"||Number.isNaN(l)?this.evaluate().message||this.messageFor("digits"):!this.options.signed&&l<0?this.messageFor("negative"):this.mode()==="reject"&&(l<this.options.min||l>this.options.max)?this.messageFor("range"):!0}toClipboard(){const l=this.readValue();return l===null||Number.isNaN(l)?this.input?String(this.input.value):"":this.format(l)}fromClipboard(l){const a=l==null?"":String(l);if(a.trim()==="")return{ok:!0,value:null};const p=this.parse(a);let m;if(p.ok)m=p.value;else if(this.mode()==="clamp"&&typeof p.value=="number"&&(p.reason==="range"||p.reason==="negative"))m=this.clamp(p.value);else return{ok:!1,message:this.messageFor(p.reason)};const b=this.checkValue(m);return b!==!0?{ok:!1,message:b}:{ok:!0,value:m}}destroy(){for(const l of this.#e)l();this.#e.length=0,this.input=null,this.hint=null,super.destroy()}}const r=s}),Ce("packages/dom/src/editors/segmented.js",function(e,G){"use strict";Object.defineProperty(e,"SEGMENTED_MAX",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,Z=_.keyOf,V=_.normaliseLookup,U=_.documentFor,D=_.lookupFor,k=G("packages/dom/src/editors/select.js").SelectEditor,y=G("packages/core/src/internal/util.js").isFunction,u=G("packages/dom/src/cell/icons.js").createIcon,n=6;class t extends M{static popup=!1;options=[];selected=null;segments=[];focused=0;#e=null;#t=[];init(o){const l=o||{},a=i(l),p=D(l,a,{colId:l.column&&(l.column.id||l.column.field)}),m=Number(a.max??n),b=p.options().length;if(Number.isFinite(m)&&b>m){const g=new k;g.init(l),this.#e=g,this.params=l,this.doc=U(l),this.props=a,this.lookup=p,this.popup=g.popup;return}super.init(l),(!this.lookup||!this.lookup.options().length)&&(this.lookup=p)}usesFallback(){return this.#e!==null}build(){const o=this.doc;this.options=this.lookup?this.lookup.options():[],this.selected=this.params.value??null;const l=R(o,"div",{class:`${$.editor}__segmented`,attrs:{role:"radiogroup","aria-label":this.params.column&&this.params.column.title||null,"data-size":this.props.size?String(this.props.size):null}});for(let a=0;a<this.options.length;a++)l.appendChild(this.buildSegment(this.options[a],a));return this.props.allowClear===!0&&l.appendChild(this.buildClear()),this.#t.push(W(l,"keydown",a=>this.onKeyDown(a))),this.focused=Math.max(0,this.indexOf(this.selected)),this.paint(),l}buildSegment(o,l){const a=this.doc,p=R(a,"button",{class:`${$.editor}__segment`,attrs:{type:"button",role:"radio",tabindex:"-1","aria-checked":"false","data-index":l,"data-variant":o.variant??null,"aria-disabled":o.disabled===!0?"true":null}});return o.icon&&p.appendChild(u(a,o.icon,{className:$.icon})),p.appendChild(R(a,"span",{class:`${$.editor}__segment-label`,text:o.label})),this.#t.push(W(p,"mousedown",m=>{m&&y(m.preventDefault)&&m.preventDefault(),o.disabled!==!0&&(this.focused=l,this.select(l,{commit:!0}))})),this.segments.push(p),p}buildClear(){const o=R(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clear")}});return this.#t.push(W(o,"mousedown",l=>{l&&y(l.preventDefault)&&l.preventDefault(),this.clearSelection()})),o}indexOf(o){if(o==null)return-1;const l=Z(o);for(let a=0;a<this.options.length;a++)if(Z(this.options[a].id)===l)return a;return-1}paint(){for(let o=0;o<this.segments.length;o++){const l=o===this.indexOf(this.selected),a=this.segments[o];a.setAttribute("aria-checked",l?"true":"false"),a.setAttribute("tabindex",o===this.focused?"0":"-1"),a.classList.toggle(`${$.editor}__segment--active`,l),a.classList.toggle(`${$.editor}__segment--disabled`,this.options[o].disabled===!0)}}select(o,l){const a=this.options[o];!a||a.disabled===!0||(this.selected=a.id,this.paint(),l&&l.commit&&this.commit())}clearSelection(){this.selected=null,this.paint()}moveFocus(o){const l=this.segments.length;if(!l)return;let a=this.focused;for(let p=0;p<l;p++)if(a=(a+o+l)%l,this.options[a].disabled!==!0){this.focusAt(a);return}}focusAt(o){if(o<0||o>=this.segments.length)return;this.focused=o,this.paint();const l=this.segments[o];l&&y(l.focus)&&l.focus()}edgeIndex(o){const l=this.options.length;for(let a=0;a<l;a++){const p=o===1?a:l-1-a;if(this.options[p].disabled!==!0)return p}return-1}onKeyDown(o){const l=()=>{y(o.preventDefault)&&o.preventDefault()};switch(o.key){case"ArrowRight":case"ArrowDown":l(),this.moveFocus(1);break;case"ArrowLeft":case"ArrowUp":l(),this.moveFocus(-1);break;case"Home":l(),this.focusAt(this.edgeIndex(1));break;case"End":l(),this.focusAt(this.edgeIndex(-1));break;case"Enter":l(),this.select(this.focused,{commit:!0});break;case" ":case"Spacebar":l(),this.select(this.focused);break;case"Escape":l(),this.cancel();break;case"Tab":this.select(this.focused),this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.clearSelection());break;default:break}}readValue(){return this.selected??null}checkValue(o){return o==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose a value":!this.lookup||!this.lookup.options().length||this.lookup.option(o)||this.lookup.allowCustom||this.props.allowCustom===!0?!0:`"${String(o)}" is not a valid option`}element(){return this.#e?this.#e.element():super.element()}value(){return this.#e?this.#e.value():super.value()}focusTarget(){if(!this.segments.length)return super.focusTarget();const o=this.indexOf(this.selected);return this.segments[o>=0?o:Math.max(0,this.edgeIndex(1))]||null}attached(){if(this.#e){this.#e.attached();return}if(super.attached(),!this.lookup)return;const o=this.lookup.ready();!o||!y(o.then)||o.then(()=>{if(!super.element()||this.options.length)return;const l=super.element();this.options=this.lookup.options();for(let a=0;a<this.options.length;a++)l.appendChild(this.buildSegment(this.options[a],a));this.focused=Math.max(0,this.indexOf(this.selected)),this.paint()})}cancelBeforeStart(){return this.#e?this.#e.cancelBeforeStart():super.cancelBeforeStart()}cancelOnClose(){return this.#e?this.#e.cancelOnClose():super.cancelOnClose()}commit(){return this.#e?this.#e.commit():super.commit()}cancel(){this.#e?this.#e.cancel():super.cancel()}validate(o){return this.#e?this.#e.validate(o):super.validate(o)}message(){return this.#e?this.#e.message():super.message()}toClipboard(){return this.#e?this.#e.toClipboard():super.toClipboard()}fromClipboard(o){return this.#e?this.#e.fromClipboard(o):super.fromClipboard(o)}destroy(){for(const o of this.#t)o();this.#t.length=0,this.segments.length=0,this.options=[],this.#e&&(this.#e.destroy(),this.#e=null),super.destroy()}}function i(r){return{...r.column&&r.column.edit&&r.column.edit.props||{},...r.props||{}}}const s=t}),Ce("packages/dom/src/editors/rating.js",function(e,G){"use strict";Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"normaliseRating",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,V=G("packages/dom/src/cell/icons.js").createIcon,U=G("packages/dom/src/cell/renderers/rating.js"),D=U.ratingFills,I=U.fillState,k=U.ratingText,S=U.clampRating,y=U.DEFAULT_RATING_ICON,d=U.DEFAULT_RATING_MAX,n=G("packages/core/src/internal/util.js").isFunction;class t extends M{static popup=!1;rating=null;preview=null;items=[];fills=[];slider=null;readout=null;#e=[];max(){const o=Math.floor(Number(this.props.max??d));return Number.isFinite(o)&&o>0?o:d}step(){return this.props.allowHalf===!0?.5:1}build(){const o=this.doc,l=this.max();this.rating=i(this.params.value,l,this.props.allowHalf===!0);const a=R(o,"div",{class:`${$.editor}__rating`}),p=R(o,"div",{class:`${$.editor}__rating-slider`,attrs:{role:"slider",tabindex:"0","aria-valuemin":"0","aria-valuemax":String(l),"aria-label":this.params.column&&this.params.column.title||"Rating"}});for(let b=0;b<l;b++)p.appendChild(this.buildItem(b));a.appendChild(p),this.slider=p;const m=R(o,"span",{class:`${$.editor}__rating-value`});return a.appendChild(m),this.readout=m,this.props.allowClear===!0&&a.appendChild(this.buildClear()),this.#e.push(W(p,"keydown",b=>this.onKeyDown(b))),this.props.hoverPreview!==!1&&this.#e.push(W(p,"mouseleave",()=>{this.preview=null,this.paint()})),this.params.key&&/^[0-9]$/.test(this.params.key)&&(this.rating=Math.min(Number(this.params.key),l)),this.paint(),a}buildItem(o){const l=this.doc,a=String(this.props.icon??y),p=R(l,"span",{class:`${$.editor}__rating-fill`,attrs:{"aria-hidden":"true"},children:[V(l,a,{className:$.icon})]}),m=R(l,"span",{class:`${$.editor}__rating-item`,attrs:{"data-index":o,"data-icon":a,"aria-hidden":"true"},children:[V(l,a,{className:$.icon}),p]});return this.fills.push(p),this.#e.push(W(m,"mousedown",b=>{b&&n(b.preventDefault)&&b.preventDefault(),this.setRating(this.ratingAt(o,b),{commit:!0})})),this.props.hoverPreview!==!1&&this.#e.push(W(m,"mousemove",b=>{const g=this.ratingAt(o,b);g!==this.preview&&(this.preview=g,this.paint())})),this.items.push(m),m}buildClear(){const o=R(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearRating")}});return this.#e.push(W(o,"mousedown",l=>{l&&n(l.preventDefault)&&l.preventDefault(),this.setRating(null)})),o}ratingAt(o,l){if(this.props.allowHalf!==!0)return o+1;const a=this.items[o],p=a&&Number(a.offsetWidth),m=l&&Number(l.offsetX);return!Number.isFinite(p)||p<=0||!Number.isFinite(m)?o+1:m*2<p?o+.5:o+1}focusTarget(){return this.slider}setRating(o,l){this.rating=o===null?null:S(o,this.max(),this.props.allowHalf===!0,!1),this.preview=null,this.paint(),l&&l.commit&&this.commit()}nudge(o){const l=this.rating===null?0:this.rating;this.setRating(l+o)}paint(){const o=this.max(),l=this.props.allowHalf===!0,a=this.preview===null?this.rating:this.preview,p=D(a===null?0:a,o,{allowHalf:l});for(let g=0;g<this.items.length;g++){const f=I(p[g]);this.items[g].setAttribute("data-fill",f),this.items[g].classList.toggle(`${$.editor}__rating-item--filled`,f!=="empty"),this.fills[g]&&this.fills[g].style.setProperty("--lat-rating-fill",`${(p[g]*100).toFixed(2)}%`)}const m=a===null?String(this.props.emptyLabel??this.t("cell.rating.empty")):this.t("cell.rating.of",{rating:k(a),max:o}),b=this.slider;b&&(b.setAttribute("aria-valuenow",a===null?"0":String(a)),b.setAttribute("aria-valuetext",m),b.setAttribute("data-preview",this.preview===null?"false":"true")),this.readout&&(this.readout.textContent=m)}onKeyDown(o){const l=()=>{n(o.preventDefault)&&o.preventDefault()},a=this.step();if(/^[0-9]$/.test(o.key)){l(),this.setRating(Math.min(Number(o.key),this.max()));return}switch(o.key){case"ArrowRight":case"ArrowUp":l(),this.nudge(a);break;case"ArrowLeft":case"ArrowDown":l(),this.nudge(-a);break;case"Home":l(),this.setRating(0);break;case"End":l(),this.setRating(this.max());break;case"Enter":l(),this.commit();break;case"Escape":l(),this.cancel();break;case"Tab":this.commit();break;case"Delete":case"Backspace":this.props.allowClear===!0&&(l(),this.setRating(null));break;default:break}}readValue(){return this.rating}checkValue(o){if(o==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a rating";if(typeof o!="number"||!Number.isFinite(o))return"Enter a rating";const l=this.max();return o<0?"Must be 0 or more":o>l?`Must be ${l} or less`:this.props.allowHalf!==!0&&!Number.isInteger(o)?"Choose a whole rating":!0}toClipboard(){return this.rating===null?"":k(this.rating)}fromClipboard(o){const l=String(o??"").trim();if(l==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a rating"};const a=Number(l);if(!Number.isFinite(a))return{ok:!1,message:`"${l}" is not a rating`};const p=this.checkValue(a);return p!==!0?{ok:!1,message:p}:{ok:!0,value:a}}destroy(){for(const o of this.#e)o();this.#e.length=0,this.items.length=0,this.slider=null,this.readout=null,super.destroy()}}function i(r,o,l){if(r==null||r==="")return null;const a=Number(r);return Number.isFinite(a)?S(a,o,l,!1):null}const s=t}),Ce("packages/dom/src/editors/slider.js",function(e,G){"use strict";Object.defineProperty(e,"SLIDER_MIN",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"SLIDER_MAX",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"proportion",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"decimalsOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"normaliseMarks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,Z=G("packages/dom/src/editors/number.js"),V=Z.parseNumberText,U=Z.presentNumber,I=G("packages/core/src/internal/util.js").isFunction,k=0,S=100;class y extends M{static popup=!1;amount=null;range=null;field=null;readout=null;root=null;marks=[];#e=[];min(){const s=Number(this.props.min??k);return Number.isFinite(s)?s:k}max(){const s=Number(this.props.max??S);return Number.isFinite(s)?s:S}step(){const s=Number(this.props.step??1);return Number.isFinite(s)&&s>0?s:1}build(){const s=this.doc,r=this.min(),o=this.max(),l=this.step(),a=n(this.props.marks);this.marks=a,this.amount=this.params.value==null||this.params.value===""?null:this.snap(Number(this.params.value));const p=R(s,"div",{class:`${$.editor}__slider`});this.root=p;const m=R(s,"input",{class:`${$.editor}__slider-input`,attrs:{type:"range",min:String(r),max:String(o),step:String(l),"aria-label":this.params.column&&this.params.column.title||null,"aria-valuetext":null,list:a.length?`${this.id}-marks`:null}});if(this.range=m,p.appendChild(m),a.length){const g=R(s,"datalist",{attrs:{id:`${this.id}-marks`}}),f=R(s,"div",{class:`${$.editor}__slider-marks`});for(const w of a){g.appendChild(R(s,"option",{attrs:{value:String(w.value),label:w.label}}));const v=R(s,"span",{class:`${$.editor}__slider-mark`,text:w.label,attrs:{"data-value":String(w.value)}});v.style&&I(v.style.setProperty)&&v.style.setProperty("--lat-slider-mark",`${(d(w.value,r,o)*100).toFixed(2)}%`),f.appendChild(v)}p.appendChild(g),p.appendChild(f)}const b=R(s,"input",{class:`${$.editor}__slider-number`,attrs:{type:"text",inputmode:"decimal","aria-label":this.t("editor.value")}});if(this.field=b,p.appendChild(b),this.props.showValue!==!1){const g=R(s,"span",{class:`${$.editor}__slider-value`});p.appendChild(g),this.readout=g}return this.#e.push(W(m,"input",()=>this.setAmount(Number(m.value),"range"))),this.#e.push(W(m,"change",()=>this.setAmount(Number(m.value),"range"))),this.#e.push(W(m,"keydown",g=>this.onKeyDown(g))),this.#e.push(W(b,"input",()=>this.onFieldInput())),this.#e.push(W(b,"change",()=>this.paint())),this.#e.push(W(b,"keydown",g=>this.onKeyDown(g))),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(b.value=this.params.key,this.onFieldInput()),this.paint(),p}focusTarget(){return this.field}attached(){super.attached();const s=this.field;s&&!this.params.key&&this.props.selectOnFocus!==!1&&I(s.select)&&s.select()}snap(s){if(!Number.isFinite(s))return this.min();const r=this.min(),o=this.max(),l=this.step(),a=Math.min(Math.max(s,r),o),p=r+Math.round((a-r)/l)*l,m=u(l),b=m>0?Number(p.toFixed(m)):Math.round(p);return Math.min(Math.max(b,r),o)}setAmount(s,r){this.amount=s===null?null:this.snap(s),this.paint(r)}onFieldInput(){const s=this.field?String(this.field.value):"";if(s.trim()===""){this.amount=null,this.paint("field");return}const r=V(s,this.params.locale);if(r===null||Number.isNaN(r)){this.paint("field");return}this.setAmount(r,"field")}paint(s){const r=this.min(),o=this.max(),l=this.amount,a=l===null?r:l;this.range&&s!=="range"&&(this.range.value=String(a)),this.field&&s!=="field"&&(this.field.value=l===null?"":U(l,this.props));const p=this.root;p&&p.style&&I(p.style.setProperty)&&p.style.setProperty("--lat-slider-pos",`${(d(a,r,o)*100).toFixed(2)}%`),p&&p.setAttribute&&p.setAttribute("data-empty",l===null?"true":"false");const m=this.labelFor(l);this.range&&this.range.setAttribute&&this.range.setAttribute("aria-valuetext",m),this.readout&&(this.readout.textContent=m)}labelFor(s){if(s===null)return String(this.props.emptyLabel??"");const r=this.marks.find(l=>l.value===s),o=U(s,this.props);return r&&r.label!==o?`${o} (${r.label})`:o}onKeyDown(s){if(s.key==="Escape"){I(s.preventDefault)&&s.preventDefault(),this.cancel();return}if(s.key==="Enter"){I(s.preventDefault)&&s.preventDefault(),this.commit();return}s.key==="Tab"&&this.commit()}readValue(){const s=this.field?String(this.field.value):"";if(s.trim()==="")return null;const r=V(s,this.params.locale);return r===null||Number.isNaN(r)?NaN:this.snap(r)}checkValue(s){return s==null?this.props.allowClear===!0||this.params.value==null?!0:"Enter a value":typeof s!="number"||Number.isNaN(s)?"Enter a number":s<this.min()?`Must be ${this.min()} or more`:s>this.max()?`Must be ${this.max()} or less`:!0}fromClipboard(s){const r=String(s??"").trim();if(r==="")return this.checkValue(null)===!0?{ok:!0,value:null}:{ok:!1,message:"Enter a value"};const o=V(r,this.params.locale);if(o===null||Number.isNaN(o))return{ok:!1,message:"Enter a number"};const l=this.snap(o),a=this.checkValue(l);return a!==!0?{ok:!1,message:a}:{ok:!0,value:l}}destroy(){for(const s of this.#e)s();this.#e.length=0,this.range=null,this.field=null,this.readout=null,this.root=null,this.marks=[],super.destroy()}}function d(i,s,r){const o=r-s;return!Number.isFinite(o)||o===0?0:Math.min(1,Math.max(0,(Number(i)-s)/o))}function u(i){if(!Number.isFinite(i))return 0;const s=String(i),r=s.indexOf("e");if(r>=0){const l=s.slice(0,r),a=l.indexOf("."),p=a<0?0:l.length-a-1;return Math.min(15,Math.max(0,p-Number(s.slice(r+1))))}const o=s.indexOf(".");return o<0?0:Math.min(15,s.length-o-1)}function n(i){if(!i)return[];const s=[];if(Array.isArray(i)){for(const r of i){if(r&&typeof r=="object"){const l=Number(r.value);Number.isFinite(l)&&s.push({value:l,label:String(r.label??l)});continue}const o=Number(r);Number.isFinite(o)&&s.push({value:o,label:String(o)})}return s}if(typeof i=="object")for(const[r,o]of Object.entries(i)){const l=Number(r);Number.isFinite(l)&&s.push({value:l,label:String(o)})}return s}const t=y}),Ce("packages/dom/src/editors/colour.js",function(e,G){"use strict";Object.defineProperty(e,"DEFAULT_SWATCHES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"TOKEN_FALLBACK",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"normaliseSwatch",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveSwatchColour",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"toSwatches",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,Z=G("packages/dom/src/cell/renderers/colour.js"),V=Z.normaliseColour,U=Z.parseColour,I=G("packages/core/src/internal/util.js").isFunction,k=Object.freeze(["neutral","info","success","warning","danger","accent"]),S=Object.freeze({neutral:"#5b6670",info:"#1a6bc7",success:"#1b7f3b",warning:"#a96a0b",danger:"#c22b2b",accent:"#5a46d6"});function y(s){if(s==null)return null;if(typeof s=="object"){const l=s,a=y(l.token??l.value??l.colour??l.color);return a?{...a,label:l.label==null?a.label:String(l.label)}:null}const r=String(s).trim();if(r==="")return null;const o=V(r);return o?{token:null,hex:o,label:o}:Object.hasOwn(S,r)?{token:r,hex:S[r],label:r}:null}function d(s,r){const o=s&&s.ownerDocument,l=o&&o.defaultView;if(!l||!I(l.getComputedStyle))return null;try{const a=l.getComputedStyle(s);return!a||!I(a.getPropertyValue)?null:V(String(a.getPropertyValue(`--lattice-variant-${r}-solid`)).trim())}catch{return null}}class u extends M{static popup=!0;swatches=[];buttons=[];native=null;hex=null;preview=null;#e=[];alpha(){return this.props.alpha===!0}build(){const r=this.doc;this.swatches=n(this.props.swatches);const o=R(r,"div",{class:`${$.editor}__colour`,attrs:{"aria-label":this.params.column&&this.params.column.title||null}});if(this.preview=R(r,"span",{class:`${$.editor}__colour-preview`,attrs:{"aria-hidden":"true"}}),o.appendChild(this.preview),this.swatches.length){const a=R(r,"div",{class:`${$.editor}__colour-swatches`,attrs:{role:"radiogroup","aria-label":this.t("editor.colours")}});for(let p=0;p<this.swatches.length;p++)a.appendChild(this.buildSwatch(this.swatches[p],p));o.appendChild(a)}this.native=R(r,"input",{class:`${$.editor}__colour-native`,attrs:{type:"color","aria-label":this.t("editor.customColour")}}),o.appendChild(this.native),this.hex=R(r,"input",{class:`${$.editor}__colour-hex`,attrs:{type:"text",spellcheck:"false",autocomplete:"off",placeholder:this.t("editor.hexPlaceholder"),"aria-label":this.t("editor.hexValue")}}),o.appendChild(this.hex),this.props.allowClear===!0&&o.appendChild(this.buildClear()),this.#e.push(W(this.native,"input",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.native,"change",()=>this.setColour(this.native?this.native.value:null))),this.#e.push(W(this.hex,"input",()=>this.paint())),this.#e.push(W(this.hex,"change",()=>this.paint())),this.#e.push(W(this.hex,"keydown",a=>this.onKeyDown(a))),this.#e.push(W(o,"keydown",a=>this.onKeyDown(a)));const l=V(this.params.value,{alpha:this.alpha()});return this.hex.value=l===null?this.params.value==null?"":String(this.params.value):l,this.params.key&&/^[#0-9a-fA-F]$/.test(this.params.key)&&(this.hex.value=this.params.key),this.paint(),o}buildSwatch(r,o){const l=R(this.doc,"button",{class:`${$.editor}__colour-swatch`,attrs:{type:"button",role:"radio","aria-checked":"false","aria-label":r.label,"data-index":o,"data-variant":r.token}});return r.token||t(l,r.hex),this.#e.push(W(l,"mousedown",a=>{a&&I(a.preventDefault)&&a.preventDefault(),this.setColour(this.swatches[o].hex)})),this.buttons.push(l),l}buildClear(){const r=R(this.doc,"button",{class:`${$.editor}__clear`,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.clearColour")}});return this.#e.push(W(r,"mousedown",o=>{o&&I(o.preventDefault)&&o.preventDefault(),this.setColour(null)})),r}focusTarget(){return this.hex}attached(){super.attached();for(let r=0;r<this.swatches.length;r++){const o=this.swatches[r];if(!o.token)continue;const l=d(this.buttons[r]||this.element(),o.token);l&&(o.hex=l)}this.paint()}setColour(r){const o=r===null?null:V(r,{alpha:this.alpha()});this.hex&&(this.hex.value=o===null?"":o),this.paint()}current(){const r=this.hex?String(this.hex.value).trim():"";return r===""?null:V(r,{alpha:this.alpha()})}paint(){const r=this.current(),o=r===null?null:r.slice(0,7);t(this.preview,o),this.preview&&this.preview.setAttribute&&this.preview.setAttribute("data-empty",r===null?"true":"false"),this.native&&(this.native.value=o===null?"#000000":o);for(let l=0;l<this.buttons.length;l++){const a=r!==null&&this.swatches[l].hex.toLowerCase()===r.toLowerCase();this.buttons[l].setAttribute("aria-checked",a?"true":"false"),this.buttons[l].classList.toggle(`${$.editor}__colour-swatch--selected`,a),this.swatches[l].token||t(this.buttons[l],this.swatches[l].hex)}}onKeyDown(r){if(r.key==="Escape"){I(r.preventDefault)&&r.preventDefault(),this.cancel();return}if(r.key==="Enter"){I(r.preventDefault)&&r.preventDefault(),this.commit();return}r.key==="Tab"&&this.commit()}readValue(){const r=this.hex?String(this.hex.value).trim():"";if(r==="")return null;const o=V(r,{alpha:this.alpha()});return o===null?r:o}checkValue(r){if(r==null||r==="")return this.props.allowClear===!0||this.params.value==null?!0:"Choose a colour";const o=U(r);return o?!this.alpha()&&o.a<1?"This column does not accept transparency":!0:`"${String(r)}" is not a colour`}toClipboard(){const r=this.current();return r===null?"":r}fromClipboard(r){const o=String(r??"").trim();if(o==="")return this.props.allowClear===!0||this.params.value==null?{ok:!0,value:null}:{ok:!1,message:"Choose a colour"};const l=V(o,{alpha:this.alpha()});if(l===null)return{ok:!1,message:`"${o}" is not a colour`};const a=this.checkValue(l);return a!==!0?{ok:!1,message:a}:{ok:!0,value:l}}destroy(){for(const r of this.#e)r();this.#e.length=0,this.buttons.length=0,this.swatches=[],this.native=null,this.hex=null,this.preview=null,super.destroy()}}function n(s){const r=Array.isArray(s)&&s.length?s:s===!1?[]:k,o=[];for(const l of r){const a=y(l);a&&o.push(a)}return o}function t(s,r){const o=s&&s.style;if(o){if(r===null){I(o.removeProperty)&&o.removeProperty("--lat-swatch");return}I(o.setProperty)&&o.setProperty("--lat-swatch",r)}}const i=u}),Ce("packages/dom/src/editors/treeselect.js",function(e,G){"use strict";Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return i}});const M=G("packages/dom/src/editors/select.js").SelectEditorBase,R=G("packages/dom/src/cell/icons.js").createIcon,W=G("packages/dom/src/editors/common.js"),Z=W.CLS,V=W.el,U=W.on,D=W.clear,I=W.keyOf,k=W.rawOptions,S=W.lookupKey,y=G("packages/core/src/internal/util.js"),d=y.isFunction,u=y.isObject,n="\0";class t extends M{static popup=!0;roots=[];nodes=new Map;expanded=new Set;matched=new Set;selected=null;leavesOnly=!0;build(){this.leavesOnly=this.props.selectLeavesOnly!==!1;const r=super.build();return r.classList.add("lat-treeselect"),this.list&&this.list.element().setAttribute("role","tree"),r}initSelection(){this.rebuild(),this.selected=this.params.value??null;const r=this.nodeById(this.selected);if(r)for(let o=r.parent;o;o=o.parent)this.expanded.add(o.key)}rebuild(){const r=k(this.params,this.props),o=this.props.keys||{},l=o.value||S(this.params,"valueKey")||"id",a=o.label||S(this.params,"labelKey")||"label";this.roots=[],this.nodes=new Map;for(const p of r){if(!u(p)){this.addNode(null,String(p??""),p,null);continue}Array.isArray(p.path)&&p.path.length?this.addByPath(p,l,a):this.addByChildren(p,null,l,a)}if(this.props.defaultExpanded===!0)for(const p of this.nodes.keys())this.expanded.add(p)}addNode(r,o,l,a){const p=r?`${r.key}${n}${o}`:o;let m=this.nodes.get(p);return m?m.id===void 0&&l!==void 0&&(m.id=l):(m={id:l,label:o,key:p,parent:r,children:[],depth:r?r.depth+1:0,disabled:!1},this.nodes.set(p,m),(r?r.children:this.roots).push(m)),a&&(a.disabled===!0&&(m.disabled=!0),a.icon!==void 0&&(m.icon=a.icon),a.variant!==void 0&&(m.variant=a.variant)),m}addByPath(r,o,l){const a=r.path;let p=null;for(let m=0;m<a.length;m++){const b=m===a.length-1,g=String(a[m]),f=b&&r[l]!=null?String(r[l]):g,w=this.addNode(p,g,b?r[o]:void 0,b?r:null);b&&(w.label=f),p=w}}addByChildren(r,o,l,a){const p=r[l],m=r[a]!=null?String(r[a]):String(p??""),b=this.addNode(o,m,p,r),g=Array.isArray(r.children)?r.children:[];for(const f of g)u(f)?this.addByChildren(f,b,l,a):this.addNode(b,String(f??""),f,null)}nodeById(r){if(r==null)return;const o=I(r);for(const l of this.nodes.values())if(l.id!==void 0&&I(l.id)===o)return l}filterOptions(r){const o=String(r||"").trim().toLowerCase(),l=o!=="";this.matched=l?this.computeMatches(o):new Set;const a=[],p=m=>{for(const b of m)l&&!this.matched.has(b.key)||(a.push(b),b.children.length&&(l||this.expanded.has(b.key))&&p(b.children))};return p(this.roots),a}computeMatches(r){const o=new Set,l=a=>{let p=a.label.toLowerCase().includes(r);for(const m of a.children)l(m)&&(p=!0);return p&&o.add(a.key),p};for(const a of this.roots)l(a);return o}repaint(r){if(this.refreshOptions(),!r||!this.list)return;const o=this.visible.findIndex(l=>l.key===r);o>=0&&this.list.setActive(o)}isBranch(r){return!!r&&r.children.length>0}isSelectable(r){return!r||r.disabled||r.id===void 0||r.id===null?!1:!(this.leavesOnly&&this.isBranch(r))}setExpanded(r,o){this.isBranch(r)&&(o?this.expanded.add(r.key):this.expanded.delete(r.key),this.repaint(r.key))}choose(r){if(r){if(!this.isSelectable(r)){this.isBranch(r)&&this.setExpanded(r,!this.expanded.has(r.key));return}this.selected=r.id,this.input&&(this.input.value=""),this.query="",this.repaint(r.key),this.paintDisplay(),this.commit()}}isSelected(r){return this.selected!=null&&r&&r.id!==void 0&&I(r.id)===I(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}checkValue(r){if(r==null)return this.props.allowClear===!0||this.params.value==null?!0:"Choose a value";if(!this.nodes.size)return!0;const o=this.nodeById(r);return o&&this.isSelectable(o)?!0:o?`"${o.label}" is a group, not a value`:this.props.allowCustom===!0||this.lookup&&this.lookup.allowCustom?!0:`"${String(r)}" is not a valid option`}renderOption(r,o,l){D(o),o.setAttribute("role","treeitem"),o.setAttribute("aria-level",String(r.depth+1)),o.setAttribute("data-depth",String(r.depth));const a=V(this.doc,"span",{class:"lat-tree__indent"});for(let w=0;w<r.depth;w++)a.appendChild(V(this.doc,"span",{class:"lat-tree__guide"}));o.appendChild(a);const p=this.isBranch(r),m=p&&(this.expanded.has(r.key)||this.query.trim()!==""),b=p?m?"chevronDown":"chevronRight":"blank",g=V(this.doc,"span",{class:p?"lat-tree__twisty":"lat-tree__twisty lat-tree__twisty--leaf",children:[R(this.doc,b,{className:Z.icon})],attrs:{"data-icon":p?b:null,"aria-hidden":"true"}});p&&U(g,"mousedown",w=>{d(w.preventDefault)&&w.preventDefault(),d(w.stopPropagation)&&w.stopPropagation(),this.setExpanded(r,!this.expanded.has(r.key))}),o.appendChild(g),r.icon&&o.appendChild(R(this.doc,r.icon,{className:Z.icon})),o.appendChild(V(this.doc,"span",{class:`${Z.option}__label`,text:r.label})),r.variant?o.setAttribute("data-variant",r.variant):o.removeAttribute("data-variant"),p?o.setAttribute("aria-expanded",m?"true":"false"):o.removeAttribute("aria-expanded");const f=this.isSelected(r);o.classList.toggle(Z.optionSelected,f),o.classList.toggle(Z.optionDisabled,!this.isSelectable(r)),o.classList.toggle("lat-tree__row--branch",p),o.setAttribute("aria-selected",f?"true":"false"),this.isSelectable(r)?o.removeAttribute("aria-disabled"):o.setAttribute("aria-disabled","true")}paintDisplay(){const r=this.display;if(!r)return;if(D(r),this.selected==null){r.removeAttribute("data-variant");return}const o=this.nodeById(this.selected);if(!o){r.appendChild(V(this.doc,"span",{text:String(this.selected)}));return}o.icon&&r.appendChild(R(this.doc,o.icon,{className:Z.icon})),r.appendChild(V(this.doc,"span",{class:"lat-tree__path",text:this.pathLabel(o)})),o.variant?r.setAttribute("data-variant",o.variant):r.removeAttribute("data-variant")}pathLabel(r){const o=[];for(let l=r;l;l=l.parent)o.unshift(l.label);return o.join(String(this.props.pathSeparator??" / "))}onKeyDown(r){const o=this.list,l=o&&o.active>=0?this.visible[o.active]:null;switch(r.key){case"ArrowRight":{if(d(r.preventDefault)&&r.preventDefault(),!l)return;this.isBranch(l)&&!this.expanded.has(l.key)?this.setExpanded(l,!0):this.isBranch(l)&&o&&o.setActive(Math.min(this.visible.length-1,o.active+1));return}case"ArrowLeft":{if(d(r.preventDefault)&&r.preventDefault(),!l)return;this.isBranch(l)&&this.expanded.has(l.key)?this.setExpanded(l,!1):l.parent&&this.focusNode(l.parent.key);return}case"Home":d(r.preventDefault)&&r.preventDefault(),o&&this.visible.length&&o.setActive(0);return;case"End":d(r.preventDefault)&&r.preventDefault(),o&&this.visible.length&&o.setActive(this.visible.length-1);return;default:super.onKeyDown(r)}}focusNode(r){if(!this.list)return;const o=this.visible.findIndex(l=>l.key===r);o>=0&&this.list.setActive(o)}acceptHighlight(r){const o=this.list,l=o&&o.active>=0?this.visible[o.active]:null;if(!l){r&&r.commit&&this.commit();return}if(this.isSelectable(l)){this.choose(l);return}this.isBranch(l)?this.setExpanded(l,!this.expanded.has(l.key)):r&&r.commit&&this.commit()}moveHighlight(r){const o=this.list;if(!o)return;let l=o.active;for(let a=0;a<this.visible.length;a++){if(l+=r,l<0||l>=this.visible.length)return;if(!this.visible[l].disabled){o.setActive(l);return}}}}const i=t}),Ce("packages/dom/src/editors/objectpicker.js",function(e,G){"use strict";Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"readField",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"initialsOf",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const M=G("packages/dom/src/editors/select.js").SelectEditorBase,$=G("packages/dom/src/editors/common.js"),R=$.CLS,W=$.el,Z=$.on,V=$.clear,U=$.keyOf,D=$.debounce,I=$.rawOptions,k=$.optionSource,S=$.lookupSearch,y=$.lookupKey,d=G("packages/core/src/internal/util.js"),u=d.isFunction,n=d.isObject,t=d.getPath,s=G("packages/dom/src/cell/icons.js").createIcon;class r extends M{static popup=!0;all=[];selected=null;#e=null;#t=!1;#n=null;build(){const b=super.build();if(b.classList.add("lat-objectpicker"),u(this.props.search)&&!(this.lookup&&this.lookup.search)){const g=Number(this.props.searchDebounce)||200;this.#n=D(f=>this.runRemoteSearch(String(f)),g)}return b}onQuery(b){super.onQuery(b),this.#n&&this.#n(b)}initSelection(){const b=I(this.params,this.props).map(g=>this.toOption(g));(b.length||!this.all.length)&&(this.all=b),this.selected=this.params.value??null}toOption(b){if(!n(b)){const c=b==null?"":String(b);return{id:b,label:c,secondary:"",avatar:"",initials:l(c),disabled:!1,raw:{}}}const g=this.props.valueKey||y(this.params,"valueKey")||"id",f=this.props.labelKey||y(this.params,"labelKey")||"label",w=o(b,this.props.template??f,""),v=o(b,this.props.secondary,""),h=o(b,this.props.avatar,"");return{id:b[g],label:w||String(b[g]??""),secondary:v,avatar:h,initials:l(w||String(b[g]??"")),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);u(b)&&(this.#t=!0,Promise.resolve(b()).then(g=>{!this.element()||!Array.isArray(g)||(this.all=g.map(f=>this.toOption(f)),this.refreshOptions(),this.paintDisplay())}))}filterOptions(b){const g=String(b||"").trim().toLowerCase();if(g==="")return this.all;const f=a(this.props.searchFields);return this.all.filter(w=>{if(!f)return w.label.toLowerCase().includes(g)||w.secondary.toLowerCase().includes(g);for(const v of f){const h=u(v)?v(w.raw):t(w.raw,v);if(h!=null&&String(h).toLowerCase().includes(g))return!0}return!1})}async runRemoteSearch(b){const g=S(this.params,this.props);if(!g)return;this.#e&&this.#e.abort();const f=new AbortController;this.#e=f;try{const w=await g(b,f.signal);if(f.signal.aborted||this.#e!==f)return;this.refreshOptions(Array.isArray(w)?w.map(v=>this.toOption(v)):[])}catch(w){if(!f.signal.aborted)throw w}finally{this.#e===f&&(this.#e=null)}}choose(b){!b||b.disabled||(this.selected=b.id,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay(),this.commit())}isSelected(b){return this.selected!=null&&b!=null&&U(b.id)===U(this.selected)}clearSelection(){this.selected=null,this.input&&(this.input.value=""),this.query="",this.refreshOptions(),this.paintDisplay()}readValue(){return this.selected??null}optionById(b){if(b==null)return;const g=U(b);return this.all.find(f=>U(f.id)===g)}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,g,f){V(g),g.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})),g.appendChild(w),b.icon&&g.appendChild(s(this.doc,b.icon,{className:R.icon})),b.variant?g.setAttribute("data-variant",b.variant):g.removeAttribute("data-variant");const v=this.isSelected(b);g.classList.add("lat-object__row"),g.classList.toggle(R.optionSelected,v),g.classList.toggle(R.optionDisabled,b.disabled===!0),g.setAttribute("aria-selected",v?"true":"false"),b.disabled?g.setAttribute("aria-disabled","true"):g.removeAttribute("aria-disabled")}buildAvatar(b){const g=W(this.doc,"span",{class:"lat-avatar",attrs:{"aria-hidden":"true"}});if(!b.avatar)return g.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),g.setAttribute("data-fallback","initials"),g;const f=W(this.doc,"img",{class:"lat-avatar__image",attrs:{src:b.avatar,alt:"",loading:"lazy",decoding:"async"}});return Z(f,"error",()=>{f.parentNode===g&&(g.removeChild(f),g.appendChild(W(this.doc,"span",{class:"lat-avatar__initials",text:b.initials})),g.setAttribute("data-fallback","initials"))}),g.appendChild(f),g}paintDisplay(){const b=this.display;if(!b)return;if(V(b),this.selected==null){b.removeAttribute("data-variant");return}const g=this.optionById(this.selected);if(!g){b.appendChild(W(this.doc,"span",{text:this.lookup?this.lookup.label(this.selected):String(this.selected)}));return}b.appendChild(this.buildAvatar(g)),b.appendChild(W(this.doc,"span",{class:"lat-object__primary",text:g.label})),g.variant?b.setAttribute("data-variant",g.variant):b.removeAttribute("data-variant")}destroy(){this.#e&&(this.#e.abort(),this.#e=null),this.#n&&(this.#n.cancel(),this.#n=null),this.all=[],super.destroy()}}function o(m,b,g){if(b==null)return g;const f=u(b)?b(m):t(m,String(b));return f==null?g:String(f)}function l(m){const b=String(m||"").trim().split(/\s+/).filter(w=>w!=="");if(!b.length)return"";const g=[...b[0]][0]||"";if(b.length===1)return g.toUpperCase();const f=[...b[b.length-1]][0]||"";return(g+f).toUpperCase()}function a(m){if(m==null)return null;const g=(Array.isArray(m)?m:[m]).filter(f=>typeof f=="string"||u(f));return g.length?g:null}const p=r}),Ce("packages/dom/src/editors/iconpicker.js",function(e,G){"use strict";Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"resolveNames",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.VirtualList,W=_.el,Z=_.on,V=_.clear,U=G("packages/dom/src/cell/icons.js"),D=U.createIcon,I=U.iconNames,S=G("packages/core/src/internal/util.js").isFunction;class y extends M{static popup=!0;input=null;display=null;list=null;names=[];matches=[];rows=[];columns=8;cursor=-1;selected=null;query="";off=[];build(){const t=this.props;this.columns=Math.max(1,Math.floor(Number(t.columns)||8)),this.names=d(t.icons),this.selected=this.params.value==null?null:String(this.params.value);const i=W(this.doc,"div",{class:["lat-iconpicker",`${$.editor}__select`],attrs:{role:"combobox","aria-expanded":"true"}});return this.display=W(this.doc,"div",{class:`${$.editor}__display`}),this.input=W(this.doc,"input",{class:$.input,attrs:{type:"text",autocomplete:"off",placeholder:t.placeholder??"Search icons","aria-label":this.params.column&&this.params.column.title||"Search icons","aria-autocomplete":"list"}}),this.input.value="",this.list=new R({document:this.doc,itemHeight:Number(t.rowHeight)||34,height:Number(t.listHeight)||204,renderItem:(s,r,o)=>this.renderRow(s,r,o)}),this.list.element().setAttribute("role","grid"),this.list.element().setAttribute("aria-label",this.t("panel.icons")),i.appendChild(this.display),i.appendChild(this.input),t.allowClear===!0&&i.appendChild(this.buildClearButton()),i.appendChild(this.list.element()),this.off.push(Z(this.input,"input",()=>this.onQuery(this.input?this.input.value:""))),this.off.push(Z(this.input,"keydown",s=>this.onKeyDown(s))),this.refreshIcons(),this.paintDisplay(),this.params.key&&this.params.key.length===1&&(this.input.value=this.params.key,this.onQuery(this.params.key)),i}buildClearButton(){const t=W(this.doc,"button",{class:"lat-iconpicker__clear",text:this.t("editor.noIcon"),attrs:{type:"button",tabindex:"-1","aria-label":this.t("editor.noIcon")}});return this.off.push(Z(t,"mousedown",i=>{S(i.preventDefault)&&i.preventDefault(),this.selected=null,this.paintDisplay(),this.commit()})),t}focusTarget(){return this.input}onQuery(t){this.query=t,this.refreshIcons()}refreshIcons(){const t=this.query.trim().toLowerCase();this.matches=t===""?this.names.slice():this.names.filter(s=>s.toLowerCase().includes(t)),this.rows=[];for(let s=0;s<this.matches.length;s+=this.columns)this.rows.push(this.matches.slice(s,s+this.columns));const i=this.selected?this.matches.indexOf(this.selected):-1;this.cursor=i>=0?i:this.matches.length?0:-1,this.list&&this.list.setItems(this.rows,this.rowOf(this.cursor))}rowOf(t){return t<0?-1:Math.floor(t/this.columns)}moveCursor(t){if(!this.matches.length)return-1;const i=Math.max(0,Math.min(this.matches.length-1,this.cursor+t));return this.setCursor(i)}setCursor(t){return this.cursor=t,this.list&&this.list.setActive(this.rowOf(t)),this.cursor}cursorName(){return this.cursor>=0&&this.cursor<this.matches.length?this.matches[this.cursor]:null}renderRow(t,i,s){i.setAttribute("role","row"),i.classList.add("lat-iconpicker__row");let r=i.__latIconCells;if(!r){r=[],V(i);for(let o=0;o<this.columns;o++){const l=W(this.doc,"span",{class:"lat-iconpicker__cell",attrs:{role:"gridcell",tabindex:"-1"}});Z(l,"mousedown",a=>{S(a.preventDefault)&&a.preventDefault();const p=l.getAttribute("data-icon");p&&this.choose(p)}),i.appendChild(l),r.push(l)}i.__latIconCells=r}for(let o=0;o<r.length;o++){const l=r[o],a=t[o];if(a===void 0){l.setAttribute("aria-hidden","true"),l.removeAttribute("data-icon"),l.removeAttribute("title"),l.removeAttribute("aria-label"),l.classList.add("lat-iconpicker__cell--empty"),l.classList.remove("lat-iconpicker__cell--active"),l.classList.remove("lat-iconpicker__cell--selected"),l.__latIconName!==void 0&&(V(l),l.__latIconName=void 0);continue}const p=s*this.columns+o;l.removeAttribute("aria-hidden"),l.classList.remove("lat-iconpicker__cell--empty"),l.setAttribute("data-icon",a),l.setAttribute("title",a),l.setAttribute("aria-label",a),l.__latIconName!==a&&(V(l),l.appendChild(D(this.doc,a,{className:$.icon})),l.__latIconName=a);const m=this.selected===a;l.classList.toggle("lat-iconpicker__cell--active",p===this.cursor),l.classList.toggle("lat-iconpicker__cell--selected",m),l.setAttribute("aria-selected",m?"true":"false")}}paintDisplay(){const t=this.display;if(t){if(V(t),this.selected==null){t.appendChild(W(this.doc,"span",{class:"lat-iconpicker__none",text:this.t("editor.noIcon")}));return}t.appendChild(D(this.doc,this.selected,{className:$.icon})),t.appendChild(W(this.doc,"span",{text:this.selected}))}}choose(t){this.selected=t;const i=this.matches.indexOf(t);i>=0&&(this.cursor=i),this.list&&this.list.paint(),this.paintDisplay(),this.commit()}readValue(){return this.selected??null}checkValue(t){return t==null?this.props.allowClear===!0||this.params.value==null?!0:"Choose an icon":this.names.includes(String(t))?!0:`"${String(t)}" is not a known icon name`}onKeyDown(t){const i=()=>{S(t.preventDefault)&&t.preventDefault()};switch(t.key){case"ArrowRight":i(),this.moveCursor(1);return;case"ArrowLeft":i(),this.moveCursor(-1);return;case"ArrowDown":i(),this.moveCursor(this.columns);return;case"ArrowUp":i(),this.moveCursor(-this.columns);return;case"PageDown":i(),this.moveCursor(this.columns*5);return;case"PageUp":i(),this.moveCursor(-this.columns*5);return;case"Home":i(),this.setCursor(this.matches.length?0:-1);return;case"End":i(),this.setCursor(this.matches.length-1);return;case"Enter":{i();const s=this.cursorName();s&&this.choose(s);return}case"Escape":i(),this.cancel();return;case"Tab":{const s=this.cursorName();s&&(this.selected=s),this.commit();return}default:break}}destroy(){for(const t of this.off)t();this.off.length=0,this.list&&(this.list.destroy(),this.list=null),this.input=null,this.display=null,this.rows=[],super.destroy()}}function d(n){const t=I();if(Array.isArray(n)&&n.length){const i=new Set(t);return n.map(s=>String(s)).filter(s=>i.has(s))}return t.filter(i=>i!=="blank")}const u=y}),Ce("packages/dom/src/editors/temperature.js",function(e,G){"use strict";Object.defineProperty(e,"presentTemperature",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,V=G("packages/core/src/internal/util.js").isFunction,U=G("packages/core/src/columns/types/temperature.js"),D=U.formatTemperature,I=U.parseTemperature,k=U.findScale;function S(u,n){return D(u,{...n,decimals:void 0,minDecimals:0,maxDecimals:20})}class y extends M{input=null;hint=null;opts=null;#e=[];buildOptions(){const n=this.params.column&&this.params.column.dataType||null,t=n&&n.temperatureConfig||{};return{scale:this.props.scale||t.scale||"C",locale:this.params.locale}}build(){const n=this.props;this.opts=this.buildOptions();const t=k(this.opts.scale),i=t?t.scale.symbol:"",s=`${this.id}-scale`,r=R(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:n.placeholder??null,"aria-label":this.params.column&&this.params.column.title||null,"aria-describedby":i?s:null}});r.value=S(this.params.value,this.opts),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(r.value=this.params.key),this.input=r;const o=typeof n.step=="number"?n.step:0;return o>0&&this.#e.push(W(r,"keydown",l=>{l.key==="ArrowUp"?(V(l.preventDefault)&&l.preventDefault(),this.nudge(o)):l.key==="ArrowDown"&&(V(l.preventDefault)&&l.preventDefault(),this.nudge(-o))})),this.hint=R(this.doc,"span",{class:`${$.editor}__suffix`,text:i,attrs:{id:s,"aria-hidden":"true"}}),R(this.doc,"div",{class:`${$.editor}__unit`,children:[r,this.hint]})}focusTarget(){return this.input}attached(){super.attached();const n=this.input;n&&!this.params.key&&this.props.selectOnFocus!==!1&&V(n.select)&&n.select()}nudge(n){const t=I(this.input?this.input.value:"",this.opts);let i=(t??0)+n;const{min:s,max:r}=this.props;typeof s=="number"&&i<s&&(i=s),typeof r=="number"&&i>r&&(i=r),this.input&&(this.input.value=S(i,this.opts))}readValue(){const n=this.input?String(this.input.value).trim():"";if(n==="")return null;const t=I(n,this.opts);return t===null?Number.NaN:t}checkValue(n){if(n===null)return!0;if(typeof n!="number"||Number.isNaN(n))return"Enter a temperature";const{min:t,max:i}=this.props;return typeof t=="number"&&n<t?`Must be ${t} or more`:typeof i=="number"&&n>i?`Must be ${i} or less`:!0}destroy(){for(const n of this.#e)n();this.#e=[],this.input=null,this.hint=null,super.destroy()}}const d=y}),Ce("packages/dom/src/editors/currency.js",function(e,G){"use strict";Object.defineProperty(e,"presentAmount",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const _=G("packages/dom/src/editors/common.js"),M=_.BaseEditor,$=_.CLS,R=_.el,W=_.on,V=G("packages/core/src/internal/util.js").isFunction,U=G("packages/core/src/columns/types/currency.js"),D=U.parseMoney,I=U.toMoney,k=U.normaliseCode,S=["USD","EUR","GBP","JPY","CHF","CAD","AUD","CNY"];function y(n){const t=I(n);return t?String(t.amount):""}class d extends M{input=null;picker=null;opts=null;#e=[];buildOptions(){const t=this.params.column&&this.params.column.dataType||null,i=t&&t.currencyConfig||{},s=I(this.params.value),r=k(this.props.code)||s&&s.code||k(i.code)||"USD";let o=this.props.codes||i.codes||S;return o=o.map(l=>k(l)).filter(Boolean),o.includes(r)||(o=[r,...o]),{code:r,codes:o,locale:this.params.locale}}build(){const t=this.props;this.opts=this.buildOptions();const i=R(this.doc,"input",{class:$.input,attrs:{type:"text",inputmode:"decimal",autocomplete:"off",spellcheck:"false",placeholder:t.placeholder??null,"aria-label":this.params.column&&this.params.column.title||"Amount"}});i.value=y(this.params.value),this.params.key&&/^[0-9.,+-]$/.test(this.params.key)&&(i.value=this.params.key),this.input=i;const s=R(this.doc,"select",{class:`${$.editor}__suffix`,attrs:{"aria-label":this.t("editor.currency")}});for(const r of this.opts.codes){const o=R(this.doc,"option",{text:r,attrs:{value:r}});r===this.opts.code&&(o.selected=!0),s.appendChild(o)}return this.picker=s,R(this.doc,"div",{class:`${$.editor}__unit`,children:[i,s]})}focusTarget(){return this.input}attached(){super.attached();const t=this.input;t&&!this.params.key&&this.props.selectOnFocus!==!1&&V(t.select)&&t.select()}readValue(){const t=this.input?String(this.input.value).trim():"";if(t==="")return null;const i=this.picker?this.picker.value:this.opts.code,s=D(t,{...this.opts,code:i});return s===null?Number.NaN:s}checkValue(t){if(t===null)return!0;if(!t||typeof t!="object"||!Number.isFinite(t.amount))return"Enter an amount";const i=t.amount,{min:s,max:r}=this.props;return typeof s=="number"&&i<s?`Must be ${s} or more`:typeof r=="number"&&i>r?`Must be ${r} or less`:!0}destroy(){for(const t of this.#e)t();this.#e=[],this.input=null,this.picker=null,super.destroy()}}const u=d}),Ce("packages/dom/src/editors/index.js",function(e,G){"use strict";Object.defineProperty(e,"TextEditor",{enumerable:!0,get:function(){return M}}),Object.defineProperty(e,"TextareaEditor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"NumberEditor",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"DateEditor",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"CheckboxEditor",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"SelectEditor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"MultiSelectEditor",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"TimeEditor",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"DateTimeEditor",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"DurationEditor",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"IpAddressEditor",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"PasswordEditor",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"CodeEditor",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"UnitEditor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"RadixEditor",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"SegmentedEditor",{enumerable:!0,get:function(){return c}}),Object.defineProperty(e,"RatingEditor",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"SliderEditor",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"ColourEditor",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"TreeSelectEditor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(e,"ObjectPickerEditor",{enumerable:!0,get:function(){return x}}),Object.defineProperty(e,"IconPickerEditor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(e,"TemperatureEditor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(e,"CurrencyEditor",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return de}}),Object.defineProperty(e,"editorByType",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return ce}});const M=G("packages/dom/src/editors/text.js").TextEditor,R=G("packages/dom/src/editors/textarea.js").TextareaEditor,Z=G("packages/dom/src/editors/number.js").NumberEditor,U=G("packages/dom/src/editors/date.js").DateEditor,I=G("packages/dom/src/editors/checkbox.js").CheckboxEditor,S=G("packages/dom/src/editors/select.js").SelectEditor,d=G("packages/dom/src/editors/multiselect.js").MultiSelectEditor,n=G("packages/dom/src/editors/time.js").TimeEditor,i=G("packages/dom/src/editors/datetime.js").DateTimeEditor,r=G("packages/dom/src/editors/duration.js").DurationEditor,l=G("packages/dom/src/editors/ipaddress.js").IpAddressEditor,p=G("packages/dom/src/editors/password.js").PasswordEditor,b=G("packages/dom/src/editors/code.js").CodeEditor,f=G("packages/dom/src/editors/unit.js").UnitEditor,v=G("packages/dom/src/editors/radix.js").RadixEditor,c=G("packages/dom/src/editors/segmented.js").SegmentedEditor,E=G("packages/dom/src/editors/rating.js").RatingEditor,T=G("packages/dom/src/editors/slider.js").SliderEditor,P=G("packages/dom/src/editors/colour.js").ColourEditor,z=G("packages/dom/src/editors/treeselect.js").TreeSelectEditor,x=G("packages/dom/src/editors/objectpicker.js").ObjectPickerEditor,C=G("packages/dom/src/editors/iconpicker.js").IconPickerEditor,q=G("packages/dom/src/editors/temperature.js").TemperatureEditor,Y=G("packages/dom/src/editors/currency.js").CurrencyEditor,J=G("packages/core/src/internal/util.js"),te=J.isCtor,ee=J.isFunction,re=J.warnOnce,se=G("packages/dom/src/editors/common.js");for(const pe of Object.keys(se))pe!=="default"&&Object.defineProperty(e,pe,{enumerable:!0,get:function(){return se[pe]}});const de=Object.freeze({text:M,textarea:R,number:Z,date:U,checkbox:I,select:S,multiSelect:d,temperature:q,currency:Y,time:n,datetime:i,duration:r,ipaddress:l,password:p,code:b,unit:f,radix:v,slider:T,rating:E,segmented:c,treeSelect:z,objectPicker:x,iconPicker:C,colour:P}),ie=Object.freeze({text:"text",number:"number",boolean:"checkbox",date:"date",dateString:"date",lookup:"select",object:""});function oe(pe,Me){const $e=pe&&pe.edit&&pe.edit.editor,je=Me&&Me.editors||{},ke=!!(pe&&pe.lookup&&pe.lookup.multiple);if(te($e)||ee($e))return $e;if(typeof $e=="string"){if(ke&&$e==="select")return d;const Ie=je[$e]||de[$e];if(Ie)return Ie;re(`editor:missing:${$e}`,`unknown editor "${$e}"; falling back to the data type default`)}const ge=pe&&pe.type||"text";if(ge==="lookup"||pe&&pe.lookup)return ke?d:S;const Ee=ie[ge];return Ee&&(je[Ee]||de[Ee])||null}function ue(pe,Me){const $e=oe(pe.column||{},Me);if(!$e)return null;const je=new $e;return je.init(pe),ee(je.cancelBeforeStart)&&je.cancelBeforeStart()===!0?(ee(je.destroy)&&je.destroy(),null):je}const ce=de}),Ce("packages/dom/src/ui/statusbar.js",function(e,G){"use strict";Object.defineProperty(e,"aggregate",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"StatusPanel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"RowCountPanel",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"SelectedCountPanel",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"AggregationPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"ProgressPanel",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"UpdatesPanel",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"CommentsPanel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"statusPanels",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"formatCount",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"formatNumber",{enumerable:!0,get:function(){return a}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return p}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.documentFor,R=_.el,W=_.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction;function I(m){let b=0,g=0,f=0,w=null,v=null;for(const h of m||[]){if(h==null||h==="")continue;b++;const c=typeof h=="number"?h:Number(h);Number.isFinite(c)&&(g++,f+=c,(w===null||c<w)&&(w=c),(v===null||c>v)&&(v=c))}return{count:b,numericCount:g,sum:g?f:null,min:w,max:v,avg:g?f/g:null}}class k{root=null;valueNode=null;init(b){this.ctx=b,this.doc=b.document,this.root=R(this.doc,"div",{class:`${M.statusBar}__panel`,attrs:{"data-align":b.align||"end"}}),b.label&&this.root.appendChild(R(this.doc,"span",{class:`${M.statusBar}__label`,text:b.label})),this.valueNode=R(this.doc,"span",{class:`${M.statusBar}__value`,text:""}),this.root.appendChild(this.valueNode)}t(b,g){const f=this.ctx&&this.ctx.messages;return(f&&D(f.t)?f:V).t(b,g)}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 S extends k{read(){const b=this.ctx.host||{},g=D(b.totalRowCount)?b.totalRowCount():0;if(g==null)return this.t("status.counting");const f=D(b.rowCount)?b.rowCount():g,w=this.ctx.noun,v=h=>w===void 0?this.t("count.rows",{count:h}):`${o(h,this.ctx.locale)}${w?` ${w}`:""}`;return f===g?this.t("status.total",{rows:v(g)}):this.t("status.shownOfTotal",{shown:o(f,this.ctx.locale),total:v(g)})}}class y extends k{read(){const b=this.ctx.host||{},g=D(b.selectedCount)?b.selectedCount():0;return g?this.t("status.selected",{count:g}):""}}class d extends k{read(){const b=this.ctx.host||{},g=D(b.rangeValues)?b.rangeValues():[],f=I(g);if(!f.count)return"";const w=this.ctx.stats||["count","sum","min","max","avg"],v=[];for(const h of w){if(h==="count"){v.push(this.t("status.count",{count:f.count}));continue}const c=f[h];c!==null&&v.push(`${this.t(`status.stat.${h}`)} ${a(c,this.ctx.locale)}`)}return v.join(" ")}}class u extends k{read(){const b=this.ctx.host||{},g=D(b.progress)?b.progress():null;if(!g)return"";const{loaded:f,estimated:w,done:v}=g;if(v)return"";if(!w)return this.t("status.loading",{count:f||0});const h=Math.min(100,Math.round((f||0)/w*100));return this.t("status.loadingOf",{loaded:f||0,total:w,percent:h})}}class n extends k{read(){const b=this.ctx.host||{},g=D(b.updateStats)?b.updateStats():null;return g?g.paused?g.pending?this.t("status.pausedWaiting",{waiting:this.t("count.waiting",{count:g.pending})}):this.t("status.paused"):g.coalescedTotal?this.t("status.coalesced",{count:g.coalescedTotal}):"":""}}class t extends k{read(){const b=this.ctx.host||{},g=D(b.hiddenUnresolved)?b.hiddenUnresolved():0;return g?this.t("status.hiddenComments",{comments:this.t("count.unresolvedComments",{count:g})}):""}}const i=Object.freeze({rowCount:S,selectedCount:y,aggregation:d,progress:u,updates:n,comments:t});class s{panels=[];root=null;init(b){const g=b||{};this.doc=$(g),this.host=g.host||{},this.messages=g.messages||null,this.root=R(this.doc,"div",{class:M.statusBar,attrs:{role:"status","aria-live":"polite"}});const f=g.registry||{},w=Array.isArray(g.panels)&&g.panels.length?g.panels:["rowCount","selectedCount","aggregation","comments","updates","progress"];for(const v of w){const h=typeof v=="string"?v:v.name,c=typeof v=="function"?v:f[h]||i[h];if(!c)continue;const j=new c;j.init({document:this.doc,host:this.host,locale:g.locale,messages:this.messages,...typeof v=="object"?v.props||{}:{}}),this.panels.push({name:String(h||"panel"),panel:j}),this.root.appendChild(j.element())}this.refresh()}element(){return this.root}addPanel(b,g,f){const w=new g;return w.init({document:this.doc,host:this.host,messages:this.messages,...f||{}}),this.panels.push({name:b,panel:w}),this.root&&this.root.appendChild(w.element()),w.refresh(),w}removePanel(b){const g=this.panels.findIndex(v=>v.name===b);if(g<0)return!1;const[f]=this.panels.splice(g,1),w=f.panel.element();return w&&w.parentNode&&w.parentNode.removeChild(w),D(f.panel.destroy)&&f.panel.destroy(),!0}refresh(){for(const b of this.panels)b.panel.refresh()}destroy(){for(const b of this.panels)D(b.panel.destroy)&&b.panel.destroy();this.panels=[],this.root&&W(this.root),this.root=null}}const r=new Map;function o(m,b){const g=b||"";let f=r.get(g);return f||(f=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:0}),r.set(g,f)),f.format(Number(m)||0)}const l=new Map;function a(m,b){const g=b||"";let f=l.get(g);return f||(f=new Intl.NumberFormat(b||void 0,{maximumFractionDigits:3}),l.set(g,f)),f.format(Number(m)||0)}const p=s}),Ce("packages/dom/src/ui/contextmenu.js",function(e,G){"use strict";Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.documentFor,R=_.el,W=_.on,Z=_.clear,U=G("packages/core/src/internal/util.js").isFunction,I=G("packages/dom/src/renderer/direction.js").isRtlElement,S=G("packages/dom/src/cell/icons.js").renderIconInto;function y(i,s){const r=[];for(const o of i||[]){const l=U(o)?o(s):o;if(l==null||l===!1)continue;if(l==="separator"){r.push({separator:!0});continue}if(typeof l=="string"){r.push({name:l});continue}const a=l,p=a.subMenu||a.children;p?r.push({...a,subMenu:y(p,s)}):r.push(a)}return r.filter((o,l,a)=>o.separator?l===0||l===a.length-1?!1:!a[l-1].separator:!0)}class d{root=null;itemNodes=[];items=[];focused=-1;child=null;off=[];open=!1;anchor=null;constructor(s){const r=s||{};this.doc=$(r),this.host=r.host||this.doc.body,this.ctx=r.ctx||{},this.onClose=r.onClose||null,this.parent=r.parent||null}place(s){const r=this.host,o=U(r.getBoundingClientRect)?r.getBoundingClientRect():{left:0,top:0},l=U(this.root.getBoundingClientRect)?this.root.getBoundingClientRect():{width:0,height:0},a=this.doc.defaultView||{innerWidth:0,innerHeight:0},p=a.innerWidth||0,m=a.innerHeight||0;let b=s.x||0,g=s.y||0;const f=I(r);if(s.anchor&&U(s.anchor.getBoundingClientRect)){const h=s.anchor.getBoundingClientRect();s.placement==="below"?(b=f?h.right-l.width:h.left,g=h.bottom):(b=f?h.left-l.width:h.right,g=h.top)}else f&&(b-=l.width);const w={left:Math.max(0,o.left||0),top:Math.max(0,o.top||0),right:Math.min(p||1/0,(o.left||0)+(o.width||1/0)),bottom:Math.min(m||1/0,(o.top||0)+(o.height||1/0))};b+l.width>w.right&&(b-=l.width),b<w.left&&(b=w.left),g+l.height>w.bottom&&(g-=l.height),g<w.top&&(g=w.top);const v=w.bottom-g;l.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-o.left+(r.scrollLeft||0))}px`,this.root.style.top=`${Math.round(g-o.top+(r.scrollTop||0))}px`}show(s){return this.hide(),s.ctx&&(this.ctx={...this.ctx||{},...s.ctx}),this.items=y(s.items,this.ctx),this.returnFocus=s.returnFocus||null,this.anchor=s.anchor&&U(s.anchor.setAttribute)&&s.anchor.getAttribute&&s.anchor.getAttribute("aria-haspopup")?s.anchor:null,this.anchor&&this.anchor.setAttribute("aria-expanded","true"),this.root=R(this.doc,"div",{class:M.menu,attrs:{role:"menu",tabindex:"-1"},style:{position:"absolute"}}),this.itemNodes=[],this.items.forEach((r,o)=>{if(r.separator){this.root.appendChild(R(this.doc,"div",{class:M.menuSeparator,attrs:{role:"separator"}}));return}const l=R(this.doc,"div",{class:[M.menuItem,r.cssClass||""],attrs:{role:r.checked===void 0?"menuitem":"menuitemcheckbox",tabindex:"-1","aria-disabled":r.disabled?"true":null,"aria-checked":r.checked===void 0?null:String(r.checked===!0),"aria-haspopup":r.subMenu?"true":null,"aria-expanded":r.subMenu?"false":null,"data-index":o}});if(r.icon!=null&&r.icon!==""){const p=R(this.doc,"span",{class:M.icon});S(p,r.icon,`menu:${r.name||o}`),l.appendChild(p)}l.appendChild(R(this.doc,"span",{class:`${M.menuItem}__label`,text:r.name||""})),r.shortcut&&l.appendChild(R(this.doc,"span",{class:`${M.menuItem}__shortcut`,text:r.shortcut})),r.subMenu&&l.appendChild(R(this.doc,"span",{class:`${M.menuItem}__arrow`,text:"›"}));const a=this.itemNodes.length;this.off.push(W(l,"click",()=>this.invoke(a))),this.off.push(W(l,"mouseenter",()=>{this.focus(a),r.subMenu?this.openSubMenu(a):this.closeChild()})),this.itemNodes.push(l),this.root.appendChild(l)}),this.host.appendChild(this.root),this.place(s),this.open=!0,this.off.push(W(this.root,"keydown",r=>this.onKeyDown(r))),U(this.doc.addEventListener)&&this.off.push(W(this.doc,"mousedown",this.outside=r=>{this.root&&!n(this.root,r.target)&&!(this.child&&this.child.root&&n(this.child.root,r.target))&&this.hide()},!0)),U(this.root.focus)&&this.root.focus({preventScroll:!0}),this.focus(this.firstEnabled()),this.root}firstEnabled(){for(let s=0;s<this.itemNodes.length;s++)if(!this.itemAt(s).disabled)return s;return-1}itemAt(s){const r=this.itemNodes[s];return r?this.items[Number(r.getAttribute("data-index"))]||{}:{}}focus(s){if(s<0||s>=this.itemNodes.length)return;const r=this.itemNodes[this.focused];r&&r.classList.remove(`${M.menuItem}--focused`),this.focused=s;const o=this.itemNodes[s];o.classList.add(`${M.menuItem}--focused`),U(o.focus)&&o.focus(),U(o.scrollIntoView)&&o.scrollIntoView({block:"nearest",inline:"nearest"})}move(s){const r=this.itemNodes.length;if(!r)return;let o=this.focused;for(let l=0;l<r;l++)if(o=(o+s+r)%r,!this.itemAt(o).disabled){this.focus(o);return}}invoke(s){const r=this.itemAt(s);if(!(!r||r.disabled)){if(r.subMenu){this.openSubMenu(s);return}U(r.action)&&r.action({...this.ctx,item:r}),this.hideRoot()}}openSubMenu(s){const r=this.itemAt(s);r.subMenu&&(this.closeChild(),this.child=new d({document:this.doc,host:this.host,ctx:this.ctx,parent:this}),this.child.show({items:r.subMenu,anchor:this.itemNodes[s]}))}closeChild(){this.child&&(this.child.hide(),this.child=null)}onKeyDown(s){switch(s.key){case"ArrowDown":u(s),this.move(1);break;case"ArrowUp":u(s),this.move(-1);break;case"Home":u(s),this.focus(this.firstEnabled());break;case"End":u(s),this.focus(this.itemNodes.length-1);break;case"ArrowRight":u(s),this.openSubMenu(this.focused);break;case"ArrowLeft":u(s),this.parent&&(this.hide(),U(this.parent.root?.focus)&&this.parent.root.focus());break;case"Enter":case" ":u(s),this.invoke(this.focused);break;case"Escape":u(s),this.hideRoot();break;default:s.key&&s.key.length===1&&this.jumpTo(s.key);break}}jumpTo(s){const r=s.toLowerCase(),o=this.itemNodes.length;for(let l=1;l<=o;l++){const a=(this.focused+l+o)%o,p=this.itemAt(a);if(!p.disabled&&(p.name||"").toLowerCase().startsWith(r)){this.focus(a);return}}}hideRoot(){let s=this;for(;s.parent;)s=s.parent;s.hide()}hide(){this.closeChild();for(const s of this.off)s();this.off.length=0,this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.itemNodes=[],this.focused=-1,this.anchor&&U(this.anchor.setAttribute)&&this.anchor.setAttribute("aria-expanded","false"),this.anchor=null,this.open&&this.returnFocus&&U(this.returnFocus.focus)&&this.returnFocus.focus(),this.open=!1,U(this.onClose)&&this.onClose()}destroy(){this.hide(),this.items=[]}}function u(i){U(i.preventDefault)&&i.preventDefault(),U(i.stopPropagation)&&i.stopPropagation()}function n(i,s){let r=s;for(;r;){if(r===i)return!0;r=r.parentNode}return!1}const t=d}),Ce("packages/dom/src/viewpicker.js",function(e,G){"use strict";Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const _=G("packages/dom/src/editors/common.js"),M=_.documentFor,$=_.el,R=_.on,W=_.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction,k=G("packages/dom/src/cell/icons.js").createIcon,S=Object.freeze({root:"lat-views",head:"lat-views__head",title:"lat-views__title",count:"lat-views__count",list:"lat-views__list",empty:"lat-views__empty",item:"lat-views__item",itemActive:"lat-views__item--active",itemEditing:"lat-views__item--editing",apply:"lat-views__apply",name:"lat-views__name",description:"lat-views__description",badges:"lat-views__badges",badge:"lat-views__badge",badgeDefault:"lat-views__badge--default",badgeShared:"lat-views__badge--shared",badgePrivate:"lat-views__badge--private",diff:"lat-views__diff",diffClean:"lat-views__diff--clean",actions:"lat-views__actions",action:"lat-views__action",actionIcon:"lat-views__action-icon",actionDanger:"lat-views__action--danger",confirm:"lat-views__confirm",foot:"lat-views__foot",input:"lat-views__input",save:"lat-views__save"});class y{root=null;off=[];host={};props={};editing=null;confirming=null;draft="";t(t,i){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(t,i)}init(t){this.messages=t&&t.messages||t&&t.grid&&t.grid.messages||V;const i=t||{};this.doc=M(i),this.host=i.host||{},this.props=i.props||{},this.root=$(this.doc,"div",{class:S.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 l of this.off)l();this.off.length=0,W(t),this.diffs=new Map;const i=this.views(),s=i.filter(l=>l.builtin),r=i.filter(l=>!l.builtin);s.length&&(t.appendChild(this.buildHead(String(this.props.builtinTitle||"Defined views"),s.length)),t.appendChild(this.buildList(s))),t.appendChild(this.buildHead(String(this.props.title||"Saved views"),r.length)),r.length?t.appendChild(this.buildList(r)):t.appendChild($(this.doc,"p",{class:S.empty,text:String(this.props.emptyText||this.t("views.empty"))}));const o=this.buildFoot();o&&t.appendChild(o)}buildList(t){const i=$(this.doc,"div",{class:S.list,attrs:{role:"list"}});for(const s of t)i.appendChild(this.buildItem(s));return i}views(){const t=D(this.host.views)?this.host.views()||[]:[];return this.props.sort!=="name"?t:t.slice().sort((i,s)=>String(i.name||"").localeCompare(String(s.name||"")))}activeId(){return D(this.host.activeId)?this.host.activeId():null}buildHead(t,i){return $(this.doc,"div",{class:S.head,children:[$(this.doc,"span",{class:S.title,text:String(t)}),$(this.doc,"span",{class:S.count,text:String(i)})]})}buildItem(t){const i=String(t.id),s=this.activeId()===i,r=D(this.host.canEdit)?this.host.canEdit(t)!==!1:!0,o=$(this.doc,"div",{class:[S.item,s?S.itemActive:"",this.editing===i?S.itemEditing:""],attrs:{role:"listitem","data-view":i,"data-shared":t.shared?"true":"false"}});if(this.editing===i)return o.appendChild(this.buildRenameRow(t)),o;const l=$(this.doc,"button",{class:S.apply,attrs:{type:"button","aria-current":s?"true":null,title:[s?`${t.name} is applied`:`Apply ${t.name}`,t.shared?"Shared with everyone":"Private to you"].join(": ")},children:[$(this.doc,"span",{class:S.name,text:String(t.name||"")}),t.isDefault?this.buildBadges(t):null].filter(Boolean)});D(this.host.apply)?this.off.push(R(l,"click",()=>this.applyView(i))):l.setAttribute("disabled",""),t.description&&l.appendChild($(this.doc,"span",{class:S.description,text:String(t.description)}));const a=this.buildDiff(i,s);return a&&l.appendChild(a),o.appendChild(l),t.builtin||o.appendChild(this.confirming===i?this.buildConfirm(t):this.buildActions(t,r)),o}buildBadges(t){const i=$(this.doc,"span",{class:S.badges});return t.isDefault&&i.appendChild($(this.doc,"span",{class:[S.badge,S.badgeDefault],text:this.t("views.default"),attrs:{title:"Applied when the grid loads"}})),i}buildDiff(t,i){if(this.props.showDiff!==!0||!D(this.host.diff))return null;const s=this.diffOf(t);if(!s)return null;if(!s.changed)return $(this.doc,"span",{class:[S.diff,S.diffClean],text:this.t(i?"views.applied":"views.matchesGrid")});const r=d(s);return r.length?$(this.doc,"span",{class:S.diff,text:r.join(" · ")}):null}diffOf(t){if(!D(this.host.diff))return null;if(this.diffs.has(t))return this.diffs.get(t);let i=null;try{i=this.host.diff(t)}catch{i=null}return this.diffs.set(t,i),i}buildActions(t,i){const s=String(t.id),r=$(this.doc,"span",{class:S.actions});if(i&&D(this.host.rename)&&r.appendChild(this.buildAction("Rename",`Rename ${t.name}`,()=>{this.editing=s,this.confirming=null,this.refresh(),this.focusInput()},"pencil")),t.isDefault&&D(this.host.clearDefault)?r.appendChild(this.buildAction("Unset default",`Stop applying ${t.name} at load`,()=>{this.host.clearDefault(s),this.refresh()},"pin")):!t.isDefault&&D(this.host.setDefault)&&r.appendChild(this.buildAction("Make default",`Apply ${t.name} when the grid loads`,()=>{this.host.setDefault(s),this.refresh()},"pin")),D(this.host.export)&&r.appendChild(this.buildAction("Share",`Export ${t.name}`,()=>this.host.export(s),"share")),i&&D(this.host.remove)){const o=this.buildAction("Delete",`Delete ${t.name}`,()=>{this.confirming=s,this.refresh()},"trash");o.classList.add(S.actionDanger),r.appendChild(o)}return r}buildConfirm(t){const i=String(t.id),s=$(this.doc,"span",{class:S.confirm});s.appendChild($(this.doc,"span",{text:this.t("views.confirmDelete",{name:t.name})}));const r=this.buildAction(this.t("views.delete"),this.t("views.confirmDeleteLabel",{name:t.name}),()=>{this.confirming=null,this.host.remove(i),this.refresh()});return r.classList.add(S.actionDanger),s.appendChild(r),s.appendChild(this.buildAction("Cancel","Keep this view",()=>{this.confirming=null,this.refresh()})),s}buildRenameRow(t){const i=String(t.id),s=$(this.doc,"span",{class:S.confirm}),r=$(this.doc,"input",{class:S.input,attrs:{type:"text","aria-label":`New name for ${t.name}`}});r.value=String(t.name||""),this.input=r;const o=()=>{const a=String(r.value||"").trim();this.editing=null,a&&a!==t.name&&this.host.rename(i,a),this.refresh()},l=()=>{this.editing=null,this.refresh()};return this.off.push(R(r,"keydown",a=>{a.key==="Enter"?o():a.key==="Escape"&&l()})),s.appendChild(r),s.appendChild(this.buildAction("Save","Save the new name",o)),s.appendChild(this.buildAction("Cancel","Leave the name alone",l)),s}buildFoot(){if(this.props.allowSave===!1||!D(this.host.saveAs))return null;const t=$(this.doc,"div",{class:S.foot}),i=$(this.doc,"input",{class:S.input,attrs:{type:"text",placeholder:this.t("views.namePlaceholder"),"aria-label":this.t("views.nameLabel")}});i.value=this.draft,this.editing===null&&(this.input=i);const s=()=>{const o=String(i.value||"").trim();if(!o){D(i.focus)&&i.focus();return}this.draft="",this.host.saveAs(o),this.refresh()};this.off.push(R(i,"input",()=>{this.draft=String(i.value||"")})),this.off.push(R(i,"keydown",o=>{o.key==="Enter"&&s()}));const r=$(this.doc,"button",{class:S.save,text:this.t("views.save"),attrs:{type:"button"}});return this.off.push(R(r,"click",s)),t.appendChild(i),t.appendChild(r),t}buildAction(t,i,s,r){const o=$(this.doc,"button",{class:S.action,text:r?null:t,attrs:{type:"button",title:i,"aria-label":i,"data-action":t}});return r&&o.appendChild(k(this.doc,r,{className:S.actionIcon})),this.off.push(R(o,"click",s)),o}applyView(t){this.confirming=null,this.host.apply(t),this.refresh()}focusInput(){const t=this.input;t&&D(t.focus)&&t.focus(),t&&D(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(n,t=3){if(!n||!n.changed)return[];const i=n.counts||{},s=[],r=(o,l,a)=>{o&&s.push((o===1?l:a).replace("%",String(o)))};if(r(i.columnsHidden,"hides % column","hides % columns"),r(i.columnsShown,"shows % column","shows % columns"),r(i.columnsMoved,"moves % column","moves % columns"),r(i.columnsPinned,"repins % column","repins % columns"),r(i.columnsResized,"resizes % column","resizes % columns"),n.filters&&n.filters.changed){const o=i.filterColumns||0;s.push(o?`changes ${o} filter${o===1?"":"s"}`:"changes the filter")}return n.quick&&n.quick.changed&&s.push("changes the search"),n.sort&&n.sort.changed&&s.push("changes the sort"),n.group&&n.group.changed&&s.push("changes the grouping"),n.pivot&&n.pivot.changed&&s.push("changes the pivot"),r(i.columnsTotalled,"changes % total","changes % totals"),n.pagination&&n.pagination.changed&&s.push("changes the page size"),s.length<=t?s:[...s.slice(0,t),`and ${s.length-t} more`]}const u=y}),Ce("packages/dom/src/ui/panelbase.js",function(e,G){"use strict";Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return Z}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.el,W=G("packages/core/src/i18n/index.js").defaultMessages;class Z{root=null;off=[];init(U){this.ctx=U,this.doc=U.document,this.host=U.host||{},this.props=U.props||{},this.root=$(this.doc,"div",{class:`${M.panel}__body`}),this.refresh()}t(U,D){const I=this.host||{};if(typeof I.t=="function")return I.t(U,D);const k=this.ctx||{};if(k.messages&&typeof k.messages.t=="function")return k.messages.t(U,D);const S=k.grid;return(S&&S.messages?S.messages:W).t(U,D)}element(){return this.root}refresh(){}destroy(){for(const U of this.off)U();this.off.length=0,this.root=null}}}),Ce("packages/dom/src/formattingpanel.js",function(e,G){"use strict";Object.defineProperty(e,"describeRule",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"FormattingPanel",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"createFormattingPanel",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return f}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.documentFor,R=_.el,W=_.on,Z=_.clear,U=G("packages/core/src/internal/util.js").isFunction,I=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,k=G("packages/core/src/formatting/rules.js"),S=k.compileRules,y=k.summariseColumn,d=k.needsDistribution,u=k.DISTRIBUTION_LABELS,n="*",t=8,i=Object.freeze([{op:"gt",label:"greater than",values:1},{op:"gte",label:"at least",values:1},{op:"lt",label:"less than",values:1},{op:"lte",label:"at most",values:1},{op:"eq",label:"equal to",values:1},{op:"ne",label:"not equal to",values:1},{op:"between",label:"between",values:2},{op:"outside",label:"outside",values:2},{op:"contains",label:"contains",values:1},{op:"notContains",label:"does not contain",values:1},{op:"startsWith",label:"starts with",values:1},{op:"endsWith",label:"ends with",values:1},{op:"blank",label:"is blank",values:0},{op:"notBlank",label:"is not blank",values:0}]),s=Object.freeze([{op:"topPercent",label:u.topPercent,values:1},{op:"bottomPercent",label:u.bottomPercent,values:1},{op:"topN",label:u.topN,values:1},{op:"bottomN",label:u.bottomN,values:1},{op:"aboveMean",label:u.aboveMean,values:0},{op:"belowMean",label:u.belowMean,values:0},{op:"aboveMedian",label:u.aboveMedian,values:0},{op:"belowMedian",label:u.belowMedian,values:0},{op:"zAbove",label:u.zAbove,values:1},{op:"zBelow",label:u.zBelow,values:1},{op:"outlier",label:u.outlier,values:0}]),r=Object.freeze([...i,...s]),o=Object.freeze([{name:"Red",background:"#fbeceb",color:"#b03030"},{name:"Amber",background:"#fdf3e0",color:"#9a6400"},{name:"Green",background:"#e8f5ee",color:"#1a7f4b"},{name:"Blue",background:"#e7f0fb",color:"#1a6bc7"},{name:"Grey",background:"#f1f3f5",color:"#5b6570"}]),l=Object.freeze([{name:"White → Blue",colours:["#f8f9fa","#1a6bc7"]},{name:"White → Green",colours:["#f8f9fa","#1a7f4b"]},{name:"Red → Green",colours:["#d64545","#f6e58d","#1a7f4b"]},{name:"Blue → White → Red",colours:["#1a6bc7","#f8f9fa","#d64545"]}]),a=Object.freeze([{from:"minmax",label:"across the full range"},{from:"quantile",label:"across the middle 90%"},{from:"stddev",label:"within 2 deviations of the mean"}]);function p(w){const v=r.find(h=>h.op===w);return v?v.values:1}function m(w){if(!w)return"";if(w.scale){const{min:j,max:E,from:O}=w.scale;if(Number.isFinite(j)&&Number.isFinite(E))return`Colour scale, ${j} to ${E}`;const T=a.find(A=>A.from===O);return T?`Colour scale ${T.label}`:"Colour scale"}const v=w.when||{},h=r.find(j=>j.op===v.op),c=h?h.label:v.op;return!h||h.values===0?`Value ${c}`:h.values===2?`Value ${c} ${v.value} and ${v.value2}`:`Value ${c} ${v.value}`}class b extends I{scope=n;mode="condition";refresh(){const v=this.root;if(v){for(const h of this.off)h();this.off.length=0,Z(v),v.appendChild(this.#o()),v.appendChild(this.#i()),v.appendChild(this.#l())}}#e(){const v=U(this.host.formattableColumns)?this.host.formattableColumns():[];return[{id:n,title:"All columns"},...v]}#t(){return U(this.host.formattingRules)?this.host.formattingRules(this.scope):[]}#n(v){if(!U(this.host.columnSamples))return[];const h=this.host.columnSamples(v);return Array.isArray(h)?h:[...h||[]]}#r(v,h,c){const j=d(v)?y(h):null;return S(v,j)({value:c})}#o(){const v=R(this.doc,"div",{class:`${M.panel}__row`});v.appendChild(R(this.doc,"label",{class:`${M.panel}__label`,text:this.t("formatting.format"),attrs:{for:"lat-fmt-scope"}}));const h=R(this.doc,"select",{class:`${M.panel}__select`,attrs:{id:"lat-fmt-scope"}});for(const c of this.#e()){const j=R(this.doc,"option",{text:c.title,attrs:{value:c.id}});c.id===this.scope&&j.setAttribute("selected","selected"),h.appendChild(j)}return h.value=this.scope,this.off.push(W(h,"change",()=>{this.scope=h.value||n,this.refresh()})),v.appendChild(h),v}#i(){const v=R(this.doc,"ul",{class:`${M.panel}__list`}),h=this.#t();if(!h.length)return v.appendChild(R(this.doc,"li",{class:`${M.panel}__empty`,text:this.t("formatting.noRules")})),v;h.forEach((E,O)=>{const T=R(this.doc,"li",{class:`${M.panel}__item`,attrs:{"data-rule":E.id}}),A=R(this.doc,"input",{attrs:{type:"checkbox","aria-label":`Enable ${m(E)}`}});A.checked=E.enabled!==!1,this.off.push(W(A,"change",()=>{this.#c("updateRule",this.scope,E.id,{enabled:A.checked})})),T.appendChild(A);const P=R(this.doc,"span",{class:`${M.panel}__swatch`}),L=E.style||{};if(L.background&&P.style&&P.style.setProperty)P.style.setProperty("background",String(L.background));else if(E.scale&&E.scale.colours&&P.style&&P.style.setProperty){const F=E.scale.colours;P.style.setProperty("background",`linear-gradient(90deg, ${F[0]}, ${F[F.length-1]})`)}T.appendChild(P),T.appendChild(R(this.doc,"span",{class:`${M.panel}__text`,text:m(E)}));const z=R(this.doc,"button",{class:`${M.panel}__icon`,text:"↑",attrs:{type:"button","aria-label":this.t("formatting.moveEarlier"),...O===0?{disabled:"disabled"}:{}}});this.off.push(W(z,"click",()=>this.#c("moveRule",this.scope,E.id,O-1))),T.appendChild(z);const H=R(this.doc,"button",{class:`${M.panel}__icon`,text:"↓",attrs:{type:"button","aria-label":this.t("formatting.moveLater"),...O===h.length-1?{disabled:"disabled"}:{}}});this.off.push(W(H,"click",()=>this.#c("moveRule",this.scope,E.id,O+1))),T.appendChild(H);const x=R(this.doc,"button",{class:`${M.panel}__icon`,text:"×",attrs:{type:"button","aria-label":`Remove ${m(E)}`}});this.off.push(W(x,"click",()=>this.#c("removeRule",this.scope,E.id))),T.appendChild(x),v.appendChild(T)});const c=this.#s(h);c&&v.appendChild(c);const j=R(this.doc,"button",{class:`${M.panel}__link`,text:this.t("formatting.clearAll"),attrs:{type:"button"}});return this.off.push(W(j,"click",()=>this.#c("clearRules",this.scope))),v.appendChild(j),v}#s(v){const h=this.#n(this.scope);if(!h.length)return null;const c=v.filter(E=>E.enabled!==!1);if(!c.length)return null;const j=R(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.preview")}});for(const E of h.slice(0,t)){const O=this.#r(c,h,E),T=R(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(E)});O&&T.style&&T.style.setProperty&&(O.background&&T.style.setProperty("background",String(O.background)),O.color&&T.style.setProperty("color",String(O.color))),j.appendChild(T)}return j}#l(){const v=R(this.doc,"div",{class:`${M.panel}__form`}),h=R(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.ruleKind")}});return h.appendChild(R(this.doc,"option",{text:this.t("formatting.aCondition"),attrs:{value:"condition"}})),h.appendChild(R(this.doc,"option",{text:this.t("formatting.aColourScale"),attrs:{value:"scale"}})),h.value=this.mode,this.off.push(W(h,"change",()=>{this.mode=h.value==="scale"?"scale":"condition",this.refresh()})),v.appendChild(h),this.mode==="scale"?v.appendChild(this.#u()):v.appendChild(this.#a()),v}#a(){const v=R(this.doc,"div",{class:`${M.panel}__form`}),h=R(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.condition")}}),c=R(this.doc,"optgroup",{attrs:{label:this.t("formatting.compare")}});for(const x of i)c.appendChild(R(this.doc,"option",{text:x.label,attrs:{value:x.op}}));h.appendChild(c);const j=R(this.doc,"optgroup",{attrs:{label:this.t("formatting.distribution")}});for(const x of s)j.appendChild(R(this.doc,"option",{text:x.label,attrs:{value:x.op}}));h.appendChild(j),h.value="gt",v.appendChild(h);const E=R(this.doc,"input",{class:`${M.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.value")}}),O=R(this.doc,"input",{class:`${M.panel}__input`,attrs:{type:"text","aria-label":this.t("formatting.secondValue")}});v.appendChild(E),v.appendChild(O);const T=()=>{const x=p(h.value);E.style.setProperty("display",x>=1?"":"none"),O.style.setProperty("display",x>=2?"":"none"),z()};this.off.push(W(h,"change",T));const A=R(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("menu.colour")}});for(const x of o)A.appendChild(R(this.doc,"option",{text:x.name,attrs:{value:x.name}}));A.value=o[0].name,v.appendChild(A);const P=R(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(P);const L=()=>{const x=o.find(B=>B.name===A.value)||o[0],F=p(h.value),C={op:h.value};return F>=1&&(C.value=E.value),F>=2&&(C.value2=O.value),{when:C,style:{background:x.background,color:x.color}}},z=()=>{Z(P);const x=this.#n(this.scope);if(x.length)for(const F of x.slice(0,t)){const C=this.#r([L()],x,F),B=R(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(F)});C&&B.style&&B.style.setProperty&&(C.background&&B.style.setProperty("background",String(C.background)),C.color&&B.style.setProperty("color",String(C.color))),P.appendChild(B)}};this.off.push(W(E,"input",z)),this.off.push(W(O,"input",z)),this.off.push(W(A,"change",z)),T();const H=R(this.doc,"button",{class:`${M.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(H,"click",()=>{this.#c("addRule",this.scope,L()),E.value="",O.value=""})),v.appendChild(H),v}#u(){const v=R(this.doc,"div",{class:`${M.panel}__form`}),h=R(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.colourScale")}});for(const A of l)h.appendChild(R(this.doc,"option",{text:A.name,attrs:{value:A.name}}));h.value=l[0].name,v.appendChild(h);const c=R(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("formatting.scaleBounds")}});for(const A of a)c.appendChild(R(this.doc,"option",{text:A.label,attrs:{value:A.from}}));c.value=a[0].from,v.appendChild(c);const j=R(this.doc,"div",{class:`${M.panel}__preview`,attrs:{"aria-label":this.t("formatting.livePreview")}});v.appendChild(j);const E=()=>{const A=l.find(P=>P.name===h.value)||l[0];return{scale:{from:c.value,colours:[...A.colours]}}},O=()=>{Z(j);const A=this.#n(this.scope);if(A.length)for(const P of A.slice(0,t)){const L=this.#r([E()],A,P),z=R(this.doc,"span",{class:`${M.panel}__previewcell`,text:String(P)});L&&L.background&&z.style&&z.style.setProperty&&z.style.setProperty("background",String(L.background)),j.appendChild(z)}};this.off.push(W(h,"change",O)),this.off.push(W(c,"change",O)),O();const T=R(this.doc,"button",{class:`${M.panel}__button`,text:this.t("formatting.addRule"),attrs:{type:"button"}});return this.off.push(W(T,"click",()=>{this.#c("addRule",this.scope,E())})),v.appendChild(T),v}#c(v,...h){U(this.host[v])&&this.host[v](...h),this.refresh()}}function g(w={}){const v=new b;return v.init({document:$(w),host:w.host||{}}),v}const f=b}),Ce("packages/dom/src/statisticspanel.js",function(e,G){"use strict";Object.defineProperty(e,"StatisticsPanel",{enumerable:!0,get:function(){return d}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.el,R=_.on,W=_.clear,V=G("packages/core/src/internal/util.js").isFunction,D=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"},{key:"min",label:"stats.min",kind:"value"},{key:"max",label:"stats.max",kind:"value"},{key:"mean",label:"stats.mean",kind:"value"},{key:"median",label:"stats.median",kind:"value"},{key:"q1",label:"stats.q1",kind:"value"},{key:"q3",label:"stats.q3",kind:"value"},{key:"iqr",label:"stats.iqr",kind:"value"},{key:"stddev",label:"stats.stddev",kind:"value"},{key:"outliers",label:"stats.outliers",kind:"count"}]),k=Object.freeze([{key:"present",label:"stats.present",kind:"count"},{key:"missing",label:"stats.missing",kind:"count"},{key:"distinct",label:"stats.distinct",kind:"count"}]),S=Object.freeze([{label:"stats.section.shape",kernels:["skewness","kurtosis","jarqueBera"]},{label:"stats.section.robust",kernels:["trimmedMean","winsorizedMean","mad","robustOutliers"]},{label:"stats.section.concentration",kernels:["gini","hhi","entropy","evenness","top3Share"]}]);function y(u){if(u==null||!Number.isFinite(u))return"—";if(Number.isInteger(u))return String(u);const n=Math.abs(u);return n!==0&&(n<.001||n>=1e7)?u.toExponential(2):String(Number(u.toPrecision(4)))}class d extends D{column=null;#e(){return V(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const n=this.root;if(!n)return;for(const r of this.off)r();this.off.length=0,W(n);const t=this.#e();if(!t.length){n.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("stats.noColumns")}));return}t.some(r=>r.id===this.column)||(this.column=t[0].id),n.appendChild(this.#t(t));const i=V(this.host.columnProfile)?this.host.columnProfile(this.column):null;if(!i||!i.present){n.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("stats.noValues")}));return}if(n.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("stats.filtered",{count:i.rows})})),Array.isArray(i.topValues)){n.appendChild(this.#o(i,k)),n.appendChild(this.#i(i.topValues));return}n.appendChild(this.#o(i));for(const r of S){const o=this.#n(r);o&&n.appendChild(o)}const s=this.#r();s&&n.appendChild(s),i.histogram&&i.histogram.length>1&&n.appendChild(this.#s(i.histogram))}#t(n){const t=$(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t("stats.choose")}});for(const i of n){const s=$(this.doc,"option",{text:i.title,attrs:{value:i.id,selected:i.id===this.column?!0:null}});t.appendChild(s)}return t.value=this.column,this.off.push(R(t,"change",()=>{this.column=t.value,this.refresh()})),$(this.doc,"label",{class:`${M.panel}__field`,children:[$(this.doc,"span",{class:`${M.panel}__label`,text:this.t("stats.column")}),t]})}#n(n){const t=this.host.reduceColumn;if(!V(t)||!this.column)return null;const i=[];for(const o of n.kernels){const l=t(this.column,o);l==null||Number.isNaN(l)||i.push([o,l])}if(!i.length)return null;const s=this.doc.createElement("div");s.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t(n.label)}));const r=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const[o,l]of i)r.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(`total.${o}`)})),r.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:typeof l=="number"?y(l):String(l)}));return s.appendChild(r),s}#r(){const n=this.host.columnCapability;if(!V(n)||!this.column)return null;const t=n(this.column);if(!t)return null;const i=this.doc.createElement("div");i.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.section.capability")}));const s=$(this.doc,"dl",{class:`${M.panel}__stats`}),r=[["stats.cp",t.cp,null],["stats.cpk",t.cpk,t.interval],["stats.pp",t.pp,null],["stats.ppk",t.ppk,t.intervalPp],["stats.outOfSpec",t.outOfSpec,null]];for(const[o,l,a]of r){if(l==null)continue;s.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(o)}));const p=[$(this.doc,"span",{text:y(l)})];a&&Number.isFinite(a.lower)&&p.push($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${y(a.lower)} – ${y(a.upper)}`,attrs:{title:`${Math.round(a.confidence*100)}%`}})),s.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,children:p}))}return i.appendChild(s),i}#o(n,t=I){const i=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const s of t){const r=n[s.key];i.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(s.label)})),i.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:s.kind==="count"?String(r??0):y(r)}))}return i}#i(n){const t=this.doc.createElement("div");t.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.topValues")}));const i=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const s of n)i.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:String(s.value)})),i.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,children:[$(this.doc,"span",{text:String(s.count)}),$(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${Math.round(s.share*100)}%`})]}));return t.appendChild(i),t}#s(n){const t=n.reduce((s,r)=>Math.max(s,r.count),0)||1,i=$(this.doc,"div",{class:`${M.panel}__histogram`});i.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t("stats.distribution")}));for(const s of n){const r=$(this.doc,"div",{class:`${M.panel}__bar`,style:{width:`${s.count?Math.max(2,s.count/t*100):0}%`}});i.appendChild($(this.doc,"div",{class:`${M.panel}__bin`,attrs:{title:this.t("stats.bin",{count:s.count,from:y(s.from),to:y(s.to)})},children:[r]}))}return i}}}),Ce("packages/dom/src/regressionpanel.js",function(e,G){"use strict";Object.defineProperty(e,"RegressionPanel",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.el,R=_.clear,Z=G("packages/core/src/internal/util.js").isFunction,U=G("packages/dom/src/ui/panelbase.js").ToolPanelBase;function D(S,y=4){const d=Number(S);return Number.isFinite(d)?d.toFixed(y):d===1/0?"∞":"—"}class I 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,u=d&&Z(d.get)?d.get("regression"):null;return u&&Array.isArray(u.predictors)&&u.response?u:null}refresh(){const y=this.root;if(!y)return;R(y);const d=this.#e();if(!d){y.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.noModel")}));return}const u=Z(this.host.regressionModel)?this.host.regressionModel(d):null;if(!u){y.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.cannotFit")}));return}y.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("regression.observations",{count:u.n})})),y.appendChild(this.#t(u)),y.appendChild(this.#n(u));const n=this.#r(u,d);n&&y.appendChild(n),y.appendChild(this.#o(u))}#t(y){const d=$(this.doc,"dl",{class:`${M.panel}__stats`}),u=(n,t)=>{d.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-label`,text:n})),d.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:t}))};return u(this.t("regression.r2"),D(y.r2,4)),u(this.t("regression.adjR2"),D(y.adjR2,4)),d}#n(y){const d=$(this.doc,"div",{class:`${M.panel}__section`});d.appendChild($(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.coefficients")}));const u=$(this.doc,"table",{class:`${M.panel}__coef-table`}),n=$(this.doc,"tr");for(const t of["regression.term","regression.estimate","regression.stdError","regression.t","regression.p"])n.appendChild($(this.doc,"th",{text:this.t(t)}));u.appendChild(n);for(const t of y.coefficients){const i=$(this.doc,"tr");i.appendChild($(this.doc,"td",{text:t.name})),i.appendChild($(this.doc,"td",{text:`${D(t.estimate)} ± ${D(t.stdError)}`})),i.appendChild($(this.doc,"td",{text:D(t.stdError)})),i.appendChild($(this.doc,"td",{text:D(t.t,3)})),i.appendChild($(this.doc,"td",{text:D(t.p,4)})),u.appendChild(i)}return d.appendChild(u),d}#r(y,d){if(!Array.isArray(y.vif)||y.vif.length<2)return null;const u=$(this.doc,"div",{class:`${M.panel}__section`});u.appendChild($(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.vif")}));const n=$(this.doc,"dl",{class:`${M.panel}__stats`});return y.vif.forEach((t,i)=>{n.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-label`,text:d.predictors[i]})),n.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:D(t,3)}))}),u.appendChild(n),u}#o(y){const d=y.heteroscedasticity,u=$(this.doc,"div",{class:`${M.panel}__section`});return u.appendChild($(this.doc,"h4",{class:`${M.panel}__heading`,text:this.t("regression.heteroscedasticity")})),d?(u.appendChild($(this.doc,"p",{class:`${M.panel}__flag`,attrs:{"data-heteroscedastic":d.heteroscedastic?"true":"false"},text:this.t(d.heteroscedastic?"regression.heteroscedastic":"regression.homoscedastic",{statistic:D(d.statistic,3),p:D(d.p,4)})})),u):(u.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("regression.cannotFit")})),u)}}const k=I}),Ce("packages/dom/src/comparepanel.js",function(e,G){"use strict";Object.defineProperty(e,"ComparePanel",{enumerable:!0,get:function(){return S}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.el,R=_.on,W=_.clear,V=G("packages/core/src/internal/util.js").isFunction,D=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=Object.freeze([{key:"pearson",label:"compare.pearson"},{key:"spearman",label:"compare.spearman"},{key:"kendall",label:"compare.kendall"},{key:"slope",label:"compare.slope"},{key:"intercept",label:"compare.intercept"},{key:"r2",label:"compare.r2"},{key:"stdError",label:"compare.stdError"},{key:"covariance",label:"compare.covariance"},{key:"weighted",label:"compare.weighted"}]);function 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 S extends D{first=null;second=null;#e(){return V(this.host.profilableColumns)?this.host.profilableColumns():[]}refresh(){const d=this.root;if(!d)return;for(const i of this.off)i();this.off.length=0,W(d);const u=this.#e();if(u.length<2){d.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("compare.needTwo")}));return}u.some(i=>i.id===this.first)||(this.first=u[0].id),(!u.some(i=>i.id===this.second)||this.second===this.first)&&(this.second=(u.find(i=>i.id!==this.first)||u[0]).id),d.appendChild(this.#t("compare.first",u,this.first,i=>{this.first=i,this.second===i&&(this.second=(u.find(s=>s.id!==i)||u[0]).id),this.refresh()})),d.appendChild(this.#t("compare.second",u,this.second,i=>{this.second=i,this.first===i&&(this.first=(u.find(s=>s.id!==i)||u[0]).id),this.refresh()}));const n=V(this.host.compareColumns)?this.host.compareColumns(this.first,this.second):null;if(!n||!n.n){d.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("compare.noPairs")}));return}d.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("compare.pairs",{count:n.n})}));const t=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const i of I){const s=n[i.key];s!=null&&(t.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(i.label)})),t.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,text:k(s)})))}d.appendChild(t)}#t(d,u,n,t){const i=$(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t(d)}});for(const s of u)i.appendChild($(this.doc,"option",{text:s.title,attrs:{value:s.id,selected:s.id===n?!0:null}}));return i.value=n,this.off.push(R(i,"change",()=>t(i.value))),$(this.doc,"label",{class:`${M.panel}__field`,children:[$(this.doc,"span",{class:`${M.panel}__label`,text:this.t(d)}),i]})}}}),Ce("packages/dom/src/insightspanel.js",function(e,G){"use strict";Object.defineProperty(e,"InsightsPanel",{enumerable:!0,get:function(){return S}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.el,R=_.on,W=_.clear,V=G("packages/core/src/internal/util.js").isFunction,D=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,I=Object.freeze([{key:"stats.cp",field:"cp",interval:null},{key:"stats.cpk",field:"cpk",interval:"interval"},{key:"stats.pp",field:"pp",interval:null},{key:"stats.ppk",field:"ppk",interval:"intervalPp"},{key:"stats.outOfSpec",field:"outOfSpec",interval:null}]);function 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 S extends D{column=null;by=null;#e(){return V(this.host.insightsColumns)?this.host.insightsColumns():[]}refresh(){const d=this.root;if(!d)return;for(const r of this.off)r();this.off.length=0,W(d);const u=this.#e();if(!u.length){d.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.empty")}));return}const n=this.#t();n&&d.appendChild(n);const t=this.#n();t&&d.appendChild(t),d.appendChild(this.#o(u));const i=this.#s();i&&d.appendChild(i);const s=this.#u();s&&d.appendChild(s)}#t(){if(!V(this.host.subsetVsPopulation))return null;const d=this.host.subsetVsPopulation();if(!d)return null;const u=this.#c("insights.subset");return d.filtered?(u.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("stats.filtered",{count:d.subsetN})})),u.appendChild(this.#r(d.ranked)),u):(u.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.noFilter")})),u)}#n(){const d=this.props&&this.props.other;if(!d||!V(this.host.datasetVsDataset))return null;let u;try{u=this.host.datasetVsDataset(d)}catch{return null}if(!u||!u.ranked)return null;const n=this.#c("insights.dataset");return n.appendChild(this.#r(u.ranked)),n}#r(d){const u=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const n of d||[]){const t=$(this.doc,"dt",{class:`${M.panel}__stat-name`});t.appendChild($(this.doc,"span",{text:String(n.name??n.column)})),t.appendChild($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:String(n.measure||"")}));const i=$(this.doc,"dd",{class:`${M.panel}__stat-value`});i.appendChild($(this.doc,"span",{text:k(n.magnitude)})),n.reliable===!1&&i.appendChild($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:this.t("insights.smallSample")})),u.appendChild(t),u.appendChild(i)}return u}#o(d){const u=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),u.appendChild(this.#d("stats.column",d,this.column,t=>{this.column=t,this.by===t&&(this.by=(d.find(i=>i.id!==t)||d[0]).id),this.refresh()})),u.appendChild(this.#d("insights.by",d,this.by,t=>{this.by=t,this.column===t&&(this.column=(d.find(i=>i.id!==t)||d[0]).id),this.refresh()}));const n=V(this.host.compareGroups)?this.host.compareGroups(this.column,{by:this.by}):null;return n?(u.appendChild(this.#i(n)),u):(u.appendChild($(this.doc,"p",{class:`${M.panel}__empty`,text:this.t("insights.needGroups")})),u)}#i(d){const u=$(this.doc,"dl",{class:`${M.panel}__stats`});Array.isArray(d.groups)&&d.groups.length===2&&this.#a(u,"insights.groups",`${d.groups[0]} · ${d.groups[1]}`),this.#a(u,"insights.test",String(d.method||d.test||""));const n=d.effectSize||{};this.#a(u,"insights.effect",`${n.name||""} ${k(n.value)}`.trim());const t=d.interval;let i="—";if(t&&Number.isFinite(t.lower)&&Number.isFinite(t.upper)){const r=Number.isFinite(t.confidence)?` (${Math.round(t.confidence*100)}%)`:"";i=`${k(t.lower)} – ${k(t.upper)}${r}`}const s=this.#a(u,"insights.interval",i);return t&&t.method&&s.appendChild($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:String(t.method)})),Number.isFinite(d.pValue)&&this.#a(u,"insights.pValue",k(d.pValue)),u}#s(){if(!V(this.host.anomalies))return null;let d;try{d=this.host.anomalies()}catch{return null}if(!d)return null;const u=this.#c("insights.anomalies");u.appendChild($(this.doc,"p",{class:`${M.panel}__count`,text:this.t("insights.anomalyCount",{count:d.flagged||0,n:d.n||0})}));const n=$(this.doc,"dl",{class:`${M.panel}__stats`});this.#a(n,"insights.anomalyMethod",String(d.method||""));const t=this.#l(d);t!==null&&this.#a(n,"insights.anomalyThreshold",k(t)),u.appendChild(n);const i=(d.rows||[]).map(s=>({name:s.rowKey!=null?String(s.rowKey):`#${s.index}`,measure:(s.why||[]).map(r=>r.name||r.column).join(", "),magnitude:s.score}));return u.appendChild(this.#r(i)),u}#l(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 u=Array.isArray(d.columns)?d.columns[0]:null;return u&&Number.isFinite(u.threshold)?u.threshold:null}#a(d,u,n){d.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(u)}));const t=$(this.doc,"dd",{class:`${M.panel}__stat-value`});return t.appendChild($(this.doc,"span",{text:n})),d.appendChild(t),t}#u(){if(!V(this.host.columnCapability)||!this.column)return null;const d=this.host.columnCapability(this.column);if(!d)return null;const u=this.#c("stats.section.capability"),n=$(this.doc,"dl",{class:`${M.panel}__stats`});for(const t of I){const i=d[t.field];if(i==null)continue;n.appendChild($(this.doc,"dt",{class:`${M.panel}__stat-name`,text:this.t(t.key)}));const s=[$(this.doc,"span",{text:k(i)})],r=t.interval?d[t.interval]:null;r&&Number.isFinite(r.lower)&&s.push($(this.doc,"span",{class:`${M.panel}__stat-interval`,text:`${k(r.lower)} – ${k(r.upper)}`,attrs:{title:`${Math.round(r.confidence*100)}%`}})),n.appendChild($(this.doc,"dd",{class:`${M.panel}__stat-value`,children:s}))}return u.appendChild(n),u}#c(d){const u=this.doc.createElement("div");return u.appendChild($(this.doc,"h4",{class:`${M.panel}__subtitle`,text:this.t(d)})),u}#d(d,u,n,t){const i=$(this.doc,"select",{class:`${M.panel}__select`,attrs:{"aria-label":this.t(d)}});for(const s of u)i.appendChild($(this.doc,"option",{text:s.title,attrs:{value:s.id,selected:s.id===n?!0:null}}));return i.value=n,this.off.push(R(i,"change",()=>t(i.value))),$(this.doc,"label",{class:`${M.panel}__field`,children:[$(this.doc,"span",{class:`${M.panel}__label`,text:this.t(d)}),i]})}}}),Ce("packages/dom/src/ui/toolpanel.js",function(e,G){"use strict";Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return j}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return E}}),Object.defineProperty(e,"QuickFilterPanel",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return v}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return T}}),Object.defineProperty(e,"toolPanelTitles",{enumerable:!0,get:function(){return A}}),Object.defineProperty(e,"toolPanelIcons",{enumerable:!0,get:function(){return P}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return L}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return z}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.cssEscape,R=_.documentFor,W=_.el,Z=_.on,V=_.clear,D=G("packages/core/src/i18n/index.js").defaultMessages,I=G("packages/core/src/internal/util.js"),k=I.isFunction,S=I.nextFrame,y=G("packages/dom/src/cell/icons.js"),d=y.createIcon,u=y.updateIcon,n=y.icon,i=G("packages/dom/src/viewpicker.js").ViewPicker,r=G("packages/dom/src/formattingpanel.js").FormattingPanel,l=G("packages/dom/src/statisticspanel.js").StatisticsPanel,p=G("packages/dom/src/regressionpanel.js").RegressionPanel,b=G("packages/dom/src/comparepanel.js").ComparePanel,f=G("packages/dom/src/insightspanel.js").InsightsPanel,v=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,c=G("packages/core/src/compute/total.js").TOTAL_LABELS;class j extends v{dragging=null;refresh(){const F=this.root;if(!F)return;for(const Y of this.off)Y();this.off.length=0,V(F);const C=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.searchColumns"),"aria-label":this.t("panel.searchColumns")}});this.off.push(Z(C,"input",()=>{this.query=C.value,this.paintList()})),F.appendChild(C),F.appendChild(this.buildZone("group","Row groups")),F.appendChild(this.buildZone("values","Grouped row calculation")),F.appendChild(this.buildZone("pivot","Pivot"));const B=W(this.doc,"div",{class:`${M.panel}__heading`});B.appendChild(W(this.doc,"span",{text:this.t("panel.columns")}));const q=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.showAll"),attrs:{type:"button"}}),Q=W(this.doc,"button",{class:`${M.panel}__link`,text:this.t("panel.hideAll"),attrs:{type:"button"}});this.off.push(Z(q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);k(this.host.showColumns)&&this.host.showColumns(Y),this.refresh()})),this.off.push(Z(Q,"click",()=>{const Y=this.columns().filter(J=>!(J.layout&&J.layout.lockVisible)).map(J=>J.id);k(this.host.hideColumns)&&this.host.hideColumns(Y),this.refresh()})),B.appendChild(q),B.appendChild(Q),F.appendChild(B),this.list=W(this.doc,"div",{class:`${M.panel}__columns`,attrs:{role:"group","aria-label":this.t("panel.columns")}}),F.appendChild(this.list),this.paintList()}columns(){const F=this.host;return k(F.columns)?F.columns()||[]:F.columns&&k(F.columns.all)?F.columns.all():[]}paintList(){const F=this.list;if(!F)return;V(F);const C=String(this.query||"").trim().toLowerCase();for(const B of this.columns()){const q=String(B.title||B.id||"");if(C&&!q.toLowerCase().includes(C))continue;const Q=W(this.doc,"div",{class:`${M.panel}__column`,attrs:{"data-col":B.id,draggable:"true",title:this.t("panel.columnDragHint",{column:q})}});Q.appendChild(W(this.doc,"span",{class:`${M.panel}__grip`,attrs:{"aria-hidden":"true"}}));const Y=W(this.doc,"input",{attrs:{type:"checkbox","aria-label":q}});Y.checked=!(B.layout&&B.layout.hidden),B.layout&&B.layout.lockVisible&&Y.setAttribute("disabled",""),this.off.push(Z(Y,"change",()=>this.setVisible(B.id,Y.checked))),Q.appendChild(Y),Q.appendChild(W(this.doc,"span",{text:q})),Q.setAttribute("tabindex","0"),Q.setAttribute("role","listitem"),this.off.push(Z(Q,"keydown",J=>this.onRowKey(J,B))),this.off.push(Z(Q,"dragstart",()=>{this.dragging=B.id})),this.off.push(Z(Q,"dragend",()=>{this.dragging=null,this.clearDropMark()})),this.off.push(Z(Q,"dragover",J=>{if(!this.dragging||this.dragging===B.id)return;k(J.preventDefault)&&J.preventDefault();const te=H(J,Q);Q.setAttribute("data-drop",te?"before":"after")})),this.off.push(Z(Q,"dragleave",()=>Q.removeAttribute("data-drop"))),this.off.push(Z(Q,"drop",J=>{k(J.preventDefault)&&J.preventDefault();const te=this.dragging;this.dragging=null,this.clearDropMark(),!(!te||te===B.id)&&this.moveColumn(te,B.id,H(J,Q))})),F.appendChild(Q)}}onRowKey(F,C){const B=F&&F.key,q=j.zoneKeys[String(B).toLowerCase()];if(q&&!F.ctrlKey&&!F.metaKey&&!F.altKey){k(F.preventDefault)&&F.preventDefault(),this.toggleZone(q,C);return}if(B!=="ArrowUp"&&B!=="ArrowDown")return;const Q=B==="ArrowUp",Y=this.columns().map(de=>de.id),J=Y.indexOf(C.id);if(J<0)return;if(k(F.preventDefault)&&F.preventDefault(),!F.shiftKey){const de=this.list&&this.list.querySelectorAll?[...this.list.querySelectorAll("[data-col]")]:[],ie=de.findIndex(ue=>ue.getAttribute("data-col")===C.id),oe=de[ie+(Q?-1:1)];oe&&k(oe.focus)&&oe.focus();return}const te=C.layout&&(C.layout.movable===!1||C.layout.lockPosition),ee=String(C.title||C.id||"");if(te){this.announce(this.t("a11y.panel.cannotMove",{column:ee}),{repeat:!0});return}const re=Y[J+(Q?-1:1)];if(!re){this.announce(this.t(Q?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:ee}),{repeat:!0});return}this.moveColumn(C.id,re,Q),this.announce(this.t("a11y.panel.moved",{column:ee,at:Q?J:J+2,of:Y.length}),{repeat:!0});const se=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(C.id)}"]`):null;se&&k(se.focus)&&se.focus()}toggleZone(F,C){const B=this.titleOf(C.id),q=this.t(j.zoneLabel[F]||"panel.zone.group");if(this.zoneColumns(F).includes(C.id)){this.dropFromZone(F,C.id),this.announce(this.t("a11y.panel.removedFrom",{column:B,list:q}),{repeat:!0}),this.restoreFocus(C.id);return}if(this.addToZone(F,C.id)){this.announce(this.t("a11y.panel.addedTo",{column:B,list:q}),{repeat:!0}),this.restoreFocus(C.id);return}this.announce(this.t("a11y.panel.cannotAddTo",{column:B,list:q}),{repeat:!0})}restoreFocus(F){const C=this.list&&this.list.querySelector?this.list.querySelector(`[data-col="${$(F)}"]`):null;C&&k(C.focus)&&C.focus()}announce(F,C){const B=this.host||{};k(B.announce)&&B.announce(F,C)}clearDropMark(){if(!(!this.list||!this.list.querySelectorAll))for(const F of this.list.querySelectorAll("[data-drop]"))F.removeAttribute("data-drop")}moveColumn(F,C,B){const q=this.host||{};k(q.moveColumn)&&(q.moveColumn(F,C,B),this.refresh())}buildZone(F,C){const B=W(this.doc,"div",{class:`${M.panel}__zone`,attrs:{"data-zone":F,role:"group","aria-label":C}});B.appendChild(W(this.doc,"div",{class:`${M.panel}__zoneTitle`,text:C}));const q=this.zoneColumns(F);let Q=j.zoneAbout[F]||"";F==="values"&&q.length&&!this.zoneColumns("group").length&&(Q+=" Add a row group to see them."),Q&&B.appendChild(W(this.doc,"div",{class:`${M.panel}__zoneAbout`,text:Q}));const Y=W(this.doc,"div",{class:`${M.panel}__zoneBody`});q.length||Y.appendChild(W(this.doc,"span",{class:`${M.panel}__zoneHint`,text:this.t(j.zoneHint[F]||"panel.zoneHint.any")})),F==="values"&&Y.classList.add(`${M.panel}__zoneBody--rows`);for(const J of q){const te=W(this.doc,"span",{class:[M.chip,F==="values"?`${M.chip}--row`:""]});if(te.appendChild(W(this.doc,"span",{class:`${M.chip}__label`,text:this.titleOf(J)})),F==="values"&&k(this.host.setValueAggregation)){const re=k(this.host.valueAggregation)?this.host.valueAggregation(J):"sum",se=W(this.doc,"select",{class:`${M.chip}__fn`,attrs:{"aria-label":`Calculation for ${this.titleOf(J)}`}});for(const de of j.aggregations)se.appendChild(W(this.doc,"option",{text:this.t(`total.${de.name}`),attrs:{value:de.name,selected:de.name===re?"":null}}));se.value=re,this.off.push(Z(se,"change",()=>{this.host.setValueAggregation(J,se.value),this.refresh()})),te.appendChild(se)}const ee=W(this.doc,"button",{class:M.chipRemove,text:"×",attrs:{type:"button","aria-label":`Remove ${this.titleOf(J)}`}});this.off.push(Z(ee,"click",()=>this.dropFromZone(F,J))),te.appendChild(ee),Y.appendChild(te)}return this.off.push(Z(B,"dragover",J=>{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(F,this.dragging)})),B.appendChild(Y),B}static aggregations=Object.freeze(Object.keys(c).map(F=>({name:F})));static zoneAbout=Object.freeze({group:"Rows are grouped by these columns, in order.",values:"Each column here is calculated for every group. Pick the calculation on its chip.",pivot:"Generates a column for each distinct value."});static zoneHint=Object.freeze({group:"panel.zoneHint.group",values:"panel.zoneHint.values",pivot:"panel.zoneHint.pivot"});static zoneKeys=Object.freeze({g:"group",v:"values",p:"pivot"});static zoneLabel=Object.freeze({group:"panel.zone.group",values:"panel.zone.values",pivot:"panel.zone.pivot"});static zoneApi=Object.freeze({group:{read:"groupBy",write:"setGroupBy",permission:"allowGroup"},values:{read:"valueColumns",write:"setValueColumns",permission:"allowTotal"},pivot:{read:"pivotBy",write:"setPivotBy",permission:"allowPivot"}});zoneColumns(F){const C=j.zoneApi[F],B=this.host;return C&&k(B[C.read])?B[C.read]()||[]:[]}titleOf(F){const C=this.columns().find(B=>B.id===F);return String(C&&(C.title||C.id)||F)}addToZone(F,C){const B=j.zoneApi[F],q=this.columns().find(Y=>Y.id===C);if(!B||!q||q[B.permission]===!1||!k(this.host[B.write]))return!1;const Q=this.zoneColumns(F);return Q.includes(C)?!1:(this.host[B.write]([...Q,C]),this.refresh(),!0)}dropFromZone(F,C){const B=j.zoneApi[F];return!B||!k(this.host[B.write])?!1:(this.host[B.write](this.zoneColumns(F).filter(q=>q!==C)),this.refresh(),!0)}setVisible(F,C){const B=this.host;C&&k(B.showColumns)?B.showColumns([F]):!C&&k(B.hideColumns)&&B.hideColumns([F])}}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 F=this.root;if(!F)return;for(const te of this.off)te();this.off.length=0,V(F);const C=this.host,B=(k(C.columns)?C.columns():[]).filter(te=>!(te.filter&&te.filter.enabled===!1));if(!k(C.filterFor))return;const q=B.filter(te=>this.isFiltered(te.id));F.appendChild(this.buildSearch()),F.appendChild(this.buildSummary(q.length,B.length));const Q=this.query.trim().toLowerCase(),Y=Q?B.filter(te=>String(te.title||te.id).toLowerCase().includes(Q)):B;if(!Y.length){F.appendChild(W(this.doc,"p",{class:`${M.panel}__empty`,text:Q?this.t("panel.filterEmptyNoMatch",{query:this.query.trim()}):this.t("panel.filterEmptyNone")}));return}const J=W(this.doc,"div",{class:`${M.panel}__filters`});for(const te of Y)J.appendChild(this.buildSection(te));F.appendChild(J)}isFiltered(F){const C=this.host;return k(C.isFiltered)?C.isFiltered(F)===!0:!1}buildSearch(){const F=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"text",placeholder:this.t("panel.searchColumnsPlaceholder"),"aria-label":this.t("panel.searchColumnsToFilter")}});return F.value=this.query,this.off.push(Z(F,"input",()=>{this.query=F.value||"",this.refresh();const C=this.root&&this.root.querySelector?this.root.querySelector(`.${M.panel}__search`):null;C&&k(C.focus)&&C.focus()})),F}buildSummary(F,C){const B=W(this.doc,"div",{class:`${M.panel}__filterSummary`});if(B.appendChild(W(this.doc,"span",{class:`${M.panel}__filterCount`,text:F?this.t("panel.filterSummaryActive",{active:F,total:C}):this.t("panel.filterSummaryNone",{total:C}),attrs:{"data-active":F?"true":"false"}})),!F)return B;const q=W(this.doc,"button",{class:`${M.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(F){const C=F.id,B=String(F.title||C),q=this.isFiltered(C),Q=this.open.has(C),Y=W(this.doc,"section",{class:`${M.panel}__filter`,attrs:{"data-col":C,"data-filtered":q?"true":null}}),J=W(this.doc,"button",{class:`${M.panel}__filterTitle`,attrs:{type:"button","aria-expanded":Q?"true":"false",title:this.t(q?"panel.filteredBy":"panel.filterBy",{column:B})},children:[d(this.doc,Q?"chevronDown":"chevronRight",{className:`${M.panel}__twisty`}),W(this.doc,"span",{class:`${M.panel}__filterName`,text:B})]});q&&J.appendChild(W(this.doc,"span",{class:`${M.panel}__filterDot`,attrs:{"aria-label":this.t("panel.columnFiltered"),title:this.t("panel.columnFiltered")}}));const te=W(this.doc,"div",{class:`${M.panel}__filterBody`,style:{display:Q?"":"none"}}),ee=()=>{if(te.firstChild)return;const re=this.host.filterFor(C);re&&k(re.element)&&te.appendChild(re.element())};if(this.off.push(Z(J,"click",()=>{const re=this.open.has(C);re?this.open.delete(C):this.open.add(C),J.setAttribute("aria-expanded",re?"false":"true"),te.style.display=re?"none":"";const se=J.firstElementChild;se&&u(se,re?"chevronRight":"chevronDown"),re||ee()})),Y.appendChild(J),q){const re=W(this.doc,"button",{class:`${M.panel}__filterClear`,attrs:{type:"button","aria-label":this.t("panel.clearFilterOn",{column:B}),title:this.t("panel.clearFilter")},children:[d(this.doc,"close",{className:M.icon})]});this.off.push(Z(re,"click",se=>{k(se.stopPropagation)&&se.stopPropagation(),k(this.host.clearFilter)&&this.host.clearFilter(C),this.refresh()})),Y.appendChild(re)}return Y.appendChild(te),Q&&ee(),Y}}class O extends v{refresh(){const F=this.root;if(!F)return;if(this.box){const Q=k(this.host.quickFilter)?this.host.quickFilter():"";this.doc&&this.doc.activeElement!==this.box&&this.box.value!==Q&&(this.box.value=Q),this.paintCount();return}for(const Q of this.off)Q();this.off.length=0,V(F);const C=k(this.host.quickFilter)?this.host.quickFilter():"",B=W(this.doc,"input",{class:`${M.panel}__search`,attrs:{type:"search",placeholder:this.t("panel.filterAllColumns"),"aria-label":this.t("panel.quickFilter")}});B.value=C||"",this.off.push(Z(B,"input",()=>{k(this.host.setQuickFilter)&&this.host.setQuickFilter(B.value),this.paintCount()})),F.appendChild(B),this.box=B;const q=W(this.doc,"button",{class:`${M.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()})),F.appendChild(q),this.count=W(this.doc,"p",{class:`${M.panel}__count`}),F.appendChild(this.count),this.paintCount()}destroy(){this.box=null,this.count=null,super.destroy()}focus(){S(()=>{this.box&&k(this.box.focus)&&this.box.focus()})}paintCount(){if(!this.count)return;const F=k(this.host.rowCount)?this.host.rowCount():null,C=k(this.host.totalRowCount)?this.host.totalRowCount():null;if(F===null||C===null){this.count.textContent="";return}this.count.textContent=F===C?this.t("count.rows",{count:C}):this.t("panel.rowsOf",{shown:F,total:C})}}const T=Object.freeze({columns:j,filters:E,views:i,quick:O,formatting:r,statistics:l,regression:p,compare:b,insights:f}),A=Object.freeze({columns:"panel.columns",filters:"panel.filters",views:"panel.views",quick:"panel.quickFilter",formatting:"panel.formatting",statistics:"panel.statistics",regression:"panel.regression",compare:"panel.compare",insights:"panel.insights"}),P=Object.freeze({columns:"columns",filters:"filter",views:"views",quick:"search",formatting:"palette",statistics:"chart",regression:"chart",compare:"link",insights:"chart"});class L{panels=[];actions=[];root=null;openPanel=null;off=[];t(F,C){return(this.messages&&typeof this.messages.t=="function"?this.messages:D).t(F,C)}init(F){const C=F||{};this.doc=R(C),this.host=C.host||{},this.messages=C.messages||C.grid&&C.grid.messages||D,this.icons=C.icons===void 0?C.side==="left":!!C.icons,this.side=C.side==="left"?"left":"right",this.root=W(this.doc,"div",{class:[M.panel,`${M.panel}--${this.side}`,this.icons?`${M.panel}--icons`:null]}),this.tabs=W(this.doc,"div",{class:`${M.panel}__tabs`,attrs:{role:"tablist"}}),this.body=W(this.doc,"div",{class:`${M.panel}__content`}),this.side==="left"?(this.root.appendChild(this.tabs),this.root.appendChild(this.body)):(this.root.appendChild(this.body),this.root.appendChild(this.tabs)),this.actionGroup=W(this.doc,"div",{class:`${M.panel}__actions`,attrs:{role:"group","aria-label":this.t("panel.gridActions")}}),this.tabs.appendChild(this.actionGroup);for(const Q of Array.isArray(C.actions)?C.actions:[])this.registerAction(Q);const B=C.registry||{},q=Array.isArray(C.panels)&&C.panels.length?C.panels:["columns","filters"];for(const Q of q){const Y=typeof Q=="string"?Q:Q.name,J=typeof Q=="function"?Q:B[Y]||T[Y];J&&this.registerPanel(String(Y),J,typeof Q=="object"?Q:{})}C.openPanel&&this.show(C.openPanel)}registerPanel(F,C,B){const q=new C;q.init({document:this.doc,host:this.host,props:B&&B.props||{}});const Q=B&&B.title||F,Y=B&&B.icon||F,J=W(this.doc,"button",{class:`${M.panel}__tab`,text:this.icons?null:Q,attrs:{type:"button",role:"tab","aria-selected":"false","data-panel":F,title:this.icons?Q:null,"aria-label":this.icons?Q:null}});return this.icons&&J.appendChild(d(this.doc,Y,{className:`${M.panel}__icon`})),this.off.push(Z(J,"click",()=>this.toggle(F))),this.tabs.appendChild(J),this.panels.push({name:F,title:Q,panel:q}),q}registerAction(F){if(!F||!F.name)return null;if(F.separator)return this.actionGroup.appendChild(W(this.doc,"div",{class:`${M.panel}__divider`,attrs:{"aria-hidden":"true"}})),null;const C=W(this.doc,"button",{class:`${M.panel}__action`,text:this.icons?null:k(F.title)?String(F.title()):F.title,attrs:{type:"button","data-action":F.name,title:k(F.title)?null:F.title,"aria-label":k(F.title)?null:F.title}});if(this.icons){const Q=(k(F.icon)?F.icon():F.icon)||(n(F.name)?F.name:"blank");C.appendChild(d(this.doc,Q,{className:`${M.panel}__icon`})),C.setAttribute("data-icon",Q)}const B=Z(C,"click",()=>{k(F.enabled)&&!F.enabled()||(k(F.run)&&F.run(),this.paintActions())});return this.off.push(B),this.actionGroup.appendChild(C),this.actions.push({...F,button:C,offClick:B}),this.paintActions(),C}removeAction(F){const C=this.actions.findIndex(q=>q.name===F);if(C<0)return!1;const B=this.actions[C];return k(B.offClick)&&B.offClick(),B.button&&B.button.parentNode&&B.button.parentNode.removeChild(B.button),this.actions.splice(C,1),!0}paintActions(){for(const F of this.actions){if(!F.button)continue;const C=k(F.enabled)?!!F.enabled():!0;if(F.button.disabled=!C,F.button.setAttribute("aria-disabled",C?"false":"true"),k(F.active)&&F.button.setAttribute("aria-pressed",F.active()?"true":"false"),k(F.title)){const B=String(F.title());F.button.setAttribute("title",B),F.button.setAttribute("aria-label",B),!this.icons&&F.button.textContent!==B&&(F.button.textContent=B)}if(this.icons&&k(F.icon)){const B=String(F.icon());F.button.getAttribute("data-icon")!==B&&(V(F.button),F.button.appendChild(d(this.doc,B,{className:`${M.panel}__icon`})),F.button.setAttribute("data-icon",B))}}}show(F){const C=this.panels.find(B=>B.name===F);return C?(V(this.body),k(C.panel.refresh)&&C.panel.refresh(),this.body.appendChild(C.panel.element()),this.openPanel=F,this.paintTabs(),k(C.panel.focus)&&C.panel.focus(),!0):!1}hide(){V(this.body),this.openPanel=null,this.paintTabs()}toggle(F){this.openPanel===F?this.hide():this.show(F)}paintTabs(){if(!(!this.tabs||!this.tabs.childNodes))for(let F=0;F<this.tabs.childNodes.length;F++){const C=this.tabs.childNodes[F];C&&C.setAttribute&&C.setAttribute("aria-selected",C.getAttribute("data-panel")===this.openPanel?"true":"false")}}element(){return this.root}refresh(){const F=this.panels.find(C=>C.name===this.openPanel);F&&k(F.panel.refresh)&&!this.#e(F.panel)&&F.panel.refresh(),this.paintActions()}#e(F){const C=this.doc&&this.doc.activeElement;if(!C||C===this.doc.body)return!1;const B=k(F.element)?F.element():null;return!!(B&&k(B.contains)&&B.contains(C))}destroy(){for(const F of this.off)F();this.off.length=0;for(const F of this.panels)k(F.panel.destroy)&&F.panel.destroy();this.panels=[],this.root=null}}const z=L;function H(x,F){if(!F.getBoundingClientRect||typeof x.clientY!="number")return!0;const C=F.getBoundingClientRect();return x.clientY<C.top+C.height/2}}),Ce("packages/dom/src/ui/groupbyzone.js",function(e,G){"use strict";Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return S}});const M=G("packages/dom/src/ui/panelbase.js").ToolPanelBase,$=G("packages/dom/src/editors/common.js"),R=$.CLS,W=$.el,Z=$.on,V=$.clear,U=$.cssEscape,I=G("packages/core/src/internal/util.js").isFunction,k="text/x-lattice-col";class S extends M{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:R.groupZone,attrs:{role:"group","aria-label":this.t("groupZone.label")}}),this.refresh()}columns(){const d=this.host;return I(d.columns)?d.columns()||[]:d.columns&&I(d.columns.all)?d.columns.all():[]}groups(){return I(this.host.groupBy)?this.host.groupBy()||[]:[]}setGroups(d){I(this.host.setGroupBy)&&this.host.setGroupBy(d)}titleOf(d){const u=this.columns().find(n=>n.id===d);return String(u&&(u.title||u.id)||d)}canGroup(d){const u=this.columns().find(n=>n.id===d);return!!u&&u.allowGroup!==!1&&!u.generated}announce(d,u){I(this.host.announce)&&this.host.announce(d,u)}refresh(){const d=this.root;if(!d)return;for(const t of this.off)t();this.off.length=0,V(d),d.appendChild(W(this.doc,"span",{class:R.groupZoneTitle,text:this.t("groupZone.title"),attrs:{"aria-hidden":"true"}}));const u=this.groups(),n=W(this.doc,"div",{class:R.groupZoneChips,attrs:{role:"listbox","aria-orientation":"horizontal","aria-label":this.t("groupZone.label")}});u.length||n.appendChild(W(this.doc,"span",{class:R.groupZoneHint,text:this.t("groupZone.hint")})),u.forEach((t,i)=>n.appendChild(this.#t(t,i,u.length))),d.appendChild(n),this.chips=n,d.appendChild(this.#i(u)),this.off.push(Z(d,"dragover",t=>{this.dragging==null&&!this.#l(t)||(I(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=>{I(t.preventDefault)&&t.preventDefault(),d.removeAttribute("data-over");const i=this.#l(t)||this.dragging;i!=null&&this.#o(i,this.groups().length)})),this.#s()}#t(d,u,n){const t=this.titleOf(d),i=W(this.doc,"div",{class:[R.chip,R.groupZoneChip],attrs:{role:"option","aria-selected":"true",tabindex:"0",draggable:"true","data-col":d,"aria-label":this.t("groupZone.chip",{column:t,at:u+1,of:n})}});i.appendChild(W(this.doc,"span",{class:R.groupZoneChipText,text:t}));const s=W(this.doc,"button",{class:R.chipRemove,text:"×",attrs:{type:"button",tabindex:"-1","aria-label":this.t("groupZone.remove",{column:t})}});return this.off.push(Z(s,"click",()=>this.#r(d))),i.appendChild(s),this.off.push(Z(i,"dragstart",r=>{this.dragging=d,r.dataTransfer&&I(r.dataTransfer.setData)&&r.dataTransfer.setData(k,d)})),this.off.push(Z(i,"dragend",()=>{this.dragging=null})),this.off.push(Z(i,"dragover",r=>{const o=this.#l(r)||this.dragging;o==null||o===d||I(r.preventDefault)&&r.preventDefault()})),this.off.push(Z(i,"drop",r=>{const o=this.#l(r)||this.dragging;o!=null&&(I(r.preventDefault)&&r.preventDefault(),I(r.stopPropagation)&&r.stopPropagation(),this.#o(o,u))})),this.off.push(Z(i,"keydown",r=>this.#n(r,d,u))),i}#n(d,u,n){const t=d&&d.key,i=this.groups();if(t==="Delete"||t==="Backspace"){I(d.preventDefault)&&d.preventDefault(),this.#r(u,i,n);return}const s=t==="ArrowLeft"||t==="ArrowUp",r=t==="ArrowRight"||t==="ArrowDown",o=t==="Home",l=t==="End";if(!s&&!r&&!o&&!l)return;if(I(d.preventDefault)&&d.preventDefault(),d.shiftKey&&(s||r)){const m=n+(s?-1:1);if(m<0||m>=i.length){this.announce(this.t(s?"a11y.panel.alreadyFirst":"a11y.panel.alreadyLast",{column:this.titleOf(u)}),{repeat:!0});return}const b=i.slice();b.splice(n,1),b.splice(m,0,u),this.setGroups(b),this.announce(this.t("a11y.panel.moved",{column:this.titleOf(u),at:m+1,of:b.length}),{repeat:!0}),this.#a(u);return}let a=n+(s?-1:r?1:0);o&&(a=0),l&&(a=i.length-1);const p=i[a];p&&this.#a(p)}#r(d,u=this.groups(),n=u.indexOf(d)){const t=this.titleOf(d);this.setGroups(u.filter(s=>s!==d)),this.announce(this.t("a11y.panel.removedFrom",{column:t,list:this.t("panel.zone.group")}),{repeat:!0});const i=this.groups();i.length?this.#a(i[Math.min(n,i.length-1)]):this.#u()}#o(d,u){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 n=this.groups(),t=n.indexOf(d),i=n.slice();t>=0&&(i.splice(t,1),t<u&&(u-=1)),i.splice(Math.max(0,Math.min(u,i.length)),0,d),this.setGroups(i);const s=i.indexOf(d);this.announce(this.t(t>=0?"a11y.panel.moved":"a11y.panel.addedTo",t>=0?{column:this.titleOf(d),at:s+1,of:i.length}:{column:this.titleOf(d),list:this.t("panel.zone.group")}),{repeat:!0}),this.#a(d)}#i(d){const u=new Set(d),n=W(this.doc,"label",{class:R.groupZoneAdd}),t=W(this.doc,"select",{class:R.groupZoneAddSelect,attrs:{"aria-label":this.t("groupZone.add")}});t.appendChild(W(this.doc,"option",{text:this.t("groupZone.add"),attrs:{value:""}}));for(const i of this.columns())u.has(i.id)||!this.canGroup(i.id)||t.appendChild(W(this.doc,"option",{text:this.titleOf(i.id),attrs:{value:i.id}}));return this.off.push(Z(t,"change",()=>{const i=t.value;i&&this.#o(i,this.groups().length)})),this.adderSelect=t,n.appendChild(t),n}#s(){for(const u of this.#e)u();this.#e.length=0;const d=this.props&&this.props.header;if(!(!d||!I(d.querySelectorAll)))for(const u of d.querySelectorAll("[data-col]")){const n=I(u.getAttribute)?u.getAttribute("data-col"):null;!n||!this.canGroup(n)||(I(u.setAttribute)&&u.setAttribute("draggable","true"),this.#e.push(Z(u,"dragstart",t=>{this.dragging=n,t.dataTransfer&&I(t.dataTransfer.setData)&&t.dataTransfer.setData(k,n)})),this.#e.push(Z(u,"dragend",()=>{this.dragging=null})))}}#l(d){const u=d&&d.dataTransfer;if(u&&I(u.getData)){const n=u.getData(k);if(n)return n}return null}#a(d){const u=this.chips&&I(this.chips.querySelector)?this.chips.querySelector(`[data-col="${U(d)}"]`):null;u&&I(u.focus)&&u.focus()}#u(){this.adderSelect&&I(this.adderSelect.focus)&&this.adderSelect.focus()}destroy(){for(const d of this.#e)d();this.#e.length=0,super.destroy()}}}),Ce("packages/dom/src/ui/tooltip.js",function(e,G){"use strict";Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.documentFor,R=_.el,W=_.on,Z=_.clear,U=G("packages/core/src/internal/util.js").isFunction;class D{root=null;init(y){this.doc=y.document,this.root=R(this.doc,"div",{class:`${M.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 I{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:D,...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",u=typeof d=="function"?d:this.components[d]||D;return this.root||(this.root=R(this.doc,"div",{class:M.tooltip,attrs:{role:"tooltip"},style:{position:"absolute"}}),this.host.appendChild(this.root)),!this.component||this.componentCtor!==u?(this.component&&U(this.component.destroy)&&this.component.destroy(),Z(this.root),this.component=new u,this.componentCtor=u,this.component.init({document:this.doc,content:y.content,...y.props||{}}),this.root.appendChild(this.component.element())):U(this.component.update)&&this.component.update(y.content),this.target=y.target||null,this.position(),this.root.setAttribute("data-open","true"),this.root}position(){if(!this.root||!this.target||!U(this.target.getBoundingClientRect))return;const y=this.target.getBoundingClientRect(),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,u){const n=()=>this.show({target:y,content:d(),...u||{}}),t=()=>this.hide(),i=[W(y,"mouseenter",n),W(y,"mouseleave",t),W(y,"focus",n),W(y,"blur",t)],s=()=>{for(const r of i)r()};return this.off.push(s),s}destroy(){this.hide();for(const y of this.off)y();this.off.length=0,this.component&&U(this.component.destroy)&&this.component.destroy(),this.component=null,this.root=null}}const k=I}),Ce("packages/dom/src/ui/pagination.js",function(e,G){"use strict";Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.documentFor,R=_.el,W=_.on,Z=_.clear,U=G("packages/core/src/i18n/index.js").defaultMessages,I=G("packages/core/src/internal/util.js").isFunction;function k(d){const u=Math.max(1,Number(d.pageSize)||100),n=d.total==null?null:Math.max(0,Number(d.total)),t=n==null?null:Math.max(1,Math.ceil(n/u)),i=Math.max(0,t==null?Number(d.page)||0:Math.min(Number(d.page)||0,t-1)),s=n===0?0:i*u+1,r=n==null?(i+1)*u:Math.min(n,(i+1)*u);return{page:i,pageSize:u,pageCount:t,from:s,to:r,first:i===0,last:t==null?d.hasMore!==!0:i>=t-1,total:n}}class S{root=null;page=0;pageSize=100;total=null;counting=!1;hasMore=!1;off=[];init(u){const n=u||{};this.doc=$(n),this.host=n.host||{},this.pageSize=Number(n.pageSize)||100;const t=Array.isArray(n.pageSizes)&&n.pageSizes.length?[...n.pageSizes]:[25,50,100,250,1e3];this.pageSize>0&&!t.includes(this.pageSize)&&t.push(this.pageSize),this.pageSizes=t.sort((i,s)=>i-s),this.page=Number(n.page)||0,this.total=n.total===void 0?null:n.total,this.locale=n.locale,this.messages=n.messages||null,this.onChange=n.onChange||null,this.root=R(this.doc,"nav",{class:M.pagination,attrs:{"aria-label":this.t("pagination.label")}}),this.paint()}t(u,n){const t=this.messages;return(t&&typeof t.t=="function"?t:U).t(u,n)}element(){return this.root}model(){return k({total:this.total,pageSize:this.pageSize,page:this.page,hasMore:this.hasMore})}setState(u){u.total!==void 0&&(this.total=u.total),u.counting!==void 0&&(this.counting=u.counting===!0),u.hasMore!==void 0&&(this.hasMore=u.hasMore===!0),u.page!==void 0&&(this.page=Number(u.page)||0),this.paint()}goTo(u){const n=this.page;this.page=u;const t=this.model();return this.page=t.page,this.paint(),this.page!==n&&I(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize}),this.page}next(){return this.model().last?this.page:this.goTo(this.page+1)}previous(){return this.page===0?0:this.goTo(this.page-1)}last(){const u=this.model();return u.pageCount==null?this.page:this.goTo(u.pageCount-1)}setPageSize(u){const n=this.page*this.pageSize;this.pageSize=Math.max(1,Number(u)||1),this.page=Math.floor(n/this.pageSize),this.paint(),I(this.onChange)&&this.onChange({page:this.page,pageSize:this.pageSize})}paint(){const u=this.root;if(!u)return;for(const a of this.off)a();this.off.length=0,Z(u);const n=this.model(),t=R(this.doc,"select",{class:`${M.pagination}__size`,attrs:{"aria-label":this.t("pagination.pageSize")}});for(const a of this.pageSizes)t.appendChild(R(this.doc,"option",{text:String(a),attrs:{value:a}}));t.value=String(this.pageSize),this.off.push(W(t,"change",()=>this.setPageSize(Number(t.value)))),u.appendChild(t);const i=n.total==null?this.t(this.counting?"pagination.counting":"pagination.range",{from:n.from,to:n.to}):this.t("pagination.summary",{from:n.from,to:n.to,total:n.total});u.appendChild(R(this.doc,"span",{class:`${M.pagination}__summary`,text:i}));const s=(a,p,m,b)=>{const g=R(this.doc,"button",{class:`${M.pagination}__button`,text:a,attrs:{type:"button","aria-label":b,disabled:m?"":null}});return m||this.off.push(W(g,"click",p)),g};u.appendChild(s("«",()=>this.goTo(0),n.first,this.t("pagination.first"))),u.appendChild(s("‹",()=>this.previous(),n.first,this.t("pagination.previous")));const r=R(this.doc,"span",{class:`${M.pagination}__page`});r.appendChild(R(this.doc,"span",{text:`${this.t("pagination.page")} `}));const o=R(this.doc,"input",{class:`${M.pagination}__field`,attrs:{type:"text",inputmode:"numeric","aria-label":n.pageCount==null?this.t("pagination.jump"):this.t("pagination.jumpBounded",{pages:n.pageCount}),size:String(Math.max(2,String(n.pageCount??n.page+1).length))}});o.value=String(n.page+1);const l=()=>{const a=parseInt(String(o.value).trim(),10);if(!Number.isFinite(a)){o.value=String(this.model().page+1);return}this.goTo(a-1)};this.off.push(W(o,"keydown",a=>{a.key==="Enter"?(l(),a.preventDefault?.()):a.key==="Escape"?(o.value=String(this.model().page+1),o.blur?.()):a.stopPropagation?.()})),this.off.push(W(o,"blur",()=>l())),this.off.push(W(o,"focus",()=>o.select?.())),r.appendChild(o),n.pageCount!=null&&r.appendChild(R(this.doc,"span",{text:` ${this.t("pagination.ofPages",{pages:n.pageCount})}`})),u.appendChild(r),u.appendChild(s("›",()=>this.next(),n.last,this.t("pagination.next"))),u.appendChild(s("»",()=>this.last(),n.last||n.pageCount==null,this.t("pagination.last")))}destroy(){for(const u of this.off)u();this.off.length=0,this.root=null}}const y=S}),Ce("packages/dom/src/ui/overlay.js",function(e,G){"use strict";Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const _=G("packages/dom/src/editors/common.js"),M=_.CLS,$=_.documentFor,R=_.el,W=_.clear,V=G("packages/core/src/internal/util.js").isFunction,D=G("packages/core/src/i18n/index.js").defaultMessages;function I(n,t){const i=n&&n.grid&&n.grid.messages;return(i&&V(i.t)?i:D).t(t)}class k{root=null;init(t){this.doc=t.document,this.root=R(this.doc,"div",{class:`${M.overlay}__loading`,attrs:{role:"status","aria-live":"polite"},children:[R(this.doc,"span",{class:`${M.overlay}__spinner`,attrs:{"aria-hidden":"true"}}),R(this.doc,"span",{class:`${M.overlay}__message`,text:t.message||I(t,"overlay.loading")})]})}element(){return this.root}destroy(){this.root=null}}class S{root=null;init(t){this.doc=t.document,this.root=R(this.doc,"div",{class:`${M.overlay}__empty`,attrs:{role:"status"},children:[R(this.doc,"span",{class:`${M.overlay}__message`,text:t.message||I(t,"overlay.noRows")})]})}element(){return this.root}destroy(){this.root=null}}const y=Object.freeze({loading:k,empty:S});class d{root=null;slot=null;component=null;current=null;init(t){const i=t||{};this.doc=$(i),this.components={...y,...i.components||{}},this.root=R(this.doc,"div",{class:M.overlay,attrs:{"data-open":"false"}}),this.slot=R(this.doc,"div",{class:`${M.overlay}__slot`}),this.root.appendChild(this.slot),i.host&&i.host.appendChild(this.root)}element(){return this.root}show(t,i){const s=typeof t=="function"?t:this.components[t];return s?(this.hide(),this.component=new s,this.component.init({document:this.doc,message:i&&i.message,...i&&i.props||{}}),this.slot.appendChild(this.component.element()),this.current=typeof t=="string"?t:"custom",this.root.setAttribute("data-open","true"),this.root.setAttribute("data-overlay",this.current),this.component.element()):null}hide(){this.component&&V(this.component.destroy)&&this.component.destroy(),this.component=null,this.current=null,this.slot&&W(this.slot),this.root&&(this.root.setAttribute("data-open","false"),this.root.removeAttribute("data-overlay"))}showing(){return this.current}register(t,i){this.components[t]=i}destroy(){this.hide(),this.root&&this.root.parentNode&&this.root.parentNode.removeChild(this.root),this.root=null,this.slot=null}}const u=d}),Ce("packages/dom/src/ui/index.js",function(e,G){"use strict";const _=G("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 M=G("packages/dom/src/ui/contextmenu.js");Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return M.ContextMenu}}),Object.defineProperty(e,"resolveMenuItems",{enumerable:!0,get:function(){return M.resolveMenuItems}});const $=G("packages/dom/src/ui/toolpanel.js");Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return $.ToolPanel}}),Object.defineProperty(e,"ToolPanelBase",{enumerable:!0,get:function(){return $.ToolPanelBase}}),Object.defineProperty(e,"ColumnsPanel",{enumerable:!0,get:function(){return $.ColumnsPanel}}),Object.defineProperty(e,"FiltersPanel",{enumerable:!0,get:function(){return $.FiltersPanel}}),Object.defineProperty(e,"toolPanels",{enumerable:!0,get:function(){return $.toolPanels}});const R=G("packages/dom/src/ui/groupbyzone.js");Object.defineProperty(e,"GroupByZone",{enumerable:!0,get:function(){return R.GroupByZone}});const W=G("packages/dom/src/ui/tooltip.js");Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return W.TooltipManager}}),Object.defineProperty(e,"TextTooltip",{enumerable:!0,get:function(){return W.TextTooltip}});const Z=G("packages/dom/src/ui/pagination.js");Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return Z.Pagination}}),Object.defineProperty(e,"pageModel",{enumerable:!0,get:function(){return Z.pageModel}});const V=G("packages/dom/src/ui/overlay.js");Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return V.OverlayLayer}}),Object.defineProperty(e,"LoadingOverlay",{enumerable:!0,get:function(){return V.LoadingOverlay}}),Object.defineProperty(e,"EmptyOverlay",{enumerable:!0,get:function(){return V.EmptyOverlay}}),Object.defineProperty(e,"overlays",{enumerable:!0,get:function(){return V.overlays}})}),Ce("packages/dom/src/ui/celltooltip.js",function(e,G){"use strict";Object.defineProperty(e,"CellTooltips",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return b}});const _=G("packages/dom/src/editors/common.js"),M=_.documentFor,$=_.el,R=_.on,W=_.clear,Z=G("packages/core/src/internal/util.js"),V=Z.isFunction,U=Z.warnOnce,I=G("packages/dom/src/cell/sanitise.js").sanitiseHtml,S=G("packages/dom/src/detailhost.js").insideDetail,d=G("packages/dom/src/renderer/renderer.js").displayIndexOf,u=G("packages/dom/src/renderer/viewport.js"),n=u.CLASS,t=u.NAMESPACE,s=G("packages/dom/src/themeof.js").carryTheme,r={tooltip:"lat-cell-tooltip",body:"lat-cell-tooltip__body",title:"lat-cell-tooltip__title",rows:"lat-cell-tooltip__rows",row:"lat-cell-tooltip__row",label:"lat-cell-tooltip__label",value:"lat-cell-tooltip__value",note:"lat-cell-tooltip__note"},o=400,l=140,a=6;let p=0;class m{#e;#t;#n;#r;#o=null;#i=null;#s;#l=!1;#a=null;#u=null;#c=null;#d=null;#h=null;#f=[];#m=!1;constructor(f){const w=f||{};this.#e=w.grid,this.#t=w.host,this.#n=w.viewport,this.#r=M(w),p+=1,this.#s=`lat-cell-tooltip-${p}`}mount(){const f=this.#n&&this.#n.root;if(!f||!V(f.addEventListener))return;const w=this.#e.on("cell:mouseover",c=>this.#b(c));V(w)&&this.#f.push(w);const v=this.#e.on("cell:mouseout",()=>this.#A());V(v)&&this.#f.push(v),this.#f.push(R(f,"focusin",c=>this.#v(c))),this.#f.push(R(f,"focusout",()=>this.#A())),this.#f.push(R(this.#r,"keydown",c=>this.#y(c),!0));const h=this.#r.defaultView;h&&V(h.addEventListener)&&this.#f.push(R(h,"scroll",()=>this.hide(),!0))}#p(){const f=V(this.#e.get)?this.#e.get("tooltip"):null,w=f&&typeof f=="object"?f:{},v=Number.isFinite(w.delay)&&w.delay>=0?Number(w.delay):o,h=w.maxWidth;return{delay:v,hideDelay:l,maxWidth:typeof h=="number"&&Number.isFinite(h)?`${h}px`:typeof h=="string"&&h?h:null}}#g(f){const w=f&&f.cell?f.cell.tooltip:null;return!w||typeof w!="object"||Array.isArray(w)||!V(w.render)&&!V(w.mount)?null:w}#w(f){if(!f||!V(f.closest))return null;const w=f.closest(`.${n.row}`);if(!w)return null;const v=d(w);if(v<0)return null;const h=this.#t.rowAt(v);if(!h)return null;const c=f.getAttribute("data-col");if(!c)return null;const j=this.#t.columns.get(c);return j?{row:h,key:h.key,index:v,colId:c,column:j,value:this.#t.cellValue?this.#t.cellValue(h,j):void 0,text:this.#t.cellText?this.#t.cellText(h,j):"",cell:f,grid:this.#e}:null}#b(f){const w=f&&f.target;if(!this.#g(f&&f.column)){this.#A();return}this.#S(w)}#v(f){const w=f&&f.target;if(!w||!V(w.closest)||S(w,this.#n.root))return;const v=w.closest(`.${n.cell}`);if(!v||v!==w){this.#A();return}const h=v.getAttribute("data-col"),c=h?this.#t.columns.get(h):null;if(!this.#g(c)){this.#A();return}this.#S(v)}#y(f){!f||f.key!=="Escape"||f.defaultPrevented||this.#l&&(V(f.preventDefault)&&f.preventDefault(),this.hide())}#S(f){if(this.#m||!f||(this.#I(),this.#l&&this.#a===f))return;this.#N();const{delay:w}=this.#p();if(!w){this.#C(f);return}this.#d=setTimeout(()=>{this.#d=null,this.#C(f)},w)}#A(){if(this.#N(),!this.#l||this.#h!==null)return;const{hideDelay:f}=this.#p();this.#h=setTimeout(()=>{this.#h=null,this.hide()},f)}#j(){if(this.#o)return this.#o;const f=this.#r,w=$(f,"div",{class:[t,r.tooltip],attrs:{id:this.#s,role:"tooltip","data-open":"false"}});this.#i=$(f,"div",{class:r.body}),w.appendChild(this.#i),this.#f.push(R(w,"mouseenter",()=>this.#I())),this.#f.push(R(w,"mouseleave",()=>this.#A()));const v=f.body;return v&&V(v.appendChild)&&v.appendChild(w),this.#o=w,w}#O(f,w){const v=this.#i;if(W(v),f==null||f==="")return!1;if(typeof f=="string")return v.textContent=f,!0;if(typeof f=="object"){if(typeof f.nodeType=="number")return v.appendChild(f),!0;const h=f;if(typeof h.html=="string")return v.innerHTML=I(h.html),!0;if(h.title!==void 0||h.rows!==void 0||h.note!==void 0)return this.#E(h),!0}return U(`tooltip-content:${w}`,`Column '${w}' cell.tooltip render returned a value that is not an element, a { title, rows, note } spec, a { html } wrapper or a string, so nothing was shown.`),!1}#E(f){const w=this.#r,v=this.#i,h=j=>j==null?"":String(j);f.title!==void 0&&f.title!==null&&f.title!==""&&v.appendChild($(w,"div",{class:r.title,text:h(f.title)}));const c=Array.isArray(f.rows)?f.rows:[];if(c.length){const j=$(w,"div",{class:r.rows});for(const E of c){if(!E||typeof E!="object")continue;const O=$(w,"div",{class:r.row});O.appendChild($(w,"span",{class:r.label,text:h(E.label)})),O.appendChild($(w,"span",{class:r.value,text:h(E.value)})),j.appendChild(O)}v.appendChild(j)}f.note!==void 0&&f.note!==null&&f.note!==""&&v.appendChild($(w,"div",{class:r.note,text:h(f.note)}))}#C(f){if(this.#m)return;const w=this.#w(f);if(!w){this.hide();return}const v=this.#g(w.column);if(!v){this.hide();return}this.hide();const h=this.#j();s(h,this.#n&&this.#n.root);let c;if(V(v.render))try{c=v.render(w)}catch(O){U(`tooltip-render:${w.colId}`,`Column '${w.colId}' cell.tooltip render threw; no tooltip was shown.`,O);return}const j=this.#O(c,w.colId);if(V(v.mount))try{v.mount(this.#i,w),this.#u=v}catch(O){U(`tooltip-mount:${w.colId}`,`Column '${w.colId}' cell.tooltip mount threw; the tooltip was closed.`,O),this.hide();return}else if(!j)return;const{maxWidth:E}=this.#p();E&&(h.style.maxWidth=E),this.#a=f,this.#l=!0,h.setAttribute("data-open","true"),this.#T(f),this.#D(f)}#T(f){if(!V(f.setAttribute))return;const w=V(f.getAttribute)?f.getAttribute("aria-describedby"):null;this.#c={cell:f,previous:w},f.setAttribute("aria-describedby",w?`${w} ${this.#s}`:this.#s)}#D(f){const w=this.#o;if(!w||!V(f.getBoundingClientRect))return;const v=this.#r.defaultView;if(!v)return;const h=f.getBoundingClientRect(),c=V(w.getBoundingClientRect)?w.getBoundingClientRect():{width:0,height:0},j=v.innerWidth||0,E=v.innerHeight||0,O=c.width||0,T=c.height||0;let A=h.bottom+a;const P=h.top-a-T;A+T>E-a&&P>=a&&(A=P),E&&(A=Math.max(a,Math.min(A,Math.max(a,E-T-a))));let L=h.left;j&&(L=Math.min(L,Math.max(a,j-O-a))),L=Math.max(a,L),w.style.left=`${Math.round(L)}px`,w.style.top=`${Math.round(A)}px`}hide(){if(this.#N(),this.#I(),!this.#l)return;if(this.#l=!1,this.#u&&V(this.#u.unmount))try{this.#u.unmount(this.#i)}catch(w){U("tooltip-unmount","A cell.tooltip unmount threw while the tooltip was closing.",w)}this.#u=null,this.#i&&W(this.#i),this.#o&&this.#o.setAttribute("data-open","false");const f=this.#c;f&&V(f.cell.setAttribute)&&(f.previous?f.cell.setAttribute("aria-describedby",f.previous):V(f.cell.removeAttribute)&&f.cell.removeAttribute("aria-describedby")),this.#c=null,this.#a=null}#N(){this.#d!==null&&(clearTimeout(this.#d),this.#d=null)}#I(){this.#h!==null&&(clearTimeout(this.#h),this.#h=null)}destroy(){this.hide(),this.#m=!0;for(const f of this.#f)f();this.#f.length=0,this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}const b=m}),Ce("packages/dom/src/platform.js",function(e,G){"use strict";Object.defineProperty(e,"macLike",{enumerable:!0,get:function(){return _}});function _(){const M=globalThis.navigator,$=String(M&&(M.userAgentData?.platform||M.platform)||"");return/mac|iphone|ipad/i.test($)}}),Ce("packages/dom/src/columnmenu.js",function(e,G){"use strict";Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"aggregateMenuItem",{enumerable:!0,get:function(){return n}}),Object.defineProperty(e,"headerMenuItems",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"gridAcceptsEdits",{enumerable:!0,get:function(){return o}}),Object.defineProperty(e,"columnAcceptsEdits",{enumerable:!0,get:function(){return l}}),Object.defineProperty(e,"rangeChartConfig",{enumerable:!0,get:function(){return p}}),Object.defineProperty(e,"chartableRange",{enumerable:!0,get:function(){return m}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"applyMenuLayer",{enumerable:!0,get:function(){return g}}),Object.defineProperty(e,"resolveMenuChain",{enumerable:!0,get:function(){return f}}),Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return w}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/dom/src/platform.js").macLike,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/dom/src/ui/contextmenu.js").ContextMenu,I=G("packages/core/src/compute/total.js"),k=I.aggregatesFor,S=I.totalLabel,y=10,d=150;function u(v,h){const c=(te,ee)=>(v&&v.messages?v.messages:V).t(te,ee),j=v.columns.get(h);if(!j)return[];const E=v.sort.get(),O=E.find(te=>te.col===h),T=j.layout&&j.layout.pin,A=v.state.get().group||[],P=A.includes(h);if(j.generated&&Array.isArray(j.groupedIds))return s(v,j,A);const L=!j.sort||j.sort.enabled!==!1,z=!j.filter||j.filter.enabled!==!1,H=[];L&&H.push({name:c("menu.sortAscending"),icon:"↑",disabled:O&&O.dir==="asc",action:()=>v.sort.set([{col:h,dir:"asc"}])},{name:c("menu.sortDescending"),icon:"↓",disabled:O&&O.dir==="desc",action:()=>v.sort.set([{col:h,dir:"desc"}])},{name:c("menu.clearSort"),disabled:!O,action:()=>v.sort.set(E.filter(te=>te.col!==h))},{separator:!0}),z&&H.push({name:c("menu.filterEllipsis"),action:()=>v.emit("column:filter:open",{colId:h})},{separator:!0}),H.push({name:c("menu.columnStatistics"),action:()=>v.emit("column:profile:open",{colId:h})},{separator:!0}),H.push({name:c("menu.pinColumn"),children:[{name:c("menu.pinStart"),disabled:T==="start",action:()=>v.columns.pin(h,"start")},{name:c("menu.pinEnd"),disabled:T==="end",action:()=>v.columns.pin(h,"end")},{name:c("menu.unpin"),disabled:!T,action:()=>v.columns.pin(h,null)}]});const x=!(j.layout&&(j.layout.movable===!1||j.layout.lockPosition)),F=!(j.layout&&j.layout.resizable===!1),C=te=>{const ee=v.columns.get(te);return Number(ee&&ee.layout&&ee.layout.width)||d},B=v.columns.visible().filter(te=>!te.generated).map(te=>te.id),q=B.indexOf(h);if(H.push({name:c("menu.sizeToFit"),action:()=>v.columns.autoSize(h)},{name:c("menu.sizeAllToFit"),action:()=>v.columns.fit()},{name:c("menu.width"),disabled:!F,children:[{name:c("menu.narrower"),disabled:!F,action:()=>v.columns.resize(h,Math.max(1,C(h)-y))},{name:c("menu.wider"),disabled:!F,action:()=>v.columns.resize(h,C(h)+y)},{name:c("menu.autosize"),disabled:!F,action:()=>v.columns.autoSize(h)}]},{separator:!0},{name:c("menu.moveColumn"),disabled:!x,children:[{name:c("menu.moveLeft"),disabled:!x||q<=0,action:()=>v.columns.move(h,Math.max(0,q-1))},{name:c("menu.moveRight"),disabled:!x||q<0||q>=B.length-1,action:()=>v.columns.move(h,Math.min(B.length-1,q+1))},{name:c("menu.moveToStart"),disabled:!x||q<=0,action:()=>v.columns.move(h,0)},{name:c("menu.moveToEnd"),disabled:!x||q<0||q>=B.length-1,action:()=>v.columns.move(h,B.length-1)}]},{separator:!0}),j.allowGroup!==!1&&H.push({name:c(P?"menu.ungroup":"menu.groupBy"),action:()=>v.columns.group(P?A.filter(te=>te!==h):[...A,h])}),A.length&&H.push({name:c("menu.expandAll"),action:()=>v.rows.expandAll()},{name:c("menu.collapseAll"),action:()=>v.rows.collapseAll()}),M(v.columns.groupColumns)){const te=j.groupPath||[],ee=te.length?te[te.length-1]:null,re=[{name:c("columngroup.group"),disabled:B.length<2||q<0,action:()=>{const se=B[q+1]??B[q-1];if(!se)return;const de=(v.columns.get(se)||{}).groupPath||[],ie=de.length?de[de.length-1]:null;ie?v.columns.groupColumns([h],{groupId:ie}):v.columns.groupColumns([h,se],{title:c("columngroup.newGroup")})}}];ee&&re.push({name:c("columngroup.dissolve"),action:()=>v.columns.dissolveGroup(ee)}),H.push({separator:!0},...re)}const Q=v.state&&M(v.state.get)?v.state.get().pivot:null,Y=Q&&Q.columns||[],J=Y.includes(h);if(j.allowPivot!==!1&&H.push({name:c(J?"menu.unpivot":"menu.pivotBy"),action:()=>v.columns.pivot(J?Y.filter(te=>te!==h):[...Y,h])}),j.allowTotal!==!1)if(M(v.get)&&v.get("aggregateChooser")===!0)H.push(n(v,j,c));else{const ee=!!j.total;H.push({name:c(ee?"menu.stopTotalling":"menu.totalColumn"),action:()=>v.columns.setTotal(h,ee?null:"sum")})}return H.push({name:c("menu.hideColumn"),disabled:j.layout&&j.layout.lockVisible===!0,action:()=>v.columns.hide(h)}),H}function n(v,h,c){const j=h.id,E=typeof h.total=="string"?h.total:null,O=[{name:c("menu.aggregateNone"),checked:!h.total,action:()=>v.columns.setTotal(j,null)},{separator:!0},...k(h).map(T=>({name:S(T),checked:E===T,action:()=>v.columns.setTotal(j,T)})),{separator:!0},t(v,h,c,"group",c("menu.aggregateGroup")),t(v,h,c,"grand",c("menu.aggregateGrand"))];return{name:c("menu.aggregate"),children:O}}function t(v,h,c,j,E){const O=h.id,T=j==="grand"?h.grandTotal:h.groupTotal,A=typeof T=="string"?T:null,P=[{name:c("menu.aggregateSame"),checked:T==null,action:()=>v.columns.setTotal(O,null,{scope:j})},{separator:!0},...k(h).map(L=>({name:S(L),checked:A===L,action:()=>v.columns.setTotal(O,L,{scope:j})}))];return{name:E,children:P}}function i(v,h){const c=(A,P)=>(v&&v.messages?v.messages:V).t(A,P),j=v.columns.get(h);if(!j)return[];const E=v.redaction,O=!!(E&&E.has(h)),T=[];return E&&(T.push({name:c(O?"menu.stopRedacting":"menu.redactColumn"),action:()=>E.toggle(h)}),(E.list().length>1||E.active&&!O)&&T.push({name:c("menu.stopRedactingAll"),action:()=>E.clear()}),T.push({separator:!0})),T.push({name:c("menu.hideColumn"),disabled:j.layout&&j.layout.lockVisible===!0,action:()=>v.columns.hide(h)}),T}function s(v,h,c){const j=(P,L)=>(v&&v.messages?v.messages:V).t(P,L),E=c[0],O=v.sort.get(),T=E?O.find(P=>P.col===E):null,A=[];E&&A.push({name:j("menu.sortGroupsAscending"),icon:"↑",disabled:T&&T.dir==="asc",action:()=>v.sort.set([{col:E,dir:"asc"}])},{name:j("menu.sortGroupsDescending"),icon:"↓",disabled:T&&T.dir==="desc",action:()=>v.sort.set([{col:E,dir:"desc"}])},{separator:!0},{name:j("menu.filterGroups"),action:()=>v.emit("column:filter:open",{colId:h.id})},{separator:!0}),A.push({name:j("menu.expandAll"),action:()=>v.rows.expandAll()},{name:j("menu.collapseAll"),action:()=>v.rows.collapseAll()},{separator:!0});for(const P of c){const L=v.columns.get(P);A.push({name:`Remove "${L&&L.title||P}" from grouping`,action:()=>v.columns.group(c.filter(z=>z!==P))})}return A.push({name:j("menu.clearGrouping"),disabled:!c.length,action:()=>v.columns.group([])}),A}function r(){const v=globalThis.navigator&&globalThis.navigator.clipboard;return!!(v&&typeof v.readText=="function")}function o(v){return M(v.get)&&v.get("edit")===!1?!1:(v.columns&&M(v.columns.visible)?v.columns.visible():[]).some(c=>{const j=c&&c.edit;return j?j.enabled===void 0||M(j.enabled)?!0:j.enabled!==!1:!1})}function l(v,h){if(M(v.get)&&v.get("edit")===!1)return!1;const c=h&&h.edit;return c?c.enabled===void 0||M(c.enabled)?!0:c.enabled!==!1:!1}const a=new Set(["number","currency","percent","integer"]);function p(v){const h=M(v.get)?v.get("rangeChart"):void 0;return h?M(h)?{enabled:!0,handler:h}:h&&typeof h=="object"&&M(h.onChart)?{enabled:!0,handler:h.onChart}:{enabled:!0,handler:null}:{enabled:!1,handler:null}}function m(v){const h=v.selection&&M(v.selection.ranges)?v.selection.ranges():[];if(!Array.isArray(h)||!h.length)return null;const c=h[h.length-1],j=M(v.columns.visible)?v.columns.visible():[],E=new Set(j.filter(O=>O&&a.has(O.type)).map(O=>O.id));return(c.columns||[]).some(O=>E.has(O))?c:null}function b(v,h){const c=(Y,J)=>(v&&v.messages?v.messages:V).t(Y,J),{colId:j,row:E}=h,O=v.selection.keys().length,T=v.selection.cells().length,A=(v.state&&M(v.state.get)?v.state.get().group:null)||[],P=v.ranges||null,L=W()?"Cmd":"Ctrl",z=()=>T||O||0,H=Y=>v.columns&&M(v.columns.get)?v.columns.get(Y):null,x=M(v.selection.cells)?v.selection.cells():[],F=[...new Set(x.map(Y=>Y&&Y.colId).filter(Boolean))];!F.length&&j&&F.push(j);const C=F.length?F.some(Y=>l(v,H(Y))):o(v),B=j?l(v,H(j)):!1,q=p(v),Q=q.enabled?m(v):null;return[{name:T>1?`Copy ${T} cells`:c("menu.copy"),shortcut:`${L}+C`,disabled:!z(),action:()=>P&&T?P.copy():v.export.clipboard({rows:O?"selected":"range"})},{name:c("menu.copyWithHeaders"),disabled:!z(),action:()=>v.export.clipboard({headers:!0,rows:O?"selected":"range"})},...j==null?[]:[{name:c("menu.paste"),shortcut:`${L}+V`,disabled:!P||!C||!r(),action:()=>P&&P.paste()},{separator:!0},{name:c("menu.clearCells",{count:T||1}),shortcut:"Delete",disabled:!P||!C||!T,action:()=>P&&P.clear()},{name:c("menu.fillDown"),shortcut:`${L}+D`,disabled:!P||!C||T<2,action:()=>P&&P.fillDown()}],...Q&&q.handler?[{name:"Chart selection",action:()=>q.handler(v,Q)}]:[],{separator:!0},{name:"Export visible rows to CSV",action:()=>v.export.csv({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to CSV`,disabled:!O,action:()=>v.export.csv({rows:"selected",download:!0})},{name:"Export visible rows to Excel",action:()=>v.export.excel({rows:"visible",download:!0})},{name:`Export ${O} selected row${O===1?"":"s"} to Excel`,disabled:!O,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&&M(v.importer.openFile)?[{name:c("menu.importCsv"),action:()=>v.importer.openFile()}]:[],{separator:!0},...A.length?[{name:c("menu.expandAll"),action:()=>v.rows.expandAll()},{name:c("menu.collapseAll"),action:()=>v.rows.collapseAll()}]:[],{name:"Clear selection",disabled:!O,action:()=>v.selection.clear()},...M(v.get)&&v.get("rowDelete")===!0?[{name:c("menu.deleteRow",{count:O||1}),disabled:!O&&!E,action:()=>v.edit.deleteRows(O?void 0:E?E.key:void 0)}]:[],...j==null?[]:[{name:"Edit cell",disabled:!E||!j||!B,action:()=>E&&j&&v.edit.start(E.key,j)}]]}function g(v,h,c,j){if(v==null)return{items:h,spoke:!1,suppress:!1};if(v===!1)return{items:h,spoke:!0,suppress:!0};if(v===!0)return{items:h,spoke:!0,suppress:!1};if(Array.isArray(v))return{items:[...h,...v],spoke:!0,suppress:!1};if(M(v)){const E=v(c,h);return{items:Array.isArray(E)?E:h,spoke:!0,suppress:!1}}return $(`menu-layer:${j}`,`${j} must be a boolean, an array of items or a (params, defaults) => items function; got ${typeof v}. Ignoring it.`),{items:h,spoke:!1,suppress:!1}}function f(v,h,c){let j=Array.isArray(v)?v:[],E=!1;for(const O of h){if(!O)continue;const T=g(O.layer,j,c,O.where);j=T.items,T.spoke&&(E=T.suppress)}return E?null:j}class w{#e=!0;#t=!0;#n;#r;#o=[];#i=null;#s=null;constructor(h){this.#n=h.grid,this.#e=h.cellMenu!==!1,this.#t=h.headerMenu!==!1,this.#i=M(h.items)?h.items:null,this.#s=M(h.headerItems)?h.headerItems:null,this.#r=new D({document:h.document,host:h.host,ctx:{grid:h.grid}})}mount(){this.#t&&this.#o.push(this.#n.on("column:menu:open",h=>{const c=String(h.colId),j=this.#c(c,u(this.#n,c));j.length&&this.#r.show({items:j,ctx:this.#u(c),anchor:h.element,placement:"below",returnFocus:h.element})})),this.#t&&this.#o.push(this.#n.on("header:contextmenu",h=>{const c=String(h.colId),j=this.#c(c,i(this.#n,c));j.length&&this.#r.show({items:j,ctx:this.#u(c),x:h.x,y:h.y,returnFocus:h.element})})),this.#o.push(this.#n.on("cell:contextmenu",h=>{const c=h.event;this.#e&&c&&M(c.preventDefault)&&c.preventDefault();const j=this.#l(h),E=b(this.#n,j),O=f(E,[{layer:this.#e===!1?!1:this.#i,where:"contextMenu"},{layer:this.#a(j.column),where:`column '${j.colId}' contextMenu`}],j);!O||!O.length||(!this.#e&&c&&M(c.preventDefault)&&c.preventDefault(),this.#r.show({items:O,ctx:j,x:c?c.clientX:void 0,y:c?c.clientY:void 0}))}))}#l(h){const c=this.#n.columns,j=h.column||(h.colId!=null&&c&&M(c.get)?c.get(h.colId):void 0),E=h.row,O=this.#n.rows,T=h.key!==void 0?h.key:E?E.key:void 0;return{key:T,colId:h.colId,value:h.value!==void 0||T===void 0||h.colId==null?h.value:O&&M(O.value)?O.value(T,h.colId):void 0,row:E,data:E?E.data:void 0,column:j,index:h.index!==void 0?h.index:h.rowIndex,grid:this.#n}}#a(h){if(!(!h||h.contextMenu===void 0||h.contextMenu===null))return h.contextMenu}#u(h){return{colId:h,column:this.#n.columns.get(h),grid:this.#n}}#c(h,c){return this.#s?f(c,[{layer:this.#s,where:"columnMenu"}],this.#u(h))||[]:c}destroy(){for(const h of this.#o)h();this.#o=[],this.#r.destroy()}}}),Ce("packages/dom/src/shortcutshelp.js",function(e,G){"use strict";Object.defineProperty(e,"HELP_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"ShortcutsHelp",{enumerable:!0,get:function(){return S}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/renderer/keyboard.js"),Z=W.groupedShortcuts,V=W.SHORTCUT_IDS,D=G("packages/dom/src/platform.js").macLike,I="lat-shortcuts",k='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class S{#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,u){const n=this.#e;return(n&&n.messages?n.messages:R).t(d,u)}#s(d){const u=V[d.combo];if(!u)return d.meaning;const n=`shortcut.${u}`,t=this.#i(n);return t===n?d.meaning:t}mount(){const d=this.#t.viewport?.root;if(!d||!M(d.addEventListener))return;const u=n=>{if(this.open||n.key!=="?")return;const t=n.target,i=t&&t.tagName;i==="INPUT"||i==="TEXTAREA"||t&&t.isContentEditable||(n.preventDefault(),n.stopPropagation(),this.show())};d.addEventListener("keydown",u,!0),this.#o.push(()=>d.removeEventListener("keydown",u,!0))}show(){const d=this.#l();if(!d)return;const u=d.ownerDocument;this.#r=u&&u.activeElement,d.style.display="",M(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&&M(d.focus)&&d.focus(),this.#e.emit?.("shortcuts:closed",{})}#l(){if(this.#n)return this.#n;const d=this.#t.viewport?.overlays,u=d?.ownerDocument;if(!d||!u?.createElement)return null;const n=u.createElement("div");n.className=I,n.setAttribute("role","dialog"),n.setAttribute("aria-modal","true"),n.setAttribute("tabindex","-1");const t=`${I}-title`;n.setAttribute("aria-labelledby",t);const i=u.createElement("div");i.className=`${I}__head`;const s=u.createElement("h2");s.className=`${I}__title`,s.id=t,s.textContent=this.#i("shortcuts.title");const r=u.createElement("button");r.className=`${I}__close`,r.type="button",r.setAttribute("aria-label",this.#i("shortcuts.close")),r.textContent="×",i.appendChild(s),i.appendChild(r),n.appendChild(i);const o=u.createElement("div");o.className=`${I}__body`;for(const a of Z())a.items.length&&o.appendChild(this.#a(u,a));n.appendChild(o);const l=u.createElement("p");return l.className=`${I}__hint`,l.textContent=this.#i("shortcuts.hint"),n.appendChild(l),d.appendChild(n),this.#n=n,this.#u(n,r),n}#a(d,u){const n=d.createElement("section");n.className=`${I}__group`;const t=d.createElement("h3");t.className=`${I}__group-title`,t.textContent=this.#i(u.messageKey),n.appendChild(t);const i=d.createElement("dl");i.className=`${I}__list`;const s=D();for(const r of u.items){const o=d.createElement("dt");o.className=`${I}__keys`,r.alternatives.forEach((a,p)=>{if(p>0){const m=d.createElement("span");m.className=`${I}__or`,m.textContent=this.#i("shortcuts.or"),o.appendChild(m)}a.forEach((m,b)=>{b>0&&o.appendChild(d.createTextNode("+"));const g=d.createElement("kbd");g.textContent=s&&m==="Ctrl"?this.#i("shortcuts.key.cmd"):m,o.appendChild(g)})});const l=d.createElement("dd");l.className=`${I}__meaning`,l.textContent=this.#s(r),i.appendChild(o),i.appendChild(l)}return n.appendChild(i),n}#u(d,u){const n=i=>{if(i.stopPropagation(),i.key==="Escape"){i.preventDefault(),this.hide();return}if(i.key!=="Tab")return;const s=[...d.querySelectorAll(k)];if(!s.length){i.preventDefault();return}const r=s[0],o=s[s.length-1],l=d.ownerDocument.activeElement;i.shiftKey&&(l===r||l===d)?(i.preventDefault(),o.focus()):!i.shiftKey&&l===o&&(i.preventDefault(),r.focus())},t=i=>{i.preventDefault?.(),this.hide()};d.addEventListener("keydown",n),u.addEventListener("click",t),this.#o.push(()=>{d.removeEventListener("keydown",n),u.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}}}),Ce("packages/dom/src/rowreorder.js",function(e,G){"use strict";Object.defineProperty(e,"HANDLE_CLASS",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"MARKER_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"DRAGGING_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"resolveRowTransfer",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"resolveRowReorder",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"RowReorder",{enumerable:!0,get:function(){return d}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/renderer/renderer.js").displayIndexOf,V="lat-rowdrag",U="lat-rowdrag-marker",D="lat-rowdrag-lifted",I=4,k=new Set;function S(u){if(!u)return null;const n=u===!0?{}:typeof u=="object"?u:null;return n?{send:n.send!==!1,receive:n.receive!==!1,mode:n.mode==="copy"?"copy":"move",group:typeof n.group=="string"?n.group:null}:null}function y(u){return u===!0?{column:null}:!u||typeof u!="object"?null:{column:typeof u.column=="string"?u.column:null}}class d{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=[];constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document,this.#r=y(n.grid.get("rowReorder")),this.#o=S(n.grid.get("rowTransfer"))}get active(){return this.#r!==null||this.#o!==null}get draggable(){return this.#r!==null}get grid(){return this.#e}get root(){return this.#t.viewport?.root||null}accepts(n){if(!this.#o||!this.#o.receive)return!1;const t=n&&n.transfer;return!t||!t.send?!1:t.group===this.#o.group}get transfer(){return this.#o}#u(n,t){const i=this.#e;return(i&&i.messages?i.messages:R).t(n,t)}#c(n,t){const i=this.#t&&this.#t.announce;M(i)&&i.call(this.#t,n,t)}#d(){if(!this.#r)return null;if(this.#r.column)return this.#r.column;const n=this.#e.columns.visible().filter(t=>!t.generated);return n.length?n[0].id:null}paint(){if(!this.draggable)return;const n=this.#d(),t=this.#t.viewport?.root;if(!n||!t)return;const i=t.querySelectorAll(`.lat-cell[data-col="${n}"]`);for(const s of i){if(s.querySelector(`.${V}`))continue;const r=s.parentNode;if(r&&M(r.getAttribute)&&r.getAttribute("data-pinned"))continue;const o=this.#n.createElement("span");o.className=V,o.setAttribute("data-role","row-drag"),o.setAttribute("aria-hidden","true"),o.setAttribute("title",this.#u("a11y.reorder.grab")),o.textContent="⠿",s.insertBefore(o,s.firstChild||null)}}mount(){if(!this.active)return;k.add(this);const n=this.#t.viewport?.root;if(!n||!M(n.addEventListener))return;const t=l=>this.#h(l),i=l=>this.#f(l),s=()=>this.#m(),r=l=>this.#j(l);n.addEventListener("pointerdown",t),n.addEventListener("keydown",r);const o=this.#n.defaultView||this.#n;o.addEventListener?.("pointermove",i),o.addEventListener?.("pointerup",s),this.#a.push(()=>{n.removeEventListener("pointerdown",t),n.removeEventListener("keydown",r),o.removeEventListener?.("pointermove",i),o.removeEventListener?.("pointerup",s)})}#h(n){const t=n.target;if(!t||!M(t.closest)||!t.closest('[data-role="row-drag"]'))return;const i=t.closest(".lat-row"),s=i?Z(i):-1;if(s<0)return;const r=this.#e.rows.get(s);if(!r)return;const o=this.#E();if(o&&!(this.#o&&this.#o.send)){this.#c(this.#u(o),{repeat:!0});return}n.preventDefault?.(),this.#i={key:r.key,from:s,at:s,x:n.clientX,y:n.clientY,armed:!1,hit:null,over:null,frame:null,pending:null}}#f(n){const t=this.#i;if(!t)return;if(!t.armed){if(Math.abs(n.clientX-t.x)+Math.abs(n.clientY-t.y)<I)return;t.armed=!0,this.#T(t),t.over=this,this.#e.emit("rowDrag:started",this.#p(t,this,t.from,t.key),"user")}this.#l&&this.#D(n.clientX,n.clientY);const i=this.#A(n.clientX,n.clientY);if(t.target=i,i!==this){this.#M(),i&&i.accepts(this)?(i.showDropTarget(n.clientX,n.clientY),t.hit=i.hitAt(n.clientX,n.clientY)):t.hit=null,this.#w(t,i),this.#b(t,i,t.hit?t.hit.at:null,t.hit?t.hit.overKey:null);return}const s=this.#C(n.clientX,n.clientY);if(this.#w(t,i),s<0){this.#b(t,this,null,null);return}t.at=s,this.#I(s);const r=this.#e.rows.get(s);this.#b(t,this,s,r?r.key:null)}#m(){const n=this.#i;this.#i=null,this.#M(),this.#N();for(const s of k)s.hideDropTarget();if(!n||(this.#v(n),!n.armed))return;const t=n.target;if(this.#e.emit("rowDrag:ended",this.#g(n),"user"),t&&t!==this){this.#S(n,t);return}if(n.at===n.from)return;const i=this.#E();if(i){this.#c(this.#u(i),{repeat:!0});return}this.#O(n.key,n.at)}#p(n,t,i,s){const r=this.#e.rows.byKey(n.key);return{key:n.key,data:r?r.data:null,over:t?t.grid:null,at:i,overKey:s}}#g(n){const t=n.target||null;if(t&&t!==this){if(!t.accepts(this))return{...this.#p(n,t,null,null),dropped:!1};const i=n.hit||{at:t.grid.rows.count(),overKey:null};return{...this.#p(n,t,i.at,i.overKey),dropped:!0}}if(t===this){const i=this.#e.rows.get(n.at);return{...this.#p(n,this,n.at,i?i.key:null),dropped:n.at!==n.from&&this.#E()===null}}return{...this.#p(n,null,null,null),dropped:!1}}#w(n,t){if(n.over===t)return;const i=n.over;n.over=t,i&&(this.#v(n),this.#e.emit("rowDrag:left",this.#p(n,i,null,null),"user"))}#b(n,t,i,s){n.pending={over:t,at:i,overKey:s},n.frame===null&&(n.frame=this.#y(()=>{n.frame=null;const r=n.pending;n.pending=null,!(!r||this.#i!==n)&&this.#e.emit("rowDrag:moved",this.#p(n,r.over,r.at,r.overKey),"user")}))}#v(n){n.pending=null,n.frame!==null&&(n.frame(),n.frame=null)}#y(n){const t=this.#n.defaultView||globalThis;if(M(t.requestAnimationFrame)){const s=t.requestAnimationFrame(n);return()=>{M(t.cancelAnimationFrame)&&t.cancelAnimationFrame(s)}}const i=setTimeout(n,16);return()=>clearTimeout(i)}#S(n,t){if(!t.accepts(this)){this.#c(this.#u("a11y.transfer.refused"),{repeat:!0});return}const i=this.#e.rows.byKey(n.key);if(!i)return;const s=this.#o.mode,r=n.key,o=n.hit||{at:t.grid.rows.count(),overKey:null};let l=null;const a=t.receive(i.data,o.at,{overKey:o.overKey,source:this.#e,revalidate:()=>!!this.#e.rows.byKey(r),onCancel:m=>{l=m}}),p=m=>{if(m!==!0){const b=m===!1?"a11y.transfer.refused":l==="stale"?"a11y.transfer.stale":"a11y.transfer.declined";this.#c(this.#u(b),{repeat:!0});return}s==="move"?(this.#e.rows.apply({remove:[r]}),this.#e.emit("row:sent",{key:r,data:i.data,mode:s})):this.#e.emit("row:copied",{key:r,data:i.data,mode:s}),this.#c(this.#u(s==="copy"?"a11y.transfer.copied":"a11y.transfer.moved"),{repeat:!0})};a&&M(a.then)?a.then(p):p(a)}receive(n,t,i={}){const s=this.#e,r=n&&typeof n=="object"?{...n}:n,o=i.overKey??null,l=i.source||null,a=M(i.onCancel)?i.onCancel:null,p=()=>{const w=s.rows.totalCount(),v=s.rows.apply({add:[r],at:Math.max(0,t||0)}),h=s.rows.totalCount()>w;return h&&s.emit("row:received",{data:r,at:t,overKey:o,rejected:v?.rejected||[]}),h},m=()=>{if(o!==null){const w=s.rows.get(t);if(!w||w.key!==o)return!1}return!M(i.revalidate)||i.revalidate()},b=M(s.rendererHost)?s.rendererHost():null;if(!b||!M(b.gateBefore))return p();const g=a?s.on("rowReceive:cancelled",w=>a(w.reason)):null,f=b.gateBefore("beforeRowReceive","rowReceive:cancelled",{data:r,at:t,overKey:o,source:l,origin:"user"},p,m);return g&&(f&&M(f.then)?f.then(g,g):g()),f}hitAt(n,t){const i=this.#C(n,t);if(i<0)return{at:this.#e.rows.count(),overKey:null};const s=this.#e.rows.get(i);return{at:i,overKey:s?s.key:null}}showDropTarget(n,t){const i=this.root;i&&M(i.setAttribute)&&i.setAttribute("data-drop-target","")}hideDropTarget(){const n=this.root;n&&M(n.removeAttribute)&&n.removeAttribute("data-drop-target")}#A(n,t){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(n,t):null,s=i&&M(i.closest)?i.closest(".lattice"):null;if(!s)return null;for(const r of k)if(r.root===s)return r;return null}#j(n){if(!n.altKey||!n.shiftKey)return;const t=n.key==="ArrowUp"?-1:n.key==="ArrowDown"?1:0;if(!t)return;const i=this.#n.activeElement,s=i&&M(i.closest)?i.closest(".lat-row"):null,r=s?Z(s):-1;if(r<0)return;n.preventDefault?.(),n.stopPropagation?.();const o=this.#E();if(o){this.#c(this.#u(o),{repeat:!0});return}const l=this.#e.rows.get(r);l&&this.#O(l.key,r+t)}#O(n,t){const i=this.#e.rows.count(),s=Math.max(0,Math.min(i-1,t)),r=this.#e.rows.move(n,s);if(!r.moved){r.reason&&r.reason!=="unchanged"&&this.#c(this.#u(`a11y.reorder.${r.reason}`),{repeat:!0});return}this.#c(this.#u("a11y.reorder.moved",{position:r.to+1,total:i}),{repeat:!0})}#E(){const n=this.#e;if(n.sort.get().length)return"a11y.reorder.sorted";if((n.state.get().group||[]).length)return"a11y.reorder.grouped";const t=n.filters.get();return t&&Object.keys(t).length?"a11y.reorder.filtered":null}#C(n,t){const i=this.#n.elementFromPoint?this.#n.elementFromPoint(n,t):null,s=i&&M(i.closest)?i.closest(".lat-row"):null;return!s||M(s.getAttribute)&&s.getAttribute("data-pinned")?-1:Z(s)}#T(n){const t=this.root,i=t&&M(t.querySelector)?t.querySelector(`.lat-row[data-index="${n.from}"]`):null;i&&M(i.classList?.add)&&i.classList.add(D);const s=this.#n.body;if(!s||!M(s.appendChild))return;const r=this.#d(),o=r&&M(this.#e.rows?.text)&&this.#e.rows.text(n.key,r)||this.#u("a11y.reorder.grab"),l=t&&this.#n.defaultView?.getComputedStyle?this.#n.defaultView.getComputedStyle(t):null,a=(m,b)=>l&&l.getPropertyValue(m).trim()||b,p=this.#n.createElement("div");p.textContent=String(o),p.setAttribute("aria-hidden","true"),p.setAttribute("data-role","row-drag-ghost"),p.style.cssText=["position:fixed","z-index:2147483647","pointer-events:none","top:0","left:0","white-space:nowrap",`padding:${a("--lattice-space","4px")} calc(${a("--lattice-space","4px")} * 2)`,`border-radius:${a("--lattice-radius-sm",a("--lattice-radius","4px"))}`,`border:${a("--lattice-border-width","1px")} solid ${a("--lattice-border-strong","#0003")}`,`background:${a("--lattice-background","#fff")}`,`color:${a("--lattice-foreground","#000")}`,`box-shadow:${a("--lattice-shadow-overlay","0 4px 12px rgba(0,0,0,.25)")}`,`font:${a("--lattice-font-size","13px")} ${a("--lattice-font-family","system-ui, sans-serif")}`].join(";"),s.appendChild(p),this.#l=p}#D(n,t){this.#l&&(this.#l.style.transform=`translate(${Math.round(n)+14}px, ${Math.round(t)+16}px)`)}#N(){this.#l&&(this.#l.parentNode&&this.#l.parentNode.removeChild(this.#l),this.#l=null);const n=this.root,t=n&&M(n.querySelectorAll)?n.querySelectorAll(`.${D}`):[];for(const i of t)i.classList.remove(D)}#I(n){const t=this.#t.viewport?.overlays;if(!t)return;this.#s||(this.#s=this.#n.createElement("div"),this.#s.className=U,t.appendChild(this.#s));const i=this.#t.viewport.root,s=i.querySelector(`.lat-row[data-index="${n}"]`)||i.querySelectorAll(".lat-row")[0];if(!s||!M(s.getBoundingClientRect))return;const r=s.getBoundingClientRect(),o=i.getBoundingClientRect(),l=this.#i&&n>this.#i.from;this.#s.style.display="",this.#s.style.top=`${Math.round((l?r.bottom:r.top)-o.top)}px`}#M(){this.#s&&(this.#s.style.display="none")}destroy(){k.delete(this);for(const n of this.#a)n();this.#a=[],this.#i&&this.#v(this.#i),this.#i=null,this.#N(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#s=null}}}),Ce("packages/dom/src/alignedgrids.js",function(e,G){"use strict";Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$=["column:resized","column:moved","column:visible","column:pinned"];function R(V){return(V||[]).map(U=>({id:U.id,width:U.width,flex:U.flex,hidden:U.hidden,pin:U.pin===void 0?null:U.pin}))}class W{#e=new Set;#t=new Map;#n=!1;add(U){if(!U||this.#e.has(U))return;this.#e.add(U);const D=[];for(const k of $)D.push(U.on(k,()=>this.#r(U)));D.push(U.on("scroll",k=>this.#i(U,k))),D.push(U.on("destroy",()=>this.remove(U))),this.#t.set(U,D);const[I]=this.#e;I!==U&&this.#o(U,R(I.columns.state()))}remove(U){const D=this.#t.get(U);if(D)for(const I of D)I();this.#t.delete(U),this.#e.delete(U)}get size(){return this.#e.size}destroy(){for(const U of[...this.#e])this.remove(U)}#r(U){if(this.#n)return;const D=R(U.columns.state());this.#n=!0;try{for(const I of this.#e)I!==U&&this.#o(I,D)}finally{this.#n=!1}}#o(U,D){if(!U.columns||!M(U.columns.apply))return;const I=new Map((U.columns.state()||[]).map(S=>[S.id,S])),k=[];for(const S of D){const y=I.get(S.id);y&&(k.push({...y,...S}),I.delete(S.id))}for(const S of I.values())k.push(S);U.columns.apply(k)}#i(U,D){if(this.#n)return;const I=D&&typeof D.left=="number"?D.left:null;if(I!==null){this.#n=!0;try{for(const k of this.#e)k!==U&&k.scroll?.to?.({left:I})}finally{this.#n=!1}}}}function Z(V){const U=new W;for(const D of V||[])U.add(D);return U}}),Ce("packages/dom/src/columntagbar.js",function(e,G){"use strict";Object.defineProperty(e,"BAR_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveTagFilter",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"ColumnTagBar",{enumerable:!0,get:function(){return V}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-tagbar";function Z(D){if(!D)return null;const I=D===!0?{}:typeof D=="object"?D:null;return I?{multiple:I.multiple===!0,label:typeof I.label=="string"?I.label:null}:null}class V{#e;#t;#n;#r=null;#o=null;#i=null;#s="\0";#l=[];constructor(I){this.#e=I.grid,this.#t=I.renderer,this.#n=I.document,this.#r=Z(I.grid.get("columnTagFilter"))}get active(){return this.#r!==null}#a(I,k){const S=this.#e;return(S&&S.messages?S.messages:R).t(I,k)}mount(){if(!this.active)return;const I=this.#t.viewport,k=I?.root;if(!k||!M(k.insertBefore))return;const S=this.#n.createElement("div");S.className=W,S.setAttribute("role","toolbar"),S.setAttribute("aria-label",this.#a("tags.label"));const y=this.#n.createElement("label");y.className=`${W}__label`,y.textContent=this.#r.label||this.#a("tags.label");const d=this.#n.createElement("select");d.className=`${W}__select`,this.#r.multiple&&d.setAttribute("multiple","");const u=`${W}-select-${Math.abs(U(String(k.className)))}`;d.id=u,y.setAttribute("for",u),S.appendChild(y),S.appendChild(d),k.insertBefore(S,I.header||k.firstChild),this.#o=S,this.#i=d;const n=()=>{const i=this.#r.multiple?[...d.selectedOptions||[]].map(s=>s.value).filter(Boolean):d.value?[d.value]:[];this.#e.columns.showTagged(i),this.#u(i)};d.addEventListener("change",n),this.#l.push(()=>d.removeEventListener("change",n));const t=this.#e.on("model:changed",()=>this.refresh());this.#l.push(t),this.refresh()}#u(I){const k=this.#t&&this.#t.announce;if(!M(k))return;const S=I.length?I.join(", "):this.#a("tags.all");k.call(this.#t,this.#a("tags.showing",{tag:S}))}refresh(){if(!this.#i||!this.#o)return;const I=this.#e.columns.tags();if(this.#o.style.display=I.length?"":"none",!I.length)return;const k=I.join("\0");if(k===this.#s)return;this.#s=k;const S=this.#e.columns.activeTags();if(this.#i.replaceChildren&&this.#i.replaceChildren(),!this.#r.multiple){const y=this.#n.createElement("option");y.value="",y.textContent=this.#a("tags.all"),this.#i.appendChild(y)}for(const y of I){const d=this.#n.createElement("option");d.value=y,d.textContent=y,S.includes(y)&&(d.selected=!0),this.#i.appendChild(d)}this.#r.multiple||(this.#i.value=S.length?S[0]:"")}destroy(){for(const I of this.#l)I();this.#l=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}function U(D){let I=0;for(let k=0;k<D.length;k++)I=I*31+D.charCodeAt(k)|0;return I}}),Ce("packages/dom/src/anomalychip.js",function(e,G){"use strict";Object.defineProperty(e,"CHIP_CLASS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"resolveAnomalySummary",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"AnomalyChip",{enumerable:!0,get:function(){return D}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-anomaly-chip";function Z(I){if(!I)return null;const k=I===!0?{}:typeof I=="object"?I:null;return k?{column:typeof k.column=="string"?k.column:null,label:typeof k.label=="string"?k.label:null}:null}function V(I){return I?typeof I=="string"?{kind:I}:typeof I=="object"?I:null:null}function U(I,k){return I?Array.isArray(I.conditions)?I.conditions.some(S=>U(S,k)):I.col===k&&I.op==="eq"&&I.value===!0:!1}class D{#e;#t;#n;#r=null;#o=null;#i=null;#s=[];#l=!1;#a=!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,S){const y=this.#e;return(y&&y.messages?y.messages:R).t(k,S)}#f(){const k=this.#r&&this.#r.column;let S=null;for(const y of this.#e.columns.all()){const d=V(y.shadow);if(!d||d.kind!=="anomalyFlag")continue;const u=d.of||y.field||y.id;if(k){if(y.id===k||u===k)return this.#d=y.id,y}else S||(S=y,this.#d=y.id)}return k?null:S}#m(){if(!this.#d||!M(this.#e.rows&&this.#e.rows.forEach))return 0;let k=0;try{this.#e.rows.forEach(S=>{!S||S.group||S.key==null||this.#e.rows.value(S.key,this.#d)===!0&&k++})}catch{return 0}return k}mount(){if(!this.active)return;const k=this.#t.viewport,S=k&&k.root;if(!S||!M(S.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),S.insertBefore(y,k.header||S.firstChild),this.#o=y,this.#i=d;const u=()=>this.toggle();d.addEventListener("click",u),this.#s.push(()=>d.removeEventListener("click",u));for(const n of["filter:changed","rows:changed","model:changed"])this.#s.push(this.#e.on(n,()=>{this.#a||this.refresh()}));this.refresh()}toggle(){this.#l?this.#g():this.#p()}#p(){if(!this.#d)return;this.#u=this.#e.filters.get();const k={col:this.#d,op:"eq",value:!0},S=this.#u?{op:"and",conditions:[this.#u,k]}:k;this.#l=!0,this.#a=!0;try{this.#e.filters.set(S)}finally{this.#a=!1}this.refresh()}#g(){this.#l=!1,this.#a=!0;try{this.#e.filters.set(this.#u||null)}finally{this.#a=!1}this.#u=null,this.refresh()}refresh(){if(!this.#o||!this.#i)return;if(!this.#f()){this.#o.style.display="none";return}if(this.#l&&!U(this.#e.filters.get(),this.#d)&&(this.#l=!1,this.#u=null),this.#l){this.#w(this.#c,!0);return}const S=this.#m();if(this.#c=S,!S){this.#o.style.display="none";return}this.#w(S,!1)}#w(k,S){if(!this.#o||!this.#i)return;this.#o.style.display="",this.#o.setAttribute("data-active",S?"true":"false"),this.#i.setAttribute("aria-pressed",S?"true":"false");const y=this.#r&&this.#r.label,d=S?this.#h("anomaly.chipActive",{count:k}):y||this.#h("anomaly.chip",{count:k});this.#i.textContent=d}destroy(){for(const k of this.#s)k();this.#s=[],this.#o&&this.#o.parentNode&&this.#o.parentNode.removeChild(this.#o),this.#o=null,this.#i=null}}}),Ce("packages/dom/src/rowform.js",function(e,G){"use strict";Object.defineProperty(e,"FORM_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"resolveRowForm",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"RowForm",{enumerable:!0,get:function(){return i}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,V=G("packages/dom/src/editors/index.js").createEditor,D=G("packages/dom/src/renderer/renderer.js").displayIndexOf,k=G("packages/dom/src/themeof.js").themeOf,S="lat-rowform",y='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function d(s){if(!s)return null;const r=s===!0?{}:typeof s=="object"?s:null;if(!r)return null;const o=M(r.load)?r.load:null,l=Array.isArray(r.fields)&&r.fields.length?r.fields:null;return{timeout:t(r.timeout),container:r.container??null,mode:r.container?"inline":r.mode==="dialog"?"dialog":"drawer",load:o,fields:l,title:r.title??null,width:typeof r.width=="string"?r.width:null,trigger:r.trigger===!1?"none":"dblclick"}}function u(s,r){const o=M(s)?s():s;return o?typeof o=="string"?r&&M(r.querySelector)?r.querySelector(o):null:o&&M(o.appendChild)?o:null:null}const n=2e3;function t(s){return s===!1||s===0?0:typeof s!="number"||!Number.isFinite(s)||s<=0?n:s}class i{#e;#t;#n;#r;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];#c=null;#d=0;#h=null;#f=!1;#m=[];constructor(r){this.#e=r.grid,this.#t=r.renderer,this.#n=r.document,this.#r=r.registry||null,this.#o=d(r.grid.get("rowForm"))}get active(){return this.#o!==null}get open(){return!!this.#i&&this.#i.style.display!=="none"}#p(r,o){const l=this.#e;return(l&&l.messages?l.messages:W).t(r,o)}mount(){if(!this.active)return;const r=this.#t.viewport?.root;if(!r||!M(r.addEventListener)||this.#o.trigger==="none")return;const o=l=>{const a=l.target;if(!a||!M(a.closest)||a.closest(".lat-editor-host, .lat-editor--popup"))return;const p=a.closest(".lat-row"),m=p?D(p):-1;if(m<0)return;const b=this.#e.rows.get(m);!b||b.group||b.detail||(l.preventDefault?.(),l.stopPropagation?.(),this.openRow(b.key))};r.addEventListener("dblclick",o,!0),this.#m.push(()=>r.removeEventListener("dblclick",o,!0))}openRow(r){const o=this.#e.rows.byKey(r);if(!o)return!1;const l=this.#g();if(!l)return!1;this.#a=o,this.#c=this.#n.activeElement,l.style.display="",this.#C(l),this.#b(o);const a=this.#o.load;if(!a)this.#E(o.data);else{this.#A();const p=++this.#d;this.#v(p,r),Promise.resolve().then(()=>a({row:o,data:o.data,key:r,grid:this.#e})).then(m=>{p!==this.#d||!this.open||(this.#S(),this.#E(m||o.data))}).catch(m=>{p!==this.#d||!this.open||(this.#S(),this.#j(m,r))})}return M(l.focus)&&l.focus(),this.#e.emit("form:opened",{key:r,row:o}),!0}close(){if(!this.#i)return;this.#d+=1,this.#S(),this.#R(),this.#i.style.display="none";const r=this.#a?this.#a.key:null;this.#a=null;const o=this.#c;this.#c=null,o&&M(o.focus)&&o.focus(),this.#e.emit("form:closed",{key:r})}save(){if(!this.#a||!this.#u.length)return!1;const r=this.#a.key,o={},l={},a=[],p=[];for(const m of this.#u){const b=M(m.editor.commit)?m.editor.commit():{ok:!0,value:void 0};if(!b.ok)return this.#N(m,b.message),!1;o[m.field]=b.value;const g=m.initial;Object.is(g,b.value)||(l[m.field]=b.value,m.colId?a.push({key:r,colId:m.colId,value:b.value}):p.push(m.field))}return a.length&&this.#e.edit.setCells(a),this.#e.emit("form:saved",{key:r,values:o,changed:l,unmapped:p}),this.close(),!0}#g(){if(this.#i)return this.#i;const r=this.#t.viewport?.overlays,o=this.#n||r?.ownerDocument;if(!o?.createElement)return null;const l=u(this.#o.container,o),a=l||r;if(!a)return null;this.#o.container&&!l&&$("rowform:container","rowForm.container could not be resolved; the form opens over the grid instead."),this.#f=!!l;const p=o.createElement("div"),m=this.#f?"lattice ":"";p.className=`${m}${S} ${S}--${this.#f?"inline":this.#o.mode}`,p.setAttribute("role",this.#f?"region":"dialog"),this.#f||p.setAttribute("aria-modal","true"),p.setAttribute("tabindex","-1"),this.#o.width&&p.style.setProperty("--lattice-rowform-width",this.#o.width);const b=`${S}-title`;p.setAttribute("aria-labelledby",b);const g=o.createElement("div");g.className=`${S}__head`;const f=o.createElement("h2");f.className=`${S}__title`,f.id=b,g.appendChild(f);const w=o.createElement("div");w.className=`${S}__body`;const v=o.createElement("div");v.className=`${S}__foot`;const h=o.createElement("button");h.className=`${S}__cancel`,h.type="button",h.textContent=this.#p("form.cancel");const c=o.createElement("button");return c.className=`${S}__save`,c.type="button",c.textContent=this.#p("form.save"),v.appendChild(h),v.appendChild(c),p.appendChild(g),p.appendChild(w),p.appendChild(v),a.appendChild(p),this.#i=p,this.#s=w,this.#l=c,this.#w(p,c,h),p}#w(r,o,l){const a=b=>{if(b.stopPropagation(),b.key==="Escape"){b.preventDefault(),this.close();return}if(b.key!=="Tab"||this.#f)return;const g=[...r.querySelectorAll(y)];if(!g.length){b.preventDefault();return}const f=g[0],w=g[g.length-1],v=r.ownerDocument.activeElement;b.shiftKey&&(v===f||v===r)?(b.preventDefault(),w.focus()):!b.shiftKey&&v===w&&(b.preventDefault(),f.focus())},p=b=>{b.preventDefault?.(),this.save()},m=b=>{b.preventDefault?.(),this.close()};r.addEventListener("keydown",a),o.addEventListener("click",p),l.addEventListener("click",m),this.#m.push(()=>{r.removeEventListener("keydown",a),o.removeEventListener("click",p),l.removeEventListener("click",m)})}#b(r){const o=this.#i.querySelector(`.${S}__title`);if(!o)return;const l=this.#o.title;M(l)?o.textContent=String(l({row:r,data:r.data})??""):typeof l=="string"?o.textContent=l:o.textContent=this.#p("form.title")}#v(r,o){this.#S();const l=this.#o.timeout;if(!l)return;const a=this.#n.defaultView||globalThis;M(a.setTimeout)&&(this.#h=a.setTimeout(()=>{this.#h=null,!(r!==this.#d||!this.open)&&(this.#d+=1,this.#j(new Error(`Loading the record timed out after ${l}ms`),o,"form.loadTimeout"))},l))}#y(r){this.#l&&(this.#l.disabled=!r,r?this.#l.removeAttribute("aria-disabled"):this.#l.setAttribute("aria-disabled","true"))}#S(){if(this.#h===null)return;const r=this.#n.defaultView||globalThis;M(r.clearTimeout)&&r.clearTimeout(this.#h),this.#h=null}#A(){this.#R(),this.#y(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const r=this.#n.createElement("p");r.className=`${S}__note`,r.setAttribute("role","status"),r.textContent=this.#p("form.loading"),this.#s.appendChild(r)}#j(r,o,l="form.loadFailed"){this.#R(),this.#y(!1),this.#s.replaceChildren&&this.#s.replaceChildren();const a=this.#n.createElement("p");a.className=`${S}__note ${S}__note--error`,a.setAttribute("role","alert"),a.textContent=this.#p(l);const p=this.#n.createElement("button");p.className=`${S}__retry`,p.type="button",p.textContent=this.#p("form.retry"),p.addEventListener("click",()=>this.openRow(o)),this.#s.appendChild(a),this.#s.appendChild(p),this.#e.emit("form:error",{key:o,error:r,timedOut:l==="form.loadTimeout"})}#O(){return this.#o.fields?this.#o.fields.map(r=>typeof r=="string"?{field:r}:r):this.#e.columns.all().filter(r=>!r.generated&&r.field).map(r=>({field:r.field,label:r.title,colId:r.id}))}#E(r){this.#R(),this.#y(!0),this.#s.replaceChildren&&this.#s.replaceChildren();const o=r&&typeof r=="object"?r:{};for(const l of this.#O()){const a=l.field;if(!a)continue;const p=l.colId?this.#e.columns.get(l.colId):this.#W(a),m=this.#x(l,p,a),b=Object.hasOwn(o,a)?o[a]:null,g=this.#n.createElement("div");g.className=`${S}__field`;const f=this.#n.createElement("label");f.className=`${S}__label`,f.textContent=String(l.label??(p&&p.title)??a);const w=this.#n.createElement("div");w.className=`${S}__control`,g.appendChild(f),g.appendChild(w),this.#s.appendChild(g);const v={field:a,colId:p?p.id:null,editor:null,initial:b,opener:null,wrap:g},h=V({grid:this.#e,column:m,colId:p?p.id:a,row:this.#a,data:o,value:b,text:b==null?"":String(b),locale:this.#e.get("locale"),props:l.props||p&&p.edit&&p.edit.props,lookup:l.lookup||p&&p.lookup,document:this.#n,cell:w,overlay:this.#T(),stop:()=>this.#I(v)},this.#r);if(h){v.editor=h;try{M(h.value)&&(v.initial=h.value())}catch{}if(this.#u.push(v),h.popup===!0)this.#D(w,v);else{const c=M(h.element)?h.element():null;c&&w.appendChild(c)}}}}#C(r){if(!this.#f)return;const o=this.#t.viewport?.root;if(!(!o||!M(o.getAttribute)))for(const l of["data-theme","data-density","dir"]){const a=l==="data-theme"?k(o):o.getAttribute(l);a?r.setAttribute(l,a):M(r.removeAttribute)&&r.removeAttribute(l)}}#T(){return this.#f?this.#n.body||this.#t.viewport.overlays:this.#t.viewport.overlays}#D(r,o){const l=this.#n.createElement("button");l.className=`${S}__opener`,l.type="button",o.opener=l,this.#M(o);const a=()=>{M(o.editor.attached)&&o.editor.attached()};l.addEventListener("click",a),this.#m.push(()=>l.removeEventListener("click",a)),r.appendChild(l)}#N(r,o){const l=r.wrap;l&&M(l.scrollIntoView)&&l.scrollIntoView({block:"nearest"});const a=r.opener||(M(r.editor.focusTarget)?r.editor.focusTarget():null);a&&M(a.focus)&&a.focus();const p=this.#t&&this.#t.announce;M(p)&&o&&p.call(this.#t,String(o))}#I(r){if(!r.opener||!r.editor)return;const o=M(r.editor.popupHandle)?r.editor.popupHandle():null;o&&M(o.hide)&&o.hide(),this.#M(r),M(r.opener.focus)&&r.opener.focus()}#M(r){if(!r.opener)return;let o="";try{const a=r.colId?this.#e.columns.get(r.colId):null,p=a&&a.dataType&&a.dataType.format;M(p)&&(o=p({value:M(r.editor.value)?r.editor.value():null,column:a,row:this.#a,data:this.#a?this.#a.data:null,locale:this.#e.get("locale")})),(o===""||o==null)&&M(r.editor.toClipboard)&&(o=r.editor.toClipboard())}catch{o=""}const l=o===""||o==null;r.opener.textContent=l?this.#p("form.choose"):String(o),r.opener.classList.toggle(`${S}__opener--empty`,l)}#x(r,o,l){const a=r.editor||r.type||r.lookup||r.props;if(o&&!a)return o;const p={...o&&o.edit?o.edit:{}};return r.editor&&(p.editor=r.editor),r.props&&(p.props=r.props),{...o||{id:l,field:l},type:r.type||o&&o.type||"text",lookup:r.lookup||o&&o.lookup||void 0,edit:p}}#W(r){for(const o of this.#e.columns.all())if(!o.generated&&o.field===r)return o;return null}#R(){for(const r of this.#u)M(r.editor.destroy)&&r.editor.destroy();this.#u=[]}destroy(){this.#d+=1,this.#S(),this.#R();for(const r of this.#m)r();this.#m=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Ce("packages/dom/src/toolpanelmount.js",function(e,G){"use strict";Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return b}}),Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return g}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,R=G("packages/dom/src/ui/toolpanel.js"),W=R.ToolPanel,Z=R.toolPanels,V=R.toolPanelTitles,U=R.toolPanelIcons,I=G("packages/dom/src/filters/index.js").createFilter,k=G("packages/dom/src/editors/common.js"),S=k.CLS,y=k.documentFor,d=k.scannableRows,u=G("packages/dom/src/filtermenu.js"),n=u.mergeColumnFilter,t=u.branchFor,i=Object.freeze(["column:visible","column:moved","column:pinned","column:grouped","column:pivoted","filter:changed","model:changed","views:changed","sort:changed","history:changed","state:reset","cell:changed","formatting:changed"]);function s(f){const{grid:w,container:v}=f||{};if(!w)throw new Error("[lattice] mountPanel needs a grid");if(!v||!v.appendChild)throw new Error("[lattice] mountPanel needs a container element");const h=M(f.panel)?f.panel:Z[String(f.panel)];if(!h)throw new Error(`[lattice] unknown panel "${f.panel}"; known panels are ${Object.keys(Z).join(", ")}`);const c=v.ownerDocument||y(v),j=b(w,c,f.announce),E=new h;E.init({document:c,host:j,grid:w,props:f.props||{}});const O=E.element();v.appendChild(O);const T=[];for(const A of i)M(w.on)&&T.push(w.on(A,()=>E.refresh()));return{element:O,refresh(){E.refresh()},destroy(){for(const A of T)A();T.length=0,M(E.destroy)&&E.destroy(),O&&O.parentNode&&O.parentNode.removeChild(O)}}}const r=260,o=30,l=`${S.panel}-dock`;function a(f,w,v){if(!f||!M(f.set))return;const h=t(v.filters.get(),w)||null,c=M(f.get)&&(!M(f.active)||f.active())&&f.get()||null;JSON.stringify(c)!==JSON.stringify(h)&&(h?f.set(h):M(f.clear)?f.clear():f.set(null))}function p(f,w){if(f==="insights"){const c=w&&M(w.get)?w.get("insights"):null;return{other:(c&&typeof c=="object"?c:{}).compareWith||null}}if(f!=="views")return{};const v=w&&M(w.get)?w.get("views"):null,h=v&&typeof v=="object"?v:{};return{allowSave:h.allowSave!==!1,showDiff:h.showDiff===!0,builtinTitle:h.builtinTitle,savedTitle:h.savedTitle}}function m(f){const w=f.pagination&&M(f.pagination.get)?f.pagination.get():null;return w&&Number.isFinite(w.total)?w.total:f.rows.count()}function b(f,w,v){const h=new Map;return{announce(c,j){M(v)&&v(c,j)},t(c,j){return f.messages.t(c,j)},grid:f,document:w,columns:()=>f.columns.all(),showColumns:c=>f.columns.show(c),hideColumns:c=>f.columns.hide(c),groupBy:()=>f.state.get().group||[],setGroupBy:c=>f.columns.group(c),pivotBy:()=>(f.state.get().pivot||{}).columns||[],setPivotBy:c=>f.columns.pivot(c),valueColumns:()=>f.columns.all().filter(c=>c.total).map(c=>c.id),setValueColumns:c=>f.columns.totals(c),valueAggregation(c){const j=f.columns.get(c);return!j||!j.total?"sum":typeof j.total=="string"?j.total:"custom"},setValueAggregation(c,j){f.columns.setTotal(c,j)},quickFilter:()=>f.state.get().quick||"",setQuickFilter:c=>f.filters.quick(c),rowCount:()=>m(f),totalRowCount:()=>M(f.rows.totalCount)?f.rows.totalCount():f.rows.count(),formattableColumns:()=>f.columns.visible().filter(c=>!c.generated).map(c=>({id:c.id,title:String(c.title??c.id)})),formattingRules:c=>f.formatting.list(c),columnSamples:c=>{let j=c;if(!j||j==="*"){const T=f.columns.visible().find(A=>!A.generated);j=T?T.id:null}if(!j)return[];const E=[],O=new Set;for(const T of d(f)){const A=f.rows.value(T.key,j);if(A==null||A==="")continue;const P=typeof A=="object"?E.length:A;if(!O.has(P)&&(O.add(P),E.push(A),E.length>=24))break}return E},profilableColumns:()=>f.columns.visible().filter(c=>!c.generated).map(c=>({id:c.id,title:String(c.title??c.id)})),columnProfile:c=>f.statistics.profile(c),reduceColumn:(c,j)=>f.statistics.reduce(c,j),columnCapability:c=>f.statistics.capability(c),regressionModel:c=>M(f.statistics.regressionModel)?f.statistics.regressionModel(c):null,insightsColumns:()=>f.columns.visible().filter(c=>!c.generated).map(c=>({id:c.id,title:String(c.title??c.id),type:c.type})),subsetVsPopulation:()=>f.statistics.subsetVsPopulation(),datasetVsDataset:c=>f.statistics.datasetVsDataset(c),compareGroups:(c,j)=>f.statistics.compareGroups(c,j),anomalies:c=>f.statistics.anomalies(c||{}),compareColumns:(c,j)=>{if(!c||!j||c===j)return null;const E=f.statistics.regression(c,j);return{n:E?E.n:0,pearson:f.statistics.correlation(c,j),spearman:f.statistics.spearman(c,j),kendall:f.statistics.kendall(c,j),covariance:f.statistics.covariance(c,j),slope:E?E.slope:null,intercept:E?E.intercept:null,r2:E?E.r2:null,stdError:E?E.stdError:null,weighted:f.statistics.weightedAverage(c,j)}},addRule:(c,j)=>f.formatting.add(c,j),removeRule:(c,j)=>f.formatting.remove(c,j),updateRule:(c,j,E)=>f.formatting.update(c,j,E),moveRule:(c,j,E)=>f.formatting.move(c,j,E),clearRules:c=>f.formatting.clear(c),views:()=>f.views.list(),activeId:()=>f.views.activeId,apply:c=>{f.views.apply(c)},saveAs:c=>f.views.save(c),rename:(c,j)=>f.views.rename(c,j),setDefault:c=>f.views.setDefault(c),clearDefault:()=>f.views.setDefault(null),remove:c=>f.views.remove(c),export:c=>f.views.export(c),diff:c=>f.views.diff(c),moveColumn(c,j,E){const O=f.columns.all().map(L=>L.id),T=O.indexOf(c),A=O.indexOf(j);if(T<0||A<0)return;let P=E?A:A+1;T<P&&(P-=1),P!==T&&f.columns.move(c,P)},isFiltered(c){return t(f.filters.get(),c)!==null},clearFilter(c){f.filters.set(n(f.filters.get(),c,null));const j=h.get(c);j&&M(j.clear)?j.clear():j&&M(j.set)&&j.set(null)},clearAllFilters(){f.filters.set(null);for(const c of h.values())M(c.clear)?c.clear():M(c.set)&&c.set(null)},filterFor(c){if(h.has(c))return a(h.get(c),c,f),h.get(c);const j=f.columns.get(c);if(!j)return null;const E=I({grid:f,column:j,colId:c,type:j.type,locale:f.get("locale"),props:{...j.filter&&j.filter.props,values:j.filter&&j.filter.props&&j.filter.props.values||(j.lookup?void 0:()=>f.columns.distinct(c))},lookup:j.lookup,document:w,value:O=>f.rows.value(O.row&&O.row.key,c),rows:j.lookup?void 0:()=>d(f),changed:()=>{const T=(M(E.active)?E.active():!0)&&M(E.get)?E.get():null;f.filters.set(n(f.filters.get(),c,T||null))}});return E&&(a(E,c,f),h.set(c,E)),E},destroyFilters(){for(const c of h.values())M(c.destroy)&&c.destroy();h.clear()}}}class g{#e;#t;#n;#r;#o;#i=null;#s=[];#l="right";#a=null;#u=!1;#c=!1;constructor(w){this.#e=w.grid,this.#t=w.document,this.#n=w.root,this.#o=b(w.grid,w.document,w.announce);const h=(w.panels||["columns","filters"]).map(c=>Z[c]?{name:c,title:V[c]?w.grid.messages.t(V[c]):c,icon:U[c]||c,Ctor:Z[c],props:p(c,w.grid)}:($(`toolpanel:${c}`,`unknown tool panel "${c}"`),null)).filter(Boolean);this.#l=w.side==="left"?"left":"right",this.#r=new W,this.#r.init({document:w.document,host:this.#o,grid:w.grid,panels:h,actions:w.actions,icons:w.icons,side:this.#l,openPanel:w.openPanel})}mount(){const w=this.#t.createElement("div");w.className=`${l} ${l}--${this.#l}`,w.appendChild(this.#r.element()),this.#n.appendChild(w),this.#i=w;const v=this.#r.show.bind(this.#r),h=this.#r.hide.bind(this.#r);this.#r.show=c=>{const j=v(c);return this.#f(),j},this.#r.hide=()=>{h(),this.#f()};for(const c of[...i,"rows:paused","rows:resumed","rows:queued","annotation:changed"])this.#s.push(this.#e.on(c,()=>this.#r.refresh()));this.#s.push(this.#e.on("presentation:started",c=>{this.#u=!0;const j=c&&c.options&&Array.isArray(c.options.chrome)?c.options.chrome:[];this.#c=j.includes("toolPanel")})),this.#s.push(this.#e.on("presentation:ended",()=>{this.#u=!1,this.#c=!1})),this.#s.push(this.#e.on("toolpanel:focus",()=>this.open("columns"))),this.#s.push(this.#e.on("column:profile:open",c=>{const j=c&&c.colId,E=this.#r.panels.find(O=>O.name==="statistics");E&&j!=null&&(E.panel.column=String(j)),this.open("statistics")})),this.#f()}open(w){this.#r.show(w),this.#f()}close(){this.#r.hide(),this.#f()}toggle(w){this.#r.toggle(w),this.#f()}addAction(w){if(!(!w||!w.name)&&!this.#r.actions.some(v=>v.name===w.name)){if(this.#r.registerAction(w),this.#a&&!w.annotation){const v=this.#r.actions.find(h=>h.name===w.name);v&&this.#h(v.button)}else!this.#a&&w.annotation&&this.#u&&!this.#c&&this.#d();this.#f()}}removeAction(w){this.#r.removeAction(w)&&this.#f()}presentOnly(){return this.#a?!0:this.#r.actions.some(w=>w.annotation&&w.button)?(this.#d(),!0):!1}#d(){const w=this.#r;this.#a={hidden:[],reopen:w.openPanel||null},this.#a.reopen&&w.hide(),this.#h(w.body);for(const v of[...w.tabs?.children||[]])v!==w.actionGroup&&this.#h(v);for(const v of[...w.actionGroup?.children||[]]){const h=w.actions.find(c=>c.button===v);(!h||!h.annotation)&&this.#h(v)}this.#i&&this.#i.style&&(this.#i.style.display=""),this.#f()}presentRestore(){const w=this.#a;if(!w)return!1;this.#a=null;for(const 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.#a)return;const v=w.style.display||"";v!=="none"&&(w.style.display="none",this.#a.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?`${r}px`:"";const v=`${w?r:this.#m()}px`;this.#n.style.paddingLeft=this.#l==="left"?v:"",this.#n.style.paddingRight=this.#l==="left"?"":v,this.#n.style.setProperty("--lattice-dock-left",this.#l==="left"?v:"0px"),this.#n.style.setProperty("--lattice-dock-right",this.#l==="left"?"0px":v)}#m(){const w=this.#r&&M(this.#r.element)?this.#r.element().querySelector?.(`.${S.panel}__tabs`):null,v=w&&(w.offsetWidth||w.getBoundingClientRect?.().width)||0;return v>0?Math.ceil(v):o}destroy(){for(const w of this.#s)w();this.#s=[],this.#a=null,this.#o.destroyFilters(),this.#r.destroy(),this.#i&&this.#i.remove&&this.#i.remove(),this.#i=null,this.#n.style.paddingRight=""}}}),Ce("packages/dom/src/celledit.js",function(e,G){"use strict";Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return S}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/dom/src/editors/index.js").createEditor,Z=G("packages/dom/src/editors/common.js"),V=Z.CLS,U=Z.markInvalid,I=G("packages/dom/src/detailhost.js").insideDetail,k=`${V.editor}-host`;class S{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=-1;#u=[];#c=null;#d=!1;constructor(t){this.#e=t.grid,this.#t=t.document,this.#n=t.renderer,this.#r=t.registry||null,this.#o=t.cellLayer||null}mount(){this.#u.push(this.#e.on("cell:edit:start",a=>this.open(a))),this.#u.push(this.#e.on("cell:edit:end",()=>this.close()));const t=this.#n.viewport.root,i=this.#e.get("edit"),s=i&&typeof i=="object"&&i.start||"double",r=a=>{if(I(a.target,t))return;const p=y(a.target,w=>w.getAttribute&&w.getAttribute("data-col"));if(!p)return;const m=y(p,w=>w.getAttribute&&w.getAttribute("data-key"));if(!m)return;const b=this.#e.rows.byKey(m.getAttribute("data-key"));if(!b||b.group)return;const g=p.getAttribute("data-col"),f=this.#e.columns.get(g);!f||!f.edit||!f.edit.enabled||this.#e.edit.start(b.key,g)},o=s==="key"?null:s==="single"?"click":"dblclick";o&&(t.addEventListener(o,r),this.#u.push(()=>t.removeEventListener(o,r)));const l=a=>{!this.#i||!this.#l||this.#m(a.target)||this.commit()};this.#t.addEventListener("mousedown",l,!0),this.#u.push(()=>this.#t.removeEventListener("mousedown",l,!0))}get target(){return this.#l}open(t){this.close();const i=t.key||t.row&&t.row.key,s=t.colId;if(!i||!s)return;const r=this.#e.columns.get(s),o=this.#e.rows.byKey(i);if(!r||!o)return;const l=this.#b(i,s);if(this.#c=l,!l){$("celledit.offscreen","cannot edit a row that is not rendered; scroll to it first.");return}const a=this.#e.permissions,p=!!(a&&M(a.isSecret)&&a.isSecret(s)),m=W({grid:this.#e,column:r,colId:s,row:o,data:o.data,value:p?null:this.#e.rows.value(i,s),text:p?"":this.#e.rows.text(i,s),locale:this.#e.get("locale"),props:r.edit&&r.edit.props,lookup:r.lookup,document:this.#t,cell:l,overlay:this.#n.viewport.overlays,onCommit:f=>this.#f({value:f,key:i,colId:s}),onCancel:()=>{this.#d=!0,this.#e.edit.stop(!0)},stop:f=>{this.#d||this.#e.edit.stop(f)}},this.#r);if(!m){$(`celledit.noeditor:${s}`,`column "${s}" has no editor.`);return}this.#i=m,this.#s=l,this.#l={key:i,colId:s},this.#d=!1,this.#a=this.#w(l);const b=m.element();m.popup?(this.#n.viewport.overlays.appendChild(b),d(b,l,this.#n.viewport.root)):l.replaceChildren(b),l.classList.add(k),M(m.attached)&&m.attached(),u(b);const g=f=>this.#h(f);b.addEventListener("keydown",g),this.#u.push(()=>b.removeEventListener("keydown",g))}#h(t){const i=t.key;if(i!=="Enter"&&i!=="Tab"&&i!=="Escape")return;if(t.preventDefault(),t.stopPropagation(),i==="Escape"){this.#e.edit.stop(!0);return}const s=i==="Enter"?this.#p(t.shiftKey?-1:1):this.#g(t.shiftKey?-1:1);this.commit()&&s&&this.#e.edit.start(s.key,s.colId)}#f(t){this.#d||(this.#d=!0,this.#e.edit.stop(!1,t))}commit(){if(!this.#i||!this.#l)return!1;if(this.#d)return!0;if(M(this.#i.cancelOnClose)&&this.#i.cancelOnClose()===!0)return this.#d=!0,this.#e.edit.stop(!0),!0;const{key:t,colId:i}=this.#l;if(M(this.#i.value)){const s=this.#i.value();if(M(this.#i.validate)){const r=this.#i.validate(s);if(r!==!0){if(U(this.#c,r),M(this.#i.focusTarget)){const o=this.#i.focusTarget();o&&M(o.focus)&&o.focus()}return!1}U(this.#c,null)}this.#f({value:s,key:t,colId:i})}else this.#d=!0,this.#e.edit.stop(!1);return!0}#m(t){if(!t)return!1;const i=M(this.#i.element)?this.#i.element():null;if(i&&M(i.contains)&&i.contains(t))return!0;const s=this.#c;return!!(s&&M(s.contains)&&s.contains(t))}#p(t){if(!this.#l||this.#a<0)return null;for(let i=this.#a+t;i>=0&&i<this.#e.rows.count();i+=t){const s=this.#e.rows.get(i);if(s&&!s.group)return{key:s.key,colId:this.#l.colId}}return null}#g(t){if(!this.#l)return null;const i=this.#e.columns.visible(),s=i.findIndex(r=>r.id===this.#l.colId);for(let r=s+t;r>=0&&r<i.length;r+=t){const o=i[r];if(o.edit&&o.edit.enabled)return{key:this.#l.key,colId:o.id}}return null}#w(t){const i=y(t,r=>r.getAttribute&&r.getAttribute("data-index"));if(!i)return-1;const s=Number(i.getAttribute("data-index"));return Number.isFinite(s)?s:-1}#b(t,i){const s=this.#n.viewport.root;if(!s||!s.querySelectorAll)return null;for(const r of s.querySelectorAll(`[data-col="${i}"]`)){const o=y(r,l=>l.getAttribute&&l.getAttribute("data-key"));if(o&&o.getAttribute("data-key")===t)return r}return null}close(){this.#c&&U(this.#c,null);const t=this.#v();if(this.#i&&M(this.#i.destroy)&&this.#i.destroy(),this.#s){if(this.#s.classList.remove(k),this.#o&&M(this.#o.releaseCell)){const i=this.#l?this.#e.columns.get(this.#l.colId):null;this.#o.releaseCell(this.#s,i)}this.#s.replaceChildren&&this.#s.replaceChildren(),t&&this.#y(this.#s),this.#n.refresh({force:!0})}this.#i=null,this.#c=null,this.#s=null,this.#l=null,this.#a=-1,this.#d=!1}#v(){const t=this.#t.activeElement;if(!t||t===this.#t.body)return!1;const i=this.#i&&M(this.#i.element)?this.#i.element():null,s=r=>!!r&&M(r.contains)&&r.contains(t);return s(i)||s(this.#s)}#y(t){const s=M(t.hasAttribute)&&t.hasAttribute("tabindex")?t:this.#n.viewport.root;s&&M(s.focus)&&s.focus()}destroy(){this.close();for(const t of this.#u)t();this.#u=[]}}function y(n,t){let i=n;for(;i;){if(t(i))return i;i=i.parentNode}return null}function d(n,t,i){if(!M(t.getBoundingClientRect))return;const s=t.getBoundingClientRect(),r=i.getBoundingClientRect();n.style.position="absolute",n.style.top=`${Math.round(s.top-r.top)}px`,n.style.minWidth=`${Math.round(s.width)}px`,n.style.left=`${Math.round(s.left-r.left)}px`;const o=n.offsetWidth||Math.round(s.width),l=Math.round(s.left-r.left)+o-Math.round(r.width);l>0&&(n.style.left=`${Math.max(0,Math.round(s.left-r.left)-l)}px`)}function u(n){const t=n.querySelector&&n.querySelector("input, select, textarea, [tabindex]")||n;M(t.focus)&&t.focus(),M(t.select)&&t.select()}}),Ce("packages/dom/src/editbar.js",function(e,G){"use strict";Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return D}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/dom/src/editors/index.js").createEditor,U=`${G("packages/dom/src/editors/common.js").CLS.editor}-bar`;class D{#e;#t;#n;#r=null;#o=null;#i=null;#s=null;#l=null;#a=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,S=k.createElement("div");S.className=U;const y=k.createElement("span");y.className=`${U}__ref`,y.textContent="";const d=k.createElement("div");d.className=`${U}__slot`;const u=k.createElement("span");u.className=`${U}__readonly`,S.appendChild(y),S.appendChild(d),this.#n.insertBefore(S,this.#n.firstChild),this.#r=S,this.#o=y,this.#i=d,this.#l=u;for(const n of["cell:clicked","cell:edit:start","selection:changed","model:changed","rows:changed"])this.#d.push(this.#e.on(n,t=>this.#f(t)))}bind(k,S){const y=this.#e.columns.get(S),d=k?this.#e.rows.byKey(k):null;this.#a=d&&y&&!d.group?{key:k,colId:S}:null,this.refresh()}refresh(){if(!this.#i||this.#u)return;if(this.#h(),!this.#a){this.#o.textContent="";return}const{key:k,colId:S}=this.#a,y=this.#e.columns.get(S);if(!y)return;if(this.#o.textContent=y.title||S,!!!(y.edit&&y.edit.enabled)){this.#l.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#l);return}const u=this.#e.rows.byKey(k);if(!u)return;const n=W({grid:this.#e,column:y,colId:S,row:u,data:u.data,value:this.#e.rows.value(k,S),text:this.#e.rows.text(k,S),locale:this.#e.get("locale"),props:y.edit&&y.edit.props,lookup:y.lookup,document:this.#t,cell:this.#i,overlay:this.#n,stop:o=>o?this.cancel():this.commit(!0)});if(!n){$(`editbar.noeditor:${S}`,`column "${S}" has no editor.`),this.#l.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#l);return}this.#s=n;const t=n.element();n.popup?(this.#l.textContent=this.#e.rows.text(k,S),this.#i.appendChild(this.#l)):this.#i.appendChild(t),M(n.attached)&&n.attached();const i=o=>this.#m(o),s=()=>{this.#u=!0},r=[t,this.#i];for(const o of r)o.addEventListener("keydown",i),o.addEventListener("input",s),o.addEventListener("change",s);this.#c=()=>{for(const o of r)o.removeEventListener("keydown",i),o.removeEventListener("input",s),o.removeEventListener("change",s)}}#h(){this.#c&&(this.#c(),this.#c=null),this.#s&&M(this.#s.destroy)&&this.#s.destroy(),this.#s=null,this.#i&&this.#i.replaceChildren&&this.#i.replaceChildren()}cancel(){this.#u=!1,this.refresh()}#f(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.#a||!this.#u&&!k)return!1;const{key:S,colId:y}=this.#a;if(!this.#s||!M(this.#s.value))return!1;const d=this.#s.value();return this.#u=!1,this.#e.edit.start(S,y),this.#e.edit.stop(!1,{value:d,key:S,colId:y}),this.refresh(),!0}destroy(){this.#h();for(const k of this.#d)k();this.#d=[],this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#r=null,this.#i=null,this.#o=null,this.#a=null}}}),Ce("packages/dom/src/pastepreview.js",function(e,G){"use strict";Object.defineProperty(e,"PREVIEW_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"PastePreview",{enumerable:!0,get:function(){return I}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.clear,U="lat-pastepreview",D='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';class I{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=null;#a=null;#u=[];constructor(S){this.#e=S.grid,this.#t=S.renderer}get open(){return!!this.#n&&this.#n.style.display!=="none"}#c(S,y){const d=this.#e;return(d&&d.messages?d.messages:R).t(S,y)}#d(S){const y=`paste.preview.reason.${S}`,d=this.#c(y);return d===y?S:d}#h(S){return S==null||S===""?"":String(S)}#f(S,y){const d=this.#e.columns&&M(this.#e.columns.get)?this.#e.columns.get(y):null;return`${d&&(d.title||d.headerName)||y} · ${S}`}show(S,y){const d=this.#b();if(!d)return!1;this.#l=y&&y.onConfirm,this.#a=y&&y.onCancel||null;const u=S&&S.changes||[],n=S&&S.rejected||[],t=u.filter(s=>s.changed);this.#m(t,n);const i=d.ownerDocument;return this.#s=i&&i.activeElement,d.style.display="",M(d.focus)&&d.focus(),this.#y(this.#c("a11y.paste.previewOpened",{count:t.length,changes:t.length,rejected:n.length}),{repeat:!0}),!0}#m(S,y){const d=this.#r.ownerDocument;V(this.#r);const u=Z(d,"p",{class:`${U}__summary`,attrs:{role:"status"},text:this.#c("paste.preview.summary",{count:S.length,changes:S.length,rejected:y.length})});if(this.#r.appendChild(u),!S.length&&!y.length){this.#r.appendChild(Z(d,"p",{class:`${U}__empty`,text:this.#c("paste.preview.empty")})),this.#o.disabled=!S.length;return}this.#o.disabled=!S.length,S.length&&(this.#r.appendChild(Z(d,"h3",{class:`${U}__heading`,text:this.#c("paste.preview.changesHeading",{count:S.length})})),this.#r.appendChild(this.#p(d,S))),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(S,y){const d=Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colOld")}),Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colNew")})]}),u=y.map(n=>Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"row"},text:this.#f(n.key,n.colId)}),Z(S,"td",{class:`${U}__old`,text:this.#h(n.oldValue)}),Z(S,"td",{class:`${U}__new`,text:this.#h(n.newValue)})]}));return Z(S,"table",{class:`${U}__table`,children:[Z(S,"thead",{children:[d]}),Z(S,"tbody",{children:u})]})}#g(S,y){const d=Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colCell")}),Z(S,"th",{attrs:{scope:"col"},text:this.#c("paste.preview.colReason")})]}),u=y.map(n=>Z(S,"tr",{children:[Z(S,"th",{attrs:{scope:"row"},text:this.#f(n.key,n.colId)}),Z(S,"td",{class:`${U}__reason`,text:this.#d(n.reason)})]}));return Z(S,"table",{class:`${U}__table ${U}__table--rejected`,children:[Z(S,"thead",{children:[d]}),Z(S,"tbody",{children:u})]})}confirm(){const S=this.#l;this.#w(),M(S)&&S()}cancel(){const S=this.#a;this.#w(),this.#y(this.#c("a11y.paste.cancelled"),{repeat:!0}),M(S)&&S()}#w(){if(!this.#n)return;this.#n.style.display="none",this.#l=null,this.#a=null;const S=this.#s;this.#s=null,S&&M(S.focus)&&S.focus()}#b(){if(this.#n)return this.#n;const S=this.#t.viewport&&this.#t.viewport.overlays,y=S&&S.ownerDocument;if(!S||!y||!M(y.createElement))return null;const d=`${U}-title`,u=Z(y,"h2",{class:`${U}__title`,attrs:{id:d},text:this.#c("paste.preview.title")}),n=Z(y,"div",{class:`${U}__body`}),t=Z(y,"button",{class:`${U}__confirm`,attrs:{type:"button"},text:this.#c("paste.preview.confirm")}),i=Z(y,"button",{class:`${U}__cancel`,attrs:{type:"button"},text:this.#c("paste.preview.cancel")}),s=Z(y,"div",{class:`${U}__foot`,children:[i,t]}),r=Z(y,"div",{class:U,attrs:{role:"dialog","aria-modal":"true",tabindex:"-1","aria-labelledby":d},children:[Z(y,"div",{class:`${U}__head`,children:[u]}),n,s]});return S.appendChild(r),this.#n=r,this.#r=n,this.#o=t,this.#i=i,this.#v(r,t,i),r}#v(S,y,d){const u=i=>{if(i.stopPropagation(),i.key==="Escape"){i.preventDefault(),this.cancel();return}if(i.key!=="Tab")return;const s=[...S.querySelectorAll(D)].filter(a=>!a.disabled);if(!s.length){i.preventDefault();return}const r=s[0],o=s[s.length-1],l=S.ownerDocument.activeElement;i.shiftKey&&(l===r||l===S)?(i.preventDefault(),o.focus()):!i.shiftKey&&l===o&&(i.preventDefault(),r.focus())},n=i=>{i&&M(i.preventDefault)&&i.preventDefault(),this.confirm()},t=i=>{i&&M(i.preventDefault)&&i.preventDefault(),this.cancel()};S.addEventListener("keydown",u),y.addEventListener("click",n),d.addEventListener("click",t),this.#u.push(()=>{S.removeEventListener("keydown",u),y.removeEventListener("click",n),d.removeEventListener("click",t)})}#y(S,y){const d=this.#t&&this.#t.announce;M(d)&&d.call(this.#t,S,y)}destroy(){for(const S of this.#u)S();this.#u=[],this.#n&&this.#n.parentNode&&this.#n.parentNode.removeChild(this.#n),this.#n=null,this.#r=null,this.#o=null,this.#i=null,this.#s=null,this.#l=null,this.#a=null}}}),Ce("packages/dom/src/rangeselect.js",function(e,G){"use strict";Object.defineProperty(e,"RangeController",{enumerable:!0,get:function(){return r}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return o}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/core/src/model/selection.js"),Z=W.extendSeries,V=W.resolveSelectionConfig,U=G("packages/dom/src/renderer/textentry.js"),D=U.isTextEntry,I=U.isFindBarControl,S=G("packages/dom/src/pastepreview.js").PastePreview,y=G("packages/dom/src/columnmenu.js"),d=y.chartableRange,u=y.rangeChartConfig,n="lat-cell--range",t="lat-cell--range-edge",i=Object.freeze({top:"lat-cell--range-top",right:"lat-cell--range-right",bottom:"lat-cell--range-bottom",left:"lat-cell--range-left"}),s=3;class r{#e;#t;#n;#r=!1;#o=[];#i=null;#s=null;#l=null;#a=null;#u=null;constructor(a){this.#e=a.grid,this.#t=a.renderer,this.#n=a.document,this.#a=a.preview||null}mount(){const a=this.#t.viewport.root,p=f=>this.#c(f),m=f=>this.#d(f),b=()=>this.#h(),g=f=>this.#f(f);a.addEventListener("pointerdown",p),this.#n.addEventListener("pointermove",m),this.#n.addEventListener("pointerup",b),a.addEventListener("keydown",g),this.#o.push(()=>{a.removeEventListener("pointerdown",p),this.#n.removeEventListener("pointermove",m),this.#n.removeEventListener("pointerup",b),a.removeEventListener("keydown",g)});for(const f of["range:changed","rows:changed","model:changed","scroll"])this.#o.push(this.#e.on(f,()=>this.paint()));this.paint()}#c(a){if(a.button!==0)return;const p=a.target;if(!p||!M(p.closest))return;if(this.#r=!1,p.closest('[data-role="fill-handle"]')){if(this.#T())return;this.#i={mode:"fill",fromX:a.clientX,fromY:a.clientY,armed:!0};return}if(p.closest('[data-role="row-drag"]'))return;const m=this.#R(p);if(!m)return;if(a.shiftKey&&this.#e.selection.corner()){const g=this.#C(m);this.#e.selection.extendRange(g.rowIndex,g.colId),this.#i={mode:"select",fromX:a.clientX,fromY:a.clientY,armed:!0};return}const b=this.#E(m);this.#u=b,this.#e.selection.startRange(b.rowIndex,b.colId,{additive:a.ctrlKey||a.metaKey}),this.#i={mode:"select",fromX:a.clientX,fromY:a.clientY,armed:!1}}#d(a){const p=this.#i;if(!p)return;if(!p.armed){if(Math.abs(a.clientX-p.fromX)+Math.abs(a.clientY-p.fromY)<s)return;p.armed=!0}const m=this.#_(a.clientX,a.clientY);if(!m)return;if(p.mode==="fill"){this.#l=m,this.paint();return}const b=this.#C(m);this.#e.selection.extendRange(b.rowIndex,b.colId)}#h(){const a=this.#i;if(this.#i=null,!!a){if(a.mode==="fill"&&this.#l){const p=this.#l;this.#l=null,this.fillTo(p.rowIndex)}this.#l=null,this.paint()}}#f(a){if(this.#I()||I(a.target)||D(a.target))return;const p=a.ctrlKey||a.metaKey,m=a.key;if(p&&(m==="c"||m==="C")){this.copy(),a.preventDefault();return}if(p&&(m==="v"||m==="V")){this.paste(),a.preventDefault();return}if(p&&(m==="d"||m==="D")){this.fillDown(),a.preventDefault();return}if(m==="Delete"||m==="Backspace"){if(!this.#e.selection.cells().length&&this.#e.selection.keys().length&&this.#e.get("rowDelete")===!0){this.#e.edit.deleteRows(),a.preventDefault();return}this.clear(),a.preventDefault();return}if(a.altKey&&m==="F1"){this.chartSelection()&&a.preventDefault();return}if(!a.shiftKey)return;const b={ArrowDown:[1,0],ArrowUp:[-1,0],ArrowRight:[0,1],ArrowLeft:[0,-1]}[m];if(!b)return;if(p){const O=this.#W();if(!O)return;if(!this.#r){const z=this.#E(O);this.#u=z,this.#e.selection.startRange(z.rowIndex,z.colId,{additive:!0}),this.#r=!0}const T=this.#e.columns.visible().map(z=>z.id),A=T.indexOf(O.colId),P=this.#e.selection.corner()||{row:O.rowIndex,colId:O.colId},L=this.#C({rowIndex:Math.min(this.#e.rows.count()-1,Math.max(0,P.row+b[0])),colId:T[Math.min(T.length-1,Math.max(0,(A<0?0:A)+b[1]))]});this.#e.selection.extendRange(L.rowIndex,L.colId),a.preventDefault();return}this.#r=!1;const g=this.#e.selection.corner(),f=this.#W(),w=g||f;if(!w)return;if(!g&&f){const O=this.#E(f);this.#u=O,this.#e.selection.startRange(O.rowIndex,O.colId)}const v=this.#e.columns.visible().map(O=>O.id),h=v.indexOf(w.colId??w.colId),c=v[Math.min(v.length-1,Math.max(0,h+b[1]))],j=Math.min(this.#e.rows.count()-1,Math.max(0,(g?g.row:f.rowIndex)+b[0])),E=this.#C({rowIndex:j,colId:c});this.#e.selection.extendRange(E.rowIndex,E.colId),a.preventDefault()}async copy(){const a=this.#e.export.rangeText();if(!a)return this.#e.selection.ranges().length>1&&this.#e.emit("clipboard:copy",{text:"",ok:!1,rows:"range",reason:"discontiguous"},"user"),!1;const p=globalThis.navigator&&globalThis.navigator.clipboard;if(!p||!M(p.writeText))return!1;try{return await p.writeText(a),this.#e.emit("clipboard:copy",{text:a,ok:!0,rows:"range"},"user"),!0}catch{return this.#e.emit("clipboard:copy",{text:a,ok:!1,rows:"range"},"user"),!1}}async paste(){const a=globalThis.navigator&&globalThis.navigator.clipboard;if(!a||!M(a.readText))return 0;let p="";try{p=await a.readText()}catch{return 0}return this.pasteText(p)}pasteText(a){if(!a)return 0;const p=this.#e.selection.cells(),m=p.length?p[0]:this.#v();if(!m)return 0;const b=p.length>1?{rows:new Set(p.map(g=>g.key)).size,columns:new Set(p.map(g=>g.colId)).size}:void 0;if(this.#m()){const g=this.#e.edit.previewPaste(m,a,b);if(g.changes.length+g.rejected.length>1)return this.#p().show(g,{onConfirm:()=>this.#g(m,a,b)}),0}return this.#g(m,a,b)}#m(){const a=this.#e.edit;return!!(a&&a.pastePreview&&M(a.previewPaste))}#p(){return this.#a||(this.#a=new S({grid:this.#e,renderer:this.#t})),this.#a}#g(a,p,m){const b=this.#e.edit.pasteInto(a,p,m);return this.#b(b?this.#w("a11y.range.written",{count:b}):this.#w("a11y.range.refused"),{repeat:!0}),b}#w(a,p){const m=this.#e;return(m&&m.messages?m.messages:R).t(a,p)}#b(a,p){const m=this.#t&&this.#t.announce;M(m)&&m.call(this.#t,a,p)}#v(){const a=this.#W();if(!a)return null;const p=this.#e.rows.get(a.rowIndex);return p?{key:p.key,colId:a.colId}:null}clear(){const a=this.#e.selection.cells();return a.length?this.#e.edit.setCells(a.map(p=>({...p,value:null}))):0}fillDown(){if(this.#e.selection.ranges().length>1)return 0;const a=this.#e.selection.cells();if(a.length<2)return 0;const p=[...new Set(a.map(g=>g.key))];if(p.length<2)return 0;const m=p[0],b=[];for(const{key:g,colId:f}of a)g!==m&&b.push({key:g,colId:f,value:this.#e.rows.value(m,f)});return this.#e.edit.setCells(b)}chartSelection(){const a=u(this.#e);if(!a.handler)return!1;const p=d(this.#e);return p?(a.handler(this.#e,p),!0):!1}fillTo(a){if(this.#e.selection.ranges().length>1)return 0;const p=this.#e.selection.cells();if(!p.length)return 0;const m=[...new Set(p.map(c=>c.key))],b=[...new Set(p.map(c=>c.colId))],g=this.#x(m[m.length-1]);if(g<0||a<=g)return 0;const f=[];for(let c=g+1;c<=a;c++){const j=this.#e.rows.get(c);if(!j)break;f.push(j)}if(!f.length)return 0;const w=[];for(const c of b){const j=m.map(O=>this.#e.rows.value(O,c)),E=this.#y(j,f,c);for(let O=0;O<f.length;O++)w.push({key:f[O].key,colId:c,value:E[O]})}const v=this.#e.edit.setCells(w),h=this.#e.selection.corner();return h&&this.#e.selection.extendRange(a,h.colId),v}#y(a,p,m){const b=this.#e.get("selection"),g=b&&typeof b=="object"?b.fill:void 0;if(M(g)){const f=this.#e.columns.get(m),w=p.map(h=>({row:h,column:f})),v=g({source:a,target:w,direction:"down"});if(Array.isArray(v)&&v.length===p.length)return v}return Z(a,p.length)}paint(){const a=this.#t.viewport.root;if(!a||!a.querySelectorAll)return;const p=this.#e.selection,m=p.ranges().length>0,b=this.#l;for(const g of a.querySelectorAll("[data-col]")){const f=g.getAttribute("data-col"),w=g.parentNode,v=g.getAttribute?g.getAttribute("data-index"):null,h=v!==null&&v!==""?v:w&&w.getAttribute?w.getAttribute("data-index"):null;if(h===null||h==="")continue;const c=Number(h);if(!Number.isFinite(c)||c<0)continue;const j=m&&p.inRange(c,f),E=!!b&&this.#S(c,f,b);g.classList.toggle(n,j||E);const O=j||E?this.#A(c,f,p):null;g.classList.toggle(t,!!O&&O.any);for(const[T,A]of Object.entries(i))g.classList.toggle(A,!!O&&O[T])}this.#j()}#S(a,p,m){const b=this.#e.selection.cells();if(!b.length||!new Set(b.map(w=>w.colId)).has(p))return!1;const f=this.#x([...new Set(b.map(w=>w.key))].pop());return a>f&&a<=m.rowIndex}#A(a,p,m){const b=this.#e.columns.visible().map(h=>h.id),g=b.indexOf(p),f=g>0?b[g-1]:null,w=g>=0&&g<b.length-1?b[g+1]:null,v={top:!m.inRange(a-1,p),bottom:!m.inRange(a+1,p),left:!f||!m.inRange(a,f),right:!w||!m.inRange(a,w)};return v.any=v.top||v.bottom||v.left||v.right,v}#j(){const a=this.#e.selection.corner(),p=this.#t.viewport.overlays;if(!p)return;if(!a||this.#N()===!1||this.#e.selection.ranges().length>1||this.#T()){this.#s&&(this.#s.style.display="none");return}const m=this.#B(a.row,a.colId);if(!m||!M(m.getBoundingClientRect)){this.#s&&(this.#s.style.display="none");return}this.#s||(this.#s=this.#n.createElement("div"),this.#s.className="lat-fill-handle",this.#s.setAttribute("data-role","fill-handle"),this.#s.setAttribute("title",this.#w("a11y.fillHandle")),p.appendChild(this.#s));const b=m.getBoundingClientRect(),g=this.#t.viewport.root.getBoundingClientRect();this.#s.style.display="";const w=this.#t.viewport.rtl===!0?b.left:b.right;this.#s.style.left=`${Math.round(w-g.left)-4}px`,this.#s.style.top=`${Math.round(b.bottom-g.top)-4}px`}#O(a){const p=this.#t;return!a||typeof p.spanAt!="function"?null:p.spanAt(a.rowIndex,a.colId)}#E(a){const p=this.#O(a);return p?{rowIndex:p.row,colId:p.columnId}:a}#C(a){const p=this.#O(a);if(!p)return a;const m=this.#u,b=!!m&&m.rowIndex>=p.row+p.rows,g=this.#D(),f=m?g.indexOf(m.colId):-1,w=f>=0&&f>=p.col+p.cols;return{rowIndex:b?p.row:p.row+p.rows-1,colId:w?p.columnId:p.endColumnId}}#T(){const a=this.#e.selection.corner();if(!a)return!1;const p=this.#O({rowIndex:a.row,colId:a.colId});return!!p&&(p.rows>1||p.cols>1)}#D(){const a=this.#e.columns;return a&&M(a.visible)?a.visible().map(p=>p.id):[]}#N(){return V(this.#e.get("selection")).fillHandle}#I(){const a=this.#t.viewport.root;return!!(a&&a.querySelector&&a.querySelector(".lat-editor-host, .lat-editor--popup"))}#M(){const a=this.#e.selection.cells();return a.length?a[0]:null}#x(a){for(let p=0;p<this.#e.rows.count();p++){const m=this.#e.rows.get(p);if(m&&m.key===a)return p}return-1}#W(){const a=this.#t.viewport.root,p=a&&a.querySelector?a.querySelector('[data-col][tabindex="0"]'):null;return p?this.#R(p):null}#R(a){if(!a||!M(a.closest))return null;const p=a.closest("[data-col]");if(!p||!p.classList.contains("lat-cell"))return null;const m=p.closest("[data-index]");if(!m)return null;const b=Number(m.getAttribute("data-index"));return!Number.isFinite(b)||b<0?null:{rowIndex:b,colId:p.getAttribute("data-col")}}#_(a,p){const m=this.#n.elementFromPoint?this.#n.elementFromPoint(a,p):null;return m?this.#R(m):null}#B(a,p){const m=this.#t.viewport.root;if(!m||!m.querySelectorAll)return null;for(const b of m.querySelectorAll(`[data-col="${p}"]`)){const g=b.closest?b.closest("[data-index]"):null;if(g&&Number(g.getAttribute("data-index"))===a)return b}return null}destroy(){for(const a of this.#o)a();this.#o=[],this.#s&&M(this.#s.remove)&&this.#s.remove(),this.#s=null,this.#i=null,this.#l=null,this.#a&&M(this.#a.destroy)&&this.#a.destroy(),this.#a=null}}const o=r}),Ce("packages/dom/src/importer.js",function(e,G){"use strict";Object.defineProperty(e,"IMPORT_DIALOG_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"ImportController",{enumerable:!0,get:function(){return r}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/core/src/import/index.js"),Z=W.parseDelimited,V=W.inferColumns,U=W.mapRecords,D=W.readXlsx,I=W.looksLikeXlsx,k=G("packages/dom/src/editors/common.js"),S=k.el,y=k.clear,d=k.on,n=G("packages/dom/src/renderer/textentry.js").isTextEntry,t="lat-import",i='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])',s=".csv,.tsv,.txt,.xlsx,text/csv,text/tab-separated-values,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";class r{#e;#t;#n;#r;#o=[];#i=null;#s=null;#l=null;#a=null;constructor(l){this.#e=l.grid,this.#t=l.renderer,this.#n=l.document;const a=l.settings&&typeof l.settings=="object"?l.settings:{};this.#r={file:a.file!==!1,drop:a.drop!==!1,paste:a.paste!==!1,mode:a.mode==="replace"?"replace":"append"},this.#u()}#u(){const l=this.#t&&this.#t.viewport?this.#t.viewport.root:null;l&&(this.#r.drop&&(this.#o.push(d(l,"dragover",a=>{a.dataTransfer&&[...a.dataTransfer.types||[]].includes("Files")&&(a.preventDefault(),l.classList.add("lat-import--dropzone"))})),this.#o.push(d(l,"dragleave",()=>l.classList.remove("lat-import--dropzone"))),this.#o.push(d(l,"drop",a=>{l.classList.remove("lat-import--dropzone");const p=a.dataTransfer&&a.dataTransfer.files&&a.dataTransfer.files[0];p&&(a.preventDefault(),this.#c(p))}))),this.#r.paste&&this.#o.push(d(l,"paste",a=>{if(n(a.target)||this.#e.edit.isEditing?.()||this.#e.selection&&this.#e.selection.cells().length)return;const p=a.clipboardData&&a.clipboardData.getData("text/plain");!p||!p.includes(`
56
- `)||(a.preventDefault(),this.fromText(p))})))}openFile(){const l=S(this.#n,"input",{attrs:{type:"file",accept:s}});l.style.display="none",this.#o.push(d(l,"change",()=>{const a=l.files&&l.files[0];a&&this.#c(a),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(M(l.arrayBuffer)){l.arrayBuffer().then(p=>{const m=new Uint8Array(p);if(I(m)){this.fromXlsx(m,l.name);return}this.fromText(new TextDecoder().decode(m),l.name)});return}if(M(l.text)){l.text().then(p=>this.fromText(p,l.name));return}const a=new this.#n.defaultView.FileReader;a.onload=()=>this.fromText(String(a.result||""),l.name),a.readAsText(l)}async fromXlsx(l,a){const{header:p,rows:m}=await D(l);if(!p.length)return;const b=V(p,m,{columns:this.#e.columns.all()}),g=m.filter(f=>f.length!==p.length).length;this.#l={rows:m,columns:b,delimiter:null,name:a,warnings:g?[`${g} row(s) do not have ${p.length} columns`]:[]},this.#d()}fromText(l,a){const{header:p,rows:m,delimiter:b}=Z(l);if(!p.length)return;const g=V(p,m,{columns:this.#e.columns.all()}),f=m.filter(w=>w.length!==p.length).length;this.#l={rows:m,columns:g,delimiter:b,name:a,warnings:f?[`${f} row(s) do not have ${p.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(i);l&&M(l.focus)&&l.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(l,a){const p=this.#t&&this.#t.announce;M(p)&&p.call(this.#t,l,a)}#f(l,a){return(this.#e&&this.#e.messages?this.#e.messages:R).t(l,a)}#m(){const l=this.#n,a=S(l,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),p=S(l,"div",{class:`${t}__panel`});p.appendChild(S(l,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#s=S(l,"div",{class:`${t}__body`}),p.appendChild(this.#s);const m=S(l,"div",{class:`${t}__footer`}),b=S(l,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),g=S(l,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(d(b,"click",()=>this.close())),this.#o.push(d(g,"click",()=>this.#g())),m.appendChild(b),m.appendChild(g),p.appendChild(m),a.appendChild(p),this.#o.push(d(a,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...a.querySelectorAll(i)].filter(j=>!j.hidden);if(!v.length)return;const h=v[0],c=v[v.length-1];w.shiftKey&&this.#n.activeElement===h?(w.preventDefault(),c.focus()):!w.shiftKey&&this.#n.activeElement===c&&(w.preventDefault(),h.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(a),this.#i=a}#p(){const l=this.#n,a=y(this.#s),{rows:p,columns:m,name:b,warnings:g}=this.#l;a.appendChild(S(l,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:p.length,name:b||this.#f("import.clipboard")})}));for(const j of g)a.appendChild(S(l,"p",{class:`${t}__warning`,text:j}));const f=this.#e.columns.all().map(j=>j.field||j.id).filter(Boolean),w=S(l,"table",{class:`${t}__map`}),v=S(l,"tr",{});for(const j of["import.colSource","import.colField","import.colType"])v.appendChild(S(l,"th",{text:this.#f(j)}));w.appendChild(v),m.forEach((j,E)=>{const O=S(l,"tr",{});O.appendChild(S(l,"td",{text:j.source}));const T=S(l,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:j.source})}});T.appendChild(S(l,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of f)T.appendChild(S(l,"option",{text:P,attrs:{value:P,selected:P===j.field?!0:null}}));j.field&&!f.includes(j.field)&&T.appendChild(S(l,"option",{text:j.field,attrs:{value:j.field,selected:!0}}));const A=S(l,"td",{});A.appendChild(T),O.appendChild(A),O.appendChild(S(l,"td",{class:`${t}__type`,text:j.type})),w.appendChild(O)}),a.appendChild(w);const h=S(l,"div",{class:`${t}__mode`}),c=S(l,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});c.appendChild(S(l,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),c.appendChild(S(l,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),h.appendChild(S(l,"label",{text:this.#f("import.modeLabel")})),h.appendChild(c),a.appendChild(h)}#g(){const{rows:l,columns:a}=this.#l;for(const f of this.#i.querySelectorAll("select[data-col]")){const w=Number(f.getAttribute("data-col"));a[w]&&f.value!==void 0&&f.value!==null&&(a[w].field=f.value)}const p=this.#i.querySelector("select[data-mode]"),m=p?p.value:void 0,b=m==="replace"||m==="append"?m:this.#r.mode,g=U(l,a);this.#e.import.apply(g,{mode:b}),this.close(),this.#h(this.#f("import.done",{count:g.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&M(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Ce("packages/dom/src/historybar.js",function(e,G){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.on,U=W.clear,D=W.documentFor,I="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(d,u){return(this.messages&&typeof this.messages.t=="function"?this.messages:R).t(d,u)}init(d){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||R;const u=d||{};if(this.doc=D(u),this.host=u.host||{},this.props=u.props||{},this.root=Z(this.doc,"div",{class:["lattice-tokens",I],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const n=Z(this.doc,"button",{class:`${I}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(V(n,"click",()=>this.toggle())),this.root.appendChild(n),this.toggleButton=n,this.menu=Z(this.doc,"div",{class:`${I}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(d,u,n){const t=Z(this.doc,"button",{class:`${I}__${d}`,attrs:{type:"button"},children:[Z(this.doc,"span",{class:`${I}__glyph`,text:n,attrs:{"aria-hidden":"true"}}),Z(this.doc,"span",{class:`${I}__label`,text:u})]});return this.off.push(V(t,"click",()=>{const i=this.host[d];M(i)&&i(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const d=this.host,u=M(d.canUndo)?d.canUndo():!1,n=M(d.canRedo)?d.canRedo():!1,t=M(d.peek)?d.peek("undo"):null,i=M(d.peek)?d.peek("redo"):null;this.#t(this.undoButton,"undo",u,t),this.#t(this.redoButton,"redo",n,i),this.open&&this.#n()}#t(d,u,n,t){if(!d)return;d.disabled=!n;const i=u==="undo",s=this.t(i?"history.undo":"history.redo"),r=d.querySelector(`.${I}__label`);r&&(r.textContent=s);const o=t&&t.label?this.t("history.described",{action:s,label:t.label}):s;d.setAttribute("title",n?o:this.t(i?"history.nothingToUndo":"history.nothingToRedo")),d.setAttribute("aria-label",n?o:this.t(i?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const d=this.menu;if(!d)return;U(d);const u=M(this.host.list)?this.host.list():[];if(!u.length){d.appendChild(Z(this.doc,"p",{class:`${I}__empty`,text:this.t("history.empty")}));return}u.forEach((n,t)=>{const i=Z(this.doc,"button",{class:`${I}__item`,attrs:{type:"button",role:"menuitem","data-type":n.type,"data-undone":n.undone?"true":null},children:[Z(this.doc,"span",{class:`${I}__kind`,text:n.type}),Z(this.doc,"span",{class:`${I}__text`,text:n.label||n.type})]});this.off.push(V(i,"click",()=>{const s=t+1;for(let r=0;r<s;r++)M(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),d.appendChild(i)})}destroy(){for(const d of this.off)d();this.off=[],this.root&&M(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=k}),Ce("packages/dom/src/diffpaint.js",function(e,G){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,Z={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},V="lat-cell--changed",U="lat-cell--added-column";class D{#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,u=d&&d.enabled;for(const n of y.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key"),i=u?d.statusOf(t):"unchanged";for(const r of Object.values(Z))n.classList.remove(r);u&&Z[i]&&n.classList.add(Z[i]),n.setAttribute("data-diff",u?i:"");const s=u&&i==="changed";for(const r of n.querySelectorAll("[data-col]")){const o=r.getAttribute("data-col");if(r.classList.remove(V,U),r.removeAttribute("data-before"),!s)continue;const l=d.cellStatus(t,o);if(l==="changed"){r.classList.add(V);const a=this.#r(d,t,o);a===null?r.removeAttribute("title"):(r.setAttribute("data-before",a),r.setAttribute("title",this.#o("diff.before",{value:a})))}else l==="added-column"&&r.classList.add(U)}}}#r(y,d,u){const n=this.#e,t=n&&n.columns,i=t&&M(t.get)?t.get(u):null,s=n&&n.permissions;if(i&&s&&M(s.isSecret)&&s.isSecret(i))return null;const r=y.before(d,u);if(r==null)return this.#o("diff.empty");if(!i||!M(i.formatValue))return String(r);const o=M(y.beforeRow)?y.beforeRow(d):void 0,a={...(n.rows&&M(n.rows.byKey)?n.rows.byKey(d):null)||{},data:o===void 0?{}:o};try{const p=i.formatValue(r,a,a.data);return p==null?"":String(p)}catch(p){return $(`diff-before-format:${u}`,`the formatter for column "${u}" threw while formatting a previous value, so the diff hover shows the raw one.`,p),String(r)}}#o(y,d){const u=this.#e;return(u&&u.messages?u.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 u of Object.values(Z))d.classList.remove(u);d.removeAttribute("data-diff")}for(const d of y.querySelectorAll("[data-col]"))d.classList.remove(V,U),d.removeAttribute("data-before")}}}function I(S){return!!(S&&S.diff&&(M(S.diff)||typeof S.diff=="object"))}const k=D}),Ce("packages/dom/src/highlightpaint.js",function(e,G){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="lat-cell--highlight",R="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const U=()=>{this.#o=!1,this.paint()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):M(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const D=this.#l();if(D){D.sweep();for(const I of U.querySelectorAll("[data-key]")){const k=I.getAttribute("data-key");for(const S of I.querySelectorAll("[data-col]")){const y=D.active?D.colourFor(k,S.getAttribute("data-col")):null;y?(S.classList.add($),S.style.setProperty(R,y)):S.classList.contains($)&&(S.classList.remove($),S.style.removeProperty(R))}}this.#s(D)}}#s(U){this.#r!==null&&M(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const D=U.nextExpiry;if(!Number.isFinite(D)||!M(this.#i.setTimeout))return;const I=Math.max(0,D-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},I)}#l(){const U=this.#e.highlight;return U&&M(U.model)?U.model():null}destroy(){this.#r!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const D of this.#n)D();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const D of U.querySelectorAll(`.${$}`))D.classList.remove($),D.style.removeProperty(R)}}const Z=W}),Ce("packages/dom/src/findpaint.js",function(e,G){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="lat-cell--find",R="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const U=()=>{this.#r=!1,this.paint()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):M(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const D=this.#e.find;if(!D||!M(D.stateFor))return;const I=M(D.model)?D.model():null,k=!!I&&I.active;if(!k&&!this.#o)return;let S=!1;for(const y of U.querySelectorAll("[data-key]")){const d=y.getAttribute("data-key");for(const u of y.querySelectorAll("[data-col]")){const n=k?D.stateFor(d,u.getAttribute("data-col")):null;n?(S=!0,u.classList.add($),u.classList.toggle(R,n==="current")):u.classList.contains($)&&u.classList.remove($,R)}}this.#o=S}destroy(){for(const D of this.#n)D();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll)){for(const D of U.querySelectorAll(`.${$}`))D.classList.remove($,R);this.#o=!1}}}const Z=W}),Ce("packages/dom/src/findbar.js",function(e,G){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=G("packages/dom/src/editors/common.js"),M=_.el,$=_.on,W=G("packages/dom/src/renderer/textentry.js").isTextEntry,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction,I="lat-find",k=12,S=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#w=null;#b=null;#v=!1;constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document||n.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=n.settings&&typeof n.settings=="object"?n.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(n,t){const i=this.#e;return(i&&i.messages&&D(i.messages.t)?i.messages:V).t(n,t)}mount(){const n=this.#S();if(!n)return;n.attachUi({open:i=>this.show(i),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),n.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&D(t.addEventListener)&&this.#o.shortcut!==!1){const i=s=>{if(!(s.ctrlKey||s.metaKey)||s.altKey||s.shiftKey||s.key!=="f"&&s.key!=="F")return;const r=s.target;if(this.#s&&r===this.#s){s.preventDefault(),s.stopPropagation(),D(this.#s.select)&&this.#s.select();return}W(r)||(s.preventDefault(),s.stopPropagation(),this.show())};t.addEventListener("keydown",i,!0),this.#g.push(()=>t.removeEventListener("keydown",i,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(n){const t=this.#A();if(!t)return;const i=t.style.display!=="none";t.style.display="",i||this.#y(),this.#S().setOpen(!0),n!=null&&(this.#s.value=String(n),this.#E()),this.#s.focus(),D(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#x();const n=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),n&&(n.clear(),n.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&D(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const r=(D(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;D(r.focus)&&r.focus()}search(){this.#E()}destroy(){this.#v=!0,this.#x();for(const t of this.#g)t();this.#g=[];const n=this.#S();n&&(n.attachUi(null),n.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const n=this.#t;n&&D(n.invalidate)&&n.invalidate("size")}#S(){const n=this.#e&&this.#e.find;return n&&D(n.model)?n.model():null}#A(){if(this.#i)return this.#i;const n=this.#t.viewport,t=n?.root,i=this.#n;if(!t||!i||!D(t.insertBefore))return null;const s=M(i,"div",{class:I,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=M(i,"input",{class:`${I}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=M(i,"span",{class:`${I}__count`,attrs:{"aria-hidden":"true"}}),this.#a=M(i,"span",{class:`${I}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=M(i,"span",{class:`${I}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const r=M(i,"button",{class:`${I}__nav ${I}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),o=M(i,"button",{class:`${I}__nav ${I}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=M(i,"button",{class:`${I}__toggle ${I}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=M(i,"button",{class:`${I}__toggle ${I}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=M(i,"select",{class:`${I}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=M(i,"button",{class:`${I}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),a=M(i,"div",{class:`${I}__options`,children:[this.#c,this.#d,this.#h]});for(const m of[this.#s,this.#l,this.#a,this.#u,r,o,l,a])s.appendChild(m);this.#g.push($(this.#s,"input",()=>this.#O())),this.#g.push($(r,"click",()=>this.#e.find.prev())),this.#g.push($(o,"click",()=>this.#e.find.next())),this.#g.push($(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push($(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#E()})),this.#g.push($(this.#h,"change",()=>{const m=this.#h.value;this.#p=m?String(m):null,this.#E()})),this.#g.push($(l,"click",()=>this.hide()));const p=m=>{if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),this.hide();return}m.key==="Enter"&&m.target===this.#s&&(m.preventDefault(),m.stopPropagation(),this.#w!==null&&(this.#I(),this.#E()),m.shiftKey?this.#e.find.prev():this.#e.find.next())};return s.addEventListener("keydown",p),this.#g.push(()=>s.removeEventListener("keydown",p)),s.style.display="none",t.insertBefore(s,n.header||t.firstChild),this.#i=s,this.#j(),s}#j(){const n=this.#h;if(!n)return;const t=this.#n;for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(M(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const i=this.#e.columns,s=i&&D(i.visible)?i.visible():[];let r=!1;for(const o of s){if(!o||o.id===void 0)continue;const l=String(o.id);n.appendChild(M(t,"option",{text:o.title||l,attrs:{value:l}})),l===this.#p&&(r=!0)}r||(this.#p=null),n.value=this.#p||""}#O(){const n=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#I(),n===0||!D(this.#r.setTimeout)){this.#E();return}this.#w=this.#r.setTimeout(()=>{this.#w=null,this.#E()},n)}#E(){const n=this.#S();if(!n||this.#v)return;const t=this.#s?this.#s.value:"";if(!t){this.#M(),n.clear();return}n.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#C()}),this.#T()}#C(){const n=this.#t&&this.#t.window,t=n&&Number.isFinite(n.first)?n.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#v)return;const n=()=>{this.#b=null,this.#D()};D(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(n):D(this.#r.setTimeout)?this.#b=this.#r.setTimeout(n,0):n()}#D(){const n=this.#S();!n||this.#v||!n.active||(n.stale&&n.rescan({from:this.#C()}),!n.complete&&(n.step(k)||this.#T()))}#N(){if(!this.#i||this.#v)return;const n=this.#e.find.count(),t=this.#S().active;let i="",s="idle";t&&(n.total===0?(i=n.complete?this.t("find.none"):this.t("find.searching"),s=n.complete?"none":"searching"):(i=this.t(n.complete?"find.count":"find.countPartial",{current:n.current,total:n.total}),s=n.complete?"matches":"searching")),this.#l.textContent=i,this.#i.setAttribute("data-state",s);const r=t&&n.windowed;this.#a.textContent=r?this.t("find.loadedRows"):"",this.#a.style.display=r?"":"none",t?n.complete&&(this.#u.textContent=n.total===0?this.t(r?"a11y.find.noneLoaded":"a11y.find.none"):this.t(r?"a11y.find.countLoaded":"a11y.find.count",{current:n.current,count:n.total})):this.#u.textContent=""}#I(){this.#w!==null&&D(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null}#M(){this.#b!==null&&(D(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):D(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#x(){this.#I(),this.#M()}}const d=y}),Ce("packages/dom/src/redactpaint.js",function(e,G){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return R}});const _="lat-cell--redacted",M="lat-cell";class ${#e;#t;#n=[];constructor(Z){this.#e=Z.grid,this.#t=Z.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Z=this.#t.viewport?.root;if(!Z||!Z.querySelectorAll)return;const V=this.#e.redaction;if(!V)return;const U=V.active;for(const D of Z.querySelectorAll(`.${M}[data-col]`))U&&V.has(D.getAttribute("data-col"))?D.classList.add(_):D.classList.contains(_)&&D.classList.remove(_)}destroy(){for(const Z of this.#n)Z();this.#n=[]}}const R=$}),Ce("packages/dom/src/validationpaint.js",function(e,G){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/dom/src/editors/common.js").markInvalid,$="lat-cell";function R(V,U){let D=V;for(;D;){if(U(D))return D;D=D.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 D=R(U,I=>I.getAttribute&&I.getAttribute("data-key")!==null);return D?D.getAttribute("data-key"):null}paint(){const U=this.#e.validation;if(!U||!U.active)return;const D=this.#t.viewport?.root;if(!(!D||!D.querySelectorAll))for(const I of D.querySelectorAll(`.${$}[data-col]`)){const k=I.getAttribute("data-col"),S=this.#r(I),y=S?U.errorFor(S,k):null;M(I,y?y.message:null)}}destroy(){for(const U of this.#n)U();this.#n=[]}}const Z=W}),Ce("packages/dom/src/presentation.js",function(e,G){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/dom/src/renderer/textentry.js").isTextEntry,Z=G("packages/dom/src/renderer/viewport.js").CLASS,V="lat-presenting",U="lat-presenting--changing",D="lat-presenting__progress",I="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",n=>this.#a(n))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&M(this.#n.watch)&&this.#r.push(this.#n.watch(n=>{n||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const u=this.#t.viewport?.root;if(u&&M(u.addEventListener)){const n=t=>this.#l(t);u.addEventListener("keydown",n),this.#r.push(()=>u.removeEventListener("keydown",n))}}#l(u){const n=this.#e.presentation;if(!n?.active)return;const t=u.ctrlKey||u.metaKey,i=u.key;if(i==="Escape"&&!this.#n){u.defaultPrevented||(n.stop(),u.preventDefault?.());return}if(t){i==="="||i==="+"?(n.nudge(1),u.preventDefault?.()):i==="-"||i==="_"?(n.nudge(-1),u.preventDefault?.()):i==="0"&&(n.setScale(1.5),u.preventDefault?.());return}if(!n.views.length||R(u.target))return;i==="ArrowRight"||i==="ArrowDown"||i==="PageDown"||i===" "?(n.step(1),u.preventDefault?.()):i==="ArrowLeft"||i==="ArrowUp"||i==="PageUp"?(n.step(-1),u.preventDefault?.()):i==="Home"?(n.goTo(0),u.preventDefault?.()):i==="End"?(n.goTo(n.views.length-1),u.preventDefault?.()):(i==="r"||i==="R")&&(n.reset(),u.preventDefault?.())}#a(u){!u||!u.viewId||(this.#u(),this.#e.views?.apply?.(u.viewId),this.#c(u))}#u(){const u=this.#t.viewport?.root;u?.classList&&(u.classList.remove(U),u.offsetWidth,u.classList.add(U))}#c(u){const n=this.#t.viewport?.overlays;if(!n||!this.#e.presentation.views.length)return;const t=n.ownerDocument;if(!t?.createElement)return;if(!this.#i){const r=t.createElement("div");r.className=D,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),n.appendChild(r),this.#i=r}const i=this.#e.views?.get?.(u.viewId),s=i&&i.name?i.name:"";this.#i.textContent=s?`${s} · ${(u.index||0)+1} / ${u.count||0}`:`${(u.index||0)+1} / ${u.count||0}`}#d(){if(this.#o){this.#f();return}const u=!!(this.#n&&this.#n.active());this.#n&&!u&&this.#n.enter();const n=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const s of k){if(n.has(s)||s==="toolPanel"&&this.#v())continue;const r=this.#y(s);r&&r.style&&r.style.display!=="none"&&(r.style.display="none",t.push(r))}const i=this.#w();i&&i.style&&i.style.display!=="none"&&this.#b(i)&&(i.style.display="none",t.push(i)),this.#o={maximised:u,hidden:t},this.#t.viewport?.root?.classList?.add(V),this.#f(),this.#p()}#h(){const u=this.#o;this.#o=null;const n=this.#t.viewport?.root;if(n?.classList?.remove(V),n?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),n?.classList?.remove(U),this.#m(),u){const t=this.#e.toolPanel;t&&M(t.presentRestore)&&t.presentRestore();for(const i of u.hidden)i.style.display="";this.#n&&!u.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const u=this.#t.viewport?.root;!u||!u.style||(u.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const u=this.#t.viewport?.root;if(!u?.querySelectorAll)return;const n=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=n&&n.keys.length?new Set(n.keys):null,i=n&&n.colIds.length?new Set(n.colIds):null;for(const s of u.querySelectorAll("[data-key]")){const r=!t||t.has(s.getAttribute("data-key"));for(const o of s.querySelectorAll("[data-col]"))!n||r&&(!i||i.has(o.getAttribute("data-col")))?o.classList.remove(I):o.classList.add(I)}}#p(){this.#g();const u=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(u)||u<=0||!this.#e.presentation.views.length)return;const n=this.#t.viewport?.root?.ownerDocument?.defaultView;n?.setInterval&&(this.#s=n.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,u)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#w(){const u=this.#e.element;return!u||!M(u.querySelector)?null:u.querySelector(`.${Z.statusBar}`)}#b(u){const n=u.children||[];for(const t of n)if(!t.style||t.style.display!=="none")return!1;return!0}#v(){const u=this.#e.toolPanel;return!!(u&&M(u.presentOnly)&&u.presentOnly())}#y(u){const n=this.#e.element;if(!n||!M(n.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[u];return t?n.querySelector(t):null}destroy(){this.#o&&this.#h();for(const u of this.#r)u();this.#r=[]}}const y=S}),Ce("packages/dom/src/capture.js",function(e,G){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const M=G("packages/core/src/internal/util.js").isFunction,$=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function R(D,I,k){const S=k.getComputedStyle(D),y=I.style;if(y)for(let d=0;d<S.length;d++){const u=S[d];$.has(u)||y.setProperty(u,S.getPropertyValue(u),S.getPropertyPriority(u))}}function W(D,I,k){if(R(D,I,k),D.tagName==="CANVAS"&&M(D.toDataURL))try{const d=D.toDataURL("image/png"),u=I.style;u&&(u.setProperty("background-image",`url(${d})`),u.setProperty("background-size","100% 100%"),u.setProperty("background-repeat","no-repeat"))}catch{}const S=D.children||[],y=I.children||[];for(let d=0;d<S.length&&d<y.length;d++)W(S[d],y[d],k)}function Z(D,I){if(!D||D.startsWith("data:")||D.startsWith("blob:"))return!0;try{return new URL(D,I).origin===I}catch{return!0}}async function V(D,I={}){const k=D.ownerDocument,S=k?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=D.getBoundingClientRect(),d=Math.max(1,Math.ceil(y.width)),u=Math.max(1,Math.ceil(y.height)),n=Math.max(.1,Number(I.scale)||2),t=S.location?.origin||"";for(const p of D.querySelectorAll("img")){const m=p.getAttribute("src")||"";if(!Z(m,t))throw new Error(`capture refused: the image at ${m} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const i=D.cloneNode(!0);W(D,i,S),i.style.width=`${d}px`,i.style.height=`${u}px`,i.style.margin="0";const s=new S.XMLSerializer().serializeToString(i),r=`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${u}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${s}</div></foreignObject></svg>`,o=new S.Image;await new Promise((p,m)=>{o.onload=()=>p(void 0),o.onerror=()=>m(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`});const l=k.createElement("canvas");l.width=Math.round(d*n),l.height=Math.round(u*n);const a=l.getContext("2d");if(!a)throw new Error("capture could not get a 2d context");return a.fillStyle=I.background||S.getComputedStyle(D).backgroundColor||"#ffffff",a.fillRect(0,0,l.width,l.height),a.drawImage(o,0,0,l.width,l.height),new Promise((p,m)=>{l.toBlob(b=>b?p({blob:b,width:l.width,height:l.height}):m(new Error("capture produced no image")),I.type||"image/png",I.quality)})}const U=V}),Ce("packages/dom/src/annotate.js",function(e,G){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/dom/src/renderer/direction.js").signedX,Z=Object.freeze(["pen","arrow","rect","highlight"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),I=14,k="system-ui, -apple-system, sans-serif";function S(r,o){if(!r||typeof r!="object")return null;const l=U[r.type];if(!l)return null;const a=Array.isArray(r.points)?r.points:[],p=[];for(const b of a){const g=Number(b&&b.x),f=Number(b&&b.y);Number.isFinite(g)&&Number.isFinite(f)&&p.push({x:g,y:f})}const m=typeof r.colour=="string"&&r.colour?r.colour:o;if(l==="text"){const b=typeof r.text=="string"?r.text:"";if(!p.length||!b)return null;const g={tool:l,colour:m,points:[p[0]],text:b,region:y(r.region)},f=Number(r.fontSize);return Number.isFinite(f)&&f>0&&(g.fontSize=f),typeof r.background=="string"&&r.background&&(g.background=r.background),g}return p.length<2?null:{tool:l,colour:m,points:p,region:y(r.region)}}function y(r){return r==="start"||r==="end"?r:"centre"}function d(r){const o={type:D[r.tool]||r.tool,colour:r.colour,points:r.points.map(l=>({x:l.x,y:l.y}))};return(r.region==="start"||r.region==="end")&&(o.region=r.region),r.tool==="text"&&(o.text=r.text,r.fontSize!==void 0&&(o.fontSize=r.fontSize),r.background!==void 0&&(o.background=r.background)),o}const u="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(r){return r==="arrow"||r==="rect"}class i{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#u=Array.isArray(o.seed)?o.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(o){const l=S(o,this.#i);return l?(l.durable=!0,this.#s.push(l),this.#y(),this.redraw(),this.#j(),this.#s.length):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#s.length)}list(){return this.#s.map(d)}replaceAll(o){const l=Array.isArray(o)?o:[];this.#s=l.map(a=>S(a,this.#i)).filter(Boolean);for(const a of this.#s)a.durable=!0;this.#s.length&&this.#y(),this.redraw(),this.#j()}#c(){const o=this.#t.viewport?.root;if(!o||!M(o.addEventListener))return;const l=a=>{!this.#o||!a||a.key!=="Escape"||(this.use(null),a.preventDefault?.())};o.addEventListener("keydown",l,!0),this.#a.push(()=>o.removeEventListener("keydown",l,!0))}#d(){const o=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!o||!M(o.matchMedia))return;let l=null;const a=()=>{const p=o.devicePixelRatio||1;let m;try{m=o.matchMedia(`(resolution: ${p}dppx)`)}catch{return}l=m;const b=()=>{this.redraw(),a()};M(m.addEventListener)?m.addEventListener("change",b,{once:!0}):M(m.addListener)&&m.addListener(b)};a(),this.#a.push(()=>{l=null})}use(o,l={}){const a=!!l.colour&&o===this.#o;l.colour&&(this.#i=String(l.colour));const p=o&&Z.includes(o)?o:null;this.#o=p&&p===this.#o&&!a?null:p;const m=this.#o?this.#y():this.#n;return m&&(m.style.pointerEvents=this.#o?"auto":"none",m.style.cursor=this.#o?"crosshair":""),this.#j(),this.#o}undo(){return this.#s.pop(),this.redraw(),this.#j(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.redraw(),this.#j())}#h(){const o=this.#s.filter(l=>l.durable);o.length!==this.#s.length&&(this.#s=o,this.redraw(),this.#j())}redraw(){!this.#n&&this.#s.length&&this.#y();const o=this.#n,l=this.#r;if(!o||!l)return;this.#S();const{left:a,top:p}=this.#v();l.clearRect(0,0,o.width,o.height);const m=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const g=m.filter(f=>y(f.region)===b);if(g.length){l.save(),this.#f(l,b),l.translate((b==="centre"?-a:0)||0,-p||0);for(const f of g)this.#w(l,f);l.restore()}}}#f(o,l="centre"){const a=this.#n,p=this.#t.viewport?.bodyViewport;if(!M(a?.getBoundingClientRect)||!M(p?.getBoundingClientRect))return;const m=a.getBoundingClientRect(),b=p.getBoundingClientRect();if(!b.width||!b.height)return;const g=this.#m(l,b);g&&(o.beginPath(),o.rect(g.left-m.left,b.top-m.top,g.width,b.height),o.clip())}#m(o,l){const a=w=>{if(!M(w?.getBoundingClientRect))return null;const v=w.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},p=a(this.#t.viewport?.bodyStart),m=a(this.#t.viewport?.bodyEnd);if(o==="start")return p;if(o==="end")return m;let b=l.left,g=l.left+l.width;const f=l.left+l.width/2;for(const w of[p,m]){if(!w)continue;const v=w.left+w.width;w.left+w.width/2<f?b=Math.max(b,v):g=Math.min(g,w.left)}return g>b?{left:b,width:g-b}:null}#p(o){for(const[l,a]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!M(a?.getBoundingClientRect))continue;const p=a.getBoundingClientRect();if(p&&p.width>0&&o>=p.left&&o<p.left+p.width)return l}return"centre"}#g(o){const l=this.#t.viewport?.bodyViewport;if(!M(l?.getBoundingClientRect))return!0;const a=l.getBoundingClientRect();return!a.width||!a.height?!0:o.clientX>=a.left&&o.clientX<=a.right&&o.clientY>=a.top&&o.clientY<=a.bottom}#w(o,l){const a=l.points;if(!a.length)return;const p=this.#e.presentation?.scale||1;o.lineWidth=(n[l.tool]||3)*p,o.strokeStyle=l.colour,o.fillStyle=l.colour,o.lineCap="round",o.lineJoin="round",o.globalAlpha=l.tool==="highlight"?.32:1;const m=a[0],b=a[a.length-1];if(l.tool==="text"){const g=(l.fontSize||I)*p;o.font=`${g}px ${k}`,o.textBaseline="top";const f=l.text||"";if(l.background){let w=f.length*g*.6;if(typeof o.measureText=="function"){const v=o.measureText(f);v&&Number.isFinite(v.width)&&(w=v.width)}o.fillStyle=l.background,o.fillRect(m.x-g*.15,m.y-g*.1,w+g*.3,g*1.2)}o.fillStyle=l.colour,o.fillText(f,m.x,m.y),o.globalAlpha=1;return}if(l.tool==="rect")o.strokeRect(m.x,m.y,b.x-m.x,b.y-m.y);else if(l.tool==="arrow")o.beginPath(),o.moveTo(m.x,m.y),o.lineTo(b.x,b.y),o.stroke(),this.#b(o,m,b,o.lineWidth);else{o.beginPath(),o.moveTo(m.x,m.y);for(let g=1;g<a.length;g++)o.lineTo(a[g].x,a[g].y);o.stroke()}o.globalAlpha=1}#b(o,l,a,p){const m=Math.atan2(a.y-l.y,a.x-l.x),b=Math.max(8,p*3);o.beginPath(),o.moveTo(a.x,a.y),o.lineTo(a.x-b*Math.cos(m-Math.PI/7),a.y-b*Math.sin(m-Math.PI/7)),o.lineTo(a.x-b*Math.cos(m+Math.PI/7),a.y-b*Math.sin(m+Math.PI/7)),o.closePath(),o.fill()}#v(){const o=M(this.#t.scrollPosition)?this.#t.scrollPosition():null,l=this.#t.viewport?.rtl===!0;return{left:W(o?.left||0,l),top:o?.top||0}}#y(){if(this.#n)return this.#n;const o=this.#t.viewport?.overlays,l=o?.ownerDocument;if(!o||!l?.createElement)return null;const a=l.createElement("canvas");return a.className=u,a.style.position="absolute",a.style.inset="0",a.style.pointerEvents="none",o.appendChild(a),this.#n=a,this.#r=a.getContext?a.getContext("2d"):null,this.#S(),this.#A(a),a}#S(){const o=this.#n,l=this.#t.viewport?.root;if(!o||!l?.getBoundingClientRect)return;const a=l.getBoundingClientRect(),m=o.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(a.width*m)),g=Math.max(1,Math.round(a.height*m));o.width===b&&o.height===g||(o.width=b,o.height=g,o.style&&(o.style.width=`${Math.max(1,a.width)}px`,o.style.height=`${Math.max(1,a.height)}px`),this.#r?.setTransform(m,0,0,m,0,0))}#A(o){const l=(g,f="centre")=>{const w=o.getBoundingClientRect(),{left:v,top:h}=this.#v();return{x:g.clientX-w.left+(f==="centre"?v:0),y:g.clientY-w.top+h}},a=g=>{if(!this.#o||!this.#g(g))return;const f=this.#p(g.clientX);this.#l={tool:this.#o,colour:this.#i,points:[l(g,f)],region:f},o.setPointerCapture?.(g.pointerId),g.preventDefault?.()},p=g=>{if(!this.#l)return;const f=l(g,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(f),this.redraw()},m=g=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,o.releasePointerCapture?.(g.pointerId),this.redraw(),this.#j())},b=g=>{if(!this.#o)return;const f=this.#t.viewport?.bodyViewport;if(!f)return;let w=!1;g.deltaY&&typeof f.scrollTop=="number"&&(f.scrollTop+=g.deltaY,w=!0),g.deltaX&&typeof f.scrollLeft=="number"&&(f.scrollLeft+=g.deltaX,w=!0),w&&g.preventDefault?.()};o.addEventListener("pointerdown",a),o.addEventListener("pointermove",p),o.addEventListener("pointerup",m),o.addEventListener("pointercancel",m),o.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{o.removeEventListener("pointerdown",a),o.removeEventListener("pointermove",p),o.removeEventListener("pointerup",m),o.removeEventListener("pointercancel",m),o.removeEventListener("wheel",b)})}#j(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}destroy(){for(const o of this.#a)o();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const s=i}),Ce("packages/dom/src/timelinebar.js",function(e,G){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Z(I){if(!Number.isFinite(I)||I<1e3)return"now";const k=Math.round(I/1e3);if(k<60)return`${k}s ago`;const S=Math.round(k/60);return S<60?`${S}m ago`:`${Math.round(S/60)}h ago`}function V(I,k){return Number.isFinite(I)?new Date(I).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;#s=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,S=k.depth,y=k.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-y)),this.#r.disabled=S===0;const d=k.at(),u=k.live;this.#o&&(this.#o.textContent=u?this.#l("timeline.live"):Z(Date.now()-(d||Date.now())),this.#o.setAttribute("data-live",u?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#l("timeline.recording"):V(d,this.#e.get("locale"))),this.#n.setAttribute("data-live",u?"true":"false")}#l(k,S){const y=this.#e;return(y&&y.messages?y.messages:R).t(k,S)}#a(){if(this.#n)return;const k=this.#t.viewport?.overlays,S=k?.ownerDocument;if(!k||!S?.createElement)return;const y=S.createElement("div");y.className=W;const d=S.createElement("span");d.className=`${W}__ago`,d.setAttribute("role","status"),d.setAttribute("aria-live","polite");const u=S.createElement("input");u.className=`${W}__range`,u.type="range",u.min="0",u.step="1",u.setAttribute("aria-label",this.#l("timeline.scrub"));const n=S.createElement("span");n.className=`${W}__clock`;const t=S.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#l("timeline.goLive"),t.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(d),y.appendChild(u),y.appendChild(n),y.appendChild(t),k.appendChild(y),this.#n=y,this.#r=u,this.#o=d,this.#i=n;const i=()=>{const o=this.#e.timeline.depth;this.#e.timeline.seek(o-Number(u.value))};u.addEventListener("input",i);const s=()=>this.#e.timeline.toLive();t.addEventListener("click",s);const r=o=>o.stopPropagation();u.addEventListener("keydown",r),this.#s.push(()=>{u.removeEventListener("input",i),t.removeEventListener("click",s),u.removeEventListener("keydown",r)})}#u(){this.#n&&(M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#s)k();this.#s=[],this.#u()}}const D=U}),Ce("packages/dom/src/commentpaint.js",function(e,G){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/renderer/direction.js").isRtlElement,V="lat-comment-mark",U="lat-cell--commented",D="lat-cell--commented-open";class I{#e;#t;#n=[];#r=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const d=this.#t.viewport?.root;if(!d||!d.querySelectorAll)return;const u=[];for(const n of d.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key");if(t){u.push(t);for(const i of n.querySelectorAll("[data-col]")){const s=i.getAttribute("data-col"),r=y.at(t,s),o=!!(r&&r.count);i.classList.toggle(U,o),i.classList.toggle(D,o&&r.unresolved>0),this.#i(i,r,s)}}}(u.length!==this.#r.length||u.some((n,t)=>n!==this.#r[t]))&&(this.#r=u,y.request(u))}#o(y,d){const u=this.#e;return(u&&u.messages?u.messages:R).t(y,d)}#i(y,d,u){if(!d||!d.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const n=d.count,t=d.unresolved,i=this.#o("count.comments",{count:n});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:i,unresolved:t}):this.#o("comments.allResolved",{comments:i}))}#s(){const y=this.#t.viewport?.root;if(!y||!M(y.addEventListener))return;const d=n=>{const t=this.#e.comments;if(!t||!t.enabled)return;const i=n.target&&M(n.target.closest)?n.target.closest("[data-col]"):null;if(!i||!i.classList.contains(U)||!this.#l(i,n))return;const s=i.closest("[data-key]"),r=s&&s.getAttribute("data-key");r&&(n.stopPropagation(),n.preventDefault(),t.open(r,i.getAttribute("data-col")))},u=n=>{const t=this.#e.comments;if(!t||!t.enabled||!n.altKey||n.key!=="m"&&n.key!=="M")return;const i=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&M(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!i)return;const s=i.closest("[data-key]"),r=s&&s.getAttribute("data-key");r&&(n.preventDefault(),n.stopPropagation(),t.open(r,i.getAttribute("data-col")))};y.addEventListener("click",d,!0),y.addEventListener("keydown",u,!0),this.#n.push(()=>{y.removeEventListener("click",d,!0),y.removeEventListener("keydown",u,!0)})}#l(y,d){if(!M(y.getBoundingClientRect))return!1;const u=y.getBoundingClientRect(),n=Math.max(14,Math.min(24,u.height*.6));return(Z(y)?d.clientX<=u.left+n:d.clientX>=u.right-n)&&d.clientY<=u.top+n}destroy(){for(const y of this.#n)y();this.#n=[]}}const k=I}),Ce("packages/dom/src/presencepaint.js",function(e,G){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/editors/common.js").cssEscape,U=G("packages/core/src/model/presence.js").CURSOR_LABEL_MS,D="lat-presence";class I{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){const y=this.#e.presence;if(!(!y||!y.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const d of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(d,u=>this.#l(d,u)));this.#a(),this.paint()}}#l(y,d){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const n=d&&d.peer;n&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:n.name}))}#a(){const y=this.#t.viewport?.overlays,d=y?.ownerDocument;if(!y||!d?.createElement)return;const u=this.#e.get("presence")||{},n=d.createElement("span");if(n.className=`${D}__live`,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),y.appendChild(n),this.#r=n,u.roster===!1)return;const t=d.createElement("div");t.className=D,u.roster&&u.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,d=this.#t.viewport?.root;if(!y||!y.enabled||!d?.querySelectorAll)return;this.#d(d);const u=y.peers(),n=[...u].sort((t,i)=>t.at-i.at);for(const t of n)for(const i of t.ranges||[])for(const s of i.rowIds||[])for(const r of i.columns||[])this.#c(d,s,r,t,"range");for(const t of n)t.cursor&&this.#c(d,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of n)t.editing&&this.#c(d,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(u)}#u(y){if(this.#s!==null)return;const d=y.filter(t=>t.cursorFresh);if(!d.length)return;const n=Math.max(...d.map(t=>t.cursorAt||0))+U-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,n))}#c(y,d,u,n,t){const i=y.querySelector(`[data-key="${Z(d)}"]`),s=i&&i.querySelector(`[data-col="${Z(u)}"]`);s&&(s.setAttribute("data-presence",t),s.style.setProperty("--lat-peer",n.colour),s.setAttribute("data-peer-name",n.name),s.setAttribute("data-peer-initial",n.initials||(n.name||"?").slice(0,1).toUpperCase()),n.idle?s.setAttribute("data-peer-idle","true"):s.removeAttribute("data-peer-idle"),t==="cursor"&&n.cursorFresh&&s.setAttribute("data-peer-fresh","true"),this.#o.add(`${d}${u}`))}#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 n of d){const t=y.createElement("button");t.className=`${D}__peer`,t.type="button",t.style.setProperty("--lat-peer",n.colour),t.toggleAttribute("data-idle",!!n.idle),t.toggleAttribute("data-hidden",!!n.hidden);let i="presence.peer";n.hidden?i="presence.peerHidden":n.idle&&(i="presence.peerIdle"),t.setAttribute("aria-label",this.#f(i,{name:n.name}));const s=y.createElement("span");s.className=`${D}__dot`,s.setAttribute("aria-hidden","true"),s.textContent=n.initials||(n.name||"?").slice(0,1).toUpperCase(),t.appendChild(s);const r=y.createElement("span");r.className=`${D}__name`,r.textContent=n.name,t.appendChild(r),t.addEventListener("click",()=>this.#e.presence.jumpTo(n.id)),this.#n.appendChild(t)}const u=d.filter(n=>n.hidden).length;if(u){const n=y.createElement("span");n.className=`${D}__hidden`,n.textContent=this.#f("presence.hidden",{count:u}),this.#n.appendChild(n)}}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 u=this.#e;return(u&&u.messages?u.messages:R).t(y,d)}destroy(){for(const d of this.#i)d();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=I}),Ce("packages/dom/src/commentpanel.js",function(e,G){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/editors/common.js").cssEscape,U=G("packages/core/src/model/comments.js").parseCellKey,D="lat-comments",I=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(n,t){if(!Number.isFinite(n))return"";const i=Math.max(0,Math.round((t-n)/1e3));if(i<60)return"just now";const s=Math.round(i/60);if(s<60)return`${s}m ago`;const r=Math.round(s/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function y(n,t,i,s){t.textContent="";const r=String(i??"");if(!s){t.textContent=r;return}const o=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,a=o.exec(r);for(;a;){a.index>l&&t.appendChild(n.createTextNode(r.slice(l,a.index)));const p=a[0];if(p.startsWith("*")){const m=n.createElement("em");m.textContent=p.slice(1,-1),t.appendChild(m)}else if(p.startsWith("`")){const m=n.createElement("code");m.textContent=p.slice(1,-1),t.appendChild(m)}else{const m=p.indexOf("]("),b=p.slice(1,m),g=p.slice(m+2,-1);if(I.test(g)){const f=n.createElement("a");f.href=g,f.textContent=b,f.rel="noopener noreferrer",f.target="_blank",t.appendChild(f)}else t.appendChild(n.createTextNode(b))}l=a.index+p.length,a=o.exec(r)}l<r.length&&t.appendChild(n.createTextNode(r.slice(l)))}class d{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",t=>this.#a(t))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(t){const i=this.#t.viewport?.root?.ownerDocument;i&&(this.#s=i.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(i),this.#n.setAttribute("data-open","true"),this.#b(),this.#y(),this.#o&&M(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#s;this.#s=null,t&&M(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:i}=U(t);this.#e.rows.byKey(i)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(t){if(!this.#r)return;const s=this.#r.ownerDocument.createElement("p");s.className=`${D}__note`,s.setAttribute("role","status"),s.textContent=t,this.#r.appendChild(s)}#h(t,i){const s=this.#t.viewport?.root;if(!s||!s.querySelector)return null;const r=s.querySelector(`[data-key="${Z(t)}"]`);return r?r.querySelector(`[data-col="${i}"]`):null}#f(t,i){const s=this.#e;return(s&&s.messages?s.messages:R).t(t,i)}#m(t){const i=t.createElement("div");i.className=D,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",this.#f("comments.panel"));const s=t.createElement("header");s.className=`${D}__head`;const r=t.createElement("div");r.className=`${D}__title`,s.appendChild(r);const o=t.createElement("button");o.className=`${D}__resolve`,o.type="button",s.appendChild(o);const l=t.createElement("button");l.className=`${D}__close`,l.type="button",l.setAttribute("aria-label",this.#f("comments.close")),l.textContent="×",s.appendChild(l);const a=t.createElement("div");a.className=`${D}__list`,a.setAttribute("role","log"),a.setAttribute("aria-live","polite");const p=t.createElement("form");p.className=`${D}__composer`;const m=t.createElement("textarea");m.className=`${D}__input`,m.rows=2,m.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${D}__send`,b.type="submit",b.textContent=this.#f("comments.post"),p.appendChild(m),p.appendChild(b),i.appendChild(s),i.appendChild(a),i.appendChild(p),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(i),this.#n=i,this.#r=a,this.#o=m,this.#p=r,this.#g=o;const g=h=>{h.preventDefault();const c=String(m.value||"").trim();c&&(m.value="",this.#e.comments.add(c))},f=()=>this.#e.comments.close(),w=()=>{this.#w()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.#e.comments.close();return}if(h.key!=="Tab")return;const c=[...i.querySelectorAll(k)].filter(T=>T.offsetParent!==null||T===m);if(!c.length)return;const j=c[0],E=c[c.length-1],O=i.ownerDocument.activeElement;h.shiftKey&&O===j?(h.preventDefault(),E.focus()):!h.shiftKey&&O===E&&(h.preventDefault(),j.focus())};p.addEventListener("submit",g),l.addEventListener("click",f),o.addEventListener("click",w),i.addEventListener("keydown",v),this.#l.push(()=>{p.removeEventListener("submit",g),l.removeEventListener("click",f),o.removeEventListener("click",w),i.removeEventListener("keydown",v)})}#p=null;#g=null;#w(){return(this.#e.comments.thread||[]).filter(i=>!i.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const i=this.#n.ownerDocument,s=this.#e.get("comments")||{},r=Date.now(),o=t.openKey,{rowId:l,field:a}=U(o),p=this.#e.columns.get(a),m=this.#e.rows.byKey(l),b=M(s.rowLabel)&&m?s.rowLabel(m):l;if(this.#p.textContent=this.#f("comments.cellTitle",{column:p&&(p.title??p.id)||a,row:b}),this.#g.textContent=this.#w()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const g=t.thread||[];if(!g.length){this.#d(this.#f("comments.empty"));return}const f=m&&p?p.getValue(m.data,m):void 0;for(const w of g)this.#r.appendChild(this.#v(i,w,r,f,s))}#v(t,i,s,r,o){const l=t.createElement("article");l.className=`${D}__item`,i.pending&&l.setAttribute("data-pending","true"),i.resolved&&l.setAttribute("data-resolved","true");const a=t.createElement("div");a.className=`${D}__meta`;const p=t.createElement("span");p.className=`${D}__author`,p.textContent=i.author&&(i.author.name||i.author.initials)||this.#f("comments.unknownAuthor"),a.appendChild(p);const m=t.createElement("time");m.className=`${D}__time`;const b=S(i.at,s);m.textContent=i.edited?this.#f("comments.edited",{time:b}):b,a.appendChild(m),l.appendChild(a);const g=t.createElement("div");if(g.className=`${D}__body`,y(t,g,i.body,!!o.markdown),l.appendChild(g),i.value!==void 0&&!Object.is(i.value,r)){const v=t.createElement("p");v.className=`${D}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(i.value),now:String(r)}),l.appendChild(v)}const f=i.can||{},w=v=>f[v]!==!1;if(w("edit")||w("delete")){const v=t.createElement("div");if(v.className=`${D}__actions`,w("delete")){const h=t.createElement("button");h.type="button",h.className=`${D}__action`,h.textContent=this.#f("comments.delete"),h.addEventListener("click",()=>this.#e.comments.remove(i.id)),v.appendChild(h)}l.appendChild(v)}return l}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const i=this.#e.comments.openKey,{rowId:s,field:r}=U(i),o=this.#h(s,r)||this.#i,l=this.#t.viewport?.root;if(!o||!l||!M(o.getBoundingClientRect))return;const a=o.getBoundingClientRect(),p=l.getBoundingClientRect(),m=this.#n.getBoundingClientRect();let b=a.bottom-p.top+4;b+m.height>p.height&&a.top-p.top>m.height&&(b=a.top-p.top-m.height-4);let g=a.left-p.left;g+m.width>p.width&&(g=Math.max(0,p.width-m.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,g)}px`;const f=a.bottom<p.top||a.top>p.bottom;this.#n.toggleAttribute("data-offscreen",f)}destroy(){for(const t of this.#l)t();this.#l=[],this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const u=d}),Ce("packages/dom/src/watermark.js",function(e,G){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.on,U="lat-watermark",D="https://www.latticegrid.dev",I=["br","bl","tl","tr"],k=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(u){this.#e=u.grid,this.#t=u.document,this.#n=u.element,this.#i=u.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),M(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const u=this.#e.licence&&this.#e.licence.ready;u&&M(u.then)&&u.then(()=>this.refresh(),()=>this.refresh())}refresh(){const u=this.#d();u&&!this.#r?(this.#h(),this.#u()):!u&&this.#r&&(this.#f(),this.#c())}#a(){const u=this.#i;if(!u||!M(u.matchMedia))return!1;try{return!!u.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),M(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%I.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#l!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const u=this.#e.licence;return!!(u&&M(u.watermark)&&u.watermark())}#h(){const u=Z(this.#t,"a",{class:`${U}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:R).t("licence.watermark"),attrs:{href:D,target:"_blank",rel:"noopener noreferrer"}});this.#r=Z(this.#t,"div",{class:`${U} ${U}--${I[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[u]}),this.#o.push(V(this.#r,"pointerdown",n=>{M(n.stopPropagation)&&n.stopPropagation()})),this.#n&&M(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const u of this.#o)u();this.#o=[],this.#f()}}const y=S}),Ce("packages/dom/src/maximise.js",function(e,G){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.isFunction,R=G("packages/dom/src/editors/common.js"),W=R.el,Z=R.on,U=G("packages/dom/src/themeof.js").themeOf,D="lat-maximised",I={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},k="lat-maximised-host",S="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(n){this.#e=n.element,this.#t=n.document,this.#n=$(n.onChange)?n.onChange:null,this.#r=$(n.captureScroll)?n.captureScroll:null,this.#o=$(n.restoreScroll)?n.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const n=this.#e.parentNode;if(!n||!this.#t.body)return M("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:S}),this.#i.style.visibility="hidden";const t=this.#e.offsetWidth,i=this.#e.offsetHeight;t&&(this.#i.style.width=`${t}px`),i&&(this.#i.style.height=`${i}px`);const s=this.#r?this.#r():null,r=$(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?U(n):null;r&&(this.#e.setAttribute("data-theme",r),this.#u=!0),n.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[o,l]of Object.entries(I))this.#a[o]=this.#e.style[o]||"",this.#e.style[o]=l;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(D),this.#t.body.classList&&this.#t.body.classList.add(k),s&&this.#o&&this.#o(s),this.#s=Z(this.#t,"keydown",o=>this.#h(o)),this.#f(),!0}exit(){if(!this.active())return!1;const n=this.#r?this.#r():null,t=this.#i,i=t.parentNode;if(i&&$(i.insertBefore)&&this.#d(()=>i.insertBefore(this.#e,t)),$(t.remove)&&t.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[s,r]of Object.entries(this.#a))this.#e.style[s]=r;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(D),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(k),n&&this.#o&&this.#o(n),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(n){const t=this.#t.activeElement,i=t&&t!==this.#t.body&&$(this.#e.contains)&&this.#e.contains(t)?t:null;n(),i&&$(i.focus)&&i.focus()}#h(n){!n||n.key!=="Escape"||n.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const n of this.#l)n(this.active())}watch(n){return $(n)?(this.#l.add(n),()=>this.#l.delete(n)):()=>{}}destroy(){this.exit()}}const d=y}),Ce("packages/dom/src/promptbar.js",function(e,G){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return i}});const _=G("packages/dom/src/editors/common.js"),M=_.documentFor,$=_.el,R=_.on,W=_.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction,I=G("packages/core/src/ai/schema.js"),k=I.describeGrid,S=I.promptText,y=G("packages/core/src/ai/intent.js"),d=y.applyPlan,u=y.buildPrompt,n=y.planIntent,t="lat-prompt";class i{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#w="idle";#b=0;#v=!1;#y=[];t(l,a){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(l,a)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||V,this.#e=M(l),this.#t=l.grid||null,this.#n=D(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:D(l.onPlan)?l.onPlan:null,onApply:D(l.onApply)?l.onApply:null,onError:D(l.onError)?l.onError:null},this.#s=$(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(l)}element(){return this.#s}refresh(){this.#v||!this.#s||this.#w!=="busy"&&this.#E()}destroy(){this.#v=!0,this.#b++;for(const l of this.#y)l();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(l){if(this.#v||this.#w==="busy")return null;const a=String(l??(this.#l&&this.#l.value)??"").trim();if(!a)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const p=++this.#b;this.#A("busy"),this.#C("Thinking…");let m;try{const b=k(this.#t,this.#r),g=S(b);if(m=await this.#n({prompt:a,schema:b,schemaText:g,message:u(a,g),context:this.#o}),this.#v||p!==this.#b)return null;const f=n(m,b);return this.#j(f),f}catch(b){return this.#v||p!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const l=this.#g;if(this.#v||!l||!l.ok)return null;const a=this.#t?.ai,p=D(a?.apply)?a.apply(l):d(l,this.#t);return this.#i.onApply&&this.#i.onApply(p,l),this.#E(),this.#l&&(this.#l.value=""),p.failed.length?this.#T(`Applied ${p.applied.length}; ${p.failed.map(m=>`${m.type} failed: ${m.reason}`).join("; ")}`):this.#C(`Applied: ${l.describe()}`),p}discard(){this.#v||(this.#E(),this.#C("Discarded."))}#S(l){const a=this.#e,p=$(a,"div",{class:`${t}__row`});this.#l=$(a,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(R(this.#l,"keydown",b=>{const g=b&&b.key;g==="Enter"?(D(b.preventDefault)&&b.preventDefault(),this.ask()):g==="Escape"&&this.#g&&(D(b.preventDefault)&&b.preventDefault(),this.discard())})),p.appendChild(this.#l),this.#a=$(a,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(R(this.#a,"click",()=>{this.ask()})),p.appendChild(this.#a),this.#s.appendChild(p),this.#u=$(a,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=$(a,"p",{class:`${t}__summary`}),this.#d=$(a,"ul",{class:`${t}__notes`});const m=$(a,"div",{class:`${t}__buttons`});this.#h=$(a,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=$(a,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(R(this.#h,"click",()=>{this.apply()})),this.#y.push(R(this.#f,"click",()=>{this.discard()})),m.appendChild(this.#h),m.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(m),this.#s.appendChild(this.#u),this.#m=$(a,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=$(a,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#m),this.#s.appendChild(this.#p)}#A(l){if(this.#w=l,!this.#s)return;this.#s.setAttribute("data-state",l);const a=l==="busy";s(this.#l,a),s(this.#a,a),this.#a&&(this.#a.textContent=this.t(a?"prompt.asking":"prompt.ask")),r(this.#u,l!=="preview"),r(this.#p,l!=="error")}#j(l){const a=l;if(this.#i.onPlan&&this.#i.onPlan(l),!a.ok){this.#g=null;const p=a.rejected.length?a.rejected.map(m=>m.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${p}`);return}this.#g=l,this.#C(""),this.#c&&(this.#c.textContent=a.describe()),this.#O(a.rejected),this.#A("preview")}#O(l){const a=this.#d;if(a){W(a),r(a,!l.length);for(const p of l.slice(0,6))a.appendChild($(this.#e,"li",{class:`${t}__note`,text:p.reason}));l.length>6&&a.appendChild($(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#A("idle")}#C(l){this.#m&&(this.#m.textContent=l)}#T(l){this.#g=null,this.#C(""),this.#p&&(this.#p.textContent=l),this.#A("error")}}function s(o,l){o&&(o.disabled=l,l?o.setAttribute("disabled",""):o.removeAttribute("disabled"))}function r(o,l){o&&(o.hidden=l,l?o.setAttribute("hidden",""):o.removeAttribute("hidden"))}}),Ce("packages/dom/src/stat.js",function(e,G){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.isObject,R=_.warnOnce,Z=G("packages/core/src/source/derive.js").reduceValues,U=G("packages/core/src/source/memory.js").isPipelineSettle,I=G("packages/core/src/i18n/index.js").defaultMessages,S=G("packages/dom/src/cell/icons.js").renderIconInto,y={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},d="unknown",u=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),n=Object.freeze({direction:"flat",change:null,percent:null});function t(g,f){if(!Number.isFinite(g)||!Number.isFinite(f))return n;const w=g-f,v=w>0?"up":w<0?"down":"flat",h=f===0?null:w/Math.abs(f)*100;return{direction:v,change:w,percent:h}}function i(g,f){return g==="flat"||f==="neither"?"flat":g===f?"good":"bad"}function s(g,f,w=null){if(M(f)){const O=f(g,w);return O==="good"||O==="warn"||O==="bad"?O:null}if(!$(f))return null;const v=typeof g=="number"&&Number.isFinite(g)?g:null;if(v===null)return null;const h=Number.isFinite(Number(f.good))?Number(f.good):null,c=Number.isFinite(Number(f.warn))?Number(f.warn):null,j=String(f.direction||"up")==="down",E=O=>j?v<=O:v>=O;return h!==null&&E(h)?"good":c!==null&&E(c)?"warn":h===null&&c===null?null:"bad"}function r(g){return!(M(g.value)||g.value!==void 0&&!$(g.value))}function o(g){return!g||!g.rows||!M(g.rows.totalCount)?!0:g.rows.totalCount()>0}function l(g){const f=$(g)?g:{},w=f.grid||null,v=m(f.container,w);if(!v)return R("stat.container","createStat needs a `container`: an element or a selector."),b();const h=v.ownerDocument||(typeof document>"u"?null:document);if(!h)return R("stat.document","createStat needs a document; it draws DOM."),b();const c=h.createElement("div");c.className=["lattice",y.root,f.class].filter(Boolean).join(" "),c.setAttribute("role","group");const j=h.createElement("div");j.className=y.title;const E=h.createElement("div");E.className=y.value;const O=h.createElement("div");O.className=y.interval;const T=h.createElement("div");T.className=y.delta;const A=h.createElement("div");A.className=y.footer;const P=h.createElement("div");if(P.className=y.note,P.hidden=!0,f.icon!=null&&f.icon!==""){const te=h.createElement("span");te.className=y.icon,te.setAttribute("aria-hidden","true"),S(te,f.icon,`stat:${f.title||"stat"}`),c.appendChild(te);const ee=h.createElement("div");ee.className=y.body,ee.appendChild(j),ee.appendChild(E),ee.appendChild(P),ee.appendChild(O),ee.appendChild(T),ee.appendChild(A),c.appendChild(ee)}else c.appendChild(j),c.appendChild(E),c.appendChild(P),c.appendChild(O),c.appendChild(T),c.appendChild(A);v.appendChild(c);let z=null;const H=[];let x=!1;function F(){if(M(f.value))return f.value(w);if(f.value!==void 0&&!$(f.value))return f.value;const te=$(f.value)?f.value:f,ee=te.of,re=te.fn||"sum",se=te.show;return w?re==="count"?B().length:ee?se?q(String(ee),String(re),String(se)):C()==="filtered"&&w.statistics&&M(w.statistics.reduce)?w.statistics.reduce(String(ee),String(re)):Z(B().map(de=>p(de,String(ee))),String(re)):null:null}function C(){return String(f.scope||"filtered")}function B(){if(!w||!w.rows)return[];const te=C();if(te==="all"){const re=[];return M(w.rows.forEachAll)&&w.rows.forEachAll(se=>{se.group||re.push(a(se))}),re}if(te==="selected")return(w.selection&&M(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(a);const ee=[];return M(w.rows.forEach)&&w.rows.forEach(re=>{re.group||ee.push(a(re))}),ee}function q(te,ee,re){if(ee!=="min"&&ee!=="max")return R(`stat.show.${ee}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ee}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,de=null;for(const ie of B()){const oe=Number(p(ie,te));Number.isFinite(oe)&&(se===null||(ee==="max"?oe>se:oe<se))&&(se=oe,de=ie)}return de===null?null:p(de,re)}function Q(te){if(M(f.format))return String(f.format(te,w));if(te==null)return f.empty??"—";const ee=$(f.value)?f.value:f,re=ee.show||ee.of;if((ee.show?!0:u.has(String(ee.fn||"sum")))&&w&&re&&M(w.columns?.get)){const de=w.columns.get(String(re));if(de&&M(de.formatValue))return de.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(f.decimals??2):String(te)}function Y(te){return te?(w&&w.messages||I).t(`stat.tone.${te}`):""}function J(){if(x)return;const te=F(),ee=r(f)&&!!w&&!o(w),re=ee?null:te,se=M(f.baseline)?f.baseline(w):f.baseline;z=re,j.textContent=f.title??"",j.hidden=!f.title,E.textContent=Q(re),P.hidden=!ee,ee&&(P.textContent=w.messages.t("stat.noData"));const de=ee||se===void 0||se===null?n:t(typeof re=="number"?re:null,Number(se)),ie=i(de.direction,f.goodWhen||"up");if(T.hidden=de.change===null,de.change!==null){const pe=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Me=de.percent===null?Q(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;T.textContent=`${pe} ${Me}`,T.setAttribute("data-tone",ie),T.setAttribute("data-direction",de.direction)}const oe=M(f.interval)?f.interval(re,w):null,ue=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);O.hidden=!ue,ue&&(O.textContent=`${Q(oe.lower)} – ${Q(oe.upper)}`,Number.isFinite(oe.confidence)&&O.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const ce=ee?d:f.bands?s(re,f.bands,w):null;ce?c.setAttribute("data-tone",ce):c.removeAttribute("data-tone"),A.textContent=M(f.footer)?String(f.footer(re,w)):f.footer??"",A.hidden=!A.textContent,c.setAttribute("aria-label",[f.title,E.textContent,ee?P.textContent:"",ue?O.textContent:"",de.change===null?"":T.textContent,de.change===null?"":Y(ie),A.textContent].filter(Boolean).join(", "))}if(w&&M(w.on)&&f.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ee=re=>{te==="model:changed"&&!U(re)||J()};w.on(te,ee),H.push(()=>M(w.off)&&w.off(te,ee))}return J(),{element:()=>c,value:()=>z,refresh:J,destroy(){x=!0;for(const te of H)try{te()}catch{}H.length=0,c.remove()}}}function a(g){return $(g)&&"data"in g?g.data:g}function p(g,f){if(!$(g))return;if(!f.includes("."))return g[f];let w=g;for(const v of f.split(".")){if(!$(w))return;w=w[v]}return w}function m(g,f){if(g&&typeof g=="object")return g;if(typeof g!="string")return null;const w=f&&f.element&&f.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(g):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Ce("packages/dom/src/kpistrip.js",function(e,G){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isObject,R=G("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Z{#e;#t;#n;#r=null;#o=[];constructor({grid:U,document:D,kpis:I}){this.#e=U,this.#t=D,this.#n=Array.isArray(I)?I.filter(M):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const D=this.#t.createElement("div");D.className=`lattice ${W.band}`,D.setAttribute("role","group"),D.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=D;for(const I of this.#n){const k=R({...I,grid:this.#e,container:D});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)}}}),Ce("packages/dom/src/createGrid.js",function(e,G){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const M=G("packages/core/src/index.js").createHeadlessGrid,R=G("packages/core/src/defaults.js").applyDefaults,Z=G("packages/core/src/export/download.js").downloadBlob,V=G("packages/core/src/internal/util.js"),U=V.fail,D=V.isFunction,I=V.warnOnce,S=G("packages/dom/src/localviews.js").createLocalViewStorage,d=G("packages/dom/src/renderer/index.js").DomRenderer,n=G("packages/dom/src/cell/index.js").createCellLayer,t=G("packages/dom/src/cell/icons.js"),i=t.icon,s=t.iconNames,o=G("packages/dom/src/editors/index.js").editors,a=G("packages/dom/src/filters/index.js").filters,p=G("packages/dom/src/ui/index.js"),m=p.StatusBar,b=p.TooltipManager,g=p.Pagination,f=p.GroupByZone,v=G("packages/dom/src/ui/celltooltip.js").CellTooltips,c=G("packages/dom/src/filtermenu.js").FilterMenu,E=G("packages/dom/src/columnmenu.js").ColumnMenu,T=G("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=G("packages/dom/src/rowreorder.js").RowReorder,z=G("packages/dom/src/alignedgrids.js").AlignedGrids,x=G("packages/dom/src/columntagbar.js").ColumnTagBar,C=G("packages/dom/src/anomalychip.js").AnomalyChip,q=G("packages/dom/src/rowform.js").RowForm,Q=G("packages/dom/src/toolpanelmount.js"),Y=Q.ToolPanelDock,J=Q.panelHost,ee=G("packages/dom/src/celledit.js").CellEditController,se=G("packages/dom/src/editbar.js").EditBar,ie=G("packages/dom/src/rangeselect.js").RangeController,ue=G("packages/core/src/model/selection.js").resolveSelectionConfig,pe=G("packages/dom/src/importer.js").ImportController,$e=G("packages/dom/src/historybar.js").HistoryBar,ke=G("packages/dom/src/diffpaint.js").DiffPainter,Ee=G("packages/dom/src/detailhost.js").DetailHost,ze=G("packages/dom/src/highlightpaint.js").HighlightPainter,Qe=G("packages/dom/src/findpaint.js").FindPainter,Ae=G("packages/dom/src/findbar.js").FindBar,Ve=G("packages/dom/src/redactpaint.js").RedactionPainter,st=G("packages/dom/src/validationpaint.js").ValidationPainter,bt=G("packages/dom/src/presentation.js").PresentationController,Tt=G("packages/dom/src/capture.js").captureElement,Dt=G("packages/dom/src/annotate.js").AnnotationLayer,Yt=G("packages/dom/src/timelinebar.js").TimelineBar,fe=G("packages/dom/src/commentpaint.js").CommentPainter,xe=G("packages/dom/src/presencepaint.js").PresencePainter,Ze=G("packages/dom/src/commentpanel.js").CommentPanel,gt=G("packages/dom/src/watermark.js").Watermark,Oe=G("packages/dom/src/maximise.js").Maximiser,Ne=G("packages/dom/src/promptbar.js").PromptBar,ve=G("packages/dom/src/kpistrip.js").KpiStrip;function Te(Le,rt,et){const it=rt==="redo"?"toolbar.redo":"toolbar.undo";return!et||!et.label?Le(it):Le(rt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:et.label})}const Pe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Re=2e3;function Ue(Le,rt,et){const it=rt.annotate===!0?qe(Le):[];if(rt.actions===!1)return[];if(rt.actions===void 0&&rt.side!=="left")return it;const Et=Array.isArray(rt.actions)?rt.actions:Pe,Nt=(Ot,Vt)=>Le.messages.t(Ot,Vt),dt={undo:{name:"undo",title:()=>Te(Nt,"undo",Le.history.peek("undo")),icon:"undo",run:()=>Le.history.undo(),enabled:()=>Le.history.canUndo()},redo:{name:"redo",title:()=>Te(Nt,"redo",Le.history.peek("redo")),icon:"redo",run:()=>Le.history.redo(),enabled:()=>Le.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Le.export.csv({download:!0,fileName:rt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Le.export.excel({download:!0,fileName:rt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Le.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Le.export.print()},pause:{name:"pause",title:()=>{if(!Le.updates.paused)return Nt("toolbar.pause");const Ot=Le.updates.stats().pending;return Ot?Nt("toolbar.applyHeld",{count:Ot}):Nt("toolbar.resume")},icon:()=>Le.updates.paused?"play":"pause",run:()=>Le.updates.paused?Le.updates.resume():Le.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Le.state.reset(),enabled:()=>Le.state.modified()},maximise:{name:"maximise",title:()=>Nt(et&&et.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>et&&et.active()?"minimise":"maximise",run:()=>et.toggle()}};return et||delete dt.maximise,Et.map(Ot=>Ot==="-"?{name:"-",separator:!0}:typeof Ot=="string"?dt[Ot]:!Ot||typeof Ot!="object"||!Ot.name?null:{...Ot,run:D(Ot.run)?()=>Ot.run({grid:Le,keys:Le.selection&&D(Le.selection.keys)?Le.selection.keys():[],cells:Le.selection&&D(Le.selection.cells)?Le.selection.cells():[]}):void 0}).filter(Boolean).concat(it)}function qe(Le){const rt=it=>Le.messages.t(it),et={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(it=>({name:it,title:()=>rt(`toolbar.annotate.${it}`),icon:et[it],run:()=>Le.annotate?.use(it),active:()=>Le.annotate?.tool===it,annotation:!0}))}const ft=["pen","arrow","rect","highlight"];function at(Le){return{rowCount:()=>{if(D(Le.rows.matchCount))return Le.rows.matchCount();const rt=Le.pagination&&D(Le.pagination.get)?Le.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:Le.rows.count()},totalRowCount:()=>D(Le.rows.totalCount)?Le.rows.totalCount():Le.rows.count(),selectedCount:()=>{const rt=Le.selection&&Le.selection.keys?Le.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=Le.selection;return!rt||!D(rt.cells)?[]:rt.cells().map(({key:et,colId:it})=>Le.rows.value(et,it))},hiddenUnresolved:()=>D(Le.comments&&Le.comments.hiddenUnresolved)?Le.comments.hiddenUnresolved():0,progress:()=>D(Le.source&&Le.source.progress)?Le.source.progress():null,updateStats:()=>Le.updates?Le.updates.stats():null}}function mt(Le,rt){for(const[et,it]of Object.entries(o||{}))Le.register("editor",et,it);for(const[et,it]of Object.entries(a||{}))Le.register("filter",et,it);for(const[et,it]of Object.entries(rt.components||{}))Le.register("component",et,it);for(const[et,it]of Object.entries(rt.pipes||{}))Le.register("pipe",et,it);for(const[et,it]of Object.entries(rt.totalFns||{}))Le.register("totalFn",et,it)}function ct(Le,rt,et,it,Et,Nt){const dt=[],Ot=rt.viewport;let Vt=null;if(et.maximise!==!1&&(Vt=new Oe({element:Nt,document:it,onChange:()=>rt.invalidate("all"),captureScroll:()=>rt.scrollState(),restoreScroll:tt=>rt.restoreScroll(tt)}),Le.maximise=Vt,dt.push(()=>Vt.destroy())),et.statusBar){const tt=typeof et.statusBar=="object"?et.statusBar:{},pt=new m;pt.init({document:it,host:at(Le),panels:tt.panels,registry:tt.registry,locale:Le.get("locale"),messages:Le.messages}),Ot.statusBar.appendChild(pt.element());const Pt=()=>{const nn=Ot.statusBar.offsetHeight||Ot.statusBar.getBoundingClientRect?.().height||0;Ot.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},$t=()=>{pt.refresh(),Pt()},Ht=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Le.on(nn,$t));$t(),Pt(),dt.push(()=>{for(const nn of Ht)nn();Ot.root.style.removeProperty("--lattice-status-height"),pt.destroy?.()})}const Wt=ue(et.selection);if(Wt.ranges){const tt=new ie({grid:Le,renderer:rt,document:it});tt.mount(),Le.ranges=tt,dt.push(()=>tt.destroy())}if(et.import){const tt=new pe({grid:Le,renderer:rt,document:it,settings:typeof et.import=="object"?et.import:{}});Le.importer=tt,dt.push(()=>tt.destroy())}if(et.historyBar){const tt=typeof et.historyBar=="object"?et.historyBar.element:null,pt=new $e;pt.init({document:it,host:{undo:()=>Le.history.undo(),redo:()=>Le.history.redo(),canUndo:()=>Le.history.canUndo(),canRedo:()=>Le.history.canRedo(),peek:$t=>Le.history.peek($t),list:()=>Le.history.list()},props:typeof et.historyBar=="object"?et.historyBar:{}}),(tt||Ot.root).appendChild(pt.element());const Pt=[Le.on("history:changed",()=>pt.refresh())];Le.historyBar=pt,dt.push(()=>{for(const $t of Pt)$t();pt.destroy()})}if(et.diff){const tt=new ke({grid:Le,renderer:rt});tt.mount(),Le.diffPainter=tt,dt.push(()=>tt.destroy())}if(et.ai&&D(et.ai.ask)){const tt=new Ne;tt.init({document:it,grid:Le,ask:et.ai.ask,schemaOptions:et.ai.schemaOptions,context:et.ai.context,placeholder:et.ai.placeholder});const pt=et.ai.element||Ot.root;pt===Ot.root?pt.insertBefore(tt.element(),pt.firstChild):pt.appendChild(tt.element()),Le.promptBar=tt,dt.push(()=>tt.destroy())}if(et.groupPanel){const tt=typeof et.groupPanel=="object"?et.groupPanel:{},pt=new f;pt.init({document:it,grid:Le,host:J(Le,it,(Pt,$t)=>rt.announce?.(Pt,$t)),props:{header:Ot.header,hint:tt.hint}}),Ot.root.insertBefore(pt.element(),Ot.header),Le.groupPanel=pt;for(const Pt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])D(Le.on)&&dt.push(Le.on(Pt,()=>pt.refresh()));dt.push(()=>pt.destroy())}if(et.kpis){const tt=new ve({grid:Le,document:it,kpis:et.kpis});tt.active&&(tt.mount(),Ot.root.insertBefore(tt.element(),Ot.header),Le.kpiStrip=tt,dt.push(()=>tt.destroy()))}if(et.toolPanel){const tt=typeof et.toolPanel=="object"?et.toolPanel:{},pt=new Y({grid:Le,document:it,root:Ot.root,panels:tt.panels,openPanel:tt.openPanel,side:tt.side,icons:tt.icons,actions:Ue(Le,tt,Vt),announce:(Pt,$t)=>rt.announce?.(Pt,$t)});pt.mount(),Le.toolPanel=pt,dt.push(()=>pt.destroy()),tt.annotate===void 0&&(dt.push(Le.on("presentation:started",()=>{for(const Pt of qe(Le))pt.addAction(Pt)})),dt.push(Le.on("presentation:ended",()=>{for(const Pt of ft)pt.removeAction(Pt)})))}if(et.pagination){const tt=typeof et.pagination=="object"?et.pagination:{},pt=new g;pt.init({document:it,pageSize:tt.pageSize,pageSizes:tt.pageSizes,page:tt.page,total:tt.total,locale:Le.get("locale"),messages:Le.messages,onChange:({page:Ht,pageSize:nn})=>Le.pagination.set({page:Ht,pageSize:nn})});const Pt=()=>{const Ht=Le.pagination.get();pt.total=Ht.total,pt.counting=Ht.counting===!0,pt.page=Ht.page,pt.paint()};Le.pagination.set({pageSize:pt.pageSize}),Pt();const $t=["rows:changed","filter:changed","model:changed"].map(Ht=>Le.on(Ht,Pt));Ot.statusBar.appendChild(pt.element()),dt.push(()=>{for(const Ht of $t)Ht();pt.destroy?.()})}if(et.edit!==!1)if(et.editBar){const tt=new se({grid:Le,document:it,root:Ot.root});tt.mount(),Le.editBar=tt,dt.push(()=>tt.destroy())}else{const tt=new ee({grid:Le,document:it,renderer:rt,registry:Et,cellLayer:rt.cellLayer});tt.mount(),dt.push(()=>tt.destroy())}const an=new c({grid:Le,document:it,layer:Ot.overlays,registry:Et});an.mount(),dt.push(()=>an.destroy());const ln=new E({grid:Le,document:it,host:Ot.root,cellMenu:et.contextMenu!==!1,headerMenu:et.columnMenu!==!1,items:D(et.contextMenu)?et.contextMenu:void 0,headerItems:D(et.columnMenu)?et.columnMenu:void 0});if(ln.mount(),dt.push(()=>ln.destroy()),Array.isArray(et.alignedGrids)&&et.alignedGrids.length){const tt=new z;tt.add(Le);for(const pt of et.alignedGrids)pt&&pt!==Le&&tt.add(pt);dt.push(()=>tt.destroy())}const zt=new q({grid:Le,renderer:rt,document:it,registry:Et});zt.active&&(zt.mount(),dt.push(()=>zt.destroy())),Object.defineProperty(Le,"form",{configurable:!0,value:Object.freeze({open(tt){return zt.active?zt.openRow(tt):!1},close(){zt.active&&zt.close()},save(){return zt.active?zt.save():!1},isOpen(){return zt.active?zt.open:!1}})}),dt.push(()=>{delete Le.form}),Object.defineProperty(Le,"icons",{configurable:!0,value:Object.freeze({get(tt){const pt=i(tt);return pt?{viewBox:pt.viewBox,paths:pt.paths.slice(),paint:pt.paint==="stroke"?"stroke":"fill"}:null},names(){return s()}})}),dt.push(()=>{delete Le.icons});const un=new x({grid:Le,renderer:rt,document:it});un.active&&(un.mount(),dt.push(()=>un.destroy()));const cn=new C({grid:Le,renderer:rt,document:it});cn.active&&(cn.mount(),dt.push(()=>cn.destroy()));const rn=new P({grid:Le,renderer:rt,document:it});if(rn.active){rn.mount(),rn.paint();const tt=Le.on("render:done",()=>rn.paint());dt.push(()=>{tt(),rn.destroy()})}if(et.shortcuts!==!1){const tt=new T({grid:Le,renderer:rt});tt.mount(),dt.push(()=>tt.destroy())}const jt=new ze({grid:Le,renderer:rt,window:it.defaultView||void 0});jt.mount(),dt.push(()=>jt.destroy());const Rt=new Qe({grid:Le,renderer:rt,window:it.defaultView||void 0});if(Rt.mount(),dt.push(()=>Rt.destroy()),et.find!==!1){const tt=new Ae({grid:Le,renderer:rt,document:it,settings:et.find});tt.mount(),dt.push(()=>tt.destroy())}const Ft=new Ve({grid:Le,renderer:rt});Ft.mount(),dt.push(()=>Ft.destroy());const Ut=new st({grid:Le,renderer:rt});Ut.mount(),dt.push(()=>Ut.destroy());const Qt=new bt({grid:Le,renderer:rt,maximiser:Vt});Qt.mount(),dt.push(()=>Qt.destroy());const qt=new Yt({grid:Le,renderer:rt});qt.mount(),dt.push(()=>qt.destroy()),et.environment||Le.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let Zt=null;for(const[tt,pt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])dt.push(Le.on(tt,()=>{Zt=pt}));dt.push(Le.on("render:done",tt=>{Le.diagnostics.render(Zt||tt.cause,tt.phases),Zt=null}));const en=new xe({grid:Le,renderer:rt});if(en.mount(),dt.push(()=>en.destroy()),dt.push(Le.on("presence:lockRefused",tt=>en.announceRefusal(tt.peer))),Le.presence&&Le.presence.enabled){for(const Pt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])dt.push(Le.on(Pt,()=>Le.presence.publish()));let tt="";dt.push(Le.on("render:done",()=>{const Pt=rt.focusState&&rt.focusState(),$t=Pt?`${Pt.rowKey}${Pt.colId}`:"";$t!==tt&&(tt=$t,Le.presence.publish())}));const pt=Nt.ownerDocument;if(pt&&D(pt.addEventListener)){const Pt=()=>Le.presence.setPaused(pt.visibilityState==="hidden");pt.addEventListener("visibilitychange",Pt),Pt(),dt.push(()=>pt.removeEventListener("visibilitychange",Pt))}}const Xt=new fe({grid:Le,renderer:rt});Xt.mount(),dt.push(()=>Xt.destroy());const dn=new Ze({grid:Le,renderer:rt});dn.mount(),dt.push(()=>dn.destroy()),dt.push(Le.on("facet:computed",()=>rt.refreshHeader?.())),Wt&&Wt.headerCheckbox===!0&&dt.push(Le.on("selection:changed",()=>rt.refreshHeader?.())),dt.push(Le.on("facet:expanded",()=>rt.invalidate("columns"))),dt.push(Le.on("model:changed",()=>rt.invalidate("rows")));const Kt=(tt,pt)=>rt.announce?.(tt,pt),fn=Le.messages,Bt=(tt,pt)=>fn.t(tt,pt),pn=tt=>Bt("count.rows",{count:tt});dt.push(Le.on("sort:changed",()=>{const tt=Le.sort.get();if(!tt.length){Kt(Bt("a11y.sort.cleared"));return}const pt=tt.map(Pt=>{const $t=Le.columns.get(Pt.col);return Bt("a11y.sort.column",{column:$t&&$t.title||Pt.col,direction:Bt(Pt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Kt(Bt("a11y.sort.by",{columns:fn.list(pt)}))})),dt.push(Le.on("filter:changed",()=>{const tt=Le.rows.matchCount?Le.rows.matchCount():Le.rows.count(),pt=Le.rows.totalCount?Le.rows.totalCount():tt;Kt(tt===pt?Bt("a11y.filter.cleared",{rows:pn(pt)}):Bt("a11y.filter.applied",{shown:pn(tt),total:pn(pt)}))})),dt.push(Le.on("selection:changed",()=>{const tt=Le.selection.keys().length;Kt(tt===0?Bt("a11y.selection.cleared"):Bt("a11y.selection.count",{count:tt}))})),dt.push(Le.on("group:toggled",tt=>{const pt=Le.rows.byKey?Le.rows.byKey(tt.key):null,Pt=(pt&&(pt.groupLabel??pt.groupValue))??tt.key;Kt(Bt(tt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Pt,rows:pn(Le.rows.count())}))})),dt.push(Le.on("column:grouped",tt=>{const pt=Array.isArray(tt.columns)?tt.columns:[];if(!pt.length){Kt(Bt("a11y.group.cleared"));return}const Pt=pt.map($t=>{const Ht=Le.columns.get($t);return Ht&&Ht.title||$t});Kt(Bt("a11y.group.by",{columns:fn.list(Pt)}))})),dt.push(Le.on("page:changed",tt=>{const pt=Number(tt.size)||0,Pt=Number(tt.total)||0,$t=pt>0?Math.max(1,Math.ceil(Pt/pt)):1;Kt(Bt("a11y.page.position",{page:(Number(tt.page)||0)+1,pages:$t}))}));let tn={added:0,removed:0},_t=null;const En=()=>{_t=null;const tt=[];tn.added&&tt.push(Bt("count.rowsAdded",{count:tn.added})),tn.removed&&tt.push(Bt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},tt.length&&Kt(fn.list(tt))};dt.push(Le.on("rows:changed",tt=>{if(!tt||typeof tt.added!="number")return;const pt=Number(tt.added)||0,Pt=Number(tt.removed)||0;!pt&&!Pt||(tn.added+=pt,tn.removed+=Pt,_t||(_t=setTimeout(En,Re)))})),dt.push(()=>{_t&&clearTimeout(_t)}),dt.push(Le.on("rows:paused",()=>{_t&&(clearTimeout(_t),_t=null),tn={added:0,removed:0},Kt(Bt("a11y.updates.paused"),{repeat:!0})})),dt.push(Le.on("rows:resumed",()=>Kt(Bt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:tt,first:pt}=hn;if(hn={count:0,first:null},!tt||!pt)return;const Pt=Le.columns.get(pt.colId),$t=Pt&&Pt.title||pt.colId,Ht=pt.reason?Bt("a11y.edit.reason",{reason:pt.reason}):"";if(tt===1){const nn=pt.restored===void 0||pt.restored===null||pt.restored===""?Bt("value.empty"):String(pt.restored);Kt(Bt("a11y.edit.refusedOne",{column:$t,value:nn,reason:Ht}),{repeat:!0});return}Kt(Bt("a11y.edit.refusedMany",{count:tt,reason:Ht}),{repeat:!0})};dt.push(Le.on("cell:reverted",tt=>{!tt||!tt.applied||(hn.count+=1,hn.first||(hn.first=tt),mn||(mn=setTimeout(Sn,150)))})),dt.push(()=>{mn&&clearTimeout(mn)}),dt.push(Le.on("history:applied",tt=>{const pt=!!(tt&&tt.direction==="redo"),Pt=tt&&tt.step&&tt.step.label;Kt(Pt?Bt(pt?"a11y.history.redo":"a11y.history.undo",{label:Pt}):Bt(pt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new Dt({grid:Le,renderer:rt,seed:et.state&&Array.isArray(et.state.annotations)?et.state.annotations:null});gn.mount(),dt.push(()=>gn.destroy()),Le.annotate=gn,Le.capture=async(tt={})=>{const{blob:pt,width:Pt,height:$t}=await Tt(rt.viewport.root,tt);return(tt.download===!0||tt.download!==!1&&tt.fileName)&&Z(pt,tt.fileName||`${Le.get("exportName")||"grid"}.png`),Le.emit("presentation:captured",{width:Pt,height:$t,bytes:pt.size,mimeType:pt.type,fileName:tt.fileName||null},"api"),pt};const On=new gt({grid:Le,document:it,element:Ot.overlays,window:it.defaultView||void 0});On.mount(),dt.push(()=>On.destroy());const Tn=new b({grid:Le,document:it,element:Ot.overlays});Tn.mount?.(),dt.push(()=>Tn.destroy?.());const jn=new v({grid:Le,host:Le.rendererHost(),viewport:Ot,document:it});return jn.mount(),dt.push(()=>jn.destroy()),dt}function vt(Le){const rt=[],et=it=>{if(it&&(it.__lattice&&rt.push(it),it.children))for(const Et of it.children)et(Et)};return et(Le),rt}function St(Le,rt={}){(!Le||typeof Le!="object"||!("appendChild"in Le))&&U("createGrid needs a host element as its first argument."),rt=R(rt);const et=Le.ownerDocument||(typeof document<"u"?document:null);et||U("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const it=et.documentElement&&et.documentElement.lang,Et=!rt.licence&&D(et.querySelector)?et.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...rt};if(!rt.locale&&it&&(Nt.locale=it),Et&&(Nt.licence=Et),rt.views&&rt.views.local)if(rt.views.storage)I("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const zt=rt.views.local===!0?{}:rt.views.local;Nt.views={...rt.views,storage:S(zt)}}const dt=M(Nt),Ot=dt.rendererHost();Ot.document=et,mt(Ot.registry,rt),Ot.cellLayer=n(Ot),Ot.detailHost=new Ee({grid:dt,document:Le.ownerDocument||globalThis.document,createGrid:(zt,un)=>St(zt,un)});const Vt=new d(Le,Ot),Wt=dt.on("detail:toggled",()=>{Ot.detailHost.syncTarget(),Ot.detailHost.prune()}),sn=dt.on("config:changed",zt=>{zt&&zt.key==="detail"&&Ot.detailHost.reconfigure()});dt.on("destroy",()=>{Wt(),sn(),Ot.detailHost.destroy()}),Ot.detailHost.syncTarget(),dt.attachRenderer(Vt),Vt.mount();const an=ct(dt,Vt,rt,et,Ot.registry,Le),ln=dt.destroy.bind(dt);return dt.destroy=()=>{for(const zt of an)try{zt()}catch{}Le.__lattice===dt&&(Le.__lattice=null),ln()},Le.__lattice=dt,dt}}),Ce("packages/dom/src/hydrate.js",function(e,G){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return n}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,V=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,D=G("packages/dom/src/createGrid.js").createGrid,I=new Set([...Object.keys(W),...Object.keys(V)]);function k(t,i){for(const s of t.children)if(s.tagName===i.toUpperCase())return s;return null}function S(t,i){const s=[];for(const r of t.children)r.tagName===i.toUpperCase()&&s.push(r);return s}function y(t,i){const s=M(t.getAttribute)?t.getAttribute("data-field"):null;return s||String(t.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${i}`}function d(t){const i=t.trim();if(i==="")return null;if(i==="true"||i==="false")return i==="true";const s=Number(i);return Number.isFinite(s)&&i!==""?s:i}function u(t){const i=k(t,"thead"),s=k(i||t,"tr"),o=(s?S(s,"th").length?S(s,"th"):S(s,"td"):[]).map((m,b)=>{const g=y(m,b),f={id:g,field:g,title:String(m.textContent||"").trim()||g},w=M(m.getAttribute)?m.getAttribute("data-type"):null;w&&(I.has(w)?f.type=w:$(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${g}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const v=M(m.getAttribute)?m.getAttribute("data-format"):null;return v&&(f.format=v),f}),l=k(t,"tbody"),p=(l?S(l,"tr"):S(t,"tr").filter(m=>m!==s)).map((m,b)=>{const g=S(m,"td"),w={__row:(M(m.getAttribute)?m.getAttribute("data-id"):null)||`row${b}`};return o.forEach((v,h)=>{w[v.field]=g[h]?d(String(g[h].textContent||"")):null}),w});return{columns:o,rows:p}}function n(t,i={}){const{columns:s,rows:r}=u(t),o=t.ownerDocument.createElement("div");return t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),D(o,{rowKey:"__row",columns:s,rows:r,...i,columns:i.columns!==void 0?i.columns:s,rows:i.rows!==void 0?i.rows:r})}}),Ce("packages/dom/src/autoinit.js",function(e,G){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return I}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/dom/src/createGrid.js").createGrid,Z=G("packages/dom/src/hydrate.js").hydrateTable;function V(k,S){const y=[];return M(k.hasAttribute)&&k.hasAttribute(S)&&y.push(k),M(k.querySelectorAll)&&y.push(...k.querySelectorAll(`[${S}]`)),y}function U(k){const S=k.parentNode;if(!S||!S.children)return null;const y=[...S.children],d=y.indexOf(k),u=[y[d+1],y[d-1]];for(const n of u)if(n&&n.tagName==="SCRIPT"&&M(n.getAttribute)&&n.hasAttribute("data-lattice-config"))return n;return null}function D(k){const S=U(k);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function I(k){const S=k||(typeof document<"u"?document:null);if(!S)return[];const y=[];for(const d of V(S,"data-lattice-grid")){if(d.__lattice)continue;const u=D(d);y.push(d.tagName==="TABLE"?Z(d,u):R(d,u))}return y}}),Ce("packages/dom/src/index.js",function(e,G){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const _=G("packages/dom/src/createGrid.js"),M=_.createGrid,$=G("packages/dom/src/hydrate.js"),R=$.hydrateTable,W=G("packages/dom/src/autoinit.js"),Z=W.autoInit,V=G("packages/dom/src/localviews.js"),U=V.createLocalViewStorage,D=G("packages/core/src/index.js"),I=D.createHeadlessGrid,k=D.registerModules,S=D.setLicence,y=D.version,d=D.getVersion,u=D.serialiseState,n=D.restoreState,t=D.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return _.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return _.gridElementsWithin}});const i=G("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return i.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return i.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return i.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return $.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return $.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return V.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return V.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return D.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return D.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return D.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return D.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return D.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return D.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return D.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return D.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return D.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return D.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return D.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return D.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return D.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return D.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return D.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return D.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return D.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return D.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return D.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return D.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return D.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return D.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return D.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return D.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return D.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return D.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return D.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return D.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return D.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return D.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return D.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return D.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return D.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return D.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return D.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return D.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return D.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return D.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return D.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return D.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return D.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return D.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return D.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return D.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return D.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return D.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return D.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return D.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return D.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return D.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return D.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return D.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return D.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return D.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return D.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return D.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return D.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return D.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return D.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return D.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return D.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return D.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return D.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return D.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return D.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return D.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return D.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return D.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return D.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return D.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return D.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return D.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return D.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return D.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return D.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return D.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return D.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return D.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return D.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return D.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return D.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return D.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return D.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return D.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return D.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return D.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return D.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return D.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return D.WINDOW_KINDS}}),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}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return D.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return D.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return D.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return D.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return D.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return D.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return D.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return D.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return D.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return D.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return D.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return D.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return D.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return D.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return D.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return D.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return D.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return D.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return D.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return D.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return D.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return D.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return D.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return D.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return D.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return D.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return D.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return D.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return D.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return D.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return D.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return D.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return D.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return D.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return D.splunkAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return D.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return D.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return D.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return D.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return D.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return D.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return D.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return D.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return D.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return D.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return D.VERSION}});const s=G("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return s.DomRenderer}});const r=G("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return r.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return r.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return r.branchFor}});const o=G("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return o.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return o.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return o.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return o.autoGroupMenuItems}});const l=G("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const a=G("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return a.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return a.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return a.mountPanel}});const p=G("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return p.CellEditController}});const m=G("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return m.EditBar}});const b=G("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return b.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return b.HISTORY_CLS}});const g=G("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return g.DiffPainter}});const f=G("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return f.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return f.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return f.summariseDiff}});const w=G("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return w.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return w.PROMPT_CLASS}});const v=G("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 h=G("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return h.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return h.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return h.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return h.BaseEditor}});const c=G("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return c.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return c.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return c.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return c.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return c.ConditionFilter}});const j=G("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return j.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return j.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return j.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return j.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return j.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return j.OverlayLayer}});const E=G("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return E.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return E.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return E.licenceState}});const O=Object.freeze({createGrid:M,createHeadlessGrid:I,defaults:t,registerModules:k,setLicence:S,version:y,autoInit:Z,hydrateTable:R,serialiseState:u,restoreState:n,createLocalViewStorage:U}),T=O});try{Un("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return H}});const fe="1.74.0";async function he(){return fe}const X="1.74.0",z=new Set,te=2e3;function x(w){if(z.add(w),z.size>te){const A=z.values().next().value;A!==void 0&&z.delete(A)}}const T=[],K=500;function re(w,A,q){T.push({key:w,level:A,message:q.map(le=>typeof le=="string"?le:J(le)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function ue(){return T.map(w=>({...w}))}function oe(w,...A){z.has(w)||(x(w),re(w,"warn",A),console.warn("[lattice]",...A))}function Y(w,...A){z.has(w)||(x(w),re(w,"info",A),console.info("[lattice]",...A))}function L(){z.clear(),T.length=0}function Q(w,A){const q=new Error(`[lattice] ${w}`);throw A!==void 0&&(q.cause=A),q}function _(w,A){w||Q(A)}const C=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function i(w){return typeof w=="function"}function s(w){return w==null}function u(w){return w==null||w===""}function f(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const c=new Map;function t(w){let A=c.get(w);if(A)return A;if(!w.includes("."))A=q=>q?.[w];else{const q=w.split("."),le=q.length;A=ae=>{let de=ae;for(let pe=0;pe<le;pe++){if(de==null)return;de=de[q[pe]]}return de}}return c.set(w,A),A}const a=new Map;function m(w){let A=a.get(w);if(A)return A;if(!w.includes("."))A=(q,le)=>{q!=null&&(q[w]=le)};else{const q=w.split("."),le=q.length-1;A=(ae,de)=>{let pe=ae;for(let ge=0;ge<le;ge++){if(pe==null)return;const ke=q[ge];pe[ke]==null&&(pe[ke]={}),pe=pe[ke]}pe!=null&&(pe[q[le]]=de)}}return a.set(w,A),A}function e(w,A){return t(A)(w)}function d(w,A,q){m(A)(w,q)}function h(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,q=>q.toUpperCase()):""}const r={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function n(w){const A=w==null?"":String(w);return/[&<>"\']/.test(A)?A.replace(/[&<>"\']/g,q=>r[q]):A}function l(w){return String(w).replace(/\\w\\S*/g,A=>A[0].toUpperCase()+A.slice(1).toLowerCase())}function g(w,A,q){if(w!==void 0)return w===!0?{enabled:!0,...q}:w===!1?{enabled:!1}:M(w)?w:{[A]:w,enabled:!0}}function P(w){return w==null?[]:Array.isArray(w)?w:[w]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function G(w,A){if(!M(w))return M(A)?{...A}:A;if(!M(A))return A===void 0?w:A;const q={...w};for(const le of Object.keys(A)){if(S.has(le))continue;const ae=A[le];ae!==void 0&&(q[le]=M(ae)&&M(q[le])?G(q[le],ae):ae)}return q}function F(w,A){if(!M(w)||!M(A)||w===A)return A;const q=Object.create(Object.getPrototypeOf(w));return Object.assign(q,w,A),q}class E{#t;#e=new Map;#n;constructor(A=256,q=null){this.#t=A,this.#n=q}get size(){return this.#e.size}get max(){return this.#t}set max(A){this.#t=A,this.#r()}has(A){return this.#e.has(A)}get(A){const q=this.#e;if(!q.has(A))return;const le=q.get(A);return q.delete(A),q.set(A,le),le}peek(A){return this.#e.get(A)}set(A,q){const le=this.#e;return le.has(A)&&le.delete(A),le.set(A,q),this.#r(),q}delete(A){const q=this.#e.get(A);return this.#e.delete(A)&&this.#n&&this.#n(q,A),q}clear(){if(this.#n)for(const[A,q]of this.#e)this.#n(q,A);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const A=this.#e;for(;A.size>this.#t;){const q=A.keys().next().value,le=A.get(q);A.delete(q),this.#n&&this.#n(le,q)}}}const Z=new Map;function R(w,A){const q=`${w||""}|${A?JSON.stringify(A):""}`;let le=Z.get(q);return le||(le=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...A}),Z.set(q,le)),le}function v(w,A){if(w===A)return 0;if(w==null)return 1;if(A==null)return-1;if(typeof w=="number"&&typeof A=="number")return Number.isNaN(w)?Number.isNaN(A)?0:1:Number.isNaN(A)||w<A?-1:w>A?1:0;const q=String(w),le=String(A);return q<le?-1:q>le?1:0}function U(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const V=typeof requestAnimationFrame=="function";function $(w){return V?requestAnimationFrame(w):setTimeout(()=>w(U()),16)}function ee(w){w!=null&&(V?cancelAnimationFrame(w):clearTimeout(w))}function ne(w){let A=null,q=null;const le=()=>{A=null;const de=q;q=null,w(...de||[])},ae=(...de)=>{q=de,A===null&&(A=$(le))};return ae.cancel=()=>{ee(A),A=null,q=null},ae.flush=()=>{A!==null&&(ee(A),le())},ae}function ce(w,A){let q=null,le=null;const ae=()=>{if(q=null,le===null)return;const ge=le;le=null,w(...ge),de()},de=()=>{q=setTimeout(ae,A),typeof q?.unref=="function"&&q.unref()},pe=(...ge)=>{q===null?(w(...ge),de()):(le=ge,clearTimeout(q),de())};return pe.flush=()=>{if(q!==null&&clearTimeout(q),q=null,le===null)return;const ge=le;le=null,w(...ge)},pe.cancel=()=>{q!==null&&clearTimeout(q),q=null,le=null},pe.pending=()=>q!==null||le!==null,pe}function p(w,A=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:A}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function H(w="l"){return`${w}${(++B).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.isFunction,z=1,te=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),x=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?re(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function re(s){return Array.isArray(s)?s:X(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class ue{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class oe{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const f=this.#e.get(u);if(f!==void 0)return f;const c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const m=he(u).compare,e=this.#t,d=Array.from(a).sort((r,n)=>{const l=e[r],g=e[n];return l===g?0:l==null?1:g==null?-1:m(String(l),String(g))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function Y(s){if(s==null)return null;const u=s.presence?new ue(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new oe(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,m=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(c[e]):c[e];case"bitset":return(c[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=f?f.valueOf(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,presence:u,dict:f,offsets:t,get:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=Y(s[f]);return u}function Q(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function _(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=c=>{if(!_(c))return;const t=c.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const c=f.conditions;if(Array.isArray(c))for(const t of c)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const te=Math.max(0,z|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,te){return te?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const te=Math.max(0,z|0);if(te<=this.#n)return this;const x=Math.ceil(te/fe);if(x>this.#e.length){const T=new Uint8Array(x);T.set(this.#e),this.#e=T}return this.#n=te,this}count(){const z=this.#e,te=he.#t;let x=0;for(let T=0;T<z.length;T++)x+=te[z[T]];return x}and(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]&=te[K];for(let K=T;K<x.length;K++)x[K]=0;return this}or(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]|=te[K];return this}not(){const z=this.#e;for(let te=0;te<z.length;te++)z[te]=~z[te]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<z)-1)}static from(z){const te=Array.isArray(z)?z:Array.from(z),x=new he(te.length);for(let T=0;T<te.length;T++)te[T]&&x.set(T);return x}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(x=[]){this.#t=[];for(let T=0;T<x.length;T++){const K=x[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let x=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(x+=K.length*2),x+=16}return x}codeOf(x){const T=this.#e.get(x);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(x),this.#e.set(x,K),this.#n++,K}lookup(x){const T=this.#e.get(x);return T===void 0?-1:T}has(x){return this.#e.has(x)}valueOf(x){return this.#t[x]}values(){return this.#t}ranks(x){const T=x||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,re=new Array(K);for(let Y=0;Y<K;Y++)re[Y]=Y;const J=he(x).compare,ue=this.#t;re.sort((Y,L)=>this.#h(ue[Y],ue[L],J));const oe=new Uint32Array(K);for(let Y=0;Y<K;Y++)oe[re[Y]]=Y;return this.#r=oe,this.#i=this.#n,this.#s=T,oe}#h(x,T,K){return typeof x=="string"&&typeof T=="string"?K(x,T):X(x,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(X={}){const z=Math.max(1,X.rows??16),te=Math.max(1,X.values??z);this.#t=new Int32Array(te),this.#e=new Uint32Array(z+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(X){return X<0||X>=this.#n?0:this.#e[X+1]-this.#e[X]}at(X){return X<0||X>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[X],this.#e[X+1])}has(X,z){if(X<0||X>=this.#n)return!1;const te=this.#t,x=this.#e[X+1];for(let T=this.#e[X];T<x;T++)if(te[T]===z)return!0;return!1}hasAny(X,z){for(let te=0;te<z.length;te++)if(this.has(X,z[te]))return!0;return!1}hasAll(X,z){for(let te=0;te<z.length;te++)if(!this.has(X,z[te]))return!1;return!0}hasNone(X,z){return!this.hasAny(X,z)}push(X){const z=this.#n,te=X.length;this.#i(z+1),this.#s(this.#r+te);const x=this.#r;for(let T=0;T<te;T++)this.#t[x+T]=X[T]|0;return this.#r+=te,this.#n=z+1,this.#e[z]=x,this.#e[z+1]=this.#r,z}write(X,z){if(X===this.#n){this.push(z);return}if(X<0||X>this.#n)return;const te=this.#e[X],x=this.#e[X+1],T=z.length;if(x-te===T){for(let K=0;K<T;K++)this.#t[te+K]=z[K]|0;return}this.#h(X,z)}compact(X,z,te){const x=this.#t,T=this.#e,K=this.#n,re=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let ue=0;for(let oe=0;oe<K;oe++){if(X[oe]===te)continue;const Y=T[oe],L=T[oe+1];J[X[oe]]=ue;for(let Q=Y;Q<L;Q++)re[ue++]=x[Q];J[X[oe]+1]=ue}this.#t=re,this.#e=J,this.#n=z,this.#r=ue}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<X;)z=z*2||16;const te=new Uint32Array(z+1);te.set(this.#e),this.#e=te}#s(X){if(X<=this.#t.length)return;let z=this.#t.length;for(;z<X;)z=z*2||16;const te=new Int32Array(z);te.set(this.#t),this.#t=te}#h(X,z){const te=this.#t,x=this.#e,T=this.#n,K=z.length-(x[X+1]-x[X]),re=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(x.length);let ue=0;for(let oe=0;oe<T;oe++){if(J[oe]=ue,oe===X)for(let Y=0;Y<z.length;Y++)re[ue++]=z[Y]|0;else for(let Y=x[oe];Y<x[oe+1];Y++)re[ue++]=te[Y];J[oe+1]=ue}this.#t=re,this.#e=J,this.#r=ue}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare,z=fe.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function x(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(z(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.get(s);if(u)return u;let f="unknown";try{let c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function re(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function J(i){return!i||!i.presence?null:re(i.presence)}function ue(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function oe(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function Y(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,m=new Array(t-c);for(let e=c;e<t;e++)m[e-c]=a?oe(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?oe(c,s[t]):null:t=>oe(c,s[t])}if(f==="bitset"){const c=re(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?Y(i,c):null:c=>Y(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Q(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function _(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Q(u,f);if(c==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),m=f instanceof Date?f.getTime():Number(f);return Q(a,m)}return X(u,f)}}function C(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,c=_(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>c(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return E}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,X=fe.dictRanks,z=fe.dictSize,te=fe.identity,x=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,re=fe.valueComparator,J=fe.valueReader,ue=new Uint32Array(0),oe=new ArrayBuffer(8),Y=new Float64Array(oe),L=new Uint32Array(oe),Q=(Y[0]=-1,(L[1]&2147483648)!==0?1:0),_=Q===1?0:1;function C(R,v){Y[0]=R;let U=L[Q],V=L[_];(U&2147483648)!==0?(U=~U>>>0,V=~V>>>0):U=(U^2147483648)>>>0,v[0]=V,v[1]=U}function M(R,v,U,V){if(V<2)return R;const $=new Uint32Array(256*8);for(let A=0;A<V;A++){const q=v[A],le=U[A];$[q&255]++,$[256+(q>>>8&255)]++,$[512+(q>>>16&255)]++,$[768+(q>>>24&255)]++,$[1024+(le&255)]++,$[1280+(le>>>8&255)]++,$[1536+(le>>>16&255)]++,$[1792+(le>>>24&255)]++}let ee=R,ne=v,ce=U,p=new Uint32Array(V),B=new Uint32Array(V),H=new Uint32Array(V);const w=new Uint32Array(256);for(let A=0;A<8;A++){const q=A<<8,le=(A&3)<<3,ae=A>=4;let de=!1;for(let ke=0;ke<256;ke++)if($[q+ke]===V){de=!0;break}if(de)continue;let pe=0;for(let ke=0;ke<256;ke++)w[ke]=pe,pe+=$[q+ke];for(let ke=0;ke<V;ke++){const Le=ne[ke],Re=ce[ke],Be=(ae?Re:Le)>>>le&255,ze=w[Be]++;p[ze]=ee[ke],B[ze]=Le,H[ze]=Re}let ge=ee;ee=p,p=ge,ge=ne,ne=B,B=ge,ge=ce,ce=H,H=ge}return ee}function i(R,v,U){if(U<2)return R;const V=new Uint32Array(256*4);for(let B=0;B<U;B++){const H=v[B];V[H&255]++,V[256+(H>>>8&255)]++,V[512+(H>>>16&255)]++,V[768+(H>>>24&255)]++}let $=R,ee=v,ne=new Uint32Array(U),ce=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const H=B<<8,w=B<<3;let A=!1;for(let ae=0;ae<256;ae++)if(V[H+ae]===U){A=!0;break}if(A)continue;let q=0;for(let ae=0;ae<256;ae++)p[ae]=q,q+=V[H+ae];for(let ae=0;ae<U;ae++){const de=ee[ae],pe=p[de>>>w&255]++;ne[pe]=$[ae],ce[pe]=de}let le=$;$=ne,ne=le,le=ee,ee=ce,ce=le}return $}function s(R,v,U,V){const $=new Uint32Array(V+1);for(let ce=0;ce<U;ce++)$[v[ce]]++;let ee=0;for(let ce=0;ce<=V;ce++){const p=$[ce];$[ce]=ee,ee+=p}const ne=new Uint32Array(U);for(let ce=0;ce<U;ce++)ne[$[v[ce]]++]=R[ce];return ne}function u(R,v,U,V){return U<2?R:V<=65536||V<=U*2?s(R,v,U,V):i(R,v,U)}function f(R,v){return R.length===v&&R.byteOffset===0?R:Uint32Array.prototype.slice.call(R,0,v)}function c(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=new Uint32Array($),ne=new Uint32Array($),ce=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let H=0,w=0;for(let le=0;le<$;le++){const ae=V[le],de=R[ae];if(Number.isNaN(de)){p[w++]=ae;continue}C(de,B),U?(ne[H]=~B[0]>>>0,ce[H]=~B[1]>>>0):(ne[H]=B[0],ce[H]=B[1]),ee[H++]=ae}const A=M(ee.subarray(0,H),ne.subarray(0,H),ce.subarray(0,H),H);if(w===0)return f(A,H);const q=new Uint32Array($);return q.set(A.subarray(0,H),0),q.set(p.subarray(0,w),H),q}function t(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=Uint32Array.from(V),ne=new Uint32Array($);for(let ce=0;ce<$;ce++){const p=(R[ee[ce]]^2147483648)>>>0;ne[ce]=U?~p>>>0:p}return f(i(ee,ne,$),$)}function a(R,v,U={}){const V=v||te(K(R,U)),$=V.length;if($<2)return Uint32Array.from(V);const ee=X(R.dict,U.locale),ne=R.values,ce=T(R),p=Math.max(z(R.dict),ee.length),B=p,H=Uint32Array.from(V),w=new Uint32Array($),A=!!U.descending;for(let q=0;q<$;q++){const le=H[q];let ae=ce&&ce(le)===0?B:ee[ne[le]];ae===void 0&&(ae=B),w[q]=A?B-ae:ae}return f(u(H,w,$,p+1),$)}function m(R,v,U){const V=v.length;let $=Uint32Array.from(v);if(V<2)return $;let ee=new Uint32Array(V);for(let ne=1;ne<V;ne<<=1){for(let p=0;p<V;p+=ne<<1){const B=Math.min(p+ne,V),H=Math.min(p+(ne<<1),V);let w=p,A=B,q=p;for(;w<B&&A<H;)ee[q++]=U(R[$[w]],R[$[A]])<=0?$[w++]:$[A++];for(;w<B;)ee[q++]=$[w++];for(;A<H;)ee[q++]=$[A++]}const ce=$;$=ee,ee=ce}return $}function e(R,v,U){const V=he(R.values),$=v.length,ee=new Uint32Array($),ne=U?1:0;let ce=0;for(let p=0;p<$;p++)V(v[p])===ne&&(ee[ce++]=v[p]);for(let p=0;p<$;p++)V(v[p])!==ne&&(ee[ce++]=v[p]);return ee}function d(R,v){const U=R.values,V=R.kind;if((V==="object"||V===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!R.presence)return U;const ee=J(R),ne=new Array(K(R)||0);for(let ce=0;ce<v.length;ce++){const p=v[ce];ne[p]=ee(p)}return ne}function h(R,v){for(let U=0;U<v.length;U++)if(typeof R[v[U]]!="string")return!1;return!0}function r(R,v,U,V,$){const ee=R.length,ne=Uint32Array.from(R);if(ee<2||V<1)return ne;const ce=new Uint32Array(ee),p=V-1;for(let B=0;B<ee;B++){const H=U[v[B]];ce[B]=$?p-H:H}return f(u(ne,ce,ee,V),ee)}function n(R,v,U){const V=re(U),$=new Array(v);for(let ne=0;ne<v;ne++)$[ne]=ne;$.sort((ne,ce)=>V(R[ne],R[ce])||ne-ce);const ee=new Uint32Array(v);for(let ne=0;ne<v;ne++)ee[$[ne]]=ne;return ee}function l(R,v,U){const V=v.length,$=new Map,ee=[],ne=new Uint32Array(V);for(let B=0;B<V;B++){const H=R[v[B]];let w=$.get(H);w===void 0&&(w=ee.length,$.set(H,w),ee.push(H)),ne[B]=w}const ce=ee.length,p=n(ee,ce,U.locale);return r(v,ne,p,ce,!!U.descending)}function g(R,v,U){const V=d(R,v);if(v.length>=2&&h(V,v)){const ne=R.stringRank;return ne&&ne.version===R.version&&ne.usable(v,V,U.locale)?ne.sort(v,U):l(V,v,U)}const $=re(U.locale),ee=U.descending?(ne,ce)=>$(ce,ne):$;return m(V,v,ee)}function P(R,v,U){const V=d(R,v),$=U.compare,ne=!!U.descending?(ce,p)=>-$(ce,p,void 0,void 0,!0):(ce,p)=>$(ce,p,void 0,void 0,!1);return m(V,v,ne)}function S(R,v){const U=v.length,V=T(R),$=R.values,ee=R.kind==="float64"&&!!$,ne=R.kind==="object"||R.kind==="multi"||R.kind===void 0;if(!V&&!ee&&!ne)return{present:v,absent:ue};const ce=new Uint32Array(U),p=new Uint32Array(U);let B=0,H=0;if(V&&ee)for(let w=0;w<U;w++){const A=v[w];V(A)===1&&!Number.isNaN($[A])?ce[B++]=A:p[H++]=A}else if(ee&&!V)for(let w=0;w<U;w++){const A=v[w];Number.isNaN($[A])?p[H++]=A:ce[B++]=A}else if(V&&!ne)for(let w=0;w<U;w++){const A=v[w];V(A)===1?ce[B++]=A:p[H++]=A}else{const w=J(R);for(let A=0;A<U;A++){const q=v[A];x(w(q))?p[H++]=q:ce[B++]=q}}return H===0?{present:v,absent:ue}:{present:ce.subarray(0,B),absent:p.subarray(0,H)}}function G(R,v,U){if(v.length===0)return R;const V=new Uint32Array(R.length+v.length);return U?(V.set(v,0),V.set(R,v.length)):(V.set(R,0),V.set(v,R.length)),V}function F(R,v,U={}){const V=v||te(K(R,U));if(!R||V.length<2)return Uint32Array.from(V);const{present:$,absent:ee}=S(R,V);if($.length===0)return Uint32Array.from(V);const ne=!!U.descending;let ce;if(typeof U.compare=="function")ce=P(R,$,U);else switch(R.kind){case"float64":ce=c(R.values,$,ne);break;case"int32":ce=t(R.values,$,ne);break;case"dictionary":ce=a(R,$,U);break;case"bitset":ce=e(R,$,ne);break;default:ce=g(R,$,U);break}return G(ce,ee,!!U.nullsFirst)}function E(R,v,U,V={}){const $=v||[],ee=$.length&&($[0].handle||Z(R,$[0].col))||R&&R[0];let ne=U||te(K(ee,V));for(let ce=$.length-1;ce>=0;ce--){const p=$[ce],B=p.handle||Z(R,p.col)||R&&R[ce];B&&(ne=F(B,ne,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:V.locale,compare:p.compare}))}return ne instanceof Uint32Array?ne:Uint32Array.from(ne)}function Z(R,v){if(!(!R||v===void 0)){for(let U=0;U<R.length;U++)if(R[U]&&R[U].id===v)return R[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,X=fe.rankSortStrings,z=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let re=0;re<K.length;re++)T+=K[re].length*2+24;return T}#a(T,K){const re=this.#e.get(T);if(re!==void 0)return re;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const re=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let J=0;J<re;J++){const ue=T[J],oe=typeof ue=="string"?this.#a(ue,!1):-1;this.#n[J]=oe<0?0:oe}this.#r=re}append(T,K,re){const J=(K|0)+(re|0);if(J>this.#n.length){const ue=new Uint32Array(J);ue.set(this.#n.subarray(0,this.#r)),this.#n=ue}for(let ue=K|0;ue<J;ue++){const oe=T[ue],Y=typeof oe=="string"?this.#a(oe,!0):-1;this.#n[ue]=Y<0?0:Y}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const re=he(this.#t,this.#t.length,T);return this.#o=re,this.#c=this.#i,this.#l=K,re}usable(T,K,re){if(this.#u||this.#t.length===0)return!1;const J=this.#n,ue=this.#t,oe=this.#r;for(let Y=0;Y<T.length;Y++){const L=T[Y];if(L>=oe||ue[J[L]]!==K[L])return!1}return!0}sort(T,K){const re=this.ranks(K.locale),J=this.#t.length,ue=T.length,oe=new Uint32Array(ue),Y=this.#n;for(let L=0;L<ue;L++)oe[L]=Y[T[L]];return X(T,oe,re,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return a}});const fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,X=fe.isFunction,z=fe.pathGetter,x=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,oe=me("packages/core/src/store/stringrank.js").StringRankIndex,Y=4294967295,L=1024,Q=5e3,_=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return M(m)?[]:Array.isArray(m)?m:[m]}function f(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function c(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let l=d;l<h;l++)n[l-d]=r[m.values[l]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=X(e.read)?e.read:z(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const h=new oe(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,h){if(this.#g||h<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let g=!1;switch(this.#e){case"float64":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]);if(typeof G=="number"){n&&l.set(d+S),P[d+S]=G;continue}const F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?NaN:i(G)}break}case"int32":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?0:s(G)}break}case"bitset":{const P=this.#c;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P.assign(d+S,!F&&!!G)}break}case"dictionary":{const P=this.#o,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0),P[d+G]=E?0:S.codeOf(F)}break}case"multi":{const P=this.#l,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0);const Z=u(F),R=new Array(Z.length);for(let v=0;v<Z.length;v++)R[v]=S.codeOf(Z[v]);P.write(d+G,R)}break}default:{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?null:G}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;g++)r.set(d+g);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(l&&this.#e==="bitset"){const g=e.values;for(let P=0;P<h;P++)this.#c.assign(d+P,(g[P>>3]&1<<(P&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const g=e.table||[],P=new Uint32Array(g.length);for(let E=0;E<g.length;E++)P[E]=this.#a.codeOf(g[E]);const S=e.values,G=this.#o,F=r;for(let E=0;E<h;E++){if(F&&(n&&(n[E>>3]&1<<(E&7))===0)){G[d+E]=0;continue}G[d+E]=P[S[E]]??0}this.#f++;return}if(l&&this.#e==="multi"){const g=e.table||[],P=new Uint32Array(g.length);for(let F=0;F<g.length;F++)P[F]=this.#a.codeOf(g[F]);const S=e.values,G=e.offsets;for(let F=0;F<h;F++){const E=G[F],Z=G[F+1],R=new Array(Z-E);for(let v=E;v<Z;v++)R[v-E]=P[S[v]]??0;this.#l.write(d+F,R)}this.#f++;return}for(let g=0;g<h;g++){const P=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,P?null:c(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!C.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,g]of r)e[l]!==Y&&n.set(e[l],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==Y&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,Y);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new x(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new x(d)),this.#p=d}#A(e,d){const h=M(d);switch(this.#r?this.#m.assign(e,!h):h&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(d),n=new Array(r.length);for(let l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);this.#l.write(e,n);break}default:this.#o[e]=h?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),h=this.#r?new x(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!M(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new x(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Q:0,this.#w=d.compactRatio??_;const h={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,h);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let l=0;l<r;l++)this.#r[h+l]=d[l];this.#i=h+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const l of e.columns)n.set(l.id,l);for(const l of this.#n){const g=n.get(l.id);g?l.appendPacked(g,h,r):l.grow(this.#s)}return{from:h,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,h)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?Y:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let l=0;l<d;l++)h[l]!==Y&&(n[h[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new x(Math.max(this.#s,r)),h}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,X=fe.nextFrame,z=fe.infoOnce,te=fe.warnOnce,x=fe.isFunction,T=fe.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ue(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let m=0;m<M.length;m++){const e=M[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function oe(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function Y(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const g=x(l.read)?l.read:T(l.field||l.id);f.set(l.id,g),u.set(l.id,g)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=c.filter(l=>x(t[l])),d=e.some(l=>a[l]==="*");let h=new WeakMap;const r=l=>{const g={};if(d)for(const[P,S]of f)g[P]=S(l);for(const P of e){const S=a[P];let G;if(S==="*")G=g;else{G={};const F=S||[];for(let E=0;E<F.length;E++){const Z=F[E];G[Z]=Z in g?g[Z]:f.get(Z)?.(l)}}g[P]=t[P](m?m(G,P):G,{data:l,row:null,column:null,grid:null,context:s})}return g},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let g=h.get(l);return g===void 0&&(g=r(l),h.set(l,g)),g};for(const l of e)u.set(l,g=>n(g)[l]);return{readers:u,reset(){h=new WeakMap}}}class L{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Q{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=Y(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new re(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,this.#r.reset(),this.#w(!1)}while(this.#i<f&&he()-i<s);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),c=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){te(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(a.id)??(x(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=ue(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=oe(r,d.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`ingest.mixed.${a.id}`,`column "${a.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const c=this.#d(f);if(f.kind==="dictionary"&&c>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function _(M,i={},s={}){const u=new Q(M,i,s),f=s.scheduler?.frame??X;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function C(M,i={},s={}){const u=new Q(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Q}});const he=me("packages/core/src/internal/util.js").pathGetter,X=me("packages/core/src/store/ingest.js"),z=X.inferKind,te=X.decideText,x=X.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(_){if(!Array.isArray(_)||_.length===0)return!1;for(const C of _)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!re.has(C.kind))return!1;return!0}function ue(_){const C=K(_);return Number.isFinite(C)?C|0:0}function oe(_){return _==null?[]:Array.isArray(_)?_:[_]}function Y(_,C,M,i){if(_.kind)return _.kind;const s=[];for(let c=0;c<C.length&&s.length<x.sampleSize;c++){const t=C[c];t!=null&&s.push(t)}const u=z(s,{multi:_.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function L(_,C,M={}){const i=C.length|0,s=M.dictionaryRatio??x.dictionaryRatio,u=[];for(const f of _){const c=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(C[r]);a[r]=n===void 0?null:n}const m=Y(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?NaN:K(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?0:ue(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),!g&&l&&(r[n>>3]|=1<<(n&7))}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let g=0;g<i;g++){const P=a[g];if(P===null){r[g]=0;continue}d(g);let S=l.get(P);S===void 0&&(S=n.length,n.push(P),l.set(P,S)),r[g]=S}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),g=[];for(let P=0;P<i;P++){const S=a[P];l[P]=g.length,S===null||d(P);const F=oe(S);for(let E=0;E<F.length;E++){const Z=F[E];let R=n.get(Z);R===void 0&&(R=r.length,r.push(Z),n.set(Z,R)),g.push(R)}}l[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&d(n),r[n]=l}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Q(_){const C=[];if(!_||!Array.isArray(_.columns))return C;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of _.columns)M(i.values),M(i.presence),M(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function fe(x){return{locale:x===void 0?void 0:String(x),numeric:!0,sensitivity:"variant"}}function he(x){return!!x&&typeof x.compare!="function"}function X(x){if(!x)return!0;for(let T=0;T<x.length;T++)if(!he(x[T]))return!1;return!0}function z(x,T){const K=x.col!==void 0?x.col:x.handle&&x.handle.id,re=x.locale!==void 0?x.locale:T;return{col:K,descending:x.descending!==void 0?!!x.descending:x.dir==="desc",nullsFirst:!!x.nullsFirst,collation:fe(re)}}function te(x,T){const K=x||[],re=new Array(K.length);for(let J=0;J<K.length;J++)re[J]=z(K[J],T);return re}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,X=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=z.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&X(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=c,s+=1}return f(),i}const x=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(M){if(he(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=x.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+m)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function K(M,i){return String(M).padStart(i,"0")}function re(M){if(!M)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function J(M,i,s){const u=te(M),f=re(s),c=new Set(u.filter(d=>d.token).map(d=>d.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ue=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function oe(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const h={timeZone:c};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>h.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-l;if(Math.abs(g)<e){for(const[P,S]of ue)if(Math.abs(g)>=S||P==="second")return a.format(Math.round(g/S),P)}}return t(n)};return d.spec=s,d}function Y(M){if(he(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=T(M);return f?Y(f):null}const i=T(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(M,i){if(he(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Q.test(u)){const t=T(u);return t?_(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=T(u);return c?L(c):null}const s=T(M);return s?_(s,i):null}const Q=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function _(M,i){const s=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(M).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const u=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function C(M,i){const s=he(M)||M===""?null:String(M),u=he(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ce}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,X=fe.toArray,z=fe.warnOnce,x=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,re=T.dictSize,J=T.dictValue,ue=T.presenceReader,oe=T.valueComparator,Y=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Q="\\0null\\0";function _(p,B){const H=p&&p.pool;if(H){const w=H.mask||H.acquireMask||H.acquire||H.take;if(typeof w=="function"){const A=w.call(H,B);if(A&&A.length>=B)return A}}return new Uint8Array(B)}function C(p,B){const H=p&&p.pool;if(!H||!B)return;const w=H.release||H.releaseMask||H.free||H.recycle;typeof w=="function"&&w.call(H,B)}function M(p,B,H){return p.fill(H,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const H=x(p);return H===null?u(p):H}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function c(p,B){const H=typeof p=="string"?p:String(p);return B?H:H.toLowerCase()}function t(p,B){return p==null?Q:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,H){const w=new Set;for(const A of X(p)){const q=s(A,H);w.add(t(q,B)),typeof q=="string"&&q!==""&&Number.isFinite(Number(q))?w.add(Number(q)):typeof q=="number"&&Number.isFinite(q)&&w.add(t(String(q),B))}return w}function m(p,B,H){if(p==null||B===null||B===void 0)return p==null&&B==null;const w=typeof p,A=typeof B;return w==="string"&&A==="string"?H?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):w==="number"&&A==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):w==="number"&&A==="string"?p===Number(B):w==="string"&&A==="number"?Number(p)===B:w==="boolean"||A==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((q,le)=>m(q,B[le],H)):p===B}function e(p,B){try{if(p instanceof RegExp){const H=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||H.includes("i")?H:`${H}i`)}return new RegExp(String(p),B?"":"i")}catch(H){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,H),null}}function d(p,B){const H=h(p,B),w=p&&p.type;return w!=="date"&&w!=="dateString"?H:A=>H(typeof A=="string"&&L.test(A)?A:x(A)??A)}function h(p,B){const H=p&&p.op,w=!!(p&&p.caseSensitive),A=p&&p.type,q=oe(B),le=ae=>de=>!ae(de);switch(H){case"eq":{const ae=s(p.value,A);return de=>m(de,ae,w)}case"ne":{const ae=s(p.value,A);return de=>!m(de,ae,w)}case"lt":case"lte":case"gt":case"gte":{const ae=s(p.value,A);if(i(ae))return()=>!1;const de=H==="lt"?-1:H==="lte"?0:H==="gt"?1:2;return pe=>{if(i(pe))return!1;const ge=q(pe,ae);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const ae=X(p.value),de=s(ae[0],A),pe=s(ae[1],A),ge=p.bounds||"[]",ke=ge.charAt(0)!=="(",Le=ge.charAt(1)!==")";if(i(de)||i(pe))return H==="between"?()=>!1:()=>!0;const Re=Be=>{if(i(Be))return!1;const ze=q(Be,de),Ke=q(Be,pe);return(ke?ze>=0:ze>0)&&(Le?Ke<=0:Ke<0)};return H==="between"?Re:le(Re)}case"in":case"notIn":{const ae=a(p.value,w,A),de=pe=>ae.has(t(pe,w));return H==="in"?de:le(de)}case"contains":case"notContains":{const ae=c(s(p.value,A),w),de=pe=>pe==null?!1:c(pe,w).includes(ae);return H==="contains"?de:le(de)}case"startsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).startsWith(ae)}case"endsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).endsWith(ae)}case"matches":{const ae=e(p.value,w);return ae?de=>de==null?!1:ae.test(String(de)):()=>!1}case"blank":return ae=>he(ae)||Array.isArray(ae)&&ae.length===0;case"notBlank":return ae=>!(he(ae)||Array.isArray(ae)&&ae.length===0);case"containsAny":case"containsNone":{const ae=a(p.value,w,A),de=pe=>{const ge=pe==null?[]:X(pe);for(let ke=0;ke<ge.length;ke++)if(ae.has(t(ge[ke],w)))return!0;return!1};return H==="containsAny"?de:le(de)}case"containsAll":{const ae=X(p.value).map(de=>t(s(de,A),w));return de=>{const pe=de==null?[]:X(de);if(ae.length===0)return!0;const ge=new Set(pe.map(ke=>t(ke,w)));for(let ke=0;ke<ae.length;ke++)if(!ge.has(ae[ke]))return!1;return!0}}default:{const ae=ce(H);return ae?ae.compile(p.value):(z(`op:${String(H)}`,`unknown filter operator "${String(H)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,H){return d(B,H)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),l=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,H){const w=p&&p.op,A=n[w]||w,q=d({...p,op:A,type:B.type},H),le=B.items,ae=de=>{const pe=le(de);if(!pe)return!1;for(let ge=0;ge<pe.length;ge++)if(q(pe[ge]))return!0;return!1};return n[w]?de=>!ae(de):ae}function P(p,B,H,w){const A=ue(p);if(A){const ae=B?1:0;for(let de=0;de<w;de++)H[de]=A(de)===ae?1:0;return H}const q=p.kind;if(q==="float64"||q==="int32"||q==="bitset")return M(H,w,B?1:0);const le=Y(p);for(let ae=0;ae<w;ae++){const de=le(ae),pe=he(de)||Array.isArray(de)&&de.length===0;H[ae]=pe===B?0:1}return H}function S(p,B,H,w){const A=p.dict,q=re(A),le=new Uint8Array(q);for(let ge=0;ge<q;ge++)le[ge]=B(J(A,ge))?1:0;const ae=p.values,de=ue(p);if(!de){for(let ge=0;ge<w;ge++)H[ge]=le[ae[ge]];return H}const pe=B(null)?1:0;for(let ge=0;ge<w;ge++)H[ge]=de(ge)===1?le[ae[ge]]:pe;return H}function G(p,B,H,w){const A=K(p.values),q=B(!0)?1:0,le=B(!1)?1:0,ae=ue(p);if(!ae){for(let pe=0;pe<w;pe++)H[pe]=A(pe)===1?q:le;return H}const de=B(null)?1:0;for(let pe=0;pe<w;pe++)H[pe]=ae(pe)===0?de:A(pe)===1?q:le;return H}function F(p,B,H,w,A){const q=p.values,le=B.type,ae=B.op;let de=!0;switch(ae){case"eq":case"ne":{const ge=f(s(B.value,le)),ke=typeof B.value=="number"&&Number.isNaN(B.value),Le=ae==="ne"?1:0;if(ke)for(let Re=0;Re<A;Re++)w[Re]=(Number.isNaN(q[Re])?1:0)^Le;else for(let Re=0;Re<A;Re++)w[Re]=(q[Re]===ge?1:0)^Le;break}case"lt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<ge?1:0;break}case"lte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>ge?1:0;break}case"gte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>=ge?1:0;break}case"between":case"notBetween":{const ge=X(B.value),ke=f(s(ge[0],le)),Le=f(s(ge[1],le)),Re=B.bounds||"[]",Be=Re.charAt(0)!=="(",ze=Re.charAt(1)!==")",Ke=ae==="notBetween"?1:0;if(Be&&ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<=Le?1:0)^Ke;else if(Be)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<Le?1:0)^Ke;else if(ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<=Le?1:0)^Ke;else for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<Le?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Le of X(B.value)){const Re=f(s(Le,le));Number.isNaN(Re)||ge.add(Re)}const ke=ae==="notIn"?1:0;for(let Le=0;Le<A;Le++)w[Le]=(ge.has(q[Le])?1:0)^ke;break}default:de=!1;break}if(!de)return!1;const pe=ue(p);if(pe){const ge=H(null)?1:0;for(let ke=0;ke<A;ke++)pe(ke)===0&&(w[ke]=ge)}return!0}function E(p,B,H,w){const A=Y(p);for(let q=0;q<w;q++)H[q]=B(A(q))?1:0;return H}function Z(p,B,H){const w=B.count|0,A=H||_(B,w);if(!p)return M(A,w,1);const q=typeof B.handle=="function"?B.handle(p.col):void 0,le=typeof B.custom=="function"?B.custom:null;if(!q){if(le){for(let ge=0;ge<w;ge++)A[ge]=le(p,ge)?1:0;return A}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),M(A,w,0)}const ae=p.op;if(ae==="blank"||ae==="notBlank")return P(q,ae==="notBlank",A,w);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ce(ae)&&!l.has(ae))return E(q,g(p,de,B.locale),A,w);const pe=d(p,B.locale);switch(q.kind){case"dictionary":return S(q,pe,A,w);case"bitset":return G(q,pe,A,w);case"float64":case"int32":return F(q,p,pe,A,w)?A:E(q,pe,A,w);default:return E(q,pe,A,w)}}function R(p,B,H){if(!p)return M(_(B,H),H,1);if(Array.isArray(p.conditions)){const w=p.conditions.filter(le=>le!=null),A=p.op==="or"?"or":p.op==="not"?"not":"and";if(w.length===0)return M(_(B,H),H,1);const q=R(w[0],B,H);for(let le=1;le<w.length;le++){const ae=R(w[le],B,H);if(A==="or")for(let de=0;de<H;de++)q[de]|=ae[de];else for(let de=0;de<H;de++)q[de]&=ae[de];C(B,ae)}if(A==="not")for(let le=0;le<H;le++)q[le]^=1;return q}return Z(p,B,_(B,H))}function v(p,B){return R(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const H=p;if(Array.isArray(H.conditions)){if((H.op==="or"?"or":H.op==="not"?"not":"and")!=="and")return V(H,B)?null:p;const A=[];for(const q of H.conditions){const le=U(q,B);le&&A.push(le)}return A.length?{...H,op:"and",conditions:A}:null}return H.col===B?null:p}function V(p,B){if(!p||typeof p!="object")return!1;const H=p;if(H.col===B)return!0;if(Array.isArray(H.conditions)){for(const w of H.conditions)if(V(w,B))return!0}return!1}function $(p,B,H){if(H&&H.length>=B){let le=0;for(let ae=0;ae<B;ae++)p[ae]&&(H[le++]=ae);return H.subarray(0,le)}let w=0;for(let le=0;le<B;le++)w+=p[le]?1:0;const A=new Uint32Array(w);let q=0;for(let le=0;le<B;le++)p[le]&&(A[q++]=le);return A}const ee=new Map;function ne(p){if(!(!p||typeof p!="object"))for(const[B,H]of Object.entries(p))H&&typeof H.compile=="function"&&ee.set(B,H)}function ce(p){return typeof p=="string"?ee.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return oe}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,X=fe.identity,z=fe.presenceReader,te=fe.rowCount,x=fe.valueReader,T="",K="\\0",re=1<<20;function J(Y,L,Q,_){const C=Y.length,M=Y.map(t=>x(t)),i=Array.isArray(_)&&_.some(Boolean),s=i?M.map((t,a)=>_[a]?m=>_[a](t(m)):t):M;if(!i&&C>0&&Y.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=Y.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=Y.map(r=>r.values),e=Y.map(r=>z(r)),d=r=>{let n=0;for(let l=0;l<C;l++){const g=e[l],P=g&&g(r)===0?t[l]-1:m[l][r];n=n*t[l]+P}return n},h=new Float64Array(Q);for(let r=0;r<Q;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},c=new Array(Q);for(let t=0;t<Q;t++)c[t]=f(L[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ue(Y,L,Q,_){const C=new Uint32Array(_+1);for(let u=0;u<Q;u++)C[L[u]+1]++;for(let u=0;u<_;u++)C[u+1]+=C[u];const M=new Uint32Array(Q),i=C.slice(0,_);for(let u=0;u<Q;u++)M[i[L[u]]++]=Y[u];const s=new Array(_);for(let u=0;u<_;u++)s[u]=M.subarray(C[u],C[u+1]);return s}function oe(Y,L,Q={}){const _=Y||[],C=L||X(te(_[0],Q)),M=C.length;if(_.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(_,C,M,Q.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(re,M*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<M;r++){const n=i[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<M;r++){const n=s[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}}const m=ue(C,c,M,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=fe.dictSize,te=fe.dictValue,x=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,re=50,J=1e4;function ue(n,l){if(!n)return"none";const g=l;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const P=l&&l.base;if(P==="date"||P==="datetime"||P==="time"||P==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return P==="number"?"numeric":P==="boolean"?"boolean":P==="text"?"category":"none"}}function oe(n){const l=n.values,g=n.kind;if((g==="float64"||g==="int32")&&l)return S=>l[S];const P=X(n);return S=>Y(P(S))}function Y(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const l=Number(n);if(Number.isFinite(l))return l;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,l,g,P=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=X(n),G=l?l.length:g,F=new Set;for(let E=0;E<G;E++){const Z=S(l?l[E]:E);if(Z!=null&&(F.add(Z),F.size>P))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Q=36e5,_=864e5;function C(n,l=K){const g=Number.isFinite(n)&&n>0?n:0,P=Math.max(1,l)*2;return g/Q<=P?"hour":g/_<=P?"day":g/(7*_)<=P?"week":g/(30*_)<=P?"month":g/(91*_)<=P?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(l){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const P=(g.getDay()+6)%7;return g.setDate(g.getDate()-P),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,l){const g=new Date(n);switch(l){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,l,g){const P=oe(n),S=he(n),G=l?l.length:g;let F=1/0,E=-1/0,Z=0,R=0;for(let v=0;v<G;v++){const U=l?l[v]:v;if(S&&!S(U)){Z++;continue}const V=P(U);if(!Number.isFinite(V)){Z++;continue}V<F&&(F=V),V>E&&(E=V),R++}return{min:F,max:E,nulls:Z,finite:R}}function u(n,l,g,P){const S=oe(n),G=he(n),F=l?l.length:g,E=F>P?F/P:1,Z=[];for(let v=0;v<F;v+=E){const U=l?l[Math.floor(v)]:Math.floor(v);if(G&&!G(U))continue;const V=S(U);Number.isFinite(V)&&Z.push(V)}const R=Float64Array.from(Z);return R.sort(),R}function f(n,l,g,P={}){const S=P.kind||ue(n,P.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,g):S==="category"?t(n,l,g,P):a(n,l,g,S,P)}function c(n,l,g){const P=he(n);let S=0;if(P){const F=l?l.length:g;for(let E=0;E<F;E++)P(l?l[E]:E)||S++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,l,g,P){const S=P.cardinalityLimit??re,{cardinality:G}=L(n,l,g,S);if(G>S&&(P.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=X(n),E=l?l.length:g,Z=new Map;let R=0;for(let ee=0;ee<E;ee++){const ne=F(l?l[ee]:ee);if(ne==null||ne===""){R++;continue}if(Array.isArray(ne)){if(!ne.length){R++;continue}for(const ce of ne)Z.set(ce,(Z.get(ce)||0)+1);continue}Z.set(ne,(Z.get(ne)||0)+1)}let v=[...Z.entries()];P.order==="alpha"?v.sort((ee,ne)=>String(ee[0]).localeCompare(String(ne[0]))):v.sort((ee,ne)=>ne[1]-ee[1]);let U=0,V=0;if(v.length>S){V=v.length-S;for(let ee=S;ee<v.length;ee++)U+=v[ee][1];v=v.slice(0,S)}const $=v.map(([ee])=>({value:ee,label:String(ee)}));return U>0&&$.push({remainder:!0,label:`Other (${V} values)`}),R>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,l,g,P,S){const{min:G,max:F,nulls:E,finite:Z}=s(n,l,g);if(!Z)return{kind:P,buckets:E?[{null:!0,label:"Empty"}]:[],empty:!0};const R=Math.max(1,Math.floor(S.buckets||K));let v=[];if(P==="date"){const V=T.includes(S.granularity)?S.granularity:C(F-G,R);let $=M(G,V);for(;$<=F&&v.length<4096;){const ee=i($,V);if(!(ee>$))break;v.push({from:$,to:ee}),$=ee}return{kind:P,buckets:m(v,E),granularity:V}}const U=x.includes(S.strategy)?S.strategy:"equal";if(U==="quantile"){const V=u(n,l,g,J);if(V.length){const $=[V[0]];for(let ee=1;ee<R;ee++){const ne=V[Math.min(V.length-1,Math.floor(ee/R*V.length))];ne>$[$.length-1]&&$.push(ne)}$.push(F);for(let ee=0;ee<$.length-1;ee++)v.push({from:$[ee],to:$[ee+1]})}}else if(U==="log"&&G>0){const V=Math.log10(G),ee=(Math.log10(F)-V)/R||1;for(let ne=0;ne<R;ne++)v.push({from:10**(V+ne*ee),to:10**(V+(ne+1)*ee)})}if(!v.length){const V=(F-G)/R||1;for(let $=0;$<R;$++)v.push({from:G+$*V,to:G+($+1)*V})}return v[v.length-1].to=F,{kind:P,buckets:m(v,E),strategy:U,min:G,max:F}}function m(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,g,P,S){const G=P&&P.buckets||[],F=S&&S.length>=G.length?S.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const E=G.length-1,Z=!!G[E]&&G[E].null===!0,R=l?l.length:g;if(P.kind==="boolean"){const ee=X(n);for(let ne=0;ne<R;ne++){const ce=ee(l?l[ne]:ne);if(ce==null){Z&&F[E]++;continue}F[ce?1:0]++}return F}if(P.kind==="category"){const ee=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&ee.set(G[p].value,p);const ne=G.findIndex(p=>p.remainder),ce=X(n);for(let p=0;p<R;p++){const B=ce(l?l[p]:p);if(B==null||B===""){Z&&F[E]++;continue}if(Array.isArray(B)){if(!B.length){Z&&F[E]++;continue}for(const w of B){const A=ee.get(w);A!==void 0?F[A]++:ne>=0&&F[ne]++}continue}const H=ee.get(B);H!==void 0?F[H]++:ne>=0&&F[ne]++}return F}const v=Z?G.length-1:G.length,U=new Float64Array(v+1);for(let ee=0;ee<v;ee++)U[ee]=G[ee].from;U[v]=v?G[v-1].to:0;const V=oe(n),$=he(n);for(let ee=0;ee<R;ee++){const ne=l?l[ee]:ee;if($&&!$(ne)){Z&&F[E]++;continue}const ce=V(ne);if(!Number.isFinite(ce)){Z&&F[E]++;continue}const p=d(U,v,ce);p>=0&&F[p]++}return F}function d(n,l,g){if(!l||g<n[0])return-1;if(g>=n[l])return g===n[l]?l-1:-1;let P=0,S=l-1;for(;P<S;){const G=P+S+1>>>1;g>=n[G]?P=G:S=G-1}return P}function h(n,l,g,P={}){const S=P.bounds||f(n,P.boundsIndices??l,g,P);return{bounds:S,counts:e(n,l,g,S)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return _}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,X=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const M=C-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(C,M,i){const s=C+M,u=C+1,f=C-1;let c=1,t=1-s*i/u;Math.abs(t)<X&&(t=X),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(M-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t,a*=t*c,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t;const h=t*c;if(a*=h,Math.abs(h-1)<he)break}return a}function x(C,M,i){if(!(C>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+M)-z(C)-z(M)+C*Math.log(i)+M*Math.log(1-i));return i<(C+1)/(C+M+2)?s*te(C,M,i)/C:1-s*te(M,C,1-i)/M}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const M=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let c,t,a;C<f?(c=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):C<=1-f?(c=C-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1));const e=(.5*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const M=Math.abs(C),i=2/(2+M),s=4*i-2,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let f=0,c=0,t;for(let m=u.length-1;m>0;m--)t=c,c=s*c-f+u[m],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return C>=0?a:2-a}function re(C){return .5*K(-C/Math.SQRT2)}function J(C,M){if(!(M>0)||!Number.isFinite(C))return Number.NaN;const i=.5*x(M/2,.5,M/(M+C*C));return C>0?1-i:i}function ue(C,M){if(!(C>0)||!(C<1)||!(M>0))return Number.NaN;if(M>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(M/2)+z(.5)-z((M+1)/2);for(let c=0;c<60;c++){const t=J(u,M);t<C?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function oe(C,M){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-M+C*Math.log(M)-z(C))}function Y(C,M){let i=M+1-C,s=1/X,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-C);i+=2,u=t*u+i,Math.abs(u)<X&&(u=X),s=i+t/s,Math.abs(s)<X&&(s=X),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-M+C*Math.log(M)-z(C))*f}function L(C,M){return!(C>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<C+1?oe(C,M):1-Y(C,M)}function Q(C,M){return M>0?L(M/2,C/2):Number.NaN}function _(C,M){const i=Q(C,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return x}});function fe(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let ue=0;ue<=J;ue++){let oe=T[J][ue];for(let Y=0;Y<ue;Y++)oe-=re[J][Y]*re[ue][Y];if(J===ue){if(!(oe>0))return null;re[J][ue]=Math.sqrt(oe)}else re[J][ue]=oe/re[ue][ue]}return re}function he(T,K){const re=T.length,J=new Array(re).fill(0);for(let oe=0;oe<re;oe++){let Y=K[oe];for(let L=0;L<oe;L++)Y-=T[oe][L]*J[L];J[oe]=Y/T[oe][oe]}const ue=new Array(re).fill(0);for(let oe=re-1;oe>=0;oe--){let Y=J[oe];for(let L=oe+1;L<re;L++)Y-=T[L][oe]*ue[L];ue[oe]=Y/T[oe][oe]}return ue}function X(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const ue=new Array(K).fill(0);ue[J]=1;const oe=he(T,ue);for(let Y=0;Y<K;Y++)re[Y][J]=oe[Y]}return re}function z(T,K,re){const J=T.length,ue=J?T[0].length:0,oe=Array.from({length:ue},()=>new Array(ue).fill(0)),Y=new Array(ue).fill(0);for(let L=0;L<J;L++){const Q=re?re[L]:1,_=T[L];for(let C=0;C<ue;C++){const M=Q*_[C];Y[C]+=M*K[L];for(let i=C;i<ue;i++)oe[C][i]+=M*_[i]}}for(let L=0;L<ue;L++)for(let Q=0;Q<L;Q++)oe[L][Q]=oe[Q][L];return{xtwx:oe,xtwy:Y}}function te(T,K){return T.map(re=>re.reduce((J,ue,oe)=>J+ue*K[oe],0))}function x(T,K){let re=0;for(let J=0;J<T.length;J++){let ue=0;for(let oe=0;oe<T.length;oe++)ue+=K[J][oe]*T[oe];re+=T[J]*ue}return re}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return oe}});class fe{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(L){if(!Number.isFinite(L))return;this.#t++;const Q=L-this.#e;this.#e+=Q/this.#t,this.#n+=Q*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Q=this.#t+L.#t,_=L.#e-this.#e;this.#e+=_*(L.#t/Q),this.#n+=L.#n+_*_*(this.#t*L.#t/Q),this.#t=Q}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Q=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Q}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Q=Math.floor(this.#r()*this.#e);Q<this.#n&&(this.#t[Q]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Q of this.#t)L+=Q;return L/this.#t.length}quantile(L){const Q=this.#t.length;if(!Q)return null;const _=this.#t.slice().sort((s,u)=>s-u);if(Q===1)return _[0];const C=(Q-1)*Math.min(1,Math.max(0,L)),M=Math.floor(C),i=Math.ceil(C);return M===i?_[M]:_[M]+(C-M)*(_[i]-_[M])}}function X(Y){return Y^=Y>>>16,Y=Math.imul(Y,2246822507),Y^=Y>>>13,Y=Math.imul(Y,3266489909),Y^=Y>>>15,Y>>>0}function z(Y){if(typeof Y=="number"){const _=new DataView(new ArrayBuffer(8));return _.setFloat64(0,Y===0?0:Y),X(_.getUint32(0)^_.getUint32(4))}const L=typeof Y=="string"?Y:String(Y);let Q=2166136261;for(let _=0;_<L.length;_++)Q^=L.charCodeAt(_),Q=Math.imul(Q,16777619);return X(Q)}class te{#t;#e;#n;constructor(L=14){const Q=Math.floor(L);if(Q<4||Q>16)throw new RangeError("HLL precision must be 4..16");this.#t=Q,this.#e=1<<Q,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Q=1<<Math.floor(L),_=1.04/Math.sqrt(Q);return Object.freeze({kind:"probabilistic",metric:"relative",value:_,statement:`distinct count within ~${(_*100).toFixed(2)}% relative standard error (m=${Q} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(L){const Q=z(L),_=Q&this.#e-1,C=Q>>>this.#t|1<<32-this.#t;let M=1,i=C;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[_]&&(this.#n[_]=M)}count(){const L=this.#e,Q=32-this.#t,_=new Float64Array(Q+2);for(let i=0;i<L;i++)_[this.#n[i]]++;let C=L*K(1-_[Q+1]/L);for(let i=Q;i>=1;i--)C=.5*(C+_[i]);C+=L*T(_[0]/L);const M=x*L*L/C;return Math.round(M)}}const x=.5/Math.log(2);function T(Y){if(Y===1)return 1/0;let L=1,Q=Y,_;do Y*=Y,_=Q,Q+=Y*L,L+=L;while(Q!==_);return Q}function K(Y){if(Y===0||Y===1)return 0;let L=1,Q=1-Y,_;do Y=Math.sqrt(Y),_=Q,L*=.5,Q-=(1-Y)**2*L;while(Q!==_);return Q/3}class re{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Q=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Q,statement:`each count overestimates the truth by at most N/m = ${Q.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Q=this.#t.get(L);if(Q){Q.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let _,C=1/0;for(const[M,i]of this.#t)i.count<C&&(C=i.count,_=M);this.#t.delete(_),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([_,C])=>({item:_,count:C.count,error:C.error})).sort((_,C)=>C.count-_.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Q=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Q,this.#i=2/3}static errorBoundFor(L=200){const Q=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Q,statement:`queried quantile\'s true rank within ~${(Q*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const _=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**_);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Q=this.#e[L];Q.sort((M,i)=>M-i),L+1>=this.#e.length&&this.#e.push([]);const _=this.#e[L+1],C=this.#r()<.5?0:1;for(let M=C;M<Q.length;M+=2)_.push(Q[M]);this.#e[L]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const L=[];for(let Q=0;Q<this.#e.length;Q++){const _=1<<Q;for(const C of this.#e[Q])L.push({v:C,w:_})}return L}quantile(L){const Q=this.#u();if(!Q.length)return null;Q.sort((i,s)=>i.v-s.v);let _=0;for(const i of Q)_+=i.w;const C=Math.min(1,Math.max(0,L))*_;let M=0;for(const i of Q)if(M+=i.w,M>=C)return i.v;return Q[Q.length-1].v}rank(L){let Q=0;for(let _=0;_<this.#e.length;_++){const C=1<<_;for(const M of this.#e[_])M<=L&&(Q+=C)}return Q}}const ue=Object.freeze({distinct:te.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),oe={Welford:fe,Reservoir:he,HyperLogLog:te,SpaceSaving:re,KLL:J,hash32:z,SKETCH_BOUNDS:ue}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=me("packages/core/src/compute/special.js"),te=z.studentTQuantile,x=z.studentT,T=z.normalQuantile,K=z.normalCdf,re=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),ue=J.cholesky,oe=J.choleskySolve,Y=J.choleskyInverse,L=J.normalEquations,Q=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let ie=0;ie<y;ie++){const se=j[ie];if(D&&D(se)!==1)continue;const we=I[se];Number.isNaN(we)||(O[k++]=we)}return O.subarray(0,k)}const W=X(b);for(let I=0;I<y;I++){const D=W(j[I]);if(D==null||D==="")continue;const ie=typeof D=="number"?D:Number(D);Number.isFinite(ie)&&(O[k++]=ie)}return O.subarray(0,k)}function c(b,j){const y=new Map,O=X(b);let k=0;for(let W=0;W<j.length;W++){const I=O(j[W]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const N=[...y.values()].sort((W,I)=>I-W);return{counts:N,total:k,distinct:N.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=c(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=c(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let N=0;for(let W=0;W<Math.min(k,O.counts.length);W++)N+=O.counts[W];return N/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let N=0,W=0;for(let I=0;I<O;I++)N+=k[I],W+=(I+1)*k[I];return N===0?0:2*W/(O*N)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const N=b[k];j++;const W=N-y;y+=W/j,O+=W*(N-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),N=Math.ceil(O);return k===N?b[k]:b[k]+(O-k)*(b[N]-b[k])}function l(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=X(b);let O=0,k=0,N=0;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&N++}return{pass:O+N,fail:k,warn:N,judged:O+N+k}}const P=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>Z(f(b,j),.1),winsorizedMean:(b,j)=>R(f(b,j),.1),robustOutliers:(b,j)=>v(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?l(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?l(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?l(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?l(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?l(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?l(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=l(y,.5),k=new Float64Array(y.length);for(let N=0;N<y.length;N++)k[N]=Math.abs(y[N]-O);return l(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let N=0;N<y.length;N++)y[N]<O&&(O=y[N]),y[N]>k&&(k=y[N]);return k-O},distinct:(b,j)=>{const y=X(b),O=new Set;for(let k=0;k<j.length;k++){const N=y(j[k]);N==null||N===""||O.add(N instanceof Date?N.getTime():N)}return O.size},mode:(b,j)=>{const y=X(b),O=new Map;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,N=1;for(const[W,I]of O)I>N&&(N=I,k=W);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<3||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/W)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<4||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let se=0;se<y.length;se++)I+=((y[se]-k)/W)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),ie=3*(O-1)**2/((O-2)*(O-3));return D*I-ie},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).fail}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function G(b,j,y){const O=X(b),k=X(j);let N=0,W=0;for(let I=0;I<y.length;I++){const D=y[I],ie=Number(O(D)),se=Number(k(D));!Number.isFinite(ie)||!Number.isFinite(se)||(N+=ie*se,W+=se)}return W===0?null:N/W}function F(b,j,y){const O=X(b);let k=null,N=y?-1/0:1/0;for(let W=0;W<j.length;W++){const I=j[W],D=Number(O(I));Number.isFinite(D)&&(y?D>N:D<N)&&(N=D,k=I)}return k}function E(b,j,y){const O=X(b),k=X(j);let N=0,W=0,I=0,D=0,ie=0,se=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(N++,W+=Pe,I+=ye,D+=Pe*Pe,ie+=ye*ye,se+=Pe*ye)}if(N<2)return null;const we=N*se-W*I,Oe=Math.sqrt((N*D-W*W)*(N*ie-I*I));if(Oe===0)return null;const je=we/Oe;return Math.max(-1,Math.min(1,je))}function Z(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O.slice(k,y-k);if(!N.length)return n(O,.5);let W=0;for(const I of N)W+=I;return W/N.length}function R(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O[k],W=O[y-1-k];let I=0;for(const D of O)I+=Math.min(W,Math.max(N,D));return I/y}function v(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=n(O,.5),N=O.map(D=>Math.abs(D-k)).sort((D,ie)=>D-ie),W=n(N,.5);if(W===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/W)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,N=0;for(const D of b){const ie=D-y;O+=ie*ie,k+=ie*ie*ie,N+=ie*ie*ie*ie}if(O/=j,k/=j,N/=j,O===0)return null;const W=k/O**1.5,I=N/(O*O)-3;return j/6*(W*W+I*I/4)}function V(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const ie=Number(b[D]),se=Number(j[D]);!Number.isFinite(ie)||!Number.isFinite(se)||se<=0||(O.push([ie,se]),k+=se)}if(!O.length||k<=0)return null;if(O.sort((D,ie)=>D[0]-ie[0]),O.length===1)return O[0][0];const N=[];let W=0;for(const[,D]of O)N.push((W+D/2)/k),W+=D;const I=Math.max(0,Math.min(1,y));if(I<=N[0])return O[0][0];if(I>=N[N.length-1])return O[O.length-1][0];for(let D=1;D<N.length;D++){if(I>N[D])continue;const ie=N[D]-N[D-1],se=ie>0?(I-N[D-1])/ie:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*se}return O[O.length-1][0]}function $(b,j,y){const O=X(b),k=X(j),N=new Float64Array(y.length),W=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const ie=y[D],se=Number(O(ie)),we=Number(k(ie));!Number.isFinite(se)||!Number.isFinite(we)||(N[I]=se,W[I]=we,I++)}return{xs:N.subarray(0,I),ys:W.subarray(0,I),n:I}}function ee(b,j,y,O=!1){const{xs:k,ys:N,n:W}=$(b,j,y);if(W<2)return null;let I=0,D=0;for(let se=0;se<W;se++)I+=k[se],D+=N[se];I/=W,D/=W;let ie=0;for(let se=0;se<W;se++)ie+=(k[se]-I)*(N[se]-D);return ie/(O?W:W-1)}function ne(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;let W=0,I=0;for(let Pe=0;Pe<N;Pe++)W+=O[Pe],I+=k[Pe];W/=N,I/=N;let D=0,ie=0,se=0;for(let Pe=0;Pe<N;Pe++){const ye=O[Pe]-W,ve=k[Pe]-I;D+=ye*ye,ie+=ye*ve,se+=ve*ve}if(D===0)return null;const we=ie/D,Oe=I-we*W,je=se===0?1:Math.max(0,Math.min(1,ie*ie/(D*se))),be=Math.max(0,se-we*ie),Ae=N>2?Math.sqrt(be/(N-2)/D):0;return{slope:we,intercept:Oe,r2:je,stdError:Ae,n:N}}const ce=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),H=1.345;function w(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),N=ue(O);if(!N)return null;const W=oe(N,k),I=Y(N),D=A(b,W),ie=j.map((se,we)=>se-D[we]);return{beta:W,cov:I,fitted:D,residuals:ie}}function A(b,j){return b.map(y=>y.reduce((O,k,N)=>O+k*j[N],0))}function q(b,j){const y=b.length,O=b.map(ie=>ie[j]),k=b.map(ie=>[1,...ie.filter((se,we)=>we!==j)]),N=w(k,O,null);if(!N)return 1;const W=O.reduce((ie,se)=>ie+se,0)/y;let I=0,D=0;for(let ie=0;ie<y;ie++)I+=N.residuals[ie]**2,D+=(O[ie]-W)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function le(b){const j=[...b].sort((k,N)=>k-N),y=ae(j),O=b.map(k=>Math.abs(k-y)).sort((k,N)=>k-N);return ae(O)/.6745}function ae(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ce.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,N=k&&Array.isArray(b[0])?b[0].length:0,W=N+1;if(!(k>W))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==N)return null;for(let Ne=0;Ne<N;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let ie,se=null;if(O==="robust"){if(ie=w(D,j,null),!ie)return null;for(let Me=0;Me<50;Me++){const Ne=le(ie.residuals);if(!(Ne>0))break;const Ee=ie.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=H?1:H/We}),Ce=w(D,j,Ee);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-ie.beta[Je])),0);if(ie=Ce,se=Ee,Ve<1e-10)break}}else if(ie=w(D,j,I),!ie)return null;const we=O==="robust"?se:I,{beta:Oe,cov:je,fitted:be,residuals:Ae}=ie;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-W,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===N?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?te(1-(1-He)/2,De):1/0,Lt=Oe.map((Me,Ne)=>{const Ee=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Ee>0?Me/Ee:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-x(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Ee:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Ee,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1,Ee=Math.max(0,Math.min(1,Ne*Q(D[Me],je)));dt[Me]=Ee;const Ce=(1-Ee)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(W*qe)*(Ee/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(N<2)return 1;const Ee=q(b,Ne);return Ee>=1?1/0:1/(1-Ee)});let gt=null;{const Me=Ae.map(Ee=>Ee*Ee),Ne=w(D,Me,null);if(Ne){const Ee=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Ee)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=re(We,N);gt={statistic:We,df:N,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(N===1){const Me=b.map((Ne,Ee)=>Ee).sort((Ne,Ee)=>b[Ne][0]-b[Ee][0]);bt={confidence:He,points:Me.map(Ne=>{const Ee=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Q(Ee,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:we?[...we]:null}}function pe(b){const j=b.length,y=Array.from({length:j},(N,W)=>W).sort((N,W)=>b[N]-b[W]),O=new Float64Array(j);let k=0;for(;k<j;){let N=k;for(;N+1<j&&b[y[N+1]]===b[y[k]];)N++;const W=(k+N)/2+1;for(let I=k;I<=N;I++)O[y[I]]=W;k=N+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const N=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+N*(b-y[0]))))}if(b>=y[2]){const N=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+N*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Le(b,j,y,O){const k=y-O,N=O+3,W=new Array(k),I=new Array(k);let D=!0,ie=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(N);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<N;ye++)Number.isFinite(Pe[ye])||(ie=Math.min(ie,ye-3));W[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:se,xtwy:we}=L(W,I,null);let Oe=0,je=1/0;for(let be=0;be<=ie;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=se[Ue].slice(0,Ae);const ye=ue(Pe);if(!ye)continue;const ve=oe(ye,we.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=W[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,Oe=be)}return Oe}function Re(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const N=new Array(k);for(let je=0;je<k;je++)N[je]=y[je+1]-y[je];let W=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);W=Math.max(0,Math.min(W,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(N[ye-Fe]);Ae.push(ve),Pe.push(N[ye])}return de(Ae,Pe,{method:"ols"})},D=Le(y,N,k,W),ie=I(D,D);if(!ie||!ie.coefficients[2])return null;const se=ie.coefficients[2].t,we=ke(se),Oe=se<ge["5%"];return{statistic:se,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:we,pApproximate:!0,stationary:Oe,verdict:Oe?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let Oe=0;Oe<b.length;Oe++){const je=Number(b[Oe]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let N=0;for(const Oe of y)N+=Oe;N/=O;const W=y.map(Oe=>Oe-N);let I=0;for(const Oe of W)I+=Oe*Oe;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let Oe=1;Oe<=k;Oe++){let je=0;for(let be=Oe;be<O;be++)je+=W[be]*W[be-Oe];D[Oe]=I>0?je/O/I:0}const ie=new Array(k+1).fill(0);ie[0]=1;let se=[];for(let Oe=1;Oe<=k;Oe++){let je=D[Oe];for(let ye=1;ye<Oe;ye++)je-=se[ye-1]*D[Oe-ye];let be=1;for(let ye=1;ye<Oe;ye++)be-=se[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(Oe);for(let ye=1;ye<Oe;ye++)Pe[ye-1]=se[ye-1]-Ae*se[Oe-1-ye];Pe[Oe-1]=Ae,ie[Oe]=Ae,se=Pe}const we=1.96/Math.sqrt(O);return{acf:D,pacf:ie,bounds:{upper:we,lower:-we},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;const W=pe(O),I=pe(k);let D=0,ie=0;for(let je=0;je<N;je++)D+=W[je],ie+=I[je];D/=N,ie/=N;let se=0,we=0,Oe=0;for(let je=0;je<N;je++){const be=W[je]-D,Ae=I[je]-ie;se+=be*Ae,we+=be*be,Oe+=Ae*Ae}return we===0||Oe===0?null:Math.max(-1,Math.min(1,se/Math.sqrt(we*Oe)))}function Ke(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2||N>M)return null;let W=0,I=0,D=0,ie=0;for(let Oe=0;Oe<N;Oe++)for(let je=Oe+1;je<N;je++){const be=Math.sign(O[Oe]-O[je]),Ae=Math.sign(k[Oe]-k[je]),Pe=be*Ae;Pe>0?W++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:ie++)}const se=W+I+ie,we=W+I+D;return se===0||we===0?null:(W-I)/Math.sqrt(se*we)}function Te(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],N=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&N.push((b[ye]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let ye=0;for(const Fe of N)ye+=Fe;ye/=N.length;let ve=0;for(const Fe of N)ve+=(Fe-ye)**2;W=Math.sqrt(ve/(N.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],ie=0,se=0,we=0,Oe=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],ie=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>se&&(se=ve,we=ie,Oe=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of N)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:W,annualisedVolatility:W!==null&&I?W*Math.sqrt(I):null,growth:Pe,maxDrawdown:se,maxDrawdownFrom:we,maxDrawdownTo:Oe,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,N)=>k+N,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let N=0;for(let be=0;be<y;be++)N+=b[be];N/=y;let W=0;for(let be=0;be<y;be++)W+=(b[be]-N)**2;const I=Math.sqrt(W/(y-1)),D=xe(b),ie=D?D.sigma:null,se=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-N)/(3*be):1/0,ve=O!==null?(N-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},we=se(ie),Oe=se(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:N,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:ie,sigmaOverall:I,cp:we.index,cpk:we.k,pp:Oe.index,ppk:Oe.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=I=>(b[I]-O)/k,W=[];for(let I=0;I<y;I++){if(Math.abs(N(I))>3&&W.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let ie=0;for(let se=I-2;se<=I;se++)N(se)*D>2&&ie++;if(ie>=2){W.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let ie=0;for(let se=I-4;se<=I;se++)N(se)*D>1&&ie++;if(ie>=4){W.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let ie=!0;for(let se=I-7;se<=I;se++)if(N(se)*D<=0){ie=!1;break}if(ie){W.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return W}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=D=>(b[D]-O)/k,W=(D,ie,se,we)=>{for(const Oe of[1,-1]){let je=0;for(let be=D;be<=ie;be++)N(be)*Oe>se&&je++;if(je>=we)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(N(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const ie of[1,-1]){let se=!0;for(let we=D-8;we<=D;we++)if(N(we)*ie<=0){se=!1;break}if(se){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const ie of[1,-1]){let se=!0;for(let we=D-4;we<=D;we++)if((b[we]-b[we-1])*ie<=0){se=!1;break}if(se){I.push({index:D,rule:3,description:ie>0?"six rising":"six falling"});break}}if(D>=13){let ie=!0;for(let se=D-12;se<=D;se++){const we=b[se]-b[se-1],Oe=b[se+1<=D?se+1:se]-b[se];if(se+1>D)break;if(we===0||Oe===0||we>0==Oe>0){ie=!1;break}}ie&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&W(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&W(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let ie=!0;for(let se=D-14;se<=D;se++)if(Math.abs(N(se))>=1){ie=!1;break}ie&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let ie=!0;for(let se=D-7;se<=D;se++)if(Math.abs(N(se))<=1){ie=!1;break}ie&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const N=b[0],W=b[k-1];if(W===N)return[{from:N,to:W,count:k}];const I=y-j,D=1.5*I;let ie=I>0?Math.max(N,j-D):N,se=I>0?Math.min(W,y+D):W;se>ie||(ie=N,se=W);const we=I>0?2*I/Math.cbrt(k):(se-ie)/(Math.ceil(Math.log2(k))+1),Oe=we>0?Math.min(O,Math.max(1,Math.ceil((se-ie)/we))):1,je=(se-ie)/Oe,be=[];for(let Ae=0;Ae<Oe;Ae++)be.push({from:ie+Ae*je,to:ie+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(Oe-1,Math.max(0,Math.floor((b[Ae]-ie)/je)));be[Pe].count++}return be[0].from=N,be[Oe-1].to=W,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let se=0;se<y;se++)O+=b[se];const k=O/y;let N=0;for(let se=0;se<y;se++){const we=b[se]-k;N+=we*we}const W=Math.sqrt(N/(y-1)),I=Qe(j),ie=te(1-(1-I)/2,y-1)*W/Math.sqrt(y);return{mean:k,lower:k-ie,upper:k+ie,margin:ie,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const N=Qe(y),W=T(1-(1-N)/2),I=O/k,D=W*W,ie=1+D/k,se=(I+D/(2*k))/ie,we=W/ie*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,se-we),upper:Math.min(1,se+we),n:k,confidence:N}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=te(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const N=Qe(y),I=T(1-(1-N)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:N}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=X(b);let k=0;for(let N=0;N<j.length;N++){const W=O(j[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const I=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const N=new Set(b.keys());for(const W of y.keys())N.add(W);for(const W of N){const I=(b.get(W)||0)/j,D=(y.get(W)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:ie}=r(I),se=D>0?lt({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:se,distance:se===null?0:at(se),direction:se===null?0:Math.sign(se),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:N}=_e(b,j),W=ft(k,N,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:y.total||0,reliable:N>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=X(b);let O=0,k=0;for(let N=0;N<j.length&&O<200;N++){const W=y(j[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;O++;const I=typeof W=="number"?W:Number(W);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:N,mean:W,m2:I}=r(k);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(I/N):0,n:N}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,X=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),te=z.presenceReader,x=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),re=K.STAT_FNS,J=K.STAT_LABELS;function ue(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function oe(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++){const E=S[n[F]];Number.isNaN(E)||(g+=E)}return g}for(let F=0;F<l;F++){const E=n[F];if(G(E)===1){const Z=S[E];Number.isNaN(Z)||(g+=Z)}}return g}const P=T(r);for(let S=0;S<l;S++){const G=u(P(n[S]));G!==null&&(g+=G)}return g}oe.kernel=!0;function Y(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++)Number.isNaN(S[n[F]])||g++;return g}for(let F=0;F<l;F++){const E=n[F];G(E)===1&&!Number.isNaN(S[E])&&g++}return g}const P=T(r);for(let S=0;S<l;S++){const G=P(n[S]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}Y.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Q(r,n){const l=Y(r,n);return l===0?null:oe(r,n)/l}Q.kernel=!0;function _(r,n,l,g){const P=n.length;if(ue(r)){const E=r.values,Z=te(r);let R=null;if(!Z){for(let v=0;v<P;v++){const U=E[n[v]];Number.isNaN(U)||(R===null||(l<0?U<R:U>R))&&(R=U)}return R}for(let v=0;v<P;v++){const U=n[v];if(Z(U)===0)continue;const V=E[U];Number.isNaN(V)||(R===null||(l<0?V<R:V>R))&&(R=V)}return R}const S=T(r),G=x(g);let F=null;for(let E=0;E<P;E++){const Z=S(n[E]);Z==null||typeof Z=="number"&&Number.isNaN(Z)||(F===null||(l<0?G(Z,F)<0:G(Z,F)>0))&&(F=Z)}return F}function C(r,n,l){return _(r,n,-1,l&&l.locale)}C.kernel=!0;function M(r,n,l){return _(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(r)(n[n.length-1])}s.kernel=!0;function u(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const f={sum:oe,min:C,max:M,avg:Q,count:L,first:i,last:s,countValues:Y,...re},c=Object.freeze({...J,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?c[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(g=>g in f);for(const g of Object.keys(f))l.includes(g)||l.push(g);return l}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const l=T(r),g=[];for(let P=0;P<n.length;P++){const S=l(n[P]);S!=null&&g.push(S)}return g}function h(r,n,l,g){const P=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,P,g):(X(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return he(l)?l.kernel===!0?l(r,P,g):l(d(r,P),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,x=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,re="|",J="/",ue=2e3;function oe(u,f,c){return`${u}${re}${f}${re}${c}`}function Y(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function L(u,f,c={}){const t=c.separator||J,a=f.length,{keyOf:m,readers:e}=x(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const E=f[F],Z=m(E);if(d.has(Z))continue;d.set(Z,h.length),r.push(Z);const R=new Array(e.length);for(let v=0;v<e.length;v++)R[v]=e[v](E);h.push(R)}const n=z(c.locale),l=h.map((F,E)=>E);l.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Q(Z[v],R[v],n);if(U!==0)return U}return F-E});const g=new Array(l.length),P=new Array(l.length),S=new Map;for(let F=0;F<l.length;F++){const E=l[F];g[F]=h[E],P[F]=Y(h[E],t),S.set(r[E],F)}return{keys:g,paths:P,idOf:F=>{const E=S.get(m(F));return E===void 0?-1:E}}}function Q(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function _(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=c(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=C(u,f,c),a=t.separator||J,m=_(t),e=t.maxColumns===void 0?ue:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(Z=>Y(Z,a)):[""]),n=s(h),{keys:l,paths:g,idOf:P}=L(t.pivotHandles||[],n,t),S=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&S>e){const Z=new Map;return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:Z,cells:Z,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const F=new Map,E=g.length;for(let Z=0;Z<h.length;Z++){const R=h[Z],v=r[Z]===void 0?"":r[Z],U=R.length;if(U===0)continue;const V=new Int32Array(U),$=new Uint32Array(E+1);for(let ce=0;ce<U;ce++){const p=P(R[ce]);V[ce]=p,p>=0&&$[p+1]++}for(let ce=0;ce<E;ce++)$[ce+1]+=$[ce];const ee=new Uint32Array(U),ne=$.slice(0,E);for(let ce=0;ce<U;ce++){const p=V[ce];p>=0&&(ee[ne[p]++]=R[ce])}for(let ce=0;ce<E;ce++){const p=$[ce],B=$[ce+1];if(B===p)continue;const H=ee.subarray(p,B);for(let w=0;w<m.length;w++){const A=m[w],q=K(A.handle,H,A.fn,t.totalContext||{locale:t.locale});F.set(oe(v,g[ce],A.colId),q)}}}return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:F,cells:F,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${c}${m.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,x=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,re=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,ue="";function oe(i,s,u={}){const f=u.separator||re,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ue],buckets:[t]};const{keyOf:m,readers:e}=x(c,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const E=t[F],Z=m(E);let R=d.get(Z);if(R===void 0){R=h.length,d.set(Z,R),r.push(Z);const v=new Array(e.length);for(let U=0;U<e.length;U++)v[U]=e[U](E);h.push(v),n.push([])}n[R].push(E)}const l=he(u.locale),g=h.map((F,E)=>E);g.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Y(Z[v],R[v],l);if(U!==0)return U}return F-E});const P=new Array(g.length),S=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const E=g[F];P[F]=h[E],S[F]=K(h[E],f),G[F]=Uint32Array.from(n[E])}return{tuples:P,paths:S,buckets:G}}function Y(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Q(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function _(i){const s=i&&i.opts||{},u=s.separator||re,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=oe(i.rowHandles||[],t,{...s,separator:u}),m=oe(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,c.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,l=new Map,g=new Map,P=m.buckets.map(S=>new Set(S));for(let S=0;S<m.paths.length;S++){const G=m.buckets[S],F=m.paths[S];for(const E of c)l.set(M(F,E.colId),Q(E.handle,G,E.fn,f))}for(let S=0;S<a.paths.length;S++){const G=a.buckets[S],F=a.paths[S];for(const E of c)n.set(M(F,E.colId),Q(E.handle,G,E.fn,f));for(let E=0;E<m.paths.length;E++){const Z=L(G,m.buckets[E],P[E]);if(Z.length===0)continue;const R=m.paths[E];for(const v of c)r.set(C(F,R,v.colId),Q(v.handle,Z,v.fn,f))}}for(const S of c)g.set(S.colId,Q(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function M(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/internal/util.js").getPath,X=me("packages/core/src/compute/handle.js"),z=X.isMissing,te=X.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",re="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function ue(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=oe(i,c,f[t],u);return c}function oe(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),a=u.descending!==void 0?!!u.descending:u.dir==="desc",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const h=(r,n)=>{const l=J(i[r],u.col),g=J(i[n],u.col);let P;return typeof u.compare=="function"?(P=u.compare(l,g,i[r],i[n],a),a&&(P=-P)):P=a?t(g,l):t(l,g),P!==0?P:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function Y(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)L(i[c],s,u,c)&&f.push(c);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>L(i,a,u,f));const t=c.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Q(i,s,u,f){const c=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of c){const d=s.map((n,l)=>{const g=J(i[e],n);return f&&f[l]?f[l](g):g}),h=d.map(n=>n==null?re:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function _(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!z(a)),t=c.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return c.length===0?null:t.reduce((a,m)=>a+m,0)/c.length;case"min":return c.length===0?null:c.reduce((a,m)=>f(m,a)<0?m:a);case"max":return c.length===0?null:c.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(i[i.length-1]);default:return null}}function C(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function M(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return x}});const he=me("packages/core/src/compute/sketch.js").Welford;class X{#t;#e;#n=[];#r;#i;constructor(K,re=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(re>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(re),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,re=this.#r()){Number.isFinite(K)&&(this.#n.push({t:re,v:K}),this.#s(re))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=K-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let J=0,ue=1/0,oe=-1/0;for(const{v:Y}of this.#n)J+=Y,Y<ue&&(ue=Y),Y>oe&&(oe=Y),re.add(Y);return{over:K,count:this.#n.length,sum:J,mean:re.mean(),min:ue,max:oe,variance:re.variance(),stddev:re.stddev()}}reduce(K){const re=this.aggregate(),J={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:re.over}}}const z=Object.freeze(["count","time","session"]);function te(T,K=Date.now){const re=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new X(T.kind,re,K)}const x={Window:X,WINDOW_KINDS:z,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,te=.6745,x=3.5,T=1.5,K=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(c){if(!c.length)return null;const a=Array.from(c,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function ue(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:x,m=c.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let l=0;l<m;l++){const g=Number(c[l]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let l=0;l<m;l++){const g=Number(c[l]);if(!Number.isFinite(g))continue;const P=te*(g-r.median)/r.mad;e[l]=P,Math.abs(P)>a&&(d[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function oe(c,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&m.push(l)}if(!m.length)return null;const e=m.sort((n,l)=>n-l),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function Y(c,t){if(t<=0)return 0;const a=z(c);if(t<c+1){let l=c,g=1/c,P=g;for(let S=0;S<1e3&&(l+=1,P*=t/l,g+=P,!(Math.abs(P)<Math.abs(g)*1e-15));S++);return g*Math.exp(-t+c*Math.log(t)-a)}const m=1e-300;let e=t+1-c,d=1/m,h=1/e,r=h;for(let l=1;l<1e3;l++){const g=-l*(l-c);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const P=h*d;if(r*=P,Math.abs(P-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function L(c,t){return c<=0?0:Y(t/2,c/2)}function Q(c,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,c);for(;L(m,c)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,c)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function _(c){const t=c.length,a=c.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(c,t){const a=c.length,m=new Array(t).fill(0);for(const h of c)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of c)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let l=r;l<t;l++)e[r][l]+=n*(h[l]-m[l])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const d=c[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],g=[];for(let v=0;v<e;v++){const U=c[v];let V=U.length===d;const $=new Array(d);for(let ee=0;V&&ee<d;ee++){const ne=Number(U[ee]);Number.isFinite(ne)?$[ee]=ne:V=!1}V&&(l.push(v),g.push($))}const P=d,S=Q(P,a);if(g.length<=d)return{center:[],df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let E=_(F),Z=!1;if(!E){Z=!0;let v=0;for(let $=0;$<d;$++)v+=F[$][$];const U=v/d*m||m,V=F.map(($,ee)=>$.map((ne,ce)=>ee===ce?ne+U:ne));if(E=_(V),!E)return{center:G,df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let R=0;for(let v=0;v<g.length;v++){const U=g[v],V=new Array(d);for(let ne=0;ne<d;ne++)V[ne]=U[ne]-G[ne];let $=0;for(let ne=0;ne<d;ne++){let ce=0;for(let p=0;p<d;p++)ce+=E[ne][p]*V[p];$+=V[ne]*ce}$<0&&($=0);const ee=l[v];r[ee]=$,h[ee]=Math.sqrt($),$>S&&(n[ee]=!0,R++)}return{center:G,df:P,cutoff:S,singular:Z,used:g.length,distances:h,squared:r,flags:n,flagged:R}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:x,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let g=0;for(let P=0;P<r;P++){const S=Number(c[P]);if(!Number.isFinite(S))continue;const G=Math.max(0,P-m+1),F=[];for(let E=G;E<=P;E++){const Z=Number(c[E]);Number.isFinite(Z)&&F.push(Z)}if(!(F.length<h))if(a==="rollingIqr"){const E=oe(F,{k:d});if(!E)continue;(S<E.lower||S>E.upper)&&(l[P]=!0,g++)}else{const E=J(F);if(!E||E.mad===0)continue;const Z=te*(S-E.median)/E.mad;n[P]=Z,Math.abs(Z)>e&&(l[P]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:l,flagged:g}}function f(c={}){const t=c||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=l=>Number(l==null?NaN:l[a]);return l=>{const g=Array.isArray(l)?l.slice():[...l];d&&g.sort((E,Z)=>{const R=E?.[d],v=Z?.[d];return R===v?0:R==null?-1:v==null?1:R<v?-1:1});const P=g.map(n);let S,G;if(r)({flags:S,scores:G}=u(P,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const E=oe(P,{k:t.k});S=P.map(Z=>E?Number.isFinite(Z)&&(Z<E.lower||Z>E.upper):!1),G=P.map(()=>null)}else({flags:S,scores:G}=ue(P,{threshold:t.threshold}));if(h){const E=S.length-1;return E<0||!S[E]?!1:{method:m,field:a,flagged:[{row:g[E],score:G[E]}]}}const F=[];for(let E=0;E<S.length;E++)S[E]&&F.push({row:g[E],score:G[E]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,X=fe.studentTQuantile,te=me("packages/core/src/internal/util.js").warnOnce,x=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function re(t){const a=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function ue(t){return Math.min(K,Math.max(T,t))}function oe(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),l=h+d*(r-h),g=t(n),P=t(l);for(let S=0;S<e;S++)g<P?(r=l,l=n,P=g,n=r-d*(r-h),g=t(n)):(h=n,n=l,g=P,l=h+d*(r-h),P=t(l));return(h+r)/2}function Y(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=l;continue}d===null&&(d=l-e);const g=e+d;h+=(l-g)**2,r+=1;const P=e;e=a*l+(1-a)*(P+d),d=m*(e-P)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Q(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=Z=>{let R=0,v=0;for(let U=Z;U<Z+a&&U<h;U++)t[U]!==null&&(R+=t[U],v+=1);return v?R/v:null},n=r(0),l=r(a);if(n===null||l===null)return null;let g=n,P=(l-n)/a;const S=new Array(a).fill(0);for(let Z=0;Z<a;Z++)S[Z]=t[Z]===null?0:t[Z]-g;const G=S.reduce((Z,R)=>Z+R,0)/a;for(let Z=0;Z<a;Z++)S[Z]-=G;let F=0,E=0;for(let Z=a;Z<h;Z++){const R=Z%a,v=S[R],U=t[Z];if(U===null){g+=P;continue}const V=g+P+v;F+=(U-V)**2,E+=1;const $=g;g=m*(U-v)+(1-m)*(g+P),P=e*(g-$)+(1-e)*P,S[R]=d*(U-g)+(1-d)*v}return{level:g,trend:P,season:S,phase:(h-1)%a,sse:F,count:E}}function _(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=x.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=re(t),n=r.map(F=>F.value),l=n.filter(F=>F!==null),g=l.length,{lastAt:P,step:S}=g?J(r):{lastAt:0,step:1},G=F=>P+F*S;return m==="linear"?M(r,g,e,d,h,G):m==="movingAverage"?i(l,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function M(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let l=0,g=0,P=0;for(const U of t){if(U.value===null)continue;const V=U.at-r,$=U.value-n;l+=V*V,g+=V*$,P+=$*$}if(l===0)return null;const S=g/l,G=n-S*r,F=P===0?1:Math.max(0,Math.min(1,g*g/(l*P))),E=Math.max(0,P-S*g),Z=a>2?Math.sqrt(E/(a-2)):null,R=a>2?X(d,a-2):null,v=[];for(let U=1;U<=m;U++){const V=h(U),$=G+S*V;let ee=null,ne=null,ce=null,p=null,B=null;if(Z!==null){const H=1/a+(V-r)**2/l,w=Z*Math.sqrt(1+H),A=Z*Math.sqrt(H);B=w,ee=$-R*w,ne=$+R*w,ce=$-R*A,p=$+R*A}v.push({step:U,at:V,mean:$,lower:ee,upper:ne,lowerMean:ce,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:Z,r2:F,params:{slope:S,intercept:G},points:v}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),l=t.slice(a-n);let g=0;for(const Z of l)g+=Z;const P=g/n;let S=null,G=null;if(n>1){let Z=0;for(const v of l)Z+=(v-P)**2;S=Math.sqrt(Z/(n-1))*Math.sqrt(1+1/n),G=X(d,n-1)}const F=S===null?null:G*S,E=[];for(let Z=1;Z<=m;Z++)E.push({step:Z,at:r(Z),mean:P,lower:F===null?null:P-F,upper:F===null?null:P+F,se:S});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:E}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null;n===null&&(n=oe(G=>Y(t,G).sse));const l=Y(t,n),g=he(d),P=l.m>0?l.sse/l.m:null,S=[];for(let G=1;G<=m;G++){const F=l.level;let E=null,Z=null,R=null;if(P!==null){const v=[];for(let V=1;V<G;V++)v.push(n);const U=_(P,v,g);R=U.se,E=F-U.margin,Z=F+U.margin}S.push({step:G,at:r(G),mean:F,lower:E,upper:Z,se:R})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:P===null?null:Math.sqrt(P),params:{alpha:n},points:S}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null,l=Number.isFinite(h.beta)?ue(h.beta):null;if(n===null||l===null){let E=n===null?.5:n,Z=l===null?.5:l;for(let R=0;R<6;R++)n===null&&(E=oe(v=>L(t,v,Z).sse)),l===null&&(Z=oe(v=>L(t,E,v).sse));n=n===null?E:n,l=l===null?Z:l}const g=L(t,n,l),P=he(d),S=g.m>0?g.sse/g.m:null,G=n*l,F=[];for(let E=1;E<=m;E++){const Z=g.level+E*g.trend;let R=null,v=null,U=null;if(S!==null){const V=[];for(let ee=1;ee<E;ee++)V.push(n+ee*G);const $=_(S,V,P);U=$.se,R=Z-$.margin,v=Z+$.margin}F.push({step:E,at:r(E),mean:Z,lower:R,upper:v,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(h.alpha)?ue(h.alpha):null,g=Number.isFinite(h.beta)?ue(h.beta):null,P=Number.isFinite(h.gamma)?ue(h.gamma):null;const S=(U,V,$)=>{const ee=Q(t,n,U,V,$);return ee?ee.sse:1/0};if(l===null||g===null||P===null){let U=l===null?.5:l,V=g===null?.5:g,$=P===null?.5:P;for(let ee=0;ee<8;ee++)l===null&&(U=oe(ne=>S(ne,V,$))),g===null&&(V=oe(ne=>S(U,ne,$))),P===null&&($=oe(ne=>S(U,V,ne)));l=l===null?U:l,g=g===null?V:g,P=P===null?$:P}const G=Q(t,n,l,g,P);if(!G)return null;const F=he(d),E=G.count>0?G.sse/G.count:null,Z=l*g,R=P*(1-l),v=[];for(let U=1;U<=m;U++){const V=G.season[(G.phase+U)%n],$=G.level+U*G.trend+V;let ee=null,ne=null,ce=null;if(E!==null){const p=[];for(let H=1;H<U;H++)p.push(l+H*Z+(H%n===0?R:0));const B=_(E,p,F);ce=B.se,ee=$-B.margin,ne=$+B.margin}v.push({step:U,at:r(U),mean:$,lower:ee,upper:ne,se:ce})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:l,beta:g,gamma:P,period:n},points:v}}const c={FORECAST_METHODS:x,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const X=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const te=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const x=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return x.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return x.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return x.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const ue=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ue.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ue.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ue.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ue.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ue.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ue.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue.SKETCH_BOUNDS}});const oe=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return oe.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return oe.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return oe.openWindow}});const Y=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return Y.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return Y.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return Y.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Q=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Q.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,X=fe.OPS,z=fe.CONTROL,te=fe.ERRORS,x=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,re=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),ue=J.packChunk,oe=J.packedTransfers;let Y=null,L=null,Q=null;async function _(f){if(Y)return Y;if(!L){const c=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(c).then(t=>(Y=t,t)).catch(t=>(Q=t,Y=null,null))}return L}function C(f){Y=f,L=f?Promise.resolve(f):null,Q=f?null:Q}function M(f,c,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:c,pool:K(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===X.COLUMNIZE)return ue(a.schema||[],a.rows||[],a.opts||{});const m=c[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case X.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case X.SORT_COLUMN:return m(x(a.handle),a.order??null,a.opts||{});case X.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case X.EVALUATE_FILTERS:return m(a.filters,M(T(a.handles||[]),a.count,a.locale));case X.COMPACT:return m(a.mask,a.count,void 0);case X.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.TOTAL:return m(x(a.handle),a.indices??null,a.fn);case X.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.FACET:return m(x(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return c.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===X.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ue(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:oe(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await _(c.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Q?Q.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),_(c.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Be=Un("packages/dom/src/index.js"),_i=Be.createGrid,Zi=Be.gridElementsWithin,Yi=Be.createStat,Xi=Be.deltaOf,Qi=Be.toneOf,Ji=Be.readTable,eo=Be.hydrateTable,to=Be.autoInit,no=Be.createLocalViewStorage,ro=Be.DEFAULT_VIEWS_KEY,io=Be.createHeadlessGrid,oo=Be.defaults,so=Be.version,ao=Be.getVersion,lo=Be.Grid,uo=Be.EventBus,co=Be.Registry,fo=Be.sharedRegistry,ho=Be.registerModules,mo=Be.parseLicence,po=Be.verifyLicence,go=Be.licenceInfo,yo=Be.watermark,bo=Be.setLicence,wo=Be.licenceState,vo=Be.isLocalHost,ko=Be.matchesDomain,So=Be.LicenceHolder,Oo=Be.ColumnModel,jo=Be.buildGraph,Ao=Be.Lookup,Po=Be.ValuePipeline,Co=Be.compileFormat,Eo=Be.compileMask,To=Be.specToOoxml,Mo=Be.EXTENDED_TYPES,No=Be.createRadixType,Ro=Be.RADIX_PRESETS,Lo=Be.parseRadix,Fo=Be.formatRadix,xo=Be.createUnitType,Io=Be.registerUnitSystem,Do=Be.defineUnit,$o=Be.UNIT_SYSTEMS,zo=Be.parseUnit,Bo=Be.formatUnit,Uo=Be.createCurrencyType,Ho=Be.parseMoney,Vo=Be.formatMoney,Go=Be.convertMoney,Ko=Be.rateFunction,Wo=Be.MISSING_RATE,qo=Be.Messages,_o=Be.createMessages,Zo=Be.auditCatalogue,Yo=Be.EN_GB,Xo=Be.MESSAGE_KEYS,Qo=Be.DEFAULT_LOCALE,Jo=Be.formatList,es=Be.resolveLocale,ts=Be.LOCALES,ns=Be.resolveCatalogue,rs=Be.EN_US,is=Be.FR_FR,os=Be.FR_CA,ss=Be.IT_IT,as=Be.ES_ES,ls=Be.PT_BR,us=Be.DE_DE,cs=Be.NL_NL,ds=Be.SV_SE,fs=Be.DA_DK,hs=Be.NB_NO,ms=Be.FI_FI,ps=Be.PL_PL,gs=Be.CS_CZ,ys=Be.HU_HU,bs=Be.RO_RO,ws=Be.UK_UA,vs=Be.EL_GR,ks=Be.JA_JP,Ss=Be.AR,Os=Be.AR_SA,js=Be.ColumnStore,As=Be.Bitset,Ps=Be.Dictionary,Cs=Be.MultiValue,Es=Be.MaskPool,Ts=Be.sortColumn,Ms=Be.sortMulti,Ns=Be.evaluateFilters,Rs=Be.compact,Ls=Be.testValue,Fs=Be.groupByColumns,xs=Be.total,Is=Be.TOTAL_FNS,Ds=Be.pivot,$s=Be.Window,zs=Be.openWindow,Bs=Be.WINDOW_KINDS,Us=Be.ANOMALY_METHODS,Hs=Be.modifiedZScores,Vs=Be.iqrFences,Gs=Be.mahalanobis,Ks=Be.ROLLING_ANOMALY_METHODS,Ws=Be.rollingAnomalies,qs=Be.anomalyCondition,_s=Be.FORECAST_METHODS,Zs=Be.forecast,Ys=Be.evaluateFormula,Xs=Be.parseFormula,Qs=Be.referencesOf,Js=Be.looksLikeFormula,ea=Be.FormulaError,ta=Be.FUNCTIONS,na=Be.compileRules,ra=Be.ingest,ia=Be.ingestSync,oa=Be.createSource,sa=Be.createMemorySource,aa=Be.createPagedSource,la=Be.createRemoteSource,ua=Be.createStreamSource,ca=Be.createUrlSource,da=Be.PROTOCOL,fa=Be.createPushdownSource,ha=Be.planQuery,ma=Be.splitFilters,pa=Be.applyResidual,ga=Be.capabilitiesOf,ya=Be.resolveMutate,ba=Be.NO_CAPABILITIES,wa=Be.odataAdapter,va=Be.filtersToOData,ka=Be.conditionToOData,Sa=Be.restAdapter,Oa=Be.DEFAULT_PARAMS,ja=Be.dfqlAdapter,Aa=Be.duckdbAdapter,Pa=Be.filtersToSql,Ca=Be.graphqlAdapter,Ea=Be.splunkAdapter,Ta=Be.RowModel,Ma=Be.createRowKey,Na=Be.SelectionModel,Ra=Be.RangeModel,La=Be.EditModel,Fa=Be.ChangeModel,xa=Be.StateModel,Ia=Be.STATE_VERSION,Da=Be.serialiseState,$a=Be.restoreState,za=Be.VERSION,Ba=Be.DomRenderer,Ua=Be.FilterMenu,Ha=Be.mergeColumnFilter,Va=Be.branchFor,Ga=Be.ColumnMenu,Ka=Be.columnMenuItems,Wa=Be.cellMenuItems,qa=Be.autoGroupMenuItems,_a=Be.AlignedGrids,Za=Be.alignGrids,Ya=Be.layoutState,Xa=Be.ToolPanelDock,Qa=Be.panelHost,Ja=Be.mountPanel,el=Be.CellEditController,tl=Be.EditBar,nl=Be.HistoryBar,rl=Be.HISTORY_CLS,il=Be.DiffPainter,ol=Be.ViewPicker,sl=Be.VIEW_CLS,al=Be.summariseDiff,ll=Be.PromptBar,ul=Be.PROMPT_CLASS,cl=Be.createCellLayer,dl=Be.compileTemplate,fl=Be.compileVariant,hl=Be.checkVariant,ml=Be.VariantRegistry,pl=Be.BUILTIN_RENDERERS,gl=Be.BUILTIN_VARIANTS,yl=Be.BUILTIN_PIPES,bl=Be.sanitiseHtml,wl=Be.editors,vl=Be.createEditor,kl=Be.editorFor,Sl=Be.BaseEditor,Ol=Be.filters,jl=Be.createFilter,Al=Be.filterFor,Pl=Be.parseExpression,Cl=Be.ConditionFilter,El=Be.StatusBar,Tl=Be.ContextMenu,Ml=Be.ToolPanel,Nl=Be.TooltipManager,Rl=Be.Pagination,Ll=Be.OverlayLayer,Fl=Be.LatticeGrid,xl=Be.setLicense,Il=Be.licenseInfo,Dl=Be.licenseState;var $l=Be.default;export{Us as ANOMALY_METHODS,Ss as AR,Os as AR_SA,_a as AlignedGrids,yl as BUILTIN_PIPES,pl as BUILTIN_RENDERERS,gl as BUILTIN_VARIANTS,Sl as BaseEditor,As as Bitset,gs as CS_CZ,el as CellEditController,Fa as ChangeModel,Ga as ColumnMenu,Oo as ColumnModel,js as ColumnStore,Cl as ConditionFilter,Tl as ContextMenu,fs as DA_DK,Qo as DEFAULT_LOCALE,Oa as DEFAULT_PARAMS,ro as DEFAULT_VIEWS_KEY,us as DE_DE,Ps as Dictionary,il as DiffPainter,Ba as DomRenderer,vs as EL_GR,Yo as EN_GB,rs as EN_US,as as ES_ES,Mo as EXTENDED_TYPES,tl as EditBar,La as EditModel,uo as EventBus,ms as FI_FI,_s as FORECAST_METHODS,os as FR_CA,is as FR_FR,ta as FUNCTIONS,Ua as FilterMenu,ea as FormulaError,lo as Grid,rl as HISTORY_CLS,ys as HU_HU,nl as HistoryBar,ss as IT_IT,ks as JA_JP,ts as LOCALES,Fl as LatticeGrid,So as LicenceHolder,Ao as Lookup,Xo as MESSAGE_KEYS,Wo as MISSING_RATE,Es as MaskPool,qo as Messages,Cs as MultiValue,hs as NB_NO,cs as NL_NL,ba as NO_CAPABILITIES,Ll as OverlayLayer,ps as PL_PL,ul as PROMPT_CLASS,da as PROTOCOL,ls as PT_BR,Rl as Pagination,ll as PromptBar,Ro as RADIX_PRESETS,Ks as ROLLING_ANOMALY_METHODS,bs as RO_RO,Ra as RangeModel,co as Registry,Ta as RowModel,Ia as STATE_VERSION,ds as SV_SE,Na as SelectionModel,xa as StateModel,El as StatusBar,Is as TOTAL_FNS,Ml as ToolPanel,Xa as ToolPanelDock,Nl as TooltipManager,ws as UK_UA,$o as UNIT_SYSTEMS,za as VERSION,sl as VIEW_CLS,Po as ValuePipeline,ml as VariantRegistry,ol as ViewPicker,Bs as WINDOW_KINDS,$s as Window,Za as alignGrids,qs as anomalyCondition,pa as applyResidual,Zo as auditCatalogue,qa as autoGroupMenuItems,to as autoInit,Va as branchFor,jo as buildGraph,ga as capabilitiesOf,Wa as cellMenuItems,hl as checkVariant,Ka as columnMenuItems,Rs as compact,Co as compileFormat,Eo as compileMask,na as compileRules,dl as compileTemplate,fl as compileVariant,ka as conditionToOData,Go as convertMoney,cl as createCellLayer,Uo as createCurrencyType,vl as createEditor,jl as createFilter,_i as createGrid,io as createHeadlessGrid,no as createLocalViewStorage,sa as createMemorySource,_o as createMessages,aa as createPagedSource,fa as createPushdownSource,No as createRadixType,la as createRemoteSource,Ma as createRowKey,oa as createSource,Yi as createStat,ua as createStreamSource,xo as createUnitType,ca as createUrlSource,$l as default,oo as defaults,Do as defineUnit,Xi as deltaOf,ja as dfqlAdapter,Aa as duckdbAdapter,kl as editorFor,wl as editors,Ns as evaluateFilters,Ys as evaluateFormula,Al as filterFor,Ol as filters,va as filtersToOData,Pa as filtersToSql,Zs as forecast,Jo as formatList,Vo as formatMoney,Fo as formatRadix,Bo as formatUnit,ao as getVersion,Ca as graphqlAdapter,Zi as gridElementsWithin,Fs as groupByColumns,eo as hydrateTable,ra as ingest,ia as ingestSync,Vs as iqrFences,vo as isLocalHost,Ya as layoutState,go as licenceInfo,wo as licenceState,Il as licenseInfo,Dl as licenseState,Js as looksLikeFormula,Gs as mahalanobis,ko as matchesDomain,Ha as mergeColumnFilter,Hs as modifiedZScores,Ja as mountPanel,wa as odataAdapter,zs as openWindow,Qa as panelHost,Pl as parseExpression,Xs as parseFormula,mo as parseLicence,Ho as parseMoney,Lo as parseRadix,zo as parseUnit,Ds as pivot,ha as planQuery,Ko as rateFunction,Ji as readTable,Qs as referencesOf,ho as registerModules,Io as registerUnitSystem,ns as resolveCatalogue,es as resolveLocale,ya as resolveMutate,Sa as restAdapter,$a as restoreState,Ws as rollingAnomalies,bl as sanitiseHtml,Da as serialiseState,bo as setLicence,xl as setLicense,fo as sharedRegistry,Ts as sortColumn,Ms as sortMulti,To as specToOoxml,ma as splitFilters,Ea as splunkAdapter,al as summariseDiff,Ls as testValue,Qi as toneOf,xs as total,po as verifyLicence,so as version,yo as watermark};
56
+ `)||(a.preventDefault(),this.fromText(p))})))}openFile(){const l=S(this.#n,"input",{attrs:{type:"file",accept:s}});l.style.display="none",this.#o.push(d(l,"change",()=>{const a=l.files&&l.files[0];a&&this.#c(a),l.parentNode&&l.parentNode.removeChild(l)})),this.#n.body.appendChild(l),l.click()}#c(l){if(M(l.arrayBuffer)){l.arrayBuffer().then(p=>{const m=new Uint8Array(p);if(I(m)){this.fromXlsx(m,l.name);return}this.fromText(new TextDecoder().decode(m),l.name)});return}if(M(l.text)){l.text().then(p=>this.fromText(p,l.name));return}const a=new this.#n.defaultView.FileReader;a.onload=()=>this.fromText(String(a.result||""),l.name),a.readAsText(l)}async fromXlsx(l,a){const{header:p,rows:m}=await D(l);if(!p.length)return;const b=V(p,m,{columns:this.#e.columns.all()}),g=m.filter(f=>f.length!==p.length).length;this.#l={rows:m,columns:b,delimiter:null,name:a,warnings:g?[`${g} row(s) do not have ${p.length} columns`]:[]},this.#d()}fromText(l,a){const{header:p,rows:m,delimiter:b}=Z(l);if(!p.length)return;const g=V(p,m,{columns:this.#e.columns.all()}),f=m.filter(w=>w.length!==p.length).length;this.#l={rows:m,columns:g,delimiter:b,name:a,warnings:f?[`${f} row(s) do not have ${p.length} columns`]:[]},this.#d()}#d(){this.#i||this.#m(),this.#p(),this.#a=this.#n.activeElement,this.#i.hidden=!1;const l=this.#i.querySelector(i);l&&M(l.focus)&&l.focus(),this.#h(this.#f("import.opened",{count:this.#l.rows.length}),{repeat:!0})}#h(l,a){const p=this.#t&&this.#t.announce;M(p)&&p.call(this.#t,l,a)}#f(l,a){return(this.#e&&this.#e.messages?this.#e.messages:R).t(l,a)}#m(){const l=this.#n,a=S(l,"div",{class:t,attrs:{role:"dialog","aria-modal":"true","aria-label":this.#f("import.title"),hidden:!0}}),p=S(l,"div",{class:`${t}__panel`});p.appendChild(S(l,"h2",{class:`${t}__title`,text:this.#f("import.title")})),this.#s=S(l,"div",{class:`${t}__body`}),p.appendChild(this.#s);const m=S(l,"div",{class:`${t}__footer`}),b=S(l,"button",{class:`${t}__cancel`,text:this.#f("import.cancel"),attrs:{type:"button"}}),g=S(l,"button",{class:`${t}__confirm`,text:this.#f("import.confirm"),attrs:{type:"button"}});this.#o.push(d(b,"click",()=>this.close())),this.#o.push(d(g,"click",()=>this.#g())),m.appendChild(b),m.appendChild(g),p.appendChild(m),a.appendChild(p),this.#o.push(d(a,"keydown",w=>{if(w.key==="Escape"){w.preventDefault(),this.close();return}if(w.key!=="Tab")return;const v=[...a.querySelectorAll(i)].filter(j=>!j.hidden);if(!v.length)return;const h=v[0],c=v[v.length-1];w.shiftKey&&this.#n.activeElement===h?(w.preventDefault(),c.focus()):!w.shiftKey&&this.#n.activeElement===c&&(w.preventDefault(),h.focus())})),(this.#t.viewport&&this.#t.viewport.overlays||this.#n.body).appendChild(a),this.#i=a}#p(){const l=this.#n,a=y(this.#s),{rows:p,columns:m,name:b,warnings:g}=this.#l;a.appendChild(S(l,"p",{class:`${t}__summary`,text:this.#f("import.summary",{count:p.length,name:b||this.#f("import.clipboard")})}));for(const j of g)a.appendChild(S(l,"p",{class:`${t}__warning`,text:j}));const f=this.#e.columns.all().map(j=>j.field||j.id).filter(Boolean),w=S(l,"table",{class:`${t}__map`}),v=S(l,"tr",{});for(const j of["import.colSource","import.colField","import.colType"])v.appendChild(S(l,"th",{text:this.#f(j)}));w.appendChild(v),m.forEach((j,E)=>{const O=S(l,"tr",{});O.appendChild(S(l,"td",{text:j.source}));const T=S(l,"select",{attrs:{"data-col":String(E),"aria-label":this.#f("import.mapLabel",{source:j.source})}});T.appendChild(S(l,"option",{text:this.#f("import.skip"),attrs:{value:""}}));for(const P of f)T.appendChild(S(l,"option",{text:P,attrs:{value:P,selected:P===j.field?!0:null}}));j.field&&!f.includes(j.field)&&T.appendChild(S(l,"option",{text:j.field,attrs:{value:j.field,selected:!0}}));const A=S(l,"td",{});A.appendChild(T),O.appendChild(A),O.appendChild(S(l,"td",{class:`${t}__type`,text:j.type})),w.appendChild(O)}),a.appendChild(w);const h=S(l,"div",{class:`${t}__mode`}),c=S(l,"select",{attrs:{"aria-label":this.#f("import.modeLabel"),"data-mode":"mode"}});c.appendChild(S(l,"option",{text:this.#f("import.append"),attrs:{value:"append",selected:this.#r.mode==="append"?!0:null}})),c.appendChild(S(l,"option",{text:this.#f("import.replace"),attrs:{value:"replace",selected:this.#r.mode==="replace"?!0:null}})),h.appendChild(S(l,"label",{text:this.#f("import.modeLabel")})),h.appendChild(c),a.appendChild(h)}#g(){const{rows:l,columns:a}=this.#l;for(const f of this.#i.querySelectorAll("select[data-col]")){const w=Number(f.getAttribute("data-col"));a[w]&&f.value!==void 0&&f.value!==null&&(a[w].field=f.value)}const p=this.#i.querySelector("select[data-mode]"),m=p?p.value:void 0,b=m==="replace"||m==="append"?m:this.#r.mode,g=U(l,a);this.#e.import.apply(g,{mode:b}),this.close(),this.#h(this.#f("import.done",{count:g.length}),{repeat:!0})}close(){this.#i&&(this.#i.hidden=!0),this.#l=null,this.#a&&M(this.#a.focus)&&this.#a.focus(),this.#a=null}destroy(){for(const l of this.#o)l();this.#o=[],this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null,this.#s=null,this.#l=null}}}),Ce("packages/dom/src/historybar.js",function(e,G){"use strict";Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return S}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.on,U=W.clear,D=W.documentFor,I="lat-history";class k{doc=null;host={};root=null;undoButton=null;redoButton=null;menu=null;open=!1;off=[];t(d,u){return(this.messages&&typeof this.messages.t=="function"?this.messages:R).t(d,u)}init(d){this.messages=d&&d.messages||d&&d.grid&&d.grid.messages||R;const u=d||{};if(this.doc=D(u),this.host=u.host||{},this.props=u.props||{},this.root=Z(this.doc,"div",{class:["lattice-tokens",I],attrs:{role:"group","aria-label":this.t("history.title")}}),this.undoButton=this.#e("undo","Undo","↶"),this.redoButton=this.#e("redo","Redo","↷"),this.root.appendChild(this.undoButton),this.root.appendChild(this.redoButton),this.props.timeline!==!1){const n=Z(this.doc,"button",{class:`${I}__toggle`,text:"▾",attrs:{type:"button","aria-haspopup":"menu","aria-expanded":"false","aria-label":this.t("history.show")}});this.off.push(V(n,"click",()=>this.toggle())),this.root.appendChild(n),this.toggleButton=n,this.menu=Z(this.doc,"div",{class:`${I}__menu`,attrs:{role:"menu"}}),this.menu.style.display="none",this.root.appendChild(this.menu)}this.refresh()}#e(d,u,n){const t=Z(this.doc,"button",{class:`${I}__${d}`,attrs:{type:"button"},children:[Z(this.doc,"span",{class:`${I}__glyph`,text:n,attrs:{"aria-hidden":"true"}}),Z(this.doc,"span",{class:`${I}__label`,text:u})]});return this.off.push(V(t,"click",()=>{const i=this.host[d];M(i)&&i(),this.refresh()})),t}element(){return this.root}refresh(){if(!this.root)return;const d=this.host,u=M(d.canUndo)?d.canUndo():!1,n=M(d.canRedo)?d.canRedo():!1,t=M(d.peek)?d.peek("undo"):null,i=M(d.peek)?d.peek("redo"):null;this.#t(this.undoButton,"undo",u,t),this.#t(this.redoButton,"redo",n,i),this.open&&this.#n()}#t(d,u,n,t){if(!d)return;d.disabled=!n;const i=u==="undo",s=this.t(i?"history.undo":"history.redo"),r=d.querySelector(`.${I}__label`);r&&(r.textContent=s);const o=t&&t.label?this.t("history.described",{action:s,label:t.label}):s;d.setAttribute("title",n?o:this.t(i?"history.nothingToUndo":"history.nothingToRedo")),d.setAttribute("aria-label",n?o:this.t(i?"history.undoDisabled":"history.redoDisabled"))}toggle(){this.menu&&(this.open=!this.open,this.menu.style.display=this.open?"":"none",this.toggleButton&&this.toggleButton.setAttribute("aria-expanded",this.open?"true":"false"),this.open&&this.#n())}#n(){const d=this.menu;if(!d)return;U(d);const u=M(this.host.list)?this.host.list():[];if(!u.length){d.appendChild(Z(this.doc,"p",{class:`${I}__empty`,text:this.t("history.empty")}));return}u.forEach((n,t)=>{const i=Z(this.doc,"button",{class:`${I}__item`,attrs:{type:"button",role:"menuitem","data-type":n.type,"data-undone":n.undone?"true":null},children:[Z(this.doc,"span",{class:`${I}__kind`,text:n.type}),Z(this.doc,"span",{class:`${I}__text`,text:n.label||n.type})]});this.off.push(V(i,"click",()=>{const s=t+1;for(let r=0;r<s;r++)M(this.host.undo)&&this.host.undo();this.toggle(),this.refresh()})),d.appendChild(i)})}destroy(){for(const d of this.off)d();this.off=[],this.root&&M(this.root.remove)&&this.root.remove(),this.root=null,this.menu=null,this.undoButton=null,this.redoButton=null}}const S=k}),Ce("packages/dom/src/diffpaint.js",function(e,G){"use strict";Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"diffConfigured",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/core/src/i18n/index.js").defaultMessages,Z={changed:"lat-row--changed",added:"lat-row--added",removed:"lat-row--removed"},V="lat-cell--changed",U="lat-cell--added-column";class D{#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,u=d&&d.enabled;for(const n of y.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key"),i=u?d.statusOf(t):"unchanged";for(const r of Object.values(Z))n.classList.remove(r);u&&Z[i]&&n.classList.add(Z[i]),n.setAttribute("data-diff",u?i:"");const s=u&&i==="changed";for(const r of n.querySelectorAll("[data-col]")){const o=r.getAttribute("data-col");if(r.classList.remove(V,U),r.removeAttribute("data-before"),!s)continue;const l=d.cellStatus(t,o);if(l==="changed"){r.classList.add(V);const a=this.#r(d,t,o);a===null?r.removeAttribute("title"):(r.setAttribute("data-before",a),r.setAttribute("title",this.#o("diff.before",{value:a})))}else l==="added-column"&&r.classList.add(U)}}}#r(y,d,u){const n=this.#e,t=n&&n.columns,i=t&&M(t.get)?t.get(u):null,s=n&&n.permissions;if(i&&s&&M(s.isSecret)&&s.isSecret(i))return null;const r=y.before(d,u);if(r==null)return this.#o("diff.empty");if(!i||!M(i.formatValue))return String(r);const o=M(y.beforeRow)?y.beforeRow(d):void 0,a={...(n.rows&&M(n.rows.byKey)?n.rows.byKey(d):null)||{},data:o===void 0?{}:o};try{const p=i.formatValue(r,a,a.data);return p==null?"":String(p)}catch(p){return $(`diff-before-format:${u}`,`the formatter for column "${u}" threw while formatting a previous value, so the diff hover shows the raw one.`,p),String(r)}}#o(y,d){const u=this.#e;return(u&&u.messages?u.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 u of Object.values(Z))d.classList.remove(u);d.removeAttribute("data-diff")}for(const d of y.querySelectorAll("[data-col]"))d.classList.remove(V,U),d.removeAttribute("data-before")}}}function I(S){return!!(S&&S.diff&&(M(S.diff)||typeof S.diff=="object"))}const k=D}),Ce("packages/dom/src/highlightpaint.js",function(e,G){"use strict";Object.defineProperty(e,"HighlightPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="lat-cell--highlight",R="--lattice-cell-highlight";class W{#e;#t;#n=[];#r=null;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("highlight:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#o)return;this.#o=!0;const U=()=>{this.#o=!1,this.paint()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):M(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const D=this.#l();if(D){D.sweep();for(const I of U.querySelectorAll("[data-key]")){const k=I.getAttribute("data-key");for(const S of I.querySelectorAll("[data-col]")){const y=D.active?D.colourFor(k,S.getAttribute("data-col")):null;y?(S.classList.add($),S.style.setProperty(R,y)):S.classList.contains($)&&(S.classList.remove($),S.style.removeProperty(R))}}this.#s(D)}}#s(U){this.#r!==null&&M(this.#i.clearTimeout)&&(this.#i.clearTimeout(this.#r),this.#r=null);const D=U.nextExpiry;if(!Number.isFinite(D)||!M(this.#i.setTimeout))return;const I=Math.max(0,D-Date.now());this.#r=this.#i.setTimeout(()=>{this.#r=null,this.schedule()},I)}#l(){const U=this.#e.highlight;return U&&M(U.model)?U.model():null}destroy(){this.#r!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#r),this.#r=null;for(const D of this.#n)D();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll))for(const D of U.querySelectorAll(`.${$}`))D.classList.remove($),D.style.removeProperty(R)}}const Z=W}),Ce("packages/dom/src/findpaint.js",function(e,G){"use strict";Object.defineProperty(e,"MATCH_CLASS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"CURRENT_CLASS",{enumerable:!0,get:function(){return R}}),Object.defineProperty(e,"FindPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isFunction,$="lat-cell--find",R="lat-cell--find-current";class W{#e;#t;#n=[];#r=!1;#o=!1;#i;constructor(U){this.#e=U.grid,this.#t=U.renderer,this.#i=U.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("find:changed",()=>this.schedule())),this.paint()}schedule(){if(this.#r)return;this.#r=!0;const U=()=>{this.#r=!1,this.paint()};M(this.#i.requestAnimationFrame)?this.#i.requestAnimationFrame(U):M(this.#i.setTimeout)?this.#i.setTimeout(U,0):U()}paint(){const U=this.#t.viewport?.root;if(!U||!U.querySelectorAll)return;const D=this.#e.find;if(!D||!M(D.stateFor))return;const I=M(D.model)?D.model():null,k=!!I&&I.active;if(!k&&!this.#o)return;let S=!1;for(const y of U.querySelectorAll("[data-key]")){const d=y.getAttribute("data-key");for(const u of y.querySelectorAll("[data-col]")){const n=k?D.stateFor(d,u.getAttribute("data-col")):null;n?(S=!0,u.classList.add($),u.classList.toggle(R,n==="current")):u.classList.contains($)&&u.classList.remove($,R)}}this.#o=S}destroy(){for(const D of this.#n)D();this.#n=[];const U=this.#t.viewport?.root;if(!(!U||!U.querySelectorAll)){for(const D of U.querySelectorAll(`.${$}`))D.classList.remove($,R);this.#o=!1}}}const Z=W}),Ce("packages/dom/src/findbar.js",function(e,G){"use strict";Object.defineProperty(e,"FIND_CLASS",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"FindBar",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=G("packages/dom/src/editors/common.js"),M=_.el,$=_.on,W=G("packages/dom/src/renderer/textentry.js").isTextEntry,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction,I="lat-find",k=12,S=120;class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=!1;#m=!1;#p=null;#g=[];#w=null;#b=null;#v=!1;constructor(n){this.#e=n.grid,this.#t=n.renderer,this.#n=n.document||n.renderer.viewport?.document,this.#r=this.#n&&this.#n.defaultView||(typeof globalThis>"u"?{}:globalThis),this.#o=n.settings&&typeof n.settings=="object"?n.settings:{}}get open(){return!!this.#i&&this.#i.style.display!=="none"}get element(){return this.#i}t(n,t){const i=this.#e;return(i&&i.messages&&D(i.messages.t)?i.messages:V).t(n,t)}mount(){const n=this.#S();if(!n)return;n.attachUi({open:i=>this.show(i),close:()=>this.hide(),focus:()=>{this.#s&&this.#s.focus()}}),n.attachDriver({run:()=>this.#T()});const t=this.#t.viewport?.root;if(t&&D(t.addEventListener)&&this.#o.shortcut!==!1){const i=s=>{if(!(s.ctrlKey||s.metaKey)||s.altKey||s.shiftKey||s.key!=="f"&&s.key!=="F")return;const r=s.target;if(this.#s&&r===this.#s){s.preventDefault(),s.stopPropagation(),D(this.#s.select)&&this.#s.select();return}W(r)||(s.preventDefault(),s.stopPropagation(),this.show())};t.addEventListener("keydown",i,!0),this.#g.push(()=>t.removeEventListener("keydown",i,!0))}this.#g.push(this.#e.on("find:changed",()=>this.#N())),this.#g.push(this.#e.on("columns:changed",()=>this.#j())),this.#g.push(this.#e.on("column:visible",()=>this.#j()))}show(n){const t=this.#A();if(!t)return;const i=t.style.display!=="none";t.style.display="",i||this.#y(),this.#S().setOpen(!0),n!=null&&(this.#s.value=String(n),this.#E()),this.#s.focus(),D(this.#s.select)&&this.#s.select(),this.#N()}hide(){this.#x();const n=this.#S();this.#i&&this.#i.style.display!=="none"&&(this.#i.style.display="none",this.#y()),n&&(n.clear(),n.setOpen(!1));const t=this.#t.viewport?.root;if(!t||!(this.#i&&this.#n&&this.#n.activeElement&&D(this.#i.contains)&&this.#i.contains(this.#n.activeElement)))return;const r=(D(t.querySelector)?t.querySelector('[tabindex="0"]'):null)||t;D(r.focus)&&r.focus()}search(){this.#E()}destroy(){this.#v=!0,this.#x();for(const t of this.#g)t();this.#g=[];const n=this.#S();n&&(n.attachUi(null),n.attachDriver(null)),this.#i&&this.#i.parentNode&&this.#i.parentNode.removeChild(this.#i),this.#i=null}#y(){const n=this.#t;n&&D(n.invalidate)&&n.invalidate("size")}#S(){const n=this.#e&&this.#e.find;return n&&D(n.model)?n.model():null}#A(){if(this.#i)return this.#i;const n=this.#t.viewport,t=n?.root,i=this.#n;if(!t||!i||!D(t.insertBefore))return null;const s=M(i,"div",{class:I,attrs:{role:"search","aria-label":this.t("find.label")}});this.#s=M(i,"input",{class:`${I}__input`,attrs:{type:"text","aria-label":this.t("find.label"),placeholder:this.t("find.placeholder"),autocomplete:"off",spellcheck:"false"}}),this.#l=M(i,"span",{class:`${I}__count`,attrs:{"aria-hidden":"true"}}),this.#a=M(i,"span",{class:`${I}__scope`,attrs:{"aria-hidden":"true"}}),this.#a.style.display="none",this.#u=M(i,"span",{class:`${I}__status`,attrs:{role:"status","aria-live":"polite","aria-atomic":"true"}});const r=M(i,"button",{class:`${I}__nav ${I}__prev`,text:"‹",attrs:{type:"button","aria-label":this.t("find.previous"),title:this.t("find.previous")}}),o=M(i,"button",{class:`${I}__nav ${I}__next`,text:"›",attrs:{type:"button","aria-label":this.t("find.next"),title:this.t("find.next")}});this.#c=M(i,"button",{class:`${I}__toggle ${I}__case`,text:this.t("find.matchCase"),attrs:{type:"button","aria-pressed":"false"}}),this.#d=M(i,"button",{class:`${I}__toggle ${I}__whole`,text:this.t("find.wholeCell"),attrs:{type:"button","aria-pressed":"false"}}),this.#h=M(i,"select",{class:`${I}__columns`,attrs:{"aria-label":this.t("find.columnScope"),title:this.t("find.columnScope")}});const l=M(i,"button",{class:`${I}__close`,text:"×",attrs:{type:"button","aria-label":this.t("find.close"),title:this.t("find.close")}}),a=M(i,"div",{class:`${I}__options`,children:[this.#c,this.#d,this.#h]});for(const m of[this.#s,this.#l,this.#a,this.#u,r,o,l,a])s.appendChild(m);this.#g.push($(this.#s,"input",()=>this.#O())),this.#g.push($(r,"click",()=>this.#e.find.prev())),this.#g.push($(o,"click",()=>this.#e.find.next())),this.#g.push($(this.#c,"click",()=>{this.#f=!this.#f,this.#c.setAttribute("aria-pressed",String(this.#f)),this.#E()})),this.#g.push($(this.#d,"click",()=>{this.#m=!this.#m,this.#d.setAttribute("aria-pressed",String(this.#m)),this.#E()})),this.#g.push($(this.#h,"change",()=>{const m=this.#h.value;this.#p=m?String(m):null,this.#E()})),this.#g.push($(l,"click",()=>this.hide()));const p=m=>{if(m.key==="Escape"){m.preventDefault(),m.stopPropagation(),this.hide();return}m.key==="Enter"&&m.target===this.#s&&(m.preventDefault(),m.stopPropagation(),this.#w!==null&&(this.#I(),this.#E()),m.shiftKey?this.#e.find.prev():this.#e.find.next())};return s.addEventListener("keydown",p),this.#g.push(()=>s.removeEventListener("keydown",p)),s.style.display="none",t.insertBefore(s,n.header||t.firstChild),this.#i=s,this.#j(),s}#j(){const n=this.#h;if(!n)return;const t=this.#n;for(;n.firstChild;)n.removeChild(n.firstChild);n.appendChild(M(t,"option",{text:this.t("find.allColumns"),attrs:{value:""}}));const i=this.#e.columns,s=i&&D(i.visible)?i.visible():[];let r=!1;for(const o of s){if(!o||o.id===void 0)continue;const l=String(o.id);n.appendChild(M(t,"option",{text:o.title||l,attrs:{value:l}})),l===this.#p&&(r=!0)}r||(this.#p=null),n.value=this.#p||""}#O(){const n=Number.isFinite(this.#o.debounce)?Math.max(0,this.#o.debounce):S;if(this.#I(),n===0||!D(this.#r.setTimeout)){this.#E();return}this.#w=this.#r.setTimeout(()=>{this.#w=null,this.#E()},n)}#E(){const n=this.#S();if(!n||this.#v)return;const t=this.#s?this.#s.value:"";if(!t){this.#M(),n.clear();return}n.begin(t,{caseSensitive:this.#f,wholeCell:this.#m,columns:this.#p?[this.#p]:null,from:this.#C()}),this.#T()}#C(){const n=this.#t&&this.#t.window,t=n&&Number.isFinite(n.first)?n.first:0;return Math.max(0,t)}#T(){if(this.#b!==null||this.#v)return;const n=()=>{this.#b=null,this.#D()};D(this.#r.requestAnimationFrame)?this.#b=this.#r.requestAnimationFrame(n):D(this.#r.setTimeout)?this.#b=this.#r.setTimeout(n,0):n()}#D(){const n=this.#S();!n||this.#v||!n.active||(n.stale&&n.rescan({from:this.#C()}),!n.complete&&(n.step(k)||this.#T()))}#N(){if(!this.#i||this.#v)return;const n=this.#e.find.count(),t=this.#S().active;let i="",s="idle";t&&(n.total===0?(i=n.complete?this.t("find.none"):this.t("find.searching"),s=n.complete?"none":"searching"):(i=this.t(n.complete?"find.count":"find.countPartial",{current:n.current,total:n.total}),s=n.complete?"matches":"searching")),this.#l.textContent=i,this.#i.setAttribute("data-state",s);const r=t&&n.windowed;this.#a.textContent=r?this.t("find.loadedRows"):"",this.#a.style.display=r?"":"none",t?n.complete&&(this.#u.textContent=n.total===0?this.t(r?"a11y.find.noneLoaded":"a11y.find.none"):this.t(r?"a11y.find.countLoaded":"a11y.find.count",{current:n.current,count:n.total})):this.#u.textContent=""}#I(){this.#w!==null&&D(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#w),this.#w=null}#M(){this.#b!==null&&(D(this.#r.cancelAnimationFrame)?this.#r.cancelAnimationFrame(this.#b):D(this.#r.clearTimeout)&&this.#r.clearTimeout(this.#b),this.#b=null)}#x(){this.#I(),this.#M()}}const d=y}),Ce("packages/dom/src/redactpaint.js",function(e,G){"use strict";Object.defineProperty(e,"RedactionPainter",{enumerable:!0,get:function(){return $}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return R}});const _="lat-cell--redacted",M="lat-cell";class ${#e;#t;#n=[];constructor(Z){this.#e=Z.grid,this.#t=Z.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.paint()}paint(){const Z=this.#t.viewport?.root;if(!Z||!Z.querySelectorAll)return;const V=this.#e.redaction;if(!V)return;const U=V.active;for(const D of Z.querySelectorAll(`.${M}[data-col]`))U&&V.has(D.getAttribute("data-col"))?D.classList.add(_):D.classList.contains(_)&&D.classList.remove(_)}destroy(){for(const Z of this.#n)Z();this.#n=[]}}const R=$}),Ce("packages/dom/src/validationpaint.js",function(e,G){"use strict";Object.defineProperty(e,"ValidationPainter",{enumerable:!0,get:function(){return W}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return Z}});const M=G("packages/dom/src/editors/common.js").markInvalid,$="lat-cell";function R(V,U){let D=V;for(;D;){if(U(D))return D;D=D.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 D=R(U,I=>I.getAttribute&&I.getAttribute("data-key")!==null);return D?D.getAttribute("data-key"):null}paint(){const U=this.#e.validation;if(!U||!U.active)return;const D=this.#t.viewport?.root;if(!(!D||!D.querySelectorAll))for(const I of D.querySelectorAll(`.${$}[data-col]`)){const k=I.getAttribute("data-col"),S=this.#r(I),y=S?U.errorFor(S,k):null;M(I,y?y.message:null)}}destroy(){for(const U of this.#n)U();this.#n=[]}}const Z=W}),Ce("packages/dom/src/presentation.js",function(e,G){"use strict";Object.defineProperty(e,"CHROME",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PresentationController",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/dom/src/renderer/textentry.js").isTextEntry,Z=G("packages/dom/src/renderer/viewport.js").CLASS,V="lat-presenting",U="lat-presenting--changing",D="lat-presenting__progress",I="lat-cell--dimmed",k=Object.freeze(["toolPanel","statusBar","editBar","historyBar","pagination"]);class S{#e;#t;#n;#r=[];#o=null;#i=null;#s=null;constructor(u){this.#e=u.grid,this.#t=u.renderer,this.#n=u.maximiser||null}mount(){this.#r.push(this.#e.on("presentation:started",()=>this.#d())),this.#r.push(this.#e.on("presentation:changed",()=>this.#f())),this.#r.push(this.#e.on("presentation:scale",()=>this.#f())),this.#r.push(this.#e.on("presentation:ended",()=>this.#h())),this.#r.push(this.#e.on("presentation:view",n=>this.#a(n))),this.#r.push(this.#e.on("presentation:spotlight",()=>this.#m())),this.#r.push(this.#e.on("render:done",()=>this.#m())),this.#n&&M(this.#n.watch)&&this.#r.push(this.#n.watch(n=>{n||!this.#o||this.#o.maximised||this.#e.presentation?.active&&this.#e.presentation.stop()}));const u=this.#t.viewport?.root;if(u&&M(u.addEventListener)){const n=t=>this.#l(t);u.addEventListener("keydown",n),this.#r.push(()=>u.removeEventListener("keydown",n))}}#l(u){const n=this.#e.presentation;if(!n?.active)return;const t=u.ctrlKey||u.metaKey,i=u.key;if(i==="Escape"&&!this.#n){u.defaultPrevented||(n.stop(),u.preventDefault?.());return}if(t){i==="="||i==="+"?(n.nudge(1),u.preventDefault?.()):i==="-"||i==="_"?(n.nudge(-1),u.preventDefault?.()):i==="0"&&(n.setScale(1.5),u.preventDefault?.());return}if(!n.views.length||R(u.target))return;i==="ArrowRight"||i==="ArrowDown"||i==="PageDown"||i===" "?(n.step(1),u.preventDefault?.()):i==="ArrowLeft"||i==="ArrowUp"||i==="PageUp"?(n.step(-1),u.preventDefault?.()):i==="Home"?(n.goTo(0),u.preventDefault?.()):i==="End"?(n.goTo(n.views.length-1),u.preventDefault?.()):(i==="r"||i==="R")&&(n.reset(),u.preventDefault?.())}#a(u){!u||!u.viewId||(this.#u(),this.#e.views?.apply?.(u.viewId),this.#c(u))}#u(){const u=this.#t.viewport?.root;u?.classList&&(u.classList.remove(U),u.offsetWidth,u.classList.add(U))}#c(u){const n=this.#t.viewport?.overlays;if(!n||!this.#e.presentation.views.length)return;const t=n.ownerDocument;if(!t?.createElement)return;if(!this.#i){const r=t.createElement("div");r.className=D,r.setAttribute("role","status"),r.setAttribute("aria-live","polite"),n.appendChild(r),this.#i=r}const i=this.#e.views?.get?.(u.viewId),s=i&&i.name?i.name:"";this.#i.textContent=s?`${s} · ${(u.index||0)+1} / ${u.count||0}`:`${(u.index||0)+1} / ${u.count||0}`}#d(){if(this.#o){this.#f();return}const u=!!(this.#n&&this.#n.active());this.#n&&!u&&this.#n.enter();const n=new Set(this.#e.presentation?.options?.chrome||[]),t=[];for(const s of k){if(n.has(s)||s==="toolPanel"&&this.#v())continue;const r=this.#y(s);r&&r.style&&r.style.display!=="none"&&(r.style.display="none",t.push(r))}const i=this.#w();i&&i.style&&i.style.display!=="none"&&this.#b(i)&&(i.style.display="none",t.push(i)),this.#o={maximised:u,hidden:t},this.#t.viewport?.root?.classList?.add(V),this.#f(),this.#p()}#h(){const u=this.#o;this.#o=null;const n=this.#t.viewport?.root;if(n?.classList?.remove(V),n?.style?.removeProperty("--lattice-presentation-scale"),this.#g(),this.#i&&(this.#i.remove?.(),this.#i=null),n?.classList?.remove(U),this.#m(),u){const t=this.#e.toolPanel;t&&M(t.presentRestore)&&t.presentRestore();for(const i of u.hidden)i.style.display="";this.#n&&!u.maximised&&this.#n.active()&&this.#n.exit()}this.#t.invalidate?.("theme")}#f(){const u=this.#t.viewport?.root;!u||!u.style||(u.style.setProperty("--lattice-presentation-scale",String(this.#e.presentation.scale)),this.#t.invalidate?.("theme"))}#m(){const u=this.#t.viewport?.root;if(!u?.querySelectorAll)return;const n=this.#e.presentation?.active?this.#e.presentation.spotlight:null,t=n&&n.keys.length?new Set(n.keys):null,i=n&&n.colIds.length?new Set(n.colIds):null;for(const s of u.querySelectorAll("[data-key]")){const r=!t||t.has(s.getAttribute("data-key"));for(const o of s.querySelectorAll("[data-col]"))!n||r&&(!i||i.has(o.getAttribute("data-col")))?o.classList.remove(I):o.classList.add(I)}}#p(){this.#g();const u=Number(this.#e.presentation?.options?.autoAdvance);if(!Number.isFinite(u)||u<=0||!this.#e.presentation.views.length)return;const n=this.#t.viewport?.root?.ownerDocument?.defaultView;n?.setInterval&&(this.#s=n.setInterval(()=>{const t=this.#e.presentation;t.active&&t.goTo(t.index>=t.views.length-1?0:t.index+1)},Math.max(1e3,u)))}#g(){if(this.#s===null)return;this.#t.viewport?.root?.ownerDocument?.defaultView?.clearInterval?.(this.#s),this.#s=null}#w(){const u=this.#e.element;return!u||!M(u.querySelector)?null:u.querySelector(`.${Z.statusBar}`)}#b(u){const n=u.children||[];for(const t of n)if(!t.style||t.style.display!=="none")return!1;return!0}#v(){const u=this.#e.toolPanel;return!!(u&&M(u.presentOnly)&&u.presentOnly())}#y(u){const n=this.#e.element;if(!n||!M(n.querySelector))return null;const t={toolPanel:".lat-panel-dock",statusBar:".lat-statusbar",editBar:".lat-editor-bar",historyBar:".lat-history",pagination:".lat-pagination"}[u];return t?n.querySelector(t):null}destroy(){this.#o&&this.#h();for(const u of this.#r)u();this.#r=[]}}const y=S}),Ce("packages/dom/src/capture.js",function(e,G){"use strict";Object.defineProperty(e,"isSafeImageSource",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"captureElement",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return U}});const M=G("packages/core/src/internal/util.js").isFunction,$=new Set(["cursor","pointer-events","user-select","-webkit-user-select","transition","animation"]);function R(D,I,k){const S=k.getComputedStyle(D),y=I.style;if(y)for(let d=0;d<S.length;d++){const u=S[d];$.has(u)||y.setProperty(u,S.getPropertyValue(u),S.getPropertyPriority(u))}}function W(D,I,k){if(R(D,I,k),D.tagName==="CANVAS"&&M(D.toDataURL))try{const d=D.toDataURL("image/png"),u=I.style;u&&(u.setProperty("background-image",`url(${d})`),u.setProperty("background-size","100% 100%"),u.setProperty("background-repeat","no-repeat"))}catch{}const S=D.children||[],y=I.children||[];for(let d=0;d<S.length&&d<y.length;d++)W(S[d],y[d],k)}function Z(D,I){if(!D||D.startsWith("data:")||D.startsWith("blob:"))return!0;try{return new URL(D,I).origin===I}catch{return!0}}async function V(D,I={}){const k=D.ownerDocument,S=k?.defaultView;if(!S||typeof S.getComputedStyle!="function")throw new Error("capture needs a browser document");const y=D.getBoundingClientRect(),d=Math.max(1,Math.ceil(y.width)),u=Math.max(1,Math.ceil(y.height)),n=Math.max(.1,Number(I.scale)||2),t=S.location?.origin||"";for(const p of D.querySelectorAll("img")){const m=p.getAttribute("src")||"";if(!Z(m,t))throw new Error(`capture refused: the image at ${m} is on another origin and would taint the canvas. Serve it same-origin, inline it as a data: URL, or hide the column.`)}const i=D.cloneNode(!0);W(D,i,S),i.style.width=`${d}px`,i.style.height=`${u}px`,i.style.margin="0";const s=new S.XMLSerializer().serializeToString(i),r=`<svg xmlns="http://www.w3.org/2000/svg" width="${d}" height="${u}"><foreignObject width="100%" height="100%"><div xmlns="http://www.w3.org/1999/xhtml">${s}</div></foreignObject></svg>`,o=new S.Image;await new Promise((p,m)=>{o.onload=()=>p(void 0),o.onerror=()=>m(new Error("capture failed to rasterise the grid; a host element inside it may not serialise as XML")),o.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`});const l=k.createElement("canvas");l.width=Math.round(d*n),l.height=Math.round(u*n);const a=l.getContext("2d");if(!a)throw new Error("capture could not get a 2d context");return a.fillStyle=I.background||S.getComputedStyle(D).backgroundColor||"#ffffff",a.fillRect(0,0,l.width,l.height),a.drawImage(o,0,0,l.width,l.height),new Promise((p,m)=>{l.toBlob(b=>b?p({blob:b,width:l.width,height:l.height}):m(new Error("capture produced no image")),I.type||"image/png",I.quality)})}const U=V}),Ce("packages/dom/src/annotate.js",function(e,G){"use strict";Object.defineProperty(e,"TOOLS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"MARK_TYPES",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"AnnotationLayer",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return s}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/dom/src/renderer/direction.js").signedX,Z=Object.freeze(["pen","arrow","rect","highlight"]),V=Object.freeze(["freehand","arrow","rect","highlight","text"]),U=Object.freeze({freehand:"pen",pen:"pen",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),D=Object.freeze({pen:"freehand",arrow:"arrow",rect:"rect",highlight:"highlight",text:"text"}),I=14,k="system-ui, -apple-system, sans-serif";function S(r,o){if(!r||typeof r!="object")return null;const l=U[r.type];if(!l)return null;const a=Array.isArray(r.points)?r.points:[],p=[];for(const b of a){const g=Number(b&&b.x),f=Number(b&&b.y);Number.isFinite(g)&&Number.isFinite(f)&&p.push({x:g,y:f})}const m=typeof r.colour=="string"&&r.colour?r.colour:o;if(l==="text"){const b=typeof r.text=="string"?r.text:"";if(!p.length||!b)return null;const g={tool:l,colour:m,points:[p[0]],text:b,region:y(r.region)},f=Number(r.fontSize);return Number.isFinite(f)&&f>0&&(g.fontSize=f),typeof r.background=="string"&&r.background&&(g.background=r.background),g}return p.length<2?null:{tool:l,colour:m,points:p,region:y(r.region)}}function y(r){return r==="start"||r==="end"?r:"centre"}function d(r){const o={type:D[r.tool]||r.tool,colour:r.colour,points:r.points.map(l=>({x:l.x,y:l.y}))};return(r.region==="start"||r.region==="end")&&(o.region=r.region),r.tool==="text"&&(o.text=r.text,r.fontSize!==void 0&&(o.fontSize=r.fontSize),r.background!==void 0&&(o.background=r.background)),o}const u="lat-annotate",n=Object.freeze({pen:3,arrow:4,rect:3,highlight:14});function t(r){return r==="arrow"||r==="rect"}class i{#e;#t;#n=null;#r=null;#o=null;#i="#e0245e";#s=[];#l=null;#a=[];#u=null;constructor(o){this.#e=o.grid,this.#t=o.renderer,this.#u=Array.isArray(o.seed)?o.seed:null}get tool(){return this.#o}get count(){return this.#s.length}mount(){this.#a.push(this.#e.on("scroll",()=>this.redraw())),this.#a.push(this.#e.on("render:done",()=>this.redraw())),this.#a.push(this.#e.on("presentation:ended",()=>{this.use(null),this.#h()})),this.#c(),this.#d(),this.#u&&this.#u.length&&this.replaceAll(this.#u),this.#u=null}add(o){const l=S(o,this.#i);return l?(l.durable=!0,this.#s.push(l),this.#y(),this.redraw(),this.#j(),this.#s.length):($("annotate.add.invalid",`annotate.add ignored a mark: it needs a known \`type\` (${V.join(", ")}) and at least two finite {x, y} points in content coordinates.`),this.#s.length)}list(){return this.#s.map(d)}replaceAll(o){const l=Array.isArray(o)?o:[];this.#s=l.map(a=>S(a,this.#i)).filter(Boolean);for(const a of this.#s)a.durable=!0;this.#s.length&&this.#y(),this.redraw(),this.#j()}#c(){const o=this.#t.viewport?.root;if(!o||!M(o.addEventListener))return;const l=a=>{!this.#o||!a||a.key!=="Escape"||(this.use(null),a.preventDefault?.())};o.addEventListener("keydown",l,!0),this.#a.push(()=>o.removeEventListener("keydown",l,!0))}#d(){const o=this.#n?.ownerDocument?.defaultView||this.#t.viewport?.root?.ownerDocument?.defaultView;if(!o||!M(o.matchMedia))return;let l=null;const a=()=>{const p=o.devicePixelRatio||1;let m;try{m=o.matchMedia(`(resolution: ${p}dppx)`)}catch{return}l=m;const b=()=>{this.redraw(),a()};M(m.addEventListener)?m.addEventListener("change",b,{once:!0}):M(m.addListener)&&m.addListener(b)};a(),this.#a.push(()=>{l=null})}use(o,l={}){const a=!!l.colour&&o===this.#o;l.colour&&(this.#i=String(l.colour));const p=o&&Z.includes(o)?o:null;this.#o=p&&p===this.#o&&!a?null:p;const m=this.#o?this.#y():this.#n;return m&&(m.style.pointerEvents=this.#o?"auto":"none",m.style.cursor=this.#o?"crosshair":""),this.#j(),this.#o}undo(){return this.#s.pop(),this.redraw(),this.#j(),this.#s.length}clear(){this.#s.length&&(this.#s=[],this.redraw(),this.#j())}#h(){const o=this.#s.filter(l=>l.durable);o.length!==this.#s.length&&(this.#s=o,this.redraw(),this.#j())}redraw(){!this.#n&&this.#s.length&&this.#y();const o=this.#n,l=this.#r;if(!o||!l)return;this.#S();const{left:a,top:p}=this.#v();l.clearRect(0,0,o.width,o.height);const m=this.#l?[...this.#s,this.#l]:this.#s;for(const b of["centre","start","end"]){const g=m.filter(f=>y(f.region)===b);if(g.length){l.save(),this.#f(l,b),l.translate((b==="centre"?-a:0)||0,-p||0);for(const f of g)this.#w(l,f);l.restore()}}}#f(o,l="centre"){const a=this.#n,p=this.#t.viewport?.bodyViewport;if(!M(a?.getBoundingClientRect)||!M(p?.getBoundingClientRect))return;const m=a.getBoundingClientRect(),b=p.getBoundingClientRect();if(!b.width||!b.height)return;const g=this.#m(l,b);g&&(o.beginPath(),o.rect(g.left-m.left,b.top-m.top,g.width,b.height),o.clip())}#m(o,l){const a=w=>{if(!M(w?.getBoundingClientRect))return null;const v=w.getBoundingClientRect();return v&&v.width>0?{left:v.left,width:v.width}:null},p=a(this.#t.viewport?.bodyStart),m=a(this.#t.viewport?.bodyEnd);if(o==="start")return p;if(o==="end")return m;let b=l.left,g=l.left+l.width;const f=l.left+l.width/2;for(const w of[p,m]){if(!w)continue;const v=w.left+w.width;w.left+w.width/2<f?b=Math.max(b,v):g=Math.min(g,w.left)}return g>b?{left:b,width:g-b}:null}#p(o){for(const[l,a]of[["start",this.#t.viewport?.bodyStart],["end",this.#t.viewport?.bodyEnd]]){if(!M(a?.getBoundingClientRect))continue;const p=a.getBoundingClientRect();if(p&&p.width>0&&o>=p.left&&o<p.left+p.width)return l}return"centre"}#g(o){const l=this.#t.viewport?.bodyViewport;if(!M(l?.getBoundingClientRect))return!0;const a=l.getBoundingClientRect();return!a.width||!a.height?!0:o.clientX>=a.left&&o.clientX<=a.right&&o.clientY>=a.top&&o.clientY<=a.bottom}#w(o,l){const a=l.points;if(!a.length)return;const p=this.#e.presentation?.scale||1;o.lineWidth=(n[l.tool]||3)*p,o.strokeStyle=l.colour,o.fillStyle=l.colour,o.lineCap="round",o.lineJoin="round",o.globalAlpha=l.tool==="highlight"?.32:1;const m=a[0],b=a[a.length-1];if(l.tool==="text"){const g=(l.fontSize||I)*p;o.font=`${g}px ${k}`,o.textBaseline="top";const f=l.text||"";if(l.background){let w=f.length*g*.6;if(typeof o.measureText=="function"){const v=o.measureText(f);v&&Number.isFinite(v.width)&&(w=v.width)}o.fillStyle=l.background,o.fillRect(m.x-g*.15,m.y-g*.1,w+g*.3,g*1.2)}o.fillStyle=l.colour,o.fillText(f,m.x,m.y),o.globalAlpha=1;return}if(l.tool==="rect")o.strokeRect(m.x,m.y,b.x-m.x,b.y-m.y);else if(l.tool==="arrow")o.beginPath(),o.moveTo(m.x,m.y),o.lineTo(b.x,b.y),o.stroke(),this.#b(o,m,b,o.lineWidth);else{o.beginPath(),o.moveTo(m.x,m.y);for(let g=1;g<a.length;g++)o.lineTo(a[g].x,a[g].y);o.stroke()}o.globalAlpha=1}#b(o,l,a,p){const m=Math.atan2(a.y-l.y,a.x-l.x),b=Math.max(8,p*3);o.beginPath(),o.moveTo(a.x,a.y),o.lineTo(a.x-b*Math.cos(m-Math.PI/7),a.y-b*Math.sin(m-Math.PI/7)),o.lineTo(a.x-b*Math.cos(m+Math.PI/7),a.y-b*Math.sin(m+Math.PI/7)),o.closePath(),o.fill()}#v(){const o=M(this.#t.scrollPosition)?this.#t.scrollPosition():null,l=this.#t.viewport?.rtl===!0;return{left:W(o?.left||0,l),top:o?.top||0}}#y(){if(this.#n)return this.#n;const o=this.#t.viewport?.overlays,l=o?.ownerDocument;if(!o||!l?.createElement)return null;const a=l.createElement("canvas");return a.className=u,a.style.position="absolute",a.style.inset="0",a.style.pointerEvents="none",o.appendChild(a),this.#n=a,this.#r=a.getContext?a.getContext("2d"):null,this.#S(),this.#A(a),a}#S(){const o=this.#n,l=this.#t.viewport?.root;if(!o||!l?.getBoundingClientRect)return;const a=l.getBoundingClientRect(),m=o.ownerDocument?.defaultView?.devicePixelRatio||1,b=Math.max(1,Math.round(a.width*m)),g=Math.max(1,Math.round(a.height*m));o.width===b&&o.height===g||(o.width=b,o.height=g,o.style&&(o.style.width=`${Math.max(1,a.width)}px`,o.style.height=`${Math.max(1,a.height)}px`),this.#r?.setTransform(m,0,0,m,0,0))}#A(o){const l=(g,f="centre")=>{const w=o.getBoundingClientRect(),{left:v,top:h}=this.#v();return{x:g.clientX-w.left+(f==="centre"?v:0),y:g.clientY-w.top+h}},a=g=>{if(!this.#o||!this.#g(g))return;const f=this.#p(g.clientX);this.#l={tool:this.#o,colour:this.#i,points:[l(g,f)],region:f},o.setPointerCapture?.(g.pointerId),g.preventDefault?.()},p=g=>{if(!this.#l)return;const f=l(g,this.#l.region);t(this.#l.tool)&&this.#l.points.length>1&&this.#l.points.pop(),this.#l.points.push(f),this.redraw()},m=g=>{this.#l&&(this.#l.points.length>1&&this.#s.push(this.#l),this.#l=null,o.releasePointerCapture?.(g.pointerId),this.redraw(),this.#j())},b=g=>{if(!this.#o)return;const f=this.#t.viewport?.bodyViewport;if(!f)return;let w=!1;g.deltaY&&typeof f.scrollTop=="number"&&(f.scrollTop+=g.deltaY,w=!0),g.deltaX&&typeof f.scrollLeft=="number"&&(f.scrollLeft+=g.deltaX,w=!0),w&&g.preventDefault?.()};o.addEventListener("pointerdown",a),o.addEventListener("pointermove",p),o.addEventListener("pointerup",m),o.addEventListener("pointercancel",m),o.addEventListener("wheel",b,{passive:!1}),this.#a.push(()=>{o.removeEventListener("pointerdown",a),o.removeEventListener("pointermove",p),o.removeEventListener("pointerup",m),o.removeEventListener("pointercancel",m),o.removeEventListener("wheel",b)})}#j(){this.#e.emit?.("annotation:changed",{tool:this.#o,count:this.#s.length},"user")}destroy(){for(const o of this.#a)o();this.#a=[],this.#n?.remove?.(),this.#n=null,this.#r=null,this.#s=[]}}const s=i}),Ce("packages/dom/src/timelinebar.js",function(e,G){"use strict";Object.defineProperty(e,"agoLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(e,"clockLabel",{enumerable:!0,get:function(){return V}}),Object.defineProperty(e,"TimelineBar",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return D}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W="lat-timeline";function Z(I){if(!Number.isFinite(I)||I<1e3)return"now";const k=Math.round(I/1e3);if(k<60)return`${k}s ago`;const S=Math.round(k/60);return S<60?`${S}m ago`:`${Math.round(S/60)}h ago`}function V(I,k){return Number.isFinite(I)?new Date(I).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;#s=[];constructor(k){this.#e=k.grid,this.#t=k.renderer}mount(){this.#s.push(this.#e.on("timeline:attached",()=>{this.#a(),this.refresh()})),this.#s.push(this.#e.on("timeline:detached",()=>this.#u())),this.#s.push(this.#e.on("timeline:seek",()=>this.refresh())),this.#s.push(this.#e.on("rows:changed",()=>this.refresh()))}refresh(){if(!this.#n||!this.#e.timeline.attached)return;const k=this.#e.timeline,S=k.depth,y=k.position;this.#r.max=String(Math.max(1,S)),this.#r.value=String(Math.max(0,S-y)),this.#r.disabled=S===0;const d=k.at(),u=k.live;this.#o&&(this.#o.textContent=u?this.#l("timeline.live"):Z(Date.now()-(d||Date.now())),this.#o.setAttribute("data-live",u?"true":"false")),this.#i&&(this.#i.textContent=S===0?this.#l("timeline.recording"):V(d,this.#e.get("locale"))),this.#n.setAttribute("data-live",u?"true":"false")}#l(k,S){const y=this.#e;return(y&&y.messages?y.messages:R).t(k,S)}#a(){if(this.#n)return;const k=this.#t.viewport?.overlays,S=k?.ownerDocument;if(!k||!S?.createElement)return;const y=S.createElement("div");y.className=W;const d=S.createElement("span");d.className=`${W}__ago`,d.setAttribute("role","status"),d.setAttribute("aria-live","polite");const u=S.createElement("input");u.className=`${W}__range`,u.type="range",u.min="0",u.step="1",u.setAttribute("aria-label",this.#l("timeline.scrub"));const n=S.createElement("span");n.className=`${W}__clock`;const t=S.createElement("button");t.className=`${W}__live`,t.type="button",t.textContent=this.#l("timeline.goLive"),t.setAttribute("aria-label",this.#l("timeline.returnToPresent")),y.appendChild(d),y.appendChild(u),y.appendChild(n),y.appendChild(t),k.appendChild(y),this.#n=y,this.#r=u,this.#o=d,this.#i=n;const i=()=>{const o=this.#e.timeline.depth;this.#e.timeline.seek(o-Number(u.value))};u.addEventListener("input",i);const s=()=>this.#e.timeline.toLive();t.addEventListener("click",s);const r=o=>o.stopPropagation();u.addEventListener("keydown",r),this.#s.push(()=>{u.removeEventListener("input",i),t.removeEventListener("click",s),u.removeEventListener("keydown",r)})}#u(){this.#n&&(M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null,this.#i=null)}destroy(){for(const k of this.#s)k();this.#s=[],this.#u()}}const D=U}),Ce("packages/dom/src/commentpaint.js",function(e,G){"use strict";Object.defineProperty(e,"CommentPainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/renderer/direction.js").isRtlElement,V="lat-comment-mark",U="lat-cell--commented",D="lat-cell--commented-open";class I{#e;#t;#n=[];#r=[];constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){this.#n.push(this.#e.on("render:done",()=>this.paint())),this.#n.push(this.#e.on("comment:indexLoaded",()=>this.paint())),this.#s(),this.paint()}paint(){const y=this.#e.comments;if(!y||!y.enabled)return;const d=this.#t.viewport?.root;if(!d||!d.querySelectorAll)return;const u=[];for(const n of d.querySelectorAll("[data-key]")){const t=n.getAttribute("data-key");if(t){u.push(t);for(const i of n.querySelectorAll("[data-col]")){const s=i.getAttribute("data-col"),r=y.at(t,s),o=!!(r&&r.count);i.classList.toggle(U,o),i.classList.toggle(D,o&&r.unresolved>0),this.#i(i,r,s)}}}(u.length!==this.#r.length||u.some((n,t)=>n!==this.#r[t]))&&(this.#r=u,y.request(u))}#o(y,d){const u=this.#e;return(u&&u.messages?u.messages:R).t(y,d)}#i(y,d,u){if(!d||!d.count){y.hasAttribute("aria-description")&&y.removeAttribute("aria-description");return}const n=d.count,t=d.unresolved,i=this.#o("count.comments",{count:n});y.setAttribute("aria-description",t>0?this.#o("comments.someUnresolved",{comments:i,unresolved:t}):this.#o("comments.allResolved",{comments:i}))}#s(){const y=this.#t.viewport?.root;if(!y||!M(y.addEventListener))return;const d=n=>{const t=this.#e.comments;if(!t||!t.enabled)return;const i=n.target&&M(n.target.closest)?n.target.closest("[data-col]"):null;if(!i||!i.classList.contains(U)||!this.#l(i,n))return;const s=i.closest("[data-key]"),r=s&&s.getAttribute("data-key");r&&(n.stopPropagation(),n.preventDefault(),t.open(r,i.getAttribute("data-col")))},u=n=>{const t=this.#e.comments;if(!t||!t.enabled||!n.altKey||n.key!=="m"&&n.key!=="M")return;const i=this.#t.viewport?.root?.querySelector?.("[data-col].lat-cell--focus")||(typeof document<"u"&&document.activeElement&&M(document.activeElement.closest)?document.activeElement.closest("[data-col]"):null);if(!i)return;const s=i.closest("[data-key]"),r=s&&s.getAttribute("data-key");r&&(n.preventDefault(),n.stopPropagation(),t.open(r,i.getAttribute("data-col")))};y.addEventListener("click",d,!0),y.addEventListener("keydown",u,!0),this.#n.push(()=>{y.removeEventListener("click",d,!0),y.removeEventListener("keydown",u,!0)})}#l(y,d){if(!M(y.getBoundingClientRect))return!1;const u=y.getBoundingClientRect(),n=Math.max(14,Math.min(24,u.height*.6));return(Z(y)?d.clientX<=u.left+n:d.clientX>=u.right-n)&&d.clientY<=u.top+n}destroy(){for(const y of this.#n)y();this.#n=[]}}const k=I}),Ce("packages/dom/src/presencepaint.js",function(e,G){"use strict";Object.defineProperty(e,"PresencePainter",{enumerable:!0,get:function(){return I}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return k}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/editors/common.js").cssEscape,U=G("packages/core/src/model/presence.js").CURSOR_LABEL_MS,D="lat-presence";class I{#e;#t;#n=null;#r=null;#o=new Set;#i=[];#s=null;constructor(y){this.#e=y.grid,this.#t=y.renderer}mount(){const y=this.#e.presence;if(!(!y||!y.enabled)){this.#i.push(this.#e.on("render:done",()=>this.paint()));for(const d of["presence:joined","presence:left","presence:updated"])this.#i.push(this.#e.on(d,u=>this.#l(d,u)));this.#a(),this.paint()}}#l(y,d){if(this.#h(),y==="presence:updated"||!this.#r||(this.#e.get("presence")||{}).announce===!1)return;const n=d&&d.peer;n&&(this.#r.textContent=this.#f(y==="presence:joined"?"a11y.presence.joined":"a11y.presence.left",{name:n.name}))}#a(){const y=this.#t.viewport?.overlays,d=y?.ownerDocument;if(!y||!d?.createElement)return;const u=this.#e.get("presence")||{},n=d.createElement("span");if(n.className=`${D}__live`,n.setAttribute("role","status"),n.setAttribute("aria-live","polite"),y.appendChild(n),this.#r=n,u.roster===!1)return;const t=d.createElement("div");t.className=D,u.roster&&u.roster.side==="start"&&t.setAttribute("data-side","start"),t.style.pointerEvents="auto",y.appendChild(t),this.#n=t}paint(){const y=this.#e.presence,d=this.#t.viewport?.root;if(!y||!y.enabled||!d?.querySelectorAll)return;this.#d(d);const u=y.peers(),n=[...u].sort((t,i)=>t.at-i.at);for(const t of n)for(const i of t.ranges||[])for(const s of i.rowIds||[])for(const r of i.columns||[])this.#c(d,s,r,t,"range");for(const t of n)t.cursor&&this.#c(d,t.cursor.rowId,t.cursor.colId,t,"cursor");for(const t of n)t.editing&&this.#c(d,t.editing.rowId,t.editing.colId,t,"edit");this.#h(),this.#u(u)}#u(y){if(this.#s!==null)return;const d=y.filter(t=>t.cursorFresh);if(!d.length)return;const n=Math.max(...d.map(t=>t.cursorAt||0))+U-Date.now();this.#s=setTimeout(()=>{this.#s=null,this.paint()},Math.max(50,n))}#c(y,d,u,n,t){const i=y.querySelector(`[data-key="${Z(d)}"]`),s=i&&i.querySelector(`[data-col="${Z(u)}"]`);s&&(s.setAttribute("data-presence",t),s.style.setProperty("--lat-peer",n.colour),s.setAttribute("data-peer-name",n.name),s.setAttribute("data-peer-initial",n.initials||(n.name||"?").slice(0,1).toUpperCase()),n.idle?s.setAttribute("data-peer-idle","true"):s.removeAttribute("data-peer-idle"),t==="cursor"&&n.cursorFresh&&s.setAttribute("data-peer-fresh","true"),this.#o.add(`${d}${u}`))}#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 n of d){const t=y.createElement("button");t.className=`${D}__peer`,t.type="button",t.style.setProperty("--lat-peer",n.colour),t.toggleAttribute("data-idle",!!n.idle),t.toggleAttribute("data-hidden",!!n.hidden);let i="presence.peer";n.hidden?i="presence.peerHidden":n.idle&&(i="presence.peerIdle"),t.setAttribute("aria-label",this.#f(i,{name:n.name}));const s=y.createElement("span");s.className=`${D}__dot`,s.setAttribute("aria-hidden","true"),s.textContent=n.initials||(n.name||"?").slice(0,1).toUpperCase(),t.appendChild(s);const r=y.createElement("span");r.className=`${D}__name`,r.textContent=n.name,t.appendChild(r),t.addEventListener("click",()=>this.#e.presence.jumpTo(n.id)),this.#n.appendChild(t)}const u=d.filter(n=>n.hidden).length;if(u){const n=y.createElement("span");n.className=`${D}__hidden`,n.textContent=this.#f("presence.hidden",{count:u}),this.#n.appendChild(n)}}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 u=this.#e;return(u&&u.messages?u.messages:R).t(y,d)}destroy(){for(const d of this.#i)d();this.#i=[],this.#s!==null&&clearTimeout(this.#s),this.#s=null;const y=this.#t.viewport?.root;y?.querySelectorAll&&this.#d(y),this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#n=null,this.#r=null}}const k=I}),Ce("packages/dom/src/commentpanel.js",function(e,G){"use strict";Object.defineProperty(e,"relativeTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"renderBody",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"CommentPanel",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return u}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,Z=G("packages/dom/src/editors/common.js").cssEscape,U=G("packages/core/src/model/comments.js").parseCellKey,D="lat-comments",I=/^(https?:|mailto:)/i,k='a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])';function S(n,t){if(!Number.isFinite(n))return"";const i=Math.max(0,Math.round((t-n)/1e3));if(i<60)return"just now";const s=Math.round(i/60);if(s<60)return`${s}m ago`;const r=Math.round(s/60);return r<24?`${r}h ago`:`${Math.round(r/24)}d ago`}function y(n,t,i,s){t.textContent="";const r=String(i??"");if(!s){t.textContent=r;return}const o=/(\*[^*\n]+\*)|(`[^`\n]+`)|(\[[^\]\n]+\]\([^)\s]+\))/g;let l=0,a=o.exec(r);for(;a;){a.index>l&&t.appendChild(n.createTextNode(r.slice(l,a.index)));const p=a[0];if(p.startsWith("*")){const m=n.createElement("em");m.textContent=p.slice(1,-1),t.appendChild(m)}else if(p.startsWith("`")){const m=n.createElement("code");m.textContent=p.slice(1,-1),t.appendChild(m)}else{const m=p.indexOf("]("),b=p.slice(1,m),g=p.slice(m+2,-1);if(I.test(g)){const f=n.createElement("a");f.href=g,f.textContent=b,f.rel="noopener noreferrer",f.target="_blank",t.appendChild(f)}else t.appendChild(n.createTextNode(b))}l=a.index+p.length,a=o.exec(r)}l<r.length&&t.appendChild(n.createTextNode(r.slice(l)))}class d{#e;#t;#n=null;#r=null;#o=null;#i=null;#s=null;#l=[];constructor(t){this.#e=t.grid,this.#t=t.renderer}mount(){this.#l.push(this.#e.on("comment:threadOpened",t=>this.#a(t))),this.#l.push(this.#e.on("comment:threadClosed",()=>this.#u())),this.#l.push(this.#e.on("render:done",()=>{this.#b(),this.#y()})),this.#l.push(this.#e.on("stream:evicted",()=>this.#c()))}#a(t){const i=this.#t.viewport?.root?.ownerDocument;i&&(this.#s=i.activeElement||null,this.#i=this.#h(t.rowId,t.field),this.#n||this.#m(i),this.#n.setAttribute("data-open","true"),this.#b(),this.#y(),this.#o&&M(this.#o.focus)&&this.#o.focus())}#u(){if(!this.#n)return;this.#n.removeAttribute("data-open"),this.#i=null;const t=this.#s;this.#s=null,t&&M(t.focus)&&t.focus()}#c(){const t=this.#e.comments.openKey;if(!t)return;const{rowId:i}=U(t);this.#e.rows.byKey(i)||(this.#d("This row is no longer in the grid: it scrolled out of the live window."),this.#e.comments.close({reason:"evicted"}))}#d(t){if(!this.#r)return;const s=this.#r.ownerDocument.createElement("p");s.className=`${D}__note`,s.setAttribute("role","status"),s.textContent=t,this.#r.appendChild(s)}#h(t,i){const s=this.#t.viewport?.root;if(!s||!s.querySelector)return null;const r=s.querySelector(`[data-key="${Z(t)}"]`);return r?r.querySelector(`[data-col="${i}"]`):null}#f(t,i){const s=this.#e;return(s&&s.messages?s.messages:R).t(t,i)}#m(t){const i=t.createElement("div");i.className=D,i.setAttribute("role","dialog"),i.setAttribute("aria-modal","true"),i.setAttribute("aria-label",this.#f("comments.panel"));const s=t.createElement("header");s.className=`${D}__head`;const r=t.createElement("div");r.className=`${D}__title`,s.appendChild(r);const o=t.createElement("button");o.className=`${D}__resolve`,o.type="button",s.appendChild(o);const l=t.createElement("button");l.className=`${D}__close`,l.type="button",l.setAttribute("aria-label",this.#f("comments.close")),l.textContent="×",s.appendChild(l);const a=t.createElement("div");a.className=`${D}__list`,a.setAttribute("role","log"),a.setAttribute("aria-live","polite");const p=t.createElement("form");p.className=`${D}__composer`;const m=t.createElement("textarea");m.className=`${D}__input`,m.rows=2,m.setAttribute("aria-label",this.#f("comments.write"));const b=t.createElement("button");b.className=`${D}__send`,b.type="submit",b.textContent=this.#f("comments.post"),p.appendChild(m),p.appendChild(b),i.appendChild(s),i.appendChild(a),i.appendChild(p),(this.#t.viewport.overlays||this.#t.viewport.root).appendChild(i),this.#n=i,this.#r=a,this.#o=m,this.#p=r,this.#g=o;const g=h=>{h.preventDefault();const c=String(m.value||"").trim();c&&(m.value="",this.#e.comments.add(c))},f=()=>this.#e.comments.close(),w=()=>{this.#w()>0?this.#e.comments.resolve():this.#e.comments.unresolve()},v=h=>{if(h.stopPropagation(),h.key==="Escape"){h.preventDefault(),this.#e.comments.close();return}if(h.key!=="Tab")return;const c=[...i.querySelectorAll(k)].filter(T=>T.offsetParent!==null||T===m);if(!c.length)return;const j=c[0],E=c[c.length-1],O=i.ownerDocument.activeElement;h.shiftKey&&O===j?(h.preventDefault(),E.focus()):!h.shiftKey&&O===E&&(h.preventDefault(),j.focus())};p.addEventListener("submit",g),l.addEventListener("click",f),o.addEventListener("click",w),i.addEventListener("keydown",v),this.#l.push(()=>{p.removeEventListener("submit",g),l.removeEventListener("click",f),o.removeEventListener("click",w),i.removeEventListener("keydown",v)})}#p=null;#g=null;#w(){return(this.#e.comments.thread||[]).filter(i=>!i.resolved).length}#b(){const t=this.#e.comments;if(!this.#n||!t.openKey)return;const i=this.#n.ownerDocument,s=this.#e.get("comments")||{},r=Date.now(),o=t.openKey,{rowId:l,field:a}=U(o),p=this.#e.columns.get(a),m=this.#e.rows.byKey(l),b=M(s.rowLabel)&&m?s.rowLabel(m):l;if(this.#p.textContent=this.#f("comments.cellTitle",{column:p&&(p.title??p.id)||a,row:b}),this.#g.textContent=this.#w()>0?this.#f("comments.resolve"):this.#f("comments.reopen"),this.#r.textContent="",t.loading){this.#d(this.#f("comments.loading"));return}const g=t.thread||[];if(!g.length){this.#d(this.#f("comments.empty"));return}const f=m&&p?p.getValue(m.data,m):void 0;for(const w of g)this.#r.appendChild(this.#v(i,w,r,f,s))}#v(t,i,s,r,o){const l=t.createElement("article");l.className=`${D}__item`,i.pending&&l.setAttribute("data-pending","true"),i.resolved&&l.setAttribute("data-resolved","true");const a=t.createElement("div");a.className=`${D}__meta`;const p=t.createElement("span");p.className=`${D}__author`,p.textContent=i.author&&(i.author.name||i.author.initials)||this.#f("comments.unknownAuthor"),a.appendChild(p);const m=t.createElement("time");m.className=`${D}__time`;const b=S(i.at,s);m.textContent=i.edited?this.#f("comments.edited",{time:b}):b,a.appendChild(m),l.appendChild(a);const g=t.createElement("div");if(g.className=`${D}__body`,y(t,g,i.body,!!o.markdown),l.appendChild(g),i.value!==void 0&&!Object.is(i.value,r)){const v=t.createElement("p");v.className=`${D}__moved`,v.textContent=this.#f("comments.valueMoved",{was:String(i.value),now:String(r)}),l.appendChild(v)}const f=i.can||{},w=v=>f[v]!==!1;if(w("edit")||w("delete")){const v=t.createElement("div");if(v.className=`${D}__actions`,w("delete")){const h=t.createElement("button");h.type="button",h.className=`${D}__action`,h.textContent=this.#f("comments.delete"),h.addEventListener("click",()=>this.#e.comments.remove(i.id)),v.appendChild(h)}l.appendChild(v)}return l}#y(){if(!this.#n||!this.#e.comments.openKey)return;if((this.#e.get("comments")||{}).mode==="docked"){this.#n.setAttribute("data-docked","true");return}this.#n.removeAttribute("data-docked");const i=this.#e.comments.openKey,{rowId:s,field:r}=U(i),o=this.#h(s,r)||this.#i,l=this.#t.viewport?.root;if(!o||!l||!M(o.getBoundingClientRect))return;const a=o.getBoundingClientRect(),p=l.getBoundingClientRect(),m=this.#n.getBoundingClientRect();let b=a.bottom-p.top+4;b+m.height>p.height&&a.top-p.top>m.height&&(b=a.top-p.top-m.height-4);let g=a.left-p.left;g+m.width>p.width&&(g=Math.max(0,p.width-m.width-4)),this.#n.style.top=`${Math.max(0,b)}px`,this.#n.style.left=`${Math.max(0,g)}px`;const f=a.bottom<p.top||a.top>p.bottom;this.#n.toggleAttribute("data-offscreen",f)}destroy(){for(const t of this.#l)t();this.#l=[],this.#n&&M(this.#n.remove)&&this.#n.remove(),this.#n=null,this.#r=null,this.#o=null}}const u=d}),Ce("packages/dom/src/watermark.js",function(e,G){"use strict";Object.defineProperty(e,"WATERMARK_CLASS",{enumerable:!0,get:function(){return U}}),Object.defineProperty(e,"Watermark",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return y}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/core/src/i18n/index.js").defaultMessages,W=G("packages/dom/src/editors/common.js"),Z=W.el,V=W.on,U="lat-watermark",D="https://www.latticegrid.dev",I=["br","bl","tl","tr"],k=4e3;class S{#e;#t;#n;#r=null;#o=[];#i;#s=0;#l=null;constructor(u){this.#e=u.grid,this.#t=u.document,this.#n=u.element,this.#i=u.window||(typeof globalThis>"u"?{}:globalThis)}mount(){this.refresh(),M(this.#e.on)&&this.#o.push(this.#e.on("licence:changed",()=>this.refresh()));const u=this.#e.licence&&this.#e.licence.ready;u&&M(u.then)&&u.then(()=>this.refresh(),()=>this.refresh())}refresh(){const u=this.#d();u&&!this.#r?(this.#h(),this.#u()):!u&&this.#r&&(this.#f(),this.#c())}#a(){const u=this.#i;if(!u||!M(u.matchMedia))return!1;try{return!!u.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}#u(){this.#c(),M(this.#i.setTimeout)&&(this.#a()||(this.#l=this.#i.setTimeout(()=>{if(this.#l=null,!this.#d()){this.#f();return}this.#s=(this.#s+1)%I.length,this.#f(),this.#h(),this.#u()},k)))}#c(){this.#l!==null&&M(this.#i.clearTimeout)&&this.#i.clearTimeout(this.#l),this.#l=null}#d(){const u=this.#e.licence;return!!(u&&M(u.watermark)&&u.watermark())}#h(){const u=Z(this.#t,"a",{class:`${U}__link`,text:(this.grid&&this.grid.messages?this.grid.messages:R).t("licence.watermark"),attrs:{href:D,target:"_blank",rel:"noopener noreferrer"}});this.#r=Z(this.#t,"div",{class:`${U} ${U}--${I[this.#s]}`,attrs:{role:"note",title:"This grid is unlicensed for this domain. Visit latticegrid.dev for a licence."},children:[u]}),this.#o.push(V(this.#r,"pointerdown",n=>{M(n.stopPropagation)&&n.stopPropagation()})),this.#n&&M(this.#n.appendChild)&&this.#n.appendChild(this.#r)}#f(){this.#r&&M(this.#r.remove)&&this.#r.remove(),this.#r=null}destroy(){this.#c();for(const u of this.#o)u();this.#o=[],this.#f()}}const y=S}),Ce("packages/dom/src/maximise.js",function(e,G){"use strict";Object.defineProperty(e,"MAXIMISED_CLASS",{enumerable:!0,get:function(){return D}}),Object.defineProperty(e,"MAXIMISED_BODY_CLASS",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"PLACEHOLDER_CLASS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"Maximiser",{enumerable:!0,get:function(){return y}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return d}});const _=G("packages/core/src/internal/util.js"),M=_.warnOnce,$=_.isFunction,R=G("packages/dom/src/editors/common.js"),W=R.el,Z=R.on,U=G("packages/dom/src/themeof.js").themeOf,D="lat-maximised",I={position:"fixed",top:"0px",left:"0px",right:"0px",bottom:"0px",width:"auto",height:"auto",minWidth:"0px",minHeight:"0px",maxWidth:"none",maxHeight:"none",margin:"0px",zIndex:"2147483000"},k="lat-maximised-host",S="lat-maximise-placeholder";class y{#e;#t;#n;#r;#o;#i=null;#s=null;#l=new Set;#a=null;#u=!1;#c=null;constructor(n){this.#e=n.element,this.#t=n.document,this.#n=$(n.onChange)?n.onChange:null,this.#r=$(n.captureScroll)?n.captureScroll:null,this.#o=$(n.restoreScroll)?n.restoreScroll:null}active(){return this.#i!==null}enter(){if(this.active())return!0;const n=this.#e.parentNode;if(!n||!this.#t.body)return M("maximise.detached","the grid cannot be maximised because its element is not in the document."),!1;this.#i=W(this.#t,"div",{class:S}),this.#i.style.visibility="hidden";const t=this.#e.offsetWidth,i=this.#e.offsetHeight;t&&(this.#i.style.width=`${t}px`),i&&(this.#i.style.height=`${i}px`);const s=this.#r?this.#r():null,r=$(this.#e.getAttribute)&&!this.#e.getAttribute("data-theme")?U(n):null;r&&(this.#e.setAttribute("data-theme",r),this.#u=!0),n.insertBefore(this.#i,this.#e),this.#d(()=>this.#t.body.appendChild(this.#e)),this.#a={};for(const[o,l]of Object.entries(I))this.#a[o]=this.#e.style[o]||"",this.#e.style[o]=l;return this.#c=this.#t.body.style?this.#t.body.style.overflow||"":null,this.#t.body.style&&(this.#t.body.style.overflow="hidden"),this.#e.classList.add(D),this.#t.body.classList&&this.#t.body.classList.add(k),s&&this.#o&&this.#o(s),this.#s=Z(this.#t,"keydown",o=>this.#h(o)),this.#f(),!0}exit(){if(!this.active())return!1;const n=this.#r?this.#r():null,t=this.#i,i=t.parentNode;if(i&&$(i.insertBefore)&&this.#d(()=>i.insertBefore(this.#e,t)),$(t.remove)&&t.remove(),this.#i=null,this.#u&&(this.#e.removeAttribute("data-theme"),this.#u=!1),this.#a){for(const[s,r]of Object.entries(this.#a))this.#e.style[s]=r;this.#a=null}return this.#c!==null&&this.#t.body&&this.#t.body.style&&(this.#t.body.style.overflow=this.#c),this.#c=null,this.#e.classList.remove(D),this.#t.body&&this.#t.body.classList&&this.#t.body.classList.remove(k),n&&this.#o&&this.#o(n),this.#s&&this.#s(),this.#s=null,this.#f(),!0}toggle(){return this.active()?!this.exit():this.enter()}#d(n){const t=this.#t.activeElement,i=t&&t!==this.#t.body&&$(this.#e.contains)&&this.#e.contains(t)?t:null;n(),i&&$(i.focus)&&i.focus()}#h(n){!n||n.key!=="Escape"||n.defaultPrevented||this.exit()}#f(){this.#n&&this.#n();for(const n of this.#l)n(this.active())}watch(n){return $(n)?(this.#l.add(n),()=>this.#l.delete(n)):()=>{}}destroy(){this.exit()}}const d=y}),Ce("packages/dom/src/promptbar.js",function(e,G){"use strict";Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return i}});const _=G("packages/dom/src/editors/common.js"),M=_.documentFor,$=_.el,R=_.on,W=_.clear,V=G("packages/core/src/i18n/index.js").defaultMessages,D=G("packages/core/src/internal/util.js").isFunction,I=G("packages/core/src/ai/schema.js"),k=I.describeGrid,S=I.promptText,y=G("packages/core/src/ai/intent.js"),d=y.applyPlan,u=y.buildPrompt,n=y.planIntent,t="lat-prompt";class i{#e;#t=null;#n=null;#r={};#o;#i={};#s=null;#l=null;#a=null;#u=null;#c=null;#d=null;#h=null;#f=null;#m=null;#p=null;#g=null;#w="idle";#b=0;#v=!1;#y=[];t(l,a){return(this.messages&&typeof this.messages.t=="function"?this.messages:V).t(l,a)}init(l={}){this.messages=l&&l.messages||l&&l.grid&&l.grid.messages||V,this.#e=M(l),this.#t=l.grid||null,this.#n=D(l.ask)?l.ask:null,this.#r=l.schemaOptions||{},this.#o=l.context,this.#i={onPlan:D(l.onPlan)?l.onPlan:null,onApply:D(l.onApply)?l.onApply:null,onError:D(l.onError)?l.onError:null},this.#s=$(this.#e,"div",{class:t,attrs:{"data-state":"idle",role:"search"}}),this.#S(l)}element(){return this.#s}refresh(){this.#v||!this.#s||this.#w!=="busy"&&this.#E()}destroy(){this.#v=!0,this.#b++;for(const l of this.#y)l();this.#y.length=0,this.#g=null,this.#s=null,this.#l=null,this.#a=null,this.#u=null,this.#c=null,this.#d=null,this.#h=null,this.#f=null,this.#m=null,this.#p=null}plan(){return this.#g}async ask(l){if(this.#v||this.#w==="busy")return null;const a=String(l??(this.#l&&this.#l.value)??"").trim();if(!a)return null;if(!this.#n)return this.#T("No model is wired up. Supply `ai.ask` to use the prompt bar."),null;const p=++this.#b;this.#A("busy"),this.#C("Thinking…");let m;try{const b=k(this.#t,this.#r),g=S(b);if(m=await this.#n({prompt:a,schema:b,schemaText:g,message:u(a,g),context:this.#o}),this.#v||p!==this.#b)return null;const f=n(m,b);return this.#j(f),f}catch(b){return this.#v||p!==this.#b||(this.#i.onError&&this.#i.onError(b),this.#T(b instanceof Error?b.message:String(b))),null}}apply(){const l=this.#g;if(this.#v||!l||!l.ok)return null;const a=this.#t?.ai,p=D(a?.apply)?a.apply(l):d(l,this.#t);return this.#i.onApply&&this.#i.onApply(p,l),this.#E(),this.#l&&(this.#l.value=""),p.failed.length?this.#T(`Applied ${p.applied.length}; ${p.failed.map(m=>`${m.type} failed: ${m.reason}`).join("; ")}`):this.#C(`Applied: ${l.describe()}`),p}discard(){this.#v||(this.#E(),this.#C("Discarded."))}#S(l){const a=this.#e,p=$(a,"div",{class:`${t}__row`});this.#l=$(a,"input",{class:`${t}__input`,attrs:{type:"text",placeholder:l.placeholder||"Ask for a view: “EMEA deals over 50k, biggest first”","aria-label":l.label||"Ask about this grid",autocomplete:"off"}}),this.#y.push(R(this.#l,"keydown",b=>{const g=b&&b.key;g==="Enter"?(D(b.preventDefault)&&b.preventDefault(),this.ask()):g==="Escape"&&this.#g&&(D(b.preventDefault)&&b.preventDefault(),this.discard())})),p.appendChild(this.#l),this.#a=$(a,"button",{class:`${t}__submit`,text:this.t("prompt.ask"),attrs:{type:"button"}}),this.#y.push(R(this.#a,"click",()=>{this.ask()})),p.appendChild(this.#a),this.#s.appendChild(p),this.#u=$(a,"div",{class:`${t}__preview`,attrs:{hidden:!0}}),this.#c=$(a,"p",{class:`${t}__summary`}),this.#d=$(a,"ul",{class:`${t}__notes`});const m=$(a,"div",{class:`${t}__buttons`});this.#h=$(a,"button",{class:`${t}__apply`,text:this.t("prompt.apply"),attrs:{type:"button"}}),this.#f=$(a,"button",{class:`${t}__discard`,text:this.t("prompt.discard"),attrs:{type:"button"}}),this.#y.push(R(this.#h,"click",()=>{this.apply()})),this.#y.push(R(this.#f,"click",()=>{this.discard()})),m.appendChild(this.#h),m.appendChild(this.#f),this.#u.appendChild(this.#c),this.#u.appendChild(this.#d),this.#u.appendChild(m),this.#s.appendChild(this.#u),this.#m=$(a,"p",{class:`${t}__status`,attrs:{role:"status","aria-live":"polite"}}),this.#p=$(a,"p",{class:`${t}__error`,attrs:{role:"alert",hidden:!0}}),this.#s.appendChild(this.#m),this.#s.appendChild(this.#p)}#A(l){if(this.#w=l,!this.#s)return;this.#s.setAttribute("data-state",l);const a=l==="busy";s(this.#l,a),s(this.#a,a),this.#a&&(this.#a.textContent=this.t(a?"prompt.asking":"prompt.ask")),r(this.#u,l!=="preview"),r(this.#p,l!=="error")}#j(l){const a=l;if(this.#i.onPlan&&this.#i.onPlan(l),!a.ok){this.#g=null;const p=a.rejected.length?a.rejected.map(m=>m.reason).join("; "):"nothing to do";this.#T(`I could not turn that into a change: ${p}`);return}this.#g=l,this.#C(""),this.#c&&(this.#c.textContent=a.describe()),this.#O(a.rejected),this.#A("preview")}#O(l){const a=this.#d;if(a){W(a),r(a,!l.length);for(const p of l.slice(0,6))a.appendChild($(this.#e,"li",{class:`${t}__note`,text:p.reason}));l.length>6&&a.appendChild($(this.#e,"li",{class:`${t}__note`,text:this.t("prompt.moreNotes",{count:l.length-6})}))}}#E(){this.#g=null,this.#c&&(this.#c.textContent=""),this.#d&&W(this.#d),this.#A("idle")}#C(l){this.#m&&(this.#m.textContent=l)}#T(l){this.#g=null,this.#C(""),this.#p&&(this.#p.textContent=l),this.#A("error")}}function s(o,l){o&&(o.disabled=l,l?o.setAttribute("disabled",""):o.removeAttribute("disabled"))}function r(o,l){o&&(o.hidden=l,l?o.setAttribute("hidden",""):o.removeAttribute("hidden"))}}),Ce("packages/dom/src/stat.js",function(e,G){"use strict";Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return t}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return i}}),Object.defineProperty(e,"bandTone",{enumerable:!0,get:function(){return s}}),Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return l}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.isObject,R=_.warnOnce,Z=G("packages/core/src/source/derive.js").reduceValues,U=G("packages/core/src/source/memory.js").isPipelineSettle,I=G("packages/core/src/i18n/index.js").defaultMessages,S=G("packages/dom/src/cell/icons.js").renderIconInto,y={root:"lat-stat",icon:"lat-stat__icon",body:"lat-stat__body",title:"lat-stat__title",value:"lat-stat__value",delta:"lat-stat__delta",interval:"lat-stat__interval",footer:"lat-stat__footer",note:"lat-stat__note"},d="unknown",u=new Set(["sum","min","max","avg","first","last","mode","median","p25","p75","p90","p95","p99","stddev","stddevP","mad","range","iqr","trimmedMean","winsorizedMean","geomean","harmean"]),n=Object.freeze({direction:"flat",change:null,percent:null});function t(g,f){if(!Number.isFinite(g)||!Number.isFinite(f))return n;const w=g-f,v=w>0?"up":w<0?"down":"flat",h=f===0?null:w/Math.abs(f)*100;return{direction:v,change:w,percent:h}}function i(g,f){return g==="flat"||f==="neither"?"flat":g===f?"good":"bad"}function s(g,f,w=null){if(M(f)){const O=f(g,w);return O==="good"||O==="warn"||O==="bad"?O:null}if(!$(f))return null;const v=typeof g=="number"&&Number.isFinite(g)?g:null;if(v===null)return null;const h=Number.isFinite(Number(f.good))?Number(f.good):null,c=Number.isFinite(Number(f.warn))?Number(f.warn):null,j=String(f.direction||"up")==="down",E=O=>j?v<=O:v>=O;return h!==null&&E(h)?"good":c!==null&&E(c)?"warn":h===null&&c===null?null:"bad"}function r(g){return!(M(g.value)||g.value!==void 0&&!$(g.value))}function o(g){return!g||!g.rows||!M(g.rows.totalCount)?!0:g.rows.totalCount()>0}function l(g){const f=$(g)?g:{},w=f.grid||null,v=m(f.container,w);if(!v)return R("stat.container","createStat needs a `container`: an element or a selector."),b();const h=v.ownerDocument||(typeof document>"u"?null:document);if(!h)return R("stat.document","createStat needs a document; it draws DOM."),b();const c=h.createElement("div");c.className=["lattice",y.root,f.class].filter(Boolean).join(" "),c.setAttribute("role","group");const j=h.createElement("div");j.className=y.title;const E=h.createElement("div");E.className=y.value;const O=h.createElement("div");O.className=y.interval;const T=h.createElement("div");T.className=y.delta;const A=h.createElement("div");A.className=y.footer;const P=h.createElement("div");if(P.className=y.note,P.hidden=!0,f.icon!=null&&f.icon!==""){const te=h.createElement("span");te.className=y.icon,te.setAttribute("aria-hidden","true"),S(te,f.icon,`stat:${f.title||"stat"}`),c.appendChild(te);const ee=h.createElement("div");ee.className=y.body,ee.appendChild(j),ee.appendChild(E),ee.appendChild(P),ee.appendChild(O),ee.appendChild(T),ee.appendChild(A),c.appendChild(ee)}else c.appendChild(j),c.appendChild(E),c.appendChild(P),c.appendChild(O),c.appendChild(T),c.appendChild(A);v.appendChild(c);let z=null;const H=[];let x=!1;function F(){if(M(f.value))return f.value(w);if(f.value!==void 0&&!$(f.value))return f.value;const te=$(f.value)?f.value:f,ee=te.of,re=te.fn||"sum",se=te.show;return w?re==="count"?B().length:ee?se?q(String(ee),String(re),String(se)):C()==="filtered"&&w.statistics&&M(w.statistics.reduce)?w.statistics.reduce(String(ee),String(re)):Z(B().map(de=>p(de,String(ee))),String(re)):null:null}function C(){return String(f.scope||"filtered")}function B(){if(!w||!w.rows)return[];const te=C();if(te==="all"){const re=[];return M(w.rows.forEachAll)&&w.rows.forEachAll(se=>{se.group||re.push(a(se))}),re}if(te==="selected")return(w.selection&&M(w.selection.rows)?w.selection.rows():[]).filter(Boolean).map(a);const ee=[];return M(w.rows.forEach)&&w.rows.forEach(re=>{re.group||ee.push(a(re))}),ee}function q(te,ee,re){if(ee!=="min"&&ee!=="max")return R(`stat.show.${ee}`,`\`show\` needs \`fn: 'min'\` or \`fn: 'max'\`: "${ee}" reduces to a value that no single row holds, so there is no row to report from.`),null;let se=null,de=null;for(const ie of B()){const oe=Number(p(ie,te));Number.isFinite(oe)&&(se===null||(ee==="max"?oe>se:oe<se))&&(se=oe,de=ie)}return de===null?null:p(de,re)}function Q(te){if(M(f.format))return String(f.format(te,w));if(te==null)return f.empty??"—";const ee=$(f.value)?f.value:f,re=ee.show||ee.of;if((ee.show?!0:u.has(String(ee.fn||"sum")))&&w&&re&&M(w.columns?.get)){const de=w.columns.get(String(re));if(de&&M(de.formatValue))return de.formatValue(te)}return typeof te=="number"?Number.isInteger(te)?String(te):te.toFixed(f.decimals??2):String(te)}function Y(te){return te?(w&&w.messages||I).t(`stat.tone.${te}`):""}function J(){if(x)return;const te=F(),ee=r(f)&&!!w&&!o(w),re=ee?null:te,se=M(f.baseline)?f.baseline(w):f.baseline;z=re,j.textContent=f.title??"",j.hidden=!f.title,E.textContent=Q(re),P.hidden=!ee,ee&&(P.textContent=w.messages.t("stat.noData"));const de=ee||se===void 0||se===null?n:t(typeof re=="number"?re:null,Number(se)),ie=i(de.direction,f.goodWhen||"up");if(T.hidden=de.change===null,de.change!==null){const pe=de.direction==="up"?"↑":de.direction==="down"?"↓":"→",Me=de.percent===null?Q(Math.abs(de.change)):`${Math.abs(de.percent).toFixed(1)}%`;T.textContent=`${pe} ${Me}`,T.setAttribute("data-tone",ie),T.setAttribute("data-direction",de.direction)}const oe=M(f.interval)?f.interval(re,w):null,ue=!!oe&&Number.isFinite(oe.lower)&&Number.isFinite(oe.upper);O.hidden=!ue,ue&&(O.textContent=`${Q(oe.lower)} – ${Q(oe.upper)}`,Number.isFinite(oe.confidence)&&O.setAttribute("title",`${Math.round(oe.confidence*100)}%`));const ce=ee?d:f.bands?s(re,f.bands,w):null;ce?c.setAttribute("data-tone",ce):c.removeAttribute("data-tone"),A.textContent=M(f.footer)?String(f.footer(re,w)):f.footer??"",A.hidden=!A.textContent,c.setAttribute("aria-label",[f.title,E.textContent,ee?P.textContent:"",ue?O.textContent:"",de.change===null?"":T.textContent,de.change===null?"":Y(ie),A.textContent].filter(Boolean).join(", "))}if(w&&M(w.on)&&f.live!==!1)for(const te of["rows:changed","filter:changed","selection:changed","model:changed"]){const ee=re=>{te==="model:changed"&&!U(re)||J()};w.on(te,ee),H.push(()=>M(w.off)&&w.off(te,ee))}return J(),{element:()=>c,value:()=>z,refresh:J,destroy(){x=!0;for(const te of H)try{te()}catch{}H.length=0,c.remove()}}}function a(g){return $(g)&&"data"in g?g.data:g}function p(g,f){if(!$(g))return;if(!f.includes("."))return g[f];let w=g;for(const v of f.split(".")){if(!$(w))return;w=w[v]}return w}function m(g,f){if(g&&typeof g=="object")return g;if(typeof g!="string")return null;const w=f&&f.element&&f.element.ownerDocument||(typeof document>"u"?null:document);return w?w.querySelector(g):null}function b(){return{element:()=>null,value:()=>null,refresh(){},destroy(){}}}}),Ce("packages/dom/src/kpistrip.js",function(e,G){"use strict";Object.defineProperty(e,"KpiStrip",{enumerable:!0,get:function(){return Z}});const M=G("packages/core/src/internal/util.js").isObject,R=G("packages/dom/src/stat.js").createStat,W={band:"lat-kpi-strip"};class Z{#e;#t;#n;#r=null;#o=[];constructor({grid:U,document:D,kpis:I}){this.#e=U,this.#t=D,this.#n=Array.isArray(I)?I.filter(M):[]}get active(){return this.#n.length>0}element(){return this.#r}mount(){if(this.#r)return;const D=this.#t.createElement("div");D.className=`lattice ${W.band}`,D.setAttribute("role","group"),D.setAttribute("aria-label",this.#e.messages.t("panel.statistics")),this.#r=D;for(const I of this.#n){const k=R({...I,grid:this.#e,container:D});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)}}}),Ce("packages/dom/src/createGrid.js",function(e,G){"use strict";Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return St}});const M=G("packages/core/src/index.js").createHeadlessGrid,R=G("packages/core/src/defaults.js").applyDefaults,Z=G("packages/core/src/export/download.js").downloadBlob,V=G("packages/core/src/internal/util.js"),U=V.fail,D=V.isFunction,I=V.warnOnce,S=G("packages/dom/src/localviews.js").createLocalViewStorage,d=G("packages/dom/src/renderer/index.js").DomRenderer,n=G("packages/dom/src/cell/index.js").createCellLayer,t=G("packages/dom/src/cell/icons.js"),i=t.icon,s=t.iconNames,o=G("packages/dom/src/editors/index.js").editors,a=G("packages/dom/src/filters/index.js").filters,p=G("packages/dom/src/ui/index.js"),m=p.StatusBar,b=p.TooltipManager,g=p.Pagination,f=p.GroupByZone,v=G("packages/dom/src/ui/celltooltip.js").CellTooltips,c=G("packages/dom/src/filtermenu.js").FilterMenu,E=G("packages/dom/src/columnmenu.js").ColumnMenu,T=G("packages/dom/src/shortcutshelp.js").ShortcutsHelp,P=G("packages/dom/src/rowreorder.js").RowReorder,z=G("packages/dom/src/alignedgrids.js").AlignedGrids,x=G("packages/dom/src/columntagbar.js").ColumnTagBar,C=G("packages/dom/src/anomalychip.js").AnomalyChip,q=G("packages/dom/src/rowform.js").RowForm,Q=G("packages/dom/src/toolpanelmount.js"),Y=Q.ToolPanelDock,J=Q.panelHost,ee=G("packages/dom/src/celledit.js").CellEditController,se=G("packages/dom/src/editbar.js").EditBar,ie=G("packages/dom/src/rangeselect.js").RangeController,ue=G("packages/core/src/model/selection.js").resolveSelectionConfig,pe=G("packages/dom/src/importer.js").ImportController,$e=G("packages/dom/src/historybar.js").HistoryBar,ke=G("packages/dom/src/diffpaint.js").DiffPainter,Ee=G("packages/dom/src/detailhost.js").DetailHost,ze=G("packages/dom/src/highlightpaint.js").HighlightPainter,Qe=G("packages/dom/src/findpaint.js").FindPainter,Ae=G("packages/dom/src/findbar.js").FindBar,Ve=G("packages/dom/src/redactpaint.js").RedactionPainter,st=G("packages/dom/src/validationpaint.js").ValidationPainter,bt=G("packages/dom/src/presentation.js").PresentationController,Tt=G("packages/dom/src/capture.js").captureElement,Dt=G("packages/dom/src/annotate.js").AnnotationLayer,Yt=G("packages/dom/src/timelinebar.js").TimelineBar,fe=G("packages/dom/src/commentpaint.js").CommentPainter,xe=G("packages/dom/src/presencepaint.js").PresencePainter,Ze=G("packages/dom/src/commentpanel.js").CommentPanel,gt=G("packages/dom/src/watermark.js").Watermark,Oe=G("packages/dom/src/maximise.js").Maximiser,Ne=G("packages/dom/src/promptbar.js").PromptBar,ve=G("packages/dom/src/kpistrip.js").KpiStrip;function Te(Le,rt,et){const it=rt==="redo"?"toolbar.redo":"toolbar.undo";return!et||!et.label?Le(it):Le(rt==="redo"?"toolbar.redoLabelled":"toolbar.undoLabelled",{label:et.label})}const Pe=["undo","redo","pause","restore","maximise","-","export","excel","clipboard","print"],Re=2e3;function Ue(Le,rt,et){const it=rt.annotate===!0?qe(Le):[];if(rt.actions===!1)return[];if(rt.actions===void 0&&rt.side!=="left")return it;const Et=Array.isArray(rt.actions)?rt.actions:Pe,Nt=(Ot,Vt)=>Le.messages.t(Ot,Vt),dt={undo:{name:"undo",title:()=>Te(Nt,"undo",Le.history.peek("undo")),icon:"undo",run:()=>Le.history.undo(),enabled:()=>Le.history.canUndo()},redo:{name:"redo",title:()=>Te(Nt,"redo",Le.history.peek("redo")),icon:"redo",run:()=>Le.history.redo(),enabled:()=>Le.history.canRedo()},export:{name:"export",title:()=>Nt("toolbar.exportCsv"),icon:"download",run:()=>Le.export.csv({download:!0,fileName:rt.exportName})},excel:{name:"excel",title:()=>Nt("toolbar.exportExcel"),icon:"spreadsheet",run:()=>Le.export.excel({download:!0,fileName:rt.exportName})},clipboard:{name:"clipboard",title:()=>Nt("toolbar.clipboard"),icon:"copy",run:()=>Le.export.clipboard({rows:"visible",headers:!0})},print:{name:"print",title:()=>Nt("toolbar.print"),icon:"print",run:()=>Le.export.print()},pause:{name:"pause",title:()=>{if(!Le.updates.paused)return Nt("toolbar.pause");const Ot=Le.updates.stats().pending;return Ot?Nt("toolbar.applyHeld",{count:Ot}):Nt("toolbar.resume")},icon:()=>Le.updates.paused?"play":"pause",run:()=>Le.updates.paused?Le.updates.resume():Le.updates.pause()},restore:{name:"restore",title:()=>Nt("toolbar.restoreView"),icon:"restore",run:()=>Le.state.reset(),enabled:()=>Le.state.modified()},maximise:{name:"maximise",title:()=>Nt(et&&et.active()?"toolbar.restoreSize":"toolbar.maximiseGrid"),icon:()=>et&&et.active()?"minimise":"maximise",run:()=>et.toggle()}};return et||delete dt.maximise,Et.map(Ot=>Ot==="-"?{name:"-",separator:!0}:typeof Ot=="string"?dt[Ot]:!Ot||typeof Ot!="object"||!Ot.name?null:{...Ot,run:D(Ot.run)?()=>Ot.run({grid:Le,keys:Le.selection&&D(Le.selection.keys)?Le.selection.keys():[],cells:Le.selection&&D(Le.selection.cells)?Le.selection.cells():[]}):void 0}).filter(Boolean).concat(it)}function qe(Le){const rt=it=>Le.messages.t(it),et={pen:"pencil",arrow:"arrow",rect:"square",highlight:"highlight"};return["pen","arrow","rect","highlight"].map(it=>({name:it,title:()=>rt(`toolbar.annotate.${it}`),icon:et[it],run:()=>Le.annotate?.use(it),active:()=>Le.annotate?.tool===it,annotation:!0}))}const ft=["pen","arrow","rect","highlight"];function at(Le){return{rowCount:()=>{if(D(Le.rows.matchCount))return Le.rows.matchCount();const rt=Le.pagination&&D(Le.pagination.get)?Le.pagination.get():null;return rt&&Number.isFinite(rt.total)?rt.total:Le.rows.count()},totalRowCount:()=>D(Le.rows.totalCount)?Le.rows.totalCount():Le.rows.count(),selectedCount:()=>{const rt=Le.selection&&Le.selection.keys?Le.selection.keys():null;return rt?rt.length:0},rangeValues:()=>{const rt=Le.selection;return!rt||!D(rt.cells)?[]:rt.cells().map(({key:et,colId:it})=>Le.rows.value(et,it))},hiddenUnresolved:()=>D(Le.comments&&Le.comments.hiddenUnresolved)?Le.comments.hiddenUnresolved():0,progress:()=>D(Le.source&&Le.source.progress)?Le.source.progress():null,updateStats:()=>Le.updates?Le.updates.stats():null}}function mt(Le,rt){for(const[et,it]of Object.entries(o||{}))Le.register("editor",et,it);for(const[et,it]of Object.entries(a||{}))Le.register("filter",et,it);for(const[et,it]of Object.entries(rt.components||{}))Le.register("component",et,it);for(const[et,it]of Object.entries(rt.pipes||{}))Le.register("pipe",et,it);for(const[et,it]of Object.entries(rt.totalFns||{}))Le.register("totalFn",et,it)}function ct(Le,rt,et,it,Et,Nt){const dt=[],Ot=rt.viewport;let Vt=null;if(et.maximise!==!1&&(Vt=new Oe({element:Nt,document:it,onChange:()=>rt.invalidate("all"),captureScroll:()=>rt.scrollState(),restoreScroll:tt=>rt.restoreScroll(tt)}),Le.maximise=Vt,dt.push(()=>Vt.destroy())),et.statusBar){const tt=typeof et.statusBar=="object"?et.statusBar:{},pt=new m;pt.init({document:it,host:at(Le),panels:tt.panels,registry:tt.registry,locale:Le.get("locale"),messages:Le.messages}),Ot.statusBar.appendChild(pt.element());const Pt=()=>{const nn=Ot.statusBar.offsetHeight||Ot.statusBar.getBoundingClientRect?.().height||0;Ot.root.style.setProperty("--lattice-status-height",`${Math.ceil(nn)}px`)},$t=()=>{pt.refresh(),Pt()},Ht=["rows:changed","model:changed","selection:changed","range:changed","rows:queued","rows:paused","rows:resumed","comment:added","comment:edited","comment:deleted","comment:indexLoaded"].map(nn=>Le.on(nn,$t));$t(),Pt(),dt.push(()=>{for(const nn of Ht)nn();Ot.root.style.removeProperty("--lattice-status-height"),pt.destroy?.()})}const Wt=ue(et.selection);if(Wt.ranges){const tt=new ie({grid:Le,renderer:rt,document:it});tt.mount(),Le.ranges=tt,dt.push(()=>tt.destroy())}if(et.import){const tt=new pe({grid:Le,renderer:rt,document:it,settings:typeof et.import=="object"?et.import:{}});Le.importer=tt,dt.push(()=>tt.destroy())}if(et.historyBar){const tt=typeof et.historyBar=="object"?et.historyBar.element:null,pt=new $e;pt.init({document:it,host:{undo:()=>Le.history.undo(),redo:()=>Le.history.redo(),canUndo:()=>Le.history.canUndo(),canRedo:()=>Le.history.canRedo(),peek:$t=>Le.history.peek($t),list:()=>Le.history.list()},props:typeof et.historyBar=="object"?et.historyBar:{}}),(tt||Ot.root).appendChild(pt.element());const Pt=[Le.on("history:changed",()=>pt.refresh())];Le.historyBar=pt,dt.push(()=>{for(const $t of Pt)$t();pt.destroy()})}if(et.diff){const tt=new ke({grid:Le,renderer:rt});tt.mount(),Le.diffPainter=tt,dt.push(()=>tt.destroy())}if(et.ai&&D(et.ai.ask)){const tt=new Ne;tt.init({document:it,grid:Le,ask:et.ai.ask,schemaOptions:et.ai.schemaOptions,context:et.ai.context,placeholder:et.ai.placeholder});const pt=et.ai.element||Ot.root;pt===Ot.root?pt.insertBefore(tt.element(),pt.firstChild):pt.appendChild(tt.element()),Le.promptBar=tt,dt.push(()=>tt.destroy())}if(et.groupPanel){const tt=typeof et.groupPanel=="object"?et.groupPanel:{},pt=new f;pt.init({document:it,grid:Le,host:J(Le,it,(Pt,$t)=>rt.announce?.(Pt,$t)),props:{header:Ot.header,hint:tt.hint}}),Ot.root.insertBefore(pt.element(),Ot.header),Le.groupPanel=pt;for(const Pt of["ready","columns:changed","column:grouped","column:moved","column:visible","column:pinned","model:changed","state:reset"])D(Le.on)&&dt.push(Le.on(Pt,()=>pt.refresh()));dt.push(()=>pt.destroy())}if(et.kpis){const tt=new ve({grid:Le,document:it,kpis:et.kpis});tt.active&&(tt.mount(),Ot.root.insertBefore(tt.element(),Ot.header),Le.kpiStrip=tt,dt.push(()=>tt.destroy()))}if(et.toolPanel){const tt=typeof et.toolPanel=="object"?et.toolPanel:{},pt=new Y({grid:Le,document:it,root:Ot.root,panels:tt.panels,openPanel:tt.openPanel,side:tt.side,icons:tt.icons,actions:Ue(Le,tt,Vt),announce:(Pt,$t)=>rt.announce?.(Pt,$t)});pt.mount(),Le.toolPanel=pt,dt.push(()=>pt.destroy()),tt.annotate===void 0&&(dt.push(Le.on("presentation:started",()=>{for(const Pt of qe(Le))pt.addAction(Pt)})),dt.push(Le.on("presentation:ended",()=>{for(const Pt of ft)pt.removeAction(Pt)})))}if(et.pagination){const tt=typeof et.pagination=="object"?et.pagination:{},pt=new g;pt.init({document:it,pageSize:tt.pageSize,pageSizes:tt.pageSizes,page:tt.page,total:tt.total,locale:Le.get("locale"),messages:Le.messages,onChange:({page:Ht,pageSize:nn})=>Le.pagination.set({page:Ht,pageSize:nn})});const Pt=()=>{const Ht=Le.pagination.get();pt.total=Ht.total,pt.counting=Ht.counting===!0,pt.page=Ht.page,pt.paint()};Le.pagination.set({pageSize:pt.pageSize}),Pt();const $t=["rows:changed","filter:changed","model:changed"].map(Ht=>Le.on(Ht,Pt));Ot.statusBar.appendChild(pt.element()),dt.push(()=>{for(const Ht of $t)Ht();pt.destroy?.()})}if(et.edit!==!1)if(et.editBar){const tt=new se({grid:Le,document:it,root:Ot.root});tt.mount(),Le.editBar=tt,dt.push(()=>tt.destroy())}else{const tt=new ee({grid:Le,document:it,renderer:rt,registry:Et,cellLayer:rt.cellLayer});tt.mount(),dt.push(()=>tt.destroy())}const an=new c({grid:Le,document:it,layer:Ot.overlays,registry:Et});an.mount(),dt.push(()=>an.destroy());const ln=new E({grid:Le,document:it,host:Ot.root,cellMenu:et.contextMenu!==!1,headerMenu:et.columnMenu!==!1,items:D(et.contextMenu)?et.contextMenu:void 0,headerItems:D(et.columnMenu)?et.columnMenu:void 0});if(ln.mount(),dt.push(()=>ln.destroy()),Array.isArray(et.alignedGrids)&&et.alignedGrids.length){const tt=new z;tt.add(Le);for(const pt of et.alignedGrids)pt&&pt!==Le&&tt.add(pt);dt.push(()=>tt.destroy())}const zt=new q({grid:Le,renderer:rt,document:it,registry:Et});zt.active&&(zt.mount(),dt.push(()=>zt.destroy())),Object.defineProperty(Le,"form",{configurable:!0,value:Object.freeze({open(tt){return zt.active?zt.openRow(tt):!1},close(){zt.active&&zt.close()},save(){return zt.active?zt.save():!1},isOpen(){return zt.active?zt.open:!1}})}),dt.push(()=>{delete Le.form}),Object.defineProperty(Le,"icons",{configurable:!0,value:Object.freeze({get(tt){const pt=i(tt);return pt?{viewBox:pt.viewBox,paths:pt.paths.slice(),paint:pt.paint==="stroke"?"stroke":"fill"}:null},names(){return s()}})}),dt.push(()=>{delete Le.icons});const un=new x({grid:Le,renderer:rt,document:it});un.active&&(un.mount(),dt.push(()=>un.destroy()));const cn=new C({grid:Le,renderer:rt,document:it});cn.active&&(cn.mount(),dt.push(()=>cn.destroy()));const rn=new P({grid:Le,renderer:rt,document:it});if(rn.active){rn.mount(),rn.paint();const tt=Le.on("render:done",()=>rn.paint());dt.push(()=>{tt(),rn.destroy()})}if(et.shortcuts!==!1){const tt=new T({grid:Le,renderer:rt});tt.mount(),dt.push(()=>tt.destroy())}const jt=new ze({grid:Le,renderer:rt,window:it.defaultView||void 0});jt.mount(),dt.push(()=>jt.destroy());const Rt=new Qe({grid:Le,renderer:rt,window:it.defaultView||void 0});if(Rt.mount(),dt.push(()=>Rt.destroy()),et.find!==!1){const tt=new Ae({grid:Le,renderer:rt,document:it,settings:et.find});tt.mount(),dt.push(()=>tt.destroy())}const Ft=new Ve({grid:Le,renderer:rt});Ft.mount(),dt.push(()=>Ft.destroy());const Ut=new st({grid:Le,renderer:rt});Ut.mount(),dt.push(()=>Ut.destroy());const Qt=new bt({grid:Le,renderer:rt,maximiser:Vt});Qt.mount(),dt.push(()=>Qt.destroy());const qt=new Yt({grid:Le,renderer:rt});qt.mount(),dt.push(()=>qt.destroy()),et.environment||Le.set("environment",()=>({userAgent:typeof navigator=="object"&&navigator?navigator.userAgent:void 0,hardwareConcurrency:typeof navigator=="object"&&navigator?navigator.hardwareConcurrency:void 0,devicePixelRatio:typeof window=="object"&&window?window.devicePixelRatio:void 0,viewport:typeof window=="object"&&window?{width:window.innerWidth,height:window.innerHeight}:void 0,crossOriginIsolated:typeof globalThis.crossOriginIsolated=="boolean"?globalThis.crossOriginIsolated:void 0}));let Zt=null;for(const[tt,pt]of[["filter:changed","filter"],["sort:changed","sort"],["rows:changed","data"],["column:resized","resize"],["column:moved","columns"],["column:visible","columns"]])dt.push(Le.on(tt,()=>{Zt=pt}));dt.push(Le.on("render:done",tt=>{Le.diagnostics.render(Zt||tt.cause,tt.phases),Zt=null}));const en=new xe({grid:Le,renderer:rt});if(en.mount(),dt.push(()=>en.destroy()),dt.push(Le.on("presence:lockRefused",tt=>en.announceRefusal(tt.peer))),Le.presence&&Le.presence.enabled){for(const Pt of["selection:changed","range:changed","cell:edit:start","cell:edit:end"])dt.push(Le.on(Pt,()=>Le.presence.publish()));let tt="";dt.push(Le.on("render:done",()=>{const Pt=rt.focusState&&rt.focusState(),$t=Pt?`${Pt.rowKey}${Pt.colId}`:"";$t!==tt&&(tt=$t,Le.presence.publish())}));const pt=Nt.ownerDocument;if(pt&&D(pt.addEventListener)){const Pt=()=>Le.presence.setPaused(pt.visibilityState==="hidden");pt.addEventListener("visibilitychange",Pt),Pt(),dt.push(()=>pt.removeEventListener("visibilitychange",Pt))}}const Xt=new fe({grid:Le,renderer:rt});Xt.mount(),dt.push(()=>Xt.destroy());const dn=new Ze({grid:Le,renderer:rt});dn.mount(),dt.push(()=>dn.destroy()),dt.push(Le.on("facet:computed",()=>rt.refreshHeader?.())),Wt&&Wt.headerCheckbox===!0&&dt.push(Le.on("selection:changed",()=>rt.refreshHeader?.())),dt.push(Le.on("facet:expanded",()=>rt.invalidate("columns"))),dt.push(Le.on("model:changed",()=>rt.invalidate("rows")));const Kt=(tt,pt)=>rt.announce?.(tt,pt),fn=Le.messages,Bt=(tt,pt)=>fn.t(tt,pt),pn=tt=>Bt("count.rows",{count:tt});dt.push(Le.on("sort:changed",()=>{const tt=Le.sort.get();if(!tt.length){Kt(Bt("a11y.sort.cleared"));return}const pt=tt.map(Pt=>{const $t=Le.columns.get(Pt.col);return Bt("a11y.sort.column",{column:$t&&$t.title||Pt.col,direction:Bt(Pt.dir==="desc"?"a11y.sort.descending":"a11y.sort.ascending")})});Kt(Bt("a11y.sort.by",{columns:fn.list(pt)}))})),dt.push(Le.on("filter:changed",()=>{const tt=Le.rows.matchCount?Le.rows.matchCount():Le.rows.count(),pt=Le.rows.totalCount?Le.rows.totalCount():tt;Kt(tt===pt?Bt("a11y.filter.cleared",{rows:pn(pt)}):Bt("a11y.filter.applied",{shown:pn(tt),total:pn(pt)}))})),dt.push(Le.on("selection:changed",()=>{const tt=Le.selection.keys().length;Kt(tt===0?Bt("a11y.selection.cleared"):Bt("a11y.selection.count",{count:tt}))})),dt.push(Le.on("group:toggled",tt=>{const pt=Le.rows.byKey?Le.rows.byKey(tt.key):null,Pt=(pt&&(pt.groupLabel??pt.groupValue))??tt.key;Kt(Bt(tt.expanded?"a11y.group.expanded":"a11y.group.collapsed",{label:Pt,rows:pn(Le.rows.count())}))})),dt.push(Le.on("column:grouped",tt=>{const pt=Array.isArray(tt.columns)?tt.columns:[];if(!pt.length){Kt(Bt("a11y.group.cleared"));return}const Pt=pt.map($t=>{const Ht=Le.columns.get($t);return Ht&&Ht.title||$t});Kt(Bt("a11y.group.by",{columns:fn.list(Pt)}))})),dt.push(Le.on("page:changed",tt=>{const pt=Number(tt.size)||0,Pt=Number(tt.total)||0,$t=pt>0?Math.max(1,Math.ceil(Pt/pt)):1;Kt(Bt("a11y.page.position",{page:(Number(tt.page)||0)+1,pages:$t}))}));let tn={added:0,removed:0},_t=null;const En=()=>{_t=null;const tt=[];tn.added&&tt.push(Bt("count.rowsAdded",{count:tn.added})),tn.removed&&tt.push(Bt("count.rowsRemoved",{count:tn.removed})),tn={added:0,removed:0},tt.length&&Kt(fn.list(tt))};dt.push(Le.on("rows:changed",tt=>{if(!tt||typeof tt.added!="number")return;const pt=Number(tt.added)||0,Pt=Number(tt.removed)||0;!pt&&!Pt||(tn.added+=pt,tn.removed+=Pt,_t||(_t=setTimeout(En,Re)))})),dt.push(()=>{_t&&clearTimeout(_t)}),dt.push(Le.on("rows:paused",()=>{_t&&(clearTimeout(_t),_t=null),tn={added:0,removed:0},Kt(Bt("a11y.updates.paused"),{repeat:!0})})),dt.push(Le.on("rows:resumed",()=>Kt(Bt("a11y.updates.resumed"),{repeat:!0})));let hn={count:0,first:null},mn=null;const Sn=()=>{mn=null;const{count:tt,first:pt}=hn;if(hn={count:0,first:null},!tt||!pt)return;const Pt=Le.columns.get(pt.colId),$t=Pt&&Pt.title||pt.colId,Ht=pt.reason?Bt("a11y.edit.reason",{reason:pt.reason}):"";if(tt===1){const nn=pt.restored===void 0||pt.restored===null||pt.restored===""?Bt("value.empty"):String(pt.restored);Kt(Bt("a11y.edit.refusedOne",{column:$t,value:nn,reason:Ht}),{repeat:!0});return}Kt(Bt("a11y.edit.refusedMany",{count:tt,reason:Ht}),{repeat:!0})};dt.push(Le.on("cell:reverted",tt=>{!tt||!tt.applied||(hn.count+=1,hn.first||(hn.first=tt),mn||(mn=setTimeout(Sn,150)))})),dt.push(()=>{mn&&clearTimeout(mn)}),dt.push(Le.on("history:applied",tt=>{const pt=!!(tt&&tt.direction==="redo"),Pt=tt&&tt.step&&tt.step.label;Kt(Pt?Bt(pt?"a11y.history.redo":"a11y.history.undo",{label:Pt}):Bt(pt?"a11y.history.redoLast":"a11y.history.undoLast"),{repeat:!0})}));const gn=new Dt({grid:Le,renderer:rt,seed:et.state&&Array.isArray(et.state.annotations)?et.state.annotations:null});gn.mount(),dt.push(()=>gn.destroy()),Le.annotate=gn,Le.capture=async(tt={})=>{const{blob:pt,width:Pt,height:$t}=await Tt(rt.viewport.root,tt);return(tt.download===!0||tt.download!==!1&&tt.fileName)&&Z(pt,tt.fileName||`${Le.get("exportName")||"grid"}.png`),Le.emit("presentation:captured",{width:Pt,height:$t,bytes:pt.size,mimeType:pt.type,fileName:tt.fileName||null},"api"),pt};const On=new gt({grid:Le,document:it,element:Ot.overlays,window:it.defaultView||void 0});On.mount(),dt.push(()=>On.destroy());const Tn=new b({grid:Le,document:it,element:Ot.overlays});Tn.mount?.(),dt.push(()=>Tn.destroy?.());const jn=new v({grid:Le,host:Le.rendererHost(),viewport:Ot,document:it});return jn.mount(),dt.push(()=>jn.destroy()),dt}function vt(Le){const rt=[],et=it=>{if(it&&(it.__lattice&&rt.push(it),it.children))for(const Et of it.children)et(Et)};return et(Le),rt}function St(Le,rt={}){(!Le||typeof Le!="object"||!("appendChild"in Le))&&U("createGrid needs a host element as its first argument."),rt=R(rt);const et=Le.ownerDocument||(typeof document<"u"?document:null);et||U("createGrid needs a DOM. Use createHeadlessGrid() on the server.");const it=et.documentElement&&et.documentElement.lang,Et=!rt.licence&&D(et.querySelector)?et.querySelector('meta[name="lattice-license"]')?.getAttribute("content"):null,Nt={...rt};if(!rt.locale&&it&&(Nt.locale=it),Et&&(Nt.licence=Et),rt.views&&rt.views.local)if(rt.views.storage)I("views:local:ignored","[lattice] views.local is ignored because views.storage was also supplied; the explicit adapter wins.");else{const zt=rt.views.local===!0?{}:rt.views.local;Nt.views={...rt.views,storage:S(zt)}}const dt=M(Nt),Ot=dt.rendererHost();Ot.document=et,mt(Ot.registry,rt),Ot.cellLayer=n(Ot),Ot.detailHost=new Ee({grid:dt,document:Le.ownerDocument||globalThis.document,createGrid:(zt,un)=>St(zt,un)});const Vt=new d(Le,Ot),Wt=dt.on("detail:toggled",()=>{Ot.detailHost.syncTarget(),Ot.detailHost.prune()}),sn=dt.on("config:changed",zt=>{zt&&zt.key==="detail"&&Ot.detailHost.reconfigure()});dt.on("destroy",()=>{Wt(),sn(),Ot.detailHost.destroy()}),Ot.detailHost.syncTarget(),dt.attachRenderer(Vt),Vt.mount();const an=ct(dt,Vt,rt,et,Ot.registry,Le),ln=dt.destroy.bind(dt);return dt.destroy=()=>{for(const zt of an)try{zt()}catch{}Le.__lattice===dt&&(Le.__lattice=null),ln()},Le.__lattice=dt,dt}}),Ce("packages/dom/src/hydrate.js",function(e,G){"use strict";Object.defineProperty(e,"firstChildTag",{enumerable:!0,get:function(){return k}}),Object.defineProperty(e,"childTags",{enumerable:!0,get:function(){return S}}),Object.defineProperty(e,"coerceCell",{enumerable:!0,get:function(){return d}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return u}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return n}});const _=G("packages/core/src/internal/util.js"),M=_.isFunction,$=_.warnOnce,W=G("packages/core/src/columns/datatypes.js").BUILTIN_TYPES,V=G("packages/core/src/columns/types/index.js").EXTENDED_TYPES,D=G("packages/dom/src/createGrid.js").createGrid,I=new Set([...Object.keys(W),...Object.keys(V)]);function k(t,i){for(const s of t.children)if(s.tagName===i.toUpperCase())return s;return null}function S(t,i){const s=[];for(const r of t.children)r.tagName===i.toUpperCase()&&s.push(r);return s}function y(t,i){const s=M(t.getAttribute)?t.getAttribute("data-field"):null;return s||String(t.textContent||"").trim().toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||`col${i}`}function d(t){const i=t.trim();if(i==="")return null;if(i==="true"||i==="false")return i==="true";const s=Number(i);return Number.isFinite(s)&&i!==""?s:i}function u(t){const i=k(t,"thead"),s=k(i||t,"tr"),o=(s?S(s,"th").length?S(s,"th"):S(s,"td"):[]).map((m,b)=>{const g=y(m,b),f={id:g,field:g,title:String(m.textContent||"").trim()||g},w=M(m.getAttribute)?m.getAttribute("data-type"):null;w&&(I.has(w)?f.type=w:$(`hydrate.unknownType:${w}`,`data-type "${w}" on column "${g}" is not a built-in type name, so it was ignored; the column falls back to sampled shape typing.`));const v=M(m.getAttribute)?m.getAttribute("data-format"):null;return v&&(f.format=v),f}),l=k(t,"tbody"),p=(l?S(l,"tr"):S(t,"tr").filter(m=>m!==s)).map((m,b)=>{const g=S(m,"td"),w={__row:(M(m.getAttribute)?m.getAttribute("data-id"):null)||`row${b}`};return o.forEach((v,h)=>{w[v.field]=g[h]?d(String(g[h].textContent||"")):null}),w});return{columns:o,rows:p}}function n(t,i={}){const{columns:s,rows:r}=u(t),o=t.ownerDocument.createElement("div");return t.parentNode.insertBefore(o,t),t.parentNode.removeChild(t),D(o,{rowKey:"__row",columns:s,rows:r,...i,columns:i.columns!==void 0?i.columns:s,rows:i.rows!==void 0?i.rows:r})}}),Ce("packages/dom/src/autoinit.js",function(e,G){"use strict";Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return I}});const M=G("packages/core/src/internal/util.js").isFunction,R=G("packages/dom/src/createGrid.js").createGrid,Z=G("packages/dom/src/hydrate.js").hydrateTable;function V(k,S){const y=[];return M(k.hasAttribute)&&k.hasAttribute(S)&&y.push(k),M(k.querySelectorAll)&&y.push(...k.querySelectorAll(`[${S}]`)),y}function U(k){const S=k.parentNode;if(!S||!S.children)return null;const y=[...S.children],d=y.indexOf(k),u=[y[d+1],y[d-1]];for(const n of u)if(n&&n.tagName==="SCRIPT"&&M(n.getAttribute)&&n.hasAttribute("data-lattice-config"))return n;return null}function D(k){const S=U(k);if(!S)return{};try{return JSON.parse(S.textContent||"{}")}catch(y){return console.warn("[lattice] autoInit: data-lattice-config is not valid JSON, ignoring it.",y),{}}}function I(k){const S=k||(typeof document<"u"?document:null);if(!S)return[];const y=[];for(const d of V(S,"data-lattice-grid")){if(d.__lattice)continue;const u=D(d);y.push(d.tagName==="TABLE"?Z(d,u):R(d,u))}return y}}),Ce("packages/dom/src/index.js",function(e,G){"use strict";Object.defineProperty(e,"LatticeGrid",{enumerable:!0,get:function(){return O}}),Object.defineProperty(e,"default",{enumerable:!0,get:function(){return T}});const _=G("packages/dom/src/createGrid.js"),M=_.createGrid,$=G("packages/dom/src/hydrate.js"),R=$.hydrateTable,W=G("packages/dom/src/autoinit.js"),Z=W.autoInit,V=G("packages/dom/src/localviews.js"),U=V.createLocalViewStorage,D=G("packages/core/src/index.js"),I=D.createHeadlessGrid,k=D.registerModules,S=D.setLicence,y=D.version,d=D.getVersion,u=D.serialiseState,n=D.restoreState,t=D.defaults;Object.defineProperty(e,"createGrid",{enumerable:!0,get:function(){return _.createGrid}}),Object.defineProperty(e,"gridElementsWithin",{enumerable:!0,get:function(){return _.gridElementsWithin}});const i=G("packages/dom/src/stat.js");Object.defineProperty(e,"createStat",{enumerable:!0,get:function(){return i.createStat}}),Object.defineProperty(e,"deltaOf",{enumerable:!0,get:function(){return i.deltaOf}}),Object.defineProperty(e,"toneOf",{enumerable:!0,get:function(){return i.toneOf}}),Object.defineProperty(e,"readTable",{enumerable:!0,get:function(){return $.readTable}}),Object.defineProperty(e,"hydrateTable",{enumerable:!0,get:function(){return $.hydrateTable}}),Object.defineProperty(e,"autoInit",{enumerable:!0,get:function(){return W.autoInit}}),Object.defineProperty(e,"createLocalViewStorage",{enumerable:!0,get:function(){return V.createLocalViewStorage}}),Object.defineProperty(e,"DEFAULT_VIEWS_KEY",{enumerable:!0,get:function(){return V.DEFAULT_VIEWS_KEY}}),Object.defineProperty(e,"createHeadlessGrid",{enumerable:!0,get:function(){return D.createHeadlessGrid}}),Object.defineProperty(e,"defaults",{enumerable:!0,get:function(){return D.defaults}}),Object.defineProperty(e,"version",{enumerable:!0,get:function(){return D.version}}),Object.defineProperty(e,"getVersion",{enumerable:!0,get:function(){return D.getVersion}}),Object.defineProperty(e,"Grid",{enumerable:!0,get:function(){return D.Grid}}),Object.defineProperty(e,"EventBus",{enumerable:!0,get:function(){return D.EventBus}}),Object.defineProperty(e,"Registry",{enumerable:!0,get:function(){return D.Registry}}),Object.defineProperty(e,"sharedRegistry",{enumerable:!0,get:function(){return D.sharedRegistry}}),Object.defineProperty(e,"registerModules",{enumerable:!0,get:function(){return D.registerModules}}),Object.defineProperty(e,"parseLicence",{enumerable:!0,get:function(){return D.parseLicence}}),Object.defineProperty(e,"verifyLicence",{enumerable:!0,get:function(){return D.verifyLicence}}),Object.defineProperty(e,"licenceInfo",{enumerable:!0,get:function(){return D.licenceInfo}}),Object.defineProperty(e,"watermark",{enumerable:!0,get:function(){return D.watermark}}),Object.defineProperty(e,"setLicence",{enumerable:!0,get:function(){return D.setLicence}}),Object.defineProperty(e,"licenceState",{enumerable:!0,get:function(){return D.licenceState}}),Object.defineProperty(e,"isLocalHost",{enumerable:!0,get:function(){return D.isLocalHost}}),Object.defineProperty(e,"matchesDomain",{enumerable:!0,get:function(){return D.matchesDomain}}),Object.defineProperty(e,"LicenceHolder",{enumerable:!0,get:function(){return D.LicenceHolder}}),Object.defineProperty(e,"ColumnModel",{enumerable:!0,get:function(){return D.ColumnModel}}),Object.defineProperty(e,"buildGraph",{enumerable:!0,get:function(){return D.buildGraph}}),Object.defineProperty(e,"Lookup",{enumerable:!0,get:function(){return D.Lookup}}),Object.defineProperty(e,"ValuePipeline",{enumerable:!0,get:function(){return D.ValuePipeline}}),Object.defineProperty(e,"compileFormat",{enumerable:!0,get:function(){return D.compileFormat}}),Object.defineProperty(e,"compileMask",{enumerable:!0,get:function(){return D.compileMask}}),Object.defineProperty(e,"specToOoxml",{enumerable:!0,get:function(){return D.specToOoxml}}),Object.defineProperty(e,"EXTENDED_TYPES",{enumerable:!0,get:function(){return D.EXTENDED_TYPES}}),Object.defineProperty(e,"createRadixType",{enumerable:!0,get:function(){return D.createRadixType}}),Object.defineProperty(e,"RADIX_PRESETS",{enumerable:!0,get:function(){return D.RADIX_PRESETS}}),Object.defineProperty(e,"parseRadix",{enumerable:!0,get:function(){return D.parseRadix}}),Object.defineProperty(e,"formatRadix",{enumerable:!0,get:function(){return D.formatRadix}}),Object.defineProperty(e,"createUnitType",{enumerable:!0,get:function(){return D.createUnitType}}),Object.defineProperty(e,"registerUnitSystem",{enumerable:!0,get:function(){return D.registerUnitSystem}}),Object.defineProperty(e,"defineUnit",{enumerable:!0,get:function(){return D.defineUnit}}),Object.defineProperty(e,"UNIT_SYSTEMS",{enumerable:!0,get:function(){return D.UNIT_SYSTEMS}}),Object.defineProperty(e,"parseUnit",{enumerable:!0,get:function(){return D.parseUnit}}),Object.defineProperty(e,"formatUnit",{enumerable:!0,get:function(){return D.formatUnit}}),Object.defineProperty(e,"createCurrencyType",{enumerable:!0,get:function(){return D.createCurrencyType}}),Object.defineProperty(e,"parseMoney",{enumerable:!0,get:function(){return D.parseMoney}}),Object.defineProperty(e,"formatMoney",{enumerable:!0,get:function(){return D.formatMoney}}),Object.defineProperty(e,"convertMoney",{enumerable:!0,get:function(){return D.convertMoney}}),Object.defineProperty(e,"rateFunction",{enumerable:!0,get:function(){return D.rateFunction}}),Object.defineProperty(e,"MISSING_RATE",{enumerable:!0,get:function(){return D.MISSING_RATE}}),Object.defineProperty(e,"Messages",{enumerable:!0,get:function(){return D.Messages}}),Object.defineProperty(e,"createMessages",{enumerable:!0,get:function(){return D.createMessages}}),Object.defineProperty(e,"auditCatalogue",{enumerable:!0,get:function(){return D.auditCatalogue}}),Object.defineProperty(e,"EN_GB",{enumerable:!0,get:function(){return D.EN_GB}}),Object.defineProperty(e,"MESSAGE_KEYS",{enumerable:!0,get:function(){return D.MESSAGE_KEYS}}),Object.defineProperty(e,"DEFAULT_LOCALE",{enumerable:!0,get:function(){return D.DEFAULT_LOCALE}}),Object.defineProperty(e,"formatList",{enumerable:!0,get:function(){return D.formatList}}),Object.defineProperty(e,"resolveLocale",{enumerable:!0,get:function(){return D.resolveLocale}}),Object.defineProperty(e,"LOCALES",{enumerable:!0,get:function(){return D.LOCALES}}),Object.defineProperty(e,"resolveCatalogue",{enumerable:!0,get:function(){return D.resolveCatalogue}}),Object.defineProperty(e,"EN_US",{enumerable:!0,get:function(){return D.EN_US}}),Object.defineProperty(e,"FR_FR",{enumerable:!0,get:function(){return D.FR_FR}}),Object.defineProperty(e,"FR_CA",{enumerable:!0,get:function(){return D.FR_CA}}),Object.defineProperty(e,"IT_IT",{enumerable:!0,get:function(){return D.IT_IT}}),Object.defineProperty(e,"ES_ES",{enumerable:!0,get:function(){return D.ES_ES}}),Object.defineProperty(e,"PT_BR",{enumerable:!0,get:function(){return D.PT_BR}}),Object.defineProperty(e,"DE_DE",{enumerable:!0,get:function(){return D.DE_DE}}),Object.defineProperty(e,"NL_NL",{enumerable:!0,get:function(){return D.NL_NL}}),Object.defineProperty(e,"SV_SE",{enumerable:!0,get:function(){return D.SV_SE}}),Object.defineProperty(e,"DA_DK",{enumerable:!0,get:function(){return D.DA_DK}}),Object.defineProperty(e,"NB_NO",{enumerable:!0,get:function(){return D.NB_NO}}),Object.defineProperty(e,"FI_FI",{enumerable:!0,get:function(){return D.FI_FI}}),Object.defineProperty(e,"PL_PL",{enumerable:!0,get:function(){return D.PL_PL}}),Object.defineProperty(e,"CS_CZ",{enumerable:!0,get:function(){return D.CS_CZ}}),Object.defineProperty(e,"HU_HU",{enumerable:!0,get:function(){return D.HU_HU}}),Object.defineProperty(e,"RO_RO",{enumerable:!0,get:function(){return D.RO_RO}}),Object.defineProperty(e,"UK_UA",{enumerable:!0,get:function(){return D.UK_UA}}),Object.defineProperty(e,"EL_GR",{enumerable:!0,get:function(){return D.EL_GR}}),Object.defineProperty(e,"JA_JP",{enumerable:!0,get:function(){return D.JA_JP}}),Object.defineProperty(e,"AR",{enumerable:!0,get:function(){return D.AR}}),Object.defineProperty(e,"AR_SA",{enumerable:!0,get:function(){return D.AR_SA}}),Object.defineProperty(e,"ColumnStore",{enumerable:!0,get:function(){return D.ColumnStore}}),Object.defineProperty(e,"Bitset",{enumerable:!0,get:function(){return D.Bitset}}),Object.defineProperty(e,"Dictionary",{enumerable:!0,get:function(){return D.Dictionary}}),Object.defineProperty(e,"MultiValue",{enumerable:!0,get:function(){return D.MultiValue}}),Object.defineProperty(e,"MaskPool",{enumerable:!0,get:function(){return D.MaskPool}}),Object.defineProperty(e,"sortColumn",{enumerable:!0,get:function(){return D.sortColumn}}),Object.defineProperty(e,"sortMulti",{enumerable:!0,get:function(){return D.sortMulti}}),Object.defineProperty(e,"evaluateFilters",{enumerable:!0,get:function(){return D.evaluateFilters}}),Object.defineProperty(e,"compact",{enumerable:!0,get:function(){return D.compact}}),Object.defineProperty(e,"testValue",{enumerable:!0,get:function(){return D.testValue}}),Object.defineProperty(e,"groupByColumns",{enumerable:!0,get:function(){return D.groupByColumns}}),Object.defineProperty(e,"total",{enumerable:!0,get:function(){return D.total}}),Object.defineProperty(e,"TOTAL_FNS",{enumerable:!0,get:function(){return D.TOTAL_FNS}}),Object.defineProperty(e,"pivot",{enumerable:!0,get:function(){return D.pivot}}),Object.defineProperty(e,"Window",{enumerable:!0,get:function(){return D.Window}}),Object.defineProperty(e,"openWindow",{enumerable:!0,get:function(){return D.openWindow}}),Object.defineProperty(e,"WINDOW_KINDS",{enumerable:!0,get:function(){return D.WINDOW_KINDS}}),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}}),Object.defineProperty(e,"FORECAST_METHODS",{enumerable:!0,get:function(){return D.FORECAST_METHODS}}),Object.defineProperty(e,"forecast",{enumerable:!0,get:function(){return D.forecast}}),Object.defineProperty(e,"evaluateFormula",{enumerable:!0,get:function(){return D.evaluateFormula}}),Object.defineProperty(e,"parseFormula",{enumerable:!0,get:function(){return D.parseFormula}}),Object.defineProperty(e,"referencesOf",{enumerable:!0,get:function(){return D.referencesOf}}),Object.defineProperty(e,"looksLikeFormula",{enumerable:!0,get:function(){return D.looksLikeFormula}}),Object.defineProperty(e,"FormulaError",{enumerable:!0,get:function(){return D.FormulaError}}),Object.defineProperty(e,"FUNCTIONS",{enumerable:!0,get:function(){return D.FUNCTIONS}}),Object.defineProperty(e,"compileRules",{enumerable:!0,get:function(){return D.compileRules}}),Object.defineProperty(e,"ingest",{enumerable:!0,get:function(){return D.ingest}}),Object.defineProperty(e,"ingestSync",{enumerable:!0,get:function(){return D.ingestSync}}),Object.defineProperty(e,"createSource",{enumerable:!0,get:function(){return D.createSource}}),Object.defineProperty(e,"createMemorySource",{enumerable:!0,get:function(){return D.createMemorySource}}),Object.defineProperty(e,"createPagedSource",{enumerable:!0,get:function(){return D.createPagedSource}}),Object.defineProperty(e,"createRemoteSource",{enumerable:!0,get:function(){return D.createRemoteSource}}),Object.defineProperty(e,"createStreamSource",{enumerable:!0,get:function(){return D.createStreamSource}}),Object.defineProperty(e,"createUrlSource",{enumerable:!0,get:function(){return D.createUrlSource}}),Object.defineProperty(e,"PROTOCOL",{enumerable:!0,get:function(){return D.PROTOCOL}}),Object.defineProperty(e,"createPushdownSource",{enumerable:!0,get:function(){return D.createPushdownSource}}),Object.defineProperty(e,"planQuery",{enumerable:!0,get:function(){return D.planQuery}}),Object.defineProperty(e,"splitFilters",{enumerable:!0,get:function(){return D.splitFilters}}),Object.defineProperty(e,"applyResidual",{enumerable:!0,get:function(){return D.applyResidual}}),Object.defineProperty(e,"capabilitiesOf",{enumerable:!0,get:function(){return D.capabilitiesOf}}),Object.defineProperty(e,"resolveMutate",{enumerable:!0,get:function(){return D.resolveMutate}}),Object.defineProperty(e,"NO_CAPABILITIES",{enumerable:!0,get:function(){return D.NO_CAPABILITIES}}),Object.defineProperty(e,"odataAdapter",{enumerable:!0,get:function(){return D.odataAdapter}}),Object.defineProperty(e,"filtersToOData",{enumerable:!0,get:function(){return D.filtersToOData}}),Object.defineProperty(e,"conditionToOData",{enumerable:!0,get:function(){return D.conditionToOData}}),Object.defineProperty(e,"restAdapter",{enumerable:!0,get:function(){return D.restAdapter}}),Object.defineProperty(e,"DEFAULT_PARAMS",{enumerable:!0,get:function(){return D.DEFAULT_PARAMS}}),Object.defineProperty(e,"dfqlAdapter",{enumerable:!0,get:function(){return D.dfqlAdapter}}),Object.defineProperty(e,"duckdbAdapter",{enumerable:!0,get:function(){return D.duckdbAdapter}}),Object.defineProperty(e,"filtersToSql",{enumerable:!0,get:function(){return D.filtersToSql}}),Object.defineProperty(e,"graphqlAdapter",{enumerable:!0,get:function(){return D.graphqlAdapter}}),Object.defineProperty(e,"splunkAdapter",{enumerable:!0,get:function(){return D.splunkAdapter}}),Object.defineProperty(e,"RowModel",{enumerable:!0,get:function(){return D.RowModel}}),Object.defineProperty(e,"createRowKey",{enumerable:!0,get:function(){return D.createRowKey}}),Object.defineProperty(e,"SelectionModel",{enumerable:!0,get:function(){return D.SelectionModel}}),Object.defineProperty(e,"RangeModel",{enumerable:!0,get:function(){return D.RangeModel}}),Object.defineProperty(e,"EditModel",{enumerable:!0,get:function(){return D.EditModel}}),Object.defineProperty(e,"ChangeModel",{enumerable:!0,get:function(){return D.ChangeModel}}),Object.defineProperty(e,"StateModel",{enumerable:!0,get:function(){return D.StateModel}}),Object.defineProperty(e,"STATE_VERSION",{enumerable:!0,get:function(){return D.STATE_VERSION}}),Object.defineProperty(e,"serialiseState",{enumerable:!0,get:function(){return D.serialiseState}}),Object.defineProperty(e,"restoreState",{enumerable:!0,get:function(){return D.restoreState}}),Object.defineProperty(e,"VERSION",{enumerable:!0,get:function(){return D.VERSION}});const s=G("packages/dom/src/renderer/index.js");Object.defineProperty(e,"DomRenderer",{enumerable:!0,get:function(){return s.DomRenderer}});const r=G("packages/dom/src/filtermenu.js");Object.defineProperty(e,"FilterMenu",{enumerable:!0,get:function(){return r.FilterMenu}}),Object.defineProperty(e,"mergeColumnFilter",{enumerable:!0,get:function(){return r.mergeColumnFilter}}),Object.defineProperty(e,"branchFor",{enumerable:!0,get:function(){return r.branchFor}});const o=G("packages/dom/src/columnmenu.js");Object.defineProperty(e,"ColumnMenu",{enumerable:!0,get:function(){return o.ColumnMenu}}),Object.defineProperty(e,"columnMenuItems",{enumerable:!0,get:function(){return o.columnMenuItems}}),Object.defineProperty(e,"cellMenuItems",{enumerable:!0,get:function(){return o.cellMenuItems}}),Object.defineProperty(e,"autoGroupMenuItems",{enumerable:!0,get:function(){return o.autoGroupMenuItems}});const l=G("packages/dom/src/alignedgrids.js");Object.defineProperty(e,"AlignedGrids",{enumerable:!0,get:function(){return l.AlignedGrids}}),Object.defineProperty(e,"alignGrids",{enumerable:!0,get:function(){return l.alignGrids}}),Object.defineProperty(e,"layoutState",{enumerable:!0,get:function(){return l.layoutState}});const a=G("packages/dom/src/toolpanelmount.js");Object.defineProperty(e,"ToolPanelDock",{enumerable:!0,get:function(){return a.ToolPanelDock}}),Object.defineProperty(e,"panelHost",{enumerable:!0,get:function(){return a.panelHost}}),Object.defineProperty(e,"mountPanel",{enumerable:!0,get:function(){return a.mountPanel}});const p=G("packages/dom/src/celledit.js");Object.defineProperty(e,"CellEditController",{enumerable:!0,get:function(){return p.CellEditController}});const m=G("packages/dom/src/editbar.js");Object.defineProperty(e,"EditBar",{enumerable:!0,get:function(){return m.EditBar}});const b=G("packages/dom/src/historybar.js");Object.defineProperty(e,"HistoryBar",{enumerable:!0,get:function(){return b.HistoryBar}}),Object.defineProperty(e,"HISTORY_CLS",{enumerable:!0,get:function(){return b.HISTORY_CLS}});const g=G("packages/dom/src/diffpaint.js");Object.defineProperty(e,"DiffPainter",{enumerable:!0,get:function(){return g.DiffPainter}});const f=G("packages/dom/src/viewpicker.js");Object.defineProperty(e,"ViewPicker",{enumerable:!0,get:function(){return f.ViewPicker}}),Object.defineProperty(e,"VIEW_CLS",{enumerable:!0,get:function(){return f.VIEW_CLS}}),Object.defineProperty(e,"summariseDiff",{enumerable:!0,get:function(){return f.summariseDiff}});const w=G("packages/dom/src/promptbar.js");Object.defineProperty(e,"PromptBar",{enumerable:!0,get:function(){return w.PromptBar}}),Object.defineProperty(e,"PROMPT_CLASS",{enumerable:!0,get:function(){return w.PROMPT_CLASS}});const v=G("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 h=G("packages/dom/src/editors/index.js");Object.defineProperty(e,"editors",{enumerable:!0,get:function(){return h.editors}}),Object.defineProperty(e,"createEditor",{enumerable:!0,get:function(){return h.createEditor}}),Object.defineProperty(e,"editorFor",{enumerable:!0,get:function(){return h.editorFor}}),Object.defineProperty(e,"BaseEditor",{enumerable:!0,get:function(){return h.BaseEditor}});const c=G("packages/dom/src/filters/index.js");Object.defineProperty(e,"filters",{enumerable:!0,get:function(){return c.filters}}),Object.defineProperty(e,"createFilter",{enumerable:!0,get:function(){return c.createFilter}}),Object.defineProperty(e,"filterFor",{enumerable:!0,get:function(){return c.filterFor}}),Object.defineProperty(e,"parseExpression",{enumerable:!0,get:function(){return c.parseExpression}}),Object.defineProperty(e,"ConditionFilter",{enumerable:!0,get:function(){return c.ConditionFilter}});const j=G("packages/dom/src/ui/index.js");Object.defineProperty(e,"StatusBar",{enumerable:!0,get:function(){return j.StatusBar}}),Object.defineProperty(e,"ContextMenu",{enumerable:!0,get:function(){return j.ContextMenu}}),Object.defineProperty(e,"ToolPanel",{enumerable:!0,get:function(){return j.ToolPanel}}),Object.defineProperty(e,"TooltipManager",{enumerable:!0,get:function(){return j.TooltipManager}}),Object.defineProperty(e,"Pagination",{enumerable:!0,get:function(){return j.Pagination}}),Object.defineProperty(e,"OverlayLayer",{enumerable:!0,get:function(){return j.OverlayLayer}});const E=G("packages/core/src/registry/licence.js");Object.defineProperty(e,"setLicense",{enumerable:!0,get:function(){return E.setLicence}}),Object.defineProperty(e,"licenseInfo",{enumerable:!0,get:function(){return E.licenceInfo}}),Object.defineProperty(e,"licenseState",{enumerable:!0,get:function(){return E.licenceState}});const O=Object.freeze({createGrid:M,createHeadlessGrid:I,defaults:t,registerModules:k,setLicence:S,version:y,autoInit:Z,hydrateTable:R,serialiseState:u,restoreState:n,createLocalViewStorage:U}),T=O});try{Un("packages/worker/src/inline.js").setWorkerSource('(function(yt){"use strict";var nt=Object.create(null),rt=Object.create(null);function Se(o,me){nt[o]=me}function it(o){var me=rt[o];if(me)return me;var fe=Object.create(null);rt[o]=fe;var he=nt[o];if(!he)throw new Error("[lattice] missing module: "+o);return he(fe,it),fe}Se("packages/core/src/internal/util.js",function(o,me){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return H}});const fe="1.75.0";async function he(){return fe}const X="1.75.0",z=new Set,te=2e3;function x(w){if(z.add(w),z.size>te){const A=z.values().next().value;A!==void 0&&z.delete(A)}}const T=[],K=500;function re(w,A,q){T.push({key:w,level:A,message:q.map(le=>typeof le=="string"?le:J(le)).join(" "),at:Date.now()}),T.length>K&&T.shift()}function J(w){if(w instanceof Error)return w.message;try{return JSON.stringify(w)}catch{return String(w)}}function ue(){return T.map(w=>({...w}))}function oe(w,...A){z.has(w)||(x(w),re(w,"warn",A),console.warn("[lattice]",...A))}function Y(w,...A){z.has(w)||(x(w),re(w,"info",A),console.info("[lattice]",...A))}function L(){z.clear(),T.length=0}function Q(w,A){const q=new Error(`[lattice] ${w}`);throw A!==void 0&&(q.cause=A),q}function _(w,A){w||Q(A)}const C=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function M(w){return w!==null&&typeof w=="object"&&!Array.isArray(w)}function i(w){return typeof w=="function"}function s(w){return w==null}function u(w){return w==null||w===""}function f(w){return typeof w!="function"?!1:/^class[\\s{]/.test(Function.prototype.toString.call(w))?!0:!!(w.prototype&&Object.getOwnPropertyNames(w.prototype).length>1)}const c=new Map;function t(w){let A=c.get(w);if(A)return A;if(!w.includes("."))A=q=>q?.[w];else{const q=w.split("."),le=q.length;A=ae=>{let de=ae;for(let pe=0;pe<le;pe++){if(de==null)return;de=de[q[pe]]}return de}}return c.set(w,A),A}const a=new Map;function m(w){let A=a.get(w);if(A)return A;if(!w.includes("."))A=(q,le)=>{q!=null&&(q[w]=le)};else{const q=w.split("."),le=q.length-1;A=(ae,de)=>{let pe=ae;for(let ge=0;ge<le;ge++){if(pe==null)return;const ke=q[ge];pe[ke]==null&&(pe[ke]={}),pe=pe[ke]}pe!=null&&(pe[q[le]]=de)}}return a.set(w,A),A}function e(w,A){return t(A)(w)}function d(w,A,q){m(A)(w,q)}function h(w){return w?(w.includes(".")?w.slice(w.lastIndexOf(".")+1):w).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\\s+/g," ").trim().replace(/^./,q=>q.toUpperCase()):""}const r={"&":"&amp;","<":"&lt;",">":"&gt;",\'"\':"&quot;","\'":"&#39;"};function n(w){const A=w==null?"":String(w);return/[&<>"\']/.test(A)?A.replace(/[&<>"\']/g,q=>r[q]):A}function l(w){return String(w).replace(/\\w\\S*/g,A=>A[0].toUpperCase()+A.slice(1).toLowerCase())}function g(w,A,q){if(w!==void 0)return w===!0?{enabled:!0,...q}:w===!1?{enabled:!1}:M(w)?w:{[A]:w,enabled:!0}}function P(w){return w==null?[]:Array.isArray(w)?w:[w]}const S=Object.freeze(new Set(["__proto__","constructor","prototype"]));function G(w,A){if(!M(w))return M(A)?{...A}:A;if(!M(A))return A===void 0?w:A;const q={...w};for(const le of Object.keys(A)){if(S.has(le))continue;const ae=A[le];ae!==void 0&&(q[le]=M(ae)&&M(q[le])?G(q[le],ae):ae)}return q}function F(w,A){if(!M(w)||!M(A)||w===A)return A;const q=Object.create(Object.getPrototypeOf(w));return Object.assign(q,w,A),q}class E{#t;#e=new Map;#n;constructor(A=256,q=null){this.#t=A,this.#n=q}get size(){return this.#e.size}get max(){return this.#t}set max(A){this.#t=A,this.#r()}has(A){return this.#e.has(A)}get(A){const q=this.#e;if(!q.has(A))return;const le=q.get(A);return q.delete(A),q.set(A,le),le}peek(A){return this.#e.get(A)}set(A,q){const le=this.#e;return le.has(A)&&le.delete(A),le.set(A,q),this.#r(),q}delete(A){const q=this.#e.get(A);return this.#e.delete(A)&&this.#n&&this.#n(q,A),q}clear(){if(this.#n)for(const[A,q]of this.#e)this.#n(q,A);this.#e.clear()}keys(){return this.#e.keys()}values(){return this.#e.values()}#r(){const A=this.#e;for(;A.size>this.#t;){const q=A.keys().next().value,le=A.get(q);A.delete(q),this.#n&&this.#n(le,q)}}}const Z=new Map;function R(w,A){const q=`${w||""}|${A?JSON.stringify(A):""}`;let le=Z.get(q);return le||(le=new Intl.Collator(w||void 0,{numeric:!0,sensitivity:"variant",...A}),Z.set(q,le)),le}function v(w,A){if(w===A)return 0;if(w==null)return 1;if(A==null)return-1;if(typeof w=="number"&&typeof A=="number")return Number.isNaN(w)?Number.isNaN(A)?0:1:Number.isNaN(A)||w<A?-1:w>A?1:0;const q=String(w),le=String(A);return q<le?-1:q>le?1:0}function U(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const V=typeof requestAnimationFrame=="function";function $(w){return V?requestAnimationFrame(w):setTimeout(()=>w(U()),16)}function ee(w){w!=null&&(V?cancelAnimationFrame(w):clearTimeout(w))}function ne(w){let A=null,q=null;const le=()=>{A=null;const de=q;q=null,w(...de||[])},ae=(...de)=>{q=de,A===null&&(A=$(le))};return ae.cancel=()=>{ee(A),A=null,q=null},ae.flush=()=>{A!==null&&(ee(A),le())},ae}function ce(w,A){let q=null,le=null;const ae=()=>{if(q=null,le===null)return;const ge=le;le=null,w(...ge),de()},de=()=>{q=setTimeout(ae,A),typeof q?.unref=="function"&&q.unref()},pe=(...ge)=>{q===null?(w(...ge),de()):(le=ge,clearTimeout(q),de())};return pe.flush=()=>{if(q!==null&&clearTimeout(q),q=null,le===null)return;const ge=le;le=null,w(...ge)},pe.cancel=()=>{q!==null&&clearTimeout(q),q=null,le=null},pe.pending=()=>q!==null||le!==null,pe}function p(w,A=50){return typeof requestIdleCallback=="function"?requestIdleCallback(w,{timeout:A}):setTimeout(()=>w({timeRemaining:()=>0,didTimeout:!0}),1)}let B=0;function H(w="l"){return`${w}${(++B).toString(36)}`}}),Se("packages/worker/src/transport.js",function(o,me){"use strict";Object.defineProperty(o,"PROTOCOL",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"OPS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"CONTROL",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"ERRORS",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"packHandle",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"packHandles",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"TransportedDictionary",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"unpackHandle",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"unpackHandles",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"createMaskPool",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"isTransferable",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"collectTransfers",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isPortable",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"filterColumnIds",{enumerable:!0,get:function(){return i}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.isFunction,z=1,te=Object.freeze({SORT_COLUMN:"sortColumn",SORT_MULTI:"sortMulti",EVALUATE_FILTERS:"evaluateFilters",COMPACT:"compact",GROUP_BY_COLUMNS:"groupByColumns",TOTAL:"total",PIVOT:"pivot",FACET:"facet",COLUMNIZE:"columnize",COLLATE_STRING_RANKS:"collateStringRanks"}),x=Object.freeze({READY:"ready",CANCEL:"cancel",PING:"ping"}),T=Object.freeze({NO_COMPUTE:"E_NO_COMPUTE",NO_KERNEL:"E_NO_KERNEL",ABORTED:"E_ABORTED",KERNEL:"E_KERNEL",PROTOCOL:"E_PROTOCOL"});function K(s){if(s==null)return null;const u=s.presence;return{id:s.id,kind:s.kind,nullable:!!s.nullable,values:s.values??null,presence:u?u.words??u:null,presenceBits:u?u.size??(u.words??u).length*8:0,dict:s.dict?re(s.dict):null,offsets:s.offsets??null,version:s.version??0}}function re(s){return Array.isArray(s)?s:X(s.values)?s.values():[]}function J(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=K(s[f]);return u}class ue{#t;#e;constructor(u,f){this.#t=u,this.#e=f}get words(){return this.#t}get size(){return this.#e}get(u){return(this.#t[u>>>3]&1<<(u&7))!==0}count(){const u=this.#t;let f=0;for(let c=0;c<u.length;c++){let t=u[c];for(;t;)t&=t-1,f++}return f}}class oe{#t;#e=null;#n=0;#r=new Map;constructor(u){this.#t=u||[]}get size(){return this.#t.length}get version(){return this.#n}codeOf(u){if(this.#e===null){this.#e=new Map;for(let t=0;t<this.#t.length;t++)this.#e.set(this.#t[t],t)}const f=this.#e.get(u);if(f!==void 0)return f;const c=this.#t.length;return this.#t.push(u),this.#e.set(u,c),this.#n++,c}valueOf(u){return this.#t[u]}values(){return this.#t}ranks(u){const f=u||"",c=this.#r.get(f);if(c&&c.version===this.#n)return c.ranks;const t=this.#t.length,a=new Uint32Array(t);for(let r=0;r<t;r++)a[r]=r;const m=he(u).compare,e=this.#t,d=Array.from(a).sort((r,n)=>{const l=e[r],g=e[n];return l===g?0:l==null?1:g==null?-1:m(String(l),String(g))}),h=new Uint32Array(t);for(let r=0;r<d.length;r++)h[d[r]]=r;return this.#r.set(f,{version:this.#n,ranks:h}),h}}function Y(s){if(s==null)return null;const u=s.presence?new ue(s.presence,s.presenceBits||s.presence.length*8):null,f=s.dict?new oe(s.dict):null,c=s.values,t=s.offsets??null,a=s.kind,m=e=>{if(u&&!u.get(e))return null;switch(a){case"dictionary":return f?f.valueOf(c[e]):c[e];case"bitset":return(c[e>>>3]&1<<(e&7))!==0;case"multi":{if(!t)return null;const d=t[e],h=t[e+1],r=new Array(h-d);for(let n=d;n<h;n++)r[n-d]=f?f.valueOf(c[n]):c[n];return r}default:return c[e]}};return{id:s.id,kind:a,nullable:s.nullable,values:c,presence:u,dict:f,offsets:t,get:m,version:s.version}}function L(s){const u=new Array(s.length);for(let f=0;f<s.length;f++)u[f]=Y(s[f]);return u}function Q(){const s=[],u=[];return{mask(f){for(let c=0;c<s.length;c++)if(s[c].length>=f){const t=s.splice(c,1)[0].subarray(0,f);return t.fill(0),t}return new Uint8Array(f)},indices(f){for(let c=0;c<u.length;c++)if(u[c].length>=f)return u.splice(c,1)[0].subarray(0,f);return new Uint32Array(f)},release(f){f&&(f instanceof Uint8Array?s.push(f):f instanceof Uint32Array&&u.push(f))},clear(){s.length=0,u.length=0}}}function _(s){if(!ArrayBuffer.isView(s))return!1;const u=s.buffer;return u?typeof SharedArrayBuffer>"u"||!(u instanceof SharedArrayBuffer):!1}function C(s,u=[]){const f=c=>{if(!_(c))return;const t=c.buffer;u.includes(t)||u.push(t)};if(s==null)return u;if(ArrayBuffer.isView(s))return f(s),u;if(Array.isArray(s)){for(const c of s)f(c);return u}if(typeof s=="object")for(const c of Object.keys(s)){const t=s[c];if(Array.isArray(t))for(const a of t)f(a);else f(t)}return u}function M(s,u=0){if(s==null)return!0;const f=typeof s;if(f==="function"||f==="symbol")return!1;if(f!=="object"||u>4||ArrayBuffer.isView(s)||s instanceof ArrayBuffer||s instanceof Date)return!0;if(Array.isArray(s)){for(const c of s)if(!M(c,u+1))return!1;return!0}for(const c of Object.keys(s))if(!M(s[c],u+1))return!1;return!0}function i(s,u=new Set){if(!s||typeof s!="object")return u;const f=s;typeof f.col=="string"&&u.add(f.col);const c=f.conditions;if(Array.isArray(c))for(const t of c)i(t,u);return u}}),Se("packages/core/src/store/bitset.js",function(o,me){"use strict";Object.defineProperty(o,"Bitset",{enumerable:!0,get:function(){return he}});const fe=8;class he{static#t=new Uint8Array(256);static{for(let z=1;z<256;z++)he.#t[z]=he.#t[z>>1]+(z&1)}#e;#n;constructor(z=0){const te=Math.max(0,z|0);this.#n=te,this.#e=new Uint8Array(Math.ceil(te/fe))}get size(){return this.#n}get words(){return this.#e}get bytes(){return this.#e?this.#e.byteLength:0}get(z){return z<0||z>=this.#n?0:this.#e[z>>3]>>(z&7)&1}set(z){return z>=0&&z<this.#n&&(this.#e[z>>3]|=1<<(z&7)),this}clear(z){return z>=0&&z<this.#n&&(this.#e[z>>3]&=~(1<<(z&7))),this}assign(z,te){return te?this.set(z):this.clear(z)}fill(z=!1){return this.#e.fill(z?255:0),z&&this.#r(),this}grow(z){const te=Math.max(0,z|0);if(te<=this.#n)return this;const x=Math.ceil(te/fe);if(x>this.#e.length){const T=new Uint8Array(x);T.set(this.#e),this.#e=T}return this.#n=te,this}count(){const z=this.#e,te=he.#t;let x=0;for(let T=0;T<z.length;T++)x+=te[z[T]];return x}and(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]&=te[K];for(let K=T;K<x.length;K++)x[K]=0;return this}or(z){const te=z instanceof he?z.words:z,x=this.#e,T=Math.min(x.length,te.length);for(let K=0;K<T;K++)x[K]|=te[K];return this}not(){const z=this.#e;for(let te=0;te<z.length;te++)z[te]=~z[te]&255;return this.#r(),this}clone(){const z=new he(this.#n);return z.words.set(this.#e.subarray(0,z.words.length)),z}release(){this.#e=new Uint8Array(0),this.#n=0}#r(){const z=this.#n&7;if(z===0)return;const te=this.#n>>3;te<this.#e.length&&(this.#e[te]&=(1<<z)-1)}static from(z){const te=Array.isArray(z)?z:Array.from(z),x=new he(te.length);for(let T=0;T<te.length;T++)te[T]&&x.set(T);return x}}}),Se("packages/core/src/store/dictionary.js",function(o,me){"use strict";Object.defineProperty(o,"Dictionary",{enumerable:!0,get:function(){return z}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare;class z{#t;#e=new Map;#n=0;#r=null;#i=-1;#s="\\0";constructor(x=[]){this.#t=[];for(let T=0;T<x.length;T++){const K=x[T];this.#e.has(K)||(this.#e.set(K,this.#t.length),this.#t.push(K))}}get size(){return this.#t.length}get version(){return this.#n}get bytes(){let x=this.#t.length*8;for(let T=0;T<this.#t.length;T++){const K=this.#t[T];typeof K=="string"&&(x+=K.length*2),x+=16}return x}codeOf(x){const T=this.#e.get(x);if(T!==void 0)return T;const K=this.#t.length;return this.#t.push(x),this.#e.set(x,K),this.#n++,K}lookup(x){const T=this.#e.get(x);return T===void 0?-1:T}has(x){return this.#e.has(x)}valueOf(x){return this.#t[x]}values(){return this.#t}ranks(x){const T=x||"";if(this.#r&&this.#i===this.#n&&this.#s===T)return this.#r;const K=this.#t.length,re=new Array(K);for(let Y=0;Y<K;Y++)re[Y]=Y;const J=he(x).compare,ue=this.#t;re.sort((Y,L)=>this.#h(ue[Y],ue[L],J));const oe=new Uint32Array(K);for(let Y=0;Y<K;Y++)oe[re[Y]]=Y;return this.#r=oe,this.#i=this.#n,this.#s=T,oe}#h(x,T,K){return typeof x=="string"&&typeof T=="string"?K(x,T):X(x,T)}}}),Se("packages/core/src/store/multivalue.js",function(o,me){"use strict";Object.defineProperty(o,"MultiValue",{enumerable:!0,get:function(){return fe}});class fe{#t;#e;#n=0;#r=0;constructor(X={}){const z=Math.max(1,X.rows??16),te=Math.max(1,X.values??z);this.#t=new Int32Array(te),this.#e=new Uint32Array(z+1)}get values(){return this.#t}get offsets(){return this.#e}get rows(){return this.#n}get length(){return this.#r}get bytes(){return this.#t.byteLength+this.#e.byteLength}count(X){return X<0||X>=this.#n?0:this.#e[X+1]-this.#e[X]}at(X){return X<0||X>=this.#n?this.#t.subarray(0,0):this.#t.subarray(this.#e[X],this.#e[X+1])}has(X,z){if(X<0||X>=this.#n)return!1;const te=this.#t,x=this.#e[X+1];for(let T=this.#e[X];T<x;T++)if(te[T]===z)return!0;return!1}hasAny(X,z){for(let te=0;te<z.length;te++)if(this.has(X,z[te]))return!0;return!1}hasAll(X,z){for(let te=0;te<z.length;te++)if(!this.has(X,z[te]))return!1;return!0}hasNone(X,z){return!this.hasAny(X,z)}push(X){const z=this.#n,te=X.length;this.#i(z+1),this.#s(this.#r+te);const x=this.#r;for(let T=0;T<te;T++)this.#t[x+T]=X[T]|0;return this.#r+=te,this.#n=z+1,this.#e[z]=x,this.#e[z+1]=this.#r,z}write(X,z){if(X===this.#n){this.push(z);return}if(X<0||X>this.#n)return;const te=this.#e[X],x=this.#e[X+1],T=z.length;if(x-te===T){for(let K=0;K<T;K++)this.#t[te+K]=z[K]|0;return}this.#h(X,z)}compact(X,z,te){const x=this.#t,T=this.#e,K=this.#n,re=new Int32Array(Math.max(1,this.#r)),J=new Uint32Array(z+1);let ue=0;for(let oe=0;oe<K;oe++){if(X[oe]===te)continue;const Y=T[oe],L=T[oe+1];J[X[oe]]=ue;for(let Q=Y;Q<L;Q++)re[ue++]=x[Q];J[X[oe]+1]=ue}this.#t=re,this.#e=J,this.#n=z,this.#r=ue}release(){this.#t=new Int32Array(0),this.#e=new Uint32Array(1),this.#n=0,this.#r=0}#i(X){if(X+1<=this.#e.length)return;let z=this.#e.length-1;for(;z<X;)z=z*2||16;const te=new Uint32Array(z+1);te.set(this.#e),this.#e=te}#s(X){if(X<=this.#t.length)return;let z=this.#t.length;for(;z<X;)z=z*2||16;const te=new Int32Array(z);te.set(this.#t),this.#t=te}#h(X,z){const te=this.#t,x=this.#e,T=this.#n,K=z.length-(x[X+1]-x[X]),re=new Int32Array(Math.max(1,this.#r+K)),J=new Uint32Array(x.length);let ue=0;for(let oe=0;oe<T;oe++){if(J[oe]=ue,oe===X)for(let Y=0;Y<z.length;Y++)re[ue++]=z[Y]|0;else for(let Y=x[oe];Y<x[oe+1];Y++)re[ue++]=te[Y];J[oe+1]=ue}this.#t=re,this.#e=J,this.#r=ue}}}),Se("packages/core/src/compute/handle.js",function(o,me){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return M}});const fe=me("packages/core/src/internal/util.js"),he=fe.collator,X=fe.defaultCompare,z=fe.warnOnce;function te(i){const s=new Uint32Array(i);for(let u=0;u<i;u++)s[u]=u;return s}function x(i,s){if(s&&typeof s.count=="number")return s.count;if(!i)return 0;if(typeof i.count=="number")return i.count;if(typeof i.length=="number")return i.length;const u=i.values;return i.kind==="multi"&&i.offsets?Math.max(0,i.offsets.length-1):u?i.kind==="bitset"?typeof u.size=="number"?u.size:i.presence&&typeof i.presence.size=="number"?i.presence.size:(z(`count:${i.id}`,`column "${i.id}" is bitset-backed with no declared row count; assuming ${u.length*8}`),u.length*8):u.length:i.presence&&typeof i.presence.size=="number"?i.presence.size:0}const T=new WeakMap;function K(i){const s=i.constructor;if(!s)return"unknown";const u=T.get(s);if(u)return u;let f="unknown";try{let c=null;typeof s.from=="function"?c=s.from([!1,!0]):(c=new s(8),c.set(1));const t=c&&c.words;t&&t.length&&(t[0]===2?f="lsb":t[0]===64&&(f="msb"))}catch{f="unknown"}return T.set(s,f),f}function re(i){if(!i)return()=>0;const s=i instanceof Uint8Array?i:i.words;if(s instanceof Uint8Array){const u=i instanceof Uint8Array?"lsb":K(i);if(u==="lsb")return f=>s[f>>>3]>>>(f&7)&1;if(u==="msb")return f=>s[f>>>3]>>>7-(f&7)&1}return typeof i.get=="function"?u=>i.get(u)?1:0:()=>0}function J(i){return!i||!i.presence?null:re(i.presence)}function ue(i){return i?typeof i.size=="number"?i.size:typeof i.values=="function"?i.values().length:0:0}function oe(i,s){return i?typeof i.valueOf=="function"?i.valueOf(s):typeof i.values=="function"?i.values()[s]:null:null}function Y(i,s){const u=i.offsets,f=i.values;if(!u||!f)return[];const c=u[s],t=u[s+1];if(!(t>c))return[];const a=i.dict,m=new Array(t-c);for(let e=c;e<t;e++)m[e-c]=a?oe(a,f[e]):f[e];return m}function L(i){if(!i)return()=>{};const s=i.values,u=J(i),f=i.kind;if(f==="dictionary"){const c=i.dict;return u?t=>u(t)?oe(c,s[t]):null:t=>oe(c,s[t])}if(f==="bitset"){const c=re(s);return u?t=>u(t)?c(t)===1:null:t=>c(t)===1}if(f==="multi")return u?c=>u(c)?Y(i,c):null:c=>Y(i,c);if(!s&&typeof i.get=="function"){const c=i.get.bind(i);return t=>{const a=c(t);return a===void 0?null:a}}return u?c=>{if(!u(c))return null;const t=s[c];return t===void 0?null:t}:c=>{const t=s[c];return t===void 0?null:t}}function Q(i,s){if(i<s)return-1;if(i>s)return 1;if(i===s){const c=Object.is(i,-0),t=Object.is(s,-0);return c===t?0:c?-1:1}const u=Number.isNaN(i),f=Number.isNaN(s);return u&&f?0:u?1:-1}function _(i){const s=he(i);return(u,f)=>{if(u===f)return 0;const c=typeof u,t=typeof f;if(c==="string"&&t==="string")return s.compare(u,f);if(c==="number"&&t==="number")return Q(u,f);if(c==="boolean"&&t==="boolean")return u===f?0:u?1:-1;if(u instanceof Date||f instanceof Date){const a=u instanceof Date?u.getTime():Number(u),m=f instanceof Date?f.getTime():Number(f);return Q(a,m)}return X(u,f)}}function C(i,s){if(i&&typeof i.ranks=="function")return i.ranks(s);const u=i&&typeof i.values=="function"?i.values():[],f=u.length,c=_(s),t=new Array(f);for(let m=0;m<f;m++)t[m]=m;t.sort((m,e)=>c(u[m],u[e])||m-e);const a=new Uint32Array(f);for(let m=0;m<f;m++)a[t[m]]=m;return a}function M(i){return i==null||typeof i=="number"&&Number.isNaN(i)}}),Se("packages/core/src/compute/sort.js",function(o,me){"use strict";Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return E}});const fe=me("packages/core/src/compute/handle.js"),he=fe.bitReader,X=fe.dictRanks,z=fe.dictSize,te=fe.identity,x=fe.isMissing,T=fe.presenceReader,K=fe.rowCount,re=fe.valueComparator,J=fe.valueReader,ue=new Uint32Array(0),oe=new ArrayBuffer(8),Y=new Float64Array(oe),L=new Uint32Array(oe),Q=(Y[0]=-1,(L[1]&2147483648)!==0?1:0),_=Q===1?0:1;function C(R,v){Y[0]=R;let U=L[Q],V=L[_];(U&2147483648)!==0?(U=~U>>>0,V=~V>>>0):U=(U^2147483648)>>>0,v[0]=V,v[1]=U}function M(R,v,U,V){if(V<2)return R;const $=new Uint32Array(256*8);for(let A=0;A<V;A++){const q=v[A],le=U[A];$[q&255]++,$[256+(q>>>8&255)]++,$[512+(q>>>16&255)]++,$[768+(q>>>24&255)]++,$[1024+(le&255)]++,$[1280+(le>>>8&255)]++,$[1536+(le>>>16&255)]++,$[1792+(le>>>24&255)]++}let ee=R,ne=v,ce=U,p=new Uint32Array(V),B=new Uint32Array(V),H=new Uint32Array(V);const w=new Uint32Array(256);for(let A=0;A<8;A++){const q=A<<8,le=(A&3)<<3,ae=A>=4;let de=!1;for(let ke=0;ke<256;ke++)if($[q+ke]===V){de=!0;break}if(de)continue;let pe=0;for(let ke=0;ke<256;ke++)w[ke]=pe,pe+=$[q+ke];for(let ke=0;ke<V;ke++){const Le=ne[ke],Re=ce[ke],Be=(ae?Re:Le)>>>le&255,ze=w[Be]++;p[ze]=ee[ke],B[ze]=Le,H[ze]=Re}let ge=ee;ee=p,p=ge,ge=ne,ne=B,B=ge,ge=ce,ce=H,H=ge}return ee}function i(R,v,U){if(U<2)return R;const V=new Uint32Array(256*4);for(let B=0;B<U;B++){const H=v[B];V[H&255]++,V[256+(H>>>8&255)]++,V[512+(H>>>16&255)]++,V[768+(H>>>24&255)]++}let $=R,ee=v,ne=new Uint32Array(U),ce=new Uint32Array(U);const p=new Uint32Array(256);for(let B=0;B<4;B++){const H=B<<8,w=B<<3;let A=!1;for(let ae=0;ae<256;ae++)if(V[H+ae]===U){A=!0;break}if(A)continue;let q=0;for(let ae=0;ae<256;ae++)p[ae]=q,q+=V[H+ae];for(let ae=0;ae<U;ae++){const de=ee[ae],pe=p[de>>>w&255]++;ne[pe]=$[ae],ce[pe]=de}let le=$;$=ne,ne=le,le=ee,ee=ce,ce=le}return $}function s(R,v,U,V){const $=new Uint32Array(V+1);for(let ce=0;ce<U;ce++)$[v[ce]]++;let ee=0;for(let ce=0;ce<=V;ce++){const p=$[ce];$[ce]=ee,ee+=p}const ne=new Uint32Array(U);for(let ce=0;ce<U;ce++)ne[$[v[ce]]++]=R[ce];return ne}function u(R,v,U,V){return U<2?R:V<=65536||V<=U*2?s(R,v,U,V):i(R,v,U)}function f(R,v){return R.length===v&&R.byteOffset===0?R:Uint32Array.prototype.slice.call(R,0,v)}function c(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=new Uint32Array($),ne=new Uint32Array($),ce=new Uint32Array($),p=new Uint32Array($),B=new Uint32Array(2);let H=0,w=0;for(let le=0;le<$;le++){const ae=V[le],de=R[ae];if(Number.isNaN(de)){p[w++]=ae;continue}C(de,B),U?(ne[H]=~B[0]>>>0,ce[H]=~B[1]>>>0):(ne[H]=B[0],ce[H]=B[1]),ee[H++]=ae}const A=M(ee.subarray(0,H),ne.subarray(0,H),ce.subarray(0,H),H);if(w===0)return f(A,H);const q=new Uint32Array($);return q.set(A.subarray(0,H),0),q.set(p.subarray(0,w),H),q}function t(R,v,U=!1){const V=v||te(R.length),$=V.length;if($<2)return Uint32Array.from(V);const ee=Uint32Array.from(V),ne=new Uint32Array($);for(let ce=0;ce<$;ce++){const p=(R[ee[ce]]^2147483648)>>>0;ne[ce]=U?~p>>>0:p}return f(i(ee,ne,$),$)}function a(R,v,U={}){const V=v||te(K(R,U)),$=V.length;if($<2)return Uint32Array.from(V);const ee=X(R.dict,U.locale),ne=R.values,ce=T(R),p=Math.max(z(R.dict),ee.length),B=p,H=Uint32Array.from(V),w=new Uint32Array($),A=!!U.descending;for(let q=0;q<$;q++){const le=H[q];let ae=ce&&ce(le)===0?B:ee[ne[le]];ae===void 0&&(ae=B),w[q]=A?B-ae:ae}return f(u(H,w,$,p+1),$)}function m(R,v,U){const V=v.length;let $=Uint32Array.from(v);if(V<2)return $;let ee=new Uint32Array(V);for(let ne=1;ne<V;ne<<=1){for(let p=0;p<V;p+=ne<<1){const B=Math.min(p+ne,V),H=Math.min(p+(ne<<1),V);let w=p,A=B,q=p;for(;w<B&&A<H;)ee[q++]=U(R[$[w]],R[$[A]])<=0?$[w++]:$[A++];for(;w<B;)ee[q++]=$[w++];for(;A<H;)ee[q++]=$[A++]}const ce=$;$=ee,ee=ce}return $}function e(R,v,U){const V=he(R.values),$=v.length,ee=new Uint32Array($),ne=U?1:0;let ce=0;for(let p=0;p<$;p++)V(v[p])===ne&&(ee[ce++]=v[p]);for(let p=0;p<$;p++)V(v[p])!==ne&&(ee[ce++]=v[p]);return ee}function d(R,v){const U=R.values,V=R.kind;if((V==="object"||V===void 0)&&(Array.isArray(U)||ArrayBuffer.isView(U))&&!R.presence)return U;const ee=J(R),ne=new Array(K(R)||0);for(let ce=0;ce<v.length;ce++){const p=v[ce];ne[p]=ee(p)}return ne}function h(R,v){for(let U=0;U<v.length;U++)if(typeof R[v[U]]!="string")return!1;return!0}function r(R,v,U,V,$){const ee=R.length,ne=Uint32Array.from(R);if(ee<2||V<1)return ne;const ce=new Uint32Array(ee),p=V-1;for(let B=0;B<ee;B++){const H=U[v[B]];ce[B]=$?p-H:H}return f(u(ne,ce,ee,V),ee)}function n(R,v,U){const V=re(U),$=new Array(v);for(let ne=0;ne<v;ne++)$[ne]=ne;$.sort((ne,ce)=>V(R[ne],R[ce])||ne-ce);const ee=new Uint32Array(v);for(let ne=0;ne<v;ne++)ee[$[ne]]=ne;return ee}function l(R,v,U){const V=v.length,$=new Map,ee=[],ne=new Uint32Array(V);for(let B=0;B<V;B++){const H=R[v[B]];let w=$.get(H);w===void 0&&(w=ee.length,$.set(H,w),ee.push(H)),ne[B]=w}const ce=ee.length,p=n(ee,ce,U.locale);return r(v,ne,p,ce,!!U.descending)}function g(R,v,U){const V=d(R,v);if(v.length>=2&&h(V,v)){const ne=R.stringRank;return ne&&ne.version===R.version&&ne.usable(v,V,U.locale)?ne.sort(v,U):l(V,v,U)}const $=re(U.locale),ee=U.descending?(ne,ce)=>$(ce,ne):$;return m(V,v,ee)}function P(R,v,U){const V=d(R,v),$=U.compare,ne=!!U.descending?(ce,p)=>-$(ce,p,void 0,void 0,!0):(ce,p)=>$(ce,p,void 0,void 0,!1);return m(V,v,ne)}function S(R,v){const U=v.length,V=T(R),$=R.values,ee=R.kind==="float64"&&!!$,ne=R.kind==="object"||R.kind==="multi"||R.kind===void 0;if(!V&&!ee&&!ne)return{present:v,absent:ue};const ce=new Uint32Array(U),p=new Uint32Array(U);let B=0,H=0;if(V&&ee)for(let w=0;w<U;w++){const A=v[w];V(A)===1&&!Number.isNaN($[A])?ce[B++]=A:p[H++]=A}else if(ee&&!V)for(let w=0;w<U;w++){const A=v[w];Number.isNaN($[A])?p[H++]=A:ce[B++]=A}else if(V&&!ne)for(let w=0;w<U;w++){const A=v[w];V(A)===1?ce[B++]=A:p[H++]=A}else{const w=J(R);for(let A=0;A<U;A++){const q=v[A];x(w(q))?p[H++]=q:ce[B++]=q}}return H===0?{present:v,absent:ue}:{present:ce.subarray(0,B),absent:p.subarray(0,H)}}function G(R,v,U){if(v.length===0)return R;const V=new Uint32Array(R.length+v.length);return U?(V.set(v,0),V.set(R,v.length)):(V.set(R,0),V.set(v,R.length)),V}function F(R,v,U={}){const V=v||te(K(R,U));if(!R||V.length<2)return Uint32Array.from(V);const{present:$,absent:ee}=S(R,V);if($.length===0)return Uint32Array.from(V);const ne=!!U.descending;let ce;if(typeof U.compare=="function")ce=P(R,$,U);else switch(R.kind){case"float64":ce=c(R.values,$,ne);break;case"int32":ce=t(R.values,$,ne);break;case"dictionary":ce=a(R,$,U);break;case"bitset":ce=e(R,$,ne);break;default:ce=g(R,$,U);break}return G(ce,ee,!!U.nullsFirst)}function E(R,v,U,V={}){const $=v||[],ee=$.length&&($[0].handle||Z(R,$[0].col))||R&&R[0];let ne=U||te(K(ee,V));for(let ce=$.length-1;ce>=0;ce--){const p=$[ce],B=p.handle||Z(R,p.col)||R&&R[ce];B&&(ne=F(B,ne,{descending:p.descending!==void 0?!!p.descending:p.dir==="desc",nullsFirst:!!p.nullsFirst,locale:p.locale!==void 0?p.locale:V.locale,compare:p.compare}))}return ne instanceof Uint32Array?ne:Uint32Array.from(ne)}function Z(R,v){if(!(!R||v===void 0)){for(let U=0;U<R.length;U++)if(R[U]&&R[U].id===v)return R[U]}}}),Se("packages/core/src/store/stringrank.js",function(o,me){"use strict";Object.defineProperty(o,"DEFAULT_MAX_DISTINCT",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"StringRankIndex",{enumerable:!0,get:function(){return te}});const fe=me("packages/core/src/compute/sort.js"),he=fe.collateStringRanks,X=fe.rankSortStrings,z=1e5;class te{#t=[];#e=new Map;#n;#r=0;#i=0;#s=-1;#h;#u=!1;#o=null;#c=-1;#l="\\0";constructor(T=z){this.#h=T>0?T:z,this.#n=new Uint32Array(0)}get version(){return this.#s}set version(T){this.#s=T}get generation(){return this.#i}get size(){return this.#t.length}get capped(){return this.#u}get length(){return this.#r}get bytes(){let T=this.#n.byteLength;const K=this.#t;for(let re=0;re<K.length;re++)T+=K[re].length*2+24;return T}#a(T,K){const re=this.#e.get(T);if(re!==void 0)return re;if(this.#u)return-1;if(K&&this.#t.length>=this.#h)return this.#u=!0,-1;const J=this.#t.length;return this.#t.push(T),this.#e.set(T,J),this.#i++,J}build(T,K){const re=K|0;this.#t=[],this.#e=new Map,this.#i=0,this.#u=!1,this.#o=null,this.#c=-1,this.#n=new Uint32Array(re);for(let J=0;J<re;J++){const ue=T[J],oe=typeof ue=="string"?this.#a(ue,!1):-1;this.#n[J]=oe<0?0:oe}this.#r=re}append(T,K,re){const J=(K|0)+(re|0);if(J>this.#n.length){const ue=new Uint32Array(J);ue.set(this.#n.subarray(0,this.#r)),this.#n=ue}for(let ue=K|0;ue<J;ue++){const oe=T[ue],Y=typeof oe=="string"?this.#a(oe,!0):-1;this.#n[ue]=Y<0?0:Y}this.#r=Math.max(this.#r,J)}ranks(T){const K=T||"";if(this.#o&&this.#c===this.#i&&this.#l===K)return this.#o;const re=he(this.#t,this.#t.length,T);return this.#o=re,this.#c=this.#i,this.#l=K,re}usable(T,K,re){if(this.#u||this.#t.length===0)return!1;const J=this.#n,ue=this.#t,oe=this.#r;for(let Y=0;Y<T.length;Y++){const L=T[Y];if(L>=oe||ue[J[L]]!==K[L])return!1}return!0}sort(T,K){const re=this.ranks(K.locale),J=this.#t.length,ue=T.length,oe=new Uint32Array(ue),Y=this.#n;for(let L=0;L<ue;L++)oe[L]=Y[T[L]];return X(T,oe,re,J,!!K.descending)}}}),Se("packages/core/src/store/columnstore.js",function(o,me){"use strict";Object.defineProperty(o,"REMOVED",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toFloat",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ColumnHandle",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"ColumnStore",{enumerable:!0,get:function(){return a}});const fe=me("packages/core/src/internal/util.js"),he=fe.warnOnce,X=fe.isFunction,z=fe.pathGetter,x=me("packages/core/src/store/bitset.js").Bitset,K=me("packages/core/src/store/dictionary.js").Dictionary,J=me("packages/core/src/store/multivalue.js").MultiValue,oe=me("packages/core/src/store/stringrank.js").StringRankIndex,Y=4294967295,L=1024,Q=5e3,_=.2,C=new Set(["float64","int32","bitset","dictionary","object","multi"]);function M(m){return m==null}function i(m){if(typeof m=="number")return m;if(m instanceof Date)return m.getTime();if(typeof m=="boolean")return m?1:0;const e=Number(m);return Number.isNaN(e)&&typeof m=="string"?Date.parse(m):e}function s(m){const e=i(m);return Number.isFinite(e)?e|0:0}function u(m){return M(m)?[]:Array.isArray(m)?m:[m]}function f(m,e){switch(m.kind){case"float64":case"int32":return m.buf[e];case"bitset":return m.bits.get(e)===1;case"dictionary":return m.dict.valueOf(m.buf[e]);case"multi":{const d=m.mv.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=m.dict.valueOf(d[r]);return h}default:return m.buf[e]}}function c(m,e){switch(m.kind){case"float64":case"int32":return m.values[e];case"bitset":return(m.values[e>>3]&1<<(e&7))!==0;case"dictionary":return(m.table||[])[m.values[e]];case"multi":{const d=m.offsets[e],h=m.offsets[e+1],r=m.table||[],n=new Array(h-d);for(let l=d;l<h;l++)n[l-d]=r[m.values[l]];return n}default:return m.values[e]}}class t{#t;#e;#n;#r;#i;#s;#h;#u=!1;#o=null;#c=null;#l=null;#a=null;#d=null;#w;#b;#k=-1;#m=null;#p=0;#f=0;#y=null;#O=null;#g=!1;constructor(e,d){this.#t=e.id;const h=C.has(e.kind)?e.kind:"object";e.kind&&!C.has(e.kind)&&he(`store.kind.${e.id}`,`column "${e.id}" declares unknown storage kind "${e.kind}"; falling back to object`),this.#n=h,this.#e=h,this.#r=e.nullable!==!1,this.#h=e.dictionary??null,this.#s=d,this.#i=X(e.read)?e.read:z(e.field||e.id),this.#w=e.stringRankIndex!=="off",this.#b=typeof e.stringRankMaxDistinct=="number"?e.stringRankMaxDistinct:0,this.#y=new Map}get id(){return this.#t}get kind(){return this.#u?this.#e:"object"}get target(){return this.#n}get nullable(){return this.#r}get values(){return this.#g?null:this.#u?this.#e==="bitset"?this.#c.words:this.#e==="multi"?this.#l.values:this.#o:this.#N().values}get presence(){return this.#g||!this.#r?null:this.#u?this.#m:this.#N().presence}get dict(){return this.#g||!this.#u?null:this.#e==="dictionary"||this.#e==="multi"?this.#a:null}get stringRank(){if(this.#g||!this.#w||this.kind!=="object")return null;const e=this.values,d=this.#s.physical();if(!e||d===0)return null;if(this.#d===null){if(typeof e[0]!="string")return null;const h=new oe(this.#S());return h.build(e,d),h.version=this.#f,this.#d=h,this.#k=this.#f,h.capped?null:h}return this.#d.length<d&&this.#d.append(e,this.#d.length,d-this.#d.length),this.#d.version=this.#f,this.#k=this.#f,this.#d.capped?null:this.#d}#S(){return this.#b}#j(){this.#d=null,this.#k=-1}get offsets(){return this.#g||!this.#u||this.#e!=="multi"?null:this.#l.offsets}get version(){return this.#f}get bytes(){let e=0;return this.#o&&(e+=this.#o.byteLength??this.#o.length*8),this.#c&&(e+=this.#c.bytes),this.#l&&(e+=this.#l.bytes),this.#m&&(e+=this.#m.bytes),this.#a&&(e+=this.#a.bytes),this.#y&&(e+=this.#y.size*24),e}get(e){if(!this.#g&&!(e<0||e>=this.#s.physical())){if(!this.#u)return this.#M(e);if(this.#r&&this.#m.get(e)===0)return null;switch(this.#e){case"float64":case"int32":return this.#o[e];case"bitset":return this.#c.get(e)===1;case"dictionary":return this.#a.valueOf(this.#o[e]);case"multi":{const d=this.#l.at(e),h=new Array(d.length);for(let r=0;r<d.length;r++)h[r]=this.#a.valueOf(d[r]);return h}default:return this.#o[e]}}}set(e,d){this.#g||(this.#u?this.#A(e,d):this.#y.set(e,d===void 0?null:d),this.#d&&this.#j(),this.#f++)}read(e){return this.#i(e)}appendColumn(e,d,h){if(this.#g||h<=0)return;if(!this.#u){this.#f++;return}const r=this.#i,n=this.#r,l=this.#m;let g=!1;switch(this.#e){case"float64":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]);if(typeof G=="number"){n&&l.set(d+S),P[d+S]=G;continue}const F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?NaN:i(G)}break}case"int32":{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?0:s(G)}break}case"bitset":{const P=this.#c;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P.assign(d+S,!F&&!!G)}break}case"dictionary":{const P=this.#o,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0),P[d+G]=E?0:S.codeOf(F)}break}case"multi":{const P=this.#l,S=this.#a;for(let G=0;G<h;G++){const F=r(e[G]),E=F==null;n?l.assign(d+G,!E):E&&(g=!0);const Z=u(F),R=new Array(Z.length);for(let v=0;v<Z.length;v++)R[v]=S.codeOf(Z[v]);P.write(d+G,R)}break}default:{const P=this.#o;for(let S=0;S<h;S++){const G=r(e[S]),F=G==null;n?l.assign(d+S,!F):F&&(g=!0),P[d+S]=F?null:G}break}}g&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#d&&this.#e==="object"&&(this.#d.append(this.#o,d,h),this.#d.version=this.#f+1,this.#k=this.#f+1),this.#f++}appendPacked(e,d,h){if(this.#g||h<=0||!e)return;if(!this.#u){this.#f++;return}const r=this.#m,n=e.presence;if(r)if(n)for(let g=0;g<h;g++)r.assign(d+g,(n[g>>3]&1<<(g&7))!==0);else for(let g=0;g<h;g++)r.set(d+g);const l=e.kind===this.#e;if(l&&(this.#e==="float64"||this.#e==="int32")){this.#o.set(e.values,d),this.#f++;return}if(l&&this.#e==="bitset"){const g=e.values;for(let P=0;P<h;P++)this.#c.assign(d+P,(g[P>>3]&1<<(P&7))!==0);this.#f++;return}if(l&&this.#e==="dictionary"){const g=e.table||[],P=new Uint32Array(g.length);for(let E=0;E<g.length;E++)P[E]=this.#a.codeOf(g[E]);const S=e.values,G=this.#o,F=r;for(let E=0;E<h;E++){if(F&&(n&&(n[E>>3]&1<<(E&7))===0)){G[d+E]=0;continue}G[d+E]=P[S[E]]??0}this.#f++;return}if(l&&this.#e==="multi"){const g=e.table||[],P=new Uint32Array(g.length);for(let F=0;F<g.length;F++)P[F]=this.#a.codeOf(g[F]);const S=e.values,G=e.offsets;for(let F=0;F<h;F++){const E=G[F],Z=G[F+1],R=new Array(Z-E);for(let v=E;v<Z;v++)R[v-E]=P[S[v]]??0;this.#l.write(d+F,R)}this.#f++;return}for(let g=0;g<h;g++){const P=n?(n[g>>3]&1<<(g&7))===0:e.kind==="object"?e.values[g]===null:!1;this.#A(d+g,P?null:c(e,g))}this.#f++}touch(){this.#f++}columnarise(e,d){if(this.#u||this.#g)return;const h=new Array(d);for(let r=0;r<d;r++)h[r]=this.#M(r);this.#e=this.#n,this.#u=!0,this.#P(e);for(let r=0;r<d;r++)this.#A(r,h[r]);this.#y.clear(),this.#O=null,this.#j(),this.#f++}grow(e){if(!(!this.#u||this.#g||e<=this.#p)){switch(this.#e){case"float64":case"int32":case"dictionary":{const d=new this.#o.constructor(e);d.set(this.#o),this.#o=d;break}case"bitset":this.#c.grow(e);break;case"multi":break;default:this.#o.length=e;break}this.#m&&this.#m.grow(e),this.#p=e,this.#f++}}convert(e){if(this.#g||!C.has(e)||(this.#n=e,!this.#u||e===this.#e))return!1;const d={kind:this.#e,buf:this.#o,bits:this.#c,mv:this.#l,dict:this.#a},h=this.#s.physical(),r=this.#m;this.#e=e,this.#P(this.#p);for(let n=0;n<h;n++){const l=r!==null&&r.get(n)===0;l&&e!=="multi"||this.#A(n,l?null:f(d,n))}return this.#j(),this.#f++,!0}compact(e,d,h){if(!this.#g){if(this.#j(),!this.#u){const r=this.#y;if(r.size){const n=new Map;for(const[l,g]of r)e[l]!==Y&&n.set(e[l],g);this.#y=n}this.#O=null,this.#f++;return}switch(this.#e){case"float64":case"int32":case"dictionary":case"object":{const r=this.#o;for(let n=0;n<d;n++)e[n]!==Y&&(r[e[n]]=r[n]);if(this.#e==="object")for(let n=h;n<d;n++)r[n]=void 0;break}case"bitset":{const r=this.#c;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n);break}case"multi":this.#l.compact(e,h,Y);break;default:break}if(this.#m){const r=this.#m;for(let n=0;n<d;n++)e[n]!==Y&&r.assign(e[n],r.get(n)===1);for(let n=h;n<d;n++)r.clear(n)}this.#f++}}release(){this.#g||(this.#g=!0,this.#o=null,this.#c&&this.#c.release(),this.#c=null,this.#l&&this.#l.release(),this.#l=null,this.#m&&this.#m.release(),this.#m=null,this.#a=null,this.#d=null,this.#y=new Map,this.#O=null,this.#p=0,this.#f++)}#P(e){const d=Math.max(1,e);switch(this.#o=null,this.#c=null,this.#l=null,this.#e){case"float64":this.#o=new Float64Array(d);break;case"int32":this.#o=new Int32Array(d);break;case"bitset":this.#c=new x(d);break;case"dictionary":this.#o=new Uint32Array(d),this.#a=this.#a??new K(this.#h??[]);break;case"multi":this.#l=new J({rows:d,values:d}),this.#a=this.#a??new K(this.#h??[]);break;default:this.#o=new Array(d);break}this.#e!=="dictionary"&&this.#e!=="multi"&&(this.#a=null),this.#r&&(this.#m?this.#m.grow(d):this.#m=new x(d)),this.#p=d}#A(e,d){const h=M(d);switch(this.#r?this.#m.assign(e,!h):h&&he(`store.null.${this.#t}`,`column "${this.#t}" is declared non-nullable but received null; storing a filler value`),this.#e){case"float64":this.#o[e]=h?NaN:i(d);break;case"int32":this.#o[e]=h?0:s(d);break;case"bitset":this.#c.assign(e,!h&&!!d);break;case"dictionary":this.#o[e]=h?0:this.#a.codeOf(d);break;case"multi":{const r=u(d),n=new Array(r.length);for(let l=0;l<r.length;l++)n[l]=this.#a.codeOf(r[l]);this.#l.write(e,n);break}default:this.#o[e]=h?null:d;break}}#M(e){if(this.#y.has(e))return this.#y.get(e);const d=this.#i(this.#s.rowAt(e));return d===void 0?null:d}#N(){if(this.#O&&this.#O.version===this.#f)return this.#O;const e=this.#s.physical(),d=new Array(e),h=this.#r?new x(e):null;for(let r=0;r<e;r++){const n=this.#M(r);d[r]=n,h&&!M(n)&&h.set(r)}return this.#O={version:this.#f,values:d,presence:h},this.#O}}class a{#t;#e=new Map;#n=[];#r=[];#i=0;#s=0;#h=0;#u=0;#o=new x(0);#c=!1;#l=!0;#a;#d;#w;#b=!1;constructor(e,d={}){this.#t=Array.isArray(e)?e:[],this.#d=Math.max(1,d.initialCapacity??L),this.#l=d.retainSource!==!1,this.#a=this.#l?d.columnarBelow??Q:0,this.#w=d.compactRatio??_;const h={rowAt:r=>this.#r[r],physical:()=>this.#i};for(const r of this.#t){if(!r||!r.id)continue;if(this.#e.has(r.id)){he(`store.dup.${r.id}`,`duplicate column id "${r.id}" in the store schema; ignoring the second`);continue}const n=new t(r,h);this.#e.set(r.id,n),this.#n.push(n)}this.#a<=0&&this.#p()}get count(){return this.#h}get physical(){return this.#i}get capacity(){return this.#c?this.#s:this.#r.length}get tombstones(){return this.#u}get columnar(){return this.#c}get destroyed(){return this.#b}get bytes(){let e=this.#o.bytes+this.#r.length*8;for(const d of this.#n)e+=d.bytes;return e}append(e){const d=this.#i;if(this.#b||!e)return{from:d,to:d};const h=e.length|0;if(h===0)return{from:d,to:d};if(this.#l)for(let n=0;n<h;n++)this.#r[d+n]=e[n];if(this.#i=d+h,this.#h+=h,this.#o.grow(this.#i),!this.#c){if(this.#i>=this.#a)this.#p();else for(const n of this.#n)n.touch();return{from:d,to:this.#i}}this.#k(this.#i);const r=this.#n;for(let n=0;n<r.length;n++)r[n].appendColumn(e,d,h);return{from:d,to:this.#i}}appendPacked(e,d){const h=this.#i;if(this.#b||!e)return{from:h,to:h};const r=e.count|0;if(r===0)return{from:h,to:h};if(this.#l&&d)for(let l=0;l<r;l++)this.#r[h+l]=d[l];this.#i=h+r,this.#h+=r,this.#o.grow(this.#i),this.#c||this.#p(),this.#k(this.#i);const n=new Map;for(const l of e.columns)n.set(l.id,l);for(const l of this.#n){const g=n.get(l.id);g?l.appendPacked(g,h,r):l.grow(this.#s)}return{from:h,to:this.#i}}source(e){if(this.#l)return this.#r[e];if(!(e<0||e>=this.#i))return this.#m(e)}setSource(e,d){this.#b||e<0||e>=this.#i||this.#l&&(this.#r[e]=d)}get(e,d){const h=this.#e.get(e);return h?h.get(d):void 0}set(e,d,h){if(this.#b||d<0||d>=this.#i)return;const r=this.#e.get(e);if(!r){he(`store.set.${e}`,`set() on unknown column "${e}"`);return}r.set(d,h)}remove(e){return this.#b||e<0||e>=this.#i||this.#o.get(e)===1?!1:(this.#o.set(e),this.#u++,this.#h--,!0)}live(e){return e<0||e>=this.#i?!1:this.#o.get(e)===0}compact(e={}){if(this.#b||this.#u===0||!e.force&&this.#u/this.#i<this.#w)return null;const d=this.#i,h=new Uint32Array(d);let r=0;for(let n=0;n<d;n++)h[n]=this.#o.get(n)===1?Y:r++;for(const n of this.#n)n.compact(h,d,r);if(this.#l){const n=this.#r;for(let l=0;l<d;l++)h[l]!==Y&&(n[h[l]]=n[l]);n.length=r}return this.#i=r,this.#h=r,this.#u=0,this.#o=new x(Math.max(this.#s,r)),h}column(e){return this.#e.get(e)}columns(){return this.#n.slice()}liveIndices(){const e=new Uint32Array(this.#h);if(this.#u===0){for(let h=0;h<this.#i;h++)e[h]=h;return e}let d=0;for(let h=0;h<this.#i;h++)this.#o.get(h)===0&&(e[d++]=h);return e}convert(e,d){const h=this.#e.get(e);return h?h.convert(d):!1}destroy(){if(!this.#b){this.#b=!0;for(const e of this.#n)e.release();this.#e.clear(),this.#n.length=0,this.#r.length=0,this.#o.release(),this.#i=0,this.#h=0,this.#u=0,this.#s=0}}#k(e){if(e<=this.#s)return;let d=this.#s||this.#d;for(;d<e;)d*=2;for(const h of this.#n)h.grow(d);this.#o.grow(d),this.#s=d}#m(e){const d={};for(const h of this.#n)d[h.id]=h.get(e);return d}#p(){if(this.#c)return;let e=this.#d;for(;e<this.#i;)e*=2;this.#c=!0,this.#s=e,this.#o.grow(e);for(const d of this.#n)d.columnarise(e,this.#i)}}}),Se("packages/core/src/store/ingest.js",function(o,me){"use strict";Object.defineProperty(o,"INGEST_DEFAULTS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"inferKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"decideText",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"createReaders",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"Ingest",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ingest",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ingestSync",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.now,X=fe.nextFrame,z=fe.infoOnce,te=fe.warnOnce,x=fe.isFunction,T=fe.pathGetter,re=me("packages/core/src/store/columnstore.js").ColumnStore,J=Object.freeze({chunkMs:8,chunkRows:512,sampleSize:100,dictionaryRatio:.1,columnarBelow:5e3,initialCapacity:1024});function ue(M,i={}){if(i.multi)return"multi";if(M.length===0)return"object";let s=0,u=0,f=0,c=0,t=0;for(let m=0;m<M.length;m++){const e=M[m];typeof e=="number"?s++:typeof e=="boolean"?u++:typeof e=="string"?f++:e instanceof Date?c++:Array.isArray(e)&&t++}const a=M.length;return s===a?"float64":u===a?"bitset":c===a?"float64":f===a?"text":t===a?"multi":"object"}function oe(M,i,s){return i<=0||M<s*i?"dictionary":"object"}function Y(M,i,s){const u=new Map,f=new Map;for(const l of M){if(l.computed)continue;const g=x(l.read)?l.read:T(l.field||l.id);f.set(l.id,g),u.set(l.id,g)}const c=i?.order??[],t=i?.fns??{},a=i?.deps??{},m=i?.wrapDeps??null,e=c.filter(l=>x(t[l])),d=e.some(l=>a[l]==="*");let h=new WeakMap;const r=l=>{const g={};if(d)for(const[P,S]of f)g[P]=S(l);for(const P of e){const S=a[P];let G;if(S==="*")G=g;else{G={};const F=S||[];for(let E=0;E<F.length;E++){const Z=F[E];G[Z]=Z in g?g[Z]:f.get(Z)?.(l)}}g[P]=t[P](m?m(G,P):G,{data:l,row:null,column:null,grid:null,context:s})}return g},n=l=>{if(l===null||typeof l!="object"&&typeof l!="function")return r(l);let g=h.get(l);return g===void 0&&(g=r(l),h.set(l,g)),g};for(const l of e)u.set(l,g=>n(g)[l]);return{readers:u,reset(){h=new WeakMap}}}class L{spec;read;kind;inferred;nullable;candidate=!1;distinct=null;change=null;reason="";constructor(i,s){this.spec=i,this.read=s,this.kind="object",this.inferred=!1,this.nullable=i.nullable!==!1}}class Q{#t;#e=[];#n=null;#r;#i=0;#s;#h=!1;#u=!1;#o=0;#c;constructor(i,s={},u={}){this.#t=Array.isArray(i)?i:Array.from(i||[]),this.#s={...J,...u};const f=s.columns??[];this.#r=Y(f,s.computed??null,s.context),this.#c=this.#t.length>=this.#s.columnarBelow,this.#l(f,s.computed??null),this.#n=new re(this.#e.map(c=>({id:c.spec.id,kind:c.kind,nullable:c.nullable,read:c.read,dictionary:c.spec.dictionary})),{initialCapacity:this.#s.initialCapacity,columnarBelow:this.#s.columnarBelow})}get store(){return this.#n}get done(){return this.#h||this.#u}get progress(){return this.#i}slice(){if(this.done)return!1;if(this.#s.signal?.aborted)return this.#u=!0,!1;const i=he(),{chunkMs:s,chunkRows:u}=this.#s,f=this.#t.length;do{const c=Math.min(this.#i+u,f);this.#n.append(this.#t.slice(this.#i,c)),this.#a(this.#i,c),this.#i=c,this.#r.reset(),this.#w(!1)}while(this.#i<f&&he()-i<s);return this.#o+=he()-i,this.#s.onProgress?.({loaded:this.#i,total:f}),this.#i>=f?(this.#w(!0),this.#h=!0,!1):!0}cancel(){this.#u=!0}result(){return{store:this.#n,schema:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,read:i.read,dictionary:i.spec.dictionary})),decisions:this.#e.map(i=>({id:i.spec.id,kind:i.kind,nullable:i.nullable,inferred:i.inferred,distinct:i.candidate||i.change?this.#d(i):null,change:i.change,reason:i.reason})),count:this.#n.count,elapsed:this.#o,cancelled:this.#u}}#l(i,s){const u=this.#t,f=Math.min(this.#s.sampleSize,u.length),c=this.#s.dictionaryRatio,t=s?.pure instanceof Set?s.pure:new Set(s?.pure??s?.order??[]);for(const a of i){if(!a||!a.id)continue;if(a.computed&&(a.pure===!1||s&&!t.has(a.id))){te(`ingest.impure.${a.id}`,`column "${a.id}" is an impure computed column and is not materialised into the store`);continue}const m=this.#r.readers.get(a.id)??(x(a.read)?a.read:T(a.field||a.id)),e=new L(a,m);if(a.kind)e.kind=a.kind,e.reason="declared by the caller";else if(a.dictionary)e.kind=a.multi?"multi":"dictionary",e.reason="value table supplied (lookup column)";else{const d=[];for(let r=0;r<f&&d.length<this.#s.sampleSize;r++){const n=m(u[r]);n!=null&&d.push(n)}e.inferred=!0;const h=ue(d,{multi:a.multi});if(h==="text"){const r=new Set(d).size;e.kind=oe(r,d.length,c),e.candidate=this.#c,e.reason=`sampled ${r} distinct in ${d.length}`}else e.kind=h,e.reason=`inferred from ${d.length} sampled values`,h==="object"&&d.length&&z(`ingest.mixed.${a.id}`,`column "${a.id}" holds mixed or unrecognised value types; storing as an object array. Declare a type to avoid this.`);e.kind==="object"&&e.candidate&&(e.distinct=new Set(d))}this.#e.push(e)}}#a(i,s){const u=this.#t;for(const f of this.#e){if(!f.candidate||!f.distinct)continue;const c=f.distinct;for(let t=i;t<s;t++){const a=f.read(u[t]);a!=null&&c.add(a)}}}#d(i){if(i.distinct)return i.distinct.size;const s=this.#n.column(i.spec.id);return s?.dict?s.dict.size:0}#w(i){const s=this.#s.dictionaryRatio,u=this.#t.length;for(const f of this.#e){if(!f.candidate)continue;const c=this.#d(f);if(f.kind==="dictionary"&&c>=s*u){const t=this.#n.column(f.spec.id);f.distinct=new Set(t?.dict?t.dict.values():[]),this.#n.convert(f.spec.id,"object"),f.kind="object",f.change="demoted",f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}if(f.kind==="object"&&c>=s*u){f.candidate=!1,f.distinct=null,f.reason=`${c} distinct values is at or above ${s*100}% of ${u} rows`;continue}i&&f.kind==="object"&&c<s*u&&(this.#n.convert(f.spec.id,"dictionary"),f.kind="dictionary",f.change=f.change==="demoted"?null:"promoted",f.reason=`${c} distinct values is below ${s*100}% of ${u} rows`,f.distinct=null),i&&(f.candidate=!1)}}}async function _(M,i={},s={}){const u=new Q(M,i,s),f=s.scheduler?.frame??X;for(;u.slice();)await new Promise(c=>{f(c)});return u.result()}function C(M,i={},s={}){const u=new Q(M,i,{...s,chunkMs:1/0});for(;u.slice(););return u.result()}}),Se("packages/core/src/store/columnpack.js",function(o,me){"use strict";Object.defineProperty(o,"isPortableSchema",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"packChunk",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"packedTransfers",{enumerable:!0,get:function(){return Q}});const he=me("packages/core/src/internal/util.js").pathGetter,X=me("packages/core/src/store/ingest.js"),z=X.inferKind,te=X.decideText,x=X.INGEST_DEFAULTS,K=me("packages/core/src/store/columnstore.js").toFloat,re=new Set(["float64","int32","bitset","dictionary","object","multi"]);function J(_){if(!Array.isArray(_)||_.length===0)return!1;for(const C of _)if(!C||typeof C.id!="string"||typeof C.field!="string"||C.field===""||C.kind&&!re.has(C.kind))return!1;return!0}function ue(_){const C=K(_);return Number.isFinite(C)?C|0:0}function oe(_){return _==null?[]:Array.isArray(_)?_:[_]}function Y(_,C,M,i){if(_.kind)return _.kind;const s=[];for(let c=0;c<C.length&&s.length<x.sampleSize;c++){const t=C[c];t!=null&&s.push(t)}const u=z(s,{multi:_.multi});if(u!=="text")return u;const f=new Set(s).size;return te(f,s.length,i)}function L(_,C,M={}){const i=C.length|0,s=M.dictionaryRatio??x.dictionaryRatio,u=[];for(const f of _){const c=he(f.field||f.id),t=f.nullable!==!1,a=new Array(i);for(let r=0;r<i;r++){const n=c(C[r]);a[r]=n===void 0?null:n}const m=Y(f,a,i,s),e=t?new Uint8Array(i+7>>3):null,d=r=>{e&&(e[r>>3]|=1<<(r&7))};let h;switch(m){case"float64":{const r=new Float64Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?NaN:K(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"int32":{const r=new Int32Array(i);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),r[n]=g?0:ue(l)}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"bitset":{const r=new Uint8Array(i+7>>3);for(let n=0;n<i;n++){const l=a[n],g=l===null;g||d(n),!g&&l&&(r[n>>3]|=1<<(n&7))}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:null};break}case"dictionary":{const r=new Uint32Array(i),n=[],l=new Map;for(let g=0;g<i;g++){const P=a[g];if(P===null){r[g]=0;continue}d(g);let S=l.get(P);S===void 0&&(S=n.length,n.push(P),l.set(P,S)),r[g]=S}h={id:f.id,kind:m,nullable:t,values:r,presence:e,offsets:null,table:n};break}case"multi":{const r=[],n=new Map,l=new Uint32Array(i+1),g=[];for(let P=0;P<i;P++){const S=a[P];l[P]=g.length,S===null||d(P);const F=oe(S);for(let E=0;E<F.length;E++){const Z=F[E];let R=n.get(Z);R===void 0&&(R=r.length,r.push(Z),n.set(Z,R)),g.push(R)}}l[i]=g.length,h={id:f.id,kind:m,nullable:t,values:Int32Array.from(g),presence:e,offsets:l,table:r};break}default:{const r=new Array(i);for(let n=0;n<i;n++){const l=a[n];l!==null&&d(n),r[n]=l}h={id:f.id,kind:"object",nullable:t,values:r,presence:e,offsets:null,table:null};break}}u.push(h)}return{count:i,columns:u}}function Q(_){const C=[];if(!_||!Array.isArray(_.columns))return C;const M=i=>{ArrayBuffer.isView(i)&&i.buffer&&!C.includes(i.buffer)&&C.push(i.buffer)};for(const i of _.columns)M(i.values),M(i.presence),M(i.offsets);return C}}),Se("packages/core/src/compute/sortspec.js",function(o,me){"use strict";Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return te}});function fe(x){return{locale:x===void 0?void 0:String(x),numeric:!0,sensitivity:"variant"}}function he(x){return!!x&&typeof x.compare!="function"}function X(x){if(!x)return!0;for(let T=0;T<x.length;T++)if(!he(x[T]))return!1;return!0}function z(x,T){const K=x.col!==void 0?x.col:x.handle&&x.handle.id,re=x.locale!==void 0?x.locale:T;return{col:K,descending:x.descending!==void 0?!!x.descending:x.dir==="desc",nullsFirst:!!x.nullsFirst,collation:fe(re)}}function te(x,T){const K=x||[],re=new Array(K.length);for(let J=0;J<K.length;J++)re[J]=z(K[J],T);return re}}),Se("packages/core/src/format/date.js",function(o,me){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return C}});const fe=me("packages/core/src/internal/util.js"),he=fe.isNil,X=fe.warnOnce,z=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function te(M){const i=[];let s=0,u="";const f=()=>{u&&(i.push({token:null,text:u}),u="")};for(;s<M.length;){const c=M[s];if(c==="\'"){if(M[s+1]==="\'"){u+="\'",s+=2;continue}const a=M.indexOf("\'",s+1);if(a===-1){u+=M.slice(s+1),s=M.length;continue}u+=M.slice(s+1,a),s=a+1;continue}const t=z.find(a=>M.startsWith(a,s));if(t){f(),i.push({token:t,text:t}),s+=t.length;continue}/[A-Za-z]/.test(c)&&X(`date.pattern.token:${c}`,`the date pattern "${M}" contains \'${c}\', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${z.join(" ")}.`),u+=c,s+=1}return f(),i}const x=/^(\\d{4})-(\\d{2})-(\\d{2})(?:[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?(?:\\.\\d+)?)?$/;function T(M){if(he(M)||M==="")return null;if(M instanceof Date)return Number.isNaN(M.getTime())?null:M;if(typeof M=="number")return Number.isNaN(M)?null:new Date(M);if(typeof M=="string"){const i=x.exec(M.trim());if(i){const[,u,f,c,t="0",a="0",m="0"]=i;return new Date(+u,+f-1,+c,+t,+a,+m)}const s=new Date(M);return Number.isNaN(s.getTime())?null:s}return null}function K(M,i){return String(M).padStart(i,"0")}function re(M){if(!M)return u=>({year:u.getFullYear(),month:u.getMonth()+1,day:u.getDate(),hour:u.getHours(),minute:u.getMinutes(),second:u.getSeconds(),ms:u.getMilliseconds(),weekday:u.getDay()});const i=new Intl.DateTimeFormat("en-US",{timeZone:M,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),s={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return u=>{const f={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:u.getMilliseconds(),weekday:0};for(const c of i.formatToParts(u))switch(c.type){case"year":f.year=Number(c.value);break;case"month":f.month=Number(c.value);break;case"day":f.day=Number(c.value);break;case"hour":f.hour=Number(c.value)%24;break;case"minute":f.minute=Number(c.value);break;case"second":f.second=Number(c.value);break;case"weekday":f.weekday=s[c.value]??0;break;default:break}return f}}function J(M,i,s){const u=te(M),f=re(s),c=new Set(u.filter(d=>d.token).map(d=>d.token)),t=c.has("MMM")?new Intl.DateTimeFormat(i,{month:"short",timeZone:s}):null,a=c.has("MMMM")?new Intl.DateTimeFormat(i,{month:"long",timeZone:s}):null,m=c.has("EEE")?new Intl.DateTimeFormat(i,{weekday:"short",timeZone:s}):null,e=c.has("EEEE")?new Intl.DateTimeFormat(i,{weekday:"long",timeZone:s}):null;return d=>{const h=f(d);let r="";for(const n of u){if(!n.token){r+=n.text;continue}switch(n.token){case"yyyy":r+=K(h.year,4);break;case"yy":r+=K(h.year%100,2);break;case"MMMM":r+=a.format(d);break;case"MMM":r+=t.format(d);break;case"MM":r+=K(h.month,2);break;case"M":r+=String(h.month);break;case"dd":r+=K(h.day,2);break;case"d":r+=String(h.day);break;case"EEEE":r+=e.format(d);break;case"EEE":r+=m.format(d);break;case"HH":r+=K(h.hour,2);break;case"H":r+=String(h.hour);break;case"hh":r+=K(h.hour%12===0?12:h.hour%12,2);break;case"h":r+=String(h.hour%12===0?12:h.hour%12);break;case"mm":r+=K(h.minute,2);break;case"m":r+=String(h.minute);break;case"ss":r+=K(h.second,2);break;case"s":r+=String(h.second);break;case"SSS":r+=K(h.ms,3);break;case"a":r+=h.hour<12?"AM":"PM";break;default:r+=n.text;break}}return r}}const ue=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function oe(M,i){const s=M||{},u=s.locale||i||void 0,f=s.nullDisplay??"",c=s.timeZone;let t;if(s.pattern)t=J(s.pattern,u,c);else if(s.dateStyle||s.timeStyle){const h={timeZone:c};s.dateStyle&&(h.dateStyle=s.dateStyle),s.timeStyle&&(h.timeStyle=s.timeStyle);const r=new Intl.DateTimeFormat(u,h);t=n=>r.format(n)}else{const h=new Intl.DateTimeFormat(u,{dateStyle:"medium",timeZone:c});t=r=>h.format(r)}const a=s.relative?new Intl.RelativeTimeFormat(u,{numeric:"auto"}):null,e=(typeof s.relative=="object"&&s.relative?s.relative.threshold??7:7)*24*36e5,d=(h,r)=>{const n=T(h);if(!n)return f;if(a){const l=r&&typeof r.now=="number"?r.now:Date.now(),g=n.getTime()-l;if(Math.abs(g)<e){for(const[P,S]of ue)if(Math.abs(g)>=S||P==="second")return a.format(Math.round(g/S),P)}}return t(n)};return d.spec=s,d}function Y(M){if(he(M)||M==="")return null;if(typeof M=="string"){const u=/^(\\d{4}-\\d{2}-\\d{2})/.exec(M.trim());if(u)return u[1];const f=T(M);return f?Y(f):null}const i=T(M);if(!i)return null;const s=u=>String(u).padStart(2,"0");return`${i.getFullYear()}-${s(i.getMonth()+1)}-${s(i.getDate())}`}function L(M,i){if(he(M)||M==="")return null;if(typeof M=="string"){const u=M.trim();if(Q.test(u)){const t=T(u);return t?_(t,i):null}const f=/^(\\d{4}-\\d{2}-\\d{2})[T ](\\d{2}):(\\d{2})(?::(\\d{2}))?/.exec(u);if(f){const[,t,a,m,e]=f;return`${t}T${a}:${m}${e&&e!=="00"?`:${e}`:""}`}if(/^\\d{4}-\\d{2}-\\d{2}$/.test(u))return`${u}T00:00`;const c=T(u);return c?L(c):null}const s=T(M);return s?_(s,i):null}const Q=/(?:Z|[+-]\\d{2}:?\\d{2})$/i;function _(M,i){const s=t=>String(t).padStart(2,"0");if(i)try{const t=new Intl.DateTimeFormat("en-CA",{timeZone:i,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(M).reduce((e,d)=>(d.type!=="literal"&&(e[d.type]=d.value),e),{}),a=t.hour==="24"?"00":t.hour,m=Number(t.second);return`${t.year}-${t.month}-${t.day}T${a}:${t.minute}`+(m?`:${t.second}`:"")}catch{}const u=`${M.getFullYear()}-${s(M.getMonth()+1)}-${s(M.getDate())}`,f=M.getSeconds(),c=`${s(M.getHours())}:${s(M.getMinutes())}${f?`:${s(f)}`:""}`;return`${u}T${c}`}function C(M,i){const s=he(M)||M===""?null:String(M),u=he(i)||i===""?null:String(i);return s===null?u===null?0:1:u===null||s<u?-1:s>u?1:0}}),Se("packages/core/src/compute/filter.js",function(o,me){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return ce}});const fe=me("packages/core/src/internal/util.js"),he=fe.isBlank,X=fe.toArray,z=fe.warnOnce,x=me("packages/core/src/format/date.js").toIsoDate,T=me("packages/core/src/compute/handle.js"),K=T.bitReader,re=T.dictSize,J=T.dictValue,ue=T.presenceReader,oe=T.valueComparator,Y=T.valueReader,L=/^\\d{4}-\\d{2}-\\d{2}$/,Q="\\0null\\0";function _(p,B){const H=p&&p.pool;if(H){const w=H.mask||H.acquireMask||H.acquire||H.take;if(typeof w=="function"){const A=w.call(H,B);if(A&&A.length>=B)return A}}return new Uint8Array(B)}function C(p,B){const H=p&&p.pool;if(!H||!B)return;const w=H.release||H.releaseMask||H.free||H.recycle;typeof w=="function"&&w.call(H,B)}function M(p,B,H){return p.fill(H,0,B),p}function i(p){return p==null||typeof p=="number"&&Number.isNaN(p)}function s(p,B){if(p==null)return p;if(B==="number")return typeof p=="number"?p:Number(p);if(B==="date"||B==="dateString"){const H=x(p);return H===null?u(p):H}return B==="boolean"?typeof p=="boolean"?p:p==="true"||p===1?!0:p==="false"||p===0?!1:!!p:p}function u(p){return p instanceof Date?p.getTime():typeof p=="number"?p:Date.parse(String(p))}function f(p){return typeof p=="number"?p:p instanceof Date?p.getTime():p==null||p===""?NaN:Number(p)}function c(p,B){const H=typeof p=="string"?p:String(p);return B?H:H.toLowerCase()}function t(p,B){return p==null?Q:typeof p=="string"?B?p:p.toLowerCase():p instanceof Date?p.getTime():p}function a(p,B,H){const w=new Set;for(const A of X(p)){const q=s(A,H);w.add(t(q,B)),typeof q=="string"&&q!==""&&Number.isFinite(Number(q))?w.add(Number(q)):typeof q=="number"&&Number.isFinite(q)&&w.add(t(String(q),B))}return w}function m(p,B,H){if(p==null||B===null||B===void 0)return p==null&&B==null;const w=typeof p,A=typeof B;return w==="string"&&A==="string"?H?p===B:p.toLowerCase()===B.toLowerCase():p instanceof Date||B instanceof Date?u(p)===u(B):w==="number"&&A==="number"?p===B||Number.isNaN(p)&&Number.isNaN(B):w==="number"&&A==="string"?p===Number(B):w==="string"&&A==="number"?Number(p)===B:w==="boolean"||A==="boolean"?p===B:Array.isArray(p)&&Array.isArray(B)?p.length===B.length&&p.every((q,le)=>m(q,B[le],H)):p===B}function e(p,B){try{if(p instanceof RegExp){const H=p.flags.replace(/[gy]/g,"");return new RegExp(p.source,B||H.includes("i")?H:`${H}i`)}return new RegExp(String(p),B?"":"i")}catch(H){return z(`regex:${String(p)}`,`filter operator "matches" received an invalid pattern: ${String(p)}`,H),null}}function d(p,B){const H=h(p,B),w=p&&p.type;return w!=="date"&&w!=="dateString"?H:A=>H(typeof A=="string"&&L.test(A)?A:x(A)??A)}function h(p,B){const H=p&&p.op,w=!!(p&&p.caseSensitive),A=p&&p.type,q=oe(B),le=ae=>de=>!ae(de);switch(H){case"eq":{const ae=s(p.value,A);return de=>m(de,ae,w)}case"ne":{const ae=s(p.value,A);return de=>!m(de,ae,w)}case"lt":case"lte":case"gt":case"gte":{const ae=s(p.value,A);if(i(ae))return()=>!1;const de=H==="lt"?-1:H==="lte"?0:H==="gt"?1:2;return pe=>{if(i(pe))return!1;const ge=q(pe,ae);return de===-1?ge<0:de===0?ge<=0:de===1?ge>0:ge>=0}}case"between":case"notBetween":{const ae=X(p.value),de=s(ae[0],A),pe=s(ae[1],A),ge=p.bounds||"[]",ke=ge.charAt(0)!=="(",Le=ge.charAt(1)!==")";if(i(de)||i(pe))return H==="between"?()=>!1:()=>!0;const Re=Be=>{if(i(Be))return!1;const ze=q(Be,de),Ke=q(Be,pe);return(ke?ze>=0:ze>0)&&(Le?Ke<=0:Ke<0)};return H==="between"?Re:le(Re)}case"in":case"notIn":{const ae=a(p.value,w,A),de=pe=>ae.has(t(pe,w));return H==="in"?de:le(de)}case"contains":case"notContains":{const ae=c(s(p.value,A),w),de=pe=>pe==null?!1:c(pe,w).includes(ae);return H==="contains"?de:le(de)}case"startsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).startsWith(ae)}case"endsWith":{const ae=c(s(p.value,A),w);return de=>de==null?!1:c(de,w).endsWith(ae)}case"matches":{const ae=e(p.value,w);return ae?de=>de==null?!1:ae.test(String(de)):()=>!1}case"blank":return ae=>he(ae)||Array.isArray(ae)&&ae.length===0;case"notBlank":return ae=>!(he(ae)||Array.isArray(ae)&&ae.length===0);case"containsAny":case"containsNone":{const ae=a(p.value,w,A),de=pe=>{const ge=pe==null?[]:X(pe);for(let ke=0;ke<ge.length;ke++)if(ae.has(t(ge[ke],w)))return!0;return!1};return H==="containsAny"?de:le(de)}case"containsAll":{const ae=X(p.value).map(de=>t(s(de,A),w));return de=>{const pe=de==null?[]:X(de);if(ae.length===0)return!0;const ge=new Set(pe.map(ke=>t(ke,w)));for(let ke=0;ke<ae.length;ke++)if(!ge.has(ae[ke]))return!1;return!0}}default:{const ae=ce(H);return ae?ae.compile(p.value):(z(`op:${String(H)}`,`unknown filter operator "${String(H)}"; the condition is refused rather than matching every row`),()=>!1)}}}function r(p,B,H){return d(B,H)(p)}const n=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),l=new Set(["containsAny","containsAll","containsNone"]);function g(p,B,H){const w=p&&p.op,A=n[w]||w,q=d({...p,op:A,type:B.type},H),le=B.items,ae=de=>{const pe=le(de);if(!pe)return!1;for(let ge=0;ge<pe.length;ge++)if(q(pe[ge]))return!0;return!1};return n[w]?de=>!ae(de):ae}function P(p,B,H,w){const A=ue(p);if(A){const ae=B?1:0;for(let de=0;de<w;de++)H[de]=A(de)===ae?1:0;return H}const q=p.kind;if(q==="float64"||q==="int32"||q==="bitset")return M(H,w,B?1:0);const le=Y(p);for(let ae=0;ae<w;ae++){const de=le(ae),pe=he(de)||Array.isArray(de)&&de.length===0;H[ae]=pe===B?0:1}return H}function S(p,B,H,w){const A=p.dict,q=re(A),le=new Uint8Array(q);for(let ge=0;ge<q;ge++)le[ge]=B(J(A,ge))?1:0;const ae=p.values,de=ue(p);if(!de){for(let ge=0;ge<w;ge++)H[ge]=le[ae[ge]];return H}const pe=B(null)?1:0;for(let ge=0;ge<w;ge++)H[ge]=de(ge)===1?le[ae[ge]]:pe;return H}function G(p,B,H,w){const A=K(p.values),q=B(!0)?1:0,le=B(!1)?1:0,ae=ue(p);if(!ae){for(let pe=0;pe<w;pe++)H[pe]=A(pe)===1?q:le;return H}const de=B(null)?1:0;for(let pe=0;pe<w;pe++)H[pe]=ae(pe)===0?de:A(pe)===1?q:le;return H}function F(p,B,H,w,A){const q=p.values,le=B.type,ae=B.op;let de=!0;switch(ae){case"eq":case"ne":{const ge=f(s(B.value,le)),ke=typeof B.value=="number"&&Number.isNaN(B.value),Le=ae==="ne"?1:0;if(ke)for(let Re=0;Re<A;Re++)w[Re]=(Number.isNaN(q[Re])?1:0)^Le;else for(let Re=0;Re<A;Re++)w[Re]=(q[Re]===ge?1:0)^Le;break}case"lt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<ge?1:0;break}case"lte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]<=ge?1:0;break}case"gt":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>ge?1:0;break}case"gte":{const ge=f(s(B.value,le));for(let ke=0;ke<A;ke++)w[ke]=q[ke]>=ge?1:0;break}case"between":case"notBetween":{const ge=X(B.value),ke=f(s(ge[0],le)),Le=f(s(ge[1],le)),Re=B.bounds||"[]",Be=Re.charAt(0)!=="(",ze=Re.charAt(1)!==")",Ke=ae==="notBetween"?1:0;if(Be&&ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<=Le?1:0)^Ke;else if(Be)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>=ke&q[Te]<Le?1:0)^Ke;else if(ze)for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<=Le?1:0)^Ke;else for(let Te=0;Te<A;Te++)w[Te]=(q[Te]>ke&q[Te]<Le?1:0)^Ke;break}case"in":case"notIn":{const ge=new Set;for(const Le of X(B.value)){const Re=f(s(Le,le));Number.isNaN(Re)||ge.add(Re)}const ke=ae==="notIn"?1:0;for(let Le=0;Le<A;Le++)w[Le]=(ge.has(q[Le])?1:0)^ke;break}default:de=!1;break}if(!de)return!1;const pe=ue(p);if(pe){const ge=H(null)?1:0;for(let ke=0;ke<A;ke++)pe(ke)===0&&(w[ke]=ge)}return!0}function E(p,B,H,w){const A=Y(p);for(let q=0;q<w;q++)H[q]=B(A(q))?1:0;return H}function Z(p,B,H){const w=B.count|0,A=H||_(B,w);if(!p)return M(A,w,1);const q=typeof B.handle=="function"?B.handle(p.col):void 0,le=typeof B.custom=="function"?B.custom:null;if(!q){if(le){for(let ge=0;ge<w;ge++)A[ge]=le(p,ge)?1:0;return A}return z(`filter:col:${String(p.col)}`,`filter references unknown column "${String(p.col)}"; the condition is refused rather than matching every row`),M(A,w,0)}const ae=p.op;if(ae==="blank"||ae==="notBlank")return P(q,ae==="notBlank",A,w);const de=typeof B.itemwise=="function"?B.itemwise(p.col):null;if(de&&!ce(ae)&&!l.has(ae))return E(q,g(p,de,B.locale),A,w);const pe=d(p,B.locale);switch(q.kind){case"dictionary":return S(q,pe,A,w);case"bitset":return G(q,pe,A,w);case"float64":case"int32":return F(q,p,pe,A,w)?A:E(q,pe,A,w);default:return E(q,pe,A,w)}}function R(p,B,H){if(!p)return M(_(B,H),H,1);if(Array.isArray(p.conditions)){const w=p.conditions.filter(le=>le!=null),A=p.op==="or"?"or":p.op==="not"?"not":"and";if(w.length===0)return M(_(B,H),H,1);const q=R(w[0],B,H);for(let le=1;le<w.length;le++){const ae=R(w[le],B,H);if(A==="or")for(let de=0;de<H;de++)q[de]|=ae[de];else for(let de=0;de<H;de++)q[de]&=ae[de];C(B,ae)}if(A==="not")for(let le=0;le<H;le++)q[le]^=1;return q}return Z(p,B,_(B,H))}function v(p,B){return R(p,B,B.count|0)}function U(p,B){if(!p||!B)return p||null;const H=p;if(Array.isArray(H.conditions)){if((H.op==="or"?"or":H.op==="not"?"not":"and")!=="and")return V(H,B)?null:p;const A=[];for(const q of H.conditions){const le=U(q,B);le&&A.push(le)}return A.length?{...H,op:"and",conditions:A}:null}return H.col===B?null:p}function V(p,B){if(!p||typeof p!="object")return!1;const H=p;if(H.col===B)return!0;if(Array.isArray(H.conditions)){for(const w of H.conditions)if(V(w,B))return!0}return!1}function $(p,B,H){if(H&&H.length>=B){let le=0;for(let ae=0;ae<B;ae++)p[ae]&&(H[le++]=ae);return H.subarray(0,le)}let w=0;for(let le=0;le<B;le++)w+=p[le]?1:0;const A=new Uint32Array(w);let q=0;for(let le=0;le<B;le++)p[le]&&(A[q++]=le);return A}const ee=new Map;function ne(p){if(!(!p||typeof p!="object"))for(const[B,H]of Object.entries(p))H&&typeof H.compile=="function"&&ee.set(B,H)}function ce(p){return typeof p=="string"?ee.get(p):void 0}}),Se("packages/core/src/compute/group.js",function(o,me){"use strict";Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return oe}});const fe=me("packages/core/src/compute/handle.js"),he=fe.dictSize,X=fe.identity,z=fe.presenceReader,te=fe.rowCount,x=fe.valueReader,T="",K="\\0",re=1<<20;function J(Y,L,Q,_){const C=Y.length,M=Y.map(t=>x(t)),i=Array.isArray(_)&&_.some(Boolean),s=i?M.map((t,a)=>_[a]?m=>_[a](t(m)):t):M;if(!i&&C>0&&Y.every(t=>t&&t.kind==="dictionary"&&t.dict)){const t=Y.map(m=>he(m.dict)+1);let a=1;for(let m=0;m<C;m++)a*=t[m];if(a<=Number.MAX_SAFE_INTEGER){const m=Y.map(r=>r.values),e=Y.map(r=>z(r)),d=r=>{let n=0;for(let l=0;l<C;l++){const g=e[l],P=g&&g(r)===0?t[l]-1:m[l][r];n=n*t[l]+P}return n},h=new Float64Array(Q);for(let r=0;r<Q;r++)h[r]=d(L[r]);return{packed:h,strings:null,product:a,readers:s,keyOf:d}}}const f=t=>{let a="";for(let m=0;m<C;m++){const e=s[m](t);a+=(m===0?"":T)+(e==null?K:String(e))}return a},c=new Array(Q);for(let t=0;t<Q;t++)c[t]=f(L[t]);return{packed:null,strings:c,product:1/0,readers:s,keyOf:f}}function ue(Y,L,Q,_){const C=new Uint32Array(_+1);for(let u=0;u<Q;u++)C[L[u]+1]++;for(let u=0;u<_;u++)C[u+1]+=C[u];const M=new Uint32Array(Q),i=C.slice(0,_);for(let u=0;u<Q;u++)M[i[L[u]]++]=Y[u];const s=new Array(_);for(let u=0;u<_;u++)s[u]=M.subarray(C[u],C[u+1]);return s}function oe(Y,L,Q={}){const _=Y||[],C=L||X(te(_[0],Q)),M=C.length;if(_.length===0||M===0)return{keys:[],buckets:[]};const{packed:i,strings:s,product:u,readers:f}=J(_,C,M,Q.project),c=new Uint32Array(M);let t=0,a=null;if(i&&u<=Math.max(1024,Math.min(re,M*4))){const h=u,r=new Int32Array(h).fill(-1);for(let n=0;n<M;n++)r[i[n]]=0;for(let n=0;n<h;n++)r[n]===0&&(r[n]=t++);for(let n=0;n<M;n++)c[n]=r[i[n]];a=new Float64Array(t);for(let n=0;n<h;n++)r[n]>=0&&(a[r[n]]=n)}else if(i){const h=new Map;for(let r=0;r<M;r++){const n=i[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}a=new Float64Array(t);for(const[r,n]of h)a[n]=r}else{const h=new Map;for(let r=0;r<M;r++){const n=s[r];let l=h.get(n);l===void 0&&(l=t++,h.set(n,l)),c[r]=l}}const m=ue(C,c,M,t),e=new Array(t);for(let h=0;h<t;h++){const r=m[h][0],n=new Array(f.length);for(let l=0;l<f.length;l++)n[l]=f[l](r);e[h]=n}const d={keys:e,buckets:m};return a&&(d.packed=a),d}}),Se("packages/core/src/compute/facet.js",function(o,me){"use strict";Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"orderedReader",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"toNumeric",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return r}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=fe.dictSize,te=fe.dictValue,x=Object.freeze(["equal","quantile","log"]),T=Object.freeze(["hour","day","week","month","quarter","year"]),K=20,re=50,J=1e4;function ue(n,l){if(!n)return"none";const g=l;if(g&&(g.multi===!0||typeof g.items=="function"))return"category";const P=l&&l.base;if(P==="date"||P==="datetime"||P==="time"||P==="dateString")return"date";switch(n.kind){case"bitset":return"boolean";case"float64":case"int32":return"numeric";case"dictionary":return"category";case"multi":return"category";default:return P==="number"?"numeric":P==="boolean"?"boolean":P==="text"?"category":"none"}}function oe(n){const l=n.values,g=n.kind;if((g==="float64"||g==="int32")&&l)return S=>l[S];const P=X(n);return S=>Y(P(S))}function Y(n){if(typeof n=="number")return n;if(n instanceof Date)return n.getTime();if(n==null||n==="")return NaN;if(typeof n=="boolean")return n?1:0;if(typeof n=="string"){const l=Number(n);if(Number.isFinite(l))return l;const g=Date.parse(n);return Number.isFinite(g)?g:NaN}return NaN}function L(n,l,g,P=re){if(!n)return{cardinality:0,exact:!0};if(n.dict)return{cardinality:z(n.dict),exact:!0};if(n.kind==="bitset")return{cardinality:2,exact:!0};const S=X(n),G=l?l.length:g,F=new Set;for(let E=0;E<G;E++){const Z=S(l?l[E]:E);if(Z!=null&&(F.add(Z),F.size>P))return{cardinality:F.size,exact:!1}}return{cardinality:F.size,exact:!0}}const Q=36e5,_=864e5;function C(n,l=K){const g=Number.isFinite(n)&&n>0?n:0,P=Math.max(1,l)*2;return g/Q<=P?"hour":g/_<=P?"day":g/(7*_)<=P?"week":g/(30*_)<=P?"month":g/(91*_)<=P?"quarter":"year"}function M(n,l){if(!Number.isFinite(n))return NaN;const g=new Date(n);switch(l){case"hour":return g.setMinutes(0,0,0),g.getTime();case"day":return g.setHours(0,0,0,0),g.getTime();case"week":{g.setHours(0,0,0,0);const P=(g.getDay()+6)%7;return g.setDate(g.getDate()-P),g.getTime()}case"month":return g.setDate(1),g.setHours(0,0,0,0),g.getTime();case"quarter":return g.setMonth(Math.floor(g.getMonth()/3)*3,1),g.setHours(0,0,0,0),g.getTime();default:return g.setMonth(0,1),g.setHours(0,0,0,0),g.getTime()}}function i(n,l){const g=new Date(n);switch(l){case"hour":g.setHours(g.getHours()+1);break;case"day":g.setDate(g.getDate()+1);break;case"week":g.setDate(g.getDate()+7);break;case"month":g.setMonth(g.getMonth()+1);break;case"quarter":g.setMonth(g.getMonth()+3);break;default:g.setFullYear(g.getFullYear()+1);break}return g.getTime()}function s(n,l,g){const P=oe(n),S=he(n),G=l?l.length:g;let F=1/0,E=-1/0,Z=0,R=0;for(let v=0;v<G;v++){const U=l?l[v]:v;if(S&&!S(U)){Z++;continue}const V=P(U);if(!Number.isFinite(V)){Z++;continue}V<F&&(F=V),V>E&&(E=V),R++}return{min:F,max:E,nulls:Z,finite:R}}function u(n,l,g,P){const S=oe(n),G=he(n),F=l?l.length:g,E=F>P?F/P:1,Z=[];for(let v=0;v<F;v+=E){const U=l?l[Math.floor(v)]:Math.floor(v);if(G&&!G(U))continue;const V=S(U);Number.isFinite(V)&&Z.push(V)}const R=Float64Array.from(Z);return R.sort(),R}function f(n,l,g,P={}){const S=P.kind||ue(n,P.type);return S==="none"||!n?{kind:"none",buckets:[],suppressed:"type"}:S==="boolean"?c(n,l,g):S==="category"?t(n,l,g,P):a(n,l,g,S,P)}function c(n,l,g){const P=he(n);let S=0;if(P){const F=l?l.length:g;for(let E=0;E<F;E++)P(l?l[E]:E)||S++}const G=[{value:!1,label:"false"},{value:!0,label:"true"}];return S>0&&G.push({null:!0,label:"Empty"}),{kind:"boolean",buckets:G}}function t(n,l,g,P){const S=P.cardinalityLimit??re,{cardinality:G}=L(n,l,g,S);if(G>S&&(P.aboveLimit||"suppress")==="suppress")return{kind:"category",buckets:[],suppressed:"cardinality",cardinality:G};const F=X(n),E=l?l.length:g,Z=new Map;let R=0;for(let ee=0;ee<E;ee++){const ne=F(l?l[ee]:ee);if(ne==null||ne===""){R++;continue}if(Array.isArray(ne)){if(!ne.length){R++;continue}for(const ce of ne)Z.set(ce,(Z.get(ce)||0)+1);continue}Z.set(ne,(Z.get(ne)||0)+1)}let v=[...Z.entries()];P.order==="alpha"?v.sort((ee,ne)=>String(ee[0]).localeCompare(String(ne[0]))):v.sort((ee,ne)=>ne[1]-ee[1]);let U=0,V=0;if(v.length>S){V=v.length-S;for(let ee=S;ee<v.length;ee++)U+=v[ee][1];v=v.slice(0,S)}const $=v.map(([ee])=>({value:ee,label:String(ee)}));return U>0&&$.push({remainder:!0,label:`Other (${V} values)`}),R>0&&$.push({null:!0,label:"Empty"}),{kind:"category",buckets:$,cardinality:G}}function a(n,l,g,P,S){const{min:G,max:F,nulls:E,finite:Z}=s(n,l,g);if(!Z)return{kind:P,buckets:E?[{null:!0,label:"Empty"}]:[],empty:!0};const R=Math.max(1,Math.floor(S.buckets||K));let v=[];if(P==="date"){const V=T.includes(S.granularity)?S.granularity:C(F-G,R);let $=M(G,V);for(;$<=F&&v.length<4096;){const ee=i($,V);if(!(ee>$))break;v.push({from:$,to:ee}),$=ee}return{kind:P,buckets:m(v,E),granularity:V}}const U=x.includes(S.strategy)?S.strategy:"equal";if(U==="quantile"){const V=u(n,l,g,J);if(V.length){const $=[V[0]];for(let ee=1;ee<R;ee++){const ne=V[Math.min(V.length-1,Math.floor(ee/R*V.length))];ne>$[$.length-1]&&$.push(ne)}$.push(F);for(let ee=0;ee<$.length-1;ee++)v.push({from:$[ee],to:$[ee+1]})}}else if(U==="log"&&G>0){const V=Math.log10(G),ee=(Math.log10(F)-V)/R||1;for(let ne=0;ne<R;ne++)v.push({from:10**(V+ne*ee),to:10**(V+(ne+1)*ee)})}if(!v.length){const V=(F-G)/R||1;for(let $=0;$<R;$++)v.push({from:G+$*V,to:G+($+1)*V})}return v[v.length-1].to=F,{kind:P,buckets:m(v,E),strategy:U,min:G,max:F}}function m(n,l){return l>0?[...n,{null:!0,label:"Empty"}]:n}function e(n,l,g,P,S){const G=P&&P.buckets||[],F=S&&S.length>=G.length?S.subarray(0,G.length):new Uint32Array(G.length);if(F.fill(0),!n||!G.length)return F;const E=G.length-1,Z=!!G[E]&&G[E].null===!0,R=l?l.length:g;if(P.kind==="boolean"){const ee=X(n);for(let ne=0;ne<R;ne++){const ce=ee(l?l[ne]:ne);if(ce==null){Z&&F[E]++;continue}F[ce?1:0]++}return F}if(P.kind==="category"){const ee=new Map;for(let p=0;p<G.length;p++)!G[p].null&&!G[p].remainder&&ee.set(G[p].value,p);const ne=G.findIndex(p=>p.remainder),ce=X(n);for(let p=0;p<R;p++){const B=ce(l?l[p]:p);if(B==null||B===""){Z&&F[E]++;continue}if(Array.isArray(B)){if(!B.length){Z&&F[E]++;continue}for(const w of B){const A=ee.get(w);A!==void 0?F[A]++:ne>=0&&F[ne]++}continue}const H=ee.get(B);H!==void 0?F[H]++:ne>=0&&F[ne]++}return F}const v=Z?G.length-1:G.length,U=new Float64Array(v+1);for(let ee=0;ee<v;ee++)U[ee]=G[ee].from;U[v]=v?G[v-1].to:0;const V=oe(n),$=he(n);for(let ee=0;ee<R;ee++){const ne=l?l[ee]:ee;if($&&!$(ne)){Z&&F[E]++;continue}const ce=V(ne);if(!Number.isFinite(ce)){Z&&F[E]++;continue}const p=d(U,v,ce);p>=0&&F[p]++}return F}function d(n,l,g){if(!l||g<n[0])return-1;if(g>=n[l])return g===n[l]?l-1:-1;let P=0,S=l-1;for(;P<S;){const G=P+S+1>>>1;g>=n[G]?P=G:S=G-1}return P}function h(n,l,g,P={}){const S=P.bounds||f(n,P.boundsIndices??l,g,P);return{bounds:S,counts:e(n,l,g,S)}}const r=h}),Se("packages/core/src/compute/special.js",function(o,me){"use strict";Object.defineProperty(o,"logGamma",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"incompleteBeta",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"normalCdf",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"studentT",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"regularizedGammaP",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chiSquareUpperTail",{enumerable:!0,get:function(){return _}});const fe=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),he=3e-12,X=1e-300;function z(C){if(C<.5)return Math.log(Math.PI/Math.sin(Math.PI*C))-z(1-C);const M=C-1;let i=.9999999999998099;const s=M+7.5;for(let u=0;u<fe.length;u++)i+=fe[u]/(M+u+1);return .5*Math.log(2*Math.PI)+(M+.5)*Math.log(s)-s+Math.log(i)}function te(C,M,i){const s=C+M,u=C+1,f=C-1;let c=1,t=1-s*i/u;Math.abs(t)<X&&(t=X),t=1/t;let a=t;for(let m=1;m<=300;m++){const e=2*m;let d=m*(M-m)*i/((f+e)*(C+e));t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t,a*=t*c,d=-(C+m)*(s+m)*i/((C+e)*(u+e)),t=1+d*t,Math.abs(t)<X&&(t=X),c=1+d/c,Math.abs(c)<X&&(c=X),t=1/t;const h=t*c;if(a*=h,Math.abs(h-1)<he)break}return a}function x(C,M,i){if(!(C>0)||!(M>0)||!Number.isFinite(i))return Number.NaN;if(i<=0)return 0;if(i>=1)return 1;const s=Math.exp(z(C+M)-z(C)-z(M)+C*Math.log(i)+M*Math.log(1-i));return i<(C+1)/(C+M+2)?s*te(C,M,i)/C:1-s*te(M,C,1-i)/M}function T(C){if(!(C>0)||!(C<1))return C===0?-1/0:C===1?1/0:Number.NaN;const M=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],i=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],s=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],u=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],f=.02425;let c,t,a;C<f?(c=Math.sqrt(-2*Math.log(C)),a=(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1)):C<=1-f?(c=C-.5,t=c*c,a=(((((M[0]*t+M[1])*t+M[2])*t+M[3])*t+M[4])*t+M[5])*c/(((((i[0]*t+i[1])*t+i[2])*t+i[3])*t+i[4])*t+1)):(c=Math.sqrt(-2*Math.log(1-C)),a=-(((((s[0]*c+s[1])*c+s[2])*c+s[3])*c+s[4])*c+s[5])/((((u[0]*c+u[1])*c+u[2])*c+u[3])*c+1));const e=(.5*K(-a/Math.SQRT2)-C)*Math.sqrt(2*Math.PI)*Math.exp(a*a/2);return a-e/(1+a*e/2)}function K(C){const M=Math.abs(C),i=2/(2+M),s=4*i-2,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let f=0,c=0,t;for(let m=u.length-1;m>0;m--)t=c,c=s*c-f+u[m],f=t;const a=i*Math.exp(-M*M+.5*(u[0]+s*c)-f);return C>=0?a:2-a}function re(C){return .5*K(-C/Math.SQRT2)}function J(C,M){if(!(M>0)||!Number.isFinite(C))return Number.NaN;const i=.5*x(M/2,.5,M/(M+C*C));return C>0?1-i:i}function ue(C,M){if(!(C>0)||!(C<1)||!(M>0))return Number.NaN;if(M>1e7)return T(C);let i=-1e4,s=1e4,u=T(C);const f=z(M/2)+z(.5)-z((M+1)/2);for(let c=0;c<60;c++){const t=J(u,M);t<C?i=u:s=u;const a=Math.exp(-((M+1)/2)*Math.log(1+u*u/M)-f)/Math.sqrt(M),m=a>0?(t-C)/a:0;if(Math.abs(m)<1e-12)break;const e=u-m;if(u=e>i&&e<s&&Number.isFinite(e)?e:(i+s)/2,s-i<1e-12)break}return u}function oe(C,M){let i=C,s=1/C,u=s;for(let f=0;f<300&&(i+=1,u*=M/i,s+=u,!(Math.abs(u)<Math.abs(s)*he));f++);return s*Math.exp(-M+C*Math.log(M)-z(C))}function Y(C,M){let i=M+1-C,s=1/X,u=1/i,f=u;for(let c=1;c<=300;c++){const t=-c*(c-C);i+=2,u=t*u+i,Math.abs(u)<X&&(u=X),s=i+t/s,Math.abs(s)<X&&(s=X),u=1/u;const a=u*s;if(f*=a,Math.abs(a-1)<he)break}return Math.exp(-M+C*Math.log(M)-z(C))*f}function L(C,M){return!(C>0)||!(M>=0)||!Number.isFinite(M)?Number.NaN:M===0?0:M<C+1?oe(C,M):1-Y(C,M)}function Q(C,M){return M>0?L(M/2,C/2):Number.NaN}function _(C,M){const i=Q(C,M);return Number.isNaN(i)?Number.NaN:Math.min(1,Math.max(0,1-i))}}),Se("packages/core/src/compute/linalg.js",function(o,me){"use strict";Object.defineProperty(o,"cholesky",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"choleskySolve",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"choleskyInverse",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"normalEquations",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"matVec",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quadForm",{enumerable:!0,get:function(){return x}});function fe(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++)for(let ue=0;ue<=J;ue++){let oe=T[J][ue];for(let Y=0;Y<ue;Y++)oe-=re[J][Y]*re[ue][Y];if(J===ue){if(!(oe>0))return null;re[J][ue]=Math.sqrt(oe)}else re[J][ue]=oe/re[ue][ue]}return re}function he(T,K){const re=T.length,J=new Array(re).fill(0);for(let oe=0;oe<re;oe++){let Y=K[oe];for(let L=0;L<oe;L++)Y-=T[oe][L]*J[L];J[oe]=Y/T[oe][oe]}const ue=new Array(re).fill(0);for(let oe=re-1;oe>=0;oe--){let Y=J[oe];for(let L=oe+1;L<re;L++)Y-=T[L][oe]*ue[L];ue[oe]=Y/T[oe][oe]}return ue}function X(T){const K=T.length,re=Array.from({length:K},()=>new Array(K).fill(0));for(let J=0;J<K;J++){const ue=new Array(K).fill(0);ue[J]=1;const oe=he(T,ue);for(let Y=0;Y<K;Y++)re[Y][J]=oe[Y]}return re}function z(T,K,re){const J=T.length,ue=J?T[0].length:0,oe=Array.from({length:ue},()=>new Array(ue).fill(0)),Y=new Array(ue).fill(0);for(let L=0;L<J;L++){const Q=re?re[L]:1,_=T[L];for(let C=0;C<ue;C++){const M=Q*_[C];Y[C]+=M*K[L];for(let i=C;i<ue;i++)oe[C][i]+=M*_[i]}}for(let L=0;L<ue;L++)for(let Q=0;Q<L;Q++)oe[L][Q]=oe[Q][L];return{xtwx:oe,xtwy:Y}}function te(T,K){return T.map(re=>re.reduce((J,ue,oe)=>J+ue*K[oe],0))}function x(T,K){let re=0;for(let J=0;J<T.length;J++){let ue=0;for(let oe=0;oe<T.length;oe++)ue+=K[J][oe]*T[oe];re+=T[J]*ue}return re}}),Se("packages/core/src/compute/sketch.js",function(o,me){"use strict";Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return oe}});class fe{#t=0;#e=0;#n=0;static get errorBound(){return Object.freeze({kind:"exact",metric:"none",value:0,statement:"mean and variance match a full recompute to float rounding"})}get count(){return this.#t}add(L){if(!Number.isFinite(L))return;this.#t++;const Q=L-this.#e;this.#e+=Q/this.#t,this.#n+=Q*(L-this.#e)}merge(L){if(L.#t===0)return;if(this.#t===0){this.#t=L.#t,this.#e=L.#e,this.#n=L.#n;return}const Q=this.#t+L.#t,_=L.#e-this.#e;this.#e+=_*(L.#t/Q),this.#n+=L.#n+_*_*(this.#t*L.#t/Q),this.#t=Q}mean(){return this.#t?this.#e:null}variance(){return this.#t>1?this.#n/(this.#t-1):null}varianceP(){return this.#t?this.#n/this.#t:null}stddev(){const L=this.variance();return L===null?null:Math.sqrt(L)}stddevP(){const L=this.varianceP();return L===null?null:Math.sqrt(L)}}class he{#t=[];#e=0;#n;#r;constructor(L,Q=Math.random){if(!(L>0))throw new RangeError("reservoir capacity must be positive");this.#n=Math.floor(L),this.#r=Q}static get errorBound(){return Object.freeze({kind:"probabilistic",metric:"none",value:0,statement:"uniform sample: each element included with probability capacity/n; sample statistics are unbiased estimators"})}get seen(){return this.#e}get size(){return this.#t.length}add(L){if(!Number.isFinite(L))return;if(this.#e++,this.#t.length<this.#n){this.#t.push(L);return}const Q=Math.floor(this.#r()*this.#e);Q<this.#n&&(this.#t[Q]=L)}sample(){return this.#t.slice()}mean(){if(!this.#t.length)return null;let L=0;for(const Q of this.#t)L+=Q;return L/this.#t.length}quantile(L){const Q=this.#t.length;if(!Q)return null;const _=this.#t.slice().sort((s,u)=>s-u);if(Q===1)return _[0];const C=(Q-1)*Math.min(1,Math.max(0,L)),M=Math.floor(C),i=Math.ceil(C);return M===i?_[M]:_[M]+(C-M)*(_[i]-_[M])}}function X(Y){return Y^=Y>>>16,Y=Math.imul(Y,2246822507),Y^=Y>>>13,Y=Math.imul(Y,3266489909),Y^=Y>>>15,Y>>>0}function z(Y){if(typeof Y=="number"){const _=new DataView(new ArrayBuffer(8));return _.setFloat64(0,Y===0?0:Y),X(_.getUint32(0)^_.getUint32(4))}const L=typeof Y=="string"?Y:String(Y);let Q=2166136261;for(let _=0;_<L.length;_++)Q^=L.charCodeAt(_),Q=Math.imul(Q,16777619);return X(Q)}class te{#t;#e;#n;constructor(L=14){const Q=Math.floor(L);if(Q<4||Q>16)throw new RangeError("HLL precision must be 4..16");this.#t=Q,this.#e=1<<Q,this.#n=new Uint8Array(this.#e)}static errorBoundFor(L=14){const Q=1<<Math.floor(L),_=1.04/Math.sqrt(Q);return Object.freeze({kind:"probabilistic",metric:"relative",value:_,statement:`distinct count within ~${(_*100).toFixed(2)}% relative standard error (m=${Q} buckets)`})}errorBound(){return te.errorBoundFor(this.#t)}add(L){const Q=z(L),_=Q&this.#e-1,C=Q>>>this.#t|1<<32-this.#t;let M=1,i=C;for(;(i&1)===0;)M++,i>>>=1;M>this.#n[_]&&(this.#n[_]=M)}count(){const L=this.#e,Q=32-this.#t,_=new Float64Array(Q+2);for(let i=0;i<L;i++)_[this.#n[i]]++;let C=L*K(1-_[Q+1]/L);for(let i=Q;i>=1;i--)C=.5*(C+_[i]);C+=L*T(_[0]/L);const M=x*L*L/C;return Math.round(M)}}const x=.5/Math.log(2);function T(Y){if(Y===1)return 1/0;let L=1,Q=Y,_;do Y*=Y,_=Q,Q+=Y*L,L+=L;while(Q!==_);return Q}function K(Y){if(Y===0||Y===1)return 0;let L=1,Q=1-Y,_;do Y=Math.sqrt(Y),_=Q,L*=.5,Q-=(1-Y)**2*L;while(Q!==_);return Q/3}class re{#t=new Map;#e;#n=0;constructor(L){if(!(L>0))throw new RangeError("Space-Saving capacity must be positive");this.#e=Math.floor(L)}errorBoundFor(L){const Q=L/this.#e;return Object.freeze({kind:"deterministic",metric:"absolute",value:Q,statement:`each count overestimates the truth by at most N/m = ${Q.toFixed(2)} (N=${L}, m=${this.#e})`})}get seen(){return this.#n}add(L){this.#n++;const Q=this.#t.get(L);if(Q){Q.count++;return}if(this.#t.size<this.#e){this.#t.set(L,{count:1,error:0});return}let _,C=1/0;for(const[M,i]of this.#t)i.count<C&&(C=i.count,_=M);this.#t.delete(_),this.#t.set(L,{count:C+1,error:C})}top(L=this.#e){return[...this.#t.entries()].map(([_,C])=>({item:_,count:C.count,error:C.error})).sort((_,C)=>C.count-_.count).slice(0,Math.max(0,Math.floor(L)))}}class J{#t;#e=[[]];#n=0;#r;#i;constructor(L=200,Q=Math.random){this.#t=Math.max(8,Math.floor(L)),this.#r=Q,this.#i=2/3}static errorBoundFor(L=200){const Q=1/Math.max(8,Math.floor(L));return Object.freeze({kind:"probabilistic",metric:"rank",value:Q,statement:`queried quantile\'s true rank within ~${(Q*100).toFixed(2)}% of N of the requested rank (k=${L})`})}errorBound(){return J.errorBoundFor(this.#t)}get count(){return this.#n}#s(L){const _=this.#e.length-1-L,C=Math.ceil(this.#t*this.#i**_);return Math.max(2,C)}add(L){Number.isFinite(L)&&(this.#n++,this.#e[0].push(L),this.#e[0].length>=this.#s(0)&&this.#h(0))}#h(L){const Q=this.#e[L];Q.sort((M,i)=>M-i),L+1>=this.#e.length&&this.#e.push([]);const _=this.#e[L+1],C=this.#r()<.5?0:1;for(let M=C;M<Q.length;M+=2)_.push(Q[M]);this.#e[L]=[];for(let M=0;M<this.#e.length;M++)if(this.#e[M].length>=this.#s(M)){this.#h(M);return}}#u(){const L=[];for(let Q=0;Q<this.#e.length;Q++){const _=1<<Q;for(const C of this.#e[Q])L.push({v:C,w:_})}return L}quantile(L){const Q=this.#u();if(!Q.length)return null;Q.sort((i,s)=>i.v-s.v);let _=0;for(const i of Q)_+=i.w;const C=Math.min(1,Math.max(0,L))*_;let M=0;for(const i of Q)if(M+=i.w,M>=C)return i.v;return Q[Q.length-1].v}rank(L){let Q=0;for(let _=0;_<this.#e.length;_++){const C=1<<_;for(const M of this.#e[_])M<=L&&(Q+=C)}return Q}}const ue=Object.freeze({distinct:te.errorBoundFor(14),median:J.errorBoundFor(200),p25:J.errorBoundFor(200),p75:J.errorBoundFor(200),p90:J.errorBoundFor(200),p95:J.errorBoundFor(200),p99:J.errorBoundFor(200),iqr:J.errorBoundFor(200),topK:Object.freeze({kind:"deterministic",metric:"absolute",value:0,statement:"each count overestimates the truth by at most N/m; top-K exact when the K-th item exceeds N/m"})}),oe={Welford:fe,Reservoir:he,HyperLogLog:te,SpaceSaving:re,KLL:J,hash32:z,SKETCH_BOUNDS:ue}}),Se("packages/core/src/compute/statistics.js",function(o,me){"use strict";Object.defineProperty(o,"KENDALL_LIMIT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"numbers",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"frequencies",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"herfindahl",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"entropy",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evenness",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"topShare",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"gini",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"moments",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"quantileSorted",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"STAT_FNS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"STAT_LABELS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"weightedAverage",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"extremeRow",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"correlation",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"trimmedMean",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"winsorizedMean",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"modifiedZOutliers",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"jarqueBera",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"weightedQuantile",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"pairs",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"covariance",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"regression",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"fitLinearModel",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"ADF_CT_CRITICAL",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"augmentedDickeyFuller",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"autocorrelations",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"spearman",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"kendall",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"seriesStats",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"D2_N2",{enumerable:!0,get:function(){return ot}}),Object.defineProperty(o,"D4_N2",{enumerable:!0,get:function(){return st}}),Object.defineProperty(o,"movingRanges",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(o,"withinSigma",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"capability",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"controlLimits",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(o,"westernElectricViolations",{enumerable:!0,get:function(){return ut}}),Object.defineProperty(o,"nelsonViolations",{enumerable:!0,get:function(){return ct}}),Object.defineProperty(o,"CONTROL_RULE_SETS",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(o,"controlViolations",{enumerable:!0,get:function(){return At}}),Object.defineProperty(o,"countOutside",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(o,"DEFAULT_CONFIDENCE",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(o,"meanInterval",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(o,"proportionInterval",{enumerable:!0,get:function(){return St}}),Object.defineProperty(o,"slopeInterval",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(o,"capabilityInterval",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(o,"standardizedMeanDifference",{enumerable:!0,get:function(){return lt}}),Object.defineProperty(o,"normalTotalVariation",{enumerable:!0,get:function(){return at}}),Object.defineProperty(o,"frequencyMap",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"categoricalDistance",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(o,"SUBSET_RELIABILITY_FLOOR",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"compareColumn",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"isNumericColumn",{enumerable:!0,get:function(){return ht}}),Object.defineProperty(o,"populationRead",{enumerable:!0,get:function(){return Rt}});const fe=me("packages/core/src/compute/handle.js"),he=fe.presenceReader,X=fe.valueReader,z=me("packages/core/src/compute/special.js"),te=z.studentTQuantile,x=z.studentT,T=z.normalQuantile,K=z.normalCdf,re=z.chiSquareUpperTail,J=me("packages/core/src/compute/linalg.js"),ue=J.cholesky,oe=J.choleskySolve,Y=J.choleskyInverse,L=J.normalEquations,Q=J.quadForm,C=me("packages/core/src/compute/sketch.js").SKETCH_BOUNDS,M=5e3,i=Object.freeze({variance:"rescan",varianceP:"rescan",stddev:"rescan",stddevP:"rescan",sumSquares:"rescan",weightedAvg:"rescan",median:"rescan",p25:"rescan",p75:"rescan",p90:"rescan",p95:"rescan",p99:"rescan",iqr:"rescan",mode:"rescan",distinct:"rescan",range:"rescan",skewness:"rescan",kurtosis:"rescan",geomean:"rescan",harmean:"rescan",mad:"rescan",argmin:"rescan",argmax:"rescan",hhi:"rescan",entropy:"rescan",evenness:"rescan",top3Share:"rescan",top10Share:"rescan",gini:"rescan",trimmedMean:"rescan",winsorizedMean:"rescan",robustOutliers:"rescan",jarqueBera:"rescan",passRate:"rescan",failureCount:"rescan"}),s=Object.freeze({distinct:Object.freeze({sketch:"HyperLogLog",bound:C.distinct}),median:Object.freeze({sketch:"KLL",bound:C.median}),p25:Object.freeze({sketch:"KLL",bound:C.p25}),p75:Object.freeze({sketch:"KLL",bound:C.p75}),p90:Object.freeze({sketch:"KLL",bound:C.p90}),p95:Object.freeze({sketch:"KLL",bound:C.p95}),p99:Object.freeze({sketch:"KLL",bound:C.p99}),iqr:Object.freeze({sketch:"KLL",bound:C.iqr}),top3Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK}),top10Share:Object.freeze({sketch:"SpaceSaving",bound:C.topK})});function u(b){const j=b==="sum"||b==="avg"||b==="countValues"||b==="min"||b==="max"?"maintained":Object.prototype.hasOwnProperty.call(i,b)?i[b]:null,y=Object.prototype.hasOwnProperty.call(s,b)?s[b]:null;return{stat:b,exact:j,approximate:y}}function f(b,j){const y=j.length,O=new Float64Array(y);let k=0;if(b&&(b.kind==="float64"||b.kind==="int32")){const I=b.values,D=he(b);for(let ie=0;ie<y;ie++){const se=j[ie];if(D&&D(se)!==1)continue;const we=I[se];Number.isNaN(we)||(O[k++]=we)}return O.subarray(0,k)}const W=X(b);for(let I=0;I<y;I++){const D=W(j[I]);if(D==null||D==="")continue;const ie=typeof D=="number"?D:Number(D);Number.isFinite(ie)&&(O[k++]=ie)}return O.subarray(0,k)}function c(b,j){const y=new Map,O=X(b);let k=0;for(let W=0;W<j.length;W++){const I=O(j[W]);if(I==null||I===""||typeof I=="number"&&Number.isNaN(I))continue;const D=typeof I=="object"?String(I):I;y.set(D,(y.get(D)||0)+1),k++}const N=[...y.values()].sort((W,I)=>I-W);return{counts:N,total:k,distinct:N.length}}function t(b){return b.total>0?b.counts.map(j=>j/b.total):[]}function a(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))O+=k*k;return O}function m(b,j){const y=c(b,j);if(!y.total)return null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O}function e(b,j){const y=c(b,j);if(!y.total||y.distinct<2)return y.total?1:null;let O=0;for(const k of t(y))k>0&&(O-=k*Math.log2(k));return O/Math.log2(y.distinct)}function d(b,j,y=3){const O=c(b,j);if(!O.total)return null;const k=Math.max(1,Math.floor(y));let N=0;for(let W=0;W<Math.min(k,O.counts.length);W++)N+=O.counts[W];return N/O.total}function h(b,j){const y=f(b,j),O=y.length;if(!O)return null;const k=y.slice().sort();if(k[0]<0)return null;let N=0,W=0;for(let I=0;I<O;I++)N+=k[I],W+=(I+1)*k[I];return N===0?0:2*W/(O*N)-(O+1)/O}function r(b){let j=0,y=0,O=0;for(let k=0;k<b.length;k++){const N=b[k];j++;const W=N-y;y+=W/j,O+=W*(N-y)}return{n:j,mean:y,m2:O}}function n(b,j){const y=b.length;if(!y)return NaN;if(y===1)return b[0];const O=(y-1)*Math.min(1,Math.max(0,j)),k=Math.floor(O),N=Math.ceil(O);return k===N?b[k]:b[k]+(O-k)*(b[N]-b[k])}function l(b,j){if(!b.length)return NaN;const y=b.slice().sort();return n(y,j)}function g(b,j){const y=X(b);let O=0,k=0,N=0;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=String(I).toUpperCase();D==="PASS"?O++:D==="FAIL"?k++:D==="WARN"&&N++}return{pass:O+N,fail:k,warn:N,judged:O+N+k}}const P=Object.freeze({hhi:(b,j)=>a(b,j),entropy:(b,j)=>m(b,j),evenness:(b,j)=>e(b,j),top3Share:(b,j)=>d(b,j,3),top10Share:(b,j)=>d(b,j,10),gini:(b,j)=>h(b,j),trimmedMean:(b,j)=>Z(f(b,j),.1),winsorizedMean:(b,j)=>R(f(b,j),.1),robustOutliers:(b,j)=>v(f(b,j),3.5),jarqueBera:(b,j)=>U(f(b,j)),variance:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?O/(y-1):null},varianceP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?O/y:null},stddev:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>1?Math.sqrt(O/(y-1)):null},stddevP:(b,j)=>{const{n:y,m2:O}=r(f(b,j));return y>0?Math.sqrt(O/y):null},median:(b,j)=>{const y=f(b,j);return y.length?l(y,.5):null},p25:(b,j)=>{const y=f(b,j);return y.length?l(y,.25):null},p75:(b,j)=>{const y=f(b,j);return y.length?l(y,.75):null},p90:(b,j)=>{const y=f(b,j);return y.length?l(y,.9):null},p95:(b,j)=>{const y=f(b,j);return y.length?l(y,.95):null},p99:(b,j)=>{const y=f(b,j);return y.length?l(y,.99):null},iqr:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=y.slice().sort();return n(O,.75)-n(O,.25)},mad:(b,j)=>{const y=f(b,j);if(!y.length)return null;const O=l(y,.5),k=new Float64Array(y.length);for(let N=0;N<y.length;N++)k[N]=Math.abs(y[N]-O);return l(k,.5)},range:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=1/0,k=-1/0;for(let N=0;N<y.length;N++)y[N]<O&&(O=y[N]),y[N]>k&&(k=y[N]);return k-O},distinct:(b,j)=>{const y=X(b),O=new Set;for(let k=0;k<j.length;k++){const N=y(j[k]);N==null||N===""||O.add(N instanceof Date?N.getTime():N)}return O.size},mode:(b,j)=>{const y=X(b),O=new Map;for(let W=0;W<j.length;W++){const I=y(j[W]);if(I==null||I==="")continue;const D=I instanceof Date?I.getTime():I;O.set(D,(O.get(D)||0)+1)}let k=null,N=1;for(const[W,I]of O)I>N&&(N=I,k=W);return k},skewness:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<3||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let D=0;D<y.length;D++)I+=((y[D]-k)/W)**3;return O/((O-1)*(O-2))*I},kurtosis:(b,j)=>{const y=f(b,j),{n:O,mean:k,m2:N}=r(y);if(O<4||N<=0)return null;const W=Math.sqrt(N/(O-1));let I=0;for(let se=0;se<y.length;se++)I+=((y[se]-k)/W)**4;const D=O*(O+1)/((O-1)*(O-2)*(O-3)),ie=3*(O-1)**2/((O-2)*(O-3));return D*I-ie},geomean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]<=0)return null;O+=Math.log(y[k])}return Math.exp(O/y.length)},harmean:(b,j)=>{const y=f(b,j);if(!y.length)return null;let O=0;for(let k=0;k<y.length;k++){if(y[k]===0)return null;O+=1/y[k]}return y.length/O},sumSquares:(b,j)=>{const y=f(b,j);let O=0;for(let k=0;k<y.length;k++)O+=y[k]*y[k];return O},passRate:(b,j)=>{const{pass:y,judged:O}=g(b,j);return O?y/O:null},failureCount:(b,j)=>g(b,j).fail}),S=Object.freeze({hhi:"Concentration (HHI)",entropy:"Entropy",evenness:"Evenness",top3Share:"Top 3 share",top10Share:"Top 10 share",gini:"Gini coefficient",trimmedMean:"Trimmed mean",winsorizedMean:"Winsorized mean",robustOutliers:"Outliers (robust)",jarqueBera:"Jarque–Bera",median:"Median",p25:"25th percentile",p75:"75th percentile",p90:"90th percentile",p95:"95th percentile",p99:"99th percentile",iqr:"Interquartile range",mad:"Median absolute deviation",variance:"Variance",varianceP:"Variance (population)",stddev:"Standard deviation",stddevP:"Standard deviation (population)",range:"Range",distinct:"Distinct",mode:"Mode",skewness:"Skewness",kurtosis:"Kurtosis",geomean:"Geometric mean",harmean:"Harmonic mean",sumSquares:"Sum of squares",weightedAvg:"Weighted average",argmin:"Lowest by",argmax:"Highest by",passRate:"Pass rate",failureCount:"Failures"});function G(b,j,y){const O=X(b),k=X(j);let N=0,W=0;for(let I=0;I<y.length;I++){const D=y[I],ie=Number(O(D)),se=Number(k(D));!Number.isFinite(ie)||!Number.isFinite(se)||(N+=ie*se,W+=se)}return W===0?null:N/W}function F(b,j,y){const O=X(b);let k=null,N=y?-1/0:1/0;for(let W=0;W<j.length;W++){const I=j[W],D=Number(O(I));Number.isFinite(D)&&(y?D>N:D<N)&&(N=D,k=I)}return k}function E(b,j,y){const O=X(b),k=X(j);let N=0,W=0,I=0,D=0,ie=0,se=0;for(let be=0;be<y.length;be++){const Ae=y[be],Pe=Number(O(Ae)),ye=Number(k(Ae));!Number.isFinite(Pe)||!Number.isFinite(ye)||(N++,W+=Pe,I+=ye,D+=Pe*Pe,ie+=ye*ye,se+=Pe*ye)}if(N<2)return null;const we=N*se-W*I,Oe=Math.sqrt((N*D-W*W)*(N*ie-I*I));if(Oe===0)return null;const je=we/Oe;return Math.max(-1,Math.min(1,je))}function Z(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((I,D)=>I-D),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O.slice(k,y-k);if(!N.length)return n(O,.5);let W=0;for(const I of N)W+=I;return W/N.length}function R(b,j=.1){const y=b.length;if(!y)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=Math.floor(y*Math.min(.49,Math.max(0,j))),N=O[k],W=O[y-1-k];let I=0;for(const D of O)I+=Math.min(W,Math.max(N,D));return I/y}function v(b,j=3.5){if(!b.length)return null;const O=Array.from(b).sort((D,ie)=>D-ie),k=n(O,.5),N=O.map(D=>Math.abs(D-k)).sort((D,ie)=>D-ie),W=n(N,.5);if(W===0)return null;let I=0;for(const D of O)Math.abs(.6745*(D-k)/W)>j&&I++;return I}function U(b){const j=b.length;if(j<8)return null;let y=0;for(const D of b)y+=D;y/=j;let O=0,k=0,N=0;for(const D of b){const ie=D-y;O+=ie*ie,k+=ie*ie*ie,N+=ie*ie*ie*ie}if(O/=j,k/=j,N/=j,O===0)return null;const W=k/O**1.5,I=N/(O*O)-3;return j/6*(W*W+I*I/4)}function V(b,j,y){const O=[];let k=0;for(let D=0;D<b.length;D++){const ie=Number(b[D]),se=Number(j[D]);!Number.isFinite(ie)||!Number.isFinite(se)||se<=0||(O.push([ie,se]),k+=se)}if(!O.length||k<=0)return null;if(O.sort((D,ie)=>D[0]-ie[0]),O.length===1)return O[0][0];const N=[];let W=0;for(const[,D]of O)N.push((W+D/2)/k),W+=D;const I=Math.max(0,Math.min(1,y));if(I<=N[0])return O[0][0];if(I>=N[N.length-1])return O[O.length-1][0];for(let D=1;D<N.length;D++){if(I>N[D])continue;const ie=N[D]-N[D-1],se=ie>0?(I-N[D-1])/ie:0;return O[D-1][0]+(O[D][0]-O[D-1][0])*se}return O[O.length-1][0]}function $(b,j,y){const O=X(b),k=X(j),N=new Float64Array(y.length),W=new Float64Array(y.length);let I=0;for(let D=0;D<y.length;D++){const ie=y[D],se=Number(O(ie)),we=Number(k(ie));!Number.isFinite(se)||!Number.isFinite(we)||(N[I]=se,W[I]=we,I++)}return{xs:N.subarray(0,I),ys:W.subarray(0,I),n:I}}function ee(b,j,y,O=!1){const{xs:k,ys:N,n:W}=$(b,j,y);if(W<2)return null;let I=0,D=0;for(let se=0;se<W;se++)I+=k[se],D+=N[se];I/=W,D/=W;let ie=0;for(let se=0;se<W;se++)ie+=(k[se]-I)*(N[se]-D);return ie/(O?W:W-1)}function ne(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;let W=0,I=0;for(let Pe=0;Pe<N;Pe++)W+=O[Pe],I+=k[Pe];W/=N,I/=N;let D=0,ie=0,se=0;for(let Pe=0;Pe<N;Pe++){const ye=O[Pe]-W,ve=k[Pe]-I;D+=ye*ye,ie+=ye*ve,se+=ve*ve}if(D===0)return null;const we=ie/D,Oe=I-we*W,je=se===0?1:Math.max(0,Math.min(1,ie*ie/(D*se))),be=Math.max(0,se-we*ie),Ae=N>2?Math.sqrt(be/(N-2)/D):0;return{slope:we,intercept:Oe,r2:je,stdError:Ae,n:N}}const ce=new Set(["ols","wls","robust"]),p=new Set(["quantile"]),B=new Set(["ridge","lasso","elasticnet","mixed","gls"]),H=1.345;function w(b,j,y){const{xtwx:O,xtwy:k}=L(b,j,y),N=ue(O);if(!N)return null;const W=oe(N,k),I=Y(N),D=A(b,W),ie=j.map((se,we)=>se-D[we]);return{beta:W,cov:I,fitted:D,residuals:ie}}function A(b,j){return b.map(y=>y.reduce((O,k,N)=>O+k*j[N],0))}function q(b,j){const y=b.length,O=b.map(ie=>ie[j]),k=b.map(ie=>[1,...ie.filter((se,we)=>we!==j)]),N=w(k,O,null);if(!N)return 1;const W=O.reduce((ie,se)=>ie+se,0)/y;let I=0,D=0;for(let ie=0;ie<y;ie++)I+=N.residuals[ie]**2,D+=(O[ie]-W)**2;return D===0?1:Math.max(0,Math.min(1,1-I/D))}function le(b){const j=[...b].sort((k,N)=>k-N),y=ae(j),O=b.map(k=>Math.abs(k-y)).sort((k,N)=>k-N);return ae(O)/.6745}function ae(b){const j=b.length;if(!j)return 0;const y=Math.floor(j/2);return j%2?b[y]:(b[y-1]+b[y])/2}function de(b,j,y={}){const O=y.method||"ols";if(B.has(O))throw new Error(`[lattice] regression method "${O}" is out of scope; use ols, wls or robust.`);if(p.has(O))throw new Error("[lattice] quantile regression is coming next and not yet available; use ols, wls or robust.");if(!ce.has(O))throw new Error(`[lattice] unknown regression method "${O}"; use ols, wls or robust.`);const k=Array.isArray(j)?j.length:0,N=k&&Array.isArray(b[0])?b[0].length:0,W=N+1;if(!(k>W))return null;for(let Me=0;Me<k;Me++){if(!Number.isFinite(j[Me])||!Array.isArray(b[Me])||b[Me].length!==N)return null;for(let Ne=0;Ne<N;Ne++)if(!Number.isFinite(b[Me][Ne]))return null}let I=null;if(O==="wls"){if(I=y.weights,!Array.isArray(I)||I.length!==k)return null;for(let Me=0;Me<k;Me++)if(!(I[Me]>0)||!Number.isFinite(I[Me]))return null}const D=b.map(Me=>[1,...Me]);let ie,se=null;if(O==="robust"){if(ie=w(D,j,null),!ie)return null;for(let Me=0;Me<50;Me++){const Ne=le(ie.residuals);if(!(Ne>0))break;const Ee=ie.residuals.map($e=>{const We=Math.abs($e/Ne);return We<=H?1:H/We}),Ce=w(D,j,Ee);if(!Ce)return null;const Ve=Ce.beta.reduce(($e,We,Je)=>Math.max($e,Math.abs(We-ie.beta[Je])),0);if(ie=Ce,se=Ee,Ve<1e-10)break}}else if(ie=w(D,j,I),!ie)return null;const we=O==="robust"?se:I,{beta:Oe,cov:je,fitted:be,residuals:Ae}=ie;let Pe=0,ye=0,ve=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Pe+=Ne*Ae[Me]**2,ye+=Ne,ve+=Ne*j[Me]}const Fe=ve/ye;let Ie=0;for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1;Ie+=Ne*(j[Me]-Fe)**2}const De=k-W,qe=Pe/De,Ue=Ie===0?1:Math.max(0,Math.min(1,1-Pe/Ie)),tt=1-(1-Ue)*(k-1)/De,Xe=Array.isArray(y.names)&&y.names.length===N?y.names:b[0].map((Me,Ne)=>`x${Ne+1}`),He=Qe(y.confidence),Ze=De>0?te(1-(1-He)/2,De):1/0,Lt=Oe.map((Me,Ne)=>{const Ee=Math.sqrt(Math.max(0,qe*je[Ne][Ne])),Ce=Ee>0?Me/Ee:Me===0?0:1/0,Ve=Number.isFinite(Ce)?2*(1-x(Math.abs(Ce),De)):0,$e=Number.isFinite(Ze)?Ze*Ee:null;return{name:Ne===0?"(intercept)":Xe[Ne-1],estimate:Me,stdError:Ee,t:Ce,p:Math.max(0,Math.min(1,Ve)),lower:$e===null?null:Me-$e,upper:$e===null?null:Me+$e}}),dt=new Array(k),mt=new Array(k);for(let Me=0;Me<k;Me++){const Ne=we?we[Me]:1,Ee=Math.max(0,Math.min(1,Ne*Q(D[Me],je)));dt[Me]=Ee;const Ce=(1-Ee)**2;mt[Me]=Ce>0&&qe>0?Ae[Me]**2/(W*qe)*(Ee/Ce):null}const Ft=b[0].map((Me,Ne)=>{if(N<2)return 1;const Ee=q(b,Ne);return Ee>=1?1/0:1/(1-Ee)});let gt=null;{const Me=Ae.map(Ee=>Ee*Ee),Ne=w(D,Me,null);if(Ne){const Ee=Me.reduce((Ye,Ct)=>Ye+Ct,0)/k;let Ce=0,Ve=0;for(let Ye=0;Ye<k;Ye++)Ce+=Ne.residuals[Ye]**2,Ve+=(Me[Ye]-Ee)**2;const $e=Ve===0?0:Math.max(0,Math.min(1,1-Ce/Ve)),We=k*$e,Je=re(We,N);gt={statistic:We,df:N,p:Je,heteroscedastic:Je<.05}}}let bt=null;if(N===1){const Me=b.map((Ne,Ee)=>Ee).sort((Ne,Ee)=>b[Ne][0]-b[Ee][0]);bt={confidence:He,points:Me.map(Ne=>{const Ee=D[Ne],Ce=Math.sqrt(Math.max(0,qe*Q(Ee,je)));return{x:b[Ne][0],yhat:be[Ne],lower:be[Ne]-Ze*Ce,upper:be[Ne]+Ze*Ce}})}}return{method:O,coefficients:Lt,r2:Ue,adjR2:tt,n:k,df:De,sigma2:qe,fitted:be,residuals:Ae,leverage:dt,cooksD:mt,vif:Ft,heteroscedasticity:gt,band:bt,weights:we?[...we]:null}}function pe(b){const j=b.length,y=Array.from({length:j},(N,W)=>W).sort((N,W)=>b[N]-b[W]),O=new Float64Array(j);let k=0;for(;k<j;){let N=k;for(;N+1<j&&b[y[N+1]]===b[y[k]];)N++;const W=(k+N)/2+1;for(let I=k;I<=N;I++)O[y[I]]=W;k=N+1}return O}const ge=Object.freeze({"1%":-3.9638,"5%":-3.4126,"10%":-3.1279});function ke(b){const j=[.01,.05,.1],y=[ge["1%"],ge["5%"],ge["10%"]];if(b<=y[0]){const N=(Math.log(j[1])-Math.log(j[0]))/(y[1]-y[0]);return Math.max(1e-4,Math.min(.01,Math.exp(Math.log(j[0])+N*(b-y[0]))))}if(b>=y[2]){const N=(Math.log(j[2])-Math.log(j[1]))/(y[2]-y[1]);return Math.max(.1,Math.min(.999,Math.exp(Math.log(j[2])+N*(b-y[2]))))}const O=b<y[1]?0:1,k=(b-y[O])/(y[O+1]-y[O]);return Math.exp(Math.log(j[O])+k*(Math.log(j[O+1])-Math.log(j[O])))}function Le(b,j,y,O){const k=y-O,N=O+3,W=new Array(k),I=new Array(k);let D=!0,ie=O;for(let be=0;be<k;be++){const Ae=O+be,Pe=new Float64Array(N);Pe[0]=1,Pe[1]=be+1,Pe[2]=b[Ae];for(let ye=1;ye<=O;ye++)Pe[2+ye]=j[Ae-ye];for(let ye=1;ye<N;ye++)Number.isFinite(Pe[ye])||(ie=Math.min(ie,ye-3));W[be]=Pe,I[be]=j[Ae],Number.isFinite(I[be])||(D=!1)}if(!D)return 0;const{xtwx:se,xtwy:we}=L(W,I,null);let Oe=0,je=1/0;for(let be=0;be<=ie;be++){const Ae=be+3;if(!(k>Ae))continue;const Pe=new Array(Ae);for(let Ue=0;Ue<Ae;Ue++)Pe[Ue]=se[Ue].slice(0,Ae);const ye=ue(Pe);if(!ye)continue;const ve=oe(ye,we.slice(0,Ae));let Fe=0;for(let Ue=0;Ue<k;Ue++){const tt=W[Ue];let Xe=0;for(let He=0;He<Ae;He++)Xe+=tt[He]*ve[He];Fe+=(I[Ue]-Xe)**2}const De=Fe/(k-Ae)*(k-Ae);if(!(De>0))continue;const qe=k*Math.log(De/k)+2*Ae;qe<je&&(je=qe,Oe=be)}return Oe}function Re(b,j={}){const y=[];for(let je=0;je<b.length;je++){const be=Number(b[je]);Number.isFinite(be)&&y.push(be)}const O=y.length,k=O-1;if(O<8||k<6)return null;const N=new Array(k);for(let je=0;je<k;je++)N[je]=y[je+1]-y[je];let W=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.ceil(12*(O/100)**.25);W=Math.max(0,Math.min(W,Math.floor((k-5)/2)));const I=(je,be)=>{const Ae=[],Pe=[];for(let ye=be;ye<k;ye++){const ve=[ye-be+1,y[ye]];for(let Fe=1;Fe<=je;Fe++)ve.push(N[ye-Fe]);Ae.push(ve),Pe.push(N[ye])}return de(Ae,Pe,{method:"ols"})},D=Le(y,N,k,W),ie=I(D,D);if(!ie||!ie.coefficients[2])return null;const se=ie.coefficients[2].t,we=ke(se),Oe=se<ge["5%"];return{statistic:se,usedLag:D,nobs:k-D,criticalValues:{...ge},pValue:we,pApproximate:!0,stationary:Oe,verdict:Oe?"stationary":"non-stationary",regression:"ct"}}function Be(b,j={}){const y=[];for(let Oe=0;Oe<b.length;Oe++){const je=Number(b[Oe]);Number.isFinite(je)&&y.push(je)}const O=y.length;if(O<3)return null;let k=Number.isFinite(j.maxlag)?Math.floor(j.maxlag):Math.min(10,O-1);k=Math.max(1,Math.min(k,O-1));let N=0;for(const Oe of y)N+=Oe;N/=O;const W=y.map(Oe=>Oe-N);let I=0;for(const Oe of W)I+=Oe*Oe;I/=O;const D=new Array(k+1).fill(0);D[0]=1;for(let Oe=1;Oe<=k;Oe++){let je=0;for(let be=Oe;be<O;be++)je+=W[be]*W[be-Oe];D[Oe]=I>0?je/O/I:0}const ie=new Array(k+1).fill(0);ie[0]=1;let se=[];for(let Oe=1;Oe<=k;Oe++){let je=D[Oe];for(let ye=1;ye<Oe;ye++)je-=se[ye-1]*D[Oe-ye];let be=1;for(let ye=1;ye<Oe;ye++)be-=se[ye-1]*D[ye];const Ae=be!==0?je/be:0,Pe=new Array(Oe);for(let ye=1;ye<Oe;ye++)Pe[ye-1]=se[ye-1]-Ae*se[Oe-1-ye];Pe[Oe-1]=Ae,ie[Oe]=Ae,se=Pe}const we=1.96/Math.sqrt(O);return{acf:D,pacf:ie,bounds:{upper:we,lower:-we},n:O,nlags:k,approximate:!0}}function ze(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2)return null;const W=pe(O),I=pe(k);let D=0,ie=0;for(let je=0;je<N;je++)D+=W[je],ie+=I[je];D/=N,ie/=N;let se=0,we=0,Oe=0;for(let je=0;je<N;je++){const be=W[je]-D,Ae=I[je]-ie;se+=be*Ae,we+=be*be,Oe+=Ae*Ae}return we===0||Oe===0?null:Math.max(-1,Math.min(1,se/Math.sqrt(we*Oe)))}function Ke(b,j,y){const{xs:O,ys:k,n:N}=$(b,j,y);if(N<2||N>M)return null;let W=0,I=0,D=0,ie=0;for(let Oe=0;Oe<N;Oe++)for(let je=Oe+1;je<N;je++){const be=Math.sign(O[Oe]-O[je]),Ae=Math.sign(k[Oe]-k[je]),Pe=be*Ae;Pe>0?W++:Pe<0?I++:be===0&&Ae===0||(be===0?D++:ie++)}const se=W+I+ie,we=W+I+D;return se===0||we===0?null:(W-I)/Math.sqrt(se*we)}function Te(b,j={}){const y=b.length;if(y<2)return null;const O=b[0],k=b[y-1],N=[];for(let ye=1;ye<y;ye++){const ve=b[ye-1];ve!==0&&N.push((b[ye]-ve)/Math.abs(ve))}let W=null;if(N.length>1){let ye=0;for(const Fe of N)ye+=Fe;ye/=N.length;let ve=0;for(const Fe of N)ve+=(Fe-ye)**2;W=Math.sqrt(ve/(N.length-1))}const I=Number(j.periodsPerYear)>0?Number(j.periodsPerYear):null;let D=b[0],ie=0,se=0,we=0,Oe=0;for(let ye=1;ye<y;ye++){if(b[ye]>D){D=b[ye],ie=ye;continue}if(D<=0)continue;const ve=(D-b[ye])/D;ve>se&&(se=ve,we=ie,Oe=ye)}let je=null;if(y>2){let ye=0;for(let Ie=0;Ie<y;Ie++)ye+=b[Ie];ye/=y;let ve=0,Fe=0;for(let Ie=0;Ie<y;Ie++){const De=b[Ie]-ye;Fe+=De*De,Ie>0&&(ve+=De*(b[Ie-1]-ye))}je=Fe>0?ve/Fe:null}let be=0,Ae=0;for(const ye of N)ye>0?be++:ye<0&&Ae++;let Pe=null;if(O>0&&k>0){const ye=(k/O)**(1/(y-1))-1;Pe=I?(1+ye)**I-1:ye}return{n:y,first:O,last:k,change:k-O,changePercent:O===0?null:(k-O)/Math.abs(O)*100,volatility:W,annualisedVolatility:W!==null&&I?W*Math.sqrt(I):null,growth:Pe,maxDrawdown:se,maxDrawdownFrom:we,maxDrawdownTo:Oe,autocorrelation:je,upDays:be,downDays:Ae}}const ot=1.128,st=3.267;function wt(b){const j=b.length;if(j<2)return null;const y=[];for(let k=1;k<j;k++)y.push(Math.abs(b[k]-b[k-1]));const O=y.reduce((k,N)=>k+N,0)/y.length;return{ranges:y,centre:O,upper:st*O,lower:0}}function xe(b){const j=b.length;if(j<2)return null;let y=0;for(let k=1;k<j;k++)y+=Math.abs(b[k]-b[k-1]);const O=y/(j-1);return{sigma:O/ot,meanRange:O}}function Ot(b,j){const y=b.length;if(y<2||!j)return null;const O=Number.isFinite(Number(j.lower))?Number(j.lower):null,k=Number.isFinite(Number(j.upper))?Number(j.upper):null;if(O===null&&k===null)return null;let N=0;for(let be=0;be<y;be++)N+=b[be];N/=y;let W=0;for(let be=0;be<y;be++)W+=(b[be]-N)**2;const I=Math.sqrt(W/(y-1)),D=xe(b),ie=D?D.sigma:null,se=be=>{if(!be||be<=0)return{index:null,k:null};const Pe=O!==null&&k!==null?(k-O)/(6*be):null,ye=k!==null?(k-N)/(3*be):1/0,ve=O!==null?(N-O)/(3*be):1/0;return{index:Pe,k:Math.min(ye,ve)}},we=se(ie),Oe=se(I);let je=0;for(let be=0;be<y;be++){if(O!==null&&b[be]<O){je++;continue}k!==null&&b[be]>k&&je++}return{n:y,mean:N,lower:O,upper:k,target:Number.isFinite(Number(j.target))?Number(j.target):null,sigmaWithin:ie,sigmaOverall:I,cp:we.index,cpk:we.k,pp:Oe.index,ppk:Oe.k,outOfSpec:je,defectRate:y?je/y:null}}function kt(b){const j=b.length;if(j<2)return null;const y=xe(b);if(!y||!(y.sigma>0))return null;let O=0;for(let k=0;k<j;k++)O+=b[k];return O/=j,{centre:O,sigma:y.sigma,upper:O+3*y.sigma,lower:O-3*y.sigma}}function ut(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=I=>(b[I]-O)/k,W=[];for(let I=0;I<y;I++){if(Math.abs(N(I))>3&&W.push({index:I,rule:1,description:"beyond three sigma"}),I>=2)for(const D of[1,-1]){let ie=0;for(let se=I-2;se<=I;se++)N(se)*D>2&&ie++;if(ie>=2){W.push({index:I,rule:2,description:"two of three past two sigma"});break}}if(I>=4)for(const D of[1,-1]){let ie=0;for(let se=I-4;se<=I;se++)N(se)*D>1&&ie++;if(ie>=4){W.push({index:I,rule:3,description:"four of five past one sigma"});break}}if(I>=7)for(const D of[1,-1]){let ie=!0;for(let se=I-7;se<=I;se++)if(N(se)*D<=0){ie=!1;break}if(ie){W.push({index:I,rule:4,description:"eight in a row on one side"});break}}}return W}function ct(b,j){if(!j||!(j.sigma>0))return[];const y=b.length,{centre:O,sigma:k}=j,N=D=>(b[D]-O)/k,W=(D,ie,se,we)=>{for(const Oe of[1,-1]){let je=0;for(let be=D;be<=ie;be++)N(be)*Oe>se&&je++;if(je>=we)return!0}return!1},I=[];for(let D=0;D<y;D++){if(Math.abs(N(D))>3&&I.push({index:D,rule:1,description:"beyond three sigma"}),D>=8)for(const ie of[1,-1]){let se=!0;for(let we=D-8;we<=D;we++)if(N(we)*ie<=0){se=!1;break}if(se){I.push({index:D,rule:2,description:"nine in a row on one side"});break}}if(D>=5)for(const ie of[1,-1]){let se=!0;for(let we=D-4;we<=D;we++)if((b[we]-b[we-1])*ie<=0){se=!1;break}if(se){I.push({index:D,rule:3,description:ie>0?"six rising":"six falling"});break}}if(D>=13){let ie=!0;for(let se=D-12;se<=D;se++){const we=b[se]-b[se-1],Oe=b[se+1<=D?se+1:se]-b[se];if(se+1>D)break;if(we===0||Oe===0||we>0==Oe>0){ie=!1;break}}ie&&I.push({index:D,rule:4,description:"fourteen alternating"})}if(D>=2&&W(D-2,D,2,2)&&I.push({index:D,rule:5,description:"two of three past two sigma"}),D>=4&&W(D-4,D,1,4)&&I.push({index:D,rule:6,description:"four of five past one sigma"}),D>=14){let ie=!0;for(let se=D-14;se<=D;se++)if(Math.abs(N(se))>=1){ie=!1;break}ie&&I.push({index:D,rule:7,description:"fifteen within one sigma"})}if(D>=7){let ie=!0;for(let se=D-7;se<=D;se++)if(Math.abs(N(se))<=1){ie=!1;break}ie&&I.push({index:D,rule:8,description:"eight beyond one sigma"})}}return I}const jt=Object.freeze(["westernElectric","nelson"]);function At(b,j,y="westernElectric"){return String(y)==="nelson"?ct(b,j):ut(b,j)}function Mt(b,j,y){let O=0;for(let k=0;k<b.length;k++)(b[k]<j||b[k]>y)&&O++;return O}function Pt(b,j,y,O=20){const k=b.length;if(!k)return[];const N=b[0],W=b[k-1];if(W===N)return[{from:N,to:W,count:k}];const I=y-j,D=1.5*I;let ie=I>0?Math.max(N,j-D):N,se=I>0?Math.min(W,y+D):W;se>ie||(ie=N,se=W);const we=I>0?2*I/Math.cbrt(k):(se-ie)/(Math.ceil(Math.log2(k))+1),Oe=we>0?Math.min(O,Math.max(1,Math.ceil((se-ie)/we))):1,je=(se-ie)/Oe,be=[];for(let Ae=0;Ae<Oe;Ae++)be.push({from:ie+Ae*je,to:ie+(Ae+1)*je,count:0});for(let Ae=0;Ae<k;Ae++){const Pe=Math.min(Oe-1,Math.max(0,Math.floor((b[Ae]-ie)/je)));be[Pe].count++}return be[0].from=N,be[Oe-1].to=W,be}const Ge=.95;function Qe(b){const j=Number(b);return Number.isFinite(j)&&j>0&&j<1?j:Ge}function Nt(b,j=Ge){const y=b.length;if(y<2)return null;let O=0;for(let se=0;se<y;se++)O+=b[se];const k=O/y;let N=0;for(let se=0;se<y;se++){const we=b[se]-k;N+=we*we}const W=Math.sqrt(N/(y-1)),I=Qe(j),ie=te(1-(1-I)/2,y-1)*W/Math.sqrt(y);return{mean:k,lower:k-ie,upper:k+ie,margin:ie,n:y,confidence:I}}function St(b,j,y=Ge){const O=Number(b),k=Number(j);if(!(k>0)||!(O>=0)||O>k)return null;const N=Qe(y),W=T(1-(1-N)/2),I=O/k,D=W*W,ie=1+D/k,se=(I+D/(2*k))/ie,we=W/ie*Math.sqrt(I*(1-I)/k+D/(4*k*k));return{proportion:I,lower:Math.max(0,se-we),upper:Math.min(1,se+we),n:k,confidence:N}}function vt(b,j=Ge){if(!b||!(b.n>2)||!Number.isFinite(b.stdError))return null;const y=Qe(j),k=te(1-(1-y)/2,b.n-2)*b.stdError;return{slope:b.slope,lower:b.slope-k,upper:b.slope+k,margin:k,confidence:y}}function Tt(b,j,y=Ge){const O=Number(b),k=Number(j);if(!Number.isFinite(O)||!(k>1))return null;const N=Qe(y),I=T(1-(1-N)/2)*Math.sqrt(1/(9*k)+O*O/(2*(k-1)));return{index:O,lower:O-I,upper:O+I,margin:I,n:k,confidence:N}}function lt(b,j){return!b||!(b.sd>0)||!Number.isFinite(j)||!Number.isFinite(b.mean)?null:(j-b.mean)/b.sd}function at(b){return Number.isFinite(b)?Math.min(1,Math.max(0,2*K(Math.abs(b)/2)-1)):0}function _e(b,j){const y=new Map,O=X(b);let k=0;for(let N=0;N<j.length;N++){const W=O(j[N]);if(W==null||W===""||typeof W=="number"&&Number.isNaN(W))continue;const I=W instanceof Date?W.getTime():typeof W=="object"?String(W):W;y.set(I,(y.get(I)||0)+1),k++}return{map:y,total:k}}function ft(b,j,y,O){if(!(j>0)||!(O>0))return null;let k=0;const N=new Set(b.keys());for(const W of y.keys())N.add(W);for(const W of N){const I=(b.get(W)||0)/j,D=(y.get(W)||0)/O;k+=Math.abs(I-D)}return k/2}const et=10;function Et(b,j,y){if(y&&y.numeric){const I=f(b,j),{n:D,mean:ie}=r(I),se=D>0?lt({mean:y.mean,sd:y.sd},ie):null;return{measure:"standardizedMeanDifference",magnitude:se,distance:se===null?0:at(se),direction:se===null?0:Math.sign(se),subsetN:D,populationN:y.n||0,reliable:D>=et}}const{map:k,total:N}=_e(b,j),W=ft(k,N,y.map,y.total);return{measure:"categoricalTotalVariation",magnitude:W,distance:W===null?0:W,direction:0,subsetN:N,populationN:y.total||0,reliable:N>=et}}function ht(b,j){if(b&&(b.kind==="float64"||b.kind==="int32"))return!0;const y=X(b);let O=0,k=0;for(let N=0;N<j.length&&O<200;N++){const W=y(j[N]);if(W==null||W==="")continue;if(W instanceof Date)return!1;O++;const I=typeof W=="number"?W:Number(W);Number.isFinite(I)&&k++}return O===0?!1:k/O>=.9}function Rt(b,j){if(ht(b,j)){const k=f(b,j),{n:N,mean:W,m2:I}=r(k);return{numeric:!0,mean:W,sd:N>0?Math.sqrt(I/N):0,n:N}}const{map:y,total:O}=_e(b,j);return{numeric:!1,map:y,total:O}}}),Se("packages/core/src/compute/total.js",function(o,me){"use strict";Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"aggregatesFor",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"aggregateAllowed",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return h}});const fe=me("packages/core/src/internal/util.js"),he=fe.isFunction,X=fe.warnOnce,z=me("packages/core/src/compute/handle.js"),te=z.presenceReader,x=z.valueComparator,T=z.valueReader,K=me("packages/core/src/compute/statistics.js"),re=K.STAT_FNS,J=K.STAT_LABELS;function ue(r){return!!r&&(r.kind==="float64"||r.kind==="int32")}function oe(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++){const E=S[n[F]];Number.isNaN(E)||(g+=E)}return g}for(let F=0;F<l;F++){const E=n[F];if(G(E)===1){const Z=S[E];Number.isNaN(Z)||(g+=Z)}}return g}const P=T(r);for(let S=0;S<l;S++){const G=u(P(n[S]));G!==null&&(g+=G)}return g}oe.kernel=!0;function Y(r,n){const l=n.length;let g=0;if(ue(r)){const S=r.values,G=te(r);if(!G){for(let F=0;F<l;F++)Number.isNaN(S[n[F]])||g++;return g}for(let F=0;F<l;F++){const E=n[F];G(E)===1&&!Number.isNaN(S[E])&&g++}return g}const P=T(r);for(let S=0;S<l;S++){const G=P(n[S]);G!=null&&!(typeof G=="number"&&Number.isNaN(G))&&g++}return g}Y.kernel=!0;function L(r,n){return n.length}L.kernel=!0;function Q(r,n){const l=Y(r,n);return l===0?null:oe(r,n)/l}Q.kernel=!0;function _(r,n,l,g){const P=n.length;if(ue(r)){const E=r.values,Z=te(r);let R=null;if(!Z){for(let v=0;v<P;v++){const U=E[n[v]];Number.isNaN(U)||(R===null||(l<0?U<R:U>R))&&(R=U)}return R}for(let v=0;v<P;v++){const U=n[v];if(Z(U)===0)continue;const V=E[U];Number.isNaN(V)||(R===null||(l<0?V<R:V>R))&&(R=V)}return R}const S=T(r),G=x(g);let F=null;for(let E=0;E<P;E++){const Z=S(n[E]);Z==null||typeof Z=="number"&&Number.isNaN(Z)||(F===null||(l<0?G(Z,F)<0:G(Z,F)>0))&&(F=Z)}return F}function C(r,n,l){return _(r,n,-1,l&&l.locale)}C.kernel=!0;function M(r,n,l){return _(r,n,1,l&&l.locale)}M.kernel=!0;function i(r,n){return n.length===0?null:T(r)(n[0])}i.kernel=!0;function s(r,n){return n.length===0?null:T(r)(n[n.length-1])}s.kernel=!0;function u(r){if(typeof r=="number")return Number.isNaN(r)?null:r;if(r==null||r===""||typeof r=="boolean")return null;if(r instanceof Date)return r.getTime();const n=Number(r);return Number.isNaN(n)?null:n}const f={sum:oe,min:C,max:M,avg:Q,count:L,first:i,last:s,countValues:Y,...re},c=Object.freeze({...J,sum:"Sum",avg:"Average",min:"Min",max:"Max",count:"Count",countValues:"Count of values",first:"First",last:"Last"});function t(r){return r?typeof r=="string"?c[r]||r:"Total":""}const a=Object.freeze(["sum","avg","min","max","count","countValues","first","last"]);function m(r){const n=r&&r.dataType&&r.dataType.totals&&r.dataType.totals.supported;if(Array.isArray(n))return n.slice();const l=a.filter(g=>g in f);for(const g of Object.keys(f))l.includes(g)||l.push(g);return l}function e(r,n){return typeof n!="string"?!0:m(r).includes(n)}function d(r,n){const l=T(r),g=[];for(let P=0;P<n.length;P++){const S=l(n[P]);S!=null&&g.push(S)}return g}function h(r,n,l,g){const P=n||[];if(typeof l=="string"){const S=f[l];return S?S(r,P,g):(X(`total:${l}`,`unknown total function "${l}"; register it in config.totalFns`),null)}return he(l)?l.kernel===!0?l(r,P,g):l(d(r,P),g||{}):null}}),Se("packages/core/src/compute/pivot.js",function(o,me){"use strict";Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/internal/util.js").warnOnce,z=me("packages/core/src/compute/handle.js").valueComparator,x=me("packages/core/src/compute/group.js").packKeys,K=me("packages/core/src/compute/total.js").total,re="|",J="/",ue=2e3;function oe(u,f,c){return`${u}${re}${f}${re}${c}`}function Y(u,f){let c="";for(let t=0;t<u.length;t++){const a=u[t];c+=(t===0?"":f)+(a==null?"":String(a))}return c}function L(u,f,c={}){const t=c.separator||J,a=f.length,{keyOf:m,readers:e}=x(u,f,0),d=new Map,h=[],r=[];for(let F=0;F<a;F++){const E=f[F],Z=m(E);if(d.has(Z))continue;d.set(Z,h.length),r.push(Z);const R=new Array(e.length);for(let v=0;v<e.length;v++)R[v]=e[v](E);h.push(R)}const n=z(c.locale),l=h.map((F,E)=>E);l.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Q(Z[v],R[v],n);if(U!==0)return U}return F-E});const g=new Array(l.length),P=new Array(l.length),S=new Map;for(let F=0;F<l.length;F++){const E=l[F];g[F]=h[E],P[F]=Y(h[E],t),S.set(r[E],F)}return{keys:g,paths:P,idOf:F=>{const E=S.get(m(F));return E===void 0?-1:E}}}function Q(u,f,c){const t=u==null,a=f==null;return t||a?t&&a?0:t?1:-1:c(u,f)}function _(u){const f=u.values||u.totals||[];if(f.length&&typeof f[0]=="object"&&f[0]!==null)return f.filter(m=>m&&m.handle);const c=typeof u.handle=="function"?u.handle:null;if(!c)return f.length&&he("pivot:handles","pivot was given total column ids but no handle(colId) resolver, so no cell values were reduced. Pass values: [{ colId, handle, fn }] or opts.handle."),[];const t=typeof u.totalOf=="function"?u.totalOf:null,a=[];for(const m of f){const e=c(m);e&&a.push({colId:m,handle:e,fn:t?t(m):"sum"})}return a}function C(u,f,c){if(Array.isArray(u)){const t=c||{};return{...t,pivotHandles:u,order:f||null,groups:t.groups||null}}return u||{}}function M(u,f,c){const t=C(u,f,c),a=t.separator||J,m=_(t),e=t.maxColumns===void 0?ue:t.maxColumns,d=t.groups&&t.groups.buckets?t.groups:null,h=d?d.buckets:[t.order||new Uint32Array(0)],r=t.groupPaths||(d?d.keys.map(Z=>Y(Z,a)):[""]),n=s(h),{keys:l,paths:g,idOf:P}=L(t.pivotHandles||[],n,t),S=g.length*Math.max(1,m.length),G=i(g,m,a);if(e&&S>e){const Z=new Map;return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:Z,cells:Z,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${S} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:S,maxColumns:e}}}const F=new Map,E=g.length;for(let Z=0;Z<h.length;Z++){const R=h[Z],v=r[Z]===void 0?"":r[Z],U=R.length;if(U===0)continue;const V=new Int32Array(U),$=new Uint32Array(E+1);for(let ce=0;ce<U;ce++){const p=P(R[ce]);V[ce]=p,p>=0&&$[p+1]++}for(let ce=0;ce<E;ce++)$[ce+1]+=$[ce];const ee=new Uint32Array(U),ne=$.slice(0,E);for(let ce=0;ce<U;ce++){const p=V[ce];p>=0&&(ee[ne[p]++]=R[ce])}for(let ce=0;ce<E;ce++){const p=$[ce],B=$[ce+1];if(B===p)continue;const H=ee.subarray(p,B);for(let w=0;w<m.length;w++){const A=m[w],q=K(A.handle,H,A.fn,t.totalContext||{locale:t.locale});F.set(oe(v,g[ce],A.colId),q)}}}return{keys:l,paths:g,fields:G,groupPaths:r,columns:S,values:F,cells:F,error:null}}function i(u,f,c){if(f.length===0)return u.slice();const t=[];for(const a of u)for(const m of f)t.push(`${a}${c}${m.colId}`);return t}function s(u){if(u.length===1)return u[0]||new Uint32Array(0);let f=0;for(const a of u)f+=a?a.length:0;const c=new Uint32Array(f);let t=0;for(const a of u)!a||a.length===0||(c.set(a,t),t+=a.length);return c}}),Se("packages/core/src/compute/pivotmatrix.js",function(o,me){"use strict";Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return M}});const he=me("packages/core/src/compute/handle.js").valueComparator,z=me("packages/core/src/compute/total.js").total,x=me("packages/core/src/compute/group.js").packKeys,T=me("packages/core/src/compute/pivot.js"),K=T.joinPath,re=T.DEFAULT_PATH_SEPARATOR,J=T.DEFAULT_MAX_COLUMNS,ue="";function oe(i,s,u={}){const f=u.separator||re,c=i||[],t=s instanceof Uint32Array?s:Uint32Array.from(s||[]),a=t.length;if(c.length===0)return{tuples:[[]],paths:[ue],buckets:[t]};const{keyOf:m,readers:e}=x(c,t,0),d=new Map,h=[],r=[],n=[];for(let F=0;F<a;F++){const E=t[F],Z=m(E);let R=d.get(Z);if(R===void 0){R=h.length,d.set(Z,R),r.push(Z);const v=new Array(e.length);for(let U=0;U<e.length;U++)v[U]=e[U](E);h.push(v),n.push([])}n[R].push(E)}const l=he(u.locale),g=h.map((F,E)=>E);g.sort((F,E)=>{const Z=h[F],R=h[E];for(let v=0;v<Z.length;v++){const U=Y(Z[v],R[v],l);if(U!==0)return U}return F-E});const P=new Array(g.length),S=new Array(g.length),G=new Array(g.length);for(let F=0;F<g.length;F++){const E=g[F];P[F]=h[E],S[F]=K(h[E],f),G[F]=Uint32Array.from(n[E])}return{tuples:P,paths:S,buckets:G}}function Y(i,s,u){const f=i==null,c=s==null;return f||c?f&&c?0:f?1:-1:u(i,s)}function L(i,s,u){const f=[];for(let c=0;c<i.length;c++)u.has(i[c])&&f.push(i[c]);return Uint32Array.from(f)}function Q(i,s,u,f){return{value:s.length?z(i,s,u,f):null,leaves:s,count:s.length}}function _(i){const s=i&&i.opts||{},u=s.separator||re,f=s.totalContext||{locale:s.locale},c=(i.measures||[]).filter(S=>S&&S.handle),t=i.leaves instanceof Uint32Array?i.leaves:Uint32Array.from(i.leaves||[]),a=oe(i.rowHandles||[],t,{...s,separator:u}),m=oe(i.columnHandles||[],t,{...s,separator:u}),e=s.maxColumns===void 0?J:s.maxColumns,d=m.paths.length*Math.max(1,c.length),h=new Map;if(e&&d>e)return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:h,rowMargin:h,columnMargin:h,grand:h,columns:d,error:{code:"pivot-max-columns",message:`[lattice] pivot would generate ${d} columns, above pivot.maxColumns of ${e}. Narrow the pivot columns or raise the limit.`,columns:d,maxColumns:e}};const r=new Map,n=new Map,l=new Map,g=new Map,P=m.buckets.map(S=>new Set(S));for(let S=0;S<m.paths.length;S++){const G=m.buckets[S],F=m.paths[S];for(const E of c)l.set(M(F,E.colId),Q(E.handle,G,E.fn,f))}for(let S=0;S<a.paths.length;S++){const G=a.buckets[S],F=a.paths[S];for(const E of c)n.set(M(F,E.colId),Q(E.handle,G,E.fn,f));for(let E=0;E<m.paths.length;E++){const Z=L(G,m.buckets[E],P[E]);if(Z.length===0)continue;const R=m.paths[E];for(const v of c)r.set(C(F,R,v.colId),Q(v.handle,Z,v.fn,f))}}for(const S of c)g.set(S.colId,Q(S.handle,t,S.fn,f));return{rowAxis:a,columnAxis:m,measures:c.map(S=>({colId:S.colId,fn:S.fn})),body:r,rowMargin:n,columnMargin:l,grand:g,columns:d,error:null}}function C(i,s,u){return`${i}\\0${s}\\0${u}`}function M(i,s){return`${i}\\0${s}`}}),Se("packages/core/src/compute/reference.js",function(o,me){"use strict";Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return _}});const he=me("packages/core/src/internal/util.js").getPath,X=me("packages/core/src/compute/handle.js"),z=X.isMissing,te=X.valueComparator,T=me("packages/core/src/compute/filter.js").testValue,K="",re="\\0";function J(i,s){const u=s.includes(".")?he(i,s):i?.[s];return u===void 0?null:u}function ue(i,s,u={}){const f=s||[];let c=i.map((t,a)=>a);if(f.length===0)return c;for(let t=f.length-1;t>=0;t--)c=oe(i,c,f[t],u);return c}function oe(i,s,u,f){const c=u.locale!==void 0?u.locale:f.locale,t=te(c),a=u.descending!==void 0?!!u.descending:u.dir==="desc",m=[],e=[];for(const r of s){const n=J(i[r],u.col);z(n)?e.push(r):m.push(r)}const d=new Map;for(let r=0;r<m.length;r++)d.set(m[r],r);const h=(r,n)=>{const l=J(i[r],u.col),g=J(i[n],u.col);let P;return typeof u.compare=="function"?(P=u.compare(l,g,i[r],i[n],a),a&&(P=-P)):P=a?t(g,l):t(l,g),P!==0?P:d.get(r)-d.get(n)};return m.sort(h),u.nullsFirst?e.concat(m):m.concat(e)}function Y(i,s,u={}){const f=[];for(let c=0;c<i.length;c++)L(i[c],s,u,c)&&f.push(c);return f}function L(i,s,u,f){if(!s)return!0;if(Array.isArray(s.conditions)){const c=s.conditions.filter(a=>a!=null);if(c.length===0)return!0;if(s.op==="or")return c.some(a=>L(i,a,u,f));const t=c.every(a=>L(i,a,u,f));return s.op==="not"?!t:t}return s.col===void 0&&typeof u.custom=="function"?!!u.custom(s,i,f):T(J(i,s.col),s,u.locale)}function Q(i,s,u,f){const c=u||i.map((e,d)=>d),t=new Map,a=[],m=[];for(const e of c){const d=s.map((n,l)=>{const g=J(i[e],n);return f&&f[l]?f[l](g):g}),h=d.map(n=>n==null?re:String(n)).join(K);let r=t.get(h);r===void 0&&(r=a.length,t.set(h,r),a.push(d),m.push([])),m[r].push(e)}return{keys:a,buckets:m}}function _(i,s,u={}){const f=te(u.locale),c=i.filter(a=>!z(a)),t=c.map(C).filter(a=>a!==null);switch(s){case"count":return i.length;case"countValues":return c.length;case"sum":return t.reduce((a,m)=>a+m,0);case"avg":return c.length===0?null:t.reduce((a,m)=>a+m,0)/c.length;case"min":return c.length===0?null:c.reduce((a,m)=>f(m,a)<0?m:a);case"max":return c.length===0?null:c.reduce((a,m)=>f(m,a)>0?m:a);case"first":return i.length===0?null:M(i[0]);case"last":return i.length===0?null:M(i[i.length-1]);default:return null}}function C(i){if(typeof i=="number")return Number.isNaN(i)?null:i;if(i==null||i===""||typeof i=="boolean")return null;if(i instanceof Date)return i.getTime();const s=Number(i);return Number.isNaN(s)?null:s}function M(i){return i===void 0?null:i}}),Se("packages/core/src/compute/windowed.js",function(o,me){"use strict";Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return x}});const he=me("packages/core/src/compute/sketch.js").Welford;class X{#t;#e;#n=[];#r;#i;constructor(K,re=0,J=Date.now){if(K!=="count"&&K!=="time"&&K!=="session")throw new RangeError(`unknown window kind: ${K}`);if((K==="count"||K==="time")&&!(re>0))throw new RangeError(`a ${K} window needs a positive span`);this.#t=K,this.#e=Math.floor(re),this.#r=J,this.#i=J()}get size(){return this.#n.length}push(K,re=this.#r()){Number.isFinite(K)&&(this.#n.push({t:re,v:K}),this.#s(re))}#s(K){if(this.#t==="count")for(;this.#n.length>this.#e;)this.#n.shift();else if(this.#t==="time"){const re=K-this.#e;for(;this.#n.length&&this.#n[0].t<re;)this.#n.shift()}}spec(){const K=this.#t==="session"?this.#r()-this.#i:this.#e;return{kind:this.#t,span:K,size:this.#n.length}}values(){return this.#n.map(K=>K.v)}aggregate(){const K=this.spec();if(!this.#n.length)return{over:K,count:0,sum:null,mean:null,min:null,max:null,variance:null,stddev:null};const re=new he;let J=0,ue=1/0,oe=-1/0;for(const{v:Y}of this.#n)J+=Y,Y<ue&&(ue=Y),Y>oe&&(oe=Y),re.add(Y);return{over:K,count:this.#n.length,sum:J,mean:re.mean(),min:ue,max:oe,variance:re.variance(),stddev:re.stddev()}}reduce(K){const re=this.aggregate(),J={sum:re.sum,avg:re.mean,mean:re.mean,min:re.min,max:re.max,count:re.count,variance:re.variance,stddev:re.stddev};if(!(K in J))throw new RangeError(`unknown windowed aggregate: ${K}`);return{value:J[K],over:re.over}}}const z=Object.freeze(["count","time","session"]);function te(T,K=Date.now){const re=T.kind==="time"&&T.minutes!=null?T.minutes*6e4:T.span??0;return new X(T.kind,re,K)}const x={Window:X,WINDOW_KINDS:z,openWindow:te}}),Se("packages/core/src/compute/anomaly.js",function(o,me){"use strict";Object.defineProperty(o,"MAD_SCALE",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"DEFAULT_MODIFIED_Z_THRESHOLD",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"DEFAULT_IQR_K",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"DEFAULT_CHI_SQUARE_P",{enumerable:!0,get:function(){return K}}),Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"robustSpread",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"chiSquareCdf",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"chiSquareQuantile",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"DEFAULT_ROLLING_WINDOW",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return f}});const he=me("packages/core/src/compute/statistics.js").quantileSorted,z=me("packages/core/src/compute/special.js").logGamma,te=.6745,x=3.5,T=1.5,K=.975,re=Object.freeze(["modifiedZScore","iqr","mahalanobis"]);function J(c){if(!c.length)return null;const a=Array.from(c,Number).sort((h,r)=>h-r),m=he(a,.5),e=a.map(h=>Math.abs(h-m)).sort((h,r)=>h-r),d=he(e,.5);return{median:m,mad:d}}function ue(c,t={}){const a=Number.isFinite(t.threshold)?t.threshold:x,m=c.length,e=new Array(m).fill(null),d=new Array(m).fill(!1),h=[];for(let l=0;l<m;l++){const g=Number(c[l]);Number.isFinite(g)&&h.push(g)}if(!h.length)return{median:null,mad:null,threshold:a,scores:e,flags:d,flagged:0};const r=J(h);if(r.mad===0)return{median:r.median,mad:0,threshold:a,scores:e,flags:d,flagged:0};let n=0;for(let l=0;l<m;l++){const g=Number(c[l]);if(!Number.isFinite(g))continue;const P=te*(g-r.median)/r.mad;e[l]=P,Math.abs(P)>a&&(d[l]=!0,n++)}return{median:r.median,mad:r.mad,threshold:a,scores:e,flags:d,flagged:n}}function oe(c,t={}){const a=Number.isFinite(t.k)?t.k:T,m=[];for(let n=0;n<c.length;n++){const l=Number(c[n]);Number.isFinite(l)&&m.push(l)}if(!m.length)return null;const e=m.sort((n,l)=>n-l),d=he(e,.25),h=he(e,.75),r=h-d;return{q1:d,q3:h,iqr:r,lower:d-a*r,upper:h+a*r,k:a}}function Y(c,t){if(t<=0)return 0;const a=z(c);if(t<c+1){let l=c,g=1/c,P=g;for(let S=0;S<1e3&&(l+=1,P*=t/l,g+=P,!(Math.abs(P)<Math.abs(g)*1e-15));S++);return g*Math.exp(-t+c*Math.log(t)-a)}const m=1e-300;let e=t+1-c,d=1/m,h=1/e,r=h;for(let l=1;l<1e3;l++){const g=-l*(l-c);e+=2,h=g*h+e,Math.abs(h)<m&&(h=m),d=e+g/d,Math.abs(d)<m&&(d=m),h=1/h;const P=h*d;if(r*=P,Math.abs(P-1)<1e-15)break}return 1-Math.exp(-t+c*Math.log(t)-a)*r}function L(c,t){return c<=0?0:Y(t/2,c/2)}function Q(c,t=K){if(!(t>0)||!(t<1))return NaN;let a=0,m=Math.max(1,c);for(;L(m,c)<t;)m*=2;for(let e=0;e<200;e++){const d=(a+m)/2;if(L(d,c)<t?a=d:m=d,m-a<1e-10)break}return(a+m)/2}function _(c){const t=c.length,a=c.map((m,e)=>{const d=m.slice();for(let h=0;h<t;h++)d.push(e===h?1:0);return d});for(let m=0;m<t;m++){let e=m;for(let h=m+1;h<t;h++)Math.abs(a[h][m])>Math.abs(a[e][m])&&(e=h);if(Math.abs(a[e][m])<1e-12)return null;if(e!==m){const h=a[e];a[e]=a[m],a[m]=h}const d=a[m][m];for(let h=0;h<2*t;h++)a[m][h]/=d;for(let h=0;h<t;h++){if(h===m)continue;const r=a[h][m];if(r!==0)for(let n=0;n<2*t;n++)a[h][n]-=r*a[m][n]}}return a.map(m=>m.slice(t))}function C(c,t){const a=c.length,m=new Array(t).fill(0);for(const h of c)for(let r=0;r<t;r++)m[r]+=h[r];for(let h=0;h<t;h++)m[h]/=a;const e=Array.from({length:t},()=>new Array(t).fill(0));for(const h of c)for(let r=0;r<t;r++){const n=h[r]-m[r];for(let l=r;l<t;l++)e[r][l]+=n*(h[l]-m[l])}const d=a>1?a-1:1;for(let h=0;h<t;h++)for(let r=h;r<t;r++)e[h][r]/=d,e[r][h]=e[h][r];return{mean:m,cov:e}}function M(c,t={}){const a=Number.isFinite(t.p)?t.p:K,m=Number.isFinite(t.ridge)?t.ridge:1e-6,e=c.length;if(!e)return null;const d=c[0].length;if(!d)return null;const h=new Array(e).fill(null),r=new Array(e).fill(null),n=new Array(e).fill(!1),l=[],g=[];for(let v=0;v<e;v++){const U=c[v];let V=U.length===d;const $=new Array(d);for(let ee=0;V&&ee<d;ee++){const ne=Number(U[ee]);Number.isFinite(ne)?$[ee]=ne:V=!1}V&&(l.push(v),g.push($))}const P=d,S=Q(P,a);if(g.length<=d)return{center:[],df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0};const{mean:G,cov:F}=C(g,d);let E=_(F),Z=!1;if(!E){Z=!0;let v=0;for(let $=0;$<d;$++)v+=F[$][$];const U=v/d*m||m,V=F.map(($,ee)=>$.map((ne,ce)=>ee===ce?ne+U:ne));if(E=_(V),!E)return{center:G,df:P,cutoff:S,singular:!0,used:g.length,distances:h,squared:r,flags:n,flagged:0}}let R=0;for(let v=0;v<g.length;v++){const U=g[v],V=new Array(d);for(let ne=0;ne<d;ne++)V[ne]=U[ne]-G[ne];let $=0;for(let ne=0;ne<d;ne++){let ce=0;for(let p=0;p<d;p++)ce+=E[ne][p]*V[p];$+=V[ne]*ce}$<0&&($=0);const ee=l[v];r[ee]=$,h[ee]=Math.sqrt($),$>S&&(n[ee]=!0,R++)}return{center:G,df:P,cutoff:S,singular:Z,used:g.length,distances:h,squared:r,flags:n,flagged:R}}const i=20,s=Object.freeze(["rollingModifiedZScore","rollingIqr"]);function u(c,t={}){const a=t.method==="rollingIqr"?"rollingIqr":"rollingModifiedZScore",m=Number.isFinite(t.windowLen)&&t.windowLen>=1?Math.floor(t.windowLen):i,e=Number.isFinite(t.threshold)?t.threshold:x,d=Number.isFinite(t.k)?t.k:T,h=Number.isFinite(t.minPeriods)&&t.minPeriods>=1?Math.floor(t.minPeriods):m,r=c.length,n=new Array(r).fill(null),l=new Array(r).fill(!1);let g=0;for(let P=0;P<r;P++){const S=Number(c[P]);if(!Number.isFinite(S))continue;const G=Math.max(0,P-m+1),F=[];for(let E=G;E<=P;E++){const Z=Number(c[E]);Number.isFinite(Z)&&F.push(Z)}if(!(F.length<h))if(a==="rollingIqr"){const E=oe(F,{k:d});if(!E)continue;(S<E.lower||S>E.upper)&&(l[P]=!0,g++)}else{const E=J(F);if(!E||E.mad===0)continue;const Z=te*(S-E.median)/E.mad;n[P]=Z,Math.abs(Z)>e&&(l[P]=!0,g++)}}return{method:a,windowLen:m,minPeriods:h,threshold:e,k:d,scores:n,flags:l,flagged:g}}function f(c={}){const t=c||{},a=t.field;if(typeof a!="string"||!a)throw new TypeError("[lattice] anomalyCondition: a string `field` naming the numeric property to monitor is required");const m=t.method||"modifiedZScore";if(!(re.includes(m)||s.includes(m))||m==="mahalanobis")throw new RangeError(`[lattice] anomalyCondition: unknown or unsupported method \'${m}\'`);const d=typeof t.orderBy=="string"?t.orderBy:null,h=t.latest===!0,r=s.includes(m),n=l=>Number(l==null?NaN:l[a]);return l=>{const g=Array.isArray(l)?l.slice():[...l];d&&g.sort((E,Z)=>{const R=E?.[d],v=Z?.[d];return R===v?0:R==null?-1:v==null?1:R<v?-1:1});const P=g.map(n);let S,G;if(r)({flags:S,scores:G}=u(P,{method:m,windowLen:t.windowLen,threshold:t.threshold,k:t.k,minPeriods:t.minPeriods}));else if(m==="iqr"){const E=oe(P,{k:t.k});S=P.map(Z=>E?Number.isFinite(Z)&&(Z<E.lower||Z>E.upper):!1),G=P.map(()=>null)}else({flags:S,scores:G}=ue(P,{threshold:t.threshold}));if(h){const E=S.length-1;return E<0||!S[E]?!1:{method:m,field:a,flagged:[{row:g[E],score:G[E]}]}}const F=[];for(let E=0;E<S.length;E++)S[E]&&F.push({row:g[E],score:G[E]});return F.length?{method:m,field:a,flagged:F}:!1}}}),Se("packages/core/src/compute/forecast.js",function(o,me){"use strict";Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"default",{enumerable:!0,get:function(){return c}});const fe=me("packages/core/src/compute/special.js"),he=fe.normalQuantile,X=fe.studentTQuantile,te=me("packages/core/src/internal/util.js").warnOnce,x=Object.freeze(["movingAverage","ses","holt","holtWinters","linear"]),T=1e-4,K=1-1e-4;function re(t){const a=[];for(let m=0;m<t.length;m++){const e=t[m];if(e!==null&&typeof e=="object"){const d=Number.isFinite(e.at)?e.at:m,h=Number.isFinite(e.value)?e.value:null;a.push({at:d,value:h})}else a.push({at:m,value:Number.isFinite(e)?Number(e):null})}return a}function J(t){const a=t.filter(r=>r.value!==null),m=a[0],e=a[a.length-1],d=e.at-m.at,h=a.length>1&&d>0?d/(a.length-1):1;return{lastAt:e.at,step:h}}function ue(t){return Math.min(K,Math.max(T,t))}function oe(t,a=T,m=K,e=80){const d=(Math.sqrt(5)-1)/2;let h=a,r=m,n=r-d*(r-h),l=h+d*(r-h),g=t(n),P=t(l);for(let S=0;S<e;S++)g<P?(r=l,l=n,P=g,n=r-d*(r-h),g=t(n)):(h=n,n=l,g=P,l=h+d*(r-h),P=t(l));return(h+r)/2}function Y(t,a){let m=null,e=0,d=0;for(let h=0;h<t.length;h++){const r=t[h];if(r!==null){if(m===null){m=r;continue}e+=(r-m)**2,d+=1,m=a*r+(1-a)*m}}return{level:m,sse:e,m:d}}function L(t,a,m){let e=null,d=null,h=0,r=0;for(let n=0;n<t.length;n++){const l=t[n];if(l===null){e!==null&&d!==null&&(e+=d);continue}if(e===null){e=l;continue}d===null&&(d=l-e);const g=e+d;h+=(l-g)**2,r+=1;const P=e;e=a*l+(1-a)*(P+d),d=m*(e-P)+(1-m)*d}return{level:e,trend:d,sse:h,m:r}}function Q(t,a,m,e,d){const h=t.length;if(h<2*a)return null;const r=Z=>{let R=0,v=0;for(let U=Z;U<Z+a&&U<h;U++)t[U]!==null&&(R+=t[U],v+=1);return v?R/v:null},n=r(0),l=r(a);if(n===null||l===null)return null;let g=n,P=(l-n)/a;const S=new Array(a).fill(0);for(let Z=0;Z<a;Z++)S[Z]=t[Z]===null?0:t[Z]-g;const G=S.reduce((Z,R)=>Z+R,0)/a;for(let Z=0;Z<a;Z++)S[Z]-=G;let F=0,E=0;for(let Z=a;Z<h;Z++){const R=Z%a,v=S[R],U=t[Z];if(U===null){g+=P;continue}const V=g+P+v;F+=(U-V)**2,E+=1;const $=g;g=m*(U-v)+(1-m)*(g+P),P=e*(g-$)+(1-e)*P,S[R]=d*(U-g)+(1-d)*v}return{level:g,trend:P,season:S,phase:(h-1)%a,sse:F,count:E}}function _(t,a,m){let e=1;for(const h of a)e+=h*h;const d=Math.sqrt(t*e);return{se:d,margin:m*d}}function C(t,a={}){if(!t||typeof t.length!="number"||t.length===0)return null;const m=x.includes(a.method)?a.method:"linear",e=Math.max(1,Math.floor(Number(a.horizon)||1)),d=Number.isFinite(a.confidence)&&a.confidence>0&&a.confidence<1?a.confidence:.95,h=1-(1-d)/2,r=re(t),n=r.map(F=>F.value),l=n.filter(F=>F!==null),g=l.length,{lastAt:P,step:S}=g?J(r):{lastAt:0,step:1},G=F=>P+F*S;return m==="linear"?M(r,g,e,d,h,G):m==="movingAverage"?i(l,g,e,d,h,a,G):m==="ses"?s(n,g,e,d,h,a,G):m==="holt"?u(n,g,e,d,h,a,G):f(n,g,e,d,h,a,G)}function M(t,a,m,e,d,h){if(a<2)return null;let r=0,n=0;for(const U of t)U.value!==null&&(r+=U.at,n+=U.value);r/=a,n/=a;let l=0,g=0,P=0;for(const U of t){if(U.value===null)continue;const V=U.at-r,$=U.value-n;l+=V*V,g+=V*$,P+=$*$}if(l===0)return null;const S=g/l,G=n-S*r,F=P===0?1:Math.max(0,Math.min(1,g*g/(l*P))),E=Math.max(0,P-S*g),Z=a>2?Math.sqrt(E/(a-2)):null,R=a>2?X(d,a-2):null,v=[];for(let U=1;U<=m;U++){const V=h(U),$=G+S*V;let ee=null,ne=null,ce=null,p=null,B=null;if(Z!==null){const H=1/a+(V-r)**2/l,w=Z*Math.sqrt(1+H),A=Z*Math.sqrt(H);B=w,ee=$-R*w,ne=$+R*w,ce=$-R*A,p=$+R*A}v.push({step:U,at:V,mean:$,lower:ee,upper:ne,lowerMean:ce,upperMean:p,se:B})}return{method:"linear",horizon:m,confidence:e,n:a,sigma:Z,r2:F,params:{slope:S,intercept:G},points:v}}function i(t,a,m,e,d,h,r){if(a<1)return null;const n=Math.max(1,Math.min(a,Math.floor(Number(h.windowLen)||a))),l=t.slice(a-n);let g=0;for(const Z of l)g+=Z;const P=g/n;let S=null,G=null;if(n>1){let Z=0;for(const v of l)Z+=(v-P)**2;S=Math.sqrt(Z/(n-1))*Math.sqrt(1+1/n),G=X(d,n-1)}const F=S===null?null:G*S,E=[];for(let Z=1;Z<=m;Z++)E.push({step:Z,at:r(Z),mean:P,lower:F===null?null:P-F,upper:F===null?null:P+F,se:S});return{method:"movingAverage",horizon:m,confidence:e,n:a,sigma:S===null?null:S,params:{windowLen:n},points:E}}function s(t,a,m,e,d,h,r){if(a<1)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null;n===null&&(n=oe(G=>Y(t,G).sse));const l=Y(t,n),g=he(d),P=l.m>0?l.sse/l.m:null,S=[];for(let G=1;G<=m;G++){const F=l.level;let E=null,Z=null,R=null;if(P!==null){const v=[];for(let V=1;V<G;V++)v.push(n);const U=_(P,v,g);R=U.se,E=F-U.margin,Z=F+U.margin}S.push({step:G,at:r(G),mean:F,lower:E,upper:Z,se:R})}return{method:"ses",horizon:m,confidence:e,n:a,sigma:P===null?null:Math.sqrt(P),params:{alpha:n},points:S}}function u(t,a,m,e,d,h,r){if(a<2)return null;let n=Number.isFinite(h.alpha)?ue(h.alpha):null,l=Number.isFinite(h.beta)?ue(h.beta):null;if(n===null||l===null){let E=n===null?.5:n,Z=l===null?.5:l;for(let R=0;R<6;R++)n===null&&(E=oe(v=>L(t,v,Z).sse)),l===null&&(Z=oe(v=>L(t,E,v).sse));n=n===null?E:n,l=l===null?Z:l}const g=L(t,n,l),P=he(d),S=g.m>0?g.sse/g.m:null,G=n*l,F=[];for(let E=1;E<=m;E++){const Z=g.level+E*g.trend;let R=null,v=null,U=null;if(S!==null){const V=[];for(let ee=1;ee<E;ee++)V.push(n+ee*G);const $=_(S,V,P);U=$.se,R=Z-$.margin,v=Z+$.margin}F.push({step:E,at:r(E),mean:Z,lower:R,upper:v,se:U})}return{method:"holt",horizon:m,confidence:e,n:a,sigma:S===null?null:Math.sqrt(S),params:{alpha:n,beta:l},points:F}}function f(t,a,m,e,d,h,r){const n=Math.floor(Number(h.period));if(!(n>=2))return te("forecast.holtWinters.period","forecast: holtWinters needs a period (opts.period >= 2)"),null;if(a<2*n)return null;let l=Number.isFinite(h.alpha)?ue(h.alpha):null,g=Number.isFinite(h.beta)?ue(h.beta):null,P=Number.isFinite(h.gamma)?ue(h.gamma):null;const S=(U,V,$)=>{const ee=Q(t,n,U,V,$);return ee?ee.sse:1/0};if(l===null||g===null||P===null){let U=l===null?.5:l,V=g===null?.5:g,$=P===null?.5:P;for(let ee=0;ee<8;ee++)l===null&&(U=oe(ne=>S(ne,V,$))),g===null&&(V=oe(ne=>S(U,ne,$))),P===null&&($=oe(ne=>S(U,V,ne)));l=l===null?U:l,g=g===null?V:g,P=P===null?$:P}const G=Q(t,n,l,g,P);if(!G)return null;const F=he(d),E=G.count>0?G.sse/G.count:null,Z=l*g,R=P*(1-l),v=[];for(let U=1;U<=m;U++){const V=G.season[(G.phase+U)%n],$=G.level+U*G.trend+V;let ee=null,ne=null,ce=null;if(E!==null){const p=[];for(let H=1;H<U;H++)p.push(l+H*Z+(H%n===0?R:0));const B=_(E,p,F);ce=B.se,ee=$-B.margin,ne=$+B.margin}v.push({step:U,at:r(U),mean:$,lower:ee,upper:ne,se:ce})}return{method:"holtWinters",horizon:m,confidence:e,n:a,sigma:E===null?null:Math.sqrt(E),params:{alpha:l,beta:g,gamma:P,period:n},points:v}}const c={FORECAST_METHODS:x,forecast:C}}),Se("packages/core/src/compute/index.js",function(o,me){"use strict";const fe=me("packages/core/src/compute/sort.js");Object.defineProperty(o,"sortColumn",{enumerable:!0,get:function(){return fe.sortColumn}}),Object.defineProperty(o,"sortMulti",{enumerable:!0,get:function(){return fe.sortMulti}}),Object.defineProperty(o,"radixSortFloat64",{enumerable:!0,get:function(){return fe.radixSortFloat64}}),Object.defineProperty(o,"radixSortInt32",{enumerable:!0,get:function(){return fe.radixSortInt32}}),Object.defineProperty(o,"rankSortDictionary",{enumerable:!0,get:function(){return fe.rankSortDictionary}}),Object.defineProperty(o,"mergeSortComparator",{enumerable:!0,get:function(){return fe.mergeSortComparator}}),Object.defineProperty(o,"collateStringRanks",{enumerable:!0,get:function(){return fe.collateStringRanks}}),Object.defineProperty(o,"rankSortStrings",{enumerable:!0,get:function(){return fe.rankSortStrings}});const he=me("packages/core/src/compute/sortspec.js");Object.defineProperty(o,"collationDescriptor",{enumerable:!0,get:function(){return he.collationDescriptor}}),Object.defineProperty(o,"isPortableSort",{enumerable:!0,get:function(){return he.isPortableSort}}),Object.defineProperty(o,"isPortableSortSet",{enumerable:!0,get:function(){return he.isPortableSortSet}}),Object.defineProperty(o,"describeSortEntry",{enumerable:!0,get:function(){return he.describeSortEntry}}),Object.defineProperty(o,"describeSort",{enumerable:!0,get:function(){return he.describeSort}});const X=me("packages/core/src/compute/filter.js");Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return X.evaluateFilters}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return X.evaluateCondition}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return X.compact}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return X.testValue}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return X.compilePredicate}}),Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return X.releaseMask}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return X.pruneColumn}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return X.mentionsColumn}});const z=me("packages/core/src/compute/group.js");Object.defineProperty(o,"groupByColumns",{enumerable:!0,get:function(){return z.groupByColumns}}),Object.defineProperty(o,"packKeys",{enumerable:!0,get:function(){return z.packKeys}});const te=me("packages/core/src/compute/facet.js");Object.defineProperty(o,"facet",{enumerable:!0,get:function(){return te.facet}}),Object.defineProperty(o,"computeBounds",{enumerable:!0,get:function(){return te.computeBounds}}),Object.defineProperty(o,"countInto",{enumerable:!0,get:function(){return te.countInto}}),Object.defineProperty(o,"bucketOf",{enumerable:!0,get:function(){return te.bucketOf}}),Object.defineProperty(o,"facetKind",{enumerable:!0,get:function(){return te.facetKind}}),Object.defineProperty(o,"cardinalityOf",{enumerable:!0,get:function(){return te.cardinalityOf}}),Object.defineProperty(o,"pickGranularity",{enumerable:!0,get:function(){return te.pickGranularity}}),Object.defineProperty(o,"floorTo",{enumerable:!0,get:function(){return te.floorTo}}),Object.defineProperty(o,"advance",{enumerable:!0,get:function(){return te.advance}}),Object.defineProperty(o,"STRATEGIES",{enumerable:!0,get:function(){return te.STRATEGIES}}),Object.defineProperty(o,"GRANULARITIES",{enumerable:!0,get:function(){return te.GRANULARITIES}}),Object.defineProperty(o,"DEFAULT_BUCKETS",{enumerable:!0,get:function(){return te.DEFAULT_BUCKETS}}),Object.defineProperty(o,"DEFAULT_CARDINALITY_LIMIT",{enumerable:!0,get:function(){return te.DEFAULT_CARDINALITY_LIMIT}}),Object.defineProperty(o,"QUANTILE_SAMPLE",{enumerable:!0,get:function(){return te.QUANTILE_SAMPLE}});const x=me("packages/core/src/compute/total.js");Object.defineProperty(o,"TOTAL_FNS",{enumerable:!0,get:function(){return x.TOTAL_FNS}}),Object.defineProperty(o,"TOTAL_LABELS",{enumerable:!0,get:function(){return x.TOTAL_LABELS}}),Object.defineProperty(o,"totalLabel",{enumerable:!0,get:function(){return x.totalLabel}}),Object.defineProperty(o,"total",{enumerable:!0,get:function(){return x.total}}),Object.defineProperty(o,"collectValues",{enumerable:!0,get:function(){return x.collectValues}});const T=me("packages/core/src/compute/pivot.js");Object.defineProperty(o,"pivot",{enumerable:!0,get:function(){return T.pivot}}),Object.defineProperty(o,"resolvePivotKeys",{enumerable:!0,get:function(){return T.resolvePivotKeys}}),Object.defineProperty(o,"pivotKey",{enumerable:!0,get:function(){return T.pivotKey}}),Object.defineProperty(o,"joinPath",{enumerable:!0,get:function(){return T.joinPath}}),Object.defineProperty(o,"KEY_DELIMITER",{enumerable:!0,get:function(){return T.KEY_DELIMITER}}),Object.defineProperty(o,"DEFAULT_PATH_SEPARATOR",{enumerable:!0,get:function(){return T.DEFAULT_PATH_SEPARATOR}}),Object.defineProperty(o,"DEFAULT_MAX_COLUMNS",{enumerable:!0,get:function(){return T.DEFAULT_MAX_COLUMNS}});const K=me("packages/core/src/compute/pivotmatrix.js");Object.defineProperty(o,"pivotMatrix",{enumerable:!0,get:function(){return K.pivotMatrix}}),Object.defineProperty(o,"resolveAxis",{enumerable:!0,get:function(){return K.resolveAxis}}),Object.defineProperty(o,"cellKey",{enumerable:!0,get:function(){return K.cellKey}}),Object.defineProperty(o,"marginKey",{enumerable:!0,get:function(){return K.marginKey}}),Object.defineProperty(o,"GRAND_PATH",{enumerable:!0,get:function(){return K.GRAND_PATH}});const re=me("packages/core/src/compute/reference.js");Object.defineProperty(o,"referenceSort",{enumerable:!0,get:function(){return re.referenceSort}}),Object.defineProperty(o,"referenceFilter",{enumerable:!0,get:function(){return re.referenceFilter}}),Object.defineProperty(o,"referenceGroup",{enumerable:!0,get:function(){return re.referenceGroup}}),Object.defineProperty(o,"referenceTotal",{enumerable:!0,get:function(){return re.referenceTotal}}),Object.defineProperty(o,"referencePasses",{enumerable:!0,get:function(){return re.referencePasses}}),Object.defineProperty(o,"referenceValue",{enumerable:!0,get:function(){return re.referenceValue}});const J=me("packages/core/src/compute/handle.js");Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return J.identity}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return J.rowCount}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return J.presenceReader}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return J.bitReader}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return J.valueReader}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return J.valueComparator}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return J.numericTotalOrder}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return J.dictRanks}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return J.dictSize}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return J.dictValue}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return J.multiValue}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return J.isMissing}});const ue=me("packages/core/src/compute/sketch.js");Object.defineProperty(o,"Welford",{enumerable:!0,get:function(){return ue.Welford}}),Object.defineProperty(o,"Reservoir",{enumerable:!0,get:function(){return ue.Reservoir}}),Object.defineProperty(o,"HyperLogLog",{enumerable:!0,get:function(){return ue.HyperLogLog}}),Object.defineProperty(o,"SpaceSaving",{enumerable:!0,get:function(){return ue.SpaceSaving}}),Object.defineProperty(o,"KLL",{enumerable:!0,get:function(){return ue.KLL}}),Object.defineProperty(o,"hash32",{enumerable:!0,get:function(){return ue.hash32}}),Object.defineProperty(o,"SKETCH_BOUNDS",{enumerable:!0,get:function(){return ue.SKETCH_BOUNDS}});const oe=me("packages/core/src/compute/windowed.js");Object.defineProperty(o,"Window",{enumerable:!0,get:function(){return oe.Window}}),Object.defineProperty(o,"WINDOW_KINDS",{enumerable:!0,get:function(){return oe.WINDOW_KINDS}}),Object.defineProperty(o,"openWindow",{enumerable:!0,get:function(){return oe.openWindow}});const Y=me("packages/core/src/compute/statistics.js");Object.defineProperty(o,"MAINTENANCE",{enumerable:!0,get:function(){return Y.MAINTENANCE}}),Object.defineProperty(o,"APPROXIMATE",{enumerable:!0,get:function(){return Y.APPROXIMATE}}),Object.defineProperty(o,"maintenanceOf",{enumerable:!0,get:function(){return Y.maintenanceOf}});const L=me("packages/core/src/compute/anomaly.js");Object.defineProperty(o,"ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ANOMALY_METHODS}}),Object.defineProperty(o,"modifiedZScores",{enumerable:!0,get:function(){return L.modifiedZScores}}),Object.defineProperty(o,"iqrFences",{enumerable:!0,get:function(){return L.iqrFences}}),Object.defineProperty(o,"mahalanobis",{enumerable:!0,get:function(){return L.mahalanobis}}),Object.defineProperty(o,"ROLLING_ANOMALY_METHODS",{enumerable:!0,get:function(){return L.ROLLING_ANOMALY_METHODS}}),Object.defineProperty(o,"rollingAnomalies",{enumerable:!0,get:function(){return L.rollingAnomalies}}),Object.defineProperty(o,"anomalyCondition",{enumerable:!0,get:function(){return L.anomalyCondition}});const Q=me("packages/core/src/compute/forecast.js");Object.defineProperty(o,"FORECAST_METHODS",{enumerable:!0,get:function(){return Q.FORECAST_METHODS}}),Object.defineProperty(o,"forecast",{enumerable:!0,get:function(){return Q.forecast}})}),Se("packages/worker/src/kernel.js",function(o,me){"use strict";Object.defineProperty(o,"loadCompute",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"setCompute",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"dispatch",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"handleMessage",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"installKernel",{enumerable:!0,get:function(){return u}});const fe=me("packages/worker/src/transport.js"),he=fe.PROTOCOL,X=fe.OPS,z=fe.CONTROL,te=fe.ERRORS,x=fe.unpackHandle,T=fe.unpackHandles,K=fe.createMaskPool,re=fe.collectTransfers,J=me("packages/core/src/store/columnpack.js"),ue=J.packChunk,oe=J.packedTransfers;let Y=null,L=null,Q=null;async function _(f){if(Y)return Y;if(!L){const c=f||(()=>Promise.resolve(me("packages/core/src/compute/index.js")));L=Promise.resolve().then(c).then(t=>(Y=t,t)).catch(t=>(Q=t,Y=null,null))}return L}function C(f){Y=f,L=f?Promise.resolve(f):null,Q=f?null:Q}function M(f,c,t){const a=new Map;for(const m of f)m&&a.set(m.id,m);return{handle(m){return a.get(m)},count:c,pool:K(),locale:t}}function i(f,c){const{op:t,args:a}=f;if(t===X.COLUMNIZE)return ue(a.schema||[],a.rows||[],a.opts||{});const m=c[t];if(typeof m!="function"){const e=new Error(`[lattice] compute kernel \'${t}\' is not exported`);throw e.code=te.NO_KERNEL,e}switch(t){case X.COLLATE_STRING_RANKS:return m(a.table||[],(a.table||[]).length,a.locale);case X.SORT_COLUMN:return m(x(a.handle),a.order??null,a.opts||{});case X.SORT_MULTI:{const e=T(a.handles||[]),d=(a.entries||[]).map(h=>({...h,handle:e[h.index]}));return m(e,d,a.order??null)}case X.EVALUATE_FILTERS:return m(a.filters,M(T(a.handles||[]),a.count,a.locale));case X.COMPACT:return m(a.mask,a.count,void 0);case X.GROUP_BY_COLUMNS:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.TOTAL:return m(x(a.handle),a.indices??null,a.fn);case X.PIVOT:return m(T(a.handles||[]),a.order??null,a.opts||{});case X.FACET:return m(x(a.handle),a.indices??null,a.count,a.opts||{});default:{const e=new Error(`[lattice] unknown worker op \'${t}\'`);throw e.code=te.PROTOCOL,e}}}async function s(f,c={}){if(!f||f.lattice!==he)return null;const{id:t,op:a}=f;if(a===z.CANCEL)return c.cancelled?.add(f.target),null;if(a===z.PING)return{reply:{lattice:he,id:t,ok:!0,result:"pong"},transfer:[]};if(a===X.COLUMNIZE){if(c.cancelled?.has(t))return c.cancelled.delete(t),null;try{const e=ue(f.args.schema||[],f.args.rows||[],f.args.opts||{});return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:oe(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}const m=await _(c.loader);if(!m)return{reply:{lattice:he,id:t,ok:!1,error:{code:te.NO_COMPUTE,message:`[lattice] compute kernels unavailable in worker: ${Q?Q.message:"module not found"}`}},transfer:[]};if(c.cancelled?.has(t))return c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]};try{const e=i(f,m);return c.cancelled?.has(t)?(c.cancelled.delete(t),{reply:{lattice:he,id:t,ok:!1,error:{code:te.ABORTED,message:"[lattice] request superseded"}},transfer:[]}):{reply:{lattice:he,id:t,ok:!0,result:e},transfer:re(e)}}catch(e){const d=e;return{reply:{lattice:he,id:t,ok:!1,error:{code:d.code||te.KERNEL,message:d.message||String(e),stack:d.stack}},transfer:[]}}}function u(f,c={}){const t=new Set,a=async m=>{const e=await s(m.data,{loader:c.loader,cancelled:t});e&&f.postMessage(e.reply,e.transfer)};return f.addEventListener("message",a),_(c.loader).then(m=>{f.postMessage({lattice:he,id:0,op:z.READY,compute:!!m})}),()=>f.removeEventListener("message",a)}});var pt=it("packages/worker/src/kernel.js");yt.__latticeKernel=pt})(typeof globalThis<"u"?globalThis:this);\n\n__latticeKernel.installKernel(self);\n',{type:"classic"})}catch{}const Be=Un("packages/dom/src/index.js"),_i=Be.createGrid,Zi=Be.gridElementsWithin,Yi=Be.createStat,Xi=Be.deltaOf,Qi=Be.toneOf,Ji=Be.readTable,eo=Be.hydrateTable,to=Be.autoInit,no=Be.createLocalViewStorage,ro=Be.DEFAULT_VIEWS_KEY,io=Be.createHeadlessGrid,oo=Be.defaults,so=Be.version,ao=Be.getVersion,lo=Be.Grid,uo=Be.EventBus,co=Be.Registry,fo=Be.sharedRegistry,ho=Be.registerModules,mo=Be.parseLicence,po=Be.verifyLicence,go=Be.licenceInfo,yo=Be.watermark,bo=Be.setLicence,wo=Be.licenceState,vo=Be.isLocalHost,ko=Be.matchesDomain,So=Be.LicenceHolder,Oo=Be.ColumnModel,jo=Be.buildGraph,Ao=Be.Lookup,Po=Be.ValuePipeline,Co=Be.compileFormat,Eo=Be.compileMask,To=Be.specToOoxml,Mo=Be.EXTENDED_TYPES,No=Be.createRadixType,Ro=Be.RADIX_PRESETS,Lo=Be.parseRadix,Fo=Be.formatRadix,xo=Be.createUnitType,Io=Be.registerUnitSystem,Do=Be.defineUnit,$o=Be.UNIT_SYSTEMS,zo=Be.parseUnit,Bo=Be.formatUnit,Uo=Be.createCurrencyType,Ho=Be.parseMoney,Vo=Be.formatMoney,Go=Be.convertMoney,Ko=Be.rateFunction,Wo=Be.MISSING_RATE,qo=Be.Messages,_o=Be.createMessages,Zo=Be.auditCatalogue,Yo=Be.EN_GB,Xo=Be.MESSAGE_KEYS,Qo=Be.DEFAULT_LOCALE,Jo=Be.formatList,es=Be.resolveLocale,ts=Be.LOCALES,ns=Be.resolveCatalogue,rs=Be.EN_US,is=Be.FR_FR,os=Be.FR_CA,ss=Be.IT_IT,as=Be.ES_ES,ls=Be.PT_BR,us=Be.DE_DE,cs=Be.NL_NL,ds=Be.SV_SE,fs=Be.DA_DK,hs=Be.NB_NO,ms=Be.FI_FI,ps=Be.PL_PL,gs=Be.CS_CZ,ys=Be.HU_HU,bs=Be.RO_RO,ws=Be.UK_UA,vs=Be.EL_GR,ks=Be.JA_JP,Ss=Be.AR,Os=Be.AR_SA,js=Be.ColumnStore,As=Be.Bitset,Ps=Be.Dictionary,Cs=Be.MultiValue,Es=Be.MaskPool,Ts=Be.sortColumn,Ms=Be.sortMulti,Ns=Be.evaluateFilters,Rs=Be.compact,Ls=Be.testValue,Fs=Be.groupByColumns,xs=Be.total,Is=Be.TOTAL_FNS,Ds=Be.pivot,$s=Be.Window,zs=Be.openWindow,Bs=Be.WINDOW_KINDS,Us=Be.ANOMALY_METHODS,Hs=Be.modifiedZScores,Vs=Be.iqrFences,Gs=Be.mahalanobis,Ks=Be.ROLLING_ANOMALY_METHODS,Ws=Be.rollingAnomalies,qs=Be.anomalyCondition,_s=Be.FORECAST_METHODS,Zs=Be.forecast,Ys=Be.evaluateFormula,Xs=Be.parseFormula,Qs=Be.referencesOf,Js=Be.looksLikeFormula,ea=Be.FormulaError,ta=Be.FUNCTIONS,na=Be.compileRules,ra=Be.ingest,ia=Be.ingestSync,oa=Be.createSource,sa=Be.createMemorySource,aa=Be.createPagedSource,la=Be.createRemoteSource,ua=Be.createStreamSource,ca=Be.createUrlSource,da=Be.PROTOCOL,fa=Be.createPushdownSource,ha=Be.planQuery,ma=Be.splitFilters,pa=Be.applyResidual,ga=Be.capabilitiesOf,ya=Be.resolveMutate,ba=Be.NO_CAPABILITIES,wa=Be.odataAdapter,va=Be.filtersToOData,ka=Be.conditionToOData,Sa=Be.restAdapter,Oa=Be.DEFAULT_PARAMS,ja=Be.dfqlAdapter,Aa=Be.duckdbAdapter,Pa=Be.filtersToSql,Ca=Be.graphqlAdapter,Ea=Be.splunkAdapter,Ta=Be.RowModel,Ma=Be.createRowKey,Na=Be.SelectionModel,Ra=Be.RangeModel,La=Be.EditModel,Fa=Be.ChangeModel,xa=Be.StateModel,Ia=Be.STATE_VERSION,Da=Be.serialiseState,$a=Be.restoreState,za=Be.VERSION,Ba=Be.DomRenderer,Ua=Be.FilterMenu,Ha=Be.mergeColumnFilter,Va=Be.branchFor,Ga=Be.ColumnMenu,Ka=Be.columnMenuItems,Wa=Be.cellMenuItems,qa=Be.autoGroupMenuItems,_a=Be.AlignedGrids,Za=Be.alignGrids,Ya=Be.layoutState,Xa=Be.ToolPanelDock,Qa=Be.panelHost,Ja=Be.mountPanel,el=Be.CellEditController,tl=Be.EditBar,nl=Be.HistoryBar,rl=Be.HISTORY_CLS,il=Be.DiffPainter,ol=Be.ViewPicker,sl=Be.VIEW_CLS,al=Be.summariseDiff,ll=Be.PromptBar,ul=Be.PROMPT_CLASS,cl=Be.createCellLayer,dl=Be.compileTemplate,fl=Be.compileVariant,hl=Be.checkVariant,ml=Be.VariantRegistry,pl=Be.BUILTIN_RENDERERS,gl=Be.BUILTIN_VARIANTS,yl=Be.BUILTIN_PIPES,bl=Be.sanitiseHtml,wl=Be.editors,vl=Be.createEditor,kl=Be.editorFor,Sl=Be.BaseEditor,Ol=Be.filters,jl=Be.createFilter,Al=Be.filterFor,Pl=Be.parseExpression,Cl=Be.ConditionFilter,El=Be.StatusBar,Tl=Be.ContextMenu,Ml=Be.ToolPanel,Nl=Be.TooltipManager,Rl=Be.Pagination,Ll=Be.OverlayLayer,Fl=Be.LatticeGrid,xl=Be.setLicense,Il=Be.licenseInfo,Dl=Be.licenseState;var $l=Be.default;export{Us as ANOMALY_METHODS,Ss as AR,Os as AR_SA,_a as AlignedGrids,yl as BUILTIN_PIPES,pl as BUILTIN_RENDERERS,gl as BUILTIN_VARIANTS,Sl as BaseEditor,As as Bitset,gs as CS_CZ,el as CellEditController,Fa as ChangeModel,Ga as ColumnMenu,Oo as ColumnModel,js as ColumnStore,Cl as ConditionFilter,Tl as ContextMenu,fs as DA_DK,Qo as DEFAULT_LOCALE,Oa as DEFAULT_PARAMS,ro as DEFAULT_VIEWS_KEY,us as DE_DE,Ps as Dictionary,il as DiffPainter,Ba as DomRenderer,vs as EL_GR,Yo as EN_GB,rs as EN_US,as as ES_ES,Mo as EXTENDED_TYPES,tl as EditBar,La as EditModel,uo as EventBus,ms as FI_FI,_s as FORECAST_METHODS,os as FR_CA,is as FR_FR,ta as FUNCTIONS,Ua as FilterMenu,ea as FormulaError,lo as Grid,rl as HISTORY_CLS,ys as HU_HU,nl as HistoryBar,ss as IT_IT,ks as JA_JP,ts as LOCALES,Fl as LatticeGrid,So as LicenceHolder,Ao as Lookup,Xo as MESSAGE_KEYS,Wo as MISSING_RATE,Es as MaskPool,qo as Messages,Cs as MultiValue,hs as NB_NO,cs as NL_NL,ba as NO_CAPABILITIES,Ll as OverlayLayer,ps as PL_PL,ul as PROMPT_CLASS,da as PROTOCOL,ls as PT_BR,Rl as Pagination,ll as PromptBar,Ro as RADIX_PRESETS,Ks as ROLLING_ANOMALY_METHODS,bs as RO_RO,Ra as RangeModel,co as Registry,Ta as RowModel,Ia as STATE_VERSION,ds as SV_SE,Na as SelectionModel,xa as StateModel,El as StatusBar,Is as TOTAL_FNS,Ml as ToolPanel,Xa as ToolPanelDock,Nl as TooltipManager,ws as UK_UA,$o as UNIT_SYSTEMS,za as VERSION,sl as VIEW_CLS,Po as ValuePipeline,ml as VariantRegistry,ol as ViewPicker,Bs as WINDOW_KINDS,$s as Window,Za as alignGrids,qs as anomalyCondition,pa as applyResidual,Zo as auditCatalogue,qa as autoGroupMenuItems,to as autoInit,Va as branchFor,jo as buildGraph,ga as capabilitiesOf,Wa as cellMenuItems,hl as checkVariant,Ka as columnMenuItems,Rs as compact,Co as compileFormat,Eo as compileMask,na as compileRules,dl as compileTemplate,fl as compileVariant,ka as conditionToOData,Go as convertMoney,cl as createCellLayer,Uo as createCurrencyType,vl as createEditor,jl as createFilter,_i as createGrid,io as createHeadlessGrid,no as createLocalViewStorage,sa as createMemorySource,_o as createMessages,aa as createPagedSource,fa as createPushdownSource,No as createRadixType,la as createRemoteSource,Ma as createRowKey,oa as createSource,Yi as createStat,ua as createStreamSource,xo as createUnitType,ca as createUrlSource,$l as default,oo as defaults,Do as defineUnit,Xi as deltaOf,ja as dfqlAdapter,Aa as duckdbAdapter,kl as editorFor,wl as editors,Ns as evaluateFilters,Ys as evaluateFormula,Al as filterFor,Ol as filters,va as filtersToOData,Pa as filtersToSql,Zs as forecast,Jo as formatList,Vo as formatMoney,Fo as formatRadix,Bo as formatUnit,ao as getVersion,Ca as graphqlAdapter,Zi as gridElementsWithin,Fs as groupByColumns,eo as hydrateTable,ra as ingest,ia as ingestSync,Vs as iqrFences,vo as isLocalHost,Ya as layoutState,go as licenceInfo,wo as licenceState,Il as licenseInfo,Dl as licenseState,Js as looksLikeFormula,Gs as mahalanobis,ko as matchesDomain,Ha as mergeColumnFilter,Hs as modifiedZScores,Ja as mountPanel,wa as odataAdapter,zs as openWindow,Qa as panelHost,Pl as parseExpression,Xs as parseFormula,mo as parseLicence,Ho as parseMoney,Lo as parseRadix,zo as parseUnit,Ds as pivot,ha as planQuery,Ko as rateFunction,Ji as readTable,Qs as referencesOf,ho as registerModules,Io as registerUnitSystem,ns as resolveCatalogue,es as resolveLocale,ya as resolveMutate,Sa as restAdapter,$a as restoreState,Ws as rollingAnomalies,bl as sanitiseHtml,Da as serialiseState,bo as setLicence,xl as setLicense,fo as sharedRegistry,Ts as sortColumn,Ms as sortMulti,To as specToOoxml,ma as splitFilters,Ea as splunkAdapter,al as summariseDiff,Ls as testValue,Qi as toneOf,xs as total,po as verifyLicence,so as version,yo as watermark};
57
57
 
58
58
  //# sourceMappingURL=lattice-grid.esm.min.js.map