@antv/layout 1.0.0 → 1.2.0

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.
@@ -2,6 +2,6 @@ import { Point } from "../types";
2
2
  import { CalcGraph } from "./types";
3
3
  export declare function forceNBody(calcGraph: CalcGraph, factor: number, coulombDisScale2: number, accMap: {
4
4
  [id: string]: Point;
5
- }): {
5
+ }, dimensions: number): {
6
6
  [id: string]: Point;
7
7
  };
@@ -100,7 +100,7 @@ export declare class ForceLayout implements LayoutWithIterations<ForceLayoutOpti
100
100
  */
101
101
  calAttractive(calcGraph: CalcGraph, accMap: {
102
102
  [id: string]: Point;
103
- }): void;
103
+ }, options: FormatedOptions): void;
104
104
  /**
105
105
  * Calculate the gravity forces toward center.
106
106
  * @param calcGraph calculation graph
@@ -3,6 +3,7 @@ import { CentripetalOptions, Edge, Node, EdgeData, ForceLayoutOptions, NodeData,
3
3
  export interface CalcNodeData extends NodeData {
4
4
  x: number;
5
5
  y: number;
6
+ z?: number;
6
7
  mass: number;
7
8
  nodeStrength: number;
8
9
  }
package/lib/types.d.ts CHANGED
@@ -6,6 +6,7 @@ export interface NodeData extends PlainObject {
6
6
  borderRight?: ID | ID[];
7
7
  x?: number;
8
8
  y?: number;
9
+ z?: number;
9
10
  height?: number;
10
11
  width?: number;
11
12
  e?: IEdge<EdgeData>;
@@ -24,6 +25,7 @@ export interface NodeData extends PlainObject {
24
25
  export interface OutNodeData extends NodeData {
25
26
  x: number;
26
27
  y: number;
28
+ z?: number;
27
29
  }
28
30
  export interface EdgeData extends PlainObject {
29
31
  virtual?: boolean;
@@ -54,10 +56,11 @@ export declare type IndexMap = {
54
56
  };
55
57
  export declare type Graph = IGraph<NodeData, EdgeData>;
56
58
  export declare type GraphView = IGraphView<NodeData, EdgeData>;
57
- export declare type PointTuple = [number, number];
59
+ export declare type PointTuple = [number, number] | [number, number, number];
58
60
  export declare type Point = {
59
61
  x: number;
60
62
  y: number;
63
+ z?: number;
61
64
  };
62
65
  export declare type Matrix = number[];
63
66
  export declare type LayoutMapping = {
@@ -231,14 +234,22 @@ export interface CentripetalOptions {
231
234
  center?: (node: Node, nodes: Node[], edges: Edge[], width: number, height: number) => {
232
235
  x: number;
233
236
  y: number;
237
+ z?: number;
234
238
  centerStrength?: number;
235
239
  };
236
240
  }
237
241
  interface CommonForceLayoutOptions {
242
+ dimensions?: number;
238
243
  center?: PointTuple;
239
244
  minMovement?: number;
240
245
  maxIteration?: number;
241
246
  distanceThresholdMode?: "mean" | "max" | "min";
247
+ /**
248
+ * If distance is specified, sets the maximum distance between nodes over which this force is considered.
249
+ * If distance is not specified, returns the current maximum distance, which defaults to infinity.
250
+ * Specifying a finite maximum distance improves performance and produces a more localized layout.
251
+ */
252
+ maxDistance?: number;
242
253
  }
243
254
  export interface ForceLayoutOptions extends CommonForceLayoutOptions {
244
255
  width?: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/layout",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "graph layout algorithm",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,6 +32,7 @@
32
32
  "@naoak/workerize-transferable": "^0.1.0",
33
33
  "d3-force": "^3.0.0",
34
34
  "d3-quadtree": "^3.0.1",
35
+ "d3-octree": "^1.0.2",
35
36
  "eventemitter3": "^4.0.0",
36
37
  "ml-matrix": "^6.10.4",
37
38
  "tslib": "^2.5.0"
@@ -57,4 +58,4 @@
57
58
  "build:umd": "webpack --config webpack.config.js --mode production",
58
59
  "publish:alpha": "npm publish --tag alpha"
59
60
  }
