/**
 * Highcharts JS v13.0.0 (2026-06-11)
 * @module highcharts/modules/dependency-wheel
 * @requires highcharts
 * @requires highcharts/modules/sankey
 *
 * Dependency wheel 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 t from"../highcharts.js";var e,a,o={};o.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return o.d(e,{a:e}),e},o.d=(t,e)=>{for(var a in e)o.o(e,a)&&!o.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:e[a]})},o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let i=t.default;var n=o.n(i);let r=t.default.SeriesRegistry;var s=o.n(r);let{sankey:{prototype:{pointClass:h}}}=s().seriesTypes,l=class extends h{getSumTo(){let t=0;for(let e of this.linksFrom)t+=e.weightTo||e.weight||0;for(let e of this.linksTo)t+=e.weight||0;return t}getDataLabelPath(t){let e=this,a=e.series.chart.renderer,o=e.shapeArgs,n=e.angle<0||e.angle>Math.PI,r=o.start||0,s=o.end||0;return e.dataLabelPath?(e.dataLabelPath=e.dataLabelPath.destroy(),delete e.dataLabelPath):(0,i.wrap)(t,"destroy",function(t){return e.dataLabelPath&&(e.dataLabelPath=e.dataLabelPath.destroy()),t.call(this)}),e.dataLabelPath=a.arc({open:!0,longArc:Math.abs(Math.abs(r)-Math.abs(s))<Math.PI?0:1}).attr({x:o.x,y:o.y,r:(o.r||0)+(0,i.pInt)(t.options?.distance||0),start:n?r:s,end:n?s:r,clockwise:+n}).add(a.defs),e.dataLabelPath}isValid(){return!0}};var d=a||(a={});d.compose=function(t,e){return t.sankeyColumn=new p(t,e),t};class p{constructor(t,e){this.points=t,this.series=e}getTranslationFactor(t){let e=this.points,a=e.slice(),o=t.chart,i=t.options.minLinkWidth||0,n,r=0,s,h=(o.plotSizeY||0)-(t.options.borderWidth||0)-(e.length-1)*t.nodePadding;for(;e.length;){for(r=h/e.sankeyColumn.sum(),n=!1,s=e.length;s--;)e[s].getSum()*r<i&&(e.splice(s,1),h=Math.max(0,h-i),n=!0);if(!n)break}for(let t of(e.length=0,a))e.push(t);return r}top(t){let e=this.series,a=e.nodePadding,o=this.points.reduce((o,i)=>(o>0&&(o+=a),o+=Math.max(i.getSum()*t,e.options.minLinkWidth||0)),0);return(0,i.getAlignFactor)(e.options.nodeAlignment||"center")*((e.chart.plotSizeY||0)-o)}left(t){let e=this.series,a=e.chart,o=e.options.equalNodes,i=a.inverted?a.plotHeight:a.plotWidth,n=e.nodePadding,r=this.points.reduce((a,r)=>(a>0&&(a+=n),a+=o?i/r.series.nodes.length-n:Math.max(r.getSum()*t,e.options.minLinkWidth||0)),0);return((a.plotSizeX||0)-Math.round(r))/2}sum(){return this.points.reduce((t,e)=>t+e.getSum(),0)}offset(t,e){let a=this.points,o=this.series,n=o.nodePadding,r=0,s;if(o.is("organization")&&t.hangsFrom)return{absoluteTop:t.hangsFrom.nodeY};for(let h=0;h<a.length;h++){let l=a[h].getSum(),d=Math.max(l*e,o.options.minLinkWidth||0),p=t.options[o.chart.inverted?"offsetHorizontal":"offsetVertical"],c=t.options.offset||0;if(s=l?d+n:0,a[h]===t)return{relativeTop:r+((0,i.defined)(p)?(0,i.relativeLength)(p,d):(0,i.relativeLength)(c,s))};r+=s}}}d.SankeyColumnAdditions=p;let c=a,g=t.default.SVGElement;var u=o.n(g);let{composed:f,deg2rad:m}=n(),{animObject:y}=n(),{deg2rad:x}=n(),{pie:b,sankey:P}=s().seriesTypes;e=u(),(0,i.pushUnique)(f,"TextPath")&&((0,i.addEvent)(e,"afterGetBBox",function(t){let e=t.bBox,a=this.element?.querySelector("textPath");if(a){let t=[],{b:o,h:i}=this.renderer.fontMetrics(this.element),n=i-o,r=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),s=a.innerHTML.replace(r,"").split(/<tspan class="highcharts-br"[^>]*>/),h=s.length,l=(t,e)=>{let{x:i,y:r}=e,s=(a.getRotationOfChar(t)-90)*m,h=Math.cos(s),l=Math.sin(s);return[[i-n*h,r-n*l],[i+o*h,r+o*l]]};for(let e=0,o=0;o<h;o++){let i=s[o].length;for(let n=0;n<i;n+=5)try{let i=e+n+o,[r,s]=l(i,a.getStartPositionOfChar(i));0===n?(t.push(s),t.push(r)):(0===o&&t.unshift(s),o===h-1&&t.push(r))}catch{break}e+=i-1;try{let i=e+o,n=a.getEndPositionOfChar(i),[r,s]=l(i,n);t.unshift(s),t.unshift(r)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}),(0,i.addEvent)(e,"beforeAddingDataLabel",function(t){let e=t.labelOptions,a=t.point,o=e[a.formatPrefix+"TextPath"]||e.textPath;o&&!e.useHTML&&(this.setTextPath(a.getDataLabelPath?.(this)||a.graphic,o),a.dataLabelPath&&!o.enabled&&(a.dataLabelPath=a.dataLabelPath.destroy()))}),e.prototype.setTextPath=e.prototype.setTextPath??function(t,e){let a=this.renderer.url,o=this.text||this,n=o.textPath,{attributes:r,enabled:s}=(0,i.merge)({enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);if(t=t||n&&n.path,n?.undo(),t&&s){let e=(0,i.addEvent)(o,"afterModifyTree",e=>{if(t&&s){let n=t.attr("id");n||t.attr("id",n=(0,i.uniqueKey)());let s={x:0,y:0};(0,i.defined)(r.dx)&&(s.dx=r.dx,delete r.dx),(0,i.defined)(r.dy)&&(s.dy=r.dy,delete r.dy),o.attr(s),this.attr({transform:""}),this.box&&(this.box=this.box.destroy());let h=e.nodes.slice(0);e.nodes.length=0,e.nodes[0]={tagName:"textPath",attributes:(0,i.extend)(r,{"text-anchor":r.textAnchor,href:`${a}#${n}`}),children:h}}});o.textPath={path:t,undo:e}}else o.attr({dx:0,dy:0}),delete o.textPath;return this.added&&(o.textCache="",this.renderer.buildText(o)),this});class T extends P{animate(t){if(!t){let t=y(this.options.animation).duration/2/this.nodes.length,e=0;for(let a of this.nodes){let o=a.graphic;o&&(o.attr({opacity:0}),setTimeout(()=>{a.graphic&&a.graphic.animate({opacity:1},{duration:t})},t*e++))}for(let t of this.points){let e=t.graphic;!t.isNode&&e&&e.attr({opacity:0}).animate({opacity:1},this.options.animation)}}}createNode(t){let e=super.createNode(t);return e.getSum=()=>{let t=0;for(let a of e.linksFrom)t+=a.weight||0;for(let a of e.linksTo)t+=a.weightTo||a.weight||0;return t},e.offset=t=>{let a=t=>t.fromNode===e?t.toNode:t.fromNode,o=0,i=e.linksFrom.concat(e.linksTo),n;i.sort((t,e)=>a(t).index-a(e).index);for(let t=0;t<i.length;t++)if(a(i[t]).index>e.index){i=i.slice(0,t).reverse().concat(i.slice(t).reverse()),n=!0;break}n||i.reverse();for(let a=0;a<i.length;a++){if(i[a]===t)return o;let n=i[a].weight||0;o+=i[a].to===e.id&&i[a].weightTo||n}},e}createNodeColumns(){let t=[c.compose([],this)];for(let e of this.nodes)e.column=0,t[0].push(e);return t}getNodePadding(){return this.options.nodePadding/Math.PI}translate(){let t=this.options,e=2*Math.PI/(this.chart.plotHeight+this.getNodePadding()),a=this.getCenter(),o=((t.startAngle||0)-90)*x,n=t.borderRadius,r="object"==typeof n?n.radius:n;for(let n of(super.translate(),this.nodeColumns[0]))if(n.sum){let s=n.shapeArgs,h=a[0],l=a[1],d=a[2]/2,p="auto"===t.nodeWidth?20:t.nodeWidth,c=d-(0,i.relativeLength)(p||0,d),g=o+e*(s.y||0),u=o+e*((s.y||0)+(s.height||0));for(let a of(n.angle=g+(u-g)/2,n.shapeType="arc",n.shapeArgs={x:h,y:l,r:d,innerR:c,start:g,end:u,borderRadius:r},n.dlBox={x:h+Math.cos((g+u)/2)*(d+c)/2,y:l+Math.sin((g+u)/2)*(d+c)/2,width:1,height:1},n.linksFrom))if(a.linkBase){let i,n,r=a.linkBase.map((r,s)=>{let d=e*r,p=Math.cos(o+d)*(c+1),g=Math.sin(o+d)*(c+1);return i=t.curveFactor||0,(n=Math.abs(a.linkBase[3-s]*e-d))>Math.PI&&(n=2*Math.PI-n),(n*=c)<c&&(i*=n/c),{x:h+p,y:l+g,cpX:h+(1-i)*p,cpY:l+(1-i)*g}});a.shapeArgs={d:[["M",r[0].x,r[0].y],["A",c,c,0,0,1,r[1].x,r[1].y],["C",r[1].cpX,r[1].cpY,r[2].cpX,r[2].cpY,r[2].x,r[2].y],["A",c,c,0,0,1,r[3].x,r[3].y],["C",r[3].cpX,r[3].cpY,r[0].cpX,r[0].cpY,r[0].x,r[0].y]]}}}}translateLink(t){let e=Math.max((t.weightTo||t.weight||0)*this.translationFactor,this.options.minLinkWidth||0),a=this.getY(t,t.toNode,"linksTo",e);super.translateLink(t,a),t.linkBase[3]=a+e}translateNode(t,e){super.translateNode(t,e),t.sumTo=t.getSumTo()}}T.defaultOptions=(0,i.merge)(P.defaultOptions,{center:[null,null],curveFactor:.6,startAngle:0,dataLabels:{allowOverlap:!0,textPath:{enabled:!1,attributes:{dy:5}}},tooltip:{pointFormat:"{point.fromNode.name} → {point.toNode.name}: <b>{point.weight}</b><br/>{#if point.weightTo}{point.toNode.name} → {point.fromNode.name}: <b>{point.weightTo}</b><br/>{/if}"}}),(0,i.extend)(T.prototype,{orderNodes:!1,pointArrayMap:["from","to","weight","weightTo"],getCenter:b.prototype.getCenter}),T.prototype.pointClass=l,s().registerSeriesType("dependencywheel",T);let k=n();export{k as default};