@antv/layout 1.0.0-alpha.5 → 1.0.0-alpha.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a3736fcd924e7b5b918c.worker.js +2 -0
- package/dist/a3736fcd924e7b5b918c.worker.js.map +1 -0
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/esm/a3736fcd924e7b5b918c.worker.js +2 -0
- package/esm/a3736fcd924e7b5b918c.worker.js.map +1 -0
- package/esm/index.esm.js +1 -1
- package/esm/index.esm.js.map +1 -1
- package/lib/d3Force/forceInBox.d.ts +28 -0
- package/lib/d3Force/index.d.ts +41 -0
- package/lib/force/forceNBody.d.ts +7 -0
- package/lib/force/index.d.ts +125 -0
- package/lib/force/types.d.ts +42 -0
- package/lib/index.d.ts +2 -0
- package/lib/types.d.ts +10 -9
- package/lib/util/function.d.ts +3 -3
- package/lib/util/gpu.d.ts +0 -7
- package/lib/util/math.d.ts +8 -5
- package/lib/worker.d.ts +1 -2
- package/package.json +3 -1
- package/dist/dc35eb8f009986ba5391.worker.js +0 -2
- package/dist/dc35eb8f009986ba5391.worker.js.map +0 -1
- package/esm/dc35eb8f009986ba5391.worker.js +0 -2
- package/esm/dc35eb8f009986ba5391.worker.js.map +0 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
interface INode {
|
|
2
|
+
id: string;
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
vx: number;
|
|
6
|
+
vy: number;
|
|
7
|
+
cluster: any;
|
|
8
|
+
}
|
|
9
|
+
export default function forceInBox(): {
|
|
10
|
+
(alpha: number): any | undefined;
|
|
11
|
+
initialize(_: any): void;
|
|
12
|
+
template: (x: any) => string | any;
|
|
13
|
+
groupBy: (x: any) => ((d: INode) => any) | any;
|
|
14
|
+
enableGrouping: (x: any) => boolean | any;
|
|
15
|
+
strength: (x: any) => number | any;
|
|
16
|
+
centerX: (_: any) => number | any;
|
|
17
|
+
centerY: (_: any) => number | any;
|
|
18
|
+
nodes: (_: any) => INode[] | any;
|
|
19
|
+
links: (_: any) => any[] | any;
|
|
20
|
+
forceNodeSize: (_: any) => ((d: any) => number) | any;
|
|
21
|
+
nodeSize: (_: any) => ((d: any) => number) | any;
|
|
22
|
+
forceCharge: (_: any) => ((d: any) => number) | any;
|
|
23
|
+
forceLinkDistance: (_: any) => ((d: any) => number) | any;
|
|
24
|
+
forceLinkStrength: (_: any) => ((d: any) => number) | any;
|
|
25
|
+
offset: (_: any) => number[] | any;
|
|
26
|
+
getFocis: () => any;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Graph, Node, LayoutMapping, D3ForceLayoutOptions, SyncLayout } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Layout the nodes' positions with d3's basic classic force
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* // Assign layout options when initialization.
|
|
7
|
+
* const layout = new D3ForceLayout({ center: [100, 100] });
|
|
8
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
9
|
+
*
|
|
10
|
+
* // Or use different options later.
|
|
11
|
+
* const layout = new D3ForceLayout({ center: [100, 100] });
|
|
12
|
+
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
13
|
+
*
|
|
14
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
15
|
+
* layout.assign(graph, { center: [100, 100] });
|
|
16
|
+
*/
|
|
17
|
+
export declare class D3ForceLayout implements SyncLayout<D3ForceLayoutOptions> {
|
|
18
|
+
options: D3ForceLayoutOptions;
|
|
19
|
+
id: string;
|
|
20
|
+
constructor(options?: D3ForceLayoutOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Return the positions of nodes and edges(if needed).
|
|
23
|
+
*/
|
|
24
|
+
execute(graph: Graph, options?: D3ForceLayoutOptions): LayoutMapping;
|
|
25
|
+
/**
|
|
26
|
+
* To directly assign the positions to the nodes.
|
|
27
|
+
*/
|
|
28
|
+
assign(graph: Graph, options?: D3ForceLayoutOptions): void;
|
|
29
|
+
/** The sign of running */
|
|
30
|
+
private running;
|
|
31
|
+
private genericForceLayout;
|
|
32
|
+
/**
|
|
33
|
+
* Prevent overlappings.
|
|
34
|
+
* @param {object} simulation force simulation of d3
|
|
35
|
+
*/
|
|
36
|
+
overlapProcess(simulation: any, options: {
|
|
37
|
+
nodeSize: number | number[] | ((d?: Node) => number) | undefined;
|
|
38
|
+
nodeSpacing: number | number[] | ((d?: Node) => number) | undefined;
|
|
39
|
+
collideStrength: number;
|
|
40
|
+
}): void;
|
|
41
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Graph, LayoutMapping, ForceLayoutOptions, SyncLayout, Point } from "../types";
|
|
2
|
+
import { CalcGraph, FormatedOptions } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Layout with faster force
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* // Assign layout options when initialization.
|
|
8
|
+
* const layout = new ForceLayout({ center: [100, 100] });
|
|
9
|
+
* const positions = layout.execute(graph); // { nodes: [], edges: [] }
|
|
10
|
+
*
|
|
11
|
+
* // Or use different options later.
|
|
12
|
+
* const layout = new ForceLayout({ center: [100, 100] });
|
|
13
|
+
* const positions = layout.execute(graph, { center: [100, 100] }); // { nodes: [], edges: [] }
|
|
14
|
+
*
|
|
15
|
+
* // If you want to assign the positions directly to the nodes, use assign method.
|
|
16
|
+
* layout.assign(graph, { center: [100, 100] });
|
|
17
|
+
*/
|
|
18
|
+
export declare class ForceLayout implements SyncLayout<ForceLayoutOptions> {
|
|
19
|
+
options: ForceLayoutOptions;
|
|
20
|
+
id: string;
|
|
21
|
+
/**
|
|
22
|
+
* time interval for layout force animations
|
|
23
|
+
*/
|
|
24
|
+
private timeInterval;
|
|
25
|
+
/**
|
|
26
|
+
* compare with minMovement to end the nodes' movement
|
|
27
|
+
*/
|
|
28
|
+
private judgingDistance;
|
|
29
|
+
constructor(options?: ForceLayoutOptions);
|
|
30
|
+
/**
|
|
31
|
+
* Return the positions of nodes and edges(if needed).
|
|
32
|
+
*/
|
|
33
|
+
execute(graph: Graph, options?: ForceLayoutOptions): LayoutMapping;
|
|
34
|
+
/**
|
|
35
|
+
* To directly assign the positions to the nodes.
|
|
36
|
+
*/
|
|
37
|
+
assign(graph: Graph, options?: ForceLayoutOptions): void;
|
|
38
|
+
private genericForceLayout;
|
|
39
|
+
/**
|
|
40
|
+
* Format merged layout options.
|
|
41
|
+
* @param options merged layout options
|
|
42
|
+
* @param graph original graph
|
|
43
|
+
* @returns
|
|
44
|
+
*/
|
|
45
|
+
private formatOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Format centripetalOption in the option.
|
|
48
|
+
* @param options merged layout options
|
|
49
|
+
* @param calcGraph calculation graph
|
|
50
|
+
*/
|
|
51
|
+
private formatCentripetal;
|
|
52
|
+
/**
|
|
53
|
+
* One iteration.
|
|
54
|
+
* @param calcGraph calculation graph
|
|
55
|
+
* @param graph origin graph
|
|
56
|
+
* @param iter current iteration index
|
|
57
|
+
* @param velMap nodes' velocity map
|
|
58
|
+
* @param options formatted layout options
|
|
59
|
+
* @returns
|
|
60
|
+
*/
|
|
61
|
+
private runOneStep;
|
|
62
|
+
/**
|
|
63
|
+
* Calculate graph energy for monitoring convergence.
|
|
64
|
+
* @param accMap acceleration map
|
|
65
|
+
* @param nodes calculation nodes
|
|
66
|
+
* @returns energy
|
|
67
|
+
*/
|
|
68
|
+
private calTotalEnergy;
|
|
69
|
+
/**
|
|
70
|
+
* Calculate the repulsive forces according to coulombs law.
|
|
71
|
+
* @param calcGraph calculation graph
|
|
72
|
+
* @param accMap acceleration map
|
|
73
|
+
* @param options formatted layout options
|
|
74
|
+
*/
|
|
75
|
+
calRepulsive(calcGraph: CalcGraph, accMap: {
|
|
76
|
+
[id: string]: Point;
|
|
77
|
+
}, options: FormatedOptions): void;
|
|
78
|
+
/**
|
|
79
|
+
* Calculate the attractive forces according to hooks law.
|
|
80
|
+
* @param calcGraph calculation graph
|
|
81
|
+
* @param accMap acceleration map
|
|
82
|
+
*/
|
|
83
|
+
calAttractive(calcGraph: CalcGraph, accMap: {
|
|
84
|
+
[id: string]: Point;
|
|
85
|
+
}): void;
|
|
86
|
+
/**
|
|
87
|
+
* Calculate the gravity forces toward center.
|
|
88
|
+
* @param calcGraph calculation graph
|
|
89
|
+
* @param graph origin graph
|
|
90
|
+
* @param accMap acceleration map
|
|
91
|
+
* @param options formatted layout options
|
|
92
|
+
*/
|
|
93
|
+
calGravity(calcGraph: CalcGraph, graph: Graph, accMap: {
|
|
94
|
+
[id: string]: Point;
|
|
95
|
+
}, options: FormatedOptions): void;
|
|
96
|
+
/**
|
|
97
|
+
* Update the velocities for nodes.
|
|
98
|
+
* @param calcGraph calculation graph
|
|
99
|
+
* @param accMap acceleration map
|
|
100
|
+
* @param velMap velocity map
|
|
101
|
+
* @param options formatted layout options
|
|
102
|
+
* @returns
|
|
103
|
+
*/
|
|
104
|
+
updateVelocity(calcGraph: CalcGraph, accMap: {
|
|
105
|
+
[id: string]: Point;
|
|
106
|
+
}, velMap: {
|
|
107
|
+
[id: string]: Point;
|
|
108
|
+
}, options: FormatedOptions): void;
|
|
109
|
+
/**
|
|
110
|
+
* Update nodes' positions.
|
|
111
|
+
* @param graph origin graph
|
|
112
|
+
* @param calcGraph calculatition graph
|
|
113
|
+
* @param velMap velocity map
|
|
114
|
+
* @param options formatted layou options
|
|
115
|
+
* @returns
|
|
116
|
+
*/
|
|
117
|
+
updatePosition(graph: Graph, calcGraph: CalcGraph, velMap: {
|
|
118
|
+
[id: string]: Point;
|
|
119
|
+
}, options: FormatedOptions): void;
|
|
120
|
+
/**
|
|
121
|
+
* Stop the animation for no-silence force.
|
|
122
|
+
* TODO: confirm the controller and worker's controller
|
|
123
|
+
*/
|
|
124
|
+
stop(): void;
|
|
125
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Graph as IGraph, Node as INode, Edge as IEdge } from "@antv/graphlib";
|
|
2
|
+
import { CentripetalOptions, Edge, Node, EdgeData, ForceLayoutOptions, NodeData, PointTuple } from "../types";
|
|
3
|
+
export interface CalcNodeData extends NodeData {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
mass: number;
|
|
7
|
+
nodeStrength: number;
|
|
8
|
+
}
|
|
9
|
+
export type CalcNode = INode<CalcNodeData>;
|
|
10
|
+
export interface CalcEdgeData extends EdgeData {
|
|
11
|
+
linkDistance?: number;
|
|
12
|
+
edgeStrength?: number;
|
|
13
|
+
}
|
|
14
|
+
export type CalcEdge = IEdge<CalcEdgeData>;
|
|
15
|
+
export type CalcGraph = IGraph<CalcNodeData, CalcEdgeData>;
|
|
16
|
+
interface FormatCentripetalOptions extends CentripetalOptions {
|
|
17
|
+
leaf: (node: Node, nodes: Node[], edges: Edge[]) => number;
|
|
18
|
+
/** Force strength for single nodes. */
|
|
19
|
+
single: (node: Node) => number;
|
|
20
|
+
/** Force strength for other nodes. */
|
|
21
|
+
others: (node: Node) => number;
|
|
22
|
+
}
|
|
23
|
+
export interface FormatedOptions extends ForceLayoutOptions {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
center: PointTuple;
|
|
27
|
+
minMovement: number;
|
|
28
|
+
maxIteration: number;
|
|
29
|
+
factor: number;
|
|
30
|
+
interval: number;
|
|
31
|
+
damping: number;
|
|
32
|
+
maxSpeed: number;
|
|
33
|
+
coulombDisScale: number;
|
|
34
|
+
centripetalOptions: FormatCentripetalOptions;
|
|
35
|
+
nodeSize: (d?: Node) => number;
|
|
36
|
+
getMass: (d?: Node) => number;
|
|
37
|
+
nodeStrength: (d?: Node) => number;
|
|
38
|
+
edgeStrength: (d?: Edge) => number;
|
|
39
|
+
linkDistance: (edge?: Edge, source?: any, target?: any) => number;
|
|
40
|
+
clusterNodeStrength: (node?: Node) => number;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
package/lib/index.d.ts
CHANGED
package/lib/types.d.ts
CHANGED
|
@@ -151,13 +151,13 @@ export interface DagreLayoutOptions extends CommonOptions {
|
|
|
151
151
|
}
|
|
152
152
|
export interface D3ForceLayoutOptions extends CommonOptions {
|
|
153
153
|
center?: PointTuple;
|
|
154
|
-
linkDistance?: number | ((
|
|
155
|
-
edgeStrength?: number | ((
|
|
156
|
-
nodeStrength?: number | ((
|
|
154
|
+
linkDistance?: number | ((edge?: Edge) => number) | undefined;
|
|
155
|
+
edgeStrength?: number | ((edge?: Edge) => number) | undefined;
|
|
156
|
+
nodeStrength?: number | ((node: Node, i: number, nodes: Node[]) => number) | undefined;
|
|
157
157
|
preventOverlap?: boolean;
|
|
158
158
|
collideStrength?: number;
|
|
159
|
-
nodeSize?: number | number[] | ((
|
|
160
|
-
nodeSpacing?: number | number[] | ((
|
|
159
|
+
nodeSize?: number | number[] | ((node?: Node) => number) | undefined;
|
|
160
|
+
nodeSpacing?: number | number[] | ((node?: Node) => number) | undefined;
|
|
161
161
|
alpha?: number;
|
|
162
162
|
alphaDecay?: number;
|
|
163
163
|
alphaMin?: number;
|
|
@@ -192,8 +192,8 @@ export interface ForceLayoutOptions extends CommonOptions {
|
|
|
192
192
|
nodeStrength?: number | ((d?: Node) => number) | undefined;
|
|
193
193
|
edgeStrength?: number | ((d?: Edge) => number) | undefined;
|
|
194
194
|
preventOverlap?: boolean;
|
|
195
|
-
nodeSize?: number | number[] | ((d?: Node) => number)
|
|
196
|
-
nodeSpacing?: number |
|
|
195
|
+
nodeSize?: number | number[] | ((d?: Node) => number);
|
|
196
|
+
nodeSpacing?: number | ((d?: Node) => number);
|
|
197
197
|
minMovement?: number;
|
|
198
198
|
maxIteration?: number;
|
|
199
199
|
damping?: number;
|
|
@@ -201,6 +201,7 @@ export interface ForceLayoutOptions extends CommonOptions {
|
|
|
201
201
|
coulombDisScale?: number;
|
|
202
202
|
gravity?: number;
|
|
203
203
|
factor?: number;
|
|
204
|
+
interval?: number;
|
|
204
205
|
centripetalOptions?: CentripetalOptions;
|
|
205
206
|
leafCluster?: boolean;
|
|
206
207
|
clustering?: boolean;
|
|
@@ -210,12 +211,12 @@ export interface ForceLayoutOptions extends CommonOptions {
|
|
|
210
211
|
distanceThresholdMode?: "mean" | "max" | "min";
|
|
211
212
|
animate?: boolean;
|
|
212
213
|
onTick?: (data: LayoutMapping) => void;
|
|
213
|
-
getMass?: ((d
|
|
214
|
+
getMass?: ((d: Node) => number) | undefined;
|
|
214
215
|
getCenter?: ((d?: Node, degree?: number) => number[]) | undefined;
|
|
215
216
|
monitor?: (params: {
|
|
216
217
|
energy: number;
|
|
217
218
|
nodes: Node[];
|
|
218
|
-
|
|
219
|
+
edges: Edge[];
|
|
219
220
|
iterations: number;
|
|
220
221
|
}) => void;
|
|
221
222
|
}
|
package/lib/util/function.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Node } from
|
|
1
|
+
import { Node } from "../types";
|
|
2
2
|
export declare const isFunction: (val: unknown) => val is Function;
|
|
3
3
|
/**
|
|
4
4
|
* Format value with multiple types into a function returns number.
|
|
@@ -6,7 +6,7 @@ export declare const isFunction: (val: unknown) => val is Function;
|
|
|
6
6
|
* @param value value to be formatted
|
|
7
7
|
* @returns formatted result, a function returns number
|
|
8
8
|
*/
|
|
9
|
-
export declare
|
|
9
|
+
export declare function formatNumberFn<T = unknown>(defaultValue: number, value: number | ((d?: T) => number) | undefined): (d?: T | undefined) => number;
|
|
10
10
|
/**
|
|
11
11
|
* Format size config with multiple types into a function returns number
|
|
12
12
|
* @param defaultValue default value when value is invalid
|
|
@@ -17,4 +17,4 @@ export declare const formatNumberFn: (defaultValue: number, value: number | ((d?
|
|
|
17
17
|
export declare function formatSizeFn<T extends Node>(defaultValue: number, value?: number | number[] | {
|
|
18
18
|
width: number;
|
|
19
19
|
height: number;
|
|
20
|
-
} | ((d?: T) => number) | undefined, resultIsNumber?: boolean): (
|
|
20
|
+
} | ((d?: T) => number) | undefined, resultIsNumber?: boolean): (d: T) => number | number[];
|
package/lib/util/gpu.d.ts
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { OutNode, Edge } from "../types";
|
|
2
|
-
/**
|
|
3
|
-
* 将 number | Function 类型的参数转换为 return number 的 Function
|
|
4
|
-
* @param {number | Function} value 需要被转换的值
|
|
5
|
-
* @param {number} defaultV 返回函数的默认返回值
|
|
6
|
-
* @return {Function} 转换后的函数
|
|
7
|
-
*/
|
|
8
|
-
export declare const proccessToFunc: (value: number | Function | undefined, defaultV?: number) => (d?: any) => number;
|
|
9
2
|
/**
|
|
10
3
|
* 将节点和边数据转换为 GPU 可读的数组。并返回 maxEdgePerVetex,每个节点上最多的边数
|
|
11
4
|
* @param {NodeConfig[]} nodes 需要被转换的值
|
package/lib/util/math.d.ts
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { Matrix,
|
|
2
|
-
export declare const getDegree: (n: number, nodeIdxMap: IndexMap, edges: Edge[] | null) => Degree[];
|
|
3
|
-
export declare const getDegreeMap: (nodes: Node[], edges: Edge[] | null) => {
|
|
4
|
-
[id: string]: Degree;
|
|
5
|
-
};
|
|
1
|
+
import type { Matrix, Edge, Node, OutNode, Degree, Point } from "../types";
|
|
6
2
|
export declare const floydWarshall: (adjMatrix: Matrix[]) => Matrix[];
|
|
7
3
|
export declare const getAdjMatrix: (data: {
|
|
8
4
|
nodes: Node[];
|
|
@@ -50,3 +46,10 @@ export declare const getCoreNodeAndRelativeLeafNodes: (type: "leaf" | "all", nod
|
|
|
50
46
|
relativeLeafNodes: Node[];
|
|
51
47
|
sameTypeLeafNodes: Node[];
|
|
52
48
|
};
|
|
49
|
+
/**
|
|
50
|
+
* calculate the euclidean distance form p1 to p2
|
|
51
|
+
* @param p1
|
|
52
|
+
* @param p2
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
export declare const getEuclideanDistance: (p1: Point, p2: Point) => number;
|
package/lib/worker.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import type { Payload } from "./supervisor";
|
|
2
|
-
|
|
3
|
-
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): (LayoutMapping | Float32Array[])[];
|
|
2
|
+
export declare function calculateLayout(payload: Payload, transferables: Float32Array[]): Promise<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/layout",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.7",
|
|
4
4
|
"description": "graph layout algorithm",
|
|
5
5
|
"main": "dist/index.min.js",
|
|
6
6
|
"module": "esm/index.esm.js",
|
|
@@ -23,6 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@antv/graphlib": "^2.0.0-alpha.2",
|
|
25
25
|
"@naoak/workerize-transferable": "^0.1.0",
|
|
26
|
+
"d3-force": "^3.0.0",
|
|
27
|
+
"d3-quadtree": "^3.0.1",
|
|
26
28
|
"eventemitter3": "^4.0.0",
|
|
27
29
|
"ml-matrix": "^6.10.4"
|
|
28
30
|
},
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{calculateLayout:()=>Mt});class r{nodeMap=new Map;edgeMap=new Map;inEdgesMap=new Map;outEdgesMap=new Map;treeIndices=new Map;changes=[];batchCount=0;onChanged=()=>{};constructor(t){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=[],this.onChanged({graph:this,changes:t})}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 o=e.value.id===t.value.id;return o&&(r=!0),!o}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 o=e.value.id===t.value.id;return o&&(r=!0),!o}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){if(!this.hasNode(t))throw new Error("Node not found for id: "+t)}hasNode(t){return this.nodeMap.has(t)}areNeighbors(t,e){return this.checkNodeExistence(t),this.getNeighbors(e).some((e=>e.id===t))}getNode(t){return this.checkNodeExistence(t),this.nodeMap.get(t)}getRelatedEdges(t,e){this.checkNodeExistence(t);const r=this.inEdgesMap.get(t),o=this.outEdgesMap.get(t);if("in"===e)return Array.from(r);if("out"===e)return Array.from(o);const s=new Set([...r,...o]);return Array.from(s)}getDegree(t,e){return this.getRelatedEdges(t,e).length}getSuccessors(t){const e=this.getRelatedEdges(t,"out").map((t=>t.target));return Array.from(new Set(e)).map((t=>this.getNode(t)))}getPredecessors(t){const e=this.getRelatedEdges(t,"in").map((t=>t.source));return Array.from(new Set(e)).map((t=>this.getNode(t)))}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.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.inEdgesMap.get(t),o=this.outEdgesMap.get(t);r?.forEach((t=>this.doRemoveEdge(t.id))),o?.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])}updateNodeData(t,e,r){const o=this.getNode(t);this.batch((()=>{const s=o.data[e],n=r;o.data[e]=n,this.changes.push({type:"NodeDataUpdated",id:t,propertyName:e,oldValue:s,newValue:n})}))}mergeNodeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateNodeData(t,e,r)}))}))}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);e.add(t),r.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),o=this.inEdgesMap.get(e.target);r.delete(e),o.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 o=r.source,s=e;this.outEdgesMap.get(o).delete(r),this.outEdgesMap.get(s).add(r),r.source=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"source",oldValue:o,newValue:s})}))}updateEdgeTarget(t,e){const r=this.getEdge(t);this.checkNodeExistence(e);const o=r.target,s=e;this.inEdgesMap.get(o).delete(r),this.inEdgesMap.get(s).add(r),r.target=e,this.batch((()=>{this.changes.push({type:"EdgeUpdated",id:t,propertyName:"target",oldValue:o,newValue:s})}))}updateEdgeData(t,e,r){const o=this.getEdge(t);this.batch((()=>{const s=o.data[e],n=r;o.data[e]=n,this.changes.push({type:"EdgeDataUpdated",id:t,propertyName:e,oldValue:s,newValue:n})}))}mergeEdgeData(t,e){this.batch((()=>{Object.entries(e).forEach((([e,r])=>{this.updateEdgeData(t,e,r)}))}))}checkTreeExistence(t){if(!this.treeIndices.has(t))throw new Error("Tree structure not found for treeKey: "+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=[],o=Array.isArray(t)?t:[t];for(;o.length;){const t=o.shift();r.push(t),t.children&&o.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}setParent(t,e,r){this.checkTreeExistence(r);const o=this.treeIndices.get(r),s=this.getNode(t),n=o.parentMap.get(t),i=this.getNode(e);o.parentMap.set(t,i),n&&o.childrenMap.get(n.id)?.delete(s);let a=o.childrenMap.get(i.id);a||(a=new Set,o.childrenMap.set(i.id,a)),a.add(s),this.batch((()=>{this.changes.push({type:"TreeStructureChanged",treeKey:r,nodeId:t,oldParentId:n?.id,newParentId:i.id})}))}getAllNodes(){return Array.from(this.nodeMap.values())}getAllEdges(){return Array.from(this.edgeMap.values())}doBFS(t,e,r){for(;t.length;){const o=t.shift();r(o),e.add(o.id),this.getSuccessors(o.id).forEach((r=>{e.has(r.id)||(e.add(r.id),t.push(r))}))}}bfs(t,e){this.doBFS([this.getNode(t)],new Set,e)}doDFS(t,e,r){r(t),e.add(t.id),this.getSuccessors(t.id).forEach((t=>{e.has(t.id)||this.doDFS(t,e,r)}))}dfs(t,e){this.doDFS(this.getNode(t),new Set,e)}clone(){const t=this.getAllNodes().map((t=>({...t,data:{...t.data}}))),e=this.getAllEdges().map((t=>({...t,data:{...t.data}}))),o=new r({nodes:t,edges:e});return this.treeIndices.forEach((({parentMap:t,childrenMap:e},r)=>{const s=new Map;t.forEach(((t,e)=>{s.set(e,o.getNode(t.id))}));const n=new Map;e.forEach(((t,e)=>{n.set(e,new Set(Array.from(t).map((t=>o.getNode(t.id)))))})),o.treeIndices.set(r,{parentMap:s,childrenMap:n})})),o}toJSON(){return JSON.stringify({nodes:this.getAllNodes(),edges:this.getAllEdges()})}}var o=function(){return o=Object.assign||function(t){for(var e,r=1,o=arguments.length;r<o;r++)for(var s in e=arguments[r])Object.prototype.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t},o.apply(this,arguments)};function s(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var o,s,n=r.call(t),i=[];try{for(;(void 0===e||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(t){s={error:t}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}function n(t,e,r){if(r||2===arguments.length)for(var o,s=0,n=e.length;s<n;s++)!o&&s in e||(o||(o=Array.prototype.slice.call(e,0,s)),o[s]=e[s]);return t.concat(o||Array.prototype.slice.call(e))}Object.create,Object.create;var i=function(t){return"string"==typeof t},a=/-(\w)/g,h=(function(t){return t.replace(a,(function(t,e){return e?e.toUpperCase():""}))},Object.create(null),Array.isArray),u=function(t){return"number"==typeof t},l=function(t){for(var e=[],r=t.length,o=0;o<r;o+=1){e[o]=[];for(var s=0;s<r;s+=1)o===s?e[o][s]=0:0!==t[o][s]&&t[o][s]?e[o][s]=t[o][s]:e[o][s]=1/0}for(var n=0;n<r;n+=1)for(o=0;o<r;o+=1)for(s=0;s<r;s+=1)e[o][s]>e[o][n]+e[n][s]&&(e[o][s]=e[o][n]+e[n][s]);return e},c=function(t,e){var r=t.nodes,o=t.edges,s=[],n={};if(!r)throw new Error("invalid nodes data!");return r&&r.forEach((function(t,e){n[t.id]=e,s.push([])})),null==o||o.forEach((function(t){var r=t.source,o=t.target,i=n[r],a=n[o];void 0!==i&&void 0!==a&&(s[i][a]=1,e||(s[a][i]=1))})),s},f=function(t){return null!==t&&"object"==typeof t},d=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 d(t)}))}if("object"==typeof t&&Object.keys(t).length){var r=o({},t);return Object.keys(r).forEach((function(t){r[t]=d(r[t])})),r}return t},g=function(t){var e=d(t);return e.data=e.data||{},e},m=function(t){return"function"==typeof t},p=function(t,e){return m(e)?e:u(e)?function(){return e}:function(){return t}};function w(t,e,r){return void 0===r&&(r=!0),e||0===e?m(e)?e:u(e)?function(){return e}:h(e)?function(){if(r){var o=Math.max.apply(Math,n([],s(e),!1));return isNaN(o)?t:o}return e}:f(e)?function(){if(r){var o=Math.max(e.width,e.height);return isNaN(o)?t:o}return[e.width,e.height]}:function(){return t}:function(e){var r=(e.data||{}).size;return r?h(r)?r[0]>r[1]?r[0]:r[1]:f(r)?r.width>r.height?r.width:r.height:r:t}}var y={radius:null,startRadius:null,endRadius:null,startAngle:0,endAngle:2*Math.PI,clockwise:!0,divisions:1,ordering:null,angleRatio:1},v=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="circular",this.options=o(o({},y),t)}return t.prototype.execute=function(t,e){return this.genericCircularLayout(!1,t,e)},t.prototype.assign=function(t,e){var r=this;t.batch((function(){r.genericCircularLayout(!0,t,e)}))},t.prototype.genericCircularLayout=function(t,e,r){var n=o(o({},this.options),r),i=n.width,a=n.height,h=n.center,u=n.divisions,l=n.startAngle,c=void 0===l?0:l,f=n.endAngle,d=void 0===f?2*Math.PI:f,m=n.angleRatio,y=n.ordering,v=n.clockwise,E=n.nodeSpacing,x=n.nodeSize,S=n.layoutInvisibles,N=n.onLayoutEnd,R=e.getAllNodes(),I=e.getAllEdges();S||(R=R.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),I=I.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var k=R.length;if(0===k)return null==N||N({nodes:[],edges:[]}),{nodes:[],edges:[]};var A=s(b(i,a,h),3),T=A[0],C=A[1],D=A[2];if(1===k){t&&e.mergeNodeData(R[0].id,{x:D[0],y:D[1]});var z={nodes:[o(o({},R[0]),{data:o(o({},R[0].data),{x:D[0],y:D[1]})})],edges:I};return null==N||N(z),z}var P=(d-c)/k,V=n.radius,q=n.startRadius,j=n.endRadius;if(E){var F=p(10,E),O=w(10,x),L=-1/0;R.forEach((function(t){var e=O(t);L<e&&(L=e)}));var $=0;R.forEach((function(t,e){$+=0===e?L||10:(F(t)||0)+(L||10)})),V=$/(2*Math.PI)}else V||q||j?!q&&j?q=j:q&&!j&&(j=q):V=Math.min(C,T)/2;var U=P*m,B=[];B="topology"===y?M(e,R):"topology-directed"===y?M(e,R,!0):"degree"===y?function(t,e){var r=[];return e.forEach((function(t,e){r.push(g(t))})),r.sort((function(e,r){return t.getDegree(e.id,"both")-t.getDegree(r.id,"both")})),r}(e,R):R.map((function(t){return g(t)}));for(var K=Math.ceil(k/u),W=0;W<k;++W){var J=V;J||null===q||null===j||(J=q+W*(j-q)/(k-1)),J||(J=10+100*W/(k-1));var _=c+W%K*U+2*Math.PI/u*Math.floor(W/K);v||(_=d-W%K*U-2*Math.PI/u*Math.floor(W/K)),B[W].data.x=D[0]+Math.cos(_)*J,B[W].data.y=D[1]+Math.sin(_)*J}t&&B.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var G={nodes:B,edges:I};return null==N||N(G),G},t}(),M=function(t,e,r){void 0===r&&(r=!1);var o=[g(e[0])],s={},n=e.length;s[e[0].id]=!0;var i=0;return e.forEach((function(a,h){if(0!==h)if(h!==n-1&&t.getDegree(a.id,"both")===t.getDegree(e[h+1].id,"both")&&!t.areNeighbors(o[i].id,a.id)||s[a.id]){for(var u=r?t.getSuccessors(o[i].id):t.getNeighbors(o[i].id),l=!1,c=0;c<u.length;c++){var f=u[c];if(t.getDegree(f.id)===t.getDegree(a.id)&&!s[f.id]){o.push(g(f)),s[f.id]=!0,l=!0;break}}for(var d=0;!l&&(s[e[d].id]||(o.push(g(e[d])),s[e[d].id]=!0,l=!0),++d!==n););}else o.push(g(a)),s[a.id]=!0,i++})),o},b=function(t,e,r){var o=t,s=e,n=r;return o||"undefined"==typeof window||(o=window.innerWidth),s||"undefined"==typeof window||(s=window.innerHeight),n||(n=[o/2,s/2]),[o,s,n]},E={nodeSize:30,minNodeSpacing:10,nodeSpacing:10,preventOverlap:!1,sweep:void 0,equidistant:!1,startAngle:1.5*Math.PI,clockwise:!0,maxLevelDiff:void 0,sortBy:"degree"},x=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="concentric",this.options=o(o({},E),t)}return t.prototype.execute=function(t,e){return this.genericConcentricLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericConcentricLayout(!0,t,e)},t.prototype.genericConcentricLayout=function(t,e,r){var s=o(o({},this.options),r),n=s.center,a=s.width,l=s.height,c=s.sortBy,d=s.maxLevelDiff,p=s.sweep,w=s.clockwise,y=s.equidistant,v=s.minNodeSpacing,M=void 0===v?10:v,b=s.preventOverlap,E=s.startAngle,x=void 0===E?1.5*Math.PI:E,S=s.nodeSize,N=s.nodeSpacing,R=s.layoutInvisibles,I=s.onLayoutEnd,k=e.getAllNodes(),A=e.getAllEdges();R||(k=k.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var T=k.length;if(0===T){var C={nodes:[],edges:A};return null==I||I(C),C}var D=a||"undefined"==typeof window?a:window.innerWidth,z=l||"undefined"==typeof window?l:window.innerHeight,P=n||[D/2,z/2];if(1===T){t&&e.mergeNodeData(k[0].id,{x:P[0],y:P[1]});var V={nodes:[o(o({},k[0]),{data:o(o({},k[0].data),{x:P[0],y:P[1]})})],edges:A};return null==I||I(V),V}var q,j=[],F=0;q=h(S)?Math.max(S[0],S[1]):S,h(N)?F=Math.max(N[0],N[1]):u(N)&&(F=N),k.forEach((function(t){var e=g(t);j.push(e);var r=q,o=e.data;h(o.size)?r=Math.max(o.size[0],o.size[1]):u(o.size)?r=o.size:f(o.size)&&(r=Math.max(o.size.width,o.size.height)),q=Math.max(q,r),m(N)&&(F=Math.max(N(t),F))}));var O={};j.forEach((function(t,e){O[t.id]=e}));var L={},$=c;i($)&&void 0!==j[0].data[$]||($="degree"),"degree"===$?(j.forEach((function(t){L[t.id]=e.getDegree(t.id,"both")})),j.sort((function(t,e){return L[e.id]-L[t.id]}))):j.sort((function(t,e){return e.data[$]-t.data[$]}));var U=j[0],B=d||U.data[$]/4,K=[{nodes:[]}],W=K[0];j.forEach((function(t){if(W.nodes.length>0){var e=void 0,r=void 0;"degree"===$?(e=L[W.nodes[0].id],r=L[t.id]):(e=W.nodes[0].data[$],r=t.data[$]);var o=Math.abs(e-r);B&&o>=B&&(W={nodes:[]},K.push(W))}W.nodes.push(t)}));var J=q+(F||M);if(!b){var _=K.length>0&&K[0].nodes.length>1,G=(Math.min(D,z)/2-J)/(K.length+(_?1:0));J=Math.min(J,G)}var H=0;if(K.forEach((function(t){var e=void 0===p?2*Math.PI-2*Math.PI/t.nodes.length:p;if(t.dTheta=e/Math.max(1,t.nodes.length-1),t.nodes.length>1&&b){var r=Math.cos(t.dTheta)-Math.cos(0),o=Math.sin(t.dTheta)-Math.sin(0),s=Math.sqrt(J*J/(r*r+o*o));H=Math.max(s,H)}t.r=H,H+=J})),y){for(var Y=0,Q=0,X=0;X<K.length;X++){var Z=(K[X].r||0)-Q;Y=Math.max(Y,Z)}Q=0,K.forEach((function(t,e){0===e&&(Q=t.r||0),t.r=Q,Q+=Y}))}K.forEach((function(t){var e=t.dTheta||0,r=t.r||0;t.nodes.forEach((function(t,o){var s=x+(w?1:-1)*e*o;t.data.x=P[0]+r*Math.cos(s),t.data.y=P[1]+r*Math.sin(s)}))})),t&&j.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var tt={nodes:j,edges:A};return null==I||I(tt),tt},t}(),S={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},N=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="grid",this.options=o(o({},S),t)}return t.prototype.execute=function(t,e){return this.genericGridLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericGridLayout(!0,t,e)},t.prototype.genericGridLayout=function(t,e,r){var s=o(o({},this.options),r),n=s.begin,a=void 0===n?[0,0]:n,l=s.condense,c=s.preventOverlapPadding,f=s.preventOverlap,d=s.rows,m=s.cols,y=s.nodeSpacing,v=s.nodeSize,M=s.width,b=s.height,E=s.layoutInvisibles,x=s.onLayoutEnd,S=s.position,N=s.sortBy,T=e.getAllNodes(),D=e.getAllEdges();E||(T=T.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),D=D.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var z=T.length;if(0===z){var P={nodes:[],edges:D};return null==x||x(P),P}if(1===z){t&&e.mergeNodeData(T[0].id,{x:a[0],y:a[1]});var V={nodes:[o(o({},T[0]),{data:o(o({},T[0].data),{x:a[0],y:a[1]})})],edges:D};return null==x||x(V),V}var q=T.map((function(t){return g(t)}));"id"===N||i(N)&&void 0!==q[0].data[N]||(N="degree"),"degree"===N?q.sort((function(t,r){return e.getDegree(r.id,"both")-e.getDegree(t.id,"both")})):"id"===N?q.sort((function(t,e){return u(e.id)&&u(t.id)?e.id-t.id:"".concat(t.id).localeCompare("".concat(e.id))})):q.sort((function(t,e){return e.data[N]-t.data[N]}));var j=M||"undefined"==typeof window?M:window.innerWidth,F=b||"undefined"==typeof window?b:window.innerHeight,O=z,L={rows:d,cols:m};if(null!=d&&null!=m)L.rows=d,L.cols=m;else if(null!=d&&null==m)L.rows=d,L.cols=Math.ceil(O/L.rows);else if(null==d&&null!=m)L.cols=m,L.rows=Math.ceil(O/L.cols);else{var $=Math.sqrt(O*F/j);L.rows=Math.round($),L.cols=Math.round(j/F*$)}if(L.rows=Math.max(L.rows,1),L.cols=Math.max(L.cols,1),L.cols*L.rows>O)((B=R(L))-1)*(U=I(L))>=O?R(L,B-1):(U-1)*B>=O&&I(L,U-1);else for(;L.cols*L.rows<O;){var U,B=R(L);((U=I(L))+1)*B>=O?I(L,U+1):R(L,B+1)}var K=l?0:j/L.cols,W=l?0:F/L.rows;if(f||y){var J=p(10,y),_=w(30,v,!1);q.forEach((function(t){t.data.x&&t.data.y||(t.data.x=0,t.data.y=0);var r,o,s=e.getNode(t.id),n=_(s)||30;h(n)?(r=n[0],o=n[1]):(r=n,o=n);var i=void 0!==J?J(t):c,a=r+i,u=o+i;K=Math.max(K,a),W=Math.max(W,u)}))}for(var G={},H={row:0,col:0},Y={},Q=0;Q<q.length;Q++){var X=q[Q],Z=void 0;if(S&&(Z=S(e.getNode(X.id))),Z&&(void 0!==Z.row||void 0!==Z.col)){var tt={row:Z.row,col:Z.col};if(void 0===tt.col)for(tt.col=0;k(G,tt);)tt.col++;else if(void 0===tt.row)for(tt.row=0;k(G,tt);)tt.row++;Y[X.id]=tt,A(G,tt)}C(X,a,K,W,Y,L,H,G)}var et={nodes:q,edges:D};return null==x||x(et),t&&q.forEach((function(t){e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})})),et},t}(),R=function(t,e){var r,o=t.rows||5,s=t.cols||5;return null==e?r=Math.min(o,s):Math.min(o,s)===t.rows?t.rows=e:t.cols=e,r},I=function(t,e){var r,o=t.rows||5,s=t.cols||5;return null==e?r=Math.max(o,s):Math.max(o,s)===t.rows?t.rows=e:t.cols=e,r},k=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]||!1},A=function(t,e){return t["c-".concat(e.row,"-").concat(e.col)]=!0},T=function(t,e){var r=t.cols||5;e.col++,e.col>=r&&(e.col=0,e.row++)},C=function(t,e,r,o,s,n,i,a){var h,u,l=s[t.id];if(l)h=l.col*r+r/2+e[0],u=l.row*o+o/2+e[1];else{for(;k(a,i);)T(n,i);h=i.col*r+r/2+e[0],u=i.row*o+o/2+e[1],A(a,i),T(n,i)}t.data.x=h,t.data.y=u};const D=Object.prototype.toString;function z(t){return D.call(t).endsWith("Array]")}function P(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!z(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,o=void 0===r?0:r,s=e.toIndex,n=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=o||n>t.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var i=t[o],a=o+1;a<n;a++)t[a]>i&&(i=t[a]);return i}function V(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!z(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,o=void 0===r?0:r,s=e.toIndex,n=void 0===s?t.length:s;if(o<0||o>=t.length||!Number.isInteger(o))throw new Error("fromIndex must be a positive integer smaller than length");if(n<=o||n>t.length||!Number.isInteger(n))throw new Error("toIndex must be an integer greater than fromIndex and at most equal to length");for(var i=t[o],a=o+1;a<n;a++)t[a]<i&&(i=t[a]);return i}function q(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!z(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(!z(r.output))throw new TypeError("output option must be an array if specified");e=r.output}else e=new Array(t.length);var o=V(t),s=P(t);if(o===s)throw new RangeError("minimum and maximum input values are equal. Cannot rescale a constant array");var n=r.min,i=void 0===n?r.autoMinMax?o:0:n,a=r.max,h=void 0===a?r.autoMinMax?s:1:a;if(i>=h)throw new RangeError("min option must be smaller than max option");for(var u=(h-i)/(s-o),l=0;l<t.length;l++)e[l]=(t[l]-o)*u+i;return e}const j=" ".repeat(2),F=" ".repeat(4);function O(t,e={}){const{maxRows:r=15,maxColumns:o=10,maxNumSize:s=8,padMinus:n="auto"}=e;return`${t.constructor.name} {\n${j}[\n${F}${function(t,e,r,o,s){const{rows:n,columns:i}=t,a=Math.min(n,e),h=Math.min(i,r),u=[];if("auto"===s){s=!1;t:for(let e=0;e<a;e++)for(let r=0;r<h;r++)if(t.get(e,r)<0){s=!0;break t}}for(let e=0;e<a;e++){let r=[];for(let n=0;n<h;n++)r.push(L(t.get(e,n),o,s));u.push(`${r.join(" ")}`)}return h!==i&&(u[u.length-1]+=` ... ${i-r} more columns`),a!==n&&u.push(`... ${n-e} more rows`),u.join(`\n${F}`)}(t,r,o,s,n)}\n${j}]\n${j}rows: ${t.rows}\n${j}columns: ${t.columns}\n}`}function L(t,e,r){return(t>=0&&r?` ${$(t,e-1)}`:$(t,e)).padEnd(e)}function $(t,e){let r=t.toString();if(r.length<=e)return r;let o=t.toFixed(e);if(o.length>e&&(o=t.toFixed(Math.max(0,e-(o.length-e)))),o.length<=e&&!o.startsWith("0.000")&&!o.startsWith("-0.000"))return o;let s=t.toExponential(e);return s.length>e&&(s=t.toExponential(Math.max(0,e-(s.length-e)))),s.slice(0)}function U(t,e,r){let o=r?t.rows:t.rows-1;if(e<0||e>o)throw new RangeError("Row index out of range")}function B(t,e,r){let o=r?t.columns:t.columns-1;if(e<0||e>o)throw new RangeError("Column index out of range")}function K(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.columns)throw new RangeError("vector size must be the same as the number of columns");return e}function W(t,e){if(e.to1DArray&&(e=e.to1DArray()),e.length!==t.rows)throw new RangeError("vector size must be the same as the number of rows");return e}function J(t,e,r,o,s){if(5!==arguments.length)throw new RangeError("expected 4 arguments");if(G("startRow",e),G("endRow",r),G("startColumn",o),G("endColumn",s),e>r||o>s||e<0||e>=t.rows||r<0||r>=t.rows||o<0||o>=t.columns||s<0||s>=t.columns)throw new RangeError("Submatrix indices are out of range")}function _(t,e=0){let r=[];for(let o=0;o<t;o++)r.push(e);return r}function G(t,e){if("number"!=typeof e)throw new TypeError(`${t} must be a number`)}function H(t){if(t.isEmpty())throw new Error("Empty matrix has no elements to index")}class Y{static from1DArray(t,e,r){if(t*e!==r.length)throw new RangeError("data length does not match given dimensions");let o=new X(t,e);for(let s=0;s<t;s++)for(let t=0;t<e;t++)o.set(s,t,r[s*e+t]);return o}static rowVector(t){let e=new X(1,t.length);for(let r=0;r<t.length;r++)e.set(0,r,t[r]);return e}static columnVector(t){let e=new X(t.length,1);for(let r=0;r<t.length;r++)e.set(r,0,t[r]);return e}static zeros(t,e){return new X(t,e)}static ones(t,e){return new X(t,e).fill(1)}static rand(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{random:o=Math.random}=r;let s=new X(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++)s.set(r,t,o());return s}static randInt(t,e,r={}){if("object"!=typeof r)throw new TypeError("options must be an object");const{min:o=0,max:s=1e3,random:n=Math.random}=r;if(!Number.isInteger(o))throw new TypeError("min must be an integer");if(!Number.isInteger(s))throw new TypeError("max must be an integer");if(o>=s)throw new RangeError("min must be smaller than max");let i=s-o,a=new X(t,e);for(let r=0;r<t;r++)for(let t=0;t<e;t++){let e=o+Math.round(n()*i);a.set(r,t,e)}return a}static eye(t,e,r){void 0===e&&(e=t),void 0===r&&(r=1);let o=Math.min(t,e),s=this.zeros(t,e);for(let t=0;t<o;t++)s.set(t,t,r);return s}static diag(t,e,r){let o=t.length;void 0===e&&(e=o),void 0===r&&(r=e);let s=Math.min(o,e,r),n=this.zeros(e,r);for(let e=0;e<s;e++)n.set(e,e,t[e]);return n}static min(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,o=t.columns,s=new X(r,o);for(let n=0;n<r;n++)for(let r=0;r<o;r++)s.set(n,r,Math.min(t.get(n,r),e.get(n,r)));return s}static max(t,e){t=this.checkMatrix(t),e=this.checkMatrix(e);let r=t.rows,o=t.columns,s=new this(r,o);for(let n=0;n<r;n++)for(let r=0;r<o;r++)s.set(n,r,Math.max(t.get(n,r),e.get(n,r)));return s}static checkMatrix(t){return Y.isMatrix(t)?t:new X(t)}static isMatrix(t){return null!=t&&"Matrix"===t.klass}get size(){return this.rows*this.columns}apply(t){if("function"!=typeof t)throw new TypeError("callback must be a function");for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.call(this,e,r);return this}to1DArray(){let t=[];for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.push(this.get(e,r));return t}to2DArray(){let t=[];for(let e=0;e<this.rows;e++){t.push([]);for(let r=0;r<this.columns;r++)t[e].push(this.get(e,r))}return t}toJSON(){return this.to2DArray()}isRowVector(){return 1===this.rows}isColumnVector(){return 1===this.columns}isVector(){return 1===this.rows||1===this.columns}isSquare(){return this.rows===this.columns}isEmpty(){return 0===this.rows||0===this.columns}isSymmetric(){if(this.isSquare()){for(let t=0;t<this.rows;t++)for(let e=0;e<=t;e++)if(this.get(t,e)!==this.get(e,t))return!1;return!0}return!1}isEchelonForm(){let t=0,e=0,r=-1,o=!0,s=!1;for(;t<this.rows&&o;){for(e=0,s=!1;e<this.columns&&!1===s;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(s=!0,r=e):(o=!1,s=!0);t++}return o}isReducedEchelonForm(){let t=0,e=0,r=-1,o=!0,s=!1;for(;t<this.rows&&o;){for(e=0,s=!1;e<this.columns&&!1===s;)0===this.get(t,e)?e++:1===this.get(t,e)&&e>r?(s=!0,r=e):(o=!1,s=!0);for(let r=e+1;r<this.rows;r++)0!==this.get(t,r)&&(o=!1);t++}return o}echelonForm(){let t=this.clone(),e=0,r=0;for(;e<t.rows&&r<t.columns;){let o=e;for(let s=e;s<t.rows;s++)t.get(s,r)>t.get(o,r)&&(o=s);if(0===t.get(o,r))r++;else{t.swapRows(e,o);let s=t.get(e,r);for(let o=r;o<t.columns;o++)t.set(e,o,t.get(e,o)/s);for(let o=e+1;o<t.rows;o++){let s=t.get(o,r)/t.get(e,r);t.set(o,r,0);for(let n=r+1;n<t.columns;n++)t.set(o,n,t.get(o,n)-t.get(e,n)*s)}e++,r++}}return t}reducedEchelonForm(){let t=this.echelonForm(),e=t.columns,r=t.rows,o=r-1;for(;o>=0;)if(0===t.maxRow(o))o--;else{let s=0,n=!1;for(;s<r&&!1===n;)1===t.get(o,s)?n=!0:s++;for(let r=0;r<o;r++){let n=t.get(r,s);for(let i=s;i<e;i++){let e=t.get(r,i)-n*t.get(o,i);t.set(r,i,e)}}o--}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 o=new X(this.rows*e,this.columns*r);for(let t=0;t<e;t++)for(let e=0;e<r;e++)o.setSubMatrix(this,this.rows*t,this.columns*e);return o}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){U(this,t);let e=[];for(let r=0;r<this.columns;r++)e.push(this.get(t,r));return e}getRowVector(t){return X.rowVector(this.getRow(t))}setRow(t,e){U(this,t),e=K(this,e);for(let r=0;r<this.columns;r++)this.set(t,r,e[r]);return this}swapRows(t,e){U(this,t),U(this,e);for(let r=0;r<this.columns;r++){let o=this.get(t,r);this.set(t,r,this.get(e,r)),this.set(e,r,o)}return this}getColumn(t){B(this,t);let e=[];for(let r=0;r<this.rows;r++)e.push(this.get(r,t));return e}getColumnVector(t){return X.columnVector(this.getColumn(t))}setColumn(t,e){B(this,t),e=W(this,e);for(let r=0;r<this.rows;r++)this.set(r,t,e[r]);return this}swapColumns(t,e){B(this,t),B(this,e);for(let r=0;r<this.rows;r++){let o=this.get(r,t);this.set(r,t,this.get(r,e)),this.set(r,e,o)}return this}addRowVector(t){t=K(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=K(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=K(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=K(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[r]);return this}addColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)+t[e]);return this}subColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)-t[e]);return this}mulColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)*t[e]);return this}divColumnVector(t){t=W(this,t);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.set(e,r,this.get(e,r)/t[e]);return this}mulRow(t,e){U(this,t);for(let r=0;r<this.columns;r++)this.set(t,r,this.get(t,r)*e);return this}mulColumn(t,e){B(this,t);for(let r=0;r<this.rows;r++)this.set(r,t,this.get(r,t)*e);return this}max(t){if(this.isEmpty())return NaN;switch(t){case"row":{const t=new Array(this.rows).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[e]&&(t[e]=this.get(e,r));return t}case"column":{const t=new Array(this.columns).fill(Number.NEGATIVE_INFINITY);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t[r]&&(t[r]=this.get(e,r));return t}case void 0:{let t=this.get(0,0);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)this.get(e,r)>t&&(t=this.get(e,r));return t}default:throw new Error(`invalid option: ${t}`)}}maxIndex(){H(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let o=0;o<this.columns;o++)this.get(r,o)>t&&(t=this.get(r,o),e[0]=r,e[1]=o);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(){H(this);let t=this.get(0,0),e=[0,0];for(let r=0;r<this.rows;r++)for(let o=0;o<this.columns;o++)this.get(r,o)<t&&(t=this.get(r,o),e[0]=r,e[1]=o);return e}maxRow(t){if(U(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){U(this,t),H(this);let e=this.get(t,0),r=[t,0];for(let o=1;o<this.columns;o++)this.get(t,o)>e&&(e=this.get(t,o),r[1]=o);return r}minRow(t){if(U(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){U(this,t),H(this);let e=this.get(t,0),r=[t,0];for(let o=1;o<this.columns;o++)this.get(t,o)<e&&(e=this.get(t,o),r[1]=o);return r}maxColumn(t){if(B(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)>e&&(e=this.get(r,t));return e}maxColumnIndex(t){B(this,t),H(this);let e=this.get(0,t),r=[0,t];for(let o=1;o<this.rows;o++)this.get(o,t)>e&&(e=this.get(o,t),r[0]=o);return r}minColumn(t){if(B(this,t),this.isEmpty())return NaN;let e=this.get(0,t);for(let r=1;r<this.rows;r++)this.get(r,t)<e&&(e=this.get(r,t));return e}minColumnIndex(t){B(this,t),H(this);let e=this.get(0,t),r=[0,t];for(let o=1;o<this.rows;o++)this.get(o,t)<e&&(e=this.get(o,t),r[0]=o);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){Y.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 o=0;o<e.length;o++)r+=e[o]*t[o];return r}mmul(t){t=X.checkMatrix(t);let e=this.rows,r=this.columns,o=t.columns,s=new X(e,o),n=new Float64Array(r);for(let i=0;i<o;i++){for(let e=0;e<r;e++)n[e]=t.get(e,i);for(let t=0;t<e;t++){let e=0;for(let o=0;o<r;o++)e+=this.get(t,o)*n[o];s.set(t,i,e)}}return s}strassen2x2(t){t=X.checkMatrix(t);let e=new X(2,2);const r=this.get(0,0),o=t.get(0,0),s=this.get(0,1),n=t.get(0,1),i=this.get(1,0),a=t.get(1,0),h=this.get(1,1),u=t.get(1,1),l=(r+h)*(o+u),c=(i+h)*o,f=r*(n-u),d=h*(a-o),g=(r+s)*u,m=l+d-g+(s-h)*(a+u),p=f+g,w=c+d,y=l-c+f+(i-r)*(o+n);return e.set(0,0,m),e.set(0,1,p),e.set(1,0,w),e.set(1,1,y),e}strassen3x3(t){t=X.checkMatrix(t);let e=new X(3,3);const r=this.get(0,0),o=this.get(0,1),s=this.get(0,2),n=this.get(1,0),i=this.get(1,1),a=this.get(1,2),h=this.get(2,0),u=this.get(2,1),l=this.get(2,2),c=t.get(0,0),f=t.get(0,1),d=t.get(0,2),g=t.get(1,0),m=t.get(1,1),p=t.get(1,2),w=t.get(2,0),y=t.get(2,1),v=t.get(2,2),M=(r-n)*(-f+m),b=(-r+n+i)*(c-f+m),E=(n+i)*(-c+f),x=r*c,S=(-r+h+u)*(c-d+p),N=(-r+h)*(d-p),R=(h+u)*(-c+d),I=(-s+u+l)*(m+w-y),k=(s-l)*(m-y),A=s*w,T=(u+l)*(-w+y),C=(-s+i+a)*(p+w-v),D=(s-a)*(p-v),z=(i+a)*(-w+v),P=x+A+o*g,V=(r+o+s-n-i-u-l)*m+b+E+x+I+A+T,q=x+S+R+(r+o+s-i-a-h-u)*p+A+C+z,j=M+i*(-c+f+g-m-p-w+v)+b+x+A+C+D,F=M+b+E+x+a*y,O=A+C+D+z+n*d,L=x+S+N+u*(-c+d+g-m-p-w+y)+I+k+A,$=I+k+A+T+h*f,U=x+S+N+R+l*v;return e.set(0,0,P),e.set(0,1,V),e.set(0,2,q),e.set(1,0,j),e.set(1,1,F),e.set(1,2,O),e.set(2,0,L),e.set(2,1,$),e.set(2,2,U),e}mmulStrassen(t){t=X.checkMatrix(t);let e=this.clone(),r=e.rows,o=e.columns,s=t.rows,n=t.columns;function i(t,e,r){let o=t.rows,s=t.columns;if(o===e&&s===r)return t;{let o=Y.zeros(e,r);return o=o.setSubMatrix(t,0,0),o}}o!==s&&console.warn(`Multiplying ${r} x ${o} and ${s} x ${n} matrix: dimensions do not match.`);let a=Math.max(r,s),h=Math.max(o,n);return e=i(e,a,h),function t(e,r,o,s){if(o<=512||s<=512)return e.mmul(r);o%2==1&&s%2==1?(e=i(e,o+1,s+1),r=i(r,o+1,s+1)):o%2==1?(e=i(e,o+1,s),r=i(r,o+1,s)):s%2==1&&(e=i(e,o,s+1),r=i(r,o,s+1));let n=parseInt(e.rows/2,10),a=parseInt(e.columns/2,10),h=e.subMatrix(0,n-1,0,a-1),u=r.subMatrix(0,n-1,0,a-1),l=e.subMatrix(0,n-1,a,e.columns-1),c=r.subMatrix(0,n-1,a,r.columns-1),f=e.subMatrix(n,e.rows-1,0,a-1),d=r.subMatrix(n,r.rows-1,0,a-1),g=e.subMatrix(n,e.rows-1,a,e.columns-1),m=r.subMatrix(n,r.rows-1,a,r.columns-1),p=t(Y.add(h,g),Y.add(u,m),n,a),w=t(Y.add(f,g),u,n,a),y=t(h,Y.sub(c,m),n,a),v=t(g,Y.sub(d,u),n,a),M=t(Y.add(h,l),m,n,a),b=t(Y.sub(f,h),Y.add(u,c),n,a),E=t(Y.sub(l,g),Y.add(d,m),n,a),x=Y.add(p,v);x.sub(M),x.add(E);let S=Y.add(y,M),N=Y.add(w,v),R=Y.sub(p,w);R.add(y),R.add(b);let I=Y.zeros(2*x.rows,2*x.columns);return I=I.setSubMatrix(x,0,0),I=I.setSubMatrix(S,x.rows,0),I=I.setSubMatrix(N,0,x.columns),I=I.setSubMatrix(R,x.rows,x.columns),I.subMatrix(0,o-1,0,s-1)}(e,t=i(t,a,h),a,h)}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 o=new X(this.rows,this.columns);for(let t=0;t<this.rows;t++){const s=this.getRow(t);s.length>0&&q(s,{min:e,max:r,output:s}),o.setRow(t,s)}return o}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 o=new X(this.rows,this.columns);for(let t=0;t<this.columns;t++){const s=this.getColumn(t);s.length&&q(s,{min:e,max:r,output:s}),o.setColumn(t,s)}return o}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),o=this.get(e,this.columns-1-r);this.set(e,r,o),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),o=this.get(this.rows-1-r,e);this.set(r,e,o),this.set(this.rows-1-r,e,t)}return this}kroneckerProduct(t){t=X.checkMatrix(t);let e=this.rows,r=this.columns,o=t.rows,s=t.columns,n=new X(e*o,r*s);for(let i=0;i<e;i++)for(let e=0;e<r;e++)for(let r=0;r<o;r++)for(let a=0;a<s;a++)n.set(o*i+r,s*e+a,this.get(i,e)*t.get(r,a));return n}kroneckerSum(t){if(t=X.checkMatrix(t),!this.isSquare()||!t.isSquare())throw new Error("Kronecker Sum needs two Square Matrices");let e=this.rows,r=t.rows,o=this.kroneckerProduct(X.eye(r,r)),s=X.eye(e,e).kroneckerProduct(t);return o.add(s)}transpose(){let t=new X(this.columns,this.rows);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(r,e,this.get(e,r));return t}sortRows(t=Q){for(let e=0;e<this.rows;e++)this.setRow(e,this.getRow(e).sort(t));return this}sortColumns(t=Q){for(let e=0;e<this.columns;e++)this.setColumn(e,this.getColumn(e).sort(t));return this}subMatrix(t,e,r,o){J(this,t,e,r,o);let s=new X(e-t+1,o-r+1);for(let n=t;n<=e;n++)for(let e=r;e<=o;e++)s.set(n-t,e-r,this.get(n,e));return s}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 o=new X(t.length,r-e+1);for(let s=0;s<t.length;s++)for(let n=e;n<=r;n++){if(t[s]<0||t[s]>=this.rows)throw new RangeError(`Row index out of range: ${t[s]}`);o.set(s,n-e,this.get(t[s],n))}return o}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 o=new X(r-e+1,t.length);for(let s=0;s<t.length;s++)for(let n=e;n<=r;n++){if(t[s]<0||t[s]>=this.columns)throw new RangeError(`Column index out of range: ${t[s]}`);o.set(n-e,s,this.get(n,t[s]))}return o}setSubMatrix(t,e,r){if((t=X.checkMatrix(t)).isEmpty())return this;J(this,e,e+t.rows-1,r,r+t.columns-1);for(let o=0;o<t.rows;o++)for(let s=0;s<t.columns;s++)this.set(e+o,r+s,t.get(o,s));return this}selection(t,e){!function(t,e){if(!z(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(!z(e))throw new TypeError("column indices must be an array");for(let r=0;r<e.length;r++)if(e[r]<0||e[r]>=t.columns)throw new RangeError("column indices are out of range")}(this,e);let r=new X(t.length,e.length);for(let o=0;o<t.length;o++){let s=t[o];for(let t=0;t<e.length;t++){let n=e[t];r.set(o,t,this.get(s,n))}}return r}trace(){let t=Math.min(this.rows,this.columns),e=0;for(let r=0;r<t;r++)e+=this.get(r,r);return e}clone(){let t=new X(this.rows,this.columns);for(let e=0;e<this.rows;e++)for(let r=0;r<this.columns;r++)t.set(e,r,this.get(e,r));return t}sum(t){switch(t){case"row":return function(t){let e=_(t.rows);for(let r=0;r<t.rows;++r)for(let o=0;o<t.columns;++o)e[r]+=t.get(r,o);return e}(this);case"column":return function(t){let e=_(t.columns);for(let r=0;r<t.rows;++r)for(let o=0;o<t.columns;++o)e[o]+=t.get(r,o);return e}(this);case void 0:return function(t){let e=0;for(let r=0;r<t.rows;r++)for(let o=0;o<t.columns;o++)e+=t.get(r,o);return e}(this);default:throw new Error(`invalid option: ${t}`)}}product(t){switch(t){case"row":return function(t){let e=_(t.rows,1);for(let r=0;r<t.rows;++r)for(let o=0;o<t.columns;++o)e[r]*=t.get(r,o);return e}(this);case"column":return function(t){let e=_(t.columns,1);for(let r=0;r<t.rows;++r)for(let o=0;o<t.columns;++o)e[o]*=t.get(r,o);return e}(this);case void 0:return function(t){let e=1;for(let r=0;r<t.rows;r++)for(let o=0;o<t.columns;o++)e*=t.get(r,o);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:o=this.mean(t)}=e;if("boolean"!=typeof r)throw new TypeError("unbiased must be a boolean");switch(t){case"row":if(!z(o))throw new TypeError("mean must be an array");return function(t,e,r){const o=t.rows,s=t.columns,n=[];for(let i=0;i<o;i++){let o=0,a=0,h=0;for(let e=0;e<s;e++)h=t.get(i,e)-r[i],o+=h,a+=h*h;e?n.push((a-o*o/s)/(s-1)):n.push((a-o*o/s)/s)}return n}(this,r,o);case"column":if(!z(o))throw new TypeError("mean must be an array");return function(t,e,r){const o=t.rows,s=t.columns,n=[];for(let i=0;i<s;i++){let s=0,a=0,h=0;for(let e=0;e<o;e++)h=t.get(e,i)-r[i],s+=h,a+=h*h;e?n.push((a-s*s/o)/(o-1)):n.push((a-s*s/o)/o)}return n}(this,r,o);case void 0:if("number"!=typeof o)throw new TypeError("mean must be a number");return function(t,e,r){const o=t.rows,s=t.columns,n=o*s;let i=0,a=0,h=0;for(let e=0;e<o;e++)for(let o=0;o<s;o++)h=t.get(e,o)-r,i+=h,a+=h*h;return e?(a-i*i/n)/(n-1):(a-i*i/n)/n}(this,r,o);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(!z(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let o=0;o<t.columns;o++)t.set(r,o,t.get(r,o)-e[r])}(this,r),this;case"column":if(!z(r))throw new TypeError("center must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let o=0;o<t.columns;o++)t.set(r,o,t.get(r,o)-e[o])}(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 o=0;o<t.columns;o++)t.set(r,o,t.get(r,o)-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 o=0;for(let e=0;e<t.columns;e++)o+=Math.pow(t.get(r,e),2)/(t.columns-1);e.push(Math.sqrt(o))}return e}(this);else if(!z(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let o=0;o<t.columns;o++)t.set(r,o,t.get(r,o)/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 o=0;for(let e=0;e<t.rows;e++)o+=Math.pow(t.get(e,r),2)/(t.rows-1);e.push(Math.sqrt(o))}return e}(this);else if(!z(r))throw new TypeError("scale must be an array");return function(t,e){for(let r=0;r<t.rows;r++)for(let o=0;o<t.columns;o++)t.set(r,o,t.get(r,o)/e[o])}(this,r),this;case void 0:if(void 0===r)r=function(t){const e=t.size-1;let r=0;for(let o=0;o<t.columns;o++)for(let s=0;s<t.rows;s++)r+=Math.pow(t.get(s,o),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 o=0;o<t.columns;o++)t.set(r,o,t.get(r,o)/e)}(this,r),this;default:throw new Error(`invalid option: ${t}`)}}toString(t){return O(this,t)}}function Q(t,e){return t-e}Y.prototype.klass="Matrix","undefined"!=typeof Symbol&&(Y.prototype[Symbol.for("nodejs.util.inspect.custom")]=function(){return O(this)}),Y.random=Y.rand,Y.randomInt=Y.randInt,Y.diagonal=Y.diag,Y.prototype.diagonal=Y.prototype.diag,Y.identity=Y.eye,Y.prototype.negate=Y.prototype.neg,Y.prototype.tensorProduct=Y.prototype.kroneckerProduct;class X extends Y{constructor(t,e){if(super(),X.isMatrix(t))return t.clone();if(Number.isInteger(t)&&t>=0){if(this.data=[],!(Number.isInteger(e)&&e>=0))throw new TypeError("nColumns must be a positive integer");for(let r=0;r<t;r++)this.data.push(new Float64Array(e))}else{if(!z(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 o=0;o<t;o++){if(r[o].length!==e)throw new RangeError("Inconsistent array dimensions");if(!r[o].every((t=>"number"==typeof t)))throw new TypeError("Input data contains non-numeric values");this.data.push(Float64Array.from(r[o]))}}}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 U(this,t),this.data.splice(t,1),this.rows-=1,this}addRow(t,e){return void 0===e&&(e=t,t=this.rows),U(this,t,!0),e=Float64Array.from(K(this,e)),this.data.splice(t,0,e),this.rows+=1,this}removeColumn(t){B(this,t);for(let e=0;e<this.rows;e++){const r=new Float64Array(this.columns-1);for(let o=0;o<t;o++)r[o]=this.data[e][o];for(let o=t+1;o<this.columns;o++)r[o-1]=this.data[e][o];this.data[e]=r}return this.columns-=1,this}addColumn(t,e){void 0===e&&(e=t,t=this.columns),B(this,t,!0),e=W(this,e);for(let r=0;r<this.rows;r++){const o=new Float64Array(this.columns+1);let s=0;for(;s<t;s++)o[s]=this.data[r][s];for(o[s++]=e[r];s<this.columns+1;s++)o[s]=this.data[r][s-1];this.data[r]=o}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}}(Y,X);class Z extends Y{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 tt(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 et{constructor(t,e={}){if((t=Z.checkMatrix(t)).isEmpty())throw new Error("Matrix must be non-empty");let r=t.rows,o=t.columns;const{computeLeftSingularVectors:s=!0,computeRightSingularVectors:n=!0,autoTranspose:i=!1}=e;let a,h=Boolean(s),u=Boolean(n),l=!1;if(r<o)if(i){a=t.transpose(),r=a.rows,o=a.columns,l=!0;let e=h;h=u,u=e}else a=t.clone(),console.warn("Computing SVD on a matrix with more columns than rows. Consider enabling autoTranspose");else a=t.clone();let c=Math.min(r,o),f=Math.min(r+1,o),d=new Float64Array(f),g=new X(r,c),m=new X(o,o),p=new Float64Array(o),w=new Float64Array(r),y=new Float64Array(f);for(let t=0;t<f;t++)y[t]=t;let v=Math.min(r-1,o),M=Math.max(0,Math.min(o-2,r)),b=Math.max(v,M);for(let t=0;t<b;t++){if(t<v){d[t]=0;for(let e=t;e<r;e++)d[t]=tt(d[t],a.get(e,t));if(0!==d[t]){a.get(t,t)<0&&(d[t]=-d[t]);for(let e=t;e<r;e++)a.set(e,t,a.get(e,t)/d[t]);a.set(t,t,a.get(t,t)+1)}d[t]=-d[t]}for(let e=t+1;e<o;e++){if(t<v&&0!==d[t]){let o=0;for(let s=t;s<r;s++)o+=a.get(s,t)*a.get(s,e);o=-o/a.get(t,t);for(let s=t;s<r;s++)a.set(s,e,a.get(s,e)+o*a.get(s,t))}p[e]=a.get(t,e)}if(h&&t<v)for(let e=t;e<r;e++)g.set(e,t,a.get(e,t));if(t<M){p[t]=0;for(let e=t+1;e<o;e++)p[t]=tt(p[t],p[e]);if(0!==p[t]){p[t+1]<0&&(p[t]=0-p[t]);for(let e=t+1;e<o;e++)p[e]/=p[t];p[t+1]+=1}if(p[t]=-p[t],t+1<r&&0!==p[t]){for(let e=t+1;e<r;e++)w[e]=0;for(let e=t+1;e<r;e++)for(let r=t+1;r<o;r++)w[e]+=p[r]*a.get(e,r);for(let e=t+1;e<o;e++){let o=-p[e]/p[t+1];for(let s=t+1;s<r;s++)a.set(s,e,a.get(s,e)+o*w[s])}}if(u)for(let e=t+1;e<o;e++)m.set(e,t,p[e])}}let E=Math.min(o,r+1);if(v<o&&(d[v]=a.get(v,v)),r<E&&(d[E-1]=0),M+1<E&&(p[M]=a.get(M,E-1)),p[E-1]=0,h){for(let t=v;t<c;t++){for(let e=0;e<r;e++)g.set(e,t,0);g.set(t,t,1)}for(let t=v-1;t>=0;t--)if(0!==d[t]){for(let e=t+1;e<c;e++){let o=0;for(let s=t;s<r;s++)o+=g.get(s,t)*g.get(s,e);o=-o/g.get(t,t);for(let s=t;s<r;s++)g.set(s,e,g.get(s,e)+o*g.get(s,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(u)for(let t=o-1;t>=0;t--){if(t<M&&0!==p[t])for(let e=t+1;e<o;e++){let r=0;for(let s=t+1;s<o;s++)r+=m.get(s,t)*m.get(s,e);r=-r/m.get(t+1,t);for(let s=t+1;s<o;s++)m.set(s,e,m.get(s,e)+r*m.get(s,t))}for(let e=0;e<o;e++)m.set(e,t,0);m.set(t,t,1)}let x=E-1,S=0,N=Number.EPSILON;for(;E>0;){let t,e;for(t=E-2;t>=-1&&-1!==t;t--){const e=Number.MIN_VALUE+N*Math.abs(d[t]+Math.abs(d[t+1]));if(Math.abs(p[t])<=e||Number.isNaN(p[t])){p[t]=0;break}}if(t===E-2)e=4;else{let r;for(r=E-1;r>=t&&r!==t;r--){let e=(r!==E?Math.abs(p[r]):0)+(r!==t+1?Math.abs(p[r-1]):0);if(Math.abs(d[r])<=N*e){d[r]=0;break}}r===t?e=3:r===E-1?e=1:(e=2,t=r)}switch(t++,e){case 1:{let e=p[E-2];p[E-2]=0;for(let r=E-2;r>=t;r--){let s=tt(d[r],e),n=d[r]/s,i=e/s;if(d[r]=s,r!==t&&(e=-i*p[r-1],p[r-1]=n*p[r-1]),u)for(let t=0;t<o;t++)s=n*m.get(t,r)+i*m.get(t,E-1),m.set(t,E-1,-i*m.get(t,r)+n*m.get(t,E-1)),m.set(t,r,s)}break}case 2:{let e=p[t-1];p[t-1]=0;for(let o=t;o<E;o++){let s=tt(d[o],e),n=d[o]/s,i=e/s;if(d[o]=s,e=-i*p[o],p[o]=n*p[o],h)for(let e=0;e<r;e++)s=n*g.get(e,o)+i*g.get(e,t-1),g.set(e,t-1,-i*g.get(e,o)+n*g.get(e,t-1)),g.set(e,o,s)}break}case 3:{const e=Math.max(Math.abs(d[E-1]),Math.abs(d[E-2]),Math.abs(p[E-2]),Math.abs(d[t]),Math.abs(p[t])),s=d[E-1]/e,n=d[E-2]/e,i=p[E-2]/e,a=d[t]/e,l=p[t]/e,c=((n+s)*(n-s)+i*i)/2,f=s*i*(s*i);let w=0;0===c&&0===f||(w=c<0?0-Math.sqrt(c*c+f):Math.sqrt(c*c+f),w=f/(c+w));let y=(a+s)*(a-s)+w,v=a*l;for(let e=t;e<E-1;e++){let s=tt(y,v);0===s&&(s=Number.MIN_VALUE);let n=y/s,i=v/s;if(e!==t&&(p[e-1]=s),y=n*d[e]+i*p[e],p[e]=n*p[e]-i*d[e],v=i*d[e+1],d[e+1]=n*d[e+1],u)for(let t=0;t<o;t++)s=n*m.get(t,e)+i*m.get(t,e+1),m.set(t,e+1,-i*m.get(t,e)+n*m.get(t,e+1)),m.set(t,e,s);if(s=tt(y,v),0===s&&(s=Number.MIN_VALUE),n=y/s,i=v/s,d[e]=s,y=n*p[e]+i*d[e+1],d[e+1]=-i*p[e]+n*d[e+1],v=i*p[e+1],p[e+1]=n*p[e+1],h&&e<r-1)for(let t=0;t<r;t++)s=n*g.get(t,e)+i*g.get(t,e+1),g.set(t,e+1,-i*g.get(t,e)+n*g.get(t,e+1)),g.set(t,e,s)}p[E-2]=y,S+=1;break}case 4:if(d[t]<=0&&(d[t]=d[t]<0?-d[t]:0,u))for(let e=0;e<=x;e++)m.set(e,t,-m.get(e,t));for(;t<x&&!(d[t]>=d[t+1]);){let e=d[t];if(d[t]=d[t+1],d[t+1]=e,u&&t<o-1)for(let r=0;r<o;r++)e=m.get(r,t+1),m.set(r,t+1,m.get(r,t)),m.set(r,t,e);if(h&&t<r-1)for(let o=0;o<r;o++)e=g.get(o,t+1),g.set(o,t+1,g.get(o,t)),g.set(o,t,e);t++}S=0,E--}}if(l){let t=m;m=g,g=t}this.m=r,this.n=o,this.s=d,this.U=g,this.V=m}solve(t){let e=t,r=this.threshold,o=this.s.length,s=X.zeros(o,o);for(let t=0;t<o;t++)Math.abs(this.s[t])<=r?s.set(t,t,0):s.set(t,t,1/this.s[t]);let n=this.U,i=this.rightSingularVectors,a=i.mmul(s),h=i.rows,u=n.rows,l=X.zeros(h,u);for(let t=0;t<h;t++)for(let e=0;e<u;e++){let r=0;for(let s=0;s<o;s++)r+=a.get(t,s)*n.get(e,s);l.set(t,e,r)}return l.mmul(e)}solveForDiagonal(t){return this.solve(X.diag(t))}inverse(){let t=this.V,e=this.threshold,r=t.rows,o=t.columns,s=new X(r,this.s.length);for(let n=0;n<r;n++)for(let r=0;r<o;r++)Math.abs(this.s[r])>e&&s.set(n,r,t.get(n,r)/this.s[r]);let n=this.U,i=n.rows,a=n.columns,h=new X(r,i);for(let t=0;t<r;t++)for(let e=0;e<i;e++){let r=0;for(let o=0;o<a;o++)r+=s.get(t,o)*n.get(e,o);h.set(t,e,r)}return h}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 o=0,s=r.length;o<s;o++)r[o]>t&&e++;return e}get diagonal(){return Array.from(this.s)}get threshold(){return Number.EPSILON/2*Math.max(this.m,this.n)*this.s[0]}get leftSingularVectors(){return this.U}get rightSingularVectors(){return this.V}get diagonalMatrix(){return X.diag(this.s)}}var rt={center:[0,0],linkDistance:50},ot=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="mds",this.options=o(o({},rt),t)}return t.prototype.execute=function(t,e){return this.genericMDSLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericMDSLayout(!0,t,e)},t.prototype.genericMDSLayout=function(t,e,r){var s=o(o({},this.options),r),n=s.center,i=void 0===n?[0,0]:n,a=s.linkDistance,h=void 0===a?50:a,u=s.layoutInvisibles,f=s.onLayoutEnd,d=e.getAllNodes(),m=e.getAllEdges();if(u||(d=d.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),m=m.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!d||0===d.length){var p={nodes:[],edges:m};return null==f||f(p),p}if(1===d.length){t&&e.mergeNodeData(d[0].id,{x:i[0],y:i[1]});var w={nodes:[o(o({},d[0]),{data:o(o({},d[0].data),{x:i[0],y:i[1]})})],edges:m};return null==f||f(w),w}var y=c({nodes:d,edges:m},!1),v=l(y);st(v);var M=function(t,e){var r=[];return t.forEach((function(t){var o=[];t.forEach((function(t){o.push(t*e)})),r.push(o)})),r}(v,h),b=nt(M),E=[];b.forEach((function(t,e){var r=g(d[e]);r.data.x=t[0]+i[0],r.data.y=t[1]+i[1],E.push(r)})),t&&E.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var x={nodes:E,edges:m};return null==f||f(x),x},t}(),st=function(t){var e=-999999;t.forEach((function(t){t.forEach((function(t){t!==1/0&&e<t&&(e=t)}))})),t.forEach((function(r,o){r.forEach((function(r,s){r===1/0&&(t[o][s]=e)}))}))},nt=function(t){var e=X.mul(X.pow(t,2),-.5),r=e.mean("row"),o=e.mean("column"),s=e.mean();e.add(s).subRowVector(r).subColumnVector(o);var n=new et(e),i=X.sqrt(n.diagonalMatrix).diagonal();return n.leftSingularVectors.toJSON().map((function(t){return X.mul([t],[i]).toJSON()[0].splice(0,2)}))},it={iterations:10,height:10,width:10,speed:100,gravity:10,k:5},at=function(t,e,r,o,s,n){e.forEach((function(i,a){r[a]={x:0,y:0},e.forEach((function(e,h){if(a!==h&&s[a]===s[h]){var u=i.x-e.x,l=i.y-e.y,c=Math.sqrt(u*u+l*l);if(0===c){c=1;var f=a>h?1:-1;u=.01*f,l=.01*f}if(c<n(t[a])/2+n(t[h])/2){var d=o*o/c;r[a].x+=u/c*d,r[a].y+=l/c*d}}}))}))},ht=function(t,e,r,o,s,n,i,a){var h=n||i/10;return o&&e.forEach((function(e,r){var o=t[r].x-t[s].x,n=t[r].y-t[s].y,i=Math.sqrt(o*o+n*n),a=n/i,h=-o/i,u=Math.sqrt(e.x*e.x+e.y*e.y),l=Math.acos((a*e.x+h*e.y)/u);l>Math.PI/2&&(l-=Math.PI/2,a*=-1,h*=-1);var c=Math.cos(l)*u;e.x=a*c,e.y=h*c})),t.forEach((function(n,i){if(i!==s){var u=Math.sqrt(e[i].x*e[i].x+e[i].y*e[i].y);if(u>0&&i!==s){var l=Math.min(h*(r/800),u);if(n.x+=e[i].x/u*l,n.y+=e[i].y/u*l,o){var c=n.x-t[s].x,f=n.y-t[s].y,d=Math.sqrt(c*c+f*f);c=c/d*a[i],f=f/d*a[i],n.x=t[s].x+c,n.y=t[s].y+f}}}})),t},ut={maxIteration:1e3,focusNode:null,unitRadius:null,linkDistance:50,preventOverlap:!1,nodeSize:void 0,nodeSpacing:void 0,strictRadial:!0,maxPreventOverlapIteration:200,sortBy:void 0,sortStrength:10},lt=function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="radial",this.options=o(o({},ut),t)}return t.prototype.execute=function(t,e){return this.genericRadialLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRadialLayout(!0,t,e)},t.prototype.genericRadialLayout=function(t,e,r){var a=o(o({},this.options),r),h=a.width,u=a.height,f=a.center,d=a.focusNode,g=a.unitRadius,m=a.nodeSize,p=a.nodeSpacing,w=a.strictRadial,y=a.preventOverlap,v=a.maxPreventOverlapIteration,M=a.sortBy,b=a.linkDistance,E=void 0===b?50:b,x=a.sortStrength,S=void 0===x?10:x,N=a.maxIteration,R=void 0===N?1e3:N,I=a.layoutInvisibles,k=a.onLayoutEnd,A=e.getAllNodes(),T=e.getAllEdges();if(I||(A=A.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})),T=T.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e}))),!A||0===A.length){var C={nodes:[],edges:T};return null==k||k(C),C}var D=h||"undefined"==typeof window?h:window.innerWidth,z=u||"undefined"==typeof window?u:window.innerHeight,P=f||[D/2,z/2];if(1===A.length){t&&e.mergeNodeData(A[0].id,{x:P[0],y:P[1]});var V={nodes:[o(o({},A[0]),{data:o(o({},A[0].data),{x:P[0],y:P[1]})})],edges:T};return null==k||k(V),V}var q=A[0];if(i(d)){for(var j=0;j<A.length;j++)if(A[j].id===d){q=A[j];break}}else q=d||A[0];var F=gt(A,q.id),O=c({nodes:A,edges:T},!1),L=l(O),$=pt(L,F);mt(L,F,$+1);var U=L[F],B=D-P[0]>P[0]?P[0]:D-P[0],K=z-P[1]>P[1]?P[1]:z-P[1];0===B&&(B=D/2),0===K&&(K=z/2);var W=Math.min(B,K),J=Math.max.apply(Math,n([],s(U),!1)),_=[],G=g||W/J;U.forEach((function(t,e){_[e]=t*G}));var H,Y=ct(A,L,E,_,G,M,S),Q=ft(Y),Z=function(t,e,r){try{var o=X.mul(X.pow(e,2),-.5),s=o.mean("row"),n=o.mean("column"),i=o.mean();o.add(i).subRowVector(s).subColumnVector(n);var a=new et(o),h=X.sqrt(a.diagonalMatrix).diagonal();return a.leftSingularVectors.toJSON().map((function(e){return X.mul([e],[h]).toJSON()[0].splice(0,t)}))}catch(t){for(var u=[],l=0;l<e.length;l++){var c=Math.random()*r,f=Math.random()*r;u.push([c,f])}return u}}(E,Y,E).map((function(t){var e=s(t,2),r=e[0],o=e[1];return{x:(isNaN(r)?Math.random()*E:r)-Z[F].x,y:(isNaN(o)?Math.random()*E:o)-Z[F].y}}));if(this.run(R,Z,Q,Y,_,F),y){H=wt(m,p);var tt={nodes:A,nodeSizeFunc:H,positions:Z,radii:_,height:z,width:D,strictRadial:Boolean(w),focusIdx:F,iterations:v||200,k:Z.length/4.5};Z=function(t,e){for(var r=o(o({},it),e),s=r.positions,n=r.iterations,i=r.width,a=r.k,h=r.speed,u=void 0===h?100:h,l=r.strictRadial,c=r.focusIdx,f=r.radii,d=void 0===f?[]:f,g=r.nodeSizeFunc,m=t.getAllNodes(),p=[],w=i/10,y=0;y<n;y++)s.forEach((function(t,e){p[e]={x:0,y:0}})),at(m,s,p,a,d,g),ht(s,p,u,l,c,w,i,d);return s}(e,tt)}var rt=[];Z.forEach((function(t,e){rt.push(o(o({},A[e]),{data:o(o({},A[0].data),{x:t.x+P[0],y:t.y+P[1]})}))})),t&&rt.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var ot={nodes:rt,edges:T};return null==k||k(ot),ot},t.prototype.run=function(t,e,r,o,s,n){for(var i=0;i<=t;i++){var a=i/t;this.oneIteration(a,e,s,o,r,n)}},t.prototype.oneIteration=function(t,e,r,o,s,n){var i=1-t;e.forEach((function(a,h){var u=dt(a,{x:0,y:0}),l=0===u?0:1/u;if(h!==n){var c=0,f=0,d=0;e.forEach((function(t,e){if(h!==e){var r=dt(a,t),n=0===r?0:1/r,i=o[e][h];d+=s[h][e],c+=s[h][e]*(t.x+i*(a.x-t.x)*n),f+=s[h][e]*(t.y+i*(a.y-t.y)*n)}}));var g=0===r[h]?0:1/r[h];d*=i,d+=t*g*g,c*=i,c+=t*g*a.x*l,a.x=c/d,f*=i,f+=t*g*a.y*l,a.y=f/d}}))},t}(),ct=function(t,e,r,o,s,n,a){if(!t)return[];var h=[];return e&&e.forEach((function(e,u){var l=[];e.forEach((function(e,h){if(u===h)l.push(0);else if(o[u]===o[h])if("data"===n)l.push(e*(Math.abs(u-h)*a)/(o[u]/s));else if(n){var c=t[u][n]||0,f=t[h][n]||0;i(c)&&(c=c.charCodeAt(0)),i(f)&&(f=f.charCodeAt(0)),l.push(e*(Math.abs(c-f)*a)/(o[u]/s))}else l.push(e*r/(o[u]/s));else{var d=(r+s)/2;l.push(e*d)}})),h.push(l)})),h},ft=function(t){for(var e=t.length,r=t[0].length,o=[],s=0;s<e;s++){for(var n=[],i=0;i<r;i++)0!==t[s][i]?n.push(1/(t[s][i]*t[s][i])):n.push(0);o.push(n)}return o},dt=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},gt=function(t,e){var r=-1;return t.forEach((function(t,o){t.id===e&&(r=o)})),Math.max(r,0)},mt=function(t,e,r){for(var o=t.length,s=0;s<o;s++)if(t[e][s]===1/0){t[e][s]=r,t[s][e]=r;for(var n=0;n<o;n++)t[s][n]!==1/0&&t[e][n]===1/0&&(t[e][n]=r+t[s][n],t[n][e]=r+t[s][n])}for(s=0;s<o;s++)if(s!==e)for(n=0;n<o;n++)if(t[s][n]===1/0){var i=Math.abs(t[e][s]-t[e][n]);i=0===i?1:i,t[s][n]=i}},pt=function(t,e){for(var r=0,o=0;o<t[e].length;o++)t[e][o]!==1/0&&(r=t[e][o]>r?t[e][o]:r);return r},wt=function(t,e){var r;return r=u(e)?function(){return e}:m(e)?e:function(){return 0},t?h(t)?function(e){return(t[0]>t[1]?t[0]:t[1])+r(e)}:function(e){return t+r(e)}:function(t){return t.data.bboxSize?Math.max(t.data.bboxSize[0],t.data.bboxSize[1])+r(t):t.data.size?h(t.data.size)?Math.max(t.data.size[0],t.data.size[1])+r(t):f(t.data.size)?(t.data.size.width>t.data.size.height?t.data.size.width:t.data.size.height)+r(t):t.data.size+r(t):10+r(t)}},yt={center:[0,0],width:300,height:300},vt={circular:v,concentric:x,mds:ot,random:function(){function t(t){void 0===t&&(t={}),this.options=t,this.id="random",this.options=o(o({},yt),t)}return t.prototype.execute=function(t,e){return this.genericRandomLayout(!1,t,e)},t.prototype.assign=function(t,e){this.genericRandomLayout(!0,t,e)},t.prototype.genericRandomLayout=function(t,e,r){var s=o(o({},this.options),r),n=s.center,i=s.width,a=s.height,h=s.layoutInvisibles,u=s.onLayoutEnd,l=e.getAllNodes();h||(l=l.filter((function(t){var e=(t.data||{}).visible;return e||void 0===e})));var c=i||"undefined"==typeof window?i:window.innerWidth,f=a||"undefined"==typeof window?a:window.innerHeight,d=n||[c/2,f/2],g=[];l&&l.forEach((function(t){g.push({id:t.id,data:{x:.9*(Math.random()-.5)*c+d[0],y:.9*(Math.random()-.5)*f+d[1]}})})),t&&g.forEach((function(t){return e.mergeNodeData(t.id,{x:t.data.x,y:t.data.y})}));var m={nodes:g,edges:e.getAllEdges()};return null==u||u(m),m},t}(),grid:N,radial:lt};function Mt(t,e){var o=t.layout,s=o.id,n=o.options,i=t.nodes,a=t.edges,h=new r({nodes:i,edges:a}),u=vt[s];if(!u)throw new Error("Unknown layout id: ".concat(s));return[new u(n).execute(h),e]}addEventListener("message",(function(t){var r,o=t.data,s=o.type,n=o.method,i=o.id,a=o.params;"RPC"===s&&n&&((r=e[n])?Promise.resolve().then((function(){return r.apply(e,a)})):Promise.reject("No such method")).then((function(t){postMessage({type:"RPC",id:i,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:i,error:e})}))})),postMessage({type:"RPC",method:"ready"})})();
|
|
2
|
-
//# sourceMappingURL=dc35eb8f009986ba5391.worker.js.map
|