@oscherbakov/react-flow-automated-layout 1.3.4 → 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 P } from "react/jsx-runtime";
2
- import { createContext as Ft, useContext as Vt, useState as B, useEffect as V, useRef as dt, useCallback as U } from "react";
3
- import { Position as A, useReactFlow as It, useNodes as Yt, useEdges as Pt, useOnSelectionChange as jt, ControlButton as D, Controls as Xt } from "@xyflow/react";
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 = Ft(void 0);
6
- function I() {
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
- }, pt = (t) => {
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 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)
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: o, edges: i };
80
+ return { nodes: s, edges: o };
81
81
  }
82
- const Wt = 172, Kt = 36, X = async (t, r, e, o = 0, n = 50, i = 50, l = Wt, c = Kt, h = !1) => {
83
- const a = new ut.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
84
- a.setGraph({
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: o,
87
- marginy: o,
86
+ marginx: s,
87
+ marginy: s,
88
88
  nodesep: n,
89
- ranksep: i,
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 s = h ? t : t.filter((f) => !f.hidden);
95
- if (s.length === 0)
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
- s.forEach((f) => {
98
- var w, y;
99
- const p = Number((w = f.style) == null ? void 0 : w.width) || l, m = Number((y = f.style) == null ? void 0 : y.height) || c;
100
- a.setNode(f.id, { width: p, height: m });
101
- }), r.forEach((f) => {
102
- var C, b;
103
- const p = f.sourceHandle, m = f.targetHandle, w = !!((C = f.data) != null && C.isReciprocal), y = !!((b = f.data) != null && b.isSyntheticBridge);
104
- let g = {};
105
- w ? g = { constraint: !1, minlen: 1, weight: 5 } : y ? g = { constraint: !0, minlen: 1, weight: 4 } : p === "right" && m === "left" ? g = { constraint: !1, minlen: 1 } : p === "bottom" && m === "top" ? g = { constraint: !0, minlen: 1 } : g = { constraint: !0, minlen: 2 }, a.setEdge(f.source, f.target, g);
106
- }), ut.layout(a);
107
- const d = a.graph().width || 0, x = a.graph().height || 0, N = Zt(pt(e)), L = qt(pt(e));
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: s.map((f) => {
110
- var b;
111
- const p = a.node(f.id), { width: m, height: w } = p, y = {
112
- ...f,
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: L,
114
+ targetPosition: b,
115
115
  selected: !1
116
- }, g = p.x, C = p.y;
117
- switch ((b = f.data) == null ? void 0 : b.positionType) {
116
+ }, w = f.x, E = f.y;
117
+ switch ((L = p.data) == null ? void 0 : L.positionType) {
118
118
  case "center":
119
- y.position = { x: g, y: C };
119
+ g.position = { x: w, y: E };
120
120
  break;
121
121
  case "topRight":
122
- y.position = { x: g + m / 2, y: C - w / 2 };
122
+ g.position = { x: w + m / 2, y: E - y / 2 };
123
123
  break;
124
124
  case "bottomLeft":
125
- y.position = { x: g - m / 2, y: C + w / 2 };
125
+ g.position = { x: w - m / 2, y: E + y / 2 };
126
126
  break;
127
127
  case "bottomRight":
128
- y.position = { x: g + m / 2, y: C + w / 2 };
128
+ g.position = { x: w + m / 2, y: E + y / 2 };
129
129
  break;
130
130
  case "topLeft":
131
131
  default:
132
- y.position = { x: g - m / 2, y: C - w / 2 };
132
+ g.position = { x: w - m / 2, y: E - y / 2 };
133
133
  }
134
- return y;
134
+ return g;
135
135
  }),
136
136
  edges: r,
137
- width: d,
137
+ width: c,
138
138
  height: x
139
139
  };
140
- }, te = {
140
+ }, Kt = {
141
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, d = e.nodeHeight ?? 36, x = e.layoutHidden ?? !1;
143
- return X(
144
- o,
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
- }, ee = {
156
- dagre: te
155
+ }, te = {
156
+ dagre: Kt
157
157
  };
158
- function re({
158
+ function ee({
159
159
  initialDirection: t = "DOWN",
160
160
  initialAlgorithm: r = "layered",
161
161
  initialAutoLayout: e = !0,
162
- initialPadding: o = 50,
162
+ initialPadding: s = 50,
163
163
  initialSpacing: n = { node: 50, layer: 50 },
164
- initialNodeDimensions: i = { width: 172, height: 36 },
165
- initialParentResizingOptions: l,
166
- includeHidden: c = !1,
167
- layoutEngines: h
164
+ initialNodeDimensions: o = { width: 172, height: 36 },
165
+ initialParentResizingOptions: h,
166
+ includeHidden: a = !1,
167
+ layoutEngines: d
168
168
  }) {
169
- const [a, s] = B(t), [d, x] = B(r), [N, L] = B(e), [E, f] = B(!1), [p, m] = B(c), [w, y] = B({
170
- ...ee,
171
- ...h
172
- }), [g, C] = B({}), [b, 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({
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
- ...l,
174
+ ...h,
175
175
  enabled: e
176
- }), [Y, Q] = B([]);
176
+ }), [P, I] = B([]);
177
177
  return {
178
178
  // State
179
- direction: a,
180
- algorithm: d,
179
+ direction: l,
180
+ algorithm: c,
181
181
  autoLayout: N,
182
- layoutInProgress: E,
183
- layoutHidden: p,
184
- layoutEngines: w,
185
- layoutEngineOptions: g,
186
- padding: b,
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: Z,
192
- selectedNodes: Y,
191
+ parentResizingOptions: q,
192
+ selectedNodes: P,
193
193
  // Setters
194
- setDirection: s,
194
+ setDirection: i,
195
195
  setAlgorithm: x,
196
- setAutoLayout: L,
197
- setLayoutInProgress: f,
196
+ setAutoLayout: b,
197
+ setLayoutInProgress: p,
198
198
  setLayoutHidden: m,
199
- setLayoutEngines: y,
200
- setLayoutEngineOptions: C,
199
+ setLayoutEngines: g,
200
+ setLayoutEngineOptions: E,
201
201
  setPadding: M,
202
202
  setNodeSpacing: O,
203
203
  setLayerSpacing: v,
204
204
  setNodeWidth: R,
205
- setNodeHeight: J,
206
- setParentResizingOptionsState: q,
207
- setSelectedNodes: Q
205
+ setNodeHeight: Z,
206
+ setParentResizingOptionsState: Q,
207
+ setSelectedNodes: I
208
208
  };
209
209
  }
210
- function ne({
210
+ function re({
211
211
  nodes: t,
212
212
  externalNodeIdWithNode: r,
213
213
  externalNodeParentIdMapWithChildIdSet: e,
214
- noParentKey: o = "no-parent"
214
+ noParentKey: s = "no-parent"
215
215
  }) {
216
- const [n, i] = B(/* @__PURE__ */ new Map()), [l, c] = B(/* @__PURE__ */ new Map()), [h, a] = B({}), [s, d] = B(t.length), [x, N] = B(!1), [L, E] = B(!1), f = r || n, p = e || l, m = f.size;
217
- return V(() => {
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 w = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
220
- E(!1), t.forEach((g) => {
221
- var b;
222
- w.set(g.id, g);
223
- const C = g.parentId || o;
224
- y.has(C) || y.set(C, /* @__PURE__ */ new Set()), (b = y.get(C)) == null || b.add(g.id);
225
- }), r || i(w), e || c(y);
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, o]), V(() => {
228
- t.length !== s && d(t.length);
229
- }, [t]), V(() => {
230
- f.size > 0 && p.size > 0 && (x || N(!0), E(!0));
231
- }, [f, p, x]), V(() => {
232
- const w = {};
233
- p.forEach((g, C) => {
234
- w[C] = g.size;
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 y = !1;
237
- for (const g in w)
238
- if (!h.hasOwnProperty(g) || w[g] !== h[g]) {
239
- y = !0;
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
- y && a(w);
243
- }, [p]), {
244
- nodeIdWithNode: f,
245
- nodeParentIdMapWithChildIdSet: p,
246
- numberOfNodes: m,
247
- nodesLength: s,
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: h
249
+ parentChildStructure: d
251
250
  };
252
251
  }
253
- function oe({
252
+ function ne({
254
253
  nodes: t,
255
254
  edges: r,
256
255
  selectedNodes: e,
257
- layoutHidden: o,
256
+ layoutHidden: s,
258
257
  calculateLayout: n,
259
- calculateContainerLayout: i,
260
- updateNodes: l,
261
- updateEdges: c,
262
- setLayoutInProgress: h,
263
- setNodeSpacing: a,
264
- setLayerSpacing: s
258
+ calculateContainerLayout: o,
259
+ updateNodes: h,
260
+ updateEdges: a,
261
+ setLayoutInProgress: d,
262
+ setNodeSpacing: l,
263
+ setLayerSpacing: i
265
264
  }) {
266
- const d = It(), x = dt(null), N = dt(null), L = U(async (f = [], p = []) => {
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 w = f.length > 0 ? f : t, y = p.length > 0 ? p : r;
271
- if (w.length === 0)
272
- return { nodes: w, edges: y };
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 (h(!0), m.signal.aborted)
275
- return { nodes: w, edges: y };
276
- const { nodes: g, edges: C } = Qt(w, y, o), b = await n(g, C, e, m.signal);
277
- return m.signal.aborted ? { nodes: w, edges: y } : (x.current === m && (l ? l(b.nodes) : d != null && d.setNodes && d.setNodes(b.nodes), c ? c(b.edges) : d != null && d.setEdges && d.setEdges(b.edges), N.current && (N.current.node !== void 0 && a(N.current.node), N.current.layer !== void 0 && s(N.current.layer), N.current = null)), b);
278
- } catch (g) {
279
- return m.signal.aborted || console.error("Error applying layout:", g), { nodes: w, edges: y };
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 && (h(!1), x.current = null);
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
- s
295
- ]), E = U(async (f) => {
289
+ c,
290
+ s,
291
+ d,
292
+ l,
293
+ i
294
+ ]), C = U(async (p) => {
296
295
  x.current && x.current.abort();
297
- const p = new AbortController();
298
- if (x.current = p, t.length === 0) return { nodes: t, edges: r };
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 (h(!0), p.signal.aborted) return { nodes: t, edges: r };
301
- const m = await i(f, t, r, p.signal);
302
- return p.signal.aborted ? { nodes: t, edges: r } : (x.current === p && (l ? l(m.nodes) : d != null && d.setNodes && d.setNodes(m.nodes), c ? c(m.edges) : d != null && d.setEdges && d.setEdges(m.edges)), m);
303
- } catch (m) {
304
- return p.signal.aborted || console.error("Error applying container layout:", m), { nodes: t, edges: r };
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 === p && (h(!1), x.current = null);
307
+ x.current === f && (d(!1), x.current = null);
307
308
  }
308
- }, [t, r, i, l, c, d, h]);
309
+ }, [t, r, o, h, a, c, d]);
309
310
  return {
310
- applyLayout: L,
311
- applyContainerLayout: E,
311
+ applyLayout: b,
312
+ applyContainerLayout: C,
312
313
  pendingSpacingUpdateRef: N
313
314
  };
314
315
  }
315
- const ie = (t, r, e = "no-parent") => {
316
- const o = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
317
- t.forEach((c, h) => {
318
- const a = r.get(h);
319
- a && n.set(h, {
320
- id: h,
321
- node: a,
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 i = (c, h) => {
327
- if (o.has(c) || !t.has(c) || !r.get(c)) return null;
328
- o.add(c);
329
- const s = n.get(c);
330
- s.depth = h;
331
- const d = t.get(c) || /* @__PURE__ */ new Set();
332
- for (const x of d)
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 L = i(x, h + 1);
335
- L && s.children.push(L);
335
+ const b = o(x, d + 1);
336
+ b && i.children.push(b);
336
337
  }
337
- return s;
338
- }, l = [];
339
- return t.forEach((c, h) => {
340
- const a = r.get(h);
341
- if (a) {
342
- const s = a.parentId;
343
- if (!s || s === e) {
344
- const d = i(h, 0);
345
- d && l.push(d);
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
- }), l;
349
+ }), h;
349
350
  };
350
351
  function tt(t, r, e = "no-parent") {
351
- const o = [];
352
+ const s = [];
352
353
  let n = t;
353
- const i = /* @__PURE__ */ new Set();
354
+ const o = /* @__PURE__ */ new Set();
354
355
  for (; n && n !== e; ) {
355
- if (i.has(n)) {
356
+ if (o.has(n)) {
356
357
  console.warn(`Cycle detected in ancestor path for node ${t}`);
357
358
  break;
358
359
  }
359
- i.add(n), o.push(n);
360
- const l = r.get(n);
361
- if (!l || !l.parentId) {
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 = l.parentId;
366
+ n = h.parentId;
366
367
  }
367
- return n === e && o.push(e), o;
368
+ return n === e && s.push(e), s;
368
369
  }
369
- function z(t, r, e, o = "no-parent") {
370
+ function z(t, r, e, s = "no-parent") {
370
371
  if (t === r)
371
372
  return t;
372
- const n = tt(t, e, o), i = n.indexOf(r);
373
- return i === -1 ? null : i === 0 ? t : n[i - 1] || null;
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 F(t, r, e, o = "no-parent") {
376
- const n = tt(t, e, o), i = tt(r, e, o), l = new Set(i);
377
- let c = null, h = -1;
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 (l.has(n[x])) {
380
- c = n[x], h = x;
380
+ if (h.has(n[x])) {
381
+ a = n[x], d = x;
381
382
  break;
382
383
  }
383
- if (!c)
384
+ if (!a)
384
385
  return { lca: null, sourceChild: null, targetChild: null };
385
- const a = i.indexOf(c), s = h > 0 ? n[h - 1] : t, d = a > 0 ? i[a - 1] : r;
386
- return { lca: c, sourceChild: s, targetChild: d };
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 se = (t) => JSON.parse(JSON.stringify(t)), Et = (t, r, e, o, n) => {
389
- const i = se(t);
390
- return i.source = r, i.target = e, i.id = o, i.data = {
391
- ...i.data,
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
- }, i;
394
- }, ce = (t) => {
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 i = `${n.source}->${n.target}`, l = e.get(i) || [];
399
- l.push(n), e.set(i, l);
399
+ const o = `${n.source}->${n.target}`, h = e.get(o) || [];
400
+ h.push(n), e.set(o, h);
400
401
  });
401
- const o = /* @__PURE__ */ new Set();
402
+ const s = /* @__PURE__ */ new Set();
402
403
  r.forEach((n) => {
403
- const i = `${n.source}->${n.target}`, l = `${n.target}->${n.source}`;
404
- if (o.has(i) || o.has(l))
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 c = e.get(l);
407
- if (!c || c.length === 0)
407
+ const a = e.get(h);
408
+ if (!a || a.length === 0)
408
409
  return;
409
- [...e.get(i) || [], ...c].forEach((a) => {
410
- a.data = {
411
- ...a.data,
410
+ [...e.get(o) || [], ...a].forEach((l) => {
411
+ l.data = {
412
+ ...l.data,
412
413
  isReciprocal: !0
413
414
  };
414
- }), o.add(i), o.add(l);
415
+ }), s.add(o), s.add(h);
415
416
  });
416
417
  }
417
- }, ae = (t, r, e, o) => {
418
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
419
- t.forEach((c) => {
420
- const h = n.get(c.target) || [];
421
- h.push(c), n.set(c.target, h);
422
- const a = i.get(c.source) || [];
423
- a.push(c), i.set(c.source, a);
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 l = /* @__PURE__ */ new Set();
426
- i.forEach((c, h) => {
427
- const a = n.get(h) || [];
428
- a.length !== 0 && a.forEach((s) => {
429
- c.forEach((d) => {
430
- if (s.source === d.target)
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: L } = F(
433
- s.source,
434
- d.target,
433
+ const { lca: x, sourceChild: N, targetChild: b } = V(
434
+ i.source,
435
+ c.target,
435
436
  r,
436
- o
437
- ), E = F(
438
- s.source,
439
- h,
437
+ s
438
+ ), C = V(
439
+ i.source,
440
+ d,
440
441
  r,
441
- o
442
- ).lca, f = F(
443
- h,
444
- d.target,
442
+ s
443
+ ).lca, p = V(
444
+ d,
445
+ c.target,
445
446
  r,
446
- o
447
+ s
447
448
  ).lca;
448
- if (!E || E !== f)
449
+ if (!C || C !== p)
449
450
  return;
450
- const p = z(
451
- s.source,
452
- E,
451
+ const f = z(
452
+ i.source,
453
+ C,
453
454
  r,
454
- o
455
+ s
455
456
  ), m = z(
456
- d.target,
457
- E,
457
+ c.target,
458
+ C,
458
459
  r,
459
- o
460
- ), w = z(
461
- h,
462
- E,
460
+ s
461
+ ), y = z(
462
+ d,
463
+ C,
463
464
  r,
464
- o
465
+ s
465
466
  );
466
- if (!p || !m || !w || p !== m || p === w)
467
+ if (!f || !m || !y || f !== m || f === y)
467
468
  return;
468
- const y = p, g = z(
469
- s.source,
470
- y,
469
+ const g = f, w = z(
470
+ i.source,
471
+ g,
471
472
  r,
472
- o
473
- ), C = z(
474
- d.target,
475
- y,
473
+ s
474
+ ), E = z(
475
+ c.target,
476
+ g,
476
477
  r,
477
- o
478
+ s
478
479
  );
479
- if (!x || !N || !L || !g || !C || g === C)
480
+ if (!x || !N || !b || !w || !E || w === E)
480
481
  return;
481
- const b = `synthetic_bridge_${s.id}_${h}_${d.id}_${y}`;
482
- if (l.has(b))
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
- s,
486
- g,
487
- C,
488
- b,
486
+ i,
487
+ w,
488
+ E,
489
+ L,
489
490
  {
490
491
  isTemporary: !0,
491
492
  isSyntheticBridge: !0,
492
- bridgeNode: h,
493
- bridgeBranch: w,
494
- anchorBranch: p,
495
- originalSource: s.source,
496
- originalTarget: d.target
493
+ bridgeNode: d,
494
+ bridgeBranch: y,
495
+ anchorBranch: f,
496
+ originalSource: i.source,
497
+ originalTarget: c.target
497
498
  }
498
499
  );
499
- e.has(y) || e.set(y, []), e.get(y).push(M), l.add(b);
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 o = /* @__PURE__ */ new Map();
506
+ const s = /* @__PURE__ */ new Map();
506
507
  for (const n of t) {
507
- const { lca: i, sourceChild: l, targetChild: c } = F(
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 (i && l && c && l !== c) {
514
- const h = Et(
514
+ if (o && h && a && h !== a) {
515
+ const d = Et(
515
516
  n,
516
- l,
517
- c,
518
- `temp_${n.id}_${i}`,
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
- o.has(i) || o.set(i, []), o.get(i).push(h);
526
+ s.has(o) || s.set(o, []), s.get(o).push(d);
526
527
  }
527
528
  }
528
- return ae(t, r, o, e), ce(o), o;
529
+ return ce(t, r, s, e), ie(s), s;
529
530
  }
530
- const rt = 10, gt = (t, r) => t.find((e) => e.id === r), yt = (t, r, e) => {
531
- var c, h;
532
- const o = e.get(t);
533
- if (!o)
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 = 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;
536
- for (; l && l !== r; ) {
537
- const a = e.get(l);
538
- if (!a)
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 += a.position.x, i += a.position.y, l = a.parentId;
541
+ n += l.position.x, o += l.position.y, h = l.parentId;
541
542
  }
542
- return { x: n, y: i };
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
- }, le = (t, r) => {
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, o = Number.POSITIVE_INFINITY, n = Number.NEGATIVE_INFINITY, i = Number.NEGATIVE_INFINITY;
559
- t.forEach((s) => {
560
- const { width: d, height: x } = $(s);
561
- e = Math.min(e, s.position.x), o = Math.min(o, s.position.y), n = Math.max(n, s.position.x + d), i = Math.max(i, s.position.y + x);
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 l = r - e, c = r - o;
564
- t.forEach((s) => {
565
- s.position = {
566
- x: s.position.x + l,
567
- y: s.position.y + c
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 h = n - e + r * 2, a = i - o + r * 2;
571
- return { nodes: t, width: h, height: a };
572
- }, he = (t, r, e, o) => {
573
- if (!(t.length < 2 || o.size === 0))
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((i, l) => i.position.x - l.position.x);
576
- n.forEach((i, l) => {
577
- if (!o.has(i.id))
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 c = i.position.x + $(i).width;
580
- for (let h = l + 1; h < n.length; h++) {
581
- const a = n[h], { width: s } = $(a), d = c + e;
582
- a.position.x < d && (a.position.x = d), c = a.position.x + s;
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((i, l) => i.position.y - l.position.y);
587
- n.forEach((i, l) => {
588
- if (!o.has(i.id))
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 c = i.position.y + $(i).height;
591
- for (let h = l + 1; h < n.length; h++) {
592
- const a = n[h], { height: s } = $(a), d = c + e;
593
- a.position.y < d && (a.position.y = d), c = a.position.y + s;
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
- }, de = (t, r, e, o) => {
598
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
599
- r.forEach((c) => {
600
- const h = n.get(c.target) || [];
601
- h.push(c), n.set(c.target, h);
602
- const a = i.get(c.source) || [];
603
- a.push(c), i.set(c.source, a);
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 l = /* @__PURE__ */ new Map();
606
- return i.forEach((c, h) => {
607
- const a = n.get(h) || [];
608
- a.length !== 0 && a.forEach((s) => {
609
- c.forEach((d) => {
610
- if (s.source === d.target)
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 = F(
613
- s.source,
614
- h,
613
+ const x = V(
614
+ i.source,
615
+ d,
615
616
  e,
616
- o
617
- ).lca, N = F(
618
- h,
619
- d.target,
617
+ s
618
+ ).lca, N = V(
619
+ d,
620
+ c.target,
620
621
  e,
621
- o
622
+ s
622
623
  ).lca;
623
624
  if (x !== t || N !== t)
624
625
  return;
625
- const L = z(
626
- s.source,
626
+ const b = z(
627
+ i.source,
627
628
  t,
628
629
  e,
629
- o
630
- ), E = z(
631
- d.target,
630
+ s
631
+ ), C = z(
632
+ c.target,
632
633
  t,
633
634
  e,
634
- o
635
- ), f = z(
636
- h,
635
+ s
636
+ ), p = z(
637
+ d,
637
638
  t,
638
639
  e,
639
- o
640
+ s
640
641
  );
641
- if (!L || !E || !f || L !== E || L === f)
642
+ if (!b || !C || !p || b !== C || b === p)
642
643
  return;
643
- const p = z(
644
- s.source,
645
- L,
644
+ const f = z(
645
+ i.source,
646
+ b,
646
647
  e,
647
- o
648
+ s
648
649
  ), m = z(
649
- d.target,
650
- L,
650
+ c.target,
651
+ b,
651
652
  e,
652
- o
653
+ s
653
654
  );
654
- if (!p || !m || p === m)
655
+ if (!f || !m || f === m)
655
656
  return;
656
- const w = `${L}:${f}:${p}:${m}`;
657
- l.set(w, {
658
- anchorContainerId: L,
659
- bridgeContainerId: f,
660
- sourceNodeId: p,
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
- }), [...l.values()];
666
- }, ue = (t, r, e, o, n, i, l) => {
667
- const c = de(r, n, i, l), h = /* @__PURE__ */ new Set();
668
- return c.forEach((a) => {
669
- const s = gt(t, a.anchorContainerId), d = gt(t, a.bridgeContainerId);
670
- if (!s || !d)
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(a.sourceNodeId, r, i), N = yt(a.targetNodeId, r, i);
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: L, height: E } = $(d), { width: f, height: p } = $(s), m = xt(s), w = xt(d);
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 y = (x.y + N.y) / 2;
678
- d.position.y = y - E / 2;
679
- const g = w.x >= m.x, C = g ? d.position.x - (s.position.x + f) : s.position.x - (d.position.x + L), b = Math.max(o, C);
680
- d.position.x = g ? s.position.x + f + b : s.position.x - L - b;
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 y = (x.x + N.x) / 2;
683
- d.position.x = y - L / 2;
684
- const g = w.y >= m.y, C = g ? d.position.y - (s.position.y + p) : s.position.y - (d.position.y + E), b = Math.max(o, C);
685
- d.position.y = g ? s.position.y + p + b : s.position.y - E - b;
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
- h.add(d.id);
688
- }), h;
689
- }, Nt = async (t, r, e, o, n, i = rt, l = 50, c = 50, h = 172, a = 36, s = X, d = !1, x = "no-parent") => {
690
- const N = et(n, o, x), { updatedNodes: L } = await j(
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
- o,
695
+ s,
695
696
  n,
696
- i,
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
- ), E = o.get(t);
706
- if (!E)
707
- return { updatedNodes: L, updatedEdges: n };
708
- const { updatedNodes: f } = await Nt(
709
- E.parentId || x,
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
- o,
713
+ s,
713
714
  n,
714
- i,
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: [...f, ...L],
725
+ updatedNodes: [...p, ...b],
725
726
  updatedEdges: n
726
727
  // Always return original edges unchanged
727
728
  };
728
- }, j = async (t, r, e, o, n, i = rt, l = 50, c = 50, h = 172, a = 36, s = X, d = !1, x = /* @__PURE__ */ new Map(), N = "no-parent") => {
729
- const L = e.get(t);
730
- if (!L || L.size === 0)
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 E = [];
733
- if (L.forEach((b) => {
734
- const M = o.get(b);
735
- M && E.push(M);
736
- }), E.length === 0)
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 f = r;
739
- const p = o.get(t);
740
- p && p.data.layoutDirection && (f = p.data.layoutDirection);
741
- const m = x.get(t) || [], { nodes: w, edges: y } = await s(
742
- E,
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
- f,
746
- i,
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
- w.forEach((b) => {
754
- o.set(b.id, b);
754
+ y.forEach((L) => {
755
+ s.set(L.id, L);
755
756
  });
756
- const g = ue(
757
- w,
757
+ const w = de(
758
+ y,
758
759
  t,
759
- f,
760
- l,
760
+ p,
761
+ h,
761
762
  n,
762
- o,
763
+ s,
763
764
  N
764
765
  );
765
- he(
766
- w,
767
- f,
768
- l,
769
- g
770
- ), w.forEach((b) => {
771
- o.set(b.id, b);
766
+ le(
767
+ y,
768
+ p,
769
+ h,
770
+ w
771
+ ), y.forEach((L) => {
772
+ s.set(L.id, L);
772
773
  });
773
- const C = le(w, i);
774
- return C.nodes.forEach((b) => {
775
- o.set(b.id, b);
776
- }), p && C.width && C.height && fe(p, C.width, C.height), {
777
- updatedNodes: [...C.nodes],
778
- udpatedParentNode: p || void 0
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
- }, fe = (t, r, e) => (t.style || (t.style = {}), t.width = r, t.height = e, t.measured = {
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), pe = async (t, r, e, o, n, i = rt, l = 50, c = 50, h = 172, a = 36, s = X, d = !1, x = "no-parent") => {
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 L = et(n, o, x), E = /* @__PURE__ */ new Map();
786
- let f = 0;
787
- const p = (w, y) => {
788
- y > f && (f = y);
789
- for (const g of w)
790
- E.has(y) || E.set(y, []), E.get(y).push(g.id), g.children.length > 0 && p(g.children, y + 1);
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
- p(t, 0);
793
- for (let w = f; w >= 0; w--) {
794
- const y = E.get(w) || [], g = await Promise.all(y.map(
795
- (C) => j(
796
- C,
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
- o,
800
+ s,
800
801
  n,
801
802
  // Pass original edges (only used for returning)
802
- i,
803
- l,
804
- c,
803
+ o,
805
804
  h,
806
805
  a,
807
- s,
808
806
  d,
809
- L,
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: C } of g)
815
- N = [...C, ...N];
815
+ for (const { updatedNodes: E } of w)
816
+ N = [...E, ...N];
816
817
  }
817
- const { updatedNodes: m } = await j(
818
+ const { updatedNodes: m } = await X(
818
819
  x,
819
820
  r,
820
821
  e,
821
- o,
822
+ s,
822
823
  n,
823
824
  // Pass original edges (only used for returning)
824
- i,
825
- l,
826
- c,
825
+ o,
827
826
  h,
828
827
  a,
829
- s,
830
828
  d,
831
- L,
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, o = "no-parent") => {
841
- const n = t.map((a) => a.id), i = t.map((a) => {
842
- var s;
843
- return ((s = e.get(a.id)) == null ? void 0 : s.parentId) || a.parentId;
844
- }).filter((a) => !!a), c = Array.from(
845
- /* @__PURE__ */ new Set([...n, ...i])
846
- ).filter((a) => r.has(a)), h = c.filter((a) => {
847
- const s = e.get(a);
848
- return s ? !s.parentId || !c.includes(s.parentId) : !0;
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 h.length === 0 ? [o] : h;
851
- }, ye = async (t, r, e) => {
851
+ return d.length === 0 ? [s] : d;
852
+ }, pe = async (t, r, e) => {
852
853
  const {
853
- dagreDirection: o,
854
+ dagreDirection: s,
854
855
  nodeParentIdMapWithChildIdSet: n,
855
- nodeIdWithNode: i,
856
- nodes: l,
857
- edges: c,
858
- margin: h,
859
- nodeSpacing: a,
860
- layerSpacing: s,
861
- nodeWidth: d,
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: L = "no-parent"
865
- } = r, E = ge(
865
+ noParentKey: b = "no-parent"
866
+ } = r, C = ge(
866
867
  t,
867
868
  n,
868
- i,
869
- L
869
+ o,
870
+ b
870
871
  );
871
- if (E.length === 0)
872
- return { nodes: l, edges: c };
873
- const f = /* @__PURE__ */ new Map(), p = /* @__PURE__ */ new Map();
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: l, edges: c };
876
+ return { nodes: h, edges: a };
876
877
  (await Promise.all(
877
- E.map(async (g) => e != null && e.aborted ? { updatedNodes: [], updatedEdges: [] } : Nt(
878
- g,
879
- o,
878
+ C.map(async (w) => e != null && e.aborted ? { updatedNodes: [], updatedEdges: [] } : Nt(
879
+ w,
880
+ s,
880
881
  n,
881
- i,
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: g, updatedEdges: C }) => {
892
- g.forEach((b) => {
893
- f.set(b.id, b);
894
- }), C.forEach((b) => {
895
- p.set(b.id, b);
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 w = l.map(
899
- (g) => f.has(g.id) ? f.get(g.id) : g
900
- ), y = c.map(
901
- (g) => p.has(g.id) ? p.get(g.id) : g
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: w, edges: y };
904
- }, xe = (t, r, e, o, n, i, l, c, h = 172, a = 36, s = !1, d = "no-parent") => {
905
- const x = U(async (L, E, f, p) => {
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: L, edges: E };
908
- const w = s ? L : L.filter((k) => !k.hidden), y = new Set(w.map((k) => k.id)), g = s ? E : E.filter(
909
- (k) => y.has(k.source) && y.has(k.target)
910
- ), C = ft(r), b = o.padding.horizontal;
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 (f && f.length > 0) {
913
- const k = s ? f : f.filter((S) => !S.hidden), v = await ye(
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: C,
917
+ dagreDirection: E,
917
918
  nodeParentIdMapWithChildIdSet: n,
918
- nodeIdWithNode: i,
919
- nodes: w,
920
- edges: g,
921
- margin: b,
922
- nodeSpacing: l,
923
- layerSpacing: c,
924
- nodeWidth: h,
925
- nodeHeight: a,
926
- layoutHidden: s,
927
- noParentKey: d
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
- p
930
+ f
930
931
  );
931
932
  M = v.nodes, G = v.edges;
932
933
  } else {
933
- if (p != null && p.aborted)
934
- return { nodes: L, edges: E };
935
- const k = ie(n, i, d), v = await pe(
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
- C,
938
+ E,
938
939
  n,
939
- i,
940
- g,
941
- b,
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
- s,
948
- d
948
+ i,
949
+ c
949
950
  );
950
951
  M = v.updatedNodes, G = v.updatedEdges;
951
952
  }
952
953
  return {
953
- nodes: L.map((k) => !s && k.hidden ? k : M.find((S) => S.id === k.id) || k),
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
- o.padding.horizontal,
961
+ s.padding.horizontal,
961
962
  n,
962
- i,
963
- l,
964
- c,
963
+ o,
965
964
  h,
966
965
  a,
967
- s,
968
- d
969
- ]), N = U(async (L, E, f, p) => {
970
- if (p != null && p.aborted) return { nodes: E, edges: f };
971
- const m = ft(r), w = o.padding.horizontal, y = s ? E : E.filter((v) => !v.hidden), g = new Set(y.map((v) => v.id)), C = s ? f : f.filter((v) => g.has(v.source) && g.has(v.target)), b = et(C, i, d), M = (v) => {
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(L), O = /* @__PURE__ */ new Map();
978
+ }, G = M(b), O = /* @__PURE__ */ new Map();
978
979
  for (const v of G) {
979
- if (p != null && p.aborted) return { nodes: E, edges: f };
980
- const { updatedNodes: S, udpatedParentNode: R } = await j(
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
- i,
985
- C,
986
- w,
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
- s,
993
- b,
994
- d
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: E.map((v) => O.get(v.id) ?? v), edges: f };
999
+ return { nodes: C.map((v) => O.get(v.id) ?? v), edges: p };
999
1000
  }, [
1000
1001
  r,
1001
- o.padding.horizontal,
1002
+ s.padding.horizontal,
1002
1003
  n,
1003
- i,
1004
- l,
1005
- c,
1004
+ o,
1006
1005
  h,
1007
1006
  a,
1008
- s,
1009
- d
1007
+ d,
1008
+ l,
1009
+ i,
1010
+ c
1010
1011
  ]);
1011
1012
  return { calculateLayout: x, calculateContainerLayout: N };
1012
1013
  };
1013
- function Le({
1014
+ function Ce({
1014
1015
  children: t,
1015
1016
  initialDirection: r = "DOWN",
1016
1017
  initialAlgorithm: e = "layered",
1017
- initialAutoLayout: o = !0,
1018
+ initialAutoLayout: s = !0,
1018
1019
  initialPadding: n = 50,
1019
- initialSpacing: i = { node: 50, layer: 50 },
1020
- initialNodeDimensions: l = { width: 172, height: 36 },
1021
- initialParentResizingOptions: c,
1022
- includeHidden: h = !1,
1023
- layoutEngines: a,
1024
- updateNodes: s,
1025
- updateEdges: d,
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: L = "no-parent",
1029
- disableAutoLayoutEffect: E = !1
1029
+ noParentKey: b = "no-parent",
1030
+ disableAutoLayoutEffect: C = !1
1030
1031
  }) {
1031
- const f = Yt(), p = Pt(), {
1032
+ const p = Ft(), f = Pt(), {
1032
1033
  direction: m,
1033
- algorithm: w,
1034
- autoLayout: y,
1035
- layoutInProgress: g,
1036
- layoutHidden: C,
1037
- layoutEngines: b,
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: J,
1047
- setAlgorithm: Z,
1048
- setAutoLayout: q,
1049
- setLayoutInProgress: Y,
1050
- setLayoutHidden: Q,
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: ot,
1055
- setLayerSpacing: it,
1055
+ setNodeSpacing: st,
1056
+ setLayerSpacing: ot,
1056
1057
  setNodeWidth: kt,
1057
1058
  setNodeHeight: Bt,
1058
- setParentResizingOptionsState: st,
1059
+ setParentResizingOptionsState: it,
1059
1060
  setSelectedNodes: ct
1060
- } = re({
1061
+ } = ee({
1061
1062
  initialDirection: r,
1062
1063
  initialAlgorithm: e,
1063
- initialAutoLayout: o,
1064
+ initialAutoLayout: s,
1064
1065
  initialPadding: n,
1065
- initialSpacing: i,
1066
- initialNodeDimensions: l,
1067
- initialParentResizingOptions: c,
1068
- includeHidden: h,
1069
- layoutEngines: a
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
- nodesInitialized: Dt,
1077
- parentChildStructure: Rt
1078
- } = ne({
1079
- nodes: f,
1077
+ parentChildStructure: Dt
1078
+ } = re({
1079
+ nodes: p,
1080
1080
  externalNodeIdWithNode: N,
1081
1081
  externalNodeParentIdMapWithChildIdSet: x,
1082
- noParentKey: L
1083
- }), Ot = U(({ nodes: H }) => {
1082
+ noParentKey: b
1083
+ }), Rt = U(({ nodes: H }) => {
1084
1084
  ct(H);
1085
1085
  }, [ct]);
1086
1086
  jt({
1087
- onChange: Ot
1087
+ onChange: Rt
1088
1088
  });
1089
- const { calculateLayout: At, calculateContainerLayout: zt } = xe(
1090
- b,
1089
+ const { calculateLayout: Ot, calculateContainerLayout: At } = ye(
1090
+ L,
1091
1091
  m,
1092
- w,
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
- C,
1101
- L
1102
- ), { applyLayout: ht, applyContainerLayout: Gt } = oe({
1103
- nodes: f,
1104
- edges: p,
1100
+ E,
1101
+ b
1102
+ ), { applyLayout: ht, applyContainerLayout: zt } = ne({
1103
+ nodes: p,
1104
+ edges: f,
1105
1105
  selectedNodes: _,
1106
- layoutHidden: C,
1107
- calculateLayout: At,
1108
- calculateContainerLayout: zt,
1109
- updateNodes: s,
1110
- updateEdges: d,
1111
- setLayoutInProgress: Y,
1112
- setNodeSpacing: ot,
1113
- setLayerSpacing: it
1114
- }), _t = U((H, K) => {
1115
- nt((Ut) => ({ ...Ut, [H]: K }));
1116
- }, [nt]), Ht = U((H) => {
1117
- st((K) => ({
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: y
1120
+ enabled: g
1121
1121
  }));
1122
- }, [y, st]);
1123
- V(() => {
1122
+ }, [g, it]);
1123
+ Y(() => {
1124
1124
  var H;
1125
- E || W.has((H = f[f.length - 1]) == null ? void 0 : H.id) && lt && y && ht();
1126
- }, [lt, y, m, Mt, O, k, Rt, St]);
1127
- const $t = {
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: w,
1130
- autoLayout: y,
1131
- layoutInProgress: g,
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: C,
1137
+ layoutHidden: E,
1139
1138
  parentResizingOptions: R,
1140
- layoutEngines: b,
1139
+ layoutEngines: L,
1141
1140
  layoutEngineOptions: M,
1142
1141
  nodeParentIdMapWithChildIdSet: at,
1143
1142
  nodeIdWithNode: W,
1144
- noParentKey: L,
1145
- updateNodes: s,
1146
- updateEdges: d,
1147
- setDirection: J,
1148
- setAlgorithm: Z,
1149
- setAutoLayout: q,
1150
- setLayoutInProgress: Y,
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: ot,
1153
- setLayerSpacing: it,
1151
+ setNodeSpacing: st,
1152
+ setLayerSpacing: ot,
1154
1153
  setNodeWidth: kt,
1155
1154
  setNodeHeight: Bt,
1156
- setLayoutHidden: Q,
1157
- setParentResizingOptions: Ht,
1155
+ setLayoutHidden: I,
1156
+ setParentResizingOptions: _t,
1158
1157
  setLayoutEngineOptions: vt,
1159
1158
  applyLayout: ht,
1160
- applyContainerLayout: Gt,
1159
+ applyContainerLayout: zt,
1161
1160
  clearLayoutCache: () => {
1162
1161
  },
1163
- registerLayoutEngine: _t
1162
+ registerLayoutEngine: Gt
1164
1163
  };
1165
- return /* @__PURE__ */ u(Lt.Provider, { value: $t, children: t });
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: o
1174
- } = I(), n = (i) => {
1175
- e(i), o && o();
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(P, { children: [
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: o,
1233
+ setNodeSpacing: s,
1235
1234
  setLayerSpacing: n,
1236
- clearLayoutCache: i
1237
- } = I(), [l, c] = B(!1), h = (s) => {
1238
- o(s), i && i();
1239
- }, a = (s) => {
1240
- n(s), i && i();
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: () => c(!l),
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
- l && /* @__PURE__ */ T(
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((s) => /* @__PURE__ */ u(
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: () => h(s),
1283
+ onClick: () => d(i),
1285
1284
  style: {
1286
- background: r === s ? "#0041d0" : "#f5f5f5",
1287
- color: r === s ? "white" : "inherit",
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: s
1292
+ children: i
1294
1293
  },
1295
- s
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((s) => /* @__PURE__ */ u(
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: () => a(s),
1306
+ onClick: () => l(i),
1308
1307
  style: {
1309
- background: e === s ? "#0041d0" : "#f5f5f5",
1310
- color: e === s ? "white" : "inherit",
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: s
1315
+ children: i
1317
1316
  },
1318
- s
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: () => c(!1),
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: () => h(Math.max(50, r - 25)),
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: () => h(Math.min(300, r + 25)),
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: () => a(Math.max(50, e - 25)),
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: () => a(Math.min(300, e + 25)),
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
- } = I();
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(P, { children: [
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(P, { children: [
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: o
1474
- } = I();
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 o();
1482
- } catch (i) {
1483
- console.error("Error applying layout:", i);
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
- }, Ee = ({
1502
+ }, Le = ({
1504
1503
  showDirectionControls: t = !0,
1505
1504
  showSpacingControls: r = !0,
1506
1505
  showAutoLayoutToggle: e = !0,
1507
- showApplyLayoutButton: o = !0,
1506
+ showApplyLayoutButton: s = !0,
1508
1507
  // Enable by default
1509
1508
  standalone: n = !1,
1510
- position: i = "top-right"
1509
+ position: o = "top-right"
1511
1510
  }) => {
1512
- const l = I(), {
1513
- autoLayout: c
1514
- } = l;
1515
- return n ? /* @__PURE__ */ T(Xt, { position: i, showZoom: !1, showFitView: !1, showInteractive: !1, children: [
1516
- o && !c && /* @__PURE__ */ u(
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(P, { children: [
1541
- o && !c && /* @__PURE__ */ u(
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
- te as DagreEngine,
1568
+ Kt as DagreEngine,
1570
1569
  wt as DirectionControls,
1571
- Ee as LayoutControls,
1572
- Le as LayoutProvider,
1570
+ Le as LayoutControls,
1571
+ Ce as LayoutProvider,
1573
1572
  mt as SpacingControls,
1574
- ee as engines,
1575
- I as useLayoutContext
1573
+ te as engines,
1574
+ F as useLayoutContext
1576
1575
  };