From b2364d26ec0097ffde70426be04c58b9db7c1ce9 Mon Sep 17 00:00:00 2001 From: James Cole Date: Sun, 27 Aug 2023 18:45:06 +0200 Subject: [PATCH] Various color fixes. --- ...oard-7d4913ce.js => dashboard-767a50a1.js} | 8 +- public/build/manifest.json | 4 +- .../assets/v2/pages/dashboard/accounts.js | 13 ++-- .../assets/v2/pages/dashboard/budgets.js | 7 ++ .../assets/v2/pages/dashboard/categories.js | 4 + resources/assets/v2/pages/dashboard/sankey.js | 39 +++++----- resources/assets/v2/support/get-colors.js | 77 +++++++++++-------- 7 files changed, 91 insertions(+), 61 deletions(-) rename public/build/assets/{dashboard-7d4913ce.js => dashboard-767a50a1.js} (86%) diff --git a/public/build/assets/dashboard-7d4913ce.js b/public/build/assets/dashboard-767a50a1.js similarity index 86% rename from public/build/assets/dashboard-7d4913ce.js rename to public/build/assets/dashboard-767a50a1.js index 7812db7a83..7a3f6481e0 100644 --- a/public/build/assets/dashboard-7d4913ce.js +++ b/public/build/assets/dashboard-767a50a1.js @@ -30,17 +30,17 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho * https://www.chartjs.org * (c) 2023 Chart.js Contributors * Released under the MIT License - */class Animator{constructor(){this._request=null,this._charts=new Map,this._running=!1,this._lastDate=void 0}_notify(e,a,n,r){const i=a.listeners[r],o=a.duration;i.forEach(s=>s({chart:e,initial:a.initial,numSteps:o,currentStep:Math.min(n-a.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=requestAnimFrame.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let a=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;const i=n.items;let o=i.length-1,s=!1,l;for(;o>=0;--o)l=i[o],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(e),s=!0):(i[o]=i[i.length-1],i.pop());s&&(r.draw(),this._notify(r,n,e,"progress")),i.length||(n.running=!1,this._notify(r,n,e,"complete"),n.initial=!1),a+=i.length}),this._lastDate=e,a===0&&(this._running=!1)}_getAnims(e){const a=this._charts;let n=a.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},a.set(e,n)),n}listen(e,a,n){this._getAnims(e).listeners[a].push(n)}add(e,a){!a||!a.length||this._getAnims(e).items.push(...a)}has(e){return this._getAnims(e).items.length>0}start(e){const a=this._charts.get(e);a&&(a.running=!0,a.start=Date.now(),a.duration=a.items.reduce((n,r)=>Math.max(n,r._duration),0),this._refresh())}running(e){if(!this._running)return!1;const a=this._charts.get(e);return!(!a||!a.running||!a.items.length)}stop(e){const a=this._charts.get(e);if(!a||!a.items.length)return;const n=a.items;let r=n.length-1;for(;r>=0;--r)n[r].cancel();a.items=[],this._notify(e,a,Date.now(),"complete")}remove(e){return this._charts.delete(e)}}var animator=new Animator;const transparent="transparent",interpolators={boolean(t,e,a){return a>.5?e:t},color(t,e,a){const n=color(t||transparent),r=n.valid&&color(e||transparent);return r&&r.valid?r.mix(n,a).hexString():e},number(t,e,a){return t+(e-t)*a}};class Animation{constructor(e,a,n,r){const i=a[n];r=resolve([e.to,r,i,e.from]);const o=resolve([e.from,i,r]);this._active=!0,this._fn=e.fn||interpolators[e.type||typeof o],this._easing=effects[e.easing]||effects.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=a,this._prop=n,this._from=o,this._to=r,this._promises=void 0}active(){return this._active}update(e,a,n){if(this._active){this._notify(!1);const r=this._target[this._prop],i=n-this._start,o=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(o,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=resolve([e.to,a,r,e.from]),this._from=resolve([e.from,r,a])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){const a=e-this._start,n=this._duration,r=this._prop,i=this._from,o=this._loop,s=this._to;let l;if(this._active=i!==s&&(o||a1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[r]=this._fn(i,s,l)}wait(){const e=this._promises||(this._promises=[]);return new Promise((a,n)=>{e.push({res:a,rej:n})})}_notify(e){const a=e?"res":"rej",n=this._promises||[];for(let r=0;r{const i=e[r];if(!isObject$8(i))return;const o={};for(const s of a)o[s]=i[s];(isArray$c(i.properties)&&i.properties||[r]).forEach(s=>{(s===r||!n.has(s))&&n.set(s,o)})})}_animateOptions(e,a){const n=a.options,r=resolveTargetOptions(e,n);if(!r)return[];const i=this._createAnimations(r,n);return n.$shared&&awaitAll(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,a){const n=this._properties,r=[],i=e.$animations||(e.$animations={}),o=Object.keys(a),s=Date.now();let l;for(l=o.length-1;l>=0;--l){const u=o[l];if(u.charAt(0)==="$")continue;if(u==="options"){r.push(...this._animateOptions(e,a));continue}const c=a[u];let d=i[u];const h=n.get(u);if(d)if(h&&d.active()){d.update(h,c,s);continue}else d.cancel();if(!h||!h.duration){e[u]=c;continue}i[u]=d=new Animation(h,e,u,c),r.push(d)}return r}update(e,a){if(this._properties.size===0){Object.assign(e,a);return}const n=this._createAnimations(e,a);if(n.length)return animator.add(this._chart,n),!0}}function awaitAll(t,e){const a=[],n=Object.keys(e);for(let r=0;r0||!a&&i<0)return r.index}return null}function updateStacks(t,e){const{chart:a,_cachedMeta:n}=t,r=a._stacks||(a._stacks={}),{iScale:i,vScale:o,index:s}=n,l=i.axis,u=o.axis,c=getStackKey(i,o,n),d=e.length;let h;for(let m=0;ma[n].axis===e).shift()}function createDatasetContext(t,e){return createContext(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function createDataContext(t,e,a){return createContext(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:a,index:e,mode:"default",type:"data"})}function clearStacks(t,e){const a=t.controller.index,n=t.vScale&&t.vScale.axis;if(n){e=e||t._parsed;for(const r of e){const i=r._stacks;if(!i||i[n]===void 0||i[n][a]===void 0)return;delete i[n][a],i[n]._visualValues!==void 0&&i[n]._visualValues[a]!==void 0&&delete i[n]._visualValues[a]}}}const isDirectUpdateMode=t=>t==="reset"||t==="none",cloneIfNotShared=(t,e)=>e?t:Object.assign({},t),createStack=(t,e,a)=>t&&!e.hidden&&e._stacked&&{keys:getSortedDatasetIndices(a,!0),values:null};class DatasetController{constructor(e,a){this.chart=e,this._ctx=e.ctx,this.index=a,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=isStacked(e.vScale,e),this.addElements(),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(e){this.index!==e&&clearStacks(this._cachedMeta),this.index=e}linkScales(){const e=this.chart,a=this._cachedMeta,n=this.getDataset(),r=(d,h,m,p)=>d==="x"?h:d==="r"?p:m,i=a.xAxisID=valueOrDefault(n.xAxisID,getFirstScaleId(e,"x")),o=a.yAxisID=valueOrDefault(n.yAxisID,getFirstScaleId(e,"y")),s=a.rAxisID=valueOrDefault(n.rAxisID,getFirstScaleId(e,"r")),l=a.indexAxis,u=a.iAxisID=r(l,i,o,s),c=a.vAxisID=r(l,o,i,s);a.xScale=this.getScaleForId(i),a.yScale=this.getScaleForId(o),a.rScale=this.getScaleForId(s),a.iScale=this.getScaleForId(u),a.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){const a=this._cachedMeta;return e===a.iScale?a.vScale:a.iScale}reset(){this._update("reset")}_destroy(){const e=this._cachedMeta;this._data&&unlistenArrayEvents(this._data,this),e._stacked&&clearStacks(e)}_dataCheck(){const e=this.getDataset(),a=e.data||(e.data=[]),n=this._data;if(isObject$8(a))this._data=convertObjectDataToArray(a);else if(n!==a){if(n){unlistenArrayEvents(n,this);const r=this._cachedMeta;clearStacks(r),r._parsed=[]}a&&Object.isExtensible(a)&&listenArrayEvents(a,this),this._syncList=[],this._data=a}}addElements(){const e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){const a=this._cachedMeta,n=this.getDataset();let r=!1;this._dataCheck();const i=a._stacked;a._stacked=isStacked(a.vScale,a),a.stack!==n.stack&&(r=!0,clearStacks(a),a.stack=n.stack),this._resyncElements(e),(r||i!==a._stacked)&&updateStacks(this,a._parsed)}configure(){const e=this.chart.config,a=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),a,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,a){const{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:o}=n,s=i.axis;let l=e===0&&a===r.length?!0:n._sorted,u=e>0&&n._parsed[e-1],c,d,h;if(this._parsing===!1)n._parsed=r,n._sorted=!0,h=r;else{isArray$c(r[e])?h=this.parseArrayData(n,r,e,a):isObject$8(r[e])?h=this.parseObjectData(n,r,e,a):h=this.parsePrimitiveData(n,r,e,a);const m=()=>d[s]===null||u&&d[s]v||d=0;--h)if(!p()){this.updateRangeFromParsed(u,e,m,l);break}}return u}getAllParsedValues(e){const a=this._cachedMeta._parsed,n=[];let r,i,o;for(r=0,i=a.length;r=0&&ethis.getContext(n,r,a),v=u.resolveNamedOptions(h,m,p,d);return v.$shared&&(v.$shared=l,i[o]=Object.freeze(cloneIfNotShared(v,l))),v}_resolveAnimations(e,a,n){const r=this.chart,i=this._cachedDataOpts,o=`animation-${a}`,s=i[o];if(s)return s;let l;if(r.options.animation!==!1){const c=this.chart.config,d=c.datasetAnimationScopeKeys(this._type,a),h=c.getOptionScopes(this.getDataset(),d);l=c.createResolver(h,this.getContext(e,n,a))}const u=new Animations(r,l&&l.animations);return l&&l._cacheable&&(i[o]=Object.freeze(u)),u}getSharedOptions(e){if(e.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},e))}includeOptions(e,a){return!a||isDirectUpdateMode(e)||this.chart._animationsDisabled}_getSharedOptions(e,a){const n=this.resolveDataElementOptions(e,a),r=this._sharedOptions,i=this.getSharedOptions(n),o=this.includeOptions(a,i)||i!==r;return this.updateSharedOptions(i,a,n),{sharedOptions:i,includeOptions:o}}updateElement(e,a,n,r){isDirectUpdateMode(r)?Object.assign(e,n):this._resolveAnimations(a,r).update(e,n)}updateSharedOptions(e,a,n){e&&!isDirectUpdateMode(a)&&this._resolveAnimations(void 0,a).update(e,n)}_setStyle(e,a,n,r){e.active=r;const i=this.getStyle(a,r);this._resolveAnimations(a,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,a,n){this._setStyle(e,n,"active",!1)}setHoverStyle(e,a,n){this._setStyle(e,n,"active",!0)}_removeDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!1)}_setDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!0)}_resyncElements(e){const a=this._data,n=this._cachedMeta.data;for(const[s,l,u]of this._syncList)this[s](l,u);this._syncList=[];const r=n.length,i=a.length,o=Math.min(i,r);o&&this.parse(0,o),i>r?this._insertElements(r,i-r,e):i{for(u.length+=a,s=u.length-1;s>=o;s--)u[s]=u[s-a]};for(l(i),s=e;sr-i))}return t._cache.$bar}function computeMinSampleSize(t){const e=t.iScale,a=getAllScaleValues(e,t.type);let n=e._length,r,i,o,s;const l=()=>{o===32767||o===-32768||(defined$1(s)&&(n=Math.min(n,Math.abs(o-s)||n)),s=o)};for(r=0,i=a.length;r0?r[t-1]:null,s=tMath.abs(s)&&(l=s,u=o),e[a.axis]=u,e._custom={barStart:l,barEnd:u,start:r,end:i,min:o,max:s}}function parseValue(t,e,a,n){return isArray$c(t)?parseFloatBar(t,e,a,n):e[a.axis]=a.parse(t,n),e}function parseArrayOrPrimitive(t,e,a,n){const r=t.iScale,i=t.vScale,o=r.getLabels(),s=r===i,l=[];let u,c,d,h;for(u=a,c=a+n;u=a?1:-1)}function borderProps(t){let e,a,n,r,i;return t.horizontal?(e=t.base>t.x,a="left",n="right"):(e=t.basel.controller.options.grouped),i=n.options.stacked,o=[],s=l=>{const u=l.controller.getParsed(a),c=u&&u[l.vScale.axis];if(isNullOrUndef(c)||isNaN(c))return!0};for(const l of r)if(!(a!==void 0&&s(l))&&((i===!1||o.indexOf(l.stack)===-1||i===void 0&&l.stack===void 0)&&o.push(l.stack),l.index===e))break;return o.length||o.push(void 0),o}_getStackCount(e){return this._getStacks(void 0,e).length}_getStackIndex(e,a,n){const r=this._getStacks(e,n),i=a!==void 0?r.indexOf(a):-1;return i===-1?r.length-1:i}_getRuler(){const e=this.options,a=this._cachedMeta,n=a.iScale,r=[];let i,o;for(i=0,o=a.data.length;i_angleBetween(D,s,l,!0)?1:Math.max(k,k*a,O,O*a),p=(D,k,O)=>_angleBetween(D,s,l,!0)?-1:Math.min(k,k*a,O,O*a),v=m(0,u,d),y=m(HALF_PI,c,h),w=p(PI,u,d),_=p(PI+HALF_PI,c,h);n=(v-w)/2,r=(y-_)/2,i=-(v+w)/2,o=-(y+_)/2}return{ratioX:n,ratioY:r,offsetX:i,offsetY:o}}class DoughnutController extends DatasetController{constructor(e,a){super(e,a),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,a){const n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=l=>+n[l];if(isObject$8(n[e])){const{key:l="value"}=this._parsing;i=u=>+resolveObjectKey(n[u],l)}let o,s;for(o=e,s=e+a;o0&&!isNaN(e)?TAU*(Math.abs(e)/a):0}getLabelAndValue(e){const a=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=formatNumber$1(a._parsed[e],n.options.locale);return{label:r[e]||"",value:i}}getMaxBorderWidth(e){let a=0;const n=this.chart;let r,i,o,s,l;if(!e){for(r=0,i=n.data.datasets.length;re!=="spacing",_indexable:e=>e!=="spacing"&&!e.startsWith("borderDash")&&!e.startsWith("hoverBorderDash")}),R(DoughnutController,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){const a=e.data;if(a.labels.length&&a.datasets.length){const{labels:{pointStyle:n,color:r}}=e.legend.options;return a.labels.map((i,o)=>{const l=e.getDatasetMeta(0).controller.getStyle(o);return{text:i,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:r,lineWidth:l.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(o),index:o}})}return[]}},onClick(e,a,n){n.chart.toggleDataVisibility(a.index),n.chart.update()}}}});class LineController extends DatasetController{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(e){const a=this._cachedMeta,{dataset:n,data:r=[],_dataset:i}=a,o=this.chart._animationsDisabled;let{start:s,count:l}=_getStartAndCountOfVisiblePoints(a,r,o);this._drawStart=s,this._drawCount=l,_scaleRangesChanged(a)&&(s=0,l=r.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!i._decimated,n.points=r;const u=this.resolveDatasetElementOptions(e);this.options.showLine||(u.borderWidth=0),u.segment=this.options.segment,this.updateElement(n,void 0,{animated:!o,options:u},e),this.updateElements(r,s,l,e)}updateElements(e,a,n,r){const i=r==="reset",{iScale:o,vScale:s,_stacked:l,_dataset:u}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(a,r),h=o.axis,m=s.axis,{spanGaps:p,segment:v}=this.options,y=isNumber(p)?p:Number.POSITIVE_INFINITY,w=this.chart._animationsDisabled||i||r==="none",_=a+n,D=e.length;let k=a>0&&this.getParsed(a-1);for(let O=0;O=_){F.skip=!0;continue}const g=this.getParsed(O),b=isNullOrUndef(g[m]),$=F[h]=o.getPixelForValue(g[h],O),S=F[m]=i||b?s.getBasePixel():s.getPixelForValue(l?this.applyStack(s,g,l):g[m],O);F.skip=isNaN($)||isNaN(S)||b,F.stop=O>0&&Math.abs(g[h]-k[h])>y,v&&(F.parsed=g,F.raw=u.data[O]),d&&(F.options=c||this.resolveDataElementOptions(O,N.active?"active":r)),w||this.updateElement(N,O,F,r),k=g}}getMaxOverflow(){const e=this._cachedMeta,a=e.dataset,n=a.options&&a.options.borderWidth||0,r=e.data||[];if(!r.length)return n;const i=r[0].size(this.resolveDataElementOptions(0)),o=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,o)/2}draw(){const e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}}R(LineController,"id","line"),R(LineController,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),R(LineController,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class PolarAreaController extends DatasetController{constructor(e,a){super(e,a),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){const a=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=formatNumber$1(a._parsed[e].r,n.options.locale);return{label:r[e]||"",value:i}}parseObjectData(e,a,n,r){return _parseObjectDataRadialScale.bind(this)(e,a,n,r)}update(e){const a=this._cachedMeta.data;this._updateRadius(),this.updateElements(a,0,a.length,e)}getMinMax(){const e=this._cachedMeta,a={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return e.data.forEach((n,r)=>{const i=this.getParsed(r).r;!isNaN(i)&&this.chart.getDataVisibility(r)&&(ia.max&&(a.max=i))}),a}_updateRadius(){const e=this.chart,a=e.chartArea,n=e.options,r=Math.min(a.right-a.left,a.bottom-a.top),i=Math.max(r/2,0),o=Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0),s=(i-o)/e.getVisibleDatasetCount();this.outerRadius=i-s*this.index,this.innerRadius=this.outerRadius-s}updateElements(e,a,n,r){const i=r==="reset",o=this.chart,l=o.options.animation,u=this._cachedMeta.rScale,c=u.xCenter,d=u.yCenter,h=u.getIndexAngle(0)-.5*PI;let m=h,p;const v=360/this.countVisibleElements();for(p=0;p{!isNaN(this.getParsed(r).r)&&this.chart.getDataVisibility(r)&&a++}),a}_computeAngle(e,a,n){return this.chart.getDataVisibility(e)?toRadians(this.resolveDataElementOptions(e,a).angle||n):0}}R(PolarAreaController,"id","polarArea"),R(PolarAreaController,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),R(PolarAreaController,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){const a=e.data;if(a.labels.length&&a.datasets.length){const{labels:{pointStyle:n,color:r}}=e.legend.options;return a.labels.map((i,o)=>{const l=e.getDatasetMeta(0).controller.getStyle(o);return{text:i,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:r,lineWidth:l.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(o),index:o}})}return[]}},onClick(e,a,n){n.chart.toggleDataVisibility(a.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class PieController extends DoughnutController{}R(PieController,"id","pie"),R(PieController,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});function abstract(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapterBase{constructor(e){R(this,"options");this.options=e||{}}static override(e){Object.assign(DateAdapterBase.prototype,e)}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(t,e,a,n){const{controller:r,data:i,_sorted:o}=t,s=r._cachedMeta.iScale;if(s&&e===s.axis&&e!=="r"&&o&&i.length){const l=s._reversePixels?_rlookupByKey:_lookupByKey;if(n){if(r._sharedOptions){const u=i[0],c=typeof u.getRange=="function"&&u.getRange(e);if(c){const d=l(i,e,a-c),h=l(i,e,a+c);return{lo:d.lo,hi:h.hi}}}}else return l(i,e,a)}return{lo:0,hi:i.length-1}}function evaluateInteractionItems(t,e,a,n,r){const i=t.getSortedVisibleDatasetMetas(),o=a[e];for(let s=0,l=i.length;s{l[o](e[a],r)&&(i.push({element:l,datasetIndex:u,index:c}),s=s||l.inRange(e.x,e.y,r))}),n&&!s?[]:i}var Interaction={evaluateInteractionItems,modes:{index(t,e,a,n){const r=getRelativePosition(e,t),i=a.axis||"x",o=a.includeInvisible||!1,s=a.intersect?getIntersectItems(t,r,i,n,o):getNearestItems(t,r,i,!1,n,o),l=[];return s.length?(t.getSortedVisibleDatasetMetas().forEach(u=>{const c=s[0].index,d=u.data[c];d&&!d.skip&&l.push({element:d,datasetIndex:u.index,index:c})}),l):[]},dataset(t,e,a,n){const r=getRelativePosition(e,t),i=a.axis||"xy",o=a.includeInvisible||!1;let s=a.intersect?getIntersectItems(t,r,i,n,o):getNearestItems(t,r,i,!1,n,o);if(s.length>0){const l=s[0].datasetIndex,u=t.getDatasetMeta(l).data;s=[];for(let c=0;ca.pos===e)}function filterDynamicPositionByAxis(t,e){return t.filter(a=>STATIC_POSITIONS.indexOf(a.pos)===-1&&a.box.axis===e)}function sortByWeight(t,e){return t.sort((a,n)=>{const r=e?n:a,i=e?a:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function wrapBoxes(t){const e=[];let a,n,r,i,o,s;for(a=0,n=(t||[]).length;au.box.fullSize),!0),n=sortByWeight(filterByPosition(e,"left"),!0),r=sortByWeight(filterByPosition(e,"right")),i=sortByWeight(filterByPosition(e,"top"),!0),o=sortByWeight(filterByPosition(e,"bottom")),s=filterDynamicPositionByAxis(e,"x"),l=filterDynamicPositionByAxis(e,"y");return{fullSize:a,leftAndTop:n.concat(i),rightAndBottom:r.concat(l).concat(o).concat(s),chartArea:filterByPosition(e,"chartArea"),vertical:n.concat(r).concat(l),horizontal:i.concat(o).concat(s)}}function getCombinedMax(t,e,a,n){return Math.max(t[a],e[a])+Math.max(t[n],e[n])}function updateMaxPadding(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function updateDims(t,e,a,n){const{pos:r,box:i}=a,o=t.maxPadding;if(!isObject$8(r)){a.size&&(t[r]-=a.size);const d=n[a.stack]||{size:0,count:1};d.size=Math.max(d.size,a.horizontal?i.height:i.width),a.size=d.size/d.count,t[r]+=a.size}i.getPadding&&updateMaxPadding(o,i.getPadding());const s=Math.max(0,e.outerWidth-getCombinedMax(o,t,"left","right")),l=Math.max(0,e.outerHeight-getCombinedMax(o,t,"top","bottom")),u=s!==t.w,c=l!==t.h;return t.w=s,t.h=l,a.horizontal?{same:u,other:c}:{same:c,other:u}}function handleMaxPadding(t){const e=t.maxPadding;function a(n){const r=Math.max(e[n]-t[n],0);return t[n]+=r,r}t.y+=a("top"),t.x+=a("left"),a("right"),a("bottom")}function getMargins(t,e){const a=e.maxPadding;function n(r){const i={left:0,top:0,right:0,bottom:0};return r.forEach(o=>{i[o]=Math.max(e[o],a[o])}),i}return n(t?["left","right"]:["top","bottom"])}function fitBoxes(t,e,a,n){const r=[];let i,o,s,l,u,c;for(i=0,o=t.length,u=0;i{typeof v.beforeLayout=="function"&&v.beforeLayout()});const c=l.reduce((v,y)=>y.box.options&&y.box.options.display===!1?v:v+1,0)||1,d=Object.freeze({outerWidth:e,outerHeight:a,padding:r,availableWidth:i,availableHeight:o,vBoxMaxWidth:i/2/c,hBoxMaxHeight:o/2}),h=Object.assign({},r);updateMaxPadding(h,toPadding(n));const m=Object.assign({maxPadding:h,w:i,h:o,x:r.left,y:r.top},r),p=setLayoutDims(l.concat(u),d);fitBoxes(s.fullSize,m,d,p),fitBoxes(l,m,d,p),fitBoxes(u,m,d,p)&&fitBoxes(l,m,d,p),handleMaxPadding(m),placeBoxes(s.leftAndTop,m,d,p),m.x+=m.w,m.y+=m.h,placeBoxes(s.rightAndBottom,m,d,p),t.chartArea={left:m.left,top:m.top,right:m.left+m.w,bottom:m.top+m.h,height:m.h,width:m.w},each(s.chartArea,v=>{const y=v.box;Object.assign(y,t.chartArea),y.update(m.w,m.h,{left:0,top:0,right:0,bottom:0})})}};class BasePlatform{acquireContext(e,a){}releaseContext(e){return!1}addEventListener(e,a,n){}removeEventListener(e,a,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,a,n,r){return a=Math.max(0,a||e.width),n=n||e.height,{width:a,height:Math.max(0,r?Math.floor(a/r):n)}}isAttached(e){return!0}updateConfig(e){}}class BasicPlatform extends BasePlatform{acquireContext(e){return e&&e.getContext&&e.getContext("2d")||null}updateConfig(e){e.options.animation=!1}}const EXPANDO_KEY="$chartjs",EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},isNullOrEmpty=t=>t===null||t==="";function initCanvas(t,e){const a=t.style,n=t.getAttribute("height"),r=t.getAttribute("width");if(t[EXPANDO_KEY]={initial:{height:n,width:r,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",isNullOrEmpty(r)){const i=readUsedSize(t,"width");i!==void 0&&(t.width=i)}if(isNullOrEmpty(n))if(t.style.height==="")t.height=t.width/(e||2);else{const i=readUsedSize(t,"height");i!==void 0&&(t.height=i)}return t}const eventListenerOptions=supportsEventListenerOptions?{passive:!0}:!1;function addListener(t,e,a){t.addEventListener(e,a,eventListenerOptions)}function removeListener(t,e,a){t.canvas.removeEventListener(e,a,eventListenerOptions)}function fromNativeEvent(t,e){const a=EVENT_TYPES[t.type]||t.type,{x:n,y:r}=getRelativePosition(t,e);return{type:a,chart:e,native:t,x:n!==void 0?n:null,y:r!==void 0?r:null}}function nodeListContains(t,e){for(const a of t)if(a===e||a.contains(e))return!0}function createAttachObserver(t,e,a){const n=t.canvas,r=new MutationObserver(i=>{let o=!1;for(const s of i)o=o||nodeListContains(s.addedNodes,n),o=o&&!nodeListContains(s.removedNodes,n);o&&a()});return r.observe(document,{childList:!0,subtree:!0}),r}function createDetachObserver(t,e,a){const n=t.canvas,r=new MutationObserver(i=>{let o=!1;for(const s of i)o=o||nodeListContains(s.removedNodes,n),o=o&&!nodeListContains(s.addedNodes,n);o&&a()});return r.observe(document,{childList:!0,subtree:!0}),r}const drpListeningCharts=new Map;let oldDevicePixelRatio=0;function onWindowResize(){const t=window.devicePixelRatio;t!==oldDevicePixelRatio&&(oldDevicePixelRatio=t,drpListeningCharts.forEach((e,a)=>{a.currentDevicePixelRatio!==t&&e()}))}function listenDevicePixelRatioChanges(t,e){drpListeningCharts.size||window.addEventListener("resize",onWindowResize),drpListeningCharts.set(t,e)}function unlistenDevicePixelRatioChanges(t){drpListeningCharts.delete(t),drpListeningCharts.size||window.removeEventListener("resize",onWindowResize)}function createResizeObserver(t,e,a){const n=t.canvas,r=n&&_getParentNode(n);if(!r)return;const i=throttled((s,l)=>{const u=r.clientWidth;a(s,l),u{const l=s[0],u=l.contentRect.width,c=l.contentRect.height;u===0&&c===0||i(u,c)});return o.observe(r),listenDevicePixelRatioChanges(t,i),o}function releaseObserver(t,e,a){a&&a.disconnect(),e==="resize"&&unlistenDevicePixelRatioChanges(t)}function createProxyAndListen(t,e,a){const n=t.canvas,r=throttled(i=>{t.ctx!==null&&a(fromNativeEvent(i,t))},t);return addListener(n,e,r),r}class DomPlatform extends BasePlatform{acquireContext(e,a){const n=e&&e.getContext&&e.getContext("2d");return n&&n.canvas===e?(initCanvas(e,a),n):null}releaseContext(e){const a=e.canvas;if(!a[EXPANDO_KEY])return!1;const n=a[EXPANDO_KEY].initial;["height","width"].forEach(i=>{const o=n[i];isNullOrUndef(o)?a.removeAttribute(i):a.setAttribute(i,o)});const r=n.style||{};return Object.keys(r).forEach(i=>{a.style[i]=r[i]}),a.width=a.width,delete a[EXPANDO_KEY],!0}addEventListener(e,a,n){this.removeEventListener(e,a);const r=e.$proxies||(e.$proxies={}),o={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver}[a]||createProxyAndListen;r[a]=o(e,a,n)}removeEventListener(e,a){const n=e.$proxies||(e.$proxies={}),r=n[a];if(!r)return;({attach:releaseObserver,detach:releaseObserver,resize:releaseObserver}[a]||removeListener)(e,a,r),n[a]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,a,n,r){return getMaximumSize(e,a,n,r)}isAttached(e){const a=_getParentNode(e);return!!(a&&a.isConnected)}}function _detectPlatform(t){return!_isDomSupported()||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas?BasicPlatform:DomPlatform}var ne;let Element$1=(ne=class{constructor(){R(this,"x");R(this,"y");R(this,"active",!1);R(this,"options");R(this,"$animations")}tooltipPosition(e){const{x:a,y:n}=this.getProps(["x","y"],e);return{x:a,y:n}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(e,a){const n=this.$animations;if(!a||!n)return this;const r={};return e.forEach(i=>{r[i]=n[i]&&n[i].active()?n[i]._to:this[i]}),r}},R(ne,"defaults",{}),R(ne,"defaultRoutes"),ne);function autoSkip(t,e){const a=t.options.ticks,n=determineMaxTicks(t),r=Math.min(a.maxTicksLimit||n,n),i=a.major.enabled?getMajorIndices(e):[],o=i.length,s=i[0],l=i[o-1],u=[];if(o>r)return skipMajors(e,u,i,o/r),u;const c=calculateSpacing(i,e,r);if(o>0){let d,h;const m=o>1?Math.round((l-s)/(o-1)):null;for(skip(e,u,c,isNullOrUndef(m)?0:s-m,s),d=0,h=o-1;dr)return l}return Math.max(r,1)}function getMajorIndices(t){const e=[];let a,n;for(a=0,n=t.length;at==="left"?"right":t==="right"?"left":t,offsetFromEdge=(t,e,a)=>e==="top"||e==="left"?t[e]+a:t[e]-a,getTicksLimit=(t,e)=>Math.min(e||t,t);function sample(t,e){const a=[],n=t.length/e,r=t.length;let i=0;for(;io+s)))return l}function garbageCollect(t,e){each(t,a=>{const n=a.gc,r=n.length/2;let i;if(r>e){for(i=0;in?n:a,n=r&&a>n?a:n,{min:finiteOrDefault(a,finiteOrDefault(n,a)),max:finiteOrDefault(n,finiteOrDefault(a,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(e))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){callback(this.options.beforeUpdate,[this])}update(e,a,n){const{beginAtZero:r,grace:i,ticks:o}=this.options,s=o.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=a,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=_addGrace(this,i,r),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=s=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}const c=this._getLabelSizes(),d=c.widest.width,h=c.highest.height,m=_limitValue(this.chart.width-d,0,this.maxWidth);s=e.offset?this.maxWidth/n:m/(n-1),d+6>s&&(s=m/(n-(e.offset?.5:1)),l=this.maxHeight-getTickMarkLength(e.grid)-a.padding-getTitleHeight(e.title,this.chart.options.font),u=Math.sqrt(d*d+h*h),o=toDegrees(Math.min(Math.asin(_limitValue((c.highest.height+6)/s,-1,1)),Math.asin(_limitValue(l/u,-1,1))-Math.asin(_limitValue(h/u,-1,1)))),o=Math.max(r,Math.min(i,o))),this.labelRotation=o}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const e={width:0,height:0},{chart:a,options:{ticks:n,title:r,grid:i}}=this,o=this._isVisible(),s=this.isHorizontal();if(o){const l=getTitleHeight(r,a.options.font);if(s?(e.width=this.maxWidth,e.height=getTickMarkLength(i)+l):(e.height=this.maxHeight,e.width=getTickMarkLength(i)+l),n.display&&this.ticks.length){const{first:u,last:c,widest:d,highest:h}=this._getLabelSizes(),m=n.padding*2,p=toRadians(this.labelRotation),v=Math.cos(p),y=Math.sin(p);if(s){const w=n.mirror?0:y*d.width+v*h.height;e.height=Math.min(this.maxHeight,e.height+w+m)}else{const w=n.mirror?0:v*d.width+y*h.height;e.width=Math.min(this.maxWidth,e.width+w+m)}this._calculatePadding(u,c,y,v)}}this._handleMargins(),s?(this.width=this._length=a.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=a.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,a,n,r){const{ticks:{align:i,padding:o},position:s}=this.options,l=this.labelRotation!==0,u=s!=="top"&&this.axis==="x";if(this.isHorizontal()){const c=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let h=0,m=0;l?u?(h=r*e.width,m=n*a.height):(h=n*e.height,m=r*a.width):i==="start"?m=a.width:i==="end"?h=e.width:i!=="inner"&&(h=e.width/2,m=a.width/2),this.paddingLeft=Math.max((h-c+o)*this.width/(this.width-c),0),this.paddingRight=Math.max((m-d+o)*this.width/(this.width-d),0)}else{let c=a.height/2,d=e.height/2;i==="start"?(c=0,d=e.height):i==="end"&&(c=a.height,d=0),this.paddingTop=c+o,this.paddingBottom=d+o}}_handleMargins(){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:e,position:a}=this.options;return a==="top"||a==="bottom"||e==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let a,n;for(a=0,n=e.length;a({width:o[b]||0,height:s[b]||0});return{first:g(0),last:g(a-1),widest:g(N),highest:g(F),widths:o,heights:s}}getLabelForValue(e){return e}getPixelForValue(e,a){return NaN}getValueForPixel(e){}getPixelForTick(e){const a=this.ticks;return e<0||e>a.length-1?null:this.getPixelForValue(a[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);const a=this._startPixel+e*this._length;return _int16Range(this._alignToPixels?_alignPixel(this.chart,a,0):a)}getDecimalForPixel(e){const a=(e-this._startPixel)/this._length;return this._reversePixels?1-a:a}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:e,max:a}=this;return e<0&&a<0?a:e>0&&a>0?e:0}getContext(e){const a=this.ticks||[];if(e>=0&&es*r?s/n:l/r:l*r0}_computeGridLineItems(e){const a=this.axis,n=this.chart,r=this.options,{grid:i,position:o,border:s}=r,l=i.offset,u=this.isHorizontal(),d=this.ticks.length+(l?1:0),h=getTickMarkLength(i),m=[],p=s.setContext(this.getContext()),v=p.display?p.width:0,y=v/2,w=function(T){return _alignPixel(n,T,v)};let _,D,k,O,N,F,g,b,$,S,P,M;if(o==="top")_=w(this.bottom),F=this.bottom-h,b=_-y,S=w(e.top)+y,M=e.bottom;else if(o==="bottom")_=w(this.top),S=e.top,M=w(e.bottom)-y,F=_+y,b=this.top+h;else if(o==="left")_=w(this.right),N=this.right-h,g=_-y,$=w(e.left)+y,P=e.right;else if(o==="right")_=w(this.left),$=e.left,P=w(e.right)-y,N=_+y,g=this.left+h;else if(a==="x"){if(o==="center")_=w((e.top+e.bottom)/2+.5);else if(isObject$8(o)){const T=Object.keys(o)[0],x=o[T];_=w(this.chart.scales[T].getPixelForValue(x))}S=e.top,M=e.bottom,F=_+y,b=F+h}else if(a==="y"){if(o==="center")_=w((e.left+e.right)/2);else if(isObject$8(o)){const T=Object.keys(o)[0],x=o[T];_=w(this.chart.scales[T].getPixelForValue(x))}N=_-y,g=N-h,$=e.left,P=e.right}const C=valueOrDefault(r.ticks.maxTicksLimit,d),E=Math.max(1,Math.ceil(d/C));for(D=0;Di.value===e);return r>=0?a.setContext(this.getContext(r)).lineWidth:0}drawGrid(e){const a=this.options.grid,n=this.ctx,r=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e));let i,o;const s=(l,u,c)=>{!c.width||!c.color||(n.save(),n.lineWidth=c.width,n.strokeStyle=c.color,n.setLineDash(c.borderDash||[]),n.lineDashOffset=c.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(u.x,u.y),n.stroke(),n.restore())};if(a.display)for(i=0,o=r.length;i{this.draw(i)}}]:[{z:n,draw:i=>{this.drawBackground(),this.drawGrid(i),this.drawTitle()}},{z:r,draw:()=>{this.drawBorder()}},{z:a,draw:i=>{this.drawLabels(i)}}]}getMatchingVisibleMetas(e){const a=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",r=[];let i,o;for(i=0,o=a.length;i{const n=a.split("."),r=n.pop(),i=[t].concat(n).join("."),o=e[a].split("."),s=o.pop(),l=o.join(".");defaults.route(i,r,l,s)})}function isIChartComponent(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",!0),this.elements=new TypedRegistry(Element$1,"elements"),this.plugins=new TypedRegistry(Object,"plugins"),this.scales=new TypedRegistry(Scale,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each("register",e)}remove(...e){this._each("unregister",e)}addControllers(...e){this._each("register",e,this.controllers)}addElements(...e){this._each("register",e,this.elements)}addPlugins(...e){this._each("register",e,this.plugins)}addScales(...e){this._each("register",e,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(...e){this._each("unregister",e,this.controllers)}removeElements(...e){this._each("unregister",e,this.elements)}removePlugins(...e){this._each("unregister",e,this.plugins)}removeScales(...e){this._each("unregister",e,this.scales)}_each(e,a,n){[...a].forEach(r=>{const i=n||this._getRegistryForType(r);n||i.isForType(r)||i===this.plugins&&r.id?this._exec(e,i,r):each(r,o=>{const s=n||this._getRegistryForType(o);this._exec(e,s,o)})})}_exec(e,a,n){const r=_capitalize(e);callback(n["before"+r],[],n),a[e](n),callback(n["after"+r],[],n)}_getRegistryForType(e){for(let a=0;ai.filter(s=>!o.some(l=>s.plugin.id===l.plugin.id));this._notify(r(a,n),e,"stop"),this._notify(r(n,a),e,"start")}}function allPlugins(t){const e={},a=[],n=Object.keys(registry.plugins.items);for(let i=0;i1&&idMatchesAxis(t[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function getAxisFromDataset(t,e,a){if(a[e+"AxisID"]===t)return{axis:e}}function retrieveAxisFromDatasets(t,e){if(e.data&&e.data.datasets){const a=e.data.datasets.filter(n=>n.xAxisID===t||n.yAxisID===t);if(a.length)return getAxisFromDataset(t,"x",a[0])||getAxisFromDataset(t,"y",a[0])}return{}}function mergeScaleConfig(t,e){const a=overrides[t.type]||{scales:{}},n=e.scales||{},r=getIndexAxis(t.type,e),i=Object.create(null);return Object.keys(n).forEach(o=>{const s=n[o];if(!isObject$8(s))return console.error(`Invalid scale configuration for scale: ${o}`);if(s._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${o}`);const l=determineAxis(o,s,retrieveAxisFromDatasets(o,t),defaults.scales[s.type]),u=getDefaultScaleIDFromAxis(l,r),c=a.scales||{};i[o]=mergeIf(Object.create(null),[{axis:l},s,c[l],c[u]])}),t.data.datasets.forEach(o=>{const s=o.type||t.type,l=o.indexAxis||getIndexAxis(s,e),c=(overrides[s]||{}).scales||{};Object.keys(c).forEach(d=>{const h=getAxisFromDefaultScaleID(d,l),m=o[h+"AxisID"]||h;i[m]=i[m]||Object.create(null),mergeIf(i[m],[{axis:h},n[m],c[d]])})}),Object.keys(i).forEach(o=>{const s=i[o];mergeIf(s,[defaults.scales[s.type],defaults.scale])}),i}function initOptions(t){const e=t.options||(t.options={});e.plugins=valueOrDefault(e.plugins,{}),e.scales=mergeScaleConfig(t,e)}function initData(t){return t=t||{},t.datasets=t.datasets||[],t.labels=t.labels||[],t}function initConfig(t){return t=t||{},t.data=initData(t.data),initOptions(t),t}const keyCache=new Map,keysCached=new Set;function cachedKeys(t,e){let a=keyCache.get(t);return a||(a=e(),keyCache.set(t,a),keysCached.add(a)),a}const addIfFound=(t,e,a)=>{const n=resolveObjectKey(e,a);n!==void 0&&t.add(n)};class Config{constructor(e){this._config=initConfig(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=initData(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){const e=this._config;this.clearCache(),initOptions(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return cachedKeys(e,()=>[[`datasets.${e}`,""]])}datasetAnimationScopeKeys(e,a){return cachedKeys(`${e}.transition.${a}`,()=>[[`datasets.${e}.transitions.${a}`,`transitions.${a}`],[`datasets.${e}`,""]])}datasetElementScopeKeys(e,a){return cachedKeys(`${e}-${a}`,()=>[[`datasets.${e}.elements.${a}`,`datasets.${e}`,`elements.${a}`,""]])}pluginScopeKeys(e){const a=e.id,n=this.type;return cachedKeys(`${n}-plugin-${a}`,()=>[[`plugins.${a}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,a){const n=this._scopeCache;let r=n.get(e);return(!r||a)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,a,n){const{options:r,type:i}=this,o=this._cachedScopes(e,n),s=o.get(a);if(s)return s;const l=new Set;a.forEach(c=>{e&&(l.add(e),c.forEach(d=>addIfFound(l,e,d))),c.forEach(d=>addIfFound(l,r,d)),c.forEach(d=>addIfFound(l,overrides[i]||{},d)),c.forEach(d=>addIfFound(l,defaults,d)),c.forEach(d=>addIfFound(l,descriptors,d))});const u=Array.from(l);return u.length===0&&u.push(Object.create(null)),keysCached.has(a)&&o.set(a,u),u}chartOptionScopes(){const{options:e,type:a}=this;return[e,overrides[a]||{},defaults.datasets[a]||{},{type:a},defaults,descriptors]}resolveNamedOptions(e,a,n,r=[""]){const i={$shared:!0},{resolver:o,subPrefixes:s}=getResolver(this._resolverCache,e,r);let l=o;if(needContext(o,a)){i.$shared=!1,n=isFunction$3(n)?n():n;const u=this.createResolver(e,n,s);l=_attachContext(o,n,u)}for(const u of a)i[u]=l[u];return i}createResolver(e,a,n=[""],r){const{resolver:i}=getResolver(this._resolverCache,e,n);return isObject$8(a)?_attachContext(i,a,void 0,r):i}}function getResolver(t,e,a){let n=t.get(e);n||(n=new Map,t.set(e,n));const r=a.join();let i=n.get(r);return i||(i={resolver:_createResolver(e,a),subPrefixes:a.filter(s=>!s.toLowerCase().includes("hover"))},n.set(r,i)),i}const hasFunction=t=>isObject$8(t)&&Object.getOwnPropertyNames(t).reduce((e,a)=>e||isFunction$3(t[a]),!1);function needContext(t,e){const{isScriptable:a,isIndexable:n}=_descriptors(t);for(const r of e){const i=a(r),o=n(r),s=(o||i)&&t[r];if(i&&(isFunction$3(s)||hasFunction(s))||o&&isArray$c(s))return!0}return!1}var version="4.3.3";const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(t,e){return t==="top"||t==="bottom"||KNOWN_POSITIONS.indexOf(t)===-1&&e==="x"}function compare2Level(t,e){return function(a,n){return a[t]===n[t]?a[e]-n[e]:a[t]-n[t]}}function onAnimationsComplete(t){const e=t.chart,a=e.options.animation;e.notifyPlugins("afterRender"),callback(a&&a.onComplete,[t],e)}function onAnimationProgress(t){const e=t.chart,a=e.options.animation;callback(a&&a.onProgress,[t],e)}function getCanvas(t){return _isDomSupported()&&typeof t=="string"?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const instances={},getChart=t=>{const e=getCanvas(t);return Object.values(instances).filter(a=>a.canvas===e).pop()};function moveNumericKeys(t,e,a){const n=Object.keys(t);for(const r of n){const i=+r;if(i>=e){const o=t[r];delete t[r],(a>0||i>e)&&(t[i+a]=o)}}}function determineLastEvent(t,e,a,n){return!a||t.type==="mouseout"?null:n?e:t}function getDatasetArea(t){const{xScale:e,yScale:a}=t;if(e&&a)return{left:e.left,right:e.right,top:a.top,bottom:a.bottom}}class Chart{static register(...e){registry.add(...e),invalidatePlugins()}static unregister(...e){registry.remove(...e),invalidatePlugins()}constructor(e,a){const n=this.config=new Config(a),r=getCanvas(e),i=getChart(r);if(i)throw new Error("Canvas is already in use. Chart with ID '"+i.id+"' must be destroyed before the canvas with ID '"+i.canvas.id+"' can be reused.");const o=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||_detectPlatform(r)),this.platform.updateConfig(n);const s=this.platform.acquireContext(r,o.aspectRatio),l=s&&s.canvas,u=l&&l.height,c=l&&l.width;if(this.id=uid(),this.ctx=s,this.canvas=l,this.width=c,this.height=u,this._options=o,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new PluginService,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=debounce(d=>this.update(d),o.resizeDelay||0),this._dataChanges=[],instances[this.id]=this,!s||!l){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(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:e,maintainAspectRatio:a},width:n,height:r,_aspectRatio:i}=this;return isNullOrUndef(e)?a&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return registry}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():retinaScale(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return clearCanvas(this.canvas,this.ctx),this}stop(){return animator.stop(this),this}resize(e,a){animator.running(this)?this._resizeBeforeDraw={width:e,height:a}:this._resize(e,a)}_resize(e,a){const n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(r,e,a,i),s=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,retinaScale(this,s,!0)&&(this.notifyPlugins("resize",{size:o}),callback(n.onResize,[this,o],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const a=this.options.scales||{};each(a,(n,r)=>{n.id=r})}buildOrUpdateScales(){const e=this.options,a=e.scales,n=this.scales,r=Object.keys(n).reduce((o,s)=>(o[s]=!1,o),{});let i=[];a&&(i=i.concat(Object.keys(a).map(o=>{const s=a[o],l=determineAxis(o,s),u=l==="r",c=l==="x";return{options:s,dposition:u?"chartArea":c?"bottom":"left",dtype:u?"radialLinear":c?"category":"linear"}}))),each(i,o=>{const s=o.options,l=s.id,u=determineAxis(l,s),c=valueOrDefault(s.type,o.dtype);(s.position===void 0||positionIsHorizontal(s.position,u)!==positionIsHorizontal(o.dposition))&&(s.position=o.dposition),r[l]=!0;let d=null;if(l in n&&n[l].type===c)d=n[l];else{const h=registry.getScale(c);d=new h({id:l,type:c,ctx:this.ctx,chart:this}),n[d.id]=d}d.init(s,e)}),each(r,(o,s)=>{o||delete n[s]}),each(n,o=>{layouts.configure(this,o,o.options),layouts.addBox(this,o)})}_updateMetasets(){const e=this._metasets,a=this.data.datasets.length,n=e.length;if(e.sort((r,i)=>r.index-i.index),n>a){for(let r=a;ra.length&&delete this._stacks,e.forEach((n,r)=>{a.filter(i=>i===n._dataset).length===0&&this._destroyDatasetMeta(r)})}buildOrUpdateControllers(){const e=[],a=this.data.datasets;let n,r;for(this._removeUnreferencedMetasets(),n=0,r=a.length;n{this.getDatasetMeta(a).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){const a=this.config;a.update();const n=this._options=a.createResolver(a.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0})===!1)return;const i=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let u=0,c=this.data.datasets.length;u{u.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(compare2Level("z","_idx"));const{_active:s,_lastEvent:l}=this;l?this._eventHandler(l,!0):s.length&&this._updateHoverStyles(s,s,!0),this.render()}_updateScales(){each(this.scales,e=>{layouts.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const e=this.options,a=new Set(Object.keys(this._listeners)),n=new Set(e.events);(!setsEqual(a,n)||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:e}=this,a=this._getUniformDataChanges()||[];for(const{method:n,start:r,count:i}of a){const o=n==="_removeElements"?-i:i;moveNumericKeys(e,r,o)}}_getUniformDataChanges(){const e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];const a=this.data.datasets.length,n=i=>new Set(e.filter(o=>o[0]===i).map((o,s)=>s+","+o.splice(1).join(","))),r=n(0);for(let i=1;ii.split(",")).map(i=>({method:i[1],start:+i[2],count:+i[3]}))}_updateLayout(e){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;layouts.update(this,this.width,this.height,e);const a=this.chartArea,n=a.width<=0||a.height<=0;this._layers=[],each(this.boxes,r=>{n&&r.position==="chartArea"||(r.configure&&r.configure(),this._layers.push(...r._layers()))},this),this._layers.forEach((r,i)=>{r._idx=i}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})!==!1){for(let a=0,n=this.data.datasets.length;a=0;--a)this._drawDataset(e[a]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){const a=this.ctx,n=e._clip,r=!n.disabled,i=getDatasetArea(e)||this.chartArea,o={meta:e,index:e.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",o)!==!1&&(r&&clipArea(a,{left:n.left===!1?0:i.left-n.left,right:n.right===!1?this.width:i.right+n.right,top:n.top===!1?0:i.top-n.top,bottom:n.bottom===!1?this.height:i.bottom+n.bottom}),e.controller.draw(),r&&unclipArea(a),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(e){return _isPointInArea(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,a,n,r){const i=Interaction.modes[a];return typeof i=="function"?i(this,e,n,r):[]}getDatasetMeta(e){const a=this.data.datasets[e],n=this._metasets;let r=n.filter(i=>i&&i._dataset===a).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:a&&a.order||0,index:e,_dataset:a,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||(this.$context=createContext(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){const a=this.data.datasets[e];if(!a)return!1;const n=this.getDatasetMeta(e);return typeof n.hidden=="boolean"?!n.hidden:!a.hidden}setDatasetVisibility(e,a){const n=this.getDatasetMeta(e);n.hidden=!a}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,a,n){const r=n?"show":"hide",i=this.getDatasetMeta(e),o=i.controller._resolveAnimations(void 0,r);defined$1(a)?(i.data[a].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),o.update(i,{visible:n}),this.update(s=>s.datasetIndex===e?r:void 0))}hide(e,a){this._updateVisibility(e,a,!1)}show(e,a){this._updateVisibility(e,a,!0)}_destroyDatasetMeta(e){const a=this._metasets[e];a&&a.controller&&a.controller._destroy(),delete this._metasets[e]}_stop(){let e,a;for(this.stop(),animator.remove(this),e=0,a=this.data.datasets.length;e{a.addEventListener(this,i,o),e[i]=o},r=(i,o,s)=>{i.offsetX=o,i.offsetY=s,this._eventHandler(i)};each(this.options.events,i=>n(i,r))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const e=this._responsiveListeners,a=this.platform,n=(l,u)=>{a.addEventListener(this,l,u),e[l]=u},r=(l,u)=>{e[l]&&(a.removeEventListener(this,l,u),delete e[l])},i=(l,u)=>{this.canvas&&this.resize(l,u)};let o;const s=()=>{r("attach",s),this.attached=!0,this.resize(),n("resize",i),n("detach",o)};o=()=>{this.attached=!1,r("resize",i),this._stop(),this._resize(0,0),n("attach",s)},a.isAttached(this.canvas)?s():o()}unbindEvents(){each(this._listeners,(e,a)=>{this.platform.removeEventListener(this,a,e)}),this._listeners={},each(this._responsiveListeners,(e,a)=>{this.platform.removeEventListener(this,a,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,a,n){const r=n?"set":"remove";let i,o,s,l;for(a==="dataset"&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller["_"+r+"DatasetHoverStyle"]()),s=0,l=e.length;s{const s=this.getDatasetMeta(i);if(!s)throw new Error("No dataset found at index "+i);return{datasetIndex:i,element:s.data[o],index:o}});!_elementsEqual(n,a)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,a))}notifyPlugins(e,a,n){return this._plugins.notify(this,e,a,n)}isPluginEnabled(e){return this._plugins._cache.filter(a=>a.plugin.id===e).length===1}_updateHoverStyles(e,a,n){const r=this.options.hover,i=(l,u)=>l.filter(c=>!u.some(d=>c.datasetIndex===d.datasetIndex&&c.index===d.index)),o=i(a,e),s=n?e:i(e,a);o.length&&this.updateHoverStyle(o,r.mode,!1),s.length&&r.mode&&this.updateHoverStyle(s,r.mode,!0)}_eventHandler(e,a){const n={event:e,replay:a,cancelable:!0,inChartArea:this.isPointInArea(e)},r=o=>(o.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",n,r)===!1)return;const i=this._handleEvent(e,a,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,a,n){const{_active:r=[],options:i}=this,o=a,s=this._getActiveElements(e,r,n,o),l=_isClickEvent(e),u=determineLastEvent(e,this._lastEvent,n,l);n&&(this._lastEvent=null,callback(i.onHover,[e,s,this],this),l&&callback(i.onClick,[e,s,this],this));const c=!_elementsEqual(s,r);return(c||a)&&(this._active=s,this._updateHoverStyles(s,r,a)),this._lastEvent=u,c}_getActiveElements(e,a,n,r){if(e.type==="mouseout")return[];if(!n)return a;const i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}}R(Chart,"defaults",defaults),R(Chart,"instances",instances),R(Chart,"overrides",overrides),R(Chart,"registry",registry),R(Chart,"version",version),R(Chart,"getChart",getChart);function invalidatePlugins(){return each(Chart.instances,t=>t._plugins.invalidate())}function clipArc(t,e,a){const{startAngle:n,pixelMargin:r,x:i,y:o,outerRadius:s,innerRadius:l}=e;let u=r/s;t.beginPath(),t.arc(i,o,s,n-u,a+u),l>r?(u=r/l,t.arc(i,o,l,a+u,n-u,!0)):t.arc(i,o,r,a+HALF_PI,n-HALF_PI),t.closePath(),t.clip()}function toRadiusCorners(t){return _readValueToProps(t,["outerStart","outerEnd","innerStart","innerEnd"])}function parseBorderRadius$1(t,e,a,n){const r=toRadiusCorners(t.options.borderRadius),i=(a-e)/2,o=Math.min(i,n*e/2),s=l=>{const u=(a-Math.min(i,l))*n/2;return _limitValue(l,0,Math.min(i,u))};return{outerStart:s(r.outerStart),outerEnd:s(r.outerEnd),innerStart:_limitValue(r.innerStart,0,o),innerEnd:_limitValue(r.innerEnd,0,o)}}function rThetaToXY(t,e,a,n){return{x:a+t*Math.cos(e),y:n+t*Math.sin(e)}}function pathArc(t,e,a,n,r,i){const{x:o,y:s,startAngle:l,pixelMargin:u,innerRadius:c}=e,d=Math.max(e.outerRadius+n+a-u,0),h=c>0?c+n+a+u:0;let m=0;const p=r-l;if(n){const E=c>0?c-n:0,T=d>0?d-n:0,x=(E+T)/2,A=x!==0?p*x/(x+n):p;m=(p-A)/2}const v=Math.max(.001,p*d-a/PI)/d,y=(p-v)/2,w=l+y+m,_=r-y-m,{outerStart:D,outerEnd:k,innerStart:O,innerEnd:N}=parseBorderRadius$1(e,h,d,_-w),F=d-D,g=d-k,b=w+D/F,$=_-k/g,S=h+O,P=h+N,M=w+O/S,C=_-N/P;if(t.beginPath(),i){const E=(b+$)/2;if(t.arc(o,s,d,b,E),t.arc(o,s,d,E,$),k>0){const L=rThetaToXY(g,$,o,s);t.arc(L.x,L.y,k,$,_+HALF_PI)}const T=rThetaToXY(P,_,o,s);if(t.lineTo(T.x,T.y),N>0){const L=rThetaToXY(P,C,o,s);t.arc(L.x,L.y,N,_+HALF_PI,C+Math.PI)}const x=(_-N/h+(w+O/h))/2;if(t.arc(o,s,h,_-N/h,x,!0),t.arc(o,s,h,x,w+O/h,!0),O>0){const L=rThetaToXY(S,M,o,s);t.arc(L.x,L.y,O,M+Math.PI,w-HALF_PI)}const A=rThetaToXY(F,w,o,s);if(t.lineTo(A.x,A.y),D>0){const L=rThetaToXY(F,b,o,s);t.arc(L.x,L.y,D,w-HALF_PI,b)}}else{t.moveTo(o,s);const E=Math.cos(b)*d+o,T=Math.sin(b)*d+s;t.lineTo(E,T);const x=Math.cos($)*d+o,A=Math.sin($)*d+s;t.lineTo(x,A)}t.closePath()}function drawArc(t,e,a,n,r){const{fullCircles:i,startAngle:o,circumference:s}=e;let l=e.endAngle;if(i){pathArc(t,e,a,n,l,r);for(let u=0;u=TAU||_angleBetween(o,l,u),y=_isBetween(s,c+m,d+m);return v&&y}getCenterPoint(a){const{x:n,y:r,startAngle:i,endAngle:o,innerRadius:s,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],a),{offset:u,spacing:c}=this.options,d=(i+o)/2,h=(s+l+c+u)/2;return{x:n+Math.cos(d)*h,y:r+Math.sin(d)*h}}tooltipPosition(a){return this.getCenterPoint(a)}draw(a){const{options:n,circumference:r}=this,i=(n.offset||0)/4,o=(n.spacing||0)/2,s=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=r>TAU?Math.floor(r/TAU):0,r===0||this.innerRadius<0||this.outerRadius<0)return;a.save();const l=(this.startAngle+this.endAngle)/2;a.translate(Math.cos(l)*i,Math.sin(l)*i);const u=1-Math.sin(Math.min(PI,r||0)),c=i*u;a.fillStyle=n.backgroundColor,a.strokeStyle=n.borderColor,drawArc(a,this,c,o,s),drawBorder(a,this,c,o,s),a.restore()}}R(ArcElement,"id","arc"),R(ArcElement,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0}),R(ArcElement,"defaultRoutes",{backgroundColor:"backgroundColor"}),R(ArcElement,"descriptors",{_scriptable:!0,_indexable:a=>a!=="borderDash"});function setStyle$1(t,e,a=e){t.lineCap=valueOrDefault(a.borderCapStyle,e.borderCapStyle),t.setLineDash(valueOrDefault(a.borderDash,e.borderDash)),t.lineDashOffset=valueOrDefault(a.borderDashOffset,e.borderDashOffset),t.lineJoin=valueOrDefault(a.borderJoinStyle,e.borderJoinStyle),t.lineWidth=valueOrDefault(a.borderWidth,e.borderWidth),t.strokeStyle=valueOrDefault(a.borderColor,e.borderColor)}function lineTo(t,e,a){t.lineTo(a.x,a.y)}function getLineMethod(t){return t.stepped?_steppedLineTo:t.tension||t.cubicInterpolationMode==="monotone"?_bezierCurveTo:lineTo}function pathVars(t,e,a={}){const n=t.length,{start:r=0,end:i=n-1}=a,{start:o,end:s}=e,l=Math.max(r,o),u=Math.min(i,s),c=rs&&i>s;return{count:n,start:l,loop:e.loop,ilen:u(o+(u?s-k:k))%i,D=()=>{v!==y&&(t.lineTo(c,y),t.lineTo(c,v),t.lineTo(c,w))};for(l&&(m=r[_(0)],t.moveTo(m.x,m.y)),h=0;h<=s;++h){if(m=r[_(h)],m.skip)continue;const k=m.x,O=m.y,N=k|0;N===p?(Oy&&(y=O),c=(d*c+k)/++d):(D(),t.lineTo(k,O),p=N,d=0,v=y=O),w=O}D()}function _getSegmentMethod(t){const e=t.options,a=e.borderDash&&e.borderDash.length;return!t._decimated&&!t._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!a?fastPathSegment:pathSegment}function _getInterpolationMethod(t){return t.stepped?_steppedInterpolation:t.tension||t.cubicInterpolationMode==="monotone"?_bezierInterpolation:_pointInLine}function strokePathWithCache(t,e,a,n){let r=e._path;r||(r=e._path=new Path2D,e.path(r,a,n)&&r.closePath()),setStyle$1(t,e.options),t.stroke(r)}function strokePathDirect(t,e,a,n){const{segments:r,options:i}=e,o=_getSegmentMethod(e);for(const s of r)setStyle$1(t,i,s.style),t.beginPath(),o(t,e,s,{start:a,end:a+n-1})&&t.closePath(),t.stroke()}const usePath2D=typeof Path2D=="function";function draw(t,e,a,n){usePath2D&&!e.options.segment?strokePathWithCache(t,e,a,n):strokePathDirect(t,e,a,n)}class LineElement extends Element$1{constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,a){const n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){const r=n.spanGaps?this._loop:this._fullLoop;_updateBezierControlPoints(this._points,n,e,r,a),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this,this.options.segment))}first(){const e=this.segments,a=this.points;return e.length&&a[e[0].start]}last(){const e=this.segments,a=this.points,n=e.length;return n&&a[e[n-1].end]}interpolate(e,a){const n=this.options,r=e[a],i=this.points,o=_boundSegments(this,{property:a,start:r,end:r});if(!o.length)return;const s=[],l=_getInterpolationMethod(n);let u,c;for(u=0,c=o.length;ue!=="borderDash"&&e!=="fill"});function inRange$1(t,e,a,n){const r=t.options,{[a]:i}=t.getProps([a],n);return Math.abs(e-i)t.replace("rgb(","rgba(").replace(")",", 0.5)"));function getBorderColor(t){return BORDER_COLORS[t%BORDER_COLORS.length]}function getBackgroundColor(t){return BACKGROUND_COLORS[t%BACKGROUND_COLORS.length]}function colorizeDefaultDataset(t,e){return t.borderColor=getBorderColor(e),t.backgroundColor=getBackgroundColor(e),++e}function colorizeDoughnutDataset(t,e){return t.backgroundColor=t.data.map(()=>getBorderColor(e++)),e}function colorizePolarAreaDataset(t,e){return t.backgroundColor=t.data.map(()=>getBackgroundColor(e++)),e}function getColorizer(t){let e=0;return(a,n)=>{const r=t.getDatasetMeta(n).controller;r instanceof DoughnutController?e=colorizeDoughnutDataset(a,e):r instanceof PolarAreaController?e=colorizePolarAreaDataset(a,e):r&&(e=colorizeDefaultDataset(a,e))}}function containsColorsDefinitions(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}function containsColorsDefinition(t){return t&&(t.borderColor||t.backgroundColor)}var plugin_colors={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,a){if(!a.enabled)return;const{data:{datasets:n},options:r}=t.config,{elements:i}=r;if(!a.forceOverride&&(containsColorsDefinitions(n)||containsColorsDefinition(r)||i&&containsColorsDefinitions(i)))return;const o=getColorizer(t);n.forEach(o)}};function _segments(t,e,a){const n=t.segments,r=t.points,i=e.points,o=[];for(const s of n){let{start:l,end:u}=s;u=_findSegmentEnd(l,u,r);const c=_getBounds(a,r[l],r[u],s.loop);if(!e.segments){o.push({source:s,target:c,start:r[l],end:r[u]});continue}const d=_boundSegments(e,c);for(const h of d){const m=_getBounds(a,i[h.start],i[h.end],h.loop),p=_boundSegment(s,r,m);for(const v of p)o.push({source:v,target:h,start:{[a]:_getEdge(c,m,"start",Math.max)},end:{[a]:_getEdge(c,m,"end",Math.min)}})}}return o}function _getBounds(t,e,a,n){if(n)return;let r=e[t],i=a[t];return t==="angle"&&(r=_normalizeAngle(r),i=_normalizeAngle(i)),{property:t,start:r,end:i}}function _pointsFromSegments(t,e){const{x:a=null,y:n=null}=t||{},r=e.points,i=[];return e.segments.forEach(({start:o,end:s})=>{s=_findSegmentEnd(o,s,r);const l=r[o],u=r[s];n!==null?(i.push({x:l.x,y:n}),i.push({x:u.x,y:n})):a!==null&&(i.push({x:a,y:l.y}),i.push({x:a,y:u.y}))}),i}function _findSegmentEnd(t,e,a){for(;e>t;e--){const n=a[e];if(!isNaN(n.x)&&!isNaN(n.y))break}return e}function _getEdge(t,e,a,n){return t&&e?n(t[a],e[a]):t?t[a]:e?e[a]:0}function _createBoundaryLine(t,e){let a=[],n=!1;return isArray$c(t)?(n=!0,a=t):a=_pointsFromSegments(t,e),a.length?new LineElement({points:a,options:{tension:0},_loop:n,_fullLoop:n}):null}function _shouldApplyFill(t){return t&&t.fill!==!1}function _resolveTarget(t,e,a){let r=t[e].fill;const i=[e];let o;if(!a)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!isNumberFinite(r))return r;if(o=t[r],!o)return!1;if(o.visible)return r;i.push(r),r=o.fill}return!1}function _decodeFill(t,e,a){const n=parseFillOption(t);if(isObject$8(n))return isNaN(n.value)?!1:n;let r=parseFloat(n);return isNumberFinite(r)&&Math.floor(r)===r?decodeTargetIndex(n[0],e,r,a):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function decodeTargetIndex(t,e,a,n){return(t==="-"||t==="+")&&(a=e+a),a===e||a<0||a>=n?!1:a}function _getTargetPixel(t,e){let a=null;return t==="start"?a=e.bottom:t==="end"?a=e.top:isObject$8(t)?a=e.getPixelForValue(t.value):e.getBasePixel&&(a=e.getBasePixel()),a}function _getTargetValue(t,e,a){let n;return t==="start"?n=a:t==="end"?n=e.options.reverse?e.min:e.max:isObject$8(t)?n=t.value:n=e.getBaseValue(),n}function parseFillOption(t){const e=t.options,a=e.fill;let n=valueOrDefault(a&&a.target,a);return n===void 0&&(n=!!e.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function _buildStackLine(t){const{scale:e,index:a,line:n}=t,r=[],i=n.segments,o=n.points,s=getLinesBelow(e,a);s.push(_createBoundaryLine({x:null,y:e.bottom},n));for(let l=0;l=0;--o){const s=r[o].$filler;s&&(s.line.updateControlPoints(i,s.axis),n&&s.fill&&_drawfill(t.ctx,s,i))}},beforeDatasetsDraw(t,e,a){if(a.drawTime!=="beforeDatasetsDraw")return;const n=t.getSortedVisibleDatasetMetas();for(let r=n.length-1;r>=0;--r){const i=n[r].$filler;_shouldApplyFill(i)&&_drawfill(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,a){const n=e.meta.$filler;!_shouldApplyFill(n)||a.drawTime!=="beforeDatasetDraw"||_drawfill(t.ctx,n,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const getBoxSize=(t,e)=>{let{boxHeight:a=e,boxWidth:n=e}=t;return t.usePointStyle&&(a=Math.min(a,e),n=t.pointStyleWidth||Math.min(n,e)),{boxWidth:n,boxHeight:a,itemHeight:Math.max(e,a)}},itemsEqual=(t,e)=>t!==null&&e!==null&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Legend extends Element$1{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,a,n){this.maxWidth=e,this.maxHeight=a,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const e=this.options.labels||{};let a=callback(e.generateLabels,[this.chart],this)||[];e.filter&&(a=a.filter(n=>e.filter(n,this.chart.data))),e.sort&&(a=a.sort((n,r)=>e.sort(n,r,this.chart.data))),this.options.reverse&&a.reverse(),this.legendItems=a}fit(){const{options:e,ctx:a}=this;if(!e.display){this.width=this.height=0;return}const n=e.labels,r=toFont(n.font),i=r.size,o=this._computeTitleHeight(),{boxWidth:s,itemHeight:l}=getBoxSize(n,i);let u,c;a.font=r.string,this.isHorizontal()?(u=this.maxWidth,c=this._fitRows(o,i,s,l)+10):(c=this.maxHeight,u=this._fitCols(o,r,s,l)+10),this.width=Math.min(u,e.maxWidth||this.maxWidth),this.height=Math.min(c,e.maxHeight||this.maxHeight)}_fitRows(e,a,n,r){const{ctx:i,maxWidth:o,options:{labels:{padding:s}}}=this,l=this.legendHitBoxes=[],u=this.lineWidths=[0],c=r+s;let d=e;i.textAlign="left",i.textBaseline="middle";let h=-1,m=-c;return this.legendItems.forEach((p,v)=>{const y=n+a/2+i.measureText(p.text).width;(v===0||u[u.length-1]+y+2*s>o)&&(d+=c,u[u.length-(v>0?0:1)]=0,m+=c,h++),l[v]={left:0,top:m,row:h,width:y,height:r},u[u.length-1]+=y+s}),d}_fitCols(e,a,n,r){const{ctx:i,maxHeight:o,options:{labels:{padding:s}}}=this,l=this.legendHitBoxes=[],u=this.columnSizes=[],c=o-e;let d=s,h=0,m=0,p=0,v=0;return this.legendItems.forEach((y,w)=>{const{itemWidth:_,itemHeight:D}=calculateItemSize(n,a,i,y,r);w>0&&m+D+2*s>c&&(d+=h+s,u.push({width:h,height:m}),p+=h+s,v++,h=m=0),l[w]={left:p,top:m,col:v,width:_,height:D},h=Math.max(h,_),m+=D+s}),d+=h,u.push({width:h,height:m}),d}adjustHitBoxes(){if(!this.options.display)return;const e=this._computeTitleHeight(),{legendHitBoxes:a,options:{align:n,labels:{padding:r},rtl:i}}=this,o=getRtlAdapter(i,this.left,this.width);if(this.isHorizontal()){let s=0,l=_alignStartEnd(n,this.left+r,this.right-this.lineWidths[s]);for(const u of a)s!==u.row&&(s=u.row,l=_alignStartEnd(n,this.left+r,this.right-this.lineWidths[s])),u.top+=this.top+e+r,u.left=o.leftForLtr(o.x(l),u.width),l+=u.width+r}else{let s=0,l=_alignStartEnd(n,this.top+e+r,this.bottom-this.columnSizes[s].height);for(const u of a)u.col!==s&&(s=u.col,l=_alignStartEnd(n,this.top+e+r,this.bottom-this.columnSizes[s].height)),u.top=l,u.left+=this.left+r,u.left=o.leftForLtr(o.x(u.left),u.width),l+=u.height+r}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const e=this.ctx;clipArea(e,this),this._draw(),unclipArea(e)}}_draw(){const{options:e,columnSizes:a,lineWidths:n,ctx:r}=this,{align:i,labels:o}=e,s=defaults.color,l=getRtlAdapter(e.rtl,this.left,this.width),u=toFont(o.font),{padding:c}=o,d=u.size,h=d/2;let m;this.drawTitle(),r.textAlign=l.textAlign("left"),r.textBaseline="middle",r.lineWidth=.5,r.font=u.string;const{boxWidth:p,boxHeight:v,itemHeight:y}=getBoxSize(o,d),w=function(N,F,g){if(isNaN(p)||p<=0||isNaN(v)||v<0)return;r.save();const b=valueOrDefault(g.lineWidth,1);if(r.fillStyle=valueOrDefault(g.fillStyle,s),r.lineCap=valueOrDefault(g.lineCap,"butt"),r.lineDashOffset=valueOrDefault(g.lineDashOffset,0),r.lineJoin=valueOrDefault(g.lineJoin,"miter"),r.lineWidth=b,r.strokeStyle=valueOrDefault(g.strokeStyle,s),r.setLineDash(valueOrDefault(g.lineDash,[])),o.usePointStyle){const $={radius:v*Math.SQRT2/2,pointStyle:g.pointStyle,rotation:g.rotation,borderWidth:b},S=l.xPlus(N,p/2),P=F+h;drawPointLegend(r,$,S,P,o.pointStyleWidth&&p)}else{const $=F+Math.max((d-v)/2,0),S=l.leftForLtr(N,p),P=toTRBLCorners(g.borderRadius);r.beginPath(),Object.values(P).some(M=>M!==0)?addRoundedRectPath(r,{x:S,y:$,w:p,h:v,radius:P}):r.rect(S,$,p,v),r.fill(),b!==0&&r.stroke()}r.restore()},_=function(N,F,g){renderText(r,g.text,N,F+y/2,u,{strikethrough:g.hidden,textAlign:l.textAlign(g.textAlign)})},D=this.isHorizontal(),k=this._computeTitleHeight();D?m={x:_alignStartEnd(i,this.left+c,this.right-n[0]),y:this.top+c+k,line:0}:m={x:this.left+c,y:_alignStartEnd(i,this.top+k+c,this.bottom-a[0].height),line:0},overrideTextDirection(this.ctx,e.textDirection);const O=y+c;this.legendItems.forEach((N,F)=>{r.strokeStyle=N.fontColor,r.fillStyle=N.fontColor;const g=r.measureText(N.text).width,b=l.textAlign(N.textAlign||(N.textAlign=o.textAlign)),$=p+h+g;let S=m.x,P=m.y;l.setWidth(this.width),D?F>0&&S+$+c>this.right&&(P=m.y+=O,m.line++,S=m.x=_alignStartEnd(i,this.left+c,this.right-n[m.line])):F>0&&P+O>this.bottom&&(S=m.x=S+a[m.line].width+c,m.line++,P=m.y=_alignStartEnd(i,this.top+k+c,this.bottom-a[m.line].height));const M=l.x(S);if(w(M,P,N),S=_textX(b,S+p+h,D?S+$:this.right,e.rtl),_(l.x(S),P,N),D)m.x+=$+c;else if(typeof N.text!="string"){const C=u.lineHeight;m.y+=calculateLegendItemHeight(N,C)+c}else m.y+=O}),restoreTextDirection(this.ctx,e.textDirection)}drawTitle(){const e=this.options,a=e.title,n=toFont(a.font),r=toPadding(a.padding);if(!a.display)return;const i=getRtlAdapter(e.rtl,this.left,this.width),o=this.ctx,s=a.position,l=n.size/2,u=r.top+l;let c,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),c=this.top+u,d=_alignStartEnd(e.align,d,this.right-h);else{const p=this.columnSizes.reduce((v,y)=>Math.max(v,y.height),0);c=u+_alignStartEnd(e.align,this.top,this.bottom-p-e.labels.padding-this._computeTitleHeight())}const m=_alignStartEnd(s,d,d+h);o.textAlign=i.textAlign(_toLeftRightCenter(s)),o.textBaseline="middle",o.strokeStyle=a.color,o.fillStyle=a.color,o.font=n.string,renderText(o,a.text,m,c,n)}_computeTitleHeight(){const e=this.options.title,a=toFont(e.font),n=toPadding(e.padding);return e.display?a.lineHeight+n.height:0}_getLegendItemAt(e,a){let n,r,i;if(_isBetween(e,this.left,this.right)&&_isBetween(a,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ni.length>o.length?i:o)),e+a.size/2+n.measureText(r).width}function calculateItemHeight(t,e,a){let n=t;return typeof e.text!="string"&&(n=calculateLegendItemHeight(e,a)),n}function calculateLegendItemHeight(t,e){const a=t.text?t.text.length:0;return e*a}function isListened(t,e){return!!((t==="mousemove"||t==="mouseout")&&(e.onHover||e.onLeave)||e.onClick&&(t==="click"||t==="mouseup"))}var plugin_legend={id:"legend",_element:Legend,start(t,e,a){const n=t.legend=new Legend({ctx:t.ctx,options:a,chart:t});layouts.configure(t,n,a),layouts.addBox(t,n)},stop(t){layouts.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,a){const n=t.legend;layouts.configure(t,n,a),n.options=a},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,a){const n=e.datasetIndex,r=a.chart;r.isDatasetVisible(n)?(r.hide(n),e.hidden=!0):(r.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:a,pointStyle:n,textAlign:r,color:i,useBorderRadius:o,borderRadius:s}}=t.legend.options;return t._getSortedDatasetMetas().map(l=>{const u=l.controller.getStyle(a?0:void 0),c=toPadding(u.borderWidth);return{text:e[l.index].label,fillStyle:u.backgroundColor,fontColor:i,hidden:!l.visible,lineCap:u.borderCapStyle,lineDash:u.borderDash,lineDashOffset:u.borderDashOffset,lineJoin:u.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:u.borderColor,pointStyle:n||u.pointStyle,rotation:u.rotation,textAlign:r||u.textAlign,borderRadius:o&&(s||u.borderRadius),datasetIndex:l.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};const positioners={average(t){if(!t.length)return!1;let e,a,n=0,r=0,i=0;for(e=0,a=t.length;es({chart:e,initial:a.initial,numSteps:o,currentStep:Math.min(n-a.start,o)}))}_refresh(){this._request||(this._running=!0,this._request=requestAnimFrame.call(window,()=>{this._update(),this._request=null,this._running&&this._refresh()}))}_update(e=Date.now()){let a=0;this._charts.forEach((n,r)=>{if(!n.running||!n.items.length)return;const i=n.items;let o=i.length-1,s=!1,l;for(;o>=0;--o)l=i[o],l._active?(l._total>n.duration&&(n.duration=l._total),l.tick(e),s=!0):(i[o]=i[i.length-1],i.pop());s&&(r.draw(),this._notify(r,n,e,"progress")),i.length||(n.running=!1,this._notify(r,n,e,"complete"),n.initial=!1),a+=i.length}),this._lastDate=e,a===0&&(this._running=!1)}_getAnims(e){const a=this._charts;let n=a.get(e);return n||(n={running:!1,initial:!0,items:[],listeners:{complete:[],progress:[]}},a.set(e,n)),n}listen(e,a,n){this._getAnims(e).listeners[a].push(n)}add(e,a){!a||!a.length||this._getAnims(e).items.push(...a)}has(e){return this._getAnims(e).items.length>0}start(e){const a=this._charts.get(e);a&&(a.running=!0,a.start=Date.now(),a.duration=a.items.reduce((n,r)=>Math.max(n,r._duration),0),this._refresh())}running(e){if(!this._running)return!1;const a=this._charts.get(e);return!(!a||!a.running||!a.items.length)}stop(e){const a=this._charts.get(e);if(!a||!a.items.length)return;const n=a.items;let r=n.length-1;for(;r>=0;--r)n[r].cancel();a.items=[],this._notify(e,a,Date.now(),"complete")}remove(e){return this._charts.delete(e)}}var animator=new Animator;const transparent="transparent",interpolators={boolean(t,e,a){return a>.5?e:t},color(t,e,a){const n=color(t||transparent),r=n.valid&&color(e||transparent);return r&&r.valid?r.mix(n,a).hexString():e},number(t,e,a){return t+(e-t)*a}};class Animation{constructor(e,a,n,r){const i=a[n];r=resolve([e.to,r,i,e.from]);const o=resolve([e.from,i,r]);this._active=!0,this._fn=e.fn||interpolators[e.type||typeof o],this._easing=effects[e.easing]||effects.linear,this._start=Math.floor(Date.now()+(e.delay||0)),this._duration=this._total=Math.floor(e.duration),this._loop=!!e.loop,this._target=a,this._prop=n,this._from=o,this._to=r,this._promises=void 0}active(){return this._active}update(e,a,n){if(this._active){this._notify(!1);const r=this._target[this._prop],i=n-this._start,o=this._duration-i;this._start=n,this._duration=Math.floor(Math.max(o,e.duration)),this._total+=i,this._loop=!!e.loop,this._to=resolve([e.to,a,r,e.from]),this._from=resolve([e.from,r,a])}}cancel(){this._active&&(this.tick(Date.now()),this._active=!1,this._notify(!1))}tick(e){const a=e-this._start,n=this._duration,r=this._prop,i=this._from,o=this._loop,s=this._to;let l;if(this._active=i!==s&&(o||a1?2-l:l,l=this._easing(Math.min(1,Math.max(0,l))),this._target[r]=this._fn(i,s,l)}wait(){const e=this._promises||(this._promises=[]);return new Promise((a,n)=>{e.push({res:a,rej:n})})}_notify(e){const a=e?"res":"rej",n=this._promises||[];for(let r=0;r{const i=e[r];if(!isObject$8(i))return;const o={};for(const s of a)o[s]=i[s];(isArray$c(i.properties)&&i.properties||[r]).forEach(s=>{(s===r||!n.has(s))&&n.set(s,o)})})}_animateOptions(e,a){const n=a.options,r=resolveTargetOptions(e,n);if(!r)return[];const i=this._createAnimations(r,n);return n.$shared&&awaitAll(e.options.$animations,n).then(()=>{e.options=n},()=>{}),i}_createAnimations(e,a){const n=this._properties,r=[],i=e.$animations||(e.$animations={}),o=Object.keys(a),s=Date.now();let l;for(l=o.length-1;l>=0;--l){const u=o[l];if(u.charAt(0)==="$")continue;if(u==="options"){r.push(...this._animateOptions(e,a));continue}const c=a[u];let d=i[u];const h=n.get(u);if(d)if(h&&d.active()){d.update(h,c,s);continue}else d.cancel();if(!h||!h.duration){e[u]=c;continue}i[u]=d=new Animation(h,e,u,c),r.push(d)}return r}update(e,a){if(this._properties.size===0){Object.assign(e,a);return}const n=this._createAnimations(e,a);if(n.length)return animator.add(this._chart,n),!0}}function awaitAll(t,e){const a=[],n=Object.keys(e);for(let r=0;r0||!a&&i<0)return r.index}return null}function updateStacks(t,e){const{chart:a,_cachedMeta:n}=t,r=a._stacks||(a._stacks={}),{iScale:i,vScale:o,index:s}=n,l=i.axis,u=o.axis,c=getStackKey(i,o,n),d=e.length;let h;for(let m=0;ma[n].axis===e).shift()}function createDatasetContext(t,e){return createContext(t,{active:!1,dataset:void 0,datasetIndex:e,index:e,mode:"default",type:"dataset"})}function createDataContext(t,e,a){return createContext(t,{active:!1,dataIndex:e,parsed:void 0,raw:void 0,element:a,index:e,mode:"default",type:"data"})}function clearStacks(t,e){const a=t.controller.index,n=t.vScale&&t.vScale.axis;if(n){e=e||t._parsed;for(const r of e){const i=r._stacks;if(!i||i[n]===void 0||i[n][a]===void 0)return;delete i[n][a],i[n]._visualValues!==void 0&&i[n]._visualValues[a]!==void 0&&delete i[n]._visualValues[a]}}}const isDirectUpdateMode=t=>t==="reset"||t==="none",cloneIfNotShared=(t,e)=>e?t:Object.assign({},t),createStack=(t,e,a)=>t&&!e.hidden&&e._stacked&&{keys:getSortedDatasetIndices(a,!0),values:null};class DatasetController{constructor(e,a){this.chart=e,this._ctx=e.ctx,this.index=a,this._cachedDataOpts={},this._cachedMeta=this.getMeta(),this._type=this._cachedMeta.type,this.options=void 0,this._parsing=!1,this._data=void 0,this._objectData=void 0,this._sharedOptions=void 0,this._drawStart=void 0,this._drawCount=void 0,this.enableOptionSharing=!1,this.supportsDecimation=!1,this.$context=void 0,this._syncList=[],this.datasetElementType=new.target.datasetElementType,this.dataElementType=new.target.dataElementType,this.initialize()}initialize(){const e=this._cachedMeta;this.configure(),this.linkScales(),e._stacked=isStacked(e.vScale,e),this.addElements(),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(e){this.index!==e&&clearStacks(this._cachedMeta),this.index=e}linkScales(){const e=this.chart,a=this._cachedMeta,n=this.getDataset(),r=(d,h,m,p)=>d==="x"?h:d==="r"?p:m,i=a.xAxisID=valueOrDefault(n.xAxisID,getFirstScaleId(e,"x")),o=a.yAxisID=valueOrDefault(n.yAxisID,getFirstScaleId(e,"y")),s=a.rAxisID=valueOrDefault(n.rAxisID,getFirstScaleId(e,"r")),l=a.indexAxis,u=a.iAxisID=r(l,i,o,s),c=a.vAxisID=r(l,o,i,s);a.xScale=this.getScaleForId(i),a.yScale=this.getScaleForId(o),a.rScale=this.getScaleForId(s),a.iScale=this.getScaleForId(u),a.vScale=this.getScaleForId(c)}getDataset(){return this.chart.data.datasets[this.index]}getMeta(){return this.chart.getDatasetMeta(this.index)}getScaleForId(e){return this.chart.scales[e]}_getOtherScale(e){const a=this._cachedMeta;return e===a.iScale?a.vScale:a.iScale}reset(){this._update("reset")}_destroy(){const e=this._cachedMeta;this._data&&unlistenArrayEvents(this._data,this),e._stacked&&clearStacks(e)}_dataCheck(){const e=this.getDataset(),a=e.data||(e.data=[]),n=this._data;if(isObject$8(a))this._data=convertObjectDataToArray(a);else if(n!==a){if(n){unlistenArrayEvents(n,this);const r=this._cachedMeta;clearStacks(r),r._parsed=[]}a&&Object.isExtensible(a)&&listenArrayEvents(a,this),this._syncList=[],this._data=a}}addElements(){const e=this._cachedMeta;this._dataCheck(),this.datasetElementType&&(e.dataset=new this.datasetElementType)}buildOrUpdateElements(e){const a=this._cachedMeta,n=this.getDataset();let r=!1;this._dataCheck();const i=a._stacked;a._stacked=isStacked(a.vScale,a),a.stack!==n.stack&&(r=!0,clearStacks(a),a.stack=n.stack),this._resyncElements(e),(r||i!==a._stacked)&&updateStacks(this,a._parsed)}configure(){const e=this.chart.config,a=e.datasetScopeKeys(this._type),n=e.getOptionScopes(this.getDataset(),a,!0);this.options=e.createResolver(n,this.getContext()),this._parsing=this.options.parsing,this._cachedDataOpts={}}parse(e,a){const{_cachedMeta:n,_data:r}=this,{iScale:i,_stacked:o}=n,s=i.axis;let l=e===0&&a===r.length?!0:n._sorted,u=e>0&&n._parsed[e-1],c,d,h;if(this._parsing===!1)n._parsed=r,n._sorted=!0,h=r;else{isArray$c(r[e])?h=this.parseArrayData(n,r,e,a):isObject$8(r[e])?h=this.parseObjectData(n,r,e,a):h=this.parsePrimitiveData(n,r,e,a);const m=()=>d[s]===null||u&&d[s]v||d=0;--h)if(!p()){this.updateRangeFromParsed(u,e,m,l);break}}return u}getAllParsedValues(e){const a=this._cachedMeta._parsed,n=[];let r,i,o;for(r=0,i=a.length;r=0&&ethis.getContext(n,r,a),v=u.resolveNamedOptions(h,m,p,d);return v.$shared&&(v.$shared=l,i[o]=Object.freeze(cloneIfNotShared(v,l))),v}_resolveAnimations(e,a,n){const r=this.chart,i=this._cachedDataOpts,o=`animation-${a}`,s=i[o];if(s)return s;let l;if(r.options.animation!==!1){const c=this.chart.config,d=c.datasetAnimationScopeKeys(this._type,a),h=c.getOptionScopes(this.getDataset(),d);l=c.createResolver(h,this.getContext(e,n,a))}const u=new Animations(r,l&&l.animations);return l&&l._cacheable&&(i[o]=Object.freeze(u)),u}getSharedOptions(e){if(e.$shared)return this._sharedOptions||(this._sharedOptions=Object.assign({},e))}includeOptions(e,a){return!a||isDirectUpdateMode(e)||this.chart._animationsDisabled}_getSharedOptions(e,a){const n=this.resolveDataElementOptions(e,a),r=this._sharedOptions,i=this.getSharedOptions(n),o=this.includeOptions(a,i)||i!==r;return this.updateSharedOptions(i,a,n),{sharedOptions:i,includeOptions:o}}updateElement(e,a,n,r){isDirectUpdateMode(r)?Object.assign(e,n):this._resolveAnimations(a,r).update(e,n)}updateSharedOptions(e,a,n){e&&!isDirectUpdateMode(a)&&this._resolveAnimations(void 0,a).update(e,n)}_setStyle(e,a,n,r){e.active=r;const i=this.getStyle(a,r);this._resolveAnimations(a,n,r).update(e,{options:!r&&this.getSharedOptions(i)||i})}removeHoverStyle(e,a,n){this._setStyle(e,n,"active",!1)}setHoverStyle(e,a,n){this._setStyle(e,n,"active",!0)}_removeDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!1)}_setDatasetHoverStyle(){const e=this._cachedMeta.dataset;e&&this._setStyle(e,void 0,"active",!0)}_resyncElements(e){const a=this._data,n=this._cachedMeta.data;for(const[s,l,u]of this._syncList)this[s](l,u);this._syncList=[];const r=n.length,i=a.length,o=Math.min(i,r);o&&this.parse(0,o),i>r?this._insertElements(r,i-r,e):i{for(u.length+=a,s=u.length-1;s>=o;s--)u[s]=u[s-a]};for(l(i),s=e;sr-i))}return t._cache.$bar}function computeMinSampleSize(t){const e=t.iScale,a=getAllScaleValues(e,t.type);let n=e._length,r,i,o,s;const l=()=>{o===32767||o===-32768||(defined$1(s)&&(n=Math.min(n,Math.abs(o-s)||n)),s=o)};for(r=0,i=a.length;r0?r[t-1]:null,s=tMath.abs(s)&&(l=s,u=o),e[a.axis]=u,e._custom={barStart:l,barEnd:u,start:r,end:i,min:o,max:s}}function parseValue(t,e,a,n){return isArray$c(t)?parseFloatBar(t,e,a,n):e[a.axis]=a.parse(t,n),e}function parseArrayOrPrimitive(t,e,a,n){const r=t.iScale,i=t.vScale,o=r.getLabels(),s=r===i,l=[];let u,c,d,h;for(u=a,c=a+n;u=a?1:-1)}function borderProps(t){let e,a,n,r,i;return t.horizontal?(e=t.base>t.x,a="left",n="right"):(e=t.basel.controller.options.grouped),i=n.options.stacked,o=[],s=l=>{const u=l.controller.getParsed(a),c=u&&u[l.vScale.axis];if(isNullOrUndef(c)||isNaN(c))return!0};for(const l of r)if(!(a!==void 0&&s(l))&&((i===!1||o.indexOf(l.stack)===-1||i===void 0&&l.stack===void 0)&&o.push(l.stack),l.index===e))break;return o.length||o.push(void 0),o}_getStackCount(e){return this._getStacks(void 0,e).length}_getStackIndex(e,a,n){const r=this._getStacks(e,n),i=a!==void 0?r.indexOf(a):-1;return i===-1?r.length-1:i}_getRuler(){const e=this.options,a=this._cachedMeta,n=a.iScale,r=[];let i,o;for(i=0,o=a.data.length;i_angleBetween(D,s,l,!0)?1:Math.max(k,k*a,O,O*a),p=(D,k,O)=>_angleBetween(D,s,l,!0)?-1:Math.min(k,k*a,O,O*a),v=m(0,u,d),y=m(HALF_PI,c,h),w=p(PI,u,d),_=p(PI+HALF_PI,c,h);n=(v-w)/2,r=(y-_)/2,i=-(v+w)/2,o=-(y+_)/2}return{ratioX:n,ratioY:r,offsetX:i,offsetY:o}}class DoughnutController extends DatasetController{constructor(e,a){super(e,a),this.enableOptionSharing=!0,this.innerRadius=void 0,this.outerRadius=void 0,this.offsetX=void 0,this.offsetY=void 0}linkScales(){}parse(e,a){const n=this.getDataset().data,r=this._cachedMeta;if(this._parsing===!1)r._parsed=n;else{let i=l=>+n[l];if(isObject$8(n[e])){const{key:l="value"}=this._parsing;i=u=>+resolveObjectKey(n[u],l)}let o,s;for(o=e,s=e+a;o0&&!isNaN(e)?TAU*(Math.abs(e)/a):0}getLabelAndValue(e){const a=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=formatNumber$1(a._parsed[e],n.options.locale);return{label:r[e]||"",value:i}}getMaxBorderWidth(e){let a=0;const n=this.chart;let r,i,o,s,l;if(!e){for(r=0,i=n.data.datasets.length;re!=="spacing",_indexable:e=>e!=="spacing"&&!e.startsWith("borderDash")&&!e.startsWith("hoverBorderDash")}),R(DoughnutController,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){const a=e.data;if(a.labels.length&&a.datasets.length){const{labels:{pointStyle:n,color:r}}=e.legend.options;return a.labels.map((i,o)=>{const l=e.getDatasetMeta(0).controller.getStyle(o);return{text:i,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:r,lineWidth:l.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(o),index:o}})}return[]}},onClick(e,a,n){n.chart.toggleDataVisibility(a.index),n.chart.update()}}}});class LineController extends DatasetController{initialize(){this.enableOptionSharing=!0,this.supportsDecimation=!0,super.initialize()}update(e){const a=this._cachedMeta,{dataset:n,data:r=[],_dataset:i}=a,o=this.chart._animationsDisabled;let{start:s,count:l}=_getStartAndCountOfVisiblePoints(a,r,o);this._drawStart=s,this._drawCount=l,_scaleRangesChanged(a)&&(s=0,l=r.length),n._chart=this.chart,n._datasetIndex=this.index,n._decimated=!!i._decimated,n.points=r;const u=this.resolveDatasetElementOptions(e);this.options.showLine||(u.borderWidth=0),u.segment=this.options.segment,this.updateElement(n,void 0,{animated:!o,options:u},e),this.updateElements(r,s,l,e)}updateElements(e,a,n,r){const i=r==="reset",{iScale:o,vScale:s,_stacked:l,_dataset:u}=this._cachedMeta,{sharedOptions:c,includeOptions:d}=this._getSharedOptions(a,r),h=o.axis,m=s.axis,{spanGaps:p,segment:v}=this.options,y=isNumber(p)?p:Number.POSITIVE_INFINITY,w=this.chart._animationsDisabled||i||r==="none",_=a+n,D=e.length;let k=a>0&&this.getParsed(a-1);for(let O=0;O=_){F.skip=!0;continue}const g=this.getParsed(O),b=isNullOrUndef(g[m]),$=F[h]=o.getPixelForValue(g[h],O),S=F[m]=i||b?s.getBasePixel():s.getPixelForValue(l?this.applyStack(s,g,l):g[m],O);F.skip=isNaN($)||isNaN(S)||b,F.stop=O>0&&Math.abs(g[h]-k[h])>y,v&&(F.parsed=g,F.raw=u.data[O]),d&&(F.options=c||this.resolveDataElementOptions(O,N.active?"active":r)),w||this.updateElement(N,O,F,r),k=g}}getMaxOverflow(){const e=this._cachedMeta,a=e.dataset,n=a.options&&a.options.borderWidth||0,r=e.data||[];if(!r.length)return n;const i=r[0].size(this.resolveDataElementOptions(0)),o=r[r.length-1].size(this.resolveDataElementOptions(r.length-1));return Math.max(n,i,o)/2}draw(){const e=this._cachedMeta;e.dataset.updateControlPoints(this.chart.chartArea,e.iScale.axis),super.draw()}}R(LineController,"id","line"),R(LineController,"defaults",{datasetElementType:"line",dataElementType:"point",showLine:!0,spanGaps:!1}),R(LineController,"overrides",{scales:{_index_:{type:"category"},_value_:{type:"linear"}}});class PolarAreaController extends DatasetController{constructor(e,a){super(e,a),this.innerRadius=void 0,this.outerRadius=void 0}getLabelAndValue(e){const a=this._cachedMeta,n=this.chart,r=n.data.labels||[],i=formatNumber$1(a._parsed[e].r,n.options.locale);return{label:r[e]||"",value:i}}parseObjectData(e,a,n,r){return _parseObjectDataRadialScale.bind(this)(e,a,n,r)}update(e){const a=this._cachedMeta.data;this._updateRadius(),this.updateElements(a,0,a.length,e)}getMinMax(){const e=this._cachedMeta,a={min:Number.POSITIVE_INFINITY,max:Number.NEGATIVE_INFINITY};return e.data.forEach((n,r)=>{const i=this.getParsed(r).r;!isNaN(i)&&this.chart.getDataVisibility(r)&&(ia.max&&(a.max=i))}),a}_updateRadius(){const e=this.chart,a=e.chartArea,n=e.options,r=Math.min(a.right-a.left,a.bottom-a.top),i=Math.max(r/2,0),o=Math.max(n.cutoutPercentage?i/100*n.cutoutPercentage:1,0),s=(i-o)/e.getVisibleDatasetCount();this.outerRadius=i-s*this.index,this.innerRadius=this.outerRadius-s}updateElements(e,a,n,r){const i=r==="reset",o=this.chart,l=o.options.animation,u=this._cachedMeta.rScale,c=u.xCenter,d=u.yCenter,h=u.getIndexAngle(0)-.5*PI;let m=h,p;const v=360/this.countVisibleElements();for(p=0;p{!isNaN(this.getParsed(r).r)&&this.chart.getDataVisibility(r)&&a++}),a}_computeAngle(e,a,n){return this.chart.getDataVisibility(e)?toRadians(this.resolveDataElementOptions(e,a).angle||n):0}}R(PolarAreaController,"id","polarArea"),R(PolarAreaController,"defaults",{dataElementType:"arc",animation:{animateRotate:!0,animateScale:!0},animations:{numbers:{type:"number",properties:["x","y","startAngle","endAngle","innerRadius","outerRadius"]}},indexAxis:"r",startAngle:0}),R(PolarAreaController,"overrides",{aspectRatio:1,plugins:{legend:{labels:{generateLabels(e){const a=e.data;if(a.labels.length&&a.datasets.length){const{labels:{pointStyle:n,color:r}}=e.legend.options;return a.labels.map((i,o)=>{const l=e.getDatasetMeta(0).controller.getStyle(o);return{text:i,fillStyle:l.backgroundColor,strokeStyle:l.borderColor,fontColor:r,lineWidth:l.borderWidth,pointStyle:n,hidden:!e.getDataVisibility(o),index:o}})}return[]}},onClick(e,a,n){n.chart.toggleDataVisibility(a.index),n.chart.update()}}},scales:{r:{type:"radialLinear",angleLines:{display:!1},beginAtZero:!0,grid:{circular:!0},pointLabels:{display:!1},startAngle:0}}});class PieController extends DoughnutController{}R(PieController,"id","pie"),R(PieController,"defaults",{cutout:0,rotation:0,circumference:360,radius:"100%"});function abstract(){throw new Error("This method is not implemented: Check that a complete date adapter is provided.")}class DateAdapterBase{constructor(e){R(this,"options");this.options=e||{}}static override(e){Object.assign(DateAdapterBase.prototype,e)}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(t,e,a,n){const{controller:r,data:i,_sorted:o}=t,s=r._cachedMeta.iScale;if(s&&e===s.axis&&e!=="r"&&o&&i.length){const l=s._reversePixels?_rlookupByKey:_lookupByKey;if(n){if(r._sharedOptions){const u=i[0],c=typeof u.getRange=="function"&&u.getRange(e);if(c){const d=l(i,e,a-c),h=l(i,e,a+c);return{lo:d.lo,hi:h.hi}}}}else return l(i,e,a)}return{lo:0,hi:i.length-1}}function evaluateInteractionItems(t,e,a,n,r){const i=t.getSortedVisibleDatasetMetas(),o=a[e];for(let s=0,l=i.length;s{l[o](e[a],r)&&(i.push({element:l,datasetIndex:u,index:c}),s=s||l.inRange(e.x,e.y,r))}),n&&!s?[]:i}var Interaction={evaluateInteractionItems,modes:{index(t,e,a,n){const r=getRelativePosition(e,t),i=a.axis||"x",o=a.includeInvisible||!1,s=a.intersect?getIntersectItems(t,r,i,n,o):getNearestItems(t,r,i,!1,n,o),l=[];return s.length?(t.getSortedVisibleDatasetMetas().forEach(u=>{const c=s[0].index,d=u.data[c];d&&!d.skip&&l.push({element:d,datasetIndex:u.index,index:c})}),l):[]},dataset(t,e,a,n){const r=getRelativePosition(e,t),i=a.axis||"xy",o=a.includeInvisible||!1;let s=a.intersect?getIntersectItems(t,r,i,n,o):getNearestItems(t,r,i,!1,n,o);if(s.length>0){const l=s[0].datasetIndex,u=t.getDatasetMeta(l).data;s=[];for(let c=0;ca.pos===e)}function filterDynamicPositionByAxis(t,e){return t.filter(a=>STATIC_POSITIONS.indexOf(a.pos)===-1&&a.box.axis===e)}function sortByWeight(t,e){return t.sort((a,n)=>{const r=e?n:a,i=e?a:n;return r.weight===i.weight?r.index-i.index:r.weight-i.weight})}function wrapBoxes(t){const e=[];let a,n,r,i,o,s;for(a=0,n=(t||[]).length;au.box.fullSize),!0),n=sortByWeight(filterByPosition(e,"left"),!0),r=sortByWeight(filterByPosition(e,"right")),i=sortByWeight(filterByPosition(e,"top"),!0),o=sortByWeight(filterByPosition(e,"bottom")),s=filterDynamicPositionByAxis(e,"x"),l=filterDynamicPositionByAxis(e,"y");return{fullSize:a,leftAndTop:n.concat(i),rightAndBottom:r.concat(l).concat(o).concat(s),chartArea:filterByPosition(e,"chartArea"),vertical:n.concat(r).concat(l),horizontal:i.concat(o).concat(s)}}function getCombinedMax(t,e,a,n){return Math.max(t[a],e[a])+Math.max(t[n],e[n])}function updateMaxPadding(t,e){t.top=Math.max(t.top,e.top),t.left=Math.max(t.left,e.left),t.bottom=Math.max(t.bottom,e.bottom),t.right=Math.max(t.right,e.right)}function updateDims(t,e,a,n){const{pos:r,box:i}=a,o=t.maxPadding;if(!isObject$8(r)){a.size&&(t[r]-=a.size);const d=n[a.stack]||{size:0,count:1};d.size=Math.max(d.size,a.horizontal?i.height:i.width),a.size=d.size/d.count,t[r]+=a.size}i.getPadding&&updateMaxPadding(o,i.getPadding());const s=Math.max(0,e.outerWidth-getCombinedMax(o,t,"left","right")),l=Math.max(0,e.outerHeight-getCombinedMax(o,t,"top","bottom")),u=s!==t.w,c=l!==t.h;return t.w=s,t.h=l,a.horizontal?{same:u,other:c}:{same:c,other:u}}function handleMaxPadding(t){const e=t.maxPadding;function a(n){const r=Math.max(e[n]-t[n],0);return t[n]+=r,r}t.y+=a("top"),t.x+=a("left"),a("right"),a("bottom")}function getMargins(t,e){const a=e.maxPadding;function n(r){const i={left:0,top:0,right:0,bottom:0};return r.forEach(o=>{i[o]=Math.max(e[o],a[o])}),i}return n(t?["left","right"]:["top","bottom"])}function fitBoxes(t,e,a,n){const r=[];let i,o,s,l,u,c;for(i=0,o=t.length,u=0;i{typeof v.beforeLayout=="function"&&v.beforeLayout()});const c=l.reduce((v,y)=>y.box.options&&y.box.options.display===!1?v:v+1,0)||1,d=Object.freeze({outerWidth:e,outerHeight:a,padding:r,availableWidth:i,availableHeight:o,vBoxMaxWidth:i/2/c,hBoxMaxHeight:o/2}),h=Object.assign({},r);updateMaxPadding(h,toPadding(n));const m=Object.assign({maxPadding:h,w:i,h:o,x:r.left,y:r.top},r),p=setLayoutDims(l.concat(u),d);fitBoxes(s.fullSize,m,d,p),fitBoxes(l,m,d,p),fitBoxes(u,m,d,p)&&fitBoxes(l,m,d,p),handleMaxPadding(m),placeBoxes(s.leftAndTop,m,d,p),m.x+=m.w,m.y+=m.h,placeBoxes(s.rightAndBottom,m,d,p),t.chartArea={left:m.left,top:m.top,right:m.left+m.w,bottom:m.top+m.h,height:m.h,width:m.w},each(s.chartArea,v=>{const y=v.box;Object.assign(y,t.chartArea),y.update(m.w,m.h,{left:0,top:0,right:0,bottom:0})})}};class BasePlatform{acquireContext(e,a){}releaseContext(e){return!1}addEventListener(e,a,n){}removeEventListener(e,a,n){}getDevicePixelRatio(){return 1}getMaximumSize(e,a,n,r){return a=Math.max(0,a||e.width),n=n||e.height,{width:a,height:Math.max(0,r?Math.floor(a/r):n)}}isAttached(e){return!0}updateConfig(e){}}class BasicPlatform extends BasePlatform{acquireContext(e){return e&&e.getContext&&e.getContext("2d")||null}updateConfig(e){e.options.animation=!1}}const EXPANDO_KEY="$chartjs",EVENT_TYPES={touchstart:"mousedown",touchmove:"mousemove",touchend:"mouseup",pointerenter:"mouseenter",pointerdown:"mousedown",pointermove:"mousemove",pointerup:"mouseup",pointerleave:"mouseout",pointerout:"mouseout"},isNullOrEmpty=t=>t===null||t==="";function initCanvas(t,e){const a=t.style,n=t.getAttribute("height"),r=t.getAttribute("width");if(t[EXPANDO_KEY]={initial:{height:n,width:r,style:{display:a.display,height:a.height,width:a.width}}},a.display=a.display||"block",a.boxSizing=a.boxSizing||"border-box",isNullOrEmpty(r)){const i=readUsedSize(t,"width");i!==void 0&&(t.width=i)}if(isNullOrEmpty(n))if(t.style.height==="")t.height=t.width/(e||2);else{const i=readUsedSize(t,"height");i!==void 0&&(t.height=i)}return t}const eventListenerOptions=supportsEventListenerOptions?{passive:!0}:!1;function addListener(t,e,a){t.addEventListener(e,a,eventListenerOptions)}function removeListener(t,e,a){t.canvas.removeEventListener(e,a,eventListenerOptions)}function fromNativeEvent(t,e){const a=EVENT_TYPES[t.type]||t.type,{x:n,y:r}=getRelativePosition(t,e);return{type:a,chart:e,native:t,x:n!==void 0?n:null,y:r!==void 0?r:null}}function nodeListContains(t,e){for(const a of t)if(a===e||a.contains(e))return!0}function createAttachObserver(t,e,a){const n=t.canvas,r=new MutationObserver(i=>{let o=!1;for(const s of i)o=o||nodeListContains(s.addedNodes,n),o=o&&!nodeListContains(s.removedNodes,n);o&&a()});return r.observe(document,{childList:!0,subtree:!0}),r}function createDetachObserver(t,e,a){const n=t.canvas,r=new MutationObserver(i=>{let o=!1;for(const s of i)o=o||nodeListContains(s.removedNodes,n),o=o&&!nodeListContains(s.addedNodes,n);o&&a()});return r.observe(document,{childList:!0,subtree:!0}),r}const drpListeningCharts=new Map;let oldDevicePixelRatio=0;function onWindowResize(){const t=window.devicePixelRatio;t!==oldDevicePixelRatio&&(oldDevicePixelRatio=t,drpListeningCharts.forEach((e,a)=>{a.currentDevicePixelRatio!==t&&e()}))}function listenDevicePixelRatioChanges(t,e){drpListeningCharts.size||window.addEventListener("resize",onWindowResize),drpListeningCharts.set(t,e)}function unlistenDevicePixelRatioChanges(t){drpListeningCharts.delete(t),drpListeningCharts.size||window.removeEventListener("resize",onWindowResize)}function createResizeObserver(t,e,a){const n=t.canvas,r=n&&_getParentNode(n);if(!r)return;const i=throttled((s,l)=>{const u=r.clientWidth;a(s,l),u{const l=s[0],u=l.contentRect.width,c=l.contentRect.height;u===0&&c===0||i(u,c)});return o.observe(r),listenDevicePixelRatioChanges(t,i),o}function releaseObserver(t,e,a){a&&a.disconnect(),e==="resize"&&unlistenDevicePixelRatioChanges(t)}function createProxyAndListen(t,e,a){const n=t.canvas,r=throttled(i=>{t.ctx!==null&&a(fromNativeEvent(i,t))},t);return addListener(n,e,r),r}class DomPlatform extends BasePlatform{acquireContext(e,a){const n=e&&e.getContext&&e.getContext("2d");return n&&n.canvas===e?(initCanvas(e,a),n):null}releaseContext(e){const a=e.canvas;if(!a[EXPANDO_KEY])return!1;const n=a[EXPANDO_KEY].initial;["height","width"].forEach(i=>{const o=n[i];isNullOrUndef(o)?a.removeAttribute(i):a.setAttribute(i,o)});const r=n.style||{};return Object.keys(r).forEach(i=>{a.style[i]=r[i]}),a.width=a.width,delete a[EXPANDO_KEY],!0}addEventListener(e,a,n){this.removeEventListener(e,a);const r=e.$proxies||(e.$proxies={}),o={attach:createAttachObserver,detach:createDetachObserver,resize:createResizeObserver}[a]||createProxyAndListen;r[a]=o(e,a,n)}removeEventListener(e,a){const n=e.$proxies||(e.$proxies={}),r=n[a];if(!r)return;({attach:releaseObserver,detach:releaseObserver,resize:releaseObserver}[a]||removeListener)(e,a,r),n[a]=void 0}getDevicePixelRatio(){return window.devicePixelRatio}getMaximumSize(e,a,n,r){return getMaximumSize(e,a,n,r)}isAttached(e){const a=_getParentNode(e);return!!(a&&a.isConnected)}}function _detectPlatform(t){return!_isDomSupported()||typeof OffscreenCanvas<"u"&&t instanceof OffscreenCanvas?BasicPlatform:DomPlatform}var ne;let Element$1=(ne=class{constructor(){R(this,"x");R(this,"y");R(this,"active",!1);R(this,"options");R(this,"$animations")}tooltipPosition(e){const{x:a,y:n}=this.getProps(["x","y"],e);return{x:a,y:n}}hasValue(){return isNumber(this.x)&&isNumber(this.y)}getProps(e,a){const n=this.$animations;if(!a||!n)return this;const r={};return e.forEach(i=>{r[i]=n[i]&&n[i].active()?n[i]._to:this[i]}),r}},R(ne,"defaults",{}),R(ne,"defaultRoutes"),ne);function autoSkip(t,e){const a=t.options.ticks,n=determineMaxTicks(t),r=Math.min(a.maxTicksLimit||n,n),i=a.major.enabled?getMajorIndices(e):[],o=i.length,s=i[0],l=i[o-1],u=[];if(o>r)return skipMajors(e,u,i,o/r),u;const c=calculateSpacing(i,e,r);if(o>0){let d,h;const m=o>1?Math.round((l-s)/(o-1)):null;for(skip(e,u,c,isNullOrUndef(m)?0:s-m,s),d=0,h=o-1;dr)return l}return Math.max(r,1)}function getMajorIndices(t){const e=[];let a,n;for(a=0,n=t.length;at==="left"?"right":t==="right"?"left":t,offsetFromEdge=(t,e,a)=>e==="top"||e==="left"?t[e]+a:t[e]-a,getTicksLimit=(t,e)=>Math.min(e||t,t);function sample(t,e){const a=[],n=t.length/e,r=t.length;let i=0;for(;io+s)))return l}function garbageCollect(t,e){each(t,a=>{const n=a.gc,r=n.length/2;let i;if(r>e){for(i=0;in?n:a,n=r&&a>n?a:n,{min:finiteOrDefault(a,finiteOrDefault(n,a)),max:finiteOrDefault(n,finiteOrDefault(a,n))}}getPadding(){return{left:this.paddingLeft||0,top:this.paddingTop||0,right:this.paddingRight||0,bottom:this.paddingBottom||0}}getTicks(){return this.ticks}getLabels(){const e=this.chart.data;return this.options.labels||(this.isHorizontal()?e.xLabels:e.yLabels)||e.labels||[]}getLabelItems(e=this.chart.chartArea){return this._labelItems||(this._labelItems=this._computeLabelItems(e))}beforeLayout(){this._cache={},this._dataLimitsCached=!1}beforeUpdate(){callback(this.options.beforeUpdate,[this])}update(e,a,n){const{beginAtZero:r,grace:i,ticks:o}=this.options,s=o.sampleSize;this.beforeUpdate(),this.maxWidth=e,this.maxHeight=a,this._margins=n=Object.assign({left:0,right:0,top:0,bottom:0},n),this.ticks=null,this._labelSizes=null,this._gridLineItems=null,this._labelItems=null,this.beforeSetDimensions(),this.setDimensions(),this.afterSetDimensions(),this._maxLength=this.isHorizontal()?this.width+n.left+n.right:this.height+n.top+n.bottom,this._dataLimitsCached||(this.beforeDataLimits(),this.determineDataLimits(),this.afterDataLimits(),this._range=_addGrace(this,i,r),this._dataLimitsCached=!0),this.beforeBuildTicks(),this.ticks=this.buildTicks()||[],this.afterBuildTicks();const l=s=i||n<=1||!this.isHorizontal()){this.labelRotation=r;return}const c=this._getLabelSizes(),d=c.widest.width,h=c.highest.height,m=_limitValue(this.chart.width-d,0,this.maxWidth);s=e.offset?this.maxWidth/n:m/(n-1),d+6>s&&(s=m/(n-(e.offset?.5:1)),l=this.maxHeight-getTickMarkLength(e.grid)-a.padding-getTitleHeight(e.title,this.chart.options.font),u=Math.sqrt(d*d+h*h),o=toDegrees(Math.min(Math.asin(_limitValue((c.highest.height+6)/s,-1,1)),Math.asin(_limitValue(l/u,-1,1))-Math.asin(_limitValue(h/u,-1,1)))),o=Math.max(r,Math.min(i,o))),this.labelRotation=o}afterCalculateLabelRotation(){callback(this.options.afterCalculateLabelRotation,[this])}afterAutoSkip(){}beforeFit(){callback(this.options.beforeFit,[this])}fit(){const e={width:0,height:0},{chart:a,options:{ticks:n,title:r,grid:i}}=this,o=this._isVisible(),s=this.isHorizontal();if(o){const l=getTitleHeight(r,a.options.font);if(s?(e.width=this.maxWidth,e.height=getTickMarkLength(i)+l):(e.height=this.maxHeight,e.width=getTickMarkLength(i)+l),n.display&&this.ticks.length){const{first:u,last:c,widest:d,highest:h}=this._getLabelSizes(),m=n.padding*2,p=toRadians(this.labelRotation),v=Math.cos(p),y=Math.sin(p);if(s){const w=n.mirror?0:y*d.width+v*h.height;e.height=Math.min(this.maxHeight,e.height+w+m)}else{const w=n.mirror?0:v*d.width+y*h.height;e.width=Math.min(this.maxWidth,e.width+w+m)}this._calculatePadding(u,c,y,v)}}this._handleMargins(),s?(this.width=this._length=a.width-this._margins.left-this._margins.right,this.height=e.height):(this.width=e.width,this.height=this._length=a.height-this._margins.top-this._margins.bottom)}_calculatePadding(e,a,n,r){const{ticks:{align:i,padding:o},position:s}=this.options,l=this.labelRotation!==0,u=s!=="top"&&this.axis==="x";if(this.isHorizontal()){const c=this.getPixelForTick(0)-this.left,d=this.right-this.getPixelForTick(this.ticks.length-1);let h=0,m=0;l?u?(h=r*e.width,m=n*a.height):(h=n*e.height,m=r*a.width):i==="start"?m=a.width:i==="end"?h=e.width:i!=="inner"&&(h=e.width/2,m=a.width/2),this.paddingLeft=Math.max((h-c+o)*this.width/(this.width-c),0),this.paddingRight=Math.max((m-d+o)*this.width/(this.width-d),0)}else{let c=a.height/2,d=e.height/2;i==="start"?(c=0,d=e.height):i==="end"&&(c=a.height,d=0),this.paddingTop=c+o,this.paddingBottom=d+o}}_handleMargins(){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:e,position:a}=this.options;return a==="top"||a==="bottom"||e==="x"}isFullSize(){return this.options.fullSize}_convertTicksToLabels(e){this.beforeTickToLabelConversion(),this.generateTickLabels(e);let a,n;for(a=0,n=e.length;a({width:o[b]||0,height:s[b]||0});return{first:g(0),last:g(a-1),widest:g(N),highest:g(F),widths:o,heights:s}}getLabelForValue(e){return e}getPixelForValue(e,a){return NaN}getValueForPixel(e){}getPixelForTick(e){const a=this.ticks;return e<0||e>a.length-1?null:this.getPixelForValue(a[e].value)}getPixelForDecimal(e){this._reversePixels&&(e=1-e);const a=this._startPixel+e*this._length;return _int16Range(this._alignToPixels?_alignPixel(this.chart,a,0):a)}getDecimalForPixel(e){const a=(e-this._startPixel)/this._length;return this._reversePixels?1-a:a}getBasePixel(){return this.getPixelForValue(this.getBaseValue())}getBaseValue(){const{min:e,max:a}=this;return e<0&&a<0?a:e>0&&a>0?e:0}getContext(e){const a=this.ticks||[];if(e>=0&&es*r?s/n:l/r:l*r0}_computeGridLineItems(e){const a=this.axis,n=this.chart,r=this.options,{grid:i,position:o,border:s}=r,l=i.offset,u=this.isHorizontal(),d=this.ticks.length+(l?1:0),h=getTickMarkLength(i),m=[],p=s.setContext(this.getContext()),v=p.display?p.width:0,y=v/2,w=function(T){return _alignPixel(n,T,v)};let _,D,k,O,N,F,g,b,$,S,P,M;if(o==="top")_=w(this.bottom),F=this.bottom-h,b=_-y,S=w(e.top)+y,M=e.bottom;else if(o==="bottom")_=w(this.top),S=e.top,M=w(e.bottom)-y,F=_+y,b=this.top+h;else if(o==="left")_=w(this.right),N=this.right-h,g=_-y,$=w(e.left)+y,P=e.right;else if(o==="right")_=w(this.left),$=e.left,P=w(e.right)-y,N=_+y,g=this.left+h;else if(a==="x"){if(o==="center")_=w((e.top+e.bottom)/2+.5);else if(isObject$8(o)){const T=Object.keys(o)[0],x=o[T];_=w(this.chart.scales[T].getPixelForValue(x))}S=e.top,M=e.bottom,F=_+y,b=F+h}else if(a==="y"){if(o==="center")_=w((e.left+e.right)/2);else if(isObject$8(o)){const T=Object.keys(o)[0],x=o[T];_=w(this.chart.scales[T].getPixelForValue(x))}N=_-y,g=N-h,$=e.left,P=e.right}const C=valueOrDefault(r.ticks.maxTicksLimit,d),E=Math.max(1,Math.ceil(d/C));for(D=0;Di.value===e);return r>=0?a.setContext(this.getContext(r)).lineWidth:0}drawGrid(e){const a=this.options.grid,n=this.ctx,r=this._gridLineItems||(this._gridLineItems=this._computeGridLineItems(e));let i,o;const s=(l,u,c)=>{!c.width||!c.color||(n.save(),n.lineWidth=c.width,n.strokeStyle=c.color,n.setLineDash(c.borderDash||[]),n.lineDashOffset=c.borderDashOffset,n.beginPath(),n.moveTo(l.x,l.y),n.lineTo(u.x,u.y),n.stroke(),n.restore())};if(a.display)for(i=0,o=r.length;i{this.draw(i)}}]:[{z:n,draw:i=>{this.drawBackground(),this.drawGrid(i),this.drawTitle()}},{z:r,draw:()=>{this.drawBorder()}},{z:a,draw:i=>{this.drawLabels(i)}}]}getMatchingVisibleMetas(e){const a=this.chart.getSortedVisibleDatasetMetas(),n=this.axis+"AxisID",r=[];let i,o;for(i=0,o=a.length;i{const n=a.split("."),r=n.pop(),i=[t].concat(n).join("."),o=e[a].split("."),s=o.pop(),l=o.join(".");defaults.route(i,r,l,s)})}function isIChartComponent(t){return"id"in t&&"defaults"in t}class Registry{constructor(){this.controllers=new TypedRegistry(DatasetController,"datasets",!0),this.elements=new TypedRegistry(Element$1,"elements"),this.plugins=new TypedRegistry(Object,"plugins"),this.scales=new TypedRegistry(Scale,"scales"),this._typedRegistries=[this.controllers,this.scales,this.elements]}add(...e){this._each("register",e)}remove(...e){this._each("unregister",e)}addControllers(...e){this._each("register",e,this.controllers)}addElements(...e){this._each("register",e,this.elements)}addPlugins(...e){this._each("register",e,this.plugins)}addScales(...e){this._each("register",e,this.scales)}getController(e){return this._get(e,this.controllers,"controller")}getElement(e){return this._get(e,this.elements,"element")}getPlugin(e){return this._get(e,this.plugins,"plugin")}getScale(e){return this._get(e,this.scales,"scale")}removeControllers(...e){this._each("unregister",e,this.controllers)}removeElements(...e){this._each("unregister",e,this.elements)}removePlugins(...e){this._each("unregister",e,this.plugins)}removeScales(...e){this._each("unregister",e,this.scales)}_each(e,a,n){[...a].forEach(r=>{const i=n||this._getRegistryForType(r);n||i.isForType(r)||i===this.plugins&&r.id?this._exec(e,i,r):each(r,o=>{const s=n||this._getRegistryForType(o);this._exec(e,s,o)})})}_exec(e,a,n){const r=_capitalize(e);callback(n["before"+r],[],n),a[e](n),callback(n["after"+r],[],n)}_getRegistryForType(e){for(let a=0;ai.filter(s=>!o.some(l=>s.plugin.id===l.plugin.id));this._notify(r(a,n),e,"stop"),this._notify(r(n,a),e,"start")}}function allPlugins(t){const e={},a=[],n=Object.keys(registry.plugins.items);for(let i=0;i1&&idMatchesAxis(t[0].toLowerCase());if(n)return n}throw new Error(`Cannot determine type of '${t}' axis. Please provide 'axis' or 'position' option.`)}function getAxisFromDataset(t,e,a){if(a[e+"AxisID"]===t)return{axis:e}}function retrieveAxisFromDatasets(t,e){if(e.data&&e.data.datasets){const a=e.data.datasets.filter(n=>n.xAxisID===t||n.yAxisID===t);if(a.length)return getAxisFromDataset(t,"x",a[0])||getAxisFromDataset(t,"y",a[0])}return{}}function mergeScaleConfig(t,e){const a=overrides[t.type]||{scales:{}},n=e.scales||{},r=getIndexAxis(t.type,e),i=Object.create(null);return Object.keys(n).forEach(o=>{const s=n[o];if(!isObject$8(s))return console.error(`Invalid scale configuration for scale: ${o}`);if(s._proxy)return console.warn(`Ignoring resolver passed as options for scale: ${o}`);const l=determineAxis(o,s,retrieveAxisFromDatasets(o,t),defaults.scales[s.type]),u=getDefaultScaleIDFromAxis(l,r),c=a.scales||{};i[o]=mergeIf(Object.create(null),[{axis:l},s,c[l],c[u]])}),t.data.datasets.forEach(o=>{const s=o.type||t.type,l=o.indexAxis||getIndexAxis(s,e),c=(overrides[s]||{}).scales||{};Object.keys(c).forEach(d=>{const h=getAxisFromDefaultScaleID(d,l),m=o[h+"AxisID"]||h;i[m]=i[m]||Object.create(null),mergeIf(i[m],[{axis:h},n[m],c[d]])})}),Object.keys(i).forEach(o=>{const s=i[o];mergeIf(s,[defaults.scales[s.type],defaults.scale])}),i}function initOptions(t){const e=t.options||(t.options={});e.plugins=valueOrDefault(e.plugins,{}),e.scales=mergeScaleConfig(t,e)}function initData(t){return t=t||{},t.datasets=t.datasets||[],t.labels=t.labels||[],t}function initConfig(t){return t=t||{},t.data=initData(t.data),initOptions(t),t}const keyCache=new Map,keysCached=new Set;function cachedKeys(t,e){let a=keyCache.get(t);return a||(a=e(),keyCache.set(t,a),keysCached.add(a)),a}const addIfFound=(t,e,a)=>{const n=resolveObjectKey(e,a);n!==void 0&&t.add(n)};class Config{constructor(e){this._config=initConfig(e),this._scopeCache=new Map,this._resolverCache=new Map}get platform(){return this._config.platform}get type(){return this._config.type}set type(e){this._config.type=e}get data(){return this._config.data}set data(e){this._config.data=initData(e)}get options(){return this._config.options}set options(e){this._config.options=e}get plugins(){return this._config.plugins}update(){const e=this._config;this.clearCache(),initOptions(e)}clearCache(){this._scopeCache.clear(),this._resolverCache.clear()}datasetScopeKeys(e){return cachedKeys(e,()=>[[`datasets.${e}`,""]])}datasetAnimationScopeKeys(e,a){return cachedKeys(`${e}.transition.${a}`,()=>[[`datasets.${e}.transitions.${a}`,`transitions.${a}`],[`datasets.${e}`,""]])}datasetElementScopeKeys(e,a){return cachedKeys(`${e}-${a}`,()=>[[`datasets.${e}.elements.${a}`,`datasets.${e}`,`elements.${a}`,""]])}pluginScopeKeys(e){const a=e.id,n=this.type;return cachedKeys(`${n}-plugin-${a}`,()=>[[`plugins.${a}`,...e.additionalOptionScopes||[]]])}_cachedScopes(e,a){const n=this._scopeCache;let r=n.get(e);return(!r||a)&&(r=new Map,n.set(e,r)),r}getOptionScopes(e,a,n){const{options:r,type:i}=this,o=this._cachedScopes(e,n),s=o.get(a);if(s)return s;const l=new Set;a.forEach(c=>{e&&(l.add(e),c.forEach(d=>addIfFound(l,e,d))),c.forEach(d=>addIfFound(l,r,d)),c.forEach(d=>addIfFound(l,overrides[i]||{},d)),c.forEach(d=>addIfFound(l,defaults,d)),c.forEach(d=>addIfFound(l,descriptors,d))});const u=Array.from(l);return u.length===0&&u.push(Object.create(null)),keysCached.has(a)&&o.set(a,u),u}chartOptionScopes(){const{options:e,type:a}=this;return[e,overrides[a]||{},defaults.datasets[a]||{},{type:a},defaults,descriptors]}resolveNamedOptions(e,a,n,r=[""]){const i={$shared:!0},{resolver:o,subPrefixes:s}=getResolver(this._resolverCache,e,r);let l=o;if(needContext(o,a)){i.$shared=!1,n=isFunction$3(n)?n():n;const u=this.createResolver(e,n,s);l=_attachContext(o,n,u)}for(const u of a)i[u]=l[u];return i}createResolver(e,a,n=[""],r){const{resolver:i}=getResolver(this._resolverCache,e,n);return isObject$8(a)?_attachContext(i,a,void 0,r):i}}function getResolver(t,e,a){let n=t.get(e);n||(n=new Map,t.set(e,n));const r=a.join();let i=n.get(r);return i||(i={resolver:_createResolver(e,a),subPrefixes:a.filter(s=>!s.toLowerCase().includes("hover"))},n.set(r,i)),i}const hasFunction=t=>isObject$8(t)&&Object.getOwnPropertyNames(t).reduce((e,a)=>e||isFunction$3(t[a]),!1);function needContext(t,e){const{isScriptable:a,isIndexable:n}=_descriptors(t);for(const r of e){const i=a(r),o=n(r),s=(o||i)&&t[r];if(i&&(isFunction$3(s)||hasFunction(s))||o&&isArray$c(s))return!0}return!1}var version="4.3.3";const KNOWN_POSITIONS=["top","bottom","left","right","chartArea"];function positionIsHorizontal(t,e){return t==="top"||t==="bottom"||KNOWN_POSITIONS.indexOf(t)===-1&&e==="x"}function compare2Level(t,e){return function(a,n){return a[t]===n[t]?a[e]-n[e]:a[t]-n[t]}}function onAnimationsComplete(t){const e=t.chart,a=e.options.animation;e.notifyPlugins("afterRender"),callback(a&&a.onComplete,[t],e)}function onAnimationProgress(t){const e=t.chart,a=e.options.animation;callback(a&&a.onProgress,[t],e)}function getCanvas(t){return _isDomSupported()&&typeof t=="string"?t=document.getElementById(t):t&&t.length&&(t=t[0]),t&&t.canvas&&(t=t.canvas),t}const instances={},getChart=t=>{const e=getCanvas(t);return Object.values(instances).filter(a=>a.canvas===e).pop()};function moveNumericKeys(t,e,a){const n=Object.keys(t);for(const r of n){const i=+r;if(i>=e){const o=t[r];delete t[r],(a>0||i>e)&&(t[i+a]=o)}}}function determineLastEvent(t,e,a,n){return!a||t.type==="mouseout"?null:n?e:t}function getDatasetArea(t){const{xScale:e,yScale:a}=t;if(e&&a)return{left:e.left,right:e.right,top:a.top,bottom:a.bottom}}class Chart{static register(...e){registry.add(...e),invalidatePlugins()}static unregister(...e){registry.remove(...e),invalidatePlugins()}constructor(e,a){const n=this.config=new Config(a),r=getCanvas(e),i=getChart(r);if(i)throw new Error("Canvas is already in use. Chart with ID '"+i.id+"' must be destroyed before the canvas with ID '"+i.canvas.id+"' can be reused.");const o=n.createResolver(n.chartOptionScopes(),this.getContext());this.platform=new(n.platform||_detectPlatform(r)),this.platform.updateConfig(n);const s=this.platform.acquireContext(r,o.aspectRatio),l=s&&s.canvas,u=l&&l.height,c=l&&l.width;if(this.id=uid(),this.ctx=s,this.canvas=l,this.width=c,this.height=u,this._options=o,this._aspectRatio=this.aspectRatio,this._layers=[],this._metasets=[],this._stacks=void 0,this.boxes=[],this.currentDevicePixelRatio=void 0,this.chartArea=void 0,this._active=[],this._lastEvent=void 0,this._listeners={},this._responsiveListeners=void 0,this._sortedMetasets=[],this.scales={},this._plugins=new PluginService,this.$proxies={},this._hiddenIndices={},this.attached=!1,this._animationsDisabled=void 0,this.$context=void 0,this._doResize=debounce(d=>this.update(d),o.resizeDelay||0),this._dataChanges=[],instances[this.id]=this,!s||!l){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(),this.attached&&this.update()}get aspectRatio(){const{options:{aspectRatio:e,maintainAspectRatio:a},width:n,height:r,_aspectRatio:i}=this;return isNullOrUndef(e)?a&&i?i:r?n/r:null:e}get data(){return this.config.data}set data(e){this.config.data=e}get options(){return this._options}set options(e){this.config.options=e}get registry(){return registry}_initialize(){return this.notifyPlugins("beforeInit"),this.options.responsive?this.resize():retinaScale(this,this.options.devicePixelRatio),this.bindEvents(),this.notifyPlugins("afterInit"),this}clear(){return clearCanvas(this.canvas,this.ctx),this}stop(){return animator.stop(this),this}resize(e,a){animator.running(this)?this._resizeBeforeDraw={width:e,height:a}:this._resize(e,a)}_resize(e,a){const n=this.options,r=this.canvas,i=n.maintainAspectRatio&&this.aspectRatio,o=this.platform.getMaximumSize(r,e,a,i),s=n.devicePixelRatio||this.platform.getDevicePixelRatio(),l=this.width?"resize":"attach";this.width=o.width,this.height=o.height,this._aspectRatio=this.aspectRatio,retinaScale(this,s,!0)&&(this.notifyPlugins("resize",{size:o}),callback(n.onResize,[this,o],this),this.attached&&this._doResize(l)&&this.render())}ensureScalesHaveIDs(){const a=this.options.scales||{};each(a,(n,r)=>{n.id=r})}buildOrUpdateScales(){const e=this.options,a=e.scales,n=this.scales,r=Object.keys(n).reduce((o,s)=>(o[s]=!1,o),{});let i=[];a&&(i=i.concat(Object.keys(a).map(o=>{const s=a[o],l=determineAxis(o,s),u=l==="r",c=l==="x";return{options:s,dposition:u?"chartArea":c?"bottom":"left",dtype:u?"radialLinear":c?"category":"linear"}}))),each(i,o=>{const s=o.options,l=s.id,u=determineAxis(l,s),c=valueOrDefault(s.type,o.dtype);(s.position===void 0||positionIsHorizontal(s.position,u)!==positionIsHorizontal(o.dposition))&&(s.position=o.dposition),r[l]=!0;let d=null;if(l in n&&n[l].type===c)d=n[l];else{const h=registry.getScale(c);d=new h({id:l,type:c,ctx:this.ctx,chart:this}),n[d.id]=d}d.init(s,e)}),each(r,(o,s)=>{o||delete n[s]}),each(n,o=>{layouts.configure(this,o,o.options),layouts.addBox(this,o)})}_updateMetasets(){const e=this._metasets,a=this.data.datasets.length,n=e.length;if(e.sort((r,i)=>r.index-i.index),n>a){for(let r=a;ra.length&&delete this._stacks,e.forEach((n,r)=>{a.filter(i=>i===n._dataset).length===0&&this._destroyDatasetMeta(r)})}buildOrUpdateControllers(){const e=[],a=this.data.datasets;let n,r;for(this._removeUnreferencedMetasets(),n=0,r=a.length;n{this.getDatasetMeta(a).controller.reset()},this)}reset(){this._resetElements(),this.notifyPlugins("reset")}update(e){const a=this.config;a.update();const n=this._options=a.createResolver(a.chartOptionScopes(),this.getContext()),r=this._animationsDisabled=!n.animation;if(this._updateScales(),this._checkEventBindings(),this._updateHiddenIndices(),this._plugins.invalidate(),this.notifyPlugins("beforeUpdate",{mode:e,cancelable:!0})===!1)return;const i=this.buildOrUpdateControllers();this.notifyPlugins("beforeElementsUpdate");let o=0;for(let u=0,c=this.data.datasets.length;u{u.reset()}),this._updateDatasets(e),this.notifyPlugins("afterUpdate",{mode:e}),this._layers.sort(compare2Level("z","_idx"));const{_active:s,_lastEvent:l}=this;l?this._eventHandler(l,!0):s.length&&this._updateHoverStyles(s,s,!0),this.render()}_updateScales(){each(this.scales,e=>{layouts.removeBox(this,e)}),this.ensureScalesHaveIDs(),this.buildOrUpdateScales()}_checkEventBindings(){const e=this.options,a=new Set(Object.keys(this._listeners)),n=new Set(e.events);(!setsEqual(a,n)||!!this._responsiveListeners!==e.responsive)&&(this.unbindEvents(),this.bindEvents())}_updateHiddenIndices(){const{_hiddenIndices:e}=this,a=this._getUniformDataChanges()||[];for(const{method:n,start:r,count:i}of a){const o=n==="_removeElements"?-i:i;moveNumericKeys(e,r,o)}}_getUniformDataChanges(){const e=this._dataChanges;if(!e||!e.length)return;this._dataChanges=[];const a=this.data.datasets.length,n=i=>new Set(e.filter(o=>o[0]===i).map((o,s)=>s+","+o.splice(1).join(","))),r=n(0);for(let i=1;ii.split(",")).map(i=>({method:i[1],start:+i[2],count:+i[3]}))}_updateLayout(e){if(this.notifyPlugins("beforeLayout",{cancelable:!0})===!1)return;layouts.update(this,this.width,this.height,e);const a=this.chartArea,n=a.width<=0||a.height<=0;this._layers=[],each(this.boxes,r=>{n&&r.position==="chartArea"||(r.configure&&r.configure(),this._layers.push(...r._layers()))},this),this._layers.forEach((r,i)=>{r._idx=i}),this.notifyPlugins("afterLayout")}_updateDatasets(e){if(this.notifyPlugins("beforeDatasetsUpdate",{mode:e,cancelable:!0})!==!1){for(let a=0,n=this.data.datasets.length;a=0;--a)this._drawDataset(e[a]);this.notifyPlugins("afterDatasetsDraw")}_drawDataset(e){const a=this.ctx,n=e._clip,r=!n.disabled,i=getDatasetArea(e)||this.chartArea,o={meta:e,index:e.index,cancelable:!0};this.notifyPlugins("beforeDatasetDraw",o)!==!1&&(r&&clipArea(a,{left:n.left===!1?0:i.left-n.left,right:n.right===!1?this.width:i.right+n.right,top:n.top===!1?0:i.top-n.top,bottom:n.bottom===!1?this.height:i.bottom+n.bottom}),e.controller.draw(),r&&unclipArea(a),o.cancelable=!1,this.notifyPlugins("afterDatasetDraw",o))}isPointInArea(e){return _isPointInArea(e,this.chartArea,this._minPadding)}getElementsAtEventForMode(e,a,n,r){const i=Interaction.modes[a];return typeof i=="function"?i(this,e,n,r):[]}getDatasetMeta(e){const a=this.data.datasets[e],n=this._metasets;let r=n.filter(i=>i&&i._dataset===a).pop();return r||(r={type:null,data:[],dataset:null,controller:null,hidden:null,xAxisID:null,yAxisID:null,order:a&&a.order||0,index:e,_dataset:a,_parsed:[],_sorted:!1},n.push(r)),r}getContext(){return this.$context||(this.$context=createContext(null,{chart:this,type:"chart"}))}getVisibleDatasetCount(){return this.getSortedVisibleDatasetMetas().length}isDatasetVisible(e){const a=this.data.datasets[e];if(!a)return!1;const n=this.getDatasetMeta(e);return typeof n.hidden=="boolean"?!n.hidden:!a.hidden}setDatasetVisibility(e,a){const n=this.getDatasetMeta(e);n.hidden=!a}toggleDataVisibility(e){this._hiddenIndices[e]=!this._hiddenIndices[e]}getDataVisibility(e){return!this._hiddenIndices[e]}_updateVisibility(e,a,n){const r=n?"show":"hide",i=this.getDatasetMeta(e),o=i.controller._resolveAnimations(void 0,r);defined$1(a)?(i.data[a].hidden=!n,this.update()):(this.setDatasetVisibility(e,n),o.update(i,{visible:n}),this.update(s=>s.datasetIndex===e?r:void 0))}hide(e,a){this._updateVisibility(e,a,!1)}show(e,a){this._updateVisibility(e,a,!0)}_destroyDatasetMeta(e){const a=this._metasets[e];a&&a.controller&&a.controller._destroy(),delete this._metasets[e]}_stop(){let e,a;for(this.stop(),animator.remove(this),e=0,a=this.data.datasets.length;e{a.addEventListener(this,i,o),e[i]=o},r=(i,o,s)=>{i.offsetX=o,i.offsetY=s,this._eventHandler(i)};each(this.options.events,i=>n(i,r))}bindResponsiveEvents(){this._responsiveListeners||(this._responsiveListeners={});const e=this._responsiveListeners,a=this.platform,n=(l,u)=>{a.addEventListener(this,l,u),e[l]=u},r=(l,u)=>{e[l]&&(a.removeEventListener(this,l,u),delete e[l])},i=(l,u)=>{this.canvas&&this.resize(l,u)};let o;const s=()=>{r("attach",s),this.attached=!0,this.resize(),n("resize",i),n("detach",o)};o=()=>{this.attached=!1,r("resize",i),this._stop(),this._resize(0,0),n("attach",s)},a.isAttached(this.canvas)?s():o()}unbindEvents(){each(this._listeners,(e,a)=>{this.platform.removeEventListener(this,a,e)}),this._listeners={},each(this._responsiveListeners,(e,a)=>{this.platform.removeEventListener(this,a,e)}),this._responsiveListeners=void 0}updateHoverStyle(e,a,n){const r=n?"set":"remove";let i,o,s,l;for(a==="dataset"&&(i=this.getDatasetMeta(e[0].datasetIndex),i.controller["_"+r+"DatasetHoverStyle"]()),s=0,l=e.length;s{const s=this.getDatasetMeta(i);if(!s)throw new Error("No dataset found at index "+i);return{datasetIndex:i,element:s.data[o],index:o}});!_elementsEqual(n,a)&&(this._active=n,this._lastEvent=null,this._updateHoverStyles(n,a))}notifyPlugins(e,a,n){return this._plugins.notify(this,e,a,n)}isPluginEnabled(e){return this._plugins._cache.filter(a=>a.plugin.id===e).length===1}_updateHoverStyles(e,a,n){const r=this.options.hover,i=(l,u)=>l.filter(c=>!u.some(d=>c.datasetIndex===d.datasetIndex&&c.index===d.index)),o=i(a,e),s=n?e:i(e,a);o.length&&this.updateHoverStyle(o,r.mode,!1),s.length&&r.mode&&this.updateHoverStyle(s,r.mode,!0)}_eventHandler(e,a){const n={event:e,replay:a,cancelable:!0,inChartArea:this.isPointInArea(e)},r=o=>(o.options.events||this.options.events).includes(e.native.type);if(this.notifyPlugins("beforeEvent",n,r)===!1)return;const i=this._handleEvent(e,a,n.inChartArea);return n.cancelable=!1,this.notifyPlugins("afterEvent",n,r),(i||n.changed)&&this.render(),this}_handleEvent(e,a,n){const{_active:r=[],options:i}=this,o=a,s=this._getActiveElements(e,r,n,o),l=_isClickEvent(e),u=determineLastEvent(e,this._lastEvent,n,l);n&&(this._lastEvent=null,callback(i.onHover,[e,s,this],this),l&&callback(i.onClick,[e,s,this],this));const c=!_elementsEqual(s,r);return(c||a)&&(this._active=s,this._updateHoverStyles(s,r,a)),this._lastEvent=u,c}_getActiveElements(e,a,n,r){if(e.type==="mouseout")return[];if(!n)return a;const i=this.options.hover;return this.getElementsAtEventForMode(e,i.mode,i,r)}}R(Chart,"defaults",defaults),R(Chart,"instances",instances),R(Chart,"overrides",overrides),R(Chart,"registry",registry),R(Chart,"version",version),R(Chart,"getChart",getChart);function invalidatePlugins(){return each(Chart.instances,t=>t._plugins.invalidate())}function clipArc(t,e,a){const{startAngle:n,pixelMargin:r,x:i,y:o,outerRadius:s,innerRadius:l}=e;let u=r/s;t.beginPath(),t.arc(i,o,s,n-u,a+u),l>r?(u=r/l,t.arc(i,o,l,a+u,n-u,!0)):t.arc(i,o,r,a+HALF_PI,n-HALF_PI),t.closePath(),t.clip()}function toRadiusCorners(t){return _readValueToProps(t,["outerStart","outerEnd","innerStart","innerEnd"])}function parseBorderRadius$1(t,e,a,n){const r=toRadiusCorners(t.options.borderRadius),i=(a-e)/2,o=Math.min(i,n*e/2),s=l=>{const u=(a-Math.min(i,l))*n/2;return _limitValue(l,0,Math.min(i,u))};return{outerStart:s(r.outerStart),outerEnd:s(r.outerEnd),innerStart:_limitValue(r.innerStart,0,o),innerEnd:_limitValue(r.innerEnd,0,o)}}function rThetaToXY(t,e,a,n){return{x:a+t*Math.cos(e),y:n+t*Math.sin(e)}}function pathArc(t,e,a,n,r,i){const{x:o,y:s,startAngle:l,pixelMargin:u,innerRadius:c}=e,d=Math.max(e.outerRadius+n+a-u,0),h=c>0?c+n+a+u:0;let m=0;const p=r-l;if(n){const E=c>0?c-n:0,T=d>0?d-n:0,x=(E+T)/2,A=x!==0?p*x/(x+n):p;m=(p-A)/2}const v=Math.max(.001,p*d-a/PI)/d,y=(p-v)/2,w=l+y+m,_=r-y-m,{outerStart:D,outerEnd:k,innerStart:O,innerEnd:N}=parseBorderRadius$1(e,h,d,_-w),F=d-D,g=d-k,b=w+D/F,$=_-k/g,S=h+O,P=h+N,M=w+O/S,C=_-N/P;if(t.beginPath(),i){const E=(b+$)/2;if(t.arc(o,s,d,b,E),t.arc(o,s,d,E,$),k>0){const L=rThetaToXY(g,$,o,s);t.arc(L.x,L.y,k,$,_+HALF_PI)}const T=rThetaToXY(P,_,o,s);if(t.lineTo(T.x,T.y),N>0){const L=rThetaToXY(P,C,o,s);t.arc(L.x,L.y,N,_+HALF_PI,C+Math.PI)}const x=(_-N/h+(w+O/h))/2;if(t.arc(o,s,h,_-N/h,x,!0),t.arc(o,s,h,x,w+O/h,!0),O>0){const L=rThetaToXY(S,M,o,s);t.arc(L.x,L.y,O,M+Math.PI,w-HALF_PI)}const A=rThetaToXY(F,w,o,s);if(t.lineTo(A.x,A.y),D>0){const L=rThetaToXY(F,b,o,s);t.arc(L.x,L.y,D,w-HALF_PI,b)}}else{t.moveTo(o,s);const E=Math.cos(b)*d+o,T=Math.sin(b)*d+s;t.lineTo(E,T);const x=Math.cos($)*d+o,A=Math.sin($)*d+s;t.lineTo(x,A)}t.closePath()}function drawArc(t,e,a,n,r){const{fullCircles:i,startAngle:o,circumference:s}=e;let l=e.endAngle;if(i){pathArc(t,e,a,n,l,r);for(let u=0;u=TAU||_angleBetween(o,l,u),y=_isBetween(s,c+m,d+m);return v&&y}getCenterPoint(a){const{x:n,y:r,startAngle:i,endAngle:o,innerRadius:s,outerRadius:l}=this.getProps(["x","y","startAngle","endAngle","innerRadius","outerRadius"],a),{offset:u,spacing:c}=this.options,d=(i+o)/2,h=(s+l+c+u)/2;return{x:n+Math.cos(d)*h,y:r+Math.sin(d)*h}}tooltipPosition(a){return this.getCenterPoint(a)}draw(a){const{options:n,circumference:r}=this,i=(n.offset||0)/4,o=(n.spacing||0)/2,s=n.circular;if(this.pixelMargin=n.borderAlign==="inner"?.33:0,this.fullCircles=r>TAU?Math.floor(r/TAU):0,r===0||this.innerRadius<0||this.outerRadius<0)return;a.save();const l=(this.startAngle+this.endAngle)/2;a.translate(Math.cos(l)*i,Math.sin(l)*i);const u=1-Math.sin(Math.min(PI,r||0)),c=i*u;a.fillStyle=n.backgroundColor,a.strokeStyle=n.borderColor,drawArc(a,this,c,o,s),drawBorder(a,this,c,o,s),a.restore()}}R(ArcElement,"id","arc"),R(ArcElement,"defaults",{borderAlign:"center",borderColor:"#fff",borderDash:[],borderDashOffset:0,borderJoinStyle:void 0,borderRadius:0,borderWidth:2,offset:0,spacing:0,angle:void 0,circular:!0}),R(ArcElement,"defaultRoutes",{backgroundColor:"backgroundColor"}),R(ArcElement,"descriptors",{_scriptable:!0,_indexable:a=>a!=="borderDash"});function setStyle$1(t,e,a=e){t.lineCap=valueOrDefault(a.borderCapStyle,e.borderCapStyle),t.setLineDash(valueOrDefault(a.borderDash,e.borderDash)),t.lineDashOffset=valueOrDefault(a.borderDashOffset,e.borderDashOffset),t.lineJoin=valueOrDefault(a.borderJoinStyle,e.borderJoinStyle),t.lineWidth=valueOrDefault(a.borderWidth,e.borderWidth),t.strokeStyle=valueOrDefault(a.borderColor,e.borderColor)}function lineTo(t,e,a){t.lineTo(a.x,a.y)}function getLineMethod(t){return t.stepped?_steppedLineTo:t.tension||t.cubicInterpolationMode==="monotone"?_bezierCurveTo:lineTo}function pathVars(t,e,a={}){const n=t.length,{start:r=0,end:i=n-1}=a,{start:o,end:s}=e,l=Math.max(r,o),u=Math.min(i,s),c=rs&&i>s;return{count:n,start:l,loop:e.loop,ilen:u(o+(u?s-k:k))%i,D=()=>{v!==y&&(t.lineTo(c,y),t.lineTo(c,v),t.lineTo(c,w))};for(l&&(m=r[_(0)],t.moveTo(m.x,m.y)),h=0;h<=s;++h){if(m=r[_(h)],m.skip)continue;const k=m.x,O=m.y,N=k|0;N===p?(Oy&&(y=O),c=(d*c+k)/++d):(D(),t.lineTo(k,O),p=N,d=0,v=y=O),w=O}D()}function _getSegmentMethod(t){const e=t.options,a=e.borderDash&&e.borderDash.length;return!t._decimated&&!t._loop&&!e.tension&&e.cubicInterpolationMode!=="monotone"&&!e.stepped&&!a?fastPathSegment:pathSegment}function _getInterpolationMethod(t){return t.stepped?_steppedInterpolation:t.tension||t.cubicInterpolationMode==="monotone"?_bezierInterpolation:_pointInLine}function strokePathWithCache(t,e,a,n){let r=e._path;r||(r=e._path=new Path2D,e.path(r,a,n)&&r.closePath()),setStyle$1(t,e.options),t.stroke(r)}function strokePathDirect(t,e,a,n){const{segments:r,options:i}=e,o=_getSegmentMethod(e);for(const s of r)setStyle$1(t,i,s.style),t.beginPath(),o(t,e,s,{start:a,end:a+n-1})&&t.closePath(),t.stroke()}const usePath2D=typeof Path2D=="function";function draw(t,e,a,n){usePath2D&&!e.options.segment?strokePathWithCache(t,e,a,n):strokePathDirect(t,e,a,n)}class LineElement extends Element$1{constructor(e){super(),this.animated=!0,this.options=void 0,this._chart=void 0,this._loop=void 0,this._fullLoop=void 0,this._path=void 0,this._points=void 0,this._segments=void 0,this._decimated=!1,this._pointsUpdated=!1,this._datasetIndex=void 0,e&&Object.assign(this,e)}updateControlPoints(e,a){const n=this.options;if((n.tension||n.cubicInterpolationMode==="monotone")&&!n.stepped&&!this._pointsUpdated){const r=n.spanGaps?this._loop:this._fullLoop;_updateBezierControlPoints(this._points,n,e,r,a),this._pointsUpdated=!0}}set points(e){this._points=e,delete this._segments,delete this._path,this._pointsUpdated=!1}get points(){return this._points}get segments(){return this._segments||(this._segments=_computeSegments(this,this.options.segment))}first(){const e=this.segments,a=this.points;return e.length&&a[e[0].start]}last(){const e=this.segments,a=this.points,n=e.length;return n&&a[e[n-1].end]}interpolate(e,a){const n=this.options,r=e[a],i=this.points,o=_boundSegments(this,{property:a,start:r,end:r});if(!o.length)return;const s=[],l=_getInterpolationMethod(n);let u,c;for(u=0,c=o.length;ue!=="borderDash"&&e!=="fill"});function inRange$1(t,e,a,n){const r=t.options,{[a]:i}=t.getProps([a],n);return Math.abs(e-i)t.replace("rgb(","rgba(").replace(")",", 0.5)"));function getBorderColor(t){return BORDER_COLORS[t%BORDER_COLORS.length]}function getBackgroundColor(t){return BACKGROUND_COLORS[t%BACKGROUND_COLORS.length]}function colorizeDefaultDataset(t,e){return t.borderColor=getBorderColor(e),t.backgroundColor=getBackgroundColor(e),++e}function colorizeDoughnutDataset(t,e){return t.backgroundColor=t.data.map(()=>getBorderColor(e++)),e}function colorizePolarAreaDataset(t,e){return t.backgroundColor=t.data.map(()=>getBackgroundColor(e++)),e}function getColorizer(t){let e=0;return(a,n)=>{const r=t.getDatasetMeta(n).controller;r instanceof DoughnutController?e=colorizeDoughnutDataset(a,e):r instanceof PolarAreaController?e=colorizePolarAreaDataset(a,e):r&&(e=colorizeDefaultDataset(a,e))}}function containsColorsDefinitions(t){let e;for(e in t)if(t[e].borderColor||t[e].backgroundColor)return!0;return!1}function containsColorsDefinition(t){return t&&(t.borderColor||t.backgroundColor)}var plugin_colors={id:"colors",defaults:{enabled:!0,forceOverride:!1},beforeLayout(t,e,a){if(!a.enabled)return;const{data:{datasets:n},options:r}=t.config,{elements:i}=r;if(!a.forceOverride&&(containsColorsDefinitions(n)||containsColorsDefinition(r)||i&&containsColorsDefinitions(i)))return;const o=getColorizer(t);n.forEach(o)}};function _segments(t,e,a){const n=t.segments,r=t.points,i=e.points,o=[];for(const s of n){let{start:l,end:u}=s;u=_findSegmentEnd(l,u,r);const c=_getBounds(a,r[l],r[u],s.loop);if(!e.segments){o.push({source:s,target:c,start:r[l],end:r[u]});continue}const d=_boundSegments(e,c);for(const h of d){const m=_getBounds(a,i[h.start],i[h.end],h.loop),p=_boundSegment(s,r,m);for(const v of p)o.push({source:v,target:h,start:{[a]:_getEdge(c,m,"start",Math.max)},end:{[a]:_getEdge(c,m,"end",Math.min)}})}}return o}function _getBounds(t,e,a,n){if(n)return;let r=e[t],i=a[t];return t==="angle"&&(r=_normalizeAngle(r),i=_normalizeAngle(i)),{property:t,start:r,end:i}}function _pointsFromSegments(t,e){const{x:a=null,y:n=null}=t||{},r=e.points,i=[];return e.segments.forEach(({start:o,end:s})=>{s=_findSegmentEnd(o,s,r);const l=r[o],u=r[s];n!==null?(i.push({x:l.x,y:n}),i.push({x:u.x,y:n})):a!==null&&(i.push({x:a,y:l.y}),i.push({x:a,y:u.y}))}),i}function _findSegmentEnd(t,e,a){for(;e>t;e--){const n=a[e];if(!isNaN(n.x)&&!isNaN(n.y))break}return e}function _getEdge(t,e,a,n){return t&&e?n(t[a],e[a]):t?t[a]:e?e[a]:0}function _createBoundaryLine(t,e){let a=[],n=!1;return isArray$c(t)?(n=!0,a=t):a=_pointsFromSegments(t,e),a.length?new LineElement({points:a,options:{tension:0},_loop:n,_fullLoop:n}):null}function _shouldApplyFill(t){return t&&t.fill!==!1}function _resolveTarget(t,e,a){let r=t[e].fill;const i=[e];let o;if(!a)return r;for(;r!==!1&&i.indexOf(r)===-1;){if(!isNumberFinite(r))return r;if(o=t[r],!o)return!1;if(o.visible)return r;i.push(r),r=o.fill}return!1}function _decodeFill(t,e,a){const n=parseFillOption(t);if(isObject$8(n))return isNaN(n.value)?!1:n;let r=parseFloat(n);return isNumberFinite(r)&&Math.floor(r)===r?decodeTargetIndex(n[0],e,r,a):["origin","start","end","stack","shape"].indexOf(n)>=0&&n}function decodeTargetIndex(t,e,a,n){return(t==="-"||t==="+")&&(a=e+a),a===e||a<0||a>=n?!1:a}function _getTargetPixel(t,e){let a=null;return t==="start"?a=e.bottom:t==="end"?a=e.top:isObject$8(t)?a=e.getPixelForValue(t.value):e.getBasePixel&&(a=e.getBasePixel()),a}function _getTargetValue(t,e,a){let n;return t==="start"?n=a:t==="end"?n=e.options.reverse?e.min:e.max:isObject$8(t)?n=t.value:n=e.getBaseValue(),n}function parseFillOption(t){const e=t.options,a=e.fill;let n=valueOrDefault(a&&a.target,a);return n===void 0&&(n=!!e.backgroundColor),n===!1||n===null?!1:n===!0?"origin":n}function _buildStackLine(t){const{scale:e,index:a,line:n}=t,r=[],i=n.segments,o=n.points,s=getLinesBelow(e,a);s.push(_createBoundaryLine({x:null,y:e.bottom},n));for(let l=0;l=0;--o){const s=r[o].$filler;s&&(s.line.updateControlPoints(i,s.axis),n&&s.fill&&_drawfill(t.ctx,s,i))}},beforeDatasetsDraw(t,e,a){if(a.drawTime!=="beforeDatasetsDraw")return;const n=t.getSortedVisibleDatasetMetas();for(let r=n.length-1;r>=0;--r){const i=n[r].$filler;_shouldApplyFill(i)&&_drawfill(t.ctx,i,t.chartArea)}},beforeDatasetDraw(t,e,a){const n=e.meta.$filler;!_shouldApplyFill(n)||a.drawTime!=="beforeDatasetDraw"||_drawfill(t.ctx,n,t.chartArea)},defaults:{propagate:!0,drawTime:"beforeDatasetDraw"}};const getBoxSize=(t,e)=>{let{boxHeight:a=e,boxWidth:n=e}=t;return t.usePointStyle&&(a=Math.min(a,e),n=t.pointStyleWidth||Math.min(n,e)),{boxWidth:n,boxHeight:a,itemHeight:Math.max(e,a)}},itemsEqual=(t,e)=>t!==null&&e!==null&&t.datasetIndex===e.datasetIndex&&t.index===e.index;class Legend extends Element$1{constructor(e){super(),this._added=!1,this.legendHitBoxes=[],this._hoveredItem=null,this.doughnutMode=!1,this.chart=e.chart,this.options=e.options,this.ctx=e.ctx,this.legendItems=void 0,this.columnSizes=void 0,this.lineWidths=void 0,this.maxHeight=void 0,this.maxWidth=void 0,this.top=void 0,this.bottom=void 0,this.left=void 0,this.right=void 0,this.height=void 0,this.width=void 0,this._margins=void 0,this.position=void 0,this.weight=void 0,this.fullSize=void 0}update(e,a,n){this.maxWidth=e,this.maxHeight=a,this._margins=n,this.setDimensions(),this.buildLabels(),this.fit()}setDimensions(){this.isHorizontal()?(this.width=this.maxWidth,this.left=this._margins.left,this.right=this.width):(this.height=this.maxHeight,this.top=this._margins.top,this.bottom=this.height)}buildLabels(){const e=this.options.labels||{};let a=callback(e.generateLabels,[this.chart],this)||[];e.filter&&(a=a.filter(n=>e.filter(n,this.chart.data))),e.sort&&(a=a.sort((n,r)=>e.sort(n,r,this.chart.data))),this.options.reverse&&a.reverse(),this.legendItems=a}fit(){const{options:e,ctx:a}=this;if(!e.display){this.width=this.height=0;return}const n=e.labels,r=toFont(n.font),i=r.size,o=this._computeTitleHeight(),{boxWidth:s,itemHeight:l}=getBoxSize(n,i);let u,c;a.font=r.string,this.isHorizontal()?(u=this.maxWidth,c=this._fitRows(o,i,s,l)+10):(c=this.maxHeight,u=this._fitCols(o,r,s,l)+10),this.width=Math.min(u,e.maxWidth||this.maxWidth),this.height=Math.min(c,e.maxHeight||this.maxHeight)}_fitRows(e,a,n,r){const{ctx:i,maxWidth:o,options:{labels:{padding:s}}}=this,l=this.legendHitBoxes=[],u=this.lineWidths=[0],c=r+s;let d=e;i.textAlign="left",i.textBaseline="middle";let h=-1,m=-c;return this.legendItems.forEach((p,v)=>{const y=n+a/2+i.measureText(p.text).width;(v===0||u[u.length-1]+y+2*s>o)&&(d+=c,u[u.length-(v>0?0:1)]=0,m+=c,h++),l[v]={left:0,top:m,row:h,width:y,height:r},u[u.length-1]+=y+s}),d}_fitCols(e,a,n,r){const{ctx:i,maxHeight:o,options:{labels:{padding:s}}}=this,l=this.legendHitBoxes=[],u=this.columnSizes=[],c=o-e;let d=s,h=0,m=0,p=0,v=0;return this.legendItems.forEach((y,w)=>{const{itemWidth:_,itemHeight:D}=calculateItemSize(n,a,i,y,r);w>0&&m+D+2*s>c&&(d+=h+s,u.push({width:h,height:m}),p+=h+s,v++,h=m=0),l[w]={left:p,top:m,col:v,width:_,height:D},h=Math.max(h,_),m+=D+s}),d+=h,u.push({width:h,height:m}),d}adjustHitBoxes(){if(!this.options.display)return;const e=this._computeTitleHeight(),{legendHitBoxes:a,options:{align:n,labels:{padding:r},rtl:i}}=this,o=getRtlAdapter(i,this.left,this.width);if(this.isHorizontal()){let s=0,l=_alignStartEnd(n,this.left+r,this.right-this.lineWidths[s]);for(const u of a)s!==u.row&&(s=u.row,l=_alignStartEnd(n,this.left+r,this.right-this.lineWidths[s])),u.top+=this.top+e+r,u.left=o.leftForLtr(o.x(l),u.width),l+=u.width+r}else{let s=0,l=_alignStartEnd(n,this.top+e+r,this.bottom-this.columnSizes[s].height);for(const u of a)u.col!==s&&(s=u.col,l=_alignStartEnd(n,this.top+e+r,this.bottom-this.columnSizes[s].height)),u.top=l,u.left+=this.left+r,u.left=o.leftForLtr(o.x(u.left),u.width),l+=u.height+r}}isHorizontal(){return this.options.position==="top"||this.options.position==="bottom"}draw(){if(this.options.display){const e=this.ctx;clipArea(e,this),this._draw(),unclipArea(e)}}_draw(){const{options:e,columnSizes:a,lineWidths:n,ctx:r}=this,{align:i,labels:o}=e,s=defaults.color,l=getRtlAdapter(e.rtl,this.left,this.width),u=toFont(o.font),{padding:c}=o,d=u.size,h=d/2;let m;this.drawTitle(),r.textAlign=l.textAlign("left"),r.textBaseline="middle",r.lineWidth=.5,r.font=u.string;const{boxWidth:p,boxHeight:v,itemHeight:y}=getBoxSize(o,d),w=function(N,F,g){if(isNaN(p)||p<=0||isNaN(v)||v<0)return;r.save();const b=valueOrDefault(g.lineWidth,1);if(r.fillStyle=valueOrDefault(g.fillStyle,s),r.lineCap=valueOrDefault(g.lineCap,"butt"),r.lineDashOffset=valueOrDefault(g.lineDashOffset,0),r.lineJoin=valueOrDefault(g.lineJoin,"miter"),r.lineWidth=b,r.strokeStyle=valueOrDefault(g.strokeStyle,s),r.setLineDash(valueOrDefault(g.lineDash,[])),o.usePointStyle){const $={radius:v*Math.SQRT2/2,pointStyle:g.pointStyle,rotation:g.rotation,borderWidth:b},S=l.xPlus(N,p/2),P=F+h;drawPointLegend(r,$,S,P,o.pointStyleWidth&&p)}else{const $=F+Math.max((d-v)/2,0),S=l.leftForLtr(N,p),P=toTRBLCorners(g.borderRadius);r.beginPath(),Object.values(P).some(M=>M!==0)?addRoundedRectPath(r,{x:S,y:$,w:p,h:v,radius:P}):r.rect(S,$,p,v),r.fill(),b!==0&&r.stroke()}r.restore()},_=function(N,F,g){renderText(r,g.text,N,F+y/2,u,{strikethrough:g.hidden,textAlign:l.textAlign(g.textAlign)})},D=this.isHorizontal(),k=this._computeTitleHeight();D?m={x:_alignStartEnd(i,this.left+c,this.right-n[0]),y:this.top+c+k,line:0}:m={x:this.left+c,y:_alignStartEnd(i,this.top+k+c,this.bottom-a[0].height),line:0},overrideTextDirection(this.ctx,e.textDirection);const O=y+c;this.legendItems.forEach((N,F)=>{r.strokeStyle=N.fontColor,r.fillStyle=N.fontColor;const g=r.measureText(N.text).width,b=l.textAlign(N.textAlign||(N.textAlign=o.textAlign)),$=p+h+g;let S=m.x,P=m.y;l.setWidth(this.width),D?F>0&&S+$+c>this.right&&(P=m.y+=O,m.line++,S=m.x=_alignStartEnd(i,this.left+c,this.right-n[m.line])):F>0&&P+O>this.bottom&&(S=m.x=S+a[m.line].width+c,m.line++,P=m.y=_alignStartEnd(i,this.top+k+c,this.bottom-a[m.line].height));const M=l.x(S);if(w(M,P,N),S=_textX(b,S+p+h,D?S+$:this.right,e.rtl),_(l.x(S),P,N),D)m.x+=$+c;else if(typeof N.text!="string"){const C=u.lineHeight;m.y+=calculateLegendItemHeight(N,C)+c}else m.y+=O}),restoreTextDirection(this.ctx,e.textDirection)}drawTitle(){const e=this.options,a=e.title,n=toFont(a.font),r=toPadding(a.padding);if(!a.display)return;const i=getRtlAdapter(e.rtl,this.left,this.width),o=this.ctx,s=a.position,l=n.size/2,u=r.top+l;let c,d=this.left,h=this.width;if(this.isHorizontal())h=Math.max(...this.lineWidths),c=this.top+u,d=_alignStartEnd(e.align,d,this.right-h);else{const p=this.columnSizes.reduce((v,y)=>Math.max(v,y.height),0);c=u+_alignStartEnd(e.align,this.top,this.bottom-p-e.labels.padding-this._computeTitleHeight())}const m=_alignStartEnd(s,d,d+h);o.textAlign=i.textAlign(_toLeftRightCenter(s)),o.textBaseline="middle",o.strokeStyle=a.color,o.fillStyle=a.color,o.font=n.string,renderText(o,a.text,m,c,n)}_computeTitleHeight(){const e=this.options.title,a=toFont(e.font),n=toPadding(e.padding);return e.display?a.lineHeight+n.height:0}_getLegendItemAt(e,a){let n,r,i;if(_isBetween(e,this.left,this.right)&&_isBetween(a,this.top,this.bottom)){for(i=this.legendHitBoxes,n=0;ni.length>o.length?i:o)),e+a.size/2+n.measureText(r).width}function calculateItemHeight(t,e,a){let n=t;return typeof e.text!="string"&&(n=calculateLegendItemHeight(e,a)),n}function calculateLegendItemHeight(t,e){const a=t.text?t.text.length:0;return e*a}function isListened(t,e){return!!((t==="mousemove"||t==="mouseout")&&(e.onHover||e.onLeave)||e.onClick&&(t==="click"||t==="mouseup"))}var plugin_legend={id:"legend",_element:Legend,start(t,e,a){const n=t.legend=new Legend({ctx:t.ctx,options:a,chart:t});layouts.configure(t,n,a),layouts.addBox(t,n)},stop(t){layouts.removeBox(t,t.legend),delete t.legend},beforeUpdate(t,e,a){const n=t.legend;layouts.configure(t,n,a),n.options=a},afterUpdate(t){const e=t.legend;e.buildLabels(),e.adjustHitBoxes()},afterEvent(t,e){e.replay||t.legend.handleEvent(e.event)},defaults:{display:!0,position:"top",align:"center",fullSize:!0,reverse:!1,weight:1e3,onClick(t,e,a){const n=e.datasetIndex,r=a.chart;r.isDatasetVisible(n)?(r.hide(n),e.hidden=!0):(r.show(n),e.hidden=!1)},onHover:null,onLeave:null,labels:{color:t=>t.chart.options.color,boxWidth:40,padding:10,generateLabels(t){const e=t.data.datasets,{labels:{usePointStyle:a,pointStyle:n,textAlign:r,color:i,useBorderRadius:o,borderRadius:s}}=t.legend.options;return t._getSortedDatasetMetas().map(l=>{const u=l.controller.getStyle(a?0:void 0),c=toPadding(u.borderWidth);return{text:e[l.index].label,fillStyle:u.backgroundColor,fontColor:i,hidden:!l.visible,lineCap:u.borderCapStyle,lineDash:u.borderDash,lineDashOffset:u.borderDashOffset,lineJoin:u.borderJoinStyle,lineWidth:(c.width+c.height)/4,strokeStyle:u.borderColor,pointStyle:n||u.pointStyle,rotation:u.rotation,textAlign:r||u.textAlign,borderRadius:o&&(s||u.borderRadius),datasetIndex:l.index}},this)}},title:{color:t=>t.chart.options.color,display:!1,position:"center",text:""}},descriptors:{_scriptable:t=>!t.startsWith("on"),labels:{_scriptable:t=>!["generateLabels","filter","sort"].includes(t)}}};const positioners={average(t){if(!t.length)return!1;let e,a,n=0,r=0,i=0;for(e=0,a=t.length;e-1?t.split(` -`):t}function createTooltipItem(t,e){const{element:a,datasetIndex:n,index:r}=e,i=t.getDatasetMeta(n).controller,{label:o,value:s}=i.getLabelAndValue(r);return{chart:t,label:o,parsed:i.getParsed(r),raw:t.data.datasets[n].data[r],formattedValue:s,dataset:i.getDataset(),dataIndex:r,datasetIndex:n,element:a}}function getTooltipSize(t,e){const a=t.chart.ctx,{body:n,footer:r,title:i}=t,{boxWidth:o,boxHeight:s}=e,l=toFont(e.bodyFont),u=toFont(e.titleFont),c=toFont(e.footerFont),d=i.length,h=r.length,m=n.length,p=toPadding(e.padding);let v=p.height,y=0,w=n.reduce((k,O)=>k+O.before.length+O.lines.length+O.after.length,0);if(w+=t.beforeBody.length+t.afterBody.length,d&&(v+=d*u.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),w){const k=e.displayColors?Math.max(s,l.lineHeight):l.lineHeight;v+=m*k+(w-m)*l.lineHeight+(w-1)*e.bodySpacing}h&&(v+=e.footerMarginTop+h*c.lineHeight+(h-1)*e.footerSpacing);let _=0;const D=function(k){y=Math.max(y,a.measureText(k).width+_)};return a.save(),a.font=u.string,each(t.title,D),a.font=l.string,each(t.beforeBody.concat(t.afterBody),D),_=e.displayColors?o+2+e.boxPadding:0,each(n,k=>{each(k.before,D),each(k.lines,D),each(k.after,D)}),_=0,a.font=c.string,each(t.footer,D),a.restore(),y+=p.width,{width:y,height:v}}function determineYAlign(t,e){const{y:a,height:n}=e;return at.height-n/2?"bottom":"center"}function doesNotFitWithAlign(t,e,a,n){const{x:r,width:i}=n,o=a.caretSize+a.caretPadding;if(t==="left"&&r+i+o>e.width||t==="right"&&r-i-o<0)return!0}function determineXAlign(t,e,a,n){const{x:r,width:i}=a,{width:o,chartArea:{left:s,right:l}}=t;let u="center";return n==="center"?u=r<=(s+l)/2?"left":"right":r<=i/2?u="left":r>=o-i/2&&(u="right"),doesNotFitWithAlign(u,t,e,a)&&(u="center"),u}function determineAlignment(t,e,a){const n=a.yAlign||e.yAlign||determineYAlign(t,a);return{xAlign:a.xAlign||e.xAlign||determineXAlign(t,e,a,n),yAlign:n}}function alignX(t,e){let{x:a,width:n}=t;return e==="right"?a-=n:e==="center"&&(a-=n/2),a}function alignY(t,e,a){let{y:n,height:r}=t;return e==="top"?n+=a:e==="bottom"?n-=r+a:n-=r/2,n}function getBackgroundPoint(t,e,a,n){const{caretSize:r,caretPadding:i,cornerRadius:o}=t,{xAlign:s,yAlign:l}=a,u=r+i,{topLeft:c,topRight:d,bottomLeft:h,bottomRight:m}=toTRBLCorners(o);let p=alignX(e,s);const v=alignY(e,l,u);return l==="center"?s==="left"?p+=u:s==="right"&&(p-=u):s==="left"?p-=Math.max(c,h)+r:s==="right"&&(p+=Math.max(d,m)+r),{x:_limitValue(p,0,n.width-e.width),y:_limitValue(v,0,n.height-e.height)}}function getAlignedX(t,e,a){const n=toPadding(a.padding);return e==="center"?t.x+t.width/2:e==="right"?t.x+t.width-n.right:t.x+n.left}function getBeforeAfterBodyLines(t){return pushOrConcat([],splitNewlines(t))}function createTooltipContext(t,e,a){return createContext(t,{tooltip:e,tooltipItems:a,type:"tooltip"})}function overrideCallbacks(t,e){const a=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return a?t.override(a):t}const defaultCallbacks={beforeTitle:noop$2,title(t){if(t.length>0){const e=t[0],a=e.chart.data.labels,n=a?a.length:0;if(this&&this.options&&this.options.mode==="dataset")return e.dataset.label||"";if(e.label)return e.label;if(n>0&&e.dataIndex"u"?defaultCallbacks[e].call(a,n):r}class Tooltip extends Element$1{constructor(e){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=e.chart,this.options=e.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const e=this._cachedAnimations;if(e)return e;const a=this.chart,n=this.options.setContext(this.getContext()),r=n.enabled&&a.options.animation&&n.animations,i=new Animations(this.chart,r);return r._cacheable&&(this._cachedAnimations=Object.freeze(i)),i}getContext(){return this.$context||(this.$context=createTooltipContext(this.chart.getContext(),this,this._tooltipItems))}getTitle(e,a){const{callbacks:n}=a,r=invokeCallbackWithFallback(n,"beforeTitle",this,e),i=invokeCallbackWithFallback(n,"title",this,e),o=invokeCallbackWithFallback(n,"afterTitle",this,e);let s=[];return s=pushOrConcat(s,splitNewlines(r)),s=pushOrConcat(s,splitNewlines(i)),s=pushOrConcat(s,splitNewlines(o)),s}getBeforeBody(e,a){return getBeforeAfterBodyLines(invokeCallbackWithFallback(a.callbacks,"beforeBody",this,e))}getBody(e,a){const{callbacks:n}=a,r=[];return each(e,i=>{const o={before:[],lines:[],after:[]},s=overrideCallbacks(n,i);pushOrConcat(o.before,splitNewlines(invokeCallbackWithFallback(s,"beforeLabel",this,i))),pushOrConcat(o.lines,invokeCallbackWithFallback(s,"label",this,i)),pushOrConcat(o.after,splitNewlines(invokeCallbackWithFallback(s,"afterLabel",this,i))),r.push(o)}),r}getAfterBody(e,a){return getBeforeAfterBodyLines(invokeCallbackWithFallback(a.callbacks,"afterBody",this,e))}getFooter(e,a){const{callbacks:n}=a,r=invokeCallbackWithFallback(n,"beforeFooter",this,e),i=invokeCallbackWithFallback(n,"footer",this,e),o=invokeCallbackWithFallback(n,"afterFooter",this,e);let s=[];return s=pushOrConcat(s,splitNewlines(r)),s=pushOrConcat(s,splitNewlines(i)),s=pushOrConcat(s,splitNewlines(o)),s}_createItems(e){const a=this._active,n=this.chart.data,r=[],i=[],o=[];let s=[],l,u;for(l=0,u=a.length;le.filter(c,d,h,n))),e.itemSort&&(s=s.sort((c,d)=>e.itemSort(c,d,n))),each(s,c=>{const d=overrideCallbacks(e.callbacks,c);r.push(invokeCallbackWithFallback(d,"labelColor",this,c)),i.push(invokeCallbackWithFallback(d,"labelPointStyle",this,c)),o.push(invokeCallbackWithFallback(d,"labelTextColor",this,c))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=o,this.dataPoints=s,s}update(e,a){const n=this.options.setContext(this.getContext()),r=this._active;let i,o=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{const s=positioners[n.position].call(this,r,this._eventPosition);o=this._createItems(n),this.title=this.getTitle(o,n),this.beforeBody=this.getBeforeBody(o,n),this.body=this.getBody(o,n),this.afterBody=this.getAfterBody(o,n),this.footer=this.getFooter(o,n);const l=this._size=getTooltipSize(this,n),u=Object.assign({},s,l),c=determineAlignment(this.chart,n,u),d=getBackgroundPoint(n,u,c,this.chart);this.xAlign=c.xAlign,this.yAlign=c.yAlign,i={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:s.x,caretY:s.y}}this._tooltipItems=o,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:a})}drawCaret(e,a,n,r){const i=this.getCaretPosition(e,n,r);a.lineTo(i.x1,i.y1),a.lineTo(i.x2,i.y2),a.lineTo(i.x3,i.y3)}getCaretPosition(e,a,n){const{xAlign:r,yAlign:i}=this,{caretSize:o,cornerRadius:s}=n,{topLeft:l,topRight:u,bottomLeft:c,bottomRight:d}=toTRBLCorners(s),{x:h,y:m}=e,{width:p,height:v}=a;let y,w,_,D,k,O;return i==="center"?(k=m+v/2,r==="left"?(y=h,w=y-o,D=k+o,O=k-o):(y=h+p,w=y+o,D=k-o,O=k+o),_=y):(r==="left"?w=h+Math.max(l,c)+o:r==="right"?w=h+p-Math.max(u,d)-o:w=this.caretX,i==="top"?(D=m,k=D-o,y=w-o,_=w+o):(D=m+v,k=D+o,y=w+o,_=w-o),O=D),{x1:y,x2:w,x3:_,y1:D,y2:k,y3:O}}drawTitle(e,a,n){const r=this.title,i=r.length;let o,s,l;if(i){const u=getRtlAdapter(n.rtl,this.x,this.width);for(e.x=getAlignedX(this,n.titleAlign,n),a.textAlign=u.textAlign(n.titleAlign),a.textBaseline="middle",o=toFont(n.titleFont),s=n.titleSpacing,a.fillStyle=n.titleColor,a.font=o.string,l=0;l_!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,addRoundedRectPath(e,{x:v,y:p,w:u,h:l,radius:w}),e.fill(),e.stroke(),e.fillStyle=o.backgroundColor,e.beginPath(),addRoundedRectPath(e,{x:y,y:p+1,w:u-2,h:l-2,radius:w}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(v,p,u,l),e.strokeRect(v,p,u,l),e.fillStyle=o.backgroundColor,e.fillRect(y,p+1,u-2,l-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,a,n){const{body:r}=this,{bodySpacing:i,bodyAlign:o,displayColors:s,boxHeight:l,boxWidth:u,boxPadding:c}=n,d=toFont(n.bodyFont);let h=d.lineHeight,m=0;const p=getRtlAdapter(n.rtl,this.x,this.width),v=function(g){a.fillText(g,p.x(e.x+m),e.y+h/2),e.y+=h+i},y=p.textAlign(o);let w,_,D,k,O,N,F;for(a.textAlign=o,a.textBaseline="middle",a.font=d.string,e.x=getAlignedX(this,y,n),a.fillStyle=n.bodyColor,each(this.beforeBody,v),m=s&&y!=="right"?o==="center"?u/2+c:u+2+c:0,k=0,N=r.length;k0&&a.stroke()}_updateAnimationTarget(e){const a=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){const o=positioners[e.position].call(this,this._active,this._eventPosition);if(!o)return;const s=this._size=getTooltipSize(this,e),l=Object.assign({},o,this._size),u=determineAlignment(a,e,l),c=getBackgroundPoint(e,l,u,a);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=u.xAlign,this.yAlign=u.yAlign,this.width=s.width,this.height=s.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){const a=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(a);const r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const o=toPadding(a.padding),s=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;a.enabled&&s&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,a),overrideTextDirection(e,a.textDirection),i.y+=o.top,this.drawTitle(i,e,a),this.drawBody(i,e,a),this.drawFooter(i,e,a),restoreTextDirection(e,a.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,a){const n=this._active,r=e.map(({datasetIndex:s,index:l})=>{const u=this.chart.getDatasetMeta(s);if(!u)throw new Error("Cannot find a dataset at index "+s);return{datasetIndex:s,element:u.data[l],index:l}}),i=!_elementsEqual(n,r),o=this._positionChanged(r,a);(i||o)&&(this._active=r,this._eventPosition=a,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,a,n=!0){if(a&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const r=this.options,i=this._active||[],o=this._getActiveElements(e,i,a,n),s=this._positionChanged(o,e),l=a||!_elementsEqual(o,i)||s;return l&&(this._active=o,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,a))),l}_getActiveElements(e,a,n,r){const i=this.options;if(e.type==="mouseout")return[];if(!r)return a;const o=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&o.reverse(),o}_positionChanged(e,a){const{caretX:n,caretY:r,options:i}=this,o=positioners[i.position].call(this,e,a);return o!==!1&&(n!==o.x||r!==o.y)}}R(Tooltip,"positioners",positioners);var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners,afterInit(t,e,a){a&&(t.tooltip=new Tooltip({chart:t,options:a}))},beforeUpdate(t,e,a){t.tooltip&&t.tooltip.initialize(a)},reset(t,e,a){t.tooltip&&t.tooltip.initialize(a)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const a={tooltip:e};if(t.notifyPlugins("beforeTooltipDraw",{...a,cancelable:!0})===!1)return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",a)}},afterEvent(t,e){if(t.tooltip){const a=e.replay;t.tooltip.handleEvent(e.event,a,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,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:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,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:t=>t!=="filter"&&t!=="itemSort"&&t!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const addIfString=(t,e,a,n)=>(typeof e=="string"?(a=t.push(e)-1,n.unshift({index:a,label:e})):isNaN(e)&&(a=null),a);function findOrAddLabel(t,e,a,n){const r=t.indexOf(e);if(r===-1)return addIfString(t,e,a,n);const i=t.lastIndexOf(e);return r!==i?a:r}const validIndex=(t,e)=>t===null?null:_limitValue(Math.round(t),0,e);function _getLabelForValue(t){const e=this.getLabels();return t>=0&&ta.length-1?null:this.getPixelForValue(a[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}}R(CategoryScale,"id","category"),R(CategoryScale,"defaults",{ticks:{callback:_getLabelForValue}});function generateTicks$1(t,e){const a=[],{bounds:r,step:i,min:o,max:s,precision:l,count:u,maxTicks:c,maxDigits:d,includeBounds:h}=t,m=i||1,p=c-1,{min:v,max:y}=e,w=!isNullOrUndef(o),_=!isNullOrUndef(s),D=!isNullOrUndef(u),k=(y-v)/(d+1);let O=niceNum((y-v)/p/m)*m,N,F,g,b;if(O<1e-14&&!w&&!_)return[{value:v},{value:y}];b=Math.ceil(y/O)-Math.floor(v/O),b>p&&(O=niceNum(b*O/p/m)*m),isNullOrUndef(l)||(N=Math.pow(10,l),O=Math.ceil(O*N)/N),r==="ticks"?(F=Math.floor(v/O)*O,g=Math.ceil(y/O)*O):(F=v,g=y),w&&_&&i&&almostWhole((s-o)/i,O/1e3)?(b=Math.round(Math.min((s-o)/O,c)),O=(s-o)/b,F=o,g=s):D?(F=w?o:F,g=_?s:g,b=u-1,O=(g-F)/b):(b=(g-F)/O,almostEquals(b,Math.round(b),O/1e3)?b=Math.round(b):b=Math.ceil(b));const $=Math.max(_decimalPlaces(O),_decimalPlaces(F));N=Math.pow(10,isNullOrUndef(l)?$:l),F=Math.round(F*N)/N,g=Math.round(g*N)/N;let S=0;for(w&&(h&&F!==o?(a.push({value:o}),Fs)break;a.push({value:P})}return _&&h&&g!==s?a.length&&almostEquals(a[a.length-1].value,s,relativeLabelSize(s,k,t))?a[a.length-1].value=s:a.push({value:s}):(!_||g===s)&&a.push({value:g}),a}function relativeLabelSize(t,e,{horizontal:a,minRotation:n}){const r=toRadians(n),i=(a?Math.sin(r):Math.cos(r))||.001,o=.75*e*(""+t).length;return Math.min(e/i,o)}class LinearScaleBase extends Scale{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,a){return isNullOrUndef(e)||(typeof e=="number"||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){const{beginAtZero:e}=this.options,{minDefined:a,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this;const o=l=>r=a?r:l,s=l=>i=n?i:l;if(e){const l=sign(r),u=sign(i);l<0&&u<0?s(0):l>0&&u>0&&o(0)}if(r===i){let l=i===0?1:Math.abs(i*.05);s(i+l),e||o(r-l)}this.min=r,this.max=i}getTickLimit(){const e=this.options.ticks;let{maxTicksLimit:a,stepSize:n}=e,r;return n?(r=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,r>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${r} ticks. Limiting to 1000.`),r=1e3)):(r=this.computeTickLimit(),a=a||11),a&&(r=Math.min(a,r)),r}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const e=this.options,a=e.ticks;let n=this.getTickLimit();n=Math.max(2,n);const r={maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:a.precision,step:a.stepSize,count:a.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:a.minRotation||0,includeBounds:a.includeBounds!==!1},i=this._range||this,o=generateTicks$1(r,i);return e.bounds==="ticks"&&_setMinAndMaxByKey(o,this,"value"),e.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const e=this.ticks;let a=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){const r=(n-a)/Math.max(e.length-1,1)/2;a-=r,n+=r}this._startValue=a,this._endValue=n,this._valueRange=n-a}getLabelForValue(e){return formatNumber$1(e,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{determineDataLimits(){const{min:e,max:a}=this.getMinMax(!0);this.min=isNumberFinite(e)?e:0,this.max=isNumberFinite(a)?a:1,this.handleTickRangeOptions()}computeTickLimit(){const e=this.isHorizontal(),a=e?this.width:this.height,n=toRadians(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(a/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}}R(LinearScale,"id","linear"),R(LinearScale,"defaults",{ticks:{callback:Ticks.formatters.numeric}});const log10Floor=t=>Math.floor(log10(t)),changeExponent=(t,e)=>Math.pow(10,log10Floor(t)+e);function isMajor(t){return t/Math.pow(10,log10Floor(t))===1}function steps(t,e,a){const n=Math.pow(10,a),r=Math.floor(t/n);return Math.ceil(e/n)-r}function startExp(t,e){const a=e-t;let n=log10Floor(a);for(;steps(t,e,n)>10;)n++;for(;steps(t,e,n)<10;)n--;return Math.min(n,log10Floor(t))}function generateTicks(t,{min:e,max:a}){e=finiteOrDefault(t.min,e);const n=[],r=log10Floor(e);let i=startExp(e,a),o=i<0?Math.pow(10,Math.abs(i)):1;const s=Math.pow(10,i),l=r>i?Math.pow(10,r):0,u=Math.round((e-l)*o)/o,c=Math.floor((e-l)/s/10)*s*10;let d=Math.floor((u-c)/Math.pow(10,i)),h=finiteOrDefault(t.min,Math.round((l+c+d*Math.pow(10,i))*o)/o);for(;h=10?d=d<15?15:20:d++,d>=20&&(i++,d=2,o=i>=0?1:o),h=Math.round((l+c+d*Math.pow(10,i))*o)/o;const m=finiteOrDefault(t.max,h);return n.push({value:m,major:isMajor(m),significand:d}),n}class LogarithmicScale extends Scale{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,a){const n=LinearScaleBase.prototype.parse.apply(this,[e,a]);if(n===0){this._zero=!0;return}return isNumberFinite(n)&&n>0?n:null}determineDataLimits(){const{min:e,max:a}=this.getMinMax(!0);this.min=isNumberFinite(e)?Math.max(0,e):null,this.max=isNumberFinite(a)?Math.max(0,a):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!isNumberFinite(this._userMin)&&(this.min=e===changeExponent(this.min,0)?changeExponent(this.min,-1):changeExponent(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:e,maxDefined:a}=this.getUserBounds();let n=this.min,r=this.max;const i=s=>n=e?n:s,o=s=>r=a?r:s;n===r&&(n<=0?(i(1),o(10)):(i(changeExponent(n,-1)),o(changeExponent(r,1)))),n<=0&&i(changeExponent(r,-1)),r<=0&&o(changeExponent(n,1)),this.min=n,this.max=r}buildTicks(){const e=this.options,a={min:this._userMin,max:this._userMax},n=generateTicks(a,this);return e.bounds==="ticks"&&_setMinAndMaxByKey(n,this,"value"),e.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(e){return e===void 0?"0":formatNumber$1(e,this.chart.options.locale,this.options.ticks.format)}configure(){const e=this.min;super.configure(),this._startValue=log10(e),this._valueRange=log10(this.max)-log10(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(log10(e)-this._startValue)/this._valueRange)}getValueForPixel(e){const a=this.getDecimalForPixel(e);return Math.pow(10,this._startValue+a*this._valueRange)}}R(LogarithmicScale,"id","logarithmic"),R(LogarithmicScale,"defaults",{ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:!0}}});function getTickBackdropHeight(t){const e=t.ticks;if(e.display&&t.display){const a=toPadding(e.backdropPadding);return valueOrDefault(e.font&&e.font.size,defaults.font.size)+a.height}return 0}function measureLabelSize(t,e,a){return a=isArray$c(a)?a:[a],{w:_longestText(t,e.string,a),h:a.length*e.lineHeight}}function determineLimits(t,e,a,n,r){return t===n||t===r?{start:e-a/2,end:e+a/2}:tr?{start:e-a,end:e}:{start:e,end:e+a}}function fitWithPointLabels(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},a=Object.assign({},e),n=[],r=[],i=t._pointLabels.length,o=t.options.pointLabels,s=o.centerPointLabels?PI/i:0;for(let l=0;le.r&&(s=(n.end-e.r)/i,t.r=Math.max(t.r,e.r+s)),r.starte.b&&(l=(r.end-e.b)/o,t.b=Math.max(t.b,e.b+l))}function createPointLabelItem(t,e,a){const n=t.drawingArea,{extra:r,additionalAngle:i,padding:o,size:s}=a,l=t.getPointPosition(e,n+r+o,i),u=Math.round(toDegrees(_normalizeAngle(l.angle+HALF_PI))),c=yForAngle(l.y,s.h,u),d=getTextAlignForAngle(u),h=leftForTextAlign(l.x,s.w,d);return{visible:!0,x:l.x,y:c,textAlign:d,left:h,top:c,right:h+s.w,bottom:c+s.h}}function isNotOverlapped(t,e){if(!e)return!0;const{left:a,top:n,right:r,bottom:i}=t;return!(_isPointInArea({x:a,y:n},e)||_isPointInArea({x:a,y:i},e)||_isPointInArea({x:r,y:n},e)||_isPointInArea({x:r,y:i},e))}function buildPointLabelItems(t,e,a){const n=[],r=t._pointLabels.length,i=t.options,{centerPointLabels:o,display:s}=i.pointLabels,l={extra:getTickBackdropHeight(i)/2,additionalAngle:o?PI/r:0};let u;for(let c=0;c270||a<90)&&(t-=e),t}function drawPointLabelBox(t,e,a){const{left:n,top:r,right:i,bottom:o}=a,{backdropColor:s}=e;if(!isNullOrUndef(s)){const l=toTRBLCorners(e.borderRadius),u=toPadding(e.backdropPadding);t.fillStyle=s;const c=n-u.left,d=r-u.top,h=i-n+u.width,m=o-r+u.height;Object.values(l).some(p=>p!==0)?(t.beginPath(),addRoundedRectPath(t,{x:c,y:d,w:h,h:m,radius:l}),t.fill()):t.fillRect(c,d,h,m)}}function drawPointLabels(t,e){const{ctx:a,options:{pointLabels:n}}=t;for(let r=e-1;r>=0;r--){const i=t._pointLabelItems[r];if(!i.visible)continue;const o=n.setContext(t.getPointLabelContext(r));drawPointLabelBox(a,o,i);const s=toFont(o.font),{x:l,y:u,textAlign:c}=i;renderText(a,t._pointLabels[r],l,u+s.lineHeight/2,s,{color:o.color,textAlign:c,textBaseline:"middle"})}}function pathRadiusLine(t,e,a,n){const{ctx:r}=t;if(a)r.arc(t.xCenter,t.yCenter,e,0,TAU);else{let i=t.getPointPosition(0,e);r.moveTo(i.x,i.y);for(let o=1;o{const r=callback(this.options.pointLabels.callback,[a,n],this);return r||r===0?r:""}).filter((a,n)=>this.chart.getDataVisibility(n))}fit(){const e=this.options;e.display&&e.pointLabels.display?fitWithPointLabels(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,a,n,r){this.xCenter+=Math.floor((e-a)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,a,n,r))}getIndexAngle(e){const a=TAU/(this._pointLabels.length||1),n=this.options.startAngle||0;return _normalizeAngle(e*a+toRadians(n))}getDistanceFromCenterForValue(e){if(isNullOrUndef(e))return NaN;const a=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*a:(e-this.min)*a}getValueForDistanceFromCenter(e){if(isNullOrUndef(e))return NaN;const a=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-a:this.min+a}getPointLabelContext(e){const a=this._pointLabels||[];if(e>=0&&e{if(d!==0){l=this.getDistanceFromCenterForValue(c.value);const h=this.getContext(d),m=r.setContext(h),p=i.setContext(h);drawRadiusLine(this,m,l,o,p)}}),n.display){for(e.save(),s=o-1;s>=0;s--){const c=n.setContext(this.getPointLabelContext(s)),{color:d,lineWidth:h}=c;!h||!d||(e.lineWidth=h,e.strokeStyle=d,e.setLineDash(c.borderDash),e.lineDashOffset=c.borderDashOffset,l=this.getDistanceFromCenterForValue(a.ticks.reverse?this.min:this.max),u=this.getPointPosition(s,l),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(u.x,u.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){const e=this.ctx,a=this.options,n=a.ticks;if(!n.display)return;const r=this.getIndexAngle(0);let i,o;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign="center",e.textBaseline="middle",this.ticks.forEach((s,l)=>{if(l===0&&!a.reverse)return;const u=n.setContext(this.getContext(l)),c=toFont(u.font);if(i=this.getDistanceFromCenterForValue(this.ticks[l].value),u.showLabelBackdrop){e.font=c.string,o=e.measureText(s.label).width,e.fillStyle=u.backdropColor;const d=toPadding(u.backdropPadding);e.fillRect(-o/2-d.left,-i-c.size/2-d.top,o+d.width,c.size+d.height)}renderText(e,s.label,0,-i,c,{color:u.color,strokeColor:u.textStrokeColor,strokeWidth:u.textStrokeWidth})}),e.restore()}drawTitle(){}}R(RadialLinearScale,"id","radialLinear"),R(RadialLinearScale,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ticks.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(e){return e},padding:5,centerPointLabels:!1}}),R(RadialLinearScale,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),R(RadialLinearScale,"descriptors",{angleLines:{_fallback:"grid"}});const INTERVALS={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},UNITS=Object.keys(INTERVALS);function sorter(t,e){return t-e}function parse(t,e){if(isNullOrUndef(e))return null;const a=t._adapter,{parser:n,round:r,isoWeekday:i}=t._parseOpts;let o=e;return typeof n=="function"&&(o=n(o)),isNumberFinite(o)||(o=typeof n=="string"?a.parse(o,n):a.parse(o)),o===null?null:(r&&(o=r==="week"&&(isNumber(i)||i===!0)?a.startOf(o,"isoWeek",i):a.startOf(o,r)),+o)}function determineUnitForAutoTicks(t,e,a,n){const r=UNITS.length;for(let i=UNITS.indexOf(t);i=UNITS.indexOf(a);i--){const o=UNITS[i];if(INTERVALS[o].common&&t._adapter.diff(r,n,o)>=e-1)return o}return UNITS[a?UNITS.indexOf(a):0]}function determineMajorUnit(t){for(let e=UNITS.indexOf(t)+1,a=UNITS.length;e=e?a[n]:a[r];t[i]=!0}}function setMajorTicks(t,e,a,n){const r=t._adapter,i=+r.startOf(e[0].value,n),o=e[e.length-1].value;let s,l;for(s=i;s<=o;s=+r.add(s,1,n))l=a[s],l>=0&&(e[l].major=!0);return e}function ticksFromTimestamps(t,e,a){const n=[],r={},i=e.length;let o,s;for(o=0;o+e.value))}initOffsets(e=[]){let a=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),e.length===1?a=1-r:a=(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),e.length===1?n=i:n=(i-this.getDecimalForValue(e[e.length-2]))/2);const o=e.length<3?.5:.25;a=_limitValue(a,0,o),n=_limitValue(n,0,o),this._offsets={start:a,end:n,factor:1/(a+1+n)}}_generate(){const e=this._adapter,a=this.min,n=this.max,r=this.options,i=r.time,o=i.unit||determineUnitForAutoTicks(i.minUnit,a,n,this._getLabelCapacity(a)),s=valueOrDefault(r.ticks.stepSize,1),l=o==="week"?i.isoWeekday:!1,u=isNumber(l)||l===!0,c={};let d=a,h,m;if(u&&(d=+e.startOf(d,"isoWeek",l)),d=+e.startOf(d,u?"day":o),e.diff(n,a,o)>1e5*s)throw new Error(a+" and "+n+" are too far apart with stepSize of "+s+" "+o);const p=r.ticks.source==="data"&&this.getDataTimestamps();for(h=d,m=0;h+v)}getLabelForValue(e){const a=this._adapter,n=this.options.time;return n.tooltipFormat?a.format(e,n.tooltipFormat):a.format(e,n.displayFormats.datetime)}format(e,a){const r=this.options.time.displayFormats,i=this._unit,o=a||r[i];return this._adapter.format(e,o)}_tickFormatFunction(e,a,n,r){const i=this.options,o=i.ticks.callback;if(o)return callback(o,[e,a,n],this);const s=i.time.displayFormats,l=this._unit,u=this._majorUnit,c=l&&s[l],d=u&&s[u],h=n[a],m=u&&d&&h&&h.major;return this._adapter.format(e,r||(m?d:c))}generateTickLabels(e){let a,n,r;for(a=0,n=e.length;a0?s:1}getDataTimestamps(){let e=this._cache.data||[],a,n;if(e.length)return e;const r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(a=0,n=r.length;a=t[n].pos&&e<=t[r].pos&&({lo:n,hi:r}=_lookupByKey(t,"pos",e)),{pos:i,time:s}=t[n],{pos:o,time:l}=t[r]):(e>=t[n].time&&e<=t[r].time&&({lo:n,hi:r}=_lookupByKey(t,"time",e)),{time:i,pos:s}=t[n],{time:o,pos:l}=t[r]);const u=o-i;return u?s+(l-s)*(e-i)/u:s}class TimeSeriesScale extends TimeScale{constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const e=this._getTimestampsForTable(),a=this._table=this.buildLookupTable(e);this._minPos=interpolate$1(a,this.min),this._tableRange=interpolate$1(a,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){const{min:a,max:n}=this,r=[],i=[];let o,s,l,u,c;for(o=0,s=e.length;o=a&&u<=n&&r.push(u);if(r.length<2)return[{time:a,pos:0},{time:n,pos:1}];for(o=0,s=r.length;or-i)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;const a=this.getDataTimestamps(),n=this.getLabelTimestamps();return a.length&&n.length?e=this.normalize(a.concat(n)):e=a.length?a:n,e=this._cache.all=e,e}getDecimalForValue(e){return(interpolate$1(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){const a=this._offsets,n=this.getDecimalForPixel(e)/a.factor-a.end;return interpolate$1(this._table,n*this._tableRange+this._minPos,!0)}}R(TimeSeriesScale,"id","timeseries"),R(TimeSeriesScale,"defaults",TimeScale.defaults);function getDefaultChartSettings(t){return t==="sankey"?{type:"sankey",data:{datasets:[]}}:t==="pie"?{type:"pie",data:{datasets:[]}}:t==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(e){let a=e.dataset.currency_code;return formatMoney(e.raw,a)}}}},maintainAspectRatio:!1,scales:{}}}:t==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(e){let a=e.dataset.currency_code;return formatMoney(e.raw,a)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let currencies$2=[],chart$4=null,chartData$2=null,afterPromises$5=!1;const CHART_CACHE_KEY="dashboard-accounts-chart",ACCOUNTS_CACHE_KEY="dashboard-accounts-data",accounts=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,setVariable("autoConversion",this.autoConversion)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CHART_CACHE_KEY);if(t&&typeof e<"u"){let n=window.store.get(CHART_CACHE_KEY);this.drawChart(n),this.loading=!1;return}new Dashboard$2().dashboard(new Date(window.store.get("start")),new Date(window.store.get("end")),null).then(n=>{this.chartData=n.data;let r=this.generateOptions(this.chartData);window.store.set(CHART_CACHE_KEY,r),this.drawChart(r),this.loading=!1})},generateOptions(t){currencies$2=[];let e=getDefaultChartSettings("line");for(let a=0;a0){this.loadingAccounts=!1;return}const t=window.store.get("cacheValid");let e=window.store.get(ACCOUNTS_CACHE_KEY);if(t&&typeof e<"u"){this.accountList=e,this.loadingAccounts=!1;return}const a=10;let n=0,r=0,i=[];Promise.all([getVariable("frontpageAccounts")]).then(o=>{n=o[0].length;for(let s in o[0]){let l=o[0];if(l.hasOwnProperty(s)){let u=l[s];new Get$3().get(u,new Date(window.store.get("end"))).then(c=>{let d=c.data.data;new Get$3().transactions(d.id,1).then(h=>{let m=[];for(let p=0;p=a);p++){let v=h.data.data[p],y={title:v.attributes.group_title===null?"":v.attributes.group_title,id:v.id,transactions:[]};for(let w=0;wp.order-v.order),this.accountList=i,this.loadingAccounts=!1,window.store.set(ACCOUNTS_CACHE_KEY,i))})})}}})},init(){Promise.all([getVariable("viewRange","1M"),getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{this.autoConversion=t[1],afterPromises$5=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{afterPromises$5&&(chartData$2=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{afterPromises$5&&(this.loadChart(),this.loadAccounts())})}});let Dashboard$1=class{dashboard(e,a){let n=format$1(e,"y-MM-dd"),r=format$1(a,"y-MM-dd");return api.get("/api/v2/chart/budget/dashboard",{params:{start:n,end:r}})}};var isArray$a=Array.isArray,isArray_1=isArray$a;const isArray$b=getDefaultExportFromCjs(isArray_1);var freeGlobal$1=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root$8=freeGlobal||freeSelf||Function("return this")(),_root=root$8,root$7=_root,Symbol$6=root$7.Symbol,_Symbol=Symbol$6,Symbol$5=_Symbol,objectProto$d=Object.prototype,hasOwnProperty$a=objectProto$d.hasOwnProperty,nativeObjectToString$1=objectProto$d.toString,symToStringTag$1=Symbol$5?Symbol$5.toStringTag:void 0;function getRawTag$1(t){var e=hasOwnProperty$a.call(t,symToStringTag$1),a=t[symToStringTag$1];try{t[symToStringTag$1]=void 0;var n=!0}catch{}var r=nativeObjectToString$1.call(t);return n&&(e?t[symToStringTag$1]=a:delete t[symToStringTag$1]),r}var _getRawTag=getRawTag$1,objectProto$c=Object.prototype,nativeObjectToString=objectProto$c.toString;function objectToString$1(t){return nativeObjectToString.call(t)}var _objectToString=objectToString$1,Symbol$4=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$4?Symbol$4.toStringTag:void 0;function baseGetTag$5(t){return t==null?t===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(t)?getRawTag(t):objectToString(t)}var _baseGetTag=baseGetTag$5;function isObjectLike$5(t){return t!=null&&typeof t=="object"}var isObjectLike_1=isObjectLike$5,baseGetTag$4=_baseGetTag,isObjectLike$4=isObjectLike_1,symbolTag$1="[object Symbol]";function isSymbol$5(t){return typeof t=="symbol"||isObjectLike$4(t)&&baseGetTag$4(t)==symbolTag$1}var isSymbol_1=isSymbol$5,isArray$9=isArray_1,isSymbol$4=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$3(t,e){if(isArray$9(t))return!1;var a=typeof t;return a=="number"||a=="symbol"||a=="boolean"||t==null||isSymbol$4(t)?!0:reIsPlainProp.test(t)||!reIsDeepProp.test(t)||e!=null&&t in Object(e)}var _isKey=isKey$3;function isObject$6(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var isObject_1=isObject$6;const isObject$7=getDefaultExportFromCjs(isObject_1);var baseGetTag$3=_baseGetTag,isObject$5=isObject_1,asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$2(t){if(!isObject$5(t))return!1;var e=baseGetTag$3(t);return e==funcTag$1||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$2,root$6=_root,coreJsData$1=root$6["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=_coreJsData,maskSrcKey=function(){var t=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function isMasked$1(t){return!!maskSrcKey&&maskSrcKey in t}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$2(t){if(t!=null){try{return funcToString$1.call(t)}catch{}try{return t+""}catch{}}return""}var _toSource=toSource$2,isFunction$1=isFunction_1,isMasked=_isMasked,isObject$4=isObject_1,toSource$1=_toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$b=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$9=objectProto$b.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$9).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(t){if(!isObject$4(t)||isMasked(t))return!1;var e=isFunction$1(t)?reIsNative:reIsHostCtor;return e.test(toSource$1(t))}var _baseIsNative=baseIsNative$1;function getValue$1(t,e){return t==null?void 0:t[e]}var _getValue=getValue$1,baseIsNative=_baseIsNative,getValue=_getValue;function getNative$7(t,e){var a=getValue(t,e);return baseIsNative(a)?a:void 0}var _getNative=getNative$7,getNative$6=_getNative,nativeCreate$4=getNative$6(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$2="__lodash_hash_undefined__",objectProto$a=Object.prototype,hasOwnProperty$8=objectProto$a.hasOwnProperty;function hashGet$1(t){var e=this.__data__;if(nativeCreate$2){var a=e[t];return a===HASH_UNDEFINED$2?void 0:a}return hasOwnProperty$8.call(e,t)?e[t]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty;function hashHas$1(t){var e=this.__data__;return nativeCreate$1?e[t]!==void 0:hasOwnProperty$7.call(e,t)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__";function hashSet$1(t,e){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=nativeCreate&&e===void 0?HASH_UNDEFINED$1:e,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(t){var e=-1,a=t==null?0:t.length;for(this.clear();++e-1}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(t,e){var a=this.__data__,n=assocIndexOf(a,t);return n<0?(++this.size,a.push([t,e])):a[n][1]=e,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$4(t){var e=-1,a=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=MAX_SAFE_INTEGER$2}var isLength_1=isLength$3,castPath$1=_castPath,isArguments$2=isArguments_1,isArray$6=isArray_1,isIndex$3=_isIndex,isLength$2=isLength_1,toKey$3=_toKey;function hasPath$2(t,e,a){e=castPath$1(e,t);for(var n=-1,r=e.length,i=!1;++n-1}var _arrayIncludes=arrayIncludes$1;function arrayIncludesWith$1(t,e,a){for(var n=-1,r=t==null?0:t.length;++n=LARGE_ARRAY_SIZE$1){var u=e?null:createSet(t);if(u)return setToArray$1(u);o=!1,r=cacheHas$1,l=new SetCache$1}else l=e?[]:s;e:for(;++n{const a=[],n=[];return a.push(e),e||a.push(t.locale),t.enableFallback&&a.push(t.defaultLocale),a.filter(Boolean).map(r=>r.toString()).forEach(function(r){if(n.includes(r)||n.push(r),!t.enableFallback)return;const i=r.split("-");i.length===3&&n.push(`${i[0]}-${i[1]}`),n.push(i[0])}),uniq$1(n)};class Locales{constructor(e){this.i18n=e,this.registry={},this.register("default",defaultLocaleResolver)}register(e,a){if(typeof a!="function"){const n=a;a=()=>n}this.registry[e]=a}get(e){let a=this.registry[e]||this.registry[this.i18n.locale]||this.registry.default;return typeof a=="function"&&(a=a(this.i18n,e)),a instanceof Array||(a=[a]),a}}const en=(t,e)=>{const a=String(t).split("."),n=!a[1],r=Number(a[0])==t,i=r&&a[0].slice(-1),o=r&&a[0].slice(-2);return e?i==1&&o!=11?"one":i==2&&o!=12?"two":i==3&&o!=13?"few":"other":t==1&&n?"one":"other"};function useMakePlural({pluralizer:t,includeZero:e=!0,ordinal:a=!1}){return function(n,r){return[e&&r===0?"zero":"",t(r,a)].filter(Boolean)}}const defaultPluralizer=useMakePlural({pluralizer:en,includeZero:!0});class Pluralization{constructor(e){this.i18n=e,this.registry={},this.register("default",defaultPluralizer)}register(e,a){this.registry[e]=a}get(e){return this.registry[e]||this.registry[this.i18n.locale]||this.registry.default}}function baseSlice$1(t,e,a){var n=-1,r=t.length;e<0&&(e=-e>r?0:r+e),a=a>r?r:a,a<0&&(a+=r),r=e>a?0:a-e>>>0,e>>>=0;for(var i=Array(r);++n=n?t:baseSlice(t,e,a)}var _castSlice=castSlice$1,rsAstralRange$2="\\ud800-\\udfff",rsComboMarksRange$3="\\u0300-\\u036f",reComboHalfMarksRange$3="\\ufe20-\\ufe2f",rsComboSymbolsRange$3="\\u20d0-\\u20ff",rsComboRange$3=rsComboMarksRange$3+reComboHalfMarksRange$3+rsComboSymbolsRange$3,rsVarRange$2="\\ufe0e\\ufe0f",rsZWJ$2="\\u200d",reHasUnicode=RegExp("["+rsZWJ$2+rsAstralRange$2+rsComboRange$3+rsVarRange$2+"]");function hasUnicode$2(t){return reHasUnicode.test(t)}var _hasUnicode=hasUnicode$2;function asciiToArray$1(t){return t.split("")}var _asciiToArray=asciiToArray$1,rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$2="\\u0300-\\u036f",reComboHalfMarksRange$2="\\ufe20-\\ufe2f",rsComboSymbolsRange$2="\\u20d0-\\u20ff",rsComboRange$2=rsComboMarksRange$2+reComboHalfMarksRange$2+rsComboSymbolsRange$2,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo$2="["+rsComboRange$2+"]",rsFitz$1="\\ud83c[\\udffb-\\udfff]",rsModifier$1="(?:"+rsCombo$2+"|"+rsFitz$1+")",rsNonAstral$1="[^"+rsAstralRange$1+"]",rsRegional$1="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair$1="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod$1=rsModifier$1+"?",rsOptVar$1="["+rsVarRange$1+"]?",rsOptJoin$1="(?:"+rsZWJ$1+"(?:"+[rsNonAstral$1,rsRegional$1,rsSurrPair$1].join("|")+")"+rsOptVar$1+reOptMod$1+")*",rsSeq$1=rsOptVar$1+reOptMod$1+rsOptJoin$1,rsSymbol="(?:"+[rsNonAstral$1+rsCombo$2+"?",rsCombo$2,rsRegional$1,rsSurrPair$1,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz$1+"(?="+rsFitz$1+")|"+rsSymbol+rsSeq$1,"g");function unicodeToArray$1(t){return t.match(reUnicode)||[]}var _unicodeToArray=unicodeToArray$1,asciiToArray=_asciiToArray,hasUnicode$1=_hasUnicode,unicodeToArray=_unicodeToArray;function stringToArray$1(t){return hasUnicode$1(t)?unicodeToArray(t):asciiToArray(t)}var _stringToArray=stringToArray$1,castSlice=_castSlice,hasUnicode=_hasUnicode,stringToArray=_stringToArray,toString$4=toString_1;function createCaseFirst$1(t){return function(e){e=toString$4(e);var a=hasUnicode(e)?stringToArray(e):void 0,n=a?a[0]:e.charAt(0),r=a?castSlice(a,1).join(""):e.slice(1);return n[t]()+r}}var _createCaseFirst=createCaseFirst$1,createCaseFirst=_createCaseFirst,upperFirst$1=createCaseFirst("toUpperCase"),upperFirst_1=upperFirst$1,toString$3=toString_1,upperFirst=upperFirst_1;function capitalize$1(t){return upperFirst(toString$3(t).toLowerCase())}var capitalize_1=capitalize$1;function arrayReduce$1(t,e,a,n){var r=-1,i=t==null?0:t.length;for(n&&i&&(a=t[++r]);++r(e[camelCase$1(a)]=t[a],e),{}):{}}function isSet(t){return t!=null}function createTranslationOptions(t,e,a){let n=[{scope:e}];if(isSet(a.defaults)&&(n=n.concat(a.defaults)),isSet(a.defaultValue)){const r=typeof a.defaultValue=="function"?a.defaultValue(t,e,a):a.defaultValue;n.push({message:r}),delete a.defaultValue}return n}var isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER$1=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(t){var e,a,n,r=_.prototype={constructor:_,toString:null,valueOf:null},i=new _(1),o=20,s=4,l=-7,u=21,c=-1e7,d=1e7,h=!1,m=1,p=0,v={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},y="0123456789abcdefghijklmnopqrstuvwxyz",w=!0;function _(g,b){var $,S,P,M,C,E,T,x,A=this;if(!(A instanceof _))return new _(g,b);if(b==null){if(g&&g._isBigNumber===!0){A.s=g.s,!g.c||g.e>d?A.c=A.e=null:g.e=10;C/=10,M++);M>d?A.c=A.e=null:(A.e=M,A.c=[g]);return}x=String(g)}else{if(!isNumeric.test(x=String(g)))return n(A,x,E);A.s=x.charCodeAt(0)==45?(x=x.slice(1),-1):1}(M=x.indexOf("."))>-1&&(x=x.replace(".","")),(C=x.search(/e/i))>0?(M<0&&(M=C),M+=+x.slice(C+1),x=x.substring(0,C)):M<0&&(M=x.length)}else{if(intCheck(b,2,y.length,"Base"),b==10&&w)return A=new _(g),N(A,o+A.e+1,s);if(x=String(g),E=typeof g=="number"){if(g*0!=0)return n(A,x,E,b);if(A.s=1/g<0?(x=x.slice(1),-1):1,_.DEBUG&&x.replace(/^0\.0*|\./,"").length>15)throw Error(tooManyDigits+g)}else A.s=x.charCodeAt(0)===45?(x=x.slice(1),-1):1;for($=y.slice(0,b),M=C=0,T=x.length;CM){M=T;continue}}else if(!P&&(x==x.toUpperCase()&&(x=x.toLowerCase())||x==x.toLowerCase()&&(x=x.toUpperCase()))){P=!0,C=-1,M=0;continue}return n(A,String(g),E,b)}E=!1,x=a(x,b,10,A.s),(M=x.indexOf("."))>-1?x=x.replace(".",""):M=x.length}for(C=0;x.charCodeAt(C)===48;C++);for(T=x.length;x.charCodeAt(--T)===48;);if(x=x.slice(C,++T)){if(T-=C,E&&_.DEBUG&&T>15&&(g>MAX_SAFE_INTEGER$1||g!==mathfloor(g)))throw Error(tooManyDigits+A.s*g);if((M=M-C-1)>d)A.c=A.e=null;else if(M=-MAX&&P<=MAX&&P===mathfloor(P)){if(S[0]===0){if(P===0&&S.length===1)return!0;break e}if(b=(P+1)%LOG_BASE,b<1&&(b+=LOG_BASE),String(S[0]).length==b){for(b=0;b=BASE||$!==mathfloor($))break e;if($!==0)return!0}}}else if(S===null&&P===null&&(M===null||M===1||M===-1))return!0;throw Error(bignumberError+"Invalid BigNumber: "+g)},_.maximum=_.max=function(){return k(arguments,r.lt)},_.minimum=_.min=function(){return k(arguments,r.gt)},_.random=function(){var g=9007199254740992,b=Math.random()*g&2097151?function(){return mathfloor(Math.random()*g)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function($){var S,P,M,C,E,T=0,x=[],A=new _(i);if($==null?$=o:intCheck($,0,MAX),C=mathceil($/LOG_BASE),h)if(crypto.getRandomValues){for(S=crypto.getRandomValues(new Uint32Array(C*=2));T>>11),E>=9e15?(P=crypto.getRandomValues(new Uint32Array(2)),S[T]=P[0],S[T+1]=P[1]):(x.push(E%1e14),T+=2);T=C/2}else if(crypto.randomBytes){for(S=crypto.randomBytes(C*=7);T=9e15?crypto.randomBytes(7).copy(S,T):(x.push(E%1e14),T+=7);T=C/7}else throw h=!1,Error(bignumberError+"crypto unavailable");if(!h)for(;T=10;E/=10,T++);TP-1&&(E[C+1]==null&&(E[C+1]=0),E[C+1]+=E[C]/P|0,E[C]%=P)}return E.reverse()}return function($,S,P,M,C){var E,T,x,A,L,I,W,z,U=$.indexOf("."),B=o,V=s;for(U>=0&&(A=p,p=0,$=$.replace(".",""),z=new _(S),I=z.pow($.length-U),p=A,z.c=b(toFixedPoint(coeffToString(I.c),I.e,"0"),10,P,g),z.e=z.c.length),W=b($,S,P,C?(E=y,g):(E=g,y)),x=A=W.length;W[--A]==0;W.pop());if(!W[0])return E.charAt(0);if(U<0?--x:(I.c=W,I.e=x,I.s=M,I=e(I,z,B,V,P),W=I.c,L=I.r,x=I.e),T=x+B+1,U=W[T],A=P/2,L=L||T<0||W[T+1]!=null,L=V<4?(U!=null||L)&&(V==0||V==(I.s<0?3:2)):U>A||U==A&&(V==4||L||V==6&&W[T-1]&1||V==(I.s<0?8:7)),T<1||!W[0])$=L?toFixedPoint(E.charAt(1),-B,E.charAt(0)):E.charAt(0);else{if(W.length=T,L)for(--P;++W[--T]>P;)W[T]=0,T||(++x,W=[1].concat(W));for(A=W.length;!W[--A];);for(U=0,$="";U<=A;$+=E.charAt(W[U++]));$=toFixedPoint($,x,E.charAt(0))}return $}}(),e=function(){function g(S,P,M){var C,E,T,x,A=0,L=S.length,I=P%SQRT_BASE,W=P/SQRT_BASE|0;for(S=S.slice();L--;)T=S[L]%SQRT_BASE,x=S[L]/SQRT_BASE|0,C=W*T+x*I,E=I*T+C%SQRT_BASE*SQRT_BASE+A,A=(E/M|0)+(C/SQRT_BASE|0)+W*x,S[L]=E%M;return A&&(S=[A].concat(S)),S}function b(S,P,M,C){var E,T;if(M!=C)T=M>C?1:-1;else for(E=T=0;EP[E]?1:-1;break}return T}function $(S,P,M,C){for(var E=0;M--;)S[M]-=E,E=S[M]1;S.splice(0,1));}return function(S,P,M,C,E){var T,x,A,L,I,W,z,U,B,V,H,G,K,Y,J,Q,ee,Z=S.s==P.s?1:-1,X=S.c,q=P.c;if(!X||!X[0]||!q||!q[0])return new _(!S.s||!P.s||(X?q&&X[0]==q[0]:!q)?NaN:X&&X[0]==0||!q?Z*0:Z/0);for(U=new _(Z),B=U.c=[],x=S.e-P.e,Z=M+x+1,E||(E=BASE,x=bitFloor(S.e/LOG_BASE)-bitFloor(P.e/LOG_BASE),Z=Z/LOG_BASE|0),A=0;q[A]==(X[A]||0);A++);if(q[A]>(X[A]||0)&&x--,Z<0)B.push(1),L=!0;else{for(Y=X.length,Q=q.length,A=0,Z+=2,I=mathfloor(E/(q[0]+1)),I>1&&(q=g(q,I,E),X=g(X,I,E),Q=q.length,Y=X.length),K=Q,V=X.slice(0,Q),H=V.length;H=E/2&&J++;do{if(I=0,T=b(q,V,Q,H),T<0){if(G=V[0],Q!=H&&(G=G*E+(V[1]||0)),I=mathfloor(G/J),I>1)for(I>=E&&(I=E-1),W=g(q,I,E),z=W.length,H=V.length;b(W,V,z,H)==1;)I--,$(W,Q=10;Z/=10,A++);N(U,M+(U.e=A+x*LOG_BASE-1)+1,C,L)}else U.e=x,U.r=+L;return U}}();function D(g,b,$,S){var P,M,C,E,T;if($==null?$=s:intCheck($,0,8),!g.c)return g.toString();if(P=g.c[0],C=g.e,b==null)T=coeffToString(g.c),T=S==1||S==2&&(C<=l||C>=u)?toExponential(T,C):toFixedPoint(T,C,"0");else if(g=N(new _(g),b,$),M=g.e,T=coeffToString(g.c),E=T.length,S==1||S==2&&(b<=M||M<=l)){for(;EE){if(--b>0)for(T+=".";b--;T+="0");}else if(b+=M-E,b>0)for(M+1==E&&(T+=".");b--;T+="0");return g.s<0&&P?"-"+T:T}function k(g,b){for(var $,S=1,P=new _(g[0]);S=10;P/=10,S++);return($=S+$*LOG_BASE-1)>d?g.c=g.e=null:$=10;E/=10,P++);if(M=b-P,M<0)M+=LOG_BASE,C=b,T=L[x=0],A=T/I[P-C-1]%10|0;else if(x=mathceil((M+1)/LOG_BASE),x>=L.length)if(S){for(;L.length<=x;L.push(0));T=A=0,P=1,M%=LOG_BASE,C=M-LOG_BASE+1}else break e;else{for(T=E=L[x],P=1;E>=10;E/=10,P++);M%=LOG_BASE,C=M-LOG_BASE+P,A=C<0?0:T/I[P-C-1]%10|0}if(S=S||b<0||L[x+1]!=null||(C<0?T:T%I[P-C-1]),S=$<4?(A||S)&&($==0||$==(g.s<0?3:2)):A>5||A==5&&($==4||S||$==6&&(M>0?C>0?T/I[P-C]:0:L[x-1])%10&1||$==(g.s<0?8:7)),b<1||!L[0])return L.length=0,S?(b-=g.e+1,L[0]=I[(LOG_BASE-b%LOG_BASE)%LOG_BASE],g.e=-b||0):L[0]=g.e=0,g;if(M==0?(L.length=x,E=1,x--):(L.length=x+1,E=I[LOG_BASE-M],L[x]=C>0?mathfloor(T/I[P-C]%I[C])*E:0),S)for(;;)if(x==0){for(M=1,C=L[0];C>=10;C/=10,M++);for(C=L[0]+=E,E=1;C>=10;C/=10,E++);M!=E&&(g.e++,L[0]==BASE&&(L[0]=1));break}else{if(L[x]+=E,L[x]!=BASE)break;L[x--]=0,E=1}for(M=L.length;L[--M]===0;L.pop());}g.e>d?g.c=g.e=null:g.e=u?toExponential(b,$):toFixedPoint(b,$,"0"),g.s<0?"-"+b:b)}return r.absoluteValue=r.abs=function(){var g=new _(this);return g.s<0&&(g.s=1),g},r.comparedTo=function(g,b){return compare(this,new _(g,b))},r.decimalPlaces=r.dp=function(g,b){var $,S,P,M=this;if(g!=null)return intCheck(g,0,MAX),b==null?b=s:intCheck(b,0,8),N(new _(M),g+M.e+1,b);if(!($=M.c))return null;if(S=((P=$.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,P=$[P])for(;P%10==0;P/=10,S--);return S<0&&(S=0),S},r.dividedBy=r.div=function(g,b){return e(this,new _(g,b),o,s)},r.dividedToIntegerBy=r.idiv=function(g,b){return e(this,new _(g,b),0,1)},r.exponentiatedBy=r.pow=function(g,b){var $,S,P,M,C,E,T,x,A,L=this;if(g=new _(g),g.c&&!g.isInteger())throw Error(bignumberError+"Exponent not an integer: "+F(g));if(b!=null&&(b=new _(b)),E=g.e>14,!L.c||!L.c[0]||L.c[0]==1&&!L.e&&L.c.length==1||!g.c||!g.c[0])return A=new _(Math.pow(+F(L),E?g.s*(2-isOdd(g)):+F(g))),b?A.mod(b):A;if(T=g.s<0,b){if(b.c?!b.c[0]:!b.s)return new _(NaN);S=!T&&L.isInteger()&&b.isInteger(),S&&(L=L.mod(b))}else{if(g.e>9&&(L.e>0||L.e<-1||(L.e==0?L.c[0]>1||E&&L.c[1]>=24e7:L.c[0]<8e13||E&&L.c[0]<=9999975e7)))return M=L.s<0&&isOdd(g)?-0:0,L.e>-1&&(M=1/M),new _(T?1/M:M);p&&(M=mathceil(p/LOG_BASE+2))}for(E?($=new _(.5),T&&(g.s=1),x=isOdd(g)):(P=Math.abs(+F(g)),x=P%2),A=new _(i);;){if(x){if(A=A.times(L),!A.c)break;M?A.c.length>M&&(A.c.length=M):S&&(A=A.mod(b))}if(P){if(P=mathfloor(P/2),P===0)break;x=P%2}else if(g=g.times($),N(g,g.e+1,1),g.e>14)x=isOdd(g);else{if(P=+F(g),P===0)break;x=P%2}L=L.times(L),M?L.c&&L.c.length>M&&(L.c.length=M):S&&(L=L.mod(b))}return S?A:(T&&(A=i.div(A)),b?A.mod(b):M?N(A,p,s,C):A)},r.integerValue=function(g){var b=new _(this);return g==null?g=s:intCheck(g,0,8),N(b,b.e+1,g)},r.isEqualTo=r.eq=function(g,b){return compare(this,new _(g,b))===0},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(g,b){return compare(this,new _(g,b))>0},r.isGreaterThanOrEqualTo=r.gte=function(g,b){return(b=compare(this,new _(g,b)))===1||b===0},r.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},r.isLessThan=r.lt=function(g,b){return compare(this,new _(g,b))<0},r.isLessThanOrEqualTo=r.lte=function(g,b){return(b=compare(this,new _(g,b)))===-1||b===0},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return this.s>0},r.isZero=function(){return!!this.c&&this.c[0]==0},r.minus=function(g,b){var $,S,P,M,C=this,E=C.s;if(g=new _(g,b),b=g.s,!E||!b)return new _(NaN);if(E!=b)return g.s=-b,C.plus(g);var T=C.e/LOG_BASE,x=g.e/LOG_BASE,A=C.c,L=g.c;if(!T||!x){if(!A||!L)return A?(g.s=-b,g):new _(L?C:NaN);if(!A[0]||!L[0])return L[0]?(g.s=-b,g):new _(A[0]?C:s==3?-0:0)}if(T=bitFloor(T),x=bitFloor(x),A=A.slice(),E=T-x){for((M=E<0)?(E=-E,P=A):(x=T,P=L),P.reverse(),b=E;b--;P.push(0));P.reverse()}else for(S=(M=(E=A.length)<(b=L.length))?E:b,E=b=0;b0)for(;b--;A[$++]=0);for(b=BASE-1;S>E;){if(A[--S]=0;){for($=0,I=G[P]%B,W=G[P]/B|0,C=T,M=P+C;M>P;)x=H[--C]%B,A=H[C]/B|0,E=W*x+A*I,x=I*x+E%B*B+z[M]+$,$=(x/U|0)+(E/B|0)+W*A,z[M--]=x%U;z[M]=$}return $?++S:z.splice(0,1),O(g,z,S)},r.negated=function(){var g=new _(this);return g.s=-g.s||null,g},r.plus=function(g,b){var $,S=this,P=S.s;if(g=new _(g,b),b=g.s,!P||!b)return new _(NaN);if(P!=b)return g.s=-b,S.minus(g);var M=S.e/LOG_BASE,C=g.e/LOG_BASE,E=S.c,T=g.c;if(!M||!C){if(!E||!T)return new _(P/0);if(!E[0]||!T[0])return T[0]?g:new _(E[0]?S:P*0)}if(M=bitFloor(M),C=bitFloor(C),E=E.slice(),P=M-C){for(P>0?(C=M,$=T):(P=-P,$=E),$.reverse();P--;$.push(0));$.reverse()}for(P=E.length,b=T.length,P-b<0&&($=T,T=E,E=$,b=P),P=0;b;)P=(E[--b]=E[b]+T[b]+P)/BASE|0,E[b]=BASE===E[b]?0:E[b]%BASE;return P&&(E=[P].concat(E),++C),O(g,E,C)},r.precision=r.sd=function(g,b){var $,S,P,M=this;if(g!=null&&g!==!!g)return intCheck(g,1,MAX),b==null?b=s:intCheck(b,0,8),N(new _(M),g,b);if(!($=M.c))return null;if(P=$.length-1,S=P*LOG_BASE+1,P=$[P]){for(;P%10==0;P/=10,S--);for(P=$[0];P>=10;P/=10,S++);}return g&&M.e+1>S&&(S=M.e+1),S},r.shiftedBy=function(g){return intCheck(g,-MAX_SAFE_INTEGER$1,MAX_SAFE_INTEGER$1),this.times("1e"+g)},r.squareRoot=r.sqrt=function(){var g,b,$,S,P,M=this,C=M.c,E=M.s,T=M.e,x=o+4,A=new _("0.5");if(E!==1||!C||!C[0])return new _(!E||E<0&&(!C||C[0])?NaN:C?M:1/0);if(E=Math.sqrt(+F(M)),E==0||E==1/0?(b=coeffToString(C),(b.length+T)%2==0&&(b+="0"),E=Math.sqrt(+b),T=bitFloor((T+1)/2)-(T<0||T%2),E==1/0?b="5e"+T:(b=E.toExponential(),b=b.slice(0,b.indexOf("e")+1)+T),$=new _(b)):$=new _(E+""),$.c[0]){for(T=$.e,E=T+x,E<3&&(E=0);;)if(P=$,$=A.times(P.plus(e(M,P,x,1))),coeffToString(P.c).slice(0,E)===(b=coeffToString($.c)).slice(0,E))if($.e0&&z>0){for(M=z%E||E,A=W.substr(0,M);M0&&(A+=x+W.slice(M)),I&&(A="-"+A)}S=L?A+($.decimalSeparator||"")+((T=+$.fractionGroupSize)?L.replace(new RegExp("\\d{"+T+"}\\B","g"),"$&"+($.fractionGroupSeparator||"")):L):A}return($.prefix||"")+S+($.suffix||"")},r.toFraction=function(g){var b,$,S,P,M,C,E,T,x,A,L,I,W=this,z=W.c;if(g!=null&&(E=new _(g),!E.isInteger()&&(E.c||E.s!==1)||E.lt(i)))throw Error(bignumberError+"Argument "+(E.isInteger()?"out of range: ":"not an integer: ")+F(E));if(!z)return new _(W);for(b=new _(i),x=$=new _(i),S=T=new _(i),I=coeffToString(z),M=b.e=I.length-W.e-1,b.c[0]=POWS_TEN[(C=M%LOG_BASE)<0?LOG_BASE+C:C],g=!g||E.comparedTo(b)>0?M>0?b:x:E,C=d,d=1/0,E=new _(I),T.c[0]=0;A=e(E,b,0,1),P=$.plus(A.times(S)),P.comparedTo(g)!=1;)$=S,S=P,x=T.plus(A.times(P=x)),T=P,b=E.minus(A.times(P=b)),E=P;return P=e(g.minus($),S,0,1),T=T.plus(P.times(x)),$=$.plus(P.times(S)),T.s=x.s=W.s,M=M*2,L=e(x,S,M,s).minus(W).abs().comparedTo(e(T,$,M,s).minus(W).abs())<1?[x,S]:[T,$],d=C,L},r.toNumber=function(){return+F(this)},r.toPrecision=function(g,b){return g!=null&&intCheck(g,1,MAX),D(this,g,b,2)},r.toString=function(g){var b,$=this,S=$.s,P=$.e;return P===null?S?(b="Infinity",S<0&&(b="-"+b)):b="NaN":(g==null?b=P<=l||P>=u?toExponential(coeffToString($.c),P):toFixedPoint(coeffToString($.c),P,"0"):g===10&&w?($=N(new _($),o+P+1,s),b=toFixedPoint(coeffToString($.c),$.e,"0")):(intCheck(g,2,y.length,"Base"),b=a(toFixedPoint(coeffToString($.c),P,"0"),10,g,S,!0)),S<0&&$.c[0]&&(b="-"+b)),b},r.valueOf=r.toJSON=function(){return F(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,t!=null&&_.set(t),_}function bitFloor(t){var e=t|0;return t>0||t===e?e:e-1}function coeffToString(t){for(var e,a,n=1,r=t.length,i=t[0]+"";nu^a?1:-1;for(s=(l=r.length)<(u=i.length)?l:u,o=0;oi[o]^a?1:-1;return l==u?0:l>u^a?1:-1}function intCheck(t,e,a,n){if(ta||t!==mathfloor(t))throw Error(bignumberError+(n||"Argument")+(typeof t=="number"?ta?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function isOdd(t){var e=t.c.length-1;return bitFloor(t.e/LOG_BASE)==e&&t.c[e]%2!=0}function toExponential(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function toFixedPoint(t,e,a){var n,r;if(e<0){for(r=a+".";++e;r+=a);t=r+t}else if(n=t.length,++e>n){for(r=a,e-=n;--e;r+=a);t+=r}else eMAX_SAFE_INTEGER)return a;do e%2&&(a+=t),e=nativeFloor(e/2),e&&(t+=t);while(e);return a}var _baseRepeat=baseRepeat$1,isFunction=isFunction_1,isLength$1=isLength_1;function isArrayLike$4(t){return t!=null&&isLength$1(t.length)&&!isFunction(t)}var isArrayLike_1=isArrayLike$4,eq$1=eq_1,isArrayLike$3=isArrayLike_1,isIndex$1=_isIndex,isObject$2=isObject_1;function isIterateeCall$3(t,e,a){if(!isObject$2(a))return!1;var n=typeof e;return(n=="number"?isArrayLike$3(a)&&isIndex$1(e,a.length):n=="string"&&e in a)?eq$1(a[e],t):!1}var _isIterateeCall=isIterateeCall$3,reWhitespace=/\s/;function trimmedEndIndex$1(t){for(var e=t.length;e--&&reWhitespace.test(t.charAt(e)););return e}var _trimmedEndIndex=trimmedEndIndex$1,trimmedEndIndex=_trimmedEndIndex,reTrimStart=/^\s+/;function baseTrim$1(t){return t&&t.slice(0,trimmedEndIndex(t)+1).replace(reTrimStart,"")}var _baseTrim=baseTrim$1,baseTrim=_baseTrim,isObject$1=isObject_1,isSymbol$1=isSymbol_1,NAN=0/0,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber$1(t){if(typeof t=="number")return t;if(isSymbol$1(t))return NAN;if(isObject$1(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=isObject$1(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=baseTrim(t);var a=reIsBinary.test(t);return a||reIsOctal.test(t)?freeParseInt(t.slice(2),a?2:8):reIsBadHex.test(t)?NAN:+t}var toNumber_1=toNumber$1,toNumber=toNumber_1,INFINITY$1=1/0,MAX_INTEGER=17976931348623157e292;function toFinite$2(t){if(!t)return t===0?t:0;if(t=toNumber(t),t===INFINITY$1||t===-INFINITY$1){var e=t<0?-1:1;return e*MAX_INTEGER}return t===t?t:0}var toFinite_1=toFinite$2,toFinite$1=toFinite_1;function toInteger$1(t){var e=toFinite$1(t),a=e%1;return e===e?a?e-a:e:0}var toInteger_1=toInteger$1,baseRepeat=_baseRepeat,isIterateeCall$2=_isIterateeCall,toInteger=toInteger_1,toString=toString_1;function repeat(t,e,a){return(a?isIterateeCall$2(t,e,a):e===void 0)?e=1:e=toInteger(e),baseRepeat(toString(t),e)}var repeat_1=repeat;const repeat$1=getDefaultExportFromCjs(repeat_1);function digitCount(t){return t.isZero()?1:Math.floor(Math.log10(t.abs().toNumber())+1)}function getAbsolutePrecision(t,{precision:e,significant:a}){return a&&e!==null&&e>0?e-digitCount(t):e}function roundNumber(t,e){const a=getAbsolutePrecision(t,e);if(a===null)return t.toString();const n=expandRoundMode(e.roundMode);if(a>=0)return t.toFixed(a,n);const r=Math.pow(10,Math.abs(a));return t=new BigNumber(t.div(r).toFixed(0,n)).times(r),t.toString()}function replaceInFormat(t,{formattedNumber:e,unit:a}){return t.replace("%n",e).replace("%u",a)}function computeSignificand({significand:t,whole:e,precision:a}){if(e==="0"||a===null)return t;const n=Math.max(0,a-e.length);return(t??"").substr(0,n)}function formatNumber(t,e){var a,n,r;const i=new BigNumber(t);if(e.raise&&!i.isFinite())throw new Error(`"${t}" is not a valid numeric value`);const o=roundNumber(i,e),s=new BigNumber(o),l=s.lt(0),u=s.isZero();let[c,d]=o.split(".");const h=[];let m;const p=(a=e.format)!==null&&a!==void 0?a:"%n",v=(n=e.negativeFormat)!==null&&n!==void 0?n:`-${p}`,y=l&&!u?v:p;for(c=c.replace("-","");c.length>0;)h.unshift(c.substr(Math.max(0,c.length-3),3)),c=c.substr(0,c.length-3);return c=h.join(""),m=h.join(e.delimiter),e.significant?d=computeSignificand({whole:c,significand:d,precision:e.precision}):d=d??repeat$1("0",(r=e.precision)!==null&&r!==void 0?r:0),e.stripInsignificantZeros&&d&&(d=d.replace(/0+$/,"")),i.isNaN()&&(m=t.toString()),d&&i.isFinite()&&(m+=(e.separator||".")+d),replaceInFormat(y,{formattedNumber:m,unit:e.unit})}function getFullScope(t,e,a){let n="";return(e instanceof String||typeof e=="string")&&(n=e),e instanceof Array&&(n=e.join(t.defaultSeparator)),a.scope&&(n=[a.scope,n].join(t.defaultSeparator)),n}function inferType(t){var e,a;if(t===null)return"null";const n=typeof t;return n!=="object"?n:((a=(e=t==null?void 0:t.constructor)===null||e===void 0?void 0:e.name)===null||a===void 0?void 0:a.toLowerCase())||"object"}function interpolate(t,e,a){a=Object.keys(a).reduce((r,i)=>(r[t.transformKey(i)]=a[i],r),{});const n=e.match(t.placeholder);if(!n)return e;for(;n.length;){let r;const i=n.shift(),o=i.replace(t.placeholder,"$1");isSet(a[o])?r=a[o].toString().replace(/\$/gm,"_#$#_"):o in a?r=t.nullPlaceholder(t,i,e,a):r=t.missingPlaceholder(t,i,e,a);const s=new RegExp(i.replace(/\{/gm,"\\{").replace(/\}/gm,"\\}"));e=e.replace(s,r)}return e.replace(/_#\$#_/g,"$")}function lookup(t,e,a={}){a=Object.assign({},a);const n="locale"in a?a.locale:t.locale,r=inferType(n),i=t.locales.get(r==="string"?n:typeof n).slice();e=getFullScope(t,e,a).split(t.defaultSeparator).map(s=>t.transformKey(s)).join(".");const o=i.map(s=>get$2(t.translations,[s,e].join(".")));return o.push(a.defaultValue),o.find(s=>isSet(s))}function numberToDelimited(t,e){const a=new BigNumber(t);if(!a.isFinite())return t.toString();if(!e.delimiterPattern.global)throw new Error(`options.delimiterPattern must be a global regular expression; received ${e.delimiterPattern}`);let[n,r]=a.toString().split(".");return n=n.replace(e.delimiterPattern,i=>`${i}${e.delimiter}`),[n,r].filter(Boolean).join(e.separator)}function arrayPush$2(t,e){for(var a=-1,n=e.length,r=t.length;++a0&&a(s)?e>1?baseFlatten$2(s,e-1,a,n,r):arrayPush$1(r,s):n||(r[r.length]=s)}return r}var _baseFlatten=baseFlatten$2,ListCache$2=_ListCache;function stackClear$1(){this.__data__=new ListCache$2,this.size=0}var _stackClear=stackClear$1;function stackDelete$1(t){var e=this.__data__,a=e.delete(t);return this.size=e.size,a}var _stackDelete=stackDelete$1;function stackGet$1(t){return this.__data__.get(t)}var _stackGet=stackGet$1;function stackHas$1(t){return this.__data__.has(t)}var _stackHas=stackHas$1,ListCache$1=_ListCache,Map$2=_Map,MapCache=_MapCache,LARGE_ARRAY_SIZE=200;function stackSet$1(t,e){var a=this.__data__;if(a instanceof ListCache$1){var n=a.__data__;if(!Map$2||n.lengths))return!1;var u=i.get(t),c=i.get(e);if(u&&c)return u==e&&c==t;var d=-1,h=!0,m=a&COMPARE_UNORDERED_FLAG$3?new SetCache:void 0;for(i.set(t,e),i.set(e,t);++de||i&&o&&l&&!s&&!u||n&&o&&l||!a&&l||!r)return 1;if(!n&&!i&&!u&&t=s)return l;var u=a[n];return l*(u=="desc"?-1:1)}}return t.index-e.index}var _compareMultiple=compareMultiple$1,arrayMap=_arrayMap,baseGet=_baseGet,baseIteratee=_baseIteratee,baseMap=_baseMap,baseSortBy=_baseSortBy,baseUnary=_baseUnary,compareMultiple=_compareMultiple,identity$2=identity_1,isArray=isArray_1;function baseOrderBy$1(t,e,a){e.length?e=arrayMap(e,function(i){return isArray(i)?function(o){return baseGet(o,i.length===1?i[0]:i)}:i}):e=[identity$2];var n=-1;e=arrayMap(e,baseUnary(baseIteratee));var r=baseMap(t,function(i,o,s){var l=arrayMap(e,function(u){return u(i)});return{criteria:l,index:++n,value:i}});return baseSortBy(r,function(i,o){return compareMultiple(i,o,a)})}var _baseOrderBy=baseOrderBy$1;function apply$1(t,e,a){switch(a.length){case 0:return t.call(e);case 1:return t.call(e,a[0]);case 2:return t.call(e,a[0],a[1]);case 3:return t.call(e,a[0],a[1],a[2])}return t.apply(e,a)}var _apply=apply$1,apply=_apply,nativeMax$1=Math.max;function overRest$1(t,e,a){return e=nativeMax$1(e===void 0?t.length-1:e,0),function(){for(var n=arguments,r=-1,i=nativeMax$1(n.length-e,0),o=Array(i);++r0){if(++e>=HOT_COUNT)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var _shortOut=shortOut$1,baseSetToString=_baseSetToString,shortOut=_shortOut,setToString$1=shortOut(baseSetToString),_setToString=setToString$1,identity=identity_1,overRest=_overRest,setToString=_setToString;function baseRest$1(t,e){return setToString(overRest(t,e,identity),t+"")}var _baseRest=baseRest$1,baseFlatten$1=_baseFlatten,baseOrderBy=_baseOrderBy,baseRest=_baseRest,isIterateeCall$1=_isIterateeCall,sortBy=baseRest(function(t,e){if(t==null)return[];var a=e.length;return a>1&&isIterateeCall$1(t,e[0],e[1])?e=[]:a>2&&isIterateeCall$1(e[0],e[1],e[2])&&(e=[e[0]]),baseOrderBy(t,baseFlatten$1(e,1),[])}),sortBy_1=sortBy;const sortBy$1=getDefaultExportFromCjs(sortBy_1);function baseZipObject$1(t,e,a){for(var n=-1,r=t.length,i=e.length,o={};++nparseInt(t,10)));function numberToHuman(t,e,a){const n={roundMode:a.roundMode,precision:a.precision,significant:a.significant};let r;if(inferType(a.units)==="string"){const d=a.units;if(r=lookup(t,d),!r)throw new Error(`The scope "${t.locale}${t.defaultSeparator}${getFullScope(t,d,{})}" couldn't be found`)}else r=a.units;let i=roundNumber(new BigNumber(e),n);const o=d=>sortBy$1(Object.keys(d).map(h=>INVERTED_DECIMAL_UNITS[h]),h=>h*-1),s=(d,h)=>{const m=d.isZero()?0:Math.floor(Math.log10(d.abs().toNumber()));return o(h).find(p=>m>=p)||0},l=(d,h)=>{const m=DECIMAL_UNITS[h.toString()];return d[m]||""},u=s(new BigNumber(i),r),c=l(r,u);if(i=roundNumber(new BigNumber(i).div(Math.pow(10,u)),n),a.stripInsignificantZeros){let[d,h]=i.split(".");h=(h||"").replace(/0+$/,""),i=d,h&&(i+=`${a.separator}${h}`)}return a.format.replace("%n",i||"0").replace("%u",c).trim()}const STORAGE_UNITS=["byte","kb","mb","gb","tb","pb","eb"];function numberToHumanSize(t,e,a){const n=expandRoundMode(a.roundMode),r=1024,i=new BigNumber(e).abs(),o=i.lt(r);let s;const l=(p,v)=>{const y=v.length-1,w=new BigNumber(Math.log(p.toNumber())).div(Math.log(r)).integerValue(BigNumber.ROUND_DOWN).toNumber();return Math.min(y,w)},u=p=>`number.human.storage_units.units.${o?"byte":p[c]}`,c=l(i,STORAGE_UNITS);o?s=i.integerValue():s=new BigNumber(roundNumber(i.div(Math.pow(r,c)),{significant:a.significant,precision:a.precision,roundMode:a.roundMode}));const d=t.translate("number.human.storage_units.format",{defaultValue:"%n %u"}),h=t.translate(u(STORAGE_UNITS),{count:i.integerValue().toNumber()});let m=s.toFixed(a.precision,n);return a.stripInsignificantZeros&&(m=m.replace(/(\..*?)0+$/,"$1").replace(/\.$/,"")),d.replace("%n",m).replace("%u",h)}function parseDate(t){if(t instanceof Date)return t;if(typeof t=="number"){const n=new Date;return n.setTime(t),n}const e=new String(t).match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})(?:[.,](\d{1,3}))?)?(Z|\+00:?00)?/);if(e){const n=e.slice(1,8).map(h=>parseInt(h,10)||0);n[1]-=1;const[r,i,o,s,l,u,c]=n;return e[8]?new Date(Date.UTC(r,i,o,s,l,u,c)):new Date(r,i,o,s,l,u,c)}t.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)&&new Date().setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" ")));const a=new Date;return a.setTime(Date.parse(t)),a}function pluralize({i18n:t,count:e,scope:a,options:n,baseScope:r}){n=Object.assign({},n);let i,o;if(typeof a=="object"&&a?i=a:i=lookup(t,a,n),!i)return t.missingTranslation.get(a,n);const l=t.pluralization.get(n.locale)(t,e),u=[];for(;l.length;){const c=l.shift();if(isSet(i[c])){o=i[c];break}u.push(c)}return isSet(o)?(n.count=e,t.interpolate(t,o,n)):t.missingTranslation.get(r.split(t.defaultSeparator).concat([u[0]]),n)}var baseFlatten=_baseFlatten,INFINITY=1/0;function flattenDeep(t){var e=t==null?0:t.length;return e?baseFlatten(t,INFINITY):[]}var flattenDeep_1=flattenDeep;const flattenDeep$1=getDefaultExportFromCjs(flattenDeep_1);class PropertyFlatList{constructor(e){this.target=e}call(){const e=flattenDeep$1(Object.keys(this.target).map(a=>this.compute(this.target[a],a)));return e.sort(),e}compute(e,a){return!isArray$b(e)&&isObject$7(e)?Object.keys(e).map(n=>this.compute(e[n],`${a}.${n}`)):a}}function propertyFlatList(t){return new PropertyFlatList(t).call()}const DEFAULT_OPTIONS={meridian:{am:"AM",pm:"PM"},dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbrDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthNames:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbrMonthNames:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]};function strftime(t,e,a={}){const{abbrDayNames:n,dayNames:r,abbrMonthNames:i,monthNames:o,meridian:s}=Object.assign(Object.assign({},DEFAULT_OPTIONS),a);if(isNaN(t.getTime()))throw new Error("strftime() requires a valid date object, but received an invalid date.");const l=t.getDay(),u=t.getDate(),c=t.getFullYear(),d=t.getMonth()+1,h=t.getHours();let m=h;const p=h>11?"pm":"am",v=t.getSeconds(),y=t.getMinutes(),w=t.getTimezoneOffset(),_=Math.floor(Math.abs(w/60)),D=Math.abs(w)-_*60,k=(w>0?"-":"+")+(_.toString().length<2?"0"+_:_)+(D.toString().length<2?"0"+D:D);return m>12?m=m-12:m===0&&(m=12),e=e.replace("%a",n[l]),e=e.replace("%A",r[l]),e=e.replace("%b",i[d]),e=e.replace("%B",o[d]),e=e.replace("%d",u.toString().padStart(2,"0")),e=e.replace("%e",u.toString()),e=e.replace("%-d",u.toString()),e=e.replace("%H",h.toString().padStart(2,"0")),e=e.replace("%-H",h.toString()),e=e.replace("%k",h.toString()),e=e.replace("%I",m.toString().padStart(2,"0")),e=e.replace("%-I",m.toString()),e=e.replace("%l",m.toString()),e=e.replace("%m",d.toString().padStart(2,"0")),e=e.replace("%-m",d.toString()),e=e.replace("%M",y.toString().padStart(2,"0")),e=e.replace("%-M",y.toString()),e=e.replace("%p",s[p]),e=e.replace("%P",s[p].toLowerCase()),e=e.replace("%S",v.toString().padStart(2,"0")),e=e.replace("%-S",v.toString()),e=e.replace("%w",l.toString()),e=e.replace("%y",c.toString().padStart(2,"0").substr(-2)),e=e.replace("%-y",c.toString().padStart(2,"0").substr(-2).replace(/^0+/,"")),e=e.replace("%Y",c.toString()),e=e.replace(/%z/i,k),e}var nativeCeil=Math.ceil,nativeMax=Math.max;function baseRange$1(t,e,a,n){for(var r=-1,i=nativeMax(nativeCeil((e-t)/(a||1)),0),o=Array(i);i--;)o[n?i:++r]=t,t+=a;return o}var _baseRange=baseRange$1,baseRange=_baseRange,isIterateeCall=_isIterateeCall,toFinite=toFinite_1;function createRange$1(t){return function(e,a,n){return n&&typeof n!="number"&&isIterateeCall(e,a,n)&&(a=n=void 0),e=toFinite(e),a===void 0?(a=e,e=0):a=toFinite(a),n=n===void 0?ea>=t&&a<=e;function timeAgoInWords(t,e,a,n={}){const r=n.scope||"datetime.distance_in_words",i=(F,g=0)=>t.t(F,{count:g,scope:r});e=parseDate(e),a=parseDate(a);let o=e.getTime()/1e3,s=a.getTime()/1e3;o>s&&([e,a,o,s]=[a,e,s,o]);const l=Math.round(s-o),u=Math.round((s-o)/60),d=u/60/24,h=Math.round(u/60),m=Math.round(d),p=Math.round(m/30);if(within(0,1,u))return n.includeSeconds?within(0,4,l)?i("less_than_x_seconds",5):within(5,9,l)?i("less_than_x_seconds",10):within(10,19,l)?i("less_than_x_seconds",20):within(20,39,l)?i("half_a_minute"):within(40,59,l)?i("less_than_x_minutes",1):i("x_minutes",1):u===0?i("less_than_x_minutes",1):i("x_minutes",u);if(within(2,44,u))return i("x_minutes",u);if(within(45,89,u))return i("about_x_hours",1);if(within(90,1439,u))return i("about_x_hours",h);if(within(1440,2519,u))return i("x_days",1);if(within(2520,43199,u))return i("x_days",m);if(within(43200,86399,u))return i("about_x_months",Math.round(u/43200));if(within(86400,525599,u))return i("x_months",p);let v=e.getFullYear();e.getMonth()+1>=3&&(v+=1);let y=a.getFullYear();a.getMonth()+1<3&&(y-=1);const w=v>y?0:range$1(v,y).filter(F=>new Date(F,1,29).getMonth()==1).length,_=525600,D=w*1440,k=u-D,O=Math.trunc(k/_),N=parseFloat((k/_-O).toPrecision(3));return N<.25?i("about_x_years",O):N<.75?i("over_x_years",O):i("almost_x_years",O+1)}const guessStrategy=function(t,e){e instanceof Array&&(e=e.join(t.defaultSeparator));const a=e.split(t.defaultSeparator).slice(-1)[0];return t.missingTranslationPrefix+a.replace("_"," ").replace(/([a-z])([A-Z])/g,(n,r,i)=>`${r} ${i.toLowerCase()}`)},messageStrategy=(t,e,a)=>{const n=getFullScope(t,e,a),r="locale"in a?a.locale:t.locale,i=inferType(r);return`[missing "${[i=="string"?r:i,n].join(t.defaultSeparator)}" translation]`},errorStrategy=(t,e,a)=>{const n=getFullScope(t,e,a),r=[t.locale,n].join(t.defaultSeparator);throw new Error(`Missing translation: ${r}`)};class MissingTranslation{constructor(e){this.i18n=e,this.registry={},this.register("guess",guessStrategy),this.register("message",messageStrategy),this.register("error",errorStrategy)}register(e,a){this.registry[e]=a}get(e,a){var n;return this.registry[(n=a.missingBehavior)!==null&&n!==void 0?n:this.i18n.missingBehavior](this.i18n,e,a)}}var __awaiter=globalThis&&globalThis.__awaiter||function(t,e,a,n){function r(i){return i instanceof a?i:new a(function(o){o(i)})}return new(a||(a=Promise))(function(i,o){function s(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):r(c.value).then(s,l)}u((n=n.apply(t,e||[])).next())})};const DEFAULT_I18N_OPTIONS={defaultLocale:"en",availableLocales:["en"],locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,enableFallback:!1,missingBehavior:"message",missingTranslationPrefix:"",missingPlaceholder:(t,e)=>`[missing "${e}" value]`,nullPlaceholder:(t,e,a,n)=>t.missingPlaceholder(t,e,a,n),transformKey:t=>t};class I18n{constructor(e={},a={}){this._locale=DEFAULT_I18N_OPTIONS.locale,this._defaultLocale=DEFAULT_I18N_OPTIONS.defaultLocale,this._version=0,this.onChangeHandlers=[],this.translations={},this.availableLocales=[],this.t=this.translate,this.p=this.pluralize,this.l=this.localize,this.distanceOfTimeInWords=this.timeAgoInWords;const{locale:n,enableFallback:r,missingBehavior:i,missingTranslationPrefix:o,missingPlaceholder:s,nullPlaceholder:l,defaultLocale:u,defaultSeparator:c,placeholder:d,transformKey:h}=Object.assign(Object.assign({},DEFAULT_I18N_OPTIONS),a);this.locale=n,this.defaultLocale=u,this.defaultSeparator=c,this.enableFallback=r,this.locale=n,this.missingBehavior=i,this.missingTranslationPrefix=o,this.missingPlaceholder=s,this.nullPlaceholder=l,this.placeholder=d,this.pluralization=new Pluralization(this),this.locales=new Locales(this),this.missingTranslation=new MissingTranslation(this),this.transformKey=h,this.interpolate=interpolate,this.store(e)}store(e){propertyFlatList(e).forEach(n=>set$1(this.translations,n,get$2(e,n))),this.hasChanged()}get locale(){return this._locale||this.defaultLocale||"en"}set locale(e){if(typeof e!="string")throw new Error(`Expected newLocale to be a string; got ${inferType(e)}`);const a=this._locale!==e;this._locale=e,a&&this.hasChanged()}get defaultLocale(){return this._defaultLocale||"en"}set defaultLocale(e){if(typeof e!="string")throw new Error(`Expected newLocale to be a string; got ${inferType(e)}`);const a=this._defaultLocale!==e;this._defaultLocale=e,a&&this.hasChanged()}translate(e,a){a=Object.assign({},a);const n=createTranslationOptions(this,e,a);let r;return n.some(o=>(isSet(o.scope)?r=lookup(this,o.scope,a):isSet(o.message)&&(r=o.message),r!=null))?(typeof r=="string"?r=this.interpolate(this,r,a):typeof r=="object"&&r&&isSet(a.count)&&(r=pluralize({i18n:this,count:a.count||0,scope:r,options:a,baseScope:getFullScope(this,e,a)})),a&&r instanceof Array&&(r=r.map(o=>typeof o=="string"?interpolate(this,o,a):o)),r):this.missingTranslation.get(e,a)}pluralize(e,a,n){return pluralize({i18n:this,count:e,scope:a,options:Object.assign({},n),baseScope:getFullScope(this,a,n??{})})}localize(e,a,n){if(n=Object.assign({},n),a==null)return"";switch(e){case"currency":return this.numberToCurrency(a);case"number":return formatNumber(a,Object.assign({delimiter:",",precision:3,separator:".",significant:!1,stripInsignificantZeros:!1},lookup(this,"number.format")));case"percentage":return this.numberToPercentage(a);default:{let r;return e.match(/^(date|time)/)?r=this.toTime(e,a):r=a.toString(),interpolate(this,r,n)}}}toTime(e,a){const n=parseDate(a),r=lookup(this,e);return n.toString().match(/invalid/i)||!r?n.toString():this.strftime(n,r)}numberToCurrency(e,a={}){return formatNumber(e,Object.assign(Object.assign(Object.assign({delimiter:",",format:"%u%n",precision:2,separator:".",significant:!1,stripInsignificantZeros:!1,unit:"$"},camelCaseKeys(this.get("number.format"))),camelCaseKeys(this.get("number.currency.format"))),a))}numberToPercentage(e,a={}){return formatNumber(e,Object.assign(Object.assign(Object.assign({delimiter:"",format:"%n%",precision:3,stripInsignificantZeros:!1,separator:".",significant:!1},camelCaseKeys(this.get("number.format"))),camelCaseKeys(this.get("number.percentage.format"))),a))}numberToHumanSize(e,a={}){return numberToHumanSize(this,e,Object.assign(Object.assign(Object.assign({delimiter:"",precision:3,significant:!0,stripInsignificantZeros:!0,units:{billion:"Billion",million:"Million",quadrillion:"Quadrillion",thousand:"Thousand",trillion:"Trillion",unit:""}},camelCaseKeys(this.get("number.human.format"))),camelCaseKeys(this.get("number.human.storage_units"))),a))}numberToHuman(e,a={}){return numberToHuman(this,e,Object.assign(Object.assign(Object.assign({delimiter:"",separator:".",precision:3,significant:!0,stripInsignificantZeros:!0,format:"%n %u",roundMode:"default",units:{billion:"Billion",million:"Million",quadrillion:"Quadrillion",thousand:"Thousand",trillion:"Trillion",unit:""}},camelCaseKeys(this.get("number.human.format"))),camelCaseKeys(this.get("number.human.decimal_units"))),a))}numberToRounded(e,a){return formatNumber(e,Object.assign({unit:"",precision:3,significant:!1,separator:".",delimiter:"",stripInsignificantZeros:!1},a))}numberToDelimited(e,a={}){return numberToDelimited(e,Object.assign({delimiterPattern:/(\d)(?=(\d\d\d)+(?!\d))/g,delimiter:",",separator:"."},a))}withLocale(e,a){return __awaiter(this,void 0,void 0,function*(){const n=this.locale;try{this.locale=e,yield a()}finally{this.locale=n}})}strftime(e,a,n={}){return strftime(e,a,Object.assign(Object.assign(Object.assign({},camelCaseKeys(lookup(this,"date"))),{meridian:{am:lookup(this,"time.am")||"AM",pm:lookup(this,"time.pm")||"PM"}}),n))}update(e,a,n={strict:!1}){if(n.strict&&!has$1(this.translations,e))throw new Error(`The path "${e}" is not currently defined`);const r=get$2(this.translations,e),i=inferType(r),o=inferType(a);if(n.strict&&i!==o)throw new Error(`The current type for "${e}" is "${i}", but you're trying to override it with "${o}"`);let s;o==="object"?s=Object.assign(Object.assign({},r),a):s=a,set$1(this.translations,e,s),this.hasChanged()}toSentence(e,a={}){const{wordsConnector:n,twoWordsConnector:r,lastWordConnector:i}=Object.assign(Object.assign({wordsConnector:", ",twoWordsConnector:" and ",lastWordConnector:", and "},camelCaseKeys(lookup(this,"support.array"))),a),o=e.length;switch(o){case 0:return"";case 1:return`${e[0]}`;case 2:return e.join(r);default:return[e.slice(0,o-1).join(n),i,e[o-1]].join("")}}timeAgoInWords(e,a,n={}){return timeAgoInWords(this,e,a,n)}onChange(e){return this.onChangeHandlers.push(e),()=>{this.onChangeHandlers.splice(this.onChangeHandlers.indexOf(e),1)}}get version(){return this._version}formatNumber(e,a){return formatNumber(e,a)}get(e){return lookup(this,e)}runCallbacks(){this.onChangeHandlers.forEach(e=>e(this))}hasChanged(){this._version+=1,this.runCallbacks()}}async function loadTranslations(t,e){const n=await(await fetch(`./v2/i18n/${e}.json`)).json();t.store(n)}let currencies$1=[],chart$3=null,chartData$1=null,afterPromises$4=!1,i18n$3;const CACHE_KEY$4="dashboard-budgets-chart",budgets=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,chartData$1!==null){this.drawChart(this.generateOptions(chartData$1)),this.loading=!1;return}this.getFreshData()}},drawChart(t){if(chart$3!==null){chart$3.data.datasets=t.data.datasets,chart$3.update();return}chart$3=new Chart(document.querySelector("#budget-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$4);if(t&&typeof e<"u"){chartData$1=e,this.drawChart(this.generateOptions(chartData$1)),this.loading=!1;return}new Dashboard$1().dashboard(new Date(window.store.get("start")),new Date(window.store.get("end")),null).then(n=>{chartData$1=n.data,this.drawChart(this.generateOptions(chartData$1)),window.store.set(CACHE_KEY$4,chartData$1),this.loading=!1})},generateOptions(t){currencies$1=[];let e=getDefaultChartSettings("column");e.options.locale=window.store.get("locale").replace("_","-"),e.options.plugins={tooltip:{callbacks:{title:function(a){return a.label},label:function(a){let n=a.dataset.label||"";return n&&(n+=": "),n+" "+formatMoney(a.parsed.y,currencies$1[a.parsed.x]??"EUR")}}}},e.data={labels:[],datasets:[{label:i18n$3.t("firefly.spent"),data:[],borderWidth:1,stack:1},{label:i18n$3.t("firefly.left"),data:[],borderWidth:1,stack:1},{label:i18n$3.t("firefly.overspent"),data:[],borderWidth:1,stack:1}]};for(const a in t)if(t.hasOwnProperty(a)){let n=t[a],r=n.label+" ("+n.currency_code+")";e.data.labels.push(r),this.autoConversion&&(currencies$1.push(n.native_code),e.data.datasets[0].data.push(parseFloat(n.native_entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(n.native_entries.left)),e.data.datasets[2].data.push(parseFloat(n.native_entries.overspent))),this.autoConversion||(currencies$1.push(n.currency_code),e.data.datasets[0].data.push(parseFloat(n.entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(n.entries.left)),e.data.datasets[2].data.push(parseFloat(n.entries.overspent)))}return e.options.scales={y:{ticks:{callback:function(a){return formatMoney(a,currencies$1[0])}}}},e},init(){Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{i18n$3=new I18n,i18n$3.locale=t[1],loadTranslations(i18n$3,t[1]).then(()=>{this.autoConversion=t[0],afterPromises$4=!0,this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{afterPromises$4&&this.loading===!1&&(chartData$1=null,this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$4&&(this.autoConversion=t,this.loading===!1&&this.loadChart())})}});class Dashboard{dashboard(e,a){let n=format$1(e,"y-MM-dd"),r=format$1(a,"y-MM-dd");return api.get("/api/v2/chart/category/dashboard",{params:{start:n,end:r}})}}let currencies=[],chart$2=null,chartData=null,afterPromises$3=!1;const CACHE_KEY$3="dashboard-categories-chart",categories=()=>({loading:!1,autoConversion:!1,generateOptions(t){currencies=[];let e=getDefaultChartSettings("column"),a={};for(const r in t)if(t.hasOwnProperty(r)){let i=t[r],o=i.currency_code;this.autoConversion&&(o=i.native_code),a.hasOwnProperty(o)||(a[o]={name:o,yAxisID:"",data:{}},currencies.push(o))}for(const r in t)if(t.hasOwnProperty(r)){let i=t[r],o=i.currency_code;this.autoConversion&&(o=i.native_code);for(const s in a)if(a.hasOwnProperty(s)){let l=0;o===s&&(l=parseFloat(i.amount),""+i.currency_code,this.autoConversion&&(l=parseFloat(i.native_amount),""+i.native_code)),a[s].data.hasOwnProperty(i.label)&&(a[s].data[i.label]=a[s].data[i.label]+l),a[s].data.hasOwnProperty(i.label)||(a[s].data[i.label]=l)}e.data.labels.includes(i.label)||e.data.labels.push(i.label)}let n=0;for(const r in a){let i="y"+r,o={label:r,currency_code:r,yAxisID:i,data:[]};for(const s in a[r].data)o.data.push(a[r].data[s]);e.data.datasets.push(o),e.options.scales.hasOwnProperty(i)||(e.options.scales[i]={beginAtZero:!0,type:"linear",position:n===1?"right":"left",ticks:{callback:function(s,l,u){return formatMoney(s,r)}}},n++)}return e},drawChart(t){if(chart$2!==null){chart$2.options=t.options,chart$2.data=t.data,chart$2.update();return}chart$2=new Chart(document.querySelector("#category-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$3);if(t&&typeof e<"u"){chartData=e,this.drawChart(this.generateOptions(chartData)),this.loading=!1;return}new Dashboard().dashboard(new Date(window.store.get("start")),new Date(window.store.get("end")),null).then(n=>{chartData=n.data,this.drawChart(this.generateOptions(n.data)),window.store.set(CACHE_KEY$3,chartData),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,chartData!==null){this.drawChart(this.generateOptions(chartData)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([getVariable("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],afterPromises$3=!0,this.loadChart()}),window.store.observe("end",()=>{afterPromises$3&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$3&&(this.autoConversion=t,this.loadChart())})}});let Get$2=class{get(e){return api.get("/api/v2/transactions",{params:e})}};/*! +`):t}function createTooltipItem(t,e){const{element:a,datasetIndex:n,index:r}=e,i=t.getDatasetMeta(n).controller,{label:o,value:s}=i.getLabelAndValue(r);return{chart:t,label:o,parsed:i.getParsed(r),raw:t.data.datasets[n].data[r],formattedValue:s,dataset:i.getDataset(),dataIndex:r,datasetIndex:n,element:a}}function getTooltipSize(t,e){const a=t.chart.ctx,{body:n,footer:r,title:i}=t,{boxWidth:o,boxHeight:s}=e,l=toFont(e.bodyFont),u=toFont(e.titleFont),c=toFont(e.footerFont),d=i.length,h=r.length,m=n.length,p=toPadding(e.padding);let v=p.height,y=0,w=n.reduce((k,O)=>k+O.before.length+O.lines.length+O.after.length,0);if(w+=t.beforeBody.length+t.afterBody.length,d&&(v+=d*u.lineHeight+(d-1)*e.titleSpacing+e.titleMarginBottom),w){const k=e.displayColors?Math.max(s,l.lineHeight):l.lineHeight;v+=m*k+(w-m)*l.lineHeight+(w-1)*e.bodySpacing}h&&(v+=e.footerMarginTop+h*c.lineHeight+(h-1)*e.footerSpacing);let _=0;const D=function(k){y=Math.max(y,a.measureText(k).width+_)};return a.save(),a.font=u.string,each(t.title,D),a.font=l.string,each(t.beforeBody.concat(t.afterBody),D),_=e.displayColors?o+2+e.boxPadding:0,each(n,k=>{each(k.before,D),each(k.lines,D),each(k.after,D)}),_=0,a.font=c.string,each(t.footer,D),a.restore(),y+=p.width,{width:y,height:v}}function determineYAlign(t,e){const{y:a,height:n}=e;return at.height-n/2?"bottom":"center"}function doesNotFitWithAlign(t,e,a,n){const{x:r,width:i}=n,o=a.caretSize+a.caretPadding;if(t==="left"&&r+i+o>e.width||t==="right"&&r-i-o<0)return!0}function determineXAlign(t,e,a,n){const{x:r,width:i}=a,{width:o,chartArea:{left:s,right:l}}=t;let u="center";return n==="center"?u=r<=(s+l)/2?"left":"right":r<=i/2?u="left":r>=o-i/2&&(u="right"),doesNotFitWithAlign(u,t,e,a)&&(u="center"),u}function determineAlignment(t,e,a){const n=a.yAlign||e.yAlign||determineYAlign(t,a);return{xAlign:a.xAlign||e.xAlign||determineXAlign(t,e,a,n),yAlign:n}}function alignX(t,e){let{x:a,width:n}=t;return e==="right"?a-=n:e==="center"&&(a-=n/2),a}function alignY(t,e,a){let{y:n,height:r}=t;return e==="top"?n+=a:e==="bottom"?n-=r+a:n-=r/2,n}function getBackgroundPoint(t,e,a,n){const{caretSize:r,caretPadding:i,cornerRadius:o}=t,{xAlign:s,yAlign:l}=a,u=r+i,{topLeft:c,topRight:d,bottomLeft:h,bottomRight:m}=toTRBLCorners(o);let p=alignX(e,s);const v=alignY(e,l,u);return l==="center"?s==="left"?p+=u:s==="right"&&(p-=u):s==="left"?p-=Math.max(c,h)+r:s==="right"&&(p+=Math.max(d,m)+r),{x:_limitValue(p,0,n.width-e.width),y:_limitValue(v,0,n.height-e.height)}}function getAlignedX(t,e,a){const n=toPadding(a.padding);return e==="center"?t.x+t.width/2:e==="right"?t.x+t.width-n.right:t.x+n.left}function getBeforeAfterBodyLines(t){return pushOrConcat([],splitNewlines(t))}function createTooltipContext(t,e,a){return createContext(t,{tooltip:e,tooltipItems:a,type:"tooltip"})}function overrideCallbacks(t,e){const a=e&&e.dataset&&e.dataset.tooltip&&e.dataset.tooltip.callbacks;return a?t.override(a):t}const defaultCallbacks={beforeTitle:noop$2,title(t){if(t.length>0){const e=t[0],a=e.chart.data.labels,n=a?a.length:0;if(this&&this.options&&this.options.mode==="dataset")return e.dataset.label||"";if(e.label)return e.label;if(n>0&&e.dataIndex"u"?defaultCallbacks[e].call(a,n):r}class Tooltip extends Element$1{constructor(e){super(),this.opacity=0,this._active=[],this._eventPosition=void 0,this._size=void 0,this._cachedAnimations=void 0,this._tooltipItems=[],this.$animations=void 0,this.$context=void 0,this.chart=e.chart,this.options=e.options,this.dataPoints=void 0,this.title=void 0,this.beforeBody=void 0,this.body=void 0,this.afterBody=void 0,this.footer=void 0,this.xAlign=void 0,this.yAlign=void 0,this.x=void 0,this.y=void 0,this.height=void 0,this.width=void 0,this.caretX=void 0,this.caretY=void 0,this.labelColors=void 0,this.labelPointStyles=void 0,this.labelTextColors=void 0}initialize(e){this.options=e,this._cachedAnimations=void 0,this.$context=void 0}_resolveAnimations(){const e=this._cachedAnimations;if(e)return e;const a=this.chart,n=this.options.setContext(this.getContext()),r=n.enabled&&a.options.animation&&n.animations,i=new Animations(this.chart,r);return r._cacheable&&(this._cachedAnimations=Object.freeze(i)),i}getContext(){return this.$context||(this.$context=createTooltipContext(this.chart.getContext(),this,this._tooltipItems))}getTitle(e,a){const{callbacks:n}=a,r=invokeCallbackWithFallback(n,"beforeTitle",this,e),i=invokeCallbackWithFallback(n,"title",this,e),o=invokeCallbackWithFallback(n,"afterTitle",this,e);let s=[];return s=pushOrConcat(s,splitNewlines(r)),s=pushOrConcat(s,splitNewlines(i)),s=pushOrConcat(s,splitNewlines(o)),s}getBeforeBody(e,a){return getBeforeAfterBodyLines(invokeCallbackWithFallback(a.callbacks,"beforeBody",this,e))}getBody(e,a){const{callbacks:n}=a,r=[];return each(e,i=>{const o={before:[],lines:[],after:[]},s=overrideCallbacks(n,i);pushOrConcat(o.before,splitNewlines(invokeCallbackWithFallback(s,"beforeLabel",this,i))),pushOrConcat(o.lines,invokeCallbackWithFallback(s,"label",this,i)),pushOrConcat(o.after,splitNewlines(invokeCallbackWithFallback(s,"afterLabel",this,i))),r.push(o)}),r}getAfterBody(e,a){return getBeforeAfterBodyLines(invokeCallbackWithFallback(a.callbacks,"afterBody",this,e))}getFooter(e,a){const{callbacks:n}=a,r=invokeCallbackWithFallback(n,"beforeFooter",this,e),i=invokeCallbackWithFallback(n,"footer",this,e),o=invokeCallbackWithFallback(n,"afterFooter",this,e);let s=[];return s=pushOrConcat(s,splitNewlines(r)),s=pushOrConcat(s,splitNewlines(i)),s=pushOrConcat(s,splitNewlines(o)),s}_createItems(e){const a=this._active,n=this.chart.data,r=[],i=[],o=[];let s=[],l,u;for(l=0,u=a.length;le.filter(c,d,h,n))),e.itemSort&&(s=s.sort((c,d)=>e.itemSort(c,d,n))),each(s,c=>{const d=overrideCallbacks(e.callbacks,c);r.push(invokeCallbackWithFallback(d,"labelColor",this,c)),i.push(invokeCallbackWithFallback(d,"labelPointStyle",this,c)),o.push(invokeCallbackWithFallback(d,"labelTextColor",this,c))}),this.labelColors=r,this.labelPointStyles=i,this.labelTextColors=o,this.dataPoints=s,s}update(e,a){const n=this.options.setContext(this.getContext()),r=this._active;let i,o=[];if(!r.length)this.opacity!==0&&(i={opacity:0});else{const s=positioners[n.position].call(this,r,this._eventPosition);o=this._createItems(n),this.title=this.getTitle(o,n),this.beforeBody=this.getBeforeBody(o,n),this.body=this.getBody(o,n),this.afterBody=this.getAfterBody(o,n),this.footer=this.getFooter(o,n);const l=this._size=getTooltipSize(this,n),u=Object.assign({},s,l),c=determineAlignment(this.chart,n,u),d=getBackgroundPoint(n,u,c,this.chart);this.xAlign=c.xAlign,this.yAlign=c.yAlign,i={opacity:1,x:d.x,y:d.y,width:l.width,height:l.height,caretX:s.x,caretY:s.y}}this._tooltipItems=o,this.$context=void 0,i&&this._resolveAnimations().update(this,i),e&&n.external&&n.external.call(this,{chart:this.chart,tooltip:this,replay:a})}drawCaret(e,a,n,r){const i=this.getCaretPosition(e,n,r);a.lineTo(i.x1,i.y1),a.lineTo(i.x2,i.y2),a.lineTo(i.x3,i.y3)}getCaretPosition(e,a,n){const{xAlign:r,yAlign:i}=this,{caretSize:o,cornerRadius:s}=n,{topLeft:l,topRight:u,bottomLeft:c,bottomRight:d}=toTRBLCorners(s),{x:h,y:m}=e,{width:p,height:v}=a;let y,w,_,D,k,O;return i==="center"?(k=m+v/2,r==="left"?(y=h,w=y-o,D=k+o,O=k-o):(y=h+p,w=y+o,D=k-o,O=k+o),_=y):(r==="left"?w=h+Math.max(l,c)+o:r==="right"?w=h+p-Math.max(u,d)-o:w=this.caretX,i==="top"?(D=m,k=D-o,y=w-o,_=w+o):(D=m+v,k=D+o,y=w+o,_=w-o),O=D),{x1:y,x2:w,x3:_,y1:D,y2:k,y3:O}}drawTitle(e,a,n){const r=this.title,i=r.length;let o,s,l;if(i){const u=getRtlAdapter(n.rtl,this.x,this.width);for(e.x=getAlignedX(this,n.titleAlign,n),a.textAlign=u.textAlign(n.titleAlign),a.textBaseline="middle",o=toFont(n.titleFont),s=n.titleSpacing,a.fillStyle=n.titleColor,a.font=o.string,l=0;l_!==0)?(e.beginPath(),e.fillStyle=i.multiKeyBackground,addRoundedRectPath(e,{x:v,y:p,w:u,h:l,radius:w}),e.fill(),e.stroke(),e.fillStyle=o.backgroundColor,e.beginPath(),addRoundedRectPath(e,{x:y,y:p+1,w:u-2,h:l-2,radius:w}),e.fill()):(e.fillStyle=i.multiKeyBackground,e.fillRect(v,p,u,l),e.strokeRect(v,p,u,l),e.fillStyle=o.backgroundColor,e.fillRect(y,p+1,u-2,l-2))}e.fillStyle=this.labelTextColors[n]}drawBody(e,a,n){const{body:r}=this,{bodySpacing:i,bodyAlign:o,displayColors:s,boxHeight:l,boxWidth:u,boxPadding:c}=n,d=toFont(n.bodyFont);let h=d.lineHeight,m=0;const p=getRtlAdapter(n.rtl,this.x,this.width),v=function(g){a.fillText(g,p.x(e.x+m),e.y+h/2),e.y+=h+i},y=p.textAlign(o);let w,_,D,k,O,N,F;for(a.textAlign=o,a.textBaseline="middle",a.font=d.string,e.x=getAlignedX(this,y,n),a.fillStyle=n.bodyColor,each(this.beforeBody,v),m=s&&y!=="right"?o==="center"?u/2+c:u+2+c:0,k=0,N=r.length;k0&&a.stroke()}_updateAnimationTarget(e){const a=this.chart,n=this.$animations,r=n&&n.x,i=n&&n.y;if(r||i){const o=positioners[e.position].call(this,this._active,this._eventPosition);if(!o)return;const s=this._size=getTooltipSize(this,e),l=Object.assign({},o,this._size),u=determineAlignment(a,e,l),c=getBackgroundPoint(e,l,u,a);(r._to!==c.x||i._to!==c.y)&&(this.xAlign=u.xAlign,this.yAlign=u.yAlign,this.width=s.width,this.height=s.height,this.caretX=o.x,this.caretY=o.y,this._resolveAnimations().update(this,c))}}_willRender(){return!!this.opacity}draw(e){const a=this.options.setContext(this.getContext());let n=this.opacity;if(!n)return;this._updateAnimationTarget(a);const r={width:this.width,height:this.height},i={x:this.x,y:this.y};n=Math.abs(n)<.001?0:n;const o=toPadding(a.padding),s=this.title.length||this.beforeBody.length||this.body.length||this.afterBody.length||this.footer.length;a.enabled&&s&&(e.save(),e.globalAlpha=n,this.drawBackground(i,e,r,a),overrideTextDirection(e,a.textDirection),i.y+=o.top,this.drawTitle(i,e,a),this.drawBody(i,e,a),this.drawFooter(i,e,a),restoreTextDirection(e,a.textDirection),e.restore())}getActiveElements(){return this._active||[]}setActiveElements(e,a){const n=this._active,r=e.map(({datasetIndex:s,index:l})=>{const u=this.chart.getDatasetMeta(s);if(!u)throw new Error("Cannot find a dataset at index "+s);return{datasetIndex:s,element:u.data[l],index:l}}),i=!_elementsEqual(n,r),o=this._positionChanged(r,a);(i||o)&&(this._active=r,this._eventPosition=a,this._ignoreReplayEvents=!0,this.update(!0))}handleEvent(e,a,n=!0){if(a&&this._ignoreReplayEvents)return!1;this._ignoreReplayEvents=!1;const r=this.options,i=this._active||[],o=this._getActiveElements(e,i,a,n),s=this._positionChanged(o,e),l=a||!_elementsEqual(o,i)||s;return l&&(this._active=o,(r.enabled||r.external)&&(this._eventPosition={x:e.x,y:e.y},this.update(!0,a))),l}_getActiveElements(e,a,n,r){const i=this.options;if(e.type==="mouseout")return[];if(!r)return a;const o=this.chart.getElementsAtEventForMode(e,i.mode,i,n);return i.reverse&&o.reverse(),o}_positionChanged(e,a){const{caretX:n,caretY:r,options:i}=this,o=positioners[i.position].call(this,e,a);return o!==!1&&(n!==o.x||r!==o.y)}}R(Tooltip,"positioners",positioners);var plugin_tooltip={id:"tooltip",_element:Tooltip,positioners,afterInit(t,e,a){a&&(t.tooltip=new Tooltip({chart:t,options:a}))},beforeUpdate(t,e,a){t.tooltip&&t.tooltip.initialize(a)},reset(t,e,a){t.tooltip&&t.tooltip.initialize(a)},afterDraw(t){const e=t.tooltip;if(e&&e._willRender()){const a={tooltip:e};if(t.notifyPlugins("beforeTooltipDraw",{...a,cancelable:!0})===!1)return;e.draw(t.ctx),t.notifyPlugins("afterTooltipDraw",a)}},afterEvent(t,e){if(t.tooltip){const a=e.replay;t.tooltip.handleEvent(e.event,a,e.inChartArea)&&(e.changed=!0)}},defaults:{enabled:!0,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:(t,e)=>e.bodyFont.size,boxWidth:(t,e)=>e.bodyFont.size,multiKeyBackground:"#fff",displayColors:!0,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:t=>t!=="filter"&&t!=="itemSort"&&t!=="external",_indexable:!1,callbacks:{_scriptable:!1,_indexable:!1},animation:{_fallback:!1},animations:{_fallback:"animation"}},additionalOptionScopes:["interaction"]};const addIfString=(t,e,a,n)=>(typeof e=="string"?(a=t.push(e)-1,n.unshift({index:a,label:e})):isNaN(e)&&(a=null),a);function findOrAddLabel(t,e,a,n){const r=t.indexOf(e);if(r===-1)return addIfString(t,e,a,n);const i=t.lastIndexOf(e);return r!==i?a:r}const validIndex=(t,e)=>t===null?null:_limitValue(Math.round(t),0,e);function _getLabelForValue(t){const e=this.getLabels();return t>=0&&ta.length-1?null:this.getPixelForValue(a[e].value)}getValueForPixel(e){return Math.round(this._startValue+this.getDecimalForPixel(e)*this._valueRange)}getBasePixel(){return this.bottom}}R(CategoryScale,"id","category"),R(CategoryScale,"defaults",{ticks:{callback:_getLabelForValue}});function generateTicks$1(t,e){const a=[],{bounds:r,step:i,min:o,max:s,precision:l,count:u,maxTicks:c,maxDigits:d,includeBounds:h}=t,m=i||1,p=c-1,{min:v,max:y}=e,w=!isNullOrUndef(o),_=!isNullOrUndef(s),D=!isNullOrUndef(u),k=(y-v)/(d+1);let O=niceNum((y-v)/p/m)*m,N,F,g,b;if(O<1e-14&&!w&&!_)return[{value:v},{value:y}];b=Math.ceil(y/O)-Math.floor(v/O),b>p&&(O=niceNum(b*O/p/m)*m),isNullOrUndef(l)||(N=Math.pow(10,l),O=Math.ceil(O*N)/N),r==="ticks"?(F=Math.floor(v/O)*O,g=Math.ceil(y/O)*O):(F=v,g=y),w&&_&&i&&almostWhole((s-o)/i,O/1e3)?(b=Math.round(Math.min((s-o)/O,c)),O=(s-o)/b,F=o,g=s):D?(F=w?o:F,g=_?s:g,b=u-1,O=(g-F)/b):(b=(g-F)/O,almostEquals(b,Math.round(b),O/1e3)?b=Math.round(b):b=Math.ceil(b));const $=Math.max(_decimalPlaces(O),_decimalPlaces(F));N=Math.pow(10,isNullOrUndef(l)?$:l),F=Math.round(F*N)/N,g=Math.round(g*N)/N;let S=0;for(w&&(h&&F!==o?(a.push({value:o}),Fs)break;a.push({value:P})}return _&&h&&g!==s?a.length&&almostEquals(a[a.length-1].value,s,relativeLabelSize(s,k,t))?a[a.length-1].value=s:a.push({value:s}):(!_||g===s)&&a.push({value:g}),a}function relativeLabelSize(t,e,{horizontal:a,minRotation:n}){const r=toRadians(n),i=(a?Math.sin(r):Math.cos(r))||.001,o=.75*e*(""+t).length;return Math.min(e/i,o)}class LinearScaleBase extends Scale{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._endValue=void 0,this._valueRange=0}parse(e,a){return isNullOrUndef(e)||(typeof e=="number"||e instanceof Number)&&!isFinite(+e)?null:+e}handleTickRangeOptions(){const{beginAtZero:e}=this.options,{minDefined:a,maxDefined:n}=this.getUserBounds();let{min:r,max:i}=this;const o=l=>r=a?r:l,s=l=>i=n?i:l;if(e){const l=sign(r),u=sign(i);l<0&&u<0?s(0):l>0&&u>0&&o(0)}if(r===i){let l=i===0?1:Math.abs(i*.05);s(i+l),e||o(r-l)}this.min=r,this.max=i}getTickLimit(){const e=this.options.ticks;let{maxTicksLimit:a,stepSize:n}=e,r;return n?(r=Math.ceil(this.max/n)-Math.floor(this.min/n)+1,r>1e3&&(console.warn(`scales.${this.id}.ticks.stepSize: ${n} would result generating up to ${r} ticks. Limiting to 1000.`),r=1e3)):(r=this.computeTickLimit(),a=a||11),a&&(r=Math.min(a,r)),r}computeTickLimit(){return Number.POSITIVE_INFINITY}buildTicks(){const e=this.options,a=e.ticks;let n=this.getTickLimit();n=Math.max(2,n);const r={maxTicks:n,bounds:e.bounds,min:e.min,max:e.max,precision:a.precision,step:a.stepSize,count:a.count,maxDigits:this._maxDigits(),horizontal:this.isHorizontal(),minRotation:a.minRotation||0,includeBounds:a.includeBounds!==!1},i=this._range||this,o=generateTicks$1(r,i);return e.bounds==="ticks"&&_setMinAndMaxByKey(o,this,"value"),e.reverse?(o.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),o}configure(){const e=this.ticks;let a=this.min,n=this.max;if(super.configure(),this.options.offset&&e.length){const r=(n-a)/Math.max(e.length-1,1)/2;a-=r,n+=r}this._startValue=a,this._endValue=n,this._valueRange=n-a}getLabelForValue(e){return formatNumber$1(e,this.chart.options.locale,this.options.ticks.format)}}class LinearScale extends LinearScaleBase{determineDataLimits(){const{min:e,max:a}=this.getMinMax(!0);this.min=isNumberFinite(e)?e:0,this.max=isNumberFinite(a)?a:1,this.handleTickRangeOptions()}computeTickLimit(){const e=this.isHorizontal(),a=e?this.width:this.height,n=toRadians(this.options.ticks.minRotation),r=(e?Math.sin(n):Math.cos(n))||.001,i=this._resolveTickFontOptions(0);return Math.ceil(a/Math.min(40,i.lineHeight/r))}getPixelForValue(e){return e===null?NaN:this.getPixelForDecimal((e-this._startValue)/this._valueRange)}getValueForPixel(e){return this._startValue+this.getDecimalForPixel(e)*this._valueRange}}R(LinearScale,"id","linear"),R(LinearScale,"defaults",{ticks:{callback:Ticks.formatters.numeric}});const log10Floor=t=>Math.floor(log10(t)),changeExponent=(t,e)=>Math.pow(10,log10Floor(t)+e);function isMajor(t){return t/Math.pow(10,log10Floor(t))===1}function steps(t,e,a){const n=Math.pow(10,a),r=Math.floor(t/n);return Math.ceil(e/n)-r}function startExp(t,e){const a=e-t;let n=log10Floor(a);for(;steps(t,e,n)>10;)n++;for(;steps(t,e,n)<10;)n--;return Math.min(n,log10Floor(t))}function generateTicks(t,{min:e,max:a}){e=finiteOrDefault(t.min,e);const n=[],r=log10Floor(e);let i=startExp(e,a),o=i<0?Math.pow(10,Math.abs(i)):1;const s=Math.pow(10,i),l=r>i?Math.pow(10,r):0,u=Math.round((e-l)*o)/o,c=Math.floor((e-l)/s/10)*s*10;let d=Math.floor((u-c)/Math.pow(10,i)),h=finiteOrDefault(t.min,Math.round((l+c+d*Math.pow(10,i))*o)/o);for(;h=10?d=d<15?15:20:d++,d>=20&&(i++,d=2,o=i>=0?1:o),h=Math.round((l+c+d*Math.pow(10,i))*o)/o;const m=finiteOrDefault(t.max,h);return n.push({value:m,major:isMajor(m),significand:d}),n}class LogarithmicScale extends Scale{constructor(e){super(e),this.start=void 0,this.end=void 0,this._startValue=void 0,this._valueRange=0}parse(e,a){const n=LinearScaleBase.prototype.parse.apply(this,[e,a]);if(n===0){this._zero=!0;return}return isNumberFinite(n)&&n>0?n:null}determineDataLimits(){const{min:e,max:a}=this.getMinMax(!0);this.min=isNumberFinite(e)?Math.max(0,e):null,this.max=isNumberFinite(a)?Math.max(0,a):null,this.options.beginAtZero&&(this._zero=!0),this._zero&&this.min!==this._suggestedMin&&!isNumberFinite(this._userMin)&&(this.min=e===changeExponent(this.min,0)?changeExponent(this.min,-1):changeExponent(this.min,0)),this.handleTickRangeOptions()}handleTickRangeOptions(){const{minDefined:e,maxDefined:a}=this.getUserBounds();let n=this.min,r=this.max;const i=s=>n=e?n:s,o=s=>r=a?r:s;n===r&&(n<=0?(i(1),o(10)):(i(changeExponent(n,-1)),o(changeExponent(r,1)))),n<=0&&i(changeExponent(r,-1)),r<=0&&o(changeExponent(n,1)),this.min=n,this.max=r}buildTicks(){const e=this.options,a={min:this._userMin,max:this._userMax},n=generateTicks(a,this);return e.bounds==="ticks"&&_setMinAndMaxByKey(n,this,"value"),e.reverse?(n.reverse(),this.start=this.max,this.end=this.min):(this.start=this.min,this.end=this.max),n}getLabelForValue(e){return e===void 0?"0":formatNumber$1(e,this.chart.options.locale,this.options.ticks.format)}configure(){const e=this.min;super.configure(),this._startValue=log10(e),this._valueRange=log10(this.max)-log10(e)}getPixelForValue(e){return(e===void 0||e===0)&&(e=this.min),e===null||isNaN(e)?NaN:this.getPixelForDecimal(e===this.min?0:(log10(e)-this._startValue)/this._valueRange)}getValueForPixel(e){const a=this.getDecimalForPixel(e);return Math.pow(10,this._startValue+a*this._valueRange)}}R(LogarithmicScale,"id","logarithmic"),R(LogarithmicScale,"defaults",{ticks:{callback:Ticks.formatters.logarithmic,major:{enabled:!0}}});function getTickBackdropHeight(t){const e=t.ticks;if(e.display&&t.display){const a=toPadding(e.backdropPadding);return valueOrDefault(e.font&&e.font.size,defaults.font.size)+a.height}return 0}function measureLabelSize(t,e,a){return a=isArray$c(a)?a:[a],{w:_longestText(t,e.string,a),h:a.length*e.lineHeight}}function determineLimits(t,e,a,n,r){return t===n||t===r?{start:e-a/2,end:e+a/2}:tr?{start:e-a,end:e}:{start:e,end:e+a}}function fitWithPointLabels(t){const e={l:t.left+t._padding.left,r:t.right-t._padding.right,t:t.top+t._padding.top,b:t.bottom-t._padding.bottom},a=Object.assign({},e),n=[],r=[],i=t._pointLabels.length,o=t.options.pointLabels,s=o.centerPointLabels?PI/i:0;for(let l=0;le.r&&(s=(n.end-e.r)/i,t.r=Math.max(t.r,e.r+s)),r.starte.b&&(l=(r.end-e.b)/o,t.b=Math.max(t.b,e.b+l))}function createPointLabelItem(t,e,a){const n=t.drawingArea,{extra:r,additionalAngle:i,padding:o,size:s}=a,l=t.getPointPosition(e,n+r+o,i),u=Math.round(toDegrees(_normalizeAngle(l.angle+HALF_PI))),c=yForAngle(l.y,s.h,u),d=getTextAlignForAngle(u),h=leftForTextAlign(l.x,s.w,d);return{visible:!0,x:l.x,y:c,textAlign:d,left:h,top:c,right:h+s.w,bottom:c+s.h}}function isNotOverlapped(t,e){if(!e)return!0;const{left:a,top:n,right:r,bottom:i}=t;return!(_isPointInArea({x:a,y:n},e)||_isPointInArea({x:a,y:i},e)||_isPointInArea({x:r,y:n},e)||_isPointInArea({x:r,y:i},e))}function buildPointLabelItems(t,e,a){const n=[],r=t._pointLabels.length,i=t.options,{centerPointLabels:o,display:s}=i.pointLabels,l={extra:getTickBackdropHeight(i)/2,additionalAngle:o?PI/r:0};let u;for(let c=0;c270||a<90)&&(t-=e),t}function drawPointLabelBox(t,e,a){const{left:n,top:r,right:i,bottom:o}=a,{backdropColor:s}=e;if(!isNullOrUndef(s)){const l=toTRBLCorners(e.borderRadius),u=toPadding(e.backdropPadding);t.fillStyle=s;const c=n-u.left,d=r-u.top,h=i-n+u.width,m=o-r+u.height;Object.values(l).some(p=>p!==0)?(t.beginPath(),addRoundedRectPath(t,{x:c,y:d,w:h,h:m,radius:l}),t.fill()):t.fillRect(c,d,h,m)}}function drawPointLabels(t,e){const{ctx:a,options:{pointLabels:n}}=t;for(let r=e-1;r>=0;r--){const i=t._pointLabelItems[r];if(!i.visible)continue;const o=n.setContext(t.getPointLabelContext(r));drawPointLabelBox(a,o,i);const s=toFont(o.font),{x:l,y:u,textAlign:c}=i;renderText(a,t._pointLabels[r],l,u+s.lineHeight/2,s,{color:o.color,textAlign:c,textBaseline:"middle"})}}function pathRadiusLine(t,e,a,n){const{ctx:r}=t;if(a)r.arc(t.xCenter,t.yCenter,e,0,TAU);else{let i=t.getPointPosition(0,e);r.moveTo(i.x,i.y);for(let o=1;o{const r=callback(this.options.pointLabels.callback,[a,n],this);return r||r===0?r:""}).filter((a,n)=>this.chart.getDataVisibility(n))}fit(){const e=this.options;e.display&&e.pointLabels.display?fitWithPointLabels(this):this.setCenterPoint(0,0,0,0)}setCenterPoint(e,a,n,r){this.xCenter+=Math.floor((e-a)/2),this.yCenter+=Math.floor((n-r)/2),this.drawingArea-=Math.min(this.drawingArea/2,Math.max(e,a,n,r))}getIndexAngle(e){const a=TAU/(this._pointLabels.length||1),n=this.options.startAngle||0;return _normalizeAngle(e*a+toRadians(n))}getDistanceFromCenterForValue(e){if(isNullOrUndef(e))return NaN;const a=this.drawingArea/(this.max-this.min);return this.options.reverse?(this.max-e)*a:(e-this.min)*a}getValueForDistanceFromCenter(e){if(isNullOrUndef(e))return NaN;const a=e/(this.drawingArea/(this.max-this.min));return this.options.reverse?this.max-a:this.min+a}getPointLabelContext(e){const a=this._pointLabels||[];if(e>=0&&e{if(d!==0){l=this.getDistanceFromCenterForValue(c.value);const h=this.getContext(d),m=r.setContext(h),p=i.setContext(h);drawRadiusLine(this,m,l,o,p)}}),n.display){for(e.save(),s=o-1;s>=0;s--){const c=n.setContext(this.getPointLabelContext(s)),{color:d,lineWidth:h}=c;!h||!d||(e.lineWidth=h,e.strokeStyle=d,e.setLineDash(c.borderDash),e.lineDashOffset=c.borderDashOffset,l=this.getDistanceFromCenterForValue(a.ticks.reverse?this.min:this.max),u=this.getPointPosition(s,l),e.beginPath(),e.moveTo(this.xCenter,this.yCenter),e.lineTo(u.x,u.y),e.stroke())}e.restore()}}drawBorder(){}drawLabels(){const e=this.ctx,a=this.options,n=a.ticks;if(!n.display)return;const r=this.getIndexAngle(0);let i,o;e.save(),e.translate(this.xCenter,this.yCenter),e.rotate(r),e.textAlign="center",e.textBaseline="middle",this.ticks.forEach((s,l)=>{if(l===0&&!a.reverse)return;const u=n.setContext(this.getContext(l)),c=toFont(u.font);if(i=this.getDistanceFromCenterForValue(this.ticks[l].value),u.showLabelBackdrop){e.font=c.string,o=e.measureText(s.label).width,e.fillStyle=u.backdropColor;const d=toPadding(u.backdropPadding);e.fillRect(-o/2-d.left,-i-c.size/2-d.top,o+d.width,c.size+d.height)}renderText(e,s.label,0,-i,c,{color:u.color,strokeColor:u.textStrokeColor,strokeWidth:u.textStrokeWidth})}),e.restore()}drawTitle(){}}R(RadialLinearScale,"id","radialLinear"),R(RadialLinearScale,"defaults",{display:!0,animate:!0,position:"chartArea",angleLines:{display:!0,lineWidth:1,borderDash:[],borderDashOffset:0},grid:{circular:!1},startAngle:0,ticks:{showLabelBackdrop:!0,callback:Ticks.formatters.numeric},pointLabels:{backdropColor:void 0,backdropPadding:2,display:!0,font:{size:10},callback(e){return e},padding:5,centerPointLabels:!1}}),R(RadialLinearScale,"defaultRoutes",{"angleLines.color":"borderColor","pointLabels.color":"color","ticks.color":"color"}),R(RadialLinearScale,"descriptors",{angleLines:{_fallback:"grid"}});const INTERVALS={millisecond:{common:!0,size:1,steps:1e3},second:{common:!0,size:1e3,steps:60},minute:{common:!0,size:6e4,steps:60},hour:{common:!0,size:36e5,steps:24},day:{common:!0,size:864e5,steps:30},week:{common:!1,size:6048e5,steps:4},month:{common:!0,size:2628e6,steps:12},quarter:{common:!1,size:7884e6,steps:4},year:{common:!0,size:3154e7}},UNITS=Object.keys(INTERVALS);function sorter(t,e){return t-e}function parse(t,e){if(isNullOrUndef(e))return null;const a=t._adapter,{parser:n,round:r,isoWeekday:i}=t._parseOpts;let o=e;return typeof n=="function"&&(o=n(o)),isNumberFinite(o)||(o=typeof n=="string"?a.parse(o,n):a.parse(o)),o===null?null:(r&&(o=r==="week"&&(isNumber(i)||i===!0)?a.startOf(o,"isoWeek",i):a.startOf(o,r)),+o)}function determineUnitForAutoTicks(t,e,a,n){const r=UNITS.length;for(let i=UNITS.indexOf(t);i=UNITS.indexOf(a);i--){const o=UNITS[i];if(INTERVALS[o].common&&t._adapter.diff(r,n,o)>=e-1)return o}return UNITS[a?UNITS.indexOf(a):0]}function determineMajorUnit(t){for(let e=UNITS.indexOf(t)+1,a=UNITS.length;e=e?a[n]:a[r];t[i]=!0}}function setMajorTicks(t,e,a,n){const r=t._adapter,i=+r.startOf(e[0].value,n),o=e[e.length-1].value;let s,l;for(s=i;s<=o;s=+r.add(s,1,n))l=a[s],l>=0&&(e[l].major=!0);return e}function ticksFromTimestamps(t,e,a){const n=[],r={},i=e.length;let o,s;for(o=0;o+e.value))}initOffsets(e=[]){let a=0,n=0,r,i;this.options.offset&&e.length&&(r=this.getDecimalForValue(e[0]),e.length===1?a=1-r:a=(this.getDecimalForValue(e[1])-r)/2,i=this.getDecimalForValue(e[e.length-1]),e.length===1?n=i:n=(i-this.getDecimalForValue(e[e.length-2]))/2);const o=e.length<3?.5:.25;a=_limitValue(a,0,o),n=_limitValue(n,0,o),this._offsets={start:a,end:n,factor:1/(a+1+n)}}_generate(){const e=this._adapter,a=this.min,n=this.max,r=this.options,i=r.time,o=i.unit||determineUnitForAutoTicks(i.minUnit,a,n,this._getLabelCapacity(a)),s=valueOrDefault(r.ticks.stepSize,1),l=o==="week"?i.isoWeekday:!1,u=isNumber(l)||l===!0,c={};let d=a,h,m;if(u&&(d=+e.startOf(d,"isoWeek",l)),d=+e.startOf(d,u?"day":o),e.diff(n,a,o)>1e5*s)throw new Error(a+" and "+n+" are too far apart with stepSize of "+s+" "+o);const p=r.ticks.source==="data"&&this.getDataTimestamps();for(h=d,m=0;h+v)}getLabelForValue(e){const a=this._adapter,n=this.options.time;return n.tooltipFormat?a.format(e,n.tooltipFormat):a.format(e,n.displayFormats.datetime)}format(e,a){const r=this.options.time.displayFormats,i=this._unit,o=a||r[i];return this._adapter.format(e,o)}_tickFormatFunction(e,a,n,r){const i=this.options,o=i.ticks.callback;if(o)return callback(o,[e,a,n],this);const s=i.time.displayFormats,l=this._unit,u=this._majorUnit,c=l&&s[l],d=u&&s[u],h=n[a],m=u&&d&&h&&h.major;return this._adapter.format(e,r||(m?d:c))}generateTickLabels(e){let a,n,r;for(a=0,n=e.length;a0?s:1}getDataTimestamps(){let e=this._cache.data||[],a,n;if(e.length)return e;const r=this.getMatchingVisibleMetas();if(this._normalized&&r.length)return this._cache.data=r[0].controller.getAllParsedValues(this);for(a=0,n=r.length;a=t[n].pos&&e<=t[r].pos&&({lo:n,hi:r}=_lookupByKey(t,"pos",e)),{pos:i,time:s}=t[n],{pos:o,time:l}=t[r]):(e>=t[n].time&&e<=t[r].time&&({lo:n,hi:r}=_lookupByKey(t,"time",e)),{time:i,pos:s}=t[n],{time:o,pos:l}=t[r]);const u=o-i;return u?s+(l-s)*(e-i)/u:s}class TimeSeriesScale extends TimeScale{constructor(e){super(e),this._table=[],this._minPos=void 0,this._tableRange=void 0}initOffsets(){const e=this._getTimestampsForTable(),a=this._table=this.buildLookupTable(e);this._minPos=interpolate$1(a,this.min),this._tableRange=interpolate$1(a,this.max)-this._minPos,super.initOffsets(e)}buildLookupTable(e){const{min:a,max:n}=this,r=[],i=[];let o,s,l,u,c;for(o=0,s=e.length;o=a&&u<=n&&r.push(u);if(r.length<2)return[{time:a,pos:0},{time:n,pos:1}];for(o=0,s=r.length;or-i)}_getTimestampsForTable(){let e=this._cache.all||[];if(e.length)return e;const a=this.getDataTimestamps(),n=this.getLabelTimestamps();return a.length&&n.length?e=this.normalize(a.concat(n)):e=a.length?a:n,e=this._cache.all=e,e}getDecimalForValue(e){return(interpolate$1(this._table,e)-this._minPos)/this._tableRange}getValueForPixel(e){const a=this._offsets,n=this.getDecimalForPixel(e)/a.factor-a.end;return interpolate$1(this._table,n*this._tableRange+this._minPos,!0)}}R(TimeSeriesScale,"id","timeseries"),R(TimeSeriesScale,"defaults",TimeScale.defaults);function getDefaultChartSettings(t){return t==="sankey"?{type:"sankey",data:{datasets:[]}}:t==="pie"?{type:"pie",data:{datasets:[]}}:t==="column"?{type:"bar",data:{labels:[],datasets:[]},options:{plugins:{tooltip:{callbacks:{label:function(e){let a=e.dataset.currency_code;return formatMoney(e.raw,a)}}}},maintainAspectRatio:!1,scales:{}}}:t==="line"?{options:{plugins:{tooltip:{callbacks:{label:function(e){let a=e.dataset.currency_code;return formatMoney(e.raw,a)}}}},maintainAspectRatio:!1,scales:{x:{type:"time",time:{tooltipFormat:"PP"}}}},type:"line",data:{labels:[],datasets:[]}}:{}}let blue=new Color("#36a2eb"),red=new Color("#ff6384"),green=new Color("#4bc0c0"),orange=new Color("#ff9f40"),purple=new Color("#9966ff"),yellow=new Color("#ffcd56"),grey=new Color("#c9cbcf"),index=0;window.theme==="dark"&&(red.darken(.3).desaturate(.3),green.darken(.3).desaturate(.3),blue.darken(.3).desaturate(.3),orange.darken(.3).desaturate(.3));let allColors=[red,orange,blue,green,purple,yellow,grey,green];function getColors(t,e){let a={borderColor:red.rgbString(),backgroundColor:red.rgbString()},n;switch(t){default:let i=Math.floor(index/2)%allColors.length;n=new Color(allColors[i].rgbString()),n.lighten(.38),a={borderColor:allColors[i].hexString(),backgroundColor:n.hexString()};break;case"spent":n=new Color(blue.rgbString()),n.lighten(.38),a={borderColor:blue.rgbString(),backgroundColor:n.rgbString()};break;case"left":n=new Color(green.rgbString()),n.lighten(.38),a={borderColor:green.rgbString(),backgroundColor:n.rgbString()};break;case"overspent":n=new Color(red.rgbString()),n.lighten(.22),console.log("#ffb1c1 vs "+n.hexString()),a={borderColor:red.rgbString(),backgroundColor:n.rgbString()};break}return index++,e==="border"?a.borderColor:e==="background"?a.backgroundColor:"#FF0000"}let currencies$2=[],chart$4=null,chartData$2=null,afterPromises$5=!1;const CHART_CACHE_KEY="dashboard-accounts-chart",ACCOUNTS_CACHE_KEY="dashboard-accounts-data",accounts=()=>({loading:!1,loadingAccounts:!1,accountList:[],autoConversion:!1,chartOptions:null,switchAutoConversion(){this.autoConversion=!this.autoConversion,setVariable("autoConversion",this.autoConversion)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CHART_CACHE_KEY);if(t&&typeof e<"u"){this.drawChart(this.generateOptions(e)),this.loading=!1;return}new Dashboard$2().dashboard(new Date(window.store.get("start")),new Date(window.store.get("end")),null).then(n=>{this.chartData=n.data,window.store.set(CHART_CACHE_KEY,n.data),this.drawChart(this.generateOptions(this.chartData)),this.loading=!1})},generateOptions(t){currencies$2=[];let e=getDefaultChartSettings("line");for(let a=0;a0){this.loadingAccounts=!1;return}const t=window.store.get("cacheValid");let e=window.store.get(ACCOUNTS_CACHE_KEY);if(t&&typeof e<"u"){this.accountList=e,this.loadingAccounts=!1;return}const a=10;let n=0,r=0,i=[];Promise.all([getVariable("frontpageAccounts")]).then(o=>{n=o[0].length;for(let s in o[0]){let l=o[0];if(l.hasOwnProperty(s)){let u=l[s];new Get$3().get(u,new Date(window.store.get("end"))).then(c=>{let d=c.data.data;new Get$3().transactions(d.id,1).then(h=>{let m=[];for(let p=0;p=a);p++){let v=h.data.data[p],y={title:v.attributes.group_title===null?"":v.attributes.group_title,id:v.id,transactions:[]};for(let w=0;wp.order-v.order),this.accountList=i,this.loadingAccounts=!1,window.store.set(ACCOUNTS_CACHE_KEY,i))})})}}})},init(){Promise.all([getVariable("viewRange","1M"),getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{this.autoConversion=t[1],afterPromises$5=!0,this.loadChart(),this.loadAccounts()}),window.store.observe("end",()=>{afterPromises$5&&(chartData$2=null,this.accountList=[],this.loadChart(),this.loadAccounts())}),window.store.observe("autoConversion",()=>{afterPromises$5&&(this.loadChart(),this.loadAccounts())})}});let Dashboard$1=class{dashboard(e,a){let n=format$1(e,"y-MM-dd"),r=format$1(a,"y-MM-dd");return api.get("/api/v2/chart/budget/dashboard",{params:{start:n,end:r}})}};var isArray$a=Array.isArray,isArray_1=isArray$a;const isArray$b=getDefaultExportFromCjs(isArray_1);var freeGlobal$1=typeof commonjsGlobal=="object"&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,_freeGlobal=freeGlobal$1,freeGlobal=_freeGlobal,freeSelf=typeof self=="object"&&self&&self.Object===Object&&self,root$8=freeGlobal||freeSelf||Function("return this")(),_root=root$8,root$7=_root,Symbol$6=root$7.Symbol,_Symbol=Symbol$6,Symbol$5=_Symbol,objectProto$d=Object.prototype,hasOwnProperty$a=objectProto$d.hasOwnProperty,nativeObjectToString$1=objectProto$d.toString,symToStringTag$1=Symbol$5?Symbol$5.toStringTag:void 0;function getRawTag$1(t){var e=hasOwnProperty$a.call(t,symToStringTag$1),a=t[symToStringTag$1];try{t[symToStringTag$1]=void 0;var n=!0}catch{}var r=nativeObjectToString$1.call(t);return n&&(e?t[symToStringTag$1]=a:delete t[symToStringTag$1]),r}var _getRawTag=getRawTag$1,objectProto$c=Object.prototype,nativeObjectToString=objectProto$c.toString;function objectToString$1(t){return nativeObjectToString.call(t)}var _objectToString=objectToString$1,Symbol$4=_Symbol,getRawTag=_getRawTag,objectToString=_objectToString,nullTag="[object Null]",undefinedTag="[object Undefined]",symToStringTag=Symbol$4?Symbol$4.toStringTag:void 0;function baseGetTag$5(t){return t==null?t===void 0?undefinedTag:nullTag:symToStringTag&&symToStringTag in Object(t)?getRawTag(t):objectToString(t)}var _baseGetTag=baseGetTag$5;function isObjectLike$5(t){return t!=null&&typeof t=="object"}var isObjectLike_1=isObjectLike$5,baseGetTag$4=_baseGetTag,isObjectLike$4=isObjectLike_1,symbolTag$1="[object Symbol]";function isSymbol$5(t){return typeof t=="symbol"||isObjectLike$4(t)&&baseGetTag$4(t)==symbolTag$1}var isSymbol_1=isSymbol$5,isArray$9=isArray_1,isSymbol$4=isSymbol_1,reIsDeepProp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,reIsPlainProp=/^\w*$/;function isKey$3(t,e){if(isArray$9(t))return!1;var a=typeof t;return a=="number"||a=="symbol"||a=="boolean"||t==null||isSymbol$4(t)?!0:reIsPlainProp.test(t)||!reIsDeepProp.test(t)||e!=null&&t in Object(e)}var _isKey=isKey$3;function isObject$6(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var isObject_1=isObject$6;const isObject$7=getDefaultExportFromCjs(isObject_1);var baseGetTag$3=_baseGetTag,isObject$5=isObject_1,asyncTag="[object AsyncFunction]",funcTag$1="[object Function]",genTag="[object GeneratorFunction]",proxyTag="[object Proxy]";function isFunction$2(t){if(!isObject$5(t))return!1;var e=baseGetTag$3(t);return e==funcTag$1||e==genTag||e==asyncTag||e==proxyTag}var isFunction_1=isFunction$2,root$6=_root,coreJsData$1=root$6["__core-js_shared__"],_coreJsData=coreJsData$1,coreJsData=_coreJsData,maskSrcKey=function(){var t=/[^.]+$/.exec(coreJsData&&coreJsData.keys&&coreJsData.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function isMasked$1(t){return!!maskSrcKey&&maskSrcKey in t}var _isMasked=isMasked$1,funcProto$1=Function.prototype,funcToString$1=funcProto$1.toString;function toSource$2(t){if(t!=null){try{return funcToString$1.call(t)}catch{}try{return t+""}catch{}}return""}var _toSource=toSource$2,isFunction$1=isFunction_1,isMasked=_isMasked,isObject$4=isObject_1,toSource$1=_toSource,reRegExpChar=/[\\^$.*+?()[\]{}|]/g,reIsHostCtor=/^\[object .+?Constructor\]$/,funcProto=Function.prototype,objectProto$b=Object.prototype,funcToString=funcProto.toString,hasOwnProperty$9=objectProto$b.hasOwnProperty,reIsNative=RegExp("^"+funcToString.call(hasOwnProperty$9).replace(reRegExpChar,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function baseIsNative$1(t){if(!isObject$4(t)||isMasked(t))return!1;var e=isFunction$1(t)?reIsNative:reIsHostCtor;return e.test(toSource$1(t))}var _baseIsNative=baseIsNative$1;function getValue$1(t,e){return t==null?void 0:t[e]}var _getValue=getValue$1,baseIsNative=_baseIsNative,getValue=_getValue;function getNative$7(t,e){var a=getValue(t,e);return baseIsNative(a)?a:void 0}var _getNative=getNative$7,getNative$6=_getNative,nativeCreate$4=getNative$6(Object,"create"),_nativeCreate=nativeCreate$4,nativeCreate$3=_nativeCreate;function hashClear$1(){this.__data__=nativeCreate$3?nativeCreate$3(null):{},this.size=0}var _hashClear=hashClear$1;function hashDelete$1(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var _hashDelete=hashDelete$1,nativeCreate$2=_nativeCreate,HASH_UNDEFINED$2="__lodash_hash_undefined__",objectProto$a=Object.prototype,hasOwnProperty$8=objectProto$a.hasOwnProperty;function hashGet$1(t){var e=this.__data__;if(nativeCreate$2){var a=e[t];return a===HASH_UNDEFINED$2?void 0:a}return hasOwnProperty$8.call(e,t)?e[t]:void 0}var _hashGet=hashGet$1,nativeCreate$1=_nativeCreate,objectProto$9=Object.prototype,hasOwnProperty$7=objectProto$9.hasOwnProperty;function hashHas$1(t){var e=this.__data__;return nativeCreate$1?e[t]!==void 0:hasOwnProperty$7.call(e,t)}var _hashHas=hashHas$1,nativeCreate=_nativeCreate,HASH_UNDEFINED$1="__lodash_hash_undefined__";function hashSet$1(t,e){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=nativeCreate&&e===void 0?HASH_UNDEFINED$1:e,this}var _hashSet=hashSet$1,hashClear=_hashClear,hashDelete=_hashDelete,hashGet=_hashGet,hashHas=_hashHas,hashSet=_hashSet;function Hash$1(t){var e=-1,a=t==null?0:t.length;for(this.clear();++e-1}var _listCacheHas=listCacheHas$1,assocIndexOf=_assocIndexOf;function listCacheSet$1(t,e){var a=this.__data__,n=assocIndexOf(a,t);return n<0?(++this.size,a.push([t,e])):a[n][1]=e,this}var _listCacheSet=listCacheSet$1,listCacheClear=_listCacheClear,listCacheDelete=_listCacheDelete,listCacheGet=_listCacheGet,listCacheHas=_listCacheHas,listCacheSet=_listCacheSet;function ListCache$4(t){var e=-1,a=t==null?0:t.length;for(this.clear();++e-1&&t%1==0&&t-1&&t%1==0&&t<=MAX_SAFE_INTEGER$2}var isLength_1=isLength$3,castPath$1=_castPath,isArguments$2=isArguments_1,isArray$6=isArray_1,isIndex$3=_isIndex,isLength$2=isLength_1,toKey$3=_toKey;function hasPath$2(t,e,a){e=castPath$1(e,t);for(var n=-1,r=e.length,i=!1;++n-1}var _arrayIncludes=arrayIncludes$1;function arrayIncludesWith$1(t,e,a){for(var n=-1,r=t==null?0:t.length;++n=LARGE_ARRAY_SIZE$1){var u=e?null:createSet(t);if(u)return setToArray$1(u);o=!1,r=cacheHas$1,l=new SetCache$1}else l=e?[]:s;e:for(;++n{const a=[],n=[];return a.push(e),e||a.push(t.locale),t.enableFallback&&a.push(t.defaultLocale),a.filter(Boolean).map(r=>r.toString()).forEach(function(r){if(n.includes(r)||n.push(r),!t.enableFallback)return;const i=r.split("-");i.length===3&&n.push(`${i[0]}-${i[1]}`),n.push(i[0])}),uniq$1(n)};class Locales{constructor(e){this.i18n=e,this.registry={},this.register("default",defaultLocaleResolver)}register(e,a){if(typeof a!="function"){const n=a;a=()=>n}this.registry[e]=a}get(e){let a=this.registry[e]||this.registry[this.i18n.locale]||this.registry.default;return typeof a=="function"&&(a=a(this.i18n,e)),a instanceof Array||(a=[a]),a}}const en=(t,e)=>{const a=String(t).split("."),n=!a[1],r=Number(a[0])==t,i=r&&a[0].slice(-1),o=r&&a[0].slice(-2);return e?i==1&&o!=11?"one":i==2&&o!=12?"two":i==3&&o!=13?"few":"other":t==1&&n?"one":"other"};function useMakePlural({pluralizer:t,includeZero:e=!0,ordinal:a=!1}){return function(n,r){return[e&&r===0?"zero":"",t(r,a)].filter(Boolean)}}const defaultPluralizer=useMakePlural({pluralizer:en,includeZero:!0});class Pluralization{constructor(e){this.i18n=e,this.registry={},this.register("default",defaultPluralizer)}register(e,a){this.registry[e]=a}get(e){return this.registry[e]||this.registry[this.i18n.locale]||this.registry.default}}function baseSlice$1(t,e,a){var n=-1,r=t.length;e<0&&(e=-e>r?0:r+e),a=a>r?r:a,a<0&&(a+=r),r=e>a?0:a-e>>>0,e>>>=0;for(var i=Array(r);++n=n?t:baseSlice(t,e,a)}var _castSlice=castSlice$1,rsAstralRange$2="\\ud800-\\udfff",rsComboMarksRange$3="\\u0300-\\u036f",reComboHalfMarksRange$3="\\ufe20-\\ufe2f",rsComboSymbolsRange$3="\\u20d0-\\u20ff",rsComboRange$3=rsComboMarksRange$3+reComboHalfMarksRange$3+rsComboSymbolsRange$3,rsVarRange$2="\\ufe0e\\ufe0f",rsZWJ$2="\\u200d",reHasUnicode=RegExp("["+rsZWJ$2+rsAstralRange$2+rsComboRange$3+rsVarRange$2+"]");function hasUnicode$2(t){return reHasUnicode.test(t)}var _hasUnicode=hasUnicode$2;function asciiToArray$1(t){return t.split("")}var _asciiToArray=asciiToArray$1,rsAstralRange$1="\\ud800-\\udfff",rsComboMarksRange$2="\\u0300-\\u036f",reComboHalfMarksRange$2="\\ufe20-\\ufe2f",rsComboSymbolsRange$2="\\u20d0-\\u20ff",rsComboRange$2=rsComboMarksRange$2+reComboHalfMarksRange$2+rsComboSymbolsRange$2,rsVarRange$1="\\ufe0e\\ufe0f",rsAstral="["+rsAstralRange$1+"]",rsCombo$2="["+rsComboRange$2+"]",rsFitz$1="\\ud83c[\\udffb-\\udfff]",rsModifier$1="(?:"+rsCombo$2+"|"+rsFitz$1+")",rsNonAstral$1="[^"+rsAstralRange$1+"]",rsRegional$1="(?:\\ud83c[\\udde6-\\uddff]){2}",rsSurrPair$1="[\\ud800-\\udbff][\\udc00-\\udfff]",rsZWJ$1="\\u200d",reOptMod$1=rsModifier$1+"?",rsOptVar$1="["+rsVarRange$1+"]?",rsOptJoin$1="(?:"+rsZWJ$1+"(?:"+[rsNonAstral$1,rsRegional$1,rsSurrPair$1].join("|")+")"+rsOptVar$1+reOptMod$1+")*",rsSeq$1=rsOptVar$1+reOptMod$1+rsOptJoin$1,rsSymbol="(?:"+[rsNonAstral$1+rsCombo$2+"?",rsCombo$2,rsRegional$1,rsSurrPair$1,rsAstral].join("|")+")",reUnicode=RegExp(rsFitz$1+"(?="+rsFitz$1+")|"+rsSymbol+rsSeq$1,"g");function unicodeToArray$1(t){return t.match(reUnicode)||[]}var _unicodeToArray=unicodeToArray$1,asciiToArray=_asciiToArray,hasUnicode$1=_hasUnicode,unicodeToArray=_unicodeToArray;function stringToArray$1(t){return hasUnicode$1(t)?unicodeToArray(t):asciiToArray(t)}var _stringToArray=stringToArray$1,castSlice=_castSlice,hasUnicode=_hasUnicode,stringToArray=_stringToArray,toString$4=toString_1;function createCaseFirst$1(t){return function(e){e=toString$4(e);var a=hasUnicode(e)?stringToArray(e):void 0,n=a?a[0]:e.charAt(0),r=a?castSlice(a,1).join(""):e.slice(1);return n[t]()+r}}var _createCaseFirst=createCaseFirst$1,createCaseFirst=_createCaseFirst,upperFirst$1=createCaseFirst("toUpperCase"),upperFirst_1=upperFirst$1,toString$3=toString_1,upperFirst=upperFirst_1;function capitalize$1(t){return upperFirst(toString$3(t).toLowerCase())}var capitalize_1=capitalize$1;function arrayReduce$1(t,e,a,n){var r=-1,i=t==null?0:t.length;for(n&&i&&(a=t[++r]);++r(e[camelCase$1(a)]=t[a],e),{}):{}}function isSet(t){return t!=null}function createTranslationOptions(t,e,a){let n=[{scope:e}];if(isSet(a.defaults)&&(n=n.concat(a.defaults)),isSet(a.defaultValue)){const r=typeof a.defaultValue=="function"?a.defaultValue(t,e,a):a.defaultValue;n.push({message:r}),delete a.defaultValue}return n}var isNumeric=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,mathceil=Math.ceil,mathfloor=Math.floor,bignumberError="[BigNumber Error] ",tooManyDigits=bignumberError+"Number primitive has more than 15 significant digits: ",BASE=1e14,LOG_BASE=14,MAX_SAFE_INTEGER$1=9007199254740991,POWS_TEN=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],SQRT_BASE=1e7,MAX=1e9;function clone(t){var e,a,n,r=_.prototype={constructor:_,toString:null,valueOf:null},i=new _(1),o=20,s=4,l=-7,u=21,c=-1e7,d=1e7,h=!1,m=1,p=0,v={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},y="0123456789abcdefghijklmnopqrstuvwxyz",w=!0;function _(g,b){var $,S,P,M,C,E,T,x,A=this;if(!(A instanceof _))return new _(g,b);if(b==null){if(g&&g._isBigNumber===!0){A.s=g.s,!g.c||g.e>d?A.c=A.e=null:g.e=10;C/=10,M++);M>d?A.c=A.e=null:(A.e=M,A.c=[g]);return}x=String(g)}else{if(!isNumeric.test(x=String(g)))return n(A,x,E);A.s=x.charCodeAt(0)==45?(x=x.slice(1),-1):1}(M=x.indexOf("."))>-1&&(x=x.replace(".","")),(C=x.search(/e/i))>0?(M<0&&(M=C),M+=+x.slice(C+1),x=x.substring(0,C)):M<0&&(M=x.length)}else{if(intCheck(b,2,y.length,"Base"),b==10&&w)return A=new _(g),N(A,o+A.e+1,s);if(x=String(g),E=typeof g=="number"){if(g*0!=0)return n(A,x,E,b);if(A.s=1/g<0?(x=x.slice(1),-1):1,_.DEBUG&&x.replace(/^0\.0*|\./,"").length>15)throw Error(tooManyDigits+g)}else A.s=x.charCodeAt(0)===45?(x=x.slice(1),-1):1;for($=y.slice(0,b),M=C=0,T=x.length;CM){M=T;continue}}else if(!P&&(x==x.toUpperCase()&&(x=x.toLowerCase())||x==x.toLowerCase()&&(x=x.toUpperCase()))){P=!0,C=-1,M=0;continue}return n(A,String(g),E,b)}E=!1,x=a(x,b,10,A.s),(M=x.indexOf("."))>-1?x=x.replace(".",""):M=x.length}for(C=0;x.charCodeAt(C)===48;C++);for(T=x.length;x.charCodeAt(--T)===48;);if(x=x.slice(C,++T)){if(T-=C,E&&_.DEBUG&&T>15&&(g>MAX_SAFE_INTEGER$1||g!==mathfloor(g)))throw Error(tooManyDigits+A.s*g);if((M=M-C-1)>d)A.c=A.e=null;else if(M=-MAX&&P<=MAX&&P===mathfloor(P)){if(S[0]===0){if(P===0&&S.length===1)return!0;break e}if(b=(P+1)%LOG_BASE,b<1&&(b+=LOG_BASE),String(S[0]).length==b){for(b=0;b=BASE||$!==mathfloor($))break e;if($!==0)return!0}}}else if(S===null&&P===null&&(M===null||M===1||M===-1))return!0;throw Error(bignumberError+"Invalid BigNumber: "+g)},_.maximum=_.max=function(){return k(arguments,r.lt)},_.minimum=_.min=function(){return k(arguments,r.gt)},_.random=function(){var g=9007199254740992,b=Math.random()*g&2097151?function(){return mathfloor(Math.random()*g)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function($){var S,P,M,C,E,T=0,x=[],A=new _(i);if($==null?$=o:intCheck($,0,MAX),C=mathceil($/LOG_BASE),h)if(crypto.getRandomValues){for(S=crypto.getRandomValues(new Uint32Array(C*=2));T>>11),E>=9e15?(P=crypto.getRandomValues(new Uint32Array(2)),S[T]=P[0],S[T+1]=P[1]):(x.push(E%1e14),T+=2);T=C/2}else if(crypto.randomBytes){for(S=crypto.randomBytes(C*=7);T=9e15?crypto.randomBytes(7).copy(S,T):(x.push(E%1e14),T+=7);T=C/7}else throw h=!1,Error(bignumberError+"crypto unavailable");if(!h)for(;T=10;E/=10,T++);TP-1&&(E[C+1]==null&&(E[C+1]=0),E[C+1]+=E[C]/P|0,E[C]%=P)}return E.reverse()}return function($,S,P,M,C){var E,T,x,A,L,I,W,z,U=$.indexOf("."),B=o,V=s;for(U>=0&&(A=p,p=0,$=$.replace(".",""),z=new _(S),I=z.pow($.length-U),p=A,z.c=b(toFixedPoint(coeffToString(I.c),I.e,"0"),10,P,g),z.e=z.c.length),W=b($,S,P,C?(E=y,g):(E=g,y)),x=A=W.length;W[--A]==0;W.pop());if(!W[0])return E.charAt(0);if(U<0?--x:(I.c=W,I.e=x,I.s=M,I=e(I,z,B,V,P),W=I.c,L=I.r,x=I.e),T=x+B+1,U=W[T],A=P/2,L=L||T<0||W[T+1]!=null,L=V<4?(U!=null||L)&&(V==0||V==(I.s<0?3:2)):U>A||U==A&&(V==4||L||V==6&&W[T-1]&1||V==(I.s<0?8:7)),T<1||!W[0])$=L?toFixedPoint(E.charAt(1),-B,E.charAt(0)):E.charAt(0);else{if(W.length=T,L)for(--P;++W[--T]>P;)W[T]=0,T||(++x,W=[1].concat(W));for(A=W.length;!W[--A];);for(U=0,$="";U<=A;$+=E.charAt(W[U++]));$=toFixedPoint($,x,E.charAt(0))}return $}}(),e=function(){function g(S,P,M){var C,E,T,x,A=0,L=S.length,I=P%SQRT_BASE,W=P/SQRT_BASE|0;for(S=S.slice();L--;)T=S[L]%SQRT_BASE,x=S[L]/SQRT_BASE|0,C=W*T+x*I,E=I*T+C%SQRT_BASE*SQRT_BASE+A,A=(E/M|0)+(C/SQRT_BASE|0)+W*x,S[L]=E%M;return A&&(S=[A].concat(S)),S}function b(S,P,M,C){var E,T;if(M!=C)T=M>C?1:-1;else for(E=T=0;EP[E]?1:-1;break}return T}function $(S,P,M,C){for(var E=0;M--;)S[M]-=E,E=S[M]1;S.splice(0,1));}return function(S,P,M,C,E){var T,x,A,L,I,W,z,U,B,V,H,G,K,Y,J,Q,ee,Z=S.s==P.s?1:-1,X=S.c,q=P.c;if(!X||!X[0]||!q||!q[0])return new _(!S.s||!P.s||(X?q&&X[0]==q[0]:!q)?NaN:X&&X[0]==0||!q?Z*0:Z/0);for(U=new _(Z),B=U.c=[],x=S.e-P.e,Z=M+x+1,E||(E=BASE,x=bitFloor(S.e/LOG_BASE)-bitFloor(P.e/LOG_BASE),Z=Z/LOG_BASE|0),A=0;q[A]==(X[A]||0);A++);if(q[A]>(X[A]||0)&&x--,Z<0)B.push(1),L=!0;else{for(Y=X.length,Q=q.length,A=0,Z+=2,I=mathfloor(E/(q[0]+1)),I>1&&(q=g(q,I,E),X=g(X,I,E),Q=q.length,Y=X.length),K=Q,V=X.slice(0,Q),H=V.length;H=E/2&&J++;do{if(I=0,T=b(q,V,Q,H),T<0){if(G=V[0],Q!=H&&(G=G*E+(V[1]||0)),I=mathfloor(G/J),I>1)for(I>=E&&(I=E-1),W=g(q,I,E),z=W.length,H=V.length;b(W,V,z,H)==1;)I--,$(W,Q=10;Z/=10,A++);N(U,M+(U.e=A+x*LOG_BASE-1)+1,C,L)}else U.e=x,U.r=+L;return U}}();function D(g,b,$,S){var P,M,C,E,T;if($==null?$=s:intCheck($,0,8),!g.c)return g.toString();if(P=g.c[0],C=g.e,b==null)T=coeffToString(g.c),T=S==1||S==2&&(C<=l||C>=u)?toExponential(T,C):toFixedPoint(T,C,"0");else if(g=N(new _(g),b,$),M=g.e,T=coeffToString(g.c),E=T.length,S==1||S==2&&(b<=M||M<=l)){for(;EE){if(--b>0)for(T+=".";b--;T+="0");}else if(b+=M-E,b>0)for(M+1==E&&(T+=".");b--;T+="0");return g.s<0&&P?"-"+T:T}function k(g,b){for(var $,S=1,P=new _(g[0]);S=10;P/=10,S++);return($=S+$*LOG_BASE-1)>d?g.c=g.e=null:$=10;E/=10,P++);if(M=b-P,M<0)M+=LOG_BASE,C=b,T=L[x=0],A=T/I[P-C-1]%10|0;else if(x=mathceil((M+1)/LOG_BASE),x>=L.length)if(S){for(;L.length<=x;L.push(0));T=A=0,P=1,M%=LOG_BASE,C=M-LOG_BASE+1}else break e;else{for(T=E=L[x],P=1;E>=10;E/=10,P++);M%=LOG_BASE,C=M-LOG_BASE+P,A=C<0?0:T/I[P-C-1]%10|0}if(S=S||b<0||L[x+1]!=null||(C<0?T:T%I[P-C-1]),S=$<4?(A||S)&&($==0||$==(g.s<0?3:2)):A>5||A==5&&($==4||S||$==6&&(M>0?C>0?T/I[P-C]:0:L[x-1])%10&1||$==(g.s<0?8:7)),b<1||!L[0])return L.length=0,S?(b-=g.e+1,L[0]=I[(LOG_BASE-b%LOG_BASE)%LOG_BASE],g.e=-b||0):L[0]=g.e=0,g;if(M==0?(L.length=x,E=1,x--):(L.length=x+1,E=I[LOG_BASE-M],L[x]=C>0?mathfloor(T/I[P-C]%I[C])*E:0),S)for(;;)if(x==0){for(M=1,C=L[0];C>=10;C/=10,M++);for(C=L[0]+=E,E=1;C>=10;C/=10,E++);M!=E&&(g.e++,L[0]==BASE&&(L[0]=1));break}else{if(L[x]+=E,L[x]!=BASE)break;L[x--]=0,E=1}for(M=L.length;L[--M]===0;L.pop());}g.e>d?g.c=g.e=null:g.e=u?toExponential(b,$):toFixedPoint(b,$,"0"),g.s<0?"-"+b:b)}return r.absoluteValue=r.abs=function(){var g=new _(this);return g.s<0&&(g.s=1),g},r.comparedTo=function(g,b){return compare(this,new _(g,b))},r.decimalPlaces=r.dp=function(g,b){var $,S,P,M=this;if(g!=null)return intCheck(g,0,MAX),b==null?b=s:intCheck(b,0,8),N(new _(M),g+M.e+1,b);if(!($=M.c))return null;if(S=((P=$.length-1)-bitFloor(this.e/LOG_BASE))*LOG_BASE,P=$[P])for(;P%10==0;P/=10,S--);return S<0&&(S=0),S},r.dividedBy=r.div=function(g,b){return e(this,new _(g,b),o,s)},r.dividedToIntegerBy=r.idiv=function(g,b){return e(this,new _(g,b),0,1)},r.exponentiatedBy=r.pow=function(g,b){var $,S,P,M,C,E,T,x,A,L=this;if(g=new _(g),g.c&&!g.isInteger())throw Error(bignumberError+"Exponent not an integer: "+F(g));if(b!=null&&(b=new _(b)),E=g.e>14,!L.c||!L.c[0]||L.c[0]==1&&!L.e&&L.c.length==1||!g.c||!g.c[0])return A=new _(Math.pow(+F(L),E?g.s*(2-isOdd(g)):+F(g))),b?A.mod(b):A;if(T=g.s<0,b){if(b.c?!b.c[0]:!b.s)return new _(NaN);S=!T&&L.isInteger()&&b.isInteger(),S&&(L=L.mod(b))}else{if(g.e>9&&(L.e>0||L.e<-1||(L.e==0?L.c[0]>1||E&&L.c[1]>=24e7:L.c[0]<8e13||E&&L.c[0]<=9999975e7)))return M=L.s<0&&isOdd(g)?-0:0,L.e>-1&&(M=1/M),new _(T?1/M:M);p&&(M=mathceil(p/LOG_BASE+2))}for(E?($=new _(.5),T&&(g.s=1),x=isOdd(g)):(P=Math.abs(+F(g)),x=P%2),A=new _(i);;){if(x){if(A=A.times(L),!A.c)break;M?A.c.length>M&&(A.c.length=M):S&&(A=A.mod(b))}if(P){if(P=mathfloor(P/2),P===0)break;x=P%2}else if(g=g.times($),N(g,g.e+1,1),g.e>14)x=isOdd(g);else{if(P=+F(g),P===0)break;x=P%2}L=L.times(L),M?L.c&&L.c.length>M&&(L.c.length=M):S&&(L=L.mod(b))}return S?A:(T&&(A=i.div(A)),b?A.mod(b):M?N(A,p,s,C):A)},r.integerValue=function(g){var b=new _(this);return g==null?g=s:intCheck(g,0,8),N(b,b.e+1,g)},r.isEqualTo=r.eq=function(g,b){return compare(this,new _(g,b))===0},r.isFinite=function(){return!!this.c},r.isGreaterThan=r.gt=function(g,b){return compare(this,new _(g,b))>0},r.isGreaterThanOrEqualTo=r.gte=function(g,b){return(b=compare(this,new _(g,b)))===1||b===0},r.isInteger=function(){return!!this.c&&bitFloor(this.e/LOG_BASE)>this.c.length-2},r.isLessThan=r.lt=function(g,b){return compare(this,new _(g,b))<0},r.isLessThanOrEqualTo=r.lte=function(g,b){return(b=compare(this,new _(g,b)))===-1||b===0},r.isNaN=function(){return!this.s},r.isNegative=function(){return this.s<0},r.isPositive=function(){return this.s>0},r.isZero=function(){return!!this.c&&this.c[0]==0},r.minus=function(g,b){var $,S,P,M,C=this,E=C.s;if(g=new _(g,b),b=g.s,!E||!b)return new _(NaN);if(E!=b)return g.s=-b,C.plus(g);var T=C.e/LOG_BASE,x=g.e/LOG_BASE,A=C.c,L=g.c;if(!T||!x){if(!A||!L)return A?(g.s=-b,g):new _(L?C:NaN);if(!A[0]||!L[0])return L[0]?(g.s=-b,g):new _(A[0]?C:s==3?-0:0)}if(T=bitFloor(T),x=bitFloor(x),A=A.slice(),E=T-x){for((M=E<0)?(E=-E,P=A):(x=T,P=L),P.reverse(),b=E;b--;P.push(0));P.reverse()}else for(S=(M=(E=A.length)<(b=L.length))?E:b,E=b=0;b0)for(;b--;A[$++]=0);for(b=BASE-1;S>E;){if(A[--S]=0;){for($=0,I=G[P]%B,W=G[P]/B|0,C=T,M=P+C;M>P;)x=H[--C]%B,A=H[C]/B|0,E=W*x+A*I,x=I*x+E%B*B+z[M]+$,$=(x/U|0)+(E/B|0)+W*A,z[M--]=x%U;z[M]=$}return $?++S:z.splice(0,1),O(g,z,S)},r.negated=function(){var g=new _(this);return g.s=-g.s||null,g},r.plus=function(g,b){var $,S=this,P=S.s;if(g=new _(g,b),b=g.s,!P||!b)return new _(NaN);if(P!=b)return g.s=-b,S.minus(g);var M=S.e/LOG_BASE,C=g.e/LOG_BASE,E=S.c,T=g.c;if(!M||!C){if(!E||!T)return new _(P/0);if(!E[0]||!T[0])return T[0]?g:new _(E[0]?S:P*0)}if(M=bitFloor(M),C=bitFloor(C),E=E.slice(),P=M-C){for(P>0?(C=M,$=T):(P=-P,$=E),$.reverse();P--;$.push(0));$.reverse()}for(P=E.length,b=T.length,P-b<0&&($=T,T=E,E=$,b=P),P=0;b;)P=(E[--b]=E[b]+T[b]+P)/BASE|0,E[b]=BASE===E[b]?0:E[b]%BASE;return P&&(E=[P].concat(E),++C),O(g,E,C)},r.precision=r.sd=function(g,b){var $,S,P,M=this;if(g!=null&&g!==!!g)return intCheck(g,1,MAX),b==null?b=s:intCheck(b,0,8),N(new _(M),g,b);if(!($=M.c))return null;if(P=$.length-1,S=P*LOG_BASE+1,P=$[P]){for(;P%10==0;P/=10,S--);for(P=$[0];P>=10;P/=10,S++);}return g&&M.e+1>S&&(S=M.e+1),S},r.shiftedBy=function(g){return intCheck(g,-MAX_SAFE_INTEGER$1,MAX_SAFE_INTEGER$1),this.times("1e"+g)},r.squareRoot=r.sqrt=function(){var g,b,$,S,P,M=this,C=M.c,E=M.s,T=M.e,x=o+4,A=new _("0.5");if(E!==1||!C||!C[0])return new _(!E||E<0&&(!C||C[0])?NaN:C?M:1/0);if(E=Math.sqrt(+F(M)),E==0||E==1/0?(b=coeffToString(C),(b.length+T)%2==0&&(b+="0"),E=Math.sqrt(+b),T=bitFloor((T+1)/2)-(T<0||T%2),E==1/0?b="5e"+T:(b=E.toExponential(),b=b.slice(0,b.indexOf("e")+1)+T),$=new _(b)):$=new _(E+""),$.c[0]){for(T=$.e,E=T+x,E<3&&(E=0);;)if(P=$,$=A.times(P.plus(e(M,P,x,1))),coeffToString(P.c).slice(0,E)===(b=coeffToString($.c)).slice(0,E))if($.e0&&z>0){for(M=z%E||E,A=W.substr(0,M);M0&&(A+=x+W.slice(M)),I&&(A="-"+A)}S=L?A+($.decimalSeparator||"")+((T=+$.fractionGroupSize)?L.replace(new RegExp("\\d{"+T+"}\\B","g"),"$&"+($.fractionGroupSeparator||"")):L):A}return($.prefix||"")+S+($.suffix||"")},r.toFraction=function(g){var b,$,S,P,M,C,E,T,x,A,L,I,W=this,z=W.c;if(g!=null&&(E=new _(g),!E.isInteger()&&(E.c||E.s!==1)||E.lt(i)))throw Error(bignumberError+"Argument "+(E.isInteger()?"out of range: ":"not an integer: ")+F(E));if(!z)return new _(W);for(b=new _(i),x=$=new _(i),S=T=new _(i),I=coeffToString(z),M=b.e=I.length-W.e-1,b.c[0]=POWS_TEN[(C=M%LOG_BASE)<0?LOG_BASE+C:C],g=!g||E.comparedTo(b)>0?M>0?b:x:E,C=d,d=1/0,E=new _(I),T.c[0]=0;A=e(E,b,0,1),P=$.plus(A.times(S)),P.comparedTo(g)!=1;)$=S,S=P,x=T.plus(A.times(P=x)),T=P,b=E.minus(A.times(P=b)),E=P;return P=e(g.minus($),S,0,1),T=T.plus(P.times(x)),$=$.plus(P.times(S)),T.s=x.s=W.s,M=M*2,L=e(x,S,M,s).minus(W).abs().comparedTo(e(T,$,M,s).minus(W).abs())<1?[x,S]:[T,$],d=C,L},r.toNumber=function(){return+F(this)},r.toPrecision=function(g,b){return g!=null&&intCheck(g,1,MAX),D(this,g,b,2)},r.toString=function(g){var b,$=this,S=$.s,P=$.e;return P===null?S?(b="Infinity",S<0&&(b="-"+b)):b="NaN":(g==null?b=P<=l||P>=u?toExponential(coeffToString($.c),P):toFixedPoint(coeffToString($.c),P,"0"):g===10&&w?($=N(new _($),o+P+1,s),b=toFixedPoint(coeffToString($.c),$.e,"0")):(intCheck(g,2,y.length,"Base"),b=a(toFixedPoint(coeffToString($.c),P,"0"),10,g,S,!0)),S<0&&$.c[0]&&(b="-"+b)),b},r.valueOf=r.toJSON=function(){return F(this)},r._isBigNumber=!0,r[Symbol.toStringTag]="BigNumber",r[Symbol.for("nodejs.util.inspect.custom")]=r.valueOf,t!=null&&_.set(t),_}function bitFloor(t){var e=t|0;return t>0||t===e?e:e-1}function coeffToString(t){for(var e,a,n=1,r=t.length,i=t[0]+"";nu^a?1:-1;for(s=(l=r.length)<(u=i.length)?l:u,o=0;oi[o]^a?1:-1;return l==u?0:l>u^a?1:-1}function intCheck(t,e,a,n){if(ta||t!==mathfloor(t))throw Error(bignumberError+(n||"Argument")+(typeof t=="number"?ta?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function isOdd(t){var e=t.c.length-1;return bitFloor(t.e/LOG_BASE)==e&&t.c[e]%2!=0}function toExponential(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function toFixedPoint(t,e,a){var n,r;if(e<0){for(r=a+".";++e;r+=a);t=r+t}else if(n=t.length,++e>n){for(r=a,e-=n;--e;r+=a);t+=r}else eMAX_SAFE_INTEGER)return a;do e%2&&(a+=t),e=nativeFloor(e/2),e&&(t+=t);while(e);return a}var _baseRepeat=baseRepeat$1,isFunction=isFunction_1,isLength$1=isLength_1;function isArrayLike$4(t){return t!=null&&isLength$1(t.length)&&!isFunction(t)}var isArrayLike_1=isArrayLike$4,eq$1=eq_1,isArrayLike$3=isArrayLike_1,isIndex$1=_isIndex,isObject$2=isObject_1;function isIterateeCall$3(t,e,a){if(!isObject$2(a))return!1;var n=typeof e;return(n=="number"?isArrayLike$3(a)&&isIndex$1(e,a.length):n=="string"&&e in a)?eq$1(a[e],t):!1}var _isIterateeCall=isIterateeCall$3,reWhitespace=/\s/;function trimmedEndIndex$1(t){for(var e=t.length;e--&&reWhitespace.test(t.charAt(e)););return e}var _trimmedEndIndex=trimmedEndIndex$1,trimmedEndIndex=_trimmedEndIndex,reTrimStart=/^\s+/;function baseTrim$1(t){return t&&t.slice(0,trimmedEndIndex(t)+1).replace(reTrimStart,"")}var _baseTrim=baseTrim$1,baseTrim=_baseTrim,isObject$1=isObject_1,isSymbol$1=isSymbol_1,NAN=0/0,reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toNumber$1(t){if(typeof t=="number")return t;if(isSymbol$1(t))return NAN;if(isObject$1(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;t=isObject$1(e)?e+"":e}if(typeof t!="string")return t===0?t:+t;t=baseTrim(t);var a=reIsBinary.test(t);return a||reIsOctal.test(t)?freeParseInt(t.slice(2),a?2:8):reIsBadHex.test(t)?NAN:+t}var toNumber_1=toNumber$1,toNumber=toNumber_1,INFINITY$1=1/0,MAX_INTEGER=17976931348623157e292;function toFinite$2(t){if(!t)return t===0?t:0;if(t=toNumber(t),t===INFINITY$1||t===-INFINITY$1){var e=t<0?-1:1;return e*MAX_INTEGER}return t===t?t:0}var toFinite_1=toFinite$2,toFinite$1=toFinite_1;function toInteger$1(t){var e=toFinite$1(t),a=e%1;return e===e?a?e-a:e:0}var toInteger_1=toInteger$1,baseRepeat=_baseRepeat,isIterateeCall$2=_isIterateeCall,toInteger=toInteger_1,toString=toString_1;function repeat(t,e,a){return(a?isIterateeCall$2(t,e,a):e===void 0)?e=1:e=toInteger(e),baseRepeat(toString(t),e)}var repeat_1=repeat;const repeat$1=getDefaultExportFromCjs(repeat_1);function digitCount(t){return t.isZero()?1:Math.floor(Math.log10(t.abs().toNumber())+1)}function getAbsolutePrecision(t,{precision:e,significant:a}){return a&&e!==null&&e>0?e-digitCount(t):e}function roundNumber(t,e){const a=getAbsolutePrecision(t,e);if(a===null)return t.toString();const n=expandRoundMode(e.roundMode);if(a>=0)return t.toFixed(a,n);const r=Math.pow(10,Math.abs(a));return t=new BigNumber(t.div(r).toFixed(0,n)).times(r),t.toString()}function replaceInFormat(t,{formattedNumber:e,unit:a}){return t.replace("%n",e).replace("%u",a)}function computeSignificand({significand:t,whole:e,precision:a}){if(e==="0"||a===null)return t;const n=Math.max(0,a-e.length);return(t??"").substr(0,n)}function formatNumber(t,e){var a,n,r;const i=new BigNumber(t);if(e.raise&&!i.isFinite())throw new Error(`"${t}" is not a valid numeric value`);const o=roundNumber(i,e),s=new BigNumber(o),l=s.lt(0),u=s.isZero();let[c,d]=o.split(".");const h=[];let m;const p=(a=e.format)!==null&&a!==void 0?a:"%n",v=(n=e.negativeFormat)!==null&&n!==void 0?n:`-${p}`,y=l&&!u?v:p;for(c=c.replace("-","");c.length>0;)h.unshift(c.substr(Math.max(0,c.length-3),3)),c=c.substr(0,c.length-3);return c=h.join(""),m=h.join(e.delimiter),e.significant?d=computeSignificand({whole:c,significand:d,precision:e.precision}):d=d??repeat$1("0",(r=e.precision)!==null&&r!==void 0?r:0),e.stripInsignificantZeros&&d&&(d=d.replace(/0+$/,"")),i.isNaN()&&(m=t.toString()),d&&i.isFinite()&&(m+=(e.separator||".")+d),replaceInFormat(y,{formattedNumber:m,unit:e.unit})}function getFullScope(t,e,a){let n="";return(e instanceof String||typeof e=="string")&&(n=e),e instanceof Array&&(n=e.join(t.defaultSeparator)),a.scope&&(n=[a.scope,n].join(t.defaultSeparator)),n}function inferType(t){var e,a;if(t===null)return"null";const n=typeof t;return n!=="object"?n:((a=(e=t==null?void 0:t.constructor)===null||e===void 0?void 0:e.name)===null||a===void 0?void 0:a.toLowerCase())||"object"}function interpolate(t,e,a){a=Object.keys(a).reduce((r,i)=>(r[t.transformKey(i)]=a[i],r),{});const n=e.match(t.placeholder);if(!n)return e;for(;n.length;){let r;const i=n.shift(),o=i.replace(t.placeholder,"$1");isSet(a[o])?r=a[o].toString().replace(/\$/gm,"_#$#_"):o in a?r=t.nullPlaceholder(t,i,e,a):r=t.missingPlaceholder(t,i,e,a);const s=new RegExp(i.replace(/\{/gm,"\\{").replace(/\}/gm,"\\}"));e=e.replace(s,r)}return e.replace(/_#\$#_/g,"$")}function lookup(t,e,a={}){a=Object.assign({},a);const n="locale"in a?a.locale:t.locale,r=inferType(n),i=t.locales.get(r==="string"?n:typeof n).slice();e=getFullScope(t,e,a).split(t.defaultSeparator).map(s=>t.transformKey(s)).join(".");const o=i.map(s=>get$2(t.translations,[s,e].join(".")));return o.push(a.defaultValue),o.find(s=>isSet(s))}function numberToDelimited(t,e){const a=new BigNumber(t);if(!a.isFinite())return t.toString();if(!e.delimiterPattern.global)throw new Error(`options.delimiterPattern must be a global regular expression; received ${e.delimiterPattern}`);let[n,r]=a.toString().split(".");return n=n.replace(e.delimiterPattern,i=>`${i}${e.delimiter}`),[n,r].filter(Boolean).join(e.separator)}function arrayPush$2(t,e){for(var a=-1,n=e.length,r=t.length;++a0&&a(s)?e>1?baseFlatten$2(s,e-1,a,n,r):arrayPush$1(r,s):n||(r[r.length]=s)}return r}var _baseFlatten=baseFlatten$2,ListCache$2=_ListCache;function stackClear$1(){this.__data__=new ListCache$2,this.size=0}var _stackClear=stackClear$1;function stackDelete$1(t){var e=this.__data__,a=e.delete(t);return this.size=e.size,a}var _stackDelete=stackDelete$1;function stackGet$1(t){return this.__data__.get(t)}var _stackGet=stackGet$1;function stackHas$1(t){return this.__data__.has(t)}var _stackHas=stackHas$1,ListCache$1=_ListCache,Map$2=_Map,MapCache=_MapCache,LARGE_ARRAY_SIZE=200;function stackSet$1(t,e){var a=this.__data__;if(a instanceof ListCache$1){var n=a.__data__;if(!Map$2||n.lengths))return!1;var u=i.get(t),c=i.get(e);if(u&&c)return u==e&&c==t;var d=-1,h=!0,m=a&COMPARE_UNORDERED_FLAG$3?new SetCache:void 0;for(i.set(t,e),i.set(e,t);++de||i&&o&&l&&!s&&!u||n&&o&&l||!a&&l||!r)return 1;if(!n&&!i&&!u&&t=s)return l;var u=a[n];return l*(u=="desc"?-1:1)}}return t.index-e.index}var _compareMultiple=compareMultiple$1,arrayMap=_arrayMap,baseGet=_baseGet,baseIteratee=_baseIteratee,baseMap=_baseMap,baseSortBy=_baseSortBy,baseUnary=_baseUnary,compareMultiple=_compareMultiple,identity$2=identity_1,isArray=isArray_1;function baseOrderBy$1(t,e,a){e.length?e=arrayMap(e,function(i){return isArray(i)?function(o){return baseGet(o,i.length===1?i[0]:i)}:i}):e=[identity$2];var n=-1;e=arrayMap(e,baseUnary(baseIteratee));var r=baseMap(t,function(i,o,s){var l=arrayMap(e,function(u){return u(i)});return{criteria:l,index:++n,value:i}});return baseSortBy(r,function(i,o){return compareMultiple(i,o,a)})}var _baseOrderBy=baseOrderBy$1;function apply$1(t,e,a){switch(a.length){case 0:return t.call(e);case 1:return t.call(e,a[0]);case 2:return t.call(e,a[0],a[1]);case 3:return t.call(e,a[0],a[1],a[2])}return t.apply(e,a)}var _apply=apply$1,apply=_apply,nativeMax$1=Math.max;function overRest$1(t,e,a){return e=nativeMax$1(e===void 0?t.length-1:e,0),function(){for(var n=arguments,r=-1,i=nativeMax$1(n.length-e,0),o=Array(i);++r0){if(++e>=HOT_COUNT)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var _shortOut=shortOut$1,baseSetToString=_baseSetToString,shortOut=_shortOut,setToString$1=shortOut(baseSetToString),_setToString=setToString$1,identity=identity_1,overRest=_overRest,setToString=_setToString;function baseRest$1(t,e){return setToString(overRest(t,e,identity),t+"")}var _baseRest=baseRest$1,baseFlatten$1=_baseFlatten,baseOrderBy=_baseOrderBy,baseRest=_baseRest,isIterateeCall$1=_isIterateeCall,sortBy=baseRest(function(t,e){if(t==null)return[];var a=e.length;return a>1&&isIterateeCall$1(t,e[0],e[1])?e=[]:a>2&&isIterateeCall$1(e[0],e[1],e[2])&&(e=[e[0]]),baseOrderBy(t,baseFlatten$1(e,1),[])}),sortBy_1=sortBy;const sortBy$1=getDefaultExportFromCjs(sortBy_1);function baseZipObject$1(t,e,a){for(var n=-1,r=t.length,i=e.length,o={};++nparseInt(t,10)));function numberToHuman(t,e,a){const n={roundMode:a.roundMode,precision:a.precision,significant:a.significant};let r;if(inferType(a.units)==="string"){const d=a.units;if(r=lookup(t,d),!r)throw new Error(`The scope "${t.locale}${t.defaultSeparator}${getFullScope(t,d,{})}" couldn't be found`)}else r=a.units;let i=roundNumber(new BigNumber(e),n);const o=d=>sortBy$1(Object.keys(d).map(h=>INVERTED_DECIMAL_UNITS[h]),h=>h*-1),s=(d,h)=>{const m=d.isZero()?0:Math.floor(Math.log10(d.abs().toNumber()));return o(h).find(p=>m>=p)||0},l=(d,h)=>{const m=DECIMAL_UNITS[h.toString()];return d[m]||""},u=s(new BigNumber(i),r),c=l(r,u);if(i=roundNumber(new BigNumber(i).div(Math.pow(10,u)),n),a.stripInsignificantZeros){let[d,h]=i.split(".");h=(h||"").replace(/0+$/,""),i=d,h&&(i+=`${a.separator}${h}`)}return a.format.replace("%n",i||"0").replace("%u",c).trim()}const STORAGE_UNITS=["byte","kb","mb","gb","tb","pb","eb"];function numberToHumanSize(t,e,a){const n=expandRoundMode(a.roundMode),r=1024,i=new BigNumber(e).abs(),o=i.lt(r);let s;const l=(p,v)=>{const y=v.length-1,w=new BigNumber(Math.log(p.toNumber())).div(Math.log(r)).integerValue(BigNumber.ROUND_DOWN).toNumber();return Math.min(y,w)},u=p=>`number.human.storage_units.units.${o?"byte":p[c]}`,c=l(i,STORAGE_UNITS);o?s=i.integerValue():s=new BigNumber(roundNumber(i.div(Math.pow(r,c)),{significant:a.significant,precision:a.precision,roundMode:a.roundMode}));const d=t.translate("number.human.storage_units.format",{defaultValue:"%n %u"}),h=t.translate(u(STORAGE_UNITS),{count:i.integerValue().toNumber()});let m=s.toFixed(a.precision,n);return a.stripInsignificantZeros&&(m=m.replace(/(\..*?)0+$/,"$1").replace(/\.$/,"")),d.replace("%n",m).replace("%u",h)}function parseDate(t){if(t instanceof Date)return t;if(typeof t=="number"){const n=new Date;return n.setTime(t),n}const e=new String(t).match(/(\d{4})-(\d{2})-(\d{2})(?:[ T](\d{2}):(\d{2}):(\d{2})(?:[.,](\d{1,3}))?)?(Z|\+00:?00)?/);if(e){const n=e.slice(1,8).map(h=>parseInt(h,10)||0);n[1]-=1;const[r,i,o,s,l,u,c]=n;return e[8]?new Date(Date.UTC(r,i,o,s,l,u,c)):new Date(r,i,o,s,l,u,c)}t.match(/([A-Z][a-z]{2}) ([A-Z][a-z]{2}) (\d+) (\d+:\d+:\d+) ([+-]\d+) (\d+)/)&&new Date().setTime(Date.parse([RegExp.$1,RegExp.$2,RegExp.$3,RegExp.$6,RegExp.$4,RegExp.$5].join(" ")));const a=new Date;return a.setTime(Date.parse(t)),a}function pluralize({i18n:t,count:e,scope:a,options:n,baseScope:r}){n=Object.assign({},n);let i,o;if(typeof a=="object"&&a?i=a:i=lookup(t,a,n),!i)return t.missingTranslation.get(a,n);const l=t.pluralization.get(n.locale)(t,e),u=[];for(;l.length;){const c=l.shift();if(isSet(i[c])){o=i[c];break}u.push(c)}return isSet(o)?(n.count=e,t.interpolate(t,o,n)):t.missingTranslation.get(r.split(t.defaultSeparator).concat([u[0]]),n)}var baseFlatten=_baseFlatten,INFINITY=1/0;function flattenDeep(t){var e=t==null?0:t.length;return e?baseFlatten(t,INFINITY):[]}var flattenDeep_1=flattenDeep;const flattenDeep$1=getDefaultExportFromCjs(flattenDeep_1);class PropertyFlatList{constructor(e){this.target=e}call(){const e=flattenDeep$1(Object.keys(this.target).map(a=>this.compute(this.target[a],a)));return e.sort(),e}compute(e,a){return!isArray$b(e)&&isObject$7(e)?Object.keys(e).map(n=>this.compute(e[n],`${a}.${n}`)):a}}function propertyFlatList(t){return new PropertyFlatList(t).call()}const DEFAULT_OPTIONS={meridian:{am:"AM",pm:"PM"},dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbrDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthNames:[null,"January","February","March","April","May","June","July","August","September","October","November","December"],abbrMonthNames:[null,"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]};function strftime(t,e,a={}){const{abbrDayNames:n,dayNames:r,abbrMonthNames:i,monthNames:o,meridian:s}=Object.assign(Object.assign({},DEFAULT_OPTIONS),a);if(isNaN(t.getTime()))throw new Error("strftime() requires a valid date object, but received an invalid date.");const l=t.getDay(),u=t.getDate(),c=t.getFullYear(),d=t.getMonth()+1,h=t.getHours();let m=h;const p=h>11?"pm":"am",v=t.getSeconds(),y=t.getMinutes(),w=t.getTimezoneOffset(),_=Math.floor(Math.abs(w/60)),D=Math.abs(w)-_*60,k=(w>0?"-":"+")+(_.toString().length<2?"0"+_:_)+(D.toString().length<2?"0"+D:D);return m>12?m=m-12:m===0&&(m=12),e=e.replace("%a",n[l]),e=e.replace("%A",r[l]),e=e.replace("%b",i[d]),e=e.replace("%B",o[d]),e=e.replace("%d",u.toString().padStart(2,"0")),e=e.replace("%e",u.toString()),e=e.replace("%-d",u.toString()),e=e.replace("%H",h.toString().padStart(2,"0")),e=e.replace("%-H",h.toString()),e=e.replace("%k",h.toString()),e=e.replace("%I",m.toString().padStart(2,"0")),e=e.replace("%-I",m.toString()),e=e.replace("%l",m.toString()),e=e.replace("%m",d.toString().padStart(2,"0")),e=e.replace("%-m",d.toString()),e=e.replace("%M",y.toString().padStart(2,"0")),e=e.replace("%-M",y.toString()),e=e.replace("%p",s[p]),e=e.replace("%P",s[p].toLowerCase()),e=e.replace("%S",v.toString().padStart(2,"0")),e=e.replace("%-S",v.toString()),e=e.replace("%w",l.toString()),e=e.replace("%y",c.toString().padStart(2,"0").substr(-2)),e=e.replace("%-y",c.toString().padStart(2,"0").substr(-2).replace(/^0+/,"")),e=e.replace("%Y",c.toString()),e=e.replace(/%z/i,k),e}var nativeCeil=Math.ceil,nativeMax=Math.max;function baseRange$1(t,e,a,n){for(var r=-1,i=nativeMax(nativeCeil((e-t)/(a||1)),0),o=Array(i);i--;)o[n?i:++r]=t,t+=a;return o}var _baseRange=baseRange$1,baseRange=_baseRange,isIterateeCall=_isIterateeCall,toFinite=toFinite_1;function createRange$1(t){return function(e,a,n){return n&&typeof n!="number"&&isIterateeCall(e,a,n)&&(a=n=void 0),e=toFinite(e),a===void 0?(a=e,e=0):a=toFinite(a),n=n===void 0?ea>=t&&a<=e;function timeAgoInWords(t,e,a,n={}){const r=n.scope||"datetime.distance_in_words",i=(F,g=0)=>t.t(F,{count:g,scope:r});e=parseDate(e),a=parseDate(a);let o=e.getTime()/1e3,s=a.getTime()/1e3;o>s&&([e,a,o,s]=[a,e,s,o]);const l=Math.round(s-o),u=Math.round((s-o)/60),d=u/60/24,h=Math.round(u/60),m=Math.round(d),p=Math.round(m/30);if(within(0,1,u))return n.includeSeconds?within(0,4,l)?i("less_than_x_seconds",5):within(5,9,l)?i("less_than_x_seconds",10):within(10,19,l)?i("less_than_x_seconds",20):within(20,39,l)?i("half_a_minute"):within(40,59,l)?i("less_than_x_minutes",1):i("x_minutes",1):u===0?i("less_than_x_minutes",1):i("x_minutes",u);if(within(2,44,u))return i("x_minutes",u);if(within(45,89,u))return i("about_x_hours",1);if(within(90,1439,u))return i("about_x_hours",h);if(within(1440,2519,u))return i("x_days",1);if(within(2520,43199,u))return i("x_days",m);if(within(43200,86399,u))return i("about_x_months",Math.round(u/43200));if(within(86400,525599,u))return i("x_months",p);let v=e.getFullYear();e.getMonth()+1>=3&&(v+=1);let y=a.getFullYear();a.getMonth()+1<3&&(y-=1);const w=v>y?0:range$1(v,y).filter(F=>new Date(F,1,29).getMonth()==1).length,_=525600,D=w*1440,k=u-D,O=Math.trunc(k/_),N=parseFloat((k/_-O).toPrecision(3));return N<.25?i("about_x_years",O):N<.75?i("over_x_years",O):i("almost_x_years",O+1)}const guessStrategy=function(t,e){e instanceof Array&&(e=e.join(t.defaultSeparator));const a=e.split(t.defaultSeparator).slice(-1)[0];return t.missingTranslationPrefix+a.replace("_"," ").replace(/([a-z])([A-Z])/g,(n,r,i)=>`${r} ${i.toLowerCase()}`)},messageStrategy=(t,e,a)=>{const n=getFullScope(t,e,a),r="locale"in a?a.locale:t.locale,i=inferType(r);return`[missing "${[i=="string"?r:i,n].join(t.defaultSeparator)}" translation]`},errorStrategy=(t,e,a)=>{const n=getFullScope(t,e,a),r=[t.locale,n].join(t.defaultSeparator);throw new Error(`Missing translation: ${r}`)};class MissingTranslation{constructor(e){this.i18n=e,this.registry={},this.register("guess",guessStrategy),this.register("message",messageStrategy),this.register("error",errorStrategy)}register(e,a){this.registry[e]=a}get(e,a){var n;return this.registry[(n=a.missingBehavior)!==null&&n!==void 0?n:this.i18n.missingBehavior](this.i18n,e,a)}}var __awaiter=globalThis&&globalThis.__awaiter||function(t,e,a,n){function r(i){return i instanceof a?i:new a(function(o){o(i)})}return new(a||(a=Promise))(function(i,o){function s(c){try{u(n.next(c))}catch(d){o(d)}}function l(c){try{u(n.throw(c))}catch(d){o(d)}}function u(c){c.done?i(c.value):r(c.value).then(s,l)}u((n=n.apply(t,e||[])).next())})};const DEFAULT_I18N_OPTIONS={defaultLocale:"en",availableLocales:["en"],locale:"en",defaultSeparator:".",placeholder:/(?:\{\{|%\{)(.*?)(?:\}\}?)/gm,enableFallback:!1,missingBehavior:"message",missingTranslationPrefix:"",missingPlaceholder:(t,e)=>`[missing "${e}" value]`,nullPlaceholder:(t,e,a,n)=>t.missingPlaceholder(t,e,a,n),transformKey:t=>t};class I18n{constructor(e={},a={}){this._locale=DEFAULT_I18N_OPTIONS.locale,this._defaultLocale=DEFAULT_I18N_OPTIONS.defaultLocale,this._version=0,this.onChangeHandlers=[],this.translations={},this.availableLocales=[],this.t=this.translate,this.p=this.pluralize,this.l=this.localize,this.distanceOfTimeInWords=this.timeAgoInWords;const{locale:n,enableFallback:r,missingBehavior:i,missingTranslationPrefix:o,missingPlaceholder:s,nullPlaceholder:l,defaultLocale:u,defaultSeparator:c,placeholder:d,transformKey:h}=Object.assign(Object.assign({},DEFAULT_I18N_OPTIONS),a);this.locale=n,this.defaultLocale=u,this.defaultSeparator=c,this.enableFallback=r,this.locale=n,this.missingBehavior=i,this.missingTranslationPrefix=o,this.missingPlaceholder=s,this.nullPlaceholder=l,this.placeholder=d,this.pluralization=new Pluralization(this),this.locales=new Locales(this),this.missingTranslation=new MissingTranslation(this),this.transformKey=h,this.interpolate=interpolate,this.store(e)}store(e){propertyFlatList(e).forEach(n=>set$1(this.translations,n,get$2(e,n))),this.hasChanged()}get locale(){return this._locale||this.defaultLocale||"en"}set locale(e){if(typeof e!="string")throw new Error(`Expected newLocale to be a string; got ${inferType(e)}`);const a=this._locale!==e;this._locale=e,a&&this.hasChanged()}get defaultLocale(){return this._defaultLocale||"en"}set defaultLocale(e){if(typeof e!="string")throw new Error(`Expected newLocale to be a string; got ${inferType(e)}`);const a=this._defaultLocale!==e;this._defaultLocale=e,a&&this.hasChanged()}translate(e,a){a=Object.assign({},a);const n=createTranslationOptions(this,e,a);let r;return n.some(o=>(isSet(o.scope)?r=lookup(this,o.scope,a):isSet(o.message)&&(r=o.message),r!=null))?(typeof r=="string"?r=this.interpolate(this,r,a):typeof r=="object"&&r&&isSet(a.count)&&(r=pluralize({i18n:this,count:a.count||0,scope:r,options:a,baseScope:getFullScope(this,e,a)})),a&&r instanceof Array&&(r=r.map(o=>typeof o=="string"?interpolate(this,o,a):o)),r):this.missingTranslation.get(e,a)}pluralize(e,a,n){return pluralize({i18n:this,count:e,scope:a,options:Object.assign({},n),baseScope:getFullScope(this,a,n??{})})}localize(e,a,n){if(n=Object.assign({},n),a==null)return"";switch(e){case"currency":return this.numberToCurrency(a);case"number":return formatNumber(a,Object.assign({delimiter:",",precision:3,separator:".",significant:!1,stripInsignificantZeros:!1},lookup(this,"number.format")));case"percentage":return this.numberToPercentage(a);default:{let r;return e.match(/^(date|time)/)?r=this.toTime(e,a):r=a.toString(),interpolate(this,r,n)}}}toTime(e,a){const n=parseDate(a),r=lookup(this,e);return n.toString().match(/invalid/i)||!r?n.toString():this.strftime(n,r)}numberToCurrency(e,a={}){return formatNumber(e,Object.assign(Object.assign(Object.assign({delimiter:",",format:"%u%n",precision:2,separator:".",significant:!1,stripInsignificantZeros:!1,unit:"$"},camelCaseKeys(this.get("number.format"))),camelCaseKeys(this.get("number.currency.format"))),a))}numberToPercentage(e,a={}){return formatNumber(e,Object.assign(Object.assign(Object.assign({delimiter:"",format:"%n%",precision:3,stripInsignificantZeros:!1,separator:".",significant:!1},camelCaseKeys(this.get("number.format"))),camelCaseKeys(this.get("number.percentage.format"))),a))}numberToHumanSize(e,a={}){return numberToHumanSize(this,e,Object.assign(Object.assign(Object.assign({delimiter:"",precision:3,significant:!0,stripInsignificantZeros:!0,units:{billion:"Billion",million:"Million",quadrillion:"Quadrillion",thousand:"Thousand",trillion:"Trillion",unit:""}},camelCaseKeys(this.get("number.human.format"))),camelCaseKeys(this.get("number.human.storage_units"))),a))}numberToHuman(e,a={}){return numberToHuman(this,e,Object.assign(Object.assign(Object.assign({delimiter:"",separator:".",precision:3,significant:!0,stripInsignificantZeros:!0,format:"%n %u",roundMode:"default",units:{billion:"Billion",million:"Million",quadrillion:"Quadrillion",thousand:"Thousand",trillion:"Trillion",unit:""}},camelCaseKeys(this.get("number.human.format"))),camelCaseKeys(this.get("number.human.decimal_units"))),a))}numberToRounded(e,a){return formatNumber(e,Object.assign({unit:"",precision:3,significant:!1,separator:".",delimiter:"",stripInsignificantZeros:!1},a))}numberToDelimited(e,a={}){return numberToDelimited(e,Object.assign({delimiterPattern:/(\d)(?=(\d\d\d)+(?!\d))/g,delimiter:",",separator:"."},a))}withLocale(e,a){return __awaiter(this,void 0,void 0,function*(){const n=this.locale;try{this.locale=e,yield a()}finally{this.locale=n}})}strftime(e,a,n={}){return strftime(e,a,Object.assign(Object.assign(Object.assign({},camelCaseKeys(lookup(this,"date"))),{meridian:{am:lookup(this,"time.am")||"AM",pm:lookup(this,"time.pm")||"PM"}}),n))}update(e,a,n={strict:!1}){if(n.strict&&!has$1(this.translations,e))throw new Error(`The path "${e}" is not currently defined`);const r=get$2(this.translations,e),i=inferType(r),o=inferType(a);if(n.strict&&i!==o)throw new Error(`The current type for "${e}" is "${i}", but you're trying to override it with "${o}"`);let s;o==="object"?s=Object.assign(Object.assign({},r),a):s=a,set$1(this.translations,e,s),this.hasChanged()}toSentence(e,a={}){const{wordsConnector:n,twoWordsConnector:r,lastWordConnector:i}=Object.assign(Object.assign({wordsConnector:", ",twoWordsConnector:" and ",lastWordConnector:", and "},camelCaseKeys(lookup(this,"support.array"))),a),o=e.length;switch(o){case 0:return"";case 1:return`${e[0]}`;case 2:return e.join(r);default:return[e.slice(0,o-1).join(n),i,e[o-1]].join("")}}timeAgoInWords(e,a,n={}){return timeAgoInWords(this,e,a,n)}onChange(e){return this.onChangeHandlers.push(e),()=>{this.onChangeHandlers.splice(this.onChangeHandlers.indexOf(e),1)}}get version(){return this._version}formatNumber(e,a){return formatNumber(e,a)}get(e){return lookup(this,e)}runCallbacks(){this.onChangeHandlers.forEach(e=>e(this))}hasChanged(){this._version+=1,this.runCallbacks()}}async function loadTranslations(t,e){const n=await(await fetch(`./v2/i18n/${e}.json`)).json();t.store(n)}let currencies$1=[],chart$3=null,chartData$1=null,afterPromises$4=!1,i18n$3;const CACHE_KEY$4="dashboard-budgets-chart",budgets=()=>({loading:!1,autoConversion:!1,loadChart(){if(this.loading!==!0){if(this.loading=!0,chartData$1!==null){this.drawChart(this.generateOptions(chartData$1)),this.loading=!1;return}this.getFreshData()}},drawChart(t){if(chart$3!==null){chart$3.data.datasets=t.data.datasets,chart$3.update();return}chart$3=new Chart(document.querySelector("#budget-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$4);if(t&&typeof e<"u"){chartData$1=e,this.drawChart(this.generateOptions(chartData$1)),this.loading=!1;return}new Dashboard$1().dashboard(new Date(window.store.get("start")),new Date(window.store.get("end")),null).then(n=>{chartData$1=n.data,this.drawChart(this.generateOptions(chartData$1)),window.store.set(CACHE_KEY$4,chartData$1),this.loading=!1})},generateOptions(t){currencies$1=[];let e=getDefaultChartSettings("column");e.options.locale=window.store.get("locale").replace("_","-"),e.options.plugins={tooltip:{callbacks:{title:function(a){return a.label},label:function(a){let n=a.dataset.label||"";return n&&(n+=": "),n+" "+formatMoney(a.parsed.y,currencies$1[a.parsed.x]??"EUR")}}}},e.data={labels:[],datasets:[{label:i18n$3.t("firefly.spent"),data:[],borderWidth:1,stack:1,backgroundColor:getColors("spent","background"),borderColor:getColors("spent","border")},{label:i18n$3.t("firefly.left"),data:[],borderWidth:1,stack:1,backgroundColor:getColors("left","background"),borderColor:getColors("left","border")},{label:i18n$3.t("firefly.overspent"),data:[],borderWidth:1,stack:1,backgroundColor:getColors("overspent","background"),borderColor:getColors("overspent","border")}]};for(const a in t)if(t.hasOwnProperty(a)){let n=t[a],r=n.label+" ("+n.currency_code+")";e.data.labels.push(r),this.autoConversion&&(currencies$1.push(n.native_code),e.data.datasets[0].data.push(parseFloat(n.native_entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(n.native_entries.left)),e.data.datasets[2].data.push(parseFloat(n.native_entries.overspent))),this.autoConversion||(currencies$1.push(n.currency_code),e.data.datasets[0].data.push(parseFloat(n.entries.spent)*-1),e.data.datasets[1].data.push(parseFloat(n.entries.left)),e.data.datasets[2].data.push(parseFloat(n.entries.overspent)))}return e.options.scales={y:{ticks:{callback:function(a){return formatMoney(a,currencies$1[0])}}}},e},init(){Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{i18n$3=new I18n,i18n$3.locale=t[1],loadTranslations(i18n$3,t[1]).then(()=>{this.autoConversion=t[0],afterPromises$4=!0,this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{afterPromises$4&&this.loading===!1&&(chartData$1=null,this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$4&&(this.autoConversion=t,this.loading===!1&&this.loadChart())})}});class Dashboard{dashboard(e,a){let n=format$1(e,"y-MM-dd"),r=format$1(a,"y-MM-dd");return api.get("/api/v2/chart/category/dashboard",{params:{start:n,end:r}})}}let currencies=[],chart$2=null,chartData=null,afterPromises$3=!1;const CACHE_KEY$3="dashboard-categories-chart",categories=()=>({loading:!1,autoConversion:!1,generateOptions(t){currencies=[];let e=getDefaultChartSettings("column"),a={};for(const r in t)if(t.hasOwnProperty(r)){let i=t[r],o=i.currency_code;this.autoConversion&&(o=i.native_code),a.hasOwnProperty(o)||(a[o]={name:o,yAxisID:"",data:{}},currencies.push(o))}for(const r in t)if(t.hasOwnProperty(r)){let i=t[r],o=i.currency_code;this.autoConversion&&(o=i.native_code);for(const s in a)if(a.hasOwnProperty(s)){let l=0;o===s&&(l=parseFloat(i.amount),""+i.currency_code,this.autoConversion&&(l=parseFloat(i.native_amount),""+i.native_code)),a[s].data.hasOwnProperty(i.label)&&(a[s].data[i.label]=a[s].data[i.label]+l),a[s].data.hasOwnProperty(i.label)||(a[s].data[i.label]=l)}e.data.labels.includes(i.label)||e.data.labels.push(i.label)}let n=0;for(const r in a){console.log("series");let i="y"+r,o={label:r,currency_code:r,yAxisID:i,data:[]};for(const s in a[r].data)o.data.push(a[r].data[s]);e.data.datasets.push(o),e.options.scales.hasOwnProperty(i)||(e.options.scales[i]={beginAtZero:!0,type:"linear",position:n===1?"right":"left",ticks:{callback:function(s,l,u){return formatMoney(s,r)}}},n++)}return e},drawChart(t){if(chart$2!==null){chart$2.options=t.options,chart$2.data=t.data,chart$2.update();return}chart$2=new Chart(document.querySelector("#category-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$3);if(t&&typeof e<"u"){chartData=e,this.drawChart(this.generateOptions(chartData)),this.loading=!1;return}new Dashboard().dashboard(new Date(window.store.get("start")),new Date(window.store.get("end")),null).then(n=>{chartData=n.data,this.drawChart(this.generateOptions(n.data)),window.store.set(CACHE_KEY$3,chartData),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,chartData!==null){this.drawChart(this.generateOptions(chartData)),this.loading=!1;return}this.getFreshData()}},init(){Promise.all([getVariable("autoConversion",!1)]).then(t=>{this.autoConversion=t[0],afterPromises$3=!0,this.loadChart()}),window.store.observe("end",()=>{afterPromises$3&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$3&&(this.autoConversion=t,this.loadChart())})}});let Get$2=class{get(e){return api.get("/api/v2/transactions",{params:e})}};/*! * chartjs-chart-sankey v0.12.0 * https://github.com/kurkle/chartjs-chart-sankey#readme * (c) 2022 Jukka Kurkela * Released under the MIT license */function toTextLines(t){const e=[],a=isArray$c(t)?t:isNullOrUndef(t)?[]:[t];for(;a.length;){const n=a.pop();typeof n=="string"?e.unshift.apply(e,n.split(` -`)):Array.isArray(n)?a.push.apply(a,n):isNullOrUndef(a)||e.unshift(""+n)}return e}function validateSizeValue(t){return!t||["min","max"].indexOf(t)===-1?"max":t}const defined=t=>t!==void 0;function calculateX(t,e){const a=new Set(e.map(o=>o.to)),n=new Set(e.map(o=>o.from)),r=new Set([...t.keys()]);let i=0;for(;r.size;){const o=nextColumn([...r],a);for(const s of o){const l=t.get(s);defined(l.x)||(l.x=i),r.delete(s)}r.size&&(a.clear(),e.filter(s=>r.has(s.from)).forEach(s=>a.add(s.to)),i++)}return[...t.keys()].filter(o=>!n.has(o)).forEach(o=>{const s=t.get(o);s.column||(s.x=i)}),i}function nextColumn(t,e){const a=t.filter(n=>!e.has(n));return a.length?a:t.slice(0,1)}const nodeByXY=(t,e)=>t.x!==e.x?t.x-e.x:t.y-e.y;let prevCountId=-1;function getCountId(){return prevCountId=prevCountId<100?prevCountId+1:0,prevCountId}function nodeCount(t,e,a=getCountId()){let n=0;for(const r of t)r.node._visited!==a&&(r.node._visited=a,n+=r.node[e].length+nodeCount(r.node[e],e,a));return n}const flowByNodeCount=t=>(e,a)=>nodeCount(e.node[t],t)-nodeCount(a.node[t],t)||e.node[t].length-a.node[t].length;function processFrom(t,e){t.from.sort(flowByNodeCount("from"));for(const a of t.from){const n=a.node;defined(n.y)||(n.y=e,processFrom(n,e)),e=Math.max(n.y+n.out,e)}return e}function processTo(t,e){t.to.sort(flowByNodeCount("to"));for(const a of t.to){const n=a.node;defined(n.y)||(n.y=e,processTo(n,e)),e=Math.max(n.y+n.in,e)}return e}function setOrGetY(t,e){return defined(t.y)?t.y:(t.y=e,e)}function processRest(t,e){const a=t.filter(c=>c.x===0),n=t.filter(c=>c.x===e),r=a.filter(c=>!defined(c.y)),i=n.filter(c=>!defined(c.y)),o=t.filter(c=>c.x>0&&c.xMath.max(c,d.y+d.out||0),0),l=n.reduce((c,d)=>Math.max(c,d.y+d.in||0),0),u=0;return s>=l?(r.forEach(c=>{s=setOrGetY(c,s),s=Math.max(s+c.out,processTo(c,s))}),i.forEach(c=>{l=setOrGetY(c,l),l=Math.max(l+c.in,processTo(c,l))})):(i.forEach(c=>{l=setOrGetY(c,l),l=Math.max(l+c.in,processTo(c,l))}),r.forEach(c=>{s=setOrGetY(c,s),s=Math.max(s+c.out,processTo(c,s))})),o.forEach(c=>{let d=t.filter(h=>h.x===c.x&&defined(h.y)).reduce((h,m)=>Math.max(h,m.y+Math.max(m.in,m.out)),0);d=setOrGetY(c,d),d=Math.max(d+c.in,processFrom(c,d)),d=Math.max(d+c.out,processTo(c,d)),u=Math.max(u,d)}),Math.max(s,l,u)}function calculateY(t,e){t.sort((o,s)=>Math.max(s.in,s.out)-Math.max(o.in,o.out));const a=t[0];a.y=0;const n=processFrom(a,0),r=processTo(a,0),i=processRest(t,e);return Math.max(n,r,i)}function calculateYUsingPriority(t,e){let a=0,n=0;for(let r=0;r<=e;r++){let i=n;const o=t.filter(s=>s.x===r).sort((s,l)=>s.priority-l.priority);n=o[0].to.filter(s=>s.node.x>r+1).reduce((s,l)=>s+l.flow,0)||0;for(const s of o)s.y=i,i+=Math.max(s.out,s.in);a=Math.max(i,a)}return a}function addPadding(t,e){let a=1,n=0,r=0,i=0;const o=[];t.sort(nodeByXY);for(const s of t){if(s.y){if(s.x===0)o.push(s.y);else{for(n!==s.x&&(n=s.x,r=0),a=r+1;as.y);a++);r=a}s.y+=a*e,a++}i=Math.max(i,s.y+Math.max(s.in,s.out))}return i}function sortFlows(t,e){t.forEach(a=>{const n=Math[e](a.in||a.out,a.out||a.in),r=nl.node.y+l.node.out/2-(u.node.y+u.node.out/2)).forEach((l,u)=>{r?l.addY=u*(n-l.flow)/(s-1):(l.addY=o,o+=l.flow)}),o=0,s=a.to.length,a.to.sort((l,u)=>l.node.y+l.node.in/2-(u.node.y+u.node.in/2)).forEach((l,u)=>{i?l.addY=u*(n-l.flow)/(s-1):(l.addY=o,o+=l.flow)})})}function layout(t,e,a,n){const r=[...t.values()],i=calculateX(t,e),s=(a?calculateYUsingPriority(r,i):calculateY(r,i))*.03,l=addPadding(r,s);return sortFlows(r,n),{maxX:i,maxY:l}}function buildNodesFromRawData(t){const e=new Map;for(let n=0;nr.flow-n.flow;return[...e.values()].forEach(n=>{n.from=n.from.sort(a),n.from.forEach(r=>{r.node=e.get(r.key)}),n.to=n.to.sort(a),n.to.forEach(r=>{r.node=e.get(r.key)})}),e}function getAddY(t,e,a){for(const n of t)if(n.key===e&&n.index===a)return n.addY;return 0}class SankeyController extends DatasetController{parseObjectData(e,a,n,r){const{from:i="from",to:o="to",flow:s="flow"}=this.options.parsing,l=a.map(({[i]:_,[o]:D,[s]:k})=>({from:_,to:D,flow:k})),{xScale:u,yScale:c}=e,d=[],h=this._nodes=buildNodesFromRawData(l),{column:m,priority:p,size:v}=this.getDataset();if(p)for(const _ of h.values())_.key in p&&(_.priority=p[_.key]);if(m)for(const _ of h.values())_.key in m&&(_.column=!0,_.x=m[_.key]);const{maxX:y,maxY:w}=layout(h,l,!!p,validateSizeValue(v));this._maxX=y,this._maxY=w;for(let _=0,D=l.length;_1){const h=u-c*l/2+d;for(let m=0;mt.type==="data"?(t.parsed._custom.x-t.parsed.x)*200:void 0,delay:t=>t.type==="data"?t.parsed.x*500+t.dataIndex*20:void 0},colors:{type:"color",properties:["colorFrom","colorTo"]}},transitions:{hide:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],to:"transparent"}}},show:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],from:"transparent"}}}}};SankeyController.overrides={interaction:{mode:"nearest",intersect:!0},datasets:{clip:!1,parsing:!0},plugins:{tooltip:{callbacks:{title(){return""},label(t){const e=t.dataset.data[t.dataIndex];return e.from+" -> "+e.to+": "+e.flow}}},legend:{display:!1}},scales:{x:{type:"linear",bounds:"data",display:!1,min:0,offset:!1},y:{type:"linear",bounds:"data",display:!1,min:0,reverse:!0,offset:!1}},layout:{padding:{top:3,left:3,right:13,bottom:3}}};const controlPoints=(t,e,a,n)=>t({x:t.x+a*(e.x-t.x),y:t.y+a*(e.y-t.y)});function setStyle(t,{x:e,x2:a,options:n}){let r;n.colorMode==="from"?r=color(n.colorFrom).alpha(.5).rgbString():n.colorMode==="to"?r=color(n.colorTo).alpha(.5).rgbString():(r=t.createLinearGradient(e,0,a,0),r.addColorStop(0,color(n.colorFrom).alpha(.5).rgbString()),r.addColorStop(1,color(n.colorTo).alpha(.5).rgbString())),t.fillStyle=r,t.strokeStyle=r,t.lineWidth=.5}class Flow extends Element$1{constructor(e){super(),this.options=void 0,this.x=void 0,this.y=void 0,this.x2=void 0,this.y2=void 0,this.height=void 0,e&&Object.assign(this,e)}draw(e){const a=this,{x:n,x2:r,y:i,y2:o,height:s,progress:l}=a,{cp1:u,cp2:c}=controlPoints(n,i,r,o);l!==0&&(e.save(),l<1&&(e.beginPath(),e.rect(n,Math.min(i,o),(r-n)*l+1,Math.abs(o-i)+s+1),e.clip()),setStyle(e,a),e.beginPath(),e.moveTo(n,i),e.bezierCurveTo(u.x,u.y,c.x,c.y,r,o),e.lineTo(r,o+s),e.bezierCurveTo(c.x,c.y+s,u.x,u.y+s,n,i+s),e.lineTo(n,i),e.stroke(),e.closePath(),e.fill(),e.restore())}inRange(e,a,n){const{x:r,y:i,x2:o,y2:s,height:l}=this.getProps(["x","y","x2","y2","height"],n);if(eo)return!1;const{cp1:u,cp2:c}=controlPoints(r,i,o,s),d=(e-r)/(o-r),h={x:r,y:i},m={x:o,y:s},p=pointInLine(h,u,d),v=pointInLine(u,c,d),y=pointInLine(c,m,d),w=pointInLine(p,v,d),_=pointInLine(v,y,d),D=pointInLine(w,_,d).y;return a>=D&&a<=D+l}inXRange(e,a){const{x:n,x2:r}=this.getProps(["x","x2"],a);return e>=n&&e<=r}inYRange(e,a){const{y:n,y2:r,height:i}=this.getProps(["y","y2","height"],a),o=Math.min(n,r),s=Math.max(n,r)+i;return e>=o&&e<=s}getCenterPoint(e){const{x:a,y:n,x2:r,y2:i,height:o}=this.getProps(["x","y","x2","y2","height"],e);return{x:(a+r)/2,y:(n+i+o)/2}}tooltipPosition(e){return this.getCenterPoint(e)}getRange(e){return e==="x"?this.width/2:this.height/2}}Flow.id="flow";Flow.defaults={colorFrom:"red",colorTo:"green",colorMode:"gradient",hoverColorFrom:(t,e)=>getHoverColor(e.colorFrom),hoverColorTo:(t,e)=>getHoverColor(e.colorTo)};Chart.register({SankeyController,Flow});const CACHE_KEY$2="dashboard-sankey-data";let i18n$2,afterPromises$2=!1,chart$1=null,transactions=[],translations={category:null,unknown_category:null,in:null,out:null,unknown_source:null,unknown_dest:null,unknown_account:null,expense_account:null,revenue_account:null,budget:null,unknown_budget:null,all_money:null};const getColor=function(t){return t.includes(translations.revenue_account)?"forestgreen":t.includes("("+translations.in+",")?"green":t.includes(translations.budget)||t.includes(translations.unknown_budget)?"Orchid":t.includes("("+translations.out+",")?"MediumOrchid":t.includes(translations.all_money)?"blue":"red"};function getObjectName(t,e,a,n){if(t==="category"&&e!==null&&a==="in")return translations.category+' "'+e+'" ('+translations.in+", "+n+")";if(t==="category"&&e===null&&a==="in")return translations.unknown_category+" ("+translations.in+", "+n+")";if(t==="category"&&e!==null&&a==="out")return translations.category+' "'+e+'" ('+translations.out+", "+n+")";if(t==="category"&&e===null&&a==="out")return translations.unknown_category+" ("+translations.out+", "+n+")";if(t==="account"&&e===null&&a==="in")return translations.unknown_source+" ("+n+")";if(t==="account"&&e!==null&&a==="in")return translations.revenue_account+'"'+e+'" ('+n+")";if(t==="account"&&e===null&&a==="out")return translations.unknown_dest+" ("+n+")";if(t==="account"&&e!==null&&a==="out")return translations.expense_account+' "'+e+'" ('+n+")";if(t==="budget"&&e!==null)return translations.budget+' "'+e+'" ('+n+")";if(t==="budget"&&e===null)return translations.unknown_budget+" ("+n+")";console.error('Cannot handle: type:"'+t+'", dir: "'+a+'"')}function getLabelName(t,e,a){if(t==="category"&&e!==null)return translations.category+' "'+e+'" ('+a+")";if(t==="category"&&e===null)return translations.unknown_category+" ("+a+")";if(t==="account"&&e===null)return translations.unknown_account+" ("+a+")";if(t==="account"&&e!==null)return e+" ("+a+")";if(t==="budget"&&e!==null)return translations.budget+' "'+e+'" ('+a+")";if(t==="budget"&&e===null)return translations.unknown_budget+" ("+a+")";console.error('Cannot handle: type:"'+t+'"')}const sankey=()=>({loading:!1,autoConversion:!1,generateOptions(){let t=getDefaultChartSettings("sankey"),e={},a={};for(let r in transactions)if(transactions.hasOwnProperty(r)){let i=transactions[r];for(let o in i.attributes.transactions)if(i.attributes.transactions.hasOwnProperty(o)){let s=i.attributes.transactions[o],l=this.autoConversion?s.native_code:s.currency_code,u=this.autoConversion?parseFloat(s.native_amount):parseFloat(s.amount),c;if(s.type==="deposit"){let d=getObjectName("category",s.category_name,"in",l),h=getObjectName("account",s.source_name,"in",l);a[d]=getLabelName("category",s.category_name,l),a[h]=getLabelName("account",s.source_name,l),c=h+"-"+d+"-"+l,e.hasOwnProperty(c)||(e[c]={from:h,to:d,amount:0}),e[c].amount+=u,c=d+"-"+translations.all_money+"-"+l,e.hasOwnProperty(c)||(e[c]={from:d,to:translations.all_money+" ("+l+")",amount:0}),e[c].amount+=u}if(s.type==="withdrawal"){let d=getObjectName("budget",s.budget_name,"out",l);a[d]=getLabelName("budget",s.budget_name,l),c=translations.all_money+"-"+d+"-"+l,e.hasOwnProperty(c)||(e[c]={from:translations.all_money+" ("+l+")",to:d,amount:0}),e[c].amount+=u;let h=getObjectName("category",s.category_name,"out",l);a[h]=getLabelName("category",s.category_name,l),c=d+"-"+h+"-"+l,e.hasOwnProperty(c)||(e[c]={from:d,to:h,amount:0}),e[c].amount+=u;let m=getObjectName("account",s.destination_name,"out",l);a[m]=getLabelName("account",s.destination_name,l),c=h+"-"+m+"-"+l,e.hasOwnProperty(c)||(e[c]={from:h,to:m,amount:0}),e[c].amount+=u}}}let n={label:"Firefly III dashboard sankey chart",data:[],colorFrom:r=>getColor(r.dataset.data[r.dataIndex].from),colorTo:r=>getColor(r.dataset.data[r.dataIndex].to),colorMode:"gradient",labels:a,size:"min"};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];n.data.push({from:i.from,to:i.to,flow:i.amount})}return t.data.datasets.push(n),t},drawChart(t){if(chart$1!==null){chart$1.data.datasets=t.data.datasets,chart$1.update();return}chart$1=new Chart(document.querySelector("#sankey-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$2);if(t&&typeof e<"u"){transactions=e,this.drawChart(this.generateOptions()),this.loading=!1;return}let a={start:window.store.get("start").slice(0,10),end:window.store.get("end").slice(0,10),type:"withdrawal,deposit",page:1};this.downloadTransactions(a)},downloadTransactions(t){new Get$2().get(t).then(a=>{if(transactions=[...transactions,...a.data.data],parseInt(a.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadTransactions(t);return}window.store.set(CACHE_KEY$2,transactions),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,transactions.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){transactions=[],Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{i18n$2=new I18n,i18n$2.locale=t[1],loadTranslations(i18n$2,t[1]).then(()=>{translations.all_money=i18n$2.t("firefly.all_money"),translations.category=i18n$2.t("firefly.category"),translations.in=i18n$2.t("firefly.money_flowing_in"),translations.out=i18n$2.t("firefly.money_flowing_out"),translations.unknown_category=i18n$2.t("firefly.unknown_category_plain"),translations.unknown_source=i18n$2.t("firefly.unknown_source_plain"),translations.unknown_dest=i18n$2.t("firefly.unknown_dest_plain"),translations.unknown_account=i18n$2.t("firefly.unknown_any_plain"),translations.unknown_budget=i18n$2.t("firefly.unknown_budget_plain"),translations.expense_account=i18n$2.t("firefly.expense_account"),translations.revenue_account=i18n$2.t("firefly.revenue_account"),translations.budget=i18n$2.t("firefly.budget"),afterPromises$2=!0,this.autoConversion=t[0],this.loadChart()})}),window.store.observe("end",()=>{afterPromises$2&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$2&&(this.autoConversion=t,this.loadChart())})}});let Get$1=class{get(e){return api.get("/api/v2/subscriptions",{params:e})}paid(e){return api.get("/api/v2/subscriptions/sum/paid",{params:e})}unpaid(e){return api.get("/api/v2/subscriptions/sum/unpaid",{params:e})}};const CACHE_KEY$1="dashboard-subscriptions-data";let chart=null,afterPromises$1=!1,i18n$1;const subscriptions=()=>({loading:!1,autoConversion:!1,loadChart(){this.loading!==!0&&(this.loading=!0,this.getFreshData())},drawChart(t){if(chart!==null){chart.data.datasets=t.data.datasets,chart.update();return}chart=new Chart(document.querySelector("#subscriptions-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$1);if(t&&typeof e<"u"){this.drawChart(this.generateOptions(e)),this.loading=!1;return}const a=new Get$1;let n={start:format$1(new Date(window.store.get("start")),"y-MM-dd"),end:format$1(new Date(window.store.get("end")),"y-MM-dd")};a.paid(n).then(r=>{let i=r.data;a.unpaid(n).then(o=>{let s=o.data,l={paid:i,unpaid:s};window.store.set(CACHE_KEY$1,l),this.drawChart(this.generateOptions(l)),this.loading=!1})})},generateOptions(t){let e=getDefaultChartSettings("pie");e.data.labels=[i18n$1.t("firefly.paid"),i18n$1.t("firefly.unpaid")],e.data.datasets=[];let a={};for(let n in t.paid)if(t.paid.hasOwnProperty(n)){let r=t.paid[n],i=this.autoConversion?r.native_code:r.currency_code,o=this.autoConversion?r.native_sum:r.sum;a.hasOwnProperty(i)||(a[i]={paid:0,unpaid:0}),a[i].paid+=parseFloat(o)*-1}for(let n in t.unpaid)if(t.unpaid.hasOwnProperty(n)){let r=t.unpaid[n],i=this.autoConversion?r.native_code:r.currency_code,o=this.autoConversion?r.native_sum:r.sum;a.hasOwnProperty(i)||(a[i]={paid:0,unpaid:0}),a[i].unpaid+=parseFloat(o)}for(let n in a)if(a.hasOwnProperty(n)){let r=a[n];e.data.datasets.push({label:n,data:[r.paid,r.unpaid],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"]})}return e},init(){Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{this.autoConversion=t[0],afterPromises$1=!0,i18n$1=new I18n,i18n$1.locale=t[1],loadTranslations(i18n$1,t[1]).then(()=>{this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{afterPromises$1&&this.loading===!1&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$1&&(this.autoConversion=t,this.loading===!1&&this.loadChart())})}});class Get{get(e){return api.get("/api/v2/piggy-banks",{params:e})}}let apiData={},afterPromises=!1,i18n;const CACHE_KEY="dashboard-piggies-data",piggies=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY);if(t&&typeof e<"u"){apiData=e,this.parsePiggies(),this.loading=!1;return}let a={start:window.store.get("start").slice(0,10),end:window.store.get("end").slice(0,10),page:1};this.downloadPiggyBanks(a)},downloadPiggyBanks(t){new Get().get(t).then(a=>{if(apiData=[...apiData,...a.data.data],parseInt(a.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadPiggyBanks(t);return}window.store.set(CACHE_KEY,apiData),this.parsePiggies(),this.loading=!1})},parsePiggies(){let t=[];for(let e in apiData)if(apiData.hasOwnProperty(e)){let a=apiData[e];if(a.attributes.percentage>=100||a.attributes.percentage===0)continue;let n=a.object_group_title??i18n.t("firefly.default_group_title_name_plain");t.hasOwnProperty(n)||(t[n]={id:a.object_group_id??0,title:n,order:a.object_group_order??0,piggies:[]});let r={id:a.id,name:a.attributes.name,percentage:parseInt(a.attributes.percentage),amount:this.autoConversion?a.attributes.native_current_amount:a.attributes.current_amount,left_to_save:this.autoConversion?a.attributes.native_left_to_save:a.attributes.left_to_save,target_amount:this.autoConversion?a.attributes.native_target_amount:a.attributes.target_amount,save_per_month:this.autoConversion?a.attributes.native_save_per_month:a.attributes.save_per_month,currency_code:this.autoConversion?a.attributes.native_code:a.attributes.currency_code};t[n].piggies.push(r)}this.piggies=Object.values(t)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){apiData=[],Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{i18n=new I18n,i18n.locale=t[1],loadTranslations(i18n,t[1]).then(()=>{afterPromises=!0,this.autoConversion=t[0],this.loadPiggyBanks()})}),window.store.observe("end",()=>{afterPromises&&(apiData=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",t=>{afterPromises&&(this.autoConversion=t,this.loadPiggyBanks())})}});/*! +`)):Array.isArray(n)?a.push.apply(a,n):isNullOrUndef(a)||e.unshift(""+n)}return e}function validateSizeValue(t){return!t||["min","max"].indexOf(t)===-1?"max":t}const defined=t=>t!==void 0;function calculateX(t,e){const a=new Set(e.map(o=>o.to)),n=new Set(e.map(o=>o.from)),r=new Set([...t.keys()]);let i=0;for(;r.size;){const o=nextColumn([...r],a);for(const s of o){const l=t.get(s);defined(l.x)||(l.x=i),r.delete(s)}r.size&&(a.clear(),e.filter(s=>r.has(s.from)).forEach(s=>a.add(s.to)),i++)}return[...t.keys()].filter(o=>!n.has(o)).forEach(o=>{const s=t.get(o);s.column||(s.x=i)}),i}function nextColumn(t,e){const a=t.filter(n=>!e.has(n));return a.length?a:t.slice(0,1)}const nodeByXY=(t,e)=>t.x!==e.x?t.x-e.x:t.y-e.y;let prevCountId=-1;function getCountId(){return prevCountId=prevCountId<100?prevCountId+1:0,prevCountId}function nodeCount(t,e,a=getCountId()){let n=0;for(const r of t)r.node._visited!==a&&(r.node._visited=a,n+=r.node[e].length+nodeCount(r.node[e],e,a));return n}const flowByNodeCount=t=>(e,a)=>nodeCount(e.node[t],t)-nodeCount(a.node[t],t)||e.node[t].length-a.node[t].length;function processFrom(t,e){t.from.sort(flowByNodeCount("from"));for(const a of t.from){const n=a.node;defined(n.y)||(n.y=e,processFrom(n,e)),e=Math.max(n.y+n.out,e)}return e}function processTo(t,e){t.to.sort(flowByNodeCount("to"));for(const a of t.to){const n=a.node;defined(n.y)||(n.y=e,processTo(n,e)),e=Math.max(n.y+n.in,e)}return e}function setOrGetY(t,e){return defined(t.y)?t.y:(t.y=e,e)}function processRest(t,e){const a=t.filter(c=>c.x===0),n=t.filter(c=>c.x===e),r=a.filter(c=>!defined(c.y)),i=n.filter(c=>!defined(c.y)),o=t.filter(c=>c.x>0&&c.xMath.max(c,d.y+d.out||0),0),l=n.reduce((c,d)=>Math.max(c,d.y+d.in||0),0),u=0;return s>=l?(r.forEach(c=>{s=setOrGetY(c,s),s=Math.max(s+c.out,processTo(c,s))}),i.forEach(c=>{l=setOrGetY(c,l),l=Math.max(l+c.in,processTo(c,l))})):(i.forEach(c=>{l=setOrGetY(c,l),l=Math.max(l+c.in,processTo(c,l))}),r.forEach(c=>{s=setOrGetY(c,s),s=Math.max(s+c.out,processTo(c,s))})),o.forEach(c=>{let d=t.filter(h=>h.x===c.x&&defined(h.y)).reduce((h,m)=>Math.max(h,m.y+Math.max(m.in,m.out)),0);d=setOrGetY(c,d),d=Math.max(d+c.in,processFrom(c,d)),d=Math.max(d+c.out,processTo(c,d)),u=Math.max(u,d)}),Math.max(s,l,u)}function calculateY(t,e){t.sort((o,s)=>Math.max(s.in,s.out)-Math.max(o.in,o.out));const a=t[0];a.y=0;const n=processFrom(a,0),r=processTo(a,0),i=processRest(t,e);return Math.max(n,r,i)}function calculateYUsingPriority(t,e){let a=0,n=0;for(let r=0;r<=e;r++){let i=n;const o=t.filter(s=>s.x===r).sort((s,l)=>s.priority-l.priority);n=o[0].to.filter(s=>s.node.x>r+1).reduce((s,l)=>s+l.flow,0)||0;for(const s of o)s.y=i,i+=Math.max(s.out,s.in);a=Math.max(i,a)}return a}function addPadding(t,e){let a=1,n=0,r=0,i=0;const o=[];t.sort(nodeByXY);for(const s of t){if(s.y){if(s.x===0)o.push(s.y);else{for(n!==s.x&&(n=s.x,r=0),a=r+1;as.y);a++);r=a}s.y+=a*e,a++}i=Math.max(i,s.y+Math.max(s.in,s.out))}return i}function sortFlows(t,e){t.forEach(a=>{const n=Math[e](a.in||a.out,a.out||a.in),r=nl.node.y+l.node.out/2-(u.node.y+u.node.out/2)).forEach((l,u)=>{r?l.addY=u*(n-l.flow)/(s-1):(l.addY=o,o+=l.flow)}),o=0,s=a.to.length,a.to.sort((l,u)=>l.node.y+l.node.in/2-(u.node.y+u.node.in/2)).forEach((l,u)=>{i?l.addY=u*(n-l.flow)/(s-1):(l.addY=o,o+=l.flow)})})}function layout(t,e,a,n){const r=[...t.values()],i=calculateX(t,e),s=(a?calculateYUsingPriority(r,i):calculateY(r,i))*.03,l=addPadding(r,s);return sortFlows(r,n),{maxX:i,maxY:l}}function buildNodesFromRawData(t){const e=new Map;for(let n=0;nr.flow-n.flow;return[...e.values()].forEach(n=>{n.from=n.from.sort(a),n.from.forEach(r=>{r.node=e.get(r.key)}),n.to=n.to.sort(a),n.to.forEach(r=>{r.node=e.get(r.key)})}),e}function getAddY(t,e,a){for(const n of t)if(n.key===e&&n.index===a)return n.addY;return 0}class SankeyController extends DatasetController{parseObjectData(e,a,n,r){const{from:i="from",to:o="to",flow:s="flow"}=this.options.parsing,l=a.map(({[i]:_,[o]:D,[s]:k})=>({from:_,to:D,flow:k})),{xScale:u,yScale:c}=e,d=[],h=this._nodes=buildNodesFromRawData(l),{column:m,priority:p,size:v}=this.getDataset();if(p)for(const _ of h.values())_.key in p&&(_.priority=p[_.key]);if(m)for(const _ of h.values())_.key in m&&(_.column=!0,_.x=m[_.key]);const{maxX:y,maxY:w}=layout(h,l,!!p,validateSizeValue(v));this._maxX=y,this._maxY=w;for(let _=0,D=l.length;_1){const h=u-c*l/2+d;for(let m=0;mt.type==="data"?(t.parsed._custom.x-t.parsed.x)*200:void 0,delay:t=>t.type==="data"?t.parsed.x*500+t.dataIndex*20:void 0},colors:{type:"color",properties:["colorFrom","colorTo"]}},transitions:{hide:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],to:"transparent"}}},show:{animations:{colors:{type:"color",properties:["colorFrom","colorTo"],from:"transparent"}}}}};SankeyController.overrides={interaction:{mode:"nearest",intersect:!0},datasets:{clip:!1,parsing:!0},plugins:{tooltip:{callbacks:{title(){return""},label(t){const e=t.dataset.data[t.dataIndex];return e.from+" -> "+e.to+": "+e.flow}}},legend:{display:!1}},scales:{x:{type:"linear",bounds:"data",display:!1,min:0,offset:!1},y:{type:"linear",bounds:"data",display:!1,min:0,reverse:!0,offset:!1}},layout:{padding:{top:3,left:3,right:13,bottom:3}}};const controlPoints=(t,e,a,n)=>t({x:t.x+a*(e.x-t.x),y:t.y+a*(e.y-t.y)});function setStyle(t,{x:e,x2:a,options:n}){let r;n.colorMode==="from"?r=color(n.colorFrom).alpha(.5).rgbString():n.colorMode==="to"?r=color(n.colorTo).alpha(.5).rgbString():(r=t.createLinearGradient(e,0,a,0),r.addColorStop(0,color(n.colorFrom).alpha(.5).rgbString()),r.addColorStop(1,color(n.colorTo).alpha(.5).rgbString())),t.fillStyle=r,t.strokeStyle=r,t.lineWidth=.5}class Flow extends Element$1{constructor(e){super(),this.options=void 0,this.x=void 0,this.y=void 0,this.x2=void 0,this.y2=void 0,this.height=void 0,e&&Object.assign(this,e)}draw(e){const a=this,{x:n,x2:r,y:i,y2:o,height:s,progress:l}=a,{cp1:u,cp2:c}=controlPoints(n,i,r,o);l!==0&&(e.save(),l<1&&(e.beginPath(),e.rect(n,Math.min(i,o),(r-n)*l+1,Math.abs(o-i)+s+1),e.clip()),setStyle(e,a),e.beginPath(),e.moveTo(n,i),e.bezierCurveTo(u.x,u.y,c.x,c.y,r,o),e.lineTo(r,o+s),e.bezierCurveTo(c.x,c.y+s,u.x,u.y+s,n,i+s),e.lineTo(n,i),e.stroke(),e.closePath(),e.fill(),e.restore())}inRange(e,a,n){const{x:r,y:i,x2:o,y2:s,height:l}=this.getProps(["x","y","x2","y2","height"],n);if(eo)return!1;const{cp1:u,cp2:c}=controlPoints(r,i,o,s),d=(e-r)/(o-r),h={x:r,y:i},m={x:o,y:s},p=pointInLine(h,u,d),v=pointInLine(u,c,d),y=pointInLine(c,m,d),w=pointInLine(p,v,d),_=pointInLine(v,y,d),D=pointInLine(w,_,d).y;return a>=D&&a<=D+l}inXRange(e,a){const{x:n,x2:r}=this.getProps(["x","x2"],a);return e>=n&&e<=r}inYRange(e,a){const{y:n,y2:r,height:i}=this.getProps(["y","y2","height"],a),o=Math.min(n,r),s=Math.max(n,r)+i;return e>=o&&e<=s}getCenterPoint(e){const{x:a,y:n,x2:r,y2:i,height:o}=this.getProps(["x","y","x2","y2","height"],e);return{x:(a+r)/2,y:(n+i+o)/2}}tooltipPosition(e){return this.getCenterPoint(e)}getRange(e){return e==="x"?this.width/2:this.height/2}}Flow.id="flow";Flow.defaults={colorFrom:"red",colorTo:"green",colorMode:"gradient",hoverColorFrom:(t,e)=>getHoverColor(e.colorFrom),hoverColorTo:(t,e)=>getHoverColor(e.colorTo)};Chart.register({SankeyController,Flow});const CACHE_KEY$2="dashboard-sankey-data";let i18n$2,afterPromises$2=!1,chart$1=null,transactions=[],autoConversion=!1,translations={category:null,unknown_category:null,in:null,out:null,unknown_source:null,unknown_dest:null,unknown_account:null,expense_account:null,revenue_account:null,budget:null,unknown_budget:null,all_money:null};const getColor=function(t){return t.includes(translations.revenue_account)?"forestgreen":t.includes("("+translations.in+",")?"green":t.includes(translations.budget)||t.includes(translations.unknown_budget)?"Orchid":t.includes("("+translations.out+",")?"MediumOrchid":t.includes(translations.all_money)?"blue":"red"};function getObjectName(t,e,a,n){if(t==="category"&&e!==null&&a==="in")return translations.category+' "'+e+'" ('+translations.in+(autoConversion?", "+n+")":")");if(t==="category"&&e===null&&a==="in")return translations.unknown_category+" ("+translations.in+(autoConversion?", "+n+")":")");if(t==="category"&&e!==null&&a==="out")return translations.category+' "'+e+'" ('+translations.out+(autoConversion?", "+n+")":")");if(t==="category"&&e===null&&a==="out")return translations.unknown_category+" ("+translations.out+(autoConversion?", "+n+")":")");if(t==="account"&&e===null&&a==="in")return translations.unknown_source+(autoConversion?" ("+n+")":"");if(t==="account"&&e!==null&&a==="in")return translations.revenue_account+'"'+e+'"'+(autoConversion?" ("+n+")":"");if(t==="account"&&e===null&&a==="out")return translations.unknown_dest+(autoConversion?" ("+n+")":"");if(t==="account"&&e!==null&&a==="out")return translations.expense_account+' "'+e+'"'+(autoConversion?" ("+n+")":"");if(t==="budget"&&e!==null)return translations.budget+' "'+e+'"'+(autoConversion?" ("+n+")":"");if(t==="budget"&&e===null)return translations.unknown_budget+(autoConversion?" ("+n+")":"");console.error('Cannot handle: type:"'+t+'", dir: "'+a+'"')}function getLabelName(t,e,a){if(t==="category"&&e!==null)return translations.category+' "'+e+'"'+(autoConversion?" ("+a+")":"");if(t==="category"&&e===null)return translations.unknown_category+(autoConversion?" ("+a+")":"");if(t==="account"&&e===null)return translations.unknown_account+(autoConversion?" ("+a+")":"");if(t==="account"&&e!==null)return e+(autoConversion?" ("+a+")":"");if(t==="budget"&&e!==null)return translations.budget+' "'+e+'"'+(autoConversion?" ("+a+")":"");if(t==="budget"&&e===null)return translations.unknown_budget+(autoConversion?" ("+a+")":"");console.error('Cannot handle: type:"'+t+'"')}const sankey=()=>({loading:!1,autoConversion:!1,generateOptions(){let t=getDefaultChartSettings("sankey"),e={},a={};for(let r in transactions)if(transactions.hasOwnProperty(r)){let i=transactions[r];for(let o in i.attributes.transactions)if(i.attributes.transactions.hasOwnProperty(o)){let s=i.attributes.transactions[o],l=this.autoConversion?s.native_code:s.currency_code,u=this.autoConversion?parseFloat(s.native_amount):parseFloat(s.amount),c;if(s.type==="deposit"){let d=getObjectName("category",s.category_name,"in",l),h=getObjectName("account",s.source_name,"in",l);a[d]=getLabelName("category",s.category_name,l),a[h]=getLabelName("account",s.source_name,l),c=h+"-"+d+"-"+l,e.hasOwnProperty(c)||(e[c]={from:h,to:d,amount:0}),e[c].amount+=u,c=d+"-"+translations.all_money+"-"+l,e.hasOwnProperty(c)||(e[c]={from:d,to:translations.all_money+(this.autoConversion?" ("+l+")":""),amount:0}),e[c].amount+=u}if(s.type==="withdrawal"){let d=getObjectName("budget",s.budget_name,"out",l);a[d]=getLabelName("budget",s.budget_name,l),c=translations.all_money+"-"+d+"-"+l,e.hasOwnProperty(c)||(e[c]={from:translations.all_money+" ("+l+")",to:d,amount:0}),e[c].amount+=u;let h=getObjectName("category",s.category_name,"out",l);a[h]=getLabelName("category",s.category_name,l),c=d+"-"+h+"-"+l,e.hasOwnProperty(c)||(e[c]={from:d,to:h,amount:0}),e[c].amount+=u;let m=getObjectName("account",s.destination_name,"out",l);a[m]=getLabelName("account",s.destination_name,l),c=h+"-"+m+"-"+l,e.hasOwnProperty(c)||(e[c]={from:h,to:m,amount:0}),e[c].amount+=u}}}let n={label:"Firefly III dashboard sankey chart",data:[],colorFrom:r=>getColor(r.dataset.data[r.dataIndex].from),colorTo:r=>getColor(r.dataset.data[r.dataIndex].to),colorMode:"gradient",labels:a,size:"min"};for(let r in e)if(e.hasOwnProperty(r)){let i=e[r];n.data.push({from:i.from,to:i.to,flow:i.amount})}return t.data.datasets.push(n),t},drawChart(t){if(chart$1!==null){chart$1.data.datasets=t.data.datasets,chart$1.update();return}chart$1=new Chart(document.querySelector("#sankey-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$2);if(t&&typeof e<"u"){transactions=e,this.drawChart(this.generateOptions()),this.loading=!1;return}let a={start:window.store.get("start").slice(0,10),end:window.store.get("end").slice(0,10),type:"withdrawal,deposit",page:1};this.downloadTransactions(a)},downloadTransactions(t){new Get$2().get(t).then(a=>{if(transactions=[...transactions,...a.data.data],parseInt(a.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadTransactions(t);return}window.store.set(CACHE_KEY$2,transactions),this.drawChart(this.generateOptions()),this.loading=!1})},loadChart(){if(this.loading!==!0){if(this.loading=!0,transactions.length!==0){this.drawChart(this.generateOptions()),this.loading=!1;return}this.getFreshData()}},init(){transactions=[],Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{this.autoConversion=t[0],autoConversion=t[0],i18n$2=new I18n,i18n$2.locale=t[1],loadTranslations(i18n$2,t[1]).then(()=>{translations.all_money=i18n$2.t("firefly.all_money"),translations.category=i18n$2.t("firefly.category"),translations.in=i18n$2.t("firefly.money_flowing_in"),translations.out=i18n$2.t("firefly.money_flowing_out"),translations.unknown_category=i18n$2.t("firefly.unknown_category_plain"),translations.unknown_source=i18n$2.t("firefly.unknown_source_plain"),translations.unknown_dest=i18n$2.t("firefly.unknown_dest_plain"),translations.unknown_account=i18n$2.t("firefly.unknown_any_plain"),translations.unknown_budget=i18n$2.t("firefly.unknown_budget_plain"),translations.expense_account=i18n$2.t("firefly.expense_account"),translations.revenue_account=i18n$2.t("firefly.revenue_account"),translations.budget=i18n$2.t("firefly.budget"),afterPromises$2=!0,this.loadChart()})}),window.store.observe("end",()=>{afterPromises$2&&(this.transactions=[],this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$2&&(this.autoConversion=t,this.loadChart())})}});let Get$1=class{get(e){return api.get("/api/v2/subscriptions",{params:e})}paid(e){return api.get("/api/v2/subscriptions/sum/paid",{params:e})}unpaid(e){return api.get("/api/v2/subscriptions/sum/unpaid",{params:e})}};const CACHE_KEY$1="dashboard-subscriptions-data";let chart=null,afterPromises$1=!1,i18n$1;const subscriptions=()=>({loading:!1,autoConversion:!1,loadChart(){this.loading!==!0&&(this.loading=!0,this.getFreshData())},drawChart(t){if(chart!==null){chart.data.datasets=t.data.datasets,chart.update();return}chart=new Chart(document.querySelector("#subscriptions-chart"),t)},getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY$1);if(t&&typeof e<"u"){this.drawChart(this.generateOptions(e)),this.loading=!1;return}const a=new Get$1;let n={start:format$1(new Date(window.store.get("start")),"y-MM-dd"),end:format$1(new Date(window.store.get("end")),"y-MM-dd")};a.paid(n).then(r=>{let i=r.data;a.unpaid(n).then(o=>{let s=o.data,l={paid:i,unpaid:s};window.store.set(CACHE_KEY$1,l),this.drawChart(this.generateOptions(l)),this.loading=!1})})},generateOptions(t){let e=getDefaultChartSettings("pie");e.data.labels=[i18n$1.t("firefly.paid"),i18n$1.t("firefly.unpaid")],e.data.datasets=[];let a={};for(let n in t.paid)if(t.paid.hasOwnProperty(n)){let r=t.paid[n],i=this.autoConversion?r.native_code:r.currency_code,o=this.autoConversion?r.native_sum:r.sum;a.hasOwnProperty(i)||(a[i]={paid:0,unpaid:0}),a[i].paid+=parseFloat(o)*-1}for(let n in t.unpaid)if(t.unpaid.hasOwnProperty(n)){let r=t.unpaid[n],i=this.autoConversion?r.native_code:r.currency_code,o=this.autoConversion?r.native_sum:r.sum;a.hasOwnProperty(i)||(a[i]={paid:0,unpaid:0}),a[i].unpaid+=parseFloat(o)}for(let n in a)if(a.hasOwnProperty(n)){let r=a[n];e.data.datasets.push({label:n,data:[r.paid,r.unpaid],backgroundColor:["rgb(54, 162, 235)","rgb(255, 99, 132)"]})}return e},init(){Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{this.autoConversion=t[0],afterPromises$1=!0,i18n$1=new I18n,i18n$1.locale=t[1],loadTranslations(i18n$1,t[1]).then(()=>{this.loading===!1&&this.loadChart()})}),window.store.observe("end",()=>{afterPromises$1&&this.loading===!1&&(this.chartData=null,this.loadChart())}),window.store.observe("autoConversion",t=>{afterPromises$1&&(this.autoConversion=t,this.loading===!1&&this.loadChart())})}});class Get{get(e){return api.get("/api/v2/piggy-banks",{params:e})}}let apiData={},afterPromises=!1,i18n;const CACHE_KEY="dashboard-piggies-data",piggies=()=>({loading:!1,autoConversion:!1,sankeyGrouping:"account",piggies:[],getFreshData(){const t=window.store.get("cacheValid");let e=window.store.get(CACHE_KEY);if(t&&typeof e<"u"){apiData=e,this.parsePiggies(),this.loading=!1;return}let a={start:window.store.get("start").slice(0,10),end:window.store.get("end").slice(0,10),page:1};this.downloadPiggyBanks(a)},downloadPiggyBanks(t){new Get().get(t).then(a=>{if(apiData=[...apiData,...a.data.data],parseInt(a.data.meta.pagination.total_pages)>t.page){t.page++,this.downloadPiggyBanks(t);return}window.store.set(CACHE_KEY,apiData),this.parsePiggies(),this.loading=!1})},parsePiggies(){let t=[];for(let e in apiData)if(apiData.hasOwnProperty(e)){let a=apiData[e];if(a.attributes.percentage>=100||a.attributes.percentage===0)continue;let n=a.object_group_title??i18n.t("firefly.default_group_title_name_plain");t.hasOwnProperty(n)||(t[n]={id:a.object_group_id??0,title:n,order:a.object_group_order??0,piggies:[]});let r={id:a.id,name:a.attributes.name,percentage:parseInt(a.attributes.percentage),amount:this.autoConversion?a.attributes.native_current_amount:a.attributes.current_amount,left_to_save:this.autoConversion?a.attributes.native_left_to_save:a.attributes.left_to_save,target_amount:this.autoConversion?a.attributes.native_target_amount:a.attributes.target_amount,save_per_month:this.autoConversion?a.attributes.native_save_per_month:a.attributes.save_per_month,currency_code:this.autoConversion?a.attributes.native_code:a.attributes.currency_code};t[n].piggies.push(r)}this.piggies=Object.values(t)},loadPiggyBanks(){if(this.loading!==!0){if(this.loading=!0,this.piggies.length!==0){this.parsePiggies(),this.loading=!1;return}this.getFreshData()}},init(){apiData=[],Promise.all([getVariable("autoConversion",!1),getVariable("language","en-US")]).then(t=>{i18n=new I18n,i18n.locale=t[1],loadTranslations(i18n,t[1]).then(()=>{afterPromises=!0,this.autoConversion=t[0],this.loadPiggyBanks()})}),window.store.observe("end",()=>{afterPromises&&(apiData=[],this.loadPiggyBanks())}),window.store.observe("autoConversion",t=>{afterPromises&&(this.autoConversion=t,this.loadPiggyBanks())})}});/*! * chartjs-adapter-date-fns v3.0.0 * https://www.chartjs.org * (c) 2022 chartjs-adapter-date-fns Contributors * Released under the MIT license - */const FORMATS={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};adapters._date.override({_id:"date-fns",formats:function(){return FORMATS},parse:function(t,e){if(t===null||typeof t>"u")return null;const a=typeof t;return a==="number"||t instanceof Date?t=toDate(t):a==="string"&&(typeof e=="string"?t=parse$1(t,e,new Date,this.options):t=parseISO(t,this.options)),isValid(t)?t.getTime():null},format:function(t,e){return format$1(t,e,this.options)},add:function(t,e,a){switch(a){case"millisecond":return addMilliseconds(t,e);case"second":return addSeconds(t,e);case"minute":return addMinutes(t,e);case"hour":return addHours(t,e);case"day":return addDays(t,e);case"week":return addWeeks(t,e);case"month":return addMonths(t,e);case"quarter":return addQuarters(t,e);case"year":return addYears(t,e);default:return t}},diff:function(t,e,a){switch(a){case"millisecond":return differenceInMilliseconds(t,e);case"second":return differenceInSeconds(t,e);case"minute":return differenceInMinutes(t,e);case"hour":return differenceInHours(t,e);case"day":return differenceInDays(t,e);case"week":return differenceInWeeks(t,e);case"month":return differenceInMonths(t,e);case"quarter":return differenceInQuarters(t,e);case"year":return differenceInYears(t,e);default:return 0}},startOf:function(t,e,a){switch(e){case"second":return startOfSecond(t);case"minute":return startOfMinute(t);case"hour":return startOfHour(t);case"day":return startOfDay(t);case"week":return startOfWeek(t);case"isoWeek":return startOfWeek(t,{weekStartsOn:+a});case"month":return startOfMonth(t);case"quarter":return startOfQuarter(t);case"year":return startOfYear(t);default:return t}},endOf:function(t,e){switch(e){case"second":return endOfSecond(t);case"minute":return endOfMinute(t);case"hour":return endOfHour(t);case"day":return endOfDay(t);case"week":return endOfWeek(t);case"month":return endOfMonth(t);case"quarter":return endOfQuarter(t);case"year":return endOfYear(t);default:return t}}});Chart.register({LineController,LineElement,ArcElement,BarController,TimeScale,PieController,BarElement,Filler:index,Colors:plugin_colors,LinearScale,CategoryScale,PointElement,Tooltip:plugin_tooltip,Legend:plugin_legend});const comps={dates,boxes,accounts,budgets,categories,sankey,subscriptions,piggies};function loadPage(t){Object.keys(t).forEach(e=>{console.log(`Loading page component "${e}"`);let a=t[e]();Alpine.data(e,()=>a)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{loadPage(comps)});window.bootstrapped&&loadPage(comps); + */const FORMATS={datetime:"MMM d, yyyy, h:mm:ss aaaa",millisecond:"h:mm:ss.SSS aaaa",second:"h:mm:ss aaaa",minute:"h:mm aaaa",hour:"ha",day:"MMM d",week:"PP",month:"MMM yyyy",quarter:"qqq - yyyy",year:"yyyy"};adapters._date.override({_id:"date-fns",formats:function(){return FORMATS},parse:function(t,e){if(t===null||typeof t>"u")return null;const a=typeof t;return a==="number"||t instanceof Date?t=toDate(t):a==="string"&&(typeof e=="string"?t=parse$1(t,e,new Date,this.options):t=parseISO(t,this.options)),isValid(t)?t.getTime():null},format:function(t,e){return format$1(t,e,this.options)},add:function(t,e,a){switch(a){case"millisecond":return addMilliseconds(t,e);case"second":return addSeconds(t,e);case"minute":return addMinutes(t,e);case"hour":return addHours(t,e);case"day":return addDays(t,e);case"week":return addWeeks(t,e);case"month":return addMonths(t,e);case"quarter":return addQuarters(t,e);case"year":return addYears(t,e);default:return t}},diff:function(t,e,a){switch(a){case"millisecond":return differenceInMilliseconds(t,e);case"second":return differenceInSeconds(t,e);case"minute":return differenceInMinutes(t,e);case"hour":return differenceInHours(t,e);case"day":return differenceInDays(t,e);case"week":return differenceInWeeks(t,e);case"month":return differenceInMonths(t,e);case"quarter":return differenceInQuarters(t,e);case"year":return differenceInYears(t,e);default:return 0}},startOf:function(t,e,a){switch(e){case"second":return startOfSecond(t);case"minute":return startOfMinute(t);case"hour":return startOfHour(t);case"day":return startOfDay(t);case"week":return startOfWeek(t);case"isoWeek":return startOfWeek(t,{weekStartsOn:+a});case"month":return startOfMonth(t);case"quarter":return startOfQuarter(t);case"year":return startOfYear(t);default:return t}},endOf:function(t,e){switch(e){case"second":return endOfSecond(t);case"minute":return endOfMinute(t);case"hour":return endOfHour(t);case"day":return endOfDay(t);case"week":return endOfWeek(t);case"month":return endOfMonth(t);case"quarter":return endOfQuarter(t);case"year":return endOfYear(t);default:return t}}});Chart.register({LineController,LineElement,ArcElement,BarController,TimeScale,PieController,BarElement,Filler:index$1,Colors:plugin_colors,LinearScale,CategoryScale,PointElement,Tooltip:plugin_tooltip,Legend:plugin_legend});const comps={dates,boxes,accounts,budgets,categories,sankey,subscriptions,piggies};function loadPage(t){Object.keys(t).forEach(e=>{console.log(`Loading page component "${e}"`);let a=t[e]();Alpine.data(e,()=>a)}),Alpine.start()}document.addEventListener("firefly-iii-bootstrapped",()=>{loadPage(comps)});window.bootstrapped&&loadPage(comps); diff --git a/public/build/manifest.json b/public/build/manifest.json index 09874aebc2..49d1dd87de 100644 --- a/public/build/manifest.json +++ b/public/build/manifest.json @@ -30,10 +30,10 @@ "integrity": "sha384-B73JAwYNSgI4rwb14zwxigHgAkg1Ms+j6+9sJoDpiL11+VW5RjQCLfIh0RVoi0h6" }, "resources/assets/v2/pages/dashboard/dashboard.js": { - "file": "assets/dashboard-7d4913ce.js", + "file": "assets/dashboard-767a50a1.js", "isEntry": true, "src": "resources/assets/v2/pages/dashboard/dashboard.js", - "integrity": "sha384-D/XG0fkIuVUkCWnAa6ylWQBCrMwuNJAeD65RK/ZFXnpkJvwmd9zn3IxTlqS/RyE8" + "integrity": "sha384-IHFHBTu2Ag0GEIYzgrhY5c1H/PQHLghtTMCJBvV4HjiQHVJ+Al1FSRX3Ro92N3NT" }, "resources/assets/v2/sass/app.scss": { "file": "assets/app-28a195fd.css", diff --git a/resources/assets/v2/pages/dashboard/accounts.js b/resources/assets/v2/pages/dashboard/accounts.js index 7d23852773..dcb66c99f2 100644 --- a/resources/assets/v2/pages/dashboard/accounts.js +++ b/resources/assets/v2/pages/dashboard/accounts.js @@ -25,6 +25,7 @@ import formatMoney from "../../util/format-money.js"; import Get from "../../api/v2/model/account/get.js"; import {Chart} from 'chart.js'; import {getDefaultChartSettings} from "../../support/default-chart-settings.js"; +import {getColors} from "../../support/get-colors.js"; // this is very ugly, but I have no better ideas at the moment to save the currency info // for each series. @@ -50,8 +51,7 @@ export default () => ({ let cachedData = window.store.get(CHART_CACHE_KEY); if (cacheValid && typeof cachedData !== 'undefined') { - let options = window.store.get(CHART_CACHE_KEY); - this.drawChart(options); + this.drawChart(this.generateOptions(cachedData)); this.loading = false; return; } @@ -59,9 +59,8 @@ export default () => ({ dashboard.dashboard(new Date(window.store.get('start')), new Date(window.store.get('end')), null).then((response) => { this.chartData = response.data; // cache generated options: - let options = this.generateOptions(this.chartData); - window.store.set(CHART_CACHE_KEY, options); - this.drawChart(options); + window.store.set(CHART_CACHE_KEY, response.data); + this.drawChart(this.generateOptions(this.chartData)); this.loading = false; }); @@ -99,6 +98,10 @@ export default () => ({ dataset.yAxisID = yAxis; dataset.data = collection; + // add colors: + //dataset.backgroundColor = getColors(null, 'background'); + //dataset.borderColor = getColors(null, 'background'); + // add data set to the correct Y Axis: options.data.datasets.push(dataset); diff --git a/resources/assets/v2/pages/dashboard/budgets.js b/resources/assets/v2/pages/dashboard/budgets.js index a9223afe7d..f8696eea3a 100644 --- a/resources/assets/v2/pages/dashboard/budgets.js +++ b/resources/assets/v2/pages/dashboard/budgets.js @@ -24,6 +24,7 @@ import formatMoney from "../../util/format-money.js"; import {Chart} from 'chart.js'; import {I18n} from "i18n-js"; import {loadTranslations} from "../../support/load-translations.js"; +import {getColors} from "../../support/get-colors.js"; let currencies = []; let chart = null; @@ -105,18 +106,24 @@ export default () => ({ data: [], borderWidth: 1, stack: 1, + backgroundColor: getColors('spent', 'background'), + borderColor: getColors('spent', 'border'), }, { label: i18n.t('firefly.left'), data: [], borderWidth: 1, stack: 1, + backgroundColor: getColors('left', 'background'), + borderColor: getColors('left', 'border'), }, { label: i18n.t('firefly.overspent'), data: [], borderWidth: 1, stack: 1, + backgroundColor: getColors('overspent', 'background'), + borderColor: getColors('overspent', 'border'), } ] }; diff --git a/resources/assets/v2/pages/dashboard/categories.js b/resources/assets/v2/pages/dashboard/categories.js index 6768797358..d88e6babf1 100644 --- a/resources/assets/v2/pages/dashboard/categories.js +++ b/resources/assets/v2/pages/dashboard/categories.js @@ -22,6 +22,7 @@ import Dashboard from "../../api/v2/chart/category/dashboard.js"; import {getDefaultChartSettings} from "../../support/default-chart-settings.js"; import {Chart} from "chart.js"; import formatMoney from "../../util/format-money.js"; +import {getColors} from "../../support/get-colors.js"; let currencies = []; let chart = null; @@ -104,12 +105,15 @@ export default () => ({ // loop the series and create ChartJS-compatible data sets. let count = 0; for (const i in series) { + console.log('series'); let yAxisID = 'y' + i; let dataset = { label: i, currency_code: i, yAxisID: yAxisID, data: [], + // backgroundColor: getColors(null, 'background'), + // borderColor: getColors(null, 'border'), } for (const ii in series[i].data) { dataset.data.push(series[i].data[ii]); diff --git a/resources/assets/v2/pages/dashboard/sankey.js b/resources/assets/v2/pages/dashboard/sankey.js index 3b66fc4f4b..76c2d2615c 100644 --- a/resources/assets/v2/pages/dashboard/sankey.js +++ b/resources/assets/v2/pages/dashboard/sankey.js @@ -33,6 +33,7 @@ let currencies = []; let afterPromises = false; let chart = null; let transactions = []; +let autoConversion = false; let translations = { category: null, unknown_category: null, @@ -82,37 +83,37 @@ function getObjectName(type, name, direction, code) { // category 4x if ('category' === type && null !== name && 'in' === direction) { - return translations.category + ' "' + name + '" (' + translations.in + ', ' + code + ')'; + return translations.category + ' "' + name + '" (' + translations.in + (autoConversion ? ', ' + code + ')' : ')'); } if ('category' === type && null === name && 'in' === direction) { - return translations.unknown_category + ' (' + translations.in + ', ' + code + ')'; + return translations.unknown_category + ' (' + translations.in + (autoConversion ? ', ' + code + ')' : ')'); } if ('category' === type && null !== name && 'out' === direction) { - return translations.category + ' "' + name + '" (' + translations.out + ', ' + code + ')'; + return translations.category + ' "' + name + '" (' + translations.out + (autoConversion ? ', ' + code + ')' : ')'); } if ('category' === type && null === name && 'out' === direction) { - return translations.unknown_category + ' (' + translations.out + ', ' + code + ')'; + return translations.unknown_category + ' (' + translations.out + (autoConversion ? ', ' + code + ')' : ')'); } // account 4x if ('account' === type && null === name && 'in' === direction) { - return translations.unknown_source + ' (' + code + ')'; + return translations.unknown_source + (autoConversion ? ' (' + code + ')' : ''); } if ('account' === type && null !== name && 'in' === direction) { - return translations.revenue_account + '"' + name + '" (' + code + ')'; + return translations.revenue_account + '"' + name + '"' + (autoConversion ? ' (' + code + ')' : ''); } if ('account' === type && null === name && 'out' === direction) { - return translations.unknown_dest + ' (' + code + ')'; + return translations.unknown_dest + (autoConversion ? ' (' + code + ')' : ''); } if ('account' === type && null !== name && 'out' === direction) { - return translations.expense_account + ' "' + name + '" (' + code + ')'; + return translations.expense_account + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : ''); } // budget 2x if ('budget' === type && null !== name) { - return translations.budget + ' "' + name + '" (' + code + ')'; + return translations.budget + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : ''); } if ('budget' === type && null === name) { - return translations.unknown_budget + ' (' + code + ')'; + return translations.unknown_budget + (autoConversion ? ' (' + code + ')' : ''); } console.error('Cannot handle: type:"' + type + '", dir: "' + direction + '"'); } @@ -120,25 +121,25 @@ function getObjectName(type, name, direction, code) { function getLabelName(type, name, code) { // category if ('category' === type && null !== name) { - return translations.category + ' "' + name + '" (' + code + ')'; + return translations.category + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : ''); } if ('category' === type && null === name) { - return translations.unknown_category + ' (' + code + ')'; + return translations.unknown_category + (autoConversion ? ' (' + code + ')' : ''); } // account if ('account' === type && null === name) { - return translations.unknown_account + ' (' + code + ')'; + return translations.unknown_account + (autoConversion ? ' (' + code + ')' : ''); } if ('account' === type && null !== name) { - return name + ' (' + code + ')'; + return name + (autoConversion ? ' (' + code + ')' : ''); } // budget 2x if ('budget' === type && null !== name) { - return translations.budget + ' "' + name + '" (' + code + ')'; + return translations.budget + ' "' + name + '"' + (autoConversion ? ' (' + code + ')' : ''); } if ('budget' === type && null === name) { - return translations.unknown_budget + ' (' + code + ')'; + return translations.unknown_budget + (autoConversion ? ' (' + code + ')' : ''); } console.error('Cannot handle: type:"' + type + '"'); } @@ -193,7 +194,7 @@ export default () => ({ if (!amounts.hasOwnProperty(flowKey)) { amounts[flowKey] = { from: category, - to: translations.all_money + ' (' + currencyCode + ')', + to: translations.all_money + (this.autoConversion ? ' (' + currencyCode + ')' : ''), amount: 0 }; } @@ -340,7 +341,8 @@ export default () => ({ // console.log('sankey init'); transactions = []; Promise.all([getVariable('autoConversion', false), getVariable('language', 'en-US')]).then((values) => { - + this.autoConversion = values[0]; + autoConversion = values[0]; i18n = new I18n(); i18n.locale = values[1]; loadTranslations(i18n, values[1]).then(() => { @@ -360,7 +362,6 @@ export default () => ({ // console.log('sankey after promises'); afterPromises = true; - this.autoConversion = values[0]; this.loadChart(); }); diff --git a/resources/assets/v2/support/get-colors.js b/resources/assets/v2/support/get-colors.js index 7644d11e29..7c6d0eacaf 100644 --- a/resources/assets/v2/support/get-colors.js +++ b/resources/assets/v2/support/get-colors.js @@ -23,71 +23,86 @@ import {Color} from '@kurkle/color'; -// base colors for most things -let red = new Color('#dc3545'); // same as bootstrap danger -let green = new Color('#198754'); // same as bootstrap success. -let blue = new Color('#0d6efd'); // bootstrap blue. - // four other colors: -let orange = new Color('#fd7e14'); // bootstrap orange. +// base colors for most things (BORDER) +let blue = new Color('#36a2eb'); +let red = new Color('#ff6384'); +let green = new Color('#4bc0c0'); + +// four other colors +let orange = new Color('#ff9f40'); +let purple = new Color('#9966ff'); +let yellow = new Color('#ffcd56'); +let grey = new Color('#c9cbcf'); let index = 0; // or cycle through X colors: if ('light' === window.theme) { - red.lighten(0.3).clearer(0.3); - green.lighten(0.3).clearer(0.3); - blue.lighten(0.3).clearer(0.3); - orange.lighten(0.3).clearer(0.3); + // red.lighten(0.3).clearer(0.3); + // green.lighten(0.3).clearer(0.3); + // blue.lighten(0.3).clearer(0.3); + // orange.lighten(0.3).clearer(0.3); +} +if ('dark' === window.theme) { + red.darken(0.3).desaturate(0.3); + green.darken(0.3).desaturate(0.3); + blue.darken(0.3).desaturate(0.3); + orange.darken(0.3).desaturate(0.3); + } - -let allColors = [red, green, blue, orange]; +let allColors = [red, orange, blue, green, purple, yellow, grey, green]; function getColors(type, field) { - index++; let colors = { borderColor: red.rgbString(), backgroundColor: red.rgbString(), }; - let border; + let background; switch (type) { default: - let currentIndex = (Math.ceil(index / 2) % allColors.length) - 1; - border = new Color(allColors[currentIndex].rgbString()); - border.darken(0.4); + let correctedIndex = Math.floor(index / 2); + let currentIndex = correctedIndex % allColors.length; + //console.log('index:' + index + ', correctedIndex:' + correctedIndex + ', currentIndex:' + currentIndex); + background = new Color(allColors[currentIndex].rgbString()); + background.lighten(0.38); + colors = { - borderColor: border.rgbString(), - backgroundColor: allColors[currentIndex].rgbString(), + borderColor: allColors[currentIndex].hexString(), + backgroundColor: background.hexString(), }; break; case 'spent': - border = new Color(blue.rgbString()); - border.darken(0.4); + background = new Color(blue.rgbString()); + background.lighten(0.38); + //console.log('#9ad0f5 vs ' + background.hexString()); colors = { - borderColor: border.rgbString(), - backgroundColor: blue.rgbString(), + borderColor: blue.rgbString(), + backgroundColor: background.rgbString(), }; break; case 'left': - border = new Color(green.rgbString()); - border.darken(0.4); + background = new Color(green.rgbString()); + background.lighten(0.38); colors = { - borderColor: border.rgbString(), - backgroundColor: green.rgbString(), + borderColor: green.rgbString(), + backgroundColor: background.rgbString(), }; break; case 'overspent': - border = new Color(red.rgbString()); - border.darken(0.4); + background = new Color(red.rgbString()); + background.lighten(0.22); + console.log('#ffb1c1 vs ' + background.hexString()); colors = { - borderColor: border.rgbString(), - backgroundColor: red.rgbString(), + borderColor: red.rgbString(), + backgroundColor: background.rgbString(), }; break; } + index++; if ('border' === field) { return colors.borderColor;