let t;/**
 * Highstock JS v12.6.0 (2026-04-13)
 * @module highcharts/modules/datagrouping
 * @requires highcharts
 *
 * Data grouping module
 *
 * (c) 2010-2026 Highsoft AS
 * Author: Torstein Hønsi
 *
 * A commercial license may be required depending on use.
 * See www.highcharts.com/license
 */import*as e from"../highcharts.js";var o,n={};n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var o in e)n.o(e,o)&&!n.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=e.default;var r=n.n(i);let a={},{doc:s,win:l}=r();function u(t,e,o,n={}){let i="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(i,"hcEvents")||(i.hcEvents={});let a=i.hcEvents;r().Point&&t instanceof r().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let s=t.addEventListener;s&&s.call(t,e,o,!!r().supportsPassiveEvents&&{passive:void 0===n.passive?-1!==e.indexOf("touch"):n.passive,capture:!1}),a[e]||(a[e]=[]);let l={fn:o,order:"number"==typeof n.order?n.order:1/0};return a[e].push(l),a[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,o){function n(e,o){let n=t.removeEventListener;n&&n.call(t,e,o,!1)}function i(o){let i,r;t.nodeName&&(e?(i={})[e]=!0:i=o,b(i,function(t,e){if(o[e])for(r=o[e].length;r--;)n(e,o[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];o?(t[e]=r.filter(function(t){return o!==t.fn}),n(e,o)):(i(t),t[e]=[])}else i(t),delete r.hcEvents}}(t,e,o)}}function h(t,e){return t>1e14?t:parseFloat(t.toPrecision(e||14))}function p(t){return null!=t}function c(t,e){let o;for(o in t||(t={}),e)t[o]=e[o];return t}function d(t,e,o,n){if(o=o||{},s?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==r())){let n=s.createEvent("Events");n.initEvent(e,!0,!0),o=c(n,o),t.dispatchEvent?t.dispatchEvent(o):t.fireEvent(e,o)}else if(t.hcEvents){o.target||c(o,{preventDefault:function(){o.defaultPrevented=!0},target:t,type:e});let n=[],i=t,r=!1;for(;i.hcEvents;)Object.hasOwnProperty.call(i,"hcEvents")&&i.hcEvents[e]&&(n.length&&(r=!0),n.unshift.apply(n,i.hcEvents[e])),i=Object.getPrototypeOf(i);r&&n.sort((t,e)=>t.order-e.order),n.forEach(e=>{!1===e.fn.call(t,o,t)&&o.preventDefault()})}n&&!o.defaultPrevented&&n.call(t,o)}function f(t){return Math.pow(10,Math.floor(Math.log(t)/Math.LN10))}function g(t){return v(t)&&"number"==typeof t.nodeType}function m(t){return"number"==typeof t&&!isNaN(t)&&t<1/0&&t>-1/0}function y(t){let e=Object.prototype.toString.call(t);return"[object Array]"===e||"[object Array Iterator]"===e}function v(t,e){return!!t&&"object"==typeof t&&(!e||!y(t))}function x(t,...e){let o,n=[t,...e],i={},r=function(t,e){return"object"!=typeof t&&(t={}),b(e,function(o,n){if("__proto__"!==n&&"constructor"!==n){let i;!v(o,!0)||(i=o?.constructor,v(o,!0)&&!g(o)&&i?.name&&"Object"!==i.name)||g(o)?t[n]=e[n]:t[n]=r(t[n]||{},o)}}),t};!0===t&&(i=n[1],n=Array.prototype.slice.call(n,2));let a=n.length;for(o=0;o<a;o++)i=r(i,n[o]);return i}function b(t,e,o){for(let n in t)Object.hasOwnProperty.call(t,n)&&e.call(o||t[n],t[n],n,t)}function M(){let t=arguments,e=t.length;for(let o=0;o<e;o++){let e=t[o];if(null!=e)return e}}function G(t){let e=t.length,o=P(t);return m(o)&&e&&(o=h(o/e)),o}function P(t){let e=t.length,o;if(!e&&t.hasNulls)o=null;else if(e)for(o=0;e--;)o+=t[e];return o}Array.prototype.find;let A={average:G,averages:function(){let t=[];return[].forEach.call(arguments,function(e){t.push(G(e))}),void 0===t[0]?void 0:t},close:function(t){return t.length?t[t.length-1]:t.hasNulls?null:void 0},high:function(t){return t.length?function(t){let e=t.length,o=t[0];for(;e--;)t[e]>o&&(o=t[e]);return o}(t):t.hasNulls?null:void 0},hlc:function(t,e,o){if(t=a.high(t),e=a.low(e),o=a.close(o),m(t)||m(e)||m(o))return[t,e,o]},low:function(t){return t.length?function(t){let e=t.length,o=t[0];for(;e--;)t[e]<o&&(o=t[e]);return o}(t):t.hasNulls?null:void 0},ohlc:function(t,e,o,n){if(t=a.open(t),e=a.high(e),o=a.low(o),n=a.close(n),m(t)||m(e)||m(o)||m(n))return[t,e,o,n]},open:function(t){return t.length?t[0]:t.hasNulls?null:void 0},range:function(t,e){return(t=a.low(t),e=a.high(e),m(t)||m(e))?[t,e]:null===t&&null===e?null:void 0},sum:P};c(a,A);let T={groupPixelWidth:2,dateTimeLabelFormats:{millisecond:["%[AebHMSL]","%[AebHMSL]","-%[HMSL]"],second:["%[AebHMS]","%[AebHMS]","-%[HMS]"],minute:["%[AebHM]","%[AebHM]","-%[HM]"],hour:["%[AebHM]","%[AebHM]","-%[HM]"],day:["%[AebY]","%[Aeb]","-%[AebY]"],week:["%v %[AebY]","%[Aeb]","-%[AebY]"],month:["%[BY]","%[B]","-%[BY]"],year:["%Y","%Y","-%Y"]}},w={line:{},spline:{},area:{},areaspline:{},arearange:{},column:{groupPixelWidth:10},columnrange:{groupPixelWidth:10},candlestick:{groupPixelWidth:10},ohlc:{groupPixelWidth:5},hlc:{groupPixelWidth:5},heikinashi:{groupPixelWidth:10}},D=[["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]];function C(t){let e=this,o=e.series;o.forEach(function(t){t.groupPixelWidth=void 0}),o.forEach(function(o){o.groupPixelWidth=e.getGroupPixelWidth&&e.getGroupPixelWidth(),o.groupPixelWidth&&(o.hasProcessed=!0),o.applyGrouping(!!t.hasExtremesChanged)})}function E(){let t=this.series,e=t.length,o=0,n=!1,i,r;for(;e--;)(r=t[e].options.dataGrouping)&&(o=Math.max(o,M(r.groupPixelWidth,T.groupPixelWidth)),i=(t[e].dataTable.getModified()||t[e].dataTable).rowCount,(t[e].groupPixelWidth||i>this.chart.plotSizeX/o||i&&r.forced)&&(n=!0));return n?o:0}function O(){this.series.forEach(function(t){t.hasProcessed=!1})}function S(e,o){let n;if(o=M(o,!0),e||(e={forced:!1,units:null}),this instanceof t)for(n=this.series.length;n--;)this.series[n].update({dataGrouping:e},!1);else this.chart.options.series.forEach(function(t){t.dataGrouping="boolean"==typeof e?e:x(e,t.dataGrouping)});this.ordinal&&(this.ordinal.slope=void 0),o&&this.chart.redraw()}let k=function(e){t=e;let o=e.prototype;o.applyGrouping||(u(e,"afterSetScale",O),u(e,"postProcessData",C),c(o,{applyGrouping:C,getGroupPixelWidth:E,setDataGrouping:S}))},{setLength:F,splice:N}={convertToNumber:function(t,e){switch(typeof t){case"boolean":return+!!t;case"number":return isNaN(t)&&!e?null:t;default:return isNaN(t=parseFloat(`${t??""}`))&&!e?null:t}},setLength:function(t,e,o){return Array.isArray(t)?(t.length=e,t):t[o?"subarray":"slice"](0,e)},splice:function(t,e,o,n,i=[]){if(Array.isArray(t))return Array.isArray(i)||(i=Array.from(i)),{removed:t.splice(e,o,...i),array:t};let r=Object.getPrototypeOf(t).constructor,a=t[n?"subarray":"slice"](e,e+o),s=new r(t.length-o+i.length);return s.set(t.subarray(0,e),0),s.set(i,e),s.set(t.subarray(e+o),e+i.length),{removed:a,array:s}}},j=class{constructor(t={}){this.autoId=!t.id,this.columns={},this.id=t.id||(0,i.uniqueKey)(),this.rowCount=0,this.versionTag=(0,i.uniqueKey)();let e=0;b(t.columns||{},(t,o)=>{this.columns[o]=t.slice(),e=Math.max(e,t.length)}),this.applyRowCount(e)}applyRowCount(t){this.rowCount=t,b(this.columns,(e,o)=>{e.length!==t&&(this.columns[o]=F(e,t))})}deleteRows(t,e=1){if(e>0&&t<this.rowCount){let o=0;b(this.columns,(n,i)=>{this.columns[i]=N(n,t,e).array,o=n.length}),this.rowCount=o}d(this,"afterDeleteRows",{rowIndex:t,rowCount:e}),this.versionTag=(0,i.uniqueKey)()}getColumn(t,e){return this.columns[t]}getColumns(t,e){return(t||Object.keys(this.columns)).reduce((t,e)=>(t[e]=this.columns[e],t),{})}getRow(t,e){return(e||Object.keys(this.columns)).map(e=>this.columns[e]?.[t])}setColumn(t,e=[],o=0,n){this.setColumns({[t]:e},o,n)}setColumns(t,e,o){let n=this.rowCount;b(t,(t,e)=>{this.columns[e]=t.slice(),n=t.length}),this.applyRowCount(n),o?.silent||(d(this,"afterSetColumns"),this.versionTag=(0,i.uniqueKey)())}setRow(t,e=this.rowCount,o,n){let{columns:r}=this,a=o?this.rowCount+1:e+1,s=Object.keys(t);if(n?.addColumns!==!1)for(let t=0,e=s.length;t<e;t++){let e=s[t];r[e]||(r[e]=[])}b(r,(i,s)=>{i||n?.addColumns===!1||(i=Array(a)),i&&(o?i=N(i,e,0,!0,[t[s]??null]).array:i[e]=t[s]??null,r[s]=i)}),a>this.rowCount&&this.applyRowCount(a),n?.silent||(d(this,"afterSetRows"),this.versionTag=(0,i.uniqueKey)())}getModified(){return this.modified||this}};!function(t){function e(){return this.chart.time.getTimeTicks.apply(this.chart.time,arguments)}function o(){if("datetime"!==this.type){this.dateTime=void 0;return}this.dateTime||(this.dateTime=new n(this))}t.compose=function(t){return t.keepProps.includes("dateTime")||(t.keepProps.push("dateTime"),t.prototype.getTimeTicks=e,u(t,"afterSetType",o)),t};class n{constructor(t){this.axis=t}normalizeTimeTickInterval(t,e){let o=e||[["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,2]],["week",[1,2]],["month",[1,2,3,4,6]],["year",null]],n=o[o.length-1],r=i.timeUnits[n[0]],a=n[1],s,l;for(s=0;s<o.length;s++)if(n=o[s],r=i.timeUnits[n[0]],a=n[1],o[s+1]){let e=(r*a[a.length-1]+i.timeUnits[o[s+1][0]])/2;if(t<=e){l=e/t;break}}r===i.timeUnits.year&&t<5*r&&(a=[1,2,5]);let u=function(t,e,o,n,i){let r,a=t;o=M(o,f(t));let s=t/o;for(e||(e=[1,2,2.5,5,10]),r=0;r<e.length&&(a=e[r],!(s<=(e[r]+(e[r+1]||e[r]))/2));r++);return h(a*o,-Math.round(Math.log(.001)/Math.LN10))}(t/r,a,"year"===n[0]?Math.max(f(t/r),1):1);return{unitRange:r,count:u,unitName:n[0],match:l}}getXDateFormat(t,e){let{axis:o}=this,n=o.chart.time;return o.closestPointRange?n.getDateFormat(o.closestPointRange,t,o.options.startOfWeek,e)||n.resolveDTLFormat(e.year).main:n.resolveDTLFormat(e.day).main}}t.Additions=n}(o||(o={}));let R=o,W=e.default.SeriesRegistry,{series:{prototype:L}}=n.n(W)(),H=L.generatePoints;function I(t){var e,o,n;let r,a,s=this.chart,l=this.options.dataGrouping,u=!1!==this.allowDG&&l&&M(l.enabled,s.options.isStock),h=this.reserveSpace(),c=this.currentDataGrouping,d,f,g=!1;u&&!this.requireSorting&&(this.requireSorting=g=!0);let y=!1==(e=this,o=t,!(e.isCartesian&&!e.isDirty&&!e.xAxis.isDirty&&!e.yAxis.isDirty&&!o))||!u;if(g&&(this.requireSorting=!1),y)return;this.destroyGroupedData();let v=l.groupAll?this.dataTable:this.dataTable.getModified()||this.dataTable,x=this.getColumn("x",!l.groupAll),b=s.plotSizeX,G=this.xAxis,P=G.getExtremes(),A=G.options.ordinal,T=this.groupPixelWidth;if(T&&x&&v.rowCount&&b&&m(P.min)){a=!0,this.isDirty=!0,this.points=null;let t=P.min,e=P.max,o=A&&G.ordinal&&G.ordinal.getGroupIntervalFactor(t,e,this)||1,u=T*(e-t)/b*o,c=G.getTimeTicks(R.Additions.prototype.normalizeTimeTickInterval(u,l.units||D),Math.min(t,x[0]),Math.max(e,x[x.length-1]),G.options.startOfWeek,x,this.closestPointRange),g=L.groupData.apply(this,[v,c,l.approximation]),y=g.modified,M=y.getColumn("x",!0),w=0;for(l?.smoothed&&y.rowCount&&(l.firstAnchor="firstPoint",l.anchor="middle",l.lastAnchor="lastPoint",(0,i.error)(32,!1,s,{"dataGrouping.smoothed":"use dataGrouping.anchor"})),r=1;r<c.length;r++)c.info.segmentStarts&&-1!==c.info.segmentStarts.indexOf(r)||(w=Math.max(c[r]-c[r-1],w));(d=c.info).gapSize=w,this.closestPointRange=c.info.totalRange,this.groupMap=g.groupMap,this.currentDataGrouping=d,function(t,e,o){let n=t.options.dataGrouping,i=t.currentDataGrouping&&t.currentDataGrouping.gapSize,r=t.getColumn("x");if(!(n&&r.length&&i&&t.groupMap))return;let a=e.length-1,s=n.anchor,l=n.firstAnchor,u=n.lastAnchor,h=e.length-1,p=0;if(l&&r[0]>=e[0]){let o;p++;let n=t.groupMap[0].start,a=t.groupMap[0].length;m(n)&&m(a)&&(o=n+(a-1)),e[0]=({start:e[0],middle:e[0]+.5*i,end:e[0]+i,firstPoint:r[0],lastPoint:o&&r[o]})[l]}if(a>0&&u&&i&&e[a]>=o-i){h--;let o=t.groupMap[t.groupMap.length-1].start;e[a]=({start:e[a],middle:e[a]+.5*i,end:e[a]+i,firstPoint:o&&r[o],lastPoint:r[r.length-1]})[u]}if(s&&"start"!==s){let t=i*({middle:.5,end:1})[s];for(;h>=p;)e[h]+=t,h--}}(this,M||[],e),h&&M&&(p((n=M)[0])&&m(G.min)&&m(G.dataMin)&&n[0]<G.min&&((!p(G.options.min)&&G.min<=G.dataMin||G.min===G.dataMin)&&(G.min=Math.min(n[0],G.min)),G.dataMin=Math.min(n[0],G.dataMin)),p(n[n.length-1])&&m(G.max)&&m(G.dataMax)&&n[n.length-1]>G.max&&((!p(G.options.max)&&m(G.dataMax)&&G.max>=G.dataMax||G.max===G.dataMax)&&(G.max=Math.max(n[n.length-1],G.max)),G.dataMax=Math.max(n[n.length-1],G.dataMax))),l.groupAll&&(this.allGroupedTable=y,M=(y=(f=this.cropData(y,G.min||0,G.max||0)).modified).getColumn("x"),this.cropStart=f.start),this.dataTable.modified=y}else this.groupMap=void 0,this.currentDataGrouping=void 0;this.hasGroupedData=a,this.preventGraphAnimation=(c&&c.totalRange)!==(d&&d.totalRange)}function Y(){this.groupedData&&(this.groupedData.forEach(function(t,e){t&&(this.groupedData[e]=t.destroy?t.destroy():null)},this),this.groupedData.length=0,delete this.allGroupedTable)}function q(){H.apply(this),this.destroyGroupedData(),this.groupedData=this.hasGroupedData?this.points:null}function _(){return this.is("arearange")?"range":this.is("ohlc")?"ohlc":this.is("hlc")?"hlc":this.is("column")||this.options.cumulative?"sum":"average"}function z(t,e,o){let n=t.getColumn("x",!0)||[],i=t.getColumn("y",!0),r=this,s=r.data,l=r.options&&r.options.data,u=[],h=new j,c=[],d=t.rowCount,f=!!i,g=[],v=r.pointArrayMap,b=v&&v.length,M=["x"].concat(v||["y"]),G=(v||["y"]).map(()=>[]),P=this.options.dataGrouping&&this.options.dataGrouping.groupAll,A,T,w,D=0,C=0,E="function"==typeof o?o:o&&a[o]?a[o]:a[r.getDGApproximation&&r.getDGApproximation()||"average"];if(b){let t=v.length;for(;t--;)g.push([])}else g.push([]);let O=b||1;for(let t=0;t<=d;t++)if(!(n[t]<e[0])){for(;void 0!==e[D+1]&&n[t]>=e[D+1]||t===d;){if(A=e[D],r.dataGroupInfo={start:P?C:r.cropStart+C,length:g[0].length,groupStart:A},w=E.apply(r,g),r.pointClass&&!p(r.dataGroupInfo.options)&&(r.dataGroupInfo.options=x(r.pointClass.prototype.optionsToObject.call({series:r},r.options.data[r.cropStart+C])),M.forEach(function(t){delete r.dataGroupInfo.options[t]})),void 0!==w){u.push(A);let t=y(w)?w:[w];for(let e=0;e<t.length;e++)G[e].push(t[e]);c.push(r.dataGroupInfo)}C=t;for(let t=0;t<O;t++)g[t].length=0,g[t].hasNulls=!1;if(D+=1,t===d)break}if(t===d)break;if(v){let e,o=P?t:r.cropStart+t,n=s&&s[o]||r.pointClass.prototype.applyOptions.apply({series:r},[l[o]]);for(let t=0;t<b;t++)m(e=n[v[t]])?g[t].push(e):null===e&&(g[t].hasNulls=!0)}else m(T=f?i[t]:null)?g[0].push(T):null===T&&(g[0].hasNulls=!0)}let S={x:u};return(v||["y"]).forEach((t,e)=>{S[t]=G[e]}),h.setColumns(S),{groupMap:c,modified:h}}function K(t){let e=t.options,o=this.type,n=this.chart.options.plotOptions,i=this.useCommonDataGrouping&&T,a=r().defaultOptions.plotOptions[o].dataGrouping;if(n&&(w[o]||i)){let t=this.chart.rangeSelector;a||(a=x(T,w[o])),e.dataGrouping=x(i,a,n.series&&n.series.dataGrouping,n[o].dataGrouping,this.userOptions.dataGrouping,!e.isInternal&&t&&m(t.selected)&&t.buttonOptions[t.selected].dataGrouping)}}let U=function(t){let e=t.prototype;e.applyGrouping||(u(t.prototype.pointClass,"update",function(){if(this.dataGroup)return(0,i.error)(24,!1,this.series.chart),!1}),u(t,"afterSetOptions",K),u(t,"destroy",Y),c(e,{applyGrouping:I,destroyGroupedData:Y,generatePoints:q,getDGApproximation:_,groupData:z}))},X=e.default.Templating,{format:B}=n.n(X)(),{composed:$}=r();function J(t){let e=this.chart,o=e.time,n=t.point,i=n.series,r=i.options,a=i.tooltipOptions,s=r.dataGrouping,l=i.xAxis,u=a.xDateFormat||"",h,p,d,f,g,y=a[t.isFooter?"footerFormat":"headerFormat"];if(l&&"datetime"===l.options.type&&s&&m(n.key)){p=i.currentDataGrouping,d=s.dateTimeLabelFormats||T.dateTimeLabelFormats,p?(f=d[p.unitName],1===p.count?u=f[0]:(u=f[1],h=f[2])):!u&&d&&l.dateTime&&(u=l.dateTime.getXDateFormat(n.x,a.dateTimeLabelFormats));let r=M(i.groupMap?.[n.index].groupStart,n.key),m=r+(p?.totalRange||0)-1;g=o.dateFormat(u,r),h&&(g+=o.dateFormat(h,m)),i.chart.styledMode&&(y=this.styledModeFormat(y)),t.text=B(y,{point:c(n,{key:g}),series:i},e),t.preventDefault()}}let Q=r();Q.dataGrouping=Q.dataGrouping||{},Q.dataGrouping.approximationDefaults=Q.dataGrouping.approximationDefaults||A,Q.dataGrouping.approximations=Q.dataGrouping.approximations||a,({compose:function(t,e,o){var n;k(t),U(e),o&&(n="DataGrouping",0>$.indexOf(n)&&$.push(n))&&u(o,"headerFormatter",J)},groupData:z}).compose(Q.Axis,Q.Series,Q.Tooltip);let V=r();export{V as default};