@oscherbakov/react-flow-automated-layout 1.3.3 → 1.3.5
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.
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { jsx as u, jsxs as T, Fragment as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { Position as A, useReactFlow as
|
|
1
|
+
import { jsx as u, jsxs as T, Fragment as j } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Ut, useContext as Vt, useState as B, useEffect as Y, useRef as dt, useCallback as U } from "react";
|
|
3
|
+
import { Position as A, useReactFlow as Yt, useNodes as Ft, useEdges as Pt, useOnSelectionChange as jt, ControlButton as D, Controls as Xt } from "@xyflow/react";
|
|
4
4
|
import ut from "@dagrejs/dagre";
|
|
5
|
-
const Lt =
|
|
6
|
-
function
|
|
5
|
+
const Lt = Ut(void 0);
|
|
6
|
+
function F() {
|
|
7
7
|
const t = Vt(Lt);
|
|
8
8
|
if (t === void 0)
|
|
9
9
|
throw new Error("useLayoutContext must be used within a LayoutProvider");
|
|
@@ -22,7 +22,7 @@ const ft = (t) => {
|
|
|
22
22
|
default:
|
|
23
23
|
return "TB";
|
|
24
24
|
}
|
|
25
|
-
},
|
|
25
|
+
}, gt = (t) => {
|
|
26
26
|
switch (t) {
|
|
27
27
|
case "TB":
|
|
28
28
|
return "DOWN";
|
|
@@ -74,472 +74,473 @@ const ft = (t) => {
|
|
|
74
74
|
function Qt(t, r, e) {
|
|
75
75
|
if (e)
|
|
76
76
|
return { nodes: t, edges: r };
|
|
77
|
-
const
|
|
78
|
-
(
|
|
77
|
+
const s = t.filter((h) => !h.hidden), n = new Set(s.map((h) => h.id)), o = r.filter(
|
|
78
|
+
(h) => n.has(h.source) && n.has(h.target)
|
|
79
79
|
);
|
|
80
|
-
return { nodes:
|
|
80
|
+
return { nodes: s, edges: o };
|
|
81
81
|
}
|
|
82
|
-
const
|
|
83
|
-
const
|
|
84
|
-
|
|
82
|
+
const It = 172, Wt = 36, J = async (t, r, e, s = 0, n = 50, o = 50, h = It, a = Wt, d = !1) => {
|
|
83
|
+
const l = new ut.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
|
|
84
|
+
l.setGraph({
|
|
85
85
|
rankdir: e,
|
|
86
|
-
marginx:
|
|
87
|
-
marginy:
|
|
86
|
+
marginx: s,
|
|
87
|
+
marginy: s,
|
|
88
88
|
nodesep: n,
|
|
89
|
-
ranksep:
|
|
89
|
+
ranksep: o,
|
|
90
90
|
edgesep: Math.max(20, n / 4),
|
|
91
91
|
//When we have siblings, we want their top edges to be aligned
|
|
92
92
|
ranker: "tight-tree"
|
|
93
93
|
});
|
|
94
|
-
const
|
|
95
|
-
if (
|
|
94
|
+
const i = d ? t : t.filter((p) => !p.hidden);
|
|
95
|
+
if (i.length === 0)
|
|
96
96
|
return { nodes: [], edges: [], width: 0, height: 0 };
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
}), r.forEach((
|
|
102
|
-
var
|
|
103
|
-
const
|
|
104
|
-
let
|
|
105
|
-
|
|
106
|
-
}), ut.layout(
|
|
107
|
-
const
|
|
97
|
+
i.forEach((p) => {
|
|
98
|
+
var y, g;
|
|
99
|
+
const f = Number((y = p.style) == null ? void 0 : y.width) || h, m = Number((g = p.style) == null ? void 0 : g.height) || a;
|
|
100
|
+
l.setNode(p.id, { width: f, height: m });
|
|
101
|
+
}), r.forEach((p) => {
|
|
102
|
+
var E, L;
|
|
103
|
+
const f = p.sourceHandle, m = p.targetHandle, y = !!((E = p.data) != null && E.isReciprocal), g = !!((L = p.data) != null && L.isSyntheticBridge);
|
|
104
|
+
let w = {};
|
|
105
|
+
y ? w = { constraint: !1, minlen: 1, weight: 5 } : g ? w = { constraint: !0, minlen: 1, weight: 4 } : f === "right" && m === "left" ? w = { constraint: !1, minlen: 1 } : f === "bottom" && m === "top" ? w = { constraint: !0, minlen: 1 } : w = { constraint: !0, minlen: 2 }, l.setEdge(p.source, p.target, w);
|
|
106
|
+
}), ut.layout(l);
|
|
107
|
+
const c = l.graph().width || 0, x = l.graph().height || 0, N = Zt(gt(e)), b = qt(gt(e));
|
|
108
108
|
return {
|
|
109
|
-
nodes:
|
|
110
|
-
var
|
|
111
|
-
const
|
|
112
|
-
...
|
|
109
|
+
nodes: i.map((p) => {
|
|
110
|
+
var L;
|
|
111
|
+
const f = l.node(p.id), { width: m, height: y } = f, g = {
|
|
112
|
+
...p,
|
|
113
113
|
sourcePosition: N,
|
|
114
|
-
targetPosition:
|
|
114
|
+
targetPosition: b,
|
|
115
115
|
selected: !1
|
|
116
|
-
},
|
|
117
|
-
switch ((
|
|
116
|
+
}, w = f.x, E = f.y;
|
|
117
|
+
switch ((L = p.data) == null ? void 0 : L.positionType) {
|
|
118
118
|
case "center":
|
|
119
|
-
|
|
119
|
+
g.position = { x: w, y: E };
|
|
120
120
|
break;
|
|
121
121
|
case "topRight":
|
|
122
|
-
|
|
122
|
+
g.position = { x: w + m / 2, y: E - y / 2 };
|
|
123
123
|
break;
|
|
124
124
|
case "bottomLeft":
|
|
125
|
-
|
|
125
|
+
g.position = { x: w - m / 2, y: E + y / 2 };
|
|
126
126
|
break;
|
|
127
127
|
case "bottomRight":
|
|
128
|
-
|
|
128
|
+
g.position = { x: w + m / 2, y: E + y / 2 };
|
|
129
129
|
break;
|
|
130
130
|
case "topLeft":
|
|
131
131
|
default:
|
|
132
|
-
|
|
132
|
+
g.position = { x: w - m / 2, y: E - y / 2 };
|
|
133
133
|
}
|
|
134
|
-
return
|
|
134
|
+
return g;
|
|
135
135
|
}),
|
|
136
136
|
edges: r,
|
|
137
|
-
width:
|
|
137
|
+
width: c,
|
|
138
138
|
height: x
|
|
139
139
|
};
|
|
140
|
-
},
|
|
140
|
+
}, Kt = {
|
|
141
141
|
calculate: async (t, r, e) => {
|
|
142
|
-
const
|
|
143
|
-
return
|
|
144
|
-
|
|
142
|
+
const s = e.nodes || t, n = e.edges || r, h = e.dagreDirection || typeof e.direction == "string" && (e.direction === "RIGHT" || e.direction === "LEFT" ? "LR" : "TB") || "TB", a = e.margin ?? (typeof e.padding == "number" ? e.padding : 0), d = e.nodeSpacing ?? 50, l = e.layerSpacing ?? 50, i = e.nodeWidth ?? 172, c = e.nodeHeight ?? 36, x = e.layoutHidden ?? !1;
|
|
143
|
+
return J(
|
|
144
|
+
s,
|
|
145
145
|
n,
|
|
146
|
-
l,
|
|
147
|
-
c,
|
|
148
146
|
h,
|
|
149
147
|
a,
|
|
150
|
-
s,
|
|
151
148
|
d,
|
|
149
|
+
l,
|
|
150
|
+
i,
|
|
151
|
+
c,
|
|
152
152
|
x
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
|
-
},
|
|
156
|
-
dagre:
|
|
155
|
+
}, te = {
|
|
156
|
+
dagre: Kt
|
|
157
157
|
};
|
|
158
|
-
function
|
|
158
|
+
function ee({
|
|
159
159
|
initialDirection: t = "DOWN",
|
|
160
160
|
initialAlgorithm: r = "layered",
|
|
161
161
|
initialAutoLayout: e = !0,
|
|
162
|
-
initialPadding:
|
|
162
|
+
initialPadding: s = 50,
|
|
163
163
|
initialSpacing: n = { node: 50, layer: 50 },
|
|
164
|
-
initialNodeDimensions:
|
|
165
|
-
initialParentResizingOptions:
|
|
166
|
-
includeHidden:
|
|
167
|
-
layoutEngines:
|
|
164
|
+
initialNodeDimensions: o = { width: 172, height: 36 },
|
|
165
|
+
initialParentResizingOptions: h,
|
|
166
|
+
includeHidden: a = !1,
|
|
167
|
+
layoutEngines: d
|
|
168
168
|
}) {
|
|
169
|
-
const [
|
|
170
|
-
...
|
|
171
|
-
...
|
|
172
|
-
}), [
|
|
169
|
+
const [l, i] = B(t), [c, x] = B(r), [N, b] = B(e), [C, p] = B(!1), [f, m] = B(a), [y, g] = B({
|
|
170
|
+
...te,
|
|
171
|
+
...d
|
|
172
|
+
}), [w, E] = B({}), [L, M] = B(s), [G, O] = B(n.node || 150), [k, v] = B(n.layer || 180), [S, R] = B(o.width || 100), [_, Z] = B(o.height || 100), [q, Q] = B({
|
|
173
173
|
...Jt,
|
|
174
|
-
...
|
|
174
|
+
...h,
|
|
175
175
|
enabled: e
|
|
176
|
-
}), [
|
|
176
|
+
}), [P, I] = B([]);
|
|
177
177
|
return {
|
|
178
178
|
// State
|
|
179
|
-
direction:
|
|
180
|
-
algorithm:
|
|
179
|
+
direction: l,
|
|
180
|
+
algorithm: c,
|
|
181
181
|
autoLayout: N,
|
|
182
|
-
layoutInProgress:
|
|
183
|
-
layoutHidden:
|
|
184
|
-
layoutEngines:
|
|
185
|
-
layoutEngineOptions:
|
|
186
|
-
padding:
|
|
182
|
+
layoutInProgress: C,
|
|
183
|
+
layoutHidden: f,
|
|
184
|
+
layoutEngines: y,
|
|
185
|
+
layoutEngineOptions: w,
|
|
186
|
+
padding: L,
|
|
187
187
|
nodeSpacing: G,
|
|
188
188
|
layerSpacing: k,
|
|
189
189
|
nodeWidth: S,
|
|
190
190
|
nodeHeight: _,
|
|
191
|
-
parentResizingOptions:
|
|
192
|
-
selectedNodes:
|
|
191
|
+
parentResizingOptions: q,
|
|
192
|
+
selectedNodes: P,
|
|
193
193
|
// Setters
|
|
194
|
-
setDirection:
|
|
194
|
+
setDirection: i,
|
|
195
195
|
setAlgorithm: x,
|
|
196
|
-
setAutoLayout:
|
|
197
|
-
setLayoutInProgress:
|
|
196
|
+
setAutoLayout: b,
|
|
197
|
+
setLayoutInProgress: p,
|
|
198
198
|
setLayoutHidden: m,
|
|
199
|
-
setLayoutEngines:
|
|
200
|
-
setLayoutEngineOptions:
|
|
199
|
+
setLayoutEngines: g,
|
|
200
|
+
setLayoutEngineOptions: E,
|
|
201
201
|
setPadding: M,
|
|
202
202
|
setNodeSpacing: O,
|
|
203
203
|
setLayerSpacing: v,
|
|
204
204
|
setNodeWidth: R,
|
|
205
|
-
setNodeHeight:
|
|
206
|
-
setParentResizingOptionsState:
|
|
207
|
-
setSelectedNodes:
|
|
205
|
+
setNodeHeight: Z,
|
|
206
|
+
setParentResizingOptionsState: Q,
|
|
207
|
+
setSelectedNodes: I
|
|
208
208
|
};
|
|
209
209
|
}
|
|
210
|
-
function
|
|
210
|
+
function re({
|
|
211
211
|
nodes: t,
|
|
212
212
|
externalNodeIdWithNode: r,
|
|
213
213
|
externalNodeParentIdMapWithChildIdSet: e,
|
|
214
|
-
noParentKey:
|
|
214
|
+
noParentKey: s = "no-parent"
|
|
215
215
|
}) {
|
|
216
|
-
const [n,
|
|
217
|
-
return
|
|
216
|
+
const [n, o] = B(/* @__PURE__ */ new Map()), [h, a] = B(/* @__PURE__ */ new Map()), [d, l] = B({}), [i, c] = B(t.length), [x, N] = B(!1), b = r || n, C = e || h, p = b.size;
|
|
217
|
+
return Y(() => {
|
|
218
218
|
if (!r || !e) {
|
|
219
|
-
const
|
|
220
|
-
|
|
221
|
-
var
|
|
222
|
-
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
}), r ||
|
|
219
|
+
const f = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
220
|
+
t.forEach((y) => {
|
|
221
|
+
var w;
|
|
222
|
+
f.set(y.id, y);
|
|
223
|
+
const g = y.parentId || s;
|
|
224
|
+
m.has(g) || m.set(g, /* @__PURE__ */ new Set()), (w = m.get(g)) == null || w.add(y.id);
|
|
225
|
+
}), r || o(f), e || a(m);
|
|
226
226
|
}
|
|
227
|
-
}, [t, r, e,
|
|
228
|
-
t.length !==
|
|
229
|
-
}, [t]),
|
|
230
|
-
|
|
231
|
-
}, [
|
|
232
|
-
const
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
}, [t, r, e, s]), Y(() => {
|
|
228
|
+
t.length !== i && c(t.length);
|
|
229
|
+
}, [t]), Y(() => {
|
|
230
|
+
b.size > 0 && C.size > 0 && !x && N(!0);
|
|
231
|
+
}, [b, C, x]), Y(() => {
|
|
232
|
+
const f = {};
|
|
233
|
+
C.forEach((y, g) => {
|
|
234
|
+
f[g] = y.size;
|
|
235
235
|
});
|
|
236
|
-
let
|
|
237
|
-
for (const
|
|
238
|
-
if (!
|
|
239
|
-
|
|
236
|
+
let m = !1;
|
|
237
|
+
for (const y in f)
|
|
238
|
+
if (!d.hasOwnProperty(y) || f[y] !== d[y]) {
|
|
239
|
+
m = !0;
|
|
240
240
|
break;
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
}, [
|
|
244
|
-
nodeIdWithNode:
|
|
245
|
-
nodeParentIdMapWithChildIdSet:
|
|
246
|
-
numberOfNodes:
|
|
247
|
-
nodesLength:
|
|
248
|
-
nodesInitialized: L,
|
|
242
|
+
m && l(f);
|
|
243
|
+
}, [C]), {
|
|
244
|
+
nodeIdWithNode: b,
|
|
245
|
+
nodeParentIdMapWithChildIdSet: C,
|
|
246
|
+
numberOfNodes: p,
|
|
247
|
+
nodesLength: i,
|
|
249
248
|
childrenInitialized: x,
|
|
250
|
-
parentChildStructure:
|
|
249
|
+
parentChildStructure: d
|
|
251
250
|
};
|
|
252
251
|
}
|
|
253
|
-
function
|
|
252
|
+
function ne({
|
|
254
253
|
nodes: t,
|
|
255
254
|
edges: r,
|
|
256
255
|
selectedNodes: e,
|
|
257
|
-
layoutHidden:
|
|
256
|
+
layoutHidden: s,
|
|
258
257
|
calculateLayout: n,
|
|
259
|
-
calculateContainerLayout:
|
|
260
|
-
updateNodes:
|
|
261
|
-
updateEdges:
|
|
262
|
-
setLayoutInProgress:
|
|
263
|
-
setNodeSpacing:
|
|
264
|
-
setLayerSpacing:
|
|
258
|
+
calculateContainerLayout: o,
|
|
259
|
+
updateNodes: h,
|
|
260
|
+
updateEdges: a,
|
|
261
|
+
setLayoutInProgress: d,
|
|
262
|
+
setNodeSpacing: l,
|
|
263
|
+
setLayerSpacing: i
|
|
265
264
|
}) {
|
|
266
|
-
const
|
|
265
|
+
const c = Yt(), x = dt(null), N = dt(null), b = U(async (p = [], f = []) => {
|
|
267
266
|
x.current && x.current.abort();
|
|
268
267
|
const m = new AbortController();
|
|
269
268
|
x.current = m;
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
return { nodes:
|
|
269
|
+
const y = p.length > 0 ? p : (c == null ? void 0 : c.getNodes()) ?? t, g = f.length > 0 ? f : (c == null ? void 0 : c.getEdges()) ?? r;
|
|
270
|
+
if (y.length === 0)
|
|
271
|
+
return { nodes: y, edges: g };
|
|
273
272
|
try {
|
|
274
|
-
if (
|
|
275
|
-
return { nodes:
|
|
276
|
-
const { nodes:
|
|
277
|
-
return m.signal.aborted ? { nodes:
|
|
278
|
-
} catch (
|
|
279
|
-
return m.signal.aborted || console.error("Error applying layout:",
|
|
273
|
+
if (d(!0), m.signal.aborted)
|
|
274
|
+
return { nodes: y, edges: g };
|
|
275
|
+
const { nodes: w, edges: E } = Qt(y, g, s), L = await n(w, E, e, m.signal);
|
|
276
|
+
return m.signal.aborted ? { nodes: y, edges: g } : (x.current === m && (h ? h(L.nodes) : c != null && c.setNodes && c.setNodes(L.nodes), a ? a(L.edges) : c != null && c.setEdges && c.setEdges(L.edges), N.current && (N.current.node !== void 0 && l(N.current.node), N.current.layer !== void 0 && i(N.current.layer), N.current = null)), L);
|
|
277
|
+
} catch (w) {
|
|
278
|
+
return m.signal.aborted || console.error("Error applying layout:", w), { nodes: y, edges: g };
|
|
280
279
|
} finally {
|
|
281
|
-
x.current === m && (
|
|
280
|
+
x.current === m && (d(!1), x.current = null);
|
|
282
281
|
}
|
|
283
282
|
}, [
|
|
284
283
|
t,
|
|
285
284
|
r,
|
|
286
285
|
e,
|
|
287
286
|
n,
|
|
288
|
-
l,
|
|
289
|
-
c,
|
|
290
|
-
d,
|
|
291
|
-
o,
|
|
292
287
|
h,
|
|
293
288
|
a,
|
|
294
|
-
|
|
295
|
-
|
|
289
|
+
c,
|
|
290
|
+
s,
|
|
291
|
+
d,
|
|
292
|
+
l,
|
|
293
|
+
i
|
|
294
|
+
]), C = U(async (p) => {
|
|
296
295
|
x.current && x.current.abort();
|
|
297
|
-
const
|
|
298
|
-
|
|
296
|
+
const f = new AbortController();
|
|
297
|
+
x.current = f;
|
|
298
|
+
const m = (c == null ? void 0 : c.getNodes()) ?? t, y = (c == null ? void 0 : c.getEdges()) ?? r;
|
|
299
|
+
if (m.length === 0) return { nodes: m, edges: y };
|
|
299
300
|
try {
|
|
300
|
-
if (
|
|
301
|
-
const
|
|
302
|
-
return
|
|
303
|
-
} catch (
|
|
304
|
-
return
|
|
301
|
+
if (d(!0), f.signal.aborted) return { nodes: m, edges: y };
|
|
302
|
+
const g = await o(p, m, y, f.signal);
|
|
303
|
+
return f.signal.aborted ? { nodes: m, edges: y } : (x.current === f && (h ? h(g.nodes) : c != null && c.setNodes && c.setNodes(g.nodes), a ? a(g.edges) : c != null && c.setEdges && c.setEdges(g.edges)), g);
|
|
304
|
+
} catch (g) {
|
|
305
|
+
return f.signal.aborted || console.error("Error applying container layout:", g), { nodes: m, edges: y };
|
|
305
306
|
} finally {
|
|
306
|
-
x.current ===
|
|
307
|
+
x.current === f && (d(!1), x.current = null);
|
|
307
308
|
}
|
|
308
|
-
}, [t, r,
|
|
309
|
+
}, [t, r, o, h, a, c, d]);
|
|
309
310
|
return {
|
|
310
|
-
applyLayout:
|
|
311
|
-
applyContainerLayout:
|
|
311
|
+
applyLayout: b,
|
|
312
|
+
applyContainerLayout: C,
|
|
312
313
|
pendingSpacingUpdateRef: N
|
|
313
314
|
};
|
|
314
315
|
}
|
|
315
|
-
const
|
|
316
|
-
const
|
|
317
|
-
t.forEach((
|
|
318
|
-
const
|
|
319
|
-
|
|
320
|
-
id:
|
|
321
|
-
node:
|
|
316
|
+
const se = (t, r, e = "no-parent") => {
|
|
317
|
+
const s = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
|
|
318
|
+
t.forEach((a, d) => {
|
|
319
|
+
const l = r.get(d);
|
|
320
|
+
l && n.set(d, {
|
|
321
|
+
id: d,
|
|
322
|
+
node: l,
|
|
322
323
|
children: [],
|
|
323
324
|
depth: 0
|
|
324
325
|
});
|
|
325
326
|
});
|
|
326
|
-
const
|
|
327
|
-
if (
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
const
|
|
332
|
-
for (const x of
|
|
327
|
+
const o = (a, d) => {
|
|
328
|
+
if (s.has(a) || !t.has(a) || !r.get(a)) return null;
|
|
329
|
+
s.add(a);
|
|
330
|
+
const i = n.get(a);
|
|
331
|
+
i.depth = d;
|
|
332
|
+
const c = t.get(a) || /* @__PURE__ */ new Set();
|
|
333
|
+
for (const x of c)
|
|
333
334
|
if (t.has(x) && r.get(x)) {
|
|
334
|
-
const
|
|
335
|
-
|
|
335
|
+
const b = o(x, d + 1);
|
|
336
|
+
b && i.children.push(b);
|
|
336
337
|
}
|
|
337
|
-
return
|
|
338
|
-
},
|
|
339
|
-
return t.forEach((
|
|
340
|
-
const
|
|
341
|
-
if (
|
|
342
|
-
const
|
|
343
|
-
if (!
|
|
344
|
-
const
|
|
345
|
-
|
|
338
|
+
return i;
|
|
339
|
+
}, h = [];
|
|
340
|
+
return t.forEach((a, d) => {
|
|
341
|
+
const l = r.get(d);
|
|
342
|
+
if (l) {
|
|
343
|
+
const i = l.parentId;
|
|
344
|
+
if (!i || i === e) {
|
|
345
|
+
const c = o(d, 0);
|
|
346
|
+
c && h.push(c);
|
|
346
347
|
}
|
|
347
348
|
}
|
|
348
|
-
}),
|
|
349
|
+
}), h;
|
|
349
350
|
};
|
|
350
351
|
function tt(t, r, e = "no-parent") {
|
|
351
|
-
const
|
|
352
|
+
const s = [];
|
|
352
353
|
let n = t;
|
|
353
|
-
const
|
|
354
|
+
const o = /* @__PURE__ */ new Set();
|
|
354
355
|
for (; n && n !== e; ) {
|
|
355
|
-
if (
|
|
356
|
+
if (o.has(n)) {
|
|
356
357
|
console.warn(`Cycle detected in ancestor path for node ${t}`);
|
|
357
358
|
break;
|
|
358
359
|
}
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
if (!
|
|
360
|
+
o.add(n), s.push(n);
|
|
361
|
+
const h = r.get(n);
|
|
362
|
+
if (!h || !h.parentId) {
|
|
362
363
|
n = e;
|
|
363
364
|
break;
|
|
364
365
|
}
|
|
365
|
-
n =
|
|
366
|
+
n = h.parentId;
|
|
366
367
|
}
|
|
367
|
-
return n === e &&
|
|
368
|
+
return n === e && s.push(e), s;
|
|
368
369
|
}
|
|
369
|
-
function z(t, r, e,
|
|
370
|
+
function z(t, r, e, s = "no-parent") {
|
|
370
371
|
if (t === r)
|
|
371
372
|
return t;
|
|
372
|
-
const n = tt(t, e,
|
|
373
|
-
return
|
|
373
|
+
const n = tt(t, e, s), o = n.indexOf(r);
|
|
374
|
+
return o === -1 ? null : o === 0 ? t : n[o - 1] || null;
|
|
374
375
|
}
|
|
375
|
-
function
|
|
376
|
-
const n = tt(t, e,
|
|
377
|
-
let
|
|
376
|
+
function V(t, r, e, s = "no-parent") {
|
|
377
|
+
const n = tt(t, e, s), o = tt(r, e, s), h = new Set(o);
|
|
378
|
+
let a = null, d = -1;
|
|
378
379
|
for (let x = 0; x < n.length; x++)
|
|
379
|
-
if (
|
|
380
|
-
|
|
380
|
+
if (h.has(n[x])) {
|
|
381
|
+
a = n[x], d = x;
|
|
381
382
|
break;
|
|
382
383
|
}
|
|
383
|
-
if (!
|
|
384
|
+
if (!a)
|
|
384
385
|
return { lca: null, sourceChild: null, targetChild: null };
|
|
385
|
-
const
|
|
386
|
-
return { lca:
|
|
386
|
+
const l = o.indexOf(a), i = d > 0 ? n[d - 1] : t, c = l > 0 ? o[l - 1] : r;
|
|
387
|
+
return { lca: a, sourceChild: i, targetChild: c };
|
|
387
388
|
}
|
|
388
|
-
const
|
|
389
|
-
const
|
|
390
|
-
return
|
|
391
|
-
...
|
|
389
|
+
const oe = (t) => JSON.parse(JSON.stringify(t)), Et = (t, r, e, s, n) => {
|
|
390
|
+
const o = oe(t);
|
|
391
|
+
return o.source = r, o.target = e, o.id = s, o.data = {
|
|
392
|
+
...o.data,
|
|
392
393
|
...n
|
|
393
|
-
},
|
|
394
|
-
},
|
|
394
|
+
}, o;
|
|
395
|
+
}, ie = (t) => {
|
|
395
396
|
for (const r of t.values()) {
|
|
396
397
|
const e = /* @__PURE__ */ new Map();
|
|
397
398
|
r.forEach((n) => {
|
|
398
|
-
const
|
|
399
|
-
|
|
399
|
+
const o = `${n.source}->${n.target}`, h = e.get(o) || [];
|
|
400
|
+
h.push(n), e.set(o, h);
|
|
400
401
|
});
|
|
401
|
-
const
|
|
402
|
+
const s = /* @__PURE__ */ new Set();
|
|
402
403
|
r.forEach((n) => {
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
404
|
+
const o = `${n.source}->${n.target}`, h = `${n.target}->${n.source}`;
|
|
405
|
+
if (s.has(o) || s.has(h))
|
|
405
406
|
return;
|
|
406
|
-
const
|
|
407
|
-
if (!
|
|
407
|
+
const a = e.get(h);
|
|
408
|
+
if (!a || a.length === 0)
|
|
408
409
|
return;
|
|
409
|
-
[...e.get(
|
|
410
|
-
|
|
411
|
-
...
|
|
410
|
+
[...e.get(o) || [], ...a].forEach((l) => {
|
|
411
|
+
l.data = {
|
|
412
|
+
...l.data,
|
|
412
413
|
isReciprocal: !0
|
|
413
414
|
};
|
|
414
|
-
}),
|
|
415
|
+
}), s.add(o), s.add(h);
|
|
415
416
|
});
|
|
416
417
|
}
|
|
417
|
-
},
|
|
418
|
-
const n = /* @__PURE__ */ new Map(),
|
|
419
|
-
t.forEach((
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
const
|
|
423
|
-
|
|
418
|
+
}, ce = (t, r, e, s) => {
|
|
419
|
+
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
420
|
+
t.forEach((a) => {
|
|
421
|
+
const d = n.get(a.target) || [];
|
|
422
|
+
d.push(a), n.set(a.target, d);
|
|
423
|
+
const l = o.get(a.source) || [];
|
|
424
|
+
l.push(a), o.set(a.source, l);
|
|
424
425
|
});
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
const
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
if (
|
|
426
|
+
const h = /* @__PURE__ */ new Set();
|
|
427
|
+
o.forEach((a, d) => {
|
|
428
|
+
const l = n.get(d) || [];
|
|
429
|
+
l.length !== 0 && l.forEach((i) => {
|
|
430
|
+
a.forEach((c) => {
|
|
431
|
+
if (i.source === c.target)
|
|
431
432
|
return;
|
|
432
|
-
const { lca: x, sourceChild: N, targetChild:
|
|
433
|
-
|
|
434
|
-
|
|
433
|
+
const { lca: x, sourceChild: N, targetChild: b } = V(
|
|
434
|
+
i.source,
|
|
435
|
+
c.target,
|
|
435
436
|
r,
|
|
436
|
-
|
|
437
|
-
),
|
|
438
|
-
|
|
439
|
-
|
|
437
|
+
s
|
|
438
|
+
), C = V(
|
|
439
|
+
i.source,
|
|
440
|
+
d,
|
|
440
441
|
r,
|
|
441
|
-
|
|
442
|
-
).lca,
|
|
443
|
-
|
|
444
|
-
|
|
442
|
+
s
|
|
443
|
+
).lca, p = V(
|
|
444
|
+
d,
|
|
445
|
+
c.target,
|
|
445
446
|
r,
|
|
446
|
-
|
|
447
|
+
s
|
|
447
448
|
).lca;
|
|
448
|
-
if (!
|
|
449
|
+
if (!C || C !== p)
|
|
449
450
|
return;
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
451
|
+
const f = z(
|
|
452
|
+
i.source,
|
|
453
|
+
C,
|
|
453
454
|
r,
|
|
454
|
-
|
|
455
|
+
s
|
|
455
456
|
), m = z(
|
|
456
|
-
|
|
457
|
-
|
|
457
|
+
c.target,
|
|
458
|
+
C,
|
|
458
459
|
r,
|
|
459
|
-
|
|
460
|
-
),
|
|
461
|
-
|
|
462
|
-
|
|
460
|
+
s
|
|
461
|
+
), y = z(
|
|
462
|
+
d,
|
|
463
|
+
C,
|
|
463
464
|
r,
|
|
464
|
-
|
|
465
|
+
s
|
|
465
466
|
);
|
|
466
|
-
if (!
|
|
467
|
+
if (!f || !m || !y || f !== m || f === y)
|
|
467
468
|
return;
|
|
468
|
-
const
|
|
469
|
-
|
|
470
|
-
|
|
469
|
+
const g = f, w = z(
|
|
470
|
+
i.source,
|
|
471
|
+
g,
|
|
471
472
|
r,
|
|
472
|
-
|
|
473
|
-
),
|
|
474
|
-
|
|
475
|
-
|
|
473
|
+
s
|
|
474
|
+
), E = z(
|
|
475
|
+
c.target,
|
|
476
|
+
g,
|
|
476
477
|
r,
|
|
477
|
-
|
|
478
|
+
s
|
|
478
479
|
);
|
|
479
|
-
if (!x || !N || !
|
|
480
|
+
if (!x || !N || !b || !w || !E || w === E)
|
|
480
481
|
return;
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
482
|
+
const L = `synthetic_bridge_${i.id}_${d}_${c.id}_${g}`;
|
|
483
|
+
if (h.has(L))
|
|
483
484
|
return;
|
|
484
485
|
const M = Et(
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
486
|
+
i,
|
|
487
|
+
w,
|
|
488
|
+
E,
|
|
489
|
+
L,
|
|
489
490
|
{
|
|
490
491
|
isTemporary: !0,
|
|
491
492
|
isSyntheticBridge: !0,
|
|
492
|
-
bridgeNode:
|
|
493
|
-
bridgeBranch:
|
|
494
|
-
anchorBranch:
|
|
495
|
-
originalSource:
|
|
496
|
-
originalTarget:
|
|
493
|
+
bridgeNode: d,
|
|
494
|
+
bridgeBranch: y,
|
|
495
|
+
anchorBranch: f,
|
|
496
|
+
originalSource: i.source,
|
|
497
|
+
originalTarget: c.target
|
|
497
498
|
}
|
|
498
499
|
);
|
|
499
|
-
e.has(
|
|
500
|
+
e.has(g) || e.set(g, []), e.get(g).push(M), h.add(L);
|
|
500
501
|
});
|
|
501
502
|
});
|
|
502
503
|
});
|
|
503
504
|
};
|
|
504
505
|
function et(t, r, e = "no-parent") {
|
|
505
|
-
const
|
|
506
|
+
const s = /* @__PURE__ */ new Map();
|
|
506
507
|
for (const n of t) {
|
|
507
|
-
const { lca:
|
|
508
|
+
const { lca: o, sourceChild: h, targetChild: a } = V(
|
|
508
509
|
n.source,
|
|
509
510
|
n.target,
|
|
510
511
|
r,
|
|
511
512
|
e
|
|
512
513
|
);
|
|
513
|
-
if (
|
|
514
|
-
const
|
|
514
|
+
if (o && h && a && h !== a) {
|
|
515
|
+
const d = Et(
|
|
515
516
|
n,
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
`temp_${n.id}_${
|
|
517
|
+
h,
|
|
518
|
+
a,
|
|
519
|
+
`temp_${n.id}_${o}`,
|
|
519
520
|
{
|
|
520
521
|
isTemporary: !0,
|
|
521
522
|
originalSource: n.source,
|
|
522
523
|
originalTarget: n.target
|
|
523
524
|
}
|
|
524
525
|
);
|
|
525
|
-
|
|
526
|
+
s.has(o) || s.set(o, []), s.get(o).push(d);
|
|
526
527
|
}
|
|
527
528
|
}
|
|
528
|
-
return
|
|
529
|
+
return ce(t, r, s, e), ie(s), s;
|
|
529
530
|
}
|
|
530
|
-
const rt = 10,
|
|
531
|
-
var
|
|
532
|
-
const
|
|
533
|
-
if (!
|
|
531
|
+
const rt = 10, pt = (t, r) => t.find((e) => e.id === r), yt = (t, r, e) => {
|
|
532
|
+
var a, d;
|
|
533
|
+
const s = e.get(t);
|
|
534
|
+
if (!s)
|
|
534
535
|
return null;
|
|
535
|
-
let n =
|
|
536
|
-
for (;
|
|
537
|
-
const
|
|
538
|
-
if (!
|
|
536
|
+
let n = s.position.x + (s.width || Number((a = s.style) == null ? void 0 : a.width) || 172) / 2, o = s.position.y + (s.height || Number((d = s.style) == null ? void 0 : d.height) || 36) / 2, h = s.parentId;
|
|
537
|
+
for (; h && h !== r; ) {
|
|
538
|
+
const l = e.get(h);
|
|
539
|
+
if (!l)
|
|
539
540
|
break;
|
|
540
|
-
n +=
|
|
541
|
+
n += l.position.x, o += l.position.y, h = l.parentId;
|
|
541
542
|
}
|
|
542
|
-
return { x: n, y:
|
|
543
|
+
return { x: n, y: o };
|
|
543
544
|
}, $ = (t) => {
|
|
544
545
|
var r, e;
|
|
545
546
|
return {
|
|
@@ -552,283 +553,283 @@ const rt = 10, gt = (t, r) => t.find((e) => e.id === r), yt = (t, r, e) => {
|
|
|
552
553
|
x: t.position.x + r / 2,
|
|
553
554
|
y: t.position.y + e / 2
|
|
554
555
|
};
|
|
555
|
-
},
|
|
556
|
+
}, ae = (t, r) => {
|
|
556
557
|
if (t.length === 0)
|
|
557
558
|
return { nodes: t, width: 0, height: 0 };
|
|
558
|
-
let e = Number.POSITIVE_INFINITY,
|
|
559
|
-
t.forEach((
|
|
560
|
-
const { width:
|
|
561
|
-
e = Math.min(e,
|
|
559
|
+
let e = Number.POSITIVE_INFINITY, s = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY, o = Number.NEGATIVE_INFINITY;
|
|
560
|
+
t.forEach((i) => {
|
|
561
|
+
const { width: c, height: x } = $(i);
|
|
562
|
+
e = Math.min(e, i.position.x), s = Math.min(s, i.position.y), n = Math.max(n, i.position.x + c), o = Math.max(o, i.position.y + x);
|
|
562
563
|
});
|
|
563
|
-
const
|
|
564
|
-
t.forEach((
|
|
565
|
-
|
|
566
|
-
x:
|
|
567
|
-
y:
|
|
564
|
+
const h = r - e, a = r - s;
|
|
565
|
+
t.forEach((i) => {
|
|
566
|
+
i.position = {
|
|
567
|
+
x: i.position.x + h,
|
|
568
|
+
y: i.position.y + a
|
|
568
569
|
};
|
|
569
570
|
});
|
|
570
|
-
const
|
|
571
|
-
return { nodes: t, width:
|
|
572
|
-
},
|
|
573
|
-
if (!(t.length < 2 ||
|
|
571
|
+
const d = n - e + r * 2, l = o - s + r * 2;
|
|
572
|
+
return { nodes: t, width: d, height: l };
|
|
573
|
+
}, le = (t, r, e, s) => {
|
|
574
|
+
if (!(t.length < 2 || s.size === 0))
|
|
574
575
|
if (r === "TB" || r === "BT") {
|
|
575
|
-
const n = [...t].sort((
|
|
576
|
-
n.forEach((
|
|
577
|
-
if (!
|
|
576
|
+
const n = [...t].sort((o, h) => o.position.x - h.position.x);
|
|
577
|
+
n.forEach((o, h) => {
|
|
578
|
+
if (!s.has(o.id))
|
|
578
579
|
return;
|
|
579
|
-
let
|
|
580
|
-
for (let
|
|
581
|
-
const
|
|
582
|
-
|
|
580
|
+
let a = o.position.x + $(o).width;
|
|
581
|
+
for (let d = h + 1; d < n.length; d++) {
|
|
582
|
+
const l = n[d], { width: i } = $(l), c = a + e;
|
|
583
|
+
l.position.x < c && (l.position.x = c), a = l.position.x + i;
|
|
583
584
|
}
|
|
584
585
|
});
|
|
585
586
|
} else {
|
|
586
|
-
const n = [...t].sort((
|
|
587
|
-
n.forEach((
|
|
588
|
-
if (!
|
|
587
|
+
const n = [...t].sort((o, h) => o.position.y - h.position.y);
|
|
588
|
+
n.forEach((o, h) => {
|
|
589
|
+
if (!s.has(o.id))
|
|
589
590
|
return;
|
|
590
|
-
let
|
|
591
|
-
for (let
|
|
592
|
-
const
|
|
593
|
-
|
|
591
|
+
let a = o.position.y + $(o).height;
|
|
592
|
+
for (let d = h + 1; d < n.length; d++) {
|
|
593
|
+
const l = n[d], { height: i } = $(l), c = a + e;
|
|
594
|
+
l.position.y < c && (l.position.y = c), a = l.position.y + i;
|
|
594
595
|
}
|
|
595
596
|
});
|
|
596
597
|
}
|
|
597
|
-
},
|
|
598
|
-
const n = /* @__PURE__ */ new Map(),
|
|
599
|
-
r.forEach((
|
|
600
|
-
const
|
|
601
|
-
|
|
602
|
-
const
|
|
603
|
-
|
|
598
|
+
}, he = (t, r, e, s) => {
|
|
599
|
+
const n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map();
|
|
600
|
+
r.forEach((a) => {
|
|
601
|
+
const d = n.get(a.target) || [];
|
|
602
|
+
d.push(a), n.set(a.target, d);
|
|
603
|
+
const l = o.get(a.source) || [];
|
|
604
|
+
l.push(a), o.set(a.source, l);
|
|
604
605
|
});
|
|
605
|
-
const
|
|
606
|
-
return
|
|
607
|
-
const
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
if (
|
|
606
|
+
const h = /* @__PURE__ */ new Map();
|
|
607
|
+
return o.forEach((a, d) => {
|
|
608
|
+
const l = n.get(d) || [];
|
|
609
|
+
l.length !== 0 && l.forEach((i) => {
|
|
610
|
+
a.forEach((c) => {
|
|
611
|
+
if (i.source === c.target)
|
|
611
612
|
return;
|
|
612
|
-
const x =
|
|
613
|
-
|
|
614
|
-
|
|
613
|
+
const x = V(
|
|
614
|
+
i.source,
|
|
615
|
+
d,
|
|
615
616
|
e,
|
|
616
|
-
|
|
617
|
-
).lca, N =
|
|
618
|
-
|
|
619
|
-
|
|
617
|
+
s
|
|
618
|
+
).lca, N = V(
|
|
619
|
+
d,
|
|
620
|
+
c.target,
|
|
620
621
|
e,
|
|
621
|
-
|
|
622
|
+
s
|
|
622
623
|
).lca;
|
|
623
624
|
if (x !== t || N !== t)
|
|
624
625
|
return;
|
|
625
|
-
const
|
|
626
|
-
|
|
626
|
+
const b = z(
|
|
627
|
+
i.source,
|
|
627
628
|
t,
|
|
628
629
|
e,
|
|
629
|
-
|
|
630
|
-
),
|
|
631
|
-
|
|
630
|
+
s
|
|
631
|
+
), C = z(
|
|
632
|
+
c.target,
|
|
632
633
|
t,
|
|
633
634
|
e,
|
|
634
|
-
|
|
635
|
-
),
|
|
636
|
-
|
|
635
|
+
s
|
|
636
|
+
), p = z(
|
|
637
|
+
d,
|
|
637
638
|
t,
|
|
638
639
|
e,
|
|
639
|
-
|
|
640
|
+
s
|
|
640
641
|
);
|
|
641
|
-
if (!
|
|
642
|
+
if (!b || !C || !p || b !== C || b === p)
|
|
642
643
|
return;
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
644
|
+
const f = z(
|
|
645
|
+
i.source,
|
|
646
|
+
b,
|
|
646
647
|
e,
|
|
647
|
-
|
|
648
|
+
s
|
|
648
649
|
), m = z(
|
|
649
|
-
|
|
650
|
-
|
|
650
|
+
c.target,
|
|
651
|
+
b,
|
|
651
652
|
e,
|
|
652
|
-
|
|
653
|
+
s
|
|
653
654
|
);
|
|
654
|
-
if (!
|
|
655
|
+
if (!f || !m || f === m)
|
|
655
656
|
return;
|
|
656
|
-
const
|
|
657
|
-
|
|
658
|
-
anchorContainerId:
|
|
659
|
-
bridgeContainerId:
|
|
660
|
-
sourceNodeId:
|
|
657
|
+
const y = `${b}:${p}:${f}:${m}`;
|
|
658
|
+
h.set(y, {
|
|
659
|
+
anchorContainerId: b,
|
|
660
|
+
bridgeContainerId: p,
|
|
661
|
+
sourceNodeId: f,
|
|
661
662
|
targetNodeId: m
|
|
662
663
|
});
|
|
663
664
|
});
|
|
664
665
|
});
|
|
665
|
-
}), [...
|
|
666
|
-
},
|
|
667
|
-
const
|
|
668
|
-
return
|
|
669
|
-
const
|
|
670
|
-
if (!
|
|
666
|
+
}), [...h.values()];
|
|
667
|
+
}, de = (t, r, e, s, n, o, h) => {
|
|
668
|
+
const a = he(r, n, o, h), d = /* @__PURE__ */ new Set();
|
|
669
|
+
return a.forEach((l) => {
|
|
670
|
+
const i = pt(t, l.anchorContainerId), c = pt(t, l.bridgeContainerId);
|
|
671
|
+
if (!i || !c)
|
|
671
672
|
return;
|
|
672
|
-
const x = yt(
|
|
673
|
+
const x = yt(l.sourceNodeId, r, o), N = yt(l.targetNodeId, r, o);
|
|
673
674
|
if (!x || !N)
|
|
674
675
|
return;
|
|
675
|
-
const { width:
|
|
676
|
+
const { width: b, height: C } = $(c), { width: p, height: f } = $(i), m = xt(i), y = xt(c);
|
|
676
677
|
if (e === "TB" || e === "BT") {
|
|
677
|
-
const
|
|
678
|
-
|
|
679
|
-
const
|
|
680
|
-
|
|
678
|
+
const g = (x.y + N.y) / 2;
|
|
679
|
+
c.position.y = g - C / 2;
|
|
680
|
+
const w = y.x >= m.x, E = w ? c.position.x - (i.position.x + p) : i.position.x - (c.position.x + b), L = Math.max(s, E);
|
|
681
|
+
c.position.x = w ? i.position.x + p + L : i.position.x - b - L;
|
|
681
682
|
} else {
|
|
682
|
-
const
|
|
683
|
-
|
|
684
|
-
const
|
|
685
|
-
|
|
683
|
+
const g = (x.x + N.x) / 2;
|
|
684
|
+
c.position.x = g - b / 2;
|
|
685
|
+
const w = y.y >= m.y, E = w ? c.position.y - (i.position.y + f) : i.position.y - (c.position.y + C), L = Math.max(s, E);
|
|
686
|
+
c.position.y = w ? i.position.y + f + L : i.position.y - C - L;
|
|
686
687
|
}
|
|
687
|
-
|
|
688
|
-
}),
|
|
689
|
-
}, Nt = async (t, r, e,
|
|
690
|
-
const N = et(n,
|
|
688
|
+
d.add(c.id);
|
|
689
|
+
}), d;
|
|
690
|
+
}, Nt = async (t, r, e, s, n, o = rt, h = 50, a = 50, d = 172, l = 36, i = J, c = !1, x = "no-parent") => {
|
|
691
|
+
const N = et(n, s, x), { updatedNodes: b } = await X(
|
|
691
692
|
t,
|
|
692
693
|
r,
|
|
693
694
|
e,
|
|
694
|
-
|
|
695
|
+
s,
|
|
695
696
|
n,
|
|
696
|
-
|
|
697
|
-
l,
|
|
698
|
-
c,
|
|
697
|
+
o,
|
|
699
698
|
h,
|
|
700
699
|
a,
|
|
701
|
-
s,
|
|
702
700
|
d,
|
|
701
|
+
l,
|
|
702
|
+
i,
|
|
703
|
+
c,
|
|
703
704
|
N,
|
|
704
705
|
x
|
|
705
|
-
),
|
|
706
|
-
if (!
|
|
707
|
-
return { updatedNodes:
|
|
708
|
-
const { updatedNodes:
|
|
709
|
-
|
|
706
|
+
), C = s.get(t);
|
|
707
|
+
if (!C)
|
|
708
|
+
return { updatedNodes: b, updatedEdges: n };
|
|
709
|
+
const { updatedNodes: p } = await Nt(
|
|
710
|
+
C.parentId || x,
|
|
710
711
|
r,
|
|
711
712
|
e,
|
|
712
|
-
|
|
713
|
+
s,
|
|
713
714
|
n,
|
|
714
|
-
|
|
715
|
-
l,
|
|
716
|
-
c,
|
|
715
|
+
o,
|
|
717
716
|
h,
|
|
718
717
|
a,
|
|
719
|
-
s,
|
|
720
718
|
d,
|
|
719
|
+
l,
|
|
720
|
+
i,
|
|
721
|
+
c,
|
|
721
722
|
x
|
|
722
723
|
);
|
|
723
724
|
return {
|
|
724
|
-
updatedNodes: [...
|
|
725
|
+
updatedNodes: [...p, ...b],
|
|
725
726
|
updatedEdges: n
|
|
726
727
|
// Always return original edges unchanged
|
|
727
728
|
};
|
|
728
|
-
},
|
|
729
|
-
const
|
|
730
|
-
if (!
|
|
729
|
+
}, X = async (t, r, e, s, n, o = rt, h = 50, a = 50, d = 172, l = 36, i = J, c = !1, x = /* @__PURE__ */ new Map(), N = "no-parent") => {
|
|
730
|
+
const b = e.get(t);
|
|
731
|
+
if (!b || b.size === 0)
|
|
731
732
|
return { updatedNodes: [] };
|
|
732
|
-
const
|
|
733
|
-
if (
|
|
734
|
-
const M =
|
|
735
|
-
M &&
|
|
736
|
-
}),
|
|
733
|
+
const C = [];
|
|
734
|
+
if (b.forEach((L) => {
|
|
735
|
+
const M = s.get(L);
|
|
736
|
+
M && C.push(M);
|
|
737
|
+
}), C.length === 0)
|
|
737
738
|
return { updatedNodes: [] };
|
|
738
|
-
let
|
|
739
|
-
const
|
|
740
|
-
|
|
741
|
-
const m = x.get(t) || [], { nodes:
|
|
742
|
-
|
|
739
|
+
let p = r;
|
|
740
|
+
const f = s.get(t);
|
|
741
|
+
f && f.data.layoutDirection && (p = f.data.layoutDirection);
|
|
742
|
+
const m = x.get(t) || [], { nodes: y, edges: g } = await i(
|
|
743
|
+
C,
|
|
743
744
|
m,
|
|
744
745
|
// Only use temporary edges for layout
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
l,
|
|
748
|
-
c,
|
|
746
|
+
p,
|
|
747
|
+
o,
|
|
749
748
|
h,
|
|
750
749
|
a,
|
|
751
|
-
d
|
|
750
|
+
d,
|
|
751
|
+
l,
|
|
752
|
+
c
|
|
752
753
|
);
|
|
753
|
-
|
|
754
|
-
|
|
754
|
+
y.forEach((L) => {
|
|
755
|
+
s.set(L.id, L);
|
|
755
756
|
});
|
|
756
|
-
const
|
|
757
|
-
|
|
757
|
+
const w = de(
|
|
758
|
+
y,
|
|
758
759
|
t,
|
|
759
|
-
|
|
760
|
-
|
|
760
|
+
p,
|
|
761
|
+
h,
|
|
761
762
|
n,
|
|
762
|
-
|
|
763
|
+
s,
|
|
763
764
|
N
|
|
764
765
|
);
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
),
|
|
771
|
-
|
|
766
|
+
le(
|
|
767
|
+
y,
|
|
768
|
+
p,
|
|
769
|
+
h,
|
|
770
|
+
w
|
|
771
|
+
), y.forEach((L) => {
|
|
772
|
+
s.set(L.id, L);
|
|
772
773
|
});
|
|
773
|
-
const
|
|
774
|
-
return
|
|
775
|
-
|
|
776
|
-
}),
|
|
777
|
-
updatedNodes: [...
|
|
778
|
-
udpatedParentNode:
|
|
774
|
+
const E = ae(y, o);
|
|
775
|
+
return E.nodes.forEach((L) => {
|
|
776
|
+
s.set(L.id, L);
|
|
777
|
+
}), f && E.width && E.height && ue(f, E.width, E.height), {
|
|
778
|
+
updatedNodes: [...E.nodes],
|
|
779
|
+
udpatedParentNode: f || void 0
|
|
779
780
|
};
|
|
780
|
-
},
|
|
781
|
+
}, ue = (t, r, e) => (t.style || (t.style = {}), t.width = r, t.height = e, t.measured = {
|
|
781
782
|
width: r,
|
|
782
783
|
height: e
|
|
783
|
-
}, t.style.width = r, t.style.height = e, t),
|
|
784
|
+
}, t.style.width = r, t.style.height = e, t), fe = async (t, r, e, s, n, o = rt, h = 50, a = 50, d = 172, l = 36, i = J, c = !1, x = "no-parent") => {
|
|
784
785
|
let N = [];
|
|
785
|
-
const
|
|
786
|
-
let
|
|
787
|
-
const
|
|
788
|
-
|
|
789
|
-
for (const
|
|
790
|
-
|
|
786
|
+
const b = et(n, s, x), C = /* @__PURE__ */ new Map();
|
|
787
|
+
let p = 0;
|
|
788
|
+
const f = (y, g) => {
|
|
789
|
+
g > p && (p = g);
|
|
790
|
+
for (const w of y)
|
|
791
|
+
C.has(g) || C.set(g, []), C.get(g).push(w.id), w.children.length > 0 && f(w.children, g + 1);
|
|
791
792
|
};
|
|
792
|
-
|
|
793
|
-
for (let
|
|
794
|
-
const
|
|
795
|
-
(
|
|
796
|
-
|
|
793
|
+
f(t, 0);
|
|
794
|
+
for (let y = p; y >= 0; y--) {
|
|
795
|
+
const g = C.get(y) || [], w = await Promise.all(g.map(
|
|
796
|
+
(E) => X(
|
|
797
|
+
E,
|
|
797
798
|
r,
|
|
798
799
|
e,
|
|
799
|
-
|
|
800
|
+
s,
|
|
800
801
|
n,
|
|
801
802
|
// Pass original edges (only used for returning)
|
|
802
|
-
|
|
803
|
-
l,
|
|
804
|
-
c,
|
|
803
|
+
o,
|
|
805
804
|
h,
|
|
806
805
|
a,
|
|
807
|
-
s,
|
|
808
806
|
d,
|
|
809
|
-
|
|
807
|
+
l,
|
|
808
|
+
i,
|
|
809
|
+
c,
|
|
810
|
+
b,
|
|
810
811
|
// Pass the global temporary edges map
|
|
811
812
|
x
|
|
812
813
|
)
|
|
813
814
|
));
|
|
814
|
-
for (const { updatedNodes:
|
|
815
|
-
N = [...
|
|
815
|
+
for (const { updatedNodes: E } of w)
|
|
816
|
+
N = [...E, ...N];
|
|
816
817
|
}
|
|
817
|
-
const { updatedNodes: m } = await
|
|
818
|
+
const { updatedNodes: m } = await X(
|
|
818
819
|
x,
|
|
819
820
|
r,
|
|
820
821
|
e,
|
|
821
|
-
|
|
822
|
+
s,
|
|
822
823
|
n,
|
|
823
824
|
// Pass original edges (only used for returning)
|
|
824
|
-
|
|
825
|
-
l,
|
|
826
|
-
c,
|
|
825
|
+
o,
|
|
827
826
|
h,
|
|
828
827
|
a,
|
|
829
|
-
s,
|
|
830
828
|
d,
|
|
831
|
-
|
|
829
|
+
l,
|
|
830
|
+
i,
|
|
831
|
+
c,
|
|
832
|
+
b,
|
|
832
833
|
// Process root-level temporary edges
|
|
833
834
|
x
|
|
834
835
|
);
|
|
@@ -837,204 +838,204 @@ const rt = 10, gt = (t, r) => t.find((e) => e.id === r), yt = (t, r, e) => {
|
|
|
837
838
|
updatedEdges: n
|
|
838
839
|
// Always return original edges unchanged
|
|
839
840
|
};
|
|
840
|
-
}, ge = (t, r, e,
|
|
841
|
-
const n = t.map((
|
|
842
|
-
var
|
|
843
|
-
return ((
|
|
844
|
-
}).filter((
|
|
845
|
-
/* @__PURE__ */ new Set([...n, ...
|
|
846
|
-
).filter((
|
|
847
|
-
const
|
|
848
|
-
return
|
|
841
|
+
}, ge = (t, r, e, s = "no-parent") => {
|
|
842
|
+
const n = t.map((l) => l.id), o = t.map((l) => {
|
|
843
|
+
var i;
|
|
844
|
+
return ((i = e.get(l.id)) == null ? void 0 : i.parentId) || l.parentId;
|
|
845
|
+
}).filter((l) => !!l), a = Array.from(
|
|
846
|
+
/* @__PURE__ */ new Set([...n, ...o])
|
|
847
|
+
).filter((l) => r.has(l)), d = a.filter((l) => {
|
|
848
|
+
const i = e.get(l);
|
|
849
|
+
return i ? !i.parentId || !a.includes(i.parentId) : !0;
|
|
849
850
|
});
|
|
850
|
-
return
|
|
851
|
-
},
|
|
851
|
+
return d.length === 0 ? [s] : d;
|
|
852
|
+
}, pe = async (t, r, e) => {
|
|
852
853
|
const {
|
|
853
|
-
dagreDirection:
|
|
854
|
+
dagreDirection: s,
|
|
854
855
|
nodeParentIdMapWithChildIdSet: n,
|
|
855
|
-
nodeIdWithNode:
|
|
856
|
-
nodes:
|
|
857
|
-
edges:
|
|
858
|
-
margin:
|
|
859
|
-
nodeSpacing:
|
|
860
|
-
layerSpacing:
|
|
861
|
-
nodeWidth:
|
|
856
|
+
nodeIdWithNode: o,
|
|
857
|
+
nodes: h,
|
|
858
|
+
edges: a,
|
|
859
|
+
margin: d,
|
|
860
|
+
nodeSpacing: l,
|
|
861
|
+
layerSpacing: i,
|
|
862
|
+
nodeWidth: c,
|
|
862
863
|
nodeHeight: x,
|
|
863
864
|
layoutHidden: N = !1,
|
|
864
|
-
noParentKey:
|
|
865
|
-
} = r,
|
|
865
|
+
noParentKey: b = "no-parent"
|
|
866
|
+
} = r, C = ge(
|
|
866
867
|
t,
|
|
867
868
|
n,
|
|
868
|
-
|
|
869
|
-
|
|
869
|
+
o,
|
|
870
|
+
b
|
|
870
871
|
);
|
|
871
|
-
if (
|
|
872
|
-
return { nodes:
|
|
873
|
-
const
|
|
872
|
+
if (C.length === 0)
|
|
873
|
+
return { nodes: h, edges: a };
|
|
874
|
+
const p = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map();
|
|
874
875
|
if (e != null && e.aborted)
|
|
875
|
-
return { nodes:
|
|
876
|
+
return { nodes: h, edges: a };
|
|
876
877
|
(await Promise.all(
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
878
|
+
C.map(async (w) => e != null && e.aborted ? { updatedNodes: [], updatedEdges: [] } : Nt(
|
|
879
|
+
w,
|
|
880
|
+
s,
|
|
880
881
|
n,
|
|
881
|
-
|
|
882
|
-
c,
|
|
883
|
-
h,
|
|
882
|
+
o,
|
|
884
883
|
a,
|
|
885
|
-
s,
|
|
886
884
|
d,
|
|
885
|
+
l,
|
|
886
|
+
i,
|
|
887
|
+
c,
|
|
887
888
|
x,
|
|
888
889
|
void 0,
|
|
889
890
|
N
|
|
890
891
|
))
|
|
891
|
-
)).forEach(({ updatedNodes:
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}),
|
|
895
|
-
|
|
892
|
+
)).forEach(({ updatedNodes: w, updatedEdges: E }) => {
|
|
893
|
+
w.forEach((L) => {
|
|
894
|
+
p.set(L.id, L);
|
|
895
|
+
}), E.forEach((L) => {
|
|
896
|
+
f.set(L.id, L);
|
|
896
897
|
});
|
|
897
898
|
});
|
|
898
|
-
const
|
|
899
|
-
(
|
|
900
|
-
),
|
|
901
|
-
(
|
|
899
|
+
const y = h.map(
|
|
900
|
+
(w) => p.has(w.id) ? p.get(w.id) : w
|
|
901
|
+
), g = a.map(
|
|
902
|
+
(w) => f.has(w.id) ? f.get(w.id) : w
|
|
902
903
|
);
|
|
903
|
-
return { nodes:
|
|
904
|
-
},
|
|
905
|
-
const x = U(async (
|
|
904
|
+
return { nodes: y, edges: g };
|
|
905
|
+
}, ye = (t, r, e, s, n, o, h, a, d = 172, l = 36, i = !1, c = "no-parent") => {
|
|
906
|
+
const x = U(async (b, C, p, f) => {
|
|
906
907
|
if (!(t[e] || t.dagre))
|
|
907
|
-
return console.error(`Layout engine "${e}" not found`), { nodes:
|
|
908
|
-
const
|
|
909
|
-
(k) =>
|
|
910
|
-
),
|
|
908
|
+
return console.error(`Layout engine "${e}" not found`), { nodes: b, edges: C };
|
|
909
|
+
const y = i ? b : b.filter((k) => !k.hidden), g = new Set(y.map((k) => k.id)), w = i ? C : C.filter(
|
|
910
|
+
(k) => g.has(k.source) && g.has(k.target)
|
|
911
|
+
), E = ft(r), L = s.padding.horizontal;
|
|
911
912
|
let M = [], G = [];
|
|
912
|
-
if (
|
|
913
|
-
const k =
|
|
913
|
+
if (p && p.length > 0) {
|
|
914
|
+
const k = i ? p : p.filter((S) => !S.hidden), v = await pe(
|
|
914
915
|
k,
|
|
915
916
|
{
|
|
916
|
-
dagreDirection:
|
|
917
|
+
dagreDirection: E,
|
|
917
918
|
nodeParentIdMapWithChildIdSet: n,
|
|
918
|
-
nodeIdWithNode:
|
|
919
|
-
nodes:
|
|
920
|
-
edges:
|
|
921
|
-
margin:
|
|
922
|
-
nodeSpacing:
|
|
923
|
-
layerSpacing:
|
|
924
|
-
nodeWidth:
|
|
925
|
-
nodeHeight:
|
|
926
|
-
layoutHidden:
|
|
927
|
-
noParentKey:
|
|
919
|
+
nodeIdWithNode: o,
|
|
920
|
+
nodes: y,
|
|
921
|
+
edges: w,
|
|
922
|
+
margin: L,
|
|
923
|
+
nodeSpacing: h,
|
|
924
|
+
layerSpacing: a,
|
|
925
|
+
nodeWidth: d,
|
|
926
|
+
nodeHeight: l,
|
|
927
|
+
layoutHidden: i,
|
|
928
|
+
noParentKey: c
|
|
928
929
|
},
|
|
929
|
-
|
|
930
|
+
f
|
|
930
931
|
);
|
|
931
932
|
M = v.nodes, G = v.edges;
|
|
932
933
|
} else {
|
|
933
|
-
if (
|
|
934
|
-
return { nodes:
|
|
935
|
-
const k =
|
|
934
|
+
if (f != null && f.aborted)
|
|
935
|
+
return { nodes: b, edges: C };
|
|
936
|
+
const k = se(n, o, c), v = await fe(
|
|
936
937
|
k,
|
|
937
|
-
|
|
938
|
+
E,
|
|
938
939
|
n,
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
l,
|
|
943
|
-
c,
|
|
940
|
+
o,
|
|
941
|
+
w,
|
|
942
|
+
L,
|
|
944
943
|
h,
|
|
945
944
|
a,
|
|
945
|
+
d,
|
|
946
|
+
l,
|
|
946
947
|
void 0,
|
|
947
|
-
|
|
948
|
-
|
|
948
|
+
i,
|
|
949
|
+
c
|
|
949
950
|
);
|
|
950
951
|
M = v.updatedNodes, G = v.updatedEdges;
|
|
951
952
|
}
|
|
952
953
|
return {
|
|
953
|
-
nodes:
|
|
954
|
+
nodes: b.map((k) => !i && k.hidden ? k : M.find((S) => S.id === k.id) || k),
|
|
954
955
|
edges: G
|
|
955
956
|
};
|
|
956
957
|
}, [
|
|
957
958
|
e,
|
|
958
959
|
r,
|
|
959
960
|
t,
|
|
960
|
-
|
|
961
|
+
s.padding.horizontal,
|
|
961
962
|
n,
|
|
962
|
-
|
|
963
|
-
l,
|
|
964
|
-
c,
|
|
963
|
+
o,
|
|
965
964
|
h,
|
|
966
965
|
a,
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
966
|
+
d,
|
|
967
|
+
l,
|
|
968
|
+
i,
|
|
969
|
+
c
|
|
970
|
+
]), N = U(async (b, C, p, f) => {
|
|
971
|
+
if (f != null && f.aborted) return { nodes: C, edges: p };
|
|
972
|
+
const m = ft(r), y = s.padding.horizontal, g = i ? C : C.filter((v) => !v.hidden), w = new Set(g.map((v) => v.id)), E = i ? p : p.filter((v) => w.has(v.source) && w.has(v.target)), L = et(E, o, c), M = (v) => {
|
|
972
973
|
const S = [], R = n.get(v);
|
|
973
974
|
if (R)
|
|
974
975
|
for (const _ of R)
|
|
975
976
|
n.has(_) && S.push(...M(_));
|
|
976
977
|
return S.push(v), S;
|
|
977
|
-
}, G = M(
|
|
978
|
+
}, G = M(b), O = /* @__PURE__ */ new Map();
|
|
978
979
|
for (const v of G) {
|
|
979
|
-
if (
|
|
980
|
-
const { updatedNodes: S, udpatedParentNode: R } = await
|
|
980
|
+
if (f != null && f.aborted) return { nodes: C, edges: p };
|
|
981
|
+
const { updatedNodes: S, udpatedParentNode: R } = await X(
|
|
981
982
|
v,
|
|
982
983
|
m,
|
|
983
984
|
n,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
l,
|
|
988
|
-
c,
|
|
985
|
+
o,
|
|
986
|
+
E,
|
|
987
|
+
y,
|
|
989
988
|
h,
|
|
990
989
|
a,
|
|
990
|
+
d,
|
|
991
|
+
l,
|
|
991
992
|
void 0,
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
993
|
+
i,
|
|
994
|
+
L,
|
|
995
|
+
c
|
|
995
996
|
);
|
|
996
997
|
S.forEach((_) => O.set(_.id, _)), R && O.set(R.id, { ...R });
|
|
997
998
|
}
|
|
998
|
-
return { nodes:
|
|
999
|
+
return { nodes: C.map((v) => O.get(v.id) ?? v), edges: p };
|
|
999
1000
|
}, [
|
|
1000
1001
|
r,
|
|
1001
|
-
|
|
1002
|
+
s.padding.horizontal,
|
|
1002
1003
|
n,
|
|
1003
|
-
|
|
1004
|
-
l,
|
|
1005
|
-
c,
|
|
1004
|
+
o,
|
|
1006
1005
|
h,
|
|
1007
1006
|
a,
|
|
1008
|
-
|
|
1009
|
-
|
|
1007
|
+
d,
|
|
1008
|
+
l,
|
|
1009
|
+
i,
|
|
1010
|
+
c
|
|
1010
1011
|
]);
|
|
1011
1012
|
return { calculateLayout: x, calculateContainerLayout: N };
|
|
1012
1013
|
};
|
|
1013
|
-
function
|
|
1014
|
+
function Ce({
|
|
1014
1015
|
children: t,
|
|
1015
1016
|
initialDirection: r = "DOWN",
|
|
1016
1017
|
initialAlgorithm: e = "layered",
|
|
1017
|
-
initialAutoLayout:
|
|
1018
|
+
initialAutoLayout: s = !0,
|
|
1018
1019
|
initialPadding: n = 50,
|
|
1019
|
-
initialSpacing:
|
|
1020
|
-
initialNodeDimensions:
|
|
1021
|
-
initialParentResizingOptions:
|
|
1022
|
-
includeHidden:
|
|
1023
|
-
layoutEngines:
|
|
1024
|
-
updateNodes:
|
|
1025
|
-
updateEdges:
|
|
1020
|
+
initialSpacing: o = { node: 50, layer: 50 },
|
|
1021
|
+
initialNodeDimensions: h = { width: 172, height: 36 },
|
|
1022
|
+
initialParentResizingOptions: a,
|
|
1023
|
+
includeHidden: d = !1,
|
|
1024
|
+
layoutEngines: l,
|
|
1025
|
+
updateNodes: i,
|
|
1026
|
+
updateEdges: c,
|
|
1026
1027
|
nodeParentIdMapWithChildIdSet: x,
|
|
1027
1028
|
nodeIdWithNode: N,
|
|
1028
|
-
noParentKey:
|
|
1029
|
-
disableAutoLayoutEffect:
|
|
1029
|
+
noParentKey: b = "no-parent",
|
|
1030
|
+
disableAutoLayoutEffect: C = !1
|
|
1030
1031
|
}) {
|
|
1031
|
-
const
|
|
1032
|
+
const p = Ft(), f = Pt(), {
|
|
1032
1033
|
direction: m,
|
|
1033
|
-
algorithm:
|
|
1034
|
-
autoLayout:
|
|
1035
|
-
layoutInProgress:
|
|
1036
|
-
layoutHidden:
|
|
1037
|
-
layoutEngines:
|
|
1034
|
+
algorithm: y,
|
|
1035
|
+
autoLayout: g,
|
|
1036
|
+
layoutInProgress: w,
|
|
1037
|
+
layoutHidden: E,
|
|
1038
|
+
layoutEngines: L,
|
|
1038
1039
|
layoutEngineOptions: M,
|
|
1039
1040
|
padding: G,
|
|
1040
1041
|
nodeSpacing: O,
|
|
@@ -1043,53 +1044,52 @@ function Le({
|
|
|
1043
1044
|
nodeHeight: S,
|
|
1044
1045
|
parentResizingOptions: R,
|
|
1045
1046
|
selectedNodes: _,
|
|
1046
|
-
setDirection:
|
|
1047
|
-
setAlgorithm:
|
|
1048
|
-
setAutoLayout:
|
|
1049
|
-
setLayoutInProgress:
|
|
1050
|
-
setLayoutHidden:
|
|
1047
|
+
setDirection: Z,
|
|
1048
|
+
setAlgorithm: q,
|
|
1049
|
+
setAutoLayout: Q,
|
|
1050
|
+
setLayoutInProgress: P,
|
|
1051
|
+
setLayoutHidden: I,
|
|
1051
1052
|
setLayoutEngines: nt,
|
|
1052
1053
|
setLayoutEngineOptions: vt,
|
|
1053
1054
|
setPadding: Tt,
|
|
1054
|
-
setNodeSpacing:
|
|
1055
|
-
setLayerSpacing:
|
|
1055
|
+
setNodeSpacing: st,
|
|
1056
|
+
setLayerSpacing: ot,
|
|
1056
1057
|
setNodeWidth: kt,
|
|
1057
1058
|
setNodeHeight: Bt,
|
|
1058
|
-
setParentResizingOptionsState:
|
|
1059
|
+
setParentResizingOptionsState: it,
|
|
1059
1060
|
setSelectedNodes: ct
|
|
1060
|
-
} =
|
|
1061
|
+
} = ee({
|
|
1061
1062
|
initialDirection: r,
|
|
1062
1063
|
initialAlgorithm: e,
|
|
1063
|
-
initialAutoLayout:
|
|
1064
|
+
initialAutoLayout: s,
|
|
1064
1065
|
initialPadding: n,
|
|
1065
|
-
initialSpacing:
|
|
1066
|
-
initialNodeDimensions:
|
|
1067
|
-
initialParentResizingOptions:
|
|
1068
|
-
includeHidden:
|
|
1069
|
-
layoutEngines:
|
|
1066
|
+
initialSpacing: o,
|
|
1067
|
+
initialNodeDimensions: h,
|
|
1068
|
+
initialParentResizingOptions: a,
|
|
1069
|
+
includeHidden: d,
|
|
1070
|
+
layoutEngines: l
|
|
1070
1071
|
}), {
|
|
1071
1072
|
nodeIdWithNode: W,
|
|
1072
1073
|
nodeParentIdMapWithChildIdSet: at,
|
|
1073
1074
|
numberOfNodes: Mt,
|
|
1074
1075
|
nodesLength: St,
|
|
1075
1076
|
childrenInitialized: lt,
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
nodes: f,
|
|
1077
|
+
parentChildStructure: Dt
|
|
1078
|
+
} = re({
|
|
1079
|
+
nodes: p,
|
|
1080
1080
|
externalNodeIdWithNode: N,
|
|
1081
1081
|
externalNodeParentIdMapWithChildIdSet: x,
|
|
1082
|
-
noParentKey:
|
|
1083
|
-
}),
|
|
1082
|
+
noParentKey: b
|
|
1083
|
+
}), Rt = U(({ nodes: H }) => {
|
|
1084
1084
|
ct(H);
|
|
1085
1085
|
}, [ct]);
|
|
1086
1086
|
jt({
|
|
1087
|
-
onChange:
|
|
1087
|
+
onChange: Rt
|
|
1088
1088
|
});
|
|
1089
|
-
const { calculateLayout:
|
|
1090
|
-
|
|
1089
|
+
const { calculateLayout: Ot, calculateContainerLayout: At } = ye(
|
|
1090
|
+
L,
|
|
1091
1091
|
m,
|
|
1092
|
-
|
|
1092
|
+
y,
|
|
1093
1093
|
R,
|
|
1094
1094
|
at,
|
|
1095
1095
|
W,
|
|
@@ -1097,72 +1097,71 @@ function Le({
|
|
|
1097
1097
|
k,
|
|
1098
1098
|
v,
|
|
1099
1099
|
S,
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
), { applyLayout: ht, applyContainerLayout:
|
|
1103
|
-
nodes:
|
|
1104
|
-
edges:
|
|
1100
|
+
E,
|
|
1101
|
+
b
|
|
1102
|
+
), { applyLayout: ht, applyContainerLayout: zt } = ne({
|
|
1103
|
+
nodes: p,
|
|
1104
|
+
edges: f,
|
|
1105
1105
|
selectedNodes: _,
|
|
1106
|
-
layoutHidden:
|
|
1107
|
-
calculateLayout:
|
|
1108
|
-
calculateContainerLayout:
|
|
1109
|
-
updateNodes:
|
|
1110
|
-
updateEdges:
|
|
1111
|
-
setLayoutInProgress:
|
|
1112
|
-
setNodeSpacing:
|
|
1113
|
-
setLayerSpacing:
|
|
1114
|
-
}),
|
|
1115
|
-
nt((
|
|
1116
|
-
}, [nt]),
|
|
1117
|
-
|
|
1106
|
+
layoutHidden: E,
|
|
1107
|
+
calculateLayout: Ot,
|
|
1108
|
+
calculateContainerLayout: At,
|
|
1109
|
+
updateNodes: i,
|
|
1110
|
+
updateEdges: c,
|
|
1111
|
+
setLayoutInProgress: P,
|
|
1112
|
+
setNodeSpacing: st,
|
|
1113
|
+
setLayerSpacing: ot
|
|
1114
|
+
}), Gt = U((H, K) => {
|
|
1115
|
+
nt(($t) => ({ ...$t, [H]: K }));
|
|
1116
|
+
}, [nt]), _t = U((H) => {
|
|
1117
|
+
it((K) => ({
|
|
1118
1118
|
...K,
|
|
1119
1119
|
...H,
|
|
1120
|
-
enabled:
|
|
1120
|
+
enabled: g
|
|
1121
1121
|
}));
|
|
1122
|
-
}, [
|
|
1123
|
-
|
|
1122
|
+
}, [g, it]);
|
|
1123
|
+
Y(() => {
|
|
1124
1124
|
var H;
|
|
1125
|
-
|
|
1126
|
-
}, [lt,
|
|
1127
|
-
const
|
|
1125
|
+
C || W.has((H = p[p.length - 1]) == null ? void 0 : H.id) && lt && g && ht();
|
|
1126
|
+
}, [lt, g, m, Mt, O, k, Dt, St]);
|
|
1127
|
+
const Ht = {
|
|
1128
1128
|
direction: m,
|
|
1129
|
-
algorithm:
|
|
1130
|
-
autoLayout:
|
|
1131
|
-
layoutInProgress:
|
|
1132
|
-
nodesInitialized: Dt,
|
|
1129
|
+
algorithm: y,
|
|
1130
|
+
autoLayout: g,
|
|
1131
|
+
layoutInProgress: w,
|
|
1133
1132
|
padding: G,
|
|
1134
1133
|
nodeSpacing: O,
|
|
1135
1134
|
layerSpacing: k,
|
|
1136
1135
|
nodeWidth: v,
|
|
1137
1136
|
nodeHeight: S,
|
|
1138
|
-
layoutHidden:
|
|
1137
|
+
layoutHidden: E,
|
|
1139
1138
|
parentResizingOptions: R,
|
|
1140
|
-
layoutEngines:
|
|
1139
|
+
layoutEngines: L,
|
|
1141
1140
|
layoutEngineOptions: M,
|
|
1142
1141
|
nodeParentIdMapWithChildIdSet: at,
|
|
1143
1142
|
nodeIdWithNode: W,
|
|
1144
|
-
noParentKey:
|
|
1145
|
-
updateNodes:
|
|
1146
|
-
updateEdges:
|
|
1147
|
-
setDirection:
|
|
1148
|
-
setAlgorithm:
|
|
1149
|
-
setAutoLayout:
|
|
1150
|
-
setLayoutInProgress:
|
|
1143
|
+
noParentKey: b,
|
|
1144
|
+
updateNodes: i,
|
|
1145
|
+
updateEdges: c,
|
|
1146
|
+
setDirection: Z,
|
|
1147
|
+
setAlgorithm: q,
|
|
1148
|
+
setAutoLayout: Q,
|
|
1149
|
+
setLayoutInProgress: P,
|
|
1151
1150
|
setPadding: Tt,
|
|
1152
|
-
setNodeSpacing:
|
|
1153
|
-
setLayerSpacing:
|
|
1151
|
+
setNodeSpacing: st,
|
|
1152
|
+
setLayerSpacing: ot,
|
|
1154
1153
|
setNodeWidth: kt,
|
|
1155
1154
|
setNodeHeight: Bt,
|
|
1156
|
-
setLayoutHidden:
|
|
1157
|
-
setParentResizingOptions:
|
|
1155
|
+
setLayoutHidden: I,
|
|
1156
|
+
setParentResizingOptions: _t,
|
|
1158
1157
|
setLayoutEngineOptions: vt,
|
|
1159
1158
|
applyLayout: ht,
|
|
1160
|
-
applyContainerLayout:
|
|
1159
|
+
applyContainerLayout: zt,
|
|
1161
1160
|
clearLayoutCache: () => {
|
|
1162
1161
|
},
|
|
1163
|
-
registerLayoutEngine:
|
|
1162
|
+
registerLayoutEngine: Gt
|
|
1164
1163
|
};
|
|
1165
|
-
return /* @__PURE__ */ u(Lt.Provider, { value:
|
|
1164
|
+
return /* @__PURE__ */ u(Lt.Provider, { value: Ht, children: t });
|
|
1166
1165
|
}
|
|
1167
1166
|
const wt = ({
|
|
1168
1167
|
compact: t = !1
|
|
@@ -1170,9 +1169,9 @@ const wt = ({
|
|
|
1170
1169
|
const {
|
|
1171
1170
|
direction: r,
|
|
1172
1171
|
setDirection: e,
|
|
1173
|
-
clearLayoutCache:
|
|
1174
|
-
} =
|
|
1175
|
-
e(
|
|
1172
|
+
clearLayoutCache: s
|
|
1173
|
+
} = F(), n = (o) => {
|
|
1174
|
+
e(o), s && s();
|
|
1176
1175
|
};
|
|
1177
1176
|
return t ? /* @__PURE__ */ u(
|
|
1178
1177
|
D,
|
|
@@ -1187,7 +1186,7 @@ const wt = ({
|
|
|
1187
1186
|
/* @__PURE__ */ u("path", { d: "M12 4v16M6 16l6 6 6-6" })
|
|
1188
1187
|
) })
|
|
1189
1188
|
}
|
|
1190
|
-
) : /* @__PURE__ */ T(
|
|
1189
|
+
) : /* @__PURE__ */ T(j, { children: [
|
|
1191
1190
|
/* @__PURE__ */ u(
|
|
1192
1191
|
D,
|
|
1193
1192
|
{
|
|
@@ -1231,19 +1230,19 @@ const wt = ({
|
|
|
1231
1230
|
const {
|
|
1232
1231
|
nodeSpacing: r,
|
|
1233
1232
|
layerSpacing: e,
|
|
1234
|
-
setNodeSpacing:
|
|
1233
|
+
setNodeSpacing: s,
|
|
1235
1234
|
setLayerSpacing: n,
|
|
1236
|
-
clearLayoutCache:
|
|
1237
|
-
} =
|
|
1238
|
-
|
|
1239
|
-
},
|
|
1240
|
-
n(
|
|
1235
|
+
clearLayoutCache: o
|
|
1236
|
+
} = F(), [h, a] = B(!1), d = (i) => {
|
|
1237
|
+
s(i), o && o();
|
|
1238
|
+
}, l = (i) => {
|
|
1239
|
+
n(i), o && o();
|
|
1241
1240
|
};
|
|
1242
1241
|
return t ? /* @__PURE__ */ T("div", { style: { position: "relative" }, children: [
|
|
1243
1242
|
/* @__PURE__ */ u(
|
|
1244
1243
|
D,
|
|
1245
1244
|
{
|
|
1246
|
-
onClick: () =>
|
|
1245
|
+
onClick: () => a(!h),
|
|
1247
1246
|
title: "Adjust node and layer spacing",
|
|
1248
1247
|
children: /* @__PURE__ */ T("svg", { viewBox: "0 0 24 24", width: "16", height: "16", stroke: "currentColor", strokeWidth: "2", fill: "none", children: [
|
|
1249
1248
|
/* @__PURE__ */ u("rect", { x: "3", y: "3", width: "7", height: "7", rx: "1" }),
|
|
@@ -1254,7 +1253,7 @@ const wt = ({
|
|
|
1254
1253
|
] })
|
|
1255
1254
|
}
|
|
1256
1255
|
),
|
|
1257
|
-
|
|
1256
|
+
h && /* @__PURE__ */ T(
|
|
1258
1257
|
"div",
|
|
1259
1258
|
{
|
|
1260
1259
|
className: "react-flow-spacing-dropdown",
|
|
@@ -1278,21 +1277,21 @@ const wt = ({
|
|
|
1278
1277
|
r,
|
|
1279
1278
|
"px"
|
|
1280
1279
|
] }),
|
|
1281
|
-
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "4px" }, children: [50, 100, 150, 200].map((
|
|
1280
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "4px" }, children: [50, 100, 150, 200].map((i) => /* @__PURE__ */ u(
|
|
1282
1281
|
"button",
|
|
1283
1282
|
{
|
|
1284
|
-
onClick: () =>
|
|
1283
|
+
onClick: () => d(i),
|
|
1285
1284
|
style: {
|
|
1286
|
-
background: r ===
|
|
1287
|
-
color: r ===
|
|
1285
|
+
background: r === i ? "#0041d0" : "#f5f5f5",
|
|
1286
|
+
color: r === i ? "white" : "inherit",
|
|
1288
1287
|
border: "1px solid #ddd",
|
|
1289
1288
|
borderRadius: "4px",
|
|
1290
1289
|
padding: "4px 8px",
|
|
1291
1290
|
cursor: "pointer"
|
|
1292
1291
|
},
|
|
1293
|
-
children:
|
|
1292
|
+
children: i
|
|
1294
1293
|
},
|
|
1295
|
-
|
|
1294
|
+
i
|
|
1296
1295
|
)) })
|
|
1297
1296
|
] }),
|
|
1298
1297
|
/* @__PURE__ */ T("div", { children: [
|
|
@@ -1301,27 +1300,27 @@ const wt = ({
|
|
|
1301
1300
|
e,
|
|
1302
1301
|
"px"
|
|
1303
1302
|
] }),
|
|
1304
|
-
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "4px" }, children: [50, 100, 150, 200].map((
|
|
1303
|
+
/* @__PURE__ */ u("div", { style: { display: "flex", gap: "4px" }, children: [50, 100, 150, 200].map((i) => /* @__PURE__ */ u(
|
|
1305
1304
|
"button",
|
|
1306
1305
|
{
|
|
1307
|
-
onClick: () =>
|
|
1306
|
+
onClick: () => l(i),
|
|
1308
1307
|
style: {
|
|
1309
|
-
background: e ===
|
|
1310
|
-
color: e ===
|
|
1308
|
+
background: e === i ? "#0041d0" : "#f5f5f5",
|
|
1309
|
+
color: e === i ? "white" : "inherit",
|
|
1311
1310
|
border: "1px solid #ddd",
|
|
1312
1311
|
borderRadius: "4px",
|
|
1313
1312
|
padding: "4px 8px",
|
|
1314
1313
|
cursor: "pointer"
|
|
1315
1314
|
},
|
|
1316
|
-
children:
|
|
1315
|
+
children: i
|
|
1317
1316
|
},
|
|
1318
|
-
|
|
1317
|
+
i
|
|
1319
1318
|
)) })
|
|
1320
1319
|
] }),
|
|
1321
1320
|
/* @__PURE__ */ u("div", { style: { marginTop: "12px", textAlign: "right" }, children: /* @__PURE__ */ u(
|
|
1322
1321
|
"button",
|
|
1323
1322
|
{
|
|
1324
|
-
onClick: () =>
|
|
1323
|
+
onClick: () => a(!1),
|
|
1325
1324
|
style: {
|
|
1326
1325
|
background: "#f5f5f5",
|
|
1327
1326
|
border: "1px solid #ddd",
|
|
@@ -1339,7 +1338,7 @@ const wt = ({
|
|
|
1339
1338
|
/* @__PURE__ */ T(
|
|
1340
1339
|
D,
|
|
1341
1340
|
{
|
|
1342
|
-
onClick: () =>
|
|
1341
|
+
onClick: () => d(Math.max(50, r - 25)),
|
|
1343
1342
|
title: "Decrease node spacing",
|
|
1344
1343
|
children: [
|
|
1345
1344
|
/* @__PURE__ */ T("svg", { viewBox: "0 0 24 24", width: "16", height: "16", stroke: "currentColor", strokeWidth: "2", fill: "none", children: [
|
|
@@ -1372,7 +1371,7 @@ const wt = ({
|
|
|
1372
1371
|
/* @__PURE__ */ T(
|
|
1373
1372
|
D,
|
|
1374
1373
|
{
|
|
1375
|
-
onClick: () =>
|
|
1374
|
+
onClick: () => d(Math.min(300, r + 25)),
|
|
1376
1375
|
title: "Increase node spacing",
|
|
1377
1376
|
children: [
|
|
1378
1377
|
/* @__PURE__ */ T("svg", { viewBox: "0 0 24 24", width: "16", height: "16", stroke: "currentColor", strokeWidth: "2", fill: "none", children: [
|
|
@@ -1393,7 +1392,7 @@ const wt = ({
|
|
|
1393
1392
|
/* @__PURE__ */ T(
|
|
1394
1393
|
D,
|
|
1395
1394
|
{
|
|
1396
|
-
onClick: () =>
|
|
1395
|
+
onClick: () => l(Math.max(50, e - 25)),
|
|
1397
1396
|
title: "Decrease layer spacing",
|
|
1398
1397
|
children: [
|
|
1399
1398
|
/* @__PURE__ */ T("svg", { viewBox: "0 0 24 24", width: "16", height: "16", stroke: "currentColor", strokeWidth: "2", fill: "none", children: [
|
|
@@ -1421,7 +1420,7 @@ const wt = ({
|
|
|
1421
1420
|
/* @__PURE__ */ T(
|
|
1422
1421
|
D,
|
|
1423
1422
|
{
|
|
1424
|
-
onClick: () =>
|
|
1423
|
+
onClick: () => l(Math.min(300, e + 25)),
|
|
1425
1424
|
title: "Increase layer spacing",
|
|
1426
1425
|
children: [
|
|
1427
1426
|
/* @__PURE__ */ T("svg", { viewBox: "0 0 24 24", width: "16", height: "16", stroke: "currentColor", strokeWidth: "2", fill: "none", children: [
|
|
@@ -1440,7 +1439,7 @@ const wt = ({
|
|
|
1440
1439
|
const {
|
|
1441
1440
|
autoLayout: r,
|
|
1442
1441
|
setAutoLayout: e
|
|
1443
|
-
} =
|
|
1442
|
+
} = F();
|
|
1444
1443
|
return /* @__PURE__ */ u(
|
|
1445
1444
|
D,
|
|
1446
1445
|
{
|
|
@@ -1454,11 +1453,11 @@ const wt = ({
|
|
|
1454
1453
|
/* @__PURE__ */ u("rect", { x: "4", y: "4", width: "4", height: "4", rx: "1" }),
|
|
1455
1454
|
/* @__PURE__ */ u("rect", { x: "4", y: "16", width: "4", height: "4", rx: "1" }),
|
|
1456
1455
|
/* @__PURE__ */ u("rect", { x: "16", y: "10", width: "4", height: "4", rx: "1" }),
|
|
1457
|
-
/* @__PURE__ */ T(
|
|
1456
|
+
/* @__PURE__ */ T(j, { children: [
|
|
1458
1457
|
/* @__PURE__ */ u("path", { d: "M8 6c6 0 3 8 8 6" }),
|
|
1459
1458
|
/* @__PURE__ */ u("path", { d: "M8 18c3-3 2-8 6-6" })
|
|
1460
1459
|
] })
|
|
1461
|
-
] }) : /* @__PURE__ */ T(
|
|
1460
|
+
] }) : /* @__PURE__ */ T(j, { children: [
|
|
1462
1461
|
"Auto-Layout ",
|
|
1463
1462
|
r ? "ON" : "OFF"
|
|
1464
1463
|
] })
|
|
@@ -1470,17 +1469,17 @@ const wt = ({
|
|
|
1470
1469
|
const {
|
|
1471
1470
|
layoutInProgress: r,
|
|
1472
1471
|
setLayoutInProgress: e,
|
|
1473
|
-
applyLayout:
|
|
1474
|
-
} =
|
|
1472
|
+
applyLayout: s
|
|
1473
|
+
} = F();
|
|
1475
1474
|
return /* @__PURE__ */ T(
|
|
1476
1475
|
D,
|
|
1477
1476
|
{
|
|
1478
1477
|
onClick: async () => {
|
|
1479
1478
|
if (!r)
|
|
1480
1479
|
try {
|
|
1481
|
-
e(!0), await
|
|
1482
|
-
} catch (
|
|
1483
|
-
console.error("Error applying layout:",
|
|
1480
|
+
e(!0), await s();
|
|
1481
|
+
} catch (o) {
|
|
1482
|
+
console.error("Error applying layout:", o);
|
|
1484
1483
|
}
|
|
1485
1484
|
},
|
|
1486
1485
|
title: "Apply layout",
|
|
@@ -1500,20 +1499,20 @@ const wt = ({
|
|
|
1500
1499
|
]
|
|
1501
1500
|
}
|
|
1502
1501
|
);
|
|
1503
|
-
},
|
|
1502
|
+
}, Le = ({
|
|
1504
1503
|
showDirectionControls: t = !0,
|
|
1505
1504
|
showSpacingControls: r = !0,
|
|
1506
1505
|
showAutoLayoutToggle: e = !0,
|
|
1507
|
-
showApplyLayoutButton:
|
|
1506
|
+
showApplyLayoutButton: s = !0,
|
|
1508
1507
|
// Enable by default
|
|
1509
1508
|
standalone: n = !1,
|
|
1510
|
-
position:
|
|
1509
|
+
position: o = "top-right"
|
|
1511
1510
|
}) => {
|
|
1512
|
-
const
|
|
1513
|
-
autoLayout:
|
|
1514
|
-
} =
|
|
1515
|
-
return n ? /* @__PURE__ */ T(Xt, { position:
|
|
1516
|
-
|
|
1511
|
+
const h = F(), {
|
|
1512
|
+
autoLayout: a
|
|
1513
|
+
} = h;
|
|
1514
|
+
return n ? /* @__PURE__ */ T(Xt, { position: o, showZoom: !1, showFitView: !1, showInteractive: !1, children: [
|
|
1515
|
+
s && !a && /* @__PURE__ */ u(
|
|
1517
1516
|
Ct,
|
|
1518
1517
|
{
|
|
1519
1518
|
compact: !0
|
|
@@ -1537,8 +1536,8 @@ const wt = ({
|
|
|
1537
1536
|
compact: !0
|
|
1538
1537
|
}
|
|
1539
1538
|
)
|
|
1540
|
-
] }) : /* @__PURE__ */ T(
|
|
1541
|
-
|
|
1539
|
+
] }) : /* @__PURE__ */ T(j, { children: [
|
|
1540
|
+
s && !a && /* @__PURE__ */ u(
|
|
1542
1541
|
Ct,
|
|
1543
1542
|
{
|
|
1544
1543
|
compact: !0
|
|
@@ -1566,11 +1565,11 @@ const wt = ({
|
|
|
1566
1565
|
};
|
|
1567
1566
|
export {
|
|
1568
1567
|
bt as AutoLayoutToggle,
|
|
1569
|
-
|
|
1568
|
+
Kt as DagreEngine,
|
|
1570
1569
|
wt as DirectionControls,
|
|
1571
|
-
|
|
1572
|
-
|
|
1570
|
+
Le as LayoutControls,
|
|
1571
|
+
Ce as LayoutProvider,
|
|
1573
1572
|
mt as SpacingControls,
|
|
1574
|
-
|
|
1575
|
-
|
|
1573
|
+
te as engines,
|
|
1574
|
+
F as useLayoutContext
|
|
1576
1575
|
};
|