/*
 Highcharts JS v10.1.0 (2022-04-29)

 Sankey diagram module

 (c) 2010-2021 Torstein Honsi

 License: www.highcharts.com/license
*/
(function(b){"object"===typeof module&&module.exports?(b["default"]=b,module.exports=b):"function"===typeof define&&define.amd?define("highcharts/modules/sankey",["highcharts"],function(q){b(q);b.Highcharts=q;return b}):b("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(b){function q(b,f,l,m){b.hasOwnProperty(f)||(b[f]=m.apply(null,l),"function"===typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:f,module:b[f]}})))}b=b?b._modules:{};q(b,"Series/NodesComposition.js",
[b["Core/Series/Point.js"],b["Core/Series/Series.js"],b["Core/Utilities.js"]],function(b,f,l){var m=l.defined,w=l.extend,y=l.find,g=l.merge,c=l.pick,n;(function(a){function e(){this.data=[].concat(this.points||[],this.nodes);return f.prototype.destroy.apply(this,arguments)}function n(){this.nodes&&(this.nodes.forEach(function(a){a.destroy()}),this.nodes.length=0);f.prototype.setData.apply(this,arguments)}function v(a){var c=arguments,d=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,
this.toNode];"select"!==a&&d.forEach(function(a){a&&a.series&&(b.prototype.setState.apply(a,c),a.isNode||(a.fromNode.graphic&&b.prototype.setState.apply(a.fromNode,c),a.toNode&&a.toNode.graphic&&b.prototype.setState.apply(a.toNode,c)))});b.prototype.setState.apply(this,c)}function u(a,e,d,k){var h=this,p=this.series.options.nodes,x=this.series.options.data,n=x&&x.length||0,r=x&&x[this.index];b.prototype.update.call(this,a,this.isNode?!1:e,d,k);this.isNode&&(a=(p||[]).reduce(function(a,p,c){return h.id===
p.id?c:a},-1),k=g(p&&p[a]||{},x&&x[this.index]||{}),x&&(r?x[this.index]=r:x.length=n),p?0<=a?p[a]=k:p.push(k):this.series.options.nodes=[k],c(e,!0)&&this.series.chart.redraw(d))}var t=[];a.compose=function(a,c){-1===t.indexOf(a)&&(t.push(a),a=a.prototype,a.setNodeState=v,a.setState=v,a.update=u);-1===t.indexOf(c)&&(t.push(c),a=c.prototype,a.destroy=e,a.setData=n);return c};a.createNode=function(a){var e=this.pointClass,d=function(a,p){return y(a,function(a){return a.id===p})},k=d(this.nodes,a);k||
(d=this.options.nodes&&d(this.options.nodes,a),k=(new e).init(this,w({className:"highcharts-node",isNode:!0,id:a,y:1},d)),k.linksTo=[],k.linksFrom=[],k.getSum=function(){var a=0,p=0;k.linksTo.forEach(function(h){a+=h.weight});k.linksFrom.forEach(function(a){p+=a.weight});return Math.max(a,p)},k.offset=function(a,p){for(var h=0,c=0;c<k[p].length;c++){if(k[p][c]===a)return h;h+=k[p][c].weight}},k.hasShape=function(){var a=0;k.linksTo.forEach(function(h){h.outgoing&&a++});return!k.linksTo.length||a!==
k.linksTo.length},k.index=this.nodes.push(k)-1);k.formatPrefix="node";k.name=k.name||k.options.id||"";k.mass=c(k.options.mass,k.options.marker&&k.options.marker.radius,this.options.marker&&this.options.marker.radius,4);return k};a.destroy=e;a.generatePoints=function(){var a=this.chart,e={};f.prototype.generatePoints.call(this);this.nodes||(this.nodes=[]);this.colorCounter=0;this.nodes.forEach(function(a){a.linksFrom.length=0;a.linksTo.length=0;a.level=a.options.level});this.points.forEach(function(d){m(d.from)&&
(e[d.from]||(e[d.from]=this.createNode(d.from)),e[d.from].linksFrom.push(d),d.fromNode=e[d.from],a.styledMode?d.colorIndex=c(d.options.colorIndex,e[d.from].colorIndex):d.color=d.options.color||e[d.from].color);m(d.to)&&(e[d.to]||(e[d.to]=this.createNode(d.to)),e[d.to].linksTo.push(d),d.toNode=e[d.to]);d.name=d.name||d.id},this);this.nodeLookup=e};a.setNodeState=v;a.updateNode=u})(n||(n={}));return n});q(b,"Series/Sankey/SankeyPoint.js",[b["Core/Series/Point.js"],b["Core/Series/SeriesRegistry.js"],
b["Core/Utilities.js"]],function(b,f,l){var m=this&&this.__extends||function(){var b=function(g,c){b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(c,a){c.__proto__=a}||function(c,a){for(var e in a)a.hasOwnProperty(e)&&(c[e]=a[e])};return b(g,c)};return function(g,c){function n(){this.constructor=g}b(g,c);g.prototype=null===c?Object.create(c):(n.prototype=c.prototype,new n)}}(),w=l.defined;return function(f){function g(){var c=null!==f&&f.apply(this,arguments)||this;c.className=void 0;
c.fromNode=void 0;c.level=void 0;c.linkBase=void 0;c.linksFrom=void 0;c.linksTo=void 0;c.mass=void 0;c.nodeX=void 0;c.nodeY=void 0;c.options=void 0;c.series=void 0;c.toNode=void 0;return c}m(g,f);g.prototype.applyOptions=function(c,n){b.prototype.applyOptions.call(this,c,n);w(this.options.level)&&(this.options.column=this.column=this.options.level);return this};g.prototype.getClassName=function(){return(this.isNode?"highcharts-node ":"highcharts-link ")+b.prototype.getClassName.call(this)};g.prototype.getFromNode=
function(){for(var c=-1,b,a=0;a<this.linksTo.length;a++){var e=this.linksTo[a];e.fromNode.column>c&&e.fromNode!==this&&(b=e.fromNode,c=b.column)}return{fromNode:b,fromColumn:c}};g.prototype.setNodeColumn=function(){w(this.options.column)||(this.column=0===this.linksTo.length?0:this.getFromNode().fromColumn+1)};g.prototype.isValid=function(){return this.isNode||"number"===typeof this.weight};return g}(f.seriesTypes.column.prototype.pointClass)});q(b,"Series/Sankey/SankeyColumnComposition.js",[b["Core/Utilities.js"]],
function(b){var f=b.defined,l=b.relativeLength,m;(function(b){b.compose=function(b,c){b.sankeyColumn=new m(b,c);return b};var m=function(){function b(c,b){this.points=c;this.series=b}b.prototype.getTranslationFactor=function(c){for(var b=this.points,a=b.slice(),e=c.options.minLinkWidth||0,g=0,v,f=(c.chart.plotSizeY||0)-(c.options.borderWidth||0)-(b.length-1)*c.nodePadding;b.length;){g=f/b.sankeyColumn.sum();c=!1;for(v=b.length;v--;)b[v].getSum()*g<e&&(b.splice(v,1),f-=e,c=!0);if(!c)break}b.length=
0;a.forEach(function(a){b.push(a)});return g};b.prototype.top=function(c){var b=this.series,a=b.nodePadding,e=this.points.reduce(function(e,g){0<e&&(e+=a);g=Math.max(g.getSum()*c,b.options.minLinkWidth||0);return e+g},0);return((b.chart.plotSizeY||0)-e)/2};b.prototype.left=function(c){var b=this.series,a=b.chart,e=b.options.equalNodes,g=a.inverted?a.plotHeight:a.plotWidth,f=b.nodePadding,u=this.points.reduce(function(a,n){0<a&&(a+=f);n=e?g/n.series.nodes.length-f:Math.max(n.getSum()*c,b.options.minLinkWidth||
0);return a+n},0);return((a.plotSizeX||0)-Math.round(u))/2};b.prototype.sum=function(){return this.points.reduce(function(b,g){return b+g.getSum()},0)};b.prototype.offset=function(b,g){var a=this.points,c=this.series,n=c.nodePadding,v=0;if(c.is("organization")&&b.hangsFrom)return{absoluteTop:b.hangsFrom.nodeY};for(var u=0;u<a.length;u++){var t=a[u].getSum();var m=Math.max(t*g,c.options.minLinkWidth||0),r=b.options[c.chart.inverted?"offsetHorizontal":"offsetVertical"],d=b.options.offset||0;t=t?m+n:
0;if(a[u]===b)return{relativeTop:v+(f(r)?l(r,m):l(d,t))};v+=t}};return b}();b.SankeyColumnAdditions=m})(m||(m={}));return m});q(b,"Series/TreeUtilities.js",[b["Core/Color/Color.js"],b["Core/Utilities.js"]],function(b,f){function l(a,b){var c=b.before,e=b.idRoot,g=b.mapIdToNode[e],f=b.points[a.i],z=f&&f.options||{},r=[],d=0;a.levelDynamic=a.level-(!1!==b.levelIsConstant?0:g.level);a.name=n(f&&f.name,"");a.visible=e===a.id||!0===b.visible;"function"===typeof c&&(a=c(a,b));a.children.forEach(function(c,
h){var p=m({},b);m(p,{index:h,siblings:a.children.length,visible:a.visible});c=l(c,p);r.push(c);c.visible&&(d+=c.val)});c=n(z.value,d);a.visible=0<=c&&(0<d||a.visible);a.children=r;a.childrenTotal=d;a.isLeaf=a.visible&&!d;a.val=c;return a}var m=f.extend,w=f.isArray,q=f.isNumber,g=f.isObject,c=f.merge,n=f.pick;return{getColor:function(a,c){var e=c.index,g=c.mapOptionsToLevel,f=c.parentColor,m=c.parentColorIndex,l=c.series,r=c.colors,d=c.siblings,k=l.points,h=l.chart.options.chart,p;if(a){k=k[a.i];
a=g[a.level]||{};if(g=k&&a.colorByPoint){var x=k.index%(r?r.length:h.colorCount);var H=r&&r[x]}if(!l.chart.styledMode){r=k&&k.options.color;h=a&&a.color;if(p=f)p=(p=a&&a.colorVariation)&&"brightness"===p.key&&e&&d?b.parse(f).brighten(e/d*p.to).get():f;p=n(r,h,H,p,l.color)}var I=n(k&&k.options.colorIndex,a&&a.colorIndex,x,m,c.colorIndex)}return{color:p,colorIndex:I}},getLevelOptions:function(a){var b=null;if(g(a)){b={};var f=q(a.from)?a.from:1;var l=a.levels;var m={};var t=g(a.defaults)?a.defaults:
{};w(l)&&(m=l.reduce(function(a,b){if(g(b)&&q(b.level)){var d=c({},b);var k=n(d.levelIsConstant,t.levelIsConstant);delete d.levelIsConstant;delete d.level;b=b.level+(k?0:f-1);g(a[b])?c(!0,a[b],d):a[b]=d}return a},{}));l=q(a.to)?a.to:1;for(a=0;a<=l;a++)b[a]=c({},t,g(m[a])?m[a]:{})}return b},setTreeValues:l,updateRootId:function(a){if(g(a)){var b=g(a.options)?a.options:{};b=n(a.rootNode,b.rootId,"");g(a.userOptions)&&(a.userOptions.rootId=b);a.rootNode=b}return b}}});q(b,"Series/Sankey/SankeySeries.js",
[b["Core/Color/Color.js"],b["Core/Globals.js"],b["Series/NodesComposition.js"],b["Series/Sankey/SankeyPoint.js"],b["Core/Series/SeriesRegistry.js"],b["Series/Sankey/SankeyColumnComposition.js"],b["Series/TreeUtilities.js"],b["Core/Utilities.js"]],function(b,f,l,m,q,y,g,c){var n=this&&this.__extends||function(){var a=function(b,h){a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var h in b)b.hasOwnProperty(h)&&(a[h]=b[h])};return a(b,h)};return function(b,
h){function c(){this.constructor=b}a(b,h);b.prototype=null===h?Object.create(h):(c.prototype=h.prototype,new c)}}(),a=q.series,e=q.seriesTypes.column,w=g.getLevelOptions;g=c.extend;var v=c.isObject,u=c.merge,t=c.pick,z=c.relativeLength,r=c.stableSort;c=function(a){function c(){var b=null!==a&&a.apply(this,arguments)||this;b.colDistance=void 0;b.data=void 0;b.group=void 0;b.nodeLookup=void 0;b.nodePadding=void 0;b.nodes=void 0;b.nodeWidth=void 0;b.options=void 0;b.points=void 0;b.translationFactor=
void 0;return b}n(c,a);c.getDLOptions=function(a){var b=v(a.optionsPoint)?a.optionsPoint.dataLabels:{};a=v(a.level)?a.level.dataLabels:{};return u({style:{}},a,b)};c.prototype.createNodeColumns=function(){var a=[];this.nodes.forEach(function(b){b.setNodeColumn();a[b.column]||(a[b.column]=y.compose([],this));a[b.column].push(b)},this);for(var b=0;b<a.length;b++)"undefined"===typeof a[b]&&(a[b]=y.compose([],this));return a};c.prototype.generatePoints=function(){function a(b,c){"undefined"===typeof b.level&&
(b.level=c,b.linksFrom.forEach(function(b){b.toNode&&a(b.toNode,c+1)}))}l.generatePoints.apply(this,arguments);this.orderNodes&&(this.nodes.filter(function(a){return 0===a.linksTo.length}).forEach(function(b){a(b,0)}),r(this.nodes,function(a,b){return a.level-b.level}))};c.prototype.getNodePadding=function(){var a=this.options.nodePadding||0;if(this.nodeColumns){var b=this.nodeColumns.reduce(function(a,b){return Math.max(a,b.length)},0);b*a>this.chart.plotSizeY&&(a=this.chart.plotSizeY/b)}return a};
c.prototype.hasData=function(){return!!this.processedXData.length};c.prototype.pointAttribs=function(a,c){if(!a)return{};var h=this,p=h.mapOptionsToLevel[(a.isNode?a.level:a.fromNode.level)||0]||{},d=a.options,e=p.states&&p.states[c||""]||{};c=["colorByPoint","borderColor","borderWidth","linkOpacity"].reduce(function(a,b){a[b]=t(e[b],d[b],p[b],h.options[b]);return a},{});var g=t(e.color,d.color,c.colorByPoint?a.color:p.color);return a.isNode?{fill:g,stroke:c.borderColor,"stroke-width":c.borderWidth}:
{fill:b.parse(g).setOpacity(c.linkOpacity).get()}};c.prototype.render=function(){var a=this.points;this.points=this.points.concat(this.nodes||[]);e.prototype.render.call(this);this.points=a};c.prototype.translate=function(){this.processedXData||this.processData();this.generatePoints();this.nodeColumns=this.createNodeColumns();this.nodeWidth=z(this.options.nodeWidth,this.chart.plotSizeX);var a=this,b=this.chart,c=this.options,d=this.nodeWidth,e=this.nodeColumns;this.nodePadding=this.getNodePadding();
this.translationFactor=e.reduce(function(b,c){return Math.min(b,c.sankeyColumn.getTranslationFactor(a))},Infinity);this.colDistance=(b.plotSizeX-d-c.borderWidth)/Math.max(1,e.length-1);a.mapOptionsToLevel=w({from:1,levels:c.levels,to:e.length-1,defaults:{borderColor:c.borderColor,borderRadius:c.borderRadius,borderWidth:c.borderWidth,color:a.color,colorByPoint:c.colorByPoint,levelIsConstant:!0,linkColor:c.linkColor,linkLineWidth:c.linkLineWidth,linkOpacity:c.linkOpacity,states:c.states}});e.forEach(function(b){b.forEach(function(c){a.translateNode(c,
b)})},this);this.nodes.forEach(function(b){b.linksFrom.forEach(function(b){(b.weight||b.isNull)&&b.to&&(a.translateLink(b),b.allowShadow=!1)})})};c.prototype.translateLink=function(a){var b=function(b,c){c=b.offset(a,c)*g;return Math.min(b.nodeY+c,b.nodeY+(b.shapeArgs&&b.shapeArgs.height||0)-h)},c=a.fromNode,d=a.toNode,e=this.chart,g=this.translationFactor,h=Math.max(a.weight*g,this.options.minLinkWidth),k=(e.inverted?-this.colDistance:this.colDistance)*this.options.curveFactor,f=b(c,"linksFrom");
b=b(d,"linksTo");var l=c.nodeX,m=this.nodeWidth;d=d.nodeX;var n=a.outgoing,q=d>l+m;e.inverted&&(f=e.plotSizeY-f,b=(e.plotSizeY||0)-b,m=-m,h=-h,q=l>d);a.shapeType="path";a.linkBase=[f,f+h,b,b+h];if(q&&"number"===typeof b)a.shapeArgs={d:[["M",l+m,f],["C",l+m+k,f,d-k,b,d,b],["L",d+(n?m:0),b+h/2],["L",d,b+h],["C",d-k,b+h,l+m+k,f+h,l+m,f+h],["Z"]]};else if("number"===typeof b){k=d-20-h;n=d-20;q=l+m;var r=q+20,t=r+h,v=f,u=f+h,w=u+20,B=w+(e.plotHeight-f-h),A=B+20,y=A+h,z=b,C=z+h,D=C+20,E=A+.7*h,F=d-.7*h,
G=q+.7*h;a.shapeArgs={d:[["M",q,v],["C",G,v,t,u-.7*h,t,w],["L",t,B],["C",t,E,G,y,q,y],["L",d,y],["C",F,y,k,E,k,B],["L",k,D],["C",k,C-.7*h,F,z,d,z],["L",d,C],["C",n,C,n,C,n,D],["L",n,B],["C",n,A,n,A,d,A],["L",q,A],["C",r,A,r,A,r,B],["L",r,w],["C",r,u,r,u,q,u],["Z"]]}}a.dlBox={x:l+(d-l+m)/2,y:f+(b-f)/2,height:h,width:0};a.tooltipPos=e.inverted?[e.plotSizeY-a.dlBox.y-h/2,e.plotSizeX-a.dlBox.x]:[a.dlBox.x,a.dlBox.y+h/2];a.y=a.plotY=1;a.x=a.plotX=1;a.color||(a.color=c.color)};c.prototype.translateNode=
function(a,b){var d=this.translationFactor,e=this.chart,f=this.options,g=a.getSum(),k=Math.max(Math.round(g*d),this.options.minLinkWidth),h=Math.round(this.nodeWidth),l=Math.round(f.borderWidth)%2/2,m=b.sankeyColumn.offset(a,d);b=Math.floor(t(m.absoluteTop,b.sankeyColumn.top(d)+m.relativeTop))+l;l=Math.floor(this.colDistance*a.column+f.borderWidth/2)+z(a.options.offsetHorizontal||0,h)+l;l=e.inverted?e.plotSizeX-l:l;if(a.sum=g){a.shapeType="rect";a.nodeX=l;a.nodeY=b;g=l;d=b;m=a.options.width||f.width||
h;var n=a.options.height||f.height||k;e.inverted&&(g=l-h,d=e.plotSizeY-b-k,m=a.options.height||f.height||h,n=a.options.width||f.width||k);a.dlOptions=c.getDLOptions({level:this.mapOptionsToLevel[a.level],optionsPoint:a.options});a.plotX=1;a.plotY=1;a.tooltipPos=e.inverted?[e.plotSizeY-d-n/2,e.plotSizeX-g-m/2]:[g+m/2,d+n/2];a.shapeArgs={x:g,y:d,width:m,height:n,display:a.hasShape()?"":"none"}}else a.dlOptions={enabled:!1}};c.defaultOptions=u(e.defaultOptions,{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/>"}});return c}(e);l.compose(m,c);g(c.prototype,{animate:a.prototype.animate,createNode:l.createNode,forceDL:!0,invertible:!0,isCartesian:!1,orderNodes:!0,noSharedTooltip:!0,pointArrayMap:["from","to","weight"],pointClass:m,searchPoint:f.noop});q.registerSeriesType("sankey",c);"";"";return c});q(b,"masters/modules/sankey.src.js",[],function(){})});
//# sourceMappingURL=sankey.js.map