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