60
- }
61
+ }
@@ -1,2 +0,0 @@
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:()=>_n,stopLayout:()=>In});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()})}}var f=/-(\w)/g,g=(function(t){return t.replace(f,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),p=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},v=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},y=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},m={}.toString;const w=function(t,e){return m.call(t)==="[object "+e+"]"},x=function(t){return w(t,"Number")};var 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&&(x(r.data.x)||(r.data.x=Math.random()*e[0]),x(r.data.y)||(r.data.y=Math.random()*e[1])),r};const N=function(t){return"function"==typeof t},M=function(t){var e=typeof t;return null!==t&&"object"===e||"function"===e};function S(t,e){return N(e)?e:x(e)?function(){return e}:function(){return t}}function k(t,e,r){return void 0===r&&(r=!0),e||0===e?N(e)?e:x(e)?function(){return e}:g(e)?function(){if(r){var n=Math.max.apply(Math,u([],s(e)));return isNaN(n)?t:n}return e}:M(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?g(r)?r[0]>r[1]?r[0]:r[1]:M(r)?r.width>r.height?r.width:r.height:r:t}}var A=function(t,e){var r;return r=x(e)?function(){return e}:N(e)?e:function(){return 0},t?g(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}: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(g(t.data.size))return Math.max(t.data.size[0],t.data.size[1])+r(t);var o=t.data.size;return M(o)?(o.width>o.height?o.width:o.height)+r(t):o+r(t)}return 10+r(t)}},R=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}},I={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},_=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=n(n({},I),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,m,w,x,E,N,M,A,I,_,P,T,z,C,L,q,j,F,V,G,W,B,$,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,m=o.nodeSpacing,w=o.nodeSize,x=e.getAllNodes(),E=e.getAllEdges(),N=s(O(i,u,d),3),M=N[0],A=N[1],I=N[2],!(_=null==x?void 0:x.length)||1===_)return[2,R(e,t,I)];for(P=(g-l)/_,T=o.radius,z=o.startRadius,C=o.endRadius,m?(L=S(10,m),q=k(10,w),j=-1/0,x.forEach((function(t){var e=q(t);j<e&&(j=e)})),F=0,x.forEach((function(t,e){F+=0===e?j||10:(L(t)||0)+(j||10)})),T=F/(2*Math.PI)):T||z||C?!z&&C?z=C:z&&!C&&(C=z):T=Math.min(A,M)/2,V=P*p,G=[],G="topology"===v?D(e,x):"topology-directed"===v?D(e,x,!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,x):x.map((function(t){return b(t)})),W=Math.ceil(_/h),B=0;B<_;++B)($=T)||null===z||null===C||($=z+B*(C-z)/(_-1)),$||($=10+100*B/(_-1)),U=l+B%W*V+2*Math.PI/h*Math.floor(B/W),y||(U=g-B%W*V-2*Math.PI/h*Math.floor(B/W)),G[B].data.x=I[0]+Math.cos(U)*$,G[B].data.y=I[1]+Math.sin(U)*$;return t&&G.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:G,edges:E}]}))}))},t}(),D=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},O=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]};const P=function(t){return w(t,"String")};var T={nodeSize:30,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},z=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=n(n({},T),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,f,p,v,y,m,w,E,S,k,A,I,_,D,O,T,z,C,L,q,j,F,V,G,W,B,$,U,H,K,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,f=o.equidistant,p=o.preventOverlap,v=o.startAngle,y=void 0===v?1.5*Math.PI:v,m=o.nodeSize,w=o.nodeSpacing,E=e.getAllNodes(),S=e.getAllEdges(),k=s||"undefined"==typeof window?s:window.innerWidth,A=u||"undefined"==typeof window?u:window.innerHeight,I=i||[k/2,A/2],!(null==E?void 0:E.length)||1===E.length)return[2,R(e,t,I)];if(_=[],O=0,D=g(m)?Math.max(m[0],m[1]):m,g(w)?O=Math.max(w[0],w[1]):x(w)&&(O=w),E.forEach((function(t){var e=b(t);_.push(e);var r=D,n=e.data;g(n.size)?r=Math.max(n.size[0],n.size[1]):x(n.size)?r=n.size:M(n.size)&&(r=Math.max(n.size.width,n.size.height)),D=Math.max(D,r),N(w)&&(O=Math.max(w(t),O))})),T={},_.forEach((function(t,e){T[t.id]=e})),P(z=d)&&void 0!==_[0].data[z]||(z="degree"),"degree"===z?_.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):_.sort((function(t,e){return e.data[z]-t.data[z]})),C=_[0],L=(h||("degree"===z?e.getDegree(C.id,"both"):C.data[z]))/4,j=(q=[{nodes:[]}])[0],_.forEach((function(t){if(j.nodes.length>0){var r="degree"===z?Math.abs(e.getDegree(j.nodes[0].id,"both")-e.getDegree(t.id,"both")):Math.abs(j.nodes[0].data[z]-t.data[z]);L&&r>=L&&(j={nodes:[]},q.push(j))}j.nodes.push(t)})),F=D+O,p||(V=q.length>0&&q[0].nodes.length>1,G=Math.min(k,A)/2-F,W=G/(q.length+(V?1:0)),F=Math.min(F,W)),B=0,q.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(F*F/(r*r+n*n));B=Math.max(o,B)}t.r=B,B+=F})),f){for($=0,U=0,H=0;H<q.length;H++)K=q[H],Y=(K.r||0)-U,$=Math.max($,Y);U=0,q.forEach((function(t,e){0===e&&(U=t.r||0),t.r=U,U+=$}))}return q.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,n){var o=y+(l?1:-1)*e*n;t.data.x=I[0]+r*Math.cos(o),t.data.y=I[1]+r*Math.sin(o)}))})),t&&_.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:_,edges:S}]}))}))},t}();function C(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 L(t,e,r,n,o){this.node=t,this.x0=e,this.y0=r,this.x1=n,this.y1=o}function q(t){return t[0]}function j(t){return t[1]}function F(t,e,r){var n=new V(null==e?q:e,null==r?j:r,NaN,NaN,NaN,NaN);return null==t?n:n.addAll(t)}function V(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 G(t){for(var e={data:t.data},r=e;t=t.next;)r=r.next={data:t.data};return e}var W=F.prototype=V.prototype;function B(t){return function(){return t}}function $(t){return 1e-6*(t()-.5)}W.copy=function(){var t,e,r=new V(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=G(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]=G(e));return r},W.add=function(t){const e=+this._x.call(null,t),r=+this._y.call(null,t);return C(this.cover(e,r),e,r,t)},W.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)C(this,a[r],s[r],t[r]);return this},W.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},W.data=function(){var t=[];return this.visit((function(e){if(!e.length)do{t.push(e.data)}while(e=e.next)})),t},W.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]]},W.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 L(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 L(p[3],v,y,a,s),new L(p[2],o,y,v,s),new L(p[1],v,i,a,y),new L(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},W.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)},W.removeAll=function(t){for(var e=0,r=t.length;e<r;++e)this.remove(t[e]);return this},W.root=function(){return this._root},W.size=function(){var t=0;return this.visit((function(e){if(!e.length)do{++t}while(e=e.next)})),t},W.visit=function(t){var e,r,n,o,i,a,s=[],u=this._root;for(u&&s.push(new L(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 L(r,d,h,i,a)),(r=u[2])&&s.push(new L(r,n,h,d,a)),(r=u[1])&&s.push(new L(r,d,o,i,h)),(r=u[0])&&s.push(new L(r,n,o,d,h))}return this},W.visitAfter=function(t){var e,r=[],n=[];for(this._root&&r.push(new L(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 L(i,a,s,h,c)),(i=o[1])&&r.push(new L(i,h,s,u,c)),(i=o[2])&&r.push(new L(i,a,c,h,d)),(i=o[3])&&r.push(new L(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},W.x=function(t){return arguments.length?(this._x=t,this):this._x},W.y=function(t){return arguments.length?(this._y=t,this):this._y};var U={value:()=>{}};function H(){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 K(n)}function K(t){this._=t}function Y(t,e){for(var r,n=0,o=t.length;n<o;++n)if((r=t[n]).name===e)return r.value}function J(t,e,r){for(var n=0,o=t.length;n<o;++n)if(t[n].name===e){t[n]=U,t=t.slice(0,n).concat(t.slice(n+1));break}return null!=r&&t.push({name:e,value:r}),t}K.prototype=H.prototype={constructor:K,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]=J(o[r],t.name,e);else if(null==e)for(r in o)o[r]=J(o[r],t.name,null);return this}for(;++a<s;)if((r=(t=i[a]).type)&&(r=Y(o[r],t.name)))return r},copy:function(){var t={},e=this._;for(var r in e)t[r]=e[r].slice();return new K(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 X=H;var Q,Z,tt=0,et=0,rt=0,nt=1e3,ot=0,it=0,at=0,st="object"==typeof performance&&performance.now?performance:Date,ut="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function dt(){return it||(ut(ht),it=st.now()+at)}function ht(){it=0}function ct(){this._call=this._time=this._next=null}function lt(t,e,r){var n=new ct;return n.restart(t,e,r),n}function ft(){it=(ot=st.now())+at,tt=et=0;try{!function(){dt(),++tt;for(var t,e=Q;e;)(t=it-e._time)>=0&&e._call.call(void 0,t),e=e._next;--tt}()}finally{tt=0,function(){for(var t,e,r=Q,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:Q=e);Z=t,pt(n)}(),it=0}}function gt(){var t=st.now(),e=t-ot;e>nt&&(at-=e,ot=t)}function pt(t){tt||(et&&(et=clearTimeout(et)),t-it>24?(t<1/0&&(et=setTimeout(ft,t-st.now()-at)),rt&&(rt=clearInterval(rt))):(rt||(ot=st.now(),rt=setInterval(gt,nt)),tt=1,ut(ft)))}ct.prototype=lt.prototype={constructor:ct,restart:function(t,e,r){if("function"!=typeof t)throw new TypeError("callback is not a function");r=(null==r?dt():+r)+(null==e?0:+e),this._next||Z===this||(Z?Z._next=this:Q=this,Z=this),this._call=t,this._time=r,pt()},stop:function(){this._call&&(this._call=null,this._time=1/0,pt())}};const vt=1664525,yt=1013904223,mt=4294967296;function wt(t){return t.x}function xt(t){return t.y}var Et=10,bt=Math.PI*(3-Math.sqrt(5));function Nt(t){var e,r=1,n=.001,o=1-Math.pow(n,1/300),i=0,a=.6,s=new Map,u=lt(c),d=X("tick","end"),h=function(){let t=1;return()=>(t=(vt*t+yt)%mt)/mt}();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=Et*Math.sqrt(.5+r),i=r*bt;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 Mt(){var t,e,r,n,o,i=B(-30),a=1,s=1/0,u=.81;function d(r){var o,i=t.length,a=F(t,wt,xt).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=$(r))*c),0===l&&(g+=(l=$(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=$(r))*c),0===l&&(g+=(l=$(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:B(+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 St(t){return t.index}function kt(t,e){var r=t.get(e);if(!r)throw new Error("node not found: "+e);return r}function At(t){var e,r,n,o,i,a,s=St,u=function(t){return 1/Math.min(o[t.source.index],o[t.target.index])},d=B(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||$(a),f=c.y+c.vy-d.y-d.vy||$(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=kt(c,u.source)),"object"!=typeof u.target&&(u.target=kt(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:B(+t),f(),c):u},c.distance=function(t){return arguments.length?(d="function"==typeof t?t:B(+t),g(),c):d},c}function Rt(t){return t.x+t.vx}function It(t){return t.y+t.vy}function _t(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=F(e,Rt,It).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=$(n))*p),0===v&&(y+=(v=$(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=B(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:B(+e),u(),a):t},a}function Dt(t){var e,r,n,o=B(.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=B(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:B(+t),a(),i):o},i.x=function(e){return arguments.length?(t="function"==typeof e?e:B(+e),a(),i):t},i}function Ot(t){var e,r,n,o=B(.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=B(null==t?0:+t)),i.initialize=function(t){e=t,a()},i.strength=function(t){return arguments.length?(o="function"==typeof t?t:B(+t),a(),i):o},i.y=function(e){return arguments.length?(t="function"==typeof e?e:B(+e),a(),i):t},i}function Pt(){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=Nt(m.nodes).force("x",Dt(l).strength(.1)).force("y",Ot(f).strength(.1)).force("collide",_t((function(t){return t.r})).iterations(4)).force("charge",Mt().strength(o)).force("links",At(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 Tt={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},zt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="d3force",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.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:Ct(this.lastLayoutNodes),edges:Lt(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,R,I,_,D,O=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,R=o.nodeSize,I=o.nodeSpacing,_=o.onTick,D=o.forceSimulation,[2,new Promise((function(r){if(D){v&&((i=Pt()).nodes(u),i.links(d)),D.nodes(u),d&&(s=At().id((function(t){return t.id})).links(d),g&&s.strength(g),p&&s.distance(p),D.force("link",s)),A&&O.overlapProcess(D,{nodeSize:R,nodeSpacing:I,collideStrength:M}),D.alpha(l).restart();var n=Ct(u),o=Lt(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=Mt();if(f&&a.strength(f),D=Nt().nodes(u),v&&((i=Pt()).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),D.force("group",i)),D.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&&O.overlapProcess(D,{nodeSize:R,nodeSpacing:I,collideStrength:M}),d){var s=At().id((function(t){return t.id})).links(d);g&&s.strength(g),p&&s.distance(p),D.force("link",s)}D.on("tick",(function(){var r=Ct(u);null==_||_({nodes:r,edges:Lt(d)}),t&&r.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}))})).on("end",(function(){var n=Ct(u);t&&n.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),r({nodes:n,edges:Lt(d)})}))}catch(t){console.warn(t)}O.forceSimulation=D}))]}))}))},t.prototype.overlapProcess=function(t,e){var r,n,o=e.nodeSize,i=e.nodeSpacing,a=e.collideStrength;if(n=x(i)?function(){return i}:N(i)?i:function(){return 0},o)if(N(o))r=function(t){return o(t)+n(t)};else if(g(o)){var s=(o[0]>o[1]?o[0]:o[1])/2;r=function(t){return s+n(t)}}else if(x(o)){var u=o/2;r=function(t){return u+n(t)}}else r=function(){return 10};else r=function(t){return t.size?g(t.size)?(t.size[0]>t.size[1]?t.size[0]:t.size[1])/2+n(t):M(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",_t(r).strength(a))},t}(),Ct=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})})}))},Lt=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 qt=function(t,e){if("next"!==t&&"prev"!==t)return e},jt=function(t){t.prev.next=t.next,t.next.prev=t.prev,delete t.next,delete t.prev},Ft=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 jt(e),e},t.prototype.enqueue=function(t){var e=this.shortcut;t.prev&&t.next&&jt(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,qt)),r=null==r?void 0:r.prev;return"["+t.join(", ")+"]"},t}()),Vt=function(){return 1},Gt=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,Wt(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,Wt(e,r,n({v:s.id},s.data))})),t.removeNode(o.v)),i?u:void 0},Wt=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)},Bt=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 Ft);var d=o+1;return r.getAllNodes().forEach((function(t){Wt(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}||Vt);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();)Gt(t,e,r,n);for(;n=i.dequeue();)Gt(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(Gt(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):$t(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)})}))},$t=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},Ut=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},Ht=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},Kt=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}},Yt=function(t){for(var e=[],r=Xt(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},Jt=function(t,e,r,n){var o={width:0,height:0};return x(r)&&x(n)&&(o.rank=r,o.order=n),Ut(t,"border",o,e)},Xt=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},Qt=function(t,e){return t.reduce((function(t,r){return e(t)>e(r)?r:t}))},Zt=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 Zt(t,e,r,n,o,i)})),r&&i.push(e.id))},te=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);Zt(t,e,"post"===r,s,i,a)})),a},ee="edge-label",re=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)}))},ne=function(t,e){return t.getNode(e.target).data.rank-t.getNode(e.source).data.rank-e.data.minlen},oe=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)||ne(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},ie=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&&ne(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},ae=function(t,e){return Qt(e.getAllEdges(),(function(r){return t.hasNode(r.source)!==t.hasNode(r.target)?ne(e,r):1/0}))},se=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}))},ue=function(t,e){var r=te(t,t.getAllNodes(),"post",!1);(r=r.slice(0,(null==r?void 0:r.length)-1)).forEach((function(r){de(t,e,r)}))},de=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=he(t,e,r)},he=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,ye(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},ce=function(t,e){void 0===e&&(e=t.getAllNodes()[0].id),le(t,{},1,e)},le=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=le(t,e,s,r.id,n))})),u.data.low=a,u.data.lim=s++,o?u.data.parent=o:delete u.data.parent,s},fe=function(t){return t.getAllEdges().find((function(t){return t.data.cutvalue<0}))},ge=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===me(t.getNode(e.source),s)&&u!==me(t.getNode(e.target),s)}));return Qt(d,(function(t){return ne(e,t)}))},pe=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:{}}),ce(t),ue(t,e),ve(t,e)},ve=function(t,e){var r=t.getAllNodes().find((function(t){return!t.data.parent})),n=te(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))}))},ye=function(t,e,r){return t.getRelatedEdges(e,"both").find((function(t){return t.source===r||t.target===r}))},me=function(t,e){return e.data.low<=t.data.lim&&t.data.lim<=e.data.lim},we=re,xe=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);re(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);oe(n,t)<i;)e=ae(n,t),r=n.hasNode(e.source)?ne(t,e):-ne(t,e),se(n,t,r);return n}(e);for(ce(i),ue(i,e);r=fe(i);)o=ge(i,e,r),pe(i,e,r,o)}(t)},Ee=function(t,e,r,n,o,i,a){var s=t.getChildren(a);if(null==s?void 0:s.length){var u=Jt(t,"_bt"),d=Jt(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){Ee(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}})},be=function(t,e,r,n,o,i){var a={rank:i,borderType:e,width:0,height:0},s=o.data[e][i-1],u=Ut(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}})},Ne=function(t){t.getAllNodes().forEach((function(t){Me(t)})),t.getAllEdges().forEach((function(t){Me(t)}))},Me=function(t){var e=t.data.width;t.data.width=t.data.height,t.data.height=e},Se=function(t){(null==t?void 0:t.y)&&(t.y=-t.y)},ke=function(t){var e=t.x;t.x=t.y,t.y=e},Ae=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},Re=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},Ie=function(t,e){for(var r=0,n=1;n<(null==e?void 0:e.length);n+=1)r+=Re(t,e[n-1],e[n]);return r},_e=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 De=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)&&_e(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 Oe=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},Pe=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=Pe(t,e.v,r,n,i);g[e.v]=a,a.hasOwnProperty("barycenter")&&ze(e,a)}}));var v=De(p,r);Te(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=Oe(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=Oe(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},Te=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()}))},ze=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)},Ce=function(t){if("object"!=typeof t||null===t)return t;var e,r;if(r=t,Array.isArray?Array.isArray(r):w(r,"Array")){e=[];for(var n=0,o=t.length;n<o;n++)"object"==typeof t[n]&&null!=t[n]?e[n]=Ce(t[n]):e[n]=t[n]}else for(var i in e={},t)"object"==typeof t[i]&&null!=t[i]?e[i]=Ce(t[i]):e[i]=t[i];return e};const Le=Ce;var qe=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)}))},je=function(t,e,r,n){var o=new l;null==t||t.forEach((function(t){for(var i,a=t.getRoots()[0].id,s=Pe(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.addNodes([{id:a,data:{}},{id:s.id,data:{}}]),void e.addEdge({id:"e"+a+"-"+s.id,source:a,target:s.id,data:{}});s=i}}))}(t,o,s.vs)}))},Fe=function(t,e){null==e||e.forEach((function(e){null==e||e.forEach((function(e,r){t.getNode(e).data.order=r}))}))},Ve=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)&&We(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},Ge=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}))},We=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},Be=function(t,e,r){var n=e;return n>r&&(n=r),!!t[n]},$e=function(t,e,r,o,i,a){var s=new l,u=Ue(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 Ue=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}},He=function(t,e){return t.getNode(e).data.width||0},Ke=function(t,e){var r,n=Ht(t);!function(t,e){var r=(e||{}).ranksep,n=void 0===r?0:r,o=Yt(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=Yt(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=Ge(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)||We(r,n.id,e)}))})),i=u+1,o=c)})),n})),r}(t,h),Ve(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]&&!Be(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=$e(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 Qt(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=He(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]}))},Ye=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;dr(t),Bt(t,r);var w=function(t){var e=Ut(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){Ee(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":xe(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);ie(n,t)<i;)e=ae(n,t),r=n.hasNode(e.source)?ne(t,e):-ne(t,e),se(n,t,r)}(t)}(t);break;case"longest-path":we(t)}}(Ht(t),o),er(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),rr(t),nr(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=Ut(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=ee,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)be(t,"borderLeft","_bl",r,o,i),be(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=Xt(t),n=[],o=[],i=1;i<r+1;i++)n.push(i);for(i=r-1;i>-1;i--)o.push(i);var a=qe(t,n,"in"),s=qe(t,o,"out"),u=Ae(t);Fe(t,u);for(var d,h=Number.POSITIVE_INFINITY,c=(i=0,0);c<4;++i,++c)je(i%2?a:s,i%4>=2,!1,e),u=Yt(t),(l=Ie(t,u))<h&&(c=0,d=Le(u),h=l);for(u=Ae(t),Fe(t,u),i=0,c=0;c<4;++i,++c){var l;je(i%2?a:s,i%4>=2,!0,e),u=Yt(t),(l=Ie(t,u))<h&&(c=0,d=Le(u),h=l)}Fe(t,d)}(t,h),hr(t),function(t,e){var r=e.toLowerCase();"lr"!==r&&"rl"!==r||Ne(t)}(t,a),Ke(t,{align:c,nodesep:g,edgesep:v,ranksep:m}),cr(t),ur(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===ee&&(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),ar(t),function(t,e){var r=e.toLowerCase();"bt"!==r&&"rl"!==r||function(t){t.getAllNodes().forEach((function(t){Se(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return Se(t)})),t.data.hasOwnProperty("y")&&Se(t.data)}))}(t),"lr"!==r&&"rl"!==r||(function(t){t.getAllNodes().forEach((function(t){ke(t.data)})),t.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){return ke(t)})),t.data.hasOwnProperty("x")&&ke(t.data)}))}(t),Ne(t))}(t,a);var N=or(t),M=N.width,S=N.height;return ir(t),sr(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}},Je=["width","height","layer","fixorder"],Xe={width:0,height:0},Qe=["minlen","weight","width","height","labeloffset"],Ze={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},tr=["labelpos"],er=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};Ut(t,"edge-proxy",n,"_ep")}}))},rr=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},nr=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))}))},or=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}},ir=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(Kt(o.data,r)),e.data.points.push(Kt(i.data,n))}))},ar=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}}))},sr=function(t){t.getAllEdges().forEach((function(t){var e;t.data.reversed&&(null===(e=t.data.points)||void 0===e||e.reverse())}))},ur=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)}))},dr=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)}}))},hr=function(t){var e=Yt(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){Ut(t,"selfedge",{width:e.data.width,height:e.data.height,rank:i.data.rank,order:n+ ++r,e},"_se")})),delete i.data.selfEdges}))}))},cr=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}}))},lr=function(t,e){var r={};return null==e||e.forEach((function(e){void 0!==t[e]&&(r[e]=+t[e])})),r},fr=function(t){void 0===t&&(t={});var e={};return Object.keys(t).forEach((function(r){e[r.toLowerCase()]=t[r]})),e},gr={rankdir:"TB",nodesep:50,ranksep:50,edgeLabelSpace:!0,controlPoints:!1,radial:!1,focusNode:null},pr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="dagre",this.layoutNode=function(t){return t.data.layout},this.options=n(n({},gr),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,v,y,m,w,E,N,M,k,R,I,_,D,O,P,T,z,C,L,q,j,F,V,G,W=this;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,v=o.nodeOrder,y=o.begin,m=o.controlPoints,w=o.radial,E=new l({tree:[]}),N=S(h||50,f),M=S(c||50,g),k=M,R=N,"LR"!==d&&"RL"!==d||(k=N,R=M),I=A(i,void 0),_=e.getAllNodes(),D=e.getAllEdges(),_.filter((function(t){return t.data.layout})).forEach((function(t){var e=I(t),r=R(t),n=e+2*k(t),o=e+2*r,i=t.data.layer;x(i)?E.addNode({id:t.id,data:{width:n,height:o,layer:i}}):E.addNode({id:t.id,data:{width:n,height:o}})})),D.forEach((function(t){W.layoutNode(E.getNode(t.source))&&W.layoutNode(E.getNode(t.target))&&E.addEdge({id:t.id,source:t.source,target:t.target,data:{weight:t.data.weight||1}})})),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),n=o.getNode(t.id);void 0!==n?(e.data.fixorder=n.data._order,delete n.data._order):delete e.data.fixorder})));var h=function(t){var e=new l({tree:[]});return t.getAllNodes().forEach((function(r){var o=fr(t.getNode(r.id).data),i=n(n({},Xe),o),a=lr(i,Je);e.hasNode(r.id)||e.addNode({id:r.id,data:n({},a)});var s=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=fr(t.getEdge(r.id).data),o={};null==tr||tr.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({},Ze,lr(n,Qe),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{Ye(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)}(E,{prevGraph:null,edgeLabelSpace:p,keepNodeOrder:!!v,nodeOrder:v||[],acyclicer:"greedy",ranker:"network-simplex",rankdir:d,nodesep:c,align:s}),O=[0,0],y&&(P=1/0,T=1/0,E.getAllNodes().forEach((function(t){P>t.data.x&&(P=t.data.x),T>t.data.y&&(T=t.data.y)})),E.getAllEdges().forEach((function(t){var e;null===(e=t.data.points)||void 0===e||e.forEach((function(t){P>t.x&&(P=t.x),T>t.y&&(T=t.y)}))})),O[0]=y[0]-P,O[1]=y[1]-T),z="LR"===d||"RL"===d,w||(C=new Set,L="BT"===d||"RL"===d?function(t,e){return e-t}:function(t,e){return t-e},E.getAllNodes().forEach((function(t){t.data.x=t.data.x+O[0],t.data.y=t.data.y+O[1],C.add(z?t.data.x:t.data.y)})),q=Array.from(C).sort(L),j=z?function(t,e){return t.x!==e.x}:function(t,e){return t.y!==e.y},F=z?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}))},E.getAllEdges().forEach((function(t,e){var r;p&&m&&"loop"!==t.data.type&&(t.data.controlPoints=vr(null===(r=t.data.points)||void 0===r?void 0:r.map((function(t){var e=t.x,r=t.y;return{x:e+O[0],y:r+O[1]}})),E.getNode(t.source),E.getNode(t.target),q,z,j,F))}))),V=[],V=E.getAllNodes().map((function(t){return b(t)})),G=E.getAllEdges(),t&&(V.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),G.forEach((function(t){e.mergeEdgeData(t.id,{controlPoints:t.data.controlPoints})}))),[2,{nodes:V,edges:G}]}))}))},t}(),vr=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};function yr(t){var e=0,r=0,n=0;if(t.length){for(var o=0;o<4;o++)(i=t[o])&&i.weight&&(e+=i.weight,r+=i.x*i.weight,n+=i.y*i.weight);t.x=r/e,t.y=n/e,t.weight=e}else{var i=t;t.x=i.data.x,t.y=i.data.y,t.weight=i.data.weight}}var mr=function(t,e,r,n,o,i){var a=i.x-t.x||.1,s=i.y-t.y||.1,u=n-e,d=a*a+s*s,h=Math.sqrt(d)*d;if(u*u*.81<d){var c=t.weight/h;return i.vx+=a*c,i.vy+=s*c,!0}if(t.length)return!1;t.data!==i&&(c=t.data.weight/h,i.vx+=a*c,i.vy+=s*c)},wr={maxIteration:500,gravity:10,factor:1,edgeStrength:200,nodeStrength:1e3,coulombDisScale:.005,damping:.9,maxSpeed:500,minMovement:.4,interval:.02,linkDistance:200,clusterNodeStrength:20,preventOverlap:!0,distanceThresholdMode:"mean"},xr=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({},wr),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})})),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,v,y,m,w,E,b,N,M,S,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.width,h=u.height,c=u.nodeSize,f=u.getMass,g=u.nodeStrength,p=u.edgeStrength,v=u.linkDistance,y=i.map((function(t){return n(n({},t),{data:n(n({},t.data),{x:x(t.data.x)?t.data.x:Math.random()*d,y:x(t.data.y)?t.data.y:Math.random()*h,size:c(t)||30,mass:f(t),nodeStrength:g(t)})})})),m=s.map((function(t){return n(n({},t),{data:n(n({},t.data),{edgeStrength:p(t),linkDistance:v(t,e.getNode(t.source),e.getNode(t.target))})})})),(null==i?void 0:i.length)?(w={},i.forEach((function(t,e){w[t.id]={x:0,y:0}})),E=new l({nodes:y,edges:m}),this.formatCentripetal(u,E),b=u.maxIteration,N=u.minMovement,M=u.onTick,this.lastLayoutNodes=y,this.lastLayoutEdges=m,this.lastAssign=t,this.lastGraph=e,this.lastCalcGraph=E,this.lastOptions=u,this.lastVelMap=w,"undefined"==typeof window?[2]:(S=0,[2,new Promise((function(r){k.timeInterval=window.setInterval((function(){i&&k.running||r({nodes:Sr(e,y),edges:s}),k.runOneStep(E,e,S,w,u),k.updatePosition(e,E,w,u),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),null==M||M({nodes:Sr(e,y),edges:s}),(++S>=b||k.judgingDistance<N)&&(window.clearInterval(k.timeInterval),r({nodes:Sr(e,y),edges:s}))}),0),k.running=!0}))])):(this.lastResult={nodes:[],edges:s},[2,{nodes:[],edges:s}])}))}))},t.prototype.formatOptions=function(t,e){var r=t,n=t.width,o=t.height,i=t.getMass;if(r.width=n||"undefined"==typeof window?n:window.innerWidth,r.height=o||"undefined"==typeof window?o:window.innerHeight,t.center||(r.center=[r.width/2,r.height/2]),i||(r.getMass=function(t){var r=1;x(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}),t.preventOverlap){var a=S(0,t.nodeSpacing);t.nodeSize?g(t.nodeSize)?r.nodeSize=function(e){var r=t.nodeSize;return Math.max(r[0],r[1])+a(e)}:r.nodeSize=function(e){return t.nodeSize+a(e)}:r.nodeSize=function(t){var e=((null==t?void 0:t.data)||{}).size;return e?g(e)?Math.max(e[0],e[1])+a(t):M(e)?Math.max(e.width,e.height)+a(t):e+a(t):10+a(t)}}return r.linkDistance=t.linkDistance?S(1,t.linkDistance):function(t){return 1+r.nodeSize(e.getNode(t.source))+r.nodeSize(e.getNode(t.target))},r.nodeStrength=S(1,t.nodeStrength),r.edgeStrength=S(1,t.edgeStrength),t},t.prototype.formatCentripetal=function(t,e){var r,n=t.centripetalOptions,o=t.center,i=t.clusterNodeStrength,a=t.leafCluster,s=t.clustering,u=t.nodeClusterBy,d=e.getAllNodes(),h=n||{leaf:2,single:2,others:1,center:function(t){return{x:o[0],y:o[1]}}};"function"!=typeof i&&(t.clusterNodeStrength=function(t){return i});var c=[];if(a&&u&&(r=Er(e,u),c=Array.from(new Set(null==d?void 0:d.map((function(t){return t.data[u]}))))||[],t.centripetalOptions=Object.assign(h,{single:100,leaf:function(e){var n=r[e.id]||{},o=n.siblingLeaves,i=n.sameTypeLeaves;return(null==i?void 0:i.length)===(null==o?void 0:o.length)||1===(null==c?void 0:c.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};if(1===o){var i=(r[t.id]||{}).sameTypeLeaves,a=void 0===i?[]:i;1===a.length?n=void 0:a.length>1&&(n=Mr(a))}else n=void 0;return{x:null==n?void 0:n.x,y:null==n?void 0:n.y}}})),s&&u){r||(r=Er(e,u)),c||(c=Array.from(new Set(d.map((function(t){return t.data[u]}))))),c=c.filter((function(t){return void 0!==t}));var l={};c.forEach((function(t){var r=d.filter((function(e){return e.data[u]===t})).map((function(t){return e.getNode(t.id)}));l[t]=Mr(r)})),t.centripetalOptions=Object.assign(h,{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=l[t.data[u]];return{x:null==e?void 0:e.x,y:null==e?void 0:e.y}}})}var f=t.centripetalOptions||{},g=f.leaf,p=f.single,v=f.others;g&&"function"!=typeof g&&(t.centripetalOptions.leaf=function(){return g}),p&&"function"!=typeof p&&(t.centripetalOptions.single=function(){return p}),v&&"function"!=typeof v&&(t.centripetalOptions.others=function(){return v})},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),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){if(!(null==e?void 0:e.length))return 0;var r=0;return e.forEach((function(e,n){var o=t[e.id].x,i=t[e.id].y,a=o*o+i*i,s=e.data.mass;r+=(void 0===s?1:s)*a*.5})),r},t.prototype.calRepulsive=function(t,e,r){var n=r.factor,o=r.coulombDisScale;!function(t,e,r,n){var o=e/r,i=t.getAllNodes(),a=i.map((function(t,e){var r=t.data,n=r.nodeStrength;return{x:r.x,y:r.y,size:r.size,index:e,vx:0,vy:0,weight:o*n}})),s=F(a,(function(t){return t.x}),(function(t){return t.y})).visitAfter(yr);a.forEach((function(t){!function(t,e){e.visit((function(e,r,n,o,i){return mr(e,r,n,o,i,t)}))}(t,s)})),a.map((function(t,e){var r=i[e],o=r.id,a=r.data.mass,s=void 0===a?1:a;n[o]={x:t.vx/s,y:t.vy/s}}))}(t,n,o*o,e)},t.prototype.calAttractive=function(t,e){t.getAllEdges().forEach((function(r,n){var o=r.source,i=r.target,a=t.getNode(o),s=t.getNode(i);if(a&&s){var u=s.data.x-a.data.x,d=s.data.y-a.data.y;u||d||(u=.01*Math.random(),d=.01*Math.random());var h=Math.sqrt(u*u+d*d),c=u/h,l=d/h,f=r.data||{},g=f.linkDistance,p=void 0===g?200:g,v=f.edgeStrength,y=(p-h)*(void 0===v?200:v),m=1/(a.data.mass||1),w=1/(s.data.mass||1),x=c*y,E=l*y;e[o].x-=x*m,e[o].y-=E*m,e[i].x+=x*w,e[i].y+=E*w}}))},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,v=g.x,y=g.y,m=e.getNode(i),w=0,E=0,b=l,N=t.getDegree(i,"in"),M=t.getDegree(i,"out"),S=t.getDegree(i,"both"),k=null==o?void 0:o(m,S);if(k){var A=s(k,3);w=v-A[0],E=y-A[1],b=A[2]}else w=v-c[0],E=y-c[1];if(b&&(r[i].x-=b*w/p,r[i].y-=b*E/p),f){var R=f.leaf,I=f.single,_=f.others,D=f.center,O=(null==D?void 0:D(m,a,u,d,h))||{x:0,y:0,centerStrength:0},P=O.x,T=O.y,z=O.centerStrength;if(!x(P)||!x(T))return;var C=(v-P)/p,L=(y-T)/p;if(z&&(r[i].x-=z*C,r[i].y-=z*L),0===S){var q=I(m);if(!q)return;return r[i].x-=q*C,void(r[i].y-=q*L)}if(0===N||0===M){var j=R(m,a,u);if(!j)return;return r[i].x-=j*C,void(r[i].y-=j*L)}var F=_(m);if(!F)return;r[i].x-=F*C,r[i].y-=F*L}}))},t.prototype.updateVelocity=function(t,e,r,n){var o=n.damping,i=n.maxSpeed,a=n.interval,s=t.getAllNodes();(null==s?void 0:s.length)&&s.forEach((function(t){var n=t.id,s=(r[n].x+e[n].x*a)*o||.01,u=(r[n].y+e[n].y*a)*o||.01,d=Math.sqrt(s*s+u*u);if(d>i){var h=i/d;s*=h,u*=h}r[n]={x:s,y:u}}))},t.prototype.updatePosition=function(t,e,r,n){var o=this,i=n.distanceThresholdMode,a=n.interval,s=e.getAllNodes();if(null==s?void 0:s.length){var u=0;"max"===i?this.judgingDistance=-1/0:"min"===i&&(this.judgingDistance=1/0),s.forEach((function(n){var s=n.id,d=t.getNode(s);if(x(d.data.fx)&&x(d.data.fy))e.mergeNodeData(s,{x:d.data.fx,y:d.data.fy});else{var h=r[s].x*a,c=r[s].y*a;e.mergeNodeData(s,{x:n.data.x+h,y:n.data.y+c});var l=Math.sqrt(h*h+c*c);switch(i){case"max":o.judgingDistance<l&&(o.judgingDistance=l);break;case"min":o.judgingDistance>l&&(o.judgingDistance=l);break;default:u+=l}}})),i&&"mean"!==i||(this.judgingDistance=u/s.length)}else this.judgingDistance=0},t}(),Er=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]=br(t,"leaf",r,e))})),n},br=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:Nr(t,e,n,r,s)}},Nr=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},Mr=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}},Sr=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})})}))},kr=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 Ar=kr;const Rr=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}(),Ir=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 _r={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},Dr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="forceAtlas2",this.options=n(n({},_r),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,N,M,S,k,A,I;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,R(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,N=x.target,M=y.getDegree(E),S=y.getDegree(E),M<=1?(k=y.getNode(N),y.mergeNodeData(E,{x:k.data.x,y:k.data.y})):S<=1&&(A=y.getNode(E),y.mergeNodeData(N,{x:A.data.x,y:A.data.y}));I=n(n({},s),{prune:!1,barnesHut:!1}),this.run(y,e,100,m,t,I)}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,x(h.size))o[d]=h.size;else if(g(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(M(h.size))o[d]=Math.max(h.size.width,h.size.height);else if(N(r)){var c=r(e.getNode(d));g(c)?o[d]=Math.max.apply(Math,u([],s(c))):o[d]=c}else g(r)?o[d]=Math.max.apply(Math,u([],s(r))):x(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 Ar(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 Rr({xmid:(h+d)/2,ymid:(l+c)/2,length:y,massCenter:i,mass:u}),w=new Ir(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,v=0;v<h;v+=1){var y=d[v].id,m=t.getDegree(y);if(!(s&&m<=1)){var w=[e[y][0]-r[y][0],e[y][1]-r[y][1]],E=Math.hypot(w[0],w[1]),b=[e[y][0]+r[y][0],e[y][1]+r[y][1]],N=Math.hypot(b[0],b[1]);c[v]=E,l[v]=N/2,f+=(m+1)*c[v],g+=(m+1)*l[v]}}var M=p;for(p=a*g/f,0!==M&&(p=p>1.5*M?1.5*M:p),v=0;v<h;v+=1){var S=d[v],k=(y=S.id,S.data);if(m=t.getDegree(y),!(s&&m<=1||x(k.fx)&&x(k.fy))){var A=i*p/(1+p*Math.sqrt(c[v])),R=Math.hypot(e[y][0],e[y][1]),I=u/(R=R<1e-4?1e-4:R),_=(A=A>I?I:A)*e[y][0],D=A*e[y][1];t.mergeNodeData(y,{x:k.x+_,y:k.y+D})}}return p},t}(),Or={maxIteration:1e3,gravity:10,speed:5,clustering:!1,clusterGravity:10,width:300,height:300,nodeClusterBy:"cluster"},Pr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="fruchterman",this.timeInterval=0,this.running=!1,this.options=n(n({},Or),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})})),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=this;return a(this,(function(a){return this.running?[2]:(o=this.formatOptions(r),i=o.width,s=o.height,u=o.center,d=o.clustering,h=o.nodeClusterBy,c=o.maxIteration,f=o.onTick,g=e.getAllNodes(),p=e.getAllEdges(),(null==g?void 0:g.length)?1===g.length?(t&&e.mergeNodeData(g[0].id,{x:u[0],y:u[1]}),v={nodes:[n(n({},g[0]),{data:n(n({},g[0].data),{x:u[0],y:u[1]})})],edges:p},this.lastResult=v,[2,v]):(y=g.map((function(t){return b(t,[i,s])})),m=new l({nodes:y,edges:p}),w={},d&&y.forEach((function(t){var e=t.data[h];w[e]||(w[e]={name:e,cx:0,cy:0,count:0})})),this.lastLayoutNodes=y,this.lastLayoutEdges=p,this.lastAssign=t,this.lastGraph=m,this.lastOptions=o,this.lastClusterMap=w,"undefined"==typeof window?[2]:(x=0,[2,new Promise((function(r){E.timeInterval=window.setInterval((function(){E.running?(E.runOneStep(m,w,o),t&&y.forEach((function(t){var r=t.id,n=t.data;return e.mergeNodeData(r,{x:n.x,y:n.y})})),null==f||f({nodes:y,edges:p}),++x>=c&&(window.clearInterval(E.timeInterval),r({nodes:y,edges:p}))):r({nodes:y,edges:p})}),0),E.running=!0}))])):(v={nodes:[],edges:p},this.lastResult=v,[2,v]))}))}))},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.height,o=r.width,i=r.gravity,a=r.center,s=r.speed,u=r.clustering,d=r.nodeClusterBy,h=r.clusterGravity,c=n*o,l=Math.sqrt(c)/10,f=t.getAllNodes(),g=c/(f.length+1),p=Math.sqrt(g),v={};if(this.applyCalculate(t,v,p,g),u){for(var y in e)e[y].cx=0,e[y].cy=0,e[y].count=0;for(var y in f.forEach((function(t){var r=t.data,n=e[r[d]];x(r.x)&&(n.cx+=r.x),x(r.y)&&(n.cy+=r.y),n.count++})),e)e[y].cx/=e[y].count,e[y].cy/=e[y].count;var m=h||i;f.forEach((function(t,r){var n=t.id,o=t.data;if(x(o.x)&&x(o.y)){var i=e[o[d]],a=Math.sqrt((o.x-i.cx)*(o.x-i.cx)+(o.y-i.cy)*(o.y-i.cy)),s=p*m;v[n].x-=s*(o.x-i.cx)/a,v[n].y-=s*(o.y-i.cy)/a}}))}f.forEach((function(t,e){var r=t.id,n=t.data;if(x(n.x)&&x(n.y)){var o=.01*p*i;v[r].x-=o*(n.x-a[0]),v[r].y-=o*(n.y-a[1])}})),f.forEach((function(e,r){var n=e.id,o=e.data;if(x(o.fx)&&x(o.fy))return o.x=o.fx,void(o.y=o.fy);if(x(o.x)&&x(o.y)){var i=Math.sqrt(v[n].x*v[n].x+v[n].y*v[n].y);if(i>0){var a=Math.min(l*(s/800),i);t.mergeNodeData(n,{x:o.x+v[n].x/i*a,y:o.y+v[n].y/i*a})}}}))},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=t.getAllNodes();n.forEach((function(t,o){var i=t.data,a=t.id;e[a]={x:0,y:0},n.forEach((function(t,n){var s=t.data,u=t.id;if(!(o<=n)&&x(i.x)&&x(s.x)&&x(i.y)&&x(s.y)){var d=i.x-s.x,h=i.y-s.y,c=d*d+h*h;0===c&&(c=1,d=.01,h=.01);var l=r/c,f=d*l,g=h*l;e[a].x+=f,e[a].y+=g,e[u].x-=f,e[u].y-=g}}))}))},t.prototype.calAttractive=function(t,e,r){t.getAllEdges().forEach((function(n){var o=n.source,i=n.target;if(o&&i&&o!==i){var a=t.getNode(o).data,s=t.getNode(i).data;if(x(s.x)&&x(a.x)&&x(s.y)&&x(a.y)){var u=s.x-a.x,d=s.y-a.y,h=Math.sqrt(u*u+d*d)/r,c=u*h,l=d*h;e[o].x+=c,e[o].y+=l,e[i].x-=c,e[i].y-=l}}}))},t}(),Tr={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},zr=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=n(n({},Tr),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,p,v,y,m,w,E,N,M,A,I,_,D,O,T,z,C,L,q,j,F,V,G,W,B,$,U,H,K;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,p=o.nodeSize,v=o.width,y=o.height,m=o.position,w=o.sortBy,E=e.getAllNodes(),N=e.getAllEdges(),!(M=null==E?void 0:E.length)||1===M)return[2,R(e,t,s)];if(A=E.map((function(t){return b(t)})),"id"===w||P(w)&&void 0!==A[0].data[w]||(w="degree"),"degree"===w?A.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===w?A.sort((function(t,e){return x(e.id)&&x(t.id)?e.id-t.id:(""+t.id).localeCompare(""+e.id)})):A.sort((function(t,e){return e.data[w]-t.data[w]})),I=v||"undefined"==typeof window?v:window.innerWidth,_=y||"undefined"==typeof window?y:window.innerHeight,D=M,O={rows:c,cols:l},null!=c&&null!=l?(O.rows=c,O.cols=l):null!=c&&null==l?(O.rows=c,O.cols=Math.ceil(D/O.rows)):null==c&&null!=l?(O.cols=l,O.rows=Math.ceil(D/O.cols)):(T=Math.sqrt(D*_/I),O.rows=Math.round(T),O.cols=Math.round(I/_*T)),O.rows=Math.max(O.rows,1),O.cols=Math.max(O.cols,1),O.cols*O.rows>D)z=Cr(O),C=Lr(O),(z-1)*C>=D?Cr(O,z-1):(C-1)*z>=D&&Lr(O,C-1);else for(;O.cols*O.rows<D;)z=Cr(O),((C=Lr(O))+1)*z>=D?Lr(O,C+1):Cr(O,z+1);for(L=u?0:I/O.cols,q=u?0:_/O.rows,(h||f)&&(j=S(10,f),F=k(30,p,!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=F(o)||30;g(i)?(r=i[0],n=i[1]):(r=i,n=i);var a=void 0!==j?j(t):d,s=r+a,u=n+a;L=Math.max(L,s),q=Math.max(q,u)}))),V={},G={row:0,col:0},W={},B=0;B<A.length;B++){if($=A[B],U=void 0,m&&(U=m(e.getNode($.id))),U&&(void 0!==U.row||void 0!==U.col)){if(void 0===(H={row:U.row,col:U.col}).col)for(H.col=0;qr(V,H);)H.col++;else if(void 0===H.row)for(H.row=0;qr(V,H);)H.row++;W[$.id]=H,jr(V,H)}Vr($,s,L,q,W,O,G,V)}return K={nodes:A,edges:N},t&&A.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,K]}))}))},t}(),Cr=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},Lr=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},qr=function(t,e){return t["c-"+e.row+"-"+e.col]||!1},jr=function(t,e){return t["c-"+e.row+"-"+e.col]=!0},Fr=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},Vr=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(;qr(s,a);)Fr(i,a);u=a.col*r+r/2+e[0],d=a.row*n+n/2+e[1],jr(s,a),Fr(i,a)}t.data.x=u,t.data.y=d};const Gr=Object.prototype.toString;function Wr(t){return Gr.call(t).endsWith("Array]")}function Br(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!Wr(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(!Wr(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(!Wr(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(!Wr(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 $r=" ".repeat(2),Ur=" ".repeat(4);function Hr(t,e={}){const{maxRows:r=15,maxColumns:n=10,maxNumSize:o=8,padMinus:i="auto"}=e;return`${t.constructor.name} {\n${$r}[\n${Ur}${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(Kr(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${Ur}`)}(t,r,n,o,i)}\n${$r}]\n${$r}rows: ${t.rows}\n${$r}columns: ${t.columns}\n}`}function Kr(t,e,r){return(t>=0&&r?` ${Yr(t,e-1)}`:Yr(t,e)).padEnd(e)}function Yr(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 Jr(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 Xr(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 Qr(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 Zr(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 tn(t,e,r,n,o){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(rn("startRow",e),rn("endRow",r),rn("startColumn",n),rn("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 en(t,e=0){let r=[];for(let n=0;n<t;n++)r.push(e);return r}function rn(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function nn(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class on{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let n=new sn(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 sn(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 sn(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 sn(t,e)}static ones(t,e){return new sn(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 sn(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 sn(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 sn(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 on.isMatrix(t)?t:new sn(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 sn(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){Jr(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return sn.rowVector(this.getRow(t))}setRow(t,e){Jr(this,t),e=Qr(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){Jr(this,t),Jr(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){Xr(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return sn.columnVector(this.getColumn(t))}setColumn(t,e){Xr(this,t),e=Zr(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){Xr(this,t),Xr(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=Qr(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=Qr(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=Qr(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=Qr(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=Zr(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=Zr(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=Zr(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=Zr(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){Jr(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){Xr(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(){nn(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(){nn(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(Jr(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){Jr(this,t),nn(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(Jr(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){Jr(this,t),nn(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(Xr(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){Xr(this,t),nn(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(Xr(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){Xr(this,t),nn(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){on.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=sn.checkMatrix(t);let e=this.rows,r=this.columns,n=t.columns,o=new sn(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=sn.checkMatrix(t);let e=new sn(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=sn.checkMatrix(t);let e=new sn(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),R=(o-h)*(p-m),I=o*y,_=(d+h)*(-y+m),D=(-o+a+s)*(v+y-w),O=(o-s)*(v-w),P=(a+s)*(-y+w),T=N+I+n*g,z=(r+n+o-i-a-d-h)*p+E+b+N+A+I+_,C=N+M+k+(r+n+o-a-s-u-d)*v+I+D+P,L=x+a*(-c+l+g-p-v-y+w)+E+N+I+D+O,q=x+E+b+N+s*m,j=I+D+O+P+i*f,F=N+M+S+d*(-c+f+g-p-v-y+m)+A+R+I,V=A+R+I+_+u*l,G=N+M+S+k+h*w;return e.set(0,0,T),e.set(0,1,z),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,G),e}mmulStrassen(t){t=sn.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=on.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(on.add(u,g),on.add(d,p),i,s),y=t(on.add(l,g),d,i,s),m=t(u,on.sub(c,p),i,s),w=t(g,on.sub(f,d),i,s),x=t(on.add(u,h),p,i,s),E=t(on.sub(l,u),on.add(d,c),i,s),b=t(on.sub(h,g),on.add(f,p),i,s),N=on.add(v,w);N.sub(x),N.add(b);let M=on.add(m,x),S=on.add(y,w),k=on.sub(v,y);k.add(m),k.add(E);let A=on.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 sn(this.rows,this.columns);for(let t=0;t<this.rows;t++){const o=this.getRow(t);o.length>0&&Br(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 sn(this.rows,this.columns);for(let t=0;t<this.columns;t++){const o=this.getColumn(t);o.length&&Br(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=sn.checkMatrix(t);let e=this.rows,r=this.columns,n=t.rows,o=t.columns,i=new sn(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=sn.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(sn.eye(r,r)),o=sn.eye(e,e).kroneckerProduct(t);return n.add(o)}transpose(){let t=new sn(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=an){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=an){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,n){tn(this,t,e,r,n);let o=new sn(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 sn(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 sn(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=sn.checkMatrix(t)).isEmpty())return this;tn(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(!Wr(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(!Wr(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 sn(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 sn(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=en(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=en(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=en(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=en(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(!Wr(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(!Wr(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(!Wr(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(!Wr(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(!Wr(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(!Wr(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 Hr(this,t)}}function an(t,e){return t-e}on.prototype.klass="Matrix","undefined"!=typeof Symbol&&(on.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return Hr(this)}),on.random=on.rand,on.randomInt=on.randInt,on.diagonal=on.diag,on.prototype.diagonal=on.prototype.diag,on.identity=on.eye,on.prototype.negate=on.prototype.neg,on.prototype.tensorProduct=on.prototype.kroneckerProduct;class sn extends on{constructor(t,e){if(super(),sn.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(!Wr(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 Jr(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),Jr(this,t,!0),e=Float64Array.from(Qr(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){Xr(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),Xr(this,t,!0),e=Zr(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}}(on,sn);class un extends on{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 dn(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 hn{constructor(t,e={}){if((t=un.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 sn(r,c),p=new sn(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]=dn(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]=dn(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=dn(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=dn(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=dn(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=dn(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=sn.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=sn.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(sn.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,n=t.columns,o=new sn(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 sn(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 sn.diag(this.s)}}var cn,ln={center:[0,0],linkDistance:50},fn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=n(n({},ln),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,y;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=v({nodes:h,edges:c},!1),f=p(l),gn(f),m=d,w=[],f.forEach((function(t){var e=[];t.forEach((function(t){e.push(t*m)})),w.push(e)})),g=pn(w),y=[],g.forEach((function(t,e){var r=b(h[e]);r.data.x=t[0]+s[0],r.data.y=t[1]+s[1],y.push(r)})),t&&y.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:y,edges:c}]):[2,R(e,t,s)];var m,w}))}))},t}(),gn=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)}))}))},pn=function(t){var e=sn.mul(sn.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 hn(e),a=sn.sqrt(i.diagonalMatrix).diagonal();return i.leftSingularVectors.toJSON().map((function(t){return sn.mul([t],[a]).toJSON()[0].splice(0,2)}))},vn={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},yn=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}}}))}))},mn=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},wn={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,strictRadial:!0,maxPreventOverlapIteration:200,sortStrength:10},xn=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=n(n({},wn),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,y,m,w,x,E,N,M,S,k,I,_,D,O,T,z,C,L,q,j,F,V,G,W,B,$,U,H,K,Y,J,X,Q,Z,tt,et;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,y=o.strictRadial,m=o.preventOverlap,w=o.maxPreventOverlapIteration,x=o.sortBy,E=o.linkDistance,N=void 0===E?50:E,M=o.sortStrength,S=void 0===M?10:M,k=o.maxIteration,I=void 0===k?1e3:k,_=e.getAllNodes(),D=e.getAllEdges(),O=i||"undefined"==typeof window?i:window.innerWidth,T=d||"undefined"==typeof window?d:window.innerHeight,z=h||[O/2,T/2],!(null==_?void 0:_.length)||1===_.length)return[2,R(e,t,z)];if(C=_[0],P(c)){for(L=0;L<_.length;L++)if(_[L].id===c){C=_[L];break}}else C=c||_[0];return q=Nn(_,C.id),j=v({nodes:_,edges:D},!1),F=p(j),V=Sn(F,q),Mn(F,q,V+1),G=F[q],W=O-z[0]>z[0]?z[0]:O-z[0],B=T-z[1]>z[1]?z[1]:T-z[1],0===W&&(W=O/2),0===B&&(B=T/2),$=Math.min(W,B),U=Math.max.apply(Math,u([],s(G))),H=[],K=l||$/U,G.forEach((function(t,e){H[e]=t*K})),Y=En(_,F,N,H,K,x,S),J=bn(Y),X=function(t,e,r){try{var n=sn.mul(sn.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 hn(n),u=sn.sqrt(s.diagonalMatrix).diagonal();return s.leftSingularVectors.toJSON().map((function(e){return sn.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}}(N,Y,N),Q=X.map((function(t){var e=s(t,2),r=e[0],n=e[1];return{x:(isNaN(r)?Math.random()*N:r)-X[q][0],y:(isNaN(n)?Math.random()*N:n)-X[q][1]}})),this.run(I,Q,J,Y,H,q),m&&(Z=A(f,g),tt={nodes:_,nodeSizeFunc:Z,positions:Q,radii:H,height:T,width:O,strictRadial:Boolean(y),focusIdx:q,iterations:w||200,k:Q.length/4.5},Q=function(t,e){for(var r=n(n({},vn),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}})),yn(p,o,v,s,f,g),mn(o,v,d,h,c,y,a,f);return o}(e,tt)),et=[],Q.forEach((function(t,e){var r=b(_[e]);r.data.x=t.x+z[0],r.data.y=t.y+z[1],et.push(r)})),t&&et.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),[2,{nodes:et,edges:D}]}))}))},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=y(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=y(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}(),En=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=P(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=P(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},bn=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},Nn=function(t,e){var r=-1;return t.forEach((function(t,n){t.id===e&&(r=n)})),Math.max(r,0)},Mn=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}},Sn=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},kn={center:[0,0],width:300,height:300},An=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=n(n({},kn),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}(),Rn={circular:_,concentric:z,mds:fn,random:An,grid:zr,radial:xn,force:xr,d3force:zt,fruchterman:Pr,forceAtlas2:Dr,dagre:pr};function In(){var t;(null===(t=cn)||void 0===t?void 0:t.stop)&&cn.stop()}function _n(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=Rn[n]))throw new Error("Unknown layout id: "+n);return[4,(cn=new h(o)).execute(d)];case 1:return c=a.sent(),!!(f=cn).tick&&!!f.stop&&(cn.stop(),c=cn.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=c1c68049e416ee50a3be.worker.js.map