/*
 Highcharts JS v7.2.0 (2019-09-03)

 Sankey diagram module

 (c) 2010-2019 Torstein Honsi

 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/sankey",["highcharts"],function(t){a(t);a.Highcharts=t;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function t(h,a,y,u){h.hasOwnProperty(a)||(h[a]=u.apply(null,y))}a=a?a._modules:{};t(a,"mixins/nodes.js",[a["parts/Globals.js"],a["parts/Utilities.js"]],function(h,a){var q=a.defined,u=h.pick,n=h.Point;h.NodesMixin=
{createNode:function(a){function l(c,e){return h.find(c,function(c){return c.id===e})}var b=l(this.nodes,a),v=this.pointClass;if(!b){var r=this.options.nodes&&l(this.options.nodes,a);b=(new v).init(this,h.extend({className:"highcharts-node",isNode:!0,id:a,y:1},r));b.linksTo=[];b.linksFrom=[];b.formatPrefix="node";b.name=b.name||b.options.id;b.mass=u(b.options.mass,b.options.marker&&b.options.marker.radius,this.options.marker&&this.options.marker.radius,4);b.getSum=function(){var c=0,e=0;b.linksTo.forEach(function(d){c+=
d.weight});b.linksFrom.forEach(function(c){e+=c.weight});return Math.max(c,e)};b.offset=function(c,e){for(var d=0,p=0;p<b[e].length;p++){if(b[e][p]===c)return d;d+=b[e][p].weight}};b.hasShape=function(){var c=0;b.linksTo.forEach(function(e){e.outgoing&&c++});return!b.linksTo.length||c!==b.linksTo.length};this.nodes.push(b)}return b},generatePoints:function(){var a=this.chart,l={};h.Series.prototype.generatePoints.call(this);this.nodes||(this.nodes=[]);this.colorCounter=0;this.nodes.forEach(function(b){b.linksFrom.length=
0;b.linksTo.length=0;b.level=void 0});this.points.forEach(function(b){q(b.from)&&(l[b.from]||(l[b.from]=this.createNode(b.from)),l[b.from].linksFrom.push(b),b.fromNode=l[b.from],a.styledMode?b.colorIndex=u(b.options.colorIndex,l[b.from].colorIndex):b.color=b.options.color||l[b.from].color);q(b.to)&&(l[b.to]||(l[b.to]=this.createNode(b.to)),l[b.to].linksTo.push(b),b.toNode=l[b.to]);b.name=b.name||b.id},this);this.nodeLookup=l},setData:function(){this.nodes&&(this.nodes.forEach(function(a){a.destroy()}),
this.nodes.length=0);h.Series.prototype.setData.apply(this,arguments)},destroy:function(){this.data=[].concat(this.points||[],this.nodes);return h.Series.prototype.destroy.apply(this,arguments)},setNodeState:function(a){var h=arguments,b=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==a&&b.forEach(function(b){b.series&&(n.prototype.setState.apply(b,h),b.isNode||(b.fromNode.graphic&&n.prototype.setState.apply(b.fromNode,h),b.toNode.graphic&&n.prototype.setState.apply(b.toNode,
h)))});n.prototype.setState.apply(this,h)}}});t(a,"mixins/tree-series.js",[a["parts/Globals.js"],a["parts/Utilities.js"]],function(h,a){var t=a.isArray,u=a.isNumber,n=a.isObject,q=h.extend,l=h.merge,b=h.pick;return{getColor:function(a,r){var c=r.index,e=r.mapOptionsToLevel,d=r.parentColor,p=r.parentColorIndex,f=r.series,k=r.colors,m=r.siblings,g=f.points,C=f.chart.options.chart,w;if(a){g=g[a.i];a=e[a.level]||{};if(e=g&&a.colorByPoint){var v=g.index%(k?k.length:C.colorCount);var l=k&&k[v]}if(!f.chart.styledMode){k=
g&&g.options.color;C=a&&a.color;if(w=d)w=(w=a&&a.colorVariation)&&"brightness"===w.key?h.color(d).brighten(c/m*w.to).get():d;w=b(k,C,l,w,f.color)}var n=b(g&&g.options.colorIndex,a&&a.colorIndex,v,p,r.colorIndex)}return{color:w,colorIndex:n}},getLevelOptions:function(b){var a=null;if(n(b)){a={};var c=u(b.from)?b.from:1;var e=b.levels;var d={};var p=n(b.defaults)?b.defaults:{};t(e)&&(d=e.reduce(function(b,d){if(n(d)&&u(d.level)){var e=l({},d);var g="boolean"===typeof e.levelIsConstant?e.levelIsConstant:
p.levelIsConstant;delete e.levelIsConstant;delete e.level;d=d.level+(g?0:c-1);n(b[d])?q(b[d],e):b[d]=e}return b},{}));e=u(b.to)?b.to:1;for(b=0;b<=e;b++)a[b]=l({},p,n(d[b])?d[b]:{})}return a},setTreeValues:function e(a,c){var d=c.before,p=c.idRoot,f=c.mapIdToNode[p],k=c.points[a.i],m=k&&k.options||{},g=0,h=[];q(a,{levelDynamic:a.level-(("boolean"===typeof c.levelIsConstant?c.levelIsConstant:1)?0:f.level),name:b(k&&k.name,""),visible:p===a.id||("boolean"===typeof c.visible?c.visible:!1)});"function"===
typeof d&&(a=d(a,c));a.children.forEach(function(b,d){var p=q({},c);q(p,{index:d,siblings:a.children.length,visible:a.visible});b=e(b,p);h.push(b);b.visible&&(g+=b.val)});a.visible=0<g||a.visible;d=b(m.value,g);q(a,{children:h,childrenTotal:g,isLeaf:a.visible&&!g,val:d});return a},updateRootId:function(a){if(n(a)){var c=n(a.options)?a.options:{};c=b(a.rootNode,c.rootId,"");n(a.userOptions)&&(a.userOptions.rootId=c);a.rootNode=c}return c}}});t(a,"modules/sankey.src.js",[a["parts/Globals.js"],a["parts/Utilities.js"],
a["mixins/tree-series.js"]],function(a,q,t){var h=q.defined,n=q.isObject,y=t.getLevelOptions,l=a.find,b=a.merge;q=a.seriesType;var v=a.pick,r=a.Point;q("sankey","column",{borderWidth:0,colorByPoint:!0,curveFactor:.33,dataLabels:{enabled:!0,backgroundColor:"none",crop:!1,nodeFormat:void 0,nodeFormatter:function(){return this.point.name},format:void 0,formatter:function(){},inside:!0},inactiveOtherPoints:!0,linkOpacity:.5,minLinkWidth:0,nodeWidth:20,nodePadding:10,showInLegend:!1,states:{hover:{linkOpacity:1},
inactive:{linkOpacity:.1,opacity:.1,animation:{duration:50}}},tooltip:{followPointer:!0,headerFormat:'<span style="font-size: 10px">{series.name}</span><br/>',pointFormat:"{point.fromNode.name} \u2192 {point.toNode.name}: <b>{point.weight}</b><br/>",nodeFormat:"{point.name}: <b>{point.sum}</b><br/>"}},{isCartesian:!1,invertable:!0,forceDL:!0,orderNodes:!0,pointArrayMap:["from","to"],createNode:a.NodesMixin.createNode,setData:a.NodesMixin.setData,destroy:a.NodesMixin.destroy,getNodePadding:function(){return this.options.nodePadding},
createNodeColumn:function(){var b=this.chart,e=[],d=this.getNodePadding();e.sum=function(){return this.reduce(function(b,a){return b+a.getSum()},0)};e.offset=function(b,c){for(var p=0,f,g=0;g<e.length;g++){f=e[g].getSum()*c+d;if(e[g]===b)return{relativeTop:p+a.relativeLength(b.options.offset||0,f)};p+=f}};e.top=function(a){var c=this.reduce(function(b,c){0<b&&(b+=d);return b+=c.getSum()*a},0);return(b.plotSizeY-c)/2};return e},createNodeColumns:function(){var b=[];this.nodes.forEach(function(a){var c=
-1,d;if(!h(a.options.column))if(0===a.linksTo.length)a.column=0;else{for(d=0;d<a.linksTo.length;d++){var e=a.linksTo[0];if(e.fromNode.column>c){var m=e.fromNode;c=m.column}}a.column=c+1;m&&"hanging"===m.options.layout&&(a.hangsFrom=m,d=-1,l(m.linksFrom,function(b,c){(b=b.toNode===a)&&(d=c);return b}),a.column+=d)}b[a.column]||(b[a.column]=this.createNodeColumn());b[a.column].push(a)},this);for(var a=0;a<b.length;a++)void 0===b[a]&&(b[a]=this.createNodeColumn());return b},hasData:function(){return!!this.processedXData.length},
pointAttribs:function(b,e){var c=this,p=c.mapOptionsToLevel[(b.isNode?b.level:b.fromNode.level)||0]||{},f=b.options,k=p.states&&p.states[e]||{};e=["colorByPoint","borderColor","borderWidth","linkOpacity"].reduce(function(b,a){b[a]=v(k[a],f[a],p[a],c.options[a]);return b},{});var m=v(k.color,f.color,e.colorByPoint?b.color:p.color);return b.isNode?{fill:m,stroke:e.borderColor,"stroke-width":e.borderWidth}:{fill:a.color(m).setOpacity(e.linkOpacity).get()}},generatePoints:function(){function b(a,c){void 0===
a.level&&(a.level=c,a.linksFrom.forEach(function(a){b(a.toNode,c+1)}))}a.NodesMixin.generatePoints.apply(this,arguments);this.orderNodes&&(this.nodes.filter(function(b){return 0===b.linksTo.length}).forEach(function(a){b(a,0)}),a.stableSort(this.nodes,function(b,a){return b.level-a.level}))},translateNode:function(a,e){var d=this.translationFactor,c=this.chart,f=this.options,k=a.getSum(),m=Math.round(k*d),g=Math.round(f.borderWidth)%2/2,h=e.offset(a,d);e=Math.floor(v(h.absoluteTop,e.top(d)+h.relativeTop))+
g;g=Math.floor(this.colDistance*a.column+f.borderWidth/2)+g;g=c.inverted?c.plotSizeX-g:g;d=Math.round(this.nodeWidth);a.sum=k;a.shapeType="rect";a.nodeX=g;a.nodeY=e;a.shapeArgs=c.inverted?{x:g-d,y:c.plotSizeY-e-m,width:a.options.height||f.height||d,height:a.options.width||f.width||m}:{x:g,y:e,width:a.options.width||f.width||d,height:a.options.height||f.height||m};a.shapeArgs.display=a.hasShape()?"":"none";c=this.mapOptionsToLevel[a.level];f=a.options;f=n(f)?f.dataLabels:{};c=n(c)?c.dataLabels:{};
c=b({style:{}},c,f);a.dlOptions=c;a.plotY=1},translateLink:function(a){var b=a.fromNode,d=a.toNode,c=this.chart,f=this.translationFactor,k=Math.max(a.weight*f,this.options.minLinkWidth),m=this.options,g=b.offset(a,"linksFrom")*f,h=(c.inverted?-this.colDistance:this.colDistance)*m.curveFactor;g=b.nodeY+g;m=b.nodeX;f=this.nodeColumns[d.column].top(f)+d.offset(a,"linksTo")*f+this.nodeColumns[d.column].offset(d,f).relativeTop;var l=this.nodeWidth;d=d.column*this.colDistance;var n=a.outgoing,q=d>m;c.inverted&&
(g=c.plotSizeY-g,f=c.plotSizeY-f,d=c.plotSizeX-d,l=-l,k=-k,q=m>d);a.shapeType="path";a.linkBase=[g,g+k,f,f+k];if(q)a.shapeArgs={d:["M",m+l,g,"C",m+l+h,g,d-h,f,d,f,"L",d+(n?l:0),f+k/2,"L",d,f+k,"C",d-h,f+k,m+l+h,g+k,m+l,g+k,"z"]};else{h=d-20-k;n=d-20;q=d;var r=m+l,t=r+20,u=t+k,v=g,z=g+k,y=z+20;c=y+(c.plotHeight-g-k);var x=c+20,B=x+k,D=f,A=D+k,E=A+20,F=x+.7*k,G=q-.7*k,H=r+.7*k;a.shapeArgs={d:["M",r,v,"C",H,v,u,z-.7*k,u,y,"L",u,c,"C",u,F,H,B,r,B,"L",q,B,"C",G,B,h,F,h,c,"L",h,E,"C",h,A-.7*k,G,D,q,D,"L",
q,A,"C",n,A,n,A,n,E,"L",n,c,"C",n,x,n,x,q,x,"L",r,x,"C",t,x,t,x,t,c,"L",t,y,"C",t,z,t,z,r,z,"z"]}}a.dlBox={x:m+(d-m+l)/2,y:g+(f-g)/2,height:k,width:0};a.y=a.plotY=1;a.color||(a.color=b.color)},translate:function(){this.processedXData||this.processData();this.generatePoints();this.nodeColumns=this.createNodeColumns();this.nodeWidth=a.relativeLength(this.options.nodeWidth,this.chart.plotSizeX);var b=this,e=this.chart,d=this.options,h=this.nodeWidth,f=this.nodeColumns,k=this.getNodePadding();this.translationFactor=
f.reduce(function(a,b){return Math.min(a,(e.plotSizeY-d.borderWidth-(b.length-1)*k)/b.sum())},Infinity);this.colDistance=(e.plotSizeX-h-d.borderWidth)/Math.max(1,f.length-1);b.mapOptionsToLevel=y({from:1,levels:d.levels,to:f.length-1,defaults:{borderColor:d.borderColor,borderRadius:d.borderRadius,borderWidth:d.borderWidth,color:b.color,colorByPoint:d.colorByPoint,levelIsConstant:!0,linkColor:d.linkColor,linkLineWidth:d.linkLineWidth,linkOpacity:d.linkOpacity,states:d.states}});f.forEach(function(a){a.forEach(function(c){b.translateNode(c,
a)})},this);this.nodes.forEach(function(a){a.linksFrom.forEach(function(a){b.translateLink(a);a.allowShadow=!1})})},render:function(){var b=this.points;this.points=this.points.concat(this.nodes||[]);a.seriesTypes.column.prototype.render.call(this);this.points=b},animate:a.Series.prototype.animate},{applyOptions:function(a,b){r.prototype.applyOptions.call(this,a,b);h(this.options.level)&&(this.options.column=this.column=this.options.level);return this},setState:a.NodesMixin.setNodeState,getClassName:function(){return(this.isNode?
"highcharts-node ":"highcharts-link ")+r.prototype.getClassName.call(this)},isValid:function(){return this.isNode||"number"===typeof this.weight}});""});t(a,"masters/modules/sankey.src.js",[],function(){})});
//# sourceMappingURL=sankey.js.map