@xxrandr/conecta-diagram 0.0.0-stage → 0.1.4
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/LICENSE +21 -0
- package/README.md +319 -2
- package/dist/chunk-3QGSCPWL.cjs +663 -0
- package/dist/chunk-43VYPB4U.js +2136 -0
- package/dist/chunk-6ADTOXBT.cjs +626 -0
- package/dist/chunk-B2RLLFGC.js +0 -0
- package/dist/chunk-GXOBW2BK.js +290 -0
- package/dist/chunk-HZER5BPR.js +1122 -0
- package/dist/chunk-IT5H6WO2.js +626 -0
- package/dist/chunk-LKOWNTPR.cjs +1 -0
- package/dist/chunk-Q62JPMJH.js +663 -0
- package/dist/chunk-QI4NNFRQ.cjs +290 -0
- package/dist/chunk-VD32JNDO.cjs +2136 -0
- package/dist/chunk-ZMSQTBVW.cjs +1122 -0
- package/dist/core/index.cjs +56 -0
- package/dist/core/index.d.cts +65 -0
- package/dist/core/index.d.ts +65 -0
- package/dist/core/index.js +56 -0
- package/dist/d3/index.cjs +8 -0
- package/dist/d3/index.d.cts +46 -0
- package/dist/d3/index.d.ts +46 -0
- package/dist/d3/index.js +8 -0
- package/dist/index.cjs +71 -0
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +71 -0
- package/dist/photon.css +339 -0
- package/dist/runner-display-BkBJpBY-.d.ts +151 -0
- package/dist/runner-display-DHHtavSX.d.cts +151 -0
- package/dist/store-CtOInpPu.d.cts +242 -0
- package/dist/store-CtOInpPu.d.ts +242 -0
- package/dist/svg/index.cjs +15 -0
- package/dist/svg/index.d.cts +172 -0
- package/dist/svg/index.d.ts +172 -0
- package/dist/svg/index.js +15 -0
- package/docs/devtools-refactor.md +93 -0
- package/docs/java-runtime-integration.md +268 -0
- package/docs/photon-template.html +547 -0
- package/docs/presentation-architecture.md +30 -0
- package/docs/runner-display.md +109 -0
- package/package.json +130 -4
|
@@ -0,0 +1,1122 @@
|
|
|
1
|
+
import {
|
|
2
|
+
FlowError,
|
|
3
|
+
assertFlow
|
|
4
|
+
} from "./chunk-Q62JPMJH.js";
|
|
5
|
+
|
|
6
|
+
// node_modules/d3-quadtree/src/add.js
|
|
7
|
+
function add_default(d) {
|
|
8
|
+
const x2 = +this._x.call(null, d), y2 = +this._y.call(null, d);
|
|
9
|
+
return add(this.cover(x2, y2), x2, y2, d);
|
|
10
|
+
}
|
|
11
|
+
function add(tree, x2, y2, d) {
|
|
12
|
+
if (isNaN(x2) || isNaN(y2)) return tree;
|
|
13
|
+
var parent, node = tree._root, leaf = { data: d }, x0 = tree._x0, y0 = tree._y0, x1 = tree._x1, y1 = tree._y1, xm, ym, xp, yp, right, bottom, i, j;
|
|
14
|
+
if (!node) return tree._root = leaf, tree;
|
|
15
|
+
while (node.length) {
|
|
16
|
+
if (right = x2 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
17
|
+
else x1 = xm;
|
|
18
|
+
if (bottom = y2 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
19
|
+
else y1 = ym;
|
|
20
|
+
if (parent = node, !(node = node[i = bottom << 1 | right])) return parent[i] = leaf, tree;
|
|
21
|
+
}
|
|
22
|
+
xp = +tree._x.call(null, node.data);
|
|
23
|
+
yp = +tree._y.call(null, node.data);
|
|
24
|
+
if (x2 === xp && y2 === yp) return leaf.next = node, parent ? parent[i] = leaf : tree._root = leaf, tree;
|
|
25
|
+
do {
|
|
26
|
+
parent = parent ? parent[i] = new Array(4) : tree._root = new Array(4);
|
|
27
|
+
if (right = x2 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
28
|
+
else x1 = xm;
|
|
29
|
+
if (bottom = y2 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
30
|
+
else y1 = ym;
|
|
31
|
+
} while ((i = bottom << 1 | right) === (j = (yp >= ym) << 1 | xp >= xm));
|
|
32
|
+
return parent[j] = node, parent[i] = leaf, tree;
|
|
33
|
+
}
|
|
34
|
+
function addAll(data) {
|
|
35
|
+
var d, i, n = data.length, x2, y2, xz = new Array(n), yz = new Array(n), x0 = Infinity, y0 = Infinity, x1 = -Infinity, y1 = -Infinity;
|
|
36
|
+
for (i = 0; i < n; ++i) {
|
|
37
|
+
if (isNaN(x2 = +this._x.call(null, d = data[i])) || isNaN(y2 = +this._y.call(null, d))) continue;
|
|
38
|
+
xz[i] = x2;
|
|
39
|
+
yz[i] = y2;
|
|
40
|
+
if (x2 < x0) x0 = x2;
|
|
41
|
+
if (x2 > x1) x1 = x2;
|
|
42
|
+
if (y2 < y0) y0 = y2;
|
|
43
|
+
if (y2 > y1) y1 = y2;
|
|
44
|
+
}
|
|
45
|
+
if (x0 > x1 || y0 > y1) return this;
|
|
46
|
+
this.cover(x0, y0).cover(x1, y1);
|
|
47
|
+
for (i = 0; i < n; ++i) {
|
|
48
|
+
add(this, xz[i], yz[i], data[i]);
|
|
49
|
+
}
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// node_modules/d3-quadtree/src/cover.js
|
|
54
|
+
function cover_default(x2, y2) {
|
|
55
|
+
if (isNaN(x2 = +x2) || isNaN(y2 = +y2)) return this;
|
|
56
|
+
var x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1;
|
|
57
|
+
if (isNaN(x0)) {
|
|
58
|
+
x1 = (x0 = Math.floor(x2)) + 1;
|
|
59
|
+
y1 = (y0 = Math.floor(y2)) + 1;
|
|
60
|
+
} else {
|
|
61
|
+
var z = x1 - x0 || 1, node = this._root, parent, i;
|
|
62
|
+
while (x0 > x2 || x2 >= x1 || y0 > y2 || y2 >= y1) {
|
|
63
|
+
i = (y2 < y0) << 1 | x2 < x0;
|
|
64
|
+
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
|
|
65
|
+
switch (i) {
|
|
66
|
+
case 0:
|
|
67
|
+
x1 = x0 + z, y1 = y0 + z;
|
|
68
|
+
break;
|
|
69
|
+
case 1:
|
|
70
|
+
x0 = x1 - z, y1 = y0 + z;
|
|
71
|
+
break;
|
|
72
|
+
case 2:
|
|
73
|
+
x1 = x0 + z, y0 = y1 - z;
|
|
74
|
+
break;
|
|
75
|
+
case 3:
|
|
76
|
+
x0 = x1 - z, y0 = y1 - z;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (this._root && this._root.length) this._root = node;
|
|
81
|
+
}
|
|
82
|
+
this._x0 = x0;
|
|
83
|
+
this._y0 = y0;
|
|
84
|
+
this._x1 = x1;
|
|
85
|
+
this._y1 = y1;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// node_modules/d3-quadtree/src/data.js
|
|
90
|
+
function data_default() {
|
|
91
|
+
var data = [];
|
|
92
|
+
this.visit(function(node) {
|
|
93
|
+
if (!node.length) do
|
|
94
|
+
data.push(node.data);
|
|
95
|
+
while (node = node.next);
|
|
96
|
+
});
|
|
97
|
+
return data;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// node_modules/d3-quadtree/src/extent.js
|
|
101
|
+
function extent_default(_) {
|
|
102
|
+
return arguments.length ? this.cover(+_[0][0], +_[0][1]).cover(+_[1][0], +_[1][1]) : isNaN(this._x0) ? void 0 : [[this._x0, this._y0], [this._x1, this._y1]];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// node_modules/d3-quadtree/src/quad.js
|
|
106
|
+
function quad_default(node, x0, y0, x1, y1) {
|
|
107
|
+
this.node = node;
|
|
108
|
+
this.x0 = x0;
|
|
109
|
+
this.y0 = y0;
|
|
110
|
+
this.x1 = x1;
|
|
111
|
+
this.y1 = y1;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// node_modules/d3-quadtree/src/find.js
|
|
115
|
+
function find_default(x2, y2, radius) {
|
|
116
|
+
var data, x0 = this._x0, y0 = this._y0, x1, y1, x22, y22, x3 = this._x1, y3 = this._y1, quads = [], node = this._root, q, i;
|
|
117
|
+
if (node) quads.push(new quad_default(node, x0, y0, x3, y3));
|
|
118
|
+
if (radius == null) radius = Infinity;
|
|
119
|
+
else {
|
|
120
|
+
x0 = x2 - radius, y0 = y2 - radius;
|
|
121
|
+
x3 = x2 + radius, y3 = y2 + radius;
|
|
122
|
+
radius *= radius;
|
|
123
|
+
}
|
|
124
|
+
while (q = quads.pop()) {
|
|
125
|
+
if (!(node = q.node) || (x1 = q.x0) > x3 || (y1 = q.y0) > y3 || (x22 = q.x1) < x0 || (y22 = q.y1) < y0) continue;
|
|
126
|
+
if (node.length) {
|
|
127
|
+
var xm = (x1 + x22) / 2, ym = (y1 + y22) / 2;
|
|
128
|
+
quads.push(
|
|
129
|
+
new quad_default(node[3], xm, ym, x22, y22),
|
|
130
|
+
new quad_default(node[2], x1, ym, xm, y22),
|
|
131
|
+
new quad_default(node[1], xm, y1, x22, ym),
|
|
132
|
+
new quad_default(node[0], x1, y1, xm, ym)
|
|
133
|
+
);
|
|
134
|
+
if (i = (y2 >= ym) << 1 | x2 >= xm) {
|
|
135
|
+
q = quads[quads.length - 1];
|
|
136
|
+
quads[quads.length - 1] = quads[quads.length - 1 - i];
|
|
137
|
+
quads[quads.length - 1 - i] = q;
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
var dx = x2 - +this._x.call(null, node.data), dy = y2 - +this._y.call(null, node.data), d2 = dx * dx + dy * dy;
|
|
141
|
+
if (d2 < radius) {
|
|
142
|
+
var d = Math.sqrt(radius = d2);
|
|
143
|
+
x0 = x2 - d, y0 = y2 - d;
|
|
144
|
+
x3 = x2 + d, y3 = y2 + d;
|
|
145
|
+
data = node.data;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return data;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
// node_modules/d3-quadtree/src/remove.js
|
|
153
|
+
function remove_default(d) {
|
|
154
|
+
if (isNaN(x2 = +this._x.call(null, d)) || isNaN(y2 = +this._y.call(null, d))) return this;
|
|
155
|
+
var parent, node = this._root, retainer, previous, next, x0 = this._x0, y0 = this._y0, x1 = this._x1, y1 = this._y1, x2, y2, xm, ym, right, bottom, i, j;
|
|
156
|
+
if (!node) return this;
|
|
157
|
+
if (node.length) while (true) {
|
|
158
|
+
if (right = x2 >= (xm = (x0 + x1) / 2)) x0 = xm;
|
|
159
|
+
else x1 = xm;
|
|
160
|
+
if (bottom = y2 >= (ym = (y0 + y1) / 2)) y0 = ym;
|
|
161
|
+
else y1 = ym;
|
|
162
|
+
if (!(parent = node, node = node[i = bottom << 1 | right])) return this;
|
|
163
|
+
if (!node.length) break;
|
|
164
|
+
if (parent[i + 1 & 3] || parent[i + 2 & 3] || parent[i + 3 & 3]) retainer = parent, j = i;
|
|
165
|
+
}
|
|
166
|
+
while (node.data !== d) if (!(previous = node, node = node.next)) return this;
|
|
167
|
+
if (next = node.next) delete node.next;
|
|
168
|
+
if (previous) return next ? previous.next = next : delete previous.next, this;
|
|
169
|
+
if (!parent) return this._root = next, this;
|
|
170
|
+
next ? parent[i] = next : delete parent[i];
|
|
171
|
+
if ((node = parent[0] || parent[1] || parent[2] || parent[3]) && node === (parent[3] || parent[2] || parent[1] || parent[0]) && !node.length) {
|
|
172
|
+
if (retainer) retainer[j] = node;
|
|
173
|
+
else this._root = node;
|
|
174
|
+
}
|
|
175
|
+
return this;
|
|
176
|
+
}
|
|
177
|
+
function removeAll(data) {
|
|
178
|
+
for (var i = 0, n = data.length; i < n; ++i) this.remove(data[i]);
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// node_modules/d3-quadtree/src/root.js
|
|
183
|
+
function root_default() {
|
|
184
|
+
return this._root;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// node_modules/d3-quadtree/src/size.js
|
|
188
|
+
function size_default() {
|
|
189
|
+
var size = 0;
|
|
190
|
+
this.visit(function(node) {
|
|
191
|
+
if (!node.length) do
|
|
192
|
+
++size;
|
|
193
|
+
while (node = node.next);
|
|
194
|
+
});
|
|
195
|
+
return size;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// node_modules/d3-quadtree/src/visit.js
|
|
199
|
+
function visit_default(callback) {
|
|
200
|
+
var quads = [], q, node = this._root, child, x0, y0, x1, y1;
|
|
201
|
+
if (node) quads.push(new quad_default(node, this._x0, this._y0, this._x1, this._y1));
|
|
202
|
+
while (q = quads.pop()) {
|
|
203
|
+
if (!callback(node = q.node, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1) && node.length) {
|
|
204
|
+
var xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
|
205
|
+
if (child = node[3]) quads.push(new quad_default(child, xm, ym, x1, y1));
|
|
206
|
+
if (child = node[2]) quads.push(new quad_default(child, x0, ym, xm, y1));
|
|
207
|
+
if (child = node[1]) quads.push(new quad_default(child, xm, y0, x1, ym));
|
|
208
|
+
if (child = node[0]) quads.push(new quad_default(child, x0, y0, xm, ym));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return this;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// node_modules/d3-quadtree/src/visitAfter.js
|
|
215
|
+
function visitAfter_default(callback) {
|
|
216
|
+
var quads = [], next = [], q;
|
|
217
|
+
if (this._root) quads.push(new quad_default(this._root, this._x0, this._y0, this._x1, this._y1));
|
|
218
|
+
while (q = quads.pop()) {
|
|
219
|
+
var node = q.node;
|
|
220
|
+
if (node.length) {
|
|
221
|
+
var child, x0 = q.x0, y0 = q.y0, x1 = q.x1, y1 = q.y1, xm = (x0 + x1) / 2, ym = (y0 + y1) / 2;
|
|
222
|
+
if (child = node[0]) quads.push(new quad_default(child, x0, y0, xm, ym));
|
|
223
|
+
if (child = node[1]) quads.push(new quad_default(child, xm, y0, x1, ym));
|
|
224
|
+
if (child = node[2]) quads.push(new quad_default(child, x0, ym, xm, y1));
|
|
225
|
+
if (child = node[3]) quads.push(new quad_default(child, xm, ym, x1, y1));
|
|
226
|
+
}
|
|
227
|
+
next.push(q);
|
|
228
|
+
}
|
|
229
|
+
while (q = next.pop()) {
|
|
230
|
+
callback(q.node, q.x0, q.y0, q.x1, q.y1);
|
|
231
|
+
}
|
|
232
|
+
return this;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// node_modules/d3-quadtree/src/x.js
|
|
236
|
+
function defaultX(d) {
|
|
237
|
+
return d[0];
|
|
238
|
+
}
|
|
239
|
+
function x_default(_) {
|
|
240
|
+
return arguments.length ? (this._x = _, this) : this._x;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
// node_modules/d3-quadtree/src/y.js
|
|
244
|
+
function defaultY(d) {
|
|
245
|
+
return d[1];
|
|
246
|
+
}
|
|
247
|
+
function y_default(_) {
|
|
248
|
+
return arguments.length ? (this._y = _, this) : this._y;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// node_modules/d3-quadtree/src/quadtree.js
|
|
252
|
+
function quadtree(nodes, x2, y2) {
|
|
253
|
+
var tree = new Quadtree(x2 == null ? defaultX : x2, y2 == null ? defaultY : y2, NaN, NaN, NaN, NaN);
|
|
254
|
+
return nodes == null ? tree : tree.addAll(nodes);
|
|
255
|
+
}
|
|
256
|
+
function Quadtree(x2, y2, x0, y0, x1, y1) {
|
|
257
|
+
this._x = x2;
|
|
258
|
+
this._y = y2;
|
|
259
|
+
this._x0 = x0;
|
|
260
|
+
this._y0 = y0;
|
|
261
|
+
this._x1 = x1;
|
|
262
|
+
this._y1 = y1;
|
|
263
|
+
this._root = void 0;
|
|
264
|
+
}
|
|
265
|
+
function leaf_copy(leaf) {
|
|
266
|
+
var copy = { data: leaf.data }, next = copy;
|
|
267
|
+
while (leaf = leaf.next) next = next.next = { data: leaf.data };
|
|
268
|
+
return copy;
|
|
269
|
+
}
|
|
270
|
+
var treeProto = quadtree.prototype = Quadtree.prototype;
|
|
271
|
+
treeProto.copy = function() {
|
|
272
|
+
var copy = new Quadtree(this._x, this._y, this._x0, this._y0, this._x1, this._y1), node = this._root, nodes, child;
|
|
273
|
+
if (!node) return copy;
|
|
274
|
+
if (!node.length) return copy._root = leaf_copy(node), copy;
|
|
275
|
+
nodes = [{ source: node, target: copy._root = new Array(4) }];
|
|
276
|
+
while (node = nodes.pop()) {
|
|
277
|
+
for (var i = 0; i < 4; ++i) {
|
|
278
|
+
if (child = node.source[i]) {
|
|
279
|
+
if (child.length) nodes.push({ source: child, target: node.target[i] = new Array(4) });
|
|
280
|
+
else node.target[i] = leaf_copy(child);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
return copy;
|
|
285
|
+
};
|
|
286
|
+
treeProto.add = add_default;
|
|
287
|
+
treeProto.addAll = addAll;
|
|
288
|
+
treeProto.cover = cover_default;
|
|
289
|
+
treeProto.data = data_default;
|
|
290
|
+
treeProto.extent = extent_default;
|
|
291
|
+
treeProto.find = find_default;
|
|
292
|
+
treeProto.remove = remove_default;
|
|
293
|
+
treeProto.removeAll = removeAll;
|
|
294
|
+
treeProto.root = root_default;
|
|
295
|
+
treeProto.size = size_default;
|
|
296
|
+
treeProto.visit = visit_default;
|
|
297
|
+
treeProto.visitAfter = visitAfter_default;
|
|
298
|
+
treeProto.x = x_default;
|
|
299
|
+
treeProto.y = y_default;
|
|
300
|
+
|
|
301
|
+
// node_modules/d3-force/src/constant.js
|
|
302
|
+
function constant_default(x2) {
|
|
303
|
+
return function() {
|
|
304
|
+
return x2;
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// node_modules/d3-force/src/jiggle.js
|
|
309
|
+
function jiggle_default(random) {
|
|
310
|
+
return (random() - 0.5) * 1e-6;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// node_modules/d3-force/src/link.js
|
|
314
|
+
function index(d) {
|
|
315
|
+
return d.index;
|
|
316
|
+
}
|
|
317
|
+
function find(nodeById, nodeId) {
|
|
318
|
+
var node = nodeById.get(nodeId);
|
|
319
|
+
if (!node) throw new Error("node not found: " + nodeId);
|
|
320
|
+
return node;
|
|
321
|
+
}
|
|
322
|
+
function link_default(links) {
|
|
323
|
+
var id = index, strength = defaultStrength, strengths, distance = constant_default(30), distances, nodes, count, bias, random, iterations = 1;
|
|
324
|
+
if (links == null) links = [];
|
|
325
|
+
function defaultStrength(link) {
|
|
326
|
+
return 1 / Math.min(count[link.source.index], count[link.target.index]);
|
|
327
|
+
}
|
|
328
|
+
function force(alpha) {
|
|
329
|
+
for (var k = 0, n = links.length; k < iterations; ++k) {
|
|
330
|
+
for (var i = 0, link, source, target, x2, y2, l, b; i < n; ++i) {
|
|
331
|
+
link = links[i], source = link.source, target = link.target;
|
|
332
|
+
x2 = target.x + target.vx - source.x - source.vx || jiggle_default(random);
|
|
333
|
+
y2 = target.y + target.vy - source.y - source.vy || jiggle_default(random);
|
|
334
|
+
l = Math.sqrt(x2 * x2 + y2 * y2);
|
|
335
|
+
l = (l - distances[i]) / l * alpha * strengths[i];
|
|
336
|
+
x2 *= l, y2 *= l;
|
|
337
|
+
target.vx -= x2 * (b = bias[i]);
|
|
338
|
+
target.vy -= y2 * b;
|
|
339
|
+
source.vx += x2 * (b = 1 - b);
|
|
340
|
+
source.vy += y2 * b;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
function initialize() {
|
|
345
|
+
if (!nodes) return;
|
|
346
|
+
var i, n = nodes.length, m2 = links.length, nodeById = new Map(nodes.map((d, i2) => [id(d, i2, nodes), d])), link;
|
|
347
|
+
for (i = 0, count = new Array(n); i < m2; ++i) {
|
|
348
|
+
link = links[i], link.index = i;
|
|
349
|
+
if (typeof link.source !== "object") link.source = find(nodeById, link.source);
|
|
350
|
+
if (typeof link.target !== "object") link.target = find(nodeById, link.target);
|
|
351
|
+
count[link.source.index] = (count[link.source.index] || 0) + 1;
|
|
352
|
+
count[link.target.index] = (count[link.target.index] || 0) + 1;
|
|
353
|
+
}
|
|
354
|
+
for (i = 0, bias = new Array(m2); i < m2; ++i) {
|
|
355
|
+
link = links[i], bias[i] = count[link.source.index] / (count[link.source.index] + count[link.target.index]);
|
|
356
|
+
}
|
|
357
|
+
strengths = new Array(m2), initializeStrength();
|
|
358
|
+
distances = new Array(m2), initializeDistance();
|
|
359
|
+
}
|
|
360
|
+
function initializeStrength() {
|
|
361
|
+
if (!nodes) return;
|
|
362
|
+
for (var i = 0, n = links.length; i < n; ++i) {
|
|
363
|
+
strengths[i] = +strength(links[i], i, links);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
function initializeDistance() {
|
|
367
|
+
if (!nodes) return;
|
|
368
|
+
for (var i = 0, n = links.length; i < n; ++i) {
|
|
369
|
+
distances[i] = +distance(links[i], i, links);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
force.initialize = function(_nodes, _random) {
|
|
373
|
+
nodes = _nodes;
|
|
374
|
+
random = _random;
|
|
375
|
+
initialize();
|
|
376
|
+
};
|
|
377
|
+
force.links = function(_) {
|
|
378
|
+
return arguments.length ? (links = _, initialize(), force) : links;
|
|
379
|
+
};
|
|
380
|
+
force.id = function(_) {
|
|
381
|
+
return arguments.length ? (id = _, force) : id;
|
|
382
|
+
};
|
|
383
|
+
force.iterations = function(_) {
|
|
384
|
+
return arguments.length ? (iterations = +_, force) : iterations;
|
|
385
|
+
};
|
|
386
|
+
force.strength = function(_) {
|
|
387
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initializeStrength(), force) : strength;
|
|
388
|
+
};
|
|
389
|
+
force.distance = function(_) {
|
|
390
|
+
return arguments.length ? (distance = typeof _ === "function" ? _ : constant_default(+_), initializeDistance(), force) : distance;
|
|
391
|
+
};
|
|
392
|
+
return force;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// node_modules/d3-dispatch/src/dispatch.js
|
|
396
|
+
var noop = { value: () => {
|
|
397
|
+
} };
|
|
398
|
+
function dispatch() {
|
|
399
|
+
for (var i = 0, n = arguments.length, _ = {}, t; i < n; ++i) {
|
|
400
|
+
if (!(t = arguments[i] + "") || t in _ || /[\s.]/.test(t)) throw new Error("illegal type: " + t);
|
|
401
|
+
_[t] = [];
|
|
402
|
+
}
|
|
403
|
+
return new Dispatch(_);
|
|
404
|
+
}
|
|
405
|
+
function Dispatch(_) {
|
|
406
|
+
this._ = _;
|
|
407
|
+
}
|
|
408
|
+
function parseTypenames(typenames, types) {
|
|
409
|
+
return typenames.trim().split(/^|\s+/).map(function(t) {
|
|
410
|
+
var name = "", i = t.indexOf(".");
|
|
411
|
+
if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i);
|
|
412
|
+
if (t && !types.hasOwnProperty(t)) throw new Error("unknown type: " + t);
|
|
413
|
+
return { type: t, name };
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
Dispatch.prototype = dispatch.prototype = {
|
|
417
|
+
constructor: Dispatch,
|
|
418
|
+
on: function(typename, callback) {
|
|
419
|
+
var _ = this._, T = parseTypenames(typename + "", _), t, i = -1, n = T.length;
|
|
420
|
+
if (arguments.length < 2) {
|
|
421
|
+
while (++i < n) if ((t = (typename = T[i]).type) && (t = get(_[t], typename.name))) return t;
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if (callback != null && typeof callback !== "function") throw new Error("invalid callback: " + callback);
|
|
425
|
+
while (++i < n) {
|
|
426
|
+
if (t = (typename = T[i]).type) _[t] = set(_[t], typename.name, callback);
|
|
427
|
+
else if (callback == null) for (t in _) _[t] = set(_[t], typename.name, null);
|
|
428
|
+
}
|
|
429
|
+
return this;
|
|
430
|
+
},
|
|
431
|
+
copy: function() {
|
|
432
|
+
var copy = {}, _ = this._;
|
|
433
|
+
for (var t in _) copy[t] = _[t].slice();
|
|
434
|
+
return new Dispatch(copy);
|
|
435
|
+
},
|
|
436
|
+
call: function(type, that) {
|
|
437
|
+
if ((n = arguments.length - 2) > 0) for (var args = new Array(n), i = 0, n, t; i < n; ++i) args[i] = arguments[i + 2];
|
|
438
|
+
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
|
|
439
|
+
for (t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
|
|
440
|
+
},
|
|
441
|
+
apply: function(type, that, args) {
|
|
442
|
+
if (!this._.hasOwnProperty(type)) throw new Error("unknown type: " + type);
|
|
443
|
+
for (var t = this._[type], i = 0, n = t.length; i < n; ++i) t[i].value.apply(that, args);
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
function get(type, name) {
|
|
447
|
+
for (var i = 0, n = type.length, c2; i < n; ++i) {
|
|
448
|
+
if ((c2 = type[i]).name === name) {
|
|
449
|
+
return c2.value;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function set(type, name, callback) {
|
|
454
|
+
for (var i = 0, n = type.length; i < n; ++i) {
|
|
455
|
+
if (type[i].name === name) {
|
|
456
|
+
type[i] = noop, type = type.slice(0, i).concat(type.slice(i + 1));
|
|
457
|
+
break;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
if (callback != null) type.push({ name, value: callback });
|
|
461
|
+
return type;
|
|
462
|
+
}
|
|
463
|
+
var dispatch_default = dispatch;
|
|
464
|
+
|
|
465
|
+
// node_modules/d3-timer/src/timer.js
|
|
466
|
+
var frame = 0;
|
|
467
|
+
var timeout = 0;
|
|
468
|
+
var interval = 0;
|
|
469
|
+
var pokeDelay = 1e3;
|
|
470
|
+
var taskHead;
|
|
471
|
+
var taskTail;
|
|
472
|
+
var clockLast = 0;
|
|
473
|
+
var clockNow = 0;
|
|
474
|
+
var clockSkew = 0;
|
|
475
|
+
var clock = typeof performance === "object" && performance.now ? performance : Date;
|
|
476
|
+
var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f) {
|
|
477
|
+
setTimeout(f, 17);
|
|
478
|
+
};
|
|
479
|
+
function now() {
|
|
480
|
+
return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
|
|
481
|
+
}
|
|
482
|
+
function clearNow() {
|
|
483
|
+
clockNow = 0;
|
|
484
|
+
}
|
|
485
|
+
function Timer() {
|
|
486
|
+
this._call = this._time = this._next = null;
|
|
487
|
+
}
|
|
488
|
+
Timer.prototype = timer.prototype = {
|
|
489
|
+
constructor: Timer,
|
|
490
|
+
restart: function(callback, delay, time) {
|
|
491
|
+
if (typeof callback !== "function") throw new TypeError("callback is not a function");
|
|
492
|
+
time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
|
|
493
|
+
if (!this._next && taskTail !== this) {
|
|
494
|
+
if (taskTail) taskTail._next = this;
|
|
495
|
+
else taskHead = this;
|
|
496
|
+
taskTail = this;
|
|
497
|
+
}
|
|
498
|
+
this._call = callback;
|
|
499
|
+
this._time = time;
|
|
500
|
+
sleep();
|
|
501
|
+
},
|
|
502
|
+
stop: function() {
|
|
503
|
+
if (this._call) {
|
|
504
|
+
this._call = null;
|
|
505
|
+
this._time = Infinity;
|
|
506
|
+
sleep();
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
};
|
|
510
|
+
function timer(callback, delay, time) {
|
|
511
|
+
var t = new Timer();
|
|
512
|
+
t.restart(callback, delay, time);
|
|
513
|
+
return t;
|
|
514
|
+
}
|
|
515
|
+
function timerFlush() {
|
|
516
|
+
now();
|
|
517
|
+
++frame;
|
|
518
|
+
var t = taskHead, e;
|
|
519
|
+
while (t) {
|
|
520
|
+
if ((e = clockNow - t._time) >= 0) t._call.call(void 0, e);
|
|
521
|
+
t = t._next;
|
|
522
|
+
}
|
|
523
|
+
--frame;
|
|
524
|
+
}
|
|
525
|
+
function wake() {
|
|
526
|
+
clockNow = (clockLast = clock.now()) + clockSkew;
|
|
527
|
+
frame = timeout = 0;
|
|
528
|
+
try {
|
|
529
|
+
timerFlush();
|
|
530
|
+
} finally {
|
|
531
|
+
frame = 0;
|
|
532
|
+
nap();
|
|
533
|
+
clockNow = 0;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
function poke() {
|
|
537
|
+
var now2 = clock.now(), delay = now2 - clockLast;
|
|
538
|
+
if (delay > pokeDelay) clockSkew -= delay, clockLast = now2;
|
|
539
|
+
}
|
|
540
|
+
function nap() {
|
|
541
|
+
var t0, t1 = taskHead, t2, time = Infinity;
|
|
542
|
+
while (t1) {
|
|
543
|
+
if (t1._call) {
|
|
544
|
+
if (time > t1._time) time = t1._time;
|
|
545
|
+
t0 = t1, t1 = t1._next;
|
|
546
|
+
} else {
|
|
547
|
+
t2 = t1._next, t1._next = null;
|
|
548
|
+
t1 = t0 ? t0._next = t2 : taskHead = t2;
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
taskTail = t0;
|
|
552
|
+
sleep(time);
|
|
553
|
+
}
|
|
554
|
+
function sleep(time) {
|
|
555
|
+
if (frame) return;
|
|
556
|
+
if (timeout) timeout = clearTimeout(timeout);
|
|
557
|
+
var delay = time - clockNow;
|
|
558
|
+
if (delay > 24) {
|
|
559
|
+
if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
|
|
560
|
+
if (interval) interval = clearInterval(interval);
|
|
561
|
+
} else {
|
|
562
|
+
if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
|
|
563
|
+
frame = 1, setFrame(wake);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
// node_modules/d3-force/src/lcg.js
|
|
568
|
+
var a = 1664525;
|
|
569
|
+
var c = 1013904223;
|
|
570
|
+
var m = 4294967296;
|
|
571
|
+
function lcg_default() {
|
|
572
|
+
let s = 1;
|
|
573
|
+
return () => (s = (a * s + c) % m) / m;
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// node_modules/d3-force/src/simulation.js
|
|
577
|
+
function x(d) {
|
|
578
|
+
return d.x;
|
|
579
|
+
}
|
|
580
|
+
function y(d) {
|
|
581
|
+
return d.y;
|
|
582
|
+
}
|
|
583
|
+
var initialRadius = 10;
|
|
584
|
+
var initialAngle = Math.PI * (3 - Math.sqrt(5));
|
|
585
|
+
function simulation_default(nodes) {
|
|
586
|
+
var simulation, alpha = 1, alphaMin = 1e-3, alphaDecay = 1 - Math.pow(alphaMin, 1 / 300), alphaTarget = 0, velocityDecay = 0.6, forces = /* @__PURE__ */ new Map(), stepper = timer(step), event = dispatch_default("tick", "end"), random = lcg_default();
|
|
587
|
+
if (nodes == null) nodes = [];
|
|
588
|
+
function step() {
|
|
589
|
+
tick();
|
|
590
|
+
event.call("tick", simulation);
|
|
591
|
+
if (alpha < alphaMin) {
|
|
592
|
+
stepper.stop();
|
|
593
|
+
event.call("end", simulation);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
function tick(iterations) {
|
|
597
|
+
var i, n = nodes.length, node;
|
|
598
|
+
if (iterations === void 0) iterations = 1;
|
|
599
|
+
for (var k = 0; k < iterations; ++k) {
|
|
600
|
+
alpha += (alphaTarget - alpha) * alphaDecay;
|
|
601
|
+
forces.forEach(function(force) {
|
|
602
|
+
force(alpha);
|
|
603
|
+
});
|
|
604
|
+
for (i = 0; i < n; ++i) {
|
|
605
|
+
node = nodes[i];
|
|
606
|
+
if (node.fx == null) node.x += node.vx *= velocityDecay;
|
|
607
|
+
else node.x = node.fx, node.vx = 0;
|
|
608
|
+
if (node.fy == null) node.y += node.vy *= velocityDecay;
|
|
609
|
+
else node.y = node.fy, node.vy = 0;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
return simulation;
|
|
613
|
+
}
|
|
614
|
+
function initializeNodes() {
|
|
615
|
+
for (var i = 0, n = nodes.length, node; i < n; ++i) {
|
|
616
|
+
node = nodes[i], node.index = i;
|
|
617
|
+
if (node.fx != null) node.x = node.fx;
|
|
618
|
+
if (node.fy != null) node.y = node.fy;
|
|
619
|
+
if (isNaN(node.x) || isNaN(node.y)) {
|
|
620
|
+
var radius = initialRadius * Math.sqrt(0.5 + i), angle = i * initialAngle;
|
|
621
|
+
node.x = radius * Math.cos(angle);
|
|
622
|
+
node.y = radius * Math.sin(angle);
|
|
623
|
+
}
|
|
624
|
+
if (isNaN(node.vx) || isNaN(node.vy)) {
|
|
625
|
+
node.vx = node.vy = 0;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
function initializeForce(force) {
|
|
630
|
+
if (force.initialize) force.initialize(nodes, random);
|
|
631
|
+
return force;
|
|
632
|
+
}
|
|
633
|
+
initializeNodes();
|
|
634
|
+
return simulation = {
|
|
635
|
+
tick,
|
|
636
|
+
restart: function() {
|
|
637
|
+
return stepper.restart(step), simulation;
|
|
638
|
+
},
|
|
639
|
+
stop: function() {
|
|
640
|
+
return stepper.stop(), simulation;
|
|
641
|
+
},
|
|
642
|
+
nodes: function(_) {
|
|
643
|
+
return arguments.length ? (nodes = _, initializeNodes(), forces.forEach(initializeForce), simulation) : nodes;
|
|
644
|
+
},
|
|
645
|
+
alpha: function(_) {
|
|
646
|
+
return arguments.length ? (alpha = +_, simulation) : alpha;
|
|
647
|
+
},
|
|
648
|
+
alphaMin: function(_) {
|
|
649
|
+
return arguments.length ? (alphaMin = +_, simulation) : alphaMin;
|
|
650
|
+
},
|
|
651
|
+
alphaDecay: function(_) {
|
|
652
|
+
return arguments.length ? (alphaDecay = +_, simulation) : +alphaDecay;
|
|
653
|
+
},
|
|
654
|
+
alphaTarget: function(_) {
|
|
655
|
+
return arguments.length ? (alphaTarget = +_, simulation) : alphaTarget;
|
|
656
|
+
},
|
|
657
|
+
velocityDecay: function(_) {
|
|
658
|
+
return arguments.length ? (velocityDecay = 1 - _, simulation) : 1 - velocityDecay;
|
|
659
|
+
},
|
|
660
|
+
randomSource: function(_) {
|
|
661
|
+
return arguments.length ? (random = _, forces.forEach(initializeForce), simulation) : random;
|
|
662
|
+
},
|
|
663
|
+
force: function(name, _) {
|
|
664
|
+
return arguments.length > 1 ? (_ == null ? forces.delete(name) : forces.set(name, initializeForce(_)), simulation) : forces.get(name);
|
|
665
|
+
},
|
|
666
|
+
find: function(x2, y2, radius) {
|
|
667
|
+
var i = 0, n = nodes.length, dx, dy, d2, node, closest;
|
|
668
|
+
if (radius == null) radius = Infinity;
|
|
669
|
+
else radius *= radius;
|
|
670
|
+
for (i = 0; i < n; ++i) {
|
|
671
|
+
node = nodes[i];
|
|
672
|
+
dx = x2 - node.x;
|
|
673
|
+
dy = y2 - node.y;
|
|
674
|
+
d2 = dx * dx + dy * dy;
|
|
675
|
+
if (d2 < radius) closest = node, radius = d2;
|
|
676
|
+
}
|
|
677
|
+
return closest;
|
|
678
|
+
},
|
|
679
|
+
on: function(name, _) {
|
|
680
|
+
return arguments.length > 1 ? (event.on(name, _), simulation) : event.on(name);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// node_modules/d3-force/src/manyBody.js
|
|
686
|
+
function manyBody_default() {
|
|
687
|
+
var nodes, node, random, alpha, strength = constant_default(-30), strengths, distanceMin2 = 1, distanceMax2 = Infinity, theta2 = 0.81;
|
|
688
|
+
function force(_) {
|
|
689
|
+
var i, n = nodes.length, tree = quadtree(nodes, x, y).visitAfter(accumulate);
|
|
690
|
+
for (alpha = _, i = 0; i < n; ++i) node = nodes[i], tree.visit(apply);
|
|
691
|
+
}
|
|
692
|
+
function initialize() {
|
|
693
|
+
if (!nodes) return;
|
|
694
|
+
var i, n = nodes.length, node2;
|
|
695
|
+
strengths = new Array(n);
|
|
696
|
+
for (i = 0; i < n; ++i) node2 = nodes[i], strengths[node2.index] = +strength(node2, i, nodes);
|
|
697
|
+
}
|
|
698
|
+
function accumulate(quad) {
|
|
699
|
+
var strength2 = 0, q, c2, weight = 0, x2, y2, i;
|
|
700
|
+
if (quad.length) {
|
|
701
|
+
for (x2 = y2 = i = 0; i < 4; ++i) {
|
|
702
|
+
if ((q = quad[i]) && (c2 = Math.abs(q.value))) {
|
|
703
|
+
strength2 += q.value, weight += c2, x2 += c2 * q.x, y2 += c2 * q.y;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
quad.x = x2 / weight;
|
|
707
|
+
quad.y = y2 / weight;
|
|
708
|
+
} else {
|
|
709
|
+
q = quad;
|
|
710
|
+
q.x = q.data.x;
|
|
711
|
+
q.y = q.data.y;
|
|
712
|
+
do
|
|
713
|
+
strength2 += strengths[q.data.index];
|
|
714
|
+
while (q = q.next);
|
|
715
|
+
}
|
|
716
|
+
quad.value = strength2;
|
|
717
|
+
}
|
|
718
|
+
function apply(quad, x1, _, x2) {
|
|
719
|
+
if (!quad.value) return true;
|
|
720
|
+
var x3 = quad.x - node.x, y2 = quad.y - node.y, w = x2 - x1, l = x3 * x3 + y2 * y2;
|
|
721
|
+
if (w * w / theta2 < l) {
|
|
722
|
+
if (l < distanceMax2) {
|
|
723
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
724
|
+
if (y2 === 0) y2 = jiggle_default(random), l += y2 * y2;
|
|
725
|
+
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
726
|
+
node.vx += x3 * quad.value * alpha / l;
|
|
727
|
+
node.vy += y2 * quad.value * alpha / l;
|
|
728
|
+
}
|
|
729
|
+
return true;
|
|
730
|
+
} else if (quad.length || l >= distanceMax2) return;
|
|
731
|
+
if (quad.data !== node || quad.next) {
|
|
732
|
+
if (x3 === 0) x3 = jiggle_default(random), l += x3 * x3;
|
|
733
|
+
if (y2 === 0) y2 = jiggle_default(random), l += y2 * y2;
|
|
734
|
+
if (l < distanceMin2) l = Math.sqrt(distanceMin2 * l);
|
|
735
|
+
}
|
|
736
|
+
do
|
|
737
|
+
if (quad.data !== node) {
|
|
738
|
+
w = strengths[quad.data.index] * alpha / l;
|
|
739
|
+
node.vx += x3 * w;
|
|
740
|
+
node.vy += y2 * w;
|
|
741
|
+
}
|
|
742
|
+
while (quad = quad.next);
|
|
743
|
+
}
|
|
744
|
+
force.initialize = function(_nodes, _random) {
|
|
745
|
+
nodes = _nodes;
|
|
746
|
+
random = _random;
|
|
747
|
+
initialize();
|
|
748
|
+
};
|
|
749
|
+
force.strength = function(_) {
|
|
750
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : strength;
|
|
751
|
+
};
|
|
752
|
+
force.distanceMin = function(_) {
|
|
753
|
+
return arguments.length ? (distanceMin2 = _ * _, force) : Math.sqrt(distanceMin2);
|
|
754
|
+
};
|
|
755
|
+
force.distanceMax = function(_) {
|
|
756
|
+
return arguments.length ? (distanceMax2 = _ * _, force) : Math.sqrt(distanceMax2);
|
|
757
|
+
};
|
|
758
|
+
force.theta = function(_) {
|
|
759
|
+
return arguments.length ? (theta2 = _ * _, force) : Math.sqrt(theta2);
|
|
760
|
+
};
|
|
761
|
+
return force;
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
// node_modules/d3-force/src/x.js
|
|
765
|
+
function x_default2(x2) {
|
|
766
|
+
var strength = constant_default(0.1), nodes, strengths, xz;
|
|
767
|
+
if (typeof x2 !== "function") x2 = constant_default(x2 == null ? 0 : +x2);
|
|
768
|
+
function force(alpha) {
|
|
769
|
+
for (var i = 0, n = nodes.length, node; i < n; ++i) {
|
|
770
|
+
node = nodes[i], node.vx += (xz[i] - node.x) * strengths[i] * alpha;
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
function initialize() {
|
|
774
|
+
if (!nodes) return;
|
|
775
|
+
var i, n = nodes.length;
|
|
776
|
+
strengths = new Array(n);
|
|
777
|
+
xz = new Array(n);
|
|
778
|
+
for (i = 0; i < n; ++i) {
|
|
779
|
+
strengths[i] = isNaN(xz[i] = +x2(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
force.initialize = function(_) {
|
|
783
|
+
nodes = _;
|
|
784
|
+
initialize();
|
|
785
|
+
};
|
|
786
|
+
force.strength = function(_) {
|
|
787
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : strength;
|
|
788
|
+
};
|
|
789
|
+
force.x = function(_) {
|
|
790
|
+
return arguments.length ? (x2 = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : x2;
|
|
791
|
+
};
|
|
792
|
+
return force;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
// node_modules/d3-force/src/y.js
|
|
796
|
+
function y_default2(y2) {
|
|
797
|
+
var strength = constant_default(0.1), nodes, strengths, yz;
|
|
798
|
+
if (typeof y2 !== "function") y2 = constant_default(y2 == null ? 0 : +y2);
|
|
799
|
+
function force(alpha) {
|
|
800
|
+
for (var i = 0, n = nodes.length, node; i < n; ++i) {
|
|
801
|
+
node = nodes[i], node.vy += (yz[i] - node.y) * strengths[i] * alpha;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
function initialize() {
|
|
805
|
+
if (!nodes) return;
|
|
806
|
+
var i, n = nodes.length;
|
|
807
|
+
strengths = new Array(n);
|
|
808
|
+
yz = new Array(n);
|
|
809
|
+
for (i = 0; i < n; ++i) {
|
|
810
|
+
strengths[i] = isNaN(yz[i] = +y2(nodes[i], i, nodes)) ? 0 : +strength(nodes[i], i, nodes);
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
force.initialize = function(_) {
|
|
814
|
+
nodes = _;
|
|
815
|
+
initialize();
|
|
816
|
+
};
|
|
817
|
+
force.strength = function(_) {
|
|
818
|
+
return arguments.length ? (strength = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : strength;
|
|
819
|
+
};
|
|
820
|
+
force.y = function(_) {
|
|
821
|
+
return arguments.length ? (y2 = typeof _ === "function" ? _ : constant_default(+_), initialize(), force) : y2;
|
|
822
|
+
};
|
|
823
|
+
return force;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
// src/core/node-presentation.ts
|
|
827
|
+
function nodeDimensions(node) {
|
|
828
|
+
const card = node.type === "decision" || node.type === "wait" || node.type === "task";
|
|
829
|
+
if (card) return { width: 300, height: 204, card: true };
|
|
830
|
+
if (node.type === "fork" || node.type === "join")
|
|
831
|
+
return { width: 88, height: 68, card: false };
|
|
832
|
+
return { width: 56, height: 56, card: false };
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
// src/d3/box-collision.ts
|
|
836
|
+
function boxCollision(padding) {
|
|
837
|
+
let nodes = [];
|
|
838
|
+
const predictedX = (node) => node.x + (node.vx ?? 0);
|
|
839
|
+
const predictedY = (node) => node.y + (node.vy ?? 0);
|
|
840
|
+
const force = () => {
|
|
841
|
+
if (!nodes.length) return;
|
|
842
|
+
const maxWidth = nodes.reduce((max, node) => Math.max(max, node.halfWidth), 0) + padding;
|
|
843
|
+
const maxHeight = nodes.reduce((max, node) => Math.max(max, node.halfHeight), 0) + padding;
|
|
844
|
+
for (let iteration = 0; iteration < 2; iteration++) {
|
|
845
|
+
const tree = quadtree().x(predictedX).y(predictedY).addAll(nodes);
|
|
846
|
+
for (const node of nodes) {
|
|
847
|
+
const x2 = predictedX(node), y2 = predictedY(node);
|
|
848
|
+
const reachX = node.halfWidth + maxWidth + padding;
|
|
849
|
+
const reachY = node.halfHeight + maxHeight + padding;
|
|
850
|
+
tree.visit((quad, x0, y0, x1, y1) => {
|
|
851
|
+
if (x0 > x2 + reachX || x1 < x2 - reachX || y0 > y2 + reachY || y1 < y2 - reachY)
|
|
852
|
+
return true;
|
|
853
|
+
if ("data" in quad) {
|
|
854
|
+
let leaf = quad;
|
|
855
|
+
while (leaf) {
|
|
856
|
+
const other = leaf.data;
|
|
857
|
+
if ((other.index ?? 0) > (node.index ?? 0)) {
|
|
858
|
+
const dx = predictedX(other) - predictedX(node), dy = predictedY(other) - predictedY(node);
|
|
859
|
+
const overlapX = node.halfWidth + other.halfWidth + padding * 2 - Math.abs(dx);
|
|
860
|
+
const overlapY = node.halfHeight + other.halfHeight + padding * 2 - Math.abs(dy);
|
|
861
|
+
if (overlapX > 0 && overlapY > 0) {
|
|
862
|
+
const horizontal = overlapX < overlapY;
|
|
863
|
+
const fixed = horizontal ? node.fx != null : node.fy != null;
|
|
864
|
+
const otherFixed = horizontal ? other.fx != null : other.fy != null;
|
|
865
|
+
const divisor = Number(!fixed) + Number(!otherFixed);
|
|
866
|
+
if (divisor) {
|
|
867
|
+
const sign = (horizontal ? dx : dy) < 0 ? -1 : 1;
|
|
868
|
+
const impulse = (horizontal ? overlapX : overlapY) * sign * 0.8 / divisor;
|
|
869
|
+
if (horizontal) {
|
|
870
|
+
if (!fixed) node.vx = (node.vx ?? 0) - impulse;
|
|
871
|
+
if (!otherFixed) other.vx = (other.vx ?? 0) + impulse;
|
|
872
|
+
} else {
|
|
873
|
+
if (!fixed) node.vy = (node.vy ?? 0) - impulse;
|
|
874
|
+
if (!otherFixed) other.vy = (other.vy ?? 0) + impulse;
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
leaf = leaf.next;
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
return false;
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
force.initialize = (initial) => {
|
|
888
|
+
nodes = initial;
|
|
889
|
+
};
|
|
890
|
+
return force;
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
// src/d3/ForcePlacement.ts
|
|
894
|
+
var ForcePlacement = class {
|
|
895
|
+
constructor(document, options = {}) {
|
|
896
|
+
this.options = options;
|
|
897
|
+
this.config = {
|
|
898
|
+
anchorStrength: options.anchorStrength ?? 0.12,
|
|
899
|
+
linkDistance: options.linkDistance ?? 190,
|
|
900
|
+
linkStrength: options.linkStrength ?? 0.08,
|
|
901
|
+
chargeStrength: options.chargeStrength ?? -80,
|
|
902
|
+
collisionPadding: options.collisionPadding ?? 12,
|
|
903
|
+
velocityDecay: options.velocityDecay ?? 0.6,
|
|
904
|
+
alphaDecay: options.alphaDecay ?? 0.04,
|
|
905
|
+
maxDisplacement: options.maxDisplacement ?? 200
|
|
906
|
+
};
|
|
907
|
+
for (const [name, value] of Object.entries(this.config)) {
|
|
908
|
+
if (!Number.isFinite(value) || (name === "chargeStrength" ? value > 0 : value < 0) || [
|
|
909
|
+
"anchorStrength",
|
|
910
|
+
"linkStrength",
|
|
911
|
+
"velocityDecay",
|
|
912
|
+
"alphaDecay"
|
|
913
|
+
].includes(name) && value > 1 || ["linkDistance", "alphaDecay"].includes(name) && value === 0) {
|
|
914
|
+
throw new FlowError(
|
|
915
|
+
"INVALID_FORCE_OPTIONS",
|
|
916
|
+
`Invalid force option ${name}.`
|
|
917
|
+
);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
assertFlow(document);
|
|
921
|
+
this.fixed = new Set(options.fixedNodeIds);
|
|
922
|
+
this.simulation = simulation_default([]).stop().velocityDecay(this.config.velocityDecay).alphaDecay(this.config.alphaDecay).force(
|
|
923
|
+
"charge",
|
|
924
|
+
manyBody_default().strength(this.config.chargeStrength)
|
|
925
|
+
).force(
|
|
926
|
+
"collision",
|
|
927
|
+
boxCollision(this.config.collisionPadding)
|
|
928
|
+
).force(
|
|
929
|
+
"x",
|
|
930
|
+
x_default2((node) => node.anchorX).strength(
|
|
931
|
+
this.config.anchorStrength
|
|
932
|
+
)
|
|
933
|
+
).force(
|
|
934
|
+
"y",
|
|
935
|
+
y_default2((node) => node.anchorY).strength(
|
|
936
|
+
this.config.anchorStrength
|
|
937
|
+
)
|
|
938
|
+
).on("tick.placement", () => {
|
|
939
|
+
this.constrain();
|
|
940
|
+
this.notify();
|
|
941
|
+
});
|
|
942
|
+
this.update(document);
|
|
943
|
+
}
|
|
944
|
+
options;
|
|
945
|
+
simulation;
|
|
946
|
+
nodes = /* @__PURE__ */ new Map();
|
|
947
|
+
listeners = /* @__PURE__ */ new Set();
|
|
948
|
+
signature = "";
|
|
949
|
+
destroyed = false;
|
|
950
|
+
fixed;
|
|
951
|
+
config;
|
|
952
|
+
/** Returns true only for a topology, shape, or authored-position change. */
|
|
953
|
+
update(document) {
|
|
954
|
+
this.alive();
|
|
955
|
+
assertFlow(document);
|
|
956
|
+
const signature = JSON.stringify([
|
|
957
|
+
document.nodes.map((node) => [
|
|
958
|
+
node.id,
|
|
959
|
+
node.type,
|
|
960
|
+
node.position.x,
|
|
961
|
+
node.position.y,
|
|
962
|
+
nodeDimensions(node)
|
|
963
|
+
]),
|
|
964
|
+
document.edges.map((edge) => [edge.id, edge.source, edge.target])
|
|
965
|
+
]);
|
|
966
|
+
if (signature === this.signature) return false;
|
|
967
|
+
this.signature = signature;
|
|
968
|
+
const nodes = document.nodes.map((node) => {
|
|
969
|
+
const previous = this.nodes.get(node.id);
|
|
970
|
+
const moved = previous && (previous.anchorX !== node.position.x || previous.anchorY !== node.position.y);
|
|
971
|
+
const next = previous ?? {
|
|
972
|
+
id: node.id,
|
|
973
|
+
x: node.position.x,
|
|
974
|
+
y: node.position.y,
|
|
975
|
+
anchorX: node.position.x,
|
|
976
|
+
anchorY: node.position.y,
|
|
977
|
+
halfWidth: 0,
|
|
978
|
+
halfHeight: 0
|
|
979
|
+
};
|
|
980
|
+
if (moved) {
|
|
981
|
+
next.x = node.position.x;
|
|
982
|
+
next.y = node.position.y;
|
|
983
|
+
next.vx = 0;
|
|
984
|
+
next.vy = 0;
|
|
985
|
+
if (next.fx != null) {
|
|
986
|
+
next.fx = next.x;
|
|
987
|
+
next.fy = next.y;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
next.anchorX = node.position.x;
|
|
991
|
+
next.anchorY = node.position.y;
|
|
992
|
+
const dimensions = nodeDimensions(node);
|
|
993
|
+
next.halfWidth = dimensions.width / 2;
|
|
994
|
+
next.halfHeight = dimensions.height / 2 + (dimensions.card ? 0 : 24);
|
|
995
|
+
if (this.fixed.has(node.id)) {
|
|
996
|
+
next.fx = next.anchorX;
|
|
997
|
+
next.fy = next.anchorY;
|
|
998
|
+
}
|
|
999
|
+
return next;
|
|
1000
|
+
});
|
|
1001
|
+
this.nodes = new Map(nodes.map((node) => [node.id, node]));
|
|
1002
|
+
this.simulation.force("link", null).nodes(nodes).force(
|
|
1003
|
+
"link",
|
|
1004
|
+
link_default(
|
|
1005
|
+
document.edges.map((edge) => ({
|
|
1006
|
+
source: edge.source,
|
|
1007
|
+
target: edge.target
|
|
1008
|
+
}))
|
|
1009
|
+
).id((node) => node.id).distance(this.config.linkDistance).strength(this.config.linkStrength)
|
|
1010
|
+
);
|
|
1011
|
+
this.constrain();
|
|
1012
|
+
return true;
|
|
1013
|
+
}
|
|
1014
|
+
getPositions() {
|
|
1015
|
+
this.alive();
|
|
1016
|
+
return new Map(
|
|
1017
|
+
[...this.nodes].map(([id, node]) => [
|
|
1018
|
+
id,
|
|
1019
|
+
Object.freeze({ x: node.x, y: node.y })
|
|
1020
|
+
])
|
|
1021
|
+
);
|
|
1022
|
+
}
|
|
1023
|
+
subscribe(listener) {
|
|
1024
|
+
this.alive();
|
|
1025
|
+
this.listeners.add(listener);
|
|
1026
|
+
return () => {
|
|
1027
|
+
this.listeners.delete(listener);
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
restart(alpha = 0.35) {
|
|
1031
|
+
this.alive();
|
|
1032
|
+
if (!Number.isFinite(alpha) || alpha <= 0 || alpha > 1)
|
|
1033
|
+
throw new FlowError(
|
|
1034
|
+
"INVALID_ALPHA",
|
|
1035
|
+
"alpha must be greater than 0 and at most 1."
|
|
1036
|
+
);
|
|
1037
|
+
if (this.nodes.size) this.simulation.alpha(alpha).restart();
|
|
1038
|
+
}
|
|
1039
|
+
stop() {
|
|
1040
|
+
this.alive();
|
|
1041
|
+
this.simulation.stop();
|
|
1042
|
+
}
|
|
1043
|
+
/** Manual, deterministic settling, useful for reduced motion and server-side layout. */
|
|
1044
|
+
tick(iterations = 1) {
|
|
1045
|
+
this.alive();
|
|
1046
|
+
if (!Number.isSafeInteger(iterations) || iterations < 1 || iterations > 1e4)
|
|
1047
|
+
throw new FlowError(
|
|
1048
|
+
"INVALID_ITERATIONS",
|
|
1049
|
+
"iterations must be an integer between 1 and 10000."
|
|
1050
|
+
);
|
|
1051
|
+
this.simulation.alpha(Math.max(0.35, this.simulation.alpha()));
|
|
1052
|
+
for (let index2 = 0; index2 < iterations; index2++) {
|
|
1053
|
+
this.simulation.tick();
|
|
1054
|
+
this.constrain();
|
|
1055
|
+
}
|
|
1056
|
+
this.notify();
|
|
1057
|
+
return this.getPositions();
|
|
1058
|
+
}
|
|
1059
|
+
/** A temporary pin for dragging; null restores the configured fixed-node policy. */
|
|
1060
|
+
pin(id, position) {
|
|
1061
|
+
this.alive();
|
|
1062
|
+
const node = this.nodes.get(id);
|
|
1063
|
+
if (!node) throw new FlowError("NODE_NOT_FOUND", `Unknown node ${id}.`);
|
|
1064
|
+
if (position && ![position.x, position.y].every(Number.isFinite))
|
|
1065
|
+
throw new FlowError("INVALID_POSITION", "Expected finite coordinates.");
|
|
1066
|
+
node.fx = position?.x ?? (this.fixed.has(id) ? node.anchorX : null);
|
|
1067
|
+
node.fy = position?.y ?? (this.fixed.has(id) ? node.anchorY : null);
|
|
1068
|
+
if (node.fx != null && node.fy != null) {
|
|
1069
|
+
node.x = node.fx;
|
|
1070
|
+
node.y = node.fy;
|
|
1071
|
+
node.vx = 0;
|
|
1072
|
+
node.vy = 0;
|
|
1073
|
+
}
|
|
1074
|
+
}
|
|
1075
|
+
destroy() {
|
|
1076
|
+
if (this.destroyed) return;
|
|
1077
|
+
this.simulation.stop().on("tick.placement", null);
|
|
1078
|
+
this.listeners.clear();
|
|
1079
|
+
this.nodes.clear();
|
|
1080
|
+
this.destroyed = true;
|
|
1081
|
+
}
|
|
1082
|
+
constrain() {
|
|
1083
|
+
for (const node of this.nodes.values()) {
|
|
1084
|
+
if (node.fx != null || node.fy != null) continue;
|
|
1085
|
+
const dx = node.x - node.anchorX;
|
|
1086
|
+
const dy = node.y - node.anchorY;
|
|
1087
|
+
const distance = Math.hypot(dx, dy);
|
|
1088
|
+
if (distance > this.config.maxDisplacement) {
|
|
1089
|
+
const ratio = this.config.maxDisplacement / distance;
|
|
1090
|
+
node.x = node.anchorX + dx * ratio;
|
|
1091
|
+
node.y = node.anchorY + dy * ratio;
|
|
1092
|
+
node.vx = 0;
|
|
1093
|
+
node.vy = 0;
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
notify() {
|
|
1098
|
+
for (const listener of [...this.listeners]) {
|
|
1099
|
+
try {
|
|
1100
|
+
listener(this.getPositions());
|
|
1101
|
+
} catch (error) {
|
|
1102
|
+
try {
|
|
1103
|
+
this.options.onListenerError?.(error);
|
|
1104
|
+
} catch {
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
}
|
|
1109
|
+
alive() {
|
|
1110
|
+
if (this.destroyed)
|
|
1111
|
+
throw new FlowError(
|
|
1112
|
+
"PLACEMENT_DESTROYED",
|
|
1113
|
+
"This force placement has been destroyed."
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
export {
|
|
1119
|
+
nodeDimensions,
|
|
1120
|
+
timer,
|
|
1121
|
+
ForcePlacement
|
|
1122
|
+
};
|