/*
 Highcharts JS v6.0.7 (2018-02-16)
 Highcharts Drilldown module

 Author: Torstein Honsi
 License: www.highcharts.com/license

*/
(function(p){"object"===typeof module&&module.exports?module.exports=p:p(Highcharts)})(function(p){(function(e){var p=e.animObject,y=e.noop,z=e.color,A=e.defaultOptions,k=e.each,q=e.extend,E=e.format,F=e.objectEach,t=e.pick,m=e.Chart,n=e.seriesTypes,B=n.pie,n=n.column,u=e.Tick,v=e.fireEvent,C=e.inArray,D=1;q(A.lang,{drillUpText:"\u25c1 Back to {series.name}"});A.drilldown={animation:{duration:500},drillUpButton:{position:{align:"right",x:-10,y:10}}};e.SVGRenderer.prototype.Element.prototype.fadeIn=
function(a){this.attr({opacity:.1,visibility:"inherit"}).animate({opacity:t(this.newOpacity,1)},a||{duration:250})};m.prototype.addSeriesAsDrilldown=function(a,b){this.addSingleSeriesAsDrilldown(a,b);this.applyDrilldown()};m.prototype.addSingleSeriesAsDrilldown=function(a,b){var d=a.series,c=d.xAxis,g=d.yAxis,f,h=[],w=[],l,r,m;m={colorIndex:t(a.colorIndex,d.colorIndex)};this.drilldownLevels||(this.drilldownLevels=[]);l=d.options._levelNumber||0;(r=this.drilldownLevels[this.drilldownLevels.length-
1])&&r.levelNumber!==l&&(r=void 0);b=q(q({_ddSeriesId:D++},m),b);f=C(a,d.points);k(d.chart.series,function(a){a.xAxis!==c||a.isDrilling||(a.options._ddSeriesId=a.options._ddSeriesId||D++,a.options._colorIndex=a.userOptions._colorIndex,a.options._levelNumber=a.options._levelNumber||l,r?(h=r.levelSeries,w=r.levelSeriesOptions):(h.push(a),w.push(a.options)))});a=q({levelNumber:l,seriesOptions:d.options,levelSeriesOptions:w,levelSeries:h,shapeArgs:a.shapeArgs,bBox:a.graphic?a.graphic.getBBox():{},color:a.isNull?
(new e.Color(z)).setOpacity(0).get():z,lowerSeriesOptions:b,pointOptions:d.options.data[f],pointIndex:f,oldExtremes:{xMin:c&&c.userMin,xMax:c&&c.userMax,yMin:g&&g.userMin,yMax:g&&g.userMax},resetZoomButton:this.resetZoomButton},m);this.drilldownLevels.push(a);c&&c.names&&(c.names.length=0);b=a.lowerSeries=this.addSeries(b,!1);b.options._levelNumber=l+1;c&&(c.oldPos=c.pos,c.userMin=c.userMax=null,g.userMin=g.userMax=null);d.type===b.type&&(b.animate=b.animateDrilldown||y,b.options.animation=!0)};m.prototype.applyDrilldown=
function(){var a=this.drilldownLevels,b;a&&0<a.length&&(b=a[a.length-1].levelNumber,k(this.drilldownLevels,function(a){a.levelNumber===b&&k(a.levelSeries,function(a){a.options&&a.options._levelNumber===b&&a.remove(!1)})}));this.resetZoomButton&&(this.resetZoomButton.hide(),delete this.resetZoomButton);this.pointer.reset();this.redraw();this.showDrillUpButton()};m.prototype.getDrilldownBackText=function(){var a=this.drilldownLevels;if(a&&0<a.length)return a=a[a.length-1],a.series=a.seriesOptions,E(this.options.lang.drillUpText,
a)};m.prototype.showDrillUpButton=function(){var a=this,b=this.getDrilldownBackText(),d=a.options.drilldown.drillUpButton,c,g;this.drillUpButton?this.drillUpButton.attr({text:b}).align():(g=(c=d.theme)&&c.states,this.drillUpButton=this.renderer.button(b,null,null,function(){a.drillUp()},c,g&&g.hover,g&&g.select).addClass("highcharts-drillup-button").attr({align:d.position.align,zIndex:7}).add().align(d.position,!1,d.relativeTo||"plotBox"))};m.prototype.drillUp=function(){if(this.drilldownLevels&&
0!==this.drilldownLevels.length){for(var a=this,b=a.drilldownLevels,d=b[b.length-1].levelNumber,c=b.length,g=a.series,f,h,e,l,m=function(b){var c;k(g,function(a){a.options._ddSeriesId===b._ddSeriesId&&(c=a)});c=c||a.addSeries(b,!1);c.type===e.type&&c.animateDrillupTo&&(c.animate=c.animateDrillupTo);b===h.seriesOptions&&(l=c)};c--;)if(h=b[c],h.levelNumber===d){b.pop();e=h.lowerSeries;if(!e.chart)for(f=g.length;f--;)if(g[f].options.id===h.lowerSeriesOptions.id&&g[f].options._levelNumber===d+1){e=g[f];
break}e.xData=[];k(h.levelSeriesOptions,m);v(a,"drillup",{seriesOptions:h.seriesOptions});l.type===e.type&&(l.drilldownLevel=h,l.options.animation=a.options.drilldown.animation,e.animateDrillupFrom&&e.chart&&e.animateDrillupFrom(h));l.options._levelNumber=d;e.remove(!1);l.xAxis&&(f=h.oldExtremes,l.xAxis.setExtremes(f.xMin,f.xMax,!1),l.yAxis.setExtremes(f.yMin,f.yMax,!1));h.resetZoomButton&&(a.resetZoomButton=h.resetZoomButton,a.resetZoomButton.show())}v(a,"drillupall");this.redraw();0===this.drilldownLevels.length?
this.drillUpButton=this.drillUpButton.destroy():this.drillUpButton.attr({text:this.getDrilldownBackText()}).align();this.ddDupes.length=[]}};m.prototype.callbacks.push(function(){var a=this;a.drilldown={update:function(b,d){e.merge(!0,a.options.drilldown,b);t(d,!0)&&a.redraw()}}});e.addEvent(m.prototype,"beforeShowResetZoom",function(){if(this.drillUpButton)return!1});n.prototype.animateDrillupTo=function(a){if(!a){var b=this,d=b.drilldownLevel;k(this.points,function(a){var b=a.dataLabel;a.graphic&&
a.graphic.hide();b&&(b.hidden="hidden"===b.attr("visibility"),b.hidden||(b.hide(),a.connector&&a.connector.hide()))});e.syncTimeout(function(){b.points&&k(b.points,function(a,b){b=b===(d&&d.pointIndex)?"show":"fadeIn";var c="show"===b?!0:void 0,e=a.dataLabel;if(a.graphic)a.graphic[b](c);e&&!e.hidden&&(e.fadeIn(),a.connector&&a.connector.fadeIn())})},Math.max(this.chart.options.drilldown.animation.duration-50,0));this.animate=y}};n.prototype.animateDrilldown=function(a){var b=this,d=this.chart.drilldownLevels,
c,e=p(this.chart.options.drilldown.animation),f=this.xAxis;a||(k(d,function(a){b.options._ddSeriesId===a.lowerSeriesOptions._ddSeriesId&&(c=a.shapeArgs)}),c.x+=t(f.oldPos,f.pos)-f.pos,k(this.points,function(a){a.graphic&&a.graphic.attr(c).animate(q(a.shapeArgs,{fill:a.color||b.color}),e);a.dataLabel&&a.dataLabel.fadeIn(e)}),this.animate=null)};n.prototype.animateDrillupFrom=function(a){var b=p(this.chart.options.drilldown.animation),d=this.group,c=d!==this.chart.columnGroup,g=this;k(g.trackerGroups,
function(a){if(g[a])g[a].on("mouseover")});c&&delete this.group;k(this.points,function(g){var f=g.graphic,k=a.shapeArgs,l=function(){f.destroy();d&&c&&(d=d.destroy())};f&&(delete g.graphic,b.duration?f.animate(k,e.merge(b,{complete:l})):(f.attr(k),l()))})};B&&q(B.prototype,{animateDrillupTo:n.prototype.animateDrillupTo,animateDrillupFrom:n.prototype.animateDrillupFrom,animateDrilldown:function(a){var b=this.chart.options.drilldown.animation,d=this.chart.drilldownLevels[this.chart.drilldownLevels.length-
1].shapeArgs,c=d.start,g=(d.end-c)/this.points.length;a||(k(this.points,function(a,h){var f=a.shapeArgs;if(a.graphic)a.graphic.attr(e.merge(d,{start:c+h*g,end:c+(h+1)*g}))[b?"animate":"attr"](f,b)}),this.animate=null)}});e.Point.prototype.doDrilldown=function(a,b,d){var c=this.series.chart,e=c.options.drilldown,f=(e.series||[]).length,h;c.ddDupes||(c.ddDupes=[]);for(;f--&&!h;)e.series[f].id===this.drilldown&&-1===C(this.drilldown,c.ddDupes)&&(h=e.series[f],c.ddDupes.push(this.drilldown));v(c,"drilldown",
{point:this,seriesOptions:h,category:b,originalEvent:d,points:void 0!==b&&this.series.xAxis.getDDPoints(b).slice(0)},function(b){var c=b.point.series&&b.point.series.chart,d=b.seriesOptions;c&&d&&(a?c.addSingleSeriesAsDrilldown(b.point,d):c.addSeriesAsDrilldown(b.point,d))})};e.Axis.prototype.drilldownCategory=function(a,b){F(this.getDDPoints(a),function(d){d&&d.series&&d.series.visible&&d.doDrilldown&&d.doDrilldown(!0,a,b)});this.chart.applyDrilldown()};e.Axis.prototype.getDDPoints=function(a){var b=
[];k(this.series,function(d){var c,e=d.xData,f=d.points;for(c=0;c<e.length;c++)if(e[c]===a&&d.options.data[c]&&d.options.data[c].drilldown){b.push(f?f[c]:!0);break}});return b};u.prototype.drillable=function(){var a=this.pos,b=this.label,d=this.axis,c="xAxis"===d.coll&&d.getDDPoints,e=c&&d.getDDPoints(a);c&&(b&&e.length?(b.drillable=!0,b.addClass("highcharts-drilldown-axis-label").on("click",function(b){d.drilldownCategory(a,b)})):b&&b.drillable&&(b.on("click",null),b.removeClass("highcharts-drilldown-axis-label")))};
e.addEvent(u.prototype,"afterRender",u.prototype.drillable);e.addEvent(e.Point.prototype,"afterInit",function(){var a=this,b=a.series,d=b.xAxis,d=d&&d.ticks[a.x];a.drilldown&&e.addEvent(a,"click",function(c){b.xAxis&&!1===b.chart.options.drilldown.allowPointDrilldown?b.xAxis.drilldownCategory(a.x,c):a.doDrilldown(void 0,void 0,c)});d&&d.drillable();return a});e.addEvent(e.Series.prototype,"afterDrawDataLabels",function(){k(this.points,function(a){var b=a.options.dataLabels,d=t(a.dlOptions,b&&b.style,
{});a.drilldown&&a.dataLabel&&(b&&b.color&&(d.color=b.color),a.dataLabel.addClass("highcharts-drilldown-data-label"))},this)});var x=function(a,b,d){a[d?"addClass":"removeClass"]("highcharts-drilldown-point")};e.addEvent(e.Series.prototype,"afterDrawTracker",function(){k(this.points,function(a){a.drilldown&&a.graphic&&x(a.graphic,"pointer",!0)})});e.addEvent(e.Point.prototype,"afterSetState",function(){this.drilldown&&this.series.halo&&"hover"===this.state?x(this.series.halo,"pointer",!0):this.series.halo&&
x(this.series.halo,"auto",!1)})})(p)});
