/**
 * Highcharts JS v13.0.0 (2026-06-11)
 * @module modules/arc-diagram
 * @requires highcharts/modules/sankey
 *
 * Arc diagram module
 *
 * (c) 2021-2026 Highsoft AS
 * Author: Piotr Madej
 *
 * A commercial license may be required depending on use,
 * see www.highcharts.com/license
 */import*as t from"../highcharts.js";var e,o,s,i={};i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n=t.default;var a=i.n(n);let r=t.default.SeriesRegistry;var l=i.n(r);let{series:{prototype:h,prototype:{pointClass:{prototype:d}}}}=l();!function(t){function e(){if(!this.hasDataLabels?.()&&this.nodes)for(let t of this.nodes)t.destroyElements({dataLabel:1})}function o(){return this.data=[].concat(this.points||[],this.nodes),h.destroy.apply(this,arguments)}function s(){this.nodes&&(this.nodes.forEach(t=>{t.destroy()}),this.nodes.length=0),h.setData.apply(this,arguments)}function i(t){let e=arguments,o=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==t&&o.forEach(t=>{t&&t.series&&(d.setState.apply(t,e),!t.isNode&&(t.fromNode.graphic&&d.setState.apply(t.fromNode,e),t.toNode&&t.toNode.graphic&&d.setState.apply(t.toNode,e)))}),d.setState.apply(this,e)}function a(t,e,o,s){let i=this.series.options.nodes,a=this.series.options.data,r=a?.length||0,l=a?.[this.index];if(d.update.call(this,t,!this.isNode&&e,o,s),this.isNode){let t=(i||[]).reduce((t,e,o)=>this.id===e.id?o:t,-1),s=(0,n.merge)(i&&i[t]||{},a?.[this.index]||{});a&&(l?a[this.index]=l:a.length=r),i?t>=0?i[t]=s:i.push(s):this.series.options.nodes=[s],(0,n.pick)(e,!0)&&this.series.chart.redraw(o)}}t.compose=function(t,r){let l=t.prototype,h=r.prototype;return l.setNodeState=i,l.setState=i,l.update=a,h.destroy=o,h.setData=s,(0,n.addEvent)(r,"afterUpdate",e),r},t.createNode=function(t){let e=this.pointClass,o=(t,e)=>(0,n.find)(t,t=>t.id===e),s=o(this.nodes,t),i;if(!s){i=this.options.nodes&&o(this.options.nodes,t);let a=new e(this,(0,n.extend)({className:"highcharts-node",isNode:!0,id:t,y:1},i));a.linksTo=[],a.linksFrom=[],a.getSum=function(){let t=0,e=0;return a.linksTo.forEach(e=>{t+=e.weight||0}),a.linksFrom.forEach(t=>{e+=t.weight||0}),Math.max(t,e)},a.offset=function(t,e){let o=0;for(let s=0;s<a[e].length;s++){if(a[e][s]===t)return o;o+=a[e][s].weight}},a.hasShape=function(){let t=0;return a.linksTo.forEach(e=>{e.outgoing&&t++}),!a.linksTo.length||t!==a.linksTo.length},a.index=this.nodes.push(a)-1,s=a}return s.formatPrefix="node",s.name=s.name||s.options.id||"",s.mass=(0,n.pick)(s.options.mass,s.options.marker&&s.options.marker.radius,this.options.marker&&this.options.marker.radius,4),s},t.destroy=o,t.generatePoints=function(){let t=this.chart,e={};h.generatePoints.call(this),this.nodes||(this.nodes=[]),this.colorCounter=0,this.nodes.forEach(t=>{t.linksFrom.length=0,t.linksTo.length=0,t.level=t.options.level}),this.points.forEach(o=>{(0,n.defined)(o.from)&&(e[o.from]||(e[o.from]=this.createNode(o.from)),e[o.from].linksFrom.push(o),o.fromNode=e[o.from],t.styledMode?o.colorIndex=(0,n.pick)(o.options.colorIndex,e[o.from].colorIndex):o.color=o.options.color||e[o.from].color),(0,n.defined)(o.to)&&(e[o.to]||(e[o.to]=this.createNode(o.to)),e[o.to].linksTo.push(o),o.toNode=e[o.to]),o.name=o.name||o.id},this),this.nodeLookup=e},t.setNodeState=i,t.updateNode=a}(o||(o={}));let p=o,{seriesTypes:{sankey:{prototype:{pointClass:c}}}}=l();class u extends c{isValid(){return!0}}(0,n.extend)(u.prototype,{setState:p.setNodeState});var f=s||(s={});f.compose=function(t,e){return t.sankeyColumn=new m(t,e),t};class m{constructor(t,e){this.points=t,this.series=e}getTranslationFactor(t){let e=this.points,o=e.slice(),s=t.chart,i=t.options.minLinkWidth||0,n,a=0,r,l=(s.plotSizeY||0)-(t.options.borderWidth||0)-(e.length-1)*t.nodePadding;for(;e.length;){for(a=l/e.sankeyColumn.sum(),n=!1,r=e.length;r--;)e[r].getSum()*a<i&&(e.splice(r,1),l=Math.max(0,l-i),n=!0);if(!n)break}for(let t of(e.length=0,o))e.push(t);return a}top(t){let e=this.series,o=e.nodePadding,s=this.points.reduce((s,i)=>(s>0&&(s+=o),s+=Math.max(i.getSum()*t,e.options.minLinkWidth||0)),0);return(0,n.getAlignFactor)(e.options.nodeAlignment||"center")*((e.chart.plotSizeY||0)-s)}left(t){let e=this.series,o=e.chart,s=e.options.equalNodes,i=o.inverted?o.plotHeight:o.plotWidth,n=e.nodePadding,a=this.points.reduce((o,a)=>(o>0&&(o+=n),o+=s?i/a.series.nodes.length-n:Math.max(a.getSum()*t,e.options.minLinkWidth||0)),0);return((o.plotSizeX||0)-Math.round(a))/2}sum(){return this.points.reduce((t,e)=>t+e.getSum(),0)}offset(t,e){let o=this.points,s=this.series,i=s.nodePadding,a=0,r;if(s.is("organization")&&t.hangsFrom)return{absoluteTop:t.hangsFrom.nodeY};for(let l=0;l<o.length;l++){let h=o[l].getSum(),d=Math.max(h*e,s.options.minLinkWidth||0),p=t.options[s.chart.inverted?"offsetHorizontal":"offsetVertical"],c=t.options.offset||0;if(r=h?d+i:0,o[l]===t)return{relativeTop:a+((0,n.defined)(p)?(0,n.relativeLength)(p,d):(0,n.relativeLength)(c,r))};a+=r}}}f.SankeyColumnAdditions=m;let g=s,y=t.default.Series;var x=i.n(y);let k=t.default.SVGRenderer;var b=i.n(k);let L=t.default.SVGElement;var S=i.n(L);let{composed:P,deg2rad:v}=a();e=S(),(0,n.pushUnique)(P,"TextPath")&&((0,n.addEvent)(e,"afterGetBBox",function(t){let e=t.bBox,o=this.element?.querySelector("textPath");if(o){let t=[],{b:s,h:i}=this.renderer.fontMetrics(this.element),n=i-s,a=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),r=o.innerHTML.replace(a,"").split(/<tspan class="highcharts-br"[^>]*>/),l=r.length,h=(t,e)=>{let{x:i,y:a}=e,r=(o.getRotationOfChar(t)-90)*v,l=Math.cos(r),h=Math.sin(r);return[[i-n*l,a-n*h],[i+s*l,a+s*h]]};for(let e=0,s=0;s<l;s++){let i=r[s].length;for(let n=0;n<i;n+=5)try{let i=e+n+s,[a,r]=h(i,o.getStartPositionOfChar(i));0===n?(t.push(r),t.push(a)):(0===s&&t.unshift(r),s===l-1&&t.push(a))}catch{break}e+=i-1;try{let i=e+s,n=o.getEndPositionOfChar(i),[a,r]=h(i,n);t.unshift(r),t.unshift(a)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}),(0,n.addEvent)(e,"beforeAddingDataLabel",function(t){let e=t.labelOptions,o=t.point,s=e[o.formatPrefix+"TextPath"]||e.textPath;s&&!e.useHTML&&(this.setTextPath(o.getDataLabelPath?.(this)||o.graphic,s),o.dataLabelPath&&!s.enabled&&(o.dataLabelPath=o.dataLabelPath.destroy()))}),e.prototype.setTextPath=e.prototype.setTextPath??function(t,e){let o=this.renderer.url,s=this.text||this,i=s.textPath,{attributes:a,enabled:r}=(0,n.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||i&&i.path,i?.undo(),t&&r){let e=(0,n.addEvent)(s,"afterModifyTree",e=>{if(t&&r){let i=t.attr("id");i||t.attr("id",i=(0,n.uniqueKey)());let r={x:0,y:0};(0,n.defined)(a.dx)&&(r.dx=a.dx,delete a.dx),(0,n.defined)(a.dy)&&(r.dy=a.dy,delete a.dy),s.attr(r),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let l=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,n.extend)(a,{"text-anchor":a.textAnchor,href:`${o}#${i}`}),children:l}}});s.textPath={path:t,undo:e}}else s.attr({dx:0,dy:0}),delete s.textPath;return this.added&&(s.textCache="",this.renderer.buildText(s)),this});let{prototype:{symbols:N}}=b(),{seriesTypes:{column:T,sankey:C}}=l();class M extends C{createNodeColumns(){let t=this,e=t.chart,o=g.compose([],t);return o.sankeyColumn.maxLength=e.inverted?e.plotHeight:e.plotWidth,o.sankeyColumn.getTranslationFactor=t=>{let s=o.slice(),i=this.options.minLinkWidth||0,n,a=0,r,l,h=0,d=1,p=0,c=(e.plotSizeX||0)-(t.options.marker&&t.options.marker.lineWidth||0)-(o.length-1)*t.nodePadding;for(;o.length;){for(a=c/o.sankeyColumn.sum(),n=!1,r=o.length;r--;){l=o[r].getSum()*a*d;let t=Math.min(e.plotHeight,e.plotWidth);l>t?d=Math.min(t/l,d):l<i&&(o.splice(r,1),c-=i,l=i,n=!0),p+=l*(1-d)/2,h=Math.max(h,l)}if(!n)break}return o.length=0,s.forEach(t=>{t.scale=d,o.push(t)}),o.sankeyColumn.maxRadius=h,o.sankeyColumn.scale=d,o.sankeyColumn.additionalSpace=p,a},o.sankeyColumn.offset=function(s,i){let a=s.series.options.equalNodes,r=t.nodePadding,l=Math.min(e.plotWidth,e.plotHeight,(o.sankeyColumn.maxLength||0)/t.nodes.length-r),h=o.sankeyColumn.additionalSpace||0,d;for(let e=0;e<o.length;e++){let p=o[e].getSum()*(o.sankeyColumn.scale||0),c=a?l:Math.max(p*i,t.options.minLinkWidth||0);if(d=p?c+r:0,o[e]===s)return{relativeLeft:h+(0,n.relativeLength)(s.options.offset||0,d)};h+=d}},t.nodes.forEach(function(t){t.column=0,o.push(t)}),[o]}translateLink(t){let e=t.fromNode,o=t.toNode,s=this.chart,i=this.translationFactor,a=t.options,r=this.options,l=(0,n.pick)(a.linkWeight,r.linkWeight,Math.max((t.weight||0)*i*e.scale,this.options.minLinkWidth||0)),h=t.series.options.centeredLinks,d=e.nodeY,p=(e,o)=>{let s=(e.offset(t,o)||0)*i;return Math.min(e.nodeX+s,e.nodeX+(e.shapeArgs&&e.shapeArgs.height||0)-l)},c=h?e.nodeX+((e.shapeArgs.height||0)-l)/2:p(e,"linksFrom"),u=h?o.nodeX+((o.shapeArgs.height||0)-l)/2:p(o,"linksTo"),f=d;c>u&&([c,u]=[u,c]),r.reversed&&([c,u]=[u,c],f=(s.plotSizeY||0)-f),t.shapeType="path",t.linkBase=[c,c+l,u,u+l];let m=(u+l-c)/Math.abs(u+l-c)*(0,n.pick)(r.linkRadius,Math.min(Math.abs(u+l-c)/2,e.nodeY-Math.abs(l)));t.shapeArgs={d:[["M",c,f],["A",(u+l-c)/2,m,0,0,1,u+l,f],["L",u,f],["A",(u-c-l)/2,m-l,0,0,0,c+l,f],["Z"]]},t.dlBox={x:c+(u-c)/2,y:f-m,height:l,width:0},t.tooltipPos=s.inverted?[(s.plotSizeY||0)-t.dlBox.y-l/2,(s.plotSizeX||0)-t.dlBox.x]:[t.dlBox.x,t.dlBox.y+l/2],t.y=t.plotY=1,t.x=t.plotX=1,t.color||(t.color=e.color)}translateNode(t,e){let o=this.translationFactor,s=this.chart,i=s.inverted?s.plotWidth:s.plotHeight,a=this.options,r=Math.min(s.plotWidth,s.plotHeight,i/t.series.nodes.length-this.nodePadding),l=t.getSum()*(e.sankeyColumn.scale||0),h=a.equalNodes?r:Math.max(l*o,this.options.minLinkWidth||0),d=a.marker?.lineWidth||0,p=e.sankeyColumn.offset(t,o),c=(0,n.crisp)((0,n.pick)(p&&p.absoluteLeft,(e.sankeyColumn.left(o)||0)+(p&&p.relativeLeft||0)),d),u=(0,n.merge)(a.marker,t.options.marker),f=u.symbol,m=u.radius,g=parseInt(a.offset??"100",10)*((s.inverted?s.plotWidth:s.plotHeight)-((0,n.crisp)(this.colDistance*(t.column||0)+(u.lineWidth||0)/2,d)+(e.sankeyColumn.scale||0)*(e.sankeyColumn.maxRadius||0)/2))/100;if(t.sum=l,l){t.nodeX=c,t.nodeY=g;let e=t.options.width||a.width||h,o=t.options.height||a.height||h,i=g;a.reversed&&(i=(s.plotSizeY||0)-g,s.inverted&&(i=(s.plotSizeY||0)-g)),this.mapOptionsToLevel&&(t.dlOptions={...C.getDLOptions({level:this.mapOptionsToLevel[t.level],optionsPoint:t.options}),zIndex:void 0},delete t.dlOptions.zIndex),t.plotX=1,t.plotY=1,t.tooltipPos=s.inverted?[(s.plotSizeY||0)-i-o/2,(s.plotSizeX||0)-c-e/2]:[c+e/2,i+o/2],t.shapeType="path",t.shapeArgs={d:N[f||"circle"](c,i-(m||o)/2,m||e,m||o),width:m||e,height:m||o},t.dlBox={x:c+e/2,y:i,height:0,width:0}}else t.dlOptions={enabled:!1}}drawDataLabels(){if(this.options.dataLabels){let t=this.options.dataLabels.textPath;T.prototype.drawDataLabels.call(this,this.nodes),this.options.dataLabels.textPath=this.options.dataLabels.linkTextPath,T.prototype.drawDataLabels.call(this,this.data),this.options.dataLabels.textPath=t}}pointAttribs(t,e){if(t&&t.isNode){let{...t}=x().prototype.pointAttribs.apply(this,arguments);return t}return super.pointAttribs.apply(this,arguments)}markerAttribs(t){return t.isNode?super.markerAttribs.apply(this,arguments):{}}}M.defaultOptions=(0,n.merge)(C.defaultOptions,{centeredLinks:!1,equalNodes:!1,dataLabels:{linkTextPath:{attributes:{startOffset:"25%"}}},marker:{fillOpacity:1,lineWidth:0,states:{},symbol:"circle"},offset:"100%",reversed:!1}),(0,n.extend)(M.prototype,{orderNodes:!1}),M.prototype.pointClass=u,l().registerSeriesType("arcdiagram",M);let W=a();export{W as default};