@antv/layout 1.2.12 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{4161e9d58bae8f39711a.worker.js → aa1bb0ccc06b11cf79c1.worker.js} +2 -2
- package/dist/aa1bb0ccc06b11cf79c1.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/lib/dagre.js +4 -3
- package/lib/dagre.js.map +1 -1
- package/lib/types.d.ts +1 -0
- package/package.json +1 -1
- package/dist/4161e9d58bae8f39711a.worker.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Bn,stopLayout:()=>Vn});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;const d=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events["*"]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function h(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function l(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&l(o,e,r,n))return!0;return!1}class c extends d{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),r=this.bothEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:o})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return l(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return h([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return h([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return l(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new c({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}const f=function(t){return"function"==typeof t};var g={}.toString;const p=function(t,e){return g.call(t)==="[object "+e+"]"},v=function(t){return p(t,"Number")},y=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function m(t,e){return f(e)?e:v(e)?function(){return e}:function(){return t}}function w(t,e,r){return void 0===r&&(r=!0),e||0===e?f(e)?e:v(e)?function(){return e}:Array.isArray(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e)));return isNaN(n)?t:n}return e}:y(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?Array.isArray(r)?r[0]>r[1]?r[0]:r[1]:y(r)?r.width>r.height?r.width:r.height:r:t}}var x=function(t,e){var r;return r=v(e)?function(){return e}:f(e)?e:function(){return 0},t?Array.isArray(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:f(t)?t:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return y(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},E=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return E(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=E(t[e])})),r}return t},b=function(t,e){var r=E(t);return r.data=r.data||{},e&&(v(r.data.x)||(r.data.x=Math.random()*e[0]),v(r.data.y)||(r.data.y=Math.random()*e[1])),r},N=function(t,e,r){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:r[0],y:r[1]}),{nodes:[n(n({},o[0]),{data:n(n({},o[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},M={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},S=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},M),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,u,d,h,l,c,f,g,p,v,y,x,E,M,S,_,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,u=o.height,d=o.center,h=o.divisions,l=o.startAngle,c=void 0===l?0:l,f=o.endAngle,g=void 0===f?2*Math.PI:f,p=o.angleRatio,v=o.ordering,y=o.clockwise,x=o.nodeSpacing,E=o.nodeSize,M=e.getAllNodes(),S=e.getAllEdges(),_=s(k(i,u,d),3),z=_[0],R=_[1],I=_[2],!(D=null==M?void 0:M.length)||1===D)return[2,N(e,t,I)];for(P=(g-c)/D,O=o.radius,T=o.startRadius,C=o.endRadius,x?(L=m(10,x),q=w(10,E),j=-1/0,M.forEach((function(t){var e=q(t);j<e&&(j=e)})),F=0,M.forEach((function(t,e){F+=0===e?j||10:(L(t)||0)+(j||10)})),O=F/(2*Math.PI)):O||T||C?!T&&C?T=C:T&&!C&&(C=T):O=Math.min(R,z)/2,V=P*p,B=[],B="topology"===v?A(e,M):"topology-directed"===v?A(e,M,!0):"degree"===v?function(t,e){var r=[];return e.forEach((function(t,e){r.push(b(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,M):M.map((function(t){return b(t)})),G=Math.ceil(D/h),W=0;W<D;++W)($=O)||null===T||null===C||($=T+W*(C-T)/(D-1)),$||($=10+100*W/(D-1)),U=c+W%G*V+2*Math.PI/h*Math.floor(W/G),y||(U=g-W%G*V-2*Math.PI/h*Math.floor(W/G)),B[W].data.x=I[0]+Math.cos(U)*$,B[W].data.y=I[1]+Math.sin(U)*$;return t&&B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:B,edges:S}]}))}))},t}(),A=function(t,e,r){void 0===r&&(r=!1);var n=[b(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){for(var d=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),h=!1,l=0;l<d.length;l++){var c=d[l];if(t.getDegree(c.id)===t.getDegree(s.id)&&!o[c.id]){n.push(b(c)),o[c.id]=!0,h=!0;break}}for(var f=0;!h&&(o[e[f].id]||(n.push(b(e[f])),o[e[f].id]=!0,h=!0),++f!==i););}else n.push(b(s)),o[s.id]=!0,a++})),n},k=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]},_=Array.isArray,z=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},R=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},I=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},D=function(t,e,r,n,o,i){if(void 0===n&&(n="TB"),void 0===i&&(i={}),null==e?void 0:e.length)for(var a=i.stopBranchFn,s=i.stopAllFn,u=0;u<e.length;u++){var d=e[u];if(t.hasNode(d.id)&&!(null==a?void 0:a(d))){if(null==s?void 0:s(d))return;"TB"===n&&r(d),D(t,t.getChildren(d.id,o),r,n,o,i),"TB"!==n&&r(d)}}};const P=Object.prototype.toString;function O(t){const e=P.call(t);return e.endsWith("Array]")&&!e.includes("Big")}function T(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!O(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!O(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!O(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]<a&&(a=t[s]);return a}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!O(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]>a&&(a=t[s]);return a}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,a=void 0===i?r.autoMinMax?n:0:i,s=r.max,u=void 0===s?r.autoMinMax?o:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var d=(u-a)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*d+a;return e}const C=" ".repeat(2),L=" ".repeat(4);function q(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${C}[\n${L}${function(t,e,r,n,o){const{rows:i,columns:a}=t,s=Math.min(i,e),u=Math.min(a,r),d=[];if("auto"===o){o=!1;t:for(let e=0;e<s;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<s;e++){let r=[];for(let i=0;i<u;i++)r.push(j(t.get(e,i),n,o));d.push(`${r.join(" ")}`)}return u!==a&&(d[d.length-1]+=` ... ${a-r} more columns`),s!==i&&d.push(`... ${i-e} more rows`),d.join(`\n${L}`)}(t,r,n,o,i)}\n${C}]\n${C}rows: ${t.rows}\n${C}columns: ${t.columns}\n}`}function j(t,e,r){return(t>=0&&r?` ${F(t,e-1)}`:F(t,e)).padEnd(e)}function F(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function V(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function B(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function G(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function W(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function $(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(H("startRow",e),H("endRow",r),H("startColumn",n),H("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function U(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function H(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Y(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class K{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new X(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new X(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new X(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new X(t,e)}static ones(t,e){return new X(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new X(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let a=o-n,s=new X(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*a);s.set(r,t,e)}return s}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new X(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return K.isMatrix(t)?t:new X(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let a=o;a<e;a++){let e=t.get(r,a)-i*t.get(n,a);t.set(r,a,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new X(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){V(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return X.rowVector(this.getRow(t))}setRow(t,e){V(this,t),e=G(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){V(this,t),V(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){B(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return X.columnVector(this.getColumn(t))}setColumn(t,e){B(this,t),e=W(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){B(this,t),B(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){V(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){B(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Y(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Y(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(V(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){V(this,t),Y(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(V(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){V(this,t),Y(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(B(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){B(this,t),Y(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(B(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){B(this,t),Y(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){K.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=X.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new X(e,n),i=new Float64Array(r);for(let a=0;a<n;a++){for(let e=0;e<r;e++)i[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,a,e)}}return o}strassen2x2(t){t=X.checkMatrix(t);let e=new X(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),d=t.get(1,1),h=(r+u)*(n+d),l=(a+u)*n,c=r*(i-d),f=u*(s-n),g=(r+o)*d,p=h+f-g+(o-u)*(s+d),v=c+g,y=l+f,m=h-l+c+(a-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,y),e.set(1,1,m),e}strassen3x3(t){t=X.checkMatrix(t);let e=new X(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),d=this.get(2,1),h=this.get(2,2),l=t.get(0,0),c=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-c+p),E=(-r+i+a)*(l-c+p),b=(i+a)*(-l+c),N=r*l,M=(-r+u+d)*(l-f+v),S=(-r+u)*(f-v),A=(u+d)*(-l+f),k=(-o+d+h)*(p+y-m),_=(o-h)*(p-m),z=o*y,R=(d+h)*(-y+m),I=(-o+a+s)*(v+y-w),D=(o-s)*(v-w),P=(a+s)*(-y+w),O=N+z+n*g,T=(r+n+o-i-a-d-h)*p+E+b+N+k+z+R,C=N+M+A+(r+n+o-a-s-u-d)*v+z+I+P,L=x+a*(-l+c+g-p-v-y+w)+E+N+z+I+D,q=x+E+b+N+s*m,j=z+I+D+P+i*f,F=N+M+S+d*(-l+f+g-p-v-y+m)+k+_+z,V=k+_+z+R+u*c,B=N+M+S+A+h*w;return e.set(0,0,O),e.set(0,1,T),e.set(0,2,C),e.set(1,0,L),e.set(1,1,q),e.set(1,2,j),e.set(2,0,F),e.set(2,1,V),e.set(2,2,B),e}mmulStrassen(t){t=X.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function a(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=K.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let s=Math.max(r,o),u=Math.max(n,i);return e=a(e,s,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=a(e,n+1,o+1),r=a(r,n+1,o+1)):n%2==1?(e=a(e,n+1,o),r=a(r,n+1,o)):o%2==1&&(e=a(e,n,o+1),r=a(r,n,o+1));let i=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,s-1),d=r.subMatrix(0,i-1,0,s-1),h=e.subMatrix(0,i-1,s,e.columns-1),l=r.subMatrix(0,i-1,s,r.columns-1),c=e.subMatrix(i,e.rows-1,0,s-1),f=r.subMatrix(i,r.rows-1,0,s-1),g=e.subMatrix(i,e.rows-1,s,e.columns-1),p=r.subMatrix(i,r.rows-1,s,r.columns-1),v=t(K.add(u,g),K.add(d,p),i,s),y=t(K.add(c,g),d,i,s),m=t(u,K.sub(l,p),i,s),w=t(g,K.sub(f,d),i,s),x=t(K.add(u,h),p,i,s),E=t(K.sub(c,u),K.add(d,l),i,s),b=t(K.sub(h,g),K.add(f,p),i,s),N=K.add(v,w);N.sub(x),N.add(b);let M=K.add(m,x),S=K.add(y,w),A=K.sub(v,y);A.add(m),A.add(E);let k=K.zeros(2*N.rows,2*N.columns);return k=k.setSubMatrix(N,0,0),k=k.setSubMatrix(M,N.rows,0),k=k.setSubMatrix(S,0,N.columns),k=k.setSubMatrix(A,N.rows,N.columns),k.subMatrix(0,n-1,0,o-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new X(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&T(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new X(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&T(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=X.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new X(e*n,r*o);for(let a=0;a<e;a++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let s=0;s<o;s++)i.set(n*a+r,o*e+s,this.get(a,e)*t.get(r,s));return i}kroneckerSum(t){if(t=X.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(X.eye(r,r)),o=X.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new X(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=J){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=J){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){$(this,t,e,r,n);let o=new X(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new X(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new X(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=X.checkMatrix(t)).isEmpty())return this;$(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!O(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!O(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new X(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new X(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=U(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=U(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=U(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=U(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!O(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<n;a++){let n=0,s=0,u=0;for(let e=0;e<o;e++)u=t.get(a,e)-r[a],n+=u,s+=u*u;e?i.push((s-n*n/o)/(o-1)):i.push((s-n*n/o)/o)}return i}(this,r,n);case"column":if(!O(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<o;a++){let o=0,s=0,u=0;for(let e=0;e<n;e++)u=t.get(e,a)-r[a],o+=u,s+=u*u;e?i.push((s-o*o/n)/(n-1)):i.push((s-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let a=0,s=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,a+=u,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!O(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!O(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!O(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!O(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return q(this,t)}}function J(t,e){return t-e}K.prototype.klass="Matrix","undefined"!=typeof Symbol&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return q(this)}),K.random=K.rand,K.randomInt=K.randInt,K.diagonal=K.diag,K.prototype.diagonal=K.prototype.diag,K.identity=K.eye,K.prototype.negate=K.prototype.neg,K.prototype.tensorProduct=K.prototype.kroneckerProduct;class X extends K{constructor(t,e){if(super(),X.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!O(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return V(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),V(this,t,!0),e=Float64Array.from(G(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){B(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),B(this,t,!0),e=W(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(K,X);class Q extends K{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function Z(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class tt{constructor(t,e={}){if((t=Q.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),d=Boolean(i),h=!1;if(r<n)if(a){s=t.transpose(),r=s.rows,n=s.columns,h=!0;let e=u;u=d,d=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let l=Math.min(r,n),c=Math.min(r+1,n),f=new Float64Array(c),g=new X(r,l),p=new X(n,n),v=new Float64Array(n),y=new Float64Array(r),m=new Float64Array(c);for(let t=0;t<c;t++)m[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),E=Math.max(w,x);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=Z(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=s.get(o,t)*s.get(o,e);n=-n/s.get(t,t);for(let o=t;o<r;o++)s.set(o,e,s.get(o,e)+n*s.get(o,t))}v[e]=s.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<n;e++)v[t]=Z(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)y[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)y[e]+=v[r]*s.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)s.set(o,e,s.get(o,e)+n*y[o])}}if(d)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let b=Math.min(n,r+1);if(w<n&&(f[w]=s.get(w,w)),r<b&&(f[b-1]=0),x+1<b&&(v[x]=s.get(x,b-1)),v[b-1]=0,u){for(let t=w;t<l;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<l;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(d)for(let t=n-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=b-1,M=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=S*e){f[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[b-2];v[b-2]=0;for(let r=b-2;r>=t;r--){let o=Z(f[r],e),i=f[r]/o,a=e/o;if(f[r]=o,r!==t&&(e=-a*v[r-1],v[r-1]=i*v[r-1]),d)for(let t=0;t<n;t++)o=i*p.get(t,r)+a*p.get(t,b-1),p.set(t,b-1,-a*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let n=t;n<b;n++){let o=Z(f[n],e),i=f[n]/o,a=e/o;if(f[n]=o,e=-a*v[n],v[n]=i*v[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+a*g.get(e,t-1),g.set(e,t-1,-a*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(f[b-1]),Math.abs(f[b-2]),Math.abs(v[b-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[b-1]/e,i=f[b-2]/e,a=v[b-2]/e,s=f[t]/e,h=v[t]/e,l=((i+o)*(i-o)+a*a)/2,c=o*a*(o*a);let y=0;0===l&&0===c||(y=l<0?0-Math.sqrt(l*l+c):Math.sqrt(l*l+c),y=c/(l+y));let m=(s+o)*(s-o)+y,w=s*h;for(let e=t;e<b-1;e++){let o=Z(m,w);0===o&&(o=Number.MIN_VALUE);let i=m/o,a=w/o;if(e!==t&&(v[e-1]=o),m=i*f[e]+a*v[e],v[e]=i*v[e]-a*f[e],w=a*f[e+1],f[e+1]=i*f[e+1],d)for(let t=0;t<n;t++)o=i*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=Z(m,w),0===o&&(o=Number.MIN_VALUE),i=m/o,a=w/o,f[e]=o,m=i*v[e]+a*f[e+1],f[e+1]=-a*v[e]+i*f[e+1],w=a*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}v[b-2]=m,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,d))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,d&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M=0,b--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=X.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,a=this.rightSingularVectors,s=a.mmul(o),u=a.rows,d=i.rows,h=X.zeros(u,d);for(let t=0;t<u;t++)for(let e=0;e<d;e++){let r=0;for(let o=0;o<n;o++)r+=s.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(X.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new X(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,a=i.rows,s=i.columns,u=new X(r,a);for(let t=0;t<r;t++)for(let e=0;e<a;e++){let r=0;for(let n=0;n<s;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return X.diag(this.s)}}var et={center:[0,0],linkDistance:50},rt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},et),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,c,f,g,p;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=void 0===i?[0,0]:i,u=o.linkDistance,d=void 0===u?50:u,h=e.getAllNodes(),l=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(c=R({nodes:h,edges:l},!1),f=z(c),nt(f),v=d,y=[],f.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*v)})),y.push(e)})),g=ot(y),p=[],g.forEach((function(t,e){var r=b(h[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],p.push(r)})),t&&p.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:l}]):[2,N(e,t,s)];var v,y}))}))},t}(),nt=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},ot=function(t){var e=X.mul(X.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new tt(e),a=X.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return X.mul([t],[a]).toJSON()[0].splice(0,2)}))};function it(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,d,h,l,c,f=t._root,g={data:n},p=t._x0,v=t._y0,y=t._x1,m=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a,o=f,!(f=f[l=h<<1|d]))return o[l]=g,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&r===u)return g.next=f,o?o[l]=g:t._root=g,t;do{o=o?o[l]=new Array(4):t._root=new Array(4),(d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a}while((l=h<<1|d)==(c=(u>=a)<<1|s>=i));return o[c]=f,o[l]=g,t}function at(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function st(t){return t[0]}function ut(t){return t[1]}function dt(t,e,r){var n=new ht(null==e?st:e,null==r?ut:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function ht(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function lt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var ct=dt.prototype=ht.prototype;function ft(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,a,s,u,d,h,l,c,f,g,p,v,y=t._root,m={data:o},w=t._x0,x=t._y0,E=t._z0,b=t._x1,N=t._y1,M=t._z1;if(!y)return t._root=m,t;for(;y.length;)if((c=e>=(a=(w+b)/2))?w=a:b=a,(f=r>=(s=(x+N)/2))?x=s:N=s,(g=n>=(u=(E+M)/2))?E=u:M=u,i=y,!(y=y[p=g<<2|f<<1|c]))return i[p]=m,t;if(d=+t._x.call(null,y.data),h=+t._y.call(null,y.data),l=+t._z.call(null,y.data),e===d&&r===h&&n===l)return m.next=y,i?i[p]=m:t._root=m,t;do{i=i?i[p]=new Array(8):t._root=new Array(8),(c=e>=(a=(w+b)/2))?w=a:b=a,(f=r>=(s=(x+N)/2))?x=s:N=s,(g=n>=(u=(E+M)/2))?E=u:M=u}while((p=g<<2|f<<1|c)==(v=(l>=u)<<2|(h>=s)<<1|d>=a));return i[v]=y,i[p]=m,t}function gt(t,e,r,n,o,i,a){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=o,this.y1=i,this.z1=a}function pt(t){return t[0]}function vt(t){return t[1]}function yt(t){return t[2]}function mt(t,e,r,n){var o=new wt(null==e?pt:e,null==r?vt:r,null==n?yt:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function wt(t,e,r,n,o,i,a,s,u){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function xt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}ct.copy=function(){var t,e,r=new ht(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=lt(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=lt(e));return r},ct.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return it(this.cover(e,r),e,r,t)},ct.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,d=1/0,h=-1/0,l=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>h&&(h=n),o<d&&(d=o),o>l&&(l=o));if(u>h||d>l)return this;for(this.cover(u,d).cover(h,l),r=0;r<i;++r)it(this,a[r],s[r],t[r]);return this},ct.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,d=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=d,d=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},ct.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},ct.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},ct.find=function(t,e,r){var n,o,i,a,s,u,d,h=this._x0,l=this._y0,c=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new at(p,h,l,c,f)),null==r?r=1/0:(h=t-r,l=e-r,c=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>c||(i=u.y0)>f||(a=u.x1)<h||(s=u.y1)<l))if(p.length){var v=(o+a)/2,y=(i+s)/2;g.push(new at(p[3],v,y,a,s),new at(p[2],o,y,v,s),new at(p[1],v,i,a,y),new at(p[0],o,i,v,y)),(d=(e>=y)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-d],g[g.length-1-d]=u)}else{var m=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=m*m+w*w;if(x<r){var E=Math.sqrt(r=x);h=t-E,l=e-E,c=t+E,f=e+E,n=p.data}}return n},ct.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,l,c,f=this._root,g=this._x0,p=this._y0,v=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((d=i>=(s=(g+v)/2))?g=s:v=s,(h=a>=(u=(p+y)/2))?p=u:y=u,e=f,!(f=f[l=h<<1|d]))return this;if(!f.length)break;(e[l+1&3]||e[l+2&3]||e[l+3&3])&&(r=e,c=l)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[l]=o:delete e[l],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[c]=f:this._root=f),this):(this._root=o,this)},ct.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},ct.root=function(){return this._root},ct.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},ct.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new at(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var d=(n+i)/2,h=(o+a)/2;(r=u[3])&&s.push(new at(r,d,h,i,a)),(r=u[2])&&s.push(new at(r,n,h,d,a)),(r=u[1])&&s.push(new at(r,d,o,i,h)),(r=u[0])&&s.push(new at(r,n,o,d,h))}return this},ct.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new at(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,d=e.y1,h=(a+u)/2,l=(s+d)/2;(i=o[0])&&r.push(new at(i,a,s,h,l)),(i=o[1])&&r.push(new at(i,h,s,u,l)),(i=o[2])&&r.push(new at(i,a,l,h,d)),(i=o[3])&&r.push(new at(i,h,l,u,d))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},ct.x=function(t){return arguments.length?(this._x=t,this):this._x},ct.y=function(t){return arguments.length?(this._y=t,this):this._y};var Et=mt.prototype=wt.prototype;function bt(t){var e=0,r=0,n=0,o=0,i=0,a=t.length;if(a){for(var s=0;s<a;s++)(u=t[s])&&u.weight&&(e+=u.weight,r+=u.x*u.weight,n+=u.y*u.weight,o+=u.z*u.weight,i+=u.size*u.weight);t.x=r/e,t.y=n/e,t.z=o/e,t.size=i/e,t.weight=e}else{var u=t;t.x=u.data.x,t.y=u.data.y,t.z=u.data.z,t.size=u.data.size,t.weight=u.data.weight}}Et.copy=function(){var t,e,r=new wt(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return r;if(!n.length)return r._root=xt(n),r;for(t=[{source:n,target:r._root=new Array(8)}];n=t.pop();)for(var o=0;o<8;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(8)}):n.target[o]=xt(e));return r},Et.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return ft(this.cover(e,r,n),e,r,n,t)},Et.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e),n=new Float64Array(e),o=new Float64Array(e);let i=1/0,a=1/0,s=1/0,u=-1/0,d=-1/0,h=-1/0;for(let l,c,f,g,p=0;p<e;++p)isNaN(c=+this._x.call(null,l=t[p]))||isNaN(f=+this._y.call(null,l))||isNaN(g=+this._z.call(null,l))||(r[p]=c,n[p]=f,o[p]=g,c<i&&(i=c),c>u&&(u=c),f<a&&(a=f),f>d&&(d=f),g<s&&(s=g),g>h&&(h=g));if(i>u||a>d||s>h)return this;this.cover(i,a,s).cover(u,d,h);for(let i=0;i<e;++i)ft(this,r[i],n[i],o[i],t[i]);return this},Et.cover=function(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,o=this._y0,i=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(n))a=(n=Math.floor(t))+1,s=(o=Math.floor(e))+1,u=(i=Math.floor(r))+1;else{for(var d,h,l=a-n||1,c=this._root;n>t||t>=a||o>e||e>=s||i>r||r>=u;)switch(h=(r<i)<<2|(e<o)<<1|t<n,(d=new Array(8))[h]=c,c=d,l*=2,h){case 0:a=n+l,s=o+l,u=i+l;break;case 1:n=a-l,s=o+l,u=i+l;break;case 2:a=n+l,o=s-l,u=i+l;break;case 3:n=a-l,o=s-l,u=i+l;break;case 4:a=n+l,s=o+l,i=u-l;break;case 5:n=a-l,s=o+l,i=u-l;break;case 6:a=n+l,o=s-l,i=u-l;break;case 7:n=a-l,o=s-l,i=u-l}this._root&&this._root.length&&(this._root=c)}return this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this},Et.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Et.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Et.find=function(t,e,r,n){var o,i,a,s,u,d,h,l,c,f=this._x0,g=this._y0,p=this._z0,v=this._x1,y=this._y1,m=this._z1,w=[],x=this._root;for(x&&w.push(new gt(x,f,g,p,v,y,m)),null==n?n=1/0:(f=t-n,g=e-n,p=r-n,v=t+n,y=e+n,m=r+n,n*=n);l=w.pop();)if(!(!(x=l.node)||(i=l.x0)>v||(a=l.y0)>y||(s=l.z0)>m||(u=l.x1)<f||(d=l.y1)<g||(h=l.z1)<p))if(x.length){var E=(i+u)/2,b=(a+d)/2,N=(s+h)/2;w.push(new gt(x[7],E,b,N,u,d,h),new gt(x[6],i,b,N,E,d,h),new gt(x[5],E,a,N,u,b,h),new gt(x[4],i,a,N,E,b,h),new gt(x[3],E,b,s,u,d,N),new gt(x[2],i,b,s,E,d,N),new gt(x[1],E,a,s,u,b,N),new gt(x[0],i,a,s,E,b,N)),(c=(r>=N)<<2|(e>=b)<<1|t>=E)&&(l=w[w.length-1],w[w.length-1]=w[w.length-1-c],w[w.length-1-c]=l)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),A=r-+this._z.call(null,x.data),k=M*M+S*S+A*A;if(k<n){var _=Math.sqrt(n=k);f=t-_,g=e-_,p=r-_,v=t+_,y=e+_,m=r+_,o=x.data}}return o},Et.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,l,c,f,g,p,v=this._root,y=this._x0,m=this._y0,w=this._z0,x=this._x1,E=this._y1,b=this._z1;if(!v)return this;if(v.length)for(;;){if((l=i>=(u=(y+x)/2))?y=u:x=u,(c=a>=(d=(m+E)/2))?m=d:E=d,(f=s>=(h=(w+b)/2))?w=h:b=h,e=v,!(v=v[g=f<<2|c<<1|l]))return this;if(!v.length)break;(e[g+1&7]||e[g+2&7]||e[g+3&7]||e[g+4&7]||e[g+5&7]||e[g+6&7]||e[g+7&7])&&(r=e,p=g)}for(;v.data!==t;)if(n=v,!(v=v.next))return this;return(o=v.next)&&delete v.next,n?(o?n.next=o:delete n.next,this):e?(o?e[g]=o:delete e[g],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(r?r[p]=v:this._root=v),this):(this._root=o,this)},Et.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Et.root=function(){return this._root},Et.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Et.visit=function(t){var e,r,n,o,i,a,s,u,d=[],h=this._root;for(h&&d.push(new gt(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=d.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.z0,a=e.x1,s=e.y1,u=e.z1)&&h.length){var l=(n+a)/2,c=(o+s)/2,f=(i+u)/2;(r=h[7])&&d.push(new gt(r,l,c,f,a,s,u)),(r=h[6])&&d.push(new gt(r,n,c,f,l,s,u)),(r=h[5])&&d.push(new gt(r,l,o,f,a,c,u)),(r=h[4])&&d.push(new gt(r,n,o,f,l,c,u)),(r=h[3])&&d.push(new gt(r,l,c,i,a,s,f)),(r=h[2])&&d.push(new gt(r,n,c,i,l,s,f)),(r=h[1])&&d.push(new gt(r,l,o,i,a,c,f)),(r=h[0])&&d.push(new gt(r,n,o,i,l,c,f))}return this},Et.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new gt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.z0,d=e.x1,h=e.y1,l=e.z1,c=(a+d)/2,f=(s+h)/2,g=(u+l)/2;(i=o[0])&&r.push(new gt(i,a,s,u,c,f,g)),(i=o[1])&&r.push(new gt(i,c,s,u,d,f,g)),(i=o[2])&&r.push(new gt(i,a,f,u,c,h,g)),(i=o[3])&&r.push(new gt(i,c,f,u,d,h,g)),(i=o[4])&&r.push(new gt(i,a,s,g,c,f,l)),(i=o[5])&&r.push(new gt(i,c,s,g,d,f,l)),(i=o[6])&&r.push(new gt(i,a,f,g,c,h,l)),(i=o[7])&&r.push(new gt(i,c,f,g,d,h,l))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Et.x=function(t){return arguments.length?(this._x=t,this):this._x},Et.y=function(t){return arguments.length?(this._y=t,this):this._y},Et.z=function(t){return arguments.length?(this._z=t,this):this._z};var Nt=function(t,e,r,n,o,i,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)!==i.id){for(var u=[r,n,o][a-1],d=i.x-t.x||.1,h=i.y-t.y||.1,l=i.z-t.z||.1,c=[d,h,l],f=u-e,g=0,p=0;p<a;p++)g+=c[p]*c[p];var v=Math.sqrt(g)*g;if(f*f*.81<g){var y=t.weight/v;return i.vx+=d*y,i.vy+=h*y,i.vz+=l*y,!0}if(t.length)return!1;t.data!==i&&(y=t.data.weight/v,i.vx+=d*y,i.vy+=h*y,i.vz+=l*y)}},Mt={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},St=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=n(n({},Mt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,f,g,p,y,m,w,x,E,b,N,M,S,A,k=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=this.formatOptions(o,e),d=u.dimensions,h=u.width,l=u.height,f=u.nodeSize,g=u.getMass,p=u.nodeStrength,y=u.edgeStrength,m=u.linkDistance,w=i.map((function(t,e){return n(n({},t),{data:n(n({},t.data),{x:v(t.data.x)?t.data.x:Math.random()*h,y:v(t.data.y)?t.data.y:Math.random()*l,z:v(t.data.z)?t.data.z:Math.random()*Math.sqrt(h*l),size:f(t)||30,mass:g(t),nodeStrength:p(t)})})})),x=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:y(t),linkDistance:m(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(E={},i.forEach((function(t,e){E[t.id]={x:0,y:0,z:0}})),b=new c({nodes:w,edges:x}),this.formatCentripetal(u,b),N=u.maxIteration,M=u.minMovement,S=u.onTick,this.lastLayoutNodes=w,this.lastLayoutEdges=x,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=b,this.lastOptions=u,this.lastVelMap=E,"undefined"==typeof window?[2]:(A=0,[2,new Promise((function(r){k.timeInterval=window.setInterval((function(){i&&k.running||r({nodes:Rt(e,w),edges:s}),k.runOneStep(b,e,A,E,u),k.updatePosition(e,b,E,u),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===d?t.data.z:void 0})})),null==S||S({nodes:Rt(e,w),edges:s}),(++A>=N||k.judgingDistance<M)&&(window.clearInterval(k.timeInterval),r({nodes:Rt(e,w),edges:s}))}),0),k.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=n({},t),o=t.width,i=t.height,a=t.getMass,s=t.nodeSize;r.width=o||"undefined"==typeof window?o:window.innerWidth,r.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),a||(r.getMass=function(t){var r=1;v(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r});var u,d=m(0,t.nodeSpacing);u=s?f(s)?function(t){return s(t)+d(t)}:_(s)?function(t){var e=s;return Math.max(e[0],e[1])+d(t)}:function(t){return s+d(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?_(e)?Math.max(e[0],e[1])+d(t):y(e)?Math.max(e.width,e.height)+d(t):e+d(t):10+d(t)},r.nodeSize=u;var h=t.linkDistance?m(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))};return r.linkDistance=h,r.nodeStrength=m(1,t.nodeStrength),r.edgeStrength=m(1,t.edgeStrength),r},t.prototype.formatCentripetal=function(t,e){var r,n,o=t.dimensions,i=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,u=t.leafCluster,d=t.clustering,h=t.nodeClusterBy,l=e.getAllNodes(),c=i||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===o?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),u&&h&&(r=At(e,h),n=Array.from(new Set(null==l?void 0:l.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(c,{single:100,leaf:function(e){var o=r[e.id]||{},i=o.siblingLeaves,a=o.sameTypeLeaves;return(null==a?void 0:a.length)===(null==i?void 0:i.length)||1===(null==n?void 0:n.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100,z:0};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=zt(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),d&&h){r||(r=At(e,h)),n||(n=Array.from(new Set(l.map((function(t){return t.data[h]}))))),n=n.filter((function(t){return void 0!==t}));var f={};n.forEach((function(t){var r=l.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=zt(r)})),t.centripetalOptions=Object.assign(c,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[h]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var g=t.centripetalOptions||{},p=g.leaf,v=g.single,y=g.others;p&&"function"!=typeof p&&(t.centripetalOptions.leaf=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.single=function(){return v}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;this.calRepulsive(t,i,o),s&&this.calAttractive(t,i,o),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){var r=this;if(!(null==e?void 0:e.length))return 0;var n=0;return e.forEach((function(e,o){var i=t[e.id].x,a=t[e.id].y,s=3===r.options.dimensions?t[e.id].z:0,u=i*i+a*a+s*s,d=e.data.mass;n+=(void 0===d?1:d)*u*.5})),n},t.prototype.calRepulsive=function(t,e,r){var n=r.dimensions,o=r.factor,i=r.coulombDisScale;!function(t,e,r,n,o){void 0===o&&(o=2);var i=e/r,a=t.getAllNodes(),s=a.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,z:r.z,size:r.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*n}})),u=(2===o?dt(s,(function(t){return t.x}),(function(t){return t.y})):mt(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(bt),d=new Map;s.forEach((function(t){d.set(t.id,t),function(t,e,r){e.visit((function(e,n,o,i,a){return Nt(e,n,o,i,a,t,r)}))}(t,u,o)})),s.map((function(t,e){var r=a[e],o=r.id,i=r.data.mass,s=void 0===i?1:i;n[o]={x:t.vx/s,y:t.vy/s,z:t.vz/s}}))}(t,o,i*i,e,n)},t.prototype.calAttractive=function(t,e,r){var n=r.dimensions,o=r.nodeSize;t.getAllEdges().forEach((function(r,i){var a=r.source,s=r.target,u=t.getNode(a),d=t.getNode(s);if(u&&d){var h=d.data.x-u.data.x,l=d.data.y-u.data.y,c=3===n?d.data.z-u.data.z:0;h||l||(h=.01*Math.random(),l=.01*Math.random(),3!==n||c||(c=.01*Math.random()));var f=Math.sqrt(h*h+l*l+c*c);if(!(f<o(u)+o(d))){var g=h/f,p=l/f,v=c/f,y=r.data||{},m=y.linkDistance,w=void 0===m?200:m,x=y.edgeStrength,E=(w-f)*(void 0===x?200:x),b=1/(u.data.mass||1),N=1/(d.data.mass||1),M=g*E,S=p*E,A=v*E;e[a].x-=M*b,e[a].y-=S*b,e[a].z-=A*b,e[s].x+=M*N,e[s].y+=S*N,e[s].z+=A*N}}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),d=n.width,h=n.height,l=n.center,c=n.gravity,f=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,y=g.x,m=g.y,w=g.z,x=e.getNode(i),E=0,b=0,N=0,M=c,S=t.getDegree(i,"in"),A=t.getDegree(i,"out"),k=t.getDegree(i,"both"),_=null==o?void 0:o(x,k);if(_){var z=s(_,3);E=y-z[0],b=m-z[1],M=z[2]}else E=y-l[0],b=m-l[1],N=w-l[2];if(M&&(r[i].x-=M*E/p,r[i].y-=M*b/p,r[i].z-=M*N/p),f){var R=f.leaf,I=f.single,D=f.others,P=f.center,O=(null==P?void 0:P(x,a,u,d,h))||{x:0,y:0,z:0,centerStrength:0},T=O.x,C=O.y,L=O.z,q=O.centerStrength;if(!v(T)||!v(C))return;var j=(y-T)/p,F=(m-C)/p,V=(w-L)/p;if(q&&(r[i].x-=q*j,r[i].y-=q*F,r[i].z-=q*V),0===k){var B=I(x);if(!B)return;return r[i].x-=B*j,r[i].y-=B*F,void(r[i].z-=B*V)}if(0===S||0===A){var G=R(x,a,u);if(!G)return;return r[i].x-=G*j,r[i].y-=G*F,void(r[i].z-=G*V)}var W=D(x);if(!W)return;r[i].x-=W*j,r[i].y-=W*F,r[i].z-=W*V}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=n.dimensions,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((function(t){var n=t.id,u=(r[n].x+e[n].x*a)*o||.01,d=(r[n].y+e[n].y*a)*o||.01,h=3===s?(r[n].z+e[n].z*a)*o||.01:0,l=Math.sqrt(u*u+d*d+h*h);if(l>i){var c=i/l;u*=c,d*=c,h*=c}r[n]={x:u,y:d,z:h}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=n.dimensions,u=e.getAllNodes();if(null==u?void 0:u.length){var d=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),u.forEach((function(n){var u=n.id,h=t.getNode(u);if(v(h.data.fx)&&v(h.data.fy))e.mergeNodeData(u,{x:h.data.fx,y:h.data.fy,z:3===s?h.data.fz:void 0});else{var l=r[u].x*a,c=r[u].y*a,f=3===s?r[u].z*a:0;e.mergeNodeData(u,{x:n.data.x+l,y:n.data.y+c,z:n.data.z+f});var g=Math.sqrt(l*l+c*c+f*f);switch(i){case"max":o.judgingDistance<g&&(o.judgingDistance=g);break;case"min":o.judgingDistance>g&&(o.judgingDistance=g);break;default:d+=g}}})),i&&"mean"!==i||(this.judgingDistance=d/u.length)}else this.judgingDistance=0},t}(),At=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=kt(t,"leaf",r,e))})),n},kt=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:_t(t,e,n,r,s)}},_t=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},zt=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Rt=function(t,e){return e.map((function(e){var r=e.id,o=e.data,i=t.getNode(r);return n(n({},i),{data:n(n({},i.data),{x:o.x,y:o.y,z:o.z})})}))};const It=function(t){return p(t,"String")};var Dt={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},Pt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},Dt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,c,g,p,m,w,x,E,M,S,A,k,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U,H,Y;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=o.sortBy,h=o.maxLevelDiff,l=o.sweep,c=o.clockwise,g=o.equidistant,p=o.preventOverlap,m=o.startAngle,w=void 0===m?1.5*Math.PI:m,x=o.nodeSize,E=o.nodeSpacing,M=e.getAllNodes(),S=e.getAllEdges(),A=s||"undefined"==typeof window?s:window.innerWidth,k=u||"undefined"==typeof window?u:window.innerHeight,z=i||[A/2,k/2],!(null==M?void 0:M.length)||1===M.length)return[2,N(e,t,z)];if(R=[],D=0,_(x)?I=Math.max(x[0],x[1]):f(x)?(I=-1/0,M.forEach((function(t){var e=x(t);e>I&&(I=e)}))):I=x,_(E)?D=Math.max(E[0],E[1]):v(E)&&(D=E),M.forEach((function(t){var e=b(t);R.push(e);var r=I,n=e.data;_(n.size)?r=Math.max(n.size[0],n.size[1]):v(n.size)?r=n.size:y(n.size)&&(r=Math.max(n.size.width,n.size.height)),I=Math.max(I,r),f(E)&&(D=Math.max(E(t),D))})),P={},R.forEach((function(t,e){P[t.id]=e})),It(O=d)&&void 0!==R[0].data[O]||(O="degree"),"degree"===O?R.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):R.sort((function(t,e){return e.data[O]-t.data[O]})),T=R[0],C=(h||("degree"===O?e.getDegree(T.id,"both"):T.data[O]))/4,q=(L=[{nodes:[]}])[0],R.forEach((function(t){if(q.nodes.length>0){var r="degree"===O?Math.abs(e.getDegree(q.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(q.nodes[0].data[O]-t.data[O]);C&&r>=C&&(q={nodes:[]},L.push(q))}q.nodes.push(t)})),j=I+D,p||(F=L.length>0&&L[0].nodes.length>1,V=Math.min(A,k)/2-j,B=V/(L.length+(F?1:0)),j=Math.min(j,B)),G=0,L.forEach((function(t){var e=void 0===l?2*Math.PI-2*Math.PI/t.nodes.length:l;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(j*j/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=j})),g){for(W=0,$=0,U=0;U<L.length;U++)H=L[U],Y=(H.r||0)-$,W=Math.max(W,Y);$=0,L.forEach((function(t,e){0===e&&($=t.r||0),t.r=$,$+=W}))}return L.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=w+(c?1:-1)*e*n;t.data.x=z[0]+r*Math.cos(o),t.data.y=z[1]+r*Math.sin(o)}))})),t&&R.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:R,edges:S}]}))}))},t}(),Ot={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Tt={center:[0,0],comboPadding:10,treeKey:"combo"},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=n(n({},Tt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,l,f,g,p,v,y,m,w,x,E,b,M,S,A,k,_,z;return a(this,(function(a){switch(a.label){case 0:return o=this.initVals(n(n({},this.options),r)),i=o.center,d=o.treeKey,h=o.outerLayout,l=e.getAllNodes().filter((function(t){return!t.data._isCombo})),f=e.getAllNodes().filter((function(t){return t.data._isCombo})),g=e.getAllEdges(),(p=null==l?void 0:l.length)&&1!==p?(v=[],y=new Map,l.forEach((function(t){y.set(t.id,t)})),m=new Map,f.forEach((function(t){m.set(t.id,t)})),w=new Map,x=this.getInnerGraphs(e,d,y,m,g,o,w),[4,Promise.all(x)]):[2,N(e,t,i)];case 1:return a.sent(),E=new Map,b=[],M=new Map,S=!0,e.getRoots(d).forEach((function(t){var r=w.get(t.id),o=m.get(t.id)||y.get(t.id),i={id:t.id,data:n(n({},t.data),{x:r.data.x||o.data.x,y:r.data.y||o.data.y,fx:r.data.fx||o.data.fx,fy:r.data.fy||o.data.fy,mass:r.data.mass||o.data.mass,size:r.data.size})};b.push(i),E.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):S=!1,D(e,[t],(function(e){e.id!==t.id&&M.set(e.id,t.id)}),"TB",d)})),A=[],g.forEach((function(t){var e=M.get(t.source)||t.source,r=M.get(t.target)||t.target;e!==r&&E.has(e)&&E.has(r)&&A.push({id:t.id,source:e,target:r,data:{}})})),(null==b?void 0:b.length)?1!==b.length?[3,2]:(b[0].data.x=i[0],b[0].data.y=i[1],[3,6]):[3,7];case 2:return _=new c({nodes:b,edges:A}),z=h||new St,S&&Ot[z.id]?[4,(b.length<100?new rt:new Pt).assign(_)]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,z.execute(_,n({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===z.id?{gravity:1,factor:4,linkDistance:function(t,e,r){return(Math.max.apply(Math,u([],s(e.data.size)))||32)/2+(Math.max.apply(Math,u([],s(r.data.size)))||32)/2+200}}:{}))];case 5:k=a.sent(),a.label=6;case 6:w.forEach((function(t){var e,r=k.nodes.find((function(e){return e.id===t.id}));if(r){var n=r.data,o=n.x,i=n.y;t.data.visited=!0,t.data.x=o,t.data.y=i,v.push({id:t.id,data:{x:o,y:i}})}var a=t.data,s=a.x,u=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){v.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+u}})}))})),w.forEach((function(t){var e,r=t.data,n=r.x,o=r.y,i=r.visited;null===(e=r.nodes)||void 0===e||e.forEach((function(t){if(!i){var e=v.find((function(e){return e.id===t.id}));e.data.x+=n||0,e.data.y+=o||0}}))})),a.label=7;case 7:return t&&v.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:v,edges:g}]}}))}))},t.prototype.initVals=function(t){var e,r,o,i=n({},t),a=t.nodeSize,s=t.spacing,u=t.comboPadding;if(r=v(s)?function(){return s}:f(s)?s:function(){return 0},i.spacing=r,a)if(f(a))e=function(t){var e=a(t),n=r(t);return _(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+n)/2:((e||32)+n)/2};else if(_(a)){var d=(a[0]>a[1]?a[0]:a[1])/2;e=function(t){return d+r(t)/2}}else{var h=a/2;e=function(t){return h+r(t)/2}}else e=function(t){var e=r(t);return t.size?_(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:y(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return i.nodeSize=e,o=v(u)?function(){return u}:_(u)?function(){return Math.max.apply(null,u)}:f(u)?u:function(){return 0},i.comboPadding=o,i},t.prototype.getInnerGraphs=function(t,e,r,o,d,h,l){var f=this,g=h.nodeSize,p=h.comboPadding,y=h.spacing,m=h.innerLayout||new Pt({}),w={center:[0,0],preventOverlap:!0,nodeSpacing:y},x=[],E=function(t){var e=(null==p?void 0:p(t))||10;return _(e)&&(e=Math.max.apply(Math,u([],s(e)))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(u){l.set(u.id,{id:u.id,data:{nodes:[],size:E(u).size}});var h=Promise.resolve();D(t,[u],(function(u){var p;if(u.data._isCombo){var y=E(u),x=y.size,b=y.padding;if(null===(p=t.getChildren(u.id,e))||void 0===p?void 0:p.length){var N=l.get(u.id);l.set(u.id,{id:u.id,data:n({nodes:[]},null==N?void 0:N.data)});var M=new Map,S=t.getChildren(u.id,e).map((function(t){if(t.data._isCombo)return l.has(t.id)||l.set(t.id,{id:t.id,data:n({},t.data)}),M.set(t.id,!0),l.get(t.id);var e=r.get(t.id)||o.get(t.id);return M.set(t.id,!0),{id:t.id,data:n(n({},e.data),t.data)}})),A={nodes:S,edges:d.filter((function(t){return M.has(t.source)&&M.has(t.target)}))},k=1/0;S.forEach((function(t){var e,r,n=t.data.size;n||(n=(null===(e=l.get(t.id))||void 0===e?void 0:e.data.size)||(null===(r=g)||void 0===r?void 0:r(t))||[30,30]),v(n)&&(n=[n,n]);var o=s(n,2),i=o[0],a=o[1];k>i&&(k=i),k>a&&(k=a),t.data.size=n})),h=h.then((function(){return i(f,void 0,void 0,(function(){var t,e,r,n,o,i,s,d,h;return a(this,(function(a){switch(a.label){case 0:return t=new c(A),[4,m.assign(t,w)];case 1:return e=a.sent(),r=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((function(t){var i=t.data.size;_(i)?1===i.length&&(i=[i[0],i[0]]):v(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);var a=[i[0]/2,i[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],d=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),r>d&&(r=d),n<u&&(n=u),o<h&&(o=h)})),{minX:e,minY:r,maxX:n,maxY:o}}(S),n=r.minX,o=r.minY,i=r.maxX,s=r.maxY,d={x:(i+n)/2,y:(s+o)/2},A.nodes.forEach((function(t){t.data.x-=d.x,t.data.y-=d.y})),h=[Math.max(i-n,k)+2*b,Math.max(s-o,k)+2*b],l.get(u.id).data.size=h,l.get(u.id).data.nodes=S,[2,e]}}))}))}))}else l.set(u.id,{id:u.id,data:n(n({},u.data),{size:x})});return!0}}),"BT",e),x.push(h)})),x},t}();function Lt(t){return function(){return t}}function qt(t){return 1e-6*(t()-.5)}var jt={value:()=>{}};function Ft(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new Vt(n)}function Vt(t){this._=t}function Bt(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function Gt(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=jt,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Vt.prototype=Ft.prototype={constructor:Vt,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(r=(t=i[a]).type)o[r]=Gt(o[r],t.name,e);else if(null==e)for(r in o)o[r]=Gt(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=Bt(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Vt(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Wt=Ft;var $t,Ut,Ht=0,Yt=0,Kt=0,Jt=1e3,Xt=0,Qt=0,Zt=0,te="object"==typeof performance&&performance.now?performance:Date,ee="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function re(){return Qt||(ee(ne),Qt=te.now()+Zt)}function ne(){Qt=0}function oe(){this._call=this._time=this._next=null}function ie(t,e,r){var n=new oe;return n.restart(t,e,r),n}function ae(){Qt=(Xt=te.now())+Zt,Ht=Yt=0;try{!function(){re(),++Ht;for(var t,e=$t;e;)(t=Qt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ht}()}finally{Ht=0,function(){for(var t,e,r=$t,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:$t=e);Ut=t,ue(n)}(),Qt=0}}function se(){var t=te.now(),e=t-Xt;e>Jt&&(Zt-=e,Xt=t)}function ue(t){Ht||(Yt&&(Yt=clearTimeout(Yt)),t-Qt>24?(t<1/0&&(Yt=setTimeout(ae,t-te.now()-Zt)),Kt&&(Kt=clearInterval(Kt))):(Kt||(Xt=te.now(),Kt=setInterval(se,Jt)),Ht=1,ee(ae)))}oe.prototype=ie.prototype={constructor:oe,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?re():+r)+(null==e?0:+e),this._next||Ut===this||(Ut?Ut._next=this:$t=this,Ut=this),this._call=t,this._time=r,ue()},stop:function(){this._call&&(this._call=null,this._time=1/0,ue())}};const de=1664525,he=1013904223,le=4294967296;function ce(t){return t.x}function fe(t){return t.y}var ge=10,pe=Math.PI*(3-Math.sqrt(5));function ve(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=ie(l),d=Wt("tick","end"),h=function(){let t=1;return()=>(t=(de*t+he)%le)/le}();function l(){c(),d.call("tick",e),r<n&&(u.stop(),d.call("end",e))}function c(n){var u,d,h=t.length;void 0===n&&(n=1);for(var l=0;l<n;++l)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<h;++u)null==(d=t[u]).fx?d.x+=d.vx*=a:(d.x=d.fx,d.vx=0),null==d.fy?d.y+=d.vy*=a:(d.y=d.fy,d.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=ge*Math.sqrt(.5+r),i=r*pe;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:c,restart:function(){return u.restart(l),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(g),e):h},force:function(t,r){return arguments.length>1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,d=0,h=t.length;for(null==n?n=1/0:n*=n,d=0;d<h;++d)(a=(o=e-(s=t[d]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(d.on(t,r),e):d.on(t)}}}function ye(){var t,e,r,n,o,i=Lt(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=dt(t,ce,fe).visitAfter(l);for(n=r,o=0;o<i;++o)e=t[o],a.visit(c)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function l(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function c(t,i,d,h){if(!t.value)return!0;var l=t.x-e.x,c=t.y-e.y,f=h-i,g=l*l+c*c;if(f*f/u<g)return g<s&&(0===l&&(g+=(l=qt(r))*l),0===c&&(g+=(c=qt(r))*c),g<a&&(g=Math.sqrt(a*g)),e.vx+=l*t.value*n/g,e.vy+=c*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===l&&(g+=(l=qt(r))*l),0===c&&(g+=(c=qt(r))*c),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=l*f,e.vy+=c*f)}while(t=t.next)}}return d.initialize=function(e,n){t=e,r=n,h()},d.strength=function(t){return arguments.length?(i="function"==typeof t?t:Lt(+t),h(),d):i},d.distanceMin=function(t){return arguments.length?(a=t*t,d):Math.sqrt(a)},d.distanceMax=function(t){return arguments.length?(s=t*t,d):Math.sqrt(s)},d.theta=function(t){return arguments.length?(u=t*t,d):Math.sqrt(u)},d}function me(t){return t.index}function we(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function xe(t){var e,r,n,o,i,a,s=me,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=Lt(30),h=1;function l(n){for(var o=0,s=t.length;o<h;++o)for(var u,d,l,c,f,g,p,v=0;v<s;++v)d=(u=t[v]).source,c=(l=u.target).x+l.vx-d.x-d.vx||qt(a),f=l.y+l.vy-d.y-d.vy||qt(a),c*=g=((g=Math.sqrt(c*c+f*f))-r[v])/g*n*e[v],f*=g,l.vx-=c*(p=i[v]),l.vy-=f*p,d.vx+=c*(p=1-p),d.vy+=f*p}function c(){if(n){var a,u,d=n.length,h=t.length,l=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(d);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=we(l,u.source)),"object"!=typeof u.target&&(u.target=we(l,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(h);a<h;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+d(t[e],e,t)}return null==t&&(t=[]),l.initialize=function(t,e){n=t,a=e,c()},l.links=function(e){return arguments.length?(t=e,c(),l):t},l.id=function(t){return arguments.length?(s=t,l):s},l.iterations=function(t){return arguments.length?(h=+t,l):h},l.strength=function(t){return arguments.length?(u="function"==typeof t?t:Lt(+t),f(),l):u},l.distance=function(t){return arguments.length?(d="function"==typeof t?t:Lt(+t),g(),l):d},l}function Ee(t){return t.x+t.vx}function be(t){return t.y+t.vy}function Ne(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,d,h,l,c,f=e.length,g=0;g<i;++g)for(a=dt(e,Ee,be).visitAfter(s),t=0;t<f;++t)u=e[t],l=r[u.index],c=l*l,d=u.x+u.vx,h=u.y+u.vy,a.visit(p);function p(t,e,r,i,a){var s=t.data,f=t.r,g=l+f;if(!s)return e>d+g||i<d-g||r>h+g||a<h-g;if(s.index>u.index){var p=d-s.x-s.vx,v=h-s.y-s.vy,y=p*p+v*v;y<g*g&&(0===p&&(y+=(p=qt(n))*p),0===v&&(y+=(v=qt(n))*v),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(p*=y)*(g=(f*=f)/(c+f)),u.vy+=(v*=y)*g,s.vx-=p*(g=1-g),s.vy-=v*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=Lt(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Lt(+e),u(),a):t},a}function Me(t){var e,r,n,o=Lt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=Lt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Lt(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:Lt(+e),a(),i):t},i}function Se(t){var e,r,n,o=Lt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=Lt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Lt(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:Lt(+e),a(),i):t},i}function Ae(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),u=[0,0],d=[],h={},l=[],c=100,f=100,g={none:{x:0,y:0}},p=[],v="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),E();for(var n=0,o=d.length,i=void 0,a=t*m;n<o;++n)(i=d[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){d&&function(){if(d&&d.length){if(void 0===r(d[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,u,g,v,y,m=(t=[],u=[],g={},{},y=[],v=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(d),y=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,(a=r(h[o]))<=(s=r(h[i]))?a+"~"+s:s+"~"+a),d=0;void 0!==e[u]&&(d=e[u]),d+=1,e[u]=d})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(l),Object.keys(v).forEach((function(e,r){var n=v[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),y.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=ve(m.nodes).force("x",Me(c).strength(.1)).force("y",Se(f).strength(.1)).force("collide",Ne((function(t){return t.r})).iterations(4)).force("charge",ye().strength(o)).force("links",xe(m.nodes.length?m.links:[]).distance(i).strength(a)),p=e.nodes(),E()}}()}function E(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}return w.initialize=function(t){d=t,x()},w.template=function(t){return arguments.length?(v=t,x(),w):v},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(c=t,w):c},w.centerY=function(t){return arguments.length?(f=t,w):f},w.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),d=t||[],w):d},w.links=function(t){return arguments.length?(l=t||[],x(),w):l},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(u=t,w):u},w.getFocis=E,w}var ke={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},_e=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=n(n({},ke),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:ze(this.lastLayoutNodes),edges:Re(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,c,f,g,p,v,y,m,w,x,E,N,M,S,A,k,_,z,R,I,D=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=i.map((function(t){var e,r;return n(n({},b(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),d=s.map((function(t){return b(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,h=o.alphaMin,l=o.alphaDecay,c=o.alpha,f=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,v=o.clustering,y=o.clusterFociStrength,m=o.clusterEdgeDistance,w=o.clusterEdgeStrength,x=o.clusterNodeStrength,E=o.clusterNodeSize,N=o.collideStrength,M=void 0===N?1:N,S=o.center,A=void 0===S?[0,0]:S,k=o.preventOverlap,_=o.nodeSize,z=o.nodeSpacing,R=o.onTick,I=o.forceSimulation,[2,new Promise((function(r){if(I){v&&((i=Ae()).nodes(u),i.links(d)),I.nodes(u),d&&(s=xe().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),I.force("link",s)),k&&D.overlapProcess(I,{nodeSize:_,nodeSpacing:z,collideStrength:M}),I.alpha(c).restart();var n=ze(u),o=Re(d);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=ye();if(f&&a.strength(f),I=ve().nodes(u),v&&((i=Ae()).centerX(A[0]).centerY(A[1]).template("force").strength(y),d&&i.links(d),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(E),I.force("group",i)),I.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(A[0],A[1])).force("charge",a).alpha(c).alphaDecay(l).alphaMin(h),k&&D.overlapProcess(I,{nodeSize:_,nodeSpacing:z,collideStrength:M}),d){var s=xe().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),I.force("link",s)}I.on("tick",(function(){var r=ze(u);null==R||R({nodes:r,edges:Re(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=ze(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Re(d)})}))}catch(t){console.warn(t)}D.forceSimulation=I}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=v(i)?function(){return i}:f(i)?i:function(){return 0},o)if(f(o))r=function(t){return o(t)+n(t)};else if(_(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(v(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?_(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):y(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Ne(r).strength(a))},t}(),ze=function(t){return t.map((function(t){var e=t.x,r=t.y,i=o(t,["x","y"]);return n(n({},i),{data:n(n({},i.data),{x:e,y:r})})}))},Re=function(t){return t.map((function(t){var e=t.source,r=t.target,i=o(t,["source","target"]);return n(n({},i),{source:e.id,target:r.id})}))};var Ie=function(t,e){if("next"!==t&&"prev"!==t)return e},De=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return De(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&De(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,Ie)),r=null==r?void 0:r.prev;return"["+t.join(", ")+"]"},t}()),Oe=function(){return 1},Te=function(t,e,r,o,i){var a,s,u=[];return t.hasNode(o.v)&&(null===(a=t.getRelatedEdges(o.v,"in"))||void 0===a||a.forEach((function(o){var a=o.data.weight,s=t.getNode(o.source);i&&u.push({v:o.source,w:o.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,Ce(e,r,n({v:s.id},s.data))})),null===(s=t.getRelatedEdges(o.v,"out"))||void 0===s||s.forEach((function(o){var i=o.data.weight,a=o.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,Ce(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Ce=function(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},Le=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var o=function(t,e){var r=new c,o=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,n(n({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),o=Math.max(o,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+o+3,u=0;u<s;u++)a.push(new Pe);var d=o+1;return r.getAllNodes().forEach((function(t){Ce(a,d,n({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:d,graph:r}}(t,function(t){return t.data.weight||1}||Oe);return null===(r=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)Te(t,e,r,n);for(;n=i.dequeue();)Te(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(Te(t,e,r,n,!0));break}}return o}(o.graph,o.buckets,o.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t):qe(t);null==r||r.forEach((function(e){var r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:n({},r)})}))},qe=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},je=function(t,e,r,n){var o;do{o=""+n+Math.random()}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},Fe=function(t){var e=new c;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(n({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},Ve=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,d=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*d?(s<0&&(d=-d),r=d*a/s,n=d):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},Be=function(t){for(var e=[],r=We(t)+1,n=0;n<r;n++)e.push([]);for(t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)})),n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},Ge=function(t,e,r,n){var o={width:0,height:0};return v(r)&&v(n)&&(o.rank=r,o.order=n),je(t,"border",o,e)},We=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},$e=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},Ue=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return Ue(t,e,r,n,o,i)})),r&&i.push(e.id))},He=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);Ue(t,e,"post"===r,s,i,a)})),a},Ye="edge-label",Ke=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},Je=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},Xe=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||Je(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},Qe=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&Je(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},Ze=function(t,e){return $e(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?Je(e,r):1/0}))},tr=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},er=function(t,e){var r=He(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){rr(t,e,r)}))},rr=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=nr(t,e,r)},nr=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,d=e.data.weight;if(a+=u?d:-d,hr(t,r,s)){var h=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},or=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),ir(t,{},1,e)},ir=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=ir(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},ar=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},sr=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var d=e.getAllEdges().filter((function(e){return u===lr(t.getNode(e.source),s)&&u!==lr(t.getNode(e.target),s)}));return $e(d,(function(t){return Je(e,t)}))},ur=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return t.source===r.target||t.target===r.target}));o&&t.removeEdge(o.id),t.addEdge({id:"e"+Math.random(),source:n.source,target:n.target,data:{}}),or(t),er(t,e),dr(t,e)},dr=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=He(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},hr=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},lr=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},cr=Ke,fr=function(t){!function(t){var e=function(t){var e=new c;return t.getAllNodes().forEach((function(t){e.addNode(n({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,n(n({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);Ke(e);var r,o,i=function(t){var e,r,n=new c({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Xe(n,t)<i;)e=Ze(n,t),r=n.hasNode(e.source)?Je(t,e):-Je(t,e),tr(n,t,r);return n}(e);for(or(i),er(i,e);r=ar(i);)o=sr(i,e,r),ur(i,e,r,o)}(t)},gr=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=Ge(t,"_bt"),d=Ge(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(d,a),h.data.borderBottom=d,null==s||s.forEach((function(s){gr(t,e,r,n,o,i,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,l=s.data.borderBottom?s.data.borderBottom:s.id,c=s.data.borderTop?n:2*n,f=h!==l?1:o-i[a]+1;t.addEdge({id:"e"+Math.random(),source:u,target:h,data:{minlen:f,weight:c,nestingEdge:!0}}),t.addEdge({id:"e"+Math.random(),source:l,target:d,data:{minlen:f,weight:c,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e"+Math.random(),source:e,target:u,data:{weight:0,minlen:o+i[a]}})}else a!==e&&t.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:r}})},pr=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=je(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:"e"+Math.random(),source:s,target:u,data:{weight:1}})},vr=function(t){t.getAllNodes().forEach((function(t){yr(t)})),t.getAllEdges().forEach((function(t){yr(t)}))},yr=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},mr=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},wr=function(t){var e=t.x;t.x=t.y,t.y=e},xr=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,u([],s(n))),i=[],a=0;a<o+1;a++)i.push([]);var d=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),h=d.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==h||h.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==d||d.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},Er=function(t,e,r){for(var n=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})}(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),d=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;d+=t.weight*r}})),d},br=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=Er(t,e[n-1],e[n]);return r},Nr=function(t,e){var r,n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};const Mr=function(t,e){var r,n,o,i={};return null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))})),function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Nr(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))}(null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree})))};var Sr=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},Ar=function(t,e,r,n,o,i){var a,s,u,d,h=t.getChildren(e).map((function(t){return t.id})),l=t.getNode(e),c=l?l.data.borderLeft:void 0,f=l?l.data.borderRight:void 0,g={};c&&(h=null==h?void 0:h.filter((function(t){return t!==c&&t!==f})));var p=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))}(t,h||[]);null==p||p.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=Ar(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&_r(e,a)}}));var v=Mr(p,r);kr(v,g),null===(a=v.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){var e,o;o=(e=t).hasOwnProperty("fixorder")&&!isNaN(e.fixorder),(n?!o&&e.hasOwnProperty("barycenter"):o||e.hasOwnProperty("barycenter"))?r.lhs.push(t):r.rhs.push(t)})),r}(t),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,d=0,h=0;null==i||i.sort(function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}}(!!e,!!r)),h=Sr(s,a,h),null==i||i.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,d+=t.weight,h=Sr(s,a,h)}));var l={vs:s.flat()};return d&&(l.barycenter=u/d,l.weight=d),l}(v,n,o,i);if(c&&(y.vs=[c,y.vs,f].flat(),null===(s=t.getPredecessors(c))||void 0===s?void 0:s.length)){var m=t.getNode((null===(u=t.getPredecessors(c))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(d=t.getPredecessors(f))||void 0===d?void 0:d[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},kr=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},_r=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},zr=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):p(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=zr(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=zr(t[i]):e[i]=t[i];return e};const Rr=zr;var Ir=function(t,e,r){return e.map((function(e){return function(t,e,r){var o=function(t){for(var e;t.hasNode(e="_root"+Math.random()););return e}(t),i=new c({tree:[{id:o,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(n({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(n({},s)),i.setParent(a.id,(null==s?void 0:s.id)||o),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(n({},t.getNode(r)));var o=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==o?o.data.weight:0;o?i.updateEdgeData(o.id,n(n({},o.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,n(n({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},Dr=function(t,e,r,n){var o=new c;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=Ar(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var d=t.getNode(s.vs[u]);d&&(d.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge("e"+a+"-"+s.id)||e.addEdge({id:"e"+a+"-"+s.id,source:a,target:s.id,data:{}}));s=i}}))}(t,o,s.vs)}))},Pr=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Or=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,d,h=n;h<o;h++)d=e[h],(null===(s=t.getNode(d))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(d))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&Cr(r,e.id,d)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,u([],s(t))),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,d){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var l=t.getPredecessors(u)||[];l.length&&(n=t.getNode(l[0].id).data.order,o([r,a,d,i,n],s),a=d,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},Tr=function(t,e){var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((function(e){return t.getNode(e.id).data.dummy}))},Cr=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},Lr=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},qr=function(t,e,r,o,i,a){var s=new c,u=jr(o,i,a);return null==e||e.forEach((function(e){var o;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),o){var a=r[o],d=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));d?s.updateEdgeData(d.id,n(n({},d.data),{weight:Math.max(u(t,e,o),d.data.weight||0)})):s.addEdge({id:"e"+Math.random(),source:a,target:i,data:{weight:Math.max(u(t,e,o),0)}})}o=e}))})),s};var jr=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,d=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":d=-a.data.width/2;break;case"r":d=a.data.width/2}if(d&&(u+=r?d:-d),d=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":d=s.data.width/2;break;case"r":d=-s.data.width/2}return d&&(u+=r?d:-d),d=0,u}},Fr=function(t,e){return t.getNode(e).data.width||0},Vr=function(t,e){var r,n=Fe(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=Be(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,u(u([],s(r)),[0]));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=r.nodesep,i=void 0===o?0:o,a=r.edgesep,d=void 0===a?0:a,h=Be(t),l=Object.assign(function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var d,h=Tr(t,e),l=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(d=n.slice(i,u+1))||void 0===d||d.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||l<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Cr(r,n.id,e)}))})),i=u+1,o=l)})),n})),r}(t,h),Or(t,h)),c={},f=[];["u","d"].forEach((function(e){f="u"===e?h:Object.values(h).reverse(),["l","r"].forEach((function(r){"r"===r&&(f=f.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,d=Math.floor(u),h=Math.ceil(u);d<=h;++d){var l=s[d];i[t]===t&&e<a[l]&&!Lr(r,t,l)&&(i[l]=t,i[t]=o[t]=o[l],e=a[l])}}}))})),{root:o,align:i}}(0,f,l,n),a=function(t,e,r,n,o,i,a){var s,u={},d=qr(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",l=function(t,e){for(var r=d.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return l((function(t){u[t]=(d.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),d.getPredecessors.bind(d)),l((function(e){var r=(d.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),d.getSuccessors.bind(d)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u}(t,f,o.root,o.align,i,d,"r"===r);"r"===r&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),c[e+r]=a}))}));var g=function(t,e){return $e(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=Fr(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))}(t,c);return g&&function(t,e){var r=Object.values(e),n=Math.min.apply(Math,u([],s(r))),o=Math.max.apply(Math,u([],s(r)));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,d=r+i,h=t[d];if(h!==e){var l=Object.values(h);(a="l"===i?n-Math.min.apply(Math,u([],s(l))):o-Math.max.apply(Math,u([],s(l))))&&(t[d]={},Object.keys(h).forEach((function(e){t[d][e]=h[e]+a})))}}))}))}(c,g),function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r}(c,n)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},Br=function(t,e){var r=e.acyclicer,o=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,d=e.nodeOrder,h=e.keepNodeOrder,l=e.align,f=e.nodesep,g=void 0===f?50:f,p=e.edgesep,v=void 0===p?20:p,y=e.ranksep,m=void 0===y?50:y;rn(t),Le(t,r);var w=function(t){var e=je(t,"root",{},"_root"),r=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e}(t),n=Math.max.apply(Math,u([],s(Object.values(r))));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e}(t)+1;return t.getRoots().forEach((function(n){gr(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),x=w.nestingRoot,E=w.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":fr(t);break;case"tight-tree":default:!function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new c({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Qe(n,t)<i;)e=Ze(n,t),r=n.hasNode(e.source)?Je(t,e):-Je(t,e),tr(n,t,r)}(t)}(t);break;case"longest-path":cr(t)}}(Fe(t),o),Yr(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,u([],s(n))),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,d=0;d<i.length;d++){var h=i[d];void 0===h?d%e!=0&&(a-=1):a&&(null==h||h.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,E),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,x),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,u([],s(e)));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),Kr(t),Jr(t);var b=[];!function(t,e){t.getAllEdges().forEach((function(r){return function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,d,h;for(t.removeEdge(e.id),h=0,++o;o<a;++h,++o)e.data.points=[],u=je(t,"edge",d={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(d.width=e.data.width,d.height=e.data.height,d.dummy=Ye,d.labelpos=e.data.labelpos),t.addEdge({id:"e"+Math.random(),source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:"e"+Math.random(),source:n,target:i,data:{weight:e.data.weight}})}}(t,r,e)}))}(t,b),function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],d=[],h=Math.min(e[r].low,e[n].low),l=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>h||l>e[a].lim));for(s=a,a=n;a&&a!==s;)d.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(d.reverse())}}(t,r,s.source,s.target),d=u.path,h=u.lca,l=0,c=d[l],f=!0;i!==s.target;){if(a=t.getNode(i),f){for(;c!==h&&(null===(n=t.getNode(c))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)c=d[++l];c===h&&(f=!1)}if(!f){for(;l<d.length-1&&(null===(o=t.getNode(d[l+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)l++;c=d[l]}t.hasNode(c)&&t.setParent(i,c),i=t.getSuccessors(i)[0].id}}))}(t,b),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)pr(t,"borderLeft","_bl",r,o,i),pr(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),h&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,u([],s(r))),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var r=t.getNode(e);r&&!r.data.dummy&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))}(t,d),function(t,e){for(var r=We(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=Ir(t,n,"in"),s=Ir(t,o,"out"),u=xr(t);Pr(t,u);for(var d,h=Number.POSITIVE_INFINITY,l=(i=0,0);l<4;++i,++l)Dr(i%2?a:s,i%4>=2,!1,e),u=Be(t),(c=br(t,u))<h&&(l=0,d=Rr(u),h=c);for(u=xr(t),Pr(t,u),i=0,l=0;l<4;++i,++l){var c;Dr(i%2?a:s,i%4>=2,!0,e),u=Be(t),(c=br(t,u))<h&&(l=0,d=Rr(u),h=c)}Pr(t,d)}(t,h),nn(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||vr(t)}(t,a),Vr(t,{align:l,nodesep:g,edgesep:v,ranksep:m}),on(t),en(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Ye&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,b),Zr(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){mr(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return mr(t)})),t.data.hasOwnProperty("y")&&mr(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){wr(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return wr(t)})),t.data.hasOwnProperty("x")&&wr(t.data)}))}(t),vr(t))}(t,a);var N=Xr(t),M=N.width,S=N.height;return Qr(t),tn(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var o=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:n(n({},r),{forwardName:o})})}}))}(t),{width:M,height:S}},Gr=["width","height","layer","fixorder"],Wr={width:0,height:0},$r=["minlen","weight","width","height","labeloffset"],Ur={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Hr=["labelpos"],Yr=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};je(t,"edge-proxy",n,"_ep")}}))},Kr=function(t){var e=0;return t.getAllNodes().forEach((function(r){var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},Jr=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Xr=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,d=a.marginy,h=void 0===d?0:d,l=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))}};return t.getAllNodes().forEach((function(t){l(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&l(t)})),r-=u,n-=h,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+u,height:i-n+h}},Qr=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(Ve(o.data,r)),e.data.points.push(Ve(i.data,n))}))},Zr=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},tn=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},en=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),d=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==d?void 0:d.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},rn=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},nn=function(t){var e=Be(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){je(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},on=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},an=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},sn=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},un={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},dn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=n(n({},un),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,f,g,p,y,w,E,N,M,S,A,k,_,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$;return a(this,(function(a){return o=n(n({},this.options),r),i=o.nodeSize,s=o.align,u=o.rankdir,d=void 0===u?"TB":u,h=o.ranksep,l=o.nodesep,f=o.ranksepFunc,g=o.nodesepFunc,p=o.edgeLabelSpace,y=o.nodeOrder,w=o.begin,E=o.controlPoints,N=o.radial,M=o.sortByCombo,S=o.preset,A=new c({tree:[]}),k=m(h||50,f),_=m(l||50,g),z=_,R=k,"LR"!==d&&"RL"!==d||(z=k,R=_),I=x(i,void 0),D=e.getAllNodes(),P=e.getAllEdges(),D.forEach((function(t){var e=I(t),r=R(t),n=e+2*z(t),o=e+2*r,i=t.data.layer;v(i)?A.addNode({id:t.id,data:{width:n,height:o,layer:i}}):A.addNode({id:t.id,data:{width:n,height:o}})})),M&&(A.attachTreeStructure("combo"),D.forEach((function(t){var e=t.data.parentId;void 0!==e&&A.hasNode(e)&&A.setParent(t.id,e,"combo")}))),P.forEach((function(t){A.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),O=void 0,(null==S?void 0:S.length)&&(O=new c({nodes:S})),function(t,e){var r,o,i=e.edgeLabelSpace,a=e.keepNodeOrder,s=e.prevGraph,u=e.rankdir,d=e.ranksep;!a&&s&&(o=s,(r=t).getAllNodes().forEach((function(t){var e=r.getNode(t.id);if(o.hasNode(t.id)){var n=o.getNode(t.id);e.data.fixorder=n.data._order,delete n.data._order}else delete e.data.fixorder})));var h=function(t){var e=new c({tree:[]});return t.getAllNodes().forEach((function(r){var o=sn(t.getNode(r.id).data),i=n(n({},Wr),o),a=an(i,Gr);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);null==s||(e.hasNode(s.id)||e.addNode(n({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=sn(t.getEdge(r.id).data),o={};null==Hr||Hr.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},Ur,an(n,$r),o)})})),e}(t);i&&(e.ranksep=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2}(h,{rankdir:u,ranksep:d}));try{Br(h,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}!function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))}(t,h)}(A,{prevGraph:O,edgeLabelSpace:p,keepNodeOrder:!!y,nodeOrder:y||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:d,nodesep:l,align:s}),T=[0,0],w&&(C=1/0,L=1/0,A.getAllNodes().forEach((function(t){C>t.data.x&&(C=t.data.x),L>t.data.y&&(L=t.data.y)})),A.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){C>t.x&&(C=t.x),L>t.y&&(L=t.y)}))})),T[0]=w[0]-C,T[1]=w[1]-L),q="LR"===d||"RL"===d,N||(j=new Set,F="BT"===d||"RL"===d?function(t,e){return e-t}:function(t,e){return t-e},A.getAllNodes().forEach((function(t){t.data.x=t.data.x+T[0],t.data.y=t.data.y+T[1],j.add(q?t.data.x:t.data.y)})),V=Array.from(j).sort(F),B=q?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},G=q?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},A.getAllEdges().forEach((function(t,e){var r;p&&E&&"loop"!==t.data.type&&(t.data.controlPoints=hn(null===(r=t.data.points)||void 0===r?void 0:r.map((function(t){var e=t.x,r=t.y;return{x:e+T[0],y:r+T[1]}})),A.getNode(t.source),A.getNode(t.target),V,q,B,G))}))),W=[],W=A.getAllNodes().map((function(t){return b(t)})),$=A.getAllEdges(),t&&(W.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),$.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:W,edges:$}]}))}))},t}(),hn=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,d=u.x,h=u.y,l=r.data,c=l.x,f=l.y;if(o&&(d=e.data.y,h=e.data.x,c=r.data.y,f=r.data.x),f!==h&&d!==c){var g=n.indexOf(h),p=n[g+1];if(p){var v=s[0],y=o?{x:(h+p)/2,y:(null==v?void 0:v.y)||c}:{x:(null==v?void 0:v.x)||c,y:(h+p)/2};v&&!i(v,y)||s.unshift(y)}var m=n.indexOf(f),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(h+f)/2,y:d}:{x:d,y:(h+f)/2});else if(w>1){var x=n[m-1];if(x){var E=s[s.length-1],b=o?{x:(f+x)/2,y:(null==E?void 0:E.y)||c}:{x:(null==E?void 0:E.x)||d,y:(f+x)/2};E&&!i(E,b)||s.push(b)}}}}return s},ln=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const cn=ln;const fn=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),gn=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var pn,vn={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1},yn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},vn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,f,g,p,v,y,m,w,x,E,M,S,A,k,_,z;return a(this,(function(a){if(o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(r,i.length),u=s.width,d=s.height,h=s.prune,l=s.maxIteration,f=s.nodeSize,g=s.center,!(null==i?void 0:i.length)||1===i.length)return[2,N(e,t,g)];if(p=i.map((function(t){return b(t,[u,d])})),v=o.filter((function(t){return t.source!==t.target})),y=new c({nodes:p,edges:v}),m=this.getSizes(y,e,f),this.run(y,e,l,m,t,s),h){for(w=0;w<v.length;w+=1)x=v[w],E=x.source,M=x.target,S=y.getDegree(E),A=y.getDegree(E),S<=1?(k=y.getNode(M),y.mergeNodeData(E,{x:k.data.x,y:k.data.y})):A<=1&&(_=y.getNode(E),y.mergeNodeData(M,{x:_.data.x,y:_.data.y}));z=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,z)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],d=a.id,h=a.data;if(o[d]=10,v(h.size))o[d]=h.size;else if(_(h.size))isNaN(h.size[0])||(o[d]=Math.max(h.size[0])),isNaN(h.size[1])||(o[d]=Math.max(h.size[1]));else if(y(h.size))o[d]=Math.max(h.size.width,h.size.height);else if(f(r)){var l=r(e.getNode(d));_(l)?o[d]=Math.max.apply(Math,u([],s(l))):o[d]=l}else _(r)?o[d]=Math.max.apply(Math,u([],s(r))):v(r)&&(o[d]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=n(n({},this.options),t),o=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,d=r.maxIteration,h=r.kr,l=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=o||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==d||u?0===d&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),h||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),l||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,d=t.getAllNodes(),h=0,l=r,c={},f={},g={},p=0;p<d.length;p+=1){var v=d[p],y=v.data,m=v.id;if(c[m]=[0,0],s){var w={id:p,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new cn(w)}}for(;l>0;)h=this.oneStep(t,{iter:l,preventOverlapIters:50,krPrime:100,sg:h,forces:c,preForces:f,bodies:g,sizes:n},i),l--,null==u||u({nodes:d,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,d=e.preForces,h=e.bodies,l=e.sizes,c=e.forces,f=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),v=0;v<p.length;v+=1){var y=p[v].id;d[y]=u([],s(c[y])),c[y]=[0,0]}return c=this.getAttrForces(t,n,o,l,c,r),c=g&&(f&&n>o||!f)?this.getOptRepGraForces(t,c,h,r):this.getRepGraForces(t,n,o,c,i,l,r),this.updatePos(t,c,d,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,d=i.prune,h=t.getAllEdges(),l=0;l<h.length;l+=1){var c=h[l],f=c.source,g=c.target,p=t.getNode(f),v=t.getNode(g),y=t.getDegree(f),m=t.getDegree(g);if(!d||!(y<=1||m<=1)){var w=[v.data.x-p.data.x,v.data.y-p.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[f]-n[g]);var E=x,b=E;"linlog"===u&&(b=E=Math.log(1+x)),s&&(E=x/y,b=x/m),a&&e<r&&x<=0?(E=0,b=0):a&&e<r&&x>0&&(E=x,b=x),o[f][0]+=E*w[0],o[g][0]-=b*w[0],o[f][1]+=E*w[1],o[g][1]-=b*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,d=9e10,h=-9e10,l=9e10,c=-9e10,f=0;f<u;f+=1){var g=s[f],p=g.id,v=g.data;a&&t.getDegree(p)<=1||(r[p].setPos(v.x,v.y),v.x>=h&&(h=v.x),v.x<=d&&(d=v.x),v.y>=c&&(c=v.y),v.y<=l&&(l=v.y))}var y=Math.max(h-d,c-l),m=new fn({xmid:(h+d)/2,ymid:(c+l)/2,length:y,massCenter:i,mass:u}),w=new gn(m);for(f=0;f<u;f+=1)p=s[f].id,a&&t.getDegree(p)<=1||r[p].in(m)&&w.insert(r[p]);for(f=0;f<u;f+=1){var x=s[f],E=(p=x.id,v=x.data,t.getDegree(p));if(!(a&&E<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[v.x-i[0],v.y-i[1]],N=Math.hypot(b[0],b[1]);N=N<1e-4?1e-4:N,b[0]=b[0]/N,b[1]=b[1]/N;var M=o*(E+1);e[p][0]-=M*b[0],e[p][1]-=M*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,d=a.kg,h=a.center,l=a.prune,c=t.getAllNodes(),f=c.length,g=0;g<f;g+=1){for(var p=c[g],v=t.getDegree(p.id),y=g+1;y<f;y+=1){var m=c[y],w=t.getDegree(m.id);if(!l||!(v<=1||w<=1)){var x=[m.data.x-p.data.x,m.data.y-p.data.y],E=Math.hypot(x[0],x[1]);E=E<1e-4?1e-4:E,x[0]=x[0]/E,x[1]=x[1]/E,s&&e<r&&(E=E-i[p.id]-i[m.id]);var b=u*(v+1)*(w+1)/E;s&&e<r&&E<0?b=o*(v+1)*(w+1):s&&e<r&&0===E?b=0:s&&e<r&&E>0&&(b=u*(v+1)*(w+1)/E),n[p.id][0]-=b*x[0],n[m.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[m.id][1]+=b*x[1]}}var N=[p.data.x-h[0],p.data.y-h[1]],M=Math.hypot(N[0],N[1]);N[0]=N[0]/M,N[1]=N[1]/M;var S=d*(v+1);n[p.id][0]-=S*N[0],n[p.id][1]-=S*N[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,d=t.getAllNodes(),h=d.length,l=[],c=[],f=0,g=0,p=n,y=0;y<h;y+=1){var m=d[y].id,w=t.getDegree(m);if(!(s&&w<=1)){var x=[e[m][0]-r[m][0],e[m][1]-r[m][1]],E=Math.hypot(x[0],x[1]),b=[e[m][0]+r[m][0],e[m][1]+r[m][1]],N=Math.hypot(b[0],b[1]);l[y]=E,c[y]=N/2,f+=(w+1)*l[y],g+=(w+1)*c[y]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),y=0;y<h;y+=1){var S=d[y],A=(m=S.id,S.data);if(w=t.getDegree(m),!(s&&w<=1||v(A.fx)&&v(A.fy))){var k=i*p/(1+p*Math.sqrt(l[y])),_=Math.hypot(e[m][0],e[m][1]),z=u/(_=_<1e-4?1e-4:_),R=(k=k>z?z:k)*e[m][0],I=k*e[m][1];t.mergeNodeData(m,{x:A.x+R,y:A.y+I})}}return p},t}(),mn={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},wn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},mn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,f,g,p,v,y,m,w,x,E,N=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.dimensions,s=o.width,u=o.height,d=o.center,h=o.clustering,l=o.nodeClusterBy,f=o.maxIteration,g=o.onTick,p=e.getAllNodes(),v=e.getAllEdges(),(null==p?void 0:p.length)?1===p.length?(t&&e.mergeNodeData(p[0].id,{x:d[0],y:d[1],z:3===i?d[2]:void 0}),y={nodes:[n(n({},p[0]),{data:n(n({},p[0].data),{x:d[0],y:d[1],z:3===i?d[2]:void 0})})],edges:v},this.lastResult=y,[2,y]):(m=p.map((function(t){return b(t,[s,u])})),w=new c({nodes:m,edges:v}),x={},h&&m.forEach((function(t){var e=t.data[l];x[e]||(x[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=m,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=w,this.lastOptions=o,this.lastClusterMap=x,"undefined"==typeof window?[2]:(E=0,[2,new Promise((function(r){N.timeInterval=window.setInterval((function(){N.running?(N.runOneStep(w,x,o),t&&m.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y,z:3===i?n.z:void 0})})),null==g||g({nodes:m,edges:v}),++E>=f&&(window.clearInterval(N.timeInterval),r({nodes:m,edges:v}))):r({nodes:m,edges:v})}),0),N.running=!0}))])):(y={nodes:[],edges:v},this.lastResult=y,[2,y]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=n(n({},this.options),t),r=e.clustering,o=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.dimensions,o=r.height,i=r.width,a=r.gravity,s=r.center,u=r.speed,d=r.clustering,h=r.nodeClusterBy,l=r.clusterGravity,c=o*i,f=Math.sqrt(c)/10,g=t.getAllNodes(),p=c/(g.length+1),y=Math.sqrt(p),m={};if(this.applyCalculate(t,m,y,p),d){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in g.forEach((function(t){var r=t.data,n=e[r[h]];v(r.x)&&(n.cx+=r.x),v(r.y)&&(n.cy+=r.y),n.count++})),e)e[w].cx/=e[w].count,e[w].cy/=e[w].count;var x=l||a;g.forEach((function(t,r){var n=t.id,o=t.data;if(v(o.x)&&v(o.y)){var i=e[o[h]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=y*x;m[n].x-=s*(o.x-i.cx)/a,m[n].y-=s*(o.y-i.cy)/a}}))}g.forEach((function(t,e){var r=t.id,o=t.data;if(v(o.x)&&v(o.y)){var i=.01*y*a;m[r].x-=i*(o.x-s[0]),m[r].y-=i*(o.y-s[1]),3===n&&(m[r].z-=i*(o.z-s[2]))}})),g.forEach((function(e,r){var o=e.id,i=e.data;if(v(i.fx)&&v(i.fy))return i.x=i.fx,i.y=i.fy,void(3===n&&(i.z=i.fz));if(v(i.x)&&v(i.y)){var a=Math.sqrt(m[o].x*m[o].x+m[o].y*m[o].y+(3===n?m[o].z*m[o].z:0));if(a>0){var s=Math.min(f*(u/800),a);t.mergeNodeData(o,{x:i.x+m[o].x/a*s,y:i.y+m[o].y/a*s,z:3===n?i.z+m[o].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=this,o=t.getAllNodes();o.forEach((function(t,i){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},o.forEach((function(t,o){var u=t.data,d=t.id;if(!(i<=o)&&v(a.x)&&v(u.x)&&v(a.y)&&v(u.y)){var h=a.x-u.x,l=a.y-u.y,c=3===n.options.dimensions?a.z-u.z:0,f=h*h+l*l+c*c;0===f&&(f=1,h=.01,l=.01,c=.01);var g=r/f,p=h*g,y=l*g,m=c*g;e[s].x+=p,e[s].y+=y,e[d].x-=p,e[d].y-=y,3===n.options.dimensions&&(e[s].z+=m,e[d].z-=m)}}))}))},t.prototype.calAttractive=function(t,e,r){var n=this;t.getAllEdges().forEach((function(o){var i=o.source,a=o.target;if(i&&a&&i!==a){var s=t.getNode(i).data,u=t.getNode(a).data;if(v(u.x)&&v(s.x)&&v(u.y)&&v(s.y)){var d=u.x-s.x,h=u.y-s.y,l=3===n.options.dimensions?u.z-s.z:0,c=Math.sqrt(d*d+h*h+l*l)/r,f=d*c,g=h*c,p=l*c;e[i].x+=f,e[i].y+=g,e[a].x-=f,e[a].y-=g,3===n.options.dimensions&&(e[i].z+=p,e[a].z-=p)}}}))},t}(),xn={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300},En=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},xn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,c,f,g,p,y,x,E,M,S,A,k,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U,H;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.begin,s=void 0===i?[0,0]:i,u=o.condense,d=o.preventOverlapPadding,h=o.preventOverlap,l=o.rows,c=o.cols,f=o.nodeSpacing,g=o.nodeSize,p=o.width,y=o.height,x=o.position,E=o.sortBy,M=e.getAllNodes(),S=e.getAllEdges(),!(A=null==M?void 0:M.length)||1===A)return[2,N(e,t,s)];if(k=M.map((function(t){return b(t)})),"id"===E||It(E)&&void 0!==k[0].data[E]||(E="degree"),"degree"===E?k.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===E?k.sort((function(t,e){return v(e.id)&&v(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):k.sort((function(t,e){return e.data[E]-t.data[E]})),z=p||"undefined"==typeof window?p:window.innerWidth,R=y||"undefined"==typeof window?y:window.innerHeight,I=A,D={rows:l,cols:c},null!=l&&null!=c?(D.rows=l,D.cols=c):null!=l&&null==c?(D.rows=l,D.cols=Math.ceil(I/D.rows)):null==l&&null!=c?(D.cols=c,D.rows=Math.ceil(I/D.cols)):(P=Math.sqrt(I*R/z),D.rows=Math.round(P),D.cols=Math.round(z/R*P)),D.rows=Math.max(D.rows,1),D.cols=Math.max(D.cols,1),D.cols*D.rows>I)O=bn(D),T=Nn(D),(O-1)*T>=I?bn(D,O-1):(T-1)*O>=I&&Nn(D,T-1);else for(;D.cols*D.rows<I;)O=bn(D),((T=Nn(D))+1)*O>=I?Nn(D,T+1):bn(D,O+1);for(C=u?0:z/D.cols,L=u?0:R/D.rows,(h||f)&&(q=m(10,f),j=w(30,g,!1),k.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=j(o)||30;_(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==q?q(t):d,s=r+a,u=n+a;C=Math.max(C,s),L=Math.max(L,u)}))),F={},V={row:0,col:0},B={},G=0;G<k.length;G++){if(W=k[G],$=void 0,x&&($=x(e.getNode(W.id))),$&&(void 0!==$.row||void 0!==$.col)){if(void 0===(U={row:$.row,col:$.col}).col)for(U.col=0;Mn(F,U);)U.col++;else if(void 0===U.row)for(U.row=0;Mn(F,U);)U.row++;B[W.id]=U,Sn(F,U)}kn(W,s,C,L,B,D,V,F)}return H={nodes:k,edges:S},t&&k.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,H]}))}))},t}(),bn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},Nn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},Mn=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},Sn=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},An=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},kn=function(t,e,r,n,o,i,a,s){var u,d,h=o[t.id];if(h)u=h.col*r+r/2+e[0],d=h.row*n+n/2+e[1];else{for(;Mn(s,a);)An(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],Sn(s,a),An(i,a)}t.data.x=u,t.data.y=d},_n={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},zn=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var d=a.x-e.x,h=a.y-e.y,l=Math.sqrt(d*d+h*h);if(0===l){l=1;var c=s>u?1:-1;d=.01*c,h=.01*c}if(l<i(t[s])/2+i(t[u])/2){var f=n*n/l;r[s].x+=d/l*f,r[s].y+=h/l*f}}}))}))},Rn=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,d=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/d);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var l=Math.cos(h)*d;e.x=s*l,e.y=u*l})),t.forEach((function(i,a){if(a!==o){var d=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(d>0&&a!==o){var h=Math.min(u*(r/800),d);if(i.x+=e[a].x/d*h,i.y+=e[a].y/d*h,n){var l=i.x-t[o].x,c=i.y-t[o].y,f=Math.sqrt(l*l+c*c);l=l/f*s[a],c=c/f*s[a],i.x=t[o].x+l,i.y=t[o].y+c}}}})),t},In={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Dn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},In),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,l,c,f,g,p,v,y,m,w,E,M,S,A,k,_,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U,H,Y,K,J,Q,Z,et,rt;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,d=o.height,h=o.center,l=o.focusNode,c=o.unitRadius,f=o.nodeSize,g=o.nodeSpacing,p=o.strictRadial,v=o.preventOverlap,y=o.maxPreventOverlapIteration,m=o.sortBy,w=o.linkDistance,E=void 0===w?50:w,M=o.sortStrength,S=void 0===M?10:M,A=o.maxIteration,k=void 0===A?1e3:A,_=e.getAllNodes(),I=e.getAllEdges(),D=i||"undefined"==typeof window?i:window.innerWidth,P=d||"undefined"==typeof window?d:window.innerHeight,O=h||[D/2,P/2],!(null==_?void 0:_.length)||1===_.length)return[2,N(e,t,O)];if(T=_[0],It(l)){for(C=0;C<_.length;C++)if(_[C].id===l){T=_[C];break}}else T=l||_[0];return L=Tn(_,T.id),q=R({nodes:_,edges:I},!1),j=z(q),F=Ln(j,L),Cn(j,L,F+1),V=j[L],B=D-O[0]>O[0]?O[0]:D-O[0],G=P-O[1]>O[1]?O[1]:P-O[1],0===B&&(B=D/2),0===G&&(G=P/2),W=Math.min(B,G),$=Math.max.apply(Math,u([],s(V))),U=[],H=c||W/$,V.forEach((function(t,e){U[e]=t*H})),Y=Pn(_,j,E,U,H,m,S),K=On(Y),J=function(t,e,r){try{var n=X.mul(X.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new tt(n),u=X.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return X.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var d=[],h=0;h<e.length;h++){var l=Math.random()*r,c=Math.random()*r;d.push([l,c])}return d}}(E,Y,E),Q=J.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-J[L][0],y:(isNaN(n)?Math.random()*E:n)-J[L][1]}})),this.run(k,Q,K,Y,U,L),v&&(Z=x(f,g),et={nodes:_,nodeSizeFunc:Z,positions:Q,radii:U,height:P,width:D,strictRadial:Boolean(p),focusIdx:L,iterations:y||200,k:Q.length/4.5},Q=function(t,e){for(var r=n(n({},_n),e),o=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,d=void 0===u?100:u,h=r.strictRadial,l=r.focusIdx,c=r.radii,f=void 0===c?[]:c,g=r.nodeSizeFunc,p=t.getAllNodes(),v=[],y=a/10,m=0;m<i;m++)o.forEach((function(t,e){v[e]={x:0,y:0}})),zn(p,o,v,s,f,g),Rn(o,v,d,h,l,y,a,f);return o}(e,et)),rt=[],Q.forEach((function(t,e){var r=b(_[e]);r.data.x=t.x+O[0],r.data.y=t.y+O[1],rt.push(r)})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:rt,edges:I}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var d=I(s,{x:0,y:0}),h=0===d?0:1/d;if(u!==i){var l=0,c=0,f=0;e.forEach((function(t,e){if(u!==e){var r=I(s,t),i=0===r?0:1/r,a=n[e][u];f+=o[u][e],l+=o[u][e]*(t.x+a*(s.x-t.x)*i),c+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];f*=a,f+=t*g*g,l*=a,l+=t*g*s.x*h,s.x=l/f,c*=a,c+=t*g*s.y*h,s.y=c/f}}))},t}(),Pn=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,d){var h=[];e.forEach((function(e,s){var l,c;if(d===s)h.push(0);else if(n[d]===n[s])if("data"===i)h.push(e*(Math.abs(d-s)*a)/(n[d]/o));else if(i){var f=void 0,g=void 0;if(u[t[d].id])f=u[t[d].id];else{var p=("id"===i?t[d].id:null===(l=t[d].data)||void 0===l?void 0:l[i])||0;f=It(p)?p.charCodeAt(0):p,u[t[d].id]=f}u[t[s].id]?g=u[t[s].id]:(p=("id"===i?t[s].id:null===(c=t[s].data)||void 0===c?void 0:c[i])||0,g=It(p)?p.charCodeAt(0):p,u[t[s].id]=g),h.push(e*(Math.abs(f-g)*a)/(n[d]/o))}else h.push(e*r/(n[d]/o));else{var v=(r+o)/2;h.push(e*v)}})),s.push(h)}))}return s},On=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},Tn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Cn=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},Ln=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},qn={center:[0,0],width:300,height:300},jn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},qn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,l,c,f;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=e.getAllNodes(),h=s||"undefined"==typeof window?s:window.innerWidth,l=u||"undefined"==typeof window?u:window.innerHeight,c=i||[h/2,l/2],f=[],d&&d.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+c[0],y:.9*(Math.random()-.5)*l+c[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}(),Fn={circular:S,concentric:Pt,mds:rt,random:jn,grid:En,radial:Dn,force:St,d3force:_e,fruchterman:wn,forceAtlas2:yn,dagre:dn,comboCombined:Ct};function Vn(){var t;(null===(t=pn)||void 0===t?void 0:t.stop)&&pn.stop()}function Bn(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,s,u,d,h,l;return a(this,(function(a){switch(a.label){case 0:if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,u=t.edges,d=new c({nodes:s,edges:u}),!(h=Fn[n]))throw new Error("Unknown layout id: "+n);return[4,(pn=new h(o)).execute(d)];case 1:return l=a.sent(),!!(f=pn).tick&&!!f.stop&&(pn.stop(),l=pn.tick(i)),[2,[l,e]]}var f}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,a=n.id,s=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,s)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:a,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:a,error:e})}))})),postMessage({type:"RPC",method:"ready"})})();
|
|
2
|
-
//# sourceMappingURL=
|
|
1
|
+
(()=>{"use strict";var t={d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Bn,stopLayout:()=>Vn});var r=function(t,e){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},r(t,e)},n=function(){return n=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},n.apply(this,arguments)};function o(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function i(t,e,r,n){return new(r||(r=Promise))((function(o,i){function a(t){try{u(n.next(t))}catch(t){i(t)}}function s(t){try{u(n.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(a,s)}u((n=n.apply(t,e||[])).next())}))}function a(t,e){var r,n,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&s[0]?n.return:s[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,s[1])).done)return o;switch(n=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,n=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],n=0}finally{r=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)a.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return a}function u(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}Object.create,Object.create;const d=function(){function t(){this._events={}}return t.prototype.on=function(t,e,r){return this._events[t]||(this._events[t]=[]),this._events[t].push({callback:e,once:!!r}),this},t.prototype.once=function(t,e){return this.on(t,e,!0)},t.prototype.emit=function(t){for(var e=this,r=[],n=1;n<arguments.length;n++)r[n-1]=arguments[n];var o=this._events[t]||[],i=this._events["*"]||[],a=function(n){for(var o=n.length,i=0;i<o;i++)if(n[i]){var a=n[i],s=a.callback;a.once&&(n.splice(i,1),0===n.length&&delete e._events[t],o--,i--),s.apply(e,r)}};a(o),a(i)},t.prototype.off=function(t,e){if(t)if(e){for(var r=this._events[t]||[],n=r.length,o=0;o<n;o++)r[o].callback===e&&(r.splice(o,1),n--,o--);0===r.length&&delete this._events[t]}else delete this._events[t];else this._events={};return this},t.prototype.getEvents=function(){return this._events},t}();function h(t,e,r,n){for(;t.length;){const o=t.shift();if(r(o))return!0;e.add(o.id),n(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}return!1}function c(t,e,r,n){if(r(t))return!0;e.add(t.id);for(const o of n(t.id))if(!e.has(o.id)&&c(o,e,r,n))return!0;return!1}class l extends d{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;bothEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){super(),t&&(t.nodes&&this.addNodes(t.nodes),t.edges&&this.addEdges(t.edges),t.tree&&this.addTree(t.tree),t.onChanged&&(this.onChanged=t.onChanged))}batch=t=>{this.batchCount+=1,t(),this.batchCount-=1,this.batchCount||this.commit()};commit(){const t=this.changes;this.changes=[];const e={graph:this,changes:t};this.emit("changed",e),this.onChanged(e)}reduceChanges(t){let e=[];return t.forEach((t=>{switch(t.type){case"NodeRemoved":{let r=!1;e=e.filter((e=>{if("NodeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"NodeDataUpdated"===e.type?e.id!==t.value.id:"TreeStructureChanged"!==e.type||e.nodeId!==t.value.id})),r||e.push(t);break}case"EdgeRemoved":{let r=!1;e=e.filter((e=>{if("EdgeAdded"===e.type){const n=e.value.id===t.value.id;return n&&(r=!0),!n}return"EdgeDataUpdated"!==e.type&&"EdgeUpdated"!==e.type||e.id!==t.value.id})),r||e.push(t);break}case"NodeDataUpdated":case"EdgeDataUpdated":case"EdgeUpdated":{const r=e.find((e=>e.type===t.type&&e.id===t.id&&e.propertyName===t.propertyName));r?r.newValue=t.newValue:e.push(t);break}case"TreeStructureDetached":e=e.filter((e=>"TreeStructureAttached"===e.type?e.treeKey!==t.treeKey:"TreeStructureChanged"!==e.type||e.treeKey!==t.treeKey)),e.push(t);break;case"TreeStructureChanged":{const r=e.find((e=>"TreeStructureChanged"===e.type&&e.treeKey===t.treeKey&&e.nodeId===t.nodeId));r?r.newParentId=t.newParentId:e.push(t);break}default:e.push(t)}})),e}checkNodeExistence(t){this.getNode(t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.getNeighbors(e).some((e=>e.id===t))}getNode(t){const e=this.nodeMap.get(t);if(!e)throw new Error("Node not found for id: "+t);return e}getRelatedEdges(t,e){if(this.checkNodeExistence(t),"in"===e){const e=this.inEdgesMap.get(t);return Array.from(e)}if("out"===e){const e=this.outEdgesMap.get(t);return Array.from(e)}{const e=this.bothEdgesMap.get(t);return Array.from(e)}}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>this.getNode(t.target)));return Array.from(new Set(e))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>this.getNode(t.source)));return Array.from(new Set(e))}getNeighbors(t){const e=this.getPredecessors(t),r=this.getSuccessors(t);return Array.from(new Set([...e,...r]))}doAddNode(t){if(this.hasNode(t.id))throw new Error("Node already exists: "+t.id);this.nodeMap.set(t.id,t),this.inEdgesMap.set(t.id,new Set),this.outEdgesMap.set(t.id,new Set),this.bothEdgesMap.set(t.id,new Set),this.treeIndices.forEach((e=>{e.childrenMap.set(t.id,new Set)})),this.changes.push({type:"NodeAdded",value:t})}addNodes(t){this.batch((()=>{for(const e of t)this.doAddNode(e)}))}addNode(t){this.addNodes([t])}doRemoveNode(t){const e=this.getNode(t),r=this.bothEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),this.nodeMap.delete(t),this.treeIndices.forEach((e=>{e.childrenMap.get(t)?.forEach((t=>{e.parentMap.delete(t.id)})),e.parentMap.delete(t),e.childrenMap.delete(t)})),this.changes.push({type:"NodeRemoved",value:e})}removeNodes(t){this.batch((()=>{t.forEach((t=>this.doRemoveNode(t)))}))}removeNode(t){this.removeNodes([t])}updateNodeDataProperty(t,e,r){const n=this.getNode(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeDataProperty(t,e,r)}))}))}updateNodeData(...t){const e=t[0],r=this.getNode(e);if("string"==typeof t[1])return void this.updateNodeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"NodeDataUpdated",id:e,oldValue:t,newValue:o})}))}checkEdgeExistence(t){if(!this.hasEdge(t))throw new Error("Edge not found for id: "+t)}hasEdge(t){return this.edgeMap.has(t)}getEdge(t){return this.checkEdgeExistence(t),this.edgeMap.get(t)}getEdgeDetail(t){const e=this.getEdge(t);return{edge:e,source:this.getNode(e.source),target:this.getNode(e.target)}}doAddEdge(t){if(this.hasEdge(t.id))throw new Error("Edge already exists: "+t.id);this.checkNodeExistence(t.source),this.checkNodeExistence(t.target),this.edgeMap.set(t.id,t);const e=this.inEdgesMap.get(t.target),r=this.outEdgesMap.get(t.source),n=this.bothEdgesMap.get(t.source),o=this.bothEdgesMap.get(t.target);e.add(t),r.add(t),n.add(t),o.add(t),this.changes.push({type:"EdgeAdded",value:t})}addEdges(t){this.batch((()=>{for(const e of t)this.doAddEdge(e)}))}addEdge(t){this.addEdges([t])}doRemoveEdge(t){const e=this.getEdge(t),r=this.outEdgesMap.get(e.source),n=this.inEdgesMap.get(e.target),o=this.bothEdgesMap.get(e.source),i=this.bothEdgesMap.get(e.target);r.delete(e),n.delete(e),o.delete(e),i.delete(e),this.edgeMap.delete(t),this.changes.push({type:"EdgeRemoved",value:e})}removeEdges(t){this.batch((()=>{t.forEach((t=>this.doRemoveEdge(t)))}))}removeEdge(t){this.removeEdges([t])}updateEdgeSource(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.source,o=e;this.outEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.outEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:n,newValue:o})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const n=r.target,o=e;this.inEdgesMap.get(n).delete(r),this.bothEdgesMap.get(n).delete(r),this.inEdgesMap.get(o).add(r),this.bothEdgesMap.get(o).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:n,newValue:o})}))}updateEdgeDataProperty(t,e,r){const n=this.getEdge(t);this.batch((()=>{const o=n.data[e],i=r;n.data[e]=i,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:o,newValue:i})}))}updateEdgeData(...t){const e=t[0],r=this.getEdge(e);if("string"==typeof t[1])return void this.updateEdgeDataProperty(e,t[1],t[2]);let n;if("function"==typeof t[1]){const e=t[1];n=e(r.data)}else"object"==typeof t[1]&&(n=t[1]);this.batch((()=>{const t=r.data,o=n;r.data=n,this.changes.push({type:"EdgeDataUpdated",id:e,oldValue:t,newValue:o})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeDataProperty(t,e,r)}))}))}checkTreeExistence(t){if(!this.hasTreeStructure(t))throw new Error("Tree structure not found for treeKey: "+t)}hasTreeStructure(t){return this.treeIndices.has(t)}attachTreeStructure(t){this.treeIndices.has(t)||(this.treeIndices.set(t,{parentMap:new Map,childrenMap:new Map}),this.batch((()=>{this.changes.push({type:"TreeStructureAttached",treeKey:t})})))}detachTreeStructure(t){this.checkTreeExistence(t),this.treeIndices.delete(t),this.batch((()=>{this.changes.push({type:"TreeStructureDetached",treeKey:t})}))}addTree(t,e){this.batch((()=>{this.attachTreeStructure(e);const r=[],n=Array.isArray(t)?t:[t];for(;n.length;){const t=n.shift();r.push(t),t.children&&n.push(...t.children)}this.addNodes(r),r.forEach((t=>{t.children?.forEach((r=>{this.setParent(r.id,t.id,e)}))}))}))}getRoots(t){return this.checkTreeExistence(t),this.getAllNodes().filter((e=>!this.getParent(e.id,t)))}getChildren(t,e){this.checkNodeExistence(t),this.checkTreeExistence(e);const r=this.treeIndices.get(e).childrenMap.get(t);return Array.from(r||[])}getParent(t,e){return this.checkNodeExistence(t),this.checkTreeExistence(e),this.treeIndices.get(e).parentMap.get(t)||null}getAncestors(t,e){const r=[];let n,o=this.getNode(t);for(;n=this.getParent(o.id,e);)r.push(n),o=n;return r}setParent(t,e,r){this.checkTreeExistence(r);const n=this.treeIndices.get(r),o=this.getNode(t),i=n.parentMap.get(t),a=this.getNode(e);n.parentMap.set(t,a),i&&n.childrenMap.get(i.id)?.delete(o);let s=n.childrenMap.get(a.id);s||(s=new Set,n.childrenMap.set(a.id,s)),s.add(o),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:i?.id,newParentId:a.id})}))}dfsTree(t,e,r){return c(this.getNode(t),new Set,e,(t=>this.getChildren(t,r)))}bfsTree(t,e,r){return h([this.getNode(t)],new Set,e,(t=>this.getChildren(t,r)))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}bfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return h([this.getNode(t)],new Set,e,n)}dfs(t,e,r="out"){const n={in:this.getPredecessors.bind(this),out:this.getSuccessors.bind(this),both:this.getNeighbors.bind(this)}[r];return c(this.getNode(t),new Set,e,n)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),r=new l({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},n)=>{const o=new Map;t.forEach(((t,e)=>{o.set(e,r.getNode(t.id))}));const i=new Map;e.forEach(((t,e)=>{i.set(e,new Set(Array.from(t).map((t=>r.getNode(t.id)))))})),r.treeIndices.set(n,{parentMap:o,childrenMap:i})})),r}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}const f=function(t){return"function"==typeof t};var g={}.toString;const p=function(t,e){return g.call(t)==="[object "+e+"]"},v=function(t){return p(t,"Number")},y=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function m(t,e){return f(e)?e:v(e)?function(){return e}:function(){return t}}function w(t,e,r){return void 0===r&&(r=!0),e||0===e?f(e)?e:v(e)?function(){return e}:Array.isArray(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e)));return isNaN(n)?t:n}return e}:y(e)?function(){if(r){var n=Math.max(e.width,e.height);return isNaN(n)?t:n}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?Array.isArray(r)?r[0]>r[1]?r[0]:r[1]:y(r)?r.width>r.height?r.width:r.height:r:t}}var x=function(t,e){var r;return r=v(e)?function(){return e}:f(e)?e:function(){return 0},t?Array.isArray(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:f(t)?t:function(e){return t+r(e)}:function(t){var e,n;if(null===(e=t.data)||void 0===e?void 0:e.bboxSize)return Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t);if(null===(n=t.data)||void 0===n?void 0:n.size){if(Array.isArray(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return y(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},E=function(t){if(null===t)return t;if(t instanceof Date)return new Date(t.getTime());if(t instanceof Array){var e=[];return t.forEach((function(t){e.push(t)})),e.map((function(t){return E(t)}))}if("object"==typeof t){var r={};return Object.keys(t).forEach((function(e){r[e]=E(t[e])})),r}return t},b=function(t,e){var r=E(t);return r.data=r.data||{},e&&(v(r.data.x)||(r.data.x=Math.random()*e[0]),v(r.data.y)||(r.data.y=Math.random()*e[1])),r},N=function(t,e,r){var o=t.getAllNodes(),i=t.getAllEdges();return(null==o?void 0:o.length)?1===o.length?(e&&t.mergeNodeData(o[0].id,{x:r[0],y:r[1]}),{nodes:[n(n({},o[0]),{data:n(n({},o[0].data),{x:r[0],y:r[1]})})],edges:i}):void 0:{nodes:[],edges:i}},M={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},S=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},M),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericCircularLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericCircularLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericCircularLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,u,d,h,c,l,f,g,p,v,y,x,E,M,S,_,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,u=o.height,d=o.center,h=o.divisions,c=o.startAngle,l=void 0===c?0:c,f=o.endAngle,g=void 0===f?2*Math.PI:f,p=o.angleRatio,v=o.ordering,y=o.clockwise,x=o.nodeSpacing,E=o.nodeSize,M=e.getAllNodes(),S=e.getAllEdges(),_=s(A(i,u,d),3),z=_[0],R=_[1],I=_[2],!(D=null==M?void 0:M.length)||1===D)return[2,N(e,t,I)];for(P=(g-l)/D,O=o.radius,T=o.startRadius,C=o.endRadius,x?(L=m(10,x),q=w(10,E),j=-1/0,M.forEach((function(t){var e=q(t);j<e&&(j=e)})),F=0,M.forEach((function(t,e){F+=0===e?j||10:(L(t)||0)+(j||10)})),O=F/(2*Math.PI)):O||T||C?!T&&C?T=C:T&&!C&&(C=T):O=Math.min(R,z)/2,V=P*p,B=[],B="topology"===v?k(e,M):"topology-directed"===v?k(e,M,!0):"degree"===v?function(t,e){var r=[];return e.forEach((function(t,e){r.push(b(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,M):M.map((function(t){return b(t)})),G=Math.ceil(D/h),W=0;W<D;++W)($=O)||null===T||null===C||($=T+W*(C-T)/(D-1)),$||($=10+100*W/(D-1)),U=l+W%G*V+2*Math.PI/h*Math.floor(W/G),y||(U=g-W%G*V-2*Math.PI/h*Math.floor(W/G)),B[W].data.x=I[0]+Math.cos(U)*$,B[W].data.y=I[1]+Math.sin(U)*$;return t&&B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:B,edges:S}]}))}))},t}(),k=function(t,e,r){void 0===r&&(r=!1);var n=[b(e[0])],o={},i=e.length;o[e[0].id]=!0;var a=0;return e.forEach((function(s,u){if(0!==u)if(u!==i-1&&t.getDegree(s.id,"both")===t.getDegree(e[u+1].id,"both")&&!t.areNeighbors(n[a].id,s.id)||o[s.id]){for(var d=r?t.getSuccessors(n[a].id):t.getNeighbors(n[a].id),h=!1,c=0;c<d.length;c++){var l=d[c];if(t.getDegree(l.id)===t.getDegree(s.id)&&!o[l.id]){n.push(b(l)),o[l.id]=!0,h=!0;break}}for(var f=0;!h&&(o[e[f].id]||(n.push(b(e[f])),o[e[f].id]=!0,h=!0),++f!==i););}else n.push(b(s)),o[s.id]=!0,a++})),n},A=function(t,e,r){var n=t,o=e,i=r;return n||"undefined"==typeof window||(n=window.innerWidth),o||"undefined"==typeof window||(o=window.innerHeight),i||(i=[n/2,o/2]),[n,o,i]},_=Array.isArray,z=function(t){for(var e=[],r=t.length,n=0;n<r;n+=1){e[n]=[];for(var o=0;o<r;o+=1)n===o?e[n][o]=0:0!==t[n][o]&&t[n][o]?e[n][o]=t[n][o]:e[n][o]=1/0}for(var i=0;i<r;i+=1)for(n=0;n<r;n+=1)for(o=0;o<r;o+=1)e[n][o]>e[n][i]+e[i][o]&&(e[n][o]=e[n][i]+e[i][o]);return e},R=function(t,e){var r=t.nodes,n=t.edges,o=[],i={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){i[t.id]=e,o.push([])})),null==n||n.forEach((function(t){var r=t.source,n=t.target,a=i[r],s=i[n];void 0!==a&&void 0!==s&&(o[a][s]=1,e||(o[s][a]=1))})),o},I=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},D=function(t,e,r,n,o,i){if(void 0===n&&(n="TB"),void 0===i&&(i={}),null==e?void 0:e.length)for(var a=i.stopBranchFn,s=i.stopAllFn,u=0;u<e.length;u++){var d=e[u];if(t.hasNode(d.id)&&!(null==a?void 0:a(d))){if(null==s?void 0:s(d))return;"TB"===n&&r(d),D(t,t.getChildren(d.id,o),r,n,o,i),"TB"!==n&&r(d)}}};const P=Object.prototype.toString;function O(t){const e=P.call(t);return e.endsWith("Array]")&&!e.includes("Big")}function T(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!O(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");if(void 0!==r.output){if(!O(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var n=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!O(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]<a&&(a=t[s]);return a}(t),o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!O(t))throw new TypeError("input must be an array");if(0===t.length)throw new TypeError("input must not be empty");var r=e.fromIndex,n=void 0===r?0:r,o=e.toIndex,i=void 0===o?t.length:o;if(n<0||n>=t.length||!Number.isInteger(n))throw new Error("fromIndex must be a positive integer smaller than length");if(i<=n||i>t.length||!Number.isInteger(i))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var a=t[n],s=n+1;s<i;s++)t[s]>a&&(a=t[s]);return a}(t);if(n===o)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var i=r.min,a=void 0===i?r.autoMinMax?n:0:i,s=r.max,u=void 0===s?r.autoMinMax?o:1:s;if(a>=u)throw new RangeError("min option must be smaller than max option");for(var d=(u-a)/(o-n),h=0;h<t.length;h++)e[h]=(t[h]-n)*d+a;return e}const C=" ".repeat(2),L=" ".repeat(4);function q(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${C}[\n${L}${function(t,e,r,n,o){const{rows:i,columns:a}=t,s=Math.min(i,e),u=Math.min(a,r),d=[];if("auto"===o){o=!1;t:for(let e=0;e<s;e++)for(let r=0;r<u;r++)if(t.get(e,r)<0){o=!0;break t}}for(let e=0;e<s;e++){let r=[];for(let i=0;i<u;i++)r.push(j(t.get(e,i),n,o));d.push(`${r.join(" ")}`)}return u!==a&&(d[d.length-1]+=` ... ${a-r} more columns`),s!==i&&d.push(`... ${i-e} more rows`),d.join(`\n${L}`)}(t,r,n,o,i)}\n${C}]\n${C}rows: ${t.rows}\n${C}columns: ${t.columns}\n}`}function j(t,e,r){return(t>=0&&r?` ${F(t,e-1)}`:F(t,e)).padEnd(e)}function F(t,e){let r=t.toString();if(r.length<=e)return r;let n=t.toFixed(e);if(n.length>e&&(n=t.toFixed(Math.max(0,e-(n.length-e)))),n.length<=e&&!n.startsWith("0.000")&&!n.startsWith("-0.000"))return n;let o=t.toExponential(e);return o.length>e&&(o=t.toExponential(Math.max(0,e-(o.length-e)))),o.slice(0)}function V(t,e,r){let n=r?t.rows:t.rows-1;if(e<0||e>n)throw new RangeError("Row index out of range")}function B(t,e,r){let n=r?t.columns:t.columns-1;if(e<0||e>n)throw new RangeError("Column index out of range")}function G(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function W(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function $(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(H("startRow",e),H("endRow",r),H("startColumn",n),H("endColumn",o),e>r||n>o||e<0||e>=t.rows||r<0||r>=t.rows||n<0||n>=t.columns||o<0||o>=t.columns)throw new RangeError("Submatrix indices are out of range")}function U(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function H(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function Y(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class K{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new X(t,e);for(let o=0;o<t;o++)for(let t=0;t<e;t++)n.set(o,t,r[o*e+t]);return n}static rowVector(t){let e=new X(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new X(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new X(t,e)}static ones(t,e){return new X(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:n=Math.random}=r;let o=new X(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)o.set(r,t,n());return o}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:n=0,max:o=1e3,random:i=Math.random}=r;if(!Number.isInteger(n))throw new TypeError("min must be an integer");if(!Number.isInteger(o))throw new TypeError("max must be an integer");if(n>=o)throw new RangeError("min must be smaller than max");let a=o-n,s=new X(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=n+Math.round(i()*a);s.set(r,t,e)}return s}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let n=Math.min(t,e),o=this.zeros(t,e);for(let t=0;t<n;t++)o.set(t,t,r);return o}static diag(t,e,r){let n=t.length;void 0===e&&(e=n),void 0===r&&(r=e);let o=Math.min(n,e,r),i=this.zeros(e,r);for(let e=0;e<o;e++)i.set(e,e,t[e]);return i}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new X(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.min(t.get(i,r),e.get(i,r)));return o}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,n=t.columns,o=new this(r,n);for(let i=0;i<r;i++)for(let r=0;r<n;r++)o.set(i,r,Math.max(t.get(i,r),e.get(i,r)));return o}static checkMatrix(t){return K.isMatrix(t)?t:new X(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);t++}return n}isReducedEchelonForm(){let t=0,e=0,r=-1,n=!0,o=!1;for(;t<this.rows&&n;){for(e=0,o=!1;e<this.columns&&!1===o;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(o=!0,r=e):(n=!1,o=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(n=!1);t++}return n}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let n=e;for(let o=e;o<t.rows;o++)t.get(o,r)>t.get(n,r)&&(n=o);if(0===t.get(n,r))r++;else{t.swapRows(e,n);let o=t.get(e,r);for(let n=r;n<t.columns;n++)t.set(e,n,t.get(e,n)/o);for(let n=e+1;n<t.rows;n++){let o=t.get(n,r)/t.get(e,r);t.set(n,r,0);for(let i=r+1;i<t.columns;i++)t.set(n,i,t.get(n,i)-t.get(e,i)*o)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,n=r-1;for(;n>=0;)if(0===t.maxRow(n))n--;else{let o=0,i=!1;for(;o<r&&!1===i;)1===t.get(n,o)?i=!0:o++;for(let r=0;r<n;r++){let i=t.get(r,o);for(let a=o;a<e;a++){let e=t.get(r,a)-i*t.get(n,a);t.set(r,a,e)}}n--}return t}set(){throw new Error("set method is unimplemented")}get(){throw new Error("get method is unimplemented")}repeat(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{rows:e=1,columns:r=1}=t;if(!Number.isInteger(e)||e<=0)throw new TypeError("rows must be a positive integer");if(!Number.isInteger(r)||r<=0)throw new TypeError("columns must be a positive integer");let n=new X(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)n.setSubMatrix(this,this.rows*t,this.columns*e);return n}fill(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,t);return this}neg(){return this.mulS(-1)}getRow(t){V(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return X.rowVector(this.getRow(t))}setRow(t,e){V(this,t),e=G(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){V(this,t),V(this,e);for(let r=0;r<this.columns;r++){let n=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,n)}return this}getColumn(t){B(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return X.columnVector(this.getColumn(t))}setColumn(t,e){B(this,t),e=W(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){B(this,t),B(this,e);for(let r=0;r<this.rows;r++){let n=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,n)}return this}addRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[r]);return this}subRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[r]);return this}mulRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[r]);return this}divRowVector(t){t=G(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){V(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){B(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){Y(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)>t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}min(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.POSITIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)<t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}minIndex(){Y(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let n=0;n<this.columns;n++)this.get(r,n)<t&&(t=this.get(r,n),e[0]=r,e[1]=n);return e}maxRow(t){if(V(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)>e&&(e=this.get(t,r));return e}maxRowIndex(t){V(this,t),Y(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)>e&&(e=this.get(t,n),r[1]=n);return r}minRow(t){if(V(this,t),this.isEmpty())return NaN;let e=this.get(t,0);for(let r=1;r<this.columns;r++)this.get(t,r)<e&&(e=this.get(t,r));return e}minRowIndex(t){V(this,t),Y(this);let e=this.get(t,0),r=[t,0];for(let n=1;n<this.columns;n++)this.get(t,n)<e&&(e=this.get(t,n),r[1]=n);return r}maxColumn(t){if(B(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){B(this,t),Y(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)>e&&(e=this.get(n,t),r[0]=n);return r}minColumn(t){if(B(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){B(this,t),Y(this);let e=this.get(0,t),r=[0,t];for(let n=1;n<this.rows;n++)this.get(n,t)<e&&(e=this.get(n,t),r[0]=n);return r}diag(){let t=Math.min(this.rows,this.columns),e=[];for(let r=0;r<t;r++)e.push(this.get(r,r));return e}norm(t="frobenius"){let e=0;if("max"===t)return this.max();if("frobenius"===t){for(let t=0;t<this.rows;t++)for(let r=0;r<this.columns;r++)e+=this.get(t,r)*this.get(t,r);return Math.sqrt(e)}throw new RangeError(`unknown norm type: ${t}`)}cumulativeSum(){let t=0;for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t+=this.get(e,r),this.set(e,r,t);return this}dot(t){K.isMatrix(t)&&(t=t.to1DArray());let e=this.to1DArray();if(e.length!==t.length)throw new RangeError("vectors do not have the same size");let r=0;for(let n=0;n<e.length;n++)r+=e[n]*t[n];return r}mmul(t){t=X.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new X(e,n),i=new Float64Array(r);for(let a=0;a<n;a++){for(let e=0;e<r;e++)i[e]=t.get(e,a);for(let t=0;t<e;t++){let e=0;for(let n=0;n<r;n++)e+=this.get(t,n)*i[n];o.set(t,a,e)}}return o}strassen2x2(t){t=X.checkMatrix(t);let e=new X(2,2);const r=this.get(0,0),n=t.get(0,0),o=this.get(0,1),i=t.get(0,1),a=this.get(1,0),s=t.get(1,0),u=this.get(1,1),d=t.get(1,1),h=(r+u)*(n+d),c=(a+u)*n,l=r*(i-d),f=u*(s-n),g=(r+o)*d,p=h+f-g+(o-u)*(s+d),v=l+g,y=c+f,m=h-c+l+(a-r)*(n+i);return e.set(0,0,p),e.set(0,1,v),e.set(1,0,y),e.set(1,1,m),e}strassen3x3(t){t=X.checkMatrix(t);let e=new X(3,3);const r=this.get(0,0),n=this.get(0,1),o=this.get(0,2),i=this.get(1,0),a=this.get(1,1),s=this.get(1,2),u=this.get(2,0),d=this.get(2,1),h=this.get(2,2),c=t.get(0,0),l=t.get(0,1),f=t.get(0,2),g=t.get(1,0),p=t.get(1,1),v=t.get(1,2),y=t.get(2,0),m=t.get(2,1),w=t.get(2,2),x=(r-i)*(-l+p),E=(-r+i+a)*(c-l+p),b=(i+a)*(-c+l),N=r*c,M=(-r+u+d)*(c-f+v),S=(-r+u)*(f-v),k=(u+d)*(-c+f),A=(-o+d+h)*(p+y-m),_=(o-h)*(p-m),z=o*y,R=(d+h)*(-y+m),I=(-o+a+s)*(v+y-w),D=(o-s)*(v-w),P=(a+s)*(-y+w),O=N+z+n*g,T=(r+n+o-i-a-d-h)*p+E+b+N+A+z+R,C=N+M+k+(r+n+o-a-s-u-d)*v+z+I+P,L=x+a*(-c+l+g-p-v-y+w)+E+N+z+I+D,q=x+E+b+N+s*m,j=z+I+D+P+i*f,F=N+M+S+d*(-c+f+g-p-v-y+m)+A+_+z,V=A+_+z+R+u*l,B=N+M+S+k+h*w;return e.set(0,0,O),e.set(0,1,T),e.set(0,2,C),e.set(1,0,L),e.set(1,1,q),e.set(1,2,j),e.set(2,0,F),e.set(2,1,V),e.set(2,2,B),e}mmulStrassen(t){t=X.checkMatrix(t);let e=this.clone(),r=e.rows,n=e.columns,o=t.rows,i=t.columns;function a(t,e,r){let n=t.rows,o=t.columns;if(n===e&&o===r)return t;{let n=K.zeros(e,r);return n=n.setSubMatrix(t,0,0),n}}n!==o&&console.warn(`Multiplying ${r} x ${n} and ${o} x ${i} matrix: dimensions do not match.`);let s=Math.max(r,o),u=Math.max(n,i);return e=a(e,s,u),function t(e,r,n,o){if(n<=512||o<=512)return e.mmul(r);n%2==1&&o%2==1?(e=a(e,n+1,o+1),r=a(r,n+1,o+1)):n%2==1?(e=a(e,n+1,o),r=a(r,n+1,o)):o%2==1&&(e=a(e,n,o+1),r=a(r,n,o+1));let i=parseInt(e.rows/2,10),s=parseInt(e.columns/2,10),u=e.subMatrix(0,i-1,0,s-1),d=r.subMatrix(0,i-1,0,s-1),h=e.subMatrix(0,i-1,s,e.columns-1),c=r.subMatrix(0,i-1,s,r.columns-1),l=e.subMatrix(i,e.rows-1,0,s-1),f=r.subMatrix(i,r.rows-1,0,s-1),g=e.subMatrix(i,e.rows-1,s,e.columns-1),p=r.subMatrix(i,r.rows-1,s,r.columns-1),v=t(K.add(u,g),K.add(d,p),i,s),y=t(K.add(l,g),d,i,s),m=t(u,K.sub(c,p),i,s),w=t(g,K.sub(f,d),i,s),x=t(K.add(u,h),p,i,s),E=t(K.sub(l,u),K.add(d,c),i,s),b=t(K.sub(h,g),K.add(f,p),i,s),N=K.add(v,w);N.sub(x),N.add(b);let M=K.add(m,x),S=K.add(y,w),k=K.sub(v,y);k.add(m),k.add(E);let A=K.zeros(2*N.rows,2*N.columns);return A=A.setSubMatrix(N,0,0),A=A.setSubMatrix(M,N.rows,0),A=A.setSubMatrix(S,0,N.columns),A=A.setSubMatrix(k,N.rows,N.columns),A.subMatrix(0,n-1,0,o-1)}(e,t=a(t,s,u),s,u)}scaleRows(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new X(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&T(o,{min:e,max:r,output:o}),n.setRow(t,o)}return n}scaleColumns(t={}){if("object"!=typeof t)throw new TypeError("options must be an object");const{min:e=0,max:r=1}=t;if(!Number.isFinite(e))throw new TypeError("min must be a number");if(!Number.isFinite(r))throw new TypeError("max must be a number");if(e>=r)throw new RangeError("min must be smaller than max");let n=new X(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&T(o,{min:e,max:r,output:o}),n.setColumn(t,o)}return n}flipRows(){const t=Math.ceil(this.columns/2);for(let e=0;e<this.rows;e++)for(let r=0;r<t;r++){let t=this.get(e,r),n=this.get(e,this.columns-1-r);this.set(e,r,n),this.set(e,this.columns-1-r,t)}return this}flipColumns(){const t=Math.ceil(this.rows/2);for(let e=0;e<this.columns;e++)for(let r=0;r<t;r++){let t=this.get(r,e),n=this.get(this.rows-1-r,e);this.set(r,e,n),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=X.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new X(e*n,r*o);for(let a=0;a<e;a++)for(let e=0;e<r;e++)for(let r=0;r<n;r++)for(let s=0;s<o;s++)i.set(n*a+r,o*e+s,this.get(a,e)*t.get(r,s));return i}kroneckerSum(t){if(t=X.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,n=this.kroneckerProduct(X.eye(r,r)),o=X.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new X(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=J){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=J){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){$(this,t,e,r,n);let o=new X(e-t+1,n-r+1);for(let i=t;i<=e;i++)for(let e=r;e<=n;e++)o.set(i-t,e-r,this.get(i,e));return o}subMatrixRow(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.columns-1),e>r||e<0||e>=this.columns||r<0||r>=this.columns)throw new RangeError("Argument out of range");let n=new X(t.length,r-e+1);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.rows)throw new RangeError(`Row index out of range: ${t[o]}`);n.set(o,i-e,this.get(t[o],i))}return n}subMatrixColumn(t,e,r){if(void 0===e&&(e=0),void 0===r&&(r=this.rows-1),e>r||e<0||e>=this.rows||r<0||r>=this.rows)throw new RangeError("Argument out of range");let n=new X(r-e+1,t.length);for(let o=0;o<t.length;o++)for(let i=e;i<=r;i++){if(t[o]<0||t[o]>=this.columns)throw new RangeError(`Column index out of range: ${t[o]}`);n.set(i-e,o,this.get(i,t[o]))}return n}setSubMatrix(t,e,r){if((t=X.checkMatrix(t)).isEmpty())return this;$(this,e,e+t.rows-1,r,r+t.columns-1);for(let n=0;n<t.rows;n++)for(let o=0;o<t.columns;o++)this.set(e+n,r+o,t.get(n,o));return this}selection(t,e){!function(t,e){if(!O(e))throw new TypeError("row indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.rows)throw new RangeError("row indices are out of range")}(this,t),function(t,e){if(!O(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new X(t.length,e.length);for(let n=0;n<t.length;n++){let o=t[n];for(let t=0;t<e.length;t++){let i=e[t];r.set(n,t,this.get(o,i))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new X(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=U(t.rows);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]+=t.get(r,n);return e}(this);case"column":return function(t){let e=U(t.columns);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]+=t.get(r,n);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e+=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=U(t.rows,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[r]*=t.get(r,n);return e}(this);case"column":return function(t){let e=U(t.columns,1);for(let r=0;r<t.rows;++r)for(let n=0;n<t.columns;++n)e[n]*=t.get(r,n);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)e*=t.get(r,n);return e}(this);default:throw new Error(`invalid option: ${t}`)}}mean(t){const e=this.sum(t);switch(t){case"row":for(let t=0;t<this.rows;t++)e[t]/=this.columns;return e;case"column":for(let t=0;t<this.columns;t++)e[t]/=this.rows;return e;case void 0:return e/this.size;default:throw new Error(`invalid option: ${t}`)}}variance(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{unbiased:r=!0,mean:n=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!O(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<n;a++){let n=0,s=0,u=0;for(let e=0;e<o;e++)u=t.get(a,e)-r[a],n+=u,s+=u*u;e?i.push((s-n*n/o)/(o-1)):i.push((s-n*n/o)/o)}return i}(this,r,n);case"column":if(!O(n))throw new TypeError("mean must be an array");return function(t,e,r){const n=t.rows,o=t.columns,i=[];for(let a=0;a<o;a++){let o=0,s=0,u=0;for(let e=0;e<n;e++)u=t.get(e,a)-r[a],o+=u,s+=u*u;e?i.push((s-o*o/n)/(n-1)):i.push((s-o*o/n)/n)}return i}(this,r,n);case void 0:if("number"!=typeof n)throw new TypeError("mean must be a number");return function(t,e,r){const n=t.rows,o=t.columns,i=n*o;let a=0,s=0,u=0;for(let e=0;e<n;e++)for(let n=0;n<o;n++)u=t.get(e,n)-r,a+=u,s+=u*u;return e?(s-a*a/i)/(i-1):(s-a*a/i)/i}(this,r,n);default:throw new Error(`invalid option: ${t}`)}}standardDeviation(t,e){"object"==typeof t&&(e=t,t=void 0);const r=this.variance(t,e);if(void 0===t)return Math.sqrt(r);for(let t=0;t<r.length;t++)r[t]=Math.sqrt(r[t]);return r}center(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");const{center:r=this.mean(t)}=e;switch(t){case"row":if(!O(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[r])}(this,r),this;case"column":if(!O(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e[n])}(this,r),this;case void 0:if("number"!=typeof r)throw new TypeError("center must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)-e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}scale(t,e={}){if("object"==typeof t&&(e=t,t=void 0),"object"!=typeof e)throw new TypeError("options must be an object");let r=e.scale;switch(t){case"row":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.rows;r++){let n=0;for(let e=0;e<t.columns;e++)n+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(n))}return e}(this);else if(!O(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[r])}(this,r),this;case"column":if(void 0===r)r=function(t){const e=[];for(let r=0;r<t.columns;r++){let n=0;for(let e=0;e<t.rows;e++)n+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(n))}return e}(this);else if(!O(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e[n])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let n=0;n<t.columns;n++)for(let o=0;o<t.rows;o++)r+=Math.pow(t.get(o,n),2)/e;return Math.sqrt(r)}(this);else if("number"!=typeof r)throw new TypeError("scale must be a number");return function(t,e){for(let r=0;r<t.rows;r++)for(let n=0;n<t.columns;n++)t.set(r,n,t.get(r,n)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return q(this,t)}}function J(t,e){return t-e}K.prototype.klass="Matrix","undefined"!=typeof Symbol&&(K.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return q(this)}),K.random=K.rand,K.randomInt=K.randInt,K.diagonal=K.diag,K.prototype.diagonal=K.prototype.diag,K.identity=K.eye,K.prototype.negate=K.prototype.neg,K.prototype.tensorProduct=K.prototype.kroneckerProduct;class X extends K{constructor(t,e){if(super(),X.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!O(t))throw new TypeError("First argument must be a positive number or an array");{const r=t;if("number"!=typeof(e=(t=r.length)?r[0].length:0))throw new TypeError("Data must be a 2D array with at least one element");this.data=[];for(let n=0;n<t;n++){if(r[n].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[n].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[n]))}}}this.rows=t,this.columns=e}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}removeRow(t){return V(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),V(this,t,!0),e=Float64Array.from(G(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){B(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let n=0;n<t;n++)r[n]=this.data[e][n];for(let n=t+1;n<this.columns;n++)r[n-1]=this.data[e][n];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),B(this,t,!0),e=W(this,e);for(let r=0;r<this.rows;r++){const n=new Float64Array(this.columns+1);let o=0;for(;o<t;o++)n[o]=this.data[r][o];for(n[o++]=e[r];o<this.columns+1;o++)n[o]=this.data[r][o-1];this.data[r]=n}return this.columns+=1,this}}!function(t,e){t.prototype.add=function(t){return"number"==typeof t?this.addS(t):this.addM(t)},t.prototype.addS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t);return this},t.prototype.addM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t.get(e,r));return this},t.add=function(t,r){return new e(t).add(r)},t.prototype.sub=function(t){return"number"==typeof t?this.subS(t):this.subM(t)},t.prototype.subS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t);return this},t.prototype.subM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t.get(e,r));return this},t.sub=function(t,r){return new e(t).sub(r)},t.prototype.subtract=t.prototype.sub,t.prototype.subtractS=t.prototype.subS,t.prototype.subtractM=t.prototype.subM,t.subtract=t.sub,t.prototype.mul=function(t){return"number"==typeof t?this.mulS(t):this.mulM(t)},t.prototype.mulS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t);return this},t.prototype.mulM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t.get(e,r));return this},t.mul=function(t,r){return new e(t).mul(r)},t.prototype.multiply=t.prototype.mul,t.prototype.multiplyS=t.prototype.mulS,t.prototype.multiplyM=t.prototype.mulM,t.multiply=t.mul,t.prototype.div=function(t){return"number"==typeof t?this.divS(t):this.divM(t)},t.prototype.divS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t);return this},t.prototype.divM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t.get(e,r));return this},t.div=function(t,r){return new e(t).div(r)},t.prototype.divide=t.prototype.div,t.prototype.divideS=t.prototype.divS,t.prototype.divideM=t.prototype.divM,t.divide=t.div,t.prototype.mod=function(t){return"number"==typeof t?this.modS(t):this.modM(t)},t.prototype.modS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t);return this},t.prototype.modM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)%t.get(e,r));return this},t.mod=function(t,r){return new e(t).mod(r)},t.prototype.modulus=t.prototype.mod,t.prototype.modulusS=t.prototype.modS,t.prototype.modulusM=t.prototype.modM,t.modulus=t.mod,t.prototype.and=function(t){return"number"==typeof t?this.andS(t):this.andM(t)},t.prototype.andS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t);return this},t.prototype.andM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)&t.get(e,r));return this},t.and=function(t,r){return new e(t).and(r)},t.prototype.or=function(t){return"number"==typeof t?this.orS(t):this.orM(t)},t.prototype.orS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t);return this},t.prototype.orM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)|t.get(e,r));return this},t.or=function(t,r){return new e(t).or(r)},t.prototype.xor=function(t){return"number"==typeof t?this.xorS(t):this.xorM(t)},t.prototype.xorS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t);return this},t.prototype.xorM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)^t.get(e,r));return this},t.xor=function(t,r){return new e(t).xor(r)},t.prototype.leftShift=function(t){return"number"==typeof t?this.leftShiftS(t):this.leftShiftM(t)},t.prototype.leftShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t);return this},t.prototype.leftShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)<<t.get(e,r));return this},t.leftShift=function(t,r){return new e(t).leftShift(r)},t.prototype.signPropagatingRightShift=function(t){return"number"==typeof t?this.signPropagatingRightShiftS(t):this.signPropagatingRightShiftM(t)},t.prototype.signPropagatingRightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t);return this},t.prototype.signPropagatingRightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>t.get(e,r));return this},t.signPropagatingRightShift=function(t,r){return new e(t).signPropagatingRightShift(r)},t.prototype.rightShift=function(t){return"number"==typeof t?this.rightShiftS(t):this.rightShiftM(t)},t.prototype.rightShiftS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t);return this},t.prototype.rightShiftM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)>>>t.get(e,r));return this},t.rightShift=function(t,r){return new e(t).rightShift(r)},t.prototype.zeroFillRightShift=t.prototype.rightShift,t.prototype.zeroFillRightShiftS=t.prototype.rightShiftS,t.prototype.zeroFillRightShiftM=t.prototype.rightShiftM,t.zeroFillRightShift=t.rightShift,t.prototype.not=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,~this.get(t,e));return this},t.not=function(t){return new e(t).not()},t.prototype.abs=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.abs(this.get(t,e)));return this},t.abs=function(t){return new e(t).abs()},t.prototype.acos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acos(this.get(t,e)));return this},t.acos=function(t){return new e(t).acos()},t.prototype.acosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.acosh(this.get(t,e)));return this},t.acosh=function(t){return new e(t).acosh()},t.prototype.asin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asin(this.get(t,e)));return this},t.asin=function(t){return new e(t).asin()},t.prototype.asinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.asinh(this.get(t,e)));return this},t.asinh=function(t){return new e(t).asinh()},t.prototype.atan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atan(this.get(t,e)));return this},t.atan=function(t){return new e(t).atan()},t.prototype.atanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.atanh(this.get(t,e)));return this},t.atanh=function(t){return new e(t).atanh()},t.prototype.cbrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cbrt(this.get(t,e)));return this},t.cbrt=function(t){return new e(t).cbrt()},t.prototype.ceil=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.ceil(this.get(t,e)));return this},t.ceil=function(t){return new e(t).ceil()},t.prototype.clz32=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.clz32(this.get(t,e)));return this},t.clz32=function(t){return new e(t).clz32()},t.prototype.cos=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cos(this.get(t,e)));return this},t.cos=function(t){return new e(t).cos()},t.prototype.cosh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.cosh(this.get(t,e)));return this},t.cosh=function(t){return new e(t).cosh()},t.prototype.exp=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.exp(this.get(t,e)));return this},t.exp=function(t){return new e(t).exp()},t.prototype.expm1=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.expm1(this.get(t,e)));return this},t.expm1=function(t){return new e(t).expm1()},t.prototype.floor=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.floor(this.get(t,e)));return this},t.floor=function(t){return new e(t).floor()},t.prototype.fround=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.fround(this.get(t,e)));return this},t.fround=function(t){return new e(t).fround()},t.prototype.log=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log(this.get(t,e)));return this},t.log=function(t){return new e(t).log()},t.prototype.log1p=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log1p(this.get(t,e)));return this},t.log1p=function(t){return new e(t).log1p()},t.prototype.log10=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log10(this.get(t,e)));return this},t.log10=function(t){return new e(t).log10()},t.prototype.log2=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.log2(this.get(t,e)));return this},t.log2=function(t){return new e(t).log2()},t.prototype.round=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.round(this.get(t,e)));return this},t.round=function(t){return new e(t).round()},t.prototype.sign=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sign(this.get(t,e)));return this},t.sign=function(t){return new e(t).sign()},t.prototype.sin=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sin(this.get(t,e)));return this},t.sin=function(t){return new e(t).sin()},t.prototype.sinh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sinh(this.get(t,e)));return this},t.sinh=function(t){return new e(t).sinh()},t.prototype.sqrt=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.sqrt(this.get(t,e)));return this},t.sqrt=function(t){return new e(t).sqrt()},t.prototype.tan=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tan(this.get(t,e)));return this},t.tan=function(t){return new e(t).tan()},t.prototype.tanh=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.tanh(this.get(t,e)));return this},t.tanh=function(t){return new e(t).tanh()},t.prototype.trunc=function(){for(let t=0;t<this.rows;t++)for(let e=0;e<this.columns;e++)this.set(t,e,Math.trunc(this.get(t,e)));return this},t.trunc=function(t){return new e(t).trunc()},t.pow=function(t,r){return new e(t).pow(r)},t.prototype.pow=function(t){return"number"==typeof t?this.powS(t):this.powM(t)},t.prototype.powS=function(t){for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t));return this},t.prototype.powM=function(t){if(t=e.checkMatrix(t),this.rows!==t.rows||this.columns!==t.columns)throw new RangeError("Matrices dimensions must be equal");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,Math.pow(this.get(e,r),t.get(e,r)));return this}}(K,X);class Q extends K{constructor(t){super(),this.data=t,this.rows=t.length,this.columns=t[0].length}set(t,e,r){return this.data[t][e]=r,this}get(t,e){return this.data[t][e]}}function Z(t,e){let r=0;return Math.abs(t)>Math.abs(e)?(r=e/t,Math.abs(t)*Math.sqrt(1+r*r)):0!==e?(r=t/e,Math.abs(e)*Math.sqrt(1+r*r)):0}class tt{constructor(t,e={}){if((t=Q.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,n=t.columns;const{computeLeftSingularVectors:o=!0,computeRightSingularVectors:i=!0,autoTranspose:a=!1}=e;let s,u=Boolean(o),d=Boolean(i),h=!1;if(r<n)if(a){s=t.transpose(),r=s.rows,n=s.columns,h=!0;let e=u;u=d,d=e}else s=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else s=t.clone();let c=Math.min(r,n),l=Math.min(r+1,n),f=new Float64Array(l),g=new X(r,c),p=new X(n,n),v=new Float64Array(n),y=new Float64Array(r),m=new Float64Array(l);for(let t=0;t<l;t++)m[t]=t;let w=Math.min(r-1,n),x=Math.max(0,Math.min(n-2,r)),E=Math.max(w,x);for(let t=0;t<E;t++){if(t<w){f[t]=0;for(let e=t;e<r;e++)f[t]=Z(f[t],s.get(e,t));if(0!==f[t]){s.get(t,t)<0&&(f[t]=-f[t]);for(let e=t;e<r;e++)s.set(e,t,s.get(e,t)/f[t]);s.set(t,t,s.get(t,t)+1)}f[t]=-f[t]}for(let e=t+1;e<n;e++){if(t<w&&0!==f[t]){let n=0;for(let o=t;o<r;o++)n+=s.get(o,t)*s.get(o,e);n=-n/s.get(t,t);for(let o=t;o<r;o++)s.set(o,e,s.get(o,e)+n*s.get(o,t))}v[e]=s.get(t,e)}if(u&&t<w)for(let e=t;e<r;e++)g.set(e,t,s.get(e,t));if(t<x){v[t]=0;for(let e=t+1;e<n;e++)v[t]=Z(v[t],v[e]);if(0!==v[t]){v[t+1]<0&&(v[t]=0-v[t]);for(let e=t+1;e<n;e++)v[e]/=v[t];v[t+1]+=1}if(v[t]=-v[t],t+1<r&&0!==v[t]){for(let e=t+1;e<r;e++)y[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<n;r++)y[e]+=v[r]*s.get(e,r);for(let e=t+1;e<n;e++){let n=-v[e]/v[t+1];for(let o=t+1;o<r;o++)s.set(o,e,s.get(o,e)+n*y[o])}}if(d)for(let e=t+1;e<n;e++)p.set(e,t,v[e])}}let b=Math.min(n,r+1);if(w<n&&(f[w]=s.get(w,w)),r<b&&(f[b-1]=0),x+1<b&&(v[x]=s.get(x,b-1)),v[b-1]=0,u){for(let t=w;t<c;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=w-1;t>=0;t--)if(0!==f[t]){for(let e=t+1;e<c;e++){let n=0;for(let o=t;o<r;o++)n+=g.get(o,t)*g.get(o,e);n=-n/g.get(t,t);for(let o=t;o<r;o++)g.set(o,e,g.get(o,e)+n*g.get(o,t))}for(let e=t;e<r;e++)g.set(e,t,-g.get(e,t));g.set(t,t,1+g.get(t,t));for(let e=0;e<t-1;e++)g.set(e,t,0)}else{for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}}if(d)for(let t=n-1;t>=0;t--){if(t<x&&0!==v[t])for(let e=t+1;e<n;e++){let r=0;for(let o=t+1;o<n;o++)r+=p.get(o,t)*p.get(o,e);r=-r/p.get(t+1,t);for(let o=t+1;o<n;o++)p.set(o,e,p.get(o,e)+r*p.get(o,t))}for(let e=0;e<n;e++)p.set(e,t,0);p.set(t,t,1)}let N=b-1,M=0,S=Number.EPSILON;for(;b>0;){let t,e;for(t=b-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+S*Math.abs(f[t]+Math.abs(f[t+1]));if(Math.abs(v[t])<=e||Number.isNaN(v[t])){v[t]=0;break}}if(t===b-2)e=4;else{let r;for(r=b-1;r>=t&&r!==t;r--){let e=(r!==b?Math.abs(v[r]):0)+(r!==t+1?Math.abs(v[r-1]):0);if(Math.abs(f[r])<=S*e){f[r]=0;break}}r===t?e=3:r===b-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=v[b-2];v[b-2]=0;for(let r=b-2;r>=t;r--){let o=Z(f[r],e),i=f[r]/o,a=e/o;if(f[r]=o,r!==t&&(e=-a*v[r-1],v[r-1]=i*v[r-1]),d)for(let t=0;t<n;t++)o=i*p.get(t,r)+a*p.get(t,b-1),p.set(t,b-1,-a*p.get(t,r)+i*p.get(t,b-1)),p.set(t,r,o)}break}case 2:{let e=v[t-1];v[t-1]=0;for(let n=t;n<b;n++){let o=Z(f[n],e),i=f[n]/o,a=e/o;if(f[n]=o,e=-a*v[n],v[n]=i*v[n],u)for(let e=0;e<r;e++)o=i*g.get(e,n)+a*g.get(e,t-1),g.set(e,t-1,-a*g.get(e,n)+i*g.get(e,t-1)),g.set(e,n,o)}break}case 3:{const e=Math.max(Math.abs(f[b-1]),Math.abs(f[b-2]),Math.abs(v[b-2]),Math.abs(f[t]),Math.abs(v[t])),o=f[b-1]/e,i=f[b-2]/e,a=v[b-2]/e,s=f[t]/e,h=v[t]/e,c=((i+o)*(i-o)+a*a)/2,l=o*a*(o*a);let y=0;0===c&&0===l||(y=c<0?0-Math.sqrt(c*c+l):Math.sqrt(c*c+l),y=l/(c+y));let m=(s+o)*(s-o)+y,w=s*h;for(let e=t;e<b-1;e++){let o=Z(m,w);0===o&&(o=Number.MIN_VALUE);let i=m/o,a=w/o;if(e!==t&&(v[e-1]=o),m=i*f[e]+a*v[e],v[e]=i*v[e]-a*f[e],w=a*f[e+1],f[e+1]=i*f[e+1],d)for(let t=0;t<n;t++)o=i*p.get(t,e)+a*p.get(t,e+1),p.set(t,e+1,-a*p.get(t,e)+i*p.get(t,e+1)),p.set(t,e,o);if(o=Z(m,w),0===o&&(o=Number.MIN_VALUE),i=m/o,a=w/o,f[e]=o,m=i*v[e]+a*f[e+1],f[e+1]=-a*v[e]+i*f[e+1],w=a*v[e+1],v[e+1]=i*v[e+1],u&&e<r-1)for(let t=0;t<r;t++)o=i*g.get(t,e)+a*g.get(t,e+1),g.set(t,e+1,-a*g.get(t,e)+i*g.get(t,e+1)),g.set(t,e,o)}v[b-2]=m,M+=1;break}case 4:if(f[t]<=0&&(f[t]=f[t]<0?-f[t]:0,d))for(let e=0;e<=N;e++)p.set(e,t,-p.get(e,t));for(;t<N&&!(f[t]>=f[t+1]);){let e=f[t];if(f[t]=f[t+1],f[t+1]=e,d&&t<n-1)for(let r=0;r<n;r++)e=p.get(r,t+1),p.set(r,t+1,p.get(r,t)),p.set(r,t,e);if(u&&t<r-1)for(let n=0;n<r;n++)e=g.get(n,t+1),g.set(n,t+1,g.get(n,t)),g.set(n,t,e);t++}M=0,b--}}if(h){let t=p;p=g,g=t}this.m=r,this.n=n,this.s=f,this.U=g,this.V=p}solve(t){let e=t,r=this.threshold,n=this.s.length,o=X.zeros(n,n);for(let t=0;t<n;t++)Math.abs(this.s[t])<=r?o.set(t,t,0):o.set(t,t,1/this.s[t]);let i=this.U,a=this.rightSingularVectors,s=a.mmul(o),u=a.rows,d=i.rows,h=X.zeros(u,d);for(let t=0;t<u;t++)for(let e=0;e<d;e++){let r=0;for(let o=0;o<n;o++)r+=s.get(t,o)*i.get(e,o);h.set(t,e,r)}return h.mmul(e)}solveForDiagonal(t){return this.solve(X.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new X(r,this.s.length);for(let i=0;i<r;i++)for(let r=0;r<n;r++)Math.abs(this.s[r])>e&&o.set(i,r,t.get(i,r)/this.s[r]);let i=this.U,a=i.rows,s=i.columns,u=new X(r,a);for(let t=0;t<r;t++)for(let e=0;e<a;e++){let r=0;for(let n=0;n<s;n++)r+=o.get(t,n)*i.get(e,n);u.set(t,e,r)}return u}get condition(){return this.s[0]/this.s[Math.min(this.m,this.n)-1]}get norm2(){return this.s[0]}get rank(){let t=Math.max(this.m,this.n)*this.s[0]*Number.EPSILON,e=0,r=this.s;for(let n=0,o=r.length;n<o;n++)r[n]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return X.diag(this.s)}}var et={center:[0,0],linkDistance:50},rt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},et),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericMDSLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericMDSLayout(!0,t,e),[2]}))}))},t.prototype.genericMDSLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=void 0===i?[0,0]:i,u=o.linkDistance,d=void 0===u?50:u,h=e.getAllNodes(),c=e.getAllEdges(),(null==h?void 0:h.length)&&1!==h.length?(l=R({nodes:h,edges:c},!1),f=z(l),nt(f),v=d,y=[],f.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*v)})),y.push(e)})),g=ot(y),p=[],g.forEach((function(t,e){var r=b(h[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],p.push(r)})),t&&p.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:p,edges:c}]):[2,N(e,t,s)];var v,y}))}))},t}(),nt=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,n){r.forEach((function(r,o){r===1/0&&(t[n][o]=e)}))}))},ot=function(t){var e=X.mul(X.pow(t,2),-.5),r=e.mean("row"),n=e.mean("column"),o=e.mean();e.add(o).subRowVector(r).subColumnVector(n);var i=new tt(e),a=X.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return X.mul([t],[a]).toJSON()[0].splice(0,2)}))};function it(t,e,r,n){if(isNaN(e)||isNaN(r))return t;var o,i,a,s,u,d,h,c,l,f=t._root,g={data:n},p=t._x0,v=t._y0,y=t._x1,m=t._y1;if(!f)return t._root=g,t;for(;f.length;)if((d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a,o=f,!(f=f[c=h<<1|d]))return o[c]=g,t;if(s=+t._x.call(null,f.data),u=+t._y.call(null,f.data),e===s&&r===u)return g.next=f,o?o[c]=g:t._root=g,t;do{o=o?o[c]=new Array(4):t._root=new Array(4),(d=e>=(i=(p+y)/2))?p=i:y=i,(h=r>=(a=(v+m)/2))?v=a:m=a}while((c=h<<1|d)==(l=(u>=a)<<1|s>=i));return o[l]=f,o[c]=g,t}function at(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function st(t){return t[0]}function ut(t){return t[1]}function dt(t,e,r){var n=new ht(null==e?st:e,null==r?ut:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function ht(t,e,r,n,o,i){this._x=t,this._y=e,this._x0=r,this._y0=n,this._x1=o,this._y1=i,this._root=void 0}function ct(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var lt=dt.prototype=ht.prototype;function ft(t,e,r,n,o){if(isNaN(e)||isNaN(r)||isNaN(n))return t;var i,a,s,u,d,h,c,l,f,g,p,v,y=t._root,m={data:o},w=t._x0,x=t._y0,E=t._z0,b=t._x1,N=t._y1,M=t._z1;if(!y)return t._root=m,t;for(;y.length;)if((l=e>=(a=(w+b)/2))?w=a:b=a,(f=r>=(s=(x+N)/2))?x=s:N=s,(g=n>=(u=(E+M)/2))?E=u:M=u,i=y,!(y=y[p=g<<2|f<<1|l]))return i[p]=m,t;if(d=+t._x.call(null,y.data),h=+t._y.call(null,y.data),c=+t._z.call(null,y.data),e===d&&r===h&&n===c)return m.next=y,i?i[p]=m:t._root=m,t;do{i=i?i[p]=new Array(8):t._root=new Array(8),(l=e>=(a=(w+b)/2))?w=a:b=a,(f=r>=(s=(x+N)/2))?x=s:N=s,(g=n>=(u=(E+M)/2))?E=u:M=u}while((p=g<<2|f<<1|l)==(v=(c>=u)<<2|(h>=s)<<1|d>=a));return i[v]=y,i[p]=m,t}function gt(t,e,r,n,o,i,a){this.node=t,this.x0=e,this.y0=r,this.z0=n,this.x1=o,this.y1=i,this.z1=a}function pt(t){return t[0]}function vt(t){return t[1]}function yt(t){return t[2]}function mt(t,e,r,n){var o=new wt(null==e?pt:e,null==r?vt:r,null==n?yt:n,NaN,NaN,NaN,NaN,NaN,NaN);return null==t?o:o.addAll(t)}function wt(t,e,r,n,o,i,a,s,u){this._x=t,this._y=e,this._z=r,this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this._root=void 0}function xt(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}lt.copy=function(){var t,e,r=new ht(this._x,this._y,this._x0,this._y0,this._x1,this._y1),n=this._root;if(!n)return r;if(!n.length)return r._root=ct(n),r;for(t=[{source:n,target:r._root=new Array(4)}];n=t.pop();)for(var o=0;o<4;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(4)}):n.target[o]=ct(e));return r},lt.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return it(this.cover(e,r),e,r,t)},lt.addAll=function(t){var e,r,n,o,i=t.length,a=new Array(i),s=new Array(i),u=1/0,d=1/0,h=-1/0,c=-1/0;for(r=0;r<i;++r)isNaN(n=+this._x.call(null,e=t[r]))||isNaN(o=+this._y.call(null,e))||(a[r]=n,s[r]=o,n<u&&(u=n),n>h&&(h=n),o<d&&(d=o),o>c&&(c=o));if(u>h||d>c)return this;for(this.cover(u,d).cover(h,c),r=0;r<i;++r)it(this,a[r],s[r],t[r]);return this},lt.cover=function(t,e){if(isNaN(t=+t)||isNaN(e=+e))return this;var r=this._x0,n=this._y0,o=this._x1,i=this._y1;if(isNaN(r))o=(r=Math.floor(t))+1,i=(n=Math.floor(e))+1;else{for(var a,s,u=o-r||1,d=this._root;r>t||t>=o||n>e||e>=i;)switch(s=(e<n)<<1|t<r,(a=new Array(4))[s]=d,d=a,u*=2,s){case 0:o=r+u,i=n+u;break;case 1:r=o-u,i=n+u;break;case 2:o=r+u,n=i-u;break;case 3:r=o-u,n=i-u}this._root&&this._root.length&&(this._root=d)}return this._x0=r,this._y0=n,this._x1=o,this._y1=i,this},lt.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},lt.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},lt.find=function(t,e,r){var n,o,i,a,s,u,d,h=this._x0,c=this._y0,l=this._x1,f=this._y1,g=[],p=this._root;for(p&&g.push(new at(p,h,c,l,f)),null==r?r=1/0:(h=t-r,c=e-r,l=t+r,f=e+r,r*=r);u=g.pop();)if(!(!(p=u.node)||(o=u.x0)>l||(i=u.y0)>f||(a=u.x1)<h||(s=u.y1)<c))if(p.length){var v=(o+a)/2,y=(i+s)/2;g.push(new at(p[3],v,y,a,s),new at(p[2],o,y,v,s),new at(p[1],v,i,a,y),new at(p[0],o,i,v,y)),(d=(e>=y)<<1|t>=v)&&(u=g[g.length-1],g[g.length-1]=g[g.length-1-d],g[g.length-1-d]=u)}else{var m=t-+this._x.call(null,p.data),w=e-+this._y.call(null,p.data),x=m*m+w*w;if(x<r){var E=Math.sqrt(r=x);h=t-E,c=e-E,l=t+E,f=e+E,n=p.data}}return n},lt.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f=this._root,g=this._x0,p=this._y0,v=this._x1,y=this._y1;if(!f)return this;if(f.length)for(;;){if((d=i>=(s=(g+v)/2))?g=s:v=s,(h=a>=(u=(p+y)/2))?p=u:y=u,e=f,!(f=f[c=h<<1|d]))return this;if(!f.length)break;(e[c+1&3]||e[c+2&3]||e[c+3&3])&&(r=e,l=c)}for(;f.data!==t;)if(n=f,!(f=f.next))return this;return(o=f.next)&&delete f.next,n?(o?n.next=o:delete n.next,this):e?(o?e[c]=o:delete e[c],(f=e[0]||e[1]||e[2]||e[3])&&f===(e[3]||e[2]||e[1]||e[0])&&!f.length&&(r?r[l]=f:this._root=f),this):(this._root=o,this)},lt.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},lt.root=function(){return this._root},lt.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},lt.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new at(u,this._x0,this._y0,this._x1,this._y1));e=s.pop();)if(!t(u=e.node,n=e.x0,o=e.y0,i=e.x1,a=e.y1)&&u.length){var d=(n+i)/2,h=(o+a)/2;(r=u[3])&&s.push(new at(r,d,h,i,a)),(r=u[2])&&s.push(new at(r,n,h,d,a)),(r=u[1])&&s.push(new at(r,d,o,i,h)),(r=u[0])&&s.push(new at(r,n,o,d,h))}return this},lt.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new at(this._root,this._x0,this._y0,this._x1,this._y1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.x1,d=e.y1,h=(a+u)/2,c=(s+d)/2;(i=o[0])&&r.push(new at(i,a,s,h,c)),(i=o[1])&&r.push(new at(i,h,s,u,c)),(i=o[2])&&r.push(new at(i,a,c,h,d)),(i=o[3])&&r.push(new at(i,h,c,u,d))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.x1,e.y1);return this},lt.x=function(t){return arguments.length?(this._x=t,this):this._x},lt.y=function(t){return arguments.length?(this._y=t,this):this._y};var Et=mt.prototype=wt.prototype;function bt(t){var e=0,r=0,n=0,o=0,i=0,a=t.length;if(a){for(var s=0;s<a;s++)(u=t[s])&&u.weight&&(e+=u.weight,r+=u.x*u.weight,n+=u.y*u.weight,o+=u.z*u.weight,i+=u.size*u.weight);t.x=r/e,t.y=n/e,t.z=o/e,t.size=i/e,t.weight=e}else{var u=t;t.x=u.data.x,t.y=u.data.y,t.z=u.data.z,t.size=u.data.size,t.weight=u.data.weight}}Et.copy=function(){var t,e,r=new wt(this._x,this._y,this._z,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1),n=this._root;if(!n)return r;if(!n.length)return r._root=xt(n),r;for(t=[{source:n,target:r._root=new Array(8)}];n=t.pop();)for(var o=0;o<8;++o)(e=n.source[o])&&(e.length?t.push({source:e,target:n.target[o]=new Array(8)}):n.target[o]=xt(e));return r},Et.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t),n=+this._z.call(null,t);return ft(this.cover(e,r,n),e,r,n,t)},Et.addAll=function(t){Array.isArray(t)||(t=Array.from(t));const e=t.length,r=new Float64Array(e),n=new Float64Array(e),o=new Float64Array(e);let i=1/0,a=1/0,s=1/0,u=-1/0,d=-1/0,h=-1/0;for(let c,l,f,g,p=0;p<e;++p)isNaN(l=+this._x.call(null,c=t[p]))||isNaN(f=+this._y.call(null,c))||isNaN(g=+this._z.call(null,c))||(r[p]=l,n[p]=f,o[p]=g,l<i&&(i=l),l>u&&(u=l),f<a&&(a=f),f>d&&(d=f),g<s&&(s=g),g>h&&(h=g));if(i>u||a>d||s>h)return this;this.cover(i,a,s).cover(u,d,h);for(let i=0;i<e;++i)ft(this,r[i],n[i],o[i],t[i]);return this},Et.cover=function(t,e,r){if(isNaN(t=+t)||isNaN(e=+e)||isNaN(r=+r))return this;var n=this._x0,o=this._y0,i=this._z0,a=this._x1,s=this._y1,u=this._z1;if(isNaN(n))a=(n=Math.floor(t))+1,s=(o=Math.floor(e))+1,u=(i=Math.floor(r))+1;else{for(var d,h,c=a-n||1,l=this._root;n>t||t>=a||o>e||e>=s||i>r||r>=u;)switch(h=(r<i)<<2|(e<o)<<1|t<n,(d=new Array(8))[h]=l,l=d,c*=2,h){case 0:a=n+c,s=o+c,u=i+c;break;case 1:n=a-c,s=o+c,u=i+c;break;case 2:a=n+c,o=s-c,u=i+c;break;case 3:n=a-c,o=s-c,u=i+c;break;case 4:a=n+c,s=o+c,i=u-c;break;case 5:n=a-c,s=o+c,i=u-c;break;case 6:a=n+c,o=s-c,i=u-c;break;case 7:n=a-c,o=s-c,i=u-c}this._root&&this._root.length&&(this._root=l)}return this._x0=n,this._y0=o,this._z0=i,this._x1=a,this._y1=s,this._z1=u,this},Et.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},Et.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1],+t[0][2]).cover(+t[1][0],+t[1][1],+t[1][2]):isNaN(this._x0)?void 0:[[this._x0,this._y0,this._z0],[this._x1,this._y1,this._z1]]},Et.find=function(t,e,r,n){var o,i,a,s,u,d,h,c,l,f=this._x0,g=this._y0,p=this._z0,v=this._x1,y=this._y1,m=this._z1,w=[],x=this._root;for(x&&w.push(new gt(x,f,g,p,v,y,m)),null==n?n=1/0:(f=t-n,g=e-n,p=r-n,v=t+n,y=e+n,m=r+n,n*=n);c=w.pop();)if(!(!(x=c.node)||(i=c.x0)>v||(a=c.y0)>y||(s=c.z0)>m||(u=c.x1)<f||(d=c.y1)<g||(h=c.z1)<p))if(x.length){var E=(i+u)/2,b=(a+d)/2,N=(s+h)/2;w.push(new gt(x[7],E,b,N,u,d,h),new gt(x[6],i,b,N,E,d,h),new gt(x[5],E,a,N,u,b,h),new gt(x[4],i,a,N,E,b,h),new gt(x[3],E,b,s,u,d,N),new gt(x[2],i,b,s,E,d,N),new gt(x[1],E,a,s,u,b,N),new gt(x[0],i,a,s,E,b,N)),(l=(r>=N)<<2|(e>=b)<<1|t>=E)&&(c=w[w.length-1],w[w.length-1]=w[w.length-1-l],w[w.length-1-l]=c)}else{var M=t-+this._x.call(null,x.data),S=e-+this._y.call(null,x.data),k=r-+this._z.call(null,x.data),A=M*M+S*S+k*k;if(A<n){var _=Math.sqrt(n=A);f=t-_,g=e-_,p=r-_,v=t+_,y=e+_,m=r+_,o=x.data}}return o},Et.remove=function(t){if(isNaN(i=+this._x.call(null,t))||isNaN(a=+this._y.call(null,t))||isNaN(s=+this._z.call(null,t)))return this;var e,r,n,o,i,a,s,u,d,h,c,l,f,g,p,v=this._root,y=this._x0,m=this._y0,w=this._z0,x=this._x1,E=this._y1,b=this._z1;if(!v)return this;if(v.length)for(;;){if((c=i>=(u=(y+x)/2))?y=u:x=u,(l=a>=(d=(m+E)/2))?m=d:E=d,(f=s>=(h=(w+b)/2))?w=h:b=h,e=v,!(v=v[g=f<<2|l<<1|c]))return this;if(!v.length)break;(e[g+1&7]||e[g+2&7]||e[g+3&7]||e[g+4&7]||e[g+5&7]||e[g+6&7]||e[g+7&7])&&(r=e,p=g)}for(;v.data!==t;)if(n=v,!(v=v.next))return this;return(o=v.next)&&delete v.next,n?(o?n.next=o:delete n.next,this):e?(o?e[g]=o:delete e[g],(v=e[0]||e[1]||e[2]||e[3]||e[4]||e[5]||e[6]||e[7])&&v===(e[7]||e[6]||e[5]||e[4]||e[3]||e[2]||e[1]||e[0])&&!v.length&&(r?r[p]=v:this._root=v),this):(this._root=o,this)},Et.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},Et.root=function(){return this._root},Et.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},Et.visit=function(t){var e,r,n,o,i,a,s,u,d=[],h=this._root;for(h&&d.push(new gt(h,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=d.pop();)if(!t(h=e.node,n=e.x0,o=e.y0,i=e.z0,a=e.x1,s=e.y1,u=e.z1)&&h.length){var c=(n+a)/2,l=(o+s)/2,f=(i+u)/2;(r=h[7])&&d.push(new gt(r,c,l,f,a,s,u)),(r=h[6])&&d.push(new gt(r,n,l,f,c,s,u)),(r=h[5])&&d.push(new gt(r,c,o,f,a,l,u)),(r=h[4])&&d.push(new gt(r,n,o,f,c,l,u)),(r=h[3])&&d.push(new gt(r,c,l,i,a,s,f)),(r=h[2])&&d.push(new gt(r,n,l,i,c,s,f)),(r=h[1])&&d.push(new gt(r,c,o,i,a,l,f)),(r=h[0])&&d.push(new gt(r,n,o,i,c,l,f))}return this},Et.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new gt(this._root,this._x0,this._y0,this._z0,this._x1,this._y1,this._z1));e=r.pop();){var o=e.node;if(o.length){var i,a=e.x0,s=e.y0,u=e.z0,d=e.x1,h=e.y1,c=e.z1,l=(a+d)/2,f=(s+h)/2,g=(u+c)/2;(i=o[0])&&r.push(new gt(i,a,s,u,l,f,g)),(i=o[1])&&r.push(new gt(i,l,s,u,d,f,g)),(i=o[2])&&r.push(new gt(i,a,f,u,l,h,g)),(i=o[3])&&r.push(new gt(i,l,f,u,d,h,g)),(i=o[4])&&r.push(new gt(i,a,s,g,l,f,c)),(i=o[5])&&r.push(new gt(i,l,s,g,d,f,c)),(i=o[6])&&r.push(new gt(i,a,f,g,l,h,c)),(i=o[7])&&r.push(new gt(i,l,f,g,d,h,c))}n.push(e)}for(;e=n.pop();)t(e.node,e.x0,e.y0,e.z0,e.x1,e.y1,e.z1);return this},Et.x=function(t){return arguments.length?(this._x=t,this):this._x},Et.y=function(t){return arguments.length?(this._y=t,this):this._y},Et.z=function(t){return arguments.length?(this._z=t,this):this._z};var Nt=function(t,e,r,n,o,i,a){var s;if((null===(s=t.data)||void 0===s?void 0:s.id)!==i.id){for(var u=[r,n,o][a-1],d=i.x-t.x||.1,h=i.y-t.y||.1,c=i.z-t.z||.1,l=[d,h,c],f=u-e,g=0,p=0;p<a;p++)g+=l[p]*l[p];var v=Math.sqrt(g)*g;if(f*f*.81<g){var y=t.weight/v;return i.vx+=d*y,i.vy+=h*y,i.vz+=c*y,!0}if(t.length)return!1;t.data!==i&&(y=t.data.weight/v,i.vx+=d*y,i.vy+=h*y,i.vz+=c*y)}},Mt={dimensions:2,maxIteration:500,gravity:10,factor:1,edgeStrength:50,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:200,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},St=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="force",this.timeInterval=0,this.judgingDistance=0,this.running=!1,this.options=n(n({},Mt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;(this.judgingDistance>this.lastOptions.minMovement||r<1)&&r<t;r++)this.runOneStep(this.lastCalcGraph,this.lastGraph,r,this.lastVelMap,this.lastOptions),this.updatePosition(this.lastGraph,this.lastCalcGraph,this.lastVelMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,f,g,p,y,m,w,x,E,b,N,M,S,k,A=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=this.formatOptions(o,e),d=u.dimensions,h=u.width,c=u.height,f=u.nodeSize,g=u.getMass,p=u.nodeStrength,y=u.edgeStrength,m=u.linkDistance,w=i.map((function(t,e){return n(n({},t),{data:n(n({},t.data),{x:v(t.data.x)?t.data.x:Math.random()*h,y:v(t.data.y)?t.data.y:Math.random()*c,z:v(t.data.z)?t.data.z:Math.random()*Math.sqrt(h*c),size:f(t)||30,mass:g(t),nodeStrength:p(t)})})})),x=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:y(t),linkDistance:m(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(E={},i.forEach((function(t,e){E[t.id]={x:0,y:0,z:0}})),b=new l({nodes:w,edges:x}),this.formatCentripetal(u,b),N=u.maxIteration,M=u.minMovement,S=u.onTick,this.lastLayoutNodes=w,this.lastLayoutEdges=x,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=b,this.lastOptions=u,this.lastVelMap=E,"undefined"==typeof window?[2]:(k=0,[2,new Promise((function(r){A.timeInterval=window.setInterval((function(){i&&A.running||r({nodes:Rt(e,w),edges:s}),A.runOneStep(b,e,k,E,u),A.updatePosition(e,b,E,u),t&&w.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===d?t.data.z:void 0})})),null==S||S({nodes:Rt(e,w),edges:s}),(++k>=N||A.judgingDistance<M)&&(window.clearInterval(A.timeInterval),r({nodes:Rt(e,w),edges:s}))}),0),A.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=n({},t),o=t.width,i=t.height,a=t.getMass,s=t.nodeSize;r.width=o||"undefined"==typeof window?o:window.innerWidth,r.height=i||"undefined"==typeof window?i:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),a||(r.getMass=function(t){var r=1;v(null==t?void 0:t.data.mass)&&(r=null==t?void 0:t.data.mass);var n=e.getDegree(t.id,"both");return!n||n<5?r:5*n*r});var u,d=m(0,t.nodeSpacing);u=s?f(s)?function(t){return s(t)+d(t)}:_(s)?function(t){var e=s;return Math.max(e[0],e[1])+d(t)}:function(t){return s+d(t)}:function(t){var e=((null==t?void 0:t.data)||{}).size;return e?_(e)?Math.max(e[0],e[1])+d(t):y(e)?Math.max(e.width,e.height)+d(t):e+d(t):10+d(t)},r.nodeSize=u;var h=t.linkDistance?m(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))};return r.linkDistance=h,r.nodeStrength=m(1,t.nodeStrength),r.edgeStrength=m(1,t.edgeStrength),r},t.prototype.formatCentripetal=function(t,e){var r,n,o=t.dimensions,i=t.centripetalOptions,a=t.center,s=t.clusterNodeStrength,u=t.leafCluster,d=t.clustering,h=t.nodeClusterBy,c=e.getAllNodes(),l=i||{leaf:2,single:2,others:1,center:function(t){return{x:a[0],y:a[1],z:3===o?a[2]:void 0}}};if("function"!=typeof s&&(t.clusterNodeStrength=function(t){return s}),u&&h&&(r=kt(e,h),n=Array.from(new Set(null==c?void 0:c.map((function(t){return t.data[h]}))))||[],t.centripetalOptions=Object.assign(l,{single:100,leaf:function(e){var o=r[e.id]||{},i=o.siblingLeaves,a=o.sameTypeLeaves;return(null==a?void 0:a.length)===(null==i?void 0:i.length)||1===(null==n?void 0:n.length)?1:t.clusterNodeStrength(e)},others:1,center:function(t){var n,o=e.getDegree(t.id,"both");if(!o)return{x:100,y:100,z:0};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=zt(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y,z:null==n?void 0:n.z}}})),d&&h){r||(r=kt(e,h)),n||(n=Array.from(new Set(c.map((function(t){return t.data[h]}))))),n=n.filter((function(t){return void 0!==t}));var f={};n.forEach((function(t){var r=c.filter((function(e){return e.data[h]===t})).map((function(t){return e.getNode(t.id)}));f[t]=zt(r)})),t.centripetalOptions=Object.assign(l,{single:function(e){return t.clusterNodeStrength(e)},leaf:function(e){return t.clusterNodeStrength(e)},others:function(e){return t.clusterNodeStrength(e)},center:function(t){var e=f[t.data[h]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y,z:null==e?void 0:e.z}}})}var g=t.centripetalOptions||{},p=g.leaf,v=g.single,y=g.others;p&&"function"!=typeof p&&(t.centripetalOptions.leaf=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.single=function(){return v}),y&&"function"!=typeof y&&(t.centripetalOptions.others=function(){return y})},t.prototype.runOneStep=function(t,e,r,n,o){var i={},a=t.getAllNodes(),s=t.getAllEdges();if(null==a?void 0:a.length){var u=o.monitor;this.calRepulsive(t,i,o),s&&this.calAttractive(t,i,o),this.calGravity(t,e,i,o),this.updateVelocity(t,i,n,o),u&&u({energy:this.calTotalEnergy(i,a),nodes:e.getAllNodes(),edges:e.getAllEdges(),iterations:r})}},t.prototype.calTotalEnergy=function(t,e){var r=this;if(!(null==e?void 0:e.length))return 0;var n=0;return e.forEach((function(e,o){var i=t[e.id].x,a=t[e.id].y,s=3===r.options.dimensions?t[e.id].z:0,u=i*i+a*a+s*s,d=e.data.mass;n+=(void 0===d?1:d)*u*.5})),n},t.prototype.calRepulsive=function(t,e,r){var n=r.dimensions,o=r.factor,i=r.coulombDisScale;!function(t,e,r,n,o){void 0===o&&(o=2);var i=e/r,a=t.getAllNodes(),s=a.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,z:r.z,size:r.size,index:e,id:t.id,vx:0,vy:0,vz:0,weight:i*n}})),u=(2===o?dt(s,(function(t){return t.x}),(function(t){return t.y})):mt(s,(function(t){return t.x}),(function(t){return t.y}),(function(t){return t.z}))).visitAfter(bt),d=new Map;s.forEach((function(t){d.set(t.id,t),function(t,e,r){e.visit((function(e,n,o,i,a){return Nt(e,n,o,i,a,t,r)}))}(t,u,o)})),s.map((function(t,e){var r=a[e],o=r.id,i=r.data.mass,s=void 0===i?1:i;n[o]={x:t.vx/s,y:t.vy/s,z:t.vz/s}}))}(t,o,i*i,e,n)},t.prototype.calAttractive=function(t,e,r){var n=r.dimensions,o=r.nodeSize;t.getAllEdges().forEach((function(r,i){var a=r.source,s=r.target,u=t.getNode(a),d=t.getNode(s);if(u&&d){var h=d.data.x-u.data.x,c=d.data.y-u.data.y,l=3===n?d.data.z-u.data.z:0;h||c||(h=.01*Math.random(),c=.01*Math.random(),3!==n||l||(l=.01*Math.random()));var f=Math.sqrt(h*h+c*c+l*l);if(!(f<o(u)+o(d))){var g=h/f,p=c/f,v=l/f,y=r.data||{},m=y.linkDistance,w=void 0===m?200:m,x=y.edgeStrength,E=(w-f)*(void 0===x?200:x),b=1/(u.data.mass||1),N=1/(d.data.mass||1),M=g*E,S=p*E,k=v*E;e[a].x-=M*b,e[a].y-=S*b,e[a].z-=k*b,e[s].x+=M*N,e[s].y+=S*N,e[s].z+=k*N}}}))},t.prototype.calGravity=function(t,e,r,n){var o=n.getCenter,i=t.getAllNodes(),a=e.getAllNodes(),u=e.getAllEdges(),d=n.width,h=n.height,c=n.center,l=n.gravity,f=n.centripetalOptions;i&&i.forEach((function(n){var i=n.id,g=n.data,p=g.mass,y=g.x,m=g.y,w=g.z,x=e.getNode(i),E=0,b=0,N=0,M=l,S=t.getDegree(i,"in"),k=t.getDegree(i,"out"),A=t.getDegree(i,"both"),_=null==o?void 0:o(x,A);if(_){var z=s(_,3);E=y-z[0],b=m-z[1],M=z[2]}else E=y-c[0],b=m-c[1],N=w-c[2];if(M&&(r[i].x-=M*E/p,r[i].y-=M*b/p,r[i].z-=M*N/p),f){var R=f.leaf,I=f.single,D=f.others,P=f.center,O=(null==P?void 0:P(x,a,u,d,h))||{x:0,y:0,z:0,centerStrength:0},T=O.x,C=O.y,L=O.z,q=O.centerStrength;if(!v(T)||!v(C))return;var j=(y-T)/p,F=(m-C)/p,V=(w-L)/p;if(q&&(r[i].x-=q*j,r[i].y-=q*F,r[i].z-=q*V),0===A){var B=I(x);if(!B)return;return r[i].x-=B*j,r[i].y-=B*F,void(r[i].z-=B*V)}if(0===S||0===k){var G=R(x,a,u);if(!G)return;return r[i].x-=G*j,r[i].y-=G*F,void(r[i].z-=G*V)}var W=D(x);if(!W)return;r[i].x-=W*j,r[i].y-=W*F,r[i].z-=W*V}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=n.dimensions,u=t.getAllNodes();(null==u?void 0:u.length)&&u.forEach((function(t){var n=t.id,u=(r[n].x+e[n].x*a)*o||.01,d=(r[n].y+e[n].y*a)*o||.01,h=3===s?(r[n].z+e[n].z*a)*o||.01:0,c=Math.sqrt(u*u+d*d+h*h);if(c>i){var l=i/c;u*=l,d*=l,h*=l}r[n]={x:u,y:d,z:h}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=n.dimensions,u=e.getAllNodes();if(null==u?void 0:u.length){var d=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),u.forEach((function(n){var u=n.id,h=t.getNode(u);if(v(h.data.fx)&&v(h.data.fy))e.mergeNodeData(u,{x:h.data.fx,y:h.data.fy,z:3===s?h.data.fz:void 0});else{var c=r[u].x*a,l=r[u].y*a,f=3===s?r[u].z*a:0;e.mergeNodeData(u,{x:n.data.x+c,y:n.data.y+l,z:n.data.z+f});var g=Math.sqrt(c*c+l*l+f*f);switch(i){case"max":o.judgingDistance<g&&(o.judgingDistance=g);break;case"min":o.judgingDistance>g&&(o.judgingDistance=g);break;default:d+=g}}})),i&&"mean"!==i||(this.judgingDistance=d/u.length)}else this.judgingDistance=0},t}(),kt=function(t,e){var r=t.getAllNodes();if(!(null==r?void 0:r.length))return{};var n={};return r.forEach((function(r,o){1===t.getDegree(r.id,"both")&&(n[r.id]=At(t,"leaf",r,e))})),n},At=function(t,e,r,n){var o=t.getDegree(r.id,"in"),i=t.getDegree(r.id,"out"),a=r,s=[];return 0===o?(a=t.getSuccessors(r.id)[0],s=t.getNeighbors(a.id)):0===i&&(a=t.getPredecessors(r.id)[0],s=t.getNeighbors(a.id)),s=s.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")})),{coreNode:a,siblingLeaves:s,sameTypeLeaves:_t(t,e,n,r,s)}},_t=function(t,e,r,n,o){var i=n.data[r]||"",a=(null==o?void 0:o.filter((function(t){return t.data[r]===i})))||[];return"leaf"===e&&(a=a.filter((function(e){return 0===t.getDegree(e.id,"in")||0===t.getDegree(e.id,"out")}))),a},zt=function(t){var e={x:0,y:0};t.forEach((function(t){var r=t.data,n=r.x,o=r.y;e.x+=n||0,e.y+=o||0}));var r=t.length||1;return{x:e.x/r,y:e.y/r}},Rt=function(t,e){return e.map((function(e){var r=e.id,o=e.data,i=t.getNode(r);return n(n({},i),{data:n(n({},i.data),{x:o.x,y:o.y,z:o.z})})}))};const It=function(t){return p(t,"String")};var Dt={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},Pt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},Dt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericConcentricLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericConcentricLayout(!0,t,e),[2]}))}))},t.prototype.genericConcentricLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,g,p,m,w,x,E,M,S,k,A,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U,H,Y;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=o.sortBy,h=o.maxLevelDiff,c=o.sweep,l=o.clockwise,g=o.equidistant,p=o.preventOverlap,m=o.startAngle,w=void 0===m?1.5*Math.PI:m,x=o.nodeSize,E=o.nodeSpacing,M=e.getAllNodes(),S=e.getAllEdges(),k=s||"undefined"==typeof window?s:window.innerWidth,A=u||"undefined"==typeof window?u:window.innerHeight,z=i||[k/2,A/2],!(null==M?void 0:M.length)||1===M.length)return[2,N(e,t,z)];if(R=[],D=0,_(x)?I=Math.max(x[0],x[1]):f(x)?(I=-1/0,M.forEach((function(t){var e=x(t);e>I&&(I=e)}))):I=x,_(E)?D=Math.max(E[0],E[1]):v(E)&&(D=E),M.forEach((function(t){var e=b(t);R.push(e);var r=I,n=e.data;_(n.size)?r=Math.max(n.size[0],n.size[1]):v(n.size)?r=n.size:y(n.size)&&(r=Math.max(n.size.width,n.size.height)),I=Math.max(I,r),f(E)&&(D=Math.max(E(t),D))})),P={},R.forEach((function(t,e){P[t.id]=e})),It(O=d)&&void 0!==R[0].data[O]||(O="degree"),"degree"===O?R.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):R.sort((function(t,e){return e.data[O]-t.data[O]})),T=R[0],C=(h||("degree"===O?e.getDegree(T.id,"both"):T.data[O]))/4,q=(L=[{nodes:[]}])[0],R.forEach((function(t){if(q.nodes.length>0){var r="degree"===O?Math.abs(e.getDegree(q.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(q.nodes[0].data[O]-t.data[O]);C&&r>=C&&(q={nodes:[]},L.push(q))}q.nodes.push(t)})),j=I+D,p||(F=L.length>0&&L[0].nodes.length>1,V=Math.min(k,A)/2-j,B=V/(L.length+(F?1:0)),j=Math.min(j,B)),G=0,L.forEach((function(t){var e=void 0===c?2*Math.PI-2*Math.PI/t.nodes.length:c;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&p){var r=Math.cos(t.dTheta)-Math.cos(0),n=Math.sin(t.dTheta)-Math.sin(0),o=Math.sqrt(j*j/(r*r+n*n));G=Math.max(o,G)}t.r=G,G+=j})),g){for(W=0,$=0,U=0;U<L.length;U++)H=L[U],Y=(H.r||0)-$,W=Math.max(W,Y);$=0,L.forEach((function(t,e){0===e&&($=t.r||0),t.r=$,$+=W}))}return L.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=w+(l?1:-1)*e*n;t.data.x=z[0]+r*Math.cos(o),t.data.y=z[1]+r*Math.sin(o)}))})),t&&R.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:R,edges:S}]}))}))},t}(),Ot={gForce:!0,force2:!0,d3force:!0,fruchterman:!0,forceAtlas2:!0,force:!0,"graphin-force":!0},Tt={center:[0,0],comboPadding:10,treeKey:"combo"},Ct=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="comboCombined",this.options=n(n({},Tt),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericComboCombinedLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericComboCombinedLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericComboCombinedLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,c,f,g,p,v,y,m,w,x,E,b,M,S,k,A,_,z;return a(this,(function(a){switch(a.label){case 0:return o=this.initVals(n(n({},this.options),r)),i=o.center,d=o.treeKey,h=o.outerLayout,c=e.getAllNodes().filter((function(t){return!t.data._isCombo})),f=e.getAllNodes().filter((function(t){return t.data._isCombo})),g=e.getAllEdges(),(p=null==c?void 0:c.length)&&1!==p?(v=[],y=new Map,c.forEach((function(t){y.set(t.id,t)})),m=new Map,f.forEach((function(t){m.set(t.id,t)})),w=new Map,x=this.getInnerGraphs(e,d,y,m,g,o,w),[4,Promise.all(x)]):[2,N(e,t,i)];case 1:return a.sent(),E=new Map,b=[],M=new Map,S=!0,e.getRoots(d).forEach((function(t){var r=w.get(t.id),o=m.get(t.id)||y.get(t.id),i={id:t.id,data:n(n({},t.data),{x:r.data.x||o.data.x,y:r.data.y||o.data.y,fx:r.data.fx||o.data.fx,fy:r.data.fy||o.data.fy,mass:r.data.mass||o.data.mass,size:r.data.size})};b.push(i),E.set(t.id,!0),isNaN(i.data.x)||0===i.data.x||isNaN(i.data.y)||0===i.data.y?(i.data.x=100*Math.random(),i.data.y=100*Math.random()):S=!1,D(e,[t],(function(e){e.id!==t.id&&M.set(e.id,t.id)}),"TB",d)})),k=[],g.forEach((function(t){var e=M.get(t.source)||t.source,r=M.get(t.target)||t.target;e!==r&&E.has(e)&&E.has(r)&&k.push({id:t.id,source:e,target:r,data:{}})})),(null==b?void 0:b.length)?1!==b.length?[3,2]:(b[0].data.x=i[0],b[0].data.y=i[1],[3,6]):[3,7];case 2:return _=new l({nodes:b,edges:k}),z=h||new St,S&&Ot[z.id]?[4,(b.length<100?new rt:new Pt).assign(_)]:[3,4];case 3:a.sent(),a.label=4;case 4:return[4,z.execute(_,n({center:i,kg:5,preventOverlap:!0,animate:!1},"force"===z.id?{gravity:1,factor:4,linkDistance:function(t,e,r){return(Math.max.apply(Math,u([],s(e.data.size)))||32)/2+(Math.max.apply(Math,u([],s(r.data.size)))||32)/2+200}}:{}))];case 5:A=a.sent(),a.label=6;case 6:w.forEach((function(t){var e,r=A.nodes.find((function(e){return e.id===t.id}));if(r){var n=r.data,o=n.x,i=n.y;t.data.visited=!0,t.data.x=o,t.data.y=i,v.push({id:t.id,data:{x:o,y:i}})}var a=t.data,s=a.x,u=a.y;null===(e=t.data.nodes)||void 0===e||e.forEach((function(t){v.push({id:t.id,data:{x:t.data.x+s,y:t.data.y+u}})}))})),w.forEach((function(t){var e,r=t.data,n=r.x,o=r.y,i=r.visited;null===(e=r.nodes)||void 0===e||e.forEach((function(t){if(!i){var e=v.find((function(e){return e.id===t.id}));e.data.x+=n||0,e.data.y+=o||0}}))})),a.label=7;case 7:return t&&v.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:v,edges:g}]}}))}))},t.prototype.initVals=function(t){var e,r,o,i=n({},t),a=t.nodeSize,s=t.spacing,u=t.comboPadding;if(r=v(s)?function(){return s}:f(s)?s:function(){return 0},i.spacing=r,a)if(f(a))e=function(t){var e=a(t),n=r(t);return _(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+n)/2:((e||32)+n)/2};else if(_(a)){var d=(a[0]>a[1]?a[0]:a[1])/2;e=function(t){return d+r(t)/2}}else{var h=a/2;e=function(t){return h+r(t)/2}}else e=function(t){var e=r(t);return t.size?_(t.size)?((t.size[0]>t.size[1]?t.size[0]:t.size[1])+e)/2:y(t.size)?((t.size.width>t.size.height?t.size.width:t.size.height)+e)/2:(t.size+e)/2:32+e/2};return i.nodeSize=e,o=v(u)?function(){return u}:_(u)?function(){return Math.max.apply(null,u)}:f(u)?u:function(){return 0},i.comboPadding=o,i},t.prototype.getInnerGraphs=function(t,e,r,o,d,h,c){var f=this,g=h.nodeSize,p=h.comboPadding,y=h.spacing,m=h.innerLayout||new Pt({}),w={center:[0,0],preventOverlap:!0,nodeSpacing:y},x=[],E=function(t){var e=(null==p?void 0:p(t))||10;return _(e)&&(e=Math.max.apply(Math,u([],s(e)))),{size:e?[2*e,2*e]:[30,30],padding:e}};return t.getRoots(e).forEach((function(u){c.set(u.id,{id:u.id,data:{nodes:[],size:E(u).size}});var h=Promise.resolve();D(t,[u],(function(u){var p;if(u.data._isCombo){var y=E(u),x=y.size,b=y.padding;if(null===(p=t.getChildren(u.id,e))||void 0===p?void 0:p.length){var N=c.get(u.id);c.set(u.id,{id:u.id,data:n({nodes:[]},null==N?void 0:N.data)});var M=new Map,S=t.getChildren(u.id,e).map((function(t){if(t.data._isCombo)return c.has(t.id)||c.set(t.id,{id:t.id,data:n({},t.data)}),M.set(t.id,!0),c.get(t.id);var e=r.get(t.id)||o.get(t.id);return M.set(t.id,!0),{id:t.id,data:n(n({},e.data),t.data)}})),k={nodes:S,edges:d.filter((function(t){return M.has(t.source)&&M.has(t.target)}))},A=1/0;S.forEach((function(t){var e,r,n=t.data.size;n||(n=(null===(e=c.get(t.id))||void 0===e?void 0:e.data.size)||(null===(r=g)||void 0===r?void 0:r(t))||[30,30]),v(n)&&(n=[n,n]);var o=s(n,2),i=o[0],a=o[1];A>i&&(A=i),A>a&&(A=a),t.data.size=n})),h=h.then((function(){return i(f,void 0,void 0,(function(){var t,e,r,n,o,i,s,d,h;return a(this,(function(a){switch(a.label){case 0:return t=new l(k),[4,m.assign(t,w)];case 1:return e=a.sent(),r=function(t){var e=1/0,r=1/0,n=-1/0,o=-1/0;return t.forEach((function(t){var i=t.data.size;_(i)?1===i.length&&(i=[i[0],i[0]]):v(i)?i=[i,i]:(void 0===i||isNaN(i))&&(i=[30,30]);var a=[i[0]/2,i[1]/2],s=t.data.x-a[0],u=t.data.x+a[0],d=t.data.y-a[1],h=t.data.y+a[1];e>s&&(e=s),r>d&&(r=d),n<u&&(n=u),o<h&&(o=h)})),{minX:e,minY:r,maxX:n,maxY:o}}(S),n=r.minX,o=r.minY,i=r.maxX,s=r.maxY,d={x:(i+n)/2,y:(s+o)/2},k.nodes.forEach((function(t){t.data.x-=d.x,t.data.y-=d.y})),h=[Math.max(i-n,A)+2*b,Math.max(s-o,A)+2*b],c.get(u.id).data.size=h,c.get(u.id).data.nodes=S,[2,e]}}))}))}))}else c.set(u.id,{id:u.id,data:n(n({},u.data),{size:x})});return!0}}),"BT",e),x.push(h)})),x},t}();function Lt(t){return function(){return t}}function qt(t){return 1e-6*(t()-.5)}var jt={value:()=>{}};function Ft(){for(var t,e=0,r=arguments.length,n={};e<r;++e){if(!(t=arguments[e]+"")||t in n||/[\s.]/.test(t))throw new Error("illegal type: "+t);n[t]=[]}return new Vt(n)}function Vt(t){this._=t}function Bt(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function Gt(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=jt,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}Vt.prototype=Ft.prototype={constructor:Vt,on:function(t,e){var r,n,o=this._,i=(n=o,(t+"").trim().split(/^|\s+/).map((function(t){var e="",r=t.indexOf(".");if(r>=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}}))),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a<s;)if(r=(t=i[a]).type)o[r]=Gt(o[r],t.name,e);else if(null==e)for(r in o)o[r]=Gt(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=Bt(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new Vt(t)},call:function(t,e){if((r=arguments.length-2)>0)for(var r,n,o=new Array(r),i=0;i<r;++i)o[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,r=(n=this._[t]).length;i<r;++i)n[i].value.apply(e,o)},apply:function(t,e,r){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var n=this._[t],o=0,i=n.length;o<i;++o)n[o].value.apply(e,r)}};const Wt=Ft;var $t,Ut,Ht=0,Yt=0,Kt=0,Jt=1e3,Xt=0,Qt=0,Zt=0,te="object"==typeof performance&&performance.now?performance:Date,ee="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function re(){return Qt||(ee(ne),Qt=te.now()+Zt)}function ne(){Qt=0}function oe(){this._call=this._time=this._next=null}function ie(t,e,r){var n=new oe;return n.restart(t,e,r),n}function ae(){Qt=(Xt=te.now())+Zt,Ht=Yt=0;try{!function(){re(),++Ht;for(var t,e=$t;e;)(t=Qt-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ht}()}finally{Ht=0,function(){for(var t,e,r=$t,n=1/0;r;)r._call?(n>r._time&&(n=r._time),t=r,r=r._next):(e=r._next,r._next=null,r=t?t._next=e:$t=e);Ut=t,ue(n)}(),Qt=0}}function se(){var t=te.now(),e=t-Xt;e>Jt&&(Zt-=e,Xt=t)}function ue(t){Ht||(Yt&&(Yt=clearTimeout(Yt)),t-Qt>24?(t<1/0&&(Yt=setTimeout(ae,t-te.now()-Zt)),Kt&&(Kt=clearInterval(Kt))):(Kt||(Xt=te.now(),Kt=setInterval(se,Jt)),Ht=1,ee(ae)))}oe.prototype=ie.prototype={constructor:oe,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?re():+r)+(null==e?0:+e),this._next||Ut===this||(Ut?Ut._next=this:$t=this,Ut=this),this._call=t,this._time=r,ue()},stop:function(){this._call&&(this._call=null,this._time=1/0,ue())}};const de=1664525,he=1013904223,ce=4294967296;function le(t){return t.x}function fe(t){return t.y}var ge=10,pe=Math.PI*(3-Math.sqrt(5));function ve(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=ie(c),d=Wt("tick","end"),h=function(){let t=1;return()=>(t=(de*t+he)%ce)/ce}();function c(){l(),d.call("tick",e),r<n&&(u.stop(),d.call("end",e))}function l(n){var u,d,h=t.length;void 0===n&&(n=1);for(var c=0;c<n;++c)for(r+=(i-r)*o,s.forEach((function(t){t(r)})),u=0;u<h;++u)null==(d=t[u]).fx?d.x+=d.vx*=a:(d.x=d.fx,d.vx=0),null==d.fy?d.y+=d.vy*=a:(d.y=d.fy,d.vy=0);return e}function f(){for(var e,r=0,n=t.length;r<n;++r){if((e=t[r]).index=r,null!=e.fx&&(e.x=e.fx),null!=e.fy&&(e.y=e.fy),isNaN(e.x)||isNaN(e.y)){var o=ge*Math.sqrt(.5+r),i=r*pe;e.x=o*Math.cos(i),e.y=o*Math.sin(i)}(isNaN(e.vx)||isNaN(e.vy))&&(e.vx=e.vy=0)}}function g(e){return e.initialize&&e.initialize(t,h),e}return null==t&&(t=[]),f(),e={tick:l,restart:function(){return u.restart(c),e},stop:function(){return u.stop(),e},nodes:function(r){return arguments.length?(t=r,f(),s.forEach(g),e):t},alpha:function(t){return arguments.length?(r=+t,e):r},alphaMin:function(t){return arguments.length?(n=+t,e):n},alphaDecay:function(t){return arguments.length?(o=+t,e):+o},alphaTarget:function(t){return arguments.length?(i=+t,e):i},velocityDecay:function(t){return arguments.length?(a=1-t,e):1-a},randomSource:function(t){return arguments.length?(h=t,s.forEach(g),e):h},force:function(t,r){return arguments.length>1?(null==r?s.delete(t):s.set(t,g(r)),e):s.get(t)},find:function(e,r,n){var o,i,a,s,u,d=0,h=t.length;for(null==n?n=1/0:n*=n,d=0;d<h;++d)(a=(o=e-(s=t[d]).x)*o+(i=r-s.y)*i)<n&&(u=s,n=a);return u},on:function(t,r){return arguments.length>1?(d.on(t,r),e):d.on(t)}}}function ye(){var t,e,r,n,o,i=Lt(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=dt(t,le,fe).visitAfter(c);for(n=r,o=0;o<i;++o)e=t[o],a.visit(l)}function h(){if(t){var e,r,n=t.length;for(o=new Array(n),e=0;e<n;++e)r=t[e],o[r.index]=+i(r,e,t)}}function c(t){var e,r,n,i,a,s=0,u=0;if(t.length){for(n=i=a=0;a<4;++a)(e=t[a])&&(r=Math.abs(e.value))&&(s+=e.value,u+=r,n+=r*e.x,i+=r*e.y);t.x=n/u,t.y=i/u}else{(e=t).x=e.data.x,e.y=e.data.y;do{s+=o[e.data.index]}while(e=e.next)}t.value=s}function l(t,i,d,h){if(!t.value)return!0;var c=t.x-e.x,l=t.y-e.y,f=h-i,g=c*c+l*l;if(f*f/u<g)return g<s&&(0===c&&(g+=(c=qt(r))*c),0===l&&(g+=(l=qt(r))*l),g<a&&(g=Math.sqrt(a*g)),e.vx+=c*t.value*n/g,e.vy+=l*t.value*n/g),!0;if(!(t.length||g>=s)){(t.data!==e||t.next)&&(0===c&&(g+=(c=qt(r))*c),0===l&&(g+=(l=qt(r))*l),g<a&&(g=Math.sqrt(a*g)));do{t.data!==e&&(f=o[t.data.index]*n/g,e.vx+=c*f,e.vy+=l*f)}while(t=t.next)}}return d.initialize=function(e,n){t=e,r=n,h()},d.strength=function(t){return arguments.length?(i="function"==typeof t?t:Lt(+t),h(),d):i},d.distanceMin=function(t){return arguments.length?(a=t*t,d):Math.sqrt(a)},d.distanceMax=function(t){return arguments.length?(s=t*t,d):Math.sqrt(s)},d.theta=function(t){return arguments.length?(u=t*t,d):Math.sqrt(u)},d}function me(t){return t.index}function we(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function xe(t){var e,r,n,o,i,a,s=me,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=Lt(30),h=1;function c(n){for(var o=0,s=t.length;o<h;++o)for(var u,d,c,l,f,g,p,v=0;v<s;++v)d=(u=t[v]).source,l=(c=u.target).x+c.vx-d.x-d.vx||qt(a),f=c.y+c.vy-d.y-d.vy||qt(a),l*=g=((g=Math.sqrt(l*l+f*f))-r[v])/g*n*e[v],f*=g,c.vx-=l*(p=i[v]),c.vy-=f*p,d.vx+=l*(p=1-p),d.vy+=f*p}function l(){if(n){var a,u,d=n.length,h=t.length,c=new Map(n.map(((t,e)=>[s(t,e,n),t])));for(a=0,o=new Array(d);a<h;++a)(u=t[a]).index=a,"object"!=typeof u.source&&(u.source=we(c,u.source)),"object"!=typeof u.target&&(u.target=we(c,u.target)),o[u.source.index]=(o[u.source.index]||0)+1,o[u.target.index]=(o[u.target.index]||0)+1;for(a=0,i=new Array(h);a<h;++a)u=t[a],i[a]=o[u.source.index]/(o[u.source.index]+o[u.target.index]);e=new Array(h),f(),r=new Array(h),g()}}function f(){if(n)for(var r=0,o=t.length;r<o;++r)e[r]=+u(t[r],r,t)}function g(){if(n)for(var e=0,o=t.length;e<o;++e)r[e]=+d(t[e],e,t)}return null==t&&(t=[]),c.initialize=function(t,e){n=t,a=e,l()},c.links=function(e){return arguments.length?(t=e,l(),c):t},c.id=function(t){return arguments.length?(s=t,c):s},c.iterations=function(t){return arguments.length?(h=+t,c):h},c.strength=function(t){return arguments.length?(u="function"==typeof t?t:Lt(+t),f(),c):u},c.distance=function(t){return arguments.length?(d="function"==typeof t?t:Lt(+t),g(),c):d},c}function Ee(t){return t.x+t.vx}function be(t){return t.y+t.vy}function Ne(t){var e,r,n,o=1,i=1;function a(){for(var t,a,u,d,h,c,l,f=e.length,g=0;g<i;++g)for(a=dt(e,Ee,be).visitAfter(s),t=0;t<f;++t)u=e[t],c=r[u.index],l=c*c,d=u.x+u.vx,h=u.y+u.vy,a.visit(p);function p(t,e,r,i,a){var s=t.data,f=t.r,g=c+f;if(!s)return e>d+g||i<d-g||r>h+g||a<h-g;if(s.index>u.index){var p=d-s.x-s.vx,v=h-s.y-s.vy,y=p*p+v*v;y<g*g&&(0===p&&(y+=(p=qt(n))*p),0===v&&(y+=(v=qt(n))*v),y=(g-(y=Math.sqrt(y)))/y*o,u.vx+=(p*=y)*(g=(f*=f)/(l+f)),u.vy+=(v*=y)*g,s.vx-=p*(g=1-g),s.vy-=v*g)}}}function s(t){if(t.data)return t.r=r[t.data.index];for(var e=t.r=0;e<4;++e)t[e]&&t[e].r>t.r&&(t.r=t[e].r)}function u(){if(e){var n,o,i=e.length;for(r=new Array(i),n=0;n<i;++n)o=e[n],r[o.index]=+t(o,n,e)}}return"function"!=typeof t&&(t=Lt(null==t?1:+t)),a.initialize=function(t,r){e=t,n=r,u()},a.iterations=function(t){return arguments.length?(i=+t,a):i},a.strength=function(t){return arguments.length?(o=+t,a):o},a.radius=function(e){return arguments.length?(t="function"==typeof e?e:Lt(+e),u(),a):t},a}function Me(t){var e,r,n,o=Lt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vx+=(n[i]-o.x)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=Lt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Lt(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:Lt(+e),a(),i):t},i}function Se(t){var e,r,n,o=Lt(.1);function i(t){for(var o,i=0,a=e.length;i<a;++i)(o=e[i]).vy+=(n[i]-o.y)*r[i]*t}function a(){if(e){var i,a=e.length;for(r=new Array(a),n=new Array(a),i=0;i<a;++i)r[i]=isNaN(n[i]=+t(e[i],i,e))?0:+o(e[i],i,e)}}return"function"!=typeof t&&(t=Lt(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:Lt(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:Lt(+e),a(),i):t},i}function ke(){function t(t){return function(){return t}}var e,r=function(t){return t.cluster},n=t(1),o=t(-1),i=t(100),a=t(.1),u=[0,0],d=[],h={},c=[],l=100,f=100,g={none:{x:0,y:0}},p=[],v="force",y=!0,m=.1;function w(t){if(!y)return w;e.tick(),E();for(var n=0,o=d.length,i=void 0,a=t*m;n<o;++n)(i=d[n]).vx+=(g[r(i)].x-i.x)*a,i.vy+=(g[r(i)].y-i.y)*a}function x(){d&&function(){if(d&&d.length){if(void 0===r(d[0]))throw Error("Couldnt find the grouping attribute for the nodes. Make sure to set it up with forceInBox.groupBy('clusterAttr') before calling .links()");var t,u,g,v,y,m=(t=[],u=[],g={},{},y=[],v=function(t){var e={};return t.forEach((function(t){var n=r(t);e[n]||(e[n]={count:0,sumforceNodeSize:0})})),t.forEach((function(t){var o=r(t),i=n(t),a=e[o];a.count=a.count+1,a.sumforceNodeSize=a.sumforceNodeSize+Math.PI*(i*i)*1.3,e[o]=a})),e}(d),y=function(t){var e={},n=[];return t.forEach((function(t){var n,o,i,a,s,u=(o=(n=t).source,i=n.target,(a=r(h[o]))<=(s=r(h[i]))?a+"~"+s:s+"~"+a),d=0;void 0!==e[u]&&(d=e[u]),d+=1,e[u]=d})),Object.entries(e).forEach((function(t){var e=s(t,2),r=e[0],o=e[1],i=r.split("~")[0],a=r.split("~")[1];void 0!==i&&void 0!==a&&n.push({source:i,target:a,count:o})})),n}(c),Object.keys(v).forEach((function(e,r){var n=v[e];t.push({id:e,size:n.count,r:Math.sqrt(n.sumforceNodeSize/Math.PI)}),g[e]=r})),y.forEach((function(t){var e=t.source,r=t.target,n=g[e],o=g[r];void 0!==n&&void 0!==o&&u.push({source:n,target:o,count:t.count})})),{nodes:t,links:u});e=ve(m.nodes).force("x",Me(l).strength(.1)).force("y",Se(f).strength(.1)).force("collide",Ne((function(t){return t.r})).iterations(4)).force("charge",ye().strength(o)).force("links",xe(m.nodes.length?m.links:[]).distance(i).strength(a)),p=e.nodes(),E()}}()}function E(){return g={none:{x:0,y:0}},p.forEach((function(t){g[t.id]={x:t.x-u[0],y:t.y-u[1]}})),g}return w.initialize=function(t){d=t,x()},w.template=function(t){return arguments.length?(v=t,x(),w):v},w.groupBy=function(t){return arguments.length?"string"==typeof t?(r=function(e){return e[t]},w):(r=t,w):r},w.enableGrouping=function(t){return arguments.length?(y=t,w):y},w.strength=function(t){return arguments.length?(m=t,w):m},w.centerX=function(t){return arguments.length?(l=t,w):l},w.centerY=function(t){return arguments.length?(f=t,w):f},w.nodes=function(t){return arguments.length?(function(t){h={},t.forEach((function(t){h[t.id]=t}))}(t||[]),d=t||[],w):d},w.links=function(t){return arguments.length?(c=t||[],x(),w):c},w.forceNodeSize=function(e){return arguments.length?(n="function"==typeof e?e:t(+e),x(),w):n},w.nodeSize=w.forceNodeSize,w.forceCharge=function(e){return arguments.length?(o="function"==typeof e?e:t(+e),x(),w):o},w.forceLinkDistance=function(e){return arguments.length?(i="function"==typeof e?e:t(+e),x(),w):i},w.forceLinkStrength=function(e){return arguments.length?(a="function"==typeof e?e:t(+e),x(),w):a},w.offset=function(t){return arguments.length?(u=t,w):u},w.getFocis=E,w}var Ae={center:[0,0],preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,linkDistance:50,forceSimulation:null,alphaDecay:.028,alphaMin:.001,alpha:.3,collideStrength:1,clustering:!1,clusterNodeStrength:-1,clusterEdgeStrength:.1,clusterEdgeDistance:100,clusterFociStrength:.8,clusterNodeSize:10},_e=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",this.options=n(n({},Ae),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){var t;null===(t=this.forceSimulation)||void 0===t||t.stop()},t.prototype.tick=function(t){var e=this;void 0===t&&(t=1),this.forceSimulation.tick(t);var r={nodes:ze(this.lastLayoutNodes),edges:Re(this.lastLayoutEdges)};return this.lastAssign&&r.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r},t.prototype.genericForceLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p,v,y,m,w,x,E,N,M,S,k,A,_,z,R,I,D=this;return a(this,(function(a){return o=n(n({},this.options),r),i=e.getAllNodes(),s=e.getAllEdges(),u=i.map((function(t){var e,r;return n(n({},b(t)),{x:null===(e=t.data)||void 0===e?void 0:e.x,y:null===(r=t.data)||void 0===r?void 0:r.y})})),d=s.map((function(t){return b(t)})),this.lastLayoutNodes=u,this.lastLayoutEdges=d,this.lastAssign=t,this.lastGraph=e,h=o.alphaMin,c=o.alphaDecay,l=o.alpha,f=o.nodeStrength,g=o.edgeStrength,p=o.linkDistance,v=o.clustering,y=o.clusterFociStrength,m=o.clusterEdgeDistance,w=o.clusterEdgeStrength,x=o.clusterNodeStrength,E=o.clusterNodeSize,N=o.collideStrength,M=void 0===N?1:N,S=o.center,k=void 0===S?[0,0]:S,A=o.preventOverlap,_=o.nodeSize,z=o.nodeSpacing,R=o.onTick,I=o.forceSimulation,[2,new Promise((function(r){if(I){v&&((i=ke()).nodes(u),i.links(d)),I.nodes(u),d&&(s=xe().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),I.force("link",s)),A&&D.overlapProcess(I,{nodeSize:_,nodeSpacing:z,collideStrength:M}),I.alpha(l).restart();var n=ze(u),o=Re(d);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:o})}else try{var i,a=ye();if(f&&a.strength(f),I=ve().nodes(u),v&&((i=ke()).centerX(k[0]).centerY(k[1]).template("force").strength(y),d&&i.links(d),u&&i.nodes(u),i.forceLinkDistance(m).forceLinkStrength(w).forceCharge(x).forceNodeSize(E),I.force("group",i)),I.force("center",function(t,e){var r,n=1;function o(){var o,i,a=r.length,s=0,u=0;for(o=0;o<a;++o)s+=(i=r[o]).x,u+=i.y;for(s=(s/a-t)*n,u=(u/a-e)*n,o=0;o<a;++o)(i=r[o]).x-=s,i.y-=u}return null==t&&(t=0),null==e&&(e=0),o.initialize=function(t){r=t},o.x=function(e){return arguments.length?(t=+e,o):t},o.y=function(t){return arguments.length?(e=+t,o):e},o.strength=function(t){return arguments.length?(n=+t,o):n},o}(k[0],k[1])).force("charge",a).alpha(l).alphaDecay(c).alphaMin(h),A&&D.overlapProcess(I,{nodeSize:_,nodeSpacing:z,collideStrength:M}),d){var s=xe().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),I.force("link",s)}I.on("tick",(function(){var r=ze(u);null==R||R({nodes:r,edges:Re(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=ze(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Re(d)})}))}catch(t){console.warn(t)}D.forceSimulation=I}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=v(i)?function(){return i}:f(i)?i:function(){return 0},o)if(f(o))r=function(t){return o(t)+n(t)};else if(_(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(v(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?_(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):y(t.size)?(t.size.width>t.size.height?t.size.width:t.size.height)/2+n(t):t.size/2+n(t):10+n(t)};t.force("collisionForce",Ne(r).strength(a))},t}(),ze=function(t){return t.map((function(t){var e=t.x,r=t.y,i=o(t,["x","y"]);return n(n({},i),{data:n(n({},i.data),{x:e,y:r})})}))},Re=function(t){return t.map((function(t){var e=t.source,r=t.target,i=o(t,["source","target"]);return n(n({},i),{source:e.id,target:r.id})}))};var Ie=function(t,e){if("next"!==t&&"prev"!==t)return e},De=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Pe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}(e,t),e}(function(){function t(){var t={};t.prev=t,t.next=t.prev,this.shortcut=t}return t.prototype.dequeue=function(){var t=this.shortcut,e=t.prev;if(e&&e!==t)return De(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&De(t),t.next=e.next,e.next.prev=t,e.next=t,t.prev=e},t.prototype.toString=function(){for(var t=[],e=this.shortcut,r=e.prev;r!==e;)t.push(JSON.stringify(r,Ie)),r=null==r?void 0:r.prev;return"["+t.join(", ")+"]"},t}()),Oe=function(){return 1},Te=function(t,e,r,o,i){var a,s,u=[];return t.hasNode(o.v)&&(null===(a=t.getRelatedEdges(o.v,"in"))||void 0===a||a.forEach((function(o){var a=o.data.weight,s=t.getNode(o.source);i&&u.push({v:o.source,w:o.target,in:0,out:0}),void 0===s.data.out&&(s.data.out=0),s.data.out-=a,Ce(e,r,n({v:s.id},s.data))})),null===(s=t.getRelatedEdges(o.v,"out"))||void 0===s||s.forEach((function(o){var i=o.data.weight,a=o.target,s=t.getNode(a);void 0===s.data.in&&(s.data.in=0),s.data.in-=i,Ce(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Ce=function(t,e,r){r.out?r.in?t[r.out-r.in+e].enqueue(r):t[t.length-1].enqueue(r):t[0].enqueue(r)},Le=function(t,e){var r="greedy"===e?function(t,e){var r;if(t.getAllNodes().length<=1)return[];var o=function(t,e){var r=new l,o=0,i=0;t.getAllNodes().forEach((function(t){r.addNode({id:t.id,data:{v:t.id,in:0,out:0}})})),t.getAllEdges().forEach((function(t){var a=r.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target})),s=(null==e?void 0:e(t))||1;a?r.updateEdgeData(null==a?void 0:a.id,n(n({},a.data),{weight:a.data.weight+s})):r.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:s}}),i=Math.max(i,r.getNode(t.source).data.out+=s),o=Math.max(o,r.getNode(t.target).data.in+=s)}));for(var a=[],s=i+o+3,u=0;u<s;u++)a.push(new Pe);var d=o+1;return r.getAllNodes().forEach((function(t){Ce(a,d,n({v:t.id},r.getNode(t.id).data))})),{buckets:a,zeroIdx:d,graph:r}}(t,function(t){return t.data.weight||1}||Oe);return null===(r=function(t,e,r){for(var n,o=[],i=e[e.length-1],a=e[0];t.getAllNodes().length;){for(;n=a.dequeue();)Te(t,e,r,n);for(;n=i.dequeue();)Te(t,e,r,n);if(t.getAllNodes().length)for(var s=e.length-2;s>0;--s)if(n=e[s].dequeue()){o=o.concat(Te(t,e,r,n,!0));break}}return o}(o.graph,o.buckets,o.zeroIdx).map((function(e){return t.getRelatedEdges(e.v,"out").filter((function(t){return t.target===e.w}))})))||void 0===r?void 0:r.flat()}(t):qe(t);null==r||r.forEach((function(e){var r=e.data;t.removeEdge(e.id),r.forwardName=e.data.name,r.reversed=!0,t.addEdge({id:e.id,source:e.target,target:e.source,data:n({},r)})}))},qe=function(t){var e=[],r={},n={},o=function(i){n[i]||(n[i]=!0,r[i]=!0,t.getRelatedEdges(i,"out").forEach((function(t){r[t.target]?e.push(t):o(t.target)})),delete r[i])};return t.getAllNodes().forEach((function(t){return o(t.id)})),e},je=function(t,e,r,n){var o;do{o=""+n+Math.random()}while(t.hasNode(o));return r.dummy=e,t.addNode({id:o,data:r}),o},Fe=function(t){var e=new l;return t.getAllNodes().forEach((function(r){t.getChildren(r.id).length||e.addNode(n({},r))})),t.getAllEdges().forEach((function(t){e.addEdge(t)})),e},Ve=function(t,e){var r,n,o=Number(t.x),i=Number(t.y),a=Number(e.x)-o,s=Number(e.y)-i,u=Number(t.width)/2,d=Number(t.height)/2;return a||s?(Math.abs(s)*u>Math.abs(a)*d?(s<0&&(d=-d),r=d*a/s,n=d):(a<0&&(u=-u),r=u,n=u*s/a),{x:o+r,y:i+n}):{x:0,y:0}},Be=function(t){for(var e=[],r=We(t)+1,n=0;n<r;n++)e.push([]);for(t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&e[r]&&e[r].push(t.id)})),n=0;n<r;n++)e[n]=e[n].sort((function(e,r){return n=t.getNode(e).data.order,o=t.getNode(r).data.order,Number(n)-Number(o);var n,o}));return e},Ge=function(t,e,r,n){var o={width:0,height:0};return v(r)&&v(n)&&(o.rank=r,o.order=n),je(t,"border",o,e)},We=function(t){var e;return t.getAllNodes().forEach((function(t){var r=t.data.rank;void 0!==r&&(void 0===e||r>e)&&(e=r)})),e||(e=0),e},$e=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},Ue=function(t,e,r,n,o,i){n.includes(e.id)||(n.push(e.id),r||i.push(e.id),o(e.id).forEach((function(e){return Ue(t,e,r,n,o,i)})),r&&i.push(e.id))},He=function(t,e,r,n){var o=Array.isArray(e)?e:[e],i=function(e){return n?t.getSuccessors(e):t.getNeighbors(e)},a=[],s=[];return o.forEach((function(e){if(!t.hasNode(e.id))throw new Error("Graph does not have node: "+e);Ue(t,e,"post"===r,s,i,a)})),a},Ye="edge-label",Ke=function(t){var e={},r=function(n){var o,i,a=t.getNode(n);return a?e[n]?a.data.rank:(e[n]=!0,null===(o=t.getRelatedEdges(n,"out"))||void 0===o||o.forEach((function(t){var e=r(t.target)-t.data.minlen;e&&(void 0===i||e<i)&&(i=e)})),i||(i=0),a.data.rank=i,i):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){return r(t.id)}))},Je=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},Xe=function(t,e){var r=function(n){e.getRelatedEdges(n,"both").forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||Je(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},Qe=function(t,e){var r=function(n){var o;null===(o=e.getRelatedEdges(n,"both"))||void 0===o||o.forEach((function(o){var i=o.source,a=n===i?o.target:i;t.hasNode(a)||void 0===e.getNode(a).data.layer&&Je(e,o)||(t.addNode({id:a,data:{}}),t.addEdge({id:o.id,source:n,target:a,data:{}}),r(a))}))};return t.getAllNodes().forEach((function(t){return r(t.id)})),t.getAllNodes().length},Ze=function(t,e){return $e(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?Je(e,r):1/0}))},tr=function(t,e,r){t.getAllNodes().forEach((function(t){var n=e.getNode(t.id);n.data.rank||(n.data.rank=0),n.data.rank+=r}))},er=function(t,e){var r=He(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){rr(t,e,r)}))},rr=function(t,e,r){var n=t.getNode(r).data.parent;t.getRelatedEdges(r,"both").find((function(t){return t.target===n||t.source===n})).data.cutvalue=nr(t,e,r)},nr=function(t,e,r){var n=t.getNode(r).data.parent,o=!0,i=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),a=0;return i||(o=!1,i=e.getRelatedEdges(n,"out").find((function(t){return t.target===r}))),a=i.data.weight,e.getRelatedEdges(r,"both").forEach((function(e){var i=e.source===r,s=i?e.target:e.source;if(s!==n){var u=i===o,d=e.data.weight;if(a+=u?d:-d,hr(t,r,s)){var h=t.getRelatedEdges(r,"both").find((function(t){return t.source===s||t.target===s})).data.cutvalue;a+=u?-h:h}}})),a},or=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),ir(t,{},1,e)},ir=function(t,e,r,n,o){var i,a=r,s=r,u=t.getNode(n);return e[n]=!0,null===(i=t.getNeighbors(n))||void 0===i||i.forEach((function(r){e[r.id]||(s=ir(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},ar=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},sr=function(t,e,r){var n=r.source,o=r.target;e.getRelatedEdges(n,"out").find((function(t){return t.target===o}))||(n=r.target,o=r.source);var i=t.getNode(n),a=t.getNode(o),s=i,u=!1;i.data.lim>a.data.lim&&(s=a,u=!0);var d=e.getAllEdges().filter((function(e){return u===cr(t.getNode(e.source),s)&&u!==cr(t.getNode(e.target),s)}));return $e(d,(function(t){return Je(e,t)}))},ur=function(t,e,r,n){var o=t.getRelatedEdges(r.source,"both").find((function(t){return t.source===r.target||t.target===r.target}));o&&t.removeEdge(o.id),t.addEdge({id:"e"+Math.random(),source:n.source,target:n.target,data:{}}),or(t),er(t,e),dr(t,e)},dr=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=He(t,r,"pre",!1);(n=n.slice(1)).forEach((function(r){var n=t.getNode(r).data.parent,o=e.getRelatedEdges(r,"out").find((function(t){return t.target===n})),i=!1;!o&&e.hasNode(n)&&(o=e.getRelatedEdges(n,"out").find((function(t){return t.target===r})),i=!0),e.getNode(r).data.rank=(e.hasNode(n)&&e.getNode(n).data.rank||0)+(i?null==o?void 0:o.data.minlen:-(null==o?void 0:o.data.minlen))}))},hr=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},cr=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},lr=Ke,fr=function(t){!function(t){var e=function(t){var e=new l;return t.getAllNodes().forEach((function(t){e.addNode(n({},t))})),t.getAllEdges().forEach((function(t){var r=e.getRelatedEdges(t.source,"out").find((function(e){return e.target===t.target}));r?e.updateEdgeData(null==r?void 0:r.id,n(n({},r.data),{weight:r.data.weight+t.data.weight||0,minlen:Math.max(r.data.minlen,t.data.minlen||1)})):e.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||0,minlen:t.data.minlen||1}})})),e}(t);Ke(e);var r,o,i=function(t){var e,r,n=new l({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Xe(n,t)<i;)e=Ze(n,t),r=n.hasNode(e.source)?Je(t,e):-Je(t,e),tr(n,t,r);return n}(e);for(or(i),er(i,e);r=ar(i);)o=sr(i,e,r),ur(i,e,r,o)}(t)},gr=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=Ge(t,"_bt"),d=Ge(t,"_bb"),h=t.getNode(a);t.setParent(u,a),h.data.borderTop=u,t.setParent(d,a),h.data.borderBottom=d,null==s||s.forEach((function(s){gr(t,e,r,n,o,i,s.id);var h=s.data.borderTop?s.data.borderTop:s.id,c=s.data.borderBottom?s.data.borderBottom:s.id,l=s.data.borderTop?n:2*n,f=h!==c?1:o-i[a]+1;t.addEdge({id:"e"+Math.random(),source:u,target:h,data:{minlen:f,weight:l,nestingEdge:!0}}),t.addEdge({id:"e"+Math.random(),source:c,target:d,data:{minlen:f,weight:l,nestingEdge:!0}})})),t.getParent(a)||t.addEdge({id:"e"+Math.random(),source:e,target:u,data:{weight:0,minlen:o+i[a]}})}else a!==e&&t.addEdge({id:"e"+Math.random(),source:e,target:a,data:{weight:0,minlen:r}})},pr=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=je(t,"border",a,r);o.data[e][i]=u,t.setParent(u,n),s&&t.addEdge({id:"e"+Math.random(),source:s,target:u,data:{weight:1}})},vr=function(t){t.getAllNodes().forEach((function(t){yr(t)})),t.getAllEdges().forEach((function(t){yr(t)}))},yr=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},mr=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},wr=function(t){var e=t.x;t.x=t.y,t.y=e},xr=function(t){for(var e={},r=t.getAllNodes(),n=r.map((function(t){var e;return null!==(e=t.data.rank)&&void 0!==e?e:-1/0})),o=Math.max.apply(Math,u([],s(n))),i=[],a=0;a<o+1;a++)i.push([]);var d=r.sort((function(e,r){return t.getNode(e.id).data.rank-t.getNode(r.id).data.rank})),h=d.filter((function(e){return void 0!==t.getNode(e.id).data.fixorder})).sort((function(e,r){return t.getNode(e.id).data.fixorder-t.getNode(r.id).data.fixorder}));return null==h||h.forEach((function(r){isNaN(t.getNode(r.id).data.rank)||i[t.getNode(r.id).data.rank].push(r.id),e[r.id]=!0})),null==d||d.forEach((function(r){return t.dfsTree(r.id,(function(t){if(e.hasOwnProperty(t.id))return!0;e[t.id]=!0,isNaN(t.data.rank)||i[t.data.rank].push(t.id)}))})),i},Er=function(t,e,r){for(var n=function(t,e){return null==t?void 0:t.reduce((function(t,r,n){return t[r]=e[n],t}),{})}(r,r.map((function(t,e){return e}))),o=e.map((function(e){var r=t.getRelatedEdges(e,"out").map((function(t){return{pos:n[t.target]||0,weight:t.data.weight}}));return null==r?void 0:r.sort((function(t,e){return t.pos-e.pos}))})),i=o.flat().filter((function(t){return void 0!==t})),a=1;a<r.length;)a<<=1;var s=2*a-1;a-=1;var u=Array(s).fill(0,0,s),d=0;return null==i||i.forEach((function(t){if(t){var e=t.pos+a;u[e]+=t.weight;for(var r=0;e>0;)e%2&&(r+=u[e+1]),u[e=e-1>>1]+=t.weight;d+=t.weight*r}})),d},br=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=Er(t,e[n-1],e[n]);return r},Nr=function(t,e){var r,n=0,o=0;t.weight&&(n+=t.barycenter*t.weight,o+=t.weight),e.weight&&(n+=e.barycenter*e.weight,o+=e.weight),t.vs=null===(r=e.vs)||void 0===r?void 0:r.concat(t.vs),t.barycenter=n/o,t.weight=o,t.i=Math.min(e.i,t.i),e.merged=!0};const Mr=function(t,e){var r,n,o,i={};return null==t||t.forEach((function(t,e){i[t.v]={i:e,indegree:0,in:[],out:[],vs:[t.v]};var r=i[t.v];void 0!==t.barycenter&&(r.barycenter=t.barycenter,r.weight=t.weight)})),null===(r=e.getAllEdges())||void 0===r||r.forEach((function(t){var e=i[t.source],r=i[t.target];void 0!==e&&void 0!==r&&(r.indegree++,e.out.push(i[t.target]))})),function(t){for(var e,r,n=[],o=function(){var o=t.pop();n.push(o),null===(e=o.in.reverse())||void 0===e||e.forEach((function(t){return(e=o,function(t){t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&Nr(e,t)})(t);var e})),null===(r=o.out)||void 0===r||r.forEach((function(e){return(r=o,function(e){e.in.push(r),0==--e.indegree&&t.push(e)})(e);var r}))};null==t?void 0:t.length;)o();var i=n.filter((function(t){return!t.merged})),a=["vs","i","barycenter","weight"];return i.map((function(t){var e={};return null==a||a.forEach((function(r){void 0!==t[r]&&(e[r]=t[r])})),e}))}(null===(o=(n=Object.values(i)).filter)||void 0===o?void 0:o.call(n,(function(t){return!t.indegree})))};var Sr=function(t,e,r){for(var n,o=r;e.length&&(n=e[e.length-1]).i<=o;)e.pop(),null==t||t.push(n.vs),o++;return o},kr=function(t,e,r,n,o,i){var a,s,u,d,h=t.getChildren(e).map((function(t){return t.id})),c=t.getNode(e),l=c?c.data.borderLeft:void 0,f=c?c.data.borderRight:void 0,g={};l&&(h=null==h?void 0:h.filter((function(t){return t!==l&&t!==f})));var p=function(t,e){return e.map((function(e){var r=t.getRelatedEdges(e,"in");if(!(null==r?void 0:r.length))return{v:e};var n={sum:0,weight:0};return null==r||r.forEach((function(e){var r=t.getNode(e.source);n.sum+=e.data.weight*r.data.order,n.weight+=e.data.weight})),{v:e,barycenter:n.sum/n.weight,weight:n.weight}}))}(t,h||[]);null==p||p.forEach((function(e){var o;if(null===(o=t.getChildren(e.v))||void 0===o?void 0:o.length){var a=kr(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&_r(e,a)}}));var v=Mr(p,r);Ar(v,g),null===(a=v.filter((function(t){return t.vs.length>0})))||void 0===a||a.forEach((function(e){var r=t.getNode(e.vs[0]);r&&(e.fixorder=r.data.fixorder,e.order=r.data.order)}));var y=function(t,e,r,n){var o=function(t,e){var r={lhs:[],rhs:[]};return null==t||t.forEach((function(t){var e,o;o=(e=t).hasOwnProperty("fixorder")&&!isNaN(e.fixorder),(n?!o&&e.hasOwnProperty("barycenter"):o||e.hasOwnProperty("barycenter"))?r.lhs.push(t):r.rhs.push(t)})),r}(t),i=o.lhs,a=o.rhs.sort((function(t,e){return-t.i- -e.i})),s=[],u=0,d=0,h=0;null==i||i.sort(function(t,e){return function(r,n){if(void 0!==r.fixorder&&void 0!==n.fixorder)return r.fixorder-n.fixorder;if(r.barycenter<n.barycenter)return-1;if(r.barycenter>n.barycenter)return 1;if(e&&void 0!==r.order&&void 0!==n.order){if(r.order<n.order)return-1;if(r.order>n.order)return 1}return t?n.i-r.i:r.i-n.i}}(!!e,!!r)),h=Sr(s,a,h),null==i||i.forEach((function(t){var e;h+=null===(e=t.vs)||void 0===e?void 0:e.length,s.push(t.vs),u+=t.barycenter*t.weight,d+=t.weight,h=Sr(s,a,h)}));var c={vs:s.flat()};return d&&(c.barycenter=u/d,c.weight=d),c}(v,n,o,i);if(l&&(y.vs=[l,y.vs,f].flat(),null===(s=t.getPredecessors(l))||void 0===s?void 0:s.length)){var m=t.getNode((null===(u=t.getPredecessors(l))||void 0===u?void 0:u[0].id)||""),w=t.getNode((null===(d=t.getPredecessors(f))||void 0===d?void 0:d[0].id)||"");y.hasOwnProperty("barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+m.data.order+w.data.order)/(y.weight+2),y.weight+=2}return y},Ar=function(t,e){null==t||t.forEach((function(t){var r,n=null===(r=t.vs)||void 0===r?void 0:r.map((function(t){return e[t]?e[t].vs:t}));t.vs=n.flat()}))},_r=function(t,e){void 0!==t.barycenter?(t.barycenter=(t.barycenter*t.weight+e.barycenter*e.weight)/(t.weight+e.weight),t.weight+=e.weight):(t.barycenter=e.barycenter,t.weight=e.weight)},zr=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):p(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=zr(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=zr(t[i]):e[i]=t[i];return e};const Rr=zr;var Ir=function(t,e,r){return e.map((function(e){return function(t,e,r){var o=function(t){for(var e;t.hasNode(e="_root"+Math.random()););return e}(t),i=new l({tree:[{id:o,children:[],data:{}}]});return t.getAllNodes().forEach((function(a){var s=t.getParent(a.id);(a.data.rank===e||a.data.minRank<=e&&e<=a.data.maxRank)&&(i.hasNode(a.id)||i.addNode(n({},a)),(null==s?void 0:s.id)&&!i.hasNode(null==s?void 0:s.id)&&i.addNode(n({},s)),i.setParent(a.id,(null==s?void 0:s.id)||o),t.getRelatedEdges(a.id,r).forEach((function(e){var r=e.source===a.id?e.target:e.source;i.hasNode(r)||i.addNode(n({},t.getNode(r)));var o=i.getRelatedEdges(r,"out").find((function(t){return t.target===a.id})),s=void 0!==o?o.data.weight:0;o?i.updateEdgeData(o.id,n(n({},o.data),{weight:e.data.weight+s})):i.addEdge({id:e.id,source:r,target:a.id,data:{weight:e.data.weight+s}})})),a.data.hasOwnProperty("minRank")&&i.updateNodeData(a.id,n(n({},a.data),{borderLeft:a.data.borderLeft[e],borderRight:a.data.borderRight[e]})))})),i}(t,e,r)}))},Dr=function(t,e,r,n){var o=new l;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=kr(t,a,o,e,r,n),u=0;u<(null===(i=s.vs)||void 0===i?void 0:i.length);u++){var d=t.getNode(s.vs[u]);d&&(d.data.order=u)}!function(t,e,r){var n,o={};null==r||r.forEach((function(r){for(var i,a,s=t.getParent(r);s;){if((i=t.getParent(s.id))?(a=o[i.id],o[i.id]=s.id):(a=n,n=s.id),a&&a!==s.id)return e.hasNode(a)||e.addNode({id:a,data:{}}),e.hasNode(s.id)||e.addNode({id:s.id,data:{}}),void(e.hasEdge("e"+a+"-"+s.id)||e.addEdge({id:"e"+a+"-"+s.id,source:a,target:s.id,data:{}}));s=i}}))}(t,o,s.vs)}))},Pr=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Or=function(t,e){var r={};function n(e,n,o,i,a){for(var s,u,d,h=n;h<o;h++)d=e[h],(null===(s=t.getNode(d))||void 0===s?void 0:s.data.dummy)&&(null===(u=t.getPredecessors(d))||void 0===u||u.forEach((function(e){var n=t.getNode(e.id);n.data.dummy&&(n.data.order<i||n.data.order>a)&&Cr(r,e.id,d)})))}function o(t,e){var r=function(t){return JSON.stringify(t.slice(1))}(t);e.get(r)||(n.apply(void 0,u([],s(t))),e.set(r,!0))}return(null==e?void 0:e.length)&&e.reduce((function(e,r){var n,i=-1,a=0,s=new Map;return null==r||r.forEach((function(u,d){var h;if("border"===(null===(h=t.getNode(u))||void 0===h?void 0:h.data.dummy)){var c=t.getPredecessors(u)||[];c.length&&(n=t.getNode(c[0].id).data.order,o([r,a,d,i,n],s),a=d,i=n)}o([r,a,r.length,n,e.length],s)})),r})),r},Tr=function(t,e){var r,n;if(null===(r=t.getNode(e))||void 0===r?void 0:r.data.dummy)return null===(n=t.getPredecessors(e))||void 0===n?void 0:n.find((function(e){return t.getNode(e.id).data.dummy}))},Cr=function(t,e,r){var n=e,o=r;if(n>o){var i=n;n=o,o=i}var a=t[n];a||(t[n]=a={}),a[o]=!0},Lr=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},qr=function(t,e,r,o,i,a){var s=new l,u=jr(o,i,a);return null==e||e.forEach((function(e){var o;null==e||e.forEach((function(e){var i=r[e];if(s.hasNode(i)||s.addNode({id:i,data:{}}),o){var a=r[o],d=s.getRelatedEdges(a,"out").find((function(t){return t.target===i}));d?s.updateEdgeData(d.id,n(n({},d.data),{weight:Math.max(u(t,e,o),d.data.weight||0)})):s.addEdge({id:"e"+Math.random(),source:a,target:i,data:{weight:Math.max(u(t,e,o),0)}})}o=e}))})),s};var jr=function(t,e,r){return function(n,o,i){var a=n.getNode(o),s=n.getNode(i),u=0,d=0;if(u+=a.data.width/2,a.data.hasOwnProperty("labelpos"))switch((a.data.labelpos||"").toLowerCase()){case"l":d=-a.data.width/2;break;case"r":d=a.data.width/2}if(d&&(u+=r?d:-d),d=0,u+=(a.data.dummy?e:t)/2,u+=(s.data.dummy?e:t)/2,u+=s.data.width/2,s.data.labelpos)switch((s.data.labelpos||"").toLowerCase()){case"l":d=s.data.width/2;break;case"r":d=-s.data.width/2}return d&&(u+=r?d:-d),d=0,u}},Fr=function(t,e){return t.getNode(e).data.width||0},Vr=function(t,e){var r,n=Fe(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=Be(t),i=0;null==o||o.forEach((function(e){var r=e.map((function(e){return t.getNode(e).data.height})),o=Math.max.apply(Math,u(u([],s(r)),[0]));null==e||e.forEach((function(e){t.getNode(e).data.y=i+o/2})),i+=o+n}))}(n,e);var o=function(t,e){var r=e||{},n=r.align,o=r.nodesep,i=void 0===o?0:o,a=r.edgesep,d=void 0===a?0:a,h=Be(t),c=Object.assign(function(t,e){var r={};return(null==e?void 0:e.length)&&e.reduce((function(e,n){var o=0,i=0,a=e.length,s=null==n?void 0:n[(null==n?void 0:n.length)-1];return null==n||n.forEach((function(e,u){var d,h=Tr(t,e),c=h?t.getNode(h.id).data.order:a;(h||e===s)&&(null===(d=n.slice(i,u+1))||void 0===d||d.forEach((function(e){var n;null===(n=t.getPredecessors(e))||void 0===n||n.forEach((function(n){var i,a=t.getNode(n.id),s=a.data.order;!(s<o||c<s)||a.data.dummy&&(null===(i=t.getNode(e))||void 0===i?void 0:i.data.dummy)||Cr(r,n.id,e)}))})),i=u+1,o=c)})),n})),r}(t,h),Or(t,h)),l={},f=[];["u","d"].forEach((function(e){f="u"===e?h:Object.values(h).reverse(),["l","r"].forEach((function(r){"r"===r&&(f=f.map((function(t){return Object.values(t).reverse()})));var n=("u"===e?t.getPredecessors:t.getSuccessors).bind(t),o=function(t,e,r,n){var o={},i={},a={};return null==e||e.forEach((function(t){null==t||t.forEach((function(t,e){o[t]=t,i[t]=t,a[t]=e}))})),null==e||e.forEach((function(t){var e=-1;null==t||t.forEach((function(t){var s=n(t).map((function(t){return t.id}));if(s.length){s=s.sort((function(t,e){return a[t]-a[e]}));for(var u=(s.length-1)/2,d=Math.floor(u),h=Math.ceil(u);d<=h;++d){var c=s[d];i[t]===t&&e<a[c]&&!Lr(r,t,c)&&(i[c]=t,i[t]=o[t]=o[c],e=a[c])}}}))})),{root:o,align:i}}(0,f,c,n),a=function(t,e,r,n,o,i,a){var s,u={},d=qr(t,e,r,o,i,a),h=a?"borderLeft":"borderRight",c=function(t,e){for(var r=d.getAllNodes(),n=r.pop(),o={};n;)o[n.id]?t(n.id):(o[n.id]=!0,r.push(n),r=r.concat(e(n.id))),n=r.pop()};return c((function(t){u[t]=(d.getRelatedEdges(t,"in")||[]).reduce((function(t,e){return Math.max(t,(u[e.source]||0)+e.data.weight)}),0)}),d.getPredecessors.bind(d)),c((function(e){var r=(d.getRelatedEdges(e,"out")||[]).reduce((function(t,e){return Math.min(t,(u[e.target]||0)-e.data.weight)}),Number.POSITIVE_INFINITY),n=t.getNode(e);r!==Number.POSITIVE_INFINITY&&n.data.borderType!==h&&(u[e]=Math.max(u[e],r))}),d.getSuccessors.bind(d)),null===(s=Object.values(n))||void 0===s||s.forEach((function(t){u[t]=u[r[t]]})),u}(t,f,o.root,o.align,i,d,"r"===r);"r"===r&&Object.keys(a).forEach((function(t){return a[t]=-a[t]})),l[e+r]=a}))}));var g=function(t,e){return $e(Object.values(e),(function(e){var r,n=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;return null===(r=Object.keys(e))||void 0===r||r.forEach((function(r){var i=e[r],a=Fr(t,r)/2;n=Math.max(i+a,n),o=Math.min(i-a,o)})),n-o}))}(t,l);return g&&function(t,e){var r=Object.values(e),n=Math.min.apply(Math,u([],s(r))),o=Math.max.apply(Math,u([],s(r)));["u","d"].forEach((function(r){["l","r"].forEach((function(i){var a,d=r+i,h=t[d];if(h!==e){var c=Object.values(h);(a="l"===i?n-Math.min.apply(Math,u([],s(c))):o-Math.max.apply(Math,u([],s(c))))&&(t[d]={},Object.keys(h).forEach((function(e){t[d][e]=h[e]+a})))}}))}))}(l,g),function(t,e){var r={};return Object.keys(t.ul).forEach((function(n){if(e)r[n]=t[e.toLowerCase()][n];else{var o=Object.values(t).map((function(t){return t[n]}));r[n]=(o[0]+o[1])/2}})),r}(l,n)}(n,e);null===(r=Object.keys(o))||void 0===r||r.forEach((function(t){n.getNode(t).data.x=o[t]}))},Br=function(t,e){var r=e.acyclicer,o=e.ranker,i=e.rankdir,a=void 0===i?"tb":i,d=e.nodeOrder,h=e.keepNodeOrder,c=e.align,f=e.nodesep,g=void 0===f?50:f,p=e.edgesep,v=void 0===p?20:p,y=e.ranksep,m=void 0===y?50:y;rn(t),Le(t,r);var w=function(t){var e=je(t,"root",{},"_root"),r=function(t){var e={},r=function(n,o){var i=t.getChildren(n);null==i||i.forEach((function(t){return r(t.id,o+1)})),e[n]=o};return t.getRoots().forEach((function(t){return r(t.id,1)})),e}(t),n=Math.max.apply(Math,u([],s(Object.values(r))));Math.abs(n)===1/0&&(n=1);var o=n-1,i=2*o+1;t.getAllEdges().forEach((function(t){t.data.minlen*=i}));var a=function(t){var e=0;return t.getAllEdges().forEach((function(t){e+=t.data.weight})),e}(t)+1;return t.getRoots().forEach((function(n){gr(t,e,i,a,o,r,n.id)})),{nestingRoot:e,nodeRankFactor:i}}(t),x=w.nestingRoot,E=w.nodeRankFactor;!function(t,e){switch(e){case"network-simplex":fr(t);break;case"tight-tree":default:!function(t){!function(t){var e,r={},n=function(o){var i,a,s=t.getNode(o);return s?r[o]?s.data.rank:(r[o]=!0,null===(i=t.getRelatedEdges(o,"out"))||void 0===i||i.forEach((function(t){var e=n(t.target)-t.data.minlen;e&&(void 0===a||e<a)&&(a=e)})),a||(a=0),(void 0===e||a<e)&&(e=a),s.data.rank=a,a):0};t.getAllNodes().filter((function(e){return 0===t.getRelatedEdges(e.id,"in").length})).forEach((function(t){t&&n(t.id)})),void 0===e&&(e=0);var o={},i=function(e,r){var n,a=t.getNode(e),s=isNaN(a.data.layer)?r:a.data.layer;(void 0===a.data.rank||a.data.rank<s)&&(a.data.rank=s),o[e]||(o[e]=!0,null===(n=t.getRelatedEdges(e,"out"))||void 0===n||n.forEach((function(t){i(t.target,s+t.data.minlen)})))};t.getAllNodes().forEach((function(t){var r=t.data;r&&(isNaN(r.layer)?r.rank-=e:i(t.id,r.layer))}))}(t),function(t){var e,r,n=new l({tree:[]}),o=t.getAllNodes()[0],i=t.getAllNodes().length;for(n.addNode(o);Qe(n,t)<i;)e=Ze(n,t),r=n.hasNode(e.source)?Je(t,e):-Je(t,e),tr(n,t,r)}(t)}(t);break;case"longest-path":lr(t)}}(Fe(t),o),Yr(t),function(t,e){void 0===e&&(e=0);var r=t.getAllNodes(),n=r.filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),o=Math.min.apply(Math,u([],s(n))),i=[];r.forEach((function(t){var e=(t.data.rank||0)-o;i[e]||(i[e]=[]),i[e].push(t.id)}));for(var a=0,d=0;d<i.length;d++){var h=i[d];void 0===h?d%e!=0&&(a-=1):a&&(null==h||h.forEach((function(e){var r=t.getNode(e);r&&(r.data.rank=r.data.rank||0,r.data.rank+=a)})))}}(t,E),function(t,e){e&&t.removeNode(e),t.getAllEdges().forEach((function(e){e.data.nestingEdge&&t.removeEdge(e.id)}))}(t,x),function(t){var e=t.getAllNodes().filter((function(t){return void 0!==t.data.rank})).map((function(t){return t.data.rank})),r=Math.min.apply(Math,u([],s(e)));t.getAllNodes().forEach((function(t){t.data.hasOwnProperty("rank")&&r!==1/0&&(t.data.rank-=r)}))}(t),Kr(t),Jr(t);var b=[];!function(t,e){t.getAllEdges().forEach((function(r){return function(t,e,r){var n=e.source,o=t.getNode(n).data.rank,i=e.target,a=t.getNode(i).data.rank,s=e.data.labelRank;if(a!==o+1){var u,d,h;for(t.removeEdge(e.id),h=0,++o;o<a;++h,++o)e.data.points=[],u=je(t,"edge",d={originalEdge:e,width:0,height:0,rank:o},"_d"),o===s&&(d.width=e.data.width,d.height=e.data.height,d.dummy=Ye,d.labelpos=e.data.labelpos),t.addEdge({id:"e"+Math.random(),source:n,target:u,data:{weight:e.data.weight}}),0===h&&r.push(u),n=u;t.addEdge({id:"e"+Math.random(),source:n,target:i,data:{weight:e.data.weight}})}}(t,r,e)}))}(t,b),function(t,e){var r=function(t){var e={},r=0,n=function(o){var i=r;t.getChildren(o).forEach((function(t){return n(t.id)})),e[o]={low:i,lim:r++}};return t.getRoots().forEach((function(t){return n(t.id)})),e}(t);e.forEach((function(e){var n,o,i=e,a=t.getNode(i),s=a.data.originalEdge;if(s)for(var u=function(t,e,r,n){var o,i,a,s,u=[],d=[],h=Math.min(e[r].low,e[n].low),c=Math.max(e[r].lim,e[n].lim);a=r;do{a=null===(o=t.getParent(a))||void 0===o?void 0:o.id,u.push(a)}while(a&&(e[a].low>h||c>e[a].lim));for(s=a,a=n;a&&a!==s;)d.push(a),a=null===(i=t.getParent(a))||void 0===i?void 0:i.id;return{lca:s,path:u.concat(d.reverse())}}(t,r,s.source,s.target),d=u.path,h=u.lca,c=0,l=d[c],f=!0;i!==s.target;){if(a=t.getNode(i),f){for(;l!==h&&(null===(n=t.getNode(l))||void 0===n?void 0:n.data.maxRank)<a.data.rank;)l=d[++c];l===h&&(f=!1)}if(!f){for(;c<d.length-1&&(null===(o=t.getNode(d[c+1]))||void 0===o?void 0:o.data.minRank)<=a.data.rank;)c++;l=d[c]}t.hasNode(l)&&t.setParent(i,l),i=t.getSuccessors(i)[0].id}}))}(t,b),function(t){var e=function(r){var n=t.getChildren(r),o=t.getNode(r);if((null==n?void 0:n.length)&&n.forEach((function(t){return e(t.id)})),o.data.hasOwnProperty("minRank")){o.data.borderLeft=[],o.data.borderRight=[];for(var i=o.data.minRank,a=o.data.maxRank+1;i<a;i+=1)pr(t,"borderLeft","_bl",r,o,i),pr(t,"borderRight","_br",r,o,i)}};t.getRoots().forEach((function(t){return e(t.id)}))}(t),h&&function(t,e){for(var r=t.getAllNodes().filter((function(e){var r;return!(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length)})).map((function(t){return t.data.rank})),n=Math.max.apply(Math,u([],s(r))),o=[],i=0;i<n+1;i++)o[i]=[];null==e||e.forEach((function(e){var r=t.getNode(e);r&&!r.data.dummy&&(isNaN(r.data.rank)||(r.data.fixorder=o[r.data.rank].length,o[r.data.rank].push(e)))}))}(t,d),function(t,e){for(var r=We(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=Ir(t,n,"in"),s=Ir(t,o,"out"),u=xr(t);Pr(t,u);for(var d,h=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)Dr(i%2?a:s,i%4>=2,!1,e),u=Be(t),(l=br(t,u))<h&&(c=0,d=Rr(u),h=l);for(u=xr(t),Pr(t,u),i=0,c=0;c<4;++i,++c){var l;Dr(i%2?a:s,i%4>=2,!0,e),u=Be(t),(l=br(t,u))<h&&(c=0,d=Rr(u),h=l)}Pr(t,d)}(t,h),nn(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||vr(t)}(t,a),Vr(t,{align:c,nodesep:g,edgesep:v,ranksep:m}),on(t),en(t),function(t,e){e.forEach((function(e){var r,n=t.getNode(e),o=n.data.originalEdge;o&&t.addEdge(o);for(var i=e;n.data.dummy;)r=t.getSuccessors(i)[0],t.removeNode(i),o.data.points.push({x:n.data.x,y:n.data.y}),n.data.dummy===Ye&&(o.data.x=n.data.x,o.data.y=n.data.y,o.data.width=n.data.width,o.data.height=n.data.height),i=r.id,n=t.getNode(i)}))}(t,b),Zr(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){mr(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return mr(t)})),t.data.hasOwnProperty("y")&&mr(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){wr(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return wr(t)})),t.data.hasOwnProperty("x")&&wr(t.data)}))}(t),vr(t))}(t,a);var N=Xr(t),M=N.width,S=N.height;return Qr(t),tn(t),function(t){t.getAllEdges().forEach((function(e){var r=e.data;if(r.reversed){t.removeEdge(e.id);var o=r.forwardName;delete r.reversed,delete r.forwardName,t.addEdge({id:e.id,source:e.target,target:e.source,data:n(n({},r),{forwardName:o})})}}))}(t),{width:M,height:S}},Gr=["width","height","layer","fixorder"],Wr={width:0,height:0},$r=["minlen","weight","width","height","labeloffset"],Ur={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Hr=["labelpos"],Yr=function(t){t.getAllEdges().forEach((function(e){if(e.data.width&&e.data.height){var r=t.getNode(e.source),n={e,rank:(t.getNode(e.target).data.rank-r.data.rank)/2+r.data.rank};je(t,"edge-proxy",n,"_ep")}}))},Kr=function(t){var e=0;return t.getAllNodes().forEach((function(r){var n,o;r.data.borderTop&&(r.data.minRank=null===(n=t.getNode(r.data.borderTop))||void 0===n?void 0:n.data.rank,r.data.maxRank=null===(o=t.getNode(r.data.borderBottom))||void 0===o?void 0:o.data.rank,e=Math.max(e,r.data.maxRank||-1/0))})),e},Jr=function(t){t.getAllNodes().forEach((function(e){"edge-proxy"===e.data.dummy&&(t.getEdge(e.data.e.id).data.labelRank=e.data.rank,t.removeNode(e.id))}))},Xr=function(t,e){var r,n,o=0,i=0,a=e||{},s=a.marginx,u=void 0===s?0:s,d=a.marginy,h=void 0===d?0:d,c=function(t){if(t.data){var e=t.data.x,a=t.data.y,s=t.data.width,u=t.data.height;isNaN(e)||isNaN(s)||(void 0===r&&(r=e-s/2),r=Math.min(r,e-s/2),o=Math.max(o,e+s/2)),isNaN(a)||isNaN(u)||(void 0===n&&(n=a-u/2),n=Math.min(n,a-u/2),i=Math.max(i,a+u/2))}};return t.getAllNodes().forEach((function(t){c(t)})),t.getAllEdges().forEach((function(t){(null==t?void 0:t.data.hasOwnProperty("x"))&&c(t)})),r-=u,n-=h,t.getAllNodes().forEach((function(t){t.data.x-=r,t.data.y-=n})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){t.x-=r,t.y-=n})),t.data.hasOwnProperty("x")&&(t.data.x-=r),t.data.hasOwnProperty("y")&&(t.data.y-=n)})),{width:o-r+u,height:i-n+h}},Qr=function(t){t.getAllEdges().forEach((function(e){var r,n,o=t.getNode(e.source),i=t.getNode(e.target);e.data.points?(r=e.data.points[0],n=e.data.points[e.data.points.length-1]):(e.data.points=[],r={x:i.data.x,y:i.data.y},n={x:o.data.x,y:o.data.y}),e.data.points.unshift(Ve(o.data,r)),e.data.points.push(Ve(i.data,n))}))},Zr=function(t){t.getAllEdges().forEach((function(t){if(t.data.hasOwnProperty("x"))switch("l"!==t.data.labelpos&&"r"!==t.data.labelpos||(t.data.width-=t.data.labeloffset),t.data.labelpos){case"l":t.data.x-=t.data.width/2+t.data.labeloffset;break;case"r":t.data.x+=t.data.width/2+t.data.labeloffset}}))},tn=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},en=function(t){t.getAllNodes().forEach((function(e){var r,n,o;if(null===(r=t.getChildren(e.id))||void 0===r?void 0:r.length){var i=t.getNode(e.id),a=t.getNode(i.data.borderTop),s=t.getNode(i.data.borderBottom),u=t.getNode(i.data.borderLeft[(null===(n=i.data.borderLeft)||void 0===n?void 0:n.length)-1]),d=t.getNode(i.data.borderRight[(null===(o=i.data.borderRight)||void 0===o?void 0:o.length)-1]);i.data.width=Math.abs((null==d?void 0:d.data.x)-(null==u?void 0:u.data.x))||10,i.data.height=Math.abs((null==s?void 0:s.data.y)-(null==a?void 0:a.data.y))||10,i.data.x=((null==u?void 0:u.data.x)||0)+i.data.width/2,i.data.y=((null==a?void 0:a.data.y)||0)+i.data.height/2}})),t.getAllNodes().forEach((function(e){"border"===e.data.dummy&&t.removeNode(e.id)}))},rn=function(t){t.getAllEdges().forEach((function(e){if(e.source===e.target){var r=t.getNode(e.source);r.data.selfEdges||(r.data.selfEdges=[]),r.data.selfEdges.push(e),t.removeEdge(e.id)}}))},nn=function(t){var e=Be(t);null==e||e.forEach((function(e){var r=0;null==e||e.forEach((function(e,n){var o,i=t.getNode(e);i.data.order=n+r,null===(o=i.data.selfEdges)||void 0===o||o.forEach((function(e){je(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},on=function(t){t.getAllNodes().forEach((function(e){var r=t.getNode(e.id);if("selfedge"===r.data.dummy){var n=t.getNode(r.data.e.source),o=n.data.x+n.data.width/2,i=n.data.y,a=r.data.x-o,s=n.data.height/2;t.hasEdge(r.data.e.id)?t.updateEdgeData(r.data.e.id,r.data.e.data):t.addEdge({id:r.data.e.id,source:r.data.e.source,target:r.data.e.target,data:r.data.e.data}),t.removeNode(e.id),r.data.e.data.points=[{x:o+2*a/3,y:i-s},{x:o+5*a/6,y:i-s},{y:i,x:o+a},{x:o+5*a/6,y:i+s},{x:o+2*a/3,y:i+s}],r.data.e.data.x=r.data.x,r.data.e.data.y=r.data.y}}))},an=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},sn=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},un={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,ranker:"tight-tree",controlPoints:!1,radial:!1,focusNode:null},dn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.options=n(n({},un),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericDagreLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return[4,this.genericDagreLayout(!0,t,e)];case 1:return r.sent(),[2]}}))}))},t.prototype.genericDagreLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,f,g,p,y,w,E,N,M,S,k,A,_,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U;return a(this,(function(a){return o=n(n({},this.options),r),i=o.nodeSize,s=o.align,u=o.rankdir,d=void 0===u?"TB":u,h=o.ranksep,c=o.nodesep,f=o.ranksepFunc,g=o.nodesepFunc,p=o.edgeLabelSpace,y=o.ranker,w=o.nodeOrder,E=o.begin,N=o.controlPoints,M=o.radial,S=o.sortByCombo,k=o.preset,A=new l({tree:[]}),_=m(h||50,f),z=m(c||50,g),R=z,I=_,"LR"!==d&&"RL"!==d||(R=_,I=z),D=x(i,void 0),P=e.getAllNodes(),O=e.getAllEdges(),P.forEach((function(t){var e=D(t),r=I(t),n=e+2*R(t),o=e+2*r,i=t.data.layer;v(i)?A.addNode({id:t.id,data:{width:n,height:o,layer:i}}):A.addNode({id:t.id,data:{width:n,height:o}})})),S&&(A.attachTreeStructure("combo"),P.forEach((function(t){var e=t.data.parentId;void 0!==e&&A.hasNode(e)&&A.setParent(t.id,e,"combo")}))),O.forEach((function(t){A.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),T=void 0,(null==k?void 0:k.length)&&(T=new l({nodes:k})),function(t,e){var r,o,i=e.edgeLabelSpace,a=e.keepNodeOrder,s=e.prevGraph,u=e.rankdir,d=e.ranksep;!a&&s&&(o=s,(r=t).getAllNodes().forEach((function(t){var e=r.getNode(t.id);if(o.hasNode(t.id)){var n=o.getNode(t.id);e.data.fixorder=n.data._order,delete n.data._order}else delete e.data.fixorder})));var h=function(t){var e=new l({tree:[]});return t.getAllNodes().forEach((function(r){var o=sn(t.getNode(r.id).data),i=n(n({},Wr),o),a=an(i,Gr);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=t.hasTreeStructure("combo")?t.getParent(r.id,"combo"):t.getParent(r.id);null==s||(e.hasNode(s.id)||e.addNode(n({},s)),e.setParent(r.id,s.id))})),t.getAllEdges().forEach((function(r){var n=sn(t.getEdge(r.id).data),o={};null==Hr||Hr.forEach((function(t){void 0!==n[t]&&(o[t]=n[t])})),e.addEdge({id:r.id,source:r.source,target:r.target,data:Object.assign({},Ur,an(n,$r),o)})})),e}(t);i&&(e.ranksep=function(t,e){var r=e.ranksep,n=void 0===r?0:r,o=e.rankdir;return t.getAllNodes().forEach((function(t){isNaN(t.data.layer)||t.data.layer||(t.data.layer=0)})),t.getAllEdges().forEach((function(t){var e;t.data.minlen*=2,"c"!==(null===(e=t.data.labelpos)||void 0===e?void 0:e.toLowerCase())&&("TB"===o||"BT"===o?t.data.width+=t.data.labeloffset:t.data.height+=t.data.labeloffset)})),n/2}(h,{rankdir:u,ranksep:d}));try{Br(h,e)}catch(t){if("Not possible to find intersection inside of the rectangle"===t.message)return void console.error("The following error may be caused by improper layer setting, please make sure your manual layer setting does not violate the graph's structure:\n",t);throw t}!function(t,e){t.getAllNodes().forEach((function(r){var n,o=t.getNode(r.id);if(o){var i=e.getNode(r.id);o.data.x=i.data.x,o.data.y=i.data.y,o.data._order=i.data.order,o.data._rank=i.data.rank,(null===(n=e.getChildren(r.id))||void 0===n?void 0:n.length)&&(o.data.width=i.data.width,o.data.height=i.data.height)}})),t.getAllEdges().forEach((function(r){var n=t.getEdge(r.id),o=e.getEdge(r.id);n.data.points=o?o.data.points:[],o&&o.data.hasOwnProperty("x")&&(n.data.x=o.data.x,n.data.y=o.data.y)}))}(t,h)}(A,{prevGraph:T,edgeLabelSpace:p,keepNodeOrder:!!w,nodeOrder:w||[],acyclicer:"greedy",ranker:y,rankdir:d,nodesep:c,align:s}),C=[0,0],E&&(L=1/0,q=1/0,A.getAllNodes().forEach((function(t){L>t.data.x&&(L=t.data.x),q>t.data.y&&(q=t.data.y)})),A.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){L>t.x&&(L=t.x),q>t.y&&(q=t.y)}))})),C[0]=E[0]-L,C[1]=E[1]-q),j="LR"===d||"RL"===d,M||(F=new Set,V="BT"===d||"RL"===d?function(t,e){return e-t}:function(t,e){return t-e},A.getAllNodes().forEach((function(t){t.data.x=t.data.x+C[0],t.data.y=t.data.y+C[1],F.add(j?t.data.x:t.data.y)})),B=Array.from(F).sort(V),G=j?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},W=j?function(t,e,r){var n=Math.max(e.y,r.y),o=Math.min(e.y,r.y);return t.filter((function(t){return t.y<=n&&t.y>=o}))}:function(t,e,r){var n=Math.max(e.x,r.x),o=Math.min(e.x,r.x);return t.filter((function(t){return t.x<=n&&t.x>=o}))},A.getAllEdges().forEach((function(t,e){var r;p&&N&&"loop"!==t.data.type&&(t.data.controlPoints=hn(null===(r=t.data.points)||void 0===r?void 0:r.map((function(t){var e=t.x,r=t.y;return{x:e+C[0],y:r+C[1]}})),A.getNode(t.source),A.getNode(t.target),B,j,G,W))}))),$=[],$=A.getAllNodes().map((function(t){return b(t)})),U=A.getAllEdges(),t&&($.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),U.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:$,edges:U}]}))}))},t}(),hn=function(t,e,r,n,o,i,a){var s=(null==t?void 0:t.slice(1,t.length-1))||[];if(e&&r){var u=e.data,d=u.x,h=u.y,c=r.data,l=c.x,f=c.y;if(o&&(d=e.data.y,h=e.data.x,l=r.data.y,f=r.data.x),f!==h&&d!==l){var g=n.indexOf(h),p=n[g+1];if(p){var v=s[0],y=o?{x:(h+p)/2,y:(null==v?void 0:v.y)||l}:{x:(null==v?void 0:v.x)||l,y:(h+p)/2};v&&!i(v,y)||s.unshift(y)}var m=n.indexOf(f),w=Math.abs(m-g);if(1===w)(s=a(s,e.data,r.data)).length||s.push(o?{x:(h+f)/2,y:d}:{x:d,y:(h+f)/2});else if(w>1){var x=n[m-1];if(x){var E=s[s.length-1],b=o?{x:(f+x)/2,y:(null==E?void 0:E.y)||l}:{x:(null==E?void 0:E.x)||d,y:(f+x)/2};E&&!i(E,b)||s.push(b)}}}}return s},cn=function(){function t(t){this.id=t.id||0,this.rx=t.rx,this.ry=t.ry,this.fx=0,this.fy=0,this.mass=t.mass,this.degree=t.degree,this.g=t.g||0}return t.prototype.distanceTo=function(t){var e=this.rx-t.rx,r=this.ry-t.ry;return Math.hypot(e,r)},t.prototype.setPos=function(t,e){this.rx=t,this.ry=e},t.prototype.resetForce=function(){this.fx=0,this.fy=0},t.prototype.addForce=function(t){var e=t.rx-this.rx,r=t.ry-this.ry,n=Math.hypot(e,r);n=n<1e-4?1e-4:n;var o=this.g*(this.degree+1)*(t.degree+1)/n;this.fx+=o*e/n,this.fy+=o*r/n},t.prototype.in=function(t){return t.contains(this.rx,this.ry)},t.prototype.add=function(e){var r=this.mass+e.mass;return new t({rx:(this.rx*this.mass+e.rx*e.mass)/r,ry:(this.ry*this.mass+e.ry*e.mass)/r,mass:r,degree:this.degree+e.degree})},t}();const ln=cn;const fn=function(){function t(t){this.xmid=t.xmid,this.ymid=t.ymid,this.length=t.length,this.massCenter=t.massCenter||[0,0],this.mass=t.mass||1}return t.prototype.getLength=function(){return this.length},t.prototype.contains=function(t,e){var r=this.length/2;return t<=this.xmid+r&&t>=this.xmid-r&&e<=this.ymid+r&&e>=this.ymid-r},t.prototype.NW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.NE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid+this.length/4,length:this.length/2})},t.prototype.SW=function(){return new t({xmid:this.xmid-this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t.prototype.SE=function(){return new t({xmid:this.xmid+this.length/4,ymid:this.ymid-this.length/4,length:this.length/2})},t}(),gn=function(){function t(t){this.body=null,this.quad=null,this.NW=null,this.NE=null,this.SW=null,this.SE=null,this.theta=.5,null!=t&&(this.quad=t)}return t.prototype.insert=function(e){null!=this.body?this._isExternal()?(this.quad&&(this.NW=new t(this.quad.NW()),this.NE=new t(this.quad.NE()),this.SW=new t(this.quad.SW()),this.SE=new t(this.quad.SE())),this._putBody(this.body),this._putBody(e),this.body=this.body.add(e)):(this.body=this.body.add(e),this._putBody(e)):this.body=e},t.prototype._putBody=function(t){this.quad&&(t.in(this.quad.NW())&&this.NW?this.NW.insert(t):t.in(this.quad.NE())&&this.NE?this.NE.insert(t):t.in(this.quad.SW())&&this.SW?this.SW.insert(t):t.in(this.quad.SE())&&this.SE&&this.SE.insert(t))},t.prototype._isExternal=function(){return null==this.NW&&null==this.NE&&null==this.SW&&null==this.SE},t.prototype.updateForce=function(t){null!=this.body&&t!==this.body&&(this._isExternal()||(this.quad?this.quad.getLength():0)/this.body.distanceTo(t)<this.theta?t.addForce(this.body):(this.NW&&this.NW.updateForce(t),this.NE&&this.NE.updateForce(t),this.SW&&this.SW.updateForce(t),this.SE&&this.SE.updateForce(t)))},t}();var pn,vn={center:[0,0],width:300,height:300,kr:5,kg:1,mode:"normal",preventOverlap:!1,dissuadeHubs:!1,maxIteration:0,ks:.1,ksmax:10,tao:.1},yn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},vn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericForceAtlas2Layout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericForceAtlas2Layout(!0,t,e),[2]}))}))},t.prototype.genericForceAtlas2Layout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,f,g,p,v,y,m,w,x,E,M,S,k,A,_,z;return a(this,(function(a){if(o=e.getAllEdges(),i=e.getAllNodes(),s=this.formatOptions(r,i.length),u=s.width,d=s.height,h=s.prune,c=s.maxIteration,f=s.nodeSize,g=s.center,!(null==i?void 0:i.length)||1===i.length)return[2,N(e,t,g)];if(p=i.map((function(t){return b(t,[u,d])})),v=o.filter((function(t){return t.source!==t.target})),y=new l({nodes:p,edges:v}),m=this.getSizes(y,e,f),this.run(y,e,c,m,t,s),h){for(w=0;w<v.length;w+=1)x=v[w],E=x.source,M=x.target,S=y.getDegree(E),k=y.getDegree(E),S<=1?(A=y.getNode(M),y.mergeNodeData(E,{x:A.data.x,y:A.data.y})):k<=1&&(_=y.getNode(E),y.mergeNodeData(M,{x:_.data.x,y:_.data.y}));z=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,z)}return[2,{nodes:p,edges:o}]}))}))},t.prototype.getSizes=function(t,e,r){for(var n=t.getAllNodes(),o={},i=0;i<n.length;i+=1){var a=n[i],d=a.id,h=a.data;if(o[d]=10,v(h.size))o[d]=h.size;else if(_(h.size))isNaN(h.size[0])||(o[d]=Math.max(h.size[0])),isNaN(h.size[1])||(o[d]=Math.max(h.size[1]));else if(y(h.size))o[d]=Math.max(h.size.width,h.size.height);else if(f(r)){var c=r(e.getNode(d));_(c)?o[d]=Math.max.apply(Math,u([],s(c))):o[d]=c}else _(r)?o[d]=Math.max.apply(Math,u([],s(r))):v(r)&&(o[d]=r)}return o},t.prototype.formatOptions=function(t,e){void 0===t&&(t={});var r=n(n({},this.options),t),o=r.center,i=r.width,a=r.height,s=r.barnesHut,u=r.prune,d=r.maxIteration,h=r.kr,c=r.kg;return r.width=i||"undefined"==typeof window?i:window.innerWidth,r.height=a||"undefined"==typeof window?a:window.innerHeight,r.center=o||[r.width/2,r.height/2],void 0===s&&e>250&&(r.barnesHut=!0),void 0===u&&e>100&&(r.prune=!0),0!==d||u?0===d&&u&&(r.maxIteration=100,e<=200&&e>100?r.maxIteration=500:e>200&&(r.maxIteration=950)):(r.maxIteration=250,e<=200&&e>100?r.maxIteration=1e3:e>200&&(r.maxIteration=1200)),h||(r.kr=50,e>100&&e<=500?r.kr=20:e>500&&(r.kr=1)),c||(r.kg=20,e>100&&e<=500?r.kg=10:e>500&&(r.kg=1)),r},t.prototype.run=function(t,e,r,n,o,i){for(var a=i.kr,s=i.barnesHut,u=i.onTick,d=t.getAllNodes(),h=0,c=r,l={},f={},g={},p=0;p<d.length;p+=1){var v=d[p],y=v.data,m=v.id;if(l[m]=[0,0],s){var w={id:p,rx:y.x,ry:y.y,mass:1,g:a,degree:t.getDegree(m)};g[m]=new ln(w)}}for(;c>0;)h=this.oneStep(t,{iter:c,preventOverlapIters:50,krPrime:100,sg:h,forces:l,preForces:f,bodies:g,sizes:n},i),c--,null==u||u({nodes:d,edges:e.getAllEdges()});return t},t.prototype.oneStep=function(t,e,r){for(var n=e.iter,o=e.preventOverlapIters,i=e.krPrime,a=e.sg,d=e.preForces,h=e.bodies,c=e.sizes,l=e.forces,f=r.preventOverlap,g=r.barnesHut,p=t.getAllNodes(),v=0;v<p.length;v+=1){var y=p[v].id;d[y]=u([],s(l[y])),l[y]=[0,0]}return l=this.getAttrForces(t,n,o,c,l,r),l=g&&(f&&n>o||!f)?this.getOptRepGraForces(t,l,h,r):this.getRepGraForces(t,n,o,l,i,c,r),this.updatePos(t,l,d,a,r)},t.prototype.getAttrForces=function(t,e,r,n,o,i){for(var a=i.preventOverlap,s=i.dissuadeHubs,u=i.mode,d=i.prune,h=t.getAllEdges(),c=0;c<h.length;c+=1){var l=h[c],f=l.source,g=l.target,p=t.getNode(f),v=t.getNode(g),y=t.getDegree(f),m=t.getDegree(g);if(!d||!(y<=1||m<=1)){var w=[v.data.x-p.data.x,v.data.y-p.data.y],x=Math.hypot(w[0],w[1]);x=x<1e-4?1e-4:x,w[0]=w[0]/x,w[1]=w[1]/x,a&&e<r&&(x=x-n[f]-n[g]);var E=x,b=E;"linlog"===u&&(b=E=Math.log(1+x)),s&&(E=x/y,b=x/m),a&&e<r&&x<=0?(E=0,b=0):a&&e<r&&x>0&&(E=x,b=x),o[f][0]+=E*w[0],o[g][0]-=b*w[0],o[f][1]+=E*w[1],o[g][1]-=b*w[1]}}return o},t.prototype.getOptRepGraForces=function(t,e,r,n){for(var o=n.kg,i=n.center,a=n.prune,s=t.getAllNodes(),u=s.length,d=9e10,h=-9e10,c=9e10,l=-9e10,f=0;f<u;f+=1){var g=s[f],p=g.id,v=g.data;a&&t.getDegree(p)<=1||(r[p].setPos(v.x,v.y),v.x>=h&&(h=v.x),v.x<=d&&(d=v.x),v.y>=l&&(l=v.y),v.y<=c&&(c=v.y))}var y=Math.max(h-d,l-c),m=new fn({xmid:(h+d)/2,ymid:(l+c)/2,length:y,massCenter:i,mass:u}),w=new gn(m);for(f=0;f<u;f+=1)p=s[f].id,a&&t.getDegree(p)<=1||r[p].in(m)&&w.insert(r[p]);for(f=0;f<u;f+=1){var x=s[f],E=(p=x.id,v=x.data,t.getDegree(p));if(!(a&&E<=1)){r[p].resetForce(),w.updateForce(r[p]),e[p][0]-=r[p].fx,e[p][1]-=r[p].fy;var b=[v.x-i[0],v.y-i[1]],N=Math.hypot(b[0],b[1]);N=N<1e-4?1e-4:N,b[0]=b[0]/N,b[1]=b[1]/N;var M=o*(E+1);e[p][0]-=M*b[0],e[p][1]-=M*b[1]}}return e},t.prototype.getRepGraForces=function(t,e,r,n,o,i,a){for(var s=a.preventOverlap,u=a.kr,d=a.kg,h=a.center,c=a.prune,l=t.getAllNodes(),f=l.length,g=0;g<f;g+=1){for(var p=l[g],v=t.getDegree(p.id),y=g+1;y<f;y+=1){var m=l[y],w=t.getDegree(m.id);if(!c||!(v<=1||w<=1)){var x=[m.data.x-p.data.x,m.data.y-p.data.y],E=Math.hypot(x[0],x[1]);E=E<1e-4?1e-4:E,x[0]=x[0]/E,x[1]=x[1]/E,s&&e<r&&(E=E-i[p.id]-i[m.id]);var b=u*(v+1)*(w+1)/E;s&&e<r&&E<0?b=o*(v+1)*(w+1):s&&e<r&&0===E?b=0:s&&e<r&&E>0&&(b=u*(v+1)*(w+1)/E),n[p.id][0]-=b*x[0],n[m.id][0]+=b*x[0],n[p.id][1]-=b*x[1],n[m.id][1]+=b*x[1]}}var N=[p.data.x-h[0],p.data.y-h[1]],M=Math.hypot(N[0],N[1]);N[0]=N[0]/M,N[1]=N[1]/M;var S=d*(v+1);n[p.id][0]-=S*N[0],n[p.id][1]-=S*N[1]}return n},t.prototype.updatePos=function(t,e,r,n,o){for(var i=o.ks,a=o.tao,s=o.prune,u=o.ksmax,d=t.getAllNodes(),h=d.length,c=[],l=[],f=0,g=0,p=n,y=0;y<h;y+=1){var m=d[y].id,w=t.getDegree(m);if(!(s&&w<=1)){var x=[e[m][0]-r[m][0],e[m][1]-r[m][1]],E=Math.hypot(x[0],x[1]),b=[e[m][0]+r[m][0],e[m][1]+r[m][1]],N=Math.hypot(b[0],b[1]);c[y]=E,l[y]=N/2,f+=(w+1)*c[y],g+=(w+1)*l[y]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),y=0;y<h;y+=1){var S=d[y],k=(m=S.id,S.data);if(w=t.getDegree(m),!(s&&w<=1||v(k.fx)&&v(k.fy))){var A=i*p/(1+p*Math.sqrt(c[y])),_=Math.hypot(e[m][0],e[m][1]),z=u/(_=_<1e-4?1e-4:_),R=(A=A>z?z:A)*e[m][0],I=A*e[m][1];t.mergeNodeData(m,{x:k.x+R,y:k.y+I})}}return p},t}(),mn={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},wn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},mn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericFruchtermanLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericFruchtermanLayout(!0,t,e),[2]}))}))},t.prototype.stop=function(){this.timeInterval&&"undefined"!=typeof window&&window.clearInterval(this.timeInterval),this.running=!1},t.prototype.tick=function(t){var e=this;if(void 0===t&&(t=this.options.maxIteration||1),this.lastResult)return this.lastResult;for(var r=0;r<t;r++)this.runOneStep(this.lastGraph,this.lastClusterMap,this.lastOptions);var n={nodes:this.lastLayoutNodes,edges:this.lastLayoutEdges};return this.lastAssign&&n.nodes.forEach((function(t){return e.lastGraph.mergeNodeData(t.id,{x:t.data.x,y:t.data.y,z:3===e.options.dimensions?t.data.z:void 0})})),n},t.prototype.genericFruchtermanLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,f,g,p,v,y,m,w,x,E,N=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.dimensions,s=o.width,u=o.height,d=o.center,h=o.clustering,c=o.nodeClusterBy,f=o.maxIteration,g=o.onTick,p=e.getAllNodes(),v=e.getAllEdges(),(null==p?void 0:p.length)?1===p.length?(t&&e.mergeNodeData(p[0].id,{x:d[0],y:d[1],z:3===i?d[2]:void 0}),y={nodes:[n(n({},p[0]),{data:n(n({},p[0].data),{x:d[0],y:d[1],z:3===i?d[2]:void 0})})],edges:v},this.lastResult=y,[2,y]):(m=p.map((function(t){return b(t,[s,u])})),w=new l({nodes:m,edges:v}),x={},h&&m.forEach((function(t){var e=t.data[c];x[e]||(x[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=m,this.lastLayoutEdges=v,this.lastAssign=t,this.lastGraph=w,this.lastOptions=o,this.lastClusterMap=x,"undefined"==typeof window?[2]:(E=0,[2,new Promise((function(r){N.timeInterval=window.setInterval((function(){N.running?(N.runOneStep(w,x,o),t&&m.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y,z:3===i?n.z:void 0})})),null==g||g({nodes:m,edges:v}),++E>=f&&(window.clearInterval(N.timeInterval),r({nodes:m,edges:v}))):r({nodes:m,edges:v})}),0),N.running=!0}))])):(y={nodes:[],edges:v},this.lastResult=y,[2,y]))}))}))},t.prototype.formatOptions=function(t){void 0===t&&(t={});var e=n(n({},this.options),t),r=e.clustering,o=e.nodeClusterBy,i=e.center,a=e.width,s=e.height;return e.width=a||"undefined"==typeof window?a:window.innerWidth,e.height=s||"undefined"==typeof window?s:window.innerHeight,e.center=i||[e.width/2,e.height/2],e.clustering=r&&!!o,e},t.prototype.runOneStep=function(t,e,r){var n=r.dimensions,o=r.height,i=r.width,a=r.gravity,s=r.center,u=r.speed,d=r.clustering,h=r.nodeClusterBy,c=r.clusterGravity,l=o*i,f=Math.sqrt(l)/10,g=t.getAllNodes(),p=l/(g.length+1),y=Math.sqrt(p),m={};if(this.applyCalculate(t,m,y,p),d){for(var w in e)e[w].cx=0,e[w].cy=0,e[w].count=0;for(var w in g.forEach((function(t){var r=t.data,n=e[r[h]];v(r.x)&&(n.cx+=r.x),v(r.y)&&(n.cy+=r.y),n.count++})),e)e[w].cx/=e[w].count,e[w].cy/=e[w].count;var x=c||a;g.forEach((function(t,r){var n=t.id,o=t.data;if(v(o.x)&&v(o.y)){var i=e[o[h]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=y*x;m[n].x-=s*(o.x-i.cx)/a,m[n].y-=s*(o.y-i.cy)/a}}))}g.forEach((function(t,e){var r=t.id,o=t.data;if(v(o.x)&&v(o.y)){var i=.01*y*a;m[r].x-=i*(o.x-s[0]),m[r].y-=i*(o.y-s[1]),3===n&&(m[r].z-=i*(o.z-s[2]))}})),g.forEach((function(e,r){var o=e.id,i=e.data;if(v(i.fx)&&v(i.fy))return i.x=i.fx,i.y=i.fy,void(3===n&&(i.z=i.fz));if(v(i.x)&&v(i.y)){var a=Math.sqrt(m[o].x*m[o].x+m[o].y*m[o].y+(3===n?m[o].z*m[o].z:0));if(a>0){var s=Math.min(f*(u/800),a);t.mergeNodeData(o,{x:i.x+m[o].x/a*s,y:i.y+m[o].y/a*s,z:3===n?i.z+m[o].z/a*s:void 0})}}}))},t.prototype.applyCalculate=function(t,e,r,n){this.calRepulsive(t,e,n),this.calAttractive(t,e,r)},t.prototype.calRepulsive=function(t,e,r){var n=this,o=t.getAllNodes();o.forEach((function(t,i){var a=t.data,s=t.id;e[s]={x:0,y:0,z:0},o.forEach((function(t,o){var u=t.data,d=t.id;if(!(i<=o)&&v(a.x)&&v(u.x)&&v(a.y)&&v(u.y)){var h=a.x-u.x,c=a.y-u.y,l=3===n.options.dimensions?a.z-u.z:0,f=h*h+c*c+l*l;0===f&&(f=1,h=.01,c=.01,l=.01);var g=r/f,p=h*g,y=c*g,m=l*g;e[s].x+=p,e[s].y+=y,e[d].x-=p,e[d].y-=y,3===n.options.dimensions&&(e[s].z+=m,e[d].z-=m)}}))}))},t.prototype.calAttractive=function(t,e,r){var n=this;t.getAllEdges().forEach((function(o){var i=o.source,a=o.target;if(i&&a&&i!==a){var s=t.getNode(i).data,u=t.getNode(a).data;if(v(u.x)&&v(s.x)&&v(u.y)&&v(s.y)){var d=u.x-s.x,h=u.y-s.y,c=3===n.options.dimensions?u.z-s.z:0,l=Math.sqrt(d*d+h*h+c*c)/r,f=d*l,g=h*l,p=c*l;e[i].x+=f,e[i].y+=g,e[a].x-=f,e[a].y-=g,3===n.options.dimensions&&(e[i].z+=p,e[a].z-=p)}}}))},t}(),xn={begin:[0,0],preventOverlap:!0,preventOverlapPadding:10,condense:!1,rows:void 0,cols:void 0,position:void 0,sortBy:"degree",nodeSize:30,width:300,height:300},En=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},xn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericGridLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericGridLayout(!0,t,e),[2]}))}))},t.prototype.genericGridLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f,g,p,y,x,E,M,S,k,A,z,R,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U,H;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.begin,s=void 0===i?[0,0]:i,u=o.condense,d=o.preventOverlapPadding,h=o.preventOverlap,c=o.rows,l=o.cols,f=o.nodeSpacing,g=o.nodeSize,p=o.width,y=o.height,x=o.position,E=o.sortBy,M=e.getAllNodes(),S=e.getAllEdges(),!(k=null==M?void 0:M.length)||1===k)return[2,N(e,t,s)];if(A=M.map((function(t){return b(t)})),"id"===E||It(E)&&void 0!==A[0].data[E]||(E="degree"),"degree"===E?A.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===E?A.sort((function(t,e){return v(e.id)&&v(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):A.sort((function(t,e){return e.data[E]-t.data[E]})),z=p||"undefined"==typeof window?p:window.innerWidth,R=y||"undefined"==typeof window?y:window.innerHeight,I=k,D={rows:c,cols:l},null!=c&&null!=l?(D.rows=c,D.cols=l):null!=c&&null==l?(D.rows=c,D.cols=Math.ceil(I/D.rows)):null==c&&null!=l?(D.cols=l,D.rows=Math.ceil(I/D.cols)):(P=Math.sqrt(I*R/z),D.rows=Math.round(P),D.cols=Math.round(z/R*P)),D.rows=Math.max(D.rows,1),D.cols=Math.max(D.cols,1),D.cols*D.rows>I)O=bn(D),T=Nn(D),(O-1)*T>=I?bn(D,O-1):(T-1)*O>=I&&Nn(D,T-1);else for(;D.cols*D.rows<I;)O=bn(D),((T=Nn(D))+1)*O>=I?Nn(D,T+1):bn(D,O+1);for(C=u?0:z/D.cols,L=u?0:R/D.rows,(h||f)&&(q=m(10,f),j=w(30,g,!1),A.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,n,o=e.getNode(t.id),i=j(o)||30;_(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==q?q(t):d,s=r+a,u=n+a;C=Math.max(C,s),L=Math.max(L,u)}))),F={},V={row:0,col:0},B={},G=0;G<A.length;G++){if(W=A[G],$=void 0,x&&($=x(e.getNode(W.id))),$&&(void 0!==$.row||void 0!==$.col)){if(void 0===(U={row:$.row,col:$.col}).col)for(U.col=0;Mn(F,U);)U.col++;else if(void 0===U.row)for(U.row=0;Mn(F,U);)U.row++;B[W.id]=U,Sn(F,U)}An(W,s,C,L,B,D,V,F)}return H={nodes:A,edges:S},t&&A.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,H]}))}))},t}(),bn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.min(n,o):Math.min(n,o)===t.rows?t.rows=e:t.cols=e,r},Nn=function(t,e){var r,n=t.rows||5,o=t.cols||5;return null==e?r=Math.max(n,o):Math.max(n,o)===t.rows?t.rows=e:t.cols=e,r},Mn=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},Sn=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},kn=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},An=function(t,e,r,n,o,i,a,s){var u,d,h=o[t.id];if(h)u=h.col*r+r/2+e[0],d=h.row*n+n/2+e[1];else{for(;Mn(s,a);)kn(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],Sn(s,a),kn(i,a)}t.data.x=u,t.data.y=d},_n={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},zn=function(t,e,r,n,o,i){e.forEach((function(a,s){r[s]={x:0,y:0},e.forEach((function(e,u){if(s!==u&&o[s]===o[u]){var d=a.x-e.x,h=a.y-e.y,c=Math.sqrt(d*d+h*h);if(0===c){c=1;var l=s>u?1:-1;d=.01*l,h=.01*l}if(c<i(t[s])/2+i(t[u])/2){var f=n*n/c;r[s].x+=d/c*f,r[s].y+=h/c*f}}}))}))},Rn=function(t,e,r,n,o,i,a,s){var u=i||a/10;return n&&e.forEach((function(e,r){var n=t[r].x-t[o].x,i=t[r].y-t[o].y,a=Math.sqrt(n*n+i*i),s=i/a,u=-n/a,d=Math.sqrt(e.x*e.x+e.y*e.y),h=Math.acos((s*e.x+u*e.y)/d);h>Math.PI/2&&(h-=Math.PI/2,s*=-1,u*=-1);var c=Math.cos(h)*d;e.x=s*c,e.y=u*c})),t.forEach((function(i,a){if(a!==o){var d=Math.sqrt(e[a].x*e[a].x+e[a].y*e[a].y);if(d>0&&a!==o){var h=Math.min(u*(r/800),d);if(i.x+=e[a].x/d*h,i.y+=e[a].y/d*h,n){var c=i.x-t[o].x,l=i.y-t[o].y,f=Math.sqrt(c*c+l*l);c=c/f*s[a],l=l/f*s[a],i.x=t[o].x+c,i.y=t[o].y+l}}}})),t},In={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},Dn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},In),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRadialLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRadialLayout(!0,t,e),[2]}))}))},t.prototype.genericRadialLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,d,h,c,l,f,g,p,v,y,m,w,E,M,S,k,A,_,I,D,P,O,T,C,L,q,j,F,V,B,G,W,$,U,H,Y,K,J,Q,Z,et,rt;return a(this,(function(a){if(o=n(n({},this.options),r),i=o.width,d=o.height,h=o.center,c=o.focusNode,l=o.unitRadius,f=o.nodeSize,g=o.nodeSpacing,p=o.strictRadial,v=o.preventOverlap,y=o.maxPreventOverlapIteration,m=o.sortBy,w=o.linkDistance,E=void 0===w?50:w,M=o.sortStrength,S=void 0===M?10:M,k=o.maxIteration,A=void 0===k?1e3:k,_=e.getAllNodes(),I=e.getAllEdges(),D=i||"undefined"==typeof window?i:window.innerWidth,P=d||"undefined"==typeof window?d:window.innerHeight,O=h||[D/2,P/2],!(null==_?void 0:_.length)||1===_.length)return[2,N(e,t,O)];if(T=_[0],It(c)){for(C=0;C<_.length;C++)if(_[C].id===c){T=_[C];break}}else T=c||_[0];return L=Tn(_,T.id),q=R({nodes:_,edges:I},!1),j=z(q),F=Ln(j,L),Cn(j,L,F+1),V=j[L],B=D-O[0]>O[0]?O[0]:D-O[0],G=P-O[1]>O[1]?O[1]:P-O[1],0===B&&(B=D/2),0===G&&(G=P/2),W=Math.min(B,G),$=Math.max.apply(Math,u([],s(V))),U=[],H=l||W/$,V.forEach((function(t,e){U[e]=t*H})),Y=Pn(_,j,E,U,H,m,S),K=On(Y),J=function(t,e,r){try{var n=X.mul(X.pow(e,2),-.5),o=n.mean("row"),i=n.mean("column"),a=n.mean();n.add(a).subRowVector(o).subColumnVector(i);var s=new tt(n),u=X.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return X.mul([e],[u]).toJSON()[0].splice(0,t)}))}catch(t){for(var d=[],h=0;h<e.length;h++){var c=Math.random()*r,l=Math.random()*r;d.push([c,l])}return d}}(E,Y,E),Q=J.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*E:r)-J[L][0],y:(isNaN(n)?Math.random()*E:n)-J[L][1]}})),this.run(A,Q,K,Y,U,L),v&&(Z=x(f,g),et={nodes:_,nodeSizeFunc:Z,positions:Q,radii:U,height:P,width:D,strictRadial:Boolean(p),focusIdx:L,iterations:y||200,k:Q.length/4.5},Q=function(t,e){for(var r=n(n({},_n),e),o=r.positions,i=r.iterations,a=r.width,s=r.k,u=r.speed,d=void 0===u?100:u,h=r.strictRadial,c=r.focusIdx,l=r.radii,f=void 0===l?[]:l,g=r.nodeSizeFunc,p=t.getAllNodes(),v=[],y=a/10,m=0;m<i;m++)o.forEach((function(t,e){v[e]={x:0,y:0}})),zn(p,o,v,s,f,g),Rn(o,v,d,h,c,y,a,f);return o}(e,et)),rt=[],Q.forEach((function(t,e){var r=b(_[e]);r.data.x=t.x+O[0],r.data.y=t.y+O[1],rt.push(r)})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:rt,edges:I}]}))}))},t.prototype.run=function(t,e,r,n,o,i){for(var a=0;a<=t;a++){var s=a/t;this.oneIteration(s,e,o,n,r,i)}},t.prototype.oneIteration=function(t,e,r,n,o,i){var a=1-t;e.forEach((function(s,u){var d=I(s,{x:0,y:0}),h=0===d?0:1/d;if(u!==i){var c=0,l=0,f=0;e.forEach((function(t,e){if(u!==e){var r=I(s,t),i=0===r?0:1/r,a=n[e][u];f+=o[u][e],c+=o[u][e]*(t.x+a*(s.x-t.x)*i),l+=o[u][e]*(t.y+a*(s.y-t.y)*i)}}));var g=0===r[u]?0:1/r[u];f*=a,f+=t*g*g,c*=a,c+=t*g*s.x*h,s.x=c/f,l*=a,l+=t*g*s.y*h,s.y=l/f}}))},t}(),Pn=function(t,e,r,n,o,i,a){if(!t)return[];var s=[];if(e){var u={};e.forEach((function(e,d){var h=[];e.forEach((function(e,s){var c,l;if(d===s)h.push(0);else if(n[d]===n[s])if("data"===i)h.push(e*(Math.abs(d-s)*a)/(n[d]/o));else if(i){var f=void 0,g=void 0;if(u[t[d].id])f=u[t[d].id];else{var p=("id"===i?t[d].id:null===(c=t[d].data)||void 0===c?void 0:c[i])||0;f=It(p)?p.charCodeAt(0):p,u[t[d].id]=f}u[t[s].id]?g=u[t[s].id]:(p=("id"===i?t[s].id:null===(l=t[s].data)||void 0===l?void 0:l[i])||0,g=It(p)?p.charCodeAt(0):p,u[t[s].id]=g),h.push(e*(Math.abs(f-g)*a)/(n[d]/o))}else h.push(e*r/(n[d]/o));else{var v=(r+o)/2;h.push(e*v)}})),s.push(h)}))}return s},On=function(t){for(var e=t.length,r=t[0].length,n=[],o=0;o<e;o++){for(var i=[],a=0;a<r;a++)0!==t[o][a]?i.push(1/(t[o][a]*t[o][a])):i.push(0);n.push(i)}return n},Tn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Cn=function(t,e,r){for(var n=t.length,o=0;o<n;o++)if(t[e][o]===1/0){t[e][o]=r,t[o][e]=r;for(var i=0;i<n;i++)t[o][i]!==1/0&&t[e][i]===1/0&&(t[e][i]=r+t[o][i],t[i][e]=r+t[o][i])}for(o=0;o<n;o++)if(o!==e)for(i=0;i<n;i++)if(t[o][i]===1/0){var a=Math.abs(t[e][o]-t[e][i]);a=0===a?1:a,t[o][i]=a}},Ln=function(t,e){for(var r=0,n=0;n<t[e].length;n++)t[e][n]!==1/0&&(r=t[e][n]>r?t[e][n]:r);return r},qn={center:[0,0],width:300,height:300},jn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},qn),t)}return t.prototype.execute=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return[2,this.genericRandomLayout(!1,t,e)]}))}))},t.prototype.assign=function(t,e){return i(this,void 0,void 0,(function(){return a(this,(function(r){return this.genericRandomLayout(!0,t,e),[2]}))}))},t.prototype.genericRandomLayout=function(t,e,r){return i(this,void 0,void 0,(function(){var o,i,s,u,d,h,c,l,f;return a(this,(function(a){return o=n(n({},this.options),r),i=o.center,s=o.width,u=o.height,d=e.getAllNodes(),h=s||"undefined"==typeof window?s:window.innerWidth,c=u||"undefined"==typeof window?u:window.innerHeight,l=i||[h/2,c/2],f=[],d&&d.forEach((function(t){f.push({id:t.id,data:{x:.9*(Math.random()-.5)*h+l[0],y:.9*(Math.random()-.5)*c+l[1]}})})),t&&f.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:f,edges:e.getAllEdges()}]}))}))},t}(),Fn={circular:S,concentric:Pt,mds:rt,random:jn,grid:En,radial:Dn,force:St,d3force:_e,fruchterman:wn,forceAtlas2:yn,dagre:dn,comboCombined:Ct};function Vn(){var t;(null===(t=pn)||void 0===t?void 0:t.stop)&&pn.stop()}function Bn(t,e){return i(this,void 0,void 0,(function(){var r,n,o,i,s,u,d,h,c;return a(this,(function(a){switch(a.label){case 0:if(r=t.layout,n=r.id,o=r.options,i=r.iterations,s=t.nodes,u=t.edges,d=new l({nodes:s,edges:u}),!(h=Fn[n]))throw new Error("Unknown layout id: "+n);return[4,(pn=new h(o)).execute(d)];case 1:return c=a.sent(),!!(f=pn).tick&&!!f.stop&&(pn.stop(),c=pn.tick(i)),[2,[c,e]]}var f}))}))}addEventListener("message",(function(t){var r,n=t.data,o=n.type,i=n.method,a=n.id,s=n.params;"RPC"===o&&i&&((r=e[i])?Promise.resolve().then((function(){return r.apply(e,s)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:a,result:t})})).catch((function(t){var e={message:t};t.stack&&(e.message=t.message,e.stack=t.stack,e.name=t.name),postMessage({type:"RPC",id:a,error:e})}))})),postMessage({type:"RPC",method:"ready"})})();
|
|
2
|
+
//# sourceMappingURL=aa1bb0ccc06b11cf79c1.worker.js.map
|