/**
 * Highcharts JS v12.6.0 (2026-04-13)
 * @module highcharts/modules/networkgraph
 * @requires highcharts
 *
 * Force directed graph 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,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 o=t.default;var s=i.n(o);let r=t.default.SVGElement;var n=i.n(r);let{doc:a,win:h}=s();function l(t,e,i,o={}){let r="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(r,"hcEvents")||(r.hcEvents={});let n=r.hcEvents;s().Point&&t instanceof s().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,i,!!s().supportsPassiveEvents&&{passive:void 0===o.passive?-1!==e.indexOf("touch"):o.passive,capture:!1}),n[e]||(n[e]=[]);let h={fn:i,order:"number"==typeof o.order?o.order:1/0};return n[e].push(h),n[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,i){function o(e,i){let o=t.removeEventListener;o&&o.call(t,e,i,!1)}function s(i){let s,r;t.nodeName&&(e?(s={})[e]=!0:s=i,g(s,function(t,e){if(i[e])for(r=i[e].length;r--;)o(e,i[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];i?(t[e]=r.filter(function(t){return i!==t.fn}),o(e,i)):(s(t),t[e]=[])}else s(t),delete r.hcEvents}}(t,e,i)}}function d(t){return null!=t}function p(t,e){let i;for(i in t||(t={}),e)t[i]=e[i];return t}let c=Array.prototype.find?function(t,e){return t.find(e)}:function(t,e){let i,o=t.length;for(i=0;i<o;i++)if(e(t[i],i))return t[i]};function u(t){return f(t)&&"number"==typeof t.nodeType}function f(t,e){let i;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(i=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==i)}function m(t,...e){let i,o=[t,...e],s={},r=function(t,e){return"object"!=typeof t&&(t={}),g(e,function(i,o){if("__proto__"!==o&&"constructor"!==o){let s;!f(i,!0)||(s=i?.constructor,f(i,!0)&&!u(i)&&s?.name&&"Object"!==s.name)||u(i)?t[o]=e[o]:t[o]=r(t[o]||{},i)}}),t};!0===t&&(s=o[1],o=Array.prototype.slice.call(o,2));let n=o.length;for(i=0;i<n;i++)s=r(s,o[i]);return s}function g(t,e,i){for(let o in t)Object.hasOwnProperty.call(t,o)&&e.call(i||t[o],t[o],o,t)}function y(){let t=arguments,e=t.length;for(let i=0;i<e;i++){let e=t[i];if(null!=e)return e}}function b(t,e){return 0>t.indexOf(e)&&!!t.push(e)}let{composed:x}=s();function v(){let t,e,i,o,s=this;s.container&&(t=l(s.container,"mousedown",t=>{e&&e(),i&&i(),(o=s.hoverPoint)&&o.series&&o.series.hasDraggableNodes&&o.series.options.draggable&&(o.series.onMouseDown(o,t),e=l(s.container,"mousemove",t=>o&&o.series&&o.series.onMouseMove(o,t)),i=l(s.container.ownerDocument,"mouseup",t=>(e(),i(),o&&o.series&&o.series.onMouseUp(o,t))))})),l(s,"destroy",function(){t()})}let k={compose:function(t){b(x,"DragNodes")&&l(t,"load",v)},onMouseDown:function(t,e){let{panKey:i}=this.chart.options.chart;if(i&&e[`${i}Key`])return;let o=this.chart.pointer?.normalize(e)||e;t.fixedPosition={chartX:o.chartX,chartY:o.chartY,plotX:t.plotX,plotY:t.plotY},t.inDragMode=!0},onMouseMove:function(t,e){if(t.fixedPosition&&t.inDragMode){let i,o,s=this.chart,r=s.pointer?.normalize(e)||e,n=t.fixedPosition.chartX-r.chartX,a=t.fixedPosition.chartY-r.chartY,h=s.graphLayoutsLookup;(Math.abs(n)>5||Math.abs(a)>5)&&(i=t.fixedPosition.plotX-n,o=t.fixedPosition.plotY-a,s.isInsidePlot(i,o)&&(t.plotX=i,t.plotY=o,t.hasDragged=!0,this.redrawHalo(t),h.forEach(t=>{t.restartSimulation()})))}},onMouseUp:function(t){t.fixedPosition&&(t.hasDragged&&(this.layout.enableSimulation?this.layout.start():this.chart.redraw()),t.inDragMode=t.hasDragged=!1,this.options.fixedDraggable||delete t.fixedPosition)},redrawHalo:function(t){t&&this.halo&&this.halo.attr({d:t.haloPath(this.options.states.hover.halo.size)})}},{setAnimation:N}=s(),{composed:L}=s();function P(){this.graphLayoutsLookup&&(this.graphLayoutsLookup.forEach(t=>{t.updateSimulation()}),this.redraw())}function w(){this.graphLayoutsLookup&&(this.graphLayoutsLookup.forEach(t=>{t.updateSimulation(!1)}),this.redraw())}function E(){this.graphLayoutsLookup&&this.graphLayoutsLookup.forEach(t=>{t.stop()})}function S(){let t,e=!1,i=i=>{i.maxIterations--&&isFinite(i.temperature)&&!i.isStable()&&!i.enableSimulation&&(i.beforeStep&&i.beforeStep(),i.step(),t=!1,e=!0)};if(this.graphLayoutsLookup&&!this.pointer?.hasDragged){for(N(!1,this),this.graphLayoutsLookup.forEach(t=>t.start());!t;)t=!0,this.graphLayoutsLookup.forEach(i);e&&this.series.forEach(t=>{t&&t.layout&&t.render()})}}let M=function(t){b(L,"GraphLayout")&&(l(t,"afterPrint",P),l(t,"beforePrint",w),l(t,"predraw",E),l(t,"render",S))},T={},X={},Y=t.default.SeriesRegistry;var D=i.n(Y);let{series:{prototype:F,prototype:{pointClass:{prototype:O}}}}=D();!function(t){function e(){return this.data=[].concat(this.points||[],this.nodes),F.destroy.apply(this,arguments)}function i(){this.nodes&&(this.nodes.forEach(t=>{t.destroy()}),this.nodes.length=0),F.setData.apply(this,arguments)}function o(t){let e=arguments,i=this.isNode?this.linksTo.concat(this.linksFrom):[this.fromNode,this.toNode];"select"!==t&&i.forEach(t=>{t&&t.series&&(O.setState.apply(t,e),!t.isNode&&(t.fromNode.graphic&&O.setState.apply(t.fromNode,e),t.toNode&&t.toNode.graphic&&O.setState.apply(t.toNode,e)))}),O.setState.apply(this,e)}function s(t,e,i,o){let s=this.series.options.nodes,r=this.series.options.data,n=r?.length||0,a=r?.[this.index];if(O.update.call(this,t,!this.isNode&&e,i,o),this.isNode){let t=(s||[]).reduce((t,e,i)=>this.id===e.id?i:t,-1),o=m(s&&s[t]||{},r?.[this.index]||{});r&&(a?r[this.index]=a:r.length=n),s?t>=0?s[t]=o:s.push(o):this.series.options.nodes=[o],y(e,!0)&&this.series.chart.redraw(i)}}t.compose=function(t,r){let n=t.prototype,a=r.prototype;return n.setNodeState=o,n.setState=o,n.update=s,a.destroy=e,a.setData=i,r},t.createNode=function(t){let e=this.pointClass,i=(t,e)=>c(t,t=>t.id===e),o=i(this.nodes,t),s;if(!o){s=this.options.nodes&&i(this.options.nodes,t);let r=new e(this,p({className:"highcharts-node",isNode:!0,id:t,y:1},s));r.linksTo=[],r.linksFrom=[],r.getSum=function(){let t=0,e=0;return r.linksTo.forEach(e=>{t+=e.weight||0}),r.linksFrom.forEach(t=>{e+=t.weight||0}),Math.max(t,e)},r.offset=function(t,e){let i=0;for(let o=0;o<r[e].length;o++){if(r[e][o]===t)return i;i+=r[e][o].weight}},r.hasShape=function(){let t=0;return r.linksTo.forEach(e=>{e.outgoing&&t++}),!r.linksTo.length||t!==r.linksTo.length},r.index=this.nodes.push(r)-1,o=r}return o.formatPrefix="node",o.name=o.name||o.options.id||"",o.mass=y(o.options.mass,o.options.marker&&o.options.marker.radius,this.options.marker&&this.options.marker.radius,4),o},t.destroy=e,t.generatePoints=function(){let t=this.chart,e={};F.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(i=>{d(i.from)&&(e[i.from]||(e[i.from]=this.createNode(i.from)),e[i.from].linksFrom.push(i),i.fromNode=e[i.from],t.styledMode?i.colorIndex=y(i.options.colorIndex,e[i.from].colorIndex):i.color=i.options.color||e[i.from].color),d(i.to)&&(e[i.to]||(e[i.to]=this.createNode(i.to)),e[i.to].linksTo.push(i),i.toNode=e[i.to]),i.name=i.name||i.id},this),this.nodeLookup=e},t.setNodeState=o,t.updateNode=s}(e||(e={}));let C=e,{series:{prototype:A,prototype:{pointClass:I}}}=D();class R extends I{destroy(){return this.isNode&&this.linksFrom.concat(this.linksTo).forEach(function(t){t.destroyElements&&t.destroyElements()}),this.series.layout.removeElementFromCollection(this,this.series.layout[this.isNode?"nodes":"links"]),I.prototype.destroy.apply(this,arguments)}getDegree(){let t=this.isNode?this.linksFrom.length+this.linksTo.length:0;return 0===t?1:t}getLinkAttributes(){let t=this.series.options.link,e=this.options;return{"stroke-width":y(e.width,t.width),stroke:e.color||t.color,dashstyle:e.dashStyle||t.dashStyle,opacity:y(e.opacity,t.opacity,1)}}getLinkPath(){let t=this.fromNode,e=this.toNode;return t.plotX>e.plotX&&(t=this.toNode,e=this.fromNode),[["M",t.plotX||0,t.plotY||0],["L",e.plotX||0,e.plotY||0]]}getMass(){let t=this.fromNode.mass,e=this.toNode.mass,i=t+e;return{fromNode:1-t/i,toNode:1-e/i}}constructor(t,e,i){super(t,e,i),this.series.options.draggable&&!this.series.chart.styledMode&&(l(this,"mouseOver",function(){var t;t=this.series.chart.container,p(t.style,{cursor:"move"})}),l(this,"mouseOut",function(){var t;t=this.series.chart.container,p(t.style,{cursor:"default"})}))}isValid(){return!this.isNode||d(this.id)}redrawLink(){let t,e=this.getLinkPath();if(this.graphic){this.shapeArgs={d:e},this.series.chart.styledMode||(t=this.series.pointAttribs(this),this.graphic.attr(t),(this.dataLabels||[]).forEach(function(e){e&&e.attr({opacity:t.opacity})})),this.graphic.animate(this.shapeArgs);let i=e[0],o=e[1];"M"===i[0]&&"L"===o[0]&&(this.plotX=(i[1]+o[1])/2,this.plotY=(i[2]+o[2])/2)}}remove(t,e){let i=this.series,o=i.options.nodes||[],s,r=o.length;if(this.isNode){for(i.points=[],[].concat(this.linksFrom).concat(this.linksTo).forEach(function(t){(s=t.fromNode.linksFrom.indexOf(t))>-1&&t.fromNode.linksFrom.splice(s,1),(s=t.toNode.linksTo.indexOf(t))>-1&&t.toNode.linksTo.splice(s,1),A.removePoint.call(i,i.data.indexOf(t),!1,!1)}),i.points=i.data.slice(),i.nodes.splice(i.nodes.indexOf(this),1);r--;)if(o[r].id===this.options.id){i.options.nodes.splice(r,1);break}this&&this.destroy(),i.isDirty=!0,i.isDirtyData=!0,t&&i.chart.redraw(t)}else i.removePoint(i.data.indexOf(this),t,e)}renderLink(){let t;!this.graphic&&(this.graphic=this.series.chart.renderer.path(this.getLinkPath()).addClass(this.getClassName(),!0).add(this.series.group),this.series.chart.styledMode||(t=this.series.pointAttribs(this),this.graphic.attr(t),(this.dataLabels||[]).forEach(function(e){e&&e.attr({opacity:t.opacity})})))}}p(R.prototype,{setState:C.setNodeState});let B={attractive:function(t,e,i,o){let s=t.getMass(),r=i.x/o*e,n=i.y/o*e;t.fromNode.fixedPosition||(t.fromNode.dispX-=r*s.fromNode/t.fromNode.degree,t.fromNode.dispY-=n*s.fromNode/t.fromNode.degree),t.toNode.fixedPosition||(t.toNode.dispX+=r*s.toNode/t.toNode.degree,t.toNode.dispY+=n*s.toNode/t.toNode.degree)},attractiveForceFunction:function(t,e){return t*t/e},barycenter:function(){let t=this.options.gravitationalConstant,e=this.barycenter.xFactor,i=this.barycenter.yFactor;this.nodes.forEach(function(o){if(!o.fixedPosition){let s=o.getDegree(),r=s*(1+s/2);o.dispX+=(e-o.plotX)*t*r/o.degree,o.dispY+=(i-o.plotY)*t*r/o.degree}})},getK:function(t){return Math.pow(t.box.width*t.box.height/t.nodes.length,.3)},integrate:function(t,e){e.dispX+=e.dispX*t.options.friction,e.dispY+=e.dispY*t.options.friction;let i=e.temperature=t.vectorLength({x:e.dispX,y:e.dispY});0!==i&&(e.plotX+=e.dispX/i*Math.min(Math.abs(e.dispX),t.temperature),e.plotY+=e.dispY/i*Math.min(Math.abs(e.dispY),t.temperature))},repulsive:function(t,e,i,o){t.dispX+=i.x/o*e/t.degree,t.dispY+=i.y/o*e/t.degree},repulsiveForceFunction:function(t,e){return e*e/t}};class j{constructor(t){this.body=!1,this.isEmpty=!1,this.isInternal=!1,this.nodes=[],this.box=t,this.boxSize=Math.min(t.width,t.height)}divideBox(){let t=this.box.width/2,e=this.box.height/2;this.nodes[0]=new j({left:this.box.left,top:this.box.top,width:t,height:e}),this.nodes[1]=new j({left:this.box.left+t,top:this.box.top,width:t,height:e}),this.nodes[2]=new j({left:this.box.left+t,top:this.box.top+e,width:t,height:e}),this.nodes[3]=new j({left:this.box.left,top:this.box.top+e,width:t,height:e})}getBoxPosition(t){let e=t.plotX<this.box.left+this.box.width/2,i=t.plotY<this.box.top+this.box.height/2;return e?3*!i:i?1:2}insert(t,e){let i;this.isInternal?this.nodes[this.getBoxPosition(t)].insert(t,e-1):(this.isEmpty=!1,this.body?e?(this.isInternal=!0,this.divideBox(),!0!==this.body&&(this.nodes[this.getBoxPosition(this.body)].insert(this.body,e-1),this.body=!0),this.nodes[this.getBoxPosition(t)].insert(t,e-1)):((i=new j({top:t.plotX||NaN,left:t.plotY||NaN,width:.1,height:.1})).body=t,i.isInternal=!1,this.nodes.push(i)):(this.isInternal=!1,this.body=t))}updateMassAndCenter(){let t=0,e=0,i=0;if(this.isInternal){for(let o of this.nodes)o.isEmpty||(t+=o.mass,e+=o.plotX*o.mass,i+=o.plotY*o.mass);e/=t,i/=t}else this.body&&(t=this.body.mass,e=this.body.plotX,i=this.body.plotY);this.mass=t,this.plotX=e,this.plotY=i}}let G=class{constructor(t,e,i,o){this.box={left:t,top:e,width:i,height:o},this.maxDepth=25,this.root=new j(this.box),this.root.isInternal=!0,this.root.isRoot=!0,this.root.divideBox()}calculateMassAndCenter(){this.visitNodeRecursive(null,null,function(t){t.updateMassAndCenter()})}insertNodes(t){for(let e of t)this.root.insert(e,this.maxDepth)}visitNodeRecursive(t,e,i){let o;if(t||(t=this.root),t===this.root&&e&&(o=e(t)),!1!==o){for(let s of t.nodes){if(s.isInternal){if(e&&(o=e(s)),!1===o)continue;this.visitNodeRecursive(s,e,i)}else s.body&&e&&e(s.body);i&&i(s)}t===this.root&&i&&i(t)}}},q={attractive:function(t,e,i){let o=t.getMass(),s=-i.x*e*this.diffTemperature,r=-i.y*e*this.diffTemperature;t.fromNode.fixedPosition||(t.fromNode.plotX-=s*o.fromNode/t.fromNode.degree,t.fromNode.plotY-=r*o.fromNode/t.fromNode.degree),t.toNode.fixedPosition||(t.toNode.plotX+=s*o.toNode/t.toNode.degree,t.toNode.plotY+=r*o.toNode/t.toNode.degree)},attractiveForceFunction:function(t,e){return(e-t)/t},barycenter:function(){let t=this.options.gravitationalConstant||0,e=(this.barycenter.xFactor-(this.box.left+this.box.width)/2)*t,i=(this.barycenter.yFactor-(this.box.top+this.box.height)/2)*t;this.nodes.forEach(function(t){t.fixedPosition||(t.plotX-=e/t.mass/t.degree,t.plotY-=i/t.mass/t.degree)})},getK:function(t){return Math.pow(t.box.width*t.box.height/t.nodes.length,.5)},integrate:function(t,e){let i=-t.options.friction,o=t.options.maxSpeed,s=e.prevX,r=e.prevY,n=(e.plotX+e.dispX-s)*i,a=(e.plotY+e.dispY-r)*i,h=Math.abs,l=h(n)/(n||1),d=h(a)/(a||1),p=l*Math.min(o,Math.abs(n)),c=d*Math.min(o,Math.abs(a));e.prevX=e.plotX+e.dispX,e.prevY=e.plotY+e.dispY,e.plotX+=p,e.plotY+=c,e.temperature=t.vectorLength({x:p,y:c})},repulsive:function(t,e,i){let o=e*this.diffTemperature/t.mass/t.degree;t.fixedPosition||(t.plotX+=i.x*o,t.plotY+=i.y*o)},repulsiveForceFunction:function(t,e){return(e-t)/t*(e>t)}},{win:H}=s();class K{constructor(){this.box={},this.currentStep=0,this.initialRendering=!0,this.links=[],this.nodes=[],this.series=[],this.simulation=!1}static compose(t){M(t),T.euler=B,T.verlet=q,X["reingold-fruchterman"]=K}init(t){this.options=t,this.nodes=[],this.links=[],this.series=[],this.box={x:0,y:0,width:0,height:0},this.setInitialRendering(!0),this.integration=T[t.integration],this.enableSimulation=t.enableSimulation,this.attractiveForce=y(t.attractiveForce,this.integration.attractiveForceFunction),this.repulsiveForce=y(t.repulsiveForce,this.integration.repulsiveForceFunction),this.approximation=t.approximation}updateSimulation(t){this.enableSimulation=y(t,this.options.enableSimulation)}start(){let t=this.series,e=this.options;this.currentStep=0,this.forces=t[0]&&t[0].forces||[],this.chart=t[0]&&t[0].chart,this.initialRendering&&(this.initPositions(),t.forEach(function(t){t.finishedAnimating=!0,t.render()})),this.setK(),this.resetSimulation(e),this.enableSimulation&&this.step()}step(){let t=this.series;for(let t of(this.currentStep++,"barnes-hut"===this.approximation&&(this.createQuadTree(),this.quadTree.calculateMassAndCenter()),this.forces||[]))this[t+"Forces"](this.temperature);if(this.applyLimits(),this.temperature=this.coolDown(this.startTemperature,this.diffTemperature,this.currentStep),this.prevSystemTemperature=this.systemTemperature,this.systemTemperature=this.getSystemTemperature(),this.enableSimulation){for(let e of t)e.chart&&e.render();this.maxIterations--&&isFinite(this.temperature)&&!this.isStable()?(this.simulation&&H.cancelAnimationFrame(this.simulation),this.simulation=H.requestAnimationFrame(()=>this.step())):(this.simulation=!1,this.series.forEach(t=>{!function(t,e,i,o){if(i=i||{},a?.createEvent&&(t.dispatchEvent||t.fireEvent&&t!==s())){let o=a.createEvent("Events");o.initEvent(e,!0,!0),i=p(o,i),t.dispatchEvent?t.dispatchEvent(i):t.fireEvent(e,i)}else if(t.hcEvents){i.target||p(i,{preventDefault:function(){i.defaultPrevented=!0},target:t,type:e});let o=[],s=t,r=!1;for(;s.hcEvents;)Object.hasOwnProperty.call(s,"hcEvents")&&s.hcEvents[e]&&(o.length&&(r=!0),o.unshift.apply(o,s.hcEvents[e])),s=Object.getPrototypeOf(s);r&&o.sort((t,e)=>t.order-e.order),o.forEach(e=>{!1===e.fn.call(t,i,t)&&i.preventDefault()})}}(t,"afterSimulation")}))}}stop(){this.simulation&&H.cancelAnimationFrame(this.simulation)}setArea(t,e,i,o){this.box={left:t,top:e,width:i,height:o}}setK(){this.k=this.options.linkLength||this.integration.getK(this)}addElementsToCollection(t,e){for(let i of t)-1===e.indexOf(i)&&e.push(i)}removeElementFromCollection(t,e){let i=e.indexOf(t);-1!==i&&e.splice(i,1)}clear(){this.nodes.length=0,this.links.length=0,this.series.length=0,this.resetSimulation()}resetSimulation(){this.forcedStop=!1,this.systemTemperature=0,this.setMaxIterations(),this.setTemperature(),this.setDiffTemperature()}restartSimulation(){this.simulation?this.resetSimulation():(this.setInitialRendering(!1),this.enableSimulation?this.start():this.setMaxIterations(1),this.chart&&this.chart.redraw(),this.setInitialRendering(!0))}setMaxIterations(t){this.maxIterations=y(t,this.options.maxIterations)}setTemperature(){this.temperature=this.startTemperature=Math.sqrt(this.nodes.length)}setDiffTemperature(){this.diffTemperature=this.startTemperature/(this.options.maxIterations+1)}setInitialRendering(t){this.initialRendering=t}createQuadTree(){this.quadTree=new G(this.box.left,this.box.top,this.box.width,this.box.height),this.quadTree.insertNodes(this.nodes)}initPositions(){let t=this.options.initialPositions;if("function"==typeof t)for(let e of(t.call(this),this.nodes))d(e.prevX)||(e.prevX=e.plotX),d(e.prevY)||(e.prevY=e.plotY),e.dispX=0,e.dispY=0;else"circle"===t?this.setCircularPositions():this.setRandomPositions()}setCircularPositions(){let t,e=this.box,i=this.nodes,o=2*Math.PI/(i.length+1),s=i.filter(function(t){return 0===t.linksTo.length}),r={},n=this.options.initialPositionRadius,a=t=>{for(let e of t.linksFrom||[])r[e.toNode.id]||(r[e.toNode.id]=!0,h.push(e.toNode),a(e.toNode))},h=[];for(let t of s)h.push(t),a(t);if(h.length)for(let t of i)-1===h.indexOf(t)&&h.push(t);else h=i;for(let i=0,s=h.length;i<s;++i)(t=h[i]).plotX=t.prevX=y(t.plotX,e.width/2+n*Math.cos(i*o)),t.plotY=t.prevY=y(t.plotY,e.height/2+n*Math.sin(i*o)),t.dispX=0,t.dispY=0}setRandomPositions(){let t,e=this.box,i=this.nodes,o=i.length+1,s=t=>{let e=t*t/Math.PI;return e-Math.floor(e)};for(let r=0,n=i.length;r<n;++r)(t=i[r]).plotX=t.prevX=y(t.plotX,e.width*s(r)),t.plotY=t.prevY=y(t.plotY,e.height*s(o+r)),t.dispX=0,t.dispY=0}force(t,...e){this.integration[t].apply(this,e)}barycenterForces(){this.getBarycenter(),this.force("barycenter")}getBarycenter(){let t=0,e=0,i=0;for(let o of this.nodes)e+=o.plotX*o.mass,i+=o.plotY*o.mass,t+=o.mass;return this.barycenter={x:e,y:i,xFactor:e/t,yFactor:i/t},this.barycenter}barnesHutApproximation(t,e){let i,o,s=this.getDistXY(t,e),r=this.vectorLength(s);return t!==e&&0!==r&&(e.isInternal?e.boxSize/r<this.options.theta&&0!==r?(o=this.repulsiveForce(r,this.k),this.force("repulsive",t,o*e.mass,s,r),i=!1):i=!0:(o=this.repulsiveForce(r,this.k),this.force("repulsive",t,o*e.mass,s,r))),i}repulsiveForces(){if("barnes-hut"===this.approximation)for(let t of this.nodes)this.quadTree.visitNodeRecursive(null,e=>this.barnesHutApproximation(t,e));else{let t,e,i;for(let o of this.nodes)for(let s of this.nodes)o===s||o.fixedPosition||(i=this.getDistXY(o,s),0!==(e=this.vectorLength(i))&&(t=this.repulsiveForce(e,this.k),this.force("repulsive",o,t*s.mass,i,e)))}}attractiveForces(){let t,e,i;for(let o of this.links)o.fromNode&&o.toNode&&(t=this.getDistXY(o.fromNode,o.toNode),0!==(e=this.vectorLength(t))&&(i=this.attractiveForce(e,this.k),this.force("attractive",o,i,t,e)))}applyLimits(){for(let t of this.nodes)t.fixedPosition||(this.integration.integrate(this,t),this.applyLimitBox(t,this.box),t.dispX=0,t.dispY=0)}applyLimitBox(t,e){var i,o,s,r,n,a;let h=t.radius;i=t.plotX,o=e.left+h,s=e.width-h,t.plotX=i>o?i<s?i:s:o,r=t.plotY,n=e.top+h,a=e.height-h,t.plotY=r>n?r<a?r:a:n}coolDown(t,e,i){return t-e*i}isStable(){return 1e-5>Math.abs(this.systemTemperature-this.prevSystemTemperature)||this.temperature<=0}getSystemTemperature(){let t=0;for(let e of this.nodes)t+=e.temperature;return t}vectorLength(t){return Math.sqrt(t.x*t.x+t.y*t.y)}getDistR(t,e){let i=this.getDistXY(t,e);return this.vectorLength(i)}getDistXY(t,e){let i=t.plotX-e.plotX,o=t.plotY-e.plotY;return{x:i,y:o,absX:Math.abs(i),absY:Math.abs(o)}}}let{animObject:_}=s(),{deg2rad:z}=s();function U(t,e){e=m(!0,{enabled:!0,attributes:{dy:-5,startOffset:"50%",textAnchor:"middle"}},e);let i=this.renderer.url,s=this.text||this,r=s.textPath,{attributes:n,enabled:a}=e;if(t=t||r&&r.path,r&&r.undo(),t&&a){let e=l(s,"afterModifyTree",e=>{if(t&&a){let r=t.attr("id");r||t.attr("id",r=(0,o.uniqueKey)());let a={x:0,y:0};d(n.dx)&&(a.dx=n.dx,delete n.dx),d(n.dy)&&(a.dy=n.dy,delete n.dy),s.attr(a),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:p(n,{"text-anchor":n.textAnchor,href:`${i}#${r}`}),children:h}}});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}function $(t){let e=t.bBox,i=this.element?.querySelector("textPath");if(i){let t=[],{b:o,h:s}=this.renderer.fontMetrics(this.element),r=s-o,n=RegExp('(<tspan>|<tspan(?!\\sclass="highcharts-br")[^>]*>|<\\/tspan>)',"g"),a=i.innerHTML.replace(n,"").split(/<tspan class="highcharts-br"[^>]*>/),h=a.length,l=(t,e)=>{let{x:s,y:n}=e,a=(i.getRotationOfChar(t)-90)*z,h=Math.cos(a),l=Math.sin(a);return[[s-r*h,n-r*l],[s+o*h,n+o*l]]};for(let e=0,o=0;o<h;o++){let s=a[o].length;for(let r=0;r<s;r+=5)try{let s=e+r+o,[n,a]=l(s,i.getStartPositionOfChar(s));0===r?(t.push(a),t.push(n)):(0===o&&t.unshift(a),o===h-1&&t.push(n))}catch{break}e+=s-1;try{let s=e+o,r=i.getEndPositionOfChar(s),[n,a]=l(s,r);t.unshift(a),t.unshift(n)}catch{break}}t.length&&t.push(t[0].slice()),e.polygon=t}return e}function Q(t){let e=t.labelOptions,i=t.point,o=e[i.formatPrefix+"TextPath"]||e.textPath;o&&!e.useHTML&&(this.setTextPath(i.getDataLabelPath?.(this)||i.graphic,o),i.dataLabelPath&&!o.enabled&&(i.dataLabelPath=i.dataLabelPath.destroy()))}let{noop:V}=s(),{series:W,seriesTypes:{column:{prototype:J},line:{prototype:Z}}}=D(),{initDataLabels:tt,initDataLabelsDefer:te}={initDataLabels:function(){let t=this.options.dataLabels;if(!this.dataLabelsGroup){let e=this.initDataLabelsGroup(0,t);return!this.chart.styledMode&&t?.style&&e.css(t.style),e.attr({opacity:0}),this.visible&&(this.options.animation&&t?.animation?e.animate({opacity:1},t.animation):e.attr({opacity:1}),e.show()),e}return this.dataLabelsGroup.attr({opacity:1,...this.getPlotBox("data-labels")}),this.dataLabelsGroup},initDataLabelsDefer:function(){let t=this.options.dataLabels;if(t?.defer&&this.options.layoutAlgorithm?.enableSimulation){var e,i;e=()=>{this.deferDataLabels=!1},(i=t?_(t.animation).defer:0)>0?setTimeout(e,i,void 0):e.call(0,void 0)}else this.deferDataLabels=!1}};({compose:function(t){l(t,"afterGetBBox",$),l(t,"beforeAddingDataLabel",Q);let e=t.prototype;e.setTextPath||(e.setTextPath=U)}}).compose(n());class ti extends W{constructor(){super(...arguments),this.deferDataLabels=!0}static compose(t){k.compose(t),K.compose(t)}deferLayout(){let t=this.options.layoutAlgorithm,e=this.chart.options.chart,i,o=this.chart.graphLayoutsStorage,s=this.chart.graphLayoutsLookup;this.visible&&(o||(this.chart.graphLayoutsStorage=o={},this.chart.graphLayoutsLookup=s=[]),(i=o[t.type])||(t.enableSimulation=d(e.forExport)?!e.forExport:t.enableSimulation,o[t.type]=i=new X[t.type],i.init(t),s.splice(i.index,0,i)),this.layout=i,i.setArea(0,0,this.chart.plotWidth,this.chart.plotHeight),i.addElementsToCollection([this],i.series),i.addElementsToCollection(this.nodes,i.nodes),i.addElementsToCollection(this.points,i.links))}destroy(){this.layout&&this.layout.removeElementFromCollection(this,this.layout.series),C.destroy.call(this)}drawDataLabels(){let t;if(this.deferDataLabels)return;let e=this.options.dataLabels;e?.textPath&&(t=e.textPath),W.prototype.drawDataLabels.call(this,this.nodes),e?.linkTextPath&&(e.textPath=e.linkTextPath),W.prototype.drawDataLabels.call(this,this.data),e?.textPath&&(e.textPath=t)}generatePoints(){let t,e;for(C.generatePoints.apply(this,arguments),this.options.nodes&&this.options.nodes.forEach(function(t){this.nodeLookup[t.id]||(this.nodeLookup[t.id]=this.createNode(t.id))},this),e=this.nodes.length-1;e>=0;e--)(t=this.nodes[e]).degree=t.getDegree(),t.radius=y(t.marker&&t.marker.radius,this.options.marker&&this.options.marker.radius,0),t.key=t.name,this.nodeLookup[t.id]||t.remove();this.data.forEach(function(t){t.formatPrefix="link"}),this.indexateNodes()}getPointsCollection(){return this.nodes||[]}indexateNodes(){this.nodes.forEach(function(t,e){t.index=e})}init(t,e){return super.init(t,e),te.call(this),l(this,"updatedData",()=>{this.layout&&this.layout.stop()}),l(this,"afterUpdate",()=>{this.nodes.forEach(t=>{t&&t.series&&t.resolveColor()})}),l(this,"afterSimulation",function(){this.deferDataLabels=!1,this.drawDataLabels()}),this}markerAttribs(t,e){let i=W.prototype.markerAttribs.call(this,t,e);return d(t.plotY)||(i.y=0),i.x=(t.plotX||0)-(i.width||0)/2,i}pointAttribs(t,e){let i=e||t&&t.state||"normal",o=this.options.states[i],s=W.prototype.pointAttribs.call(this,t,i);return t&&!t.isNode&&(s=t.getLinkAttributes(),o&&(s={stroke:o.linkColor||s.stroke,dashstyle:o.linkDashStyle||s.dashstyle,opacity:y(o.linkOpacity,s.opacity),"stroke-width":o.linkColor||s["stroke-width"]})),s}render(){let t=this.points,e=this.chart.hoverPoint,i=[];this.points=this.nodes,Z.render.call(this),this.points=t,t.forEach(function(t){t.fromNode&&t.toNode&&(t.renderLink(),t.redrawLink())}),e&&e.series===this&&this.redrawHalo(e),this.chart.hasRendered&&!this.options.dataLabels.allowOverlap&&(this.nodes.concat(this.points).forEach(function(t){t.dataLabel&&i.push(t.dataLabel)}),this.chart.hideOverlappingLabels(i))}setState(t,e){e?(this.points=this.nodes.concat(this.data),W.prototype.setState.apply(this,arguments),this.points=this.data):W.prototype.setState.apply(this,arguments),this.layout.simulation||t||this.render()}translate(){this.generatePoints(),this.deferLayout(),this.nodes.forEach(function(t){t.isInside=!0,t.linksFrom.forEach(function(t){t.shapeType="path",t.y=1})})}}ti.defaultOptions=m(W.defaultOptions,{stickyTracking:!1,inactiveOtherPoints:!0,marker:{enabled:!0,states:{inactive:{opacity:.3,animation:{duration:50}}}},states:{inactive:{linkOpacity:.3,animation:{duration:50}}},dataLabels:{formatter:function(){return String(this.key??"")},linkFormatter:function(){return this.fromNode.name+"<br>"+this.toNode.name},linkTextPath:{enabled:!0},textPath:{enabled:!1},style:{transition:"opacity 2000ms"},defer:!0,animation:{defer:1e3}},link:{color:"rgba(100, 100, 100, 0.5)",width:1},draggable:!0,layoutAlgorithm:{initialPositions:"circle",initialPositionRadius:1,enableSimulation:!1,theta:.5,maxSpeed:10,approximation:"none",type:"reingold-fruchterman",integration:"euler",maxIterations:1e3,gravitationalConstant:.0625,friction:-.981},showInLegend:!1}),p(ti.prototype,{pointClass:R,animate:void 0,directTouch:!0,drawGraph:void 0,forces:["barycenter","repulsive","attractive"],hasDraggableNodes:!0,isCartesian:!1,noSharedTooltip:!0,pointArrayMap:["from","to"],requireSorting:!1,trackerGroups:["group","markerGroup","dataLabelsGroup"],initDataLabels:tt,buildKDTree:V,createNode:C.createNode,drawTracker:J.drawTracker,onMouseDown:k.onMouseDown,onMouseMove:k.onMouseMove,onMouseUp:k.onMouseUp,redrawHalo:k.redrawHalo}),D().registerSeriesType("networkgraph",ti);let to=s();ti.compose(to.Chart);let ts=s();export{ts as default};