/*
 Highstock JS v10.3.1 (2022-10-31)

 Data grouping module

 (c) 2010-2021 Torstein Hnsi

 License: www.highcharts.com/license
*/
(function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/modules/datagrouping",["highcharts"],function(g){a(g);a.Highcharts=g;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function g(a,b,h,q){a.hasOwnProperty(b)||(a[b]=q.apply(null,h),"function"===typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:b,module:a[b]}})))}a=a?a._modules:{};
g(a,"Extensions/DataGrouping/ApproximationRegistry.js",[],function(){return{}});g(a,"Extensions/DataGrouping/ApproximationDefaults.js",[a["Extensions/DataGrouping/ApproximationRegistry.js"],a["Core/Utilities.js"]],function(a,b){function h(c){var a=c.length;c=q(c);k(c)&&a&&(c=g(c/a));return c}function q(a){var c=a.length;if(!c&&a.hasNulls)var b=null;else if(c)for(b=0;c--;)b+=a[c];return b}var d=b.arrayMax,l=b.arrayMin,g=b.correctFloat,G=b.extend,k=b.isNumber;b={average:h,averages:function(){var a=
[];[].forEach.call(arguments,function(c){a.push(h(c))});return"undefined"===typeof a[0]?void 0:a},close:function(a){return a.length?a[a.length-1]:a.hasNulls?null:void 0},high:function(a){return a.length?d(a):a.hasNulls?null:void 0},hlc:function(c,b,e){c=a.high(c);b=a.low(b);e=a.close(e);if(k(c)||k(b)||k(e))return[c,b,e]},low:function(a){return a.length?l(a):a.hasNulls?null:void 0},ohlc:function(c,b,e,u){c=a.open(c);b=a.high(b);e=a.low(e);u=a.close(u);if(k(c)||k(b)||k(e)||k(u))return[c,b,e,u]},open:function(a){return a.length?
a[0]:a.hasNulls?null:void 0},range:function(b,d){b=a.low(b);d=a.high(d);if(k(b)||k(d))return[b,d];if(null===b&&null===d)return null},sum:q};G(a,b);return b});g(a,"Extensions/DataGrouping/DataGroupingDefaults.js",[],function(){return{common:{groupPixelWidth:2,dateTimeLabelFormats:{millisecond:["%A, %b %e, %H:%M:%S.%L","%A, %b %e, %H:%M:%S.%L","-%H:%M:%S.%L"],second:["%A, %b %e, %H:%M:%S","%A, %b %e, %H:%M:%S","-%H:%M:%S"],minute:["%A, %b %e, %H:%M","%A, %b %e, %H:%M","-%H:%M"],hour:["%A, %b %e, %H:%M",
"%A, %b %e, %H:%M","-%H:%M"],day:["%A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],week:["Week from %A, %b %e, %Y","%A, %b %e","-%A, %b %e, %Y"],month:["%B %Y","%B","-%B %Y"],year:["%Y","%Y","-%Y"]}},seriesSpecific:{line:{},spline:{},area:{},areaspline:{},arearange:{},column:{groupPixelWidth:10},columnrange:{groupPixelWidth:10},candlestick:{groupPixelWidth:10},ohlc:{groupPixelWidth:5},hlc:{groupPixelWidth:5},heikinashi:{groupPixelWidth:10}},units:[["millisecond",[1,2,5,10,20,25,50,100,200,500]],["second",
[1,2,5,10,15,30]],["minute",[1,2,5,10,15,30]],["hour",[1,2,3,4,6,8,12]],["day",[1]],["week",[1]],["month",[1,3,6]],["year",null]]}});g(a,"Extensions/DataGrouping/DataGroupingAxisComposition.js",[a["Extensions/DataGrouping/DataGroupingDefaults.js"],a["Core/Utilities.js"]],function(a,b){function d(a){var b=this,u=b.series;u.forEach(function(a){a.groupPixelWidth=void 0});u.forEach(function(u){u.groupPixelWidth=b.getGroupPixelWidth&&b.getGroupPixelWidth();u.groupPixelWidth&&(u.hasProcessed=!0);u.applyGrouping(!!a.hasExtremesChanged)})}
function q(){for(var b=this.series,d=b.length,e=0,k=!1,g,r;d--;)if(r=b[d].options.dataGrouping)if(e=Math.max(e,c(r.groupPixelWidth,a.common.groupPixelWidth)),g=(b[d].processedXData||b[d].data).length,b[d].groupPixelWidth||g>this.chart.plotSizeX/e||g&&r.forced)k=!0;return k?e:0}function g(){this.series.forEach(function(a){a.hasProcessed=!1})}function l(a,b){var d;b=c(b,!0);a||(a={forced:!1,units:null});if(this instanceof e)for(d=this.series.length;d--;)this.series[d].update({dataGrouping:a},!1);else this.chart.options.series.forEach(function(b){b.dataGrouping=
"boolean"===typeof a?a:k(a,b.dataGrouping)});this.ordinal&&(this.ordinal.slope=void 0);b&&this.chart.redraw()}var K=b.addEvent,G=b.extend,k=b.merge,c=b.pick,p=[],e;return{compose:function(a){e=a;-1===p.indexOf(a)&&(p.push(a),K(a,"afterSetScale",g),K(a,"postProcessData",d),G(a.prototype,{applyGrouping:d,getGroupPixelWidth:q,setDataGrouping:l}))}}});g(a,"Extensions/DataGrouping/DataGroupingSeriesComposition.js",[a["Extensions/DataGrouping/ApproximationRegistry.js"],a["Extensions/DataGrouping/DataGroupingDefaults.js"],
a["Core/Axis/DateTimeAxis.js"],a["Core/Defaults.js"],a["Core/Series/SeriesRegistry.js"],a["Core/Utilities.js"]],function(a,b,g,q,D,l){function d(a){var c=this.chart,d=this.options.dataGrouping,e=!1!==this.allowDG&&d&&v(d.enabled,c.options.isStock),f=this.visible||!c.options.chart.ignoreHiddenSeries,A=this.currentDataGrouping,k=!1;e&&!this.requireSorting&&(this.requireSorting=k=!0);a=!1===!(this.isCartesian&&!this.isDirty&&!this.xAxis.isDirty&&!this.yAxis.isDirty&&!a)||!e;k&&(this.requireSorting=!1);
if(!a){this.destroyGroupedData();var y=d.groupAll?this.xData:this.processedXData,q=d.groupAll?this.yData:this.processedYData;e=c.plotSizeX;a=this.xAxis;var l=a.options.ordinal,h=this.groupPixelWidth;k=void 0;if(h&&y&&y.length){this.isDirty=k=!0;this.points=null;var m=a.getExtremes();var n=m.min;m=m.max;l=l&&a.ordinal&&a.ordinal.getGroupIntervalFactor(n,m,this)||1;e=a.getTimeTicks(g.Additions.prototype.normalizeTimeTickInterval(h*(m-n)/e*l,d.units||b.units),Math.min(n,y[0]),Math.max(m,y[y.length-1]),
a.options.startOfWeek,y,this.closestPointRange);h=u.groupData.apply(this,[y,q,e,d.approximation]);y=h.groupedXData;q=h.groupedYData;l=0;d&&d.smoothed&&y.length&&(d.firstAnchor="firstPoint",d.anchor="middle",d.lastAnchor="lastPoint",F(32,!1,c,{"dataGrouping.smoothed":"use dataGrouping.anchor"}));c=y;var E=this.options.dataGrouping;n=this.currentDataGrouping&&this.currentDataGrouping.gapSize;if(E&&this.xData&&n&&this.groupMap){var z=c.length-1;var x=E.anchor;var C=v(E.firstAnchor,x);E=v(E.lastAnchor,
x);if(x&&"start"!==x){var w=n*{middle:.5,end:1}[x];for(x=c.length-1;x--&&0<x;)c[x]+=w}if(C&&"start"!==C&&this.xData[0]>=c[0]){x=this.groupMap[0].start;w=this.groupMap[0].length;var p=void 0;r(x)&&r(w)&&(p=x+(w-1));c[0]={middle:c[0]+.5*n,end:c[0]+n,firstPoint:this.xData[0],lastPoint:p&&this.xData[p]}[C]}E&&"start"!==E&&n&&c[z]>=m-n&&(m=this.groupMap[this.groupMap.length-1].start,c[z]={middle:c[z]+.5*n,end:c[z]+n,firstPoint:m&&this.xData[m],lastPoint:this.xData[this.xData.length-1]}[E])}for(m=1;m<e.length;m++)e.info.segmentStarts&&
-1!==e.info.segmentStarts.indexOf(m)||(l=Math.max(e[m]-e[m-1],l));m=e.info;m.gapSize=l;this.closestPointRange=e.info.totalRange;this.groupMap=h.groupMap;if(f){f=y;if(H(f[0])&&r(a.min)&&r(a.dataMin)&&f[0]<a.min){if(!H(a.options.min)&&a.min<=a.dataMin||a.min===a.dataMin)a.min=Math.min(f[0],a.min);a.dataMin=Math.min(f[0],a.dataMin)}if(H(f[f.length-1])&&r(a.max)&&r(a.dataMax)&&f[f.length-1]>a.max){if(!H(a.options.max)&&r(a.dataMax)&&a.max>=a.dataMax||a.max===a.dataMax)a.max=Math.max(f[f.length-1],a.max);
a.dataMax=Math.max(f[f.length-1],a.dataMax)}}d.groupAll&&(this.allGroupedData=q,d=this.cropData(y,q,a.min,a.max,1),y=d.xData,q=d.yData,this.cropStart=d.start);this.processedXData=y;this.processedYData=q}else this.groupMap=null;this.hasGroupedData=k;this.currentDataGrouping=m;this.preventGraphAnimation=(A&&A.totalRange)!==(m&&m.totalRange)}}function h(){this.groupedData&&(this.groupedData.forEach(function(a,b){a&&(this.groupedData[b]=a.destroy?a.destroy():null)},this),this.groupedData.length=0)}function k(){L.apply(this);
this.destroyGroupedData();this.groupedData=this.hasGroupedData?this.points:null}function c(){return this.is("arearange")?"range":this.is("ohlc")?"ohlc":this.is("hlc")?"hlc":this.is("column")?"sum":"average"}function p(b,c,d,e){var f=this,k=f.data,q=f.options&&f.options.data,l=[],g=[],u=[],h=b.length,m=!!c,n=[],A=f.pointArrayMap,z=A&&A.length,x=["x"].concat(A||["y"]),w=this.options.dataGrouping&&this.options.dataGrouping.groupAll,C=0,p=0;e="function"===typeof e?e:e&&a[e]?a[e]:a[f.getDGApproximation&&
f.getDGApproximation()||"average"];if(z)for(var v=A.length;v--;)n.push([]);else n.push([]);v=z||1;for(var B=0;B<=h;B++)if(!(b[B]<d[0])){for(;"undefined"!==typeof d[C+1]&&b[B]>=d[C+1]||B===h;){var t=d[C];f.dataGroupInfo={start:w?p:f.cropStart+p,length:n[0].length};var F=e.apply(f,n);f.pointClass&&!H(f.dataGroupInfo.options)&&(f.dataGroupInfo.options=J(f.pointClass.prototype.optionsToObject.call({series:f},f.options.data[f.cropStart+p])),x.forEach(function(a){delete f.dataGroupInfo.options[a]}));"undefined"!==
typeof F&&(l.push(t),g.push(F),u.push(f.dataGroupInfo));p=B;for(t=0;t<v;t++)n[t].length=0,n[t].hasNulls=!1;C+=1;if(B===h)break}if(B===h)break;if(A){t=f.options.dataGrouping&&f.options.dataGrouping.groupAll?B:f.cropStart+B;F=k&&k[t]||f.pointClass.prototype.applyOptions.apply({series:f},[q[t]]);var I=void 0;for(t=0;t<z;t++)I=F[A[t]],r(I)?n[t].push(I):null===I&&(n[t].hasNulls=!0)}else t=m?c[B]:null,r(t)?n[0].push(t):null===t&&(n[0].hasNulls=!0)}return{groupedXData:l,groupedYData:g,groupMap:u}}function e(a){a=
a.options;var c=this.type,d=this.chart.options.plotOptions,e=this.useCommonDataGrouping&&b.common,f=b.seriesSpecific,k=q.defaultOptions.plotOptions[c].dataGrouping;if(d&&(f[c]||e)){var h=this.chart.rangeSelector;k||(k=J(b.common,f[c]));a.dataGrouping=J(e,k,d.series&&d.series.dataGrouping,d[c].dataGrouping,this.userOptions.dataGrouping,!a.isInternal&&h&&r(h.selected)&&h.buttonOptions[h.selected].dataGrouping)}}var u=D.series.prototype,z=l.addEvent,H=l.defined,F=l.error,C=l.extend,r=l.isNumber,J=l.merge,
v=l.pick,L=u.generatePoints,w=[];return{compose:function(a){var b=a.prototype.pointClass;-1===w.indexOf(b)&&(w.push(b),z(b,"update",function(){if(this.dataGroup)return F(24,!1,this.series.chart),!1}));-1===w.indexOf(a)&&(w.push(a),z(a,"afterSetOptions",e),z(a,"destroy",h),C(a.prototype,{applyGrouping:d,destroyGroupedData:h,generatePoints:k,getDGApproximation:c,groupData:p}))},groupData:p}});g(a,"Extensions/DataGrouping/DataGrouping.js",[a["Extensions/DataGrouping/DataGroupingAxisComposition.js"],
a["Extensions/DataGrouping/DataGroupingDefaults.js"],a["Extensions/DataGrouping/DataGroupingSeriesComposition.js"],a["Core/FormatUtilities.js"],a["Core/Utilities.js"]],function(a,b,h,g,D){function d(a){var d=this.chart,e=d.time,h=a.labelConfig,g=h.series,l=g.tooltipOptions,r=g.options.dataGrouping,p=g.xAxis,v=l.xDateFormat,D=l[a.isFooter?"footerFormat":"headerFormat"];if(p&&"datetime"===p.options.type&&r&&c(h.key)){var w=g.currentDataGrouping;r=r.dateTimeLabelFormats||b.common.dateTimeLabelFormats;
if(w)if(l=r[w.unitName],1===w.count)v=l[0];else{v=l[1];var A=l[2]}else!v&&r&&p.dateTime&&(v=p.dateTime.getXDateFormat(h.x,l.dateTimeLabelFormats));v=e.dateFormat(v,h.key);A&&(v+=e.dateFormat(A,h.key+w.totalRange-1));g.chart.styledMode&&(D=this.styledModeFormat(D));a.text=q(D,{point:k(h.point,{key:v}),series:g},d);a.preventDefault()}}var q=g.format,G=D.addEvent,k=D.extend,c=D.isNumber,p=[];g={compose:function(b,c,g){a.compose(b);h.compose(c);-1===p.indexOf(g)&&(p.push(g),G(g,"headerFormatter",d))},
groupData:h.groupData};"";"";return g});g(a,"masters/modules/datagrouping.src.js",[a["Core/Globals.js"],a["Extensions/DataGrouping/ApproximationDefaults.js"],a["Extensions/DataGrouping/ApproximationRegistry.js"],a["Extensions/DataGrouping/DataGrouping.js"]],function(a,b,g,q){a.dataGrouping={approximationDefaults:b,approximations:g};q.compose(a.Axis,a.Series,a.Tooltip)})});
//# sourceMappingURL=datagrouping.js.map