diff --git a/README.md b/README.md index 397c9bd..caa5954 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,131 @@ To register new fetchers, you need to create a new class that inherits from `Dat The `fetch_data` method should return a `pandas` `DataFrame` object with the data that should be displayed in the chart. The `make_cache_key` method should return a unique string that will be used as a key to store the data in the cache. +## Implementing new chart engines support + +Implementing support for a new chart engine includes multiple steps and changes in Python, HTML, and JavaScript. Starting from the Python code: + +1. Create a new builder class at `ckanext.charts.chart_builder` that inherits from `BaseChartBuilder` and implements the `get_supported_forms` method. This method must return a list of classes that represent supported chart types forms. + +2. Each form type builder must be connected with a respective chart type builder. + +3. The chart type builder must implement a `to_json` method that will return a dumped JSON data, which will be passed to a JS script. + +4. The form type builder must implement a `get_form_fields` method that will return a list of all form fields that will be rendered for the user, allowing them to provide all the necessary information for a chart. + +5. Register your chart engine by adding the builder class to `get_chart_engines` in `ckanext.charts.chart_builder.__init__.py`. + +A full example of an implementation of `bar` chart for `obvervable plot` library. + +```py +from __future__ import annotations + +import json +from typing import Any + +import ckanext.charts.exception as exception +from ckanext.charts.chart_builders.base import BaseChartBuilder, BaseChartForm + + +class ObservableBuilder(BaseChartBuilder): + @classmethod + def get_supported_forms(cls) -> list[type[Any]]: + return [ObservableBarForm] + + +class ObservableBarBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "bar", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservableBarForm(BaseChartForm): + name = "Bar" + builder = ObservableBarBuilder + + def fill_field(self, choices: list[dict[str, str]]) -> dict[str, str]: + field = self.color_field(choices) + field.update({"field_name": "fill", "label": "Fill"}) + + return field + + def get_form_fields(self): + columns = [{"value": col, "label": col} for col in self.df.columns] + chart_types = [ + {"value": form.name, "label": form.name} + for form in self.builder.get_supported_forms() + ] + + return [ + self.title_field(), + self.description_field(), + self.engine_field(), + self.type_field(chart_types), + self.x_axis_field(columns), + self.y_axis_field(columns), + self.fill_field(columns), + self.opacity_field(), + self.limit_field(), + ] +``` + +Another step is to register JS/CSS vendor libraries of the chart you want to use. Refer to (CKAN documentation)[https://docs.ckan.org/en/latest/theming/webassets.html] to read about adding CSS and JavaScript files using Webassets. + +You also will need a CKAN JS module, that will be responsible for rendering the Chart. This module must be registered inside a `webassets.yml` as well. +```js + ckan.module("charts-render-observable", function ($, _) { + "use strict"; + + return { + options: { + config: null + }, + + initialize: function () { + $.proxyAll(this, /_/); + + if (!this.options.config) { + console.error("No configuration provided"); + return; + } + + var plot; + + switch (this.options.config.type) { + case "bar": + plot = Plot.barY(this.options.config.data, this.options.config.settings).plot(); + break; + default: + return; + } + + this.el[0].replaceChildren(plot); + } + }; + }); +``` + +And an HTML file, that will provide a proper container and include your JS module with `data-module`. + +```html + {% asset "charts/observable" %} + + {% if chart %} +
+ {% else %} +

+ {{ _("Cannot build chart with current settings") }} +

+ {% endif %} +``` + +Note, that we should add `{% asset "charts/observable" %}` not only here, but in `charts_form.html` too. + ## Developer installation To install ckanext-charts for development, activate your CKAN virtualenv and diff --git a/ckanext/charts/assets/js/charts-render-chartjs.js b/ckanext/charts/assets/js/charts-render-chartjs.js index cf0adb7..c2d658f 100644 --- a/ckanext/charts/assets/js/charts-render-chartjs.js +++ b/ckanext/charts/assets/js/charts-render-chartjs.js @@ -9,9 +9,6 @@ ckan.module("charts-render-chartjs", function ($, _) { initialize: function () { $.proxyAll(this, /_/); - console.log(this.options.config); - - if (!this.options.config) { console.error("No configuration provided"); return; diff --git a/ckanext/charts/assets/js/charts-render-observable.js b/ckanext/charts/assets/js/charts-render-observable.js new file mode 100644 index 0000000..fba1681 --- /dev/null +++ b/ckanext/charts/assets/js/charts-render-observable.js @@ -0,0 +1,144 @@ +ckan.module("charts-render-observable", function ($, _) { + "use strict"; + + return { + options: { + config: null + }, + + initialize: function () { + $.proxyAll(this, /_/); + + if (!this.options.config) { + console.error("No configuration provided"); + return; + } + + var plot; + + switch (this.options.config.type) { + case "bar": + plot = Plot.barY(this.options.config.data, this.options.config.settings).plot(); + break; + case "horizontal-bar": + plot = Plot.barX(this.options.config.data, this.options.config.settings).plot(); + break; + case "scatter": + plot = Plot.dot(this.options.config.data, this.options.config.settings).plot(); + break; + case "line": + plot = Plot.line(this.options.config.data, this.options.config.settings).plot(); + break; + case "pie": + plot = PieChart(this.options.config.data, this.options.config.settings); + break; + case "auto": + plot = Plot.auto(this.options.config.data, this.options.config.settings).plot(); + break; + default: + return; + } + + this.el[0].replaceChildren(plot); + } + }; +}); + +// Copyright 2018-2023 Observable, Inc. +// Released under the ISC license. +// https://observablehq.com/@d3/pie-chart + +function PieChart(data, { + names, // given d in data, returns the (ordinal) label + values, // given d in data, returns the (quantitative) value + title, // given d in data, returns the title text + width = 640, // outer width, in pixels + height = 400, // outer height, in pixels + innerRadius = 0, // inner radius of pie, in pixels (non-zero for donut) + outerRadius = Math.min(width, height) / 2, // outer radius of pie, in pixels + labelRadius = (innerRadius * 0.2 + outerRadius * 0.8), // center radius of labels + format = ",", // a format specifier for values (in the label) + // names, // array of names (the domain of the color scale) + colors, // array of colors for names + stroke = innerRadius > 0 ? "none" : "white", // stroke separating widths + strokeWidth = 1, // width of stroke separating wedges + strokeLinejoin = "round", // line join of stroke separating wedges + padAngle = stroke === "none" ? 1 / outerRadius : 0, // angular separation between wedges, in radians + opacity = 1, // opacity of svg + fontSize = 12 // font size of labels +} = {}) { + // Compute values. + console.log(strokeWidth); + const N = d3.map(data, (data) => data[names]); + const V = d3.map(data, (data) => data[values]); + + const I = d3.range(N.length).filter(i => !isNaN(V[i])); + + // Unique the names. + if (names === undefined) names = N; + names = new d3.InternSet(names); + + // Chose a default color scheme based on cardinality. + if (colors === undefined) colors = d3.schemeSpectral[names.size]; + if (colors === undefined) colors = d3.quantize(t => d3.interpolateSpectral(t * 0.8 + 0.1), names.size); + + // Construct scales. + const color = d3.scaleOrdinal(names, colors); + + // Compute titles. + if (title === undefined) { + const formatValue = d3.format(format); + title = i => `${N[i]}\n${formatValue(V[i])}`; + } else { + const O = d3.map(data, d => d); + const T = title; + title = i => T(O[i], i, data); + } + + // Construct arcs. + const arcs = d3.pie().padAngle(padAngle).sort(null).value(i => V[i])(I); + const arc = d3.arc().innerRadius(innerRadius).outerRadius(outerRadius); + const arcLabel = d3.arc().innerRadius(labelRadius).outerRadius(labelRadius); + + const svg = d3.create("svg") + .attr("width", width) + .attr("height", height) + .attr("viewBox", [-width / 2, -height / 2, width, height]) + .attr("style", "max-width: 100%; height: auto; height: intrinsic;"); + + svg.append("g") + .attr("stroke", stroke) + .attr("stroke-width", strokeWidth) + .attr("stroke-linejoin", strokeLinejoin) + .selectAll("path") + .data(arcs) + .join("path") + .attr("fill", d => color(N[d.data])) + .attr("d", arc) + .append("title") + .text(d => title(d.data)); + + svg.append("g") + .attr("font-family", "sans-serif") + .attr("font-size", fontSize) + .attr("text-anchor", "middle") + .selectAll("text") + .data(arcs) + .join("text") + .attr("transform", d => `translate(${arcLabel.centroid(d)})`) + .selectAll("tspan") + .data(d => { + const lines = `${title(d.data)}`.split(/\n/); + return (d.endAngle - d.startAngle) > 0.25 ? lines : lines.slice(0, 1); + }) + .join("tspan") + .attr("x", 0) + .attr("y", (_, i) => `${i * 1.1}em`) + .attr("font-weight", (_, i) => i ? null : "bold") + .text(d => d); + + const resultSvg = Object.assign(svg.node(), { scales: { color } }); + resultSvg.setAttribute("opacity", opacity); + + return resultSvg; +} diff --git a/ckanext/charts/assets/js/charts-render-plotly.js b/ckanext/charts/assets/js/charts-render-plotly.js index 74fef7c..f6aad6c 100644 --- a/ckanext/charts/assets/js/charts-render-plotly.js +++ b/ckanext/charts/assets/js/charts-render-plotly.js @@ -9,8 +9,6 @@ ckan.module("charts-render-plotly", function ($, _) { initialize: function () { $.proxyAll(this, /_/); - console.log(this.options.config); - if (!this.options.config) { console.error("No configuration provided"); return; diff --git a/ckanext/charts/assets/js/vendor/chartjs.min.js b/ckanext/charts/assets/js/vendor/chartjs.min.js deleted file mode 100644 index 9860358..0000000 --- a/ckanext/charts/assets/js/vendor/chartjs.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * Chart.js v4.4.2 - * https://www.chartjs.org - * (c) 2024 Chart.js Contributors - * Released under the MIT License - */ -import{r as requestAnimFrame,a as resolve,e as effects,c as color,i as isObject,d as defaults,b as isArray,v as valueOrDefault,u as unlistenArrayEvents,l as listenArrayEvents,f as resolveObjectKey,g as isNumberFinite,h as defined,s as sign,j as createContext,k as isNullOrUndef,_ as _arrayUnique,t as toRadians,m as toPercentage,n as toDimension,T as TAU,o as formatNumber,p as _angleBetween,H as HALF_PI,P as PI,q as _getStartAndCountOfVisiblePoints,w as _scaleRangesChanged,x as isNumber,y as _parseObjectDataRadialScale,z as getRelativePosition,A as _rlookupByKey,B as _lookupByKey,C as _isPointInArea,D as getAngleFromPoint,E as toPadding,F as each,G as getMaximumSize,I as _getParentNode,J as readUsedSize,K as supportsEventListenerOptions,L as throttled,M as _isDomSupported,N as _factorize,O as finiteOrDefault,Q as callback,R as _addGrace,S as _limitValue,U as toDegrees,V as _measureText,W as _int16Range,X as _alignPixel,Y as clipArea,Z as renderText,$ as unclipArea,a0 as toFont,a1 as _toLeftRightCenter,a2 as _alignStartEnd,a3 as overrides,a4 as merge,a5 as _capitalize,a6 as descriptors,a7 as isFunction,a8 as _attachContext,a9 as _createResolver,aa as _descriptors,ab as mergeIf,ac as uid,ad as debounce,ae as retinaScale,af as clearCanvas,ag as setsEqual,ah as _elementsEqual,ai as _isClickEvent,aj as _isBetween,ak as _readValueToProps,al as _updateBezierControlPoints,am as _computeSegments,an as _boundSegments,ao as _steppedInterpolation,ap as _bezierInterpolation,aq as _pointInLine,ar as _steppedLineTo,as as _bezierCurveTo,at as drawPoint,au as addRoundedRectPath,av as toTRBL,aw as toTRBLCorners,ax as _boundSegment,ay as _normalizeAngle,az as getRtlAdapter,aA as overrideTextDirection,aB as _textX,aC as restoreTextDirection,aD as drawPointLegend,aE as distanceBetweenPoints,aF as noop,aG as _setMinAndMaxByKey,aH as niceNum,aI as almostWhole,aJ as almostEquals,aK as _decimalPlaces,aL as Ticks,aM as log10,aN as _longestText,aO as _filterBetween,aP as _lookup}from"./chunks/helpers.segment.js";import"@kurkle/color";class Animator{constructor(){this._request=null;this._charts=new Map;this._running=false;this._lastDate=undefined}_notify(chart,anims,date,type){const callbacks=anims.listeners[type];const numSteps=anims.duration;callbacks.forEach((fn=>fn({chart:chart,initial:anims.initial,numSteps:numSteps,currentStep:Math.min(date-anims.start,numSteps)})))}_refresh(){if(this._request){return}this._running=true;this._request=requestAnimFrame.call(window,(()=>{this._update();this._request=null;if(this._running){this._refresh()}}))}_update(date=Date.now()){let remaining=0;this._charts.forEach(((anims,chart)=>{if(!anims.running||!anims.items.length){return}const items=anims.items;let i=items.length-1;let draw=false;let item;for(;i>=0;--i){item=items[i];if(item._active){if(item._total>anims.duration){anims.duration=item._total}item.tick(date);draw=true}else{items[i]=items[items.length-1];items.pop()}}if(draw){chart.draw();this._notify(chart,anims,date,"progress")}if(!items.length){anims.running=false;this._notify(chart,anims,date,"complete");anims.initial=false}remaining+=items.length}));this._lastDate=date;if(remaining===0){this._running=false}}_getAnims(chart){const charts=this._charts;let anims=charts.get(chart);if(!anims){anims={running:false,initial:true,items:[],listeners:{complete:[],progress:[]}};charts.set(chart,anims)}return anims}listen(chart,event,cb){this._getAnims(chart).listeners[event].push(cb)}add(chart,items){if(!items||!items.length){return}this._getAnims(chart).items.push(...items)}has(chart){return this._getAnims(chart).items.length>0}start(chart){const anims=this._charts.get(chart);if(!anims){return}anims.running=true;anims.start=Date.now();anims.duration=anims.items.reduce(((acc,cur)=>Math.max(acc,cur._duration)),0);this._refresh()}running(chart){if(!this._running){return false}const anims=this._charts.get(chart);if(!anims||!anims.running||!anims.items.length){return false}return true}stop(chart){const anims=this._charts.get(chart);if(!anims||!anims.items.length){return}const items=anims.items;let i=items.length-1;for(;i>=0;--i){items[i].cancel()}anims.items=[];this._notify(chart,anims,Date.now(),"complete")}remove(chart){return this._charts.delete(chart)}}var animator=new Animator;const transparent="transparent";const interpolators={boolean(from,to,factor){return factor>.5?to:from},color(from,to,factor){const c0=color(from||transparent);const c1=c0.valid&&color(to||transparent);return c1&&c1.valid?c1.mix(c0,factor).hexString():to},number(from,to,factor){return from+(to-from)*factor}};class Animation{constructor(cfg,target,prop,to){const currentValue=target[prop];to=resolve([cfg.to,to,currentValue,cfg.from]);const from=resolve([cfg.from,currentValue,to]);this._active=true;this._fn=cfg.fn||interpolators[cfg.type||typeof from];this._easing=effects[cfg.easing]||effects.linear;this._start=Math.floor(Date.now()+(cfg.delay||0));this._duration=this._total=Math.floor(cfg.duration);this._loop=!!cfg.loop;this._target=target;this._prop=prop;this._from=from;this._to=to;this._promises=undefined}active(){return this._active}update(cfg,to,date){if(this._active){this._notify(false);const currentValue=this._target[this._prop];const elapsed=date-this._start;const remain=this._duration-elapsed;this._start=date;this._duration=Math.floor(Math.max(remain,cfg.duration));this._total+=elapsed;this._loop=!!cfg.loop;this._to=resolve([cfg.to,to,currentValue,cfg.from]);this._from=resolve([cfg.from,currentValue,to])}}cancel(){if(this._active){this.tick(Date.now());this._active=false;this._notify(false)}}tick(date){const elapsed=date-this._start;const duration=this._duration;const prop=this._prop;const from=this._from;const loop=this._loop;const to=this._to;let factor;this._active=from!==to&&(loop||elapsed1?2-factor:factor;factor=this._easing(Math.min(1,Math.max(0,factor)));this._target[prop]=this._fn(from,to,factor)}wait(){const promises=this._promises||(this._promises=[]);return new Promise(((res,rej)=>{promises.push({res:res,rej:rej})}))}_notify(resolved){const method=resolved?"res":"rej";const promises=this._promises||[];for(let i=0;i{const cfg=config[key];if(!isObject(cfg)){return}const resolved={};for(const option of animationOptions){resolved[option]=cfg[option]}(isArray(cfg.properties)&&cfg.properties||[key]).forEach((prop=>{if(prop===key||!animatedProps.has(prop)){animatedProps.set(prop,resolved)}}))}))}_animateOptions(target,values){const newOptions=values.options;const options=resolveTargetOptions(target,newOptions);if(!options){return[]}const animations=this._createAnimations(options,newOptions);if(newOptions.$shared){awaitAll(target.options.$animations,newOptions).then((()=>{target.options=newOptions}),(()=>{}))}return animations}_createAnimations(target,values){const animatedProps=this._properties;const animations=[];const running=target.$animations||(target.$animations={});const props=Object.keys(values);const date=Date.now();let i;for(i=props.length-1;i>=0;--i){const prop=props[i];if(prop.charAt(0)==="$"){continue}if(prop==="options"){animations.push(...this._animateOptions(target,values));continue}const value=values[prop];let animation=running[prop];const cfg=animatedProps.get(prop);if(animation){if(cfg&&animation.active()){animation.update(cfg,value,date);continue}else{animation.cancel()}}if(!cfg||!cfg.duration){target[prop]=value;continue}running[prop]=animation=new Animation(cfg,target,prop,value);animations.push(animation)}return animations}update(target,values){if(this._properties.size===0){Object.assign(target,values);return}const animations=this._createAnimations(target,values);if(animations.length){animator.add(this._chart,animations);return true}}}function awaitAll(animations,properties){const running=[];const keys=Object.keys(properties);for(let i=0;i0||!positive&&value<0){return meta.index}}return null}function updateStacks(controller,parsed){const{chart:chart,_cachedMeta:meta}=controller;const stacks=chart._stacks||(chart._stacks={});const{iScale:iScale,vScale:vScale,index:datasetIndex}=meta;const iAxis=iScale.axis;const vAxis=vScale.axis;const key=getStackKey(iScale,vScale,meta);const ilen=parsed.length;let stack;for(let i=0;iscales[key].axis===axis)).shift()}function createDatasetContext(parent,index){return createContext(parent,{active:false,dataset:undefined,datasetIndex:index,index:index,mode:"default",type:"dataset"})}function createDataContext(parent,index,element){return createContext(parent,{active:false,dataIndex:index,parsed:undefined,raw:undefined,element:element,index:index,mode:"default",type:"data"})}function clearStacks(meta,items){const datasetIndex=meta.controller.index;const axis=meta.vScale&&meta.vScale.axis;if(!axis){return}items=items||meta._parsed;for(const parsed of items){const stacks=parsed._stacks;if(!stacks||stacks[axis]===undefined||stacks[axis][datasetIndex]===undefined){return}delete stacks[axis][datasetIndex];if(stacks[axis]._visualValues!==undefined&&stacks[axis]._visualValues[datasetIndex]!==undefined){delete stacks[axis]._visualValues[datasetIndex]}}}const isDirectUpdateMode=mode=>mode==="reset"||mode==="none";const cloneIfNotShared=(cached,shared)=>shared?cached:Object.assign({},cached);const createStack=(canStack,meta,chart)=>canStack&&!meta.hidden&&meta._stacked&&{keys:getSortedDatasetIndices(chart,true),values:null};class DatasetController{static defaults={};static datasetElementType=null;static dataElementType=null;constructor(chart,datasetIndex){this.chart=chart;this._ctx=chart.ctx;this.index=datasetIndex;this._cachedDataOpts={};this._cachedMeta=this.getMeta();this._type=this._cachedMeta.type;this.options=undefined;this._parsing=false;this._data=undefined;this._objectData=undefined;this._sharedOptions=undefined;this._drawStart=undefined;this._drawCount=undefined;this.enableOptionSharing=false;this.supportsDecimation=false;this.$context=undefined;this._syncList=[];this.datasetElementType=new.target.datasetElementType;this.dataElementType=new.target.dataElementType;this.initialize()}initialize(){const meta=this._cachedMeta;this.configure();this.linkScales();meta._stacked=isStacked(meta.vScale,meta);this.addElements();if(this.options.fill&&!this.chart.isPluginEnabled("filler")){console.warn("Tried to use the 'fill' option without the 'Filler' plugin enabled. Please import and register the 'Filler' plugin and make sure it is not disabled in the options")}}updateIndex(datasetIndex){if(this.index!==datasetIndex){clearStacks(this._cachedMeta)}this.index=datasetIndex}linkScales(){const chart=this.chart;const meta=this._cachedMeta;const dataset=this.getDataset();const chooseId=(axis,x,y,r)=>axis==="x"?x:axis==="r"?r:y;const xid=meta.xAxisID=valueOrDefault(dataset.xAxisID,getFirstScaleId(chart,"x"));const yid=meta.yAxisID=valueOrDefault(dataset.yAxisID,getFirstScaleId(chart,"y"));const rid=meta.rAxisID=valueOrDefault(dataset.rAxisID,getFirstScaleId(chart,"r"));const indexAxis=meta.indexAxis;const iid=meta.iAxisID=chooseId(indexAxis,xid,yid,rid);const vid=meta.vAxisID=chooseId(indexAxis,yid,xid,rid);meta.xScale=this.getScaleForId(xid);meta.yScale=this.getScaleForId(yid);meta.rScale=this.getScaleForId(rid);meta.iScale=this.getScaleForId(iid);meta.vScale=this.getScaleForId(vid)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(scaleID){return this.chart.scales[scaleID]}_getOtherScale(scale){const meta=this._cachedMeta;return scale===meta.iScale?meta.vScale:meta.iScale}reset(){this._update("reset")}_destroy(){const meta=this._cachedMeta;if(this._data){unlistenArrayEvents(this._data,this)}if(meta._stacked){clearStacks(meta)}}_dataCheck(){const dataset=this.getDataset();const data=dataset.data||(dataset.data=[]);const _data=this._data;if(isObject(data)){this._data=convertObjectDataToArray(data)}else if(_data!==data){if(_data){unlistenArrayEvents(_data,this);const meta=this._cachedMeta;clearStacks(meta);meta._parsed=[]}if(data&&Object.isExtensible(data)){listenArrayEvents(data,this)}this._syncList=[];this._data=data}}addElements(){const meta=this._cachedMeta;this._dataCheck();if(this.datasetElementType){meta.dataset=new this.datasetElementType}}buildOrUpdateElements(resetNewElements){const meta=this._cachedMeta;const dataset=this.getDataset();let stackChanged=false;this._dataCheck();const oldStacked=meta._stacked;meta._stacked=isStacked(meta.vScale,meta);if(meta.stack!==dataset.stack){stackChanged=true;clearStacks(meta);meta.stack=dataset.stack}this._resyncElements(resetNewElements);if(stackChanged||oldStacked!==meta._stacked){updateStacks(this,meta._parsed)}}configure(){const config=this.chart.config;const scopeKeys=config.datasetScopeKeys(this._type);const scopes=config.getOptionScopes(this.getDataset(),scopeKeys,true);this.options=config.createResolver(scopes,this.getContext());this._parsing=this.options.parsing;this._cachedDataOpts={}}parse(start,count){const{_cachedMeta:meta,_data:data}=this;const{iScale:iScale,_stacked:_stacked}=meta;const iAxis=iScale.axis;let sorted=start===0&&count===data.length?true:meta._sorted;let prev=start>0&&meta._parsed[start-1];let i,cur,parsed;if(this._parsing===false){meta._parsed=data;meta._sorted=true;parsed=data}else{if(isArray(data[start])){parsed=this.parseArrayData(meta,data,start,count)}else if(isObject(data[start])){parsed=this.parseObjectData(meta,data,start,count)}else{parsed=this.parsePrimitiveData(meta,data,start,count)}const isNotInOrderComparedToPrev=()=>cur[iAxis]===null||prev&&cur[iAxis]otherValue||otherMax=0;--i){if(_skip()){continue}this.updateRangeFromParsed(range,scale,parsed,stack);break}}return range}getAllParsedValues(scale){const parsed=this._cachedMeta._parsed;const values=[];let i,ilen,value;for(i=0,ilen=parsed.length;i=0&&indexthis.getContext(index,active,mode);const values=config.resolveNamedOptions(scopes,names,context,prefixes);if(values.$shared){values.$shared=sharing;cache[cacheKey]=Object.freeze(cloneIfNotShared(values,sharing))}return values}_resolveAnimations(index,transition,active){const chart=this.chart;const cache=this._cachedDataOpts;const cacheKey=`animation-${transition}`;const cached=cache[cacheKey];if(cached){return cached}let options;if(chart.options.animation!==false){const config=this.chart.config;const scopeKeys=config.datasetAnimationScopeKeys(this._type,transition);const scopes=config.getOptionScopes(this.getDataset(),scopeKeys);options=config.createResolver(scopes,this.getContext(index,active,transition))}const animations=new Animations(chart,options&&options.animations);if(options&&options._cacheable){cache[cacheKey]=Object.freeze(animations)}return animations}getSharedOptions(options){if(!options.$shared){return}return this._sharedOptions||(this._sharedOptions=Object.assign({},options))}includeOptions(mode,sharedOptions){return!sharedOptions||isDirectUpdateMode(mode)||this.chart._animationsDisabled}_getSharedOptions(start,mode){const firstOpts=this.resolveDataElementOptions(start,mode);const previouslySharedOptions=this._sharedOptions;const sharedOptions=this.getSharedOptions(firstOpts);const includeOptions=this.includeOptions(mode,sharedOptions)||sharedOptions!==previouslySharedOptions;this.updateSharedOptions(sharedOptions,mode,firstOpts);return{sharedOptions:sharedOptions,includeOptions:includeOptions}}updateElement(element,index,properties,mode){if(isDirectUpdateMode(mode)){Object.assign(element,properties)}else{this._resolveAnimations(index,mode).update(element,properties)}}updateSharedOptions(sharedOptions,mode,newOptions){if(sharedOptions&&!isDirectUpdateMode(mode)){this._resolveAnimations(undefined,mode).update(sharedOptions,newOptions)}}_setStyle(element,index,mode,active){element.active=active;const options=this.getStyle(index,active);this._resolveAnimations(index,mode,active).update(element,{options:!active&&this.getSharedOptions(options)||options})}removeHoverStyle(element,datasetIndex,index){this._setStyle(element,index,"active",false)}setHoverStyle(element,datasetIndex,index){this._setStyle(element,index,"active",true)}_removeDatasetHoverStyle(){const element=this._cachedMeta.dataset;if(element){this._setStyle(element,undefined,"active",false)}}_setDatasetHoverStyle(){const element=this._cachedMeta.dataset;if(element){this._setStyle(element,undefined,"active",true)}}_resyncElements(resetNewElements){const data=this._data;const elements=this._cachedMeta.data;for(const[method,arg1,arg2]of this._syncList){this[method](arg1,arg2)}this._syncList=[];const numMeta=elements.length;const numData=data.length;const count=Math.min(numData,numMeta);if(count){this.parse(0,count)}if(numData>numMeta){this._insertElements(numMeta,numData-numMeta,resetNewElements)}else if(numData{arr.length+=count;for(i=arr.length-1;i>=end;i--){arr[i]=arr[i-count]}};move(data);for(i=start;ia-b)))}return scale._cache.$bar}function computeMinSampleSize(meta){const scale=meta.iScale;const values=getAllScaleValues(scale,meta.type);let min=scale._length;let i,ilen,curr,prev;const updateMinAndPrev=()=>{if(curr===32767||curr===-32768){return}if(defined(prev)){min=Math.min(min,Math.abs(curr-prev)||min)}prev=curr};for(i=0,ilen=values.length;i0?pixels[index-1]:null;let next=indexMath.abs(max)){barStart=max;barEnd=min}item[vScale.axis]=barEnd;item._custom={barStart:barStart,barEnd:barEnd,start:startValue,end:endValue,min:min,max:max}}function parseValue(entry,item,vScale,i){if(isArray(entry)){parseFloatBar(entry,item,vScale,i)}else{item[vScale.axis]=vScale.parse(entry,i)}return item}function parseArrayOrPrimitive(meta,data,start,count){const iScale=meta.iScale;const vScale=meta.vScale;const labels=iScale.getLabels();const singleScale=iScale===vScale;const parsed=[];let i,ilen,item,entry;for(i=start,ilen=start+count;i=actualBase?1:-1)}function borderProps(properties){let reverse,start,end,top,bottom;if(properties.horizontal){reverse=properties.base>properties.x;start="left";end="right"}else{reverse=properties.basemeta.controller.options.grouped));const stacked=iScale.options.stacked;const stacks=[];const skipNull=meta=>{const parsed=meta.controller.getParsed(dataIndex);const val=parsed&&parsed[meta.vScale.axis];if(isNullOrUndef(val)||isNaN(val)){return true}};for(const meta of metasets){if(dataIndex!==undefined&&skipNull(meta)){continue}if(stacked===false||stacks.indexOf(meta.stack)===-1||stacked===undefined&&meta.stack===undefined){stacks.push(meta.stack)}if(meta.index===last){break}}if(!stacks.length){stacks.push(undefined)}return stacks}_getStackCount(index){return this._getStacks(undefined,index).length}_getStackIndex(datasetIndex,name,dataIndex){const stacks=this._getStacks(datasetIndex,dataIndex);const index=name!==undefined?stacks.indexOf(name):-1;return index===-1?stacks.length-1:index}_getRuler(){const opts=this.options;const meta=this._cachedMeta;const iScale=meta.iScale;const pixels=[];let i,ilen;for(i=0,ilen=meta.data.length;i=0;--i){max=Math.max(max,data[i].size(this.resolveDataElementOptions(i))/2)}return max>0&&max}getLabelAndValue(index){const meta=this._cachedMeta;const labels=this.chart.data.labels||[];const{xScale:xScale,yScale:yScale}=meta;const parsed=this.getParsed(index);const x=xScale.getLabelForValue(parsed.x);const y=yScale.getLabelForValue(parsed.y);const r=parsed._custom;return{label:labels[index]||"",value:"("+x+", "+y+(r?", "+r:"")+")"}}update(mode){const points=this._cachedMeta.data;this.updateElements(points,0,points.length,mode)}updateElements(points,start,count,mode){const reset=mode==="reset";const{iScale:iScale,vScale:vScale}=this._cachedMeta;const{sharedOptions:sharedOptions,includeOptions:includeOptions}=this._getSharedOptions(start,mode);const iAxis=iScale.axis;const vAxis=vScale.axis;for(let i=start;i_angleBetween(angle,startAngle,endAngle,true)?1:Math.max(a,a*cutout,b,b*cutout);const calcMin=(angle,a,b)=>_angleBetween(angle,startAngle,endAngle,true)?-1:Math.min(a,a*cutout,b,b*cutout);const maxX=calcMax(0,startX,endX);const maxY=calcMax(HALF_PI,startY,endY);const minX=calcMin(PI,startX,endX);const minY=calcMin(PI+HALF_PI,startY,endY);ratioX=(maxX-minX)/2;ratioY=(maxY-minY)/2;offsetX=-(maxX+minX)/2;offsetY=-(maxY+minY)/2}return{ratioX:ratioX,ratioY:ratioY,offsetX:offsetX,offsetY:offsetY}}class DoughnutController extends DatasetController{static id="doughnut";static defaults={datasetElementType:false,dataElementType:"arc",animation:{animateRotate:true,animateScale:false},animations:{numbers:{type:"number",properties:["circumference","endAngle","innerRadius","outerRadius","startAngle","x","y","offset","borderWidth","spacing"]}},cutout:"50%",rotation:0,circumference:360,radius:"100%",spacing:0,indexAxis:"r"};static descriptors={_scriptable:name=>name!=="spacing",_indexable:name=>name!=="spacing"&&!name.startsWith("borderDash")&&!name.startsWith("hoverBorderDash")};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(chart){const data=chart.data;if(data.labels.length&&data.datasets.length){const{labels:{pointStyle:pointStyle,color:color}}=chart.legend.options;return data.labels.map(((label,i)=>{const meta=chart.getDatasetMeta(0);const style=meta.controller.getStyle(i);return{text:label,fillStyle:style.backgroundColor,strokeStyle:style.borderColor,fontColor:color,lineWidth:style.borderWidth,pointStyle:pointStyle,hidden:!chart.getDataVisibility(i),index:i}}))}return[]}},onClick(e,legendItem,legend){legend.chart.toggleDataVisibility(legendItem.index);legend.chart.update()}}}};constructor(chart,datasetIndex){super(chart,datasetIndex);this.enableOptionSharing=true;this.innerRadius=undefined;this.outerRadius=undefined;this.offsetX=undefined;this.offsetY=undefined}linkScales(){}parse(start,count){const data=this.getDataset().data;const meta=this._cachedMeta;if(this._parsing===false){meta._parsed=data}else{let getter=i=>+data[i];if(isObject(data[start])){const{key:key="value"}=this._parsing;getter=i=>+resolveObjectKey(data[i],key)}let i,ilen;for(i=start,ilen=start+count;i0&&!isNaN(value)){return TAU*(Math.abs(value)/total)}return 0}getLabelAndValue(index){const meta=this._cachedMeta;const chart=this.chart;const labels=chart.data.labels||[];const value=formatNumber(meta._parsed[index],chart.options.locale);return{label:labels[index]||"",value:value}}getMaxBorderWidth(arcs){let max=0;const chart=this.chart;let i,ilen,meta,controller,options;if(!arcs){for(i=0,ilen=chart.data.datasets.length;i0&&this.getParsed(start-1);for(let i=0;i=end){properties.skip=true;continue}const parsed=this.getParsed(i);const nullData=isNullOrUndef(parsed[vAxis]);const iPixel=properties[iAxis]=iScale.getPixelForValue(parsed[iAxis],i);const vPixel=properties[vAxis]=reset||nullData?vScale.getBasePixel():vScale.getPixelForValue(_stacked?this.applyStack(vScale,parsed,_stacked):parsed[vAxis],i);properties.skip=isNaN(iPixel)||isNaN(vPixel)||nullData;properties.stop=i>0&&Math.abs(parsed[iAxis]-prevParsed[iAxis])>maxGapLength;if(segment){properties.parsed=parsed;properties.raw=_dataset.data[i]}if(includeOptions){properties.options=sharedOptions||this.resolveDataElementOptions(i,point.active?"active":mode)}if(!directUpdate){this.updateElement(point,i,properties,mode)}prevParsed=parsed}}getMaxOverflow(){const meta=this._cachedMeta;const dataset=meta.dataset;const border=dataset.options&&dataset.options.borderWidth||0;const data=meta.data||[];if(!data.length){return border}const firstPoint=data[0].size(this.resolveDataElementOptions(0));const lastPoint=data[data.length-1].size(this.resolveDataElementOptions(data.length-1));return Math.max(border,firstPoint,lastPoint)/2}draw(){const meta=this._cachedMeta;meta.dataset.updateControlPoints(this.chart.chartArea,meta.iScale.axis);super.draw()}}class PolarAreaController extends DatasetController{static id="polarArea";static defaults={dataElementType:"arc",animation:{animateRotate:true,animateScale:true},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0};static overrides={aspectRatio:1,plugins:{legend:{labels:{generateLabels(chart){const data=chart.data;if(data.labels.length&&data.datasets.length){const{labels:{pointStyle:pointStyle,color:color}}=chart.legend.options;return data.labels.map(((label,i)=>{const meta=chart.getDatasetMeta(0);const style=meta.controller.getStyle(i);return{text:label,fillStyle:style.backgroundColor,strokeStyle:style.borderColor,fontColor:color,lineWidth:style.borderWidth,pointStyle:pointStyle,hidden:!chart.getDataVisibility(i),index:i}}))}return[]}},onClick(e,legendItem,legend){legend.chart.toggleDataVisibility(legendItem.index);legend.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:false},beginAtZero:true,grid:{circular:true},pointLabels:{display:false},startAngle:0}}};constructor(chart,datasetIndex){super(chart,datasetIndex);this.innerRadius=undefined;this.outerRadius=undefined}getLabelAndValue(index){const meta=this._cachedMeta;const chart=this.chart;const labels=chart.data.labels||[];const value=formatNumber(meta._parsed[index].r,chart.options.locale);return{label:labels[index]||"",value:value}}parseObjectData(meta,data,start,count){return _parseObjectDataRadialScale.bind(this)(meta,data,start,count)}update(mode){const arcs=this._cachedMeta.data;this._updateRadius();this.updateElements(arcs,0,arcs.length,mode)}getMinMax(){const meta=this._cachedMeta;const range={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};meta.data.forEach(((element,index)=>{const parsed=this.getParsed(index).r;if(!isNaN(parsed)&&this.chart.getDataVisibility(index)){if(parsedrange.max){range.max=parsed}}}));return range}_updateRadius(){const chart=this.chart;const chartArea=chart.chartArea;const opts=chart.options;const minSize=Math.min(chartArea.right-chartArea.left,chartArea.bottom-chartArea.top);const outerRadius=Math.max(minSize/2,0);const innerRadius=Math.max(opts.cutoutPercentage?outerRadius/100*opts.cutoutPercentage:1,0);const radiusLength=(outerRadius-innerRadius)/chart.getVisibleDatasetCount();this.outerRadius=outerRadius-radiusLength*this.index;this.innerRadius=this.outerRadius-radiusLength}updateElements(arcs,start,count,mode){const reset=mode==="reset";const chart=this.chart;const opts=chart.options;const animationOpts=opts.animation;const scale=this._cachedMeta.rScale;const centerX=scale.xCenter;const centerY=scale.yCenter;const datasetStartAngle=scale.getIndexAngle(0)-.5*PI;let angle=datasetStartAngle;let i;const defaultAngle=360/this.countVisibleElements();for(i=0;i{if(!isNaN(this.getParsed(index).r)&&this.chart.getDataVisibility(index)){count++}}));return count}_computeAngle(index,mode,defaultAngle){return this.chart.getDataVisibility(index)?toRadians(this.resolveDataElementOptions(index,mode).angle||defaultAngle):0}}class PieController extends DoughnutController{static id="pie";static defaults={cutout:0,rotation:0,circumference:360,radius:"100%"}}class RadarController extends DatasetController{static id="radar";static defaults={datasetElementType:"line",dataElementType:"point",indexAxis:"r",showLine:true,elements:{line:{fill:"start"}}};static overrides={aspectRatio:1,scales:{r:{type:"radialLinear"}}};getLabelAndValue(index){const vScale=this._cachedMeta.vScale;const parsed=this.getParsed(index);return{label:vScale.getLabels()[index],value:""+vScale.getLabelForValue(parsed[vScale.axis])}}parseObjectData(meta,data,start,count){return _parseObjectDataRadialScale.bind(this)(meta,data,start,count)}update(mode){const meta=this._cachedMeta;const line=meta.dataset;const points=meta.data||[];const labels=meta.iScale.getLabels();line.points=points;if(mode!=="resize"){const options=this.resolveDatasetElementOptions(mode);if(!this.options.showLine){options.borderWidth=0}const properties={_loop:true,_fullLoop:labels.length===points.length,options:options};this.updateElement(line,undefined,properties,mode)}this.updateElements(points,0,points.length,mode)}updateElements(points,start,count,mode){const scale=this._cachedMeta.rScale;const reset=mode==="reset";for(let i=start;i0&&this.getParsed(start-1);for(let i=start;i0&&Math.abs(parsed[iAxis]-prevParsed[iAxis])>maxGapLength;if(segment){properties.parsed=parsed;properties.raw=_dataset.data[i]}if(includeOptions){properties.options=sharedOptions||this.resolveDataElementOptions(i,point.active?"active":mode)}if(!directUpdate){this.updateElement(point,i,properties,mode)}prevParsed=parsed}this.updateSharedOptions(sharedOptions,mode,firstOpts)}getMaxOverflow(){const meta=this._cachedMeta;const data=meta.data||[];if(!this.options.showLine){let max=0;for(let i=data.length-1;i>=0;--i){max=Math.max(max,data[i].size(this.resolveDataElementOptions(i))/2)}return max>0&&max}const dataset=meta.dataset;const border=dataset.options&&dataset.options.borderWidth||0;if(!data.length){return border}const firstPoint=data[0].size(this.resolveDataElementOptions(0));const lastPoint=data[data.length-1].size(this.resolveDataElementOptions(data.length-1));return Math.max(border,firstPoint,lastPoint)/2}}var controllers=Object.freeze({__proto__:null,BarController:BarController,BubbleController:BubbleController,DoughnutController:DoughnutController,LineController:LineController,PieController:PieController,PolarAreaController:PolarAreaController,RadarController:RadarController,ScatterController:ScatterController});function abstract(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapterBase{static override(members){Object.assign(DateAdapterBase.prototype,members)}options;constructor(options){this.options=options||{}}init(){}formats(){return abstract()}parse(){return abstract()}format(){return abstract()}add(){return abstract()}diff(){return abstract()}startOf(){return abstract()}endOf(){return abstract()}}var adapters={_date:DateAdapterBase};function binarySearch(metaset,axis,value,intersect){const{controller:controller,data:data,_sorted:_sorted}=metaset;const iScale=controller._cachedMeta.iScale;if(iScale&&axis===iScale.axis&&axis!=="r"&&_sorted&&data.length){const lookupMethod=iScale._reversePixels?_rlookupByKey:_lookupByKey;if(!intersect){return lookupMethod(data,axis,value)}else if(controller._sharedOptions){const el=data[0];const range=typeof el.getRange==="function"&&el.getRange(axis);if(range){const start=lookupMethod(data,axis,value-range);const end=lookupMethod(data,axis,value+range);return{lo:start.lo,hi:end.hi}}}}return{lo:0,hi:data.length-1}}function evaluateInteractionItems(chart,axis,position,handler,intersect){const metasets=chart.getSortedVisibleDatasetMetas();const value=position[axis];for(let i=0,ilen=metasets.length;i{if(element[rangeMethod](position[axis],useFinalPosition)){items.push({element:element,datasetIndex:datasetIndex,index:index});intersectsItem=intersectsItem||element.inRange(position.x,position.y,useFinalPosition)}}));if(intersect&&!intersectsItem){return[]}return items}var Interaction={evaluateInteractionItems:evaluateInteractionItems,modes:{index(chart,e,options,useFinalPosition){const position=getRelativePosition(e,chart);const axis=options.axis||"x";const includeInvisible=options.includeInvisible||false;const items=options.intersect?getIntersectItems(chart,position,axis,useFinalPosition,includeInvisible):getNearestItems(chart,position,axis,false,useFinalPosition,includeInvisible);const elements=[];if(!items.length){return[]}chart.getSortedVisibleDatasetMetas().forEach((meta=>{const index=items[0].index;const element=meta.data[index];if(element&&!element.skip){elements.push({element:element,datasetIndex:meta.index,index:index})}}));return elements},dataset(chart,e,options,useFinalPosition){const position=getRelativePosition(e,chart);const axis=options.axis||"xy";const includeInvisible=options.includeInvisible||false;let items=options.intersect?getIntersectItems(chart,position,axis,useFinalPosition,includeInvisible):getNearestItems(chart,position,axis,false,useFinalPosition,includeInvisible);if(items.length>0){const datasetIndex=items[0].datasetIndex;const data=chart.getDatasetMeta(datasetIndex).data;items=[];for(let i=0;iv.pos===position))}function filterDynamicPositionByAxis(array,axis){return array.filter((v=>STATIC_POSITIONS.indexOf(v.pos)===-1&&v.box.axis===axis))}function sortByWeight(array,reverse){return array.sort(((a,b)=>{const v0=reverse?b:a;const v1=reverse?a:b;return v0.weight===v1.weight?v0.index-v1.index:v0.weight-v1.weight}))}function wrapBoxes(boxes){const layoutBoxes=[];let i,ilen,box,pos,stack,stackWeight;for(i=0,ilen=(boxes||[]).length;iwrap.box.fullSize)),true);const left=sortByWeight(filterByPosition(layoutBoxes,"left"),true);const right=sortByWeight(filterByPosition(layoutBoxes,"right"));const top=sortByWeight(filterByPosition(layoutBoxes,"top"),true);const bottom=sortByWeight(filterByPosition(layoutBoxes,"bottom"));const centerHorizontal=filterDynamicPositionByAxis(layoutBoxes,"x");const centerVertical=filterDynamicPositionByAxis(layoutBoxes,"y");return{fullSize:fullSize,leftAndTop:left.concat(top),rightAndBottom:right.concat(centerVertical).concat(bottom).concat(centerHorizontal),chartArea:filterByPosition(layoutBoxes,"chartArea"),vertical:left.concat(right).concat(centerVertical),horizontal:top.concat(bottom).concat(centerHorizontal)}}function getCombinedMax(maxPadding,chartArea,a,b){return Math.max(maxPadding[a],chartArea[a])+Math.max(maxPadding[b],chartArea[b])}function updateMaxPadding(maxPadding,boxPadding){maxPadding.top=Math.max(maxPadding.top,boxPadding.top);maxPadding.left=Math.max(maxPadding.left,boxPadding.left);maxPadding.bottom=Math.max(maxPadding.bottom,boxPadding.bottom);maxPadding.right=Math.max(maxPadding.right,boxPadding.right)}function updateDims(chartArea,params,layout,stacks){const{pos:pos,box:box}=layout;const maxPadding=chartArea.maxPadding;if(!isObject(pos)){if(layout.size){chartArea[pos]-=layout.size}const stack=stacks[layout.stack]||{size:0,count:1};stack.size=Math.max(stack.size,layout.horizontal?box.height:box.width);layout.size=stack.size/stack.count;chartArea[pos]+=layout.size}if(box.getPadding){updateMaxPadding(maxPadding,box.getPadding())}const newWidth=Math.max(0,params.outerWidth-getCombinedMax(maxPadding,chartArea,"left","right"));const newHeight=Math.max(0,params.outerHeight-getCombinedMax(maxPadding,chartArea,"top","bottom"));const widthChanged=newWidth!==chartArea.w;const heightChanged=newHeight!==chartArea.h;chartArea.w=newWidth;chartArea.h=newHeight;return layout.horizontal?{same:widthChanged,other:heightChanged}:{same:heightChanged,other:widthChanged}}function handleMaxPadding(chartArea){const maxPadding=chartArea.maxPadding;function updatePos(pos){const change=Math.max(maxPadding[pos]-chartArea[pos],0);chartArea[pos]+=change;return change}chartArea.y+=updatePos("top");chartArea.x+=updatePos("left");updatePos("right");updatePos("bottom")}function getMargins(horizontal,chartArea){const maxPadding=chartArea.maxPadding;function marginForPositions(positions){const margin={left:0,top:0,right:0,bottom:0};positions.forEach((pos=>{margin[pos]=Math.max(chartArea[pos],maxPadding[pos])}));return margin}return horizontal?marginForPositions(["left","right"]):marginForPositions(["top","bottom"])}function fitBoxes(boxes,chartArea,params,stacks){const refitBoxes=[];let i,ilen,layout,box,refit,changed;for(i=0,ilen=boxes.length,refit=0;i{if(typeof box.beforeLayout==="function"){box.beforeLayout()}}));const visibleVerticalBoxCount=verticalBoxes.reduce(((total,wrap)=>wrap.box.options&&wrap.box.options.display===false?total:total+1),0)||1;const params=Object.freeze({outerWidth:width,outerHeight:height,padding:padding,availableWidth:availableWidth,availableHeight:availableHeight,vBoxMaxWidth:availableWidth/2/visibleVerticalBoxCount,hBoxMaxHeight:availableHeight/2});const maxPadding=Object.assign({},padding);updateMaxPadding(maxPadding,toPadding(minPadding));const chartArea=Object.assign({maxPadding:maxPadding,w:availableWidth,h:availableHeight,x:padding.left,y:padding.top},padding);const stacks=setLayoutDims(verticalBoxes.concat(horizontalBoxes),params);fitBoxes(boxes.fullSize,chartArea,params,stacks);fitBoxes(verticalBoxes,chartArea,params,stacks);if(fitBoxes(horizontalBoxes,chartArea,params,stacks)){fitBoxes(verticalBoxes,chartArea,params,stacks)}handleMaxPadding(chartArea);placeBoxes(boxes.leftAndTop,chartArea,params,stacks);chartArea.x+=chartArea.w;chartArea.y+=chartArea.h;placeBoxes(boxes.rightAndBottom,chartArea,params,stacks);chart.chartArea={left:chartArea.left,top:chartArea.top,right:chartArea.left+chartArea.w,bottom:chartArea.top+chartArea.h,height:chartArea.h,width:chartArea.w};each(boxes.chartArea,(layout=>{const box=layout.box;Object.assign(box,chart.chartArea);box.update(chartArea.w,chartArea.h,{left:0,top:0,right:0,bottom:0})}))}};class BasePlatform{acquireContext(canvas,aspectRatio){}releaseContext(context){return false}addEventListener(chart,type,listener){}removeEventListener(chart,type,listener){}getDevicePixelRatio(){return 1}getMaximumSize(element,width,height,aspectRatio){width=Math.max(0,width||element.width);height=height||element.height;return{width:width,height:Math.max(0,aspectRatio?Math.floor(width/aspectRatio):height)}}isAttached(canvas){return true}updateConfig(config){}}class BasicPlatform extends BasePlatform{acquireContext(item){return item&&item.getContext&&item.getContext("2d")||null}updateConfig(config){config.options.animation=false}}const EXPANDO_KEY="$chartjs";const EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"};const isNullOrEmpty=value=>value===null||value==="";function initCanvas(canvas,aspectRatio){const style=canvas.style;const renderHeight=canvas.getAttribute("height");const renderWidth=canvas.getAttribute("width");canvas[EXPANDO_KEY]={initial:{height:renderHeight,width:renderWidth,style:{display:style.display,height:style.height,width:style.width}}};style.display=style.display||"block";style.boxSizing=style.boxSizing||"border-box";if(isNullOrEmpty(renderWidth)){const displayWidth=readUsedSize(canvas,"width");if(displayWidth!==undefined){canvas.width=displayWidth}}if(isNullOrEmpty(renderHeight)){if(canvas.style.height===""){canvas.height=canvas.width/(aspectRatio||2)}else{const displayHeight=readUsedSize(canvas,"height");if(displayHeight!==undefined){canvas.height=displayHeight}}}return canvas}const eventListenerOptions=supportsEventListenerOptions?{passive:true}:false;function addListener(node,type,listener){if(node){node.addEventListener(type,listener,eventListenerOptions)}}function removeListener(chart,type,listener){if(chart&&chart.canvas){chart.canvas.removeEventListener(type,listener,eventListenerOptions)}}function fromNativeEvent(event,chart){const type=EVENT_TYPES[event.type]||event.type;const{x:x,y:y}=getRelativePosition(event,chart);return{type:type,chart:chart,native:event,x:x!==undefined?x:null,y:y!==undefined?y:null}}function nodeListContains(nodeList,canvas){for(const node of nodeList){if(node===canvas||node.contains(canvas)){return true}}}function createAttachObserver(chart,type,listener){const canvas=chart.canvas;const observer=new MutationObserver((entries=>{let trigger=false;for(const entry of entries){trigger=trigger||nodeListContains(entry.addedNodes,canvas);trigger=trigger&&!nodeListContains(entry.removedNodes,canvas)}if(trigger){listener()}}));observer.observe(document,{childList:true,subtree:true});return observer}function createDetachObserver(chart,type,listener){const canvas=chart.canvas;const observer=new MutationObserver((entries=>{let trigger=false;for(const entry of entries){trigger=trigger||nodeListContains(entry.removedNodes,canvas);trigger=trigger&&!nodeListContains(entry.addedNodes,canvas)}if(trigger){listener()}}));observer.observe(document,{childList:true,subtree:true});return observer}const drpListeningCharts=new Map;let oldDevicePixelRatio=0;function onWindowResize(){const dpr=window.devicePixelRatio;if(dpr===oldDevicePixelRatio){return}oldDevicePixelRatio=dpr;drpListeningCharts.forEach(((resize,chart)=>{if(chart.currentDevicePixelRatio!==dpr){resize()}}))}function listenDevicePixelRatioChanges(chart,resize){if(!drpListeningCharts.size){window.addEventListener("resize",onWindowResize)}drpListeningCharts.set(chart,resize)}function unlistenDevicePixelRatioChanges(chart){drpListeningCharts.delete(chart);if(!drpListeningCharts.size){window.removeEventListener("resize",onWindowResize)}}function createResizeObserver(chart,type,listener){const canvas=chart.canvas;const container=canvas&&_getParentNode(canvas);if(!container){return}const resize=throttled(((width,height)=>{const w=container.clientWidth;listener(width,height);if(w{const entry=entries[0];const width=entry.contentRect.width;const height=entry.contentRect.height;if(width===0&&height===0){return}resize(width,height)}));observer.observe(container);listenDevicePixelRatioChanges(chart,resize);return observer}function releaseObserver(chart,type,observer){if(observer){observer.disconnect()}if(type==="resize"){unlistenDevicePixelRatioChanges(chart)}}function createProxyAndListen(chart,type,listener){const canvas=chart.canvas;const proxy=throttled((event=>{if(chart.ctx!==null){listener(fromNativeEvent(event,chart))}}),chart);addListener(canvas,type,proxy);return proxy}class DomPlatform extends BasePlatform{acquireContext(canvas,aspectRatio){const context=canvas&&canvas.getContext&&canvas.getContext("2d");if(context&&context.canvas===canvas){initCanvas(canvas,aspectRatio);return context}return null}releaseContext(context){const canvas=context.canvas;if(!canvas[EXPANDO_KEY]){return false}const initial=canvas[EXPANDO_KEY].initial;["height","width"].forEach((prop=>{const value=initial[prop];if(isNullOrUndef(value)){canvas.removeAttribute(prop)}else{canvas.setAttribute(prop,value)}}));const style=initial.style||{};Object.keys(style).forEach((key=>{canvas.style[key]=style[key]}));canvas.width=canvas.width;delete canvas[EXPANDO_KEY];return true}addEventListener(chart,type,listener){this.removeEventListener(chart,type);const proxies=chart.$proxies||(chart.$proxies={});const handlers={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver};const handler=handlers[type]||createProxyAndListen;proxies[type]=handler(chart,type,listener)}removeEventListener(chart,type){const proxies=chart.$proxies||(chart.$proxies={});const proxy=proxies[type];if(!proxy){return}const handlers={attach:releaseObserver,detach:releaseObserver,resize:releaseObserver};const handler=handlers[type]||removeListener;handler(chart,type,proxy);proxies[type]=undefined}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(canvas,width,height,aspectRatio){return getMaximumSize(canvas,width,height,aspectRatio)}isAttached(canvas){const container=_getParentNode(canvas);return!!(container&&container.isConnected)}}function _detectPlatform(canvas){if(!_isDomSupported()||typeof OffscreenCanvas!=="undefined"&&canvas instanceof OffscreenCanvas){return BasicPlatform}return DomPlatform}class Element{static defaults={};static defaultRoutes=undefined;x;y;active=false;options;$animations;tooltipPosition(useFinalPosition){const{x:x,y:y}=this.getProps(["x","y"],useFinalPosition);return{x:x,y:y}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(props,final){const anims=this.$animations;if(!final||!anims){return this}const ret={};props.forEach((prop=>{ret[prop]=anims[prop]&&anims[prop].active()?anims[prop]._to:this[prop]}));return ret}}function autoSkip(scale,ticks){const tickOpts=scale.options.ticks;const determinedMaxTicks=determineMaxTicks(scale);const ticksLimit=Math.min(tickOpts.maxTicksLimit||determinedMaxTicks,determinedMaxTicks);const majorIndices=tickOpts.major.enabled?getMajorIndices(ticks):[];const numMajorIndices=majorIndices.length;const first=majorIndices[0];const last=majorIndices[numMajorIndices-1];const newTicks=[];if(numMajorIndices>ticksLimit){skipMajors(ticks,newTicks,majorIndices,numMajorIndices/ticksLimit);return newTicks}const spacing=calculateSpacing(majorIndices,ticks,ticksLimit);if(numMajorIndices>0){let i,ilen;const avgMajorSpacing=numMajorIndices>1?Math.round((last-first)/(numMajorIndices-1)):null;skip(ticks,newTicks,spacing,isNullOrUndef(avgMajorSpacing)?0:first-avgMajorSpacing,first);for(i=0,ilen=numMajorIndices-1;ispacing){return factor}}return Math.max(spacing,1)}function getMajorIndices(ticks){const result=[];let i,ilen;for(i=0,ilen=ticks.length;ialign==="left"?"right":align==="right"?"left":align;const offsetFromEdge=(scale,edge,offset)=>edge==="top"||edge==="left"?scale[edge]+offset:scale[edge]-offset;const getTicksLimit=(ticksLength,maxTicksLimit)=>Math.min(maxTicksLimit||ticksLength,ticksLength);function sample(arr,numItems){const result=[];const increment=arr.length/numItems;const len=arr.length;let i=0;for(;iend+epsilon){return}}return lineValue}function garbageCollect(caches,length){each(caches,(cache=>{const gc=cache.gc;const gcLen=gc.length/2;let i;if(gcLen>length){for(i=0;imax?max:min;max=minDefined&&min>max?min:max;return{min:finiteOrDefault(min,finiteOrDefault(max,min)),max:finiteOrDefault(max,finiteOrDefault(min,max))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const data=this.chart.data;return this.options.labels||(this.isHorizontal()?data.xLabels:data.yLabels)||data.labels||[]}getLabelItems(chartArea=this.chart.chartArea){const items=this._labelItems||(this._labelItems=this._computeLabelItems(chartArea));return items}beforeLayout(){this._cache={};this._dataLimitsCached=false}beforeUpdate(){callback(this.options.beforeUpdate,[this])}update(maxWidth,maxHeight,margins){const{beginAtZero:beginAtZero,grace:grace,ticks:tickOpts}=this.options;const sampleSize=tickOpts.sampleSize;this.beforeUpdate();this.maxWidth=maxWidth;this.maxHeight=maxHeight;this._margins=margins=Object.assign({left:0,right:0,top:0,bottom:0},margins);this.ticks=null;this._labelSizes=null;this._gridLineItems=null;this._labelItems=null;this.beforeSetDimensions();this.setDimensions();this.afterSetDimensions();this._maxLength=this.isHorizontal()?this.width+margins.left+margins.right:this.height+margins.top+margins.bottom;if(!this._dataLimitsCached){this.beforeDataLimits();this.determineDataLimits();this.afterDataLimits();this._range=_addGrace(this,grace,beginAtZero);this._dataLimitsCached=true}this.beforeBuildTicks();this.ticks=this.buildTicks()||[];this.afterBuildTicks();const samplingEnabled=sampleSize=maxRotation||numTicks<=1||!this.isHorizontal()){this.labelRotation=minRotation;return}const labelSizes=this._getLabelSizes();const maxLabelWidth=labelSizes.widest.width;const maxLabelHeight=labelSizes.highest.height;const maxWidth=_limitValue(this.chart.width-maxLabelWidth,0,this.maxWidth);tickWidth=options.offset?this.maxWidth/numTicks:maxWidth/(numTicks-1);if(maxLabelWidth+6>tickWidth){tickWidth=maxWidth/(numTicks-(options.offset?.5:1));maxHeight=this.maxHeight-getTickMarkLength(options.grid)-tickOpts.padding-getTitleHeight(options.title,this.chart.options.font);maxLabelDiagonal=Math.sqrt(maxLabelWidth*maxLabelWidth+maxLabelHeight*maxLabelHeight);labelRotation=toDegrees(Math.min(Math.asin(_limitValue((labelSizes.highest.height+6)/tickWidth,-1,1)),Math.asin(_limitValue(maxHeight/maxLabelDiagonal,-1,1))-Math.asin(_limitValue(maxLabelHeight/maxLabelDiagonal,-1,1))));labelRotation=Math.max(minRotation,Math.min(maxRotation,labelRotation))}this.labelRotation=labelRotation}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const minSize={width:0,height:0};const{chart:chart,options:{ticks:tickOpts,title:titleOpts,grid:gridOpts}}=this;const display=this._isVisible();const isHorizontal=this.isHorizontal();if(display){const titleHeight=getTitleHeight(titleOpts,chart.options.font);if(isHorizontal){minSize.width=this.maxWidth;minSize.height=getTickMarkLength(gridOpts)+titleHeight}else{minSize.height=this.maxHeight;minSize.width=getTickMarkLength(gridOpts)+titleHeight}if(tickOpts.display&&this.ticks.length){const{first:first,last:last,widest:widest,highest:highest}=this._getLabelSizes();const tickPadding=tickOpts.padding*2;const angleRadians=toRadians(this.labelRotation);const cos=Math.cos(angleRadians);const sin=Math.sin(angleRadians);if(isHorizontal){const labelHeight=tickOpts.mirror?0:sin*widest.width+cos*highest.height;minSize.height=Math.min(this.maxHeight,minSize.height+labelHeight+tickPadding)}else{const labelWidth=tickOpts.mirror?0:cos*widest.width+sin*highest.height;minSize.width=Math.min(this.maxWidth,minSize.width+labelWidth+tickPadding)}this._calculatePadding(first,last,sin,cos)}}this._handleMargins();if(isHorizontal){this.width=this._length=chart.width-this._margins.left-this._margins.right;this.height=minSize.height}else{this.width=minSize.width;this.height=this._length=chart.height-this._margins.top-this._margins.bottom}}_calculatePadding(first,last,sin,cos){const{ticks:{align:align,padding:padding},position:position}=this.options;const isRotated=this.labelRotation!==0;const labelsBelowTicks=position!=="top"&&this.axis==="x";if(this.isHorizontal()){const offsetLeft=this.getPixelForTick(0)-this.left;const offsetRight=this.right-this.getPixelForTick(this.ticks.length-1);let paddingLeft=0;let paddingRight=0;if(isRotated){if(labelsBelowTicks){paddingLeft=cos*first.width;paddingRight=sin*last.height}else{paddingLeft=sin*first.height;paddingRight=cos*last.width}}else if(align==="start"){paddingRight=last.width}else if(align==="end"){paddingLeft=first.width}else if(align!=="inner"){paddingLeft=first.width/2;paddingRight=last.width/2}this.paddingLeft=Math.max((paddingLeft-offsetLeft+padding)*this.width/(this.width-offsetLeft),0);this.paddingRight=Math.max((paddingRight-offsetRight+padding)*this.width/(this.width-offsetRight),0)}else{let paddingTop=last.height/2;let paddingBottom=first.height/2;if(align==="start"){paddingTop=0;paddingBottom=first.height}else if(align==="end"){paddingTop=last.height;paddingBottom=0}this.paddingTop=paddingTop+padding;this.paddingBottom=paddingBottom+padding}}_handleMargins(){if(this._margins){this._margins.left=Math.max(this.paddingLeft,this._margins.left);this._margins.top=Math.max(this.paddingTop,this._margins.top);this._margins.right=Math.max(this.paddingRight,this._margins.right);this._margins.bottom=Math.max(this.paddingBottom,this._margins.bottom)}}afterFit(){callback(this.options.afterFit,[this])}isHorizontal(){const{axis:axis,position:position}=this.options;return position==="top"||position==="bottom"||axis==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(ticks){this.beforeTickToLabelConversion();this.generateTickLabels(ticks);let i,ilen;for(i=0,ilen=ticks.length;i({width:widths[idx]||0,height:heights[idx]||0});return{first:valueAt(0),last:valueAt(length-1),widest:valueAt(widest),highest:valueAt(highest),widths:widths,heights:heights}}getLabelForValue(value){return value}getPixelForValue(value,index){return NaN}getValueForPixel(pixel){}getPixelForTick(index){const ticks=this.ticks;if(index<0||index>ticks.length-1){return null}return this.getPixelForValue(ticks[index].value)}getPixelForDecimal(decimal){if(this._reversePixels){decimal=1-decimal}const pixel=this._startPixel+decimal*this._length;return _int16Range(this._alignToPixels?_alignPixel(this.chart,pixel,0):pixel)}getDecimalForPixel(pixel){const decimal=(pixel-this._startPixel)/this._length;return this._reversePixels?1-decimal:decimal}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:min,max:max}=this;return min<0&&max<0?max:min>0&&max>0?min:0}getContext(index){const ticks=this.ticks||[];if(index>=0&&indexw*sin?w/cos:h/sin:h*sin0}_computeGridLineItems(chartArea){const axis=this.axis;const chart=this.chart;const options=this.options;const{grid:grid,position:position,border:border}=options;const offset=grid.offset;const isHorizontal=this.isHorizontal();const ticks=this.ticks;const ticksLength=ticks.length+(offset?1:0);const tl=getTickMarkLength(grid);const items=[];const borderOpts=border.setContext(this.getContext());const axisWidth=borderOpts.display?borderOpts.width:0;const axisHalfWidth=axisWidth/2;const alignBorderValue=function(pixel){return _alignPixel(chart,pixel,axisWidth)};let borderValue,i,lineValue,alignedLineValue;let tx1,ty1,tx2,ty2,x1,y1,x2,y2;if(position==="top"){borderValue=alignBorderValue(this.bottom);ty1=this.bottom-tl;ty2=borderValue-axisHalfWidth;y1=alignBorderValue(chartArea.top)+axisHalfWidth;y2=chartArea.bottom}else if(position==="bottom"){borderValue=alignBorderValue(this.top);y1=chartArea.top;y2=alignBorderValue(chartArea.bottom)-axisHalfWidth;ty1=borderValue+axisHalfWidth;ty2=this.top+tl}else if(position==="left"){borderValue=alignBorderValue(this.right);tx1=this.right-tl;tx2=borderValue-axisHalfWidth;x1=alignBorderValue(chartArea.left)+axisHalfWidth;x2=chartArea.right}else if(position==="right"){borderValue=alignBorderValue(this.left);x1=chartArea.left;x2=alignBorderValue(chartArea.right)-axisHalfWidth;tx1=borderValue+axisHalfWidth;tx2=this.left+tl}else if(axis==="x"){if(position==="center"){borderValue=alignBorderValue((chartArea.top+chartArea.bottom)/2+.5)}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value))}y1=chartArea.top;y2=chartArea.bottom;ty1=borderValue+axisHalfWidth;ty2=ty1+tl}else if(axis==="y"){if(position==="center"){borderValue=alignBorderValue((chartArea.left+chartArea.right)/2)}else if(isObject(position)){const positionAxisID=Object.keys(position)[0];const value=position[positionAxisID];borderValue=alignBorderValue(this.chart.scales[positionAxisID].getPixelForValue(value))}tx1=borderValue-axisHalfWidth;tx2=tx1-tl;x1=chartArea.left;x2=chartArea.right}const limit=valueOrDefault(options.ticks.maxTicksLimit,ticksLength);const step=Math.max(1,Math.ceil(ticksLength/limit));for(i=0;i0){left-=width/2}break}backdrop={left:left,top:top,width:width+labelPadding.width,height:height+labelPadding.height,color:optsAtIndex.backdropColor}}items.push({label:label,font:font,textOffset:textOffset,options:{rotation:rotation,color:color,strokeColor:strokeColor,strokeWidth:strokeWidth,textAlign:tickTextAlign,textBaseline:textBaseline,translation:[x,y],backdrop:backdrop}})}return items}_getXAxisLabelAlignment(){const{position:position,ticks:ticks}=this.options;const rotation=-toRadians(this.labelRotation);if(rotation){return position==="top"?"left":"right"}let align="center";if(ticks.align==="start"){align="left"}else if(ticks.align==="end"){align="right"}else if(ticks.align==="inner"){align="inner"}return align}_getYAxisLabelAlignment(tl){const{position:position,ticks:{crossAlign:crossAlign,mirror:mirror,padding:padding}}=this.options;const labelSizes=this._getLabelSizes();const tickAndPadding=tl+padding;const widest=labelSizes.widest.width;let textAlign;let x;if(position==="left"){if(mirror){x=this.right+padding;if(crossAlign==="near"){textAlign="left"}else if(crossAlign==="center"){textAlign="center";x+=widest/2}else{textAlign="right";x+=widest}}else{x=this.right-tickAndPadding;if(crossAlign==="near"){textAlign="right"}else if(crossAlign==="center"){textAlign="center";x-=widest/2}else{textAlign="left";x=this.left}}}else if(position==="right"){if(mirror){x=this.left+padding;if(crossAlign==="near"){textAlign="right"}else if(crossAlign==="center"){textAlign="center";x-=widest/2}else{textAlign="left";x-=widest}}else{x=this.left+tickAndPadding;if(crossAlign==="near"){textAlign="left"}else if(crossAlign==="center"){textAlign="center";x+=widest/2}else{textAlign="right";x=this.right}}}else{textAlign="right"}return{textAlign:textAlign,x:x}}_computeLabelArea(){if(this.options.ticks.mirror){return}const chart=this.chart;const position=this.options.position;if(position==="left"||position==="right"){return{top:0,left:this.left,bottom:chart.height,right:this.right}}if(position==="top"||position==="bottom"){return{top:this.top,left:0,bottom:this.bottom,right:chart.width}}}drawBackground(){const{ctx:ctx,options:{backgroundColor:backgroundColor},left:left,top:top,width:width,height:height}=this;if(backgroundColor){ctx.save();ctx.fillStyle=backgroundColor;ctx.fillRect(left,top,width,height);ctx.restore()}}getLineWidthForValue(value){const grid=this.options.grid;if(!this._isVisible()||!grid.display){return 0}const ticks=this.ticks;const index=ticks.findIndex((t=>t.value===value));if(index>=0){const opts=grid.setContext(this.getContext(index));return opts.lineWidth}return 0}drawGrid(chartArea){const grid=this.options.grid;const ctx=this.ctx;const items=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(chartArea));let i,ilen;const drawLine=(p1,p2,style)=>{if(!style.width||!style.color){return}ctx.save();ctx.lineWidth=style.width;ctx.strokeStyle=style.color;ctx.setLineDash(style.borderDash||[]);ctx.lineDashOffset=style.borderDashOffset;ctx.beginPath();ctx.moveTo(p1.x,p1.y);ctx.lineTo(p2.x,p2.y);ctx.stroke();ctx.restore()};if(grid.display){for(i=0,ilen=items.length;i{this.draw(chartArea)}}]}return[{z:gz,draw:chartArea=>{this.drawBackground();this.drawGrid(chartArea);this.drawTitle()}},{z:bz,draw:()=>{this.drawBorder()}},{z:tz,draw:chartArea=>{this.drawLabels(chartArea)}}]}getMatchingVisibleMetas(type){const metas=this.chart.getSortedVisibleDatasetMetas();const axisID=this.axis+"AxisID";const result=[];let i,ilen;for(i=0,ilen=metas.length;i{const propertyParts=property.split(".");const sourceName=propertyParts.pop();const sourceScope=[scope].concat(propertyParts).join(".");const parts=routes[property].split(".");const targetName=parts.pop();const targetScope=parts.join(".");defaults.route(sourceScope,sourceName,targetScope,targetName)}))}function isIChartComponent(proto){return"id"in proto&&"defaults"in proto}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",true);this.elements=new TypedRegistry(Element,"elements");this.plugins=new TypedRegistry(Object,"plugins");this.scales=new TypedRegistry(Scale,"scales");this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...args){this._each("register",args)}remove(...args){this._each("unregister",args)}addControllers(...args){this._each("register",args,this.controllers)}addElements(...args){this._each("register",args,this.elements)}addPlugins(...args){this._each("register",args,this.plugins)}addScales(...args){this._each("register",args,this.scales)}getController(id){return this._get(id,this.controllers,"controller")}getElement(id){return this._get(id,this.elements,"element")}getPlugin(id){return this._get(id,this.plugins,"plugin")}getScale(id){return this._get(id,this.scales,"scale")}removeControllers(...args){this._each("unregister",args,this.controllers)}removeElements(...args){this._each("unregister",args,this.elements)}removePlugins(...args){this._each("unregister",args,this.plugins)}removeScales(...args){this._each("unregister",args,this.scales)}_each(method,args,typedRegistry){[...args].forEach((arg=>{const reg=typedRegistry||this._getRegistryForType(arg);if(typedRegistry||reg.isForType(arg)||reg===this.plugins&&arg.id){this._exec(method,reg,arg)}else{each(arg,(item=>{const itemReg=typedRegistry||this._getRegistryForType(item);this._exec(method,itemReg,item)}))}}))}_exec(method,registry,component){const camelMethod=_capitalize(method);callback(component["before"+camelMethod],[],component);registry[method](component);callback(component["after"+camelMethod],[],component)}_getRegistryForType(type){for(let i=0;ia.filter((x=>!b.some((y=>x.plugin.id===y.plugin.id))));this._notify(diff(previousDescriptors,descriptors),chart,"stop");this._notify(diff(descriptors,previousDescriptors),chart,"start")}}function allPlugins(config){const localIds={};const plugins=[];const keys=Object.keys(registry.plugins.items);for(let i=0;i1&&idMatchesAxis(id[0].toLowerCase());if(axis){return axis}}throw new Error(`Cannot determine type of '${id}' axis. Please provide 'axis' or 'position' option.`)}function getAxisFromDataset(id,axis,dataset){if(dataset[axis+"AxisID"]===id){return{axis:axis}}}function retrieveAxisFromDatasets(id,config){if(config.data&&config.data.datasets){const boundDs=config.data.datasets.filter((d=>d.xAxisID===id||d.yAxisID===id));if(boundDs.length){return getAxisFromDataset(id,"x",boundDs[0])||getAxisFromDataset(id,"y",boundDs[0])}}return{}}function mergeScaleConfig(config,options){const chartDefaults=overrides[config.type]||{scales:{}};const configScales=options.scales||{};const chartIndexAxis=getIndexAxis(config.type,options);const scales=Object.create(null);Object.keys(configScales).forEach((id=>{const scaleConf=configScales[id];if(!isObject(scaleConf)){return console.error(`Invalid scale configuration for scale: ${id}`)}if(scaleConf._proxy){return console.warn(`Ignoring resolver passed as options for scale: ${id}`)}const axis=determineAxis(id,scaleConf,retrieveAxisFromDatasets(id,config),defaults.scales[scaleConf.type]);const defaultId=getDefaultScaleIDFromAxis(axis,chartIndexAxis);const defaultScaleOptions=chartDefaults.scales||{};scales[id]=mergeIf(Object.create(null),[{axis:axis},scaleConf,defaultScaleOptions[axis],defaultScaleOptions[defaultId]])}));config.data.datasets.forEach((dataset=>{const type=dataset.type||config.type;const indexAxis=dataset.indexAxis||getIndexAxis(type,options);const datasetDefaults=overrides[type]||{};const defaultScaleOptions=datasetDefaults.scales||{};Object.keys(defaultScaleOptions).forEach((defaultID=>{const axis=getAxisFromDefaultScaleID(defaultID,indexAxis);const id=dataset[axis+"AxisID"]||axis;scales[id]=scales[id]||Object.create(null);mergeIf(scales[id],[{axis:axis},configScales[id],defaultScaleOptions[defaultID]])}))}));Object.keys(scales).forEach((key=>{const scale=scales[key];mergeIf(scale,[defaults.scales[scale.type],defaults.scale])}));return scales}function initOptions(config){const options=config.options||(config.options={});options.plugins=valueOrDefault(options.plugins,{});options.scales=mergeScaleConfig(config,options)}function initData(data){data=data||{};data.datasets=data.datasets||[];data.labels=data.labels||[];return data}function initConfig(config){config=config||{};config.data=initData(config.data);initOptions(config);return config}const keyCache=new Map;const keysCached=new Set;function cachedKeys(cacheKey,generate){let keys=keyCache.get(cacheKey);if(!keys){keys=generate();keyCache.set(cacheKey,keys);keysCached.add(keys)}return keys}const addIfFound=(set,obj,key)=>{const opts=resolveObjectKey(obj,key);if(opts!==undefined){set.add(opts)}};class Config{constructor(config){this._config=initConfig(config);this._scopeCache=new Map;this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(type){this._config.type=type}get data(){return this._config.data}set data(data){this._config.data=initData(data)}get options(){return this._config.options}set options(options){this._config.options=options}get plugins(){return this._config.plugins}update(){const config=this._config;this.clearCache();initOptions(config)}clearCache(){this._scopeCache.clear();this._resolverCache.clear()}datasetScopeKeys(datasetType){return cachedKeys(datasetType,(()=>[[`datasets.${datasetType}`,""]]))}datasetAnimationScopeKeys(datasetType,transition){return cachedKeys(`${datasetType}.transition.${transition}`,(()=>[[`datasets.${datasetType}.transitions.${transition}`,`transitions.${transition}`],[`datasets.${datasetType}`,""]]))}datasetElementScopeKeys(datasetType,elementType){return cachedKeys(`${datasetType}-${elementType}`,(()=>[[`datasets.${datasetType}.elements.${elementType}`,`datasets.${datasetType}`,`elements.${elementType}`,""]]))}pluginScopeKeys(plugin){const id=plugin.id;const type=this.type;return cachedKeys(`${type}-plugin-${id}`,(()=>[[`plugins.${id}`,...plugin.additionalOptionScopes||[]]]))}_cachedScopes(mainScope,resetCache){const _scopeCache=this._scopeCache;let cache=_scopeCache.get(mainScope);if(!cache||resetCache){cache=new Map;_scopeCache.set(mainScope,cache)}return cache}getOptionScopes(mainScope,keyLists,resetCache){const{options:options,type:type}=this;const cache=this._cachedScopes(mainScope,resetCache);const cached=cache.get(keyLists);if(cached){return cached}const scopes=new Set;keyLists.forEach((keys=>{if(mainScope){scopes.add(mainScope);keys.forEach((key=>addIfFound(scopes,mainScope,key)))}keys.forEach((key=>addIfFound(scopes,options,key)));keys.forEach((key=>addIfFound(scopes,overrides[type]||{},key)));keys.forEach((key=>addIfFound(scopes,defaults,key)));keys.forEach((key=>addIfFound(scopes,descriptors,key)))}));const array=Array.from(scopes);if(array.length===0){array.push(Object.create(null))}if(keysCached.has(keyLists)){cache.set(keyLists,array)}return array}chartOptionScopes(){const{options:options,type:type}=this;return[options,overrides[type]||{},defaults.datasets[type]||{},{type:type},defaults,descriptors]}resolveNamedOptions(scopes,names,context,prefixes=[""]){const result={$shared:true};const{resolver:resolver,subPrefixes:subPrefixes}=getResolver(this._resolverCache,scopes,prefixes);let options=resolver;if(needContext(resolver,names)){result.$shared=false;context=isFunction(context)?context():context;const subResolver=this.createResolver(scopes,context,subPrefixes);options=_attachContext(resolver,context,subResolver)}for(const prop of names){result[prop]=options[prop]}return result}createResolver(scopes,context,prefixes=[""],descriptorDefaults){const{resolver:resolver}=getResolver(this._resolverCache,scopes,prefixes);return isObject(context)?_attachContext(resolver,context,undefined,descriptorDefaults):resolver}}function getResolver(resolverCache,scopes,prefixes){let cache=resolverCache.get(scopes);if(!cache){cache=new Map;resolverCache.set(scopes,cache)}const cacheKey=prefixes.join();let cached=cache.get(cacheKey);if(!cached){const resolver=_createResolver(scopes,prefixes);cached={resolver:resolver,subPrefixes:prefixes.filter((p=>!p.toLowerCase().includes("hover")))};cache.set(cacheKey,cached)}return cached}const hasFunction=value=>isObject(value)&&Object.getOwnPropertyNames(value).some((key=>isFunction(value[key])));function needContext(proxy,names){const{isScriptable:isScriptable,isIndexable:isIndexable}=_descriptors(proxy);for(const prop of names){const scriptable=isScriptable(prop);const indexable=isIndexable(prop);const value=(indexable||scriptable)&&proxy[prop];if(scriptable&&(isFunction(value)||hasFunction(value))||indexable&&isArray(value)){return true}}return false}var version="4.4.2";const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(position,axis){return position==="top"||position==="bottom"||KNOWN_POSITIONS.indexOf(position)===-1&&axis==="x"}function compare2Level(l1,l2){return function(a,b){return a[l1]===b[l1]?a[l2]-b[l2]:a[l1]-b[l1]}}function onAnimationsComplete(context){const chart=context.chart;const animationOptions=chart.options.animation;chart.notifyPlugins("afterRender");callback(animationOptions&&animationOptions.onComplete,[context],chart)}function onAnimationProgress(context){const chart=context.chart;const animationOptions=chart.options.animation;callback(animationOptions&&animationOptions.onProgress,[context],chart)}function getCanvas(item){if(_isDomSupported()&&typeof item==="string"){item=document.getElementById(item)}else if(item&&item.length){item=item[0]}if(item&&item.canvas){item=item.canvas}return item}const instances={};const getChart=key=>{const canvas=getCanvas(key);return Object.values(instances).filter((c=>c.canvas===canvas)).pop()};function moveNumericKeys(obj,start,move){const keys=Object.keys(obj);for(const key of keys){const intKey=+key;if(intKey>=start){const value=obj[key];delete obj[key];if(move>0||intKey>start){obj[intKey+move]=value}}}}function determineLastEvent(e,lastEvent,inChartArea,isClick){if(!inChartArea||e.type==="mouseout"){return null}if(isClick){return lastEvent}return e}function getSizeForArea(scale,chartArea,field){return scale.options.clip?scale[field]:chartArea[field]}function getDatasetArea(meta,chartArea){const{xScale:xScale,yScale:yScale}=meta;if(xScale&&yScale){return{left:getSizeForArea(xScale,chartArea,"left"),right:getSizeForArea(xScale,chartArea,"right"),top:getSizeForArea(yScale,chartArea,"top"),bottom:getSizeForArea(yScale,chartArea,"bottom")}}return chartArea}class Chart{static defaults=defaults;static instances=instances;static overrides=overrides;static registry=registry;static version=version;static getChart=getChart;static register(...items){registry.add(...items);invalidatePlugins()}static unregister(...items){registry.remove(...items);invalidatePlugins()}constructor(item,userConfig){const config=this.config=new Config(userConfig);const initialCanvas=getCanvas(item);const existingChart=getChart(initialCanvas);if(existingChart){throw new Error("Canvas is already in use. Chart with ID '"+existingChart.id+"'"+" must be destroyed before the canvas with ID '"+existingChart.canvas.id+"' can be reused.")}const options=config.createResolver(config.chartOptionScopes(),this.getContext());this.platform=new(config.platform||_detectPlatform(initialCanvas));this.platform.updateConfig(config);const context=this.platform.acquireContext(initialCanvas,options.aspectRatio);const canvas=context&&context.canvas;const height=canvas&&canvas.height;const width=canvas&&canvas.width;this.id=uid();this.ctx=context;this.canvas=canvas;this.width=width;this.height=height;this._options=options;this._aspectRatio=this.aspectRatio;this._layers=[];this._metasets=[];this._stacks=undefined;this.boxes=[];this.currentDevicePixelRatio=undefined;this.chartArea=undefined;this._active=[];this._lastEvent=undefined;this._listeners={};this._responsiveListeners=undefined;this._sortedMetasets=[];this.scales={};this._plugins=new PluginService;this.$proxies={};this._hiddenIndices={};this.attached=false;this._animationsDisabled=undefined;this.$context=undefined;this._doResize=debounce((mode=>this.update(mode)),options.resizeDelay||0);this._dataChanges=[];instances[this.id]=this;if(!context||!canvas){console.error("Failed to create chart: can't acquire context from the given item");return}animator.listen(this,"complete",onAnimationsComplete);animator.listen(this,"progress",onAnimationProgress);this._initialize();if(this.attached){this.update()}}get aspectRatio(){const{options:{aspectRatio:aspectRatio,maintainAspectRatio:maintainAspectRatio},width:width,height:height,_aspectRatio:_aspectRatio}=this;if(!isNullOrUndef(aspectRatio)){return aspectRatio}if(maintainAspectRatio&&_aspectRatio){return _aspectRatio}return height?width/height:null}get data(){return this.config.data}set data(data){this.config.data=data}get options(){return this._options}set options(options){this.config.options=options}get registry(){return registry}_initialize(){this.notifyPlugins("beforeInit");if(this.options.responsive){this.resize()}else{retinaScale(this,this.options.devicePixelRatio)}this.bindEvents();this.notifyPlugins("afterInit");return this}clear(){clearCanvas(this.canvas,this.ctx);return this}stop(){animator.stop(this);return this}resize(width,height){if(!animator.running(this)){this._resize(width,height)}else{this._resizeBeforeDraw={width:width,height:height}}}_resize(width,height){const options=this.options;const canvas=this.canvas;const aspectRatio=options.maintainAspectRatio&&this.aspectRatio;const newSize=this.platform.getMaximumSize(canvas,width,height,aspectRatio);const newRatio=options.devicePixelRatio||this.platform.getDevicePixelRatio();const mode=this.width?"resize":"attach";this.width=newSize.width;this.height=newSize.height;this._aspectRatio=this.aspectRatio;if(!retinaScale(this,newRatio,true)){return}this.notifyPlugins("resize",{size:newSize});callback(options.onResize,[this,newSize],this);if(this.attached){if(this._doResize(mode)){this.render()}}}ensureScalesHaveIDs(){const options=this.options;const scalesOptions=options.scales||{};each(scalesOptions,((axisOptions,axisID)=>{axisOptions.id=axisID}))}buildOrUpdateScales(){const options=this.options;const scaleOpts=options.scales;const scales=this.scales;const updated=Object.keys(scales).reduce(((obj,id)=>{obj[id]=false;return obj}),{});let items=[];if(scaleOpts){items=items.concat(Object.keys(scaleOpts).map((id=>{const scaleOptions=scaleOpts[id];const axis=determineAxis(id,scaleOptions);const isRadial=axis==="r";const isHorizontal=axis==="x";return{options:scaleOptions,dposition:isRadial?"chartArea":isHorizontal?"bottom":"left",dtype:isRadial?"radialLinear":isHorizontal?"category":"linear"}})))}each(items,(item=>{const scaleOptions=item.options;const id=scaleOptions.id;const axis=determineAxis(id,scaleOptions);const scaleType=valueOrDefault(scaleOptions.type,item.dtype);if(scaleOptions.position===undefined||positionIsHorizontal(scaleOptions.position,axis)!==positionIsHorizontal(item.dposition)){scaleOptions.position=item.dposition}updated[id]=true;let scale=null;if(id in scales&&scales[id].type===scaleType){scale=scales[id]}else{const scaleClass=registry.getScale(scaleType);scale=new scaleClass({id:id,type:scaleType,ctx:this.ctx,chart:this});scales[scale.id]=scale}scale.init(scaleOptions,options)}));each(updated,((hasUpdated,id)=>{if(!hasUpdated){delete scales[id]}}));each(scales,(scale=>{layouts.configure(this,scale,scale.options);layouts.addBox(this,scale)}))}_updateMetasets(){const metasets=this._metasets;const numData=this.data.datasets.length;const numMeta=metasets.length;metasets.sort(((a,b)=>a.index-b.index));if(numMeta>numData){for(let i=numData;idatasets.length){delete this._stacks}metasets.forEach(((meta,index)=>{if(datasets.filter((x=>x===meta._dataset)).length===0){this._destroyDatasetMeta(index)}}))}buildOrUpdateControllers(){const newControllers=[];const datasets=this.data.datasets;let i,ilen;this._removeUnreferencedMetasets();for(i=0,ilen=datasets.length;i{this.getDatasetMeta(datasetIndex).controller.reset()}),this)}reset(){this._resetElements();this.notifyPlugins("reset")}update(mode){const config=this.config;config.update();const options=this._options=config.createResolver(config.chartOptionScopes(),this.getContext());const animsDisabled=this._animationsDisabled=!options.animation;this._updateScales();this._checkEventBindings();this._updateHiddenIndices();this._plugins.invalidate();if(this.notifyPlugins("beforeUpdate",{mode:mode,cancelable:true})===false){return}const newControllers=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let minPadding=0;for(let i=0,ilen=this.data.datasets.length;i{controller.reset()}))}this._updateDatasets(mode);this.notifyPlugins("afterUpdate",{mode:mode});this._layers.sort(compare2Level("z","_idx"));const{_active:_active,_lastEvent:_lastEvent}=this;if(_lastEvent){this._eventHandler(_lastEvent,true)}else if(_active.length){this._updateHoverStyles(_active,_active,true)}this.render()}_updateScales(){each(this.scales,(scale=>{layouts.removeBox(this,scale)}));this.ensureScalesHaveIDs();this.buildOrUpdateScales()}_checkEventBindings(){const options=this.options;const existingEvents=new Set(Object.keys(this._listeners));const newEvents=new Set(options.events);if(!setsEqual(existingEvents,newEvents)||!!this._responsiveListeners!==options.responsive){this.unbindEvents();this.bindEvents()}}_updateHiddenIndices(){const{_hiddenIndices:_hiddenIndices}=this;const changes=this._getUniformDataChanges()||[];for(const{method:method,start:start,count:count}of changes){const move=method==="_removeElements"?-count:count;moveNumericKeys(_hiddenIndices,start,move)}}_getUniformDataChanges(){const _dataChanges=this._dataChanges;if(!_dataChanges||!_dataChanges.length){return}this._dataChanges=[];const datasetCount=this.data.datasets.length;const makeSet=idx=>new Set(_dataChanges.filter((c=>c[0]===idx)).map(((c,i)=>i+","+c.splice(1).join(","))));const changeSet=makeSet(0);for(let i=1;ic.split(","))).map((a=>({method:a[1],start:+a[2],count:+a[3]})))}_updateLayout(minPadding){if(this.notifyPlugins("beforeLayout",{cancelable:true})===false){return}layouts.update(this,this.width,this.height,minPadding);const area=this.chartArea;const noArea=area.width<=0||area.height<=0;this._layers=[];each(this.boxes,(box=>{if(noArea&&box.position==="chartArea"){return}if(box.configure){box.configure()}this._layers.push(...box._layers())}),this);this._layers.forEach(((item,index)=>{item._idx=index}));this.notifyPlugins("afterLayout")}_updateDatasets(mode){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:mode,cancelable:true})===false){return}for(let i=0,ilen=this.data.datasets.length;i=0;--i){this._drawDataset(metasets[i])}this.notifyPlugins("afterDatasetsDraw")}_drawDataset(meta){const ctx=this.ctx;const clip=meta._clip;const useClip=!clip.disabled;const area=getDatasetArea(meta,this.chartArea);const args={meta:meta,index:meta.index,cancelable:true};if(this.notifyPlugins("beforeDatasetDraw",args)===false){return}if(useClip){clipArea(ctx,{left:clip.left===false?0:area.left-clip.left,right:clip.right===false?this.width:area.right+clip.right,top:clip.top===false?0:area.top-clip.top,bottom:clip.bottom===false?this.height:area.bottom+clip.bottom})}meta.controller.draw();if(useClip){unclipArea(ctx)}args.cancelable=false;this.notifyPlugins("afterDatasetDraw",args)}isPointInArea(point){return _isPointInArea(point,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,mode,options,useFinalPosition){const method=Interaction.modes[mode];if(typeof method==="function"){return method(this,e,options,useFinalPosition)}return[]}getDatasetMeta(datasetIndex){const dataset=this.data.datasets[datasetIndex];const metasets=this._metasets;let meta=metasets.filter((x=>x&&x._dataset===dataset)).pop();if(!meta){meta={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:dataset&&dataset.order||0,index:datasetIndex,_dataset:dataset,_parsed:[],_sorted:false};metasets.push(meta)}return meta}getContext(){return this.$context||(this.$context=createContext(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(datasetIndex){const dataset=this.data.datasets[datasetIndex];if(!dataset){return false}const meta=this.getDatasetMeta(datasetIndex);return typeof meta.hidden==="boolean"?!meta.hidden:!dataset.hidden}setDatasetVisibility(datasetIndex,visible){const meta=this.getDatasetMeta(datasetIndex);meta.hidden=!visible}toggleDataVisibility(index){this._hiddenIndices[index]=!this._hiddenIndices[index]}getDataVisibility(index){return!this._hiddenIndices[index]}_updateVisibility(datasetIndex,dataIndex,visible){const mode=visible?"show":"hide";const meta=this.getDatasetMeta(datasetIndex);const anims=meta.controller._resolveAnimations(undefined,mode);if(defined(dataIndex)){meta.data[dataIndex].hidden=!visible;this.update()}else{this.setDatasetVisibility(datasetIndex,visible);anims.update(meta,{visible:visible});this.update((ctx=>ctx.datasetIndex===datasetIndex?mode:undefined))}}hide(datasetIndex,dataIndex){this._updateVisibility(datasetIndex,dataIndex,false)}show(datasetIndex,dataIndex){this._updateVisibility(datasetIndex,dataIndex,true)}_destroyDatasetMeta(datasetIndex){const meta=this._metasets[datasetIndex];if(meta&&meta.controller){meta.controller._destroy()}delete this._metasets[datasetIndex]}_stop(){let i,ilen;this.stop();animator.remove(this);for(i=0,ilen=this.data.datasets.length;i{platform.addEventListener(this,type,listener);listeners[type]=listener};const listener=(e,x,y)=>{e.offsetX=x;e.offsetY=y;this._eventHandler(e)};each(this.options.events,(type=>_add(type,listener)))}bindResponsiveEvents(){if(!this._responsiveListeners){this._responsiveListeners={}}const listeners=this._responsiveListeners;const platform=this.platform;const _add=(type,listener)=>{platform.addEventListener(this,type,listener);listeners[type]=listener};const _remove=(type,listener)=>{if(listeners[type]){platform.removeEventListener(this,type,listener);delete listeners[type]}};const listener=(width,height)=>{if(this.canvas){this.resize(width,height)}};let detached;const attached=()=>{_remove("attach",attached);this.attached=true;this.resize();_add("resize",listener);_add("detach",detached)};detached=()=>{this.attached=false;_remove("resize",listener);this._stop();this._resize(0,0);_add("attach",attached)};if(platform.isAttached(this.canvas)){attached()}else{detached()}}unbindEvents(){each(this._listeners,((listener,type)=>{this.platform.removeEventListener(this,type,listener)}));this._listeners={};each(this._responsiveListeners,((listener,type)=>{this.platform.removeEventListener(this,type,listener)}));this._responsiveListeners=undefined}updateHoverStyle(items,mode,enabled){const prefix=enabled?"set":"remove";let meta,item,i,ilen;if(mode==="dataset"){meta=this.getDatasetMeta(items[0].datasetIndex);meta.controller["_"+prefix+"DatasetHoverStyle"]()}for(i=0,ilen=items.length;i{const meta=this.getDatasetMeta(datasetIndex);if(!meta){throw new Error("No dataset found at index "+datasetIndex)}return{datasetIndex:datasetIndex,element:meta.data[index],index:index}}));const changed=!_elementsEqual(active,lastActive);if(changed){this._active=active;this._lastEvent=null;this._updateHoverStyles(active,lastActive)}}notifyPlugins(hook,args,filter){return this._plugins.notify(this,hook,args,filter)}isPluginEnabled(pluginId){return this._plugins._cache.filter((p=>p.plugin.id===pluginId)).length===1}_updateHoverStyles(active,lastActive,replay){const hoverOptions=this.options.hover;const diff=(a,b)=>a.filter((x=>!b.some((y=>x.datasetIndex===y.datasetIndex&&x.index===y.index))));const deactivated=diff(lastActive,active);const activated=replay?active:diff(active,lastActive);if(deactivated.length){this.updateHoverStyle(deactivated,hoverOptions.mode,false)}if(activated.length&&hoverOptions.mode){this.updateHoverStyle(activated,hoverOptions.mode,true)}}_eventHandler(e,replay){const args={event:e,replay:replay,cancelable:true,inChartArea:this.isPointInArea(e)};const eventFilter=plugin=>(plugin.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",args,eventFilter)===false){return}const changed=this._handleEvent(e,replay,args.inChartArea);args.cancelable=false;this.notifyPlugins("afterEvent",args,eventFilter);if(changed||args.changed){this.render()}return this}_handleEvent(e,replay,inChartArea){const{_active:lastActive=[],options:options}=this;const useFinalPosition=replay;const active=this._getActiveElements(e,lastActive,inChartArea,useFinalPosition);const isClick=_isClickEvent(e);const lastEvent=determineLastEvent(e,this._lastEvent,inChartArea,isClick);if(inChartArea){this._lastEvent=null;callback(options.onHover,[e,active,this],this);if(isClick){callback(options.onClick,[e,active,this],this)}}const changed=!_elementsEqual(active,lastActive);if(changed||replay){this._active=active;this._updateHoverStyles(active,lastActive,replay)}this._lastEvent=lastEvent;return changed}_getActiveElements(e,lastActive,inChartArea,useFinalPosition){if(e.type==="mouseout"){return[]}if(!inChartArea){return lastActive}const hoverOptions=this.options.hover;return this.getElementsAtEventForMode(e,hoverOptions.mode,hoverOptions,useFinalPosition)}}function invalidatePlugins(){return each(Chart.instances,(chart=>chart._plugins.invalidate()))}function clipArc(ctx,element,endAngle){const{startAngle:startAngle,pixelMargin:pixelMargin,x:x,y:y,outerRadius:outerRadius,innerRadius:innerRadius}=element;let angleMargin=pixelMargin/outerRadius;ctx.beginPath();ctx.arc(x,y,outerRadius,startAngle-angleMargin,endAngle+angleMargin);if(innerRadius>pixelMargin){angleMargin=pixelMargin/innerRadius;ctx.arc(x,y,innerRadius,endAngle+angleMargin,startAngle-angleMargin,true)}else{ctx.arc(x,y,pixelMargin,endAngle+HALF_PI,startAngle-HALF_PI)}ctx.closePath();ctx.clip()}function toRadiusCorners(value){return _readValueToProps(value,["outerStart","outerEnd","innerStart","innerEnd"])}function parseBorderRadius$1(arc,innerRadius,outerRadius,angleDelta){const o=toRadiusCorners(arc.options.borderRadius);const halfThickness=(outerRadius-innerRadius)/2;const innerLimit=Math.min(halfThickness,angleDelta*innerRadius/2);const computeOuterLimit=val=>{const outerArcLimit=(outerRadius-Math.min(halfThickness,val))*angleDelta/2;return _limitValue(val,0,Math.min(halfThickness,outerArcLimit))};return{outerStart:computeOuterLimit(o.outerStart),outerEnd:computeOuterLimit(o.outerEnd),innerStart:_limitValue(o.innerStart,0,innerLimit),innerEnd:_limitValue(o.innerEnd,0,innerLimit)}}function rThetaToXY(r,theta,x,y){return{x:x+r*Math.cos(theta),y:y+r*Math.sin(theta)}}function pathArc(ctx,element,offset,spacing,end,circular){const{x:x,y:y,startAngle:start,pixelMargin:pixelMargin,innerRadius:innerR}=element;const outerRadius=Math.max(element.outerRadius+spacing+offset-pixelMargin,0);const innerRadius=innerR>0?innerR+spacing+offset+pixelMargin:0;let spacingOffset=0;const alpha=end-start;if(spacing){const noSpacingInnerRadius=innerR>0?innerR-spacing:0;const noSpacingOuterRadius=outerRadius>0?outerRadius-spacing:0;const avNogSpacingRadius=(noSpacingInnerRadius+noSpacingOuterRadius)/2;const adjustedAngle=avNogSpacingRadius!==0?alpha*avNogSpacingRadius/(avNogSpacingRadius+spacing):alpha;spacingOffset=(alpha-adjustedAngle)/2}const beta=Math.max(.001,alpha*outerRadius-offset/PI)/outerRadius;const angleOffset=(alpha-beta)/2;const startAngle=start+angleOffset+spacingOffset;const endAngle=end-angleOffset-spacingOffset;const{outerStart:outerStart,outerEnd:outerEnd,innerStart:innerStart,innerEnd:innerEnd}=parseBorderRadius$1(element,innerRadius,outerRadius,endAngle-startAngle);const outerStartAdjustedRadius=outerRadius-outerStart;const outerEndAdjustedRadius=outerRadius-outerEnd;const outerStartAdjustedAngle=startAngle+outerStart/outerStartAdjustedRadius;const outerEndAdjustedAngle=endAngle-outerEnd/outerEndAdjustedRadius;const innerStartAdjustedRadius=innerRadius+innerStart;const innerEndAdjustedRadius=innerRadius+innerEnd;const innerStartAdjustedAngle=startAngle+innerStart/innerStartAdjustedRadius;const innerEndAdjustedAngle=endAngle-innerEnd/innerEndAdjustedRadius;ctx.beginPath();if(circular){const outerMidAdjustedAngle=(outerStartAdjustedAngle+outerEndAdjustedAngle)/2;ctx.arc(x,y,outerRadius,outerStartAdjustedAngle,outerMidAdjustedAngle);ctx.arc(x,y,outerRadius,outerMidAdjustedAngle,outerEndAdjustedAngle);if(outerEnd>0){const pCenter=rThetaToXY(outerEndAdjustedRadius,outerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerEnd,outerEndAdjustedAngle,endAngle+HALF_PI)}const p4=rThetaToXY(innerEndAdjustedRadius,endAngle,x,y);ctx.lineTo(p4.x,p4.y);if(innerEnd>0){const pCenter=rThetaToXY(innerEndAdjustedRadius,innerEndAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,innerEnd,endAngle+HALF_PI,innerEndAdjustedAngle+Math.PI)}const innerMidAdjustedAngle=(endAngle-innerEnd/innerRadius+(startAngle+innerStart/innerRadius))/2;ctx.arc(x,y,innerRadius,endAngle-innerEnd/innerRadius,innerMidAdjustedAngle,true);ctx.arc(x,y,innerRadius,innerMidAdjustedAngle,startAngle+innerStart/innerRadius,true);if(innerStart>0){const pCenter=rThetaToXY(innerStartAdjustedRadius,innerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,innerStart,innerStartAdjustedAngle+Math.PI,startAngle-HALF_PI)}const p8=rThetaToXY(outerStartAdjustedRadius,startAngle,x,y);ctx.lineTo(p8.x,p8.y);if(outerStart>0){const pCenter=rThetaToXY(outerStartAdjustedRadius,outerStartAdjustedAngle,x,y);ctx.arc(pCenter.x,pCenter.y,outerStart,startAngle-HALF_PI,outerStartAdjustedAngle)}}else{ctx.moveTo(x,y);const outerStartX=Math.cos(outerStartAdjustedAngle)*outerRadius+x;const outerStartY=Math.sin(outerStartAdjustedAngle)*outerRadius+y;ctx.lineTo(outerStartX,outerStartY);const outerEndX=Math.cos(outerEndAdjustedAngle)*outerRadius+x;const outerEndY=Math.sin(outerEndAdjustedAngle)*outerRadius+y;ctx.lineTo(outerEndX,outerEndY)}ctx.closePath()}function drawArc(ctx,element,offset,spacing,circular){const{fullCircles:fullCircles,startAngle:startAngle,circumference:circumference}=element;let endAngle=element.endAngle;if(fullCircles){pathArc(ctx,element,offset,spacing,endAngle,circular);for(let i=0;iname!=="borderDash"};circumference;endAngle;fullCircles;innerRadius;outerRadius;pixelMargin;startAngle;constructor(cfg){super();this.options=undefined;this.circumference=undefined;this.startAngle=undefined;this.endAngle=undefined;this.innerRadius=undefined;this.outerRadius=undefined;this.pixelMargin=0;this.fullCircles=0;if(cfg){Object.assign(this,cfg)}}inRange(chartX,chartY,useFinalPosition){const point=this.getProps(["x","y"],useFinalPosition);const{angle:angle,distance:distance}=getAngleFromPoint(point,{x:chartX,y:chartY});const{startAngle:startAngle,endAngle:endAngle,innerRadius:innerRadius,outerRadius:outerRadius,circumference:circumference}=this.getProps(["startAngle","endAngle","innerRadius","outerRadius","circumference"],useFinalPosition);const rAdjust=(this.options.spacing+this.options.borderWidth)/2;const _circumference=valueOrDefault(circumference,endAngle-startAngle);const betweenAngles=_circumference>=TAU||_angleBetween(angle,startAngle,endAngle);const withinRadius=_isBetween(distance,innerRadius+rAdjust,outerRadius+rAdjust);return betweenAngles&&withinRadius}getCenterPoint(useFinalPosition){const{x:x,y:y,startAngle:startAngle,endAngle:endAngle,innerRadius:innerRadius,outerRadius:outerRadius}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],useFinalPosition);const{offset:offset,spacing:spacing}=this.options;const halfAngle=(startAngle+endAngle)/2;const halfRadius=(innerRadius+outerRadius+spacing+offset)/2;return{x:x+Math.cos(halfAngle)*halfRadius,y:y+Math.sin(halfAngle)*halfRadius}}tooltipPosition(useFinalPosition){return this.getCenterPoint(useFinalPosition)}draw(ctx){const{options:options,circumference:circumference}=this;const offset=(options.offset||0)/4;const spacing=(options.spacing||0)/2;const circular=options.circular;this.pixelMargin=options.borderAlign==="inner"?.33:0;this.fullCircles=circumference>TAU?Math.floor(circumference/TAU):0;if(circumference===0||this.innerRadius<0||this.outerRadius<0){return}ctx.save();const halfAngle=(this.startAngle+this.endAngle)/2;ctx.translate(Math.cos(halfAngle)*offset,Math.sin(halfAngle)*offset);const fix=1-Math.sin(Math.min(PI,circumference||0));const radiusOffset=offset*fix;ctx.fillStyle=options.backgroundColor;ctx.strokeStyle=options.borderColor;drawArc(ctx,this,radiusOffset,spacing,circular);drawBorder(ctx,this,radiusOffset,spacing,circular);ctx.restore()}}function setStyle(ctx,options,style=options){ctx.lineCap=valueOrDefault(style.borderCapStyle,options.borderCapStyle);ctx.setLineDash(valueOrDefault(style.borderDash,options.borderDash));ctx.lineDashOffset=valueOrDefault(style.borderDashOffset,options.borderDashOffset);ctx.lineJoin=valueOrDefault(style.borderJoinStyle,options.borderJoinStyle);ctx.lineWidth=valueOrDefault(style.borderWidth,options.borderWidth);ctx.strokeStyle=valueOrDefault(style.borderColor,options.borderColor)}function lineTo(ctx,previous,target){ctx.lineTo(target.x,target.y)}function getLineMethod(options){if(options.stepped){return _steppedLineTo}if(options.tension||options.cubicInterpolationMode==="monotone"){return _bezierCurveTo}return lineTo}function pathVars(points,segment,params={}){const count=points.length;const{start:paramsStart=0,end:paramsEnd=count-1}=params;const{start:segmentStart,end:segmentEnd}=segment;const start=Math.max(paramsStart,segmentStart);const end=Math.min(paramsEnd,segmentEnd);const outside=paramsStartsegmentEnd&¶msEnd>segmentEnd;return{count:count,start:start,loop:segment.loop,ilen:end(start+(reverse?ilen-index:index))%count;const drawX=()=>{if(minY!==maxY){ctx.lineTo(avgX,maxY);ctx.lineTo(avgX,minY);ctx.lineTo(avgX,lastY)}};if(move){point=points[pointIndex(0)];ctx.moveTo(point.x,point.y)}for(i=0;i<=ilen;++i){point=points[pointIndex(i)];if(point.skip){continue}const x=point.x;const y=point.y;const truncX=x|0;if(truncX===prevX){if(ymaxY){maxY=y}avgX=(countX*avgX+x)/++countX}else{drawX();ctx.lineTo(x,y);prevX=truncX;countX=0;minY=maxY=y}lastY=y}drawX()}function _getSegmentMethod(line){const opts=line.options;const borderDash=opts.borderDash&&opts.borderDash.length;const useFastPath=!line._decimated&&!line._loop&&!opts.tension&&opts.cubicInterpolationMode!=="monotone"&&!opts.stepped&&!borderDash;return useFastPath?fastPathSegment:pathSegment}function _getInterpolationMethod(options){if(options.stepped){return _steppedInterpolation}if(options.tension||options.cubicInterpolationMode==="monotone"){return _bezierInterpolation}return _pointInLine}function strokePathWithCache(ctx,line,start,count){let path=line._path;if(!path){path=line._path=new Path2D;if(line.path(path,start,count)){path.closePath()}}setStyle(ctx,line.options);ctx.stroke(path)}function strokePathDirect(ctx,line,start,count){const{segments:segments,options:options}=line;const segmentMethod=_getSegmentMethod(line);for(const segment of segments){setStyle(ctx,options,segment.style);ctx.beginPath();if(segmentMethod(ctx,line,segment,{start:start,end:start+count-1})){ctx.closePath()}ctx.stroke()}}const usePath2D=typeof Path2D==="function";function draw(ctx,line,start,count){if(usePath2D&&!line.options.segment){strokePathWithCache(ctx,line,start,count)}else{strokePathDirect(ctx,line,start,count)}}class LineElement extends Element{static id="line";static defaults={borderCapStyle:"butt",borderDash:[],borderDashOffset:0,borderJoinStyle:"miter",borderWidth:3,capBezierPoints:true,cubicInterpolationMode:"default",fill:false,spanGaps:false,stepped:false,tension:0};static defaultRoutes={backgroundColor:"backgroundColor",borderColor:"borderColor"};static descriptors={_scriptable:true,_indexable:name=>name!=="borderDash"&&name!=="fill"};constructor(cfg){super();this.animated=true;this.options=undefined;this._chart=undefined;this._loop=undefined;this._fullLoop=undefined;this._path=undefined;this._points=undefined;this._segments=undefined;this._decimated=false;this._pointsUpdated=false;this._datasetIndex=undefined;if(cfg){Object.assign(this,cfg)}}updateControlPoints(chartArea,indexAxis){const options=this.options;if((options.tension||options.cubicInterpolationMode==="monotone")&&!options.stepped&&!this._pointsUpdated){const loop=options.spanGaps?this._loop:this._fullLoop;_updateBezierControlPoints(this._points,options,chartArea,loop,indexAxis);this._pointsUpdated=true}}set points(points){this._points=points;delete this._segments;delete this._path;this._pointsUpdated=false}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this,this.options.segment))}first(){const segments=this.segments;const points=this.points;return segments.length&&points[segments[0].start]}last(){const segments=this.segments;const points=this.points;const count=segments.length;return count&&points[segments[count-1].end]}interpolate(point,property){const options=this.options;const value=point[property];const points=this.points;const segments=_boundSegments(this,{property:property,start:value,end:value});if(!segments.length){return}const result=[];const _interpolate=_getInterpolationMethod(options);let i,ilen;for(i=0,ilen=segments.length;icolor.replace("rgb(","rgba(").replace(")",", 0.5)")));function getBorderColor(i){return BORDER_COLORS[i%BORDER_COLORS.length]}function getBackgroundColor(i){return BACKGROUND_COLORS[i%BACKGROUND_COLORS.length]}function colorizeDefaultDataset(dataset,i){dataset.borderColor=getBorderColor(i);dataset.backgroundColor=getBackgroundColor(i);return++i}function colorizeDoughnutDataset(dataset,i){dataset.backgroundColor=dataset.data.map((()=>getBorderColor(i++)));return i}function colorizePolarAreaDataset(dataset,i){dataset.backgroundColor=dataset.data.map((()=>getBackgroundColor(i++)));return i}function getColorizer(chart){let i=0;return(dataset,datasetIndex)=>{const controller=chart.getDatasetMeta(datasetIndex).controller;if(controller instanceof DoughnutController){i=colorizeDoughnutDataset(dataset,i)}else if(controller instanceof PolarAreaController){i=colorizePolarAreaDataset(dataset,i)}else if(controller){i=colorizeDefaultDataset(dataset,i)}}}function containsColorsDefinitions(descriptors){let k;for(k in descriptors){if(descriptors[k].borderColor||descriptors[k].backgroundColor){return true}}return false}function containsColorsDefinition(descriptor){return descriptor&&(descriptor.borderColor||descriptor.backgroundColor)}var plugin_colors={id:"colors",defaults:{enabled:true,forceOverride:false},beforeLayout(chart,_args,options){if(!options.enabled){return}const{data:{datasets:datasets},options:chartOptions}=chart.config;const{elements:elements}=chartOptions;if(!options.forceOverride&&(containsColorsDefinitions(datasets)||containsColorsDefinition(chartOptions)||elements&&containsColorsDefinitions(elements))){return}const colorizer=getColorizer(chart);datasets.forEach(colorizer)}};function lttbDecimation(data,start,count,availableWidth,options){const samples=options.samples||availableWidth;if(samples>=count){return data.slice(start,start+count)}const decimated=[];const bucketWidth=(count-2)/(samples-2);let sampledIndex=0;const endIndex=start+count-1;let a=start;let i,maxAreaPoint,maxArea,area,nextA;decimated[sampledIndex++]=data[a];for(i=0;imaxArea){maxArea=area;maxAreaPoint=data[j];nextA=j}}decimated[sampledIndex++]=maxAreaPoint;a=nextA}decimated[sampledIndex++]=data[endIndex];return decimated}function minMaxDecimation(data,start,count,availableWidth){let avgX=0;let countX=0;let i,point,x,y,prevX,minIndex,maxIndex,startIndex,minY,maxY;const decimated=[];const endIndex=start+count-1;const xMin=data[start].x;const xMax=data[endIndex].x;const dx=xMax-xMin;for(i=start;imaxY){maxY=y;maxIndex=i}avgX=(countX*avgX+point.x)/++countX}else{const lastIndex=i-1;if(!isNullOrUndef(minIndex)&&!isNullOrUndef(maxIndex)){const intermediateIndex1=Math.min(minIndex,maxIndex);const intermediateIndex2=Math.max(minIndex,maxIndex);if(intermediateIndex1!==startIndex&&intermediateIndex1!==lastIndex){decimated.push({...data[intermediateIndex1],x:avgX})}if(intermediateIndex2!==startIndex&&intermediateIndex2!==lastIndex){decimated.push({...data[intermediateIndex2],x:avgX})}}if(i>0&&lastIndex!==startIndex){decimated.push(data[lastIndex])}decimated.push(point);prevX=truncX;countX=0;minY=maxY=y;minIndex=maxIndex=startIndex=i}}return decimated}function cleanDecimatedDataset(dataset){if(dataset._decimated){const data=dataset._data;delete dataset._decimated;delete dataset._data;Object.defineProperty(dataset,"data",{configurable:true,enumerable:true,writable:true,value:data})}}function cleanDecimatedData(chart){chart.data.datasets.forEach((dataset=>{cleanDecimatedDataset(dataset)}))}function getStartAndCountOfVisiblePointsSimplified(meta,points){const pointCount=points.length;let start=0;let count;const{iScale:iScale}=meta;const{min:min,max:max,minDefined:minDefined,maxDefined:maxDefined}=iScale.getUserBounds();if(minDefined){start=_limitValue(_lookupByKey(points,iScale.axis,min).lo,0,pointCount-1)}if(maxDefined){count=_limitValue(_lookupByKey(points,iScale.axis,max).hi+1,start,pointCount)-start}else{count=pointCount-start}return{start:start,count:count}}var plugin_decimation={id:"decimation",defaults:{algorithm:"min-max",enabled:false},beforeElementsUpdate:(chart,args,options)=>{if(!options.enabled){cleanDecimatedData(chart);return}const availableWidth=chart.width;chart.data.datasets.forEach(((dataset,datasetIndex)=>{const{_data:_data,indexAxis:indexAxis}=dataset;const meta=chart.getDatasetMeta(datasetIndex);const data=_data||dataset.data;if(resolve([indexAxis,chart.options.indexAxis])==="y"){return}if(!meta.controller.supportsDecimation){return}const xAxis=chart.scales[meta.xAxisID];if(xAxis.type!=="linear"&&xAxis.type!=="time"){return}if(chart.options.parsing){return}let{start:start,count:count}=getStartAndCountOfVisiblePointsSimplified(meta,data);const threshold=options.threshold||4*availableWidth;if(count<=threshold){cleanDecimatedDataset(dataset);return}if(isNullOrUndef(_data)){dataset._data=data;delete dataset.data;Object.defineProperty(dataset,"data",{configurable:true,enumerable:true,get:function(){return this._decimated},set:function(d){this._data=d}})}let decimated;switch(options.algorithm){case"lttb":decimated=lttbDecimation(data,start,count,availableWidth,options);break;case"min-max":decimated=minMaxDecimation(data,start,count,availableWidth);break;default:throw new Error(`Unsupported decimation algorithm '${options.algorithm}'`)}dataset._decimated=decimated}))},destroy(chart){cleanDecimatedData(chart)}};function _segments(line,target,property){const segments=line.segments;const points=line.points;const tpoints=target.points;const parts=[];for(const segment of segments){let{start:start,end:end}=segment;end=_findSegmentEnd(start,end,points);const bounds=_getBounds(property,points[start],points[end],segment.loop);if(!target.segments){parts.push({source:segment,target:bounds,start:points[start],end:points[end]});continue}const targetSegments=_boundSegments(target,bounds);for(const tgt of targetSegments){const subBounds=_getBounds(property,tpoints[tgt.start],tpoints[tgt.end],tgt.loop);const fillSources=_boundSegment(segment,points,subBounds);for(const fillSource of fillSources){parts.push({source:fillSource,target:tgt,start:{[property]:_getEdge(bounds,subBounds,"start",Math.max)},end:{[property]:_getEdge(bounds,subBounds,"end",Math.min)}})}}}return parts}function _getBounds(property,first,last,loop){if(loop){return}let start=first[property];let end=last[property];if(property==="angle"){start=_normalizeAngle(start);end=_normalizeAngle(end)}return{property:property,start:start,end:end}}function _pointsFromSegments(boundary,line){const{x:x=null,y:y=null}=boundary||{};const linePoints=line.points;const points=[];line.segments.forEach((({start:start,end:end})=>{end=_findSegmentEnd(start,end,linePoints);const first=linePoints[start];const last=linePoints[end];if(y!==null){points.push({x:first.x,y:y});points.push({x:last.x,y:y})}else if(x!==null){points.push({x:x,y:first.y});points.push({x:x,y:last.y})}}));return points}function _findSegmentEnd(start,end,points){for(;end>start;end--){const point=points[end];if(!isNaN(point.x)&&!isNaN(point.y)){break}}return end}function _getEdge(a,b,prop,fn){if(a&&b){return fn(a[prop],b[prop])}return a?a[prop]:b?b[prop]:0}function _createBoundaryLine(boundary,line){let points=[];let _loop=false;if(isArray(boundary)){_loop=true;points=boundary}else{points=_pointsFromSegments(boundary,line)}return points.length?new LineElement({points:points,options:{tension:0},_loop:_loop,_fullLoop:_loop}):null}function _shouldApplyFill(source){return source&&source.fill!==false}function _resolveTarget(sources,index,propagate){const source=sources[index];let fill=source.fill;const visited=[index];let target;if(!propagate){return fill}while(fill!==false&&visited.indexOf(fill)===-1){if(!isNumberFinite(fill)){return fill}target=sources[fill];if(!target){return false}if(target.visible){return fill}visited.push(fill);fill=target.fill}return false}function _decodeFill(line,index,count){const fill=parseFillOption(line);if(isObject(fill)){return isNaN(fill.value)?false:fill}let target=parseFloat(fill);if(isNumberFinite(target)&&Math.floor(target)===target){return decodeTargetIndex(fill[0],index,target,count)}return["origin","start","end","stack","shape"].indexOf(fill)>=0&&fill}function decodeTargetIndex(firstCh,index,target,count){if(firstCh==="-"||firstCh==="+"){target=index+target}if(target===index||target<0||target>=count){return false}return target}function _getTargetPixel(fill,scale){let pixel=null;if(fill==="start"){pixel=scale.bottom}else if(fill==="end"){pixel=scale.top}else if(isObject(fill)){pixel=scale.getPixelForValue(fill.value)}else if(scale.getBasePixel){pixel=scale.getBasePixel()}return pixel}function _getTargetValue(fill,scale,startValue){let value;if(fill==="start"){value=startValue}else if(fill==="end"){value=scale.options.reverse?scale.min:scale.max}else if(isObject(fill)){value=fill.value}else{value=scale.getBaseValue()}return value}function parseFillOption(line){const options=line.options;const fillOption=options.fill;let fill=valueOrDefault(fillOption&&fillOption.target,fillOption);if(fill===undefined){fill=!!options.backgroundColor}if(fill===false||fill===null){return false}if(fill===true){return"origin"}return fill}function _buildStackLine(source){const{scale:scale,index:index,line:line}=source;const points=[];const segments=line.segments;const sourcePoints=line.points;const linesBelow=getLinesBelow(scale,index);linesBelow.push(_createBoundaryLine({x:null,y:scale.bottom},line));for(let i=0;i=0;--i){const source=metasets[i].$filler;if(!source){continue}source.line.updateControlPoints(area,source.axis);if(draw&&source.fill){_drawfill(chart.ctx,source,area)}}},beforeDatasetsDraw(chart,_args,options){if(options.drawTime!=="beforeDatasetsDraw"){return}const metasets=chart.getSortedVisibleDatasetMetas();for(let i=metasets.length-1;i>=0;--i){const source=metasets[i].$filler;if(_shouldApplyFill(source)){_drawfill(chart.ctx,source,chart.chartArea)}}},beforeDatasetDraw(chart,args,options){const source=args.meta.$filler;if(!_shouldApplyFill(source)||options.drawTime!=="beforeDatasetDraw"){return}_drawfill(chart.ctx,source,chart.chartArea)},defaults:{propagate:true,drawTime:"beforeDatasetDraw"}};const getBoxSize=(labelOpts,fontSize)=>{let{boxHeight:boxHeight=fontSize,boxWidth:boxWidth=fontSize}=labelOpts;if(labelOpts.usePointStyle){boxHeight=Math.min(boxHeight,fontSize);boxWidth=labelOpts.pointStyleWidth||Math.min(boxWidth,fontSize)}return{boxWidth:boxWidth,boxHeight:boxHeight,itemHeight:Math.max(fontSize,boxHeight)}};const itemsEqual=(a,b)=>a!==null&&b!==null&&a.datasetIndex===b.datasetIndex&&a.index===b.index;class Legend extends Element{constructor(config){super();this._added=false;this.legendHitBoxes=[];this._hoveredItem=null;this.doughnutMode=false;this.chart=config.chart;this.options=config.options;this.ctx=config.ctx;this.legendItems=undefined;this.columnSizes=undefined;this.lineWidths=undefined;this.maxHeight=undefined;this.maxWidth=undefined;this.top=undefined;this.bottom=undefined;this.left=undefined;this.right=undefined;this.height=undefined;this.width=undefined;this._margins=undefined;this.position=undefined;this.weight=undefined;this.fullSize=undefined}update(maxWidth,maxHeight,margins){this.maxWidth=maxWidth;this.maxHeight=maxHeight;this._margins=margins;this.setDimensions();this.buildLabels();this.fit()}setDimensions(){if(this.isHorizontal()){this.width=this.maxWidth;this.left=this._margins.left;this.right=this.width}else{this.height=this.maxHeight;this.top=this._margins.top;this.bottom=this.height}}buildLabels(){const labelOpts=this.options.labels||{};let legendItems=callback(labelOpts.generateLabels,[this.chart],this)||[];if(labelOpts.filter){legendItems=legendItems.filter((item=>labelOpts.filter(item,this.chart.data)))}if(labelOpts.sort){legendItems=legendItems.sort(((a,b)=>labelOpts.sort(a,b,this.chart.data)))}if(this.options.reverse){legendItems.reverse()}this.legendItems=legendItems}fit(){const{options:options,ctx:ctx}=this;if(!options.display){this.width=this.height=0;return}const labelOpts=options.labels;const labelFont=toFont(labelOpts.font);const fontSize=labelFont.size;const titleHeight=this._computeTitleHeight();const{boxWidth:boxWidth,itemHeight:itemHeight}=getBoxSize(labelOpts,fontSize);let width,height;ctx.font=labelFont.string;if(this.isHorizontal()){width=this.maxWidth;height=this._fitRows(titleHeight,fontSize,boxWidth,itemHeight)+10}else{height=this.maxHeight;width=this._fitCols(titleHeight,labelFont,boxWidth,itemHeight)+10}this.width=Math.min(width,options.maxWidth||this.maxWidth);this.height=Math.min(height,options.maxHeight||this.maxHeight)}_fitRows(titleHeight,fontSize,boxWidth,itemHeight){const{ctx:ctx,maxWidth:maxWidth,options:{labels:{padding:padding}}}=this;const hitboxes=this.legendHitBoxes=[];const lineWidths=this.lineWidths=[0];const lineHeight=itemHeight+padding;let totalHeight=titleHeight;ctx.textAlign="left";ctx.textBaseline="middle";let row=-1;let top=-lineHeight;this.legendItems.forEach(((legendItem,i)=>{const itemWidth=boxWidth+fontSize/2+ctx.measureText(legendItem.text).width;if(i===0||lineWidths[lineWidths.length-1]+itemWidth+2*padding>maxWidth){totalHeight+=lineHeight;lineWidths[lineWidths.length-(i>0?0:1)]=0;top+=lineHeight;row++}hitboxes[i]={left:0,top:top,row:row,width:itemWidth,height:itemHeight};lineWidths[lineWidths.length-1]+=itemWidth+padding}));return totalHeight}_fitCols(titleHeight,labelFont,boxWidth,_itemHeight){const{ctx:ctx,maxHeight:maxHeight,options:{labels:{padding:padding}}}=this;const hitboxes=this.legendHitBoxes=[];const columnSizes=this.columnSizes=[];const heightLimit=maxHeight-titleHeight;let totalWidth=padding;let currentColWidth=0;let currentColHeight=0;let left=0;let col=0;this.legendItems.forEach(((legendItem,i)=>{const{itemWidth:itemWidth,itemHeight:itemHeight}=calculateItemSize(boxWidth,labelFont,ctx,legendItem,_itemHeight);if(i>0&¤tColHeight+itemHeight+2*padding>heightLimit){totalWidth+=currentColWidth+padding;columnSizes.push({width:currentColWidth,height:currentColHeight});left+=currentColWidth+padding;col++;currentColWidth=currentColHeight=0}hitboxes[i]={left:left,top:currentColHeight,col:col,width:itemWidth,height:itemHeight};currentColWidth=Math.max(currentColWidth,itemWidth);currentColHeight+=itemHeight+padding}));totalWidth+=currentColWidth;columnSizes.push({width:currentColWidth,height:currentColHeight});return totalWidth}adjustHitBoxes(){if(!this.options.display){return}const titleHeight=this._computeTitleHeight();const{legendHitBoxes:hitboxes,options:{align:align,labels:{padding:padding},rtl:rtl}}=this;const rtlHelper=getRtlAdapter(rtl,this.left,this.width);if(this.isHorizontal()){let row=0;let left=_alignStartEnd(align,this.left+padding,this.right-this.lineWidths[row]);for(const hitbox of hitboxes){if(row!==hitbox.row){row=hitbox.row;left=_alignStartEnd(align,this.left+padding,this.right-this.lineWidths[row])}hitbox.top+=this.top+titleHeight+padding;hitbox.left=rtlHelper.leftForLtr(rtlHelper.x(left),hitbox.width);left+=hitbox.width+padding}}else{let col=0;let top=_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-this.columnSizes[col].height);for(const hitbox of hitboxes){if(hitbox.col!==col){col=hitbox.col;top=_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-this.columnSizes[col].height)}hitbox.top=top;hitbox.left+=this.left+padding;hitbox.left=rtlHelper.leftForLtr(rtlHelper.x(hitbox.left),hitbox.width);top+=hitbox.height+padding}}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const ctx=this.ctx;clipArea(ctx,this);this._draw();unclipArea(ctx)}}_draw(){const{options:opts,columnSizes:columnSizes,lineWidths:lineWidths,ctx:ctx}=this;const{align:align,labels:labelOpts}=opts;const defaultColor=defaults.color;const rtlHelper=getRtlAdapter(opts.rtl,this.left,this.width);const labelFont=toFont(labelOpts.font);const{padding:padding}=labelOpts;const fontSize=labelFont.size;const halfFontSize=fontSize/2;let cursor;this.drawTitle();ctx.textAlign=rtlHelper.textAlign("left");ctx.textBaseline="middle";ctx.lineWidth=.5;ctx.font=labelFont.string;const{boxWidth:boxWidth,boxHeight:boxHeight,itemHeight:itemHeight}=getBoxSize(labelOpts,fontSize);const drawLegendBox=function(x,y,legendItem){if(isNaN(boxWidth)||boxWidth<=0||isNaN(boxHeight)||boxHeight<0){return}ctx.save();const lineWidth=valueOrDefault(legendItem.lineWidth,1);ctx.fillStyle=valueOrDefault(legendItem.fillStyle,defaultColor);ctx.lineCap=valueOrDefault(legendItem.lineCap,"butt");ctx.lineDashOffset=valueOrDefault(legendItem.lineDashOffset,0);ctx.lineJoin=valueOrDefault(legendItem.lineJoin,"miter");ctx.lineWidth=lineWidth;ctx.strokeStyle=valueOrDefault(legendItem.strokeStyle,defaultColor);ctx.setLineDash(valueOrDefault(legendItem.lineDash,[]));if(labelOpts.usePointStyle){const drawOptions={radius:boxHeight*Math.SQRT2/2,pointStyle:legendItem.pointStyle,rotation:legendItem.rotation,borderWidth:lineWidth};const centerX=rtlHelper.xPlus(x,boxWidth/2);const centerY=y+halfFontSize;drawPointLegend(ctx,drawOptions,centerX,centerY,labelOpts.pointStyleWidth&&boxWidth)}else{const yBoxTop=y+Math.max((fontSize-boxHeight)/2,0);const xBoxLeft=rtlHelper.leftForLtr(x,boxWidth);const borderRadius=toTRBLCorners(legendItem.borderRadius);ctx.beginPath();if(Object.values(borderRadius).some((v=>v!==0))){addRoundedRectPath(ctx,{x:xBoxLeft,y:yBoxTop,w:boxWidth,h:boxHeight,radius:borderRadius})}else{ctx.rect(xBoxLeft,yBoxTop,boxWidth,boxHeight)}ctx.fill();if(lineWidth!==0){ctx.stroke()}}ctx.restore()};const fillText=function(x,y,legendItem){renderText(ctx,legendItem.text,x,y+itemHeight/2,labelFont,{strikethrough:legendItem.hidden,textAlign:rtlHelper.textAlign(legendItem.textAlign)})};const isHorizontal=this.isHorizontal();const titleHeight=this._computeTitleHeight();if(isHorizontal){cursor={x:_alignStartEnd(align,this.left+padding,this.right-lineWidths[0]),y:this.top+padding+titleHeight,line:0}}else{cursor={x:this.left+padding,y:_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-columnSizes[0].height),line:0}}overrideTextDirection(this.ctx,opts.textDirection);const lineHeight=itemHeight+padding;this.legendItems.forEach(((legendItem,i)=>{ctx.strokeStyle=legendItem.fontColor;ctx.fillStyle=legendItem.fontColor;const textWidth=ctx.measureText(legendItem.text).width;const textAlign=rtlHelper.textAlign(legendItem.textAlign||(legendItem.textAlign=labelOpts.textAlign));const width=boxWidth+halfFontSize+textWidth;let x=cursor.x;let y=cursor.y;rtlHelper.setWidth(this.width);if(isHorizontal){if(i>0&&x+width+padding>this.right){y=cursor.y+=lineHeight;cursor.line++;x=cursor.x=_alignStartEnd(align,this.left+padding,this.right-lineWidths[cursor.line])}}else if(i>0&&y+lineHeight>this.bottom){x=cursor.x=x+columnSizes[cursor.line].width+padding;cursor.line++;y=cursor.y=_alignStartEnd(align,this.top+titleHeight+padding,this.bottom-columnSizes[cursor.line].height)}const realX=rtlHelper.x(x);drawLegendBox(realX,y,legendItem);x=_textX(textAlign,x+boxWidth+halfFontSize,isHorizontal?x+width:this.right,opts.rtl);fillText(rtlHelper.x(x),y,legendItem);if(isHorizontal){cursor.x+=width+padding}else if(typeof legendItem.text!=="string"){const fontLineHeight=labelFont.lineHeight;cursor.y+=calculateLegendItemHeight(legendItem,fontLineHeight)+padding}else{cursor.y+=lineHeight}}));restoreTextDirection(this.ctx,opts.textDirection)}drawTitle(){const opts=this.options;const titleOpts=opts.title;const titleFont=toFont(titleOpts.font);const titlePadding=toPadding(titleOpts.padding);if(!titleOpts.display){return}const rtlHelper=getRtlAdapter(opts.rtl,this.left,this.width);const ctx=this.ctx;const position=titleOpts.position;const halfFontSize=titleFont.size/2;const topPaddingPlusHalfFontSize=titlePadding.top+halfFontSize;let y;let left=this.left;let maxWidth=this.width;if(this.isHorizontal()){maxWidth=Math.max(...this.lineWidths);y=this.top+topPaddingPlusHalfFontSize;left=_alignStartEnd(opts.align,left,this.right-maxWidth)}else{const maxHeight=this.columnSizes.reduce(((acc,size)=>Math.max(acc,size.height)),0);y=topPaddingPlusHalfFontSize+_alignStartEnd(opts.align,this.top,this.bottom-maxHeight-opts.labels.padding-this._computeTitleHeight())}const x=_alignStartEnd(position,left,left+maxWidth);ctx.textAlign=rtlHelper.textAlign(_toLeftRightCenter(position));ctx.textBaseline="middle";ctx.strokeStyle=titleOpts.color;ctx.fillStyle=titleOpts.color;ctx.font=titleFont.string;renderText(ctx,titleOpts.text,x,y,titleFont)}_computeTitleHeight(){const titleOpts=this.options.title;const titleFont=toFont(titleOpts.font);const titlePadding=toPadding(titleOpts.padding);return titleOpts.display?titleFont.lineHeight+titlePadding.height:0}_getLegendItemAt(x,y){let i,hitBox,lh;if(_isBetween(x,this.left,this.right)&&_isBetween(y,this.top,this.bottom)){lh=this.legendHitBoxes;for(i=0;ia.length>b.length?a:b))}return boxWidth+labelFont.size/2+ctx.measureText(legendItemText).width}function calculateItemHeight(_itemHeight,legendItem,fontLineHeight){let itemHeight=_itemHeight;if(typeof legendItem.text!=="string"){itemHeight=calculateLegendItemHeight(legendItem,fontLineHeight)}return itemHeight}function calculateLegendItemHeight(legendItem,fontLineHeight){const labelHeight=legendItem.text?legendItem.text.length:0;return fontLineHeight*labelHeight}function isListened(type,opts){if((type==="mousemove"||type==="mouseout")&&(opts.onHover||opts.onLeave)){return true}if(opts.onClick&&(type==="click"||type==="mouseup")){return true}return false}var plugin_legend={id:"legend",_element:Legend,start(chart,_args,options){const legend=chart.legend=new Legend({ctx:chart.ctx,options:options,chart:chart});layouts.configure(chart,legend,options);layouts.addBox(chart,legend)},stop(chart){layouts.removeBox(chart,chart.legend);delete chart.legend},beforeUpdate(chart,_args,options){const legend=chart.legend;layouts.configure(chart,legend,options);legend.options=options},afterUpdate(chart){const legend=chart.legend;legend.buildLabels();legend.adjustHitBoxes()},afterEvent(chart,args){if(!args.replay){chart.legend.handleEvent(args.event)}},defaults:{display:true,position:"top",align:"center",fullSize:true,reverse:false,weight:1e3,onClick(e,legendItem,legend){const index=legendItem.datasetIndex;const ci=legend.chart;if(ci.isDatasetVisible(index)){ci.hide(index);legendItem.hidden=true}else{ci.show(index);legendItem.hidden=false}},onHover:null,onLeave:null,labels:{color:ctx=>ctx.chart.options.color,boxWidth:40,padding:10,generateLabels(chart){const datasets=chart.data.datasets;const{labels:{usePointStyle:usePointStyle,pointStyle:pointStyle,textAlign:textAlign,color:color,useBorderRadius:useBorderRadius,borderRadius:borderRadius}}=chart.legend.options;return chart._getSortedDatasetMetas().map((meta=>{const style=meta.controller.getStyle(usePointStyle?0:undefined);const borderWidth=toPadding(style.borderWidth);return{text:datasets[meta.index].label,fillStyle:style.backgroundColor,fontColor:color,hidden:!meta.visible,lineCap:style.borderCapStyle,lineDash:style.borderDash,lineDashOffset:style.borderDashOffset,lineJoin:style.borderJoinStyle,lineWidth:(borderWidth.width+borderWidth.height)/4,strokeStyle:style.borderColor,pointStyle:pointStyle||style.pointStyle,rotation:style.rotation,textAlign:textAlign||style.textAlign,borderRadius:useBorderRadius&&(borderRadius||style.borderRadius),datasetIndex:meta.index}}),this)}},title:{color:ctx=>ctx.chart.options.color,display:false,position:"center",text:""}},descriptors:{_scriptable:name=>!name.startsWith("on"),labels:{_scriptable:name=>!["generateLabels","filter","sort"].includes(name)}}};class Title extends Element{constructor(config){super();this.chart=config.chart;this.options=config.options;this.ctx=config.ctx;this._padding=undefined;this.top=undefined;this.bottom=undefined;this.left=undefined;this.right=undefined;this.width=undefined;this.height=undefined;this.position=undefined;this.weight=undefined;this.fullSize=undefined}update(maxWidth,maxHeight){const opts=this.options;this.left=0;this.top=0;if(!opts.display){this.width=this.height=this.right=this.bottom=0;return}this.width=this.right=maxWidth;this.height=this.bottom=maxHeight;const lineCount=isArray(opts.text)?opts.text.length:1;this._padding=toPadding(opts.padding);const textSize=lineCount*toFont(opts.font).lineHeight+this._padding.height;if(this.isHorizontal()){this.height=textSize}else{this.width=textSize}}isHorizontal(){const pos=this.options.position;return pos==="top"||pos==="bottom"}_drawArgs(offset){const{top:top,left:left,bottom:bottom,right:right,options:options}=this;const align=options.align;let rotation=0;let maxWidth,titleX,titleY;if(this.isHorizontal()){titleX=_alignStartEnd(align,left,right);titleY=top+offset;maxWidth=right-left}else{if(options.position==="left"){titleX=left+offset;titleY=_alignStartEnd(align,bottom,top);rotation=PI*-.5}else{titleX=right-offset;titleY=_alignStartEnd(align,top,bottom);rotation=PI*.5}maxWidth=bottom-top}return{titleX:titleX,titleY:titleY,maxWidth:maxWidth,rotation:rotation}}draw(){const ctx=this.ctx;const opts=this.options;if(!opts.display){return}const fontOpts=toFont(opts.font);const lineHeight=fontOpts.lineHeight;const offset=lineHeight/2+this._padding.top;const{titleX:titleX,titleY:titleY,maxWidth:maxWidth,rotation:rotation}=this._drawArgs(offset);renderText(ctx,opts.text,0,0,fontOpts,{color:opts.color,maxWidth:maxWidth,rotation:rotation,textAlign:_toLeftRightCenter(opts.align),textBaseline:"middle",translation:[titleX,titleY]})}}function createTitle(chart,titleOpts){const title=new Title({ctx:chart.ctx,options:titleOpts,chart:chart});layouts.configure(chart,title,titleOpts);layouts.addBox(chart,title);chart.titleBlock=title}var plugin_title={id:"title",_element:Title,start(chart,_args,options){createTitle(chart,options)},stop(chart){const titleBlock=chart.titleBlock;layouts.removeBox(chart,titleBlock);delete chart.titleBlock},beforeUpdate(chart,_args,options){const title=chart.titleBlock;layouts.configure(chart,title,options);title.options=options},defaults:{align:"center",display:false,font:{weight:"bold"},fullSize:true,padding:10,position:"top",text:"",weight:2e3},defaultRoutes:{color:"color"},descriptors:{_scriptable:true,_indexable:false}};const map=new WeakMap;var plugin_subtitle={id:"subtitle",start(chart,_args,options){const title=new Title({ctx:chart.ctx,options:options,chart:chart});layouts.configure(chart,title,options);layouts.addBox(chart,title);map.set(chart,title)},stop(chart){layouts.removeBox(chart,map.get(chart));map.delete(chart)},beforeUpdate(chart,_args,options){const title=map.get(chart);layouts.configure(chart,title,options);title.options=options},defaults:{align:"center",display:false,font:{weight:"normal"},fullSize:true,padding:0,position:"top",text:"",weight:1500},defaultRoutes:{color:"color"},descriptors:{_scriptable:true,_indexable:false}};const positioners={average(items){if(!items.length){return false}let i,len;let xSet=new Set;let y=0;let count=0;for(i=0,len=items.length;ia+b))/xSet.size;return{x:xAverage,y:y/count}},nearest(items,eventPosition){if(!items.length){return false}let x=eventPosition.x;let y=eventPosition.y;let minDistance=Number.POSITIVE_INFINITY;let i,len,nearestElement;for(i=0,len=items.length;i-1){return str.split("\n")}return str}function createTooltipItem(chart,item){const{element:element,datasetIndex:datasetIndex,index:index}=item;const controller=chart.getDatasetMeta(datasetIndex).controller;const{label:label,value:value}=controller.getLabelAndValue(index);return{chart:chart,label:label,parsed:controller.getParsed(index),raw:chart.data.datasets[datasetIndex].data[index],formattedValue:value,dataset:controller.getDataset(),dataIndex:index,datasetIndex:datasetIndex,element:element}}function getTooltipSize(tooltip,options){const ctx=tooltip.chart.ctx;const{body:body,footer:footer,title:title}=tooltip;const{boxWidth:boxWidth,boxHeight:boxHeight}=options;const bodyFont=toFont(options.bodyFont);const titleFont=toFont(options.titleFont);const footerFont=toFont(options.footerFont);const titleLineCount=title.length;const footerLineCount=footer.length;const bodyLineItemCount=body.length;const padding=toPadding(options.padding);let height=padding.height;let width=0;let combinedBodyLength=body.reduce(((count,bodyItem)=>count+bodyItem.before.length+bodyItem.lines.length+bodyItem.after.length),0);combinedBodyLength+=tooltip.beforeBody.length+tooltip.afterBody.length;if(titleLineCount){height+=titleLineCount*titleFont.lineHeight+(titleLineCount-1)*options.titleSpacing+options.titleMarginBottom}if(combinedBodyLength){const bodyLineHeight=options.displayColors?Math.max(boxHeight,bodyFont.lineHeight):bodyFont.lineHeight;height+=bodyLineItemCount*bodyLineHeight+(combinedBodyLength-bodyLineItemCount)*bodyFont.lineHeight+(combinedBodyLength-1)*options.bodySpacing}if(footerLineCount){height+=options.footerMarginTop+footerLineCount*footerFont.lineHeight+(footerLineCount-1)*options.footerSpacing}let widthPadding=0;const maxLineWidth=function(line){width=Math.max(width,ctx.measureText(line).width+widthPadding)};ctx.save();ctx.font=titleFont.string;each(tooltip.title,maxLineWidth);ctx.font=bodyFont.string;each(tooltip.beforeBody.concat(tooltip.afterBody),maxLineWidth);widthPadding=options.displayColors?boxWidth+2+options.boxPadding:0;each(body,(bodyItem=>{each(bodyItem.before,maxLineWidth);each(bodyItem.lines,maxLineWidth);each(bodyItem.after,maxLineWidth)}));widthPadding=0;ctx.font=footerFont.string;each(tooltip.footer,maxLineWidth);ctx.restore();width+=padding.width;return{width:width,height:height}}function determineYAlign(chart,size){const{y:y,height:height}=size;if(ychart.height-height/2){return"bottom"}return"center"}function doesNotFitWithAlign(xAlign,chart,options,size){const{x:x,width:width}=size;const caret=options.caretSize+options.caretPadding;if(xAlign==="left"&&x+width+caret>chart.width){return true}if(xAlign==="right"&&x-width-caret<0){return true}}function determineXAlign(chart,options,size,yAlign){const{x:x,width:width}=size;const{width:chartWidth,chartArea:{left:left,right:right}}=chart;let xAlign="center";if(yAlign==="center"){xAlign=x<=(left+right)/2?"left":"right"}else if(x<=width/2){xAlign="left"}else if(x>=chartWidth-width/2){xAlign="right"}if(doesNotFitWithAlign(xAlign,chart,options,size)){xAlign="center"}return xAlign}function determineAlignment(chart,options,size){const yAlign=size.yAlign||options.yAlign||determineYAlign(chart,size);return{xAlign:size.xAlign||options.xAlign||determineXAlign(chart,options,size,yAlign),yAlign:yAlign}}function alignX(size,xAlign){let{x:x,width:width}=size;if(xAlign==="right"){x-=width}else if(xAlign==="center"){x-=width/2}return x}function alignY(size,yAlign,paddingAndSize){let{y:y,height:height}=size;if(yAlign==="top"){y+=paddingAndSize}else if(yAlign==="bottom"){y-=height+paddingAndSize}else{y-=height/2}return y}function getBackgroundPoint(options,size,alignment,chart){const{caretSize:caretSize,caretPadding:caretPadding,cornerRadius:cornerRadius}=options;const{xAlign:xAlign,yAlign:yAlign}=alignment;const paddingAndSize=caretSize+caretPadding;const{topLeft:topLeft,topRight:topRight,bottomLeft:bottomLeft,bottomRight:bottomRight}=toTRBLCorners(cornerRadius);let x=alignX(size,xAlign);const y=alignY(size,yAlign,paddingAndSize);if(yAlign==="center"){if(xAlign==="left"){x+=paddingAndSize}else if(xAlign==="right"){x-=paddingAndSize}}else if(xAlign==="left"){x-=Math.max(topLeft,bottomLeft)+caretSize}else if(xAlign==="right"){x+=Math.max(topRight,bottomRight)+caretSize}return{x:_limitValue(x,0,chart.width-size.width),y:_limitValue(y,0,chart.height-size.height)}}function getAlignedX(tooltip,align,options){const padding=toPadding(options.padding);return align==="center"?tooltip.x+tooltip.width/2:align==="right"?tooltip.x+tooltip.width-padding.right:tooltip.x+padding.left}function getBeforeAfterBodyLines(callback){return pushOrConcat([],splitNewlines(callback))}function createTooltipContext(parent,tooltip,tooltipItems){return createContext(parent,{tooltip:tooltip,tooltipItems:tooltipItems,type:"tooltip"})}function overrideCallbacks(callbacks,context){const override=context&&context.dataset&&context.dataset.tooltip&&context.dataset.tooltip.callbacks;return override?callbacks.override(override):callbacks}const defaultCallbacks={beforeTitle:noop,title(tooltipItems){if(tooltipItems.length>0){const item=tooltipItems[0];const labels=item.chart.data.labels;const labelCount=labels?labels.length:0;if(this&&this.options&&this.options.mode==="dataset"){return item.dataset.label||""}else if(item.label){return item.label}else if(labelCount>0&&item.dataIndex{const bodyItem={before:[],lines:[],after:[]};const scoped=overrideCallbacks(callbacks,context);pushOrConcat(bodyItem.before,splitNewlines(invokeCallbackWithFallback(scoped,"beforeLabel",this,context)));pushOrConcat(bodyItem.lines,invokeCallbackWithFallback(scoped,"label",this,context));pushOrConcat(bodyItem.after,splitNewlines(invokeCallbackWithFallback(scoped,"afterLabel",this,context)));bodyItems.push(bodyItem)}));return bodyItems}getAfterBody(tooltipItems,options){return getBeforeAfterBodyLines(invokeCallbackWithFallback(options.callbacks,"afterBody",this,tooltipItems))}getFooter(tooltipItems,options){const{callbacks:callbacks}=options;const beforeFooter=invokeCallbackWithFallback(callbacks,"beforeFooter",this,tooltipItems);const footer=invokeCallbackWithFallback(callbacks,"footer",this,tooltipItems);const afterFooter=invokeCallbackWithFallback(callbacks,"afterFooter",this,tooltipItems);let lines=[];lines=pushOrConcat(lines,splitNewlines(beforeFooter));lines=pushOrConcat(lines,splitNewlines(footer));lines=pushOrConcat(lines,splitNewlines(afterFooter));return lines}_createItems(options){const active=this._active;const data=this.chart.data;const labelColors=[];const labelPointStyles=[];const labelTextColors=[];let tooltipItems=[];let i,len;for(i=0,len=active.length;ioptions.filter(element,index,array,data)))}if(options.itemSort){tooltipItems=tooltipItems.sort(((a,b)=>options.itemSort(a,b,data)))}each(tooltipItems,(context=>{const scoped=overrideCallbacks(options.callbacks,context);labelColors.push(invokeCallbackWithFallback(scoped,"labelColor",this,context));labelPointStyles.push(invokeCallbackWithFallback(scoped,"labelPointStyle",this,context));labelTextColors.push(invokeCallbackWithFallback(scoped,"labelTextColor",this,context))}));this.labelColors=labelColors;this.labelPointStyles=labelPointStyles;this.labelTextColors=labelTextColors;this.dataPoints=tooltipItems;return tooltipItems}update(changed,replay){const options=this.options.setContext(this.getContext());const active=this._active;let properties;let tooltipItems=[];if(!active.length){if(this.opacity!==0){properties={opacity:0}}}else{const position=positioners[options.position].call(this,active,this._eventPosition);tooltipItems=this._createItems(options);this.title=this.getTitle(tooltipItems,options);this.beforeBody=this.getBeforeBody(tooltipItems,options);this.body=this.getBody(tooltipItems,options);this.afterBody=this.getAfterBody(tooltipItems,options);this.footer=this.getFooter(tooltipItems,options);const size=this._size=getTooltipSize(this,options);const positionAndSize=Object.assign({},position,size);const alignment=determineAlignment(this.chart,options,positionAndSize);const backgroundPoint=getBackgroundPoint(options,positionAndSize,alignment,this.chart);this.xAlign=alignment.xAlign;this.yAlign=alignment.yAlign;properties={opacity:1,x:backgroundPoint.x,y:backgroundPoint.y,width:size.width,height:size.height,caretX:position.x,caretY:position.y}}this._tooltipItems=tooltipItems;this.$context=undefined;if(properties){this._resolveAnimations().update(this,properties)}if(changed&&options.external){options.external.call(this,{chart:this.chart,tooltip:this,replay:replay})}}drawCaret(tooltipPoint,ctx,size,options){const caretPosition=this.getCaretPosition(tooltipPoint,size,options);ctx.lineTo(caretPosition.x1,caretPosition.y1);ctx.lineTo(caretPosition.x2,caretPosition.y2);ctx.lineTo(caretPosition.x3,caretPosition.y3)}getCaretPosition(tooltipPoint,size,options){const{xAlign:xAlign,yAlign:yAlign}=this;const{caretSize:caretSize,cornerRadius:cornerRadius}=options;const{topLeft:topLeft,topRight:topRight,bottomLeft:bottomLeft,bottomRight:bottomRight}=toTRBLCorners(cornerRadius);const{x:ptX,y:ptY}=tooltipPoint;const{width:width,height:height}=size;let x1,x2,x3,y1,y2,y3;if(yAlign==="center"){y2=ptY+height/2;if(xAlign==="left"){x1=ptX;x2=x1-caretSize;y1=y2+caretSize;y3=y2-caretSize}else{x1=ptX+width;x2=x1+caretSize;y1=y2-caretSize;y3=y2+caretSize}x3=x1}else{if(xAlign==="left"){x2=ptX+Math.max(topLeft,bottomLeft)+caretSize}else if(xAlign==="right"){x2=ptX+width-Math.max(topRight,bottomRight)-caretSize}else{x2=this.caretX}if(yAlign==="top"){y1=ptY;y2=y1-caretSize;x1=x2-caretSize;x3=x2+caretSize}else{y1=ptY+height;y2=y1+caretSize;x1=x2+caretSize;x3=x2-caretSize}y3=y1}return{x1:x1,x2:x2,x3:x3,y1:y1,y2:y2,y3:y3}}drawTitle(pt,ctx,options){const title=this.title;const length=title.length;let titleFont,titleSpacing,i;if(length){const rtlHelper=getRtlAdapter(options.rtl,this.x,this.width);pt.x=getAlignedX(this,options.titleAlign,options);ctx.textAlign=rtlHelper.textAlign(options.titleAlign);ctx.textBaseline="middle";titleFont=toFont(options.titleFont);titleSpacing=options.titleSpacing;ctx.fillStyle=options.titleColor;ctx.font=titleFont.string;for(i=0;iv!==0))){ctx.beginPath();ctx.fillStyle=options.multiKeyBackground;addRoundedRectPath(ctx,{x:outerX,y:colorY,w:boxWidth,h:boxHeight,radius:borderRadius});ctx.fill();ctx.stroke();ctx.fillStyle=labelColor.backgroundColor;ctx.beginPath();addRoundedRectPath(ctx,{x:innerX,y:colorY+1,w:boxWidth-2,h:boxHeight-2,radius:borderRadius});ctx.fill()}else{ctx.fillStyle=options.multiKeyBackground;ctx.fillRect(outerX,colorY,boxWidth,boxHeight);ctx.strokeRect(outerX,colorY,boxWidth,boxHeight);ctx.fillStyle=labelColor.backgroundColor;ctx.fillRect(innerX,colorY+1,boxWidth-2,boxHeight-2)}}ctx.fillStyle=this.labelTextColors[i]}drawBody(pt,ctx,options){const{body:body}=this;const{bodySpacing:bodySpacing,bodyAlign:bodyAlign,displayColors:displayColors,boxHeight:boxHeight,boxWidth:boxWidth,boxPadding:boxPadding}=options;const bodyFont=toFont(options.bodyFont);let bodyLineHeight=bodyFont.lineHeight;let xLinePadding=0;const rtlHelper=getRtlAdapter(options.rtl,this.x,this.width);const fillLineOfText=function(line){ctx.fillText(line,rtlHelper.x(pt.x+xLinePadding),pt.y+bodyLineHeight/2);pt.y+=bodyLineHeight+bodySpacing};const bodyAlignForCalculation=rtlHelper.textAlign(bodyAlign);let bodyItem,textColor,lines,i,j,ilen,jlen;ctx.textAlign=bodyAlign;ctx.textBaseline="middle";ctx.font=bodyFont.string;pt.x=getAlignedX(this,bodyAlignForCalculation,options);ctx.fillStyle=options.bodyColor;each(this.beforeBody,fillLineOfText);xLinePadding=displayColors&&bodyAlignForCalculation!=="right"?bodyAlign==="center"?boxWidth/2+boxPadding:boxWidth+2+boxPadding:0;for(i=0,ilen=body.length;i0){ctx.stroke()}}_updateAnimationTarget(options){const chart=this.chart;const anims=this.$animations;const animX=anims&&anims.x;const animY=anims&&anims.y;if(animX||animY){const position=positioners[options.position].call(this,this._active,this._eventPosition);if(!position){return}const size=this._size=getTooltipSize(this,options);const positionAndSize=Object.assign({},position,this._size);const alignment=determineAlignment(chart,options,positionAndSize);const point=getBackgroundPoint(options,positionAndSize,alignment,chart);if(animX._to!==point.x||animY._to!==point.y){this.xAlign=alignment.xAlign;this.yAlign=alignment.yAlign;this.width=size.width;this.height=size.height;this.caretX=position.x;this.caretY=position.y;this._resolveAnimations().update(this,point)}}}_willRender(){return!!this.opacity}draw(ctx){const options=this.options.setContext(this.getContext());let opacity=this.opacity;if(!opacity){return}this._updateAnimationTarget(options);const tooltipSize={width:this.width,height:this.height};const pt={x:this.x,y:this.y};opacity=Math.abs(opacity)<.001?0:opacity;const padding=toPadding(options.padding);const hasTooltipContent=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;if(options.enabled&&hasTooltipContent){ctx.save();ctx.globalAlpha=opacity;this.drawBackground(pt,ctx,tooltipSize,options);overrideTextDirection(ctx,options.textDirection);pt.y+=padding.top;this.drawTitle(pt,ctx,options);this.drawBody(pt,ctx,options);this.drawFooter(pt,ctx,options);restoreTextDirection(ctx,options.textDirection);ctx.restore()}}getActiveElements(){return this._active||[]}setActiveElements(activeElements,eventPosition){const lastActive=this._active;const active=activeElements.map((({datasetIndex:datasetIndex,index:index})=>{const meta=this.chart.getDatasetMeta(datasetIndex);if(!meta){throw new Error("Cannot find a dataset at index "+datasetIndex)}return{datasetIndex:datasetIndex,element:meta.data[index],index:index}}));const changed=!_elementsEqual(lastActive,active);const positionChanged=this._positionChanged(active,eventPosition);if(changed||positionChanged){this._active=active;this._eventPosition=eventPosition;this._ignoreReplayEvents=true;this.update(true)}}handleEvent(e,replay,inChartArea=true){if(replay&&this._ignoreReplayEvents){return false}this._ignoreReplayEvents=false;const options=this.options;const lastActive=this._active||[];const active=this._getActiveElements(e,lastActive,replay,inChartArea);const positionChanged=this._positionChanged(active,e);const changed=replay||!_elementsEqual(active,lastActive)||positionChanged;if(changed){this._active=active;if(options.enabled||options.external){this._eventPosition={x:e.x,y:e.y};this.update(true,replay)}}return changed}_getActiveElements(e,lastActive,replay,inChartArea){const options=this.options;if(e.type==="mouseout"){return[]}if(!inChartArea){return lastActive.filter((i=>this.chart.data.datasets[i.datasetIndex]&&this.chart.getDatasetMeta(i.datasetIndex).controller.getParsed(i.index)!==undefined))}const active=this.chart.getElementsAtEventForMode(e,options.mode,options,replay);if(options.reverse){active.reverse()}return active}_positionChanged(active,e){const{caretX:caretX,caretY:caretY,options:options}=this;const position=positioners[options.position].call(this,active,e);return position!==false&&(caretX!==position.x||caretY!==position.y)}}var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners:positioners,afterInit(chart,_args,options){if(options){chart.tooltip=new Tooltip({chart:chart,options:options})}},beforeUpdate(chart,_args,options){if(chart.tooltip){chart.tooltip.initialize(options)}},reset(chart,_args,options){if(chart.tooltip){chart.tooltip.initialize(options)}},afterDraw(chart){const tooltip=chart.tooltip;if(tooltip&&tooltip._willRender()){const args={tooltip:tooltip};if(chart.notifyPlugins("beforeTooltipDraw",{...args,cancelable:true})===false){return}tooltip.draw(chart.ctx);chart.notifyPlugins("afterTooltipDraw",args)}},afterEvent(chart,args){if(chart.tooltip){const useFinalPosition=args.replay;if(chart.tooltip.handleEvent(args.event,useFinalPosition,args.inChartArea)){args.changed=true}}},defaults:{enabled:true,external:null,position:"average",backgroundColor:"rgba(0,0,0,0.8)",titleColor:"#fff",titleFont:{weight:"bold"},titleSpacing:2,titleMarginBottom:6,titleAlign:"left",bodyColor:"#fff",bodySpacing:2,bodyFont:{},bodyAlign:"left",footerColor:"#fff",footerSpacing:2,footerMarginTop:6,footerFont:{weight:"bold"},footerAlign:"left",padding:6,caretPadding:2,caretSize:5,cornerRadius:6,boxHeight:(ctx,opts)=>opts.bodyFont.size,boxWidth:(ctx,opts)=>opts.bodyFont.size,multiKeyBackground:"#fff",displayColors:true,boxPadding:0,borderColor:"rgba(0,0,0,0)",borderWidth:0,animation:{duration:400,easing:"easeOutQuart"},animations:{numbers:{type:"number",properties:["x","y","width","height","caretX","caretY"]},opacity:{easing:"linear",duration:200}},callbacks:defaultCallbacks},defaultRoutes:{bodyFont:"font",footerFont:"font",titleFont:"font"},descriptors:{_scriptable:name=>name!=="filter"&&name!=="itemSort"&&name!=="external",_indexable:false,callbacks:{_scriptable:false,_indexable:false},animation:{_fallback:false},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};var plugins=Object.freeze({__proto__:null,Colors:plugin_colors,Decimation:plugin_decimation,Filler:index,Legend:plugin_legend,SubTitle:plugin_subtitle,Title:plugin_title,Tooltip:plugin_tooltip});const addIfString=(labels,raw,index,addedLabels)=>{if(typeof raw==="string"){index=labels.push(raw)-1;addedLabels.unshift({index:index,label:raw})}else if(isNaN(raw)){index=null}return index};function findOrAddLabel(labels,raw,index,addedLabels){const first=labels.indexOf(raw);if(first===-1){return addIfString(labels,raw,index,addedLabels)}const last=labels.lastIndexOf(raw);return first!==last?index:first}const validIndex=(index,max)=>index===null?null:_limitValue(Math.round(index),0,max);function _getLabelForValue(value){const labels=this.getLabels();if(value>=0&&valueticks.length-1){return null}return this.getPixelForValue(ticks[index].value)}getValueForPixel(pixel){return Math.round(this._startValue+this.getDecimalForPixel(pixel)*this._valueRange)}getBasePixel(){return this.bottom}}function generateTicks$1(generationOptions,dataRange){const ticks=[];const MIN_SPACING=1e-14;const{bounds:bounds,step:step,min:min,max:max,precision:precision,count:count,maxTicks:maxTicks,maxDigits:maxDigits,includeBounds:includeBounds}=generationOptions;const unit=step||1;const maxSpaces=maxTicks-1;const{min:rmin,max:rmax}=dataRange;const minDefined=!isNullOrUndef(min);const maxDefined=!isNullOrUndef(max);const countDefined=!isNullOrUndef(count);const minSpacing=(rmax-rmin)/(maxDigits+1);let spacing=niceNum((rmax-rmin)/maxSpaces/unit)*unit;let factor,niceMin,niceMax,numSpaces;if(spacingmaxSpaces){spacing=niceNum(numSpaces*spacing/maxSpaces/unit)*unit}if(!isNullOrUndef(precision)){factor=Math.pow(10,precision);spacing=Math.ceil(spacing*factor)/factor}if(bounds==="ticks"){niceMin=Math.floor(rmin/spacing)*spacing;niceMax=Math.ceil(rmax/spacing)*spacing}else{niceMin=rmin;niceMax=rmax}if(minDefined&&maxDefined&&step&&almostWhole((max-min)/step,spacing/1e3)){numSpaces=Math.round(Math.min((max-min)/spacing,maxTicks));spacing=(max-min)/numSpaces;niceMin=min;niceMax=max}else if(countDefined){niceMin=minDefined?min:niceMin;niceMax=maxDefined?max:niceMax;numSpaces=count-1;spacing=(niceMax-niceMin)/numSpaces}else{numSpaces=(niceMax-niceMin)/spacing;if(almostEquals(numSpaces,Math.round(numSpaces),spacing/1e3)){numSpaces=Math.round(numSpaces)}else{numSpaces=Math.ceil(numSpaces)}}const decimalPlaces=Math.max(_decimalPlaces(spacing),_decimalPlaces(niceMin));factor=Math.pow(10,isNullOrUndef(precision)?decimalPlaces:precision);niceMin=Math.round(niceMin*factor)/factor;niceMax=Math.round(niceMax*factor)/factor;let j=0;if(minDefined){if(includeBounds&&niceMin!==min){ticks.push({value:min});if(niceMinmax){break}ticks.push({value:tickValue})}if(maxDefined&&includeBounds&&niceMax!==max){if(ticks.length&&almostEquals(ticks[ticks.length-1].value,max,relativeLabelSize(max,minSpacing,generationOptions))){ticks[ticks.length-1].value=max}else{ticks.push({value:max})}}else if(!maxDefined||niceMax===max){ticks.push({value:niceMax})}return ticks}function relativeLabelSize(value,minSpacing,{horizontal:horizontal,minRotation:minRotation}){const rad=toRadians(minRotation);const ratio=(horizontal?Math.sin(rad):Math.cos(rad))||.001;const length=.75*minSpacing*(""+value).length;return Math.min(minSpacing/ratio,length)}class LinearScaleBase extends Scale{constructor(cfg){super(cfg);this.start=undefined;this.end=undefined;this._startValue=undefined;this._endValue=undefined;this._valueRange=0}parse(raw,index){if(isNullOrUndef(raw)){return null}if((typeof raw==="number"||raw instanceof Number)&&!isFinite(+raw)){return null}return+raw}handleTickRangeOptions(){const{beginAtZero:beginAtZero}=this.options;const{minDefined:minDefined,maxDefined:maxDefined}=this.getUserBounds();let{min:min,max:max}=this;const setMin=v=>min=minDefined?min:v;const setMax=v=>max=maxDefined?max:v;if(beginAtZero){const minSign=sign(min);const maxSign=sign(max);if(minSign<0&&maxSign<0){setMax(0)}else if(minSign>0&&maxSign>0){setMin(0)}}if(min===max){let offset=max===0?1:Math.abs(max*.05);setMax(max+offset);if(!beginAtZero){setMin(min-offset)}}this.min=min;this.max=max}getTickLimit(){const tickOpts=this.options.ticks;let{maxTicksLimit:maxTicksLimit,stepSize:stepSize}=tickOpts;let maxTicks;if(stepSize){maxTicks=Math.ceil(this.max/stepSize)-Math.floor(this.min/stepSize)+1;if(maxTicks>1e3){console.warn(`scales.${this.id}.ticks.stepSize: ${stepSize} would result generating up to ${maxTicks} ticks. Limiting to 1000.`);maxTicks=1e3}}else{maxTicks=this.computeTickLimit();maxTicksLimit=maxTicksLimit||11}if(maxTicksLimit){maxTicks=Math.min(maxTicksLimit,maxTicks)}return maxTicks}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const opts=this.options;const tickOpts=opts.ticks;let maxTicks=this.getTickLimit();maxTicks=Math.max(2,maxTicks);const numericGeneratorOptions={maxTicks:maxTicks,bounds:opts.bounds,min:opts.min,max:opts.max,precision:tickOpts.precision,step:tickOpts.stepSize,count:tickOpts.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:tickOpts.minRotation||0,includeBounds:tickOpts.includeBounds!==false};const dataRange=this._range||this;const ticks=generateTicks$1(numericGeneratorOptions,dataRange);if(opts.bounds==="ticks"){_setMinAndMaxByKey(ticks,this,"value")}if(opts.reverse){ticks.reverse();this.start=this.max;this.end=this.min}else{this.start=this.min;this.end=this.max}return ticks}configure(){const ticks=this.ticks;let start=this.min;let end=this.max;super.configure();if(this.options.offset&&ticks.length){const offset=(end-start)/Math.max(ticks.length-1,1)/2;start-=offset;end+=offset}this._startValue=start;this._endValue=end;this._valueRange=end-start}getLabelForValue(value){return formatNumber(value,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{static id="linear";static defaults={ticks:{callback:Ticks.formatters.numeric}};determineDataLimits(){const{min:min,max:max}=this.getMinMax(true);this.min=isNumberFinite(min)?min:0;this.max=isNumberFinite(max)?max:1;this.handleTickRangeOptions()}computeTickLimit(){const horizontal=this.isHorizontal();const length=horizontal?this.width:this.height;const minRotation=toRadians(this.options.ticks.minRotation);const ratio=(horizontal?Math.sin(minRotation):Math.cos(minRotation))||.001;const tickFont=this._resolveTickFontOptions(0);return Math.ceil(length/Math.min(40,tickFont.lineHeight/ratio))}getPixelForValue(value){return value===null?NaN:this.getPixelForDecimal((value-this._startValue)/this._valueRange)}getValueForPixel(pixel){return this._startValue+this.getDecimalForPixel(pixel)*this._valueRange}}const log10Floor=v=>Math.floor(log10(v));const changeExponent=(v,m)=>Math.pow(10,log10Floor(v)+m);function isMajor(tickVal){const remain=tickVal/Math.pow(10,log10Floor(tickVal));return remain===1}function steps(min,max,rangeExp){const rangeStep=Math.pow(10,rangeExp);const start=Math.floor(min/rangeStep);const end=Math.ceil(max/rangeStep);return end-start}function startExp(min,max){const range=max-min;let rangeExp=log10Floor(range);while(steps(min,max,rangeExp)>10){rangeExp++}while(steps(min,max,rangeExp)<10){rangeExp--}return Math.min(rangeExp,log10Floor(min))}function generateTicks(generationOptions,{min:min,max:max}){min=finiteOrDefault(generationOptions.min,min);const ticks=[];const minExp=log10Floor(min);let exp=startExp(min,max);let precision=exp<0?Math.pow(10,Math.abs(exp)):1;const stepSize=Math.pow(10,exp);const base=minExp>exp?Math.pow(10,minExp):0;const start=Math.round((min-base)*precision)/precision;const offset=Math.floor((min-base)/stepSize/10)*stepSize*10;let significand=Math.floor((start-offset)/Math.pow(10,exp));let value=finiteOrDefault(generationOptions.min,Math.round((base+offset+significand*Math.pow(10,exp))*precision)/precision);while(value=10){significand=significand<15?15:20}else{significand++}if(significand>=20){exp++;significand=2;precision=exp>=0?1:precision}value=Math.round((base+offset+significand*Math.pow(10,exp))*precision)/precision}const lastTick=finiteOrDefault(generationOptions.max,value);ticks.push({value:lastTick,major:isMajor(lastTick),significand:significand});return ticks}class LogarithmicScale extends Scale{static id="logarithmic";static defaults={ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:true}}};constructor(cfg){super(cfg);this.start=undefined;this.end=undefined;this._startValue=undefined;this._valueRange=0}parse(raw,index){const value=LinearScaleBase.prototype.parse.apply(this,[raw,index]);if(value===0){this._zero=true;return undefined}return isNumberFinite(value)&&value>0?value:null}determineDataLimits(){const{min:min,max:max}=this.getMinMax(true);this.min=isNumberFinite(min)?Math.max(0,min):null;this.max=isNumberFinite(max)?Math.max(0,max):null;if(this.options.beginAtZero){this._zero=true}if(this._zero&&this.min!==this._suggestedMin&&!isNumberFinite(this._userMin)){this.min=min===changeExponent(this.min,0)?changeExponent(this.min,-1):changeExponent(this.min,0)}this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:minDefined,maxDefined:maxDefined}=this.getUserBounds();let min=this.min;let max=this.max;const setMin=v=>min=minDefined?min:v;const setMax=v=>max=maxDefined?max:v;if(min===max){if(min<=0){setMin(1);setMax(10)}else{setMin(changeExponent(min,-1));setMax(changeExponent(max,+1))}}if(min<=0){setMin(changeExponent(max,-1))}if(max<=0){setMax(changeExponent(min,+1))}this.min=min;this.max=max}buildTicks(){const opts=this.options;const generationOptions={min:this._userMin,max:this._userMax};const ticks=generateTicks(generationOptions,this);if(opts.bounds==="ticks"){_setMinAndMaxByKey(ticks,this,"value")}if(opts.reverse){ticks.reverse();this.start=this.max;this.end=this.min}else{this.start=this.min;this.end=this.max}return ticks}getLabelForValue(value){return value===undefined?"0":formatNumber(value,this.chart.options.locale,this.options.ticks.format)}configure(){const start=this.min;super.configure();this._startValue=log10(start);this._valueRange=log10(this.max)-log10(start)}getPixelForValue(value){if(value===undefined||value===0){value=this.min}if(value===null||isNaN(value)){return NaN}return this.getPixelForDecimal(value===this.min?0:(log10(value)-this._startValue)/this._valueRange)}getValueForPixel(pixel){const decimal=this.getDecimalForPixel(pixel);return Math.pow(10,this._startValue+decimal*this._valueRange)}}function getTickBackdropHeight(opts){const tickOpts=opts.ticks;if(tickOpts.display&&opts.display){const padding=toPadding(tickOpts.backdropPadding);return valueOrDefault(tickOpts.font&&tickOpts.font.size,defaults.font.size)+padding.height}return 0}function measureLabelSize(ctx,font,label){label=isArray(label)?label:[label];return{w:_longestText(ctx,font.string,label),h:label.length*font.lineHeight}}function determineLimits(angle,pos,size,min,max){if(angle===min||angle===max){return{start:pos-size/2,end:pos+size/2}}else if(anglemax){return{start:pos-size,end:pos}}return{start:pos,end:pos+size}}function fitWithPointLabels(scale){const orig={l:scale.left+scale._padding.left,r:scale.right-scale._padding.right,t:scale.top+scale._padding.top,b:scale.bottom-scale._padding.bottom};const limits=Object.assign({},orig);const labelSizes=[];const padding=[];const valueCount=scale._pointLabels.length;const pointLabelOpts=scale.options.pointLabels;const additionalAngle=pointLabelOpts.centerPointLabels?PI/valueCount:0;for(let i=0;iorig.r){x=(hLimits.end-orig.r)/sin;limits.r=Math.max(limits.r,orig.r+x)}if(vLimits.startorig.b){y=(vLimits.end-orig.b)/cos;limits.b=Math.max(limits.b,orig.b+y)}}function createPointLabelItem(scale,index,itemOpts){const outerDistance=scale.drawingArea;const{extra:extra,additionalAngle:additionalAngle,padding:padding,size:size}=itemOpts;const pointLabelPosition=scale.getPointPosition(index,outerDistance+extra+padding,additionalAngle);const angle=Math.round(toDegrees(_normalizeAngle(pointLabelPosition.angle+HALF_PI)));const y=yForAngle(pointLabelPosition.y,size.h,angle);const textAlign=getTextAlignForAngle(angle);const left=leftForTextAlign(pointLabelPosition.x,size.w,textAlign);return{visible:true,x:pointLabelPosition.x,y:y,textAlign:textAlign,left:left,top:y,right:left+size.w,bottom:y+size.h}}function isNotOverlapped(item,area){if(!area){return true}const{left:left,top:top,right:right,bottom:bottom}=item;const apexesInArea=_isPointInArea({x:left,y:top},area)||_isPointInArea({x:left,y:bottom},area)||_isPointInArea({x:right,y:top},area)||_isPointInArea({x:right,y:bottom},area);return!apexesInArea}function buildPointLabelItems(scale,labelSizes,padding){const items=[];const valueCount=scale._pointLabels.length;const opts=scale.options;const{centerPointLabels:centerPointLabels,display:display}=opts.pointLabels;const itemOpts={extra:getTickBackdropHeight(opts)/2,additionalAngle:centerPointLabels?PI/valueCount:0};let area;for(let i=0;i270||angle<90){y-=h}return y}function drawPointLabelBox(ctx,opts,item){const{left:left,top:top,right:right,bottom:bottom}=item;const{backdropColor:backdropColor}=opts;if(!isNullOrUndef(backdropColor)){const borderRadius=toTRBLCorners(opts.borderRadius);const padding=toPadding(opts.backdropPadding);ctx.fillStyle=backdropColor;const backdropLeft=left-padding.left;const backdropTop=top-padding.top;const backdropWidth=right-left+padding.width;const backdropHeight=bottom-top+padding.height;if(Object.values(borderRadius).some((v=>v!==0))){ctx.beginPath();addRoundedRectPath(ctx,{x:backdropLeft,y:backdropTop,w:backdropWidth,h:backdropHeight,radius:borderRadius});ctx.fill()}else{ctx.fillRect(backdropLeft,backdropTop,backdropWidth,backdropHeight)}}}function drawPointLabels(scale,labelCount){const{ctx:ctx,options:{pointLabels:pointLabels}}=scale;for(let i=labelCount-1;i>=0;i--){const item=scale._pointLabelItems[i];if(!item.visible){continue}const optsAtIndex=pointLabels.setContext(scale.getPointLabelContext(i));drawPointLabelBox(ctx,optsAtIndex,item);const plFont=toFont(optsAtIndex.font);const{x:x,y:y,textAlign:textAlign}=item;renderText(ctx,scale._pointLabels[i],x,y+plFont.lineHeight/2,plFont,{color:optsAtIndex.color,textAlign:textAlign,textBaseline:"middle"})}}function pathRadiusLine(scale,radius,circular,labelCount){const{ctx:ctx}=scale;if(circular){ctx.arc(scale.xCenter,scale.yCenter,radius,0,TAU)}else{let pointPosition=scale.getPointPosition(0,radius);ctx.moveTo(pointPosition.x,pointPosition.y);for(let i=1;i{const label=callback(this.options.pointLabels.callback,[value,index],this);return label||label===0?label:""})).filter(((v,i)=>this.chart.getDataVisibility(i)))}fit(){const opts=this.options;if(opts.display&&opts.pointLabels.display){fitWithPointLabels(this)}else{this.setCenterPoint(0,0,0,0)}}setCenterPoint(leftMovement,rightMovement,topMovement,bottomMovement){this.xCenter+=Math.floor((leftMovement-rightMovement)/2);this.yCenter+=Math.floor((topMovement-bottomMovement)/2);this.drawingArea-=Math.min(this.drawingArea/2,Math.max(leftMovement,rightMovement,topMovement,bottomMovement))}getIndexAngle(index){const angleMultiplier=TAU/(this._pointLabels.length||1);const startAngle=this.options.startAngle||0;return _normalizeAngle(index*angleMultiplier+toRadians(startAngle))}getDistanceFromCenterForValue(value){if(isNullOrUndef(value)){return NaN}const scalingFactor=this.drawingArea/(this.max-this.min);if(this.options.reverse){return(this.max-value)*scalingFactor}return(value-this.min)*scalingFactor}getValueForDistanceFromCenter(distance){if(isNullOrUndef(distance)){return NaN}const scaledDistance=distance/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-scaledDistance:this.min+scaledDistance}getPointLabelContext(index){const pointLabels=this._pointLabels||[];if(index>=0&&index{if(index!==0||index===0&&this.min<0){offset=this.getDistanceFromCenterForValue(tick.value);const context=this.getContext(index);const optsAtIndex=grid.setContext(context);const optsAtIndexBorder=border.setContext(context);drawRadiusLine(this,optsAtIndex,offset,labelCount,optsAtIndexBorder)}}))}if(angleLines.display){ctx.save();for(i=labelCount-1;i>=0;i--){const optsAtIndex=angleLines.setContext(this.getPointLabelContext(i));const{color:color,lineWidth:lineWidth}=optsAtIndex;if(!lineWidth||!color){continue}ctx.lineWidth=lineWidth;ctx.strokeStyle=color;ctx.setLineDash(optsAtIndex.borderDash);ctx.lineDashOffset=optsAtIndex.borderDashOffset;offset=this.getDistanceFromCenterForValue(opts.ticks.reverse?this.min:this.max);position=this.getPointPosition(i,offset);ctx.beginPath();ctx.moveTo(this.xCenter,this.yCenter);ctx.lineTo(position.x,position.y);ctx.stroke()}ctx.restore()}}drawBorder(){}drawLabels(){const ctx=this.ctx;const opts=this.options;const tickOpts=opts.ticks;if(!tickOpts.display){return}const startAngle=this.getIndexAngle(0);let offset,width;ctx.save();ctx.translate(this.xCenter,this.yCenter);ctx.rotate(startAngle);ctx.textAlign="center";ctx.textBaseline="middle";this.ticks.forEach(((tick,index)=>{if(index===0&&this.min>=0&&!opts.reverse){return}const optsAtIndex=tickOpts.setContext(this.getContext(index));const tickFont=toFont(optsAtIndex.font);offset=this.getDistanceFromCenterForValue(this.ticks[index].value);if(optsAtIndex.showLabelBackdrop){ctx.font=tickFont.string;width=ctx.measureText(tick.label).width;ctx.fillStyle=optsAtIndex.backdropColor;const padding=toPadding(optsAtIndex.backdropPadding);ctx.fillRect(-width/2-padding.left,-offset-tickFont.size/2-padding.top,width+padding.width,tickFont.size+padding.height)}renderText(ctx,tick.label,0,-offset,tickFont,{color:optsAtIndex.color,strokeColor:optsAtIndex.textStrokeColor,strokeWidth:optsAtIndex.textStrokeWidth})}));ctx.restore()}drawTitle(){}}const INTERVALS={millisecond:{common:true,size:1,steps:1e3},second:{common:true,size:1e3,steps:60},minute:{common:true,size:6e4,steps:60},hour:{common:true,size:36e5,steps:24},day:{common:true,size:864e5,steps:30},week:{common:false,size:6048e5,steps:4},month:{common:true,size:2628e6,steps:12},quarter:{common:false,size:7884e6,steps:4},year:{common:true,size:3154e7}};const UNITS=Object.keys(INTERVALS);function sorter(a,b){return a-b}function parse(scale,input){if(isNullOrUndef(input)){return null}const adapter=scale._adapter;const{parser:parser,round:round,isoWeekday:isoWeekday}=scale._parseOpts;let value=input;if(typeof parser==="function"){value=parser(value)}if(!isNumberFinite(value)){value=typeof parser==="string"?adapter.parse(value,parser):adapter.parse(value)}if(value===null){return null}if(round){value=round==="week"&&(isNumber(isoWeekday)||isoWeekday===true)?adapter.startOf(value,"isoWeek",isoWeekday):adapter.startOf(value,round)}return+value}function determineUnitForAutoTicks(minUnit,min,max,capacity){const ilen=UNITS.length;for(let i=UNITS.indexOf(minUnit);i=UNITS.indexOf(minUnit);i--){const unit=UNITS[i];if(INTERVALS[unit].common&&scale._adapter.diff(max,min,unit)>=numTicks-1){return unit}}return UNITS[minUnit?UNITS.indexOf(minUnit):0]}function determineMajorUnit(unit){for(let i=UNITS.indexOf(unit)+1,ilen=UNITS.length;i=time?timestamps[lo]:timestamps[hi];ticks[timestamp]=true}}function setMajorTicks(scale,ticks,map,majorUnit){const adapter=scale._adapter;const first=+adapter.startOf(ticks[0].value,majorUnit);const last=ticks[ticks.length-1].value;let major,index;for(major=first;major<=last;major=+adapter.add(major,1,majorUnit)){index=map[major];if(index>=0){ticks[index].major=true}}return ticks}function ticksFromTimestamps(scale,values,majorUnit){const ticks=[];const map={};const ilen=values.length;let i,value;for(i=0;i+tick.value)))}}initOffsets(timestamps=[]){let start=0;let end=0;let first,last;if(this.options.offset&×tamps.length){first=this.getDecimalForValue(timestamps[0]);if(timestamps.length===1){start=1-first}else{start=(this.getDecimalForValue(timestamps[1])-first)/2}last=this.getDecimalForValue(timestamps[timestamps.length-1]);if(timestamps.length===1){end=last}else{end=(last-this.getDecimalForValue(timestamps[timestamps.length-2]))/2}}const limit=timestamps.length<3?.5:.25;start=_limitValue(start,0,limit);end=_limitValue(end,0,limit);this._offsets={start:start,end:end,factor:1/(start+1+end)}}_generate(){const adapter=this._adapter;const min=this.min;const max=this.max;const options=this.options;const timeOpts=options.time;const minor=timeOpts.unit||determineUnitForAutoTicks(timeOpts.minUnit,min,max,this._getLabelCapacity(min));const stepSize=valueOrDefault(options.ticks.stepSize,1);const weekday=minor==="week"?timeOpts.isoWeekday:false;const hasWeekday=isNumber(weekday)||weekday===true;const ticks={};let first=min;let time,count;if(hasWeekday){first=+adapter.startOf(first,"isoWeek",weekday)}first=+adapter.startOf(first,hasWeekday?"day":minor);if(adapter.diff(max,min,minor)>1e5*stepSize){throw new Error(min+" and "+max+" are too far apart with stepSize of "+stepSize+" "+minor)}const timestamps=options.ticks.source==="data"&&this.getDataTimestamps();for(time=first,count=0;time+x))}getLabelForValue(value){const adapter=this._adapter;const timeOpts=this.options.time;if(timeOpts.tooltipFormat){return adapter.format(value,timeOpts.tooltipFormat)}return adapter.format(value,timeOpts.displayFormats.datetime)}format(value,format){const options=this.options;const formats=options.time.displayFormats;const unit=this._unit;const fmt=format||formats[unit];return this._adapter.format(value,fmt)}_tickFormatFunction(time,index,ticks,format){const options=this.options;const formatter=options.ticks.callback;if(formatter){return callback(formatter,[time,index,ticks],this)}const formats=options.time.displayFormats;const unit=this._unit;const majorUnit=this._majorUnit;const minorFormat=unit&&formats[unit];const majorFormat=majorUnit&&formats[majorUnit];const tick=ticks[index];const major=majorUnit&&majorFormat&&tick&&tick.major;return this._adapter.format(time,format||(major?majorFormat:minorFormat))}generateTickLabels(ticks){let i,ilen,tick;for(i=0,ilen=ticks.length;i0?capacity:1}getDataTimestamps(){let timestamps=this._cache.data||[];let i,ilen;if(timestamps.length){return timestamps}const metas=this.getMatchingVisibleMetas();if(this._normalized&&metas.length){return this._cache.data=metas[0].controller.getAllParsedValues(this)}for(i=0,ilen=metas.length;i=table[lo].pos&&val<=table[hi].pos){({lo:lo,hi:hi}=_lookupByKey(table,"pos",val))}({pos:prevSource,time:prevTarget}=table[lo]);({pos:nextSource,time:nextTarget}=table[hi])}else{if(val>=table[lo].time&&val<=table[hi].time){({lo:lo,hi:hi}=_lookupByKey(table,"time",val))}({time:prevSource,pos:prevTarget}=table[lo]);({time:nextSource,pos:nextTarget}=table[hi])}const span=nextSource-prevSource;return span?prevTarget+(nextTarget-prevTarget)*(val-prevSource)/span:prevTarget}class TimeSeriesScale extends TimeScale{static id="timeseries";static defaults=TimeScale.defaults;constructor(props){super(props);this._table=[];this._minPos=undefined;this._tableRange=undefined}initOffsets(){const timestamps=this._getTimestampsForTable();const table=this._table=this.buildLookupTable(timestamps);this._minPos=interpolate(table,this.min);this._tableRange=interpolate(table,this.max)-this._minPos;super.initOffsets(timestamps)}buildLookupTable(timestamps){const{min:min,max:max}=this;const items=[];const table=[];let i,ilen,prev,curr,next;for(i=0,ilen=timestamps.length;i=min&&curr<=max){items.push(curr)}}if(items.length<2){return[{time:min,pos:0},{time:max,pos:1}]}for(i=0,ilen=items.length;ia-b))}_getTimestampsForTable(){let timestamps=this._cache.all||[];if(timestamps.length){return timestamps}const data=this.getDataTimestamps();const label=this.getLabelTimestamps();if(data.length&&label.length){timestamps=this.normalize(data.concat(label))}else{timestamps=data.length?data:label}timestamps=this._cache.all=timestamps;return timestamps}getDecimalForValue(value){return(interpolate(this._table,value)-this._minPos)/this._tableRange}getValueForPixel(pixel){const offsets=this._offsets;const decimal=this.getDecimalForPixel(pixel)/offsets.factor-offsets.end;return interpolate(this._table,decimal*this._tableRange+this._minPos,true)}}var scales=Object.freeze({__proto__:null,CategoryScale:CategoryScale,LinearScale:LinearScale,LogarithmicScale:LogarithmicScale,RadialLinearScale:RadialLinearScale,TimeScale:TimeScale,TimeSeriesScale:TimeSeriesScale});const registerables=[controllers,elements,plugins,scales];export{Animation,Animations,ArcElement,BarController,BarElement,BasePlatform,BasicPlatform,BubbleController,CategoryScale,Chart,plugin_colors as Colors,DatasetController,plugin_decimation as Decimation,DomPlatform,DoughnutController,Element,index as Filler,Interaction,plugin_legend as Legend,LineController,LineElement,LinearScale,LogarithmicScale,PieController,PointElement,PolarAreaController,RadarController,RadialLinearScale,Scale,ScatterController,plugin_subtitle as SubTitle,Ticks,TimeScale,TimeSeriesScale,plugin_title as Title,plugin_tooltip as Tooltip,adapters as _adapters,_detectPlatform,animator,controllers,defaults,elements,layouts,plugins,registerables,registry,scales}; \ No newline at end of file diff --git a/ckanext/charts/assets/js/vendor/d3.min.js b/ckanext/charts/assets/js/vendor/d3.min.js new file mode 100644 index 0000000..33bb880 --- /dev/null +++ b/ckanext/charts/assets/js/vendor/d3.min.js @@ -0,0 +1,2 @@ +// https://d3js.org v7.9.0 Copyright 2010-2023 Mike Bostock +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";function n(t,n){return null==t||null==n?NaN:tn?1:t>=n?0:NaN}function e(t,n){return null==t||null==n?NaN:nt?1:n>=t?0:NaN}function r(t){let r,o,a;function u(t,n,e=0,i=t.length){if(e>>1;o(t[r],n)<0?e=r+1:i=r}while(en(t(e),r),a=(n,e)=>t(n)-e):(r=t===n||t===e?t:i,o=t,a=t),{left:u,center:function(t,n,e=0,r=t.length){const i=u(t,n,e,r-1);return i>e&&a(t[i-1],n)>-a(t[i],n)?i-1:i},right:function(t,n,e=0,i=t.length){if(e>>1;o(t[r],n)<=0?e=r+1:i=r}while(e{n(t,e,(r<<=2)+0,(i<<=2)+0,o<<=2),n(t,e,r+1,i+1,o),n(t,e,r+2,i+2,o),n(t,e,r+3,i+3,o)}}));function d(t){return function(n,e,r=e){if(!((e=+e)>=0))throw new RangeError("invalid rx");if(!((r=+r)>=0))throw new RangeError("invalid ry");let{data:i,width:o,height:a}=n;if(!((o=Math.floor(o))>=0))throw new RangeError("invalid width");if(!((a=Math.floor(void 0!==a?a:i.length/o))>=0))throw new RangeError("invalid height");if(!o||!a||!e&&!r)return n;const u=e&&t(e),c=r&&t(r),f=i.slice();return u&&c?(p(u,f,i,o,a),p(u,i,f,o,a),p(u,f,i,o,a),g(c,i,f,o,a),g(c,f,i,o,a),g(c,i,f,o,a)):u?(p(u,i,f,o,a),p(u,f,i,o,a),p(u,i,f,o,a)):c&&(g(c,i,f,o,a),g(c,f,i,o,a),g(c,i,f,o,a)),n}}function p(t,n,e,r,i){for(let o=0,a=r*i;o{if(!((o-=a)>=i))return;let u=t*r[i];const c=a*t;for(let t=i,n=i+c;t{if(!((a-=u)>=o))return;let c=n*i[o];const f=u*n,s=f+u;for(let t=o,n=o+f;t=n&&++e;else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(i=+i)>=i&&++e}return e}function _(t){return 0|t.length}function b(t){return!(t>0)}function m(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function x(t,n){let e,r=0,i=0,o=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(e=n-i,i+=e/++r,o+=e*(n-i));else{let a=-1;for(let u of t)null!=(u=n(u,++a,t))&&(u=+u)>=u&&(e=u-i,i+=e/++r,o+=e*(u-i))}if(r>1)return o/(r-1)}function w(t,n){const e=x(t,n);return e?Math.sqrt(e):e}function M(t,n){let e,r;if(void 0===n)for(const n of t)null!=n&&(void 0===e?n>=n&&(e=r=n):(e>n&&(e=n),r=o&&(e=r=o):(e>o&&(e=o),r0){for(o=t[--i];i>0&&(n=o,e=t[--i],o=n+e,r=e-(o-n),!r););i>0&&(r<0&&t[i-1]<0||r>0&&t[i-1]>0)&&(e=2*r,n=o+e,e==n-o&&(o=n))}return o}}class InternMap extends Map{constructor(t,n=N){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[n,e]of t)this.set(n,e)}get(t){return super.get(A(this,t))}has(t){return super.has(A(this,t))}set(t,n){return super.set(S(this,t),n)}delete(t){return super.delete(E(this,t))}}class InternSet extends Set{constructor(t,n=N){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const n of t)this.add(n)}has(t){return super.has(A(this,t))}add(t){return super.add(S(this,t))}delete(t){return super.delete(E(this,t))}}function A({_intern:t,_key:n},e){const r=n(e);return t.has(r)?t.get(r):e}function S({_intern:t,_key:n},e){const r=n(e);return t.has(r)?t.get(r):(t.set(r,e),e)}function E({_intern:t,_key:n},e){const r=n(e);return t.has(r)&&(e=t.get(r),t.delete(r)),e}function N(t){return null!==t&&"object"==typeof t?t.valueOf():t}function k(t){return t}function C(t,...n){return F(t,k,k,n)}function P(t,...n){return F(t,Array.from,k,n)}function z(t,n){for(let e=1,r=n.length;et.pop().map((([n,e])=>[...t,n,e]))));return t}function $(t,n,...e){return F(t,k,n,e)}function D(t,n,...e){return F(t,Array.from,n,e)}function R(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function F(t,n,e,r){return function t(i,o){if(o>=r.length)return e(i);const a=new InternMap,u=r[o++];let c=-1;for(const t of i){const n=u(t,++c,i),e=a.get(n);e?e.push(t):a.set(n,[t])}for(const[n,e]of a)a.set(n,t(e,o));return n(a)}(t,0)}function q(t,n){return Array.from(n,(n=>t[n]))}function U(t,...n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[e]=n;if(e&&2!==e.length||n.length>1){const r=Uint32Array.from(t,((t,n)=>n));return n.length>1?(n=n.map((n=>t.map(n))),r.sort(((t,e)=>{for(const r of n){const n=O(r[t],r[e]);if(n)return n}}))):(e=t.map(e),r.sort(((t,n)=>O(e[t],e[n])))),q(t,r)}return t.sort(I(e))}function I(t=n){if(t===n)return O;if("function"!=typeof t)throw new TypeError("compare is not a function");return(n,e)=>{const r=t(n,e);return r||0===r?r:(0===t(e,e))-(0===t(n,n))}}function O(t,n){return(null==t||!(t>=t))-(null==n||!(n>=n))||(tn?1:0)}var B=Array.prototype.slice;function Y(t){return()=>t}const L=Math.sqrt(50),j=Math.sqrt(10),H=Math.sqrt(2);function X(t,n,e){const r=(n-t)/Math.max(0,e),i=Math.floor(Math.log10(r)),o=r/Math.pow(10,i),a=o>=L?10:o>=j?5:o>=H?2:1;let u,c,f;return i<0?(f=Math.pow(10,-i)/a,u=Math.round(t*f),c=Math.round(n*f),u/fn&&--c,f=-f):(f=Math.pow(10,i)*a,u=Math.round(t/f),c=Math.round(n/f),u*fn&&--c),c0))return[];if((t=+t)===(n=+n))return[t];const r=n=i))return[];const u=o-i+1,c=new Array(u);if(r)if(a<0)for(let t=0;t0?(t=Math.floor(t/i)*i,n=Math.ceil(n/i)*i):i<0&&(t=Math.ceil(t*i)/i,n=Math.floor(n*i)/i),r=i}}function K(t){return Math.max(1,Math.ceil(Math.log(v(t))/Math.LN2)+1)}function Q(){var t=k,n=M,e=K;function r(r){Array.isArray(r)||(r=Array.from(r));var i,o,a,u=r.length,c=new Array(u);for(i=0;i=h)if(t>=h&&n===M){const t=V(l,h,e);isFinite(t)&&(t>0?h=(Math.floor(h/t)+1)*t:t<0&&(h=(Math.ceil(h*-t)+1)/-t))}else d.pop()}for(var p=d.length,g=0,y=p;d[g]<=l;)++g;for(;d[y-1]>h;)--y;(g||y0?d[i-1]:l,v.x1=i0)for(i=0;i=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e=i)&&(e=i)}return e}function tt(t,n){let e,r=-1,i=-1;if(void 0===n)for(const n of t)++i,null!=n&&(e=n)&&(e=n,r=i);else for(let o of t)null!=(o=n(o,++i,t))&&(e=o)&&(e=o,r=i);return r}function nt(t,n){let e;if(void 0===n)for(const n of t)null!=n&&(e>n||void 0===e&&n>=n)&&(e=n);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&(e>i||void 0===e&&i>=i)&&(e=i)}return e}function et(t,n){let e,r=-1,i=-1;if(void 0===n)for(const n of t)++i,null!=n&&(e>n||void 0===e&&n>=n)&&(e=n,r=i);else for(let o of t)null!=(o=n(o,++i,t))&&(e>o||void 0===e&&o>=o)&&(e=o,r=i);return r}function rt(t,n,e=0,r=1/0,i){if(n=Math.floor(n),e=Math.floor(Math.max(0,e)),r=Math.floor(Math.min(t.length-1,r)),!(e<=n&&n<=r))return t;for(i=void 0===i?O:I(i);r>e;){if(r-e>600){const o=r-e+1,a=n-e+1,u=Math.log(o),c=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*c*(o-c)/o)*(a-o/2<0?-1:1);rt(t,n,Math.max(e,Math.floor(n-a*c/o+f)),Math.min(r,Math.floor(n+(o-a)*c/o+f)),i)}const o=t[n];let a=e,u=r;for(it(t,e,n),i(t[r],o)>0&&it(t,e,r);a0;)--u}0===i(t[e],o)?it(t,e,u):(++u,it(t,u,r)),u<=n&&(e=u+1),n<=u&&(r=u-1)}return t}function it(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function ot(t,e=n){let r,i=!1;if(1===e.length){let o;for(const a of t){const t=e(a);(i?n(t,o)>0:0===n(t,t))&&(r=a,o=t,i=!0)}}else for(const n of t)(i?e(n,r)>0:0===e(n,n))&&(r=n,i=!0);return r}function at(t,n,e){if(t=Float64Array.from(function*(t,n){if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(yield n);else{let e=-1;for(let r of t)null!=(r=n(r,++e,t))&&(r=+r)>=r&&(yield r)}}(t,e)),(r=t.length)&&!isNaN(n=+n)){if(n<=0||r<2)return nt(t);if(n>=1)return J(t);var r,i=(r-1)*n,o=Math.floor(i),a=J(rt(t,o).subarray(0,o+1));return a+(nt(t.subarray(o+1))-a)*(i-o)}}function ut(t,n,e=o){if((r=t.length)&&!isNaN(n=+n)){if(n<=0||r<2)return+e(t[0],0,t);if(n>=1)return+e(t[r-1],r-1,t);var r,i=(r-1)*n,a=Math.floor(i),u=+e(t[a],a,t);return u+(+e(t[a+1],a+1,t)-u)*(i-a)}}function ct(t,n,e=o){if(!isNaN(n=+n)){if(r=Float64Array.from(t,((n,r)=>o(e(t[r],r,t)))),n<=0)return et(r);if(n>=1)return tt(r);var r,i=Uint32Array.from(t,((t,n)=>n)),a=r.length-1,u=Math.floor(a*n);return rt(i,u,0,a,((t,n)=>O(r[t],r[n]))),(u=ot(i.subarray(0,u+1),(t=>r[t])))>=0?u:-1}}function ft(t){return Array.from(function*(t){for(const n of t)yield*n}(t))}function st(t,n){return[t,n]}function lt(t,n,e){t=+t,n=+n,e=(i=arguments.length)<2?(n=t,t=0,1):i<3?1:+e;for(var r=-1,i=0|Math.max(0,Math.ceil((n-t)/e)),o=new Array(i);++r+t(n)}function kt(t,n){return n=Math.max(0,t.bandwidth()-2*n)/2,t.round()&&(n=Math.round(n)),e=>+t(e)+n}function Ct(){return!this.__axis}function Pt(t,n){var e=[],r=null,i=null,o=6,a=6,u=3,c="undefined"!=typeof window&&window.devicePixelRatio>1?0:.5,f=t===xt||t===Tt?-1:1,s=t===Tt||t===wt?"x":"y",l=t===xt||t===Mt?St:Et;function h(h){var d=null==r?n.ticks?n.ticks.apply(n,e):n.domain():r,p=null==i?n.tickFormat?n.tickFormat.apply(n,e):mt:i,g=Math.max(o,0)+u,y=n.range(),v=+y[0]+c,_=+y[y.length-1]+c,b=(n.bandwidth?kt:Nt)(n.copy(),c),m=h.selection?h.selection():h,x=m.selectAll(".domain").data([null]),w=m.selectAll(".tick").data(d,n).order(),M=w.exit(),T=w.enter().append("g").attr("class","tick"),A=w.select("line"),S=w.select("text");x=x.merge(x.enter().insert("path",".tick").attr("class","domain").attr("stroke","currentColor")),w=w.merge(T),A=A.merge(T.append("line").attr("stroke","currentColor").attr(s+"2",f*o)),S=S.merge(T.append("text").attr("fill","currentColor").attr(s,f*g).attr("dy",t===xt?"0em":t===Mt?"0.71em":"0.32em")),h!==m&&(x=x.transition(h),w=w.transition(h),A=A.transition(h),S=S.transition(h),M=M.transition(h).attr("opacity",At).attr("transform",(function(t){return isFinite(t=b(t))?l(t+c):this.getAttribute("transform")})),T.attr("opacity",At).attr("transform",(function(t){var n=this.parentNode.__axis;return l((n&&isFinite(n=n(t))?n:b(t))+c)}))),M.remove(),x.attr("d",t===Tt||t===wt?a?"M"+f*a+","+v+"H"+c+"V"+_+"H"+f*a:"M"+c+","+v+"V"+_:a?"M"+v+","+f*a+"V"+c+"H"+_+"V"+f*a:"M"+v+","+c+"H"+_),w.attr("opacity",1).attr("transform",(function(t){return l(b(t)+c)})),A.attr(s+"2",f*o),S.attr(s,f*g).text(p),m.filter(Ct).attr("fill","none").attr("font-size",10).attr("font-family","sans-serif").attr("text-anchor",t===wt?"start":t===Tt?"end":"middle"),m.each((function(){this.__axis=b}))}return h.scale=function(t){return arguments.length?(n=t,h):n},h.ticks=function(){return e=Array.from(arguments),h},h.tickArguments=function(t){return arguments.length?(e=null==t?[]:Array.from(t),h):e.slice()},h.tickValues=function(t){return arguments.length?(r=null==t?null:Array.from(t),h):r&&r.slice()},h.tickFormat=function(t){return arguments.length?(i=t,h):i},h.tickSize=function(t){return arguments.length?(o=a=+t,h):o},h.tickSizeInner=function(t){return arguments.length?(o=+t,h):o},h.tickSizeOuter=function(t){return arguments.length?(a=+t,h):a},h.tickPadding=function(t){return arguments.length?(u=+t,h):u},h.offset=function(t){return arguments.length?(c=+t,h):c},h}var zt={value:()=>{}};function $t(){for(var t,n=0,e=arguments.length,r={};n=0&&(n=t.slice(e+1),t=t.slice(0,e)),t&&!r.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}}))),a=-1,u=o.length;if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++a0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Ut.hasOwnProperty(n)?{space:Ut[n],local:t}:t}function Ot(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===qt&&n.documentElement.namespaceURI===qt?n.createElement(t):n.createElementNS(e,t)}}function Bt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function Yt(t){var n=It(t);return(n.local?Bt:Ot)(n)}function Lt(){}function jt(t){return null==t?Lt:function(){return this.querySelector(t)}}function Ht(t){return null==t?[]:Array.isArray(t)?t:Array.from(t)}function Xt(){return[]}function Gt(t){return null==t?Xt:function(){return this.querySelectorAll(t)}}function Vt(t){return function(){return this.matches(t)}}function Wt(t){return function(n){return n.matches(t)}}var Zt=Array.prototype.find;function Kt(){return this.firstElementChild}var Qt=Array.prototype.filter;function Jt(){return Array.from(this.children)}function tn(t){return new Array(t.length)}function nn(t,n){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=n}function en(t,n,e,r,i,o){for(var a,u=0,c=n.length,f=o.length;un?1:t>=n?0:NaN}function cn(t){return function(){this.removeAttribute(t)}}function fn(t){return function(){this.removeAttributeNS(t.space,t.local)}}function sn(t,n){return function(){this.setAttribute(t,n)}}function ln(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function hn(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function dn(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function pn(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function gn(t){return function(){this.style.removeProperty(t)}}function yn(t,n,e){return function(){this.style.setProperty(t,n,e)}}function vn(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function _n(t,n){return t.style.getPropertyValue(n)||pn(t).getComputedStyle(t,null).getPropertyValue(n)}function bn(t){return function(){delete this[t]}}function mn(t,n){return function(){this[t]=n}}function xn(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function wn(t){return t.trim().split(/^|\s+/)}function Mn(t){return t.classList||new Tn(t)}function Tn(t){this._node=t,this._names=wn(t.getAttribute("class")||"")}function An(t,n){for(var e=Mn(t),r=-1,i=n.length;++r=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Gn=[null];function Vn(t,n){this._groups=t,this._parents=n}function Wn(){return new Vn([[document.documentElement]],Gn)}function Zn(t){return"string"==typeof t?new Vn([[document.querySelector(t)]],[document.documentElement]):new Vn([[t]],Gn)}Vn.prototype=Wn.prototype={constructor:Vn,select:function(t){"function"!=typeof t&&(t=jt(t));for(var n=this._groups,e=n.length,r=new Array(e),i=0;i=m&&(m=b+1);!(_=y[m])&&++m=0;)(r=i[o])&&(a&&4^r.compareDocumentPosition(a)&&a.parentNode.insertBefore(r,a),a=r);return this},sort:function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=un);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?gn:"function"==typeof n?vn:yn)(t,n,null==e?"":e)):_n(this.node(),t)},property:function(t,n){return arguments.length>1?this.each((null==n?bn:"function"==typeof n?xn:mn)(t,n)):this.node()[t]},classed:function(t,n){var e=wn(t+"");if(arguments.length<2){for(var r=Mn(this.node()),i=-1,o=e.length;++i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}}))}(t+""),a=o.length;if(!(arguments.length<2)){for(u=n?Ln:Yn,r=0;r()=>t;function fe(t,{sourceEvent:n,subject:e,target:r,identifier:i,active:o,x:a,y:u,dx:c,dy:f,dispatch:s}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:e,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:f,enumerable:!0,configurable:!0},_:{value:s}})}function se(t){return!t.ctrlKey&&!t.button}function le(){return this.parentNode}function he(t,n){return null==n?{x:t.x,y:t.y}:n}function de(){return navigator.maxTouchPoints||"ontouchstart"in this}function pe(t,n,e){t.prototype=n.prototype=e,e.constructor=t}function ge(t,n){var e=Object.create(t.prototype);for(var r in n)e[r]=n[r];return e}function ye(){}fe.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};var ve=.7,_e=1/ve,be="\\s*([+-]?\\d+)\\s*",me="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",we=/^#([0-9a-f]{3,8})$/,Me=new RegExp(`^rgb\\(${be},${be},${be}\\)$`),Te=new RegExp(`^rgb\\(${xe},${xe},${xe}\\)$`),Ae=new RegExp(`^rgba\\(${be},${be},${be},${me}\\)$`),Se=new RegExp(`^rgba\\(${xe},${xe},${xe},${me}\\)$`),Ee=new RegExp(`^hsl\\(${me},${xe},${xe}\\)$`),Ne=new RegExp(`^hsla\\(${me},${xe},${xe},${me}\\)$`),ke={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};function Ce(){return this.rgb().formatHex()}function Pe(){return this.rgb().formatRgb()}function ze(t){var n,e;return t=(t+"").trim().toLowerCase(),(n=we.exec(t))?(e=n[1].length,n=parseInt(n[1],16),6===e?$e(n):3===e?new qe(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1):8===e?De(n>>24&255,n>>16&255,n>>8&255,(255&n)/255):4===e?De(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|240&n,((15&n)<<4|15&n)/255):null):(n=Me.exec(t))?new qe(n[1],n[2],n[3],1):(n=Te.exec(t))?new qe(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=Ae.exec(t))?De(n[1],n[2],n[3],n[4]):(n=Se.exec(t))?De(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=Ee.exec(t))?Le(n[1],n[2]/100,n[3]/100,1):(n=Ne.exec(t))?Le(n[1],n[2]/100,n[3]/100,n[4]):ke.hasOwnProperty(t)?$e(ke[t]):"transparent"===t?new qe(NaN,NaN,NaN,0):null}function $e(t){return new qe(t>>16&255,t>>8&255,255&t,1)}function De(t,n,e,r){return r<=0&&(t=n=e=NaN),new qe(t,n,e,r)}function Re(t){return t instanceof ye||(t=ze(t)),t?new qe((t=t.rgb()).r,t.g,t.b,t.opacity):new qe}function Fe(t,n,e,r){return 1===arguments.length?Re(t):new qe(t,n,e,null==r?1:r)}function qe(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function Ue(){return`#${Ye(this.r)}${Ye(this.g)}${Ye(this.b)}`}function Ie(){const t=Oe(this.opacity);return`${1===t?"rgb(":"rgba("}${Be(this.r)}, ${Be(this.g)}, ${Be(this.b)}${1===t?")":`, ${t})`}`}function Oe(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Be(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Ye(t){return((t=Be(t))<16?"0":"")+t.toString(16)}function Le(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new Xe(t,n,e,r)}function je(t){if(t instanceof Xe)return new Xe(t.h,t.s,t.l,t.opacity);if(t instanceof ye||(t=ze(t)),!t)return new Xe;if(t instanceof Xe)return t;var n=(t=t.rgb()).r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),a=NaN,u=o-i,c=(o+i)/2;return u?(a=n===o?(e-r)/u+6*(e0&&c<1?0:a,new Xe(a,u,c,t.opacity)}function He(t,n,e,r){return 1===arguments.length?je(t):new Xe(t,n,e,null==r?1:r)}function Xe(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Ge(t){return(t=(t||0)%360)<0?t+360:t}function Ve(t){return Math.max(0,Math.min(1,t||0))}function We(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}pe(ye,ze,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ce,formatHex:Ce,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return je(this).formatHsl()},formatRgb:Pe,toString:Pe}),pe(qe,Fe,ge(ye,{brighter(t){return t=null==t?_e:Math.pow(_e,t),new qe(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?ve:Math.pow(ve,t),new qe(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new qe(Be(this.r),Be(this.g),Be(this.b),Oe(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Ue,formatHex:Ue,formatHex8:function(){return`#${Ye(this.r)}${Ye(this.g)}${Ye(this.b)}${Ye(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Ie,toString:Ie})),pe(Xe,He,ge(ye,{brighter(t){return t=null==t?_e:Math.pow(_e,t),new Xe(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?ve:Math.pow(ve,t),new Xe(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=e+(e<.5?e:1-e)*n,i=2*e-r;return new qe(We(t>=240?t-240:t+120,i,r),We(t,i,r),We(t<120?t+240:t-120,i,r),this.opacity)},clamp(){return new Xe(Ge(this.h),Ve(this.s),Ve(this.l),Oe(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=Oe(this.opacity);return`${1===t?"hsl(":"hsla("}${Ge(this.h)}, ${100*Ve(this.s)}%, ${100*Ve(this.l)}%${1===t?")":`, ${t})`}`}}));const Ze=Math.PI/180,Ke=180/Math.PI,Qe=.96422,Je=1,tr=.82521,nr=4/29,er=6/29,rr=3*er*er,ir=er*er*er;function or(t){if(t instanceof ur)return new ur(t.l,t.a,t.b,t.opacity);if(t instanceof pr)return gr(t);t instanceof qe||(t=Re(t));var n,e,r=lr(t.r),i=lr(t.g),o=lr(t.b),a=cr((.2225045*r+.7168786*i+.0606169*o)/Je);return r===i&&i===o?n=e=a:(n=cr((.4360747*r+.3850649*i+.1430804*o)/Qe),e=cr((.0139322*r+.0971045*i+.7141733*o)/tr)),new ur(116*a-16,500*(n-a),200*(a-e),t.opacity)}function ar(t,n,e,r){return 1===arguments.length?or(t):new ur(t,n,e,null==r?1:r)}function ur(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function cr(t){return t>ir?Math.pow(t,1/3):t/rr+nr}function fr(t){return t>er?t*t*t:rr*(t-nr)}function sr(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function lr(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function hr(t){if(t instanceof pr)return new pr(t.h,t.c,t.l,t.opacity);if(t instanceof ur||(t=or(t)),0===t.a&&0===t.b)return new pr(NaN,0=1?(e=1,n-1):Math.floor(e*n),i=t[r],o=t[r+1],a=r>0?t[r-1]:2*i-o,u=r()=>t;function Cr(t,n){return function(e){return t+e*n}}function Pr(t,n){var e=n-t;return e?Cr(t,e>180||e<-180?e-360*Math.round(e/360):e):kr(isNaN(t)?n:t)}function zr(t){return 1==(t=+t)?$r:function(n,e){return e-n?function(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}(n,e,t):kr(isNaN(n)?e:n)}}function $r(t,n){var e=n-t;return e?Cr(t,e):kr(isNaN(t)?n:t)}var Dr=function t(n){var e=zr(n);function r(t,n){var r=e((t=Fe(t)).r,(n=Fe(n)).r),i=e(t.g,n.g),o=e(t.b,n.b),a=$r(t.opacity,n.opacity);return function(n){return t.r=r(n),t.g=i(n),t.b=o(n),t.opacity=a(n),t+""}}return r.gamma=t,r}(1);function Rr(t){return function(n){var e,r,i=n.length,o=new Array(i),a=new Array(i),u=new Array(i);for(e=0;eo&&(i=n.slice(o,i),u[a]?u[a]+=i:u[++a]=i),(e=e[0])===(r=r[0])?u[a]?u[a]+=r:u[++a]=r:(u[++a]=null,c.push({i:a,x:Yr(e,r)})),o=Hr.lastIndex;return o180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Yr(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}(o.rotate,a.rotate,u,c),function(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Yr(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}(o.skewX,a.skewX,u,c),function(t,n,e,r,o,a){if(t!==e||n!==r){var u=o.push(i(o)+"scale(",null,",",null,")");a.push({i:u-4,x:Yr(t,e)},{i:u-2,x:Yr(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}(o.scaleX,o.scaleY,a.scaleX,a.scaleY,u,c),o=a=null,function(t){for(var n,e=-1,r=c.length;++e=0&&n._call.call(void 0,t),n=n._next;--yi}function Ci(){xi=(mi=Mi.now())+wi,yi=vi=0;try{ki()}finally{yi=0,function(){var t,n,e=pi,r=1/0;for(;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:pi=n);gi=t,zi(r)}(),xi=0}}function Pi(){var t=Mi.now(),n=t-mi;n>bi&&(wi-=n,mi=t)}function zi(t){yi||(vi&&(vi=clearTimeout(vi)),t-xi>24?(t<1/0&&(vi=setTimeout(Ci,t-Mi.now()-wi)),_i&&(_i=clearInterval(_i))):(_i||(mi=Mi.now(),_i=setInterval(Pi,bi)),yi=1,Ti(Ci)))}function $i(t,n,e){var r=new Ei;return n=null==n?0:+n,r.restart((e=>{r.stop(),t(e+n)}),n,e),r}Ei.prototype=Ni.prototype={constructor:Ei,restart:function(t,n,e){if("function"!=typeof t)throw new TypeError("callback is not a function");e=(null==e?Ai():+e)+(null==n?0:+n),this._next||gi===this||(gi?gi._next=this:pi=this,gi=this),this._call=t,this._time=e,zi()},stop:function(){this._call&&(this._call=null,this._time=1/0,zi())}};var Di=$t("start","end","cancel","interrupt"),Ri=[],Fi=0,qi=1,Ui=2,Ii=3,Oi=4,Bi=5,Yi=6;function Li(t,n,e,r,i,o){var a=t.__transition;if(a){if(e in a)return}else t.__transition={};!function(t,n,e){var r,i=t.__transition;function o(t){e.state=qi,e.timer.restart(a,e.delay,e.time),e.delay<=t&&a(t-e.delay)}function a(o){var f,s,l,h;if(e.state!==qi)return c();for(f in i)if((h=i[f]).name===e.name){if(h.state===Ii)return $i(a);h.state===Oi?(h.state=Yi,h.timer.stop(),h.on.call("interrupt",t,t.__data__,h.index,h.group),delete i[f]):+fFi)throw new Error("too late; already scheduled");return e}function Hi(t,n){var e=Xi(t,n);if(e.state>Ii)throw new Error("too late; already running");return e}function Xi(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("transition not found");return e}function Gi(t,n){var e,r,i,o=t.__transition,a=!0;if(o){for(i in n=null==n?null:n+"",o)(e=o[i]).name===n?(r=e.state>Ui&&e.state=0&&(t=t.slice(0,n)),!t||"start"===t}))}(n)?ji:Hi;return function(){var a=o(this,t),u=a.on;u!==r&&(i=(r=u).copy()).on(n,e),a.on=i}}(e,t,n))},attr:function(t,n){var e=It(t),r="transform"===e?ni:Ki;return this.attrTween(t,"function"==typeof n?(e.local?ro:eo)(e,r,Zi(this,"attr."+t,n)):null==n?(e.local?Ji:Qi)(e):(e.local?no:to)(e,r,n))},attrTween:function(t,n){var e="attr."+t;if(arguments.length<2)return(e=this.tween(e))&&e._value;if(null==n)return this.tween(e,null);if("function"!=typeof n)throw new Error;var r=It(t);return this.tween(e,(r.local?io:oo)(r,n))},style:function(t,n,e){var r="transform"==(t+="")?ti:Ki;return null==n?this.styleTween(t,function(t,n){var e,r,i;return function(){var o=_n(this,t),a=(this.style.removeProperty(t),_n(this,t));return o===a?null:o===e&&a===r?i:i=n(e=o,r=a)}}(t,r)).on("end.style."+t,lo(t)):"function"==typeof n?this.styleTween(t,function(t,n,e){var r,i,o;return function(){var a=_n(this,t),u=e(this),c=u+"";return null==u&&(this.style.removeProperty(t),c=u=_n(this,t)),a===c?null:a===r&&c===i?o:(i=c,o=n(r=a,u))}}(t,r,Zi(this,"style."+t,n))).each(function(t,n){var e,r,i,o,a="style."+n,u="end."+a;return function(){var c=Hi(this,t),f=c.on,s=null==c.value[a]?o||(o=lo(n)):void 0;f===e&&i===s||(r=(e=f).copy()).on(u,i=s),c.on=r}}(this._id,t)):this.styleTween(t,function(t,n,e){var r,i,o=e+"";return function(){var a=_n(this,t);return a===o?null:a===r?i:i=n(r=a,e)}}(t,r,n),e).on("end.style."+t,null)},styleTween:function(t,n,e){var r="style."+(t+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(null==n)return this.tween(r,null);if("function"!=typeof n)throw new Error;return this.tween(r,function(t,n,e){var r,i;function o(){var o=n.apply(this,arguments);return o!==i&&(r=(i=o)&&function(t,n,e){return function(r){this.style.setProperty(t,n.call(this,r),e)}}(t,o,e)),r}return o._value=n,o}(t,n,null==e?"":e))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var n=t(this);this.textContent=null==n?"":n}}(Zi(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(null==t)return this.tween(n,null);if("function"!=typeof t)throw new Error;return this.tween(n,function(t){var n,e;function r(){var r=t.apply(this,arguments);return r!==e&&(n=(e=r)&&function(t){return function(n){this.textContent=t.call(this,n)}}(r)),n}return r._value=t,r}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}(this._id))},tween:function(t,n){var e=this._id;if(t+="",arguments.length<2){for(var r,i=Xi(this.node(),e).tween,o=0,a=i.length;o()=>t;function Qo(t,{sourceEvent:n,target:e,selection:r,mode:i,dispatch:o}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},selection:{value:r,enumerable:!0,configurable:!0},mode:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function Jo(t){t.preventDefault(),t.stopImmediatePropagation()}var ta={name:"drag"},na={name:"space"},ea={name:"handle"},ra={name:"center"};const{abs:ia,max:oa,min:aa}=Math;function ua(t){return[+t[0],+t[1]]}function ca(t){return[ua(t[0]),ua(t[1])]}var fa={name:"x",handles:["w","e"].map(va),input:function(t,n){return null==t?null:[[+t[0],n[0][1]],[+t[1],n[1][1]]]},output:function(t){return t&&[t[0][0],t[1][0]]}},sa={name:"y",handles:["n","s"].map(va),input:function(t,n){return null==t?null:[[n[0][0],+t[0]],[n[1][0],+t[1]]]},output:function(t){return t&&[t[0][1],t[1][1]]}},la={name:"xy",handles:["n","w","e","s","nw","ne","sw","se"].map(va),input:function(t){return null==t?null:ca(t)},output:function(t){return t}},ha={overlay:"crosshair",selection:"move",n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},da={e:"w",w:"e",nw:"ne",ne:"nw",se:"sw",sw:"se"},pa={n:"s",s:"n",nw:"sw",ne:"se",se:"ne",sw:"nw"},ga={overlay:1,selection:1,n:null,e:1,s:null,w:-1,nw:-1,ne:1,se:1,sw:-1},ya={overlay:1,selection:1,n:-1,e:null,s:1,w:null,nw:-1,ne:-1,se:1,sw:1};function va(t){return{type:t}}function _a(t){return!t.ctrlKey&&!t.button}function ba(){var t=this.ownerSVGElement||this;return t.hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]}function ma(){return navigator.maxTouchPoints||"ontouchstart"in this}function xa(t){for(;!t.__brush;)if(!(t=t.parentNode))return;return t.__brush}function wa(t){var n,e=ba,r=_a,i=ma,o=!0,a=$t("start","brush","end"),u=6;function c(n){var e=n.property("__brush",g).selectAll(".overlay").data([va("overlay")]);e.enter().append("rect").attr("class","overlay").attr("pointer-events","all").attr("cursor",ha.overlay).merge(e).each((function(){var t=xa(this).extent;Zn(this).attr("x",t[0][0]).attr("y",t[0][1]).attr("width",t[1][0]-t[0][0]).attr("height",t[1][1]-t[0][1])})),n.selectAll(".selection").data([va("selection")]).enter().append("rect").attr("class","selection").attr("cursor",ha.selection).attr("fill","#777").attr("fill-opacity",.3).attr("stroke","#fff").attr("shape-rendering","crispEdges");var r=n.selectAll(".handle").data(t.handles,(function(t){return t.type}));r.exit().remove(),r.enter().append("rect").attr("class",(function(t){return"handle handle--"+t.type})).attr("cursor",(function(t){return ha[t.type]})),n.each(f).attr("fill","none").attr("pointer-events","all").on("mousedown.brush",h).filter(i).on("touchstart.brush",h).on("touchmove.brush",d).on("touchend.brush touchcancel.brush",p).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(){var t=Zn(this),n=xa(this).selection;n?(t.selectAll(".selection").style("display",null).attr("x",n[0][0]).attr("y",n[0][1]).attr("width",n[1][0]-n[0][0]).attr("height",n[1][1]-n[0][1]),t.selectAll(".handle").style("display",null).attr("x",(function(t){return"e"===t.type[t.type.length-1]?n[1][0]-u/2:n[0][0]-u/2})).attr("y",(function(t){return"s"===t.type[0]?n[1][1]-u/2:n[0][1]-u/2})).attr("width",(function(t){return"n"===t.type||"s"===t.type?n[1][0]-n[0][0]+u:u})).attr("height",(function(t){return"e"===t.type||"w"===t.type?n[1][1]-n[0][1]+u:u}))):t.selectAll(".selection,.handle").style("display","none").attr("x",null).attr("y",null).attr("width",null).attr("height",null)}function s(t,n,e){var r=t.__brush.emitter;return!r||e&&r.clean?new l(t,n,e):r}function l(t,n,e){this.that=t,this.args=n,this.state=t.__brush,this.active=0,this.clean=e}function h(e){if((!n||e.touches)&&r.apply(this,arguments)){var i,a,u,c,l,h,d,p,g,y,v,_=this,b=e.target.__data__.type,m="selection"===(o&&e.metaKey?b="overlay":b)?ta:o&&e.altKey?ra:ea,x=t===sa?null:ga[b],w=t===fa?null:ya[b],M=xa(_),T=M.extent,A=M.selection,S=T[0][0],E=T[0][1],N=T[1][0],k=T[1][1],C=0,P=0,z=x&&w&&o&&e.shiftKey,$=Array.from(e.touches||[e],(t=>{const n=t.identifier;return(t=ne(t,_)).point0=t.slice(),t.identifier=n,t}));Gi(_);var D=s(_,arguments,!0).beforestart();if("overlay"===b){A&&(g=!0);const n=[$[0],$[1]||$[0]];M.selection=A=[[i=t===sa?S:aa(n[0][0],n[1][0]),u=t===fa?E:aa(n[0][1],n[1][1])],[l=t===sa?N:oa(n[0][0],n[1][0]),d=t===fa?k:oa(n[0][1],n[1][1])]],$.length>1&&I(e)}else i=A[0][0],u=A[0][1],l=A[1][0],d=A[1][1];a=i,c=u,h=l,p=d;var R=Zn(_).attr("pointer-events","none"),F=R.selectAll(".overlay").attr("cursor",ha[b]);if(e.touches)D.moved=U,D.ended=O;else{var q=Zn(e.view).on("mousemove.brush",U,!0).on("mouseup.brush",O,!0);o&&q.on("keydown.brush",(function(t){switch(t.keyCode){case 16:z=x&&w;break;case 18:m===ea&&(x&&(l=h-C*x,i=a+C*x),w&&(d=p-P*w,u=c+P*w),m=ra,I(t));break;case 32:m!==ea&&m!==ra||(x<0?l=h-C:x>0&&(i=a-C),w<0?d=p-P:w>0&&(u=c-P),m=na,F.attr("cursor",ha.selection),I(t));break;default:return}Jo(t)}),!0).on("keyup.brush",(function(t){switch(t.keyCode){case 16:z&&(y=v=z=!1,I(t));break;case 18:m===ra&&(x<0?l=h:x>0&&(i=a),w<0?d=p:w>0&&(u=c),m=ea,I(t));break;case 32:m===na&&(t.altKey?(x&&(l=h-C*x,i=a+C*x),w&&(d=p-P*w,u=c+P*w),m=ra):(x<0?l=h:x>0&&(i=a),w<0?d=p:w>0&&(u=c),m=ea),F.attr("cursor",ha[b]),I(t));break;default:return}Jo(t)}),!0),ae(e.view)}f.call(_),D.start(e,m.name)}function U(t){for(const n of t.changedTouches||[t])for(const t of $)t.identifier===n.identifier&&(t.cur=ne(n,_));if(z&&!y&&!v&&1===$.length){const t=$[0];ia(t.cur[0]-t[0])>ia(t.cur[1]-t[1])?v=!0:y=!0}for(const t of $)t.cur&&(t[0]=t.cur[0],t[1]=t.cur[1]);g=!0,Jo(t),I(t)}function I(t){const n=$[0],e=n.point0;var r;switch(C=n[0]-e[0],P=n[1]-e[1],m){case na:case ta:x&&(C=oa(S-i,aa(N-l,C)),a=i+C,h=l+C),w&&(P=oa(E-u,aa(k-d,P)),c=u+P,p=d+P);break;case ea:$[1]?(x&&(a=oa(S,aa(N,$[0][0])),h=oa(S,aa(N,$[1][0])),x=1),w&&(c=oa(E,aa(k,$[0][1])),p=oa(E,aa(k,$[1][1])),w=1)):(x<0?(C=oa(S-i,aa(N-i,C)),a=i+C,h=l):x>0&&(C=oa(S-l,aa(N-l,C)),a=i,h=l+C),w<0?(P=oa(E-u,aa(k-u,P)),c=u+P,p=d):w>0&&(P=oa(E-d,aa(k-d,P)),c=u,p=d+P));break;case ra:x&&(a=oa(S,aa(N,i-C*x)),h=oa(S,aa(N,l+C*x))),w&&(c=oa(E,aa(k,u-P*w)),p=oa(E,aa(k,d+P*w)))}ht+e))}function za(t,n){var e=0,r=null,i=null,o=null;function a(a){var u,c=a.length,f=new Array(c),s=Pa(0,c),l=new Array(c*c),h=new Array(c),d=0;a=Float64Array.from({length:c*c},n?(t,n)=>a[n%c][n/c|0]:(t,n)=>a[n/c|0][n%c]);for(let n=0;nr(f[t],f[n])));for(const e of s){const r=n;if(t){const t=Pa(1+~c,c).filter((t=>t<0?a[~t*c+e]:a[e*c+t]));i&&t.sort(((t,n)=>i(t<0?-a[~t*c+e]:a[e*c+t],n<0?-a[~n*c+e]:a[e*c+n])));for(const r of t)if(r<0){(l[~r*c+e]||(l[~r*c+e]={source:null,target:null})).target={index:e,startAngle:n,endAngle:n+=a[~r*c+e]*d,value:a[~r*c+e]}}else{(l[e*c+r]||(l[e*c+r]={source:null,target:null})).source={index:e,startAngle:n,endAngle:n+=a[e*c+r]*d,value:a[e*c+r]}}h[e]={index:e,startAngle:r,endAngle:n,value:f[e]}}else{const t=Pa(0,c).filter((t=>a[e*c+t]||a[t*c+e]));i&&t.sort(((t,n)=>i(a[e*c+t],a[e*c+n])));for(const r of t){let t;if(e=0))throw new Error(`invalid digits: ${t}`);if(n>15)return qa;const e=10**n;return function(t){this._+=t[0];for(let n=1,r=t.length;nRa)if(Math.abs(s*u-c*f)>Ra&&i){let h=e-o,d=r-a,p=u*u+c*c,g=h*h+d*d,y=Math.sqrt(p),v=Math.sqrt(l),_=i*Math.tan(($a-Math.acos((p+l-g)/(2*y*v)))/2),b=_/v,m=_/y;Math.abs(b-1)>Ra&&this._append`L${t+b*f},${n+b*s}`,this._append`A${i},${i},0,0,${+(s*h>f*d)},${this._x1=t+m*u},${this._y1=n+m*c}`}else this._append`L${this._x1=t},${this._y1=n}`;else;}arc(t,n,e,r,i,o){if(t=+t,n=+n,o=!!o,(e=+e)<0)throw new Error(`negative radius: ${e}`);let a=e*Math.cos(r),u=e*Math.sin(r),c=t+a,f=n+u,s=1^o,l=o?r-i:i-r;null===this._x1?this._append`M${c},${f}`:(Math.abs(this._x1-c)>Ra||Math.abs(this._y1-f)>Ra)&&this._append`L${c},${f}`,e&&(l<0&&(l=l%Da+Da),l>Fa?this._append`A${e},${e},0,1,${s},${t-a},${n-u}A${e},${e},0,1,${s},${this._x1=c},${this._y1=f}`:l>Ra&&this._append`A${e},${e},0,${+(l>=$a)},${s},${this._x1=t+e*Math.cos(i)},${this._y1=n+e*Math.sin(i)}`)}rect(t,n,e,r){this._append`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${e=+e}v${+r}h${-e}Z`}toString(){return this._}};function Ia(){return new Ua}Ia.prototype=Ua.prototype;var Oa=Array.prototype.slice;function Ba(t){return function(){return t}}function Ya(t){return t.source}function La(t){return t.target}function ja(t){return t.radius}function Ha(t){return t.startAngle}function Xa(t){return t.endAngle}function Ga(){return 0}function Va(){return 10}function Wa(t){var n=Ya,e=La,r=ja,i=ja,o=Ha,a=Xa,u=Ga,c=null;function f(){var f,s=n.apply(this,arguments),l=e.apply(this,arguments),h=u.apply(this,arguments)/2,d=Oa.call(arguments),p=+r.apply(this,(d[0]=s,d)),g=o.apply(this,d)-Ea,y=a.apply(this,d)-Ea,v=+i.apply(this,(d[0]=l,d)),_=o.apply(this,d)-Ea,b=a.apply(this,d)-Ea;if(c||(c=f=Ia()),h>Ca&&(Ma(y-g)>2*h+Ca?y>g?(g+=h,y-=h):(g-=h,y+=h):g=y=(g+y)/2,Ma(b-_)>2*h+Ca?b>_?(_+=h,b-=h):(_-=h,b+=h):_=b=(_+b)/2),c.moveTo(p*Ta(g),p*Aa(g)),c.arc(0,0,p,g,y),g!==_||y!==b)if(t){var m=v-+t.apply(this,arguments),x=(_+b)/2;c.quadraticCurveTo(0,0,m*Ta(_),m*Aa(_)),c.lineTo(v*Ta(x),v*Aa(x)),c.lineTo(m*Ta(b),m*Aa(b))}else c.quadraticCurveTo(0,0,v*Ta(_),v*Aa(_)),c.arc(0,0,v,_,b);if(c.quadraticCurveTo(0,0,p*Ta(g),p*Aa(g)),c.closePath(),f)return c=null,f+""||null}return t&&(f.headRadius=function(n){return arguments.length?(t="function"==typeof n?n:Ba(+n),f):t}),f.radius=function(t){return arguments.length?(r=i="function"==typeof t?t:Ba(+t),f):r},f.sourceRadius=function(t){return arguments.length?(r="function"==typeof t?t:Ba(+t),f):r},f.targetRadius=function(t){return arguments.length?(i="function"==typeof t?t:Ba(+t),f):i},f.startAngle=function(t){return arguments.length?(o="function"==typeof t?t:Ba(+t),f):o},f.endAngle=function(t){return arguments.length?(a="function"==typeof t?t:Ba(+t),f):a},f.padAngle=function(t){return arguments.length?(u="function"==typeof t?t:Ba(+t),f):u},f.source=function(t){return arguments.length?(n=t,f):n},f.target=function(t){return arguments.length?(e=t,f):e},f.context=function(t){return arguments.length?(c=null==t?null:t,f):c},f}var Za=Array.prototype.slice;function Ka(t,n){return t-n}var Qa=t=>()=>t;function Ja(t,n){for(var e,r=-1,i=n.length;++rr!=d>r&&e<(h-f)*(r-s)/(d-s)+f&&(i=-i)}return i}function nu(t,n,e){var r,i,o,a;return function(t,n,e){return(n[0]-t[0])*(e[1]-t[1])==(e[0]-t[0])*(n[1]-t[1])}(t,n,e)&&(i=t[r=+(t[0]===n[0])],o=e[r],a=n[r],i<=o&&o<=a||a<=o&&o<=i)}function eu(){}var ru=[[],[[[1,1.5],[.5,1]]],[[[1.5,1],[1,1.5]]],[[[1.5,1],[.5,1]]],[[[1,.5],[1.5,1]]],[[[1,1.5],[.5,1]],[[1,.5],[1.5,1]]],[[[1,.5],[1,1.5]]],[[[1,.5],[.5,1]]],[[[.5,1],[1,.5]]],[[[1,1.5],[1,.5]]],[[[.5,1],[1,.5]],[[1.5,1],[1,1.5]]],[[[1.5,1],[1,.5]]],[[[.5,1],[1.5,1]]],[[[1,1.5],[1.5,1]]],[[[.5,1],[1,1.5]]],[]];function iu(){var t=1,n=1,e=K,r=u;function i(t){var n=e(t);if(Array.isArray(n))n=n.slice().sort(Ka);else{const e=M(t,ou);for(n=G(...Z(e[0],e[1],n),n);n[n.length-1]>=e[1];)n.pop();for(;n[1]o(t,n)))}function o(e,i){const o=null==i?NaN:+i;if(isNaN(o))throw new Error(`invalid value: ${i}`);var u=[],c=[];return function(e,r,i){var o,u,c,f,s,l,h=new Array,d=new Array;o=u=-1,f=au(e[0],r),ru[f<<1].forEach(p);for(;++o=r,ru[s<<2].forEach(p);for(;++o0?u.push([t]):c.push(t)})),c.forEach((function(t){for(var n,e=0,r=u.length;e0&&o0&&a=0&&o>=0))throw new Error("invalid size");return t=r,n=o,i},i.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?Qa(Za.call(t)):Qa(t),i):e},i.smooth=function(t){return arguments.length?(r=t?u:eu,i):r===u},i}function ou(t){return isFinite(t)?t:NaN}function au(t,n){return null!=t&&+t>=n}function uu(t){return null==t||isNaN(t=+t)?-1/0:t}function cu(t,n,e,r){const i=r-n,o=e-n,a=isFinite(i)||isFinite(o)?i/o:Math.sign(i)/Math.sign(o);return isNaN(a)?t:t+a-.5}function fu(t){return t[0]}function su(t){return t[1]}function lu(){return 1}const hu=134217729,du=33306690738754706e-32;function pu(t,n,e,r,i){let o,a,u,c,f=n[0],s=r[0],l=0,h=0;s>f==s>-f?(o=f,f=n[++l]):(o=s,s=r[++h]);let d=0;if(lf==s>-f?(a=f+o,u=o-(a-f),f=n[++l]):(a=s+o,u=o-(a-s),s=r[++h]),o=a,0!==u&&(i[d++]=u);lf==s>-f?(a=o+f,c=a-o,u=o-(a-c)+(f-c),f=n[++l]):(a=o+s,c=a-o,u=o-(a-c)+(s-c),s=r[++h]),o=a,0!==u&&(i[d++]=u);for(;l=33306690738754716e-32*f?c:-function(t,n,e,r,i,o,a){let u,c,f,s,l,h,d,p,g,y,v,_,b,m,x,w,M,T;const A=t-i,S=e-i,E=n-o,N=r-o;m=A*N,h=hu*A,d=h-(h-A),p=A-d,h=hu*N,g=h-(h-N),y=N-g,x=p*y-(m-d*g-p*g-d*y),w=E*S,h=hu*E,d=h-(h-E),p=E-d,h=hu*S,g=h-(h-S),y=S-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,_u[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,_u[1]=b-(v+l)+(l-w),T=_+v,l=T-_,_u[2]=_-(T-l)+(v-l),_u[3]=T;let k=function(t,n){let e=n[0];for(let r=1;r=C||-k>=C)return k;if(l=t-A,u=t-(A+l)+(l-i),l=e-S,f=e-(S+l)+(l-i),l=n-E,c=n-(E+l)+(l-o),l=r-N,s=r-(N+l)+(l-o),0===u&&0===c&&0===f&&0===s)return k;if(C=vu*a+du*Math.abs(k),k+=A*s+N*u-(E*f+S*c),k>=C||-k>=C)return k;m=u*N,h=hu*u,d=h-(h-u),p=u-d,h=hu*N,g=h-(h-N),y=N-g,x=p*y-(m-d*g-p*g-d*y),w=c*S,h=hu*c,d=h-(h-c),p=c-d,h=hu*S,g=h-(h-S),y=S-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,wu[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,wu[1]=b-(v+l)+(l-w),T=_+v,l=T-_,wu[2]=_-(T-l)+(v-l),wu[3]=T;const P=pu(4,_u,4,wu,bu);m=A*s,h=hu*A,d=h-(h-A),p=A-d,h=hu*s,g=h-(h-s),y=s-g,x=p*y-(m-d*g-p*g-d*y),w=E*f,h=hu*E,d=h-(h-E),p=E-d,h=hu*f,g=h-(h-f),y=f-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,wu[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,wu[1]=b-(v+l)+(l-w),T=_+v,l=T-_,wu[2]=_-(T-l)+(v-l),wu[3]=T;const z=pu(P,bu,4,wu,mu);m=u*s,h=hu*u,d=h-(h-u),p=u-d,h=hu*s,g=h-(h-s),y=s-g,x=p*y-(m-d*g-p*g-d*y),w=c*f,h=hu*c,d=h-(h-c),p=c-d,h=hu*f,g=h-(h-f),y=f-g,M=p*y-(w-d*g-p*g-d*y),v=x-M,l=x-v,wu[0]=x-(v+l)+(l-M),_=m+v,l=_-m,b=m-(_-l)+(v-l),v=b-w,l=b-v,wu[1]=b-(v+l)+(l-w),T=_+v,l=T-_,wu[2]=_-(T-l)+(v-l),wu[3]=T;const $=pu(z,mu,4,wu,xu);return xu[$-1]}(t,n,e,r,i,o,f)}const Tu=Math.pow(2,-52),Au=new Uint32Array(512);class Su{static from(t,n=zu,e=$u){const r=t.length,i=new Float64Array(2*r);for(let o=0;o>1;if(n>0&&"number"!=typeof t[0])throw new Error("Expected coords to contain numbers.");this.coords=t;const e=Math.max(2*n-5,0);this._triangles=new Uint32Array(3*e),this._halfedges=new Int32Array(3*e),this._hashSize=Math.ceil(Math.sqrt(n)),this._hullPrev=new Uint32Array(n),this._hullNext=new Uint32Array(n),this._hullTri=new Uint32Array(n),this._hullHash=new Int32Array(this._hashSize),this._ids=new Uint32Array(n),this._dists=new Float64Array(n),this.update()}update(){const{coords:t,_hullPrev:n,_hullNext:e,_hullTri:r,_hullHash:i}=this,o=t.length>>1;let a=1/0,u=1/0,c=-1/0,f=-1/0;for(let n=0;nc&&(c=e),r>f&&(f=r),this._ids[n]=n}const s=(a+c)/2,l=(u+f)/2;let h,d,p;for(let n=0,e=1/0;n0&&(d=n,e=r)}let v=t[2*d],_=t[2*d+1],b=1/0;for(let n=0;nr&&(n[e++]=i,r=o)}return this.hull=n.subarray(0,e),this.triangles=new Uint32Array(0),void(this.halfedges=new Uint32Array(0))}if(Mu(g,y,v,_,m,x)<0){const t=d,n=v,e=_;d=p,v=m,_=x,p=t,m=n,x=e}const w=function(t,n,e,r,i,o){const a=e-t,u=r-n,c=i-t,f=o-n,s=a*a+u*u,l=c*c+f*f,h=.5/(a*f-u*c),d=t+(f*s-u*l)*h,p=n+(a*l-c*s)*h;return{x:d,y:p}}(g,y,v,_,m,x);this._cx=w.x,this._cy=w.y;for(let n=0;n0&&Math.abs(f-o)<=Tu&&Math.abs(s-a)<=Tu)continue;if(o=f,a=s,c===h||c===d||c===p)continue;let l=0;for(let t=0,n=this._hashKey(f,s);t=0;)if(y=g,y===l){y=-1;break}if(-1===y)continue;let v=this._addTriangle(y,c,e[y],-1,-1,r[y]);r[c]=this._legalize(v+2),r[y]=v,M++;let _=e[y];for(;g=e[_],Mu(f,s,t[2*_],t[2*_+1],t[2*g],t[2*g+1])<0;)v=this._addTriangle(_,c,g,r[c],-1,r[_]),r[c]=this._legalize(v+2),e[_]=_,M--,_=g;if(y===l)for(;g=n[y],Mu(f,s,t[2*g],t[2*g+1],t[2*y],t[2*y+1])<0;)v=this._addTriangle(g,c,y,-1,r[y],r[g]),this._legalize(v+2),r[g]=v,e[y]=y,M--,y=g;this._hullStart=n[c]=y,e[y]=n[_]=c,e[c]=_,i[this._hashKey(f,s)]=c,i[this._hashKey(t[2*y],t[2*y+1])]=y}this.hull=new Uint32Array(M);for(let t=0,n=this._hullStart;t0?3-e:1+e)/4}(t-this._cx,n-this._cy)*this._hashSize)%this._hashSize}_legalize(t){const{_triangles:n,_halfedges:e,coords:r}=this;let i=0,o=0;for(;;){const a=e[t],u=t-t%3;if(o=u+(t+2)%3,-1===a){if(0===i)break;t=Au[--i];continue}const c=a-a%3,f=u+(t+1)%3,s=c+(a+2)%3,l=n[o],h=n[t],d=n[f],p=n[s];if(Nu(r[2*l],r[2*l+1],r[2*h],r[2*h+1],r[2*d],r[2*d+1],r[2*p],r[2*p+1])){n[t]=p,n[a]=l;const r=e[s];if(-1===r){let n=this._hullStart;do{if(this._hullTri[n]===s){this._hullTri[n]=t;break}n=this._hullPrev[n]}while(n!==this._hullStart)}this._link(t,r),this._link(a,e[o]),this._link(o,s);const u=c+(a+1)%3;i=e&&n[t[a]]>o;)t[a+1]=t[a--];t[a+1]=r}else{let i=e+1,o=r;Pu(t,e+r>>1,i),n[t[e]]>n[t[r]]&&Pu(t,e,r),n[t[i]]>n[t[r]]&&Pu(t,i,r),n[t[e]]>n[t[i]]&&Pu(t,e,i);const a=t[i],u=n[a];for(;;){do{i++}while(n[t[i]]u);if(o=o-e?(Cu(t,n,i,r),Cu(t,n,e,o-1)):(Cu(t,n,e,o-1),Cu(t,n,i,r))}}function Pu(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function zu(t){return t[0]}function $u(t){return t[1]}const Du=1e-6;class Ru{constructor(){this._x0=this._y0=this._x1=this._y1=null,this._=""}moveTo(t,n){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}`}closePath(){null!==this._x1&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")}lineTo(t,n){this._+=`L${this._x1=+t},${this._y1=+n}`}arc(t,n,e){const r=(t=+t)+(e=+e),i=n=+n;if(e<0)throw new Error("negative radius");null===this._x1?this._+=`M${r},${i}`:(Math.abs(this._x1-r)>Du||Math.abs(this._y1-i)>Du)&&(this._+="L"+r+","+i),e&&(this._+=`A${e},${e},0,1,1,${t-e},${n}A${e},${e},0,1,1,${this._x1=r},${this._y1=i}`)}rect(t,n,e,r){this._+=`M${this._x0=this._x1=+t},${this._y0=this._y1=+n}h${+e}v${+r}h${-e}Z`}value(){return this._||null}}class Fu{constructor(){this._=[]}moveTo(t,n){this._.push([t,n])}closePath(){this._.push(this._[0].slice())}lineTo(t,n){this._.push([t,n])}value(){return this._.length?this._:null}}class qu{constructor(t,[n,e,r,i]=[0,0,960,500]){if(!((r=+r)>=(n=+n)&&(i=+i)>=(e=+e)))throw new Error("invalid bounds");this.delaunay=t,this._circumcenters=new Float64Array(2*t.points.length),this.vectors=new Float64Array(2*t.points.length),this.xmax=r,this.xmin=n,this.ymax=i,this.ymin=e,this._init()}update(){return this.delaunay.update(),this._init(),this}_init(){const{delaunay:{points:t,hull:n,triangles:e},vectors:r}=this;let i,o;const a=this.circumcenters=this._circumcenters.subarray(0,e.length/3*2);for(let r,u,c=0,f=0,s=e.length;c1;)i-=2;for(let t=2;t0){if(n>=this.ymax)return null;(i=(this.ymax-n)/r)0){if(t>=this.xmax)return null;(i=(this.xmax-t)/e)this.xmax?2:0)|(nthis.ymax?8:0)}_simplify(t){if(t&&t.length>4){for(let n=0;n2&&function(t){const{triangles:n,coords:e}=t;for(let t=0;t1e-10)return!1}return!0}(t)){this.collinear=Int32Array.from({length:n.length/2},((t,n)=>n)).sort(((t,e)=>n[2*t]-n[2*e]||n[2*t+1]-n[2*e+1]));const t=this.collinear[0],e=this.collinear[this.collinear.length-1],r=[n[2*t],n[2*t+1],n[2*e],n[2*e+1]],i=1e-8*Math.hypot(r[3]-r[1],r[2]-r[0]);for(let t=0,e=n.length/2;t0&&(this.triangles=new Int32Array(3).fill(-1),this.halfedges=new Int32Array(3).fill(-1),this.triangles[0]=r[0],o[r[0]]=1,2===r.length&&(o[r[1]]=0,this.triangles[1]=r[1],this.triangles[2]=r[1]))}voronoi(t){return new qu(this,t)}*neighbors(t){const{inedges:n,hull:e,_hullIndex:r,halfedges:i,triangles:o,collinear:a}=this;if(a){const n=a.indexOf(t);return n>0&&(yield a[n-1]),void(n=0&&i!==e&&i!==r;)e=i;return i}_step(t,n,e){const{inedges:r,hull:i,_hullIndex:o,halfedges:a,triangles:u,points:c}=this;if(-1===r[t]||!c.length)return(t+1)%(c.length>>1);let f=t,s=Iu(n-c[2*t],2)+Iu(e-c[2*t+1],2);const l=r[t];let h=l;do{let r=u[h];const l=Iu(n-c[2*r],2)+Iu(e-c[2*r+1],2);if(l9999?"+"+Ku(n,6):Ku(n,4))+"-"+Ku(t.getUTCMonth()+1,2)+"-"+Ku(t.getUTCDate(),2)+(o?"T"+Ku(e,2)+":"+Ku(r,2)+":"+Ku(i,2)+"."+Ku(o,3)+"Z":i?"T"+Ku(e,2)+":"+Ku(r,2)+":"+Ku(i,2)+"Z":r||e?"T"+Ku(e,2)+":"+Ku(r,2)+"Z":"")}function Ju(t){var n=new RegExp('["'+t+"\n\r]"),e=t.charCodeAt(0);function r(t,n){var r,i=[],o=t.length,a=0,u=0,c=o<=0,f=!1;function s(){if(c)return Hu;if(f)return f=!1,ju;var n,r,i=a;if(t.charCodeAt(i)===Xu){for(;a++=o?c=!0:(r=t.charCodeAt(a++))===Gu?f=!0:r===Vu&&(f=!0,t.charCodeAt(a)===Gu&&++a),t.slice(i+1,n-1).replace(/""/g,'"')}for(;amc(n,e).then((n=>(new DOMParser).parseFromString(n,t)))}var Sc=Ac("application/xml"),Ec=Ac("text/html"),Nc=Ac("image/svg+xml");function kc(t,n,e,r){if(isNaN(n)||isNaN(e))return t;var i,o,a,u,c,f,s,l,h,d=t._root,p={data:r},g=t._x0,y=t._y0,v=t._x1,_=t._y1;if(!d)return t._root=p,t;for(;d.length;)if((f=n>=(o=(g+v)/2))?g=o:v=o,(s=e>=(a=(y+_)/2))?y=a:_=a,i=d,!(d=d[l=s<<1|f]))return i[l]=p,t;if(u=+t._x.call(null,d.data),c=+t._y.call(null,d.data),n===u&&e===c)return p.next=d,i?i[l]=p:t._root=p,t;do{i=i?i[l]=new Array(4):t._root=new Array(4),(f=n>=(o=(g+v)/2))?g=o:v=o,(s=e>=(a=(y+_)/2))?y=a:_=a}while((l=s<<1|f)==(h=(c>=a)<<1|u>=o));return i[h]=d,i[l]=p,t}function Cc(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i}function Pc(t){return t[0]}function zc(t){return t[1]}function $c(t,n,e){var r=new Dc(null==n?Pc:n,null==e?zc:e,NaN,NaN,NaN,NaN);return null==t?r:r.addAll(t)}function Dc(t,n,e,r,i,o){this._x=t,this._y=n,this._x0=e,this._y0=r,this._x1=i,this._y1=o,this._root=void 0}function Rc(t){for(var n={data:t.data},e=n;t=t.next;)e=e.next={data:t.data};return n}var Fc=$c.prototype=Dc.prototype;function qc(t){return function(){return t}}function Uc(t){return 1e-6*(t()-.5)}function Ic(t){return t.x+t.vx}function Oc(t){return t.y+t.vy}function Bc(t){return t.index}function Yc(t,n){var e=t.get(n);if(!e)throw new Error("node not found: "+n);return e}Fc.copy=function(){var t,n,e=new Dc(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=Rc(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=Rc(n));return e},Fc.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t);return kc(this.cover(n,e),n,e,t)},Fc.addAll=function(t){var n,e,r,i,o=t.length,a=new Array(o),u=new Array(o),c=1/0,f=1/0,s=-1/0,l=-1/0;for(e=0;es&&(s=r),il&&(l=i));if(c>s||f>l)return this;for(this.cover(c,f).cover(s,l),e=0;et||t>=i||r>n||n>=o;)switch(u=(nh||(o=c.y0)>d||(a=c.x1)=v)<<1|t>=y)&&(c=p[p.length-1],p[p.length-1]=p[p.length-1-f],p[p.length-1-f]=c)}else{var _=t-+this._x.call(null,g.data),b=n-+this._y.call(null,g.data),m=_*_+b*b;if(m=(u=(p+y)/2))?p=u:y=u,(s=a>=(c=(g+v)/2))?g=c:v=c,n=d,!(d=d[l=s<<1|f]))return this;if(!d.length)break;(n[l+1&3]||n[l+2&3]||n[l+3&3])&&(e=n,h=l)}for(;d.data!==t;)if(r=d,!(d=d.next))return this;return(i=d.next)&&delete d.next,r?(i?r.next=i:delete r.next,this):n?(i?n[l]=i:delete n[l],(d=n[0]||n[1]||n[2]||n[3])&&d===(n[3]||n[2]||n[1]||n[0])&&!d.length&&(e?e[h]=d:this._root=d),this):(this._root=i,this)},Fc.removeAll=function(t){for(var n=0,e=t.length;n1?r[0]+r.slice(2):r,+t.slice(e+1)]}function Zc(t){return(t=Wc(Math.abs(t)))?t[1]:NaN}var Kc,Qc=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function Jc(t){if(!(n=Qc.exec(t)))throw new Error("invalid format: "+t);var n;return new tf({fill:n[1],align:n[2],sign:n[3],symbol:n[4],zero:n[5],width:n[6],comma:n[7],precision:n[8]&&n[8].slice(1),trim:n[9],type:n[10]})}function tf(t){this.fill=void 0===t.fill?" ":t.fill+"",this.align=void 0===t.align?">":t.align+"",this.sign=void 0===t.sign?"-":t.sign+"",this.symbol=void 0===t.symbol?"":t.symbol+"",this.zero=!!t.zero,this.width=void 0===t.width?void 0:+t.width,this.comma=!!t.comma,this.precision=void 0===t.precision?void 0:+t.precision,this.trim=!!t.trim,this.type=void 0===t.type?"":t.type+""}function nf(t,n){var e=Wc(t,n);if(!e)return t+"";var r=e[0],i=e[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}Jc.prototype=tf.prototype,tf.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(void 0===this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(void 0===this.precision?"":"."+Math.max(0,0|this.precision))+(this.trim?"~":"")+this.type};var ef={"%":(t,n)=>(100*t).toFixed(n),b:t=>Math.round(t).toString(2),c:t=>t+"",d:function(t){return Math.abs(t=Math.round(t))>=1e21?t.toLocaleString("en").replace(/,/g,""):t.toString(10)},e:(t,n)=>t.toExponential(n),f:(t,n)=>t.toFixed(n),g:(t,n)=>t.toPrecision(n),o:t=>Math.round(t).toString(8),p:(t,n)=>nf(100*t,n),r:nf,s:function(t,n){var e=Wc(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(Kc=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return o===a?r:o>a?r+new Array(o-a+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+Wc(t,Math.max(0,n+o-1))[0]},X:t=>Math.round(t).toString(16).toUpperCase(),x:t=>Math.round(t).toString(16)};function rf(t){return t}var of,af=Array.prototype.map,uf=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function cf(t){var n,e,r=void 0===t.grouping||void 0===t.thousands?rf:(n=af.call(t.grouping,Number),e=t.thousands+"",function(t,r){for(var i=t.length,o=[],a=0,u=n[0],c=0;i>0&&u>0&&(c+u+1>r&&(u=Math.max(1,r-c)),o.push(t.substring(i-=u,i+u)),!((c+=u+1)>r));)u=n[a=(a+1)%n.length];return o.reverse().join(e)}),i=void 0===t.currency?"":t.currency[0]+"",o=void 0===t.currency?"":t.currency[1]+"",a=void 0===t.decimal?".":t.decimal+"",u=void 0===t.numerals?rf:function(t){return function(n){return n.replace(/[0-9]/g,(function(n){return t[+n]}))}}(af.call(t.numerals,String)),c=void 0===t.percent?"%":t.percent+"",f=void 0===t.minus?"−":t.minus+"",s=void 0===t.nan?"NaN":t.nan+"";function l(t){var n=(t=Jc(t)).fill,e=t.align,l=t.sign,h=t.symbol,d=t.zero,p=t.width,g=t.comma,y=t.precision,v=t.trim,_=t.type;"n"===_?(g=!0,_="g"):ef[_]||(void 0===y&&(y=12),v=!0,_="g"),(d||"0"===n&&"="===e)&&(d=!0,n="0",e="=");var b="$"===h?i:"#"===h&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",m="$"===h?o:/[%p]/.test(_)?c:"",x=ef[_],w=/[defgprs%]/.test(_);function M(t){var i,o,c,h=b,M=m;if("c"===_)M=x(t)+M,t="";else{var T=(t=+t)<0||1/t<0;if(t=isNaN(t)?s:x(Math.abs(t),y),v&&(t=function(t){t:for(var n,e=t.length,r=1,i=-1;r0&&(i=0)}return i>0?t.slice(0,i)+t.slice(n+1):t}(t)),T&&0==+t&&"+"!==l&&(T=!1),h=(T?"("===l?l:f:"-"===l||"("===l?"":l)+h,M=("s"===_?uf[8+Kc/3]:"")+M+(T&&"("===l?")":""),w)for(i=-1,o=t.length;++i(c=t.charCodeAt(i))||c>57){M=(46===c?a+t.slice(i+1):t.slice(i))+M,t=t.slice(0,i);break}}g&&!d&&(t=r(t,1/0));var A=h.length+t.length+M.length,S=A>1)+h+t+M+S.slice(A);break;default:t=S+h+t+M}return u(t)}return y=void 0===y?6:/[gprs]/.test(_)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y)),M.toString=function(){return t+""},M}return{format:l,formatPrefix:function(t,n){var e=l(((t=Jc(t)).type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Zc(n)/3))),i=Math.pow(10,-r),o=uf[8+r/3];return function(t){return e(i*t)+o}}}}function ff(n){return of=cf(n),t.format=of.format,t.formatPrefix=of.formatPrefix,of}function sf(t){return Math.max(0,-Zc(Math.abs(t)))}function lf(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Zc(n)/3)))-Zc(Math.abs(t)))}function hf(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Zc(n)-Zc(t))+1}t.format=void 0,t.formatPrefix=void 0,ff({thousands:",",grouping:[3],currency:["$",""]});var df=1e-6,pf=1e-12,gf=Math.PI,yf=gf/2,vf=gf/4,_f=2*gf,bf=180/gf,mf=gf/180,xf=Math.abs,wf=Math.atan,Mf=Math.atan2,Tf=Math.cos,Af=Math.ceil,Sf=Math.exp,Ef=Math.hypot,Nf=Math.log,kf=Math.pow,Cf=Math.sin,Pf=Math.sign||function(t){return t>0?1:t<0?-1:0},zf=Math.sqrt,$f=Math.tan;function Df(t){return t>1?0:t<-1?gf:Math.acos(t)}function Rf(t){return t>1?yf:t<-1?-yf:Math.asin(t)}function Ff(t){return(t=Cf(t/2))*t}function qf(){}function Uf(t,n){t&&Of.hasOwnProperty(t.type)&&Of[t.type](t,n)}var If={Feature:function(t,n){Uf(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r=0?1:-1,i=r*e,o=Tf(n=(n*=mf)/2+vf),a=Cf(n),u=Vf*a,c=Gf*o+u*Tf(i),f=u*r*Cf(i);as.add(Mf(f,c)),Xf=t,Gf=o,Vf=a}function ds(t){return[Mf(t[1],t[0]),Rf(t[2])]}function ps(t){var n=t[0],e=t[1],r=Tf(e);return[r*Tf(n),r*Cf(n),Cf(e)]}function gs(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function ys(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function vs(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function _s(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function bs(t){var n=zf(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}var ms,xs,ws,Ms,Ts,As,Ss,Es,Ns,ks,Cs,Ps,zs,$s,Ds,Rs,Fs={point:qs,lineStart:Is,lineEnd:Os,polygonStart:function(){Fs.point=Bs,Fs.lineStart=Ys,Fs.lineEnd=Ls,rs=new T,cs.polygonStart()},polygonEnd:function(){cs.polygonEnd(),Fs.point=qs,Fs.lineStart=Is,Fs.lineEnd=Os,as<0?(Wf=-(Kf=180),Zf=-(Qf=90)):rs>df?Qf=90:rs<-df&&(Zf=-90),os[0]=Wf,os[1]=Kf},sphere:function(){Wf=-(Kf=180),Zf=-(Qf=90)}};function qs(t,n){is.push(os=[Wf=t,Kf=t]),nQf&&(Qf=n)}function Us(t,n){var e=ps([t*mf,n*mf]);if(es){var r=ys(es,e),i=ys([r[1],-r[0],0],r);bs(i),i=ds(i);var o,a=t-Jf,u=a>0?1:-1,c=i[0]*bf*u,f=xf(a)>180;f^(u*JfQf&&(Qf=o):f^(u*Jf<(c=(c+360)%360-180)&&cQf&&(Qf=n)),f?tjs(Wf,Kf)&&(Kf=t):js(t,Kf)>js(Wf,Kf)&&(Wf=t):Kf>=Wf?(tKf&&(Kf=t)):t>Jf?js(Wf,t)>js(Wf,Kf)&&(Kf=t):js(t,Kf)>js(Wf,Kf)&&(Wf=t)}else is.push(os=[Wf=t,Kf=t]);nQf&&(Qf=n),es=e,Jf=t}function Is(){Fs.point=Us}function Os(){os[0]=Wf,os[1]=Kf,Fs.point=qs,es=null}function Bs(t,n){if(es){var e=t-Jf;rs.add(xf(e)>180?e+(e>0?360:-360):e)}else ts=t,ns=n;cs.point(t,n),Us(t,n)}function Ys(){cs.lineStart()}function Ls(){Bs(ts,ns),cs.lineEnd(),xf(rs)>df&&(Wf=-(Kf=180)),os[0]=Wf,os[1]=Kf,es=null}function js(t,n){return(n-=t)<0?n+360:n}function Hs(t,n){return t[0]-n[0]}function Xs(t,n){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:ngf&&(t-=Math.round(t/_f)*_f),[t,n]}function ul(t,n,e){return(t%=_f)?n||e?ol(fl(t),sl(n,e)):fl(t):n||e?sl(n,e):al}function cl(t){return function(n,e){return xf(n+=t)>gf&&(n-=Math.round(n/_f)*_f),[n,e]}}function fl(t){var n=cl(t);return n.invert=cl(-t),n}function sl(t,n){var e=Tf(t),r=Cf(t),i=Tf(n),o=Cf(n);function a(t,n){var a=Tf(n),u=Tf(t)*a,c=Cf(t)*a,f=Cf(n),s=f*e+u*r;return[Mf(c*i-s*o,u*e-f*r),Rf(s*i+c*o)]}return a.invert=function(t,n){var a=Tf(n),u=Tf(t)*a,c=Cf(t)*a,f=Cf(n),s=f*i-c*o;return[Mf(c*i+f*o,u*e+s*r),Rf(s*e-u*r)]},a}function ll(t){function n(n){return(n=t(n[0]*mf,n[1]*mf))[0]*=bf,n[1]*=bf,n}return t=ul(t[0]*mf,t[1]*mf,t.length>2?t[2]*mf:0),n.invert=function(n){return(n=t.invert(n[0]*mf,n[1]*mf))[0]*=bf,n[1]*=bf,n},n}function hl(t,n,e,r,i,o){if(e){var a=Tf(n),u=Cf(n),c=r*e;null==i?(i=n+r*_f,o=n-c/2):(i=dl(a,i),o=dl(a,o),(r>0?io)&&(i+=r*_f));for(var f,s=i;r>0?s>o:s1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}}function gl(t,n){return xf(t[0]-n[0])=0;--o)i.point((s=f[o])[0],s[1]);else r(h.x,h.p.x,-1,i);h=h.p}f=(h=h.o).z,d=!d}while(!h.v);i.lineEnd()}}}function _l(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r=0?1:-1,E=S*A,N=E>gf,k=y*w;if(c.add(Mf(k*S*Cf(E),v*M+k*Tf(E))),a+=N?A+S*_f:A,N^p>=e^m>=e){var C=ys(ps(d),ps(b));bs(C);var P=ys(o,C);bs(P);var z=(N^A>=0?-1:1)*Rf(P[2]);(r>z||r===z&&(C[0]||C[1]))&&(u+=N^A>=0?1:-1)}}return(a<-df||a0){for(l||(i.polygonStart(),l=!0),i.lineStart(),t=0;t1&&2&c&&h.push(h.pop().concat(h.shift())),a.push(h.filter(wl))}return h}}function wl(t){return t.length>1}function Ml(t,n){return((t=t.x)[0]<0?t[1]-yf-df:yf-t[1])-((n=n.x)[0]<0?n[1]-yf-df:yf-n[1])}al.invert=al;var Tl=xl((function(){return!0}),(function(t){var n,e=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,a){var u=o>0?gf:-gf,c=xf(o-e);xf(c-gf)0?yf:-yf),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),t.point(o,r),n=0):i!==u&&c>=gf&&(xf(e-i)df?wf((Cf(n)*(o=Tf(r))*Cf(e)-Cf(r)*(i=Tf(n))*Cf(t))/(i*o*a)):(n+r)/2}(e,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(u,r),n=0),t.point(e=o,r=a),i=u},lineEnd:function(){t.lineEnd(),e=r=NaN},clean:function(){return 2-n}}}),(function(t,n,e,r){var i;if(null==t)i=e*yf,r.point(-gf,i),r.point(0,i),r.point(gf,i),r.point(gf,0),r.point(gf,-i),r.point(0,-i),r.point(-gf,-i),r.point(-gf,0),r.point(-gf,i);else if(xf(t[0]-n[0])>df){var o=t[0]0,i=xf(n)>df;function o(t,e){return Tf(t)*Tf(e)>n}function a(t,e,r){var i=[1,0,0],o=ys(ps(t),ps(e)),a=gs(o,o),u=o[0],c=a-u*u;if(!c)return!r&&t;var f=n*a/c,s=-n*u/c,l=ys(i,o),h=_s(i,f);vs(h,_s(o,s));var d=l,p=gs(h,d),g=gs(d,d),y=p*p-g*(gs(h,h)-1);if(!(y<0)){var v=zf(y),_=_s(d,(-p-v)/g);if(vs(_,h),_=ds(_),!r)return _;var b,m=t[0],x=e[0],w=t[1],M=e[1];x0^_[1]<(xf(_[0]-m)gf^(m<=_[0]&&_[0]<=x)){var S=_s(d,(-p+v)/g);return vs(S,h),[_,ds(S)]}}}function u(n,e){var i=r?t:gf-t,o=0;return n<-i?o|=1:n>i&&(o|=2),e<-i?o|=4:e>i&&(o|=8),o}return xl(o,(function(t){var n,e,c,f,s;return{lineStart:function(){f=c=!1,s=1},point:function(l,h){var d,p=[l,h],g=o(l,h),y=r?g?0:u(l,h):g?u(l+(l<0?gf:-gf),h):0;if(!n&&(f=c=g)&&t.lineStart(),g!==c&&(!(d=a(n,p))||gl(n,d)||gl(p,d))&&(p[2]=1),g!==c)s=0,g?(t.lineStart(),d=a(p,n),t.point(d[0],d[1])):(d=a(n,p),t.point(d[0],d[1],2),t.lineEnd()),n=d;else if(i&&n&&r^g){var v;y&e||!(v=a(p,n,!0))||(s=0,r?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1],3)))}!g||n&&gl(n,p)||t.point(p[0],p[1]),n=p,c=g,e=y},lineEnd:function(){c&&t.lineEnd(),n=null},clean:function(){return s|(f&&c)<<1}}}),(function(n,r,i,o){hl(o,t,e,i,n,r)}),r?[0,-t]:[-gf,t-gf])}var Sl,El,Nl,kl,Cl=1e9,Pl=-Cl;function zl(t,n,e,r){function i(i,o){return t<=i&&i<=e&&n<=o&&o<=r}function o(i,o,u,f){var s=0,l=0;if(null==i||(s=a(i,u))!==(l=a(o,u))||c(i,o)<0^u>0)do{f.point(0===s||3===s?t:e,s>1?r:n)}while((s=(s+u+4)%4)!==l);else f.point(o[0],o[1])}function a(r,i){return xf(r[0]-t)0?0:3:xf(r[0]-e)0?2:1:xf(r[1]-n)0?1:0:i>0?3:2}function u(t,n){return c(t.x,n.x)}function c(t,n){var e=a(t,1),r=a(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}return function(a){var c,f,s,l,h,d,p,g,y,v,_,b=a,m=pl(),x={point:w,lineStart:function(){x.point=M,f&&f.push(s=[]);v=!0,y=!1,p=g=NaN},lineEnd:function(){c&&(M(l,h),d&&y&&m.rejoin(),c.push(m.result()));x.point=w,y&&b.lineEnd()},polygonStart:function(){b=m,c=[],f=[],_=!0},polygonEnd:function(){var n=function(){for(var n=0,e=0,i=f.length;er&&(h-o)*(r-a)>(d-a)*(t-o)&&++n:d<=r&&(h-o)*(r-a)<(d-a)*(t-o)&&--n;return n}(),e=_&&n,i=(c=ft(c)).length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&vl(c,u,n,o,a),a.polygonEnd());b=a,c=f=s=null}};function w(t,n){i(t,n)&&b.point(t,n)}function M(o,a){var u=i(o,a);if(f&&s.push([o,a]),v)l=o,h=a,d=u,v=!1,u&&(b.lineStart(),b.point(o,a));else if(u&&y)b.point(o,a);else{var c=[p=Math.max(Pl,Math.min(Cl,p)),g=Math.max(Pl,Math.min(Cl,g))],m=[o=Math.max(Pl,Math.min(Cl,o)),a=Math.max(Pl,Math.min(Cl,a))];!function(t,n,e,r,i,o){var a,u=t[0],c=t[1],f=0,s=1,l=n[0]-u,h=n[1]-c;if(a=e-u,l||!(a>0)){if(a/=l,l<0){if(a0){if(a>s)return;a>f&&(f=a)}if(a=i-u,l||!(a<0)){if(a/=l,l<0){if(a>s)return;a>f&&(f=a)}else if(l>0){if(a0)){if(a/=h,h<0){if(a0){if(a>s)return;a>f&&(f=a)}if(a=o-c,h||!(a<0)){if(a/=h,h<0){if(a>s)return;a>f&&(f=a)}else if(h>0){if(a0&&(t[0]=u+f*l,t[1]=c+f*h),s<1&&(n[0]=u+s*l,n[1]=c+s*h),!0}}}}}(c,m,t,n,e,r)?u&&(b.lineStart(),b.point(o,a),_=!1):(y||(b.lineStart(),b.point(c[0],c[1])),b.point(m[0],m[1]),u||b.lineEnd(),_=!1)}p=o,g=a,y=u}return x}}var $l={sphere:qf,point:qf,lineStart:function(){$l.point=Rl,$l.lineEnd=Dl},lineEnd:qf,polygonStart:qf,polygonEnd:qf};function Dl(){$l.point=$l.lineEnd=qf}function Rl(t,n){El=t*=mf,Nl=Cf(n*=mf),kl=Tf(n),$l.point=Fl}function Fl(t,n){t*=mf;var e=Cf(n*=mf),r=Tf(n),i=xf(t-El),o=Tf(i),a=r*Cf(i),u=kl*e-Nl*r*o,c=Nl*e+kl*r*o;Sl.add(Mf(zf(a*a+u*u),c)),El=t,Nl=e,kl=r}function ql(t){return Sl=new T,Lf(t,$l),+Sl}var Ul=[null,null],Il={type:"LineString",coordinates:Ul};function Ol(t,n){return Ul[0]=t,Ul[1]=n,ql(Il)}var Bl={Feature:function(t,n){return Ll(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++r0&&(i=Ol(t[o],t[o-1]))>0&&e<=i&&r<=i&&(e+r-i)*(1-Math.pow((e-r)/i,2))df})).map(c)).concat(lt(Af(o/d)*d,i,d).filter((function(t){return xf(t%g)>df})).map(f))}return v.lines=function(){return _().map((function(t){return{type:"LineString",coordinates:t}}))},v.outline=function(){return{type:"Polygon",coordinates:[s(r).concat(l(a).slice(1),s(e).reverse().slice(1),l(u).reverse().slice(1))]}},v.extent=function(t){return arguments.length?v.extentMajor(t).extentMinor(t):v.extentMinor()},v.extentMajor=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],u=+t[0][1],a=+t[1][1],r>e&&(t=r,r=e,e=t),u>a&&(t=u,u=a,a=t),v.precision(y)):[[r,u],[e,a]]},v.extentMinor=function(e){return arguments.length?(n=+e[0][0],t=+e[1][0],o=+e[0][1],i=+e[1][1],n>t&&(e=n,n=t,t=e),o>i&&(e=o,o=i,i=e),v.precision(y)):[[n,o],[t,i]]},v.step=function(t){return arguments.length?v.stepMajor(t).stepMinor(t):v.stepMinor()},v.stepMajor=function(t){return arguments.length?(p=+t[0],g=+t[1],v):[p,g]},v.stepMinor=function(t){return arguments.length?(h=+t[0],d=+t[1],v):[h,d]},v.precision=function(h){return arguments.length?(y=+h,c=Wl(o,i,90),f=Zl(n,t,y),s=Wl(u,a,90),l=Zl(r,e,y),v):y},v.extentMajor([[-180,-90+df],[180,90-df]]).extentMinor([[-180,-80-df],[180,80+df]])}var Ql,Jl,th,nh,eh=t=>t,rh=new T,ih=new T,oh={point:qf,lineStart:qf,lineEnd:qf,polygonStart:function(){oh.lineStart=ah,oh.lineEnd=fh},polygonEnd:function(){oh.lineStart=oh.lineEnd=oh.point=qf,rh.add(xf(ih)),ih=new T},result:function(){var t=rh/2;return rh=new T,t}};function ah(){oh.point=uh}function uh(t,n){oh.point=ch,Ql=th=t,Jl=nh=n}function ch(t,n){ih.add(nh*t-th*n),th=t,nh=n}function fh(){ch(Ql,Jl)}var sh=oh,lh=1/0,hh=lh,dh=-lh,ph=dh,gh={point:function(t,n){tdh&&(dh=t);nph&&(ph=n)},lineStart:qf,lineEnd:qf,polygonStart:qf,polygonEnd:qf,result:function(){var t=[[lh,hh],[dh,ph]];return dh=ph=-(hh=lh=1/0),t}};var yh,vh,_h,bh,mh=gh,xh=0,wh=0,Mh=0,Th=0,Ah=0,Sh=0,Eh=0,Nh=0,kh=0,Ch={point:Ph,lineStart:zh,lineEnd:Rh,polygonStart:function(){Ch.lineStart=Fh,Ch.lineEnd=qh},polygonEnd:function(){Ch.point=Ph,Ch.lineStart=zh,Ch.lineEnd=Rh},result:function(){var t=kh?[Eh/kh,Nh/kh]:Sh?[Th/Sh,Ah/Sh]:Mh?[xh/Mh,wh/Mh]:[NaN,NaN];return xh=wh=Mh=Th=Ah=Sh=Eh=Nh=kh=0,t}};function Ph(t,n){xh+=t,wh+=n,++Mh}function zh(){Ch.point=$h}function $h(t,n){Ch.point=Dh,Ph(_h=t,bh=n)}function Dh(t,n){var e=t-_h,r=n-bh,i=zf(e*e+r*r);Th+=i*(_h+t)/2,Ah+=i*(bh+n)/2,Sh+=i,Ph(_h=t,bh=n)}function Rh(){Ch.point=Ph}function Fh(){Ch.point=Uh}function qh(){Ih(yh,vh)}function Uh(t,n){Ch.point=Ih,Ph(yh=_h=t,vh=bh=n)}function Ih(t,n){var e=t-_h,r=n-bh,i=zf(e*e+r*r);Th+=i*(_h+t)/2,Ah+=i*(bh+n)/2,Sh+=i,Eh+=(i=bh*t-_h*n)*(_h+t),Nh+=i*(bh+n),kh+=3*i,Ph(_h=t,bh=n)}var Oh=Ch;function Bh(t){this._context=t}Bh.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._context.moveTo(t,n),this._point=1;break;case 1:this._context.lineTo(t,n);break;default:this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,_f)}},result:qf};var Yh,Lh,jh,Hh,Xh,Gh=new T,Vh={point:qf,lineStart:function(){Vh.point=Wh},lineEnd:function(){Yh&&Zh(Lh,jh),Vh.point=qf},polygonStart:function(){Yh=!0},polygonEnd:function(){Yh=null},result:function(){var t=+Gh;return Gh=new T,t}};function Wh(t,n){Vh.point=Zh,Lh=Hh=t,jh=Xh=n}function Zh(t,n){Hh-=t,Xh-=n,Gh.add(zf(Hh*Hh+Xh*Xh)),Hh=t,Xh=n}var Kh=Vh;let Qh,Jh,td,nd;class ed{constructor(t){this._append=null==t?rd:function(t){const n=Math.floor(t);if(!(n>=0))throw new RangeError(`invalid digits: ${t}`);if(n>15)return rd;if(n!==Qh){const t=10**n;Qh=n,Jh=function(n){let e=1;this._+=n[0];for(const r=n.length;e4*n&&g--){var m=a+h,x=u+d,w=c+p,M=zf(m*m+x*x+w*w),T=Rf(w/=M),A=xf(xf(w)-1)n||xf((v*k+_*C)/b-.5)>.3||a*h+u*d+c*p2?t[2]%360*mf:0,k()):[y*bf,v*bf,_*bf]},E.angle=function(t){return arguments.length?(b=t%360*mf,k()):b*bf},E.reflectX=function(t){return arguments.length?(m=t?-1:1,k()):m<0},E.reflectY=function(t){return arguments.length?(x=t?-1:1,k()):x<0},E.precision=function(t){return arguments.length?(a=dd(u,S=t*t),C()):zf(S)},E.fitExtent=function(t,n){return ud(E,t,n)},E.fitSize=function(t,n){return cd(E,t,n)},E.fitWidth=function(t,n){return fd(E,t,n)},E.fitHeight=function(t,n){return sd(E,t,n)},function(){return n=t.apply(this,arguments),E.invert=n.invert&&N,k()}}function _d(t){var n=0,e=gf/3,r=vd(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*mf,e=t[1]*mf):[n*bf,e*bf]},i}function bd(t,n){var e=Cf(t),r=(e+Cf(n))/2;if(xf(r)0?n<-yf+df&&(n=-yf+df):n>yf-df&&(n=yf-df);var e=i/kf(Nd(n),r);return[e*Cf(r*t),i-e*Tf(r*t)]}return o.invert=function(t,n){var e=i-n,o=Pf(r)*zf(t*t+e*e),a=Mf(t,xf(e))*Pf(e);return e*r<0&&(a-=gf*Pf(t)*Pf(e)),[a/r,2*wf(kf(i/o,1/r))-yf]},o}function Cd(t,n){return[t,n]}function Pd(t,n){var e=Tf(t),r=t===n?Cf(t):(e-Tf(n))/(n-t),i=e/r+t;if(xf(r)=0;)n+=e[r].value;else n=1;t.value=n}function Gd(t,n){t instanceof Map?(t=[void 0,t],void 0===n&&(n=Wd)):void 0===n&&(n=Vd);for(var e,r,i,o,a,u=new Qd(t),c=[u];e=c.pop();)if((i=n(e.data))&&(a=(i=Array.from(i)).length))for(e.children=i,o=a-1;o>=0;--o)c.push(r=i[o]=new Qd(i[o])),r.parent=e,r.depth=e.depth+1;return u.eachBefore(Kd)}function Vd(t){return t.children}function Wd(t){return Array.isArray(t)?t[1]:null}function Zd(t){void 0!==t.data.value&&(t.value=t.data.value),t.data=t.data.data}function Kd(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function Qd(t){this.data=t,this.depth=this.height=0,this.parent=null}function Jd(t){return null==t?null:tp(t)}function tp(t){if("function"!=typeof t)throw new Error;return t}function np(){return 0}function ep(t){return function(){return t}}qd.invert=function(t,n){for(var e,r=n,i=r*r,o=i*i*i,a=0;a<12&&(o=(i=(r-=e=(r*(zd+$d*i+o*(Dd+Rd*i))-n)/(zd+3*$d*i+o*(7*Dd+9*Rd*i)))*r)*i*i,!(xf(e)df&&--i>0);return[t/(.8707+(o=r*r)*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979)),r]},Od.invert=Md(Rf),Bd.invert=Md((function(t){return 2*wf(t)})),Yd.invert=function(t,n){return[-n,2*wf(Sf(t))-yf]},Qd.prototype=Gd.prototype={constructor:Qd,count:function(){return this.eachAfter(Xd)},each:function(t,n){let e=-1;for(const r of this)t.call(n,r,++e,this);return this},eachAfter:function(t,n){for(var e,r,i,o=this,a=[o],u=[],c=-1;o=a.pop();)if(u.push(o),e=o.children)for(r=0,i=e.length;r=0;--r)o.push(e[r]);return this},find:function(t,n){let e=-1;for(const r of this)if(t.call(n,r,++e,this))return r},sum:function(t){return this.eachAfter((function(n){for(var e=+t(n.data)||0,r=n.children,i=r&&r.length;--i>=0;)e+=r[i].value;n.value=e}))},sort:function(t){return this.eachBefore((function(n){n.children&&n.children.sort(t)}))},path:function(t){for(var n=this,e=function(t,n){if(t===n)return t;var e=t.ancestors(),r=n.ancestors(),i=null;t=e.pop(),n=r.pop();for(;t===n;)i=t,t=e.pop(),n=r.pop();return i}(n,t),r=[n];n!==e;)n=n.parent,r.push(n);for(var i=r.length;t!==e;)r.splice(i,0,t),t=t.parent;return r},ancestors:function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},descendants:function(){return Array.from(this)},leaves:function(){var t=[];return this.eachBefore((function(n){n.children||t.push(n)})),t},links:function(){var t=this,n=[];return t.each((function(e){e!==t&&n.push({source:e.parent,target:e})})),n},copy:function(){return Gd(this).eachBefore(Zd)},[Symbol.iterator]:function*(){var t,n,e,r,i=this,o=[i];do{for(t=o.reverse(),o=[];i=t.pop();)if(yield i,n=i.children)for(e=0,r=n.length;e(t=(rp*t+ip)%op)/op}function up(t,n){for(var e,r,i=0,o=(t=function(t,n){let e,r,i=t.length;for(;i;)r=n()*i--|0,e=t[i],t[i]=t[r],t[r]=e;return t}(Array.from(t),n)).length,a=[];i0&&e*e>r*r+i*i}function lp(t,n){for(var e=0;e1e-6?(E+Math.sqrt(E*E-4*S*N))/(2*S):N/E);return{x:r+w+M*k,y:i+T+A*k,r:k}}function gp(t,n,e){var r,i,o,a,u=t.x-n.x,c=t.y-n.y,f=u*u+c*c;f?(i=n.r+e.r,i*=i,a=t.r+e.r,i>(a*=a)?(r=(f+a-i)/(2*f),o=Math.sqrt(Math.max(0,a/f-r*r)),e.x=t.x-r*u-o*c,e.y=t.y-r*c+o*u):(r=(f+i-a)/(2*f),o=Math.sqrt(Math.max(0,i/f-r*r)),e.x=n.x+r*u-o*c,e.y=n.y+r*c+o*u)):(e.x=n.x+e.r,e.y=n.y)}function yp(t,n){var e=t.r+n.r-1e-6,r=n.x-t.x,i=n.y-t.y;return e>0&&e*e>r*r+i*i}function vp(t){var n=t._,e=t.next._,r=n.r+e.r,i=(n.x*e.r+e.x*n.r)/r,o=(n.y*e.r+e.y*n.r)/r;return i*i+o*o}function _p(t){this._=t,this.next=null,this.previous=null}function bp(t,n){if(!(o=(t=function(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}(t)).length))return 0;var e,r,i,o,a,u,c,f,s,l,h;if((e=t[0]).x=0,e.y=0,!(o>1))return e.r;if(r=t[1],e.x=-r.r,r.x=e.r,r.y=0,!(o>2))return e.r+r.r;gp(r,e,i=t[2]),e=new _p(e),r=new _p(r),i=new _p(i),e.next=i.previous=r,r.next=e.previous=i,i.next=r.previous=e;t:for(c=3;c1&&!zp(t,n););return t.slice(0,n)}function zp(t,n){if("/"===t[n]){let e=0;for(;n>0&&"\\"===t[--n];)++e;if(!(1&e))return!0}return!1}function $p(t,n){return t.parent===n.parent?1:2}function Dp(t){var n=t.children;return n?n[0]:t.t}function Rp(t){var n=t.children;return n?n[n.length-1]:t.t}function Fp(t,n,e){var r=e/(n.i-t.i);n.c-=r,n.s+=e,t.c+=r,n.z+=e,n.m+=e}function qp(t,n,e){return t.a.parent===n.parent?t.a:e}function Up(t,n){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=n}function Ip(t,n,e,r,i){for(var o,a=t.children,u=-1,c=a.length,f=t.value&&(i-e)/t.value;++uh&&(h=u),y=s*s*g,(d=Math.max(h/y,y/l))>p){s-=u;break}p=d}v.push(a={value:s,dice:c1?n:1)},e}(Op);var Lp=function t(n){function e(t,e,r,i,o){if((a=t._squarify)&&a.ratio===n)for(var a,u,c,f,s,l=-1,h=a.length,d=t.value;++l1?n:1)},e}(Op);function jp(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(n[1]-t[1])*(e[0]-t[0])}function Hp(t,n){return t[0]-n[0]||t[1]-n[1]}function Xp(t){const n=t.length,e=[0,1];let r,i=2;for(r=2;r1&&jp(t[e[i-2]],t[e[i-1]],t[r])<=0;)--i;e[i++]=r}return e.slice(0,i)}var Gp=Math.random,Vp=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,1===arguments.length?(e=t,t=0):e-=t,function(){return n()*e+t}}return e.source=t,e}(Gp),Wp=function t(n){function e(t,e){return arguments.length<2&&(e=t,t=0),t=Math.floor(t),e=Math.floor(e)-t,function(){return Math.floor(n()*e+t)}}return e.source=t,e}(Gp),Zp=function t(n){function e(t,e){var r,i;return t=null==t?0:+t,e=null==e?1:+e,function(){var o;if(null!=r)o=r,r=null;else do{r=2*n()-1,o=2*n()-1,i=r*r+o*o}while(!i||i>1);return t+e*o*Math.sqrt(-2*Math.log(i)/i)}}return e.source=t,e}(Gp),Kp=function t(n){var e=Zp.source(n);function r(){var t=e.apply(this,arguments);return function(){return Math.exp(t())}}return r.source=t,r}(Gp),Qp=function t(n){function e(t){return(t=+t)<=0?()=>0:function(){for(var e=0,r=t;r>1;--r)e+=n();return e+r*n()}}return e.source=t,e}(Gp),Jp=function t(n){var e=Qp.source(n);function r(t){if(0==(t=+t))return n;var r=e(t);return function(){return r()/t}}return r.source=t,r}(Gp),tg=function t(n){function e(t){return function(){return-Math.log1p(-n())/t}}return e.source=t,e}(Gp),ng=function t(n){function e(t){if((t=+t)<0)throw new RangeError("invalid alpha");return t=1/-t,function(){return Math.pow(1-n(),t)}}return e.source=t,e}(Gp),eg=function t(n){function e(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return function(){return Math.floor(n()+t)}}return e.source=t,e}(Gp),rg=function t(n){function e(t){if((t=+t)<0||t>1)throw new RangeError("invalid p");return 0===t?()=>1/0:1===t?()=>1:(t=Math.log1p(-t),function(){return 1+Math.floor(Math.log1p(-n())/t)})}return e.source=t,e}(Gp),ig=function t(n){var e=Zp.source(n)();function r(t,r){if((t=+t)<0)throw new RangeError("invalid k");if(0===t)return()=>0;if(r=null==r?1:+r,1===t)return()=>-Math.log1p(-n())*r;var i=(t<1?t+1:t)-1/3,o=1/(3*Math.sqrt(i)),a=t<1?()=>Math.pow(n(),1/t):()=>1;return function(){do{do{var t=e(),u=1+o*t}while(u<=0);u*=u*u;var c=1-n()}while(c>=1-.0331*t*t*t*t&&Math.log(c)>=.5*t*t+i*(1-u+Math.log(u)));return i*u*a()*r}}return r.source=t,r}(Gp),og=function t(n){var e=ig.source(n);function r(t,n){var r=e(t),i=e(n);return function(){var t=r();return 0===t?0:t/(t+i())}}return r.source=t,r}(Gp),ag=function t(n){var e=rg.source(n),r=og.source(n);function i(t,n){return t=+t,(n=+n)>=1?()=>t:n<=0?()=>0:function(){for(var i=0,o=t,a=n;o*a>16&&o*(1-a)>16;){var u=Math.floor((o+1)*a),c=r(u,o-u+1)();c<=a?(i+=u,o-=u,a=(a-c)/(1-c)):(o=u-1,a/=c)}for(var f=a<.5,s=e(f?a:1-a),l=s(),h=0;l<=o;++h)l+=s();return i+(f?h:o-h)}}return i.source=t,i}(Gp),ug=function t(n){function e(t,e,r){var i;return 0==(t=+t)?i=t=>-Math.log(t):(t=1/t,i=n=>Math.pow(n,t)),e=null==e?0:+e,r=null==r?1:+r,function(){return e+r*i(-Math.log1p(-n()))}}return e.source=t,e}(Gp),cg=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,function(){return t+e*Math.tan(Math.PI*n())}}return e.source=t,e}(Gp),fg=function t(n){function e(t,e){return t=null==t?0:+t,e=null==e?1:+e,function(){var r=n();return t+e*Math.log(r/(1-r))}}return e.source=t,e}(Gp),sg=function t(n){var e=ig.source(n),r=ag.source(n);function i(t){return function(){for(var i=0,o=t;o>16;){var a=Math.floor(.875*o),u=e(a)();if(u>o)return i+r(a-1,o/u)();i+=a,o-=u}for(var c=-Math.log1p(-n()),f=0;c<=o;++f)c-=Math.log1p(-n());return i+f}}return i.source=t,i}(Gp);const lg=1/4294967296;function hg(t,n){switch(arguments.length){case 0:break;case 1:this.range(t);break;default:this.range(n).domain(t)}return this}function dg(t,n){switch(arguments.length){case 0:break;case 1:"function"==typeof t?this.interpolator(t):this.range(t);break;default:this.domain(t),"function"==typeof n?this.interpolator(n):this.range(n)}return this}const pg=Symbol("implicit");function gg(){var t=new InternMap,n=[],e=[],r=pg;function i(i){let o=t.get(i);if(void 0===o){if(r!==pg)return r;t.set(i,o=n.push(i)-1)}return e[o%e.length]}return i.domain=function(e){if(!arguments.length)return n.slice();n=[],t=new InternMap;for(const r of e)t.has(r)||t.set(r,n.push(r)-1);return i},i.range=function(t){return arguments.length?(e=Array.from(t),i):e.slice()},i.unknown=function(t){return arguments.length?(r=t,i):r},i.copy=function(){return gg(n,e).unknown(r)},hg.apply(i,arguments),i}function yg(){var t,n,e=gg().unknown(void 0),r=e.domain,i=e.range,o=0,a=1,u=!1,c=0,f=0,s=.5;function l(){var e=r().length,l=an&&(e=t,t=n,n=e),function(e){return Math.max(t,Math.min(n,e))}}(a[0],a[t-1])),r=t>2?Mg:wg,i=o=null,l}function l(n){return null==n||isNaN(n=+n)?e:(i||(i=r(a.map(t),u,c)))(t(f(n)))}return l.invert=function(e){return f(n((o||(o=r(u,a.map(t),Yr)))(e)))},l.domain=function(t){return arguments.length?(a=Array.from(t,_g),s()):a.slice()},l.range=function(t){return arguments.length?(u=Array.from(t),s()):u.slice()},l.rangeRound=function(t){return u=Array.from(t),c=Vr,s()},l.clamp=function(t){return arguments.length?(f=!!t||mg,s()):f!==mg},l.interpolate=function(t){return arguments.length?(c=t,s()):c},l.unknown=function(t){return arguments.length?(e=t,l):e},function(e,r){return t=e,n=r,s()}}function Sg(){return Ag()(mg,mg)}function Eg(n,e,r,i){var o,a=W(n,e,r);switch((i=Jc(null==i?",f":i)).type){case"s":var u=Math.max(Math.abs(n),Math.abs(e));return null!=i.precision||isNaN(o=lf(a,u))||(i.precision=o),t.formatPrefix(i,u);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(o=hf(a,Math.max(Math.abs(n),Math.abs(e))))||(i.precision=o-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(o=sf(a))||(i.precision=o-2*("%"===i.type))}return t.format(i)}function Ng(t){var n=t.domain;return t.ticks=function(t){var e=n();return G(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){var r=n();return Eg(r[0],r[r.length-1],null==t?10:t,e)},t.nice=function(e){null==e&&(e=10);var r,i,o=n(),a=0,u=o.length-1,c=o[a],f=o[u],s=10;for(f0;){if((i=V(c,f,e))===r)return o[a]=c,o[u]=f,n(o);if(i>0)c=Math.floor(c/i)*i,f=Math.ceil(f/i)*i;else{if(!(i<0))break;c=Math.ceil(c*i)/i,f=Math.floor(f*i)/i}r=i}return t},t}function kg(t,n){var e,r=0,i=(t=t.slice()).length-1,o=t[r],a=t[i];return a-t(-n,e)}function Fg(n){const e=n(Cg,Pg),r=e.domain;let i,o,a=10;function u(){return i=function(t){return t===Math.E?Math.log:10===t&&Math.log10||2===t&&Math.log2||(t=Math.log(t),n=>Math.log(n)/t)}(a),o=function(t){return 10===t?Dg:t===Math.E?Math.exp:n=>Math.pow(t,n)}(a),r()[0]<0?(i=Rg(i),o=Rg(o),n(zg,$g)):n(Cg,Pg),e}return e.base=function(t){return arguments.length?(a=+t,u()):a},e.domain=function(t){return arguments.length?(r(t),u()):r()},e.ticks=t=>{const n=r();let e=n[0],u=n[n.length-1];const c=u0){for(;l<=h;++l)for(f=1;fu)break;p.push(s)}}else for(;l<=h;++l)for(f=a-1;f>=1;--f)if(s=l>0?f/o(-l):f*o(l),!(su)break;p.push(s)}2*p.length{if(null==n&&(n=10),null==r&&(r=10===a?"s":","),"function"!=typeof r&&(a%1||null!=(r=Jc(r)).precision||(r.trim=!0),r=t.format(r)),n===1/0)return r;const u=Math.max(1,a*n/e.ticks().length);return t=>{let n=t/o(Math.round(i(t)));return n*ar(kg(r(),{floor:t=>o(Math.floor(i(t))),ceil:t=>o(Math.ceil(i(t)))})),e}function qg(t){return function(n){return Math.sign(n)*Math.log1p(Math.abs(n/t))}}function Ug(t){return function(n){return Math.sign(n)*Math.expm1(Math.abs(n))*t}}function Ig(t){var n=1,e=t(qg(n),Ug(n));return e.constant=function(e){return arguments.length?t(qg(n=+e),Ug(n)):n},Ng(e)}function Og(t){return function(n){return n<0?-Math.pow(-n,t):Math.pow(n,t)}}function Bg(t){return t<0?-Math.sqrt(-t):Math.sqrt(t)}function Yg(t){return t<0?-t*t:t*t}function Lg(t){var n=t(mg,mg),e=1;return n.exponent=function(n){return arguments.length?1===(e=+n)?t(mg,mg):.5===e?t(Bg,Yg):t(Og(e),Og(1/e)):e},Ng(n)}function jg(){var t=Lg(Ag());return t.copy=function(){return Tg(t,jg()).exponent(t.exponent())},hg.apply(t,arguments),t}function Hg(t){return Math.sign(t)*t*t}const Xg=new Date,Gg=new Date;function Vg(t,n,e,r){function i(n){return t(n=0===arguments.length?new Date:new Date(+n)),n}return i.floor=n=>(t(n=new Date(+n)),n),i.ceil=e=>(t(e=new Date(e-1)),n(e,1),t(e),e),i.round=t=>{const n=i(t),e=i.ceil(t);return t-n(n(t=new Date(+t),null==e?1:Math.floor(e)),t),i.range=(e,r,o)=>{const a=[];if(e=i.ceil(e),o=null==o?1:Math.floor(o),!(e0))return a;let u;do{a.push(u=new Date(+e)),n(e,o),t(e)}while(uVg((n=>{if(n>=n)for(;t(n),!e(n);)n.setTime(n-1)}),((t,r)=>{if(t>=t)if(r<0)for(;++r<=0;)for(;n(t,-1),!e(t););else for(;--r>=0;)for(;n(t,1),!e(t););})),e&&(i.count=(n,r)=>(Xg.setTime(+n),Gg.setTime(+r),t(Xg),t(Gg),Math.floor(e(Xg,Gg))),i.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?n=>r(n)%t==0:n=>i.count(0,n)%t==0):i:null)),i}const Wg=Vg((()=>{}),((t,n)=>{t.setTime(+t+n)}),((t,n)=>n-t));Wg.every=t=>(t=Math.floor(t),isFinite(t)&&t>0?t>1?Vg((n=>{n.setTime(Math.floor(n/t)*t)}),((n,e)=>{n.setTime(+n+e*t)}),((n,e)=>(e-n)/t)):Wg:null);const Zg=Wg.range,Kg=1e3,Qg=6e4,Jg=36e5,ty=864e5,ny=6048e5,ey=2592e6,ry=31536e6,iy=Vg((t=>{t.setTime(t-t.getMilliseconds())}),((t,n)=>{t.setTime(+t+n*Kg)}),((t,n)=>(n-t)/Kg),(t=>t.getUTCSeconds())),oy=iy.range,ay=Vg((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Kg)}),((t,n)=>{t.setTime(+t+n*Qg)}),((t,n)=>(n-t)/Qg),(t=>t.getMinutes())),uy=ay.range,cy=Vg((t=>{t.setUTCSeconds(0,0)}),((t,n)=>{t.setTime(+t+n*Qg)}),((t,n)=>(n-t)/Qg),(t=>t.getUTCMinutes())),fy=cy.range,sy=Vg((t=>{t.setTime(t-t.getMilliseconds()-t.getSeconds()*Kg-t.getMinutes()*Qg)}),((t,n)=>{t.setTime(+t+n*Jg)}),((t,n)=>(n-t)/Jg),(t=>t.getHours())),ly=sy.range,hy=Vg((t=>{t.setUTCMinutes(0,0,0)}),((t,n)=>{t.setTime(+t+n*Jg)}),((t,n)=>(n-t)/Jg),(t=>t.getUTCHours())),dy=hy.range,py=Vg((t=>t.setHours(0,0,0,0)),((t,n)=>t.setDate(t.getDate()+n)),((t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Qg)/ty),(t=>t.getDate()-1)),gy=py.range,yy=Vg((t=>{t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCDate(t.getUTCDate()+n)}),((t,n)=>(n-t)/ty),(t=>t.getUTCDate()-1)),vy=yy.range,_y=Vg((t=>{t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCDate(t.getUTCDate()+n)}),((t,n)=>(n-t)/ty),(t=>Math.floor(t/ty))),by=_y.range;function my(t){return Vg((n=>{n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)}),((t,n)=>{t.setDate(t.getDate()+7*n)}),((t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Qg)/ny))}const xy=my(0),wy=my(1),My=my(2),Ty=my(3),Ay=my(4),Sy=my(5),Ey=my(6),Ny=xy.range,ky=wy.range,Cy=My.range,Py=Ty.range,zy=Ay.range,$y=Sy.range,Dy=Ey.range;function Ry(t){return Vg((n=>{n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCDate(t.getUTCDate()+7*n)}),((t,n)=>(n-t)/ny))}const Fy=Ry(0),qy=Ry(1),Uy=Ry(2),Iy=Ry(3),Oy=Ry(4),By=Ry(5),Yy=Ry(6),Ly=Fy.range,jy=qy.range,Hy=Uy.range,Xy=Iy.range,Gy=Oy.range,Vy=By.range,Wy=Yy.range,Zy=Vg((t=>{t.setDate(1),t.setHours(0,0,0,0)}),((t,n)=>{t.setMonth(t.getMonth()+n)}),((t,n)=>n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())),(t=>t.getMonth())),Ky=Zy.range,Qy=Vg((t=>{t.setUTCDate(1),t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCMonth(t.getUTCMonth()+n)}),((t,n)=>n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())),(t=>t.getUTCMonth())),Jy=Qy.range,tv=Vg((t=>{t.setMonth(0,1),t.setHours(0,0,0,0)}),((t,n)=>{t.setFullYear(t.getFullYear()+n)}),((t,n)=>n.getFullYear()-t.getFullYear()),(t=>t.getFullYear()));tv.every=t=>isFinite(t=Math.floor(t))&&t>0?Vg((n=>{n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)}),((n,e)=>{n.setFullYear(n.getFullYear()+e*t)})):null;const nv=tv.range,ev=Vg((t=>{t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)}),((t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n)}),((t,n)=>n.getUTCFullYear()-t.getUTCFullYear()),(t=>t.getUTCFullYear()));ev.every=t=>isFinite(t=Math.floor(t))&&t>0?Vg((n=>{n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)}),((n,e)=>{n.setUTCFullYear(n.getUTCFullYear()+e*t)})):null;const rv=ev.range;function iv(t,n,e,i,o,a){const u=[[iy,1,Kg],[iy,5,5e3],[iy,15,15e3],[iy,30,3e4],[a,1,Qg],[a,5,3e5],[a,15,9e5],[a,30,18e5],[o,1,Jg],[o,3,108e5],[o,6,216e5],[o,12,432e5],[i,1,ty],[i,2,1728e5],[e,1,ny],[n,1,ey],[n,3,7776e6],[t,1,ry]];function c(n,e,i){const o=Math.abs(e-n)/i,a=r((([,,t])=>t)).right(u,o);if(a===u.length)return t.every(W(n/ry,e/ry,i));if(0===a)return Wg.every(Math.max(W(n,e,i),1));const[c,f]=u[o/u[a-1][2]=12)]},q:function(t){return 1+~~(t.getMonth()/3)},Q:k_,s:C_,S:Zv,u:Kv,U:Qv,V:t_,w:n_,W:e_,x:null,X:null,y:r_,Y:o_,Z:u_,"%":N_},m={a:function(t){return a[t.getUTCDay()]},A:function(t){return o[t.getUTCDay()]},b:function(t){return c[t.getUTCMonth()]},B:function(t){return u[t.getUTCMonth()]},c:null,d:c_,e:c_,f:d_,g:T_,G:S_,H:f_,I:s_,j:l_,L:h_,m:p_,M:g_,p:function(t){return i[+(t.getUTCHours()>=12)]},q:function(t){return 1+~~(t.getUTCMonth()/3)},Q:k_,s:C_,S:y_,u:v_,U:__,V:m_,w:x_,W:w_,x:null,X:null,y:M_,Y:A_,Z:E_,"%":N_},x={a:function(t,n,e){var r=d.exec(n.slice(e));return r?(t.w=p.get(r[0].toLowerCase()),e+r[0].length):-1},A:function(t,n,e){var r=l.exec(n.slice(e));return r?(t.w=h.get(r[0].toLowerCase()),e+r[0].length):-1},b:function(t,n,e){var r=v.exec(n.slice(e));return r?(t.m=_.get(r[0].toLowerCase()),e+r[0].length):-1},B:function(t,n,e){var r=g.exec(n.slice(e));return r?(t.m=y.get(r[0].toLowerCase()),e+r[0].length):-1},c:function(t,e,r){return T(t,n,e,r)},d:zv,e:zv,f:Uv,g:Nv,G:Ev,H:Dv,I:Dv,j:$v,L:qv,m:Pv,M:Rv,p:function(t,n,e){var r=f.exec(n.slice(e));return r?(t.p=s.get(r[0].toLowerCase()),e+r[0].length):-1},q:Cv,Q:Ov,s:Bv,S:Fv,u:Mv,U:Tv,V:Av,w:wv,W:Sv,x:function(t,n,r){return T(t,e,n,r)},X:function(t,n,e){return T(t,r,n,e)},y:Nv,Y:Ev,Z:kv,"%":Iv};function w(t,n){return function(e){var r,i,o,a=[],u=-1,c=0,f=t.length;for(e instanceof Date||(e=new Date(+e));++u53)return null;"w"in o||(o.w=1),"Z"in o?(i=(r=sv(lv(o.y,0,1))).getUTCDay(),r=i>4||0===i?qy.ceil(r):qy(r),r=yy.offset(r,7*(o.V-1)),o.y=r.getUTCFullYear(),o.m=r.getUTCMonth(),o.d=r.getUTCDate()+(o.w+6)%7):(i=(r=fv(lv(o.y,0,1))).getDay(),r=i>4||0===i?wy.ceil(r):wy(r),r=py.offset(r,7*(o.V-1)),o.y=r.getFullYear(),o.m=r.getMonth(),o.d=r.getDate()+(o.w+6)%7)}else("W"in o||"U"in o)&&("w"in o||(o.w="u"in o?o.u%7:"W"in o?1:0),i="Z"in o?sv(lv(o.y,0,1)).getUTCDay():fv(lv(o.y,0,1)).getDay(),o.m=0,o.d="W"in o?(o.w+6)%7+7*o.W-(i+5)%7:o.w+7*o.U-(i+6)%7);return"Z"in o?(o.H+=o.Z/100|0,o.M+=o.Z%100,sv(o)):fv(o)}}function T(t,n,e,r){for(var i,o,a=0,u=n.length,c=e.length;a=c)return-1;if(37===(i=n.charCodeAt(a++))){if(i=n.charAt(a++),!(o=x[i in pv?n.charAt(a++):i])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}return b.x=w(e,b),b.X=w(r,b),b.c=w(n,b),m.x=w(e,m),m.X=w(r,m),m.c=w(n,m),{format:function(t){var n=w(t+="",b);return n.toString=function(){return t},n},parse:function(t){var n=M(t+="",!1);return n.toString=function(){return t},n},utcFormat:function(t){var n=w(t+="",m);return n.toString=function(){return t},n},utcParse:function(t){var n=M(t+="",!0);return n.toString=function(){return t},n}}}var dv,pv={"-":"",_:" ",0:"0"},gv=/^\s*\d+/,yv=/^%/,vv=/[\\^$*+?|[\]().{}]/g;function _v(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o[t.toLowerCase(),n])))}function wv(t,n,e){var r=gv.exec(n.slice(e,e+1));return r?(t.w=+r[0],e+r[0].length):-1}function Mv(t,n,e){var r=gv.exec(n.slice(e,e+1));return r?(t.u=+r[0],e+r[0].length):-1}function Tv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.U=+r[0],e+r[0].length):-1}function Av(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.V=+r[0],e+r[0].length):-1}function Sv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.W=+r[0],e+r[0].length):-1}function Ev(t,n,e){var r=gv.exec(n.slice(e,e+4));return r?(t.y=+r[0],e+r[0].length):-1}function Nv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.y=+r[0]+(+r[0]>68?1900:2e3),e+r[0].length):-1}function kv(t,n,e){var r=/^(Z)|([+-]\d\d)(?::?(\d\d))?/.exec(n.slice(e,e+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),e+r[0].length):-1}function Cv(t,n,e){var r=gv.exec(n.slice(e,e+1));return r?(t.q=3*r[0]-3,e+r[0].length):-1}function Pv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function zv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function $v(t,n,e){var r=gv.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function Dv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function Rv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function Fv(t,n,e){var r=gv.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function qv(t,n,e){var r=gv.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function Uv(t,n,e){var r=gv.exec(n.slice(e,e+6));return r?(t.L=Math.floor(r[0]/1e3),e+r[0].length):-1}function Iv(t,n,e){var r=yv.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function Ov(t,n,e){var r=gv.exec(n.slice(e));return r?(t.Q=+r[0],e+r[0].length):-1}function Bv(t,n,e){var r=gv.exec(n.slice(e));return r?(t.s=+r[0],e+r[0].length):-1}function Yv(t,n){return _v(t.getDate(),n,2)}function Lv(t,n){return _v(t.getHours(),n,2)}function jv(t,n){return _v(t.getHours()%12||12,n,2)}function Hv(t,n){return _v(1+py.count(tv(t),t),n,3)}function Xv(t,n){return _v(t.getMilliseconds(),n,3)}function Gv(t,n){return Xv(t,n)+"000"}function Vv(t,n){return _v(t.getMonth()+1,n,2)}function Wv(t,n){return _v(t.getMinutes(),n,2)}function Zv(t,n){return _v(t.getSeconds(),n,2)}function Kv(t){var n=t.getDay();return 0===n?7:n}function Qv(t,n){return _v(xy.count(tv(t)-1,t),n,2)}function Jv(t){var n=t.getDay();return n>=4||0===n?Ay(t):Ay.ceil(t)}function t_(t,n){return t=Jv(t),_v(Ay.count(tv(t),t)+(4===tv(t).getDay()),n,2)}function n_(t){return t.getDay()}function e_(t,n){return _v(wy.count(tv(t)-1,t),n,2)}function r_(t,n){return _v(t.getFullYear()%100,n,2)}function i_(t,n){return _v((t=Jv(t)).getFullYear()%100,n,2)}function o_(t,n){return _v(t.getFullYear()%1e4,n,4)}function a_(t,n){var e=t.getDay();return _v((t=e>=4||0===e?Ay(t):Ay.ceil(t)).getFullYear()%1e4,n,4)}function u_(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+_v(n/60|0,"0",2)+_v(n%60,"0",2)}function c_(t,n){return _v(t.getUTCDate(),n,2)}function f_(t,n){return _v(t.getUTCHours(),n,2)}function s_(t,n){return _v(t.getUTCHours()%12||12,n,2)}function l_(t,n){return _v(1+yy.count(ev(t),t),n,3)}function h_(t,n){return _v(t.getUTCMilliseconds(),n,3)}function d_(t,n){return h_(t,n)+"000"}function p_(t,n){return _v(t.getUTCMonth()+1,n,2)}function g_(t,n){return _v(t.getUTCMinutes(),n,2)}function y_(t,n){return _v(t.getUTCSeconds(),n,2)}function v_(t){var n=t.getUTCDay();return 0===n?7:n}function __(t,n){return _v(Fy.count(ev(t)-1,t),n,2)}function b_(t){var n=t.getUTCDay();return n>=4||0===n?Oy(t):Oy.ceil(t)}function m_(t,n){return t=b_(t),_v(Oy.count(ev(t),t)+(4===ev(t).getUTCDay()),n,2)}function x_(t){return t.getUTCDay()}function w_(t,n){return _v(qy.count(ev(t)-1,t),n,2)}function M_(t,n){return _v(t.getUTCFullYear()%100,n,2)}function T_(t,n){return _v((t=b_(t)).getUTCFullYear()%100,n,2)}function A_(t,n){return _v(t.getUTCFullYear()%1e4,n,4)}function S_(t,n){var e=t.getUTCDay();return _v((t=e>=4||0===e?Oy(t):Oy.ceil(t)).getUTCFullYear()%1e4,n,4)}function E_(){return"+0000"}function N_(){return"%"}function k_(t){return+t}function C_(t){return Math.floor(+t/1e3)}function P_(n){return dv=hv(n),t.timeFormat=dv.format,t.timeParse=dv.parse,t.utcFormat=dv.utcFormat,t.utcParse=dv.utcParse,dv}t.timeFormat=void 0,t.timeParse=void 0,t.utcFormat=void 0,t.utcParse=void 0,P_({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var z_="%Y-%m-%dT%H:%M:%S.%LZ";var $_=Date.prototype.toISOString?function(t){return t.toISOString()}:t.utcFormat(z_),D_=$_;var R_=+new Date("2000-01-01T00:00:00.000Z")?function(t){var n=new Date(t);return isNaN(n)?null:n}:t.utcParse(z_),F_=R_;function q_(t){return new Date(t)}function U_(t){return t instanceof Date?+t:+new Date(+t)}function I_(t,n,e,r,i,o,a,u,c,f){var s=Sg(),l=s.invert,h=s.domain,d=f(".%L"),p=f(":%S"),g=f("%I:%M"),y=f("%I %p"),v=f("%a %d"),_=f("%b %d"),b=f("%B"),m=f("%Y");function x(t){return(c(t)Fr(t[t.length-1]),ib=new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571","a6611adfc27df5f5f580cdc1018571","8c510ad8b365f6e8c3c7eae55ab4ac01665e","8c510ad8b365f6e8c3f5f5f5c7eae55ab4ac01665e","8c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e","8c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e","5430058c510abf812ddfc27df6e8c3c7eae580cdc135978f01665e003c30","5430058c510abf812ddfc27df6e8c3f5f5f5c7eae580cdc135978f01665e003c30").map(H_),ob=rb(ib),ab=new Array(3).concat("af8dc3f7f7f77fbf7b","7b3294c2a5cfa6dba0008837","7b3294c2a5cff7f7f7a6dba0008837","762a83af8dc3e7d4e8d9f0d37fbf7b1b7837","762a83af8dc3e7d4e8f7f7f7d9f0d37fbf7b1b7837","762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b7837","762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b7837","40004b762a839970abc2a5cfe7d4e8d9f0d3a6dba05aae611b783700441b","40004b762a839970abc2a5cfe7d4e8f7f7f7d9f0d3a6dba05aae611b783700441b").map(H_),ub=rb(ab),cb=new Array(3).concat("e9a3c9f7f7f7a1d76a","d01c8bf1b6dab8e1864dac26","d01c8bf1b6daf7f7f7b8e1864dac26","c51b7de9a3c9fde0efe6f5d0a1d76a4d9221","c51b7de9a3c9fde0eff7f7f7e6f5d0a1d76a4d9221","c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221","c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221","8e0152c51b7dde77aef1b6dafde0efe6f5d0b8e1867fbc414d9221276419","8e0152c51b7dde77aef1b6dafde0eff7f7f7e6f5d0b8e1867fbc414d9221276419").map(H_),fb=rb(cb),sb=new Array(3).concat("998ec3f7f7f7f1a340","5e3c99b2abd2fdb863e66101","5e3c99b2abd2f7f7f7fdb863e66101","542788998ec3d8daebfee0b6f1a340b35806","542788998ec3d8daebf7f7f7fee0b6f1a340b35806","5427888073acb2abd2d8daebfee0b6fdb863e08214b35806","5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b35806","2d004b5427888073acb2abd2d8daebfee0b6fdb863e08214b358067f3b08","2d004b5427888073acb2abd2d8daebf7f7f7fee0b6fdb863e08214b358067f3b08").map(H_),lb=rb(sb),hb=new Array(3).concat("ef8a62f7f7f767a9cf","ca0020f4a58292c5de0571b0","ca0020f4a582f7f7f792c5de0571b0","b2182bef8a62fddbc7d1e5f067a9cf2166ac","b2182bef8a62fddbc7f7f7f7d1e5f067a9cf2166ac","b2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac","b2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac","67001fb2182bd6604df4a582fddbc7d1e5f092c5de4393c32166ac053061","67001fb2182bd6604df4a582fddbc7f7f7f7d1e5f092c5de4393c32166ac053061").map(H_),db=rb(hb),pb=new Array(3).concat("ef8a62ffffff999999","ca0020f4a582bababa404040","ca0020f4a582ffffffbababa404040","b2182bef8a62fddbc7e0e0e09999994d4d4d","b2182bef8a62fddbc7ffffffe0e0e09999994d4d4d","b2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d","b2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d","67001fb2182bd6604df4a582fddbc7e0e0e0bababa8787874d4d4d1a1a1a","67001fb2182bd6604df4a582fddbc7ffffffe0e0e0bababa8787874d4d4d1a1a1a").map(H_),gb=rb(pb),yb=new Array(3).concat("fc8d59ffffbf91bfdb","d7191cfdae61abd9e92c7bb6","d7191cfdae61ffffbfabd9e92c7bb6","d73027fc8d59fee090e0f3f891bfdb4575b4","d73027fc8d59fee090ffffbfe0f3f891bfdb4575b4","d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4","d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4","a50026d73027f46d43fdae61fee090e0f3f8abd9e974add14575b4313695","a50026d73027f46d43fdae61fee090ffffbfe0f3f8abd9e974add14575b4313695").map(H_),vb=rb(yb),_b=new Array(3).concat("fc8d59ffffbf91cf60","d7191cfdae61a6d96a1a9641","d7191cfdae61ffffbfa6d96a1a9641","d73027fc8d59fee08bd9ef8b91cf601a9850","d73027fc8d59fee08bffffbfd9ef8b91cf601a9850","d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850","d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850","a50026d73027f46d43fdae61fee08bd9ef8ba6d96a66bd631a9850006837","a50026d73027f46d43fdae61fee08bffffbfd9ef8ba6d96a66bd631a9850006837").map(H_),bb=rb(_b),mb=new Array(3).concat("fc8d59ffffbf99d594","d7191cfdae61abdda42b83ba","d7191cfdae61ffffbfabdda42b83ba","d53e4ffc8d59fee08be6f59899d5943288bd","d53e4ffc8d59fee08bffffbfe6f59899d5943288bd","d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd","d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd","9e0142d53e4ff46d43fdae61fee08be6f598abdda466c2a53288bd5e4fa2","9e0142d53e4ff46d43fdae61fee08bffffbfe6f598abdda466c2a53288bd5e4fa2").map(H_),xb=rb(mb),wb=new Array(3).concat("e5f5f999d8c92ca25f","edf8fbb2e2e266c2a4238b45","edf8fbb2e2e266c2a42ca25f006d2c","edf8fbccece699d8c966c2a42ca25f006d2c","edf8fbccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45005824","f7fcfde5f5f9ccece699d8c966c2a441ae76238b45006d2c00441b").map(H_),Mb=rb(wb),Tb=new Array(3).concat("e0ecf49ebcda8856a7","edf8fbb3cde38c96c688419d","edf8fbb3cde38c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68856a7810f7c","edf8fbbfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d6e016b","f7fcfde0ecf4bfd3e69ebcda8c96c68c6bb188419d810f7c4d004b").map(H_),Ab=rb(Tb),Sb=new Array(3).concat("e0f3dba8ddb543a2ca","f0f9e8bae4bc7bccc42b8cbe","f0f9e8bae4bc7bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc443a2ca0868ac","f0f9e8ccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe08589e","f7fcf0e0f3dbccebc5a8ddb57bccc44eb3d32b8cbe0868ac084081").map(H_),Eb=rb(Sb),Nb=new Array(3).concat("fee8c8fdbb84e34a33","fef0d9fdcc8afc8d59d7301f","fef0d9fdcc8afc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59e34a33b30000","fef0d9fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301f990000","fff7ecfee8c8fdd49efdbb84fc8d59ef6548d7301fb300007f0000").map(H_),kb=rb(Nb),Cb=new Array(3).concat("ece2f0a6bddb1c9099","f6eff7bdc9e167a9cf02818a","f6eff7bdc9e167a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf1c9099016c59","f6eff7d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016450","fff7fbece2f0d0d1e6a6bddb67a9cf3690c002818a016c59014636").map(H_),Pb=rb(Cb),zb=new Array(3).concat("ece7f2a6bddb2b8cbe","f1eef6bdc9e174a9cf0570b0","f1eef6bdc9e174a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf2b8cbe045a8d","f1eef6d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0034e7b","fff7fbece7f2d0d1e6a6bddb74a9cf3690c00570b0045a8d023858").map(H_),$b=rb(zb),Db=new Array(3).concat("e7e1efc994c7dd1c77","f1eef6d7b5d8df65b0ce1256","f1eef6d7b5d8df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0dd1c77980043","f1eef6d4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125691003f","f7f4f9e7e1efd4b9dac994c7df65b0e7298ace125698004367001f").map(H_),Rb=rb(Db),Fb=new Array(3).concat("fde0ddfa9fb5c51b8a","feebe2fbb4b9f768a1ae017e","feebe2fbb4b9f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1c51b8a7a0177","feebe2fcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a0177","fff7f3fde0ddfcc5c0fa9fb5f768a1dd3497ae017e7a017749006a").map(H_),qb=rb(Fb),Ub=new Array(3).concat("edf8b17fcdbb2c7fb8","ffffcca1dab441b6c4225ea8","ffffcca1dab441b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c42c7fb8253494","ffffccc7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea80c2c84","ffffd9edf8b1c7e9b47fcdbb41b6c41d91c0225ea8253494081d58").map(H_),Ib=rb(Ub),Ob=new Array(3).concat("f7fcb9addd8e31a354","ffffccc2e69978c679238443","ffffccc2e69978c67931a354006837","ffffccd9f0a3addd8e78c67931a354006837","ffffccd9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443005a32","ffffe5f7fcb9d9f0a3addd8e78c67941ab5d238443006837004529").map(H_),Bb=rb(Ob),Yb=new Array(3).concat("fff7bcfec44fd95f0e","ffffd4fed98efe9929cc4c02","ffffd4fed98efe9929d95f0e993404","ffffd4fee391fec44ffe9929d95f0e993404","ffffd4fee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c028c2d04","ffffe5fff7bcfee391fec44ffe9929ec7014cc4c02993404662506").map(H_),Lb=rb(Yb),jb=new Array(3).concat("ffeda0feb24cf03b20","ffffb2fecc5cfd8d3ce31a1c","ffffb2fecc5cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cf03b20bd0026","ffffb2fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cb10026","ffffccffeda0fed976feb24cfd8d3cfc4e2ae31a1cbd0026800026").map(H_),Hb=rb(jb),Xb=new Array(3).concat("deebf79ecae13182bd","eff3ffbdd7e76baed62171b5","eff3ffbdd7e76baed63182bd08519c","eff3ffc6dbef9ecae16baed63182bd08519c","eff3ffc6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b5084594","f7fbffdeebf7c6dbef9ecae16baed64292c62171b508519c08306b").map(H_),Gb=rb(Xb),Vb=new Array(3).concat("e5f5e0a1d99b31a354","edf8e9bae4b374c476238b45","edf8e9bae4b374c47631a354006d2c","edf8e9c7e9c0a1d99b74c47631a354006d2c","edf8e9c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45005a32","f7fcf5e5f5e0c7e9c0a1d99b74c47641ab5d238b45006d2c00441b").map(H_),Wb=rb(Vb),Zb=new Array(3).concat("f0f0f0bdbdbd636363","f7f7f7cccccc969696525252","f7f7f7cccccc969696636363252525","f7f7f7d9d9d9bdbdbd969696636363252525","f7f7f7d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525","fffffff0f0f0d9d9d9bdbdbd969696737373525252252525000000").map(H_),Kb=rb(Zb),Qb=new Array(3).concat("efedf5bcbddc756bb1","f2f0f7cbc9e29e9ac86a51a3","f2f0f7cbc9e29e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8756bb154278f","f2f0f7dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a34a1486","fcfbfdefedf5dadaebbcbddc9e9ac8807dba6a51a354278f3f007d").map(H_),Jb=rb(Qb),tm=new Array(3).concat("fee0d2fc9272de2d26","fee5d9fcae91fb6a4acb181d","fee5d9fcae91fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4ade2d26a50f15","fee5d9fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181d99000d","fff5f0fee0d2fcbba1fc9272fb6a4aef3b2ccb181da50f1567000d").map(H_),nm=rb(tm),em=new Array(3).concat("fee6cefdae6be6550d","feeddefdbe85fd8d3cd94701","feeddefdbe85fd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3ce6550da63603","feeddefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d948018c2d04","fff5ebfee6cefdd0a2fdae6bfd8d3cf16913d94801a636037f2704").map(H_),rm=rb(em);var im=hi(Tr(300,.5,0),Tr(-240,.5,1)),om=hi(Tr(-100,.75,.35),Tr(80,1.5,.8)),am=hi(Tr(260,.75,.35),Tr(80,1.5,.8)),um=Tr();var cm=Fe(),fm=Math.PI/3,sm=2*Math.PI/3;function lm(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}}var hm=lm(H_("44015444025645045745055946075a46085c460a5d460b5e470d60470e6147106347116447136548146748166848176948186a481a6c481b6d481c6e481d6f481f70482071482173482374482475482576482677482878482979472a7a472c7a472d7b472e7c472f7d46307e46327e46337f463480453581453781453882443983443a83443b84433d84433e85423f854240864241864142874144874045884046883f47883f48893e49893e4a893e4c8a3d4d8a3d4e8a3c4f8a3c508b3b518b3b528b3a538b3a548c39558c39568c38588c38598c375a8c375b8d365c8d365d8d355e8d355f8d34608d34618d33628d33638d32648e32658e31668e31678e31688e30698e306a8e2f6b8e2f6c8e2e6d8e2e6e8e2e6f8e2d708e2d718e2c718e2c728e2c738e2b748e2b758e2a768e2a778e2a788e29798e297a8e297b8e287c8e287d8e277e8e277f8e27808e26818e26828e26828e25838e25848e25858e24868e24878e23888e23898e238a8d228b8d228c8d228d8d218e8d218f8d21908d21918c20928c20928c20938c1f948c1f958b1f968b1f978b1f988b1f998a1f9a8a1e9b8a1e9c891e9d891f9e891f9f881fa0881fa1881fa1871fa28720a38620a48621a58521a68522a78522a88423a98324aa8325ab8225ac8226ad8127ad8128ae8029af7f2ab07f2cb17e2db27d2eb37c2fb47c31b57b32b67a34b67935b77937b87838b9773aba763bbb753dbc743fbc7340bd7242be7144bf7046c06f48c16e4ac16d4cc26c4ec36b50c46a52c56954c56856c66758c7655ac8645cc8635ec96260ca6063cb5f65cb5e67cc5c69cd5b6ccd5a6ece5870cf5773d05675d05477d1537ad1517cd2507fd34e81d34d84d44b86d54989d5488bd6468ed64590d74393d74195d84098d83e9bd93c9dd93ba0da39a2da37a5db36a8db34aadc32addc30b0dd2fb2dd2db5de2bb8de29bade28bddf26c0df25c2df23c5e021c8e020cae11fcde11dd0e11cd2e21bd5e21ad8e219dae319dde318dfe318e2e418e5e419e7e419eae51aece51befe51cf1e51df4e61ef6e620f8e621fbe723fde725")),dm=lm(H_("00000401000501010601010802010902020b02020d03030f03031204041405041606051806051a07061c08071e0907200a08220b09240c09260d0a290e0b2b100b2d110c2f120d31130d34140e36150e38160f3b180f3d19103f1a10421c10441d11471e114920114b21114e22115024125325125527125829115a2a115c2c115f2d11612f116331116533106734106936106b38106c390f6e3b0f703d0f713f0f72400f74420f75440f764510774710784910784a10794c117a4e117b4f127b51127c52137c54137d56147d57157e59157e5a167e5c167f5d177f5f187f601880621980641a80651a80671b80681c816a1c816b1d816d1d816e1e81701f81721f817320817521817621817822817922827b23827c23827e24828025828125818326818426818627818827818928818b29818c29818e2a81902a81912b81932b80942c80962c80982d80992d809b2e7f9c2e7f9e2f7fa02f7fa1307ea3307ea5317ea6317da8327daa337dab337cad347cae347bb0357bb2357bb3367ab5367ab73779b83779ba3878bc3978bd3977bf3a77c03a76c23b75c43c75c53c74c73d73c83e73ca3e72cc3f71cd4071cf4070d0416fd2426fd3436ed5446dd6456cd8456cd9466bdb476adc4869de4968df4a68e04c67e24d66e34e65e44f64e55064e75263e85362e95462ea5661eb5760ec5860ed5a5fee5b5eef5d5ef05f5ef1605df2625df2645cf3655cf4675cf4695cf56b5cf66c5cf66e5cf7705cf7725cf8745cf8765cf9785df9795df97b5dfa7d5efa7f5efa815ffb835ffb8560fb8761fc8961fc8a62fc8c63fc8e64fc9065fd9266fd9467fd9668fd9869fd9a6afd9b6bfe9d6cfe9f6dfea16efea36ffea571fea772fea973feaa74feac76feae77feb078feb27afeb47bfeb67cfeb77efeb97ffebb81febd82febf84fec185fec287fec488fec68afec88cfeca8dfecc8ffecd90fecf92fed194fed395fed597fed799fed89afdda9cfddc9efddea0fde0a1fde2a3fde3a5fde5a7fde7a9fde9aafdebacfcecaefceeb0fcf0b2fcf2b4fcf4b6fcf6b8fcf7b9fcf9bbfcfbbdfcfdbf")),pm=lm(H_("00000401000501010601010802010a02020c02020e03021004031204031405041706041907051b08051d09061f0a07220b07240c08260d08290e092b10092d110a30120a32140b34150b37160b39180c3c190c3e1b0c411c0c431e0c451f0c48210c4a230c4c240c4f260c51280b53290b552b0b572d0b592f0a5b310a5c320a5e340a5f3609613809623909633b09643d09653e0966400a67420a68440a68450a69470b6a490b6a4a0c6b4c0c6b4d0d6c4f0d6c510e6c520e6d540f6d550f6d57106e59106e5a116e5c126e5d126e5f136e61136e62146e64156e65156e67166e69166e6a176e6c186e6d186e6f196e71196e721a6e741a6e751b6e771c6d781c6d7a1d6d7c1d6d7d1e6d7f1e6c801f6c82206c84206b85216b87216b88226a8a226a8c23698d23698f24699025689225689326679526679727669827669a28659b29649d29649f2a63a02a63a22b62a32c61a52c60a62d60a82e5fa92e5eab2f5ead305dae305cb0315bb1325ab3325ab43359b63458b73557b93556ba3655bc3754bd3853bf3952c03a51c13a50c33b4fc43c4ec63d4dc73e4cc83f4bca404acb4149cc4248ce4347cf4446d04545d24644d34743d44842d54a41d74b3fd84c3ed94d3dda4e3cdb503bdd513ade5238df5337e05536e15635e25734e35933e45a31e55c30e65d2fe75e2ee8602de9612bea632aeb6429eb6628ec6726ed6925ee6a24ef6c23ef6e21f06f20f1711ff1731df2741cf3761bf37819f47918f57b17f57d15f67e14f68013f78212f78410f8850ff8870ef8890cf98b0bf98c0af98e09fa9008fa9207fa9407fb9606fb9706fb9906fb9b06fb9d07fc9f07fca108fca309fca50afca60cfca80dfcaa0ffcac11fcae12fcb014fcb216fcb418fbb61afbb81dfbba1ffbbc21fbbe23fac026fac228fac42afac62df9c72ff9c932f9cb35f8cd37f8cf3af7d13df7d340f6d543f6d746f5d949f5db4cf4dd4ff4df53f4e156f3e35af3e55df2e661f2e865f2ea69f1ec6df1ed71f1ef75f1f179f2f27df2f482f3f586f3f68af4f88ef5f992f6fa96f8fb9af9fc9dfafda1fcffa4")),gm=lm(H_("0d088710078813078916078a19068c1b068d1d068e20068f2206902406912605912805922a05932c05942e05952f059631059733059735049837049938049a3a049a3c049b3e049c3f049c41049d43039e44039e46039f48039f4903a04b03a14c02a14e02a25002a25102a35302a35502a45601a45801a45901a55b01a55c01a65e01a66001a66100a76300a76400a76600a76700a86900a86a00a86c00a86e00a86f00a87100a87201a87401a87501a87701a87801a87a02a87b02a87d03a87e03a88004a88104a78305a78405a78606a68707a68808a68a09a58b0aa58d0ba58e0ca48f0da4910ea3920fa39410a29511a19613a19814a099159f9a169f9c179e9d189d9e199da01a9ca11b9ba21d9aa31e9aa51f99a62098a72197a82296aa2395ab2494ac2694ad2793ae2892b02991b12a90b22b8fb32c8eb42e8db52f8cb6308bb7318ab83289ba3388bb3488bc3587bd3786be3885bf3984c03a83c13b82c23c81c33d80c43e7fc5407ec6417dc7427cc8437bc9447aca457acb4679cc4778cc4977cd4a76ce4b75cf4c74d04d73d14e72d24f71d35171d45270d5536fd5546ed6556dd7566cd8576bd9586ada5a6ada5b69db5c68dc5d67dd5e66de5f65de6164df6263e06363e16462e26561e26660e3685fe4695ee56a5de56b5de66c5ce76e5be76f5ae87059e97158e97257ea7457eb7556eb7655ec7754ed7953ed7a52ee7b51ef7c51ef7e50f07f4ff0804ef1814df1834cf2844bf3854bf3874af48849f48948f58b47f58c46f68d45f68f44f79044f79143f79342f89441f89540f9973ff9983ef99a3efa9b3dfa9c3cfa9e3bfb9f3afba139fba238fca338fca537fca636fca835fca934fdab33fdac33fdae32fdaf31fdb130fdb22ffdb42ffdb52efeb72dfeb82cfeba2cfebb2bfebd2afebe2afec029fdc229fdc328fdc527fdc627fdc827fdca26fdcb26fccd25fcce25fcd025fcd225fbd324fbd524fbd724fad824fada24f9dc24f9dd25f8df25f8e125f7e225f7e425f6e626f6e826f5e926f5eb27f4ed27f3ee27f3f027f2f227f1f426f1f525f0f724f0f921"));function ym(t){return function(){return t}}const vm=Math.abs,_m=Math.atan2,bm=Math.cos,mm=Math.max,xm=Math.min,wm=Math.sin,Mm=Math.sqrt,Tm=1e-12,Am=Math.PI,Sm=Am/2,Em=2*Am;function Nm(t){return t>=1?Sm:t<=-1?-Sm:Math.asin(t)}function km(t){let n=3;return t.digits=function(e){if(!arguments.length)return n;if(null==e)n=null;else{const t=Math.floor(e);if(!(t>=0))throw new RangeError(`invalid digits: ${e}`);n=t}return t},()=>new Ua(n)}function Cm(t){return t.innerRadius}function Pm(t){return t.outerRadius}function zm(t){return t.startAngle}function $m(t){return t.endAngle}function Dm(t){return t&&t.padAngle}function Rm(t,n,e,r,i,o,a){var u=t-e,c=n-r,f=(a?o:-o)/Mm(u*u+c*c),s=f*c,l=-f*u,h=t+s,d=n+l,p=e+s,g=r+l,y=(h+p)/2,v=(d+g)/2,_=p-h,b=g-d,m=_*_+b*b,x=i-o,w=h*g-p*d,M=(b<0?-1:1)*Mm(mm(0,x*x*m-w*w)),T=(w*b-_*M)/m,A=(-w*_-b*M)/m,S=(w*b+_*M)/m,E=(-w*_+b*M)/m,N=T-y,k=A-v,C=S-y,P=E-v;return N*N+k*k>C*C+P*P&&(T=S,A=E),{cx:T,cy:A,x01:-s,y01:-l,x11:T*(i/x-1),y11:A*(i/x-1)}}var Fm=Array.prototype.slice;function qm(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Um(t){this._context=t}function Im(t){return new Um(t)}function Om(t){return t[0]}function Bm(t){return t[1]}function Ym(t,n){var e=ym(!0),r=null,i=Im,o=null,a=km(u);function u(u){var c,f,s,l=(u=qm(u)).length,h=!1;for(null==r&&(o=i(s=a())),c=0;c<=l;++c)!(c=l;--h)u.point(v[h],_[h]);u.lineEnd(),u.areaEnd()}y&&(v[s]=+t(d,s,f),_[s]=+n(d,s,f),u.point(r?+r(d,s,f):v[s],e?+e(d,s,f):_[s]))}if(p)return u=null,p+""||null}function s(){return Ym().defined(i).curve(a).context(o)}return t="function"==typeof t?t:void 0===t?Om:ym(+t),n="function"==typeof n?n:ym(void 0===n?0:+n),e="function"==typeof e?e:void 0===e?Bm:ym(+e),f.x=function(n){return arguments.length?(t="function"==typeof n?n:ym(+n),r=null,f):t},f.x0=function(n){return arguments.length?(t="function"==typeof n?n:ym(+n),f):t},f.x1=function(t){return arguments.length?(r=null==t?null:"function"==typeof t?t:ym(+t),f):r},f.y=function(t){return arguments.length?(n="function"==typeof t?t:ym(+t),e=null,f):n},f.y0=function(t){return arguments.length?(n="function"==typeof t?t:ym(+t),f):n},f.y1=function(t){return arguments.length?(e=null==t?null:"function"==typeof t?t:ym(+t),f):e},f.lineX0=f.lineY0=function(){return s().x(t).y(n)},f.lineY1=function(){return s().x(t).y(e)},f.lineX1=function(){return s().x(r).y(n)},f.defined=function(t){return arguments.length?(i="function"==typeof t?t:ym(!!t),f):i},f.curve=function(t){return arguments.length?(a=t,null!=o&&(u=a(o)),f):a},f.context=function(t){return arguments.length?(null==t?o=u=null:u=a(o=t),f):o},f}function jm(t,n){return nt?1:n>=t?0:NaN}function Hm(t){return t}Um.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var Xm=Vm(Im);function Gm(t){this._curve=t}function Vm(t){function n(n){return new Gm(t(n))}return n._curve=t,n}function Wm(t){var n=t.curve;return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t.curve=function(t){return arguments.length?n(Vm(t)):n()._curve},t}function Zm(){return Wm(Ym().curve(Xm))}function Km(){var t=Lm().curve(Xm),n=t.curve,e=t.lineX0,r=t.lineX1,i=t.lineY0,o=t.lineY1;return t.angle=t.x,delete t.x,t.startAngle=t.x0,delete t.x0,t.endAngle=t.x1,delete t.x1,t.radius=t.y,delete t.y,t.innerRadius=t.y0,delete t.y0,t.outerRadius=t.y1,delete t.y1,t.lineStartAngle=function(){return Wm(e())},delete t.lineX0,t.lineEndAngle=function(){return Wm(r())},delete t.lineX1,t.lineInnerRadius=function(){return Wm(i())},delete t.lineY0,t.lineOuterRadius=function(){return Wm(o())},delete t.lineY1,t.curve=function(t){return arguments.length?n(Vm(t)):n()._curve},t}function Qm(t,n){return[(n=+n)*Math.cos(t-=Math.PI/2),n*Math.sin(t)]}Gm.prototype={areaStart:function(){this._curve.areaStart()},areaEnd:function(){this._curve.areaEnd()},lineStart:function(){this._curve.lineStart()},lineEnd:function(){this._curve.lineEnd()},point:function(t,n){this._curve.point(n*Math.sin(t),n*-Math.cos(t))}};class Jm{constructor(t,n){this._context=t,this._x=n}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line}point(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+t)/2,this._y0,this._x0,n,t,n):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+n)/2,t,this._y0,t,n)}this._x0=t,this._y0=n}}class tx{constructor(t){this._context=t}lineStart(){this._point=0}lineEnd(){}point(t,n){if(t=+t,n=+n,0===this._point)this._point=1;else{const e=Qm(this._x0,this._y0),r=Qm(this._x0,this._y0=(this._y0+n)/2),i=Qm(t,this._y0),o=Qm(t,n);this._context.moveTo(...e),this._context.bezierCurveTo(...r,...i,...o)}this._x0=t,this._y0=n}}function nx(t){return new Jm(t,!0)}function ex(t){return new Jm(t,!1)}function rx(t){return new tx(t)}function ix(t){return t.source}function ox(t){return t.target}function ax(t){let n=ix,e=ox,r=Om,i=Bm,o=null,a=null,u=km(c);function c(){let c;const f=Fm.call(arguments),s=n.apply(this,f),l=e.apply(this,f);if(null==o&&(a=t(c=u())),a.lineStart(),f[0]=s,a.point(+r.apply(this,f),+i.apply(this,f)),f[0]=l,a.point(+r.apply(this,f),+i.apply(this,f)),a.lineEnd(),c)return a=null,c+""||null}return c.source=function(t){return arguments.length?(n=t,c):n},c.target=function(t){return arguments.length?(e=t,c):e},c.x=function(t){return arguments.length?(r="function"==typeof t?t:ym(+t),c):r},c.y=function(t){return arguments.length?(i="function"==typeof t?t:ym(+t),c):i},c.context=function(n){return arguments.length?(null==n?o=a=null:a=t(o=n),c):o},c}const ux=Mm(3);var cx={draw(t,n){const e=.59436*Mm(n+xm(n/28,.75)),r=e/2,i=r*ux;t.moveTo(0,e),t.lineTo(0,-e),t.moveTo(-i,-r),t.lineTo(i,r),t.moveTo(-i,r),t.lineTo(i,-r)}},fx={draw(t,n){const e=Mm(n/Am);t.moveTo(e,0),t.arc(0,0,e,0,Em)}},sx={draw(t,n){const e=Mm(n/5)/2;t.moveTo(-3*e,-e),t.lineTo(-e,-e),t.lineTo(-e,-3*e),t.lineTo(e,-3*e),t.lineTo(e,-e),t.lineTo(3*e,-e),t.lineTo(3*e,e),t.lineTo(e,e),t.lineTo(e,3*e),t.lineTo(-e,3*e),t.lineTo(-e,e),t.lineTo(-3*e,e),t.closePath()}};const lx=Mm(1/3),hx=2*lx;var dx={draw(t,n){const e=Mm(n/hx),r=e*lx;t.moveTo(0,-e),t.lineTo(r,0),t.lineTo(0,e),t.lineTo(-r,0),t.closePath()}},px={draw(t,n){const e=.62625*Mm(n);t.moveTo(0,-e),t.lineTo(e,0),t.lineTo(0,e),t.lineTo(-e,0),t.closePath()}},gx={draw(t,n){const e=.87559*Mm(n-xm(n/7,2));t.moveTo(-e,0),t.lineTo(e,0),t.moveTo(0,e),t.lineTo(0,-e)}},yx={draw(t,n){const e=Mm(n),r=-e/2;t.rect(r,r,e,e)}},vx={draw(t,n){const e=.4431*Mm(n);t.moveTo(e,e),t.lineTo(e,-e),t.lineTo(-e,-e),t.lineTo(-e,e),t.closePath()}};const _x=wm(Am/10)/wm(7*Am/10),bx=wm(Em/10)*_x,mx=-bm(Em/10)*_x;var xx={draw(t,n){const e=Mm(.8908130915292852*n),r=bx*e,i=mx*e;t.moveTo(0,-e),t.lineTo(r,i);for(let n=1;n<5;++n){const o=Em*n/5,a=bm(o),u=wm(o);t.lineTo(u*e,-a*e),t.lineTo(a*r-u*i,u*r+a*i)}t.closePath()}};const wx=Mm(3);var Mx={draw(t,n){const e=-Mm(n/(3*wx));t.moveTo(0,2*e),t.lineTo(-wx*e,-e),t.lineTo(wx*e,-e),t.closePath()}};const Tx=Mm(3);var Ax={draw(t,n){const e=.6824*Mm(n),r=e/2,i=e*Tx/2;t.moveTo(0,-e),t.lineTo(i,r),t.lineTo(-i,r),t.closePath()}};const Sx=-.5,Ex=Mm(3)/2,Nx=1/Mm(12),kx=3*(Nx/2+1);var Cx={draw(t,n){const e=Mm(n/kx),r=e/2,i=e*Nx,o=r,a=e*Nx+e,u=-o,c=a;t.moveTo(r,i),t.lineTo(o,a),t.lineTo(u,c),t.lineTo(Sx*r-Ex*i,Ex*r+Sx*i),t.lineTo(Sx*o-Ex*a,Ex*o+Sx*a),t.lineTo(Sx*u-Ex*c,Ex*u+Sx*c),t.lineTo(Sx*r+Ex*i,Sx*i-Ex*r),t.lineTo(Sx*o+Ex*a,Sx*a-Ex*o),t.lineTo(Sx*u+Ex*c,Sx*c-Ex*u),t.closePath()}},Px={draw(t,n){const e=.6189*Mm(n-xm(n/6,1.7));t.moveTo(-e,-e),t.lineTo(e,e),t.moveTo(-e,e),t.lineTo(e,-e)}};const zx=[fx,sx,dx,yx,xx,Mx,Cx],$x=[fx,gx,Px,Ax,cx,vx,px];function Dx(){}function Rx(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function Fx(t){this._context=t}function qx(t){this._context=t}function Ux(t){this._context=t}function Ix(t,n){this._basis=new Fx(t),this._beta=n}Fx.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:Rx(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:Rx(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},qx.prototype={areaStart:Dx,areaEnd:Dx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x2=t,this._y2=n;break;case 1:this._point=2,this._x3=t,this._y3=n;break;case 2:this._point=3,this._x4=t,this._y4=n,this._context.moveTo((this._x0+4*this._x1+t)/6,(this._y0+4*this._y1+n)/6);break;default:Rx(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},Ux.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var e=(this._x0+4*this._x1+t)/6,r=(this._y0+4*this._y1+n)/6;this._line?this._context.lineTo(e,r):this._context.moveTo(e,r);break;case 3:this._point=4;default:Rx(this,t,n)}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n}},Ix.prototype={lineStart:function(){this._x=[],this._y=[],this._basis.lineStart()},lineEnd:function(){var t=this._x,n=this._y,e=t.length-1;if(e>0)for(var r,i=t[0],o=n[0],a=t[e]-i,u=n[e]-o,c=-1;++c<=e;)r=c/e,this._basis.point(this._beta*t[c]+(1-this._beta)*(i+r*a),this._beta*n[c]+(1-this._beta)*(o+r*u));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}};var Ox=function t(n){function e(t){return 1===n?new Fx(t):new Ix(t,n)}return e.beta=function(n){return t(+n)},e}(.85);function Bx(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function Yx(t,n){this._context=t,this._k=(1-n)/6}Yx.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:Bx(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:Bx(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Lx=function t(n){function e(t){return new Yx(t,n)}return e.tension=function(n){return t(+n)},e}(0);function jx(t,n){this._context=t,this._k=(1-n)/6}jx.prototype={areaStart:Dx,areaEnd:Dx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:Bx(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Hx=function t(n){function e(t){return new jx(t,n)}return e.tension=function(n){return t(+n)},e}(0);function Xx(t,n){this._context=t,this._k=(1-n)/6}Xx.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Bx(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Gx=function t(n){function e(t){return new Xx(t,n)}return e.tension=function(n){return t(+n)},e}(0);function Vx(t,n,e){var r=t._x1,i=t._y1,o=t._x2,a=t._y2;if(t._l01_a>Tm){var u=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,c=3*t._l01_a*(t._l01_a+t._l12_a);r=(r*u-t._x0*t._l12_2a+t._x2*t._l01_2a)/c,i=(i*u-t._y0*t._l12_2a+t._y2*t._l01_2a)/c}if(t._l23_a>Tm){var f=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,s=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*f+t._x1*t._l23_2a-n*t._l12_2a)/s,a=(a*f+t._y1*t._l23_2a-e*t._l12_2a)/s}t._context.bezierCurveTo(r,i,o,a,t._x2,t._y2)}function Wx(t,n){this._context=t,this._alpha=n}Wx.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:Vx(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Zx=function t(n){function e(t){return n?new Wx(t,n):new Yx(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function Kx(t,n){this._context=t,this._alpha=n}Kx.prototype={areaStart:Dx,areaEnd:Dx,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:Vx(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var Qx=function t(n){function e(t){return n?new Kx(t,n):new jx(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function Jx(t,n){this._context=t,this._alpha=n}Jx.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,r=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+r*r,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:Vx(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}};var tw=function t(n){function e(t){return n?new Jx(t,n):new Xx(t,0)}return e.alpha=function(n){return t(+n)},e}(.5);function nw(t){this._context=t}function ew(t){return t<0?-1:1}function rw(t,n,e){var r=t._x1-t._x0,i=n-t._x1,o=(t._y1-t._y0)/(r||i<0&&-0),a=(e-t._y1)/(i||r<0&&-0),u=(o*i+a*r)/(r+i);return(ew(o)+ew(a))*Math.min(Math.abs(o),Math.abs(a),.5*Math.abs(u))||0}function iw(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function ow(t,n,e){var r=t._x0,i=t._y0,o=t._x1,a=t._y1,u=(o-r)/3;t._context.bezierCurveTo(r+u,i+u*n,o-u,a-u*e,o,a)}function aw(t){this._context=t}function uw(t){this._context=new cw(t)}function cw(t){this._context=t}function fw(t){this._context=t}function sw(t){var n,e,r=t.length-1,i=new Array(r),o=new Array(r),a=new Array(r);for(i[0]=0,o[0]=2,a[0]=t[0]+2*t[1],n=1;n=0;--n)i[n]=(a[n]-i[n+1])/o[n];for(o[r-1]=(t[r]+i[r-1])/2,n=0;n1)for(var e,r,i,o=1,a=t[n[0]],u=a.length;o=0;)e[n]=n;return e}function pw(t,n){return t[n]}function gw(t){const n=[];return n.key=t,n}function yw(t){var n=t.map(vw);return dw(t).sort((function(t,e){return n[t]-n[e]}))}function vw(t){for(var n,e=-1,r=0,i=t.length,o=-1/0;++eo&&(o=n,r=e);return r}function _w(t){var n=t.map(bw);return dw(t).sort((function(t,e){return n[t]-n[e]}))}function bw(t){for(var n,e=0,r=-1,i=t.length;++r=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,n),this._context.lineTo(t,n);else{var e=this._x*(1-this._t)+t*this._t;this._context.lineTo(e,this._y),this._context.lineTo(e,n)}}this._x=t,this._y=n}};var mw=t=>()=>t;function xw(t,{sourceEvent:n,target:e,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:e,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ww(t,n,e){this.k=t,this.x=n,this.y=e}ww.prototype={constructor:ww,scale:function(t){return 1===t?this:new ww(this.k*t,this.x,this.y)},translate:function(t,n){return 0===t&0===n?this:new ww(this.k,this.x+this.k*t,this.y+this.k*n)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Mw=new ww(1,0,0);function Tw(t){for(;!t.__zoom;)if(!(t=t.parentNode))return Mw;return t.__zoom}function Aw(t){t.stopImmediatePropagation()}function Sw(t){t.preventDefault(),t.stopImmediatePropagation()}function Ew(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function Nw(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function kw(){return this.__zoom||Mw}function Cw(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Pw(){return navigator.maxTouchPoints||"ontouchstart"in this}function zw(t,n,e){var r=t.invertX(n[0][0])-e[0][0],i=t.invertX(n[1][0])-e[1][0],o=t.invertY(n[0][1])-e[0][1],a=t.invertY(n[1][1])-e[1][1];return t.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}Tw.prototype=ww.prototype,t.Adder=T,t.Delaunay=Lu,t.FormatSpecifier=tf,t.InternMap=InternMap,t.InternSet=InternSet,t.Node=Qd,t.Path=Ua,t.Voronoi=qu,t.ZoomTransform=ww,t.active=function(t,n){var e,r,i=t.__transition;if(i)for(r in n=null==n?null:n+"",i)if((e=i[r]).state>qi&&e.name===n)return new po([[t]],Zo,n,+r);return null},t.arc=function(){var t=Cm,n=Pm,e=ym(0),r=null,i=zm,o=$m,a=Dm,u=null,c=km(f);function f(){var f,s,l=+t.apply(this,arguments),h=+n.apply(this,arguments),d=i.apply(this,arguments)-Sm,p=o.apply(this,arguments)-Sm,g=vm(p-d),y=p>d;if(u||(u=f=c()),hTm)if(g>Em-Tm)u.moveTo(h*bm(d),h*wm(d)),u.arc(0,0,h,d,p,!y),l>Tm&&(u.moveTo(l*bm(p),l*wm(p)),u.arc(0,0,l,p,d,y));else{var v,_,b=d,m=p,x=d,w=p,M=g,T=g,A=a.apply(this,arguments)/2,S=A>Tm&&(r?+r.apply(this,arguments):Mm(l*l+h*h)),E=xm(vm(h-l)/2,+e.apply(this,arguments)),N=E,k=E;if(S>Tm){var C=Nm(S/l*wm(A)),P=Nm(S/h*wm(A));(M-=2*C)>Tm?(x+=C*=y?1:-1,w-=C):(M=0,x=w=(d+p)/2),(T-=2*P)>Tm?(b+=P*=y?1:-1,m-=P):(T=0,b=m=(d+p)/2)}var z=h*bm(b),$=h*wm(b),D=l*bm(w),R=l*wm(w);if(E>Tm){var F,q=h*bm(m),U=h*wm(m),I=l*bm(x),O=l*wm(x);if(g1?0:t<-1?Am:Math.acos(t)}((B*L+Y*j)/(Mm(B*B+Y*Y)*Mm(L*L+j*j)))/2),X=Mm(F[0]*F[0]+F[1]*F[1]);N=xm(E,(l-X)/(H-1)),k=xm(E,(h-X)/(H+1))}else N=k=0}T>Tm?k>Tm?(v=Rm(I,O,z,$,h,k,y),_=Rm(q,U,D,R,h,k,y),u.moveTo(v.cx+v.x01,v.cy+v.y01),kTm&&M>Tm?N>Tm?(v=Rm(D,R,q,U,l,-N,y),_=Rm(z,$,I,O,l,-N,y),u.lineTo(v.cx+v.x01,v.cy+v.y01),N=0))throw new RangeError("invalid r");let e=t.length;if(!((e=Math.floor(e))>=0))throw new RangeError("invalid length");if(!e||!n)return t;const r=y(n),i=t.slice();return r(t,i,0,e,1),r(i,t,0,e,1),r(t,i,0,e,1),t},t.blur2=l,t.blurImage=h,t.brush=function(){return wa(la)},t.brushSelection=function(t){var n=t.__brush;return n?n.dim.output(n.selection):null},t.brushX=function(){return wa(fa)},t.brushY=function(){return wa(sa)},t.buffer=function(t,n){return fetch(t,n).then(_c)},t.chord=function(){return za(!1,!1)},t.chordDirected=function(){return za(!0,!1)},t.chordTranspose=function(){return za(!1,!0)},t.cluster=function(){var t=Ld,n=1,e=1,r=!1;function i(i){var o,a=0;i.eachAfter((function(n){var e=n.children;e?(n.x=function(t){return t.reduce(jd,0)/t.length}(e),n.y=function(t){return 1+t.reduce(Hd,0)}(e)):(n.x=o?a+=t(n,o):0,n.y=0,o=n)}));var u=function(t){for(var n;n=t.children;)t=n[0];return t}(i),c=function(t){for(var n;n=t.children;)t=n[n.length-1];return t}(i),f=u.x-t(u,c)/2,s=c.x+t(c,u)/2;return i.eachAfter(r?function(t){t.x=(t.x-i.x)*n,t.y=(i.y-t.y)*e}:function(t){t.x=(t.x-f)/(s-f)*n,t.y=(1-(i.y?t.y/i.y:1))*e})}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.color=ze,t.contourDensity=function(){var t=fu,n=su,e=lu,r=960,i=500,o=20,a=2,u=3*o,c=r+2*u>>a,f=i+2*u>>a,s=Qa(20);function h(r){var i=new Float32Array(c*f),s=Math.pow(2,-a),h=-1;for(const o of r){var d=(t(o,++h,r)+u)*s,p=(n(o,h,r)+u)*s,g=+e(o,h,r);if(g&&d>=0&&d=0&&pt*r)))(n).map(((t,n)=>(t.value=+e[n],p(t))))}function p(t){return t.coordinates.forEach(g),t}function g(t){t.forEach(y)}function y(t){t.forEach(v)}function v(t){t[0]=t[0]*Math.pow(2,a)-u,t[1]=t[1]*Math.pow(2,a)-u}function _(){return c=r+2*(u=3*o)>>a,f=i+2*u>>a,d}return d.contours=function(t){var n=h(t),e=iu().size([c,f]),r=Math.pow(2,2*a),i=t=>{t=+t;var i=p(e.contour(n,t*r));return i.value=t,i};return Object.defineProperty(i,"max",{get:()=>J(n)/r}),i},d.x=function(n){return arguments.length?(t="function"==typeof n?n:Qa(+n),d):t},d.y=function(t){return arguments.length?(n="function"==typeof t?t:Qa(+t),d):n},d.weight=function(t){return arguments.length?(e="function"==typeof t?t:Qa(+t),d):e},d.size=function(t){if(!arguments.length)return[r,i];var n=+t[0],e=+t[1];if(!(n>=0&&e>=0))throw new Error("invalid size");return r=n,i=e,_()},d.cellSize=function(t){if(!arguments.length)return 1<=1))throw new Error("invalid cell size");return a=Math.floor(Math.log(t)/Math.LN2),_()},d.thresholds=function(t){return arguments.length?(s="function"==typeof t?t:Array.isArray(t)?Qa(Za.call(t)):Qa(t),d):s},d.bandwidth=function(t){if(!arguments.length)return Math.sqrt(o*(o+1));if(!((t=+t)>=0))throw new Error("invalid bandwidth");return o=(Math.sqrt(4*t*t+1)-1)/2,_()},d},t.contours=iu,t.count=v,t.create=function(t){return Zn(Yt(t).call(document.documentElement))},t.creator=Yt,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),e=(t=t.map(m)).map(_),r=t.length-1,i=new Array(r+1).fill(0),o=[];if(r<0||e.some(b))return o;for(;;){o.push(i.map(((n,e)=>t[e][n])));let a=r;for(;++i[a]===e[a];){if(0===a)return n?o.map(n):o;i[a--]=0}}},t.csv=wc,t.csvFormat=rc,t.csvFormatBody=ic,t.csvFormatRow=ac,t.csvFormatRows=oc,t.csvFormatValue=uc,t.csvParse=nc,t.csvParseRows=ec,t.cubehelix=Tr,t.cumsum=function(t,n){var e=0,r=0;return Float64Array.from(t,void 0===n?t=>e+=+t||0:i=>e+=+n(i,r++,t)||0)},t.curveBasis=function(t){return new Fx(t)},t.curveBasisClosed=function(t){return new qx(t)},t.curveBasisOpen=function(t){return new Ux(t)},t.curveBumpX=nx,t.curveBumpY=ex,t.curveBundle=Ox,t.curveCardinal=Lx,t.curveCardinalClosed=Hx,t.curveCardinalOpen=Gx,t.curveCatmullRom=Zx,t.curveCatmullRomClosed=Qx,t.curveCatmullRomOpen=tw,t.curveLinear=Im,t.curveLinearClosed=function(t){return new nw(t)},t.curveMonotoneX=function(t){return new aw(t)},t.curveMonotoneY=function(t){return new uw(t)},t.curveNatural=function(t){return new fw(t)},t.curveStep=function(t){return new lw(t,.5)},t.curveStepAfter=function(t){return new lw(t,1)},t.curveStepBefore=function(t){return new lw(t,0)},t.descending=e,t.deviation=w,t.difference=function(t,...n){t=new InternSet(t);for(const e of n)for(const n of e)t.delete(n);return t},t.disjoint=function(t,n){const e=n[Symbol.iterator](),r=new InternSet;for(const n of t){if(r.has(n))return!1;let t,i;for(;({value:t,done:i}=e.next())&&!i;){if(Object.is(n,t))return!1;r.add(t)}}return!0},t.dispatch=$t,t.drag=function(){var t,n,e,r,i=se,o=le,a=he,u=de,c={},f=$t("start","drag","end"),s=0,l=0;function h(t){t.on("mousedown.drag",d).filter(u).on("touchstart.drag",y).on("touchmove.drag",v,ee).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function d(a,u){if(!r&&i.call(this,a,u)){var c=b(this,o.call(this,a,u),a,u,"mouse");c&&(Zn(a.view).on("mousemove.drag",p,re).on("mouseup.drag",g,re),ae(a.view),ie(a),e=!1,t=a.clientX,n=a.clientY,c("start",a))}}function p(r){if(oe(r),!e){var i=r.clientX-t,o=r.clientY-n;e=i*i+o*o>l}c.mouse("drag",r)}function g(t){Zn(t.view).on("mousemove.drag mouseup.drag",null),ue(t.view,e),oe(t),c.mouse("end",t)}function y(t,n){if(i.call(this,t,n)){var e,r,a=t.changedTouches,u=o.call(this,t,n),c=a.length;for(e=0;e+t,t.easePoly=wo,t.easePolyIn=mo,t.easePolyInOut=wo,t.easePolyOut=xo,t.easeQuad=_o,t.easeQuadIn=function(t){return t*t},t.easeQuadInOut=_o,t.easeQuadOut=function(t){return t*(2-t)},t.easeSin=Ao,t.easeSinIn=function(t){return 1==+t?1:1-Math.cos(t*To)},t.easeSinInOut=Ao,t.easeSinOut=function(t){return Math.sin(t*To)},t.every=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let e=-1;for(const r of t)if(!n(r,++e,t))return!1;return!0},t.extent=M,t.fcumsum=function(t,n){const e=new T;let r=-1;return Float64Array.from(t,void 0===n?t=>e.add(+t||0):i=>e.add(+n(i,++r,t)||0))},t.filter=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");const e=[];let r=-1;for(const i of t)n(i,++r,t)&&e.push(i);return e},t.flatGroup=function(t,...n){return z(P(t,...n),n)},t.flatRollup=function(t,n,...e){return z(D(t,n,...e),e)},t.forceCenter=function(t,n){var e,r=1;function i(){var i,o,a=e.length,u=0,c=0;for(i=0;if+p||os+p||ac.index){var g=f-u.x-u.vx,y=s-u.y-u.vy,v=g*g+y*y;vt.r&&(t.r=t[n].r)}function c(){if(n){var r,i,o=n.length;for(e=new Array(o),r=0;r[u(t,n,r),t])));for(a=0,i=new Array(f);a=u)){(t.data!==n||t.next)&&(0===l&&(p+=(l=Uc(e))*l),0===h&&(p+=(h=Uc(e))*h),p(t=(Lc*t+jc)%Hc)/Hc}();function l(){h(),f.call("tick",n),e1?(null==e?u.delete(t):u.set(t,p(e)),n):u.get(t)},find:function(n,e,r){var i,o,a,u,c,f=0,s=t.length;for(null==r?r=1/0:r*=r,f=0;f1?(f.on(t,e),n):f.on(t)}}},t.forceX=function(t){var n,e,r,i=qc(.1);function o(t){for(var i,o=0,a=n.length;o=.12&&i<.234&&r>=-.425&&r<-.214?u:i>=.166&&i<.234&&r>=-.214&&r<-.115?c:a).invert(t)},s.stream=function(e){return t&&n===e?t:(r=[a.stream(n=e),u.stream(e),c.stream(e)],i=r.length,t={point:function(t,n){for(var e=-1;++ejs(r[0],r[1])&&(r[1]=i[1]),js(i[0],r[1])>js(r[0],r[1])&&(r[0]=i[0])):o.push(r=i);for(a=-1/0,n=0,r=o[e=o.length-1];n<=e;r=i,++n)i=o[n],(u=js(r[1],i[0]))>a&&(a=u,Wf=i[0],Kf=r[1])}return is=os=null,Wf===1/0||Zf===1/0?[[NaN,NaN],[NaN,NaN]]:[[Wf,Zf],[Kf,Qf]]},t.geoCentroid=function(t){ms=xs=ws=Ms=Ts=As=Ss=Es=0,Ns=new T,ks=new T,Cs=new T,Lf(t,Gs);var n=+Ns,e=+ks,r=+Cs,i=Ef(n,e,r);return i=0))throw new RangeError(`invalid digits: ${t}`);i=n}return null===n&&(r=new ed(i)),a},a.projection(t).digits(i).context(n)},t.geoProjection=yd,t.geoProjectionMutator=vd,t.geoRotation=ll,t.geoStereographic=function(){return yd(Bd).scale(250).clipAngle(142)},t.geoStereographicRaw=Bd,t.geoStream=Lf,t.geoTransform=function(t){return{stream:id(t)}},t.geoTransverseMercator=function(){var t=Ed(Yd),n=t.center,e=t.rotate;return t.center=function(t){return arguments.length?n([-t[1],t[0]]):[(t=n())[1],-t[0]]},t.rotate=function(t){return arguments.length?e([t[0],t[1],t.length>2?t[2]+90:90]):[(t=e())[0],t[1],t[2]-90]},e([0,0,90]).scale(159.155)},t.geoTransverseMercatorRaw=Yd,t.gray=function(t,n){return new ur(t,0,0,null==n?1:n)},t.greatest=ot,t.greatestIndex=function(t,e=n){if(1===e.length)return tt(t,e);let r,i=-1,o=-1;for(const n of t)++o,(i<0?0===e(n,n):e(n,r)>0)&&(r=n,i=o);return i},t.group=C,t.groupSort=function(t,e,r){return(2!==e.length?U($(t,e,r),(([t,e],[r,i])=>n(e,i)||n(t,r))):U(C(t,r),(([t,r],[i,o])=>e(r,o)||n(t,i)))).map((([t])=>t))},t.groups=P,t.hcl=dr,t.hierarchy=Gd,t.histogram=Q,t.hsl=He,t.html=Ec,t.image=function(t,n){return new Promise((function(e,r){var i=new Image;for(var o in n)i[o]=n[o];i.onerror=r,i.onload=function(){e(i)},i.src=t}))},t.index=function(t,...n){return F(t,k,R,n)},t.indexes=function(t,...n){return F(t,Array.from,R,n)},t.interpolate=Gr,t.interpolateArray=function(t,n){return(Ir(n)?Ur:Or)(t,n)},t.interpolateBasis=Er,t.interpolateBasisClosed=Nr,t.interpolateBlues=Gb,t.interpolateBrBG=ob,t.interpolateBuGn=Mb,t.interpolateBuPu=Ab,t.interpolateCividis=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(-4.54-t*(35.34-t*(2381.73-t*(6402.7-t*(7024.72-2710.57*t)))))))+", "+Math.max(0,Math.min(255,Math.round(32.49+t*(170.73+t*(52.82-t*(131.46-t*(176.58-67.37*t)))))))+", "+Math.max(0,Math.min(255,Math.round(81.24+t*(442.36-t*(2482.43-t*(6167.24-t*(6614.94-2475.67*t)))))))+")"},t.interpolateCool=am,t.interpolateCubehelix=li,t.interpolateCubehelixDefault=im,t.interpolateCubehelixLong=hi,t.interpolateDate=Br,t.interpolateDiscrete=function(t){var n=t.length;return function(e){return t[Math.max(0,Math.min(n-1,Math.floor(e*n)))]}},t.interpolateGnBu=Eb,t.interpolateGreens=Wb,t.interpolateGreys=Kb,t.interpolateHcl=ci,t.interpolateHclLong=fi,t.interpolateHsl=oi,t.interpolateHslLong=ai,t.interpolateHue=function(t,n){var e=Pr(+t,+n);return function(t){var n=e(t);return n-360*Math.floor(n/360)}},t.interpolateInferno=pm,t.interpolateLab=function(t,n){var e=$r((t=ar(t)).l,(n=ar(n)).l),r=$r(t.a,n.a),i=$r(t.b,n.b),o=$r(t.opacity,n.opacity);return function(n){return t.l=e(n),t.a=r(n),t.b=i(n),t.opacity=o(n),t+""}},t.interpolateMagma=dm,t.interpolateNumber=Yr,t.interpolateNumberArray=Ur,t.interpolateObject=Lr,t.interpolateOrRd=kb,t.interpolateOranges=rm,t.interpolatePRGn=ub,t.interpolatePiYG=fb,t.interpolatePlasma=gm,t.interpolatePuBu=$b,t.interpolatePuBuGn=Pb,t.interpolatePuOr=lb,t.interpolatePuRd=Rb,t.interpolatePurples=Jb,t.interpolateRainbow=function(t){(t<0||t>1)&&(t-=Math.floor(t));var n=Math.abs(t-.5);return um.h=360*t-100,um.s=1.5-1.5*n,um.l=.8-.9*n,um+""},t.interpolateRdBu=db,t.interpolateRdGy=gb,t.interpolateRdPu=qb,t.interpolateRdYlBu=vb,t.interpolateRdYlGn=bb,t.interpolateReds=nm,t.interpolateRgb=Dr,t.interpolateRgbBasis=Fr,t.interpolateRgbBasisClosed=qr,t.interpolateRound=Vr,t.interpolateSinebow=function(t){var n;return t=(.5-t)*Math.PI,cm.r=255*(n=Math.sin(t))*n,cm.g=255*(n=Math.sin(t+fm))*n,cm.b=255*(n=Math.sin(t+sm))*n,cm+""},t.interpolateSpectral=xb,t.interpolateString=Xr,t.interpolateTransformCss=ti,t.interpolateTransformSvg=ni,t.interpolateTurbo=function(t){return t=Math.max(0,Math.min(1,t)),"rgb("+Math.max(0,Math.min(255,Math.round(34.61+t*(1172.33-t*(10793.56-t*(33300.12-t*(38394.49-14825.05*t)))))))+", "+Math.max(0,Math.min(255,Math.round(23.31+t*(557.33+t*(1225.33-t*(3574.96-t*(1073.77+707.56*t)))))))+", "+Math.max(0,Math.min(255,Math.round(27.2+t*(3211.1-t*(15327.97-t*(27814-t*(22569.18-6838.66*t)))))))+")"},t.interpolateViridis=hm,t.interpolateWarm=om,t.interpolateYlGn=Bb,t.interpolateYlGnBu=Ib,t.interpolateYlOrBr=Lb,t.interpolateYlOrRd=Hb,t.interpolateZoom=ri,t.interrupt=Gi,t.intersection=function(t,...n){t=new InternSet(t),n=n.map(vt);t:for(const e of t)for(const r of n)if(!r.has(e)){t.delete(e);continue t}return t},t.interval=function(t,n,e){var r=new Ei,i=n;return null==n?(r.restart(t,n,e),r):(r._restart=r.restart,r.restart=function(t,n,e){n=+n,e=null==e?Ai():+e,r._restart((function o(a){a+=i,r._restart(o,i+=n,e),t(a)}),n,e)},r.restart(t,n,e),r)},t.isoFormat=D_,t.isoParse=F_,t.json=function(t,n){return fetch(t,n).then(Tc)},t.lab=ar,t.lch=function(t,n,e,r){return 1===arguments.length?hr(t):new pr(e,n,t,null==r?1:r)},t.least=function(t,e=n){let r,i=!1;if(1===e.length){let o;for(const a of t){const t=e(a);(i?n(t,o)<0:0===n(t,t))&&(r=a,o=t,i=!0)}}else for(const n of t)(i?e(n,r)<0:0===e(n,n))&&(r=n,i=!0);return r},t.leastIndex=ht,t.line=Ym,t.lineRadial=Zm,t.link=ax,t.linkHorizontal=function(){return ax(nx)},t.linkRadial=function(){const t=ax(rx);return t.angle=t.x,delete t.x,t.radius=t.y,delete t.y,t},t.linkVertical=function(){return ax(ex)},t.local=Qn,t.map=function(t,n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof n)throw new TypeError("mapper is not a function");return Array.from(t,((e,r)=>n(e,r,t)))},t.matcher=Vt,t.max=J,t.maxIndex=tt,t.mean=function(t,n){let e=0,r=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(++e,r+=n);else{let i=-1;for(let o of t)null!=(o=n(o,++i,t))&&(o=+o)>=o&&(++e,r+=o)}if(e)return r/e},t.median=function(t,n){return at(t,.5,n)},t.medianIndex=function(t,n){return ct(t,.5,n)},t.merge=ft,t.min=nt,t.minIndex=et,t.mode=function(t,n){const e=new InternMap;if(void 0===n)for(let n of t)null!=n&&n>=n&&e.set(n,(e.get(n)||0)+1);else{let r=-1;for(let i of t)null!=(i=n(i,++r,t))&&i>=i&&e.set(i,(e.get(i)||0)+1)}let r,i=0;for(const[t,n]of e)n>i&&(i=n,r=t);return r},t.namespace=It,t.namespaces=Ut,t.nice=Z,t.now=Ai,t.pack=function(){var t=null,n=1,e=1,r=np;function i(i){const o=ap();return i.x=n/2,i.y=e/2,t?i.eachBefore(xp(t)).eachAfter(wp(r,.5,o)).eachBefore(Mp(1)):i.eachBefore(xp(mp)).eachAfter(wp(np,1,o)).eachAfter(wp(r,i.r/Math.min(n,e),o)).eachBefore(Mp(Math.min(n,e)/(2*i.r))),i}return i.radius=function(n){return arguments.length?(t=Jd(n),i):t},i.size=function(t){return arguments.length?(n=+t[0],e=+t[1],i):[n,e]},i.padding=function(t){return arguments.length?(r="function"==typeof t?t:ep(+t),i):r},i},t.packEnclose=function(t){return up(t,ap())},t.packSiblings=function(t){return bp(t,ap()),t},t.pairs=function(t,n=st){const e=[];let r,i=!1;for(const o of t)i&&e.push(n(r,o)),r=o,i=!0;return e},t.partition=function(){var t=1,n=1,e=0,r=!1;function i(i){var o=i.height+1;return i.x0=i.y0=e,i.x1=t,i.y1=n/o,i.eachBefore(function(t,n){return function(r){r.children&&Ap(r,r.x0,t*(r.depth+1)/n,r.x1,t*(r.depth+2)/n);var i=r.x0,o=r.y0,a=r.x1-e,u=r.y1-e;a0&&(d+=l);for(null!=n?p.sort((function(t,e){return n(g[t],g[e])})):null!=e&&p.sort((function(t,n){return e(a[t],a[n])})),u=0,f=d?(v-h*b)/d:0;u0?l*f:0)+b,g[c]={data:a[c],index:u,value:l,startAngle:y,endAngle:s,padAngle:_};return g}return a.value=function(n){return arguments.length?(t="function"==typeof n?n:ym(+n),a):t},a.sortValues=function(t){return arguments.length?(n=t,e=null,a):n},a.sort=function(t){return arguments.length?(e=t,n=null,a):e},a.startAngle=function(t){return arguments.length?(r="function"==typeof t?t:ym(+t),a):r},a.endAngle=function(t){return arguments.length?(i="function"==typeof t?t:ym(+t),a):i},a.padAngle=function(t){return arguments.length?(o="function"==typeof t?t:ym(+t),a):o},a},t.piecewise=di,t.pointRadial=Qm,t.pointer=ne,t.pointers=function(t,n){return t.target&&(t=te(t),void 0===n&&(n=t.currentTarget),t=t.touches||[t]),Array.from(t,(t=>ne(t,n)))},t.polygonArea=function(t){for(var n,e=-1,r=t.length,i=t[r-1],o=0;++eu!=f>u&&a<(c-e)*(u-r)/(f-r)+e&&(s=!s),c=e,f=r;return s},t.polygonHull=function(t){if((e=t.length)<3)return null;var n,e,r=new Array(e),i=new Array(e);for(n=0;n=0;--n)f.push(t[r[o[n]][2]]);for(n=+u;n(n=1664525*n+1013904223|0,lg*(n>>>0))},t.randomLogNormal=Kp,t.randomLogistic=fg,t.randomNormal=Zp,t.randomPareto=ng,t.randomPoisson=sg,t.randomUniform=Vp,t.randomWeibull=ug,t.range=lt,t.rank=function(t,e=n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");let r=Array.from(t);const i=new Float64Array(r.length);2!==e.length&&(r=r.map(e),e=n);const o=(t,n)=>e(r[t],r[n]);let a,u;return(t=Uint32Array.from(r,((t,n)=>n))).sort(e===n?(t,n)=>O(r[t],r[n]):I(o)),t.forEach(((t,n)=>{const e=o(t,void 0===a?t:a);e>=0?((void 0===a||e>0)&&(a=t,u=n),i[t]=u):i[t]=NaN})),i},t.reduce=function(t,n,e){if("function"!=typeof n)throw new TypeError("reducer is not a function");const r=t[Symbol.iterator]();let i,o,a=-1;if(arguments.length<3){if(({done:i,value:e}=r.next()),i)return;++a}for(;({done:i,value:o}=r.next()),!i;)e=n(e,o,++a,t);return e},t.reverse=function(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()},t.rgb=Fe,t.ribbon=function(){return Wa()},t.ribbonArrow=function(){return Wa(Va)},t.rollup=$,t.rollups=D,t.scaleBand=yg,t.scaleDiverging=function t(){var n=Ng(L_()(mg));return n.copy=function(){return B_(n,t())},dg.apply(n,arguments)},t.scaleDivergingLog=function t(){var n=Fg(L_()).domain([.1,1,10]);return n.copy=function(){return B_(n,t()).base(n.base())},dg.apply(n,arguments)},t.scaleDivergingPow=j_,t.scaleDivergingSqrt=function(){return j_.apply(null,arguments).exponent(.5)},t.scaleDivergingSymlog=function t(){var n=Ig(L_());return n.copy=function(){return B_(n,t()).constant(n.constant())},dg.apply(n,arguments)},t.scaleIdentity=function t(n){var e;function r(t){return null==t||isNaN(t=+t)?e:t}return r.invert=r,r.domain=r.range=function(t){return arguments.length?(n=Array.from(t,_g),r):n.slice()},r.unknown=function(t){return arguments.length?(e=t,r):e},r.copy=function(){return t(n).unknown(e)},n=arguments.length?Array.from(n,_g):[0,1],Ng(r)},t.scaleImplicit=pg,t.scaleLinear=function t(){var n=Sg();return n.copy=function(){return Tg(n,t())},hg.apply(n,arguments),Ng(n)},t.scaleLog=function t(){const n=Fg(Ag()).domain([1,10]);return n.copy=()=>Tg(n,t()).base(n.base()),hg.apply(n,arguments),n},t.scaleOrdinal=gg,t.scalePoint=function(){return vg(yg.apply(null,arguments).paddingInner(1))},t.scalePow=jg,t.scaleQuantile=function t(){var e,r=[],i=[],o=[];function a(){var t=0,n=Math.max(1,i.length);for(o=new Array(n-1);++t0?o[n-1]:r[0],n=i?[o[i-1],r]:[o[n-1],o[n]]},u.unknown=function(t){return arguments.length?(n=t,u):u},u.thresholds=function(){return o.slice()},u.copy=function(){return t().domain([e,r]).range(a).unknown(n)},hg.apply(Ng(u),arguments)},t.scaleRadial=function t(){var n,e=Sg(),r=[0,1],i=!1;function o(t){var r=function(t){return Math.sign(t)*Math.sqrt(Math.abs(t))}(e(t));return isNaN(r)?n:i?Math.round(r):r}return o.invert=function(t){return e.invert(Hg(t))},o.domain=function(t){return arguments.length?(e.domain(t),o):e.domain()},o.range=function(t){return arguments.length?(e.range((r=Array.from(t,_g)).map(Hg)),o):r.slice()},o.rangeRound=function(t){return o.range(t).round(!0)},o.round=function(t){return arguments.length?(i=!!t,o):i},o.clamp=function(t){return arguments.length?(e.clamp(t),o):e.clamp()},o.unknown=function(t){return arguments.length?(n=t,o):n},o.copy=function(){return t(e.domain(),r).round(i).clamp(e.clamp()).unknown(n)},hg.apply(o,arguments),Ng(o)},t.scaleSequential=function t(){var n=Ng(O_()(mg));return n.copy=function(){return B_(n,t())},dg.apply(n,arguments)},t.scaleSequentialLog=function t(){var n=Fg(O_()).domain([1,10]);return n.copy=function(){return B_(n,t()).base(n.base())},dg.apply(n,arguments)},t.scaleSequentialPow=Y_,t.scaleSequentialQuantile=function t(){var e=[],r=mg;function i(t){if(null!=t&&!isNaN(t=+t))return r((s(e,t,1)-1)/(e.length-1))}return i.domain=function(t){if(!arguments.length)return e.slice();e=[];for(let n of t)null==n||isNaN(n=+n)||e.push(n);return e.sort(n),i},i.interpolator=function(t){return arguments.length?(r=t,i):r},i.range=function(){return e.map(((t,n)=>r(n/(e.length-1))))},i.quantiles=function(t){return Array.from({length:t+1},((n,r)=>at(e,r/t)))},i.copy=function(){return t(r).domain(e)},dg.apply(i,arguments)},t.scaleSequentialSqrt=function(){return Y_.apply(null,arguments).exponent(.5)},t.scaleSequentialSymlog=function t(){var n=Ig(O_());return n.copy=function(){return B_(n,t()).constant(n.constant())},dg.apply(n,arguments)},t.scaleSqrt=function(){return jg.apply(null,arguments).exponent(.5)},t.scaleSymlog=function t(){var n=Ig(Ag());return n.copy=function(){return Tg(n,t()).constant(n.constant())},hg.apply(n,arguments)},t.scaleThreshold=function t(){var n,e=[.5],r=[0,1],i=1;function o(t){return null!=t&&t<=t?r[s(e,t,0,i)]:n}return o.domain=function(t){return arguments.length?(e=Array.from(t),i=Math.min(e.length,r.length-1),o):e.slice()},o.range=function(t){return arguments.length?(r=Array.from(t),i=Math.min(e.length,r.length-1),o):r.slice()},o.invertExtent=function(t){var n=r.indexOf(t);return[e[n-1],e[n]]},o.unknown=function(t){return arguments.length?(n=t,o):n},o.copy=function(){return t().domain(e).range(r).unknown(n)},hg.apply(o,arguments)},t.scaleTime=function(){return hg.apply(I_(uv,cv,tv,Zy,xy,py,sy,ay,iy,t.timeFormat).domain([new Date(2e3,0,1),new Date(2e3,0,2)]),arguments)},t.scaleUtc=function(){return hg.apply(I_(ov,av,ev,Qy,Fy,yy,hy,cy,iy,t.utcFormat).domain([Date.UTC(2e3,0,1),Date.UTC(2e3,0,2)]),arguments)},t.scan=function(t,n){const e=ht(t,n);return e<0?void 0:e},t.schemeAccent=G_,t.schemeBlues=Xb,t.schemeBrBG=ib,t.schemeBuGn=wb,t.schemeBuPu=Tb,t.schemeCategory10=X_,t.schemeDark2=V_,t.schemeGnBu=Sb,t.schemeGreens=Vb,t.schemeGreys=Zb,t.schemeObservable10=W_,t.schemeOrRd=Nb,t.schemeOranges=em,t.schemePRGn=ab,t.schemePaired=Z_,t.schemePastel1=K_,t.schemePastel2=Q_,t.schemePiYG=cb,t.schemePuBu=zb,t.schemePuBuGn=Cb,t.schemePuOr=sb,t.schemePuRd=Db,t.schemePurples=Qb,t.schemeRdBu=hb,t.schemeRdGy=pb,t.schemeRdPu=Fb,t.schemeRdYlBu=yb,t.schemeRdYlGn=_b,t.schemeReds=tm,t.schemeSet1=J_,t.schemeSet2=tb,t.schemeSet3=nb,t.schemeSpectral=mb,t.schemeTableau10=eb,t.schemeYlGn=Ob,t.schemeYlGnBu=Ub,t.schemeYlOrBr=Yb,t.schemeYlOrRd=jb,t.select=Zn,t.selectAll=function(t){return"string"==typeof t?new Vn([document.querySelectorAll(t)],[document.documentElement]):new Vn([Ht(t)],Gn)},t.selection=Wn,t.selector=jt,t.selectorAll=Gt,t.shuffle=dt,t.shuffler=pt,t.some=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let e=-1;for(const r of t)if(n(r,++e,t))return!0;return!1},t.sort=U,t.stack=function(){var t=ym([]),n=dw,e=hw,r=pw;function i(i){var o,a,u=Array.from(t.apply(this,arguments),gw),c=u.length,f=-1;for(const t of i)for(o=0,++f;o0)for(var e,r,i,o,a,u,c=0,f=t[n[0]].length;c0?(r[0]=o,r[1]=o+=i):i<0?(r[1]=a,r[0]=a+=i):(r[0]=0,r[1]=i)},t.stackOffsetExpand=function(t,n){if((r=t.length)>0){for(var e,r,i,o=0,a=t[0].length;o0){for(var e,r=0,i=t[n[0]],o=i.length;r0&&(r=(e=t[n[0]]).length)>0){for(var e,r,i,o=0,a=1;afunction(t){t=`${t}`;let n=t.length;zp(t,n-1)&&!zp(t,n-2)&&(t=t.slice(0,-1));return"/"===t[0]?t:`/${t}`}(t(n,e,r)))),e=n.map(Pp),i=new Set(n).add("");for(const t of e)i.has(t)||(i.add(t),n.push(t),e.push(Pp(t)),h.push(Np));d=(t,e)=>n[e],p=(t,n)=>e[n]}for(a=0,i=h.length;a=0&&(f=h[t]).data===Np;--t)f.data=null}if(u.parent=Sp,u.eachBefore((function(t){t.depth=t.parent.depth+1,--i})).eachBefore(Kd),u.parent=null,i>0)throw new Error("cycle");return u}return r.id=function(t){return arguments.length?(n=Jd(t),r):n},r.parentId=function(t){return arguments.length?(e=Jd(t),r):e},r.path=function(n){return arguments.length?(t=Jd(n),r):t},r},t.style=_n,t.subset=function(t,n){return _t(n,t)},t.sum=function(t,n){let e=0;if(void 0===n)for(let n of t)(n=+n)&&(e+=n);else{let r=-1;for(let i of t)(i=+n(i,++r,t))&&(e+=i)}return e},t.superset=_t,t.svg=Nc,t.symbol=function(t,n){let e=null,r=km(i);function i(){let i;if(e||(e=i=r()),t.apply(this,arguments).draw(e,+n.apply(this,arguments)),i)return e=null,i+""||null}return t="function"==typeof t?t:ym(t||fx),n="function"==typeof n?n:ym(void 0===n?64:+n),i.type=function(n){return arguments.length?(t="function"==typeof n?n:ym(n),i):t},i.size=function(t){return arguments.length?(n="function"==typeof t?t:ym(+t),i):n},i.context=function(t){return arguments.length?(e=null==t?null:t,i):e},i},t.symbolAsterisk=cx,t.symbolCircle=fx,t.symbolCross=sx,t.symbolDiamond=dx,t.symbolDiamond2=px,t.symbolPlus=gx,t.symbolSquare=yx,t.symbolSquare2=vx,t.symbolStar=xx,t.symbolTimes=Px,t.symbolTriangle=Mx,t.symbolTriangle2=Ax,t.symbolWye=Cx,t.symbolX=Px,t.symbols=zx,t.symbolsFill=zx,t.symbolsStroke=$x,t.text=mc,t.thresholdFreedmanDiaconis=function(t,n,e){const r=v(t),i=at(t,.75)-at(t,.25);return r&&i?Math.ceil((e-n)/(2*i*Math.pow(r,-1/3))):1},t.thresholdScott=function(t,n,e){const r=v(t),i=w(t);return r&&i?Math.ceil((e-n)*Math.cbrt(r)/(3.49*i)):1},t.thresholdSturges=K,t.tickFormat=Eg,t.tickIncrement=V,t.tickStep=W,t.ticks=G,t.timeDay=py,t.timeDays=gy,t.timeFormatDefaultLocale=P_,t.timeFormatLocale=hv,t.timeFriday=Sy,t.timeFridays=$y,t.timeHour=sy,t.timeHours=ly,t.timeInterval=Vg,t.timeMillisecond=Wg,t.timeMilliseconds=Zg,t.timeMinute=ay,t.timeMinutes=uy,t.timeMonday=wy,t.timeMondays=ky,t.timeMonth=Zy,t.timeMonths=Ky,t.timeSaturday=Ey,t.timeSaturdays=Dy,t.timeSecond=iy,t.timeSeconds=oy,t.timeSunday=xy,t.timeSundays=Ny,t.timeThursday=Ay,t.timeThursdays=zy,t.timeTickInterval=cv,t.timeTicks=uv,t.timeTuesday=My,t.timeTuesdays=Cy,t.timeWednesday=Ty,t.timeWednesdays=Py,t.timeWeek=xy,t.timeWeeks=Ny,t.timeYear=tv,t.timeYears=nv,t.timeout=$i,t.timer=Ni,t.timerFlush=ki,t.transition=go,t.transpose=gt,t.tree=function(){var t=$p,n=1,e=1,r=null;function i(i){var c=function(t){for(var n,e,r,i,o,a=new Up(t,0),u=[a];n=u.pop();)if(r=n._.children)for(n.children=new Array(o=r.length),i=o-1;i>=0;--i)u.push(e=n.children[i]=new Up(r[i],i)),e.parent=n;return(a.parent=new Up(null,0)).children=[a],a}(i);if(c.eachAfter(o),c.parent.m=-c.z,c.eachBefore(a),r)i.eachBefore(u);else{var f=i,s=i,l=i;i.eachBefore((function(t){t.xs.x&&(s=t),t.depth>l.depth&&(l=t)}));var h=f===s?1:t(f,s)/2,d=h-f.x,p=n/(s.x+h+d),g=e/(l.depth||1);i.eachBefore((function(t){t.x=(t.x+d)*p,t.y=t.depth*g}))}return i}function o(n){var e=n.children,r=n.parent.children,i=n.i?r[n.i-1]:null;if(e){!function(t){for(var n,e=0,r=0,i=t.children,o=i.length;--o>=0;)(n=i[o]).z+=e,n.m+=e,e+=n.s+(r+=n.c)}(n);var o=(e[0].z+e[e.length-1].z)/2;i?(n.z=i.z+t(n._,i._),n.m=n.z-o):n.z=o}else i&&(n.z=i.z+t(n._,i._));n.parent.A=function(n,e,r){if(e){for(var i,o=n,a=n,u=e,c=o.parent.children[0],f=o.m,s=a.m,l=u.m,h=c.m;u=Rp(u),o=Dp(o),u&&o;)c=Dp(c),(a=Rp(a)).a=n,(i=u.z+l-o.z-f+t(u._,o._))>0&&(Fp(qp(u,n,r),n,i),f+=i,s+=i),l+=u.m,f+=o.m,h+=c.m,s+=a.m;u&&!Rp(a)&&(a.t=u,a.m+=l-s),o&&!Dp(c)&&(c.t=o,c.m+=f-h,r=n)}return r}(n,i,n.parent.A||r[0])}function a(t){t._.x=t.z+t.parent.m,t.m+=t.parent.m}function u(t){t.x*=n,t.y=t.depth*e}return i.separation=function(n){return arguments.length?(t=n,i):t},i.size=function(t){return arguments.length?(r=!1,n=+t[0],e=+t[1],i):r?null:[n,e]},i.nodeSize=function(t){return arguments.length?(r=!0,n=+t[0],e=+t[1],i):r?[n,e]:null},i},t.treemap=function(){var t=Yp,n=!1,e=1,r=1,i=[0],o=np,a=np,u=np,c=np,f=np;function s(t){return t.x0=t.y0=0,t.x1=e,t.y1=r,t.eachBefore(l),i=[0],n&&t.eachBefore(Tp),t}function l(n){var e=i[n.depth],r=n.x0+e,s=n.y0+e,l=n.x1-e,h=n.y1-e;l=e-1){var s=u[n];return s.x0=i,s.y0=o,s.x1=a,void(s.y1=c)}var l=f[n],h=r/2+l,d=n+1,p=e-1;for(;d>>1;f[g]c-o){var _=r?(i*v+a*y)/r:a;t(n,d,y,i,o,_,c),t(d,e,v,_,o,a,c)}else{var b=r?(o*v+c*y)/r:c;t(n,d,y,i,o,a,b),t(d,e,v,i,b,a,c)}}(0,c,t.value,n,e,r,i)},t.treemapDice=Ap,t.treemapResquarify=Lp,t.treemapSlice=Ip,t.treemapSliceDice=function(t,n,e,r,i){(1&t.depth?Ip:Ap)(t,n,e,r,i)},t.treemapSquarify=Yp,t.tsv=Mc,t.tsvFormat=lc,t.tsvFormatBody=hc,t.tsvFormatRow=pc,t.tsvFormatRows=dc,t.tsvFormatValue=gc,t.tsvParse=fc,t.tsvParseRows=sc,t.union=function(...t){const n=new InternSet;for(const e of t)for(const t of e)n.add(t);return n},t.unixDay=_y,t.unixDays=by,t.utcDay=yy,t.utcDays=vy,t.utcFriday=By,t.utcFridays=Vy,t.utcHour=hy,t.utcHours=dy,t.utcMillisecond=Wg,t.utcMilliseconds=Zg,t.utcMinute=cy,t.utcMinutes=fy,t.utcMonday=qy,t.utcMondays=jy,t.utcMonth=Qy,t.utcMonths=Jy,t.utcSaturday=Yy,t.utcSaturdays=Wy,t.utcSecond=iy,t.utcSeconds=oy,t.utcSunday=Fy,t.utcSundays=Ly,t.utcThursday=Oy,t.utcThursdays=Gy,t.utcTickInterval=av,t.utcTicks=ov,t.utcTuesday=Uy,t.utcTuesdays=Hy,t.utcWednesday=Iy,t.utcWednesdays=Xy,t.utcWeek=Fy,t.utcWeeks=Ly,t.utcYear=ev,t.utcYears=rv,t.variance=x,t.version="7.9.0",t.window=pn,t.xml=Sc,t.zip=function(){return gt(arguments)},t.zoom=function(){var t,n,e,r=Ew,i=Nw,o=zw,a=Cw,u=Pw,c=[0,1/0],f=[[-1/0,-1/0],[1/0,1/0]],s=250,l=ri,h=$t("start","zoom","end"),d=500,p=150,g=0,y=10;function v(t){t.property("__zoom",kw).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",S).filter(u).on("touchstart.zoom",E).on("touchmove.zoom",N).on("touchend.zoom touchcancel.zoom",k).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function _(t,n){return(n=Math.max(c[0],Math.min(c[1],n)))===t.k?t:new ww(n,t.x,t.y)}function b(t,n,e){var r=n[0]-e[0]*t.k,i=n[1]-e[1]*t.k;return r===t.x&&i===t.y?t:new ww(t.k,r,i)}function m(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function x(t,n,e,r){t.on("start.zoom",(function(){w(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){w(this,arguments).event(r).end()})).tween("zoom",(function(){var t=this,o=arguments,a=w(t,o).event(r),u=i.apply(t,o),c=null==e?m(u):"function"==typeof e?e.apply(t,o):e,f=Math.max(u[1][0]-u[0][0],u[1][1]-u[0][1]),s=t.__zoom,h="function"==typeof n?n.apply(t,o):n,d=l(s.invert(c).concat(f/s.k),h.invert(c).concat(f/h.k));return function(t){if(1===t)t=h;else{var n=d(t),e=f/n[2];t=new ww(e,c[0]-n[0]*e,c[1]-n[1]*e)}a.zoom(null,t)}}))}function w(t,n,e){return!e&&t.__zooming||new M(t,n)}function M(t,n){this.that=t,this.args=n,this.active=0,this.sourceEvent=null,this.extent=i.apply(t,n),this.taps=0}function T(t,...n){if(r.apply(this,arguments)){var e=w(this,n).event(t),i=this.__zoom,u=Math.max(c[0],Math.min(c[1],i.k*Math.pow(2,a.apply(this,arguments)))),s=ne(t);if(e.wheel)e.mouse[0][0]===s[0]&&e.mouse[0][1]===s[1]||(e.mouse[1]=i.invert(e.mouse[0]=s)),clearTimeout(e.wheel);else{if(i.k===u)return;e.mouse=[s,i.invert(s)],Gi(this),e.start()}Sw(t),e.wheel=setTimeout((function(){e.wheel=null,e.end()}),p),e.zoom("mouse",o(b(_(i,u),e.mouse[0],e.mouse[1]),e.extent,f))}}function A(t,...n){if(!e&&r.apply(this,arguments)){var i=t.currentTarget,a=w(this,n,!0).event(t),u=Zn(t.view).on("mousemove.zoom",(function(t){if(Sw(t),!a.moved){var n=t.clientX-s,e=t.clientY-l;a.moved=n*n+e*e>g}a.event(t).zoom("mouse",o(b(a.that.__zoom,a.mouse[0]=ne(t,i),a.mouse[1]),a.extent,f))}),!0).on("mouseup.zoom",(function(t){u.on("mousemove.zoom mouseup.zoom",null),ue(t.view,a.moved),Sw(t),a.event(t).end()}),!0),c=ne(t,i),s=t.clientX,l=t.clientY;ae(t.view),Aw(t),a.mouse=[c,this.__zoom.invert(c)],Gi(this),a.start()}}function S(t,...n){if(r.apply(this,arguments)){var e=this.__zoom,a=ne(t.changedTouches?t.changedTouches[0]:t,this),u=e.invert(a),c=e.k*(t.shiftKey?.5:2),l=o(b(_(e,c),a,u),i.apply(this,n),f);Sw(t),s>0?Zn(this).transition().duration(s).call(x,l,a,t):Zn(this).call(v.transform,l,a,t)}}function E(e,...i){if(r.apply(this,arguments)){var o,a,u,c,f=e.touches,s=f.length,l=w(this,i,e.changedTouches.length===s).event(e);for(Aw(e),a=0;a0&&isFinite(t)?t:NaN}function s(t){return t<0&&isFinite(t)?t:NaN}function c(t,e){if(t instanceof Date||(t=new Date(+t)),isNaN(t))return"function"==typeof e?e(t):e;const n=t.getUTCHours(),r=t.getUTCMinutes(),o=t.getUTCSeconds(),i=t.getUTCMilliseconds();return`${a=t.getUTCFullYear(),a<0?`-${u(-a,6)}`:a>9999?`+${u(a,6)}`:u(a,4)}-${u(t.getUTCMonth()+1,2)}-${u(t.getUTCDate(),2)}${n||r||o||i?`T${u(n,2)}:${u(r,2)}${o||i?`:${u(o,2)}${i?`.${u(i,3)}`:""}`:""}Z`:""}`;var a}function u(t,e){return`${t}`.padStart(e,"0")}const f=/^(?:[-+]\d{2})?\d{4}(?:-\d{2}(?:-\d{2})?)?(?:T\d{2}:\d{2}(?::\d{2}(?:\.\d{3})?)?(?:Z|[-+]\d{2}:?\d{2})?)?$/;function h(t,e){return f.test(t+="")?new Date(t):"function"==typeof e?e(t):e}function d(t){if(null==t)return;const n=t[0],r=t[t.length-1];return e.descending(n,r)}const p=1e3,m=6e4,y=36e5,g=864e5,v=7*g,x=30*g,w=365*g,b=[["millisecond",1],["2 milliseconds",2],["5 milliseconds",5],["10 milliseconds",10],["20 milliseconds",20],["50 milliseconds",50],["100 milliseconds",100],["200 milliseconds",200],["500 milliseconds",500],["second",p],["5 seconds",5e3],["15 seconds",15e3],["30 seconds",3e4],["minute",m],["5 minutes",3e5],["15 minutes",9e5],["30 minutes",18e5],["hour",y],["3 hours",108e5],["6 hours",216e5],["12 hours",432e5],["day",g],["2 days",2*g],["week",v],["2 weeks",2*v],["month",x],["3 months",3*x],["6 months",6*x],["year",w],["2 years",2*w],["5 years",5*w],["10 years",10*w],["20 years",20*w],["50 years",50*w],["100 years",100*w]],k=new Map([["second",p],["minute",m],["hour",y],["day",g],["monday",v],["tuesday",v],["wednesday",v],["thursday",v],["friday",v],["saturday",v],["sunday",v],["week",v],["month",x],["year",w]]),$=new Map([["second",e.timeSecond],["minute",e.timeMinute],["hour",e.timeHour],["day",e.timeDay],["monday",e.timeMonday],["tuesday",e.timeTuesday],["wednesday",e.timeWednesday],["thursday",e.timeThursday],["friday",e.timeFriday],["saturday",e.timeSaturday],["sunday",e.timeSunday],["week",e.timeWeek],["month",e.timeMonth],["year",e.timeYear]]),M=new Map([["second",e.utcSecond],["minute",e.utcMinute],["hour",e.utcHour],["day",e.unixDay],["monday",e.utcMonday],["tuesday",e.utcTuesday],["wednesday",e.utcWednesday],["thursday",e.utcThursday],["friday",e.utcFriday],["saturday",e.utcSaturday],["sunday",e.utcSunday],["week",e.utcWeek],["month",e.utcMonth],["year",e.utcYear]]),L=Symbol("intervalDuration"),A=Symbol("intervalType");for(const[t,e]of $)e[L]=k.get(t),e[A]="time";for(const[t,e]of M)e[L]=k.get(t),e[A]="utc";const S=[["year",e.utcYear,"utc"],["month",e.utcMonth,"utc"],["day",e.unixDay,"utc",6*x],["hour",e.utcHour,"utc",3*g],["minute",e.utcMinute,"utc",216e5],["second",e.utcSecond,"utc",18e5]],z=[["year",e.timeYear,"time"],["month",e.timeMonth,"time"],["day",e.timeDay,"time",6*x],["hour",e.timeHour,"time",3*g],["minute",e.timeMinute,"time",216e5],["second",e.timeSecond,"time",18e5]],O=[S[0],z[0],S[1],z[1],S[2],z[2],...S.slice(3)];function E(t){let e=`${t}`.toLowerCase();e.endsWith("s")&&(e=e.slice(0,-1));let n=1;const r=/^(?:(\d+)\s+)/.exec(e);switch(r&&(e=e.slice(r[0].length),n=+r[1]),e){case"quarter":e="month",n*=3;break;case"half":e="month",n*=6}let o=M.get(e);if(!o)throw new Error(`unknown interval: ${t}`);if(n>1&&!o.every)throw new Error(`non-periodic interval: ${e}`);return[e,n]}function R(t){return T(E(t),"time")}function C(t){return T(E(t),"utc")}function T([t,e],n){let r=("time"===n?$:M).get(t);return e>1&&(r=r.every(e),r[L]=k.get(t)*e,r[A]=n),r}function B(t,n){if(!(n>1))return;const r=t[L];if(!b.some((([,t])=>t===r)))return;if(r%g==0&&gMath.log(t))).center(b,Math.log(r*n))];return("time"===t[A]?R:C)(o)}function N(t,n,r){const o="time"===n?e.timeFormat:e.utcFormat;if(null==r)return o("year"===t?"%Y":"month"===t?"%Y-%m":"day"===t?"%Y-%m-%d":"hour"===t||"minute"===t?"%Y-%m-%dT%H:%M":"second"===t?"%Y-%m-%dT%H:%M:%S":"%Y-%m-%dT%H:%M:%S.%L");const i=function(t){return"left"===t||"right"===t?(t,e)=>`\n${t}\n${e}`:"top"===t?(t,e)=>`${e}\n${t}`:(t,e)=>`${t}\n${e}`}(r);switch(t){case"millisecond":return P(o(".%L"),o(":%M:%S"),i);case"second":return P(o(":%S"),o("%-I:%M"),i);case"minute":return P(o("%-I:%M"),o("%p"),i);case"hour":return P(o("%-I %p"),o("%b %-d"),i);case"day":return P(o("%-d"),o("%b"),i);case"month":return P(o("%b"),o("%Y"),i);case"year":return o("%Y")}throw new Error("unable to format time ticks")}function I(t,n,r){const o=e.max(e.pairs(n,((t,e)=>Math.abs(e-t))));if(o<1e3)return N("millisecond","utc",r);for(const[e,i,a,l]of function(t){return"time"===t?z:"utc"===t?S:O}(t)){if(o>l)break;if("hour"===e&&!o)break;if(n.every((t=>i.floor(t)>=t)))return N(e,a,r)}}function P(t,e,n){return(r,o,i)=>{const a=t(r,o),l=e(r,o),s=o-d(i);return o!==s&&void 0!==i[s]&&l===e(i[s],s)?a:n(a,l)}}const W=Object.getPrototypeOf(Uint8Array),j=Object.prototype.toString,q=Symbol("reindex");function F(t,e,n){const r=typeof e;return"string"===r?D(t,G(e),n):"function"===r?D(t,e,n):"number"===r||e instanceof Date||"boolean"===r?dt(t,et(e),n):"function"==typeof e?.transform?Y(e.transform(t),n):function(t,e){return e?At(t,e):t}(Y(e,n),t?.[q])}function D(t,e,n){return dt(t,n?.prototype instanceof W?function(t){return(e,n)=>ot(t(e,n))}(e):e,n)}function Y(t,e){return void 0===e?ht(t):t instanceof e?t:e.prototype instanceof W&&!(t instanceof W)?e.from(t,ot):e.from(t)}const _=[null],G=t=>e=>e[t],X={transform:Lt},H={transform:t=>t},U=()=>1,V=()=>!0,Z=t=>null==t?t:`${t}`,Q=t=>null==t?t:+t,J=t=>t?t[0]:void 0,K=t=>t?t[1]:void 0,tt=t=>t?t[2]:void 0,et=t=>()=>t;function nt(t){const n=+`${t}`.slice(1)/100;return(t,r)=>e.quantile(t,n,r)}function rt(t){return t instanceof W?t:dt(t,ot,Float64Array)}function ot(t){return null==t?NaN:Number(t)}function at(t){return dt(t,lt)}function lt(t){return t instanceof Date&&!isNaN(t)?t:"string"==typeof t?h(t):null==t||isNaN(t=+t)?void 0:new Date(t)}function st(t,e){return void 0===t&&(t=e),null===t?[void 0,"none"]:Zt(t)?[void 0,t]:[t,void 0]}function ct(t,e){return void 0===t&&(t=e),null===t||"number"==typeof t?[void 0,t]:[t,void 0]}function ut(t,e,n){if(null!=t)return ft(t,e,n)}function ft(t,e,n){const r=`${t}`.toLowerCase();if(!n.includes(r))throw new Error(`invalid ${e}: ${t}`);return r}function ht(t){return null==t||t instanceof Array||t instanceof W?t:Array.from(t)}function dt(t,e,n=Array){return null==t?t:t instanceof n?t.map(e):n.from(t,e)}function pt(t,e=Array){return t instanceof e?t.slice():e.from(t)}function mt({x:t,x1:e,x2:n}){return void 0!==t||void 0!==e||void 0!==n}function yt({y:t,y1:e,y2:n}){return void 0!==t||void 0!==e||void 0!==n}function gt(t){return mt(t)||yt(t)||void 0!==t.interval}function vt(t){return t?.toString===j}function xt(t){return vt(t)&&(void 0!==t.type||void 0!==t.domain)}function wt(t){return vt(t)&&"function"!=typeof t.transform}function bt(t){return wt(t)&&void 0===t.value&&void 0===t.channel}function kt(t,e,n,r=H){return void 0===e&&void 0===n?(e=0,n=void 0===t?r:t):void 0===e?e=void 0===t?0:t:void 0===n&&(n=void 0===t?0:t),[e,n]}function $t(t,e){return void 0===t&&void 0===e?[J,K]:[t,e]}function Mt({z:t,fill:e,stroke:n}={}){return void 0===t&&([t]=st(e)),void 0===t&&([t]=st(n)),t}function Lt(t){const e=t.length,n=new Uint32Array(e);for(let t=0;tt[e]),t.constructor)}function St(t){return 1===t.length?(e,n)=>t(At(n,e)):t}function zt(t,e,n){return t.subarray?t.subarray(e,n):t.slice(e,n)}function Ot(t){return null!==t&&"object"==typeof t?t.valueOf():t}function Et(t,e){if(void 0!==e[t])return e[t];switch(t){case"x1":case"x2":t="x";break;case"y1":case"y2":t="y"}return e[t]}function Rt(t){let e;return[{transform:()=>e,label:Tt(t)},t=>e=t]}function Ct(t){return null==t?[t]:Rt(t)}function Tt(t,e){return"string"==typeof t?t:t&&void 0!==t.label?t.label:e}function Bt(t,e){return{transform(n){const r=t.transform(n),o=e.transform(n);return _t(r)||_t(o)?dt(r,((t,e)=>new Date((+r[e]+ +o[e])/2))):dt(r,((t,e)=>(+r[e]+ +o[e])/2),Float64Array)},label:t.label}}function Nt(t,e){const n=It(e?.interval,e?.type);return n?dt(t,n):t}function It(t,e){const r=Pt(t,e);return r&&(t=>n(t)?r.floor(t):t)}function Pt(t,n){if(null!=t){if("number"==typeof t){0Math.floor(t*n)/n,offset:t=>(t*n+1)/n,range:(t,r)=>e.range(Math.ceil(t*n),r*n).map((t=>t/n))}:{floor:t=>Math.floor(t/n)*n,offset:t=>t+n,range:(t,r)=>e.range(Math.ceil(t/n),r/n).map((t=>t*n))}}if("string"==typeof t)return("time"===n?R:C)(t);if("function"!=typeof t.floor)throw new Error("invalid interval; missing floor method");if("function"!=typeof t.offset)throw new Error("invalid interval; missing offset method");return t}}function Wt(t,e){if((t=Pt(t,e))&&"function"!=typeof t.range)throw new Error("invalid interval: missing range method");return t}function jt(t){return"function"==typeof t?.range}function qt(t){return void 0===t||wt(t)?t:{value:t}}function Ft(t){return t&&"function"==typeof t[Symbol.iterator]}function Dt(t){for(const e of t)if(null!=e)return"object"!=typeof e||e instanceof Date}function Yt(t){for(const e of t){if(null==e)continue;const t=typeof e;return"string"===t||"boolean"===t}}function _t(t){for(const e of t)if(null!=e)return e instanceof Date}function Gt(t){for(const e of t)if(null!=e)return"string"==typeof e&&isNaN(e)&&h(e)}function Xt(t){for(const e of t)if(null!=e){if("string"!=typeof e)return!1;if(e.trim())return!isNaN(e)}}function Ht(t){for(const e of t)if(null!=e)return"number"==typeof e}function Ut(t,e){let n;for(const r of t)if(null!=r){if(!e(r))return!1;n=!0}return n}const Vt=new Set("none,currentcolor,transparent,aliceblue,antiquewhite,aqua,aquamarine,azure,beige,bisque,black,blanchedalmond,blue,blueviolet,brown,burlywood,cadetblue,chartreuse,chocolate,coral,cornflowerblue,cornsilk,crimson,cyan,darkblue,darkcyan,darkgoldenrod,darkgray,darkgreen,darkgrey,darkkhaki,darkmagenta,darkolivegreen,darkorange,darkorchid,darkred,darksalmon,darkseagreen,darkslateblue,darkslategray,darkslategrey,darkturquoise,darkviolet,deeppink,deepskyblue,dimgray,dimgrey,dodgerblue,firebrick,floralwhite,forestgreen,fuchsia,gainsboro,ghostwhite,gold,goldenrod,gray,green,greenyellow,grey,honeydew,hotpink,indianred,indigo,ivory,khaki,lavender,lavenderblush,lawngreen,lemonchiffon,lightblue,lightcoral,lightcyan,lightgoldenrodyellow,lightgray,lightgreen,lightgrey,lightpink,lightsalmon,lightseagreen,lightskyblue,lightslategray,lightslategrey,lightsteelblue,lightyellow,lime,limegreen,linen,magenta,maroon,mediumaquamarine,mediumblue,mediumorchid,mediumpurple,mediumseagreen,mediumslateblue,mediumspringgreen,mediumturquoise,mediumvioletred,midnightblue,mintcream,mistyrose,moccasin,navajowhite,navy,oldlace,olive,olivedrab,orange,orangered,orchid,palegoldenrod,palegreen,paleturquoise,palevioletred,papayawhip,peachpuff,peru,pink,plum,powderblue,purple,rebeccapurple,red,rosybrown,royalblue,saddlebrown,salmon,sandybrown,seagreen,seashell,sienna,silver,skyblue,slateblue,slategray,slategrey,snow,springgreen,steelblue,tan,teal,thistle,tomato,turquoise,violet,wheat,white,whitesmoke,yellow".split(","));function Zt(t){return"string"==typeof t&&(t=t.toLowerCase().trim(),/^#[0-9a-f]{3,8}$/.test(t)||/^(?:url|var|rgb|rgba|hsl|hsla|hwb|lab|lch|oklab|oklch|color|color-mix)\(.*\)$/.test(t)||Vt.has(t))}function Qt(t){return"number"==typeof t&&(0<=t&&t<=1||isNaN(t))}function Jt(t){return null==t||Kt(t)}function Kt(t){return/^\s*none\s*$/i.test(t)}function te(t,e){return ut(t,e,["middle","top-left","top","top-right","right","bottom-right","bottom","bottom-left","left"])}function ee(t="middle"){return te(t,"frameAnchor")}function ne(t){return Ft(t)?function(t){console.warn("named iterables are deprecated; please use an object instead");const e=new Set;return Object.fromEntries(Array.from(t,(t=>{const{name:n}=t;if(null==n)throw new Error("missing name");const r=`${n}`;if("__proto__"===r)throw new Error(`illegal name: ${r}`);if(e.has(r))throw new Error(`duplicate name: ${r}`);return e.add(r),[n,t]})))}(t):t}function re(t){return!0===t?t="frame":!1===t?t=null:null!=t&&(t=ft(t,"clip",["frame","sphere"])),t}const oe=Symbol("position"),ie=Symbol("color"),ae=Symbol("radius"),le=Symbol("length"),se=Symbol("opacity"),ce=Symbol("symbol"),ue=Symbol("projection"),fe=new Map([["x",oe],["y",oe],["fx",oe],["fy",oe],["r",ae],["color",ie],["opacity",se],["symbol",ce],["length",le],["projection",ue]]);const he=Math.sqrt(3),de=2/he,pe={draw(t,e){const n=Math.sqrt(e/Math.PI),r=n*de,o=r/2;t.moveTo(0,r),t.lineTo(n,o),t.lineTo(n,-o),t.lineTo(0,-r),t.lineTo(-n,-o),t.lineTo(-n,o),t.closePath()}},me=new Map([["asterisk",e.symbolAsterisk],["circle",e.symbolCircle],["cross",e.symbolCross],["diamond",e.symbolDiamond],["diamond2",e.symbolDiamond2],["hexagon",pe],["plus",e.symbolPlus],["square",e.symbolSquare],["square2",e.symbolSquare2],["star",e.symbolStar],["times",e.symbolTimes],["triangle",e.symbolTriangle],["triangle2",e.symbolTriangle2],["wye",e.symbolWye]]);function ye(t){return t&&"function"==typeof t.draw}function ge(t){return!!ye(t)||"string"==typeof t&&me.has(t.toLowerCase())}function ve(t){if(null==t||ye(t))return t;const e=me.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid symbol: ${t}`)}function xe({filter:t,sort:e,reverse:n,transform:r,initializer:o,...i}={},a){if(void 0===r&&(null!=t&&(r=Me(t)),null==e||bt(e)||(r=be(r,Se(e))),n&&(r=be(r,Le))),null!=a&&null!=o)throw new Error("transforms cannot be applied after initializers");return{...i,...(null===e||bt(e))&&{sort:e},transform:be(r,a)}}function we({filter:t,sort:e,reverse:n,initializer:r,...o}={},i){return void 0===r&&(null!=t&&(r=Me(t)),null==e||bt(e)||(r=ke(r,Se(e))),n&&(r=ke(r,Le))),{...o,...(null===e||bt(e))&&{sort:e},initializer:ke(r,i)}}function be(t,e){return null==t?null===e?void 0:e:null==e?null===t?void 0:t:function(n,r,o){return({data:n,facets:r}=t.call(this,n,r,o)),e.call(this,ht(n),r,o)}}function ke(t,e){return null==t?null===e?void 0:e:null==e?null===t?void 0:t:function(n,r,o,...i){let a,l,s,c,u,f;return({data:l=n,facets:s=r,channels:a}=t.call(this,n,r,o,...i)),({data:u=l,facets:f=s,channels:c}=e.call(this,l,s,{...o,...a},...i)),{data:u,facets:f,channels:{...a,...c}}}}function $e(t,e){return(null!=t.initializer?we:xe)(t,e)}function Me(t){return(e,n)=>{const r=F(e,t);return{data:e,facets:n.map((t=>t.filter((t=>r[t]))))}}}function Le(t,e){return{data:t,facets:e.map((t=>t.slice().reverse()))}}function Ae(t,{sort:e,...n}={}){return{...(wt(t)&&void 0!==t.channel?we:$e)(n,Se(t)),sort:bt(e)?e:null}}function Se(t){return("function"==typeof t&&1!==t.length?ze:Oe)(t)}function ze(t){return(e,n)=>{const r=(n,r)=>t(e[n],e[r]);return{data:e,facets:n.map((t=>t.slice().sort(r)))}}}function Oe(t){let e,n;({channel:e,value:t,order:n}={...qt(t)});const i=e?.startsWith("-");if(i&&(e=e.slice(1)),void 0===n&&(n=i?o:r),"function"!=typeof n)switch(`${n}`.toLowerCase()){case"ascending":n=r;break;case"descending":n=o;break;default:throw new Error(`invalid order: ${n}`)}return(r,o,i)=>{let a;if(void 0===e)a=F(r,t);else{if(void 0===i)throw new Error("channel sort requires an initializer");if(a=i[e],!a)return{};a=a.value}const l=(t,e)=>n(a[t],a[e]);return{data:r,facets:o.map((t=>t.slice().sort(l)))}}}function Ee(t,e){return Be(null,null,t,e)}function Re(t={y:"count"},e={}){const{x:n=H}=e;if(null==n)throw new Error("missing channel: x");return Be(n,null,t,e)}function Ce(t={x:"count"},e={}){const{y:n=H}=e;if(null==n)throw new Error("missing channel: y");return Be(null,n,t,e)}function Te(t={fill:"count"},e={}){let{x:n,y:r}=e;if([n,r]=$t(n,r),null==n)throw new Error("missing channel: x");if(null==r)throw new Error("missing channel: y");return Be(n,r,t,e)}function Be(t,e,{data:n=Qe,filter:r,sort:o,reverse:i,...a}={},l={}){a=De(a,l),n=Ge(n,H),o=null==o?void 0:Ye("sort",o,l),r=null==r?void 0:_e("filter",r,l);const[s,c]=Ct(t),[u,f]=Ct(e),{z:h,fill:d,stroke:p,x1:m,x2:y,y1:g,y2:v,...x}=l,[w,b]=Ct(h),[k]=st(d),[$]=st(p),[M,L]=Ct(k),[A,S]=Ct($);return{..."z"in l&&{z:w||h},..."fill"in l&&{fill:M||d},..."stroke"in l&&{stroke:A||p},...xe(x,((l,s,u)=>{const d=Nt(F(l,t),u?.x),p=Nt(F(l,e),u?.y),m=F(l,h),y=F(l,k),g=F(l,$),v=He(a,{z:m,fill:y,stroke:g}),x=[],w=[],M=d&&c([]),A=p&&f([]),z=m&&b([]),O=y&&L([]),E=g&&S([]);let R=0;for(const t of a)t.initialize(l);o&&o.initialize(l),r&&r.initialize(l);for(const t of s){const e=[];for(const e of a)e.scope("facet",t);o&&o.scope("facet",t),r&&r.scope("facet",t);for(const[i,s]of je(t,v))for(const[t,c]of je(s,p))for(const[s,u]of je(c,d)){const c={data:l};if(d&&(c.x=s),p&&(c.y=t),v&&(c.z=i),!r||r.reduce(u,c)){e.push(R++),w.push(n.reduceIndex(u,l,c)),d&&M.push(s),p&&A.push(t),m&&z.push(v===m?i:m[u[0]]),y&&O.push(v===y?i:y[u[0]]),g&&E.push(v===g?i:g[u[0]]);for(const t of a)t.reduce(u,c);o&&o.reduce(u,c)}}x.push(e)}return Ue(x,o,i),{data:w,facets:x}})),...!Ne(a,"x")&&(s?{x:s}:{x1:m,x2:y}),...!Ne(a,"y")&&(u?{y:u}:{y1:g,y2:v}),...Object.fromEntries(a.map((({name:t,output:e})=>[t,e])))}}function Ne(t,...e){for(const{name:n}of t)if(e.includes(n))return!0;return!1}function Ie(t,e,n=Pe){const r=Object.entries(t);return null!=e.title&&void 0===t.title&&r.push(["title",Ke]),null!=e.href&&void 0===t.href&&r.push(["href",Je]),r.filter((([,t])=>void 0!==t)).map((([t,r])=>null===r?function(t){return{name:t,initialize(){},scope(){},reduce(){}}}(t):n(t,r,e)))}function Pe(t,e,n,r=We){let o;vt(e)&&"reduce"in e&&(o=e.scale,e=e.reduce);const i=r(t,e,n),[a,l]=Rt(i.label);let s;return{name:t,output:void 0===o?a:{value:a,scale:o},initialize(t){i.initialize(t),s=l([])},scope(t,e){i.scope(t,e)},reduce(t,e){s.push(i.reduce(t,e))}}}function We(t,e,n,r=qe){const o=Et(t,n),i=r(e,o);let a,l;return{label:Tt(i===en?null:o,i.label),initialize(t){a=void 0===o?t:F(t,o),"data"===i.scope&&(l=i.reduceIndex(Lt(t),a))},scope(t,e){i.scope===t&&(l=i.reduceIndex(e,a))},reduce:(t,e)=>null==i.scope?i.reduceIndex(t,a,e):i.reduceIndex(t,a,l,e)}}function je(t,n){return n?e.group(t,(t=>n[t])):[[,t]]}function qe(t,n,r=Fe){if(null==t)return r(t);if("function"==typeof t.reduceIndex)return t;if("function"==typeof t.reduce&&vt(t))return function(t){return console.warn("deprecated reduce interface; implement reduceIndex instead."),{...t,reduceIndex:t.reduce.bind(t)}}(t);if("function"==typeof t)return o=t,{reduceIndex:(t,e,n)=>o(At(e,t),n)};var o;if(/^p\d{2}$/i.test(t))return Ve(nt(t));switch(`${t}`.toLowerCase()){case"first":return Je;case"last":return tn;case"identity":return Qe;case"count":return en;case"distinct":return nn;case"sum":return null==n?en:rn;case"proportion":return on(n,"data");case"proportion-facet":return on(n,"facet");case"deviation":return Ve(e.deviation);case"min":return Ve(e.min);case"min-index":return Ve(e.minIndex);case"max":return Ve(e.max);case"max-index":return Ve(e.maxIndex);case"mean":return Ze(e.mean);case"median":return Ze(e.median);case"variance":return Ve(e.variance);case"mode":return Ve(e.mode)}return r(t)}function Fe(t){throw new Error(`invalid reduce: ${t}`)}function De(t,e){return Ie(t,e,Ye)}function Ye(t,e,n){return Pe(t,e,n,_e)}function _e(t,e,n){return We(t,e,n,Ge)}function Ge(t,e){return qe(t,e,Xe)}function Xe(t){switch(`${t}`.toLowerCase()){case"x":return an;case"y":return ln;case"z":return sn}throw new Error(`invalid group reduce: ${t}`)}function He(t,e){for(const n in e){const r=e[n];if(void 0!==r&&!t.some((t=>t.name===n)))return r}}function Ue(t,e,n){if(e){const n=e.output.transform(),o=(t,e)=>r(n[t],n[e]);t.forEach((t=>t.sort(o)))}n&&t.forEach((t=>t.reverse()))}function Ve(t){return{reduceIndex:(e,n)=>t(e,(t=>n[t]))}}function Ze(t){return{reduceIndex(e,n){const r=t(e,(t=>n[t]));return _t(n)?new Date(r):r}}}const Qe={reduceIndex:(t,e)=>At(e,t)},Je={reduceIndex:(t,e)=>e[t[0]]},Ke={reduceIndex(t,n){const r=e.sort(e.rollup(t,(t=>t.length),(t=>n[t])),K),o=r.slice(-5).reverse();if(o.length`${t} (${e.toLocaleString("en-US")})`)).join("\n")}},tn={reduceIndex:(t,e)=>e[t[t.length-1]]},en={label:"Frequency",reduceIndex:t=>t.length},nn={label:"Distinct",reduceIndex(t,n){const r=new e.InternSet;for(const e of t)r.add(n[e]);return r.size}},rn=Ve(e.sum);function on(t,n){return null==t?{scope:n,label:"Frequency",reduceIndex:(t,e,n=1)=>t.length/n}:{scope:n,reduceIndex:(t,n,r=1)=>e.sum(t,(t=>n[t]))/r}}const an={reduceIndex:(t,e,{x:n})=>n},ln={reduceIndex:(t,e,{y:n})=>n},sn={reduceIndex:(t,e,{z:n})=>n};function cn(t,{scale:e,type:n,value:r,filter:o,hint:i,label:a=Tt(r)},l){return void 0===i&&"function"==typeof r?.transform&&(i=r.hint),hn(l,{scale:e,type:n,value:F(t,r),label:a,filter:o,hint:i})}function un(t,e){return Object.fromEntries(Object.entries(t).map((([t,n])=>[t,cn(e,n,t)])))}function fn(t,e){const n=Object.fromEntries(Object.entries(t).map((([t,{scale:n,value:r}])=>{const o=null==n?null:e[n];return[t,null==o?r:dt(r,o)]})));return n.channels=t,n}function hn(t,e){const{scale:n,value:r}=e;if(!0===n||"auto"===n)switch(t){case"fill":case"stroke":case"color":e.scale=!0!==n&&Ut(r,Zt)?null:"color";break;case"fillOpacity":case"strokeOpacity":case"opacity":e.scale=!0!==n&&Ut(r,Qt)?null:"opacity";break;case"symbol":!0!==n&&Ut(r,ge)?(e.scale=null,e.value=dt(r,ve)):e.scale="symbol";break;default:e.scale=fe.has(t)?t:null}else if(!1===n)e.scale=null;else if(null!=n&&!fe.has(n))throw new Error(`unknown scale: ${n}`);return e}function dn(t,e){for(const n in t){const r=t[n];if(r.scale===e)return r}}function pn(t,e){const n=t.original;if(n===t)return e;const r=e.value,o=e.value=[];for(let e=0;eMath.abs(t-r[e])),Float64Array)}function yn(t,e,n){let r=t[e];if(r||void 0===n||(r=t[n]),r)return r.value;throw new Error(`missing channel: ${e}`)}function gn(t){if(null==t||"function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"ascending":return vn;case"descending":return xn}throw new Error(`invalid order: ${t}`)}function vn([t,e],[n,o]){return r(e,o)||r(t,n)}function xn([t,e],[n,i]){return o(e,i)||r(t,n)}function wn(t,e){let n=t[e];if(n){for(;n.source;)n=n.source;return null===n.source?null:n}}function bn(t={}){const{document:e=("undefined"!=typeof window?window.document:void 0),clip:n}=t;return{document:e,clip:re(n)}}function kn(t,{document:n}){return e.select(e.creator(t).call(n.documentElement))}let $n,Mn=0;function Ln(t){t!==$n&&($n=t,console.warn(t),++Mn)}const An=Math.PI,Sn=2*An,zn=.618;function On({projection:t,inset:n=0,insetTop:r=n,insetRight:o=n,insetBottom:i=n,insetLeft:a=n}={},l){if(null==t)return;if("function"==typeof t.stream)return t;let s,c,u="frame";if(vt(t)){let e;if(({type:t,domain:c,inset:e,insetTop:r=(void 0!==e?e:r),insetRight:o=(void 0!==e?e:o),insetBottom:i=(void 0!==e?e:i),insetLeft:a=(void 0!==e?e:a),clip:u=u,...s}=t),null==t)return}"function"!=typeof t&&({type:t}=En(t));const{width:f,height:h,marginLeft:d,marginRight:p,marginTop:m,marginBottom:y}=l,g=f-d-p-a-o,v=h-m-y-r-i;if(t=t?.({width:g,height:v,clip:u,...s}),null==t)return;u=function(t,n,r,o,i){if(!1===t||null==t||"number"==typeof t)return t=>t;!0===t&&(t="frame");if("frame"===`${t}`.toLowerCase())return e.geoClipRectangle(n,r,o,i);throw new Error(`unknown projection clip type: ${t}`)}(u,d,m,f-p,h-y);let x,w=d+a,b=m+r;if(null!=c){const[[n,r],[o,i]]=e.geoPath(t).bounds(c),a=Math.min(g/(o-n),v/(i-r));a>0?(w-=(a*(n+o)-g)/2,b-=(a*(r+i)-v)/2,x=e.geoTransform({point(t,e){this.stream.point(t*a+w,e*a+b)}})):Ln("Warning: the projection could not be fit to the specified domain; using the default scale.")}return x??=0===w&&0===b?Tn():e.geoTransform({point(t,e){this.stream.point(t+w,e+b)}}),{stream:e=>t.stream(x.stream(u(e)))}}function En(t){switch(`${t}`.toLowerCase()){case"albers-usa":return Rn(e.geoAlbersUsa,.7463,.4673);case"albers":return Cn(e.geoAlbers,.7463,.4673);case"azimuthal-equal-area":return Rn(e.geoAzimuthalEqualArea,4,4);case"azimuthal-equidistant":return Rn(e.geoAzimuthalEquidistant,Sn,Sn);case"conic-conformal":return Cn(e.geoConicConformal,Sn,Sn);case"conic-equal-area":return Cn(e.geoConicEqualArea,6.1702,2.9781);case"conic-equidistant":return Cn(e.geoConicEquidistant,7.312,3.6282);case"equal-earth":return Rn(e.geoEqualEarth,5.4133,2.6347);case"equirectangular":return Rn(e.geoEquirectangular,Sn,An);case"gnomonic":return Rn(e.geoGnomonic,3.4641,3.4641);case"identity":return{type:Tn};case"reflect-y":return{type:Bn};case"mercator":return Rn(e.geoMercator,Sn,Sn);case"orthographic":return Rn(e.geoOrthographic,2,2);case"stereographic":return Rn(e.geoStereographic,2,2);case"transverse-mercator":return Rn(e.geoTransverseMercator,Sn,Sn);default:throw new Error(`unknown projection type: ${t}`)}}function Rn(t,e,n){return{type:({width:r,height:o,rotate:i,precision:a=.15,clip:l})=>{const s=t();return null!=a&&s.precision?.(a),null!=i&&s.rotate?.(i),"number"==typeof l&&s.clipAngle?.(l),s.scale(Math.min(r/e,o/n)),s.translate([r/2,o/2]),s},aspectRatio:n/e}}function Cn(t,e,n){const{type:r,aspectRatio:o}=Rn(t,e,n);return{type:t=>{const{parallels:e,domain:n,width:o,height:i}=t,a=r(t);return null!=e&&(a.parallels(e),void 0===n&&a.fitSize([o,i],{type:"Sphere"})),a},aspectRatio:o}}const Tn=et({stream:t=>t}),Bn=et(e.geoTransform({point(t,e){this.stream.point(t,-e)}}));function Nn(t,e,n,r){const o=n[t],i=n[e],a=o.length,l=n[t]=new Float64Array(a).fill(NaN),s=n[e]=new Float64Array(a).fill(NaN);let c;const u=r.stream({point(t,e){l[c]=t,s[c]=e}});for(c=0;c1===r?[t[3][1]]:2===r?[t[3][1],t[3][2]]:(r=Math.max(3,Math.floor(r)))>9?e.quantize(n,r):t[r]}function Dn(t,n){return({length:r})=>2===r?[t[3][0],t[3][2]]:(r=Math.max(3,Math.floor(r)))>11?e.quantize(n,r):t[r]}function Yn(t,n){return({length:r})=>2===r?[t[3][2],t[3][0]]:(r=Math.max(3,Math.floor(r)))>11?e.quantize((t=>n(1-t)),r):t[r].slice().reverse()}function _n(t){return({length:n})=>e.quantize(t,Math.max(2,Math.floor(n)))}function Gn(t){return({length:n})=>e.quantize(t,Math.floor(n)+1).slice(0,-1)}function Xn(t){const e=`${t}`.toLowerCase();if(!qn.has(e))throw new Error(`unknown ordinal scheme: ${e}`);return qn.get(e)}function Hn(t,e){const n=Xn(t),r="function"==typeof n?n({length:e}):n;return r.length!==e?r.slice(0,e):r}const Un=new Map([["brbg",e.interpolateBrBG],["prgn",e.interpolatePRGn],["piyg",e.interpolatePiYG],["puor",e.interpolatePuOr],["rdbu",e.interpolateRdBu],["rdgy",e.interpolateRdGy],["rdylbu",e.interpolateRdYlBu],["rdylgn",e.interpolateRdYlGn],["spectral",e.interpolateSpectral],["burd",t=>e.interpolateRdBu(1-t)],["buylrd",t=>e.interpolateRdYlBu(1-t)],["blues",e.interpolateBlues],["greens",e.interpolateGreens],["greys",e.interpolateGreys],["purples",e.interpolatePurples],["reds",e.interpolateReds],["oranges",e.interpolateOranges],["turbo",e.interpolateTurbo],["viridis",e.interpolateViridis],["magma",e.interpolateMagma],["inferno",e.interpolateInferno],["plasma",e.interpolatePlasma],["cividis",e.interpolateCividis],["cubehelix",e.interpolateCubehelixDefault],["warm",e.interpolateWarm],["cool",e.interpolateCool],["bugn",e.interpolateBuGn],["bupu",e.interpolateBuPu],["gnbu",e.interpolateGnBu],["orrd",e.interpolateOrRd],["pubugn",e.interpolatePuBuGn],["pubu",e.interpolatePuBu],["purd",e.interpolatePuRd],["rdpu",e.interpolateRdPu],["ylgnbu",e.interpolateYlGnBu],["ylgn",e.interpolateYlGn],["ylorbr",e.interpolateYlOrBr],["ylorrd",e.interpolateYlOrRd],["rainbow",e.interpolateRainbow],["sinebow",e.interpolateSinebow]]);function Vn(t){const e=`${t}`.toLowerCase();if(!Un.has(e))throw new Error(`unknown quantitative scheme: ${e}`);return Un.get(e)}const Zn=new Set(["brbg","prgn","piyg","puor","rdbu","rdgy","rdylbu","rdylgn","spectral","burd","buylrd"]);const Qn=t=>e=>t(1-e),Jn=[0,1],Kn=new Map([["number",e.interpolateNumber],["rgb",e.interpolateRgb],["hsl",e.interpolateHsl],["hcl",e.interpolateHcl],["lab",e.interpolateLab]]);function tr(t){const e=`${t}`.toLowerCase();if(!Kn.has(e))throw new Error(`unknown interpolator: ${e}`);return Kn.get(e)}function er(t,n,r,{type:o,nice:i,clamp:a,zero:l,domain:s=ir(t,r),unknown:c,round:u,scheme:f,interval:h,range:p=(fe.get(t)===ae?lr(r,s):fe.get(t)===le?sr(r,s):fe.get(t)===se?Jn:void 0),interpolate:m=(fe.get(t)===ie?null==f&&void 0!==p?e.interpolateRgb:Vn(void 0!==f?f:"cyclical"===o?"rainbow":"turbo"):u?e.interpolateRound:e.interpolateNumber),reverse:y}){if(h=Wt(h,o),"cyclical"!==o&&"sequential"!==o||(o="linear"),"function"!=typeof m&&(m=tr(m)),y=!!y,void 0!==p){if((s=ht(s)).length!==(p=ht(p)).length){if(1===m.length)throw new Error("invalid piecewise interpolator");m=e.piecewise(m,p),p=void 0}}if(1===m.length?(y&&(m=Qn(m),y=!1),void 0===p&&2===(p=Float64Array.from(s,((t,e)=>e/(s.length-1)))).length&&(p=Jn),n.interpolate((p===Jn?et:fr)(m))):n.interpolate(m),l){const[t,n]=e.extent(s);(t>0||n<0)&&(d(s=pt(s))!==Math.sign(t)?s[s.length-1]=0:s[0]=0)}return y&&(s=e.reverse(s)),n.domain(s).unknown(c),i&&(n.nice(function(t,e){return!0===t?void 0:"number"==typeof t?t:function(t,e){if((t=Wt(t,e))&&"function"!=typeof t.ceil)throw new Error("invalid interval: missing ceil method");return t}(t,e)}(i,o)),s=n.domain()),void 0!==p&&n.range(p),a&&n.clamp(a),{type:o,domain:s,range:p,scale:n,interpolate:m,interval:h}}function nr(t,n,{exponent:r=1,...o}){return er(t,e.scalePow().exponent(r),n,{...o,type:"pow"})}function rr(t,n,{domain:r=[0],unknown:o,scheme:i="rdylbu",interpolate:a,range:l=(void 0!==a?e.quantize(a,r.length+1):fe.get(t)===ie?Hn(i,r.length+1):void 0),reverse:s}){const c=d(r=ht(r));if(!isNaN(c)&&!function(t,n){for(let r=1,o=t.length,i=t[0];rvoid 0===t?t:e.min(t,n))),e.max(t,(({value:t})=>void 0===t?t:e.max(t,n)))]:[0,1]}function ir(t,e){const n=fe.get(t);return(n===ae||n===se||n===le?ar:or)(e)}function ar(t){return[0,t.length?e.max(t,(({value:t})=>void 0===t?t:e.max(t,a))):1]}function lr(t,n){const r=t.find((({radius:t})=>void 0!==t));if(void 0!==r)return[0,r.radius];const o=e.quantile(t,.5,(({value:t})=>void 0===t?NaN:e.quantile(t,.25,l))),i=n.map((t=>3*Math.sqrt(t/o))),a=30/e.max(i);return a<1?i.map((t=>t*a)):i}function sr(t,n){const r=e.median(t,(({value:t})=>void 0===t?NaN:e.median(t,Math.abs))),o=n.map((t=>12*t/r)),i=60/e.max(o);return i<1?o.map((t=>t*i)):o}function cr(t){for(const{value:e}of t)if(void 0!==e)for(let n of e){if(n>0)return or(t,l);if(n<0)return or(t,s)}return[1,10]}function ur(t){const e=[];for(const{value:n}of t)if(void 0!==n)for(const t of n)e.push(t);return e}function fr(t){return(e,n)=>r=>t(e+r*(n-e))}function hr(t,n,r,o,{type:i,nice:a,clamp:l,domain:s=or(o),unknown:c,pivot:u=0,scheme:f,range:h,symmetric:d=!0,interpolate:p=(fe.get(t)===ie?null==f&&void 0!==h?e.interpolateRgb:Vn(void 0!==f?f:"rdbu"):e.interpolateNumber),reverse:m}){u=+u,s=ht(s);let[y,g]=s;if(s.length>2&&Ln(`Warning: the diverging ${t} scale domain contains extra elements.`),e.descending(y,g)<0&&([y,g]=[g,y],m=!m),y=Math.min(y,u),g=Math.max(g,u),"function"!=typeof p&&(p=tr(p)),void 0!==h&&(p=1===p.length?fr(p)(...h):e.piecewise(p,h)),m&&(p=Qn(p)),d){const t=r.apply(u),e=t-r.apply(y),n=r.apply(g)-t;en&&(g=r.invert(t+e))}return n.domain([y,u,g]).unknown(c).interpolator(p),l&&n.clamp(l),a&&n.nice(a),{type:i,domain:[y,g],pivot:u,interpolate:p,scale:n}}function dr(t,n,{exponent:r=1,...o}){return hr(t,e.scaleDivergingPow().exponent(r=+r),function(t){return.5===t?gr:{apply:e=>Math.sign(e)*Math.pow(Math.abs(e),t),invert:e=>Math.sign(e)*Math.pow(Math.abs(e),1/t)}}(r),n,{...o,type:"diverging-pow"})}function pr(t,n,{constant:r=1,...o}){return hr(t,e.scaleDivergingSymlog().constant(r=+r),function(t){return{apply:e=>Math.sign(e)*Math.log1p(Math.abs(e/t)),invert:e=>Math.sign(e)*Math.expm1(Math.abs(e))*t}}(r),n,o)}const mr={apply:t=>t,invert:t=>t},yr={apply:Math.log,invert:Math.exp},gr={apply:t=>Math.sign(t)*Math.sqrt(Math.abs(t)),invert:t=>Math.sign(t)*(t*t)};function vr(t,e,n,r){return er(t,e,n,r)}const xr=Symbol("ordinal");function wr(t,n,r,{type:o,interval:i,domain:a,range:l,reverse:s,hint:c}){return i=Wt(i,o),void 0===a&&(a=$r(r,i,t)),"categorical"!==o&&o!==xr||(o="ordinal"),s&&(a=e.reverse(a)),a=n.domain(a).domain(),void 0!==l&&("function"==typeof l&&(l=l(a)),n.range(l)),{type:o,domain:a,range:l,scale:n,hint:c,interval:i}}function br(t,n,{type:r,interval:o,domain:i,range:a,scheme:l,unknown:s,...c}){let u;if(o=Wt(o,r),void 0===i&&(i=$r(n,o,t)),fe.get(t)===ce)u=function(t){return{fill:Mr(t,"fill"),stroke:Mr(t,"stroke")}}(n),a=void 0===a?function(t){return Jt(t.fill)?e.symbolsStroke:e.symbolsFill}(u):dt(a,ve);else if(fe.get(t)===ie&&(void 0!==a||"ordinal"!==r&&r!==xr||(a=function(t,e="greys"){const n=new Set,[r,o]=Hn(e,2);for(const e of t)if(null!=e)if(!0===e)n.add(o);else{if(!1!==e)return;n.add(r)}return[...n]}(i,l),void 0!==a&&(l=void 0)),void 0===l&&void 0===a&&(l="ordinal"===r?"turbo":"observable10"),void 0!==l))if(void 0!==a){const t=Vn(l),n=a[0],r=a[1]-a[0];a=({length:o})=>e.quantize((e=>t(n+r*e)),o)}else a=Xn(l);if(s===e.scaleImplicit)throw new Error(`implicit unknown on ${t} scale is not supported`);return wr(t,e.scaleOrdinal().unknown(s),n,{...c,type:r,domain:i,range:a,hint:u})}function kr(t,e,n,r){let{round:o}=n;return void 0!==o&&t.round(o=!!o),(t=wr(r,t,e,n)).round=o,t}function $r(t,n,o){const i=new e.InternSet;for(const{value:e,domain:n}of t){if(void 0!==n)return n();if(void 0!==e)for(const t of e)i.add(t)}if(void 0!==n){const[t,r]=e.extent(i).map(n.floor,n);return n.range(t,n.offset(r))}if(i.size>1e4&&fe.get(o)===oe)throw new Error(`implicit ordinal domain of ${o} scale has more than 10,000 values`);return e.sort(i,r)}function Mr(t,e){let n;for(const{hint:r}of t){const t=r?.[e];if(void 0!==t)if(void 0===n)n=t;else if(n!==t)return}return n}function Lr(t,{label:e,inset:n=0,insetTop:r=n,insetRight:o=n,insetBottom:i=n,insetLeft:a=n,round:l,nice:s,clamp:c,zero:u,align:f,padding:h,projection:d,facet:{label:p=e}={},...m}={}){const y={};for(const[n,g]of t){const t=m[n],v=Ir(n,g,{round:fe.get(n)===oe?l:void 0,nice:s,clamp:c,zero:u,align:f,padding:h,projection:d,...t});if(v){let{label:l=("fx"===n||"fy"===n?p:e),percent:s,transform:c,inset:u,insetTop:f=(void 0!==u?u:"y"===n?r:0),insetRight:h=(void 0!==u?u:"x"===n?o:0),insetBottom:d=(void 0!==u?u:"y"===n?i:0),insetLeft:m=(void 0!==u?u:"x"===n?a:0)}=t||{};if(null==c)c=void 0;else if("function"!=typeof c)throw new Error("invalid scale transform; not a function");v.percent=!!s,v.label=void 0===l?Sr(g,v):l,v.transform=c,"x"===n||"fx"===n?(v.insetLeft=+m,v.insetRight=+h):"y"!==n&&"fy"!==n||(v.insetTop=+f,v.insetBottom=+d),y[n]=v}}return y}function Ar(t){const e={},n={scales:e};for(const[r,o]of Object.entries(t)){const{scale:t,type:i,interval:a,label:l}=o;e[r]=Xr(o),n[r]=t,t.type=i,null!=a&&(t.interval=a),null!=l&&(t.label=l)}return n}function Sr(t=[],e){let n;for(const{label:e}of t)if(void 0!==e)if(void 0===n)n=e;else if(n!==e)return;if(void 0!==n)return!Fr(e)&&e.percent&&(n=`${n} (%)`),{inferred:!0,toString:()=>n}}function zr(t){return Math.sign(d(t.domain()))*Math.sign(d(t.range()))}function Or(t){const{marginTop:e,marginRight:n,marginBottom:r,marginLeft:o,width:i,height:a,facet:{marginTop:l,marginRight:s,marginBottom:c,marginLeft:u}}=t;return{marginTop:Math.max(e,l),marginRight:Math.max(n,s),marginBottom:Math.max(r,c),marginLeft:Math.max(o,u),width:i,height:a}}function Er({fx:t,fy:e},n){const{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:l,height:s}=Or(n);return{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:t?t.scale.bandwidth()+a+o:l,height:e?e.scale.bandwidth()+r+i:s,facet:{width:l,height:s}}}function Rr(t,e){if(void 0===t.range){const{insetLeft:n,insetRight:r}=t,{width:o,marginLeft:i=0,marginRight:a=0}=e,l=i+n,s=o-a-r;t.range=[l,Math.max(l,s)],Fr(t)||(t.range=Br(t)),t.scale.range(t.range)}Tr(t)}function Cr(t,e){if(void 0===t.range){const{insetTop:n,insetBottom:r}=t,{height:o,marginTop:i=0,marginBottom:a=0}=e,l=i+n,s=o-a-r;t.range=[Math.max(l,s),l],Fr(t)?t.range.reverse():t.range=Br(t),t.scale.range(t.range)}Tr(t)}function Tr(t){void 0===t.round&&function({type:t}){return"point"===t||"band"===t}(t)&&function({scale:t}){const e=t.domain().length,[n,r]=t.range(),o=t.paddingInner?t.paddingInner():1,i=t.paddingOuter?t.paddingOuter():t.padding(),a=e-o,l=Math.abs(r-n)/Math.max(1,a+2*i);return(l-Math.floor(l))*a}(t)<=30&&t.scale.round(!0)}function Br(t){const e=t.scale.domain().length+Dr(t);if(!(e>2))return t.range;const[n,r]=t.range;return Array.from({length:e},((t,o)=>n+o/(e-1)*(r-n)))}function Nr(t,e,n){return Ir(t,void 0===n?void 0:[{hint:n}],{...e})}function Ir(t,n=[],r={}){const o=function(t,e,{type:n,domain:r,range:o,scheme:i,pivot:a,projection:l}){if(n=Wr(n),"fx"===t||"fy"===t)return"band";"x"!==t&&"y"!==t||null==l||(n=jr);for(const t of e){const e=Wr(t.type);if(void 0!==e)if(void 0===n)n=e;else if(n!==e)throw new Error(`scale incompatible with channel: ${n} !== ${e}`)}if(n===jr)return;if(void 0!==n)return n;if(void 0===r&&!e.some((({value:t})=>void 0!==t)))return;const s=fe.get(t);if(s===ae)return"sqrt";if(s===se||s===le)return"linear";if(s===ce)return"ordinal";if((r||o||[]).length>2)return qr(s);if(void 0!==r){if(Yt(r))return qr(s);if(_t(r))return"utc"}else{const t=e.map((({value:t})=>t)).filter((t=>void 0!==t));if(t.some(Yt))return qr(s);if(t.some(_t))return"utc"}if(s===ie){if(null!=a||function(t){return null!=t&&Zn.has(`${t}`.toLowerCase())}(i))return"diverging";if(function(t){return null!=t&&jn.has(`${t}`.toLowerCase())}(i))return"categorical"}return"linear"}(t,n,r);if(void 0===r.type&&void 0===r.domain&&void 0===r.range&&null==r.interval&&"fx"!==t&&"fy"!==t&&Fr({type:o})){const e=n.map((({value:t})=>t)).filter((t=>void 0!==t));e.some(_t)?Ln(`Warning: some data associated with the ${t} scale are dates. Dates are typically associated with a "utc" or "time" scale rather than a "${Pr(o)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can specify the interval of the ${t} scale (e.g., d3.utcDay), or you can suppress this warning by setting the type of the ${t} scale to "${Pr(o)}".`):e.some(Gt)?Ln(`Warning: some data associated with the ${t} scale are strings that appear to be dates (e.g., YYYY-MM-DD). If these strings represent dates, you should parse them to Date objects. Dates are typically associated with a "utc" or "time" scale rather than a "${Pr(o)}" scale. If you are using a bar mark, you probably want a rect mark with the interval option instead; if you are using a group transform, you probably want a bin transform instead. If you want to treat this data as ordinal, you can suppress this warning by setting the type of the ${t} scale to "${Pr(o)}".`):e.some(Xt)&&Ln(`Warning: some data associated with the ${t} scale are strings that appear to be numbers. If these strings represent numbers, you should parse or coerce them to numbers. Numbers are typically associated with a "linear" scale rather than a "${Pr(o)}" scale. If you want to treat this data as ordinal, you can specify the interval of the ${t} scale (e.g., 1 for integers), or you can suppress this warning by setting the type of the ${t} scale to "${Pr(o)}".`)}switch(r.type=o,o){case"diverging":case"diverging-sqrt":case"diverging-pow":case"diverging-log":case"diverging-symlog":case"cyclical":case"sequential":case"linear":case"sqrt":case"threshold":case"quantile":case"pow":case"log":case"symlog":r=_r(n,r,rt);break;case"identity":switch(fe.get(t)){case oe:r=_r(n,r,rt);break;case ce:r=_r(n,r,Gr)}break;case"utc":case"time":r=_r(n,r,at)}switch(o){case"diverging":return function(t,n,r){return hr(t,e.scaleDiverging(),mr,n,r)}(t,n,r);case"diverging-sqrt":return function(t,e,n){return dr(t,e,{...n,exponent:.5})}(t,n,r);case"diverging-pow":return dr(t,n,r);case"diverging-log":return function(t,n,{base:r=10,pivot:o=1,domain:i=or(n,o<0?s:l),...a}){return hr(t,e.scaleDivergingLog().base(r=+r),yr,n,{domain:i,pivot:o,...a})}(t,n,r);case"diverging-symlog":return pr(t,n,r);case"categorical":case"ordinal":case xr:return br(t,n,r);case"cyclical":case"sequential":case"linear":return function(t,n,r){return er(t,e.scaleLinear(),n,r)}(t,n,r);case"sqrt":return function(t,e,n){return nr(t,e,{...n,exponent:.5})}(t,n,r);case"threshold":return rr(t,0,r);case"quantile":return function(t,n,{range:r,quantiles:o=(void 0===r?5:(r=[...r]).length),n:i=o,scheme:a="rdylbu",domain:l=ur(n),unknown:s,interpolate:c,reverse:u}){return void 0===r&&(r=void 0!==c?e.quantize(c,i):fe.get(t)===ie?Hn(a,i):void 0),l.length>0&&(l=e.scaleQuantile(l,void 0===r?{length:i}:r).quantiles()),rr(t,0,{domain:l,range:r,reverse:u,unknown:s})}(t,n,r);case"quantize":return function(t,n,{range:r,n:o=(void 0===r?5:(r=[...r]).length),scheme:i="rdylbu",domain:a=ir(t,n),unknown:l,interpolate:s,reverse:c}){const[u,f]=e.extent(a);let h;return void 0===r?(h=e.ticks(u,f,o),h[0]<=u&&h.splice(0,1),h[h.length-1]>=f&&h.pop(),o=h.length+1,r=void 0!==s?e.quantize(s,o):fe.get(t)===ie?Hn(i,o):void 0):(h=e.quantize(e.interpolateNumber(u,f),o+1).slice(1,-1),u instanceof Date&&(h=h.map((t=>new Date(t))))),d(ht(a))<0&&h.reverse(),rr(t,0,{domain:h,range:r,reverse:c,unknown:l})}(t,n,r);case"pow":return nr(t,n,r);case"log":return function(t,n,{base:r=10,domain:o=cr(n),...i}){return er(t,e.scaleLog().base(r),n,{...i,domain:o})}(t,n,r);case"symlog":return function(t,n,{constant:r=1,...o}){return er(t,e.scaleSymlog().constant(r),n,o)}(t,n,r);case"utc":return function(t,n,r){return vr(t,e.scaleUtc(),n,r)}(t,n,r);case"time":return function(t,n,r){return vr(t,e.scaleTime(),n,r)}(t,n,r);case"point":return function(t,n,{align:r=.5,padding:o=.5,...i}){return kr(e.scalePoint().align(r).padding(o),n,i,t)}(t,n,r);case"band":return function(t,n,{align:r=.5,padding:o=.1,paddingInner:i=o,paddingOuter:a=("fx"===t||"fy"===t?0:o),...l}){return kr(e.scaleBand().align(r).paddingInner(i).paddingOuter(a),n,l,t)}(t,n,r);case"identity":return function(t){return{type:"identity",scale:(n=fe.get(t),n===oe||n===ae||n===le||n===se?e.scaleIdentity():t=>t)};var n}(t);case void 0:return;default:throw new Error(`unknown scale type: ${o}`)}}function Pr(t){return"symbol"==typeof t?t.description:t}function Wr(t){return"string"==typeof t?`${t}`.toLowerCase():t}const jr={toString:()=>"projection"};function qr(t){switch(t){case oe:return"point";case ie:return xr;default:return"ordinal"}}function Fr({type:t}){return"ordinal"===t||"point"===t||"band"===t||t===xr}function Dr({type:t}){return"threshold"===t}function Yr(t){if(void 0===t)return!0;const e=t.domain(),n=t(e[0]);for(let r=1,o=e.length;rt,invert:t=>t};const c=t.unknown?t.unknown():void 0;return{type:e,domain:pt(n),...void 0!==r&&{range:pt(r)},...void 0!==a&&{transform:a},...l&&{percent:l},...void 0!==c&&{unknown:c},...void 0!==i&&{interval:i},...void 0!==o&&{interpolate:o},...t.clamp&&{clamp:t.clamp()},...void 0!==s&&{pivot:s,symmetric:!1},...t.base&&{base:t.base()},...t.exponent&&{exponent:t.exponent()},...t.constant&&{constant:t.constant()},...t.align&&{align:t.align(),round:t.round()},...t.padding&&(t.paddingInner?{paddingInner:t.paddingInner(),paddingOuter:t.paddingOuter()}:{padding:t.padding()}),...t.bandwidth&&{bandwidth:t.bandwidth(),step:t.step()},apply:e=>t(e),...t.invert&&{invert:e=>t.invert(e)}}}function Hr(t){let e,n;return(...r)=>((n?.length!==r.length||n.some(((t,e)=>t!==r[e])))&&(n=r,e=t(...r)),e)}const Ur=Hr((t=>new Intl.NumberFormat(t))),Vr=Hr(((t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...e&&{month:e}}))),Zr=Hr(((t,e)=>new Intl.DateTimeFormat(t,{timeZone:"UTC",...e&&{weekday:e}})));function Qr(t){return c(t,"Invalid Date")}const Jr=function(t="en-US"){const e=function(t="en-US"){const e=Ur(t);return t=>null==t||isNaN(t)?void 0:e.format(t)}(t);return t=>(t instanceof Date?Qr:"number"==typeof t?e:Z)(t)}(),Kr=("undefined"!=typeof window?window.devicePixelRatio>1:"undefined"==typeof it)?0:.5;let to=0;function eo(){return"plot-clip-"+ ++to}function no(t,{title:e,href:n,ariaLabel:r,ariaDescription:o,ariaHidden:i,target:a,fill:l,fillOpacity:s,stroke:c,strokeWidth:u,strokeOpacity:f,strokeLinejoin:h,strokeLinecap:d,strokeMiterlimit:p,strokeDasharray:m,strokeDashoffset:y,opacity:g,mixBlendMode:v,imageFilter:x,paintOrder:w,pointerEvents:b,shapeRendering:k,channels:$},{ariaLabel:M,fill:L="currentColor",fillOpacity:A,stroke:S="none",strokeOpacity:z,strokeWidth:O,strokeLinecap:E,strokeLinejoin:R,strokeMiterlimit:C,paintOrder:T}){null===L&&(l=null,s=null),null===S&&(c=null,f=null),Jt(L)?Jt(S)||Jt(l)&&!$?.fill||(S="none"):!Jt(S)||Jt(c)&&!$?.stroke||(L="none");const[B,N]=st(l,L),[I,P]=ct(s,A),[W,j]=st(c,S),[q,F]=ct(f,z),[D,Y]=ct(g);Kt(j)||(void 0===u&&(u=O),void 0===d&&(d=E),void 0===h&&(h=R),void 0!==p||/^\s*round\s*$/i.test(h)||(p=C),Kt(N)||void 0!==w||(w=T));const[_,G]=ct(u);return null!==L&&(t.fill=mo(N,"currentColor"),t.fillOpacity=yo(P,1)),null!==S&&(t.stroke=mo(j,"none"),t.strokeWidth=yo(G,1),t.strokeOpacity=yo(F,1),t.strokeLinejoin=mo(h,"miter"),t.strokeLinecap=mo(d,"butt"),t.strokeMiterlimit=yo(p,4),t.strokeDasharray=mo(m,"none"),t.strokeDashoffset=mo(y,"0")),t.target=Z(a),t.ariaLabel=Z(M),t.ariaDescription=Z(o),t.ariaHidden=Z(i),t.opacity=yo(Y,1),t.mixBlendMode=mo(v,"normal"),t.imageFilter=mo(x,"none"),t.paintOrder=mo(w,"normal"),t.pointerEvents=mo(b,"auto"),t.shapeRendering=mo(k,"auto"),{title:{value:e,optional:!0,filter:null},href:{value:n,optional:!0,filter:null},ariaLabel:{value:r,optional:!0,filter:null},fill:{value:B,scale:"auto",optional:!0},fillOpacity:{value:I,scale:"auto",optional:!0},stroke:{value:W,scale:"auto",optional:!0},strokeOpacity:{value:q,scale:"auto",optional:!0},strokeWidth:{value:_,optional:!0},opacity:{value:D,scale:"auto",optional:!0}}}function ro(t,e){e&&t.text((t=>Jr(e[t])))}function oo(t,e){e&&t.text((([t])=>Jr(e[t])))}function io(t,{target:e,tip:n},{ariaLabel:r,title:o,fill:a,fillOpacity:l,stroke:s,strokeOpacity:c,strokeWidth:u,opacity:f,href:h}){r&&ho(t,"aria-label",(t=>r[t])),a&&ho(t,"fill",(t=>a[t])),l&&ho(t,"fill-opacity",(t=>l[t])),s&&ho(t,"stroke",(t=>s[t])),c&&ho(t,"stroke-opacity",(t=>c[t])),u&&ho(t,"stroke-width",(t=>u[t])),f&&ho(t,"opacity",(t=>f[t])),h&&fo(t,(t=>h[t]),e),n||function(t,e){e&&t.filter((t=>i(e[t]))).append("title").call(ro,e)}(t,o)}function ao(t,{target:e,tip:n},{ariaLabel:r,title:o,fill:a,fillOpacity:l,stroke:s,strokeOpacity:c,strokeWidth:u,opacity:f,href:h}){r&&ho(t,"aria-label",(([t])=>r[t])),a&&ho(t,"fill",(([t])=>a[t])),l&&ho(t,"fill-opacity",(([t])=>l[t])),s&&ho(t,"stroke",(([t])=>s[t])),c&&ho(t,"stroke-opacity",(([t])=>c[t])),u&&ho(t,"stroke-width",(([t])=>u[t])),f&&ho(t,"opacity",(([t])=>f[t])),h&&fo(t,(([t])=>h[t]),e),n||function(t,e){e&&t.filter((([t])=>i(e[t]))).append("title").call(oo,e)}(t,o)}function lo(t,n,r){const o=e.group(t,(t=>n[t]));return void 0===r&&o.size>1+t.length>>1&&Ln("Warning: the implicit z channel has high cardinality. This may occur when the fill or stroke channel is associated with quantitative data rather than ordinal or categorical data. You can suppress this warning by setting the z option explicitly; if this data represents a single series, set z to null."),o.values()}function*so(t,e,r,o){const{z:i}=r,{z:a}=o,l=function({ariaLabel:t,title:e,fill:n,fillOpacity:r,stroke:o,strokeOpacity:i,strokeWidth:a,opacity:l,href:s},{tip:c}){return[t,c?void 0:e,n,r,o,i,a,l,s].filter((t=>void 0!==t))}(o,r),s=[...e,...l];for(const e of a?lo(t,a,i):[t]){let t,r;t:for(const o of e){for(const t of s)if(!n(t[o])){r&&r.push(-1);continue t}if(void 0!==t){r.push(o);for(let e=0;eOt(t[o]))),r=[o];continue t}}}else r&&(yield r),t=l.map((t=>Ot(t[o]))),r=[o]}r&&(yield r)}}function co(t,n,r,o){!function(t,n,r,o){let i;const{clip:a=o.clip}=n;switch(a){case"frame":{const{width:e,height:n,marginLeft:a,marginRight:l,marginTop:s,marginBottom:c}=r,u=eo();i=`url(#${u})`,t=kn("svg:g",o).call((t=>t.append("svg:clipPath").attr("id",u).append("rect").attr("x",a).attr("y",s).attr("width",e-l-a).attr("height",n-s-c))).each((function(){this.appendChild(t.node()),t.node=()=>this}));break}case"sphere":{const{projection:n}=o;if(!n)throw new Error('the "sphere" clip option requires a projection');const r=eo();i=`url(#${r})`,t.append("clipPath").attr("id",r).append("path").attr("d",e.geoPath(n)({type:"Sphere"}));break}}ho(t,"aria-label",n.ariaLabel),ho(t,"aria-description",n.ariaDescription),ho(t,"aria-hidden",n.ariaHidden),ho(t,"clip-path",i)}(t,n,r,o),ho(t,"fill",n.fill),ho(t,"fill-opacity",n.fillOpacity),ho(t,"stroke",n.stroke),ho(t,"stroke-width",n.strokeWidth),ho(t,"stroke-opacity",n.strokeOpacity),ho(t,"stroke-linejoin",n.strokeLinejoin),ho(t,"stroke-linecap",n.strokeLinecap),ho(t,"stroke-miterlimit",n.strokeMiterlimit),ho(t,"stroke-dasharray",n.strokeDasharray),ho(t,"stroke-dashoffset",n.strokeDashoffset),ho(t,"shape-rendering",n.shapeRendering),ho(t,"filter",n.imageFilter),ho(t,"paint-order",n.paintOrder);const{pointerEvents:i=(!1===o.pointerSticky?"none":void 0)}=n;ho(t,"pointer-events",i)}function uo(t,e){!function(t,e,n){null!=n&&t.style(e,n)}(t,"mix-blend-mode",e.mixBlendMode),ho(t,"opacity",e.opacity)}function fo(t,n,r){t.each((function(t){const o=n(t);if(null!=o){const t=this.ownerDocument.createElementNS(e.namespaces.svg,"a");t.setAttribute("fill","inherit"),t.setAttributeNS(e.namespaces.xlink,"href",o),null!=r&&t.setAttribute("target",r),this.parentNode.insertBefore(t,this).appendChild(this)}}))}function ho(t,e,n){null!=n&&t.attr(e,n)}function po(t,e,{x:n,y:r},o=Kr,i=Kr){o+=e.dx,i+=e.dy,n?.bandwidth&&(o+=n.bandwidth()/2),r?.bandwidth&&(i+=r.bandwidth()/2),(o||i)&&t.attr("transform",`translate(${o},${i})`)}function mo(t,e){if((t=Z(t))!==e)return t}function yo(t,e){if((t=Q(t))!==e)return t}const go=/^-?([_a-z]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\240-\377]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*$/i;function vo(t){if(void 0===t)return"plot-d6a7b5";if(t=`${t}`,!go.test(t))throw new Error(`invalid class name: ${t}`);return t}function xo(t,e){if("string"==typeof e)t.property("style",e);else if(null!=e)for(const n of t)Object.assign(n.style,e)}function wo({frameAnchor:t},{width:e,height:n,marginTop:r,marginRight:o,marginBottom:i,marginLeft:a}){return[/left$/.test(t)?a:/right$/.test(t)?e-o:(a+e-o)/2,/^top/.test(t)?r:/^bottom/.test(t)?n-i:(r+n-i)/2]}function bo({x:t,y:e,fy:n,fx:r},{projection:o,aspectRatio:i},{width:a,marginTopDefault:l,marginRightDefault:s,marginBottomDefault:c,marginLeftDefault:u}){const f=n?n.scale.domain().length:1,h=function(t){if("function"==typeof t?.stream)return zn;if(vt(t)&&(t=t.type),null!=t){if("function"!=typeof t){const{aspectRatio:e}=En(t);if(e)return e}return zn}}(o);if(h){const t=(1.1*f-.1)/(1.1*(r?r.scale.domain().length:1)-.1)*h,e=Math.max(.1,Math.min(10,t));return Math.round((a-u-s)*e+l+c)}const d=e?Fr(e)?e.scale.domain().length:Math.max(7,17/f):1;if(null!=i){if(i=+i,!(isFinite(i)&&i>0))throw new Error(`invalid aspectRatio: ${i}`);const o=ko("y",e)/(ko("x",t)*i),f=r?r.scale.bandwidth():1,h=n?n.scale.bandwidth():1;return(o*(f*(a-u-s)-t.insetLeft-t.insetRight)+e.insetTop+e.insetBottom)/h+l+c}return!(!e&&!n)*Math.max(1,Math.min(60,d*f))*20+30*!!r+60}function ko(t,n){if(!n)throw new Error(`aspectRatio requires ${t} scale`);const{type:r,domain:o}=n;let i;switch(r){case"linear":case"utc":case"time":i=Number;break;case"pow":{const t=n.scale.exponent();i=e=>Math.pow(e,t);break}case"log":i=Math.log;break;case"point":case"band":return o.length;default:throw new Error(`unsupported ${t} scale for aspectRatio: ${r}`)}const[a,l]=e.extent(o);return Math.abs(i(l)-i(a))}function $o(t,{fx:n,fy:r}){const o=Lt(t),i=n?.value,a=r?.value;return n&&r?e.rollup(o,(t=>(t.fx=i[t[0]],t.fy=a[t[0]],t)),(t=>i[t]),(t=>a[t])):n?e.rollup(o,(t=>(t.fx=i[t[0]],t)),(t=>i[t])):e.rollup(o,(t=>(t.fy=a[t[0]],t)),(t=>a[t]))}function Mo(t){const n=[],r=new Uint32Array(e.sum(t,(t=>t.length)));for(const e of t){let o=0;for(const n of t)e!==n&&(r.set(n,o),o+=n.length);n.push(r.slice(0,o))}return n}const Lo=new Map([["top",Eo],["right",To],["bottom",Ro],["left",Co],["top-left",Bo(Eo,Co)],["top-right",Bo(Eo,To)],["bottom-left",Bo(Ro,Co)],["bottom-right",Bo(Ro,To)],["top-empty",function(t,{y:e},{x:n,y:r,empty:o}){if(o)return!1;if(!e)return;const i=zo(e,r);if(i>0)return Oo(t,n,e[i-1])}],["right-empty",function(t,{x:e},{x:n,y:r,empty:o}){if(o)return!1;if(!e)return;const i=zo(e,n);if(i0)return Oo(t,e[i-1],r)}],["empty",function(t,e,{empty:n}){return n}]]);const Ao=new WeakMap;function So(t){let n=Ao.get(t);return n||Ao.set(t,n=new e.InternMap(dt(t,((t,e)=>[t,e])))),n}function zo(t,e){return So(t).get(e)}function Oo(t,e,n){return function(t,e,n){return e=Ot(e),n=Ot(n),t.find((t=>Object.is(Ot(t.x),e)&&Object.is(Ot(t.y),n)))}(t,e,n)?.empty}function Eo(t,{y:e},{y:n}){return!e||0===zo(e,n)}function Ro(t,{y:e},{y:n}){return!e||zo(e,n)===e.length-1}function Co(t,{x:e},{x:n}){return!e||0===zo(e,n)}function To(t,{x:e},{x:n}){return!e||zo(e,n)===e.length-1}function Bo(t,e){return function(){return t.apply(null,arguments)&&e.apply(null,arguments)}}function No(t,{channels:{fx:e,fy:n},groups:r}){return e&&n?t.map((({x:t,y:e})=>r.get(t)?.get(e)??[])):e?t.map((({x:t})=>r.get(t)??[])):t.map((({y:t})=>r.get(t)??[]))}class Io{constructor(t,e={},n={},r){const{facet:o="auto",facetAnchor:i,fx:a,fy:l,sort:s,dx:c=0,dy:u=0,margin:f=0,marginTop:h=f,marginRight:d=f,marginBottom:p=f,marginLeft:m=f,clip:y=r?.clip,channels:g,tip:v,render:x}=n;if(this.data=t,this.sort=bt(s)?s:null,this.initializer=we(n).initializer,this.transform=this.initializer?n.transform:xe(n).transform,null===o||!1===o?this.facet=null:(this.facet=ft(!0===o?"include":o,"facet",["auto","include","exclude","super"]),this.fx=t===_&&"string"==typeof a?[a]:a,this.fy=t===_&&"string"==typeof l?[l]:l),this.facetAnchor=function(t){if(null==t)return null;const e=Lo.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid facet anchor: ${t}`)}(i),e=ne(e),void 0!==g&&(e={...jo(g),...e}),void 0!==r&&(e={...no(this,n,r),...e}),this.channels=Object.fromEntries(Object.entries(e).map((([e,n])=>{if(wt(n.value)){const{value:t,label:e=n.label,scale:r=n.scale}=n.value;n={...n,label:e,scale:r,value:t}}if(t===_&&"string"==typeof n.value){const{value:t}=n;n={...n,value:[t]}}return[e,n]})).filter((([t,{value:e,optional:n}])=>{if(null!=e)return!0;if(n)return!1;throw new Error(`missing channel value: ${t}`)}))),this.dx=+c,this.dy=+u,this.marginTop=+h,this.marginRight=+d,this.marginBottom=+p,this.marginLeft=+m,this.clip=re(y),this.tip=function(t){return!0===t?"xy":!1===t||null==t?null:"string"==typeof t?ft(t,"tip",["x","y","xy"]):t}(v),"super"===this.facet){if(a||l)throw new Error("super-faceting cannot use fx or fy");for(const t in this.channels){const{scale:n}=e[t];if("x"===n||"y"===n)throw new Error("super-faceting cannot use x or y")}}null!=x&&(this.render=Wo(x,this.render))}initialize(t,n,r){let o=ht(this.data);void 0===t&&null!=o&&(t=[Lt(o)]);const i=t;null!=this.transform&&(({facets:t,data:o}=this.transform(o,t,r)),o=ht(o)),void 0!==t&&(t.original=i);const a=un(this.channels,o);return null!=this.sort&&function(t,n,r,o,i){const{order:a,reverse:l,reduce:s=!0,limit:c}=i;for(const u in i){if(!fe.has(u))continue;let{value:f,order:h=a,reverse:d=l,reduce:p=s,limit:m=c}=qt(i[u]);const y=f?.startsWith("-");if(y&&(f=f.slice(1)),h=void 0===h?y!==("width"===f||"height"===f)?xn:vn:gn(h),null==p||!1===p)continue;const g="fx"===u||"fy"===u?pn(n,o[u]):dn(r,u);if(!g)throw new Error(`missing channel for scale: ${u}`);const v=g.value,[x=0,w=1/0]=Ft(m)?m:m<0?[m]:[0,m];if(null==f)g.domain=()=>{let t=Array.from(new e.InternSet(v));return d&&(t=t.reverse()),0===x&&w===1/0||(t=t.slice(x,w)),t};else{const n="data"===f?t:"height"===f?mn(r,"y1","y2"):"width"===f?mn(r,"x1","x2"):yn(r,f,"y"===f?"y2":"x"===f?"x2":void 0),o=qe(!0===p?"max":p,n);g.domain=()=>{let t=e.rollups(Lt(v),(t=>o.reduceIndex(t,n)),(t=>v[t]));return h&&t.sort(h),d&&t.reverse(),0===x&&w===1/0||(t=t.slice(x,w)),t.map(J)}}}}(o,t,a,n,this.sort),{data:o,facets:t,channels:a}}filter(t,e,r){for(const o in e){const{filter:i=n}=e[o];if(null!==i){const e=r[o];t=t.filter((t=>i(e[t])))}}return t}project(t,e,n){for(const r in t)if("x"===t[r].scale&&/^x|x$/.test(r)){const o=r.replace(/^x|x$/,"y");o in t&&"y"===t[o].scale&&Nn(r,o,e,n.projection)}}scale(t,e,n){const r=fn(t,e);return n.projection&&this.project(t,r,n),r}}function Po(...t){return t.plot=Io.prototype.plot,t}function Wo(t,e){if(null==t)return null===e?void 0:e;if(null==e)return null===t?void 0:t;if("function"!=typeof t)throw new TypeError(`invalid render transform: ${t}`);if("function"!=typeof e)throw new TypeError(`invalid render transform: ${e}`);return function(n,r,o,i,a,l){return t.call(this,n,r,o,i,a,((t,n,r,o,i)=>e.call(this,t,n,r,o,i,l)))}}function jo(t){return Object.fromEntries(Object.entries(ne(t)).map((([t,e])=>(void 0===(e="string"==typeof e?{value:e,label:t}:qt(e)).filter&&null==e.scale&&(e={...e,filter:null}),[t,e]))))}function qo(t,e){return!0===t?.tip?{...t,tip:e}:vt(t?.tip)&&void 0===t.tip.pointer?{...t,tip:{...t.tip,pointer:e}}:t}const Fo=new WeakMap;function Do(t,n,{x:r,y:o,px:i,py:a,maxRadius:l=40,channels:s,render:c,...u}={}){return l=+l,null!=i&&(r??=null,s={...s,px:{value:i,scale:"x"}}),null!=a&&(o??=null,s={...s,py:{value:a,scale:"y"}}),{x:r,y:o,channels:s,...u,render:Wo((function(r,o,i,a,s,c){const u=(s={...s,pointerSticky:!1}).ownerSVGElement,{data:f}=s.getMarkState(this);let h=Fo.get(u);h||Fo.set(u,h={sticky:!1,roots:[],renders:[]});let d=h.renders.push(T)-1;const{x:p,y:m,fx:y,fy:g}=o;let v=y?y(r.fx)-a.marginLeft:0,x=g?g(r.fy)-a.marginTop:0;p?.bandwidth&&(v+=p.bandwidth()/2),m?.bandwidth&&(x+=m.bandwidth()/2);const w=null!=r.fi;let b;if(w){let t=h.facetStates;t||(h.facetStates=t=new Map),b=t.get(this),b||t.set(this,b=new Map)}const[k,$]=wo(this,a),{px:M,py:L}=i,A=M?t=>M[t]:Xo(i,k),S=L?t=>L[t]:Ho(i,$);let z,O,E,R;function C(t,e){if(w){if(R&&(R=cancelAnimationFrame(R)),null!=t)return b.set(r.fi,e),void(R=requestAnimationFrame((()=>{R=null;for(const[n,o]of b)if(o1||s.dispatchValue(null==z?null:f[z]),n}function B(o){if(h.sticky||"mouse"===o.pointerType&&1===o.buttons)return;let[i,s]=e.pointer(o);i-=v,s-=x;const c=ia.width-a.marginRight?1:t,u=sa.height-a.marginBottom?1:n;let f=null,d=l*l;for(const t of r){const e=c*(A(t)-i),n=u*(S(t)-s),r=e*e+n*n;r<=d&&(f=t,d=r)}if(null!=f&&(1!==t||1!==n)){const t=A(f)-i,e=S(f)-s;d=t*t+e*e}C(f,d)}return u.addEventListener("pointerenter",B),u.addEventListener("pointermove",B),u.addEventListener("pointerdown",(function(t){"mouse"===t.pointerType&&null!=z&&(h.sticky&&h.roots.some((e=>e?.contains(t.target)))||(h.sticky?(h.sticky=!1,h.renders.forEach((t=>t(null)))):(h.sticky=!0,T(z)),t.stopImmediatePropagation()))})),u.addEventListener("pointerleave",(function(t){"mouse"===t.pointerType&&(h.sticky||C(null))})),T(null)}),c)}}function Yo(t){return Do(1,1,t)}function _o(t){return Do(1,.01,t)}function Go(t){return Do(.01,1,t)}function Xo({x1:t,x2:e,x:n=t},r){return t&&e?n=>(t[n]+e[n])/2:n?t=>n[t]:()=>r}function Ho({y1:t,y2:e,y:n=t},r){return t&&e?n=>(t[n]+e[n])/2:n?t=>n[t]:()=>r}function Uo(t){return Fr(t)&&void 0===t.interval?void 0:"tabular-nums"}const Vo=Math.PI/180;function Zo(t,{marker:e,markerStart:n=e,markerMid:r=e,markerEnd:o=e}={}){t.markerStart=Qo(n),t.markerMid=Qo(r),t.markerEnd=Qo(o)}function Qo(t){if(null==t||!1===t)return null;if(!0===t)return ti;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"none":return null;case"arrow":return Jo("auto");case"arrow-reverse":return Jo("auto-start-reverse");case"dot":return Ko;case"circle":case"circle-fill":return ti;case"circle-stroke":return ei;case"tick":return ni("auto");case"tick-x":return ni(90);case"tick-y":return ni(0)}throw new Error(`invalid marker: ${t}`)}function Jo(t){return(e,n)=>kn("svg:marker",n).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("orient",t).attr("fill","none").attr("stroke",e).attr("stroke-width",1.5).attr("stroke-linecap","round").attr("stroke-linejoin","round").call((t=>t.append("path").attr("d","M-1.5,-3l3,3l-3,3"))).node()}function Ko(t,e){return kn("svg:marker",e).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","none").call((t=>t.append("circle").attr("r",2.5))).node()}function ti(t,e){return kn("svg:marker",e).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill",t).attr("stroke","var(--plot-background)").attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}function ei(t,e){return kn("svg:marker",e).attr("viewBox","-5 -5 10 10").attr("markerWidth",6.67).attr("markerHeight",6.67).attr("fill","var(--plot-background)").attr("stroke",t).attr("stroke-width",1.5).call((t=>t.append("circle").attr("r",3))).node()}function ni(t){return(e,n)=>kn("svg:marker",n).attr("viewBox","-3 -3 6 6").attr("markerWidth",6).attr("markerHeight",6).attr("orient",t).attr("stroke",e).call((t=>t.append("path").attr("d","M0,-3v6"))).node()}let ri=0;function oi(t,e,{stroke:n},r){return ai(t,e,n&&(t=>n[t]),r)}function ii(t,e,{stroke:n},r){return ai(t,e,n&&(([t])=>n[t]),r)}function ai(t,{markerStart:e,markerMid:n,markerEnd:r,stroke:o},i=(()=>o),a){const l=new Map;function s(t){return function(e){const n=i(e);let r=l.get(t);r||l.set(t,r=new Map);let o=r.get(n);if(!o){const e=this.parentNode.insertBefore(t(n,a),this),i="plot-marker-"+ ++ri;e.setAttribute("id",i),r.set(n,o=`url(#${i})`)}return o}}e&&t.attr("marker-start",s(e)),n&&t.attr("marker-mid",s(n)),r&&t.attr("marker-end",s(r))}function li({inset:t,insetLeft:e,insetRight:n,...r}={}){return[e,n]=ci(t,e,n),{inset:t,insetLeft:e,insetRight:n,...r}}function si({inset:t,insetTop:e,insetBottom:n,...r}={}){return[e,n]=ci(t,e,n),{inset:t,insetTop:e,insetBottom:n,...r}}function ci(t,e,n){return void 0===t&&void 0===e&&void 0===n?Kr?[1,0]:[.5,.5]:[e,n]}function ui(t,{interval:e}){return(t={...qt(t)}).interval=Pt(void 0===t.interval?e:t.interval),t}function fi(t,e,n,r){const{[t]:o,[`${t}1`]:i,[`${t}2`]:a}=n,{value:l,interval:s}=ui(o,n);if(null==l||null==s&&!r)return n;const c=Tt(o);if(null==s){let e;const o={transform:t=>e||(e=F(t,l)),label:c};return{...n,[t]:void 0,[`${t}1`]:void 0===i?o:i,[`${t}2`]:void 0!==a||i===a&&r?a:o}}let u,f;function h(t){return void 0!==f&&t===u?f:f=dt(F(u=t,l),(t=>s.floor(t)))}return e({...n,[t]:void 0,[`${t}1`]:void 0===i?{transform:h,label:c}:i,[`${t}2`]:void 0===a?{transform:t=>h(t).map((t=>s.offset(t))),label:c}:a})}function hi(t,e,n){const{[t]:r}=n,{value:o,interval:i}=ui(r,n);return null==o||null==i?n:e({...n,[t]:{label:Tt(r),transform:t=>{const e=dt(F(t,o),(t=>i.floor(t))),n=e.map((t=>i.offset(t)));return e.map(_t(e)?(t,e)=>null==t||isNaN(t=+t)||null==(e=n[e])||isNaN(e=+e)?void 0:new Date((t+e)/2):(t,e)=>null==t||null==(e=n[e])?NaN:(+t+ +e)/2)}}})}function di(t={}){return fi("x",li,t,!0)}function pi(t={}){return fi("y",si,t,!0)}function mi(t={}){return fi("x",li,t)}function yi(t={}){return fi("y",si,t)}function gi(t={}){return hi("x",li,t)}function vi(t={}){return hi("y",si,t)}const xi={ariaLabel:"rule",fill:null,stroke:"currentColor"};class wi extends Io{constructor(t,e={}){const{x:n,y1:r,y2:o,inset:i=0,insetTop:a=i,insetBottom:l=i}=e;super(t,{x:{value:n,scale:"x",optional:!0},y1:{value:r,scale:"y",optional:!0},y2:{value:o,scale:"y",optional:!0}},qo(e,"x"),xi),this.insetTop=Q(a),this.insetBottom=Q(l),Zo(this,e)}render(t,e,n,r,o){const{x:i,y:a}=e,{x:l,y1:s,y2:c}=n,{width:u,height:f,marginTop:h,marginRight:d,marginLeft:p,marginBottom:m}=r,{insetTop:y,insetBottom:g}=this;return kn("svg:g",o).call(co,this,r,o).call(po,this,{x:l&&i},Kr,0).call((e=>e.selectAll().data(t).enter().append("line").call(uo,this).attr("x1",l?t=>l[t]:(p+u-d)/2).attr("x2",l?t=>l[t]:(p+u-d)/2).attr("y1",s&&!Yr(a)?t=>s[t]+y:h+y).attr("y2",c&&!Yr(a)?a.bandwidth?t=>c[t]+a.bandwidth()-g:t=>c[t]-g:f-m-g).call(io,this,n).call(oi,this,n,o))).node()}}class bi extends Io{constructor(t,e={}){const{x1:n,x2:r,y:o,inset:i=0,insetRight:a=i,insetLeft:l=i}=e;super(t,{y:{value:o,scale:"y",optional:!0},x1:{value:n,scale:"x",optional:!0},x2:{value:r,scale:"x",optional:!0}},qo(e,"y"),xi),this.insetRight=Q(a),this.insetLeft=Q(l),Zo(this,e)}render(t,e,n,r,o){const{x:i,y:a}=e,{y:l,x1:s,x2:c}=n,{width:u,height:f,marginTop:h,marginRight:d,marginLeft:p,marginBottom:m}=r,{insetLeft:y,insetRight:g}=this;return kn("svg:g",o).call(co,this,r,o).call(po,this,{y:l&&a},0,Kr).call((e=>e.selectAll().data(t).enter().append("line").call(uo,this).attr("x1",s&&!Yr(i)?t=>s[t]+y:p+y).attr("x2",c&&!Yr(i)?i.bandwidth?t=>c[t]+i.bandwidth()-g:t=>c[t]-g:u-d-g).attr("y1",l?t=>l[t]:(h+f-m)/2).attr("y2",l?t=>l[t]:(h+f-m)/2).call(io,this,n).call(oi,this,n,o))).node()}}function ki(t,e){let{x:n=H,y:r,y1:o,y2:i,...a}=yi(e);return[o,i]=Mi(r,o,i),new wi(t,{...a,x:n,y1:o,y2:i})}function $i(t,e){let{y:n=H,x:r,x1:o,x2:i,...a}=mi(e);return[o,i]=Mi(r,o,i),new bi(t,{...a,y:n,x1:o,x2:i})}function Mi(t,e,n){if(null==t){if(void 0===e){if(void 0!==n)return[0,n]}else if(void 0===n)return[0,e]}else{if(void 0===e)return void 0===n?[0,t]:[t,n];if(void 0===n)return[t,e]}return[e,n]}function Li(t,...e){let n=e.length;for(let r=0,o=!0;r{let o=t[0];for(let i=0;iF(t,$,Float64Array),label:Tt($)}),optional:!0},text:{value:o,filter:i,optional:!0}},e,Ai),this.rotate=w,this.textAnchor=mo(l,"middle"),this.lineAnchor=ft(s,"lineAnchor",["top","middle","bottom"]),this.lineHeight=+c,this.lineWidth=+u,this.textOverflow=Oi(f),this.monospace=!!h,this.fontFamily=Z(d),this.fontSize=k,this.fontStyle=Z(m),this.fontVariant=Z(y),this.fontWeight=Z(g),this.frameAnchor=ee(a),!(this.lineWidth>=0))throw new Error(`invalid lineWidth: ${u}`);this.splitLines=qi(this),this.clipLine=Fi(this)}render(t,e,n,r,o){const{x:i,y:a}=e,{x:l,y:s,rotate:c,text:u,title:f,fontSize:h}=n,{rotate:d}=this,[p,m]=wo(this,r);return kn("svg:g",o).call(co,this,r,o).call(Bi,this,u,r).call(po,this,{x:l&&i,y:s&&a}).call((e=>e.selectAll().data(t).enter().append("text").call(uo,this).call(Ei,this,u,f).attr("transform",Li`translate(${l?t=>l[t]:p},${s?t=>s[t]:m})${c?t=>` rotate(${c[t]})`:d?` rotate(${d})`:""}`).call(ho,"font-size",h&&(t=>h[t])).call(io,this,n))).node()}}function Oi(t){return null==t?null:ft(t,"textOverflow",["clip","ellipsis","clip-start","clip-end","ellipsis-start","ellipsis-middle","ellipsis-end"]).replace(/^(clip|ellipsis)$/,"$1-end")}function Ei(t,n,r,o){if(!r)return;const{lineAnchor:i,lineHeight:a,textOverflow:l,splitLines:s,clipLine:c}=n;t.each((function(t){const n=s(Jr(r[t])??"").map(c),u=n.length,f="top"===i?.71:"bottom"===i?1-u:(164-100*u)/200;if(u>1){let t=0;for(let r=0;ro&&n(t,o,l)>e&&(r.push(t.slice(o,i)+(t[i-1]===Si?"-":"")),o=a),s?(r.push(t.slice(o,l)),o=void 0):i=l;return r}const Pi={a:56,b:63,c:57,d:63,e:58,f:37,g:62,h:60,i:26,j:26,k:55,l:26,m:88,n:60,o:60,p:62,q:62,r:39,s:54,t:38,u:60,v:55,w:79,x:54,y:55,z:55,A:69,B:67,C:73,D:74,E:61,F:58,G:76,H:75,I:28,J:55,K:67,L:58,M:89,N:75,O:78,P:65,Q:78,R:67,S:65,T:65,U:75,V:69,W:98,X:69,Y:67,Z:67,0:64,1:48,2:62,3:64,4:66,5:63,6:65,7:58,8:65,9:65," ":29,"!":32,'"':49,"'":31,"(":39,")":39,",":31,"-":48,".":31,"/":32,":":31,";":31,"?":52,"‘":31,"’":31,"“":47,"”":47,"…":82};function Wi(t,e=0,n=t.length){let r=0;for(let o=e;ot.split(/\r\n?|\n/g);const r=t?ji:Wi,o=100*e;return t=>Ii(t,o,r)}function Fi({monospace:t,lineWidth:e,textOverflow:n}){if(null==n||e==1/0)return t=>t;const r=t?ji:Wi,o=100*e;switch(n){case"clip-start":return t=>Gi(t,o,r,"");case"clip-end":return t=>_i(t,o,r,"");case"ellipsis-start":return t=>Gi(t,o,r,Di);case"ellipsis-middle":return t=>function(t,e,n,r){t=t.trim();const o=n(t);if(o<=e)return t;const i=n(r)/2,[a,l]=Yi(t,e/2,n,i),[s]=Yi(t,o-e/2-l+i,n,-i);return s<0?r:t.slice(0,a).trimEnd()+r+t.slice(Ui(t,s)).trimStart()}(t,o,r,Di);case"ellipsis-end":return t=>_i(t,o,r,Di)}}const Di="…";function Yi(t,e,n,r){const o=[];let i=0;for(let a=0,l=0,s=t.length;ae){for(i+=r;i>e&&a>0;)l=a,a=o.pop(),i-=n(t,a,l);return[a,e-i]}i+=s,o.push(a)}return[-1,0]}function _i(t,e,n,r){t=t.trim();const o=n(r),[i]=Yi(t,e,n,o);return i<0?t:t.slice(0,i).trimEnd()+r}function Gi(t,e,n,r){const o=n(t=t.trim());if(o<=e)return t;const i=n(r),[a]=Yi(t,o-e+i,n,-i);return a<0?r:r+t.slice(Ui(t,a)).trimStart()}const Xi=/[\p{Combining_Mark}\p{Emoji_Modifier}]+/uy,Hi=/\p{Extended_Pictographic}/uy;function Ui(t,e){return e+=function(t,e){const n=t.charCodeAt(e);if(n>=55296&&n<56320){const n=t.charCodeAt(e+1);return n>=56320&&n<57344}return!1}(t,e)?2:1,function(t,e){return!Vi(t,e)&&(Xi.lastIndex=e,Xi.test(t))}(t,e)&&(e=Xi.lastIndex),function(t,e){return 8205===t.charCodeAt(e)}(t,e)?Ui(t,e+1):e}function Vi(t,e){return t.charCodeAt(e)<128}function Zi(t,e){return!Vi(t,e)&&(Hi.lastIndex=e,Hi.test(t))}const Qi={ariaLabel:"vector",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinejoin:"round",strokeLinecap:"round"},Ji=3.5,Ki=5*Ji,ta={draw(t,e,n){const r=e*n/Ki;t.moveTo(0,0),t.lineTo(0,-e),t.moveTo(-r,r-e),t.lineTo(0,-e),t.lineTo(r,r-e)}},ea={draw(t,e,n){t.moveTo(-n,0),t.lineTo(0,-e),t.lineTo(n,0)}},na=new Map([["arrow",ta],["spike",ea]]);class ra extends Io{constructor(t,e={}){const{x:n,y:r,r:o=Ji,length:i,rotate:a,shape:l=ta,anchor:s="middle",frameAnchor:c}=e,[u,f]=ct(i,12),[h,d]=ct(a,0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},length:{value:u,scale:"length",optional:!0},rotate:{value:h,optional:!0}},e,Qi),this.r=+o,this.length=f,this.rotate=d,this.shape=function(t){if(function(t){return t&&"function"==typeof t.draw}(t))return t;const e=na.get(`${t}`.toLowerCase());if(e)return e;throw new Error(`invalid shape: ${t}`)}(l),this.anchor=ft(s,"anchor",["start","middle","end"]),this.frameAnchor=ee(c)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,length:u,rotate:f}=r,{length:h,rotate:d,anchor:p,shape:m,r:y}=this,[g,v]=wo(this,o);return kn("svg:g",i).call(co,this,o,i).call(po,this,{x:s&&a,y:c&&l}).call((n=>n.selectAll().data(t).enter().append("path").call(uo,this).attr("transform",Li`translate(${s?t=>s[t]:g},${c?t=>c[t]:v})${f?t=>` rotate(${f[t]})`:d?` rotate(${d})`:""}${"start"===p?"":"end"===p?u?t=>` translate(0,${u[t]})`:` translate(0,${h})`:u?t=>` translate(0,${u[t]/2})`:` translate(0,${h/2})`}`).attr("d",u?t=>{const n=e.pathRound();return m.draw(n,u[t],y),n}:(()=>{const t=e.pathRound();return m.draw(t,h,y),t})()).call(io,this,r))).node()}}function oa(t,e={}){let{x:n,y:r,...o}=e;return void 0===e.frameAnchor&&([n,r]=$t(n,r)),new ra(t,{...o,x:n,y:r})}function ia(t,e={}){const{x:n=H,...r}=e;return new ra(t,{...r,x:n})}function aa(t,e={}){const{y:n=H,...r}=e;return new ra(t,{...r,y:n})}function la(t,e){return arguments.length<2&&!Ft(t)&&(e=t,t=null),void 0===e&&(e={}),[t,e]}function sa({anchor:t}={},e){return void 0===t?e[0]:ft(t,"anchor",e)}function ca(t){return sa(t,["left","right"])}function ua(t){return sa(t,["right","left"])}function fa(t){return sa(t,["bottom","top"])}function ha(t){return sa(t,["top","bottom"])}function da(){const[t,e]=la(...arguments);return ga("y",ca(e),t,e)}function pa(){const[t,e]=la(...arguments);return ga("fy",ua(e),t,e)}function ma(){const[t,e]=la(...arguments);return va("x",fa(e),t,e)}function ya(){const[t,e]=la(...arguments);return va("fx",ha(e),t,e)}function ga(t,e,n,{color:r="currentColor",opacity:o=1,stroke:i=r,strokeOpacity:a=o,strokeWidth:l=1,fill:s=r,fillOpacity:c=o,textAnchor:u,textStroke:f,textStrokeOpacity:h,textStrokeWidth:d,tickSize:p=("y"===t?6:0),tickPadding:m,tickRotate:y,x:g,margin:v,marginTop:x=(void 0===v?20:v),marginRight:w=(void 0===v?"right"===e?40:0:v),marginBottom:b=(void 0===v?20:v),marginLeft:k=(void 0===v?"left"===e?40:0:v),label:$,labelAnchor:M,labelArrow:L,labelOffset:A,...S}){return p=Q(p),m=Q(m),y=Q(y),void 0!==M&&(M=ft(M,"labelAnchor",["center","top","bottom"])),L=Pa(L),Po(p&&!Jt(i)?function(t,e,n,{strokeWidth:r=1,strokeLinecap:o=null,strokeLinejoin:i=null,facetAnchor:a=e+("y"===t?"-empty":""),frameAnchor:l=e,tickSize:s,inset:c=0,insetLeft:u=c,insetRight:f=c,dx:h=0,y:d=("y"===t?void 0:null),...p}){return Sa(aa,t,n,{ariaLabel:`${t}-axis tick`,ariaHidden:!0},{strokeWidth:r,strokeLinecap:o,strokeLinejoin:i,facetAnchor:a,frameAnchor:l,y:d,...p,dx:"left"===e?+h-Kr+ +u:+h+Kr-f,anchor:"start",length:s,shape:"left"===e?Ta:Ba})}(t,e,n,{stroke:i,strokeOpacity:a,strokeWidth:l,tickSize:p,tickPadding:m,tickRotate:y,x:g,...S}):null,Jt(s)?null:function(t,e,n,{facetAnchor:r=e+("y"===t?"-empty":""),frameAnchor:o=e,tickSize:i,tickRotate:a=0,tickPadding:l=Math.max(3,9-i)+(Math.abs(a)>60?4*Math.cos(a*Vo):0),text:s,textAnchor:c=(Math.abs(a)>60?"middle":"left"===e?"end":"start"),lineAnchor:u=(a>60?"top":a<-60?"bottom":"middle"),fontVariant:f,inset:h=0,insetLeft:d=h,insetRight:p=h,dx:m=0,y:y=("y"===t?void 0:null),...g}){return Sa(Ti,t,n,{ariaLabel:`${t}-axis tick label`},{facetAnchor:r,frameAnchor:o,text:s,textAnchor:c,lineAnchor:u,fontVariant:f,rotate:a,y:y,...g,dx:"left"===e?+m-i-l+ +d:+m+ +i+ +l-p},(function(t,n,r,o,i){void 0===f&&(this.fontVariant=Na(t)),void 0===s&&(i.text=za(t,n,r,o,e))}))}(t,e,n,{fill:s,fillOpacity:c,stroke:f,strokeOpacity:h,strokeWidth:d,textAnchor:u,tickSize:p,tickPadding:m,tickRotate:y,x:g,marginTop:x,marginRight:w,marginBottom:b,marginLeft:k,...S}),Jt(s)||null===$?null:Ri([],Aa({fill:s,fillOpacity:c,...S},(function(n,r,o,i,a){const l=i[t],{marginTop:s,marginRight:c,marginBottom:u,marginLeft:f}="y"===t&&a.inset||a,h=M??(l.bandwidth?"center":"top"),d=A??("right"===e?c:f)-3;return"center"===h?(this.textAnchor=void 0,this.lineAnchor="right"===e?"bottom":"top",this.frameAnchor=e,this.rotate=-90):(this.textAnchor="right"===e?"end":"start",this.lineAnchor=h,this.frameAnchor=`${h}-${e}`,this.rotate=0),this.dy="top"===h?3-s:"bottom"===h?u-3:0,this.dx="right"===e?d:-d,this.ariaLabel=`${t}-axis label`,{facets:[[0]],channels:{text:{value:[Ia(t,l,{anchor:e,label:$,labelAnchor:h,labelArrow:L})]}}}}))))}function va(t,e,n,{color:r="currentColor",opacity:o=1,stroke:i=r,strokeOpacity:a=o,strokeWidth:l=1,fill:s=r,fillOpacity:c=o,textAnchor:u,textStroke:f,textStrokeOpacity:h,textStrokeWidth:d,tickSize:p=("x"===t?6:0),tickPadding:m,tickRotate:y,y:g,margin:v,marginTop:x=(void 0===v?"top"===e?30:0:v),marginRight:w=(void 0===v?20:v),marginBottom:b=(void 0===v?"bottom"===e?30:0:v),marginLeft:k=(void 0===v?20:v),label:$,labelAnchor:M,labelArrow:L,labelOffset:A,...S}){return p=Q(p),m=Q(m),y=Q(y),void 0!==M&&(M=ft(M,"labelAnchor",["center","left","right"])),L=Pa(L),Po(p&&!Jt(i)?function(t,e,n,{strokeWidth:r=1,strokeLinecap:o=null,strokeLinejoin:i=null,facetAnchor:a=e+("x"===t?"-empty":""),frameAnchor:l=e,tickSize:s,inset:c=0,insetTop:u=c,insetBottom:f=c,dy:h=0,x:d=("x"===t?void 0:null),...p}){return Sa(ia,t,n,{ariaLabel:`${t}-axis tick`,ariaHidden:!0},{strokeWidth:r,strokeLinejoin:i,strokeLinecap:o,facetAnchor:a,frameAnchor:l,x:d,...p,dy:"bottom"===e?+h-Kr-f:+h+Kr+ +u,anchor:"start",length:s,shape:"bottom"===e?Ra:Ca})}(t,e,n,{stroke:i,strokeOpacity:a,strokeWidth:l,tickSize:p,tickPadding:m,tickRotate:y,y:g,...S}):null,Jt(s)?null:function(t,e,n,{facetAnchor:r=e+("x"===t?"-empty":""),frameAnchor:o=e,tickSize:i,tickRotate:a=0,tickPadding:l=Math.max(3,9-i)+(Math.abs(a)>=10?4*Math.cos(a*Vo):0),text:s,textAnchor:c=(Math.abs(a)>=10?a<0^"bottom"===e?"start":"end":"middle"),lineAnchor:u=(Math.abs(a)>=10?"middle":"bottom"===e?"top":"bottom"),fontVariant:f,inset:h=0,insetTop:d=h,insetBottom:p=h,dy:m=0,x:y=("x"===t?void 0:null),...g}){return Sa(Ci,t,n,{ariaLabel:`${t}-axis tick label`},{facetAnchor:r,frameAnchor:o,text:void 0===s?null:s,textAnchor:c,lineAnchor:u,fontVariant:f,rotate:a,x:y,...g,dy:"bottom"===e?+m+ +i+ +l-p:+m-i-l+ +d},(function(t,n,r,o,i){void 0===f&&(this.fontVariant=Na(t)),void 0===s&&(i.text=za(t,n,r,o,e))}))}(t,e,n,{fill:s,fillOpacity:c,stroke:f,strokeOpacity:h,strokeWidth:d,textAnchor:u,tickSize:p,tickPadding:m,tickRotate:y,y:g,marginTop:x,marginRight:w,marginBottom:b,marginLeft:k,...S}),Jt(s)||null===$?null:Ri([],Aa({fill:s,fillOpacity:c,...S},(function(n,r,o,i,a){const l=i[t],{marginTop:s,marginRight:c,marginBottom:u,marginLeft:f}="x"===t&&a.inset||a,h=M??(l.bandwidth?"center":"right"),d=A??("top"===e?s:u)-3;return"center"===h?(this.frameAnchor=e,this.textAnchor=void 0):(this.frameAnchor=`${e}-${h}`,this.textAnchor="right"===h?"end":"start"),this.lineAnchor=e,this.dy="top"===e?-d:d,this.dx="right"===h?c-3:"left"===h?3-f:0,this.ariaLabel=`${t}-axis label`,{facets:[[0]],channels:{text:{value:[Ia(t,l,{anchor:e,label:$,labelAnchor:h,labelArrow:L})]}}}}))))}function xa(){const[t,e]=la(...arguments);return $a("y",ca(e),t,e)}function wa(){const[t,e]=la(...arguments);return $a("fy",ua(e),t,e)}function ba(){const[t,e]=la(...arguments);return Ma("x",fa(e),t,e)}function ka(){const[t,e]=la(...arguments);return Ma("fx",ha(e),t,e)}function $a(t,e,n,{y:r=("y"===t?void 0:null),x:o=null,x1:i=("left"===e?o:null),x2:a=("right"===e?o:null),...l}){return Sa($i,t,n,{ariaLabel:`${t}-grid`,ariaHidden:!0},{y:r,x1:i,x2:a,...La(l)})}function Ma(t,e,n,{x:r=("x"===t?void 0:null),y:o=null,y1:i=("top"===e?o:null),y2:a=("bottom"===e?o:null),...l}){return Sa(ki,t,n,{ariaLabel:`${t}-grid`,ariaHidden:!0},{x:r,y1:i,y2:a,...La(l)})}function La({color:t="currentColor",opacity:e=.1,stroke:n=t,strokeOpacity:r=e,strokeWidth:o=1,...i}){return{stroke:n,strokeOpacity:r,strokeWidth:o,...i}}function Aa({fill:t,fillOpacity:e,fontFamily:n,fontSize:r,fontStyle:o,fontVariant:i,fontWeight:a,monospace:l,pointerEvents:s,shapeRendering:c,clip:u=!1},f){return[,t]=st(t),[,e]=ct(e),{facet:"super",x:null,y:null,fill:t,fillOpacity:e,fontFamily:n,fontSize:r,fontStyle:o,fontVariant:i,fontWeight:a,monospace:l,pointerEvents:s,shapeRendering:c,clip:u,initializer:f}}function Sa(t,n,r,o,i,a){let l;const s=we(i).initializer,c=t(r,we({...i,initializer:function(t,r,o,s,c,u){const f=null==t&&("fx"===n||"fy"===n),{[n]:h}=s;if(!h)throw new Error(`missing scale: ${n}`);const d=h.domain();let{interval:p,ticks:m,tickFormat:y,tickSpacing:g=("x"===n?80:35)}=i;if("string"==typeof m&&Wa(h)&&(p=m,m=void 0),void 0===m&&(m=Wt(p,h.type)??function(t,n){const[r,o]=e.extent(t.range());return(o-r)/n}(h,g)),null==t){if(Ft(m))t=ht(m);else if(jt(m))t=Ea(m,...e.extent(d));else if(h.interval){let n=h.interval;if(h.ticks){const[r,o]=e.extent(d);n=B(n,(o-r)/n[L]/m)??n,t=Ea(n,r,o)}else{n=B(n,(t=d).length/m)??n,n!==h.interval&&(t=Ea(n,...e.extent(t)))}if(n===h.interval){const e=Math.round(t.length/m);e>1&&(t=t.filter(((t,n)=>n%e==0)))}}else t=h.ticks?h.ticks(m):d;if(!h.ticks&&t.length&&t!==d){const r=new e.InternSet(d);(t=t.filter((t=>r.has(t)))).length||Ln(`Warning: the ${n}-axis ticks appear to not align with the scale domain, resulting in no ticks. Try different ticks?`)}"y"===n||"x"===n?r=[Lt(t)]:l[n]={scale:n,value:H}}a?.call(this,h,t,m,y,l);const v=Object.fromEntries(Object.entries(l).map((([e,n])=>[e,{...n,value:F(t,n.value)}])));return f&&(r=u.filterFacets(t,v)),{data:t,facets:r,channels:v}}},s));return null==r?(l=c.channels,c.channels={}):l={},void 0!==o&&Object.assign(c,o),void 0===c.clip&&(c.clip=!1),c}function za(t,e,n,r,o){return{value:Oa(t,e,n,r,o)}}function Oa(t,n,r,o,i){return"function"==typeof o?o:void 0===o&&n&&_t(n)?I(t.type,n,i)??Jr:t.tickFormat?t.tickFormat("number"==typeof r?r:null,o):void 0===o?Jr:"string"==typeof o?(_t(t.domain())?e.utcFormat:e.format)(o):et(o)}function Ea(t,e,n){return t.range(e,t.offset(t.floor(n)))}const Ra={draw(t,e){t.moveTo(0,0),t.lineTo(0,e)}},Ca={draw(t,e){t.moveTo(0,0),t.lineTo(0,-e)}},Ta={draw(t,e){t.moveTo(0,0),t.lineTo(-e,0)}},Ba={draw(t,e){t.moveTo(0,0),t.lineTo(e,0)}};function Na(t){return t.bandwidth&&!t.interval?void 0:"tabular-nums"}function Ia(t,e,{anchor:n,label:r=e.label,labelAnchor:o,labelArrow:i}={}){if(!(null==r||r.inferred&&Wa(e)&&/^(date|time|year)$/i.test(r))){if(r=String(r),"auto"===i&&(i=(!e.bandwidth||e.interval)&&!/[↑↓→←]/.test(r)),!i)return r;if(!0===i){const n=zr(e);n&&(i=/x$/.test(t)||"center"===o?/x$/.test(t)===n<0?"left":"right":n<0?"up":"down")}switch(i){case"left":return`← ${r}`;case"right":return`${r} →`;case"up":return"right"===n?`${r} ↑`:`↑ ${r}`;case"down":return"right"===n?`${r} ↓`:`↓ ${r}`}return r}}function Pa(t="auto"){return!Jt(t)&&("boolean"==typeof t?t:ft(t,"labelArrow",["auto","up","right","down","left"]))}function Wa(t){return _t(t.domain())}function ja(t,e){if(null==e)return e;const n=t(e);if(!n)throw new Error(`scale not found: ${e}`);return n}function qa(t,e={},n){let{columns:r,tickFormat:o,fontVariant:i=Uo(t),swatchSize:a=15,swatchWidth:l=a,swatchHeight:s=a,marginLeft:c=0,className:u,style:f,width:h}=e;const d=bn(e);u=vo(u),o=Oa(t.scale,t.domain,void 0,o);const p=kn("div",d).attr("class",`${u}-swatches ${u}-swatches-${null!=r?"columns":"wrap"}`);let m;return null!=r?(m=`:where(.${u}-swatches-columns .${u}-swatch) {\n display: flex;\n align-items: center;\n break-inside: avoid;\n padding-bottom: 1px;\n}\n:where(.${u}-swatches-columns .${u}-swatch::before) {\n flex-shrink: 0;\n}\n:where(.${u}-swatches-columns .${u}-swatch-label) {\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}`,p.style("columns",r).selectAll().data(t.domain).enter().append("div").attr("class",`${u}-swatch`).call(n,t,l,s).call((t=>t.append("div").attr("class",`${u}-swatch-label`).attr("title",o).text(o)))):(m=`:where(.${u}-swatches-wrap) {\n display: flex;\n align-items: center;\n min-height: 33px;\n flex-wrap: wrap;\n}\n:where(.${u}-swatches-wrap .${u}-swatch) {\n display: inline-flex;\n align-items: center;\n margin-right: 1em;\n}`,p.selectAll().data(t.domain).enter().append("span").attr("class",`${u}-swatch`).call(n,t,l,s).append((function(){return this.ownerDocument.createTextNode(o.apply(this,arguments))}))),p.call((t=>t.insert("style","*").text(`:where(.${u}-swatches) {\n font-family: system-ui, sans-serif;\n font-size: 10px;\n margin-bottom: 0.5em;\n}\n:where(.${u}-swatch > svg) {\n margin-right: 0.5em;\n overflow: visible;\n}\n${m}`))).style("margin-left",c?+c+"px":null).style("width",void 0===h?null:+h+"px").style("font-variant",mo(i,"normal")).call(xo,f).node()}const Fa=new Map([["symbol",function(t,{fill:n=(void 0!==t.hint?.fill?t.hint.fill:"none"),fillOpacity:r=1,stroke:o=(void 0!==t.hint?.stroke?t.hint.stroke:Jt(n)?"currentColor":"none"),strokeOpacity:i=1,strokeWidth:a=1.5,r:l=4.5,...s}={},c){const[u,f]=st(n),[h,d]=st(o),p=ja(c,u),m=ja(c,h),y=l*l*Math.PI;return r=ct(r)[1],i=ct(i)[1],a=ct(a)[1],qa(t,s,((n,o,l,s)=>n.append("svg").attr("viewBox","-8 -8 16 16").attr("width",l).attr("height",s).attr("fill","color"===u?t=>p.scale(t):f).attr("fill-opacity",r).attr("stroke","color"===h?t=>m.scale(t):d).attr("stroke-opacity",i).attr("stroke-width",a).append("path").attr("d",(n=>{const r=e.pathRound();return t.scale(n).draw(r,y),r}))))}],["color",Ya],["opacity",function({type:t,interpolate:n,...r},{legend:o=!0,color:i=e.rgb(0,0,0),...a}){if(!n)throw new Error(`${t} opacity scales are not supported`);!0===o&&(o="ramp");if("ramp"!==`${o}`.toLowerCase())throw new Error(`${o} opacity legends are not supported`);return Ya({type:t,...r,interpolate:_a(i)},{legend:o,...a})}]]);function Da({className:t,...e},{label:n,ticks:r,tickFormat:o}={},i){return function(t={},...e){let n=t;for(const r of e)for(const e in r)if(void 0===n[e]){const o=r[e];n===t?n={...n,[e]:o}:n[e]=o}return n}(i,{className:t,...e},{label:n,ticks:r,tickFormat:o})}function Ya(t,{legend:n=!0,...r}){if(!0===n&&(n="ordinal"===t.type?"swatches":"ramp"),void 0!==t.domain)switch(`${n}`.toLowerCase()){case"swatches":return function(t,{opacity:e,...n}={}){if(!Fr(t)&&!Dr(t))throw new Error(`swatches legend requires ordinal or threshold color scale (not ${t.type})`);return qa(t,n,((t,n,r,o)=>t.append("svg").attr("width",r).attr("height",o).attr("fill",n.scale).attr("fill-opacity",ct(e)[1]).append("rect").attr("width","100%").attr("height","100%")))}(t,r);case"ramp":return function(t,n){let{label:r=t.label,tickSize:o=6,width:i=240,height:a=44+o,marginTop:l=18,marginRight:s=0,marginBottom:c=16+o,marginLeft:u=0,style:f,ticks:h=(i-u-s)/64,tickFormat:d,fontVariant:p=Uo(t),round:m=!0,opacity:y,className:g}=n;const v=bn(n);g=vo(g),y=ct(y)[1],null===d&&(d=()=>null);const x=kn("svg",v).attr("class",`${g}-ramp`).attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("width",i).attr("height",a).attr("viewBox",`0 0 ${i} ${a}`).call((t=>t.append("style").text(`:where(.${g}-ramp) {\n display: block;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n overflow: visible;\n}\n:where(.${g}-ramp text) {\n white-space: pre;\n}`))).call(xo,f);let w,b=t=>t.selectAll(".tick line").attr("y1",l+c-a);const k=m?(t,e)=>t.rangeRound(e):(t,e)=>t.range(e),{type:$,domain:M,range:L,interpolate:A,scale:S,pivot:z}=t;if(A){const t=void 0===L?A:e.piecewise(1===A.length?fr(A):A,L);w=k(S.copy(),e.quantize(e.interpolateNumber(u,i-s),Math.min(M.length+(void 0!==z),void 0===L?1/0:L.length)));const n=256,r=v.document.createElement("canvas");r.width=n,r.height=1;const o=r.getContext("2d");for(let e=0,r=n-1;et:"string"==typeof d?e.format(d):d;w=k(e.scaleLinear().domain([-1,L.length-1]),[u,i-s]),x.append("g").attr("fill-opacity",y).selectAll().data(L).enter().append("rect").attr("x",((t,e)=>w(e-1))).attr("y",l).attr("width",((t,e)=>w(e)-w(e-1))).attr("height",a-l-c).attr("fill",(t=>t)),h=dt(t,((t,e)=>e)),d=e=>n(t[e],e)}else w=k(e.scaleBand().domain(M),[u,i-s]),x.append("g").attr("fill-opacity",y).selectAll().data(M).enter().append("rect").attr("x",w).attr("y",l).attr("width",Math.max(0,w.bandwidth()-1)).attr("height",a-l-c).attr("fill",S),b=()=>{};return x.append("g").attr("transform",`translate(0,${a-c})`).call(e.axisBottom(w).ticks(Array.isArray(h)?null:h,"string"==typeof d?d:void 0).tickFormat("function"==typeof d?d:void 0).tickSize(o).tickValues(Array.isArray(h)?h:null)).attr("font-size",null).attr("font-family",null).attr("font-variant",mo(p,"normal")).call(b).call((t=>t.select(".domain").remove())),void 0!==r&&x.append("text").attr("x",u).attr("y",l-6).attr("fill","currentColor").attr("font-weight","bold").text(r),x.node()}(t,r);default:throw new Error(`unknown legend type: ${n}`)}}function _a(t){const{r:n,g:r,b:o}=e.rgb(t)||e.rgb(0,0,0);return t=>`rgba(${n},${r},${o},${t})`}const Ga={ariaLabel:"frame",fill:"none",stroke:"currentColor",clip:!1},Xa={ariaLabel:"frame",fill:null,stroke:"currentColor",strokeLinecap:"square",clip:!1};class Ha extends Io{constructor(t={}){const{anchor:e=null,inset:n=0,insetTop:r=n,insetRight:o=n,insetBottom:i=n,insetLeft:a=n,rx:l,ry:s}=t;super(_,void 0,t,null==e?Ga:Xa),this.anchor=ut(e,"anchor",["top","right","bottom","left"]),this.insetTop=Q(r),this.insetRight=Q(o),this.insetBottom=Q(i),this.insetLeft=Q(a),this.rx=Q(l),this.ry=Q(s)}render(t,e,n,r,o){const{marginTop:i,marginRight:a,marginBottom:l,marginLeft:s,width:c,height:u}=r,{anchor:f,insetTop:h,insetRight:d,insetBottom:p,insetLeft:m,rx:y,ry:g}=this,v=s+m,x=c-a-d,w=i+h,b=u-l-p;return kn(f?"svg:line":"svg:rect",o).datum(0).call(co,this,r,o).call(uo,this).call(io,this,n).call(po,this,{}).call("left"===f?t=>t.attr("x1",v).attr("x2",v).attr("y1",w).attr("y2",b):"right"===f?t=>t.attr("x1",x).attr("x2",x).attr("y1",w).attr("y2",b):"top"===f?t=>t.attr("x1",v).attr("x2",x).attr("y1",w).attr("y2",w):"bottom"===f?t=>t.attr("x1",v).attr("x2",x).attr("y1",b).attr("y2",b):t=>t.attr("x",v).attr("y",w).attr("width",x-v).attr("height",b-w).attr("rx",y).attr("ry",g)).node()}}function Ua(t){return new Ha(t)}const Va={ariaLabel:"tip",fill:"var(--plot-background)",stroke:"currentColor"},Za=new Set(["geometry","href","src","ariaLabel","scales"]);class Qa extends Io{constructor(t,e={}){e.tip&&(e={...e,tip:!1}),void 0===e.title&&Ft(t)&&Dt(t)&&(e={...e,title:H});const{x:n,y:r,x1:o,x2:i,y1:a,y2:l,anchor:s,preferredAnchor:c="bottom",monospace:u,fontFamily:f=(u?"ui-monospace, monospace":void 0),fontSize:h,fontStyle:d,fontVariant:p,fontWeight:m,lineHeight:y=1,lineWidth:g=20,frameAnchor:v,format:x,textAnchor:w="start",textOverflow:b,textPadding:k=8,title:$,pointerSize:M=12,pathFilter:L="drop-shadow(0 3px 4px rgba(0,0,0,0.2))"}=e;super(t,{x:{value:null!=o&&null!=i?null:n,scale:"x",optional:!0},y:{value:null!=a&&null!=l?null:r,scale:"y",optional:!0},x1:{value:o,scale:"x",optional:null==i},y1:{value:a,scale:"y",optional:null==l},x2:{value:i,scale:"x",optional:null==o},y2:{value:l,scale:"y",optional:null==a},title:{value:$,optional:!0}},e,Va),this.anchor=te(s,"anchor"),this.preferredAnchor=te(c,"preferredAnchor"),this.frameAnchor=ee(v),this.textAnchor=mo(w,"middle"),this.textPadding=+k,this.pointerSize=+M,this.pathFilter=Z(L),this.lineHeight=+y,this.lineWidth=+g,this.textOverflow=Oi(b),this.monospace=!!u,this.fontFamily=Z(f),this.fontSize=Q(h),this.fontStyle=Z(d),this.fontVariant=Z(p),this.fontWeight=Z(m);for(const t in Va)t in this.channels&&(this[t]=Va[t]);this.splitLines=qi(this),this.clipLine=Fi(this),this.format={...x}}render(t,n,r,o,i){const a=this,{x:l,y:s,fx:c,fy:u}=n,{ownerSVGElement:f,document:h}=i,{anchor:d,monospace:p,lineHeight:m,lineWidth:y}=this,{textPadding:g,pointerSize:v,pathFilter:x}=this,{marginTop:w,marginLeft:b}=o,{x1:k,y1:$,x2:M,y2:L,x:A=k??M,y:S=$??L}=r,z=c?c(t.fx)-b:0,O=u?u(t.fy)-w:0,[E,R]=wo(this,o),C=Xo(r,E),T=Ho(r,R),B=p?ji:Wi,N=B(Di);let I,P;"title"in r?(I=r.channels,P=el):(I=Ka.call(this,r,n),P=nl);const W=kn("svg:g",i).call(co,this,o,i).call(Bi,this).call(po,this,{x:A&&l,y:S&&s}).call((o=>o.selectAll().data(t).enter().append("g").attr("transform",(t=>`translate(${Math.round(C(t))},${Math.round(T(t))})`)).call(uo,this).call((t=>t.append("path").attr("filter",x))).call((o=>o.append("text").each((function(o){const i=e.select(this);this.setAttribute("fill","currentColor"),this.setAttribute("fill-opacity",1),this.setAttribute("stroke","none");const l=P.call(a,o,t,I,n,r);if("string"==typeof l)for(const t of a.splitLines(l))j(i,{value:a.clipLine(t)});else{const t=new Set;for(const e of l){const{label:n=""}=e;n&&t.has(n)||(t.add(n),j(i,e))}}}))))));function j(t,{label:e,value:n,color:r,opacity:o}){e??="",n??="";const i=null!=r||null!=o;let a,l=100*y;const[s]=Yi(e,l,B,N);if(s>=0)e=e.slice(0,s).trimEnd()+Di,a=n.trim(),n="";else{(e||!n&&!i)&&(n=" "+n);const[t]=Yi(n,l-B(e),B,N);t>=0&&(a=n.trim(),n=n.slice(0,t).trimEnd()+Di)}const c=t.append("tspan").attr("x",0).attr("dy",`${m}em`).text("​");e&&c.append("tspan").attr("font-weight","bold").text(e),n&&c.append((()=>h.createTextNode(n))),i&&c.append("tspan").text(" ■").attr("fill",r).attr("fill-opacity",o).style("user-select","none"),a&&c.append("title").text(a)}function q(){const{width:t,height:e}=o.facet??o;W.selectChildren().each((function(n){let{x:r,width:o,height:i}=this.getBBox();o=Math.round(o),i=Math.round(i);let l=d;if(void 0===l){const r=C(n)+z,s=T(n)+O,c=r+o+v+2*g0,f=s+i+v+2*g0;l=c&&u?f&&h?a.preferredAnchor:h?"bottom":"top":f&&h?c?"left":"right":(c||u)&&(f||h)?`${h?"bottom":"top"}-${c?"left":"right"}`:a.preferredAnchor}const s=this.firstChild,c=this.lastChild;if(s.setAttribute("d",function(t,e,n,r,o){const i=r+2*n,a=o+2*n;switch(t){case"middle":return`M${-i/2},${-a/2}h${i}v${a}h${-i}z`;case"top-left":return`M0,0l${e},${e}h${i-e}v${a}h${-i}z`;case"top":return`M0,0l${e/2},${e/2}h${(i-e)/2}v${a}h${-i}v${-a}h${(i-e)/2}z`;case"top-right":return`M0,0l${-e},${e}h${e-i}v${a}h${i}z`;case"right":return`M0,0l${-e/2},${-e/2}v${e/2-a/2}h${-i}v${a}h${i}v${e/2-a/2}z`;case"bottom-left":return`M0,0l${e},${-e}h${i-e}v${-a}h${-i}z`;case"bottom":return`M0,0l${e/2},${-e/2}h${(i-e)/2}v${-a}h${-i}v${a}h${(i-e)/2}z`;case"bottom-right":return`M0,0l${-e},${-e}h${e-i}v${-a}h${i}z`;case"left":return`M0,0l${e/2},${-e/2}v${e/2-a/2}h${i}v${a}h${-i}v${e/2-a/2}z`}}(l,v,g,o,i)),r)for(const t of c.childNodes)t.setAttribute("x",-r);c.setAttribute("y",+function(t,e,n){return/^top(?:-|$)/.test(t)?.94-n:-.29-e*n}(l,c.childNodes.length,m).toFixed(6)+"em"),c.setAttribute("transform",`translate(${function(t,e,n,r,o){switch(t){case"middle":return[-r/2,o/2];case"top-left":return[n,e+n];case"top":return[-r/2,e/2+n];case"top-right":return[-r-n,e+n];case"right":return[-e/2-r-n,o/2];case"bottom-left":return[n,-e-n];case"bottom":return[-r/2,-e/2-n];case"bottom-right":return[-r-n,-e-n];case"left":return[n+e/2,o/2]}}(l,v,g,o,i)})`)})),W.attr("visibility",null)}return t.length&&(W.attr("visibility","hidden"),f.isConnected?Promise.resolve().then(q):"undefined"!=typeof requestAnimationFrame&&requestAnimationFrame(q)),W.node()}}function Ja(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=$t(e,n)),new Qa(t,{...r,x:e,y:n})}function Ka({channels:t},n){const r={};let o=this.format;o=tl(o,t,"x"),o=tl(o,t,"y"),this.format=o;for(const e in o){const n=o[e];if(null!==n&&!1!==n)if("fx"===e||"fy"===e)r[e]=!0;else{const n=wn(t,e);n&&(r[e]=n)}}for(const e in t){if(e in r||e in o||Za.has(e))continue;const n=wn(t,e);n&&(r[e]=n)}this.facet&&(n.fx&&!("fx"in o)&&(r.fx=!0),n.fy&&!("fy"in o)&&(r.fy=!0));for(const t in r){const o=this.format[t];if("string"==typeof o){const i=r[t]?.value??n[t]?.domain()??[];this.format[t]=(_t(i)?e.utcFormat:e.format)(o)}else if(void 0===o||!0===o){const e=n[t];this.format[t]=e?.bandwidth?Oa(e,e.domain()):Jr}}return r}function tl(t,e,n){if(!(n in t))return t;const r=`${n}1`,o=`${n}2`;if(!(!(r in t)&&r in e||!(o in t)&&o in e))return t;const i=Object.entries(t),a=t[n];return i.splice(i.findIndex((([t])=>t===n))+1,0,[r,a],[o,a]),Object.fromEntries(i)}function el(t,e,{title:n}){return Jr(n.value[t],t)}function*nl(t,e,r,o,i){for(const a in r){if("fx"===a||"fy"===a){yield{label:il(o,r,a),value:this.format[a](e[a],t)};continue}if("x1"===a&&"x2"in r)continue;if("y1"===a&&"y2"in r)continue;const l=r[a];if("x2"===a&&"x1"in r)yield{label:ol(o,r,"x"),value:rl(this.format.x2,r.x1,l,t)};else if("y2"===a&&"y1"in r)yield{label:ol(o,r,"y"),value:rl(this.format.y2,r.y1,l,t)};else{const e=l.value[t],s=l.scale;if(!n(e)&&null==s)continue;yield{label:il(o,r,a),value:this.format[a](e,t),color:"color"===s?i[a][t]:null,opacity:"opacity"===s?i[a][t]:null}}}}function rl(t,e,n,r){return n.hint?.length?`${t(n.value[r]-e.value[r],r)}`:`${t(e.value[r],r)}–${t(n.value[r],r)}`}function ol(t,e,n){const r=il(t,e,`${n}1`,n),o=il(t,e,`${n}2`,n);return r===o?r:`${r}–${o}`}function il(t,e,n,r=n){const o=e[n],i=t[o?.scale??n];return String(i?.label??o?.label??r)}function al(t={}){const{facet:n,style:r,title:o,subtitle:i,caption:a,ariaLabel:l,ariaDescription:s}=t,c=vo(t.className),u=void 0===t.marks?[]:sl(t.marks);u.push(...function(t){const e=[];for(const n of t){let t=n.tip;if(t){!0===t?t={}:"string"==typeof t&&(t={pointer:t});let{pointer:r,preferredAnchor:o}=t;r=/^x$/i.test(r)?_o:/^y$/i.test(r)?Go:Yo,t=r(gl(n,t)),t.title=null,void 0===o&&(t.preferredAnchor=r===Go?"left":"bottom");const i=Ja(n.data,t);i.facet=n.facet,i.facetAnchor=n.facetAnchor,e.push(i)}}return e}(u));const f=function(t,e){if(null==t)return;const{x:n,y:r}=t;if(null==n&&null==r)return;const o=ht(t.data);if(null==o)throw new Error("missing facet data");const i={};null!=n&&(i.fx=cn(o,{value:n,scale:"fx"}));null!=r&&(i.fy=cn(o,{value:r,scale:"fy"}));fl(i,e);const a=$o(o,i);return{channels:i,groups:a,data:t.data}}(n,t),h=new Map;for(const e of u){const n=yl(e,f,t);n&&h.set(e,n)}const d=new Map;f&&pl(d,[f],t),pl(d,h,t);const p=sl(function(t,e,n){let{projection:r,x:o={},y:i={},fx:a={},fy:l={},axis:s,grid:c,facet:u={},facet:{axis:f=s,grid:h}=u,x:{axis:d=s,grid:p=(null===d?null:c)}=o,y:{axis:m=s,grid:y=(null===m?null:c)}=i,fx:{axis:g=f,grid:v=(null===g?null:h)}=a,fy:{axis:x=f,grid:w=(null===x?null:h)}=l}=n;(r||!xt(o)&&!kl("x",t))&&(d=p=null);(r||!xt(i)&&!kl("y",t))&&(m=y=null);e.has("fx")||(g=v=null);e.has("fy")||(x=w=null);void 0===d&&(d=!bl(t,"x"));void 0===m&&(m=!bl(t,"y"));void 0===g&&(g=!bl(t,"fx"));void 0===x&&(x=!bl(t,"fy"));!0===d&&(d="bottom");!0===m&&(m="left");!0===g&&(g="top"===d||null===d?"bottom":"top");!0===x&&(x="right"===m||null===m?"left":"right");const b=[];return xl(b,w,wa,l),vl(b,x,pa,"right","left",u,l),xl(b,v,ka,a),vl(b,g,ya,"top","bottom",u,a),xl(b,y,xa,i),vl(b,m,da,"left","right",n,i),xl(b,p,ba,o),vl(b,d,ma,"bottom","top",n,o),b}(u,d,t));for(const e of p){const n=yl(e,f,t);n&&h.set(e,n)}u.unshift(...p);let m=function(t,n){const{fx:r,fy:o}=Lr(t,n),i=r?.scale.domain(),a=o?.scale.domain();return i&&a?e.cross(i,a).map((([t,e],n)=>({x:t,y:e,i:n}))):i?i.map(((t,e)=>({x:t,i:e}))):a?a.map(((t,e)=>({y:t,i:e}))):void 0}(d,t);if(void 0!==m){const t=f?No(m,f):void 0;for(const e of u){if(null===e.facet||"super"===e.facet)continue;const n=h.get(e);void 0!==n&&(n.facetsIndex=null!=e.fx||null!=e.fy?No(m,n):t)}const e=new Set;for(const{facetsIndex:t}of h.values())t?.forEach(((t,n)=>{t?.length>0&&e.add(n)}));m.forEach(0t.empty=!e.has(n):t=>t.empty=!1);for(const t of u)if("exclude"===t.facet){const e=h.get(t);void 0!==e&&(e.facetsIndex=Mo(e.facetsIndex))}}for(const e of fe.keys())xt(t[e])&&"fx"!==e&&"fy"!==e&&d.set(e,[]);const y=new Map;for(const e of u){if(y.has(e))throw new Error("duplicate mark; each mark must be unique");const{facetsIndex:n,channels:r}=h.get(e)??{},{data:o,facets:i,channels:a}=e.initialize(n,r,t);fl(a,t),y.set(e,{data:o,facets:i,channels:a})}const g=Lr(pl(d,y,t),t),v=function(t,e,n={}){let r=.5-Kr,o=.5+Kr,i=.5+Kr,a=.5-Kr;for(const{marginTop:t,marginRight:n,marginBottom:l,marginLeft:s}of e)t>r&&(r=t),n>o&&(o=n),l>i&&(i=l),s>a&&(a=s);let{margin:l,marginTop:s=(void 0!==l?l:r),marginRight:c=(void 0!==l?l:o),marginBottom:u=(void 0!==l?l:i),marginLeft:f=(void 0!==l?l:a)}=n;s=+s,c=+c,u=+u,f=+f;let{width:h=640,height:d=bo(t,n,{width:h,marginTopDefault:r,marginRightDefault:o,marginBottomDefault:i,marginLeftDefault:a})+Math.max(0,s-r+u-i)}=n;h=+h,d=+d;const p={width:h,height:d,marginTop:s,marginRight:c,marginBottom:u,marginLeft:f};if(t.fx||t.fy){let{margin:t,marginTop:e=(void 0!==t?t:s),marginRight:r=(void 0!==t?t:c),marginBottom:o=(void 0!==t?t:u),marginLeft:i=(void 0!==t?t:f)}=n.facet??{};e=+e,r=+r,o=+o,i=+i,p.facet={marginTop:e,marginRight:r,marginBottom:o,marginLeft:i}}return p}(g,u,t);!function(t,e){const{x:n,y:r,fx:o,fy:i}=t,a=o||i?Or(e):e;o&&Rr(o,a),i&&Cr(i,a);const l=o||i?Er(t,e):e;n&&Rr(n,l),r&&Cr(r,l)}(g,v);const x=Ar(g),{fx:w,fy:b}=x,k=w||b?Er(g,v):v,$=w||b?function({fx:t,fy:e},n){const{marginTop:r,marginRight:o,marginBottom:i,marginLeft:a,width:l,height:s}=Or(n),c=t&&$l(t),u=e&&$l(e);return{marginTop:e?u[0]:r,marginRight:t?l-c[1]:o,marginBottom:e?s-u[1]:i,marginLeft:t?c[0]:a,inset:{marginTop:n.marginTop,marginRight:n.marginRight,marginBottom:n.marginBottom,marginLeft:n.marginLeft},width:l,height:s}}(x,v):v,M=bn(t),L=M.document,A=e.creator("svg").call(L.documentElement);let S=A;M.ownerSVGElement=A,M.className=c,M.projection=On(t,k),M.filterFacets=(t,e)=>No(m,{channels:e,groups:$o(t,e)}),M.getMarkState=t=>{const e=y.get(t),n=h.get(t);return{...e,channels:{...e.channels,...n?.channels}}},M.dispatchValue=t=>{S.value!==t&&(S.value=t,S.dispatchEvent(new Event("input",{bubbles:!0})))};const z=new Set;for(const[e,n]of y)if(null!=e.initializer){const r="super"===e.facet?$:k,o=e.initializer(n.data,n.facets,n.channels,x,r,M);if(void 0!==o.data&&(n.data=o.data),void 0!==o.facets&&(n.facets=o.facets),void 0!==o.channels){const{fx:r,fy:i,...a}=o.channels;dl(a),Object.assign(n.channels,a);for(const e of Object.values(a)){const{scale:n}=e;null!=n&&((O=fe.get(n))!==oe&&O!==ue)&&(hl(e,t),z.add(n))}null==r&&null==i||h.set(e,!0)}}var O;if(z.size){const e=new Map;pl(e,y,t,(t=>z.has(t))),pl(d,y,t,(t=>z.has(t)));const n=function(t,e){for(const n in t){const r=t[n],o=e[n];void 0===r.label&&o&&(r.label=o.label)}return t}(Lr(e,t),g),{scales:r,...o}=Ar(n);Object.assign(g,n),Object.assign(x,o),Object.assign(x.scales,r)}let E,R;void 0!==m&&(E={x:w?.domain(),y:b?.domain()},m=function(t,{x:e,y:n}){return e&&=So(e),n&&=So(n),t.filter(e&&n?t=>e.has(t.x)&&n.has(t.y):e?t=>e.has(t.x):t=>n.has(t.y)).sort(e&&n?(t,r)=>e.get(t.x)-e.get(r.x)||n.get(t.y)-n.get(r.y):e?(t,n)=>e.get(t.x)-e.get(n.x):(t,e)=>n.get(t.y)-n.get(e.y))}(m,E),R=function(t,e,{marginTop:n,marginLeft:r}){return t&&e?({x:o,y:i})=>`translate(${t(o)-r},${e(i)-n})`:t?({x:e})=>`translate(${t(e)-r},0)`:({y:t})=>`translate(0,${e(t)-n})`}(w,b,v));for(const[t,e]of y)e.values=t.scale(e.channels,x,M);const{width:C,height:T}=v;e.select(A).attr("class",c).attr("fill","currentColor").attr("font-family","system-ui, sans-serif").attr("font-size",10).attr("text-anchor","middle").attr("width",C).attr("height",T).attr("viewBox",`0 0 ${C} ${T}`).attr("aria-label",l).attr("aria-description",s).call((t=>t.append("style").text(`:where(.${c}) {\n --plot-background: white;\n display: block;\n height: auto;\n height: intrinsic;\n max-width: 100%;\n}\n:where(.${c} text),\n:where(.${c} tspan) {\n white-space: pre;\n}`))).call(xo,r);for(const t of u){const{channels:n,values:r,facets:o}=y.get(t);if(void 0===m||"super"===t.facet){let e=null;if(o&&(e=o[0],e=t.filter(e,n,r),0===e.length))continue;const i=t.render(e,x,r,$,M);if(null==i)continue;A.appendChild(i)}else{let i;for(const a of m){if(!(t.facetAnchor?.(m,E,a)??!a.empty))continue;let l=null;if(o){const e=h.has(t);if(l=o[e?a.i:0],l=t.filter(l,n,r),0===l.length)continue;e||l!==o[0]||(l=zt(l)),l.fx=a.x,l.fy=a.y,l.fi=a.i}const s=t.render(l,x,r,k,M);if(null!=s){(i??=e.select(A).append("g")).append((()=>s)).datum(a);for(const t of["aria-label","aria-description","aria-hidden","transform"])s.hasAttribute(t)&&(i.attr(t,s.getAttribute(t)),s.removeAttribute(t))}}i?.selectChildren().attr("transform",R)}}const B=function(t,e,n){const r=[];for(const[o,i]of Fa){const a=n[o];if(a?.legend&&o in t){const n=i(t[o],Da(e,t[o],a),(e=>t[e]));null!=n&&r.push(n)}}return r}(g,M,t),{figure:N=null!=o||null!=i||null!=a||B.length>0}=t;N&&(S=L.createElement("figure"),S.className=`${c}-figure`,S.style.maxWidth="initial",null!=o&&S.append(ll(L,o,"h2")),null!=i&&S.append(ll(L,i,"h3")),S.append(...B,A),null!=a&&S.append(function(t,e){const n=t.createElement("figcaption");return n.append(e),n}(L,a))),S.scale=function(t){return e=>{if(!fe.has(e=`${e}`))throw new Error(`unknown scale: ${e}`);return t[e]}}(x.scales),S.legend=function(t,e,n={}){return(r,o)=>{if(!Fa.has(r))throw new Error(`unknown legend type: ${r}`);if(r in t)return Fa.get(r)(t[r],Da(e,n[r],o),(e=>t[e]))}}(g,M,t);const I=function(){const t=Mn;return Mn=0,$n=void 0,t}();return I>0&&e.select(A).append("text").attr("x",C).attr("y",20).attr("dy","-1em").attr("text-anchor","end").attr("font-family","initial").text("⚠️").append("title").text(`${I.toLocaleString("en-US")} warning${1===I?"":"s"}. Please check the console.`),S}function ll(t,e,n){if(e.ownerDocument)return e;const r=t.createElement(n);return r.append(e),r}function sl(t){return t.flat(1/0).filter((t=>null!=t)).map(cl)}function cl(t){return"function"==typeof t.render?t:new ul(t)}Io.prototype.plot=function({marks:t=[],...e}={}){return al({...e,marks:[...t,this]})};class ul extends Io{constructor(t){if("function"!=typeof t)throw new TypeError("invalid mark; missing render function");super(),this.render=t}render(){}}function fl(t,e){for(const n in t)hl(t[n],e);return t}function hl(t,e){const{scale:n,transform:r=!0}=t;if(null==n||!r)return;const{type:o,percent:i,interval:a,transform:l=(i?t=>100*t:It(a,o))}=e[n]??{};null!=l&&(t.value=dt(t.value,l),t.transform=!1)}function dl(t){for(const e in t)hn(e,t[e])}function pl(t,e,n,r=V){for(const{channels:o}of e.values())for(const e in o){const i=o[e],{scale:a}=i;if(null!=a&&r(a))if("projection"===a){if(!In(n)){const e=void 0===n.x?.domain,r=void 0===n.y?.domain;if(e||r){const[n,o]=Wn(i);e&&ml(t,"x",n),r&&ml(t,"y",o)}}}else ml(t,a,i)}return t}function ml(t,e,n){const r=t.get(e);void 0!==r?r.push(n):t.set(e,[n])}function yl(t,e,n){if(null===t.facet||"super"===t.facet)return;const{fx:r,fy:o}=t;if(null!=r||null!=o){const e=ht(t.data??r??o);if(void 0===e)throw new Error(`missing facet data in ${t.ariaLabel}`);if(null===e)return;const i={};return null!=r&&(i.fx=cn(e,{value:r,scale:"fx"})),null!=o&&(i.fy=cn(e,{value:o,scale:"fy"})),fl(i,n),{channels:i,groups:$o(e,i)}}if(void 0===e)return;const{channels:i,groups:a,data:l}=e;if("auto"!==t.facet||t.data===l)return{channels:i,groups:a};l.length>0&&(a.size>1||1===a.size&&i.fx&&i.fy&&[...a][0][1].size>1)&&ht(t.data)?.length===l.length&&Ln(`Warning: the ${t.ariaLabel} mark appears to use faceted data, but isn’t faceted. The mark data has the same length as the facet data and the mark facet option is "auto", but the mark data and facet data are distinct. If this mark should be faceted, set the mark facet option to true; otherwise, suppress this warning by setting the mark facet option to false.`)}function gl(t,e={}){return we({...e,x:null,y:null},((e,n,r,o,i,a)=>a.getMarkState(t)))}function vl(t,e,n,r,o,i,a){if(!e)return;const l=/^\s*both\s*$/i.test(e);a=function(t,e,{line:n=e.line,ticks:r,tickSize:o,tickSpacing:i,tickPadding:a,tickFormat:l,tickRotate:s,fontVariant:c,ariaLabel:u,ariaDescription:f,label:h=e.label,labelAnchor:d,labelArrow:p=e.labelArrow,labelOffset:m}){return{anchor:t,line:n,ticks:r,tickSize:o,tickSpacing:i,tickPadding:a,tickFormat:l,tickRotate:s,fontVariant:c,ariaLabel:u,ariaDescription:f,label:h,labelAnchor:d,labelArrow:p,labelOffset:m}}(l?r:e,i,a);const{line:s}=a;n!==da&&n!==ma||!s||Kt(s)||t.push(Ua(function(t){const{anchor:e,line:n}=t;return{anchor:e,facetAnchor:e+"-empty",stroke:!0===n?void 0:n}}(a))),t.push(n(a)),l&&t.push(n({...a,anchor:o,label:null}))}function xl(t,e,n,r){e&&!Kt(e)&&t.push(n(function(t,{stroke:e=(Zt(t)?t:void 0),ticks:n=(wl(t)?t:void 0),tickSpacing:r,ariaLabel:o,ariaDescription:i}){return{stroke:e,ticks:n,tickSpacing:r,ariaLabel:o,ariaDescription:i}}(e,r)))}function wl(t){switch(typeof t){case"number":return!0;case"string":return!Zt(t)}return Ft(t)||"function"==typeof t?.range}function bl(t,e){const n=`${e}-axis `;return t.some((t=>t.ariaLabel?.startsWith(n)))}function kl(t,e){for(const n of e)for(const e in n.channels){const{scale:r}=n.channels[e];if(r===t||"projection"===r)return!0}return!1}function $l(t){const e=t.domain();let n=t(e[0]),r=t(e[e.length-1]);return r{const u=Nt(F(n,v),c?.[x]),h=F(n,M),p=F(n,W),y=F(n,j),w=He(s,{z:h,fill:p,stroke:y}),k=[],$=[],L=u&&b([]),A=h&&P([]),S=p&&D([]),z=y&&_([]),O=t&&f([]),E=t&&d([]),R=e&&m([]),C=e&&g([]),T=function(t,e,n){const r=t?.(n),o=e?.(n);return r&&o?function*(t){const e=r.bin(t);for(const[t,[i,a]]of r.entries()){const r=o.bin(e[t]);for(const[t,[e,l]]of o.entries())yield[r[t],{data:n,x1:i,y1:e,x2:a,y2:l}]}}:r?function*(t){const e=r.bin(t);for(const[t,[o,i]]of r.entries())yield[e[t],{data:n,x1:o,x2:i}]}:function*(t){const e=o.bin(t);for(const[t,[r,i]]of o.entries())yield[e[t],{data:n,y1:r,y2:i}]}}(t,e,n);let B=0;for(const t of s)t.initialize(n);a&&a.initialize(n),i&&i.initialize(n);for(const t of r){const e=[];for(const e of s)e.scope("facet",t);a&&a.scope("facet",t),i&&i.scope("facet",t);for(const[r,l]of je(t,w))for(const[t,c]of je(l,u))for(const[l,f]of T(c))if(w&&(f.z=r),!i||i.reduce(l,f)){e.push(B++),$.push(o.reduceIndex(l,n,f)),u&&L.push(t),h&&A.push(w===h?r:h[(l.length>0?l:c)[0]]),p&&S.push(w===p?r:p[(l.length>0?l:c)[0]]),y&&z.push(w===y?r:y[(l.length>0?l:c)[0]]),O&&(O.push(f.x1),E.push(f.x2)),R&&(R.push(f.y1),C.push(f.y2));for(const t of s)t.reduce(l,f);a&&a.reduce(l,f)}k.push(e)}return Ue(k,a,l),{data:$,facets:k}})),...!Ne(s,"x")&&(u?{x1:u,x2:h,x:Bt(u,h)}:{x:k,x1:S,x2:z}),...!Ne(s,"y")&&(p?{y1:p,y2:y,y:Bt(p,y)}:{y:$,y1:O,y2:E}),...w&&{[x]:w},...Object.fromEntries(s.map((({name:t,output:e})=>[t,e])))}}function Nl({cumulative:t,domain:e,thresholds:n,interval:r,...o},i){return[o,{cumulative:t,domain:e,thresholds:n,interval:r,...i}]}function Il(t,{cumulative:e,domain:n,thresholds:r,interval:o},i){return void 0===(t={...qt(t)}).domain&&(t.domain=n),void 0===t.cumulative&&(t.cumulative=e),void 0===t.thresholds&&(t.thresholds=r),void 0===t.interval&&(t.interval=o),void 0===t.value&&(t.value=i),t.thresholds=Wl(t.thresholds,t.interval),t}function Pl(t){if(null==t)return;const{value:n,cumulative:r,domain:o=e.extent,thresholds:i}=t,a=t=>{let a,l=F(t,n);if(_t(l)||(function(t){return jt(t)&&"function"==typeof t?.floor&&t.floor()instanceof Date}(s=i)||Ft(s)&&_t(s))){l=dt(l,lt,Float64Array);let[t,n]="function"==typeof o?o(l):o,r="function"!=typeof i||jt(i)?i:i(l,t,n);"number"==typeof r&&(r=e.utcTickInterval(t,n,r)),jt(r)&&(o===e.extent&&(t=r.floor(t),n=r.offset(r.floor(n))),r=r.range(t,r.offset(n))),a=r}else{l=rt(l);let[t,n]="function"==typeof o?o(l):o,r="function"!=typeof i||jt(i)?i:i(l,t,n);if("number"==typeof r)if(o===e.extent){let o=e.tickIncrement(t,n,r);if(isFinite(o))if(o>0){let e=Math.round(t/o),i=Math.round(n/o);e*o<=t||--e,i*o>n||++i;let a=i-e+1;r=new Float64Array(a);for(let t=0;tn||++i;let a=i-e+1;r=new Float64Array(a);for(let t=0;t0?Gl:_l)(c,a,l),c};return a.label=Tt(n),a}function Wl(t,n,r=Yl){if(void 0===t)return void 0===n?r:Wt(n);if("string"==typeof t){switch(t.toLowerCase()){case"freedman-diaconis":return e.thresholdFreedmanDiaconis;case"scott":return e.thresholdScott;case"sturges":return e.thresholdSturges;case"auto":return Yl}return C(t)}return t}function jl(t,e,n){return Pe(t,e,n,ql)}function ql(t,e,n){return We(t,e,n,Fl)}function Fl(t,e){return qe(t,e,Dl)}function Dl(t){switch(`${t}`.toLowerCase()){case"x":return Ul;case"x1":return Zl;case"x2":return Ql;case"y":return Vl;case"y1":return Jl;case"y2":return Kl;case"z":return sn}throw new Error(`invalid bin reduce: ${t}`)}function Yl(t,n,r){return Math.min(200,e.thresholdScott(t,n,r))}function _l(t,n,r){return n=rt(n),o=>{const i=t.map((()=>[]));for(const t of o)i[e.bisect(n,r[t])-1]?.push(t);return i}}function Gl(t,e,n){const r=_l(t,e,n);return t=>{const e=r(t);for(let t=1,n=e.length;t{const e=r(t);for(let t=e.length-2;t>=0;--t){const n=e[t+1],r=e[t];for(const t of n)r.push(t)}return e}}function Hl(t,e){const n=(+t+ +e)/2;return t instanceof Date?new Date(n):n}const Ul={reduceIndex:(t,e,{x1:n,x2:r})=>Hl(n,r)},Vl={reduceIndex:(t,e,{y1:n,y2:r})=>Hl(n,r)},Zl={reduceIndex:(t,e,{x1:n})=>n},Ql={reduceIndex:(t,e,{x2:n})=>n},Jl={reduceIndex:(t,e,{y1:n})=>n},Kl={reduceIndex:(t,e,{y2:n})=>n};function ts(t={}){return mt(t)?t:{...t,x:H}}function es(t={}){return yt(t)?t:{...t,y:H}}function ns(t={},e={}){1===arguments.length&&([t,e]=as(t));const{y1:n,y:r=n,x:o,...i}=e,[a,l,s,c]=ss(r,o,"y","x",t,i);return{...a,y1:n,y:l,x1:s,x2:c,x:Bt(s,c)}}function rs(t={},e={}){1===arguments.length&&([t,e]=as(t));const{x1:n,x:r=n,y:o,...i}=e,[a,l,s,c]=ss(r,o,"x","y",t,i);return{...a,x1:n,x:l,y1:s,y2:c,y:Bt(s,c)}}function os({x:t,x1:e,x2:n,...r}={}){return r=qo(r,"y"),void 0===e&&void 0===n?ns({x:t,...r}):([e,n]=kt(t,e,n),{...r,x1:e,x2:n})}function is({y:t,y1:e,y2:n,...r}={}){return r=qo(r,"x"),void 0===e&&void 0===n?rs({y:t,...r}):([e,n]=kt(t,e,n),{...r,y1:e,y2:n})}function as(t){const{offset:e,order:n,reverse:r,...o}=t;return[{offset:e,order:n,reverse:r},o]}const ls={length:!0};function ss(t,n=U,i,a,{offset:l,order:s,reverse:c},u){if(null===n)throw new Error(`stack requires ${a}`);const f=Mt(u),[h,d]=Ct(t),[p,m]=Rt(n),[y,g]=Rt(n);return p.hint=y.hint=ls,l=function(t){if(null==t)return;if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"expand":case"normalize":return us;case"center":case"silhouette":return fs;case"wiggle":return hs}throw new Error(`unknown offset: ${t}`)}(l),s=function(t,n,i){if(void 0===t&&n===hs)return ms(r);if(null==t)return;if("string"==typeof t){const n=t.startsWith("-"),a=n?o:r;switch((n?t.slice(1):t).toLowerCase()){case"value":case i:return function(t){return(e,n,r)=>(e,n)=>t(r[e],r[n])}(a);case"z":return function(t){return(e,n,r,o)=>(e,n)=>t(o[e],o[n])}(a);case"sum":return function(t){return vs(t,((t,n,r,o)=>e.groupSort(Lt(t),(t=>e.sum(t,(t=>r[t]))),(t=>o[t]))))}(a);case"appearance":return function(t){return vs(t,((t,n,r,o)=>e.groupSort(Lt(t),(t=>n[e.greatest(t,(t=>r[t]))]),(t=>o[t]))))}(a);case"inside-out":return ms(a)}return ys(G(t))}if("function"==typeof t)return(1===t.length?ys:gs)(t);if(Array.isArray(t))return a=t,vs(r,(()=>a));var a;throw new Error(`invalid order: ${t}`)}(s,l,a),[xe(u,((r,o,a)=>{({data:r,facets:o}=function(t,e){if(1===e.length)return{data:t,facets:e};const n=t.length,r=new Uint8Array(n);let o=0;for(const t of e)for(const e of t)r[e]&&++o,r[e]=1;if(0===o)return{data:t,facets:e};const i=(t=pt(t))[q]=new Uint32Array(n+o);e=e.map((t=>pt(t,Uint32Array)));let a=n;r.fill(0);for(const n of e)for(let e=0,o=n.length;eu[t])).values()):[t];if(y)for(const t of n)t.sort(y);for(const t of n){let e=0,n=0;c&&t.reverse();for(const r of t){const t=h[r];t<0?e=w[r]=(x[r]=e)+t:t>0?n=w[r]=(x[r]=n)+t:w[r]=x[r]=n}}b.push(n)}return l&&l(b,x,w,p),{data:r,facets:o}})),h,p,y]}function cs(t,e){let n=0,r=0;for(const o of t){const t=e[o];tr&&(r=t)}return[n,r]}function us(t,e,n){for(const r of t)for(const t of r){const[r,o]=cs(t,n);for(const i of t){const t=1/(o-r||1);e[i]=t*(e[i]-r),n[i]=t*(n[i]-r)}}}function fs(t,e,n){for(const r of t){for(const t of r){const[r,o]=cs(t,n);for(const i of t){const t=(o+r)/2;e[i]-=t,n[i]-=t}}ds(r,e,n)}ps(t,e,n)}function hs(t,n,r,o){for(const i of t){const t=new e.InternMap;let a=0;for(const l of i){let i=-1;const s=l.map((t=>Math.abs(r[t]-n[t]))),c=l.map((e=>{i=o?o[e]:++i;const a=r[e]-n[e],l=t.has(i)?a-t.get(i):0;return t.set(i,a),l})),u=[0,...e.cumsum(c)];for(const t of l)n[t]+=a,r[t]+=a;const f=e.sum(s);f&&(a-=e.sum(s,((t,e)=>(c[e]/2+u[e])*t))/f)}ds(i,n,r)}ps(t,n,r)}function ds(t,n,r){const o=e.min(t,(t=>e.min(t,(t=>n[t]))));for(const e of t)for(const t of e)n[t]-=o,r[t]-=o}function ps(t,n,r){const o=t.length;if(1===o)return;const i=t.map((t=>t.flat())),a=i.map((t=>(e.min(t,(t=>n[t]))+e.max(t,(t=>r[t])))/2)),l=e.min(a);for(let t=0;t{const i=Lt(t),a=e.groupSort(i,(t=>n[e.greatest(t,(t=>r[t]))]),(t=>o[t])),l=e.rollup(i,(t=>e.sum(t,(t=>r[t]))),(t=>o[t])),s=[],c=[];let u=0;for(const t of a)u<0?(u+=l.get(t),s.push(t)):(u-=l.get(t),c.push(t));return c.reverse().concat(s)}))}function ys(t){return e=>{const n=F(e,t);return(t,e)=>r(n[t],n[e])}}function gs(t){return e=>(n,r)=>t(e[n],e[r])}function vs(t,n){return(r,o,i,a)=>{if(!a)throw new Error("missing channel: z");const l=new e.InternMap(n(r,o,i,a).map(((t,e)=>[t,e])));return(e,n)=>t(l.get(a[e]),l.get(a[n]))}}const xs={ariaLabel:"area",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class ws extends Io{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,z:a,curve:l,tension:s}=e;super(t,{x1:{value:n,scale:"x"},y1:{value:r,scale:"y"},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0},z:{value:Mt(e),optional:!0}},e,xs),this.z=a,this.curve=Ll(l,s)}filter(t){return t}render(t,n,r,o,i){const{x1:a,y1:l,x2:s=a,y2:c=l}=r;return kn("svg:g",i).call(co,this,o,i).call(po,this,n,0,0).call((n=>n.selectAll().data(so(t,[a,l,s,c],this,r)).enter().append("path").call(uo,this).call(ao,this,r).attr("d",e.area().curve(this.curve).defined((t=>t>=0)).x0((t=>a[t])).y0((t=>l[t])).x1((t=>s[t])).y1((t=>c[t]))))).node()}}function bs(t,e){return void 0===e?$s(t,{x:J,y:K}):new ws(t,e)}function ks(t,e){const{y:n=X,...r}=Tl(e);return new ws(t,os(ts({...r,y1:n,y2:void 0})))}function $s(t,e){const{x:n=X,...r}=Cl(e);return new ws(t,is(es({...r,x1:n,x2:void 0})))}const Ms={ariaLabel:"link",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class Ls extends Io{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,curve:a,tension:l}=e;super(t,{x1:{value:n,scale:"x"},y1:{value:r,scale:"y"},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0}},e,Ms),this.curve=Al(a,l),Zo(this,e)}project(t,e,n){this.curve!==Sl&&super.project(t,e,n)}render(t,n,r,o,i){const{x1:a,y1:l,x2:s=a,y2:c=l}=r,{curve:u}=this;return kn("svg:g",i).call(co,this,o,i).call(po,this,n).call((n=>n.selectAll().data(t).enter().append("path").call(uo,this).attr("d",u===Sl&&i.projection?function(t,n,r,o,i){const a=e.geoPath(t);return n=rt(n),r=rt(r),o=rt(o),i=rt(i),t=>a({type:"LineString",coordinates:[[n[t],r[t]],[o[t],i[t]]]})}(i.projection,a,l,s,c):t=>{const n=e.pathRound(),r=u(n);return r.lineStart(),r.point(a[t],l[t]),r.point(s[t],c[t]),r.lineEnd(),n}).call(io,this,r).call(oi,this,r,i))).node()}}function As(t,{x:e,x1:n,x2:r,y:o,y1:i,y2:a,...l}={}){return[n,r]=Ss(e,n,r),[i,a]=Ss(o,i,a),new Ls(t,{...l,x1:n,x2:r,y1:i,y2:a})}function Ss(t,e,n){if(void 0===t){if(void 0===e){if(void 0!==n)return[n]}else if(void 0===n)return[e]}else{if(void 0===e)return void 0===n?[t]:[t,n];if(void 0===n)return[t,e]}return[e,n]}const zs={ariaLabel:"arrow",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeMiterlimit:1,strokeWidth:1.5};class Os extends Io{constructor(t,n={}){const{x1:r,y1:o,x2:i,y2:a,bend:l=0,headAngle:s=60,headLength:c=8,inset:u=0,insetStart:f=u,insetEnd:h=u,sweep:d}=n;super(t,{x1:{value:r,scale:"x"},y1:{value:o,scale:"y"},x2:{value:i,scale:"x",optional:!0},y2:{value:a,scale:"y",optional:!0}},n,zs),this.bend=!0===l?22.5:Math.max(-90,Math.min(90,l)),this.headAngle=+s,this.headLength=+c,this.insetStart=+f,this.insetEnd=+h,this.sweep=function(t=1){if("number"==typeof t)return et(Math.sign(t));if("function"==typeof t)return(e,n,r,o)=>Math.sign(t(e,n,r,o));switch(ft(t,"sweep",["+x","-x","+y","-y"])){case"+x":return(t,n,r)=>e.ascending(t,r);case"-x":return(t,n,r)=>e.descending(t,r);case"+y":return(t,n,r,o)=>e.ascending(n,o);case"-y":return(t,n,r,o)=>e.descending(n,o)}}(d)}render(t,e,n,r,o){const{x1:i,y1:a,x2:l=i,y2:s=a,SW:c}=n,{strokeWidth:u,bend:f,headAngle:h,headLength:d,insetStart:p,insetEnd:m}=this,y=c?t=>c[t]:et(void 0===u?1:u),g=h*Vo/2,v=d/1.5;return kn("svg:g",o).call(co,this,r,o).call(po,this,e).call((e=>e.selectAll().data(t).enter().append("path").call(uo,this).attr("d",(t=>{let e=i[t],n=a[t],r=l[t],o=s[t];const c=Math.hypot(r-e,o-n);if(c<=p+m)return null;let u=Math.atan2(o-n,r-e);const h=Math.min(v*y(t),c/3),d=this.sweep(e,n,r,o)*f*Vo,x=Math.hypot(c/Math.tan(d),c)/2;if(p||m)if(x<1e5){const t=Math.sign(d),[i,a]=function([t,e],[n,r],o,i){const a=n-t,l=r-e,s=Math.hypot(a,l),c=i*Math.sqrt(o*o-s*s/4)/s;return[(t+n)/2-l*c,(e+r)/2+a*c]}([e,n],[r,o],x,t);if(p&&([e,n]=Es([i,a,x],[e,n,p],-t*Math.sign(p))),m){const[e,n]=Es([i,a,x],[r,o,m],t*Math.sign(m));u+=Math.atan2(n-a,e-i)-Math.atan2(o-a,r-i),r=e,o=n}}else{const t=r-e,i=o-n,a=Math.hypot(t,i);p&&(e+=t/a*p,n+=i/a*p),m&&(r-=t/a*m,o-=i/a*m)}const w=u+d,b=w+g,k=w-g,$=r-h*Math.cos(b),M=o-h*Math.sin(b),L=r-h*Math.cos(k),A=o-h*Math.sin(k);return`M${e},${n}${x<1e5?`A${x},${x} 0,0,${d>0?1:0} `:"L"}${r},${o}${h?`M${$},${M}L${r},${o}L${L},${A}`:""}`})).call(io,this,n))).node()}}function Es([t,e,n],[r,o,i],a){const l=r-t,s=o-e,c=Math.hypot(l,s),u=(l*l+s*s-i*i+n*n)/(2*c),f=a*Math.sqrt(n*n-u*u);return[t+(l*u+s*f)/c,e+(s*u-l*f)/c]}class Rs extends Io{constructor(t,e,n={},r){super(t,e,n,r);const{inset:o=0,insetTop:i=o,insetRight:a=o,insetBottom:l=o,insetLeft:s=o,rx:c,ry:u}=n;this.insetTop=Q(i),this.insetRight=Q(a),this.insetBottom=Q(l),this.insetLeft=Q(s),this.rx=mo(c,"auto"),this.ry=mo(u,"auto")}render(t,e,n,r,o){const{rx:i,ry:a}=this;return kn("svg:g",o).call(co,this,r,o).call(this._transform,this,e).call((o=>o.selectAll().data(t).enter().append("rect").call(uo,this).attr("x",this._x(e,n,r)).attr("width",this._width(e,n,r)).attr("y",this._y(e,n,r)).attr("height",this._height(e,n,r)).call(ho,"rx",i).call(ho,"ry",a).call(io,this,n))).node()}_x(t,{x:e},{marginLeft:n}){const{insetLeft:r}=this;return e?t=>e[t]+r:n+r}_y(t,{y:e},{marginTop:n}){const{insetTop:r}=this;return e?t=>e[t]+r:n+r}_width({x:t},{x:e},{marginRight:n,marginLeft:r,width:o}){const{insetLeft:i,insetRight:a}=this,l=e&&t?t.bandwidth():o-n-r;return Math.max(0,l-i-a)}_height({y:t},{y:e},{marginTop:n,marginBottom:r,height:o}){const{insetTop:i,insetBottom:a}=this,l=e&&t?t.bandwidth():o-n-r;return Math.max(0,l-i-a)}}const Cs={ariaLabel:"bar"};class Ts extends Rs{constructor(t,e={}){const{x1:n,x2:r,y:o}=e;super(t,{x1:{value:n,scale:"x"},x2:{value:r,scale:"x"},y:{value:o,scale:"y",type:"band",optional:!0}},e,Cs)}_transform(t,e,{x:n}){t.call(po,e,{x:n},0,0)}_x({x:t},{x1:e,x2:n},{marginLeft:r}){const{insetLeft:o}=this;return Yr(t)?r+o:t=>Math.min(e[t],n[t])+o}_width({x:t},{x1:e,x2:n},{marginRight:r,marginLeft:o,width:i}){const{insetLeft:a,insetRight:l}=this;return Yr(t)?i-r-o-a-l:t=>Math.max(0,Math.abs(n[t]-e[t])-a-l)}}class Bs extends Rs{constructor(t,e={}){const{x:n,y1:r,y2:o}=e;super(t,{y1:{value:r,scale:"y"},y2:{value:o,scale:"y"},x:{value:n,scale:"x",type:"band",optional:!0}},e,Cs)}_transform(t,e,{y:n}){t.call(po,e,{y:n},0,0)}_y({y:t},{y1:e,y2:n},{marginTop:r}){const{insetTop:o}=this;return Yr(t)?r+o:t=>Math.min(e[t],n[t])+o}_height({y:t},{y1:e,y2:n},{marginTop:r,marginBottom:o,height:i}){const{insetTop:a,insetBottom:l}=this;return Yr(t)?i-r-o-a-l:t=>Math.max(0,Math.abs(n[t]-e[t])-a-l)}}function Ns(t,e={}){return gt(e)||(e={...e,y:X,x2:H}),new Ts(t,os(mi(ts(e))))}function Is(t,e={}){return gt(e)||(e={...e,x:X,y2:H}),new Bs(t,is(yi(es(e))))}const Ps={ariaLabel:"cell"};class Ws extends Rs{constructor(t,{x:e,y:n,...r}={}){super(t,{x:{value:e,scale:"x",type:"band",optional:!0},y:{value:n,scale:"y",type:"band",optional:!0}},r,Ps)}_transform(t,e){t.call(po,e,{},0,0)}}function js(t,{x:e,y:n,...r}={}){return[e,n]=$t(e,n),new Ws(t,{...r,x:e,y:n})}const qs={ariaLabel:"dot",fill:"none",stroke:"currentColor",strokeWidth:1.5};function Fs(t){return void 0===t.sort&&void 0===t.reverse?Ae({channel:"-r"},t):t}class Ds extends Io{constructor(t,n={}){const{x:r,y:o,r:i,rotate:a,symbol:s=e.symbolCircle,frameAnchor:c}=n,[u,f]=ct(a,0),[h,d]=function(t){if(null==t||ye(t))return[void 0,t];if("string"==typeof t){const e=me.get(`${t}`.toLowerCase());if(e)return[void 0,e]}return[t,void 0]}(s),[p,m]=ct(i,null==h?3:4.5);super(t,{x:{value:r,scale:"x",optional:!0},y:{value:o,scale:"y",optional:!0},r:{value:p,scale:"r",filter:l,optional:!0},rotate:{value:u,optional:!0},symbol:{value:h,scale:"auto",optional:!0}},Fs(n),qs),this.r=m,this.rotate=f,this.symbol=d,this.frameAnchor=ee(c);const{channels:y}=this,{symbol:g}=y;if(g){const{fill:t,stroke:e}=y;g.hint={fill:t?t.value===g.value?"color":"currentColor":this.fill??"currentColor",stroke:e?e.value===g.value?"color":"currentColor":this.stroke??"none"}}}render(t,n,r,o,i){const{x:a,y:l}=n,{x:c,y:u,r:f,rotate:h,symbol:d}=r,{r:p,rotate:m,symbol:y}=this,[g,v]=wo(this,o),x=y===e.symbolCircle,w=f?void 0:p*p*Math.PI;return s(p)&&(t=[]),kn("svg:g",i).call(co,this,o,i).call(po,this,{x:c&&a,y:u&&l}).call((n=>n.selectAll().data(t).enter().append(x?"circle":"path").call(uo,this).call(x?t=>{t.attr("cx",c?t=>c[t]:g).attr("cy",u?t=>u[t]:v).attr("r",f?t=>f[t]:p)}:t=>{t.attr("transform",Li`translate(${c?t=>c[t]:g},${u?t=>u[t]:v})${h?t=>` rotate(${h[t]})`:m?` rotate(${m})`:""}`).attr("d",f&&d?t=>{const n=e.pathRound();return d[t].draw(n,f[t]*f[t]*Math.PI),n}:f?t=>{const n=e.pathRound();return y.draw(n,f[t]*f[t]*Math.PI),n}:d?t=>{const n=e.pathRound();return d[t].draw(n,w),n}:(()=>{const t=e.pathRound();return y.draw(t,w),t})())}).call(io,this,r))).node()}}function Ys(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=$t(e,n)),new Ds(t,{...r,x:e,y:n})}const _s={ariaLabel:"line",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Gs extends Io{constructor(t,e={}){const{x:n,y:r,z:o,curve:i,tension:a}=e;super(t,{x:{value:n,scale:"x"},y:{value:r,scale:"y"},z:{value:Mt(e),optional:!0}},e,_s),this.z=o,this.curve=Al(i,a),Zo(this,e)}filter(t){return t}project(t,e,n){this.curve!==Sl&&super.project(t,e,n)}render(t,n,r,o,i){const{x:a,y:l}=r,{curve:s}=this;return kn("svg:g",i).call(co,this,o,i).call(po,this,n).call((n=>n.selectAll().data(so(t,[a,l],this,r)).enter().append("path").call(uo,this).call(ao,this,r).call(ii,this,r,i).attr("d",s===Sl&&i.projection?function(t,n,r){const o=e.geoPath(t);return n=rt(n),r=rt(r),t=>{let e=[];const i=[e];for(const o of t)-1===o?(e=[],i.push(e)):e.push([n[o],r[o]]);return o({type:"MultiLineString",coordinates:i})}}(i.projection,a,l):e.line().curve(s).defined((t=>t>=0)).x((t=>a[t])).y((t=>l[t]))))).node()}}function Xs(t,{x:e,y:n,...r}={}){return[e,n]=$t(e,n),new Gs(t,{...r,x:e,y:n})}function Hs(t,{x:e=H,y:n=X,...r}={}){return new Gs(t,Tl({...r,x:e,y:n}))}function Us(t,{x:e=X,y:n=H,...r}={}){return new Gs(t,Cl({...r,x:e,y:n}))}const Vs={ariaLabel:"rect"};class Zs extends Io{constructor(t,e={}){const{x1:n,y1:r,x2:o,y2:i,inset:a=0,insetTop:l=a,insetRight:s=a,insetBottom:c=a,insetLeft:u=a,rx:f,ry:h}=e;super(t,{x1:{value:n,scale:"x",type:null!=n&&null==o?"band":void 0,optional:!0},y1:{value:r,scale:"y",type:null!=r&&null==i?"band":void 0,optional:!0},x2:{value:o,scale:"x",optional:!0},y2:{value:i,scale:"y",optional:!0}},e,Vs),this.insetTop=Q(l),this.insetRight=Q(s),this.insetBottom=Q(c),this.insetLeft=Q(u),this.rx=mo(f,"auto"),this.ry=mo(h,"auto")}render(t,e,n,r,o){const{x:i,y:a}=e,{x1:l,y1:s,x2:c,y2:u}=n,{marginTop:f,marginRight:h,marginBottom:d,marginLeft:p,width:m,height:y}=r,{projection:g}=o,{insetTop:v,insetRight:x,insetBottom:w,insetLeft:b,rx:k,ry:$}=this,M=(i?.bandwidth?i.bandwidth():0)-b-x,L=(a?.bandwidth?a.bandwidth():0)-v-w;return kn("svg:g",o).call(co,this,r,o).call(po,this,{},0,0).call((e=>e.selectAll().data(t).enter().append("rect").call(uo,this).attr("x",!l||!g&&Yr(i)?p+b:c?t=>Math.min(l[t],c[t])+b:t=>l[t]+b).attr("y",!s||!g&&Yr(a)?f+v:u?t=>Math.min(s[t],u[t])+v:t=>s[t]+v).attr("width",!l||!g&&Yr(i)?m-h-p-x-b:c?t=>Math.max(0,Math.abs(c[t]-l[t])+M):M).attr("height",!s||!g&&Yr(a)?y-f-d-v-w:u?t=>Math.max(0,Math.abs(s[t]-u[t])+L):L).call(ho,"rx",k).call(ho,"ry",$).call(io,this,n))).node()}}function Qs(t,e){return new Zs(t,di(pi(e)))}function Js(t,e={}){return gt(e)||(e={...e,y:X,x2:H,interval:1}),new Zs(t,os(pi(ts(e))))}function Ks(t,e={}){return gt(e)||(e={...e,x:X,y2:H,interval:1}),new Zs(t,is(di(es(e))))}function tc(t,e){e=function({x:t,y:e,color:n,size:r,fx:o,fy:i,mark:a}={}){wt(t)||(t=rc(t));wt(e)||(e=rc(e));wt(n)||(n=Zt(n)?{color:n}:rc(n));wt(r)||(r=rc(r));wt(o)&&({value:o}=rc(o));wt(i)&&({value:i}=rc(i));null!=a&&(a=`${a}`.toLowerCase());return{x:t,y:e,color:n,size:r,fx:o,fy:i,mark:a}}(e);const{x:n,y:r,color:o,size:i}=e,a=nc(t,n),l=nc(t,r),s=nc(t,o),c=nc(t,i);let u,f,h,{fx:d,fy:p,x:{value:m,reduce:y,zero:g,...v},y:{value:x,reduce:w,zero:b,...k},color:{value:$,color:M,reduce:L},size:{value:A,reduce:S},mark:z}=e;if(void 0===y&&(y=null==w&&null==m&&null==A&&null!=x?"count":null),void 0===w&&(w=null==y&&null==x&&null==A&&null!=m?"count":null),void 0!==S||null!=A||null!=L||null!=y||null!=w||null!=m&&!Yt(a)||null!=x&&!Yt(l)||(S="count"),void 0===g&&(g=!!oc(y)||void 0),void 0===b&&(b=!!oc(w)||void 0),null==m&&null==x)throw new Error("must specify x or y");if(null!=y&&null==x)throw new Error("reducing x requires y");if(null!=w&&null==m)throw new Error("reducing y requires x");switch(void 0===z&&(z=null!=A||null!=S?"dot":oc(y)||oc(w)||null!=L?"bar":null!=m&&null!=x?Yt(a)||Yt(l)||null==y&&null==w&&!ec(a)&&!ec(l)?"dot":"line":null!=m||null!=x?"rule":null),z){case"dot":h=Ys,f="stroke";break;case"line":h=a&&l||null!=y||null!=w?b||null!=w||a&&ec(a)?Us:g||null!=y||l&&ec(l)?Hs:Xs:a?Hs:Us,f="stroke",ac(s)&&(u=null);break;case"area":h=!b&&null==w&&(g||null!=y||l&&ec(l))?ks:$s,f="fill",ac(s)&&(u=null);break;case"rule":h=a?ki:$i,f="stroke";break;case"bar":h=null!=y?Yt(l)?ic(y)&&a&&Yt(a)?js:Ns:Js:null!=w?Yt(a)?ic(w)&&l&&Yt(l)?js:Is:Ks:null!=L||null!=S?a&&Yt(a)&&l&&Yt(l)?js:a&&Yt(a)?Is:l&&Yt(l)?Ns:Qs:!a||!Ht(a)||l&&Ht(l)?!l||!Ht(l)||a&&Ht(a)?js:Is:Ns,f="fill";break;default:throw new Error(`invalid mark: ${z}`)}let O,E={fx:d,fy:p,x:a??void 0,y:l??void 0,[f]:s??M,z:u,r:c??void 0,tip:!0},R={[f]:L??void 0,r:S??void 0};if(null!=y&&null!=w)throw new Error("cannot reduce both x and y");return null!=w?(R.y=w,O=Yt(a)?Re:zl):null!=y?(R.x=y,O=Yt(l)?Ce:Ol):null==L&&null==S||(a&&l?O=Yt(a)&&Yt(l)?Te:Yt(a)?Ol:Yt(l)?zl:El:a?O=Yt(a)?Re:zl:l&&(O=Yt(l)?Ce:Ol)),O!==El&&O!==zl||(E.x={value:a,...v}),O!==El&&O!==Ol||(E.y={value:l,...k}),void 0===g&&(g=a&&!(O===El||O===zl)&&(h===Ns||h===ks||h===Js||h===$i)),void 0===b&&(b=l&&!(O===El||O===Ol)&&(h===Is||h===$s||h===Ks||h===ki)),{fx:d??null,fy:p??null,x:{value:m??null,reduce:y??null,zero:!!g,...v},y:{value:x??null,reduce:w??null,zero:!!b,...k},color:{value:$??null,reduce:L??null,...void 0!==M&&{color:M}},size:{value:A??null,reduce:S??null},mark:z,markImpl:sc[h],markOptions:E,transformImpl:sc[O],transformOptions:R,colorMode:f}}function ec(t){let n,r;for(const o of t){if(null==o)continue;if(void 0===n){n=o;continue}const t=Math.sign(e.ascending(n,o));if(t){if(void 0!==r&&t!==r)return!1;n=o,r=t}}return!0}function nc(t,e){const n=F(t,e.value);return n&&(n.label=Tt(e.value)),n}function rc(t){return function(t){if(null==t)return!1;if("function"==typeof t.reduceIndex)return!0;if("function"==typeof t.reduce&&vt(t))return!0;if(/^p\d{2}$/i.test(t))return!0;switch(`${t}`.toLowerCase()){case"first":case"last":case"count":case"distinct":case"sum":case"proportion":case"proportion-facet":case"deviation":case"min":case"min-index":case"max":case"max-index":case"mean":case"median":case"variance":case"mode":return!0}return!1}(t)?{reduce:t}:{value:t}}function oc(t){return/^(?:distinct|count|sum|proportion)$/i.test(t)}function ic(t){return/^(?:first|last|mode)$/i.test(t)}function ac(t){return!!t&&new e.InternSet(t).size>t.length>>1}const lc={dot:Ys,line:Xs,lineX:Hs,lineY:Us,areaX:ks,areaY:$s,ruleX:ki,ruleY:$i,barX:Ns,barY:Is,rect:Qs,rectX:Js,rectY:Ks,cell:js,bin:El,binX:zl,binY:Ol,group:Te,groupX:Re,groupY:Ce},sc=Object.fromEntries(Object.entries(lc).map((([t,e])=>[e,t])));function cc(t,e={}){let{x:n,x1:r,x2:o}=e;void 0===n&&void 0===r&&void 0===o&&(e={...e,x:n=H});const i={};return null!=n&&(i.x=t),null!=r&&(i.x1=t),null!=o&&(i.x2=t),fc(i,e)}function uc(t,e={}){let{y:n,y1:r,y2:o}=e;void 0===n&&void 0===r&&void 0===o&&(e={...e,y:n=H});const i={};return null!=n&&(i.y=t),null!=r&&(i.y1=t),null!=o&&(i.y2=t),fc(i,e)}function fc(t={},n={}){const r=Mt(n),o=Object.entries(t).map((([t,e])=>{const r=Et(t,n);if(null==r)throw new Error(`missing channel: ${t}`);const[o,i]=Rt(r);return{key:t,input:r,output:o,setOutput:i,map:hc(e)}}));return{...xe(n,((t,n)=>{const i=F(t,r),a=o.map((({input:e})=>F(t,e))),l=o.map((({setOutput:e})=>e(new Array(t.length))));for(const t of n)for(const n of i?e.group(t,(t=>i[t])).values():[t])o.forEach((({map:t},e)=>t.mapIndex(n,a[e],l[e])));return{data:t,facets:n}})),...Object.fromEntries(o.map((({key:t,output:e})=>[t,e])))}}function hc(t){if(null==t)throw new Error("missing map");if("function"==typeof t.mapIndex)return t;if("function"==typeof t.map&&vt(t))return function(t){return console.warn("deprecated map interface; implement mapIndex instead."),{mapIndex:t.map.bind(t)}}(t);if("function"==typeof t)return dc(St(t));switch(`${t}`.toLowerCase()){case"cumsum":return pc;case"rank":return dc(((t,n)=>e.rank(t,(t=>n[t]))));case"quantile":return dc(((t,n)=>function(t,n){const r=e.count(t,n)-1;return e.rank(t,n).map((t=>t/r))}(t,(t=>n[t]))))}throw new Error(`invalid map: ${t}`)}function dc(t){return{mapIndex(e,n,r){const o=t(e,n);if(o.length!==e.length)throw new Error("map function returned a mismatched length");for(let t=0,n=e.length;t0))throw new Error(`invalid k: ${n}`);return function(t="mean"){if("string"==typeof t){if(/^p\d{2}$/i.test(t))return yc(nt(t));switch(t.toLowerCase()){case"deviation":return yc(e.deviation);case"max":return gc(((t,n)=>e.max(t,(t=>n[t]))));case"mean":return xc;case"median":return yc(e.median);case"min":return gc(((t,n)=>e.min(t,(t=>n[t]))));case"mode":return gc(((t,n)=>e.mode(t,(t=>n[t]))));case"sum":return vc;case"variance":return yc(e.variance);case"difference":return Mc;case"ratio":return Lc;case"first":return Ac;case"last":return Sc}}if("function"!=typeof t)throw new Error(`invalid reduce: ${t}`);return gc(St(t))}(r)(n,function(t="middle",e){switch(`${t}`.toLowerCase()){case"middle":return e-1>>1;case"start":return 0;case"end":return e-1}throw new Error(`invalid anchor: ${t}`)}(i,n),a)}function yc(t){return(e,n,r)=>r?{mapIndex(r,o,i){const a=t=>null==o[t]?NaN:+o[t];let l=0;for(let t=0;tnull==o[t]?NaN:+o[t];for(let o=-n;o<0;++o)i[r[o+n]]=t(zt(r,0,o+e),a);for(let o=0,l=r.length-n;oo?{mapIndex(o,i,a){let l=0;for(let t=0;t=r;--i){const r=t[e[i]];if(n(r))return r}}function kc(t,e,n,r){for(let o=n+r;n=n;--o){let n=t[e[o]];if(null!==n&&!isNaN(n=+n))return n}}function Mc(t,e,n){return n?{mapIndex(n,r,o){for(let i=0,a=n.length-t;ie.mean(t)+n*(e.deviation(t)||0),strict:r,anchor:o})}const Ec={ariaLabel:"tick",fill:null,stroke:"currentColor"};class Rc extends Io{constructor(t,e,n){super(t,e,n,Ec),Zo(this,n)}render(t,e,n,r,o){return kn("svg:g",o).call(co,this,r,o).call(this._transform,this,e).call((i=>i.selectAll().data(t).enter().append("line").call(uo,this).attr("x1",this._x1(e,n,r)).attr("x2",this._x2(e,n,r)).attr("y1",this._y1(e,n,r)).attr("y2",this._y2(e,n,r)).call(io,this,n).call(oi,this,n,o))).node()}}class Cc extends Rc{constructor(t,e={}){const{x:n,y:r,inset:o=0,insetTop:i=o,insetBottom:a=o}=e;super(t,{x:{value:n,scale:"x"},y:{value:r,scale:"y",type:"band",optional:!0}},e),this.insetTop=Q(i),this.insetBottom=Q(a)}_transform(t,e,{x:n}){t.call(po,e,{x:n},Kr,0)}_x1(t,{x:e}){return t=>e[t]}_x2(t,{x:e}){return t=>e[t]}_y1({y:t},{y:e},{marginTop:n}){const{insetTop:r}=this;return e&&t?t=>e[t]+r:n+r}_y2({y:t},{y:e},{height:n,marginBottom:r}){const{insetBottom:o}=this;return e&&t?n=>e[n]+t.bandwidth()-o:n-r-o}}class Tc extends Rc{constructor(t,e={}){const{x:n,y:r,inset:o=0,insetRight:i=o,insetLeft:a=o}=e;super(t,{y:{value:r,scale:"y"},x:{value:n,scale:"x",type:"band",optional:!0}},e),this.insetRight=Q(i),this.insetLeft=Q(a)}_transform(t,e,{y:n}){t.call(po,e,{y:n},0,Kr)}_x1({x:t},{x:e},{marginLeft:n}){const{insetLeft:r}=this;return e&&t?t=>e[t]+r:n+r}_x2({x:t},{x:e},{width:n,marginRight:r}){const{insetRight:o}=this;return e&&t?n=>e[n]+t.bandwidth()-o:n-r-o}_y1(t,{y:e}){return t=>e[t]}_y2(t,{y:e}){return t=>e[t]}}function Bc(t,{x:e=H,...n}={}){return new Cc(t,{...n,x:e})}function Nc(t,{y:e=H,...n}={}){return new Tc(t,{...n,y:e})}function Ic(t){const e=Pc(t),n=Wc(t);return t.map((t=>tn?t:NaN))}function Pc(t){const n=2.5*jc(t)-1.5*qc(t);return e.min(t,(t=>t>=n?t:NaN))}function Wc(t){const n=2.5*qc(t)-1.5*jc(t);return e.max(t,(t=>t<=n?t:NaN))}function jc(t){return e.quantile(t,.25)}function qc(t){return e.quantile(t,.75)}const Fc={ariaLabel:"raster",stroke:null,pixelSize:1};function Dc(t,e){const n=+t;if(isNaN(n))throw new Error(`invalid ${e}: ${t}`);return n}function Yc(t,e){const n=Math.floor(t);if(isNaN(n))throw new Error(`invalid ${e}: ${t}`);return n}class _c extends Io{constructor(t,e,n={},r){let{width:o,height:i,x:a,y:l,x1:s=(null==a?0:void 0),y1:c=(null==l?0:void 0),x2:u=(null==a?o:void 0),y2:f=(null==l?i:void 0),pixelSize:h=r.pixelSize,blur:d=0,interpolate:p}=n;if(null!=o&&(o=Yc(o,"width")),null!=i&&(i=Yc(i,"height")),null!=s&&(s=Dc(s,"x1")),null!=c&&(c=Dc(c,"y1")),null!=u&&(u=Dc(u,"x2")),null!=f&&(f=Dc(f,"y2")),null==a&&(null==s||null==u))throw new Error("missing x");if(null==l&&(null==c||null==f))throw new Error("missing y");null!=t&&null!=o&&null!=i&&(void 0===a&&null!=s&&null!=u&&(a=function(t,e,n){return{transform(r){const o=r.length,i=new Float64Array(o),a=(e-t)/n,l=t+a/2;for(let t=0;tt),{x:l,y:s}=r,{document:c}=i,[u,f,h,d]=Hc(r,o,i),p=h-u,m=d-f,{pixelSize:y,width:g=Math.round(Math.abs(p)/y),height:v=Math.round(Math.abs(m)/y)}=this,x=g*v;let{fill:w,fillOpacity:b}=r,k=0;if(this.interpolate){const e=g/p,n=v/m,r=dt(l,(t=>(t-u)*e),Float64Array),o=dt(s,(t=>(t-f)*n),Float64Array);w&&(w=this.interpolate(t,g,v,r,o,w)),b&&(b=this.interpolate(t,g,v,r,o,b))}else null==this.data&&t&&(k=t.fi*x);const $=c.createElement("canvas");$.width=g,$.height=v;const M=$.getContext("2d"),L=M.createImageData(g,v),A=L.data;let{r:S,g:z,b:O}=e.rgb(this.fill)??{r:0,g:0,b:0},E=255*(this.fillOpacity??1);for(let t=0;t0&&e.blurImage(L,this.blur),M.putImageData(L,0,0),kn("svg:g",i).call(co,this,o,i).call(po,this,n).call((t=>t.append("image").attr("transform",`translate(${u},${f}) scale(${Math.sign(h-u)},${Math.sign(d-f)})`).attr("width",Math.abs(p)).attr("height",Math.abs(m)).attr("preserveAspectRatio","none").call(ho,"image-rendering",this.imageRendering).call(uo,this).attr("xlink:href",$.toDataURL()))).node()}}function Xc(t,e,n){arguments.length<3&&(n=e,e=null);let{x:r,y:o,[t]:i,...a}=n;return void 0===r&&void 0===o&&function(t){if(!Ft(t))return!1;for(const e of t)if(null!=e)return"object"==typeof e&&"0"in e&&"1"in e}(e)&&(r=J,o=K,void 0===i&&(i=tt)),[e,{...a,x:r,y:o,[t]:i}]}function Hc({x1:t,y1:e,x2:n,y2:r},o,{projection:i}){const{width:a,height:l,marginTop:s,marginRight:c,marginBottom:u,marginLeft:f}=o;return[t&&null==i?t[0]:f,e&&null==i?e[0]:s,n&&null==i?n[0]:a-c,r&&null==i?r[0]:l-u]}function Uc({x1:t,y1:e,x2:n,y2:r},o,i,a){const l={};return t&&(l.x1=t),e&&(l.y1=e),n&&(l.x2=n),r&&(l.y2=r),Hc(fn(l,o),i,a)}function Vc(t,e={}){const{[t]:n}=e;if("function"!=typeof n)throw new Error(`invalid ${t}: not a function`);return we({...e,[t]:void 0},(function(r,o,i,a,l,s){const{x:c,y:u}=a;if(!c)throw new Error("missing scale: x");if(!u)throw new Error("missing scale: y");const[f,h,d,p]=Uc(i,a,l,s),m=d-f,y=p-h,{pixelSize:g}=this,{width:v=Math.round(Math.abs(m)/g),height:x=Math.round(Math.abs(y)/g)}=e,w=new Array(v*x*(o?o.length:1)),b=m/v,k=y/x;let $=0;for(const t of o??[void 0])for(let e=.5;e=e||o[l]<0||o[l]>=n||(a[Math.floor(o[l])*e+Math.floor(r[l])]=i[l]);return a}function Qc({random:t=e.randomLcg(42)}={}){return(n,r,o,i,a,l)=>{const{points:s,triangles:c,hull:u}=e.Delaunay.from(n,(t=>i[t]),(t=>a[t])),f=new l.constructor(r*o).fill(NaN),h=new Uint8Array(r*o),d=function(t,e){return Ht(t)||_t(t)?nu:function(t){return(e,n,r,o,i,a,l,s)=>{const c=t(l,s);return c=r||e<0||e>=o)continue;const n=t+.5,i=e+.5,a=((g-v)*(n-m)+(i-v)*(m-p))/$;if(a<0)continue;const l=((v-y)*(n-m)+(i-v)*(u-m))/$;if(l<0)continue;const s=1-a-l;if(s<0)continue;const c=t+r*e;f[c]=d(M,a,L,l,A,s,t,e),h[c]=1}}return function(t,e,n,r,o,i,a,l,s,c){n=Float64Array.from(l,(t=>n[s[t]])),r=Float64Array.from(l,(t=>r[s[t]])),o=Array.from(l,(t=>o[s[t]]));const u=n.length,f=Array.from({length:u},((t,e)=>function(t,e,n){const r=e.length,o=e.at(t-2),i=n.at(t-2),a=e.at(t-1),l=n.at(t-1),s=e[t],c=n[t],u=e.at(t+1-r),f=n.at(t+1-r),h=a-s,d=l-c,p=o-a,m=i-l,y=s-u,g=c-f,v=Math.hypot(h,d),x=Math.hypot(p,m),w=Math.hypot(y,g);return(t,e)=>{const n=t-a,r=e-l,o=t-s,i=e-c;return Kc(n,r,o,i)>-1e-6&&Kc(n,r,h,d)*x-Kc(n,r,p,m)*v>-1e-6&&Kc(o,i,y,g)*v-Kc(o,i,h,d)*w<=0}}(e,n,r)));let h=0;for(let l=0;l0&&c>0?s/(s+c):+(s>c)}function Kc(t,e,n,r){return t*r-n*e}function tu(t,n,r,o,i,a){const l=new a.constructor(n*r),s=e.Delaunay.from(t,(t=>o[t]),(t=>i[t]));let c,u;for(let e=.5,o=0;e{const u=new c.constructor(i*a),f=e.Delaunay.from(o,(t=>l[t]),(t=>s[t]));let h,d,p;for(let e=.5,m=0;en&&vt.map((t=>t.value)),label:Tt(r)};for(const e in i)"value"===o[e]&&(o[e]=t)}if(null==t){if(null==r)throw new Error("missing contour value");o=Vc("value",{value:r,...o}),r=null}else{let{interpolate:t}=o;void 0===r&&(r=H),void 0===t&&(o.interpolate="nearest")}super(t,{value:{value:r,optional:!0}},function({thresholds:t,interval:n,...r}){return t=Wl(t,n,e.thresholdSturges),we(r,(function(n,r,o,i,a,l){const[s,c,u,f]=Uc(o,i,a,l),h=u-s,d=f-c,{pixelSize:p,width:m=Math.round(Math.abs(h)/p),height:y=Math.round(Math.abs(d)/p)}=this,g=m/h,v=y/d,x=o.value.value,w=[];if(this.interpolate){const{x:t,y:e}=Pn(o,i,l),n=dt(t,(t=>(t-s)*g),Float64Array),a=dt(e,(t=>(t-c)*v),Float64Array),u=[o.x,o.y,o.value],f=[n,a,x];for(const t of r){const e=this.filter(t,u,f);w.push(this.interpolate(e,m,y,n,a,x))}}else if(r){const t=m*y,e=r.length;for(let n=0;n0)for(const t of w)e.blur2({data:t,width:m,height:y},this.blur);const b=function(t,n,r,o){if("function"==typeof t?.range)return t.range(t.floor(r),o);"function"==typeof t&&(t=t(n,r,o));if("number"!=typeof t)return ht(t);const i=e.ticks(...e.nice(r,o,t),t);for(;i[i.length-1]>=o;)i.pop();for(;i[1]e.min(t,iu))),e.max(t,(t=>e.max(t,iu)))]}(w));if(null===b)throw new Error(`unsupported thresholds: ${t}`);const{contour:k}=e.contours().size([m,y]).smooth(this.smooth),$=[],M=[];for(const t of w)M.push(e.range($.length,$.push(...dt(b,(e=>k(t,e))))));for(const{coordinates:t}of $)for(const e of t)for(const t of e)for(const e of t)e[0]=e[0]/g+s,e[1]=e[1]/v+c;return{data:$,facets:M,channels:un(this.contourChannels,$)}}))}(o),ru);const a={geometry:{value:H}};for(const t in this.channels){const e=this.channels[t],{scale:n}=e;"x"!==n&&"y"!==n&&"value"!==t&&(a[t]=e,delete this.channels[t])}this.contourChannels=a,this.smooth=!!n}filter(t,{x:e,y:n,value:r,...o},i){return super.filter(t,o,i)}render(t,n,r,o,i){const{geometry:a}=r,l=e.geoPath();return kn("svg:g",i).call(co,this,o,i).call(po,this,n).call((e=>{e.selectAll().data(t).enter().append("path").call(uo,this).attr("d",(t=>l(a[t]))).call(io,this,r)})).node()}}function iu(t){return isFinite(t)?t:NaN}function au(t,e,n={}){const{x:r,y:o,maxRadius:i}=n,a=t({px:r,py:o,maxRadius:i}),l=[];null!=r&&l.push(ki(e,cu("x",{...a,inset:-6},n))),null!=o&&l.push($i(e,cu("y",{...a,inset:-6},n))),null!=r&&l.push(Ri(e,uu("x",{...a,dy:9,frameAnchor:"bottom",lineAnchor:"top"},n))),null!=o&&l.push(Ri(e,uu("y",{...a,dx:-9,frameAnchor:"left",textAnchor:"end"},n)));for(const t of l)t.ariaLabel=`crosshair ${t.ariaLabel}`;return Po(...l)}function lu(t,{channels:e,...n},{facet:r,facetAnchor:o,fx:i,fy:a,[t]:l,channels:s,transform:c,initializer:u}){return{...n,facet:r,facetAnchor:o,fx:i,fy:a,[t]:l,channels:{...e,...s},transform:c,initializer:su(t,u)}}function su(t,e){return null==e?e:function(n,r,{x:o,y:i,px:a,py:l,...s},...c){const{channels:{x:u,y:f,...h}={},...d}=e.call(this,n,r,{...s,x:a,y:l},...c);return{channels:{...h,...u&&{px:u,..."x"===t&&{x:u}},...f&&{py:f,..."y"===t&&{y:f}}},...d}}}function cu(t,e,n){const{color:r="currentColor",opacity:o=.2,ruleStroke:i=r,ruleStrokeOpacity:a=o,ruleStrokeWidth:l}=n;return{...lu(t,e,n),stroke:i,strokeOpacity:a,strokeWidth:l}}function uu(t,e,n){const{color:r="currentColor",textFill:o=r,textFillOpacity:i,textStroke:a="var(--plot-background)",textStrokeOpacity:l,textStrokeWidth:s=5}=n;return{...lu(t,e,fu(t,n)),fill:o,fillOpacity:i,stroke:a,strokeOpacity:l,strokeWidth:s}}function fu(t,e){return we(e,((e,n,r)=>({channels:{text:{value:wn(r,t)?.value}}})))}const hu={ariaLabel:"delaunay link",fill:"none",stroke:"currentColor",strokeMiterlimit:1},du={ariaLabel:"delaunay mesh",fill:null,stroke:"currentColor",strokeOpacity:.2},pu={ariaLabel:"hull",fill:"none",stroke:"currentColor",strokeWidth:1.5,strokeMiterlimit:1},mu={ariaLabel:"voronoi",fill:"none",stroke:"currentColor",strokeMiterlimit:1},yu={ariaLabel:"voronoi mesh",fill:null,stroke:"currentColor",strokeOpacity:.2};class gu extends Io{constructor(t,e={}){const{x:n,y:r,z:o,curve:i,tension:a}=e;super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:o,optional:!0}},e,hu),this.curve=Ll(i,a),Zo(this,e)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,z:u}=r,{curve:f}=this,[h,d]=wo(this,o),p=s?t=>s[t]:et(h),m=c?t=>c[t]:et(d),y=this;function g(t){let n=-1;const o=[],a={};for(const t in r)a[t]=[];const l=[],s=[],c=[],u=[];function h(e,i){e=t[e],i=t[i],o.push(++n),l[n]=p(e),c[n]=m(e),s[n]=p(i),u[n]=m(i);for(const t in r)a[t].push(r[t][i])}const{halfedges:d,hull:g,triangles:v}=e.Delaunay.from(t,p,m);for(let t=0;tt&&h(v[t],v[e])}for(let t=0;t{const n=e.pathRound(),r=f(n);return r.lineStart(),r.point(l[t],c[t]),r.point(s[t],u[t]),r.lineEnd(),n})).call(io,y,a).call(oi,y,a,i)}return kn("svg:g",i).call(co,this,o,i).call(po,this,{x:s&&a,y:c&&l}).call(u?n=>n.selectAll().data(e.group(t,(t=>u[t])).values()).enter().append("g").each(g):e=>e.datum(t).each(g)).node()}}class vu extends Io{constructor(t,e={},n,r=(({z:t})=>t)){const{x:o,y:i}=e;super(t,{x:{value:o,scale:"x",optional:!0},y:{value:i,scale:"y",optional:!0},z:{value:r(e),optional:!0}},e,n)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,z:u}=r,[f,h]=wo(this,o),d=s?t=>s[t]:et(f),p=c?t=>c[t]:et(h),m=this;function y(t){const n=e.Delaunay.from(t,d,p);e.select(this).append("path").datum(t[0]).call(uo,m).attr("d",m._render(n,o)).call(io,m,r)}return kn("svg:g",i).call(co,this,o,i).call(po,this,{x:s&&a,y:c&&l}).call(u?n=>n.selectAll().data(e.group(t,(t=>u[t])).values()).enter().append("g").each(y):e=>e.datum(t).each(y)).node()}}class xu extends vu{constructor(t,e={}){super(t,e,du),this.fill="none"}_render(t){return t.render()}}class wu extends vu{constructor(t,e={}){super(t,e,pu,Mt)}_render(t){return t.renderHull()}}class bu extends Io{constructor(t,e={}){const{x:n,y:r,z:o}=e;super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:o,optional:!0}},e,mu)}render(t,n,r,o,i){const{x:a,y:l}=n,{x:s,y:c,z:u}=r,[f,h]=wo(this,o),d=s?t=>s[t]:et(f),p=c?t=>c[t]:et(h),m=this;function y(t){const n=$u(e.Delaunay.from(t,d,p),o);e.select(this).selectAll().data(t).enter().append("path").call(uo,m).attr("d",((t,e)=>n.renderCell(e))).call(io,m,r)}return kn("svg:g",i).call(co,this,o,i).call(po,this,{x:s&&a,y:c&&l}).call(u?n=>n.selectAll().data(e.group(t,(t=>u[t])).values()).enter().append("g").each(y):e=>e.datum(t).each(y)).node()}}class ku extends vu{constructor(t,e){super(t,e,yu),this.fill="none"}_render(t,e){return $u(t,e).render()}}function $u(t,e){const{width:n,height:r,marginTop:o,marginRight:i,marginBottom:a,marginLeft:l}=e;return t.voronoi([l,o,n-i,r-a])}function Mu(t,e,{x:n,y:r,...o}={}){return[n,r]=$t(n,r),new t(e,{...o,x:n,y:r})}const Lu={ariaLabel:"density",fill:"none",stroke:"currentColor",strokeMiterlimit:1};class Au extends Io{constructor(t,{x:n,y:r,z:o,weight:i,fill:a,stroke:l,...s}={}){const c=zu(a)&&(a="currentColor",!0),u=zu(l)&&(l="currentColor",!0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},z:{value:Mt({z:o,fill:a,stroke:l}),optional:!0},weight:{value:i,optional:!0}},function(t,n,r){const o=100;let{bandwidth:i,thresholds:a}=t;return i=void 0===i?20:+i,a=void 0===a?20:"function"==typeof a?.[Symbol.iterator]?rt(a):+a,we(t,(function(t,l,s,c,u,f){const h=s.weight?rt(s.weight.value):null,d=s.z?.value,{z:p}=this,[m,y]=wo(this,u),{width:g,height:v}=u,{x:x,y:w}=Pn(s,c,f),b=Object.fromEntries(Object.entries(s).filter((([t])=>!Su.has(t))).map((([t,e])=>[t,{...e,value:[]}]))),k=n&&[],$=r&&[],M=e.contourDensity().x(x?t=>x[t]:m).y(w?t=>w[t]:y).weight(h?t=>h[t]:1).size([g,v]).bandwidth(i),L=[];for(const t of l){const e=[];L.push(e);for(const n of d?lo(t,d,p):[t]){const t=M.contours(n);e.push([n,t])}}let A=a;if(!(A instanceof W)){let t=0;for(const e of L)for(const[,n]of e){const e=n.max;e>t&&(t=e)}A=Float64Array.from({length:a-1},((e,n)=>t*o*(n+1)/a))}const S=[],z=[];for(const t of L){const e=[];S.push(e);for(const[n,r]of t)for(const t of A){e.push(z.length),z.push(r(t/o)),k&&k.push(t),$&&$.push(t);for(const t in b)b[t].value.push(s[t].value[n[0]])}}return k&&k.push(0),$&&$.push(0),{data:t,facets:S,channels:{...b,...k&&{fill:{value:k,scale:"color"}},...$&&{stroke:{value:$,scale:"color"}},contours:{value:z}}}}))}({...s,fill:a,stroke:l},c,u),Lu),c&&(this.fill=void 0),u&&(this.stroke=void 0),this.z=o}filter(t){return t}render(t,n,r,o,i){const{contours:a}=r,l=e.geoPath();return kn("svg:g",i).call(co,this,o,i).call(po,this,{}).call((e=>e.selectAll().data(t).enter().append("path").call(uo,this).call(io,this,r).attr("d",(t=>l(a[t]))))).node()}}const Su=new Set(["x","y","z","weight"]);function zu(t){return/^density$/i.test(t)}function Ou(t,e,n){return void 0===e&&void 0===n?e=n=Eu(t):void 0===e?(n=Eu(n),e=void 0===t?n:Eu(t)):void 0===n?(e=Eu(e),n=void 0===t?e:Eu(t)):(e=Eu(e),n=Eu(n)),[e,n]}function Eu(t){let e;const{value:n,label:r=Tt(n)}=qt(t);return{transform:t=>e||(e=F(t,n)),label:r}}function Ru(t){return(e,n,r,o,i,a)=>{const{x1:l,x2:s}=r,{height:c}=o,u=new Float32Array(l.length),f=new Float32Array(s.length);(t===zr(n.y)<0?u:f).fill(c);const h=a(e,n,{...r,x2:l,y2:f},o,i),d=a(e,n,{...r,x1:s,y1:u},o,i),p=h.querySelector("g")??h,m=d.querySelector("g")??d;for(let t=0;p.firstChild;t+=2){const e=eo(),n=kn("svg:clipPath",i).attr("id",e).node();n.appendChild(p.firstChild),m.childNodes[t].setAttribute("clip-path",`url(#${e})`),m.insertBefore(n,m.childNodes[t])}return d}}const Cu={ariaLabel:"geo",fill:"none",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Tu extends Io{constructor(t,e={}){const[n,r]=ct(e.r,3);super(t,{geometry:{value:e.geometry,scale:"projection"},r:{value:n,scale:"r",filter:l,optional:!0}},Fs(e),Cu),this.r=r}render(t,n,r,o,i){const{geometry:a,r:l}=r,c=e.geoPath(i.projection??function({x:t,y:n}){if(t||n)return t??=t=>t,n??=t=>t,e.geoTransform({point(e,r){this.stream.point(t(e),n(r))}})}(n)),{r:u}=this;return s(u)?t=[]:void 0!==u&&c.pointRadius(u),kn("svg:g",i).call(co,this,o,i).call(po,this,n).call((e=>{e.selectAll().data(t).enter().append("path").call(uo,this).attr("d",l?t=>c.pointRadius(l[t])(a[t]):t=>c(a[t])).call(io,this,r)})).node()}}function Bu(t,{geometry:e=H,...n}={}){switch(t?.type){case"FeatureCollection":t=t.features;break;case"GeometryCollection":t=t.geometries;break;case"Feature":case"LineString":case"MultiLineString":case"MultiPoint":case"MultiPolygon":case"Point":case"Polygon":case"Sphere":t=[t]}return new Tu(t,{geometry:e,...n})}const Nu=.5,Iu=0;function Pu(t,e,n,r,o){const i=o*(1.5/he),a=new Map;for(const l of e){let e=n[l],s=r[l];if(isNaN(e)||isNaN(s))continue;let c=Math.round(s=(s-Iu)/i),u=Math.round(e=(e-Nu)/o-(1&c)/2),f=s-c;if(3*Math.abs(f)>1){let t=e-u,n=u+(eo*o+i*i&&(u=n+(1&c?1:-1)/2,c=r)}const h=`${u},${c}`;let d=a.get(h);void 0===d&&(d={index:[],extent:{data:t,x:(u+(1&c)/2)*o+Nu,y:c*i+Iu}},a.set(h,d)),d.index.push(l)}return a.values()}const Wu={ariaLabel:"hexgrid",fill:"none",stroke:"currentColor",strokeOpacity:.1};class ju extends Io{constructor({binWidth:t=20,clip:e=!0,...n}={}){super(_,void 0,{clip:e,...n},Wu),this.binWidth=Q(t)}render(t,e,n,r,o){const{binWidth:i}=this,{marginTop:a,marginRight:l,marginBottom:s,marginLeft:c,width:u,height:f}=r,h=c-Nu,d=u-l-Nu,p=a-Iu,m=f-s-Iu,y=i/2,g=y*de,v=g/2,x=2*y,w=1.5*g,b=Math.floor(h/x),k=Math.ceil(d/x),$=Math.floor((p+v)/w),M=Math.ceil((m-v)/w)+1,L=`m0,${qu(-g)}l${qu(y)},${qu(v)}v${qu(g)}l${qu(-y)},${qu(v)}`;let A=L;for(let t=$;tt.append("path").call(uo,this).call(io,this,n).attr("d",A))).node()}}function qu(t){return Math.round(1e3*t)/1e3}const Fu={ariaLabel:"image",fill:null,stroke:null};class Du extends Io{constructor(t,e={}){let{x:n,y:r,r:o,width:i,height:a,rotate:s,src:c,preserveAspectRatio:u,crossOrigin:f,frameAnchor:h,imageRendering:d}=e;null==o&&(o=void 0),void 0===o&&void 0===i&&void 0===a?i=a=16:void 0===i&&void 0!==a?i=a:void 0===a&&void 0!==i&&(a=i);const[p,m]="string"==typeof(y=c)&&(function(t){return/^\.*\//.test(t)}(y)||function(t){return/^(blob|data|file|http|https):/i.test(t)}(y))?[void 0,y]:[y,void 0];var y;const[g,v]=ct(o),[x,w]=ct(i,void 0!==v?2*v:void 0),[b,k]=ct(a,void 0!==v?2*v:void 0),[$,M]=ct(s,0);super(t,{x:{value:n,scale:"x",optional:!0},y:{value:r,scale:"y",optional:!0},r:{value:g,scale:"r",filter:l,optional:!0},width:{value:x,filter:l,optional:!0},height:{value:b,filter:l,optional:!0},rotate:{value:$,optional:!0},src:{value:p,optional:!0}},Fs(e),Fu),this.src=m,this.width=w,this.rotate=M,this.height=k,this.r=v,this.preserveAspectRatio=mo(u,"xMidYMid"),this.crossOrigin=Z(f),this.frameAnchor=ee(h),this.imageRendering=mo(d,"auto")}render(t,e,n,r,o){const{x:i,y:a}=e,{x:l,y:s,width:c,height:u,r:f,rotate:h,src:d}=n,{r:p,width:m,height:y,rotate:g}=this,[v,x]=wo(this,r);return kn("svg:g",o).call(co,this,r,o).call(po,this,{x:l&&i,y:s&&a}).call((e=>e.selectAll().data(t).enter().append("image").call(uo,this).attr("x",Yu(l,c,f,v,m,p)).attr("y",Yu(s,u,f,x,y,p)).attr("width",c?t=>c[t]:void 0!==m?m:f?t=>2*f[t]:2*p).attr("height",u?t=>u[t]:void 0!==y?y:f?t=>2*f[t]:2*p).attr("transform",h?t=>`rotate(${h[t]})`:g?`rotate(${g})`:null).attr("transform-origin",h||g?Li`${l?t=>l[t]:v}px ${s?t=>s[t]:x}px`:null).call(ho,"href",d?t=>d[t]:this.src).call(ho,"preserveAspectRatio",this.preserveAspectRatio).call(ho,"crossorigin",this.crossOrigin).call(ho,"image-rendering",this.imageRendering).call(ho,"clip-path",f?t=>`circle(${f[t]}px)`:void 0!==p?`circle(${p}px)`:null).call(io,this,n))).node()}}function Yu(t,e,n,r,o,i){return e&&t?n=>t[n]-e[n]/2:e?t=>r-e[t]/2:t&&void 0!==o?e=>t[e]-o/2:void 0!==o?r-o/2:n&&t?e=>t[e]-n[e]:n?t=>r-n[t]:t?e=>t[e]-i:r-i}function _u(t,e,n){var r=0===t||1===t?0:Math.exp(Xu(e+n)-Xu(e)-Xu(n)+e*Math.log(t)+n*Math.log(1-t));return!(t<0||t>1)&&(t<(e+1)/(e+n+2)?r*Gu(t,e,n)/e:1-r*Gu(1-t,n,e)/n)}function Gu(t,e,n){var r,o,i,a,l=1e-30,s=1,c=e+n,u=e+1,f=e-1,h=1,d=1-c*t/u;for(Math.abs(d)=1)return 1;for(e>=1&&n>=1?(i=t<.5?t:1-t,s=(2.30753+.27061*(a=Math.sqrt(-2*Math.log(i))))/(1+a*(.99229+.04481*a))-a,t<.5&&(s=-s),c=(s*s-3)/6,u=2/(1/(2*e-1)+1/(2*n-1)),f=s*Math.sqrt(c+u)/u-(1/(2*n-1)-1/(2*e-1))*(c+5/6-2/(3*u)),s=e/(e+n*Math.exp(2*f))):(r=Math.log(e/(e+n)),o=Math.log(n/(e+n)),s=t<(a=Math.exp(e*r)/e)/(f=a+(l=Math.exp(n*o)/n))?Math.pow(e*f*t,1/e):1-Math.pow(n*f*(1-t),1/n)),h=-Xu(e)-Xu(n)+Xu(e+n);m<10;m++){if(0===s||1===s)return s;if((s-=a=(l=(_u(s,e,n)-t)/(a=Math.exp(d*Math.log(s)+p*Math.log(1-s)+h)))/(1-.5*Math.min(1,l*(d/s-p/(1-s)))))<=0&&(s=.5*(s+a)),s>=1&&(s=.5*(s+a+1)),Math.abs(a)<1e-8*s&&m>0)break}return s}(2*Math.min(t,1-t),.5*e,.5);return n=Math.sqrt(e*(1-n)/n),t>.5?n:-n}const Uu={ariaLabel:"linear-regression",fill:"currentColor",fillOpacity:.1,stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"round",strokeLinejoin:"round",strokeMiterlimit:1};class Vu extends Io{constructor(t,e={}){const{x:n,y:r,z:o,ci:i=.95,precision:a=4}=e;if(super(t,{x:{value:n,scale:"x"},y:{value:r,scale:"y"},z:{value:Mt(e),optional:!0}},e,Uu),this.z=o,this.ci=+i,this.precision=+a,!(0<=this.ci&&this.ci<1))throw new Error(`invalid ci; not in [0, 1): ${i}`);if(!(this.precision>0))throw new Error(`invalid precision: ${a}`)}render(t,e,n,r,o){const{x:i,y:a,z:l}=n,{ci:s}=this;return kn("svg:g",o).call(co,this,r,o).call(po,this,e).call((e=>e.selectAll().data(l?lo(t,l,this.z):[t]).enter().call((t=>t.append("path").attr("fill","none").call(uo,this).call(ao,this,{...n,fill:null,fillOpacity:null}).attr("d",(t=>this._renderLine(t,i,a))).call(s&&!Kt(this.fill)?t=>t.select(Zu).attr("stroke","none").call(uo,this).call(ao,this,{...n,stroke:null,strokeOpacity:null,strokeWidth:null}).attr("d",(t=>this._renderBand(t,i,a))):()=>{}))))).node()}}function Zu(){return this.parentNode.insertBefore(this.ownerDocument.createElementNS(e.namespaces.svg,"path"),this)}class Qu extends Vu{constructor(t,e){super(t,e)}_renderBand(t,n,r){const{ci:o,precision:i}=this,[a,l]=e.extent(t,(t=>r[t])),s=Ku(t,r,n),c=tf(t,r,n,(1-o)/2,s);return e.area().y((t=>t)).x0((t=>c(t,-1))).x1((t=>c(t,1)))(e.range(a,l-i/2,i).concat(l))}_renderLine(t,n,r){const[o,i]=e.extent(t,(t=>r[t])),a=Ku(t,r,n);return`M${a(o)},${o}L${a(i)},${i}`}}class Ju extends Vu{constructor(t,e){super(t,e)}_renderBand(t,n,r){const{ci:o,precision:i}=this,[a,l]=e.extent(t,(t=>n[t])),s=Ku(t,n,r),c=tf(t,n,r,(1-o)/2,s);return e.area().x((t=>t)).y0((t=>c(t,-1))).y1((t=>c(t,1)))(e.range(a,l-i/2,i).concat(l))}_renderLine(t,n,r){const[o,i]=e.extent(t,(t=>n[t])),a=Ku(t,n,r);return`M${o},${a(o)}L${i},${a(i)}`}}function Ku(t,e,n){let r=0,o=0,i=0,a=0;for(const l of t){const t=e[l],s=n[l];r+=t,o+=s,i+=t*s,a+=t*t}const l=t.length,s=(l*i-r*o)/(l*a-r*r),c=(o-s*r)/l;return t=>s*t+c}function tf(t,n,r,o,i){const a=e.sum(t,(t=>n[t]))/t.length;let l=0,s=0;for(const e of t)l+=(n[e]-a)**2,s+=(r[e]-i(n[e]))**2;const c=Math.sqrt(s/(t.length-2)),u=Hu(o,t.length-2);return(e,n)=>{const r=i(e),o=c*Math.sqrt(1/t.length+(e-a)**2/l);return r+n*u*o}}function ef({path:t=H,delimiter:n,frameAnchor:r,treeLayout:o=e.tree,treeSort:i,treeSeparation:a,treeAnchor:l,treeFilter:s,...c}={}){l=rf(l),i=lf(i),null!=s&&(s=df(s)),void 0===r&&(r=l.frameAnchor);const u=cf(n),f=Af(c,df),[h,d]=Rt(),[p,m]=Rt();return{x:h,y:p,frameAnchor:r,...xe(c,((n,r)=>{const c=u(F(n,t)),h=d([]),p=m([]);let y=-1;const g=[],v=[],x=e.stratify().path((t=>c[t])),w=o();w.nodeSize&&w.nodeSize([1,1]),w.separation&&void 0!==a&&w.separation(a??U);for(const t of f)t[Lf]=t[$f]([]);for(const t of r){const e=[],r=x(t.filter((t=>null!=c[t]))).each((t=>t.data=n[t.data]));null!=i&&r.sort(i),w(r);for(const t of r.descendants())if(null==s||s(t)){e.push(++y),g[y]=t.data,l.position(t,y,h,p);for(const e of f)e[Lf][y]=e[Mf](t)}v.push(e)}return{data:g,facets:v}})),...Object.fromEntries(f)}}function nf({path:t=H,delimiter:n,curve:r="bump-x",stroke:o="#555",strokeWidth:i=1.5,strokeOpacity:a=.5,treeLayout:l=e.tree,treeSort:s,treeSeparation:c,treeAnchor:u,treeFilter:f,...h}={}){u=rf(u),s=lf(s),null!=f&&(f=pf(f)),h={curve:r,stroke:o,strokeWidth:i,strokeOpacity:a,...h};const d=cf(n),p=Af(h,pf),[m,y]=Rt(),[g,v]=Rt(),[x,w]=Rt(),[b,k]=Rt();return{x1:m,x2:g,y1:x,y2:b,...xe(h,((n,r)=>{const o=d(F(n,t)),i=y([]),a=v([]),h=w([]),m=k([]);let g=-1;const x=[],b=[],$=e.stratify().path((t=>o[t])),M=l();M.nodeSize&&M.nodeSize([1,1]),M.separation&&void 0!==c&&M.separation(c??U);for(const t of p)t[Lf]=t[$f]([]);for(const t of r){const e=[],r=$(t.filter((t=>null!=o[t]))).each((t=>t.data=n[t.data]));null!=s&&r.sort(s),M(r);for(const{source:t,target:n}of r.links())if(null==f||f(n,t)){e.push(++g),x[g]=n.data,u.position(t,g,i,h),u.position(n,g,a,m);for(const e of p)e[Lf][g]=e[Mf](n,t)}b.push(e)}return{data:x,facets:b}})),...Object.fromEntries(p)}}function rf(t="left"){switch(`${t}`.trim().toLowerCase()){case"left":return of;case"right":return af}throw new Error(`invalid tree anchor: ${t}`)}const of={frameAnchor:"left",dx:6,position({x:t,y:e},n,r,o){r[n]=e,o[n]=-t}},af={frameAnchor:"right",dx:-6,position({x:t,y:e},n,r,o){r[n]=-e,o[n]=-t}};function lf(t){return null==t||"function"==typeof t?t:`${t}`.trim().toLowerCase().startsWith("node:")?sf(df(t)):sf(function(t){return e=>e.data?.[t]}(t))}function sf(t){return(e,n)=>r(t(e),t(n))}function cf(t="/"){if("/"===(t=`${t}`))return t=>t;if(1!==t.length)throw new Error("delimiter must be exactly one character");const e=t.charCodeAt(0);return t=>t.map((t=>function(t,e){if(e===uf)throw new Error("delimiter cannot be backslash");let n=!1;for(let r=0,o=t.length;r0&&!kf(t,e););return function(t){let e=!1;for(let n=0,r=t.length;nnull==n?void 0:t(n)}function kf(t,e){if("/"===t[e]){let n=0;for(;e>0&&"\\"===t[--e];)++n;if(!(1&n))return!0}return!1}const $f=2,Mf=3,Lf=4;function Af(t,e){const n=[];for(const r in t){const o=t[r],i=e(o);void 0!==i&&n.push([r,...Rt(o),i])}return n}function Sf(t,{fill:n,stroke:r,strokeWidth:o,strokeOpacity:i,strokeLinejoin:a,strokeLinecap:l,strokeMiterlimit:s,strokeDasharray:c,strokeDashoffset:u,marker:f,markerStart:h=f,markerEnd:d=f,dot:p=Jt(h)&&Jt(d),text:m="node:name",textStroke:y="var(--plot-background)",title:g="node:path",dx:v,dy:x,textAnchor:w,treeLayout:b=e.tree,textLayout:k=(b===e.tree||b===e.cluster?"mirrored":"normal"),tip:$,...M}={}){if(void 0===v&&(v=rf(M.treeAnchor).dx),void 0!==w)throw new Error("textAnchor is not a configurable tree option");function L(e){return Ri(t,ef({treeLayout:b,text:m,fill:void 0===n?"currentColor":n,stroke:y,dx:v,dy:x,title:g,...e,...M}))}return k=ft(k,"textLayout",["mirrored","normal"]),Po(As(t,nf({treeLayout:b,markerStart:h,markerEnd:d,stroke:void 0!==r?r:void 0===n?"node:internal":n,strokeWidth:o,strokeOpacity:i,strokeLinejoin:a,strokeLinecap:l,strokeMiterlimit:s,strokeDasharray:c,strokeDashoffset:u,...M})),p?Ys(t,ef({treeLayout:b,fill:void 0===n?"node:internal":n,title:g,tip:$,...M})):null,null!=m?"mirrored"===k?[L({textAnchor:"start",treeFilter:"node:external"}),L({textAnchor:"end",treeFilter:"node:internal",dx:-v})]:L():null)}function zf(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Of(t,e,n,r,o){for(var i=o+1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)>=0?(i=a,o=a-1):r=a+1}return i}function Ef(t,e,n,r,o){for(var i=o+1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)>0?(i=a,o=a-1):r=a+1}return i}function Rf(t,e,n,r,o){for(var i=r-1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)<0?(i=a,r=a+1):o=a-1}return i}function Cf(t,e,n,r,o){for(var i=r-1;r<=o;){var a=r+o>>>1,l=t[a];(void 0!==n?n(l,e):l-e)<=0?(i=a,r=a+1):o=a-1}return i}function Tf(t,e,n,r,o){for(;r<=o;){var i=r+o>>>1,a=t[i],l=void 0!==n?n(a,e):a-e;if(0===l)return i;l<=0?r=i+1:o=i-1}return-1}function Bf(t,e,n,r,o,i){return"function"==typeof n?i(t,e,n,void 0===r?0:0|r,void 0===o?t.length-1:0|o):i(t,e,void 0,void 0===n?0:0|n,void 0===r?t.length-1:0|r)}var Nf={ge:function(t,e,n,r,o){return Bf(t,e,n,r,o,Of)},gt:function(t,e,n,r,o){return Bf(t,e,n,r,o,Ef)},lt:function(t,e,n,r,o){return Bf(t,e,n,r,o,Rf)},le:function(t,e,n,r,o){return Bf(t,e,n,r,o,Cf)},eq:function(t,e,n,r,o){return Bf(t,e,n,r,o,Tf)}},If=function(t){if(!t||0===t.length)return new Zf(null);return new Zf(Vf(t))};function Pf(t,e,n,r,o){this.mid=t,this.left=e,this.right=n,this.leftPoints=r,this.rightPoints=o,this.count=(e?e.count:0)+(n?n.count:0)+r.length}var Wf=Pf.prototype;function jf(t,e){t.mid=e.mid,t.left=e.left,t.right=e.right,t.leftPoints=e.leftPoints,t.rightPoints=e.rightPoints,t.count=e.count}function qf(t,e){var n=Vf(e);t.mid=n.mid,t.left=n.left,t.right=n.right,t.leftPoints=n.leftPoints,t.rightPoints=n.rightPoints,t.count=n.count}function Ff(t,e){var n=t.intervals([]);n.push(e),qf(t,n)}function Df(t,e){var n=t.intervals([]),r=n.indexOf(e);return r<0?0:(n.splice(r,1),qf(t,n),1)}function Yf(t,e,n){for(var r=0;r=0&&t[r][1]>=e;--r){var o=n(t[r]);if(o)return o}}function Gf(t,e){for(var n=0;n>1],o=[],i=[],a=[];for(n=0;n3*(e+1)?Ff(this,t):this.left.insert(t):this.left=Vf([t]);else if(t[0]>this.mid)this.right?4*(this.right.count+1)>3*(e+1)?Ff(this,t):this.right.insert(t):this.right=Vf([t]);else{var n=Nf.ge(this.leftPoints,t,Hf),r=Nf.ge(this.rightPoints,t,Uf);this.leftPoints.splice(n,0,t),this.rightPoints.splice(r,0,t)}},Wf.remove=function(t){var e=this.count-this.leftPoints;if(t[1]3*(e-1)?Df(this,t):2===(i=this.left.remove(t))?(this.left=null,this.count-=1,1):(1===i&&(this.count-=1),i):0;if(t[0]>this.mid)return this.right?4*(this.left?this.left.count:0)>3*(e-1)?Df(this,t):2===(i=this.right.remove(t))?(this.right=null,this.count-=1,1):(1===i&&(this.count-=1),i):0;if(1===this.count)return this.leftPoints[0]===t?2:0;if(1===this.leftPoints.length&&this.leftPoints[0]===t){if(this.left&&this.right){for(var n=this,r=this.left;r.right;)n=r,r=r.right;if(n===this)r.right=this.right;else{var o=this.left,i=this.right;n.count-=r.count,n.right=r.left,r.left=o,r.right=i}jf(this,r),this.count=(this.left?this.left.count:0)+(this.right?this.right.count:0)+this.leftPoints.length}else this.left?jf(this,this.left):jf(this,this.right);return 1}for(o=Nf.ge(this.leftPoints,t,Hf);othis.mid){var n;if(this.right)if(n=this.right.queryPoint(t,e))return n;return _f(this.rightPoints,t,e)}return Gf(this.leftPoints,e)},Wf.queryInterval=function(t,e,n){var r;if(tthis.mid&&this.right&&(r=this.right.queryInterval(t,e,n)))return r;return ethis.mid?_f(this.rightPoints,t,n):Gf(this.leftPoints,n)};var Qf=Zf.prototype;Qf.insert=function(t){this.root?this.root.insert(t):this.root=new Pf(t[0],null,null,[t],[t])},Qf.remove=function(t){if(this.root){var e=this.root.remove(t);return 2===e&&(this.root=null),0!==e}return!1},Qf.queryPoint=function(t,e){if(this.root)return this.root.queryPoint(t,e)},Qf.queryInterval=function(t,e,n){if(t<=e&&this.root)return this.root.queryInterval(t,e,n)},Object.defineProperty(Qf,"count",{get:function(){return this.root?this.root.count:0}}),Object.defineProperty(Qf,"intervals",{get:function(){return this.root?this.root.intervals([]):[]}});var Jf=zf(If);const Kf=({marginLeft:t})=>[1,t],th=({width:t,marginRight:e})=>[-1,t-e],eh=({width:t,marginLeft:e,marginRight:n})=>[0,(e+t-n)/2],nh=({marginTop:t})=>[1,t],rh=({height:t,marginBottom:e})=>[-1,t-e],oh=({height:t,marginTop:e,marginBottom:n})=>[0,(e+t-n)/2];function ih(t){return"string"==typeof t?{anchor:t}:t}function ah(t){const{anchor:e,padding:n,...r}=t,{r:o}=r;return[{anchor:e,padding:n,r:o},r]}function lh(t,e,n,r,o,i){if(null!=o&&"number"!=typeof o){let{channels:t,sort:e,reverse:n}=i;t=ne(t),void 0===t?.r&&(i={...i,channels:{...t,r:{value:o,scale:"r"}}}),void 0===e&&void 0===n&&(i.sort={channel:"-r"})}return we(i,(function(i,s,c,u,f,h){let{[e]:d,r:p}=c;if(!c[e])throw new Error(`missing channel: ${e}`);({[e]:d}=Pn(c,u,h));const m=p?void 0:void 0!==o?Q(o):void 0!==this.r?this.r:3;p&&(p=F(p.value,u[p.scale]||H,Float64Array));let[y,g]=n(f);const v=y?ch:sh,x=new Float64Array(d.length),w=p?t=>p[t]:()=>m;for(let t of s){const e=Jf();t=t.filter(p?t=>a(d[t])&&l(p[t]):t=>a(d[t]));const n=new Float64Array(2*t.length+2);for(const o of t){const t=w(o),i=y?t+r:0,a=d[o]-t,l=d[o]+t;let s=2;e.queryInterval(a-r,l+r,(([,,t])=>{const e=x[t]-i,a=d[o]-d[t],l=r+(p?p[o]+p[t]:2*m),c=Math.sqrt(l*l-a*a);n[s++]=e-c,n[s++]=e+c}));let c=n.slice(0,s);y&&(c=c.filter((t=>t>=0)));t:for(const t of c.sort(v)){for(let e=0;et(e,(t=>n[t]))))}const dh={mapIndex(t,n,r){const[o,i]=e.extent(t,(t=>n[t])),a=i-o;for(const e of t)r[e]=null===n[e]?NaN:(n[e]-o)/a}},ph=fh(((t,e)=>{for(let r=0;r{for(let r=t.length-1;r>=0;--r){const o=e[t[r]];if(n(o))return o}})),yh={mapIndex(t,n,r){const o=e.mean(t,(t=>n[t])),i=e.deviation(t,(t=>n[t]));for(const e of t)r[e]=null===n[e]?NaN:i?(n[e]-o)/i:0}},gh=hh(e.max),vh=hh(e.mean),xh=hh(e.median),wh=hh(e.min),bh=hh(e.sum);function kh(t){if("function"==typeof t)return t;switch(`${t}`.toLowerCase()){case"min":return Sh;case"max":return zh}throw new Error(`unknown selector: ${t}`)}function $h(t){return Oh(null,Lh,t)}function Mh(t){return Oh(null,Ah,t)}function*Lh(t){yield t[0]}function*Ah(t){yield t[t.length-1]}function*Sh(t,n){yield e.least(t,(t=>n[t]))}function*zh(t,n){yield e.greatest(t,(t=>n[t]))}function Oh(t,n,r){if(null!=t){if(null==r[t])throw new Error(`missing channel: ${t}`);t=r[t]}const o=Mt(r);return xe(r,((r,i)=>{const a=F(r,o),l=F(r,t),s=[];for(const t of i){const r=[];for(const o of a?e.group(t,(t=>a[t])).values():[t])for(const t of n(o,l))r.push(t);s.push(r)}return{data:r,facets:s}}))}t.Area=ws,t.Arrow=Os,t.BarX=Ts,t.BarY=Bs,t.Cell=Ws,t.Contour=ou,t.Density=Au,t.Dot=Ds,t.Frame=Ha,t.Geo=Tu,t.Hexgrid=ju,t.Image=Du,t.Line=Gs,t.Link=Ls,t.Mark=Io,t.Raster=Gc,t.Rect=Zs,t.RuleX=wi,t.RuleY=bi,t.Text=zi,t.TickX=Cc,t.TickY=Tc,t.Tip=Qa,t.Vector=ra,t.area=bs,t.areaX=ks,t.areaY=$s,t.arrow=function(t,{x:e,x1:n,x2:r,y:o,y1:i,y2:a,...l}={}){return[n,r]=Ss(e,n,r),[i,a]=Ss(o,i,a),new Os(t,{...l,x1:n,x2:r,y1:i,y2:a})},t.auto=function(t,e){const n=tc(t,e),{fx:r,fy:o,x:{zero:i},y:{zero:a},markOptions:l,transformOptions:s,colorMode:c}=n,u=lc[n.markImpl],f=lc[n.transformImpl],h=null!=r||null!=o?Ua({strokeOpacity:.1}):null,d=[i?ki([0]):null,a?$i([0]):null],p=u(t,f?f(s,l):l);return"stroke"===c?Po(h,d,p):Po(h,p,d)},t.autoSpec=tc,t.axisFx=ya,t.axisFy=pa,t.axisX=ma,t.axisY=da,t.barX=Ns,t.barY=Is,t.bin=El,t.binX=zl,t.binY=Ol,t.bollinger=Oc,t.bollingerX=function(t,{x:e=H,y:n,k:r=zc.k,color:o=zc.color,opacity:i=zc.opacity,fill:a=o,fillOpacity:l=i,stroke:s=o,strokeOpacity:c,strokeWidth:u,...f}={}){return Po(Jt(a)?null:ks(t,fc({x1:Oc({k:-r,...f}),x2:Oc({k:r,...f})},{x1:e,x2:e,y:n,fill:a,fillOpacity:l,...f})),Jt(s)?null:Hs(t,fc({x:Oc(f)},{x:e,y:n,stroke:s,strokeOpacity:c,strokeWidth:u,...f})))},t.bollingerY=function(t,{x:e,y:n=H,k:r=zc.k,color:o=zc.color,opacity:i=zc.opacity,fill:a=o,fillOpacity:l=i,stroke:s=o,strokeOpacity:c,strokeWidth:u,...f}={}){return Po(Jt(a)?null:$s(t,fc({y1:Oc({k:-r,...f}),y2:Oc({k:r,...f})},{x:e,y1:n,y2:n,fill:a,fillOpacity:l,...f})),Jt(s)?null:Us(t,fc({y:Oc(f)},{x:e,y:n,stroke:s,strokeOpacity:c,strokeWidth:u,...f})))},t.boxX=function(t,{x:e=H,y:n=null,fill:r="#ccc",fillOpacity:o,stroke:i="currentColor",strokeOpacity:a,strokeWidth:l=2,sort:s,...c}={}){const u=null!=n?Ce:Ee;return Po($i(t,u({x1:Pc,x2:Wc},{x:e,y:n,stroke:i,strokeOpacity:a,...c})),Ns(t,u({x1:"p25",x2:"p75"},{x:e,y:n,fill:r,fillOpacity:o,...c})),Bc(t,u({x:"p50"},{x:e,y:n,stroke:i,strokeOpacity:a,strokeWidth:l,sort:s,...c})),Ys(t,fc({x:Ic},{x:e,y:n,z:n,stroke:i,strokeOpacity:a,...c})))},t.boxY=function(t,{y:e=H,x:n=null,fill:r="#ccc",fillOpacity:o,stroke:i="currentColor",strokeOpacity:a,strokeWidth:l=2,sort:s,...c}={}){const u=null!=n?Re:Ee;return Po(ki(t,u({y1:Pc,y2:Wc},{x:n,y:e,stroke:i,strokeOpacity:a,...c})),Is(t,u({y1:"p25",y2:"p75"},{x:n,y:e,fill:r,fillOpacity:o,...c})),Nc(t,u({y:"p50"},{x:n,y:e,stroke:i,strokeOpacity:a,strokeWidth:l,sort:s,...c})),Ys(t,fc({y:Ic},{x:n,y:e,z:n,stroke:i,strokeOpacity:a,...c})))},t.cell=js,t.cellX=function(t,{x:e=X,fill:n,stroke:r,...o}={}){return void 0===n&&void 0===st(r)[0]&&(n=H),new Ws(t,{...o,x:e,fill:n,stroke:r})},t.cellY=function(t,{y:e=X,fill:n,stroke:r,...o}={}){return void 0===n&&void 0===st(r)[0]&&(n=H),new Ws(t,{...o,y:e,fill:n,stroke:r})},t.centroid=function({geometry:t=H,...n}={}){return we({...n,x:null,y:null},((n,r,o,i,a,{projection:l})=>{const s=F(n,t),c=s.length,u=new Float64Array(c),f=new Float64Array(c),h=e.geoPath(l);for(let t=0;tn[e.find((e=>t(r[e],e,r)))]}},t.formatIsoDate=Qr,t.formatMonth=function(t="en-US",e="short"){const n=Vr(t,e);return t=>null==t||isNaN(t=+new Date(Date.UTC(2e3,+t)))?void 0:n.format(t)},t.formatWeekday=function(t="en-US",e="short"){const n=Zr(t,e);return t=>null==t||isNaN(t=+new Date(Date.UTC(2001,0,+t)))?void 0:n.format(t)},t.frame=Ua,t.geo=Bu,t.geoCentroid=function({geometry:t=H,...n}={}){let r;return{...n,x:{transform:n=>Float64Array.from(r=F(F(n,t),e.geoCentroid),(([t])=>t))},y:{transform:()=>Float64Array.from(r,(([,t])=>t))}}},t.graticule=function({strokeOpacity:t=.1,...n}={}){return Bu(e.geoGraticule10(),{strokeOpacity:t,...n})},t.gridFx=ka,t.gridFy=wa,t.gridX=ba,t.gridY=xa,t.group=Te,t.groupX=Re,t.groupY=Ce,t.groupZ=Ee,t.hexagon=function(t,e){return Ys(t,{...e,symbol:"hexagon"})},t.hexbin=function(t={fill:"count"},{binWidth:e,...n}={}){const{z:r}=n;return e=void 0===e?20:Q(e),Ne(t=De(t,n),"fill")&&(n.channels={...n.channels,fill:{value:[]}}),void 0===n.symbol&&(n.symbol="hexagon"),void 0!==n.r||Ne(t,"r")||(n.r=e/2),we(n,((n,o,i,a,l,s)=>{let{x:c,y:u,z:f,fill:h,stroke:d,symbol:p}=i;if(void 0===c)throw new Error("missing channel: x");if(void 0===u)throw new Error("missing channel: y");({x:c,y:u}=Pn(i,a,s)),f=f?f.value:F(n,r),h=h?.value,d=d?.value,p=p?.value;const m=He(t,{z:f,fill:h,stroke:d,symbol:p}),y=f&&[],g=h&&[],v=d&&[],x=p&&[],w=[],b=[],k=[];let $=-1;for(const e of t)e.initialize(n);for(const r of o){const o=[];for(const e of t)e.scope("facet",r);for(const[i,a]of je(r,m))for(const{index:r,extent:l}of Pu(n,a,c,u,e)){o.push(++$),b.push(l.x),k.push(l.y),f&&y.push(m===f?i:f[r[0]]),h&&g.push(m===h?i:h[r[0]]),d&&v.push(m===d?i:d[r[0]]),p&&x.push(m===p?i:p[r[0]]);for(const e of t)e.reduce(r,l)}w.push(o)}const M=i.x.scale,L=i.y.scale;return{data:n,facets:w,channels:{x:{value:b,source:a[M]?{value:dt(b,a[M].invert),scale:M}:null},y:{value:k,source:a[L]?{value:dt(k,a[L].invert),scale:L}:null},...f&&{z:{value:y}},...h&&{fill:{value:g,scale:"auto"}},...d&&{stroke:{value:v,scale:"auto"}},...p&&{symbol:{value:x,scale:"auto"}},...Object.fromEntries(t.map((({name:t,output:n})=>[t,{scale:"auto",label:n.label,radius:"r"===t?e/2:void 0,value:n.transform()}])))}}}))},t.hexgrid=function(t){return new ju(t)},t.hull=function(t,e){return Mu(wu,t,e)},t.identity=H,t.image=function(t,{x:e,y:n,...r}={}){return void 0===r.frameAnchor&&([e,n]=$t(e,n)),new Du(t,{...r,x:e,y:n})},t.indexOf=X,t.initializer=we,t.interpolateNearest=tu,t.interpolateNone=Zc,t.interpolatorBarycentric=Qc,t.interpolatorRandomWalk=eu,t.legend=function(t={}){for(const[e,n]of Fa){const r=t[e];if(xt(r)){const o=bn(t);let i;if("symbol"===e){const{fill:e,stroke:n=(void 0===e&&xt(t.color)?"color":void 0)}=t;i={fill:e,stroke:n}}return n(Nr(e,r,i),Da(o,r,t),(e=>xt(t[e])?Nr(e,t[e]):null))}}throw new Error("unknown legend type; no scale found")},t.line=Xs,t.lineX=Hs,t.lineY=Us,t.linearRegressionX=function(t,{y:e=X,x:n=H,stroke:r,fill:o=(Jt(r)?"currentColor":r),...i}={}){return new Qu(t,Tl({...i,x:n,y:e,fill:o,stroke:r}))},t.linearRegressionY=function(t,{x:e=X,y:n=H,stroke:r,fill:o=(Jt(r)?"currentColor":r),...i}={}){return new Ju(t,Cl({...i,x:e,y:n,fill:o,stroke:r}))},t.link=As,t.map=fc,t.mapX=cc,t.mapY=uc,t.marks=Po,t.normalize=uh,t.normalizeX=function(t,e){return 1===arguments.length&&({basis:t,...e}=t),cc(uh(t),e)},t.normalizeY=function(t,e){return 1===arguments.length&&({basis:t,...e}=t),uc(uh(t),e)},t.plot=al,t.pointer=Yo,t.pointerX=_o,t.pointerY=Go,t.raster=function(){const[t,e]=Xc("fill",...arguments);return new Gc(t,null==t||void 0!==e.fill||void 0!==e.fillOpacity?e:{...e,fill:H})},t.rect=Qs,t.rectX=Js,t.rectY=Ks,t.reverse=function({sort:t,...e}={}){return{...$e(e,Le),sort:bt(t)?t:null}},t.ruleX=ki,t.ruleY=$i,t.scale=function(t={}){let e;for(const n in t)if(fe.has(n)&&xt(t[n])){if(void 0!==e)throw new Error("ambiguous scale definition; multiple scales found");e=Xr(Nr(n,t[n]))}if(void 0===e)throw new Error("invalid scale definition; no scale found");return e},t.select=function(t,e={}){if("string"==typeof t)switch(t.toLowerCase()){case"first":return $h(e);case"last":return Mh(e)}if("function"==typeof t)return Oh(null,t,e);let n,r;for(n in t){if(void 0!==r)throw new Error("ambiguous selector; multiple inputs");r=kh(t[n])}if(void 0===r)throw new Error(`invalid selector: ${t}`);return Oh(n,r,e)},t.selectFirst=$h,t.selectLast=Mh,t.selectMaxX=function(t){return Oh("x",zh,t)},t.selectMaxY=function(t){return Oh("y",zh,t)},t.selectMinX=function(t){return Oh("x",Sh,t)},t.selectMinY=function(t){return Oh("y",Sh,t)},t.shiftX=function(t,n){return function(t,n,r={}){let o,i=1;if("number"==typeof n)i=n,o=(t,e)=>+t+e;else{if("string"==typeof n){const t=n.startsWith("-")?-1:1;[n,i]=E(n.replace(/^[+-]/,"")),i*=t}n=Pt(n),o=(t,e)=>n.offset(t,e)}const a=`${t}2`,l=fc({[`${t}1`]:t=>t.map((t=>o(t,i))),[a]:t=>t},r),s=l[a].transform;return l[a].transform=()=>{const t=s(),[n,r]=e.extent(t);return t.domain=i<0?[n,o(r,i)]:[o(n,i),r],t},l}("x",t,n)},t.shuffle=function({seed:t,sort:n,...r}={}){return{...$e(r,Oe(null==t?Math.random:e.randomLcg(t))),sort:bt(n)?n:null}},t.sort=Ae,t.sphere=function({strokeWidth:t=1.5,...e}={}){return Bu({type:"Sphere"},{strokeWidth:t,...e})},t.spike=function(t,e={}){const{shape:n=ea,stroke:r=Qi.stroke,strokeWidth:o=1,fill:i=r,fillOpacity:a=.3,anchor:l="start",...s}=e;return oa(t,{...s,shape:n,stroke:r,strokeWidth:o,fill:i,fillOpacity:a,anchor:l})},t.stackX=ns,t.stackX1=function(t={},e={}){1===arguments.length&&([t,e]=as(t));const{y1:n,y:r=n,x:o}=e,[i,a,l]=ss(r,o,"y","x",t,e);return{...i,y1:n,y:a,x:l}},t.stackX2=function(t={},e={}){1===arguments.length&&([t,e]=as(t));const{y1:n,y:r=n,x:o}=e,[i,a,,l]=ss(r,o,"y","x",t,e);return{...i,y1:n,y:a,x:l}},t.stackY=rs,t.stackY1=function(t={},e={}){1===arguments.length&&([t,e]=as(t));const{x1:n,x:r=n,y:o}=e,[i,a,l]=ss(r,o,"x","y",t,e);return{...i,x1:n,x:a,y:l}},t.stackY2=function(t={},e={}){1===arguments.length&&([t,e]=as(t));const{x1:n,x:r=n,y:o}=e,[i,a,,l]=ss(r,o,"x","y",t,e);return{...i,x1:n,x:a,y:l}},t.text=Ri,t.textX=Ci,t.textY=Ti,t.tickX=Bc,t.tickY=Nc,t.tip=Ja,t.transform=xe,t.tree=Sf,t.treeLink=nf,t.treeNode=ef,t.valueof=F,t.vector=oa,t.vectorX=ia,t.vectorY=aa,t.version="0.6.14",t.voronoi=function(t,e){return Mu(bu,t,e)},t.voronoiMesh=function(t,e){return Mu(ku,t,e)},t.window=mc,t.windowX=function(t={},e){return 1===arguments.length&&(e=t),cc(mc(t),e)},t.windowY=function(t={},e){return 1===arguments.length&&(e=t),uc(mc(t),e)}})); diff --git a/ckanext/charts/assets/webassets.yml b/ckanext/charts/assets/webassets.yml index acb8625..7d67a97 100644 --- a/ckanext/charts/assets/webassets.yml +++ b/ckanext/charts/assets/webassets.yml @@ -1,23 +1,32 @@ -chartjs: +# chartjs: +# filter: rjsmin +# output: ckanext-charts/%(version)s-chartjs.js +# contents: +# - js/vendor/chartjs.min.js + +# - js/charts-chartjs.js +# - js/charts-render-chartjs.js +# extra: +# preload: +# - base/main + +plotly: filter: rjsmin - output: ckanext-charts/%(version)s-chartjs.js + output: ckanext-charts/%(version)s-plotly.js contents: - - js/vendor/chartjs.min.js - - - js/charts-chartjs.js - - js/charts-render-chartjs.js + - js/vendor/plotly.min.js + - js/charts-render-plotly.js extra: preload: - base/main -plotly: +observable: filter: rjsmin - output: ckanext-charts/%(version)s-chartjs-plotly.js + output: ckanext-charts/%(version)s-observable.js contents: - - js/vendor/plotly.min.js - - # - js/charts-form.js - - js/charts-render-plotly.js + - js/vendor/d3.min.js + - js/vendor/observable.min.js + - js/charts-render-observable.js extra: preload: - base/main diff --git a/ckanext/charts/chart_builders/__init__.py b/ckanext/charts/chart_builders/__init__.py index 629f06d..57ec10c 100644 --- a/ckanext/charts/chart_builders/__init__.py +++ b/ckanext/charts/chart_builders/__init__.py @@ -1,11 +1,15 @@ from __future__ import annotations from .base import BaseChartBuilder -from .chartjs import ChartJSBuilder from .plotly import PlotlyBuilder, PlotlyBarForm +from .observable import ObservableBuilder + + +DEFAULT_CHART_FORM = PlotlyBarForm def get_chart_engines() -> dict[str, type[BaseChartBuilder]]: return { "plotly": PlotlyBuilder, + "observable": ObservableBuilder, } diff --git a/ckanext/charts/chart_builders/base.py b/ckanext/charts/chart_builders/base.py index 0b9a674..948562e 100644 --- a/ckanext/charts/chart_builders/base.py +++ b/ckanext/charts/chart_builders/base.py @@ -1,11 +1,15 @@ from __future__ import annotations from abc import ABC, abstractmethod -from typing import Any +from typing import Any, cast import pandas as pd +import ckan.types as types +import ckan.plugins.toolkit as tk + from ckanext.charts.exception import ChartTypeNotImplementedError +from ckanext.charts import fetchers class BaseChartBuilder(ABC): @@ -28,9 +32,11 @@ def __init__( self.settings.pop("query", None) + self.settings = self.drop_view_fields(self.drop_empty_values(self.settings)) + @classmethod @abstractmethod - def get_supported_forms(cls) -> list[type[Any]]: + def get_supported_forms(cls) -> list[type[BaseChartForm]]: pass @classmethod @@ -41,18 +47,22 @@ def get_builder_for_type(cls, chart_type: str) -> type[BaseChartBuilder]: @classmethod def get_form_for_type(cls, chart_type: str) -> Any: + supported_forms = cls.get_supported_forms() + + if not chart_type: + return supported_forms[0] + for form_builder in cls.get_supported_forms(): if chart_type == form_builder.name: return form_builder raise ChartTypeNotImplementedError("Chart type not implemented") - @abstractmethod - def to_html(self) -> str: - pass - @abstractmethod def to_json(self) -> str: + """This method should return the chart data as a dumped JSON data. It + will be passed to a JS script, that will render a chart based on this + data.""" pass def drop_empty_values(self, data: dict[str, Any]) -> dict[str, Any]: @@ -66,3 +76,373 @@ def drop_empty_values(self, data: dict[str, Any]) -> dict[str, Any]: result[key] = value return result + + def drop_view_fields(self, settings: dict[str, Any]) -> dict[str, Any]: + """Drop fields not related to chart settings.""" + return { + k: v + for k, v in settings.items() + if k + not in ( + "title", + "description", + "engine", + "type", + "id", + "notes", + "package_id", + "resource_id", + "view_type", + ) + } + + +class BaseChartForm(ABC): + name = "" + + def __init__(self, resource_id: str) -> None: + try: + self.df = fetchers.DatastoreDataFetcher(resource_id).fetch_data() + except tk.ValidationError: + return + + def get_validator(self, name: str) -> types.ValueValidator: + """Get the validator by name. Replaces the tk.get_validator to get rid + of annoying typing error""" + return cast(types.ValueValidator, tk.get_validator(name)) + + @abstractmethod + def get_form_fields(self) -> list[dict[str, Any]]: + """The list for a specific chart could be defined similar to a scheming + dataset schema fields.""" + + def get_form_tabs(self) -> list[str]: + return ["General", "Structure", "Data", "Styles"] + + def get_expanded_form_fields(self): + """Expands the presets.""" + return self.expand_schema_fields( + self.drop_validators( + self.get_form_fields(), + ), + ) + + def expand_schema_fields( + self, + fields: list[dict[str, Any]], + ) -> list[dict[str, Any]]: + """Expand the schema fields presets.""" + from ckanext.scheming.plugins import _expand_schemas + + expanded_schemas = _expand_schemas({"schema": {"fields": fields}}) + + return expanded_schemas["schema"]["fields"] + + def drop_validators(self, fields: list[dict[str, Any]]) -> list[dict[str, Any]]: + """Drop the validators from the fields, because we don't need this information + to render a form.""" + for field in fields: + if "validators" not in field: + continue + + field.pop("validators") + + return fields + + def get_validation_schema(self) -> dict[str, Any]: + fields = self.get_form_fields() + + return { + field["field_name"]: field["validators"] + for field in fields + if "validators" in field + } + + def get_fields_by_tab(self, tab: str) -> list[dict[str, Any]]: + fields = self.get_expanded_form_fields() + + return [field for field in fields if field["group"] == tab] + + def column_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + return { + "field_name": "column", + "label": "Column", + "preset": "select", + "required": True, + "choices": choices, + "group": "Data", + "validators": [ + self.get_validator("ignore_empty"), + self.get_validator("unicode_safe"), + ], + } + + def title_field(self) -> dict[str, Any]: + return { + "field_name": "title", + "label": "Title", + "preset": "title", + "form_placeholder": "Chart title", + "group": "General", + "validators": [ + self.get_validator("ignore_empty"), + self.get_validator("unicode_safe"), + ], + } + + def description_field(self) -> dict[str, Any]: + return { + "field_name": "description", + "label": "Description", + "form_snippet": "markdown.html", + "form_placeholder": "Information about my view", + "group": "General", + "validators": [ + self.get_validator("ignore_empty"), + self.get_validator("unicode_safe"), + ], + } + + def engine_field(self) -> dict[str, Any]: + return { + "field_name": "engine", + "label": "Engine", + "preset": "select", + "required": True, + "choices": tk.h.get_available_chart_engines_options(), + "group": "Structure", + "validators": [ + self.get_validator("default")("plotly"), + self.get_validator("unicode_safe"), + ], + "form_attrs": { + "hx-get": tk.h.url_for("charts_view.update_form", reset_engine=1), + "hx-trigger": "change", + "hx-include": "closest form", + "hx-target": ".charts-view--form", + }, + } + + def type_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + return { + "field_name": "type", + "label": "Type", + "preset": "select", + "required": True, + "choices": choices, + "group": "Structure", + "validators": [ + self.get_validator("default")("Bar"), + self.get_validator("unicode_safe"), + ], + "form_attrs": { + "hx-get": tk.h.url_for("charts_view.update_form"), + "hx-trigger": "change", + "hx-include": "closest form", + "hx-target": ".charts-view--form", + }, + } + + def x_axis_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + return { + "field_name": "x", + "label": "X Axis", + "preset": "select", + "required": True, + "choices": choices, + "group": "Data", + "validators": [ + self.get_validator("charts_if_empty_same_as")("values"), + self.get_validator("unicode_safe"), + ], + } + + def y_axis_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + field = self.column_field(choices) + field.update( + { + "field_name": "y", + "label": "Y Axis", + "validators": [ + self.get_validator("charts_if_empty_same_as")("names"), + self.get_validator("unicode_safe"), + ], + } + ) + + return field + + def sort_x_field(self) -> dict[str, Any]: + return { + "field_name": "sort_x", + "label": "Sort X-axis", + "form_snippet": "chart_checkbox.html", + "group": "Data", + "validators": [ + self.get_validator("default")(False), + self.get_validator("boolean_validator"), + ], + } + + def sort_y_field(self) -> dict[str, Any]: + return { + "field_name": "sort_y", + "label": "Sort Y-axis", + "form_snippet": "chart_checkbox.html", + "group": "Data", + "validators": [ + self.get_validator("default")(False), + self.get_validator("boolean_validator"), + ], + } + + def query_field(self) -> dict[str, Any]: + return { + "field_name": "query", + "label": "Query", + "form_snippet": "textarea.html", + "group": "Structure", + "form_attrs": {"disabled": 5}, + "validators": [ + self.get_validator("ignore_empty"), + self.get_validator("unicode_safe"), + ], + } + + def log_x_field(self) -> dict[str, Any]: + return { + "field_name": "log_x", + "label": "Log-scale X-axis", + "form_snippet": "chart_checkbox.html", + "group": "Data", + "validators": [ + self.get_validator("default")(False), + self.get_validator("boolean_validator"), + ], + } + + def log_y_field(self) -> dict[str, Any]: + return { + "field_name": "log_y", + "label": "Log-scale Y-axis", + "form_snippet": "chart_checkbox.html", + "group": "Data", + "validators": [ + self.get_validator("default")(False), + self.get_validator("boolean_validator"), + ], + } + + def color_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + return { + "field_name": "color", + "label": "Color", + "preset": "select", + "choices": choices, + "group": "Styles", + "validators": [ + self.get_validator("ignore_empty"), + self.get_validator("unicode_safe"), + ], + } + + def animation_frame_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + return { + "field_name": "animation_frame", + "label": "Animation Frame", + "preset": "select", + "choices": choices, + "group": "Styles", + "validators": [ + self.get_validator("ignore_empty"), + self.get_validator("unicode_safe"), + ], + } + + def opacity_field(self) -> dict[str, Any]: + """The opacity field represent the opacity level of the chart.""" + return { + "field_name": "opacity", + "label": "Opacity", + "form_snippet": "chart_range.html", + "group": "Styles", + "validators": [ + self.get_validator("default")(1), + self.get_validator("float_validator"), + ], + } + + def limit_field(self) -> dict[str, Any]: + """The limit field represent an amount of rows to show in the chart.""" + return { + "field_name": "limit", + "label": "Limit", + "form_snippet": "chart_text.html", + "input_type": "number", + "validators": [ + self.get_validator("default")(100), + self.get_validator("int_validator"), + self.get_validator("limit_to_configured_maximum")("", 10000), + ], + "group": "Data", + } + + def values_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + field = self.column_field(choices) + field.update( + { + "field_name": "values", + "label": "Values", + "validators": [ + self.get_validator("charts_if_empty_same_as")("y"), + self.get_validator("unicode_safe"), + ], + }, + ) + + return field + + def names_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: + field = self.column_field(choices) + field.update( + { + "field_name": "names", + "label": "Names", + "validators": [ + self.get_validator("charts_if_empty_same_as")("x"), + self.get_validator("unicode_safe"), + ], + }, + ) + + return field + + def width_field(self) -> dict[str, Any]: + """The limit field represent an amount of rows to show in the chart.""" + return { + "field_name": "width", + "label": "Width", + "form_snippet": "chart_text.html", + "input_type": "number", + "validators": [ + self.get_validator("default")(640), + self.get_validator("int_validator"), + self.get_validator("limit_to_configured_maximum")("", 1000), + ], + "group": "Data", + } + + def height_field(self) -> dict[str, Any]: + """The limit field represent an amount of rows to show in the chart.""" + return { + "field_name": "height", + "label": "Height", + "form_snippet": "chart_text.html", + "input_type": "number", + "validators": [ + self.get_validator("default")(400), + self.get_validator("int_validator"), + self.get_validator("limit_to_configured_maximum")("", 1000), + ], + "group": "Data", + } diff --git a/ckanext/charts/chart_builders/observable.py b/ckanext/charts/chart_builders/observable.py new file mode 100644 index 0000000..598fb84 --- /dev/null +++ b/ckanext/charts/chart_builders/observable.py @@ -0,0 +1,263 @@ +from __future__ import annotations + +import json +from typing import Any + +from ckanext.charts.chart_builders.base import BaseChartBuilder, BaseChartForm + + +class ObservableBuilder(BaseChartBuilder): + @classmethod + def get_supported_forms(cls) -> list[type[Any]]: + return [ + ObservableBarForm, + ObservableHoriontalBarForm, + ObservableLineForm, + ObservablePieForm, + ObservableScatterForm, + ObservableAutoForm, + ] + + +class ObservableBarBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "bar", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservableBarForm(BaseChartForm): + name = "Bar" + builder = ObservableBarBuilder + + def fill_field(self, choices: list[dict[str, str]]) -> dict[str, str]: + field = self.color_field(choices) + field.update({"field_name": "fill", "label": "Fill"}) + + return field + + def get_form_fields(self): + columns = [{"value": col, "label": col} for col in self.df.columns] + chart_types = [ + {"value": form.name, "label": form.name} + for form in self.builder.get_supported_forms() + ] + + return [ + self.title_field(), + self.description_field(), + self.engine_field(), + self.type_field(chart_types), + self.x_axis_field(columns), + self.y_axis_field(columns), + self.sort_x_field(), + self.sort_y_field(), + self.fill_field(columns), + self.opacity_field(), + self.limit_field(), + ] + + +class ObservableHorizontalBarBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "horizontal-bar", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservableHoriontalBarForm(ObservableBarForm): + name = "Horizontal Bar" + builder = ObservableHorizontalBarBuilder + + +class ObservableLineBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "line", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservableLineForm(BaseChartForm): + name = "Line" + builder = ObservableLineBuilder + + def get_form_fields(self): + columns = [{"value": col, "label": col} for col in self.df.columns] + chart_types = [ + {"value": form.name, "label": form.name} + for form in self.builder.get_supported_forms() + ] + + return [ + self.title_field(), + self.description_field(), + self.engine_field(), + self.type_field(chart_types), + self.x_axis_field(columns), + self.y_axis_field(columns), + self.sort_x_field(), + self.sort_y_field(), + self.limit_field(), + ] + + +class ObservablePieBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "pie", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservablePieForm(BaseChartForm): + name = "Pie" + builder = ObservablePieBuilder + + def inner_radius_field(self) -> dict[str, Any]: + return { + "field_name": "innerRadius", + "label": "Inner Radius", + "input_type": "number", + "group": "Styles", + "validators": [ + self.get_validator("default")(0), + self.get_validator("float_validator"), + ], + } + + def stroke_width_field(self) -> dict[str, Any]: + return { + "field_name": "strokeWidth", + "label": "Stroke Width", + "input_type": "number", + "group": "Styles", + "help_text": "Works only if inner radius is lower than 0", + "validators": [ + self.get_validator("default")(1), + self.get_validator("float_validator"), + ], + } + + def font_size_field(self) -> dict[str, Any]: + return { + "field_name": "fontSize", + "label": "Font Size", + "input_type": "number", + "group": "Styles", + "validators": [ + self.get_validator("default")(12), + self.get_validator("float_validator"), + ], + } + + def get_form_fields(self): + columns = [{"value": col, "label": col} for col in self.df.columns] + chart_types = [ + {"value": form.name, "label": form.name} + for form in self.builder.get_supported_forms() + ] + + return [ + self.title_field(), + self.description_field(), + self.engine_field(), + self.type_field(chart_types), + self.values_field(columns), + self.names_field(columns), + self.opacity_field(), + self.inner_radius_field(), + self.stroke_width_field(), + self.font_size_field(), + self.limit_field(), + self.width_field(), + self.height_field(), + ] + + +class ObservableScatterBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "scatter", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservableScatterForm(BaseChartForm): + name = "Scatter" + builder = ObservableScatterBuilder + + def get_form_fields(self): + columns = [{"value": col, "label": col} for col in self.df.columns] + chart_types = [ + {"value": form.name, "label": form.name} + for form in self.builder.get_supported_forms() + ] + + return [ + self.title_field(), + self.description_field(), + self.engine_field(), + self.type_field(chart_types), + self.x_axis_field(columns), + self.y_axis_field(columns), + self.sort_x_field(), + self.sort_y_field(), + self.color_field(columns), + self.opacity_field(), + self.limit_field(), + ] + + +class ObservableAutoBuilder(ObservableBuilder): + def to_json(self) -> str: + return json.dumps( + { + "type": "auto", + "data": self.df.to_dict(orient="records"), + "settings": self.settings, + } + ) + + +class ObservableAutoForm(BaseChartForm): + name = "Auto" + builder = ObservableAutoBuilder + + def get_form_fields(self): + columns = [{"value": col, "label": col} for col in self.df.columns] + chart_types = [ + {"value": form.name, "label": form.name} + for form in self.builder.get_supported_forms() + ] + + return [ + self.title_field(), + self.description_field(), + self.engine_field(), + self.type_field(chart_types), + self.x_axis_field(columns), + self.y_axis_field(columns), + self.sort_x_field(), + self.sort_y_field(), + self.color_field(columns), + self.opacity_field(), + self.limit_field(), + ] diff --git a/ckanext/charts/chart_builders/plotly.py b/ckanext/charts/chart_builders/plotly.py index c0432ba..ca4b07a 100644 --- a/ckanext/charts/chart_builders/plotly.py +++ b/ckanext/charts/chart_builders/plotly.py @@ -1,43 +1,16 @@ from __future__ import annotations -from abc import ABC, abstractmethod from typing import Any, cast import pandas as pd import plotly.express as px -import ckan.plugins.toolkit as tk -from ckan import types -from ckanext.charts import fetchers, exception -from ckanext.charts.chart_builders.base import BaseChartBuilder +from ckanext.charts import exception +from ckanext.charts.chart_builders.base import BaseChartBuilder, BaseChartForm class PlotlyBuilder(BaseChartBuilder): - def __init__(self, df: pd.DataFrame, settings: dict[str, Any]) -> None: - super().__init__(df, settings) - - self.settings = self.drop_view_fields(self.drop_empty_values(self.settings)) - - def drop_view_fields(self, settings: dict[str, Any]) -> dict[str, Any]: - """Drop fields not related to chart settings.""" - return { - k: v - for k, v in settings.items() - if k - not in ( - "title", - "description", - "engine", - "type", - "id", - "notes", - "package_id", - "resource_id", - "view_type", - ) - } - @classmethod def get_supported_forms(cls) -> list[type[Any]]: return [ @@ -50,11 +23,8 @@ def get_supported_forms(cls) -> list[type[Any]]: class PlotlyBarBuilder(PlotlyBuilder): - def to_json(self) -> Any: - return px.bar(self.df, **self.settings).to_json() - - def to_html(self) -> str: - return px.bar(self.df, **self.settings).to_html() + def to_json(self) -> str: + return cast(str, px.bar(self.df, **self.settings).to_json()) class PlotlyHorizontalBarBuilder(PlotlyBuilder): @@ -65,25 +35,16 @@ def __init__(self, df: pd.DataFrame, settings: dict[str, Any]) -> None: def to_json(self) -> Any: return px.bar(self.df, **self.settings).to_json() - def to_html(self) -> str: - return px.bar(self.df, **self.settings).to_html() - class PlotlyPieBuilder(PlotlyBuilder): def to_json(self) -> Any: return px.pie(self.df, **self.settings).to_json() - def to_html(self) -> str: - return px.pie(self.df, **self.settings).to_html() - class PlotlyLineBuilder(PlotlyBuilder): def to_json(self) -> Any: return px.line(self.df, **self.settings).to_json() - def to_html(self) -> str: - return px.line(self.df, **self.settings).to_html() - class PlotlyScatterBuilder(PlotlyBuilder): def to_json(self) -> Any: @@ -92,296 +53,9 @@ def to_json(self) -> Any: except Exception as e: raise exception.ChartBuildError(f"Error building the chart: {e}") - def to_html(self) -> str: - return px.scatter(self.df, **self.settings).to_html() - - -class BasePlotlyForm(ABC): - """ - TODO: move some of the common methods to the BaseChartForm class, that - will be used by all chart form builders. - """ - - def __init__(self, resource_id: str) -> None: - try: - self.df = fetchers.DatastoreDataFetcher(resource_id).fetch_data() - except tk.ValidationError: - return - - def get_validator(self, name: str) -> types.ValueValidator: - """Get the validator by name. Replaces the tk.get_validator to get rid - of annoying typing error""" - return cast(types.ValueValidator, tk.get_validator(name)) - - @abstractmethod - def get_form_fields(self) -> list[dict[str, Any]]: - """The list for a specific chart could be defined similar to a scheming - dataset schema fields.""" - - def get_expanded_form_fields(self): - """Expands the presets.""" - return self.expand_schema_fields( - self.drop_validators( - self.get_form_fields(), - ), - ) - - def expand_schema_fields( - self, - fields: list[dict[str, Any]], - ) -> list[dict[str, Any]]: - """Expand the schema fields presets.""" - from ckanext.scheming.plugins import _expand_schemas - - expanded_schemas = _expand_schemas({"schema": {"fields": fields}}) - - return expanded_schemas["schema"]["fields"] - - def drop_validators(self, fields: list[dict[str, Any]]) -> list[dict[str, Any]]: - """Drop the validators from the fields, because we don't need this information - to render a form.""" - for field in fields: - if "validators" not in field: - continue - - field.pop("validators") - - return fields - - def get_validation_schema(self) -> dict[str, Any]: - fields = self.get_form_fields() - - return { - field["field_name"]: field["validators"] - for field in fields - if "validators" in field - } - - def get_form_tabs(self) -> list[str]: - return ["General", "Structure", "Data", "Styles"] - - def get_fields_by_tab(self, tab: str) -> list[dict[str, Any]]: - fields = self.get_expanded_form_fields() - return [field for field in fields if field["group"] == tab] - - def column_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - return { - "field_name": "column", - "label": "Column", - "preset": "select", - "required": True, - "choices": choices, - "group": "Data", - "validators": [ - self.get_validator("ignore_empty"), - self.get_validator("unicode_safe"), - ], - } - - def title_field(self) -> dict[str, Any]: - return { - "field_name": "title", - "label": "Title", - "preset": "title", - "form_placeholder": "Chart title", - "group": "General", - "validators": [ - self.get_validator("ignore_empty"), - self.get_validator("unicode_safe"), - ], - } - - def description_field(self) -> dict[str, Any]: - return { - "field_name": "description", - "label": "Description", - "form_snippet": "markdown.html", - "form_placeholder": "Information about my view", - "group": "General", - "validators": [ - self.get_validator("ignore_empty"), - self.get_validator("unicode_safe"), - ], - } - - def engine_field(self) -> dict[str, Any]: - return { - "field_name": "engine", - "label": "Engine", - "preset": "select", - "required": True, - "choices": tk.h.get_available_chart_engines_options(), - "group": "Structure", - "validators": [ - self.get_validator("default")("plotly"), - self.get_validator("unicode_safe"), - ], - } - - def type_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - return { - "field_name": "type", - "label": "Type", - "preset": "select", - "required": True, - "choices": choices, - "group": "Structure", - "validators": [ - self.get_validator("default")("Bar"), - self.get_validator("unicode_safe"), - ], - "form_attrs": { - "hx-get": tk.h.url_for("charts_view.update_form"), - "hx-trigger": "change", - "hx-include": "closest form", - "hx-target": ".charts-view--form", - }, - } - - def x_axis_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - return { - "field_name": "x", - "label": "X Axis", - "preset": "select", - "required": True, - "choices": choices, - "group": "Data", - "validators": [ - self.get_validator("charts_if_empty_same_as")("values"), - self.get_validator("unicode_safe"), - ], - } - - def y_axis_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - field = self.column_field(choices) - field.update( - { - "field_name": "y", - "label": "Y Axis", - "validators": [ - self.get_validator("charts_if_empty_same_as")("names"), - self.get_validator("unicode_safe"), - ], - } - ) - - return field - - def sort_x_field(self) -> dict[str, Any]: - return { - "field_name": "sort_x", - "label": "Sort X-axis", - "form_snippet": "chart_checkbox.html", - "group": "Data", - "validators": [ - self.get_validator("default")(False), - self.get_validator("boolean_validator"), - ], - } - - def sort_y_field(self) -> dict[str, Any]: - return { - "field_name": "sort_y", - "label": "Sort Y-axis", - "form_snippet": "chart_checkbox.html", - "group": "Data", - "validators": [ - self.get_validator("default")(False), - self.get_validator("boolean_validator"), - ], - } - - def query_field(self) -> dict[str, Any]: - return { - "field_name": "query", - "label": "Query", - "form_snippet": "textarea.html", - "group": "Structure", - "form_attrs": {"disabled": 5}, - "validators": [ - self.get_validator("ignore_empty"), - self.get_validator("unicode_safe"), - ], - } - - def log_x_field(self) -> dict[str, Any]: - return { - "field_name": "log_x", - "label": "Log-scale X-axis", - "form_snippet": "chart_checkbox.html", - "group": "Data", - "validators": [ - self.get_validator("default")(False), - self.get_validator("boolean_validator"), - ], - } - - def log_y_field(self) -> dict[str, Any]: - return { - "field_name": "log_y", - "label": "Log-scale Y-axis", - "form_snippet": "chart_checkbox.html", - "group": "Data", - "validators": [ - self.get_validator("default")(False), - self.get_validator("boolean_validator"), - ], - } - - def color_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - return { - "field_name": "color", - "label": "Color", - "preset": "select", - "choices": choices, - "group": "Styles", - "validators": [ - self.get_validator("ignore_empty"), - self.get_validator("unicode_safe"), - ], - } - - def animation_frame_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - return { - "field_name": "animation_frame", - "label": "Animation Frame", - "preset": "select", - "choices": choices, - "group": "Styles", - "validators": [ - self.get_validator("ignore_empty"), - self.get_validator("unicode_safe"), - ], - } - - def opacity_field(self) -> dict[str, Any]: - """The opacity field represent the opacity level of the chart.""" - return { - "field_name": "opacity", - "label": "Opacity", - "form_snippet": "chart_range.html", - "group": "Styles", - "validators": [ - self.get_validator("default")(1), - self.get_validator("float_validator"), - ], - } - - def limit_field(self) -> dict[str, Any]: - """The limit field represent an amount of rows to show in the chart.""" - return { - "field_name": "limit", - "label": "Limit", - "form_snippet": "chart_text.html", - "input_type": "number", - "validators": [ - self.get_validator("default")(100), - self.get_validator("int_validator"), - self.get_validator("limit_to_configured_maximum")("", 10000), - ], - "group": "Data", - } +class BasePlotlyForm(BaseChartForm): + pass class PlotlyBarForm(BasePlotlyForm): @@ -419,36 +93,6 @@ class PlotlyPieForm(BasePlotlyForm): name = "Pie" builder = PlotlyPieBuilder - def values_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - field = self.column_field(choices) - field.update( - { - "field_name": "values", - "label": "Values", - "validators": [ - self.get_validator("charts_if_empty_same_as")("y"), - self.get_validator("unicode_safe"), - ], - }, - ) - - return field - - def names_field(self, choices: list[dict[str, str]]) -> dict[str, Any]: - field = self.column_field(choices) - field.update( - { - "field_name": "names", - "label": "Names", - "validators": [ - self.get_validator("charts_if_empty_same_as")("x"), - self.get_validator("unicode_safe"), - ], - }, - ) - - return field - def get_form_fields(self): """Get the form fields for the Plotly pie chart.""" columns = [{"value": col, "label": col} for col in self.df.columns] diff --git a/ckanext/charts/logic/schema.py b/ckanext/charts/logic/schema.py index 4e1e987..a54de9d 100644 --- a/ckanext/charts/logic/schema.py +++ b/ckanext/charts/logic/schema.py @@ -9,6 +9,4 @@ @validator_args def settings_schema(validate_chart_extras) -> Schema: - return { - "__extras": [validate_chart_extras], - } + return {"__extras": [validate_chart_extras]} diff --git a/ckanext/charts/logic/validators.py b/ckanext/charts/logic/validators.py index f3f13ff..256e8da 100644 --- a/ckanext/charts/logic/validators.py +++ b/ckanext/charts/logic/validators.py @@ -5,7 +5,7 @@ import ckan.plugins.toolkit as tk from ckanext.charts import utils -from ckanext.charts.chart_builders.plotly import PlotlyBarForm +from ckanext.charts.chart_builders import DEFAULT_CHART_FORM def float_validator(value): @@ -33,9 +33,8 @@ def validate_chart_extras(key, data, errors, context): """Use a custom validation schema for specific chart types.""" settings = _extract_setting(data) - # use plotly bar as default settings if "engine" not in settings or "type" not in settings: - builder = PlotlyBarForm + builder = DEFAULT_CHART_FORM else: builder = utils.get_chart_form_builder(settings["engine"], settings["type"]) diff --git a/ckanext/charts/plugin.py b/ckanext/charts/plugin.py index 872b722..1ac3476 100644 --- a/ckanext/charts/plugin.py +++ b/ckanext/charts/plugin.py @@ -10,7 +10,7 @@ import ckanext.charts.config as conf from ckanext.charts import cache, exception, fetchers, utils from ckanext.charts.logic.schema import settings_schema -from ckanext.charts.chart_builders import PlotlyBarForm +from ckanext.charts.chart_builders import DEFAULT_CHART_FORM @tk.blanket.helpers @@ -81,7 +81,7 @@ def setup_template_variables( data = { "settings": {}, "resource_id": data_dict["resource"]["id"], - "form_builder": PlotlyBarForm, + "form_builder": DEFAULT_CHART_FORM, } data_dict["resource_view"]["resource_id"] = data_dict["resource"]["id"] @@ -101,7 +101,7 @@ def setup_template_variables( settings["type"], ) except exception.ChartTypeNotImplementedError: - form_builder = PlotlyBarForm + form_builder = DEFAULT_CHART_FORM data.update({"form_builder": form_builder}) # view show diff --git a/ckanext/charts/templates/charts/charts_form.html b/ckanext/charts/templates/charts/charts_form.html index 074f343..7215aa0 100644 --- a/ckanext/charts/templates/charts/charts_form.html +++ b/ckanext/charts/templates/charts/charts_form.html @@ -1,7 +1,8 @@ {% import "macros/form.html" as form %} {% asset "charts/plotly" %} -{% asset "charts/chartjs" %} +{# {% asset "charts/chartjs" %} #} +{% asset "charts/observable" %} {% asset "charts/charts-css" %}
diff --git a/ckanext/charts/templates/charts/snippets/charts_form_fields.html b/ckanext/charts/templates/charts/snippets/charts_form_fields.html index 20b6db1..4806f78 100644 --- a/ckanext/charts/templates/charts/snippets/charts_form_fields.html +++ b/ckanext/charts/templates/charts/snippets/charts_form_fields.html @@ -4,11 +4,14 @@
@@ -23,11 +26,15 @@ hx-include="closest form" hx-target="#charts-view--preview"> {% for tab in form_tabs %} -
- {% snippet 'charts/snippets/render_fields.html', fields=builder.get_fields_by_tab(tab), data=data, - errors=errors %} -
+ {% set tab_fields = builder.get_fields_by_tab(tab) %} + + {% if tab_fields %} +
+ {% snippet 'charts/snippets/render_fields.html', fields=builder.get_fields_by_tab(tab), data=data, + errors=errors %} +
+ {% endif %} {% endfor %}
diff --git a/ckanext/charts/templates/charts/snippets/observable_chart.html b/ckanext/charts/templates/charts/snippets/observable_chart.html new file mode 100644 index 0000000..cc858c5 --- /dev/null +++ b/ckanext/charts/templates/charts/snippets/observable_chart.html @@ -0,0 +1,9 @@ +{% asset "charts/observable" %} + +{% if chart %} +
+{% else %} +

+ {{ _("Cannot build chart with current settings") }} +

+{% endif %} diff --git a/ckanext/charts/utils.py b/ckanext/charts/utils.py index b0fbcb8..ace3b28 100644 --- a/ckanext/charts/utils.py +++ b/ckanext/charts/utils.py @@ -7,7 +7,7 @@ import ckan.plugins.toolkit as tk -from ckanext.charts.chart_builders import ChartJSBuilder, PlotlyBuilder +from ckanext.charts.chart_builders import get_chart_engines from ckanext.charts.fetchers import DatastoreDataFetcher @@ -32,13 +32,12 @@ def printable_file_size(size_bytes: int) -> str: def get_chart_form_builder(engine: str, chart_type: str): - if engine == "plotly": - return PlotlyBuilder.get_form_for_type(chart_type) + builders = get_chart_engines() - if engine == "chartjs": - return ChartJSBuilder.get_form_for_type(chart_type) + if engine not in builders: + raise NotImplementedError(f"Engine {engine} is not supported") - raise NotImplementedError(f"Engine {engine} is not supported") + return builders[engine].get_form_for_type(chart_type) def build_chart_for_data(settings: dict[str, Any], data: pd.DataFrame): @@ -59,14 +58,12 @@ def build_chart_for_resource(settings: dict[str, Any], resource_id: str): def _build_chart(settings: dict[str, Any], dataframe: pd.DataFrame) -> str | None: - # TODO: rewrite it to pick the correct builder based on the engine more eloquently - if settings["engine"] == "plotly": - builder = PlotlyBuilder.get_builder_for_type(settings["type"]) - elif settings["engine"] == "chartjs": - builder = ChartJSBuilder.get_builder_for_type(settings["type"]) - else: + """Get chart config for the given settings and dataframe""" + builders = get_chart_engines() + + if settings["engine"] not in builders: return None - result = builder(dataframe, settings) + builder = builders[settings["engine"]].get_builder_for_type(settings["type"]) - return result.to_json() + return builder(dataframe, settings).to_json() diff --git a/ckanext/charts/views.py b/ckanext/charts/views.py index 0585a95..7addde4 100644 --- a/ckanext/charts/views.py +++ b/ckanext/charts/views.py @@ -47,6 +47,11 @@ def update_form(): data = parse_params(tk.request.args) resource_id = data["resource_id"] + # if we're changing the engine, drop the chart type, cause we don't know + # the list of supported types for the new engine + if data.pop("reset_engine", False): + data["type"] = "" + try: builder = _get_form_builder(data) except exception.ChartTypeNotImplementedError: