@toclocoinc/lattice-grid 1.80.0 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +1 -1
  3. package/angular/package.json +1 -1
  4. package/docs/API.html +4 -4
  5. package/docs/THEMING.md +6 -3
  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 +1 -1
  10. package/docs/api/dashboard.html +1 -1
  11. package/docs/api/data-router.html +1 -1
  12. package/docs/api/deckgl.html +1 -1
  13. package/docs/api/gantt.html +1 -1
  14. package/docs/api/geometry.html +1 -1
  15. package/docs/api/grid.html +2 -2
  16. package/docs/api/index.html +1 -1
  17. package/docs/api/kanban.html +1 -1
  18. package/docs/api/kpi.html +1 -1
  19. package/docs/api/layout.html +1 -1
  20. package/docs/api/leaflet.html +1 -1
  21. package/docs/api/list.html +1 -1
  22. package/docs/api/mock-socket.html +1 -1
  23. package/docs/api/presets.html +1 -1
  24. package/docs/api/tabs.html +1 -1
  25. package/docs/api/types.html +1 -1
  26. package/docs/api-detail.html +4 -4
  27. package/docs/warnings.json +1 -1
  28. package/lattice-grid.d.ts +1 -1
  29. package/lattice-grid.esm.min.js +3 -3
  30. package/lattice-grid.min.cjs +3 -3
  31. package/lattice-grid.min.css +1 -1
  32. package/lattice-grid.min.js +3 -3
  33. package/modules/ai.d.ts +1 -1
  34. package/modules/ai.esm.min.js +2 -2
  35. package/modules/ai.min.cjs +2 -2
  36. package/modules/ai.min.js +2 -2
  37. package/modules/alarms.d.ts +1 -1
  38. package/modules/alarms.esm.min.js +2 -2
  39. package/modules/alarms.min.cjs +2 -2
  40. package/modules/alarms.min.js +2 -2
  41. package/modules/angular.d.ts +1 -1
  42. package/modules/angular.esm.min.js +2 -2
  43. package/modules/angular.min.cjs +2 -2
  44. package/modules/angular.min.js +2 -2
  45. package/modules/chart-alluvial.d.ts +1 -1
  46. package/modules/chart-alluvial.esm.min.js +1 -1
  47. package/modules/chart-alluvial.min.cjs +1 -1
  48. package/modules/chart-alluvial.min.js +1 -1
  49. package/modules/chart-arc.d.ts +1 -1
  50. package/modules/chart-arc.esm.min.js +1 -1
  51. package/modules/chart-arc.min.cjs +1 -1
  52. package/modules/chart-arc.min.js +1 -1
  53. package/modules/chart-bubblemap.d.ts +1 -1
  54. package/modules/chart-bubblemap.esm.min.js +1 -1
  55. package/modules/chart-bubblemap.min.cjs +1 -1
  56. package/modules/chart-bubblemap.min.js +1 -1
  57. package/modules/chart-bump.d.ts +1 -1
  58. package/modules/chart-bump.esm.min.js +1 -1
  59. package/modules/chart-bump.min.cjs +1 -1
  60. package/modules/chart-bump.min.js +1 -1
  61. package/modules/chart-calendar.d.ts +1 -1
  62. package/modules/chart-calendar.esm.min.js +1 -1
  63. package/modules/chart-calendar.min.cjs +1 -1
  64. package/modules/chart-calendar.min.js +1 -1
  65. package/modules/chart-choropleth.d.ts +1 -1
  66. package/modules/chart-choropleth.esm.min.js +1 -1
  67. package/modules/chart-choropleth.min.cjs +1 -1
  68. package/modules/chart-choropleth.min.js +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 +1 -1
  87. package/modules/chart-hexbin.min.cjs +1 -1
  88. package/modules/chart-hexbin.min.js +1 -1
  89. package/modules/chart-hexmap.d.ts +1 -1
  90. package/modules/chart-hexmap.esm.min.js +1 -1
  91. package/modules/chart-hexmap.min.cjs +1 -1
  92. package/modules/chart-hexmap.min.js +1 -1
  93. package/modules/chart-icicle.d.ts +1 -1
  94. package/modules/chart-icicle.esm.min.js +1 -1
  95. package/modules/chart-icicle.min.cjs +1 -1
  96. package/modules/chart-icicle.min.js +1 -1
  97. package/modules/chart-markermap.d.ts +1 -1
  98. package/modules/chart-markermap.esm.min.js +1 -1
  99. package/modules/chart-markermap.min.cjs +1 -1
  100. package/modules/chart-markermap.min.js +1 -1
  101. package/modules/chart-parallel.d.ts +1 -1
  102. package/modules/chart-parallel.esm.min.js +1 -1
  103. package/modules/chart-parallel.min.cjs +1 -1
  104. package/modules/chart-parallel.min.js +1 -1
  105. package/modules/chart-ridgeline.d.ts +1 -1
  106. package/modules/chart-ridgeline.esm.min.js +1 -1
  107. package/modules/chart-ridgeline.min.cjs +1 -1
  108. package/modules/chart-ridgeline.min.js +1 -1
  109. package/modules/chart-roc.d.ts +1 -1
  110. package/modules/chart-roc.esm.min.js +1 -1
  111. package/modules/chart-roc.min.cjs +1 -1
  112. package/modules/chart-roc.min.js +1 -1
  113. package/modules/chart-slope.d.ts +1 -1
  114. package/modules/chart-slope.esm.min.js +1 -1
  115. package/modules/chart-slope.min.cjs +1 -1
  116. package/modules/chart-slope.min.js +1 -1
  117. package/modules/chart-splom.d.ts +1 -1
  118. package/modules/chart-splom.esm.min.js +1 -1
  119. package/modules/chart-splom.min.cjs +1 -1
  120. package/modules/chart-splom.min.js +1 -1
  121. package/modules/chart-waffle.d.ts +1 -1
  122. package/modules/chart-waffle.esm.min.js +1 -1
  123. package/modules/chart-waffle.min.cjs +1 -1
  124. package/modules/chart-waffle.min.js +1 -1
  125. package/modules/charts.d.ts +1 -1
  126. package/modules/charts.esm.min.js +2 -2
  127. package/modules/charts.min.cjs +2 -2
  128. package/modules/charts.min.js +2 -2
  129. package/modules/dashboard.d.ts +1 -1
  130. package/modules/dashboard.esm.min.js +2 -2
  131. package/modules/dashboard.min.cjs +2 -2
  132. package/modules/dashboard.min.js +2 -2
  133. package/modules/data-router.d.ts +1 -1
  134. package/modules/data-router.esm.min.js +2 -2
  135. package/modules/data-router.min.cjs +2 -2
  136. package/modules/data-router.min.js +2 -2
  137. package/modules/deckgl.d.ts +1 -1
  138. package/modules/deckgl.esm.min.js +2 -2
  139. package/modules/deckgl.min.cjs +2 -2
  140. package/modules/deckgl.min.js +2 -2
  141. package/modules/devtools.d.ts +1 -1
  142. package/modules/devtools.esm.min.js +1 -1
  143. package/modules/devtools.min.cjs +1 -1
  144. package/modules/devtools.min.js +1 -1
  145. package/modules/dhtmlx-compat.d.ts +1 -1
  146. package/modules/dhtmlx-compat.esm.min.js +2 -2
  147. package/modules/dhtmlx-compat.min.cjs +2 -2
  148. package/modules/dhtmlx-compat.min.js +2 -2
  149. package/modules/gantt.d.ts +1 -1
  150. package/modules/gantt.esm.min.js +2 -2
  151. package/modules/gantt.min.cjs +2 -2
  152. package/modules/gantt.min.js +2 -2
  153. package/modules/geo-europe-nuts.d.ts +1 -1
  154. package/modules/geo-europe-nuts.esm.min.js +1 -1
  155. package/modules/geo-europe-nuts.min.cjs +1 -1
  156. package/modules/geo-europe-nuts.min.js +1 -1
  157. package/modules/geo-uk.d.ts +1 -1
  158. package/modules/geo-uk.esm.min.js +1 -1
  159. package/modules/geo-uk.min.cjs +1 -1
  160. package/modules/geo-uk.min.js +1 -1
  161. package/modules/geo-us-states.d.ts +1 -1
  162. package/modules/geo-us-states.esm.min.js +1 -1
  163. package/modules/geo-us-states.min.cjs +1 -1
  164. package/modules/geo-us-states.min.js +1 -1
  165. package/modules/geo-world-110m.d.ts +1 -1
  166. package/modules/geo-world-110m.esm.min.js +1 -1
  167. package/modules/geo-world-110m.min.cjs +1 -1
  168. package/modules/geo-world-110m.min.js +1 -1
  169. package/modules/geo-world-50m.d.ts +1 -1
  170. package/modules/geo-world-50m.esm.min.js +1 -1
  171. package/modules/geo-world-50m.min.cjs +1 -1
  172. package/modules/geo-world-50m.min.js +1 -1
  173. package/modules/geometry.d.ts +1 -1
  174. package/modules/geometry.esm.min.js +2 -2
  175. package/modules/geometry.min.cjs +2 -2
  176. package/modules/geometry.min.js +2 -2
  177. package/modules/htmx.d.ts +1 -1
  178. package/modules/htmx.esm.min.js +3 -3
  179. package/modules/htmx.min.cjs +3 -3
  180. package/modules/htmx.min.js +3 -3
  181. package/modules/kanban.d.ts +1 -1
  182. package/modules/kanban.esm.min.js +2 -2
  183. package/modules/kanban.min.cjs +2 -2
  184. package/modules/kanban.min.js +2 -2
  185. package/modules/kpi.d.ts +1 -1
  186. package/modules/kpi.esm.min.js +2 -2
  187. package/modules/kpi.min.cjs +2 -2
  188. package/modules/kpi.min.js +2 -2
  189. package/modules/layout.d.ts +1 -1
  190. package/modules/layout.esm.min.js +2 -2
  191. package/modules/layout.min.cjs +2 -2
  192. package/modules/layout.min.js +2 -2
  193. package/modules/leaflet.d.ts +1 -1
  194. package/modules/leaflet.esm.min.js +2 -2
  195. package/modules/leaflet.min.cjs +2 -2
  196. package/modules/leaflet.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/presets/antd5.css +23 -0
  206. package/modules/presets/bootstrap5.css +46 -5
  207. package/modules/presets/fluent2.css +31 -4
  208. package/modules/presets/material3.css +53 -5
  209. package/modules/presets.d.ts +1 -1
  210. package/modules/presets.esm.min.js +2 -2
  211. package/modules/presets.min.cjs +2 -2
  212. package/modules/presets.min.js +2 -2
  213. package/modules/react.d.ts +1 -1
  214. package/modules/react.esm.min.js +2 -2
  215. package/modules/react.min.cjs +2 -2
  216. package/modules/react.min.js +2 -2
  217. package/modules/svelte.d.ts +1 -1
  218. package/modules/svelte.esm.min.js +2 -2
  219. package/modules/svelte.min.cjs +2 -2
  220. package/modules/svelte.min.js +2 -2
  221. package/modules/tabs.d.ts +1 -1
  222. package/modules/tabs.esm.min.js +2 -2
  223. package/modules/tabs.min.cjs +2 -2
  224. package/modules/tabs.min.js +2 -2
  225. package/modules/vue.d.ts +1 -1
  226. package/modules/vue.esm.min.js +2 -2
  227. package/modules/vue.min.cjs +2 -2
  228. package/modules/vue.min.js +2 -2
  229. package/modules/webcomponent.d.ts +1 -1
  230. package/modules/webcomponent.esm.min.js +3 -3
  231. package/modules/webcomponent.min.cjs +3 -3
  232. package/modules/webcomponent.min.js +3 -3
  233. package/package.json +1 -1
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * Lattice Grid 1.80.0, leaflet module
2
+ * Lattice Grid 1.81.0, leaflet module
3
3
  * Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
4
4
  * https://latticegrid.dev
5
5
  */
