@toclocoinc/lattice-grid 1.74.0 → 1.75.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/angular/package.json +1 -1
- package/docs/API.html +44 -6
- package/docs/CHART-CODES.md +8 -0
- package/docs/api/adapters.html +1 -1
- package/docs/api/ai.html +1 -1
- package/docs/api/alarms.html +1 -1
- package/docs/api/charts.html +28 -2
- package/docs/api/data-router.html +1 -1
- package/docs/api/deckgl.html +2 -2
- package/docs/api/gantt.html +1 -1
- package/docs/api/geometry.html +1 -1
- package/docs/api/grid.html +2 -2
- package/docs/api/index.html +2 -2
- package/docs/api/kanban.html +1 -1
- package/docs/api/kpi.html +1 -1
- package/docs/api/layout.html +1 -1
- package/docs/api/list.html +1 -1
- package/docs/api/mock-socket.html +1 -1
- package/docs/api/tabs.html +1 -1
- package/docs/api/types.html +13 -1
- package/docs/api-detail.html +13 -4
- package/docs/warnings.json +36 -3
- package/lattice-grid.d.ts +37 -2
- package/lattice-grid.esm.min.js +3 -3
- package/lattice-grid.min.cjs +3 -3
- package/lattice-grid.min.js +3 -3
- package/modules/ai.d.ts +1 -1
- package/modules/ai.esm.min.js +2 -2
- package/modules/ai.min.cjs +2 -2
- package/modules/ai.min.js +2 -2
- package/modules/alarms.d.ts +1 -1
- package/modules/alarms.esm.min.js +2 -2
- package/modules/alarms.min.cjs +2 -2
- package/modules/alarms.min.js +2 -2
- package/modules/angular.d.ts +1 -1
- package/modules/angular.esm.min.js +2 -2
- package/modules/angular.min.cjs +2 -2
- package/modules/angular.min.js +2 -2
- package/modules/chart-alluvial.d.ts +1 -1
- package/modules/chart-alluvial.esm.min.js +1 -1
- package/modules/chart-alluvial.min.cjs +1 -1
- package/modules/chart-alluvial.min.js +1 -1
- package/modules/chart-arc.d.ts +1 -1
- package/modules/chart-arc.esm.min.js +1 -1
- package/modules/chart-arc.min.cjs +1 -1
- package/modules/chart-arc.min.js +1 -1
- package/modules/chart-bubblemap.d.ts +1 -1
- package/modules/chart-bubblemap.esm.min.js +1 -1
- package/modules/chart-bubblemap.min.cjs +1 -1
- package/modules/chart-bubblemap.min.js +1 -1
- package/modules/chart-bump.d.ts +1 -1
- package/modules/chart-bump.esm.min.js +1 -1
- package/modules/chart-bump.min.cjs +1 -1
- package/modules/chart-bump.min.js +1 -1
- package/modules/chart-calendar.d.ts +1 -1
- package/modules/chart-calendar.esm.min.js +2 -2
- package/modules/chart-calendar.esm.min.js.map +1 -1
- package/modules/chart-calendar.min.cjs +2 -2
- package/modules/chart-calendar.min.js +2 -2
- package/modules/chart-calendar.min.js.map +1 -1
- package/modules/chart-choropleth.d.ts +1 -1
- package/modules/chart-choropleth.esm.min.js +2 -2
- package/modules/chart-choropleth.esm.min.js.map +1 -1
- package/modules/chart-choropleth.min.cjs +2 -2
- package/modules/chart-choropleth.min.js +2 -2
- package/modules/chart-choropleth.min.js.map +1 -1
- package/modules/chart-decomposition.d.ts +1 -1
- package/modules/chart-decomposition.esm.min.js +1 -1
- package/modules/chart-decomposition.min.cjs +1 -1
- package/modules/chart-decomposition.min.js +1 -1
- package/modules/chart-diverging.d.ts +1 -1
- package/modules/chart-diverging.esm.min.js +1 -1
- package/modules/chart-diverging.min.cjs +1 -1
- package/modules/chart-diverging.min.js +1 -1
- package/modules/chart-dumbbell.d.ts +1 -1
- package/modules/chart-dumbbell.esm.min.js +1 -1
- package/modules/chart-dumbbell.min.cjs +1 -1
- package/modules/chart-dumbbell.min.js +1 -1
- package/modules/chart-fan.d.ts +1 -1
- package/modules/chart-fan.esm.min.js +1 -1
- package/modules/chart-fan.min.cjs +1 -1
- package/modules/chart-fan.min.js +1 -1
- package/modules/chart-hexbin.d.ts +1 -1
- package/modules/chart-hexbin.esm.min.js +2 -2
- package/modules/chart-hexbin.esm.min.js.map +1 -1
- package/modules/chart-hexbin.min.cjs +2 -2
- package/modules/chart-hexbin.min.js +2 -2
- package/modules/chart-hexbin.min.js.map +1 -1
- package/modules/chart-hexmap.d.ts +1 -1
- package/modules/chart-hexmap.esm.min.js +2 -2
- package/modules/chart-hexmap.esm.min.js.map +1 -1
- package/modules/chart-hexmap.min.cjs +2 -2
- package/modules/chart-hexmap.min.js +2 -2
- package/modules/chart-hexmap.min.js.map +1 -1
- package/modules/chart-icicle.d.ts +1 -1
- package/modules/chart-icicle.esm.min.js +1 -1
- package/modules/chart-icicle.min.cjs +1 -1
- package/modules/chart-icicle.min.js +1 -1
- package/modules/chart-markermap.d.ts +1 -1
- package/modules/chart-markermap.esm.min.js +1 -1
- package/modules/chart-markermap.min.cjs +1 -1
- package/modules/chart-markermap.min.js +1 -1
- package/modules/chart-parallel.d.ts +1 -1
- package/modules/chart-parallel.esm.min.js +1 -1
- package/modules/chart-parallel.min.cjs +1 -1
- package/modules/chart-parallel.min.js +1 -1
- package/modules/chart-ridgeline.d.ts +1 -1
- package/modules/chart-ridgeline.esm.min.js +1 -1
- package/modules/chart-ridgeline.min.cjs +1 -1
- package/modules/chart-ridgeline.min.js +1 -1
- package/modules/chart-roc.d.ts +1 -1
- package/modules/chart-roc.esm.min.js +1 -1
- package/modules/chart-roc.min.cjs +1 -1
- package/modules/chart-roc.min.js +1 -1
- package/modules/chart-slope.d.ts +1 -1
- package/modules/chart-slope.esm.min.js +1 -1
- package/modules/chart-slope.min.cjs +1 -1
- package/modules/chart-slope.min.js +1 -1
- package/modules/chart-splom.d.ts +1 -1
- package/modules/chart-splom.esm.min.js +1 -1
- package/modules/chart-splom.min.cjs +1 -1
- package/modules/chart-splom.min.js +1 -1
- package/modules/chart-waffle.d.ts +1 -1
- package/modules/chart-waffle.esm.min.js +1 -1
- package/modules/chart-waffle.min.cjs +1 -1
- package/modules/chart-waffle.min.js +1 -1
- package/modules/charts.d.ts +1 -1
- package/modules/charts.esm.min.js +185 -178
- package/modules/charts.esm.min.js.map +2 -2
- package/modules/charts.min.cjs +185 -178
- package/modules/charts.min.js +185 -178
- package/modules/charts.min.js.map +2 -2
- package/modules/data-router.d.ts +1 -1
- package/modules/data-router.esm.min.js +2 -2
- package/modules/data-router.min.cjs +2 -2
- package/modules/data-router.min.js +2 -2
- package/modules/deckgl.d.ts +9 -3
- package/modules/deckgl.esm.min.js +18 -11
- package/modules/deckgl.esm.min.js.map +2 -2
- package/modules/deckgl.min.cjs +18 -11
- package/modules/deckgl.min.js +18 -11
- package/modules/deckgl.min.js.map +2 -2
- package/modules/devtools.d.ts +1 -1
- package/modules/devtools.esm.min.js +1 -1
- package/modules/devtools.min.cjs +1 -1
- package/modules/devtools.min.js +1 -1
- package/modules/dhtmlx-compat.d.ts +1 -1
- package/modules/dhtmlx-compat.esm.min.js +2 -2
- package/modules/dhtmlx-compat.min.cjs +2 -2
- package/modules/dhtmlx-compat.min.js +2 -2
- package/modules/gantt.d.ts +1 -1
- package/modules/gantt.esm.min.js +2 -2
- package/modules/gantt.min.cjs +2 -2
- package/modules/gantt.min.js +2 -2
- package/modules/geo-europe-nuts.d.ts +1 -1
- package/modules/geo-europe-nuts.esm.min.js +1 -1
- package/modules/geo-europe-nuts.min.cjs +1 -1
- package/modules/geo-europe-nuts.min.js +1 -1
- package/modules/geo-uk.d.ts +1 -1
- package/modules/geo-uk.esm.min.js +1 -1
- package/modules/geo-uk.min.cjs +1 -1
- package/modules/geo-uk.min.js +1 -1
- package/modules/geo-us-states.d.ts +1 -1
- package/modules/geo-us-states.esm.min.js +1 -1
- package/modules/geo-us-states.min.cjs +1 -1
- package/modules/geo-us-states.min.js +1 -1
- package/modules/geo-world-110m.d.ts +1 -1
- package/modules/geo-world-110m.esm.min.js +1 -1
- package/modules/geo-world-110m.min.cjs +1 -1
- package/modules/geo-world-110m.min.js +1 -1
- package/modules/geo-world-50m.d.ts +1 -1
- package/modules/geo-world-50m.esm.min.js +1 -1
- package/modules/geo-world-50m.min.cjs +1 -1
- package/modules/geo-world-50m.min.js +1 -1
- package/modules/geometry.d.ts +1 -1
- package/modules/geometry.esm.min.js +2 -2
- package/modules/geometry.min.cjs +2 -2
- package/modules/geometry.min.js +2 -2
- package/modules/htmx.d.ts +1 -1
- package/modules/htmx.esm.min.js +3 -3
- package/modules/htmx.min.cjs +3 -3
- package/modules/htmx.min.js +3 -3
- package/modules/kanban.d.ts +1 -1
- package/modules/kanban.esm.min.js +2 -2
- package/modules/kanban.min.cjs +2 -2
- package/modules/kanban.min.js +2 -2
- package/modules/kpi.d.ts +1 -1
- package/modules/kpi.esm.min.js +2 -2
- package/modules/kpi.min.cjs +2 -2
- package/modules/kpi.min.js +2 -2
- package/modules/layout.d.ts +1 -1
- package/modules/layout.esm.min.js +2 -2
- package/modules/layout.min.cjs +2 -2
- package/modules/layout.min.js +2 -2
- package/modules/list.d.ts +1 -1
- package/modules/list.esm.min.js +2 -2
- package/modules/list.min.cjs +2 -2
- package/modules/list.min.js +2 -2
- package/modules/mock-socket.d.ts +1 -1
- package/modules/mock-socket.esm.min.js +1 -1
- package/modules/mock-socket.min.cjs +1 -1
- package/modules/mock-socket.min.js +1 -1
- package/modules/react.d.ts +1 -1
- package/modules/react.esm.min.js +2 -2
- package/modules/react.min.cjs +2 -2
- package/modules/react.min.js +2 -2
- package/modules/svelte.d.ts +1 -1
- package/modules/svelte.esm.min.js +2 -2
- package/modules/svelte.min.cjs +2 -2
- package/modules/svelte.min.js +2 -2
- package/modules/tabs.d.ts +1 -1
- package/modules/tabs.esm.min.js +2 -2
- package/modules/tabs.min.cjs +2 -2
- package/modules/tabs.min.js +2 -2
- package/modules/vue.d.ts +1 -1
- package/modules/vue.esm.min.js +2 -2
- package/modules/vue.min.cjs +2 -2
- package/modules/vue.min.js +2 -2
- package/modules/webcomponent.d.ts +1 -1
- package/modules/webcomponent.esm.min.js +3 -3
- package/modules/webcomponent.min.cjs +3 -3
- package/modules/webcomponent.min.js +3 -3
- package/package.json +1 -1
package/modules/charts.min.cjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* Lattice Grid 1.
|
|
2
|
+
* Lattice Grid 1.75.0, charts module
|
|
3
3
|
* Copyright (c) 2026 TOCLOCO Inc. All rights reserved.
|
|
4
4
|
* https://latticegrid.dev
|
|
5
5
|
*/
|
|
6
|
-
(function(Dn){"use strict";var Bn=Object.create(null),Gn=Object.create(null);function Je(o,Y){Bn[o]=Y}function Un(o){var Y=Gn[o];if(Y)return Y;var ke=Object.create(null);Gn[o]=ke;var Q=Bn[o];if(!Q)throw new Error("[lattice] missing module: "+o);return Q(ke,Un),ke}Je("packages/modules/charts/svg.js",function(o,Y){"use strict";Object.defineProperty(o,"SVG_NS",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"el",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"svg",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"attr",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"attrs",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"setText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"clear",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"append",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"path",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"ribbonPath",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"round",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"pathRings",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"insideRings",{enumerable:!0,get:function(){return D}});const ke="http://www.w3.org/2000/svg";function Q(I,G,z){const x=I.createElement(G);return z&&x.setAttribute("class",z),x}function $(I,G,z){const x=I.createElementNS(ke,G);if(z)for(const b of Object.keys(z))x.setAttribute(b,String(z[b]));return x}function pe(I,G,z){I&&(z==null?I.removeAttribute(G):I.setAttribute(G,String(z)))}function me(I,G){if(I)for(const z of Object.keys(G))pe(I,z,G[z])}function te(I,G){I&&(I.textContent=G==null?"":String(G))}function Z(I){if(I)for(;I.firstChild;)I.removeChild(I.firstChild)}function H(I,G){for(const z of G)z&&I.appendChild(z);return I}function ue(I){return I.join(" ")}function P(I){if(!I||I.length<2)return"";const G=["M",I[0].x,I[0].upper];for(let z=1;z<I.length;z++)G.push("L",I[z].x,I[z].upper);for(let z=I.length-1;z>=0;z--)G.push("L",I[z].x,I[z].lower);return G.push("Z"),ue(G)}function y(I){return Math.round(I*100)/100}function B(I){const G=[];let z=[];const x=String(I||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let b="",f=[];const l=()=>{if(!b||!f.length){f=[];return}if(b==="M"||b==="L")for(let v=0;v+1<f.length;v+=2)z.push([f[v],f[v+1]]);else b!=="Z"&&f.length>=2&&z.push([f[f.length-2],f[f.length-1]]);f=[]};for(const v of x){if(/[A-Za-z]/.test(v)){if(l(),v==="Z"||v==="z"){z.length>2&&G.push(z),z=[],b="";continue}v==="M"&&z.length>2&&(G.push(z),z=[]),b=v;continue}f.push(Number(v))}return l(),z.length>2&&G.push(z),G}function D(I,G,z){let x=!1;for(const b of I)for(let f=0,l=b.length-1;f<b.length;l=f++){const[v,C]=b[f],[F,_]=b[l];C>z!=_>z&&G<(F-v)*(z-C)/(_-C||1e-12)+v&&(x=!x)}return x}}),Je("packages/modules/charts/typography.js",function(o,Y){"use strict";Object.defineProperty(o,"BASE_SIZE",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"BASE_FAMILY",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"CHAR_RATIO",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"resolveType",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"textWidth",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"widestLabel",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"truncateTo",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"applySize",{enumerable:!0,get:function(){return ue}});const ke=12,Q="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",$=.62;function pe(P){const y=P&&P.font,B=typeof y=="number"?{size:y}:y||{},D=me(B.size,ke);return{family:B.family||Q,size:D,small:me(B.small??B.tickSize,Math.max(9,D-1)),title:me(B.title,Math.round(D*1.15)),axisTitle:me(B.axisTitle,Math.max(10,D-1)),weight:B.weight||"inherit"}}function me(P,y){const B=Number(P);return Number.isFinite(B)&&B>0?B:y}function te(P,y){return String(P??"").length*y*$}function Z(P,y){let B=0;for(const D of P||[]){const I=te(D,y);I>B&&(B=I)}return B}function H(P,y,B){const D=String(P??""),I=Math.floor(y/(B*$));return I<=0?"":D.length<=I?D:I===1?"…":`${D.slice(0,I-1)}…`}function ue(P,y){!P||!Number.isFinite(y)||(P.style?P.style.fontSize=`${y}px`:P.setAttribute("style",`font-size:${y}px`))}}),Je("packages/modules/charts/frame.js",function(o,Y){"use strict";Object.defineProperty(o,"LABEL_GAP",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolveMargin",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"plotRect",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"shouldRotate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"Pool",{enumerable:!0,get:function(){return B}});const Q=Y("packages/modules/charts/svg.js").SVG_NS,$=Y("packages/modules/charts/typography.js"),pe=$.textWidth,me=$.widestLabel,te=8,Z=6,H=.4;function ue(D,I){const G=typeof D=="number"?D:I,z=D&&typeof D=="object"?D:{},x=b=>Number.isFinite(b)&&b>=0?Number(b):G;return{base:G,top:x(z.top),right:x(z.right),bottom:x(z.bottom),left:x(z.left)}}function P(D){const I=ue(D.margin,typeof D.padding=="number"?D.padding:8),G=I.base,z=D.fontSize||12,x=D.yLabels||[],b=D.xLabels||[],f=D.ySide==="right"?"right":"left",l=f==="right"?"left":"right",v=D.titles||{},C=D.titleSize||z,F=W=>W?C+Z:0,_=me(x,z),J=x.length?Math.min(D.width*H,I[f]+_+Z):Math.max(te,I[f]),re=I[l]+(D.rightGutter||0),q=(f==="left"?J:re)+F(v.left),U=me(b.map(W=>String(W).slice(0,14)),z),ge=(b.length?D.rotated?Math.min(D.height*H,Z+U):z+Z+I.bottom:Math.max(te,I.bottom))+F(v.bottom),A=(f==="right"?J:re)+F(v.right),X=I.top+(D.topGutter||0),ce=Math.max(0,D.width-q-A),E=Math.max(0,D.height-X-ge);return{left:q,top:X,width:ce,height:E,right:q+ce,bottom:X+E,gutter:{left:q,bottom:ge,right:A,top:X}}}function y(D,I,G,z){if(!D.length||I<=0)return!1;const x=Number.isFinite(z)&&z>0?Number(z):1;return me(D,G)>I*x-4}class B{#r;#n=0;static#l="data-pool-key";constructor(I){this.#r=I}next(I,G,z){if(z!=null)return this.#e(I,G,String(z));const x=this.#r.childNodes[this.#n],b=x&&x.tagName;if(b&&String(b).toLowerCase()===I.toLowerCase())return G&&x.setAttribute("class",G),this.#n++,x;const f=this.#r.ownerDocument.createElementNS(Q,I);return G&&f.setAttribute("class",G),x?this.#r.insertBefore(f,x):this.#r.appendChild(f),this.#n++,f}#e(I,G,z){const x=I.toLowerCase();for(let l=this.#n;l<this.#r.childNodes.length;l++){const v=this.#r.childNodes[l],C=v&&v.tagName;if(C&&String(C).toLowerCase()===x&&v.getAttribute(B.#l)===z)return l!==this.#n&&this.#r.insertBefore(v,this.#r.childNodes[this.#n]),G&&v.setAttribute("class",G),this.#n++,v}const b=this.#r.ownerDocument.createElementNS(Q,I);b.setAttribute(B.#l,z),G&&b.setAttribute("class",G);const f=this.#r.childNodes[this.#n];return f?this.#r.insertBefore(b,f):this.#r.appendChild(b),this.#n++,b}finish(){for(;this.#r.childNodes.length>this.#n;)this.#r.removeChild(this.#r.lastChild);this.#n=0}}}),Je("packages/core/src/internal/util.js",function(o,Y){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return n}});const ke="1.74.0";async function Q(){return ke}const $="1.74.0",pe=new Set,me=2e3;function te(t){if(pe.add(t),pe.size>me){const r=pe.values().next().value;r!==void 0&&pe.delete(r)}}const Z=[],H=500;function ue(t,r,a){Z.push({key:t,level:r,message:a.map(T=>typeof T=="string"?T:P(T)).join(" "),at:Date.now()}),Z.length>H&&Z.shift()}function P(t){if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function y(){return Z.map(t=>({...t}))}function B(t,...r){pe.has(t)||(te(t),ue(t,"warn",r),console.warn("[lattice]",...r))}function D(t,...r){pe.has(t)||(te(t),ue(t,"info",r),console.info("[lattice]",...r))}function I(){pe.clear(),Z.length=0}function G(t,r){const a=new Error(`[lattice] ${t}`);throw r!==void 0&&(a.cause=r),a}function z(t,r){t||G(r)}const x=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function b(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function f(t){return typeof t=="function"}function l(t){return t==null}function v(t){return t==null||t===""}function C(t){return typeof t!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(t))?!0:!!(t.prototype&&Object.getOwnPropertyNames(t.prototype).length>1)}const F=new Map;function _(t){let r=F.get(t);if(r)return r;if(!t.includes("."))r=a=>a?.[t];else{const a=t.split("."),T=a.length;r=M=>{let L=M;for(let ee=0;ee<T;ee++){if(L==null)return;L=L[a[ee]]}return L}}return F.set(t,r),r}const J=new Map;function re(t){let r=J.get(t);if(r)return r;if(!t.includes("."))r=(a,T)=>{a!=null&&(a[t]=T)};else{const a=t.split("."),T=a.length-1;r=(M,L)=>{let ee=M;for(let fe=0;fe<T;fe++){if(ee==null)return;const de=a[fe];ee[de]==null&&(ee[de]={}),ee=ee[de]}ee!=null&&(ee[a[T]]=L)}}return J.set(t,r),r}function q(t,r){return _(r)(t)}function U(t,r,a){re(r)(t,a)}function ge(t){return t?(t.includes(".")?t.slice(t.lastIndexOf(".")+1):t).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,a=>a.toUpperCase()):""}const A={"&":"&","<":"<",">":">",'"':""","'":"'"};function X(t){const r=t==null?"":String(t);return/[&<>"']/.test(r)?r.replace(/[&<>"']/g,a=>A[a]):r}function ce(t){return String(t).replace(/\w\S*/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function E(t,r,a){if(t!==void 0)return t===!0?{enabled:!0,...a}:t===!1?{enabled:!1}:b(t)?t:{[r]:t,enabled:!0}}function W(t){return t==null?[]:Array.isArray(t)?t:[t]}const h=Object.freeze(new Set(["__proto__","constructor","prototype"]));function s(t,r){if(!b(t))return b(r)?{...r}:r;if(!b(r))return r===void 0?t:r;const a={...t};for(const T of Object.keys(r)){if(h.has(T))continue;const M=r[T];M!==void 0&&(a[T]=b(M)&&b(a[T])?s(a[T],M):M)}return a}function g(t,r){if(!b(t)||!b(r)||t===r)return r;const a=Object.create(Object.getPrototypeOf(t));return Object.assign(a,t,r),a}class c{#r;#n=new Map;#l;constructor(r=256,a=null){this.#r=r,this.#l=a}get size(){return this.#n.size}get max(){return this.#r}set max(r){this.#r=r,this.#e()}has(r){return this.#n.has(r)}get(r){const a=this.#n;if(!a.has(r))return;const T=a.get(r);return a.delete(r),a.set(r,T),T}peek(r){return this.#n.get(r)}set(r,a){const T=this.#n;return T.has(r)&&T.delete(r),T.set(r,a),this.#e(),a}delete(r){const a=this.#n.get(r);return this.#n.delete(r)&&this.#l&&this.#l(a,r),a}clear(){if(this.#l)for(const[r,a]of this.#n)this.#l(a,r);this.#n.clear()}keys(){return this.#n.keys()}values(){return this.#n.values()}#e(){const r=this.#n;for(;r.size>this.#r;){const a=r.keys().next().value,T=r.get(a);r.delete(a),this.#l&&this.#l(T,a)}}}const d=new Map;function N(t,r){const a=`${t||""}|${r?JSON.stringify(r):""}`;let T=d.get(a);return T||(T=new Intl.Collator(t||void 0,{numeric:!0,sensitivity:"variant",...r}),d.set(a,T)),T}function S(t,r){if(t===r)return 0;if(t==null)return 1;if(r==null)return-1;if(typeof t=="number"&&typeof r=="number")return Number.isNaN(t)?Number.isNaN(r)?0:1:Number.isNaN(r)||t<r?-1:t>r?1:0;const a=String(t),T=String(r);return a<T?-1:a>T?1:0}function w(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const m=typeof requestAnimationFrame=="function";function u(t){return m?requestAnimationFrame(t):setTimeout(()=>t(w()),16)}function k(t){t!=null&&(m?cancelAnimationFrame(t):clearTimeout(t))}function R(t){let r=null,a=null;const T=()=>{r=null;const L=a;a=null,t(...L||[])},M=(...L)=>{a=L,r===null&&(r=u(T))};return M.cancel=()=>{k(r),r=null,a=null},M.flush=()=>{r!==null&&(k(r),T())},M}function p(t,r){let a=null,T=null;const M=()=>{if(a=null,T===null)return;const fe=T;T=null,t(...fe),L()},L=()=>{a=setTimeout(M,r),typeof a?.unref=="function"&&a.unref()},ee=(...fe)=>{a===null?(t(...fe),L()):(T=fe,clearTimeout(a),L())};return ee.flush=()=>{if(a!==null&&clearTimeout(a),a=null,T===null)return;const fe=T;T=null,t(...fe)},ee.cancel=()=>{a!==null&&clearTimeout(a),a=null,T=null},ee.pending=()=>a!==null||T!==null,ee}function e(t,r=50){return typeof requestIdleCallback=="function"?requestIdleCallback(t,{timeout:r}):setTimeout(()=>t({timeRemaining:()=>0,didTimeout:!0}),1)}let i=0;function n(t="l"){return`${t}${(++i).toString(36)}`}}),Je("packages/modules/charts/scheme.js",function(o,Y){"use strict";Object.defineProperty(o,"PALETTE",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"SCHEMES",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"registerScheme",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"setDefaultScheme",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"schemeNames",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"resolveScheme",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"toRgb",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"rampStops",{enumerable:!0,get:function(){return z}});const Q=Y("packages/core/src/internal/util.js").warnOnce,$=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),pe=Object.freeze({default:{series:$,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"}}),me=new Map;let te="default";function Z(x,b){!x||!b||me.set(String(x),b)}function H(x){if(typeof x=="string"){te=x;return}x&&typeof x=="object"&&(me.set("__default__",x),te="__default__")}function ue(){return[...Object.keys(pe),...me.keys()].filter(x=>!x.startsWith("__"))}function P(x){return me.has(x)?me.get(x):pe[x]||null}const y=["series","sequential","diverging","positive","negative"];function B(x){return!x||typeof x!="object"||Array.isArray(x)?!1:!y.some(b=>b in x)}function D(x){const b=P(te)||pe.default,f=x&&x.scheme,l=B(f)?f:null,v=typeof f=="string"?P(f):l?null:f||null,C=x&&Array.isArray(x.palette)&&x.palette.length?x.palette:null;l&&C&&Q("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 F=l?null:C,_={...pe.default,...b,...v||{}};F&&(_.series=F);const J=x&&Array.isArray(x.ramp)&&x.ramp.length>=2?x.ramp:null;J&&(_.sequential=J);const re=!!(v||F||l),q=_.series&&_.series.length?_.series:$,U=new Map;let ge=0;return{..._,series:(X,ce)=>{if(l&&ce!==void 0&&ce!==null){const E=String(ce);return Object.prototype.hasOwnProperty.call(l,E)?l[E]:(U.has(E)||U.set(E,ge++),I(q,U.get(E),!0))}return I(q,X,re)},explicit:re,nameMap:!!l}}function I(x,b,f){const l=(b%x.length+x.length)%x.length;return f?x[l]:`var(--lattice-chart-${l+1}, ${x[l]})`}function G(x){if(typeof x!="string")return null;const b=x.trim(),f=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(b);if(f){const C=f[1];return C.length===3?[0,1,2].map(F=>parseInt(C[F]+C[F],16)):[0,2,4].map(F=>parseInt(C.slice(F,F+2),16))}const l=/^rgba?\(([^)]+)\)$/i.exec(b);if(!l)return null;const v=l[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return v.length===3&&v.every(C=>Number.isFinite(C))?v:null}function z(x,b){const f=b?x.diverging:x.sequential,l=b?pe.default.diverging:pe.default.sequential,v=(Array.isArray(f)?f:l).map((C,F)=>G(C)||G(l[F])||[0,0,0]);return v.length>=2?v:l.map(C=>G(C))}}),Je("packages/modules/charts/styles.js",function(o,Y){"use strict";Object.defineProperty(o,"NS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"seriesColour",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"css",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"injectStyles",{enumerable:!0,get:function(){return Z}});const Q=Y("packages/modules/charts/scheme.js").PALETTE,$="lat-chartview",pe="data-lattice-chartview";function me(H){const ue=(H%Q.length+Q.length)%Q.length;return`var(--lattice-chart-${ue+1}, ${Q[ue]})`}function te(){return`
|
|
7
|
-
.${
|
|
6
|
+
(function(Dn){"use strict";var Bn=Object.create(null),Gn=Object.create(null);function Qe(o,X){Bn[o]=X}function Un(o){var X=Gn[o];if(X)return X;var ye=Object.create(null);Gn[o]=ye;var q=Bn[o];if(!q)throw new Error("[lattice] missing module: "+o);return q(ye,Un),ye}Qe("packages/modules/charts/svg.js",function(o,X){"use strict";Object.defineProperty(o,"SVG_NS",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"el",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"svg",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"attr",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"attrs",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"setText",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"clear",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"append",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"path",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"ribbonPath",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"round",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"pathRings",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"insideRings",{enumerable:!0,get:function(){return D}});const ye="http://www.w3.org/2000/svg";function q(T,B,_){const $=T.createElement(B);return _&&$.setAttribute("class",_),$}function j(T,B,_){const $=T.createElementNS(ye,B);if(_)for(const p of Object.keys(_))$.setAttribute(p,String(_[p]));return $}function be(T,B,_){T&&(_==null?T.removeAttribute(B):T.setAttribute(B,String(_)))}function me(T,B){if(T)for(const _ of Object.keys(B))be(T,_,B[_])}function te(T,B){T&&(T.textContent=B==null?"":String(B))}function J(T){if(T)for(;T.firstChild;)T.removeChild(T.firstChild)}function W(T,B){for(const _ of B)_&&T.appendChild(_);return T}function ie(T){return T.join(" ")}function S(T){if(!T||T.length<2)return"";const B=["M",T[0].x,T[0].upper];for(let _=1;_<T.length;_++)B.push("L",T[_].x,T[_].upper);for(let _=T.length-1;_>=0;_--)B.push("L",T[_].x,T[_].lower);return B.push("Z"),ie(B)}function y(T){return Math.round(T*100)/100}function U(T){const B=[];let _=[];const $=String(T||"").match(/[A-Za-z]|-?\d*\.?\d+(?:e[-+]?\d+)?/gi)||[];let p="",s=[];const c=()=>{if(!p||!s.length){s=[];return}if(p==="M"||p==="L")for(let k=0;k+1<s.length;k+=2)_.push([s[k],s[k+1]]);else p!=="Z"&&s.length>=2&&_.push([s[s.length-2],s[s.length-1]]);s=[]};for(const k of $){if(/[A-Za-z]/.test(k)){if(c(),k==="Z"||k==="z"){_.length>2&&B.push(_),_=[],p="";continue}k==="M"&&_.length>2&&(B.push(_),_=[]),p=k;continue}s.push(Number(k))}return c(),_.length>2&&B.push(_),B}function D(T,B,_){let $=!1;for(const p of T)for(let s=0,c=p.length-1;s<p.length;c=s++){const[k,R]=p[s],[I,z]=p[c];R>_!=z>_&&B<(I-k)*(_-R)/(z-R||1e-12)+k&&($=!$)}return $}}),Qe("packages/modules/charts/typography.js",function(o,X){"use strict";Object.defineProperty(o,"BASE_SIZE",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"BASE_FAMILY",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"CHAR_RATIO",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"resolveType",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"textWidth",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"widestLabel",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"truncateTo",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"applySize",{enumerable:!0,get:function(){return ie}});const ye=12,q="var(--lattice-font-family, system-ui, -apple-system, sans-serif)",j=.62;function be(S){const y=S&&S.font,U=typeof y=="number"?{size:y}:y||{},D=me(U.size,ye);return{family:U.family||q,size:D,small:me(U.small??U.tickSize,Math.max(9,D-1)),title:me(U.title,Math.round(D*1.15)),axisTitle:me(U.axisTitle,Math.max(10,D-1)),weight:U.weight||"inherit"}}function me(S,y){const U=Number(S);return Number.isFinite(U)&&U>0?U:y}function te(S,y){return String(S??"").length*y*j}function J(S,y){let U=0;for(const D of S||[]){const T=te(D,y);T>U&&(U=T)}return U}function W(S,y,U){const D=String(S??""),T=Math.floor(y/(U*j));return T<=0?"":D.length<=T?D:T===1?"…":`${D.slice(0,T-1)}…`}function ie(S,y){!S||!Number.isFinite(y)||(S.style?S.style.fontSize=`${y}px`:S.setAttribute("style",`font-size:${y}px`))}}),Qe("packages/modules/charts/frame.js",function(o,X){"use strict";Object.defineProperty(o,"LABEL_GAP",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"LABEL_GUTTER_SHARE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"resolveMargin",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"plotRect",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"shouldRotate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"Pool",{enumerable:!0,get:function(){return U}});const q=X("packages/modules/charts/svg.js").SVG_NS,j=X("packages/modules/charts/typography.js"),be=j.textWidth,me=j.widestLabel,te=8,J=6,W=.4;function ie(D,T){const B=typeof D=="number"?D:T,_=D&&typeof D=="object"?D:{},$=p=>Number.isFinite(p)&&p>=0?Number(p):B;return{base:B,top:$(_.top),right:$(_.right),bottom:$(_.bottom),left:$(_.left)}}function S(D){const T=ie(D.margin,typeof D.padding=="number"?D.padding:8),B=T.base,_=D.fontSize||12,$=D.yLabels||[],p=D.xLabels||[],s=D.ySide==="right"?"right":"left",c=s==="right"?"left":"right",k=D.titles||{},R=D.titleSize||_,I=V=>V?R+J:0,z=me($,_),Y=$.length?Math.min(D.width*W,T[s]+z+J):Math.max(te,T[s]),re=T[c]+(D.rightGutter||0),ee=(s==="left"?Y:re)+I(k.left),H=me(p.map(V=>String(V).slice(0,14)),_),pe=(p.length?D.rotated?Math.min(D.height*W,J+H):_+J+T.bottom:Math.max(te,T.bottom))+I(k.bottom),x=(s==="right"?Y:re)+I(k.right),Q=T.top+(D.topGutter||0),ce=Math.max(0,D.width-ee-x),E=Math.max(0,D.height-Q-pe);return{left:ee,top:Q,width:ce,height:E,right:ee+ce,bottom:Q+E,gutter:{left:ee,bottom:pe,right:x,top:Q}}}function y(D,T,B,_){if(!D.length||T<=0)return!1;const $=Number.isFinite(_)&&_>0?Number(_):1;return me(D,B)>T*$-4}class U{#r;#n=0;static#l="data-pool-key";constructor(T){this.#r=T}next(T,B,_){if(_!=null)return this.#e(T,B,String(_));const $=this.#r.childNodes[this.#n],p=$&&$.tagName;if(p&&String(p).toLowerCase()===T.toLowerCase())return B&&$.setAttribute("class",B),this.#n++,$;const s=this.#r.ownerDocument.createElementNS(q,T);return B&&s.setAttribute("class",B),$?this.#r.insertBefore(s,$):this.#r.appendChild(s),this.#n++,s}#e(T,B,_){const $=T.toLowerCase();for(let c=this.#n;c<this.#r.childNodes.length;c++){const k=this.#r.childNodes[c],R=k&&k.tagName;if(R&&String(R).toLowerCase()===$&&k.getAttribute(U.#l)===_)return c!==this.#n&&this.#r.insertBefore(k,this.#r.childNodes[this.#n]),B&&k.setAttribute("class",B),this.#n++,k}const p=this.#r.ownerDocument.createElementNS(q,T);p.setAttribute(U.#l,_),B&&p.setAttribute("class",B);const s=this.#r.childNodes[this.#n];return s?this.#r.insertBefore(p,s):this.#r.appendChild(p),this.#n++,p}finish(){for(;this.#r.childNodes.length>this.#n;)this.#r.removeChild(this.#r.lastChild);this.#n=0}}}),Qe("packages/core/src/internal/util.js",function(o,X){"use strict";Object.defineProperty(o,"VERSION",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"reportedWarnings",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"warnOnce",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"infoOnce",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"resetWarnings",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"fail",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"invariant",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"DEV",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"isObject",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"isFunction",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"isNil",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"isBlank",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"isCtor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"pathGetter",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"pathSetter",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"getPath",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"setPath",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"humanise",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"escapeHtml",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"titleCase",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"expand",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"toArray",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"merge",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"mergeRow",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"Lru",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"collator",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"defaultCompare",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"now",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"nextFrame",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"cancelFrame",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"frameBatched",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"settleDebounce",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"whenIdle",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"uid",{enumerable:!0,get:function(){return n}});const ye="1.75.0";async function q(){return ye}const j="1.75.0",be=new Set,me=2e3;function te(t){if(be.add(t),be.size>me){const r=be.values().next().value;r!==void 0&&be.delete(r)}}const J=[],W=500;function ie(t,r,l){J.push({key:t,level:r,message:l.map(L=>typeof L=="string"?L:S(L)).join(" "),at:Date.now()}),J.length>W&&J.shift()}function S(t){if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch{return String(t)}}function y(){return J.map(t=>({...t}))}function U(t,...r){be.has(t)||(te(t),ie(t,"warn",r),console.warn("[lattice]",...r))}function D(t,...r){be.has(t)||(te(t),ie(t,"info",r),console.info("[lattice]",...r))}function T(){be.clear(),J.length=0}function B(t,r){const l=new Error(`[lattice] ${t}`);throw r!==void 0&&(l.cause=r),l}function _(t,r){t||B(r)}const $=(()=>{try{return!(typeof process<"u"&&process.env&&process.env.NODE_ENV==="production")}catch{return!0}})();function p(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)}function s(t){return typeof t=="function"}function c(t){return t==null}function k(t){return t==null||t===""}function R(t){return typeof t!="function"?!1:/^class[\s{]/.test(Function.prototype.toString.call(t))?!0:!!(t.prototype&&Object.getOwnPropertyNames(t.prototype).length>1)}const I=new Map;function z(t){let r=I.get(t);if(r)return r;if(!t.includes("."))r=l=>l?.[t];else{const l=t.split("."),L=l.length;r=M=>{let C=M;for(let ne=0;ne<L;ne++){if(C==null)return;C=C[l[ne]]}return C}}return I.set(t,r),r}const Y=new Map;function re(t){let r=Y.get(t);if(r)return r;if(!t.includes("."))r=(l,L)=>{l!=null&&(l[t]=L)};else{const l=t.split("."),L=l.length-1;r=(M,C)=>{let ne=M;for(let ue=0;ue<L;ue++){if(ne==null)return;const ge=l[ue];ne[ge]==null&&(ne[ge]={}),ne=ne[ge]}ne!=null&&(ne[l[L]]=C)}}return Y.set(t,r),r}function ee(t,r){return z(r)(t)}function H(t,r,l){re(r)(t,l)}function pe(t){return t?(t.includes(".")?t.slice(t.lastIndexOf(".")+1):t).replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g,"$1 $2").replace(/\s+/g," ").trim().replace(/^./,l=>l.toUpperCase()):""}const x={"&":"&","<":"<",">":">",'"':""","'":"'"};function Q(t){const r=t==null?"":String(t);return/[&<>"']/.test(r)?r.replace(/[&<>"']/g,l=>x[l]):r}function ce(t){return String(t).replace(/\w\S*/g,r=>r[0].toUpperCase()+r.slice(1).toLowerCase())}function E(t,r,l){if(t!==void 0)return t===!0?{enabled:!0,...l}:t===!1?{enabled:!1}:p(t)?t:{[r]:t,enabled:!0}}function V(t){return t==null?[]:Array.isArray(t)?t:[t]}const h=Object.freeze(new Set(["__proto__","constructor","prototype"]));function a(t,r){if(!p(t))return p(r)?{...r}:r;if(!p(r))return r===void 0?t:r;const l={...t};for(const L of Object.keys(r)){if(h.has(L))continue;const M=r[L];M!==void 0&&(l[L]=p(M)&&p(l[L])?a(l[L],M):M)}return l}function d(t,r){if(!p(t)||!p(r)||t===r)return r;const l=Object.create(Object.getPrototypeOf(t));return Object.assign(l,t,r),l}class u{#r;#n=new Map;#l;constructor(r=256,l=null){this.#r=r,this.#l=l}get size(){return this.#n.size}get max(){return this.#r}set max(r){this.#r=r,this.#e()}has(r){return this.#n.has(r)}get(r){const l=this.#n;if(!l.has(r))return;const L=l.get(r);return l.delete(r),l.set(r,L),L}peek(r){return this.#n.get(r)}set(r,l){const L=this.#n;return L.has(r)&&L.delete(r),L.set(r,l),this.#e(),l}delete(r){const l=this.#n.get(r);return this.#n.delete(r)&&this.#l&&this.#l(l,r),l}clear(){if(this.#l)for(const[r,l]of this.#n)this.#l(l,r);this.#n.clear()}keys(){return this.#n.keys()}values(){return this.#n.values()}#e(){const r=this.#n;for(;r.size>this.#r;){const l=r.keys().next().value,L=r.get(l);r.delete(l),this.#l&&this.#l(L,l)}}}const m=new Map;function O(t,r){const l=`${t||""}|${r?JSON.stringify(r):""}`;let L=m.get(l);return L||(L=new Intl.Collator(t||void 0,{numeric:!0,sensitivity:"variant",...r}),m.set(l,L)),L}function A(t,r){if(t===r)return 0;if(t==null)return 1;if(r==null)return-1;if(typeof t=="number"&&typeof r=="number")return Number.isNaN(t)?Number.isNaN(r)?0:1:Number.isNaN(r)||t<r?-1:t>r?1:0;const l=String(t),L=String(r);return l<L?-1:l>L?1:0}function w(){return typeof performance<"u"&&performance.now?performance.now():Date.now()}const g=typeof requestAnimationFrame=="function";function f(t){return g?requestAnimationFrame(t):setTimeout(()=>t(w()),16)}function v(t){t!=null&&(g?cancelAnimationFrame(t):clearTimeout(t))}function F(t){let r=null,l=null;const L=()=>{r=null;const C=l;l=null,t(...C||[])},M=(...C)=>{l=C,r===null&&(r=f(L))};return M.cancel=()=>{v(r),r=null,l=null},M.flush=()=>{r!==null&&(v(r),L())},M}function b(t,r){let l=null,L=null;const M=()=>{if(l=null,L===null)return;const ue=L;L=null,t(...ue),C()},C=()=>{l=setTimeout(M,r),typeof l?.unref=="function"&&l.unref()},ne=(...ue)=>{l===null?(t(...ue),C()):(L=ue,clearTimeout(l),C())};return ne.flush=()=>{if(l!==null&&clearTimeout(l),l=null,L===null)return;const ue=L;L=null,t(...ue)},ne.cancel=()=>{l!==null&&clearTimeout(l),l=null,L=null},ne.pending=()=>l!==null||L!==null,ne}function e(t,r=50){return typeof requestIdleCallback=="function"?requestIdleCallback(t,{timeout:r}):setTimeout(()=>t({timeRemaining:()=>0,didTimeout:!0}),1)}let i=0;function n(t="l"){return`${t}${(++i).toString(36)}`}}),Qe("packages/modules/charts/scheme.js",function(o,X){"use strict";Object.defineProperty(o,"PALETTE",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"SCHEMES",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"registerScheme",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"setDefaultScheme",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"schemeNames",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"resolveScheme",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"RAMP_SCALES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"toRgb",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"rampStops",{enumerable:!0,get:function(){return p}});const q=X("packages/core/src/internal/util.js").warnOnce,j=Object.freeze(["#0072b2","#e69f00","#009e73","#cc79a7","#56b4e9","#d55e00","#7a5195","#6b7d8c"]),be=Object.freeze({default:{series:j,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"}}),me=new Map;let te="default";function J(s,c){!s||!c||me.set(String(s),c)}function W(s){if(typeof s=="string"){te=s;return}s&&typeof s=="object"&&(me.set("__default__",s),te="__default__")}function ie(){return[...Object.keys(be),...me.keys()].filter(s=>!s.startsWith("__"))}function S(s){return me.has(s)?me.get(s):be[s]||null}const y=["series","sequential","diverging","positive","negative"];function U(s){return!s||typeof s!="object"||Array.isArray(s)?!1:!y.some(c=>c in s)}function D(s){const c=S(te)||be.default,k=s&&s.scheme,R=U(k)?k:null,I=typeof k=="string"?S(k):R?null:k||null,z=s&&Array.isArray(s.palette)&&s.palette.length?s.palette:null;R&&z&&q("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 Y=R?null:z,re={...be.default,...c,...I||{}};Y&&(re.series=Y);const ee=s&&s.ramp&&typeof s.ramp=="object"&&!Array.isArray(s.ramp)?s.ramp:null,H=ee?ee.colours:s&&s.ramp,pe=Array.isArray(H)&&H.length>=2?H:null;pe&&(re.sequential=pe);const x=ee?B(ee.scale):null,Q=!!(I||Y||R),ce=re.series&&re.series.length?re.series:j,E=new Map;let V=0;return{...re,series:(a,d)=>{if(R&&d!==void 0&&d!==null){const u=String(d);return Object.prototype.hasOwnProperty.call(R,u)?R[u]:(E.has(u)||E.set(u,V++),_(ce,E.get(u),!0))}return _(ce,a,Q)},explicit:Q,nameMap:!!R,rampScale:x}}const T=Object.freeze(["linear","log","quantile"]);function B(s){return s==null?null:T.includes(s)?s:(q(`chart:ramp:scale:${String(s)}`,`chart "ramp.scale" was "${String(s)}", which is not a ramp scale; the chart chose one from its values instead. Use "linear", "log" or "quantile".`),null)}function _(s,c,k){const R=(c%s.length+s.length)%s.length;return k?s[R]:`var(--lattice-chart-${R+1}, ${s[R]})`}function $(s){if(typeof s!="string")return null;const c=s.trim(),k=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(c);if(k){const z=k[1];return z.length===3?[0,1,2].map(Y=>parseInt(z[Y]+z[Y],16)):[0,2,4].map(Y=>parseInt(z.slice(Y,Y+2),16))}const R=/^rgba?\(([^)]+)\)$/i.exec(c);if(!R)return null;const I=R[1].split(/[\s,/]+/).filter(Boolean).slice(0,3).map(Number);return I.length===3&&I.every(z=>Number.isFinite(z))?I:null}function p(s,c){const k=c?s.diverging:s.sequential,R=c?be.default.diverging:be.default.sequential,I=(Array.isArray(k)?k:R).map((z,Y)=>$(z)||$(R[Y])||[0,0,0]);return I.length>=2?I:R.map(z=>$(z))}}),Qe("packages/modules/charts/styles.js",function(o,X){"use strict";Object.defineProperty(o,"NS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"seriesColour",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"css",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"injectStyles",{enumerable:!0,get:function(){return J}});const q=X("packages/modules/charts/scheme.js").PALETTE,j="lat-chartview",be="data-lattice-chartview";function me(W){const ie=(W%q.length+q.length)%q.length;return`var(--lattice-chart-${ie+1}, ${q[ie]})`}function te(){return`
|
|
7
|
+
.${j}{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);
|
|
10
10
|
font-size:var(--lattice-font-size,13px);
|
|
11
11
|
color:var(--lattice-foreground,#1c2126);
|
|
12
12
|
background:var(--lattice-background,#fff);
|
|
13
|
-
--lattice-chart-1:${
|
|
14
|
-
--lattice-chart-3:${
|
|
15
|
-
--lattice-chart-5:${
|
|
16
|
-
--lattice-chart-7:${
|
|
13
|
+
--lattice-chart-1:${q[0]};--lattice-chart-2:${q[1]};
|
|
14
|
+
--lattice-chart-3:${q[2]};--lattice-chart-4:${q[3]};
|
|
15
|
+
--lattice-chart-5:${q[4]};--lattice-chart-6:${q[5]};
|
|
16
|
+
--lattice-chart-7:${q[6]};--lattice-chart-8:${q[7]};
|
|
17
17
|
--lattice-chart-grid:var(--lattice-border-color,#dfe3e6);
|
|
18
18
|
--lattice-chart-empty:var(--lattice-surface,#f7f8f9);
|
|
19
19
|
--lattice-chart-axis:var(--lattice-foreground-muted,#5b6670);
|
|
@@ -28,127 +28,127 @@
|
|
|
28
28
|
--lattice-chart-basemap-fill:#c3cfd6;
|
|
29
29
|
--lattice-chart-basemap-stroke:#456374;
|
|
30
30
|
--lattice-chart-basemap-stroke-width:0.75}
|
|
31
|
-
.${
|
|
31
|
+
.${j}__figure{margin:0;display:flex;flex-direction:column;flex:1 1 auto;min-height:0;
|
|
32
32
|
position:relative}
|
|
33
|
-
.${
|
|
34
|
-
.${
|
|
33
|
+
.${j}__caption{padding:2px 4px 6px;display:flex;flex-direction:column;gap:2px}
|
|
34
|
+
.${j}__title{font-weight:var(--lattice-header-font-weight,600);
|
|
35
35
|
font-size:var(--lattice-font-size,13px)}
|
|
36
|
-
.${
|
|
36
|
+
.${j}__subtitle{color:var(--lattice-foreground-muted,#5b6670);
|
|
37
37
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
38
|
-
.${
|
|
38
|
+
.${j}__footnote{color:var(--lattice-foreground-muted,#5b6670);
|
|
39
39
|
font-size:var(--lattice-font-size-sm,11px);padding:2px 4px 4px}
|
|
40
40
|
/* A label outside its mark sits on the chart's background and takes the axis
|
|
41
41
|
colour; one inside sits on the series colour and needs the contrast the
|
|
42
42
|
background gives it. */
|
|
43
|
-
.${
|
|
44
|
-
.${
|
|
45
|
-
.${
|
|
43
|
+
.${j}__data-label{fill:var(--lattice-chart-axis);pointer-events:none}
|
|
44
|
+
.${j}__data-label[data-inside="true"]{fill:var(--lattice-background,#fff)}
|
|
45
|
+
.${j}__plot{flex:1 1 auto;min-height:0;display:block;width:100%;height:100%;overflow:visible}
|
|
46
46
|
/* The plot is hidden while the empty state is up; the author display:block
|
|
47
47
|
above would otherwise keep an empty frame painted behind the message — the
|
|
48
48
|
mirror of the placeholder's own trap (BACKLOG-0001023). */
|
|
49
|
-
.${
|
|
50
|
-
.${
|
|
51
|
-
.${
|
|
49
|
+
.${j}__plot[hidden]{display:none}
|
|
50
|
+
.${j}__grid line{stroke:var(--lattice-chart-grid);stroke-width:1;shape-rendering:crispEdges}
|
|
51
|
+
.${j}__axis line{stroke:var(--lattice-chart-axis);stroke-width:1;shape-rendering:crispEdges}
|
|
52
52
|
/* Every tick label the axis drawers produce takes this fill regardless of
|
|
53
53
|
which paint group it lands in: a continuous x axis and a banded one both
|
|
54
|
-
draw into ${
|
|
55
|
-
bottom axis), only the measure and band-label axes draw into ${
|
|
54
|
+
draw into ${j}__overlay (BACKLOG-0001481/1470's z-order slot for the
|
|
55
|
+
bottom axis), only the measure and band-label axes draw into ${j}__axis
|
|
56
56
|
itself, and a selector scoped to the group left the overlay ones on the
|
|
57
57
|
SVG default (black) fill under a dark theme — invisible tick text that
|
|
58
58
|
read as "no x axis labels at all" (F-TRADE-P, BACKLOG-0001487). Scoped to
|
|
59
59
|
the class, not the group, so it is honoured wherever a tick is drawn now
|
|
60
60
|
or in the future. */
|
|
61
|
-
.${
|
|
61
|
+
.${j}__tick{fill:var(--lattice-chart-axis);
|
|
62
62
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
63
|
-
.${
|
|
63
|
+
.${j}__axis-title{fill:var(--lattice-chart-axis);
|
|
64
64
|
font-size:var(--lattice-font-size-sm,11px);font-weight:600}
|
|
65
|
-
.${
|
|
66
|
-
.${
|
|
67
|
-
.${
|
|
68
|
-
.${
|
|
69
|
-
.${
|
|
70
|
-
.${
|
|
65
|
+
.${j}__line{fill:none;stroke-width:2;stroke-linejoin:round;stroke-linecap:round}
|
|
66
|
+
.${j}__area{stroke:none;opacity:0.18}
|
|
67
|
+
.${j}__bar,.${j}__slice{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
68
|
+
.${j}__point{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
69
|
+
.${j}__mark[data-dim]{opacity:0.18}
|
|
70
|
+
.${j}__brush{fill:var(--lattice-range-background,#e7f1fd);fill-opacity:0.5;
|
|
71
71
|
stroke:var(--lattice-range-border,#1a6bc7);stroke-width:1;pointer-events:none}
|
|
72
|
-
.${
|
|
73
|
-
.${
|
|
72
|
+
.${j}__plot:focus{outline:none}
|
|
73
|
+
.${j}__plot:focus-visible{outline:var(--lattice-focus-width,2px) solid var(--lattice-focus-color,#1a6bc7);
|
|
74
74
|
outline-offset:-2px}
|
|
75
|
-
.${
|
|
76
|
-
.${
|
|
75
|
+
.${j}__mark:focus{outline:none}
|
|
76
|
+
.${j}__mark:focus-visible{outline:var(--lattice-focus-width,2px) solid var(--lattice-focus-color,#1a6bc7);
|
|
77
77
|
outline-offset:1px}
|
|
78
|
-
.${
|
|
79
|
-
.${
|
|
80
|
-
.${
|
|
81
|
-
.${
|
|
82
|
-
.${
|
|
83
|
-
.${
|
|
84
|
-
.${
|
|
85
|
-
.${
|
|
86
|
-
.${
|
|
87
|
-
.${
|
|
88
|
-
.${
|
|
89
|
-
.${
|
|
90
|
-
.${
|
|
91
|
-
.${
|
|
92
|
-
.${
|
|
93
|
-
.${
|
|
94
|
-
.${
|
|
95
|
-
.${
|
|
96
|
-
.${
|
|
97
|
-
.${
|
|
98
|
-
.${
|
|
99
|
-
.${
|
|
100
|
-
.${
|
|
101
|
-
.${
|
|
102
|
-
.${
|
|
103
|
-
.${
|
|
78
|
+
.${j}__box{stroke-width:1}
|
|
79
|
+
.${j}__whisker{stroke-width:1;fill:none}
|
|
80
|
+
.${j}__density{stroke-width:1.5;fill:none;opacity:.85}
|
|
81
|
+
.${j}__fit{stroke-width:1.5;fill:none;opacity:.9}
|
|
82
|
+
.${j}__fit-label{font-weight:600;opacity:.9}
|
|
83
|
+
.${j}__trend{stroke-width:1.75;fill:none;opacity:.9}
|
|
84
|
+
.${j}__trend-forecast{stroke-width:1.75;fill:none;opacity:.9;stroke-dasharray:5 4}
|
|
85
|
+
.${j}__trend-label{font-weight:600;opacity:.9}
|
|
86
|
+
.${j}__trend-band{stroke:none;pointer-events:none}
|
|
87
|
+
.${j}__qq-line{stroke:var(--lattice-foreground-muted,#5b6570);stroke-width:1;stroke-dasharray:4 3;fill:none}
|
|
88
|
+
.${j}__ecdf{stroke-width:1.5;fill:none}
|
|
89
|
+
.${j}__control-line{stroke-width:1.25;fill:none}
|
|
90
|
+
.${j}__error-bar{stroke:var(--lattice-foreground,#1a1a1a);stroke-width:1.5;fill:none;stroke-linecap:round}
|
|
91
|
+
.${j}__control-centre{stroke:var(--lattice-foreground-muted,#5b6570);stroke-width:1;fill:none}
|
|
92
|
+
.${j}__control-limit{stroke:var(--lattice-foreground-muted,#5b6570);stroke-width:1;stroke-dasharray:6 3;fill:none}
|
|
93
|
+
.${j}__spec-limit{stroke:var(--lattice-variant-danger-solid,#a4262c);stroke-width:1;stroke-dasharray:2 3;fill:none}
|
|
94
|
+
.${j}__spec-target{stroke:var(--lattice-variant-success-solid,#107c41);stroke-width:1;stroke-dasharray:1 4;fill:none}
|
|
95
|
+
.${j}__control-name{fill:var(--lattice-foreground-muted,#5b6570);font-size:9px;letter-spacing:.04em}
|
|
96
|
+
.${j}__control-rule{fill:var(--lattice-variant-danger-solid,#a4262c);font-size:9px;font-weight:600}
|
|
97
|
+
.${j}__capability-within{stroke:var(--lattice-foreground,#1a1a1a);stroke-width:1.5;fill:none}
|
|
98
|
+
.${j}__capability-overall{stroke:var(--lattice-foreground-muted,#5b6570);stroke-width:1.5;stroke-dasharray:4 3;fill:none}
|
|
99
|
+
.${j}__lorenz{stroke-width:1.75;fill:none}
|
|
100
|
+
.${j}__lorenz-equality{stroke:var(--lattice-foreground-muted,#5b6570);stroke-width:1;stroke-dasharray:4 3;fill:none}
|
|
101
|
+
.${j}__median{fill:none}
|
|
102
|
+
.${j}__tile{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
103
|
+
.${j}__tile-label{fill:var(--lattice-background,#fff);
|
|
104
104
|
font-size:var(--lattice-font-size-sm,11px);pointer-events:none}
|
|
105
|
-
.${
|
|
106
|
-
.${
|
|
107
|
-
.${
|
|
105
|
+
.${j}__tile-label--branch{fill:var(--lattice-foreground,#1d2733)}
|
|
106
|
+
.${j}__reference{stroke:var(--lattice-chart-axis);stroke-width:1}
|
|
107
|
+
.${j}__reference-label{fill:var(--lattice-chart-axis);
|
|
108
108
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
109
|
-
.${
|
|
110
|
-
.${
|
|
111
|
-
.${
|
|
112
|
-
.${
|
|
113
|
-
.${
|
|
114
|
-
.${
|
|
115
|
-
.${
|
|
109
|
+
.${j}__annotation-line{stroke:var(--lattice-chart-axis);stroke-width:1;stroke-dasharray:4 3;fill:none}
|
|
110
|
+
.${j}__annotation-target{stroke:var(--lattice-variant-success-solid,#107c41);stroke-width:1.5;stroke-dasharray:2 2;fill:none}
|
|
111
|
+
.${j}__annotation-band{stroke:none}
|
|
112
|
+
.${j}__annotation-point{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
113
|
+
.${j}__annotation-event{stroke:var(--lattice-chart-axis);stroke-width:1;fill:none}
|
|
114
|
+
.${j}__annotation-event-flag{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
115
|
+
.${j}__annotation-label{fill:var(--lattice-chart-axis);
|
|
116
116
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
117
|
-
.${
|
|
117
|
+
.${j}__annotation-list{list-style:none;margin:0;padding:0;
|
|
118
118
|
position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0)}
|
|
119
119
|
/* The interactive drawing layer and its rail (BACKLOG-0001474). Every colour is
|
|
120
120
|
a token with a literal fallback, the same rule the rest of this sheet follows,
|
|
121
121
|
so a drawing keeps its contrast when the grid's theme flips to dark: the
|
|
122
122
|
strokes take the foreground rather than a fixed near-black, and the handles
|
|
123
123
|
are knocked out of the background rather than painted white. */
|
|
124
|
-
.${
|
|
125
|
-
.${
|
|
124
|
+
.${j}--annotate-left{flex-direction:row}
|
|
125
|
+
.${j}__annotate-rail{display:flex;gap:2px;padding:3px;align-items:flex-start;
|
|
126
126
|
background:var(--lattice-surface,#f7f8f9);
|
|
127
127
|
border:1px solid var(--lattice-border-color,#dfe3e6);border-radius:4px}
|
|
128
|
-
.${
|
|
129
|
-
.${
|
|
130
|
-
.${
|
|
128
|
+
.${j}__annotate-rail--left{flex-direction:column;margin-right:4px}
|
|
129
|
+
.${j}__annotate-rail--top{flex-direction:row;margin-bottom:4px}
|
|
130
|
+
.${j}__annotate-tool{display:inline-flex;align-items:center;justify-content:center;
|
|
131
131
|
width:22px;height:22px;padding:0;border:1px solid transparent;border-radius:3px;
|
|
132
132
|
background:transparent;color:var(--lattice-foreground,#1c2126);cursor:pointer}
|
|
133
|
-
.${
|
|
134
|
-
.${
|
|
133
|
+
.${j}__annotate-tool:hover{background:var(--lattice-hovered-background,#eef1f4)}
|
|
134
|
+
.${j}__annotate-tool:focus-visible{outline:var(--lattice-focus-width,2px) solid
|
|
135
135
|
var(--lattice-focus-color,#1a6bc7);outline-offset:1px}
|
|
136
|
-
.${
|
|
136
|
+
.${j}__annotate-tool[aria-pressed="true"]{background:var(--lattice-range-background,#e7f1fd);
|
|
137
137
|
border-color:var(--lattice-range-border,#1a6bc7)}
|
|
138
|
-
.${
|
|
138
|
+
.${j}__annotate-icon{width:14px;height:14px;fill:none;stroke:currentColor;
|
|
139
139
|
stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}
|
|
140
|
-
.${
|
|
140
|
+
.${j}__annotate-input{position:absolute;z-index:6;min-width:120px;padding:2px 4px;
|
|
141
141
|
font:inherit;color:var(--lattice-foreground,#1c2126);
|
|
142
142
|
background:var(--lattice-background,#fff);
|
|
143
143
|
border:1px solid var(--lattice-focus-color,#1a6bc7);border-radius:3px}
|
|
144
|
-
.${
|
|
145
|
-
.${
|
|
146
|
-
.${
|
|
144
|
+
.${j}__drawn-line{stroke:var(--lattice-foreground,#1c2126);stroke-width:1.5;fill:none}
|
|
145
|
+
.${j}__drawn-fill{stroke:none;fill:var(--lattice-foreground,#1c2126);fill-opacity:0.1}
|
|
146
|
+
.${j}__drawn-dot{fill:var(--lattice-foreground,#1c2126);
|
|
147
147
|
stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
148
|
-
.${
|
|
148
|
+
.${j}__drawn-label{fill:var(--lattice-foreground,#1c2126);
|
|
149
149
|
font-size:var(--lattice-font-size-sm,11px);paint-order:stroke;
|
|
150
150
|
stroke:var(--lattice-background,#fff);stroke-width:3px;stroke-linejoin:round}
|
|
151
|
-
.${
|
|
151
|
+
.${j}__drawn-handle{fill:var(--lattice-background,#fff);
|
|
152
152
|
stroke:var(--lattice-focus-color,#1a6bc7);stroke-width:1.5}
|
|
153
153
|
/* The zoom toolbar (BACKLOG-0001473). It floats over the bottom edge of the
|
|
154
154
|
plot rather than taking a row of its own, because a strip that reflowed the
|
|
@@ -156,127 +156,134 @@
|
|
|
156
156
|
The hover variant fades with opacity, never with visibility or display: a
|
|
157
157
|
hidden button is not focusable, so a keyboard user could never reach the
|
|
158
158
|
control that reveals it, and :focus-within is what shows it to them. */
|
|
159
|
-
.${
|
|
159
|
+
.${j}__zoom-bar{position:absolute;left:50%;transform:translateX(-50%);bottom:2px;
|
|
160
160
|
z-index:5;display:flex;gap:2px;padding:2px;
|
|
161
161
|
background:var(--lattice-surface,#f7f8f9);
|
|
162
162
|
border:1px solid var(--lattice-border-color,#dfe3e6);border-radius:4px}
|
|
163
|
-
.${
|
|
164
|
-
.${
|
|
165
|
-
.${
|
|
166
|
-
@media (prefers-reduced-motion:reduce){.${
|
|
167
|
-
.${
|
|
163
|
+
.${j}__zoom-bar--hover{opacity:0;transition:opacity 120ms ease-in-out}
|
|
164
|
+
.${j}:hover .${j}__zoom-bar--hover,
|
|
165
|
+
.${j}__zoom-bar--hover:focus-within{opacity:1}
|
|
166
|
+
@media (prefers-reduced-motion:reduce){.${j}__zoom-bar--hover{transition:none}}
|
|
167
|
+
.${j}__zoom-button{display:inline-flex;align-items:center;justify-content:center;
|
|
168
168
|
width:22px;height:22px;padding:0;border:1px solid transparent;border-radius:3px;
|
|
169
169
|
background:transparent;color:var(--lattice-foreground,#1c2126);cursor:pointer}
|
|
170
|
-
.${
|
|
171
|
-
.${
|
|
170
|
+
.${j}__zoom-button:hover{background:var(--lattice-hovered-background,#eef1f4)}
|
|
171
|
+
.${j}__zoom-button:focus-visible{outline:var(--lattice-focus-width,2px) solid
|
|
172
172
|
var(--lattice-focus-color,#1a6bc7);outline-offset:1px}
|
|
173
|
-
.${
|
|
174
|
-
.${
|
|
173
|
+
.${j}__zoom-button[disabled]{opacity:0.4;cursor:default}
|
|
174
|
+
.${j}__zoom-icon{width:14px;height:14px;fill:none;stroke:currentColor;
|
|
175
175
|
stroke-width:1.4;stroke-linecap:round;stroke-linejoin:round}
|
|
176
|
-
.${
|
|
177
|
-
.${
|
|
178
|
-
.${
|
|
179
|
-
.${
|
|
176
|
+
.${j}__ribbon{stroke:none;fill-opacity:0.62}
|
|
177
|
+
.${j}__ribbon:hover{fill-opacity:0.85}
|
|
178
|
+
.${j}__node{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
179
|
+
.${j}__edge{stroke:var(--lattice-chart-grid);stroke-opacity:0.7}
|
|
180
180
|
/* A node's glyph, knocked out of its disc in the chart's own background colour
|
|
181
181
|
so it takes the theme rather than a colour written into the drawing. Drawn as
|
|
182
182
|
SVG paths from the grid's sprite registry, so it is sharp at any chart size
|
|
183
183
|
and any device pixel ratio. */
|
|
184
|
-
.${
|
|
185
|
-
.${
|
|
184
|
+
.${j}__node-icon{fill:var(--lattice-background,#fff);stroke:none;pointer-events:none}
|
|
185
|
+
.${j}__node-icon--stroke{fill:none;stroke:var(--lattice-background,#fff);
|
|
186
186
|
stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
|
|
187
|
-
.${
|
|
188
|
-
.${
|
|
189
|
-
.${
|
|
190
|
-
.${
|
|
191
|
-
.${
|
|
192
|
-
.${
|
|
193
|
-
.${
|
|
194
|
-
.${
|
|
195
|
-
.${
|
|
196
|
-
.${
|
|
197
|
-
.${
|
|
187
|
+
.${j}__node-icon[data-dim]{opacity:0.18}
|
|
188
|
+
.${j}__flow-label{fill:var(--lattice-chart-axis);pointer-events:none}
|
|
189
|
+
.${j}__stream{stroke:none}
|
|
190
|
+
.${j}__violin{stroke:none;fill-opacity:0.55}
|
|
191
|
+
.${j}__task{stroke:var(--lattice-background,#fff);stroke-width:1;rx:2}
|
|
192
|
+
.${j}__web{stroke:var(--lattice-chart-grid);fill:none}
|
|
193
|
+
.${j}__radar-fill{opacity:0.18;stroke:none}
|
|
194
|
+
.${j}__radar-line{stroke-width:2;fill:none}
|
|
195
|
+
.${j}__gauge-track{fill:var(--lattice-chart-grid)}
|
|
196
|
+
.${j}__gauge-target{stroke:var(--lattice-foreground,#1c2126);stroke-width:2}
|
|
197
|
+
.${j}__gauge-reading{fill:var(--lattice-foreground,#1c2126);
|
|
198
198
|
font-size:calc(var(--lattice-font-size,13px) * 1.8);font-weight:600}
|
|
199
|
-
.${
|
|
199
|
+
.${j}__gauge-caption{fill:var(--lattice-chart-axis);
|
|
200
200
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
201
|
-
.${
|
|
202
|
-
.${
|
|
203
|
-
.${
|
|
201
|
+
.${j}__cell{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
202
|
+
.${j}__funnel{stroke:var(--lattice-background,#fff);stroke-width:1}
|
|
203
|
+
.${j}__funnel-label,.${j}__funnel-value{fill:var(--lattice-foreground,#1c2126);
|
|
204
204
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
205
|
-
.${
|
|
206
|
-
.${
|
|
207
|
-
.${
|
|
208
|
-
.${
|
|
205
|
+
.${j}__wick{stroke-width:1}
|
|
206
|
+
.${j}__candle{stroke-width:1}
|
|
207
|
+
.${j}__axis-right{stroke-width:1}
|
|
208
|
+
.${j}__panel-title{fill:var(--lattice-chart-axis);
|
|
209
209
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
210
|
-
.${
|
|
210
|
+
.${j}__region{stroke:var(--lattice-chart-map-stroke,var(--lattice-chart-grid,#dfe3e6));
|
|
211
211
|
stroke-width:0.5;vector-effect:non-scaling-stroke}
|
|
212
|
-
.${
|
|
212
|
+
.${j}__graticule{fill:none;stroke:var(--lattice-chart-grid,#dfe3e6);stroke-width:0.5;
|
|
213
213
|
stroke-opacity:0.6;vector-effect:non-scaling-stroke;pointer-events:none}
|
|
214
|
-
.${
|
|
214
|
+
.${j}__geo-note{fill:var(--lattice-chart-axis);
|
|
215
215
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
216
|
-
.${
|
|
216
|
+
.${j}__attribution{color:var(--lattice-foreground-muted,#5b6670);
|
|
217
217
|
font-size:var(--lattice-font-size-sm,11px);padding:0 4px 4px}
|
|
218
|
-
.${
|
|
219
|
-
.${
|
|
218
|
+
.${j}__attribution[hidden]{display:none}
|
|
219
|
+
.${j}__slice-label{fill:var(--lattice-background,#fff);font-size:var(--lattice-font-size-sm,11px);
|
|
220
220
|
pointer-events:none;text-anchor:middle}
|
|
221
|
-
.${
|
|
221
|
+
.${j}__donut-centre-value{fill:var(--lattice-foreground,#1c2126);font-weight:600;
|
|
222
222
|
pointer-events:none;text-anchor:middle}
|
|
223
|
-
.${
|
|
223
|
+
.${j}__donut-centre-label{fill:var(--lattice-chart-axis);
|
|
224
224
|
pointer-events:none;text-anchor:middle}
|
|
225
|
-
.${
|
|
225
|
+
.${j}__legend{display:flex;flex-wrap:wrap;gap:2px 12px;padding:6px 4px 2px;
|
|
226
226
|
font-size:var(--lattice-font-size-sm,11px)}
|
|
227
|
-
.${
|
|
227
|
+
.${j}__legend-item{display:inline-flex;align-items:center;gap:5px;border:0;padding:1px 3px;
|
|
228
228
|
background:none;color:inherit;font:inherit;cursor:pointer;border-radius:3px}
|
|
229
|
-
.${
|
|
229
|
+
.${j}__legend-item:focus-visible{outline:var(--lattice-focus-width,2px) solid var(--lattice-focus-color,#1a6bc7);
|
|
230
230
|
outline-offset:1px}
|
|
231
|
-
.${
|
|
232
|
-
.${
|
|
233
|
-
.${
|
|
231
|
+
.${j}__legend-item[aria-pressed="false"]{opacity:0.45}
|
|
232
|
+
.${j}__swatch{width:10px;height:10px;border-radius:2px;flex:0 0 auto}
|
|
233
|
+
.${j}__swatch--circle{border-radius:50%}
|
|
234
234
|
/* A line swatch for a series drawn as a line: the symbol should say which mark
|
|
235
235
|
the reader is looking for, not merely which colour. */
|
|
236
|
-
.${
|
|
237
|
-
.${
|
|
238
|
-
.${
|
|
236
|
+
.${j}__swatch--line{height:3px;border-radius:2px}
|
|
237
|
+
.${j}__legend[data-align="centre"],.${j}__legend[data-align="center"]{justify-content:center}
|
|
238
|
+
.${j}__legend[data-align="end"]{justify-content:flex-end}
|
|
239
239
|
/* Top and bottom are the default row; the sides become a column beside the
|
|
240
240
|
plot, which is why the figure itself changes direction rather than the
|
|
241
241
|
legend floating over the marks. */
|
|
242
|
-
.${
|
|
243
|
-
.${
|
|
244
|
-
.${
|
|
245
|
-
.${
|
|
246
|
-
.${
|
|
242
|
+
.${j}__figure:has(> .${j}__legend[data-position="top"]){flex-direction:column}
|
|
243
|
+
.${j}__legend[data-position="top"]{order:-1}
|
|
244
|
+
.${j}__figure:has(> .${j}__legend[data-position="left"]),
|
|
245
|
+
.${j}__figure:has(> .${j}__legend[data-position="right"]){flex-direction:row;align-items:stretch}
|
|
246
|
+
.${j}__legend[data-position="left"],.${j}__legend[data-position="right"]{
|
|
247
247
|
flex-direction:column;flex:0 0 auto;align-content:flex-start;
|
|
248
248
|
max-width:40%;overflow:auto;padding:4px 8px}
|
|
249
|
-
.${
|
|
250
|
-
.${
|
|
251
|
-
.${
|
|
252
|
-
.${
|
|
253
|
-
.${
|
|
254
|
-
.${
|
|
255
|
-
.${
|
|
256
|
-
.${
|
|
257
|
-
.${
|
|
258
|
-
.${
|
|
259
|
-
.${
|
|
249
|
+
.${j}__legend[data-position="left"]{order:-1}
|
|
250
|
+
.${j}__legend-more{align-self:center;color:var(--lattice-foreground-muted,#5b6670)}
|
|
251
|
+
.${j}__legend-ramp{display:flex;align-items:center;gap:6px;flex:1 1 auto;min-width:60px}
|
|
252
|
+
.${j}__legend-ramp-bar{flex:1 1 auto;height:10px;min-width:32px;border-radius:2px}
|
|
253
|
+
.${j}__legend-ramp-label{white-space:nowrap;color:var(--lattice-foreground-muted,#5b6670)}
|
|
254
|
+
.${j}__legend-ramp-title{white-space:nowrap;font-weight:600}
|
|
255
|
+
.${j}__legend[data-position="left"] .${j}__legend-ramp,
|
|
256
|
+
.${j}__legend[data-position="right"] .${j}__legend-ramp{flex-direction:column;height:110px}
|
|
257
|
+
.${j}__legend[data-position="left"] .${j}__legend-ramp-bar,
|
|
258
|
+
.${j}__legend[data-position="right"] .${j}__legend-ramp-bar{width:10px;height:auto;min-width:0;min-height:32px}
|
|
259
|
+
.${j}__legend-ramp-bar{position:relative}
|
|
260
|
+
.${j}__legend-ramp[data-ticks]{padding-bottom:14px}
|
|
261
|
+
.${j}__legend-ramp-tick{position:absolute;top:100%;transform:translateX(-50%);padding-top:2px;line-height:1.1;white-space:nowrap;color:var(--lattice-foreground-muted,#5b6670)}
|
|
262
|
+
.${j}__legend[data-position="left"] .${j}__legend-ramp[data-ticks],
|
|
263
|
+
.${j}__legend[data-position="right"] .${j}__legend-ramp[data-ticks]{padding-bottom:0;padding-right:40px}
|
|
264
|
+
.${j}__legend[data-position="left"] .${j}__legend-ramp-tick,
|
|
265
|
+
.${j}__legend[data-position="right"] .${j}__legend-ramp-tick{top:auto;left:100%;transform:translateY(50%);padding:0 0 0 3px}
|
|
266
|
+
.${j}__tooltip{position:fixed;z-index:5;pointer-events:none;max-width:260px;
|
|
260
267
|
padding:5px 8px;border-radius:4px;font-size:var(--lattice-font-size-sm,11px);
|
|
261
268
|
background:var(--lattice-surface,#f7f8f9);color:var(--lattice-foreground,#1c2126);
|
|
262
269
|
border:1px solid var(--lattice-border-color,#dfe3e6);
|
|
263
270
|
box-shadow:var(--lattice-popup-shadow,0 6px 16px -4px rgb(16 20 24/24%))}
|
|
264
|
-
.${
|
|
265
|
-
.${
|
|
266
|
-
.${
|
|
267
|
-
.${
|
|
271
|
+
.${j}__tooltip[hidden]{display:none}
|
|
272
|
+
.${j}__tooltip-row{display:flex;align-items:center;gap:5px;white-space:nowrap}
|
|
273
|
+
.${j}__tooltip-value{font-weight:600;margin-inline-start:auto;padding-inline-start:10px}
|
|
274
|
+
.${j}__empty{display:flex;align-items:center;justify-content:center;flex:1 1 auto;
|
|
268
275
|
color:var(--lattice-foreground-muted,#5b6670)}
|
|
269
276
|
/* The author display:flex above outranks the browser's own [hidden] rule, so
|
|
270
277
|
without this the placeholder stays painted under a drawn chart whenever the
|
|
271
278
|
pane has a fixed height (BACKLOG-0001023). Same guard as the tooltip. */
|
|
272
|
-
.${
|
|
273
|
-
.${
|
|
279
|
+
.${j}__empty[hidden]{display:none}
|
|
280
|
+
.${j}__watermark{position:absolute;right:4px;bottom:4px;z-index:6;
|
|
274
281
|
font-size:var(--lattice-font-size-sm,11px);pointer-events:auto;
|
|
275
282
|
background:var(--lattice-overlay-background,rgb(255 255 255/72%));
|
|
276
283
|
padding:1px 6px;border-radius:3px}
|
|
277
|
-
.${
|
|
278
|
-
.${
|
|
279
|
-
.${
|
|
284
|
+
.${j}__watermark-link{color:var(--lattice-foreground-muted,#5b6670);text-decoration:none}
|
|
285
|
+
.${j}__watermark-link:hover{text-decoration:underline}
|
|
286
|
+
.${j}__table{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;
|
|
280
287
|
clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}
|
|
281
288
|
|
|
282
289
|
/* The dark series palette, on the NEAREST data-theme (BACKLOG-0001462): the
|
|
@@ -286,22 +293,22 @@
|
|
|
286
293
|
theme auto. Everything else in this sheet already reads the grid's tokens,
|
|
287
294
|
which the same switch darkens. */
|
|
288
295
|
@scope ([data-theme="dark"]){
|
|
289
|
-
:scope.${
|
|
296
|
+
:scope.${j},.${j}{
|
|
290
297
|
--lattice-chart-1:#4ea6dd;--lattice-chart-2:#f0b429;--lattice-chart-3:#34c79a;
|
|
291
298
|
--lattice-chart-4:#e39ec4;--lattice-chart-5:#7cc7f0;--lattice-chart-6:#f07c3f;
|
|
292
299
|
--lattice-chart-7:#a48ad4;--lattice-chart-8:#93a3b1;
|
|
293
300
|
--lattice-chart-basemap-fill:#3a4a55;--lattice-chart-basemap-stroke:#8fb0c2;color-scheme:dark}
|
|
294
301
|
}
|
|
295
302
|
@scope ([data-theme="light"],[data-theme="auto"]){
|
|
296
|
-
:scope.${
|
|
297
|
-
--lattice-chart-1:${
|
|
298
|
-
--lattice-chart-3:${
|
|
299
|
-
--lattice-chart-5:${
|
|
300
|
-
--lattice-chart-7:${
|
|
303
|
+
:scope.${j},.${j}{
|
|
304
|
+
--lattice-chart-1:${q[0]};--lattice-chart-2:${q[1]};
|
|
305
|
+
--lattice-chart-3:${q[2]};--lattice-chart-4:${q[3]};
|
|
306
|
+
--lattice-chart-5:${q[4]};--lattice-chart-6:${q[5]};
|
|
307
|
+
--lattice-chart-7:${q[6]};--lattice-chart-8:${q[7]};color-scheme:light}
|
|
301
308
|
}
|
|
302
309
|
@media (prefers-color-scheme: dark){
|
|
303
310
|
@scope ([data-theme="auto"]){
|
|
304
|
-
:scope.${
|
|
311
|
+
:scope.${j},.${j}{
|
|
305
312
|
--lattice-chart-1:#4ea6dd;--lattice-chart-2:#f0b429;--lattice-chart-3:#34c79a;
|
|
306
313
|
--lattice-chart-4:#e39ec4;--lattice-chart-5:#7cc7f0;--lattice-chart-6:#f07c3f;
|
|
307
314
|
--lattice-chart-7:#a48ad4;--lattice-chart-8:#93a3b1;
|
|
@@ -310,8 +317,8 @@
|
|
|
310
317
|
}
|
|
311
318
|
|
|
312
319
|
@media (prefers-reduced-motion: no-preference){
|
|
313
|
-
.${
|
|
314
|
-
.${
|
|
320
|
+
.${j}__line,.${j}__area{transition:d 160ms ease-out}
|
|
321
|
+
.${j}__bar{transition:x 160ms ease-out,y 160ms ease-out,width 160ms ease-out,height 160ms ease-out}
|
|
315
322
|
}
|
|
316
323
|
|
|
317
324
|
@media (forced-colors: active){
|
|
@@ -319,14 +326,14 @@
|
|
|
319
326
|
meaning entirely. What survives is position, the stroke that separates one
|
|
320
327
|
mark from the next, and the label, which is why the legend carries text
|
|
321
328
|
and the tooltip names its series rather than relying on a swatch. */
|
|
322
|
-
.${
|
|
323
|
-
.${
|
|
324
|
-
.${
|
|
325
|
-
.${
|
|
326
|
-
.${
|
|
329
|
+
.${j}__bar,.${j}__slice,.${j}__point{fill:CanvasText;stroke:Canvas;stroke-width:1}
|
|
330
|
+
.${j}__line{stroke:CanvasText}
|
|
331
|
+
.${j}__area{fill:CanvasText;opacity:0.12}
|
|
332
|
+
.${j}__swatch{border:1px solid CanvasText}
|
|
333
|
+
.${j}__mark[data-dim]{opacity:1;fill:GrayText}
|
|
327
334
|
}
|
|
328
|
-
`}function Z(H){const ue=H.documentElement;if(!ue||ue.getAttribute(pe))return;ue.setAttribute(pe,"1");const P=H.createElement("style");P.textContent=te(),(H.head||H.body||ue).appendChild(P)}}),Je("packages/modules/charts/scale.js",function(o,Y){"use strict";Object.defineProperty(o,"isNumber",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"toNumber",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"toTime",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"extent",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"niceStep",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"niceDomain",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureDomain",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"linearTicks",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"timeStepFor",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"timeTicks",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"linearScale",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"timeScale",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"key",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"bandScale",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"sqrtScale",{enumerable:!0,get:function(){return F}});const ke=[1,2,2.5,5,10],Q=6e4,$=36e5,pe=864e5,me=365.25*pe,te=[1,2,5,10,20,25,50,100],Z=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,Q,5*Q,15*Q,30*Q,$,3*$,6*$,12*$,pe,2*pe,7*pe,14*pe,30*pe,90*pe,180*pe,...te.map(_=>_*me)];function H(_){return typeof _=="number"&&Number.isFinite(_)}function ue(_){if(_==null||_==="")return null;if(_ instanceof Date){const re=_.getTime();return Number.isFinite(re)?re:null}if(typeof _=="boolean")return _?1:0;const J=Number(_);return Number.isFinite(J)?J:null}function P(_){if(_==null||_==="")return null;if(_ instanceof Date){const re=_.getTime();return Number.isFinite(re)?re:null}if(typeof _=="number")return Number.isFinite(_)?_:null;const J=Date.parse(String(_));return Number.isFinite(J)?J:null}function y(_){let J=1/0,re=-1/0;for(let q=0;q<_.length;q++){const U=_[q];H(U)&&(U<J&&(J=U),U>re&&(re=U))}return J===1/0?null:{min:J,max:re}}function B(_){if(!(_>0))return 1;const J=10**Math.floor(Math.log10(_));for(const re of ke)if(_<=re*J)return re*J;return 10*J}function D(_,J=5){const re=B((_.max-_.min)/Math.max(1,J));return{min:Math.floor(_.min/re)*re,max:Math.ceil(_.max/re)*re,step:re}}function I(_,J={}){const re=y(_)||{min:0,max:1};let{min:q,max:U}=re;if(J.zero&&(q>0&&(q=0),U<0&&(U=0)),q===U){const ge=Math.abs(q)>0?Math.abs(q)/10:1;q-=ge,U+=ge}if(J.nice!==!1){const ge=D({min:q,max:U},J.ticks||5);q=ge.min,U=ge.max}return H(J.min)&&(q=J.min),H(J.max)&&(U=J.max),q===U&&(U=q+1),{min:q,max:U}}function G(_,J=5){const re=B((_.max-_.min)/Math.max(1,J)),q=Math.ceil(_.min/re),U=Math.floor(_.max/re),ge=[];for(let A=q;A<=U;A++){const X=A*re;ge.push(Math.abs(X)<re/1e6?0:Number(X.toPrecision(12)))}return ge}function z(_,J=5){const re=Math.max(1,J),q=_/re;let U=Z[Z.length-1];for(const X of Z)if(X>=q){U=X;break}if(U<me)return U;let ge=U,A=Math.abs(_/U-re);for(const X of Z){if(X<me)continue;const ce=Math.abs(_/X-re);ce<A&&(A=ce,ge=X)}return ge}function x(_,J){const re=new Date(_.min).getUTCFullYear();let q=Math.ceil(re/J)*J;Date.UTC(q,0,1)<_.min&&(q+=J);const U=[];for(;Date.UTC(q,0,1)<=_.max;q+=J)U.push(Date.UTC(q,0,1));return U}function b(_,J=5){const re=z(_.max-_.min,J);if(re>=me)return x(_,Math.round(re/me));const q=[],U=Math.ceil(_.min/re)*re;for(let ge=U;ge<=_.max;ge+=re)q.push(ge);return q}function f(_,J){const re=_.max-_.min||1,[q,U]=J;return{kind:"linear",domain:_,range:J,of(ge){return q+(ge-_.min)/re*(U-q)},invert(ge){return _.min+(ge-q)/(U-q||1)*re},ticks(ge=5){return G(_,ge)}}}function l(_,J){return{...f(_,J),kind:"time",ticks(q=5){return b(_,q)}}}function v(_){if(_==null)return" null";if(_ instanceof Date)return` date:${_.getTime()}`;if(typeof _=="object"){const J=_,re=J.id??J.key??J.value;return re!==void 0&&typeof re!="object"?` obj:${String(re)}`:` obj:${String(_)}`}return String(_)}function C(_,J,re=.2){const q=Math.min(.9,Math.max(0,re)),[U,ge]=J,A=new Map;for(let E=0;E<_.length;E++){const W=v(_[E]);A.has(W)||A.set(W,E)}const X=_.length?(ge-U)/_.length:ge-U,ce=Math.max(0,X*(1-q));return{kind:"band",domain:_,range:J,bandwidth:ce,step:X,of(E){const W=A.get(v(E));return W===void 0?NaN:U+W*X+(X-ce)/2},centre(E){const W=this.of(E);return Number.isNaN(W)?NaN:W+ce/2},ticks(){return _}}}function F(_,J){const[re,q]=J,U=Math.max(Math.abs(_.max),Math.abs(_.min),0)||1;return{kind:"sqrt",domain:_,range:J,of(ge){const A=Math.sqrt(Math.abs(ge)/U);return re+A*(q-re)}}}}),Je("packages/modules/charts/axis.js",function(o,Y){"use strict";Object.defineProperty(o,"pinXDomain",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"TICK_FLOOR",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"tickFloor",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"fitBandLabels",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"normaliseAxes",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"tickValues",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"tickLabeller",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"drawAxisTitle",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"labelEvery",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"drawMeasureAxis",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"drawCategoryAxis",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"leftLabelRoom",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"setLabelText",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"drawBandLabels",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"drawContinuousAxis",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"drawAxisLines",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"createGroups",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"MARK_OVERHANG",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"overhangFor",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"setPlotClip",{enumerable:!0,get:function(){return w}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/svg.js"),pe=$.attrs,me=$.round,te=$.setText,Z=$.svg,H=Y("packages/modules/charts/typography.js"),ue=H.applySize,P=H.CHAR_RATIO,y=H.truncateTo,D=Y("packages/modules/charts/styles.js").NS,I=Y("packages/modules/charts/scale.js"),G=I.toNumber,z=I.toTime,b=Y("packages/core/src/internal/util.js").warnOnce;function f(m,u,k){const R=u&&u.kind==="time"?z:G,p=a=>a==null||a===""?null:R(a),e=p(k&&k.min),i=p(k&&k.max);if(e===null&&i===null)return m;if(e!==null&&i!==null)return e<i?{min:e,max:i}:(b("chart.axis.x.domain.inverted",`axis.x.min (${e}) is not below axis.x.max (${i}), which is a mirrored axis rather than a narrow one, so both were ignored and the x domain was taken from the data. On a time axis both are epoch milliseconds.`),m);const n=e!==null?e:m.min,t=i!==null?i:m.max;if(n<t)return{min:n,max:t};const r=Math.abs(m.max-m.min)||1;return b("chart.axis.x.domain.beyond",`axis.x.${e!==null?"min":"max"} is outside the x values entirely, so the plot is empty. The pin was kept and the other edge moved to hold the axis width; check the units (a time axis is pinned in epoch milliseconds).`),e!==null?{min:n,max:n+r}:{min:t-r,max:t}}const l=6,v=9;function C(m){const u=m&&m.ownerDocument,k=u&&u.defaultView;if(!k||typeof k.getComputedStyle!="function")return v;const R=k.getComputedStyle(m).getPropertyValue("--lattice-chart-tick-min"),p=parseFloat(R);return Number.isFinite(p)&&p>0?p:v}function F(m){const{size:u,floor:k,slot:R,per:p}=m,e=Number.isFinite(m.every)&&m.every>0?Number(m.every):null;if(e!==null&&e!==1)return{size:u,every:e,thinned:!1};if(!(R>0)||!(p>0))return{size:u,every:1,thinned:!1};const i=Math.min(u,R/p);return i>=k?{size:i,every:1,thinned:!1}:{size:k,every:Math.max(1,Math.ceil(k*p/R)),thinned:!0}}function _(m,u){const k=Math.ceil(m/u),R=m-k;b("chart.axis.band.thinned",`${R} of ${m} band labels were hidden: even the smallest font (--lattice-chart-tick-min) could not make them all fit. Set axis.x.every or axis.y.every to choose which ones show.`)}const J=1.2;function re(m){if(m===!1){const R={labels:!1,grid:!1};return{x:{...R},y:{...R},y2:{...R}}}const u=m&&typeof m=="object"?m:{},k=R=>typeof R=="string"?{title:R}:R&&typeof R=="object"?{...R}:{};return{x:k(u.x),y:k(u.y),y2:k(u.y2||u.right)}}function q(m,u){const k=u&&u.ticks;if(Array.isArray(k)){const p=m.domain;return!p||p.min===void 0?k:k.filter(e=>Number(e)>=p.min&&Number(e)<=p.max)}const R=Number.isFinite(k)&&k>0?Number(k):5;return m.ticks(R)}function U(m,u,k,R){const p=m&&m.format;return typeof p=="function"?e=>String(p(e)):typeof p=="string"&&k&&k.formatting&&k.formatting.format?e=>String(k.formatting.format(e,p)):R&&R.format&&R.format.pattern&&typeof R.formatValue=="function"?e=>String(R.formatValue(e,null)):u.tick}function ge(m){if(!m.text)return;const u=m.side==="left"||m.side==="right"?m.plot.height:m.plot.width,k=Number.isFinite(u)?y(String(m.text),Math.max(0,u),m.size):String(m.text);if(!k||k==="…")return;const R=Z(m.group.ownerDocument,"text",{class:`${D}__axis-title`});if(ue(R,m.size),m.side==="left"){const p=Math.max(m.size,m.plot.left-m.plot.gutter.left+m.size),e=m.plot.top+m.plot.height/2;pe(R,{transform:`translate(${me(p)} ${me(e)}) rotate(-90)`,"text-anchor":"middle"})}else if(m.side==="right"){const p=m.plot.right+m.plot.gutter.right-m.size,e=m.plot.top+m.plot.height/2;pe(R,{transform:`translate(${me(p)} ${me(e)}) rotate(90)`,"text-anchor":"middle"})}else pe(R,{x:me(m.plot.left+m.plot.width/2),y:me(m.plot.bottom+m.plot.gutter.bottom-2),"text-anchor":"middle"});te(R,k),k!==String(m.text)&&R.setAttribute("aria-label",String(m.text)),m.group.appendChild(R)}function A(m){const{values:u,scale:k,size:R,horizontal:p,label:e}=m;if(u.length<2)return 1;let i=1/0;for(let t=1;t<u.length;t++){const r=Math.abs(k.of(u[t])-k.of(u[t-1]));Number.isFinite(r)&&r<i&&(i=r)}if(!Number.isFinite(i))return 1;if(i<=0)return u.length;let n=R*J+2;if(p){let t=0;for(const r of u){const a=String(e(r)||"").length*R*P;a>t&&(t=a)}n=t+l}return Math.max(1,Math.ceil(n/i))}function X(m){const{gridGroup:u,axisGroup:k,plot:R,scale:p,format:e}=m,i=m.config||{},n=q(p,i),t=U(i,e,m.grid),r=m.size||11,a=A({values:n,scale:p,size:r,horizontal:!!m.horizontal,label:t}),T=i.grid===!1?null:u,M=T?new Q(T):null,L=new Q(k);for(let ee=0;ee<n.length;ee++){const fe=n[ee],de=me(p.of(fe)),Me=fe===0,ie=ee%a!==0;if(m.horizontal){if(M&&pe(M.next("line",`${D}__gridline`),{x1:de,x2:de,y1:me(R.top),y2:me(R.bottom),"stroke-opacity":Me?1:.6,"stroke-width":Me?1.5:1}),i.labels===!1||ie)continue;const ve=L.next("text",`${D}__tick`);ue(ve,r),pe(ve,{x:de,y:me(R.bottom+l),"text-anchor":"middle","dominant-baseline":"hanging"}),te(ve,t(fe))}else{if(M&&pe(M.next("line",`${D}__gridline`),{x1:me(R.left),x2:me(R.right),y1:de,y2:de,"stroke-opacity":Me?1:.6,"stroke-width":Me?1.5:1}),i.labels===!1||ie)continue;const ve=L.next("text",`${D}__tick`);ue(ve,r);const we=m.side==="right";pe(ve,{x:me(we?R.right+l:R.left-l),y:de,"text-anchor":we?"start":"end","dominant-baseline":"middle"}),te(ve,t(fe))}}return M?M.finish():new Q(u).finish(),L.finish(),n}function ce(m){const{group:u,plot:k,scale:R,labels:p}=m,e=m.config||{};if(e.labels===!1){new Q(u).finish();return}const i=new Q(u),n=R.domain,t=R.step,r=e.rotate===void 0||e.rotate==="auto"?m.rotated:!!e.rotate,a=r?F({size:m.fontSize,floor:C(u),slot:t,per:Math.SQRT2,every:e.every}):{size:m.fontSize,every:Number.isFinite(e.every)&&e.every>0?Number(e.every):1,thinned:!1},{size:T,every:M}=a;a.thinned&&_(n.length,M);const L=t*M;for(let ee=0;ee<n.length;ee++){const fe=me(R.centre(n[ee]));if(Number.isNaN(fe)||ee%M!==0)continue;const de=i.next("text",`${D}__tick`);ue(de,T);const Me=p[ee]===void 0?"":p[ee];r?(pe(de,{x:0,y:0,"text-anchor":"end","dominant-baseline":"middle",transform:`translate(${fe} ${me(k.bottom+l)}) rotate(-45)`}),W(de,Me,Math.max(0,k.gutter.bottom-l)*Math.SQRT2,T)):(pe(de,{x:fe,y:me(k.bottom+l),"text-anchor":"middle","dominant-baseline":"hanging",transform:null}),W(de,Me,L,T))}i.finish()}function E(m){return Math.max(0,(m.gutter?m.gutter.left:m.left)-l)}function W(m,u,k,R){const p=String(u??""),e=y(p,k,R);return te(m,e),e!==p?m.setAttribute("aria-label",p):m.removeAttribute("aria-label"),e}function h(m){const{group:u,plot:k,scale:R,labels:p}=m,e=m.config||{},i=new Q(u),n=R.domain,t=E(k),r=F({size:m.fontSize,floor:C(u),slot:R.step,per:J,every:e.every}),{size:a,every:T}=r;r.thinned&&_(n.length,T);for(let M=0;M<n.length;M++){if(M%T!==0)continue;const L=me(R.centre(n[M]));if(Number.isNaN(L))continue;const ee=i.next("text",`${D}__tick`);pe(ee,{x:me(k.left-l),y:L,"text-anchor":"end","dominant-baseline":"middle"}),ue(ee,a),W(ee,p[M],t,a)}i.finish()}function s(m){const{group:u,plot:k,scale:R,format:p}=m,e=m.config||{};if(e.labels===!1){new Q(u).finish();return}const i=U(e,p,m.grid,m.column),n=new Q(u);for(const t of q(R,e)){const r=me(R.of(t));if(r<k.left-1||r>k.right+1)continue;const a=n.next("text",`${D}__tick`);ue(a,m.size||11),pe(a,{x:r,y:me(k.bottom+l),"text-anchor":"middle","dominant-baseline":"hanging"}),te(a,i(t))}n.finish()}function g(m){const{group:u,plot:k}=m,R=m.side==="right"?k.right:k.left,p=new Q(u);pe(p.next("line"),{x1:me(R),x2:me(R),y1:me(k.top),y2:me(k.bottom)}),pe(p.next("line"),{x1:me(k.left),x2:me(k.right),y1:me(k.bottom),y2:me(k.bottom)}),p.finish()}let c=0;function d(m,u){const k=`${D}-plot-clip-${++c}`,R=Z(m,"rect"),p=Z(m,"clipPath",{id:k});p.appendChild(R);const e=`${D}-box-clip-${c}`,i=Z(m,"clipPath",{id:e});i.appendChild(Z(m,"rect",{x:0,y:0,width:"100%",height:"100%"}));const n=Z(m,"defs");n.appendChild(p),n.appendChild(i);const t={grid:Z(m,"g",{class:`${D}__grid`}),marks:Z(m,"g",{class:`${D}__marks`}),rules:Z(m,"g",{class:`${D}__axis`}),axis:Z(m,"g",{class:`${D}__axis`}),labels:Z(m,"g",{class:`${D}__labels`}),overlay:Z(m,"g",{class:`${D}__overlay`}),clip:R,clipId:k,boxClipId:e};u.appendChild(n);for(const r of["grid","marks","rules","axis","labels","overlay"])u.appendChild(t[r]);return t}const N=30;function S(m){return m==="bubble"?N:m==="scatter"?6:3}function w(m,u,k){if(!m||!m.marks||!m.clip)return;if(!u||!Number.isFinite(u.width)||!Number.isFinite(u.height)){m.marks.removeAttribute("clip-path");return}const R=Number.isFinite(k)&&k>=0?Number(k):N;pe(m.clip,{x:me(u.left-R),y:me(u.top-R),width:me(Math.max(0,u.width)+R*2),height:me(Math.max(0,u.height)+R*2)}),m.marks.setAttribute("clip-path",`url(#${m.clipId})`)}}),Je("packages/modules/charts/format.js",function(o,Y){"use strict";Object.defineProperty(o,"precisionFor",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"axisNumber",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"r2Digits",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"dateFormatFor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"formatters",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"measureText",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"measureFormat",{enumerable:!0,get:function(){return ue}});const Q=Y("packages/modules/charts/scale.js").timeStepFor;function $(P){if(!Number.isFinite(P)||P<=0)return 0;const y=Math.ceil(-Math.log10(P));return Math.min(6,Math.max(0,y))}function pe(P,y,B=0){return Number.isFinite(P)?Math.abs(P)>=1e4?y.number(P,{notation:"compact",maximumFractionDigits:1}):y.number(P,{minimumFractionDigits:B,maximumFractionDigits:B}):""}function me(P,y){const B=P&&P.messages;return!B||typeof B.number!="function"?Number(y).toFixed(2):B.number(y,{minimumFractionDigits:2,maximumFractionDigits:2})}function te(P){const B=P>0?Q(P):0;return B>0&&B<1e3?{minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}:B>0&&B<6e4?{hour:"2-digit",minute:"2-digit",second:"2-digit"}:P<=864e5?{hour:"2-digit",minute:"2-digit"}:P<=180*864e5?B>0&&B<864e5?{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short"}:P<=3*365*864e5?{month:"short",year:"numeric"}:{year:"numeric"}}function Z(P,y,B){const D=P.messages,I=D.locale,z=B&&B.format&&B.format.timeZone||P.get("timeZone")||void 0;if(y.kind==="time"){const b=te(y.span||0),f=new Intl.DateTimeFormat(I,z?{...b,timeZone:z}:b),l=new Intl.DateTimeFormat(I,z?{dateStyle:"medium",timeStyle:"short",timeZone:z}:{dateStyle:"medium",timeStyle:"short"});return{tick:v=>Number.isFinite(Number(v))?f.format(new Date(Number(v))):"",value:v=>Number.isFinite(Number(v))?l.format(new Date(Number(v))):""}}const x=$(y.step||0);return{tick:b=>typeof b=="number"?pe(b,D,x):String(b??""),value:b=>typeof b=="number"?D.number(b):String(b??"")}}function H(P,y){if(P==null||!Number.isFinite(P))return"";const B=Math.abs(P)>=1e-6?Number(P.toPrecision(6)):P;return y.number(B)}function ue(P,y,B){return P==null||!Number.isFinite(Number(P))?"":y&&y.format&&typeof y.formatValue=="function"?String(y.formatValue(P,null)):H(Number(P),B&&B.messages)}}),Je("packages/modules/charts/labels.js",function(o,Y){"use strict";Object.defineProperty(o,"resolveLabels",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"collides",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"placeLabels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"labelText",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"drawAnchoredLabels",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"drawDataLabels",{enumerable:!0,get:function(){return l}});const Q=Y("packages/modules/charts/frame.js").Pool,pe=Y("packages/modules/charts/format.js").measureText,me=Y("packages/modules/charts/svg.js"),te=me.attrs,Z=me.round,H=me.setText,P=Y("packages/modules/charts/styles.js").NS,y=Y("packages/modules/charts/typography.js"),B=y.applySize,D=y.textWidth,I=4;function G(v){const C=v&&v.labels;if(!C)return{show:!1,names:C!==!1,position:"outside",format:null,minGap:2,total:!1};const F=typeof C=="object"?C:{};return{show:!0,names:!0,position:["outside","inside","auto"].includes(F.position)?F.position:"outside",format:F.format||null,minGap:Number.isFinite(F.minGap)?Number(F.minGap):2,total:!!F.total}}function z(v,C,F){for(const _ of C)if(v.x-F<_.x+_.width&&v.x+v.width+F>_.x&&v.y-F<_.y+_.height&&v.y+v.height+F>_.y)return!0;return!1}function x(v){const{points:C,plot:F,size:_}=v,J=v.minGap===void 0?2:v.minGap,re=[],q=[];for(const U of C){if(U.px===void 0||U.py===void 0)continue;const ge=v.text(U);if(!ge)continue;const A=D(ge,_),X=_;let ce=U.px,E=U.py-I,W="middle",h=!1;v.horizontal?(ce=U.px+I,E=U.py,W="start",v.position!=="outside"&&U.pbase!==void 0&&Math.abs(U.px-U.pbase)>A+I*2&&(ce=U.px-I,W="end",h=!0)):v.position!=="outside"&&U.pbase!==void 0&&Math.abs(U.pbase-U.py)>X+I*2&&(E=U.py+X+I,h=!0);const s=()=>({x:W==="middle"?ce-A/2:W==="end"?ce-A:ce,y:E-X,width:A,height:X});let g=s();!(g.y>=F.top-1)&&!h&&!v.horizontal&&U.pbase!==void 0&&Math.abs(U.pbase-U.py)>X+I*2&&(E=U.py+X+I,h=!0,g=s()),!(g.x+g.width<=F.right+1)&&!h&&v.horizontal&&U.pbase!==void 0&&Math.abs(U.px-U.pbase)>A+I*2&&(ce=U.px-I,W="end",h=!0,g=s()),!(g.x<F.left-1||g.x+g.width>F.right+1)&&(g.y<F.top-1||g.y+g.height>F.bottom+X||z(g,re,J)||(re.push(g),q.push({x:Z(ce),y:Z(E),text:ge,anchor:W,inside:h})))}return q}function b(v,C,F){return v==null?"":typeof C.format=="function"?String(C.format(v)):typeof C.format=="string"&&F&&F.formatting&&F.formatting.format?String(F.formatting.format(v,C.format)):pe(v,F&&F.messages)}function f(v){const C=new Q(v.group),F=v.minGap===void 0?2:v.minGap,_=v.size,J=[];let re=0;for(const q of v.anchors){if(!q||!q.text)continue;const U=q.width===void 0?D(q.text,v.size):q.width,ge=q.anchor||"middle",X={x:ge==="end"?q.x-U:ge==="start"?q.x:q.x-U/2,y:q.y-_/2,width:U,height:_};if(v.plot&&(X.x<v.plot.left-1||X.x+X.width>v.plot.right+1||X.y<v.plot.top-1||X.y+X.height>v.plot.bottom+1)||q.width!==void 0&&U>q.width||q.height!==void 0&&_>q.height||z(X,J,F))continue;J.push(X);const ce=C.next("text",q.className||`${P}__data-label`);B(ce,v.size),te(ce,{x:Z(q.x),y:Z(q.y),"text-anchor":ge,"dominant-baseline":q.baseline||"middle","data-inside":q.inside?"true":null}),H(ce,q.text),re++}return C.finish(),re}function l(v){const C=new Q(v.group),{options:F}=v;let _=0;const J=re=>typeof F.format=="function"&&re.y!==null&&re.y!==void 0?String(F.format(re.y,re)):b(re.y,F,v.grid);for(const re of v.series){const q=x({points:re.points,plot:v.plot,size:v.size,position:F.position,horizontal:v.horizontal,minGap:F.minGap,text:J});for(const U of q){const ge=C.next("text",`${P}__data-label`);B(ge,v.size),te(ge,{x:U.x,y:U.y,"text-anchor":U.anchor,"data-inside":U.inside?"true":null}),H(ge,U.text),_++}}return C.finish(),_}}),Je("packages/modules/charts/dense.js",function(o,Y){"use strict";Object.defineProperty(o,"CANVAS_THRESHOLD",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"downsample",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"markCount",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"wantsCanvas",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"paintDense",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"sizeCanvas",{enumerable:!0,get:function(){return te}});const ke=3e3;function Q(Z,H){const ue=Z.length;if(!Number.isFinite(H)||H>=ue||H<3||ue<3)return Z;const P=[Z[0]],y=(ue-2)/(H-2);let B=0;for(let D=0;D<H-2;D++){const I=Math.floor(D*y)+1,G=Math.min(Math.floor((D+1)*y)+1,ue-1),z=G,x=Math.min(Math.floor((D+2)*y)+1,ue);let b=0,f=0,l=0;for(let _=z;_<x;_++){const J=Z[_];!J||!Number.isFinite(J.y)||(b+=J.x,f+=J.y,l++)}l&&(b/=l,f/=l);const v=Z[B];if(I>=G)continue;let C=I,F=-1;for(let _=I;_<G;_++){const J=Z[_];if(!J||!Number.isFinite(J.y))continue;const re=Math.abs((v.x-b)*(J.y-v.y)-(v.x-J.x)*(f-v.y));re>F&&(F=re,C=_)}C<=B||(P.push(Z[C]),B=C)}return P.push(Z[ue-1]),P}function $(Z){let H=0;for(const ue of Z)H+=ue.points.length;return H}function pe(Z){if(Z.canvas===!0)return!0;if(Z.canvas===!1)return!1;const H=Number.isFinite(Z.canvas)?Number(Z.canvas):ke;return $(Z.series)>H}function me(Z){const{context:H,series:ue,ratio:P}=Z;H.save(),H.scale(P,P);for(const y of ue){const B=Z.colour(y.index);if(Z.type==="scatter"||Z.type==="bubble"){H.fillStyle=B;for(const I of y.points)I.px!==void 0&&(H.beginPath(),H.arc(I.px,I.py,I.pr||2,0,Math.PI*2),H.fill());continue}H.strokeStyle=B,H.lineWidth=2,H.lineJoin="round",H.beginPath();let D=!1;for(const I of y.points){if(I.px===void 0||I.py===void 0){D=!1;continue}D?H.lineTo(I.px,I.py):H.moveTo(I.px,I.py),D=!0}H.stroke()}H.restore()}function te(Z){const{canvas:H}=Z;return H.width=Math.max(1,Math.round(Z.width*Z.ratio)),H.height=Math.max(1,Math.round(Z.height*Z.ratio)),H.style&&(H.style.width=`${Z.width}px`,H.style.height=`${Z.height}px`),typeof H.getContext=="function"?H.getContext("2d"):null}}),Je("packages/modules/charts/annotations.js",function(o,Y){"use strict";Object.defineProperty(o,"overlayLayer",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"annotationValue",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"annotationAxis",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"annotationText",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"drawAnnotations",{enumerable:!0,get:function(){return ge}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/scale.js"),pe=$.isNumber,me=$.toNumber,te=$.toTime,Z=Y("packages/modules/charts/svg.js"),H=Z.attrs,ue=Z.path,P=Z.round,y=Z.setText,B=Z.SVG_NS,I=Y("packages/modules/charts/styles.js").NS,z=Y("packages/core/src/internal/util.js").warnOnce;function x(A,X){for(const E of A.childNodes||[])if(E&&String(E.getAttribute&&E.getAttribute("class"))===X)return E;const ce=A.ownerDocument.createElementNS(B,"g");return ce.setAttribute("class",X),A.appendChild(ce),ce}const b=new Set(["line","target","band","callout","event"]);function f(A,X){return A.kind==="time"?te(X):me(X)}function l(A,X,ce){if(A.kind==="band"){const W=A.of(X);if(!Number.isFinite(W))return NaN;const h=Number(A.bandwidth)||0;return ce==="right"?W+h:W}const E=f(A,X);return E===null?NaN:A.of(E)}function v(A,X,ce){const E=A.kind||"line",W=A.label?` (${JSON.stringify(A.label)})`:"";z(`chart:annotation:dropped:${E}:${X}:${ce}`,`chart annotation${W} of kind ${JSON.stringify(E)}, reading the ${X} axis, was not drawn: ${ce}.`)}function C(A,X){if(A instanceof Date){const E=A.getTime();return Number.isFinite(E)?A.toISOString().slice(0,10):String(A)}if(typeof A=="number")return Number.isFinite(A)?X(A):String(A);const ce=me(A);return ce===null||typeof A=="string"?String(A):X(ce)}function F(A,X,ce){const E=[];for(const W of A)if((W.axis==="right"?"right":"left")===ce&&!(X.series!==void 0&&W.key!==X.series))for(const s of W.points)pe(s.y)&&E.push(Number(s.y));return E}function _(A,X){if(!A.length)return null;const ce=[...A].sort((s,g)=>s-g);if(ce.length===1)return ce[0];const E=Math.min(100,Math.max(0,X))/100*(ce.length-1),W=Math.floor(E),h=Math.ceil(E);return W===h?ce[W]:ce[W]+(ce[h]-ce[W])*(E-W)}function J(A,X,ce){if(!A.compute)return me(A.value);const E=F(X,A,ce);if(!E.length)return null;const W=String(A.compute).toLowerCase();if(W==="mean"||W==="avg")return E.reduce((s,g)=>s+g,0)/E.length;if(W==="median"||W==="p50")return _(E,50);if(W==="min")return Math.min(...E);if(W==="max")return Math.max(...E);const h=/^p(\d+(?:\.\d+)?)$/.exec(W);return h?_(E,Number(h[1])):null}function re(A){return A.axis==="right"||A.axis==="y2"?"right":"left"}function q(A,X,ce,E){const W=A.label?`${A.label}: `:"",h=E?` (${re(A)==="right"?"right axis":"left axis"})`:"",s=A.kind||"line";if(s==="band"){if(!Array.isArray(X)||X[0]===null||X[1]===null)return"";const[c,d]=X;return`${W||"Band: "}${ce(Math.min(c,d))} to ${ce(Math.max(c,d))}${h}`}return X==null?"":`${W||`${s==="target"?"Target":s==="callout"?"Callout":"Reference"}: `}${ce(X)}${h}`}function U(A){return(A.kind||"line")==="band"?0:1}function ge(A){const{group:X,plot:ce,xScale:E,yScale:W,rightScale:h,series:s,format:g}=A,c=new Q(x(X,`${I}__annotations`)),d=[],S=[...Array.isArray(A.annotations)?A.annotations:[]].sort((w,m)=>U(w)-U(m));for(const w of S){const m=w.kind||"line";if(!b.has(m))continue;const u=re(w),k=u==="right"&&h?h:W;if(m==="band"){if(w.orient==="vertical"){const a=l(E,w.from,"left"),T=l(E,w.to,"right");if(Number.isNaN(a)||Number.isNaN(T)){const fe=Number.isNaN(a)&&Number.isNaN(T)?"from and to":Number.isNaN(a)?"from":"to";v(w,u,`its ${fe} value could not be placed on the x scale`);continue}const M=P(Math.min(a,T)),L=P(Math.max(a,T));if(H(c.next("rect",`${I}__annotation-band ${w.className||""}`.trim()),{x:M,y:P(ce.top),width:Math.max(0,L-M),height:P(Math.max(0,ce.bottom-ce.top)),fill:w.colour||"currentColor","fill-opacity":w.opacity===void 0?.12:w.opacity}),w.label){const fe=c.next("text",`${I}__annotation-label`);H(fe,{x:M+4,y:P(ce.top+12),"text-anchor":"start"}),y(fe,w.label)}const ee=w.label?`${w.label}: `:"Event window: ";d.push({text:`${ee}${C(w.from,g)} to ${C(w.to,g)}`});continue}const i=J({...w,value:w.from,compute:w.fromCompute},s,u),n=J({...w,value:w.to,compute:w.toCompute},s,u);if(i===null||n===null)continue;const t=P(k.of(i)),r=P(k.of(n));if(H(c.next("rect",`${I}__annotation-band ${w.className||""}`.trim()),{x:P(ce.left),y:Math.min(t,r),width:P(Math.max(0,ce.right-ce.left)),height:Math.max(0,Math.abs(r-t)),fill:w.colour||"currentColor","fill-opacity":w.opacity===void 0?.12:w.opacity}),w.label){const a=c.next("text",`${I}__annotation-label`);H(a,{x:P(ce.left+4),y:Math.min(t,r)+12,"text-anchor":"start"}),y(a,w.label)}d.push({text:q(w,[i,n],g,A.dual)});continue}if(m==="event"){const i=w.x!==void 0?w.x:w.at,n=P(l(E,i,"left")+(E.kind==="band"?(Number(E.bandwidth)||0)/2:0));if(Number.isNaN(n)){v(w,u,"its x value could not be placed on the x scale");continue}if(H(c.next("path",`${I}__annotation-event`),{d:ue(["M",n,P(ce.top),"L",n,P(ce.bottom)]),stroke:w.colour||"currentColor",fill:"none"}),H(c.next("circle",`${I}__annotation-event-flag`),{cx:n,cy:P(ce.top),r:3,fill:w.colour||"currentColor"}),w.label){const r=c.next("text",`${I}__annotation-label`);H(r,{x:n+5,y:P(ce.top+10),"text-anchor":"start"}),y(r,w.label)}const t=w.label?`${w.label} — `:"Event — ";d.push({text:`${t}at ${C(i,g)}`});continue}if(m==="callout"){const i=J(w,s,u);if(i===null)continue;const n=w.at!==void 0?P(E.kind==="band"?E.centre(w.at):E.of(f(E,w.at)??NaN)):P(ce.right-4),t=P(k.of(i));if(Number.isNaN(n)){v(w,u,"its x value could not be placed on the x scale");continue}if(H(c.next("circle",`${I}__annotation-point`),{cx:n,cy:t,r:3.5,fill:w.colour||"currentColor"}),w.label){const r=c.next("text",`${I}__annotation-label`);H(r,{x:n+6,y:t-6,"text-anchor":"start"}),y(r,w.label)}d.push({text:q(w,i,g,A.dual)});continue}if(w.orient==="vertical"||w.x!==void 0){const i=w.x!==void 0?w.x:w.value,n=E.kind==="band"?P(E.centre(i)):P(E.of(f(E,i)??NaN));if(Number.isNaN(n)){v(w,u,"its x value could not be placed on the x scale");continue}const t=m==="target"?`${I}__annotation-target`:`${I}__annotation-line`;if(H(c.next("path",t),{d:ue(["M",n,P(ce.top),"L",n,P(ce.bottom)]),stroke:w.colour||"currentColor",fill:"none"}),w.label){const r=c.next("text",`${I}__annotation-label`);H(r,{x:n+4,y:P(ce.top+10),"text-anchor":"start"}),y(r,w.label)}d.push({text:w.label?`${w.label} — at ${C(i,g)}`:""});continue}const R=J(w,s,u);if(R===null)continue;const p=P(k.of(R)),e=m==="target"?`${I}__annotation-target`:`${I}__annotation-line`;if(H(c.next("path",e),{d:ue(["M",P(ce.left),p,"L",P(ce.right),p]),stroke:w.colour||"currentColor",fill:"none"}),w.label){const i=c.next("text",`${I}__annotation-label`);H(i,{x:P(ce.right-4),y:p-4,"text-anchor":"end"}),y(i,w.label)}d.push({text:q(w,R,g,A.dual)})}return c.finish(),d.filter(w=>w.text)}}),Je("packages/modules/charts/combo.js",function(o,Y){"use strict";Object.defineProperty(o,"toPareto",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"drawCombo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"drawRightAxis",{enumerable:!0,get:function(){return m}});const ke=Y("packages/modules/charts/axis.js"),Q=ke.drawAxisLines,$=ke.drawCategoryAxis,pe=ke.drawContinuousAxis,me=ke.drawMeasureAxis,te=ke.overhangFor,Z=ke.pinXDomain,H=ke.setPlotClip,ue=Y("packages/modules/charts/frame.js"),P=ue.Pool,y=ue.shouldRotate,D=Y("packages/modules/charts/format.js").formatters,I=Y("packages/modules/charts/scale.js"),G=I.bandScale,z=I.extent,x=I.isNumber,b=I.linearScale,f=I.measureDomain,l=I.timeScale,v=I.toNumber,C=I.toTime,F=Y("packages/modules/charts/svg.js"),_=F.attrs,J=F.path,re=F.round,U=Y("packages/modules/charts/styles.js").NS,A=Y("packages/modules/charts/scheme.js").resolveScheme,ce=Y("packages/modules/charts/labels.js").drawDataLabels,W=Y("packages/modules/charts/annotations.js").drawAnnotations;function h(u){return{left:u.filter(k=>k.axis!=="right"),right:u.filter(k=>k.axis==="right")}}function s(u,k){const R=u&&u.seriesStyle&&u.seriesStyle[k];if(R)return{width:R.width!=null?String(R.width):null,dash:Array.isArray(R.dash)&&R.dash.length?R.dash.join(" "):null,opacity:null,emphasized:!1};const p=u&&Array.isArray(u.emphasis)?u.emphasis:null;if(!p||!p.length)return{width:null,dash:null,opacity:null,emphasized:!1};const e=p.includes(k);return{width:e?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:e?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:e}}function g(u,k,R,p){const e=[];let i=!1;for(const n of k.points){if(n.px===void 0){i=!1;continue}e.push(i?"L":"M",n.px,n.py),i=!0}_(u.next("path",`${U}__line ${U}__mark`),{d:e.length?J(e):"",stroke:R,"data-series":k.index,"stroke-width":p.width,"stroke-dasharray":p.dash,opacity:p.opacity});for(const n of k.points)n.px!==void 0&&_(u.next("circle",`${U}__point ${U}__mark`),{cx:n.px,cy:n.py,r:3,fill:R})}function c(u,k){const R=[];for(const p of u)for(const e of p.points)R.push(e.y);return f(R,{zero:k})}function d(u){const k=u.series[0];if(!k)return u;const R=k.points.map((n,t)=>({point:n,label:u.labels[t],category:u.categories[t]})).filter(n=>x(n.point.y)).sort((n,t)=>t.point.y-n.point.y),p=R.reduce((n,t)=>n+t.point.y,0);let e=0;const i=R.map(n=>(e+=n.point.y,p>0?e/p*100:0));return{...u,categories:R.map(n=>n.category),labels:R.map(n=>n.label),series:[{...k,index:0,mark:"bar",axis:"left",points:R.map(n=>n.point)},{key:"cumulative",label:u.cumulativeLabel||"%",index:1,mark:"line",axis:"right",points:R.map((n,t)=>({x:n.category,xKey:n.point.xKey,label:n.label,y:i[t],rows:n.point.rows,rowKey:n.point.rowKey}))}]}}function N(u,k,R){const p=[k.left,k.right];if(u.kind!=="time"&&u.kind!=="linear")return G(u.categories,p,.2);const e=u.kind==="time"?u.categories.map(C):u.categories.map(v);if(u.kind==="time"){const t=z(e);if(t&&t.min===t.max)return l(Z({min:t.min-3e4,max:t.max+3e4},u,R),p)}const i=u.xDomain||f(e,{zero:!1,nice:u.kind!=="time"}),n=u.xDomain?i:Z(i,u,R);return u.kind==="time"?l(n,p):b(n,p)}function S(u,k){const R=[...new Set(u.filter(t=>Number.isFinite(t)))].sort((t,r)=>t-r);if(R.length<2){const[t,r]=k.range;return Math.max(4,(r-t)/10)}const p=[];for(let t=1;t<R.length;t++)p.push(R[t]-R[t-1]);p.sort((t,r)=>t-r);const e=Math.floor(p.length/2),i=p.length%2?p[e]:(p[e-1]+p[e])/2,n=Math.abs(k.of(R[0]+i)-k.of(R[0]));return Math.max(1,n*.8)}function w(u){const k=u.scheme||A(),{plot:R}=u,p=u.pareto?d(u.bound):u.bound,e=p.series.filter(se=>!u.hidden.has(se.key)),i=h(e),n=i.left.some(se=>(se.mark||"bar")==="bar"),t=p.yDomain||c(i.left,n),r=b(t,[R.bottom,R.top]),a=i.right.length?u.pareto?{min:0,max:100}:c(i.right,!1):null,T=a?b(a,[R.bottom,R.top]):null,M=N(p,R,u.axis&&u.axis.x),L=M.kind!=="band",ee=L?p.categories.map(se=>p.kind==="time"?C(se):v(se)):null;me({gridGroup:u.groups.grid,axisGroup:u.groups.axis,plot:R,scale:r,format:D(u.grid,{kind:"linear",step:(t.max-t.min)/5})});const fe=p.dimension&&p.dimension.col?u.grid.columns.get(p.dimension.col):void 0;L?pe({group:u.groups.overlay,plot:R,scale:M,format:D(u.grid,{kind:p.kind,span:M.domain.max-M.domain.min,step:(M.domain.max-M.domain.min)/5},fe),grid:u.grid,size:u.fontSize}):$({group:u.groups.overlay,plot:R,scale:M,labels:p.labels,fontSize:u.fontSize,rotated:y(p.labels,M.step,u.fontSize)}),Q({group:u.groups.rules,plot:R}),T&&m({group:u.groups.axis,plot:R,scale:T,colour:k.series(i.right[0].index),format:D(u.grid,{kind:"linear",step:(a.max-a.min)/5}),suffix:u.pareto?"%":""}),H(u.groups,R,te(u.type));const de=new P(u.groups.marks),Me=e.filter(se=>(se.mark||"bar")==="bar"),ie=L?S(ee,M):M.bandwidth,ve=Me.length?ie/Me.length:ie;let we=0;const Ae=[];for(const se of e){const ae=se.mark||"bar",be=se.axis==="right"&&T?T:r,le=k.series(se.index);if(ae==="bar"){const Re=we*ve;we++;const Te=be.of(Math.max(be.domain.min,0));for(let Fe=0;Fe<se.points.length;Fe++){const ze=se.points[Fe];if(!x(ze.y))continue;let Ze;if(L){const nt=p.kind==="time"?C(ze.x):v(ze.x);Ze=nt===null?NaN:M.of(nt)-ie/2}else Ze=M.of(ze.x);if(Number.isNaN(Ze))continue;const Ye=be.of(ze.y);_(de.next("rect",`${U}__bar ${U}__mark`),{x:re(Ze+Re),y:re(Math.min(Ye,Te)),width:re(Math.max(0,ve)),height:re(Math.max(1,Math.abs(Te-Ye))),fill:le,"data-series":se.index,"data-point":Fe}),ze.px=re(Ze+Re+ve/2),ze.py=re(Math.min(Ye,Te))}continue}const ye=[];let Ne=!1;for(const Re of se.points){if(!x(Re.y)){Ne=!1;continue}let Te;if(L){const ze=p.kind==="time"?C(Re.x):v(Re.x);Te=ze===null?NaN:re(M.of(ze))}else Te=re(M.centre(Re.x));if(Number.isNaN(Te)){Ne=!1;continue}const Fe=re(be.of(Re.y));ye.push(Ne?"L":"M",Te,Fe),Ne=!0,Re.px=Te,Re.py=Fe}const Ee=s(u,se.label);Ee.emphasized?Ae.push({series:se,colour:le,style:Ee}):g(de,se,le,Ee)}for(const se of Ae)g(de,se.series,se.colour,se.style);de.finish(),u.labels&&u.labels.show&&ce({group:u.groups.labels,series:e,plot:R,options:u.labels,grid:u.grid,size:u.typography&&u.typography.small||u.fontSize});let ne=null;return u.annotations&&u.annotations.length&&(ne=W({group:u.groups.overlay,plot:R,xScale:M,yScale:r,rightScale:T,series:e,annotations:u.annotations,dual:!!T,format:D(u.grid,{kind:"linear",step:(t.max-t.min)/5}).tick})),{xScale:M,yScale:r,rightScale:T,dual:!!T,series:e,bound:p,annotations:ne}}function m(u){const{group:k,plot:R,scale:p,format:e}=u,i=u.side==="left"?"left":"right",n=i==="right"?R.right:R.left,t=new P(k);_(t.next("line",`${U}__axis-right`),{x1:re(n),x2:re(n),y1:re(R.top),y2:re(R.bottom),stroke:u.colour});for(const r of p.ticks(5)){const a=re(p.of(r)),T=t.next("text",`${U}__tick`);_(T,{x:re(i==="right"?R.right+6:R.left-6),y:a,"text-anchor":i==="right"?"start":"end","dominant-baseline":"middle",fill:u.colour}),T.textContent=`${e.tick(r)}${u.suffix||""}`}t.finish()}}),Je("packages/modules/charts/quantile.js",function(o,Y){"use strict";Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return P}});const ke=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),Q=3e-12,$=1e-300;function pe(y){if(y<.5)return Math.log(Math.PI/Math.sin(Math.PI*y))-pe(1-y);const B=y-1;let D=.9999999999998099;const I=B+7.5;for(let G=0;G<ke.length;G++)D+=ke[G]/(B+G+1);return .5*Math.log(2*Math.PI)+(B+.5)*Math.log(I)-I+Math.log(D)}function me(y,B,D){const I=y+B,G=y+1,z=y-1;let x=1,b=1-I*D/G;Math.abs(b)<$&&(b=$),b=1/b;let f=b;for(let l=1;l<=300;l++){const v=2*l;let C=l*(B-l)*D/((z+v)*(y+v));b=1+C*b,Math.abs(b)<$&&(b=$),x=1+C/x,Math.abs(x)<$&&(x=$),b=1/b,f*=b*x,C=-(y+l)*(I+l)*D/((y+v)*(G+v)),b=1+C*b,Math.abs(b)<$&&(b=$),x=1+C/x,Math.abs(x)<$&&(x=$),b=1/b;const F=b*x;if(f*=F,Math.abs(F-1)<Q)break}return f}function te(y,B,D){if(!(y>0)||!(B>0)||!Number.isFinite(D))return Number.NaN;if(D<=0)return 0;if(D>=1)return 1;const I=Math.exp(pe(y+B)-pe(y)-pe(B)+y*Math.log(D)+B*Math.log(1-D));return D<(y+1)/(y+B+2)?I*me(y,B,D)/y:1-I*me(B,y,1-D)/B}function Z(y){const B=Math.abs(y),D=2/(2+B),I=4*D-2,G=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let z=0,x=0,b;for(let l=G.length-1;l>0;l--)b=x,x=I*x-z+G[l],z=b;const f=D*Math.exp(-B*B+.5*(G[0]+I*x)-z);return y>=0?f:2-f}function H(y){if(!(y>0)||!(y<1))return y===0?-1/0:y===1?1/0:Number.NaN;const B=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],D=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],I=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],G=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],z=.02425;let x,b,f;y<z?(x=Math.sqrt(-2*Math.log(y)),f=(((((I[0]*x+I[1])*x+I[2])*x+I[3])*x+I[4])*x+I[5])/((((G[0]*x+G[1])*x+G[2])*x+G[3])*x+1)):y<=1-z?(x=y-.5,b=x*x,f=(((((B[0]*b+B[1])*b+B[2])*b+B[3])*b+B[4])*b+B[5])*x/(((((D[0]*b+D[1])*b+D[2])*b+D[3])*b+D[4])*b+1)):(x=Math.sqrt(-2*Math.log(1-y)),f=-(((((I[0]*x+I[1])*x+I[2])*x+I[3])*x+I[4])*x+I[5])/((((G[0]*x+G[1])*x+G[2])*x+G[3])*x+1));const v=(.5*Z(-f/Math.SQRT2)-y)*Math.sqrt(2*Math.PI)*Math.exp(f*f/2);return f-v/(1+f*v/2)}function ue(y,B){if(!(B>0)||!Number.isFinite(y))return Number.NaN;const D=.5*te(B/2,.5,B/(B+y*y));return y>0?1-D:D}function P(y,B){if(!(y>0)||!(y<1)||!(B>0))return Number.NaN;if(B>1e7)return H(y);let D=-1e4,I=1e4,G=H(y);const z=pe(B/2)+pe(.5)-pe((B+1)/2);for(let x=0;x<60;x++){const b=ue(G,B);b<y?D=G:I=G;const f=Math.exp(-((B+1)/2)*Math.log(1+G*G/B)-z)/Math.sqrt(B),l=f>0?(b-y)/f:0;if(Math.abs(l)<1e-12)break;const v=G-l;if(G=v>D&&v<I&&Number.isFinite(v)?v:(D+I)/2,I-D<1e-12)break}return G}}),Je("packages/modules/charts/trendline.js",function(o,Y){"use strict";Object.defineProperty(o,"normaliseTrends",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"linearTrend",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"movingAverageTrend",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"exponentialTrend",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"computeTrend",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"trendText",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"drawTrendlines",{enumerable:!0,get:function(){return g}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/svg.js"),pe=$.attrs,me=$.path,te=$.ribbonPath,Z=$.round,H=$.setText,ue=$.SVG_NS,y=Y("packages/modules/charts/typography.js").applySize,D=Y("packages/modules/charts/styles.js").NS,I=Y("packages/modules/charts/scale.js"),G=I.toNumber,z=I.toTime,b=Y("packages/modules/charts/quantile.js").studentTQuantile,l=Y("packages/modules/charts/format.js").r2Digits,v={linear:new Set(["linear","lr","ols","regression","least-squares"]),movingAverage:new Set(["movingaverage","moving-average","ma","sma","rolling"]),exponential:new Set(["exponential","exp","ewma","ses","holt","smoothing"])},C=1e-4,F=1-1e-4;function _(c){const d=String(c||"linear").toLowerCase();return v.linear.has(d)?"linear":v.movingAverage.has(d)?"movingAverage":v.exponential.has(d)?"exponential":null}function J(c){if(!c)return[];const d=Array.isArray(c)?c:[c],N=[];for(const S of d){if(S===!0){N.push({method:"linear"});continue}if(typeof S=="string"){const w=_(S);w&&N.push({method:w});continue}if(S&&typeof S=="object"){const w=_(S.method);w&&N.push({...S,method:w})}}return N}function re(c,d){if(c.kind==="band")return c.centre(d);const N=c.kind==="time"?z(d):G(d);return N===null?NaN:c.of(N)}function q(c){const d=[];for(const N of c.points){const S=Number(N.y);d.push({value:Number.isFinite(S)?S:null,rawX:N.x})}return d}function U(c,d){const N=[];for(const S of c.points){const w=d.kind==="time"?z(S.x):G(S.x),m=Number(S.y);w===null||!Number.isFinite(w)||!Number.isFinite(m)||N.push({x:w,y:m})}return N.sort((S,w)=>S.x-w.x),N}function ge(c,d,N={}){const S=c.length;if(S<2)return null;let w=0,m=0;for(const ee of c)w+=ee.x,m+=ee.y;w/=S,m/=S;let u=0,k=0,R=0;for(const ee of c){const fe=ee.x-w,de=ee.y-m;u+=fe*fe,k+=fe*de,R+=de*de}if(u===0)return null;const p=k/u,e=m-p*w,i=R===0?1:Math.max(0,Math.min(1,k*k/(u*R))),n=c[0].x,t=c[S-1].x,r=ee=>({x:ee,y:e+p*ee}),a=[r(n),r(t)],T=[];let M=null;const L=Math.max(0,Math.floor(Number(d)||0));if(L>0&&t>n){const ee=(t-n)/(S-1);if(ee>0&&(T.push(r(t),r(t+L*ee)),S>2)){const fe=Number.isFinite(N.confidence)&&N.confidence>0&&N.confidence<1?Number(N.confidence):.95,de=1-(1-fe)/2,Me=Math.max(0,R-p*k),ie=Math.sqrt(Me/(S-2)),ve=b(de,S-2),we=[];for(let Ae=0;Ae<=L;Ae++){const ne=t+Ae*ee,se=e+p*ne,ae=1/S+(ne-w)**2/u,be=ie*Math.sqrt(1+ae),le=ie*Math.sqrt(ae);we.push({x:ne,mean:se,lower:se-ve*be,upper:se+ve*be,lowerMean:se-ve*le,upperMean:se+ve*le})}M={confidence:fe,points:we}}}return{fit:a,forecast:T,band:M,stats:{method:"linear",slope:p,intercept:e,r2:i,n:S,forecast:T.length?L:0,confidence:M?M.confidence:null}}}function A(c,d){const N=Math.max(1,Math.floor(Number(d)||3)),S=[];let w=0;const m=[];for(const u of c)Number.isFinite(u.value)&&(S.push(u.value),w+=u.value,S.length>N&&(w-=S.shift())),S.length&&m.push({x:u.rawX,y:w/S.length});return m.length<2?null:{fit:m,stats:{method:"movingAverage",window:N}}}function X(c,d){const N=c.length,S=new Array(N).fill(null);let w=null,m=0;for(let u=0;u<N;u++){const k=c[u];if(!Number.isFinite(k)){w!==null&&(S[u]=w);continue}if(w===null){w=k,S[u]=k;continue}m+=(k-w)**2,w=d*k+(1-d)*w,S[u]=w}return{smoothed:S,sse:m}}function ce(c,d,N){const S=c.length,w=new Array(S).fill(null);let m=null,u=null,k=0;for(let R=0;R<S;R++){const p=c[R];if(!Number.isFinite(p)){m!==null&&(m+=u,w[R]=m);continue}if(m===null){m=p,w[R]=p;continue}if(u===null){u=p-m;const n=m+u;k+=(p-n)**2;const t=m;m=d*p+(1-d)*(t+u),u=N*(m-t)+(1-N)*u,w[R]=m;continue}const e=m+u;k+=(p-e)**2;const i=m;m=d*p+(1-d)*(i+u),u=N*(m-i)+(1-N)*u,w[R]=m}return{smoothed:w,sse:k}}function E(c,d,N,S=80){const w=(Math.sqrt(5)-1)/2;let m=d,u=N,k=u-w*(u-m),R=m+w*(u-m),p=c(k),e=c(R);for(let i=0;i<S;i++)p<e?(u=R,R=k,e=p,k=u-w*(u-m),p=c(k)):(m=k,k=R,p=e,R=m+w*(u-m),e=c(R));return(m+u)/2}function W(c,d){const N=String(d.kind||d.model||"").toLowerCase()==="holt",S=c.map(e=>Number.isFinite(e.value)?e.value:null);if(S.filter(e=>e!==null).length<(N?2:1))return null;const m=e=>Math.min(F,Math.max(C,e));let u=Number.isFinite(d.alpha)?m(Number(d.alpha)):null,k=N&&Number.isFinite(d.beta)?m(Number(d.beta)):null;if(N){if(u===null||k===null){let e=u===null?.5:u,i=k===null?.5:k;for(let n=0;n<6;n++)u===null&&(e=E(t=>ce(S,t,i).sse,C,F)),k===null&&(i=E(t=>ce(S,e,t).sse,C,F));u=u===null?e:u,k=k===null?i:k}}else u===null&&(u=E(e=>X(S,e).sse,C,F));const R=N?ce(S,u,k):X(S,u),p=[];for(let e=0;e<c.length;e++){const i=R.smoothed[e];i===null||!Number.isFinite(i)||p.push({x:c[e].rawX,y:i})}return p.length<2?null:{fit:p,stats:{method:"exponential",kind:N?"holt":"ses",alpha:u,beta:N?k:null}}}function h(c,d,N){if(d.method==="linear"){const w=U(c,N);return ge(w,d.forecast,{confidence:d.confidence})}const S=q(c);return d.method==="movingAverage"?A(S,d.window||d.period):W(S,d)}function s(c,d,N,S,w,m){const u=d?` for ${d}`:"";if(c.method==="linear"){const e=Number.isFinite(c.r2)?`, R² ${c.r2.toFixed(2)}`:"";let i=`Trend (linear)${u}: slope ${N(c.slope)}${e}`;if(c.forecast>0&&S&&S.length){const n=S[S.length-1];if(i+=`; forecast ${c.forecast} step${c.forecast===1?"":"s"} ahead to ${N(n.y)}`,w&&w.points.length){const t=w.points[w.points.length-1],r=m==="confidence"||m==="mean",a=r?t.lowerMean:t.lower,T=r?t.upperMean:t.upper,M=r?"confidence":"prediction",L=Math.round(w.confidence*100);i+=`; ${L}% ${M} band ${N(a)} to ${N(T)} at the horizon`}}return i}if(c.method==="movingAverage")return`Trend (moving average, window ${c.window})${u}`;const k=c.kind==="holt"?"Holt":"single",R=Number.isFinite(c.alpha)?`, α ${c.alpha.toFixed(2)}`:"",p=Number.isFinite(c.beta)?`, β ${c.beta.toFixed(2)}`:"";return`Trend (exponential, ${k})${u}${R}${p}`}function g(c){const d=J(c.trend);if(!d.length)return[];const N=c.group.ownerDocument;let S=null;for(const u of c.group.childNodes||[])if(u&&String(u.getAttribute&&u.getAttribute("class"))===`${D}__trends`){S=u;break}S||(S=N.createElementNS(ue,"g"),S.setAttribute("class",`${D}__trends`),c.group.appendChild(S)),c.clip?S.setAttribute("clip-path",`url(#${c.clip})`):S.removeAttribute("clip-path");const w=new Q(S),m=[];for(const u of d)for(const k of c.series){const R=k.axis==="right"&&c.rightScale?c.rightScale:c.yScale,p=h(k,u,c.xScale);if(!p)continue;const e=c.scheme.series(k.index),i=[];for(const r of p.fit){const a=re(c.xScale,r.x),T=R.of(r.y);!Number.isFinite(a)||!Number.isFinite(T)||i.push(i.length?"L":"M",Z(a),Z(T))}if(i.length<4)continue;if(pe(w.next("path",`${D}__trend`),{d:me(i),fill:"none",stroke:e,"data-series":k.index}),u.band!==!1&&p.band&&p.band.points.length>=2){const r=u.band==="confidence"||u.band==="mean",a=[];for(const M of p.band.points){const L=re(c.xScale,M.x),ee=r?M.lowerMean:M.lower,fe=r?M.upperMean:M.upper,de=R.of(ee),Me=R.of(fe);!Number.isFinite(L)||!Number.isFinite(de)||!Number.isFinite(Me)||a.push({x:Z(L),lower:Z(de),upper:Z(Me)})}const T=te(a);T&&pe(w.next("path",`${D}__trend-band`),{d:T,fill:e,"fill-opacity":.15,stroke:"none","data-series":k.index})}const t=p.forecast||[];if(t.length>=2){const r=[];for(const a of t){const T=re(c.xScale,a.x),M=R.of(a.y);!Number.isFinite(T)||!Number.isFinite(M)||r.push(r.length?"L":"M",Z(T),Z(M))}r.length>=4&&pe(w.next("path",`${D}__trend-forecast`),{d:me(r),fill:"none",stroke:e,"data-series":k.index})}if(u.label!==!1&&p.stats.method==="linear"&&Number.isFinite(p.stats.r2)){const r=p.fit[p.fit.length-1],a=w.next("text",`${D}__trend-label`);y(a,c.size),pe(a,{x:Z(re(c.xScale,r.x)),y:Z(R.of(r.y))-4,"text-anchor":"end",fill:e}),H(a,c.grid.messages.t("chart.r2",{value:l(c.grid,p.stats.r2)}))}m.push({text:s(p.stats,k.label,c.format,t,u.band===!1?null:p.band,u.band)})}return w.finish(),m.filter(u=>u.text)}}),Je("packages/modules/charts/rulecolour.js",function(o,Y){"use strict";Object.defineProperty(o,"colourOf",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ruleColour",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"ruleLegend",{enumerable:!0,get:function(){return pe}});const ke="*";function Q(me){if(!me||typeof me!="object")return null;for(const te of["background","backgroundColor","color"]){const Z=me[te];if(typeof Z=="string"&&Z.trim())return Z.trim()}return null}function $(me){const{grid:te,col:Z,value:H}=me;if(!te||!Z||!te.formatting||typeof te.formatting.styleFor!="function")return null;try{return Q(te.formatting.styleFor(Z,H))}catch{return null}}function pe(me){const{grid:te,col:Z}=me,H=new Set([...me.colours||[]].filter(Boolean));if(!H.size||!te||!te.formatting||typeof te.formatting.list!="function")return[];let ue;try{ue=[...te.formatting.list(ke)||[],...Z?te.formatting.list(Z)||[]:[]]}catch{return[]}const P=[],y=new Set;for(const B of ue){if(!B||B.enabled===!1)continue;const D=Q(B.style);!D||!H.has(D)||y.has(D)||(y.add(D),P.push({key:B.id||`rule:${P.length}`,label:B.label||B.id||D,colour:D,index:P.length}))}return P}}),Je("packages/modules/charts/cartesian.js",function(o,Y){"use strict";Object.defineProperty(o,"CARTESIAN",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"axisWindowSpan",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(o,"axisWindowNow",{enumerable:!0,get:function(){return we}}),Object.defineProperty(o,"rollingDomain",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"WINDOW_LEAD",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"aheadOfWindow",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"staleWindow",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"windowedBound",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"slotPadFor",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"pinnedContinuousX",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(o,"bandedX",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"dataInterval",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(o,"continuousSlot",{enumerable:!0,get:function(){return Ye}}),Object.defineProperty(o,"xDomainFor",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(o,"xScaleFor",{enumerable:!0,get:function(){return Ot}}),Object.defineProperty(o,"drawFits",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(o,"drawConfidenceBand",{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(o,"drawBoundErrorBars",{enumerable:!0,get:function(){return en}}),Object.defineProperty(o,"drawForest",{enumerable:!0,get:function(){return nn}}),Object.defineProperty(o,"drawReferenceLines",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(o,"drawCartesian",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(o,"HIT_TOLERANCE",{enumerable:!0,get:function(){return It}}),Object.defineProperty(o,"nearestDrawnPoint",{enumerable:!0,get:function(){return Et}}),Object.defineProperty(o,"nearestCategory",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(o,"categoryKeyAt",{enumerable:!0,get:function(){return Jt}});const ke=Y("packages/modules/charts/axis.js"),Q=ke.drawAxisLines,$=ke.drawAxisTitle,pe=ke.drawBandLabels,me=ke.drawCategoryAxis,te=ke.drawContinuousAxis,Z=ke.drawMeasureAxis,H=ke.overhangFor,ue=ke.pinXDomain,P=ke.setPlotClip,y=Y("packages/modules/charts/frame.js"),B=y.Pool,D=y.shouldRotate,I=Y("packages/modules/charts/format.js"),G=I.formatters,z=I.r2Digits,x=Y("packages/modules/charts/scale.js"),b=x.bandScale,f=x.extent,l=x.isNumber,v=x.key,C=x.linearScale,F=x.measureDomain,_=x.timeScale,J=x.toNumber,re=x.toTime,q=Y("packages/modules/charts/svg.js"),U=q.attrs,ge=q.path,A=q.ribbonPath,X=q.round,ce=q.setText,E=q.SVG_NS,h=Y("packages/modules/charts/styles.js").NS,g=Y("packages/modules/charts/labels.js").drawDataLabels,d=Y("packages/modules/charts/dense.js").downsample,S=Y("packages/modules/charts/scheme.js").resolveScheme,m=Y("packages/modules/charts/typography.js").applySize,k=Y("packages/modules/charts/combo.js").drawRightAxis,R=Y("packages/modules/charts/annotations.js"),p=R.drawAnnotations,e=R.overlayLayer,n=Y("packages/modules/charts/trendline.js").drawTrendlines,t=Y("packages/modules/charts/rulecolour.js"),r=t.ruleColour,a=t.ruleLegend,M=Y("packages/core/src/internal/util.js").warnOnce,L=3.5,ee=Object.freeze({line:{zero:!1,marks:"path"},step:{zero:!1,marks:"path"},area:{zero:!0,marks:"path"},rangeArea:{zero:!1,marks:"path"},bar:{zero:!0,marks:"rect"},horizontalBar:{zero:!0,marks:"rect",horizontal:!0},waterfall:{zero:!0,marks:"rect"},scatter:{zero:!1,marks:"circle"},bubble:{zero:!1,marks:"circle"},candlestick:{zero:!1,marks:"rect"}});function fe(V){const Pe=[];for(let xe=0;xe<V.length;xe++){const je=V[xe];if(xe===0){Pe.push("M",je.x,je.y);continue}Pe.push("L",je.x,V[xe-1].y),Pe.push("L",je.x,je.y)}return Pe}function de(V,Pe,xe){if(xe)return[0,100];if(!Pe){const Ce=[];for(const Be of V)for(const _e of Be.points)Ce.push(_e.y);return Ce}const je=[],$e=[],Le=V[0]?V[0].points.length:0;for(let Ce=0;Ce<Le;Ce++){let Be=0,_e=0;for(const Ie of V){const Ue=Ie.points[Ce]?Ie.points[Ce].y:null;l(Ue)&&(Ue>=0?Be+=Ue:_e+=Ue)}je.push(Be),$e.push(_e)}return[...je,...$e]}function Me(V){const Pe=[0];if(!V)return Pe;let xe=0;for(const je of V.points)l(je.y)&&(xe+=je.y,Pe.push(xe));return Pe}function ie(V,Pe){const xe=new Float64Array(V),je=new Float64Array(V);return{take($e,Le){const Ce=Pe?Pe[$e]:0,Be=Pe?Ce?Le/Ce*100:0:Le;if(Be>=0){const Ie=xe[$e];return xe[$e]+=Be,[Ie,xe[$e]]}const _e=je[$e];return je[$e]+=Be,[_e,je[$e]]}}}function ve(V){const Pe=V&&V.window;if(!Pe||typeof Pe!="object")return 0;const xe=Number(Pe.span);return!Number.isFinite(xe)||xe<=0?0:Pe.kind!=="time"?(M("chart.axis.window.kind",`axis window kind "${Pe.kind}" is not supported on a chart axis; only { kind: "time", span } rolls the domain. Bound the row count with the source's maxRows instead.`),0):xe}function we(V,Pe){const xe=V&&V.window;if(!xe||typeof xe!="object"||typeof xe.now!="function")return Pe;const je=Number(xe.now());return Number.isFinite(je)?je:(M("chart.axis.window.now","axis.x.window.now did not return a time, so the rolling window is measured from this device's clock instead. It must return epoch milliseconds — the same number Date.now() returns — because that is what the x values are compared against."),Pe)}function Ae(V,Pe,xe){const je=xe+V*ne;let $e=xe;for(const Le of Pe)Number.isFinite(Le)&&Le>$e&&Le<=je&&($e=Le);return{min:$e-V,max:$e}}const ne=.25;function se(V,Pe,xe){const je=ve(Pe);if(!je||!V||!Array.isArray(V.categories))return null;const $e=ee[xe];if(!$e||$e.horizontal||V.kind==="category"||xe==="bar"&&!Fe(V,xe,Pe))return null;const Le=V.categories.map(Ce=>V.kind==="time"?re(Ce):J(Ce));return{span:je,values:Le}}function ae(V,Pe,xe,je){const $e=se(V,Pe,xe);if(!$e)return null;const Le=$e.span*ne;let Ce=0,Be=0;for(const _e of $e.values)_e===null||!Number.isFinite(_e)||_e-je<=Le||(Ce+=1,_e-je>Be&&(Be=_e-je));return Ce?{span:$e.span,limit:Le,count:Ce,lead:Be}:null}function be(V,Pe,xe,je){const $e=se(V,Pe,xe);if(!$e)return null;const{span:Le}=$e,Ce=$e.values.filter(Ue=>Ue!==null&&Number.isFinite(Ue));if(!Ce.length)return null;const{min:Be,max:_e}=Ae(Le,Ce,je);let Ie=-1/0;for(const Ue of Ce){if(Ue>=Be&&Ue<=_e)return null;Ue<Be&&Ue>Ie&&(Ie=Ue)}return Ie===-1/0?{span:Le,newest:null,age:null,points:Ce.length}:{span:Le,newest:Ie,age:je-Ie,points:Ce.length}}function le(V,Pe,xe,je){const $e=se(V,Pe,xe);if(!$e)return V;const{span:Le,values:Ce}=$e,Be=Ce.filter(Ve=>Ve!==null&&Number.isFinite(Ve));if(!Be.length)return V;const{min:_e,max:Ie}=Ae(Le,Be,je),Ue=[];for(let Ve=0;Ve<Ce.length;Ve++){const at=Ce[Ve];(at===null||!Number.isFinite(at)||at>=_e&&at<=Ie)&&Ue.push(Ve)}return Ue.length===Ce.length?V:{...V,categories:Ue.map(Ve=>V.categories[Ve]),labels:Array.isArray(V.labels)?Ue.map(Ve=>V.labels[Ve]):V.labels,series:(V.series||[]).map(Ve=>({...Ve,points:Array.isArray(Ve.points)?Ue.map(at=>Ve.points[at]).filter(at=>at!==void 0):Ve.points})),windowed:Ce.length-Ue.length}}const ye=Object.freeze({bar:.2,candlestick:.3}),Ne=.4;function Ee(V){return Object.hasOwn(ye,V)?ye[V]:Ne}const Re=new Set(["bar","candlestick"]);function Te(V){const Pe=V&&typeof V.scale=="string"?V.scale:"";return Pe==="time"||Pe==="linear"}function Fe(V,Pe,xe){if(!V||V.kind==="category")return!1;const je=ee[Pe];return je&&je.horizontal?!1:Re.has(Pe)?Te(xe):!0}function ze(V,Pe,xe){return!Fe(V,Pe,xe)}function Ze(V){const Pe=V.filter($e=>typeof $e=="number"&&Number.isFinite($e)).slice().sort(($e,Le)=>$e-Le),xe=[];for(let $e=1;$e<Pe.length;$e++){const Le=Pe[$e]-Pe[$e-1];Le>0&&xe.push(Le)}if(!xe.length)return 0;xe.sort(($e,Le)=>$e-Le);const je=Math.floor(xe.length/2);return xe.length%2?xe[je]:(xe[je-1]+xe[je])/2}function Ye(V){const{bound:Pe,scale:xe,config:je,padding:$e}=V,Le=je?Number(je.barWidth):NaN,Ce=Number.isFinite(Le)&&Le>0,Be=(Pe.categories||[]).map(Ve=>Pe.kind==="time"?re(Ve):J(Ve)),_e=Ce?Le:Ze(Be),Ie=Math.abs(xe.range[1]-xe.range[0]);if(!_e)return Math.max(1,Ie/20*(1-$e));const Ue=Math.abs(xe.of(xe.domain.min+_e)-xe.of(xe.domain.min));return Math.max(1,Ce?Ue:Ue*(1-$e))}function nt(V,Pe,xe,je){if(ze(V,Pe,xe))return null;const $e=ve(xe),Le=V.kind==="time"?V.categories.map(re):V.categories.map(J);if(V.kind==="time"&&!$e){const Be=f(Le);if(Be&&Be.min===Be.max)return ue({min:Be.min-3e4,max:Be.max+3e4},V,xe)}const Ce=$e?Ae($e,Le,Number.isFinite(je)?je:we(xe,Date.now())):F(Le,{zero:!1,nice:V.kind!=="time"});return ue(Ce,V,xe)}function Ot(V,Pe,xe,je){const $e=[Pe.left,Pe.right];if(ze(V,xe,je))return ve(je)&&M("chart.axis.window.band","a rolling time window needs a continuous x axis; this chart bands its x values, so the window is ignored. Bind a date or numeric column to x, or put this type on a continuous axis with axis.x.scale."),b(V.categories,$e,Ee(xe));const Le=V.xDomain||nt(V,xe,je);return V.kind==="time"?_(Le,$e):C(Le,$e)}function jt(V,Pe){if(V.kind==="band")return V.centre(Pe.x);const xe=V.kind==="time"?re(Pe.x):J(Pe.x);return xe===null?NaN:V.of(xe)}function Bt(V,Pe){const xe=V&&V.seriesStyle&&V.seriesStyle[Pe];if(xe)return{width:xe.width!=null?String(xe.width):null,dash:Array.isArray(xe.dash)&&xe.dash.length?xe.dash.join(" "):null,opacity:null,emphasized:!1};const je=V&&Array.isArray(V.emphasis)?V.emphasis:null;if(!je||!je.length)return{width:null,dash:null,opacity:null,emphasized:!1};const $e=je.includes(Pe);return{width:$e?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:$e?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:$e}}function Ht(V){const{series:Pe,xScale:xe,yScale:je,baseline:$e,fill:Le,colour:Ce,stack:Be,style:_e}=V,Ie=[],Ue=[];let Ve=!1;const at=[];for(let Xe=0;Xe<Pe.points.length;Xe++){const Nt=Pe.points[Xe],kt=X(jt(xe,Nt));if(!l(Nt.y)||Number.isNaN(kt)){Ve=!1;continue}at[Xe]=!0;const Pt=Nt.y,ft=Be?Be.take(Xe,Pt):null,mt=X(je.of(ft?ft[1]:Pt)),Ct=X(je.of(ft?ft[0]:$e));V.step&&Ve&&Ie.push("L",kt,V.previous),Ie.push(Ve?"L":"M",kt,mt),V.previous=mt,Le&&Ue.push(Ve?"L":"M",kt,mt),Le&&!Ve&&Ue.push("M",kt,mt),Ve=!0,Nt.px=kt,Nt.py=mt,Nt.pbase=Ct}if(U(V.pool.next("path",`${h}__line ${h}__mark`),{d:Ie.length?ge(Ie):"",stroke:Ce,"data-series":V.index,"stroke-width":_e?_e.width:null,"stroke-dasharray":_e?_e.dash:null,opacity:_e?_e.opacity:null}),!Le){xt({...V,placed:at});return}const et=[];let ct=[];const Mt=()=>{if(ct.length<2){ct=[];return}et.push("M",ct[0].x,ct[0].base);for(const Xe of ct)et.push("L",Xe.x,Xe.y);for(let Xe=ct.length-1;Xe>=0;Xe--)et.push("L",ct[Xe].x,ct[Xe].base);et.push("Z"),ct=[]};for(const Xe of Pe.points){if(!l(Xe.y)||Xe.px===void 0){Mt();continue}ct.push({x:Xe.px,y:Xe.py,base:Xe.pbase})}Mt(),U(V.pool.next("path",`${h}__area ${h}__mark`),{d:et.length?ge(et):"",fill:Ce,"data-series":V.index,opacity:_e?_e.emphasized?"1":_e.opacity:null}),xt({...V,placed:at})}function xt(V){const{series:Pe,placed:xe}=V;for(let je=0;je<Pe.points.length;je++){if(!xe[je]||xe[je-1]||xe[je+1])continue;const $e=Pe.points[je];U(V.pool.next("circle",`${h}__point ${h}__mark`),{cx:$e.px,cy:$e.py,r:L,fill:V.colour,"data-series":V.index,"data-point":je})}}function At(V,Pe){const xe=V&&V.range;if(!Array.isArray(xe)||xe.length!==2)return Pe;const[je,$e]=xe;return!Number.isFinite(je)||!Number.isFinite($e)||!Number.isFinite(Pe)?Pe:Math.min(Math.max(je,$e),Math.max(Math.min(je,$e),Pe))}function un(V){const{series:Pe,xScale:xe,yScale:je,baseline:$e,colour:Le,stack:Ce,slot:Be}=V;for(let _e=0;_e<Pe.points.length;_e++){const Ie=Pe.points[_e];if(!l(Ie.y))continue;const Ue=xe.kind==="band"?xe.of(Ie.x):jt(xe,Ie)-Be.span/2;if(Number.isNaN(Ue))continue;const Ve=Ie.y,at=V.pointColour&&V.pointColour(Ie)||Le,et=Ce?Ce.take(_e,Ve):[$e,Ve],ct=At(je,je.of(et[1])),Mt=At(je,je.of(et[0])),Xe=Ue+Be.offset,Nt=xe.kind==="band"?Xe:At(xe,Xe),kt=xe.kind==="band"?Xe+Be.width:At(xe,Xe+Be.width),Pt=V.pool.next("rect",`${h}__bar ${h}__mark`,`${Pe.key}:${v(Ie.x)}`);U(Pt,{x:X(Nt),y:X(Math.min(ct,Mt)),width:X(Math.max(0,kt-Nt)),height:X(Math.max(1,Math.abs(Mt-ct))),fill:at,"data-series":V.index,"data-point":_e}),Ie.px=X(Ue+Be.offset+Be.width/2),Ie.py=X(Math.min(ct,Mt)),Ie.pbase=X(Math.max(ct,Mt))}}function qt(V){const{series:Pe,xScale:xe,yScale:je}=V;let $e=0;for(let Le=0;Le<Pe.points.length;Le++){const Ce=Pe.points[Le];if(!l(Ce.y))continue;const Be=Ce.y,_e=Le===Pe.points.length-1,Ie=V.total&&_e?0:$e,Ue=(V.total&&_e,$e+Be);V.total,$e+=Be;const Ve=At(je,je.of(Math.max(Ie,Ue))),at=At(je,je.of(Math.min(Ie,Ue))),et=V.pool.next("rect",`${h}__bar ${h}__mark`,`${Pe.key}:${v(Ce.x)}`);U(et,{x:X(xe.of(Ce.x)),y:X(Ve),width:X(xe.bandwidth),height:X(Math.max(1,at-Ve)),fill:Be>=0?V.positive:V.negative,"data-series":V.index,"data-point":Le}),Ce.px=X(xe.of(Ce.x)+xe.bandwidth/2),Ce.py=X(Ve)}}function Yt(V){const{series:Pe,valueScale:xe,baseline:je,colour:$e,stack:Le,slot:Ce}=V;for(let Be=0;Be<Pe.points.length;Be++){const _e=Pe.points[Be];if(!l(_e.y))continue;const Ie=V.bandScale.of(_e.x);if(Number.isNaN(Ie))continue;const Ue=_e.y,Ve=V.pointColour&&V.pointColour(_e)||$e,at=Le?Le.take(Be,Ue):[je,Ue],et=At(xe,xe.of(at[0])),ct=At(xe,xe.of(at[1]));U(V.pool.next("rect",`${h}__bar ${h}__mark`,`${Pe.key}:${v(_e.x)}`),{x:X(Math.min(et,ct)),y:X(Ie+Ce.offset),width:X(Math.max(1,Math.abs(ct-et))),height:X(Math.max(0,Ce.width)),fill:Ve,"data-series":V.index,"data-point":Be}),_e.px=X(ct),_e.py=X(Ie+Ce.offset+Ce.width/2),_e.pbase=X(et)}}function Lt(V){const Pe=V.group.ownerDocument;let xe=null;for(const Le of V.group.childNodes||[])if(Le&&String(Le.getAttribute&&Le.getAttribute("class"))===`${h}__fits`){xe=Le;break}xe||(xe=Pe.createElementNS(E,"g"),xe.setAttribute("class",`${h}__fits`),V.group.appendChild(xe));const je=new B(xe),$e=[];for(const Le of V.series){let Ce=0,Be=0,_e=0;for(const ft of Le.points){const mt=Number(ft.x),Ct=Number(ft.y);!Number.isFinite(mt)||!Number.isFinite(Ct)||(Ce++,Be+=mt,_e+=Ct)}if(Ce<2)continue;const Ie=Be/Ce,Ue=_e/Ce;let Ve=0,at=0,et=0,ct=1/0,Mt=-1/0;for(const ft of Le.points){const mt=Number(ft.x),Ct=Number(ft.y);if(!Number.isFinite(mt)||!Number.isFinite(Ct))continue;const _t=mt-Ie,fn=Ct-Ue;Ve+=_t*_t,at+=_t*fn,et+=fn*fn,mt<ct&&(ct=mt),mt>Mt&&(Mt=mt)}if(Ve===0)continue;const Xe=at/Ve,Nt=Ue-Xe*Ie,kt=et===0?1:Math.max(0,Math.min(1,at*at/(Ve*et))),Pt=V.scheme.series(Le.index);if(U(je.next("path",`${h}__fit`),{d:ge(["M",X(V.xScale.of(ct)),X(V.yScale.of(Nt+Xe*ct)),"L",X(V.xScale.of(Mt)),X(V.yScale.of(Nt+Xe*Mt))]),fill:"none",stroke:Pt,"data-series":Le.index}),V.showR2){const ft=je.next("text",`${h}__fit-label`);m(ft,V.size),U(ft,{x:X(V.xScale.of(Mt)),y:X(V.yScale.of(Nt+Xe*Mt))-4,"text-anchor":"end",fill:Pt}),ce(ft,V.grid.messages.t("chart.r2",{value:z(V.grid,kt)}))}$e.push({key:Le.key,slope:Xe,intercept:Nt,r2:kt,n:Ce})}return je.finish(),$e}function Wt(V){const Pe=V.group.ownerDocument;let xe=null;for(const Ie of V.group.childNodes||[])if(Ie&&String(Ie.getAttribute&&Ie.getAttribute("class"))===`${h}__band`){xe=Ie;break}xe||(xe=Pe.createElementNS(E,"g"),xe.setAttribute("class",`${h}__band`),V.group.firstChild?V.group.insertBefore(xe,V.group.firstChild):V.group.appendChild(xe));const je=new B(xe),$e=V.band&&Array.isArray(V.band.points)?V.band.points:[],Le=Number.isFinite(V.index)?Number(V.index):0,Ce=V.scheme.series(Le),Be=Number.isFinite(V.opacity)?Number(V.opacity):.15,_e=[];for(const Ie of $e){const Ue=Number(Ie.x),Ve=Number(Ie.lower),at=Number(Ie.upper);if(!Number.isFinite(Ue)||!Number.isFinite(Ve)||!Number.isFinite(at))continue;const et=Number(Ie.yhat);_e.push({x:X(V.xScale.of(Ue)),lower:X(V.yScale.of(Ve)),upper:X(V.yScale.of(at)),yhat:Number.isFinite(et)?X(V.yScale.of(et)):null})}if(_e.length>=2&&(U(je.next("path",`${h}__band-fill`),{d:A(_e),fill:Ce,"fill-opacity":Be,stroke:"none","data-series":Le}),V.line!==!1)){const Ie=[];let Ue=!1;for(const Ve of _e){if(Ve.yhat===null){Ue=!1;continue}Ie.push(Ue?"L":"M",Ve.x,Ve.yhat),Ue=!0}U(je.next("path",`${h}__band-line`),{d:Ie.length?ge(Ie):"",fill:"none",stroke:Ce,"data-series":Le})}return je.finish(),{points:_e.length,confidence:V.band&&Number.isFinite(V.band.confidence)?Number(V.band.confidence):null}}function en(V){const Pe=V.group.ownerDocument;let xe=null;for(const _e of V.group.childNodes||[])if(_e&&String(_e.getAttribute&&_e.getAttribute("class"))===`${h}__whiskers`){xe=_e;break}xe||(xe=Pe.createElementNS(E,"g"),xe.setAttribute("class",`${h}__whiskers`),V.group.appendChild(xe));const je=new B(xe),$e=Number.isFinite(V.cap)?Number(V.cap):4,Le=V.colour||"currentColor",Ce=V.orient!=="v";let Be=0;for(const _e of V.points||[]){const Ie=Number(_e.main),Ue=Number(_e.lo),Ve=Number(_e.hi);if(!Number.isFinite(Ie)||!Number.isFinite(Ue)||!Number.isFinite(Ve))continue;const at=Ce?["M",Ue,Ie,"L",Ve,Ie,"M",Ue,Ie-$e,"L",Ue,Ie+$e,"M",Ve,Ie-$e,"L",Ve,Ie+$e]:["M",Ie,Ue,"L",Ie,Ve,"M",Ie-$e,Ue,"L",Ie+$e,Ue,"M",Ie-$e,Ve,"L",Ie+$e,Ve];U(je.next("path",`${h}__whisker`),{d:ge(at),stroke:Le,fill:"none"}),Be++}return je.finish(),Be}function nn(V){const Pe=V.scheme||S(),xe=V.typography||{small:V.fontSize||11,axisTitle:11},{plot:je,bound:$e}=V,Le=$e.series[0]&&$e.series[0].points||[],Ce=Le.map(et=>et.label),Be=Pe.series(0),_e=b(Ce,[je.top,je.bottom],.4),Ie=[0];for(const et of Le)for(const ct of[et.x,et.lower,et.upper])Number.isFinite(ct)&&Ie.push(ct);const Ue=C(F(Ie,{zero:!1}),[je.left,je.right]);en({group:V.groups.overlay,orient:"h",colour:Be,points:Le.map(et=>({main:X(_e.centre(et.label)),lo:X(Ue.of(et.lower)),hi:X(Ue.of(et.upper))}))});const Ve=new B(V.groups.marks);let at=0;for(const et of Le)Number.isFinite(et.x)&&(U(Ve.next("circle",`${h}__point ${h}__mark`),{cx:X(Ue.of(et.x)),cy:X(_e.centre(et.label)),r:L,fill:Be}),at++);return Ve.finish(),tt({group:V.groups.rules,plot:je,scale:Ue,lines:[{value:0}]}),te({group:V.groups.axis,plot:je,scale:Ue,format:G(V.grid,{kind:"linear",step:(Ue.domain.max-Ue.domain.min)/5}),config:{},grid:V.grid,size:xe.small}),pe({group:V.groups.labels,plot:je,scale:_e,labels:Ce,fontSize:xe.small,config:{}}),{series:[],marks:at}}function tt(V){const Pe=new B(e(V.group,`${h}__reflines`));for(const xe of V.lines||[]){if(!l(xe.value))continue;const je=X(V.scale.of(xe.value));if(U(Pe.next("path",`${h}__reference`),{d:ge(["M",X(V.plot.left),je,"L",X(V.plot.right),je]),stroke:xe.colour||"currentColor","stroke-dasharray":"4 3",fill:"none"}),!xe.label)continue;const $e=Pe.next("text",`${h}__reference-label`);U($e,{x:X(V.plot.right-4),y:je-4,"text-anchor":"end"}),ce($e,xe.label)}Pe.finish()}function dt(V){const{series:Pe,xScale:xe,yScale:je,colour:$e}=V,Le=V.size||null;for(let Ce=0;Ce<Pe.points.length;Ce++){const Be=Pe.points[Ce];if(!l(Be.y))continue;const _e=X(jt(xe,Be));if(Number.isNaN(_e))continue;const Ie=X(je.of(Be.y));U(V.pool.next("circle",`${h}__point ${h}__mark`),{cx:_e,cy:Ie,r:Le&&l(Be.size)?X(Le.of(Be.size)):L,fill:$e,"fill-opacity":Le?.7:1,"data-series":V.index,"data-point":Ce}),Be.px=_e,Be.py=Ie}}function ut(V){const{group:Pe,series:xe,xScale:je,yScale:$e,options:Le}=V,Ce=V.grid&&V.grid.statistics,Be=Ce&&typeof Ce.intervalOf=="function"?(Mt,Xe)=>Ce.intervalOf(Mt,Xe):null,_e=new B(e(Pe,`${h}__errorbars`)),Ie=Number.isFinite(Number(Le.confidence))?Number(Le.confidence):.95,Ue=4;let Ve=0,at=0,et=0,ct=0;for(const Mt of xe)for(const Xe of Mt.points){if(Xe.y===null||Xe.y===void 0)continue;at++;const Nt=Array.isArray(Xe.values)&&Xe.values.length===1;Nt&&et++;let kt=null,Pt=null;if(Le.of!==void 0&&Number.isFinite(Number(Xe[Le.of]))){const _t=Math.abs(Number(Xe[Le.of]));kt=Xe.y-_t,Pt=Xe.y+_t}else if(Array.isArray(Xe.values)&&Xe.values.length>1&&Be){const _t=Be(Xe.values,Ie);_t&&(kt=_t.lower,Pt=_t.upper)}if(kt===null||!Number.isFinite(kt)||!Number.isFinite(Pt)){Nt&&ct++;continue}const ft=X(je.of(Xe.xKey!==void 0?Xe.xKey:Xe.x)+(je.bandwidth?je.bandwidth/2:0)),mt=X($e.of(Pt)),Ct=X($e.of(kt));U(_e.next("path",`${h}__error-bar ${h}__mark`),{d:ge(["M",ft-Ue,mt,"L",ft+Ue,mt,"M",ft,mt,"L",ft,Ct,"M",ft-Ue,Ct,"L",ft+Ue,Ct]),fill:"none",stroke:"currentColor","data-lower":kt,"data-upper":Pt}),Ve++}return _e.finish(),{drawn:Ve,marks:at,single:et,singleSkipped:ct}}function $t(V){const Pe=V.scheme||S(),xe=V.axis||{x:{},y:{},y2:{}},je=V.typography||{small:V.fontSize||11,axisTitle:11},{bound:$e,plot:Le,type:Ce}=V,Be=ee[Ce]||ee.line,_e=$e.series.filter(rt=>!V.hidden.has(rt.key)),Ie=!!Be.horizontal,Ue=!Ie&&xe.y.position==="right"?"right":"left",Ve=Ue==="right"?"left":"right",at=(Ce==="bar"||Ce==="horizontalBar")&&V.byRuleColour&&_e.length===1&&$e.measure&&$e.measure.col||null,et=at?new Set:null,ct=at?rt=>{const gt=r({grid:V.grid,col:at,value:rt.y});return gt&&et.add(gt),gt}:null,Xe=(Ce==="bar"||Ce==="horizontalBar")&&V.byRuleColour&&_e.length===1&&Pe.nameMap?rt=>Pe.series(0,rt.label):null,Nt=ct||Xe?rt=>ct&&ct(rt)||Xe&&Xe(rt)||null:null,kt=!Ie&&Ce!=="waterfall"?_e.filter(rt=>rt.axis==="right"):[],Pt=kt.length?_e.filter(rt=>rt.axis!=="right"):_e,ft=kt.length>0,mt=(Ce==="bar"||Ce==="area"||Ce==="horizontalBar")&&!ft,Ct=V.stack==="percent"&&mt&&Pt.length>1,_t=(Ct||!!V.stack)&&Pt.length>1&&mt,fn=Ce==="waterfall"?Me(_e[0]):de(Pt,_t,Ct),rn=$e.yDomain||V.domain||F(fn,{zero:Be.zero,min:xe.y.min,max:xe.y.max}),Kt=Ie?C(rn,[Le.left,Le.right]):C(rn,[Le.bottom,Le.top]),yt=Ie?b($e.categories,[Le.top,Le.bottom],.2):Ot($e,Le,Ce,xe.x),hn=rn.min<=0&&rn.max>=0?0:rn.min,En=kt.some(rt=>(rt.mark||(Ce==="bar"?"bar":Ce))==="bar"),on=ft?F(de(kt,!1,!1),{zero:En,min:xe.y2.min,max:xe.y2.max}):null,Vt=on?C(on,[Le.bottom,Le.top]):null,yn=G(V.grid,{kind:"linear",step:(rn.max-rn.min)/5}),mn=V.axes!==!1;if(mn&&Z({gridGroup:V.groups.grid,axisGroup:V.groups.axis,plot:Le,scale:Kt,format:yn,horizontal:Ie,side:Ue,config:xe.y,grid:V.grid,size:je.small}),mn)if(Ie)pe({group:V.groups.overlay,plot:Le,scale:yt,labels:$e.labels,fontSize:je.small,config:xe.x});else if(yt.kind==="band")me({group:V.groups.overlay,plot:Le,scale:yt,labels:$e.labels,fontSize:je.small,rotated:D($e.labels,yt.step,je.small,xe.x.every),config:xe.x});else{const rt=$e.dimension&&$e.dimension.col?V.grid.columns.get($e.dimension.col):void 0;te({group:V.groups.overlay,plot:Le,scale:yt,format:G(V.grid,{kind:$e.kind,span:yt.domain.max-yt.domain.min,step:(yt.domain.max-yt.domain.min)/5},rt),config:xe.x,grid:V.grid,column:rt,size:je.small})}if(mn&&(Q({group:V.groups.rules,plot:Le,side:Ue}),$({group:V.groups.axis,plot:Le,text:xe.y.title,side:Ie?"bottom":Ue,size:je.axisTitle}),$({group:V.groups.axis,plot:Le,text:xe.x.title,side:Ie?"left":"bottom",size:je.axisTitle})),mn&&Vt){k({group:V.groups.axis,plot:Le,scale:Vt,colour:Pe.series(kt[0].index),side:Ve,format:G(V.grid,{kind:"linear",step:(on.max-on.min)/5})});const rt=xe.y2.title||(kt.length===1?kt[0].label:"");$({group:V.groups.axis,plot:Le,text:rt,side:Ve,size:je.axisTitle}),!xe.y.title&&Pt.length===1&&Pt[0].label&&$({group:V.groups.axis,plot:Le,text:Pt[0].label,side:Ue,size:je.axisTitle})}const wn=Number.isFinite(V.downsampleTo)?Number(V.downsampleTo):Math.max(2,Math.round(Le.width));let On=!1;if(Be.marks==="path"||Ce==="scatter"||Ce==="bubble"){for(const rt of _e)if(rt.kept=null,rt.points.length>wn*1.5){const gt=rt.points.map((Ft,Rt)=>({x:Rt,y:Ft.y,point:Ft})),ot=d(gt,wn);rt.points=ot.map(Ft=>Ft.point),rt.kept=ot.map(Ft=>Ft.x),On=!0}}V.pool||P(V.groups,Le,H(Ce));const ln=V.pool||new B(V.groups.marks),kn=Ct?$e.categories.map((rt,gt)=>_e.reduce((ot,Ft)=>{const Rt=Ft.points[gt]?Ft.points[gt].y:null;return l(Rt)?ot+Math.abs(Rt):ot},0)):null,vn=_t?ie($e.categories.length,kn):null,xn=ft?_e.filter(rt=>(rt.mark||(Ce==="bar"?"bar":Ce))==="bar"):_e,Tn=ft?Math.max(1,xn.length):Math.max(1,_e.length),Hn=Ce==="bar"||ft&&xn.length>0,gn=yt.kind==="band"?yt.bandwidth:Hn?Ye({bound:$e,scale:yt,config:xe.x,padding:Ee("bar")}):0,Gt=_t?gn:gn/Tn,Xt=new Map;for(const rt of xn)Xt.set(rt.key,Xt.size);const cn=[];for(let rt=0;rt<_e.length;rt++){const gt=_e[rt],ot=Pe.series(gt.index,gt.label),Ft=gt.axis==="right"&&Vt?Vt:Kt,Rt=ft?gt.mark||(Ce==="bar"?"bar":Ce):Ce,An=ft&&Xt.has(gt.key)?Xt.get(gt.key):rt;if(Ce==="horizontalBar")Yt({pool:ln,series:gt,bandScale:yt,valueScale:Kt,baseline:hn,colour:ot,stack:vn,index:gt.index,slot:{offset:_t?0:rt*Gt,width:Gt,span:gn},pointColour:Nt});else if(Ce==="waterfall")qt({pool:ln,series:gt,xScale:yt,yScale:Kt,index:gt.index,total:!0,positive:Pe.positive,negative:Pe.negative});else if(Rt==="bar")un({pool:ln,series:gt,xScale:yt,yScale:Ft,baseline:Ft===Vt?on.min<=0&&on.max>=0?0:on.min:hn,colour:ot,stack:vn,index:gt.index,slot:{offset:_t?0:An*Gt,width:Gt,span:gn},pointColour:Nt});else if(Ce==="scatter"||Ce==="bubble")dt({pool:ln,series:gt,xScale:yt,yScale:Ft,colour:ot,index:gt.index,size:Ce==="bubble"?V.sizes:null});else{const pn=Bt(V,gt.label),an={pool:ln,series:gt,xScale:yt,yScale:Ft,baseline:hn,fill:Rt==="area"||Rt==="rangeArea",step:Rt==="step",colour:ot,stack:vn,index:gt.index,style:pn};pn.emphasized?cn.push(an):Ht(an)}}for(const rt of cn)Ht(rt);V.pool||ln.finish(),V.band&&typeof yt.invert=="function"&&Wt({group:V.groups.overlay,band:V.band,xScale:yt,yScale:Kt,scheme:Pe,index:0,line:V.band.line!==!1&&!V.fit}),V.fit&&(Ce==="scatter"||Ce==="bubble")&&typeof yt.invert=="function"&&Lt({group:V.groups.overlay,series:_e,xScale:yt,yScale:Kt,plot:Le,scheme:Pe,grid:V.grid,size:je.small,showR2:V.fit!=="line"});let Zt=null;V.trend&&(Zt=n({group:V.groups.overlay,series:_e,xScale:yt,yScale:Kt,rightScale:Vt,plot:Le,scheme:Pe,trend:V.trend,grid:V.grid,format:rt=>yn.tick(rt),size:je.small,clip:V.groups.boxClipId}));let st=null;if(V.error&&(st=ut({group:V.groups.overlay,series:_e,xScale:yt,yScale:Kt,grid:V.grid,options:V.error===!0?{}:V.error})),V.labels&&V.labels.show&&g({group:V.groups.labels,series:_e,plot:Le,options:V.labels,grid:V.grid,size:je.small,horizontal:Ie}),V.reference&&V.reference.length){const rt=V.reference.filter(ot=>!(ot.axis==="right"||ot.axis==="y2")),gt=Vt?V.reference.filter(ot=>ot.axis==="right"||ot.axis==="y2"):[];rt.length&&tt({group:V.groups.overlay,plot:Le,scale:Kt,lines:rt}),gt.length&&tt({group:V.groups.overlay,plot:Le,scale:Vt,lines:gt})}let sn=null;V.annotations&&V.annotations.length&&(sn=p({group:V.groups.overlay,plot:Le,xScale:yt,yScale:Kt,rightScale:Vt,series:_e,annotations:V.annotations,dual:ft,format:rt=>yn.tick(rt),size:je.small}));const wt=Array.isArray(Zt)&&Zt.length?[...sn||[],...Zt]:sn;return{xScale:yt,yScale:Kt,rightScale:Vt,dual:ft,series:_e,horizontal:Ie,percent:Ct,plot:Le,errorBars:st,annotations:wt,trendlines:Zt,reduced:On,legend:at?a({grid:V.grid,col:at,colours:et}):null}}const It=32;function Et(V){const{series:Pe,xScale:xe,at:je}=V,$e=Number.isFinite(V.tolerance)?Number(V.tolerance):It,Le=[];let Ce=-1,Be=1/0;for(const _e of Pe){let Ie=null,Ue=-1,Ve=1/0;const at=_e.points||[];for(let et=0;et<at.length;et++){const ct=at[et];if(!ct||!l(ct.y))continue;const Mt=jt(xe,ct);if(Number.isNaN(Mt))continue;const Xe=Math.abs(Mt-je);Xe>=Ve||(Ve=Xe,Ie=ct,Ue=Array.isArray(_e.kept)?_e.kept[et]:et)}!Ie||Ve>$e||(Le.push({series:_e,point:Ie}),Ve<Be&&(Be=Ve,Ce=Ue))}return Ce<0?null:{index:Ce,entries:Le}}function zt(V){const{bound:Pe,xScale:xe,at:je}=V;if(!Pe.categories.length)return-1;if(xe.kind==="band"){const Ce=Math.floor((je-xe.range[0])/(xe.step||1));return Ce>=0&&Ce<Pe.categories.length?Ce:-1}let $e=-1,Le=1/0;for(let Ce=0;Ce<Pe.categories.length;Ce++){const Be=xe.kind==="time"?re(Pe.categories[Ce]):J(Pe.categories[Ce]);if(Be===null)continue;const _e=Math.abs(xe.of(Be)-je);_e<Le&&(Le=_e,$e=Ce)}return $e}function Jt(V,Pe){return Pe<0||Pe>=V.categories.length?"":v(V.categories[Pe])}}),Je("packages/modules/charts/drawable.js",function(o,Y){"use strict";Object.defineProperty(o,"REASONS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"DRAWABLE",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"namedColumns",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"missingColumns",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"bucketKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"bucketMessage",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"drawability",{enumerable:!0,get:function(){return I}});const ke=Y("packages/modules/charts/scale.js"),Q=ke.extent,$=ke.toNumber,pe=ke.toTime,te=Y("packages/modules/charts/cartesian.js").staleWindow,Z=Object.freeze({EMPTY:"empty",INCOMPLETE:"incomplete",STALE:"stale",MISSING_COLUMN:"missing-column",NO_DOMAIN:"no-domain",BUCKETED:"bucketed"}),H=Object.freeze({ok:!0});function ue(G){if(!G||typeof G!="object")return[];const z=[],x=(b,f)=>{typeof f=="string"&&f?z.push({key:b,col:f}):f&&typeof f=="object"&&typeof f.col=="string"&&f.col&&z.push({key:b,col:f.col})};if(Array.isArray(G.points))return[];if(x("x",G.x),x("code",G.code),x("y",G.y),x("series",G.series),x("size",G.size),x("source",G.source),x("target",G.target),typeof G.multiples=="string"&&x("multiples",G.multiples),Array.isArray(G.measures))for(const b of G.measures)x("measures",b);return z}function P(G,z){const x=G&&G.columns;return!x||typeof x.get!="function"?[]:ue(z).filter(({col:b})=>!x.get(b))}function y(G){return`chart:x:date-bucket:${G}`}function B(G,z,x){return`chart x column ${JSON.stringify(G)} is a 'date', which stores a calendar day, so all ${z} rows collapsed into one point and were reduced by '${x}'. For a series inside a single day, type the column 'datetime' or bind epoch milliseconds.`}function D(G,z){return!z||z.kind!=="time"&&z.kind!=="linear"?!1:G!=="bar"&&G!=="horizontalBar"}function I(G){const{grid:z,spec:x,type:b,bound:f}=G,l=G.id===void 0?"":String(G.id),v=Number.isFinite(G.now)?Number(G.now):Date.now(),C=(J,re,q,U=!0)=>({ok:!1,reason:J,key:q||`chart:${l}:${J}`,message:re,tell:U}),F=P(z,x);if(F.length){const J=F.map(q=>`${q.key}: ${JSON.stringify(q.col)}`).join(", "),re=z&&z.columns&&typeof z.columns.all=="function"?z.columns.all().map(q=>q.id||q.field).filter(Boolean):[];return C(Z.MISSING_COLUMN,`chart ${J} ${F.length>1?"name columns":"names a column"} this grid does not have, so there is nothing to read and nothing to draw.${re.length?` The columns it does have: ${re.slice(0,12).map(q=>JSON.stringify(q)).join(", ")}${re.length>12?", …":""}.`:""} Bind a column the grid declares, or declare the column.`)}if(f&&f.empty){const J=z&&z.rows&&typeof z.rows.count=="function"?z.rows.count():0;return C(Z.EMPTY,J?`chart bound nothing from the ${J} row(s) the grid is showing, so it shows its empty state. The binding named no series to draw: check that the spec names the columns this chart needs — a flow type needs source and target, a measure needs a column with values in it.`:"chart has no rows to draw, so it shows its empty state.",void 0,J>0)}if(b==="candlestick"&&(!f||!f.series||f.series.length<4)){const J=f&&f.series?f.series.length:0;return C(Z.INCOMPLETE,`a candlestick chart needs four measures — open, high, low and close, in that order — and ${J===0?"none was":`only ${J} were`} bound. Pass them as measures: [open, high, low, close].`)}const _=te(f,G.axis&&G.axis.x,b,v);if(_){const J=_.newest===null?"and every one of them is stamped ahead of it":`and the newest of ${_.points} x value(s) is ${Math.round(_.age/1e3)}s old`;return C(Z.STALE,`the rolling x window covers the last ${_.span} ms, ${J}, so every mark would be drawn outside the plot. The chart shows its empty state instead. Seed it with data inside the window, widen axis.x.window.span, or drop the window while showing history.`,`chart:${l}:x:window:stale:${x&&x.x||""}`,_.newest!==null)}if(D(b,f)){const J=Array.isArray(f.categories)?f.categories:[],re=f.kind==="time"?J.map(pe):J.map($);if(J.length&&!Q(re)){const q=x&&typeof x.x=="string"&&x.x||f.dimension&&f.dimension.col||"";return C(Z.NO_DOMAIN,`chart x ${q?`column ${JSON.stringify(q)} `:""}is drawn on a ${f.kind==="time"?"time":"continuous"} axis, and not one of its ${J.length} value(s) reads as a ${f.kind==="time"?"date":"number"} — so the axis would be drawn over a domain invented from nothing rather than measured from the data. Remove axis.x.scale to let the column choose its own scale, or type the column so its values parse.`)}}if(f&&f.bucketed&&D(b,f)){const{col:J,rows:re,fn:q}=f.bucketed;return C(Z.BUCKETED,B(J,re,q),y(J))}return H}}),Je("packages/modules/charts/bind.js",function(o,Y){"use strict";Object.defineProperty(o,"AGGREGATIONS",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"DEFAULT_AGGREGATION",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"resolveAggregation",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"defaultAggregationFor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureOf",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"walkRows",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"leafRows",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"selectedRows",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"topGroups",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"forcedScaleKind",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"scaleKindFor",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"bindSeries",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"bindPoints",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"bindMeasures",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"bindLinks",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"bindHierarchy",{enumerable:!0,get:function(){return ce}});const ke=Y("packages/modules/charts/scale.js"),Q=ke.key,$=ke.toNumber,pe=ke.toTime,me=Y("packages/modules/charts/drawable.js"),te=me.bucketKey,Z=me.bucketMessage,ue=Y("packages/core/src/internal/util.js").warnOnce,P={sum:E=>E.length?E.reduce((W,h)=>W+h,0):null,avg:E=>E.length?E.reduce((W,h)=>W+h,0)/E.length:null,mean:E=>E.length?E.reduce((W,h)=>W+h,0)/E.length:null,min:E=>{let W=null;for(let h=0;h<E.length;h++)(W===null||E[h]<W)&&(W=E[h]);return W},max:E=>{let W=null;for(let h=0;h<E.length;h++)(W===null||E[h]>W)&&(W=E[h]);return W},median:E=>{if(!E.length)return null;const W=E.slice().sort((c,d)=>c-d),h=(W.length-1)/2,s=Math.floor(h),g=Math.ceil(h);return s===g?W[s]:(W[s]+W[g])/2},count:(E,W)=>W,countValues:E=>E.length,first:E=>E.length?E[0]:null,last:E=>E.length?E[E.length-1]:null},y="sum";function B(E){return E==null?y:typeof E=="string"&&E in P?E:(ue(`chart:measure:fn:${String(E)}`,`chart measure fn ${JSON.stringify(E)} is not a known aggregation; using '${y}'. Supported: ${Object.keys(P).join(", ")}.`),y)}function D(E){if(!E)return y;const W=E.groupTotal??E.total;if(typeof W=="string"&&W in P)return W;const h=E.dataType&&E.dataType.totals?E.dataType.totals.supported:null;if(Array.isArray(h)&&!h.includes(y)){const s=["avg","mean","max","min","countValues","count"].find(g=>h.includes(g)&&g in P);if(s)return s}return y}function I(E,W){const h=D(W);return E?typeof E=="string"?{col:E,fn:h}:{col:E.col||null,fn:E.fn==null?h:B(E.fn)}:{col:null,fn:h}}function G(E,W){const h=new Set,s=g=>{if(!g||h.has(g)||(h.add(g),W(g),!g.group)||g.expanded)return;const c=g.filteredChildren||g.children;if(Array.isArray(c))for(const d of c)s(d)};E.rows.forEach(s)}function z(E){const W=[];return G(E,h=>{!h.group&&h.data!==null&&h.data!==void 0&&W.push(h)}),W}function x(E){const W=new Set(E.selection.keys());if(!W.size)return[];const h=[];return G(E,s=>{!s.group&&W.has(s.key)&&h.push(s)}),h}function b(E){const W=[];let h=1/0;return G(E,s=>{s.group&&(s.level<h&&(h=s.level,W.length=0),s.level===h&&W.push(s))}),W}function f(E,W,h){return W.group&&W.totals&&h in W.totals?$(W.totals[h]):$(E.rows.value(W.key,h))}function l(E,W,h,s){if(!W.group){const g=E.rows.text(W.key,h);if(g)return g}return s==null?"":s instanceof Date?s.toISOString().slice(0,10):String(s)}function v(E,W){return(P[W]||P[y])(E.values,E.rows)}const C=Object.freeze(["number","currency","percent"]),F=Object.freeze(["date","datetime","timestamp","dateString"]),_=Object.freeze({auto:"",band:"category",category:"category",linear:"linear",time:"time"});function J(E){const W=E&&typeof E=="object"?E.axis:null;if(!W||typeof W!="object")return"";const h=W.x;if(!h||typeof h!="object")return"";const s=typeof h.scale=="string"?h.scale:"";return s?Object.hasOwn(_,s)?_[s]:(ue(`chart:x:scale:unknown:${s}`,`chart axis.x.scale ${JSON.stringify(s)} is not a scale this chart draws. Use one of: ${Object.keys(_).join(", ")}. The scale was chosen from the column instead.`),""):""}function re(E){if(E.length<3)return"";let W=0,h=0;for(const s of E){if(s==null||s===""||typeof s=="boolean")return"";$(s)!==null?W++:typeof s=="string"&&pe(s)!==null&&h++}return h===E.length?"time":W===E.length?"linear":""}function q(E,W,h={}){if(h.forced)return h.forced;const s=E&&typeof E.type=="string"?E.type:"";if(F.includes(s)||W.length&&W.every(d=>d instanceof Date))return"time";if(C.includes(s))return"linear";const g=h.id?String(h.id):"";if(!g)return"category";const c=s&&s!=="text"?"":re(W);return c&&ue(`chart:x:banded:${g}`,`chart x column ${JSON.stringify(g)} is typed ${JSON.stringify(s||"text")}, so its ${W.length} values are drawn as categories on a band scale even though they all read as ${c==="time"?"dates":"numbers"}. Type the column ${c==="time"?"'date' (or 'datetime'/'timestamp'/'dateString')":"'number'"} for a continuous axis, or pin it with axis: { x: { scale: '${c}' } }.`),"category"}function U(E,W){const h=W.x||null,s=W.series||(typeof W.multiples=="string"?W.multiples:null)||null,g=E.columns,c=h?g.get(h):void 0,d=I(W.y),N=d.col?g.get(d.col):void 0,S=I(W.y,N);let w;const m=typeof W.rows=="function"?W.rows(E):W.rows;Array.isArray(m)?w=m:W.from==="groups"?w=b(E):W.from==="selection"?w=x(E):w=z(E);const u=w.length?w:z(E),k=new Map,R=new Map,p=[];for(let M=0;M<u.length;M++){const L=u[M],ee=h?L.group&&L.groupColumn===h?L.groupValue:E.rows.value(L.key,h):M,fe=Q(ee);k.has(fe)||(k.set(fe,{value:ee,label:h?l(E,L,h,ee):String(M),order:k.size}),p.push(ee));const de=s?L.group&&L.groupColumn===s?L.groupValue:E.rows.value(L.key,s):null,Me=s?Q(de):"";R.has(Me)||R.set(Me,{label:s?l(E,L,s,de):N?.title||"",points:new Map});const ie=R.get(Me);let ve=ie.points.get(fe);ve||(ve={values:[],rows:0,rowKey:L.key},ie.points.set(fe,ve)),ve.rows+=L.group&&L.leafCount||1;const we=S.col?f(E,L,S.col):null;if(we!==null&&ve.values.push(we),W.size){const Ae=$(E.rows.value(L.key,W.size));Ae!==null&&(ve.sizes=(ve.sizes||0)+Ae)}}const e=[...k.values()].sort((M,L)=>M.order-L.order),i=typeof W.limit=="number"&&W.limit>0?e.slice(0,W.limit):e,n=q(c,p,{forced:J(W),id:h});let t=null;n==="time"&&u.length>1&&k.size===1&&c&&(c.type==="date"||c.type==="dateString")&&(t={col:String(h),rows:u.length,fn:S.fn},ue(te(t.col),Z(t.col,t.rows,t.fn)));const a=C.includes(c&&typeof c.type=="string"?c.type:"")?[...i].sort((M,L)=>($(M.value)??0)-($(L.value)??0)):i,T=[...R.entries()].map(([M,L],ee)=>({key:M,label:L.label,index:ee,points:a.map(fe=>{const de=Q(fe.value),Me=L.points.get(de);return{x:fe.value,xKey:de,label:fe.label,y:Me?v(Me,S.fn):null,size:Me&&Me.sizes!==void 0?Me.sizes:null,rows:Me?Me.rows:0,rowKey:Me?Me.rowKey:null,values:Me&&Me.values?Me.values:null}})}));return{series:T,categories:a.map(M=>M.value),labels:a.map(M=>M.label),kind:n,measure:{...S,title:N?.title||S.col||""},dimension:{col:h,title:c?.title||h||""},empty:T.length===0||a.length===0,rows:u.length,truncated:e.length-a.length,bucketed:t}}function ge(E){const W=Array.isArray(E.points)?E.points:[],h=W.length>0&&W.every(c=>typeof c.x=="number"&&Number.isFinite(c.x)),s=c=>typeof c=="number"&&Number.isFinite(c)?c:null,g=W.map((c,d)=>({x:c.x,xKey:Q(c.x),label:c.label!=null?String(c.label):String(c.x),y:s(c.y),size:s(c.size),lower:s(c.lower),upper:s(c.upper),rows:1,rowKey:c.key!=null?String(c.key):String(d),values:null}));return{series:[{key:E.seriesKey||"",label:E.seriesLabel||"",index:0,points:g}],categories:g.map(c=>c.x),labels:g.map(c=>c.label),kind:h?"linear":"category",measure:{col:null,fn:"sum",title:E.measureTitle||""},dimension:{col:null,title:E.dimensionTitle||""},empty:g.length===0,rows:g.length,truncated:0}}function A(E,W){const h=Array.isArray(W.measures)?W.measures:[];if(!h.length)return U(E,W);const s=h.map(N=>{const S=typeof N=="string"?{col:N}:N;return{spec:S,result:U(E,{x:W.x,from:W.from,limit:W.limit,axis:W.axis,y:{col:S.col,fn:S.fn}})}}),g=s[0].result,c=new Map(g.categories.map((N,S)=>[Q(N),S])),d=s.map(({spec:N,result:S},w)=>{const m=E.columns.get(N.col),u=g.categories.map(()=>null),k=S.series[0];if(k)for(const R of k.points){const p=c.get(R.xKey);p!==void 0&&(u[p]=R)}return{key:N.col,label:N.title||N.label||m&&m.title||N.col,index:w,mark:N.type||null,axis:N.axis==="right"?"right":"left",points:g.categories.map((R,p)=>u[p]||{x:R,xKey:Q(R),label:g.labels[p],y:null,rows:0,rowKey:null})}});return{series:d,categories:g.categories,labels:g.labels,kind:g.kind,measure:{col:null,fn:"sum",title:d.map(N=>N.label).join(", ")},dimension:g.dimension,empty:!d.length||!g.categories.length,rows:g.rows,truncated:g.truncated}}function X(E,W,h={}){const s=I(W.y),g=!!h.perRow,c=Array.isArray(h.nodes)?h.nodes:[],d=W.source||W.x||null,N=W.target||null;if(!d||!N)return{nodes:[],links:[],measure:{...s,title:""},dimension:{col:null,title:""},series:[],categories:[],labels:[],empty:!0,total:0};const S=s.col?E.columns.get(s.col):void 0,w=new Map,m=new Map,u=(e,i,n)=>{const t=Q(e);return w.has(t)||w.set(t,{key:t,value:e,label:l(E,i,n,e),index:w.size,in:0,out:0}),w.get(t)},k=new Map;for(const e of c)!e||e.id===null||e.id===void 0||k.set(Q(e.id),e);for(const e of z(E)){const i=E.rows.value(e.key,d),n=E.rows.value(e.key,N);if(i==null||n===null||n===void 0)continue;const t=s.col?$(E.rows.value(e.key,s.col)):1;if(t===null||t<=0)continue;const r=u(i,e,d),a=u(n,e,N);if(g){const T=r.key>a.key,M=T?a:r,L=T?r:a;m.set(`${M.key}\0${L.key}\0${m.size}`,{source:M,target:L,value:t,undirected:!0,pair:`${M.key}\0${L.key}`,rowKeys:[e.key]})}else{const T=`${r.key}\0${a.key}`,M=m.get(T)||{source:r,target:a,value:0,rowKeys:[]};M.value+=t,M.rowKeys.length<64&&M.rowKeys.push(e.key),m.set(T,M)}r.out+=t,a.in+=t}for(const[e,i]of k)w.has(e)||w.set(e,{key:e,value:i.id,label:String(i.label??i.id),index:w.size,in:0,out:0});for(const[e,i]of k){const n=w.get(e);n&&(n.declared=!0,i.label!==void 0&&i.label!==null&&(n.label=String(i.label)),typeof i.icon=="string"&&i.icon&&(n.icon=i.icon),Number.isFinite(i.x)&&Number.isFinite(i.y)&&(n.fx=Number(i.x),n.fy=Number(i.y)))}const R=g?[...m.values()]:[...m.values()].sort((e,i)=>i.value-e.value),p=typeof W.limit=="number"&&W.limit>0?R.slice(0,W.limit):R;return{nodes:[...w.values()],links:p,measure:{...s,title:S?.title||s.col||""},dimension:{col:d,title:E.columns.get(d)?.title||d},series:[],categories:[],labels:[],empty:!p.length,total:p.reduce((e,i)=>e+i.value,0)}}function ce(E,W){const h=I(W.y),s=typeof W.depth=="number"&&W.depth>0?W.depth:1/0,g=h.col?E.columns.get(h.col):void 0,c=(m,u,k)=>({label:m,value:u,depth:k,total:0,children:[],rowKey:null}),d=c("",null,0),N=b(E);if(N.length){const m=(u,k,R)=>{const p=u.groupColumn?l(E,u,u.groupColumn,u.groupValue):"",e=c(p,u.groupValue,R);e.rowKey=u.key;const i=h.col?f(E,u,h.col):null;e.total=i===null?0:Math.abs(i),k.children.push(e);const n=u.filteredChildren||u.children;if(R<s&&Array.isArray(n))for(const t of n)t.group&&m(t,e,R+1);return!e.total&&e.children.length&&(e.total=e.children.reduce((t,r)=>t+r.total,0)),e};for(const u of N)m(u,d,1)}else{const u=U(E,{x:W.x,y:W.y,limit:W.limit}).series[0];if(u)for(const k of u.points){const R=c(k.label,k.x,1);R.total=k.y===null?0:Math.abs(k.y),R.rowKey=k.rowKey,d.children.push(R)}}d.total=d.children.reduce((m,u)=>m+u.total,0);let S=0;const w=m=>{m.depth>S&&(S=m.depth);for(const u of m.children)w(u)};return w(d),{root:d,depth:S,measure:{...h,title:g?.title||h.col||""},empty:d.total<=0||d.children.length===0}}}),Je("packages/core/src/source/filterwire.js",function(o,Y){"use strict";Object.defineProperty(o,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"warnWherePageRelative",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"warnWhereNotApplied",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"warnWhereOverThreshold",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"parseRelativeToken",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"resolveRelativeRange",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"relativeTokenOf",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"relativeTokenHelp",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"isResolvableRelative",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"resolveRelativeCondition",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"isGroup",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"forEachCondition",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"mapConditions",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"normaliseFilterSet",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"buildFilterSet",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"wireFilters",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"querySignature",{enumerable:!0,get:function(){return ce}});const Q=Y("packages/core/src/internal/util.js").warnOnce,$="source.remote.hostFilter",pe="source.where.pageRelative";function me(h,s){!Array.isArray(h)||!h.length||Q(pe,`filters.where (${h.join(", ")}) runs over the rows the ${s} 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 te(h){const s=(h||{}).config;!s||!s.hostFilter||Q($,"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 Z="source.where.notApplied";function H(h,s){Q(`${Z}:${h}`,`filters.where("${h}") is registered but the ${s} 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 P(h,s,g,c){!Array.isArray(h)||!h.length||Q(`${ue}:${s}`,`filters.where (${h.join(", ")}) is not applied to the ${s} pushdown source:`,g===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${g.toLocaleString()} rows, at or past the whereRowLimit of ${c.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 y=new Map;function B(h){let s=y.get(h);return s||(s=new Intl.DateTimeFormat("en-US",{timeZone:h,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),y.set(h,s)),s}function D(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function I(h,s){const g=B(s).formatToParts(new Date(h)),c={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const d of g)d.type==="year"?c.y=+d.value:d.type==="month"?c.m=+d.value:d.type==="day"?c.d=+d.value:d.type==="hour"?c.h=+d.value%24:d.type==="minute"?c.mi=+d.value:d.type==="second"&&(c.s=+d.value);return c}function G(h,s){const g=I(h,s);return Date.UTC(g.y,g.m-1,g.d,g.h,g.mi,g.s)-Math.floor(h/1e3)*1e3}function z(h,s,g,c){const d=Date.UTC(h,s-1,g),N=d-G(d,c);return d-G(N,c)}function x(h,s,g){const c=new Date(Date.UTC(h.y,h.m-1,h.d+s));return z(c.getUTCFullYear(),c.getUTCMonth()+1,c.getUTCDate(),g)}const b=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function f(h,s){if(typeof h!="string")return null;const g=h.trim().toLowerCase().replace(/[\s_-]+/g,""),c=/^last(\d*|n)days?$/.exec(g);if(c){const d=c[1]==="n"?"":c[1],N=Number(d||s);return!Number.isFinite(N)||N<=0?null:{kind:"lastNDays",n:Math.floor(N)}}switch(g){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 l(h,s={}){const g=f(h,s.n);if(!g)return null;const c=s.tz||D(),d=s.now instanceof Date?s.now.getTime():typeof s.now=="number"?s.now:Date.now(),N=I(d,c),S=z(N.y,N.m,N.d,c),w=x(N,1,c);let m=S,u=w;switch(g.kind){case"today":break;case"yesterday":m=x(N,-1,c),u=S;break;case"lastNDays":u=s.includeToday?w:S,m=x(N,s.includeToday?-(g.n-1):-g.n,c);break;case"thisWeek":{const k=Number.isFinite(s.weekStartsOn)?Number(s.weekStartsOn):1,p=(new Date(Date.UTC(N.y,N.m-1,N.d)).getUTCDay()-k+7)%7;m=x(N,-p,c),u=x(N,-p+7,c);break}case"thisMonth":m=z(N.y,N.m,1,c),u=z(N.m===12?N.y+1:N.y,N.m===12?1:N.m+1,1,c);break;case"thisQuarter":case"quarterToDate":{const k=Math.floor((N.m-1)/3)*3+1;m=z(N.y,k,1,c),u=g.kind==="quarterToDate"?w:k===10?z(N.y+1,1,1,c):z(N.y,k+3,1,c);break}case"thisYear":case"yearToDate":m=z(N.y,1,1,c),u=g.kind==="yearToDate"?w:z(N.y+1,1,1,c);break;default:return null}return{from:new Date(m).toISOString(),to:new Date(u).toISOString(),bounds:"[)",tz:c,relative:g.kind==="lastNDays"?`last${g.n}Days`:g.kind,n:g.n}}function v(h){if(!h||typeof h!="object")return null;const s=h.value;if(s&&typeof s=="object"&&!Array.isArray(s)&&"relative"in s)return{token:String(s.relative),n:typeof s.n=="number"?s.n:void 0};if(h.op==="relative"&&typeof h.value=="string")return{token:h.value,n:void 0};const g=h.meta;return g&&typeof g.relative=="string"&&h.value===void 0?{token:g.relative,n:typeof g.n=="number"?g.n:void 0}:null}function C(){return`Known tokens: ${b.filter(s=>s!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function F(h){const s=v(h);return s?f(s.token,s.n)!==null:!1}function _(h,s={}){const g=v(h);if(!g)return h;const c=l(g.token,{...s,n:g.n});return c?{...h,type:h.type||"date",op:"between",value:[c.from,c.to],bounds:h.bounds||c.bounds,meta:{...h.meta||{},relative:c.relative,tz:c.tz}}:(Q(`source.relative.${g.token}`,`unknown relative date token "${g.token}"; sending the condition unresolved.`,C()),h)}function J(h){return!!h&&typeof h=="object"&&Array.isArray(h.conditions)}function re(h,s){if(h){if(J(h)){for(const g of h.conditions)re(g,s);return}s(h)}}function q(h,s){if(!h)return null;if(!J(h))return s(h);const g=h;let c=!1;const d=[];for(const N of g.conditions){const S=q(N,s);S!==N&&(c=!0),S&&d.push(S)}return!c&&d.length===g.conditions.length?h:d.length?{...g,conditions:d}:null}function U(h){if(!h)return null;if(!J(h))return h;const s=h,g=[];for(const c of s.conditions){const d=U(c);d&&g.push(d)}return g.length?{op:s.op,conditions:g}:null}function ge(h){const s=U(h);return s?J(s)&&s.op==="and"?s:{op:"and",conditions:[s]}:null}function A(h){const s=(h||[]).filter(Boolean);return s.length?{op:"and",conditions:s}:null}function X(h,s={}){const g=q(h,c=>_(c,s));return ge(g)}function ce(h){const s=E(h.filters??null);return JSON.stringify([s,h.sort??null,h.quick??"",h.groupBy??null,h.pivotBy??null,W(h.context)])}function E(h){if(!h)return null;if(J(h)){const c=h;return{op:c.op,conditions:c.conditions.map(E)}}const s=h,g=s.meta&&typeof s.meta.relative=="string"?s.meta.relative:v(s)?.token;return{col:s.col,op:s.op,bounds:s.bounds??null,caseSensitive:s.caseSensitive??!1,value:g?`rel:${g}`:s.value??null}}function W(h){if(h==null)return null;try{return JSON.parse(JSON.stringify(h))}catch{return Q("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Je("packages/core/src/source/aggregates.js",function(o,Y){"use strict";Object.defineProperty(o,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"pushableAggregates",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"fillAggregateSql",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"resolveAggregatesConfig",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"routeAggregate",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"resolveAggregatePlan",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"groupKeysPushable",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"pushdownDocRows",{enumerable:!0,get:function(){return ue}});const ke=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 Q(){const P=new Set;for(const[y,B]of Object.entries(ke))B.pushable&&P.add(y);return P}function $(P,y,B){let D=P.split("%c").join(y);return B!==void 0&&(D=D.split("%w").join(B)),D}function pe(P){const y=P||{},B=y.default==="engine"||y.default==="engine-if-identical"?y.default:"client",D={};if(y.overrides&&typeof y.overrides=="object")for(const[I,G]of Object.entries(y.overrides))(G==="engine"||G==="client")&&(D[I]=G);return{default:B,overrides:D}}function me(P,y){const B=ke[P];if(!B||!B.pushable)return"client";const D=y.overrides[P];return D==="engine"||D==="client"?D:y.default==="client"?"client":y.default==="engine-if-identical"?B.class==="identical"?"engine":"client":"engine"}function te(P,y){const B=pe(y),D=[],I=[];for(const G of P||[]){const z=ke[G.fn],x=me(G.fn,B),b={id:G.id,col:G.col,fn:G.fn,class:z?z.class:"fallback"};G.weight!==void 0&&(b.weight=G.weight),G.params!==void 0&&(b.params=G.params),x==="engine"?D.push(b):(b.reason=z&&!z.pushable?z.note||"the engine cannot express this stat":"client by config",I.push(b))}return{engine:D,client:I,config:B}}const Z=/^[A-Za-z_][A-Za-z0-9_$]*$/;function H(P,y=[]){return(P||[]).every(D=>{if(typeof D=="string")return Z.test(D);if(!D||typeof D!="object")return!1;const I=D;return Array.isArray(y)&&y.includes(I.bucket)&&typeof I.col=="string"&&Z.test(I.col)&&typeof I.size=="number"&&Number.isFinite(I.size)&&I.size>0})}function ue(){return Object.entries(ke).map(([P,y])=>({stat:P,class:y.class,sql:y.sql?$(y.sql,"col",y.twoColumn?"weight":void 0):"",note:y.note||(y.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Je("packages/core/src/source/abort.js",function(o,Y){"use strict";Object.defineProperty(o,"SupersededError",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"RequestToken",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"AbortScope",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"createAbortScope",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"isAbortError",{enumerable:!0,get:function(){return me}});class ke extends Error{constructor(Z,H="superseded"){super(`[lattice] request ${Z?`"${Z}" `:""}${H}`),this.name="SupersededError",this.superseded=!0,this.key=Z}}class Q{#r;constructor(Z,H,ue,P){this.#r=Z,this.key=H,this.controller=ue,this.signal=ue.signal,this.seq=P}get current(){return!this.signal.aborted&&this.#r.tokenFor(this.key)===this}settle(){this.#r.settle(this)}abort(Z){this.signal.aborted||this.controller.abort(new ke(this.key,Z)),this.#r.settle(this)}}class ${#r=new Map;#n=0;begin(Z="",H="superseded"){const ue=this.#r.get(Z);ue&&!ue.signal.aborted&&ue.controller.abort(new ke(Z,H));const P=new Q(this,Z,new AbortController,++this.#n);return this.#r.set(Z,P),P}tokenFor(Z){return this.#r.get(Z)}pending(Z=""){const H=this.#r.get(Z);return!!H&&!H.signal.aborted}get size(){return this.#r.size}settle(Z){this.#r.get(Z.key)===Z&&this.#r.delete(Z.key)}abort(Z="",H="superseded"){const ue=this.#r.get(Z);ue&&ue.abort(H)}abortAll(Z="superseded"){for(const H of[...this.#r.values()])H.abort(Z);this.#r.clear()}}function pe(){return new $}function me(te){if(!te||typeof te!="object")return!1;const Z=te;return Z.superseded===!0||Z.name==="AbortError"||Z.name==="SupersededError"}}),Je("packages/core/src/source/pushdown.js",function(o,Y){"use strict";Object.defineProperty(o,"NO_CAPABILITIES",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"resolveMutate",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"capabilitiesOf",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"splitFilters",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"planQuery",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"applyResidual",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"createPushdownSource",{enumerable:!0,get:function(){return W}});const ke=Y("packages/core/src/internal/util.js"),Q=ke.isFunction,$=ke.warnOnce,pe=Y("packages/core/src/source/filterwire.js"),me=pe.isGroup,te=pe.warnWherePageRelative,Z=pe.warnWhereOverThreshold,H=Y("packages/core/src/source/aggregates.js"),ue=H.resolveAggregatePlan,P=H.groupKeysPushable,y=H.STAT_PUSHDOWN,D=Y("packages/core/src/source/abort.js").SupersededError;function I(h){const s=h&&h.signal;if(!s||!s.aborted)return;const g=s.reason;throw g instanceof Error?g:new D("","superseded before it was sent")}const G=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,mutate:!1});function z(h){if(!h||typeof h!="object")return!1;const s=h.returning==="row"||h.returning==="key"?h.returning:"none";return{append:h.append===!0,update:h.update===!0,delete:h.delete===!0,returning:s}}function x(h,s){if(!h||typeof s!="string")return;if(!s.includes("."))return h[s];let g=h;for(const c of s.split(".")){if(g===null||typeof g!="object")return;g=g[c]}return g}function b(h){if(h===!0)return!0;if(!h||typeof h!="object")return!1;const s=h;return s.enabled===!1?!1:s.enabled===!0||Q(s.commit)}function f(h){const s={...G,...h||{}};return s.operators=new Set(s.operators||[]),s.mutate=z(s.mutate),s}function l(h,s){return!h||!h.op||!s.operators.size?!1:s.operators.has(h.op)}function v(h,s){if(!h)return{pushed:null,residual:null};if(!s.filter)return{pushed:null,residual:h};if(s.filter==="term"){if(me(h)){const N=h.conditions||[];if(String(h.op)!=="and")return{pushed:null,residual:h};const S=N.findIndex(m=>!me(m)&&l(m,s));if(S<0)return{pushed:null,residual:h};const w=N.filter((m,u)=>u!==S);return{pushed:N[S],residual:w.length?{op:"and",conditions:w}:null}}return l(h,s)?{pushed:h,residual:null}:{pushed:null,residual:h}}if(!me(h))return l(h,s)?{pushed:h,residual:null}:{pushed:null,residual:h};if(String(h.op)!=="and")return(h.conditions||[]).every(S=>me(S)?v(S,s).residual===null:l(S,s))?{pushed:h,residual:null}:{pushed:null,residual:h};const g=[],c=[];for(const N of h.conditions||[]){if(me(N)){if(s.filter==="flat"){c.push(N);continue}const S=v(N,s);S.pushed&&g.push(S.pushed),S.residual&&c.push(S.residual);continue}(l(N,s)?g:c).push(N)}const d=N=>N.length===0?null:N.length===1?N[0]:{op:"and",conditions:N};return{pushed:d(g),residual:d(c)}}function C(h,s,g,c,d,N,S){const w=Array.isArray(h.groupBy)?h.groupBy:[],m=Array.isArray(h.groupPath)?h.groupPath:[],u=Array.isArray(h.groupValues)?h.groupValues:null;return s.group?P(w)?g.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":c?d?N?"a host `where` predicate can only run in the browser, over rows the engine grouped":S?"fullDataset holds the whole matching set, so the grid groups it itself":!u||u.length!==m.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":"the adapter does not declare the `group` capability"}function F(h,s,g=!1){const c=v(h.filters||null,s),d=[];c.residual&&d.push("filter");const N=h.sort||[],S=N.length===0||s.sort==="multi"&&N.length>=1||s.sort==="single"&&N.length===1;!S&&N.length&&d.push("sort");const w=h.quick?String(h.quick):"",m=!w||!!s.quick;m||d.push("quick");const u=h.where&&h.where.active?h.where:null;u&&d.push("where");const k={filters:c.residual,sort:S?null:N,quick:m?"":w,where:u},R=!!g,p=Array.isArray(h.groupBy)&&h.groupBy.length>0,e=p?C(h,s,c,S,m,u,R):"",i=p&&e==="";p&&!i&&d.push("group");const n=i&&Array.isArray(h.groupValues)?h.groupValues.length:0,t=i?!1:R||!!(k.filters||k.sort||k.quick||k.where)||!s.range;return{pushed:{...h,filters:c.pushed,sort:S?N:[],quick:m?w:"",range:t?null:h.range},residual:k,needsAll:t,unpushed:d,full:R,grouped:i,groupLevel:n,groupReason:e}}function _(h){const s=Array.isArray(h.totals)?h.totals:[],g=h.totalFns&&typeof h.totalFns=="object"?h.totalFns:{},c=[],d=[];for(const N of s){const S=String(N),w=typeof g[S]=="string"?g[S]:null,m=w?y[w]:null;w?!m||!m.pushable||!m.sql?d.push({id:S,fn:w,class:m?m.class:"fallback",reason:m&&m.note?m.note:`the pushdown map cannot express "${w}"`}):m.twoColumn?d.push({id:S,fn:w,class:m.class,reason:`"${w}" reduces two columns, and a grouped request carries no weight column`}):c.push({id:S,col:S,fn:w,class:m.class}):d.push({id:S,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:c,client:d}}const J=Object.freeze({items:h=>h==null?[]:Array.isArray(h)?h:[h]});function re(h,s,g){if(!s)return h;let c=h;if(s.filters&&Q(g.evaluateFilters)){const d=c,N={count:c.length,handle:m=>({id:m,get:u=>x(d[u],m)}),itemwise:m=>d.some(u=>Array.isArray(x(u,m)))?J:null},S=g.evaluateFilters(s.filters,N),w=[];for(let m=0;m<c.length;m++)S[m]&&w.push(c[m]);c=w}if(s.where&&s.where.active&&(s.whole||te(s.where.names,"pushdown"),c=c.filter(d=>s.where.passes(d))),s.quick){const d=s.quick.toLowerCase();c=c.filter(N=>{if(!N||typeof N!="object")return!1;for(const S of Object.values(N))if(S!=null&&String(S).toLowerCase().includes(d))return!0;return!1})}if(s.sort&&s.sort.length&&Q(g.sortMulti)){const d=[...new Set(s.sort.map(m=>m.col))],N=c,S=d.map(m=>({id:m,get:u=>x(N[u],m)})),w=g.sortMulti(S,s.sort.map(m=>({col:m.col,dir:m.dir})),Uint32Array.from({length:c.length},(m,u)=>u),{});c=Array.from(w,m=>N[m])}return c}function q(h){return JSON.stringify({filters:h.filters||null,sort:h.sort||[],quick:h.quick||"",groupBy:h.groupBy||[],groupPath:h.groupPath||[],context:h.context??null})}function U(h){if(!h||typeof h!="object")return 16;let s="";try{s=JSON.stringify(h)}catch{return 200}return s.length*2+64}function ge(h){const s=h||{};return{enabled:!!s.enabled,maxRows:Number.isFinite(s.maxRows)?s.maxRows:1e6,maxBytesEstimate:Number.isFinite(s.maxBytesEstimate)?s.maxBytesEstimate:512*1024*1024}}const A=5e4;function X(h){return Number.isFinite(h)&&h>=0?h:A}function ce(h){return!!h&&Q(h.then)}async function E(h){if(!h||h.total!==void 0||!ce(h.pendingTotal))return h;const s=await h.pendingTotal,{pendingTotal:g,...c}=h;return typeof s=="number"?{...c,total:s}:c}function W(h={}){const s=h.adapter;if(!s||!Q(s.execute))return $("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...h,mode:"remote",fetch:async()=>({rows:[],total:0})};const g=f(s.capabilities),c=s.capabilities&&Object.getOwnPropertyDescriptor(s.capabilities,"operators");c&&Q(c.get)&&Object.defineProperty(g,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(s.capabilities.operators||[]),set:()=>{}});const d=s.name||"adapter";let N=null;const S=()=>Q(s.ready)?(N||(N=Promise.resolve(s.ready()).then(()=>{Object.assign(g,f(s.capabilities))},se=>{throw N=null,se})),N):null,w=ge(h.fullDataset),m=!!h.allowPartialResults,u=X(h.whereRowLimit);let k=null;const R=h.aggregates;let p=null,e=null,i=null,n=null,t=null,r,a=null,T=0,M=null;const L=()=>!w.enabled||!p?null:(M!==p.key&&(T++,M=p.key),{rows:p.rows,version:T}),ee=async se=>{const ae=se.where&&se.where.active?se.where:null;if(!ae)return{request:se,probe:null};const{where:be,...le}=se,ye=F(le,g,w.enabled);if(ye.needsAll)return{request:se,probe:null};const Ne=q(ye.pushed);let Ee=null;return(!k||k.key!==Ne)&&(g.total?(I(se),Ee=await E(await s.execute(ye.pushed,se)),k={key:Ne,size:Ee&&typeof Ee.total=="number"?Ee.total:null}):k={key:Ne,size:null}),k.size!==null&&k.size<u?{request:se,probe:null}:(Z(ae.names,d,k.size,u),{request:le,probe:Ee})},fe=async(se,ae)=>{a=null;const be=_(se.pushed);i={engine:be.engine,client:be.client,groupBy:se.pushed.groupBy},be.client.length&&$(`source.pushdown.group.totals.${d}.${be.client.map(Ne=>Ne.id).join(".")}`,`the ${d} adapter cannot compute the group subtotal for ${be.client.map(Ne=>`"${Ne.id}" (${Ne.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 le=await s.executeGroupLevel(se.pushed,be.engine,ae)||{};let ye=le.rows||[];return!g.range&&ae.range&&(ye=ye.slice(ae.range.start,ae.range.end)),typeof le.matchCount=="number"&&(n=le.matchCount,t=le.grand?{totals:le.grand,leafCount:le.matchCount}:null,r===void 0&&Q(s.unfilteredCount)&&(r=null,Promise.resolve(s.unfilteredCount()).then(Ne=>{r=typeof Ne=="number"?Ne:null}).catch(Ne=>{$(`source.pushdown.group.unfiltered.${d}`,`the ${d} adapter could not count the unfiltered set (${Ne&&Ne.message?Ne.message:Ne}), so "N of M" falls back to the display count for its denominator.`)}))),le.total===void 0?{rows:ye}:{rows:ye,total:le.total}},de=(se,ae)=>{const be={key:ae,state:"pending",value:null};return a=be,se.then(le=>(a===be&&(a={key:ae,state:"settled",value:typeof le=="number"?le:null}),le),le=>{throw a===be&&(a={key:ae,state:"failed",value:null}),le})},Me=async se=>{const ae=S();ae&&await ae;const be=await ee(se);I(se);let le=F(be.request,g,w.enabled);if(le.grouped&&!Q(s.executeGroupLevel)&&($(`source.pushdown.group.method.${d}`,`the ${d} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid is left to group whatever rows it holds. Implement the method or drop the capability.`),le=F(be.request,{...g,group:!1},w.enabled)),e=le,le.grouped)return fe(le,se);if(le.groupReason&&$(`source.pushdown.group.${d}.${le.groupReason}`,`the ${d} adapter was not asked to group this query because ${le.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.`),!le.needsAll){const ze=be.probe||await s.execute(le.pushed,se),Ze=ze.rows||[];return ce(ze.pendingTotal)&&ze.total===void 0?{rows:Ze,pendingTotal:de(ze.pendingTotal,q(le.pushed))}:(a=null,!g.total&&ze.total===void 0?{rows:Ze}:{rows:Ze,total:ze.total??Ze.length})}le.unpushed.length&&$(`source.pushdown.residual.${d}.${le.unpushed.join(".")}`,`the ${d} adapter cannot push ${le.unpushed.join(" or ")}, so every matching row is fetched and the rest is applied in the browser. Correct, and slower than it needs to be: widening the adapter is the fix.`);const ye=q(le.pushed);if(!p||p.key!==ye){const ze=await E(await s.execute(le.pushed,se));a=null;const Ze=ze.rows||[];if(le.full){const Ye=typeof ze.total=="number"?Math.max(ze.total,Ze.length):Ze.length;if(Ye>w.maxRows)throw new Error(`[lattice] fullDataset refused: the ${d} adapter's matching set is ${Ye.toLocaleString()} rows, past the configured maxRows of ${w.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 nt=Ze.length*U(Ze[0]);if(nt>w.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${d} adapter's matching set is an estimated ${Math.round(nt/(1024*1024)).toLocaleString()} MB across ${Ze.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(w.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 ze.total=="number"&&Ze.length<ze.total){const Ye=!!(le.residual.filters||le.residual.quick||le.residual.sort&&le.residual.sort.length);if(Ye&&!m)throw new Error(`[lattice] the ${d} adapter returned ${Ze.length} of ${ze.total} matching rows when asked for the whole result, and the query has residual ${le.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.`);Ye?$(`source.pushdown.partial.residual.${d}`,`the ${d} adapter returned ${Ze.length} of ${ze.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.`):$(`source.pushdown.partial.${d}`,`the ${d} adapter returned ${Ze.length} of ${ze.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}p={key:ye,rows:Ze,total:typeof ze.total=="number"?ze.total:null}}let Ne=le;if(le.residual.where){const ze=p.total??p.rows.length;if(ze>=u){Z(le.residual.where.names,d,ze,u);const{where:Ze,...Ye}=be.request;Ne=F(Ye,g,w.enabled),e=Ne}}const Ee=p.total!==null&&p.rows.length>=p.total,Re=re(p.rows,{...Ne.residual,whole:Ee},h.compute||{}),Te=se.range?se.range.start:0,Fe=se.range?se.range.end:Re.length;return{rows:Re.slice(Te,Fe),total:Re.length}},ie=async(se,ae)=>{const be=S();be&&await be;const le=F(se,g,w.enabled);e=le;const ye=ue(ae,R),Ne=Array.isArray(se.groupBy)?se.groupBy:[],Ee=Ne.length>0,Re=!le.residual.filters&&!le.residual.quick,Te=!Ee||P(Ne,g.buckets);let Fe=ye.engine,ze=ye.client;const Ze=Ot=>{ze=[...Fe.map(jt=>({...jt,reason:Ot})),...ze],Fe=[]};Fe.length&&!Re?Ze(le.residual.quick&&!le.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Fe.length&&!Te&&Ze("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Ye={},nt;return Fe.length&&(Q(Ee?s.executeGroupedAggregates:s.executeAggregates)?Ee?nt=await s.executeGroupedAggregates(le.pushed,Ne,Fe)||[]:Ye=await s.executeAggregates(le.pushed,Fe)||{}:($(`source.pushdown.aggregates.${d}${Ee?".grouped":""}`,`the ${d} adapter cannot compute ${Ee?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Ze(`adapter cannot compute ${Ee?"grouped ":""}aggregates`))),i={engine:Fe,client:ze,...Ee?{groupBy:Ne}:{}},{values:Ye,engine:Fe,client:ze,...nt!==void 0?{groups:nt}:{}}},ve=b(h.edit),we=h.edit&&typeof h.edit=="object"&&Q(h.edit.commit);let Ae=h.edit;if(ve&&!we)if(g.mutate&&g.mutate.update){const se=ae=>{if(!g.mutate||!g.mutate.update)throw new Error(`[lattice] the ${d} 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 be={kind:"update",key:String(ae.key),patch:{[ae.colId]:ae.value}};return s.mutate(be,ae.request||{})};Ae={...h.edit===!0?{}:h.edit,commit:se}}else $(`source.pushdown.readonly.${d}`,`edit is enabled but the ${d} adapter declares mutate: ${g.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 ne=ve&&g.mutate&&(g.mutate.append||g.mutate.delete)?{append:g.mutate.append===!0,remove:g.mutate.delete===!0,returning:g.mutate.returning,mutate:(se,ae)=>s.mutate(se,ae||{})}:null;return{...h,edit:Ae,rowMutate:ne,mode:"remote",fetch:Me,aggregate:ie,lastPlan:()=>e?{...e,...i?{aggregates:i}:{},...a?{total:{deferred:!0,state:a.state,value:a.value}}:{}}:null,fullFrame:L,counts:()=>({match:n,total:r??null,pending:!!a&&a.state==="pending"}),grandTotals:()=>t}}}),Je("packages/modules/shared/engine.js",function(o,Y){"use strict";Object.defineProperty(o,"sourceId",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"engineSource",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"loadedAndMatching",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"gridHoldsWindow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"gridEngineRequest",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"EngineFlight",{enumerable:!0,get:function(){return I}});const ke=Y("packages/core/src/source/pushdown.js"),Q=ke.capabilitiesOf,$=ke.planQuery,me=Y("packages/core/src/source/filterwire.js").wireFilters,te=new WeakMap;let Z=0;function H(G){let z=te.get(G);return z===void 0&&(z=++Z,te.set(G,z)),z}function ue(G){const z=G&&typeof G.config=="function"?G.config():null,x=z&&z.source&&typeof z.source=="object"?z.source:null;if(!x||typeof x.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const b=Q(x.adapter&&x.adapter.capabilities);return{source:x,caps:b,config:z}}function P(G){let z=0;G.rows.forEach(b=>{b&&!b.group&&b.data!==null&&b.data!==void 0&&z++});const x=typeof G.rows.matchCount=="function"?G.rows.matchCount():NaN;return{loaded:z,total:Number.isFinite(x)?x:NaN}}function y(G){const z=G&&typeof G.config=="function"?G.config():null,x=z&&z.source&&typeof z.source=="object"?z.source:null;if(!x||x.mode!=="remote"&&x.mode!=="paged")return!1;const{loaded:b,total:f}=P(G);return Number.isFinite(f)&&b<f}function B(G,z){return z?G?{op:"and",conditions:[G,z]}:z:G||null}function D(G,z,x=null){const b=G.filters&&typeof G.filters.where=="function"?G.filters.where():[];if(Array.isArray(b)&&b.length)return{reason:`a \`where\` predicate is in force (${b.join(", ")}), which only the browser can run`};const f=G.filters&&typeof G.filters.quickState=="function"?G.filters.quickState():{text:""},l=f&&f.text?String(f.text):"",{config:v,caps:C}=z,F={filters:me(B(G.filters.get(),x),{tz:v.timeZone,weekStartsOn:v.weekStartsOn}),sort:[],range:null,context:v.context??null,...l?{quick:l}:{}},_=$(F,C);return _.unpushed.includes("filter")?{reason:x?"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"}:_.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:F,quick:l}}class I{#r=null;#n=null;#l=!1;answer(z){return this.#n&&this.#n.key===z?this.#n:null}last(){return this.#n}get busy(){return this.#r!==null}ask(z,x,b){const f=this.#r;if(f){f.key!==z&&f.controller&&f.controller.abort();return}const l=globalThis.AbortController,v=typeof l=="function"?new l:null,C={key:z,controller:v};this.#r=C;let F;Promise.resolve().then(()=>x(v?v.signal:null)).then(_=>{F={key:z,result:_}},_=>{F={key:z,error:_}}).then(()=>{this.#r===C&&(this.#r=null),!this.#l&&(v&&v.signal.aborted||(this.#n=F),b())})}abort(){const z=this.#r;z&&z.controller&&z.controller.abort()}close(){this.#l=!0,this.abort()}}}),Je("packages/modules/charts/engine.js",function(o,Y){"use strict";Object.defineProperty(o,"AGGREGATE_MODES",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"ENGINE_TYPES",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"aggregateMode",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"planAggregate",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"holdsWindow",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"boundFromGroups",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"measureProvenance",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"specMeasures",{enumerable:!0,get:function(){return s}});const ke=Y("packages/modules/charts/scale.js"),Q=ke.key,$=ke.toNumber,pe=Y("packages/modules/charts/bind.js"),me=pe.forcedScaleKind,te=pe.measureOf,Z=pe.scaleKindFor,H=Y("packages/core/src/source/aggregates.js"),ue=H.resolveAggregatePlan,P=H.STAT_PUSHDOWN,B=Y("packages/core/src/internal/util.js").warnOnce,D=Y("packages/modules/shared/engine.js"),I=D.engineSource,G=D.gridEngineRequest,z=D.gridHoldsWindow,x=D.loadedAndMatching,b=D.sourceId,f=Object.freeze(["auto","engine","client"]),l=Object.freeze(new Set(["line","step","area","bar","horizontalBar","waterfall","combo","pareto","heatmap","radar","funnel","stream","marimekko"])),v=Object.freeze(new Set(["combo","bar","line","step","area"])),C=Object.freeze({mean:"avg"}),F="__rows",_="m",J="__size",re=/^[A-Za-z_][A-Za-z0-9_$]*$/;function q(g){const c=g?g.aggregate:void 0;return c==null?"auto":typeof c=="string"&&f.includes(c)?c:(B(`chart:aggregate:mode:${String(c)}`,`chart aggregate ${JSON.stringify(c)} is not a mode; use one of ${f.join(", ")}. The chart used 'auto'.`),"auto")}function U(g,c,d){const N=g.columns.get(c);if(!N)return`the ${d} column "${c}" is not a column of the grid`;const S=N.value&&typeof N.value=="object"?N.value:null;return N.computed||S&&(typeof S.get=="function"||typeof S.compute=="function")?`the ${d} column "${c}" is computed by the grid, which the engine cannot reproduce`:(typeof N.field=="string"?N.field:c)!==c||!re.test(c)?`the ${d} column "${c}" is not a plain physical column the engine can name`:d!=="measure"&&N.type==="geometry"?`the ${d} column "${c}" is a geometry, which charts group in the browser for now`:""}function ge(g,c,d){const N=v.has(d)&&Array.isArray(c.measures)&&c.measures.length>0;return(N?c.measures:[c.y]).map((w,m)=>{const u=te(w),k=u.col?g.columns.get(u.col):void 0,R=te(w,k),p=w&&typeof w=="object"?w:{};return{id:`${_}${m}`,col:R.col,fn:R.fn,stat:C[R.fn]||R.fn,label:N?p.title||p.label||k&&k.title||R.col||"":k&&k.title||R.col||"",mark:N&&p.type||null,axis:N&&p.axis==="right"?"right":"left",multi:N}})}function A(g,c,d){const N=q(c),S=(L,ee=!1)=>({mode:"client",asked:N,reason:L,refused:N==="engine",windowed:ee});if(N==="client")return{...S("aggregate: 'client' was asked for"),refused:!1};if(!l.has(d))return S(`a "${d}" chart does not draw a grouped aggregate`);if(Array.isArray(c.points))return S("the chart draws an explicit point set");if(c.rows)return S("the chart was handed its own rows");if(c.from==="groups"||c.from==="selection")return S(`the chart reads the grid's ${c.from==="groups"?"group rows":"selection"}`);if(c.error)return S("error bars need the readings behind each mark");const w=I(g);if("reason"in w)return S(w.reason);const{source:m,caps:u}=w;if(!u.group)return S("the source's adapter does not declare the `group` capability");const k=typeof c.x=="string"&&c.x?c.x:null;if(!k)return S("the chart names no x column to group by");const R=typeof c.series=="string"&&c.series?c.series:typeof c.multiples=="string"?c.multiples:null,p=ge(g,c,d),e=p.length>0&&p[0].multi,i=R&&!e?[k,R]:[k];for(const[L,ee]of i.entries()){const fe=U(g,ee,L===0?"x":"series");if(fe)return S(fe)}for(const L of p){if(!L.col)return S("a measure names no column to reduce");const ee=U(g,L.col,"measure");if(ee)return S(ee);const fe=P[L.stat];if(!fe||!fe.pushable)return S(`"${L.fn}" of "${L.col}" is not a reduction the engine can compute`)}if(c.size){const L=typeof c.size=="string"?U(g,c.size,"measure"):"the size channel is not a column";if(L)return S(L)}const n=[...p.map(L=>({id:L.id,col:L.col,fn:L.stat})),{id:F,col:k,fn:"count"},...c.size?[{id:J,col:c.size,fn:"sum"}]:[]],t=ue(n,m.aggregates);if(t.client.length){const L=t.client[0];return S(`the source computes "${L.fn}" client-side (${L.reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to compute it in the engine`)}const r=G(g,w);if("reason"in r)return S(r.reason);const{quick:a}=r,T={...r.request,groupBy:i};if(N==="auto"){const{loaded:L,total:ee}=x(g);if(Number.isFinite(ee)&&L>=ee)return S("the grid holds every matching row")}const M=JSON.stringify([b(m),T.filters,a,i,n]);return{mode:"engine",asked:N,key:M,source:m,request:T,requested:n,groupBy:i,measures:p}}function X(g){return z(g)}function ce(g,c){if(c==null)return"";if(g&&typeof g.formatValue=="function")try{const d=g.formatValue(c,null);if(typeof d=="string"&&d)return d}catch{}return c instanceof Date?c.toISOString().slice(0,10):String(c)}function E(g,c){if(g==null)return c==null?0:1;if(c==null)return-1;const d=g instanceof Date?g.getTime():$(g),N=c instanceof Date?c.getTime():$(c);return typeof g!="string"&&typeof c!="string"&&d!==null&&N!==null?d-N:String(g).localeCompare(String(c))}function W(g,c,d,N){const{groupBy:S,measures:w}=d,m=S[0],u=S[1]||null,k=w[0].multi,R=g.columns.get(m),p=u?g.columns.get(u):void 0,e=(N||[]).filter(ve=>ve&&ve.level===S.length),i=new Map,n=new Map,t=new Map;for(const ve of e){const we=ve.keys[0],Ae=Q(we);i.has(Ae)||i.set(Ae,we);const ne=u?ve.keys[1]:null,se=u?Q(ne):"";n.has(se)||n.set(se,ne),t.set(`${se}\0${Ae}`,ve.values||{})}const r=g.sort&&typeof g.sort.get=="function"?g.sort.get():[],a=Array.isArray(r)&&r[0]&&r[0].col===m&&r[0].dir==="desc",T=[...i.entries()].sort((ve,we)=>E(ve[1],we[1]));a&&T.reverse();const M=typeof c.limit=="number"&&c.limit>0?T.slice(0,c.limit):T,L=M.map(([,ve])=>ce(R,ve)),ee=M.map(([,ve])=>ve),fe=(ve,we,Ae,ne,se)=>{const ae=t.get(`${ve}\0${we}`),be=ae?$(ae[F]):null;return{x:Ae,xKey:we,label:ne,y:ae?$(ae[se]):null,size:ae&&c.size?$(ae[J]):null,rows:be===null?0:be,rowKey:null,values:null}};let de;k?de=w.map((ve,we)=>({key:ve.col,label:ve.label,index:we,mark:ve.mark,axis:ve.axis,points:M.map(([Ae,ne],se)=>fe("",Ae,ne,L[se],ve.id))})):de=[...n.entries()].sort((we,Ae)=>E(we[1],Ae[1])).map(([we,Ae],ne)=>({key:we,label:u?ce(p,Ae):w[0].label,index:ne,points:M.map(([se,ae],be)=>fe(we,se,ae,L[be],w[0].id))}));const Me=e.reduce((ve,we)=>ve+($(we.values&&we.values[F])||0),0),ie=Z(R,ee,{forced:me(c),id:m});return{series:de,categories:ee,labels:L,kind:ie,measure:k?{col:null,fn:"sum",title:de.map(ve=>ve.label).join(", ")}:{col:w[0].col,fn:w[0].fn,title:w[0].label},dimension:{col:m,title:R&&R.title||m},empty:de.length===0||M.length===0,rows:Me,truncated:T.length-M.length,bucketed:null}}function h(g,c,d=[],N=""){return g.map(S=>{const w=d.find(m=>m.id===S.id);return{col:S.col||null,fn:S.fn,computed:c,...w&&w.class?{class:w.class}:{},...c==="client"&&N?{reason:N}:{}}})}function s(g,c,d){try{return ge(g,c,d).filter(N=>N.col)}catch{return[]}}}),Je("packages/core/src/format/date.js",function(o,Y){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return x}});const ke=Y("packages/core/src/internal/util.js"),Q=ke.isNil,$=ke.warnOnce,pe=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function me(b){const f=[];let l=0,v="";const C=()=>{v&&(f.push({token:null,text:v}),v="")};for(;l<b.length;){const F=b[l];if(F==="'"){if(b[l+1]==="'"){v+="'",l+=2;continue}const J=b.indexOf("'",l+1);if(J===-1){v+=b.slice(l+1),l=b.length;continue}v+=b.slice(l+1,J),l=J+1;continue}const _=pe.find(J=>b.startsWith(J,l));if(_){C(),f.push({token:_,text:_}),l+=_.length;continue}/[A-Za-z]/.test(F)&&$(`date.pattern.token:${F}`,`the date pattern "${b}" contains '${F}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${pe.join(" ")}.`),v+=F,l+=1}return C(),f}const te=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function Z(b){if(Q(b)||b==="")return null;if(b instanceof Date)return Number.isNaN(b.getTime())?null:b;if(typeof b=="number")return Number.isNaN(b)?null:new Date(b);if(typeof b=="string"){const f=te.exec(b.trim());if(f){const[,v,C,F,_="0",J="0",re="0"]=f;return new Date(+v,+C-1,+F,+_,+J,+re)}const l=new Date(b);return Number.isNaN(l.getTime())?null:l}return null}function H(b,f){return String(b).padStart(f,"0")}function ue(b){if(!b)return v=>({year:v.getFullYear(),month:v.getMonth()+1,day:v.getDate(),hour:v.getHours(),minute:v.getMinutes(),second:v.getSeconds(),ms:v.getMilliseconds(),weekday:v.getDay()});const f=new Intl.DateTimeFormat("en-US",{timeZone:b,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),l={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return v=>{const C={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:v.getMilliseconds(),weekday:0};for(const F of f.formatToParts(v))switch(F.type){case"year":C.year=Number(F.value);break;case"month":C.month=Number(F.value);break;case"day":C.day=Number(F.value);break;case"hour":C.hour=Number(F.value)%24;break;case"minute":C.minute=Number(F.value);break;case"second":C.second=Number(F.value);break;case"weekday":C.weekday=l[F.value]??0;break;default:break}return C}}function P(b,f,l){const v=me(b),C=ue(l),F=new Set(v.filter(U=>U.token).map(U=>U.token)),_=F.has("MMM")?new Intl.DateTimeFormat(f,{month:"short",timeZone:l}):null,J=F.has("MMMM")?new Intl.DateTimeFormat(f,{month:"long",timeZone:l}):null,re=F.has("EEE")?new Intl.DateTimeFormat(f,{weekday:"short",timeZone:l}):null,q=F.has("EEEE")?new Intl.DateTimeFormat(f,{weekday:"long",timeZone:l}):null;return U=>{const ge=C(U);let A="";for(const X of v){if(!X.token){A+=X.text;continue}switch(X.token){case"yyyy":A+=H(ge.year,4);break;case"yy":A+=H(ge.year%100,2);break;case"MMMM":A+=J.format(U);break;case"MMM":A+=_.format(U);break;case"MM":A+=H(ge.month,2);break;case"M":A+=String(ge.month);break;case"dd":A+=H(ge.day,2);break;case"d":A+=String(ge.day);break;case"EEEE":A+=q.format(U);break;case"EEE":A+=re.format(U);break;case"HH":A+=H(ge.hour,2);break;case"H":A+=String(ge.hour);break;case"hh":A+=H(ge.hour%12===0?12:ge.hour%12,2);break;case"h":A+=String(ge.hour%12===0?12:ge.hour%12);break;case"mm":A+=H(ge.minute,2);break;case"m":A+=String(ge.minute);break;case"ss":A+=H(ge.second,2);break;case"s":A+=String(ge.second);break;case"SSS":A+=H(ge.ms,3);break;case"a":A+=ge.hour<12?"AM":"PM";break;default:A+=X.text;break}}return A}}const y=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function B(b,f){const l=b||{},v=l.locale||f||void 0,C=l.nullDisplay??"",F=l.timeZone;let _;if(l.pattern)_=P(l.pattern,v,F);else if(l.dateStyle||l.timeStyle){const ge={timeZone:F};l.dateStyle&&(ge.dateStyle=l.dateStyle),l.timeStyle&&(ge.timeStyle=l.timeStyle);const A=new Intl.DateTimeFormat(v,ge);_=X=>A.format(X)}else{const ge=new Intl.DateTimeFormat(v,{dateStyle:"medium",timeZone:F});_=A=>ge.format(A)}const J=l.relative?new Intl.RelativeTimeFormat(v,{numeric:"auto"}):null,q=(typeof l.relative=="object"&&l.relative?l.relative.threshold??7:7)*24*36e5,U=(ge,A)=>{const X=Z(ge);if(!X)return C;if(J){const ce=A&&typeof A.now=="number"?A.now:Date.now(),E=X.getTime()-ce;if(Math.abs(E)<q){for(const[W,h]of y)if(Math.abs(E)>=h||W==="second")return J.format(Math.round(E/h),W)}}return _(X)};return U.spec=l,U}function D(b){if(Q(b)||b==="")return null;if(typeof b=="string"){const v=/^(\d{4}-\d{2}-\d{2})/.exec(b.trim());if(v)return v[1];const C=Z(b);return C?D(C):null}const f=Z(b);if(!f)return null;const l=v=>String(v).padStart(2,"0");return`${f.getFullYear()}-${l(f.getMonth()+1)}-${l(f.getDate())}`}function I(b,f){if(Q(b)||b==="")return null;if(typeof b=="string"){const v=b.trim();if(G.test(v)){const _=Z(v);return _?z(_,f):null}const C=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(v);if(C){const[,_,J,re,q]=C;return`${_}T${J}:${re}${q&&q!=="00"?`:${q}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(v))return`${v}T00:00`;const F=Z(v);return F?I(F):null}const l=Z(b);return l?z(l,f):null}const G=/(?:Z|[+-]\d{2}:?\d{2})$/i;function z(b,f){const l=_=>String(_).padStart(2,"0");if(f)try{const _=new Intl.DateTimeFormat("en-CA",{timeZone:f,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(b).reduce((q,U)=>(U.type!=="literal"&&(q[U.type]=U.value),q),{}),J=_.hour==="24"?"00":_.hour,re=Number(_.second);return`${_.year}-${_.month}-${_.day}T${J}:${_.minute}`+(re?`:${_.second}`:"")}catch{}const v=`${b.getFullYear()}-${l(b.getMonth()+1)}-${l(b.getDate())}`,C=b.getSeconds(),F=`${l(b.getHours())}:${l(b.getMinutes())}${C?`:${l(C)}`:""}`;return`${v}T${F}`}function x(b,f){const l=Q(b)||b===""?null:String(b),v=Q(f)||f===""?null:String(f);return l===null?v===null?0:1:v===null||l<v?-1:l>v?1:0}}),Je("packages/core/src/compute/handle.js",function(o,Y){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return b}});const ke=Y("packages/core/src/internal/util.js"),Q=ke.collator,$=ke.defaultCompare,pe=ke.warnOnce;function me(f){const l=new Uint32Array(f);for(let v=0;v<f;v++)l[v]=v;return l}function te(f,l){if(l&&typeof l.count=="number")return l.count;if(!f)return 0;if(typeof f.count=="number")return f.count;if(typeof f.length=="number")return f.length;const v=f.values;return f.kind==="multi"&&f.offsets?Math.max(0,f.offsets.length-1):v?f.kind==="bitset"?typeof v.size=="number"?v.size:f.presence&&typeof f.presence.size=="number"?f.presence.size:(pe(`count:${f.id}`,`column "${f.id}" is bitset-backed with no declared row count; assuming ${v.length*8}`),v.length*8):v.length:f.presence&&typeof f.presence.size=="number"?f.presence.size:0}const Z=new WeakMap;function H(f){const l=f.constructor;if(!l)return"unknown";const v=Z.get(l);if(v)return v;let C="unknown";try{let F=null;typeof l.from=="function"?F=l.from([!1,!0]):(F=new l(8),F.set(1));const _=F&&F.words;_&&_.length&&(_[0]===2?C="lsb":_[0]===64&&(C="msb"))}catch{C="unknown"}return Z.set(l,C),C}function ue(f){if(!f)return()=>0;const l=f instanceof Uint8Array?f:f.words;if(l instanceof Uint8Array){const v=f instanceof Uint8Array?"lsb":H(f);if(v==="lsb")return C=>l[C>>>3]>>>(C&7)&1;if(v==="msb")return C=>l[C>>>3]>>>7-(C&7)&1}return typeof f.get=="function"?v=>f.get(v)?1:0:()=>0}function P(f){return!f||!f.presence?null:ue(f.presence)}function y(f){return f?typeof f.size=="number"?f.size:typeof f.values=="function"?f.values().length:0:0}function B(f,l){return f?typeof f.valueOf=="function"?f.valueOf(l):typeof f.values=="function"?f.values()[l]:null:null}function D(f,l){const v=f.offsets,C=f.values;if(!v||!C)return[];const F=v[l],_=v[l+1];if(!(_>F))return[];const J=f.dict,re=new Array(_-F);for(let q=F;q<_;q++)re[q-F]=J?B(J,C[q]):C[q];return re}function I(f){if(!f)return()=>{};const l=f.values,v=P(f),C=f.kind;if(C==="dictionary"){const F=f.dict;return v?_=>v(_)?B(F,l[_]):null:_=>B(F,l[_])}if(C==="bitset"){const F=ue(l);return v?_=>v(_)?F(_)===1:null:_=>F(_)===1}if(C==="multi")return v?F=>v(F)?D(f,F):null:F=>D(f,F);if(!l&&typeof f.get=="function"){const F=f.get.bind(f);return _=>{const J=F(_);return J===void 0?null:J}}return v?F=>{if(!v(F))return null;const _=l[F];return _===void 0?null:_}:F=>{const _=l[F];return _===void 0?null:_}}function G(f,l){if(f<l)return-1;if(f>l)return 1;if(f===l){const F=Object.is(f,-0),_=Object.is(l,-0);return F===_?0:F?-1:1}const v=Number.isNaN(f),C=Number.isNaN(l);return v&&C?0:v?1:-1}function z(f){const l=Q(f);return(v,C)=>{if(v===C)return 0;const F=typeof v,_=typeof C;if(F==="string"&&_==="string")return l.compare(v,C);if(F==="number"&&_==="number")return G(v,C);if(F==="boolean"&&_==="boolean")return v===C?0:v?1:-1;if(v instanceof Date||C instanceof Date){const J=v instanceof Date?v.getTime():Number(v),re=C instanceof Date?C.getTime():Number(C);return G(J,re)}return $(v,C)}}function x(f,l){if(f&&typeof f.ranks=="function")return f.ranks(l);const v=f&&typeof f.values=="function"?f.values():[],C=v.length,F=z(l),_=new Array(C);for(let re=0;re<C;re++)_[re]=re;_.sort((re,q)=>F(v[re],v[q])||re-q);const J=new Uint32Array(C);for(let re=0;re<C;re++)J[_[re]]=re;return J}function b(f){return f==null||typeof f=="number"&&Number.isNaN(f)}}),Je("packages/core/src/compute/filter.js",function(o,Y){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return p}});const ke=Y("packages/core/src/internal/util.js"),Q=ke.isBlank,$=ke.toArray,pe=ke.warnOnce,te=Y("packages/core/src/format/date.js").toIsoDate,Z=Y("packages/core/src/compute/handle.js"),H=Z.bitReader,ue=Z.dictSize,P=Z.dictValue,y=Z.presenceReader,B=Z.valueComparator,D=Z.valueReader,I=/^\d{4}-\d{2}-\d{2}$/,G="\0null\0";function z(e,i){const n=e&&e.pool;if(n){const t=n.mask||n.acquireMask||n.acquire||n.take;if(typeof t=="function"){const r=t.call(n,i);if(r&&r.length>=i)return r}}return new Uint8Array(i)}function x(e,i){const n=e&&e.pool;if(!n||!i)return;const t=n.release||n.releaseMask||n.free||n.recycle;typeof t=="function"&&t.call(n,i)}function b(e,i,n){return e.fill(n,0,i),e}function f(e){return e==null||typeof e=="number"&&Number.isNaN(e)}function l(e,i){if(e==null)return e;if(i==="number")return typeof e=="number"?e:Number(e);if(i==="date"||i==="dateString"){const n=te(e);return n===null?v(e):n}return i==="boolean"?typeof e=="boolean"?e:e==="true"||e===1?!0:e==="false"||e===0?!1:!!e:e}function v(e){return e instanceof Date?e.getTime():typeof e=="number"?e:Date.parse(String(e))}function C(e){return typeof e=="number"?e:e instanceof Date?e.getTime():e==null||e===""?NaN:Number(e)}function F(e,i){const n=typeof e=="string"?e:String(e);return i?n:n.toLowerCase()}function _(e,i){return e==null?G:typeof e=="string"?i?e:e.toLowerCase():e instanceof Date?e.getTime():e}function J(e,i,n){const t=new Set;for(const r of $(e)){const a=l(r,n);t.add(_(a,i)),typeof a=="string"&&a!==""&&Number.isFinite(Number(a))?t.add(Number(a)):typeof a=="number"&&Number.isFinite(a)&&t.add(_(String(a),i))}return t}function re(e,i,n){if(e==null||i===null||i===void 0)return e==null&&i==null;const t=typeof e,r=typeof i;return t==="string"&&r==="string"?n?e===i:e.toLowerCase()===i.toLowerCase():e instanceof Date||i instanceof Date?v(e)===v(i):t==="number"&&r==="number"?e===i||Number.isNaN(e)&&Number.isNaN(i):t==="number"&&r==="string"?e===Number(i):t==="string"&&r==="number"?Number(e)===i:t==="boolean"||r==="boolean"?e===i:Array.isArray(e)&&Array.isArray(i)?e.length===i.length&&e.every((a,T)=>re(a,i[T],n)):e===i}function q(e,i){try{if(e instanceof RegExp){const n=e.flags.replace(/[gy]/g,"");return new RegExp(e.source,i||n.includes("i")?n:`${n}i`)}return new RegExp(String(e),i?"":"i")}catch(n){return pe(`regex:${String(e)}`,`filter operator "matches" received an invalid pattern: ${String(e)}`,n),null}}function U(e,i){const n=ge(e,i),t=e&&e.type;return t!=="date"&&t!=="dateString"?n:r=>n(typeof r=="string"&&I.test(r)?r:te(r)??r)}function ge(e,i){const n=e&&e.op,t=!!(e&&e.caseSensitive),r=e&&e.type,a=B(i),T=M=>L=>!M(L);switch(n){case"eq":{const M=l(e.value,r);return L=>re(L,M,t)}case"ne":{const M=l(e.value,r);return L=>!re(L,M,t)}case"lt":case"lte":case"gt":case"gte":{const M=l(e.value,r);if(f(M))return()=>!1;const L=n==="lt"?-1:n==="lte"?0:n==="gt"?1:2;return ee=>{if(f(ee))return!1;const fe=a(ee,M);return L===-1?fe<0:L===0?fe<=0:L===1?fe>0:fe>=0}}case"between":case"notBetween":{const M=$(e.value),L=l(M[0],r),ee=l(M[1],r),fe=e.bounds||"[]",de=fe.charAt(0)!=="(",Me=fe.charAt(1)!==")";if(f(L)||f(ee))return n==="between"?()=>!1:()=>!0;const ie=ve=>{if(f(ve))return!1;const we=a(ve,L),Ae=a(ve,ee);return(de?we>=0:we>0)&&(Me?Ae<=0:Ae<0)};return n==="between"?ie:T(ie)}case"in":case"notIn":{const M=J(e.value,t,r),L=ee=>M.has(_(ee,t));return n==="in"?L:T(L)}case"contains":case"notContains":{const M=F(l(e.value,r),t),L=ee=>ee==null?!1:F(ee,t).includes(M);return n==="contains"?L:T(L)}case"startsWith":{const M=F(l(e.value,r),t);return L=>L==null?!1:F(L,t).startsWith(M)}case"endsWith":{const M=F(l(e.value,r),t);return L=>L==null?!1:F(L,t).endsWith(M)}case"matches":{const M=q(e.value,t);return M?L=>L==null?!1:M.test(String(L)):()=>!1}case"blank":return M=>Q(M)||Array.isArray(M)&&M.length===0;case"notBlank":return M=>!(Q(M)||Array.isArray(M)&&M.length===0);case"containsAny":case"containsNone":{const M=J(e.value,t,r),L=ee=>{const fe=ee==null?[]:$(ee);for(let de=0;de<fe.length;de++)if(M.has(_(fe[de],t)))return!0;return!1};return n==="containsAny"?L:T(L)}case"containsAll":{const M=$(e.value).map(L=>_(l(L,r),t));return L=>{const ee=L==null?[]:$(L);if(M.length===0)return!0;const fe=new Set(ee.map(de=>_(de,t)));for(let de=0;de<M.length;de++)if(!fe.has(M[de]))return!1;return!0}}default:{const M=p(n);return M?M.compile(e.value):(pe(`op:${String(n)}`,`unknown filter operator "${String(n)}"; the condition is refused rather than matching every row`),()=>!1)}}}function A(e,i,n){return U(i,n)(e)}const X=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),ce=new Set(["containsAny","containsAll","containsNone"]);function E(e,i,n){const t=e&&e.op,r=X[t]||t,a=U({...e,op:r,type:i.type},n),T=i.items,M=L=>{const ee=T(L);if(!ee)return!1;for(let fe=0;fe<ee.length;fe++)if(a(ee[fe]))return!0;return!1};return X[t]?L=>!M(L):M}function W(e,i,n,t){const r=y(e);if(r){const M=i?1:0;for(let L=0;L<t;L++)n[L]=r(L)===M?1:0;return n}const a=e.kind;if(a==="float64"||a==="int32"||a==="bitset")return b(n,t,i?1:0);const T=D(e);for(let M=0;M<t;M++){const L=T(M),ee=Q(L)||Array.isArray(L)&&L.length===0;n[M]=ee===i?0:1}return n}function h(e,i,n,t){const r=e.dict,a=ue(r),T=new Uint8Array(a);for(let fe=0;fe<a;fe++)T[fe]=i(P(r,fe))?1:0;const M=e.values,L=y(e);if(!L){for(let fe=0;fe<t;fe++)n[fe]=T[M[fe]];return n}const ee=i(null)?1:0;for(let fe=0;fe<t;fe++)n[fe]=L(fe)===1?T[M[fe]]:ee;return n}function s(e,i,n,t){const r=H(e.values),a=i(!0)?1:0,T=i(!1)?1:0,M=y(e);if(!M){for(let ee=0;ee<t;ee++)n[ee]=r(ee)===1?a:T;return n}const L=i(null)?1:0;for(let ee=0;ee<t;ee++)n[ee]=M(ee)===0?L:r(ee)===1?a:T;return n}function g(e,i,n,t,r){const a=e.values,T=i.type,M=i.op;let L=!0;switch(M){case"eq":case"ne":{const fe=C(l(i.value,T)),de=typeof i.value=="number"&&Number.isNaN(i.value),Me=M==="ne"?1:0;if(de)for(let ie=0;ie<r;ie++)t[ie]=(Number.isNaN(a[ie])?1:0)^Me;else for(let ie=0;ie<r;ie++)t[ie]=(a[ie]===fe?1:0)^Me;break}case"lt":{const fe=C(l(i.value,T));for(let de=0;de<r;de++)t[de]=a[de]<fe?1:0;break}case"lte":{const fe=C(l(i.value,T));for(let de=0;de<r;de++)t[de]=a[de]<=fe?1:0;break}case"gt":{const fe=C(l(i.value,T));for(let de=0;de<r;de++)t[de]=a[de]>fe?1:0;break}case"gte":{const fe=C(l(i.value,T));for(let de=0;de<r;de++)t[de]=a[de]>=fe?1:0;break}case"between":case"notBetween":{const fe=$(i.value),de=C(l(fe[0],T)),Me=C(l(fe[1],T)),ie=i.bounds||"[]",ve=ie.charAt(0)!=="(",we=ie.charAt(1)!==")",Ae=M==="notBetween"?1:0;if(ve&&we)for(let ne=0;ne<r;ne++)t[ne]=(a[ne]>=de&a[ne]<=Me?1:0)^Ae;else if(ve)for(let ne=0;ne<r;ne++)t[ne]=(a[ne]>=de&a[ne]<Me?1:0)^Ae;else if(we)for(let ne=0;ne<r;ne++)t[ne]=(a[ne]>de&a[ne]<=Me?1:0)^Ae;else for(let ne=0;ne<r;ne++)t[ne]=(a[ne]>de&a[ne]<Me?1:0)^Ae;break}case"in":case"notIn":{const fe=new Set;for(const Me of $(i.value)){const ie=C(l(Me,T));Number.isNaN(ie)||fe.add(ie)}const de=M==="notIn"?1:0;for(let Me=0;Me<r;Me++)t[Me]=(fe.has(a[Me])?1:0)^de;break}default:L=!1;break}if(!L)return!1;const ee=y(e);if(ee){const fe=n(null)?1:0;for(let de=0;de<r;de++)ee(de)===0&&(t[de]=fe)}return!0}function c(e,i,n,t){const r=D(e);for(let a=0;a<t;a++)n[a]=i(r(a))?1:0;return n}function d(e,i,n){const t=i.count|0,r=n||z(i,t);if(!e)return b(r,t,1);const a=typeof i.handle=="function"?i.handle(e.col):void 0,T=typeof i.custom=="function"?i.custom:null;if(!a){if(T){for(let fe=0;fe<t;fe++)r[fe]=T(e,fe)?1:0;return r}return pe(`filter:col:${String(e.col)}`,`filter references unknown column "${String(e.col)}"; the condition is refused rather than matching every row`),b(r,t,0)}const M=e.op;if(M==="blank"||M==="notBlank")return W(a,M==="notBlank",r,t);const L=typeof i.itemwise=="function"?i.itemwise(e.col):null;if(L&&!p(M)&&!ce.has(M))return c(a,E(e,L,i.locale),r,t);const ee=U(e,i.locale);switch(a.kind){case"dictionary":return h(a,ee,r,t);case"bitset":return s(a,ee,r,t);case"float64":case"int32":return g(a,e,ee,r,t)?r:c(a,ee,r,t);default:return c(a,ee,r,t)}}function N(e,i,n){if(!e)return b(z(i,n),n,1);if(Array.isArray(e.conditions)){const t=e.conditions.filter(T=>T!=null),r=e.op==="or"?"or":e.op==="not"?"not":"and";if(t.length===0)return b(z(i,n),n,1);const a=N(t[0],i,n);for(let T=1;T<t.length;T++){const M=N(t[T],i,n);if(r==="or")for(let L=0;L<n;L++)a[L]|=M[L];else for(let L=0;L<n;L++)a[L]&=M[L];x(i,M)}if(r==="not")for(let T=0;T<n;T++)a[T]^=1;return a}return d(e,i,z(i,n))}function S(e,i){return N(e,i,i.count|0)}function w(e,i){if(!e||!i)return e||null;const n=e;if(Array.isArray(n.conditions)){if((n.op==="or"?"or":n.op==="not"?"not":"and")!=="and")return m(n,i)?null:e;const r=[];for(const a of n.conditions){const T=w(a,i);T&&r.push(T)}return r.length?{...n,op:"and",conditions:r}:null}return n.col===i?null:e}function m(e,i){if(!e||typeof e!="object")return!1;const n=e;if(n.col===i)return!0;if(Array.isArray(n.conditions)){for(const t of n.conditions)if(m(t,i))return!0}return!1}function u(e,i,n){if(n&&n.length>=i){let T=0;for(let M=0;M<i;M++)e[M]&&(n[T++]=M);return n.subarray(0,T)}let t=0;for(let T=0;T<i;T++)t+=e[T]?1:0;const r=new Uint32Array(t);let a=0;for(let T=0;T<i;T++)e[T]&&(r[a++]=T);return r}const k=new Map;function R(e){if(!(!e||typeof e!="object"))for(const[i,n]of Object.entries(e))n&&typeof n.compile=="function"&&k.set(i,n)}function p(e){return typeof e=="string"?k.get(e):void 0}}),Je("packages/modules/charts/viewport-filter.js",function(o,Y){"use strict";Object.defineProperty(o,"VIEWPORT_FILTER_DEBOUNCE_MS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"resolveViewportFilter",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"viewportTarget",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"viewportBbox",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"sameBbox",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"findColumnCondition",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"viewportCondition",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"conditionBbox",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"pruneTarget",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"mergeViewportCondition",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"adoptedGeoView",{enumerable:!0,get:function(){return G}});const Q=Y("packages/core/src/compute/filter.js").pruneColumn,$=150,pe=1e-6;function me(z){const x={enabled:!1,column:null,debounce:$};if(z==null||z===!1)return x;const b=z===!0?{}:z;if(typeof b!="object")return x;const f=typeof b.column=="string"&&b.column?b.column:null,l=Number.isFinite(b.debounce)&&b.debounce>=0?Number(b.debounce):$;return{enabled:!0,column:f,debounce:l}}function te(z,x){return typeof x=="string"&&x?{kind:"geometry",column:x}:z&&typeof z.geometry=="string"&&z.geometry?{kind:"geometry",column:z.geometry}:z&&typeof z.lon=="string"&&z.lon&&typeof z.lat=="string"&&z.lat?{kind:"lonlat",lon:z.lon,lat:z.lat}:null}function Z(z,x){if(!z||!x||typeof z.xScale?.invert!="function"||typeof z.yScale?.invert!="function")return null;const b=z.xScale.invert(x.left),f=z.xScale.invert(x.right),l=z.yScale.invert(x.bottom),v=z.yScale.invert(x.top);if(![b,f,l,v].every(Number.isFinite))return null;const C=Math.max(-180,Math.min(b,f)),F=Math.min(180,Math.max(b,f)),_=Math.max(-90,Math.min(l,v)),J=Math.min(90,Math.max(l,v));return!(F>C)||!(J>_)?null:[C,_,F,J]}function H(z,x){return!z||!x?!z&&!x:Math.abs(z[0]-x[0])<=pe&&Math.abs(z[1]-x[1])<=pe&&Math.abs(z[2]-x[2])<=pe&&Math.abs(z[3]-x[3])<=pe}function ue(z,x){if(!z)return null;if(Array.isArray(z.conditions)){for(const b of z.conditions){const f=ue(b,x);if(f)return f}return null}return z.col===x?z:null}function P(z,x,b){const[f,l,v,C]=x,F=b?{meta:{label:b}}:{};return z.kind==="geometry"?{col:z.column,op:"withinBbox",value:[f,l,v,C],...F}:{op:"and",conditions:[{col:z.lon,op:"between",value:[f,v]},{col:z.lat,op:"between",value:[l,C]}],...F}}function y(z,x){if(!z||!x)return null;if(x.kind==="geometry"){const _=ue(z,x.column);if(!_||_.op!=="withinBbox"||!Array.isArray(_.value)||_.value.length<4)return null;const J=_.value.map(Number);return J.every(Number.isFinite)?J:null}const b=ue(z,x.lon),f=ue(z,x.lat);if(!b||b.op!=="between"||!Array.isArray(b.value)||b.value.length<2||!f||f.op!=="between"||!Array.isArray(f.value)||f.value.length<2)return null;const[l,v]=b.value.map(Number),[C,F]=f.value.map(Number);return[l,C,v,F].every(Number.isFinite)?[l,C,v,F]:null}function B(z){return z.kind==="geometry"?[z.column]:[z.lon,z.lat]}function D(z,x){let b=z||null;for(const f of B(x))b=Q(b,f);return b}function I(z,x,b){const f=D(z,x);return f?{op:"and",conditions:[...f.conditions||[f],b]}:b}function G(z,x,b,f){if(!z||!x||!b||!f||!(f.scale>0))return null;const[l,v,C,F]=z,[_,J,re,q]=x,U=C-l,ge=F-v,A=re-_,X=q-J;if(!(U>0)||!(ge>0)||!(A>0)||!(X>0))return null;const ce=(_+re)/2,E=(J+q)/2,W=b.left+(ce-l)/U*(b.right-b.left),h=b.bottom-(E-v)/ge*(b.bottom-b.top);if(!Number.isFinite(W)||!Number.isFinite(h))return null;const s=(b.left+b.right)/2,g=(b.top+b.bottom)/2,c=s-W,d=g-h,[N,S]=f.offset,w=[N-c/f.scale,S+d/f.scale],m=Math.min(U/A,ge/X);return!Number.isFinite(m)||m<=0?null:{zoom:Math.min(8,Math.max(1,f.zoom*m)),offset:w}}}),Je("packages/modules/charts/mapview.js",function(o,Y){"use strict";Object.defineProperty(o,"MAP_ENGINE_TYPES",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"DEFAULT_VIEWPORT_CAP",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"DENSITY_CELLS_ACROSS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"DENSITY_FIT_PASSES",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"FRAME_REFIT_RATIO",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"viewportCap",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"densityCellSize",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"boxSpan",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"ringsBox",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"needsRefit",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"frameMoved",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"planMapViewport",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"engineRowsReader",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"frameOf",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"capClientBound",{enumerable:!0,get:function(){return s}});const Q=Y("packages/core/src/source/pushdown.js").planQuery,pe=Y("packages/core/src/source/aggregates.js").resolveAggregatePlan,te=Y("packages/core/src/internal/util.js").warnOnce,Z=Y("packages/modules/shared/engine.js"),H=Z.engineSource,ue=Z.gridEngineRequest,P=Z.loadedAndMatching,y=Z.sourceId,D=Y("packages/modules/charts/engine.js").aggregateMode,I=Y("packages/modules/charts/viewport-filter.js"),G=I.conditionBbox,z=I.viewportCondition,x=I.viewportTarget,b=Object.freeze(new Set(["markermap","bubblemap","choropleth"])),f=2e4,l=24,v=8,C=2,F="__viewport_rows",_=/^[A-Za-z_][A-Za-z0-9_$]*$/;function J(g){const c=g?g.viewportCap:void 0;return c==null?f:typeof c=="number"&&Number.isInteger(c)&&c>0?c:(te(`chart:viewportCap:${String(c)}`,`chart viewportCap ${JSON.stringify(c)} is not a positive whole number of rows; the map used ${f}.`),f)}function re(g){const c=Number.isFinite(g)&&g>0?Math.min(360,g):360,d=2**Math.floor(Math.log2(c/l));return Math.min(90,Math.max(2**-20,d))}function q(g){return Math.max(g[2]-g[0],g[3]-g[1])}function U(g){let c=1/0,d=1/0,N=-1/0,S=-1/0;for(const w of g||[])for(const[m,u]of w)!Number.isFinite(m)||!Number.isFinite(u)||(c=Math.min(c,m),N=Math.max(N,m),d=Math.min(d,u),S=Math.max(S,u));return N>=c&&S>=d?[c,d,N,S]:null}function ge(g,c){if(!g||!c)return!1;for(const[d,N]of[[0,2],[1,3]]){const S=g[N]-g[d],w=c[N]-c[d];if(!(S>0)||!(w>0))continue;const m=S/w;if(m>C||m<1/C)return!0}return!1}function A(g,c){if(!g||!c)return!!c;const d=1e-9;return!(c[0]>=g[0]-d&&c[1]>=g[1]-d&&c[2]<=g[2]+d&&c[3]<=g[3]+d)||ge(g,c)}function X(g,c,d){const N=g.columns.get(c);if(!N)return`the ${d} column "${c}" is not a column of the grid`;const S=N.value&&typeof N.value=="object"?N.value:null;return N.computed||S&&(typeof S.get=="function"||typeof S.compute=="function")?`the ${d} column "${c}" is computed by the grid, which the engine cannot reproduce`:(typeof N.field=="string"?N.field:c)!==c||!_.test(c)?`the ${d} column "${c}" is not a plain physical column the engine can name`:""}function ce(g,c,d,N){const S=D(c),w=se=>({mode:"client",asked:S,reason:se,refused:S==="engine"});if(S==="client")return{...w("aggregate: 'client' was asked for"),refused:!1};if(!b.has(d))return w(`a "${d}" chart does not draw a viewport`);if(c.rows)return w("the chart was handed its own rows");const m=x(c);if(!m)return w("the map names neither a geometry column nor lon/lat columns");if(m.kind==="geometry"&&(c.lon||c.lat))return w("the map names both a geometry column and lon/lat columns");const u=m.kind==="geometry"?[m.column]:[m.lon,m.lat];for(const se of u){const ae=X(g,se,"placement");if(ae)return w(ae)}const k=H(g);if("reason"in k)return w(k.reason);const{source:R,caps:p}=k,e=R.adapter;if(!e||typeof e.execute!="function")return w("the source's adapter has no execute() to fetch rows with");const i=u[0],n=pe([{id:F,col:i,fn:"count"}],R.aggregates);if(n.client.length)return w(`the source computes "count" client-side (${n.client[0].reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to count in the engine`);const t=Array.isArray(N&&N.bbox)?N.bbox:null,r=t?z(m,t):null,a=ue(g,k,r);if("reason"in a)return w(a.reason);if(S==="auto"){const{loaded:se,total:ae}=P(g);if(Number.isFinite(ae)&&se>=ae)return w("the grid holds every matching row")}const T=J(c),M=t||G(g.filters&&typeof g.filters.get=="function"?g.filters.get():null,m),L=M?re(q(M)):null,ee=m.kind==="geometry"&&d!=="choropleth"&&Array.isArray(p.buckets)&&p.buckets.includes("grid")&&typeof e.executeGroupedAggregates=="function",fe=d==="choropleth"?"a choropleth draws each shape, and has no density form":m.kind!=="geometry"?"the engine bins a geometry column, and this map places its rows by lon/lat":"the source's adapter cannot bin a geometry column into grid cells (no `buckets` capability)",{request:de,quick:Me}=a,ie=ue(g,k),ve=JSON.stringify([y(R),"request"in ie?ie.request.filters:null,Me]),we=JSON.stringify([y(R),de.filters,Me,m,T,d]),Ae=JSON.stringify([we,ee?L||"fit":0]);return{mode:"engine",asked:S,key:Ae,rowsKey:we,baseKey:ve,cap:T,bbox:t,box:M,cellSize:L,run:async se=>{const ae=se?{signal:se}:{},be=await R.aggregate({...de,...ae},[{id:F,col:i,fn:"count"}]);if(be&&Array.isArray(be.client)&&be.client.length)return{map:!0,refused:`the source counted client-side (${be.client[0].reason})`};const le=Number(be&&be.values?be.values[F]:NaN);if(!Number.isFinite(le))return{map:!0,refused:"the engine did not report a count for the view"};if(le<=T){const Ee={...de,range:{start:0,end:T}},Re=Q(Ee,p).pushed,Te=await e.execute({...Re,...ae},{...Ee,...ae});return{map:!0,kind:"rows",rows:(Te&&Array.isArray(Te.rows)?Te.rows:[]).slice(0,T),count:le,cap:T,bbox:t,rowsKey:we}}if(!ee)return{map:!0,kind:"over",count:le,cap:T,bbox:t,reason:fe};let ye=L||re(360),Ne=[];for(let Ee=1;;Ee++){const Re=await R.aggregate({...de,groupBy:[{col:m.column,bucket:"grid",size:ye}],...ae},[{id:F,col:i,fn:"count"}]);if(Re&&Array.isArray(Re.client)&&Re.client.length)return{map:!0,kind:"over",count:le,cap:T,bbox:t,reason:`the source binned client-side (${Re.client[0].reason})`};Ne=[];for(const ze of Re&&Re.groups||[]){if(!ze||ze.level!==1||!Array.isArray(ze.keys)||!Array.isArray(ze.keys[0]))continue;const[Ze,Ye]=ze.keys[0].map(Number),nt=Number(ze.values?ze.values[F]:NaN);!Number.isFinite(Ze)||!Number.isFinite(Ye)||!(nt>0)||Ne.push({west:Ze*ye,south:Ye*ye,east:(Ze+1)*ye,north:(Ye+1)*ye,count:nt})}if(L||Ee>=v)break;const Te=U(W([],Ne));if(!Te)break;const Fe=re(q(Te));if(Fe>=ye)break;ye=Fe}return{map:!0,kind:"density",cells:Ne,count:le,cap:T,bbox:t,size:ye}}}}function E(g,c){const d=typeof g.config=="function"?g.config():{},N=d&&typeof d.rowKey=="string"?d.rowKey:null,S=g.permissions&&typeof g.permissions.levelOf=="function"?g.permissions:null,w=new Map,m=c.map((R,p)=>{const e=N&&R&&R[N]!==void 0&&R[N]!==null?R[N]:`engine:${p}`,i=w.has(e)?`engine:${p}`:e,n={key:i,data:R,group:!1};return w.set(i,n),n}),u=R=>{if(!S)return!0;const p=S.levelOf(R);return p==="read"||p==="write"},k=(R,p)=>{const e=w.get(R);if(!e||!u(p))return;const i=g.columns.get(p),n=i&&typeof i.field=="string"?i.field:p,t=e.data?e.data[n]:void 0,r=i&&i.dataType;if(r&&typeof r.toStorage=="function"&&t!==null&&t!==void 0)try{return r.toStorage(t,{colId:p})}catch{return null}return t};return{columns:g.columns,formatting:g.formatting,messages:g.messages,rows:{count:()=>m.length,get:R=>m[R],value:k,text:(R,p)=>{const e=k(R,p);if(e==null)return"";const i=g.columns.get(p);if(i&&typeof i.formatValue=="function")try{const n=i.formatValue(e,w.get(R));if(typeof n=="string")return n}catch{}return String(e)}}}}function W(g,c=[]){let d=1/0,N=1/0,S=-1/0,w=-1/0;for(const e of g||[])!Number.isFinite(e.lon)||!Number.isFinite(e.lat)||(d=Math.min(d,e.lon),S=Math.max(S,e.lon),N=Math.min(N,e.lat),w=Math.max(w,e.lat));for(const e of c||[])d=Math.min(d,e.west),S=Math.max(S,e.east),N=Math.min(N,e.south),w=Math.max(w,e.north);if(!(S>=d)||!(w>=N))return null;const m=(e,i)=>Math.max(-i,Math.min(i,e)),u=m(d,180),k=m(S,180),R=m(N,90),p=m(w,90);return[[[u,R],[k,R],[k,p],[u,p]]]}function h(g,c){if(!c)return!0;const[d,N,S,w]=c,m=(u,k)=>u>=d&&u<=S&&k>=N&&k<=w;if(g.point)return m(g.point[0],g.point[1]);for(const u of g.polygons||[])for(const k of u)for(const[R,p]of k)if(m(R,p))return!0;return!1}function s(g,c,d,N){const S=J(d),w=N&&Array.isArray(N.bbox)?N.bbox:null;if(!c||!b.has(g))return{bound:c,viewport:null};if(g==="choropleth"){const a=c.features||[];if(a.length<=S)return{bound:c,viewport:null};let T=0;for(const ee of a)h(ee,w)&&T++;if(T<=S)return{bound:c,viewport:null};const M=[];for(const ee of a){ee.point&&M.push({lon:ee.point[0],lat:ee.point[1]});for(const fe of ee.polygons||[])for(const de of fe)for(const[Me,ie]of de)M.push({lon:Me,lat:ie})}const L="a choropleth draws each shape, and has no density form";return{bound:{...c,features:[],empty:!1,over:{count:T,cap:S,reason:L},frame:c.frame||W(M)},viewport:{rows:0,matched:T,cap:S,binned:!1,cells:0,over:L,bbox:w?[...w]:null,computed:"client"}}}const m=c.points||[];if(m.length<=S)return{bound:c,viewport:null};const[u,k,R,p]=w||[-1/0,-1/0,1/0,1/0],e=m.filter(a=>a.lon>=u&&a.lon<=R&&a.lat>=k&&a.lat<=p);if(e.length<=S)return{bound:c,viewport:null};const i=w||U([e.map(a=>[a.lon,a.lat])]),n=re(i?q(i):360),t=new Map;for(const a of e){const T=Math.floor(a.lon/n),M=Math.floor(a.lat/n),L=`${T}:${M}`,ee=t.get(L)||{west:T*n,south:M*n,east:(T+1)*n,north:(M+1)*n,count:0};ee.count++,t.set(L,ee)}const r=[...t.values()];return{bound:{...c,density:{cells:r,size:n},frame:c.frame||W(m)},viewport:{rows:0,matched:e.length,cap:S,binned:!0,cells:r.length,over:null,bbox:w?[...w]:null,computed:"client"}}}}),Je("packages/modules/charts/matrix.js",function(o,Y){"use strict";Object.defineProperty(o,"colourRamp",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"drawHeatmap",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"drawFunnel",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"drawCandlestick",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"VOLUME_PANE_HEIGHT",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"splitPanes",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"clearVolumePane",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"drawCorrelogram",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"title",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"cellAt",{enumerable:!0,get:function(){return Me}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/axis.js"),pe=$.drawAxisLines,me=$.drawBandLabels,te=$.drawCategoryAxis,Z=$.drawContinuousAxis,H=$.drawMeasureAxis,ue=$.leftLabelRoom,P=$.overhangFor,y=$.setLabelText,B=$.setPlotClip,D=Y("packages/modules/charts/cartesian.js"),I=D.continuousSlot,G=D.slotPadFor,z=D.xScaleFor,x=Y("packages/modules/charts/format.js"),b=x.formatters,f=x.measureText,l=Y("packages/modules/charts/scale.js"),v=l.bandScale,C=l.isNumber,F=l.linearTicks,_=l.measureDomain,J=l.toNumber,re=l.toTime,q=Y("packages/modules/charts/svg.js"),U=q.attrs,ge=q.path,A=q.round,X=q.setText,ce=q.SVG_NS,W=Y("packages/modules/charts/typography.js").applySize,s=Y("packages/modules/charts/styles.js").NS,g=Y("packages/modules/charts/scheme.js"),c=g.rampStops,d=g.resolveScheme,N=Y("packages/modules/charts/labels.js"),S=N.drawAnchoredLabels,w=N.labelText,m=Object.freeze([[236,243,249],[0,82,128]]),u=Object.freeze([[176,74,0],[247,247,247],[0,82,128]]);function k(ie,ve,we){const Ae=Math.min(1,Math.max(0,we)),ne=se=>Math.round(ie[se]+(ve[se]-ie[se])*Ae);return`rgb(${ne(0)} ${ne(1)} ${ne(2)})`}function R(ie,ve,we){const Ae=ie.max-ie.min||1,ne=we?c(we,ve):ve?u:m;if(!ve)return ae=>k(ne[0],ne[ne.length-1],(ae-ie.min)/Ae);const se=Math.max(Math.abs(ie.min),Math.abs(ie.max))||1;return ae=>ae>=0?k(ne[1],ne[2],ae/se):k(ne[1],ne[0],-ae/se)}function p(ie){const ve=ie.scheme||d(),{plot:we,bound:Ae}=ie;new Q(ie.groups.grid).finish(),new Q(ie.groups.axis).finish(),new Q(ie.groups.rules).finish(),new Q(ie.groups.labels).finish();const ne=Ae.series.filter(Ee=>!ie.hidden.has(Ee.key)),se=[];for(const Ee of ne)for(const Re of Ee.points)se.push(Re.y);const ae=_(se,{zero:!1,nice:!1}),be=R(ae,!!ie.diverging,ve),le=v(Ae.categories,[we.left,we.right],.04),ye=v(ne.map(Ee=>Ee.label),[we.top,we.bottom],.04),Ne=new Q(ie.groups.marks);for(const Ee of ne){const Re=ye.of(Ee.label);if(!Number.isNaN(Re))for(let Te=0;Te<Ee.points.length;Te++){const Fe=Ee.points[Te],ze=le.of(Fe.x);if(Number.isNaN(ze))continue;const Ze=Ne.next("rect",`${s}__cell ${s}__mark`);U(Ze,{x:A(ze),y:A(Re),width:A(le.bandwidth),height:A(ye.bandwidth),fill:C(Fe.y)?be(Fe.y):"transparent","data-series":Ee.index,"data-point":Te}),Fe.px=A(ze+le.bandwidth/2),Fe.py=A(Re+ye.bandwidth/2)}}if(Ne.finish(),te({group:ie.groups.overlay,plot:we,scale:le,labels:Ae.labels,fontSize:ie.fontSize,rotated:Ae.labels.length>6,config:ie.axis&&ie.axis.x||{}}),me({group:ie.groups.axis,plot:we,scale:ye,labels:ne.map(Ee=>Ee.label),fontSize:ie.fontSize,config:ie.axis&&ie.axis.y||{}}),ie.labels&&ie.labels.show){const Ee=ie.typography&&ie.typography.small||ie.fontSize||11,Re=[];for(const Te of ne)for(const Fe of Te.points)Fe.px===void 0||!C(Fe.y)||Re.push({x:Fe.px,y:Fe.py,text:w(Fe.y,ie.labels,ie.grid),inside:!0,width:le.bandwidth-4,height:ye.bandwidth-2});S({group:ie.groups.labels,size:Ee,minGap:0,anchors:Re})}return{xScale:le,yScale:ye,series:ne,ramp:be,domain:ae}}function e(ie){const ve=ie.scheme||d(),{plot:we,bound:Ae}=ie;new Q(ie.groups.grid).finish(),new Q(ie.groups.axis).finish(),new Q(ie.groups.rules).finish(),new Q(ie.groups.labels).finish();const ne=Ae.series[0],se=ne?ne.points.map((Re,Te)=>({point:Re,label:Ae.labels[Te],value:C(Re.y)?Re.y:0})).filter(Re=>Re.value>0):[];if(!se.length)return{stages:se};let ae=0;for(let Re=0;Re<se.length;Re++)se[Re].value>ae&&(ae=se[Re].value);const be=we.height/se.length,le=we.left+we.width/2,ye=we.width*.62,Ne=new Q(ie.groups.marks);se.forEach((Re,Te)=>{const Fe=se[Te+1],ze=we.top+Te*be,Ze=Re.value/ae*ye/2,Ye=(Fe?Fe.value:Re.value)/ae*ye/2;U(Ne.next("path",`${s}__funnel ${s}__mark`),{d:ge(["M",A(le-Ze),A(ze),"L",A(le+Ze),A(ze),"L",A(le+Ye),A(ze+be-2),"L",A(le-Ye),A(ze+be-2),"Z"]),fill:ve.series(Te),"data-point":Te}),Re.point.px=A(le),Re.point.py=A(ze+be/2)}),Ne.finish();const Ee=new Q(ie.groups.overlay);return se.forEach((Re,Te)=>{const Fe=we.top+Te*be,ze=Ee.next("text",`${s}__funnel-label`);U(ze,{x:A(we.left+4),y:A(Fe+be/2),"text-anchor":"start","dominant-baseline":"middle"}),X(ze,Re.label);const Ze=Ee.next("text",`${s}__funnel-value`);U(Ze,{x:A(we.right-4),y:A(Fe+be/2),"text-anchor":"end","dominant-baseline":"middle"});const Ye=Te===0?1:Re.value/se[Te-1].value,nt=ie.labels&&ie.labels.show?w(Re.value,ie.labels,ie.grid):f(Re.value,ie.grid.messages);X(Ze,Te===0?nt:`${nt} · ${Math.round(Ye*100)}%`)}),Ee.finish(),{stages:se}}function i(ie){const ve=ie.scheme||d(),{bound:we}=ie,[Ae,ne,se,ae]=we.series;if(!Ae||!ne||!se||!ae)return a(ie.groups),{xScale:null,yScale:null,series:[]};const be=ie.volume&&we.series.find((xt,At)=>At>=4&&xt.key===ie.volume)||null,le=be?t(ie.plot,ie.volumeHeight,ie.fontSize):null,ye=le?le.price:ie.plot,Ne=ie.plot,Ee=[];for(const xt of[ne,se])for(const At of xt.points)Ee.push(At.y);const Re=we.yDomain||_(Ee,{zero:!1}),Te={...v([],[0,0])},Fe=L(Re,ye),ze=ie.axis&&ie.axis.x||{},Ze=ie.axis&&ie.axis.y||{},Ye=z(we,Ne,"candlestick",ze),nt=Ye.kind==="band",Ot=nt?Ye.bandwidth:I({bound:we,scale:Ye,config:ze,padding:G("candlestick")});H({gridGroup:ie.groups.grid,axisGroup:ie.groups.axis,plot:ye,scale:Fe,side:Ze.position==="right"?"right":"left",format:b(ie.grid,{kind:"linear",step:(Re.max-Re.min)/5})}),pe({group:ie.groups.rules,plot:ye,side:Ze.position==="right"?"right":"left"});const jt=be?T({ctx:ie,pane:le.volume,series:be,side:Ze.position==="right"?"right":"left"}):null;if(be||a(ie.groups),nt)te({group:ie.groups.overlay,plot:Ne,scale:Ye,labels:we.labels,fontSize:ie.fontSize,rotated:we.labels.length>10,config:ze});else{const xt=we.dimension&&we.dimension.col?ie.grid.columns.get(we.dimension.col):void 0;Z({group:ie.groups.overlay,plot:Ne,scale:Ye,format:b(ie.grid,{kind:we.kind,span:Ye.domain.max-Ye.domain.min,step:(Ye.domain.max-Ye.domain.min)/5},xt),config:ze,grid:ie.grid,size:ie.fontSize})}nt||B(ie.groups,Ne,P("candlestick"));const Bt=new Q(ie.groups.marks);for(let xt=0;xt<we.categories.length;xt++){const At=Ae.points[xt],un=ne.points[xt],qt=se.points[xt],Yt=ae.points[xt];if(![At,un,qt,Yt].every(zt=>zt&&C(zt.y)))continue;const Lt=nt?Ye.of(we.categories[xt])+Ot/2:M(Ye,we.kind,we.categories[xt]);if(Number.isNaN(Lt))continue;const Wt=nt?Lt-Ot/2:Math.max(Ne.left,Lt-Ot/2),en=nt?Lt+Ot/2:Math.min(Ne.right,Lt+Ot/2),nn=Wt,tt=Math.max(1,en-Wt),dt=Yt.y>=At.y,ut=dt?ve.positive:ve.negative;U(Bt.next("path",`${s}__wick ${s}__mark`),{d:ge(["M",A(Lt),A(Fe.of(un.y)),"L",A(Lt),A(Fe.of(qt.y))]),stroke:ut,fill:"none"});const $t=Fe.of(Math.max(At.y,Yt.y)),It=Fe.of(Math.min(At.y,Yt.y));U(Bt.next("rect",`${s}__candle ${s}__mark`),{x:A(nn),y:A($t),width:A(tt),height:A(Math.max(1,It-$t)),fill:dt?"transparent":ut,stroke:ut,"data-point":xt}),Yt.px=A(Lt),Yt.py=A($t);const Et=be?be.points[xt]:null;if(Et&&C(Et.y)){const zt=jt.of(Math.max(jt.domain.min,0)),Jt=jt.of(Et.y);U(Bt.next("rect",`${s}__volume ${s}__mark`),{x:A(nn),y:A(Math.min(zt,Jt)),width:A(tt),height:A(Math.abs(zt-Jt)),fill:ut,"data-point":xt,"data-direction":dt?"up":"down"}),Et.px=A(Lt),Et.py=A(Jt)}}Bt.finish();const Ht={xScale:Ye,yScale:Fe,series:be?[ae,be]:[ae],candles:we.categories.length};return be&&(Ht.volumeScale=jt,Ht.panes={price:le.price,volume:le.volume}),Ht}const n=.25;function t(ie,ve,we){const Ae=Number.isFinite(ve)&&ve>0&&ve<1?Number(ve):n,ne=Math.round(Number.isFinite(we)&&we>0?we:11),se=Math.max(0,ie.height-ne),ae=Math.round(se*Ae),be=se-ae,le={...ie,bottom:ie.top+be,height:be},ye={...ie,top:ie.bottom-ae,height:ae};return{price:le,volume:ye,gap:ne}}function r(ie,ve){const we={grid:null,rules:null,axis:null};if(!ie)return we;for(const Ae of["grid","rules","axis"]){const ne=ie[Ae],se=ne&&ne.parentNode;if(!se)continue;const ae=`${s}__pane-${Ae}`,be=[...se.childNodes||[]];let le=be.find(ye=>String(ye.getAttribute&&ye.getAttribute("class")||"").split(" ").includes(ae))||null;if(!le&&ve){le=se.ownerDocument.createElementNS(ce,"g"),le.setAttribute("class",`${ne.getAttribute("class")} ${ae}`);const ye=be[be.indexOf(ne)+1]||null;ye?se.insertBefore(le,ye):se.appendChild(le)}we[Ae]=le}return we}function a(ie){const ve=r(ie,!1);for(const we of Object.values(ve))we&&new Q(we).finish()}function T(ie){const{ctx:ve,pane:we,series:Ae}=ie,ne=r(ve.groups,!0),se=Ae.points.map(le=>le&&le.y).filter(C),ae=_(se,{zero:!0,ticks:2}),be={...L(ae,we),ticks(le=2){return F(ae,le)}};return H({gridGroup:ne.grid,axisGroup:ne.axis,plot:we,scale:be,side:ie.side,config:{ticks:2},format:b(ve.grid,{kind:"linear",step:(ae.max-ae.min)/2})}),pe({group:ne.rules,plot:we,side:ie.side}),be}function M(ie,ve,we){const Ae=ve==="time"?re(we):J(we);return Ae===null?NaN:ie.of(Ae)}function L(ie,ve){const we=ie.max-ie.min||1,Ae=ve.top-ve.bottom;return{kind:"linear",domain:ie,range:[ve.bottom,ve.top],of(ne){return ve.bottom+(ne-ie.min)/we*Ae},invert(ne){return ie.min+(ne-ve.bottom)/Ae*we},ticks(ne=5){const se=[];for(let ae=0;ae<=ne;ae++)se.push(ie.min+we*ae/ne);return se}}}function ee(ie){const ve=ie.scheme||d(),{plot:we}=ie;new Q(ie.groups.grid).finish(),new Q(ie.groups.rules).finish(),new Q(ie.groups.labels).finish();const Ae=ie.columns||[];if(Ae.length<2)return null;const ne=ie.grid&&ie.grid.statistics;if(!ne)return null;const se=ie.method==="spearman"?"spearman":ie.method==="kendall"?"kendall":"correlation",ae=[];for(let Te=0;Te<Ae.length;Te++)for(let Fe=0;Fe<Ae.length;Fe++){const ze=Te===Fe?1:ne[se](Ae[Te],Ae[Fe]);ae.push({row:Te,col:Fe,a:Ae[Te],b:Ae[Fe],r:ze})}const be=Ae.length,le=we.width/be,ye=we.height/be,Ne=new Q(ie.groups.marks);for(const Te of ae){const Fe=we.left+Te.col*le,ze=we.top+Te.row*ye;Te.x=Fe,Te.y=ze,Te.width=le,Te.height=ye;const Ze=Ne.next("rect",`${s}__cell ${s}__mark`);U(Ze,{x:A(Fe),y:A(ze),width:A(Math.max(0,le-1)),height:A(Math.max(0,ye-1)),fill:Te.row===Te.col||Te.r===null?"var(--lattice-chart-empty, #eceff1)":fe(Te.r,ve),"data-row":Te.row,"data-col":Te.col}),Te.element=Ze}Ne.finish();const Ee=new Q(ie.groups.overlay),Re=ue(we);for(let Te=0;Te<be;Te++){const Fe=Ee.next("text",`${s}__tick`);W(Fe,ie.fontSize),U(Fe,{x:A(we.left-4),y:A(we.top+Te*ye+ye/2),"text-anchor":"end","dominant-baseline":"middle"}),y(Fe,de(ie.grid,Ae[Te]),Re,ie.fontSize);const ze=Ee.next("text",`${s}__tick`);W(ze,ie.fontSize),U(ze,{x:A(we.left+Te*le+le/2),y:A(we.top-4),"text-anchor":"middle"}),y(ze,de(ie.grid,Ae[Te]),le,ie.fontSize)}if(ie.values!==!1&&le>ie.fontSize*2.6&&ye>ie.fontSize*1.5)for(const Te of ae){if(Te.row===Te.col||Te.r===null)continue;const Fe=Ee.next("text",`${s}__data-label`);W(Fe,ie.fontSize),U(Fe,{x:A(we.left+Te.col*le+le/2),y:A(we.top+Te.row*ye+ye/2),"text-anchor":"middle","dominant-baseline":"middle","data-inside":"true"}),X(Fe,Te.r.toFixed(2))}return Ee.finish(),{cells:ae,columns:Ae}}function fe(ie,ve){const we=Math.min(1,Math.abs(ie)),Ae=ve?c(ve,!0):u,ne=Ae[Math.floor(Ae.length/2)],se=ie>=0?Ae[Ae.length-1]:Ae[0];return k(ne,se,we)}function de(ie,ve){const we=ie&&ie.columns&&typeof ie.columns.get=="function"?ie.columns.get(ve):null;return String(we&&we.title||ve)}function Me(ie){for(const ve of ie.cells||[])if(ve.x!==void 0&&ie.x>=ve.x&&ie.x<=ve.x+ve.width&&ie.y>=ve.y&&ie.y<=ve.y+ve.height)return ve;return null}}),Je("packages/modules/charts/mapdensity.js",function(o,Y){"use strict";Object.defineProperty(o,"drawDensityCells",{enumerable:!0,get:function(){return y}});const ke=Y("packages/modules/charts/svg.js"),Q=ke.attrs,$=ke.path,pe=ke.round,te=Y("packages/modules/charts/scale.js").measureDomain,H=Y("packages/modules/charts/matrix.js").colourRamp,P=Y("packages/modules/charts/styles.js").NS;function y(B){const{pool:D,cells:I,to:G,plot:z,scheme:x}=B;let b=0;for(const F of I)F.count>b&&(b=F.count);const f=te([0,b],{zero:!0}),l=H(f,!1,x),v=(F,_)=>{const[J,re]=G(F,_);return!Number.isFinite(J)||!Number.isFinite(re)?null:[Math.min(Math.max(J,z.left),z.right),Math.min(Math.max(re,z.top),z.bottom)]};let C=0;for(const F of I){const _=[v(F.west,F.south),v(F.east,F.south),v(F.east,F.north),v(F.west,F.north)];if(_.some(U=>U===null))continue;const J=_.map(U=>U[0]),re=_.map(U=>U[1]);if(Math.max(...J)-Math.min(...J)<.5||Math.max(...re)-Math.min(...re)<.5)continue;const q=[];_.forEach((U,ge)=>q.push(ge?"L":"M",pe(U[0]),pe(U[1]))),q.push("Z"),Q(D.next("path",`${P}__density-cell ${P}__mark`),{d:$(q),fill:l(F.count),stroke:"none","data-count":F.count,class:`${P}__density-cell ${P}__mark`}),C++}return{cells:C,maxCount:b,domain:f,ramp:l}}}),Je("packages/modules/charts/radial.js",function(o,Y){"use strict";Object.defineProperty(o,"horizontalRoom",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"arcPath",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"layoutRings",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"drawRadial",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"arcAt",{enumerable:!0,get:function(){return c}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/svg.js"),pe=$.attrs,me=$.path,te=$.round,Z=$.setText,ue=Y("packages/modules/charts/styles.js").NS,y=Y("packages/modules/charts/scheme.js").resolveScheme,B=Y("packages/modules/charts/labels.js"),D=B.drawAnchoredLabels,I=B.labelText,G=Y("packages/modules/charts/typography.js"),z=G.applySize,x=G.textWidth,b=G.truncateTo,l=Y("packages/modules/charts/format.js").measureFormat,v=Math.PI*2,C=-Math.PI/2,F=.25,_=2,J=3,re=.58,q=8,U=2;function ge(d,N,S,w){return d==="total"?l(N,S,w):typeof d=="number"?l(d,S,w):d==null?"":String(d)}function A(d,N,S){if(!d||S<=0)return q;let w=N;for(;w>q&&x(d,w)>S;)w-=1;return Math.max(q,w)}function X(d,N,S,w){const m=S*Math.SQRT2-4;if(m<=0||!d&&!N)return null;let u=A(d,Math.min(m,w*(N?1.6:2.2)),m),k=N?A(N,Math.min(m,u*.55),m):0;const R=N?U:0;for(;u+R+k>m&&(u>q||k>q);)u>q&&(u-=1),N&&k>q&&(k-=1);const p=x(d,u)>m?b(d,m,u):d,e=N&&x(N,k)>m?b(N,m,k):N;return{value:p,valueSize:u,label:e||"",labelSize:k,gap:R,height:u+R+k}}function ce(d,N){const{cx:S,cy:w,hole:m,centre:u,total:k,column:R,grid:p,baseSize:e}=N,i=ge(u.value,k,R,p),n=u.label?String(u.label):"",t=X(i,n,m,e);if(!t)return;const r=t.label?w-t.height/2+t.valueSize/2:w;if(t.value){const a=d.next("text",`${ue}__donut-centre-value`);pe(a,{x:te(S),y:te(r),"dominant-baseline":"middle"}),z(a,t.valueSize),Z(a,t.value)}if(t.label){const a=d.next("text",`${ue}__donut-centre-label`);pe(a,{x:te(S),y:te(r+t.valueSize/2+t.gap+t.labelSize/2),"dominant-baseline":"middle"}),z(a,t.labelSize),Z(a,t.label)}}function E(d,N,S,w){return[d+S*Math.cos(w),N+S*Math.sin(w)]}function W(d,N,S){const{inner:w,outer:m,from:u,to:k}=d;if(S*S>=m*m)return 0;const R=Math.sqrt(m*m-S*S);let p=N+R,e=R-N;if(w>0&&S*S<w*w){const i=Math.sqrt(w*w-S*S);if(N>=i)p=Math.min(p,N-i);else if(N<=-i)e=Math.min(e,-i-N);else return 0}if(k-u<v-1e-9)for(const i of[u,k]){const n=Math.sin(i);if(Math.abs(n)<1e-9)continue;const t=S/n;if(t<=0)continue;const r=t*Math.cos(i);r>=N?e=Math.min(e,r-N):p=Math.min(p,N-r)}return Math.max(0,p)+Math.max(0,e)}function h(d){const{cx:N,cy:S,inner:w,outer:m}=d,u=d.to-d.from;if(u<=0)return"";if(u>=v-1e-9){const[t,r]=E(N,S,m,d.from),[a,T]=E(N,S,m,d.from+Math.PI),M=["M",te(t),te(r),"A",te(m),te(m),0,1,1,te(a),te(T),"A",te(m),te(m),0,1,1,te(t),te(r)];if(w>0){const[L,ee]=E(N,S,w,d.from),[fe,de]=E(N,S,w,d.from+Math.PI);M.push("M",te(L),te(ee),"A",te(w),te(w),0,1,0,te(fe),te(de),"A",te(w),te(w),0,1,0,te(L),te(ee))}return me(M)}const k=u>Math.PI?1:0,[R,p]=E(N,S,m,d.from),[e,i]=E(N,S,m,d.to),n=["M",te(R),te(p),"A",te(m),te(m),0,k,1,te(e),te(i)];if(w>0){const[t,r]=E(N,S,w,d.to),[a,T]=E(N,S,w,d.from);n.push("L",te(t),te(r)),n.push("A",te(w),te(w),0,k,0,te(a),te(T))}else n.push("L",te(N),te(S));return n.push("Z"),me(n)}function s(d){const N=[],S=(w,m,u,k,R,p)=>{if(k>0&&N.push({node:w,from:m,to:u,depth:k,index:R,label:w.label,total:w.total,path:p}),k>=d.maxRings||!w.children.length)return;const e=w.children.reduce((t,r)=>t+r.total,0),i=u-m;if(e<=0||i<=0)return;let n=m;for(let t=0;t<w.children.length;t++){const r=w.children[t],a=r.total/e*i;S(r,n,n+a,k+1,k===0?t:R,[...p,r.label]),n+=a}};return S(d.root,C,C+v,0,0,[]),N}function g(d){const N=d.scheme||y(),{plot:S,tree:w,type:m}=d,u=S.left+S.width/2,k=S.top+S.height/2,R=Math.max(0,Math.min(S.width,S.height)/2-2),p=m==="sunburst"?Math.max(1,w.depth):1,e=s({root:w.root,depth:w.depth,maxRings:p}).filter(L=>!d.hidden.has(L.label)),i=m==="donut"?R*re:0,n=p>0?(R-i)/p:R;new Q(d.groups.grid).finish(),new Q(d.groups.axis).finish(),new Q(d.groups.rules).finish(),new Q(d.groups.labels).finish();const t=w.root.children.map(L=>L.label),r=new Q(d.groups.marks);for(const L of e){const ee=i+(L.depth-1)*n,fe=ee+n,de=r.next("path",`${ue}__slice ${ue}__mark`);pe(de,{d:h({cx:u,cy:k,inner:ee,outer:fe,from:L.from,to:L.to}),fill:N.series(L.index,t[L.index]),"fill-opacity":L.depth>1?Math.max(.45,1-(L.depth-1)*.22):1,"data-arc":e.indexOf(L)}),L.geometry={cx:u,cy:k,inner:ee,outer:fe}}r.finish();const a=d.typography&&d.typography.small||d.fontSize||11,T=!(d.labels&&d.labels.names===!1),M=new Q(d.groups.overlay);if(T)for(const L of e){if(L.to-L.from<F||L.geometry.outer-L.geometry.inner<a+_*2)continue;const ee=(L.from+L.to)/2,fe=L.geometry.inner+(L.geometry.outer-L.geometry.inner)/2;if((L.to-L.from)*fe<a+_*2)continue;const[de,Me]=E(u,k,fe,ee),{inner:ie,outer:ve}=L.geometry,we=W({inner:ie,outer:ve,from:L.from,to:L.to},de-u,Me-k)-_*2,Ae=String(L.label===null||L.label===void 0?"":L.label),ne=b(Ae,we,a);if(ne!==Ae&&ne.length<J)continue;const se=M.next("text",`${ue}__slice-label`);pe(se,{x:te(de),y:te(Me),"dominant-baseline":"middle"}),z(se,a),Z(se,ne)}if(m==="donut"&&d.centre&&i>0){const L=d.grid&&d.grid.columns&&w.measure&&w.measure.col?d.grid.columns.get(w.measure.col):null;ce(M,{cx:u,cy:k,hole:i,centre:d.centre,total:e.filter(ee=>ee.depth===1).reduce((ee,fe)=>ee+fe.total,0),column:L,grid:d.grid,baseSize:a})}return M.finish(),d.labels&&d.labels.show&&D({group:d.groups.labels,size:a,minGap:d.labels.minGap,anchors:e.filter(L=>L.depth===1&&L.to-L.from>=F).map(L=>{const ee=(L.from+L.to)/2,fe=L.geometry.inner+(L.geometry.outer-L.geometry.inner)/2,[de,Me]=E(u,k,fe,ee);return{x:te(de),y:te(Me+a+1),text:I(L.total,d.labels,d.grid),inside:!0}})}),{arcs:e,centre:{x:u,y:k,r:R}}}function c(d){for(const N of d.arcs){const S=N.geometry;if(!S)continue;const w=d.x-S.cx,m=d.y-S.cy,u=Math.sqrt(w*w+m*m);if(u<S.inner||u>S.outer)continue;let k=Math.atan2(m,w);for(;k<C;)k+=v;for(;k>=C+v;)k-=v;if(k>=N.from&&k<N.to)return N}return null}}),Je("packages/modules/charts/distribution.js",function(o,Y){"use strict";Object.defineProperty(o,"FENCE",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"summarise",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"binEdge",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"outsideDomain",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"readingsOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"valuesByCategory",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"allReadings",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"distributionDomain",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"density",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"drawHistogram",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"drawBoxPlot",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"probit",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"drawQQ",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"drawEcdf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"drawLorenz",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"drawControl",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"drawCapability",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"drawMovingRange",{enumerable:!0,get:function(){return i}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/axis.js"),pe=$.drawAxisLines,me=$.drawCategoryAxis,te=$.drawContinuousAxis,Z=$.drawMeasureAxis,H=$.tickLabeller,P=Y("packages/modules/charts/format.js").formatters,y=Y("packages/modules/charts/scale.js"),B=y.bandScale,D=y.isNumber,I=y.linearScale,G=y.measureDomain,z=y.niceStep,x=Y("packages/modules/charts/svg.js"),b=x.attrs,f=x.path,l=x.round,C=Y("packages/modules/charts/styles.js").NS,_=Y("packages/modules/charts/scheme.js").resolveScheme,J=Y("packages/modules/charts/labels.js"),re=J.drawAnchoredLabels,q=J.labelText,U=1.5,ge="–";function A(n,t){const r=n.length;if(!r)return NaN;if(r===1)return n[0];const a=(r-1)*Math.min(1,Math.max(0,t)),T=Math.floor(a),M=Math.ceil(a);return T===M?n[T]:n[T]+(a-T)*(n[M]-n[T])}function X(n){const t=n.filter(D).slice().sort((Me,ie)=>Me-ie);if(!t.length)return null;const r=A(t,.25),a=A(t,.5),T=A(t,.75),M=T-r,L=r-U*M,ee=T+U*M;let fe=t[0];for(const Me of t)if(Me>=L){fe=Me;break}let de=t[t.length-1];for(let Me=t.length-1;Me>=0;Me--)if(t[Me]<=ee){de=t[Me];break}return{min:t[0],q1:r,median:a,q3:T,max:t[t.length-1],low:fe,high:de,outliers:t.filter(Me=>Me<L||Me>ee),count:t.length}}function ce(n,t,r){const a=n+r*t;return Math.abs(a)<t/1e6?0:Number(a.toPrecision(12))}function E(n,t){const r=t||{},a=D(r.min),T=D(r.max);if(!a&&!T)return 0;let M=0;for(let L=0;L<n.length;L++){const ee=n[L];D(ee)&&(a&&ee<r.min||T&&ee>r.max)&&M++}return M}function W(n,t=12,r){const a=r||{},T=D(a.min),M=D(a.max);let L=1/0,ee=-1/0,fe=0;for(let Ae=0;Ae<n.length;Ae++){const ne=n[Ae];D(ne)&&(T&&ne<a.min||M&&ne>a.max||(ne<L&&(L=ne),ne>ee&&(ee=ne),fe++))}if(!fe)return[];if(T&&(L=Number(a.min)),M&&(ee=Number(a.max)),L===ee){const Ae=Math.abs(L)>0?Math.abs(L)/10:.5;L-=Ae,ee+=Ae}const de=z((ee-L)/Math.max(1,t)),Me=Math.floor(L/de)*de,ie=Math.ceil(ee/de)*de,ve=[],we=Math.max(1,Math.round((ie-Me)/de));for(let Ae=0;Ae<we;Ae++)ve.push({from:ce(Me,de,Ae),to:ce(Me,de,Ae+1),count:0});for(let Ae=0;Ae<n.length;Ae++){const ne=n[Ae];if(!D(ne)||T&&ne<a.min||M&&ne>a.max)continue;let se=Math.floor((ne-Me)/de);se>=ve.length&&(se=ve.length-1),se<0&&(se=0),ve[se].count++}return ve}function h(n){if(!n)return[];if(Array.isArray(n.values)){const t=n.values.filter(D);if(t.length)return t}return D(n.y)?[n.y]:[]}function s(n){const t=new Map,r=!(n.dimension&&n.dimension.col),a=r&&n.measure&&n.measure.title||"";for(const T of n.series)for(const M of T.points){const L=h(M);if(!L.length)continue;const ee=r?a:M.label;t.has(ee)||t.set(ee,[]);const fe=t.get(ee);for(const de of L)fe.push(de)}return t}function g(n){const t=[];for(const r of n.series||[])for(const a of r.points||[])for(const T of h(a))t.push(T);return t}function c(n,t){const r=t&&t.y||{};return G(n,{zero:!1,min:r.min,max:r.max})}function d(n,t,r){const a=n.length;if(!a)return[];const T=n.reduce((Me,ie)=>Me+ie,0)/a,M=n.reduce((Me,ie)=>Me+(ie-T)**2,0)/Math.max(1,a-1),L=Math.sqrt(M)||1,ee=Math.max(1e-9,1.06*L*a**(-1/5)),fe=[],de=t.max-t.min||1;for(let Me=0;Me<r;Me++){const ie=t.min+de*Me/(r-1||1);let ve=0;for(const we of n){const Ae=(ie-we)/ee;ve+=Math.exp(-.5*Ae*Ae)}fe.push({at:ie,density:ve/(a*ee*Math.sqrt(Math.PI*2))})}return fe}function N(n,t,r){const a=P(n.grid,{kind:"linear",step:r}),T=t.measure&&t.measure.col&&n.grid.columns?n.grid.columns.get(t.measure.col):null,L=!!(T&&T.format&&typeof T.formatValue=="function")?{tick:ee=>String(T.formatValue(ee,null))}:a;return H(n.axis&&n.axis.x||{},L,n.grid)}function S(n){const t=n.scheme||_(),{plot:r,bound:a}=n,T=g(a),M=n.axis&&n.axis.y||{},L=W(T,n.buckets||12,M),ee=E(T,M),fe=L.map(le=>le.count),de=G(fe,{zero:!0}),Me=I(de,[r.bottom,r.top]),ie=L.length?L[0].to-L[0].from:1,ve=N(n,a,ie),we=L.map(le=>ve(le.from)),Ae=L.map(le=>`${ve(le.from)} ${ge} ${ve(le.to)}`),ne=L.map((le,ye)=>ye),se=B(ne,[r.left,r.right],.08);Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:Me,format:P(n.grid,{kind:"linear",step:(de.max-de.min)/5})}),me({group:n.groups.overlay,plot:r,scale:se,labels:we,fontSize:n.fontSize,rotated:we.length>8}),pe({group:n.groups.rules,plot:r});const ae=new Q(n.groups.marks),be=Me.of(de.min<=0?0:de.min);if(L.forEach((le,ye)=>{const Ne=Me.of(le.count);b(ae.next("rect",`${C}__bar ${C}__mark`),{x:l(se.of(ye)),y:l(Math.min(Ne,be)),width:l(se.bandwidth),height:l(Math.max(le.count>0?1:0,Math.abs(be-Ne))),fill:t.series(0),"data-point":ye})}),ae.finish(),n.curve&&T.length>1){const le={min:L[0].from,max:L[L.length-1].to},ye=d(T,le,Math.max(24,L.length*4)),Ne=ye.reduce((Ee,Re)=>Math.max(Ee,Re.density),0);if(Ne>0){const Ee=le.max-le.min||1,Re=Me.of(de.max),Te=ye.map(ze=>[l(r.left+(ze.at-le.min)/Ee*(r.right-r.left)),l(be-ze.density/Ne*(be-Re))]),Fe=new Q(n.groups.overlay);b(Fe.next("path",`${C}__density ${C}__mark`),{d:f(Te.flatMap(([ze,Ze],Ye)=>[Ye?"L":"M",ze,Ze])),fill:"none",stroke:t.series(1)}),Fe.finish()}}if(n.labels&&n.labels.show){const le=n.typography&&n.typography.small||n.fontSize||11;re({group:n.groups.labels,size:le,minGap:n.labels.minGap,plot:r,anchors:L.map((ye,Ne)=>{const Ee=Math.min(Me.of(ye.count),be),Re=Ee-le/2-2,Te=Re<r.top;return{x:l(se.of(Ne)+se.bandwidth/2),y:l(Te?Ee+le/2+2:Re),text:ye.count?q(ye.count,n.labels,n.grid):"",inside:Te,height:Te?Math.abs(be-Ee)-2:void 0}})})}return{xScale:se,yScale:Me,buckets:L,labels:Ae,categories:L.map(le=>le.from),outside:ee,series:[{key:"",label:a.measure.title,index:0,points:L.map((le,ye)=>({x:ye,xKey:String(ye),label:Ae[ye],from:le.from,to:le.to,y:le.count,rows:le.count}))}]}}function w(n){const t=n.scheme||_(),{plot:r,bound:a}=n,T=s(a),M=[...T.keys()],L=M.map(we=>X(T.get(we))).filter(Boolean),ee=[];for(const we of L)ee.push(we.min,we.max);const fe=c(ee,n.axis),de=I(fe,[r.bottom,r.top]),Me=B(M,[r.left,r.right],.4);Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:de,format:P(n.grid,{kind:"linear",step:(fe.max-fe.min)/5})}),me({group:n.groups.overlay,plot:r,scale:Me,labels:M,fontSize:n.fontSize,rotated:M.length>6}),pe({group:n.groups.rules,plot:r});const ie=new Q(n.groups.marks),ve=Me.bandwidth;return M.forEach((we,Ae)=>{const ne=L[Ae];if(!ne)return;const se=Me.of(we),ae=se+ve/2,be=t.series(Ae);b(ie.next("rect",`${C}__box ${C}__mark`),{x:l(se),y:l(de.of(ne.q3)),width:l(ve),height:l(Math.max(1,de.of(ne.q1)-de.of(ne.q3))),fill:be,"fill-opacity":.35,stroke:be,"data-point":Ae}),b(ie.next("path",`${C}__whisker ${C}__mark`),{d:f(["M",l(ae),l(de.of(ne.high)),"L",l(ae),l(de.of(ne.q3)),"M",l(ae),l(de.of(ne.q1)),"L",l(ae),l(de.of(ne.low)),"M",l(se+ve*.25),l(de.of(ne.high)),"L",l(se+ve*.75),l(de.of(ne.high)),"M",l(se+ve*.25),l(de.of(ne.low)),"L",l(se+ve*.75),l(de.of(ne.low))]),stroke:be,fill:"none"}),b(ie.next("path",`${C}__median ${C}__mark`),{d:f(["M",l(se),l(de.of(ne.median)),"L",l(se+ve),l(de.of(ne.median))]),stroke:be,"stroke-width":2,fill:"none"});for(const le of ne.outliers)b(ie.next("circle",`${C}__point ${C}__mark`),{cx:l(ae),cy:l(de.of(le)),r:2.5,fill:be,"fill-opacity":.8})}),ie.finish(),{xScale:Me,yScale:de,boxes:L,series:[{key:"",label:a.measure.title,index:0,points:M.map((we,Ae)=>({x:we,xKey:we,label:we,y:L[Ae]?L[Ae].median:null,rows:L[Ae]?L[Ae].count:0}))}]}}function m(n){if(!(n>0&&n<1))return Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],a=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],T=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],M=.02425;if(n<M){const fe=Math.sqrt(-2*Math.log(n));return(((((a[0]*fe+a[1])*fe+a[2])*fe+a[3])*fe+a[4])*fe+a[5])/((((T[0]*fe+T[1])*fe+T[2])*fe+T[3])*fe+1)}if(n>1-M){const fe=Math.sqrt(-2*Math.log(1-n));return-(((((a[0]*fe+a[1])*fe+a[2])*fe+a[3])*fe+a[4])*fe+a[5])/((((T[0]*fe+T[1])*fe+T[2])*fe+T[3])*fe+1)}const L=n-.5,ee=L*L;return(((((t[0]*ee+t[1])*ee+t[2])*ee+t[3])*ee+t[4])*ee+t[5])*L/(((((r[0]*ee+r[1])*ee+r[2])*ee+r[3])*ee+r[4])*ee+1)}function u(n){const t=n.scheme||_(),{plot:r,bound:a}=n;new Q(n.groups.grid).finish(),new Q(n.groups.axis).finish(),new Q(n.groups.rules).finish(),new Q(n.groups.labels).finish();const T=g(a);if(T.length<3)return null;const M=T.slice().sort((Ne,Ee)=>Ne-Ee),L=M.length,ee=M.map((Ne,Ee)=>m((Ee+1-.375)/(L+.25))),fe=G(ee,{zero:!1,nice:!0}),de=G(M,{zero:!1,nice:!0}),Me=I(fe,[r.left,r.right]),ie=I(de,[r.bottom,r.top]);Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ie,format:P(n.grid,{kind:"linear",step:(de.max-de.min)/5})}),te({group:n.groups.overlay,plot:r,scale:Me,fontSize:n.fontSize,format:P(n.grid,{kind:"linear",step:(fe.max-fe.min)/5})}),pe({group:n.groups.rules,plot:r});const ve=A(M,.25),we=A(M,.75),Ae=m(.25),ne=m(.75),se=(we-ve)/(ne-Ae),ae=ve-se*Ae,be=new Q(n.groups.rules);b(be.next("path",`${C}__qq-line`),{d:f(["M",l(Me.of(fe.min)),l(ie.of(ae+se*fe.min)),"L",l(Me.of(fe.max)),l(ie.of(ae+se*fe.max))]),fill:"none"}),be.finish();const le=new Q(n.groups.marks),ye=[];for(let Ne=0;Ne<L;Ne++){const Ee=l(Me.of(ee[Ne])),Re=l(ie.of(M[Ne]));b(le.next("circle",`${C}__point ${C}__mark`),{cx:Ee,cy:Re,r:2.5,fill:t.series(0),"data-point":Ne}),ye.push({x:Ee,y:Re,theoretical:ee[Ne],sample:M[Ne]})}return le.finish(),{points:ye,line:{slope:se,intercept:ae}}}function k(n){const t=n.scheme||_(),{plot:r,bound:a}=n;new Q(n.groups.grid).finish(),new Q(n.groups.axis).finish(),new Q(n.groups.rules).finish(),new Q(n.groups.labels).finish();const T=g(a);if(!T.length)return null;const M=T.slice().sort((we,Ae)=>we-Ae),L=M.length,ee=G(M,{zero:!1,nice:!0}),fe=I(ee,[r.left,r.right]),de=I({min:0,max:1},[r.bottom,r.top]);Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:de,format:P(n.grid,{kind:"linear",step:.2})}),te({group:n.groups.overlay,plot:r,scale:fe,fontSize:n.fontSize,format:P(n.grid,{kind:"linear",step:(ee.max-ee.min)/5})}),pe({group:n.groups.rules,plot:r});const Me=["M",l(fe.of(ee.min)),l(de.of(0))],ie=[];for(let we=0;we<L;we++){const Ae=l(fe.of(M[we])),ne=(we+1)/L;Me.push("L",Ae,l(de.of(we/L)),"L",Ae,l(de.of(ne))),ie.push({value:M[we],share:ne})}Me.push("L",l(fe.of(ee.max)),l(de.of(1)));const ve=new Q(n.groups.marks);return b(ve.next("path",`${C}__ecdf ${C}__mark`),{d:f(Me),fill:"none",stroke:t.series(0)}),ve.finish(),{steps:ie}}function R(n){const t=n.scheme||_(),{plot:r,bound:a}=n;new Q(n.groups.grid).finish(),new Q(n.groups.axis).finish(),new Q(n.groups.rules).finish(),new Q(n.groups.labels).finish();const T=g(a).filter(ae=>ae>=0);if(!T.length)return null;const M=T.slice().sort((ae,be)=>ae-be),L=M.length,ee=M.reduce((ae,be)=>ae+be,0);if(ee<=0)return null;const fe=I({min:0,max:1},[r.left,r.right]),de=I({min:0,max:1},[r.bottom,r.top]);Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:de,format:P(n.grid,{kind:"linear",step:.2})}),te({group:n.groups.overlay,plot:r,scale:fe,fontSize:n.fontSize,format:P(n.grid,{kind:"linear",step:.2})}),pe({group:n.groups.rules,plot:r});const Me=new Q(n.groups.rules);b(Me.next("path",`${C}__lorenz-equality`),{d:f(["M",l(fe.of(0)),l(de.of(0)),"L",l(fe.of(1)),l(de.of(1))]),fill:"none"}),Me.finish();const ie=["M",l(fe.of(0)),l(de.of(0))],ve=[{rows:0,held:0}];let we=0;for(let ae=0;ae<L;ae++){we+=M[ae];const be={rows:(ae+1)/L,held:we/ee};ie.push("L",l(fe.of(be.rows)),l(de.of(be.held))),ve.push(be)}const Ae=new Q(n.groups.marks);b(Ae.next("path",`${C}__lorenz ${C}__mark`),{d:f(ie),fill:"none",stroke:t.series(0)}),Ae.finish();let ne=0;for(let ae=0;ae<L;ae++)ne+=(ae+1)*M[ae];const se=2*ne/(L*ee)-(L+1)/L;return{curve:ve,gini:se}}function p(n){const t=n.scheme||_(),{plot:r,bound:a}=n;new Q(n.groups.grid).finish(),new Q(n.groups.labels).finish();const T=[];for(const ye of a.series)for(const Ne of ye.points)D(Ne.y)&&T.push(Ne.y);if(T.length<2)return null;const M=n.capability||null,L=M&&M.limits?M.limits:null,ee=[...T];L&&ee.push(L.upper,L.lower),M&&(M.lower!==null&&ee.push(M.lower),M.upper!==null&&ee.push(M.upper));const fe=G(ee,{zero:!1,nice:!0}),de=I(fe,[r.bottom,r.top]),Me=T.length>1?(r.right-r.left)/(T.length-1):0;Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:de,format:P(n.grid,{kind:"linear",step:(fe.max-fe.min)/5})}),pe({group:n.groups.rules,plot:r});const ie=new Q(n.groups.overlay),ve=[],we=(ye,Ne,Ee,Re="end")=>{!Number.isFinite(ye)||ye<fe.min||ye>fe.max||(b(ie.next("path",Ne),{d:f(["M",l(r.left),l(de.of(ye)),"L",l(r.right),l(de.of(ye))]),fill:"none"}),Ee&&ve.push({y:de.of(ye),text:Ee,side:Re}))};L&&(we(L.centre,`${C}__control-centre`,"CL","end"),we(L.upper,`${C}__control-limit`,"UCL","end"),we(L.lower,`${C}__control-limit`,"LCL","end")),M&&(M.lower!==null&&we(M.lower,`${C}__spec-limit`,"LSL","start"),M.upper!==null&&we(M.upper,`${C}__spec-limit`,"USL","start"),M.target!==null&&we(M.target,`${C}__spec-target`,"Target","start")),ie.finish();const Ae=new Map;for(const ye of M&&M.violations?M.violations:[]){const Ne=Ae.get(ye.index);Ne?Ne.includes(ye.rule)||Ne.push(ye.rule):Ae.set(ye.index,[ye.rule])}const ne=new Set(Ae.keys()),se=new Q(n.groups.marks),ae=[],be=[];for(let ye=0;ye<T.length;ye++){const Ne=l(r.left+ye*Me),Ee=l(de.of(T[ye]));ae.push(ye?"L":"M",Ne,Ee),be.push({x:Ne,y:Ee,index:ye,value:T[ye],violating:ne.has(ye)})}b(se.next("path",`${C}__control-line ${C}__mark`),{d:f(ae),fill:"none",stroke:t.series(0)});for(const ye of be)b(se.next("circle",`${C}__point ${C}__mark`),{cx:ye.x,cy:ye.y,r:ye.violating?4:2.5,fill:ye.violating?"var(--lattice-danger, #a4262c)":t.series(0),"data-violation":ye.violating?"true":null});se.finish();const le=[];for(const{y:ye,text:Ne,side:Ee}of ve)le.push({x:Ee==="start"?r.left+2:r.right-2,y:ye-3,text:Ne,anchor:Ee,className:`${C}__control-name`});for(const ye of be){const Ne=Ae.get(ye.index);Ne&&le.push({x:ye.x,y:ye.y-7,text:Ne.sort((Ee,Re)=>Ee-Re).join(","),anchor:"middle",className:`${C}__control-rule`})}return re({group:n.groups.labels,anchors:le,size:9,grid:n.grid,minGap:1}),{points:be,limits:L,ruleSet:M?M.ruleSet:null}}function e(n){const t=n.scheme||_(),{plot:r,bound:a}=n;new Q(n.groups.grid).finish();const T=[];for(const le of a.series)for(const ye of le.points)D(ye.y)&&T.push(ye.y);if(T.length<2)return null;const M=n.capability||null,L=[...T];M&&(M.lower!==null&&L.push(M.lower),M.upper!==null&&L.push(M.upper),M.target!==null&&L.push(M.target));const ee=G(L,{zero:!1,nice:!0}),fe=I(ee,[r.left,r.right]),de=W(T,n.buckets||14),Me=de.map(le=>le.count),ie=G(Me,{zero:!0}),ve=I(ie,[r.bottom,r.top]);Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ve,format:P(n.grid,{kind:"linear",step:(ie.max-ie.min)/5})}),te({group:n.groups.overlay,plot:r,scale:fe,fontSize:n.fontSize,format:P(n.grid,{kind:"linear",step:(ee.max-ee.min)/5})}),pe({group:n.groups.rules,plot:r});const we=ve.of(0),Ae=new Q(n.groups.marks);for(let le=0;le<de.length;le++){const ye=de[le],Ne=fe.of(ye.from),Ee=fe.of(ye.to),Re=ve.of(ye.count);b(Ae.next("rect",`${C}__bar ${C}__mark`),{x:l(Math.min(Ne,Ee)),y:l(Math.min(Re,we)),width:l(Math.max(1,Math.abs(Ee-Ne)-1)),height:l(Math.max(ye.count>0?1:0,Math.abs(we-Re))),fill:t.series(0),"data-point":le})}Ae.finish();const ne=new Q(n.groups.overlay),se=[];if(M&&Number.isFinite(M.mean)){const ye=Te=>{if(!Number.isFinite(Te)||Te<=0)return null;const Fe=[];for(let ze=0;ze<=96;ze++){const Ze=ee.min+(ee.max-ee.min)*ze/96,Ye=(Ze-M.mean)/Te;Fe.push({at:Ze,y:Math.exp(-.5*Ye*Ye)/Te})}return Fe},Ne=ye(M.sigmaWithin),Ee=ye(M.sigmaOverall);let Re=0;for(const Te of[Ne,Ee])if(Te)for(const Fe of Te)Re=Math.max(Re,Fe.y);if(Re>0){const Te=ve.of(ie.max),Fe=(ze,Ze,Ye)=>{if(!ze)return;const nt=ze.flatMap((Ot,jt)=>[jt?"L":"M",l(fe.of(Ot.at)),l(we-Ot.y/Re*(we-Te))]);b(ne.next("path",`${Ze} ${C}__mark`),{d:f(nt),fill:"none"}),se.push(Ye)};Fe(Ne,`${C}__capability-within`,"within"),Fe(Ee,`${C}__capability-overall`,"overall")}}const ae=[],be=(le,ye,Ne)=>{if(le===null||!Number.isFinite(le)||le<ee.min||le>ee.max)return;const Ee=l(fe.of(le));b(ne.next("path",ye),{d:f(["M",Ee,l(r.top),"L",Ee,l(r.bottom)]),fill:"none"}),ae.push({x:Ee,text:Ne})};return M&&(be(M.lower,`${C}__spec-limit`,"LSL"),be(M.upper,`${C}__spec-limit`,"USL"),be(M.target,`${C}__spec-target`,"Target")),ne.finish(),re({group:n.groups.labels,anchors:ae.map(({x:le,text:ye})=>({x:le,y:r.top+6,text:ye,anchor:"middle",className:`${C}__control-name`})),size:9,grid:n.grid,minGap:1}),{buckets:de,capability:M,curves:se}}function i(n){const t=n.scheme||_(),{plot:r,bound:a}=n;new Q(n.groups.grid).finish();const T=[];for(const ae of a.series)for(const be of ae.points)D(be.y)&&T.push(be.y);if(T.length<3)return null;const M=[];for(let ae=1;ae<T.length;ae++)M.push(Math.abs(T[ae]-T[ae-1]));const L=M.reduce((ae,be)=>ae+be,0)/M.length,ee=3.267*L,fe=G([...M,0,ee],{zero:!0,nice:!0}),de=I(fe,[r.bottom,r.top]),Me=M.length>1?(r.right-r.left)/(M.length-1):0;Z({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:de,format:P(n.grid,{kind:"linear",step:(fe.max-fe.min)/5})}),pe({group:n.groups.rules,plot:r});const ie=new Q(n.groups.overlay),ve=[],we=(ae,be,le)=>{!Number.isFinite(ae)||ae<fe.min||ae>fe.max||(b(ie.next("path",be),{d:f(["M",l(r.left),l(de.of(ae)),"L",l(r.right),l(de.of(ae))]),fill:"none"}),ve.push({y:de.of(ae),text:le}))};we(L,`${C}__control-centre`,"MR"),we(ee,`${C}__control-limit`,"UCL"),ie.finish();const Ae=new Q(n.groups.marks),ne=[],se=[];for(let ae=0;ae<M.length;ae++){const be=l(r.left+ae*Me),le=l(de.of(M[ae]));ne.push(ae?"L":"M",be,le),se.push({x:be,y:le,index:ae,value:M[ae],violating:M[ae]>ee})}b(Ae.next("path",`${C}__control-line ${C}__mark`),{d:f(ne),fill:"none",stroke:t.series(0)});for(const ae of se)b(Ae.next("circle",`${C}__point ${C}__mark`),{cx:ae.x,cy:ae.y,r:ae.violating?4:2.5,fill:ae.violating?"var(--lattice-danger, #a4262c)":t.series(0),"data-violation":ae.violating?"true":null});return Ae.finish(),re({group:n.groups.labels,anchors:ve.map(({y:ae,text:be})=>({x:r.right-2,y:ae-3,text:be,anchor:"end",className:`${C}__control-name`})),size:9,grid:n.grid,minGap:1}),{points:se,centre:L,upper:ee}}}),Je("packages/modules/charts/treemap.js",function(o,Y){"use strict";Object.defineProperty(o,"squarify",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"layoutTree",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"drawTreemap",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"tileAt",{enumerable:!0,get:function(){return ge}});const Q=Y("packages/modules/charts/frame.js").Pool,$=Y("packages/modules/charts/svg.js"),pe=$.attrs,me=$.round,te=$.setText,H=Y("packages/modules/charts/styles.js").NS,P=Y("packages/modules/charts/scheme.js").resolveScheme,y=Y("packages/modules/charts/labels.js"),B=y.drawAnchoredLabels,D=y.labelText,I=Y("packages/modules/charts/typography.js"),G=I.applySize,z=I.truncateTo,x=34,b=6,f=3,l=3,v=.28;function C(A){return A*1.6}function F(A){return Math.round(A*1.6)}function _(A){return A>1?Math.max(.45,1-(A-1)*.22):1}function J(A,X,ce){if(!A.length||X<=0||ce<=0)return 1/0;const E=Math.max(...A),W=Math.min(...A),h=X*X,s=ce*ce;return Math.max(h*E/s,s/(h*W))}function re(A,X){const ce=[],E=A.filter(S=>S.value>0),W=E.reduce((S,w)=>S+w.value,0);if(!E.length||W<=0||X.width<=0||X.height<=0)return ce;const h=E.slice().sort((S,w)=>w.value-S.value),s=X.width*X.height/W;let g={...X},c=[],d=[];const N=()=>{if(!c.length)return;const S=Math.min(g.width,g.height),m=d.reduce((k,R)=>k+R,0)/S;let u=0;for(let k=0;k<c.length;k++){const R=d[k]/m;ce.push(g.width>=g.height?{item:c[k],x:g.x,y:g.y+u,width:m,height:R}:{item:c[k],x:g.x+u,y:g.y,width:R,height:m}),u+=R}g.width>=g.height?g={x:g.x+m,y:g.y,width:g.width-m,height:g.height}:g={x:g.x,y:g.y+m,width:g.width,height:g.height-m},c=[],d=[]};for(const S of h){const w=S.value*s,m=Math.min(g.width,g.height),u=J(d,m,d.reduce((R,p)=>R+p,0)),k=J([...d,w],m,d.reduce((R,p)=>R+p,0)+w);c.length&&k>u&&N(),c.push(S),d.push(S.value*s)}return N(),ce}function q(A){const{plot:X,tree:ce}=A,E=C(A.fontSize),W=F(A.fontSize),h=[],s=(g,c,d,N,S)=>{const w=g.children.filter(m=>d>0||!A.hidden.has(m.label)).map((m,u)=>({node:m,value:m.total,index:d===0?u:N}));for(const m of re(w,c)){if(d>0&&(m.width<E||m.height<E))continue;const u={...m,depth:d+1,path:[...S,m.item.node.label],children:!1};h.push(u);const k={x:u.x+l,y:u.y+W,width:u.width-l*2,height:u.height-W-l};if(m.item.node.children.length&&k.width>=E&&k.height>=E){const R=h.length;s(m.item.node,k,d+1,u.item.index,u.path),u.children=h.length>R}}};return s(ce.root,{x:X.left,y:X.top,width:X.width,height:X.height},0,0,[]),h}function U(A){const X=A.scheme||P();new Q(A.groups.grid).finish(),new Q(A.groups.axis).finish(),new Q(A.groups.rules).finish(),new Q(A.groups.labels).finish();const ce=q(A),E=A.typography&&A.typography.small||A.fontSize||11,W=new Q(A.groups.marks);for(const s of ce)pe(W.next("rect",`${H}__tile ${H}__mark${s.children?` ${H}__tile--branch`:""}`),{x:me(s.x),y:me(s.y),width:me(Math.max(0,s.width)),height:me(Math.max(0,s.height)),fill:X.series(s.item.index),"fill-opacity":s.children?v:_(s.depth),"data-point":s.item.index,"data-depth":s.depth});W.finish();const h=new Q(A.groups.overlay);for(const s of ce){if(s.width<x||s.height<A.fontSize*1.6)continue;const g=String(s.item.node.label??""),c=z(g,s.width-b*2,E);if(c!==g&&c.length<f)continue;const d=h.next("text",`${H}__tile-label${s.children?` ${H}__tile-label--branch`:""}`);pe(d,{x:me(s.x+b),y:me(s.y+A.fontSize+2),"text-anchor":"start"}),G(d,E),te(d,c)}return h.finish(),A.labels&&A.labels.show&&B({group:A.groups.labels,size:E,minGap:A.labels.minGap,anchors:ce.filter(s=>!s.children&&s.width>=x&&s.height>=A.fontSize*1.6+E).sort((s,g)=>g.width*g.height-s.width*s.height).map(s=>({x:me(s.x+b),y:me(s.y+A.fontSize*2+4),text:D(s.item.value,A.labels,A.grid),anchor:"start",inside:!0,width:s.width-b*2}))}),{tiles:ce}}function ge(A){let X=null;for(const ce of A.tiles)A.x>=ce.x&&A.x<=ce.x+ce.width&&A.y>=ce.y&&A.y<=ce.y+ce.height&&(!X||(ce.depth||1)>(X.depth||1))&&(X=ce);return X}}),Je("packages/modules/charts/annotate-items.js",function(o,Y){"use strict";Object.defineProperty(o,"ANNOTATION_TOOLS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"MEASURE_KINDS",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"ANCHORS",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"ITEM_KINDS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"TEXT_KINDS",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"FIB_LEVELS",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"nextItemId",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"resolveAnnotate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"normaliseAnchor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"normaliseItem",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"serialiseItem",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"itemsFromState",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"fibLevels",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"anchorsFor",{enumerable:!0,get:function(){return b}});const Q=Y("packages/core/src/internal/util.js").warnOnce,$=Object.freeze(["select","trendLine","horizontalLine","verticalLine","channel","fibonacci","arrow","measure-x","measure-y","measure-xy","text","callout","note","delete"]),pe=Object.freeze(["measure-x","measure-y","measure-xy"]),me=Object.freeze({trendLine:2,horizontalLine:1,verticalLine:1,channel:3,fibonacci:2,arrow:2,"measure-x":2,"measure-y":2,"measure-xy":2,text:1,callout:2,note:1}),te=Object.freeze(Object.keys(me)),Z=Object.freeze(["text","callout","note"]),H=Object.freeze([0,23.6,38.2,50,61.8,78.6,100]);let ue=0;function P(){return ue+=1,`ann-${ue}`}function y(f){const l={enabled:!1,tools:[],rail:"none",readOnly:!1,measure:{volume:null}};if(f==null||f===!1)return l;const v=f===!0?{}:f;if(typeof v!="object")return l;const C=Array.isArray(v.tools)?v.tools:null;if(C){const re=C.filter(q=>!$.includes(q));re.length&&Q(`chart:annotate:tools:${re.join(",")}`,`chart annotate.tools names ${re.length} tool(s) this chart does not have: ${re.map(q=>JSON.stringify(q)).join(", ")}. The tools are ${$.join(", ")}.`)}const F=$.filter(re=>C?C.includes(re):!0),_=v.rail==="top"||v.rail==="none"?v.rail:"left",J=v.measure&&typeof v.measure.volume=="string"&&v.measure.volume?v.measure.volume:null;return{enabled:!0,tools:F,rail:_,readOnly:v.readOnly===!0,measure:{volume:J}}}function B(f){return typeof f=="string"?f!=="":typeof f=="number"?Number.isFinite(f):f instanceof Date&&Number.isFinite(f.getTime())}function D(f){if(!f||typeof f!="object")return null;const l=f,v=Number(l.y);return!Number.isFinite(v)||!B(l.x)?null:{x:l.x instanceof Date?new Date(l.x.getTime()):l.x,y:v}}function I(f){if(!f||typeof f!="object")return null;const l=f,v=String(l.kind||"");if(!me[v])return Q(`chart:annotate:kind:${v}`,`a drawn chart annotation of kind ${JSON.stringify(v)} was not restored: the kinds are ${te.join(", ")}.`),null;const C=(Array.isArray(l.anchors)?l.anchors:[]).map(D).filter(Boolean);if(C.length<me[v])return Q(`chart:annotate:anchors:${v}`,`a drawn chart annotation of kind ${JSON.stringify(v)} was not restored: it needs ${me[v]} data anchor(s) and carried ${C.length}.`),null;const F={id:typeof l.id=="string"&&l.id?l.id:P(),kind:v,anchors:C.slice(0,me[v])};return typeof l.text=="string"&&(F.text=l.text),typeof l.colour=="string"&&l.colour&&(F.colour=l.colour),l.readOnly===!0&&(F.readOnly=!0),F}function G(f){const l={id:f.id,kind:f.kind,anchors:f.anchors.map(v=>({x:v.x instanceof Date?v.x.toISOString():v.x,y:v.y}))};return f.text!==void 0&&(l.text=f.text),f.colour!==void 0&&(l.colour=f.colour),f.readOnly&&(l.readOnly=!0),l}function z(f){if(Array.isArray(f))return f.map(I).filter(Boolean);if(f&&typeof f=="object"){const l=f;if(Array.isArray(l.annotations))return l.annotations.map(I).filter(Boolean)}return[]}function x(f,l){const v=l.y-f.y;return H.map(C=>({level:C,y:f.y+v*C/100}))}function b(f,l,v){if(me[f]===1)return[l];if(f==="channel"){const C=(v.y-l.y)/4||Math.abs(v.y||1)/10;return[l,v,{x:v.x,y:v.y+C}]}return[l,v]}}),Je("packages/modules/charts/annotate-measure.js",function(o,Y){"use strict";Object.defineProperty(o,"xSpan",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"naturalDuration",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"measureReadout",{enumerable:!0,get:function(){return Z}});const ke=Y("packages/modules/charts/scale.js"),Q=ke.key,$=ke.toNumber,pe=ke.toTime;function me(H,ue,P,y){if(!Array.isArray(H)||!H.length)return null;if(y){const f=H.findIndex(F=>Q(F)===Q(ue)),l=H.findIndex(F=>Q(F)===Q(P));if(f<0||l<0)return null;const v=Math.min(f,l),C=Math.max(f,l);return{count:C-v+1,from:v,to:C}}const B=$(ue),D=$(P);if(B===null||D===null)return null;const I=Math.min(B,D),G=Math.max(B,D);let z=0,x=-1,b=-1;for(let f=0;f<H.length;f++){const l=$(H[f]);l===null||l<I||l>G||(x<0&&(x=f),b=f,z+=1)}return z?{count:z,from:x,to:b}:null}function te(H){const ue=[["years",31536e6],["months",2592e6],["weeks",6048e5],["days",864e5],["hours",36e5],["minutes",6e4]];for(const[P,y]of ue)if(H>=y)return{unit:P,count:Math.round(H/y)};return{unit:"seconds",count:Math.round(H/1e3)}}function Z(H,ue,P){const[y,B]=ue,D={};if((H==="measure-x"||H==="measure-xy")&&y&&B){const I=me(P.categories,y.x,B.x,!!P.band);if(I){if(D.count=I.count,D.countUnit=P.candles?"bars":"points",P.timeAxis){const G=pe(y.x),z=pe(B.x);G!==null&&z!==null&&(D.elapsedMs=Math.abs(z-G),D.elapsed=te(D.elapsedMs))}if(P.volumeSeries){let G=0,z=!1;for(let x=I.from;x<=I.to;x++){const b=P.volumeSeries.points[x];b&&Number.isFinite(b.y)&&(G+=b.y,z=!0)}z&&(D.volume=G)}}}return(H==="measure-y"||H==="measure-xy")&&y&&B&&(D.change=B.y-y.y,D.changePercent=y.y?(B.y-y.y)/Math.abs(y.y)*100:null),D}}),Je("packages/modules/charts/annotate-rail.js",function(o,Y){"use strict";Object.defineProperty(o,"buildRail",{enumerable:!0,get:function(){return H}});const ke=Y("packages/modules/charts/svg.js"),Q=ke.attrs,$=ke.el,pe=ke.svg,te=Y("packages/modules/charts/styles.js").NS,Z=Object.freeze({select:"M3 2 L12 8 L8 9 L10 13 L8 14 L6 10 L3 12 Z",trendLine:"M2 13 L14 4 M2 13 m-1.5 0 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0 M14 4 m-1.5 0 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0",horizontalLine:"M1 8 L15 8",verticalLine:"M8 1 L8 15",channel:"M2 12 L14 5 M2 15 L14 8",fibonacci:"M1 2 L15 2 M1 6 L15 6 M1 10 L15 10 M1 14 L15 14",arrow:"M2 14 L13 3 M13 3 L8 3 M13 3 L13 8","measure-x":"M2 4 L2 12 M14 4 L14 12 M2 8 L14 8","measure-y":"M4 2 L12 2 M4 14 L12 14 M8 2 L8 14","measure-xy":"M3 3 L13 3 L13 13 L3 13 Z M3 3 L13 13 M13 3 L3 13",text:"M3 3 L13 3 M8 3 L8 13 M6 13 L10 13",callout:"M2 2 L11 2 L11 9 L7 9 L4 13 L4 9 L2 9 Z",note:"M8 14 L8 8 M8 8 m-3 -3 a3 3 0 1 1 6 0 a3 3 0 1 1 -6 0",delete:"M3 4 L13 4 M6 4 L6 2 L10 2 L10 4 M4 4 L5 14 L11 14 L12 4 Z"});function H(ue){const{doc:P,t:y}=ue,B=$(P,"div",`${te}__annotate-rail ${te}__annotate-rail--${ue.place}`);B.setAttribute("role","toolbar"),B.setAttribute("aria-label",y("chart.annotate.rail")),B.setAttribute("aria-orientation",ue.place==="top"?"horizontal":"vertical");const D=new Map;for(const x of ue.tools){const b=$(P,"button",`${te}__annotate-tool`);b.setAttribute("type","button"),b.setAttribute("data-tool",x);const f=y(`chart.annotate.${x}`);b.setAttribute("aria-label",f),b.setAttribute("title",f),x!=="delete"&&b.setAttribute("aria-pressed","false");const l=pe(P,"svg",{class:`${te}__annotate-icon`,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false"});l.appendChild(pe(P,"path",{d:Z[x]||Z.select})),b.appendChild(l),b.setAttribute("tabindex",D.size?"-1":"0"),b.addEventListener("click",()=>ue.onTool(x)),B.appendChild(b),D.set(x,b)}const I=x=>{const b=[...D.values()];if(!b.length)return;const f=Math.max(0,Math.min(b.length-1,x));for(let l=0;l<b.length;l++)b[l].setAttribute("tabindex",l===f?"0":"-1");b[f].focus&&b[f].focus()},G=x=>{const b=[...D.values()],f=b.indexOf(x.target);if(f<0)return;const l={ArrowDown:f+1,ArrowRight:f+1,ArrowUp:f-1,ArrowLeft:f-1,Home:0,End:b.length-1};x.key in l&&(I(l[x.key]),x.preventDefault&&x.preventDefault(),x.stopPropagation&&x.stopPropagation())};return B.addEventListener("keydown",G),{element:B,sync:x=>{for(const[b,f]of D)b!=="delete"&&Q(f,{"aria-pressed":b===x?"true":"false"})}}}}),Je("packages/modules/charts/annotate-layer.js",function(o,Y){"use strict";Object.defineProperty(o,"projector",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"shapeOf",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"ChartAnnotations",{enumerable:!0,get:function(){return k}});const Q=Y("packages/modules/charts/frame.js").Pool,pe=Y("packages/modules/charts/annotations.js").overlayLayer,me=Y("packages/modules/charts/scale.js"),te=me.toNumber,Z=me.toTime,H=Y("packages/modules/charts/annotate-items.js"),ue=H.ANCHORS,P=H.anchorsFor,y=H.fibLevels,B=H.itemsFromState,D=H.MEASURE_KINDS,I=H.nextItemId,G=H.normaliseItem,z=H.serialiseItem,x=H.TEXT_KINDS,f=Y("packages/modules/charts/annotate-measure.js").measureReadout,v=Y("packages/modules/charts/annotate-rail.js").buildRail,C=Y("packages/modules/charts/svg.js"),F=C.attrs,_=C.el,J=C.path,re=C.round,q=C.setText,U=C.SVG_NS,A=Y("packages/modules/charts/styles.js").NS,X=9,ce=6,E=4,W=4;function h(p,e){let i=null,n=1/0;for(const t of p.domain||[]){const r=p.centre(t);if(!Number.isFinite(r))continue;const a=Math.abs(r-e);a<n&&(n=a,i=t)}return i}function s(p){if(p.plot&&Number.isFinite(p.plot.left))return p.plot;const e=p.xScale.range||[0,0],i=p.yScale.range||[0,0],n=p.horizontal?i:e,t=p.horizontal?e:i;return{left:Math.min(n[0],n[1]),right:Math.max(n[0],n[1]),top:Math.min(t[0],t[1]),bottom:Math.max(t[0],t[1])}}function g(p){if(!p)return null;const{xScale:e,yScale:i}=p;if(!e||!i||typeof e.of!="function"||typeof i.of!="function"||typeof i.invert!="function")return null;const n=e.kind==="band";if(!n&&typeof e.invert!="function")return null;const t=!!p.horizontal,r=s(p),a=M=>{if(n)return e.centre(M);const L=e.kind==="time"?Z(M):te(M);return L===null?NaN:e.of(L)},T=M=>n?h(e,M):e.invert(M);return{plot:r,toPixel(M){const L=a(M.x),ee=i.of(M.y);return!Number.isFinite(L)||!Number.isFinite(ee)?null:t?{x:ee,y:L}:{x:L,y:ee}},toData(M,L){const ee=t?L:M,fe=t?M:L,de=T(ee),Me=i.invert(fe);return de==null||!Number.isFinite(Me)?null:{x:de,y:Me}}}}function c(p,e,i){const n=i.x-e.x,t=i.y-e.y,r=n*n+t*t,a=r?Math.max(0,Math.min(1,((p.x-e.x)*n+(p.y-e.y)*t)/r)):0;return Math.hypot(p.x-(e.x+a*n),p.y-(e.y+a*t))}function d(p,e){if(p instanceof Date)return p.toISOString().slice(0,10);if(typeof p=="string")return p;const i=Number(p);return Number.isFinite(i)?Math.abs(i)>1e12?new Date(i).toISOString().slice(0,10):e(i):String(p)}function N(p,e,i,n){const t=p.anchors.map(T=>e.toPixel(T));if(t.some(T=>!T))return null;const{plot:r}=e,a={handles:t,segments:[],fill:null,dots:[],labels:[],title:""};if(p.kind==="trendLine"||p.kind==="arrow")return a.segments.push({from:t[0],to:t[1],arrow:p.kind==="arrow"}),a;if(p.kind==="horizontalLine"||p.kind==="verticalLine"){const T=p.kind==="horizontalLine",M=t[0],L=T?{x:r.left,y:M.y}:{x:M.x,y:r.top},ee=T?{x:r.right,y:M.y}:{x:M.x,y:r.bottom};return a.segments.push({from:L,to:ee,dashed:!0}),a.labels.push({x:ee.x-(T?4:-4),y:ee.y-(T?4:0),text:T?i(p.anchors[0].y):d(p.anchors[0].x,i),anchor:T?"end":"start"}),a}if(p.kind==="channel"){const[T,M,L]=t,ee=M.x-T.x,fe=ee?T.y+(L.x-T.x)/ee*(M.y-T.y):T.y,de=L.y-fe,Me={x:T.x,y:T.y+de},ie={x:M.x,y:M.y+de};return a.segments.push({from:T,to:M}),a.segments.push({from:Me,to:ie}),a.fill=[T,M,ie,Me],a}if(p.kind==="fibonacci"){const T=Math.min(t[0].x,t[1].x),M=Math.max(t[0].x,t[1].x);for(const L of y(p.anchors[0],p.anchors[1])){const ee=e.toPixel({x:p.anchors[0].x,y:L.y});ee&&(a.segments.push({from:{x:T,y:ee.y},to:{x:M,y:ee.y},dashed:L.level!==0}),a.labels.push({x:M+4,y:ee.y-3,text:`${L.level}% · ${i(L.y)}`,anchor:"start"}))}return a}return p.kind==="callout"?(a.dots.push(t[0]),a.segments.push({from:t[0],to:t[1]}),a.labels.push({x:t[1].x+4,y:t[1].y,text:p.text||"",anchor:"start"}),a):D.includes(p.kind)?u(p,t,a,n):p.kind==="note"?(a.dots.push(t[0]),a.title=p.text||"",a):(a.labels.push({x:t[0].x,y:t[0].y,text:p.text||"",anchor:"start"}),a)}function S(p){return!(p>0)&&!(p<0)?null:p>0?"var(--lattice-success, #15803d)":"var(--lattice-danger, #b91c1c)"}function w(p,e,i){if(!p||p.count===void 0)return"";const n=[e(p.countUnit==="bars"?"chart.annotate.measure.bars":"chart.annotate.measure.points",{count:p.count})];return p.elapsed&&n.push(e(`chart.annotate.measure.${p.elapsed.unit}`,{count:p.elapsed.count})),p.volume!==void 0&&n.push(e("chart.annotate.measure.volume",{value:i(p.volume)})),n.join(" | ")}function m(p,e){if(!p||p.change===void 0)return"";const i=p.change>0?"+":"",n=p.changePercent===null||p.changePercent===void 0?"":` (${p.changePercent>0?"+":""}${Math.round(p.changePercent*10)/10}%)`;return`${i}${e(p.change)}${n}`}function u(p,e,i,n){const[t,r]=e,a=Math.min(t.x,r.x),T=Math.max(t.x,r.x),M=Math.min(t.y,r.y),L=Math.max(t.y,r.y),ee=n?f(p.kind,p.anchors,n):{},fe=n&&n.t,de=n&&n.format;if(p.kind==="measure-xy"){i.segments.push({from:{x:a,y:M},to:{x:T,y:M}}),i.segments.push({from:{x:T,y:M},to:{x:T,y:L}}),i.segments.push({from:{x:T,y:L},to:{x:a,y:L}}),i.segments.push({from:{x:a,y:L},to:{x:a,y:M}}),i.fill=[{x:a,y:M},{x:T,y:M},{x:T,y:L},{x:a,y:L}];const ve=fe?w(ee,fe,de):"";ve&&i.labels.push({x:(a+T)/2,y:M-6,text:ve,anchor:"middle"});const we=fe?m(ee,de):"";return we&&i.labels.push({x:T+6,y:(M+L)/2,text:we,anchor:"start",fill:S(ee.change)}),i}if(p.kind==="measure-x"){const ve=(t.y+r.y)/2;i.segments.push({from:{x:a,y:ve},to:{x:T,y:ve}}),i.segments.push({from:{x:a,y:ve-5},to:{x:a,y:ve+5}}),i.segments.push({from:{x:T,y:ve-5},to:{x:T,y:ve+5}});const we=fe?w(ee,fe,de):"";return we&&i.labels.push({x:(a+T)/2,y:ve-6,text:we,anchor:"middle"}),i}const Me=(t.x+r.x)/2;i.segments.push({from:{x:Me,y:M},to:{x:Me,y:L}}),i.segments.push({from:{x:Me-5,y:M},to:{x:Me+5,y:M}}),i.segments.push({from:{x:Me-5,y:L},to:{x:Me+5,y:L}});const ie=fe?m(ee,de):"";return ie&&i.labels.push({x:Me+6,y:(M+L)/2,text:ie,anchor:"start",fill:S(ee.change)}),i}class k{#r;#n;#l=[];#e=null;#i=null;#s=null;#o=null;#c=null;#y=null;#m=null;#z=[];constructor(e,i){this.#r=e,this.#n=i,this.#u(),this.configure(i)}#w(e){if(!D.includes(e.kind))return;const i=this.#O();if(!i)return;const n=f(e.kind,e.anchors,i);return Object.keys(n).length?n:void 0}get tool(){return this.#e}get busy(){return!!this.#s||!!this.#e&&this.#e!=="delete"}configure(e){const i=this.#n;this.#n=e;const n=i&&i.rail===e.rail&&i.tools.join()===e.tools.join()&&i.readOnly===e.readOnly;if(!(this.#o&&n)){if(this.#o&&(this.#o.element.parentNode&&this.#o.element.parentNode.removeChild(this.#o.element),this.#o=null),e.rail==="none"||e.readOnly||!e.tools.length){this.#r.root.classList.remove(`${A}--annotate-left`,`${A}--annotate-top`),this.use(null);return}this.#o=v({doc:this.#r.doc,t:this.#r.t,tools:e.tools,place:e.rail,onTool:t=>this.#t(t)}),this.#r.root.classList.remove(`${A}--annotate-left`,`${A}--annotate-top`),this.#r.root.classList.add(`${A}--annotate-${e.rail}`),this.#r.root.insertBefore(this.#o.element,this.#r.root.firstChild),this.#o.sync(this.#e)}}list(){return this.#l.map(z)}setItems(e){this.#l=B(e),this.#i=null,this.redraw()}use(e){this.#e=e,this.#s=null,this.#o&&this.#o.sync(e),this.redraw()}add(e){if(this.#n.readOnly)return null;const i=G({id:I(),...e});return i?(this.#l.push(i),this.redraw(),this.#r.notify("added",z(i),this.#w(i)),i):null}remove(e){const i=this.#l.findIndex(t=>t.id===e);if(i<0||this.#n.readOnly||this.#l[i].readOnly)return!1;const[n]=this.#l.splice(i,1);return this.#i===e&&(this.#i=null),this.redraw(),this.#r.notify("removed",z(n),this.#w(n)),!0}setText(e,i){const n=this.#l.find(t=>t.id===e);return!n||this.#n.readOnly||n.readOnly?!1:(n.text=String(i),this.redraw(),this.#r.notify("changed",z(n),this.#w(n)),!0)}redraw(){const e=this.#r.groups&&this.#r.groups.overlay;if(!e)return;this.#c=pe(e,`${A}__drawn`);const i=new Q(this.#c),n=g(this.#r.drawn());if(n){const t=this.#r.format(),r=this.#O(t);for(const a of this.#l){const T=N(a,n,t,r);T&&this.#x(i,a,T,a.id===this.#i)}if(this.#s&&this.#s.preview){const a=N(this.#s.preview,n,t,r);a&&this.#x(i,this.#s.preview,a,!1)}}i.finish()}#O(e){const i=this.#r.bound?this.#r.bound():null,n=this.#r.drawn();if(!i||!n||!n.xScale)return null;const t=n.xScale.kind==="band",r=!!n.candles,a=n.xScale.kind==="time"||r,T=this.#n.measure&&this.#n.measure.volume;let M=null;return Array.isArray(i.series)&&(T?M=i.series.find(L=>L.key===T)||null:r&&i.series.length>4&&(M=i.series[4])),{categories:i.categories||[],band:t,timeAxis:a,candles:r,volumeSeries:M,t:this.#r.t,format:e||this.#r.format()}}#x(e,i,n,t){if(n.fill){const r=[];for(const T of n.fill)r.push(r.length?"L":"M",re(T.x),re(T.y));r.push("Z");const a=e.next("path",`${A}__drawn-fill`);F(a,{class:`${A}__drawn-fill`,"data-annotation-id":i.id,d:J(r),fill:i.colour||null})}for(const r of n.segments){const a=e.next("path",`${A}__drawn-line`),T=["M",re(r.from.x),re(r.from.y),"L",re(r.to.x),re(r.to.y)];r.arrow&&T.push(...R(r.from,r.to)),F(a,{class:`${A}__drawn-line`,"data-annotation-id":i.id,"data-annotation-kind":i.kind,"stroke-dasharray":r.dashed?"4 3":null,d:J(T),stroke:i.colour||null})}for(const r of n.dots){const a=e.next("circle",`${A}__drawn-dot`);F(a,{class:`${A}__drawn-dot`,"data-annotation-id":i.id,cx:re(r.x),cy:re(r.y),r:3.5,fill:i.colour||null}),this.#g(a,n.title)}for(const r of n.labels){if(!r.text)continue;const a=e.next("text",`${A}__drawn-label`);F(a,{class:`${A}__drawn-label`,"data-annotation-id":i.id,x:re(r.x),y:re(r.y),"text-anchor":r.anchor,fill:r.fill||i.colour||null}),q(a,r.text)}if(t)for(let r=0;r<n.handles.length;r++){const a=e.next("circle",`${A}__drawn-handle`);F(a,{class:`${A}__drawn-handle`,"data-annotation-id":i.id,"data-anchor":r,cx:re(n.handles[r].x),cy:re(n.handles[r].y),r:W})}}#g(e,i){const n=e.firstChild;if(!i){n&&e.removeChild(n);return}if(n){q(n,i);return}const t=this.#r.doc.createElementNS(U,"title");q(t,i),e.appendChild(t)}#t(e){if(e==="delete"){this.#i&&this.remove(this.#i);return}this.use(this.#e===e?null:e)}#u(){const e=this.#r.plot,i=this.#r.root,n=T=>this.#S(T),t=T=>this.#L(T),r=T=>this.#$(T),a=T=>this.#te(T);e.addEventListener("pointerdown",n),e.addEventListener("pointermove",t),e.addEventListener("pointerup",r),i.addEventListener("keydown",a),this.#z.push(()=>{e.removeEventListener("pointerdown",n),e.removeEventListener("pointermove",t),e.removeEventListener("pointerup",r),i.removeEventListener("keydown",a)})}#A(e){const i=this.#r.plot.getBoundingClientRect?this.#r.plot.getBoundingClientRect():{left:0,top:0};return{x:(e.clientX||0)-(i.left||0),y:(e.clientY||0)-(i.top||0)}}#P(e,i){const n=this.#r.format();for(let t=this.#l.length-1;t>=0;t--){const r=this.#l[t],a=N(r,i,n);if(!a)continue;for(let M=0;M<a.handles.length;M++)if(Math.hypot(e.x-a.handles[M].x,e.y-a.handles[M].y)<=X)return{item:r,anchor:M};if(a.segments.some(M=>c(e,M.from,M.to)<=ce)||a.dots.some(M=>Math.hypot(e.x-M.x,e.y-M.y)<=X))return{item:r,anchor:-1}}return null}#S(e){if(!this.#e)return;const i=g(this.#r.drawn());if(!i)return;const n=this.#A(e),t=i.toData(n.x,n.y);if(t){if(e.preventDefault&&e.preventDefault(),this.#e==="select"){const r=this.#P(n,i);this.#i=r?r.item.id:null,this.#s=r&&!r.item.readOnly?{mode:"move",item:r.item,anchor:r.anchor,from:t,at:n}:null,this.redraw();return}this.#s={mode:"draw",kind:this.#e,from:t,at:n}}}#L(e){if(!this.#s)return;const i=g(this.#r.drawn());if(!i)return;const n=this.#A(e),t=i.toData(n.x,n.y);if(t){if(this.#s.mode==="move"){const{item:r}=this.#s;this.#s.anchor>=0?r.anchors[this.#s.anchor]=t:this.#F(r,this.#s.from,t),this.#s.from=t,this.#s.moved=!0,this.redraw();return}ue[this.#s.kind]!==1&&(this.#s.to=t,this.#s.preview={id:"preview",kind:this.#s.kind,anchors:P(this.#s.kind,this.#s.from,t)},this.redraw())}}#F(e,i,n){const t=n.y-i.y,r=typeof i.x=="number"&&typeof n.x=="number",a=r?n.x-i.x:0;for(const T of e.anchors)T.y+=t,r&&typeof T.x=="number"&&(T.x+=a);r||(e.anchors[0].x=n.x)}#$(e){const i=this.#s;if(!i)return;this.#s=null;const n=g(this.#r.drawn());if(!n){this.redraw();return}const t=this.#A(e),r=n.toData(t.x,t.y)||i.from;if(i.mode==="move"){this.redraw(),i.moved&&this.#r.notify("changed",z(i.item),this.#w(i.item));return}const a=ue[i.kind]===1,T=Math.hypot(t.x-i.at.x,t.y-i.at.y);if(!a&&T<E){this.redraw();return}const M=G({id:I(),kind:i.kind,anchors:P(i.kind,i.from,r)});if(!M){this.redraw();return}this.#l.push(M),this.#i=M.id,this.redraw(),x.includes(M.kind)?this.#ne(M,t):this.#r.notify("added",z(M),this.#w(M))}#te(e){if(e.key==="Escape"){if(this.#y){this.#a(!0);return}if(!this.#s&&!this.#e&&!this.#i)return;this.#s=null,this.#i=null,this.use(null),e.preventDefault&&e.preventDefault();return}(e.key==="Delete"||e.key==="Backspace")&&this.#i&&!this.#y&&this.remove(this.#i)&&e.preventDefault&&e.preventDefault()}#ne(e,i){this.#a(!1);const n=this.#r.doc,t=_(n,"input",`${A}__annotate-input`);t.setAttribute("type","text"),t.setAttribute("aria-label",this.#r.t("chart.annotate.editLabel")),t.value=e.text||"";const r=this.#r.plot.getBoundingClientRect?this.#r.plot.getBoundingClientRect():{left:0,top:0},a=this.#r.root.getBoundingClientRect?this.#r.root.getBoundingClientRect():{left:0,top:0};t.setAttribute("style",`left:${Math.round(i.x+(r.left||0)-(a.left||0))}px;top:${Math.round(i.y+(r.top||0)-(a.top||0))}px`);const T=M=>{M.key==="Enter"?(this.#a(!1),M.preventDefault&&M.preventDefault()):M.key==="Escape"&&(this.#a(!0),M.preventDefault&&M.preventDefault())};t.addEventListener("keydown",T),t.addEventListener("blur",()=>this.#a(!1)),this.#r.root.appendChild(t),this.#y=t,this.#m=e,t.focus&&t.focus()}#a(e){const i=this.#y,n=this.#m;if(!i||!n)return;this.#y=null,this.#m=null,i.parentNode&&i.parentNode.removeChild(i);const t=e?"":String(i.value||""),r=!n.text;if(!t&&r){const a=this.#l.indexOf(n);a>=0&&this.#l.splice(a,1),this.#i===n.id&&(this.#i=null),this.redraw();return}if(t===n.text){this.redraw();return}n.text=t,this.redraw(),this.#r.notify(r?"added":"changed",z(n))}destroy(){for(const e of this.#z)e();this.#z=[],this.#a(!0),this.#o&&this.#o.element.parentNode&&this.#o.element.parentNode.removeChild(this.#o.element),this.#o=null,this.#l=[],this.#c&&this.#c.parentNode&&this.#c.parentNode.removeChild(this.#c),this.#c=null}}function R(p,e){const i=Math.atan2(e.y-p.y,e.x-p.x),n=8,t=.45;return["M",re(e.x),re(e.y),"L",re(e.x-n*Math.cos(i-t)),re(e.y-n*Math.sin(i-t)),"M",re(e.x),re(e.y),"L",re(e.x-n*Math.cos(i+t)),re(e.y-n*Math.sin(i+t))]}}),Je("packages/modules/charts/zoom-view.js",function(o,Y){"use strict";Object.defineProperty(o,"ZOOM_CONTROLS",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"ZOOM_BUTTONS",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"ZOOM_AXES",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"ZOOM_STEP",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"ZOOM_MIN",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"resolveZoom",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"settleView",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"magnify",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"slide",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"sameView",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"bandRange",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"slice",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"viewOfRange",{enumerable:!0,get:function(){return z}});const Q=Y("packages/core/src/internal/util.js").warnOnce,$=Object.freeze(["in","out","left","right","reset"]),pe=Object.freeze(["hover","always","none"]),me=Object.freeze(["x","y","xy"]),te=.25,Z=.01,H=1e-9;function ue(x){const b={enabled:!1,axes:"x",buttons:"none",wheel:!1,pan:!1,step:te,min:Z};if(x==null||x===!1)return b;const f=x===!0?{}:x;if(typeof f!="object")return b;let l="x";f.axes!==void 0&&(me.includes(f.axes)?l=f.axes:Q(`chart:zoom:axes:${String(f.axes)}`,`chart zoom.axes is ${JSON.stringify(f.axes)}, which is not an axis this chart can zoom; it was ignored and x was used. The values are ${me.join(", ")}.`));let v="hover";f.buttons!==void 0&&(pe.includes(f.buttons)?v=f.buttons:Q(`chart:zoom:buttons:${String(f.buttons)}`,`chart zoom.buttons is ${JSON.stringify(f.buttons)}, which is not a way to show the zoom toolbar; it was ignored and hover was used. The values are ${pe.join(", ")}.`));const C=Number.isFinite(f.step)&&f.step>0&&f.step<1?Number(f.step):te,F=Number.isFinite(f.min)&&f.min>0&&f.min<=1?Number(f.min):Z;return{enabled:!0,axes:l,buttons:v,wheel:f.wheel!==!1,pan:f.pan!==!1,step:C,min:F}}function P(x,b){if(!x||!b)return null;const f=b.max-b.min;if(!(f>0))return null;let l=Math.min(x.to-x.from,f);if(!(l>0))return null;if(x.pinned){const F=b.max;return{from:F-l,to:F,pinned:!0}}let v=x.from;v<b.min&&(v=b.min),v+l>b.max&&(v=b.max-l);const C=v+l;return v<=b.min+H&&C>=b.max-H?null:{from:v,to:C,pinned:C>=b.max-H}}function y(x,b,f,l,v){const C=b.max-b.min;if(!(C>0))return null;const F=x?x.from:b.min,_=x?x.to:b.max,J=_-F,re=!!x&&x.pinned,q=Number.isFinite(l)?Math.min(_,Math.max(F,l)):re?_:F+J/2,U=Math.max(C*v,0),ge=Math.min(Math.max(J*f,U),C),A=J>0?(q-F)/J:.5;return P({from:q-ge*A,to:q+ge*(1-A),pinned:re&&q>=_-H},b)}function B(x,b,f){if(!x)return null;const l=(x.to-x.from)*f;return P({from:x.from+l,to:x.to+l,pinned:!1},b)}function D(x,b){return!x||!b?!x&&!b:Math.abs(x.from-b.from)<=H&&Math.abs(x.to-b.to)<=H}function I(x,b){const f=Math.max(0,b-1);if(!x)return{first:0,last:f};const l=Math.max(0,Math.ceil(x.from-H)),v=Math.min(f,Math.floor(x.to+H));return v<l?{first:Math.min(l,f),last:Math.min(l,f)}:{first:l,last:v}}function G(x,b,f){const l=(x.categories||[]).length;if(b<=0&&f>=l-1)return x;const v=[];for(let C=b;C<=f;C++)v.push(C);return{...x,categories:v.map(C=>x.categories[C]),labels:Array.isArray(x.labels)?v.map(C=>x.labels[C]):x.labels,series:(x.series||[]).map(C=>({...C,points:Array.isArray(C.points)?v.map(F=>C.points[F]).filter(F=>F!==void 0):C.points}))}}function z(x,b){if(!Array.isArray(x)||x.length<2||!b)return null;const f=Number(x[0]),l=Number(x[1]);return!Number.isFinite(f)||!Number.isFinite(l)||f===l?null:P({from:Math.min(f,l),to:Math.max(f,l),pinned:!1},b)}}),Je("packages/modules/charts/zoom-toolbar.js",function(o,Y){"use strict";Object.defineProperty(o,"buildZoomToolbar",{enumerable:!0,get:function(){return H}});const ke=Y("packages/modules/charts/svg.js"),Q=ke.attrs,$=ke.el,pe=ke.svg,te=Y("packages/modules/charts/styles.js").NS,Z=Object.freeze({in:"M7 3 a4 4 0 1 0 0 8 a4 4 0 1 0 0 -8 M10 10 L14 14 M5 7 L9 7 M7 5 L7 9",out:"M7 3 a4 4 0 1 0 0 8 a4 4 0 1 0 0 -8 M10 10 L14 14 M5 7 L9 7",left:"M10 3 L5 8 L10 13",right:"M6 3 L11 8 L6 13",reset:"M3 8 a5 5 0 1 0 1.6 -3.7 M2 2 L2 5.5 L5.5 5.5"});function H(ue){const{doc:P,t:y}=ue,B=$(P,"div",`${te}__zoom-bar ${te}__zoom-bar--${ue.buttons}`);B.setAttribute("role","toolbar"),B.setAttribute("aria-label",y("chart.zoom.toolbar")),B.setAttribute("aria-orientation","horizontal");const D=new Map;for(const x of ue.controls){const b=$(P,"button",`${te}__zoom-button`);b.setAttribute("type","button"),b.setAttribute("data-zoom",x);const f=y(`chart.zoom.${x}`);b.setAttribute("aria-label",f),b.setAttribute("title",f);const l=pe(P,"svg",{class:`${te}__zoom-icon`,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false"});l.appendChild(pe(P,"path",{d:Z[x]||Z.reset})),b.appendChild(l),b.setAttribute("tabindex",D.size?"-1":"0"),b.addEventListener("click",()=>ue.onPress(x)),B.appendChild(b),D.set(x,b)}const I=x=>{const b=[...D.values()];if(!b.length)return;const f=Math.max(0,Math.min(b.length-1,x));for(let l=0;l<b.length;l++)b[l].setAttribute("tabindex",l===f?"0":"-1");b[f].focus&&b[f].focus()},G=x=>{const b=[...D.values()],f=b.indexOf(x.target);if(f<0)return;const l={ArrowRight:f+1,ArrowDown:f+1,ArrowLeft:f-1,ArrowUp:f-1,Home:0,End:b.length-1};x.key in l&&(I(l[x.key]),x.preventDefault&&x.preventDefault(),x.stopPropagation&&x.stopPropagation())};return B.addEventListener("keydown",G),{element:B,sync:x=>{for(const[b,f]of D){const l=b==="in"&&x.narrowest||b!=="in"&&!x.zoomed;Q(f,{disabled:l?"disabled":null,"aria-disabled":l?"true":null})}}}}}),Je("packages/modules/charts/topojson.js",function(o,Y){"use strict";Object.defineProperty(o,"transformer",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"arcPoints",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"stitch",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"decodeGeometry",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"feature",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"isTopology",{enumerable:!0,get:function(){return Z}});function ke(H){if(!H)return G=>[G[0],G[1]];const[ue,P]=H.scale,[y,B]=H.translate;let D=0,I=0;return(G,z)=>(z||(D=0,I=0),D+=G[0],I+=G[1],[D*ue+y,I*P+B])}function Q(H,ue){const P=H.arcs[ue],y=ke(H.transform);return P.map((B,D)=>y(B,D))}function $(H,ue){const P=Q(H,ue<0?~ue:ue);return ue<0?P.slice().reverse():P}function pe(H,ue){const P=[];for(const y of ue){const B=$(H,y);for(let D=P.length?1:0;D<B.length;D++)P.push(B[D])}return P}function me(H,ue){if(!ue||!ue.type)return null;const P=ke(H.transform);switch(ue.type){case"Point":return{type:"Point",coordinates:P(ue.coordinates,0)};case"MultiPoint":return{type:"MultiPoint",coordinates:ue.coordinates.map(y=>P(y,0))};case"LineString":return{type:"LineString",coordinates:pe(H,ue.arcs)};case"MultiLineString":return{type:"MultiLineString",coordinates:ue.arcs.map(y=>pe(H,y))};case"Polygon":return{type:"Polygon",coordinates:ue.arcs.map(y=>pe(H,y))};case"MultiPolygon":return{type:"MultiPolygon",coordinates:ue.arcs.map(y=>y.map(B=>pe(H,B)))};case"GeometryCollection":return{type:"GeometryCollection",geometries:(ue.geometries||[]).map(y=>me(H,y)).filter(Boolean)};default:return null}}function te(H,ue){const P=typeof ue=="string"?(H.objects||{})[ue]:ue;if(!P)return{type:"FeatureCollection",features:[]};const y=P.type==="GeometryCollection"?P.geometries||[]:[P],B=[];for(const D of y){const I=me(H,D);I&&B.push({type:"Feature",id:D.id,properties:D.properties||{},geometry:I})}return{type:"FeatureCollection",features:B}}function Z(H){return!!H&&typeof H=="object"&&H.type==="Topology"&&Array.isArray(H.arcs)}}),Je("packages/modules/charts/projection.js",function(o,Y){"use strict";Object.defineProperty(o,"MERCATOR_LIMIT",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"equalEarth",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"robinson",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"mercator",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"equirectangular",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"albers",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"transverseMercator",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"PROJECTIONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"DEFAULT_PROJECTION",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"resolveProjection",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"WRAP_DEGREES",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"splitAntimeridian",{enumerable:!0,get:function(){return G}}),Object.defineProperty(o,"boundsOf",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"fitted",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"graticule",{enumerable:!0,get:function(){return f}});const ke=Math.PI/180,Q=Object.freeze([1.340264,-.081106,893e-6,.003796]),$=Object.freeze([[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]]),pe=85.05113;function me(l,v){const[C,F,_,J]=Q,re=v*ke,q=Math.asin(Math.min(1,Math.max(-1,Math.sqrt(3)/2*Math.sin(re)))),U=q*q,ge=U*U*U,A=Math.sqrt(3)/2*(C+3*F*U+ge*(7*_+9*J*U));return[l*ke*Math.cos(q)/A,q*(C+F*U+ge*(_+J*U))]}function te(l,v){const C=Math.min(Math.abs(v),90),F=Math.min($.length-2,Math.floor(C/5)),_=(C-F*5)/5,[J,re]=$[F],[q,U]=$[F+1],ge=J+(q-J)*_,A=re+(U-re)*_;return[l*ke*ge,(v<0?-A:A)*(Math.PI/2)]}function Z(l,v){const C=Math.min(pe,Math.max(-pe,v))*ke;return[l*ke,Math.log(Math.tan(Math.PI/4+C/2))]}function H(l,v){return[l*ke,v*ke]}function ue(l={}){const[v,C]=l.parallels||[29.5,45.5],[F,_]=l.centre||[-96,37.5],J=v*ke,re=C*ke,q=Math.sin(J),U=Math.abs(J-re)<1e-9?q:(q+Math.sin(re))/2,ge=Math.cos(J)**2+2*U*q,A=Math.sqrt(ge-2*U*Math.sin(_*ke))/U;return(X,ce)=>{const E=U*((X-F)*ke),W=Math.max(0,ge-2*U*Math.sin(ce*ke)),h=Math.sqrt(W)/U;return[h*Math.sin(E),A-h*Math.cos(E)]}}function P(l={}){const[v,C]=l.centre||[-2,49];return(F,_)=>{const J=_*ke,re=(F-v)*ke,q=Math.cos(J)*Math.sin(re),U=Math.min(1-1e-12,Math.max(-1+1e-12,q));return[.5*Math.log((1+U)/(1-U)),Math.atan2(Math.tan(J),Math.cos(re))-C*ke]}}const y=Object.freeze({equalEarth:()=>me,robinson:()=>te,mercator:()=>Z,equirectangular:()=>H,albers:ue,transverseMercator:P,britishNationalGrid:l=>P({centre:[-2,49],...l})}),B="equalEarth";function D(l,v={},C){if(typeof l=="function")return l;const _=y[typeof l=="string"&&l?l:B];return _?_(v):(C&&C(`chart projection ${JSON.stringify(l)} is not one this module draws; using '${B}'. Supported: ${Object.keys(y).join(", ")}.`),y[B]({}))}const I=180;function G(l){if(!Array.isArray(l)||l.length<2)return l&&l.length?[l]:[];const v=[];let C=[l[0]];for(let F=1;F<l.length;F++){const[_,J]=l[F-1],[re,q]=l[F],U=re-_;if(Math.abs(U)>I){const ge=U>0?-180:180,A=U>0?U-360:U+360,X=A===0?0:Math.min(1,Math.max(0,(ge-_)/A)),ce=J+(q-J)*X;C.push([ge,ce]),v.push(C),C=[[-ge,ce],[re,q]]}else C.push([re,q])}return v.push(C),v.filter(F=>F.length>1)}function z(l){let v=1/0,C=1/0,F=-1/0,_=-1/0;for(const J of l||[])for(const[re,q]of J)re<v&&(v=re),re>F&&(F=re),q<C&&(C=q),q>_&&(_=q);return Number.isFinite(v)?{west:v,south:C,east:F,north:_}:null}function x(l){const{project:v,rings:C,plot:F}=l,_=typeof l.padding=="number"?l.padding:4;let J=1/0,re=1/0,q=-1/0,U=-1/0;for(const m of C||[])for(const[u,k]of m){const[R,p]=v(u,k);!Number.isFinite(R)||!Number.isFinite(p)||(R<J&&(J=R),R>q&&(q=R),p<re&&(re=p),p>U&&(U=p))}if(!Number.isFinite(J)||q===J||U===re)return{to:(u,k)=>{const[R,p]=v(u,k);return[F.left+F.width/2+R,F.top+F.height/2-p]},scale:1,width:F.width,height:F.height,left:F.left,top:F.top,aspect:1};const ge=Math.max(1,F.width-_*2),A=Math.max(1,F.height-_*2),X=typeof l.zoom=="number"&&l.zoom>0?l.zoom:1,ce=Math.min(ge/(q-J),A/(U-re))*X,E=(q-J)*ce,W=(U-re)*ce,[h,s]=l.centre?v(l.centre[0],l.centre[1]):[(J+q)/2,(re+U)/2],g=l.centreOffset||[0,0],c=h+(g[0]||0),d=s+(g[1]||0),N=F.left+F.width/2,S=F.top+F.height/2;return{to:(m,u)=>{const[k,R]=v(m,u);return[N+(k-c)*ce,S-(R-d)*ce]},scale:ce,width:E,height:W,left:N-E/2,top:S-W/2,aspect:(q-J)/(U-re)}}const b=2;function f(l={}){const v=l.step&&l.step>0?l.step:30,C=[];for(let F=-180;F<=180;F+=v){const _=[];for(let J=-80;J<=80;J+=b)_.push([F,J]);C.push(_)}for(let F=-60;F<=60;F+=v){const _=[];for(let J=-180;J<=180;J+=b)_.push([J,F]);C.push(_)}return C}}),Je("packages/modules/charts/geocolumn.js",function(o,Y){"use strict";Object.defineProperty(o,"geometryColumnOf",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"bothPlacements",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"rowGeometry",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"geometryPoint",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"geometryPolygons",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"geoAnchorScales",{enumerable:!0,get:function(){return ue}});const ke=Math.PI/180,Q=85.05113,$=Object.freeze({equirectangular:Object.freeze({forward:P=>P*ke,inverse:P=>P/ke}),mercator:Object.freeze({forward:P=>{const y=Math.min(Q,Math.max(-Q,P))*ke;return Math.log(Math.tan(Math.PI/4+y/2))},inverse:P=>(2*Math.atan(Math.exp(P))-Math.PI/2)/ke})});function pe(P,y){const B=y&&y.geometry;if(typeof B!="string"||!B)return null;const D=P&&P.columns&&typeof P.columns.get=="function"?P.columns.get(B):null,I=D&&D.dataType;return{col:B,measure:I&&typeof I.geometry=="function"?I.geometry:null}}function me(P){if(!P||typeof P.geometry!="string"||!P.geometry)return!1;const y=B=>B!=null&&B!=="";return y(P.lon)||y(P.lat)}function te(P,y,B){if(!y||!y.measure)return null;const D=P.rows.value(B,y.col);if(D==null)return null;const I=y.measure(D);if(!I||!I.bbox||!I.centroid)return null;const[G,z,x,b]=I.bbox;return![G,z,x,b].every(Number.isFinite)||G<-180||x>180||z<-90||b>90?null:{geometry:D,info:I}}function Z(P){const y=P.geometry;return y&&y.type==="Point"&&Array.isArray(y.coordinates)?[Number(y.coordinates[0]),Number(y.coordinates[1])]:[Number(P.info.centroid[0]),Number(P.info.centroid[1])]}function H(P,y=[]){if(!P||typeof P!="object")return y;if(P.type==="Polygon")y.push(P.coordinates);else if(P.type==="MultiPolygon")for(const B of P.coordinates)y.push(B);else if(P.type==="GeometryCollection")for(const B of P.geometries||[])H(B,y);return y}function ue(P,y,B){const D=typeof y=="string"?$[y]:null;if(!D||typeof P!="function")return null;const[I,G]=P(0,0),[z]=P(1,0),[,x]=P(0,10),b=z-I,f=(x-G)/D.forward(10);if(![I,G,b,f].every(Number.isFinite)||!b||!f)return null;const l={kind:"linear",domain:{min:(B.left-I)/b,max:(B.right-I)/b},range:[B.left,B.right],of:C=>I+Number(C)*b,invert:C=>(C-I)/b},v={kind:"linear",domain:{min:D.inverse((B.bottom-G)/f),max:D.inverse((B.top-G)/f)},range:[B.bottom,B.top],of:C=>G+D.forward(Number(C))*f,invert:C=>D.inverse((C-G)/f)};return{xScale:l,yScale:v}}}),Je("packages/modules/charts/geo.js",function(o,Y){"use strict";Object.defineProperty(o,"CONTINENTS",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"CONTINENT_NAMES",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"OUTLINES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"COUNTRY_CONTINENT",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"ALPHA3",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"NUMERIC",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"normaliseCode",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"continentOf",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"projection",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"projectedPath",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"ringPath",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"shapesToPaths",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"registerGeoPack",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"geoPack",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"geoPacks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"resolvePack",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"packRegions",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"regionLabelPoint",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"geoRamp",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"basemapStyleOf",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"drawGeomap",{enumerable:!0,get:function(){return Me}}),Object.defineProperty(o,"regionAt",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"markerAt",{enumerable:!0,get:function(){return ve}}),Object.defineProperty(o,"checkGeometrySpec",{enumerable:!0,get:function(){return we}}),Object.defineProperty(o,"GEOMETRY_TYPES_PLACED",{enumerable:!0,get:function(){return Ae}});const Q=Y("packages/modules/charts/frame.js").Pool,pe=Y("packages/modules/charts/matrix.js").colourRamp,te=Y("packages/modules/charts/topojson.js").feature,Z=Y("packages/modules/charts/projection.js"),H=Z.fitted,ue=Z.graticule,P=Z.resolveProjection,y=Z.splitAntimeridian,D=Y("packages/modules/charts/labels.js").drawAnchoredLabels,I=Y("packages/modules/charts/axis.js"),G=I.overhangFor,z=I.setPlotClip,b=Y("packages/core/src/internal/util.js").warnOnce,l=Y("packages/modules/charts/scheme.js").resolveScheme,v=Y("packages/modules/charts/scale.js"),C=v.isNumber,F=v.measureDomain,_=Y("packages/modules/charts/svg.js"),J=_.attrs,re=_.insideRings,q=_.path,U=_.pathRings,ge=_.round,A=_.setText,ce=Y("packages/modules/charts/styles.js").NS,E=Y("packages/modules/charts/geocolumn.js"),W=E.bothPlacements,h=E.geometryColumnOf,s=Object.freeze(["AF","AN","AS","EU","NA","OC","SA"]),g=Object.freeze({AF:"Africa",AN:"Antarctica",AS:"Asia",EU:"Europe",NA:"North America",OC:"Oceania",SA:"South America"}),c=Object.freeze({NA:[[[-168,66],[-156,71],[-130,70],[-115,69],[-100,69],[-85,70],[-75,73],[-64,66],[-78,62],[-79,55],[-65,60],[-56,52],[-60,45],[-67,45],[-70,42],[-74,40],[-76,37],[-81,32],[-80,27],[-81,25],[-84,30],[-90,29],[-94,29],[-97,26],[-97,21],[-91,19],[-88,21],[-87,16],[-83,9],[-79,9],[-85,13],[-92,16],[-96,16],[-105,20],[-110,24],[-114,28],[-117,32],[-122,37],[-124,42],[-124,48],[-130,55],[-140,60],[-150,59],[-160,55],[-165,60],[-168,66]],[[-43,60],[-32,64],[-22,70],[-20,74],[-25,78],[-33,83],[-45,83],[-58,82],[-62,76],[-56,70],[-55,66],[-52,61],[-43,60]]],SA:[[[-81,12],[-72,12],[-62,11],[-52,5],[-50,0],[-44,-2],[-35,-6],[-38,-13],[-39,-18],[-48,-25],[-53,-34],[-57,-38],[-62,-40],[-65,-45],[-68,-52],[-75,-53],[-73,-45],[-73,-37],[-71,-30],[-70,-23],[-71,-18],[-76,-14],[-81,-6],[-80,-2],[-78,1],[-77,8],[-81,12]]],EU:[[[-10,36],[-9,44],[-2,43],[-4,48],[-1,49],[4,52],[7,53],[8,57],[10,58],[5,58],[5,62],[11,64],[15,69],[21,70],[28,71],[32,70],[40,67],[44,68],[50,69],[60,70],[60,60],[58,52],[50,46],[40,44],[36,45],[30,46],[28,41],[26,40],[23,38],[18,40],[13,38],[15,37],[12,44],[8,44],[3,42],[-2,37],[-10,36]],[[-5,50],[1,51],[2,53],[-1,55],[-3,58],[-5,58],[-6,55],[-5,50]],[[-10,52],[-6,52],[-6,55],[-10,55],[-10,52]]],AF:[[[-17,21],[-16,15],[-17,12],[-13,8],[-8,5],[-3,5],[3,6],[8,4],[9,2],[10,-2],[12,-6],[12,-12],[14,-18],[15,-23],[18,-29],[23,-34],[27,-34],[32,-29],[33,-26],[35,-22],[40,-16],[41,-10],[40,-3],[43,0],[51,4],[51,11],[45,12],[43,12],[39,15],[37,21],[34,28],[32,31],[25,32],[20,31],[15,32],[10,37],[3,36],[-2,35],[-6,36],[-10,30],[-13,27],[-17,21]]],AS:[[[26,40],[35,36],[36,31],[43,30],[48,30],[50,27],[56,25],[57,22],[60,25],[62,25],[67,24],[70,21],[73,16],[77,8],[80,6],[80,13],[84,19],[87,21],[92,21],[95,16],[98,10],[104,1],[104,10],[107,11],[109,17],[117,23],[122,30],[122,37],[126,34],[129,35],[130,43],[135,45],[142,45],[143,53],[140,58],[155,59],[162,60],[170,66],[180,68],[170,71],[150,73],[130,74],[110,76],[90,76],[75,73],[70,70],[60,70],[60,60],[58,52],[50,46],[40,44],[36,45],[30,46],[28,41],[26,40]],[[130,31],[132,32],[135,33],[137,34],[140,35],[141,38],[141,41],[142,42],[145,43],[145,45],[141,45],[140,42],[139,40],[137,37],[135,35],[133,34],[131,33],[130,31]]],OC:[[[113,-22],[114,-26],[115,-34],[119,-34],[126,-32],[132,-32],[137,-35],[141,-38],[147,-38],[150,-37],[153,-30],[153,-25],[146,-19],[142,-11],[136,-12],[130,-12],[126,-14],[122,-18],[113,-22]],[[145,-41],[148,-41],[148,-43],[145,-43],[145,-41]],[[173,-35],[178,-38],[174,-41],[172,-43],[167,-46],[170,-44],[173,-35]]],AN:[[[-180,-78],[-150,-76],[-120,-74],[-100,-73],[-80,-72],[-60,-63],[-45,-60],[-58,-64],[-70,-70],[-60,-76],[-30,-77],[0,-70],[20,-70],[40,-68],[60,-67],[80,-66],[100,-66],[120,-66],[140,-66],[160,-78],[170,-84],[180,-85],[-180,-85],[-180,-78]]]}),d=Object.freeze({AD:"EU",AE:"AS",AF:"AS",AG:"NA",AI:"NA",AL:"EU",AM:"AS",AO:"AF",AQ:"AN",AR:"SA",AS:"OC",AT:"EU",AU:"OC",AW:"NA",AX:"EU",AZ:"AS",BA:"EU",BB:"NA",BD:"AS",BE:"EU",BF:"AF",BG:"EU",BH:"AS",BI:"AF",BJ:"AF",BM:"NA",BN:"AS",BO:"SA",BR:"SA",BS:"NA",BT:"AS",BW:"AF",BY:"EU",BZ:"NA",CA:"NA",CD:"AF",CF:"AF",CG:"AF",CH:"EU",CI:"AF",CL:"SA",CM:"AF",CN:"AS",CO:"SA",CR:"NA",CU:"NA",CV:"AF",CY:"AS",CZ:"EU",DE:"EU",DJ:"AF",DK:"EU",DM:"NA",DO:"NA",DZ:"AF",EC:"SA",EE:"EU",EG:"AF",ER:"AF",ES:"EU",ET:"AF",FI:"EU",FJ:"OC",FK:"SA",FM:"OC",FO:"EU",FR:"EU",GA:"AF",GB:"EU",GD:"NA",GE:"AS",GF:"SA",GG:"EU",GH:"AF",GI:"EU",GL:"NA",GM:"AF",GN:"AF",GP:"NA",GQ:"AF",GR:"EU",GT:"NA",GU:"OC",GW:"AF",GY:"SA",HK:"AS",HN:"NA",HR:"EU",HT:"NA",HU:"EU",ID:"AS",IE:"EU",IL:"AS",IM:"EU",IN:"AS",IQ:"AS",IR:"AS",IS:"EU",IT:"EU",JE:"EU",JM:"NA",JO:"AS",JP:"AS",KE:"AF",KG:"AS",KH:"AS",KI:"OC",KM:"AF",KN:"NA",KP:"AS",KR:"AS",KW:"AS",KY:"NA",KZ:"AS",LA:"AS",LB:"AS",LC:"NA",LI:"EU",LK:"AS",LR:"AF",LS:"AF",LT:"EU",LU:"EU",LV:"EU",LY:"AF",MA:"AF",MC:"EU",MD:"EU",ME:"EU",MG:"AF",MH:"OC",MK:"EU",ML:"AF",MM:"AS",MN:"AS",MO:"AS",MQ:"NA",MR:"AF",MT:"EU",MU:"AF",MV:"AS",MW:"AF",MX:"NA",MY:"AS",MZ:"AF",NA:"AF",NC:"OC",NE:"AF",NG:"AF",NI:"NA",NL:"EU",NO:"EU",NP:"AS",NR:"OC",NZ:"OC",OM:"AS",PA:"NA",PE:"SA",PF:"OC",PG:"OC",PH:"AS",PK:"AS",PL:"EU",PM:"NA",PR:"NA",PS:"AS",PT:"EU",PW:"OC",PY:"SA",QA:"AS",RE:"AF",RO:"EU",RS:"EU",RU:"EU",RW:"AF",SA:"AS",SB:"OC",SC:"AF",SD:"AF",SE:"EU",SG:"AS",SI:"EU",SK:"EU",SL:"AF",SM:"EU",SN:"AF",SO:"AF",SR:"SA",SS:"AF",ST:"AF",SV:"NA",SY:"AS",SZ:"AF",TC:"NA",TD:"AF",TG:"AF",TH:"AS",TJ:"AS",TL:"AS",TM:"AS",TN:"AF",TO:"OC",TR:"AS",TT:"NA",TV:"OC",TW:"AS",TZ:"AF",UA:"EU",UG:"AF",US:"NA",UY:"SA",UZ:"AS",VA:"EU",VC:"NA",VE:"SA",VG:"NA",VI:"NA",VN:"AS",VU:"OC",WS:"OC",YE:"AS",YT:"AF",ZA:"AF",ZM:"AF",ZW:"AF"}),N=Object.freeze({AFG:"AF",ALB:"AL",DZA:"DZ",AND:"AD",AGO:"AO",ARG:"AR",ARM:"AM",AUS:"AU",AUT:"AT",AZE:"AZ",BHS:"BS",BHR:"BH",BGD:"BD",BRB:"BB",BLR:"BY",BEL:"BE",BLZ:"BZ",BEN:"BJ",BTN:"BT",BOL:"BO",BIH:"BA",BWA:"BW",BRA:"BR",BRN:"BN",BGR:"BG",BFA:"BF",BDI:"BI",KHM:"KH",CMR:"CM",CAN:"CA",CPV:"CV",CAF:"CF",TCD:"TD",CHL:"CL",CHN:"CN",COL:"CO",COM:"KM",COG:"CG",COD:"CD",CRI:"CR",CIV:"CI",HRV:"HR",CUB:"CU",CYP:"CY",CZE:"CZ",DNK:"DK",DJI:"DJ",DMA:"DM",DOM:"DO",ECU:"EC",EGY:"EG",SLV:"SV",GNQ:"GQ",ERI:"ER",EST:"EE",ETH:"ET",FJI:"FJ",FIN:"FI",FRA:"FR",GAB:"GA",GMB:"GM",GEO:"GE",DEU:"DE",GHA:"GH",GRC:"GR",GRL:"GL",GTM:"GT",GIN:"GN",GNB:"GW",GUY:"GY",HTI:"HT",HND:"HN",HKG:"HK",HUN:"HU",ISL:"IS",IND:"IN",IDN:"ID",IRN:"IR",IRQ:"IQ",IRL:"IE",ISR:"IL",ITA:"IT",JAM:"JM",JPN:"JP",JOR:"JO",KAZ:"KZ",KEN:"KE",KIR:"KI",PRK:"KP",KOR:"KR",KWT:"KW",KGZ:"KG",LAO:"LA",LVA:"LV",LBN:"LB",LSO:"LS",LBR:"LR",LBY:"LY",LIE:"LI",LTU:"LT",LUX:"LU",MKD:"MK",MDG:"MG",MWI:"MW",MYS:"MY",MDV:"MV",MLI:"ML",MLT:"MT",MHL:"MH",MRT:"MR",MUS:"MU",MEX:"MX",FSM:"FM",MDA:"MD",MCO:"MC",MNG:"MN",MNE:"ME",MAR:"MA",MOZ:"MZ",MMR:"MM",NAM:"NA",NRU:"NR",NPL:"NP",NLD:"NL",NZL:"NZ",NIC:"NI",NER:"NE",NGA:"NG",NOR:"NO",OMN:"OM",PAK:"PK",PLW:"PW",PSE:"PS",PAN:"PA",PNG:"PG",PRY:"PY",PER:"PE",PHL:"PH",POL:"PL",PRT:"PT",PRI:"PR",QAT:"QA",ROU:"RO",RUS:"RU",RWA:"RW",KNA:"KN",LCA:"LC",VCT:"VC",WSM:"WS",SMR:"SM",STP:"ST",SAU:"SA",SEN:"SN",SRB:"RS",SYC:"SC",SLE:"SL",SGP:"SG",SVK:"SK",SVN:"SI",SLB:"SB",SOM:"SO",ZAF:"ZA",SSD:"SS",ESP:"ES",LKA:"LK",SDN:"SD",SUR:"SR",SWZ:"SZ",SWE:"SE",CHE:"CH",SYR:"SY",TWN:"TW",TJK:"TJ",TZA:"TZ",THA:"TH",TLS:"TL",TGO:"TG",TON:"TO",TTO:"TT",TUN:"TN",TUR:"TR",TKM:"TM",TUV:"TV",UGA:"UG",UKR:"UA",ARE:"AE",GBR:"GB",USA:"US",URY:"UY",UZB:"UZ",VUT:"VU",VEN:"VE",VNM:"VN",YEM:"YE",ZMB:"ZM",ZWE:"ZW"}),S=Object.freeze({4:"AF",8:"AL",12:"DZ",20:"AD",24:"AO",32:"AR",36:"AU",40:"AT",44:"BS",48:"BH",50:"BD",51:"AM",52:"BB",56:"BE",64:"BT",68:"BO",70:"BA",72:"BW",76:"BR",84:"BZ",90:"SB",96:"BN",100:"BG",104:"MM",108:"BI",112:"BY",116:"KH",120:"CM",124:"CA",132:"CV",140:"CF",144:"LK",148:"TD",152:"CL",156:"CN",170:"CO",174:"KM",178:"CG",180:"CD",188:"CR",191:"HR",192:"CU",196:"CY",203:"CZ",204:"BJ",208:"DK",212:"DM",214:"DO",218:"EC",222:"SV",226:"GQ",231:"ET",232:"ER",233:"EE",246:"FI",250:"FR",262:"DJ",266:"GA",268:"GE",270:"GM",276:"DE",288:"GH",300:"GR",304:"GL",320:"GT",324:"GN",328:"GY",332:"HT",340:"HN",344:"HK",348:"HU",352:"IS",356:"IN",360:"ID",364:"IR",368:"IQ",372:"IE",376:"IL",380:"IT",384:"CI",388:"JM",392:"JP",398:"KZ",400:"JO",404:"KE",408:"KP",410:"KR",414:"KW",417:"KG",418:"LA",422:"LB",426:"LS",428:"LV",430:"LR",434:"LY",438:"LI",440:"LT",442:"LU",450:"MG",454:"MW",458:"MY",462:"MV",466:"ML",470:"MT",478:"MR",480:"MU",484:"MX",496:"MN",498:"MD",499:"ME",504:"MA",508:"MZ",512:"OM",516:"NA",520:"NR",524:"NP",528:"NL",548:"VU",554:"NZ",558:"NI",562:"NE",566:"NG",578:"NO",586:"PK",585:"PW",591:"PA",598:"PG",600:"PY",604:"PE",608:"PH",616:"PL",620:"PT",624:"GW",626:"TL",630:"PR",634:"QA",642:"RO",643:"RU",646:"RW",682:"SA",686:"SN",688:"RS",690:"SC",694:"SL",702:"SG",703:"SK",704:"VN",705:"SI",706:"SO",710:"ZA",716:"ZW",724:"ES",728:"SS",729:"SD",740:"SR",748:"SZ",752:"SE",756:"CH",760:"SY",762:"TJ",764:"TH",768:"TG",776:"TO",780:"TT",784:"AE",788:"TN",792:"TR",795:"TM",798:"TV",800:"UG",804:"UA",807:"MK",818:"EG",826:"GB",834:"TZ",840:"US",858:"UY",860:"UZ",862:"VE",882:"WS",887:"YE",894:"ZM"});function w(ne){if(ne==null||ne==="")return null;const se=String(ne).trim().toUpperCase();return se?/^\d+$/.test(se)?S[String(Number(se))]||null:se.length===2?se:se.length===3&&N[se]||null:null}function m(ne){return ne?s.includes(ne)&&!(ne in d)||s.includes(ne)?ne:d[ne]||null:null}function u(ne,se={}){const ae=se.antarctic?-90:-58,be=84,le=be-ae,ye=Math.min(ne.width/360,ne.height/le),Ne=360*ye,Ee=le*ye,Re=ne.left+(ne.width-Ne)/2,Te=ne.top+(ne.height-Ee)/2;return(Fe,ze)=>[Re+(Fe+180)*ye,Te+(be-ze)*ye]}function k(ne,se){const ae=[];for(let be=0;be<ne.length;be++){const[le,ye]=se(ne[be][0],ne[be][1]);if(!Number.isFinite(le)||!Number.isFinite(ye))return ae.length>4?q([...ae,"Z"]):"";ae.push(be?"L":"M",ge(le),ge(ye))}return ae.length?q([...ae,"Z"]):""}function R(ne,se){const ae=Array.isArray(ne)&&Array.isArray(ne[0])&&Array.isArray(ne[0][0])?ne:[ne],be=[];for(const le of ae)if(!(!Array.isArray(le)||!le.length)){for(let ye=0;ye<le.length;ye++){const[Ne,Ee]=se(le[ye][0],le[ye][1]);be.push(ye?"L":"M",ge(Ne),ge(Ee))}be.push("Z")}return q(be)}function p(ne){const se=new Map,ae=ne.shapes;if(!ae)return se;const be=u(ne.plot),le=ne.codeProperty||"iso_a2";if(!Array.isArray(ae)&&!ae.type){for(const Ne of Object.keys(ae)){const Ee=w(Ne);Ee&&typeof ae[Ne]=="string"&&se.set(Ee,ae[Ne])}return se}const ye=ae.type==="FeatureCollection"?ae.features||[]:[ae];for(const Ne of ye){const Ee=Ne.properties||{},Re=w(Ee[le]??Ee.iso??Ee.code),Te=Ne.geometry;if(!Re||!Te)continue;const Fe=Te.type==="MultiPolygon"?Te.coordinates:Te.type==="Polygon"?[Te.coordinates]:[],ze=[];for(const Ze of Fe)for(const Ye of Ze)ze.push(R(Ye,be));ze.length&&se.set(Re,ze.join(" "))}return se}const e=new Map;function i(ne){return ne&&typeof ne=="object"&&typeof ne.id=="string"&&e.set(ne.id,ne),ne}function n(ne){return e.get(ne)||null}function t(){return[...e.keys()]}function r(ne,se){if(!ne||typeof ne!="object")return null;const ae=ne;let be=ne;if(typeof ae.pack=="string"){if(be=e.get(ae.pack),!be)return b(`chart:geomap:pack:${ae.pack}`,`geometry pack ${JSON.stringify(ae.pack)} has not been loaded, so the map fell back to the schematic continents. Import the pack module and pass it as \`shapes\` — import { pack } from '@toclocoinc/lattice-grid/modules/geo-${ae.pack}'; createChart({ …, shapes: pack })${e.size?`. Loaded: ${[...e.keys()].join(", ")}.`:"."}`),null}else ae.pack&&typeof ae.pack=="object"&&(be=ae.pack);if(!be||typeof be!="object")return null;const le=be;if(le.topology)return{pack:le,topology:le.topology};if(le.layers){const ye=typeof ae.layer=="string"&&ae.layer||typeof se=="string"&&se||le.defaultLayer||Object.keys(le.layers)[0],Ne=le.layers[ye];if(Ne&&Ne.topology)return{pack:le,topology:Ne.topology,layer:ye}}return null}const a=new WeakMap;function T(ne){const se=a.get(ne);if(se)return se;const ae=[];for(const be of te(ne,"regions").features){const le=[],ye=be.geometry,Ne=ye.type==="MultiPolygon"?ye.coordinates:ye.type==="Polygon"?[ye.coordinates]:[];for(const Ee of Ne)for(const Re of Ee)for(const Te of y(Re))le.push(Te);le.length&&ae.push({code:String(be.id===void 0||be.id===null?"":be.id),label:be.properties&&be.properties.name||String(be.id||""),properties:be.properties||{},rings:le})}return a.set(ne,ae),ae}function M(ne,se){const ae=[];for(let be=0;be<ne.length;be++){const[le,ye]=se(ne[be][0],ne[be][1]);!Number.isFinite(le)||!Number.isFinite(ye)||ae.push(ae.length?"L":"M",ge(le),ge(ye))}return ae.length>2?q(ae):""}function L(ne){let se=null,ae=-1;for(const ye of ne){if(!ye||ye.length<3)continue;let Ne=0,Ee=0,Re=0;for(let Fe=0;Fe<ye.length;Fe++){const[ze,Ze]=ye[Fe],[Ye,nt]=ye[(Fe+1)%ye.length],Ot=ze*nt-Ye*Ze;Ne+=Ot,Ee+=(ze+Ye)*Ot,Re+=(Ze+nt)*Ot}Ne/=2;const Te=Math.abs(Ne);Te<1e-9||Te>ae&&(ae=Te,se=[Ee/(6*Ne),Re/(6*Ne)])}if(se)return se;const be=ne.flat();if(!be.length)return null;const le=be.reduce((ye,[Ne,Ee])=>[ye[0]+Ne,ye[1]+Ee],[0,0]);return[le[0]/be.length,le[1]/be.length]}function ee(ne,se,ae){const be=pe(ne,se,ae);if(se)return be;const le=ne.max-ne.min||1,ye=1/6;return Ne=>be(ne.min+(ye+(Ne-ne.min)/le*(1-ye))*le)}function fe(ne,se){return(ae,be)=>{const[le,ye]=ne(ae,be);return!Number.isFinite(le)||!Number.isFinite(ye)?[le,ye]:[Math.min(Math.max(le,se.left),se.right),Math.min(Math.max(ye,se.top),se.bottom)]}}function de(ne){const se=ne&&ne.fill||"var(--lattice-chart-basemap-fill, #c3cfd6)",ae=ne&&ne.stroke||"var(--lattice-chart-basemap-stroke, #456374)",be=ne&&ne.strokeWidth!=null?ne.strokeWidth:"var(--lattice-chart-basemap-stroke-width, 0.75)";return{fill:se,style:`stroke:${ae};stroke-width:${be}`}}function Me(ne){const se=ne.scheme||l(),{plot:ae,bound:be}=ne;new Q(ne.groups.grid).finish(),new Q(ne.groups.axis).finish(),new Q(ne.groups.rules).finish(),new Q(ne.groups.labels).finish();const le=r(ne.shapes,ne.layer),ye=le?new Map:p({shapes:ne.shapes,plot:ae,codeProperty:ne.codeProperty}),Ne=ye.size>0||!!le,Ee=le?T(le.topology):null,Re=new Map;if(Ee)for(const tt of Ee){Re.set(tt.code,tt);const dt=tt.properties||{};dt.alpha3&&Re.set(String(dt.alpha3).toUpperCase(),tt),dt.numeric&&Re.set(String(Number(dt.numeric)),tt),dt.fips&&Re.set(String(dt.fips),tt)}const Te=new Map,Fe=[],ze=be.series[0];if(ze)for(let tt=0;tt<ze.points.length;tt++){const dt=ze.points[tt];if(!C(dt.y))continue;const ut=be.categories[tt],$t=w(ut),It=Ee?[$t,ut==null?"":String(ut).trim().toUpperCase()].map(V=>V?Re.get(V):null).find(Boolean):null,Et=It?It.code:null,zt=Ee?Et:Ne?$t:m($t);if(!zt||Ne&&!Ee&&!ye.has(zt)){be.labels[tt]&&Fe.push(be.labels[tt]);continue}const Jt=Te.get(zt)||{value:0,labels:[]};Jt.value+=dt.y,Jt.labels.push(be.labels[tt]),Te.set(zt,Jt)}const Ze=Te.has("AN")||Te.has("AQ"),Ye=u(ae,{antarctic:Ze});let nt=null;if(Ee){const tt=Ze?Ee:Ee.filter(ut=>ut.code!=="AQ"&&ut.code!=="AN"),dt=P(ne.projection||le.pack.projection,{...le.pack.projectionOptions||{},...ne.projectionOptions||{}},ut=>b(`chart:geomap:projection:${String(ne.projection)}`,ut));nt={project:dt,...H({project:dt,rings:tt.flatMap(ut=>ut.rings),plot:ae,zoom:ne.zoom,centre:ne.centre,centreOffset:ne.centreOffset}),drawn:tt}}const Ot=F([...Te.values()].map(tt=>tt.value),{zero:!ne.diverging,nice:!1}),jt=ee(Ot,!!ne.diverging,se),Bt=G("geomap");z(ne.groups,ae,Bt);const Ht={left:ae.left-Bt,top:ae.top-Bt,right:ae.right+Bt,bottom:ae.bottom+Bt},xt=nt?fe(nt.to,Ht):null,At=new Q(ne.groups.marks);if(!!ne.graticule&&!!nt){const tt=ne.graticule&&typeof ne.graticule=="object"&&ne.graticule.step||30;for(const dt of ue({step:tt}))for(const ut of y(dt)){const $t=M(ut,xt);if(!$t)continue;const It=At.next("path",`${ce}__graticule`);J(It,{d:$t,class:`${ce}__graticule`})}}const qt=[],Yt=nt?nt.drawn.map(tt=>tt.code):Ne?[...ye.keys()]:s.filter(tt=>tt!=="AN"||Ze),Lt=nt?new Map(nt.drawn.map(tt=>[tt.code,tt])):null,Wt=nt?de(ne.basemap):null;for(const tt of Yt){const dt=nt?Lt.get(tt).rings.map(It=>k(It,xt)).filter(Boolean).join(" "):Ne?ye.get(tt):R(c[tt],Ye),ut=Te.get(tt),$t=At.next("path",`${ce}__region ${ce}__mark`);J($t,{d:dt,fill:ut?jt(ut.value):Wt?Wt.fill:"var(--lattice-chart-empty, #eceff1)","data-code":tt,class:`${ce}__region ${ce}__mark`,style:Wt?Wt.style:null}),qt.push({code:tt,value:ut?ut.value:null,label:!Ne&&g[tt]||Lt&&Lt.get(tt).label||ut&&ut.labels[0]||tt,element:$t,d:dt})}At.finish();const en=new Q(ne.groups.overlay);if(Fe.length){const tt=en.next("text",`${ce}__geo-note`);J(tt,{x:ge(ae.left),y:ge(ae.bottom),"text-anchor":"start"}),A(tt,ne.grid.messages.t("chart.geoUnmatched",{count:Fe.length}))}en.finish();let nn=0;if(ne.labels&&ne.labels.show&&nt){const tt=qt.filter(dt=>dt.value!==null).sort((dt,ut)=>ut.value-dt.value).map(dt=>{const ut=Lt.get(dt.code).rings.map(It=>It.map(([Et,zt])=>nt.to(Et,zt))),$t=L(ut);return $t&&{x:$t[0],y:$t[1],text:dt.label}}).filter(Boolean);nn=D({group:ne.groups.labels,size:ne.fontSize,minGap:ne.labels.minGap,anchors:tt,plot:ae})}return{regions:qt,ramp:jt,unmatched:Fe,useCountries:Ne,packed:!!nt,scale:nt?nt.scale:null,attribution:le&&le.pack.attribution||"",aspect:nt?nt.aspect:null,labelsDrawn:nn}}function ie(ne){for(const se of ne.regions||[]){if(!se.rings){se.rings=U(se.d);let be=1/0,le=1/0,ye=-1/0,Ne=-1/0;for(const Ee of se.rings)for(const[Re,Te]of Ee)Re<be&&(be=Re),Re>ye&&(ye=Re),Te<le&&(le=Te),Te>Ne&&(Ne=Te);se.box={minX:be,minY:le,maxX:ye,maxY:Ne}}const ae=se.box;if(!(!ae||ne.x<ae.minX||ne.x>ae.maxX||ne.y<ae.minY||ne.y>ae.maxY)&&re(se.rings,ne.x,ne.y))return se}return null}function ve(ne){let ae=null,be=1/0;for(const le of ne.markers||[]){if(!le)continue;const ye=(le.r||0)+3,Ne=ne.x-le.x,Ee=ne.y-le.y,Re=Math.sqrt(Ne*Ne+Ee*Ee);Re>ye||Re>=be||(be=Re,ae=le)}return ae}function we(ne){const{grid:se,spec:ae,type:be,id:le}=ne;if(!ae||!Ae.has(be))return;if(W(ae)){b(`chart:${le}:geometry:both`,`a "${be}" chart was given both "geometry" and "lon"/"lat", and a row is placed by one or the other, so nothing was drawn rather than one being picked for you. Keep "geometry" for a geometry column, or "lon" and "lat" for two coordinate columns.`);return}const ye=h(se,ae);if(!ye){be==="choropleth"&&b(`chart:${le}:geometry:missing`,`a "choropleth" chart draws each row's own shape from a geometry column and was given none, so it has nothing to draw. Name the column: geometry: '<column>'.`);return}ye.measure||b(`chart:${le}:geometry:type:${ye.col}`,`a "${be}" chart reads "geometry" from column ${JSON.stringify(ye.col)}, which is not a geometry column, so no row could be placed. Import '@toclocoinc/lattice-grid/modules/geometry' and declare the column type: 'geometry'.`)}const Ae=new Set(["markermap","bubblemap","choropleth"])}),Je("packages/modules/charts/network.js",function(o,Y){"use strict";Object.defineProperty(o,"ITERATIONS",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"LINK_GAP",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"ICON_RADIUS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"sequence",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"layoutNetwork",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"glyphFor",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"glyphTransform",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"offsetParallel",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"drawNetwork",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"emphasiseNetwork",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"nodeAt",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"linkAt",{enumerable:!0,get:function(){return h}});const Q=Y("packages/modules/charts/frame.js").Pool,pe=Y("packages/modules/charts/scheme.js").resolveScheme,me=Y("packages/modules/charts/svg.js"),te=me.attrs,Z=me.path,H=me.round,ue=me.setText,y=Y("packages/modules/charts/styles.js").NS,B=Y("packages/modules/charts/typography.js"),D=B.applySize,I=B.truncateTo,G=Y("packages/modules/charts/rulecolour.js"),z=G.ruleColour,x=G.ruleLegend,f=Y("packages/core/src/internal/util.js").warnOnce,l=220,v=2400,C=.006,F=.015,_=4,J=10;function re(s){let g=s>>>0||1;return()=>(g^=g<<13,g>>>=0,g^=g>>17,g^=g<<5,g>>>=0,g/4294967296)}function q(s){const{nodes:g,links:c,plot:d}=s;if(!g.length)return g;const N=re(g.length*2654435761),S=d.left+d.width/2,w=d.top+d.height/2,m=Math.min(d.width,d.height)/3;for(const k of g){const R=N()*Math.PI*2,p=m*(.35+N()*.65);k.x=S+Math.cos(R)*p,k.y=w+Math.sin(R)*p,k.vx=0,k.vy=0}for(const k of g)k.pinned=Number.isFinite(k.fx)&&Number.isFinite(k.fy),k.pinned&&(k.x=d.left+Math.max(0,Math.min(1,k.fx))*d.width,k.y=d.top+Math.max(0,Math.min(1,k.fy))*d.height);const u=s.iterations||l;for(let k=0;k<u;k++){const R=1-k/u;for(let p=0;p<g.length;p++){const e=g[p];for(let i=p+1;i<g.length;i++){const n=g[i];let t=e.x-n.x,r=e.y-n.y,a=Math.sqrt(t*t+r*r);a<.01&&(t=p-i||1,r=1,a=Math.sqrt(t*t+r*r));const T=v/(a*a),M=t/a*T,L=r/a*T;e.vx+=M,e.vy+=L,n.vx-=M,n.vy-=L}}for(const p of c){const e=p.source,i=p.target;if(e===i)continue;const n=i.x-e.x,t=i.y-e.y,r=C*(p.weight||1);e.vx+=n*r,e.vy+=t*r,i.vx-=n*r,i.vy-=t*r}for(const p of g){if(p.pinned){p.vx=0,p.vy=0;continue}p.vx+=(S-p.x)*F,p.vy+=(w-p.y)*F,p.x+=p.vx*R*.08,p.y+=p.vy*R*.08,p.vx*=.82,p.vy*=.82,p.x=Math.max(d.left+8,Math.min(d.right-8,p.x)),p.y=Math.max(d.top+8,Math.min(d.bottom-8,p.y))}}return g}function U(s,g){if(!g)return null;const c=s&&s.icons;if(!c||typeof c.get!="function")return f(`chart:icons:${g}`,`A network node asked for the icon '${g}', but this grid publishes no icon registry — a headless grid has no sprites. The node drew as a plain disc.`),null;const d=c.get(g);return d||(f(`chart:icon:${g}`,`Unknown icon '${g}' on a network node; drew a plain disc instead. Register it with registerIcon or config.icons, or name a built-in.`),null)}function ge(s,g){const c=String(s.viewBox||"0 0 16 16").trim().split(/[\s,]+/).map(Number),[d,N,S,w]=c.length===4&&c.every(Number.isFinite)?c:[0,0,16,16],m=Math.max(S||16,w||16),u=g.size/m,k=g.x-S*u/2,R=g.y-w*u/2;return`translate(${H(k-d*u)} ${H(R-N*u)}) scale(${H(u)})`}function A(s){const g=new Map;for(const c of s){const d=c.pair||`${c.source.key}\0${c.target.key}`;g.has(d)||g.set(d,[]),g.get(d).push(c)}for(const c of g.values()){const d=c.length;for(let N=0;N<d;N++){const S=c[N],w=S.source,m=S.target,u=m.x-w.x,k=m.y-w.y,R=Math.sqrt(u*u+k*k)||1,p=R?-k/R:0,e=R?u/R:1,i=(N-(d-1)/2)*_;S.offset=i,S.bundled=d>1,S.line={x1:w.x+p*i,y1:w.y+e*i,x2:m.x+p*i,y2:m.y+e*i}}}}function X(s){const g=s.scheme||pe(),{plot:c,bound:d}=s;for(const a of["grid","axis","rules","labels"])new Q(s.groups[a]).finish();const N=d.nodes,S=d.links.map(a=>({...a,weight:a.value}));if(!N.length)return{nodes:[],links:[],legend:[]};const w=S.reduce((a,T)=>Math.max(a,T.value),0)||1;for(const a of S)a.weight=a.value/w;q({nodes:N,links:S,plot:c,iterations:s.iterations}),A(S);const m=d.measure&&d.measure.col||null,u=new Set;for(const a of S)a.colour=z({grid:s.grid,col:m,value:a.value}),a.colour&&u.add(a.colour);const k=N.reduce((a,T)=>Math.max(a,T.in+T.out),0)||1,R=new Q(s.groups.marks),p=Number.isFinite(s.linkWidth)&&s.linkWidth>0?Number(s.linkWidth):null;for(const a of S){a.drawnWidth=p===null?.5+a.weight*3:p;const T=R.next("path",`${y}__edge ${y}__mark`);te(T,{d:Z(["M",H(a.line.x1),H(a.line.y1),"L",H(a.line.x2),H(a.line.y2)]),style:a.colour?`stroke:${a.colour};stroke-opacity:1`:null,"stroke-width":H(a.drawnWidth),fill:"none"}),a.el=T}for(const a of N){const T=(a.in+a.out)/k,M=a.icon||s.icon||null;a.glyph=U(s.grid,M),a.r=4+Math.sqrt(T)*12,a.glyph&&(a.r=Math.max(a.r,J));const L=R.next("circle",`${y}__node ${y}__mark`);te(L,{cx:H(a.x),cy:H(a.y),r:H(a.r),fill:g.series(a.index),"data-node":a.key}),a.el=L}R.finish();const e=new Q(s.groups.overlay),i=[];for(const a of N){if(!a.glyph){a.glyphEls=[];continue}const T=a.glyph.paint==="stroke",M=ge(a.glyph,{x:a.x,y:a.y,size:a.r*1.3});a.glyphEls=a.glyph.paths.map(L=>{const ee=e.next("path",`${y}__node-icon${T?` ${y}__node-icon--stroke`:""}`);return te(ee,{d:L,transform:M}),ee}),i.push(...a.glyphEls)}const n=s.typography&&s.typography.small||s.fontSize,t=N.filter(a=>a.declared),r=N.filter(a=>!a.declared).sort((a,T)=>T.in+T.out-(a.in+a.out)).slice(0,12);for(const a of[...t,...r]){const T=e.next("text",`${y}__flow-label`);D(T,n),te(T,{x:H(a.x),y:H(a.y+a.r+n),"text-anchor":"middle"}),ue(T,I(a.label,90,n)),a.labelEl=T}return e.finish(),{nodes:N,links:S,glyphs:i,legend:x({grid:s.grid,col:m,colours:u})}}function ce(s){const g=s.drawn||{},c=s.keys||new Set,d=c.size>0;let N=0;const S=new Set;for(const w of g.links||[]){const m=d&&(w.rowKeys||[]).some(u=>c.has(u));m&&(N++,S.add(w.source),S.add(w.target)),E(w.el,d&&!m)}for(const w of g.nodes||[]){const m=S.has(w);m&&N++,E(w.el,d&&!m);for(const u of w.glyphEls||[])E(u,d&&!m)}return N}function E(s,g){!s||!s.setAttribute||(g?s.setAttribute("data-dim","true"):s.removeAttribute("data-dim"))}function W(s){const g=typeof s.slack=="number"?s.slack:2;let c=null,d=1/0;for(const N of s.nodes||[]){if(typeof N.x!="number"||typeof N.y!="number")continue;const S=s.x-N.x,w=s.y-N.y,m=Math.sqrt(S*S+w*w);m<=(N.r||0)+g&&m<d&&(d=m,c=N)}return c}function h(s){let g=null,c=1/0;for(const d of s.links||[]){const N=d.line,S=N?{x:N.x1,y:N.y1}:d.source,w=N?{x:N.x2,y:N.y2}:d.target;if(!S||!w||typeof S.x!="number"||typeof w.x!="number")continue;const m=w.x-S.x,u=w.y-S.y,k=m*m+u*u,R=k?Math.max(0,Math.min(1,((s.x-S.x)*m+(s.y-S.y)*u)/k)):0,p=s.x-(S.x+R*m),e=s.y-(S.y+R*u),i=Math.sqrt(p*p+e*e),n=Number.isFinite(d.drawnWidth)?d.drawnWidth:.5+(d.weight||0)*3,t=d.bundled?Math.min(Math.max(2,n/2),_/2):Math.max(3,n/2);i<=t&&i<c&&(c=i,g=d)}return g}}),Je("packages/modules/charts/flow.js",function(o,Y){"use strict";Object.defineProperty(o,"assignDepths",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"layoutSankey",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"ribbon",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"drawSankey",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"layoutChord",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"drawChord",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"describeLink",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"flowNodeAt",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"ribbonAt",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"chordArcAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"chordRibbonAt",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"chordPolygon",{enumerable:!0,get:function(){return h}});const Q=Y("packages/modules/charts/frame.js").Pool,pe=Y("packages/modules/charts/format.js").measureText,te=Y("packages/modules/charts/scheme.js").resolveScheme,Z=Y("packages/modules/charts/svg.js"),H=Z.attrs,ue=Z.insideRings,P=Z.path,y=Z.round,B=Z.setText,I=Y("packages/modules/charts/styles.js").NS,G=Y("packages/modules/charts/typography.js"),z=G.applySize,x=G.textWidth,b=G.truncateTo,f=Math.PI*2,l=12,v=8,C=-Math.PI/2,F=16;function _(s,g){for(const w of s)w.depth=0;const c=s.length+1;for(let w=0;w<c;w++){let m=!1;for(const u of g){if(u.source===u.target)continue;const k=u.source.depth+1;k>u.target.depth&&k<c&&(u.target.depth=k,m=!0)}if(!m)break}const d=s.reduce((w,m)=>Math.max(w,m.depth),0),N=new Set,S=new Set;for(const w of g)w.source!==w.target&&(N.add(w.source),S.add(w.target));for(const w of s)!N.has(w)&&S.has(w)&&(w.depth=d);return d+1}function J(s){const{nodes:g,links:c,plot:d}=s,N=_(g,c),S=s.nodeWidth||l,w=new Map;for(const p of g)w.has(p.depth)||w.set(p.depth,[]),w.get(p.depth).push(p);let m=0;for(const p of w.values()){const e=p.reduce((n,t)=>n+Math.max(t.in,t.out),0),i=Math.max(0,p.length-1)*v;e>0&&(m=Math.max(m,e/Math.max(1,d.height-i)))}const u=m>0?1/m:0,k=N>1?(d.width-S)/(N-1):0;for(const[p,e]of w){e.sort((r,a)=>Math.max(a.in,a.out)-Math.max(r.in,r.out));const i=e.map(r=>Math.max(1,Math.max(r.in,r.out)*u)),n=i.reduce((r,a)=>r+a,0)+(e.length-1)*v;let t=d.top+Math.max(0,(d.height-n)/2);e.forEach((r,a)=>{r.x=d.left+p*k,r.width=S,r.y=t,r.height=i[a],r.inAt=t,r.outAt=t,t+=i[a]+v})}const R=c.slice().sort((p,e)=>p.source.y-e.source.y||e.value-p.value);for(const p of R){const e=Math.max(1,p.value*u);p.thickness=e,p.y0=p.source.outAt+e/2,p.source.outAt+=e}for(const p of R.slice().sort((e,i)=>e.target.y-i.target.y||i.value-e.value))p.y1=p.target.inAt+p.thickness/2,p.target.inAt+=p.thickness;return{columns:N,scale:u}}function re(s){const g=s.source.x+s.source.width,c=s.target.x,d=(g+c)/2,N=s.thickness/2;return P(["M",y(g),y(s.y0-N),"C",y(d),y(s.y0-N),y(d),y(s.y1-N),y(c),y(s.y1-N),"L",y(c),y(s.y1+N),"C",y(d),y(s.y1+N),y(d),y(s.y0+N),y(g),y(s.y0+N),"Z"])}function q(s){const g=s.scheme||te(),{plot:c,bound:d}=s;for(const k of["grid","axis","rules","labels"])new Q(s.groups[k]).finish();const N=d.nodes,S=d.links;if(!N.length||!S.length)return{nodes:[],links:[]};J({nodes:N,links:S,plot:c});const w=new Q(s.groups.marks);for(const k of S){const R=w.next("path",`${I}__ribbon ${I}__mark`);H(R,{d:re(k),fill:g.series(k.source.index),"data-link":`${k.source.key}->${k.target.key}`})}for(const k of N)H(w.next("rect",`${I}__node ${I}__mark`),{x:y(k.x),y:y(k.y),width:y(k.width),height:y(k.height),fill:g.series(k.index),"data-node":k.key});w.finish();const m=new Q(s.groups.overlay),u=s.typography&&s.typography.small||s.fontSize;for(const k of N){const R=k.x<c.left+c.width/2,p=m.next("text",`${I}__flow-label`);z(p,u),H(p,{x:y(R?k.x+k.width+4:k.x-4),y:y(k.y+k.height/2),"text-anchor":R?"start":"end","dominant-baseline":"middle"});const e=R?c.right-(k.x+k.width)-6:k.x-c.left-6;B(p,b(k.label,Math.max(0,e),u))}return m.finish(),{nodes:N,links:S}}function U(s){const{nodes:g,links:c}=s,d=new Map;for(const p of g)d.set(p.key,0);for(const p of c)d.set(p.source.key,(d.get(p.source.key)||0)+p.value),d.set(p.target.key,(d.get(p.target.key)||0)+p.value);const N=[...d.values()].reduce((p,e)=>p+e,0);if(N<=0)return{arcs:[],ribbons:[]};const S=Math.min(.04,f/(g.length*8||1)),w=f-S*g.length,m=[];let u=-Math.PI/2;const k=new Map;for(const p of g){const i=(d.get(p.key)||0)/N*w;m.push({node:p,from:u,to:u+i}),k.set(p.key,u),u+=i+S}const R=[];for(const p of c.slice().sort((e,i)=>i.value-e.value)){const e=p.value/N*w,i=k.get(p.source.key),n=k.get(p.target.key);k.set(p.source.key,i+e),k.set(p.target.key,n+e),R.push({link:p,source:{from:i,to:i+e},target:{from:n,to:n+e}})}return{arcs:m,ribbons:R}}function ge(s){const g=s.scheme||te(),{plot:c,bound:d}=s;for(const t of["grid","axis","rules","labels"])new Q(s.groups[t]).finish();const N=c.left+c.width/2,S=c.top+c.height/2,w=s.typography&&s.typography.small||s.fontSize,m=Math.max(...d.nodes.map(t=>x(t.label,w)),0),u=Math.max(10,Math.min(c.width,c.height)/2-Math.min(m+8,90)),k=u*.92,{arcs:R,ribbons:p}=U({nodes:d.nodes,links:d.links,cx:N,cy:S,radius:u}),e=(t,r)=>[N+r*Math.cos(t),S+r*Math.sin(t)],i=new Q(s.groups.marks);for(const{link:t,source:r,target:a}of p){const[T,M]=e(r.from,k),[L,ee]=e(r.to,k),[fe,de]=e(a.from,k),[Me,ie]=e(a.to,k);H(i.next("path",`${I}__ribbon ${I}__mark`),{d:P(["M",y(T),y(M),"A",y(k),y(k),0,0,1,y(L),y(ee),"Q",y(N),y(S),y(fe),y(de),"A",y(k),y(k),0,0,1,y(Me),y(ie),"Q",y(N),y(S),y(T),y(M),"Z"]),fill:g.series(t.source.index),"fill-opacity":.55,"data-link":`${t.source.key}->${t.target.key}`})}for(const t of R){const[r,a]=e(t.from,u),[T,M]=e(t.to,u),[L,ee]=e(t.to,k),[fe,de]=e(t.from,k),Me=t.to-t.from>Math.PI?1:0;H(i.next("path",`${I}__node ${I}__mark`),{d:P(["M",y(r),y(a),"A",y(u),y(u),0,Me,1,y(T),y(M),"L",y(L),y(ee),"A",y(k),y(k),0,Me,0,y(fe),y(de),"Z"]),fill:g.series(t.node.index),"data-node":t.node.key})}i.finish();const n=new Q(s.groups.overlay);for(const t of R){const r=(t.from+t.to)/2,[a,T]=e(r,u+6),M=n.next("text",`${I}__flow-label`);z(M,w);const L=Math.cos(r)>=0;H(M,{x:y(a),y:y(T),"text-anchor":L?"start":"end","dominant-baseline":"middle"}),B(M,t.node.label)}return n.finish(),{arcs:R,ribbons:p,ring:{cx:N,cy:S,inner:k,radius:u}}}function A(s,g){return`${s.source.label} → ${s.target.label}: ${pe(s.value,g)}`}function X(s){for(const g of s.nodes||[])if(!(typeof g.x!="number"||typeof g.width!="number")&&s.x>=g.x&&s.x<=g.x+g.width&&s.y>=g.y&&s.y<=g.y+g.height)return g;return null}function ce(s){let g=null,c=1/0;for(const d of s.links||[]){const N=d.source,S=d.target;if(!N||!S||typeof d.y0!="number")continue;const w=N.x+N.width,m=S.x;if(s.x<Math.min(w,m)||s.x>Math.max(w,m))continue;const u=(w+m)/2,k=r=>{const a=1-r;return a*a*a*w+3*a*a*r*u+3*a*r*r*u+r*r*r*m};let R=0,p=1;for(let r=0;r<24;r++){const a=(R+p)/2;k(a)<s.x?R=a:p=a}const e=(R+p)/2,i=1-e,n=i*i*i*d.y0+3*i*i*e*d.y0+3*i*e*e*d.y1+e*e*e*d.y1,t=Math.max(1,d.thickness||1)/2;Math.abs(s.y-n)<=t&&(d.thickness||1)<c&&(c=d.thickness||1,g=d)}return g}function E(s){const g=s.ring;if(!g)return null;const c=s.x-g.cx,d=s.y-g.cy,N=Math.sqrt(c*c+d*d);if(N<g.inner||N>g.radius)return null;let S=Math.atan2(d,c);for(;S<C;)S+=f;for(;S>=C+f;)S-=f;for(const w of s.arcs||[])if(S>=w.from&&S<w.to)return w;return null}function W(s){const g=s.ring;if(!g)return null;const c=s.x-g.cx,d=s.y-g.cy;if(Math.sqrt(c*c+d*d)>g.inner)return null;for(const N of s.ribbons||[])if(ue([h(N,g)],s.x,s.y))return N;return null}function h(s,g){const{cx:c,cy:d,inner:N}=g,S=k=>[c+N*Math.cos(k),d+N*Math.sin(k)],w=[],m=(k,R)=>{for(let p=0;p<=F;p++)w.push(S(k+(R-k)*p/F))},u=(k,R)=>{for(let p=1;p<F;p++){const e=p/F,i=1-e;w.push([i*i*k[0]+2*i*e*c+e*e*R[0],i*i*k[1]+2*i*e*d+e*e*R[1]])}};return m(s.source.from,s.source.to),u(S(s.source.to),S(s.target.from)),m(s.target.from,s.target.to),u(S(s.target.to),S(s.source.from)),w}}),Je("packages/modules/charts/hit.js",function(o,Y){"use strict";Object.defineProperty(o,"valueText",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"ownsGeometry",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"resolveHit",{enumerable:!0,get:function(){return ge}});const Q=Y("packages/modules/charts/format.js").measureText,pe=Y("packages/modules/charts/treemap.js").tileAt,me=Y("packages/modules/charts/geo.js"),te=me.markerAt,Z=me.regionAt,ue=Y("packages/modules/charts/matrix.js").cellAt,P=Y("packages/modules/charts/network.js"),y=P.linkAt,B=P.nodeAt,D=Y("packages/modules/charts/flow.js"),I=D.chordArcAt,G=D.chordRibbonAt,z=D.flowNodeAt,x=D.ribbonAt,b=" → ",f=" – ",l=" › ";function v(A,X,ce){const E=Q(A,ce);if(!X||typeof A!="number"||!Number.isFinite(A))return E;const W=A/X;return Number.isFinite(W)?`${E} (${ce.number(W,{style:"percent",maximumFractionDigits:1})})`:E}function C(A,X){const ce=A.item.node,E=X.bound.root&&X.bound.root.total||0,W=Array.isArray(A.path)?[...A.path]:[ce.label];return{heading:W.length>1?W.join(l):ce.label,rows:[{label:X.bound.measure.title,value:v(ce.total,E,X.grid.messages),colour:X.scheme.series(A.item.index||0)}],datum:{label:ce.label,value:ce.total,category:ce.value,column:X.bound.measure.col&&X.spec.x||null,series:null,depth:A.depth,path:W,rowKeys:ce.rowKey?[ce.rowKey]:[]}}}function F(A,X,ce){const E=X.reduce((W,h)=>W+(h.value||0),0);return{heading:A.label||A.code,rows:[{label:ce.bound.measure.title,value:typeof A.text=="string"?A.text:v(A.value,E,ce.grid.messages),colour:ce.scheme.series(0)}],datum:{label:A.label||A.code,value:A.value,category:A.code,column:ce.spec.code||ce.spec.x||null,series:null,path:[A.label||A.code],rowKeys:Array.isArray(A.rowKeys)?[...A.rowKeys]:[]}}}function _(A,X,ce){const E=ce.spec.value||ce.spec.y||null,W=E?ce.grid.columns.get(E):null,h=c=>`${Number(c).toFixed(4)}°`,s=(X.legend||[]).find(c=>c.colour===A.fill)||null,g=[{label:W&&W.title||E||"",value:A.text||"",colour:A.fill},{label:"",value:`${h(A.lat)}, ${h(A.lon)}`,colour:"transparent"}];return s&&s.label&&g.push({label:"",value:s.label,colour:A.fill}),{heading:A.label||A.text||"",rows:g,datum:{label:A.label||A.text||"",value:A.value,category:A.value,column:E,series:null,path:[A.label||A.text||""],lon:A.lon,lat:A.lat,status:s?s.label:null,rowKeys:A.rowKey?[A.rowKey]:[]}}}function J(A,X){const ce=h=>{const s=X.grid.columns.get(h);return s&&s.title||h},E=ce(A.a),W=ce(A.b);return{heading:`${E} × ${W}`,rows:[{label:X.spec.method==="spearman"?"ρ":"r",value:typeof A.r=="number"&&Number.isFinite(A.r)?A.r.toFixed(2):"",colour:X.scheme.series(0)}],datum:{label:`${E} × ${W}`,value:typeof A.r=="number"?A.r:null,category:null,column:null,series:null,path:[E,W],rowKeys:[]}}}function re(A,X){const ce=[];for(const W of X.drawn&&X.drawn.links||[])if(!(W.source!==A&&W.target!==A))for(const h of W.rowKeys||[])ce.includes(h)||ce.push(h);const E=Math.max(A.in||0,A.out||0);return{heading:A.label,rows:[{label:X.bound.measure.title,value:Q(E,X.grid.messages),colour:X.scheme.series(A.index||0)}],datum:{label:A.label,value:E,category:A.value===void 0?A.key:A.value,column:null,series:null,path:[A.label],rowKeys:ce}}}function q(A,X){const ce=`${A.source.label}${A.undirected?f:b}${A.target.label}`;return{heading:ce,rows:[{label:X.bound.measure.title,value:v(A.value,A.undirected?0:X.bound.total||0,X.grid.messages),colour:A.colour||X.scheme.series(A.source.index||0)}],datum:{label:ce,value:A.value,category:null,column:null,series:null,path:[A.source.label,A.target.label],rowKeys:Array.isArray(A.rowKeys)?[...A.rowKeys]:[]}}}function U(A){return A?!!(Array.isArray(A.tiles)||Array.isArray(A.regions)||Array.isArray(A.markers)||Array.isArray(A.cells)&&Array.isArray(A.columns)||Array.isArray(A.ribbons)&&A.ring||Array.isArray(A.nodes)&&Array.isArray(A.links)):!1}function ge(A){const X=A.drawn;if(!X||!A.bound||!U(X))return null;const{x:ce,y:E}=A.at;if(Array.isArray(X.tiles)){const W=pe({tiles:X.tiles,x:ce,y:E});return W?C(W,A):null}if(Array.isArray(X.regions)){const W=Z({regions:X.regions,x:ce,y:E});return W?F(W,X.regions,A):null}if(Array.isArray(X.markers)){const W=te({markers:X.markers,x:ce,y:E});return W?_(W,X,A):null}if(Array.isArray(X.cells)&&Array.isArray(X.columns)){const W=ue({cells:X.cells,x:ce,y:E});return W?J(W,A):null}if(Array.isArray(X.ribbons)&&X.ring){const W=G({ribbons:X.ribbons,ring:X.ring,x:ce,y:E});if(W)return q(W.link,A);const h=I({arcs:X.arcs,ring:X.ring,x:ce,y:E});return h?re(h.node,A):null}if(Array.isArray(X.nodes)&&Array.isArray(X.links)){const W=X.nodes.some(g=>typeof g.r=="number"),h=W?B({nodes:X.nodes,x:ce,y:E}):z({nodes:X.nodes,x:ce,y:E});if(h)return re(h,A);const s=W?y({links:X.links,x:ce,y:E}):x({links:X.links,x:ce,y:E});return s?q(s,A):null}return null}}),Je("packages/modules/charts/polar.js",function(o,Y){"use strict";Object.defineProperty(o,"arcBand",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"drawRadar",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"drawGauge",{enumerable:!0,get:function(){return q}});const Q=Y("packages/modules/charts/frame.js").Pool,pe=Y("packages/modules/charts/format.js").measureText,me=Y("packages/modules/charts/scale.js"),te=me.isNumber,Z=me.measureDomain,H=Y("packages/modules/charts/svg.js"),ue=H.attrs,P=H.path,y=H.round,B=H.setText,I=Y("packages/modules/charts/styles.js").NS,z=Y("packages/modules/charts/scheme.js").resolveScheme,x=Y("packages/modules/charts/labels.js"),b=x.drawAnchoredLabels,f=x.labelText,l=Math.PI*2,v=4,C=l*2/3,F=Math.PI/2+(l-C)/2;function _(U,ge,A,X){const ce=X-Math.PI/2;return[U+A*Math.cos(ce),ge+A*Math.sin(ce)]}function J(U){const ge=U.to-U.from;if(ge<=0)return"";const A=Math.max(0,U.r-U.width),X=ge>Math.PI?1:0,[ce,E]=_(U.cx,U.cy,U.r,U.from),[W,h]=_(U.cx,U.cy,U.r,U.to),[s,g]=_(U.cx,U.cy,A,U.to),[c,d]=_(U.cx,U.cy,A,U.from);return P(["M",y(ce),y(E),"A",y(U.r),y(U.r),0,X,1,y(W),y(h),"L",y(s),y(g),"A",y(A),y(A),0,X,0,y(c),y(d),"Z"])}function re(U){const ge=U.scheme||z(),{plot:A,bound:X}=U;new Q(U.groups.grid).finish(),new Q(U.groups.axis).finish(),new Q(U.groups.rules).finish(),new Q(U.groups.labels).finish();const ce=A.left+A.width/2,E=A.top+A.height/2,W=Math.max(0,Math.min(A.width,A.height)/2-U.fontSize*2),h=X.labels,s=X.series.filter(u=>!U.hidden.has(u.key)),g=[];for(const u of s)for(const k of u.points)g.push(k.y);const c=Z(g,{zero:!0}),d=h.length?l/h.length:l,N=u=>{const k=c.max-c.min||1;return Math.max(0,(u-c.min)/k*W)},S=new Q(U.groups.grid);for(let u=1;u<=v;u++){const k=W*u/v,R=h.map((p,e)=>_(ce,E,k,e*d));ue(S.next("path",`${I}__web`),{d:R.length?P([...R.flatMap(([p,e],i)=>[i?"L":"M",y(p),y(e)]),"Z"]):"",fill:"none"})}for(let u=0;u<h.length;u++){const[k,R]=_(ce,E,W,u*d);ue(S.next("path",`${I}__web`),{d:P(["M",y(ce),y(E),"L",y(k),y(R)]),fill:"none"})}S.finish();const w=new Q(U.groups.marks);for(const u of s){const k=[];for(let e=0;e<h.length;e++){const i=u.points[e],n=te(i&&i.y)?i.y:c.min,[t,r]=_(ce,E,N(n),e*d);k.push([y(t),y(r)]),i&&(i.px=y(t),i.py=y(r))}const R=k.length?P([...k.flatMap(([e,i],n)=>[n?"L":"M",e,i]),"Z"]):"",p=ge.series(u.index);ue(w.next("path",`${I}__radar-fill ${I}__mark`),{d:R,fill:p,"data-series":u.index}),ue(w.next("path",`${I}__radar-line ${I}__mark`),{d:R,stroke:p,fill:"none","data-series":u.index})}w.finish();const m=new Q(U.groups.overlay);for(let u=0;u<h.length;u++){const[k,R]=_(ce,E,W+U.fontSize,u*d),p=m.next("text",`${I}__tick`),e=Math.abs(k-ce)<1?"middle":k>ce?"start":"end";ue(p,{x:y(k),y:y(R),"text-anchor":e,"dominant-baseline":"middle"}),B(p,h[u])}if(m.finish(),U.labels&&U.labels.show){const u=U.typography&&U.typography.small||U.fontSize||11,k=[];for(const R of s)for(const p of R.points){if(!p||p.px===void 0||!te(p.y))continue;const e=p.px-ce,i=p.py-E,n=Math.hypot(e,i)||1;k.push({x:y(p.px+e/n*(u*.8)),y:y(p.py+i/n*(u*.8)),text:f(p.y,U.labels,U.grid)})}b({group:U.groups.labels,size:u,minGap:U.labels.minGap,anchors:k,plot:A})}return{centre:{x:ce,y:E,r:W},series:s,axes:h}}function q(U){const ge=U.scheme||z(),{plot:A,bound:X}=U;new Q(U.groups.grid).finish(),new Q(U.groups.axis).finish(),new Q(U.groups.rules).finish(),new Q(U.groups.labels).finish();const ce=X.series[0],W=(ce?ce.points.filter(p=>te(p.y)):[]).reduce((p,e)=>p+e.y,0),h=te(U.min)?U.min:0,s=te(U.max)?U.max:Math.max(W,1),g=s-h||1,c=Math.min(1,Math.max(0,(W-h)/g)),d=A.left+A.width/2,N=A.top+A.height/2,S=Math.max(0,Math.min(A.width,A.height)/2-4),w=Math.max(6,S*.24),m=new Q(U.groups.marks);if(ue(m.next("path",`${I}__gauge-track`),{d:J({cx:d,cy:N,r:S,width:w,from:F,to:F+C})}),ue(m.next("path",`${I}__gauge-value ${I}__mark`),{d:J({cx:d,cy:N,r:S,width:w,from:F,to:F+C*c}),fill:ge.series(0)}),te(U.target)){const p=Math.min(1,Math.max(0,(U.target-h)/g)),e=F+C*p,[i,n]=_(d,N,S-w,e),[t,r]=_(d,N,S,e);ue(m.next("path",`${I}__gauge-target`),{d:P(["M",y(i),y(n),"L",y(t),y(r)]),fill:"none"})}m.finish();const u=new Q(U.groups.overlay),k=u.next("text",`${I}__gauge-reading`);ue(k,{x:y(d),y:y(N),"text-anchor":"middle","dominant-baseline":"middle"}),B(k,pe(W,U.grid.messages));const R=u.next("text",`${I}__gauge-caption`);return ue(R,{x:y(d),y:y(N+U.fontSize*1.6),"text-anchor":"middle","dominant-baseline":"middle"}),B(R,X.measure.title||""),u.finish(),{value:W,domain:{min:h,max:s}}}}),Je("packages/modules/charts/multiples.js",function(o,Y){"use strict";Object.defineProperty(o,"MAX_PANELS",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(o,"panelGrid",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"panelRects",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"splitPanels",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"sharedDomain",{enumerable:!0,get:function(){return me}});const ke=24;function Q(te,Z){if(te<=1)return{columns:1,rows:1};const H=(Z.width||1)/(Z.height||1);let ue=Math.max(1,Math.round(Math.sqrt(te*H)));ue=Math.min(ue,te);const P=Math.ceil(te/ue);return{columns:ue,rows:P}}function $(te){const Z=Math.min(te.count,ke),H=te.gap===void 0?10:te.gap,ue=te.titleHeight===void 0?14:te.titleHeight,{columns:P,rows:y}=Q(Z,te.plot),B=(te.plot.width-H*(P-1))/P,D=(te.plot.height-H*(y-1))/y,I=[];for(let G=0;G<Z;G++){const z=G%P,x=Math.floor(G/P);I.push({index:G,x:te.plot.left+z*(B+H),y:te.plot.top+x*(D+H)+ue,width:Math.max(0,B),height:Math.max(0,D-ue)})}return I}function pe(te){return te.series.map((Z,H)=>({label:Z.label,key:Z.key,index:H,bound:{...te,series:[{...Z,index:H}]}}))}function me(te,Z,H){const ue=[];for(const P of te.series)for(const y of P.points)ue.push(y.y);return H(ue,{zero:Z})}}),Je("packages/modules/charts/stream.js",function(o,Y){"use strict";Object.defineProperty(o,"wiggleBaseline",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"drawStream",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"drawMarimekko",{enumerable:!0,get:function(){return X}}),Object.defineProperty(o,"drawViolin",{enumerable:!0,get:function(){return ce}});const ke=Y("packages/modules/charts/axis.js"),Q=ke.drawAxisLines,$=ke.drawCategoryAxis,pe=ke.drawMeasureAxis,me=Y("packages/modules/charts/distribution.js"),te=me.density,Z=me.distributionDomain,H=me.summarise,ue=me.valuesByCategory,P=Y("packages/modules/charts/frame.js"),y=P.Pool,B=P.shouldRotate,I=Y("packages/modules/charts/format.js").formatters,G=Y("packages/modules/charts/scale.js"),z=G.bandScale,x=G.isNumber,b=G.linearScale,f=G.measureDomain,v=Y("packages/modules/charts/scheme.js").resolveScheme,C=Y("packages/modules/charts/svg.js"),F=C.attrs,_=C.path,J=C.round,q=Y("packages/modules/charts/styles.js").NS,U=32;function ge(E){const W=[];let h=0;for(let s=0;s<E.length;s++){const g=E[s],c=g.reduce((w,m)=>w+m,0);if(s===0){h=-c/2,W.push(h);continue}const d=E[s-1];let N=0;const S=g.length;for(let w=0;w<S;w++){let m=0;for(let u=0;u<w;u++)m+=(g[u]||0)-(d[u]||0);N+=(S-w-.5)*((g[w]||0)-(d[w]||0))+m*0}h-=S>0?N/S:0,W.push(h)}return W}function A(E){const W=E.scheme||v(),{plot:h,bound:s}=E;new y(E.groups.grid).finish(),new y(E.groups.rules).finish(),new y(E.groups.labels).finish();const g=s.series.filter(k=>!E.hidden.has(k.key)),c=s.categories.map((k,R)=>g.map(p=>{const e=p.points[R];return x(e&&e.y)?Math.max(0,e.y):0})),d=ge(c),N=[];c.forEach((k,R)=>{N.push(d[R]),N.push(d[R]+k.reduce((p,e)=>p+e,0))});const S=f(N,{zero:!1,nice:!1}),w=b(S,[h.bottom,h.top]),m=z(s.categories,[h.left,h.right],0),u=new y(E.groups.marks);return g.forEach((k,R)=>{const p=[],e=[];c.forEach((n,t)=>{let r=d[t];for(let T=0;T<R;T++)r+=n[T];const a=J(m.centre(s.categories[t]));e.push([a,J(w.of(r))]),p.push([a,J(w.of(r+n[R]))])});const i=[];p.forEach(([n,t],r)=>i.push(r?"L":"M",n,t));for(let n=e.length-1;n>=0;n--)i.push("L",e[n][0],e[n][1]);i.push("Z"),F(u.next("path",`${q}__stream ${q}__mark`),{d:_(i),fill:W.series(k.index),"data-series":k.index})}),u.finish(),$({group:E.groups.overlay,plot:h,scale:m,labels:s.labels,fontSize:E.typography&&E.typography.small||E.fontSize,rotated:B(s.labels,m.step,E.fontSize,(E.axis&&E.axis.x||{}).every),config:E.axis&&E.axis.x||{}}),{xScale:m,yScale:w,series:g}}function X(E){const W=E.scheme||v(),{plot:h,bound:s}=E,g=s.series.filter(e=>!E.hidden.has(e.key)),c=s.categories.map((e,i)=>g.reduce((n,t)=>{const r=t.points[i];return n+(x(r&&r.y)?Math.abs(r.y):0)},0)),d=c.reduce((e,i)=>e+i,0);if(d<=0)return{series:g,columns:[]};const N=2,S=h.width-N*Math.max(0,s.categories.length-1),w=b({min:0,max:100},[h.bottom,h.top]);pe({gridGroup:E.groups.grid,axisGroup:E.groups.axis,plot:h,scale:w,format:I(E.grid,{kind:"linear",step:20}),config:E.axis&&E.axis.y||{},grid:E.grid,size:E.typography&&E.typography.small||E.fontSize}),Q({group:E.groups.rules,plot:h});const m=new y(E.groups.marks),u=[];let k=h.left;s.categories.forEach((e,i)=>{const n=c[i]/d*S;let t=h.bottom;g.forEach((r,a)=>{const T=r.points[i],M=x(T&&T.y)?Math.abs(T.y):0,ee=(c[i]>0?M/c[i]:0)*h.height;F(m.next("rect",`${q}__bar ${q}__mark`),{x:J(k),y:J(t-ee),width:J(Math.max(0,n)),height:J(Math.max(0,ee)),fill:W.series(r.index),"data-series":r.index,"data-point":i}),T&&(T.px=J(k+n/2),T.py=J(t-ee)),t-=ee}),u.push({category:e,label:s.labels[i],x:k,width:n,total:c[i]}),k+=n+N}),m.finish();const R=new y(E.groups.overlay),p=E.typography&&E.typography.small||E.fontSize;for(const e of u){if(e.width<p*2)continue;const i=R.next("text",`${q}__tick`);i.style.fontSize=`${p}px`,F(i,{x:J(e.x+e.width/2),y:J(h.top-2),"text-anchor":"middle"}),i.textContent=e.label}return R.finish(),{series:g,columns:u}}function ce(E){const W=E.scheme||v(),{plot:h,bound:s}=E,g=ue(s),c=[...g.keys()],d=[];for(const u of g.values())for(let k=0;k<u.length;k++)d.push(u[k]);const N=Z(d,E.axis),S=b(N,[h.bottom,h.top]),w=z(c,[h.left,h.right],.3);pe({gridGroup:E.groups.grid,axisGroup:E.groups.axis,plot:h,scale:S,format:I(E.grid,{kind:"linear",step:(N.max-N.min)/5}),config:E.axis&&E.axis.y||{},grid:E.grid,size:E.typography&&E.typography.small||E.fontSize}),$({group:E.groups.overlay,plot:h,scale:w,labels:c,fontSize:E.typography&&E.typography.small||E.fontSize,rotated:c.length>6,config:E.axis&&E.axis.x||{}}),Q({group:E.groups.rules,plot:h});const m=new y(E.groups.marks);return c.forEach((u,k)=>{const R=g.get(u),p=te(R,N,U),e=p.reduce((M,L)=>Math.max(M,L.density),0)||1,i=w.bandwidth/2,n=w.of(u)+i,t=p.map(M=>[J(n+M.density/e*i),J(S.of(M.at))]),r=p.map(M=>[J(n-M.density/e*i),J(S.of(M.at))]),a=[];t.forEach(([M,L],ee)=>a.push(ee?"L":"M",M,L));for(let M=r.length-1;M>=0;M--)a.push("L",r[M][0],r[M][1]);a.push("Z"),F(m.next("path",`${q}__violin ${q}__mark`),{d:_(a),fill:W.series(k),"data-point":k});const T=H(R);T&&F(m.next("path",`${q}__median ${q}__mark`),{d:_(["M",J(n-i*.5),J(S.of(T.median)),"L",J(n+i*.5),J(S.of(T.median))]),stroke:W.series(k),"stroke-width":2,fill:"none"})}),m.finish(),{xScale:w,yScale:S,series:[{key:"",label:s.measure.title,index:0,points:c.map(u=>{const k=H(g.get(u));return{x:u,xKey:u,label:u,y:k?k.median:null,rows:(g.get(u)||[]).length}})}]}}}),Je("packages/modules/charts/gantt.js",function(o,Y){"use strict";Object.defineProperty(o,"readTasks",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"drawGantt",{enumerable:!0,get:function(){return re}});const ke=Y("packages/modules/charts/axis.js"),Q=ke.drawAxisLines,$=ke.drawBandLabels,pe=ke.drawContinuousAxis,te=Y("packages/modules/charts/frame.js").Pool,H=Y("packages/modules/charts/format.js").formatters,ue=Y("packages/modules/charts/scale.js"),P=ue.bandScale,y=ue.timeScale,B=ue.toTime,I=Y("packages/modules/charts/scheme.js").resolveScheme,G=Y("packages/modules/charts/svg.js"),z=G.attrs,x=G.round,b=G.setText,l=Y("packages/modules/charts/styles.js").NS,v=Y("packages/modules/charts/typography.js"),C=v.applySize,F=v.truncateTo,_=8;function J(q,U,ge){const A=[];let X=1/0,ce=-1/0;for(const E of ge){const W=B(q.rows.value(E.key,U.start)),h=B(q.rows.value(E.key,U.end));if(W===null||h===null)continue;const s=U.label?q.rows.text(E.key,U.label):E.key,g=U.series?q.rows.value(E.key,U.series):null;A.push({key:E.key,label:s,group:g,from:Math.min(W,h),to:Math.max(W,h)}),X=Math.min(X,W,h),ce=Math.max(ce,W,h)}return{tasks:A,span:A.length?{min:X,max:ce}:null}}function re(q){const U=q.scheme||I(),{plot:ge}=q,{tasks:A,span:X}=J(q.grid,q.spec,q.rows);if(!X)return{tasks:[],xScale:null,dropped:0};const ce=Math.max(1,Math.floor(ge.height/_)),E=A.slice(0,ce),W=A.length-E.length,h=y({min:X.min,max:X.max},[ge.left,ge.right]),s=P(E.map(S=>S.key),[ge.top,ge.bottom],.25),g=q.typography&&q.typography.small||q.fontSize;pe({group:q.groups.overlay,plot:ge,scale:h,format:H(q.grid,{kind:"time",span:X.max-X.min}),config:q.axis&&q.axis.x||{},grid:q.grid,size:g}),$({group:q.groups.axis,plot:ge,scale:s,labels:E.map(S=>S.label),fontSize:g}),Q({group:q.groups.rules,plot:ge});const c=[...new Set(E.map(S=>String(S.group)))],d=new te(q.groups.marks);E.forEach((S,w)=>{const m=s.of(S.key),u=h.of(S.from),k=h.of(S.to);z(d.next("rect",`${l}__task ${l}__mark`),{x:x(u),width:x(Math.max(2,k-u)),y:x(m),height:x(s.bandwidth),fill:U.series(S.group===null?0:c.indexOf(String(S.group))),"data-point":w,"data-key":S.key}),S.px=x((u+k)/2),S.py=x(m+s.bandwidth/2)}),d.finish();const N=new te(q.groups.labels);if(W>0){const S=N.next("text",`${l}__geo-note`);C(S,g),z(S,{x:x(ge.left),y:x(ge.bottom+g+4),"text-anchor":"start"}),b(S,F(q.grid.messages.t("chart.tasksDropped",{count:W}),ge.width,g))}return N.finish(),{tasks:E,xScale:h,dropped:W,series:[{key:"",label:q.spec.label||"",index:0,points:E.map(S=>({x:S.key,xKey:S.key,label:S.label,y:S.to-S.from,rows:1,rowKey:S.key,px:S.px,py:S.py}))}]}}}),Je("packages/modules/charts/interaction.js",function(o,Y){"use strict";Object.defineProperty(o,"resolveBrush",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"brushed",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"brushCondition",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"attachBrush",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(o,"applySelection",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"attachKeyboard",{enumerable:!0,get:function(){return ue}});const Q=Y("packages/modules/charts/svg.js").attrs,$=4;function pe(P){const y=P&&P.brush;if(y===!0)return{mode:"filter",axis:"x"};if(y==="filter"||y==="zoom"||y==="select")return{mode:y,axis:"x"};if(y&&typeof y=="object"&&y.mode){const B=["filter","zoom","select"].includes(y.mode)?y.mode:null,D=y.axis==="y"||y.axis==="y2"?y.axis:"x";return{mode:B,axis:D}}return{mode:null,axis:"x"}}function me(P){const{bound:y,xScale:B}=P,D=Math.min(P.from,P.to),I=Math.max(P.from,P.to);if(P.axis==="y"||P.axis==="y2"){const x=P.axis==="y2"&&P.rightScale?P.rightScale:P.yScale||B;if(!x||typeof x.invert!="function")return{kind:"range",values:[],range:null,axis:P.axis};const b=x.invert(D),f=x.invert(I);return{kind:"range",values:[],range:[b,f],axis:P.axis}}if(B.kind==="band"){const x=[];for(const b of y.categories){const f=B.centre(b);!Number.isNaN(f)&&f>=D&&f<=I&&x.push(b)}return{kind:"set",values:x,range:null,axis:"x"}}const G=B.invert(D),z=B.invert(I);return{kind:"range",values:[],range:[G,z],axis:"x"}}function te(P){const{column:y,result:B}=P;if(!y)return null;if(B.kind==="set")return B.values.length?{col:y,op:"in",value:B.values.slice()}:null;if(!B.range)return null;const[D,I]=B.range;if(!Number.isFinite(D)||!Number.isFinite(I))return null;const G=P.kind==="time"?[new Date(Math.min(D,I)),new Date(Math.max(D,I))]:[Math.min(D,I),Math.max(D,I)];return{col:y,op:"between",value:G,bounds:"[]"}}function Z(P){let y=null,B=null;const D=()=>{const x=typeof P.axis=="function"?P.axis():"x",b=x==="y"||x==="y2";return(typeof P.horizontal=="function"?P.horizontal():!1)!==b},I=x=>{if(!P.enabled())return;const b=P.pointOf(x);y=D()?b.y:b.x,B=P.svg.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect"),B.setAttribute("class","lat-chartview__brush"),P.overlay.appendChild(B)},G=x=>{if(y===null||!B)return;const b=P.plot();if(D()){const C=P.pointOf(x).y,F=Math.max(b.top,Math.min(y,C)),_=Math.min(b.bottom,Math.max(y,C));Q(B,{x:b.left,y:F,width:Math.max(0,b.right-b.left),height:Math.max(0,_-F)});return}const f=P.pointOf(x).x,l=Math.max(b.left,Math.min(y,f)),v=Math.min(b.right,Math.max(y,f));Q(B,{x:l,y:b.top,width:Math.max(0,v-l),height:b.height})},z=x=>{if(y===null)return;const b=P.pointOf(x),f=D()?b.y:b.x,l=Math.abs(f-y),v=y;y=null,B&&B.parentNode&&B.parentNode.removeChild(B),B=null,l>=$&&P.onBrush(v,f)};return P.svg.addEventListener("pointerdown",I),P.svg.addEventListener("pointermove",G),P.svg.addEventListener("pointerup",z),P.svg.addEventListener("pointerleave",z),()=>{P.svg.removeEventListener("pointerdown",I),P.svg.removeEventListener("pointermove",G),P.svg.removeEventListener("pointerup",z),P.svg.removeEventListener("pointerleave",z)}}function H(P){const y=P.groups.marks,B=P.keys.size>0||P.categories.size>0;let D=0;for(const I of y.childNodes||[]){if(!I.getAttribute)continue;const G=Number(I.getAttribute("data-series")),z=Number(I.getAttribute("data-point")),x=P.series[G],b=x&&x.points[z],f=!!b&&(b.rowKey&&P.keys.has(b.rowKey)||b.xKey!==void 0&&P.categories.has(b.xKey));f&&D++,B&&!f?I.setAttribute("data-dim","true"):I.removeAttribute("data-dim")}return D}function ue(P){let y=0;const B=I=>{const G=P.marks();if(G.length){y=Math.max(0,Math.min(G.length-1,I));for(let z=0;z<G.length;z++)G[z].setAttribute("tabindex",z===y?"0":"-1");G[y].focus&&G[y].focus(),P.onFocus(y)}},D=I=>{const G=P.marks();if(G.length){switch(I.key){case"ArrowRight":case"ArrowDown":B(y+1);break;case"ArrowLeft":case"ArrowUp":B(y-1);break;case"Home":B(0);break;case"End":B(G.length-1);break;case"Enter":case" ":P.onActivate(y);break;default:return}I.preventDefault&&I.preventDefault()}};return P.svg.addEventListener("keydown",D),()=>P.svg.removeEventListener("keydown",D)}}),Je("packages/modules/charts/range.js",function(o,Y){"use strict";Object.defineProperty(o,"deriveRangeSpec",{enumerable:!0,get:function(){return me}});const ke=new Set(["number","currency","percent","integer"]);function Q(te){return!!te&&typeof te.type=="string"&&ke.has(te.type)}function $(te){const Z=te&&te.selection&&typeof te.selection.ranges=="function"?te.selection.ranges():[];return!Array.isArray(Z)||!Z.length?null:Z[Z.length-1]}function pe(te,Z){const H=[],ue=Math.min(Z.startRow,Z.endRow),P=Math.max(Z.startRow,Z.endRow);for(let y=ue;y<=P;y++){const B=te.rows.get(y);B&&!B.group&&B.data!==null&&B.data!==void 0&&H.push(B)}return H}function me(te,Z={}){const H=F=>({spec:null,type:null,x:null,measures:[],columns:[],reason:F}),ue=Z.range||$(te);if(!ue)return H("no-range");const P=te.columns.visible(),y=new Set(P.map(F=>F.id)),B=(ue.columns||[]).filter(F=>y.has(F));if(!B.length)return H("no-visible-columns");const D=B.map(F=>({id:F,column:te.columns.get(F)})),I=D.filter(F=>Q(F.column)).map(F=>F.id),G=D.filter(F=>!Q(F.column)).map(F=>F.id);if(!I.length)return H("no-measure");const z=G.length?G[0]:null,x=I,f={rows:pe(te,ue)},l=new Set(["bar","line","area"]);if(x.length>1){const F=Z.type,_=l.has(F)?F:null,J=F&&!l.has(F)?F:"combo";return{spec:{...f,type:J,x:z,measures:x.map(q=>_?{col:q,type:_}:{col:q})},type:J,x:z,measures:x,columns:B,reason:null}}const v=Z.type||"bar";return{spec:{...f,type:v,x:z,y:x[0]},type:v,x:z,measures:x,columns:B,reason:null}}}),Je("packages/modules/charts/regression.js",function(o,Y){"use strict";Object.defineProperty(o,"regressionPlots",{enumerable:!0,get:function(){return me}});const ke=new Set(["number","currency","percent","integer"]);function Q(te,Z={}){return{spec:te,reason:null,...Z}}function $(te,Z={}){return{spec:null,reason:te,...Z}}function pe(te){if(!te||!Array.isArray(te.fitted)||!Array.isArray(te.residuals)||!Array.isArray(te.leverage)||!(te.sigma2>0))return null;const Z=Math.sqrt(te.sigma2),H=[];for(let ue=0;ue<te.fitted.length;ue++){const P=te.leverage[ue];if(!Number.isFinite(P)||P>=1)continue;const y=Z*Math.sqrt(1-P);if(!(y>0))continue;const B=te.residuals[ue]/y;H.push({x:te.fitted[ue],y:Math.sqrt(Math.abs(B)),key:String(ue)})}return H}function me(te,Z={}){const H=Z.model||(te&&te.statistics&&typeof te.statistics.regressionModel=="function"?te.statistics.regressionModel(Z.spec||{}):null),ue=ge=>({fit:$(ge),residualsFitted:$(ge),qq:$(ge),multicollinearity:$(ge),scaleLocation:$(ge),residualsLeverage:$(ge),coefficientForest:$(ge)});if(!H||!Array.isArray(H.predictors)||!H.predictors.length||!H.response)return{model:null,plots:ue("no-model")};const P=H.predictors,y=H.response,B=Z.rows,D=()=>B===void 0?{}:{rows:B},I=Z.fitted||null,G=Z.residual||null,z=Z.stdResidual||null,x=Z.leverage||null,b=Z.cooksD||null,f=P.length===1?Q({type:"scatter",x:P[0],y,fit:!0,band:H.band||null,...D()}):$("multiple-predictors"),l=I&&G?Q({type:"scatter",x:I,y:G,reference:[{value:0}],...D()}):$("needs-fitted-and-residual-columns"),v=G?Q({type:"qq",y:G,...D()}):$("needs-residual-column"),C=P.filter(ge=>{const A=te&&te.columns&&typeof te.columns.get=="function"?te.columns.get(ge):null;return!A||typeof A.type=="string"&&ke.has(A.type)}),F=P.length>=2?Q({type:"correlogram",columns:C},{vif:H.vif||null}):$("single-predictor",{vif:H.vif||null}),_=x&&z?Q({type:b?"bubble":"scatter",x,y:z,...b?{size:b}:{},reference:[{value:0}],...D()}):$("needs-leverage-and-standardised-residual-columns"),J=pe(H),re=J&&J.length?Q({type:"scatter",points:J,fit:!0,dimensionTitle:"Fitted",measureTitle:"√|standardised residual|"}):$("needs-fitted-model"),q=Array.isArray(H.coefficients)?H.coefficients.filter(ge=>ge&&Number.isFinite(ge.estimate)&&Number.isFinite(ge.lower)&&Number.isFinite(ge.upper)).map(ge=>({x:ge.estimate,label:ge.name,lower:ge.lower,upper:ge.upper})):[],U=q.length?Q({type:"forest",points:q,dimensionTitle:"Coefficient",measureTitle:"Estimate"},{coefficients:H.coefficients||null}):$("needs-coefficient-intervals",{coefficients:H.coefficients||null});return{model:H,plots:{fit:f,residualsFitted:l,qq:v,multicollinearity:F,scaleLocation:re,residualsLeverage:_,coefficientForest:U}}}}),Je("packages/modules/charts/registry.js",function(o,Y){"use strict";Object.defineProperty(o,"registerChartType",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"chartTypeDef",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"registeredChartTypes",{enumerable:!0,get:function(){return pe}});const ke=new Map;function Q(me,te){if(typeof me!="string"||!me)throw new TypeError("[lattice] registerChartType needs a non-empty type name.");if(!te||typeof te.draw!="function")throw new TypeError(`[lattice] registerChartType('${me}') needs a { draw } function.`);ke.set(me,te)}function $(me){return ke.get(me)||null}function pe(){return[...ke.keys()]}}),Je("packages/modules/charts/index.js",function(o,Y){"use strict";Object.defineProperty(o,"TYPES",{enumerable:!0,get:function(){return _n}}),Object.defineProperty(o,"Chart",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(o,"createChart",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(o,"deriveRangeSpec",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(o,"regressionPlots",{enumerable:!0,get:function(){return br}}),Object.defineProperty(o,"chartRange",{enumerable:!0,get:function(){return io}}),Object.defineProperty(o,"canChartRange",{enumerable:!0,get:function(){return so}});const ke=Y("packages/modules/charts/cartesian.js"),Q=ke.aheadOfWindow,$=ke.axisWindowNow,pe=ke.axisWindowSpan,me=ke.bandedX,te=ke.CARTESIAN,Z=ke.drawCartesian,H=ke.drawForest,ue=ke.nearestCategory,P=ke.nearestDrawnPoint,y=ke.WINDOW_LEAD,B=ke.windowedBound,D=ke.xDomainFor,G=Y("packages/modules/charts/drawable.js").drawability,z=Y("packages/modules/charts/axis.js"),x=z.createGroups,b=z.drawAxisTitle,f=z.normaliseAxes,l=z.setPlotClip,v=Y("packages/modules/charts/bind.js"),C=v.bindHierarchy,F=v.bindLinks,_=v.bindMeasures,J=v.bindPoints,re=v.bindSeries,q=v.leafRows,ge=Y("packages/modules/shared/engine.js").EngineFlight,A=Y("packages/modules/charts/mapview.js"),X=A.capClientBound,ce=A.engineRowsReader,E=A.frameMoved,W=A.frameOf,h=A.MAP_ENGINE_TYPES,s=A.needsRefit,g=A.planMapViewport,c=A.ringsBox,d=A.viewportCap,S=Y("packages/modules/charts/mapdensity.js").drawDensityCells,w=Y("packages/modules/charts/engine.js"),m=w.boundFromGroups,u=w.holdsWindow,k=w.measureProvenance,R=w.planAggregate,p=w.specMeasures,e=Y("packages/modules/charts/frame.js"),i=e.Pool,n=e.plotRect,t=Y("packages/modules/charts/scale.js"),r=t.key,a=t.measureDomain,T=t.sqrtScale,M=Y("packages/modules/charts/format.js"),L=M.measureFormat,ee=M.measureText,fe=Y("packages/modules/charts/radial.js"),de=fe.arcAt,Me=fe.drawRadial,ie=Y("packages/modules/charts/distribution.js"),ve=ie.drawBoxPlot,we=ie.drawCapability,Ae=ie.drawControl,ne=ie.drawEcdf,se=ie.drawHistogram,ae=ie.drawLorenz,be=ie.drawMovingRange,le=ie.drawQQ,Ne=Y("packages/modules/charts/treemap.js").drawTreemap,Re=Y("packages/modules/charts/annotate-layer.js").ChartAnnotations,Te=Y("packages/modules/charts/annotate-items.js"),Fe=Te.itemsFromState,ze=Te.resolveAnnotate,Ze=Te.serialiseItem,Ye=Y("packages/modules/charts/zoom-view.js"),nt=Ye.bandRange,Ot=Ye.magnify,jt=Ye.resolveZoom,Bt=Ye.sameView,Ht=Ye.settleView,xt=Ye.slice,At=Ye.slide,un=Ye.viewOfRange,qt=Ye.ZOOM_CONTROLS,Lt=Y("packages/modules/charts/zoom-toolbar.js").buildZoomToolbar,Wt=Y("packages/modules/charts/hit.js"),en=Wt.ownsGeometry,nn=Wt.resolveHit,dt=Y("packages/modules/charts/combo.js").drawCombo,ut=Y("packages/modules/charts/polar.js"),$t=ut.drawGauge,It=ut.drawRadar,Et=Y("packages/modules/charts/matrix.js"),zt=Et.clearVolumePane,Jt=Et.drawCandlestick,V=Et.drawCorrelogram,Pe=Et.drawFunnel,xe=Et.drawHeatmap,je=Et.title,$e=Et.VOLUME_PANE_HEIGHT,Le=Y("packages/modules/charts/multiples.js"),Ce=Le.panelRects,Be=Le.splitPanels,_e=Y("packages/modules/charts/geo.js"),Ie=_e.basemapStyleOf,Ue=_e.checkGeometrySpec,Ve=_e.drawGeomap,at=_e.geoRamp,et=_e.GEOMETRY_TYPES_PLACED,ct=_e.packRegions,Mt=_e.projectedPath,Xe=_e.resolvePack,Nt=Y("packages/modules/charts/projection.js"),kt=Nt.fitted,Pt=Nt.resolveProjection,ft=Nt.splitAntimeridian,mt=Y("packages/modules/charts/viewport-filter.js"),Ct=mt.adoptedGeoView,_t=mt.conditionBbox,fn=mt.mergeViewportCondition,rn=mt.pruneTarget,Kt=mt.resolveViewportFilter,yt=mt.sameBbox,hn=mt.viewportBbox,En=mt.viewportCondition,on=mt.viewportTarget,Vt=Y("packages/modules/charts/flow.js"),yn=Vt.drawChord,mn=Vt.drawSankey,wn=Y("packages/modules/charts/network.js"),On=wn.drawNetwork,ln=wn.emphasiseNetwork,kn=Y("packages/modules/charts/stream.js"),vn=kn.drawMarimekko,xn=kn.drawStream,Tn=kn.drawViolin,gn=Y("packages/modules/charts/gantt.js").drawGantt,Gt=Y("packages/modules/charts/svg.js"),Xt=Gt.attrs,cn=Gt.append,Zt=Gt.clear,st=Gt.el,sn=Gt.round,wt=Gt.setText,rt=Gt.svg,gt=Y("packages/modules/charts/styles.js"),ot=gt.NS,Ft=gt.injectStyles,Rt=Y("packages/modules/charts/scheme.js"),An=Rt.resolveScheme,pn=Y("packages/modules/charts/typography.js"),an=pn.applySize,Wn=pn.resolveType,lr=pn.textWidth,Kn=Y("packages/modules/charts/labels.js"),cr=Kn.collides,ur=Kn.resolveLabels,bn=Y("packages/modules/charts/interaction.js"),fr=bn.applySelection,hr=bn.attachBrush,dr=bn.attachKeyboard,mr=bn.brushCondition,gr=bn.brushed,jn=bn.resolveBrush,Ln=Y("packages/modules/charts/dense.js"),ao=Ln.downsample,lo=Ln.markCount,pr=Ln.wantsCanvas,Cn=Y("packages/modules/charts/range.js").deriveRangeSpec,br=Y("packages/modules/charts/regression.js").regressionPlots,Sn=Y("packages/modules/charts/registry.js"),Vn=Sn.chartTypeDef,fo=Sn.registeredChartTypes,ho=Sn.registerChartType,yr=t.linearScale,wr=t.bandScale,Zn=t.extent,Yn=t.toNumber,kr=t.isNumber,vr=t.niceDomain,xr=t.linearTicks,Ar=t.timeScale,Jn=t.toTime,Sr=t.niceStep,Mr=Et.colourRamp,Nr=Gt.path,Or=Gt.attr,Dt=Y("packages/core/src/internal/util.js").warnOnce,jr=z.drawMeasureAxis,Pr=z.drawCategoryAxis,$r=z.drawAxisLines,Er=z.drawContinuousAxis,Tr=z.drawBandLabels,Lr=z.tickValues,Cr=ie.density,_r=ie.valuesByCategory,Rr=ie.summarise,zr=ie.quantile,Fr=ie.histogram,Xn=M.formatters;Object.defineProperty(o,"registerScheme",{enumerable:!0,get:function(){return Rt.registerScheme}}),Object.defineProperty(o,"resolveScheme",{enumerable:!0,get:function(){return Rt.resolveScheme}}),Object.defineProperty(o,"schemeNames",{enumerable:!0,get:function(){return Rt.schemeNames}}),Object.defineProperty(o,"setDefaultScheme",{enumerable:!0,get:function(){return Rt.setDefaultScheme}}),Object.defineProperty(o,"SCHEMES",{enumerable:!0,get:function(){return Rt.SCHEMES}}),Object.defineProperty(o,"PALETTE",{enumerable:!0,get:function(){return Rt.PALETTE}}),Object.defineProperty(o,"registerChartType",{enumerable:!0,get:function(){return Sn.registerChartType}}),Object.defineProperty(o,"registeredChartTypes",{enumerable:!0,get:function(){return Sn.registeredChartTypes}});const Ir=Object.freeze({el:st,svg:rt,attr:Or,attrs:Xt,append:cn,clear:Zt,path:Nr,round:sn,setText:wt,Pool:i,plotRect:n,linearScale:yr,bandScale:wr,sqrtScale:T,extent:Zn,measureDomain:a,niceDomain:vr,linearTicks:xr,timeScale:Ar,toTime:Jn,niceStep:Sr,toNumber:Yn,isNumber:kr,key:r,drawMeasureAxis:jr,drawCategoryAxis:Pr,drawAxisLines:$r,drawContinuousAxis:Er,drawBandLabels:Tr,tickValues:Lr,formatters:Xn,resolveScheme:An,colourRamp:Mr,density:Cr,valuesByCategory:_r,summarise:Rr,quantile:zr,histogram:Fr,resolvePack:Xe,packRegions:ct,fitted:kt,resolveProjection:Pt,splitAntimeridian:ft,projectedPath:Mt,basemapStyleOf:Ie,geoRamp:at,textWidth:lr,applySize:an,collides:cr,drawDensityCells:S,NS:ot}),_n=Object.freeze(["line","step","area","rangeArea","bar","horizontalBar","waterfall","scatter","bubble","forest","combo","pareto","histogram","boxplot","heatmap","qq","ecdf","lorenz","correlogram","control","capability","movingRange","pie","donut","sunburst","treemap","radar","gauge","funnel","candlestick","geomap","sankey","chord","network","stream","marimekko","violin","gantt"]),Rn=new Set([...Object.keys(te),"combo","candlestick",...et]),zn=new Set([...Object.keys(te),"combo"]),Dr=4,Qn=new Set(["bar","column","horizontalBar","line","area","scatter","bubble","combo","pareto","histogram","heatmap","pie","donut","sunburst","treemap","radar","geomap"]),Br=new Set(["pie","donut","sunburst"]),Gr=new Set(["pie","donut","sunburst","treemap"]),qn=20,Ur=new Set(["histogram","boxplot","qq","ecdf","lorenz","control","capability","movingRange"]),Hr=new Set(["histogram","boxplot","qq","ecdf","lorenz","violin"]);function Wr(it){const O=it.y||(Array.isArray(it.measures)&&it.measures.length?it.measures[0]:null);if(!O)return it;const j=typeof O=="string"?O:O.col;if(!j)return it;const K=typeof O=="object"&&O.fn!=null?O.fn:"median";return{...it,y:{col:j,fn:K}}}const Kr=new Set(["combo","candlestick"]),er=new Set(["bar","line","step","area","scatter","bubble"]),Vr=new Set(["sankey","chord","network"]),Fn=Symbol("pending"),Zr=new Set(["gantt"]),Yr=new Set(["radar","gauge","funnel","heatmap","geomap","sankey","chord","network"]),tn=Object.freeze({width:480,height:300}),tr=Object.freeze(["00000"]),nr=new Set(["horizontalBar","forest"]);function Jr(it){if(!it||!Array.isArray(it.points))return null;let O=0,j=!1;for(const K of it.points)typeof K.y=="number"&&Number.isFinite(K.y)&&(O+=K.y,j=!0);return j?O:null}function rr(it,O,j,K){return it==="correlogram"?(Array.isArray(K.columns)?K.columns:[]).map(oe=>je(j,oe)):it==="heatmap"?(O.series||[]).map(he=>he.label):it==="gantt"?(O.rows||[]).map(he=>K.label?j.rows.text(he.key,K.label):String(he.key)):nr.has(it)?O.labels||[]:tr}const Xr=1e3,Qr=50;let qr=0;function eo(it){const O=it/1e3;return`${O>=10?Math.round(O):Math.round(O*10)/10}s`}function or(it){return`${it/1e3}s`}function Qt(it){return it&&it.defaultView||globalThis}function to(it,O){return O?typeof O=="string"?it.querySelector(O):O:null}function no(it,O,j){const K=["fill","fill-opacity","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linejoin","stroke-linecap","font-size","font-family","font-weight","opacity","text-anchor","dominant-baseline","visibility"],he=[it,...it.querySelectorAll("*")],oe=[O,...O.querySelectorAll("*")];for(let Se=0;Se<he.length&&Se<oe.length;Se++){const Oe=j.getComputedStyle(he[Se]),Ge=[];for(const Ke of K){const We=Oe.getPropertyValue(Ke);We&&Ge.push(`${Ke}:${We}`)}Ge.length&&oe[Se].setAttribute("style",Ge.join(";"))}}function ro(it,O){let j=it.root;const K=[];for(const he of O){const oe=(j.children||[]).find(Se=>Se.label===he);if(!oe||!oe.children||!oe.children.length)break;j=oe,K.push(he)}return K.length?{...it,root:j,path:K,empty:!j.children.length}:it}function oo(it,O,j){return it&&it.plot?it.plot:{left:0,top:0,right:O,bottom:j,width:O,height:j,gutter:{left:0,bottom:0,right:0,top:0}}}class ir{#r=++qr;#n;#l;#e;#i;#s=null;#o=null;#c=null;#y=null;#m=null;#z=!1;#w=null;#O=null;#x=[];#g=new Set;#t=null;#u={zoom:1,offset:[0,0]};#A=null;#P=null;#S=null;#L=0;#F=null;#$=null;#te=!1;#ne=!1;#a=null;#le=0;#V=null;#re=null;#be=!1;#E=!1;#I=new Map;#Z=An();#D=Wn();#xt=null;#p=null;#T=null;#h=null;#Y=null;#M=null;#f={x:null,y:null};#N={x:null,y:null};#B=!1;#v=[];#oe={first:0,last:0};#C=!1;#G=null;#j=null;#ie=!1;#ce=null;#U=null;#ue=0;#_=new ge;#J={bbox:null,span:360,width:0};#H=null;#ye=0;#b=null;#k={source:"client",asked:"auto",reason:"the chart has not drawn yet",pending:!1,measures:[]};constructor(O){this.#n=O.grid,this.#l=O.container,this.#e=O.spec,this.#i=O.container.ownerDocument,this.#Te(),this.#Le(),this.draw()}#Te(){Ft(this.#i);const O=this.#i;this.#s=st(O,"div",ot);const j=st(O,"figure",`${ot}__figure`);if(this.#e.title||this.#e.subtitle){const K=st(O,"figcaption",`${ot}__caption`);if(this.#e.title){const he=st(O,"div",`${ot}__title`);wt(he,this.#e.title),K.appendChild(he)}if(this.#e.subtitle){const he=st(O,"div",`${ot}__subtitle`);wt(he,this.#e.subtitle),K.appendChild(he)}j.appendChild(K)}if(this.#o=rt(O,"svg",{class:`${ot}__plot`,preserveAspectRatio:"xMidYMid meet",role:"img"}),this.#c=x(O,this.#o),j.appendChild(this.#o),this.#O=st(O,"div",`${ot}__empty`),this.#O.setAttribute("hidden",""),j.appendChild(this.#O),this.#w=st(O,"div",`${ot}__table`),j.appendChild(this.#w),this.#y=st(O,"div",`${ot}__legend`),j.appendChild(this.#y),this.#e.footnote){const K=st(O,"div",`${ot}__footnote`);wt(K,this.#e.footnote),j.appendChild(K)}this.#P=st(O,"div",`${ot}__attribution`),this.#P.setAttribute("hidden",""),j.appendChild(this.#P),this.#m=st(O,"div",`${ot}__tooltip`),this.#m.setAttribute("hidden",""),this.#s.appendChild(j),this.#s.appendChild(this.#m),this.#l.appendChild(this.#s),this.#Ce()}#Le(){const O=["model:changed","rows:changed","filter:changed","sort:changed","column:grouped","column:pivoted","cell:changed","timeline:seek","timeline:attached","timeline:detached"];this.#e.selection&&this.#x.push(this.#n.on("selection:changed",()=>this.#Me()));for(const K of O)this.#x.push(this.#n.on(K,()=>this.schedule()));const j=Qt(this.#i);j&&typeof j.ResizeObserver=="function"&&(this.#re=this.#l.getBoundingClientRect?this.#l.getBoundingClientRect():null,this.#V=new j.ResizeObserver(()=>{if(!this.#be){this.#be=!0;const K=this.#l.getBoundingClientRect?this.#l.getBoundingClientRect():null;if(K&&this.#re&&Math.round(K.width)===Math.round(this.#re.width)&&Math.round(K.height)===Math.round(this.#re.height))return}this.schedule()}),this.#V.observe(this.#l))}#we(){const O=this.#o&&this.#o.getBoundingClientRect?this.#o.getBoundingClientRect():null;return O&&O.width>0&&O.height>0?O:this.#l.getBoundingClientRect?this.#l.getBoundingClientRect():tn}#Ce(){const O=He=>{this.#A||this.#_e(He)},j=()=>this.#X();this.#o.addEventListener("pointermove",O),this.#o.addEventListener("pointerleave",j),this.#o.addEventListener("click",He=>this.#Se(He));const K=He=>{!this.#t||!this.#t.packed||this.#h&&this.#h.busy||(this.#A={x:He.clientX||0,y:He.clientY||0})},he=He=>{if(!this.#A)return;const bt=He.clientX||0,St=He.clientY||0;this.#Q(bt-this.#A.x,St-this.#A.y),this.#A={x:bt,y:St}},oe=()=>{this.#A=null},Se=He=>{!this.#t||!this.#t.packed||(He.preventDefault&&He.preventDefault(),this.#he(He.deltaY<0?1.15:1/1.15))},Oe=He=>{if(!this.#t||!this.#t.packed)return;const bt=40;if(He.shiftKey&&He.key==="ArrowLeft")this.#Q(-bt,0);else if(He.shiftKey&&He.key==="ArrowRight")this.#Q(bt,0);else if(He.shiftKey&&He.key==="ArrowUp")this.#Q(0,-bt);else if(He.shiftKey&&He.key==="ArrowDown")this.#Q(0,bt);else if(He.key==="+"||He.key==="=")this.#he(1.25);else if(He.key==="-"||He.key==="_")this.#he(1/1.25);else if(He.key==="0")this.#Ge();else return;He.preventDefault&&He.preventDefault()};this.#o.addEventListener("pointerdown",K),this.#o.addEventListener("pointermove",he),this.#o.addEventListener("pointerup",oe),this.#o.addEventListener("pointerleave",oe),this.#o.addEventListener("wheel",Se,{passive:!1}),this.#o.addEventListener("keydown",Oe);const Ge=()=>{if(!this.#C)return null;const He=jt(this.#e.zoom);return He.enabled?He:null},Ke=()=>!!(this.#h&&this.#h.busy)||!!jn(this.#e).mode,We=He=>{const bt=Ge();if(!bt||!bt.wheel||this.#t&&this.#t.packed)return;const St=Number(He.deltaY)||0;if(!St)return;const lt=this.#R(He);this.#W(St<0?"in":"out","wheel",this.#ht(lt)),He.preventDefault&&He.preventDefault()},qe=He=>{this.#ie=!1;const bt=Ge();!bt||!bt.pan||Ke()||this.#t&&this.#t.packed||!this.#f.x&&!this.#f.y||(this.#j={at:this.#R(He),moved:!1})},vt=He=>{if(!this.#j)return;const bt=this.#t&&this.#t.plot||null;if(!bt)return;const St=this.#R(He),lt=St.x-this.#j.at.x,Qe=St.y-this.#j.at.y,ht=bt.right-bt.left||1,Tt=bt.bottom-bt.top||1;!this.#j.moved&&Math.hypot(lt,Qe)<Dr||(this.#j.moved=!0,this.#ie=!0,this.#j.at=St,this.#ae((dn,Pn,Mn)=>dn==="x"?At(Pn,Mn,-lt/ht):At(Pn,Mn,Qe/Tt),"pan"),He.preventDefault&&He.preventDefault())},pt=()=>{this.#j=null},De=He=>{if(Ge()&&!(this.#t&&this.#t.packed)){if(He.key==="+"||He.key==="=")this.#W("in","key");else if(He.key==="-"||He.key==="_")this.#W("out","key");else return;He.preventDefault&&He.preventDefault()}},Ut=He=>{Ge()&&(this.#t&&this.#t.packed||(this.#W("reset","reset"),He.preventDefault&&He.preventDefault()))};this.#o.addEventListener("wheel",We,{passive:!1}),this.#o.addEventListener("pointerdown",qe),this.#o.addEventListener("pointermove",vt),this.#o.addEventListener("pointerup",pt),this.#o.addEventListener("pointerleave",pt),this.#o.addEventListener("keydown",De),this.#o.addEventListener("dblclick",Ut),this.#x.push(()=>{this.#o.removeEventListener("wheel",We),this.#o.removeEventListener("pointerdown",qe),this.#o.removeEventListener("pointermove",vt),this.#o.removeEventListener("pointerup",pt),this.#o.removeEventListener("pointerleave",pt),this.#o.removeEventListener("keydown",De),this.#o.removeEventListener("dblclick",Ut)}),this.#x.push(hr({svg:this.#o,overlay:this.#c.overlay,plot:()=>this.#t&&this.#t.plot||{left:0,top:0,right:0,bottom:0,height:0},pointOf:He=>this.#R(He),axis:()=>jn(this.#e).axis,horizontal:()=>!!(this.#t&&this.#t.horizontal),enabled:()=>!!jn(this.#e).mode&&!!(this.#t&&this.#t.xScale)&&!(this.#h&&this.#h.busy),onBrush:(He,bt)=>this.#Ie(He,bt)})),this.#o.setAttribute("tabindex","0"),this.#x.push(dr({svg:this.#o,marks:()=>[...this.#c.marks.childNodes||[]].filter(He=>He.setAttribute),onFocus:He=>this.#De(He),onActivate:He=>this.#Be(He)})),this.#x.push(()=>{this.#o.removeEventListener("pointermove",O),this.#o.removeEventListener("pointerleave",j),this.#o.removeEventListener("pointerdown",K),this.#o.removeEventListener("pointermove",he),this.#o.removeEventListener("pointerup",oe),this.#o.removeEventListener("pointerleave",oe),this.#o.removeEventListener("wheel",Se),this.#o.removeEventListener("keydown",Oe)})}#R(O){const j=this.#o.getBoundingClientRect?this.#o.getBoundingClientRect():{left:0,top:0,width:tn.width,height:tn.height};return{x:(O.clientX||0)-j.left,y:(O.clientY||0)-j.top}}#ke(O){return ue({bound:{categories:this.#se().categories},xScale:this.#t.xScale,at:this.#t.horizontal?O.y:O.x})}#se(){const O=this.#t;return O&&Array.isArray(O.labels)&&Array.isArray(O.categories)?{labels:O.labels,categories:O.categories}:{labels:this.#a&&this.#a.labels||[],categories:this.#a&&this.#a.categories||[]}}#ve(O){if(!this.#t||!Array.isArray(this.#t.series))return null;if(this.#t.reduced)return P({series:this.#t.series,xScale:this.#t.xScale,at:this.#t.horizontal?O.y:O.x});const j=this.#ke(O);return j<0?null:{index:j,entries:this.#t.series.map(K=>({series:K,point:K.points[j]})).filter(K=>K.point&&K.point.y!==null)}}#fe(O){return nn({drawn:this.#t,bound:this.#a,spec:this.#e,grid:this.#n,scheme:this.#Z,at:O})}#_e(O){if(!this.#t||!this.#a||this.#e.tooltip===!1)return;const j=this.#R(O),K=[];let he="";const oe=this.#fe(j);if(oe){this.#xe(oe.heading,oe.rows,O),this.emit("hover",{...oe.datum,native:O});return}if(en(this.#t)){this.#X();return}if(this.#t.arcs){const Oe=de({arcs:this.#t.arcs,x:j.x,y:j.y});if(!Oe){this.#X();return}he=Oe.label;const Ge=this.#a.root.total>0?Oe.total/this.#a.root.total:0;K.push({label:this.#a.measure.title,value:`${ee(Oe.total,this.#n.messages)} (${this.#n.messages.number(Ge,{style:"percent",maximumFractionDigits:1})})`,colour:this.#Z.series(Oe.index)})}else{const Oe=this.#ve(j);if(!Oe){this.#X();return}he=this.#se().labels[Oe.index]||"";for(const Ge of Oe.entries)K.push({label:Ge.series.label,value:ee(Ge.point.y,this.#n.messages),colour:this.#Z.series(Ge.series.index)})}if(!K.length){this.#X();return}this.#xe(he,K,O);const Se=this.#Ae(j);Se&&this.emit("hover",{...Se,native:O})}#xe(O,j,K){const he=this.#i;if(Zt(this.#m),O){const oe=st(he,"div",`${ot}__tooltip-row`),Se=st(he,"strong");wt(Se,O),oe.appendChild(Se),this.#m.appendChild(oe)}for(const oe of j){const Se=st(he,"div",`${ot}__tooltip-row`),Oe=st(he,"span",`${ot}__swatch`);Oe.setAttribute("style",`background:${oe.colour}`);const Ge=st(he,"span");wt(Ge,oe.label);const Ke=st(he,"span",`${ot}__tooltip-value`);wt(Ke,oe.value),cn(Se,[Oe,Ge,Ke]),this.#m.appendChild(Se)}this.#m.removeAttribute("hidden"),this.#Re(K)}#Re(O){if(!this.#z&&(this.#z=!0,this.#ze())){const qe=this.#i&&this.#i.body;qe&&typeof qe.appendChild=="function"&&qe.appendChild(this.#m)}const j=Qt(this.#i),K=12,he=O&&O.clientX||0,oe=O&&O.clientY||0,Se=typeof this.#m.getBoundingClientRect=="function"?this.#m.getBoundingClientRect():{width:0,height:0},Oe=j.innerWidth||0,Ge=j.innerHeight||0;let Ke=he+K;Oe&&Ke+Se.width>Oe-K&&(Ke=he-K-Se.width),Ke=Math.max(K,Ke);let We=oe+K;Ge&&We+Se.height>Ge-K&&(We=oe-K-Se.height),We=Math.max(K,We),this.#m.style.left=`${Math.round(Ke)}px`,this.#m.style.top=`${Math.round(We)}px`}#ze(){const O=Qt(this.#i);if(typeof O.getComputedStyle!="function")return!1;let j=this.#s&&this.#s.parentNode;for(;j;){if(j.nodeType===11&&j.host){j=j.host;continue}if(j.nodeType!==1)break;const K=O.getComputedStyle(j);if(K&&(K.transform&&K.transform!=="none"||K.perspective&&K.perspective!=="none"||K.filter&&K.filter!=="none"||K.backdropFilter&&K.backdropFilter!=="none"||K.contain&&/layout|paint|strict|content/.test(K.contain)))return!0;j=j.parentNode}return!1}#X(){this.#m&&this.#m.setAttribute("hidden",""),this.emit("leave",{})}#Ae(O){if(!this.#t||!this.#a)return null;const j=this.#fe(O);if(j)return j.datum;if(en(this.#t))return null;if(this.#t.arcs){const Oe=de({arcs:this.#t.arcs,x:O.x,y:O.y});return Oe?{label:Oe.label,value:Oe.total,category:Oe.node.value,column:this.#e.x||null,series:null,depth:Oe.depth,path:Array.isArray(Oe.path)?[...Oe.path]:[Oe.label],rowKeys:Oe.node.rowKey?[Oe.node.rowKey]:[]}:null}const K=this.#ve(O);if(!K)return null;const he=K.entries,oe=this.#se(),Se=he.length===1&&he[0].point.from!==void 0?{from:he[0].point.from,to:he[0].point.to}:null;return{label:oe.labels[K.index]||"",category:oe.categories[K.index],column:this.#a.dimension.col,value:he.length===1?he[0].point.y:null,...Se||{},series:he.map(Oe=>({key:Oe.series.key,label:Oe.series.label,value:Oe.point.y,rows:Oe.point.rows})),rowKeys:he.map(Oe=>Oe.point.rowKey).filter(Boolean)}}#Se(O){if(!this.#t||!this.#a||this.#h&&this.#h.busy)return;if(this.#ie){this.#ie=!1;return}const j=this.#Ae(this.#R(O));if(!j)return;let K=!1;const he=this.emit("click",{...j,native:O,preventDefault(){K=!0}});if(!(K||he.defaultPrevented)){if(this.#e.drill&&this.#a&&this.#a.root&&j.label){const oe=Array.isArray(j.path)&&j.path.length?j.path:[j.label];this.#p=[...this.#p||[],...oe],this.emit("drill",{path:[...this.#p],label:j.label}),this.draw();return}if(this.#e.selection&&Array.isArray(this.#t.markers)&&Array.isArray(j.rowKeys)&&j.rowKeys.length){this.#n.selection.set([...j.rowKeys]);return}if(this.#e.selection&&this.#e.type==="network"&&Array.isArray(j.rowKeys)&&j.rowKeys.length){this.#n.selection.set([...new Set(j.rowKeys)]);return}!this.#e.filterOnClick||!j.column||this.#n.filters.set({col:j.column,op:"eq",value:j.category})}}#Me(){if(!this.#t)return;if(Array.isArray(this.#t.markers)){this.#Fe();return}if(Array.isArray(this.#t.links)&&Array.isArray(this.#t.nodes)&&!this.#t.series){ln({drawn:this.#t,keys:new Set(this.#n.selection.keys())});return}if(!this.#t.series)return;const O=this.#n.selection.keys(),j=this.#a&&this.#a.dimension&&this.#a.dimension.col,K=new Set;if(j)for(const he of O)K.add(r(this.#n.rows.value(he,j)));fr({groups:this.#c,series:this.#t.series,keys:new Set(O),categories:K})}#Fe(){const O=new Set(this.#n.selection.keys());for(const j of this.#t.markers){const K=j.element;!K||!K.setAttribute||(O.size&&!O.has(j.rowKey)?K.setAttribute("data-dim","true"):K.removeAttribute("data-dim"))}}#Ie(O,j){const K=jn(this.#e),he=K.mode;if(!he||!this.#t||!this.#t.xScale||!this.#a)return;const oe=gr({bound:this.#a,xScale:this.#t.xScale,yScale:this.#t.yScale,rightScale:this.#t.rightScale||null,axis:K.axis,from:O,to:j});let Se=!1;const Oe=this.emit("brush",{mode:he,kind:oe.kind,values:oe.values,range:oe.range,axis:oe.axis,column:oe.axis==="y"||oe.axis==="y2"?this.#a.measure&&this.#a.measure.col||null:this.#a.dimension.col,preventDefault(){Se=!0}});if(Se||Oe.defaultPrevented)return;if(he==="zoom"){if(oe.range){const Ke=oe.axis==="y2"?"y2":oe.axis==="y"?"y":"x";this.#e={...this.#e,axis:{...this.#e.axis||{},[Ke]:{...(this.#e.axis||{})[Ke]||{},min:Math.min(oe.range[0],oe.range[1]),max:Math.max(oe.range[0],oe.range[1])}}},this.draw()}return}if(he==="select"){const Ke=[];for(const We of this.#t.series||[])for(const qe of We.points){if(!qe.rowKey)continue;(oe.kind!=="set"||oe.values.some(pt=>r(pt)===qe.xKey))&&Ke.push(qe.rowKey)}this.#n.selection.set([...new Set(Ke)]);return}const Ge=mr({column:this.#a.dimension.col,result:oe,kind:this.#a.kind});Ge&&this.#n.filters.set(Ge)}#De(O){const j=(this.#c.marks.childNodes||[])[O];if(!j||!j.setAttribute)return;const K=this.#t&&this.#t.series?this.#t.series[Number(j.getAttribute("data-series"))||0]:null,he=K&&K.points[Number(j.getAttribute("data-point"))||0];if(!he){if(!j.getBoundingClientRect)return;const oe=j.getBoundingClientRect(),Se=this.#fe(this.#R({clientX:oe.left+oe.width/2,clientY:oe.top+oe.height/2}));if(!Se)return;j.setAttribute("role","img"),j.setAttribute("aria-label",`${Se.heading}: ${Se.rows.map(Oe=>Oe.value).filter(Boolean).join(", ")}`),this.emit("focus",{label:Se.datum.label,value:Se.datum.value,index:O});return}j.setAttribute("role","img"),j.setAttribute("aria-label",`${he.label}: ${ee(he.y,this.#n.messages)}`),this.emit("focus",{label:he.label,value:he.y,index:O})}#Be(O){const j=(this.#c.marks.childNodes||[])[O];if(!j||!j.getBoundingClientRect)return;const K=j.getBoundingClientRect();this.#Se({clientX:K.left+K.width/2,clientY:K.top+K.height/2})}#Ne(O){const j=O&&O.attribution||"";j?(wt(this.#P,j),this.#P.removeAttribute("hidden")):this.#P.setAttribute("hidden","");const K=O&&Number.isFinite(O.aspect)&&O.aspect>0?O.aspect:null;this.#o&&this.#o.style&&(K?this.#o.style.setProperty("aspect-ratio",String(K)):this.#o.style.removeProperty("aspect-ratio"))}#Ge(){this.#u={zoom:1,offset:[0,0]},this.#b&&this.#b.refit&&(this.#b=null),this.#q(),this.schedule()}#he(O){const j=this.#u.zoom*O;this.#u={...this.#u,zoom:Math.min(8,Math.max(1,j))},this.schedule()}#Q(O,j){const K=this.#t&&this.#t.scale||0;if(!K)return;const[he,oe]=this.#u.offset;this.#u={...this.#u,offset:[he-O/K,oe+j/K]},this.schedule()}#q(){const O=Qt(this.#i);if(O.clearTimeout&&O.clearTimeout(this.#L),this.#L=0,this.#$=null,!this.#S||!this.#F){this.#S=null;return}this.#S=null;const j=this.#n&&this.#n.filters;if(!j||typeof j.get!="function"||typeof j.set!="function")return;const K=j.get(),he=rn(K,this.#F);he!==K&&j.set(he)}#Ue(O){const j=Kt(this.#e.viewportFilter),K=this.#t,he=et.has(O)&&!!K&&!!K.anchor;if(!j.enabled||!he){this.#q();return}const oe=on(this.#e,j.column);if(!oe){this.#q();return}const Se=this.#F;Se&&(Se.kind!==oe.kind||Se.column!==oe.column||Se.lon!==oe.lon||Se.lat!==oe.lat)&&this.#q(),this.#F=oe;const Oe=this.#n&&this.#n.filters;if(!Oe||typeof Oe.get!="function"||typeof Oe.set!="function")return;const Ge=Oe.get(),Ke=_t(Ge,oe);if(Ke&&!yt(Ke,this.#S)){this.#$={zoom:this.#u.zoom,offset:[...this.#u.offset]},this.#S=Ke,this.#He(Ke);return}Ke||(this.#S=null);const[We,qe]=this.#u.offset;if(this.#u.zoom===1&&We===0&&qe===0){this.#$=null;return}const vt=this.#$;if(vt&&this.#u.zoom===vt.zoom&&We===vt.offset[0]&&qe===vt.offset[1])return;const pt=hn(K.anchor,K.plot);if(!pt||yt(pt,this.#S)){this.#$={zoom:this.#u.zoom,offset:[We,qe]};return}this.#$={zoom:this.#u.zoom,offset:[We,qe]};const De=Qt(this.#i);De.clearTimeout&&De.clearTimeout(this.#L);const Ut=typeof De.setTimeout=="function"?De.setTimeout.bind(De):setTimeout;this.#L=Ut(()=>{this.#L=0;const He=Oe.get(),bt=this.#n.messages&&typeof this.#n.messages.t=="function"?this.#n.messages.t("chart.viewportFilter.label"):void 0,St=fn(He,oe,En(oe,pt,bt));this.#S=pt,Oe.set(St)},j.debounce)}#He(O){const j=this.#t;if(!j||!j.anchor||!j.plot)return;const K=hn(j.anchor,j.plot);if(this.#H&&this.#b&&!this.#e.shapes&&s(K,O)){const[oe,Se,Oe,Ge]=O;this.#b={baseKey:this.#H.baseKey,rings:[[[oe,Se],[Oe,Se],[Oe,Ge],[oe,Ge]]],refit:!0},this.#u={zoom:1,offset:[0,0]},this.schedule();return}const he=Ct(K,O,j.plot,{zoom:this.#u.zoom,offset:this.#u.offset,scale:j.scale});he&&(this.#u=he,this.schedule())}schedule(){if(this.#E||this.#le)return;const O=Qt(this.#i),j=typeof O.requestAnimationFrame=="function"?O.requestAnimationFrame.bind(O):K=>setTimeout(K,16);this.#le=j(()=>{this.#le=0,this.draw()})||1}draw(){if(this.#E)return;const O=this.#Oe();if(!O)return;const j=this.#we(),K=Math.round(j.width||tn.width),he=Math.round(j.height||tn.height),oe=K!==O.width||he!==O.height?this.#Oe():O;oe&&this.emit("draw",{chartType:oe.chartType,categories:oe.categories,empty:oe.empty})}#Oe(){const O=this.#we(),j=Math.round(O.width||tn.width),K=Math.round(O.height||tn.height),he=_n.includes(this.#e.type)?null:Vn(this.#e.type),oe=_n.includes(this.#e.type)||he?this.#e.type:"bar";Array.isArray(this.#e.x)&&Dt(`chart:${this.#r}:x:array`,`chart "x" expects one column id (a string) and was given an array [${this.#e.x.map(lt=>JSON.stringify(lt)).join(", ")}]. A chart takes one category column on "x". For a hierarchy, group the grid — grid.columns.group([...]) — and the hierarchical types (pie, donut, sunburst, treemap) read the grouping.`);const Se=An(this.#e);this.#Z=Se;const Oe=f(this.#e.axis),Ge=this.#n.messages,Ke=Wn(this.#e);this.#D=Ke;const We=Ke.small,qe=ur(this.#e);if(qe.show&&!Qn.has(oe)&&!(he&&he.labelled)&&!this.#te){this.#te=!0;const lt=this.#i&&this.#i.defaultView,Qe=lt&<.console||(typeof globalThis<"u"?globalThis.console:null);Qe&&typeof Qe.warn=="function"&&Qe.warn(`[lattice] a "${oe}" chart does not draw data labels; "labels" has no effect on it. Types that do: ${[...Qn].join(", ")}.`)}Xt(this.#o,{viewBox:`0 0 ${j} ${K}`,width:j,height:K});const vt=Gr.has(oe)||!!(he&&he.hierarchical),pt=this.#pt(oe);if(pt===Fn)return null;pt&&pt.over&&Dt(`chart:viewportCap:over:${this.#r}`,`this map's view holds ${pt.over.count} matching rows, more than its viewportCap of ${pt.over.cap}, and ${pt.over.reason}, so it draws none of them. Zoom in, narrow the filter, or raise viewportCap.`);let De;if(he&&Ue({grid:this.#n,spec:this.#e,type:oe,id:this.#r}),pt)De=pt;else if(he&&typeof he.bind=="function")De=he.bind(this.#n,this.#e),h.has(oe)&&(De=this.#wt(oe,De));else if(vt)De=C(this.#n,this.#e),this.#p&&this.#p.length&&(De=ro(De,this.#p));else if(Kr.has(oe))De=_(this.#n,oe==="candlestick"?this.#Ke():this.#e);else if(er.has(oe)&&Array.isArray(this.#e.measures)&&this.#e.measures.length)De=_(this.#n,this.#e);else if(Vr.has(oe))De=F(this.#n,this.#e,oe==="network"?{perRow:!0,nodes:this.#e.nodes}:void 0);else if(Zr.has(oe)){const lt=q(this.#n);De={rows:lt,series:[],categories:[],labels:[],measure:{col:null,fn:"sum",title:""},dimension:{col:this.#e.label||null,title:""},empty:!lt.length}}else oe==="geomap"?De=re(this.#n,{...this.#e,x:this.#e.code||this.#e.x}):Array.isArray(this.#e.points)?De=J(this.#e):Hr.has(oe)?De=re(this.#n,Wr(this.#e)):De=re(this.#n,this.#e);const Ut=$(Oe&&Oe.x,Date.now());this.#a=De;const He=Q(De,Oe&&Oe.x,oe,Ut);if(He){const lt=typeof this.#e.x=="string"?` "${this.#e.x}"`:"",Qe=`${Math.round(y*1e3)/10}%`;Dt(`chart:${this.#r}:x:window:ahead`,`${He.count} reading(s) on the x axis${lt} were not drawn: stamped up to ${eo(He.lead)} ahead of this device's clock, which is more than the ${or(He.limit)} (${Qe} of the ${or(He.span)} rolling window) a reading may run ahead and still move the window. This is a producer whose clock is wrong, not a window that is too narrow: letting that reading carry the window would push every other producer's recent readings out of it, so it is left out instead. Correct the producer's clock (NTP), or stamp readings where they are received.`)}const bt=G({grid:this.#n,spec:this.#e,type:oe,bound:De,axis:Oe,now:Ut,id:this.#r});if(!bt.ok)return bt.tell&&Dt(bt.key,bt.message),this.#Xe(this.#e.emptyText||Ge.t("chart.empty")),null;if(De=B(De,Oe&&Oe.x,oe,Ut),De=this.#st(De,oe,Oe,Ut),this.#a=De,this.#O.setAttribute("hidden",""),this.#o.removeAttribute("hidden"),l(this.#c,null),oe!=="candlestick"&&(zt(this.#c),this.#de()),he){const lt=he.freeform?n({width:j,height:K,fontSize:We,margin:this.#e.margin}):n({width:j,height:K,fontSize:We,margin:this.#e.margin,titleSize:Ke.axisTitle,titles:{left:Oe.y.title,bottom:Oe.x.title,right:Oe.y2.title},yLabels:tr,xLabels:De.labels,rotated:!0});if(this.#t=he.draw({doc:this.#i,groups:this.#c,plot:lt,bound:De,type:oe,grid:this.#n,fontSize:We,hidden:this.#g,scheme:Se,axis:Oe,typography:Ke,labels:qe,spec:this.#e,geoView:{zoom:this.#u.zoom,offset:this.#u.offset},helpers:Ir})||{},this.#d(Array.isArray(this.#t.legend)?this.#t.legend:[],this.#Pe(this.#t,De.measure&&De.measure.col)),De.over){const Qe=new i(this.#c.overlay),ht=Qe.next("text",`${ot}__geo-note`);Xt(ht,{x:sn(lt.left),y:sn(lt.bottom),"text-anchor":"start"}),wt(ht,Ge.t("chart.viewportOverCap",{count:De.over.count,cap:De.over.cap})),Qe.finish()}this.#kt(oe)}else if(oe==="treemap"){const lt=n({width:j,height:K,fontSize:We,padding:2,margin:this.#e.margin});this.#t=Ne({scheme:Se,groups:this.#c,plot:lt,tree:De,grid:this.#n,hidden:this.#g,fontSize:We,typography:Ke,labels:qe}),this.#d(De.root.children.map((Qe,ht)=>({key:Qe.label,label:Qe.label,index:ht})))}else if(Br.has(oe)){const lt=n({width:j,height:K,fontSize:We});this.#t=Me({scheme:Se,doc:this.#i,groups:this.#c,plot:lt,tree:De,type:oe,grid:this.#n,hidden:this.#g,fontSize:We,typography:Ke,labels:qe,centre:this.#e.centre});const Qe=this.#n.columns&&De.measure&&De.measure.col?this.#n.columns.get(De.measure.col):null;this.#d(De.root.children.map((ht,Tt)=>({key:ht.label,label:ht.label,index:Tt,value:L(ht.total,Qe,this.#n),colour:Se.series(Tt,ht.label)})))}else{const lt=Yr.has(oe)?n({width:j,height:K,fontSize:We,margin:this.#e.margin,yLabels:oe==="heatmap"?rr(oe,De,this.#n,this.#e):[],xLabels:oe==="heatmap"?De.labels:[],rotated:!0}):n({width:j,height:K,fontSize:We,margin:this.#e.margin,titleSize:Ke.axisTitle,ySide:te[oe]&&!te[oe].horizontal&&Oe.y.position==="right"?"right":"left",titles:te[oe]&&te[oe].horizontal?{left:Oe.x.title,bottom:Oe.y.title,right:Oe.y2.title}:te[oe]&&Oe.y.position==="right"?{left:Oe.y2.title,bottom:Oe.x.title,right:Oe.y.title}:{left:Oe.y.title,bottom:Oe.x.title,right:Oe.y2.title},rightGutter:this.#Ye(oe,De)?Math.round(We*3):0,yLabels:rr(oe,De,this.#n,this.#e),xLabels:nr.has(oe)?[]:De.labels,rotated:!0}),Qe={doc:this.#i,groups:this.#c,plot:lt,bound:De,type:oe,grid:this.#n,fontSize:We,hidden:this.#g,scheme:Se,axis:Oe,typography:Ke,labels:qe,byRuleColour:!this.#e.series};if(oe!=="geomap"&&this.#Ne(null),this.#e.multiples)this.#t=this.#Ze(Qe),this.#d([]);else if(oe==="combo"||oe==="pareto")this.#t=dt({...Qe,pareto:oe==="pareto",reference:this.#e.reference,annotations:this.#e.annotations,emphasis:this.#e.emphasis,seriesStyle:this.#e.seriesStyle}),this.#d(this.#ee(this.#t.series,De.measure&&De.measure.col));else if(oe==="heatmap")this.#t=xe({...Qe,diverging:this.#e.diverging}),this.#d([],this.#Pe(this.#t,De.measure&&De.measure.col));else if(oe==="radar")this.#t=It(Qe),this.#d(this.#ee(De.series,De.measure&&De.measure.col));else if(oe==="gauge")this.#t=$t({...Qe,min:this.#e.min,max:this.#e.max,target:this.#e.target}),this.#d([]);else if(oe==="sankey")this.#t=mn(Qe),this.#d([]);else if(oe==="chord")this.#t=yn(Qe),this.#d([]);else if(oe==="network")this.#t=On({...Qe,iterations:this.#e.iterations,icon:this.#e.icon,linkWidth:this.#e.linkWidth}),this.#d(Array.isArray(this.#t.legend)?this.#t.legend:[]);else if(oe==="stream")this.#t=xn(Qe),this.#d(this.#ee(De.series,De.measure&&De.measure.col));else if(oe==="marimekko")this.#t=vn(Qe),this.#d(this.#ee(De.series,De.measure&&De.measure.col));else if(oe==="violin")this.#t=Tn(Qe),this.#d([]);else if(oe==="gantt")this.#t=gn({...Qe,spec:this.#e,rows:De.rows||[]}),this.#d([]);else if(oe==="geomap")this.#t=Ve({...Qe,shapes:this.#e.shapes,codeProperty:this.#e.codeProperty,diverging:this.#e.diverging,projection:this.#e.projection,projectionOptions:this.#e.projectionOptions,layer:this.#e.layer,graticule:this.#e.graticule,basemap:this.#e.basemap,zoom:this.#u.zoom,centreOffset:this.#u.offset}),this.#d([]),this.#Ne(this.#t);else if(oe==="correlogram")this.#t=V({...Qe,columns:this.#qe(),method:this.#e.method,values:this.#e.values}),this.#d([]);else if(oe==="forest")this.#t=H(Qe),this.#d([]);else if(oe==="funnel")this.#t=Pe(Qe),this.#d([]);else if(oe==="candlestick")this.#t=Jt({...Qe,volume:this.#de(),volumeHeight:this.#We()}),this.#d([]);else if(Ur.has(oe)){if(oe==="histogram")this.#t=se({...Qe,buckets:this.#e.buckets,curve:this.#e.curve});else if(oe==="movingRange")this.#t=be(Qe);else if(oe==="control"||oe==="capability"){const ht=this.#e.y||this.#e.measure,Tt=this.#n&&this.#n.statistics;this.#t=(oe==="capability"?we:Ae)({...Qe,capability:Tt&&ht?Tt.capability(ht,{by:this.#e.x,baseline:this.#e.baseline,rules:this.#e.rules,confidence:this.#e.confidence,...this.#e.spec||{}}):null})}else oe==="qq"?this.#t=le(Qe):oe==="ecdf"?this.#t=ne(Qe):oe==="lorenz"?this.#t=ae(Qe):this.#t=ve(Qe);this.#d([])}else{this.#t=Z({...Qe,fit:this.#e.fit,trend:this.#e.trend,band:this.#e.band,error:this.#e.error,dense:pr({series:De.series,canvas:this.#e.canvas}),downsampleTo:this.#e.downsample,stack:this.#e.stack,reference:this.#e.reference,annotations:this.#e.annotations,sizes:this.#Je(De),emphasis:this.#e.emphasis,seriesStyle:this.#e.seriesStyle});const ht=Array.isArray(this.#t.legend)?this.#t.legend:null;this.#d(ht||(De.series.length>1?this.#ee(De.series,De.measure&&De.measure.col,Tt=>Se.series(Tt.index,Tt.label)):[]))}}const St=this.#t&&this.#t.errorBars;if(this.#e.error&&St&&St.marks&&!this.#ne&&(!St.drawn||St.singleSkipped)){this.#ne=!0;const lt=this.#i&&this.#i.defaultView,Qe=lt&<.console||(typeof globalThis<"u"?globalThis.console:null);if(Qe&&typeof Qe.warn=="function"){let ht;St.drawn?ht=`[lattice] error bars were requested but ${St.singleSkipped} of ${St.marks} marks have a single reading behind them, so their whiskers were not drawn; the other marks are shown. A bar with no whisker is easily read as the certain one: bind those categories to the readings they summarise, or supply a margin column with \`error: { of: "column" }\`.`:ht=St.single===St.marks?'[lattice] error bars were requested but every mark has a single reading behind it, so there is no spread to compute. A chart bound to a summary or derived grid sees one row per mark: bind it to the rows the summary was computed from, or supply a margin column with `error: { of: "column" }`.':"[lattice] error bars were requested but no mark had enough readings to compute an interval.",Qe.warn(ht)}}return this.#t&&(this.#t.plot=this.#t.plot||oo(this.#t,j,K)),this.#a&&(this.#a.outside=this.#t&&this.#t.outside||0),this.#e.selection&&this.#Me(),this.#je(),this.#rt(oe,De,vt),this.#it(oe),this.#Ue(oe),this.#ct(),this.#Ve(Oe),{width:j,height:K,chartType:oe,categories:De.categories||[],empty:!!De.empty}}#de(){const O=this.#e.volume;if(O==null||O==="")return null;const j=this.#e.type;return j!=="candlestick"?(Dt(`chart:${this.#r}:volume:type:${j}`,`"volume" adds a volume pane under a candlestick's price pane, and this chart's type is ${JSON.stringify(j)}, so no volume pane was drawn. Set type: 'candlestick', or draw the volume as its own bar chart.`),null):typeof O!="string"||!this.#n.columns||!this.#n.columns.get(O)?(Dt(`chart:${this.#r}:volume:missing-column`,`"volume" names ${JSON.stringify(O)}, which is not a column of this grid, so the candlestick was drawn without a volume pane. Name the column that holds each period's traded volume by its id.`),null):O}#We(){const O=this.#e.volumePane,j=O&&typeof O=="object"?O.height:void 0;return j===void 0?$e:typeof j=="number"&&j>0&&j<1?j:(Dt(`chart:${this.#r}:volumePane:height`,`"volumePane.height" is the volume pane's share of the plot's height, a number above 0 and below 1, and was given ${JSON.stringify(j)}, so the default of ${$e} was used.`),$e)}#Ke(){const O=this.#de(),j=Array.isArray(this.#e.measures)?this.#e.measures:[];if(!O||j.length<4)return this.#e;const K=oe=>typeof oe=="string"?oe:oe&&oe.col,he=j.slice(4).filter(oe=>K(oe)!==O);return{...this.#e,measures:[...j.slice(0,4),{col:O,fn:"sum"},...he]}}#Ve(O){const j=pe(O&&O.x),K=j?Math.min(Xr,Math.max(Qr,Math.floor(j/4))):0;if(this.#E||!K){this.#me();return}if(this.#U&&this.#ue===K)return;this.#me(),this.#ue=K;const he=Qt(this.#i),oe=he&&typeof he.setInterval=="function"?he.setInterval.bind(he):setInterval;this.#U=oe(()=>{this.#E||this.#i&&this.#i.hidden||this.#s&&this.#s.isConnected===!1||this.schedule()},K);const Se=this.#U;Se&&typeof Se.unref=="function"&&Se.unref()}#me(){if(this.#U===null)return;const O=Qt(this.#i);(O&&typeof O.clearInterval=="function"?O.clearInterval.bind(O):clearInterval)(this.#U),this.#U=null,this.#ue=0}#Ze(O){const j=Be(O.bound),K=Ce({count:j.length,plot:O.plot}),he=[];for(const Ke of O.bound.series)for(const We of Ke.points)he.push(We.y);const oe=a(he,{zero:O.type!=="line"}),Se=new i(this.#c.overlay);l(this.#c,O.plot);const Oe=new i(this.#c.marks);new i(this.#c.grid).finish(),new i(this.#c.axis).finish(),new i(this.#c.rules).finish();let Ge=null;for(let Ke=0;Ke<K.length;Ke++){const We=K[Ke],qe=j[Ke],vt={left:We.x,top:We.y,width:We.width,height:We.height,right:We.x+We.width,bottom:We.y+We.height,gutter:{left:0,bottom:0}};Ge=Z({...O,plot:vt,bound:qe.bound,domain:oe,pool:Oe,axes:!1});const pt=Se.next("text",`${ot}__panel-title`);Xt(pt,{x:sn(We.x),y:sn(We.y-4),"text-anchor":"start"}),wt(pt,qe.label)}return Oe.finish(),Se.finish(),{...Ge||{},panels:K,multiples:!0}}#Ye(O,j){return O==="combo"||O==="pareto"?!0:!er.has(O)||O==="horizontalBar"||O==="waterfall"?!1:!!(j&&Array.isArray(j.series)&&j.series.some(K=>K.axis==="right"&&!this.#g.has(K.key)))}#Je(O){if(this.#e.type!=="bubble"||!this.#e.size)return null;const j=[];for(const he of O.series||[])for(const oe of he.points)typeof oe.size=="number"&&j.push(oe.size);const K=Zn(j);return K?T(K,[3,Math.max(6,Math.min(28,this.#e.maxRadius||22))]):null}#Xe(O){this.#je(),wt(this.#O,O),this.#O.removeAttribute("hidden"),this.#o.setAttribute("hidden","");for(const j of Object.values(this.#c))Zt(j);Zt(this.#y),Zt(this.#w),this.#t=null}#je(){const O=this.#n.licence;if(!!!(O&&typeof O.watermark=="function"&&O.watermark())){this.#T&&this.#T.parentNode&&this.#T.parentNode.removeChild(this.#T),this.#T=null;return}if(this.#T&&this.#T.parentNode)return;const K=this.#i,he=st(K,"div",`${ot}__watermark`);he.setAttribute("role","note");const oe=st(K,"a",`${ot}__watermark-link`);oe.setAttribute("href","https://www.latticegrid.dev"),oe.setAttribute("target","_blank"),oe.setAttribute("rel","noopener noreferrer"),wt(oe,this.#n.messages.t("licence.watermark")),he.appendChild(oe),this.#T=he,this.#s&&this.#s.appendChild(he)}#Qe(){const O=this.#e.legend;if(O===!1)return{show:!1,position:"bottom",align:"start",shape:"square",maxItems:0,isolate:!1,values:!1,title:""};const j=O&&typeof O=="object"?O:{};return{show:!0,position:["top","bottom","left","right"].includes(j.position)?j.position:"bottom",align:["start","centre","center","end"].includes(j.align)?j.align:"start",shape:["square","circle","line"].includes(j.shape)?j.shape:"square",maxItems:Number.isFinite(j.maxItems)&&j.maxItems>0?Number(j.maxItems):0,isolate:!!j.isolate,values:!!j.values,title:typeof j.title=="string"?j.title:""}}#ee(O,j,K){const he=j&&this.#n.columns?this.#n.columns.get(j):null;return(O||[]).map(oe=>({key:oe.key,label:oe.label,index:oe.index,value:L(Jr(oe),he,this.#n),...K?{colour:K(oe)}:{}}))}#qe(){const O=this.#e.columns;if(Array.isArray(O)&&O.length)return O.slice(0,qn);const j=this.#n;return!j||!j.columns||typeof j.columns.visible!="function"?[]:j.columns.visible().filter(K=>!K.generated&&(K.type==="number"||K.type==="currency"||K.type==="percent"||K.type==="integer")).map(K=>K.id).slice(0,qn)}#d(O,j=null){Zt(this.#y);const K=this.#Qe();if(Xt(this.#y,{"data-position":K.position,"data-align":K.align}),!K.show||!O.length&&!j)return;const he=this.#i;if(j&&this.#y.appendChild(this.#et(j,K)),!O.length)return;const oe=K.maxItems?O.slice(0,K.maxItems):O;for(const Se of oe){const Oe=st(he,"button",`${ot}__legend-item`);Oe.setAttribute("type","button");const Ge=!this.#g.has(Se.key);Oe.setAttribute("aria-pressed",Ge?"true":"false");const Ke=st(he,"span",`${ot}__swatch ${ot}__swatch--${K.shape}`);Ke.setAttribute("style",`background:${Se.colour||this.#Z.series(Se.index)}`);const We=st(he,"span");an(We,this.#D.small),wt(We,K.values&&Se.value?`${Se.label} ${Se.value}`:Se.label),cn(Oe,[Ke,We]),Oe.addEventListener("click",()=>{this.#tt(Se,O,K)}),this.#y.appendChild(Oe)}if(K.maxItems&&O.length>oe.length){const Se=st(he,"span",`${ot}__legend-more`);an(Se,this.#D.small),wt(Se,this.#n.messages.t("chart.legendMore",{count:O.length-oe.length})),this.#y.appendChild(Se)}}#et(O,j){const K=this.#i,he=st(K,"div",`${ot}__legend-ramp`);if(j.title){const Ke=st(K,"span",`${ot}__legend-ramp-title`);an(Ke,this.#D.small),wt(Ke,j.title),he.appendChild(Ke)}const oe=st(K,"span",`${ot}__legend-ramp-label`);an(oe,this.#D.small),wt(oe,O.minLabel);const Se=st(K,"span",`${ot}__legend-ramp-bar`),Oe=j.position==="left"||j.position==="right";Se.setAttribute("style",`background:linear-gradient(${Oe?"to top":"to right"}, ${O.colours.join(",")})`);const Ge=st(K,"span",`${ot}__legend-ramp-label`);return an(Ge,this.#D.small),wt(Ge,O.maxLabel),cn(he,[oe,Se,Ge]),he}#Pe(O,j){if(!O||typeof O.ramp!="function"||!O.domain)return null;const{min:K,max:he}=O.domain;if(!Number.isFinite(K)||!Number.isFinite(he))return null;const oe=j&&this.#n.columns?this.#n.columns.get(j):null,Se=6,Oe=[];for(let Ge=0;Ge<Se;Ge++){const Ke=Ge/(Se-1);Oe.push(O.ramp(K+(he-K)*Ke))}return{colours:Oe,minLabel:L(K,oe,this.#n),maxLabel:L(he,oe,this.#n)}}#tt(O,j,K){if(K.isolate){const he=j.filter(Se=>Se.key!==O.key),oe=he.every(Se=>this.#g.has(Se.key))&&!this.#g.has(O.key);if(this.#g.clear(),!oe)for(const Se of he)this.#g.add(Se.key)}else this.#g.has(O.key)?this.#g.delete(O.key):this.#g.add(O.key);this.emit("legend",{label:O.label,key:O.key,hidden:this.#g.has(O.key),hiddenKeys:[...this.#g]}),this.draw()}#nt(){const O=this.#n.messages,j=this.#k.viewport;return j?j.over?O.t("chart.viewportOverCap",{count:j.matched,cap:j.cap}):j.binned?O.t(j.computed==="client"?"chart.summaryClientDensity":"chart.summaryEngineDensity",{count:j.matched,cap:j.cap,cells:j.cells}):O.t("chart.summaryEngineViewport",{count:j.rows}):O.t("chart.summaryEngine")}#rt(O,j,K){const he=this.#n.messages,oe=j.measure&&j.measure.title||"",Se=j.dimension&&j.dimension.title||"",Oe=oe?Se&&!K?"chart.summary":"chart.summaryShare":"chart.summaryType",Ge=he.t(Oe,{type:he.t(`chart.type.${O}`),measure:oe,dimension:Se}),Ke=this.#k.source==="engine"||this.#k.viewport?this.#nt():"",We=Ke?`${Ge}. ${Ke}`:Ge;Xt(this.#o,{"aria-label":We}),Zt(this.#w);const qe=this.#i,vt=st(qe,"table"),pt=st(qe,"caption");wt(pt,he.t("chart.dataTable")),vt.appendChild(pt);const De=st(qe,"tr"),Ut=st(qe,"th");wt(Ut,K?"":Se),De.appendChild(Ut);const He=[];if(K&&j.root){for(const Qe of j.root.children){const ht=st(qe,"tr"),Tt=st(qe,"th");wt(Tt,Qe.label);const dn=st(qe,"td");wt(dn,ee(Qe.total,he)),cn(ht,[Tt,dn]),He.push(ht)}const lt=st(qe,"th");wt(lt,oe),De.appendChild(lt)}else{const lt=this.#se(),Qe=this.#t&&Array.isArray(this.#t.labels)&&Array.isArray(this.#t.series)&&Array.isArray(this.#t.categories)?this.#t.series:j.series||[];for(const ht of Qe){const Tt=st(qe,"th");wt(Tt,ht.label),De.appendChild(Tt)}for(let ht=0;ht<(lt.labels||[]).length;ht++){const Tt=st(qe,"tr"),dn=st(qe,"th");wt(dn,lt.labels[ht]),Tt.appendChild(dn);for(const Pn of Qe){const Mn=st(qe,"td"),In=Pn.points[ht];wt(Mn,In&&In.y!==null?ee(In.y,he):""),Tt.appendChild(Mn)}He.push(Tt)}}vt.appendChild(De);for(const lt of He)vt.appendChild(lt);this.#w.appendChild(vt);const bt=this.#t&&Number(this.#t.unplaced);if(bt>0){const lt=st(qe,"p",`${ot}__table-note`);wt(lt,he.t("chart.geoUnmatched",{count:bt})),this.#w.appendChild(lt)}const St=this.#t&&this.#t.annotations;if(Array.isArray(St)&&St.length){const lt=st(qe,"ul",`${ot}__annotation-list`);for(const Qe of St){if(!Qe||!Qe.text)continue;const ht=st(qe,"li");wt(ht,Qe.text),lt.appendChild(ht)}lt.childNodes&<.childNodes.length&&this.#w.appendChild(lt)}}on(O,j){return typeof j!="function"?()=>{}:(this.#I.has(O)||this.#I.set(O,new Set),this.#I.get(O).add(j),()=>{const K=this.#I.get(O);K&&K.delete(j)})}emit(O,j){const K={...j,type:O,chart:this,grid:this.#n},he=this.#e[`on${O.charAt(0).toUpperCase()}${O.slice(1)}`],oe=[...this.#I.get(O)||[]];typeof he=="function"&&oe.unshift(he);for(const Se of oe)try{Se(K)}catch(Oe){const Ge=Qt(this.#i);Ge.console&&typeof Ge.console.error=="function"&&Ge.console.error(`[lattice] a chart "${O}" listener threw`,Oe)}return K}#ot(){const O=this.#t;return O&&O.anchor&&et.has(this.#e.type)?{plot:O.plot,xScale:O.anchor.xScale,yScale:O.anchor.yScale}:O}#it(O){const j=ze(this.#e.annotate),K=j.enabled&&et.has(O)&&!!this.#t&&!this.#t.anchor;K&&Dt(`chart:${this.#r}:annotate:projection`,`"annotate" anchors a drawing on a ${JSON.stringify(O)} in longitude and latitude, and this map is drawn through a projection with no written inverse, so no rail was added. Draw it through projection: 'mercator' or 'equirectangular' to annotate it.`);const he=j.enabled&&Rn.has(O)&&!K;if(j.enabled&&!Rn.has(O)&&Dt(`chart:${this.#r}:annotate:type:${O}`,`"annotate" adds a drawing rail to a chart with two readable axes and ${JSON.stringify(O)} has none, so no rail was added. The types that take one are ${[...Rn].sort().join(", ")}.`),!he){this.#h&&(this.#h.destroy(),this.#h=null);return}this.#h?this.#h.configure(j):(this.#h=new Re({doc:this.#i,root:this.#s,plot:this.#o,groups:this.#c,t:(oe,Se)=>this.#n.messages.t(oe,Se),drawn:()=>this.#ot(),format:()=>this.#gt(),bound:()=>this.#a,notify:(oe,Se,Oe)=>{const Ge=Oe?{item:Se,readout:Oe}:{item:Se};oe==="added"?this.emit("annotation:added",Ge):oe==="changed"?this.emit("annotation:changed",Ge):this.emit("annotation:removed",Ge)}},j),this.#Y&&(this.#h.setItems(this.#Y),this.#Y=null)),this.#h.redraw()}#st(O,j,K,he){const oe=jt(this.#e.zoom);if(this.#C=oe.enabled&&zn.has(j),oe.enabled&&!zn.has(j)&&Dt(`chart:${this.#r}:zoom:type:${j}`,`"zoom" narrows a chart's own axes and ${JSON.stringify(j)} has none to narrow, so no zoom was added. The types that take one are ${[...zn].sort().join(", ")}.`),!this.#C)return this.#N={x:null,y:null},this.#f={x:null,y:null},this.#v=O.categories||[],this.#oe={first:0,last:Math.max(0,this.#v.length-1)},O;this.#B=me(O,j,K&&K.x),this.#v=O.categories||[],this.#N.x=this.#B?this.#v.length>1?{min:0,max:this.#v.length-1}:null:D(O,j,K&&K.x,he),oe.axes==="y"&&(this.#f.x=null),oe.axes==="x"&&(this.#f.y=null),this.#at(oe),this.#f.x=Ht(this.#f.x,this.#N.x),this.#f.y=Ht(this.#f.y,this.#N.y);let Se=O;const Oe=this.#f.x;if(this.#B){const{first:Ge,last:Ke}=nt(Oe,this.#v.length);this.#oe={first:Ge,last:Ke},Oe&&(Se=xt(Se,Ge,Ke))}else this.#oe={first:0,last:Math.max(0,this.#v.length-1)},Oe&&(Se={...Se,xDomain:{min:Oe.from,max:Oe.to}});return this.#f.y&&(Se={...Se,yDomain:{min:this.#f.y.from,max:this.#f.y.to}}),Se}#at(O){const j=this.#G;if(!j)return;const K={};for(const he of["x","y"]){if(!(he in j)||O.axes!=="xy"&&O.axes!==he)continue;if(!this.#N[he]){K[he]=j[he];continue}this.#f[he]=this.#$e(he,j[he])}this.#G=Object.keys(K).length?K:null}#$e(O,j){const K=this.#N[O];if(!K)return null;const he=Array.isArray(j)?j:j&&j.range;if(!Array.isArray(he)||he.length<2)return null;const oe=O==="x"&&this.#B?he.map(Oe=>this.#lt(Oe)):he.map(Oe=>this.#a&&this.#a.kind==="time"&&O==="x"?Jn(Oe):Yn(Oe));if(oe.some(Oe=>Oe===null||!Number.isFinite(Oe)))return Dt("chart:zoom:range","a chart zoom range named a value this chart's axis does not have, so the zoom was left alone. An x range on a category axis names two categories; on a continuous or time axis it is two readings, and a measure range is two values."),null;const Se=un(oe,K);return Se&&j&&j.pinned?Ht({...Se,pinned:!0},K):Se}#lt(O){const j=r(O);for(let K=0;K<this.#v.length;K++)if(r(this.#v[K])===j)return K;return null}#ct(){const O=jt(this.#e.zoom);if(!this.#C||O.buttons==="none")this.#ge();else{if(this.#M&&this.#M.buttons!==O.buttons&&this.#ge(),!this.#M){const j=Lt({doc:this.#i,t:he=>this.#n.messages.t(he),controls:[...qt],buttons:O.buttons,onPress:he=>this.#W(he,"button")});this.#M={...j,buttons:O.buttons};const K=this.#o.parentNode;K&&K.appendChild(j.element)}this.#M.sync({zoomed:!!(this.#f.x||this.#f.y),narrowest:this.#ut(O)})}if(this.#C&&!this.#f.y){const j=this.#t&&this.#t.yScale&&this.#t.yScale.domain;j&&Number.isFinite(j.min)&&Number.isFinite(j.max)&&(this.#N.y={min:j.min,max:j.max},this.#G&&"y"in this.#G&&this.schedule())}}#ut(O){for(const j of["x","y"]){const K=this.#N[j],he=this.#f[j];if(!K||!he)continue;const oe=K.max-K.min;if(oe>0&&he.to-he.from>oe*O.min*1.0001)return!1}return!!(this.#f.x||this.#f.y)}#ge(){this.#M&&this.#M.element.parentNode&&this.#M.element.parentNode.removeChild(this.#M.element),this.#M=null}#ae(O,j){if(!this.#C)return!1;const K=jt(this.#e.zoom);let he=!1;for(const oe of["x","y"]){if(K.axes!=="xy"&&K.axes!==oe)continue;const Se=this.#N[oe];if(!Se)continue;const Oe=Ht(O(oe,this.#f[oe],Se,K),Se);Bt(Oe,this.#f[oe])||(this.#f[oe]=Oe,he=!0)}return he?(this.draw(),this.emit("zoom",this.#ft(j)),!0):!1}#W(O,j,K){return O==="reset"?this.#ae(()=>null,"reset"):this.#ae((he,oe,Se,Oe)=>{const Ge=K&&Number.isFinite(K[he])?K[he]:null;return O==="in"?Ot(oe,Se,1-Oe.step,Ge,Oe.min):O==="out"?Ot(oe,Se,1/(1-Oe.step),Ge,Oe.min):he!=="x"?oe:At(oe,Se,O==="left"?-Oe.step:Oe.step)},j)}#ft(O){const j=jt(this.#e.zoom),K={x:this.#pe("x"),reason:O};return(j.axes==="y"||j.axes==="xy")&&(K.y=this.#pe("y")),K}#pe(O){const j=this.#N[O];if(!j)return null;const K=this.#f[O];if(O==="x"&&this.#B){const{first:he,last:oe}=nt(K,this.#v.length);return[this.#v[he],this.#v[oe]]}return K?[K.from,K.to]:[j.min,j.max]}#ht(O){const j={x:null,y:null};if(!this.#t)return j;if(this.#B){const he=this.#ke(O);he>=0&&(j.x=this.#oe.first+he)}else if(this.#t.xScale&&typeof this.#t.xScale.invert=="function"){const he=this.#t.xScale.invert(this.#t.horizontal?O.y:O.x);Number.isFinite(he)&&(j.x=he)}const K=this.#t.yScale;if(K&&typeof K.invert=="function"){const he=K.invert(this.#t.horizontal?O.x:O.y);Number.isFinite(he)&&(j.y=he)}return j}get zoom(){return this.#ce||(this.#ce=Object.freeze({set:O=>this.#dt(O),reset:()=>this.#W("reset","reset")})),this.#ce}#dt(O){if(!this.#C)return Dt(`chart:${this.#r}:zoom:off`,'chart.zoom.set() was called on a chart with no zoom, so nothing moved. Set `zoom: true` on a cartesian chart (or `zoom: { buttons: "none" }` to drive it from your own controls) before setting a range.'),!1;const j=Array.isArray(O)?{x:O}:O||{};return this.#ae((K,he)=>K in j?this.#$e(K,j[K]):he,"api")}#mt(){const O={};for(const j of["x","y"]){const K=this.#f[j];K&&(O[j]={range:this.#pe(j),pinned:!!K.pinned})}return Object.keys(O).length?O:null}#gt(){const O=this.#t&&this.#t.yScale&&this.#t.yScale.domain||null,j=O&&Number.isFinite(O.max)&&Number.isFinite(O.min)?(O.max-O.min)/5:0;return Xn(this.#n,{kind:"linear",step:j}).tick}state(){const O={annotations:this.#h?this.#h.list():Fe(this.#Y).map(Ze)},j=this.#mt();return j&&(O.zoom=j),O}setState(O){if(this.#h?this.#h.setItems(O):this.#Y=O,!O||Array.isArray(O))return;const j=O.zoom;this.#G=j&&typeof j=="object"?{...j}:null,this.#G||(this.#f={x:null,y:null}),this.schedule()}data(){return this.#a}provenance(){const O=this.#k;return{source:O.source,asked:O.asked,reason:O.reason??null,refused:!!O.refused,pending:!!O.pending,measures:O.measures.map(j=>({...j})),...O.viewport?{viewport:{...O.viewport,bbox:O.viewport.bbox?[...O.viewport.bbox]:null}}:{}}}#K(O,j){this.#Ee();const K=j.asked!=="client"&&u(this.#n);return this.#k={source:"client",asked:j.asked,reason:j.reason,refused:j.refused,pending:!1,measures:k(p(this.#n,this.#e,O),"client",[],j.reason)},j.refused?Dt(`chart:aggregate:engine-refused:${this.#r}:${j.reason}`,`chart aggregate: 'engine' was refused: ${j.reason}. The chart reads the rows the grid has loaded instead; chart.provenance() reports the same reason.`):K&&Dt(`chart:aggregate:window:${this.#r}:${j.reason}`,`this chart draws the rows the grid has loaded, which are a window of the matching set, because ${j.reason}. Its figures describe that window, not the whole relation.`),this.#o?.removeAttribute?.("aria-busy"),null}#pt(O){if(h.has(O))return this.#bt(O);this.#H=null;const j=R(this.#n,this.#e,O);if(j.mode==="client")return this.#K(O,j);const K=this.#_.answer(j.key);if(K){if(K.error!==void 0){const oe=K.error&&K.error.message?K.error.message:String(K.error);return this.#K(O,{asked:j.asked,refused:j.asked==="engine",reason:`the engine request failed (${oe})`})}const he=K.result||{};return he.client&&he.client.length?this.#K(O,{asked:j.asked,refused:j.asked==="engine",reason:`the source computed "${he.client[0].fn}" client-side (${he.client[0].reason})`}):(this.#k={source:"engine",asked:j.asked,reason:null,refused:!1,pending:!1,measures:k(j.measures,"engine",he.engine||[])},this.#o?.removeAttribute?.("aria-busy"),m(this.#n,this.#e,j,he.groups||[]))}return this.#vt(j),this.#k={...this.#k,asked:j.asked,pending:!0},this.#o&&this.#o.setAttribute("aria-busy","true"),Fn}#bt(O){const j=g(this.#n,this.#e,O,this.#J);if(j.mode==="client")return this.#H=null,this.#K(O,j);this.#H=j;let K=this.#_.answer(j.key);const he=this.#_.last();!K&&he&&he.error===void 0&&he.result&&he.result.kind==="rows"&&he.result.rowsKey===j.rowsKey&&(K=he);let oe=!1;if(!K){this.#_.ask(j.key,j.run,()=>{this.#E||this.schedule()});const Ge=this.#_.last();if(!(Ge&&Ge.error===void 0&&Ge.result&&Ge.result.map))return this.#k={...this.#k,asked:j.asked,pending:!0},this.#o&&this.#o.setAttribute("aria-busy","true"),Fn;K=Ge,oe=!0}if(K.error!==void 0){const Ge=K.error&&K.error.message?K.error.message:String(K.error);return this.#K(O,{asked:j.asked,refused:j.asked==="engine",reason:`the engine request failed (${Ge})`})}const Se=K.result;if(Se.refused)return this.#K(O,{asked:j.asked,refused:j.asked==="engine",reason:Se.refused});const Oe=this.#yt(O,Se,j,oe);return this.#k={source:"engine",asked:j.asked,reason:null,refused:!1,pending:oe,measures:[],viewport:{rows:Se.kind==="rows"?Se.rows.length:0,matched:Se.count,cap:Se.cap,binned:Se.kind==="density",cells:Se.kind==="density"?Se.cells.length:0,over:Se.kind==="over"?Se.reason:null,bbox:Se.bbox?[...Se.bbox]:null,computed:"engine"}},this.#o&&(oe?this.#o.setAttribute("aria-busy","true"):this.#o.removeAttribute("aria-busy")),Oe}#yt(O,j,K,he){let oe;if(j.kind==="rows"){const We=Vn(O),qe=ce(this.#n,j.rows);oe=We&&typeof We.bind=="function"?We.bind(qe,this.#e):{points:[],empty:!0}}else if(j.kind==="density"){const We=j.cells;oe={points:We.map(qe=>({lon:(qe.west+qe.east)/2,lat:(qe.south+qe.north)/2})),features:[],unplaced:0,fromGeometry:!0,empty:We.length===0,density:{cells:We,size:j.size}}}else oe={points:[],features:[],unplaced:0,fromGeometry:!0,empty:!1,over:{count:j.count,cap:j.cap,reason:j.reason}};const[Se,Oe]=this.#u.offset,Ge=this.#u.zoom===1&&Se===0&&Oe===0,Ke=!!(this.#b&&this.#b.refit);if(Ge&&!he&&!Ke&&(!this.#b||this.#b.baseKey!==K.baseKey)){const We=[...oe.points||[]];for(const vt of oe.features||[]){vt.point&&We.push({lon:vt.point[0],lat:vt.point[1]});for(const pt of vt.polygons||[])for(const De of pt)for(const[Ut,He]of De)We.push({lon:Ut,lat:He})}const qe=(j.kind==="density"?W([],j.cells):W(We))||[[[-180,-85],[180,-85],[180,85],[-180,85]]];(!this.#b||E(c(this.#b.rings),c(qe)))&&(this.#b={baseKey:K.baseKey,rings:qe})}return oe.frame=this.#b?this.#b.rings:null,oe}#wt(O,j){const K=j&&Array.isArray(j.points)?j.points.length:j&&Array.isArray(j.features)?j.features.length:0;this.#ye=K;const he=X(O,j,this.#e,this.#J);return he.viewport&&(this.#k={...this.#k,viewport:he.viewport},he.bound.over&&Dt(`chart:viewportCap:over:${this.#r}`,`this map's view holds ${he.bound.over.count} rows, more than its viewportCap of ${he.bound.over.cap}, and ${he.bound.over.reason}, so it draws none of them. Zoom in, narrow the filter, or raise viewportCap.`)),he.bound}#kt(O){if(!h.has(O))return;const j=this.#t,K=j&&j.plot,he=j&&j.anchor&&K?hn(j.anchor,K):null,[oe,Se]=this.#u.offset,Oe=this.#u.zoom===1&&oe===0&&Se===0,Ge=!!(this.#b&&this.#b.refit),Ke={bbox:Oe&&!Ge?null:he,span:he?he[2]-he[0]:360,width:K?K.right-K.left:this.#J.width},We=this.#J;if(yt(Ke.bbox,We.bbox)&&Math.abs(Ke.span-We.span)<1e-9&&Ke.width===We.width)return;this.#J=Ke;const vt=d(this.#e);(this.#H||this.#ye>vt)&&this.schedule()}#vt(O){this.#_.ask(O.key,j=>{const K={...O.request,...j?{signal:j}:{}};return Promise.resolve(O.source.aggregate(K,O.requested)).then(he=>({groups:he&&he.groups||[],engine:he&&he.engine||[],client:he&&he.client||[]}))},()=>{this.#E||this.schedule()})}#Ee(){this.#_.abort()}ascend(O){if(!this.#p||!this.#p.length)return[];const j=Number.isFinite(O)&&O>0?Number(O):this.#p.length;return this.#p=this.#p.slice(0,Math.max(0,this.#p.length-j)),this.emit("drill",{path:[...this.#p],label:this.#p[this.#p.length-1]||null}),this.draw(),[...this.#p]}update(O){this.#e={...this.#e,...O},this.draw()}get element(){return this.#s}toSVG(O){if(!this.#o)return"";const j=Qt(this.#i);let K=this.#o;return O&&O.inlineStyles&&j.getComputedStyle&&this.#o.cloneNode&&(K=this.#o.cloneNode(!0),no(this.#o,K,j),K.setAttribute("xmlns","http://www.w3.org/2000/svg")),typeof j.XMLSerializer=="function"?new j.XMLSerializer().serializeToString(K):K.outerHTML||""}async toPNG(O){const j=Qt(this.#i);if(!this.#o||!j.Image||!this.#i.createElement)return null;const K=O&&O.scale||j.devicePixelRatio||1,he=this.#o.getBoundingClientRect?this.#o.getBoundingClientRect():tn,oe=Math.max(1,Math.round(he.width||tn.width)),Se=Math.max(1,Math.round(he.height||tn.height)),Oe=this.toSVG({inlineStyles:!0}),Ge=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Oe)}`,Ke=new j.Image;await new Promise((pt,De)=>{Ke.onload=pt,Ke.onerror=()=>De(new Error("the chart could not be rasterised")),Ke.src=Ge});const We=this.#i.createElement("canvas");We.width=Math.round(oe*K),We.height=Math.round(Se*K);const qe=We.getContext("2d"),vt=O&&"background"in O?O.background:"#ffffff";return vt&&(qe.fillStyle=vt,qe.fillRect(0,0,We.width,We.height)),qe.drawImage(Ke,0,0,We.width,We.height),new Promise(pt=>We.toBlob(pt,"image/png"))}toCSV(){const O=this.#a;if(!O)return"";const j=oe=>{const Se=oe==null?"":String(oe);return/[",\n]/.test(Se)?`"${Se.replace(/"/g,'""')}"`:Se};if(O.root){const oe=[["Label",O.measure.title||"Value"].map(j).join(",")];for(const Se of O.root.children)oe.push([j(Se.label),j(Se.total)].join(","));return oe.join(`
|
|
329
|
-
`)}const he=[[
|
|
330
|
-
`)}destroy(){if(!this.#E){this.#E=!0,this.#
|
|
335
|
+
`}function J(W){const ie=W.documentElement;if(!ie||ie.getAttribute(be))return;ie.setAttribute(be,"1");const S=W.createElement("style");S.textContent=te(),(W.head||W.body||ie).appendChild(S)}}),Qe("packages/modules/charts/scale.js",function(o,X){"use strict";Object.defineProperty(o,"isNumber",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"toNumber",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"toTime",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"extent",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"niceStep",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"niceDomain",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureDomain",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"linearTicks",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"timeStepFor",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"timeTicks",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"linearScale",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"timeScale",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"key",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"bandScale",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"sqrtScale",{enumerable:!0,get:function(){return I}});const ye=[1,2,2.5,5,10],q=6e4,j=36e5,be=864e5,me=365.25*be,te=[1,2,5,10,20,25,50,100],J=[1,5,10,25,50,100,250,500,1e3,5e3,15e3,3e4,q,5*q,15*q,30*q,j,3*j,6*j,12*j,be,2*be,7*be,14*be,30*be,90*be,180*be,...te.map(z=>z*me)];function W(z){return typeof z=="number"&&Number.isFinite(z)}function ie(z){if(z==null||z==="")return null;if(z instanceof Date){const re=z.getTime();return Number.isFinite(re)?re:null}if(typeof z=="boolean")return z?1:0;const Y=Number(z);return Number.isFinite(Y)?Y:null}function S(z){if(z==null||z==="")return null;if(z instanceof Date){const re=z.getTime();return Number.isFinite(re)?re:null}if(typeof z=="number")return Number.isFinite(z)?z:null;const Y=Date.parse(String(z));return Number.isFinite(Y)?Y:null}function y(z){let Y=1/0,re=-1/0;for(let ee=0;ee<z.length;ee++){const H=z[ee];W(H)&&(H<Y&&(Y=H),H>re&&(re=H))}return Y===1/0?null:{min:Y,max:re}}function U(z){if(!(z>0))return 1;const Y=10**Math.floor(Math.log10(z));for(const re of ye)if(z<=re*Y)return re*Y;return 10*Y}function D(z,Y=5){const re=U((z.max-z.min)/Math.max(1,Y));return{min:Math.floor(z.min/re)*re,max:Math.ceil(z.max/re)*re,step:re}}function T(z,Y={}){const re=y(z)||{min:0,max:1};let{min:ee,max:H}=re;if(Y.zero&&(ee>0&&(ee=0),H<0&&(H=0)),ee===H){const pe=Math.abs(ee)>0?Math.abs(ee)/10:1;ee-=pe,H+=pe}if(Y.nice!==!1){const pe=D({min:ee,max:H},Y.ticks||5);ee=pe.min,H=pe.max}return W(Y.min)&&(ee=Y.min),W(Y.max)&&(H=Y.max),ee===H&&(H=ee+1),{min:ee,max:H}}function B(z,Y=5){const re=U((z.max-z.min)/Math.max(1,Y)),ee=Math.ceil(z.min/re),H=Math.floor(z.max/re),pe=[];for(let x=ee;x<=H;x++){const Q=x*re;pe.push(Math.abs(Q)<re/1e6?0:Number(Q.toPrecision(12)))}return pe}function _(z,Y=5){const re=Math.max(1,Y),ee=z/re;let H=J[J.length-1];for(const Q of J)if(Q>=ee){H=Q;break}if(H<me)return H;let pe=H,x=Math.abs(z/H-re);for(const Q of J){if(Q<me)continue;const ce=Math.abs(z/Q-re);ce<x&&(x=ce,pe=Q)}return pe}function $(z,Y){const re=new Date(z.min).getUTCFullYear();let ee=Math.ceil(re/Y)*Y;Date.UTC(ee,0,1)<z.min&&(ee+=Y);const H=[];for(;Date.UTC(ee,0,1)<=z.max;ee+=Y)H.push(Date.UTC(ee,0,1));return H}function p(z,Y=5){const re=_(z.max-z.min,Y);if(re>=me)return $(z,Math.round(re/me));const ee=[],H=Math.ceil(z.min/re)*re;for(let pe=H;pe<=z.max;pe+=re)ee.push(pe);return ee}function s(z,Y){const re=z.max-z.min||1,[ee,H]=Y;return{kind:"linear",domain:z,range:Y,of(pe){return ee+(pe-z.min)/re*(H-ee)},invert(pe){return z.min+(pe-ee)/(H-ee||1)*re},ticks(pe=5){return B(z,pe)}}}function c(z,Y){return{...s(z,Y),kind:"time",ticks(ee=5){return p(z,ee)}}}function k(z){if(z==null)return" null";if(z instanceof Date)return` date:${z.getTime()}`;if(typeof z=="object"){const Y=z,re=Y.id??Y.key??Y.value;return re!==void 0&&typeof re!="object"?` obj:${String(re)}`:` obj:${String(z)}`}return String(z)}function R(z,Y,re=.2){const ee=Math.min(.9,Math.max(0,re)),[H,pe]=Y,x=new Map;for(let E=0;E<z.length;E++){const V=k(z[E]);x.has(V)||x.set(V,E)}const Q=z.length?(pe-H)/z.length:pe-H,ce=Math.max(0,Q*(1-ee));return{kind:"band",domain:z,range:Y,bandwidth:ce,step:Q,of(E){const V=x.get(k(E));return V===void 0?NaN:H+V*Q+(Q-ce)/2},centre(E){const V=this.of(E);return Number.isNaN(V)?NaN:V+ce/2},ticks(){return z}}}function I(z,Y){const[re,ee]=Y,H=Math.max(Math.abs(z.max),Math.abs(z.min),0)||1;return{kind:"sqrt",domain:z,range:Y,of(pe){const x=Math.sqrt(Math.abs(pe)/H);return re+x*(ee-re)}}}}),Qe("packages/modules/charts/axis.js",function(o,X){"use strict";Object.defineProperty(o,"pinXDomain",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"TICK_FLOOR",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"tickFloor",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"fitBandLabels",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"normaliseAxes",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"tickValues",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"tickLabeller",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"drawAxisTitle",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"labelEvery",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"drawMeasureAxis",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"drawCategoryAxis",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"leftLabelRoom",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"setLabelText",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"drawBandLabels",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"drawContinuousAxis",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"drawAxisLines",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"createGroups",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"MARK_OVERHANG",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"overhangFor",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"setPlotClip",{enumerable:!0,get:function(){return w}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/svg.js"),be=j.attrs,me=j.round,te=j.setText,J=j.svg,W=X("packages/modules/charts/typography.js"),ie=W.applySize,S=W.CHAR_RATIO,y=W.truncateTo,D=X("packages/modules/charts/styles.js").NS,T=X("packages/modules/charts/scale.js"),B=T.toNumber,_=T.toTime,p=X("packages/core/src/internal/util.js").warnOnce;function s(g,f,v){const F=f&&f.kind==="time"?_:B,b=l=>l==null||l===""?null:F(l),e=b(v&&v.min),i=b(v&&v.max);if(e===null&&i===null)return g;if(e!==null&&i!==null)return e<i?{min:e,max:i}:(p("chart.axis.x.domain.inverted",`axis.x.min (${e}) is not below axis.x.max (${i}), which is a mirrored axis rather than a narrow one, so both were ignored and the x domain was taken from the data. On a time axis both are epoch milliseconds.`),g);const n=e!==null?e:g.min,t=i!==null?i:g.max;if(n<t)return{min:n,max:t};const r=Math.abs(g.max-g.min)||1;return p("chart.axis.x.domain.beyond",`axis.x.${e!==null?"min":"max"} is outside the x values entirely, so the plot is empty. The pin was kept and the other edge moved to hold the axis width; check the units (a time axis is pinned in epoch milliseconds).`),e!==null?{min:n,max:n+r}:{min:t-r,max:t}}const c=6,k=9;function R(g){const f=g&&g.ownerDocument,v=f&&f.defaultView;if(!v||typeof v.getComputedStyle!="function")return k;const F=v.getComputedStyle(g).getPropertyValue("--lattice-chart-tick-min"),b=parseFloat(F);return Number.isFinite(b)&&b>0?b:k}function I(g){const{size:f,floor:v,slot:F,per:b}=g,e=Number.isFinite(g.every)&&g.every>0?Number(g.every):null;if(e!==null&&e!==1)return{size:f,every:e,thinned:!1};if(!(F>0)||!(b>0))return{size:f,every:1,thinned:!1};const i=Math.min(f,F/b);return i>=v?{size:i,every:1,thinned:!1}:{size:v,every:Math.max(1,Math.ceil(v*b/F)),thinned:!0}}function z(g,f){const v=Math.ceil(g/f),F=g-v;p("chart.axis.band.thinned",`${F} of ${g} band labels were hidden: even the smallest font (--lattice-chart-tick-min) could not make them all fit. Set axis.x.every or axis.y.every to choose which ones show.`)}const Y=1.2;function re(g){if(g===!1){const F={labels:!1,grid:!1};return{x:{...F},y:{...F},y2:{...F}}}const f=g&&typeof g=="object"?g:{},v=F=>typeof F=="string"?{title:F}:F&&typeof F=="object"?{...F}:{};return{x:v(f.x),y:v(f.y),y2:v(f.y2||f.right)}}function ee(g,f){const v=f&&f.ticks;if(Array.isArray(v)){const b=g.domain;return!b||b.min===void 0?v:v.filter(e=>Number(e)>=b.min&&Number(e)<=b.max)}const F=Number.isFinite(v)&&v>0?Number(v):5;return g.ticks(F)}function H(g,f,v,F){const b=g&&g.format;return typeof b=="function"?e=>String(b(e)):typeof b=="string"&&v&&v.formatting&&v.formatting.format?e=>String(v.formatting.format(e,b)):F&&F.format&&F.format.pattern&&typeof F.formatValue=="function"?e=>String(F.formatValue(e,null)):f.tick}function pe(g){if(!g.text)return;const f=g.side==="left"||g.side==="right"?g.plot.height:g.plot.width,v=Number.isFinite(f)?y(String(g.text),Math.max(0,f),g.size):String(g.text);if(!v||v==="…")return;const F=J(g.group.ownerDocument,"text",{class:`${D}__axis-title`});if(ie(F,g.size),g.side==="left"){const b=Math.max(g.size,g.plot.left-g.plot.gutter.left+g.size),e=g.plot.top+g.plot.height/2;be(F,{transform:`translate(${me(b)} ${me(e)}) rotate(-90)`,"text-anchor":"middle"})}else if(g.side==="right"){const b=g.plot.right+g.plot.gutter.right-g.size,e=g.plot.top+g.plot.height/2;be(F,{transform:`translate(${me(b)} ${me(e)}) rotate(90)`,"text-anchor":"middle"})}else be(F,{x:me(g.plot.left+g.plot.width/2),y:me(g.plot.bottom+g.plot.gutter.bottom-2),"text-anchor":"middle"});te(F,v),v!==String(g.text)&&F.setAttribute("aria-label",String(g.text)),g.group.appendChild(F)}function x(g){const{values:f,scale:v,size:F,horizontal:b,label:e}=g;if(f.length<2)return 1;let i=1/0;for(let t=1;t<f.length;t++){const r=Math.abs(v.of(f[t])-v.of(f[t-1]));Number.isFinite(r)&&r<i&&(i=r)}if(!Number.isFinite(i))return 1;if(i<=0)return f.length;let n=F*Y+2;if(b){let t=0;for(const r of f){const l=String(e(r)||"").length*F*S;l>t&&(t=l)}n=t+c}return Math.max(1,Math.ceil(n/i))}function Q(g){const{gridGroup:f,axisGroup:v,plot:F,scale:b,format:e}=g,i=g.config||{},n=ee(b,i),t=H(i,e,g.grid),r=g.size||11,l=x({values:n,scale:b,size:r,horizontal:!!g.horizontal,label:t}),L=i.grid===!1?null:f,M=L?new q(L):null,C=new q(v);for(let ne=0;ne<n.length;ne++){const ue=n[ne],ge=me(b.of(ue)),xe=ue===0,Ce=ne%l!==0;if(g.horizontal){if(M&&be(M.next("line",`${D}__gridline`),{x1:ge,x2:ge,y1:me(F.top),y2:me(F.bottom),"stroke-opacity":xe?1:.6,"stroke-width":xe?1.5:1}),i.labels===!1||Ce)continue;const je=C.next("text",`${D}__tick`);ie(je,r),be(je,{x:ge,y:me(F.bottom+c),"text-anchor":"middle","dominant-baseline":"hanging"}),te(je,t(ue))}else{if(M&&be(M.next("line",`${D}__gridline`),{x1:me(F.left),x2:me(F.right),y1:ge,y2:ge,"stroke-opacity":xe?1:.6,"stroke-width":xe?1.5:1}),i.labels===!1||Ce)continue;const je=C.next("text",`${D}__tick`);ie(je,r);const _e=g.side==="right";be(je,{x:me(_e?F.right+c:F.left-c),y:ge,"text-anchor":_e?"start":"end","dominant-baseline":"middle"}),te(je,t(ue))}}return M?M.finish():new q(f).finish(),C.finish(),n}function ce(g){const{group:f,plot:v,scale:F,labels:b}=g,e=g.config||{};if(e.labels===!1){new q(f).finish();return}const i=new q(f),n=F.domain,t=F.step,r=e.rotate===void 0||e.rotate==="auto"?g.rotated:!!e.rotate,l=r?I({size:g.fontSize,floor:R(f),slot:t,per:Math.SQRT2,every:e.every}):{size:g.fontSize,every:Number.isFinite(e.every)&&e.every>0?Number(e.every):1,thinned:!1},{size:L,every:M}=l;l.thinned&&z(n.length,M);const C=t*M;for(let ne=0;ne<n.length;ne++){const ue=me(F.centre(n[ne]));if(Number.isNaN(ue)||ne%M!==0)continue;const ge=i.next("text",`${D}__tick`);ie(ge,L);const xe=b[ne]===void 0?"":b[ne];r?(be(ge,{x:0,y:0,"text-anchor":"end","dominant-baseline":"middle",transform:`translate(${ue} ${me(v.bottom+c)}) rotate(-45)`}),V(ge,xe,Math.max(0,v.gutter.bottom-c)*Math.SQRT2,L)):(be(ge,{x:ue,y:me(v.bottom+c),"text-anchor":"middle","dominant-baseline":"hanging",transform:null}),V(ge,xe,C,L))}i.finish()}function E(g){return Math.max(0,(g.gutter?g.gutter.left:g.left)-c)}function V(g,f,v,F){const b=String(f??""),e=y(b,v,F);return te(g,e),e!==b?g.setAttribute("aria-label",b):g.removeAttribute("aria-label"),e}function h(g){const{group:f,plot:v,scale:F,labels:b}=g,e=g.config||{},i=new q(f),n=F.domain,t=E(v),r=I({size:g.fontSize,floor:R(f),slot:F.step,per:Y,every:e.every}),{size:l,every:L}=r;r.thinned&&z(n.length,L);for(let M=0;M<n.length;M++){if(M%L!==0)continue;const C=me(F.centre(n[M]));if(Number.isNaN(C))continue;const ne=i.next("text",`${D}__tick`);be(ne,{x:me(v.left-c),y:C,"text-anchor":"end","dominant-baseline":"middle"}),ie(ne,l),V(ne,b[M],t,l)}i.finish()}function a(g){const{group:f,plot:v,scale:F,format:b}=g,e=g.config||{};if(e.labels===!1){new q(f).finish();return}const i=H(e,b,g.grid,g.column),n=new q(f);for(const t of ee(F,e)){const r=me(F.of(t));if(r<v.left-1||r>v.right+1)continue;const l=n.next("text",`${D}__tick`);ie(l,g.size||11),be(l,{x:r,y:me(v.bottom+c),"text-anchor":"middle","dominant-baseline":"hanging"}),te(l,i(t))}n.finish()}function d(g){const{group:f,plot:v}=g,F=g.side==="right"?v.right:v.left,b=new q(f);be(b.next("line"),{x1:me(F),x2:me(F),y1:me(v.top),y2:me(v.bottom)}),be(b.next("line"),{x1:me(v.left),x2:me(v.right),y1:me(v.bottom),y2:me(v.bottom)}),b.finish()}let u=0;function m(g,f){const v=`${D}-plot-clip-${++u}`,F=J(g,"rect"),b=J(g,"clipPath",{id:v});b.appendChild(F);const e=`${D}-box-clip-${u}`,i=J(g,"clipPath",{id:e});i.appendChild(J(g,"rect",{x:0,y:0,width:"100%",height:"100%"}));const n=J(g,"defs");n.appendChild(b),n.appendChild(i);const t={grid:J(g,"g",{class:`${D}__grid`}),marks:J(g,"g",{class:`${D}__marks`}),rules:J(g,"g",{class:`${D}__axis`}),axis:J(g,"g",{class:`${D}__axis`}),labels:J(g,"g",{class:`${D}__labels`}),overlay:J(g,"g",{class:`${D}__overlay`}),clip:F,clipId:v,boxClipId:e};f.appendChild(n);for(const r of["grid","marks","rules","axis","labels","overlay"])f.appendChild(t[r]);return t}const O=30;function A(g){return g==="bubble"?O:g==="scatter"?6:3}function w(g,f,v){if(!g||!g.marks||!g.clip)return;if(!f||!Number.isFinite(f.width)||!Number.isFinite(f.height)){g.marks.removeAttribute("clip-path");return}const F=Number.isFinite(v)&&v>=0?Number(v):O;be(g.clip,{x:me(f.left-F),y:me(f.top-F),width:me(Math.max(0,f.width)+F*2),height:me(Math.max(0,f.height)+F*2)}),g.marks.setAttribute("clip-path",`url(#${g.clipId})`)}}),Qe("packages/modules/charts/format.js",function(o,X){"use strict";Object.defineProperty(o,"precisionFor",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"axisNumber",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"r2Digits",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"dateFormatFor",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"formatters",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"measureText",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"measureFormat",{enumerable:!0,get:function(){return ie}});const q=X("packages/modules/charts/scale.js").timeStepFor;function j(S){if(!Number.isFinite(S)||S<=0)return 0;const y=Math.ceil(-Math.log10(S));return Math.min(6,Math.max(0,y))}function be(S,y,U=0){return Number.isFinite(S)?Math.abs(S)>=1e4?y.number(S,{notation:"compact",maximumFractionDigits:1}):y.number(S,{minimumFractionDigits:U,maximumFractionDigits:U}):""}function me(S,y){const U=S&&S.messages;return!U||typeof U.number!="function"?Number(y).toFixed(2):U.number(y,{minimumFractionDigits:2,maximumFractionDigits:2})}function te(S){const U=S>0?q(S):0;return U>0&&U<1e3?{minute:"2-digit",second:"2-digit",fractionalSecondDigits:3}:U>0&&U<6e4?{hour:"2-digit",minute:"2-digit",second:"2-digit"}:S<=864e5?{hour:"2-digit",minute:"2-digit"}:S<=180*864e5?U>0&&U<864e5?{day:"numeric",month:"short",hour:"2-digit",minute:"2-digit"}:{day:"numeric",month:"short"}:S<=3*365*864e5?{month:"short",year:"numeric"}:{year:"numeric"}}function J(S,y,U){const D=S.messages,T=D.locale,_=U&&U.format&&U.format.timeZone||S.get("timeZone")||void 0;if(y.kind==="time"){const p=te(y.span||0),s=new Intl.DateTimeFormat(T,_?{...p,timeZone:_}:p),c=new Intl.DateTimeFormat(T,_?{dateStyle:"medium",timeStyle:"short",timeZone:_}:{dateStyle:"medium",timeStyle:"short"});return{tick:k=>Number.isFinite(Number(k))?s.format(new Date(Number(k))):"",value:k=>Number.isFinite(Number(k))?c.format(new Date(Number(k))):""}}const $=j(y.step||0);return{tick:p=>typeof p=="number"?be(p,D,$):String(p??""),value:p=>typeof p=="number"?D.number(p):String(p??"")}}function W(S,y){if(S==null||!Number.isFinite(S))return"";const U=Math.abs(S)>=1e-6?Number(S.toPrecision(6)):S;return y.number(U)}function ie(S,y,U){return S==null||!Number.isFinite(Number(S))?"":y&&y.format&&typeof y.formatValue=="function"?String(y.formatValue(S,null)):W(Number(S),U&&U.messages)}}),Qe("packages/modules/charts/labels.js",function(o,X){"use strict";Object.defineProperty(o,"resolveLabels",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"collides",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"placeLabels",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"labelText",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"drawAnchoredLabels",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"drawDataLabels",{enumerable:!0,get:function(){return c}});const q=X("packages/modules/charts/frame.js").Pool,be=X("packages/modules/charts/format.js").measureText,me=X("packages/modules/charts/svg.js"),te=me.attrs,J=me.round,W=me.setText,S=X("packages/modules/charts/styles.js").NS,y=X("packages/modules/charts/typography.js"),U=y.applySize,D=y.textWidth,T=4;function B(k){const R=k&&k.labels;if(!R)return{show:!1,names:R!==!1,position:"outside",format:null,minGap:2,total:!1};const I=typeof R=="object"?R:{};return{show:!0,names:!0,position:["outside","inside","auto"].includes(I.position)?I.position:"outside",format:I.format||null,minGap:Number.isFinite(I.minGap)?Number(I.minGap):2,total:!!I.total}}function _(k,R,I){for(const z of R)if(k.x-I<z.x+z.width&&k.x+k.width+I>z.x&&k.y-I<z.y+z.height&&k.y+k.height+I>z.y)return!0;return!1}function $(k){const{points:R,plot:I,size:z}=k,Y=k.minGap===void 0?2:k.minGap,re=[],ee=[];for(const H of R){if(H.px===void 0||H.py===void 0)continue;const pe=k.text(H);if(!pe)continue;const x=D(pe,z),Q=z;let ce=H.px,E=H.py-T,V="middle",h=!1;k.horizontal?(ce=H.px+T,E=H.py,V="start",k.position!=="outside"&&H.pbase!==void 0&&Math.abs(H.px-H.pbase)>x+T*2&&(ce=H.px-T,V="end",h=!0)):k.position!=="outside"&&H.pbase!==void 0&&Math.abs(H.pbase-H.py)>Q+T*2&&(E=H.py+Q+T,h=!0);const a=()=>({x:V==="middle"?ce-x/2:V==="end"?ce-x:ce,y:E-Q,width:x,height:Q});let d=a();!(d.y>=I.top-1)&&!h&&!k.horizontal&&H.pbase!==void 0&&Math.abs(H.pbase-H.py)>Q+T*2&&(E=H.py+Q+T,h=!0,d=a()),!(d.x+d.width<=I.right+1)&&!h&&k.horizontal&&H.pbase!==void 0&&Math.abs(H.px-H.pbase)>x+T*2&&(ce=H.px-T,V="end",h=!0,d=a()),!(d.x<I.left-1||d.x+d.width>I.right+1)&&(d.y<I.top-1||d.y+d.height>I.bottom+Q||_(d,re,Y)||(re.push(d),ee.push({x:J(ce),y:J(E),text:pe,anchor:V,inside:h})))}return ee}function p(k,R,I){return k==null?"":typeof R.format=="function"?String(R.format(k)):typeof R.format=="string"&&I&&I.formatting&&I.formatting.format?String(I.formatting.format(k,R.format)):be(k,I&&I.messages)}function s(k){const R=new q(k.group),I=k.minGap===void 0?2:k.minGap,z=k.size,Y=[];let re=0;for(const ee of k.anchors){if(!ee||!ee.text)continue;const H=ee.width===void 0?D(ee.text,k.size):ee.width,pe=ee.anchor||"middle",Q={x:pe==="end"?ee.x-H:pe==="start"?ee.x:ee.x-H/2,y:ee.y-z/2,width:H,height:z};if(k.plot&&(Q.x<k.plot.left-1||Q.x+Q.width>k.plot.right+1||Q.y<k.plot.top-1||Q.y+Q.height>k.plot.bottom+1)||ee.width!==void 0&&H>ee.width||ee.height!==void 0&&z>ee.height||_(Q,Y,I))continue;Y.push(Q);const ce=R.next("text",ee.className||`${S}__data-label`);U(ce,k.size),te(ce,{x:J(ee.x),y:J(ee.y),"text-anchor":pe,"dominant-baseline":ee.baseline||"middle","data-inside":ee.inside?"true":null}),W(ce,ee.text),re++}return R.finish(),re}function c(k){const R=new q(k.group),{options:I}=k;let z=0;const Y=re=>typeof I.format=="function"&&re.y!==null&&re.y!==void 0?String(I.format(re.y,re)):p(re.y,I,k.grid);for(const re of k.series){const ee=$({points:re.points,plot:k.plot,size:k.size,position:I.position,horizontal:k.horizontal,minGap:I.minGap,text:Y});for(const H of ee){const pe=R.next("text",`${S}__data-label`);U(pe,k.size),te(pe,{x:H.x,y:H.y,"text-anchor":H.anchor,"data-inside":H.inside?"true":null}),W(pe,H.text),z++}}return R.finish(),z}}),Qe("packages/modules/charts/dense.js",function(o,X){"use strict";Object.defineProperty(o,"CANVAS_THRESHOLD",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"downsample",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"markCount",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"wantsCanvas",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"paintDense",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"sizeCanvas",{enumerable:!0,get:function(){return te}});const ye=3e3;function q(J,W){const ie=J.length;if(!Number.isFinite(W)||W>=ie||W<3||ie<3)return J;const S=[J[0]],y=(ie-2)/(W-2);let U=0;for(let D=0;D<W-2;D++){const T=Math.floor(D*y)+1,B=Math.min(Math.floor((D+1)*y)+1,ie-1),_=B,$=Math.min(Math.floor((D+2)*y)+1,ie);let p=0,s=0,c=0;for(let z=_;z<$;z++){const Y=J[z];!Y||!Number.isFinite(Y.y)||(p+=Y.x,s+=Y.y,c++)}c&&(p/=c,s/=c);const k=J[U];if(T>=B)continue;let R=T,I=-1;for(let z=T;z<B;z++){const Y=J[z];if(!Y||!Number.isFinite(Y.y))continue;const re=Math.abs((k.x-p)*(Y.y-k.y)-(k.x-Y.x)*(s-k.y));re>I&&(I=re,R=z)}R<=U||(S.push(J[R]),U=R)}return S.push(J[ie-1]),S}function j(J){let W=0;for(const ie of J)W+=ie.points.length;return W}function be(J){if(J.canvas===!0)return!0;if(J.canvas===!1)return!1;const W=Number.isFinite(J.canvas)?Number(J.canvas):ye;return j(J.series)>W}function me(J){const{context:W,series:ie,ratio:S}=J;W.save(),W.scale(S,S);for(const y of ie){const U=J.colour(y.index);if(J.type==="scatter"||J.type==="bubble"){W.fillStyle=U;for(const T of y.points)T.px!==void 0&&(W.beginPath(),W.arc(T.px,T.py,T.pr||2,0,Math.PI*2),W.fill());continue}W.strokeStyle=U,W.lineWidth=2,W.lineJoin="round",W.beginPath();let D=!1;for(const T of y.points){if(T.px===void 0||T.py===void 0){D=!1;continue}D?W.lineTo(T.px,T.py):W.moveTo(T.px,T.py),D=!0}W.stroke()}W.restore()}function te(J){const{canvas:W}=J;return W.width=Math.max(1,Math.round(J.width*J.ratio)),W.height=Math.max(1,Math.round(J.height*J.ratio)),W.style&&(W.style.width=`${J.width}px`,W.style.height=`${J.height}px`),typeof W.getContext=="function"?W.getContext("2d"):null}}),Qe("packages/modules/charts/annotations.js",function(o,X){"use strict";Object.defineProperty(o,"overlayLayer",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"annotationValue",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"annotationAxis",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"annotationText",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"drawAnnotations",{enumerable:!0,get:function(){return pe}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/scale.js"),be=j.isNumber,me=j.toNumber,te=j.toTime,J=X("packages/modules/charts/svg.js"),W=J.attrs,ie=J.path,S=J.round,y=J.setText,U=J.SVG_NS,T=X("packages/modules/charts/styles.js").NS,_=X("packages/core/src/internal/util.js").warnOnce;function $(x,Q){for(const E of x.childNodes||[])if(E&&String(E.getAttribute&&E.getAttribute("class"))===Q)return E;const ce=x.ownerDocument.createElementNS(U,"g");return ce.setAttribute("class",Q),x.appendChild(ce),ce}const p=new Set(["line","target","band","callout","event"]);function s(x,Q){return x.kind==="time"?te(Q):me(Q)}function c(x,Q,ce){if(x.kind==="band"){const V=x.of(Q);if(!Number.isFinite(V))return NaN;const h=Number(x.bandwidth)||0;return ce==="right"?V+h:V}const E=s(x,Q);return E===null?NaN:x.of(E)}function k(x,Q,ce){const E=x.kind||"line",V=x.label?` (${JSON.stringify(x.label)})`:"";_(`chart:annotation:dropped:${E}:${Q}:${ce}`,`chart annotation${V} of kind ${JSON.stringify(E)}, reading the ${Q} axis, was not drawn: ${ce}.`)}function R(x,Q){if(x instanceof Date){const E=x.getTime();return Number.isFinite(E)?x.toISOString().slice(0,10):String(x)}if(typeof x=="number")return Number.isFinite(x)?Q(x):String(x);const ce=me(x);return ce===null||typeof x=="string"?String(x):Q(ce)}function I(x,Q,ce){const E=[];for(const V of x)if((V.axis==="right"?"right":"left")===ce&&!(Q.series!==void 0&&V.key!==Q.series))for(const a of V.points)be(a.y)&&E.push(Number(a.y));return E}function z(x,Q){if(!x.length)return null;const ce=[...x].sort((a,d)=>a-d);if(ce.length===1)return ce[0];const E=Math.min(100,Math.max(0,Q))/100*(ce.length-1),V=Math.floor(E),h=Math.ceil(E);return V===h?ce[V]:ce[V]+(ce[h]-ce[V])*(E-V)}function Y(x,Q,ce){if(!x.compute)return me(x.value);const E=I(Q,x,ce);if(!E.length)return null;const V=String(x.compute).toLowerCase();if(V==="mean"||V==="avg")return E.reduce((a,d)=>a+d,0)/E.length;if(V==="median"||V==="p50")return z(E,50);if(V==="min")return Math.min(...E);if(V==="max")return Math.max(...E);const h=/^p(\d+(?:\.\d+)?)$/.exec(V);return h?z(E,Number(h[1])):null}function re(x){return x.axis==="right"||x.axis==="y2"?"right":"left"}function ee(x,Q,ce,E){const V=x.label?`${x.label}: `:"",h=E?` (${re(x)==="right"?"right axis":"left axis"})`:"",a=x.kind||"line";if(a==="band"){if(!Array.isArray(Q)||Q[0]===null||Q[1]===null)return"";const[u,m]=Q;return`${V||"Band: "}${ce(Math.min(u,m))} to ${ce(Math.max(u,m))}${h}`}return Q==null?"":`${V||`${a==="target"?"Target":a==="callout"?"Callout":"Reference"}: `}${ce(Q)}${h}`}function H(x){return(x.kind||"line")==="band"?0:1}function pe(x){const{group:Q,plot:ce,xScale:E,yScale:V,rightScale:h,series:a,format:d}=x,u=new q($(Q,`${T}__annotations`)),m=[],A=[...Array.isArray(x.annotations)?x.annotations:[]].sort((w,g)=>H(w)-H(g));for(const w of A){const g=w.kind||"line";if(!p.has(g))continue;const f=re(w),v=f==="right"&&h?h:V;if(g==="band"){if(w.orient==="vertical"){const l=c(E,w.from,"left"),L=c(E,w.to,"right");if(Number.isNaN(l)||Number.isNaN(L)){const ue=Number.isNaN(l)&&Number.isNaN(L)?"from and to":Number.isNaN(l)?"from":"to";k(w,f,`its ${ue} value could not be placed on the x scale`);continue}const M=S(Math.min(l,L)),C=S(Math.max(l,L));if(W(u.next("rect",`${T}__annotation-band ${w.className||""}`.trim()),{x:M,y:S(ce.top),width:Math.max(0,C-M),height:S(Math.max(0,ce.bottom-ce.top)),fill:w.colour||"currentColor","fill-opacity":w.opacity===void 0?.12:w.opacity}),w.label){const ue=u.next("text",`${T}__annotation-label`);W(ue,{x:M+4,y:S(ce.top+12),"text-anchor":"start"}),y(ue,w.label)}const ne=w.label?`${w.label}: `:"Event window: ";m.push({text:`${ne}${R(w.from,d)} to ${R(w.to,d)}`});continue}const i=Y({...w,value:w.from,compute:w.fromCompute},a,f),n=Y({...w,value:w.to,compute:w.toCompute},a,f);if(i===null||n===null)continue;const t=S(v.of(i)),r=S(v.of(n));if(W(u.next("rect",`${T}__annotation-band ${w.className||""}`.trim()),{x:S(ce.left),y:Math.min(t,r),width:S(Math.max(0,ce.right-ce.left)),height:Math.max(0,Math.abs(r-t)),fill:w.colour||"currentColor","fill-opacity":w.opacity===void 0?.12:w.opacity}),w.label){const l=u.next("text",`${T}__annotation-label`);W(l,{x:S(ce.left+4),y:Math.min(t,r)+12,"text-anchor":"start"}),y(l,w.label)}m.push({text:ee(w,[i,n],d,x.dual)});continue}if(g==="event"){const i=w.x!==void 0?w.x:w.at,n=S(c(E,i,"left")+(E.kind==="band"?(Number(E.bandwidth)||0)/2:0));if(Number.isNaN(n)){k(w,f,"its x value could not be placed on the x scale");continue}if(W(u.next("path",`${T}__annotation-event`),{d:ie(["M",n,S(ce.top),"L",n,S(ce.bottom)]),stroke:w.colour||"currentColor",fill:"none"}),W(u.next("circle",`${T}__annotation-event-flag`),{cx:n,cy:S(ce.top),r:3,fill:w.colour||"currentColor"}),w.label){const r=u.next("text",`${T}__annotation-label`);W(r,{x:n+5,y:S(ce.top+10),"text-anchor":"start"}),y(r,w.label)}const t=w.label?`${w.label} — `:"Event — ";m.push({text:`${t}at ${R(i,d)}`});continue}if(g==="callout"){const i=Y(w,a,f);if(i===null)continue;const n=w.at!==void 0?S(E.kind==="band"?E.centre(w.at):E.of(s(E,w.at)??NaN)):S(ce.right-4),t=S(v.of(i));if(Number.isNaN(n)){k(w,f,"its x value could not be placed on the x scale");continue}if(W(u.next("circle",`${T}__annotation-point`),{cx:n,cy:t,r:3.5,fill:w.colour||"currentColor"}),w.label){const r=u.next("text",`${T}__annotation-label`);W(r,{x:n+6,y:t-6,"text-anchor":"start"}),y(r,w.label)}m.push({text:ee(w,i,d,x.dual)});continue}if(w.orient==="vertical"||w.x!==void 0){const i=w.x!==void 0?w.x:w.value,n=E.kind==="band"?S(E.centre(i)):S(E.of(s(E,i)??NaN));if(Number.isNaN(n)){k(w,f,"its x value could not be placed on the x scale");continue}const t=g==="target"?`${T}__annotation-target`:`${T}__annotation-line`;if(W(u.next("path",t),{d:ie(["M",n,S(ce.top),"L",n,S(ce.bottom)]),stroke:w.colour||"currentColor",fill:"none"}),w.label){const r=u.next("text",`${T}__annotation-label`);W(r,{x:n+4,y:S(ce.top+10),"text-anchor":"start"}),y(r,w.label)}m.push({text:w.label?`${w.label} — at ${R(i,d)}`:""});continue}const F=Y(w,a,f);if(F===null)continue;const b=S(v.of(F)),e=g==="target"?`${T}__annotation-target`:`${T}__annotation-line`;if(W(u.next("path",e),{d:ie(["M",S(ce.left),b,"L",S(ce.right),b]),stroke:w.colour||"currentColor",fill:"none"}),w.label){const i=u.next("text",`${T}__annotation-label`);W(i,{x:S(ce.right-4),y:b-4,"text-anchor":"end"}),y(i,w.label)}m.push({text:ee(w,F,d,x.dual)})}return u.finish(),m.filter(w=>w.text)}}),Qe("packages/modules/charts/combo.js",function(o,X){"use strict";Object.defineProperty(o,"toPareto",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"drawCombo",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"drawRightAxis",{enumerable:!0,get:function(){return g}});const ye=X("packages/modules/charts/axis.js"),q=ye.drawAxisLines,j=ye.drawCategoryAxis,be=ye.drawContinuousAxis,me=ye.drawMeasureAxis,te=ye.overhangFor,J=ye.pinXDomain,W=ye.setPlotClip,ie=X("packages/modules/charts/frame.js"),S=ie.Pool,y=ie.shouldRotate,D=X("packages/modules/charts/format.js").formatters,T=X("packages/modules/charts/scale.js"),B=T.bandScale,_=T.extent,$=T.isNumber,p=T.linearScale,s=T.measureDomain,c=T.timeScale,k=T.toNumber,R=T.toTime,I=X("packages/modules/charts/svg.js"),z=I.attrs,Y=I.path,re=I.round,H=X("packages/modules/charts/styles.js").NS,x=X("packages/modules/charts/scheme.js").resolveScheme,ce=X("packages/modules/charts/labels.js").drawDataLabels,V=X("packages/modules/charts/annotations.js").drawAnnotations;function h(f){return{left:f.filter(v=>v.axis!=="right"),right:f.filter(v=>v.axis==="right")}}function a(f,v){const F=f&&f.seriesStyle&&f.seriesStyle[v];if(F)return{width:F.width!=null?String(F.width):null,dash:Array.isArray(F.dash)&&F.dash.length?F.dash.join(" "):null,opacity:null,emphasized:!1};const b=f&&Array.isArray(f.emphasis)?f.emphasis:null;if(!b||!b.length)return{width:null,dash:null,opacity:null,emphasized:!1};const e=b.includes(v);return{width:e?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:e?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:e}}function d(f,v,F,b){const e=[];let i=!1;for(const n of v.points){if(n.px===void 0){i=!1;continue}e.push(i?"L":"M",n.px,n.py),i=!0}z(f.next("path",`${H}__line ${H}__mark`),{d:e.length?Y(e):"",stroke:F,"data-series":v.index,"stroke-width":b.width,"stroke-dasharray":b.dash,opacity:b.opacity});for(const n of v.points)n.px!==void 0&&z(f.next("circle",`${H}__point ${H}__mark`),{cx:n.px,cy:n.py,r:3,fill:F})}function u(f,v){const F=[];for(const b of f)for(const e of b.points)F.push(e.y);return s(F,{zero:v})}function m(f){const v=f.series[0];if(!v)return f;const F=v.points.map((n,t)=>({point:n,label:f.labels[t],category:f.categories[t]})).filter(n=>$(n.point.y)).sort((n,t)=>t.point.y-n.point.y),b=F.reduce((n,t)=>n+t.point.y,0);let e=0;const i=F.map(n=>(e+=n.point.y,b>0?e/b*100:0));return{...f,categories:F.map(n=>n.category),labels:F.map(n=>n.label),series:[{...v,index:0,mark:"bar",axis:"left",points:F.map(n=>n.point)},{key:"cumulative",label:f.cumulativeLabel||"%",index:1,mark:"line",axis:"right",points:F.map((n,t)=>({x:n.category,xKey:n.point.xKey,label:n.label,y:i[t],rows:n.point.rows,rowKey:n.point.rowKey}))}]}}function O(f,v,F){const b=[v.left,v.right];if(f.kind!=="time"&&f.kind!=="linear")return B(f.categories,b,.2);const e=f.kind==="time"?f.categories.map(R):f.categories.map(k);if(f.kind==="time"){const t=_(e);if(t&&t.min===t.max)return c(J({min:t.min-3e4,max:t.max+3e4},f,F),b)}const i=f.xDomain||s(e,{zero:!1,nice:f.kind!=="time"}),n=f.xDomain?i:J(i,f,F);return f.kind==="time"?c(n,b):p(n,b)}function A(f,v){const F=[...new Set(f.filter(t=>Number.isFinite(t)))].sort((t,r)=>t-r);if(F.length<2){const[t,r]=v.range;return Math.max(4,(r-t)/10)}const b=[];for(let t=1;t<F.length;t++)b.push(F[t]-F[t-1]);b.sort((t,r)=>t-r);const e=Math.floor(b.length/2),i=b.length%2?b[e]:(b[e-1]+b[e])/2,n=Math.abs(v.of(F[0]+i)-v.of(F[0]));return Math.max(1,n*.8)}function w(f){const v=f.scheme||x(),{plot:F}=f,b=f.pareto?m(f.bound):f.bound,e=b.series.filter(G=>!f.hidden.has(G.key)),i=h(e),n=i.left.some(G=>(G.mark||"bar")==="bar"),t=b.yDomain||u(i.left,n),r=p(t,[F.bottom,F.top]),l=i.right.length?f.pareto?{min:0,max:100}:u(i.right,!1):null,L=l?p(l,[F.bottom,F.top]):null,M=O(b,F,f.axis&&f.axis.x),C=M.kind!=="band",ne=C?b.categories.map(G=>b.kind==="time"?R(G):k(G)):null;me({gridGroup:f.groups.grid,axisGroup:f.groups.axis,plot:F,scale:r,format:D(f.grid,{kind:"linear",step:(t.max-t.min)/5})});const ue=b.dimension&&b.dimension.col?f.grid.columns.get(b.dimension.col):void 0;C?be({group:f.groups.overlay,plot:F,scale:M,format:D(f.grid,{kind:b.kind,span:M.domain.max-M.domain.min,step:(M.domain.max-M.domain.min)/5},ue),grid:f.grid,size:f.fontSize}):j({group:f.groups.overlay,plot:F,scale:M,labels:b.labels,fontSize:f.fontSize,rotated:y(b.labels,M.step,f.fontSize)}),q({group:f.groups.rules,plot:F}),L&&g({group:f.groups.axis,plot:F,scale:L,colour:v.series(i.right[0].index),format:D(f.grid,{kind:"linear",step:(l.max-l.min)/5}),suffix:f.pareto?"%":""}),W(f.groups,F,te(f.type));const ge=new S(f.groups.marks),xe=e.filter(G=>(G.mark||"bar")==="bar"),Ce=C?A(ne,M):M.bandwidth,je=xe.length?Ce/xe.length:Ce;let _e=0;const Re=[];for(const G of e){const se=G.mark||"bar",le=G.axis==="right"&&L?L:r,ae=v.series(G.index);if(se==="bar"){const Ee=_e*je;_e++;const Te=le.of(Math.max(le.domain.min,0));for(let Ge=0;Ge<G.points.length;Ge++){const Ie=G.points[Ge];if(!$(Ie.y))continue;let Ke;if(C){const ze=b.kind==="time"?R(Ie.x):k(Ie.x);Ke=ze===null?NaN:M.of(ze)-Ce/2}else Ke=M.of(Ie.x);if(Number.isNaN(Ke))continue;const Be=le.of(Ie.y);z(ge.next("rect",`${H}__bar ${H}__mark`),{x:re(Ke+Ee),y:re(Math.min(Be,Te)),width:re(Math.max(0,je)),height:re(Math.max(1,Math.abs(Te-Be))),fill:ae,"data-series":G.index,"data-point":Ge}),Ie.px=re(Ke+Ee+je/2),Ie.py=re(Math.min(Be,Te))}continue}const de=[];let we=!1;for(const Ee of G.points){if(!$(Ee.y)){we=!1;continue}let Te;if(C){const Ie=b.kind==="time"?R(Ee.x):k(Ee.x);Te=Ie===null?NaN:re(M.of(Ie))}else Te=re(M.centre(Ee.x));if(Number.isNaN(Te)){we=!1;continue}const Ge=re(le.of(Ee.y));de.push(we?"L":"M",Te,Ge),we=!0,Ee.px=Te,Ee.py=Ge}const Ae=a(f,G.label);Ae.emphasized?Re.push({series:G,colour:ae,style:Ae}):d(ge,G,ae,Ae)}for(const G of Re)d(ge,G.series,G.colour,G.style);ge.finish(),f.labels&&f.labels.show&&ce({group:f.groups.labels,series:e,plot:F,options:f.labels,grid:f.grid,size:f.typography&&f.typography.small||f.fontSize});let fe=null;return f.annotations&&f.annotations.length&&(fe=V({group:f.groups.overlay,plot:F,xScale:M,yScale:r,rightScale:L,series:e,annotations:f.annotations,dual:!!L,format:D(f.grid,{kind:"linear",step:(t.max-t.min)/5}).tick})),{xScale:M,yScale:r,rightScale:L,dual:!!L,series:e,bound:b,annotations:fe}}function g(f){const{group:v,plot:F,scale:b,format:e}=f,i=f.side==="left"?"left":"right",n=i==="right"?F.right:F.left,t=new S(v);z(t.next("line",`${H}__axis-right`),{x1:re(n),x2:re(n),y1:re(F.top),y2:re(F.bottom),stroke:f.colour});for(const r of b.ticks(5)){const l=re(b.of(r)),L=t.next("text",`${H}__tick`);z(L,{x:re(i==="right"?F.right+6:F.left-6),y:l,"text-anchor":i==="right"?"start":"end","dominant-baseline":"middle",fill:f.colour}),L.textContent=`${e.tick(r)}${f.suffix||""}`}t.finish()}}),Qe("packages/modules/charts/quantile.js",function(o,X){"use strict";Object.defineProperty(o,"normalQuantile",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"studentTQuantile",{enumerable:!0,get:function(){return S}});const ye=Object.freeze([676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23]),q=3e-12,j=1e-300;function be(y){if(y<.5)return Math.log(Math.PI/Math.sin(Math.PI*y))-be(1-y);const U=y-1;let D=.9999999999998099;const T=U+7.5;for(let B=0;B<ye.length;B++)D+=ye[B]/(U+B+1);return .5*Math.log(2*Math.PI)+(U+.5)*Math.log(T)-T+Math.log(D)}function me(y,U,D){const T=y+U,B=y+1,_=y-1;let $=1,p=1-T*D/B;Math.abs(p)<j&&(p=j),p=1/p;let s=p;for(let c=1;c<=300;c++){const k=2*c;let R=c*(U-c)*D/((_+k)*(y+k));p=1+R*p,Math.abs(p)<j&&(p=j),$=1+R/$,Math.abs($)<j&&($=j),p=1/p,s*=p*$,R=-(y+c)*(T+c)*D/((y+k)*(B+k)),p=1+R*p,Math.abs(p)<j&&(p=j),$=1+R/$,Math.abs($)<j&&($=j),p=1/p;const I=p*$;if(s*=I,Math.abs(I-1)<q)break}return s}function te(y,U,D){if(!(y>0)||!(U>0)||!Number.isFinite(D))return Number.NaN;if(D<=0)return 0;if(D>=1)return 1;const T=Math.exp(be(y+U)-be(y)-be(U)+y*Math.log(D)+U*Math.log(1-D));return D<(y+1)/(y+U+2)?T*me(y,U,D)/y:1-T*me(U,y,1-D)/U}function J(y){const U=Math.abs(y),D=2/(2+U),T=4*D-2,B=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,15626441722e-18,-85238095915e-18,6529054439e-18,5059343495e-18,-991364156e-18,-227365122e-18,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18];let _=0,$=0,p;for(let c=B.length-1;c>0;c--)p=$,$=T*$-_+B[c],_=p;const s=D*Math.exp(-U*U+.5*(B[0]+T*$)-_);return y>=0?s:2-s}function W(y){if(!(y>0)||!(y<1))return y===0?-1/0:y===1?1/0:Number.NaN;const U=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],D=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],T=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],B=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],_=.02425;let $,p,s;y<_?($=Math.sqrt(-2*Math.log(y)),s=(((((T[0]*$+T[1])*$+T[2])*$+T[3])*$+T[4])*$+T[5])/((((B[0]*$+B[1])*$+B[2])*$+B[3])*$+1)):y<=1-_?($=y-.5,p=$*$,s=(((((U[0]*p+U[1])*p+U[2])*p+U[3])*p+U[4])*p+U[5])*$/(((((D[0]*p+D[1])*p+D[2])*p+D[3])*p+D[4])*p+1)):($=Math.sqrt(-2*Math.log(1-y)),s=-(((((T[0]*$+T[1])*$+T[2])*$+T[3])*$+T[4])*$+T[5])/((((B[0]*$+B[1])*$+B[2])*$+B[3])*$+1));const k=(.5*J(-s/Math.SQRT2)-y)*Math.sqrt(2*Math.PI)*Math.exp(s*s/2);return s-k/(1+s*k/2)}function ie(y,U){if(!(U>0)||!Number.isFinite(y))return Number.NaN;const D=.5*te(U/2,.5,U/(U+y*y));return y>0?1-D:D}function S(y,U){if(!(y>0)||!(y<1)||!(U>0))return Number.NaN;if(U>1e7)return W(y);let D=-1e4,T=1e4,B=W(y);const _=be(U/2)+be(.5)-be((U+1)/2);for(let $=0;$<60;$++){const p=ie(B,U);p<y?D=B:T=B;const s=Math.exp(-((U+1)/2)*Math.log(1+B*B/U)-_)/Math.sqrt(U),c=s>0?(p-y)/s:0;if(Math.abs(c)<1e-12)break;const k=B-c;if(B=k>D&&k<T&&Number.isFinite(k)?k:(D+T)/2,T-D<1e-12)break}return B}}),Qe("packages/modules/charts/trendline.js",function(o,X){"use strict";Object.defineProperty(o,"normaliseTrends",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"linearTrend",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"movingAverageTrend",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"exponentialTrend",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"computeTrend",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"trendText",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"drawTrendlines",{enumerable:!0,get:function(){return d}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/svg.js"),be=j.attrs,me=j.path,te=j.ribbonPath,J=j.round,W=j.setText,ie=j.SVG_NS,y=X("packages/modules/charts/typography.js").applySize,D=X("packages/modules/charts/styles.js").NS,T=X("packages/modules/charts/scale.js"),B=T.toNumber,_=T.toTime,p=X("packages/modules/charts/quantile.js").studentTQuantile,c=X("packages/modules/charts/format.js").r2Digits,k={linear:new Set(["linear","lr","ols","regression","least-squares"]),movingAverage:new Set(["movingaverage","moving-average","ma","sma","rolling"]),exponential:new Set(["exponential","exp","ewma","ses","holt","smoothing"])},R=1e-4,I=1-1e-4;function z(u){const m=String(u||"linear").toLowerCase();return k.linear.has(m)?"linear":k.movingAverage.has(m)?"movingAverage":k.exponential.has(m)?"exponential":null}function Y(u){if(!u)return[];const m=Array.isArray(u)?u:[u],O=[];for(const A of m){if(A===!0){O.push({method:"linear"});continue}if(typeof A=="string"){const w=z(A);w&&O.push({method:w});continue}if(A&&typeof A=="object"){const w=z(A.method);w&&O.push({...A,method:w})}}return O}function re(u,m){if(u.kind==="band")return u.centre(m);const O=u.kind==="time"?_(m):B(m);return O===null?NaN:u.of(O)}function ee(u){const m=[];for(const O of u.points){const A=Number(O.y);m.push({value:Number.isFinite(A)?A:null,rawX:O.x})}return m}function H(u,m){const O=[];for(const A of u.points){const w=m.kind==="time"?_(A.x):B(A.x),g=Number(A.y);w===null||!Number.isFinite(w)||!Number.isFinite(g)||O.push({x:w,y:g})}return O.sort((A,w)=>A.x-w.x),O}function pe(u,m,O={}){const A=u.length;if(A<2)return null;let w=0,g=0;for(const ne of u)w+=ne.x,g+=ne.y;w/=A,g/=A;let f=0,v=0,F=0;for(const ne of u){const ue=ne.x-w,ge=ne.y-g;f+=ue*ue,v+=ue*ge,F+=ge*ge}if(f===0)return null;const b=v/f,e=g-b*w,i=F===0?1:Math.max(0,Math.min(1,v*v/(f*F))),n=u[0].x,t=u[A-1].x,r=ne=>({x:ne,y:e+b*ne}),l=[r(n),r(t)],L=[];let M=null;const C=Math.max(0,Math.floor(Number(m)||0));if(C>0&&t>n){const ne=(t-n)/(A-1);if(ne>0&&(L.push(r(t),r(t+C*ne)),A>2)){const ue=Number.isFinite(O.confidence)&&O.confidence>0&&O.confidence<1?Number(O.confidence):.95,ge=1-(1-ue)/2,xe=Math.max(0,F-b*v),Ce=Math.sqrt(xe/(A-2)),je=p(ge,A-2),_e=[];for(let Re=0;Re<=C;Re++){const fe=t+Re*ne,G=e+b*fe,se=1/A+(fe-w)**2/f,le=Ce*Math.sqrt(1+se),ae=Ce*Math.sqrt(se);_e.push({x:fe,mean:G,lower:G-je*le,upper:G+je*le,lowerMean:G-je*ae,upperMean:G+je*ae})}M={confidence:ue,points:_e}}}return{fit:l,forecast:L,band:M,stats:{method:"linear",slope:b,intercept:e,r2:i,n:A,forecast:L.length?C:0,confidence:M?M.confidence:null}}}function x(u,m){const O=Math.max(1,Math.floor(Number(m)||3)),A=[];let w=0;const g=[];for(const f of u)Number.isFinite(f.value)&&(A.push(f.value),w+=f.value,A.length>O&&(w-=A.shift())),A.length&&g.push({x:f.rawX,y:w/A.length});return g.length<2?null:{fit:g,stats:{method:"movingAverage",window:O}}}function Q(u,m){const O=u.length,A=new Array(O).fill(null);let w=null,g=0;for(let f=0;f<O;f++){const v=u[f];if(!Number.isFinite(v)){w!==null&&(A[f]=w);continue}if(w===null){w=v,A[f]=v;continue}g+=(v-w)**2,w=m*v+(1-m)*w,A[f]=w}return{smoothed:A,sse:g}}function ce(u,m,O){const A=u.length,w=new Array(A).fill(null);let g=null,f=null,v=0;for(let F=0;F<A;F++){const b=u[F];if(!Number.isFinite(b)){g!==null&&(g+=f,w[F]=g);continue}if(g===null){g=b,w[F]=b;continue}if(f===null){f=b-g;const n=g+f;v+=(b-n)**2;const t=g;g=m*b+(1-m)*(t+f),f=O*(g-t)+(1-O)*f,w[F]=g;continue}const e=g+f;v+=(b-e)**2;const i=g;g=m*b+(1-m)*(i+f),f=O*(g-i)+(1-O)*f,w[F]=g}return{smoothed:w,sse:v}}function E(u,m,O,A=80){const w=(Math.sqrt(5)-1)/2;let g=m,f=O,v=f-w*(f-g),F=g+w*(f-g),b=u(v),e=u(F);for(let i=0;i<A;i++)b<e?(f=F,F=v,e=b,v=f-w*(f-g),b=u(v)):(g=v,v=F,b=e,F=g+w*(f-g),e=u(F));return(g+f)/2}function V(u,m){const O=String(m.kind||m.model||"").toLowerCase()==="holt",A=u.map(e=>Number.isFinite(e.value)?e.value:null);if(A.filter(e=>e!==null).length<(O?2:1))return null;const g=e=>Math.min(I,Math.max(R,e));let f=Number.isFinite(m.alpha)?g(Number(m.alpha)):null,v=O&&Number.isFinite(m.beta)?g(Number(m.beta)):null;if(O){if(f===null||v===null){let e=f===null?.5:f,i=v===null?.5:v;for(let n=0;n<6;n++)f===null&&(e=E(t=>ce(A,t,i).sse,R,I)),v===null&&(i=E(t=>ce(A,e,t).sse,R,I));f=f===null?e:f,v=v===null?i:v}}else f===null&&(f=E(e=>Q(A,e).sse,R,I));const F=O?ce(A,f,v):Q(A,f),b=[];for(let e=0;e<u.length;e++){const i=F.smoothed[e];i===null||!Number.isFinite(i)||b.push({x:u[e].rawX,y:i})}return b.length<2?null:{fit:b,stats:{method:"exponential",kind:O?"holt":"ses",alpha:f,beta:O?v:null}}}function h(u,m,O){if(m.method==="linear"){const w=H(u,O);return pe(w,m.forecast,{confidence:m.confidence})}const A=ee(u);return m.method==="movingAverage"?x(A,m.window||m.period):V(A,m)}function a(u,m,O,A,w,g){const f=m?` for ${m}`:"";if(u.method==="linear"){const e=Number.isFinite(u.r2)?`, R² ${u.r2.toFixed(2)}`:"";let i=`Trend (linear)${f}: slope ${O(u.slope)}${e}`;if(u.forecast>0&&A&&A.length){const n=A[A.length-1];if(i+=`; forecast ${u.forecast} step${u.forecast===1?"":"s"} ahead to ${O(n.y)}`,w&&w.points.length){const t=w.points[w.points.length-1],r=g==="confidence"||g==="mean",l=r?t.lowerMean:t.lower,L=r?t.upperMean:t.upper,M=r?"confidence":"prediction",C=Math.round(w.confidence*100);i+=`; ${C}% ${M} band ${O(l)} to ${O(L)} at the horizon`}}return i}if(u.method==="movingAverage")return`Trend (moving average, window ${u.window})${f}`;const v=u.kind==="holt"?"Holt":"single",F=Number.isFinite(u.alpha)?`, α ${u.alpha.toFixed(2)}`:"",b=Number.isFinite(u.beta)?`, β ${u.beta.toFixed(2)}`:"";return`Trend (exponential, ${v})${f}${F}${b}`}function d(u){const m=Y(u.trend);if(!m.length)return[];const O=u.group.ownerDocument;let A=null;for(const f of u.group.childNodes||[])if(f&&String(f.getAttribute&&f.getAttribute("class"))===`${D}__trends`){A=f;break}A||(A=O.createElementNS(ie,"g"),A.setAttribute("class",`${D}__trends`),u.group.appendChild(A)),u.clip?A.setAttribute("clip-path",`url(#${u.clip})`):A.removeAttribute("clip-path");const w=new q(A),g=[];for(const f of m)for(const v of u.series){const F=v.axis==="right"&&u.rightScale?u.rightScale:u.yScale,b=h(v,f,u.xScale);if(!b)continue;const e=u.scheme.series(v.index),i=[];for(const r of b.fit){const l=re(u.xScale,r.x),L=F.of(r.y);!Number.isFinite(l)||!Number.isFinite(L)||i.push(i.length?"L":"M",J(l),J(L))}if(i.length<4)continue;if(be(w.next("path",`${D}__trend`),{d:me(i),fill:"none",stroke:e,"data-series":v.index}),f.band!==!1&&b.band&&b.band.points.length>=2){const r=f.band==="confidence"||f.band==="mean",l=[];for(const M of b.band.points){const C=re(u.xScale,M.x),ne=r?M.lowerMean:M.lower,ue=r?M.upperMean:M.upper,ge=F.of(ne),xe=F.of(ue);!Number.isFinite(C)||!Number.isFinite(ge)||!Number.isFinite(xe)||l.push({x:J(C),lower:J(ge),upper:J(xe)})}const L=te(l);L&&be(w.next("path",`${D}__trend-band`),{d:L,fill:e,"fill-opacity":.15,stroke:"none","data-series":v.index})}const t=b.forecast||[];if(t.length>=2){const r=[];for(const l of t){const L=re(u.xScale,l.x),M=F.of(l.y);!Number.isFinite(L)||!Number.isFinite(M)||r.push(r.length?"L":"M",J(L),J(M))}r.length>=4&&be(w.next("path",`${D}__trend-forecast`),{d:me(r),fill:"none",stroke:e,"data-series":v.index})}if(f.label!==!1&&b.stats.method==="linear"&&Number.isFinite(b.stats.r2)){const r=b.fit[b.fit.length-1],l=w.next("text",`${D}__trend-label`);y(l,u.size),be(l,{x:J(re(u.xScale,r.x)),y:J(F.of(r.y))-4,"text-anchor":"end",fill:e}),W(l,u.grid.messages.t("chart.r2",{value:c(u.grid,b.stats.r2)}))}g.push({text:a(b.stats,v.label,u.format,t,f.band===!1?null:b.band,f.band)})}return w.finish(),g.filter(f=>f.text)}}),Qe("packages/modules/charts/rulecolour.js",function(o,X){"use strict";Object.defineProperty(o,"colourOf",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"ruleColour",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"ruleLegend",{enumerable:!0,get:function(){return be}});const ye="*";function q(me){if(!me||typeof me!="object")return null;for(const te of["background","backgroundColor","color"]){const J=me[te];if(typeof J=="string"&&J.trim())return J.trim()}return null}function j(me){const{grid:te,col:J,value:W}=me;if(!te||!J||!te.formatting||typeof te.formatting.styleFor!="function")return null;try{return q(te.formatting.styleFor(J,W))}catch{return null}}function be(me){const{grid:te,col:J}=me,W=new Set([...me.colours||[]].filter(Boolean));if(!W.size||!te||!te.formatting||typeof te.formatting.list!="function")return[];let ie;try{ie=[...te.formatting.list(ye)||[],...J?te.formatting.list(J)||[]:[]]}catch{return[]}const S=[],y=new Set;for(const U of ie){if(!U||U.enabled===!1)continue;const D=q(U.style);!D||!W.has(D)||y.has(D)||(y.add(D),S.push({key:U.id||`rule:${S.length}`,label:U.label||U.id||D,colour:D,index:S.length}))}return S}}),Qe("packages/modules/charts/cartesian.js",function(o,X){"use strict";Object.defineProperty(o,"CARTESIAN",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"axisWindowSpan",{enumerable:!0,get:function(){return je}}),Object.defineProperty(o,"axisWindowNow",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"rollingDomain",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"WINDOW_LEAD",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"aheadOfWindow",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"staleWindow",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"windowedBound",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"slotPadFor",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"pinnedContinuousX",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(o,"bandedX",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"dataInterval",{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(o,"continuousSlot",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"xDomainFor",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(o,"xScaleFor",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(o,"drawFits",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(o,"drawConfidenceBand",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(o,"drawBoundErrorBars",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(o,"drawForest",{enumerable:!0,get:function(){return rn}}),Object.defineProperty(o,"drawReferenceLines",{enumerable:!0,get:function(){return et}}),Object.defineProperty(o,"drawCartesian",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(o,"HIT_TOLERANCE",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(o,"nearestDrawnPoint",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(o,"nearestCategory",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(o,"categoryKeyAt",{enumerable:!0,get:function(){return Jt}});const ye=X("packages/modules/charts/axis.js"),q=ye.drawAxisLines,j=ye.drawAxisTitle,be=ye.drawBandLabels,me=ye.drawCategoryAxis,te=ye.drawContinuousAxis,J=ye.drawMeasureAxis,W=ye.overhangFor,ie=ye.pinXDomain,S=ye.setPlotClip,y=X("packages/modules/charts/frame.js"),U=y.Pool,D=y.shouldRotate,T=X("packages/modules/charts/format.js"),B=T.formatters,_=T.r2Digits,$=X("packages/modules/charts/scale.js"),p=$.bandScale,s=$.extent,c=$.isNumber,k=$.key,R=$.linearScale,I=$.measureDomain,z=$.timeScale,Y=$.toNumber,re=$.toTime,ee=X("packages/modules/charts/svg.js"),H=ee.attrs,pe=ee.path,x=ee.ribbonPath,Q=ee.round,ce=ee.setText,E=ee.SVG_NS,h=X("packages/modules/charts/styles.js").NS,d=X("packages/modules/charts/labels.js").drawDataLabels,m=X("packages/modules/charts/dense.js").downsample,A=X("packages/modules/charts/scheme.js").resolveScheme,g=X("packages/modules/charts/typography.js").applySize,v=X("packages/modules/charts/combo.js").drawRightAxis,F=X("packages/modules/charts/annotations.js"),b=F.drawAnnotations,e=F.overlayLayer,n=X("packages/modules/charts/trendline.js").drawTrendlines,t=X("packages/modules/charts/rulecolour.js"),r=t.ruleColour,l=t.ruleLegend,M=X("packages/core/src/internal/util.js").warnOnce,C=3.5,ne=Object.freeze({line:{zero:!1,marks:"path"},step:{zero:!1,marks:"path"},area:{zero:!0,marks:"path"},rangeArea:{zero:!1,marks:"path"},bar:{zero:!0,marks:"rect"},horizontalBar:{zero:!0,marks:"rect",horizontal:!0},waterfall:{zero:!0,marks:"rect"},scatter:{zero:!1,marks:"circle"},bubble:{zero:!1,marks:"circle"},candlestick:{zero:!1,marks:"rect"}});function ue(Z){const Oe=[];for(let ke=0;ke<Z.length;ke++){const Me=Z[ke];if(ke===0){Oe.push("M",Me.x,Me.y);continue}Oe.push("L",Me.x,Z[ke-1].y),Oe.push("L",Me.x,Me.y)}return Oe}function ge(Z,Oe,ke){if(ke)return[0,100];if(!Oe){const $e=[];for(const We of Z)for(const Le of We.points)$e.push(Le.y);return $e}const Me=[],Ne=[],Pe=Z[0]?Z[0].points.length:0;for(let $e=0;$e<Pe;$e++){let We=0,Le=0;for(const De of Z){const Ve=De.points[$e]?De.points[$e].y:null;c(Ve)&&(Ve>=0?We+=Ve:Le+=Ve)}Me.push(We),Ne.push(Le)}return[...Me,...Ne]}function xe(Z){const Oe=[0];if(!Z)return Oe;let ke=0;for(const Me of Z.points)c(Me.y)&&(ke+=Me.y,Oe.push(ke));return Oe}function Ce(Z,Oe){const ke=new Float64Array(Z),Me=new Float64Array(Z);return{take(Ne,Pe){const $e=Oe?Oe[Ne]:0,We=Oe?$e?Pe/$e*100:0:Pe;if(We>=0){const De=ke[Ne];return ke[Ne]+=We,[De,ke[Ne]]}const Le=Me[Ne];return Me[Ne]+=We,[Le,Me[Ne]]}}}function je(Z){const Oe=Z&&Z.window;if(!Oe||typeof Oe!="object")return 0;const ke=Number(Oe.span);return!Number.isFinite(ke)||ke<=0?0:Oe.kind!=="time"?(M("chart.axis.window.kind",`axis window kind "${Oe.kind}" is not supported on a chart axis; only { kind: "time", span } rolls the domain. Bound the row count with the source's maxRows instead.`),0):ke}function _e(Z,Oe){const ke=Z&&Z.window;if(!ke||typeof ke!="object"||typeof ke.now!="function")return Oe;const Me=Number(ke.now());return Number.isFinite(Me)?Me:(M("chart.axis.window.now","axis.x.window.now did not return a time, so the rolling window is measured from this device's clock instead. It must return epoch milliseconds — the same number Date.now() returns — because that is what the x values are compared against."),Oe)}function Re(Z,Oe,ke){const Me=ke+Z*fe;let Ne=ke;for(const Pe of Oe)Number.isFinite(Pe)&&Pe>Ne&&Pe<=Me&&(Ne=Pe);return{min:Ne-Z,max:Ne}}const fe=.25;function G(Z,Oe,ke){const Me=je(Oe);if(!Me||!Z||!Array.isArray(Z.categories))return null;const Ne=ne[ke];if(!Ne||Ne.horizontal||Z.kind==="category"||ke==="bar"&&!Ge(Z,ke,Oe))return null;const Pe=Z.categories.map($e=>Z.kind==="time"?re($e):Y($e));return{span:Me,values:Pe}}function se(Z,Oe,ke,Me){const Ne=G(Z,Oe,ke);if(!Ne)return null;const Pe=Ne.span*fe;let $e=0,We=0;for(const Le of Ne.values)Le===null||!Number.isFinite(Le)||Le-Me<=Pe||($e+=1,Le-Me>We&&(We=Le-Me));return $e?{span:Ne.span,limit:Pe,count:$e,lead:We}:null}function le(Z,Oe,ke,Me){const Ne=G(Z,Oe,ke);if(!Ne)return null;const{span:Pe}=Ne,$e=Ne.values.filter(Ve=>Ve!==null&&Number.isFinite(Ve));if(!$e.length)return null;const{min:We,max:Le}=Re(Pe,$e,Me);let De=-1/0;for(const Ve of $e){if(Ve>=We&&Ve<=Le)return null;Ve<We&&Ve>De&&(De=Ve)}return De===-1/0?{span:Pe,newest:null,age:null,points:$e.length}:{span:Pe,newest:De,age:Me-De,points:$e.length}}function ae(Z,Oe,ke,Me){const Ne=G(Z,Oe,ke);if(!Ne)return Z;const{span:Pe,values:$e}=Ne,We=$e.filter(Je=>Je!==null&&Number.isFinite(Je));if(!We.length)return Z;const{min:Le,max:De}=Re(Pe,We,Me),Ve=[];for(let Je=0;Je<$e.length;Je++){const ct=$e[Je];(ct===null||!Number.isFinite(ct)||ct>=Le&&ct<=De)&&Ve.push(Je)}return Ve.length===$e.length?Z:{...Z,categories:Ve.map(Je=>Z.categories[Je]),labels:Array.isArray(Z.labels)?Ve.map(Je=>Z.labels[Je]):Z.labels,series:(Z.series||[]).map(Je=>({...Je,points:Array.isArray(Je.points)?Ve.map(ct=>Je.points[ct]).filter(ct=>ct!==void 0):Je.points})),windowed:$e.length-Ve.length}}const de=Object.freeze({bar:.2,candlestick:.3}),we=.4;function Ae(Z){return Object.hasOwn(de,Z)?de[Z]:we}const Ee=new Set(["bar","candlestick"]);function Te(Z){const Oe=Z&&typeof Z.scale=="string"?Z.scale:"";return Oe==="time"||Oe==="linear"}function Ge(Z,Oe,ke){if(!Z||Z.kind==="category")return!1;const Me=ne[Oe];return Me&&Me.horizontal?!1:Ee.has(Oe)?Te(ke):!0}function Ie(Z,Oe,ke){return!Ge(Z,Oe,ke)}function Ke(Z){const Oe=Z.filter(Ne=>typeof Ne=="number"&&Number.isFinite(Ne)).slice().sort((Ne,Pe)=>Ne-Pe),ke=[];for(let Ne=1;Ne<Oe.length;Ne++){const Pe=Oe[Ne]-Oe[Ne-1];Pe>0&&ke.push(Pe)}if(!ke.length)return 0;ke.sort((Ne,Pe)=>Ne-Pe);const Me=Math.floor(ke.length/2);return ke.length%2?ke[Me]:(ke[Me-1]+ke[Me])/2}function Be(Z){const{bound:Oe,scale:ke,config:Me,padding:Ne}=Z,Pe=Me?Number(Me.barWidth):NaN,$e=Number.isFinite(Pe)&&Pe>0,We=(Oe.categories||[]).map(Je=>Oe.kind==="time"?re(Je):Y(Je)),Le=$e?Pe:Ke(We),De=Math.abs(ke.range[1]-ke.range[0]);if(!Le)return Math.max(1,De/20*(1-Ne));const Ve=Math.abs(ke.of(ke.domain.min+Le)-ke.of(ke.domain.min));return Math.max(1,$e?Ve:Ve*(1-Ne))}function ze(Z,Oe,ke,Me){if(Ie(Z,Oe,ke))return null;const Ne=je(ke),Pe=Z.kind==="time"?Z.categories.map(re):Z.categories.map(Y);if(Z.kind==="time"&&!Ne){const We=s(Pe);if(We&&We.min===We.max)return ie({min:We.min-3e4,max:We.max+3e4},Z,ke)}const $e=Ne?Re(Ne,Pe,Number.isFinite(Me)?Me:_e(ke,Date.now())):I(Pe,{zero:!1,nice:Z.kind!=="time"});return ie($e,Z,ke)}function qe(Z,Oe,ke,Me){const Ne=[Oe.left,Oe.right];if(Ie(Z,ke,Me))return je(Me)&&M("chart.axis.window.band","a rolling time window needs a continuous x axis; this chart bands its x values, so the window is ignored. Bind a date or numeric column to x, or put this type on a continuous axis with axis.x.scale."),p(Z.categories,Ne,Ae(ke));const Pe=Z.xDomain||ze(Z,ke,Me);return Z.kind==="time"?z(Pe,Ne):R(Pe,Ne)}function ot(Z,Oe){if(Z.kind==="band")return Z.centre(Oe.x);const ke=Z.kind==="time"?re(Oe.x):Y(Oe.x);return ke===null?NaN:Z.of(ke)}function Ot(Z,Oe){const ke=Z&&Z.seriesStyle&&Z.seriesStyle[Oe];if(ke)return{width:ke.width!=null?String(ke.width):null,dash:Array.isArray(ke.dash)&&ke.dash.length?ke.dash.join(" "):null,opacity:null,emphasized:!1};const Me=Z&&Array.isArray(Z.emphasis)?Z.emphasis:null;if(!Me||!Me.length)return{width:null,dash:null,opacity:null,emphasized:!1};const Ne=Me.includes(Oe);return{width:Ne?"var(--lattice-chart-emphasis-width, 3.5)":null,dash:null,opacity:Ne?null:"var(--lattice-chart-muted-opacity, .35)",emphasized:Ne}}function St(Z){const{series:Oe,xScale:ke,yScale:Me,baseline:Ne,fill:Pe,colour:$e,stack:We,style:Le}=Z,De=[],Ve=[];let Je=!1;const ct=[];for(let tt=0;tt<Oe.points.length;tt++){const Pt=Oe.points[tt],At=Q(ot(ke,Pt));if(!c(Pt.y)||Number.isNaN(At)){Je=!1;continue}ct[tt]=!0;const Et=Pt.y,gt=We?We.take(tt,Et):null,yt=Q(Me.of(gt?gt[1]:Et)),_t=Q(Me.of(gt?gt[0]:Ne));Z.step&&Je&&De.push("L",At,Z.previous),De.push(Je?"L":"M",At,yt),Z.previous=yt,Pe&&Ve.push(Je?"L":"M",At,yt),Pe&&!Je&&Ve.push("M",At,yt),Je=!0,Pt.px=At,Pt.py=yt,Pt.pbase=_t}if(H(Z.pool.next("path",`${h}__line ${h}__mark`),{d:De.length?pe(De):"",stroke:$e,"data-series":Z.index,"stroke-width":Le?Le.width:null,"stroke-dasharray":Le?Le.dash:null,opacity:Le?Le.opacity:null}),!Pe){zt({...Z,placed:ct});return}const rt=[];let ft=[];const jt=()=>{if(ft.length<2){ft=[];return}rt.push("M",ft[0].x,ft[0].base);for(const tt of ft)rt.push("L",tt.x,tt.y);for(let tt=ft.length-1;tt>=0;tt--)rt.push("L",ft[tt].x,ft[tt].base);rt.push("Z"),ft=[]};for(const tt of Oe.points){if(!c(tt.y)||tt.px===void 0){jt();continue}ft.push({x:tt.px,y:tt.py,base:tt.pbase})}jt(),H(Z.pool.next("path",`${h}__area ${h}__mark`),{d:rt.length?pe(rt):"",fill:$e,"data-series":Z.index,opacity:Le?Le.emphasized?"1":Le.opacity:null}),zt({...Z,placed:ct})}function zt(Z){const{series:Oe,placed:ke}=Z;for(let Me=0;Me<Oe.points.length;Me++){if(!ke[Me]||ke[Me-1]||ke[Me+1])continue;const Ne=Oe.points[Me];H(Z.pool.next("circle",`${h}__point ${h}__mark`),{cx:Ne.px,cy:Ne.py,r:C,fill:Z.colour,"data-series":Z.index,"data-point":Me})}}function $t(Z,Oe){const ke=Z&&Z.range;if(!Array.isArray(ke)||ke.length!==2)return Oe;const[Me,Ne]=ke;return!Number.isFinite(Me)||!Number.isFinite(Ne)||!Number.isFinite(Oe)?Oe:Math.min(Math.max(Me,Ne),Math.max(Math.min(Me,Ne),Oe))}function nn(Z){const{series:Oe,xScale:ke,yScale:Me,baseline:Ne,colour:Pe,stack:$e,slot:We}=Z;for(let Le=0;Le<Oe.points.length;Le++){const De=Oe.points[Le];if(!c(De.y))continue;const Ve=ke.kind==="band"?ke.of(De.x):ot(ke,De)-We.span/2;if(Number.isNaN(Ve))continue;const Je=De.y,ct=Z.pointColour&&Z.pointColour(De)||Pe,rt=$e?$e.take(Le,Je):[Ne,Je],ft=$t(Me,Me.of(rt[1])),jt=$t(Me,Me.of(rt[0])),tt=Ve+We.offset,Pt=ke.kind==="band"?tt:$t(ke,tt),At=ke.kind==="band"?tt+We.width:$t(ke,tt+We.width),Et=Z.pool.next("rect",`${h}__bar ${h}__mark`,`${Oe.key}:${k(De.x)}`);H(Et,{x:Q(Pt),y:Q(Math.min(ft,jt)),width:Q(Math.max(0,At-Pt)),height:Q(Math.max(1,Math.abs(jt-ft))),fill:ct,"data-series":Z.index,"data-point":Le}),De.px=Q(Ve+We.offset+We.width/2),De.py=Q(Math.min(ft,jt)),De.pbase=Q(Math.max(ft,jt))}}function Yt(Z){const{series:Oe,xScale:ke,yScale:Me}=Z;let Ne=0;for(let Pe=0;Pe<Oe.points.length;Pe++){const $e=Oe.points[Pe];if(!c($e.y))continue;const We=$e.y,Le=Pe===Oe.points.length-1,De=Z.total&&Le?0:Ne,Ve=(Z.total&&Le,Ne+We);Z.total,Ne+=We;const Je=$t(Me,Me.of(Math.max(De,Ve))),ct=$t(Me,Me.of(Math.min(De,Ve))),rt=Z.pool.next("rect",`${h}__bar ${h}__mark`,`${Oe.key}:${k($e.x)}`);H(rt,{x:Q(ke.of($e.x)),y:Q(Je),width:Q(ke.bandwidth),height:Q(Math.max(1,ct-Je)),fill:We>=0?Z.positive:Z.negative,"data-series":Z.index,"data-point":Pe}),$e.px=Q(ke.of($e.x)+ke.bandwidth/2),$e.py=Q(Je)}}function ln(Z){const{series:Oe,valueScale:ke,baseline:Me,colour:Ne,stack:Pe,slot:$e}=Z;for(let We=0;We<Oe.points.length;We++){const Le=Oe.points[We];if(!c(Le.y))continue;const De=Z.bandScale.of(Le.x);if(Number.isNaN(De))continue;const Ve=Le.y,Je=Z.pointColour&&Z.pointColour(Le)||Ne,ct=Pe?Pe.take(We,Ve):[Me,Ve],rt=$t(ke,ke.of(ct[0])),ft=$t(ke,ke.of(ct[1]));H(Z.pool.next("rect",`${h}__bar ${h}__mark`,`${Oe.key}:${k(Le.x)}`),{x:Q(Math.min(rt,ft)),y:Q(De+$e.offset),width:Q(Math.max(1,Math.abs(ft-rt))),height:Q(Math.max(0,$e.width)),fill:Je,"data-series":Z.index,"data-point":We}),Le.px=Q(ft),Le.py=Q(De+$e.offset+$e.width/2),Le.pbase=Q(rt)}}function Mt(Z){const Oe=Z.group.ownerDocument;let ke=null;for(const Pe of Z.group.childNodes||[])if(Pe&&String(Pe.getAttribute&&Pe.getAttribute("class"))===`${h}__fits`){ke=Pe;break}ke||(ke=Oe.createElementNS(E,"g"),ke.setAttribute("class",`${h}__fits`),Z.group.appendChild(ke));const Me=new U(ke),Ne=[];for(const Pe of Z.series){let $e=0,We=0,Le=0;for(const gt of Pe.points){const yt=Number(gt.x),_t=Number(gt.y);!Number.isFinite(yt)||!Number.isFinite(_t)||($e++,We+=yt,Le+=_t)}if($e<2)continue;const De=We/$e,Ve=Le/$e;let Je=0,ct=0,rt=0,ft=1/0,jt=-1/0;for(const gt of Pe.points){const yt=Number(gt.x),_t=Number(gt.y);if(!Number.isFinite(yt)||!Number.isFinite(_t))continue;const Rt=yt-De,fn=_t-Ve;Je+=Rt*Rt,ct+=Rt*fn,rt+=fn*fn,yt<ft&&(ft=yt),yt>jt&&(jt=yt)}if(Je===0)continue;const tt=ct/Je,Pt=Ve-tt*De,At=rt===0?1:Math.max(0,Math.min(1,ct*ct/(Je*rt))),Et=Z.scheme.series(Pe.index);if(H(Me.next("path",`${h}__fit`),{d:pe(["M",Q(Z.xScale.of(ft)),Q(Z.yScale.of(Pt+tt*ft)),"L",Q(Z.xScale.of(jt)),Q(Z.yScale.of(Pt+tt*jt))]),fill:"none",stroke:Et,"data-series":Pe.index}),Z.showR2){const gt=Me.next("text",`${h}__fit-label`);g(gt,Z.size),H(gt,{x:Q(Z.xScale.of(jt)),y:Q(Z.yScale.of(Pt+tt*jt))-4,"text-anchor":"end",fill:Et}),ce(gt,Z.grid.messages.t("chart.r2",{value:_(Z.grid,At)}))}Ne.push({key:Pe.key,slope:tt,intercept:Pt,r2:At,n:$e})}return Me.finish(),Ne}function Lt(Z){const Oe=Z.group.ownerDocument;let ke=null;for(const De of Z.group.childNodes||[])if(De&&String(De.getAttribute&&De.getAttribute("class"))===`${h}__band`){ke=De;break}ke||(ke=Oe.createElementNS(E,"g"),ke.setAttribute("class",`${h}__band`),Z.group.firstChild?Z.group.insertBefore(ke,Z.group.firstChild):Z.group.appendChild(ke));const Me=new U(ke),Ne=Z.band&&Array.isArray(Z.band.points)?Z.band.points:[],Pe=Number.isFinite(Z.index)?Number(Z.index):0,$e=Z.scheme.series(Pe),We=Number.isFinite(Z.opacity)?Number(Z.opacity):.15,Le=[];for(const De of Ne){const Ve=Number(De.x),Je=Number(De.lower),ct=Number(De.upper);if(!Number.isFinite(Ve)||!Number.isFinite(Je)||!Number.isFinite(ct))continue;const rt=Number(De.yhat);Le.push({x:Q(Z.xScale.of(Ve)),lower:Q(Z.yScale.of(Je)),upper:Q(Z.yScale.of(ct)),yhat:Number.isFinite(rt)?Q(Z.yScale.of(rt)):null})}if(Le.length>=2&&(H(Me.next("path",`${h}__band-fill`),{d:x(Le),fill:$e,"fill-opacity":We,stroke:"none","data-series":Pe}),Z.line!==!1)){const De=[];let Ve=!1;for(const Je of Le){if(Je.yhat===null){Ve=!1;continue}De.push(Ve?"L":"M",Je.x,Je.yhat),Ve=!0}H(Me.next("path",`${h}__band-line`),{d:De.length?pe(De):"",fill:"none",stroke:$e,"data-series":Pe})}return Me.finish(),{points:Le.length,confidence:Z.band&&Number.isFinite(Z.band.confidence)?Number(Z.band.confidence):null}}function Xt(Z){const Oe=Z.group.ownerDocument;let ke=null;for(const Le of Z.group.childNodes||[])if(Le&&String(Le.getAttribute&&Le.getAttribute("class"))===`${h}__whiskers`){ke=Le;break}ke||(ke=Oe.createElementNS(E,"g"),ke.setAttribute("class",`${h}__whiskers`),Z.group.appendChild(ke));const Me=new U(ke),Ne=Number.isFinite(Z.cap)?Number(Z.cap):4,Pe=Z.colour||"currentColor",$e=Z.orient!=="v";let We=0;for(const Le of Z.points||[]){const De=Number(Le.main),Ve=Number(Le.lo),Je=Number(Le.hi);if(!Number.isFinite(De)||!Number.isFinite(Ve)||!Number.isFinite(Je))continue;const ct=$e?["M",Ve,De,"L",Je,De,"M",Ve,De-Ne,"L",Ve,De+Ne,"M",Je,De-Ne,"L",Je,De+Ne]:["M",De,Ve,"L",De,Je,"M",De-Ne,Ve,"L",De+Ne,Ve,"M",De-Ne,Je,"L",De+Ne,Je];H(Me.next("path",`${h}__whisker`),{d:pe(ct),stroke:Pe,fill:"none"}),We++}return Me.finish(),We}function rn(Z){const Oe=Z.scheme||A(),ke=Z.typography||{small:Z.fontSize||11,axisTitle:11},{plot:Me,bound:Ne}=Z,Pe=Ne.series[0]&&Ne.series[0].points||[],$e=Pe.map(rt=>rt.label),We=Oe.series(0),Le=p($e,[Me.top,Me.bottom],.4),De=[0];for(const rt of Pe)for(const ft of[rt.x,rt.lower,rt.upper])Number.isFinite(ft)&&De.push(ft);const Ve=R(I(De,{zero:!1}),[Me.left,Me.right]);Xt({group:Z.groups.overlay,orient:"h",colour:We,points:Pe.map(rt=>({main:Q(Le.centre(rt.label)),lo:Q(Ve.of(rt.lower)),hi:Q(Ve.of(rt.upper))}))});const Je=new U(Z.groups.marks);let ct=0;for(const rt of Pe)Number.isFinite(rt.x)&&(H(Je.next("circle",`${h}__point ${h}__mark`),{cx:Q(Ve.of(rt.x)),cy:Q(Le.centre(rt.label)),r:C,fill:We}),ct++);return Je.finish(),et({group:Z.groups.rules,plot:Me,scale:Ve,lines:[{value:0}]}),te({group:Z.groups.axis,plot:Me,scale:Ve,format:B(Z.grid,{kind:"linear",step:(Ve.domain.max-Ve.domain.min)/5}),config:{},grid:Z.grid,size:ke.small}),be({group:Z.groups.labels,plot:Me,scale:Le,labels:$e,fontSize:ke.small,config:{}}),{series:[],marks:ct}}function et(Z){const Oe=new U(e(Z.group,`${h}__reflines`));for(const ke of Z.lines||[]){if(!c(ke.value))continue;const Me=Q(Z.scale.of(ke.value));if(H(Oe.next("path",`${h}__reference`),{d:pe(["M",Q(Z.plot.left),Me,"L",Q(Z.plot.right),Me]),stroke:ke.colour||"currentColor","stroke-dasharray":"4 3",fill:"none"}),!ke.label)continue;const Ne=Oe.next("text",`${h}__reference-label`);H(Ne,{x:Q(Z.plot.right-4),y:Me-4,"text-anchor":"end"}),ce(Ne,ke.label)}Oe.finish()}function ht(Z){const{series:Oe,xScale:ke,yScale:Me,colour:Ne}=Z,Pe=Z.size||null;for(let $e=0;$e<Oe.points.length;$e++){const We=Oe.points[$e];if(!c(We.y))continue;const Le=Q(ot(ke,We));if(Number.isNaN(Le))continue;const De=Q(Me.of(We.y));H(Z.pool.next("circle",`${h}__point ${h}__mark`),{cx:Le,cy:De,r:Pe&&c(We.size)?Q(Pe.of(We.size)):C,fill:Ne,"fill-opacity":Pe?.7:1,"data-series":Z.index,"data-point":$e}),We.px=Le,We.py=De}}function bt(Z){const{group:Oe,series:ke,xScale:Me,yScale:Ne,options:Pe}=Z,$e=Z.grid&&Z.grid.statistics,We=$e&&typeof $e.intervalOf=="function"?(jt,tt)=>$e.intervalOf(jt,tt):null,Le=new U(e(Oe,`${h}__errorbars`)),De=Number.isFinite(Number(Pe.confidence))?Number(Pe.confidence):.95,Ve=4;let Je=0,ct=0,rt=0,ft=0;for(const jt of ke)for(const tt of jt.points){if(tt.y===null||tt.y===void 0)continue;ct++;const Pt=Array.isArray(tt.values)&&tt.values.length===1;Pt&&rt++;let At=null,Et=null;if(Pe.of!==void 0&&Number.isFinite(Number(tt[Pe.of]))){const Rt=Math.abs(Number(tt[Pe.of]));At=tt.y-Rt,Et=tt.y+Rt}else if(Array.isArray(tt.values)&&tt.values.length>1&&We){const Rt=We(tt.values,De);Rt&&(At=Rt.lower,Et=Rt.upper)}if(At===null||!Number.isFinite(At)||!Number.isFinite(Et)){Pt&&ft++;continue}const gt=Q(Me.of(tt.xKey!==void 0?tt.xKey:tt.x)+(Me.bandwidth?Me.bandwidth/2:0)),yt=Q(Ne.of(Et)),_t=Q(Ne.of(At));H(Le.next("path",`${h}__error-bar ${h}__mark`),{d:pe(["M",gt-Ve,yt,"L",gt+Ve,yt,"M",gt,yt,"L",gt,_t,"M",gt-Ve,_t,"L",gt+Ve,_t]),fill:"none",stroke:"currentColor","data-lower":At,"data-upper":Et}),Je++}return Le.finish(),{drawn:Je,marks:ct,single:rt,singleSkipped:ft}}function Ct(Z){const Oe=Z.scheme||A(),ke=Z.axis||{x:{},y:{},y2:{}},Me=Z.typography||{small:Z.fontSize||11,axisTitle:11},{bound:Ne,plot:Pe,type:$e}=Z,We=ne[$e]||ne.line,Le=Ne.series.filter(st=>!Z.hidden.has(st.key)),De=!!We.horizontal,Ve=!De&&ke.y.position==="right"?"right":"left",Je=Ve==="right"?"left":"right",ct=($e==="bar"||$e==="horizontalBar")&&Z.byRuleColour&&Le.length===1&&Ne.measure&&Ne.measure.col||null,rt=ct?new Set:null,ft=ct?st=>{const wt=r({grid:Z.grid,col:ct,value:st.y});return wt&&rt.add(wt),wt}:null,tt=($e==="bar"||$e==="horizontalBar")&&Z.byRuleColour&&Le.length===1&&Oe.nameMap?st=>Oe.series(0,st.label):null,Pt=ft||tt?st=>ft&&ft(st)||tt&&tt(st)||null:null,At=!De&&$e!=="waterfall"?Le.filter(st=>st.axis==="right"):[],Et=At.length?Le.filter(st=>st.axis!=="right"):Le,gt=At.length>0,yt=($e==="bar"||$e==="area"||$e==="horizontalBar")&&!gt,_t=Z.stack==="percent"&&yt&&Et.length>1,Rt=(_t||!!Z.stack)&&Et.length>1&&yt,fn=$e==="waterfall"?xe(Le[0]):ge(Et,Rt,_t),on=Ne.yDomain||Z.domain||I(fn,{zero:We.zero,min:ke.y.min,max:ke.y.max}),Kt=De?R(on,[Pe.left,Pe.right]):R(on,[Pe.bottom,Pe.top]),xt=De?p(Ne.categories,[Pe.top,Pe.bottom],.2):qe(Ne,Pe,$e,ke.x),hn=on.min<=0&&on.max>=0?0:on.min,En=At.some(st=>(st.mark||($e==="bar"?"bar":$e))==="bar"),sn=gt?I(ge(At,!1,!1),{zero:En,min:ke.y2.min,max:ke.y2.max}):null,Vt=sn?R(sn,[Pe.bottom,Pe.top]):null,yn=B(Z.grid,{kind:"linear",step:(on.max-on.min)/5}),mn=Z.axes!==!1;if(mn&&J({gridGroup:Z.groups.grid,axisGroup:Z.groups.axis,plot:Pe,scale:Kt,format:yn,horizontal:De,side:Ve,config:ke.y,grid:Z.grid,size:Me.small}),mn)if(De)be({group:Z.groups.overlay,plot:Pe,scale:xt,labels:Ne.labels,fontSize:Me.small,config:ke.x});else if(xt.kind==="band")me({group:Z.groups.overlay,plot:Pe,scale:xt,labels:Ne.labels,fontSize:Me.small,rotated:D(Ne.labels,xt.step,Me.small,ke.x.every),config:ke.x});else{const st=Ne.dimension&&Ne.dimension.col?Z.grid.columns.get(Ne.dimension.col):void 0;te({group:Z.groups.overlay,plot:Pe,scale:xt,format:B(Z.grid,{kind:Ne.kind,span:xt.domain.max-xt.domain.min,step:(xt.domain.max-xt.domain.min)/5},st),config:ke.x,grid:Z.grid,column:st,size:Me.small})}if(mn&&(q({group:Z.groups.rules,plot:Pe,side:Ve}),j({group:Z.groups.axis,plot:Pe,text:ke.y.title,side:De?"bottom":Ve,size:Me.axisTitle}),j({group:Z.groups.axis,plot:Pe,text:ke.x.title,side:De?"left":"bottom",size:Me.axisTitle})),mn&&Vt){v({group:Z.groups.axis,plot:Pe,scale:Vt,colour:Oe.series(At[0].index),side:Je,format:B(Z.grid,{kind:"linear",step:(sn.max-sn.min)/5})});const st=ke.y2.title||(At.length===1?At[0].label:"");j({group:Z.groups.axis,plot:Pe,text:st,side:Je,size:Me.axisTitle}),!ke.y.title&&Et.length===1&&Et[0].label&&j({group:Z.groups.axis,plot:Pe,text:Et[0].label,side:Ve,size:Me.axisTitle})}const wn=Number.isFinite(Z.downsampleTo)?Number(Z.downsampleTo):Math.max(2,Math.round(Pe.width));let On=!1;if(We.marks==="path"||$e==="scatter"||$e==="bubble"){for(const st of Le)if(st.kept=null,st.points.length>wn*1.5){const wt=st.points.map((Bt,It)=>({x:It,y:Bt.y,point:Bt})),it=m(wt,wn);st.points=it.map(Bt=>Bt.point),st.kept=it.map(Bt=>Bt.x),On=!0}}Z.pool||S(Z.groups,Pe,W($e));const cn=Z.pool||new U(Z.groups.marks),kn=_t?Ne.categories.map((st,wt)=>Le.reduce((it,Bt)=>{const It=Bt.points[wt]?Bt.points[wt].y:null;return c(It)?it+Math.abs(It):it},0)):null,vn=Rt?Ce(Ne.categories.length,kn):null,xn=gt?Le.filter(st=>(st.mark||($e==="bar"?"bar":$e))==="bar"):Le,Tn=gt?Math.max(1,xn.length):Math.max(1,Le.length),Hn=$e==="bar"||gt&&xn.length>0,gn=xt.kind==="band"?xt.bandwidth:Hn?Be({bound:Ne,scale:xt,config:ke.x,padding:Ae("bar")}):0,Ht=Rt?gn:gn/Tn,qt=new Map;for(const st of xn)qt.set(st.key,qt.size);const un=[];for(let st=0;st<Le.length;st++){const wt=Le[st],it=Oe.series(wt.index,wt.label),Bt=wt.axis==="right"&&Vt?Vt:Kt,It=gt?wt.mark||($e==="bar"?"bar":$e):$e,An=gt&&qt.has(wt.key)?qt.get(wt.key):st;if($e==="horizontalBar")ln({pool:cn,series:wt,bandScale:xt,valueScale:Kt,baseline:hn,colour:it,stack:vn,index:wt.index,slot:{offset:Rt?0:st*Ht,width:Ht,span:gn},pointColour:Pt});else if($e==="waterfall")Yt({pool:cn,series:wt,xScale:xt,yScale:Kt,index:wt.index,total:!0,positive:Oe.positive,negative:Oe.negative});else if(It==="bar")nn({pool:cn,series:wt,xScale:xt,yScale:Bt,baseline:Bt===Vt?sn.min<=0&&sn.max>=0?0:sn.min:hn,colour:it,stack:vn,index:wt.index,slot:{offset:Rt?0:An*Ht,width:Ht,span:gn},pointColour:Pt});else if($e==="scatter"||$e==="bubble")ht({pool:cn,series:wt,xScale:xt,yScale:Bt,colour:it,index:wt.index,size:$e==="bubble"?Z.sizes:null});else{const pn=Ot(Z,wt.label),en={pool:cn,series:wt,xScale:xt,yScale:Bt,baseline:hn,fill:It==="area"||It==="rangeArea",step:It==="step",colour:it,stack:vn,index:wt.index,style:pn};pn.emphasized?un.push(en):St(en)}}for(const st of un)St(st);Z.pool||cn.finish(),Z.band&&typeof xt.invert=="function"&&Lt({group:Z.groups.overlay,band:Z.band,xScale:xt,yScale:Kt,scheme:Oe,index:0,line:Z.band.line!==!1&&!Z.fit}),Z.fit&&($e==="scatter"||$e==="bubble")&&typeof xt.invert=="function"&&Mt({group:Z.groups.overlay,series:Le,xScale:xt,yScale:Kt,plot:Pe,scheme:Oe,grid:Z.grid,size:Me.small,showR2:Z.fit!=="line"});let Zt=null;Z.trend&&(Zt=n({group:Z.groups.overlay,series:Le,xScale:xt,yScale:Kt,rightScale:Vt,plot:Pe,scheme:Oe,trend:Z.trend,grid:Z.grid,format:st=>yn.tick(st),size:Me.small,clip:Z.groups.boxClipId}));let lt=null;if(Z.error&&(lt=bt({group:Z.groups.overlay,series:Le,xScale:xt,yScale:Kt,grid:Z.grid,options:Z.error===!0?{}:Z.error})),Z.labels&&Z.labels.show&&d({group:Z.groups.labels,series:Le,plot:Pe,options:Z.labels,grid:Z.grid,size:Me.small,horizontal:De}),Z.reference&&Z.reference.length){const st=Z.reference.filter(it=>!(it.axis==="right"||it.axis==="y2")),wt=Vt?Z.reference.filter(it=>it.axis==="right"||it.axis==="y2"):[];st.length&&et({group:Z.groups.overlay,plot:Pe,scale:Kt,lines:st}),wt.length&&et({group:Z.groups.overlay,plot:Pe,scale:Vt,lines:wt})}let an=null;Z.annotations&&Z.annotations.length&&(an=b({group:Z.groups.overlay,plot:Pe,xScale:xt,yScale:Kt,rightScale:Vt,series:Le,annotations:Z.annotations,dual:gt,format:st=>yn.tick(st),size:Me.small}));const vt=Array.isArray(Zt)&&Zt.length?[...an||[],...Zt]:an;return{xScale:xt,yScale:Kt,rightScale:Vt,dual:gt,series:Le,horizontal:De,percent:_t,plot:Pe,errorBars:lt,annotations:vt,trendlines:Zt,reduced:On,legend:ct?l({grid:Z.grid,col:ct,colours:rt}):null}}const Dt=32;function Ft(Z){const{series:Oe,xScale:ke,at:Me}=Z,Ne=Number.isFinite(Z.tolerance)?Number(Z.tolerance):Dt,Pe=[];let $e=-1,We=1/0;for(const Le of Oe){let De=null,Ve=-1,Je=1/0;const ct=Le.points||[];for(let rt=0;rt<ct.length;rt++){const ft=ct[rt];if(!ft||!c(ft.y))continue;const jt=ot(ke,ft);if(Number.isNaN(jt))continue;const tt=Math.abs(jt-Me);tt>=Je||(Je=tt,De=ft,Ve=Array.isArray(Le.kept)?Le.kept[rt]:rt)}!De||Je>Ne||(Pe.push({series:Le,point:De}),Je<We&&(We=Je,$e=Ve))}return $e<0?null:{index:$e,entries:Pe}}function Ut(Z){const{bound:Oe,xScale:ke,at:Me}=Z;if(!Oe.categories.length)return-1;if(ke.kind==="band"){const $e=Math.floor((Me-ke.range[0])/(ke.step||1));return $e>=0&&$e<Oe.categories.length?$e:-1}let Ne=-1,Pe=1/0;for(let $e=0;$e<Oe.categories.length;$e++){const We=ke.kind==="time"?re(Oe.categories[$e]):Y(Oe.categories[$e]);if(We===null)continue;const Le=Math.abs(ke.of(We)-Me);Le<Pe&&(Pe=Le,Ne=$e)}return Ne}function Jt(Z,Oe){return Oe<0||Oe>=Z.categories.length?"":k(Z.categories[Oe])}}),Qe("packages/modules/charts/drawable.js",function(o,X){"use strict";Object.defineProperty(o,"REASONS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"DRAWABLE",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"namedColumns",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"missingColumns",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"bucketKey",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"bucketMessage",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"continuousX",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"drawability",{enumerable:!0,get:function(){return T}});const ye=X("packages/modules/charts/scale.js"),q=ye.extent,j=ye.toNumber,be=ye.toTime,te=X("packages/modules/charts/cartesian.js").staleWindow,J=Object.freeze({EMPTY:"empty",INCOMPLETE:"incomplete",STALE:"stale",MISSING_COLUMN:"missing-column",NO_DOMAIN:"no-domain",BUCKETED:"bucketed"}),W=Object.freeze({ok:!0});function ie(B){if(!B||typeof B!="object")return[];const _=[],$=(p,s)=>{typeof s=="string"&&s?_.push({key:p,col:s}):s&&typeof s=="object"&&typeof s.col=="string"&&s.col&&_.push({key:p,col:s.col})};if(Array.isArray(B.points))return[];if($("x",B.x),$("code",B.code),$("y",B.y),$("series",B.series),$("size",B.size),$("source",B.source),$("target",B.target),typeof B.multiples=="string"&&$("multiples",B.multiples),Array.isArray(B.measures))for(const p of B.measures)$("measures",p);return _}function S(B,_){const $=B&&B.columns;return!$||typeof $.get!="function"?[]:ie(_).filter(({col:p})=>!$.get(p))}function y(B){return`chart:x:date-bucket:${B}`}function U(B,_,$){return`chart x column ${JSON.stringify(B)} is a 'date', which stores a calendar day, so all ${_} rows collapsed into one point and were reduced by '${$}'. For a series inside a single day, type the column 'datetime' or bind epoch milliseconds.`}function D(B,_){return!_||_.kind!=="time"&&_.kind!=="linear"?!1:B!=="bar"&&B!=="horizontalBar"}function T(B){const{grid:_,spec:$,type:p,bound:s}=B,c=B.id===void 0?"":String(B.id),k=Number.isFinite(B.now)?Number(B.now):Date.now(),R=(Y,re,ee,H=!0)=>({ok:!1,reason:Y,key:ee||`chart:${c}:${Y}`,message:re,tell:H}),I=S(_,$);if(I.length){const Y=I.map(ee=>`${ee.key}: ${JSON.stringify(ee.col)}`).join(", "),re=_&&_.columns&&typeof _.columns.all=="function"?_.columns.all().map(ee=>ee.id||ee.field).filter(Boolean):[];return R(J.MISSING_COLUMN,`chart ${Y} ${I.length>1?"name columns":"names a column"} this grid does not have, so there is nothing to read and nothing to draw.${re.length?` The columns it does have: ${re.slice(0,12).map(ee=>JSON.stringify(ee)).join(", ")}${re.length>12?", …":""}.`:""} Bind a column the grid declares, or declare the column.`)}if(s&&s.empty){const Y=_&&_.rows&&typeof _.rows.count=="function"?_.rows.count():0;return R(J.EMPTY,Y?`chart bound nothing from the ${Y} row(s) the grid is showing, so it shows its empty state. The binding named no series to draw: check that the spec names the columns this chart needs — a flow type needs source and target, a measure needs a column with values in it.`:"chart has no rows to draw, so it shows its empty state.",void 0,Y>0)}if(p==="candlestick"&&(!s||!s.series||s.series.length<4)){const Y=s&&s.series?s.series.length:0;return R(J.INCOMPLETE,`a candlestick chart needs four measures — open, high, low and close, in that order — and ${Y===0?"none was":`only ${Y} were`} bound. Pass them as measures: [open, high, low, close].`)}const z=te(s,B.axis&&B.axis.x,p,k);if(z){const Y=z.newest===null?"and every one of them is stamped ahead of it":`and the newest of ${z.points} x value(s) is ${Math.round(z.age/1e3)}s old`;return R(J.STALE,`the rolling x window covers the last ${z.span} ms, ${Y}, so every mark would be drawn outside the plot. The chart shows its empty state instead. Seed it with data inside the window, widen axis.x.window.span, or drop the window while showing history.`,`chart:${c}:x:window:stale:${$&&$.x||""}`,z.newest!==null)}if(D(p,s)){const Y=Array.isArray(s.categories)?s.categories:[],re=s.kind==="time"?Y.map(be):Y.map(j);if(Y.length&&!q(re)){const ee=$&&typeof $.x=="string"&&$.x||s.dimension&&s.dimension.col||"";return R(J.NO_DOMAIN,`chart x ${ee?`column ${JSON.stringify(ee)} `:""}is drawn on a ${s.kind==="time"?"time":"continuous"} axis, and not one of its ${Y.length} value(s) reads as a ${s.kind==="time"?"date":"number"} — so the axis would be drawn over a domain invented from nothing rather than measured from the data. Remove axis.x.scale to let the column choose its own scale, or type the column so its values parse.`)}}if(s&&s.bucketed&&D(p,s)){const{col:Y,rows:re,fn:ee}=s.bucketed;return R(J.BUCKETED,U(Y,re,ee),y(Y))}return W}}),Qe("packages/modules/charts/bind.js",function(o,X){"use strict";Object.defineProperty(o,"AGGREGATIONS",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"DEFAULT_AGGREGATION",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"resolveAggregation",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"defaultAggregationFor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"measureOf",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"walkRows",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"leafRows",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"selectedRows",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"topGroups",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"forcedScaleKind",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"scaleKindFor",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"bindSeries",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"bindPoints",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"bindMeasures",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"bindLinks",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"bindHierarchy",{enumerable:!0,get:function(){return ce}});const ye=X("packages/modules/charts/scale.js"),q=ye.key,j=ye.toNumber,be=ye.toTime,me=X("packages/modules/charts/drawable.js"),te=me.bucketKey,J=me.bucketMessage,ie=X("packages/core/src/internal/util.js").warnOnce,S={sum:E=>E.length?E.reduce((V,h)=>V+h,0):null,avg:E=>E.length?E.reduce((V,h)=>V+h,0)/E.length:null,mean:E=>E.length?E.reduce((V,h)=>V+h,0)/E.length:null,min:E=>{let V=null;for(let h=0;h<E.length;h++)(V===null||E[h]<V)&&(V=E[h]);return V},max:E=>{let V=null;for(let h=0;h<E.length;h++)(V===null||E[h]>V)&&(V=E[h]);return V},median:E=>{if(!E.length)return null;const V=E.slice().sort((u,m)=>u-m),h=(V.length-1)/2,a=Math.floor(h),d=Math.ceil(h);return a===d?V[a]:(V[a]+V[d])/2},count:(E,V)=>V,countValues:E=>E.length,first:E=>E.length?E[0]:null,last:E=>E.length?E[E.length-1]:null},y="sum";function U(E){return E==null?y:typeof E=="string"&&E in S?E:(ie(`chart:measure:fn:${String(E)}`,`chart measure fn ${JSON.stringify(E)} is not a known aggregation; using '${y}'. Supported: ${Object.keys(S).join(", ")}.`),y)}function D(E){if(!E)return y;const V=E.groupTotal??E.total;if(typeof V=="string"&&V in S)return V;const h=E.dataType&&E.dataType.totals?E.dataType.totals.supported:null;if(Array.isArray(h)&&!h.includes(y)){const a=["avg","mean","max","min","countValues","count"].find(d=>h.includes(d)&&d in S);if(a)return a}return y}function T(E,V){const h=D(V);return E?typeof E=="string"?{col:E,fn:h}:{col:E.col||null,fn:E.fn==null?h:U(E.fn)}:{col:null,fn:h}}function B(E,V){const h=new Set,a=d=>{if(!d||h.has(d)||(h.add(d),V(d),!d.group)||d.expanded)return;const u=d.filteredChildren||d.children;if(Array.isArray(u))for(const m of u)a(m)};E.rows.forEach(a)}function _(E){const V=[];return B(E,h=>{!h.group&&h.data!==null&&h.data!==void 0&&V.push(h)}),V}function $(E){const V=new Set(E.selection.keys());if(!V.size)return[];const h=[];return B(E,a=>{!a.group&&V.has(a.key)&&h.push(a)}),h}function p(E){const V=[];let h=1/0;return B(E,a=>{a.group&&(a.level<h&&(h=a.level,V.length=0),a.level===h&&V.push(a))}),V}function s(E,V,h){return V.group&&V.totals&&h in V.totals?j(V.totals[h]):j(E.rows.value(V.key,h))}function c(E,V,h,a){if(!V.group){const d=E.rows.text(V.key,h);if(d)return d}return a==null?"":a instanceof Date?a.toISOString().slice(0,10):String(a)}function k(E,V){return(S[V]||S[y])(E.values,E.rows)}const R=Object.freeze(["number","currency","percent"]),I=Object.freeze(["date","datetime","timestamp","dateString"]),z=Object.freeze({auto:"",band:"category",category:"category",linear:"linear",time:"time"});function Y(E){const V=E&&typeof E=="object"?E.axis:null;if(!V||typeof V!="object")return"";const h=V.x;if(!h||typeof h!="object")return"";const a=typeof h.scale=="string"?h.scale:"";return a?Object.hasOwn(z,a)?z[a]:(ie(`chart:x:scale:unknown:${a}`,`chart axis.x.scale ${JSON.stringify(a)} is not a scale this chart draws. Use one of: ${Object.keys(z).join(", ")}. The scale was chosen from the column instead.`),""):""}function re(E){if(E.length<3)return"";let V=0,h=0;for(const a of E){if(a==null||a===""||typeof a=="boolean")return"";j(a)!==null?V++:typeof a=="string"&&be(a)!==null&&h++}return h===E.length?"time":V===E.length?"linear":""}function ee(E,V,h={}){if(h.forced)return h.forced;const a=E&&typeof E.type=="string"?E.type:"";if(I.includes(a)||V.length&&V.every(m=>m instanceof Date))return"time";if(R.includes(a))return"linear";const d=h.id?String(h.id):"";if(!d)return"category";const u=a&&a!=="text"?"":re(V);return u&&ie(`chart:x:banded:${d}`,`chart x column ${JSON.stringify(d)} is typed ${JSON.stringify(a||"text")}, so its ${V.length} values are drawn as categories on a band scale even though they all read as ${u==="time"?"dates":"numbers"}. Type the column ${u==="time"?"'date' (or 'datetime'/'timestamp'/'dateString')":"'number'"} for a continuous axis, or pin it with axis: { x: { scale: '${u}' } }.`),"category"}function H(E,V){const h=V.x||null,a=V.series||(typeof V.multiples=="string"?V.multiples:null)||null,d=E.columns,u=h?d.get(h):void 0,m=T(V.y),O=m.col?d.get(m.col):void 0,A=T(V.y,O);let w;const g=typeof V.rows=="function"?V.rows(E):V.rows;Array.isArray(g)?w=g:V.from==="groups"?w=p(E):V.from==="selection"?w=$(E):w=_(E);const f=w.length?w:_(E),v=new Map,F=new Map,b=[];for(let M=0;M<f.length;M++){const C=f[M],ne=h?C.group&&C.groupColumn===h?C.groupValue:E.rows.value(C.key,h):M,ue=q(ne);v.has(ue)||(v.set(ue,{value:ne,label:h?c(E,C,h,ne):String(M),order:v.size}),b.push(ne));const ge=a?C.group&&C.groupColumn===a?C.groupValue:E.rows.value(C.key,a):null,xe=a?q(ge):"";F.has(xe)||F.set(xe,{label:a?c(E,C,a,ge):O?.title||"",points:new Map});const Ce=F.get(xe);let je=Ce.points.get(ue);je||(je={values:[],rows:0,rowKey:C.key},Ce.points.set(ue,je)),je.rows+=C.group&&C.leafCount||1;const _e=A.col?s(E,C,A.col):null;if(_e!==null&&je.values.push(_e),V.size){const Re=j(E.rows.value(C.key,V.size));Re!==null&&(je.sizes=(je.sizes||0)+Re)}}const e=[...v.values()].sort((M,C)=>M.order-C.order),i=typeof V.limit=="number"&&V.limit>0?e.slice(0,V.limit):e,n=ee(u,b,{forced:Y(V),id:h});let t=null;n==="time"&&f.length>1&&v.size===1&&u&&(u.type==="date"||u.type==="dateString")&&(t={col:String(h),rows:f.length,fn:A.fn},ie(te(t.col),J(t.col,t.rows,t.fn)));const l=R.includes(u&&typeof u.type=="string"?u.type:"")?[...i].sort((M,C)=>(j(M.value)??0)-(j(C.value)??0)):i,L=[...F.entries()].map(([M,C],ne)=>({key:M,label:C.label,index:ne,points:l.map(ue=>{const ge=q(ue.value),xe=C.points.get(ge);return{x:ue.value,xKey:ge,label:ue.label,y:xe?k(xe,A.fn):null,size:xe&&xe.sizes!==void 0?xe.sizes:null,rows:xe?xe.rows:0,rowKey:xe?xe.rowKey:null,values:xe&&xe.values?xe.values:null}})}));return{series:L,categories:l.map(M=>M.value),labels:l.map(M=>M.label),kind:n,measure:{...A,title:O?.title||A.col||""},dimension:{col:h,title:u?.title||h||""},empty:L.length===0||l.length===0,rows:f.length,truncated:e.length-l.length,bucketed:t}}function pe(E){const V=Array.isArray(E.points)?E.points:[],h=V.length>0&&V.every(u=>typeof u.x=="number"&&Number.isFinite(u.x)),a=u=>typeof u=="number"&&Number.isFinite(u)?u:null,d=V.map((u,m)=>({x:u.x,xKey:q(u.x),label:u.label!=null?String(u.label):String(u.x),y:a(u.y),size:a(u.size),lower:a(u.lower),upper:a(u.upper),rows:1,rowKey:u.key!=null?String(u.key):String(m),values:null}));return{series:[{key:E.seriesKey||"",label:E.seriesLabel||"",index:0,points:d}],categories:d.map(u=>u.x),labels:d.map(u=>u.label),kind:h?"linear":"category",measure:{col:null,fn:"sum",title:E.measureTitle||""},dimension:{col:null,title:E.dimensionTitle||""},empty:d.length===0,rows:d.length,truncated:0}}function x(E,V){const h=Array.isArray(V.measures)?V.measures:[];if(!h.length)return H(E,V);const a=h.map(O=>{const A=typeof O=="string"?{col:O}:O;return{spec:A,result:H(E,{x:V.x,from:V.from,limit:V.limit,axis:V.axis,y:{col:A.col,fn:A.fn}})}}),d=a[0].result,u=new Map(d.categories.map((O,A)=>[q(O),A])),m=a.map(({spec:O,result:A},w)=>{const g=E.columns.get(O.col),f=d.categories.map(()=>null),v=A.series[0];if(v)for(const F of v.points){const b=u.get(F.xKey);b!==void 0&&(f[b]=F)}return{key:O.col,label:O.title||O.label||g&&g.title||O.col,index:w,mark:O.type||null,axis:O.axis==="right"?"right":"left",points:d.categories.map((F,b)=>f[b]||{x:F,xKey:q(F),label:d.labels[b],y:null,rows:0,rowKey:null})}});return{series:m,categories:d.categories,labels:d.labels,kind:d.kind,measure:{col:null,fn:"sum",title:m.map(O=>O.label).join(", ")},dimension:d.dimension,empty:!m.length||!d.categories.length,rows:d.rows,truncated:d.truncated}}function Q(E,V,h={}){const a=T(V.y),d=!!h.perRow,u=Array.isArray(h.nodes)?h.nodes:[],m=V.source||V.x||null,O=V.target||null;if(!m||!O)return{nodes:[],links:[],measure:{...a,title:""},dimension:{col:null,title:""},series:[],categories:[],labels:[],empty:!0,total:0};const A=a.col?E.columns.get(a.col):void 0,w=new Map,g=new Map,f=(e,i,n)=>{const t=q(e);return w.has(t)||w.set(t,{key:t,value:e,label:c(E,i,n,e),index:w.size,in:0,out:0}),w.get(t)},v=new Map;for(const e of u)!e||e.id===null||e.id===void 0||v.set(q(e.id),e);for(const e of _(E)){const i=E.rows.value(e.key,m),n=E.rows.value(e.key,O);if(i==null||n===null||n===void 0)continue;const t=a.col?j(E.rows.value(e.key,a.col)):1;if(t===null||t<=0)continue;const r=f(i,e,m),l=f(n,e,O);if(d){const L=r.key>l.key,M=L?l:r,C=L?r:l;g.set(`${M.key}\0${C.key}\0${g.size}`,{source:M,target:C,value:t,undirected:!0,pair:`${M.key}\0${C.key}`,rowKeys:[e.key]})}else{const L=`${r.key}\0${l.key}`,M=g.get(L)||{source:r,target:l,value:0,rowKeys:[]};M.value+=t,M.rowKeys.length<64&&M.rowKeys.push(e.key),g.set(L,M)}r.out+=t,l.in+=t}for(const[e,i]of v)w.has(e)||w.set(e,{key:e,value:i.id,label:String(i.label??i.id),index:w.size,in:0,out:0});for(const[e,i]of v){const n=w.get(e);n&&(n.declared=!0,i.label!==void 0&&i.label!==null&&(n.label=String(i.label)),typeof i.icon=="string"&&i.icon&&(n.icon=i.icon),Number.isFinite(i.x)&&Number.isFinite(i.y)&&(n.fx=Number(i.x),n.fy=Number(i.y)))}const F=d?[...g.values()]:[...g.values()].sort((e,i)=>i.value-e.value),b=typeof V.limit=="number"&&V.limit>0?F.slice(0,V.limit):F;return{nodes:[...w.values()],links:b,measure:{...a,title:A?.title||a.col||""},dimension:{col:m,title:E.columns.get(m)?.title||m},series:[],categories:[],labels:[],empty:!b.length,total:b.reduce((e,i)=>e+i.value,0)}}function ce(E,V){const h=T(V.y),a=typeof V.depth=="number"&&V.depth>0?V.depth:1/0,d=h.col?E.columns.get(h.col):void 0,u=(g,f,v)=>({label:g,value:f,depth:v,total:0,children:[],rowKey:null}),m=u("",null,0),O=p(E);if(O.length){const g=(f,v,F)=>{const b=f.groupColumn?c(E,f,f.groupColumn,f.groupValue):"",e=u(b,f.groupValue,F);e.rowKey=f.key;const i=h.col?s(E,f,h.col):null;e.total=i===null?0:Math.abs(i),v.children.push(e);const n=f.filteredChildren||f.children;if(F<a&&Array.isArray(n))for(const t of n)t.group&&g(t,e,F+1);return!e.total&&e.children.length&&(e.total=e.children.reduce((t,r)=>t+r.total,0)),e};for(const f of O)g(f,m,1)}else{const f=H(E,{x:V.x,y:V.y,limit:V.limit}).series[0];if(f)for(const v of f.points){const F=u(v.label,v.x,1);F.total=v.y===null?0:Math.abs(v.y),F.rowKey=v.rowKey,m.children.push(F)}}m.total=m.children.reduce((g,f)=>g+f.total,0);let A=0;const w=g=>{g.depth>A&&(A=g.depth);for(const f of g.children)w(f)};return w(m),{root:m,depth:A,measure:{...h,title:d?.title||h.col||""},empty:m.total<=0||m.children.length===0}}}),Qe("packages/core/src/source/filterwire.js",function(o,X){"use strict";Object.defineProperty(o,"HOST_FILTER_WARN_ID",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"WHERE_PAGE_RELATIVE_WARN_ID",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"warnWherePageRelative",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"warnHostFilterNotApplied",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"WHERE_NOT_APPLIED_WARN_ID",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"warnWhereNotApplied",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"WHERE_OVER_THRESHOLD_WARN_ID",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"warnWhereOverThreshold",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"RELATIVE_TOKENS",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"parseRelativeToken",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"resolveRelativeRange",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"relativeTokenOf",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"relativeTokenHelp",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"isResolvableRelative",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"resolveRelativeCondition",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"isGroup",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"forEachCondition",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"mapConditions",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"normaliseFilterSet",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"buildFilterSet",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"wireFilters",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"querySignature",{enumerable:!0,get:function(){return ce}});const q=X("packages/core/src/internal/util.js").warnOnce,j="source.remote.hostFilter",be="source.where.pageRelative";function me(h,a){!Array.isArray(h)||!h.length||q(be,`filters.where (${h.join(", ")}) runs over the rows the ${a} 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 te(h){const a=(h||{}).config;!a||!a.hostFilter||q(j,"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 J="source.where.notApplied";function W(h,a){q(`${J}:${h}`,`filters.where("${h}") is registered but the ${a} 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 ie="source.where.overThreshold";function S(h,a,d,u){!Array.isArray(h)||!h.length||q(`${ie}:${a}`,`filters.where (${h.join(", ")}) is not applied to the ${a} pushdown source:`,d===null?"the adapter reports no row total, so the size of the matching set is unknown.":`its matching set is ${d.toLocaleString()} rows, at or past the whereRowLimit of ${u.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 y=new Map;function U(h){let a=y.get(h);return a||(a=new Intl.DateTimeFormat("en-US",{timeZone:h,hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),y.set(h,a)),a}function D(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}catch{return"UTC"}}function T(h,a){const d=U(a).formatToParts(new Date(h)),u={y:1970,m:1,d:1,h:0,mi:0,s:0};for(const m of d)m.type==="year"?u.y=+m.value:m.type==="month"?u.m=+m.value:m.type==="day"?u.d=+m.value:m.type==="hour"?u.h=+m.value%24:m.type==="minute"?u.mi=+m.value:m.type==="second"&&(u.s=+m.value);return u}function B(h,a){const d=T(h,a);return Date.UTC(d.y,d.m-1,d.d,d.h,d.mi,d.s)-Math.floor(h/1e3)*1e3}function _(h,a,d,u){const m=Date.UTC(h,a-1,d),O=m-B(m,u);return m-B(O,u)}function $(h,a,d){const u=new Date(Date.UTC(h.y,h.m-1,h.d+a));return _(u.getUTCFullYear(),u.getUTCMonth()+1,u.getUTCDate(),d)}const p=Object.freeze(["today","yesterday","lastNDays","thisWeek","thisMonth","thisQuarter","thisYear","quarterToDate","yearToDate"]);function s(h,a){if(typeof h!="string")return null;const d=h.trim().toLowerCase().replace(/[\s_-]+/g,""),u=/^last(\d*|n)days?$/.exec(d);if(u){const m=u[1]==="n"?"":u[1],O=Number(m||a);return!Number.isFinite(O)||O<=0?null:{kind:"lastNDays",n:Math.floor(O)}}switch(d){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 c(h,a={}){const d=s(h,a.n);if(!d)return null;const u=a.tz||D(),m=a.now instanceof Date?a.now.getTime():typeof a.now=="number"?a.now:Date.now(),O=T(m,u),A=_(O.y,O.m,O.d,u),w=$(O,1,u);let g=A,f=w;switch(d.kind){case"today":break;case"yesterday":g=$(O,-1,u),f=A;break;case"lastNDays":f=a.includeToday?w:A,g=$(O,a.includeToday?-(d.n-1):-d.n,u);break;case"thisWeek":{const v=Number.isFinite(a.weekStartsOn)?Number(a.weekStartsOn):1,b=(new Date(Date.UTC(O.y,O.m-1,O.d)).getUTCDay()-v+7)%7;g=$(O,-b,u),f=$(O,-b+7,u);break}case"thisMonth":g=_(O.y,O.m,1,u),f=_(O.m===12?O.y+1:O.y,O.m===12?1:O.m+1,1,u);break;case"thisQuarter":case"quarterToDate":{const v=Math.floor((O.m-1)/3)*3+1;g=_(O.y,v,1,u),f=d.kind==="quarterToDate"?w:v===10?_(O.y+1,1,1,u):_(O.y,v+3,1,u);break}case"thisYear":case"yearToDate":g=_(O.y,1,1,u),f=d.kind==="yearToDate"?w:_(O.y+1,1,1,u);break;default:return null}return{from:new Date(g).toISOString(),to:new Date(f).toISOString(),bounds:"[)",tz:u,relative:d.kind==="lastNDays"?`last${d.n}Days`:d.kind,n:d.n}}function k(h){if(!h||typeof h!="object")return null;const a=h.value;if(a&&typeof a=="object"&&!Array.isArray(a)&&"relative"in a)return{token:String(a.relative),n:typeof a.n=="number"?a.n:void 0};if(h.op==="relative"&&typeof h.value=="string")return{token:h.value,n:void 0};const d=h.meta;return d&&typeof d.relative=="string"&&h.value===void 0?{token:d.relative,n:typeof d.n=="number"?d.n:void 0}:null}function R(){return`Known tokens: ${p.filter(a=>a!=="lastNDays").join(", ")}. "lastNDays" needs a count: pass "last7Days", or the value object { relative: 'lastNDays', n: 7 }.`}function I(h){const a=k(h);return a?s(a.token,a.n)!==null:!1}function z(h,a={}){const d=k(h);if(!d)return h;const u=c(d.token,{...a,n:d.n});return u?{...h,type:h.type||"date",op:"between",value:[u.from,u.to],bounds:h.bounds||u.bounds,meta:{...h.meta||{},relative:u.relative,tz:u.tz}}:(q(`source.relative.${d.token}`,`unknown relative date token "${d.token}"; sending the condition unresolved.`,R()),h)}function Y(h){return!!h&&typeof h=="object"&&Array.isArray(h.conditions)}function re(h,a){if(h){if(Y(h)){for(const d of h.conditions)re(d,a);return}a(h)}}function ee(h,a){if(!h)return null;if(!Y(h))return a(h);const d=h;let u=!1;const m=[];for(const O of d.conditions){const A=ee(O,a);A!==O&&(u=!0),A&&m.push(A)}return!u&&m.length===d.conditions.length?h:m.length?{...d,conditions:m}:null}function H(h){if(!h)return null;if(!Y(h))return h;const a=h,d=[];for(const u of a.conditions){const m=H(u);m&&d.push(m)}return d.length?{op:a.op,conditions:d}:null}function pe(h){const a=H(h);return a?Y(a)&&a.op==="and"?a:{op:"and",conditions:[a]}:null}function x(h){const a=(h||[]).filter(Boolean);return a.length?{op:"and",conditions:a}:null}function Q(h,a={}){const d=ee(h,u=>z(u,a));return pe(d)}function ce(h){const a=E(h.filters??null);return JSON.stringify([a,h.sort??null,h.quick??"",h.groupBy??null,h.pivotBy??null,V(h.context)])}function E(h){if(!h)return null;if(Y(h)){const u=h;return{op:u.op,conditions:u.conditions.map(E)}}const a=h,d=a.meta&&typeof a.meta.relative=="string"?a.meta.relative:k(a)?.token;return{col:a.col,op:a.op,bounds:a.bounds??null,caseSensitive:a.caseSensitive??!1,value:d?`rel:${d}`:a.value??null}}function V(h){if(h==null)return null;try{return JSON.parse(JSON.stringify(h))}catch{return q("source.context.unserialisable","config.context is not JSON-serialisable; cache keys ignore it."),"[unserialisable]"}}}),Qe("packages/core/src/source/aggregates.js",function(o,X){"use strict";Object.defineProperty(o,"STAT_PUSHDOWN",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"pushableAggregates",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"fillAggregateSql",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"resolveAggregatesConfig",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"routeAggregate",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"resolveAggregatePlan",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"groupKeysPushable",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"pushdownDocRows",{enumerable:!0,get:function(){return ie}});const ye=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 q(){const S=new Set;for(const[y,U]of Object.entries(ye))U.pushable&&S.add(y);return S}function j(S,y,U){let D=S.split("%c").join(y);return U!==void 0&&(D=D.split("%w").join(U)),D}function be(S){const y=S||{},U=y.default==="engine"||y.default==="engine-if-identical"?y.default:"client",D={};if(y.overrides&&typeof y.overrides=="object")for(const[T,B]of Object.entries(y.overrides))(B==="engine"||B==="client")&&(D[T]=B);return{default:U,overrides:D}}function me(S,y){const U=ye[S];if(!U||!U.pushable)return"client";const D=y.overrides[S];return D==="engine"||D==="client"?D:y.default==="client"?"client":y.default==="engine-if-identical"?U.class==="identical"?"engine":"client":"engine"}function te(S,y){const U=be(y),D=[],T=[];for(const B of S||[]){const _=ye[B.fn],$=me(B.fn,U),p={id:B.id,col:B.col,fn:B.fn,class:_?_.class:"fallback"};B.weight!==void 0&&(p.weight=B.weight),B.params!==void 0&&(p.params=B.params),$==="engine"?D.push(p):(p.reason=_&&!_.pushable?_.note||"the engine cannot express this stat":"client by config",T.push(p))}return{engine:D,client:T,config:U}}const J=/^[A-Za-z_][A-Za-z0-9_$]*$/;function W(S,y=[]){return(S||[]).every(D=>{if(typeof D=="string")return J.test(D);if(!D||typeof D!="object")return!1;const T=D;return Array.isArray(y)&&y.includes(T.bucket)&&typeof T.col=="string"&&J.test(T.col)&&typeof T.size=="number"&&Number.isFinite(T.size)&&T.size>0})}function ie(){return Object.entries(ye).map(([S,y])=>({stat:S,class:y.class,sql:y.sql?j(y.sql,"col",y.twoColumn?"weight":void 0):"",note:y.note||(y.class==="identical"?"Pushes to DuckDB with the same result.":"")}))}}),Qe("packages/core/src/source/abort.js",function(o,X){"use strict";Object.defineProperty(o,"SupersededError",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"RequestToken",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"AbortScope",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"createAbortScope",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"isAbortError",{enumerable:!0,get:function(){return me}});class ye extends Error{constructor(J,W="superseded"){super(`[lattice] request ${J?`"${J}" `:""}${W}`),this.name="SupersededError",this.superseded=!0,this.key=J}}class q{#r;constructor(J,W,ie,S){this.#r=J,this.key=W,this.controller=ie,this.signal=ie.signal,this.seq=S}get current(){return!this.signal.aborted&&this.#r.tokenFor(this.key)===this}settle(){this.#r.settle(this)}abort(J){this.signal.aborted||this.controller.abort(new ye(this.key,J)),this.#r.settle(this)}}class j{#r=new Map;#n=0;begin(J="",W="superseded"){const ie=this.#r.get(J);ie&&!ie.signal.aborted&&ie.controller.abort(new ye(J,W));const S=new q(this,J,new AbortController,++this.#n);return this.#r.set(J,S),S}tokenFor(J){return this.#r.get(J)}pending(J=""){const W=this.#r.get(J);return!!W&&!W.signal.aborted}get size(){return this.#r.size}settle(J){this.#r.get(J.key)===J&&this.#r.delete(J.key)}abort(J="",W="superseded"){const ie=this.#r.get(J);ie&&ie.abort(W)}abortAll(J="superseded"){for(const W of[...this.#r.values()])W.abort(J);this.#r.clear()}}function be(){return new j}function me(te){if(!te||typeof te!="object")return!1;const J=te;return J.superseded===!0||J.name==="AbortError"||J.name==="SupersededError"}}),Qe("packages/core/src/source/pushdown.js",function(o,X){"use strict";Object.defineProperty(o,"NO_CAPABILITIES",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"resolveMutate",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"capabilitiesOf",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"splitFilters",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"planQuery",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"applyResidual",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"DEFAULT_WHERE_ROW_LIMIT",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"createPushdownSource",{enumerable:!0,get:function(){return V}});const ye=X("packages/core/src/internal/util.js"),q=ye.isFunction,j=ye.warnOnce,be=X("packages/core/src/source/filterwire.js"),me=be.isGroup,te=be.warnWherePageRelative,J=be.warnWhereOverThreshold,W=X("packages/core/src/source/aggregates.js"),ie=W.resolveAggregatePlan,S=W.groupKeysPushable,y=W.STAT_PUSHDOWN,D=X("packages/core/src/source/abort.js").SupersededError;function T(h){const a=h&&h.signal;if(!a||!a.aborted)return;const d=a.reason;throw d instanceof Error?d:new D("","superseded before it was sent")}const B=Object.freeze({filter:!1,operators:Object.freeze([]),sort:!1,quick:!1,range:!1,total:!1,group:!1,mutate:!1});function _(h){if(!h||typeof h!="object")return!1;const a=h.returning==="row"||h.returning==="key"?h.returning:"none";return{append:h.append===!0,update:h.update===!0,delete:h.delete===!0,returning:a}}function $(h,a){if(!h||typeof a!="string")return;if(!a.includes("."))return h[a];let d=h;for(const u of a.split(".")){if(d===null||typeof d!="object")return;d=d[u]}return d}function p(h){if(h===!0)return!0;if(!h||typeof h!="object")return!1;const a=h;return a.enabled===!1?!1:a.enabled===!0||q(a.commit)}function s(h){const a={...B,...h||{}};return a.operators=new Set(a.operators||[]),a.mutate=_(a.mutate),a}function c(h,a){return!h||!h.op||!a.operators.size?!1:a.operators.has(h.op)}function k(h,a){if(!h)return{pushed:null,residual:null};if(!a.filter)return{pushed:null,residual:h};if(a.filter==="term"){if(me(h)){const O=h.conditions||[];if(String(h.op)!=="and")return{pushed:null,residual:h};const A=O.findIndex(g=>!me(g)&&c(g,a));if(A<0)return{pushed:null,residual:h};const w=O.filter((g,f)=>f!==A);return{pushed:O[A],residual:w.length?{op:"and",conditions:w}:null}}return c(h,a)?{pushed:h,residual:null}:{pushed:null,residual:h}}if(!me(h))return c(h,a)?{pushed:h,residual:null}:{pushed:null,residual:h};if(String(h.op)!=="and")return(h.conditions||[]).every(A=>me(A)?k(A,a).residual===null:c(A,a))?{pushed:h,residual:null}:{pushed:null,residual:h};const d=[],u=[];for(const O of h.conditions||[]){if(me(O)){if(a.filter==="flat"){u.push(O);continue}const A=k(O,a);A.pushed&&d.push(A.pushed),A.residual&&u.push(A.residual);continue}(c(O,a)?d:u).push(O)}const m=O=>O.length===0?null:O.length===1?O[0]:{op:"and",conditions:O};return{pushed:m(d),residual:m(u)}}function R(h,a,d,u,m,O,A){const w=Array.isArray(h.groupBy)?h.groupBy:[],g=Array.isArray(h.groupPath)?h.groupPath:[],f=Array.isArray(h.groupValues)?h.groupValues:null;return a.group?S(w)?d.residual?"the filter did not fully push, so the engine would group a superset of the matching rows":u?m?O?"a host `where` predicate can only run in the browser, over rows the engine grouped":A?"fullDataset holds the whole matching set, so the grid groups it itself":!f||f.length!==g.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":"the adapter does not declare the `group` capability"}function I(h,a,d=!1){const u=k(h.filters||null,a),m=[];u.residual&&m.push("filter");const O=h.sort||[],A=O.length===0||a.sort==="multi"&&O.length>=1||a.sort==="single"&&O.length===1;!A&&O.length&&m.push("sort");const w=h.quick?String(h.quick):"",g=!w||!!a.quick;g||m.push("quick");const f=h.where&&h.where.active?h.where:null;f&&m.push("where");const v={filters:u.residual,sort:A?null:O,quick:g?"":w,where:f},F=!!d,b=Array.isArray(h.groupBy)&&h.groupBy.length>0,e=b?R(h,a,u,A,g,f,F):"",i=b&&e==="";b&&!i&&m.push("group");const n=i&&Array.isArray(h.groupValues)?h.groupValues.length:0,t=i?!1:F||!!(v.filters||v.sort||v.quick||v.where)||!a.range;return{pushed:{...h,filters:u.pushed,sort:A?O:[],quick:g?w:"",range:t?null:h.range},residual:v,needsAll:t,unpushed:m,full:F,grouped:i,groupLevel:n,groupReason:e}}function z(h){const a=Array.isArray(h.totals)?h.totals:[],d=h.totalFns&&typeof h.totalFns=="object"?h.totalFns:{},u=[],m=[];for(const O of a){const A=String(O),w=typeof d[A]=="string"?d[A]:null,g=w?y[w]:null;w?!g||!g.pushable||!g.sql?m.push({id:A,fn:w,class:g?g.class:"fallback",reason:g&&g.note?g.note:`the pushdown map cannot express "${w}"`}):g.twoColumn?m.push({id:A,fn:w,class:g.class,reason:`"${w}" reduces two columns, and a grouped request carries no weight column`}):u.push({id:A,col:A,fn:w,class:g.class}):m.push({id:A,fn:null,class:"fallback",reason:"the column totals with a host function, so there is no named statistic to push"})}return{engine:u,client:m}}const Y=Object.freeze({items:h=>h==null?[]:Array.isArray(h)?h:[h]});function re(h,a,d){if(!a)return h;let u=h;if(a.filters&&q(d.evaluateFilters)){const m=u,O={count:u.length,handle:g=>({id:g,get:f=>$(m[f],g)}),itemwise:g=>m.some(f=>Array.isArray($(f,g)))?Y:null},A=d.evaluateFilters(a.filters,O),w=[];for(let g=0;g<u.length;g++)A[g]&&w.push(u[g]);u=w}if(a.where&&a.where.active&&(a.whole||te(a.where.names,"pushdown"),u=u.filter(m=>a.where.passes(m))),a.quick){const m=a.quick.toLowerCase();u=u.filter(O=>{if(!O||typeof O!="object")return!1;for(const A of Object.values(O))if(A!=null&&String(A).toLowerCase().includes(m))return!0;return!1})}if(a.sort&&a.sort.length&&q(d.sortMulti)){const m=[...new Set(a.sort.map(g=>g.col))],O=u,A=m.map(g=>({id:g,get:f=>$(O[f],g)})),w=d.sortMulti(A,a.sort.map(g=>({col:g.col,dir:g.dir})),Uint32Array.from({length:u.length},(g,f)=>f),{});u=Array.from(w,g=>O[g])}return u}function ee(h){return JSON.stringify({filters:h.filters||null,sort:h.sort||[],quick:h.quick||"",groupBy:h.groupBy||[],groupPath:h.groupPath||[],context:h.context??null})}function H(h){if(!h||typeof h!="object")return 16;let a="";try{a=JSON.stringify(h)}catch{return 200}return a.length*2+64}function pe(h){const a=h||{};return{enabled:!!a.enabled,maxRows:Number.isFinite(a.maxRows)?a.maxRows:1e6,maxBytesEstimate:Number.isFinite(a.maxBytesEstimate)?a.maxBytesEstimate:512*1024*1024}}const x=5e4;function Q(h){return Number.isFinite(h)&&h>=0?h:x}function ce(h){return!!h&&q(h.then)}async function E(h){if(!h||h.total!==void 0||!ce(h.pendingTotal))return h;const a=await h.pendingTotal,{pendingTotal:d,...u}=h;return typeof a=="number"?{...u,total:a}:u}function V(h={}){const a=h.adapter;if(!a||!q(a.execute))return j("source.pushdown.adapter","createPushdownSource needs an `adapter` with an `execute(query)` function."),{...h,mode:"remote",fetch:async()=>({rows:[],total:0})};const d=s(a.capabilities),u=a.capabilities&&Object.getOwnPropertyDescriptor(a.capabilities,"operators");u&&q(u.get)&&Object.defineProperty(d,"operators",{enumerable:!0,configurable:!0,get:()=>new Set(a.capabilities.operators||[]),set:()=>{}});const m=a.name||"adapter";let O=null;const A=()=>q(a.ready)?(O||(O=Promise.resolve(a.ready()).then(()=>{Object.assign(d,s(a.capabilities))},G=>{throw O=null,G})),O):null,w=pe(h.fullDataset),g=!!h.allowPartialResults,f=Q(h.whereRowLimit);let v=null;const F=h.aggregates;let b=null,e=null,i=null,n=null,t=null,r,l=null,L=0,M=null;const C=()=>!w.enabled||!b?null:(M!==b.key&&(L++,M=b.key),{rows:b.rows,version:L}),ne=async G=>{const se=G.where&&G.where.active?G.where:null;if(!se)return{request:G,probe:null};const{where:le,...ae}=G,de=I(ae,d,w.enabled);if(de.needsAll)return{request:G,probe:null};const we=ee(de.pushed);let Ae=null;return(!v||v.key!==we)&&(d.total?(T(G),Ae=await E(await a.execute(de.pushed,G)),v={key:we,size:Ae&&typeof Ae.total=="number"?Ae.total:null}):v={key:we,size:null}),v.size!==null&&v.size<f?{request:G,probe:null}:(J(se.names,m,v.size,f),{request:ae,probe:Ae})},ue=async(G,se)=>{l=null;const le=z(G.pushed);i={engine:le.engine,client:le.client,groupBy:G.pushed.groupBy},le.client.length&&j(`source.pushdown.group.totals.${m}.${le.client.map(we=>we.id).join(".")}`,`the ${m} adapter cannot compute the group subtotal for ${le.client.map(we=>`"${we.id}" (${we.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 ae=await a.executeGroupLevel(G.pushed,le.engine,se)||{};let de=ae.rows||[];return!d.range&&se.range&&(de=de.slice(se.range.start,se.range.end)),typeof ae.matchCount=="number"&&(n=ae.matchCount,t=ae.grand?{totals:ae.grand,leafCount:ae.matchCount}:null,r===void 0&&q(a.unfilteredCount)&&(r=null,Promise.resolve(a.unfilteredCount()).then(we=>{r=typeof we=="number"?we:null}).catch(we=>{j(`source.pushdown.group.unfiltered.${m}`,`the ${m} adapter could not count the unfiltered set (${we&&we.message?we.message:we}), so "N of M" falls back to the display count for its denominator.`)}))),ae.total===void 0?{rows:de}:{rows:de,total:ae.total}},ge=(G,se)=>{const le={key:se,state:"pending",value:null};return l=le,G.then(ae=>(l===le&&(l={key:se,state:"settled",value:typeof ae=="number"?ae:null}),ae),ae=>{throw l===le&&(l={key:se,state:"failed",value:null}),ae})},xe=async G=>{const se=A();se&&await se;const le=await ne(G);T(G);let ae=I(le.request,d,w.enabled);if(ae.grouped&&!q(a.executeGroupLevel)&&(j(`source.pushdown.group.method.${m}`,`the ${m} adapter declares the \`group\` capability but has no \`executeGroupLevel(query, aggregates, request)\`, so grouping is not pushed and the grid is left to group whatever rows it holds. Implement the method or drop the capability.`),ae=I(le.request,{...d,group:!1},w.enabled)),e=ae,ae.grouped)return ue(ae,G);if(ae.groupReason&&j(`source.pushdown.group.${m}.${ae.groupReason}`,`the ${m} adapter was not asked to group this query because ${ae.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.`),!ae.needsAll){const Ie=le.probe||await a.execute(ae.pushed,G),Ke=Ie.rows||[];return ce(Ie.pendingTotal)&&Ie.total===void 0?{rows:Ke,pendingTotal:ge(Ie.pendingTotal,ee(ae.pushed))}:(l=null,!d.total&&Ie.total===void 0?{rows:Ke}:{rows:Ke,total:Ie.total??Ke.length})}ae.unpushed.length&&j(`source.pushdown.residual.${m}.${ae.unpushed.join(".")}`,`the ${m} adapter cannot push ${ae.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 de=ee(ae.pushed);if(!b||b.key!==de){const Ie=await E(await a.execute(ae.pushed,G));l=null;const Ke=Ie.rows||[];if(ae.full){const Be=typeof Ie.total=="number"?Math.max(Ie.total,Ke.length):Ke.length;if(Be>w.maxRows)throw new Error(`[lattice] fullDataset refused: the ${m} adapter's matching set is ${Be.toLocaleString()} rows, past the configured maxRows of ${w.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 ze=Ke.length*H(Ke[0]);if(ze>w.maxBytesEstimate)throw new Error(`[lattice] fullDataset refused: the ${m} adapter's matching set is an estimated ${Math.round(ze/(1024*1024)).toLocaleString()} MB across ${Ke.length.toLocaleString()} rows, past the configured maxBytesEstimate of ${Math.round(w.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 Ie.total=="number"&&Ke.length<Ie.total){const Be=!!(ae.residual.filters||ae.residual.quick||ae.residual.sort&&ae.residual.sort.length);if(Be&&!g)throw new Error(`[lattice] the ${m} adapter returned ${Ke.length} of ${Ie.total} matching rows when asked for the whole result, and the query has residual ${ae.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.`);Be?j(`source.pushdown.partial.residual.${m}`,`the ${m} adapter returned ${Ke.length} of ${Ie.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.`):j(`source.pushdown.partial.${m}`,`the ${m} adapter returned ${Ke.length} of ${Ie.total} matching rows when asked for the whole result. The adapter must follow the engine's own paging before returning.`)}b={key:de,rows:Ke,total:typeof Ie.total=="number"?Ie.total:null}}let we=ae;if(ae.residual.where){const Ie=b.total??b.rows.length;if(Ie>=f){J(ae.residual.where.names,m,Ie,f);const{where:Ke,...Be}=le.request;we=I(Be,d,w.enabled),e=we}}const Ae=b.total!==null&&b.rows.length>=b.total,Ee=re(b.rows,{...we.residual,whole:Ae},h.compute||{}),Te=G.range?G.range.start:0,Ge=G.range?G.range.end:Ee.length;return{rows:Ee.slice(Te,Ge),total:Ee.length}},Ce=async(G,se)=>{const le=A();le&&await le;const ae=I(G,d,w.enabled);e=ae;const de=ie(se,F),we=Array.isArray(G.groupBy)?G.groupBy:[],Ae=we.length>0,Ee=!ae.residual.filters&&!ae.residual.quick,Te=!Ae||S(we,d.buckets);let Ge=de.engine,Ie=de.client;const Ke=qe=>{Ie=[...Ge.map(ot=>({...ot,reason:qe})),...Ie],Ge=[]};Ge.length&&!Ee?Ke(ae.residual.quick&&!ae.residual.filters?"a quick search the adapter cannot push forces all-client (no mixed provenance)":"residual filter forces all-client (no mixed provenance)"):Ge.length&&!Te&&Ke("a grouping key the engine cannot form forces all-client (no mixed provenance)");let Be={},ze;return Ge.length&&(q(Ae?a.executeGroupedAggregates:a.executeAggregates)?Ae?ze=await a.executeGroupedAggregates(ae.pushed,we,Ge)||[]:Be=await a.executeAggregates(ae.pushed,Ge)||{}:(j(`source.pushdown.aggregates.${m}${Ae?".grouped":""}`,`the ${m} adapter cannot compute ${Ae?"grouped ":""}aggregates, so every requested statistic is computed client-side. Correct, and slower than it needs to be.`),Ke(`adapter cannot compute ${Ae?"grouped ":""}aggregates`))),i={engine:Ge,client:Ie,...Ae?{groupBy:we}:{}},{values:Be,engine:Ge,client:Ie,...ze!==void 0?{groups:ze}:{}}},je=p(h.edit),_e=h.edit&&typeof h.edit=="object"&&q(h.edit.commit);let Re=h.edit;if(je&&!_e)if(d.mutate&&d.mutate.update){const G=se=>{if(!d.mutate||!d.mutate.update)throw new Error(`[lattice] the ${m} 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 le={kind:"update",key:String(se.key),patch:{[se.colId]:se.value}};return a.mutate(le,se.request||{})};Re={...h.edit===!0?{}:h.edit,commit:G}}else j(`source.pushdown.readonly.${m}`,`edit is enabled but the ${m} adapter declares mutate: ${d.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 fe=je&&d.mutate&&(d.mutate.append||d.mutate.delete)?{append:d.mutate.append===!0,remove:d.mutate.delete===!0,returning:d.mutate.returning,mutate:(G,se)=>a.mutate(G,se||{})}:null;return{...h,edit:Re,rowMutate:fe,mode:"remote",fetch:xe,aggregate:Ce,lastPlan:()=>e?{...e,...i?{aggregates:i}:{},...l?{total:{deferred:!0,state:l.state,value:l.value}}:{}}:null,fullFrame:C,counts:()=>({match:n,total:r??null,pending:!!l&&l.state==="pending"}),grandTotals:()=>t}}}),Qe("packages/modules/shared/engine.js",function(o,X){"use strict";Object.defineProperty(o,"sourceId",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"engineSource",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"loadedAndMatching",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"gridHoldsWindow",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"gridEngineRequest",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"EngineFlight",{enumerable:!0,get:function(){return T}});const ye=X("packages/core/src/source/pushdown.js"),q=ye.capabilitiesOf,j=ye.planQuery,me=X("packages/core/src/source/filterwire.js").wireFilters,te=new WeakMap;let J=0;function W(B){let _=te.get(B);return _===void 0&&(_=++J,te.set(B,_)),_}function ie(B){const _=B&&typeof B.config=="function"?B.config():null,$=_&&_.source&&typeof _.source=="object"?_.source:null;if(!$||typeof $.aggregate!="function")return{reason:"the grid's source has no aggregate() — it is not a pushdown source"};const p=q($.adapter&&$.adapter.capabilities);return{source:$,caps:p,config:_}}function S(B){let _=0;B.rows.forEach(p=>{p&&!p.group&&p.data!==null&&p.data!==void 0&&_++});const $=typeof B.rows.matchCount=="function"?B.rows.matchCount():NaN;return{loaded:_,total:Number.isFinite($)?$:NaN}}function y(B){const _=B&&typeof B.config=="function"?B.config():null,$=_&&_.source&&typeof _.source=="object"?_.source:null;if(!$||$.mode!=="remote"&&$.mode!=="paged")return!1;const{loaded:p,total:s}=S(B);return Number.isFinite(s)&&p<s}function U(B,_){return _?B?{op:"and",conditions:[B,_]}:_:B||null}function D(B,_,$=null){const p=B.filters&&typeof B.filters.where=="function"?B.filters.where():[];if(Array.isArray(p)&&p.length)return{reason:`a \`where\` predicate is in force (${p.join(", ")}), which only the browser can run`};const s=B.filters&&typeof B.filters.quickState=="function"?B.filters.quickState():{text:""},c=s&&s.text?String(s.text):"",{config:k,caps:R}=_,I={filters:me(U(B.filters.get(),$),{tz:k.timeZone,weekStartsOn:k.weekStartsOn}),sort:[],range:null,context:k.context??null,...c?{quick:c}:{}},z=j(I,R);return z.unpushed.includes("filter")?{reason:$?"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"}:z.unpushed.includes("quick")?{reason:"the quick search did not push to the engine"}:{request:I,quick:c}}class T{#r=null;#n=null;#l=!1;answer(_){return this.#n&&this.#n.key===_?this.#n:null}last(){return this.#n}get busy(){return this.#r!==null}ask(_,$,p){const s=this.#r;if(s){s.key!==_&&s.controller&&s.controller.abort();return}const c=globalThis.AbortController,k=typeof c=="function"?new c:null,R={key:_,controller:k};this.#r=R;let I;Promise.resolve().then(()=>$(k?k.signal:null)).then(z=>{I={key:_,result:z}},z=>{I={key:_,error:z}}).then(()=>{this.#r===R&&(this.#r=null),!this.#l&&(k&&k.signal.aborted||(this.#n=I),p())})}abort(){const _=this.#r;_&&_.controller&&_.controller.abort()}close(){this.#l=!0,this.abort()}}}),Qe("packages/modules/charts/engine.js",function(o,X){"use strict";Object.defineProperty(o,"AGGREGATE_MODES",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"ENGINE_TYPES",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"aggregateMode",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"planAggregate",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"holdsWindow",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"boundFromGroups",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"measureProvenance",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"specMeasures",{enumerable:!0,get:function(){return a}});const ye=X("packages/modules/charts/scale.js"),q=ye.key,j=ye.toNumber,be=X("packages/modules/charts/bind.js"),me=be.forcedScaleKind,te=be.measureOf,J=be.scaleKindFor,W=X("packages/core/src/source/aggregates.js"),ie=W.resolveAggregatePlan,S=W.STAT_PUSHDOWN,U=X("packages/core/src/internal/util.js").warnOnce,D=X("packages/modules/shared/engine.js"),T=D.engineSource,B=D.gridEngineRequest,_=D.gridHoldsWindow,$=D.loadedAndMatching,p=D.sourceId,s=Object.freeze(["auto","engine","client"]),c=Object.freeze(new Set(["line","step","area","bar","horizontalBar","waterfall","combo","pareto","heatmap","radar","funnel","stream","marimekko"])),k=Object.freeze(new Set(["combo","bar","line","step","area"])),R=Object.freeze({mean:"avg"}),I="__rows",z="m",Y="__size",re=/^[A-Za-z_][A-Za-z0-9_$]*$/;function ee(d){const u=d?d.aggregate:void 0;return u==null?"auto":typeof u=="string"&&s.includes(u)?u:(U(`chart:aggregate:mode:${String(u)}`,`chart aggregate ${JSON.stringify(u)} is not a mode; use one of ${s.join(", ")}. The chart used 'auto'.`),"auto")}function H(d,u,m){const O=d.columns.get(u);if(!O)return`the ${m} column "${u}" is not a column of the grid`;const A=O.value&&typeof O.value=="object"?O.value:null;return O.computed||A&&(typeof A.get=="function"||typeof A.compute=="function")?`the ${m} column "${u}" is computed by the grid, which the engine cannot reproduce`:(typeof O.field=="string"?O.field:u)!==u||!re.test(u)?`the ${m} column "${u}" is not a plain physical column the engine can name`:m!=="measure"&&O.type==="geometry"?`the ${m} column "${u}" is a geometry, which charts group in the browser for now`:""}function pe(d,u,m){const O=k.has(m)&&Array.isArray(u.measures)&&u.measures.length>0;return(O?u.measures:[u.y]).map((w,g)=>{const f=te(w),v=f.col?d.columns.get(f.col):void 0,F=te(w,v),b=w&&typeof w=="object"?w:{};return{id:`${z}${g}`,col:F.col,fn:F.fn,stat:R[F.fn]||F.fn,label:O?b.title||b.label||v&&v.title||F.col||"":v&&v.title||F.col||"",mark:O&&b.type||null,axis:O&&b.axis==="right"?"right":"left",multi:O}})}function x(d,u,m){const O=ee(u),A=(C,ne=!1)=>({mode:"client",asked:O,reason:C,refused:O==="engine",windowed:ne});if(O==="client")return{...A("aggregate: 'client' was asked for"),refused:!1};if(!c.has(m))return A(`a "${m}" chart does not draw a grouped aggregate`);if(Array.isArray(u.points))return A("the chart draws an explicit point set");if(u.rows)return A("the chart was handed its own rows");if(u.from==="groups"||u.from==="selection")return A(`the chart reads the grid's ${u.from==="groups"?"group rows":"selection"}`);if(u.error)return A("error bars need the readings behind each mark");const w=T(d);if("reason"in w)return A(w.reason);const{source:g,caps:f}=w;if(!f.group)return A("the source's adapter does not declare the `group` capability");const v=typeof u.x=="string"&&u.x?u.x:null;if(!v)return A("the chart names no x column to group by");const F=typeof u.series=="string"&&u.series?u.series:typeof u.multiples=="string"?u.multiples:null,b=pe(d,u,m),e=b.length>0&&b[0].multi,i=F&&!e?[v,F]:[v];for(const[C,ne]of i.entries()){const ue=H(d,ne,C===0?"x":"series");if(ue)return A(ue)}for(const C of b){if(!C.col)return A("a measure names no column to reduce");const ne=H(d,C.col,"measure");if(ne)return A(ne);const ue=S[C.stat];if(!ue||!ue.pushable)return A(`"${C.fn}" of "${C.col}" is not a reduction the engine can compute`)}if(u.size){const C=typeof u.size=="string"?H(d,u.size,"measure"):"the size channel is not a column";if(C)return A(C)}const n=[...b.map(C=>({id:C.id,col:C.col,fn:C.stat})),{id:I,col:v,fn:"count"},...u.size?[{id:Y,col:u.size,fn:"sum"}]:[]],t=ie(n,g.aggregates);if(t.client.length){const C=t.client[0];return A(`the source computes "${C.fn}" client-side (${C.reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to compute it in the engine`)}const r=B(d,w);if("reason"in r)return A(r.reason);const{quick:l}=r,L={...r.request,groupBy:i};if(O==="auto"){const{loaded:C,total:ne}=$(d);if(Number.isFinite(ne)&&C>=ne)return A("the grid holds every matching row")}const M=JSON.stringify([p(g),L.filters,l,i,n]);return{mode:"engine",asked:O,key:M,source:g,request:L,requested:n,groupBy:i,measures:b}}function Q(d){return _(d)}function ce(d,u){if(u==null)return"";if(d&&typeof d.formatValue=="function")try{const m=d.formatValue(u,null);if(typeof m=="string"&&m)return m}catch{}return u instanceof Date?u.toISOString().slice(0,10):String(u)}function E(d,u){if(d==null)return u==null?0:1;if(u==null)return-1;const m=d instanceof Date?d.getTime():j(d),O=u instanceof Date?u.getTime():j(u);return typeof d!="string"&&typeof u!="string"&&m!==null&&O!==null?m-O:String(d).localeCompare(String(u))}function V(d,u,m,O){const{groupBy:A,measures:w}=m,g=A[0],f=A[1]||null,v=w[0].multi,F=d.columns.get(g),b=f?d.columns.get(f):void 0,e=(O||[]).filter(je=>je&&je.level===A.length),i=new Map,n=new Map,t=new Map;for(const je of e){const _e=je.keys[0],Re=q(_e);i.has(Re)||i.set(Re,_e);const fe=f?je.keys[1]:null,G=f?q(fe):"";n.has(G)||n.set(G,fe),t.set(`${G}\0${Re}`,je.values||{})}const r=d.sort&&typeof d.sort.get=="function"?d.sort.get():[],l=Array.isArray(r)&&r[0]&&r[0].col===g&&r[0].dir==="desc",L=[...i.entries()].sort((je,_e)=>E(je[1],_e[1]));l&&L.reverse();const M=typeof u.limit=="number"&&u.limit>0?L.slice(0,u.limit):L,C=M.map(([,je])=>ce(F,je)),ne=M.map(([,je])=>je),ue=(je,_e,Re,fe,G)=>{const se=t.get(`${je}\0${_e}`),le=se?j(se[I]):null;return{x:Re,xKey:_e,label:fe,y:se?j(se[G]):null,size:se&&u.size?j(se[Y]):null,rows:le===null?0:le,rowKey:null,values:null}};let ge;v?ge=w.map((je,_e)=>({key:je.col,label:je.label,index:_e,mark:je.mark,axis:je.axis,points:M.map(([Re,fe],G)=>ue("",Re,fe,C[G],je.id))})):ge=[...n.entries()].sort((_e,Re)=>E(_e[1],Re[1])).map(([_e,Re],fe)=>({key:_e,label:f?ce(b,Re):w[0].label,index:fe,points:M.map(([G,se],le)=>ue(_e,G,se,C[le],w[0].id))}));const xe=e.reduce((je,_e)=>je+(j(_e.values&&_e.values[I])||0),0),Ce=J(F,ne,{forced:me(u),id:g});return{series:ge,categories:ne,labels:C,kind:Ce,measure:v?{col:null,fn:"sum",title:ge.map(je=>je.label).join(", ")}:{col:w[0].col,fn:w[0].fn,title:w[0].label},dimension:{col:g,title:F&&F.title||g},empty:ge.length===0||M.length===0,rows:xe,truncated:L.length-M.length,bucketed:null}}function h(d,u,m=[],O=""){return d.map(A=>{const w=m.find(g=>g.id===A.id);return{col:A.col||null,fn:A.fn,computed:u,...w&&w.class?{class:w.class}:{},...u==="client"&&O?{reason:O}:{}}})}function a(d,u,m){try{return pe(d,u,m).filter(O=>O.col)}catch{return[]}}}),Qe("packages/core/src/format/date.js",function(o,X){"use strict";Object.defineProperty(o,"scanPattern",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"toDate",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"compilePattern",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"compileDate",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"toIsoDate",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"toIsoDateTime",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"compareIso",{enumerable:!0,get:function(){return $}});const ye=X("packages/core/src/internal/util.js"),q=ye.isNil,j=ye.warnOnce,be=["yyyy","yy","MMMM","MMM","MM","M","dd","d","EEEE","EEE","HH","H","hh","h","mm","m","ss","s","SSS","a"];function me(p){const s=[];let c=0,k="";const R=()=>{k&&(s.push({token:null,text:k}),k="")};for(;c<p.length;){const I=p[c];if(I==="'"){if(p[c+1]==="'"){k+="'",c+=2;continue}const Y=p.indexOf("'",c+1);if(Y===-1){k+=p.slice(c+1),c=p.length;continue}k+=p.slice(c+1,Y),c=Y+1;continue}const z=be.find(Y=>p.startsWith(Y,c));if(z){R(),s.push({token:z,text:z}),c+=z.length;continue}/[A-Za-z]/.test(I)&&j(`date.pattern.token:${I}`,`the date pattern "${p}" contains '${I}', which is not a supported token, so it is rendered as text. Quote it as a literal to silence this. Supported: ${be.join(" ")}.`),k+=I,c+=1}return R(),s}const te=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2})(?::(\d{2}))?(?:\.\d+)?)?$/;function J(p){if(q(p)||p==="")return null;if(p instanceof Date)return Number.isNaN(p.getTime())?null:p;if(typeof p=="number")return Number.isNaN(p)?null:new Date(p);if(typeof p=="string"){const s=te.exec(p.trim());if(s){const[,k,R,I,z="0",Y="0",re="0"]=s;return new Date(+k,+R-1,+I,+z,+Y,+re)}const c=new Date(p);return Number.isNaN(c.getTime())?null:c}return null}function W(p,s){return String(p).padStart(s,"0")}function ie(p){if(!p)return k=>({year:k.getFullYear(),month:k.getMonth()+1,day:k.getDate(),hour:k.getHours(),minute:k.getMinutes(),second:k.getSeconds(),ms:k.getMilliseconds(),weekday:k.getDay()});const s=new Intl.DateTimeFormat("en-US",{timeZone:p,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,weekday:"short"}),c={Sun:0,Mon:1,Tue:2,Wed:3,Thu:4,Fri:5,Sat:6};return k=>{const R={year:0,month:1,day:1,hour:0,minute:0,second:0,ms:k.getMilliseconds(),weekday:0};for(const I of s.formatToParts(k))switch(I.type){case"year":R.year=Number(I.value);break;case"month":R.month=Number(I.value);break;case"day":R.day=Number(I.value);break;case"hour":R.hour=Number(I.value)%24;break;case"minute":R.minute=Number(I.value);break;case"second":R.second=Number(I.value);break;case"weekday":R.weekday=c[I.value]??0;break;default:break}return R}}function S(p,s,c){const k=me(p),R=ie(c),I=new Set(k.filter(H=>H.token).map(H=>H.token)),z=I.has("MMM")?new Intl.DateTimeFormat(s,{month:"short",timeZone:c}):null,Y=I.has("MMMM")?new Intl.DateTimeFormat(s,{month:"long",timeZone:c}):null,re=I.has("EEE")?new Intl.DateTimeFormat(s,{weekday:"short",timeZone:c}):null,ee=I.has("EEEE")?new Intl.DateTimeFormat(s,{weekday:"long",timeZone:c}):null;return H=>{const pe=R(H);let x="";for(const Q of k){if(!Q.token){x+=Q.text;continue}switch(Q.token){case"yyyy":x+=W(pe.year,4);break;case"yy":x+=W(pe.year%100,2);break;case"MMMM":x+=Y.format(H);break;case"MMM":x+=z.format(H);break;case"MM":x+=W(pe.month,2);break;case"M":x+=String(pe.month);break;case"dd":x+=W(pe.day,2);break;case"d":x+=String(pe.day);break;case"EEEE":x+=ee.format(H);break;case"EEE":x+=re.format(H);break;case"HH":x+=W(pe.hour,2);break;case"H":x+=String(pe.hour);break;case"hh":x+=W(pe.hour%12===0?12:pe.hour%12,2);break;case"h":x+=String(pe.hour%12===0?12:pe.hour%12);break;case"mm":x+=W(pe.minute,2);break;case"m":x+=String(pe.minute);break;case"ss":x+=W(pe.second,2);break;case"s":x+=String(pe.second);break;case"SSS":x+=W(pe.ms,3);break;case"a":x+=pe.hour<12?"AM":"PM";break;default:x+=Q.text;break}}return x}}const y=[["year",365*24*36e5],["month",720*36e5],["week",168*36e5],["day",24*36e5],["hour",36e5],["minute",6e4],["second",1e3]];function U(p,s){const c=p||{},k=c.locale||s||void 0,R=c.nullDisplay??"",I=c.timeZone;let z;if(c.pattern)z=S(c.pattern,k,I);else if(c.dateStyle||c.timeStyle){const pe={timeZone:I};c.dateStyle&&(pe.dateStyle=c.dateStyle),c.timeStyle&&(pe.timeStyle=c.timeStyle);const x=new Intl.DateTimeFormat(k,pe);z=Q=>x.format(Q)}else{const pe=new Intl.DateTimeFormat(k,{dateStyle:"medium",timeZone:I});z=x=>pe.format(x)}const Y=c.relative?new Intl.RelativeTimeFormat(k,{numeric:"auto"}):null,ee=(typeof c.relative=="object"&&c.relative?c.relative.threshold??7:7)*24*36e5,H=(pe,x)=>{const Q=J(pe);if(!Q)return R;if(Y){const ce=x&&typeof x.now=="number"?x.now:Date.now(),E=Q.getTime()-ce;if(Math.abs(E)<ee){for(const[V,h]of y)if(Math.abs(E)>=h||V==="second")return Y.format(Math.round(E/h),V)}}return z(Q)};return H.spec=c,H}function D(p){if(q(p)||p==="")return null;if(typeof p=="string"){const k=/^(\d{4}-\d{2}-\d{2})/.exec(p.trim());if(k)return k[1];const R=J(p);return R?D(R):null}const s=J(p);if(!s)return null;const c=k=>String(k).padStart(2,"0");return`${s.getFullYear()}-${c(s.getMonth()+1)}-${c(s.getDate())}`}function T(p,s){if(q(p)||p==="")return null;if(typeof p=="string"){const k=p.trim();if(B.test(k)){const z=J(k);return z?_(z,s):null}const R=/^(\d{4}-\d{2}-\d{2})[T ](\d{2}):(\d{2})(?::(\d{2}))?/.exec(k);if(R){const[,z,Y,re,ee]=R;return`${z}T${Y}:${re}${ee&&ee!=="00"?`:${ee}`:""}`}if(/^\d{4}-\d{2}-\d{2}$/.test(k))return`${k}T00:00`;const I=J(k);return I?T(I):null}const c=J(p);return c?_(c,s):null}const B=/(?:Z|[+-]\d{2}:?\d{2})$/i;function _(p,s){const c=z=>String(z).padStart(2,"0");if(s)try{const z=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1}).formatToParts(p).reduce((ee,H)=>(H.type!=="literal"&&(ee[H.type]=H.value),ee),{}),Y=z.hour==="24"?"00":z.hour,re=Number(z.second);return`${z.year}-${z.month}-${z.day}T${Y}:${z.minute}`+(re?`:${z.second}`:"")}catch{}const k=`${p.getFullYear()}-${c(p.getMonth()+1)}-${c(p.getDate())}`,R=p.getSeconds(),I=`${c(p.getHours())}:${c(p.getMinutes())}${R?`:${c(R)}`:""}`;return`${k}T${I}`}function $(p,s){const c=q(p)||p===""?null:String(p),k=q(s)||s===""?null:String(s);return c===null?k===null?0:1:k===null||c<k?-1:c>k?1:0}}),Qe("packages/core/src/compute/handle.js",function(o,X){"use strict";Object.defineProperty(o,"identity",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"rowCount",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"bitReader",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"presenceReader",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"dictSize",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"dictValue",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"multiValue",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"valueReader",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"numericTotalOrder",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"valueComparator",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"dictRanks",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"isMissing",{enumerable:!0,get:function(){return p}});const ye=X("packages/core/src/internal/util.js"),q=ye.collator,j=ye.defaultCompare,be=ye.warnOnce;function me(s){const c=new Uint32Array(s);for(let k=0;k<s;k++)c[k]=k;return c}function te(s,c){if(c&&typeof c.count=="number")return c.count;if(!s)return 0;if(typeof s.count=="number")return s.count;if(typeof s.length=="number")return s.length;const k=s.values;return s.kind==="multi"&&s.offsets?Math.max(0,s.offsets.length-1):k?s.kind==="bitset"?typeof k.size=="number"?k.size:s.presence&&typeof s.presence.size=="number"?s.presence.size:(be(`count:${s.id}`,`column "${s.id}" is bitset-backed with no declared row count; assuming ${k.length*8}`),k.length*8):k.length:s.presence&&typeof s.presence.size=="number"?s.presence.size:0}const J=new WeakMap;function W(s){const c=s.constructor;if(!c)return"unknown";const k=J.get(c);if(k)return k;let R="unknown";try{let I=null;typeof c.from=="function"?I=c.from([!1,!0]):(I=new c(8),I.set(1));const z=I&&I.words;z&&z.length&&(z[0]===2?R="lsb":z[0]===64&&(R="msb"))}catch{R="unknown"}return J.set(c,R),R}function ie(s){if(!s)return()=>0;const c=s instanceof Uint8Array?s:s.words;if(c instanceof Uint8Array){const k=s instanceof Uint8Array?"lsb":W(s);if(k==="lsb")return R=>c[R>>>3]>>>(R&7)&1;if(k==="msb")return R=>c[R>>>3]>>>7-(R&7)&1}return typeof s.get=="function"?k=>s.get(k)?1:0:()=>0}function S(s){return!s||!s.presence?null:ie(s.presence)}function y(s){return s?typeof s.size=="number"?s.size:typeof s.values=="function"?s.values().length:0:0}function U(s,c){return s?typeof s.valueOf=="function"?s.valueOf(c):typeof s.values=="function"?s.values()[c]:null:null}function D(s,c){const k=s.offsets,R=s.values;if(!k||!R)return[];const I=k[c],z=k[c+1];if(!(z>I))return[];const Y=s.dict,re=new Array(z-I);for(let ee=I;ee<z;ee++)re[ee-I]=Y?U(Y,R[ee]):R[ee];return re}function T(s){if(!s)return()=>{};const c=s.values,k=S(s),R=s.kind;if(R==="dictionary"){const I=s.dict;return k?z=>k(z)?U(I,c[z]):null:z=>U(I,c[z])}if(R==="bitset"){const I=ie(c);return k?z=>k(z)?I(z)===1:null:z=>I(z)===1}if(R==="multi")return k?I=>k(I)?D(s,I):null:I=>D(s,I);if(!c&&typeof s.get=="function"){const I=s.get.bind(s);return z=>{const Y=I(z);return Y===void 0?null:Y}}return k?I=>{if(!k(I))return null;const z=c[I];return z===void 0?null:z}:I=>{const z=c[I];return z===void 0?null:z}}function B(s,c){if(s<c)return-1;if(s>c)return 1;if(s===c){const I=Object.is(s,-0),z=Object.is(c,-0);return I===z?0:I?-1:1}const k=Number.isNaN(s),R=Number.isNaN(c);return k&&R?0:k?1:-1}function _(s){const c=q(s);return(k,R)=>{if(k===R)return 0;const I=typeof k,z=typeof R;if(I==="string"&&z==="string")return c.compare(k,R);if(I==="number"&&z==="number")return B(k,R);if(I==="boolean"&&z==="boolean")return k===R?0:k?1:-1;if(k instanceof Date||R instanceof Date){const Y=k instanceof Date?k.getTime():Number(k),re=R instanceof Date?R.getTime():Number(R);return B(Y,re)}return j(k,R)}}function $(s,c){if(s&&typeof s.ranks=="function")return s.ranks(c);const k=s&&typeof s.values=="function"?s.values():[],R=k.length,I=_(c),z=new Array(R);for(let re=0;re<R;re++)z[re]=re;z.sort((re,ee)=>I(k[re],k[ee])||re-ee);const Y=new Uint32Array(R);for(let re=0;re<R;re++)Y[z[re]]=re;return Y}function p(s){return s==null||typeof s=="number"&&Number.isNaN(s)}}),Qe("packages/core/src/compute/filter.js",function(o,X){"use strict";Object.defineProperty(o,"releaseMask",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"compilePredicate",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"testValue",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"itemwisePredicate",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"evaluateCondition",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"evaluateFilters",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"pruneColumn",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"mentionsColumn",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"compact",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"declareOperators",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"declaredOperator",{enumerable:!0,get:function(){return b}});const ye=X("packages/core/src/internal/util.js"),q=ye.isBlank,j=ye.toArray,be=ye.warnOnce,te=X("packages/core/src/format/date.js").toIsoDate,J=X("packages/core/src/compute/handle.js"),W=J.bitReader,ie=J.dictSize,S=J.dictValue,y=J.presenceReader,U=J.valueComparator,D=J.valueReader,T=/^\d{4}-\d{2}-\d{2}$/,B="\0null\0";function _(e,i){const n=e&&e.pool;if(n){const t=n.mask||n.acquireMask||n.acquire||n.take;if(typeof t=="function"){const r=t.call(n,i);if(r&&r.length>=i)return r}}return new Uint8Array(i)}function $(e,i){const n=e&&e.pool;if(!n||!i)return;const t=n.release||n.releaseMask||n.free||n.recycle;typeof t=="function"&&t.call(n,i)}function p(e,i,n){return e.fill(n,0,i),e}function s(e){return e==null||typeof e=="number"&&Number.isNaN(e)}function c(e,i){if(e==null)return e;if(i==="number")return typeof e=="number"?e:Number(e);if(i==="date"||i==="dateString"){const n=te(e);return n===null?k(e):n}return i==="boolean"?typeof e=="boolean"?e:e==="true"||e===1?!0:e==="false"||e===0?!1:!!e:e}function k(e){return e instanceof Date?e.getTime():typeof e=="number"?e:Date.parse(String(e))}function R(e){return typeof e=="number"?e:e instanceof Date?e.getTime():e==null||e===""?NaN:Number(e)}function I(e,i){const n=typeof e=="string"?e:String(e);return i?n:n.toLowerCase()}function z(e,i){return e==null?B:typeof e=="string"?i?e:e.toLowerCase():e instanceof Date?e.getTime():e}function Y(e,i,n){const t=new Set;for(const r of j(e)){const l=c(r,n);t.add(z(l,i)),typeof l=="string"&&l!==""&&Number.isFinite(Number(l))?t.add(Number(l)):typeof l=="number"&&Number.isFinite(l)&&t.add(z(String(l),i))}return t}function re(e,i,n){if(e==null||i===null||i===void 0)return e==null&&i==null;const t=typeof e,r=typeof i;return t==="string"&&r==="string"?n?e===i:e.toLowerCase()===i.toLowerCase():e instanceof Date||i instanceof Date?k(e)===k(i):t==="number"&&r==="number"?e===i||Number.isNaN(e)&&Number.isNaN(i):t==="number"&&r==="string"?e===Number(i):t==="string"&&r==="number"?Number(e)===i:t==="boolean"||r==="boolean"?e===i:Array.isArray(e)&&Array.isArray(i)?e.length===i.length&&e.every((l,L)=>re(l,i[L],n)):e===i}function ee(e,i){try{if(e instanceof RegExp){const n=e.flags.replace(/[gy]/g,"");return new RegExp(e.source,i||n.includes("i")?n:`${n}i`)}return new RegExp(String(e),i?"":"i")}catch(n){return be(`regex:${String(e)}`,`filter operator "matches" received an invalid pattern: ${String(e)}`,n),null}}function H(e,i){const n=pe(e,i),t=e&&e.type;return t!=="date"&&t!=="dateString"?n:r=>n(typeof r=="string"&&T.test(r)?r:te(r)??r)}function pe(e,i){const n=e&&e.op,t=!!(e&&e.caseSensitive),r=e&&e.type,l=U(i),L=M=>C=>!M(C);switch(n){case"eq":{const M=c(e.value,r);return C=>re(C,M,t)}case"ne":{const M=c(e.value,r);return C=>!re(C,M,t)}case"lt":case"lte":case"gt":case"gte":{const M=c(e.value,r);if(s(M))return()=>!1;const C=n==="lt"?-1:n==="lte"?0:n==="gt"?1:2;return ne=>{if(s(ne))return!1;const ue=l(ne,M);return C===-1?ue<0:C===0?ue<=0:C===1?ue>0:ue>=0}}case"between":case"notBetween":{const M=j(e.value),C=c(M[0],r),ne=c(M[1],r),ue=e.bounds||"[]",ge=ue.charAt(0)!=="(",xe=ue.charAt(1)!==")";if(s(C)||s(ne))return n==="between"?()=>!1:()=>!0;const Ce=je=>{if(s(je))return!1;const _e=l(je,C),Re=l(je,ne);return(ge?_e>=0:_e>0)&&(xe?Re<=0:Re<0)};return n==="between"?Ce:L(Ce)}case"in":case"notIn":{const M=Y(e.value,t,r),C=ne=>M.has(z(ne,t));return n==="in"?C:L(C)}case"contains":case"notContains":{const M=I(c(e.value,r),t),C=ne=>ne==null?!1:I(ne,t).includes(M);return n==="contains"?C:L(C)}case"startsWith":{const M=I(c(e.value,r),t);return C=>C==null?!1:I(C,t).startsWith(M)}case"endsWith":{const M=I(c(e.value,r),t);return C=>C==null?!1:I(C,t).endsWith(M)}case"matches":{const M=ee(e.value,t);return M?C=>C==null?!1:M.test(String(C)):()=>!1}case"blank":return M=>q(M)||Array.isArray(M)&&M.length===0;case"notBlank":return M=>!(q(M)||Array.isArray(M)&&M.length===0);case"containsAny":case"containsNone":{const M=Y(e.value,t,r),C=ne=>{const ue=ne==null?[]:j(ne);for(let ge=0;ge<ue.length;ge++)if(M.has(z(ue[ge],t)))return!0;return!1};return n==="containsAny"?C:L(C)}case"containsAll":{const M=j(e.value).map(C=>z(c(C,r),t));return C=>{const ne=C==null?[]:j(C);if(M.length===0)return!0;const ue=new Set(ne.map(ge=>z(ge,t)));for(let ge=0;ge<M.length;ge++)if(!ue.has(M[ge]))return!1;return!0}}default:{const M=b(n);return M?M.compile(e.value):(be(`op:${String(n)}`,`unknown filter operator "${String(n)}"; the condition is refused rather than matching every row`),()=>!1)}}}function x(e,i,n){return H(i,n)(e)}const Q=Object.freeze({ne:"eq",notIn:"in",notBetween:"between",notContains:"contains"}),ce=new Set(["containsAny","containsAll","containsNone"]);function E(e,i,n){const t=e&&e.op,r=Q[t]||t,l=H({...e,op:r,type:i.type},n),L=i.items,M=C=>{const ne=L(C);if(!ne)return!1;for(let ue=0;ue<ne.length;ue++)if(l(ne[ue]))return!0;return!1};return Q[t]?C=>!M(C):M}function V(e,i,n,t){const r=y(e);if(r){const M=i?1:0;for(let C=0;C<t;C++)n[C]=r(C)===M?1:0;return n}const l=e.kind;if(l==="float64"||l==="int32"||l==="bitset")return p(n,t,i?1:0);const L=D(e);for(let M=0;M<t;M++){const C=L(M),ne=q(C)||Array.isArray(C)&&C.length===0;n[M]=ne===i?0:1}return n}function h(e,i,n,t){const r=e.dict,l=ie(r),L=new Uint8Array(l);for(let ue=0;ue<l;ue++)L[ue]=i(S(r,ue))?1:0;const M=e.values,C=y(e);if(!C){for(let ue=0;ue<t;ue++)n[ue]=L[M[ue]];return n}const ne=i(null)?1:0;for(let ue=0;ue<t;ue++)n[ue]=C(ue)===1?L[M[ue]]:ne;return n}function a(e,i,n,t){const r=W(e.values),l=i(!0)?1:0,L=i(!1)?1:0,M=y(e);if(!M){for(let ne=0;ne<t;ne++)n[ne]=r(ne)===1?l:L;return n}const C=i(null)?1:0;for(let ne=0;ne<t;ne++)n[ne]=M(ne)===0?C:r(ne)===1?l:L;return n}function d(e,i,n,t,r){const l=e.values,L=i.type,M=i.op;let C=!0;switch(M){case"eq":case"ne":{const ue=R(c(i.value,L)),ge=typeof i.value=="number"&&Number.isNaN(i.value),xe=M==="ne"?1:0;if(ge)for(let Ce=0;Ce<r;Ce++)t[Ce]=(Number.isNaN(l[Ce])?1:0)^xe;else for(let Ce=0;Ce<r;Ce++)t[Ce]=(l[Ce]===ue?1:0)^xe;break}case"lt":{const ue=R(c(i.value,L));for(let ge=0;ge<r;ge++)t[ge]=l[ge]<ue?1:0;break}case"lte":{const ue=R(c(i.value,L));for(let ge=0;ge<r;ge++)t[ge]=l[ge]<=ue?1:0;break}case"gt":{const ue=R(c(i.value,L));for(let ge=0;ge<r;ge++)t[ge]=l[ge]>ue?1:0;break}case"gte":{const ue=R(c(i.value,L));for(let ge=0;ge<r;ge++)t[ge]=l[ge]>=ue?1:0;break}case"between":case"notBetween":{const ue=j(i.value),ge=R(c(ue[0],L)),xe=R(c(ue[1],L)),Ce=i.bounds||"[]",je=Ce.charAt(0)!=="(",_e=Ce.charAt(1)!==")",Re=M==="notBetween"?1:0;if(je&&_e)for(let fe=0;fe<r;fe++)t[fe]=(l[fe]>=ge&l[fe]<=xe?1:0)^Re;else if(je)for(let fe=0;fe<r;fe++)t[fe]=(l[fe]>=ge&l[fe]<xe?1:0)^Re;else if(_e)for(let fe=0;fe<r;fe++)t[fe]=(l[fe]>ge&l[fe]<=xe?1:0)^Re;else for(let fe=0;fe<r;fe++)t[fe]=(l[fe]>ge&l[fe]<xe?1:0)^Re;break}case"in":case"notIn":{const ue=new Set;for(const xe of j(i.value)){const Ce=R(c(xe,L));Number.isNaN(Ce)||ue.add(Ce)}const ge=M==="notIn"?1:0;for(let xe=0;xe<r;xe++)t[xe]=(ue.has(l[xe])?1:0)^ge;break}default:C=!1;break}if(!C)return!1;const ne=y(e);if(ne){const ue=n(null)?1:0;for(let ge=0;ge<r;ge++)ne(ge)===0&&(t[ge]=ue)}return!0}function u(e,i,n,t){const r=D(e);for(let l=0;l<t;l++)n[l]=i(r(l))?1:0;return n}function m(e,i,n){const t=i.count|0,r=n||_(i,t);if(!e)return p(r,t,1);const l=typeof i.handle=="function"?i.handle(e.col):void 0,L=typeof i.custom=="function"?i.custom:null;if(!l){if(L){for(let ue=0;ue<t;ue++)r[ue]=L(e,ue)?1:0;return r}return be(`filter:col:${String(e.col)}`,`filter references unknown column "${String(e.col)}"; the condition is refused rather than matching every row`),p(r,t,0)}const M=e.op;if(M==="blank"||M==="notBlank")return V(l,M==="notBlank",r,t);const C=typeof i.itemwise=="function"?i.itemwise(e.col):null;if(C&&!b(M)&&!ce.has(M))return u(l,E(e,C,i.locale),r,t);const ne=H(e,i.locale);switch(l.kind){case"dictionary":return h(l,ne,r,t);case"bitset":return a(l,ne,r,t);case"float64":case"int32":return d(l,e,ne,r,t)?r:u(l,ne,r,t);default:return u(l,ne,r,t)}}function O(e,i,n){if(!e)return p(_(i,n),n,1);if(Array.isArray(e.conditions)){const t=e.conditions.filter(L=>L!=null),r=e.op==="or"?"or":e.op==="not"?"not":"and";if(t.length===0)return p(_(i,n),n,1);const l=O(t[0],i,n);for(let L=1;L<t.length;L++){const M=O(t[L],i,n);if(r==="or")for(let C=0;C<n;C++)l[C]|=M[C];else for(let C=0;C<n;C++)l[C]&=M[C];$(i,M)}if(r==="not")for(let L=0;L<n;L++)l[L]^=1;return l}return m(e,i,_(i,n))}function A(e,i){return O(e,i,i.count|0)}function w(e,i){if(!e||!i)return e||null;const n=e;if(Array.isArray(n.conditions)){if((n.op==="or"?"or":n.op==="not"?"not":"and")!=="and")return g(n,i)?null:e;const r=[];for(const l of n.conditions){const L=w(l,i);L&&r.push(L)}return r.length?{...n,op:"and",conditions:r}:null}return n.col===i?null:e}function g(e,i){if(!e||typeof e!="object")return!1;const n=e;if(n.col===i)return!0;if(Array.isArray(n.conditions)){for(const t of n.conditions)if(g(t,i))return!0}return!1}function f(e,i,n){if(n&&n.length>=i){let L=0;for(let M=0;M<i;M++)e[M]&&(n[L++]=M);return n.subarray(0,L)}let t=0;for(let L=0;L<i;L++)t+=e[L]?1:0;const r=new Uint32Array(t);let l=0;for(let L=0;L<i;L++)e[L]&&(r[l++]=L);return r}const v=new Map;function F(e){if(!(!e||typeof e!="object"))for(const[i,n]of Object.entries(e))n&&typeof n.compile=="function"&&v.set(i,n)}function b(e){return typeof e=="string"?v.get(e):void 0}}),Qe("packages/modules/charts/viewport-filter.js",function(o,X){"use strict";Object.defineProperty(o,"VIEWPORT_FILTER_DEBOUNCE_MS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"resolveViewportFilter",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"viewportTarget",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"viewportBbox",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"sameBbox",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"findColumnCondition",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"viewportCondition",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"conditionBbox",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"pruneTarget",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"mergeViewportCondition",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"adoptedGeoView",{enumerable:!0,get:function(){return B}});const q=X("packages/core/src/compute/filter.js").pruneColumn,j=150,be=1e-6;function me(_){const $={enabled:!1,column:null,debounce:j};if(_==null||_===!1)return $;const p=_===!0?{}:_;if(typeof p!="object")return $;const s=typeof p.column=="string"&&p.column?p.column:null,c=Number.isFinite(p.debounce)&&p.debounce>=0?Number(p.debounce):j;return{enabled:!0,column:s,debounce:c}}function te(_,$){return typeof $=="string"&&$?{kind:"geometry",column:$}:_&&typeof _.geometry=="string"&&_.geometry?{kind:"geometry",column:_.geometry}:_&&typeof _.lon=="string"&&_.lon&&typeof _.lat=="string"&&_.lat?{kind:"lonlat",lon:_.lon,lat:_.lat}:null}function J(_,$){if(!_||!$||typeof _.xScale?.invert!="function"||typeof _.yScale?.invert!="function")return null;const p=_.xScale.invert($.left),s=_.xScale.invert($.right),c=_.yScale.invert($.bottom),k=_.yScale.invert($.top);if(![p,s,c,k].every(Number.isFinite))return null;const R=Math.max(-180,Math.min(p,s)),I=Math.min(180,Math.max(p,s)),z=Math.max(-90,Math.min(c,k)),Y=Math.min(90,Math.max(c,k));return!(I>R)||!(Y>z)?null:[R,z,I,Y]}function W(_,$){return!_||!$?!_&&!$:Math.abs(_[0]-$[0])<=be&&Math.abs(_[1]-$[1])<=be&&Math.abs(_[2]-$[2])<=be&&Math.abs(_[3]-$[3])<=be}function ie(_,$){if(!_)return null;if(Array.isArray(_.conditions)){for(const p of _.conditions){const s=ie(p,$);if(s)return s}return null}return _.col===$?_:null}function S(_,$,p){const[s,c,k,R]=$,I=p?{meta:{label:p}}:{};return _.kind==="geometry"?{col:_.column,op:"withinBbox",value:[s,c,k,R],...I}:{op:"and",conditions:[{col:_.lon,op:"between",value:[s,k]},{col:_.lat,op:"between",value:[c,R]}],...I}}function y(_,$){if(!_||!$)return null;if($.kind==="geometry"){const z=ie(_,$.column);if(!z||z.op!=="withinBbox"||!Array.isArray(z.value)||z.value.length<4)return null;const Y=z.value.map(Number);return Y.every(Number.isFinite)?Y:null}const p=ie(_,$.lon),s=ie(_,$.lat);if(!p||p.op!=="between"||!Array.isArray(p.value)||p.value.length<2||!s||s.op!=="between"||!Array.isArray(s.value)||s.value.length<2)return null;const[c,k]=p.value.map(Number),[R,I]=s.value.map(Number);return[c,R,k,I].every(Number.isFinite)?[c,R,k,I]:null}function U(_){return _.kind==="geometry"?[_.column]:[_.lon,_.lat]}function D(_,$){let p=_||null;for(const s of U($))p=q(p,s);return p}function T(_,$,p){const s=D(_,$);return s?{op:"and",conditions:[...s.conditions||[s],p]}:p}function B(_,$,p,s){if(!_||!$||!p||!s||!(s.scale>0))return null;const[c,k,R,I]=_,[z,Y,re,ee]=$,H=R-c,pe=I-k,x=re-z,Q=ee-Y;if(!(H>0)||!(pe>0)||!(x>0)||!(Q>0))return null;const ce=(z+re)/2,E=(Y+ee)/2,V=p.left+(ce-c)/H*(p.right-p.left),h=p.bottom-(E-k)/pe*(p.bottom-p.top);if(!Number.isFinite(V)||!Number.isFinite(h))return null;const a=(p.left+p.right)/2,d=(p.top+p.bottom)/2,u=a-V,m=d-h,[O,A]=s.offset,w=[O-u/s.scale,A+m/s.scale],g=Math.min(H/x,pe/Q);return!Number.isFinite(g)||g<=0?null:{zoom:Math.min(8,Math.max(1,s.zoom*g)),offset:w}}}),Qe("packages/modules/charts/mapview.js",function(o,X){"use strict";Object.defineProperty(o,"MAP_ENGINE_TYPES",{enumerable:!0,get:function(){return p}}),Object.defineProperty(o,"DEFAULT_VIEWPORT_CAP",{enumerable:!0,get:function(){return s}}),Object.defineProperty(o,"DENSITY_CELLS_ACROSS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"DENSITY_FIT_PASSES",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"FRAME_REFIT_RATIO",{enumerable:!0,get:function(){return R}}),Object.defineProperty(o,"viewportCap",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"densityCellSize",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"boxSpan",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"ringsBox",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"needsRefit",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"frameMoved",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"planMapViewport",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"engineRowsReader",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"frameOf",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"capClientBound",{enumerable:!0,get:function(){return a}});const q=X("packages/core/src/source/pushdown.js").planQuery,be=X("packages/core/src/source/aggregates.js").resolveAggregatePlan,te=X("packages/core/src/internal/util.js").warnOnce,J=X("packages/modules/shared/engine.js"),W=J.engineSource,ie=J.gridEngineRequest,S=J.loadedAndMatching,y=J.sourceId,D=X("packages/modules/charts/engine.js").aggregateMode,T=X("packages/modules/charts/viewport-filter.js"),B=T.conditionBbox,_=T.viewportCondition,$=T.viewportTarget,p=Object.freeze(new Set(["markermap","bubblemap","choropleth"])),s=2e4,c=24,k=8,R=2,I="__viewport_rows",z=/^[A-Za-z_][A-Za-z0-9_$]*$/;function Y(d){const u=d?d.viewportCap:void 0;return u==null?s:typeof u=="number"&&Number.isInteger(u)&&u>0?u:(te(`chart:viewportCap:${String(u)}`,`chart viewportCap ${JSON.stringify(u)} is not a positive whole number of rows; the map used ${s}.`),s)}function re(d){const u=Number.isFinite(d)&&d>0?Math.min(360,d):360,m=2**Math.floor(Math.log2(u/c));return Math.min(90,Math.max(2**-20,m))}function ee(d){return Math.max(d[2]-d[0],d[3]-d[1])}function H(d){let u=1/0,m=1/0,O=-1/0,A=-1/0;for(const w of d||[])for(const[g,f]of w)!Number.isFinite(g)||!Number.isFinite(f)||(u=Math.min(u,g),O=Math.max(O,g),m=Math.min(m,f),A=Math.max(A,f));return O>=u&&A>=m?[u,m,O,A]:null}function pe(d,u){if(!d||!u)return!1;for(const[m,O]of[[0,2],[1,3]]){const A=d[O]-d[m],w=u[O]-u[m];if(!(A>0)||!(w>0))continue;const g=A/w;if(g>R||g<1/R)return!0}return!1}function x(d,u){if(!d||!u)return!!u;const m=1e-9;return!(u[0]>=d[0]-m&&u[1]>=d[1]-m&&u[2]<=d[2]+m&&u[3]<=d[3]+m)||pe(d,u)}function Q(d,u,m){const O=d.columns.get(u);if(!O)return`the ${m} column "${u}" is not a column of the grid`;const A=O.value&&typeof O.value=="object"?O.value:null;return O.computed||A&&(typeof A.get=="function"||typeof A.compute=="function")?`the ${m} column "${u}" is computed by the grid, which the engine cannot reproduce`:(typeof O.field=="string"?O.field:u)!==u||!z.test(u)?`the ${m} column "${u}" is not a plain physical column the engine can name`:""}function ce(d,u,m,O){const A=D(u),w=G=>({mode:"client",asked:A,reason:G,refused:A==="engine"});if(A==="client")return{...w("aggregate: 'client' was asked for"),refused:!1};if(!p.has(m))return w(`a "${m}" chart does not draw a viewport`);if(u.rows)return w("the chart was handed its own rows");const g=$(u);if(!g)return w("the map names neither a geometry column nor lon/lat columns");if(g.kind==="geometry"&&(u.lon||u.lat))return w("the map names both a geometry column and lon/lat columns");const f=g.kind==="geometry"?[g.column]:[g.lon,g.lat];for(const G of f){const se=Q(d,G,"placement");if(se)return w(se)}const v=W(d);if("reason"in v)return w(v.reason);const{source:F,caps:b}=v,e=F.adapter;if(!e||typeof e.execute!="function")return w("the source's adapter has no execute() to fetch rows with");const i=f[0],n=be([{id:I,col:i,fn:"count"}],F.aggregates);if(n.client.length)return w(`the source computes "count" client-side (${n.client[0].reason}); set the pushdown source's \`aggregates: { default: 'engine' }\` to count in the engine`);const t=Array.isArray(O&&O.bbox)?O.bbox:null,r=t?_(g,t):null,l=ie(d,v,r);if("reason"in l)return w(l.reason);if(A==="auto"){const{loaded:G,total:se}=S(d);if(Number.isFinite(se)&&G>=se)return w("the grid holds every matching row")}const L=Y(u),M=t||B(d.filters&&typeof d.filters.get=="function"?d.filters.get():null,g),C=M?re(ee(M)):null,ne=g.kind==="geometry"&&m!=="choropleth"&&Array.isArray(b.buckets)&&b.buckets.includes("grid")&&typeof e.executeGroupedAggregates=="function",ue=m==="choropleth"?"a choropleth draws each shape, and has no density form":g.kind!=="geometry"?"the engine bins a geometry column, and this map places its rows by lon/lat":"the source's adapter cannot bin a geometry column into grid cells (no `buckets` capability)",{request:ge,quick:xe}=l,Ce=ie(d,v),je=JSON.stringify([y(F),"request"in Ce?Ce.request.filters:null,xe]),_e=JSON.stringify([y(F),ge.filters,xe,g,L,m]),Re=JSON.stringify([_e,ne?C||"fit":0]);return{mode:"engine",asked:A,key:Re,rowsKey:_e,baseKey:je,cap:L,bbox:t,box:M,cellSize:C,run:async G=>{const se=G?{signal:G}:{},le=await F.aggregate({...ge,...se},[{id:I,col:i,fn:"count"}]);if(le&&Array.isArray(le.client)&&le.client.length)return{map:!0,refused:`the source counted client-side (${le.client[0].reason})`};const ae=Number(le&&le.values?le.values[I]:NaN);if(!Number.isFinite(ae))return{map:!0,refused:"the engine did not report a count for the view"};if(ae<=L){const Ae={...ge,range:{start:0,end:L}},Ee=q(Ae,b).pushed,Te=await e.execute({...Ee,...se},{...Ae,...se});return{map:!0,kind:"rows",rows:(Te&&Array.isArray(Te.rows)?Te.rows:[]).slice(0,L),count:ae,cap:L,bbox:t,rowsKey:_e}}if(!ne)return{map:!0,kind:"over",count:ae,cap:L,bbox:t,reason:ue};let de=C||re(360),we=[];for(let Ae=1;;Ae++){const Ee=await F.aggregate({...ge,groupBy:[{col:g.column,bucket:"grid",size:de}],...se},[{id:I,col:i,fn:"count"}]);if(Ee&&Array.isArray(Ee.client)&&Ee.client.length)return{map:!0,kind:"over",count:ae,cap:L,bbox:t,reason:`the source binned client-side (${Ee.client[0].reason})`};we=[];for(const Ie of Ee&&Ee.groups||[]){if(!Ie||Ie.level!==1||!Array.isArray(Ie.keys)||!Array.isArray(Ie.keys[0]))continue;const[Ke,Be]=Ie.keys[0].map(Number),ze=Number(Ie.values?Ie.values[I]:NaN);!Number.isFinite(Ke)||!Number.isFinite(Be)||!(ze>0)||we.push({west:Ke*de,south:Be*de,east:(Ke+1)*de,north:(Be+1)*de,count:ze})}if(C||Ae>=k)break;const Te=H(V([],we));if(!Te)break;const Ge=re(ee(Te));if(Ge>=de)break;de=Ge}return{map:!0,kind:"density",cells:we,count:ae,cap:L,bbox:t,size:de}}}}function E(d,u){const m=typeof d.config=="function"?d.config():{},O=m&&typeof m.rowKey=="string"?m.rowKey:null,A=d.permissions&&typeof d.permissions.levelOf=="function"?d.permissions:null,w=new Map,g=u.map((F,b)=>{const e=O&&F&&F[O]!==void 0&&F[O]!==null?F[O]:`engine:${b}`,i=w.has(e)?`engine:${b}`:e,n={key:i,data:F,group:!1};return w.set(i,n),n}),f=F=>{if(!A)return!0;const b=A.levelOf(F);return b==="read"||b==="write"},v=(F,b)=>{const e=w.get(F);if(!e||!f(b))return;const i=d.columns.get(b),n=i&&typeof i.field=="string"?i.field:b,t=e.data?e.data[n]:void 0,r=i&&i.dataType;if(r&&typeof r.toStorage=="function"&&t!==null&&t!==void 0)try{return r.toStorage(t,{colId:b})}catch{return null}return t};return{columns:d.columns,formatting:d.formatting,messages:d.messages,rows:{count:()=>g.length,get:F=>g[F],value:v,text:(F,b)=>{const e=v(F,b);if(e==null)return"";const i=d.columns.get(b);if(i&&typeof i.formatValue=="function")try{const n=i.formatValue(e,w.get(F));if(typeof n=="string")return n}catch{}return String(e)}}}}function V(d,u=[]){let m=1/0,O=1/0,A=-1/0,w=-1/0;for(const e of d||[])!Number.isFinite(e.lon)||!Number.isFinite(e.lat)||(m=Math.min(m,e.lon),A=Math.max(A,e.lon),O=Math.min(O,e.lat),w=Math.max(w,e.lat));for(const e of u||[])m=Math.min(m,e.west),A=Math.max(A,e.east),O=Math.min(O,e.south),w=Math.max(w,e.north);if(!(A>=m)||!(w>=O))return null;const g=(e,i)=>Math.max(-i,Math.min(i,e)),f=g(m,180),v=g(A,180),F=g(O,90),b=g(w,90);return[[[f,F],[v,F],[v,b],[f,b]]]}function h(d,u){if(!u)return!0;const[m,O,A,w]=u,g=(f,v)=>f>=m&&f<=A&&v>=O&&v<=w;if(d.point)return g(d.point[0],d.point[1]);for(const f of d.polygons||[])for(const v of f)for(const[F,b]of v)if(g(F,b))return!0;return!1}function a(d,u,m,O){const A=Y(m),w=O&&Array.isArray(O.bbox)?O.bbox:null;if(!u||!p.has(d))return{bound:u,viewport:null};if(d==="choropleth"){const l=u.features||[];if(l.length<=A)return{bound:u,viewport:null};let L=0;for(const ne of l)h(ne,w)&&L++;if(L<=A)return{bound:u,viewport:null};const M=[];for(const ne of l){ne.point&&M.push({lon:ne.point[0],lat:ne.point[1]});for(const ue of ne.polygons||[])for(const ge of ue)for(const[xe,Ce]of ge)M.push({lon:xe,lat:Ce})}const C="a choropleth draws each shape, and has no density form";return{bound:{...u,features:[],empty:!1,over:{count:L,cap:A,reason:C},frame:u.frame||V(M)},viewport:{rows:0,matched:L,cap:A,binned:!1,cells:0,over:C,bbox:w?[...w]:null,computed:"client"}}}const g=u.points||[];if(g.length<=A)return{bound:u,viewport:null};const[f,v,F,b]=w||[-1/0,-1/0,1/0,1/0],e=g.filter(l=>l.lon>=f&&l.lon<=F&&l.lat>=v&&l.lat<=b);if(e.length<=A)return{bound:u,viewport:null};const i=w||H([e.map(l=>[l.lon,l.lat])]),n=re(i?ee(i):360),t=new Map;for(const l of e){const L=Math.floor(l.lon/n),M=Math.floor(l.lat/n),C=`${L}:${M}`,ne=t.get(C)||{west:L*n,south:M*n,east:(L+1)*n,north:(M+1)*n,count:0};ne.count++,t.set(C,ne)}const r=[...t.values()];return{bound:{...u,density:{cells:r,size:n},frame:u.frame||V(g)},viewport:{rows:0,matched:e.length,cap:A,binned:!0,cells:r.length,over:null,bbox:w?[...w]:null,computed:"client"}}}}),Qe("packages/modules/charts/rampscale.js",function(o,X){"use strict";Object.defineProperty(o,"AUTO_LOG_RATIO",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"QUANTILE_CLASSES",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"chooseRampScale",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"logTicks",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"quantileCuts",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"placeOnRamp",{enumerable:!0,get:function(){return W}});const ye=100,q=5;function j(ie){const S=[];for(const y of ie||[])typeof y=="number"&&Number.isFinite(y)&&y>0&&S.push(y);return S}function be(ie,S){const y=j(ie);let U=1/0,D=0;for(const B of y)B<U&&(U=B),B>D&&(D=B);const T=y.length?D/U:0;return S?{scale:S,auto:!1,ratio:T}:T>ye?{scale:"log",auto:!0,ratio:T}:{scale:"linear",auto:!1,ratio:T}}function me(ie){return Number(ie.toPrecision(12))}function te(ie,S){if(!(ie>0)||!(S>=ie)||!Number.isFinite(S))return[];const y=_=>_>=ie*(1-1e-9)&&_<=S*(1+1e-9),U=Math.floor(Math.log10(ie)+1e-9),D=Math.floor(Math.log10(S)+1e-9),T=[],B=Math.log10(S/ie);for(let _=U;_<=D;_++){const $=B>=2?[1]:[1,2,5];for(const p of $){const s=me(p*10**_);y(s)&&T.push(s)}}return T}function J(ie,S=q){const y=[];for(const D of ie||[])typeof D=="number"&&Number.isFinite(D)&&y.push(D);if(!y.length)return[];y.sort((D,T)=>D-T);const U=[];for(let D=1;D<S;D++){const T=(y.length-1)*(D/S),B=Math.floor(T),_=Math.min(y.length-1,B+1);U.push(me(y[B]+(T-B)*(y[_]-y[B])))}return U}function W(ie,S,y){if(ie==="log"){let D=j(y);D.length||(D=j([S.min,S.max]));let T=1/0,B=0;for(const s of D)s<T&&(T=s),s>B&&(B=s);D.length||(T=1,B=1);const _=Math.log10(T),$=Math.log10(B)-_||1,p=s=>typeof s!="number"||!Number.isFinite(s)||s<=0?0:Math.min(1,Math.max(0,(Math.log10(s)-_)/$));return{position:p,domain:{min:T,max:B},ticks:te(T,B).map(s=>({value:s,t:p(s)})),classes:0}}if(ie==="quantile"){const D=J(y),T=D.length+1;let B=1/0,_=-1/0;for(const p of y||[])typeof p!="number"||!Number.isFinite(p)||(p<B&&(B=p),p>_&&(_=p));return B>_&&(B=S.min,_=S.max),{position:p=>{if(typeof p!="number"||!Number.isFinite(p))return 0;let s=0;for(;s<D.length&&p>=D[s];)s++;return T>1?s/(T-1):0},domain:{min:B,max:_},ticks:D.map((p,s)=>({value:p,t:(s+1)/T})),classes:T}}const U=S.max-S.min||1;return{position:D=>(D-S.min)/U,domain:{min:S.min,max:S.max},ticks:[],classes:0}}}),Qe("packages/modules/charts/matrix.js",function(o,X){"use strict";Object.defineProperty(o,"colourRamp",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"drawHeatmap",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"drawFunnel",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"drawCandlestick",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"VOLUME_PANE_HEIGHT",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"splitPanes",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"clearVolumePane",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"drawCorrelogram",{enumerable:!0,get:function(){return je}}),Object.defineProperty(o,"title",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(o,"cellAt",{enumerable:!0,get:function(){return fe}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/axis.js"),be=j.drawAxisLines,me=j.drawBandLabels,te=j.drawCategoryAxis,J=j.drawContinuousAxis,W=j.drawMeasureAxis,ie=j.leftLabelRoom,S=j.overhangFor,y=j.setLabelText,U=j.setPlotClip,D=X("packages/modules/charts/cartesian.js"),T=D.continuousSlot,B=D.slotPadFor,_=D.xScaleFor,$=X("packages/modules/charts/format.js"),p=$.formatters,s=$.measureText,c=X("packages/modules/charts/scale.js"),k=c.bandScale,R=c.isNumber,I=c.linearTicks,z=c.measureDomain,Y=c.toNumber,re=c.toTime,ee=X("packages/modules/charts/svg.js"),H=ee.attrs,pe=ee.path,x=ee.round,Q=ee.setText,ce=ee.SVG_NS,V=X("packages/modules/charts/typography.js").applySize,a=X("packages/modules/charts/styles.js").NS,d=X("packages/modules/charts/scheme.js"),u=d.rampStops,m=d.resolveScheme,O=X("packages/modules/charts/rampscale.js"),A=O.chooseRampScale,w=O.placeOnRamp,f=X("packages/core/src/internal/util.js").warnOnce,v=X("packages/modules/charts/labels.js"),F=v.drawAnchoredLabels,b=v.labelText,e=Object.freeze([[236,243,249],[0,82,128]]),i=Object.freeze([[176,74,0],[247,247,247],[0,82,128]]);function n(G,se,le){const ae=Math.min(1,Math.max(0,le)),de=we=>Math.round(G[we]+(se[we]-G[we])*ae);return`rgb(${de(0)} ${de(1)} ${de(2)})`}function t(G,se,le,ae){const de=le?u(le,se):se?i:e,we=le&&le.rampScale?le.rampScale:null;if(se){we&&we!=="linear"&&f("chart:ramp:diverging-scale",`chart "ramp.scale" was "${we}" on a diverging ramp, which is always linear and centred on zero; the scale was not applied. Drop "diverging" to colour by a log or quantile scale.`);const Be=Math.max(Math.abs(G.min),Math.abs(G.max))||1,ze=ot=>ot>=0?n(de[1],de[2],ot/Be):n(de[1],de[0],-ot/Be),qe=G.max-G.min||1;return Object.assign(ze,{scale:"linear",auto:!1,ratio:0,position:ot=>(ot-G.min)/qe,colourAt:ot=>ze(G.min+ot*qe),domain:{min:G.min,max:G.max},ticks:[],classes:0})}const Ae=A(ae||[G.min,G.max],we),Ee=w(Ae.scale,G,ae||[G.min,G.max]),Te=de[0],Ge=de[de.length-1],Ie=Be=>n(Te,Ge,Be);return Object.assign(Be=>Ie(Ee.position(Be)),{scale:Ae.scale,auto:Ae.auto,ratio:Ae.ratio,position:Ee.position,colourAt:Ie,domain:Ee.domain,ticks:Ee.ticks,classes:Ee.classes})}function r(G){const se=G.scheme||m(),{plot:le,bound:ae}=G;new q(G.groups.grid).finish(),new q(G.groups.axis).finish(),new q(G.groups.rules).finish(),new q(G.groups.labels).finish();const de=ae.series.filter(Ke=>!G.hidden.has(Ke.key)),we=[];for(const Ke of de)for(const Be of Ke.points)we.push(Be.y);const Ae=z(we,{zero:!1,nice:!1}),Ee=t(Ae,!!G.diverging,se,we),Te=k(ae.categories,[le.left,le.right],.04),Ge=k(de.map(Ke=>Ke.label),[le.top,le.bottom],.04),Ie=new q(G.groups.marks);for(const Ke of de){const Be=Ge.of(Ke.label);if(!Number.isNaN(Be))for(let ze=0;ze<Ke.points.length;ze++){const qe=Ke.points[ze],ot=Te.of(qe.x);if(Number.isNaN(ot))continue;const Ot=Ie.next("rect",`${a}__cell ${a}__mark`);H(Ot,{x:x(ot),y:x(Be),width:x(Te.bandwidth),height:x(Ge.bandwidth),fill:R(qe.y)?Ee(qe.y):"transparent","data-series":Ke.index,"data-point":ze}),qe.px=x(ot+Te.bandwidth/2),qe.py=x(Be+Ge.bandwidth/2)}}if(Ie.finish(),te({group:G.groups.overlay,plot:le,scale:Te,labels:ae.labels,fontSize:G.fontSize,rotated:ae.labels.length>6,config:G.axis&&G.axis.x||{}}),me({group:G.groups.axis,plot:le,scale:Ge,labels:de.map(Ke=>Ke.label),fontSize:G.fontSize,config:G.axis&&G.axis.y||{}}),G.labels&&G.labels.show){const Ke=G.typography&&G.typography.small||G.fontSize||11,Be=[];for(const ze of de)for(const qe of ze.points)qe.px===void 0||!R(qe.y)||Be.push({x:qe.px,y:qe.py,text:b(qe.y,G.labels,G.grid),inside:!0,width:Te.bandwidth-4,height:Ge.bandwidth-2});F({group:G.groups.labels,size:Ke,minGap:0,anchors:Be})}return{xScale:Te,yScale:Ge,series:de,ramp:Ee,domain:Ae}}function l(G){const se=G.scheme||m(),{plot:le,bound:ae}=G;new q(G.groups.grid).finish(),new q(G.groups.axis).finish(),new q(G.groups.rules).finish(),new q(G.groups.labels).finish();const de=ae.series[0],we=de?de.points.map((Be,ze)=>({point:Be,label:ae.labels[ze],value:R(Be.y)?Be.y:0})).filter(Be=>Be.value>0):[];if(!we.length)return{stages:we};let Ae=0;for(let Be=0;Be<we.length;Be++)we[Be].value>Ae&&(Ae=we[Be].value);const Ee=le.height/we.length,Te=le.left+le.width/2,Ge=le.width*.62,Ie=new q(G.groups.marks);we.forEach((Be,ze)=>{const qe=we[ze+1],ot=le.top+ze*Ee,Ot=Be.value/Ae*Ge/2,St=(qe?qe.value:Be.value)/Ae*Ge/2;H(Ie.next("path",`${a}__funnel ${a}__mark`),{d:pe(["M",x(Te-Ot),x(ot),"L",x(Te+Ot),x(ot),"L",x(Te+St),x(ot+Ee-2),"L",x(Te-St),x(ot+Ee-2),"Z"]),fill:se.series(ze),"data-point":ze}),Be.point.px=x(Te),Be.point.py=x(ot+Ee/2)}),Ie.finish();const Ke=new q(G.groups.overlay);return we.forEach((Be,ze)=>{const qe=le.top+ze*Ee,ot=Ke.next("text",`${a}__funnel-label`);H(ot,{x:x(le.left+4),y:x(qe+Ee/2),"text-anchor":"start","dominant-baseline":"middle"}),Q(ot,Be.label);const Ot=Ke.next("text",`${a}__funnel-value`);H(Ot,{x:x(le.right-4),y:x(qe+Ee/2),"text-anchor":"end","dominant-baseline":"middle"});const St=ze===0?1:Be.value/we[ze-1].value,zt=G.labels&&G.labels.show?b(Be.value,G.labels,G.grid):s(Be.value,G.grid.messages);Q(Ot,ze===0?zt:`${zt} · ${Math.round(St*100)}%`)}),Ke.finish(),{stages:we}}function L(G){const se=G.scheme||m(),{bound:le}=G,[ae,de,we,Ae]=le.series;if(!ae||!de||!we||!Ae)return ue(G.groups),{xScale:null,yScale:null,series:[]};const Ee=G.volume&&le.series.find((Mt,Lt)=>Lt>=4&&Mt.key===G.volume)||null,Te=Ee?C(G.plot,G.volumeHeight,G.fontSize):null,Ge=Te?Te.price:G.plot,Ie=G.plot,Ke=[];for(const Mt of[de,we])for(const Lt of Mt.points)Ke.push(Lt.y);const Be=le.yDomain||z(Ke,{zero:!1}),ze={...k([],[0,0])},qe=Ce(Be,Ge),ot=G.axis&&G.axis.x||{},Ot=G.axis&&G.axis.y||{},St=_(le,Ie,"candlestick",ot),zt=St.kind==="band",$t=zt?St.bandwidth:T({bound:le,scale:St,config:ot,padding:B("candlestick")});W({gridGroup:G.groups.grid,axisGroup:G.groups.axis,plot:Ge,scale:qe,side:Ot.position==="right"?"right":"left",format:p(G.grid,{kind:"linear",step:(Be.max-Be.min)/5})}),be({group:G.groups.rules,plot:Ge,side:Ot.position==="right"?"right":"left"});const nn=Ee?ge({ctx:G,pane:Te.volume,series:Ee,side:Ot.position==="right"?"right":"left"}):null;if(Ee||ue(G.groups),zt)te({group:G.groups.overlay,plot:Ie,scale:St,labels:le.labels,fontSize:G.fontSize,rotated:le.labels.length>10,config:ot});else{const Mt=le.dimension&&le.dimension.col?G.grid.columns.get(le.dimension.col):void 0;J({group:G.groups.overlay,plot:Ie,scale:St,format:p(G.grid,{kind:le.kind,span:St.domain.max-St.domain.min,step:(St.domain.max-St.domain.min)/5},Mt),config:ot,grid:G.grid,size:G.fontSize})}zt||U(G.groups,Ie,S("candlestick"));const Yt=new q(G.groups.marks);for(let Mt=0;Mt<le.categories.length;Mt++){const Lt=ae.points[Mt],Xt=de.points[Mt],rn=we.points[Mt],et=Ae.points[Mt];if(![Lt,Xt,rn,et].every(Me=>Me&&R(Me.y)))continue;const ht=zt?St.of(le.categories[Mt])+$t/2:xe(St,le.kind,le.categories[Mt]);if(Number.isNaN(ht))continue;const bt=zt?ht-$t/2:Math.max(Ie.left,ht-$t/2),Ct=zt?ht+$t/2:Math.min(Ie.right,ht+$t/2),Dt=bt,Ft=Math.max(1,Ct-bt),Ut=et.y>=Lt.y,Jt=Ut?se.positive:se.negative;H(Yt.next("path",`${a}__wick ${a}__mark`),{d:pe(["M",x(ht),x(qe.of(Xt.y)),"L",x(ht),x(qe.of(rn.y))]),stroke:Jt,fill:"none"});const Z=qe.of(Math.max(Lt.y,et.y)),Oe=qe.of(Math.min(Lt.y,et.y));H(Yt.next("rect",`${a}__candle ${a}__mark`),{x:x(Dt),y:x(Z),width:x(Ft),height:x(Math.max(1,Oe-Z)),fill:Ut?"transparent":Jt,stroke:Jt,"data-point":Mt}),et.px=x(ht),et.py=x(Z);const ke=Ee?Ee.points[Mt]:null;if(ke&&R(ke.y)){const Me=nn.of(Math.max(nn.domain.min,0)),Ne=nn.of(ke.y);H(Yt.next("rect",`${a}__volume ${a}__mark`),{x:x(Dt),y:x(Math.min(Me,Ne)),width:x(Ft),height:x(Math.abs(Me-Ne)),fill:Jt,"data-point":Mt,"data-direction":Ut?"up":"down"}),ke.px=x(ht),ke.py=x(Ne)}}Yt.finish();const ln={xScale:St,yScale:qe,series:Ee?[Ae,Ee]:[Ae],candles:le.categories.length};return Ee&&(ln.volumeScale=nn,ln.panes={price:Te.price,volume:Te.volume}),ln}const M=.25;function C(G,se,le){const ae=Number.isFinite(se)&&se>0&&se<1?Number(se):M,de=Math.round(Number.isFinite(le)&&le>0?le:11),we=Math.max(0,G.height-de),Ae=Math.round(we*ae),Ee=we-Ae,Te={...G,bottom:G.top+Ee,height:Ee},Ge={...G,top:G.bottom-Ae,height:Ae};return{price:Te,volume:Ge,gap:de}}function ne(G,se){const le={grid:null,rules:null,axis:null};if(!G)return le;for(const ae of["grid","rules","axis"]){const de=G[ae],we=de&&de.parentNode;if(!we)continue;const Ae=`${a}__pane-${ae}`,Ee=[...we.childNodes||[]];let Te=Ee.find(Ge=>String(Ge.getAttribute&&Ge.getAttribute("class")||"").split(" ").includes(Ae))||null;if(!Te&&se){Te=we.ownerDocument.createElementNS(ce,"g"),Te.setAttribute("class",`${de.getAttribute("class")} ${Ae}`);const Ge=Ee[Ee.indexOf(de)+1]||null;Ge?we.insertBefore(Te,Ge):we.appendChild(Te)}le[ae]=Te}return le}function ue(G){const se=ne(G,!1);for(const le of Object.values(se))le&&new q(le).finish()}function ge(G){const{ctx:se,pane:le,series:ae}=G,de=ne(se.groups,!0),we=ae.points.map(Te=>Te&&Te.y).filter(R),Ae=z(we,{zero:!0,ticks:2}),Ee={...Ce(Ae,le),ticks(Te=2){return I(Ae,Te)}};return W({gridGroup:de.grid,axisGroup:de.axis,plot:le,scale:Ee,side:G.side,config:{ticks:2},format:p(se.grid,{kind:"linear",step:(Ae.max-Ae.min)/2})}),be({group:de.rules,plot:le,side:G.side}),Ee}function xe(G,se,le){const ae=se==="time"?re(le):Y(le);return ae===null?NaN:G.of(ae)}function Ce(G,se){const le=G.max-G.min||1,ae=se.top-se.bottom;return{kind:"linear",domain:G,range:[se.bottom,se.top],of(de){return se.bottom+(de-G.min)/le*ae},invert(de){return G.min+(de-se.bottom)/ae*le},ticks(de=5){const we=[];for(let Ae=0;Ae<=de;Ae++)we.push(G.min+le*Ae/de);return we}}}function je(G){const se=G.scheme||m(),{plot:le}=G;new q(G.groups.grid).finish(),new q(G.groups.rules).finish(),new q(G.groups.labels).finish();const ae=G.columns||[];if(ae.length<2)return null;const de=G.grid&&G.grid.statistics;if(!de)return null;const we=G.method==="spearman"?"spearman":G.method==="kendall"?"kendall":"correlation",Ae=[];for(let ze=0;ze<ae.length;ze++)for(let qe=0;qe<ae.length;qe++){const ot=ze===qe?1:de[we](ae[ze],ae[qe]);Ae.push({row:ze,col:qe,a:ae[ze],b:ae[qe],r:ot})}const Ee=ae.length,Te=le.width/Ee,Ge=le.height/Ee,Ie=new q(G.groups.marks);for(const ze of Ae){const qe=le.left+ze.col*Te,ot=le.top+ze.row*Ge;ze.x=qe,ze.y=ot,ze.width=Te,ze.height=Ge;const Ot=Ie.next("rect",`${a}__cell ${a}__mark`);H(Ot,{x:x(qe),y:x(ot),width:x(Math.max(0,Te-1)),height:x(Math.max(0,Ge-1)),fill:ze.row===ze.col||ze.r===null?"var(--lattice-chart-empty, #eceff1)":_e(ze.r,se),"data-row":ze.row,"data-col":ze.col}),ze.element=Ot}Ie.finish();const Ke=new q(G.groups.overlay),Be=ie(le);for(let ze=0;ze<Ee;ze++){const qe=Ke.next("text",`${a}__tick`);V(qe,G.fontSize),H(qe,{x:x(le.left-4),y:x(le.top+ze*Ge+Ge/2),"text-anchor":"end","dominant-baseline":"middle"}),y(qe,Re(G.grid,ae[ze]),Be,G.fontSize);const ot=Ke.next("text",`${a}__tick`);V(ot,G.fontSize),H(ot,{x:x(le.left+ze*Te+Te/2),y:x(le.top-4),"text-anchor":"middle"}),y(ot,Re(G.grid,ae[ze]),Te,G.fontSize)}if(G.values!==!1&&Te>G.fontSize*2.6&&Ge>G.fontSize*1.5)for(const ze of Ae){if(ze.row===ze.col||ze.r===null)continue;const qe=Ke.next("text",`${a}__data-label`);V(qe,G.fontSize),H(qe,{x:x(le.left+ze.col*Te+Te/2),y:x(le.top+ze.row*Ge+Ge/2),"text-anchor":"middle","dominant-baseline":"middle","data-inside":"true"}),Q(qe,ze.r.toFixed(2))}return Ke.finish(),{cells:Ae,columns:ae}}function _e(G,se){const le=Math.min(1,Math.abs(G)),ae=se?u(se,!0):i,de=ae[Math.floor(ae.length/2)],we=G>=0?ae[ae.length-1]:ae[0];return n(de,we,le)}function Re(G,se){const le=G&&G.columns&&typeof G.columns.get=="function"?G.columns.get(se):null;return String(le&&le.title||se)}function fe(G){for(const se of G.cells||[])if(se.x!==void 0&&G.x>=se.x&&G.x<=se.x+se.width&&G.y>=se.y&&G.y<=se.y+se.height)return se;return null}}),Qe("packages/modules/charts/mapdensity.js",function(o,X){"use strict";Object.defineProperty(o,"drawDensityCells",{enumerable:!0,get:function(){return y}});const ye=X("packages/modules/charts/svg.js"),q=ye.attrs,j=ye.path,be=ye.round,te=X("packages/modules/charts/scale.js").measureDomain,W=X("packages/modules/charts/matrix.js").colourRamp,S=X("packages/modules/charts/styles.js").NS;function y(U){const{pool:D,cells:T,to:B,plot:_,scheme:$}=U;let p=0;for(const I of T)I.count>p&&(p=I.count);const s=te([0,p],{zero:!0}),c=W(s,!1,$,T.map(I=>I.count)),k=(I,z)=>{const[Y,re]=B(I,z);return!Number.isFinite(Y)||!Number.isFinite(re)?null:[Math.min(Math.max(Y,_.left),_.right),Math.min(Math.max(re,_.top),_.bottom)]};let R=0;for(const I of T){const z=[k(I.west,I.south),k(I.east,I.south),k(I.east,I.north),k(I.west,I.north)];if(z.some(H=>H===null))continue;const Y=z.map(H=>H[0]),re=z.map(H=>H[1]);if(Math.max(...Y)-Math.min(...Y)<.5||Math.max(...re)-Math.min(...re)<.5)continue;const ee=[];z.forEach((H,pe)=>ee.push(pe?"L":"M",be(H[0]),be(H[1]))),ee.push("Z"),q(D.next("path",`${S}__density-cell ${S}__mark`),{d:j(ee),fill:c(I.count),stroke:"none","data-count":I.count,class:`${S}__density-cell ${S}__mark`}),R++}return{cells:R,maxCount:p,domain:s,ramp:c}}}),Qe("packages/modules/charts/radial.js",function(o,X){"use strict";Object.defineProperty(o,"horizontalRoom",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"arcPath",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"layoutRings",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"drawRadial",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"arcAt",{enumerable:!0,get:function(){return u}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/svg.js"),be=j.attrs,me=j.path,te=j.round,J=j.setText,ie=X("packages/modules/charts/styles.js").NS,y=X("packages/modules/charts/scheme.js").resolveScheme,U=X("packages/modules/charts/labels.js"),D=U.drawAnchoredLabels,T=U.labelText,B=X("packages/modules/charts/typography.js"),_=B.applySize,$=B.textWidth,p=B.truncateTo,c=X("packages/modules/charts/format.js").measureFormat,k=Math.PI*2,R=-Math.PI/2,I=.25,z=2,Y=3,re=.58,ee=8,H=2;function pe(m,O,A,w){return m==="total"?c(O,A,w):typeof m=="number"?c(m,A,w):m==null?"":String(m)}function x(m,O,A){if(!m||A<=0)return ee;let w=O;for(;w>ee&&$(m,w)>A;)w-=1;return Math.max(ee,w)}function Q(m,O,A,w){const g=A*Math.SQRT2-4;if(g<=0||!m&&!O)return null;let f=x(m,Math.min(g,w*(O?1.6:2.2)),g),v=O?x(O,Math.min(g,f*.55),g):0;const F=O?H:0;for(;f+F+v>g&&(f>ee||v>ee);)f>ee&&(f-=1),O&&v>ee&&(v-=1);const b=$(m,f)>g?p(m,g,f):m,e=O&&$(O,v)>g?p(O,g,v):O;return{value:b,valueSize:f,label:e||"",labelSize:v,gap:F,height:f+F+v}}function ce(m,O){const{cx:A,cy:w,hole:g,centre:f,total:v,column:F,grid:b,baseSize:e}=O,i=pe(f.value,v,F,b),n=f.label?String(f.label):"",t=Q(i,n,g,e);if(!t)return;const r=t.label?w-t.height/2+t.valueSize/2:w;if(t.value){const l=m.next("text",`${ie}__donut-centre-value`);be(l,{x:te(A),y:te(r),"dominant-baseline":"middle"}),_(l,t.valueSize),J(l,t.value)}if(t.label){const l=m.next("text",`${ie}__donut-centre-label`);be(l,{x:te(A),y:te(r+t.valueSize/2+t.gap+t.labelSize/2),"dominant-baseline":"middle"}),_(l,t.labelSize),J(l,t.label)}}function E(m,O,A,w){return[m+A*Math.cos(w),O+A*Math.sin(w)]}function V(m,O,A){const{inner:w,outer:g,from:f,to:v}=m;if(A*A>=g*g)return 0;const F=Math.sqrt(g*g-A*A);let b=O+F,e=F-O;if(w>0&&A*A<w*w){const i=Math.sqrt(w*w-A*A);if(O>=i)b=Math.min(b,O-i);else if(O<=-i)e=Math.min(e,-i-O);else return 0}if(v-f<k-1e-9)for(const i of[f,v]){const n=Math.sin(i);if(Math.abs(n)<1e-9)continue;const t=A/n;if(t<=0)continue;const r=t*Math.cos(i);r>=O?e=Math.min(e,r-O):b=Math.min(b,O-r)}return Math.max(0,b)+Math.max(0,e)}function h(m){const{cx:O,cy:A,inner:w,outer:g}=m,f=m.to-m.from;if(f<=0)return"";if(f>=k-1e-9){const[t,r]=E(O,A,g,m.from),[l,L]=E(O,A,g,m.from+Math.PI),M=["M",te(t),te(r),"A",te(g),te(g),0,1,1,te(l),te(L),"A",te(g),te(g),0,1,1,te(t),te(r)];if(w>0){const[C,ne]=E(O,A,w,m.from),[ue,ge]=E(O,A,w,m.from+Math.PI);M.push("M",te(C),te(ne),"A",te(w),te(w),0,1,0,te(ue),te(ge),"A",te(w),te(w),0,1,0,te(C),te(ne))}return me(M)}const v=f>Math.PI?1:0,[F,b]=E(O,A,g,m.from),[e,i]=E(O,A,g,m.to),n=["M",te(F),te(b),"A",te(g),te(g),0,v,1,te(e),te(i)];if(w>0){const[t,r]=E(O,A,w,m.to),[l,L]=E(O,A,w,m.from);n.push("L",te(t),te(r)),n.push("A",te(w),te(w),0,v,0,te(l),te(L))}else n.push("L",te(O),te(A));return n.push("Z"),me(n)}function a(m){const O=[],A=(w,g,f,v,F,b)=>{if(v>0&&O.push({node:w,from:g,to:f,depth:v,index:F,label:w.label,total:w.total,path:b}),v>=m.maxRings||!w.children.length)return;const e=w.children.reduce((t,r)=>t+r.total,0),i=f-g;if(e<=0||i<=0)return;let n=g;for(let t=0;t<w.children.length;t++){const r=w.children[t],l=r.total/e*i;A(r,n,n+l,v+1,v===0?t:F,[...b,r.label]),n+=l}};return A(m.root,R,R+k,0,0,[]),O}function d(m){const O=m.scheme||y(),{plot:A,tree:w,type:g}=m,f=A.left+A.width/2,v=A.top+A.height/2,F=Math.max(0,Math.min(A.width,A.height)/2-2),b=g==="sunburst"?Math.max(1,w.depth):1,e=a({root:w.root,depth:w.depth,maxRings:b}).filter(C=>!m.hidden.has(C.label)),i=g==="donut"?F*re:0,n=b>0?(F-i)/b:F;new q(m.groups.grid).finish(),new q(m.groups.axis).finish(),new q(m.groups.rules).finish(),new q(m.groups.labels).finish();const t=w.root.children.map(C=>C.label),r=new q(m.groups.marks);for(const C of e){const ne=i+(C.depth-1)*n,ue=ne+n,ge=r.next("path",`${ie}__slice ${ie}__mark`);be(ge,{d:h({cx:f,cy:v,inner:ne,outer:ue,from:C.from,to:C.to}),fill:O.series(C.index,t[C.index]),"fill-opacity":C.depth>1?Math.max(.45,1-(C.depth-1)*.22):1,"data-arc":e.indexOf(C)}),C.geometry={cx:f,cy:v,inner:ne,outer:ue}}r.finish();const l=m.typography&&m.typography.small||m.fontSize||11,L=!(m.labels&&m.labels.names===!1),M=new q(m.groups.overlay);if(L)for(const C of e){if(C.to-C.from<I||C.geometry.outer-C.geometry.inner<l+z*2)continue;const ne=(C.from+C.to)/2,ue=C.geometry.inner+(C.geometry.outer-C.geometry.inner)/2;if((C.to-C.from)*ue<l+z*2)continue;const[ge,xe]=E(f,v,ue,ne),{inner:Ce,outer:je}=C.geometry,_e=V({inner:Ce,outer:je,from:C.from,to:C.to},ge-f,xe-v)-z*2,Re=String(C.label===null||C.label===void 0?"":C.label),fe=p(Re,_e,l);if(fe!==Re&&fe.length<Y)continue;const G=M.next("text",`${ie}__slice-label`);be(G,{x:te(ge),y:te(xe),"dominant-baseline":"middle"}),_(G,l),J(G,fe)}if(g==="donut"&&m.centre&&i>0){const C=m.grid&&m.grid.columns&&w.measure&&w.measure.col?m.grid.columns.get(w.measure.col):null;ce(M,{cx:f,cy:v,hole:i,centre:m.centre,total:e.filter(ne=>ne.depth===1).reduce((ne,ue)=>ne+ue.total,0),column:C,grid:m.grid,baseSize:l})}return M.finish(),m.labels&&m.labels.show&&D({group:m.groups.labels,size:l,minGap:m.labels.minGap,anchors:e.filter(C=>C.depth===1&&C.to-C.from>=I).map(C=>{const ne=(C.from+C.to)/2,ue=C.geometry.inner+(C.geometry.outer-C.geometry.inner)/2,[ge,xe]=E(f,v,ue,ne);return{x:te(ge),y:te(xe+l+1),text:T(C.total,m.labels,m.grid),inside:!0}})}),{arcs:e,centre:{x:f,y:v,r:F}}}function u(m){for(const O of m.arcs){const A=O.geometry;if(!A)continue;const w=m.x-A.cx,g=m.y-A.cy,f=Math.sqrt(w*w+g*g);if(f<A.inner||f>A.outer)continue;let v=Math.atan2(g,w);for(;v<R;)v+=k;for(;v>=R+k;)v-=k;if(v>=O.from&&v<O.to)return O}return null}}),Qe("packages/modules/charts/distribution.js",function(o,X){"use strict";Object.defineProperty(o,"FENCE",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"quantile",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"summarise",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"binEdge",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"outsideDomain",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"histogram",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"readingsOf",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"valuesByCategory",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"allReadings",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"distributionDomain",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"density",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"drawHistogram",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"drawBoxPlot",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"probit",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"drawQQ",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"drawEcdf",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"drawLorenz",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"drawControl",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"drawCapability",{enumerable:!0,get:function(){return e}}),Object.defineProperty(o,"drawMovingRange",{enumerable:!0,get:function(){return i}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/axis.js"),be=j.drawAxisLines,me=j.drawCategoryAxis,te=j.drawContinuousAxis,J=j.drawMeasureAxis,W=j.tickLabeller,S=X("packages/modules/charts/format.js").formatters,y=X("packages/modules/charts/scale.js"),U=y.bandScale,D=y.isNumber,T=y.linearScale,B=y.measureDomain,_=y.niceStep,$=X("packages/modules/charts/svg.js"),p=$.attrs,s=$.path,c=$.round,R=X("packages/modules/charts/styles.js").NS,z=X("packages/modules/charts/scheme.js").resolveScheme,Y=X("packages/modules/charts/labels.js"),re=Y.drawAnchoredLabels,ee=Y.labelText,H=1.5,pe="–";function x(n,t){const r=n.length;if(!r)return NaN;if(r===1)return n[0];const l=(r-1)*Math.min(1,Math.max(0,t)),L=Math.floor(l),M=Math.ceil(l);return L===M?n[L]:n[L]+(l-L)*(n[M]-n[L])}function Q(n){const t=n.filter(D).slice().sort((xe,Ce)=>xe-Ce);if(!t.length)return null;const r=x(t,.25),l=x(t,.5),L=x(t,.75),M=L-r,C=r-H*M,ne=L+H*M;let ue=t[0];for(const xe of t)if(xe>=C){ue=xe;break}let ge=t[t.length-1];for(let xe=t.length-1;xe>=0;xe--)if(t[xe]<=ne){ge=t[xe];break}return{min:t[0],q1:r,median:l,q3:L,max:t[t.length-1],low:ue,high:ge,outliers:t.filter(xe=>xe<C||xe>ne),count:t.length}}function ce(n,t,r){const l=n+r*t;return Math.abs(l)<t/1e6?0:Number(l.toPrecision(12))}function E(n,t){const r=t||{},l=D(r.min),L=D(r.max);if(!l&&!L)return 0;let M=0;for(let C=0;C<n.length;C++){const ne=n[C];D(ne)&&(l&&ne<r.min||L&&ne>r.max)&&M++}return M}function V(n,t=12,r){const l=r||{},L=D(l.min),M=D(l.max);let C=1/0,ne=-1/0,ue=0;for(let Re=0;Re<n.length;Re++){const fe=n[Re];D(fe)&&(L&&fe<l.min||M&&fe>l.max||(fe<C&&(C=fe),fe>ne&&(ne=fe),ue++))}if(!ue)return[];if(L&&(C=Number(l.min)),M&&(ne=Number(l.max)),C===ne){const Re=Math.abs(C)>0?Math.abs(C)/10:.5;C-=Re,ne+=Re}const ge=_((ne-C)/Math.max(1,t)),xe=Math.floor(C/ge)*ge,Ce=Math.ceil(ne/ge)*ge,je=[],_e=Math.max(1,Math.round((Ce-xe)/ge));for(let Re=0;Re<_e;Re++)je.push({from:ce(xe,ge,Re),to:ce(xe,ge,Re+1),count:0});for(let Re=0;Re<n.length;Re++){const fe=n[Re];if(!D(fe)||L&&fe<l.min||M&&fe>l.max)continue;let G=Math.floor((fe-xe)/ge);G>=je.length&&(G=je.length-1),G<0&&(G=0),je[G].count++}return je}function h(n){if(!n)return[];if(Array.isArray(n.values)){const t=n.values.filter(D);if(t.length)return t}return D(n.y)?[n.y]:[]}function a(n){const t=new Map,r=!(n.dimension&&n.dimension.col),l=r&&n.measure&&n.measure.title||"";for(const L of n.series)for(const M of L.points){const C=h(M);if(!C.length)continue;const ne=r?l:M.label;t.has(ne)||t.set(ne,[]);const ue=t.get(ne);for(const ge of C)ue.push(ge)}return t}function d(n){const t=[];for(const r of n.series||[])for(const l of r.points||[])for(const L of h(l))t.push(L);return t}function u(n,t){const r=t&&t.y||{};return B(n,{zero:!1,min:r.min,max:r.max})}function m(n,t,r){const l=n.length;if(!l)return[];const L=n.reduce((xe,Ce)=>xe+Ce,0)/l,M=n.reduce((xe,Ce)=>xe+(Ce-L)**2,0)/Math.max(1,l-1),C=Math.sqrt(M)||1,ne=Math.max(1e-9,1.06*C*l**(-1/5)),ue=[],ge=t.max-t.min||1;for(let xe=0;xe<r;xe++){const Ce=t.min+ge*xe/(r-1||1);let je=0;for(const _e of n){const Re=(Ce-_e)/ne;je+=Math.exp(-.5*Re*Re)}ue.push({at:Ce,density:je/(l*ne*Math.sqrt(Math.PI*2))})}return ue}function O(n,t,r){const l=S(n.grid,{kind:"linear",step:r}),L=t.measure&&t.measure.col&&n.grid.columns?n.grid.columns.get(t.measure.col):null,C=!!(L&&L.format&&typeof L.formatValue=="function")?{tick:ne=>String(L.formatValue(ne,null))}:l;return W(n.axis&&n.axis.x||{},C,n.grid)}function A(n){const t=n.scheme||z(),{plot:r,bound:l}=n,L=d(l),M=n.axis&&n.axis.y||{},C=V(L,n.buckets||12,M),ne=E(L,M),ue=C.map(ae=>ae.count),ge=B(ue,{zero:!0}),xe=T(ge,[r.bottom,r.top]),Ce=C.length?C[0].to-C[0].from:1,je=O(n,l,Ce),_e=C.map(ae=>je(ae.from)),Re=C.map(ae=>`${je(ae.from)} ${pe} ${je(ae.to)}`),fe=C.map((ae,de)=>de),G=U(fe,[r.left,r.right],.08);J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:xe,format:S(n.grid,{kind:"linear",step:(ge.max-ge.min)/5})}),me({group:n.groups.overlay,plot:r,scale:G,labels:_e,fontSize:n.fontSize,rotated:_e.length>8}),be({group:n.groups.rules,plot:r});const se=new q(n.groups.marks),le=xe.of(ge.min<=0?0:ge.min);if(C.forEach((ae,de)=>{const we=xe.of(ae.count);p(se.next("rect",`${R}__bar ${R}__mark`),{x:c(G.of(de)),y:c(Math.min(we,le)),width:c(G.bandwidth),height:c(Math.max(ae.count>0?1:0,Math.abs(le-we))),fill:t.series(0),"data-point":de})}),se.finish(),n.curve&&L.length>1){const ae={min:C[0].from,max:C[C.length-1].to},de=m(L,ae,Math.max(24,C.length*4)),we=de.reduce((Ae,Ee)=>Math.max(Ae,Ee.density),0);if(we>0){const Ae=ae.max-ae.min||1,Ee=xe.of(ge.max),Te=de.map(Ie=>[c(r.left+(Ie.at-ae.min)/Ae*(r.right-r.left)),c(le-Ie.density/we*(le-Ee))]),Ge=new q(n.groups.overlay);p(Ge.next("path",`${R}__density ${R}__mark`),{d:s(Te.flatMap(([Ie,Ke],Be)=>[Be?"L":"M",Ie,Ke])),fill:"none",stroke:t.series(1)}),Ge.finish()}}if(n.labels&&n.labels.show){const ae=n.typography&&n.typography.small||n.fontSize||11;re({group:n.groups.labels,size:ae,minGap:n.labels.minGap,plot:r,anchors:C.map((de,we)=>{const Ae=Math.min(xe.of(de.count),le),Ee=Ae-ae/2-2,Te=Ee<r.top;return{x:c(G.of(we)+G.bandwidth/2),y:c(Te?Ae+ae/2+2:Ee),text:de.count?ee(de.count,n.labels,n.grid):"",inside:Te,height:Te?Math.abs(le-Ae)-2:void 0}})})}return{xScale:G,yScale:xe,buckets:C,labels:Re,categories:C.map(ae=>ae.from),outside:ne,series:[{key:"",label:l.measure.title,index:0,points:C.map((ae,de)=>({x:de,xKey:String(de),label:Re[de],from:ae.from,to:ae.to,y:ae.count,rows:ae.count}))}]}}function w(n){const t=n.scheme||z(),{plot:r,bound:l}=n,L=a(l),M=[...L.keys()],C=M.map(_e=>Q(L.get(_e))).filter(Boolean),ne=[];for(const _e of C)ne.push(_e.min,_e.max);const ue=u(ne,n.axis),ge=T(ue,[r.bottom,r.top]),xe=U(M,[r.left,r.right],.4);J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ge,format:S(n.grid,{kind:"linear",step:(ue.max-ue.min)/5})}),me({group:n.groups.overlay,plot:r,scale:xe,labels:M,fontSize:n.fontSize,rotated:M.length>6}),be({group:n.groups.rules,plot:r});const Ce=new q(n.groups.marks),je=xe.bandwidth;return M.forEach((_e,Re)=>{const fe=C[Re];if(!fe)return;const G=xe.of(_e),se=G+je/2,le=t.series(Re);p(Ce.next("rect",`${R}__box ${R}__mark`),{x:c(G),y:c(ge.of(fe.q3)),width:c(je),height:c(Math.max(1,ge.of(fe.q1)-ge.of(fe.q3))),fill:le,"fill-opacity":.35,stroke:le,"data-point":Re}),p(Ce.next("path",`${R}__whisker ${R}__mark`),{d:s(["M",c(se),c(ge.of(fe.high)),"L",c(se),c(ge.of(fe.q3)),"M",c(se),c(ge.of(fe.q1)),"L",c(se),c(ge.of(fe.low)),"M",c(G+je*.25),c(ge.of(fe.high)),"L",c(G+je*.75),c(ge.of(fe.high)),"M",c(G+je*.25),c(ge.of(fe.low)),"L",c(G+je*.75),c(ge.of(fe.low))]),stroke:le,fill:"none"}),p(Ce.next("path",`${R}__median ${R}__mark`),{d:s(["M",c(G),c(ge.of(fe.median)),"L",c(G+je),c(ge.of(fe.median))]),stroke:le,"stroke-width":2,fill:"none"});for(const ae of fe.outliers)p(Ce.next("circle",`${R}__point ${R}__mark`),{cx:c(se),cy:c(ge.of(ae)),r:2.5,fill:le,"fill-opacity":.8})}),Ce.finish(),{xScale:xe,yScale:ge,boxes:C,series:[{key:"",label:l.measure.title,index:0,points:M.map((_e,Re)=>({x:_e,xKey:_e,label:_e,y:C[Re]?C[Re].median:null,rows:C[Re]?C[Re].count:0}))}]}}function g(n){if(!(n>0&&n<1))return Number.NaN;const t=[-39.69683028665376,220.9460984245205,-275.9285104469687,138.357751867269,-30.66479806614716,2.506628277459239],r=[-54.47609879822406,161.5858368580409,-155.6989798598866,66.80131188771972,-13.28068155288572],l=[-.007784894002430293,-.3223964580411365,-2.400758277161838,-2.549732539343734,4.374664141464968,2.938163982698783],L=[.007784695709041462,.3224671290700398,2.445134137142996,3.754408661907416],M=.02425;if(n<M){const ue=Math.sqrt(-2*Math.log(n));return(((((l[0]*ue+l[1])*ue+l[2])*ue+l[3])*ue+l[4])*ue+l[5])/((((L[0]*ue+L[1])*ue+L[2])*ue+L[3])*ue+1)}if(n>1-M){const ue=Math.sqrt(-2*Math.log(1-n));return-(((((l[0]*ue+l[1])*ue+l[2])*ue+l[3])*ue+l[4])*ue+l[5])/((((L[0]*ue+L[1])*ue+L[2])*ue+L[3])*ue+1)}const C=n-.5,ne=C*C;return(((((t[0]*ne+t[1])*ne+t[2])*ne+t[3])*ne+t[4])*ne+t[5])*C/(((((r[0]*ne+r[1])*ne+r[2])*ne+r[3])*ne+r[4])*ne+1)}function f(n){const t=n.scheme||z(),{plot:r,bound:l}=n;new q(n.groups.grid).finish(),new q(n.groups.axis).finish(),new q(n.groups.rules).finish(),new q(n.groups.labels).finish();const L=d(l);if(L.length<3)return null;const M=L.slice().sort((we,Ae)=>we-Ae),C=M.length,ne=M.map((we,Ae)=>g((Ae+1-.375)/(C+.25))),ue=B(ne,{zero:!1,nice:!0}),ge=B(M,{zero:!1,nice:!0}),xe=T(ue,[r.left,r.right]),Ce=T(ge,[r.bottom,r.top]);J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:Ce,format:S(n.grid,{kind:"linear",step:(ge.max-ge.min)/5})}),te({group:n.groups.overlay,plot:r,scale:xe,fontSize:n.fontSize,format:S(n.grid,{kind:"linear",step:(ue.max-ue.min)/5})}),be({group:n.groups.rules,plot:r});const je=x(M,.25),_e=x(M,.75),Re=g(.25),fe=g(.75),G=(_e-je)/(fe-Re),se=je-G*Re,le=new q(n.groups.rules);p(le.next("path",`${R}__qq-line`),{d:s(["M",c(xe.of(ue.min)),c(Ce.of(se+G*ue.min)),"L",c(xe.of(ue.max)),c(Ce.of(se+G*ue.max))]),fill:"none"}),le.finish();const ae=new q(n.groups.marks),de=[];for(let we=0;we<C;we++){const Ae=c(xe.of(ne[we])),Ee=c(Ce.of(M[we]));p(ae.next("circle",`${R}__point ${R}__mark`),{cx:Ae,cy:Ee,r:2.5,fill:t.series(0),"data-point":we}),de.push({x:Ae,y:Ee,theoretical:ne[we],sample:M[we]})}return ae.finish(),{points:de,line:{slope:G,intercept:se}}}function v(n){const t=n.scheme||z(),{plot:r,bound:l}=n;new q(n.groups.grid).finish(),new q(n.groups.axis).finish(),new q(n.groups.rules).finish(),new q(n.groups.labels).finish();const L=d(l);if(!L.length)return null;const M=L.slice().sort((_e,Re)=>_e-Re),C=M.length,ne=B(M,{zero:!1,nice:!0}),ue=T(ne,[r.left,r.right]),ge=T({min:0,max:1},[r.bottom,r.top]);J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ge,format:S(n.grid,{kind:"linear",step:.2})}),te({group:n.groups.overlay,plot:r,scale:ue,fontSize:n.fontSize,format:S(n.grid,{kind:"linear",step:(ne.max-ne.min)/5})}),be({group:n.groups.rules,plot:r});const xe=["M",c(ue.of(ne.min)),c(ge.of(0))],Ce=[];for(let _e=0;_e<C;_e++){const Re=c(ue.of(M[_e])),fe=(_e+1)/C;xe.push("L",Re,c(ge.of(_e/C)),"L",Re,c(ge.of(fe))),Ce.push({value:M[_e],share:fe})}xe.push("L",c(ue.of(ne.max)),c(ge.of(1)));const je=new q(n.groups.marks);return p(je.next("path",`${R}__ecdf ${R}__mark`),{d:s(xe),fill:"none",stroke:t.series(0)}),je.finish(),{steps:Ce}}function F(n){const t=n.scheme||z(),{plot:r,bound:l}=n;new q(n.groups.grid).finish(),new q(n.groups.axis).finish(),new q(n.groups.rules).finish(),new q(n.groups.labels).finish();const L=d(l).filter(se=>se>=0);if(!L.length)return null;const M=L.slice().sort((se,le)=>se-le),C=M.length,ne=M.reduce((se,le)=>se+le,0);if(ne<=0)return null;const ue=T({min:0,max:1},[r.left,r.right]),ge=T({min:0,max:1},[r.bottom,r.top]);J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ge,format:S(n.grid,{kind:"linear",step:.2})}),te({group:n.groups.overlay,plot:r,scale:ue,fontSize:n.fontSize,format:S(n.grid,{kind:"linear",step:.2})}),be({group:n.groups.rules,plot:r});const xe=new q(n.groups.rules);p(xe.next("path",`${R}__lorenz-equality`),{d:s(["M",c(ue.of(0)),c(ge.of(0)),"L",c(ue.of(1)),c(ge.of(1))]),fill:"none"}),xe.finish();const Ce=["M",c(ue.of(0)),c(ge.of(0))],je=[{rows:0,held:0}];let _e=0;for(let se=0;se<C;se++){_e+=M[se];const le={rows:(se+1)/C,held:_e/ne};Ce.push("L",c(ue.of(le.rows)),c(ge.of(le.held))),je.push(le)}const Re=new q(n.groups.marks);p(Re.next("path",`${R}__lorenz ${R}__mark`),{d:s(Ce),fill:"none",stroke:t.series(0)}),Re.finish();let fe=0;for(let se=0;se<C;se++)fe+=(se+1)*M[se];const G=2*fe/(C*ne)-(C+1)/C;return{curve:je,gini:G}}function b(n){const t=n.scheme||z(),{plot:r,bound:l}=n;new q(n.groups.grid).finish(),new q(n.groups.labels).finish();const L=[];for(const de of l.series)for(const we of de.points)D(we.y)&&L.push(we.y);if(L.length<2)return null;const M=n.capability||null,C=M&&M.limits?M.limits:null,ne=[...L];C&&ne.push(C.upper,C.lower),M&&(M.lower!==null&&ne.push(M.lower),M.upper!==null&&ne.push(M.upper));const ue=B(ne,{zero:!1,nice:!0}),ge=T(ue,[r.bottom,r.top]),xe=L.length>1?(r.right-r.left)/(L.length-1):0;J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ge,format:S(n.grid,{kind:"linear",step:(ue.max-ue.min)/5})}),be({group:n.groups.rules,plot:r});const Ce=new q(n.groups.overlay),je=[],_e=(de,we,Ae,Ee="end")=>{!Number.isFinite(de)||de<ue.min||de>ue.max||(p(Ce.next("path",we),{d:s(["M",c(r.left),c(ge.of(de)),"L",c(r.right),c(ge.of(de))]),fill:"none"}),Ae&&je.push({y:ge.of(de),text:Ae,side:Ee}))};C&&(_e(C.centre,`${R}__control-centre`,"CL","end"),_e(C.upper,`${R}__control-limit`,"UCL","end"),_e(C.lower,`${R}__control-limit`,"LCL","end")),M&&(M.lower!==null&&_e(M.lower,`${R}__spec-limit`,"LSL","start"),M.upper!==null&&_e(M.upper,`${R}__spec-limit`,"USL","start"),M.target!==null&&_e(M.target,`${R}__spec-target`,"Target","start")),Ce.finish();const Re=new Map;for(const de of M&&M.violations?M.violations:[]){const we=Re.get(de.index);we?we.includes(de.rule)||we.push(de.rule):Re.set(de.index,[de.rule])}const fe=new Set(Re.keys()),G=new q(n.groups.marks),se=[],le=[];for(let de=0;de<L.length;de++){const we=c(r.left+de*xe),Ae=c(ge.of(L[de]));se.push(de?"L":"M",we,Ae),le.push({x:we,y:Ae,index:de,value:L[de],violating:fe.has(de)})}p(G.next("path",`${R}__control-line ${R}__mark`),{d:s(se),fill:"none",stroke:t.series(0)});for(const de of le)p(G.next("circle",`${R}__point ${R}__mark`),{cx:de.x,cy:de.y,r:de.violating?4:2.5,fill:de.violating?"var(--lattice-danger, #a4262c)":t.series(0),"data-violation":de.violating?"true":null});G.finish();const ae=[];for(const{y:de,text:we,side:Ae}of je)ae.push({x:Ae==="start"?r.left+2:r.right-2,y:de-3,text:we,anchor:Ae,className:`${R}__control-name`});for(const de of le){const we=Re.get(de.index);we&&ae.push({x:de.x,y:de.y-7,text:we.sort((Ae,Ee)=>Ae-Ee).join(","),anchor:"middle",className:`${R}__control-rule`})}return re({group:n.groups.labels,anchors:ae,size:9,grid:n.grid,minGap:1}),{points:le,limits:C,ruleSet:M?M.ruleSet:null}}function e(n){const t=n.scheme||z(),{plot:r,bound:l}=n;new q(n.groups.grid).finish();const L=[];for(const ae of l.series)for(const de of ae.points)D(de.y)&&L.push(de.y);if(L.length<2)return null;const M=n.capability||null,C=[...L];M&&(M.lower!==null&&C.push(M.lower),M.upper!==null&&C.push(M.upper),M.target!==null&&C.push(M.target));const ne=B(C,{zero:!1,nice:!0}),ue=T(ne,[r.left,r.right]),ge=V(L,n.buckets||14),xe=ge.map(ae=>ae.count),Ce=B(xe,{zero:!0}),je=T(Ce,[r.bottom,r.top]);J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:je,format:S(n.grid,{kind:"linear",step:(Ce.max-Ce.min)/5})}),te({group:n.groups.overlay,plot:r,scale:ue,fontSize:n.fontSize,format:S(n.grid,{kind:"linear",step:(ne.max-ne.min)/5})}),be({group:n.groups.rules,plot:r});const _e=je.of(0),Re=new q(n.groups.marks);for(let ae=0;ae<ge.length;ae++){const de=ge[ae],we=ue.of(de.from),Ae=ue.of(de.to),Ee=je.of(de.count);p(Re.next("rect",`${R}__bar ${R}__mark`),{x:c(Math.min(we,Ae)),y:c(Math.min(Ee,_e)),width:c(Math.max(1,Math.abs(Ae-we)-1)),height:c(Math.max(de.count>0?1:0,Math.abs(_e-Ee))),fill:t.series(0),"data-point":ae})}Re.finish();const fe=new q(n.groups.overlay),G=[];if(M&&Number.isFinite(M.mean)){const de=Te=>{if(!Number.isFinite(Te)||Te<=0)return null;const Ge=[];for(let Ie=0;Ie<=96;Ie++){const Ke=ne.min+(ne.max-ne.min)*Ie/96,Be=(Ke-M.mean)/Te;Ge.push({at:Ke,y:Math.exp(-.5*Be*Be)/Te})}return Ge},we=de(M.sigmaWithin),Ae=de(M.sigmaOverall);let Ee=0;for(const Te of[we,Ae])if(Te)for(const Ge of Te)Ee=Math.max(Ee,Ge.y);if(Ee>0){const Te=je.of(Ce.max),Ge=(Ie,Ke,Be)=>{if(!Ie)return;const ze=Ie.flatMap((qe,ot)=>[ot?"L":"M",c(ue.of(qe.at)),c(_e-qe.y/Ee*(_e-Te))]);p(fe.next("path",`${Ke} ${R}__mark`),{d:s(ze),fill:"none"}),G.push(Be)};Ge(we,`${R}__capability-within`,"within"),Ge(Ae,`${R}__capability-overall`,"overall")}}const se=[],le=(ae,de,we)=>{if(ae===null||!Number.isFinite(ae)||ae<ne.min||ae>ne.max)return;const Ae=c(ue.of(ae));p(fe.next("path",de),{d:s(["M",Ae,c(r.top),"L",Ae,c(r.bottom)]),fill:"none"}),se.push({x:Ae,text:we})};return M&&(le(M.lower,`${R}__spec-limit`,"LSL"),le(M.upper,`${R}__spec-limit`,"USL"),le(M.target,`${R}__spec-target`,"Target")),fe.finish(),re({group:n.groups.labels,anchors:se.map(({x:ae,text:de})=>({x:ae,y:r.top+6,text:de,anchor:"middle",className:`${R}__control-name`})),size:9,grid:n.grid,minGap:1}),{buckets:ge,capability:M,curves:G}}function i(n){const t=n.scheme||z(),{plot:r,bound:l}=n;new q(n.groups.grid).finish();const L=[];for(const se of l.series)for(const le of se.points)D(le.y)&&L.push(le.y);if(L.length<3)return null;const M=[];for(let se=1;se<L.length;se++)M.push(Math.abs(L[se]-L[se-1]));const C=M.reduce((se,le)=>se+le,0)/M.length,ne=3.267*C,ue=B([...M,0,ne],{zero:!0,nice:!0}),ge=T(ue,[r.bottom,r.top]),xe=M.length>1?(r.right-r.left)/(M.length-1):0;J({gridGroup:n.groups.grid,axisGroup:n.groups.axis,plot:r,scale:ge,format:S(n.grid,{kind:"linear",step:(ue.max-ue.min)/5})}),be({group:n.groups.rules,plot:r});const Ce=new q(n.groups.overlay),je=[],_e=(se,le,ae)=>{!Number.isFinite(se)||se<ue.min||se>ue.max||(p(Ce.next("path",le),{d:s(["M",c(r.left),c(ge.of(se)),"L",c(r.right),c(ge.of(se))]),fill:"none"}),je.push({y:ge.of(se),text:ae}))};_e(C,`${R}__control-centre`,"MR"),_e(ne,`${R}__control-limit`,"UCL"),Ce.finish();const Re=new q(n.groups.marks),fe=[],G=[];for(let se=0;se<M.length;se++){const le=c(r.left+se*xe),ae=c(ge.of(M[se]));fe.push(se?"L":"M",le,ae),G.push({x:le,y:ae,index:se,value:M[se],violating:M[se]>ne})}p(Re.next("path",`${R}__control-line ${R}__mark`),{d:s(fe),fill:"none",stroke:t.series(0)});for(const se of G)p(Re.next("circle",`${R}__point ${R}__mark`),{cx:se.x,cy:se.y,r:se.violating?4:2.5,fill:se.violating?"var(--lattice-danger, #a4262c)":t.series(0),"data-violation":se.violating?"true":null});return Re.finish(),re({group:n.groups.labels,anchors:je.map(({y:se,text:le})=>({x:r.right-2,y:se-3,text:le,anchor:"end",className:`${R}__control-name`})),size:9,grid:n.grid,minGap:1}),{points:G,centre:C,upper:ne}}}),Qe("packages/modules/charts/treemap.js",function(o,X){"use strict";Object.defineProperty(o,"squarify",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"layoutTree",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"drawTreemap",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"tileAt",{enumerable:!0,get:function(){return pe}});const q=X("packages/modules/charts/frame.js").Pool,j=X("packages/modules/charts/svg.js"),be=j.attrs,me=j.round,te=j.setText,W=X("packages/modules/charts/styles.js").NS,S=X("packages/modules/charts/scheme.js").resolveScheme,y=X("packages/modules/charts/labels.js"),U=y.drawAnchoredLabels,D=y.labelText,T=X("packages/modules/charts/typography.js"),B=T.applySize,_=T.truncateTo,$=34,p=6,s=3,c=3,k=.28;function R(x){return x*1.6}function I(x){return Math.round(x*1.6)}function z(x){return x>1?Math.max(.45,1-(x-1)*.22):1}function Y(x,Q,ce){if(!x.length||Q<=0||ce<=0)return 1/0;const E=Math.max(...x),V=Math.min(...x),h=Q*Q,a=ce*ce;return Math.max(h*E/a,a/(h*V))}function re(x,Q){const ce=[],E=x.filter(A=>A.value>0),V=E.reduce((A,w)=>A+w.value,0);if(!E.length||V<=0||Q.width<=0||Q.height<=0)return ce;const h=E.slice().sort((A,w)=>w.value-A.value),a=Q.width*Q.height/V;let d={...Q},u=[],m=[];const O=()=>{if(!u.length)return;const A=Math.min(d.width,d.height),g=m.reduce((v,F)=>v+F,0)/A;let f=0;for(let v=0;v<u.length;v++){const F=m[v]/g;ce.push(d.width>=d.height?{item:u[v],x:d.x,y:d.y+f,width:g,height:F}:{item:u[v],x:d.x+f,y:d.y,width:F,height:g}),f+=F}d.width>=d.height?d={x:d.x+g,y:d.y,width:d.width-g,height:d.height}:d={x:d.x,y:d.y+g,width:d.width,height:d.height-g},u=[],m=[]};for(const A of h){const w=A.value*a,g=Math.min(d.width,d.height),f=Y(m,g,m.reduce((F,b)=>F+b,0)),v=Y([...m,w],g,m.reduce((F,b)=>F+b,0)+w);u.length&&v>f&&O(),u.push(A),m.push(A.value*a)}return O(),ce}function ee(x){const{plot:Q,tree:ce}=x,E=R(x.fontSize),V=I(x.fontSize),h=[],a=(d,u,m,O,A)=>{const w=d.children.filter(g=>m>0||!x.hidden.has(g.label)).map((g,f)=>({node:g,value:g.total,index:m===0?f:O}));for(const g of re(w,u)){if(m>0&&(g.width<E||g.height<E))continue;const f={...g,depth:m+1,path:[...A,g.item.node.label],children:!1};h.push(f);const v={x:f.x+c,y:f.y+V,width:f.width-c*2,height:f.height-V-c};if(g.item.node.children.length&&v.width>=E&&v.height>=E){const F=h.length;a(g.item.node,v,m+1,f.item.index,f.path),f.children=h.length>F}}};return a(ce.root,{x:Q.left,y:Q.top,width:Q.width,height:Q.height},0,0,[]),h}function H(x){const Q=x.scheme||S();new q(x.groups.grid).finish(),new q(x.groups.axis).finish(),new q(x.groups.rules).finish(),new q(x.groups.labels).finish();const ce=ee(x),E=x.typography&&x.typography.small||x.fontSize||11,V=new q(x.groups.marks);for(const a of ce)be(V.next("rect",`${W}__tile ${W}__mark${a.children?` ${W}__tile--branch`:""}`),{x:me(a.x),y:me(a.y),width:me(Math.max(0,a.width)),height:me(Math.max(0,a.height)),fill:Q.series(a.item.index),"fill-opacity":a.children?k:z(a.depth),"data-point":a.item.index,"data-depth":a.depth});V.finish();const h=new q(x.groups.overlay);for(const a of ce){if(a.width<$||a.height<x.fontSize*1.6)continue;const d=String(a.item.node.label??""),u=_(d,a.width-p*2,E);if(u!==d&&u.length<s)continue;const m=h.next("text",`${W}__tile-label${a.children?` ${W}__tile-label--branch`:""}`);be(m,{x:me(a.x+p),y:me(a.y+x.fontSize+2),"text-anchor":"start"}),B(m,E),te(m,u)}return h.finish(),x.labels&&x.labels.show&&U({group:x.groups.labels,size:E,minGap:x.labels.minGap,anchors:ce.filter(a=>!a.children&&a.width>=$&&a.height>=x.fontSize*1.6+E).sort((a,d)=>d.width*d.height-a.width*a.height).map(a=>({x:me(a.x+p),y:me(a.y+x.fontSize*2+4),text:D(a.item.value,x.labels,x.grid),anchor:"start",inside:!0,width:a.width-p*2}))}),{tiles:ce}}function pe(x){let Q=null;for(const ce of x.tiles)x.x>=ce.x&&x.x<=ce.x+ce.width&&x.y>=ce.y&&x.y<=ce.y+ce.height&&(!Q||(ce.depth||1)>(Q.depth||1))&&(Q=ce);return Q}}),Qe("packages/modules/charts/annotate-items.js",function(o,X){"use strict";Object.defineProperty(o,"ANNOTATION_TOOLS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"MEASURE_KINDS",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"ANCHORS",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"ITEM_KINDS",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"TEXT_KINDS",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"FIB_LEVELS",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"nextItemId",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"resolveAnnotate",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"normaliseAnchor",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"normaliseItem",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"serialiseItem",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"itemsFromState",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"fibLevels",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"anchorsFor",{enumerable:!0,get:function(){return p}});const q=X("packages/core/src/internal/util.js").warnOnce,j=Object.freeze(["select","trendLine","horizontalLine","verticalLine","channel","fibonacci","arrow","measure-x","measure-y","measure-xy","text","callout","note","delete"]),be=Object.freeze(["measure-x","measure-y","measure-xy"]),me=Object.freeze({trendLine:2,horizontalLine:1,verticalLine:1,channel:3,fibonacci:2,arrow:2,"measure-x":2,"measure-y":2,"measure-xy":2,text:1,callout:2,note:1}),te=Object.freeze(Object.keys(me)),J=Object.freeze(["text","callout","note"]),W=Object.freeze([0,23.6,38.2,50,61.8,78.6,100]);let ie=0;function S(){return ie+=1,`ann-${ie}`}function y(s){const c={enabled:!1,tools:[],rail:"none",readOnly:!1,measure:{volume:null}};if(s==null||s===!1)return c;const k=s===!0?{}:s;if(typeof k!="object")return c;const R=Array.isArray(k.tools)?k.tools:null;if(R){const re=R.filter(ee=>!j.includes(ee));re.length&&q(`chart:annotate:tools:${re.join(",")}`,`chart annotate.tools names ${re.length} tool(s) this chart does not have: ${re.map(ee=>JSON.stringify(ee)).join(", ")}. The tools are ${j.join(", ")}.`)}const I=j.filter(re=>R?R.includes(re):!0),z=k.rail==="top"||k.rail==="none"?k.rail:"left",Y=k.measure&&typeof k.measure.volume=="string"&&k.measure.volume?k.measure.volume:null;return{enabled:!0,tools:I,rail:z,readOnly:k.readOnly===!0,measure:{volume:Y}}}function U(s){return typeof s=="string"?s!=="":typeof s=="number"?Number.isFinite(s):s instanceof Date&&Number.isFinite(s.getTime())}function D(s){if(!s||typeof s!="object")return null;const c=s,k=Number(c.y);return!Number.isFinite(k)||!U(c.x)?null:{x:c.x instanceof Date?new Date(c.x.getTime()):c.x,y:k}}function T(s){if(!s||typeof s!="object")return null;const c=s,k=String(c.kind||"");if(!me[k])return q(`chart:annotate:kind:${k}`,`a drawn chart annotation of kind ${JSON.stringify(k)} was not restored: the kinds are ${te.join(", ")}.`),null;const R=(Array.isArray(c.anchors)?c.anchors:[]).map(D).filter(Boolean);if(R.length<me[k])return q(`chart:annotate:anchors:${k}`,`a drawn chart annotation of kind ${JSON.stringify(k)} was not restored: it needs ${me[k]} data anchor(s) and carried ${R.length}.`),null;const I={id:typeof c.id=="string"&&c.id?c.id:S(),kind:k,anchors:R.slice(0,me[k])};return typeof c.text=="string"&&(I.text=c.text),typeof c.colour=="string"&&c.colour&&(I.colour=c.colour),c.readOnly===!0&&(I.readOnly=!0),I}function B(s){const c={id:s.id,kind:s.kind,anchors:s.anchors.map(k=>({x:k.x instanceof Date?k.x.toISOString():k.x,y:k.y}))};return s.text!==void 0&&(c.text=s.text),s.colour!==void 0&&(c.colour=s.colour),s.readOnly&&(c.readOnly=!0),c}function _(s){if(Array.isArray(s))return s.map(T).filter(Boolean);if(s&&typeof s=="object"){const c=s;if(Array.isArray(c.annotations))return c.annotations.map(T).filter(Boolean)}return[]}function $(s,c){const k=c.y-s.y;return W.map(R=>({level:R,y:s.y+k*R/100}))}function p(s,c,k){if(me[s]===1)return[c];if(s==="channel"){const R=(k.y-c.y)/4||Math.abs(k.y||1)/10;return[c,k,{x:k.x,y:k.y+R}]}return[c,k]}}),Qe("packages/modules/charts/annotate-measure.js",function(o,X){"use strict";Object.defineProperty(o,"xSpan",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"naturalDuration",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"measureReadout",{enumerable:!0,get:function(){return J}});const ye=X("packages/modules/charts/scale.js"),q=ye.key,j=ye.toNumber,be=ye.toTime;function me(W,ie,S,y){if(!Array.isArray(W)||!W.length)return null;if(y){const s=W.findIndex(I=>q(I)===q(ie)),c=W.findIndex(I=>q(I)===q(S));if(s<0||c<0)return null;const k=Math.min(s,c),R=Math.max(s,c);return{count:R-k+1,from:k,to:R}}const U=j(ie),D=j(S);if(U===null||D===null)return null;const T=Math.min(U,D),B=Math.max(U,D);let _=0,$=-1,p=-1;for(let s=0;s<W.length;s++){const c=j(W[s]);c===null||c<T||c>B||($<0&&($=s),p=s,_+=1)}return _?{count:_,from:$,to:p}:null}function te(W){const ie=[["years",31536e6],["months",2592e6],["weeks",6048e5],["days",864e5],["hours",36e5],["minutes",6e4]];for(const[S,y]of ie)if(W>=y)return{unit:S,count:Math.round(W/y)};return{unit:"seconds",count:Math.round(W/1e3)}}function J(W,ie,S){const[y,U]=ie,D={};if((W==="measure-x"||W==="measure-xy")&&y&&U){const T=me(S.categories,y.x,U.x,!!S.band);if(T){if(D.count=T.count,D.countUnit=S.candles?"bars":"points",S.timeAxis){const B=be(y.x),_=be(U.x);B!==null&&_!==null&&(D.elapsedMs=Math.abs(_-B),D.elapsed=te(D.elapsedMs))}if(S.volumeSeries){let B=0,_=!1;for(let $=T.from;$<=T.to;$++){const p=S.volumeSeries.points[$];p&&Number.isFinite(p.y)&&(B+=p.y,_=!0)}_&&(D.volume=B)}}}return(W==="measure-y"||W==="measure-xy")&&y&&U&&(D.change=U.y-y.y,D.changePercent=y.y?(U.y-y.y)/Math.abs(y.y)*100:null),D}}),Qe("packages/modules/charts/annotate-rail.js",function(o,X){"use strict";Object.defineProperty(o,"buildRail",{enumerable:!0,get:function(){return W}});const ye=X("packages/modules/charts/svg.js"),q=ye.attrs,j=ye.el,be=ye.svg,te=X("packages/modules/charts/styles.js").NS,J=Object.freeze({select:"M3 2 L12 8 L8 9 L10 13 L8 14 L6 10 L3 12 Z",trendLine:"M2 13 L14 4 M2 13 m-1.5 0 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0 M14 4 m-1.5 0 a1.5 1.5 0 1 0 3 0 a1.5 1.5 0 1 0 -3 0",horizontalLine:"M1 8 L15 8",verticalLine:"M8 1 L8 15",channel:"M2 12 L14 5 M2 15 L14 8",fibonacci:"M1 2 L15 2 M1 6 L15 6 M1 10 L15 10 M1 14 L15 14",arrow:"M2 14 L13 3 M13 3 L8 3 M13 3 L13 8","measure-x":"M2 4 L2 12 M14 4 L14 12 M2 8 L14 8","measure-y":"M4 2 L12 2 M4 14 L12 14 M8 2 L8 14","measure-xy":"M3 3 L13 3 L13 13 L3 13 Z M3 3 L13 13 M13 3 L3 13",text:"M3 3 L13 3 M8 3 L8 13 M6 13 L10 13",callout:"M2 2 L11 2 L11 9 L7 9 L4 13 L4 9 L2 9 Z",note:"M8 14 L8 8 M8 8 m-3 -3 a3 3 0 1 1 6 0 a3 3 0 1 1 -6 0",delete:"M3 4 L13 4 M6 4 L6 2 L10 2 L10 4 M4 4 L5 14 L11 14 L12 4 Z"});function W(ie){const{doc:S,t:y}=ie,U=j(S,"div",`${te}__annotate-rail ${te}__annotate-rail--${ie.place}`);U.setAttribute("role","toolbar"),U.setAttribute("aria-label",y("chart.annotate.rail")),U.setAttribute("aria-orientation",ie.place==="top"?"horizontal":"vertical");const D=new Map;for(const $ of ie.tools){const p=j(S,"button",`${te}__annotate-tool`);p.setAttribute("type","button"),p.setAttribute("data-tool",$);const s=y(`chart.annotate.${$}`);p.setAttribute("aria-label",s),p.setAttribute("title",s),$!=="delete"&&p.setAttribute("aria-pressed","false");const c=be(S,"svg",{class:`${te}__annotate-icon`,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false"});c.appendChild(be(S,"path",{d:J[$]||J.select})),p.appendChild(c),p.setAttribute("tabindex",D.size?"-1":"0"),p.addEventListener("click",()=>ie.onTool($)),U.appendChild(p),D.set($,p)}const T=$=>{const p=[...D.values()];if(!p.length)return;const s=Math.max(0,Math.min(p.length-1,$));for(let c=0;c<p.length;c++)p[c].setAttribute("tabindex",c===s?"0":"-1");p[s].focus&&p[s].focus()},B=$=>{const p=[...D.values()],s=p.indexOf($.target);if(s<0)return;const c={ArrowDown:s+1,ArrowRight:s+1,ArrowUp:s-1,ArrowLeft:s-1,Home:0,End:p.length-1};$.key in c&&(T(c[$.key]),$.preventDefault&&$.preventDefault(),$.stopPropagation&&$.stopPropagation())};return U.addEventListener("keydown",B),{element:U,sync:$=>{for(const[p,s]of D)p!=="delete"&&q(s,{"aria-pressed":p===$?"true":"false"})}}}}),Qe("packages/modules/charts/annotate-layer.js",function(o,X){"use strict";Object.defineProperty(o,"projector",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"shapeOf",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"ChartAnnotations",{enumerable:!0,get:function(){return v}});const q=X("packages/modules/charts/frame.js").Pool,be=X("packages/modules/charts/annotations.js").overlayLayer,me=X("packages/modules/charts/scale.js"),te=me.toNumber,J=me.toTime,W=X("packages/modules/charts/annotate-items.js"),ie=W.ANCHORS,S=W.anchorsFor,y=W.fibLevels,U=W.itemsFromState,D=W.MEASURE_KINDS,T=W.nextItemId,B=W.normaliseItem,_=W.serialiseItem,$=W.TEXT_KINDS,s=X("packages/modules/charts/annotate-measure.js").measureReadout,k=X("packages/modules/charts/annotate-rail.js").buildRail,R=X("packages/modules/charts/svg.js"),I=R.attrs,z=R.el,Y=R.path,re=R.round,ee=R.setText,H=R.SVG_NS,x=X("packages/modules/charts/styles.js").NS,Q=9,ce=6,E=4,V=4;function h(b,e){let i=null,n=1/0;for(const t of b.domain||[]){const r=b.centre(t);if(!Number.isFinite(r))continue;const l=Math.abs(r-e);l<n&&(n=l,i=t)}return i}function a(b){if(b.plot&&Number.isFinite(b.plot.left))return b.plot;const e=b.xScale.range||[0,0],i=b.yScale.range||[0,0],n=b.horizontal?i:e,t=b.horizontal?e:i;return{left:Math.min(n[0],n[1]),right:Math.max(n[0],n[1]),top:Math.min(t[0],t[1]),bottom:Math.max(t[0],t[1])}}function d(b){if(!b)return null;const{xScale:e,yScale:i}=b;if(!e||!i||typeof e.of!="function"||typeof i.of!="function"||typeof i.invert!="function")return null;const n=e.kind==="band";if(!n&&typeof e.invert!="function")return null;const t=!!b.horizontal,r=a(b),l=M=>{if(n)return e.centre(M);const C=e.kind==="time"?J(M):te(M);return C===null?NaN:e.of(C)},L=M=>n?h(e,M):e.invert(M);return{plot:r,toPixel(M){const C=l(M.x),ne=i.of(M.y);return!Number.isFinite(C)||!Number.isFinite(ne)?null:t?{x:ne,y:C}:{x:C,y:ne}},toData(M,C){const ne=t?C:M,ue=t?M:C,ge=L(ne),xe=i.invert(ue);return ge==null||!Number.isFinite(xe)?null:{x:ge,y:xe}}}}function u(b,e,i){const n=i.x-e.x,t=i.y-e.y,r=n*n+t*t,l=r?Math.max(0,Math.min(1,((b.x-e.x)*n+(b.y-e.y)*t)/r)):0;return Math.hypot(b.x-(e.x+l*n),b.y-(e.y+l*t))}function m(b,e){if(b instanceof Date)return b.toISOString().slice(0,10);if(typeof b=="string")return b;const i=Number(b);return Number.isFinite(i)?Math.abs(i)>1e12?new Date(i).toISOString().slice(0,10):e(i):String(b)}function O(b,e,i,n){const t=b.anchors.map(L=>e.toPixel(L));if(t.some(L=>!L))return null;const{plot:r}=e,l={handles:t,segments:[],fill:null,dots:[],labels:[],title:""};if(b.kind==="trendLine"||b.kind==="arrow")return l.segments.push({from:t[0],to:t[1],arrow:b.kind==="arrow"}),l;if(b.kind==="horizontalLine"||b.kind==="verticalLine"){const L=b.kind==="horizontalLine",M=t[0],C=L?{x:r.left,y:M.y}:{x:M.x,y:r.top},ne=L?{x:r.right,y:M.y}:{x:M.x,y:r.bottom};return l.segments.push({from:C,to:ne,dashed:!0}),l.labels.push({x:ne.x-(L?4:-4),y:ne.y-(L?4:0),text:L?i(b.anchors[0].y):m(b.anchors[0].x,i),anchor:L?"end":"start"}),l}if(b.kind==="channel"){const[L,M,C]=t,ne=M.x-L.x,ue=ne?L.y+(C.x-L.x)/ne*(M.y-L.y):L.y,ge=C.y-ue,xe={x:L.x,y:L.y+ge},Ce={x:M.x,y:M.y+ge};return l.segments.push({from:L,to:M}),l.segments.push({from:xe,to:Ce}),l.fill=[L,M,Ce,xe],l}if(b.kind==="fibonacci"){const L=Math.min(t[0].x,t[1].x),M=Math.max(t[0].x,t[1].x);for(const C of y(b.anchors[0],b.anchors[1])){const ne=e.toPixel({x:b.anchors[0].x,y:C.y});ne&&(l.segments.push({from:{x:L,y:ne.y},to:{x:M,y:ne.y},dashed:C.level!==0}),l.labels.push({x:M+4,y:ne.y-3,text:`${C.level}% · ${i(C.y)}`,anchor:"start"}))}return l}return b.kind==="callout"?(l.dots.push(t[0]),l.segments.push({from:t[0],to:t[1]}),l.labels.push({x:t[1].x+4,y:t[1].y,text:b.text||"",anchor:"start"}),l):D.includes(b.kind)?f(b,t,l,n):b.kind==="note"?(l.dots.push(t[0]),l.title=b.text||"",l):(l.labels.push({x:t[0].x,y:t[0].y,text:b.text||"",anchor:"start"}),l)}function A(b){return!(b>0)&&!(b<0)?null:b>0?"var(--lattice-success, #15803d)":"var(--lattice-danger, #b91c1c)"}function w(b,e,i){if(!b||b.count===void 0)return"";const n=[e(b.countUnit==="bars"?"chart.annotate.measure.bars":"chart.annotate.measure.points",{count:b.count})];return b.elapsed&&n.push(e(`chart.annotate.measure.${b.elapsed.unit}`,{count:b.elapsed.count})),b.volume!==void 0&&n.push(e("chart.annotate.measure.volume",{value:i(b.volume)})),n.join(" | ")}function g(b,e){if(!b||b.change===void 0)return"";const i=b.change>0?"+":"",n=b.changePercent===null||b.changePercent===void 0?"":` (${b.changePercent>0?"+":""}${Math.round(b.changePercent*10)/10}%)`;return`${i}${e(b.change)}${n}`}function f(b,e,i,n){const[t,r]=e,l=Math.min(t.x,r.x),L=Math.max(t.x,r.x),M=Math.min(t.y,r.y),C=Math.max(t.y,r.y),ne=n?s(b.kind,b.anchors,n):{},ue=n&&n.t,ge=n&&n.format;if(b.kind==="measure-xy"){i.segments.push({from:{x:l,y:M},to:{x:L,y:M}}),i.segments.push({from:{x:L,y:M},to:{x:L,y:C}}),i.segments.push({from:{x:L,y:C},to:{x:l,y:C}}),i.segments.push({from:{x:l,y:C},to:{x:l,y:M}}),i.fill=[{x:l,y:M},{x:L,y:M},{x:L,y:C},{x:l,y:C}];const je=ue?w(ne,ue,ge):"";je&&i.labels.push({x:(l+L)/2,y:M-6,text:je,anchor:"middle"});const _e=ue?g(ne,ge):"";return _e&&i.labels.push({x:L+6,y:(M+C)/2,text:_e,anchor:"start",fill:A(ne.change)}),i}if(b.kind==="measure-x"){const je=(t.y+r.y)/2;i.segments.push({from:{x:l,y:je},to:{x:L,y:je}}),i.segments.push({from:{x:l,y:je-5},to:{x:l,y:je+5}}),i.segments.push({from:{x:L,y:je-5},to:{x:L,y:je+5}});const _e=ue?w(ne,ue,ge):"";return _e&&i.labels.push({x:(l+L)/2,y:je-6,text:_e,anchor:"middle"}),i}const xe=(t.x+r.x)/2;i.segments.push({from:{x:xe,y:M},to:{x:xe,y:C}}),i.segments.push({from:{x:xe-5,y:M},to:{x:xe+5,y:M}}),i.segments.push({from:{x:xe-5,y:C},to:{x:xe+5,y:C}});const Ce=ue?g(ne,ge):"";return Ce&&i.labels.push({x:xe+6,y:(M+C)/2,text:Ce,anchor:"start",fill:A(ne.change)}),i}class v{#r;#n;#l=[];#e=null;#i=null;#s=null;#o=null;#c=null;#y=null;#m=null;#F=[];constructor(e,i){this.#r=e,this.#n=i,this.#u(),this.configure(i)}#w(e){if(!D.includes(e.kind))return;const i=this.#O();if(!i)return;const n=s(e.kind,e.anchors,i);return Object.keys(n).length?n:void 0}get tool(){return this.#e}get busy(){return!!this.#s||!!this.#e&&this.#e!=="delete"}configure(e){const i=this.#n;this.#n=e;const n=i&&i.rail===e.rail&&i.tools.join()===e.tools.join()&&i.readOnly===e.readOnly;if(!(this.#o&&n)){if(this.#o&&(this.#o.element.parentNode&&this.#o.element.parentNode.removeChild(this.#o.element),this.#o=null),e.rail==="none"||e.readOnly||!e.tools.length){this.#r.root.classList.remove(`${x}--annotate-left`,`${x}--annotate-top`),this.use(null);return}this.#o=k({doc:this.#r.doc,t:this.#r.t,tools:e.tools,place:e.rail,onTool:t=>this.#t(t)}),this.#r.root.classList.remove(`${x}--annotate-left`,`${x}--annotate-top`),this.#r.root.classList.add(`${x}--annotate-${e.rail}`),this.#r.root.insertBefore(this.#o.element,this.#r.root.firstChild),this.#o.sync(this.#e)}}list(){return this.#l.map(_)}setItems(e){this.#l=U(e),this.#i=null,this.redraw()}use(e){this.#e=e,this.#s=null,this.#o&&this.#o.sync(e),this.redraw()}add(e){if(this.#n.readOnly)return null;const i=B({id:T(),...e});return i?(this.#l.push(i),this.redraw(),this.#r.notify("added",_(i),this.#w(i)),i):null}remove(e){const i=this.#l.findIndex(t=>t.id===e);if(i<0||this.#n.readOnly||this.#l[i].readOnly)return!1;const[n]=this.#l.splice(i,1);return this.#i===e&&(this.#i=null),this.redraw(),this.#r.notify("removed",_(n),this.#w(n)),!0}setText(e,i){const n=this.#l.find(t=>t.id===e);return!n||this.#n.readOnly||n.readOnly?!1:(n.text=String(i),this.redraw(),this.#r.notify("changed",_(n),this.#w(n)),!0)}redraw(){const e=this.#r.groups&&this.#r.groups.overlay;if(!e)return;this.#c=be(e,`${x}__drawn`);const i=new q(this.#c),n=d(this.#r.drawn());if(n){const t=this.#r.format(),r=this.#O(t);for(const l of this.#l){const L=O(l,n,t,r);L&&this.#x(i,l,L,l.id===this.#i)}if(this.#s&&this.#s.preview){const l=O(this.#s.preview,n,t,r);l&&this.#x(i,this.#s.preview,l,!1)}}i.finish()}#O(e){const i=this.#r.bound?this.#r.bound():null,n=this.#r.drawn();if(!i||!n||!n.xScale)return null;const t=n.xScale.kind==="band",r=!!n.candles,l=n.xScale.kind==="time"||r,L=this.#n.measure&&this.#n.measure.volume;let M=null;return Array.isArray(i.series)&&(L?M=i.series.find(C=>C.key===L)||null:r&&i.series.length>4&&(M=i.series[4])),{categories:i.categories||[],band:t,timeAxis:l,candles:r,volumeSeries:M,t:this.#r.t,format:e||this.#r.format()}}#x(e,i,n,t){if(n.fill){const r=[];for(const L of n.fill)r.push(r.length?"L":"M",re(L.x),re(L.y));r.push("Z");const l=e.next("path",`${x}__drawn-fill`);I(l,{class:`${x}__drawn-fill`,"data-annotation-id":i.id,d:Y(r),fill:i.colour||null})}for(const r of n.segments){const l=e.next("path",`${x}__drawn-line`),L=["M",re(r.from.x),re(r.from.y),"L",re(r.to.x),re(r.to.y)];r.arrow&&L.push(...F(r.from,r.to)),I(l,{class:`${x}__drawn-line`,"data-annotation-id":i.id,"data-annotation-kind":i.kind,"stroke-dasharray":r.dashed?"4 3":null,d:Y(L),stroke:i.colour||null})}for(const r of n.dots){const l=e.next("circle",`${x}__drawn-dot`);I(l,{class:`${x}__drawn-dot`,"data-annotation-id":i.id,cx:re(r.x),cy:re(r.y),r:3.5,fill:i.colour||null}),this.#g(l,n.title)}for(const r of n.labels){if(!r.text)continue;const l=e.next("text",`${x}__drawn-label`);I(l,{class:`${x}__drawn-label`,"data-annotation-id":i.id,x:re(r.x),y:re(r.y),"text-anchor":r.anchor,fill:r.fill||i.colour||null}),ee(l,r.text)}if(t)for(let r=0;r<n.handles.length;r++){const l=e.next("circle",`${x}__drawn-handle`);I(l,{class:`${x}__drawn-handle`,"data-annotation-id":i.id,"data-anchor":r,cx:re(n.handles[r].x),cy:re(n.handles[r].y),r:V})}}#g(e,i){const n=e.firstChild;if(!i){n&&e.removeChild(n);return}if(n){ee(n,i);return}const t=this.#r.doc.createElementNS(H,"title");ee(t,i),e.appendChild(t)}#t(e){if(e==="delete"){this.#i&&this.remove(this.#i);return}this.use(this.#e===e?null:e)}#u(){const e=this.#r.plot,i=this.#r.root,n=L=>this.#S(L),t=L=>this.#L(L),r=L=>this.#$(L),l=L=>this.#te(L);e.addEventListener("pointerdown",n),e.addEventListener("pointermove",t),e.addEventListener("pointerup",r),i.addEventListener("keydown",l),this.#F.push(()=>{e.removeEventListener("pointerdown",n),e.removeEventListener("pointermove",t),e.removeEventListener("pointerup",r),i.removeEventListener("keydown",l)})}#A(e){const i=this.#r.plot.getBoundingClientRect?this.#r.plot.getBoundingClientRect():{left:0,top:0};return{x:(e.clientX||0)-(i.left||0),y:(e.clientY||0)-(i.top||0)}}#P(e,i){const n=this.#r.format();for(let t=this.#l.length-1;t>=0;t--){const r=this.#l[t],l=O(r,i,n);if(!l)continue;for(let M=0;M<l.handles.length;M++)if(Math.hypot(e.x-l.handles[M].x,e.y-l.handles[M].y)<=Q)return{item:r,anchor:M};if(l.segments.some(M=>u(e,M.from,M.to)<=ce)||l.dots.some(M=>Math.hypot(e.x-M.x,e.y-M.y)<=Q))return{item:r,anchor:-1}}return null}#S(e){if(!this.#e)return;const i=d(this.#r.drawn());if(!i)return;const n=this.#A(e),t=i.toData(n.x,n.y);if(t){if(e.preventDefault&&e.preventDefault(),this.#e==="select"){const r=this.#P(n,i);this.#i=r?r.item.id:null,this.#s=r&&!r.item.readOnly?{mode:"move",item:r.item,anchor:r.anchor,from:t,at:n}:null,this.redraw();return}this.#s={mode:"draw",kind:this.#e,from:t,at:n}}}#L(e){if(!this.#s)return;const i=d(this.#r.drawn());if(!i)return;const n=this.#A(e),t=i.toData(n.x,n.y);if(t){if(this.#s.mode==="move"){const{item:r}=this.#s;this.#s.anchor>=0?r.anchors[this.#s.anchor]=t:this.#I(r,this.#s.from,t),this.#s.from=t,this.#s.moved=!0,this.redraw();return}ie[this.#s.kind]!==1&&(this.#s.to=t,this.#s.preview={id:"preview",kind:this.#s.kind,anchors:S(this.#s.kind,this.#s.from,t)},this.redraw())}}#I(e,i,n){const t=n.y-i.y,r=typeof i.x=="number"&&typeof n.x=="number",l=r?n.x-i.x:0;for(const L of e.anchors)L.y+=t,r&&typeof L.x=="number"&&(L.x+=l);r||(e.anchors[0].x=n.x)}#$(e){const i=this.#s;if(!i)return;this.#s=null;const n=d(this.#r.drawn());if(!n){this.redraw();return}const t=this.#A(e),r=n.toData(t.x,t.y)||i.from;if(i.mode==="move"){this.redraw(),i.moved&&this.#r.notify("changed",_(i.item),this.#w(i.item));return}const l=ie[i.kind]===1,L=Math.hypot(t.x-i.at.x,t.y-i.at.y);if(!l&&L<E){this.redraw();return}const M=B({id:T(),kind:i.kind,anchors:S(i.kind,i.from,r)});if(!M){this.redraw();return}this.#l.push(M),this.#i=M.id,this.redraw(),$.includes(M.kind)?this.#ne(M,t):this.#r.notify("added",_(M),this.#w(M))}#te(e){if(e.key==="Escape"){if(this.#y){this.#a(!0);return}if(!this.#s&&!this.#e&&!this.#i)return;this.#s=null,this.#i=null,this.use(null),e.preventDefault&&e.preventDefault();return}(e.key==="Delete"||e.key==="Backspace")&&this.#i&&!this.#y&&this.remove(this.#i)&&e.preventDefault&&e.preventDefault()}#ne(e,i){this.#a(!1);const n=this.#r.doc,t=z(n,"input",`${x}__annotate-input`);t.setAttribute("type","text"),t.setAttribute("aria-label",this.#r.t("chart.annotate.editLabel")),t.value=e.text||"";const r=this.#r.plot.getBoundingClientRect?this.#r.plot.getBoundingClientRect():{left:0,top:0},l=this.#r.root.getBoundingClientRect?this.#r.root.getBoundingClientRect():{left:0,top:0};t.setAttribute("style",`left:${Math.round(i.x+(r.left||0)-(l.left||0))}px;top:${Math.round(i.y+(r.top||0)-(l.top||0))}px`);const L=M=>{M.key==="Enter"?(this.#a(!1),M.preventDefault&&M.preventDefault()):M.key==="Escape"&&(this.#a(!0),M.preventDefault&&M.preventDefault())};t.addEventListener("keydown",L),t.addEventListener("blur",()=>this.#a(!1)),this.#r.root.appendChild(t),this.#y=t,this.#m=e,t.focus&&t.focus()}#a(e){const i=this.#y,n=this.#m;if(!i||!n)return;this.#y=null,this.#m=null,i.parentNode&&i.parentNode.removeChild(i);const t=e?"":String(i.value||""),r=!n.text;if(!t&&r){const l=this.#l.indexOf(n);l>=0&&this.#l.splice(l,1),this.#i===n.id&&(this.#i=null),this.redraw();return}if(t===n.text){this.redraw();return}n.text=t,this.redraw(),this.#r.notify(r?"added":"changed",_(n))}destroy(){for(const e of this.#F)e();this.#F=[],this.#a(!0),this.#o&&this.#o.element.parentNode&&this.#o.element.parentNode.removeChild(this.#o.element),this.#o=null,this.#l=[],this.#c&&this.#c.parentNode&&this.#c.parentNode.removeChild(this.#c),this.#c=null}}function F(b,e){const i=Math.atan2(e.y-b.y,e.x-b.x),n=8,t=.45;return["M",re(e.x),re(e.y),"L",re(e.x-n*Math.cos(i-t)),re(e.y-n*Math.sin(i-t)),"M",re(e.x),re(e.y),"L",re(e.x-n*Math.cos(i+t)),re(e.y-n*Math.sin(i+t))]}}),Qe("packages/modules/charts/zoom-view.js",function(o,X){"use strict";Object.defineProperty(o,"ZOOM_CONTROLS",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"ZOOM_BUTTONS",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"ZOOM_AXES",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"ZOOM_STEP",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"ZOOM_MIN",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"resolveZoom",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"settleView",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"magnify",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"slide",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"sameView",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"bandRange",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"slice",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"viewOfRange",{enumerable:!0,get:function(){return _}});const q=X("packages/core/src/internal/util.js").warnOnce,j=Object.freeze(["in","out","left","right","reset"]),be=Object.freeze(["hover","always","none"]),me=Object.freeze(["x","y","xy"]),te=.25,J=.01,W=1e-9;function ie($){const p={enabled:!1,axes:"x",buttons:"none",wheel:!1,pan:!1,step:te,min:J};if($==null||$===!1)return p;const s=$===!0?{}:$;if(typeof s!="object")return p;let c="x";s.axes!==void 0&&(me.includes(s.axes)?c=s.axes:q(`chart:zoom:axes:${String(s.axes)}`,`chart zoom.axes is ${JSON.stringify(s.axes)}, which is not an axis this chart can zoom; it was ignored and x was used. The values are ${me.join(", ")}.`));let k="hover";s.buttons!==void 0&&(be.includes(s.buttons)?k=s.buttons:q(`chart:zoom:buttons:${String(s.buttons)}`,`chart zoom.buttons is ${JSON.stringify(s.buttons)}, which is not a way to show the zoom toolbar; it was ignored and hover was used. The values are ${be.join(", ")}.`));const R=Number.isFinite(s.step)&&s.step>0&&s.step<1?Number(s.step):te,I=Number.isFinite(s.min)&&s.min>0&&s.min<=1?Number(s.min):J;return{enabled:!0,axes:c,buttons:k,wheel:s.wheel!==!1,pan:s.pan!==!1,step:R,min:I}}function S($,p){if(!$||!p)return null;const s=p.max-p.min;if(!(s>0))return null;let c=Math.min($.to-$.from,s);if(!(c>0))return null;if($.pinned){const I=p.max;return{from:I-c,to:I,pinned:!0}}let k=$.from;k<p.min&&(k=p.min),k+c>p.max&&(k=p.max-c);const R=k+c;return k<=p.min+W&&R>=p.max-W?null:{from:k,to:R,pinned:R>=p.max-W}}function y($,p,s,c,k){const R=p.max-p.min;if(!(R>0))return null;const I=$?$.from:p.min,z=$?$.to:p.max,Y=z-I,re=!!$&&$.pinned,ee=Number.isFinite(c)?Math.min(z,Math.max(I,c)):re?z:I+Y/2,H=Math.max(R*k,0),pe=Math.min(Math.max(Y*s,H),R),x=Y>0?(ee-I)/Y:.5;return S({from:ee-pe*x,to:ee+pe*(1-x),pinned:re&&ee>=z-W},p)}function U($,p,s){if(!$)return null;const c=($.to-$.from)*s;return S({from:$.from+c,to:$.to+c,pinned:!1},p)}function D($,p){return!$||!p?!$&&!p:Math.abs($.from-p.from)<=W&&Math.abs($.to-p.to)<=W}function T($,p){const s=Math.max(0,p-1);if(!$)return{first:0,last:s};const c=Math.max(0,Math.ceil($.from-W)),k=Math.min(s,Math.floor($.to+W));return k<c?{first:Math.min(c,s),last:Math.min(c,s)}:{first:c,last:k}}function B($,p,s){const c=($.categories||[]).length;if(p<=0&&s>=c-1)return $;const k=[];for(let R=p;R<=s;R++)k.push(R);return{...$,categories:k.map(R=>$.categories[R]),labels:Array.isArray($.labels)?k.map(R=>$.labels[R]):$.labels,series:($.series||[]).map(R=>({...R,points:Array.isArray(R.points)?k.map(I=>R.points[I]).filter(I=>I!==void 0):R.points}))}}function _($,p){if(!Array.isArray($)||$.length<2||!p)return null;const s=Number($[0]),c=Number($[1]);return!Number.isFinite(s)||!Number.isFinite(c)||s===c?null:S({from:Math.min(s,c),to:Math.max(s,c),pinned:!1},p)}}),Qe("packages/modules/charts/zoom-toolbar.js",function(o,X){"use strict";Object.defineProperty(o,"buildZoomToolbar",{enumerable:!0,get:function(){return W}});const ye=X("packages/modules/charts/svg.js"),q=ye.attrs,j=ye.el,be=ye.svg,te=X("packages/modules/charts/styles.js").NS,J=Object.freeze({in:"M7 3 a4 4 0 1 0 0 8 a4 4 0 1 0 0 -8 M10 10 L14 14 M5 7 L9 7 M7 5 L7 9",out:"M7 3 a4 4 0 1 0 0 8 a4 4 0 1 0 0 -8 M10 10 L14 14 M5 7 L9 7",left:"M10 3 L5 8 L10 13",right:"M6 3 L11 8 L6 13",reset:"M3 8 a5 5 0 1 0 1.6 -3.7 M2 2 L2 5.5 L5.5 5.5"});function W(ie){const{doc:S,t:y}=ie,U=j(S,"div",`${te}__zoom-bar ${te}__zoom-bar--${ie.buttons}`);U.setAttribute("role","toolbar"),U.setAttribute("aria-label",y("chart.zoom.toolbar")),U.setAttribute("aria-orientation","horizontal");const D=new Map;for(const $ of ie.controls){const p=j(S,"button",`${te}__zoom-button`);p.setAttribute("type","button"),p.setAttribute("data-zoom",$);const s=y(`chart.zoom.${$}`);p.setAttribute("aria-label",s),p.setAttribute("title",s);const c=be(S,"svg",{class:`${te}__zoom-icon`,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false"});c.appendChild(be(S,"path",{d:J[$]||J.reset})),p.appendChild(c),p.setAttribute("tabindex",D.size?"-1":"0"),p.addEventListener("click",()=>ie.onPress($)),U.appendChild(p),D.set($,p)}const T=$=>{const p=[...D.values()];if(!p.length)return;const s=Math.max(0,Math.min(p.length-1,$));for(let c=0;c<p.length;c++)p[c].setAttribute("tabindex",c===s?"0":"-1");p[s].focus&&p[s].focus()},B=$=>{const p=[...D.values()],s=p.indexOf($.target);if(s<0)return;const c={ArrowRight:s+1,ArrowDown:s+1,ArrowLeft:s-1,ArrowUp:s-1,Home:0,End:p.length-1};$.key in c&&(T(c[$.key]),$.preventDefault&&$.preventDefault(),$.stopPropagation&&$.stopPropagation())};return U.addEventListener("keydown",B),{element:U,sync:$=>{for(const[p,s]of D){const c=p==="in"&&$.narrowest||p!=="in"&&!$.zoomed;q(s,{disabled:c?"disabled":null,"aria-disabled":c?"true":null})}}}}}),Qe("packages/modules/charts/topojson.js",function(o,X){"use strict";Object.defineProperty(o,"transformer",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"arcPoints",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"stitch",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"decodeGeometry",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"feature",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"isTopology",{enumerable:!0,get:function(){return J}});function ye(W){if(!W)return B=>[B[0],B[1]];const[ie,S]=W.scale,[y,U]=W.translate;let D=0,T=0;return(B,_)=>(_||(D=0,T=0),D+=B[0],T+=B[1],[D*ie+y,T*S+U])}function q(W,ie){const S=W.arcs[ie],y=ye(W.transform);return S.map((U,D)=>y(U,D))}function j(W,ie){const S=q(W,ie<0?~ie:ie);return ie<0?S.slice().reverse():S}function be(W,ie){const S=[];for(const y of ie){const U=j(W,y);for(let D=S.length?1:0;D<U.length;D++)S.push(U[D])}return S}function me(W,ie){if(!ie||!ie.type)return null;const S=ye(W.transform);switch(ie.type){case"Point":return{type:"Point",coordinates:S(ie.coordinates,0)};case"MultiPoint":return{type:"MultiPoint",coordinates:ie.coordinates.map(y=>S(y,0))};case"LineString":return{type:"LineString",coordinates:be(W,ie.arcs)};case"MultiLineString":return{type:"MultiLineString",coordinates:ie.arcs.map(y=>be(W,y))};case"Polygon":return{type:"Polygon",coordinates:ie.arcs.map(y=>be(W,y))};case"MultiPolygon":return{type:"MultiPolygon",coordinates:ie.arcs.map(y=>y.map(U=>be(W,U)))};case"GeometryCollection":return{type:"GeometryCollection",geometries:(ie.geometries||[]).map(y=>me(W,y)).filter(Boolean)};default:return null}}function te(W,ie){const S=typeof ie=="string"?(W.objects||{})[ie]:ie;if(!S)return{type:"FeatureCollection",features:[]};const y=S.type==="GeometryCollection"?S.geometries||[]:[S],U=[];for(const D of y){const T=me(W,D);T&&U.push({type:"Feature",id:D.id,properties:D.properties||{},geometry:T})}return{type:"FeatureCollection",features:U}}function J(W){return!!W&&typeof W=="object"&&W.type==="Topology"&&Array.isArray(W.arcs)}}),Qe("packages/modules/charts/projection.js",function(o,X){"use strict";Object.defineProperty(o,"MERCATOR_LIMIT",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"equalEarth",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"robinson",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"mercator",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"equirectangular",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"albers",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"transverseMercator",{enumerable:!0,get:function(){return S}}),Object.defineProperty(o,"PROJECTIONS",{enumerable:!0,get:function(){return y}}),Object.defineProperty(o,"DEFAULT_PROJECTION",{enumerable:!0,get:function(){return U}}),Object.defineProperty(o,"resolveProjection",{enumerable:!0,get:function(){return D}}),Object.defineProperty(o,"WRAP_DEGREES",{enumerable:!0,get:function(){return T}}),Object.defineProperty(o,"splitAntimeridian",{enumerable:!0,get:function(){return B}}),Object.defineProperty(o,"boundsOf",{enumerable:!0,get:function(){return _}}),Object.defineProperty(o,"fitted",{enumerable:!0,get:function(){return $}}),Object.defineProperty(o,"graticule",{enumerable:!0,get:function(){return s}});const ye=Math.PI/180,q=Object.freeze([1.340264,-.081106,893e-6,.003796]),j=Object.freeze([[1,0],[.9986,.062],[.9954,.124],[.99,.186],[.9822,.248],[.973,.31],[.96,.372],[.9427,.434],[.9216,.4958],[.8962,.5571],[.8679,.6176],[.835,.6769],[.7986,.7346],[.7597,.7903],[.7186,.8435],[.6732,.8936],[.6213,.9394],[.5722,.9761],[.5322,1]]),be=85.05113;function me(c,k){const[R,I,z,Y]=q,re=k*ye,ee=Math.asin(Math.min(1,Math.max(-1,Math.sqrt(3)/2*Math.sin(re)))),H=ee*ee,pe=H*H*H,x=Math.sqrt(3)/2*(R+3*I*H+pe*(7*z+9*Y*H));return[c*ye*Math.cos(ee)/x,ee*(R+I*H+pe*(z+Y*H))]}function te(c,k){const R=Math.min(Math.abs(k),90),I=Math.min(j.length-2,Math.floor(R/5)),z=(R-I*5)/5,[Y,re]=j[I],[ee,H]=j[I+1],pe=Y+(ee-Y)*z,x=re+(H-re)*z;return[c*ye*pe,(k<0?-x:x)*(Math.PI/2)]}function J(c,k){const R=Math.min(be,Math.max(-be,k))*ye;return[c*ye,Math.log(Math.tan(Math.PI/4+R/2))]}function W(c,k){return[c*ye,k*ye]}function ie(c={}){const[k,R]=c.parallels||[29.5,45.5],[I,z]=c.centre||[-96,37.5],Y=k*ye,re=R*ye,ee=Math.sin(Y),H=Math.abs(Y-re)<1e-9?ee:(ee+Math.sin(re))/2,pe=Math.cos(Y)**2+2*H*ee,x=Math.sqrt(pe-2*H*Math.sin(z*ye))/H;return(Q,ce)=>{const E=H*((Q-I)*ye),V=Math.max(0,pe-2*H*Math.sin(ce*ye)),h=Math.sqrt(V)/H;return[h*Math.sin(E),x-h*Math.cos(E)]}}function S(c={}){const[k,R]=c.centre||[-2,49];return(I,z)=>{const Y=z*ye,re=(I-k)*ye,ee=Math.cos(Y)*Math.sin(re),H=Math.min(1-1e-12,Math.max(-1+1e-12,ee));return[.5*Math.log((1+H)/(1-H)),Math.atan2(Math.tan(Y),Math.cos(re))-R*ye]}}const y=Object.freeze({equalEarth:()=>me,robinson:()=>te,mercator:()=>J,equirectangular:()=>W,albers:ie,transverseMercator:S,britishNationalGrid:c=>S({centre:[-2,49],...c})}),U="equalEarth";function D(c,k={},R){if(typeof c=="function")return c;const z=y[typeof c=="string"&&c?c:U];return z?z(k):(R&&R(`chart projection ${JSON.stringify(c)} is not one this module draws; using '${U}'. Supported: ${Object.keys(y).join(", ")}.`),y[U]({}))}const T=180;function B(c){if(!Array.isArray(c)||c.length<2)return c&&c.length?[c]:[];const k=[];let R=[c[0]];for(let I=1;I<c.length;I++){const[z,Y]=c[I-1],[re,ee]=c[I],H=re-z;if(Math.abs(H)>T){const pe=H>0?-180:180,x=H>0?H-360:H+360,Q=x===0?0:Math.min(1,Math.max(0,(pe-z)/x)),ce=Y+(ee-Y)*Q;R.push([pe,ce]),k.push(R),R=[[-pe,ce],[re,ee]]}else R.push([re,ee])}return k.push(R),k.filter(I=>I.length>1)}function _(c){let k=1/0,R=1/0,I=-1/0,z=-1/0;for(const Y of c||[])for(const[re,ee]of Y)re<k&&(k=re),re>I&&(I=re),ee<R&&(R=ee),ee>z&&(z=ee);return Number.isFinite(k)?{west:k,south:R,east:I,north:z}:null}function $(c){const{project:k,rings:R,plot:I}=c,z=typeof c.padding=="number"?c.padding:4;let Y=1/0,re=1/0,ee=-1/0,H=-1/0;for(const g of R||[])for(const[f,v]of g){const[F,b]=k(f,v);!Number.isFinite(F)||!Number.isFinite(b)||(F<Y&&(Y=F),F>ee&&(ee=F),b<re&&(re=b),b>H&&(H=b))}if(!Number.isFinite(Y)||ee===Y||H===re)return{to:(f,v)=>{const[F,b]=k(f,v);return[I.left+I.width/2+F,I.top+I.height/2-b]},scale:1,width:I.width,height:I.height,left:I.left,top:I.top,aspect:1};const pe=Math.max(1,I.width-z*2),x=Math.max(1,I.height-z*2),Q=typeof c.zoom=="number"&&c.zoom>0?c.zoom:1,ce=Math.min(pe/(ee-Y),x/(H-re))*Q,E=(ee-Y)*ce,V=(H-re)*ce,[h,a]=c.centre?k(c.centre[0],c.centre[1]):[(Y+ee)/2,(re+H)/2],d=c.centreOffset||[0,0],u=h+(d[0]||0),m=a+(d[1]||0),O=I.left+I.width/2,A=I.top+I.height/2;return{to:(g,f)=>{const[v,F]=k(g,f);return[O+(v-u)*ce,A-(F-m)*ce]},scale:ce,width:E,height:V,left:O-E/2,top:A-V/2,aspect:(ee-Y)/(H-re)}}const p=2;function s(c={}){const k=c.step&&c.step>0?c.step:30,R=[];for(let I=-180;I<=180;I+=k){const z=[];for(let Y=-80;Y<=80;Y+=p)z.push([I,Y]);R.push(z)}for(let I=-60;I<=60;I+=k){const z=[];for(let Y=-180;Y<=180;Y+=p)z.push([Y,I]);R.push(z)}return R}}),Qe("packages/modules/charts/geocolumn.js",function(o,X){"use strict";Object.defineProperty(o,"geometryColumnOf",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"bothPlacements",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"rowGeometry",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"geometryPoint",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"geometryPolygons",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"geoAnchorScales",{enumerable:!0,get:function(){return ie}});const ye=Math.PI/180,q=85.05113,j=Object.freeze({equirectangular:Object.freeze({forward:S=>S*ye,inverse:S=>S/ye}),mercator:Object.freeze({forward:S=>{const y=Math.min(q,Math.max(-q,S))*ye;return Math.log(Math.tan(Math.PI/4+y/2))},inverse:S=>(2*Math.atan(Math.exp(S))-Math.PI/2)/ye})});function be(S,y){const U=y&&y.geometry;if(typeof U!="string"||!U)return null;const D=S&&S.columns&&typeof S.columns.get=="function"?S.columns.get(U):null,T=D&&D.dataType;return{col:U,measure:T&&typeof T.geometry=="function"?T.geometry:null}}function me(S){if(!S||typeof S.geometry!="string"||!S.geometry)return!1;const y=U=>U!=null&&U!=="";return y(S.lon)||y(S.lat)}function te(S,y,U){if(!y||!y.measure)return null;const D=S.rows.value(U,y.col);if(D==null)return null;const T=y.measure(D);if(!T||!T.bbox||!T.centroid)return null;const[B,_,$,p]=T.bbox;return![B,_,$,p].every(Number.isFinite)||B<-180||$>180||_<-90||p>90?null:{geometry:D,info:T}}function J(S){const y=S.geometry;return y&&y.type==="Point"&&Array.isArray(y.coordinates)?[Number(y.coordinates[0]),Number(y.coordinates[1])]:[Number(S.info.centroid[0]),Number(S.info.centroid[1])]}function W(S,y=[]){if(!S||typeof S!="object")return y;if(S.type==="Polygon")y.push(S.coordinates);else if(S.type==="MultiPolygon")for(const U of S.coordinates)y.push(U);else if(S.type==="GeometryCollection")for(const U of S.geometries||[])W(U,y);return y}function ie(S,y,U){const D=typeof y=="string"?j[y]:null;if(!D||typeof S!="function")return null;const[T,B]=S(0,0),[_]=S(1,0),[,$]=S(0,10),p=_-T,s=($-B)/D.forward(10);if(![T,B,p,s].every(Number.isFinite)||!p||!s)return null;const c={kind:"linear",domain:{min:(U.left-T)/p,max:(U.right-T)/p},range:[U.left,U.right],of:R=>T+Number(R)*p,invert:R=>(R-T)/p},k={kind:"linear",domain:{min:D.inverse((U.bottom-B)/s),max:D.inverse((U.top-B)/s)},range:[U.bottom,U.top],of:R=>B+D.forward(Number(R))*s,invert:R=>D.inverse((R-B)/s)};return{xScale:c,yScale:k}}}),Qe("packages/modules/charts/geo.js",function(o,X){"use strict";Object.defineProperty(o,"CONTINENTS",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"CONTINENT_NAMES",{enumerable:!0,get:function(){return d}}),Object.defineProperty(o,"OUTLINES",{enumerable:!0,get:function(){return u}}),Object.defineProperty(o,"COUNTRY_CONTINENT",{enumerable:!0,get:function(){return m}}),Object.defineProperty(o,"ALPHA3",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"NUMERIC",{enumerable:!0,get:function(){return A}}),Object.defineProperty(o,"normaliseCode",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"continentOf",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"projection",{enumerable:!0,get:function(){return f}}),Object.defineProperty(o,"projectedPath",{enumerable:!0,get:function(){return v}}),Object.defineProperty(o,"ringPath",{enumerable:!0,get:function(){return F}}),Object.defineProperty(o,"shapesToPaths",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"registerGeoPack",{enumerable:!0,get:function(){return i}}),Object.defineProperty(o,"geoPack",{enumerable:!0,get:function(){return n}}),Object.defineProperty(o,"geoPacks",{enumerable:!0,get:function(){return t}}),Object.defineProperty(o,"resolvePack",{enumerable:!0,get:function(){return r}}),Object.defineProperty(o,"packRegions",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"regionLabelPoint",{enumerable:!0,get:function(){return C}}),Object.defineProperty(o,"geoRamp",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"basemapStyleOf",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"drawGeomap",{enumerable:!0,get:function(){return xe}}),Object.defineProperty(o,"regionAt",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(o,"markerAt",{enumerable:!0,get:function(){return je}}),Object.defineProperty(o,"checkGeometrySpec",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"GEOMETRY_TYPES_PLACED",{enumerable:!0,get:function(){return Re}});const q=X("packages/modules/charts/frame.js").Pool,be=X("packages/modules/charts/matrix.js").colourRamp,te=X("packages/modules/charts/topojson.js").feature,J=X("packages/modules/charts/projection.js"),W=J.fitted,ie=J.graticule,S=J.resolveProjection,y=J.splitAntimeridian,D=X("packages/modules/charts/labels.js").drawAnchoredLabels,T=X("packages/modules/charts/axis.js"),B=T.overhangFor,_=T.setPlotClip,p=X("packages/core/src/internal/util.js").warnOnce,c=X("packages/modules/charts/scheme.js").resolveScheme,k=X("packages/modules/charts/scale.js"),R=k.isNumber,I=k.measureDomain,z=X("packages/modules/charts/svg.js"),Y=z.attrs,re=z.insideRings,ee=z.path,H=z.pathRings,pe=z.round,x=z.setText,ce=X("packages/modules/charts/styles.js").NS,E=X("packages/modules/charts/geocolumn.js"),V=E.bothPlacements,h=E.geometryColumnOf,a=Object.freeze(["AF","AN","AS","EU","NA","OC","SA"]),d=Object.freeze({AF:"Africa",AN:"Antarctica",AS:"Asia",EU:"Europe",NA:"North America",OC:"Oceania",SA:"South America"}),u=Object.freeze({NA:[[[-168,66],[-156,71],[-130,70],[-115,69],[-100,69],[-85,70],[-75,73],[-64,66],[-78,62],[-79,55],[-65,60],[-56,52],[-60,45],[-67,45],[-70,42],[-74,40],[-76,37],[-81,32],[-80,27],[-81,25],[-84,30],[-90,29],[-94,29],[-97,26],[-97,21],[-91,19],[-88,21],[-87,16],[-83,9],[-79,9],[-85,13],[-92,16],[-96,16],[-105,20],[-110,24],[-114,28],[-117,32],[-122,37],[-124,42],[-124,48],[-130,55],[-140,60],[-150,59],[-160,55],[-165,60],[-168,66]],[[-43,60],[-32,64],[-22,70],[-20,74],[-25,78],[-33,83],[-45,83],[-58,82],[-62,76],[-56,70],[-55,66],[-52,61],[-43,60]]],SA:[[[-81,12],[-72,12],[-62,11],[-52,5],[-50,0],[-44,-2],[-35,-6],[-38,-13],[-39,-18],[-48,-25],[-53,-34],[-57,-38],[-62,-40],[-65,-45],[-68,-52],[-75,-53],[-73,-45],[-73,-37],[-71,-30],[-70,-23],[-71,-18],[-76,-14],[-81,-6],[-80,-2],[-78,1],[-77,8],[-81,12]]],EU:[[[-10,36],[-9,44],[-2,43],[-4,48],[-1,49],[4,52],[7,53],[8,57],[10,58],[5,58],[5,62],[11,64],[15,69],[21,70],[28,71],[32,70],[40,67],[44,68],[50,69],[60,70],[60,60],[58,52],[50,46],[40,44],[36,45],[30,46],[28,41],[26,40],[23,38],[18,40],[13,38],[15,37],[12,44],[8,44],[3,42],[-2,37],[-10,36]],[[-5,50],[1,51],[2,53],[-1,55],[-3,58],[-5,58],[-6,55],[-5,50]],[[-10,52],[-6,52],[-6,55],[-10,55],[-10,52]]],AF:[[[-17,21],[-16,15],[-17,12],[-13,8],[-8,5],[-3,5],[3,6],[8,4],[9,2],[10,-2],[12,-6],[12,-12],[14,-18],[15,-23],[18,-29],[23,-34],[27,-34],[32,-29],[33,-26],[35,-22],[40,-16],[41,-10],[40,-3],[43,0],[51,4],[51,11],[45,12],[43,12],[39,15],[37,21],[34,28],[32,31],[25,32],[20,31],[15,32],[10,37],[3,36],[-2,35],[-6,36],[-10,30],[-13,27],[-17,21]]],AS:[[[26,40],[35,36],[36,31],[43,30],[48,30],[50,27],[56,25],[57,22],[60,25],[62,25],[67,24],[70,21],[73,16],[77,8],[80,6],[80,13],[84,19],[87,21],[92,21],[95,16],[98,10],[104,1],[104,10],[107,11],[109,17],[117,23],[122,30],[122,37],[126,34],[129,35],[130,43],[135,45],[142,45],[143,53],[140,58],[155,59],[162,60],[170,66],[180,68],[170,71],[150,73],[130,74],[110,76],[90,76],[75,73],[70,70],[60,70],[60,60],[58,52],[50,46],[40,44],[36,45],[30,46],[28,41],[26,40]],[[130,31],[132,32],[135,33],[137,34],[140,35],[141,38],[141,41],[142,42],[145,43],[145,45],[141,45],[140,42],[139,40],[137,37],[135,35],[133,34],[131,33],[130,31]]],OC:[[[113,-22],[114,-26],[115,-34],[119,-34],[126,-32],[132,-32],[137,-35],[141,-38],[147,-38],[150,-37],[153,-30],[153,-25],[146,-19],[142,-11],[136,-12],[130,-12],[126,-14],[122,-18],[113,-22]],[[145,-41],[148,-41],[148,-43],[145,-43],[145,-41]],[[173,-35],[178,-38],[174,-41],[172,-43],[167,-46],[170,-44],[173,-35]]],AN:[[[-180,-78],[-150,-76],[-120,-74],[-100,-73],[-80,-72],[-60,-63],[-45,-60],[-58,-64],[-70,-70],[-60,-76],[-30,-77],[0,-70],[20,-70],[40,-68],[60,-67],[80,-66],[100,-66],[120,-66],[140,-66],[160,-78],[170,-84],[180,-85],[-180,-85],[-180,-78]]]}),m=Object.freeze({AD:"EU",AE:"AS",AF:"AS",AG:"NA",AI:"NA",AL:"EU",AM:"AS",AO:"AF",AQ:"AN",AR:"SA",AS:"OC",AT:"EU",AU:"OC",AW:"NA",AX:"EU",AZ:"AS",BA:"EU",BB:"NA",BD:"AS",BE:"EU",BF:"AF",BG:"EU",BH:"AS",BI:"AF",BJ:"AF",BM:"NA",BN:"AS",BO:"SA",BR:"SA",BS:"NA",BT:"AS",BW:"AF",BY:"EU",BZ:"NA",CA:"NA",CD:"AF",CF:"AF",CG:"AF",CH:"EU",CI:"AF",CL:"SA",CM:"AF",CN:"AS",CO:"SA",CR:"NA",CU:"NA",CV:"AF",CY:"AS",CZ:"EU",DE:"EU",DJ:"AF",DK:"EU",DM:"NA",DO:"NA",DZ:"AF",EC:"SA",EE:"EU",EG:"AF",ER:"AF",ES:"EU",ET:"AF",FI:"EU",FJ:"OC",FK:"SA",FM:"OC",FO:"EU",FR:"EU",GA:"AF",GB:"EU",GD:"NA",GE:"AS",GF:"SA",GG:"EU",GH:"AF",GI:"EU",GL:"NA",GM:"AF",GN:"AF",GP:"NA",GQ:"AF",GR:"EU",GT:"NA",GU:"OC",GW:"AF",GY:"SA",HK:"AS",HN:"NA",HR:"EU",HT:"NA",HU:"EU",ID:"AS",IE:"EU",IL:"AS",IM:"EU",IN:"AS",IQ:"AS",IR:"AS",IS:"EU",IT:"EU",JE:"EU",JM:"NA",JO:"AS",JP:"AS",KE:"AF",KG:"AS",KH:"AS",KI:"OC",KM:"AF",KN:"NA",KP:"AS",KR:"AS",KW:"AS",KY:"NA",KZ:"AS",LA:"AS",LB:"AS",LC:"NA",LI:"EU",LK:"AS",LR:"AF",LS:"AF",LT:"EU",LU:"EU",LV:"EU",LY:"AF",MA:"AF",MC:"EU",MD:"EU",ME:"EU",MG:"AF",MH:"OC",MK:"EU",ML:"AF",MM:"AS",MN:"AS",MO:"AS",MQ:"NA",MR:"AF",MT:"EU",MU:"AF",MV:"AS",MW:"AF",MX:"NA",MY:"AS",MZ:"AF",NA:"AF",NC:"OC",NE:"AF",NG:"AF",NI:"NA",NL:"EU",NO:"EU",NP:"AS",NR:"OC",NZ:"OC",OM:"AS",PA:"NA",PE:"SA",PF:"OC",PG:"OC",PH:"AS",PK:"AS",PL:"EU",PM:"NA",PR:"NA",PS:"AS",PT:"EU",PW:"OC",PY:"SA",QA:"AS",RE:"AF",RO:"EU",RS:"EU",RU:"EU",RW:"AF",SA:"AS",SB:"OC",SC:"AF",SD:"AF",SE:"EU",SG:"AS",SI:"EU",SK:"EU",SL:"AF",SM:"EU",SN:"AF",SO:"AF",SR:"SA",SS:"AF",ST:"AF",SV:"NA",SY:"AS",SZ:"AF",TC:"NA",TD:"AF",TG:"AF",TH:"AS",TJ:"AS",TL:"AS",TM:"AS",TN:"AF",TO:"OC",TR:"AS",TT:"NA",TV:"OC",TW:"AS",TZ:"AF",UA:"EU",UG:"AF",US:"NA",UY:"SA",UZ:"AS",VA:"EU",VC:"NA",VE:"SA",VG:"NA",VI:"NA",VN:"AS",VU:"OC",WS:"OC",YE:"AS",YT:"AF",ZA:"AF",ZM:"AF",ZW:"AF"}),O=Object.freeze({AFG:"AF",ALB:"AL",DZA:"DZ",AND:"AD",AGO:"AO",ARG:"AR",ARM:"AM",AUS:"AU",AUT:"AT",AZE:"AZ",BHS:"BS",BHR:"BH",BGD:"BD",BRB:"BB",BLR:"BY",BEL:"BE",BLZ:"BZ",BEN:"BJ",BTN:"BT",BOL:"BO",BIH:"BA",BWA:"BW",BRA:"BR",BRN:"BN",BGR:"BG",BFA:"BF",BDI:"BI",KHM:"KH",CMR:"CM",CAN:"CA",CPV:"CV",CAF:"CF",TCD:"TD",CHL:"CL",CHN:"CN",COL:"CO",COM:"KM",COG:"CG",COD:"CD",CRI:"CR",CIV:"CI",HRV:"HR",CUB:"CU",CYP:"CY",CZE:"CZ",DNK:"DK",DJI:"DJ",DMA:"DM",DOM:"DO",ECU:"EC",EGY:"EG",SLV:"SV",GNQ:"GQ",ERI:"ER",EST:"EE",ETH:"ET",FJI:"FJ",FIN:"FI",FRA:"FR",GAB:"GA",GMB:"GM",GEO:"GE",DEU:"DE",GHA:"GH",GRC:"GR",GRL:"GL",GTM:"GT",GIN:"GN",GNB:"GW",GUY:"GY",HTI:"HT",HND:"HN",HKG:"HK",HUN:"HU",ISL:"IS",IND:"IN",IDN:"ID",IRN:"IR",IRQ:"IQ",IRL:"IE",ISR:"IL",ITA:"IT",JAM:"JM",JPN:"JP",JOR:"JO",KAZ:"KZ",KEN:"KE",KIR:"KI",PRK:"KP",KOR:"KR",KWT:"KW",KGZ:"KG",LAO:"LA",LVA:"LV",LBN:"LB",LSO:"LS",LBR:"LR",LBY:"LY",LIE:"LI",LTU:"LT",LUX:"LU",MKD:"MK",MDG:"MG",MWI:"MW",MYS:"MY",MDV:"MV",MLI:"ML",MLT:"MT",MHL:"MH",MRT:"MR",MUS:"MU",MEX:"MX",FSM:"FM",MDA:"MD",MCO:"MC",MNG:"MN",MNE:"ME",MAR:"MA",MOZ:"MZ",MMR:"MM",NAM:"NA",NRU:"NR",NPL:"NP",NLD:"NL",NZL:"NZ",NIC:"NI",NER:"NE",NGA:"NG",NOR:"NO",OMN:"OM",PAK:"PK",PLW:"PW",PSE:"PS",PAN:"PA",PNG:"PG",PRY:"PY",PER:"PE",PHL:"PH",POL:"PL",PRT:"PT",PRI:"PR",QAT:"QA",ROU:"RO",RUS:"RU",RWA:"RW",KNA:"KN",LCA:"LC",VCT:"VC",WSM:"WS",SMR:"SM",STP:"ST",SAU:"SA",SEN:"SN",SRB:"RS",SYC:"SC",SLE:"SL",SGP:"SG",SVK:"SK",SVN:"SI",SLB:"SB",SOM:"SO",ZAF:"ZA",SSD:"SS",ESP:"ES",LKA:"LK",SDN:"SD",SUR:"SR",SWZ:"SZ",SWE:"SE",CHE:"CH",SYR:"SY",TWN:"TW",TJK:"TJ",TZA:"TZ",THA:"TH",TLS:"TL",TGO:"TG",TON:"TO",TTO:"TT",TUN:"TN",TUR:"TR",TKM:"TM",TUV:"TV",UGA:"UG",UKR:"UA",ARE:"AE",GBR:"GB",USA:"US",URY:"UY",UZB:"UZ",VUT:"VU",VEN:"VE",VNM:"VN",YEM:"YE",ZMB:"ZM",ZWE:"ZW"}),A=Object.freeze({4:"AF",8:"AL",12:"DZ",20:"AD",24:"AO",32:"AR",36:"AU",40:"AT",44:"BS",48:"BH",50:"BD",51:"AM",52:"BB",56:"BE",64:"BT",68:"BO",70:"BA",72:"BW",76:"BR",84:"BZ",90:"SB",96:"BN",100:"BG",104:"MM",108:"BI",112:"BY",116:"KH",120:"CM",124:"CA",132:"CV",140:"CF",144:"LK",148:"TD",152:"CL",156:"CN",170:"CO",174:"KM",178:"CG",180:"CD",188:"CR",191:"HR",192:"CU",196:"CY",203:"CZ",204:"BJ",208:"DK",212:"DM",214:"DO",218:"EC",222:"SV",226:"GQ",231:"ET",232:"ER",233:"EE",246:"FI",250:"FR",262:"DJ",266:"GA",268:"GE",270:"GM",276:"DE",288:"GH",300:"GR",304:"GL",320:"GT",324:"GN",328:"GY",332:"HT",340:"HN",344:"HK",348:"HU",352:"IS",356:"IN",360:"ID",364:"IR",368:"IQ",372:"IE",376:"IL",380:"IT",384:"CI",388:"JM",392:"JP",398:"KZ",400:"JO",404:"KE",408:"KP",410:"KR",414:"KW",417:"KG",418:"LA",422:"LB",426:"LS",428:"LV",430:"LR",434:"LY",438:"LI",440:"LT",442:"LU",450:"MG",454:"MW",458:"MY",462:"MV",466:"ML",470:"MT",478:"MR",480:"MU",484:"MX",496:"MN",498:"MD",499:"ME",504:"MA",508:"MZ",512:"OM",516:"NA",520:"NR",524:"NP",528:"NL",548:"VU",554:"NZ",558:"NI",562:"NE",566:"NG",578:"NO",586:"PK",585:"PW",591:"PA",598:"PG",600:"PY",604:"PE",608:"PH",616:"PL",620:"PT",624:"GW",626:"TL",630:"PR",634:"QA",642:"RO",643:"RU",646:"RW",682:"SA",686:"SN",688:"RS",690:"SC",694:"SL",702:"SG",703:"SK",704:"VN",705:"SI",706:"SO",710:"ZA",716:"ZW",724:"ES",728:"SS",729:"SD",740:"SR",748:"SZ",752:"SE",756:"CH",760:"SY",762:"TJ",764:"TH",768:"TG",776:"TO",780:"TT",784:"AE",788:"TN",792:"TR",795:"TM",798:"TV",800:"UG",804:"UA",807:"MK",818:"EG",826:"GB",834:"TZ",840:"US",858:"UY",860:"UZ",862:"VE",882:"WS",887:"YE",894:"ZM"});function w(fe){if(fe==null||fe==="")return null;const G=String(fe).trim().toUpperCase();return G?/^\d+$/.test(G)?A[String(Number(G))]||null:G.length===2?G:G.length===3&&O[G]||null:null}function g(fe){return fe?a.includes(fe)&&!(fe in m)||a.includes(fe)?fe:m[fe]||null:null}function f(fe,G={}){const se=G.antarctic?-90:-58,le=84,ae=le-se,de=Math.min(fe.width/360,fe.height/ae),we=360*de,Ae=ae*de,Ee=fe.left+(fe.width-we)/2,Te=fe.top+(fe.height-Ae)/2;return(Ge,Ie)=>[Ee+(Ge+180)*de,Te+(le-Ie)*de]}function v(fe,G){const se=[];for(let le=0;le<fe.length;le++){const[ae,de]=G(fe[le][0],fe[le][1]);if(!Number.isFinite(ae)||!Number.isFinite(de))return se.length>4?ee([...se,"Z"]):"";se.push(le?"L":"M",pe(ae),pe(de))}return se.length?ee([...se,"Z"]):""}function F(fe,G){const se=Array.isArray(fe)&&Array.isArray(fe[0])&&Array.isArray(fe[0][0])?fe:[fe],le=[];for(const ae of se)if(!(!Array.isArray(ae)||!ae.length)){for(let de=0;de<ae.length;de++){const[we,Ae]=G(ae[de][0],ae[de][1]);le.push(de?"L":"M",pe(we),pe(Ae))}le.push("Z")}return ee(le)}function b(fe){const G=new Map,se=fe.shapes;if(!se)return G;const le=f(fe.plot),ae=fe.codeProperty||"iso_a2";if(!Array.isArray(se)&&!se.type){for(const we of Object.keys(se)){const Ae=w(we);Ae&&typeof se[we]=="string"&&G.set(Ae,se[we])}return G}const de=se.type==="FeatureCollection"?se.features||[]:[se];for(const we of de){const Ae=we.properties||{},Ee=w(Ae[ae]??Ae.iso??Ae.code),Te=we.geometry;if(!Ee||!Te)continue;const Ge=Te.type==="MultiPolygon"?Te.coordinates:Te.type==="Polygon"?[Te.coordinates]:[],Ie=[];for(const Ke of Ge)for(const Be of Ke)Ie.push(F(Be,le));Ie.length&&G.set(Ee,Ie.join(" "))}return G}const e=new Map;function i(fe){return fe&&typeof fe=="object"&&typeof fe.id=="string"&&e.set(fe.id,fe),fe}function n(fe){return e.get(fe)||null}function t(){return[...e.keys()]}function r(fe,G){if(!fe||typeof fe!="object")return null;const se=fe;let le=fe;if(typeof se.pack=="string"){if(le=e.get(se.pack),!le)return p(`chart:geomap:pack:${se.pack}`,`geometry pack ${JSON.stringify(se.pack)} has not been loaded, so the map fell back to the schematic continents. Import the pack module and pass it as \`shapes\` — import { pack } from '@toclocoinc/lattice-grid/modules/geo-${se.pack}'; createChart({ …, shapes: pack })${e.size?`. Loaded: ${[...e.keys()].join(", ")}.`:"."}`),null}else se.pack&&typeof se.pack=="object"&&(le=se.pack);if(!le||typeof le!="object")return null;const ae=le;if(ae.topology)return{pack:ae,topology:ae.topology};if(ae.layers){const de=typeof se.layer=="string"&&se.layer||typeof G=="string"&&G||ae.defaultLayer||Object.keys(ae.layers)[0],we=ae.layers[de];if(we&&we.topology)return{pack:ae,topology:we.topology,layer:de}}return null}const l=new WeakMap;function L(fe){const G=l.get(fe);if(G)return G;const se=[];for(const le of te(fe,"regions").features){const ae=[],de=le.geometry,we=de.type==="MultiPolygon"?de.coordinates:de.type==="Polygon"?[de.coordinates]:[];for(const Ae of we)for(const Ee of Ae)for(const Te of y(Ee))ae.push(Te);ae.length&&se.push({code:String(le.id===void 0||le.id===null?"":le.id),label:le.properties&&le.properties.name||String(le.id||""),properties:le.properties||{},rings:ae})}return l.set(fe,se),se}function M(fe,G){const se=[];for(let le=0;le<fe.length;le++){const[ae,de]=G(fe[le][0],fe[le][1]);!Number.isFinite(ae)||!Number.isFinite(de)||se.push(se.length?"L":"M",pe(ae),pe(de))}return se.length>2?ee(se):""}function C(fe){let G=null,se=-1;for(const de of fe){if(!de||de.length<3)continue;let we=0,Ae=0,Ee=0;for(let Ge=0;Ge<de.length;Ge++){const[Ie,Ke]=de[Ge],[Be,ze]=de[(Ge+1)%de.length],qe=Ie*ze-Be*Ke;we+=qe,Ae+=(Ie+Be)*qe,Ee+=(Ke+ze)*qe}we/=2;const Te=Math.abs(we);Te<1e-9||Te>se&&(se=Te,G=[Ae/(6*we),Ee/(6*we)])}if(G)return G;const le=fe.flat();if(!le.length)return null;const ae=le.reduce((de,[we,Ae])=>[de[0]+we,de[1]+Ae],[0,0]);return[ae[0]/le.length,ae[1]/le.length]}function ne(fe,G,se,le){const ae=be(fe,G,se,le);if(G)return ae;const de=1/6,we=Ee=>ae.colourAt(de+Ee*(1-de));return Object.assign(Ee=>we(ae.position(Ee)),{...ae,colourAt:we})}function ue(fe,G){return(se,le)=>{const[ae,de]=fe(se,le);return!Number.isFinite(ae)||!Number.isFinite(de)?[ae,de]:[Math.min(Math.max(ae,G.left),G.right),Math.min(Math.max(de,G.top),G.bottom)]}}function ge(fe){const G=fe&&fe.fill||"var(--lattice-chart-basemap-fill, #c3cfd6)",se=fe&&fe.stroke||"var(--lattice-chart-basemap-stroke, #456374)",le=fe&&fe.strokeWidth!=null?fe.strokeWidth:"var(--lattice-chart-basemap-stroke-width, 0.75)";return{fill:G,style:`stroke:${se};stroke-width:${le}`}}function xe(fe){const G=fe.scheme||c(),{plot:se,bound:le}=fe;new q(fe.groups.grid).finish(),new q(fe.groups.axis).finish(),new q(fe.groups.rules).finish(),new q(fe.groups.labels).finish();const ae=r(fe.shapes,fe.layer),de=ae?new Map:b({shapes:fe.shapes,plot:se,codeProperty:fe.codeProperty}),we=de.size>0||!!ae,Ae=ae?L(ae.topology):null,Ee=new Map;if(Ae)for(const et of Ae){Ee.set(et.code,et);const ht=et.properties||{};ht.alpha3&&Ee.set(String(ht.alpha3).toUpperCase(),et),ht.numeric&&Ee.set(String(Number(ht.numeric)),et),ht.fips&&Ee.set(String(ht.fips),et)}const Te=new Map,Ge=[],Ie=le.series[0];if(Ie)for(let et=0;et<Ie.points.length;et++){const ht=Ie.points[et];if(!R(ht.y))continue;const bt=le.categories[et],Ct=w(bt),Dt=Ae?[Ct,bt==null?"":String(bt).trim().toUpperCase()].map(Z=>Z?Ee.get(Z):null).find(Boolean):null,Ft=Dt?Dt.code:null,Ut=Ae?Ft:we?Ct:g(Ct);if(!Ut||we&&!Ae&&!de.has(Ut)){le.labels[et]&&Ge.push(le.labels[et]);continue}const Jt=Te.get(Ut)||{value:0,labels:[]};Jt.value+=ht.y,Jt.labels.push(le.labels[et]),Te.set(Ut,Jt)}const Ke=Te.has("AN")||Te.has("AQ"),Be=f(se,{antarctic:Ke});let ze=null;if(Ae){const et=Ke?Ae:Ae.filter(bt=>bt.code!=="AQ"&&bt.code!=="AN"),ht=S(fe.projection||ae.pack.projection,{...ae.pack.projectionOptions||{},...fe.projectionOptions||{}},bt=>p(`chart:geomap:projection:${String(fe.projection)}`,bt));ze={project:ht,...W({project:ht,rings:et.flatMap(bt=>bt.rings),plot:se,zoom:fe.zoom,centre:fe.centre,centreOffset:fe.centreOffset}),drawn:et}}const qe=I([...Te.values()].map(et=>et.value),{zero:!fe.diverging,nice:!1}),ot=ne(qe,!!fe.diverging,G,[...Te.values()].map(et=>et.value)),Ot=B("geomap");_(fe.groups,se,Ot);const St={left:se.left-Ot,top:se.top-Ot,right:se.right+Ot,bottom:se.bottom+Ot},zt=ze?ue(ze.to,St):null,$t=new q(fe.groups.marks);if(!!fe.graticule&&!!ze){const et=fe.graticule&&typeof fe.graticule=="object"&&fe.graticule.step||30;for(const ht of ie({step:et}))for(const bt of y(ht)){const Ct=M(bt,zt);if(!Ct)continue;const Dt=$t.next("path",`${ce}__graticule`);Y(Dt,{d:Ct,class:`${ce}__graticule`})}}const Yt=[],ln=ze?ze.drawn.map(et=>et.code):we?[...de.keys()]:a.filter(et=>et!=="AN"||Ke),Mt=ze?new Map(ze.drawn.map(et=>[et.code,et])):null,Lt=ze?ge(fe.basemap):null;for(const et of ln){const ht=ze?Mt.get(et).rings.map(Dt=>v(Dt,zt)).filter(Boolean).join(" "):we?de.get(et):F(u[et],Be),bt=Te.get(et),Ct=$t.next("path",`${ce}__region ${ce}__mark`);Y(Ct,{d:ht,fill:bt?ot(bt.value):Lt?Lt.fill:"var(--lattice-chart-empty, #eceff1)","data-code":et,class:`${ce}__region ${ce}__mark`,style:Lt?Lt.style:null}),Yt.push({code:et,value:bt?bt.value:null,label:!we&&d[et]||Mt&&Mt.get(et).label||bt&&bt.labels[0]||et,element:Ct,d:ht})}$t.finish();const Xt=new q(fe.groups.overlay);if(Ge.length){const et=Xt.next("text",`${ce}__geo-note`);Y(et,{x:pe(se.left),y:pe(se.bottom),"text-anchor":"start"}),x(et,fe.grid.messages.t("chart.geoUnmatched",{count:Ge.length}))}Xt.finish();let rn=0;if(fe.labels&&fe.labels.show&&ze){const et=Yt.filter(ht=>ht.value!==null).sort((ht,bt)=>bt.value-ht.value).map(ht=>{const bt=Mt.get(ht.code).rings.map(Dt=>Dt.map(([Ft,Ut])=>ze.to(Ft,Ut))),Ct=C(bt);return Ct&&{x:Ct[0],y:Ct[1],text:ht.label}}).filter(Boolean);rn=D({group:fe.groups.labels,size:fe.fontSize,minGap:fe.labels.minGap,anchors:et,plot:se})}return{regions:Yt,ramp:ot,unmatched:Ge,useCountries:we,packed:!!ze,scale:ze?ze.scale:null,attribution:ae&&ae.pack.attribution||"",aspect:ze?ze.aspect:null,labelsDrawn:rn}}function Ce(fe){for(const G of fe.regions||[]){if(!G.rings){G.rings=H(G.d);let le=1/0,ae=1/0,de=-1/0,we=-1/0;for(const Ae of G.rings)for(const[Ee,Te]of Ae)Ee<le&&(le=Ee),Ee>de&&(de=Ee),Te<ae&&(ae=Te),Te>we&&(we=Te);G.box={minX:le,minY:ae,maxX:de,maxY:we}}const se=G.box;if(!(!se||fe.x<se.minX||fe.x>se.maxX||fe.y<se.minY||fe.y>se.maxY)&&re(G.rings,fe.x,fe.y))return G}return null}function je(fe){let se=null,le=1/0;for(const ae of fe.markers||[]){if(!ae)continue;const de=(ae.r||0)+3,we=fe.x-ae.x,Ae=fe.y-ae.y,Ee=Math.sqrt(we*we+Ae*Ae);Ee>de||Ee>=le||(le=Ee,se=ae)}return se}function _e(fe){const{grid:G,spec:se,type:le,id:ae}=fe;if(!se||!Re.has(le))return;if(V(se)){p(`chart:${ae}:geometry:both`,`a "${le}" chart was given both "geometry" and "lon"/"lat", and a row is placed by one or the other, so nothing was drawn rather than one being picked for you. Keep "geometry" for a geometry column, or "lon" and "lat" for two coordinate columns.`);return}const de=h(G,se);if(!de){le==="choropleth"&&p(`chart:${ae}:geometry:missing`,`a "choropleth" chart draws each row's own shape from a geometry column and was given none, so it has nothing to draw. Name the column: geometry: '<column>'.`);return}de.measure||p(`chart:${ae}:geometry:type:${de.col}`,`a "${le}" chart reads "geometry" from column ${JSON.stringify(de.col)}, which is not a geometry column, so no row could be placed. Import '@toclocoinc/lattice-grid/modules/geometry' and declare the column type: 'geometry'.`)}const Re=new Set(["markermap","bubblemap","choropleth"])}),Qe("packages/modules/charts/network.js",function(o,X){"use strict";Object.defineProperty(o,"ITERATIONS",{enumerable:!0,get:function(){return c}}),Object.defineProperty(o,"LINK_GAP",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"ICON_RADIUS",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"sequence",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"layoutNetwork",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"glyphFor",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"glyphTransform",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"offsetParallel",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"drawNetwork",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"emphasiseNetwork",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"nodeAt",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"linkAt",{enumerable:!0,get:function(){return h}});const q=X("packages/modules/charts/frame.js").Pool,be=X("packages/modules/charts/scheme.js").resolveScheme,me=X("packages/modules/charts/svg.js"),te=me.attrs,J=me.path,W=me.round,ie=me.setText,y=X("packages/modules/charts/styles.js").NS,U=X("packages/modules/charts/typography.js"),D=U.applySize,T=U.truncateTo,B=X("packages/modules/charts/rulecolour.js"),_=B.ruleColour,$=B.ruleLegend,s=X("packages/core/src/internal/util.js").warnOnce,c=220,k=2400,R=.006,I=.015,z=4,Y=10;function re(a){let d=a>>>0||1;return()=>(d^=d<<13,d>>>=0,d^=d>>17,d^=d<<5,d>>>=0,d/4294967296)}function ee(a){const{nodes:d,links:u,plot:m}=a;if(!d.length)return d;const O=re(d.length*2654435761),A=m.left+m.width/2,w=m.top+m.height/2,g=Math.min(m.width,m.height)/3;for(const v of d){const F=O()*Math.PI*2,b=g*(.35+O()*.65);v.x=A+Math.cos(F)*b,v.y=w+Math.sin(F)*b,v.vx=0,v.vy=0}for(const v of d)v.pinned=Number.isFinite(v.fx)&&Number.isFinite(v.fy),v.pinned&&(v.x=m.left+Math.max(0,Math.min(1,v.fx))*m.width,v.y=m.top+Math.max(0,Math.min(1,v.fy))*m.height);const f=a.iterations||c;for(let v=0;v<f;v++){const F=1-v/f;for(let b=0;b<d.length;b++){const e=d[b];for(let i=b+1;i<d.length;i++){const n=d[i];let t=e.x-n.x,r=e.y-n.y,l=Math.sqrt(t*t+r*r);l<.01&&(t=b-i||1,r=1,l=Math.sqrt(t*t+r*r));const L=k/(l*l),M=t/l*L,C=r/l*L;e.vx+=M,e.vy+=C,n.vx-=M,n.vy-=C}}for(const b of u){const e=b.source,i=b.target;if(e===i)continue;const n=i.x-e.x,t=i.y-e.y,r=R*(b.weight||1);e.vx+=n*r,e.vy+=t*r,i.vx-=n*r,i.vy-=t*r}for(const b of d){if(b.pinned){b.vx=0,b.vy=0;continue}b.vx+=(A-b.x)*I,b.vy+=(w-b.y)*I,b.x+=b.vx*F*.08,b.y+=b.vy*F*.08,b.vx*=.82,b.vy*=.82,b.x=Math.max(m.left+8,Math.min(m.right-8,b.x)),b.y=Math.max(m.top+8,Math.min(m.bottom-8,b.y))}}return d}function H(a,d){if(!d)return null;const u=a&&a.icons;if(!u||typeof u.get!="function")return s(`chart:icons:${d}`,`A network node asked for the icon '${d}', but this grid publishes no icon registry — a headless grid has no sprites. The node drew as a plain disc.`),null;const m=u.get(d);return m||(s(`chart:icon:${d}`,`Unknown icon '${d}' on a network node; drew a plain disc instead. Register it with registerIcon or config.icons, or name a built-in.`),null)}function pe(a,d){const u=String(a.viewBox||"0 0 16 16").trim().split(/[\s,]+/).map(Number),[m,O,A,w]=u.length===4&&u.every(Number.isFinite)?u:[0,0,16,16],g=Math.max(A||16,w||16),f=d.size/g,v=d.x-A*f/2,F=d.y-w*f/2;return`translate(${W(v-m*f)} ${W(F-O*f)}) scale(${W(f)})`}function x(a){const d=new Map;for(const u of a){const m=u.pair||`${u.source.key}\0${u.target.key}`;d.has(m)||d.set(m,[]),d.get(m).push(u)}for(const u of d.values()){const m=u.length;for(let O=0;O<m;O++){const A=u[O],w=A.source,g=A.target,f=g.x-w.x,v=g.y-w.y,F=Math.sqrt(f*f+v*v)||1,b=F?-v/F:0,e=F?f/F:1,i=(O-(m-1)/2)*z;A.offset=i,A.bundled=m>1,A.line={x1:w.x+b*i,y1:w.y+e*i,x2:g.x+b*i,y2:g.y+e*i}}}}function Q(a){const d=a.scheme||be(),{plot:u,bound:m}=a;for(const l of["grid","axis","rules","labels"])new q(a.groups[l]).finish();const O=m.nodes,A=m.links.map(l=>({...l,weight:l.value}));if(!O.length)return{nodes:[],links:[],legend:[]};const w=A.reduce((l,L)=>Math.max(l,L.value),0)||1;for(const l of A)l.weight=l.value/w;ee({nodes:O,links:A,plot:u,iterations:a.iterations}),x(A);const g=m.measure&&m.measure.col||null,f=new Set;for(const l of A)l.colour=_({grid:a.grid,col:g,value:l.value}),l.colour&&f.add(l.colour);const v=O.reduce((l,L)=>Math.max(l,L.in+L.out),0)||1,F=new q(a.groups.marks),b=Number.isFinite(a.linkWidth)&&a.linkWidth>0?Number(a.linkWidth):null;for(const l of A){l.drawnWidth=b===null?.5+l.weight*3:b;const L=F.next("path",`${y}__edge ${y}__mark`);te(L,{d:J(["M",W(l.line.x1),W(l.line.y1),"L",W(l.line.x2),W(l.line.y2)]),style:l.colour?`stroke:${l.colour};stroke-opacity:1`:null,"stroke-width":W(l.drawnWidth),fill:"none"}),l.el=L}for(const l of O){const L=(l.in+l.out)/v,M=l.icon||a.icon||null;l.glyph=H(a.grid,M),l.r=4+Math.sqrt(L)*12,l.glyph&&(l.r=Math.max(l.r,Y));const C=F.next("circle",`${y}__node ${y}__mark`);te(C,{cx:W(l.x),cy:W(l.y),r:W(l.r),fill:d.series(l.index),"data-node":l.key}),l.el=C}F.finish();const e=new q(a.groups.overlay),i=[];for(const l of O){if(!l.glyph){l.glyphEls=[];continue}const L=l.glyph.paint==="stroke",M=pe(l.glyph,{x:l.x,y:l.y,size:l.r*1.3});l.glyphEls=l.glyph.paths.map(C=>{const ne=e.next("path",`${y}__node-icon${L?` ${y}__node-icon--stroke`:""}`);return te(ne,{d:C,transform:M}),ne}),i.push(...l.glyphEls)}const n=a.typography&&a.typography.small||a.fontSize,t=O.filter(l=>l.declared),r=O.filter(l=>!l.declared).sort((l,L)=>L.in+L.out-(l.in+l.out)).slice(0,12);for(const l of[...t,...r]){const L=e.next("text",`${y}__flow-label`);D(L,n),te(L,{x:W(l.x),y:W(l.y+l.r+n),"text-anchor":"middle"}),ie(L,T(l.label,90,n)),l.labelEl=L}return e.finish(),{nodes:O,links:A,glyphs:i,legend:$({grid:a.grid,col:g,colours:f})}}function ce(a){const d=a.drawn||{},u=a.keys||new Set,m=u.size>0;let O=0;const A=new Set;for(const w of d.links||[]){const g=m&&(w.rowKeys||[]).some(f=>u.has(f));g&&(O++,A.add(w.source),A.add(w.target)),E(w.el,m&&!g)}for(const w of d.nodes||[]){const g=A.has(w);g&&O++,E(w.el,m&&!g);for(const f of w.glyphEls||[])E(f,m&&!g)}return O}function E(a,d){!a||!a.setAttribute||(d?a.setAttribute("data-dim","true"):a.removeAttribute("data-dim"))}function V(a){const d=typeof a.slack=="number"?a.slack:2;let u=null,m=1/0;for(const O of a.nodes||[]){if(typeof O.x!="number"||typeof O.y!="number")continue;const A=a.x-O.x,w=a.y-O.y,g=Math.sqrt(A*A+w*w);g<=(O.r||0)+d&&g<m&&(m=g,u=O)}return u}function h(a){let d=null,u=1/0;for(const m of a.links||[]){const O=m.line,A=O?{x:O.x1,y:O.y1}:m.source,w=O?{x:O.x2,y:O.y2}:m.target;if(!A||!w||typeof A.x!="number"||typeof w.x!="number")continue;const g=w.x-A.x,f=w.y-A.y,v=g*g+f*f,F=v?Math.max(0,Math.min(1,((a.x-A.x)*g+(a.y-A.y)*f)/v)):0,b=a.x-(A.x+F*g),e=a.y-(A.y+F*f),i=Math.sqrt(b*b+e*e),n=Number.isFinite(m.drawnWidth)?m.drawnWidth:.5+(m.weight||0)*3,t=m.bundled?Math.min(Math.max(2,n/2),z/2):Math.max(3,n/2);i<=t&&i<u&&(u=i,d=m)}return d}}),Qe("packages/modules/charts/flow.js",function(o,X){"use strict";Object.defineProperty(o,"assignDepths",{enumerable:!0,get:function(){return z}}),Object.defineProperty(o,"layoutSankey",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"ribbon",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"drawSankey",{enumerable:!0,get:function(){return ee}}),Object.defineProperty(o,"layoutChord",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"drawChord",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"describeLink",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"flowNodeAt",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"ribbonAt",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"chordArcAt",{enumerable:!0,get:function(){return E}}),Object.defineProperty(o,"chordRibbonAt",{enumerable:!0,get:function(){return V}}),Object.defineProperty(o,"chordPolygon",{enumerable:!0,get:function(){return h}});const q=X("packages/modules/charts/frame.js").Pool,be=X("packages/modules/charts/format.js").measureText,te=X("packages/modules/charts/scheme.js").resolveScheme,J=X("packages/modules/charts/svg.js"),W=J.attrs,ie=J.insideRings,S=J.path,y=J.round,U=J.setText,T=X("packages/modules/charts/styles.js").NS,B=X("packages/modules/charts/typography.js"),_=B.applySize,$=B.textWidth,p=B.truncateTo,s=Math.PI*2,c=12,k=8,R=-Math.PI/2,I=16;function z(a,d){for(const w of a)w.depth=0;const u=a.length+1;for(let w=0;w<u;w++){let g=!1;for(const f of d){if(f.source===f.target)continue;const v=f.source.depth+1;v>f.target.depth&&v<u&&(f.target.depth=v,g=!0)}if(!g)break}const m=a.reduce((w,g)=>Math.max(w,g.depth),0),O=new Set,A=new Set;for(const w of d)w.source!==w.target&&(O.add(w.source),A.add(w.target));for(const w of a)!O.has(w)&&A.has(w)&&(w.depth=m);return m+1}function Y(a){const{nodes:d,links:u,plot:m}=a,O=z(d,u),A=a.nodeWidth||c,w=new Map;for(const b of d)w.has(b.depth)||w.set(b.depth,[]),w.get(b.depth).push(b);let g=0;for(const b of w.values()){const e=b.reduce((n,t)=>n+Math.max(t.in,t.out),0),i=Math.max(0,b.length-1)*k;e>0&&(g=Math.max(g,e/Math.max(1,m.height-i)))}const f=g>0?1/g:0,v=O>1?(m.width-A)/(O-1):0;for(const[b,e]of w){e.sort((r,l)=>Math.max(l.in,l.out)-Math.max(r.in,r.out));const i=e.map(r=>Math.max(1,Math.max(r.in,r.out)*f)),n=i.reduce((r,l)=>r+l,0)+(e.length-1)*k;let t=m.top+Math.max(0,(m.height-n)/2);e.forEach((r,l)=>{r.x=m.left+b*v,r.width=A,r.y=t,r.height=i[l],r.inAt=t,r.outAt=t,t+=i[l]+k})}const F=u.slice().sort((b,e)=>b.source.y-e.source.y||e.value-b.value);for(const b of F){const e=Math.max(1,b.value*f);b.thickness=e,b.y0=b.source.outAt+e/2,b.source.outAt+=e}for(const b of F.slice().sort((e,i)=>e.target.y-i.target.y||i.value-e.value))b.y1=b.target.inAt+b.thickness/2,b.target.inAt+=b.thickness;return{columns:O,scale:f}}function re(a){const d=a.source.x+a.source.width,u=a.target.x,m=(d+u)/2,O=a.thickness/2;return S(["M",y(d),y(a.y0-O),"C",y(m),y(a.y0-O),y(m),y(a.y1-O),y(u),y(a.y1-O),"L",y(u),y(a.y1+O),"C",y(m),y(a.y1+O),y(m),y(a.y0+O),y(d),y(a.y0+O),"Z"])}function ee(a){const d=a.scheme||te(),{plot:u,bound:m}=a;for(const v of["grid","axis","rules","labels"])new q(a.groups[v]).finish();const O=m.nodes,A=m.links;if(!O.length||!A.length)return{nodes:[],links:[]};Y({nodes:O,links:A,plot:u});const w=new q(a.groups.marks);for(const v of A){const F=w.next("path",`${T}__ribbon ${T}__mark`);W(F,{d:re(v),fill:d.series(v.source.index),"data-link":`${v.source.key}->${v.target.key}`})}for(const v of O)W(w.next("rect",`${T}__node ${T}__mark`),{x:y(v.x),y:y(v.y),width:y(v.width),height:y(v.height),fill:d.series(v.index),"data-node":v.key});w.finish();const g=new q(a.groups.overlay),f=a.typography&&a.typography.small||a.fontSize;for(const v of O){const F=v.x<u.left+u.width/2,b=g.next("text",`${T}__flow-label`);_(b,f),W(b,{x:y(F?v.x+v.width+4:v.x-4),y:y(v.y+v.height/2),"text-anchor":F?"start":"end","dominant-baseline":"middle"});const e=F?u.right-(v.x+v.width)-6:v.x-u.left-6;U(b,p(v.label,Math.max(0,e),f))}return g.finish(),{nodes:O,links:A}}function H(a){const{nodes:d,links:u}=a,m=new Map;for(const b of d)m.set(b.key,0);for(const b of u)m.set(b.source.key,(m.get(b.source.key)||0)+b.value),m.set(b.target.key,(m.get(b.target.key)||0)+b.value);const O=[...m.values()].reduce((b,e)=>b+e,0);if(O<=0)return{arcs:[],ribbons:[]};const A=Math.min(.04,s/(d.length*8||1)),w=s-A*d.length,g=[];let f=-Math.PI/2;const v=new Map;for(const b of d){const i=(m.get(b.key)||0)/O*w;g.push({node:b,from:f,to:f+i}),v.set(b.key,f),f+=i+A}const F=[];for(const b of u.slice().sort((e,i)=>i.value-e.value)){const e=b.value/O*w,i=v.get(b.source.key),n=v.get(b.target.key);v.set(b.source.key,i+e),v.set(b.target.key,n+e),F.push({link:b,source:{from:i,to:i+e},target:{from:n,to:n+e}})}return{arcs:g,ribbons:F}}function pe(a){const d=a.scheme||te(),{plot:u,bound:m}=a;for(const t of["grid","axis","rules","labels"])new q(a.groups[t]).finish();const O=u.left+u.width/2,A=u.top+u.height/2,w=a.typography&&a.typography.small||a.fontSize,g=Math.max(...m.nodes.map(t=>$(t.label,w)),0),f=Math.max(10,Math.min(u.width,u.height)/2-Math.min(g+8,90)),v=f*.92,{arcs:F,ribbons:b}=H({nodes:m.nodes,links:m.links,cx:O,cy:A,radius:f}),e=(t,r)=>[O+r*Math.cos(t),A+r*Math.sin(t)],i=new q(a.groups.marks);for(const{link:t,source:r,target:l}of b){const[L,M]=e(r.from,v),[C,ne]=e(r.to,v),[ue,ge]=e(l.from,v),[xe,Ce]=e(l.to,v);W(i.next("path",`${T}__ribbon ${T}__mark`),{d:S(["M",y(L),y(M),"A",y(v),y(v),0,0,1,y(C),y(ne),"Q",y(O),y(A),y(ue),y(ge),"A",y(v),y(v),0,0,1,y(xe),y(Ce),"Q",y(O),y(A),y(L),y(M),"Z"]),fill:d.series(t.source.index),"fill-opacity":.55,"data-link":`${t.source.key}->${t.target.key}`})}for(const t of F){const[r,l]=e(t.from,f),[L,M]=e(t.to,f),[C,ne]=e(t.to,v),[ue,ge]=e(t.from,v),xe=t.to-t.from>Math.PI?1:0;W(i.next("path",`${T}__node ${T}__mark`),{d:S(["M",y(r),y(l),"A",y(f),y(f),0,xe,1,y(L),y(M),"L",y(C),y(ne),"A",y(v),y(v),0,xe,0,y(ue),y(ge),"Z"]),fill:d.series(t.node.index),"data-node":t.node.key})}i.finish();const n=new q(a.groups.overlay);for(const t of F){const r=(t.from+t.to)/2,[l,L]=e(r,f+6),M=n.next("text",`${T}__flow-label`);_(M,w);const C=Math.cos(r)>=0;W(M,{x:y(l),y:y(L),"text-anchor":C?"start":"end","dominant-baseline":"middle"}),U(M,t.node.label)}return n.finish(),{arcs:F,ribbons:b,ring:{cx:O,cy:A,inner:v,radius:f}}}function x(a,d){return`${a.source.label} → ${a.target.label}: ${be(a.value,d)}`}function Q(a){for(const d of a.nodes||[])if(!(typeof d.x!="number"||typeof d.width!="number")&&a.x>=d.x&&a.x<=d.x+d.width&&a.y>=d.y&&a.y<=d.y+d.height)return d;return null}function ce(a){let d=null,u=1/0;for(const m of a.links||[]){const O=m.source,A=m.target;if(!O||!A||typeof m.y0!="number")continue;const w=O.x+O.width,g=A.x;if(a.x<Math.min(w,g)||a.x>Math.max(w,g))continue;const f=(w+g)/2,v=r=>{const l=1-r;return l*l*l*w+3*l*l*r*f+3*l*r*r*f+r*r*r*g};let F=0,b=1;for(let r=0;r<24;r++){const l=(F+b)/2;v(l)<a.x?F=l:b=l}const e=(F+b)/2,i=1-e,n=i*i*i*m.y0+3*i*i*e*m.y0+3*i*e*e*m.y1+e*e*e*m.y1,t=Math.max(1,m.thickness||1)/2;Math.abs(a.y-n)<=t&&(m.thickness||1)<u&&(u=m.thickness||1,d=m)}return d}function E(a){const d=a.ring;if(!d)return null;const u=a.x-d.cx,m=a.y-d.cy,O=Math.sqrt(u*u+m*m);if(O<d.inner||O>d.radius)return null;let A=Math.atan2(m,u);for(;A<R;)A+=s;for(;A>=R+s;)A-=s;for(const w of a.arcs||[])if(A>=w.from&&A<w.to)return w;return null}function V(a){const d=a.ring;if(!d)return null;const u=a.x-d.cx,m=a.y-d.cy;if(Math.sqrt(u*u+m*m)>d.inner)return null;for(const O of a.ribbons||[])if(ie([h(O,d)],a.x,a.y))return O;return null}function h(a,d){const{cx:u,cy:m,inner:O}=d,A=v=>[u+O*Math.cos(v),m+O*Math.sin(v)],w=[],g=(v,F)=>{for(let b=0;b<=I;b++)w.push(A(v+(F-v)*b/I))},f=(v,F)=>{for(let b=1;b<I;b++){const e=b/I,i=1-e;w.push([i*i*v[0]+2*i*e*u+e*e*F[0],i*i*v[1]+2*i*e*m+e*e*F[1]])}};return g(a.source.from,a.source.to),f(A(a.source.to),A(a.target.from)),g(a.target.from,a.target.to),f(A(a.target.to),A(a.source.from)),w}}),Qe("packages/modules/charts/hit.js",function(o,X){"use strict";Object.defineProperty(o,"valueText",{enumerable:!0,get:function(){return k}}),Object.defineProperty(o,"ownsGeometry",{enumerable:!0,get:function(){return H}}),Object.defineProperty(o,"resolveHit",{enumerable:!0,get:function(){return pe}});const q=X("packages/modules/charts/format.js").measureText,be=X("packages/modules/charts/treemap.js").tileAt,me=X("packages/modules/charts/geo.js"),te=me.markerAt,J=me.regionAt,ie=X("packages/modules/charts/matrix.js").cellAt,S=X("packages/modules/charts/network.js"),y=S.linkAt,U=S.nodeAt,D=X("packages/modules/charts/flow.js"),T=D.chordArcAt,B=D.chordRibbonAt,_=D.flowNodeAt,$=D.ribbonAt,p=" → ",s=" – ",c=" › ";function k(x,Q,ce){const E=q(x,ce);if(!Q||typeof x!="number"||!Number.isFinite(x))return E;const V=x/Q;return Number.isFinite(V)?`${E} (${ce.number(V,{style:"percent",maximumFractionDigits:1})})`:E}function R(x,Q){const ce=x.item.node,E=Q.bound.root&&Q.bound.root.total||0,V=Array.isArray(x.path)?[...x.path]:[ce.label];return{heading:V.length>1?V.join(c):ce.label,rows:[{label:Q.bound.measure.title,value:k(ce.total,E,Q.grid.messages),colour:Q.scheme.series(x.item.index||0)}],datum:{label:ce.label,value:ce.total,category:ce.value,column:Q.bound.measure.col&&Q.spec.x||null,series:null,depth:x.depth,path:V,rowKeys:ce.rowKey?[ce.rowKey]:[]}}}function I(x,Q,ce){const E=Q.reduce((V,h)=>V+(h.value||0),0);return{heading:x.label||x.code,rows:[{label:ce.bound.measure.title,value:typeof x.text=="string"?x.text:k(x.value,E,ce.grid.messages),colour:ce.scheme.series(0)}],datum:{label:x.label||x.code,value:x.value,category:x.code,column:ce.spec.code||ce.spec.x||null,series:null,path:[x.label||x.code],rowKeys:Array.isArray(x.rowKeys)?[...x.rowKeys]:[]}}}function z(x,Q,ce){const E=ce.spec.value||ce.spec.y||null,V=E?ce.grid.columns.get(E):null,h=u=>`${Number(u).toFixed(4)}°`,a=(Q.legend||[]).find(u=>u.colour===x.fill)||null,d=[{label:V&&V.title||E||"",value:x.text||"",colour:x.fill},{label:"",value:`${h(x.lat)}, ${h(x.lon)}`,colour:"transparent"}];return a&&a.label&&d.push({label:"",value:a.label,colour:x.fill}),{heading:x.label||x.text||"",rows:d,datum:{label:x.label||x.text||"",value:x.value,category:x.value,column:E,series:null,path:[x.label||x.text||""],lon:x.lon,lat:x.lat,status:a?a.label:null,rowKeys:x.rowKey?[x.rowKey]:[]}}}function Y(x,Q){const ce=h=>{const a=Q.grid.columns.get(h);return a&&a.title||h},E=ce(x.a),V=ce(x.b);return{heading:`${E} × ${V}`,rows:[{label:Q.spec.method==="spearman"?"ρ":"r",value:typeof x.r=="number"&&Number.isFinite(x.r)?x.r.toFixed(2):"",colour:Q.scheme.series(0)}],datum:{label:`${E} × ${V}`,value:typeof x.r=="number"?x.r:null,category:null,column:null,series:null,path:[E,V],rowKeys:[]}}}function re(x,Q){const ce=[];for(const V of Q.drawn&&Q.drawn.links||[])if(!(V.source!==x&&V.target!==x))for(const h of V.rowKeys||[])ce.includes(h)||ce.push(h);const E=Math.max(x.in||0,x.out||0);return{heading:x.label,rows:[{label:Q.bound.measure.title,value:q(E,Q.grid.messages),colour:Q.scheme.series(x.index||0)}],datum:{label:x.label,value:E,category:x.value===void 0?x.key:x.value,column:null,series:null,path:[x.label],rowKeys:ce}}}function ee(x,Q){const ce=`${x.source.label}${x.undirected?s:p}${x.target.label}`;return{heading:ce,rows:[{label:Q.bound.measure.title,value:k(x.value,x.undirected?0:Q.bound.total||0,Q.grid.messages),colour:x.colour||Q.scheme.series(x.source.index||0)}],datum:{label:ce,value:x.value,category:null,column:null,series:null,path:[x.source.label,x.target.label],rowKeys:Array.isArray(x.rowKeys)?[...x.rowKeys]:[]}}}function H(x){return x?!!(Array.isArray(x.tiles)||Array.isArray(x.regions)||Array.isArray(x.markers)||Array.isArray(x.cells)&&Array.isArray(x.columns)||Array.isArray(x.ribbons)&&x.ring||Array.isArray(x.nodes)&&Array.isArray(x.links)):!1}function pe(x){const Q=x.drawn;if(!Q||!x.bound||!H(Q))return null;const{x:ce,y:E}=x.at;if(Array.isArray(Q.tiles)){const V=be({tiles:Q.tiles,x:ce,y:E});return V?R(V,x):null}if(Array.isArray(Q.regions)){const V=J({regions:Q.regions,x:ce,y:E});return V?I(V,Q.regions,x):null}if(Array.isArray(Q.markers)){const V=te({markers:Q.markers,x:ce,y:E});return V?z(V,Q,x):null}if(Array.isArray(Q.cells)&&Array.isArray(Q.columns)){const V=ie({cells:Q.cells,x:ce,y:E});return V?Y(V,x):null}if(Array.isArray(Q.ribbons)&&Q.ring){const V=B({ribbons:Q.ribbons,ring:Q.ring,x:ce,y:E});if(V)return ee(V.link,x);const h=T({arcs:Q.arcs,ring:Q.ring,x:ce,y:E});return h?re(h.node,x):null}if(Array.isArray(Q.nodes)&&Array.isArray(Q.links)){const V=Q.nodes.some(d=>typeof d.r=="number"),h=V?U({nodes:Q.nodes,x:ce,y:E}):_({nodes:Q.nodes,x:ce,y:E});if(h)return re(h,x);const a=V?y({links:Q.links,x:ce,y:E}):$({links:Q.links,x:ce,y:E});return a?ee(a,x):null}return null}}),Qe("packages/modules/charts/polar.js",function(o,X){"use strict";Object.defineProperty(o,"arcBand",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"drawRadar",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"drawGauge",{enumerable:!0,get:function(){return ee}});const q=X("packages/modules/charts/frame.js").Pool,be=X("packages/modules/charts/format.js").measureText,me=X("packages/modules/charts/scale.js"),te=me.isNumber,J=me.measureDomain,W=X("packages/modules/charts/svg.js"),ie=W.attrs,S=W.path,y=W.round,U=W.setText,T=X("packages/modules/charts/styles.js").NS,_=X("packages/modules/charts/scheme.js").resolveScheme,$=X("packages/modules/charts/labels.js"),p=$.drawAnchoredLabels,s=$.labelText,c=Math.PI*2,k=4,R=c*2/3,I=Math.PI/2+(c-R)/2;function z(H,pe,x,Q){const ce=Q-Math.PI/2;return[H+x*Math.cos(ce),pe+x*Math.sin(ce)]}function Y(H){const pe=H.to-H.from;if(pe<=0)return"";const x=Math.max(0,H.r-H.width),Q=pe>Math.PI?1:0,[ce,E]=z(H.cx,H.cy,H.r,H.from),[V,h]=z(H.cx,H.cy,H.r,H.to),[a,d]=z(H.cx,H.cy,x,H.to),[u,m]=z(H.cx,H.cy,x,H.from);return S(["M",y(ce),y(E),"A",y(H.r),y(H.r),0,Q,1,y(V),y(h),"L",y(a),y(d),"A",y(x),y(x),0,Q,0,y(u),y(m),"Z"])}function re(H){const pe=H.scheme||_(),{plot:x,bound:Q}=H;new q(H.groups.grid).finish(),new q(H.groups.axis).finish(),new q(H.groups.rules).finish(),new q(H.groups.labels).finish();const ce=x.left+x.width/2,E=x.top+x.height/2,V=Math.max(0,Math.min(x.width,x.height)/2-H.fontSize*2),h=Q.labels,a=Q.series.filter(f=>!H.hidden.has(f.key)),d=[];for(const f of a)for(const v of f.points)d.push(v.y);const u=J(d,{zero:!0}),m=h.length?c/h.length:c,O=f=>{const v=u.max-u.min||1;return Math.max(0,(f-u.min)/v*V)},A=new q(H.groups.grid);for(let f=1;f<=k;f++){const v=V*f/k,F=h.map((b,e)=>z(ce,E,v,e*m));ie(A.next("path",`${T}__web`),{d:F.length?S([...F.flatMap(([b,e],i)=>[i?"L":"M",y(b),y(e)]),"Z"]):"",fill:"none"})}for(let f=0;f<h.length;f++){const[v,F]=z(ce,E,V,f*m);ie(A.next("path",`${T}__web`),{d:S(["M",y(ce),y(E),"L",y(v),y(F)]),fill:"none"})}A.finish();const w=new q(H.groups.marks);for(const f of a){const v=[];for(let e=0;e<h.length;e++){const i=f.points[e],n=te(i&&i.y)?i.y:u.min,[t,r]=z(ce,E,O(n),e*m);v.push([y(t),y(r)]),i&&(i.px=y(t),i.py=y(r))}const F=v.length?S([...v.flatMap(([e,i],n)=>[n?"L":"M",e,i]),"Z"]):"",b=pe.series(f.index);ie(w.next("path",`${T}__radar-fill ${T}__mark`),{d:F,fill:b,"data-series":f.index}),ie(w.next("path",`${T}__radar-line ${T}__mark`),{d:F,stroke:b,fill:"none","data-series":f.index})}w.finish();const g=new q(H.groups.overlay);for(let f=0;f<h.length;f++){const[v,F]=z(ce,E,V+H.fontSize,f*m),b=g.next("text",`${T}__tick`),e=Math.abs(v-ce)<1?"middle":v>ce?"start":"end";ie(b,{x:y(v),y:y(F),"text-anchor":e,"dominant-baseline":"middle"}),U(b,h[f])}if(g.finish(),H.labels&&H.labels.show){const f=H.typography&&H.typography.small||H.fontSize||11,v=[];for(const F of a)for(const b of F.points){if(!b||b.px===void 0||!te(b.y))continue;const e=b.px-ce,i=b.py-E,n=Math.hypot(e,i)||1;v.push({x:y(b.px+e/n*(f*.8)),y:y(b.py+i/n*(f*.8)),text:s(b.y,H.labels,H.grid)})}p({group:H.groups.labels,size:f,minGap:H.labels.minGap,anchors:v,plot:x})}return{centre:{x:ce,y:E,r:V},series:a,axes:h}}function ee(H){const pe=H.scheme||_(),{plot:x,bound:Q}=H;new q(H.groups.grid).finish(),new q(H.groups.axis).finish(),new q(H.groups.rules).finish(),new q(H.groups.labels).finish();const ce=Q.series[0],V=(ce?ce.points.filter(b=>te(b.y)):[]).reduce((b,e)=>b+e.y,0),h=te(H.min)?H.min:0,a=te(H.max)?H.max:Math.max(V,1),d=a-h||1,u=Math.min(1,Math.max(0,(V-h)/d)),m=x.left+x.width/2,O=x.top+x.height/2,A=Math.max(0,Math.min(x.width,x.height)/2-4),w=Math.max(6,A*.24),g=new q(H.groups.marks);if(ie(g.next("path",`${T}__gauge-track`),{d:Y({cx:m,cy:O,r:A,width:w,from:I,to:I+R})}),ie(g.next("path",`${T}__gauge-value ${T}__mark`),{d:Y({cx:m,cy:O,r:A,width:w,from:I,to:I+R*u}),fill:pe.series(0)}),te(H.target)){const b=Math.min(1,Math.max(0,(H.target-h)/d)),e=I+R*b,[i,n]=z(m,O,A-w,e),[t,r]=z(m,O,A,e);ie(g.next("path",`${T}__gauge-target`),{d:S(["M",y(i),y(n),"L",y(t),y(r)]),fill:"none"})}g.finish();const f=new q(H.groups.overlay),v=f.next("text",`${T}__gauge-reading`);ie(v,{x:y(m),y:y(O),"text-anchor":"middle","dominant-baseline":"middle"}),U(v,be(V,H.grid.messages));const F=f.next("text",`${T}__gauge-caption`);return ie(F,{x:y(m),y:y(O+H.fontSize*1.6),"text-anchor":"middle","dominant-baseline":"middle"}),U(F,Q.measure.title||""),f.finish(),{value:V,domain:{min:h,max:a}}}}),Qe("packages/modules/charts/multiples.js",function(o,X){"use strict";Object.defineProperty(o,"MAX_PANELS",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"panelGrid",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"panelRects",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"splitPanels",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"sharedDomain",{enumerable:!0,get:function(){return me}});const ye=24;function q(te,J){if(te<=1)return{columns:1,rows:1};const W=(J.width||1)/(J.height||1);let ie=Math.max(1,Math.round(Math.sqrt(te*W)));ie=Math.min(ie,te);const S=Math.ceil(te/ie);return{columns:ie,rows:S}}function j(te){const J=Math.min(te.count,ye),W=te.gap===void 0?10:te.gap,ie=te.titleHeight===void 0?14:te.titleHeight,{columns:S,rows:y}=q(J,te.plot),U=(te.plot.width-W*(S-1))/S,D=(te.plot.height-W*(y-1))/y,T=[];for(let B=0;B<J;B++){const _=B%S,$=Math.floor(B/S);T.push({index:B,x:te.plot.left+_*(U+W),y:te.plot.top+$*(D+W)+ie,width:Math.max(0,U),height:Math.max(0,D-ie)})}return T}function be(te){return te.series.map((J,W)=>({label:J.label,key:J.key,index:W,bound:{...te,series:[{...J,index:W}]}}))}function me(te,J,W){const ie=[];for(const S of te.series)for(const y of S.points)ie.push(y.y);return W(ie,{zero:J})}}),Qe("packages/modules/charts/stream.js",function(o,X){"use strict";Object.defineProperty(o,"wiggleBaseline",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"drawStream",{enumerable:!0,get:function(){return x}}),Object.defineProperty(o,"drawMarimekko",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(o,"drawViolin",{enumerable:!0,get:function(){return ce}});const ye=X("packages/modules/charts/axis.js"),q=ye.drawAxisLines,j=ye.drawCategoryAxis,be=ye.drawMeasureAxis,me=X("packages/modules/charts/distribution.js"),te=me.density,J=me.distributionDomain,W=me.summarise,ie=me.valuesByCategory,S=X("packages/modules/charts/frame.js"),y=S.Pool,U=S.shouldRotate,T=X("packages/modules/charts/format.js").formatters,B=X("packages/modules/charts/scale.js"),_=B.bandScale,$=B.isNumber,p=B.linearScale,s=B.measureDomain,k=X("packages/modules/charts/scheme.js").resolveScheme,R=X("packages/modules/charts/svg.js"),I=R.attrs,z=R.path,Y=R.round,ee=X("packages/modules/charts/styles.js").NS,H=32;function pe(E){const V=[];let h=0;for(let a=0;a<E.length;a++){const d=E[a],u=d.reduce((w,g)=>w+g,0);if(a===0){h=-u/2,V.push(h);continue}const m=E[a-1];let O=0;const A=d.length;for(let w=0;w<A;w++){let g=0;for(let f=0;f<w;f++)g+=(d[f]||0)-(m[f]||0);O+=(A-w-.5)*((d[w]||0)-(m[w]||0))+g*0}h-=A>0?O/A:0,V.push(h)}return V}function x(E){const V=E.scheme||k(),{plot:h,bound:a}=E;new y(E.groups.grid).finish(),new y(E.groups.rules).finish(),new y(E.groups.labels).finish();const d=a.series.filter(v=>!E.hidden.has(v.key)),u=a.categories.map((v,F)=>d.map(b=>{const e=b.points[F];return $(e&&e.y)?Math.max(0,e.y):0})),m=pe(u),O=[];u.forEach((v,F)=>{O.push(m[F]),O.push(m[F]+v.reduce((b,e)=>b+e,0))});const A=s(O,{zero:!1,nice:!1}),w=p(A,[h.bottom,h.top]),g=_(a.categories,[h.left,h.right],0),f=new y(E.groups.marks);return d.forEach((v,F)=>{const b=[],e=[];u.forEach((n,t)=>{let r=m[t];for(let L=0;L<F;L++)r+=n[L];const l=Y(g.centre(a.categories[t]));e.push([l,Y(w.of(r))]),b.push([l,Y(w.of(r+n[F]))])});const i=[];b.forEach(([n,t],r)=>i.push(r?"L":"M",n,t));for(let n=e.length-1;n>=0;n--)i.push("L",e[n][0],e[n][1]);i.push("Z"),I(f.next("path",`${ee}__stream ${ee}__mark`),{d:z(i),fill:V.series(v.index),"data-series":v.index})}),f.finish(),j({group:E.groups.overlay,plot:h,scale:g,labels:a.labels,fontSize:E.typography&&E.typography.small||E.fontSize,rotated:U(a.labels,g.step,E.fontSize,(E.axis&&E.axis.x||{}).every),config:E.axis&&E.axis.x||{}}),{xScale:g,yScale:w,series:d}}function Q(E){const V=E.scheme||k(),{plot:h,bound:a}=E,d=a.series.filter(e=>!E.hidden.has(e.key)),u=a.categories.map((e,i)=>d.reduce((n,t)=>{const r=t.points[i];return n+($(r&&r.y)?Math.abs(r.y):0)},0)),m=u.reduce((e,i)=>e+i,0);if(m<=0)return{series:d,columns:[]};const O=2,A=h.width-O*Math.max(0,a.categories.length-1),w=p({min:0,max:100},[h.bottom,h.top]);be({gridGroup:E.groups.grid,axisGroup:E.groups.axis,plot:h,scale:w,format:T(E.grid,{kind:"linear",step:20}),config:E.axis&&E.axis.y||{},grid:E.grid,size:E.typography&&E.typography.small||E.fontSize}),q({group:E.groups.rules,plot:h});const g=new y(E.groups.marks),f=[];let v=h.left;a.categories.forEach((e,i)=>{const n=u[i]/m*A;let t=h.bottom;d.forEach((r,l)=>{const L=r.points[i],M=$(L&&L.y)?Math.abs(L.y):0,ne=(u[i]>0?M/u[i]:0)*h.height;I(g.next("rect",`${ee}__bar ${ee}__mark`),{x:Y(v),y:Y(t-ne),width:Y(Math.max(0,n)),height:Y(Math.max(0,ne)),fill:V.series(r.index),"data-series":r.index,"data-point":i}),L&&(L.px=Y(v+n/2),L.py=Y(t-ne)),t-=ne}),f.push({category:e,label:a.labels[i],x:v,width:n,total:u[i]}),v+=n+O}),g.finish();const F=new y(E.groups.overlay),b=E.typography&&E.typography.small||E.fontSize;for(const e of f){if(e.width<b*2)continue;const i=F.next("text",`${ee}__tick`);i.style.fontSize=`${b}px`,I(i,{x:Y(e.x+e.width/2),y:Y(h.top-2),"text-anchor":"middle"}),i.textContent=e.label}return F.finish(),{series:d,columns:f}}function ce(E){const V=E.scheme||k(),{plot:h,bound:a}=E,d=ie(a),u=[...d.keys()],m=[];for(const f of d.values())for(let v=0;v<f.length;v++)m.push(f[v]);const O=J(m,E.axis),A=p(O,[h.bottom,h.top]),w=_(u,[h.left,h.right],.3);be({gridGroup:E.groups.grid,axisGroup:E.groups.axis,plot:h,scale:A,format:T(E.grid,{kind:"linear",step:(O.max-O.min)/5}),config:E.axis&&E.axis.y||{},grid:E.grid,size:E.typography&&E.typography.small||E.fontSize}),j({group:E.groups.overlay,plot:h,scale:w,labels:u,fontSize:E.typography&&E.typography.small||E.fontSize,rotated:u.length>6,config:E.axis&&E.axis.x||{}}),q({group:E.groups.rules,plot:h});const g=new y(E.groups.marks);return u.forEach((f,v)=>{const F=d.get(f),b=te(F,O,H),e=b.reduce((M,C)=>Math.max(M,C.density),0)||1,i=w.bandwidth/2,n=w.of(f)+i,t=b.map(M=>[Y(n+M.density/e*i),Y(A.of(M.at))]),r=b.map(M=>[Y(n-M.density/e*i),Y(A.of(M.at))]),l=[];t.forEach(([M,C],ne)=>l.push(ne?"L":"M",M,C));for(let M=r.length-1;M>=0;M--)l.push("L",r[M][0],r[M][1]);l.push("Z"),I(g.next("path",`${ee}__violin ${ee}__mark`),{d:z(l),fill:V.series(v),"data-point":v});const L=W(F);L&&I(g.next("path",`${ee}__median ${ee}__mark`),{d:z(["M",Y(n-i*.5),Y(A.of(L.median)),"L",Y(n+i*.5),Y(A.of(L.median))]),stroke:V.series(v),"stroke-width":2,fill:"none"})}),g.finish(),{xScale:w,yScale:A,series:[{key:"",label:a.measure.title,index:0,points:u.map(f=>{const v=W(d.get(f));return{x:f,xKey:f,label:f,y:v?v.median:null,rows:(d.get(f)||[]).length}})}]}}}),Qe("packages/modules/charts/gantt.js",function(o,X){"use strict";Object.defineProperty(o,"readTasks",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(o,"drawGantt",{enumerable:!0,get:function(){return re}});const ye=X("packages/modules/charts/axis.js"),q=ye.drawAxisLines,j=ye.drawBandLabels,be=ye.drawContinuousAxis,te=X("packages/modules/charts/frame.js").Pool,W=X("packages/modules/charts/format.js").formatters,ie=X("packages/modules/charts/scale.js"),S=ie.bandScale,y=ie.timeScale,U=ie.toTime,T=X("packages/modules/charts/scheme.js").resolveScheme,B=X("packages/modules/charts/svg.js"),_=B.attrs,$=B.round,p=B.setText,c=X("packages/modules/charts/styles.js").NS,k=X("packages/modules/charts/typography.js"),R=k.applySize,I=k.truncateTo,z=8;function Y(ee,H,pe){const x=[];let Q=1/0,ce=-1/0;for(const E of pe){const V=U(ee.rows.value(E.key,H.start)),h=U(ee.rows.value(E.key,H.end));if(V===null||h===null)continue;const a=H.label?ee.rows.text(E.key,H.label):E.key,d=H.series?ee.rows.value(E.key,H.series):null;x.push({key:E.key,label:a,group:d,from:Math.min(V,h),to:Math.max(V,h)}),Q=Math.min(Q,V,h),ce=Math.max(ce,V,h)}return{tasks:x,span:x.length?{min:Q,max:ce}:null}}function re(ee){const H=ee.scheme||T(),{plot:pe}=ee,{tasks:x,span:Q}=Y(ee.grid,ee.spec,ee.rows);if(!Q)return{tasks:[],xScale:null,dropped:0};const ce=Math.max(1,Math.floor(pe.height/z)),E=x.slice(0,ce),V=x.length-E.length,h=y({min:Q.min,max:Q.max},[pe.left,pe.right]),a=S(E.map(A=>A.key),[pe.top,pe.bottom],.25),d=ee.typography&&ee.typography.small||ee.fontSize;be({group:ee.groups.overlay,plot:pe,scale:h,format:W(ee.grid,{kind:"time",span:Q.max-Q.min}),config:ee.axis&&ee.axis.x||{},grid:ee.grid,size:d}),j({group:ee.groups.axis,plot:pe,scale:a,labels:E.map(A=>A.label),fontSize:d}),q({group:ee.groups.rules,plot:pe});const u=[...new Set(E.map(A=>String(A.group)))],m=new te(ee.groups.marks);E.forEach((A,w)=>{const g=a.of(A.key),f=h.of(A.from),v=h.of(A.to);_(m.next("rect",`${c}__task ${c}__mark`),{x:$(f),width:$(Math.max(2,v-f)),y:$(g),height:$(a.bandwidth),fill:H.series(A.group===null?0:u.indexOf(String(A.group))),"data-point":w,"data-key":A.key}),A.px=$((f+v)/2),A.py=$(g+a.bandwidth/2)}),m.finish();const O=new te(ee.groups.labels);if(V>0){const A=O.next("text",`${c}__geo-note`);R(A,d),_(A,{x:$(pe.left),y:$(pe.bottom+d+4),"text-anchor":"start"}),p(A,I(ee.grid.messages.t("chart.tasksDropped",{count:V}),pe.width,d))}return O.finish(),{tasks:E,xScale:h,dropped:V,series:[{key:"",label:ee.spec.label||"",index:0,points:E.map(A=>({x:A.key,xKey:A.key,label:A.label,y:A.to-A.from,rows:1,rowKey:A.key,px:A.px,py:A.py}))}]}}}),Qe("packages/modules/charts/interaction.js",function(o,X){"use strict";Object.defineProperty(o,"resolveBrush",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"brushed",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"brushCondition",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"attachBrush",{enumerable:!0,get:function(){return J}}),Object.defineProperty(o,"applySelection",{enumerable:!0,get:function(){return W}}),Object.defineProperty(o,"attachKeyboard",{enumerable:!0,get:function(){return ie}});const q=X("packages/modules/charts/svg.js").attrs,j=4;function be(S){const y=S&&S.brush;if(y===!0)return{mode:"filter",axis:"x"};if(y==="filter"||y==="zoom"||y==="select")return{mode:y,axis:"x"};if(y&&typeof y=="object"&&y.mode){const U=["filter","zoom","select"].includes(y.mode)?y.mode:null,D=y.axis==="y"||y.axis==="y2"?y.axis:"x";return{mode:U,axis:D}}return{mode:null,axis:"x"}}function me(S){const{bound:y,xScale:U}=S,D=Math.min(S.from,S.to),T=Math.max(S.from,S.to);if(S.axis==="y"||S.axis==="y2"){const $=S.axis==="y2"&&S.rightScale?S.rightScale:S.yScale||U;if(!$||typeof $.invert!="function")return{kind:"range",values:[],range:null,axis:S.axis};const p=$.invert(D),s=$.invert(T);return{kind:"range",values:[],range:[p,s],axis:S.axis}}if(U.kind==="band"){const $=[];for(const p of y.categories){const s=U.centre(p);!Number.isNaN(s)&&s>=D&&s<=T&&$.push(p)}return{kind:"set",values:$,range:null,axis:"x"}}const B=U.invert(D),_=U.invert(T);return{kind:"range",values:[],range:[B,_],axis:"x"}}function te(S){const{column:y,result:U}=S;if(!y)return null;if(U.kind==="set")return U.values.length?{col:y,op:"in",value:U.values.slice()}:null;if(!U.range)return null;const[D,T]=U.range;if(!Number.isFinite(D)||!Number.isFinite(T))return null;const B=S.kind==="time"?[new Date(Math.min(D,T)),new Date(Math.max(D,T))]:[Math.min(D,T),Math.max(D,T)];return{col:y,op:"between",value:B,bounds:"[]"}}function J(S){let y=null,U=null;const D=()=>{const $=typeof S.axis=="function"?S.axis():"x",p=$==="y"||$==="y2";return(typeof S.horizontal=="function"?S.horizontal():!1)!==p},T=$=>{if(!S.enabled())return;const p=S.pointOf($);y=D()?p.y:p.x,U=S.svg.ownerDocument.createElementNS("http://www.w3.org/2000/svg","rect"),U.setAttribute("class","lat-chartview__brush"),S.overlay.appendChild(U)},B=$=>{if(y===null||!U)return;const p=S.plot();if(D()){const R=S.pointOf($).y,I=Math.max(p.top,Math.min(y,R)),z=Math.min(p.bottom,Math.max(y,R));q(U,{x:p.left,y:I,width:Math.max(0,p.right-p.left),height:Math.max(0,z-I)});return}const s=S.pointOf($).x,c=Math.max(p.left,Math.min(y,s)),k=Math.min(p.right,Math.max(y,s));q(U,{x:c,y:p.top,width:Math.max(0,k-c),height:p.height})},_=$=>{if(y===null)return;const p=S.pointOf($),s=D()?p.y:p.x,c=Math.abs(s-y),k=y;y=null,U&&U.parentNode&&U.parentNode.removeChild(U),U=null,c>=j&&S.onBrush(k,s)};return S.svg.addEventListener("pointerdown",T),S.svg.addEventListener("pointermove",B),S.svg.addEventListener("pointerup",_),S.svg.addEventListener("pointerleave",_),()=>{S.svg.removeEventListener("pointerdown",T),S.svg.removeEventListener("pointermove",B),S.svg.removeEventListener("pointerup",_),S.svg.removeEventListener("pointerleave",_)}}function W(S){const y=S.groups.marks,U=S.keys.size>0||S.categories.size>0;let D=0;for(const T of y.childNodes||[]){if(!T.getAttribute)continue;const B=Number(T.getAttribute("data-series")),_=Number(T.getAttribute("data-point")),$=S.series[B],p=$&&$.points[_],s=!!p&&(p.rowKey&&S.keys.has(p.rowKey)||p.xKey!==void 0&&S.categories.has(p.xKey));s&&D++,U&&!s?T.setAttribute("data-dim","true"):T.removeAttribute("data-dim")}return D}function ie(S){let y=0;const U=T=>{const B=S.marks();if(B.length){y=Math.max(0,Math.min(B.length-1,T));for(let _=0;_<B.length;_++)B[_].setAttribute("tabindex",_===y?"0":"-1");B[y].focus&&B[y].focus(),S.onFocus(y)}},D=T=>{const B=S.marks();if(B.length){switch(T.key){case"ArrowRight":case"ArrowDown":U(y+1);break;case"ArrowLeft":case"ArrowUp":U(y-1);break;case"Home":U(0);break;case"End":U(B.length-1);break;case"Enter":case" ":S.onActivate(y);break;default:return}T.preventDefault&&T.preventDefault()}};return S.svg.addEventListener("keydown",D),()=>S.svg.removeEventListener("keydown",D)}}),Qe("packages/modules/charts/range.js",function(o,X){"use strict";Object.defineProperty(o,"deriveRangeSpec",{enumerable:!0,get:function(){return me}});const ye=new Set(["number","currency","percent","integer"]);function q(te){return!!te&&typeof te.type=="string"&&ye.has(te.type)}function j(te){const J=te&&te.selection&&typeof te.selection.ranges=="function"?te.selection.ranges():[];return!Array.isArray(J)||!J.length?null:J[J.length-1]}function be(te,J){const W=[],ie=Math.min(J.startRow,J.endRow),S=Math.max(J.startRow,J.endRow);for(let y=ie;y<=S;y++){const U=te.rows.get(y);U&&!U.group&&U.data!==null&&U.data!==void 0&&W.push(U)}return W}function me(te,J={}){const W=I=>({spec:null,type:null,x:null,measures:[],columns:[],reason:I}),ie=J.range||j(te);if(!ie)return W("no-range");const S=te.columns.visible(),y=new Set(S.map(I=>I.id)),U=(ie.columns||[]).filter(I=>y.has(I));if(!U.length)return W("no-visible-columns");const D=U.map(I=>({id:I,column:te.columns.get(I)})),T=D.filter(I=>q(I.column)).map(I=>I.id),B=D.filter(I=>!q(I.column)).map(I=>I.id);if(!T.length)return W("no-measure");const _=B.length?B[0]:null,$=T,s={rows:be(te,ie)},c=new Set(["bar","line","area"]);if($.length>1){const I=J.type,z=c.has(I)?I:null,Y=I&&!c.has(I)?I:"combo";return{spec:{...s,type:Y,x:_,measures:$.map(ee=>z?{col:ee,type:z}:{col:ee})},type:Y,x:_,measures:$,columns:U,reason:null}}const k=J.type||"bar";return{spec:{...s,type:k,x:_,y:$[0]},type:k,x:_,measures:$,columns:U,reason:null}}}),Qe("packages/modules/charts/regression.js",function(o,X){"use strict";Object.defineProperty(o,"regressionPlots",{enumerable:!0,get:function(){return me}});const ye=new Set(["number","currency","percent","integer"]);function q(te,J={}){return{spec:te,reason:null,...J}}function j(te,J={}){return{spec:null,reason:te,...J}}function be(te){if(!te||!Array.isArray(te.fitted)||!Array.isArray(te.residuals)||!Array.isArray(te.leverage)||!(te.sigma2>0))return null;const J=Math.sqrt(te.sigma2),W=[];for(let ie=0;ie<te.fitted.length;ie++){const S=te.leverage[ie];if(!Number.isFinite(S)||S>=1)continue;const y=J*Math.sqrt(1-S);if(!(y>0))continue;const U=te.residuals[ie]/y;W.push({x:te.fitted[ie],y:Math.sqrt(Math.abs(U)),key:String(ie)})}return W}function me(te,J={}){const W=J.model||(te&&te.statistics&&typeof te.statistics.regressionModel=="function"?te.statistics.regressionModel(J.spec||{}):null),ie=pe=>({fit:j(pe),residualsFitted:j(pe),qq:j(pe),multicollinearity:j(pe),scaleLocation:j(pe),residualsLeverage:j(pe),coefficientForest:j(pe)});if(!W||!Array.isArray(W.predictors)||!W.predictors.length||!W.response)return{model:null,plots:ie("no-model")};const S=W.predictors,y=W.response,U=J.rows,D=()=>U===void 0?{}:{rows:U},T=J.fitted||null,B=J.residual||null,_=J.stdResidual||null,$=J.leverage||null,p=J.cooksD||null,s=S.length===1?q({type:"scatter",x:S[0],y,fit:!0,band:W.band||null,...D()}):j("multiple-predictors"),c=T&&B?q({type:"scatter",x:T,y:B,reference:[{value:0}],...D()}):j("needs-fitted-and-residual-columns"),k=B?q({type:"qq",y:B,...D()}):j("needs-residual-column"),R=S.filter(pe=>{const x=te&&te.columns&&typeof te.columns.get=="function"?te.columns.get(pe):null;return!x||typeof x.type=="string"&&ye.has(x.type)}),I=S.length>=2?q({type:"correlogram",columns:R},{vif:W.vif||null}):j("single-predictor",{vif:W.vif||null}),z=$&&_?q({type:p?"bubble":"scatter",x:$,y:_,...p?{size:p}:{},reference:[{value:0}],...D()}):j("needs-leverage-and-standardised-residual-columns"),Y=be(W),re=Y&&Y.length?q({type:"scatter",points:Y,fit:!0,dimensionTitle:"Fitted",measureTitle:"√|standardised residual|"}):j("needs-fitted-model"),ee=Array.isArray(W.coefficients)?W.coefficients.filter(pe=>pe&&Number.isFinite(pe.estimate)&&Number.isFinite(pe.lower)&&Number.isFinite(pe.upper)).map(pe=>({x:pe.estimate,label:pe.name,lower:pe.lower,upper:pe.upper})):[],H=ee.length?q({type:"forest",points:ee,dimensionTitle:"Coefficient",measureTitle:"Estimate"},{coefficients:W.coefficients||null}):j("needs-coefficient-intervals",{coefficients:W.coefficients||null});return{model:W,plots:{fit:s,residualsFitted:c,qq:k,multicollinearity:I,scaleLocation:re,residualsLeverage:z,coefficientForest:H}}}}),Qe("packages/modules/charts/registry.js",function(o,X){"use strict";Object.defineProperty(o,"registerChartType",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"chartTypeDef",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"registeredChartTypes",{enumerable:!0,get:function(){return be}});const ye=new Map;function q(me,te){if(typeof me!="string"||!me)throw new TypeError("[lattice] registerChartType needs a non-empty type name.");if(!te||typeof te.draw!="function")throw new TypeError(`[lattice] registerChartType('${me}') needs a { draw } function.`);ye.set(me,te)}function j(me){return ye.get(me)||null}function be(){return[...ye.keys()]}}),Qe("packages/modules/charts/index.js",function(o,X){"use strict";Object.defineProperty(o,"TYPES",{enumerable:!0,get:function(){return _n}}),Object.defineProperty(o,"Chart",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(o,"createChart",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(o,"deriveRangeSpec",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(o,"regressionPlots",{enumerable:!0,get:function(){return yr}}),Object.defineProperty(o,"chartRange",{enumerable:!0,get:function(){return ao}}),Object.defineProperty(o,"canChartRange",{enumerable:!0,get:function(){return lo}});const ye=X("packages/modules/charts/cartesian.js"),q=ye.aheadOfWindow,j=ye.axisWindowNow,be=ye.axisWindowSpan,me=ye.bandedX,te=ye.CARTESIAN,J=ye.drawCartesian,W=ye.drawForest,ie=ye.nearestCategory,S=ye.nearestDrawnPoint,y=ye.WINDOW_LEAD,U=ye.windowedBound,D=ye.xDomainFor,B=X("packages/modules/charts/drawable.js").drawability,_=X("packages/modules/charts/axis.js"),$=_.createGroups,p=_.drawAxisTitle,s=_.normaliseAxes,c=_.setPlotClip,k=X("packages/modules/charts/bind.js"),R=k.bindHierarchy,I=k.bindLinks,z=k.bindMeasures,Y=k.bindPoints,re=k.bindSeries,ee=k.leafRows,pe=X("packages/modules/shared/engine.js").EngineFlight,x=X("packages/modules/charts/mapview.js"),Q=x.capClientBound,ce=x.engineRowsReader,E=x.frameMoved,V=x.frameOf,h=x.MAP_ENGINE_TYPES,a=x.needsRefit,d=x.planMapViewport,u=x.ringsBox,m=x.viewportCap,A=X("packages/modules/charts/mapdensity.js").drawDensityCells,w=X("packages/modules/charts/engine.js"),g=w.boundFromGroups,f=w.holdsWindow,v=w.measureProvenance,F=w.planAggregate,b=w.specMeasures,e=X("packages/modules/charts/frame.js"),i=e.Pool,n=e.plotRect,t=X("packages/modules/charts/scale.js"),r=t.key,l=t.measureDomain,L=t.sqrtScale,M=X("packages/modules/charts/format.js"),C=M.measureFormat,ne=M.measureText,ue=X("packages/modules/charts/radial.js"),ge=ue.arcAt,xe=ue.drawRadial,Ce=X("packages/modules/charts/distribution.js"),je=Ce.drawBoxPlot,_e=Ce.drawCapability,Re=Ce.drawControl,fe=Ce.drawEcdf,G=Ce.drawHistogram,se=Ce.drawLorenz,le=Ce.drawMovingRange,ae=Ce.drawQQ,we=X("packages/modules/charts/treemap.js").drawTreemap,Ee=X("packages/modules/charts/annotate-layer.js").ChartAnnotations,Te=X("packages/modules/charts/annotate-items.js"),Ge=Te.itemsFromState,Ie=Te.resolveAnnotate,Ke=Te.serialiseItem,Be=X("packages/modules/charts/zoom-view.js"),ze=Be.bandRange,qe=Be.magnify,ot=Be.resolveZoom,Ot=Be.sameView,St=Be.settleView,zt=Be.slice,$t=Be.slide,nn=Be.viewOfRange,Yt=Be.ZOOM_CONTROLS,Mt=X("packages/modules/charts/zoom-toolbar.js").buildZoomToolbar,Lt=X("packages/modules/charts/hit.js"),Xt=Lt.ownsGeometry,rn=Lt.resolveHit,ht=X("packages/modules/charts/combo.js").drawCombo,bt=X("packages/modules/charts/polar.js"),Ct=bt.drawGauge,Dt=bt.drawRadar,Ft=X("packages/modules/charts/matrix.js"),Ut=Ft.clearVolumePane,Jt=Ft.drawCandlestick,Z=Ft.drawCorrelogram,Oe=Ft.drawFunnel,ke=Ft.drawHeatmap,Me=Ft.title,Ne=Ft.VOLUME_PANE_HEIGHT,Pe=X("packages/modules/charts/multiples.js"),$e=Pe.panelRects,We=Pe.splitPanels,Le=X("packages/modules/charts/geo.js"),De=Le.basemapStyleOf,Ve=Le.checkGeometrySpec,Je=Le.drawGeomap,ct=Le.geoRamp,rt=Le.GEOMETRY_TYPES_PLACED,ft=Le.packRegions,jt=Le.projectedPath,tt=Le.resolvePack,Pt=X("packages/modules/charts/projection.js"),At=Pt.fitted,Et=Pt.resolveProjection,gt=Pt.splitAntimeridian,yt=X("packages/modules/charts/viewport-filter.js"),_t=yt.adoptedGeoView,Rt=yt.conditionBbox,fn=yt.mergeViewportCondition,on=yt.pruneTarget,Kt=yt.resolveViewportFilter,xt=yt.sameBbox,hn=yt.viewportBbox,En=yt.viewportCondition,sn=yt.viewportTarget,Vt=X("packages/modules/charts/flow.js"),yn=Vt.drawChord,mn=Vt.drawSankey,wn=X("packages/modules/charts/network.js"),On=wn.drawNetwork,cn=wn.emphasiseNetwork,kn=X("packages/modules/charts/stream.js"),vn=kn.drawMarimekko,xn=kn.drawStream,Tn=kn.drawViolin,gn=X("packages/modules/charts/gantt.js").drawGantt,Ht=X("packages/modules/charts/svg.js"),qt=Ht.attrs,un=Ht.append,Zt=Ht.clear,lt=Ht.el,an=Ht.round,vt=Ht.setText,st=Ht.svg,wt=X("packages/modules/charts/styles.js"),it=wt.NS,Bt=wt.injectStyles,It=X("packages/modules/charts/scheme.js"),An=It.resolveScheme,pn=X("packages/modules/charts/typography.js"),en=pn.applySize,Wn=pn.resolveType,cr=pn.textWidth,Kn=X("packages/modules/charts/labels.js"),ur=Kn.collides,fr=Kn.resolveLabels,bn=X("packages/modules/charts/interaction.js"),hr=bn.applySelection,dr=bn.attachBrush,mr=bn.attachKeyboard,gr=bn.brushCondition,pr=bn.brushed,jn=bn.resolveBrush,Ln=X("packages/modules/charts/dense.js"),co=Ln.downsample,uo=Ln.markCount,br=Ln.wantsCanvas,Cn=X("packages/modules/charts/range.js").deriveRangeSpec,yr=X("packages/modules/charts/regression.js").regressionPlots,Sn=X("packages/modules/charts/registry.js"),Vn=Sn.chartTypeDef,mo=Sn.registeredChartTypes,go=Sn.registerChartType,wr=t.linearScale,kr=t.bandScale,Zn=t.extent,Yn=t.toNumber,vr=t.isNumber,xr=t.niceDomain,Ar=t.linearTicks,Sr=t.timeScale,Jn=t.toTime,Mr=t.niceStep,Nr=Ft.colourRamp,Or=Ht.path,jr=Ht.attr,Xn=X("packages/core/src/internal/util.js"),Pr=Xn.infoOnce,Gt=Xn.warnOnce,$r=_.drawMeasureAxis,Er=_.drawCategoryAxis,Tr=_.drawAxisLines,Lr=_.drawContinuousAxis,Cr=_.drawBandLabels,_r=_.tickValues,Rr=Ce.density,zr=Ce.valuesByCategory,Fr=Ce.summarise,Ir=Ce.quantile,Dr=Ce.histogram,qn=M.formatters;Object.defineProperty(o,"registerScheme",{enumerable:!0,get:function(){return It.registerScheme}}),Object.defineProperty(o,"resolveScheme",{enumerable:!0,get:function(){return It.resolveScheme}}),Object.defineProperty(o,"schemeNames",{enumerable:!0,get:function(){return It.schemeNames}}),Object.defineProperty(o,"setDefaultScheme",{enumerable:!0,get:function(){return It.setDefaultScheme}}),Object.defineProperty(o,"SCHEMES",{enumerable:!0,get:function(){return It.SCHEMES}}),Object.defineProperty(o,"PALETTE",{enumerable:!0,get:function(){return It.PALETTE}}),Object.defineProperty(o,"registerChartType",{enumerable:!0,get:function(){return Sn.registerChartType}}),Object.defineProperty(o,"registeredChartTypes",{enumerable:!0,get:function(){return Sn.registeredChartTypes}});const Br=Object.freeze({el:lt,svg:st,attr:jr,attrs:qt,append:un,clear:Zt,path:Or,round:an,setText:vt,Pool:i,plotRect:n,linearScale:wr,bandScale:kr,sqrtScale:L,extent:Zn,measureDomain:l,niceDomain:xr,linearTicks:Ar,timeScale:Sr,toTime:Jn,niceStep:Mr,toNumber:Yn,isNumber:vr,key:r,drawMeasureAxis:$r,drawCategoryAxis:Er,drawAxisLines:Tr,drawContinuousAxis:Lr,drawBandLabels:Cr,tickValues:_r,formatters:qn,resolveScheme:An,colourRamp:Nr,density:Rr,valuesByCategory:zr,summarise:Fr,quantile:Ir,histogram:Dr,resolvePack:tt,packRegions:ft,fitted:At,resolveProjection:Et,splitAntimeridian:gt,projectedPath:jt,basemapStyleOf:De,geoRamp:ct,textWidth:cr,applySize:en,collides:ur,drawDensityCells:A,NS:it}),_n=Object.freeze(["line","step","area","rangeArea","bar","horizontalBar","waterfall","scatter","bubble","forest","combo","pareto","histogram","boxplot","heatmap","qq","ecdf","lorenz","correlogram","control","capability","movingRange","pie","donut","sunburst","treemap","radar","gauge","funnel","candlestick","geomap","sankey","chord","network","stream","marimekko","violin","gantt"]),Rn=new Set([...Object.keys(te),"combo","candlestick",...rt]),zn=new Set([...Object.keys(te),"combo"]),Gr=4,Qn=new Set(["bar","column","horizontalBar","line","area","scatter","bubble","combo","pareto","histogram","heatmap","pie","donut","sunburst","treemap","radar","geomap"]),Ur=new Set(["pie","donut","sunburst"]),Hr=new Set(["pie","donut","sunburst","treemap"]),er=20,Wr=new Set(["histogram","boxplot","qq","ecdf","lorenz","control","capability","movingRange"]),Kr=new Set(["histogram","boxplot","qq","ecdf","lorenz","violin"]);function Vr(at){const N=at.y||(Array.isArray(at.measures)&&at.measures.length?at.measures[0]:null);if(!N)return at;const P=typeof N=="string"?N:N.col;if(!P)return at;const K=typeof N=="object"&&N.fn!=null?N.fn:"median";return{...at,y:{col:P,fn:K}}}const Zr=new Set(["combo","candlestick"]),tr=new Set(["bar","line","step","area","scatter","bubble"]),Yr=new Set(["sankey","chord","network"]),Fn=Symbol("pending"),Jr=new Set(["gantt"]),Xr=new Set(["radar","gauge","funnel","heatmap","geomap","sankey","chord","network"]),tn=Object.freeze({width:480,height:300}),nr=Object.freeze(["00000"]),rr=new Set(["horizontalBar","forest"]);function qr(at){if(!at||!Array.isArray(at.points))return null;let N=0,P=!1;for(const K of at.points)typeof K.y=="number"&&Number.isFinite(K.y)&&(N+=K.y,P=!0);return P?N:null}function or(at,N,P,K){return at==="correlogram"?(Array.isArray(K.columns)?K.columns:[]).map(oe=>Me(P,oe)):at==="heatmap"?(N.series||[]).map(he=>he.label):at==="gantt"?(N.rows||[]).map(he=>K.label?P.rows.text(he.key,K.label):String(he.key)):rr.has(at)?N.labels||[]:nr}const Qr=1e3,eo=50;let to=0;function no(at){const N=at/1e3;return`${N>=10?Math.round(N):Math.round(N*10)/10}s`}function ir(at){return`${at/1e3}s`}function Qt(at){return at&&at.defaultView||globalThis}function ro(at,N){return N?typeof N=="string"?at.querySelector(N):N:null}function oo(at,N,P){const K=["fill","fill-opacity","stroke","stroke-width","stroke-opacity","stroke-dasharray","stroke-linejoin","stroke-linecap","font-size","font-family","font-weight","opacity","text-anchor","dominant-baseline","visibility"],he=[at,...at.querySelectorAll("*")],oe=[N,...N.querySelectorAll("*")];for(let ve=0;ve<he.length&&ve<oe.length;ve++){const Se=P.getComputedStyle(he[ve]),He=[];for(const Ye of K){const Fe=Se.getPropertyValue(Ye);Fe&&He.push(`${Ye}:${Fe}`)}He.length&&oe[ve].setAttribute("style",He.join(";"))}}function io(at,N){let P=at.root;const K=[];for(const he of N){const oe=(P.children||[]).find(ve=>ve.label===he);if(!oe||!oe.children||!oe.children.length)break;P=oe,K.push(he)}return K.length?{...at,root:P,path:K,empty:!P.children.length}:at}function so(at,N,P){return at&&at.plot?at.plot:{left:0,top:0,right:N,bottom:P,width:N,height:P,gutter:{left:0,bottom:0,right:0,top:0}}}class sr{#r=++to;#n;#l;#e;#i;#s=null;#o=null;#c=null;#y=null;#m=null;#F=!1;#w=null;#O=null;#x=[];#g=new Set;#t=null;#u={zoom:1,offset:[0,0]};#A=null;#P=null;#S=null;#L=0;#I=null;#$=null;#te=!1;#ne=!1;#a=null;#ce=0;#V=null;#re=null;#ye=!1;#E=!1;#D=new Map;#Z=An();#C=Wn();#St=null;#p=null;#T=null;#h=null;#Y=null;#M=null;#f={x:null,y:null};#N={x:null,y:null};#B=!1;#v=[];#oe={first:0,last:0};#_=!1;#G=null;#j=null;#ie=!1;#ue=null;#U=null;#fe=0;#R=new pe;#J={bbox:null,span:360,width:0};#H=null;#we=0;#b=null;#k={source:"client",asked:"auto",reason:"the chart has not drawn yet",pending:!1,measures:[]};#se=null;constructor(N){this.#n=N.grid,this.#l=N.container,this.#e=N.spec,this.#i=N.container.ownerDocument,this.#Ce(),this.#_e(),this.draw()}#Ce(){Bt(this.#i);const N=this.#i;this.#s=lt(N,"div",it);const P=lt(N,"figure",`${it}__figure`);if(this.#e.title||this.#e.subtitle){const K=lt(N,"figcaption",`${it}__caption`);if(this.#e.title){const he=lt(N,"div",`${it}__title`);vt(he,this.#e.title),K.appendChild(he)}if(this.#e.subtitle){const he=lt(N,"div",`${it}__subtitle`);vt(he,this.#e.subtitle),K.appendChild(he)}P.appendChild(K)}if(this.#o=st(N,"svg",{class:`${it}__plot`,preserveAspectRatio:"xMidYMid meet",role:"img"}),this.#c=$(N,this.#o),P.appendChild(this.#o),this.#O=lt(N,"div",`${it}__empty`),this.#O.setAttribute("hidden",""),P.appendChild(this.#O),this.#w=lt(N,"div",`${it}__table`),P.appendChild(this.#w),this.#y=lt(N,"div",`${it}__legend`),P.appendChild(this.#y),this.#e.footnote){const K=lt(N,"div",`${it}__footnote`);vt(K,this.#e.footnote),P.appendChild(K)}this.#P=lt(N,"div",`${it}__attribution`),this.#P.setAttribute("hidden",""),P.appendChild(this.#P),this.#m=lt(N,"div",`${it}__tooltip`),this.#m.setAttribute("hidden",""),this.#s.appendChild(P),this.#s.appendChild(this.#m),this.#l.appendChild(this.#s),this.#Re()}#_e(){const N=["model:changed","rows:changed","filter:changed","sort:changed","column:grouped","column:pivoted","cell:changed","timeline:seek","timeline:attached","timeline:detached"];this.#e.selection&&this.#x.push(this.#n.on("selection:changed",()=>this.#Ne()));for(const K of N)this.#x.push(this.#n.on(K,()=>this.schedule()));const P=Qt(this.#i);P&&typeof P.ResizeObserver=="function"&&(this.#re=this.#l.getBoundingClientRect?this.#l.getBoundingClientRect():null,this.#V=new P.ResizeObserver(()=>{if(!this.#ye){this.#ye=!0;const K=this.#l.getBoundingClientRect?this.#l.getBoundingClientRect():null;if(K&&this.#re&&Math.round(K.width)===Math.round(this.#re.width)&&Math.round(K.height)===Math.round(this.#re.height))return}this.schedule()}),this.#V.observe(this.#l))}#ke(){const N=this.#o&&this.#o.getBoundingClientRect?this.#o.getBoundingClientRect():null;return N&&N.width>0&&N.height>0?N:this.#l.getBoundingClientRect?this.#l.getBoundingClientRect():tn}#Re(){const N=Ze=>{this.#A||this.#ze(Ze)},P=()=>this.#X();this.#o.addEventListener("pointermove",N),this.#o.addEventListener("pointerleave",P),this.#o.addEventListener("click",Ze=>this.#Me(Ze));const K=Ze=>{!this.#t||!this.#t.packed||this.#h&&this.#h.busy||(this.#A={x:Ze.clientX||0,y:Ze.clientY||0})},he=Ze=>{if(!this.#A)return;const kt=Ze.clientX||0,Nt=Ze.clientY||0;this.#q(kt-this.#A.x,Nt-this.#A.y),this.#A={x:kt,y:Nt}},oe=()=>{this.#A=null},ve=Ze=>{!this.#t||!this.#t.packed||(Ze.preventDefault&&Ze.preventDefault(),this.#de(Ze.deltaY<0?1.15:1/1.15))},Se=Ze=>{if(!this.#t||!this.#t.packed)return;const kt=40;if(Ze.shiftKey&&Ze.key==="ArrowLeft")this.#q(-kt,0);else if(Ze.shiftKey&&Ze.key==="ArrowRight")this.#q(kt,0);else if(Ze.shiftKey&&Ze.key==="ArrowUp")this.#q(0,-kt);else if(Ze.shiftKey&&Ze.key==="ArrowDown")this.#q(0,kt);else if(Ze.key==="+"||Ze.key==="=")this.#de(1.25);else if(Ze.key==="-"||Ze.key==="_")this.#de(1/1.25);else if(Ze.key==="0")this.#He();else return;Ze.preventDefault&&Ze.preventDefault()};this.#o.addEventListener("pointerdown",K),this.#o.addEventListener("pointermove",he),this.#o.addEventListener("pointerup",oe),this.#o.addEventListener("pointerleave",oe),this.#o.addEventListener("wheel",ve,{passive:!1}),this.#o.addEventListener("keydown",Se);const He=()=>{if(!this.#_)return null;const Ze=ot(this.#e.zoom);return Ze.enabled?Ze:null},Ye=()=>!!(this.#h&&this.#h.busy)||!!jn(this.#e).mode,Fe=Ze=>{const kt=He();if(!kt||!kt.wheel||this.#t&&this.#t.packed)return;const Nt=Number(Ze.deltaY)||0;if(!Nt)return;const ut=this.#z(Ze);this.#W(Nt<0?"in":"out","wheel",this.#mt(ut)),Ze.preventDefault&&Ze.preventDefault()},Xe=Ze=>{this.#ie=!1;const kt=He();!kt||!kt.pan||Ye()||this.#t&&this.#t.packed||!this.#f.x&&!this.#f.y||(this.#j={at:this.#z(Ze),moved:!1})},dt=Ze=>{if(!this.#j)return;const kt=this.#t&&this.#t.plot||null;if(!kt)return;const Nt=this.#z(Ze),ut=Nt.x-this.#j.at.x,nt=Nt.y-this.#j.at.y,pt=kt.right-kt.left||1,Tt=kt.bottom-kt.top||1;!this.#j.moved&&Math.hypot(ut,nt)<Gr||(this.#j.moved=!0,this.#ie=!0,this.#j.at=Nt,this.#le((dn,Pn,Mn)=>dn==="x"?$t(Pn,Mn,-ut/pt):$t(Pn,Mn,nt/Tt),"pan"),Ze.preventDefault&&Ze.preventDefault())},mt=()=>{this.#j=null},Ue=Ze=>{if(He()&&!(this.#t&&this.#t.packed)){if(Ze.key==="+"||Ze.key==="=")this.#W("in","key");else if(Ze.key==="-"||Ze.key==="_")this.#W("out","key");else return;Ze.preventDefault&&Ze.preventDefault()}},Wt=Ze=>{He()&&(this.#t&&this.#t.packed||(this.#W("reset","reset"),Ze.preventDefault&&Ze.preventDefault()))};this.#o.addEventListener("wheel",Fe,{passive:!1}),this.#o.addEventListener("pointerdown",Xe),this.#o.addEventListener("pointermove",dt),this.#o.addEventListener("pointerup",mt),this.#o.addEventListener("pointerleave",mt),this.#o.addEventListener("keydown",Ue),this.#o.addEventListener("dblclick",Wt),this.#x.push(()=>{this.#o.removeEventListener("wheel",Fe),this.#o.removeEventListener("pointerdown",Xe),this.#o.removeEventListener("pointermove",dt),this.#o.removeEventListener("pointerup",mt),this.#o.removeEventListener("pointerleave",mt),this.#o.removeEventListener("keydown",Ue),this.#o.removeEventListener("dblclick",Wt)}),this.#x.push(dr({svg:this.#o,overlay:this.#c.overlay,plot:()=>this.#t&&this.#t.plot||{left:0,top:0,right:0,bottom:0,height:0},pointOf:Ze=>this.#z(Ze),axis:()=>jn(this.#e).axis,horizontal:()=>!!(this.#t&&this.#t.horizontal),enabled:()=>!!jn(this.#e).mode&&!!(this.#t&&this.#t.xScale)&&!(this.#h&&this.#h.busy),onBrush:(Ze,kt)=>this.#Be(Ze,kt)})),this.#o.setAttribute("tabindex","0"),this.#x.push(mr({svg:this.#o,marks:()=>[...this.#c.marks.childNodes||[]].filter(Ze=>Ze.setAttribute),onFocus:Ze=>this.#Ge(Ze),onActivate:Ze=>this.#Ue(Ze)})),this.#x.push(()=>{this.#o.removeEventListener("pointermove",N),this.#o.removeEventListener("pointerleave",P),this.#o.removeEventListener("pointerdown",K),this.#o.removeEventListener("pointermove",he),this.#o.removeEventListener("pointerup",oe),this.#o.removeEventListener("pointerleave",oe),this.#o.removeEventListener("wheel",ve),this.#o.removeEventListener("keydown",Se)})}#z(N){const P=this.#o.getBoundingClientRect?this.#o.getBoundingClientRect():{left:0,top:0,width:tn.width,height:tn.height};return{x:(N.clientX||0)-P.left,y:(N.clientY||0)-P.top}}#ve(N){return ie({bound:{categories:this.#ae().categories},xScale:this.#t.xScale,at:this.#t.horizontal?N.y:N.x})}#ae(){const N=this.#t;return N&&Array.isArray(N.labels)&&Array.isArray(N.categories)?{labels:N.labels,categories:N.categories}:{labels:this.#a&&this.#a.labels||[],categories:this.#a&&this.#a.categories||[]}}#xe(N){if(!this.#t||!Array.isArray(this.#t.series))return null;if(this.#t.reduced)return S({series:this.#t.series,xScale:this.#t.xScale,at:this.#t.horizontal?N.y:N.x});const P=this.#ve(N);return P<0?null:{index:P,entries:this.#t.series.map(K=>({series:K,point:K.points[P]})).filter(K=>K.point&&K.point.y!==null)}}#he(N){return rn({drawn:this.#t,bound:this.#a,spec:this.#e,grid:this.#n,scheme:this.#Z,at:N})}#ze(N){if(!this.#t||!this.#a||this.#e.tooltip===!1)return;const P=this.#z(N),K=[];let he="";const oe=this.#he(P);if(oe){this.#Ae(oe.heading,oe.rows,N),this.emit("hover",{...oe.datum,native:N});return}if(Xt(this.#t)){this.#X();return}if(this.#t.arcs){const Se=ge({arcs:this.#t.arcs,x:P.x,y:P.y});if(!Se){this.#X();return}he=Se.label;const He=this.#a.root.total>0?Se.total/this.#a.root.total:0;K.push({label:this.#a.measure.title,value:`${ne(Se.total,this.#n.messages)} (${this.#n.messages.number(He,{style:"percent",maximumFractionDigits:1})})`,colour:this.#Z.series(Se.index)})}else{const Se=this.#xe(P);if(!Se){this.#X();return}he=this.#ae().labels[Se.index]||"";for(const He of Se.entries)K.push({label:He.series.label,value:ne(He.point.y,this.#n.messages),colour:this.#Z.series(He.series.index)})}if(!K.length){this.#X();return}this.#Ae(he,K,N);const ve=this.#Se(P);ve&&this.emit("hover",{...ve,native:N})}#Ae(N,P,K){const he=this.#i;if(Zt(this.#m),N){const oe=lt(he,"div",`${it}__tooltip-row`),ve=lt(he,"strong");vt(ve,N),oe.appendChild(ve),this.#m.appendChild(oe)}for(const oe of P){const ve=lt(he,"div",`${it}__tooltip-row`),Se=lt(he,"span",`${it}__swatch`);Se.setAttribute("style",`background:${oe.colour}`);const He=lt(he,"span");vt(He,oe.label);const Ye=lt(he,"span",`${it}__tooltip-value`);vt(Ye,oe.value),un(ve,[Se,He,Ye]),this.#m.appendChild(ve)}this.#m.removeAttribute("hidden"),this.#Fe(K)}#Fe(N){if(!this.#F&&(this.#F=!0,this.#Ie())){const Xe=this.#i&&this.#i.body;Xe&&typeof Xe.appendChild=="function"&&Xe.appendChild(this.#m)}const P=Qt(this.#i),K=12,he=N&&N.clientX||0,oe=N&&N.clientY||0,ve=typeof this.#m.getBoundingClientRect=="function"?this.#m.getBoundingClientRect():{width:0,height:0},Se=P.innerWidth||0,He=P.innerHeight||0;let Ye=he+K;Se&&Ye+ve.width>Se-K&&(Ye=he-K-ve.width),Ye=Math.max(K,Ye);let Fe=oe+K;He&&Fe+ve.height>He-K&&(Fe=oe-K-ve.height),Fe=Math.max(K,Fe),this.#m.style.left=`${Math.round(Ye)}px`,this.#m.style.top=`${Math.round(Fe)}px`}#Ie(){const N=Qt(this.#i);if(typeof N.getComputedStyle!="function")return!1;let P=this.#s&&this.#s.parentNode;for(;P;){if(P.nodeType===11&&P.host){P=P.host;continue}if(P.nodeType!==1)break;const K=N.getComputedStyle(P);if(K&&(K.transform&&K.transform!=="none"||K.perspective&&K.perspective!=="none"||K.filter&&K.filter!=="none"||K.backdropFilter&&K.backdropFilter!=="none"||K.contain&&/layout|paint|strict|content/.test(K.contain)))return!0;P=P.parentNode}return!1}#X(){this.#m&&this.#m.setAttribute("hidden",""),this.emit("leave",{})}#Se(N){if(!this.#t||!this.#a)return null;const P=this.#he(N);if(P)return P.datum;if(Xt(this.#t))return null;if(this.#t.arcs){const Se=ge({arcs:this.#t.arcs,x:N.x,y:N.y});return Se?{label:Se.label,value:Se.total,category:Se.node.value,column:this.#e.x||null,series:null,depth:Se.depth,path:Array.isArray(Se.path)?[...Se.path]:[Se.label],rowKeys:Se.node.rowKey?[Se.node.rowKey]:[]}:null}const K=this.#xe(N);if(!K)return null;const he=K.entries,oe=this.#ae(),ve=he.length===1&&he[0].point.from!==void 0?{from:he[0].point.from,to:he[0].point.to}:null;return{label:oe.labels[K.index]||"",category:oe.categories[K.index],column:this.#a.dimension.col,value:he.length===1?he[0].point.y:null,...ve||{},series:he.map(Se=>({key:Se.series.key,label:Se.series.label,value:Se.point.y,rows:Se.point.rows})),rowKeys:he.map(Se=>Se.point.rowKey).filter(Boolean)}}#Me(N){if(!this.#t||!this.#a||this.#h&&this.#h.busy)return;if(this.#ie){this.#ie=!1;return}const P=this.#Se(this.#z(N));if(!P)return;let K=!1;const he=this.emit("click",{...P,native:N,preventDefault(){K=!0}});if(!(K||he.defaultPrevented)){if(this.#e.drill&&this.#a&&this.#a.root&&P.label){const oe=Array.isArray(P.path)&&P.path.length?P.path:[P.label];this.#p=[...this.#p||[],...oe],this.emit("drill",{path:[...this.#p],label:P.label}),this.draw();return}if(this.#e.selection&&Array.isArray(this.#t.markers)&&Array.isArray(P.rowKeys)&&P.rowKeys.length){this.#n.selection.set([...P.rowKeys]);return}if(this.#e.selection&&this.#e.type==="network"&&Array.isArray(P.rowKeys)&&P.rowKeys.length){this.#n.selection.set([...new Set(P.rowKeys)]);return}!this.#e.filterOnClick||!P.column||this.#n.filters.set({col:P.column,op:"eq",value:P.category})}}#Ne(){if(!this.#t)return;if(Array.isArray(this.#t.markers)){this.#De();return}if(Array.isArray(this.#t.links)&&Array.isArray(this.#t.nodes)&&!this.#t.series){cn({drawn:this.#t,keys:new Set(this.#n.selection.keys())});return}if(!this.#t.series)return;const N=this.#n.selection.keys(),P=this.#a&&this.#a.dimension&&this.#a.dimension.col,K=new Set;if(P)for(const he of N)K.add(r(this.#n.rows.value(he,P)));hr({groups:this.#c,series:this.#t.series,keys:new Set(N),categories:K})}#De(){const N=new Set(this.#n.selection.keys());for(const P of this.#t.markers){const K=P.element;!K||!K.setAttribute||(N.size&&!N.has(P.rowKey)?K.setAttribute("data-dim","true"):K.removeAttribute("data-dim"))}}#Be(N,P){const K=jn(this.#e),he=K.mode;if(!he||!this.#t||!this.#t.xScale||!this.#a)return;const oe=pr({bound:this.#a,xScale:this.#t.xScale,yScale:this.#t.yScale,rightScale:this.#t.rightScale||null,axis:K.axis,from:N,to:P});let ve=!1;const Se=this.emit("brush",{mode:he,kind:oe.kind,values:oe.values,range:oe.range,axis:oe.axis,column:oe.axis==="y"||oe.axis==="y2"?this.#a.measure&&this.#a.measure.col||null:this.#a.dimension.col,preventDefault(){ve=!0}});if(ve||Se.defaultPrevented)return;if(he==="zoom"){if(oe.range){const Ye=oe.axis==="y2"?"y2":oe.axis==="y"?"y":"x";this.#e={...this.#e,axis:{...this.#e.axis||{},[Ye]:{...(this.#e.axis||{})[Ye]||{},min:Math.min(oe.range[0],oe.range[1]),max:Math.max(oe.range[0],oe.range[1])}}},this.draw()}return}if(he==="select"){const Ye=[];for(const Fe of this.#t.series||[])for(const Xe of Fe.points){if(!Xe.rowKey)continue;(oe.kind!=="set"||oe.values.some(mt=>r(mt)===Xe.xKey))&&Ye.push(Xe.rowKey)}this.#n.selection.set([...new Set(Ye)]);return}const He=gr({column:this.#a.dimension.col,result:oe,kind:this.#a.kind});He&&this.#n.filters.set(He)}#Ge(N){const P=(this.#c.marks.childNodes||[])[N];if(!P||!P.setAttribute)return;const K=this.#t&&this.#t.series?this.#t.series[Number(P.getAttribute("data-series"))||0]:null,he=K&&K.points[Number(P.getAttribute("data-point"))||0];if(!he){if(!P.getBoundingClientRect)return;const oe=P.getBoundingClientRect(),ve=this.#he(this.#z({clientX:oe.left+oe.width/2,clientY:oe.top+oe.height/2}));if(!ve)return;P.setAttribute("role","img"),P.setAttribute("aria-label",`${ve.heading}: ${ve.rows.map(Se=>Se.value).filter(Boolean).join(", ")}`),this.emit("focus",{label:ve.datum.label,value:ve.datum.value,index:N});return}P.setAttribute("role","img"),P.setAttribute("aria-label",`${he.label}: ${ne(he.y,this.#n.messages)}`),this.emit("focus",{label:he.label,value:he.y,index:N})}#Ue(N){const P=(this.#c.marks.childNodes||[])[N];if(!P||!P.getBoundingClientRect)return;const K=P.getBoundingClientRect();this.#Me({clientX:K.left+K.width/2,clientY:K.top+K.height/2})}#Oe(N){const P=N&&N.attribution||"";P?(vt(this.#P,P),this.#P.removeAttribute("hidden")):this.#P.setAttribute("hidden","");const K=N&&Number.isFinite(N.aspect)&&N.aspect>0?N.aspect:null;this.#o&&this.#o.style&&(K?this.#o.style.setProperty("aspect-ratio",String(K)):this.#o.style.removeProperty("aspect-ratio"))}#He(){this.#u={zoom:1,offset:[0,0]},this.#b&&this.#b.refit&&(this.#b=null),this.#Q(),this.schedule()}#de(N){const P=this.#u.zoom*N;this.#u={...this.#u,zoom:Math.min(8,Math.max(1,P))},this.schedule()}#q(N,P){const K=this.#t&&this.#t.scale||0;if(!K)return;const[he,oe]=this.#u.offset;this.#u={...this.#u,offset:[he-N/K,oe+P/K]},this.schedule()}#Q(){const N=Qt(this.#i);if(N.clearTimeout&&N.clearTimeout(this.#L),this.#L=0,this.#$=null,!this.#S||!this.#I){this.#S=null;return}this.#S=null;const P=this.#n&&this.#n.filters;if(!P||typeof P.get!="function"||typeof P.set!="function")return;const K=P.get(),he=on(K,this.#I);he!==K&&P.set(he)}#We(N){const P=Kt(this.#e.viewportFilter),K=this.#t,he=rt.has(N)&&!!K&&!!K.anchor;if(!P.enabled||!he){this.#Q();return}const oe=sn(this.#e,P.column);if(!oe){this.#Q();return}const ve=this.#I;ve&&(ve.kind!==oe.kind||ve.column!==oe.column||ve.lon!==oe.lon||ve.lat!==oe.lat)&&this.#Q(),this.#I=oe;const Se=this.#n&&this.#n.filters;if(!Se||typeof Se.get!="function"||typeof Se.set!="function")return;const He=Se.get(),Ye=Rt(He,oe);if(Ye&&!xt(Ye,this.#S)){this.#$={zoom:this.#u.zoom,offset:[...this.#u.offset]},this.#S=Ye,this.#Ke(Ye);return}Ye||(this.#S=null);const[Fe,Xe]=this.#u.offset;if(this.#u.zoom===1&&Fe===0&&Xe===0){this.#$=null;return}const dt=this.#$;if(dt&&this.#u.zoom===dt.zoom&&Fe===dt.offset[0]&&Xe===dt.offset[1])return;const mt=hn(K.anchor,K.plot);if(!mt||xt(mt,this.#S)){this.#$={zoom:this.#u.zoom,offset:[Fe,Xe]};return}this.#$={zoom:this.#u.zoom,offset:[Fe,Xe]};const Ue=Qt(this.#i);Ue.clearTimeout&&Ue.clearTimeout(this.#L);const Wt=typeof Ue.setTimeout=="function"?Ue.setTimeout.bind(Ue):setTimeout;this.#L=Wt(()=>{this.#L=0;const Ze=Se.get(),kt=this.#n.messages&&typeof this.#n.messages.t=="function"?this.#n.messages.t("chart.viewportFilter.label"):void 0,Nt=fn(Ze,oe,En(oe,mt,kt));this.#S=mt,Se.set(Nt)},P.debounce)}#Ke(N){const P=this.#t;if(!P||!P.anchor||!P.plot)return;const K=hn(P.anchor,P.plot);if(this.#H&&this.#b&&!this.#e.shapes&&a(K,N)){const[oe,ve,Se,He]=N;this.#b={baseKey:this.#H.baseKey,rings:[[[oe,ve],[Se,ve],[Se,He],[oe,He]]],refit:!0},this.#u={zoom:1,offset:[0,0]},this.schedule();return}const he=_t(K,N,P.plot,{zoom:this.#u.zoom,offset:this.#u.offset,scale:P.scale});he&&(this.#u=he,this.schedule())}schedule(){if(this.#E||this.#ce)return;const N=Qt(this.#i),P=typeof N.requestAnimationFrame=="function"?N.requestAnimationFrame.bind(N):K=>setTimeout(K,16);this.#ce=P(()=>{this.#ce=0,this.draw()})||1}draw(){if(this.#E)return;const N=this.#je();if(!N)return;const P=this.#ke(),K=Math.round(P.width||tn.width),he=Math.round(P.height||tn.height),oe=K!==N.width||he!==N.height?this.#je():N;oe&&this.emit("draw",{chartType:oe.chartType,categories:oe.categories,empty:oe.empty})}#je(){const N=this.#ke(),P=Math.round(N.width||tn.width),K=Math.round(N.height||tn.height),he=_n.includes(this.#e.type)?null:Vn(this.#e.type),oe=_n.includes(this.#e.type)||he?this.#e.type:"bar";Array.isArray(this.#e.x)&&Gt(`chart:${this.#r}:x:array`,`chart "x" expects one column id (a string) and was given an array [${this.#e.x.map(ut=>JSON.stringify(ut)).join(", ")}]. A chart takes one category column on "x". For a hierarchy, group the grid — grid.columns.group([...]) — and the hierarchical types (pie, donut, sunburst, treemap) read the grouping.`);const ve=An(this.#e);this.#Z=ve,this.#se=null;const Se=s(this.#e.axis),He=this.#n.messages,Ye=Wn(this.#e);this.#C=Ye;const Fe=Ye.small,Xe=fr(this.#e);if(Xe.show&&!Qn.has(oe)&&!(he&&he.labelled)&&!this.#te){this.#te=!0;const ut=this.#i&&this.#i.defaultView,nt=ut&&ut.console||(typeof globalThis<"u"?globalThis.console:null);nt&&typeof nt.warn=="function"&&nt.warn(`[lattice] a "${oe}" chart does not draw data labels; "labels" has no effect on it. Types that do: ${[...Qn].join(", ")}.`)}qt(this.#o,{viewBox:`0 0 ${P} ${K}`,width:P,height:K});const dt=Hr.has(oe)||!!(he&&he.hierarchical),mt=this.#yt(oe);if(mt===Fn)return null;mt&&mt.over&&Gt(`chart:viewportCap:over:${this.#r}`,`this map's view holds ${mt.over.count} matching rows, more than its viewportCap of ${mt.over.cap}, and ${mt.over.reason}, so it draws none of them. Zoom in, narrow the filter, or raise viewportCap.`);let Ue;if(he&&Ve({grid:this.#n,spec:this.#e,type:oe,id:this.#r}),mt)Ue=mt;else if(he&&typeof he.bind=="function")Ue=he.bind(this.#n,this.#e),h.has(oe)&&(Ue=this.#vt(oe,Ue));else if(dt)Ue=R(this.#n,this.#e),this.#p&&this.#p.length&&(Ue=io(Ue,this.#p));else if(Zr.has(oe))Ue=z(this.#n,oe==="candlestick"?this.#Ze():this.#e);else if(tr.has(oe)&&Array.isArray(this.#e.measures)&&this.#e.measures.length)Ue=z(this.#n,this.#e);else if(Yr.has(oe))Ue=I(this.#n,this.#e,oe==="network"?{perRow:!0,nodes:this.#e.nodes}:void 0);else if(Jr.has(oe)){const ut=ee(this.#n);Ue={rows:ut,series:[],categories:[],labels:[],measure:{col:null,fn:"sum",title:""},dimension:{col:this.#e.label||null,title:""},empty:!ut.length}}else oe==="geomap"?Ue=re(this.#n,{...this.#e,x:this.#e.code||this.#e.x}):Array.isArray(this.#e.points)?Ue=Y(this.#e):Kr.has(oe)?Ue=re(this.#n,Vr(this.#e)):Ue=re(this.#n,this.#e);const Wt=j(Se&&Se.x,Date.now());this.#a=Ue;const Ze=q(Ue,Se&&Se.x,oe,Wt);if(Ze){const ut=typeof this.#e.x=="string"?` "${this.#e.x}"`:"",nt=`${Math.round(y*1e3)/10}%`;Gt(`chart:${this.#r}:x:window:ahead`,`${Ze.count} reading(s) on the x axis${ut} were not drawn: stamped up to ${no(Ze.lead)} ahead of this device's clock, which is more than the ${ir(Ze.limit)} (${nt} of the ${ir(Ze.span)} rolling window) a reading may run ahead and still move the window. This is a producer whose clock is wrong, not a window that is too narrow: letting that reading carry the window would push every other producer's recent readings out of it, so it is left out instead. Correct the producer's clock (NTP), or stamp readings where they are received.`)}const kt=B({grid:this.#n,spec:this.#e,type:oe,bound:Ue,axis:Se,now:Wt,id:this.#r});if(!kt.ok)return kt.tell&&Gt(kt.key,kt.message),this.#Qe(this.#e.emptyText||He.t("chart.empty")),null;if(Ue=U(Ue,Se&&Se.x,oe,Wt),Ue=this.#lt(Ue,oe,Se,Wt),this.#a=Ue,this.#O.setAttribute("hidden",""),this.#o.removeAttribute("hidden"),c(this.#c,null),oe!=="candlestick"&&(Ut(this.#c),this.#me()),he){const ut=he.freeform?n({width:P,height:K,fontSize:Fe,margin:this.#e.margin}):n({width:P,height:K,fontSize:Fe,margin:this.#e.margin,titleSize:Ye.axisTitle,titles:{left:Se.y.title,bottom:Se.x.title,right:Se.y2.title},yLabels:nr,xLabels:Ue.labels,rotated:!0});if(this.#t=he.draw({doc:this.#i,groups:this.#c,plot:ut,bound:Ue,type:oe,grid:this.#n,fontSize:Fe,hidden:this.#g,scheme:ve,axis:Se,typography:Ye,labels:Xe,spec:this.#e,geoView:{zoom:this.#u.zoom,offset:this.#u.offset},helpers:Br})||{},this.#d(Array.isArray(this.#t.legend)?this.#t.legend:[],this.#$e(this.#t,Ue.measure&&Ue.measure.col)),Ue.over){const nt=new i(this.#c.overlay),pt=nt.next("text",`${it}__geo-note`);qt(pt,{x:an(ut.left),y:an(ut.bottom),"text-anchor":"start"}),vt(pt,He.t("chart.viewportOverCap",{count:Ue.over.count,cap:Ue.over.cap})),nt.finish()}this.#xt(oe)}else if(oe==="treemap"){const ut=n({width:P,height:K,fontSize:Fe,padding:2,margin:this.#e.margin});this.#t=we({scheme:ve,groups:this.#c,plot:ut,tree:Ue,grid:this.#n,hidden:this.#g,fontSize:Fe,typography:Ye,labels:Xe}),this.#d(Ue.root.children.map((nt,pt)=>({key:nt.label,label:nt.label,index:pt})))}else if(Ur.has(oe)){const ut=n({width:P,height:K,fontSize:Fe});this.#t=xe({scheme:ve,doc:this.#i,groups:this.#c,plot:ut,tree:Ue,type:oe,grid:this.#n,hidden:this.#g,fontSize:Fe,typography:Ye,labels:Xe,centre:this.#e.centre});const nt=this.#n.columns&&Ue.measure&&Ue.measure.col?this.#n.columns.get(Ue.measure.col):null;this.#d(Ue.root.children.map((pt,Tt)=>({key:pt.label,label:pt.label,index:Tt,value:C(pt.total,nt,this.#n),colour:ve.series(Tt,pt.label)})))}else{const ut=Xr.has(oe)?n({width:P,height:K,fontSize:Fe,margin:this.#e.margin,yLabels:oe==="heatmap"?or(oe,Ue,this.#n,this.#e):[],xLabels:oe==="heatmap"?Ue.labels:[],rotated:!0}):n({width:P,height:K,fontSize:Fe,margin:this.#e.margin,titleSize:Ye.axisTitle,ySide:te[oe]&&!te[oe].horizontal&&Se.y.position==="right"?"right":"left",titles:te[oe]&&te[oe].horizontal?{left:Se.x.title,bottom:Se.y.title,right:Se.y2.title}:te[oe]&&Se.y.position==="right"?{left:Se.y2.title,bottom:Se.x.title,right:Se.y.title}:{left:Se.y.title,bottom:Se.x.title,right:Se.y2.title},rightGutter:this.#Xe(oe,Ue)?Math.round(Fe*3):0,yLabels:or(oe,Ue,this.#n,this.#e),xLabels:rr.has(oe)?[]:Ue.labels,rotated:!0}),nt={doc:this.#i,groups:this.#c,plot:ut,bound:Ue,type:oe,grid:this.#n,fontSize:Fe,hidden:this.#g,scheme:ve,axis:Se,typography:Ye,labels:Xe,byRuleColour:!this.#e.series};if(oe!=="geomap"&&this.#Oe(null),this.#e.multiples)this.#t=this.#Je(nt),this.#d([]);else if(oe==="combo"||oe==="pareto")this.#t=ht({...nt,pareto:oe==="pareto",reference:this.#e.reference,annotations:this.#e.annotations,emphasis:this.#e.emphasis,seriesStyle:this.#e.seriesStyle}),this.#d(this.#ee(this.#t.series,Ue.measure&&Ue.measure.col));else if(oe==="heatmap")this.#t=ke({...nt,diverging:this.#e.diverging}),this.#d([],this.#$e(this.#t,Ue.measure&&Ue.measure.col));else if(oe==="radar")this.#t=Dt(nt),this.#d(this.#ee(Ue.series,Ue.measure&&Ue.measure.col));else if(oe==="gauge")this.#t=Ct({...nt,min:this.#e.min,max:this.#e.max,target:this.#e.target}),this.#d([]);else if(oe==="sankey")this.#t=mn(nt),this.#d([]);else if(oe==="chord")this.#t=yn(nt),this.#d([]);else if(oe==="network")this.#t=On({...nt,iterations:this.#e.iterations,icon:this.#e.icon,linkWidth:this.#e.linkWidth}),this.#d(Array.isArray(this.#t.legend)?this.#t.legend:[]);else if(oe==="stream")this.#t=xn(nt),this.#d(this.#ee(Ue.series,Ue.measure&&Ue.measure.col));else if(oe==="marimekko")this.#t=vn(nt),this.#d(this.#ee(Ue.series,Ue.measure&&Ue.measure.col));else if(oe==="violin")this.#t=Tn(nt),this.#d([]);else if(oe==="gantt")this.#t=gn({...nt,spec:this.#e,rows:Ue.rows||[]}),this.#d([]);else if(oe==="geomap")this.#t=Je({...nt,shapes:this.#e.shapes,codeProperty:this.#e.codeProperty,diverging:this.#e.diverging,projection:this.#e.projection,projectionOptions:this.#e.projectionOptions,layer:this.#e.layer,graticule:this.#e.graticule,basemap:this.#e.basemap,zoom:this.#u.zoom,centreOffset:this.#u.offset}),this.#Ee(this.#t&&this.#t.ramp),this.#d([]),this.#Oe(this.#t);else if(oe==="correlogram")this.#t=Z({...nt,columns:this.#tt(),method:this.#e.method,values:this.#e.values}),this.#d([]);else if(oe==="forest")this.#t=W(nt),this.#d([]);else if(oe==="funnel")this.#t=Oe(nt),this.#d([]);else if(oe==="candlestick")this.#t=Jt({...nt,volume:this.#me(),volumeHeight:this.#Ve()}),this.#d([]);else if(Wr.has(oe)){if(oe==="histogram")this.#t=G({...nt,buckets:this.#e.buckets,curve:this.#e.curve});else if(oe==="movingRange")this.#t=le(nt);else if(oe==="control"||oe==="capability"){const pt=this.#e.y||this.#e.measure,Tt=this.#n&&this.#n.statistics;this.#t=(oe==="capability"?_e:Re)({...nt,capability:Tt&&pt?Tt.capability(pt,{by:this.#e.x,baseline:this.#e.baseline,rules:this.#e.rules,confidence:this.#e.confidence,...this.#e.spec||{}}):null})}else oe==="qq"?this.#t=ae(nt):oe==="ecdf"?this.#t=fe(nt):oe==="lorenz"?this.#t=se(nt):this.#t=je(nt);this.#d([])}else{this.#t=J({...nt,fit:this.#e.fit,trend:this.#e.trend,band:this.#e.band,error:this.#e.error,dense:br({series:Ue.series,canvas:this.#e.canvas}),downsampleTo:this.#e.downsample,stack:this.#e.stack,reference:this.#e.reference,annotations:this.#e.annotations,sizes:this.#qe(Ue),emphasis:this.#e.emphasis,seriesStyle:this.#e.seriesStyle});const pt=Array.isArray(this.#t.legend)?this.#t.legend:null;this.#d(pt||(Ue.series.length>1?this.#ee(Ue.series,Ue.measure&&Ue.measure.col,Tt=>ve.series(Tt.index,Tt.label)):[]))}}const Nt=this.#t&&this.#t.errorBars;if(this.#e.error&&Nt&&Nt.marks&&!this.#ne&&(!Nt.drawn||Nt.singleSkipped)){this.#ne=!0;const ut=this.#i&&this.#i.defaultView,nt=ut&&ut.console||(typeof globalThis<"u"?globalThis.console:null);if(nt&&typeof nt.warn=="function"){let pt;Nt.drawn?pt=`[lattice] error bars were requested but ${Nt.singleSkipped} of ${Nt.marks} marks have a single reading behind them, so their whiskers were not drawn; the other marks are shown. A bar with no whisker is easily read as the certain one: bind those categories to the readings they summarise, or supply a margin column with \`error: { of: "column" }\`.`:pt=Nt.single===Nt.marks?'[lattice] error bars were requested but every mark has a single reading behind it, so there is no spread to compute. A chart bound to a summary or derived grid sees one row per mark: bind it to the rows the summary was computed from, or supply a margin column with `error: { of: "column" }`.':"[lattice] error bars were requested but no mark had enough readings to compute an interval.",nt.warn(pt)}}return this.#t&&(this.#t.plot=this.#t.plot||so(this.#t,P,K)),this.#a&&(this.#a.outside=this.#t&&this.#t.outside||0),this.#e.selection&&this.#Ne(),this.#Pe(),this.#it(oe,Ue,dt),this.#at(oe),this.#We(oe),this.#ft(),this.#Ye(Se),{width:P,height:K,chartType:oe,categories:Ue.categories||[],empty:!!Ue.empty}}#me(){const N=this.#e.volume;if(N==null||N==="")return null;const P=this.#e.type;return P!=="candlestick"?(Gt(`chart:${this.#r}:volume:type:${P}`,`"volume" adds a volume pane under a candlestick's price pane, and this chart's type is ${JSON.stringify(P)}, so no volume pane was drawn. Set type: 'candlestick', or draw the volume as its own bar chart.`),null):typeof N!="string"||!this.#n.columns||!this.#n.columns.get(N)?(Gt(`chart:${this.#r}:volume:missing-column`,`"volume" names ${JSON.stringify(N)}, which is not a column of this grid, so the candlestick was drawn without a volume pane. Name the column that holds each period's traded volume by its id.`),null):N}#Ve(){const N=this.#e.volumePane,P=N&&typeof N=="object"?N.height:void 0;return P===void 0?Ne:typeof P=="number"&&P>0&&P<1?P:(Gt(`chart:${this.#r}:volumePane:height`,`"volumePane.height" is the volume pane's share of the plot's height, a number above 0 and below 1, and was given ${JSON.stringify(P)}, so the default of ${Ne} was used.`),Ne)}#Ze(){const N=this.#me(),P=Array.isArray(this.#e.measures)?this.#e.measures:[];if(!N||P.length<4)return this.#e;const K=oe=>typeof oe=="string"?oe:oe&&oe.col,he=P.slice(4).filter(oe=>K(oe)!==N);return{...this.#e,measures:[...P.slice(0,4),{col:N,fn:"sum"},...he]}}#Ye(N){const P=be(N&&N.x),K=P?Math.min(Qr,Math.max(eo,Math.floor(P/4))):0;if(this.#E||!K){this.#ge();return}if(this.#U&&this.#fe===K)return;this.#ge(),this.#fe=K;const he=Qt(this.#i),oe=he&&typeof he.setInterval=="function"?he.setInterval.bind(he):setInterval;this.#U=oe(()=>{this.#E||this.#i&&this.#i.hidden||this.#s&&this.#s.isConnected===!1||this.schedule()},K);const ve=this.#U;ve&&typeof ve.unref=="function"&&ve.unref()}#ge(){if(this.#U===null)return;const N=Qt(this.#i);(N&&typeof N.clearInterval=="function"?N.clearInterval.bind(N):clearInterval)(this.#U),this.#U=null,this.#fe=0}#Je(N){const P=We(N.bound),K=$e({count:P.length,plot:N.plot}),he=[];for(const Ye of N.bound.series)for(const Fe of Ye.points)he.push(Fe.y);const oe=l(he,{zero:N.type!=="line"}),ve=new i(this.#c.overlay);c(this.#c,N.plot);const Se=new i(this.#c.marks);new i(this.#c.grid).finish(),new i(this.#c.axis).finish(),new i(this.#c.rules).finish();let He=null;for(let Ye=0;Ye<K.length;Ye++){const Fe=K[Ye],Xe=P[Ye],dt={left:Fe.x,top:Fe.y,width:Fe.width,height:Fe.height,right:Fe.x+Fe.width,bottom:Fe.y+Fe.height,gutter:{left:0,bottom:0}};He=J({...N,plot:dt,bound:Xe.bound,domain:oe,pool:Se,axes:!1});const mt=ve.next("text",`${it}__panel-title`);qt(mt,{x:an(Fe.x),y:an(Fe.y-4),"text-anchor":"start"}),vt(mt,Xe.label)}return Se.finish(),ve.finish(),{...He||{},panels:K,multiples:!0}}#Xe(N,P){return N==="combo"||N==="pareto"?!0:!tr.has(N)||N==="horizontalBar"||N==="waterfall"?!1:!!(P&&Array.isArray(P.series)&&P.series.some(K=>K.axis==="right"&&!this.#g.has(K.key)))}#qe(N){if(this.#e.type!=="bubble"||!this.#e.size)return null;const P=[];for(const he of N.series||[])for(const oe of he.points)typeof oe.size=="number"&&P.push(oe.size);const K=Zn(P);return K?L(K,[3,Math.max(6,Math.min(28,this.#e.maxRadius||22))]):null}#Qe(N){this.#Pe(),vt(this.#O,N),this.#O.removeAttribute("hidden"),this.#o.setAttribute("hidden","");for(const P of Object.values(this.#c))Zt(P);Zt(this.#y),Zt(this.#w),this.#t=null}#Pe(){const N=this.#n.licence;if(!!!(N&&typeof N.watermark=="function"&&N.watermark())){this.#T&&this.#T.parentNode&&this.#T.parentNode.removeChild(this.#T),this.#T=null;return}if(this.#T&&this.#T.parentNode)return;const K=this.#i,he=lt(K,"div",`${it}__watermark`);he.setAttribute("role","note");const oe=lt(K,"a",`${it}__watermark-link`);oe.setAttribute("href","https://www.latticegrid.dev"),oe.setAttribute("target","_blank"),oe.setAttribute("rel","noopener noreferrer"),vt(oe,this.#n.messages.t("licence.watermark")),he.appendChild(oe),this.#T=he,this.#s&&this.#s.appendChild(he)}#et(){const N=this.#e.legend;if(N===!1)return{show:!1,position:"bottom",align:"start",shape:"square",maxItems:0,isolate:!1,values:!1,title:""};const P=N&&typeof N=="object"?N:{};return{show:!0,position:["top","bottom","left","right"].includes(P.position)?P.position:"bottom",align:["start","centre","center","end"].includes(P.align)?P.align:"start",shape:["square","circle","line"].includes(P.shape)?P.shape:"square",maxItems:Number.isFinite(P.maxItems)&&P.maxItems>0?Number(P.maxItems):0,isolate:!!P.isolate,values:!!P.values,title:typeof P.title=="string"?P.title:""}}#ee(N,P,K){const he=P&&this.#n.columns?this.#n.columns.get(P):null;return(N||[]).map(oe=>({key:oe.key,label:oe.label,index:oe.index,value:C(qr(oe),he,this.#n),...K?{colour:K(oe)}:{}}))}#tt(){const N=this.#e.columns;if(Array.isArray(N)&&N.length)return N.slice(0,er);const P=this.#n;return!P||!P.columns||typeof P.columns.visible!="function"?[]:P.columns.visible().filter(K=>!K.generated&&(K.type==="number"||K.type==="currency"||K.type==="percent"||K.type==="integer")).map(K=>K.id).slice(0,er)}#d(N,P=null){Zt(this.#y);const K=this.#et();if(qt(this.#y,{"data-position":K.position,"data-align":K.align}),!K.show||!N.length&&!P)return;const he=this.#i;if(P&&this.#y.appendChild(this.#nt(P,K)),!N.length)return;const oe=K.maxItems?N.slice(0,K.maxItems):N;for(const ve of oe){const Se=lt(he,"button",`${it}__legend-item`);Se.setAttribute("type","button");const He=!this.#g.has(ve.key);Se.setAttribute("aria-pressed",He?"true":"false");const Ye=lt(he,"span",`${it}__swatch ${it}__swatch--${K.shape}`);Ye.setAttribute("style",`background:${ve.colour||this.#Z.series(ve.index)}`);const Fe=lt(he,"span");en(Fe,this.#C.small),vt(Fe,K.values&&ve.value?`${ve.label} ${ve.value}`:ve.label),un(Se,[Ye,Fe]),Se.addEventListener("click",()=>{this.#rt(ve,N,K)}),this.#y.appendChild(Se)}if(K.maxItems&&N.length>oe.length){const ve=lt(he,"span",`${it}__legend-more`);en(ve,this.#C.small),vt(ve,this.#n.messages.t("chart.legendMore",{count:N.length-oe.length})),this.#y.appendChild(ve)}}#nt(N,P){const K=this.#i,he=lt(K,"div",`${it}__legend-ramp`);if(P.title){const Fe=lt(K,"span",`${it}__legend-ramp-title`);en(Fe,this.#C.small),vt(Fe,P.title),he.appendChild(Fe)}const oe=lt(K,"span",`${it}__legend-ramp-label`);en(oe,this.#C.small),vt(oe,N.minLabel);const ve=lt(K,"span",`${it}__legend-ramp-bar`),Se=P.position==="left"||P.position==="right";ve.setAttribute("style",`background:linear-gradient(${Se?"to top":"to right"}, ${N.colours.join(",")})`),he.setAttribute("data-scale",N.scale||"linear");const He=Array.isArray(N.ticks)?N.ticks:[];He.length&&he.setAttribute("data-ticks",String(He.length));for(const Fe of He){const Xe=lt(K,"span",`${it}__legend-ramp-tick`);en(Xe,this.#C.small);const dt=Math.round(Math.min(1,Math.max(0,Fe.t))*1e3)/10;Xe.setAttribute("style",Se?`bottom:${dt}%`:`left:${dt}%`),Xe.setAttribute("data-value",String(Fe.value)),vt(Xe,Fe.label),ve.appendChild(Xe)}const Ye=lt(K,"span",`${it}__legend-ramp-label`);return en(Ye,this.#C.small),vt(Ye,N.maxLabel),un(he,[oe,ve,Ye]),he}#$e(N,P){if(!N||typeof N.ramp!="function"||!N.domain)return null;const K=N.ramp;this.#Ee(K);const he=K.scale==="log"||K.scale==="quantile",{min:oe,max:ve}=he&&K.domain?K.domain:N.domain;if(!Number.isFinite(oe)||!Number.isFinite(ve))return null;const Se=P&&this.#n.columns?this.#n.columns.get(P):null,He=[];if(K.scale==="quantile"&&K.classes>1)for(let Fe=0;Fe<K.classes;Fe++){const Xe=K.colourAt(Fe/(K.classes-1)),dt=Math.round(Fe/K.classes*1e3)/10,mt=Math.round((Fe+1)/K.classes*1e3)/10;He.push(`${Xe} ${dt}% ${mt}%`)}else if(he)for(let Fe=0;Fe<6;Fe++)He.push(K.colourAt(Fe/5));else for(let Xe=0;Xe<6;Xe++){const dt=Xe/5;He.push(K(oe+(ve-oe)*dt))}const Ye=he&&Array.isArray(K.ticks)?K.ticks.map(Fe=>({t:Fe.t,value:Fe.value,label:C(Fe.value,Se,this.#n)})):[];return{colours:He,minLabel:C(oe,Se,this.#n),maxLabel:C(ve,Se,this.#n),scale:K.scale||"linear",ticks:Ye}}#Ee(N){typeof N!="function"||!N.scale||(this.#se={scale:N.scale,auto:!!N.auto,ratio:N.ratio||0},N.auto&&N.scale==="log"&&Pr(`chart:${this.#r}:ramp:log`,`chart ${this.#e.type} is coloured on a log ramp scale: its values span ${Math.round(N.ratio).toLocaleString("en")}:1, past the 100:1 at which a linear ramp leaves all but the largest in its palest shade. Set ramp: { scale: "linear" } to keep it linear.`))}#rt(N,P,K){if(K.isolate){const he=P.filter(ve=>ve.key!==N.key),oe=he.every(ve=>this.#g.has(ve.key))&&!this.#g.has(N.key);if(this.#g.clear(),!oe)for(const ve of he)this.#g.add(ve.key)}else this.#g.has(N.key)?this.#g.delete(N.key):this.#g.add(N.key);this.emit("legend",{label:N.label,key:N.key,hidden:this.#g.has(N.key),hiddenKeys:[...this.#g]}),this.draw()}#ot(){const N=this.#n.messages,P=this.#k.viewport;return P?P.over?N.t("chart.viewportOverCap",{count:P.matched,cap:P.cap}):P.binned?N.t(P.computed==="client"?"chart.summaryClientDensity":"chart.summaryEngineDensity",{count:P.matched,cap:P.cap,cells:P.cells}):N.t("chart.summaryEngineViewport",{count:P.rows}):N.t("chart.summaryEngine")}#it(N,P,K){const he=this.#n.messages,oe=P.measure&&P.measure.title||"",ve=P.dimension&&P.dimension.title||"",Se=oe?ve&&!K?"chart.summary":"chart.summaryShare":"chart.summaryType",He=he.t(Se,{type:he.t(`chart.type.${N}`),measure:oe,dimension:ve}),Ye=this.#k.source==="engine"||this.#k.viewport?this.#ot():"",Fe=Ye?`${He}. ${Ye}`:He;qt(this.#o,{"aria-label":Fe}),Zt(this.#w);const Xe=this.#i,dt=lt(Xe,"table"),mt=lt(Xe,"caption");vt(mt,he.t("chart.dataTable")),dt.appendChild(mt);const Ue=lt(Xe,"tr"),Wt=lt(Xe,"th");vt(Wt,K?"":ve),Ue.appendChild(Wt);const Ze=[];if(K&&P.root){for(const nt of P.root.children){const pt=lt(Xe,"tr"),Tt=lt(Xe,"th");vt(Tt,nt.label);const dn=lt(Xe,"td");vt(dn,ne(nt.total,he)),un(pt,[Tt,dn]),Ze.push(pt)}const ut=lt(Xe,"th");vt(ut,oe),Ue.appendChild(ut)}else{const ut=this.#ae(),nt=this.#t&&Array.isArray(this.#t.labels)&&Array.isArray(this.#t.series)&&Array.isArray(this.#t.categories)?this.#t.series:P.series||[];for(const pt of nt){const Tt=lt(Xe,"th");vt(Tt,pt.label),Ue.appendChild(Tt)}for(let pt=0;pt<(ut.labels||[]).length;pt++){const Tt=lt(Xe,"tr"),dn=lt(Xe,"th");vt(dn,ut.labels[pt]),Tt.appendChild(dn);for(const Pn of nt){const Mn=lt(Xe,"td"),In=Pn.points[pt];vt(Mn,In&&In.y!==null?ne(In.y,he):""),Tt.appendChild(Mn)}Ze.push(Tt)}}dt.appendChild(Ue);for(const ut of Ze)dt.appendChild(ut);this.#w.appendChild(dt);const kt=this.#t&&Number(this.#t.unplaced);if(kt>0){const ut=lt(Xe,"p",`${it}__table-note`);vt(ut,he.t("chart.geoUnmatched",{count:kt})),this.#w.appendChild(ut)}const Nt=this.#t&&this.#t.annotations;if(Array.isArray(Nt)&&Nt.length){const ut=lt(Xe,"ul",`${it}__annotation-list`);for(const nt of Nt){if(!nt||!nt.text)continue;const pt=lt(Xe,"li");vt(pt,nt.text),ut.appendChild(pt)}ut.childNodes&&ut.childNodes.length&&this.#w.appendChild(ut)}}on(N,P){return typeof P!="function"?()=>{}:(this.#D.has(N)||this.#D.set(N,new Set),this.#D.get(N).add(P),()=>{const K=this.#D.get(N);K&&K.delete(P)})}emit(N,P){const K={...P,type:N,chart:this,grid:this.#n},he=this.#e[`on${N.charAt(0).toUpperCase()}${N.slice(1)}`],oe=[...this.#D.get(N)||[]];typeof he=="function"&&oe.unshift(he);for(const ve of oe)try{ve(K)}catch(Se){const He=Qt(this.#i);He.console&&typeof He.console.error=="function"&&He.console.error(`[lattice] a chart "${N}" listener threw`,Se)}return K}#st(){const N=this.#t;return N&&N.anchor&&rt.has(this.#e.type)?{plot:N.plot,xScale:N.anchor.xScale,yScale:N.anchor.yScale}:N}#at(N){const P=Ie(this.#e.annotate),K=P.enabled&&rt.has(N)&&!!this.#t&&!this.#t.anchor;K&&Gt(`chart:${this.#r}:annotate:projection`,`"annotate" anchors a drawing on a ${JSON.stringify(N)} in longitude and latitude, and this map is drawn through a projection with no written inverse, so no rail was added. Draw it through projection: 'mercator' or 'equirectangular' to annotate it.`);const he=P.enabled&&Rn.has(N)&&!K;if(P.enabled&&!Rn.has(N)&&Gt(`chart:${this.#r}:annotate:type:${N}`,`"annotate" adds a drawing rail to a chart with two readable axes and ${JSON.stringify(N)} has none, so no rail was added. The types that take one are ${[...Rn].sort().join(", ")}.`),!he){this.#h&&(this.#h.destroy(),this.#h=null);return}this.#h?this.#h.configure(P):(this.#h=new Ee({doc:this.#i,root:this.#s,plot:this.#o,groups:this.#c,t:(oe,ve)=>this.#n.messages.t(oe,ve),drawn:()=>this.#st(),format:()=>this.#bt(),bound:()=>this.#a,notify:(oe,ve,Se)=>{const He=Se?{item:ve,readout:Se}:{item:ve};oe==="added"?this.emit("annotation:added",He):oe==="changed"?this.emit("annotation:changed",He):this.emit("annotation:removed",He)}},P),this.#Y&&(this.#h.setItems(this.#Y),this.#Y=null)),this.#h.redraw()}#lt(N,P,K,he){const oe=ot(this.#e.zoom);if(this.#_=oe.enabled&&zn.has(P),oe.enabled&&!zn.has(P)&&Gt(`chart:${this.#r}:zoom:type:${P}`,`"zoom" narrows a chart's own axes and ${JSON.stringify(P)} has none to narrow, so no zoom was added. The types that take one are ${[...zn].sort().join(", ")}.`),!this.#_)return this.#N={x:null,y:null},this.#f={x:null,y:null},this.#v=N.categories||[],this.#oe={first:0,last:Math.max(0,this.#v.length-1)},N;this.#B=me(N,P,K&&K.x),this.#v=N.categories||[],this.#N.x=this.#B?this.#v.length>1?{min:0,max:this.#v.length-1}:null:D(N,P,K&&K.x,he),oe.axes==="y"&&(this.#f.x=null),oe.axes==="x"&&(this.#f.y=null),this.#ct(oe),this.#f.x=St(this.#f.x,this.#N.x),this.#f.y=St(this.#f.y,this.#N.y);let ve=N;const Se=this.#f.x;if(this.#B){const{first:He,last:Ye}=ze(Se,this.#v.length);this.#oe={first:He,last:Ye},Se&&(ve=zt(ve,He,Ye))}else this.#oe={first:0,last:Math.max(0,this.#v.length-1)},Se&&(ve={...ve,xDomain:{min:Se.from,max:Se.to}});return this.#f.y&&(ve={...ve,yDomain:{min:this.#f.y.from,max:this.#f.y.to}}),ve}#ct(N){const P=this.#G;if(!P)return;const K={};for(const he of["x","y"]){if(!(he in P)||N.axes!=="xy"&&N.axes!==he)continue;if(!this.#N[he]){K[he]=P[he];continue}this.#f[he]=this.#Te(he,P[he])}this.#G=Object.keys(K).length?K:null}#Te(N,P){const K=this.#N[N];if(!K)return null;const he=Array.isArray(P)?P:P&&P.range;if(!Array.isArray(he)||he.length<2)return null;const oe=N==="x"&&this.#B?he.map(Se=>this.#ut(Se)):he.map(Se=>this.#a&&this.#a.kind==="time"&&N==="x"?Jn(Se):Yn(Se));if(oe.some(Se=>Se===null||!Number.isFinite(Se)))return Gt("chart:zoom:range","a chart zoom range named a value this chart's axis does not have, so the zoom was left alone. An x range on a category axis names two categories; on a continuous or time axis it is two readings, and a measure range is two values."),null;const ve=nn(oe,K);return ve&&P&&P.pinned?St({...ve,pinned:!0},K):ve}#ut(N){const P=r(N);for(let K=0;K<this.#v.length;K++)if(r(this.#v[K])===P)return K;return null}#ft(){const N=ot(this.#e.zoom);if(!this.#_||N.buttons==="none")this.#pe();else{if(this.#M&&this.#M.buttons!==N.buttons&&this.#pe(),!this.#M){const P=Mt({doc:this.#i,t:he=>this.#n.messages.t(he),controls:[...Yt],buttons:N.buttons,onPress:he=>this.#W(he,"button")});this.#M={...P,buttons:N.buttons};const K=this.#o.parentNode;K&&K.appendChild(P.element)}this.#M.sync({zoomed:!!(this.#f.x||this.#f.y),narrowest:this.#ht(N)})}if(this.#_&&!this.#f.y){const P=this.#t&&this.#t.yScale&&this.#t.yScale.domain;P&&Number.isFinite(P.min)&&Number.isFinite(P.max)&&(this.#N.y={min:P.min,max:P.max},this.#G&&"y"in this.#G&&this.schedule())}}#ht(N){for(const P of["x","y"]){const K=this.#N[P],he=this.#f[P];if(!K||!he)continue;const oe=K.max-K.min;if(oe>0&&he.to-he.from>oe*N.min*1.0001)return!1}return!!(this.#f.x||this.#f.y)}#pe(){this.#M&&this.#M.element.parentNode&&this.#M.element.parentNode.removeChild(this.#M.element),this.#M=null}#le(N,P){if(!this.#_)return!1;const K=ot(this.#e.zoom);let he=!1;for(const oe of["x","y"]){if(K.axes!=="xy"&&K.axes!==oe)continue;const ve=this.#N[oe];if(!ve)continue;const Se=St(N(oe,this.#f[oe],ve,K),ve);Ot(Se,this.#f[oe])||(this.#f[oe]=Se,he=!0)}return he?(this.draw(),this.emit("zoom",this.#dt(P)),!0):!1}#W(N,P,K){return N==="reset"?this.#le(()=>null,"reset"):this.#le((he,oe,ve,Se)=>{const He=K&&Number.isFinite(K[he])?K[he]:null;return N==="in"?qe(oe,ve,1-Se.step,He,Se.min):N==="out"?qe(oe,ve,1/(1-Se.step),He,Se.min):he!=="x"?oe:$t(oe,ve,N==="left"?-Se.step:Se.step)},P)}#dt(N){const P=ot(this.#e.zoom),K={x:this.#be("x"),reason:N};return(P.axes==="y"||P.axes==="xy")&&(K.y=this.#be("y")),K}#be(N){const P=this.#N[N];if(!P)return null;const K=this.#f[N];if(N==="x"&&this.#B){const{first:he,last:oe}=ze(K,this.#v.length);return[this.#v[he],this.#v[oe]]}return K?[K.from,K.to]:[P.min,P.max]}#mt(N){const P={x:null,y:null};if(!this.#t)return P;if(this.#B){const he=this.#ve(N);he>=0&&(P.x=this.#oe.first+he)}else if(this.#t.xScale&&typeof this.#t.xScale.invert=="function"){const he=this.#t.xScale.invert(this.#t.horizontal?N.y:N.x);Number.isFinite(he)&&(P.x=he)}const K=this.#t.yScale;if(K&&typeof K.invert=="function"){const he=K.invert(this.#t.horizontal?N.x:N.y);Number.isFinite(he)&&(P.y=he)}return P}get zoom(){return this.#ue||(this.#ue=Object.freeze({set:N=>this.#gt(N),reset:()=>this.#W("reset","reset")})),this.#ue}#gt(N){if(!this.#_)return Gt(`chart:${this.#r}:zoom:off`,'chart.zoom.set() was called on a chart with no zoom, so nothing moved. Set `zoom: true` on a cartesian chart (or `zoom: { buttons: "none" }` to drive it from your own controls) before setting a range.'),!1;const P=Array.isArray(N)?{x:N}:N||{};return this.#le((K,he)=>K in P?this.#Te(K,P[K]):he,"api")}#pt(){const N={};for(const P of["x","y"]){const K=this.#f[P];K&&(N[P]={range:this.#be(P),pinned:!!K.pinned})}return Object.keys(N).length?N:null}#bt(){const N=this.#t&&this.#t.yScale&&this.#t.yScale.domain||null,P=N&&Number.isFinite(N.max)&&Number.isFinite(N.min)?(N.max-N.min)/5:0;return qn(this.#n,{kind:"linear",step:P}).tick}state(){const N={annotations:this.#h?this.#h.list():Ge(this.#Y).map(Ke)},P=this.#pt();return P&&(N.zoom=P),N}setState(N){if(this.#h?this.#h.setItems(N):this.#Y=N,!N||Array.isArray(N))return;const P=N.zoom;this.#G=P&&typeof P=="object"?{...P}:null,this.#G||(this.#f={x:null,y:null}),this.schedule()}data(){return this.#a}provenance(){const N=this.#k;return{source:N.source,asked:N.asked,reason:N.reason??null,refused:!!N.refused,pending:!!N.pending,measures:N.measures.map(P=>({...P})),...N.viewport?{viewport:{...N.viewport,bbox:N.viewport.bbox?[...N.viewport.bbox]:null}}:{},...this.#se?{ramp:{...this.#se}}:{}}}#K(N,P){this.#Le();const K=P.asked!=="client"&&f(this.#n);return this.#k={source:"client",asked:P.asked,reason:P.reason,refused:P.refused,pending:!1,measures:v(b(this.#n,this.#e,N),"client",[],P.reason)},P.refused?Gt(`chart:aggregate:engine-refused:${this.#r}:${P.reason}`,`chart aggregate: 'engine' was refused: ${P.reason}. The chart reads the rows the grid has loaded instead; chart.provenance() reports the same reason.`):K&&Gt(`chart:aggregate:window:${this.#r}:${P.reason}`,`this chart draws the rows the grid has loaded, which are a window of the matching set, because ${P.reason}. Its figures describe that window, not the whole relation.`),this.#o?.removeAttribute?.("aria-busy"),null}#yt(N){if(h.has(N))return this.#wt(N);this.#H=null;const P=F(this.#n,this.#e,N);if(P.mode==="client")return this.#K(N,P);const K=this.#R.answer(P.key);if(K){if(K.error!==void 0){const oe=K.error&&K.error.message?K.error.message:String(K.error);return this.#K(N,{asked:P.asked,refused:P.asked==="engine",reason:`the engine request failed (${oe})`})}const he=K.result||{};return he.client&&he.client.length?this.#K(N,{asked:P.asked,refused:P.asked==="engine",reason:`the source computed "${he.client[0].fn}" client-side (${he.client[0].reason})`}):(this.#k={source:"engine",asked:P.asked,reason:null,refused:!1,pending:!1,measures:v(P.measures,"engine",he.engine||[])},this.#o?.removeAttribute?.("aria-busy"),g(this.#n,this.#e,P,he.groups||[]))}return this.#At(P),this.#k={...this.#k,asked:P.asked,pending:!0},this.#o&&this.#o.setAttribute("aria-busy","true"),Fn}#wt(N){const P=d(this.#n,this.#e,N,this.#J);if(P.mode==="client")return this.#H=null,this.#K(N,P);this.#H=P;let K=this.#R.answer(P.key);const he=this.#R.last();!K&&he&&he.error===void 0&&he.result&&he.result.kind==="rows"&&he.result.rowsKey===P.rowsKey&&(K=he);let oe=!1;if(!K){this.#R.ask(P.key,P.run,()=>{this.#E||this.schedule()});const He=this.#R.last();if(!(He&&He.error===void 0&&He.result&&He.result.map))return this.#k={...this.#k,asked:P.asked,pending:!0},this.#o&&this.#o.setAttribute("aria-busy","true"),Fn;K=He,oe=!0}if(K.error!==void 0){const He=K.error&&K.error.message?K.error.message:String(K.error);return this.#K(N,{asked:P.asked,refused:P.asked==="engine",reason:`the engine request failed (${He})`})}const ve=K.result;if(ve.refused)return this.#K(N,{asked:P.asked,refused:P.asked==="engine",reason:ve.refused});const Se=this.#kt(N,ve,P,oe);return this.#k={source:"engine",asked:P.asked,reason:null,refused:!1,pending:oe,measures:[],viewport:{rows:ve.kind==="rows"?ve.rows.length:0,matched:ve.count,cap:ve.cap,binned:ve.kind==="density",cells:ve.kind==="density"?ve.cells.length:0,over:ve.kind==="over"?ve.reason:null,bbox:ve.bbox?[...ve.bbox]:null,computed:"engine"}},this.#o&&(oe?this.#o.setAttribute("aria-busy","true"):this.#o.removeAttribute("aria-busy")),Se}#kt(N,P,K,he){let oe;if(P.kind==="rows"){const Fe=Vn(N),Xe=ce(this.#n,P.rows);oe=Fe&&typeof Fe.bind=="function"?Fe.bind(Xe,this.#e):{points:[],empty:!0}}else if(P.kind==="density"){const Fe=P.cells;oe={points:Fe.map(Xe=>({lon:(Xe.west+Xe.east)/2,lat:(Xe.south+Xe.north)/2})),features:[],unplaced:0,fromGeometry:!0,empty:Fe.length===0,density:{cells:Fe,size:P.size}}}else oe={points:[],features:[],unplaced:0,fromGeometry:!0,empty:!1,over:{count:P.count,cap:P.cap,reason:P.reason}};const[ve,Se]=this.#u.offset,He=this.#u.zoom===1&&ve===0&&Se===0,Ye=!!(this.#b&&this.#b.refit);if(He&&!he&&!Ye&&(!this.#b||this.#b.baseKey!==K.baseKey)){const Fe=[...oe.points||[]];for(const dt of oe.features||[]){dt.point&&Fe.push({lon:dt.point[0],lat:dt.point[1]});for(const mt of dt.polygons||[])for(const Ue of mt)for(const[Wt,Ze]of Ue)Fe.push({lon:Wt,lat:Ze})}const Xe=(P.kind==="density"?V([],P.cells):V(Fe))||[[[-180,-85],[180,-85],[180,85],[-180,85]]];(!this.#b||E(u(this.#b.rings),u(Xe)))&&(this.#b={baseKey:K.baseKey,rings:Xe})}return oe.frame=this.#b?this.#b.rings:null,oe}#vt(N,P){const K=P&&Array.isArray(P.points)?P.points.length:P&&Array.isArray(P.features)?P.features.length:0;this.#we=K;const he=Q(N,P,this.#e,this.#J);return he.viewport&&(this.#k={...this.#k,viewport:he.viewport},he.bound.over&&Gt(`chart:viewportCap:over:${this.#r}`,`this map's view holds ${he.bound.over.count} rows, more than its viewportCap of ${he.bound.over.cap}, and ${he.bound.over.reason}, so it draws none of them. Zoom in, narrow the filter, or raise viewportCap.`)),he.bound}#xt(N){if(!h.has(N))return;const P=this.#t,K=P&&P.plot,he=P&&P.anchor&&K?hn(P.anchor,K):null,[oe,ve]=this.#u.offset,Se=this.#u.zoom===1&&oe===0&&ve===0,He=!!(this.#b&&this.#b.refit),Ye={bbox:Se&&!He?null:he,span:he?he[2]-he[0]:360,width:K?K.right-K.left:this.#J.width},Fe=this.#J;if(xt(Ye.bbox,Fe.bbox)&&Math.abs(Ye.span-Fe.span)<1e-9&&Ye.width===Fe.width)return;this.#J=Ye;const dt=m(this.#e);(this.#H||this.#we>dt)&&this.schedule()}#At(N){this.#R.ask(N.key,P=>{const K={...N.request,...P?{signal:P}:{}};return Promise.resolve(N.source.aggregate(K,N.requested)).then(he=>({groups:he&&he.groups||[],engine:he&&he.engine||[],client:he&&he.client||[]}))},()=>{this.#E||this.schedule()})}#Le(){this.#R.abort()}ascend(N){if(!this.#p||!this.#p.length)return[];const P=Number.isFinite(N)&&N>0?Number(N):this.#p.length;return this.#p=this.#p.slice(0,Math.max(0,this.#p.length-P)),this.emit("drill",{path:[...this.#p],label:this.#p[this.#p.length-1]||null}),this.draw(),[...this.#p]}update(N){this.#e={...this.#e,...N},this.draw()}get element(){return this.#s}toSVG(N){if(!this.#o)return"";const P=Qt(this.#i);let K=this.#o;return N&&N.inlineStyles&&P.getComputedStyle&&this.#o.cloneNode&&(K=this.#o.cloneNode(!0),oo(this.#o,K,P),K.setAttribute("xmlns","http://www.w3.org/2000/svg")),typeof P.XMLSerializer=="function"?new P.XMLSerializer().serializeToString(K):K.outerHTML||""}async toPNG(N){const P=Qt(this.#i);if(!this.#o||!P.Image||!this.#i.createElement)return null;const K=N&&N.scale||P.devicePixelRatio||1,he=this.#o.getBoundingClientRect?this.#o.getBoundingClientRect():tn,oe=Math.max(1,Math.round(he.width||tn.width)),ve=Math.max(1,Math.round(he.height||tn.height)),Se=this.toSVG({inlineStyles:!0}),He=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(Se)}`,Ye=new P.Image;await new Promise((mt,Ue)=>{Ye.onload=mt,Ye.onerror=()=>Ue(new Error("the chart could not be rasterised")),Ye.src=He});const Fe=this.#i.createElement("canvas");Fe.width=Math.round(oe*K),Fe.height=Math.round(ve*K);const Xe=Fe.getContext("2d"),dt=N&&"background"in N?N.background:"#ffffff";return dt&&(Xe.fillStyle=dt,Xe.fillRect(0,0,Fe.width,Fe.height)),Xe.drawImage(Ye,0,0,Fe.width,Fe.height),new Promise(mt=>Fe.toBlob(mt,"image/png"))}toCSV(){const N=this.#a;if(!N)return"";const P=oe=>{const ve=oe==null?"":String(oe);return/[",\n]/.test(ve)?`"${ve.replace(/"/g,'""')}"`:ve};if(N.root){const oe=[["Label",N.measure.title||"Value"].map(P).join(",")];for(const ve of N.root.children)oe.push([P(ve.label),P(ve.total)].join(","));return oe.join(`
|
|
336
|
+
`)}const he=[[N.dimension.title||"",...N.series.map(oe=>oe.label)].map(P).join(",")];for(let oe=0;oe<N.labels.length;oe++){const ve=[P(N.labels[oe])];for(const Se of N.series){const He=Se.points[oe];ve.push(P(He&&He.y!==null?He.y:""))}he.push(ve.join(","))}return he.join(`
|
|
337
|
+
`)}destroy(){if(!this.#E){this.#E=!0,this.#ge(),this.#Le();for(const N of this.#x)N();this.#x=[],this.#V&&this.#V.disconnect(),this.#V=null,this.#h&&this.#h.destroy(),this.#h=null,this.#pe(),this.#j=null,this.#Q(),this.#s&&this.#s.parentNode&&this.#s.parentNode.removeChild(this.#s),this.#t=null,this.#a=null,this.#D.clear()}}}function ar(at){if(!at||!at.grid)throw new Error("createChart needs a grid");const N=at.grid.element?at.grid.element.ownerDocument:globalThis.document,P=ro(N,at.container);if(!P)throw new Error("createChart needs a container element");const{grid:K,container:he,...oe}=at;return new sr({grid:K,container:P,spec:oe})}function ao(at,N){if(!N||!N.container)return null;const P=Cn(at,N);if(!P.spec)return null;const{container:K,range:he,...oe}=N,ve=[{provided:["x"],derivedKeys:["x"]},{provided:["y","measures"],derivedKeys:["y","measures"]},{provided:["series"],derivedKeys:["series"]}],Se={...P.spec};for(const He of ve)if(He.provided.some(Ye=>Ye in oe))for(const Ye of He.derivedKeys)delete Se[Ye];return ar({...oe,...Se,grid:at,container:K})}function lo(at,N={}){return!!Cn(at,N).spec}});var Nn=Un("packages/modules/charts/index.js");if(typeof module=="object"&&module.exports)module.exports=Nn;else if(typeof define=="function"&&define.amd)define(function(){return Nn});else{var lr=Dn.LatticeGrid||(Dn.LatticeGrid={});for(var $n in Nn)$n!=="default"&&(lr[$n]=Nn[$n])}})(typeof globalThis<"u"?globalThis:this);
|
|
331
338
|
|
|
332
339
|
//# sourceMappingURL=charts.min.js.map
|