6
- var Vt=Object.create(null),qt=Object.create(null);function Ze(n,le){Vt[n]=le}function Yt(n){var le=qt[n];if(le)return le;var ve=Object.create(null);qt[n]=ve;var ae=Vt[n];if(!ae)throw new Error("[lattice] missing module: "+n);return ae(ve,Yt),ve}Ze("packages/core/src/internal/util.js",function(n,le){"use strict";Object.defineProperty(n,"VERSION",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"reportedWarnings",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"warnOnce",{enumerable:!0,get:function(){return A}}),Object.defineProperty(n,"infoOnce",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"resetWarnings",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"fail",{enumerable:!0,get:function(){return g}}),Object.defineProperty(n,"invariant",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"DEV",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"isFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(n,"isNil",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"isBlank",{enumerable:!0,get:function(){return T}}),Object.defineProperty(n,"isCtor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"pathGetter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(n,"pathSetter",{enumerable:!0,get:function(){return K}}),Object.defineProperty(n,"getPath",{enumerable:!0,get:function(){return V}}),Object.defineProperty(n,"setPath",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"humanise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(n,"escapeHtml",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"titleCase",{enumerable:!0,get:function(){return $}}),Object.defineProperty(n,"expand",{enumerable:!0,get:function(){return z}}),Object.defineProperty(n,"toArray",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"merge",{enumerable:!0,get:function(){return S}}),Object.defineProperty(n,"mergeRow",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"Lru",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"defaultCompare",{enumerable:!0,get:function(){return x}}),Object.defineProperty(n,"now",{enumerable:!0,get:function(){return m}}),Object.defineProperty(n,"nextFrame",{enumerable:!0,get:function(){return a}}),Object.defineProperty(n,"cancelFrame",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"frameBatched",{enumerable:!0,get:function(){return k}}),Object.defineProperty(n,"settleDebounce",{enumerable:!0,get:function(){return t}}),Object.defineProperty(n,"whenIdle",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"uid",{enumerable:!0,get:function(){return p}});const ve="1.80.0";async function ae(){return ve}const l="1.80.0",pe=new Set,ne=2e3;function ke(o){if(pe.add(o),pe.size>ne){const d=pe.values().next().value;d!==void 0&&pe.delete(d)}}const H=[],ee=500;function ue(o,d,P){H.push({key:o,level:d,message:P.map(E=>typeof E=="string"?E:q(E)).join(" "),at:Date.now()}),H.length>ee&&H.shift()}function q(o){if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch{return String(o)}}function B(){return H.map(o=>({...o}))}function Y(o){if(o.length===0||typeof o[0]!="string")return o;const d=o[0].replace(/^\[lattice\]\s*/,"");return d===o[0]?o:[d,...o.slice(1)]}function A(o,...d){if(pe.has(o))return;ke(o);const P=Y(d);ue(o,"warn",P),console.warn("[lattice]",...P)}function M(o,...d){if(pe.has(o))return;ke(o);const P=Y(d);ue(o,"info",P),console.info("[lattice]",...P)}function U(){pe.clear(),H.length=0}function g(o,d){const P=new Error(`[lattice] ${o}`);throw d!==void 0&&(P.cause=d),P}function O(o,d){o||g(d)}const w=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function v(o){return typeof o=="function"}function c(o){return o==null}function T(o){return o==null||o===""}function C(o){return typeof o!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(o))?!0:!!(o.prototype&&Object.getOwnPropertyNames(o.prototype).length>1)}const b=new Map;function L(o){let d=b.get(o);if(d)return d;if(!o.includes("."))d=P=>P?.[o];else{const P=o.split("."),E=P.length;d=I=>{let te=I;for(let re=0;re<E;re++){if(te==null)return;te=te[P[re]]}return te}}return b.set(o,d),d}const G=new Map;function K(o){let d=G.get(o);if(d)return d;if(!o.includes("."))d=(P,E)=>{P!=null&&(P[o]=E)};else{const P=o.split("."),E=P.length-1;d=(I,te)=>{let re=I;for(let be=0;be<E;be++){if(re==null)return;const Ae=P[be];re[Ae]==null&&(re[Ae]={}),re=re[Ae]}re!=null&&(re[P[E]]=te)}}return G.set(o,d),d}function V(o,d){return L(d)(o)}function he(o,d,P){K(d)(o,P)}function X(o){return o?(o.includes(".")?o.slice(o.lastIndexOf(".")+1):o).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(/^./,P=>P.toUpperCase()):""}const J={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function oe(o){const d=o==null?"":String(o);return/[&<>"']/.test(d)?d.replace(/[&<>"']/g,P=>J[P]):d}function $(o){return String(o).replace(/\w\S*/g,d=>d[0].toUpperCase()+d.slice(1).toLowerCase())}function z(o,d,P){if(o!==void 0)return o===!0?{enabled:!0,...P}:o===!1?{enabled:!1}:i(o)?o:{[d]:o,enabled:!0}}function y(o){return o==null?[]:Array.isArray(o)?o:[o]}const R=Object.freeze(new Set(["__proto__","constructor","prototype"]));function S(o,d){if(!i(o))return i(d)?{...d}:d;if(!i(d))return d===void 0?o:d;const P={...o};for(const E of Object.keys(d)){if(R.has(E))continue;const I=d[E];I!==void 0&&(P[E]=i(I)&&i(P[E])?S(P[E],I):I)}return P}function r(o,d){if(!i(o)||!i(d)||o===d)return d;const P=Object.create(Object.getPrototypeOf(o));return Object.assign(P,o,d),P}class _{#e;#t=new Map;#n;constructor(d=256,P=null){this.#e=d,this.#n=P}get size(){return this.#t.size}get max(){return this.#e}set max(d){this.#e=d,this.#r()}has(d){return this.#t.has(d)}get(d){const P=this.#t;if(!P.has(d))return;const E=P.get(d);return P.delete(d),P.set(d,E),E}peek(d){return this.#t.get(d)}set(d,P){const E=this.#t;return E.has(d)&&E.delete(d),E.set(d,P),this.#r(),P}delete(d){const P=this.#t.get(d);return this.#t.delete(d)&&this.#n&&this.#n(P,d),P}clear(){if(this.#n)for(const[d,P]of this.#t)this.#n(P,d);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const d=this.#t;for(;d.size>this.#e;){const P=d.keys().next().value,E=d.get(P);d.delete(P),this.#n&&this.#n(E,P)}}}const F=new Map;function D(o,d){const P=`${o||""}|${d?JSON.stringify(d):""}`;let E=F.get(P);return E||(E=new Intl.Collator(o||void 0,{numeric:!0,sensitivity:"variant",...d}),F.set(P,E)),E}function x(o,d){if(o===d)return 0;if(o==null)return 1;if(d==null)return-1;if(typeof o=="number"&&typeof d=="number")return Number.isNaN(o)?Number.isNaN(d)?0:1:Number.isNaN(d)||o<d?-1:o>d?1:0;const P=String(o),E=String(d);return P<E?-1:P>E?1:0}function m(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const e=typeof requestAnimationFrame=="function";function a(o){return e?requestAnimationFrame(o):setTimeout(()=>o(m()),16)}function s(o){o!=null&&(e?cancelAnimationFrame(o):clearTimeout(o))}function k(o){let d=null,P=null;const E=()=>{d=null;const te=P;P=null,o(...te||[])},I=(...te)=>{P=te,d===null&&(d=a(E))};return I.cancel=()=>{s(d),d=null,P=null},I.flush=()=>{d!==null&&(s(d),E())},I}function t(o,d){let P=null,E=null;const I=()=>{if(P=null,E===null)return;const be=E;E=null,o(...be),te()},te=()=>{P=setTimeout(I,d),typeof P?.unref=="function"&&P.unref()},re=(...be)=>{P===null?(o(...be),te()):(E=be,clearTimeout(P),te())};return re.flush=()=>{if(P!==null&&clearTimeout(P),P=null,E===null)return;const be=E;E=null,o(...be)},re.cancel=()=>{P!==null&&clearTimeout(P),P=null,E=null},re.pending=()=>P!==null||E!==null,re}function u(o,d=50){return typeof requestIdleCallback=="function"?requestIdleCallback(o,{timeout:d}):setTimeout(()=>o({timeRemaining:()=>0,didTimeout:!0}),1)}let f=0;function p(o="l"){return`${o}${(++f).toString(36)}`}}),Ze("packages/modules/geometry/geodata.js",function(n,le){"use strict";Object.defineProperty(n,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"EARTH_RADIUS",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"toWkt",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"toWkb",{enumerable:!0,get:function(){return $}}),Object.defineProperty(n,"readGeometry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"parseGeometry",{enumerable:!0,get:function(){return m}}),Object.defineProperty(n,"haversine",{enumerable:!0,get:function(){return a}}),Object.defineProperty(n,"geometryInfo",{enumerable:!0,get:function(){return P}}),Object.defineProperty(n,"geometryKind",{enumerable:!0,get:function(){return E}}),Object.defineProperty(n,"spatialOperand",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"spatialPredicate",{enumerable:!0,get:function(){return Re}});const ve=le("packages/core/src/internal/util.js"),ae=ve.isNil,l=ve.isObject,pe=ve.warnOnce,ne=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),ke=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),H=Object.freeze([...ke,"blank","notBlank"]),ee=63710088e-1,ue=Math.PI/180,q=16,B=1e-12;class Y extends Error{}function A(j){throw new Y(j)}function M(j){(!Array.isArray(j)||j.length<2)&&A("a position needs at least two numbers");const N=Number(j[0]),W=Number(j[1]);return(typeof j[0]!="number"||typeof j[1]!="number"||!Number.isFinite(N)||!Number.isFinite(W))&&A("a coordinate is not a finite number"),[N,W]}function U(j,N,W){Array.isArray(j)||A(`${W} is not an array of positions`);const Q=j.map(M);return Q.length<N&&A(`${W} needs at least ${N} positions, found ${Q.length}`),Q}function g(j){const N=U(j,3,"a polygon ring"),W=N[0],Q=N[N.length-1];return(W[0]!==Q[0]||W[1]!==Q[1])&&N.push([W[0],W[1]]),N.length<4&&A(`a polygon ring needs at least 3 distinct corners, found ${N.length-1}`),N}function O(j){return(!Array.isArray(j)||j.length===0)&&A("a polygon needs at least an outer ring"),j.map(g)}function w(j,N){switch(N>q&&A("geometry collections nest too deeply"),l(j)||A("GeoJSON must be an object"),j.type){case"Feature":return j.geometry==null?null:w(j.geometry,N+1);case"FeatureCollection":return A("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:M(j.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:U(j.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:U(j.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray(j.coordinates)||!j.coordinates.length)&&A("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:j.coordinates.map(W=>U(W,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:O(j.coordinates)};case"MultiPolygon":return(!Array.isArray(j.coordinates)||!j.coordinates.length)&&A("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:j.coordinates.map(O)};case"GeometryCollection":{(!Array.isArray(j.geometries)||!j.geometries.length)&&A("a GeometryCollection needs at least one geometry");const W=j.geometries.map(Q=>w(Q,N+1)).filter(Boolean);return W.length?{type:"GeometryCollection",geometries:W}:null}default:return A(`"${String(j.type)}" is not a GeoJSON geometry type`)}}const i=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),v=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,c=/[A-Za-z]+/y,T=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class C{text;at=0;constructor(N){this.text=N}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(N){this.space(),this.text[this.at]!==N&&A(`WKT expected "${N}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(N){return this.space(),this.text[this.at]===N?(this.at++,!0):!1}word(){this.space(),c.lastIndex=this.at;const N=c.exec(this.text);return N?(this.at+=N[0].length,N[0].toUpperCase()):""}numberNext(){return this.space(),v.lastIndex=this.at,v.test(this.text)}number(){this.space(),v.lastIndex=this.at;const N=v.exec(this.text);return N||A(`WKT expected a number at character ${this.at+1}`),this.at+=N[0].length,Number(N[0])}position(){const N=this.number(),W=this.number();for(;this.numberNext();)this.number();return[N,W]}positionList(){this.expect("(");const N=[this.position()];for(;this.accept(",");)N.push(this.position());return this.expect(")"),N}empty(){const N=this.at;return this.word()==="EMPTY"?!0:(this.at=N,!1)}geometry(N){N>q&&A("geometry collections nest too deeply");const W=this.word(),Q=i[W];Q||A(W?`"${W}" is not a WKT geometry type`:"WKT expected a geometry type");const ye=this.at,xe=this.word();return xe!=="Z"&&xe!=="M"&&xe!=="ZM"&&(this.at=ye),this.empty()?null:this.body(Q,N)}body(N,W){switch(N){case"Point":{this.expect("(");const Q=this.position();return this.expect(")"),{type:"Point",coordinates:Q}}case"LineString":return{type:"LineString",coordinates:U(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const Q=[];do this.empty()||(this.accept("(")?(Q.push(this.position()),this.expect(")")):Q.push(this.position()));while(this.accept(","));return this.expect(")"),Q.length?{type:"MultiPoint",coordinates:Q}:null}case"MultiLineString":{const Q=this.parts(()=>U(this.positionList(),2,"a LineString"));return Q.length?{type:"MultiLineString",coordinates:Q}:null}case"MultiPolygon":{const Q=this.parts(()=>this.polygonBody());return Q.length?{type:"MultiPolygon",coordinates:Q}:null}default:{this.expect("(");const Q=[];do{const ye=this.geometry(W+1);ye&&Q.push(ye)}while(this.accept(","));return this.expect(")"),Q.length?{type:"GeometryCollection",geometries:Q}:null}}}parts(N){this.expect("(");const W=[];do this.empty()||W.push(N());while(this.accept(","));return this.expect(")"),W}polygonBody(){return O(this.parts(()=>this.positionList()))}}function b(j){const N=new C(String(j).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),W=N.geometry(0);return N.space(),N.at<N.text.length&&A(`WKT has unexpected text after the geometry at character ${N.at+1}`),W}function L(j){return Object.is(j,-0)?"0":String(j)}function G(j){return`${L(j[0])} ${L(j[1])}`}function K(j){return`(${j.map(G).join(", ")})`}function V(j){return`(${j.map(K).join(", ")})`}function he(j){const N=m(j);return N?X(N):""}function X(j){switch(j.type){case"Point":return`POINT (${G(j.coordinates)})`;case"LineString":return`LINESTRING ${K(j.coordinates)}`;case"Polygon":return`POLYGON ${V(j.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${j.coordinates.map(N=>`(${G(N)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${j.coordinates.map(K).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${j.coordinates.map(V).join(", ")})`;default:return`GEOMETRYCOLLECTION (${j.geometries.map(X).join(", ")})`}}class J{view;at=0;constructor(N){this.view=new DataView(N.buffer,N.byteOffset,N.byteLength)}need(N){this.at+N>this.view.byteLength&&A(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(N){this.need(4);const W=this.view.getUint32(this.at,N);return this.at+=4,W}f64(N){this.need(8);const W=this.view.getFloat64(this.at,N);return this.at+=8,W}count(N,W){const Q=this.u32(N);return Q*W>this.view.byteLength-this.at&&A(`WKB claims ${Q} elements, more than its bytes can hold`),Q}position(N,W){const Q=this.f64(N),ye=this.f64(N);for(let xe=2;xe<W;xe++)this.f64(N);return[Q,ye]}positions(N,W){const Q=this.count(N,8*W),ye=new Array(Q);for(let xe=0;xe<Q;xe++)ye[xe]=this.position(N,W);return ye}geometry(N,W){N>q&&A("geometry collections nest too deeply");const Q=this.u8();Q!==0&&Q!==1&&A(`WKB byte-order mark is ${Q}, not 0 or 1`);const ye=Q===1,xe=this.u32(ye);let Se=2;xe&2147483648&&Se++,xe&1073741824&&Se++,xe&536870912&&this.u32(ye);let Oe=xe&268435455;if(Oe>=1e3){const _e=Math.floor(Oe/1e3);_e>3&&A(`WKB geometry type ${Oe} is not one this reads`),Se=2+(_e===3?2:1),Oe%=1e3}const Ce=ne[Oe-1];switch(Ce||A(`WKB geometry type ${Oe} is not one this reads`),W&&Ce!==W&&A(`a part of a WKB Multi${W} is a ${Ce}`),Ce){case"Point":{const _e=this.position(ye,Se);return Number.isNaN(_e[0])&&Number.isNaN(_e[1])?null:{type:"Point",coordinates:M(_e)}}case"LineString":return{type:"LineString",coordinates:U(this.positions(ye,Se),2,"a LineString")};case"Polygon":{const _e=this.count(ye,4),Me=[];for(let ze=0;ze<_e;ze++)Me.push(this.positions(ye,Se));return _e?{type:"Polygon",coordinates:O(Me)}:null}default:{const _e=this.count(ye,5),Me=Ce==="GeometryCollection"?void 0:Ce.slice(5),ze=[];for(let ot=0;ot<_e;ot++){const kt=this.geometry(N+1,Me);kt&&ze.push(kt)}return ze.length?Ce==="GeometryCollection"?{type:Ce,geometries:ze}:{type:Ce,coordinates:ze.map(ot=>ot.coordinates)}:null}}}}function oe(j){const N=new J(j),W=N.geometry(0);return N.at!==j.byteLength&&A(`WKB has ${j.byteLength-N.at} bytes left over after the geometry`),W}function $(j){const N=m(j);if(!N)return null;const W=[];let Q=0;const ye=Me=>{const ze=new DataView(new ArrayBuffer(5));ze.setUint8(0,1),ze.setUint32(1,ne.indexOf(Me)+1,!0),W.push(ze),Q+=5},xe=Me=>{const ze=new DataView(new ArrayBuffer(4));ze.setUint32(0,Me,!0),W.push(ze),Q+=4},Se=Me=>{const ze=new DataView(new ArrayBuffer(16*Me.length));Me.forEach((ot,kt)=>{ze.setFloat64(kt*16,ot[0],!0),ze.setFloat64(kt*16+8,ot[1],!0)}),W.push(ze),Q+=16*Me.length},Oe=Me=>{switch(ye(Me.type),Me.type){case"Point":Se([Me.coordinates]);break;case"LineString":xe(Me.coordinates.length),Se(Me.coordinates);break;case"Polygon":xe(Me.coordinates.length);for(const ze of Me.coordinates)xe(ze.length),Se(ze);break;case"GeometryCollection":xe(Me.geometries.length);for(const ze of Me.geometries)Oe(ze);break;default:{const ze=Me.type.slice(5);xe(Me.coordinates.length);for(const ot of Me.coordinates)Oe({type:ze,coordinates:ot})}}};Oe(N);const Ce=new Uint8Array(Q);let _e=0;for(const Me of W)Ce.set(new Uint8Array(Me.buffer),_e),_e+=Me.byteLength;return Ce}const z=/^0[01](?:[0-9a-fA-F]{2})+$/,y=/^[A-Za-z0-9+/_-]+={0,2}$/,R=(()=>{const j=new Int16Array(128).fill(-1),N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let W=0;W<N.length;W++)j[N.charCodeAt(W)]=W;return j[45]=62,j[95]=63,j})();function S(j){const N=new Uint8Array(j.length/2);for(let W=0;W<N.length;W++)N[W]=parseInt(j.slice(W*2,W*2+2),16);return N}function r(j){const N=j.replace(/=+$/,""),W=new Uint8Array(Math.floor(N.length*3/4));let Q=0,ye=0,xe=0;for(let Se=0;Se<N.length;Se++)ye=ye<<6|R[N.charCodeAt(Se)],Q+=6,Q>=8&&(Q-=8,W[xe++]=ye>>Q&255);return W.subarray(0,xe)}function _(j){const N=j.trim();if(N==="")return null;if(N[0]==="{"){let W;try{W=JSON.parse(N)}catch{return A("the text starts like GeoJSON but is not valid JSON")}return w(W,0)}if(z.test(N))return oe(S(N));if(T.test(N))return b(N);if(y.test(N)){const W=r(N);if(W.length>=5&&(W[0]===0||W[0]===1))return oe(W)}return A("the text is not WKT, GeoJSON, or hex or base64 WKB")}const F=new WeakSet;function D(j){if(ae(j))return{geometry:null,reason:null};if(typeof j=="object"&&F.has(j))return{geometry:j,reason:null};try{let N;return typeof j=="string"?N=_(j):j instanceof Uint8Array?N=oe(j):j instanceof ArrayBuffer?N=oe(new Uint8Array(j)):ArrayBuffer.isView(j)?N=oe(new Uint8Array(j.buffer,j.byteOffset,j.byteLength)):l(j)?N=w(j,0):A(`${Array.isArray(j)?"an array":`a ${typeof j}`} is not a geometry`),N&&x(N),{geometry:N||null,reason:null}}catch(N){if(N instanceof Y)return{geometry:null,reason:N.message};throw N}}function x(j){if(F.add(j),j.type==="GeometryCollection")for(const N of j.geometries)x(N)}function m(j){return D(j).geometry}function e(j,N){switch(j.type){case"Point":N(j.coordinates);break;case"MultiPoint":case"LineString":j.coordinates.forEach(N);break;case"MultiLineString":case"Polygon":for(const W of j.coordinates)W.forEach(N);break;case"MultiPolygon":for(const W of j.coordinates)for(const Q of W)Q.forEach(N);break;default:for(const W of j.geometries)e(W,N)}}function a(j,N){const W=j[1]*ue,Q=N[1]*ue,ye=Q-W,xe=(N[0]-j[0])*ue,Se=Math.sin(ye/2)**2+Math.cos(W)*Math.cos(Q)*Math.sin(xe/2)**2;return 2*ee*Math.asin(Math.min(1,Math.sqrt(Se)))}function s(j){let N=0;for(let W=1;W<j.length;W++)N+=a(j[W-1],j[W]);return N}function k(j){const N=j.length-1;if(N<3)return 0;let W=0;for(let Q=0;Q<N;Q++){const ye=j[(Q-1+N)%N],xe=j[(Q+1)%N];W+=(xe[0]-ye[0])*ue*Math.sin(j[Q][1]*ue)}return Math.abs(W)*ee*ee/2}function t(j){let N=k(j[0]);for(let W=1;W<j.length;W++)N-=k(j[W]);return Math.max(0,N)}function u(j){let N=0,W=0,Q=0;for(let ye=0;ye<j.length-1;ye++){const[xe,Se]=j[ye],[Oe,Ce]=j[ye+1],_e=xe*Ce-Oe*Se;N+=_e,W+=(xe+Oe)*_e,Q+=(Se+Ce)*_e}return{a:N,cx:W,cy:Q}}function f(){let j=0,N=0,W=0;return{add(Q,ye,xe){j+=Q*xe,N+=ye*xe,W+=xe},get(){return W>0?[j/W,N/W]:null}}}function p(j){let N=0,W=0;for(const Q of j)N+=Q[0],W+=Q[1];return[N/j.length,W/j.length]}function o(j,N){switch(j.type){case"Point":N[0].add(j.coordinates[0],j.coordinates[1],1);break;case"MultiPoint":for(const W of j.coordinates)N[0].add(W[0],W[1],1);break;case"LineString":case"MultiLineString":{const W=j.type==="LineString"?[j.coordinates]:j.coordinates;for(const Q of W){for(let ye=1;ye<Q.length;ye++){const[xe,Se]=Q[ye-1],[Oe,Ce]=Q[ye],_e=Math.hypot(Oe-xe,Ce-Se);N[1].add((xe+Oe)/2,(Se+Ce)/2,_e)}for(const ye of Q)N[0].add(ye[0],ye[1],1)}break}case"Polygon":case"MultiPolygon":{const W=j.type==="Polygon"?[j.coordinates]:j.coordinates;for(const Q of W){let ye=0,xe=0,Se=0;Q.forEach((Ce,_e)=>{const Me=u(Ce),ze=(_e===0?1:-1)*(Me.a<0?-1:1);ye+=ze*Me.a,xe+=ze*Me.cx,Se+=ze*Me.cy}),Math.abs(ye)>B&&N[2].add(xe/(3*ye),Se/(3*ye),Math.abs(ye)/2);const Oe=Q[0].slice(0,-1);for(const Ce of Oe)N[0].add(Ce[0],Ce[1],1)}break}default:for(const W of j.geometries)o(W,N)}}const d=new WeakMap;function P(j){const N=m(j);if(!N)return null;const W=d.get(N);if(W)return W;const Q=[1/0,1/0,-1/0,-1/0];e(N,Me=>{Me[0]<Q[0]&&(Q[0]=Me[0]),Me[1]<Q[1]&&(Q[1]=Me[1]),Me[0]>Q[2]&&(Q[2]=Me[0]),Me[1]>Q[3]&&(Q[3]=Me[1])});const ye=[f(),f(),f()];o(N,ye);const xe=ye[2].get()||ye[1].get()||ye[0].get()||p([[Q[0],Q[1]],[Q[2],Q[3]]]);let Se=0,Oe=0;const Ce=Me=>{switch(Me.type){case"LineString":Se+=s(Me.coordinates);break;case"MultiLineString":for(const ze of Me.coordinates)Se+=s(ze);break;case"Polygon":Oe+=t(Me.coordinates);for(const ze of Me.coordinates)Se+=s(ze);break;case"MultiPolygon":for(const ze of Me.coordinates){Oe+=t(ze);for(const ot of ze)Se+=s(ot)}break;case"GeometryCollection":for(const ze of Me.geometries)Ce(ze);break;default:break}};Ce(N);const _e=Object.freeze({kind:N.type,bbox:Object.freeze(Q),centroid:Object.freeze(xe),length:Se,area:Oe});return d.set(N,_e),_e}function E(j){const N=P(j);return N?N.kind:null}function I(j,N){const W=typeof j=="string"?j.split(/[\s,;]+/).filter(Boolean):j;if(!Array.isArray(W)||W.length!==N)return null;const Q=W.map(ye=>typeof ye=="number"?ye:typeof ye=="string"?Number(ye):NaN);return Q.every(Number.isFinite)?Q:null}function te(j,N){if(j==="withinBbox"){const W=I(N,4);return W?W[0]>W[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:W[1]>W[3]?{reason:"the box's minLat is above its maxLat"}:{operand:W}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if(j==="withinDistance"){let W=null;if(l(N)&&!Array.isArray(N)){const Q=N;W=I([Q.lon,Q.lat,Q.metres],3)}else W=I(N,3);return!W||W[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:W[0],lat:W[1],metres:W[2]}}}if(j==="withinPolygon"||j==="intersects"){const W=j==="intersects"?I(N,4):null;if(W){if(W[0]>W[2]||W[1]>W[3])return{reason:"the box's minimum is above its maximum"};const[xe,Se,Oe,Ce]=W;return{operand:{type:"Polygon",coordinates:[[[xe,Se],[Oe,Se],[Oe,Ce],[xe,Ce],[xe,Se]]]}}}const{geometry:Q,reason:ye}=D(N);return Q?j==="withinPolygon"&&Q.type!=="Polygon"&&Q.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${Q.type}`}:{operand:Q}:{reason:`${j} needs a geometry: ${ye||"none was given"}`}}return{reason:`"${j}" is not a spatial operator`}}function re(j,N){const[W,Q]=j;let ye=!1;for(let xe=0,Se=N.length-2;xe<N.length-1;Se=xe++){const[Oe,Ce]=N[xe],[_e,Me]=N[Se];Ce>Q!=Me>Q&&W<(_e-Oe)*(Q-Ce)/(Me-Ce)+Oe&&(ye=!ye)}return ye}function be(j,N){if(!re(j,N[0]))return!1;for(let W=1;W<N.length;W++)if(re(j,N[W]))return!1;return!0}function Ae(j,N={points:[],segments:[],polygons:[]}){const W=Q=>{for(let ye=1;ye<Q.length;ye++)N.segments.push([Q[ye-1],Q[ye]]);for(const ye of Q)N.points.push(ye)};switch(j.type){case"Point":N.points.push(j.coordinates);break;case"MultiPoint":for(const Q of j.coordinates)N.points.push(Q);break;case"LineString":W(j.coordinates);break;case"MultiLineString":j.coordinates.forEach(W);break;case"Polygon":N.polygons.push(j.coordinates),j.coordinates.forEach(W);break;case"MultiPolygon":for(const Q of j.coordinates)N.polygons.push(Q),Q.forEach(W);break;default:for(const Q of j.geometries)Ae(Q,N)}return N}function Le(j,N,W){const Q=(N[0]-j[0])*(W[1]-j[1])-(N[1]-j[1])*(W[0]-j[0]);return Math.abs(Q)<=B?0:Math.sign(Q)}function Ne(j,N,W){return j[0]>=Math.min(N[0],W[0])-B&&j[0]<=Math.max(N[0],W[0])+B&&j[1]>=Math.min(N[1],W[1])-B&&j[1]<=Math.max(N[1],W[1])+B}function Ie(j,N){const[W,Q]=j,[ye,xe]=N,Se=Le(W,Q,ye),Oe=Le(W,Q,xe),Ce=Le(ye,xe,W),_e=Le(ye,xe,Q);return Se!==Oe&&Ce!==_e?!0:Se===0&&Ne(ye,W,Q)||Oe===0&&Ne(xe,W,Q)||Ce===0&&Ne(W,ye,xe)||_e===0&&Ne(Q,ye,xe)}function Ke(j,N){return j[0]<=N[2]&&N[0]<=j[2]&&j[1]<=N[3]&&N[1]<=j[3]}function Be(j,N){const W=P(j),Q=P(N);if(!Ke(W.bbox,Q.bbox))return!1;const ye=Ae(j),xe=Ae(N);for(const Se of xe.polygons)for(const Oe of ye.points)if(be(Oe,Se))return!0;for(const Se of ye.polygons)for(const Oe of xe.points)if(be(Oe,Se))return!0;for(const Se of ye.segments)for(const Oe of xe.segments)if(Ie(Se,Oe))return!0;for(const Se of ye.points){for(const Oe of xe.points)if(Math.abs(Se[0]-Oe[0])<=B&&Math.abs(Se[1]-Oe[1])<=B)return!0;for(const Oe of xe.segments)if(Le(Oe[0],Oe[1],Se)===0&&Ne(Se,Oe[0],Oe[1]))return!0}for(const Se of xe.points)for(const Oe of ye.segments)if(Le(Oe[0],Oe[1],Se)===0&&Ne(Se,Oe[0],Oe[1]))return!0;return!1}function Re(j,N){const{operand:W,reason:Q}=te(j,N);if(Q)return pe(`filter:geometry:${j}`,`a "${j}" condition was refused: ${Q}. It matches no row rather than guessing.`),()=>!1;switch(j){case"withinBbox":return ye=>{const xe=P(ye);if(!xe)return!1;const Se=xe.bbox;return Se[0]>=W[0]&&Se[1]>=W[1]&&Se[2]<=W[2]&&Se[3]<=W[3]};case"withinPolygon":{const ye=W.type==="Polygon"?[W.coordinates]:W.coordinates,xe=Se=>ye.some(Oe=>be(Se,Oe));return Se=>{const Oe=m(Se);return Oe?Oe.type==="Point"?xe(Oe.coordinates):Oe.type==="MultiPoint"?Oe.coordinates.every(xe):xe(P(Oe).centroid):!1}}case"intersects":return ye=>{const xe=m(ye);return!!xe&&Be(xe,W)};default:{const ye=[W.lon,W.lat];return xe=>{const Se=P(xe);return!!Se&&a(Se.centroid,ye)<=W.metres}}}}}),Ze("packages/core/src/source/filterwire.js",function(n,le){"use strict";Object.defineProperty(n,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"warnWherePageRelative",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"warnWhereNotApplied",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"warnWhereOverThreshold",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"resolveRelativeRange",{enumerable:!0,get:function(){return v}}),Object.defineProperty(n,"relativeTokenOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"relativeTokenHelp",{enumerable:!0,get:function(){return T}}),Object.defineProperty(n,"isResolvableRelative",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"resolveRelativeCondition",{enumerable:!0,get:function(){return b}}),Object.defineProperty(n,"isGroup",{enumerable:!0,get:function(){return L}}),Object.defineProperty(n,"forEachCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"mapConditions",{enumerable:!0,get:function(){return K}}),Object.defineProperty(n,"normaliseFilterSet",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"buildFilterSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(n,"wireFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"querySignature",{enumerable:!0,get:function(){return oe}});const ae=le("packages/core/src/internal/util.js").warnOnce,l="source.remote.hostFilter",pe="source.where.pageRelative";function ne(y,R){!Array.isArray(y)||!y.length||ae(pe,`filters.where (${y.join(", ")}) runs over the rows the ${R} 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 ke(y){const R=(y||{}).config;!R||!R.hostFilter||ae(l,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function ee(y,R){ae(`${H}:${y}`,`filters.where("${y}") is registered but the ${R} 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 ue="source.where.overThreshold";function q(y,R,S,r){!Array.isArray(y)||!y.length||ae(`${ue}:${R}`,`filters.where (${y.join(", ")}) is not applied to the ${R} pushdown source:`,S===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${S.toLocaleString()} rows, at or past the whereRowLimit of ${r.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 B=new Map;function Y(y){let R=B.get(y);return R||(R=new Intl.DateTimeFormat("en-US",{timeZone:y,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),B.set(y,R)),R}function A(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function M(y,R){const S=Y(R).formatToParts(new Date(y)),r={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const _ of S)_.type==="year"?r.y=+_.value:_.type==="month"?r.m=+_.value:_.type==="day"?r.d=+_.value:_.type==="hour"?r.h=+_.value%24:_.type==="minute"?r.mi=+_.value:_.type==="second"&&(r.s=+_.value);return r}function U(y,R){const S=M(y,R);return Date.UTC(S.y,S.m-1,S.d,S.h,S.mi,S.s)-Math.floor(y/1e3)*1e3}function g(y,R,S,r){const _=Date.UTC(y,R-1,S),F=_-U(_,r);return _-U(F,r)}function O(y,R,S){const r=new Date(Date.UTC(y.y,y.m-1,y.d+R));return g(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),S)}const w=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(y,R){if(typeof y!="string")return null;const S=y.trim().toLowerCase().replace(/[\s_-]+/g,""),r=/^last(\d*|n)days?$/.exec(S);if(r){const _=r[1]==="n"?"":r[1],F=Number(_||R);return!Number.isFinite(F)||F<=0?null:{kind:"lastNDays",n:Math.floor(F)}}switch(S){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 v(y,R={}){const S=i(y,R.n);if(!S)return null;const r=R.tz||A(),_=R.now instanceof Date?R.now.getTime():typeof R.now=="number"?R.now:Date.now(),F=M(_,r),D=g(F.y,F.m,F.d,r),x=O(F,1,r);let m=D,e=x;switch(S.kind){case"today":break;case"yesterday":m=O(F,-1,r),e=D;break;case"lastNDays":e=R.includeToday?x:D,m=O(F,R.includeToday?-(S.n-1):-S.n,r);break;case"thisWeek":{const a=Number.isFinite(R.weekStartsOn)?Number(R.weekStartsOn):1,k=(new Date(Date.UTC(F.y,F.m-1,F.d)).getUTCDay()-a+7)%7;m=O(F,-k,r),e=O(F,-k+7,r);break}case"thisMonth":m=g(F.y,F.m,1,r),e=g(F.m===12?F.y+1:F.y,F.m===12?1:F.m+1,1,r);break;case"thisQuarter":case"quarterToDate":{const a=Math.floor((F.m-1)/3)*3+1;m=g(F.y,a,1,r),e=S.kind==="quarterToDate"?x:a===10?g(F.y+1,1,1,r):g(F.y,a+3,1,r);break}case"thisYear":case"yearToDate":m=g(F.y,1,1,r),e=S.kind==="yearToDate"?x:g(F.y+1,1,1,r);break;default:return null}return{from:new Date(m).toISOString(),to:new Date(e).toISOString(),bounds:"[)",tz:r,relative:S.kind==="lastNDays"?`last${S.n}Days`:S.kind,n:S.n}}function c(y){if(!y||typeof y!="object")return null;const R=y.value;if(R&&typeof R=="object"&&!Array.isArray(R)&&"relative"in R)return{token:String(R.relative),n:typeof R.n=="number"?R.n:void 0};if(y.op==="relative"&&typeof y.value=="string")return{token:y.value,n:void 0};const S=y.meta;return S&&typeof S.relative=="string"&&y.value===void 0?{token:S.relative,n:typeof S.n=="number"?S.n:void 0}:null}function T(){return`Known tokens: ${w.filter(R=>R!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function C(y){const R=c(y);return R?i(R.token,R.n)!==null:!1}function b(y,R={}){const S=c(y);if(!S)return y;const r=v(S.token,{...R,n:S.n});return r?{...y,type:y.type||"date",op:"between",value:[r.from,r.to],bounds:y.bounds||r.bounds,meta:{...y.meta||{},relative:r.relative,tz:r.tz}}:(ae(`source.relative.${S.token}`,`unknown relative date token "${S.token}"; sending the condition unresolved.`,T()),y)}function L(y){return!!y&&typeof y=="object"&&Array.isArray(y.conditions)}function G(y,R){if(y){if(L(y)){for(const S of y.conditions)G(S,R);return}R(y)}}function K(y,R){if(!y)return null;if(!L(y))return R(y);const S=y;let r=!1;const _=[];for(const F of S.conditions){const D=K(F,R);D!==F&&(r=!0),D&&_.push(D)}return!r&&_.length===S.conditions.length?y:_.length?{...S,conditions:_}:null}function V(y){if(!y)return null;if(!L(y))return y;const R=y,S=[];for(const r of R.conditions){const _=V(r);_&&S.push(_)}return S.length?{op:R.op,conditions:S}:null}function he(y){const R=V(y);return R?L(R)&&R.op==="and"?R:{op:"and",conditions:[R]}:null}function X(y){const R=(y||[]).filter(Boolean);return R.length?{op:"and",conditions:R}:null}function J(y,R={}){const S=K(y,r=>b(r,R));return he(S)}function oe(y){const R=$(y.filters??null);return JSON.stringify([R,y.sort??null,y.quick??"",y.groupBy??null,y.pivotBy??null,z(y.context)])}function $(y){if(!y)return null;if(L(y)){const r=y;return{op:r.op,conditions:r.conditions.map($)}}const R=y,S=R.meta&&typeof R.meta.relative=="string"?R.meta.relative:c(R)?.token;return{col:R.col,op:R.op,bounds:R.bounds??null,caseSensitive:R.caseSensitive??!1,value:S?`rel:${S}`:R.value??null}}function z(y){if(y==null)return null;try{return JSON.parse(JSON.stringify(y))}catch{return ae("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ze("packages/core/src/source/aggregates.js",function(n,le){"use strict";Object.defineProperty(n,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"pushableAggregates",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"fillAggregateSql",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"resolveAggregatesConfig",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"routeAggregate",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"resolveAggregatePlan",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"groupKeysPushable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"pushdownDocRows",{enumerable:!0,get:function(){return ue}});const ve=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function ae(){const q=new Set;for(const[B,Y]of Object.entries(ve))Y.pushable&&q.add(B);return q}function l(q,B,Y){let A=q.split("%c").join(B);return Y!==void 0&&(A=A.split("%w").join(Y)),A}function pe(q){const B=q||{},Y=B.default==="engine"||B.default==="engine-if-identical"?B.default:"client",A={};if(B.overrides&&typeof B.overrides=="object")for(const[M,U]of Object.entries(B.overrides))(U==="engine"||U==="client")&&(A[M]=U);return{default:Y,overrides:A}}function ne(q,B){const Y=ve[q];if(!Y||!Y.pushable)return"client";const A=B.overrides[q];return A==="engine"||A==="client"?A:B.default==="client"?"client":B.default==="engine-if-identical"?Y.class==="identical"?"engine":"client":"engine"}function ke(q,B){const Y=pe(B),A=[],M=[];for(const U of q||[]){const g=ve[U.fn],O=ne(U.fn,Y),w={id:U.id,col:U.col,fn:U.fn,class:g?g.class:"fallback"};U.weight!==void 0&&(w.weight=U.weight),U.params!==void 0&&(w.params=U.params),O==="engine"?A.push(w):(w.reason=g&&!g.pushable?g.note||"the engine cannot express this stat":"client by config",M.push(w))}return{engine:A,client:M,config:Y}}const H=/^[A-Za-z_][A-Za-z0-9_$]*$/;function ee(q,B=[]){return(q||[]).every(A=>{if(typeof A=="string")return H.test(A);if(!A||typeof A!="object")return!1;const M=A;return Array.isArray(B)&&B.includes(M.bucket)&&typeof M.col=="string"&&H.test(M.col)&&typeof M.size=="number"&&Number.isFinite(M.size)&&M.size>0})}function ue(){return Object.entries(ve).map(([q,B])=>({stat:q,class:B.class,sql:B.sql?l(B.sql,"col",B.twoColumn?"weight":void 0):"",note:B.note||(B.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ze("packages/core/src/source/abort.js",function(n,le){"use strict";Object.defineProperty(n,"SupersededError",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"RequestToken",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"AbortScope",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"createAbortScope",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"isAbortError",{enumerable:!0,get:function(){return ne}});class ve extends Error{constructor(H,ee="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${ee}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class ae{#e;constructor(H,ee,ue,q){this.#e=H,this.key=ee,this.controller=ue,this.signal=ue.signal,this.seq=q}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new ve(this.key,H)),this.#e.settle(this)}}class l{#e=new Map;#t=0;begin(H="",ee="superseded"){const ue=this.#e.get(H);ue&&!ue.signal.aborted&&ue.controller.abort(new ve(H,ee));const q=new ae(this,H,new AbortController,++this.#t);return this.#e.set(H,q),q}tokenFor(H){return this.#e.get(H)}pending(H=""){const ee=this.#e.get(H);return!!ee&&!ee.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",ee="superseded"){const ue=this.#e.get(H);ue&&ue.abort(ee)}abortAll(H="superseded"){for(const ee of[...this.#e.values()])ee.abort(H);this.#e.clear()}}function pe(){return new l}function ne(ke){if(!ke||typeof ke!="object")return!1;const H=ke;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),Ze("packages/core/src/source/pushdown.js",function(n,le){"use strict";Object.defineProperty(n,"NO_CAPABILITIES",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"resolveMutate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"capabilitiesOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"splitFilters",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return b}}),Object.defineProperty(n,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return V}}),Object.defineProperty(n,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return X}}),Object.defineProperty(n,"planQuery",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"applyResidual",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"createPushdownSource",{enumerable:!0,get:function(){return m}});const ve=le("packages/core/src/internal/util.js"),ae=ve.defaultCompare,l=ve.isFunction,pe=ve.toArray,ne=ve.warnOnce,ke=le("packages/core/src/source/filterwire.js"),H=ke.isGroup,ee=ke.warnWherePageRelative,ue=ke.warnWhereOverThreshold,q=le("packages/core/src/source/aggregates.js"),B=q.resolveAggregatePlan,Y=q.groupKeysPushable,A=q.STAT_PUSHDOWN,U=le("packages/core/src/source/abort.js").SupersededError;function g(e){const a=e&&e.signal;if(!a||!a.aborted)return;const s=a.reason;throw s instanceof Error?s:new U("","superseded before it was sent")}const O=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function w(e){if(!e||typeof e!="object")return!1;const a=e.returning==="row"||e.returning==="key"?e.returning:"none";return{append:e.append===!0,update:e.update===!0,delete:e.delete===!0,returning:a}}function i(e,a){if(!e||typeof a!="string")return;if(!a.includes("."))return e[a];let s=e;for(const k of a.split(".")){if(s===null||typeof s!="object")return;s=s[k]}return s}function v(e){if(e===!0)return!0;if(!e||typeof e!="object")return!1;const a=e;return a.enabled===!1?!1:a.enabled===!0||l(a.commit)}function c(e){const a={...O,...e||{}};return a.operators=new Set(a.operators||[]),a.mutate=w(a.mutate),a}function T(e,a){return!e||!e.op||!a.operators.size?!1:a.operators.has(e.op)}function C(e,a){if(!e)return{pushed:null,residual:null};if(!a.filter)return{pushed:null,residual:e};if(a.filter==="term"){if(H(e)){const u=e.conditions||[];if(String(e.op)!=="and")return{pushed:null,residual:e};const f=u.findIndex(o=>!H(o)&&T(o,a));if(f<0)return{pushed:null,residual:e};const p=u.filter((o,d)=>d!==f);return{pushed:u[f],residual:p.length?{op:"and",conditions:p}:null}}return T(e,a)?{pushed:e,residual:null}:{pushed:null,residual:e}}if(!H(e))return T(e,a)?{pushed:e,residual:null}:{pushed:null,residual:e};if(String(e.op)!=="and")return(e.conditions||[]).every(f=>H(f)?C(f,a).residual===null:T(f,a))?{pushed:e,residual:null}:{pushed:null,residual:e};const s=[],k=[];for(const u of e.conditions||[]){if(H(u)){if(a.filter==="flat"){k.push(u);continue}const f=C(u,a);f.pushed&&s.push(f.pushed),f.residual&&k.push(f.residual);continue}(T(u,a)?s:k).push(u)}const t=u=>u.length===0?null:u.length===1?u[0]:{op:"and",conditions:u};return{pushed:t(s),residual:t(k)}}const b="__lattice_leaves";function L(e){return e.aggregates?e.aggregates instanceof Set?e.aggregates:new Set(pe(e.aggregates)):new Set}function G(e){const a=L(e);return a.size?a.has("count")?e.filter!=="tree"||!e.operators||!e.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function K(e,a,s,k,t,u,f){const p=Array.isArray(e.groupBy)?e.groupBy:[],o=Array.isArray(e.groupPath)?e.groupPath:[],d=Array.isArray(e.groupValues)?e.groupValues:null;if(!a.group){const P=G(a);if(P)return P}return Y(p)?s.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":k?t?u?"a host `where` predicate can only run in the browser, over rows the engine grouped":f?"fullDataset holds the whole matching set, so the grid groups it itself":!d||d.length!==o.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const V="pushdown:pivot-unsupported",he="pushdown:group-unsupported",X=Symbol("lattice.remote.ungroupedLevel");function J(e,a,s,k,t,u){const f=Array.isArray(e.pivotBy)?e.pivotBy:[],p=Array.isArray(e.groupBy)?e.groupBy:[],o=Array.isArray(e.groupPath)?e.groupPath:[],d=Array.isArray(e.groupValues)?e.groupValues:null;return a.pivot?Y(f)?p.length&&!Y(p)?"a grouping key is not a plain column the engine can name in a GROUP BY":s.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":k?t?u?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!d||d.length!==o.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function oe(e,a,s=!1){const k=C(e.filters||null,a),t=[];k.residual&&t.push("filter");const u=e.sort||[],f=u.length===0||a.sort==="multi"&&u.length>=1||a.sort==="single"&&u.length===1;!f&&u.length&&t.push("sort");const p=e.quick?String(e.quick):"",o=!p||!!a.quick;o||t.push("quick");const d=e.where&&e.where.active?e.where:null;d&&t.push("where");const P={filters:k.residual,sort:f?null:u,quick:o?"":p,where:d},E=!!s,I=Array.isArray(e.groupBy)&&e.groupBy.length>0,te=I?K(e,a,k,f,o,d,E):"",re=e.pivotMode!==!1&&Array.isArray(e.pivotBy)&&e.pivotBy.length>0,be=re?J(e,a,k,f,o,d):"",Ae=re&&be==="";re&&!Ae&&t.push("pivot");const Le=re?Ae&&I:I&&te==="";I&&!re&&!Le&&t.push("group");const Ne=(Le||Ae)&&Array.isArray(e.groupValues)?e.groupValues.length:0,Ie=Le||re?!1:E||!!(P.filters||P.sort||P.quick||P.where)||!a.range;return{pushed:{...e,filters:k.pushed,sort:f?u:[],quick:o?p:"",range:Ie?null:e.range},residual:P,needsAll:Ie,unpushed:t,full:E,grouped:Le,groupLevel:Ne,groupReason:re?"":te,pivoted:Ae,pivotReason:be}}function $(e){const a=Array.isArray(e.totals)?e.totals:[],s=e.totalFns&&typeof e.totalFns=="object"?e.totalFns:{},k=[],t=[];for(const u of a){const f=String(u),p=typeof s[f]=="string"?s[f]:null,o=p?A[p]:null;p?!o||!o.pushable||!o.sql?t.push({id:f,fn:p,class:o?o.class:"fallback",reason:o&&o.note?o.note:`the pushdown map cannot express "${p}"`}):o.twoColumn?t.push({id:f,fn:p,class:o.class,reason:`"${p}" reduces two columns, and a grouped request carries no weight column`}):k.push({id:f,col:f,fn:p,class:o.class}):t.push({id:f,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:k,client:t}}const z=Object.freeze({items:e=>e==null?[]:Array.isArray(e)?e:[e]});function y(e,a,s){if(!a)return e;let k=e;if(a.filters&&l(s.evaluateFilters)){const t=k,u={count:k.length,handle:o=>({id:o,get:d=>i(t[d],o)}),itemwise:o=>t.some(d=>Array.isArray(i(d,o)))?z:null},f=s.evaluateFilters(a.filters,u),p=[];for(let o=0;o<k.length;o++)f[o]&&p.push(k[o]);k=p}if(a.where&&a.where.active&&(a.whole||ee(a.where.names,"pushdown"),k=k.filter(t=>a.where.passes(t))),a.quick){const t=a.quick.toLowerCase();k=k.filter(u=>{if(!u||typeof u!="object")return!1;for(const f of Object.values(u))if(f!=null&&String(f).toLowerCase().includes(t))return!0;return!1})}if(a.sort&&a.sort.length&&l(s.sortMulti)){const t=[...new Set(a.sort.map(o=>o.col))],u=k,f=t.map(o=>({id:o,get:d=>i(u[d],o)})),p=s.sortMulti(f,a.sort.map(o=>({col:o.col,dir:o.dir})),Uint32Array.from({length:k.length},(o,d)=>d),{});k=Array.from(p,o=>u[o])}return k}function R(e){return JSON.stringify({filters:e.filters||null,sort:e.sort||[],quick:e.quick||"",groupBy:e.groupBy||[],groupPath:e.groupPath||[],context:e.context??null})}function S(e){if(!e||typeof e!="object")return 16;let a="";try{a=JSON.stringify(e)}catch{return 200}return a.length*2+64}function r(e){const a=e||{};return{enabled:!!a.enabled,maxRows:Number.isFinite(a.maxRows)?a.maxRows:1e6,maxBytesEstimate:Number.isFinite(a.maxBytesEstimate)?a.maxBytesEstimate:512*1024*1024}}const _=5e4;function F(e){return Number.isFinite(e)&&e>=0?e:_}function D(e){return!!e&&l(e.then)}async function x(e){if(!e||e.total!==void 0||!D(e.pendingTotal))return e;const a=await e.pendingTotal,{pendingTotal:s,...k}=e;return typeof a=="number"?{...k,total:a}:k}function m(e={}){const a=e.adapter;if(!a||!l(a.execute))return ne("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...e,mode:"remote",fetch:async()=>({rows:[],total:0})};const s=c(a.capabilities),k=a.capabilities&&Object.getOwnPropertyDescriptor(a.capabilities,"operators");k&&l(k.get)&&Object.defineProperty(s,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(a.capabilities.operators||[]),set:()=>{}});const t=a.name||"adapter";let u=null;const f=()=>l(a.ready)?(u||(u=Promise.resolve(a.ready()).then(()=>{Object.assign(s,c(a.capabilities))},je=>{throw u=null,je})),u):null,p=r(e.fullDataset),o=!!e.allowPartialResults,d=F(e.whereRowLimit);let P=null;const E=e.aggregates;let I=null,te=null,re=null,be=null,Ae=null,Le,Ne=null,Ie=0,Ke=null;const Be=()=>!p.enabled||!I?null:(Ke!==I.key&&(Ie++,Ke=I.key),{rows:I.rows,version:Ie}),Re=async je=>{const Te=je.where&&je.where.active?je.where:null;if(!Te)return{request:je,probe:null};const{where:He,...De}=je,$e=oe(De,s,p.enabled);if($e.needsAll)return{request:je,probe:null};const Ye=R($e.pushed);let Xe=null;return(!P||P.key!==Ye)&&(s.total?(g(je),Xe=await x(await a.execute($e.pushed,je)),P={key:Ye,size:Xe&&typeof Xe.total=="number"?Xe.total:null}):P={key:Ye,size:null}),P.size!==null&&P.size<d?{request:je,probe:null}:(ue(Te.names,t,P.size,d),{request:De,probe:Xe})},j=async(je,Te)=>{Ne=null;const He=$(je.pushed);re={engine:He.engine,client:He.client,groupBy:je.pushed.groupBy},He.client.length&&ne(`source.pushdown.group.totals.${t}.${He.client.map(Ye=>Ye.id).join(".")}`,`the ${t} adapter cannot compute the group subtotal for ${He.client.map(Ye=>`"${Ye.id}" (${Ye.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const De=await a.executeGroupLevel(je.pushed,He.engine,Te)||{};let $e=De.rows||[];return!s.range&&Te.range&&($e=$e.slice(Te.range.start,Te.range.end)),ye(De),De.total===void 0?{rows:$e}:{rows:$e,total:De.total}},N=new Map,W=64,Q=async(je,Te)=>{Ne=null;const He=je.pushed,De=He.groupBy,$e=Array.isArray(He.groupValues)?He.groupValues:[],Ye=$e.length,Xe=[...He.filters?[He.filters]:[],...De.slice(0,Ye).map((de,ge)=>({col:de,op:"eq",value:$e[ge]===void 0?null:$e[ge],caseSensitive:!0}))],lt=Xe.length===0?null:Xe.length===1?Xe[0]:{op:"and",conditions:Xe},ft=Te.range?Te.range.start:0;if(Ye>=De.length){const de={...He,filters:lt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ge=await x(await a.execute(de,Te))||{};let we=ge.rows||[];return!s.range&&Te.range&&(we=we.slice(Te.range.start,Te.range.end)),typeof ge.total=="number"?{rows:we,total:ge.total}:{rows:we}}const qe=De[Ye],dt=$(He),yt=L(s),vt=dt.engine.filter(de=>yt.has(de.fn)),bt=[...dt.engine.filter(de=>!yt.has(de.fn)).map(de=>({id:de.id,fn:de.fn,class:de.class,reason:`the ${t} adapter does not compute "${de.fn}"`})),...dt.client];re={engine:vt,client:bt,groupBy:De},bt.length&&ne(`source.pushdown.group.totals.${t}.${bt.map(de=>de.id).join(".")}`,`the ${t} adapter cannot compute the group subtotal for ${bt.map(de=>`"${de.id}" (${de.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Je=[...vt.map(de=>({id:de.id,col:de.col,fn:de.fn})),{id:b,col:qe,fn:"count"}],tt={...He,filters:lt,range:null},it=JSON.stringify([R(tt),$e,qe,Je]);let h=ft>0?N.get(it):void 0;if(!h){for(h=Promise.resolve(a.executeGroupedAggregates(tt,[qe],Je)),N.delete(it),N.set(it,h);N.size>W;)N.delete(N.keys().next().value);h.catch(()=>{N.get(it)===h&&N.delete(it)})}const se=await h||[];g(Te);const Z=de=>{const ge={};for(const we of vt)ge[we.id]=de?de[we.id]:void 0;return ge},ie=(He.sort||[]).find(de=>de&&de.col===qe),ce=ie&&ie.dir==="desc"?-1:1,fe=se.filter(de=>de&&de.level===1).map(de=>({[qe]:de.keys[0]===void 0?null:de.keys[0],leafCount:Number(de.values&&de.values[b])||0,totals:Z(de.values)})).sort((de,ge)=>ce*ae(de[qe],ge[qe]));if(Ye===0){const de=se.find(we=>we&&we.level===0),ge=de?Number(de.values&&de.values[b]):NaN;ye({matchCount:Number.isFinite(ge)?ge:fe.reduce((we,Pe)=>we+Pe.leafCount,0),...de?{grand:Z(de.values)}:{}})}const me=Te.range?Te.range.end:fe.length;return{rows:fe.slice(ft,me),total:fe.length}},ye=je=>{typeof je.matchCount=="number"&&(be=je.matchCount,Ae=je.grand?{totals:je.grand,leafCount:je.matchCount}:null,Le===void 0&&l(a.unfilteredCount)&&(Le=null,Promise.resolve(a.unfilteredCount()).then(Te=>{Le=typeof Te=="number"?Te:null}).catch(Te=>{ne(`source.pushdown.group.unfiltered.${t}`,`the ${t} adapter could not count the unfiltered set (${Te&&Te.message?Te.message:Te}), so "N of M" falls back to the display count for its denominator.`)})))},xe=async(je,Te)=>{Ne=null;const He=$(je.pushed);re={engine:He.engine,client:He.client,groupBy:je.pushed.groupBy,pivotBy:je.pushed.pivotBy},He.client.length&&ne(`source.pushdown.pivot.totals.${t}.${He.client.map(lt=>lt.id).join(".")}`,`the ${t} adapter cannot compute the pivot cells for ${He.client.map(lt=>`"${lt.id}" (${lt.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const De=await a.executePivotLevel(je.pushed,He.engine,Te)||{};let $e=De.rows||[];!s.range&&Te.range&&($e=$e.slice(Te.range.start,Te.range.end)),ye(De);const Ye=De.pivot&&typeof De.pivot=="object"?De.pivot:{},Xe={cells:Array.isArray(Ye.cells)?Ye.cells:[],...Array.isArray(Ye.axis)?{axis:Ye.axis}:{}};return De.total===void 0?{rows:$e,pivot:Xe}:{rows:$e,total:De.total,pivot:Xe}},Se=je=>{ne(`source.pushdown.pivot.${t}.${je}`,`pushdown:pivot-unsupported: the ${t} adapter cannot pivot this query because ${je}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Te=new Error(`[lattice] ${V}: the ${t} adapter cannot pivot this query because ${je}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Te.code=V,Te.reason=je,Te},Oe=(je,Te)=>{const He={key:Te,state:"pending",value:null};return Ne=He,je.then(De=>(Ne===He&&(Ne={key:Te,state:"settled",value:typeof De=="number"?De:null}),De),De=>{throw Ne===He&&(Ne={key:Te,state:"failed",value:null}),De})},Ce=async je=>{const Te=f();Te&&await Te;const De=je&&je.pivotMode!==!1&&Array.isArray(je.pivotBy)&&je.pivotBy.length>0?{request:je,probe:null}:await Re(je);g(je);let $e=oe(De.request,s,p.enabled);if(s.group&&$e.grouped&&!$e.pivoted&&!l(a.executeGroupLevel)&&(ne(`source.pushdown.group.method.${t}`,`the ${t} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),$e=oe(De.request,{...s,group:!1,aggregates:null},p.enabled)),$e.pivoted&&!l(a.executePivotLevel)&&($e=oe(De.request,{...s,pivot:!1},p.enabled),$e.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),$e.grouped&&!$e.pivoted&&!s.group&&!l(a.executeGroupedAggregates)&&(ne(`source.pushdown.group.aggregates.method.${t}`,`the ${t} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),$e=oe(De.request,{...s,aggregates:null},p.enabled)),te=$e,$e.pivoted)return xe($e,je);if($e.pivotReason&&Se($e.pivotReason),$e.grouped)return s.group?j($e,je):Q($e,je);const Xe=!!$e.groupReason&&!$e.full;Xe?ne(`source.pushdown.group-unsupported.${t}.${$e.groupReason}`,`pushdown:group-unsupported: the ${t} adapter was not asked to group this query because ${$e.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):$e.groupReason&&ne(`source.pushdown.group.${t}.${$e.groupReason}`,`the ${t} adapter was not asked to group this query because ${$e.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const lt=Je=>Xe?{...Je,[X]:!0}:Je;if(!$e.needsAll){const Je=De.probe||await a.execute($e.pushed,je),tt=Je.rows||[];return D(Je.pendingTotal)&&Je.total===void 0?lt({rows:tt,pendingTotal:Oe(Je.pendingTotal,R($e.pushed))}):(Ne=null,!s.total&&Je.total===void 0?lt({rows:tt}):lt({rows:tt,total:Je.total??tt.length}))}$e.unpushed.length&&ne(`source.pushdown.residual.${t}.${$e.unpushed.join(".")}`,`the ${t} adapter cannot push ${$e.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ft=R($e.pushed);if(!I||I.key!==ft){const Je=await x(await a.execute($e.pushed,je));Ne=null;const tt=Je.rows||[];if($e.full){const it=typeof Je.total=="number"?Math.max(Je.total,tt.length):tt.length;if(it>p.maxRows)throw new Error(`[lattice] fullDataset refused: the ${t} adapter's matching set is ${it.toLocaleString()} rows, past the configured maxRows of ${p.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const h=tt.length*S(tt[0]);if(h>p.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${t} adapter's matching set is an estimated ${Math.round(h/(1024*1024)).toLocaleString()} MB across ${tt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(p.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Je.total=="number"&&tt.length<Je.total){const it=!!($e.residual.filters||$e.residual.quick||$e.residual.sort&&$e.residual.sort.length);if(it&&!o)throw new Error(`[lattice] the ${t} adapter returned ${tt.length} of ${Je.total} matching rows when asked for the whole result, and the query has residual ${$e.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);it?ne(`source.pushdown.partial.residual.${t}`,`the ${t} adapter returned ${tt.length} of ${Je.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):ne(`source.pushdown.partial.${t}`,`the ${t} adapter returned ${tt.length} of ${Je.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}I={key:ft,rows:tt,total:typeof Je.total=="number"?Je.total:null}}let qe=$e;if($e.residual.where){const Je=I.total??I.rows.length;if(Je>=d){ue($e.residual.where.names,t,Je,d);const{where:tt,...it}=De.request;qe=oe(it,s,p.enabled),te=qe}}const dt=I.total!==null&&I.rows.length>=I.total,yt=y(I.rows,{...qe.residual,whole:dt},e.compute||{}),vt=je.range?je.range.start:0,bt=je.range?je.range.end:yt.length;return lt({rows:yt.slice(vt,bt),total:yt.length})},_e=async(je,Te)=>{const He=f();He&&await He;const De=oe(je,s,p.enabled);te=De;const $e=B(Te,E),Ye=Array.isArray(je.groupBy)?je.groupBy:[],Xe=Ye.length>0,lt=!De.residual.filters&&!De.residual.quick,ft=!Xe||Y(Ye,s.buckets);let qe=$e.engine,dt=$e.client;if(s.aggregates&&qe.length){const Je=s.aggregates instanceof Set?s.aggregates:new Set(pe(s.aggregates)),tt=qe.filter(it=>!Je.has(it.fn));tt.length&&(qe=qe.filter(it=>Je.has(it.fn)),dt=[...tt.map(it=>({...it,reason:`the ${t} adapter does not compute "${it.fn}"`})),...dt])}const yt=Je=>{dt=[...qe.map(tt=>({...tt,reason:Je})),...dt],qe=[]};qe.length&&!lt?yt(De.residual.quick&&!De.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):qe.length&&!ft&&yt("a grouping key the engine cannot form forces all-client (no mixed provenance)");let vt={},bt;return qe.length&&(l(Xe?a.executeGroupedAggregates:a.executeAggregates)?Xe?bt=await a.executeGroupedAggregates(De.pushed,Ye,qe)||[]:vt=await a.executeAggregates(De.pushed,qe)||{}:(ne(`source.pushdown.aggregates.${t}${Xe?".grouped":""}`,`the ${t} adapter cannot compute ${Xe?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),yt(`adapter cannot compute ${Xe?"grouped ":""}aggregates`))),re={engine:qe,client:dt,...Xe?{groupBy:Ye}:{}},{values:vt,engine:qe,client:dt,...bt!==void 0?{groups:bt}:{}}},Me=v(e.edit),ze=e.edit&&typeof e.edit=="object"&&l(e.edit.commit);let ot=e.edit;if(Me&&!ze)if(s.mutate&&s.mutate.update){const je=Te=>{if(!s.mutate||!s.mutate.update)throw new Error(`[lattice] the ${t} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const He={kind:"update",key:String(Te.key),patch:{[Te.colId]:Te.value}};return a.mutate(He,Te.request||{})};ot={...e.edit===!0?{}:e.edit,commit:je}}else ne(`source.pushdown.readonly.${t}`,`edit is enabled but the ${t} adapter declares mutate: ${s.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const kt=Me&&s.mutate&&(s.mutate.append||s.mutate.delete)?{append:s.mutate.append===!0,remove:s.mutate.delete===!0,returning:s.mutate.returning,mutate:(je,Te)=>a.mutate(je,Te||{})}:null,Nt=async je=>{const Te=f();Te&&await Te;const{range:He,signal:De,export:$e,...Ye}=je||{},Xe={...Ye,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:oe(Xe,s,p.enabled),signal:De}};async function*Et(je,Te={}){const{plan:He,signal:De}=await Nt(je),$e=Math.max(1,Math.floor(Number(Te.pageSize))||5e3),Ye={signal:De,stream:!0};if(!He.needsAll)for(let ft=0;;ft+=$e){g(Ye);const qe=await a.execute({...He.pushed,range:{start:ft,end:ft+$e}},Ye);qe&&D(qe.pendingTotal)&&qe.pendingTotal.then(null,()=>{});const dt=qe&&qe.rows||[];if(dt.length&&(yield dt),dt.length<$e)return}g(Ye);const Xe=await x(await a.execute({...He.pushed,range:void 0},Ye)),lt=y(Xe&&Xe.rows||[],{...He.residual,whole:!0},e.compute||{});for(let ft=0;ft<lt.length;ft+=$e)yield lt.slice(ft,ft+$e)}return{...e,edit:ot,rowMutate:kt,mode:"remote",fetch:Ce,aggregate:_e,countMatching:async je=>{const{plan:Te,signal:He}=await Nt(je);if(!Te.needsAll&&s.total){g({signal:He});const $e=await x(await a.execute({...Te.pushed,range:{start:0,end:0}},{signal:He}));if($e&&typeof $e.total=="number")return $e.total}let De=0;for await(const $e of Et(je))De+=$e.length;return De},streamMatching:Et,lastPlan:()=>te?{...te,...re?{aggregates:re}:{},...Ne?{total:{deferred:!0,state:Ne.state,value:Ne.value}}:{}}:null,fullFrame:Be,counts:()=>({match:be,total:Le??null,pending:!!Ne&&Ne.state==="pending"}),grandTotals:()=>Ae}}}),Ze("packages/modules/shared/engine.js",function(n,le){"use strict";Object.defineProperty(n,"sourceId",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"engineSource",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"gridPivoted",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"loadedAndMatching",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"gridHoldsWindow",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(n,"gridEngineRequest",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"EngineFlight",{enumerable:!0,get:function(){return U}});const ve=le("packages/core/src/source/pushdown.js"),ae=ve.capabilitiesOf,l=ve.planQuery,ne=le("packages/core/src/source/filterwire.js").wireFilters,ke=new WeakMap;let H=0;function ee(g){let O=ke.get(g);return O===void 0&&(O=++H,ke.set(g,O)),O}function ue(g){const O=g&&typeof g.config=="function"?g.config():null,w=O&&O.source&&typeof O.source=="object"?O.source:null;if(!w||typeof w.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const i=ae(w.adapter&&w.adapter.capabilities);return{source:w,caps:i,config:O}}function q(g){const O=g&&typeof g.config=="function"?g.config():null,w=O&&O.source&&typeof O.source=="object"?O.source:null;if(!w||typeof w.lastPlan!="function")return!1;const i=g&&g.state&&typeof g.state.get=="function"?g.state.get():null,v=i&&i.pivot;return!!(v&&v.enabled&&Array.isArray(v.columns)&&v.columns.length>0)}function B(g){let O=0;g.rows.forEach(i=>{i&&!i.group&&i.data!==null&&i.data!==void 0&&O++});const w=typeof g.rows.matchCount=="function"?g.rows.matchCount():NaN;return{loaded:O,total:Number.isFinite(w)?w:NaN}}function Y(g){const O=g&&typeof g.config=="function"?g.config():null,w=O&&O.source&&typeof O.source=="object"?O.source:null;if(!w||w.mode!=="remote"&&w.mode!=="paged")return!1;const{loaded:i,total:v}=B(g);return Number.isFinite(v)&&i<v}function A(g,O){return O?g?{op:"and",conditions:[g,O]}:O:g||null}function M(g,O,w=null){const i=g.filters&&typeof g.filters.where=="function"?g.filters.where():[];if(Array.isArray(i)&&i.length)return{reason:`a \`where\` predicate is in force (${i.join(", ")}), which only the browser can run`};const v=g.filters&&typeof g.filters.quickState=="function"?g.filters.quickState():{text:""},c=v&&v.text?String(v.text):"",{config:T,caps:C}=O,b={filters:ne(A(g.filters.get(),w),{tz:T.timeZone,weekStartsOn:T.weekStartsOn}),sort:[],range:null,context:T.context??null,...c?{quick:c}:{}},L=l(b,C);return L.unpushed.includes("filter")?{reason:w?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:L.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:b,quick:c}}class U{#e=null;#t=null;#n=!1;answer(O){return this.#t&&this.#t.key===O?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(O,w,i){const v=this.#e;if(v){v.key!==O&&v.controller&&v.controller.abort();return}const c=globalThis.AbortController,T=typeof c=="function"?new c:null,C={key:O,controller:T};this.#e=C;let b;Promise.resolve().then(()=>w(T?T.signal:null)).then(L=>{b={key:O,result:L}},L=>{b={key:O,error:L}}).then(()=>{this.#e===C&&(this.#e=null),!this.#n&&(T&&T.signal.aborted||(this.#t=b),i())})}abort(){const O=this.#e;O&&O.controller&&O.controller.abort()}close(){this.#n=!0,this.abort()}}}),Ze("packages/modules/charts/scale.js",function(n,le){"use strict";Object.defineProperty(n,"isNumber",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"toNumber",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"toTime",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"extent",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"niceStep",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(n,"niceDomain",{enumerable:!0,get:function(){return A}}),Object.defineProperty(n,"measureDomain",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"linearTicks",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"timeStepFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(n,"timeTicks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"linearScale",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"timeScale",{enumerable:!0,get:function(){return v}}),Object.defineProperty(n,"key",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"bandScale",{enumerable:!0,get:function(){return T}}),Object.defineProperty(n,"sqrtScale",{enumerable:!0,get:function(){return C}});const ve=[1,2,2.5,5,10],ae=6e4,l=36e5,pe=864e5,ne=365.25*pe,ke=[1,2,5,10,20,25,50,100],H=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,ae,5*ae,15*ae,30*ae,l,3*l,6*l,12*l,pe,2*pe,7*pe,14*pe,30*pe,90*pe,180*pe,...ke.map(b=>b*ne)];function ee(b){return typeof b=="number"&&Number.isFinite(b)}function ue(b){if(b==null||b==="")return null;if(b instanceof Date){const G=b.getTime();return Number.isFinite(G)?G:null}if(typeof b=="boolean")return b?1:0;const L=Number(b);return Number.isFinite(L)?L:null}function q(b){if(b==null||b==="")return null;if(b instanceof Date){const G=b.getTime();return Number.isFinite(G)?G:null}if(typeof b=="number")return Number.isFinite(b)?b:null;const L=Date.parse(String(b));return Number.isFinite(L)?L:null}function B(b){let L=1/0,G=-1/0;for(let K=0;K<b.length;K++){const V=b[K];ee(V)&&(V<L&&(L=V),V>G&&(G=V))}return L===1/0?null:{min:L,max:G}}function Y(b){if(!(b>0))return 1;const L=10**Math.floor(Math.log10(b));for(const G of ve)if(b<=G*L)return G*L;return 10*L}function A(b,L=5){const G=Y((b.max-b.min)/Math.max(1,L));return{min:Math.floor(b.min/G)*G,max:Math.ceil(b.max/G)*G,step:G}}function M(b,L={}){const G=B(b)||{min:0,max:1};let{min:K,max:V}=G;if(L.zero&&(K>0&&(K=0),V<0&&(V=0)),K===V){const he=Math.abs(K)>0?Math.abs(K)/10:1;K-=he,V+=he}if(L.nice!==!1){const he=A({min:K,max:V},L.ticks||5);K=he.min,V=he.max}return ee(L.min)&&(K=L.min),ee(L.max)&&(V=L.max),K===V&&(V=K+1),{min:K,max:V}}function U(b,L=5){const G=Y((b.max-b.min)/Math.max(1,L)),K=Math.ceil(b.min/G),V=Math.floor(b.max/G),he=[];for(let X=K;X<=V;X++){const J=X*G;he.push(Math.abs(J)<G/1e6?0:Number(J.toPrecision(12)))}return he}function g(b,L=5){const G=Math.max(1,L),K=b/G;let V=H[H.length-1];for(const J of H)if(J>=K){V=J;break}if(V<ne)return V;let he=V,X=Math.abs(b/V-G);for(const J of H){if(J<ne)continue;const oe=Math.abs(b/J-G);oe<X&&(X=oe,he=J)}return he}function O(b,L){const G=new Date(b.min).getUTCFullYear();let K=Math.ceil(G/L)*L;Date.UTC(K,0,1)<b.min&&(K+=L);const V=[];for(;Date.UTC(K,0,1)<=b.max;K+=L)V.push(Date.UTC(K,0,1));return V}function w(b,L=5){const G=g(b.max-b.min,L);if(G>=ne)return O(b,Math.round(G/ne));const K=[],V=Math.ceil(b.min/G)*G;for(let he=V;he<=b.max;he+=G)K.push(he);return K}function i(b,L){const G=b.max-b.min||1,[K,V]=L;return{kind:"linear",domain:b,range:L,of(he){return K+(he-b.min)/G*(V-K)},invert(he){return b.min+(he-K)/(V-K||1)*G},ticks(he=5){return U(b,he)}}}function v(b,L){return{...i(b,L),kind:"time",ticks(K=5){return w(b,K)}}}function c(b){if(b==null)return" null";if(b instanceof Date)return` date:${b.getTime()}`;if(typeof b=="object"){const L=b,G=L.id??L.key??L.value;return G!==void 0&&typeof G!="object"?` obj:${String(G)}`:` obj:${String(b)}`}return String(b)}function T(b,L,G=.2){const K=Math.min(.9,Math.max(0,G)),[V,he]=L,X=new Map;for(let $=0;$<b.length;$++){const z=c(b[$]);X.has(z)||X.set(z,$)}const J=b.length?(he-V)/b.length:he-V,oe=Math.max(0,J*(1-K));return{kind:"band",domain:b,range:L,bandwidth:oe,step:J,of($){const z=X.get(c($));return z===void 0?NaN:V+z*J+(J-oe)/2},centre($){const z=this.of($);return Number.isNaN(z)?NaN:z+oe/2},ticks(){return b}}}function C(b,L){const[G,K]=L,V=Math.max(Math.abs(b.max),Math.abs(b.min),0)||1;return{kind:"sqrt",domain:b,range:L,of(he){const X=Math.sqrt(Math.abs(he)/V);return G+X*(K-G)}}}}),Ze("packages/modules/charts/svg.js",function(n,le){"use strict";Object.defineProperty(n,"SVG_NS",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"el",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"svg",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"attr",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"attrs",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"setText",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"clear",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"append",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"path",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"ribbonPath",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"round",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"pathRings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(n,"insideRings",{enumerable:!0,get:function(){return A}});const ve="http://www.w3.org/2000/svg";function ae(M,U,g){const O=M.createElement(U);return g&&O.setAttribute("class",g),O}function l(M,U,g){const O=M.createElementNS(ve,U);if(g)for(const w of Object.keys(g))O.setAttribute(w,String(g[w]));return O}function pe(M,U,g){M&&(g==null?M.removeAttribute(U):M.setAttribute(U,String(g)))}function ne(M,U){if(M)for(const g of Object.keys(U))pe(M,g,U[g])}function ke(M,U){M&&(M.textContent=U==null?"":String(U))}function H(M){if(M)for(;M.firstChild;)M.removeChild(M.firstChild)}function ee(M,U){for(const g of U)g&&M.appendChild(g);return M}function ue(M){return M.join(" ")}function q(M){if(!M||M.length<2)return"";const U=["M",M[0].x,M[0].upper];for(let g=1;g<M.length;g++)U.push("L",M[g].x,M[g].upper);for(let g=M.length-1;g>=0;g--)U.push("L",M[g].x,M[g].lower);return U.push("Z"),ue(U)}function B(M){return Math.round(M*100)/100}function Y(M){const U=[];let g=[];const O=String(M||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let w="",i=[];const v=()=>{if(!w||!i.length){i=[];return}if(w==="M"||w==="L")for(let c=0;c+1<i.length;c+=2)g.push([i[c],i[c+1]]);else w!=="Z"&&i.length>=2&&g.push([i[i.length-2],i[i.length-1]]);i=[]};for(const c of O){if(/[A-Za-z]/.test(c)){if(v(),c==="Z"||c==="z"){g.length>2&&U.push(g),g=[],w="";continue}c==="M"&&g.length>2&&(U.push(g),g=[]),w=c;continue}i.push(Number(c))}return v(),g.length>2&&U.push(g),U}function A(M,U,g){let O=!1;for(const w of M)for(let i=0,v=w.length-1;i<w.length;v=i++){const[c,T]=w[i],[C,b]=w[v];T>g!=b>g&&U<(C-c)*(g-T)/(b-T||1e-12)+c&&(O=!O)}return O}}),Ze("packages/modules/charts/typography.js",function(n,le){"use strict";Object.defineProperty(n,"BASE_SIZE",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"BASE_FAMILY",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"CHAR_RATIO",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"resolveType",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"textWidth",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"widestLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"truncateTo",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"applySize",{enumerable:!0,get:function(){return ue}});const ve=12,ae="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",l=.62;function pe(q){const B=q&&q.font,Y=typeof B=="number"?{size:B}:B||{},A=ne(Y.size,ve);return{family:Y.family||ae,size:A,small:ne(Y.small??Y.tickSize,Math.max(9,A-1)),title:ne(Y.title,Math.round(A*1.15)),axisTitle:ne(Y.axisTitle,Math.max(10,A-1)),weight:Y.weight||"inherit"}}function ne(q,B){const Y=Number(q);return Number.isFinite(Y)&&Y>0?Y:B}function ke(q,B){return String(q??"").length*B*l}function H(q,B){let Y=0;for(const A of q||[]){const M=ke(A,B);M>Y&&(Y=M)}return Y}function ee(q,B,Y){const A=String(q??""),M=Math.floor(B/(Y*l));return M<=0?"":A.length<=M?A:M===1?"…":`${A.slice(0,M-1)}…`}function ue(q,B){!q||!Number.isFinite(B)||(q.style?q.style.fontSize=`${B}px`:q.setAttribute("style",`font-size:${B}px`))}}),Ze("packages/modules/charts/frame.js",function(n,le){"use strict";Object.defineProperty(n,"LABEL_GAP",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"resolveMargin",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"plotRect",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"shouldRotate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"Pool",{enumerable:!0,get:function(){return Y}});const ae=le("packages/modules/charts/svg.js").SVG_NS,l=le("packages/modules/charts/typography.js"),pe=l.textWidth,ne=l.widestLabel,ke=8,H=6,ee=.4;function ue(A,M){const U=typeof A=="number"?A:M,g=A&&typeof A=="object"?A:{},O=w=>Number.isFinite(w)&&w>=0?Number(w):U;return{base:U,top:O(g.top),right:O(g.right),bottom:O(g.bottom),left:O(g.left)}}function q(A){const M=ue(A.margin,typeof A.padding=="number"?A.padding:8),U=M.base,g=A.fontSize||12,O=A.yLabels||[],w=A.xLabels||[],i=A.ySide==="right"?"right":"left",v=i==="right"?"left":"right",c=A.titles||{},T=A.titleSize||g,C=z=>z?T+H:0,b=ne(O,g),L=O.length?Math.min(A.width*ee,M[i]+b+H):Math.max(ke,M[i]),G=M[v]+(A.rightGutter||0),K=(i==="left"?L:G)+C(c.left),V=ne(w.map(z=>String(z).slice(0,14)),g),he=(w.length?A.rotated?Math.min(A.height*ee,H+V):g+H+M.bottom:Math.max(ke,M.bottom))+C(c.bottom),X=(i==="right"?L:G)+C(c.right),J=M.top+(A.topGutter||0),oe=Math.max(0,A.width-K-X),$=Math.max(0,A.height-J-he);return{left:K,top:J,width:oe,height:$,right:K+oe,bottom:J+$,gutter:{left:K,bottom:he,right:X,top:J}}}function B(A,M,U,g){if(!A.length||M<=0)return!1;const O=Number.isFinite(g)&&g>0?Number(g):1;return ne(A,U)>M*O-4}class Y{#e;#t=0;static#n="data-pool-key";constructor(M){this.#e=M}next(M,U,g){if(g!=null)return this.#r(M,U,String(g));const O=this.#e.childNodes[this.#t],w=O&&O.tagName;if(w&&String(w).toLowerCase()===M.toLowerCase())return U&&O.setAttribute("class",U),this.#t++,O;const i=this.#e.ownerDocument.createElementNS(ae,M);return U&&i.setAttribute("class",U),O?this.#e.insertBefore(i,O):this.#e.appendChild(i),this.#t++,i}#r(M,U,g){const O=M.toLowerCase();for(let v=this.#t;v<this.#e.childNodes.length;v++){const c=this.#e.childNodes[v],T=c&&c.tagName;if(T&&String(T).toLowerCase()===O&&c.getAttribute(Y.#n)===g)return v!==this.#t&&this.#e.insertBefore(c,this.#e.childNodes[this.#t]),U&&c.setAttribute("class",U),this.#t++,c}const w=this.#e.ownerDocument.createElementNS(ae,M);w.setAttribute(Y.#n,g),U&&w.setAttribute("class",U);const i=this.#e.childNodes[this.#t];return i?this.#e.insertBefore(w,i):this.#e.appendChild(w),this.#t++,w}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Ze("packages/modules/charts/scheme.js",function(n,le){"use strict";Object.defineProperty(n,"PALETTE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"SCHEMES",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"registerScheme",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"setDefaultScheme",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"schemeNames",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"resolveScheme",{enumerable:!0,get:function(){return A}}),Object.defineProperty(n,"RAMP_SCALES",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"toRgb",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"rampStops",{enumerable:!0,get:function(){return w}});const ae=le("packages/core/src/internal/util.js").warnOnce,l=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),pe=Object.freeze({default:{series:l,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"}}),ne=new Map;let ke="default";function H(i,v){!i||!v||ne.set(String(i),v)}function ee(i){if(typeof i=="string"){ke=i;return}i&&typeof i=="object"&&(ne.set("__default__",i),ke="__default__")}function ue(){return[...Object.keys(pe),...ne.keys()].filter(i=>!i.startsWith("__"))}function q(i){return ne.has(i)?ne.get(i):pe[i]||null}const B=["series","sequential","diverging","positive","negative"];function Y(i){return!i||typeof i!="object"||Array.isArray(i)?!1:!B.some(v=>v in i)}function A(i){const v=q(ke)||pe.default,c=i&&i.scheme,T=Y(c)?c:null,C=typeof c=="string"?q(c):T?null:c||null,b=i&&Array.isArray(i.palette)&&i.palette.length?i.palette:null;T&&b&&ae("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const L=T?null:b,G={...pe.default,...v,...C||{}};L&&(G.series=L);const K=i&&i.ramp&&typeof i.ramp=="object"&&!Array.isArray(i.ramp)?i.ramp:null,V=K?K.colours:i&&i.ramp,he=Array.isArray(V)&&V.length>=2?V:null;he&&(G.sequential=he);const X=K?U(K.scale):null,J=!!(C||L||T),oe=G.series&&G.series.length?G.series:l,$=new Map;let z=0;return{...G,series:(R,S)=>{if(T&&S!==void 0&&S!==null){const r=String(S);return Object.prototype.hasOwnProperty.call(T,r)?T[r]:($.has(r)||$.set(r,z++),g(oe,$.get(r),!0))}return g(oe,R,J)},explicit:J,nameMap:!!T,rampScale:X}}const M=Object.freeze(["linear","log","quantile"]);function U(i){return i==null?null:M.includes(i)?i:(ae(`chart:ramp:scale:${String(i)}`,`chart "ramp.scale" was "${String(i)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function g(i,v,c){const T=(v%i.length+i.length)%i.length;return c?i[T]:`var(--lattice-chart-${T+1}, ${i[T]})`}function O(i){if(typeof i!="string")return null;const v=i.trim(),c=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(v);if(c){const b=c[1];return b.length===3?[0,1,2].map(L=>parseInt(b[L]+b[L],16)):[0,2,4].map(L=>parseInt(b.slice(L,L+2),16))}const T=/^rgba?\(([^)]+)\)$/i.exec(v);if(!T)return null;const C=T[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return C.length===3&&C.every(b=>Number.isFinite(b))?C:null}function w(i,v){const c=v?i.diverging:i.sequential,T=v?pe.default.diverging:pe.default.sequential,C=(Array.isArray(c)?c:T).map((b,L)=>O(b)||O(T[L])||[0,0,0]);return C.length>=2?C:T.map(b=>O(b))}}),Ze("packages/modules/charts/styles.js",function(n,le){"use strict";Object.defineProperty(n,"NS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"seriesColour",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"css",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"injectStyles",{enumerable:!0,get:function(){return H}});const ae=le("packages/modules/charts/scheme.js").PALETTE,l="lat-chartview",pe="data-lattice-chartview";function ne(ee){const ue=(ee%ae.length+ae.length)%ae.length;return`var(--lattice-chart-${ue+1}, ${ae[ue]})`}function ke(){return`
6
+ var Vt=Object.create(null),qt=Object.create(null);function Ze(n,le){Vt[n]=le}function Yt(n){var le=qt[n];if(le)return le;var ve=Object.create(null);qt[n]=ve;var ae=Vt[n];if(!ae)throw new Error("[lattice] missing module: "+n);return ae(ve,Yt),ve}Ze("packages/core/src/internal/util.js",function(n,le){"use strict";Object.defineProperty(n,"VERSION",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"reportedWarnings",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"warnOnce",{enumerable:!0,get:function(){return A}}),Object.defineProperty(n,"infoOnce",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"resetWarnings",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"fail",{enumerable:!0,get:function(){return g}}),Object.defineProperty(n,"invariant",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"DEV",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"isObject",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"isFunction",{enumerable:!0,get:function(){return v}}),Object.defineProperty(n,"isNil",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"isBlank",{enumerable:!0,get:function(){return T}}),Object.defineProperty(n,"isCtor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"pathGetter",{enumerable:!0,get:function(){return L}}),Object.defineProperty(n,"pathSetter",{enumerable:!0,get:function(){return K}}),Object.defineProperty(n,"getPath",{enumerable:!0,get:function(){return V}}),Object.defineProperty(n,"setPath",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"humanise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(n,"escapeHtml",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"titleCase",{enumerable:!0,get:function(){return $}}),Object.defineProperty(n,"expand",{enumerable:!0,get:function(){return z}}),Object.defineProperty(n,"toArray",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"merge",{enumerable:!0,get:function(){return S}}),Object.defineProperty(n,"mergeRow",{enumerable:!0,get:function(){return r}}),Object.defineProperty(n,"Lru",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"collator",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"defaultCompare",{enumerable:!0,get:function(){return x}}),Object.defineProperty(n,"now",{enumerable:!0,get:function(){return m}}),Object.defineProperty(n,"nextFrame",{enumerable:!0,get:function(){return a}}),Object.defineProperty(n,"cancelFrame",{enumerable:!0,get:function(){return s}}),Object.defineProperty(n,"frameBatched",{enumerable:!0,get:function(){return k}}),Object.defineProperty(n,"settleDebounce",{enumerable:!0,get:function(){return t}}),Object.defineProperty(n,"whenIdle",{enumerable:!0,get:function(){return u}}),Object.defineProperty(n,"uid",{enumerable:!0,get:function(){return p}});const ve="1.81.0";async function ae(){return ve}const l="1.81.0",pe=new Set,ne=2e3;function ke(o){if(pe.add(o),pe.size>ne){const d=pe.values().next().value;d!==void 0&&pe.delete(d)}}const H=[],ee=500;function ue(o,d,P){H.push({key:o,level:d,message:P.map(E=>typeof E=="string"?E:q(E)).join(" "),at:Date.now()}),H.length>ee&&H.shift()}function q(o){if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch{return String(o)}}function B(){return H.map(o=>({...o}))}function Y(o){if(o.length===0||typeof o[0]!="string")return o;const d=o[0].replace(/^\[lattice\]\s*/,"");return d===o[0]?o:[d,...o.slice(1)]}function A(o,...d){if(pe.has(o))return;ke(o);const P=Y(d);ue(o,"warn",P),console.warn("[lattice]",...P)}function M(o,...d){if(pe.has(o))return;ke(o);const P=Y(d);ue(o,"info",P),console.info("[lattice]",...P)}function U(){pe.clear(),H.length=0}function g(o,d){const P=new Error(`[lattice] ${o}`);throw d!==void 0&&(P.cause=d),P}function O(o,d){o||g(d)}const w=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function i(o){return o!==null&&typeof o=="object"&&!Array.isArray(o)}function v(o){return typeof o=="function"}function c(o){return o==null}function T(o){return o==null||o===""}function C(o){return typeof o!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(o))?!0:!!(o.prototype&&Object.getOwnPropertyNames(o.prototype).length>1)}const b=new Map;function L(o){let d=b.get(o);if(d)return d;if(!o.includes("."))d=P=>P?.[o];else{const P=o.split("."),E=P.length;d=I=>{let te=I;for(let re=0;re<E;re++){if(te==null)return;te=te[P[re]]}return te}}return b.set(o,d),d}const G=new Map;function K(o){let d=G.get(o);if(d)return d;if(!o.includes("."))d=(P,E)=>{P!=null&&(P[o]=E)};else{const P=o.split("."),E=P.length-1;d=(I,te)=>{let re=I;for(let be=0;be<E;be++){if(re==null)return;const Ae=P[be];re[Ae]==null&&(re[Ae]={}),re=re[Ae]}re!=null&&(re[P[E]]=te)}}return G.set(o,d),d}function V(o,d){return L(d)(o)}function he(o,d,P){K(d)(o,P)}function X(o){return o?(o.includes(".")?o.slice(o.lastIndexOf(".")+1):o).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(/^./,P=>P.toUpperCase()):""}const J={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function oe(o){const d=o==null?"":String(o);return/[&<>"']/.test(d)?d.replace(/[&<>"']/g,P=>J[P]):d}function $(o){return String(o).replace(/\w\S*/g,d=>d[0].toUpperCase()+d.slice(1).toLowerCase())}function z(o,d,P){if(o!==void 0)return o===!0?{enabled:!0,...P}:o===!1?{enabled:!1}:i(o)?o:{[d]:o,enabled:!0}}function y(o){return o==null?[]:Array.isArray(o)?o:[o]}const R=Object.freeze(new Set(["__proto__","constructor","prototype"]));function S(o,d){if(!i(o))return i(d)?{...d}:d;if(!i(d))return d===void 0?o:d;const P={...o};for(const E of Object.keys(d)){if(R.has(E))continue;const I=d[E];I!==void 0&&(P[E]=i(I)&&i(P[E])?S(P[E],I):I)}return P}function r(o,d){if(!i(o)||!i(d)||o===d)return d;const P=Object.create(Object.getPrototypeOf(o));return Object.assign(P,o,d),P}class _{#e;#t=new Map;#n;constructor(d=256,P=null){this.#e=d,this.#n=P}get size(){return this.#t.size}get max(){return this.#e}set max(d){this.#e=d,this.#r()}has(d){return this.#t.has(d)}get(d){const P=this.#t;if(!P.has(d))return;const E=P.get(d);return P.delete(d),P.set(d,E),E}peek(d){return this.#t.get(d)}set(d,P){const E=this.#t;return E.has(d)&&E.delete(d),E.set(d,P),this.#r(),P}delete(d){const P=this.#t.get(d);return this.#t.delete(d)&&this.#n&&this.#n(P,d),P}clear(){if(this.#n)for(const[d,P]of this.#t)this.#n(P,d);this.#t.clear()}keys(){return this.#t.keys()}values(){return this.#t.values()}#r(){const d=this.#t;for(;d.size>this.#e;){const P=d.keys().next().value,E=d.get(P);d.delete(P),this.#n&&this.#n(E,P)}}}const F=new Map;function D(o,d){const P=`${o||""}|${d?JSON.stringify(d):""}`;let E=F.get(P);return E||(E=new Intl.Collator(o||void 0,{numeric:!0,sensitivity:"variant",...d}),F.set(P,E)),E}function x(o,d){if(o===d)return 0;if(o==null)return 1;if(d==null)return-1;if(typeof o=="number"&&typeof d=="number")return Number.isNaN(o)?Number.isNaN(d)?0:1:Number.isNaN(d)||o<d?-1:o>d?1:0;const P=String(o),E=String(d);return P<E?-1:P>E?1:0}function m(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const e=typeof requestAnimationFrame=="function";function a(o){return e?requestAnimationFrame(o):setTimeout(()=>o(m()),16)}function s(o){o!=null&&(e?cancelAnimationFrame(o):clearTimeout(o))}function k(o){let d=null,P=null;const E=()=>{d=null;const te=P;P=null,o(...te||[])},I=(...te)=>{P=te,d===null&&(d=a(E))};return I.cancel=()=>{s(d),d=null,P=null},I.flush=()=>{d!==null&&(s(d),E())},I}function t(o,d){let P=null,E=null;const I=()=>{if(P=null,E===null)return;const be=E;E=null,o(...be),te()},te=()=>{P=setTimeout(I,d),typeof P?.unref=="function"&&P.unref()},re=(...be)=>{P===null?(o(...be),te()):(E=be,clearTimeout(P),te())};return re.flush=()=>{if(P!==null&&clearTimeout(P),P=null,E===null)return;const be=E;E=null,o(...be)},re.cancel=()=>{P!==null&&clearTimeout(P),P=null,E=null},re.pending=()=>P!==null||E!==null,re}function u(o,d=50){return typeof requestIdleCallback=="function"?requestIdleCallback(o,{timeout:d}):setTimeout(()=>o({timeRemaining:()=>0,didTimeout:!0}),1)}let f=0;function p(o="l"){return`${o}${(++f).toString(36)}`}}),Ze("packages/modules/geometry/geodata.js",function(n,le){"use strict";Object.defineProperty(n,"GEOMETRY_KINDS",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"SPATIAL_OPERATORS",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"GEOMETRY_OPERATORS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"EARTH_RADIUS",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"toWkt",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"toWkb",{enumerable:!0,get:function(){return $}}),Object.defineProperty(n,"readGeometry",{enumerable:!0,get:function(){return D}}),Object.defineProperty(n,"parseGeometry",{enumerable:!0,get:function(){return m}}),Object.defineProperty(n,"haversine",{enumerable:!0,get:function(){return a}}),Object.defineProperty(n,"geometryInfo",{enumerable:!0,get:function(){return P}}),Object.defineProperty(n,"geometryKind",{enumerable:!0,get:function(){return E}}),Object.defineProperty(n,"spatialOperand",{enumerable:!0,get:function(){return te}}),Object.defineProperty(n,"spatialPredicate",{enumerable:!0,get:function(){return Re}});const ve=le("packages/core/src/internal/util.js"),ae=ve.isNil,l=ve.isObject,pe=ve.warnOnce,ne=Object.freeze(["Point","LineString","Polygon","MultiPoint","MultiLineString","MultiPolygon","GeometryCollection"]),ke=Object.freeze(["withinBbox","withinPolygon","intersects","withinDistance"]),H=Object.freeze([...ke,"blank","notBlank"]),ee=63710088e-1,ue=Math.PI/180,q=16,B=1e-12;class Y extends Error{}function A(j){throw new Y(j)}function M(j){(!Array.isArray(j)||j.length<2)&&A("a position needs at least two numbers");const N=Number(j[0]),W=Number(j[1]);return(typeof j[0]!="number"||typeof j[1]!="number"||!Number.isFinite(N)||!Number.isFinite(W))&&A("a coordinate is not a finite number"),[N,W]}function U(j,N,W){Array.isArray(j)||A(`${W} is not an array of positions`);const Q=j.map(M);return Q.length<N&&A(`${W} needs at least ${N} positions, found ${Q.length}`),Q}function g(j){const N=U(j,3,"a polygon ring"),W=N[0],Q=N[N.length-1];return(W[0]!==Q[0]||W[1]!==Q[1])&&N.push([W[0],W[1]]),N.length<4&&A(`a polygon ring needs at least 3 distinct corners, found ${N.length-1}`),N}function O(j){return(!Array.isArray(j)||j.length===0)&&A("a polygon needs at least an outer ring"),j.map(g)}function w(j,N){switch(N>q&&A("geometry collections nest too deeply"),l(j)||A("GeoJSON must be an object"),j.type){case"Feature":return j.geometry==null?null:w(j.geometry,N+1);case"FeatureCollection":return A("a FeatureCollection holds many rows, not one value; load its features as rows");case"Point":return{type:"Point",coordinates:M(j.coordinates)};case"MultiPoint":return{type:"MultiPoint",coordinates:U(j.coordinates,1,"a MultiPoint")};case"LineString":return{type:"LineString",coordinates:U(j.coordinates,2,"a LineString")};case"MultiLineString":return(!Array.isArray(j.coordinates)||!j.coordinates.length)&&A("a MultiLineString needs at least one line"),{type:"MultiLineString",coordinates:j.coordinates.map(W=>U(W,2,"a LineString"))};case"Polygon":return{type:"Polygon",coordinates:O(j.coordinates)};case"MultiPolygon":return(!Array.isArray(j.coordinates)||!j.coordinates.length)&&A("a MultiPolygon needs at least one polygon"),{type:"MultiPolygon",coordinates:j.coordinates.map(O)};case"GeometryCollection":{(!Array.isArray(j.geometries)||!j.geometries.length)&&A("a GeometryCollection needs at least one geometry");const W=j.geometries.map(Q=>w(Q,N+1)).filter(Boolean);return W.length?{type:"GeometryCollection",geometries:W}:null}default:return A(`"${String(j.type)}" is not a GeoJSON geometry type`)}}const i=Object.freeze({POINT:"Point",LINESTRING:"LineString",POLYGON:"Polygon",MULTIPOINT:"MultiPoint",MULTILINESTRING:"MultiLineString",MULTIPOLYGON:"MultiPolygon",GEOMETRYCOLLECTION:"GeometryCollection"}),v=/[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/y,c=/[A-Za-z]+/y,T=/^\s*(?:SRID\s*=\s*\d+\s*;\s*)?[A-Za-z]+\s*(?:ZM|Z|M)?\s*(?:\(|EMPTY\b)/i;class C{text;at=0;constructor(N){this.text=N}space(){for(;this.at<this.text.length&&/\s/.test(this.text[this.at]);)this.at++}expect(N){this.space(),this.text[this.at]!==N&&A(`WKT expected "${N}" at character ${this.at+1}, found "${this.text[this.at]??"the end"}"`),this.at++}accept(N){return this.space(),this.text[this.at]===N?(this.at++,!0):!1}word(){this.space(),c.lastIndex=this.at;const N=c.exec(this.text);return N?(this.at+=N[0].length,N[0].toUpperCase()):""}numberNext(){return this.space(),v.lastIndex=this.at,v.test(this.text)}number(){this.space(),v.lastIndex=this.at;const N=v.exec(this.text);return N||A(`WKT expected a number at character ${this.at+1}`),this.at+=N[0].length,Number(N[0])}position(){const N=this.number(),W=this.number();for(;this.numberNext();)this.number();return[N,W]}positionList(){this.expect("(");const N=[this.position()];for(;this.accept(",");)N.push(this.position());return this.expect(")"),N}empty(){const N=this.at;return this.word()==="EMPTY"?!0:(this.at=N,!1)}geometry(N){N>q&&A("geometry collections nest too deeply");const W=this.word(),Q=i[W];Q||A(W?`"${W}" is not a WKT geometry type`:"WKT expected a geometry type");const ye=this.at,xe=this.word();return xe!=="Z"&&xe!=="M"&&xe!=="ZM"&&(this.at=ye),this.empty()?null:this.body(Q,N)}body(N,W){switch(N){case"Point":{this.expect("(");const Q=this.position();return this.expect(")"),{type:"Point",coordinates:Q}}case"LineString":return{type:"LineString",coordinates:U(this.positionList(),2,"a LineString")};case"Polygon":return{type:"Polygon",coordinates:this.polygonBody()};case"MultiPoint":{this.expect("(");const Q=[];do this.empty()||(this.accept("(")?(Q.push(this.position()),this.expect(")")):Q.push(this.position()));while(this.accept(","));return this.expect(")"),Q.length?{type:"MultiPoint",coordinates:Q}:null}case"MultiLineString":{const Q=this.parts(()=>U(this.positionList(),2,"a LineString"));return Q.length?{type:"MultiLineString",coordinates:Q}:null}case"MultiPolygon":{const Q=this.parts(()=>this.polygonBody());return Q.length?{type:"MultiPolygon",coordinates:Q}:null}default:{this.expect("(");const Q=[];do{const ye=this.geometry(W+1);ye&&Q.push(ye)}while(this.accept(","));return this.expect(")"),Q.length?{type:"GeometryCollection",geometries:Q}:null}}}parts(N){this.expect("(");const W=[];do this.empty()||W.push(N());while(this.accept(","));return this.expect(")"),W}polygonBody(){return O(this.parts(()=>this.positionList()))}}function b(j){const N=new C(String(j).replace(/^\s*SRID\s*=\s*\d+\s*;/i,"")),W=N.geometry(0);return N.space(),N.at<N.text.length&&A(`WKT has unexpected text after the geometry at character ${N.at+1}`),W}function L(j){return Object.is(j,-0)?"0":String(j)}function G(j){return`${L(j[0])} ${L(j[1])}`}function K(j){return`(${j.map(G).join(", ")})`}function V(j){return`(${j.map(K).join(", ")})`}function he(j){const N=m(j);return N?X(N):""}function X(j){switch(j.type){case"Point":return`POINT (${G(j.coordinates)})`;case"LineString":return`LINESTRING ${K(j.coordinates)}`;case"Polygon":return`POLYGON ${V(j.coordinates)}`;case"MultiPoint":return`MULTIPOINT (${j.coordinates.map(N=>`(${G(N)})`).join(", ")})`;case"MultiLineString":return`MULTILINESTRING (${j.coordinates.map(K).join(", ")})`;case"MultiPolygon":return`MULTIPOLYGON (${j.coordinates.map(V).join(", ")})`;default:return`GEOMETRYCOLLECTION (${j.geometries.map(X).join(", ")})`}}class J{view;at=0;constructor(N){this.view=new DataView(N.buffer,N.byteOffset,N.byteLength)}need(N){this.at+N>this.view.byteLength&&A(`WKB ends after ${this.view.byteLength} bytes, in the middle of a geometry`)}u8(){return this.need(1),this.view.getUint8(this.at++)}u32(N){this.need(4);const W=this.view.getUint32(this.at,N);return this.at+=4,W}f64(N){this.need(8);const W=this.view.getFloat64(this.at,N);return this.at+=8,W}count(N,W){const Q=this.u32(N);return Q*W>this.view.byteLength-this.at&&A(`WKB claims ${Q} elements, more than its bytes can hold`),Q}position(N,W){const Q=this.f64(N),ye=this.f64(N);for(let xe=2;xe<W;xe++)this.f64(N);return[Q,ye]}positions(N,W){const Q=this.count(N,8*W),ye=new Array(Q);for(let xe=0;xe<Q;xe++)ye[xe]=this.position(N,W);return ye}geometry(N,W){N>q&&A("geometry collections nest too deeply");const Q=this.u8();Q!==0&&Q!==1&&A(`WKB byte-order mark is ${Q}, not 0 or 1`);const ye=Q===1,xe=this.u32(ye);let Se=2;xe&2147483648&&Se++,xe&1073741824&&Se++,xe&536870912&&this.u32(ye);let Oe=xe&268435455;if(Oe>=1e3){const _e=Math.floor(Oe/1e3);_e>3&&A(`WKB geometry type ${Oe} is not one this reads`),Se=2+(_e===3?2:1),Oe%=1e3}const Ce=ne[Oe-1];switch(Ce||A(`WKB geometry type ${Oe} is not one this reads`),W&&Ce!==W&&A(`a part of a WKB Multi${W} is a ${Ce}`),Ce){case"Point":{const _e=this.position(ye,Se);return Number.isNaN(_e[0])&&Number.isNaN(_e[1])?null:{type:"Point",coordinates:M(_e)}}case"LineString":return{type:"LineString",coordinates:U(this.positions(ye,Se),2,"a LineString")};case"Polygon":{const _e=this.count(ye,4),Me=[];for(let ze=0;ze<_e;ze++)Me.push(this.positions(ye,Se));return _e?{type:"Polygon",coordinates:O(Me)}:null}default:{const _e=this.count(ye,5),Me=Ce==="GeometryCollection"?void 0:Ce.slice(5),ze=[];for(let ot=0;ot<_e;ot++){const kt=this.geometry(N+1,Me);kt&&ze.push(kt)}return ze.length?Ce==="GeometryCollection"?{type:Ce,geometries:ze}:{type:Ce,coordinates:ze.map(ot=>ot.coordinates)}:null}}}}function oe(j){const N=new J(j),W=N.geometry(0);return N.at!==j.byteLength&&A(`WKB has ${j.byteLength-N.at} bytes left over after the geometry`),W}function $(j){const N=m(j);if(!N)return null;const W=[];let Q=0;const ye=Me=>{const ze=new DataView(new ArrayBuffer(5));ze.setUint8(0,1),ze.setUint32(1,ne.indexOf(Me)+1,!0),W.push(ze),Q+=5},xe=Me=>{const ze=new DataView(new ArrayBuffer(4));ze.setUint32(0,Me,!0),W.push(ze),Q+=4},Se=Me=>{const ze=new DataView(new ArrayBuffer(16*Me.length));Me.forEach((ot,kt)=>{ze.setFloat64(kt*16,ot[0],!0),ze.setFloat64(kt*16+8,ot[1],!0)}),W.push(ze),Q+=16*Me.length},Oe=Me=>{switch(ye(Me.type),Me.type){case"Point":Se([Me.coordinates]);break;case"LineString":xe(Me.coordinates.length),Se(Me.coordinates);break;case"Polygon":xe(Me.coordinates.length);for(const ze of Me.coordinates)xe(ze.length),Se(ze);break;case"GeometryCollection":xe(Me.geometries.length);for(const ze of Me.geometries)Oe(ze);break;default:{const ze=Me.type.slice(5);xe(Me.coordinates.length);for(const ot of Me.coordinates)Oe({type:ze,coordinates:ot})}}};Oe(N);const Ce=new Uint8Array(Q);let _e=0;for(const Me of W)Ce.set(new Uint8Array(Me.buffer),_e),_e+=Me.byteLength;return Ce}const z=/^0[01](?:[0-9a-fA-F]{2})+$/,y=/^[A-Za-z0-9+/_-]+={0,2}$/,R=(()=>{const j=new Int16Array(128).fill(-1),N="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(let W=0;W<N.length;W++)j[N.charCodeAt(W)]=W;return j[45]=62,j[95]=63,j})();function S(j){const N=new Uint8Array(j.length/2);for(let W=0;W<N.length;W++)N[W]=parseInt(j.slice(W*2,W*2+2),16);return N}function r(j){const N=j.replace(/=+$/,""),W=new Uint8Array(Math.floor(N.length*3/4));let Q=0,ye=0,xe=0;for(let Se=0;Se<N.length;Se++)ye=ye<<6|R[N.charCodeAt(Se)],Q+=6,Q>=8&&(Q-=8,W[xe++]=ye>>Q&255);return W.subarray(0,xe)}function _(j){const N=j.trim();if(N==="")return null;if(N[0]==="{"){let W;try{W=JSON.parse(N)}catch{return A("the text starts like GeoJSON but is not valid JSON")}return w(W,0)}if(z.test(N))return oe(S(N));if(T.test(N))return b(N);if(y.test(N)){const W=r(N);if(W.length>=5&&(W[0]===0||W[0]===1))return oe(W)}return A("the text is not WKT, GeoJSON, or hex or base64 WKB")}const F=new WeakSet;function D(j){if(ae(j))return{geometry:null,reason:null};if(typeof j=="object"&&F.has(j))return{geometry:j,reason:null};try{let N;return typeof j=="string"?N=_(j):j instanceof Uint8Array?N=oe(j):j instanceof ArrayBuffer?N=oe(new Uint8Array(j)):ArrayBuffer.isView(j)?N=oe(new Uint8Array(j.buffer,j.byteOffset,j.byteLength)):l(j)?N=w(j,0):A(`${Array.isArray(j)?"an array":`a ${typeof j}`} is not a geometry`),N&&x(N),{geometry:N||null,reason:null}}catch(N){if(N instanceof Y)return{geometry:null,reason:N.message};throw N}}function x(j){if(F.add(j),j.type==="GeometryCollection")for(const N of j.geometries)x(N)}function m(j){return D(j).geometry}function e(j,N){switch(j.type){case"Point":N(j.coordinates);break;case"MultiPoint":case"LineString":j.coordinates.forEach(N);break;case"MultiLineString":case"Polygon":for(const W of j.coordinates)W.forEach(N);break;case"MultiPolygon":for(const W of j.coordinates)for(const Q of W)Q.forEach(N);break;default:for(const W of j.geometries)e(W,N)}}function a(j,N){const W=j[1]*ue,Q=N[1]*ue,ye=Q-W,xe=(N[0]-j[0])*ue,Se=Math.sin(ye/2)**2+Math.cos(W)*Math.cos(Q)*Math.sin(xe/2)**2;return 2*ee*Math.asin(Math.min(1,Math.sqrt(Se)))}function s(j){let N=0;for(let W=1;W<j.length;W++)N+=a(j[W-1],j[W]);return N}function k(j){const N=j.length-1;if(N<3)return 0;let W=0;for(let Q=0;Q<N;Q++){const ye=j[(Q-1+N)%N],xe=j[(Q+1)%N];W+=(xe[0]-ye[0])*ue*Math.sin(j[Q][1]*ue)}return Math.abs(W)*ee*ee/2}function t(j){let N=k(j[0]);for(let W=1;W<j.length;W++)N-=k(j[W]);return Math.max(0,N)}function u(j){let N=0,W=0,Q=0;for(let ye=0;ye<j.length-1;ye++){const[xe,Se]=j[ye],[Oe,Ce]=j[ye+1],_e=xe*Ce-Oe*Se;N+=_e,W+=(xe+Oe)*_e,Q+=(Se+Ce)*_e}return{a:N,cx:W,cy:Q}}function f(){let j=0,N=0,W=0;return{add(Q,ye,xe){j+=Q*xe,N+=ye*xe,W+=xe},get(){return W>0?[j/W,N/W]:null}}}function p(j){let N=0,W=0;for(const Q of j)N+=Q[0],W+=Q[1];return[N/j.length,W/j.length]}function o(j,N){switch(j.type){case"Point":N[0].add(j.coordinates[0],j.coordinates[1],1);break;case"MultiPoint":for(const W of j.coordinates)N[0].add(W[0],W[1],1);break;case"LineString":case"MultiLineString":{const W=j.type==="LineString"?[j.coordinates]:j.coordinates;for(const Q of W){for(let ye=1;ye<Q.length;ye++){const[xe,Se]=Q[ye-1],[Oe,Ce]=Q[ye],_e=Math.hypot(Oe-xe,Ce-Se);N[1].add((xe+Oe)/2,(Se+Ce)/2,_e)}for(const ye of Q)N[0].add(ye[0],ye[1],1)}break}case"Polygon":case"MultiPolygon":{const W=j.type==="Polygon"?[j.coordinates]:j.coordinates;for(const Q of W){let ye=0,xe=0,Se=0;Q.forEach((Ce,_e)=>{const Me=u(Ce),ze=(_e===0?1:-1)*(Me.a<0?-1:1);ye+=ze*Me.a,xe+=ze*Me.cx,Se+=ze*Me.cy}),Math.abs(ye)>B&&N[2].add(xe/(3*ye),Se/(3*ye),Math.abs(ye)/2);const Oe=Q[0].slice(0,-1);for(const Ce of Oe)N[0].add(Ce[0],Ce[1],1)}break}default:for(const W of j.geometries)o(W,N)}}const d=new WeakMap;function P(j){const N=m(j);if(!N)return null;const W=d.get(N);if(W)return W;const Q=[1/0,1/0,-1/0,-1/0];e(N,Me=>{Me[0]<Q[0]&&(Q[0]=Me[0]),Me[1]<Q[1]&&(Q[1]=Me[1]),Me[0]>Q[2]&&(Q[2]=Me[0]),Me[1]>Q[3]&&(Q[3]=Me[1])});const ye=[f(),f(),f()];o(N,ye);const xe=ye[2].get()||ye[1].get()||ye[0].get()||p([[Q[0],Q[1]],[Q[2],Q[3]]]);let Se=0,Oe=0;const Ce=Me=>{switch(Me.type){case"LineString":Se+=s(Me.coordinates);break;case"MultiLineString":for(const ze of Me.coordinates)Se+=s(ze);break;case"Polygon":Oe+=t(Me.coordinates);for(const ze of Me.coordinates)Se+=s(ze);break;case"MultiPolygon":for(const ze of Me.coordinates){Oe+=t(ze);for(const ot of ze)Se+=s(ot)}break;case"GeometryCollection":for(const ze of Me.geometries)Ce(ze);break;default:break}};Ce(N);const _e=Object.freeze({kind:N.type,bbox:Object.freeze(Q),centroid:Object.freeze(xe),length:Se,area:Oe});return d.set(N,_e),_e}function E(j){const N=P(j);return N?N.kind:null}function I(j,N){const W=typeof j=="string"?j.split(/[\s,;]+/).filter(Boolean):j;if(!Array.isArray(W)||W.length!==N)return null;const Q=W.map(ye=>typeof ye=="number"?ye:typeof ye=="string"?Number(ye):NaN);return Q.every(Number.isFinite)?Q:null}function te(j,N){if(j==="withinBbox"){const W=I(N,4);return W?W[0]>W[2]?{reason:'the box crosses the antimeridian (its west edge is east of its east edge), which is not supported; split it into two withinBbox conditions joined by "or"'}:W[1]>W[3]?{reason:"the box's minLat is above its maxLat"}:{operand:W}:{reason:"withinBbox needs [minLon, minLat, maxLon, maxLat]"}}if(j==="withinDistance"){let W=null;if(l(N)&&!Array.isArray(N)){const Q=N;W=I([Q.lon,Q.lat,Q.metres],3)}else W=I(N,3);return!W||W[2]<0?{reason:"withinDistance needs { lon, lat, metres } with metres of 0 or more"}:{operand:{lon:W[0],lat:W[1],metres:W[2]}}}if(j==="withinPolygon"||j==="intersects"){const W=j==="intersects"?I(N,4):null;if(W){if(W[0]>W[2]||W[1]>W[3])return{reason:"the box's minimum is above its maximum"};const[xe,Se,Oe,Ce]=W;return{operand:{type:"Polygon",coordinates:[[[xe,Se],[Oe,Se],[Oe,Ce],[xe,Ce],[xe,Se]]]}}}const{geometry:Q,reason:ye}=D(N);return Q?j==="withinPolygon"&&Q.type!=="Polygon"&&Q.type!=="MultiPolygon"?{reason:`withinPolygon needs a Polygon or MultiPolygon, not a ${Q.type}`}:{operand:Q}:{reason:`${j} needs a geometry: ${ye||"none was given"}`}}return{reason:`"${j}" is not a spatial operator`}}function re(j,N){const[W,Q]=j;let ye=!1;for(let xe=0,Se=N.length-2;xe<N.length-1;Se=xe++){const[Oe,Ce]=N[xe],[_e,Me]=N[Se];Ce>Q!=Me>Q&&W<(_e-Oe)*(Q-Ce)/(Me-Ce)+Oe&&(ye=!ye)}return ye}function be(j,N){if(!re(j,N[0]))return!1;for(let W=1;W<N.length;W++)if(re(j,N[W]))return!1;return!0}function Ae(j,N={points:[],segments:[],polygons:[]}){const W=Q=>{for(let ye=1;ye<Q.length;ye++)N.segments.push([Q[ye-1],Q[ye]]);for(const ye of Q)N.points.push(ye)};switch(j.type){case"Point":N.points.push(j.coordinates);break;case"MultiPoint":for(const Q of j.coordinates)N.points.push(Q);break;case"LineString":W(j.coordinates);break;case"MultiLineString":j.coordinates.forEach(W);break;case"Polygon":N.polygons.push(j.coordinates),j.coordinates.forEach(W);break;case"MultiPolygon":for(const Q of j.coordinates)N.polygons.push(Q),Q.forEach(W);break;default:for(const Q of j.geometries)Ae(Q,N)}return N}function Le(j,N,W){const Q=(N[0]-j[0])*(W[1]-j[1])-(N[1]-j[1])*(W[0]-j[0]);return Math.abs(Q)<=B?0:Math.sign(Q)}function Ne(j,N,W){return j[0]>=Math.min(N[0],W[0])-B&&j[0]<=Math.max(N[0],W[0])+B&&j[1]>=Math.min(N[1],W[1])-B&&j[1]<=Math.max(N[1],W[1])+B}function Ie(j,N){const[W,Q]=j,[ye,xe]=N,Se=Le(W,Q,ye),Oe=Le(W,Q,xe),Ce=Le(ye,xe,W),_e=Le(ye,xe,Q);return Se!==Oe&&Ce!==_e?!0:Se===0&&Ne(ye,W,Q)||Oe===0&&Ne(xe,W,Q)||Ce===0&&Ne(W,ye,xe)||_e===0&&Ne(Q,ye,xe)}function Ke(j,N){return j[0]<=N[2]&&N[0]<=j[2]&&j[1]<=N[3]&&N[1]<=j[3]}function Be(j,N){const W=P(j),Q=P(N);if(!Ke(W.bbox,Q.bbox))return!1;const ye=Ae(j),xe=Ae(N);for(const Se of xe.polygons)for(const Oe of ye.points)if(be(Oe,Se))return!0;for(const Se of ye.polygons)for(const Oe of xe.points)if(be(Oe,Se))return!0;for(const Se of ye.segments)for(const Oe of xe.segments)if(Ie(Se,Oe))return!0;for(const Se of ye.points){for(const Oe of xe.points)if(Math.abs(Se[0]-Oe[0])<=B&&Math.abs(Se[1]-Oe[1])<=B)return!0;for(const Oe of xe.segments)if(Le(Oe[0],Oe[1],Se)===0&&Ne(Se,Oe[0],Oe[1]))return!0}for(const Se of xe.points)for(const Oe of ye.segments)if(Le(Oe[0],Oe[1],Se)===0&&Ne(Se,Oe[0],Oe[1]))return!0;return!1}function Re(j,N){const{operand:W,reason:Q}=te(j,N);if(Q)return pe(`filter:geometry:${j}`,`a "${j}" condition was refused: ${Q}. It matches no row rather than guessing.`),()=>!1;switch(j){case"withinBbox":return ye=>{const xe=P(ye);if(!xe)return!1;const Se=xe.bbox;return Se[0]>=W[0]&&Se[1]>=W[1]&&Se[2]<=W[2]&&Se[3]<=W[3]};case"withinPolygon":{const ye=W.type==="Polygon"?[W.coordinates]:W.coordinates,xe=Se=>ye.some(Oe=>be(Se,Oe));return Se=>{const Oe=m(Se);return Oe?Oe.type==="Point"?xe(Oe.coordinates):Oe.type==="MultiPoint"?Oe.coordinates.every(xe):xe(P(Oe).centroid):!1}}case"intersects":return ye=>{const xe=m(ye);return!!xe&&Be(xe,W)};default:{const ye=[W.lon,W.lat];return xe=>{const Se=P(xe);return!!Se&&a(Se.centroid,ye)<=W.metres}}}}}),Ze("packages/core/src/source/filterwire.js",function(n,le){"use strict";Object.defineProperty(n,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"warnWherePageRelative",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"warnWhereNotApplied",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"warnWhereOverThreshold",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"parseRelativeToken",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"resolveRelativeRange",{enumerable:!0,get:function(){return v}}),Object.defineProperty(n,"relativeTokenOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"relativeTokenHelp",{enumerable:!0,get:function(){return T}}),Object.defineProperty(n,"isResolvableRelative",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"resolveRelativeCondition",{enumerable:!0,get:function(){return b}}),Object.defineProperty(n,"isGroup",{enumerable:!0,get:function(){return L}}),Object.defineProperty(n,"forEachCondition",{enumerable:!0,get:function(){return G}}),Object.defineProperty(n,"mapConditions",{enumerable:!0,get:function(){return K}}),Object.defineProperty(n,"normaliseFilterSet",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"buildFilterSet",{enumerable:!0,get:function(){return X}}),Object.defineProperty(n,"wireFilters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(n,"querySignature",{enumerable:!0,get:function(){return oe}});const ae=le("packages/core/src/internal/util.js").warnOnce,l="source.remote.hostFilter",pe="source.where.pageRelative";function ne(y,R){!Array.isArray(y)||!y.length||ae(pe,`filters.where (${y.join(", ")}) runs over the rows the ${R} 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 ke(y){const R=(y||{}).config;!R||!R.hostFilter||ae(l,"config.hostFilter is not sent to a server-delegated source (paged/remote) and is not applied:","filtering only the fetched window would give wrong counts and totals.","Express the filter as a FilterSet condition, or send it through config.context.")}const H="source.where.notApplied";function ee(y,R){ae(`${H}:${y}`,`filters.where("${y}") is registered but the ${R} 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 ue="source.where.overThreshold";function q(y,R,S,r){!Array.isArray(y)||!y.length||ae(`${ue}:${R}`,`filters.where (${y.join(", ")}) is not applied to the ${R} pushdown source:`,S===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${S.toLocaleString()} rows, at or past the whereRowLimit of ${r.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 B=new Map;function Y(y){let R=B.get(y);return R||(R=new Intl.DateTimeFormat("en-US",{timeZone:y,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),B.set(y,R)),R}function A(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function M(y,R){const S=Y(R).formatToParts(new Date(y)),r={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const _ of S)_.type==="year"?r.y=+_.value:_.type==="month"?r.m=+_.value:_.type==="day"?r.d=+_.value:_.type==="hour"?r.h=+_.value%24:_.type==="minute"?r.mi=+_.value:_.type==="second"&&(r.s=+_.value);return r}function U(y,R){const S=M(y,R);return Date.UTC(S.y,S.m-1,S.d,S.h,S.mi,S.s)-Math.floor(y/1e3)*1e3}function g(y,R,S,r){const _=Date.UTC(y,R-1,S),F=_-U(_,r);return _-U(F,r)}function O(y,R,S){const r=new Date(Date.UTC(y.y,y.m-1,y.d+R));return g(r.getUTCFullYear(),r.getUTCMonth()+1,r.getUTCDate(),S)}const w=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function i(y,R){if(typeof y!="string")return null;const S=y.trim().toLowerCase().replace(/[\s_-]+/g,""),r=/^last(\d*|n)days?$/.exec(S);if(r){const _=r[1]==="n"?"":r[1],F=Number(_||R);return!Number.isFinite(F)||F<=0?null:{kind:"lastNDays",n:Math.floor(F)}}switch(S){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 v(y,R={}){const S=i(y,R.n);if(!S)return null;const r=R.tz||A(),_=R.now instanceof Date?R.now.getTime():typeof R.now=="number"?R.now:Date.now(),F=M(_,r),D=g(F.y,F.m,F.d,r),x=O(F,1,r);let m=D,e=x;switch(S.kind){case"today":break;case"yesterday":m=O(F,-1,r),e=D;break;case"lastNDays":e=R.includeToday?x:D,m=O(F,R.includeToday?-(S.n-1):-S.n,r);break;case"thisWeek":{const a=Number.isFinite(R.weekStartsOn)?Number(R.weekStartsOn):1,k=(new Date(Date.UTC(F.y,F.m-1,F.d)).getUTCDay()-a+7)%7;m=O(F,-k,r),e=O(F,-k+7,r);break}case"thisMonth":m=g(F.y,F.m,1,r),e=g(F.m===12?F.y+1:F.y,F.m===12?1:F.m+1,1,r);break;case"thisQuarter":case"quarterToDate":{const a=Math.floor((F.m-1)/3)*3+1;m=g(F.y,a,1,r),e=S.kind==="quarterToDate"?x:a===10?g(F.y+1,1,1,r):g(F.y,a+3,1,r);break}case"thisYear":case"yearToDate":m=g(F.y,1,1,r),e=S.kind==="yearToDate"?x:g(F.y+1,1,1,r);break;default:return null}return{from:new Date(m).toISOString(),to:new Date(e).toISOString(),bounds:"[)",tz:r,relative:S.kind==="lastNDays"?`last${S.n}Days`:S.kind,n:S.n}}function c(y){if(!y||typeof y!="object")return null;const R=y.value;if(R&&typeof R=="object"&&!Array.isArray(R)&&"relative"in R)return{token:String(R.relative),n:typeof R.n=="number"?R.n:void 0};if(y.op==="relative"&&typeof y.value=="string")return{token:y.value,n:void 0};const S=y.meta;return S&&typeof S.relative=="string"&&y.value===void 0?{token:S.relative,n:typeof S.n=="number"?S.n:void 0}:null}function T(){return`Known tokens: ${w.filter(R=>R!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function C(y){const R=c(y);return R?i(R.token,R.n)!==null:!1}function b(y,R={}){const S=c(y);if(!S)return y;const r=v(S.token,{...R,n:S.n});return r?{...y,type:y.type||"date",op:"between",value:[r.from,r.to],bounds:y.bounds||r.bounds,meta:{...y.meta||{},relative:r.relative,tz:r.tz}}:(ae(`source.relative.${S.token}`,`unknown relative date token "${S.token}"; sending the condition unresolved.`,T()),y)}function L(y){return!!y&&typeof y=="object"&&Array.isArray(y.conditions)}function G(y,R){if(y){if(L(y)){for(const S of y.conditions)G(S,R);return}R(y)}}function K(y,R){if(!y)return null;if(!L(y))return R(y);const S=y;let r=!1;const _=[];for(const F of S.conditions){const D=K(F,R);D!==F&&(r=!0),D&&_.push(D)}return!r&&_.length===S.conditions.length?y:_.length?{...S,conditions:_}:null}function V(y){if(!y)return null;if(!L(y))return y;const R=y,S=[];for(const r of R.conditions){const _=V(r);_&&S.push(_)}return S.length?{op:R.op,conditions:S}:null}function he(y){const R=V(y);return R?L(R)&&R.op==="and"?R:{op:"and",conditions:[R]}:null}function X(y){const R=(y||[]).filter(Boolean);return R.length?{op:"and",conditions:R}:null}function J(y,R={}){const S=K(y,r=>b(r,R));return he(S)}function oe(y){const R=$(y.filters??null);return JSON.stringify([R,y.sort??null,y.quick??"",y.groupBy??null,y.pivotBy??null,z(y.context)])}function $(y){if(!y)return null;if(L(y)){const r=y;return{op:r.op,conditions:r.conditions.map($)}}const R=y,S=R.meta&&typeof R.meta.relative=="string"?R.meta.relative:c(R)?.token;return{col:R.col,op:R.op,bounds:R.bounds??null,caseSensitive:R.caseSensitive??!1,value:S?`rel:${S}`:R.value??null}}function z(y){if(y==null)return null;try{return JSON.parse(JSON.stringify(y))}catch{return ae("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Ze("packages/core/src/source/aggregates.js",function(n,le){"use strict";Object.defineProperty(n,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"pushableAggregates",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"fillAggregateSql",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"resolveAggregatesConfig",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"routeAggregate",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"resolveAggregatePlan",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"groupKeysPushable",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"pushdownDocRows",{enumerable:!0,get:function(){return ue}});const ve=Object.freeze({sum:{pushable:!0,class:"identical",sql:"sum(%c)"},avg:{pushable:!0,class:"identical",sql:"avg(%c)"},min:{pushable:!0,class:"identical",sql:"min(%c)"},max:{pushable:!0,class:"identical",sql:"max(%c)"},count:{pushable:!0,class:"identical",sql:"count(*)"},countValues:{pushable:!0,class:"identical",sql:"count(%c)",blankAware:!0},range:{pushable:!0,class:"identical",sql:"(max(%c) - min(%c))"},variance:{pushable:!0,class:"identical",sql:"var_samp(%c)"},varianceP:{pushable:!0,class:"identical",sql:"var_pop(%c)"},stddev:{pushable:!0,class:"identical",sql:"stddev_samp(%c)"},stddevP:{pushable:!0,class:"identical",sql:"stddev_pop(%c)"},sumSquares:{pushable:!0,class:"identical",sql:"sum(%c * %c)"},median:{pushable:!0,class:"identical",sql:"median(%c)"},p25:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.25)"},p75:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.75)"},p90:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.9)"},p95:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.95)"},p99:{pushable:!0,class:"identical",sql:"quantile_cont(%c, 0.99)"},iqr:{pushable:!0,class:"identical",sql:"(quantile_cont(%c, 0.75) - quantile_cont(%c, 0.25))"},mad:{pushable:!0,class:"identical",sql:"mad(%c)"},distinct:{pushable:!0,class:"identical",sql:"count(DISTINCT %c)",blankAware:!0},skewness:{pushable:!0,class:"identical",sql:"skewness(%c)"},kurtosis:{pushable:!0,class:"identical",sql:"kurtosis(%c)"},geomean:{pushable:!0,class:"identical",sql:"exp(avg(ln(%c)))"},harmean:{pushable:!0,class:"identical",sql:"(count(%c) / sum(1.0 / %c))"},entropy:{pushable:!0,class:"identical",sql:"entropy(%c)",blankAware:!0},correlation:{pushable:!0,class:"identical",sql:"corr(%w, %c)",twoColumn:!0},hhi:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_transform(map_values(histogram(%c)), lambda v: (v::DOUBLE/count(%c))*(v::DOUBLE/count(%c)))) END"},evenness:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL WHEN count(DISTINCT %c)<2 THEN 1.0 ELSE entropy(%c)/log2(count(DISTINCT %c)) END"},top3Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,3))::DOUBLE/count(%c) END"},top10Share:{pushable:!0,class:"identical",blankAware:!0,sql:"CASE WHEN count(%c)=0 THEN NULL ELSE list_sum(list_slice(list_sort(map_values(histogram(%c)),'DESC'),1,10))::DOUBLE/count(%c) END"},gini:{pushable:!0,class:"identical",sql:"CASE WHEN list_min(list(%c) FILTER (WHERE isfinite(%c)))<0 THEN NULL WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL WHEN list_sum(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN 0 ELSE 2.0*list_sum(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v, i: i*v))/(len(list(%c) FILTER (WHERE isfinite(%c)))*list_sum(list(%c) FILTER (WHERE isfinite(%c))))-(len(list(%c) FILTER (WHERE isfinite(%c)))+1.0)/len(list(%c) FILTER (WHERE isfinite(%c))) END"},trimmedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_slice(list_sort(list(%c) FILTER (WHERE isfinite(%c))), floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1, len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT)) END"},winsorizedMean:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))=0 THEN NULL ELSE list_avg(list_transform(list_sort(list(%c) FILTER (WHERE isfinite(%c))), lambda v: least(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[len(list(%c) FILTER (WHERE isfinite(%c)))-floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT], greatest(list_sort(list(%c) FILTER (WHERE isfinite(%c)))[floor(len(list(%c) FILTER (WHERE isfinite(%c)))*0.1)::BIGINT+1], v)))) END"},robustOutliers:{pushable:!0,class:"identical",sql:"(SELECT CASE WHEN len(d.a)=0 THEN NULL WHEN d.mad=0 THEN NULL ELSE len(list_filter(d.a, lambda v: abs(0.6745*(v-d.med)/d.mad)>3.5)) END FROM (SELECT xs AS a, list_median(xs) AS med, list_median(list_transform(xs, lambda w: abs(w-list_median(xs)))) AS mad FROM (SELECT list(%c) FILTER (WHERE isfinite(%c)) AS xs)) d)"},jarqueBera:{pushable:!0,class:"identical",sql:"CASE WHEN len(list(%c) FILTER (WHERE isfinite(%c)))<8 THEN NULL WHEN list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2)))=0 THEN NULL ELSE (len(list(%c) FILTER (WHERE isfinite(%c)))/6.0)*(power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),3)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),1.5),2)+power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),4)))/power(list_avg(list_transform(list(%c) FILTER (WHERE isfinite(%c)), lambda v: power(v-list_avg(list(%c) FILTER (WHERE isfinite(%c))),2))),2)-3,2)/4.0) END"},weightedAvg:{pushable:!0,class:"identical",twoColumn:!0,sql:"sum(%c*%w) FILTER (WHERE isfinite(%c) AND isfinite(%w))/nullif(sum(%w) FILTER (WHERE isfinite(%c) AND isfinite(%w)),0)"},mode:{pushable:!0,class:"may-differ",sql:"mode(%c)",note:"DuckDB returns a modal value even for an all-distinct column; the grid returns null. Tie-breaking can also differ, and on a text column an empty string counts as a value. Under pushdown you will see a value."},weightedQuantile:{pushable:!1,class:"fallback",note:"No SQL equivalent for the grid's weighted-quantile midpoint convention; always computed client-side (needs a full-dataset pull for a correct figure over a remote source)."}});function ae(){const q=new Set;for(const[B,Y]of Object.entries(ve))Y.pushable&&q.add(B);return q}function l(q,B,Y){let A=q.split("%c").join(B);return Y!==void 0&&(A=A.split("%w").join(Y)),A}function pe(q){const B=q||{},Y=B.default==="engine"||B.default==="engine-if-identical"?B.default:"client",A={};if(B.overrides&&typeof B.overrides=="object")for(const[M,U]of Object.entries(B.overrides))(U==="engine"||U==="client")&&(A[M]=U);return{default:Y,overrides:A}}function ne(q,B){const Y=ve[q];if(!Y||!Y.pushable)return"client";const A=B.overrides[q];return A==="engine"||A==="client"?A:B.default==="client"?"client":B.default==="engine-if-identical"?Y.class==="identical"?"engine":"client":"engine"}function ke(q,B){const Y=pe(B),A=[],M=[];for(const U of q||[]){const g=ve[U.fn],O=ne(U.fn,Y),w={id:U.id,col:U.col,fn:U.fn,class:g?g.class:"fallback"};U.weight!==void 0&&(w.weight=U.weight),U.params!==void 0&&(w.params=U.params),O==="engine"?A.push(w):(w.reason=g&&!g.pushable?g.note||"the engine cannot express this stat":"client by config",M.push(w))}return{engine:A,client:M,config:Y}}const H=/^[A-Za-z_][A-Za-z0-9_$]*$/;function ee(q,B=[]){return(q||[]).every(A=>{if(typeof A=="string")return H.test(A);if(!A||typeof A!="object")return!1;const M=A;return Array.isArray(B)&&B.includes(M.bucket)&&typeof M.col=="string"&&H.test(M.col)&&typeof M.size=="number"&&Number.isFinite(M.size)&&M.size>0})}function ue(){return Object.entries(ve).map(([q,B])=>({stat:q,class:B.class,sql:B.sql?l(B.sql,"col",B.twoColumn?"weight":void 0):"",note:B.note||(B.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Ze("packages/core/src/source/abort.js",function(n,le){"use strict";Object.defineProperty(n,"SupersededError",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"RequestToken",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"AbortScope",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"createAbortScope",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"isAbortError",{enumerable:!0,get:function(){return ne}});class ve extends Error{constructor(H,ee="superseded"){super(`[lattice] request ${H?`"${H}" `:""}${ee}`),this.name="SupersededError",this.superseded=!0,this.key=H}}class ae{#e;constructor(H,ee,ue,q){this.#e=H,this.key=ee,this.controller=ue,this.signal=ue.signal,this.seq=q}get current(){return!this.signal.aborted&&this.#e.tokenFor(this.key)===this}settle(){this.#e.settle(this)}abort(H){this.signal.aborted||this.controller.abort(new ve(this.key,H)),this.#e.settle(this)}}class l{#e=new Map;#t=0;begin(H="",ee="superseded"){const ue=this.#e.get(H);ue&&!ue.signal.aborted&&ue.controller.abort(new ve(H,ee));const q=new ae(this,H,new AbortController,++this.#t);return this.#e.set(H,q),q}tokenFor(H){return this.#e.get(H)}pending(H=""){const ee=this.#e.get(H);return!!ee&&!ee.signal.aborted}get size(){return this.#e.size}settle(H){this.#e.get(H.key)===H&&this.#e.delete(H.key)}abort(H="",ee="superseded"){const ue=this.#e.get(H);ue&&ue.abort(ee)}abortAll(H="superseded"){for(const ee of[...this.#e.values()])ee.abort(H);this.#e.clear()}}function pe(){return new l}function ne(ke){if(!ke||typeof ke!="object")return!1;const H=ke;return H.superseded===!0||H.name==="AbortError"||H.name==="SupersededError"}}),Ze("packages/core/src/source/pushdown.js",function(n,le){"use strict";Object.defineProperty(n,"NO_CAPABILITIES",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"resolveMutate",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"capabilitiesOf",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"splitFilters",{enumerable:!0,get:function(){return C}}),Object.defineProperty(n,"LEAF_COUNT_ID",{enumerable:!0,get:function(){return b}}),Object.defineProperty(n,"PIVOT_UNSUPPORTED",{enumerable:!0,get:function(){return V}}),Object.defineProperty(n,"GROUP_UNSUPPORTED",{enumerable:!0,get:function(){return he}}),Object.defineProperty(n,"UNGROUPED_LEVEL",{enumerable:!0,get:function(){return X}}),Object.defineProperty(n,"planQuery",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(n,"applyResidual",{enumerable:!0,get:function(){return y}}),Object.defineProperty(n,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return _}}),Object.defineProperty(n,"createPushdownSource",{enumerable:!0,get:function(){return m}});const ve=le("packages/core/src/internal/util.js"),ae=ve.defaultCompare,l=ve.isFunction,pe=ve.toArray,ne=ve.warnOnce,ke=le("packages/core/src/source/filterwire.js"),H=ke.isGroup,ee=ke.warnWherePageRelative,ue=ke.warnWhereOverThreshold,q=le("packages/core/src/source/aggregates.js"),B=q.resolveAggregatePlan,Y=q.groupKeysPushable,A=q.STAT_PUSHDOWN,U=le("packages/core/src/source/abort.js").SupersededError;function g(e){const a=e&&e.signal;if(!a||!a.aborted)return;const s=a.reason;throw s instanceof Error?s:new U("","superseded before it was sent")}const O=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,pivot:!1,mutate:!1});function w(e){if(!e||typeof e!="object")return!1;const a=e.returning==="row"||e.returning==="key"?e.returning:"none";return{append:e.append===!0,update:e.update===!0,delete:e.delete===!0,returning:a}}function i(e,a){if(!e||typeof a!="string")return;if(!a.includes("."))return e[a];let s=e;for(const k of a.split(".")){if(s===null||typeof s!="object")return;s=s[k]}return s}function v(e){if(e===!0)return!0;if(!e||typeof e!="object")return!1;const a=e;return a.enabled===!1?!1:a.enabled===!0||l(a.commit)}function c(e){const a={...O,...e||{}};return a.operators=new Set(a.operators||[]),a.mutate=w(a.mutate),a}function T(e,a){return!e||!e.op||!a.operators.size?!1:a.operators.has(e.op)}function C(e,a){if(!e)return{pushed:null,residual:null};if(!a.filter)return{pushed:null,residual:e};if(a.filter==="term"){if(H(e)){const u=e.conditions||[];if(String(e.op)!=="and")return{pushed:null,residual:e};const f=u.findIndex(o=>!H(o)&&T(o,a));if(f<0)return{pushed:null,residual:e};const p=u.filter((o,d)=>d!==f);return{pushed:u[f],residual:p.length?{op:"and",conditions:p}:null}}return T(e,a)?{pushed:e,residual:null}:{pushed:null,residual:e}}if(!H(e))return T(e,a)?{pushed:e,residual:null}:{pushed:null,residual:e};if(String(e.op)!=="and")return(e.conditions||[]).every(f=>H(f)?C(f,a).residual===null:T(f,a))?{pushed:e,residual:null}:{pushed:null,residual:e};const s=[],k=[];for(const u of e.conditions||[]){if(H(u)){if(a.filter==="flat"){k.push(u);continue}const f=C(u,a);f.pushed&&s.push(f.pushed),f.residual&&k.push(f.residual);continue}(T(u,a)?s:k).push(u)}const t=u=>u.length===0?null:u.length===1?u[0]:{op:"and",conditions:u};return{pushed:t(s),residual:t(k)}}const b="__lattice_leaves";function L(e){return e.aggregates?e.aggregates instanceof Set?e.aggregates:new Set(pe(e.aggregates)):new Set}function G(e){const a=L(e);return a.size?a.has("count")?e.filter!=="tree"||!e.operators||!e.operators.has("eq")?"the adapter does not declare the `group` capability, and cannot narrow a group's rows by its key (that needs a `tree` filter with the `eq` operator)":"":"the adapter does not declare the `group` capability, and its declared aggregates have no `count` to give each group its row count":"the adapter does not declare the `group` capability"}function K(e,a,s,k,t,u,f){const p=Array.isArray(e.groupBy)?e.groupBy:[],o=Array.isArray(e.groupPath)?e.groupPath:[],d=Array.isArray(e.groupValues)?e.groupValues:null;if(!a.group){const P=G(a);if(P)return P}return Y(p)?s.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":k?t?u?"a host `where` predicate can only run in the browser, over rows the engine grouped":f?"fullDataset holds the whole matching set, so the grid groups it itself":!d||d.length!==o.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would group unsearched rows":"the sort did not push, so the engine would order the groups differently":"a grouping key is not a plain column the engine can name in a GROUP BY"}const V="pushdown:pivot-unsupported",he="pushdown:group-unsupported",X=Symbol("lattice.remote.ungroupedLevel");function J(e,a,s,k,t,u){const f=Array.isArray(e.pivotBy)?e.pivotBy:[],p=Array.isArray(e.groupBy)?e.groupBy:[],o=Array.isArray(e.groupPath)?e.groupPath:[],d=Array.isArray(e.groupValues)?e.groupValues:null;return a.pivot?Y(f)?p.length&&!Y(p)?"a grouping key is not a plain column the engine can name in a GROUP BY":s.residual?"the filter did not fully push, so the engine would pivot a superset of the matching rows":k?t?u?"a host `where` predicate can only run in the browser, over rows the engine pivoted":!d||d.length!==o.length?"the request carries no typed `groupValues` for its group path, and the string `groupPath` cannot be compared against a typed column":"":"a quick search did not push, so the engine would pivot unsearched rows":"the sort did not push, so the engine would order the rows differently":"a pivot column is not a plain column the engine can name in a GROUP BY":"the adapter does not declare the `pivot` capability"}function oe(e,a,s=!1){const k=C(e.filters||null,a),t=[];k.residual&&t.push("filter");const u=e.sort||[],f=u.length===0||a.sort==="multi"&&u.length>=1||a.sort==="single"&&u.length===1;!f&&u.length&&t.push("sort");const p=e.quick?String(e.quick):"",o=!p||!!a.quick;o||t.push("quick");const d=e.where&&e.where.active?e.where:null;d&&t.push("where");const P={filters:k.residual,sort:f?null:u,quick:o?"":p,where:d},E=!!s,I=Array.isArray(e.groupBy)&&e.groupBy.length>0,te=I?K(e,a,k,f,o,d,E):"",re=e.pivotMode!==!1&&Array.isArray(e.pivotBy)&&e.pivotBy.length>0,be=re?J(e,a,k,f,o,d):"",Ae=re&&be==="";re&&!Ae&&t.push("pivot");const Le=re?Ae&&I:I&&te==="";I&&!re&&!Le&&t.push("group");const Ne=(Le||Ae)&&Array.isArray(e.groupValues)?e.groupValues.length:0,Ie=Le||re?!1:E||!!(P.filters||P.sort||P.quick||P.where)||!a.range;return{pushed:{...e,filters:k.pushed,sort:f?u:[],quick:o?p:"",range:Ie?null:e.range},residual:P,needsAll:Ie,unpushed:t,full:E,grouped:Le,groupLevel:Ne,groupReason:re?"":te,pivoted:Ae,pivotReason:be}}function $(e){const a=Array.isArray(e.totals)?e.totals:[],s=e.totalFns&&typeof e.totalFns=="object"?e.totalFns:{},k=[],t=[];for(const u of a){const f=String(u),p=typeof s[f]=="string"?s[f]:null,o=p?A[p]:null;p?!o||!o.pushable||!o.sql?t.push({id:f,fn:p,class:o?o.class:"fallback",reason:o&&o.note?o.note:`the pushdown map cannot express "${p}"`}):o.twoColumn?t.push({id:f,fn:p,class:o.class,reason:`"${p}" reduces two columns, and a grouped request carries no weight column`}):k.push({id:f,col:f,fn:p,class:o.class}):t.push({id:f,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:k,client:t}}const z=Object.freeze({items:e=>e==null?[]:Array.isArray(e)?e:[e]});function y(e,a,s){if(!a)return e;let k=e;if(a.filters&&l(s.evaluateFilters)){const t=k,u={count:k.length,handle:o=>({id:o,get:d=>i(t[d],o)}),itemwise:o=>t.some(d=>Array.isArray(i(d,o)))?z:null},f=s.evaluateFilters(a.filters,u),p=[];for(let o=0;o<k.length;o++)f[o]&&p.push(k[o]);k=p}if(a.where&&a.where.active&&(a.whole||ee(a.where.names,"pushdown"),k=k.filter(t=>a.where.passes(t))),a.quick){const t=a.quick.toLowerCase();k=k.filter(u=>{if(!u||typeof u!="object")return!1;for(const f of Object.values(u))if(f!=null&&String(f).toLowerCase().includes(t))return!0;return!1})}if(a.sort&&a.sort.length&&l(s.sortMulti)){const t=[...new Set(a.sort.map(o=>o.col))],u=k,f=t.map(o=>({id:o,get:d=>i(u[d],o)})),p=s.sortMulti(f,a.sort.map(o=>({col:o.col,dir:o.dir})),Uint32Array.from({length:k.length},(o,d)=>d),{});k=Array.from(p,o=>u[o])}return k}function R(e){return JSON.stringify({filters:e.filters||null,sort:e.sort||[],quick:e.quick||"",groupBy:e.groupBy||[],groupPath:e.groupPath||[],context:e.context??null})}function S(e){if(!e||typeof e!="object")return 16;let a="";try{a=JSON.stringify(e)}catch{return 200}return a.length*2+64}function r(e){const a=e||{};return{enabled:!!a.enabled,maxRows:Number.isFinite(a.maxRows)?a.maxRows:1e6,maxBytesEstimate:Number.isFinite(a.maxBytesEstimate)?a.maxBytesEstimate:512*1024*1024}}const _=5e4;function F(e){return Number.isFinite(e)&&e>=0?e:_}function D(e){return!!e&&l(e.then)}async function x(e){if(!e||e.total!==void 0||!D(e.pendingTotal))return e;const a=await e.pendingTotal,{pendingTotal:s,...k}=e;return typeof a=="number"?{...k,total:a}:k}function m(e={}){const a=e.adapter;if(!a||!l(a.execute))return ne("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...e,mode:"remote",fetch:async()=>({rows:[],total:0})};const s=c(a.capabilities),k=a.capabilities&&Object.getOwnPropertyDescriptor(a.capabilities,"operators");k&&l(k.get)&&Object.defineProperty(s,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(a.capabilities.operators||[]),set:()=>{}});const t=a.name||"adapter";let u=null;const f=()=>l(a.ready)?(u||(u=Promise.resolve(a.ready()).then(()=>{Object.assign(s,c(a.capabilities))},je=>{throw u=null,je})),u):null,p=r(e.fullDataset),o=!!e.allowPartialResults,d=F(e.whereRowLimit);let P=null;const E=e.aggregates;let I=null,te=null,re=null,be=null,Ae=null,Le,Ne=null,Ie=0,Ke=null;const Be=()=>!p.enabled||!I?null:(Ke!==I.key&&(Ie++,Ke=I.key),{rows:I.rows,version:Ie}),Re=async je=>{const Te=je.where&&je.where.active?je.where:null;if(!Te)return{request:je,probe:null};const{where:He,...De}=je,$e=oe(De,s,p.enabled);if($e.needsAll)return{request:je,probe:null};const Ye=R($e.pushed);let Xe=null;return(!P||P.key!==Ye)&&(s.total?(g(je),Xe=await x(await a.execute($e.pushed,je)),P={key:Ye,size:Xe&&typeof Xe.total=="number"?Xe.total:null}):P={key:Ye,size:null}),P.size!==null&&P.size<d?{request:je,probe:null}:(ue(Te.names,t,P.size,d),{request:De,probe:Xe})},j=async(je,Te)=>{Ne=null;const He=$(je.pushed);re={engine:He.engine,client:He.client,groupBy:je.pushed.groupBy},He.client.length&&ne(`source.pushdown.group.totals.${t}.${He.client.map(Ye=>Ye.id).join(".")}`,`the ${t} adapter cannot compute the group subtotal for ${He.client.map(Ye=>`"${Ye.id}" (${Ye.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const De=await a.executeGroupLevel(je.pushed,He.engine,Te)||{};let $e=De.rows||[];return!s.range&&Te.range&&($e=$e.slice(Te.range.start,Te.range.end)),ye(De),De.total===void 0?{rows:$e}:{rows:$e,total:De.total}},N=new Map,W=64,Q=async(je,Te)=>{Ne=null;const He=je.pushed,De=He.groupBy,$e=Array.isArray(He.groupValues)?He.groupValues:[],Ye=$e.length,Xe=[...He.filters?[He.filters]:[],...De.slice(0,Ye).map((de,ge)=>({col:de,op:"eq",value:$e[ge]===void 0?null:$e[ge],caseSensitive:!0}))],lt=Xe.length===0?null:Xe.length===1?Xe[0]:{op:"and",conditions:Xe},ft=Te.range?Te.range.start:0;if(Ye>=De.length){const de={...He,filters:lt,groupBy:[],groupPath:[],groupValues:[],totals:[],totalFns:{}},ge=await x(await a.execute(de,Te))||{};let we=ge.rows||[];return!s.range&&Te.range&&(we=we.slice(Te.range.start,Te.range.end)),typeof ge.total=="number"?{rows:we,total:ge.total}:{rows:we}}const qe=De[Ye],dt=$(He),yt=L(s),vt=dt.engine.filter(de=>yt.has(de.fn)),bt=[...dt.engine.filter(de=>!yt.has(de.fn)).map(de=>({id:de.id,fn:de.fn,class:de.class,reason:`the ${t} adapter does not compute "${de.fn}"`})),...dt.client];re={engine:vt,client:bt,groupBy:De},bt.length&&ne(`source.pushdown.group.totals.${t}.${bt.map(de=>de.id).join(".")}`,`the ${t} adapter cannot compute the group subtotal for ${bt.map(de=>`"${de.id}" (${de.reason})`).join(", ")}, so those group rows carry no value for that column. A figure computed over anything other than the group would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const Je=[...vt.map(de=>({id:de.id,col:de.col,fn:de.fn})),{id:b,col:qe,fn:"count"}],tt={...He,filters:lt,range:null},it=JSON.stringify([R(tt),$e,qe,Je]);let h=ft>0?N.get(it):void 0;if(!h){for(h=Promise.resolve(a.executeGroupedAggregates(tt,[qe],Je)),N.delete(it),N.set(it,h);N.size>W;)N.delete(N.keys().next().value);h.catch(()=>{N.get(it)===h&&N.delete(it)})}const se=await h||[];g(Te);const Z=de=>{const ge={};for(const we of vt)ge[we.id]=de?de[we.id]:void 0;return ge},ie=(He.sort||[]).find(de=>de&&de.col===qe),ce=ie&&ie.dir==="desc"?-1:1,fe=se.filter(de=>de&&de.level===1).map(de=>({[qe]:de.keys[0]===void 0?null:de.keys[0],leafCount:Number(de.values&&de.values[b])||0,totals:Z(de.values)})).sort((de,ge)=>ce*ae(de[qe],ge[qe]));if(Ye===0){const de=se.find(we=>we&&we.level===0),ge=de?Number(de.values&&de.values[b]):NaN;ye({matchCount:Number.isFinite(ge)?ge:fe.reduce((we,Pe)=>we+Pe.leafCount,0),...de?{grand:Z(de.values)}:{}})}const me=Te.range?Te.range.end:fe.length;return{rows:fe.slice(ft,me),total:fe.length}},ye=je=>{typeof je.matchCount=="number"&&(be=je.matchCount,Ae=je.grand?{totals:je.grand,leafCount:je.matchCount}:null,Le===void 0&&l(a.unfilteredCount)&&(Le=null,Promise.resolve(a.unfilteredCount()).then(Te=>{Le=typeof Te=="number"?Te:null}).catch(Te=>{ne(`source.pushdown.group.unfiltered.${t}`,`the ${t} adapter could not count the unfiltered set (${Te&&Te.message?Te.message:Te}), so "N of M" falls back to the display count for its denominator.`)})))},xe=async(je,Te)=>{Ne=null;const He=$(je.pushed);re={engine:He.engine,client:He.client,groupBy:je.pushed.groupBy,pivotBy:je.pushed.pivotBy},He.client.length&&ne(`source.pushdown.pivot.totals.${t}.${He.client.map(lt=>lt.id).join(".")}`,`the ${t} adapter cannot compute the pivot cells for ${He.client.map(lt=>`"${lt.id}" (${lt.reason})`).join(", ")}, so those cells are empty. A figure computed over anything other than the cell would be wrong, so none is shown; \`lastPlan().aggregates.client\` names them.`);const De=await a.executePivotLevel(je.pushed,He.engine,Te)||{};let $e=De.rows||[];!s.range&&Te.range&&($e=$e.slice(Te.range.start,Te.range.end)),ye(De);const Ye=De.pivot&&typeof De.pivot=="object"?De.pivot:{},Xe={cells:Array.isArray(Ye.cells)?Ye.cells:[],...Array.isArray(Ye.axis)?{axis:Ye.axis}:{}};return De.total===void 0?{rows:$e,pivot:Xe}:{rows:$e,total:De.total,pivot:Xe}},Se=je=>{ne(`source.pushdown.pivot.${t}.${je}`,`pushdown:pivot-unsupported: the ${t} adapter cannot pivot this query because ${je}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);const Te=new Error(`[lattice] ${V}: the ${t} adapter cannot pivot this query because ${je}, so no rows are fetched rather than every leaf row being pulled into the browser to pivot there. \`lastPlan().pivotReason\` says the same.`);throw Te.code=V,Te.reason=je,Te},Oe=(je,Te)=>{const He={key:Te,state:"pending",value:null};return Ne=He,je.then(De=>(Ne===He&&(Ne={key:Te,state:"settled",value:typeof De=="number"?De:null}),De),De=>{throw Ne===He&&(Ne={key:Te,state:"failed",value:null}),De})},Ce=async je=>{const Te=f();Te&&await Te;const De=je&&je.pivotMode!==!1&&Array.isArray(je.pivotBy)&&je.pivotBy.length>0?{request:je,probe:null}:await Re(je);g(je);let $e=oe(De.request,s,p.enabled);if(s.group&&$e.grouped&&!$e.pivoted&&!l(a.executeGroupLevel)&&(ne(`source.pushdown.group.method.${t}`,`the ${t} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid stays ungrouped unless it holds the whole matching set. Implement the method or drop the capability.`),$e=oe(De.request,{...s,group:!1,aggregates:null},p.enabled)),$e.pivoted&&!l(a.executePivotLevel)&&($e=oe(De.request,{...s,pivot:!1},p.enabled),$e.pivotReason="the adapter declares the `pivot` capability but has no `executePivotLevel(query, aggregates, request)`"),$e.grouped&&!$e.pivoted&&!s.group&&!l(a.executeGroupedAggregates)&&(ne(`source.pushdown.group.aggregates.method.${t}`,`the ${t} adapter declares \`aggregates\` but has no \`executeGroupedAggregates(query, groupBy, aggregates)\`, so the grouped view cannot be built from grouped aggregates and the grid stays ungrouped unless it holds the whole matching set. Implement the method, or declare \`group\` and implement \`executeGroupLevel\`.`),$e=oe(De.request,{...s,aggregates:null},p.enabled)),te=$e,$e.pivoted)return xe($e,je);if($e.pivotReason&&Se($e.pivotReason),$e.grouped)return s.group?j($e,je):Q($e,je);const Xe=!!$e.groupReason&&!$e.full;Xe?ne(`source.pushdown.group-unsupported.${t}.${$e.groupReason}`,`pushdown:group-unsupported: the ${t} adapter was not asked to group this query because ${$e.groupReason}, so the grid stays ungrouped rather than building group rows, counts and subtotals from a window of leaf rows. \`lastPlan().groupReason\` says the same.`):$e.groupReason&&ne(`source.pushdown.group.${t}.${$e.groupReason}`,`the ${t} adapter was not asked to group this query because ${$e.groupReason}. The engine returns rows and the grouping is the grid's to do, which needs every matching row in the browser — correct where the grid holds them, and wrong-looking where it holds a window. \`lastPlan().unpushed\` names it.`);const lt=Je=>Xe?{...Je,[X]:!0}:Je;if(!$e.needsAll){const Je=De.probe||await a.execute($e.pushed,je),tt=Je.rows||[];return D(Je.pendingTotal)&&Je.total===void 0?lt({rows:tt,pendingTotal:Oe(Je.pendingTotal,R($e.pushed))}):(Ne=null,!s.total&&Je.total===void 0?lt({rows:tt}):lt({rows:tt,total:Je.total??tt.length}))}$e.unpushed.length&&ne(`source.pushdown.residual.${t}.${$e.unpushed.join(".")}`,`the ${t} adapter cannot push ${$e.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ft=R($e.pushed);if(!I||I.key!==ft){const Je=await x(await a.execute($e.pushed,je));Ne=null;const tt=Je.rows||[];if($e.full){const it=typeof Je.total=="number"?Math.max(Je.total,tt.length):tt.length;if(it>p.maxRows)throw new Error(`[lattice] fullDataset refused: the ${t} adapter's matching set is ${it.toLocaleString()} rows, past the configured maxRows of ${p.maxRows.toLocaleString()}. The whole set cannot be held client-side, so it is refused rather than truncated — a fraction shown as the whole would make every total and statistic silently wrong. Narrow the filter or raise maxRows.`);const h=tt.length*S(tt[0]);if(h>p.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${t} adapter's matching set is an estimated ${Math.round(h/(1024*1024)).toLocaleString()} MB across ${tt.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(p.maxBytesEstimate/(1024*1024)).toLocaleString()} MB. The whole set cannot be held client-side, so it is refused rather than truncated. Narrow the filter or raise maxBytesEstimate.`)}if(typeof Je.total=="number"&&tt.length<Je.total){const it=!!($e.residual.filters||$e.residual.quick||$e.residual.sort&&$e.residual.sort.length);if(it&&!o)throw new Error(`[lattice] the ${t} adapter returned ${tt.length} of ${Je.total} matching rows when asked for the whole result, and the query has residual ${$e.unpushed.join(" and ")||"work"} to finish in the browser. Filtering or sorting a fraction of the result would return wrong rows, so the result is refused. Fix the adapter to follow the engine's own paging before returning, hold the data in memory, or set \`allowPartialResults: true\` on the source config to accept this knowingly.`);it?ne(`source.pushdown.partial.residual.${t}`,`the ${t} adapter returned ${tt.length} of ${Je.total} matching rows when asked for the whole result, and residual work will run over that fraction. allowPartialResults is set, so the result is used as-is — it may be wrong. The adapter must follow the engine's own paging to be correct.`):ne(`source.pushdown.partial.${t}`,`the ${t} adapter returned ${tt.length} of ${Je.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}I={key:ft,rows:tt,total:typeof Je.total=="number"?Je.total:null}}let qe=$e;if($e.residual.where){const Je=I.total??I.rows.length;if(Je>=d){ue($e.residual.where.names,t,Je,d);const{where:tt,...it}=De.request;qe=oe(it,s,p.enabled),te=qe}}const dt=I.total!==null&&I.rows.length>=I.total,yt=y(I.rows,{...qe.residual,whole:dt},e.compute||{}),vt=je.range?je.range.start:0,bt=je.range?je.range.end:yt.length;return lt({rows:yt.slice(vt,bt),total:yt.length})},_e=async(je,Te)=>{const He=f();He&&await He;const De=oe(je,s,p.enabled);te=De;const $e=B(Te,E),Ye=Array.isArray(je.groupBy)?je.groupBy:[],Xe=Ye.length>0,lt=!De.residual.filters&&!De.residual.quick,ft=!Xe||Y(Ye,s.buckets);let qe=$e.engine,dt=$e.client;if(s.aggregates&&qe.length){const Je=s.aggregates instanceof Set?s.aggregates:new Set(pe(s.aggregates)),tt=qe.filter(it=>!Je.has(it.fn));tt.length&&(qe=qe.filter(it=>Je.has(it.fn)),dt=[...tt.map(it=>({...it,reason:`the ${t} adapter does not compute "${it.fn}"`})),...dt])}const yt=Je=>{dt=[...qe.map(tt=>({...tt,reason:Je})),...dt],qe=[]};qe.length&&!lt?yt(De.residual.quick&&!De.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):qe.length&&!ft&&yt("a grouping key the engine cannot form forces all-client (no mixed provenance)");let vt={},bt;return qe.length&&(l(Xe?a.executeGroupedAggregates:a.executeAggregates)?Xe?bt=await a.executeGroupedAggregates(De.pushed,Ye,qe)||[]:vt=await a.executeAggregates(De.pushed,qe)||{}:(ne(`source.pushdown.aggregates.${t}${Xe?".grouped":""}`,`the ${t} adapter cannot compute ${Xe?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),yt(`adapter cannot compute ${Xe?"grouped ":""}aggregates`))),re={engine:qe,client:dt,...Xe?{groupBy:Ye}:{}},{values:vt,engine:qe,client:dt,...bt!==void 0?{groups:bt}:{}}},Me=v(e.edit),ze=e.edit&&typeof e.edit=="object"&&l(e.edit.commit);let ot=e.edit;if(Me&&!ze)if(s.mutate&&s.mutate.update){const je=Te=>{if(!s.mutate||!s.mutate.update)throw new Error(`[lattice] the ${t} adapter cannot update rows (mutate.update is not declared), so this edit cannot be persisted. The cell is reverted rather than left looking saved.`);const He={kind:"update",key:String(Te.key),patch:{[Te.colId]:Te.value}};return a.mutate(He,Te.request||{})};ot={...e.edit===!0?{}:e.edit,commit:je}}else ne(`source.pushdown.readonly.${t}`,`edit is enabled but the ${t} adapter declares mutate: ${s.mutate?"without update":"false"} (read-only by declaration), so no commit is synthesised and the grid stays read-only. Declare \`mutate: { update: true }\` on the adapter to allow cell edits.`);const kt=Me&&s.mutate&&(s.mutate.append||s.mutate.delete)?{append:s.mutate.append===!0,remove:s.mutate.delete===!0,returning:s.mutate.returning,mutate:(je,Te)=>a.mutate(je,Te||{})}:null,Nt=async je=>{const Te=f();Te&&await Te;const{range:He,signal:De,export:$e,...Ye}=je||{},Xe={...Ye,groupBy:[],groupPath:[],groupValues:[],pivotBy:[],pivotMode:!1,totals:[]};return{plan:oe(Xe,s,p.enabled),signal:De}};async function*Et(je,Te={}){const{plan:He,signal:De}=await Nt(je),$e=Math.max(1,Math.floor(Number(Te.pageSize))||5e3),Ye={signal:De,stream:!0};if(!He.needsAll)for(let ft=0;;ft+=$e){g(Ye);const qe=await a.execute({...He.pushed,range:{start:ft,end:ft+$e}},Ye);qe&&D(qe.pendingTotal)&&qe.pendingTotal.then(null,()=>{});const dt=qe&&qe.rows||[];if(dt.length&&(yield dt),dt.length<$e)return}g(Ye);const Xe=await x(await a.execute({...He.pushed,range:void 0},Ye)),lt=y(Xe&&Xe.rows||[],{...He.residual,whole:!0},e.compute||{});for(let ft=0;ft<lt.length;ft+=$e)yield lt.slice(ft,ft+$e)}return{...e,edit:ot,rowMutate:kt,mode:"remote",fetch:Ce,aggregate:_e,countMatching:async je=>{const{plan:Te,signal:He}=await Nt(je);if(!Te.needsAll&&s.total){g({signal:He});const $e=await x(await a.execute({...Te.pushed,range:{start:0,end:0}},{signal:He}));if($e&&typeof $e.total=="number")return $e.total}let De=0;for await(const $e of Et(je))De+=$e.length;return De},streamMatching:Et,lastPlan:()=>te?{...te,...re?{aggregates:re}:{},...Ne?{total:{deferred:!0,state:Ne.state,value:Ne.value}}:{}}:null,fullFrame:Be,counts:()=>({match:be,total:Le??null,pending:!!Ne&&Ne.state==="pending"}),grandTotals:()=>Ae}}}),Ze("packages/modules/shared/engine.js",function(n,le){"use strict";Object.defineProperty(n,"sourceId",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"engineSource",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"gridPivoted",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"loadedAndMatching",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"gridHoldsWindow",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(n,"gridEngineRequest",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"EngineFlight",{enumerable:!0,get:function(){return U}});const ve=le("packages/core/src/source/pushdown.js"),ae=ve.capabilitiesOf,l=ve.planQuery,ne=le("packages/core/src/source/filterwire.js").wireFilters,ke=new WeakMap;let H=0;function ee(g){let O=ke.get(g);return O===void 0&&(O=++H,ke.set(g,O)),O}function ue(g){const O=g&&typeof g.config=="function"?g.config():null,w=O&&O.source&&typeof O.source=="object"?O.source:null;if(!w||typeof w.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const i=ae(w.adapter&&w.adapter.capabilities);return{source:w,caps:i,config:O}}function q(g){const O=g&&typeof g.config=="function"?g.config():null,w=O&&O.source&&typeof O.source=="object"?O.source:null;if(!w||typeof w.lastPlan!="function")return!1;const i=g&&g.state&&typeof g.state.get=="function"?g.state.get():null,v=i&&i.pivot;return!!(v&&v.enabled&&Array.isArray(v.columns)&&v.columns.length>0)}function B(g){let O=0;g.rows.forEach(i=>{i&&!i.group&&i.data!==null&&i.data!==void 0&&O++});const w=typeof g.rows.matchCount=="function"?g.rows.matchCount():NaN;return{loaded:O,total:Number.isFinite(w)?w:NaN}}function Y(g){const O=g&&typeof g.config=="function"?g.config():null,w=O&&O.source&&typeof O.source=="object"?O.source:null;if(!w||w.mode!=="remote"&&w.mode!=="paged")return!1;const{loaded:i,total:v}=B(g);return Number.isFinite(v)&&i<v}function A(g,O){return O?g?{op:"and",conditions:[g,O]}:O:g||null}function M(g,O,w=null){const i=g.filters&&typeof g.filters.where=="function"?g.filters.where():[];if(Array.isArray(i)&&i.length)return{reason:`a \`where\` predicate is in force (${i.join(", ")}), which only the browser can run`};const v=g.filters&&typeof g.filters.quickState=="function"?g.filters.quickState():{text:""},c=v&&v.text?String(v.text):"",{config:T,caps:C}=O,b={filters:ne(A(g.filters.get(),w),{tz:T.timeZone,weekStartsOn:T.weekStartsOn}),sort:[],range:null,context:T.context??null,...c?{quick:c}:{}},L=l(b,C);return L.unpushed.includes("filter")?{reason:w?"the grid's filter, or the viewport condition, did not fully push to the engine":"the grid's filter did not fully push to the engine"}:L.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:b,quick:c}}class U{#e=null;#t=null;#n=!1;answer(O){return this.#t&&this.#t.key===O?this.#t:null}last(){return this.#t}get busy(){return this.#e!==null}ask(O,w,i){const v=this.#e;if(v){v.key!==O&&v.controller&&v.controller.abort();return}const c=globalThis.AbortController,T=typeof c=="function"?new c:null,C={key:O,controller:T};this.#e=C;let b;Promise.resolve().then(()=>w(T?T.signal:null)).then(L=>{b={key:O,result:L}},L=>{b={key:O,error:L}}).then(()=>{this.#e===C&&(this.#e=null),!this.#n&&(T&&T.signal.aborted||(this.#t=b),i())})}abort(){const O=this.#e;O&&O.controller&&O.controller.abort()}close(){this.#n=!0,this.abort()}}}),Ze("packages/modules/charts/scale.js",function(n,le){"use strict";Object.defineProperty(n,"isNumber",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"toNumber",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"toTime",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"extent",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"niceStep",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(n,"niceDomain",{enumerable:!0,get:function(){return A}}),Object.defineProperty(n,"measureDomain",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"linearTicks",{enumerable:!0,get:function(){return U}}),Object.defineProperty(n,"timeStepFor",{enumerable:!0,get:function(){return g}}),Object.defineProperty(n,"timeTicks",{enumerable:!0,get:function(){return w}}),Object.defineProperty(n,"linearScale",{enumerable:!0,get:function(){return i}}),Object.defineProperty(n,"timeScale",{enumerable:!0,get:function(){return v}}),Object.defineProperty(n,"key",{enumerable:!0,get:function(){return c}}),Object.defineProperty(n,"bandScale",{enumerable:!0,get:function(){return T}}),Object.defineProperty(n,"sqrtScale",{enumerable:!0,get:function(){return C}});const ve=[1,2,2.5,5,10],ae=6e4,l=36e5,pe=864e5,ne=365.25*pe,ke=[1,2,5,10,20,25,50,100],H=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,ae,5*ae,15*ae,30*ae,l,3*l,6*l,12*l,pe,2*pe,7*pe,14*pe,30*pe,90*pe,180*pe,...ke.map(b=>b*ne)];function ee(b){return typeof b=="number"&&Number.isFinite(b)}function ue(b){if(b==null||b==="")return null;if(b instanceof Date){const G=b.getTime();return Number.isFinite(G)?G:null}if(typeof b=="boolean")return b?1:0;const L=Number(b);return Number.isFinite(L)?L:null}function q(b){if(b==null||b==="")return null;if(b instanceof Date){const G=b.getTime();return Number.isFinite(G)?G:null}if(typeof b=="number")return Number.isFinite(b)?b:null;const L=Date.parse(String(b));return Number.isFinite(L)?L:null}function B(b){let L=1/0,G=-1/0;for(let K=0;K<b.length;K++){const V=b[K];ee(V)&&(V<L&&(L=V),V>G&&(G=V))}return L===1/0?null:{min:L,max:G}}function Y(b){if(!(b>0))return 1;const L=10**Math.floor(Math.log10(b));for(const G of ve)if(b<=G*L)return G*L;return 10*L}function A(b,L=5){const G=Y((b.max-b.min)/Math.max(1,L));return{min:Math.floor(b.min/G)*G,max:Math.ceil(b.max/G)*G,step:G}}function M(b,L={}){const G=B(b)||{min:0,max:1};let{min:K,max:V}=G;if(L.zero&&(K>0&&(K=0),V<0&&(V=0)),K===V){const he=Math.abs(K)>0?Math.abs(K)/10:1;K-=he,V+=he}if(L.nice!==!1){const he=A({min:K,max:V},L.ticks||5);K=he.min,V=he.max}return ee(L.min)&&(K=L.min),ee(L.max)&&(V=L.max),K===V&&(V=K+1),{min:K,max:V}}function U(b,L=5){const G=Y((b.max-b.min)/Math.max(1,L)),K=Math.ceil(b.min/G),V=Math.floor(b.max/G),he=[];for(let X=K;X<=V;X++){const J=X*G;he.push(Math.abs(J)<G/1e6?0:Number(J.toPrecision(12)))}return he}function g(b,L=5){const G=Math.max(1,L),K=b/G;let V=H[H.length-1];for(const J of H)if(J>=K){V=J;break}if(V<ne)return V;let he=V,X=Math.abs(b/V-G);for(const J of H){if(J<ne)continue;const oe=Math.abs(b/J-G);oe<X&&(X=oe,he=J)}return he}function O(b,L){const G=new Date(b.min).getUTCFullYear();let K=Math.ceil(G/L)*L;Date.UTC(K,0,1)<b.min&&(K+=L);const V=[];for(;Date.UTC(K,0,1)<=b.max;K+=L)V.push(Date.UTC(K,0,1));return V}function w(b,L=5){const G=g(b.max-b.min,L);if(G>=ne)return O(b,Math.round(G/ne));const K=[],V=Math.ceil(b.min/G)*G;for(let he=V;he<=b.max;he+=G)K.push(he);return K}function i(b,L){const G=b.max-b.min||1,[K,V]=L;return{kind:"linear",domain:b,range:L,of(he){return K+(he-b.min)/G*(V-K)},invert(he){return b.min+(he-K)/(V-K||1)*G},ticks(he=5){return U(b,he)}}}function v(b,L){return{...i(b,L),kind:"time",ticks(K=5){return w(b,K)}}}function c(b){if(b==null)return" null";if(b instanceof Date)return` date:${b.getTime()}`;if(typeof b=="object"){const L=b,G=L.id??L.key??L.value;return G!==void 0&&typeof G!="object"?` obj:${String(G)}`:` obj:${String(b)}`}return String(b)}function T(b,L,G=.2){const K=Math.min(.9,Math.max(0,G)),[V,he]=L,X=new Map;for(let $=0;$<b.length;$++){const z=c(b[$]);X.has(z)||X.set(z,$)}const J=b.length?(he-V)/b.length:he-V,oe=Math.max(0,J*(1-K));return{kind:"band",domain:b,range:L,bandwidth:oe,step:J,of($){const z=X.get(c($));return z===void 0?NaN:V+z*J+(J-oe)/2},centre($){const z=this.of($);return Number.isNaN(z)?NaN:z+oe/2},ticks(){return b}}}function C(b,L){const[G,K]=L,V=Math.max(Math.abs(b.max),Math.abs(b.min),0)||1;return{kind:"sqrt",domain:b,range:L,of(he){const X=Math.sqrt(Math.abs(he)/V);return G+X*(K-G)}}}}),Ze("packages/modules/charts/svg.js",function(n,le){"use strict";Object.defineProperty(n,"SVG_NS",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"el",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"svg",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"attr",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"attrs",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"setText",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"clear",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"append",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"path",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"ribbonPath",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"round",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"pathRings",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(n,"insideRings",{enumerable:!0,get:function(){return A}});const ve="http://www.w3.org/2000/svg";function ae(M,U,g){const O=M.createElement(U);return g&&O.setAttribute("class",g),O}function l(M,U,g){const O=M.createElementNS(ve,U);if(g)for(const w of Object.keys(g))O.setAttribute(w,String(g[w]));return O}function pe(M,U,g){M&&(g==null?M.removeAttribute(U):M.setAttribute(U,String(g)))}function ne(M,U){if(M)for(const g of Object.keys(U))pe(M,g,U[g])}function ke(M,U){M&&(M.textContent=U==null?"":String(U))}function H(M){if(M)for(;M.firstChild;)M.removeChild(M.firstChild)}function ee(M,U){for(const g of U)g&&M.appendChild(g);return M}function ue(M){return M.join(" ")}function q(M){if(!M||M.length<2)return"";const U=["M",M[0].x,M[0].upper];for(let g=1;g<M.length;g++)U.push("L",M[g].x,M[g].upper);for(let g=M.length-1;g>=0;g--)U.push("L",M[g].x,M[g].lower);return U.push("Z"),ue(U)}function B(M){return Math.round(M*100)/100}function Y(M){const U=[];let g=[];const O=String(M||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let w="",i=[];const v=()=>{if(!w||!i.length){i=[];return}if(w==="M"||w==="L")for(let c=0;c+1<i.length;c+=2)g.push([i[c],i[c+1]]);else w!=="Z"&&i.length>=2&&g.push([i[i.length-2],i[i.length-1]]);i=[]};for(const c of O){if(/[A-Za-z]/.test(c)){if(v(),c==="Z"||c==="z"){g.length>2&&U.push(g),g=[],w="";continue}c==="M"&&g.length>2&&(U.push(g),g=[]),w=c;continue}i.push(Number(c))}return v(),g.length>2&&U.push(g),U}function A(M,U,g){let O=!1;for(const w of M)for(let i=0,v=w.length-1;i<w.length;v=i++){const[c,T]=w[i],[C,b]=w[v];T>g!=b>g&&U<(C-c)*(g-T)/(b-T||1e-12)+c&&(O=!O)}return O}}),Ze("packages/modules/charts/typography.js",function(n,le){"use strict";Object.defineProperty(n,"BASE_SIZE",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(n,"BASE_FAMILY",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(n,"CHAR_RATIO",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"resolveType",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"textWidth",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"widestLabel",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"truncateTo",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"applySize",{enumerable:!0,get:function(){return ue}});const ve=12,ae="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",l=.62;function pe(q){const B=q&&q.font,Y=typeof B=="number"?{size:B}:B||{},A=ne(Y.size,ve);return{family:Y.family||ae,size:A,small:ne(Y.small??Y.tickSize,Math.max(9,A-1)),title:ne(Y.title,Math.round(A*1.15)),axisTitle:ne(Y.axisTitle,Math.max(10,A-1)),weight:Y.weight||"inherit"}}function ne(q,B){const Y=Number(q);return Number.isFinite(Y)&&Y>0?Y:B}function ke(q,B){return String(q??"").length*B*l}function H(q,B){let Y=0;for(const A of q||[]){const M=ke(A,B);M>Y&&(Y=M)}return Y}function ee(q,B,Y){const A=String(q??""),M=Math.floor(B/(Y*l));return M<=0?"":A.length<=M?A:M===1?"…":`${A.slice(0,M-1)}…`}function ue(q,B){!q||!Number.isFinite(B)||(q.style?q.style.fontSize=`${B}px`:q.setAttribute("style",`font-size:${B}px`))}}),Ze("packages/modules/charts/frame.js",function(n,le){"use strict";Object.defineProperty(n,"LABEL_GAP",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"resolveMargin",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"plotRect",{enumerable:!0,get:function(){return q}}),Object.defineProperty(n,"shouldRotate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(n,"Pool",{enumerable:!0,get:function(){return Y}});const ae=le("packages/modules/charts/svg.js").SVG_NS,l=le("packages/modules/charts/typography.js"),pe=l.textWidth,ne=l.widestLabel,ke=8,H=6,ee=.4;function ue(A,M){const U=typeof A=="number"?A:M,g=A&&typeof A=="object"?A:{},O=w=>Number.isFinite(w)&&w>=0?Number(w):U;return{base:U,top:O(g.top),right:O(g.right),bottom:O(g.bottom),left:O(g.left)}}function q(A){const M=ue(A.margin,typeof A.padding=="number"?A.padding:8),U=M.base,g=A.fontSize||12,O=A.yLabels||[],w=A.xLabels||[],i=A.ySide==="right"?"right":"left",v=i==="right"?"left":"right",c=A.titles||{},T=A.titleSize||g,C=z=>z?T+H:0,b=ne(O,g),L=O.length?Math.min(A.width*ee,M[i]+b+H):Math.max(ke,M[i]),G=M[v]+(A.rightGutter||0),K=(i==="left"?L:G)+C(c.left),V=ne(w.map(z=>String(z).slice(0,14)),g),he=(w.length?A.rotated?Math.min(A.height*ee,H+V):g+H+M.bottom:Math.max(ke,M.bottom))+C(c.bottom),X=(i==="right"?L:G)+C(c.right),J=M.top+(A.topGutter||0),oe=Math.max(0,A.width-K-X),$=Math.max(0,A.height-J-he);return{left:K,top:J,width:oe,height:$,right:K+oe,bottom:J+$,gutter:{left:K,bottom:he,right:X,top:J}}}function B(A,M,U,g){if(!A.length||M<=0)return!1;const O=Number.isFinite(g)&&g>0?Number(g):1;return ne(A,U)>M*O-4}class Y{#e;#t=0;static#n="data-pool-key";constructor(M){this.#e=M}next(M,U,g){if(g!=null)return this.#r(M,U,String(g));const O=this.#e.childNodes[this.#t],w=O&&O.tagName;if(w&&String(w).toLowerCase()===M.toLowerCase())return U&&O.setAttribute("class",U),this.#t++,O;const i=this.#e.ownerDocument.createElementNS(ae,M);return U&&i.setAttribute("class",U),O?this.#e.insertBefore(i,O):this.#e.appendChild(i),this.#t++,i}#r(M,U,g){const O=M.toLowerCase();for(let v=this.#t;v<this.#e.childNodes.length;v++){const c=this.#e.childNodes[v],T=c&&c.tagName;if(T&&String(T).toLowerCase()===O&&c.getAttribute(Y.#n)===g)return v!==this.#t&&this.#e.insertBefore(c,this.#e.childNodes[this.#t]),U&&c.setAttribute("class",U),this.#t++,c}const w=this.#e.ownerDocument.createElementNS(ae,M);w.setAttribute(Y.#n,g),U&&w.setAttribute("class",U);const i=this.#e.childNodes[this.#t];return i?this.#e.insertBefore(w,i):this.#e.appendChild(w),this.#t++,w}finish(){for(;this.#e.childNodes.length>this.#t;)this.#e.removeChild(this.#e.lastChild);this.#t=0}}}),Ze("packages/modules/charts/scheme.js",function(n,le){"use strict";Object.defineProperty(n,"PALETTE",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"SCHEMES",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(n,"registerScheme",{enumerable:!0,get:function(){return H}}),Object.defineProperty(n,"setDefaultScheme",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(n,"schemeNames",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(n,"resolveScheme",{enumerable:!0,get:function(){return A}}),Object.defineProperty(n,"RAMP_SCALES",{enumerable:!0,get:function(){return M}}),Object.defineProperty(n,"toRgb",{enumerable:!0,get:function(){return O}}),Object.defineProperty(n,"rampStops",{enumerable:!0,get:function(){return w}});const ae=le("packages/core/src/internal/util.js").warnOnce,l=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),pe=Object.freeze({default:{series:l,sequential:["#ecf3f9","#005280"],diverging:["#b04a00","#f7f7f7","#005280"],positive:"#009e73",negative:"#d55e00"},bright:{series:["#1f77d0","#ff7f0e","#2ca02c","#d62728","#9467bd","#17becf","#e377c2","#7f7f7f"],sequential:["#eef4fb","#1f77d0"],diverging:["#d62728","#f7f7f7","#1f77d0"],positive:"#2ca02c",negative:"#d62728"},earth:{series:["#5b7c6f","#c08b52","#7a6a53","#a4553f","#4e6a83","#8f8259","#6d5566","#8c9196"],sequential:["#f2efe9","#4e6a83"],diverging:["#a4553f","#f2efe9","#4e6a83"],positive:"#5b7c6f",negative:"#a4553f"},mono:{series:["#0b2a3d","#17475f","#2c6480","#4a82a0","#6da0bd","#94bcd6","#bcd7e9","#dfecf5"],sequential:["#eef3f7","#0b2a3d"],diverging:["#7a5c00","#f5f5f5","#0b2a3d"],positive:"#17475f",negative:"#7a5c00"}}),ne=new Map;let ke="default";function H(i,v){!i||!v||ne.set(String(i),v)}function ee(i){if(typeof i=="string"){ke=i;return}i&&typeof i=="object"&&(ne.set("__default__",i),ke="__default__")}function ue(){return[...Object.keys(pe),...ne.keys()].filter(i=>!i.startsWith("__"))}function q(i){return ne.has(i)?ne.get(i):pe[i]||null}const B=["series","sequential","diverging","positive","negative"];function Y(i){return!i||typeof i!="object"||Array.isArray(i)?!1:!B.some(v=>v in i)}function A(i){const v=q(ke)||pe.default,c=i&&i.scheme,T=Y(c)?c:null,C=typeof c=="string"?q(c):T?null:c||null,b=i&&Array.isArray(i.palette)&&i.palette.length?i.palette:null;T&&b&&ae("chart:scheme:array-and-map",'chart "scheme" was given as a name map together with a "palette" array; the two do not combine. Colours came from the map and the array was ignored. Pass one or the other.');const L=T?null:b,G={...pe.default,...v,...C||{}};L&&(G.series=L);const K=i&&i.ramp&&typeof i.ramp=="object"&&!Array.isArray(i.ramp)?i.ramp:null,V=K?K.colours:i&&i.ramp,he=Array.isArray(V)&&V.length>=2?V:null;he&&(G.sequential=he);const X=K?U(K.scale):null,J=!!(C||L||T),oe=G.series&&G.series.length?G.series:l,$=new Map;let z=0;return{...G,series:(R,S)=>{if(T&&S!==void 0&&S!==null){const r=String(S);return Object.prototype.hasOwnProperty.call(T,r)?T[r]:($.has(r)||$.set(r,z++),g(oe,$.get(r),!0))}return g(oe,R,J)},explicit:J,nameMap:!!T,rampScale:X}}const M=Object.freeze(["linear","log","quantile"]);function U(i){return i==null?null:M.includes(i)?i:(ae(`chart:ramp:scale:${String(i)}`,`chart "ramp.scale" was "${String(i)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function g(i,v,c){const T=(v%i.length+i.length)%i.length;return c?i[T]:`var(--lattice-chart-${T+1}, ${i[T]})`}function O(i){if(typeof i!="string")return null;const v=i.trim(),c=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(v);if(c){const b=c[1];return b.length===3?[0,1,2].map(L=>parseInt(b[L]+b[L],16)):[0,2,4].map(L=>parseInt(b.slice(L,L+2),16))}const T=/^rgba?\(([^)]+)\)$/i.exec(v);if(!T)return null;const C=T[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return C.length===3&&C.every(b=>Number.isFinite(b))?C:null}function w(i,v){const c=v?i.diverging:i.sequential,T=v?pe.default.diverging:pe.default.sequential,C=(Array.isArray(c)?c:T).map((b,L)=>O(b)||O(T[L])||[0,0,0]);return C.length>=2?C:T.map(b=>O(b))}}),Ze("packages/modules/charts/styles.js",function(n,le){"use strict";Object.defineProperty(n,"NS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(n,"seriesColour",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(n,"css",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(n,"injectStyles",{enumerable:!0,get:function(){return H}});const ae=le("packages/modules/charts/scheme.js").PALETTE,l="lat-chartview",pe="data-lattice-chartview";function ne(ee){const ue=(ee%ae.length+ae.length)%ae.length;return`var(--lattice-chart-${ue+1}, ${ae[ue]})`}function ke(){return`
7
7
  .${l}{position:relative;display:flex;flex-direction:column;min-width:0;min-height:0;
8
8
  width:100%;height:100%;box-sizing:border-box;
9
9
  font-family:var(--lattice-font-family,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif);