@graph-render/react 1.0.1

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.
Files changed (52) hide show
  1. package/.eslintrc.json +6 -0
  2. package/CHANGELOG.md +58 -0
  3. package/README.md +0 -0
  4. package/dist/index.js +2509 -0
  5. package/dist/src/components/EdgePath.d.ts +25 -0
  6. package/dist/src/components/EdgePath.d.ts.map +1 -0
  7. package/dist/src/components/Graph.d.ts +6 -0
  8. package/dist/src/components/Graph.d.ts.map +1 -0
  9. package/dist/src/components/GraphLabels.d.ts +30 -0
  10. package/dist/src/components/GraphLabels.d.ts.map +1 -0
  11. package/dist/src/components/GraphNode.d.ts +35 -0
  12. package/dist/src/components/GraphNode.d.ts.map +1 -0
  13. package/dist/src/constants/defaults.d.ts +3 -0
  14. package/dist/src/constants/defaults.d.ts.map +1 -0
  15. package/dist/src/hooks/useGraphCollapse.d.ts +15 -0
  16. package/dist/src/hooks/useGraphCollapse.d.ts.map +1 -0
  17. package/dist/src/hooks/useGraphHover.d.ts +24 -0
  18. package/dist/src/hooks/useGraphHover.d.ts.map +1 -0
  19. package/dist/src/hooks/useGraphModel.d.ts +51 -0
  20. package/dist/src/hooks/useGraphModel.d.ts.map +1 -0
  21. package/dist/src/hooks/useGraphSearchState.d.ts +29 -0
  22. package/dist/src/hooks/useGraphSearchState.d.ts.map +1 -0
  23. package/dist/src/hooks/useStableConfig.d.ts +25 -0
  24. package/dist/src/hooks/useStableConfig.d.ts.map +1 -0
  25. package/dist/src/index.d.ts +7 -0
  26. package/dist/src/index.d.ts.map +1 -0
  27. package/dist/src/utils/columns.d.ts +7 -0
  28. package/dist/src/utils/columns.d.ts.map +1 -0
  29. package/dist/src/utils/pathHighlight.d.ts +29 -0
  30. package/dist/src/utils/pathHighlight.d.ts.map +1 -0
  31. package/dist/src/utils/viewport.d.ts +14 -0
  32. package/dist/src/utils/viewport.d.ts.map +1 -0
  33. package/dist/tsconfig.tsbuildinfo +1 -0
  34. package/package.json +52 -0
  35. package/project.json +60 -0
  36. package/src/components/EdgePath.tsx +103 -0
  37. package/src/components/Graph.tsx +1545 -0
  38. package/src/components/GraphLabels.tsx +141 -0
  39. package/src/components/GraphNode.tsx +214 -0
  40. package/src/constants/defaults.ts +62 -0
  41. package/src/hooks/useGraphCollapse.ts +53 -0
  42. package/src/hooks/useGraphHover.ts +206 -0
  43. package/src/hooks/useGraphModel.ts +445 -0
  44. package/src/hooks/useGraphSearchState.ts +215 -0
  45. package/src/hooks/useStableConfig.ts +108 -0
  46. package/src/index.ts +57 -0
  47. package/src/utils/columns.ts +51 -0
  48. package/src/utils/pathHighlight.ts +160 -0
  49. package/src/utils/viewport.ts +100 -0
  50. package/tsconfig.json +12 -0
  51. package/tsconfig.node.json +11 -0
  52. package/vite.config.ts +17 -0
package/dist/index.js ADDED
@@ -0,0 +1,2509 @@
1
+ import { LayoutType as Me, EdgeType as vr, LayoutDirection as tr } from "@graph-render/types";
2
+ import { EdgeType as ei, LayoutDirection as ri, LayoutType as ni, NodeSide as ii } from "@graph-render/types";
3
+ import re, { useState as Et, useMemo as k, useCallback as K, useRef as pt, useEffect as te, useLayoutEffect as an, useId as cn, useImperativeHandle as un } from "react";
4
+ import { groupEdgesByTarget as ln, sortEdgesBySourcePosition as fn, fromTypedNxGraph as dn, layoutNodes as er, routeEdges as xr, buildEdgePath as hn, normalizeGraphConfig as pn, DEFAULT_THEME as wr } from "@graph-render/core";
5
+ import { buildEdgePath as si, fromNxGraph as ai, layoutNodes as ci, renderGraphToSvg as ui, routeEdges as li } from "@graph-render/core";
6
+ var rr = { exports: {} }, fe = {};
7
+ /**
8
+ * @license React
9
+ * react-jsx-runtime.production.min.js
10
+ *
11
+ * Copyright (c) Facebook, Inc. and its affiliates.
12
+ *
13
+ * This source code is licensed under the MIT license found in the
14
+ * LICENSE file in the root directory of this source tree.
15
+ */
16
+ var br;
17
+ function mn() {
18
+ if (br) return fe;
19
+ br = 1;
20
+ var e = re, r = Symbol.for("react.element"), s = Symbol.for("react.fragment"), i = Object.prototype.hasOwnProperty, o = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, c = { key: !0, ref: !0, __self: !0, __source: !0 };
21
+ function h(u, w, T) {
22
+ var v, m = {}, g = null, I = null;
23
+ T !== void 0 && (g = "" + T), w.key !== void 0 && (g = "" + w.key), w.ref !== void 0 && (I = w.ref);
24
+ for (v in w) i.call(w, v) && !c.hasOwnProperty(v) && (m[v] = w[v]);
25
+ if (u && u.defaultProps) for (v in w = u.defaultProps, w) m[v] === void 0 && (m[v] = w[v]);
26
+ return { $$typeof: r, type: u, key: g, ref: I, props: m, _owner: o.current };
27
+ }
28
+ return fe.Fragment = s, fe.jsx = h, fe.jsxs = h, fe;
29
+ }
30
+ var de = {};
31
+ /**
32
+ * @license React
33
+ * react-jsx-runtime.development.js
34
+ *
35
+ * Copyright (c) Facebook, Inc. and its affiliates.
36
+ *
37
+ * This source code is licensed under the MIT license found in the
38
+ * LICENSE file in the root directory of this source tree.
39
+ */
40
+ var Ir;
41
+ function yn() {
42
+ return Ir || (Ir = 1, process.env.NODE_ENV !== "production" && function() {
43
+ var e = re, r = Symbol.for("react.element"), s = Symbol.for("react.portal"), i = Symbol.for("react.fragment"), o = Symbol.for("react.strict_mode"), c = Symbol.for("react.profiler"), h = Symbol.for("react.provider"), u = Symbol.for("react.context"), w = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), m = Symbol.for("react.memo"), g = Symbol.for("react.lazy"), I = Symbol.for("react.offscreen"), l = Symbol.iterator, L = "@@iterator";
44
+ function X(t) {
45
+ if (t === null || typeof t != "object")
46
+ return null;
47
+ var a = l && t[l] || t[L];
48
+ return typeof a == "function" ? a : null;
49
+ }
50
+ var y = e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
51
+ function E(t) {
52
+ {
53
+ for (var a = arguments.length, f = new Array(a > 1 ? a - 1 : 0), R = 1; R < a; R++)
54
+ f[R - 1] = arguments[R];
55
+ _("error", t, f);
56
+ }
57
+ }
58
+ function _(t, a, f) {
59
+ {
60
+ var R = y.ReactDebugCurrentFrame, M = R.getStackAddendum();
61
+ M !== "" && (a += "%s", f = f.concat([M]));
62
+ var W = f.map(function(z) {
63
+ return String(z);
64
+ });
65
+ W.unshift("Warning: " + a), Function.prototype.apply.call(console[t], console, W);
66
+ }
67
+ }
68
+ var x = !1, G = !1, ut = !1, rt = !1, S = !1, D;
69
+ D = Symbol.for("react.module.reference");
70
+ function H(t) {
71
+ return !!(typeof t == "string" || typeof t == "function" || t === i || t === c || S || t === o || t === T || t === v || rt || t === I || x || G || ut || typeof t == "object" && t !== null && (t.$$typeof === g || t.$$typeof === m || t.$$typeof === h || t.$$typeof === u || t.$$typeof === w || // This needs to include all possible module reference object
72
+ // types supported by any Flight configuration anywhere since
73
+ // we don't know which Flight build this will end up being used
74
+ // with.
75
+ t.$$typeof === D || t.getModuleId !== void 0));
76
+ }
77
+ function it(t, a, f) {
78
+ var R = t.displayName;
79
+ if (R)
80
+ return R;
81
+ var M = a.displayName || a.name || "";
82
+ return M !== "" ? f + "(" + M + ")" : f;
83
+ }
84
+ function q(t) {
85
+ return t.displayName || "Context";
86
+ }
87
+ function V(t) {
88
+ if (t == null)
89
+ return null;
90
+ if (typeof t.tag == "number" && E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
91
+ return t.displayName || t.name || null;
92
+ if (typeof t == "string")
93
+ return t;
94
+ switch (t) {
95
+ case i:
96
+ return "Fragment";
97
+ case s:
98
+ return "Portal";
99
+ case c:
100
+ return "Profiler";
101
+ case o:
102
+ return "StrictMode";
103
+ case T:
104
+ return "Suspense";
105
+ case v:
106
+ return "SuspenseList";
107
+ }
108
+ if (typeof t == "object")
109
+ switch (t.$$typeof) {
110
+ case u:
111
+ var a = t;
112
+ return q(a) + ".Consumer";
113
+ case h:
114
+ var f = t;
115
+ return q(f._context) + ".Provider";
116
+ case w:
117
+ return it(t, t.render, "ForwardRef");
118
+ case m:
119
+ var R = t.displayName || null;
120
+ return R !== null ? R : V(t.type) || "Memo";
121
+ case g: {
122
+ var M = t, W = M._payload, z = M._init;
123
+ try {
124
+ return V(z(W));
125
+ } catch {
126
+ return null;
127
+ }
128
+ }
129
+ }
130
+ return null;
131
+ }
132
+ var at = Object.assign, O = 0, A, Y, J, dt, jt, vt, _t;
133
+ function Ft() {
134
+ }
135
+ Ft.__reactDisabledLog = !0;
136
+ function Kt() {
137
+ {
138
+ if (O === 0) {
139
+ A = console.log, Y = console.info, J = console.warn, dt = console.error, jt = console.group, vt = console.groupCollapsed, _t = console.groupEnd;
140
+ var t = {
141
+ configurable: !0,
142
+ enumerable: !0,
143
+ value: Ft,
144
+ writable: !0
145
+ };
146
+ Object.defineProperties(console, {
147
+ info: t,
148
+ log: t,
149
+ warn: t,
150
+ error: t,
151
+ group: t,
152
+ groupCollapsed: t,
153
+ groupEnd: t
154
+ });
155
+ }
156
+ O++;
157
+ }
158
+ }
159
+ function ot() {
160
+ {
161
+ if (O--, O === 0) {
162
+ var t = {
163
+ configurable: !0,
164
+ enumerable: !0,
165
+ writable: !0
166
+ };
167
+ Object.defineProperties(console, {
168
+ log: at({}, t, {
169
+ value: A
170
+ }),
171
+ info: at({}, t, {
172
+ value: Y
173
+ }),
174
+ warn: at({}, t, {
175
+ value: J
176
+ }),
177
+ error: at({}, t, {
178
+ value: dt
179
+ }),
180
+ group: at({}, t, {
181
+ value: jt
182
+ }),
183
+ groupCollapsed: at({}, t, {
184
+ value: vt
185
+ }),
186
+ groupEnd: at({}, t, {
187
+ value: _t
188
+ })
189
+ });
190
+ }
191
+ O < 0 && E("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
192
+ }
193
+ }
194
+ var Q = y.ReactCurrentDispatcher, Lt;
195
+ function Tt(t, a, f) {
196
+ {
197
+ if (Lt === void 0)
198
+ try {
199
+ throw Error();
200
+ } catch (M) {
201
+ var R = M.stack.trim().match(/\n( *(at )?)/);
202
+ Lt = R && R[1] || "";
203
+ }
204
+ return `
205
+ ` + Lt + t;
206
+ }
207
+ }
208
+ var mt = !1, Gt;
209
+ {
210
+ var De = typeof WeakMap == "function" ? WeakMap : Map;
211
+ Gt = new De();
212
+ }
213
+ function me(t, a) {
214
+ if (!t || mt)
215
+ return "";
216
+ {
217
+ var f = Gt.get(t);
218
+ if (f !== void 0)
219
+ return f;
220
+ }
221
+ var R;
222
+ mt = !0;
223
+ var M = Error.prepareStackTrace;
224
+ Error.prepareStackTrace = void 0;
225
+ var W;
226
+ W = Q.current, Q.current = null, Kt();
227
+ try {
228
+ if (a) {
229
+ var z = function() {
230
+ throw Error();
231
+ };
232
+ if (Object.defineProperty(z.prototype, "props", {
233
+ set: function() {
234
+ throw Error();
235
+ }
236
+ }), typeof Reflect == "object" && Reflect.construct) {
237
+ try {
238
+ Reflect.construct(z, []);
239
+ } catch (C) {
240
+ R = C;
241
+ }
242
+ Reflect.construct(t, [], z);
243
+ } else {
244
+ try {
245
+ z.call();
246
+ } catch (C) {
247
+ R = C;
248
+ }
249
+ t.call(z.prototype);
250
+ }
251
+ } else {
252
+ try {
253
+ throw Error();
254
+ } catch (C) {
255
+ R = C;
256
+ }
257
+ t();
258
+ }
259
+ } catch (C) {
260
+ if (C && R && typeof C.stack == "string") {
261
+ for (var j = C.stack.split(`
262
+ `), nt = R.stack.split(`
263
+ `), B = j.length - 1, Z = nt.length - 1; B >= 1 && Z >= 0 && j[B] !== nt[Z]; )
264
+ Z--;
265
+ for (; B >= 1 && Z >= 0; B--, Z--)
266
+ if (j[B] !== nt[Z]) {
267
+ if (B !== 1 || Z !== 1)
268
+ do
269
+ if (B--, Z--, Z < 0 || j[B] !== nt[Z]) {
270
+ var ft = `
271
+ ` + j[B].replace(" at new ", " at ");
272
+ return t.displayName && ft.includes("<anonymous>") && (ft = ft.replace("<anonymous>", t.displayName)), typeof t == "function" && Gt.set(t, ft), ft;
273
+ }
274
+ while (B >= 1 && Z >= 0);
275
+ break;
276
+ }
277
+ }
278
+ } finally {
279
+ mt = !1, Q.current = W, ot(), Error.prepareStackTrace = M;
280
+ }
281
+ var $ = t ? t.displayName || t.name : "", tt = $ ? Tt($) : "";
282
+ return typeof t == "function" && Gt.set(t, tt), tt;
283
+ }
284
+ function ne(t, a, f) {
285
+ return me(t, !1);
286
+ }
287
+ function ie(t) {
288
+ var a = t.prototype;
289
+ return !!(a && a.isReactComponent);
290
+ }
291
+ function ct(t, a, f) {
292
+ if (t == null)
293
+ return "";
294
+ if (typeof t == "function")
295
+ return me(t, ie(t));
296
+ if (typeof t == "string")
297
+ return Tt(t);
298
+ switch (t) {
299
+ case T:
300
+ return Tt("Suspense");
301
+ case v:
302
+ return Tt("SuspenseList");
303
+ }
304
+ if (typeof t == "object")
305
+ switch (t.$$typeof) {
306
+ case w:
307
+ return ne(t.render);
308
+ case m:
309
+ return ct(t.type, a, f);
310
+ case g: {
311
+ var R = t, M = R._payload, W = R._init;
312
+ try {
313
+ return ct(W(M), a, f);
314
+ } catch {
315
+ }
316
+ }
317
+ }
318
+ return "";
319
+ }
320
+ var Pt = Object.prototype.hasOwnProperty, Yt = {}, Rt = y.ReactDebugCurrentFrame;
321
+ function yt(t) {
322
+ if (t) {
323
+ var a = t._owner, f = ct(t.type, t._source, a ? a.type : null);
324
+ Rt.setExtraStackFrame(f);
325
+ } else
326
+ Rt.setExtraStackFrame(null);
327
+ }
328
+ function ze(t, a, f, R, M) {
329
+ {
330
+ var W = Function.call.bind(Pt);
331
+ for (var z in t)
332
+ if (W(t, z)) {
333
+ var j = void 0;
334
+ try {
335
+ if (typeof t[z] != "function") {
336
+ var nt = Error((R || "React class") + ": " + f + " type `" + z + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[z] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
337
+ throw nt.name = "Invariant Violation", nt;
338
+ }
339
+ j = t[z](a, z, R, f, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
340
+ } catch (B) {
341
+ j = B;
342
+ }
343
+ j && !(j instanceof Error) && (yt(M), E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", R || "React class", f, z, typeof j), yt(null)), j instanceof Error && !(j.message in Yt) && (Yt[j.message] = !0, yt(M), E("Failed %s type: %s", f, j.message), yt(null));
344
+ }
345
+ }
346
+ }
347
+ var ye = Array.isArray;
348
+ function lt(t) {
349
+ return ye(t);
350
+ }
351
+ function ht(t) {
352
+ {
353
+ var a = typeof Symbol == "function" && Symbol.toStringTag, f = a && t[Symbol.toStringTag] || t.constructor.name || "Object";
354
+ return f;
355
+ }
356
+ }
357
+ function ge(t) {
358
+ try {
359
+ return Wt(t), !1;
360
+ } catch {
361
+ return !0;
362
+ }
363
+ }
364
+ function Wt(t) {
365
+ return "" + t;
366
+ }
367
+ function oe(t) {
368
+ if (ge(t))
369
+ return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", ht(t)), Wt(t);
370
+ }
371
+ var ve = y.ReactCurrentOwner, se = {
372
+ key: !0,
373
+ ref: !0,
374
+ __self: !0,
375
+ __source: !0
376
+ }, xe, we;
377
+ function Ne(t) {
378
+ if (Pt.call(t, "ref")) {
379
+ var a = Object.getOwnPropertyDescriptor(t, "ref").get;
380
+ if (a && a.isReactWarning)
381
+ return !1;
382
+ }
383
+ return t.ref !== void 0;
384
+ }
385
+ function kt(t) {
386
+ if (Pt.call(t, "key")) {
387
+ var a = Object.getOwnPropertyDescriptor(t, "key").get;
388
+ if (a && a.isReactWarning)
389
+ return !1;
390
+ }
391
+ return t.key !== void 0;
392
+ }
393
+ function ae(t, a) {
394
+ typeof t.ref == "string" && ve.current;
395
+ }
396
+ function be(t, a) {
397
+ {
398
+ var f = function() {
399
+ xe || (xe = !0, E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
400
+ };
401
+ f.isReactWarning = !0, Object.defineProperty(t, "key", {
402
+ get: f,
403
+ configurable: !0
404
+ });
405
+ }
406
+ }
407
+ function Ie(t, a) {
408
+ {
409
+ var f = function() {
410
+ we || (we = !0, E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", a));
411
+ };
412
+ f.isReactWarning = !0, Object.defineProperty(t, "ref", {
413
+ get: f,
414
+ configurable: !0
415
+ });
416
+ }
417
+ }
418
+ var xt = function(t, a, f, R, M, W, z) {
419
+ var j = {
420
+ // This tag allows us to uniquely identify this as a React Element
421
+ $$typeof: r,
422
+ // Built-in properties that belong on the element
423
+ type: t,
424
+ key: a,
425
+ ref: f,
426
+ props: z,
427
+ // Record the component responsible for creating this element.
428
+ _owner: W
429
+ };
430
+ return j._store = {}, Object.defineProperty(j._store, "validated", {
431
+ configurable: !1,
432
+ enumerable: !1,
433
+ writable: !0,
434
+ value: !1
435
+ }), Object.defineProperty(j, "_self", {
436
+ configurable: !1,
437
+ enumerable: !1,
438
+ writable: !1,
439
+ value: R
440
+ }), Object.defineProperty(j, "_source", {
441
+ configurable: !1,
442
+ enumerable: !1,
443
+ writable: !1,
444
+ value: M
445
+ }), Object.freeze && (Object.freeze(j.props), Object.freeze(j)), j;
446
+ };
447
+ function wt(t, a, f, R, M) {
448
+ {
449
+ var W, z = {}, j = null, nt = null;
450
+ f !== void 0 && (oe(f), j = "" + f), kt(a) && (oe(a.key), j = "" + a.key), Ne(a) && (nt = a.ref, ae(a, M));
451
+ for (W in a)
452
+ Pt.call(a, W) && !se.hasOwnProperty(W) && (z[W] = a[W]);
453
+ if (t && t.defaultProps) {
454
+ var B = t.defaultProps;
455
+ for (W in B)
456
+ z[W] === void 0 && (z[W] = B[W]);
457
+ }
458
+ if (j || nt) {
459
+ var Z = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
460
+ j && be(z, Z), nt && Ie(z, Z);
461
+ }
462
+ return xt(t, j, nt, M, R, ve.current, z);
463
+ }
464
+ }
465
+ var bt = y.ReactCurrentOwner, Ot = y.ReactDebugCurrentFrame;
466
+ function Dt(t) {
467
+ if (t) {
468
+ var a = t._owner, f = ct(t.type, t._source, a ? a.type : null);
469
+ Ot.setExtraStackFrame(f);
470
+ } else
471
+ Ot.setExtraStackFrame(null);
472
+ }
473
+ var $t;
474
+ $t = !1;
475
+ function b(t) {
476
+ return typeof t == "object" && t !== null && t.$$typeof === r;
477
+ }
478
+ function gt() {
479
+ {
480
+ if (bt.current) {
481
+ var t = V(bt.current.type);
482
+ if (t)
483
+ return `
484
+
485
+ Check the render method of \`` + t + "`.";
486
+ }
487
+ return "";
488
+ }
489
+ }
490
+ function Ee(t) {
491
+ return "";
492
+ }
493
+ var Xt = {};
494
+ function _e(t) {
495
+ {
496
+ var a = gt();
497
+ if (!a) {
498
+ var f = typeof t == "string" ? t : t.displayName || t.name;
499
+ f && (a = `
500
+
501
+ Check the top-level render call using <` + f + ">.");
502
+ }
503
+ return a;
504
+ }
505
+ }
506
+ function Te(t, a) {
507
+ {
508
+ if (!t._store || t._store.validated || t.key != null)
509
+ return;
510
+ t._store.validated = !0;
511
+ var f = _e(a);
512
+ if (Xt[f])
513
+ return;
514
+ Xt[f] = !0;
515
+ var R = "";
516
+ t && t._owner && t._owner !== bt.current && (R = " It was passed a child from " + V(t._owner.type) + "."), Dt(t), E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', f, R), Dt(null);
517
+ }
518
+ }
519
+ function Pe(t, a) {
520
+ {
521
+ if (typeof t != "object")
522
+ return;
523
+ if (lt(t))
524
+ for (var f = 0; f < t.length; f++) {
525
+ var R = t[f];
526
+ b(R) && Te(R, a);
527
+ }
528
+ else if (b(t))
529
+ t._store && (t._store.validated = !0);
530
+ else if (t) {
531
+ var M = X(t);
532
+ if (typeof M == "function" && M !== t.entries)
533
+ for (var W = M.call(t), z; !(z = W.next()).done; )
534
+ b(z.value) && Te(z.value, a);
535
+ }
536
+ }
537
+ }
538
+ function Fe(t) {
539
+ {
540
+ var a = t.type;
541
+ if (a == null || typeof a == "string")
542
+ return;
543
+ var f;
544
+ if (typeof a == "function")
545
+ f = a.propTypes;
546
+ else if (typeof a == "object" && (a.$$typeof === w || // Note: Memo only checks outer props here.
547
+ // Inner props are checked in the reconciler.
548
+ a.$$typeof === m))
549
+ f = a.propTypes;
550
+ else
551
+ return;
552
+ if (f) {
553
+ var R = V(a);
554
+ ze(f, t.props, "prop", R, t);
555
+ } else if (a.PropTypes !== void 0 && !$t) {
556
+ $t = !0;
557
+ var M = V(a);
558
+ E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", M || "Unknown");
559
+ }
560
+ typeof a.getDefaultProps == "function" && !a.getDefaultProps.isReactClassApproved && E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
561
+ }
562
+ }
563
+ function Ye(t) {
564
+ {
565
+ for (var a = Object.keys(t.props), f = 0; f < a.length; f++) {
566
+ var R = a[f];
567
+ if (R !== "children" && R !== "key") {
568
+ Dt(t), E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", R), Dt(null);
569
+ break;
570
+ }
571
+ }
572
+ t.ref !== null && (Dt(t), E("Invalid attribute `ref` supplied to `React.Fragment`."), Dt(null));
573
+ }
574
+ }
575
+ var Bt = {};
576
+ function ce(t, a, f, R, M, W) {
577
+ {
578
+ var z = H(t);
579
+ if (!z) {
580
+ var j = "";
581
+ (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (j += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
582
+ var nt = Ee();
583
+ nt ? j += nt : j += gt();
584
+ var B;
585
+ t === null ? B = "null" : lt(t) ? B = "array" : t !== void 0 && t.$$typeof === r ? (B = "<" + (V(t.type) || "Unknown") + " />", j = " Did you accidentally export a JSX literal instead of a component?") : B = typeof t, E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", B, j);
586
+ }
587
+ var Z = wt(t, a, f, M, W);
588
+ if (Z == null)
589
+ return Z;
590
+ if (z) {
591
+ var ft = a.children;
592
+ if (ft !== void 0)
593
+ if (R)
594
+ if (lt(ft)) {
595
+ for (var $ = 0; $ < ft.length; $++)
596
+ Pe(ft[$], t);
597
+ Object.freeze && Object.freeze(ft);
598
+ } else
599
+ E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
600
+ else
601
+ Pe(ft, t);
602
+ }
603
+ if (Pt.call(a, "key")) {
604
+ var tt = V(t), C = Object.keys(a).filter(function($e) {
605
+ return $e !== "key";
606
+ }), Vt = C.length > 0 ? "{key: someKey, " + C.join(": ..., ") + ": ...}" : "{key: someKey}";
607
+ if (!Bt[tt + Vt]) {
608
+ var We = C.length > 0 ? "{" + C.join(": ..., ") + ": ...}" : "{}";
609
+ E(`A props object containing a "key" prop is being spread into JSX:
610
+ let props = %s;
611
+ <%s {...props} />
612
+ React keys must be passed directly to JSX without using spread:
613
+ let props = %s;
614
+ <%s key={someKey} {...props} />`, Vt, tt, We, tt), Bt[tt + Vt] = !0;
615
+ }
616
+ }
617
+ return t === i ? Ye(Z) : Fe(Z), Z;
618
+ }
619
+ }
620
+ function Re(t, a, f) {
621
+ return ce(t, a, f, !0);
622
+ }
623
+ function Se(t, a, f) {
624
+ return ce(t, a, f, !1);
625
+ }
626
+ var Le = Se, F = Re;
627
+ de.Fragment = i, de.jsx = Le, de.jsxs = F;
628
+ }()), de;
629
+ }
630
+ process.env.NODE_ENV === "production" ? rr.exports = mn() : rr.exports = yn();
631
+ var N = rr.exports;
632
+ function Ue(e) {
633
+ return e.trim().toLowerCase();
634
+ }
635
+ function gn(e) {
636
+ const r = /* @__PURE__ */ new Map();
637
+ return e.forEach((s) => {
638
+ const i = s.meta;
639
+ if (!i)
640
+ return;
641
+ const o = i.pathKeys, h = (Array.isArray(o) ? o : []).map((u) => typeof u == "string" ? u : typeof u == "object" && u !== null && "name" in u && typeof u.name == "string" ? u.name : null).filter((u) => typeof u == "string").map((u) => u.trim()).filter((u) => u.length > 0);
642
+ h.length && r.set(s.id, h);
643
+ }), r;
644
+ }
645
+ function vn(e) {
646
+ const {
647
+ startNodeId: r,
648
+ sourceIndex: s,
649
+ pathKey: i,
650
+ incomingEdgesByTarget: o,
651
+ pathKeysByNode: c,
652
+ maxNodes: h = 500
653
+ } = e, u = /* @__PURE__ */ new Set([r]), w = /* @__PURE__ */ new Set(), T = /* @__PURE__ */ new Set([`${r}|${s ?? ""}|${i ?? ""}`]), v = [
654
+ { nodeId: r, sourceIndex: s ?? null, pathKey: i }
655
+ ];
656
+ for (; v.length && !(u.size >= h); ) {
657
+ const m = v.pop();
658
+ if (!m)
659
+ continue;
660
+ const g = o.get(m.nodeId) ?? [], I = m.pathKey ? Ue(m.pathKey) : null;
661
+ let l = [];
662
+ I && c && (l = g.filter((L) => (c.get(L.source) ?? []).some((y) => Ue(y) === I))), l.length || (m.sourceIndex == null ? l = g : g[m.sourceIndex] && (l = [g[m.sourceIndex]])), l.forEach((L) => {
663
+ if (w.has(L.id))
664
+ return;
665
+ w.add(L.id), u.add(L.source);
666
+ const X = (c == null ? void 0 : c.get(L.source)) ?? [], y = I ? X.findIndex((x) => Ue(x) === I) : m.sourceIndex, E = typeof y == "number" && y >= 0 ? y : m.sourceIndex, _ = `${L.source}|${E ?? ""}|${m.pathKey ?? ""}`;
667
+ T.has(_) || (T.add(_), v.push({
668
+ nodeId: L.source,
669
+ sourceIndex: E,
670
+ pathKey: m.pathKey
671
+ }));
672
+ });
673
+ }
674
+ return { nodes: u, edges: w };
675
+ }
676
+ function xn(e, r, s) {
677
+ const [i, o] = Et(null), [c, h] = Et(null), [u, w] = Et(null), T = k(
678
+ () => new Map(r.map((y) => [y.id, y])),
679
+ [r]
680
+ ), v = k(() => {
681
+ const y = /* @__PURE__ */ new Map();
682
+ return r.forEach((E) => {
683
+ y.set(E.source, [...y.get(E.source) ?? [], E]), E.target !== E.source && y.set(E.target, [...y.get(E.target) ?? [], E]);
684
+ }), y;
685
+ }, [r]), m = k(() => {
686
+ const y = /* @__PURE__ */ new Map();
687
+ return e.forEach((E) => y.set(E.id, E.position)), y;
688
+ }, [e]), g = k(
689
+ () => gn(e),
690
+ [e]
691
+ ), I = k(() => {
692
+ const y = ln(r);
693
+ return y.forEach((E, _) => {
694
+ y.set(_, fn(E, m));
695
+ }), y;
696
+ }, [r, m]), l = k(() => u ? vn({
697
+ startNodeId: u.nodeId,
698
+ sourceIndex: u.sourceIndex,
699
+ pathKey: u.pathKey,
700
+ incomingEdgesByTarget: I,
701
+ pathKeysByNode: g
702
+ }) : null, [u, I, g]), L = k(() => {
703
+ if (!s && !l) return null;
704
+ const y = /* @__PURE__ */ new Map(), E = () => {
705
+ l && l.nodes.forEach((_) => {
706
+ const x = y.get(_) ?? { in: !1, out: !1 };
707
+ y.set(_, { ...x, in: !0, out: !0 });
708
+ });
709
+ };
710
+ if (u)
711
+ E();
712
+ else {
713
+ if (s) {
714
+ if (i) {
715
+ const _ = T.get(i);
716
+ if (_) {
717
+ const x = (G, ut) => {
718
+ const rt = y.get(G) ?? { in: !1, out: !1 };
719
+ y.set(G, { ...rt, [ut]: !0 });
720
+ };
721
+ _.type === "undirected" ? (x(_.source, "in"), x(_.source, "out"), x(_.target, "in"), x(_.target, "out")) : (x(_.source, "out"), x(_.target, "in"));
722
+ }
723
+ } else if (c) {
724
+ const _ = (x, G) => {
725
+ const ut = y.get(x) ?? { in: !1, out: !1 };
726
+ y.set(x, { ...ut, [G]: !0 });
727
+ };
728
+ (v.get(c) ?? []).forEach((x) => {
729
+ const G = x.type === "undirected";
730
+ (x.source === c || x.target === c) && (G ? (_(x.source, "in"), _(x.source, "out"), _(x.target, "in"), _(x.target, "out")) : (_(x.source, "out"), _(x.target, "in")));
731
+ }), _(c, "in"), _(c, "out");
732
+ }
733
+ }
734
+ E();
735
+ }
736
+ return y.size ? y : null;
737
+ }, [
738
+ T,
739
+ v,
740
+ s,
741
+ i,
742
+ c,
743
+ l,
744
+ u
745
+ ]), X = k(() => {
746
+ const y = /* @__PURE__ */ new Set();
747
+ if (u && l ? l.edges.forEach((x) => y.add(x)) : (s && (i ? y.add(i) : c && (v.get(c) ?? []).forEach((x) => {
748
+ (x.source === c || x.target === c) && y.add(x.id);
749
+ })), l && l.edges.forEach((x) => y.add(x))), !y.size) return r;
750
+ const E = [], _ = [];
751
+ return r.forEach((x) => {
752
+ y.has(x.id) ? E.push(x) : _.push(x);
753
+ }), [..._, ...E];
754
+ }, [
755
+ v,
756
+ s,
757
+ i,
758
+ c,
759
+ r,
760
+ l,
761
+ u
762
+ ]);
763
+ return {
764
+ hoveredEdgeId: i,
765
+ setHoveredEdgeId: o,
766
+ hoveredNodeId: c,
767
+ setHoveredNodeId: h,
768
+ focusedPath: u,
769
+ setFocusedPath: w,
770
+ pathHighlight: l,
771
+ hoveredNodeStates: L,
772
+ edgesForRender: X
773
+ };
774
+ }
775
+ const wn = ({
776
+ collapsedNodeIds: e,
777
+ defaultCollapsedNodeIds: r,
778
+ onCollapsedNodeIdsChange: s
779
+ }) => {
780
+ const [i, o] = Et(
781
+ r ?? []
782
+ ), [c, h] = Et([]), u = e ?? i, w = k(() => new Set(u), [u]), T = k(
783
+ () => new Set(c),
784
+ [c]
785
+ ), v = K(
786
+ (m) => {
787
+ const I = typeof m == "function" ? m(u) : m;
788
+ e == null && o(I), s == null || s(I);
789
+ },
790
+ [u, e, s]
791
+ );
792
+ return {
793
+ collapsedIds: u,
794
+ collapsedNodeSet: w,
795
+ pendingExpansionNodeSet: T,
796
+ updateCollapsedNodeIds: v,
797
+ setPendingExpansionNodeIds: h
798
+ };
799
+ }, bn = ({
800
+ nodes: e,
801
+ edges: r,
802
+ collapsedIds: s,
803
+ hiddenNodeIds: i,
804
+ searchQuery: o,
805
+ hideUnmatchedSearch: c = !1,
806
+ searchPredicate: h,
807
+ highlightedNodeIds: u,
808
+ highlightedEdgeIds: w,
809
+ highlightStrategy: T,
810
+ onSearchResultsChange: v
811
+ }) => {
812
+ const m = pt(v);
813
+ m.current = v;
814
+ const g = k(() => {
815
+ const S = o == null ? void 0 : o.trim().toLowerCase();
816
+ return S ? e.filter((D) => {
817
+ if (h)
818
+ try {
819
+ return h(D, S);
820
+ } catch {
821
+ return !1;
822
+ }
823
+ const H = typeof D.label == "string" || typeof D.label == "number" ? String(D.label) : D.id;
824
+ return D.id.toLowerCase().includes(S) || H.toLowerCase().includes(S);
825
+ }).map((D) => D.id) : [];
826
+ }, [e, h, o]), I = k(
827
+ () => new Set(g),
828
+ [g]
829
+ ), l = k(() => {
830
+ const S = o == null ? void 0 : o.trim().toLowerCase();
831
+ return S ? r.filter((D) => {
832
+ const H = D.label != null ? String(D.label).toLowerCase() : "";
833
+ return I.has(D.source) || I.has(D.target) || H.includes(S);
834
+ }).map((D) => D.id) : [];
835
+ }, [r, I, o]), L = k(() => o != null && o.trim() ? (() => {
836
+ try {
837
+ return (T == null ? void 0 : T({
838
+ nodes: e,
839
+ edges: r,
840
+ query: o,
841
+ matchedNodeIds: g,
842
+ matchedEdgeIds: l
843
+ })) ?? { nodeIds: [], edgeIds: [] };
844
+ } catch {
845
+ return { nodeIds: [], edgeIds: [] };
846
+ }
847
+ })() : { nodeIds: [], edgeIds: [] }, [r, T, e, l, g, o]), X = k(
848
+ () => /* @__PURE__ */ new Set([
849
+ ...g,
850
+ ...L.nodeIds ?? [],
851
+ ...u ?? []
852
+ ]),
853
+ [L.nodeIds, u, g]
854
+ ), y = k(
855
+ () => /* @__PURE__ */ new Set([
856
+ ...l,
857
+ ...L.edgeIds ?? [],
858
+ ...w ?? []
859
+ ]),
860
+ [L.edgeIds, w, l]
861
+ );
862
+ te(() => {
863
+ var S;
864
+ (S = m.current) == null || S.call(m, {
865
+ nodeIds: g,
866
+ edgeIds: l
867
+ });
868
+ }, [l, g]);
869
+ const E = k(() => {
870
+ const S = new Set(i ?? []);
871
+ return c && (o != null && o.trim()) && e.forEach((D) => {
872
+ X.has(D.id) || S.add(D.id);
873
+ }), S;
874
+ }, [X, i, c, e, o]), _ = k(() => {
875
+ const S = /* @__PURE__ */ new Map();
876
+ return r.forEach((D) => {
877
+ S.set(D.source, [...S.get(D.source) ?? [], D.target]);
878
+ }), S;
879
+ }, [r]), x = k(() => {
880
+ const S = new Set(E);
881
+ return s.forEach((D) => {
882
+ const H = [..._.get(D) ?? []];
883
+ for (; H.length; ) {
884
+ const it = H.pop();
885
+ !it || S.has(it) || (S.add(it), H.push(..._.get(it) ?? []));
886
+ }
887
+ }), S;
888
+ }, [s, E, _]), G = k(
889
+ () => e.filter((S) => !x.has(S.id)),
890
+ [x, e]
891
+ ), ut = k(
892
+ () => r.filter(
893
+ (S) => !x.has(S.source) && !x.has(S.target)
894
+ ),
895
+ [x, r]
896
+ );
897
+ return {
898
+ effectiveHighlightedNodeSet: X,
899
+ effectiveHighlightedEdgeSet: y,
900
+ visibleNodes: G,
901
+ visibleEdges: ut,
902
+ childNodeIdsByParent: _
903
+ };
904
+ }, Mr = (e) => !!(e && Number.isFinite(e.x) && Number.isFinite(e.y)), he = (e, r, s) => {
905
+ const i = new Set(r.map((c) => c.id));
906
+ if (e.length !== r.length)
907
+ throw new Error(
908
+ `${s} must return ${r.length} nodes, received ${e.length}.`
909
+ );
910
+ const o = /* @__PURE__ */ new Set();
911
+ e.forEach((c) => {
912
+ if (!i.has(c.id))
913
+ throw new Error(`${s} returned unknown node id "${c.id}".`);
914
+ if (o.has(c.id))
915
+ throw new Error(`${s} returned duplicate node id "${c.id}".`);
916
+ if (!Mr(c.position))
917
+ throw new Error(`${s} returned a non-finite position for node "${c.id}".`);
918
+ o.add(c.id);
919
+ });
920
+ }, pe = (e, r, s) => {
921
+ const i = /* @__PURE__ */ new Set();
922
+ e.forEach((o) => {
923
+ if (i.has(o.id))
924
+ throw new Error(`${s} returned duplicate edge id "${o.id}".`);
925
+ if (!r.has(o.source) || !r.has(o.target))
926
+ throw new Error(
927
+ `${s} returned edge "${o.id}" with unknown endpoint(s): ${o.source} -> ${o.target}.`
928
+ );
929
+ if (!Array.isArray(o.points) || o.points.length < 2)
930
+ throw new Error(`${s} returned edge "${o.id}" without a valid point path.`);
931
+ o.points.forEach((c, h) => {
932
+ if (!Mr(c))
933
+ throw new Error(
934
+ `${s} returned a non-finite point at index ${h} for edge "${o.id}".`
935
+ );
936
+ }), i.add(o.id);
937
+ });
938
+ }, Nt = (e) => e instanceof Error ? e : new Error(String(e)), Er = (e) => er({
939
+ ...e,
940
+ layout: Me.Centered
941
+ }), _r = (e, r) => {
942
+ const s = new Map(e.map((i) => [i.id, i]));
943
+ return r.flatMap((i) => {
944
+ var v, m, g, I;
945
+ const o = s.get(i.source), c = s.get(i.target);
946
+ if (!o || !c)
947
+ return [];
948
+ const h = ((v = o.size) == null ? void 0 : v.width) ?? 0, u = ((m = o.size) == null ? void 0 : m.height) ?? 0, w = ((g = c.size) == null ? void 0 : g.width) ?? 0, T = ((I = c.size) == null ? void 0 : I.height) ?? 0;
949
+ if (o.id === c.id) {
950
+ const l = o.position.x + h, L = o.position.y;
951
+ return [
952
+ {
953
+ ...i,
954
+ type: i.type ?? vr.Directed,
955
+ points: [
956
+ { x: l - Math.min(h * 0.25, 18), y: L + Math.min(u * 0.35, 18) },
957
+ { x: l + 28, y: L - 20 },
958
+ { x: l + 36, y: L + u / 2 },
959
+ { x: l - Math.min(h * 0.25, 18), y: L + u * 0.8 }
960
+ ]
961
+ }
962
+ ];
963
+ }
964
+ return [
965
+ {
966
+ ...i,
967
+ type: i.type ?? vr.Directed,
968
+ points: [
969
+ {
970
+ x: o.position.x + h / 2,
971
+ y: o.position.y + u / 2
972
+ },
973
+ {
974
+ x: c.position.x + w / 2,
975
+ y: c.position.y + T / 2
976
+ }
977
+ ]
978
+ }
979
+ ];
980
+ });
981
+ }, In = ({
982
+ graph: e,
983
+ config: r,
984
+ mergedTheme: s,
985
+ collapsedIds: i,
986
+ hiddenNodeIds: o,
987
+ searchQuery: c,
988
+ hideUnmatchedSearch: h = !1,
989
+ searchPredicate: u,
990
+ highlightedNodeIds: w,
991
+ highlightedEdgeIds: T,
992
+ highlightStrategy: v,
993
+ onSearchResultsChange: m,
994
+ layoutNodesOverride: g,
995
+ routeEdgesOverride: I,
996
+ onError: l
997
+ }) => {
998
+ const [L, X] = Et({}), { nodes: y, edges: E } = k(
999
+ () => dn(e, r.defaultEdgeType),
1000
+ [r.defaultEdgeType, e]
1001
+ ), _ = k(
1002
+ () => y.map((O) => ({
1003
+ ...O,
1004
+ measuredSize: L[O.id] ?? O.measuredSize
1005
+ })),
1006
+ [L, y]
1007
+ );
1008
+ te(() => {
1009
+ const O = new Set(y.map((A) => A.id));
1010
+ X((A) => {
1011
+ const Y = Object.entries(A).filter(([J]) => O.has(J));
1012
+ return Y.length === Object.keys(A).length ? A : Object.fromEntries(Y);
1013
+ });
1014
+ }, [y]);
1015
+ const x = k(
1016
+ () => E.map((O) => ({
1017
+ ...O,
1018
+ type: O.type ?? r.defaultEdgeType
1019
+ })),
1020
+ [r.defaultEdgeType, E]
1021
+ ), {
1022
+ effectiveHighlightedNodeSet: G,
1023
+ effectiveHighlightedEdgeSet: ut,
1024
+ visibleNodes: rt,
1025
+ visibleEdges: S,
1026
+ childNodeIdsByParent: D
1027
+ } = bn({
1028
+ nodes: _,
1029
+ edges: x,
1030
+ collapsedIds: i,
1031
+ hiddenNodeIds: o,
1032
+ searchQuery: c,
1033
+ hideUnmatchedSearch: h,
1034
+ searchPredicate: u,
1035
+ highlightedNodeIds: w,
1036
+ highlightedEdgeIds: T,
1037
+ highlightStrategy: v,
1038
+ onSearchResultsChange: m
1039
+ }), H = k(
1040
+ () => ({
1041
+ nodes: rt,
1042
+ edges: S,
1043
+ theme: s,
1044
+ padding: r.padding,
1045
+ layout: r.layout,
1046
+ width: r.width,
1047
+ height: r.height,
1048
+ layoutDirection: r.layoutDirection,
1049
+ nodeSizing: r.nodeSizing,
1050
+ fixedNodeSize: r.fixedNodeSize,
1051
+ labelMeasurementPaddingX: r.labelMeasurementPaddingX,
1052
+ labelMeasurementPaddingY: r.labelMeasurementPaddingY,
1053
+ labelMeasurementCharWidth: r.labelMeasurementCharWidth,
1054
+ labelMeasurementLineHeight: r.labelMeasurementLineHeight
1055
+ }),
1056
+ [r, s, S, rt]
1057
+ ), it = K(
1058
+ (O, A) => {
1059
+ r.nodeSizing === "measured" && X((Y) => {
1060
+ const J = Y[O];
1061
+ return J && J.width === A.width && J.height === A.height ? Y : {
1062
+ ...Y,
1063
+ [O]: A
1064
+ };
1065
+ });
1066
+ },
1067
+ [r.nodeSizing]
1068
+ ), q = k(
1069
+ () => {
1070
+ if (!g)
1071
+ try {
1072
+ const O = er(H);
1073
+ return he(O, rt, "layout"), O;
1074
+ } catch (O) {
1075
+ l == null || l(Nt(O), {
1076
+ graph: e,
1077
+ phase: "layout"
1078
+ });
1079
+ try {
1080
+ const A = Er(H);
1081
+ return he(A, rt, "layout"), A;
1082
+ } catch (A) {
1083
+ const Y = Nt(A);
1084
+ throw l == null || l(Y, {
1085
+ graph: e,
1086
+ phase: "layout"
1087
+ }), Y;
1088
+ }
1089
+ }
1090
+ try {
1091
+ const O = g(H);
1092
+ return he(O, rt, "layout override"), O;
1093
+ } catch (O) {
1094
+ l == null || l(Nt(O), {
1095
+ graph: e,
1096
+ phase: "layout-override"
1097
+ });
1098
+ try {
1099
+ const A = er(H);
1100
+ return he(A, rt, "layout"), A;
1101
+ } catch (A) {
1102
+ l == null || l(Nt(A), { graph: e, phase: "layout" });
1103
+ try {
1104
+ const Y = Er(H);
1105
+ return he(Y, rt, "layout"), Y;
1106
+ } catch (Y) {
1107
+ const J = Nt(Y);
1108
+ throw l == null || l(J, { graph: e, phase: "layout" }), J;
1109
+ }
1110
+ }
1111
+ }
1112
+ },
1113
+ [e, g, H, l, rt]
1114
+ ), V = k(
1115
+ () => ({
1116
+ arrowPadding: r.arrowPadding,
1117
+ straight: !r.curveEdges || r.routingStyle === "orthogonal",
1118
+ layoutDirection: r.layoutDirection,
1119
+ forceRightToLeft: r.forceRightToLeft,
1120
+ routingStyle: r.routingStyle,
1121
+ edgeSeparation: r.edgeSeparation,
1122
+ selfLoopRadius: r.selfLoopRadius
1123
+ }),
1124
+ [r]
1125
+ ), at = k(
1126
+ () => {
1127
+ const O = new Set(q.map((A) => A.id));
1128
+ if (!I)
1129
+ try {
1130
+ const A = xr(q, S, V);
1131
+ return pe(A, O, "routing"), A;
1132
+ } catch (A) {
1133
+ l == null || l(Nt(A), {
1134
+ graph: e,
1135
+ phase: "routing"
1136
+ });
1137
+ const Y = _r(q, S);
1138
+ return pe(Y, O, "routing"), Y;
1139
+ }
1140
+ try {
1141
+ const A = I(q, S, V);
1142
+ return pe(A, O, "routing override"), A;
1143
+ } catch (A) {
1144
+ l == null || l(Nt(A), {
1145
+ graph: e,
1146
+ phase: "routing-override"
1147
+ });
1148
+ try {
1149
+ const Y = xr(q, S, V);
1150
+ return pe(Y, O, "routing"), Y;
1151
+ } catch (Y) {
1152
+ l == null || l(Nt(Y), { graph: e, phase: "routing" });
1153
+ const J = _r(q, S);
1154
+ return pe(J, O, "routing"), J;
1155
+ }
1156
+ }
1157
+ },
1158
+ [
1159
+ V,
1160
+ e,
1161
+ l,
1162
+ q,
1163
+ I,
1164
+ S
1165
+ ]
1166
+ );
1167
+ return {
1168
+ childNodeIdsByParent: D,
1169
+ effectiveHighlightedEdgeSet: ut,
1170
+ effectiveHighlightedNodeSet: G,
1171
+ handleNodeMeasure: it,
1172
+ positionedEdges: at,
1173
+ positionedNodes: q,
1174
+ visibleEdges: S,
1175
+ visibleNodesWithMeasuredSize: rt
1176
+ };
1177
+ }, Tr = (e) => Object.prototype.toString.call(e) === "[object Object]", nr = (e, r, s) => {
1178
+ if (Object.is(e, r))
1179
+ return !0;
1180
+ if (typeof e == "function" || typeof r == "function" || !e || !r || typeof e != "object" || typeof r != "object")
1181
+ return !1;
1182
+ const i = s.get(e);
1183
+ if (i != null && i.has(r))
1184
+ return !0;
1185
+ if (Array.isArray(e) || Array.isArray(r)) {
1186
+ if (!Array.isArray(e) || !Array.isArray(r) || e.length !== r.length)
1187
+ return !1;
1188
+ i ? i.add(r) : s.set(e, new WeakSet([r]));
1189
+ for (let h = 0; h < e.length; h += 1)
1190
+ if (!nr(e[h], r[h], s))
1191
+ return !1;
1192
+ return !0;
1193
+ }
1194
+ if (!Tr(e) || !Tr(r))
1195
+ return !1;
1196
+ i ? i.add(r) : s.set(e, new WeakSet([r]));
1197
+ const o = Object.keys(e), c = Object.keys(r);
1198
+ if (o.length !== c.length)
1199
+ return !1;
1200
+ for (const h of o)
1201
+ if (!(h in r) || !nr(e[h], r[h], s))
1202
+ return !1;
1203
+ return !0;
1204
+ };
1205
+ function En(e) {
1206
+ const r = pt(null);
1207
+ return (r.current === null || !nr(r.current, e, /* @__PURE__ */ new WeakMap())) && (r.current = e), r.current;
1208
+ }
1209
+ const _n = 180, Tn = 24, Ar = (e) => {
1210
+ var r;
1211
+ return ((r = e.size) == null ? void 0 : r.width) ?? _n;
1212
+ }, He = (e) => e.position.x + Ar(e) / 2, jr = (e, r = Tn) => {
1213
+ const s = [...e].sort((o, c) => He(o) - He(c)), i = [];
1214
+ return s.forEach((o) => {
1215
+ const c = He(o), h = Ar(o), u = i[i.length - 1];
1216
+ if (!u) {
1217
+ i.push({ centerX: c, avgWidth: h, nodes: [o] });
1218
+ return;
1219
+ }
1220
+ const w = Math.max(r, Math.min(u.avgWidth, h) * 0.35);
1221
+ if (Math.abs(c - u.centerX) > w) {
1222
+ i.push({ centerX: c, avgWidth: h, nodes: [o] });
1223
+ return;
1224
+ }
1225
+ u.nodes.push(o);
1226
+ const T = u.nodes.length;
1227
+ u.centerX = (u.centerX * (T - 1) + c) / T, u.avgWidth = (u.avgWidth * (T - 1) + h) / T;
1228
+ }), i.map((o) => ({
1229
+ centerX: o.centerX,
1230
+ nodes: [...o.nodes].sort((c, h) => c.position.y - h.position.y)
1231
+ }));
1232
+ }, Dr = 180, zr = 72, Ae = (e, r, s) => Math.min(Math.max(e, r), s), Pn = (e) => e.length ? e.reduce(
1233
+ (s, i) => {
1234
+ var v, m;
1235
+ const o = ((v = i.size) == null ? void 0 : v.width) ?? Dr, c = ((m = i.size) == null ? void 0 : m.height) ?? zr, h = Math.min(s.minX, i.position.x), u = Math.min(s.minY, i.position.y), w = Math.max(s.maxX, i.position.x + o), T = Math.max(s.maxY, i.position.y + c);
1236
+ return {
1237
+ minX: h,
1238
+ minY: u,
1239
+ maxX: w,
1240
+ maxY: T,
1241
+ width: w - h,
1242
+ height: T - u
1243
+ };
1244
+ },
1245
+ {
1246
+ minX: Number.POSITIVE_INFINITY,
1247
+ minY: Number.POSITIVE_INFINITY,
1248
+ maxX: Number.NEGATIVE_INFINITY,
1249
+ maxY: Number.NEGATIVE_INFINITY,
1250
+ width: 0,
1251
+ height: 0
1252
+ }
1253
+ ) : null, Rn = (e, r, s, i, o, c) => {
1254
+ if (!e || r <= 0 || s <= 0)
1255
+ return { x: 0, y: 0, zoom: 1 };
1256
+ const h = Math.max(e.width, 1), u = Math.max(e.height, 1), w = Math.max(r - i * 2, 1), T = Math.max(s - i * 2, 1), v = Ae(
1257
+ Math.min(w / h, T / u),
1258
+ o,
1259
+ c
1260
+ );
1261
+ return {
1262
+ x: i + (w - h * v) / 2 - e.minX * v,
1263
+ y: i + (T - u * v) / 2 - e.minY * v,
1264
+ zoom: v
1265
+ };
1266
+ }, Sn = (e, r, s, i) => {
1267
+ var w, T;
1268
+ const o = ((w = e.size) == null ? void 0 : w.width) ?? Dr, c = ((T = e.size) == null ? void 0 : T.height) ?? zr, h = e.position.x + o / 2, u = e.position.y + c / 2;
1269
+ return {
1270
+ x: r / 2 - h * i,
1271
+ y: s / 2 - u * i,
1272
+ zoom: i
1273
+ };
1274
+ }, Ln = re.memo(function({
1275
+ edge: r,
1276
+ color: s,
1277
+ width: i,
1278
+ curveEdges: o,
1279
+ curveStrength: c,
1280
+ markerEnd: h,
1281
+ isHovered: u,
1282
+ isSelected: w,
1283
+ hoverColor: T,
1284
+ selectionColor: v,
1285
+ labelColor: m,
1286
+ selectionMarker: g,
1287
+ hoverMarker: I,
1288
+ hoverEnabled: l,
1289
+ hoverStrokeWidth: L,
1290
+ selectedStrokeWidth: X,
1291
+ hitStrokeWidth: y,
1292
+ onHoverChange: E,
1293
+ onClick: _
1294
+ }) {
1295
+ const x = hn(r, o, c);
1296
+ if (!x) return null;
1297
+ const G = u ? T : w ? v ?? T : s, ut = u ? L ?? i : w ? X ?? i + 1 : i, rt = u ? I ?? g ?? h : w ? g ?? h : h, S = r.label != null && r.labelPosition ? String(r.label) : null;
1298
+ return /* @__PURE__ */ N.jsxs(N.Fragment, { children: [
1299
+ /* @__PURE__ */ N.jsx(
1300
+ "path",
1301
+ {
1302
+ d: x,
1303
+ stroke: "transparent",
1304
+ strokeWidth: y ?? i + 8,
1305
+ fill: "none",
1306
+ pointerEvents: "stroke",
1307
+ "data-graph-edge-interactive": "true",
1308
+ onMouseEnter: () => l && (E == null ? void 0 : E(!0)),
1309
+ onMouseLeave: () => l && (E == null ? void 0 : E(!1)),
1310
+ onClick: _
1311
+ }
1312
+ ),
1313
+ /* @__PURE__ */ N.jsx(
1314
+ "path",
1315
+ {
1316
+ d: x,
1317
+ stroke: G,
1318
+ strokeWidth: ut,
1319
+ fill: "none",
1320
+ markerEnd: r.type === "directed" ? rt : void 0,
1321
+ pointerEvents: "none"
1322
+ }
1323
+ ),
1324
+ S && r.labelPosition ? /* @__PURE__ */ N.jsx(
1325
+ "text",
1326
+ {
1327
+ x: r.labelPosition.x,
1328
+ y: r.labelPosition.y - 6,
1329
+ textAnchor: "middle",
1330
+ fontSize: 12,
1331
+ fontWeight: 600,
1332
+ fill: m ?? "#334155",
1333
+ pointerEvents: "none",
1334
+ children: S
1335
+ }
1336
+ ) : null
1337
+ ] });
1338
+ }), kn = 64, ee = 20, Pr = 8, On = 12, Mn = 7, An = 48, jn = 12, Dn = 700;
1339
+ function Nr(e) {
1340
+ const r = Math.min(Array.from(e).length, An);
1341
+ return Math.max(
1342
+ kn,
1343
+ r * Mn + On * 2
1344
+ );
1345
+ }
1346
+ function Fr(e, r, s, i, o = !1) {
1347
+ const c = jr(e), h = c.map((g) => g.centerX);
1348
+ if (!h.length)
1349
+ return { orderedXs: [], orderedLabels: [] };
1350
+ const w = c.map((g) => g.nodes.length).map((g) => {
1351
+ const I = g * 2;
1352
+ return I <= 2 ? "Final" : `1/${I}`;
1353
+ }), T = i && i.length ? i : o ? w : [], v = r === Me.Tree && s === tr.RTL ? [...h].reverse() : h, m = r === Me.Tree && s === tr.RTL ? [...T].reverse() : T;
1354
+ return { orderedXs: v, orderedLabels: m };
1355
+ }
1356
+ function zn({
1357
+ positionedNodes: e,
1358
+ layout: r,
1359
+ layoutDirection: s,
1360
+ labels: i,
1361
+ autoLabels: o,
1362
+ labelOffset: c,
1363
+ pillBackground: h = "#eef1f6",
1364
+ pillBorderColor: u = "#d7dbe3",
1365
+ pillTextColor: w = "#3f434b"
1366
+ }) {
1367
+ const { orderedXs: T, orderedLabels: v } = Fr(
1368
+ e,
1369
+ r,
1370
+ s,
1371
+ i,
1372
+ o
1373
+ );
1374
+ if (!T.length || !v.length) return null;
1375
+ const g = e.reduce(
1376
+ (I, l) => Math.min(I, l.position.y),
1377
+ Number.POSITIVE_INFINITY
1378
+ ) - c;
1379
+ return /* @__PURE__ */ N.jsx("g", { "aria-label": "labels", children: T.map((I, l) => {
1380
+ const L = v[l] ?? "", X = Nr(L), y = I;
1381
+ return /* @__PURE__ */ N.jsxs(
1382
+ "g",
1383
+ {
1384
+ transform: `translate(${y - X / 2}, ${g - ee + 6})`,
1385
+ children: [
1386
+ /* @__PURE__ */ N.jsx(
1387
+ "rect",
1388
+ {
1389
+ width: X,
1390
+ height: ee,
1391
+ rx: Pr,
1392
+ ry: Pr,
1393
+ fill: h,
1394
+ stroke: u,
1395
+ strokeWidth: 1
1396
+ }
1397
+ ),
1398
+ /* @__PURE__ */ N.jsx(
1399
+ "text",
1400
+ {
1401
+ x: X / 2,
1402
+ y: ee / 2 + 4,
1403
+ fill: w,
1404
+ fontSize: jn,
1405
+ fontWeight: Dn,
1406
+ textAnchor: "middle",
1407
+ children: L
1408
+ }
1409
+ )
1410
+ ]
1411
+ },
1412
+ `col-${I}`
1413
+ );
1414
+ }) });
1415
+ }
1416
+ const Nn = typeof window > "u" ? te : an, Yr = re.memo(
1417
+ ({
1418
+ node: e,
1419
+ Vertex: r,
1420
+ isSelected: s,
1421
+ isFocused: i,
1422
+ selectionColor: o,
1423
+ isHighlighted: c,
1424
+ activePathKey: h,
1425
+ activePathNodeIds: u,
1426
+ highlightColor: w,
1427
+ nodeBorderColor: T,
1428
+ nodeBorderWidth: v,
1429
+ hoverNodeBorderColor: m,
1430
+ hoverNodeBothColor: g,
1431
+ hoverNodeInColor: I,
1432
+ hoverNodeOutColor: l,
1433
+ hoverNodeHighlight: L,
1434
+ hoveredNodeStates: X,
1435
+ onNodeMeasure: y,
1436
+ onNodeFocus: E,
1437
+ onNodeClick: _,
1438
+ onNodeDoubleClick: x,
1439
+ onNodeMouseEnter: G,
1440
+ onNodeMouseLeave: ut,
1441
+ onPathHover: rt,
1442
+ onPathLeave: S
1443
+ }) => {
1444
+ var Ft, Kt;
1445
+ const D = pt(null), H = ((Ft = e.size) == null ? void 0 : Ft.width) ?? 180, it = ((Kt = e.size) == null ? void 0 : Kt.height) ?? 72, q = 8, V = X == null ? void 0 : X.get(e.id), at = (V == null ? void 0 : V.in) ?? !1, O = (V == null ? void 0 : V.out) ?? !1, A = at && O, Y = at || O, J = !!T && v > 0 || s;
1446
+ let dt = T;
1447
+ s ? dt = o : c ? dt = w : J ? L && (A ? dt = g : O ? dt = l : at ? dt = I : Y && (dt = m)) : dt = "none";
1448
+ let jt = 0;
1449
+ s || c ? jt = 1 : J && (jt = L && Y ? 1 : 0.4), Nn(() => {
1450
+ if (!D.current || !y)
1451
+ return;
1452
+ const ot = () => {
1453
+ H > 0 && it > 0 && y(e.id, { width: Math.ceil(H), height: Math.ceil(it) });
1454
+ }, Q = requestAnimationFrame(() => {
1455
+ var Lt, Tt;
1456
+ try {
1457
+ if (typeof ((Lt = D.current) == null ? void 0 : Lt.getBBox) != "function") {
1458
+ ot();
1459
+ return;
1460
+ }
1461
+ const mt = (Tt = D.current) == null ? void 0 : Tt.getBBox();
1462
+ if (mt && mt.width > 0 && mt.height > 0) {
1463
+ y(e.id, {
1464
+ width: Math.ceil(mt.width),
1465
+ height: Math.ceil(mt.height)
1466
+ });
1467
+ return;
1468
+ }
1469
+ } catch {
1470
+ ot();
1471
+ }
1472
+ ot();
1473
+ });
1474
+ return () => cancelAnimationFrame(Q);
1475
+ }, [e.id, e.label, e.meta, y, H, it]);
1476
+ const vt = s || c ? Math.max(2, v) : J ? v : 0, _t = i ? Math.max(2, vt || 2) : 0;
1477
+ return /* @__PURE__ */ N.jsxs(
1478
+ "g",
1479
+ {
1480
+ ref: D,
1481
+ transform: `translate(${e.position.x}, ${e.position.y})`,
1482
+ "data-graph-node-interactive": "true",
1483
+ role: "button",
1484
+ tabIndex: 0,
1485
+ "aria-selected": s,
1486
+ onMouseDown: (ot) => {
1487
+ ot.preventDefault();
1488
+ },
1489
+ onFocus: () => E == null ? void 0 : E(e.id),
1490
+ onClick: () => _ == null ? void 0 : _(e),
1491
+ onDoubleClick: () => x == null ? void 0 : x(e),
1492
+ onMouseEnter: () => G(e.id),
1493
+ onMouseLeave: ut,
1494
+ onKeyDown: (ot) => {
1495
+ (ot.key === "Enter" || ot.key === " ") && (ot.preventDefault(), _ == null || _(e));
1496
+ },
1497
+ children: [
1498
+ /* @__PURE__ */ N.jsx(
1499
+ "rect",
1500
+ {
1501
+ x: 0,
1502
+ y: 0,
1503
+ width: H,
1504
+ height: it,
1505
+ rx: q,
1506
+ ry: q,
1507
+ fill: "none",
1508
+ stroke: dt,
1509
+ strokeOpacity: jt,
1510
+ strokeWidth: vt,
1511
+ pointerEvents: "none"
1512
+ }
1513
+ ),
1514
+ i ? /* @__PURE__ */ N.jsx(
1515
+ "rect",
1516
+ {
1517
+ x: -3,
1518
+ y: -3,
1519
+ width: H + 6,
1520
+ height: it + 6,
1521
+ rx: q + 2,
1522
+ ry: q + 2,
1523
+ fill: "none",
1524
+ stroke: o,
1525
+ strokeOpacity: 0.7,
1526
+ strokeWidth: _t,
1527
+ strokeDasharray: "4 3",
1528
+ pointerEvents: "none"
1529
+ }
1530
+ ) : null,
1531
+ /* @__PURE__ */ N.jsx(
1532
+ r,
1533
+ {
1534
+ node: e,
1535
+ isSelected: s,
1536
+ isHovered: Y,
1537
+ isHoveredIn: at,
1538
+ isHoveredOut: O,
1539
+ isHoveredBoth: A,
1540
+ activePathKey: h,
1541
+ activePathNodeIds: u,
1542
+ hoverInColor: I,
1543
+ hoverOutColor: l,
1544
+ hoverBothColor: g,
1545
+ onPathHover: (ot, Q) => ot !== null && rt(e.id, ot, (Q == null ? void 0 : Q.pathKey) ?? (Q == null ? void 0 : Q.playerKey)),
1546
+ onPathLeave: S
1547
+ }
1548
+ )
1549
+ ]
1550
+ }
1551
+ );
1552
+ }
1553
+ );
1554
+ Yr.displayName = "GraphNode";
1555
+ const Ke = { x: 0, y: 0, zoom: 1 }, Ge = { nodeIds: [], edgeIds: [] }, Wr = 0.25, $r = 2.5, Fn = 0.12, Yn = "#f59e0b", Wn = "top-left", Ht = 26, ir = 34, Xr = 8, Ve = 48, Ze = 20, $n = 8, qe = (e, r, s) => ({
1556
+ x: Number.isFinite(e.x) ? e.x : 0,
1557
+ y: Number.isFinite(e.y) ? e.y : 0,
1558
+ zoom: Ae(Number.isFinite(e.zoom) ? e.zoom : 1, r, s)
1559
+ }), Xn = (e, r) => {
1560
+ const s = Number.isFinite(e) && e > 0 ? e : Wr, i = Number.isFinite(r) && r > 0 ? r : $r;
1561
+ return s <= i ? { minZoom: s, maxZoom: i } : { minZoom: i, maxZoom: s };
1562
+ }, Je = (e) => e instanceof Error ? e : new Error(String(e)), Rr = (e, r, s) => s === "single" ? e.length === 1 && e[0] === r ? [] : [r] : e.includes(r) ? e.filter((i) => i !== r) : [...e, r], Bn = (e, r, s) => {
1563
+ const i = 2 * Ht + 2 * ir + Xr * 3, o = 12;
1564
+ switch (s) {
1565
+ case "top-right":
1566
+ return { x: e - i - o, y: o };
1567
+ case "bottom-left":
1568
+ return { x: o, y: r - Ht - o };
1569
+ case "bottom-right":
1570
+ return {
1571
+ x: e - i - o,
1572
+ y: r - Ht - o
1573
+ };
1574
+ case "top-left":
1575
+ default:
1576
+ return { x: o, y: o };
1577
+ }
1578
+ }, Sr = (e, r) => Math.hypot(e.x - r.x, e.y - r.y), Lr = (e, r) => ({
1579
+ x: (e.x + r.x) / 2,
1580
+ y: (e.y + r.y) / 2
1581
+ }), kr = (e) => ({
1582
+ x: Math.min(e.startX, e.endX),
1583
+ y: Math.min(e.startY, e.endY),
1584
+ width: Math.abs(e.endX - e.startX),
1585
+ height: Math.abs(e.endY - e.startY)
1586
+ }), Or = (e, r, s) => e >= s.x && e <= s.x + s.width && r >= s.y && r <= s.y + s.height, Cn = (e, r) => ({
1587
+ minX: e.minX - r,
1588
+ minY: e.minY - r,
1589
+ maxX: e.maxX + r,
1590
+ maxY: e.maxY + r,
1591
+ width: e.width + r * 2,
1592
+ height: e.height + r * 2
1593
+ }), je = (e, r) => {
1594
+ if (!e)
1595
+ return r;
1596
+ if (!r)
1597
+ return e;
1598
+ const s = Math.min(e.minX, r.minX), i = Math.min(e.minY, r.minY), o = Math.max(e.maxX, r.maxX), c = Math.max(e.maxY, r.maxY);
1599
+ return {
1600
+ minX: s,
1601
+ minY: i,
1602
+ maxX: o,
1603
+ maxY: c,
1604
+ width: o - s,
1605
+ height: c - i
1606
+ };
1607
+ }, Un = (e, r, s, i, o, c) => {
1608
+ if (!e.length || !o && !(i && i.length))
1609
+ return null;
1610
+ const h = jr(e);
1611
+ if (!h.length)
1612
+ return null;
1613
+ const u = r === Me.Tree && s === tr.RTL ? [...h].reverse() : h, { orderedLabels: w } = Fr(
1614
+ e,
1615
+ r,
1616
+ s,
1617
+ i,
1618
+ o
1619
+ ), v = e.reduce(
1620
+ (m, g) => Math.min(m, g.position.y),
1621
+ Number.POSITIVE_INFINITY
1622
+ ) - c - ee + 6;
1623
+ return u.reduce((m, g, I) => {
1624
+ const l = Nr(w[I] ?? ""), L = {
1625
+ minX: g.centerX - l / 2,
1626
+ minY: v,
1627
+ maxX: g.centerX + l / 2,
1628
+ maxY: v + ee,
1629
+ width: l,
1630
+ height: ee
1631
+ };
1632
+ return je(m, L);
1633
+ }, null);
1634
+ }, Hn = (e) => e.reduce((r, s) => {
1635
+ if (!s.labelPosition)
1636
+ return r;
1637
+ const i = {
1638
+ minX: s.labelPosition.x - Ve / 2,
1639
+ minY: s.labelPosition.y - Ze / 2,
1640
+ maxX: s.labelPosition.x + Ve / 2,
1641
+ maxY: s.labelPosition.y + Ze / 2,
1642
+ width: Ve,
1643
+ height: Ze
1644
+ };
1645
+ return je(r, i);
1646
+ }, null), Qe = (e, r, s) => {
1647
+ if (!e)
1648
+ return { x: r, y: s };
1649
+ const i = e.getBoundingClientRect();
1650
+ return {
1651
+ x: r - i.left,
1652
+ y: s - i.top
1653
+ };
1654
+ }, Kn = (e, r, s) => {
1655
+ var u, w, T, v, m, g;
1656
+ const i = {
1657
+ x: e.position.x + (((u = e.size) == null ? void 0 : u.width) ?? 0) / 2,
1658
+ y: e.position.y + (((w = e.size) == null ? void 0 : w.height) ?? 0) / 2
1659
+ }, o = r.filter((I) => {
1660
+ var L, X;
1661
+ if (I.id === e.id)
1662
+ return !1;
1663
+ const l = {
1664
+ x: I.position.x + (((L = I.size) == null ? void 0 : L.width) ?? 0) / 2,
1665
+ y: I.position.y + (((X = I.size) == null ? void 0 : X.height) ?? 0) / 2
1666
+ };
1667
+ return s === "left" ? l.x < i.x : s === "right" ? l.x > i.x : s === "up" ? l.y < i.y : l.y > i.y;
1668
+ });
1669
+ if (!o.length)
1670
+ return null;
1671
+ let c = o[0], h = Math.hypot(
1672
+ c.position.x + (((T = c.size) == null ? void 0 : T.width) ?? 0) / 2 - i.x,
1673
+ c.position.y + (((v = c.size) == null ? void 0 : v.height) ?? 0) / 2 - i.y
1674
+ );
1675
+ for (let I = 1; I < o.length; I++) {
1676
+ const l = o[I], L = Math.hypot(
1677
+ l.position.x + (((m = l.size) == null ? void 0 : m.width) ?? 0) / 2 - i.x,
1678
+ l.position.y + (((g = l.size) == null ? void 0 : g.height) ?? 0) / 2 - i.y
1679
+ );
1680
+ L < h && (c = l, h = L);
1681
+ }
1682
+ return c;
1683
+ }, Gn = ({
1684
+ graph: e,
1685
+ vertexComponent: r,
1686
+ edgeComponent: s = Ln,
1687
+ config: i,
1688
+ viewport: o,
1689
+ defaultViewport: c,
1690
+ onViewportChange: h,
1691
+ fitViewOnMount: u = !1,
1692
+ fitViewPadding: w = 32,
1693
+ minZoom: T = Wr,
1694
+ maxZoom: v = $r,
1695
+ zoomStep: m = Fn,
1696
+ panEnabled: g = !0,
1697
+ zoomEnabled: I = !0,
1698
+ pinchZoomEnabled: l = !0,
1699
+ keyboardNavigation: L = !0,
1700
+ showControls: X = !1,
1701
+ controlsPosition: y = Wn,
1702
+ marqueeSelectionEnabled: E = !0,
1703
+ focusedNodeId: _,
1704
+ defaultFocusedNodeId: x = null,
1705
+ onFocusedNodeChange: G,
1706
+ collapsedNodeIds: ut,
1707
+ defaultCollapsedNodeIds: rt,
1708
+ onCollapsedNodeIdsChange: S,
1709
+ toggleCollapseOnNodeDoubleClick: D = !0,
1710
+ hiddenNodeIds: H,
1711
+ onNodeExpand: it,
1712
+ onNodeCollapse: q,
1713
+ searchQuery: V,
1714
+ hideUnmatchedSearch: at = !1,
1715
+ searchPredicate: O,
1716
+ highlightedNodeIds: A,
1717
+ highlightedEdgeIds: Y,
1718
+ highlightColor: J = "#f59e0b",
1719
+ highlightStrategy: dt,
1720
+ onSearchResultsChange: jt,
1721
+ selectedNodeIds: vt,
1722
+ selectedEdgeIds: _t,
1723
+ defaultSelectedNodeIds: Ft,
1724
+ defaultSelectedEdgeIds: Kt,
1725
+ onSelectionChange: ot,
1726
+ selectionMode: Q = "single",
1727
+ nodeSelectionEnabled: Lt = !0,
1728
+ edgeSelectionEnabled: Tt = !0,
1729
+ selectionColor: mt = Yn,
1730
+ edgeSelectionColor: Gt,
1731
+ layoutNodesOverride: De,
1732
+ routeEdgesOverride: me,
1733
+ renderBackground: ne,
1734
+ renderOverlay: ie,
1735
+ onError: ct,
1736
+ onNodeHoverChange: Pt,
1737
+ onEdgeHoverChange: Yt,
1738
+ onNodeClick: Rt,
1739
+ onEdgeClick: yt
1740
+ }, ze) => {
1741
+ const ye = k(() => Xn(T, v), [T, v]), lt = ye.minZoom, ht = ye.maxZoom, ge = En(i), Wt = cn().replace(/:/g, "-"), [oe, ve] = Et(
1742
+ () => qe({ ...Ke, ...c ?? {} }, lt, ht)
1743
+ ), [se, xe] = Et({
1744
+ nodeIds: Ft ?? [],
1745
+ edgeIds: Kt ?? []
1746
+ }), [we, Ne] = Et(
1747
+ x
1748
+ ), [kt, ae] = Et(null), [be, Ie] = Et(!1), xt = pt({
1749
+ active: !1,
1750
+ startX: 0,
1751
+ startY: 0,
1752
+ originX: 0,
1753
+ originY: 0
1754
+ }), wt = pt(/* @__PURE__ */ new Map()), bt = pt({
1755
+ active: !1,
1756
+ startDistance: 0,
1757
+ startZoom: 1,
1758
+ worldX: 0,
1759
+ worldY: 0
1760
+ }), Ot = pt(null), Dt = pt(null), $t = pt(!1), b = k(() => pn(ge), [ge]), gt = b.theme, Ee = gt.edgeColor ?? wr.edgeColor, Xt = gt.edgeWidth ?? wr.edgeWidth, _e = Gt ?? mt, Te = b.hoverNodeBorderColor ?? b.hoverEdgeColor, Pe = b.hoverNodeBothColor ?? b.hoverEdgeColor, Fe = gt.nodeBorderColor, Ye = gt.nodeBorderWidth ?? 0, Bt = b.showArrows, ce = `${Wt}-arrow`, Re = `${Wt}-arrow-hover`, Se = `${Wt}-arrow-hover-in`, Le = `${Wt}-arrow-selected`, F = k(
1761
+ () => qe(o ?? oe, lt, ht),
1762
+ [o, oe, ht, lt]
1763
+ ), t = pt(F);
1764
+ t.current = F;
1765
+ const a = pt(h);
1766
+ a.current = h;
1767
+ const f = k(
1768
+ () => ({
1769
+ nodeIds: vt ?? se.nodeIds,
1770
+ edgeIds: _t ?? se.edgeIds
1771
+ }),
1772
+ [vt, _t, se]
1773
+ ), R = pt(f);
1774
+ R.current = f;
1775
+ const M = _ !== void 0 ? _ : we, {
1776
+ collapsedIds: W,
1777
+ collapsedNodeSet: z,
1778
+ pendingExpansionNodeSet: j,
1779
+ updateCollapsedNodeIds: nt,
1780
+ setPendingExpansionNodeIds: B
1781
+ } = wn({
1782
+ collapsedNodeIds: ut,
1783
+ defaultCollapsedNodeIds: rt,
1784
+ onCollapsedNodeIdsChange: S
1785
+ }), Z = k(() => new Set(f.nodeIds), [f.nodeIds]), ft = k(() => new Set(f.edgeIds), [f.edgeIds]), $ = K(
1786
+ (n) => {
1787
+ var U;
1788
+ const d = t.current, p = typeof n == "function" ? n(d) : n, P = qe({ ...d, ...p }, lt, ht);
1789
+ return o || ve(P), (U = a.current) == null || U.call(a, P), P;
1790
+ },
1791
+ // viewport and onViewportChange are intentionally excluded: both are read
1792
+ // via refs so the callback stays stable across renders.
1793
+ [o, ht, lt]
1794
+ ), tt = K(
1795
+ (n) => {
1796
+ const d = R.current, p = typeof n == "function" ? n(d) : n;
1797
+ (vt == null || _t == null) && xe((P) => ({
1798
+ nodeIds: vt == null ? p.nodeIds : P.nodeIds,
1799
+ edgeIds: _t == null ? p.edgeIds : P.edgeIds
1800
+ })), ot == null || ot(p);
1801
+ },
1802
+ [ot, _t, vt]
1803
+ ), C = K(
1804
+ (n) => {
1805
+ _ === void 0 && Ne(n), G == null || G(n);
1806
+ },
1807
+ [_, G]
1808
+ ), {
1809
+ childNodeIdsByParent: Vt,
1810
+ effectiveHighlightedEdgeSet: We,
1811
+ effectiveHighlightedNodeSet: $e,
1812
+ handleNodeMeasure: Cr,
1813
+ positionedEdges: Mt,
1814
+ positionedNodes: st,
1815
+ visibleEdges: or,
1816
+ visibleNodesWithMeasuredSize: sr
1817
+ } = In({
1818
+ graph: e,
1819
+ config: b,
1820
+ mergedTheme: gt,
1821
+ collapsedIds: W,
1822
+ hiddenNodeIds: H,
1823
+ searchQuery: V,
1824
+ hideUnmatchedSearch: at,
1825
+ searchPredicate: O,
1826
+ highlightedNodeIds: A,
1827
+ highlightedEdgeIds: Y,
1828
+ highlightStrategy: dt,
1829
+ onSearchResultsChange: jt,
1830
+ layoutNodesOverride: De,
1831
+ routeEdgesOverride: me,
1832
+ onError: ct
1833
+ }), Ur = K(
1834
+ (n) => {
1835
+ if (!(!D || !((Vt.get(n.id) ?? []).length > 0) || j.has(n.id)))
1836
+ if (z.has(n.id))
1837
+ try {
1838
+ const p = it == null ? void 0 : it(n.id);
1839
+ if (p && typeof p == "object" && "then" in p) {
1840
+ B(
1841
+ (P) => P.includes(n.id) ? P : [...P, n.id]
1842
+ ), Promise.resolve(p).then(() => {
1843
+ nt((P) => P.filter((U) => U !== n.id));
1844
+ }).catch((P) => {
1845
+ ct == null || ct(Je(P), { graph: e, phase: "interaction" });
1846
+ }).finally(() => {
1847
+ B(
1848
+ (P) => P.filter((U) => U !== n.id)
1849
+ );
1850
+ });
1851
+ return;
1852
+ }
1853
+ nt((P) => P.filter((U) => U !== n.id));
1854
+ } catch (p) {
1855
+ ct == null || ct(Je(p), { graph: e, phase: "interaction" });
1856
+ }
1857
+ else {
1858
+ nt((p) => [...p, n.id]);
1859
+ try {
1860
+ q == null || q(n.id);
1861
+ } catch (p) {
1862
+ ct == null || ct(Je(p), { graph: e, phase: "interaction" });
1863
+ }
1864
+ }
1865
+ },
1866
+ [
1867
+ Vt,
1868
+ z,
1869
+ e,
1870
+ ct,
1871
+ q,
1872
+ it,
1873
+ j,
1874
+ B,
1875
+ D,
1876
+ nt
1877
+ ]
1878
+ );
1879
+ te(() => {
1880
+ const n = new Set(sr.map((p) => p.id)), d = new Set(or.map((p) => p.id));
1881
+ (f.nodeIds.some((p) => !n.has(p)) || f.edgeIds.some((p) => !d.has(p))) && tt({
1882
+ nodeIds: f.nodeIds.filter((p) => n.has(p)),
1883
+ edgeIds: f.edgeIds.filter((p) => d.has(p))
1884
+ }), M && !n.has(M) && C(null);
1885
+ }, [
1886
+ M,
1887
+ f,
1888
+ C,
1889
+ tt,
1890
+ or,
1891
+ sr
1892
+ ]);
1893
+ const It = k(
1894
+ () => new Map(st.map((n) => [n.id, n])),
1895
+ [st]
1896
+ ), ar = k(
1897
+ () => new Map(Mt.map((n) => [n.id, n])),
1898
+ [Mt]
1899
+ ), cr = k(() => Pn(st), [st]), ur = k(() => {
1900
+ const n = je(
1901
+ je(
1902
+ cr,
1903
+ Un(
1904
+ st,
1905
+ b.layout,
1906
+ b.layoutDirection,
1907
+ b.labels,
1908
+ b.autoLabels,
1909
+ b.labelOffset
1910
+ )
1911
+ ),
1912
+ Hn(Mt)
1913
+ );
1914
+ return n && Cn(n, $n);
1915
+ }, [
1916
+ b.autoLabels,
1917
+ b.labelOffset,
1918
+ b.labels,
1919
+ b.layout,
1920
+ b.layoutDirection,
1921
+ cr,
1922
+ Mt,
1923
+ st
1924
+ ]), ke = K(() => {
1925
+ var P;
1926
+ const n = Ot.current;
1927
+ if (!n)
1928
+ return { width: b.width, height: b.height };
1929
+ const p = ((P = n.parentElement) == null ? void 0 : P.getBoundingClientRect()) ?? n.getBoundingClientRect();
1930
+ return {
1931
+ width: p.width || b.width,
1932
+ height: p.height || b.height
1933
+ };
1934
+ }, [b.height, b.width]), Ct = K(
1935
+ (n = w) => {
1936
+ const { width: d, height: p } = ke();
1937
+ $(
1938
+ Rn(ur, d, p, n, lt, ht)
1939
+ );
1940
+ },
1941
+ [ur, w, ke, ht, lt, $]
1942
+ ), Oe = K(
1943
+ (n) => {
1944
+ const d = It.get(n);
1945
+ if (!d)
1946
+ return;
1947
+ const { width: p, height: P } = ke();
1948
+ $(Sn(d, p, P, F.zoom));
1949
+ },
1950
+ [ke, It, $, F.zoom]
1951
+ );
1952
+ un(
1953
+ ze,
1954
+ () => ({
1955
+ fitView: Ct,
1956
+ centerOnNode: Oe,
1957
+ zoomIn: () => $((n) => ({ zoom: n.zoom + m })),
1958
+ zoomOut: () => $((n) => ({ zoom: n.zoom - m })),
1959
+ zoomTo: (n) => $({ zoom: n }),
1960
+ resetViewport: () => $(Ke),
1961
+ getViewport: () => F,
1962
+ setViewport: $,
1963
+ clearSelection: () => tt(Ge)
1964
+ }),
1965
+ [Oe, Ct, tt, $, F, m]
1966
+ ), te(() => {
1967
+ $t.current = !1;
1968
+ }, [e]), te(() => {
1969
+ !u || $t.current || st.length === 0 || ($t.current = !0, Ct());
1970
+ }, [Ct, u, st.length]);
1971
+ const {
1972
+ hoveredEdgeId: lr,
1973
+ setHoveredEdgeId: fr,
1974
+ hoveredNodeId: Ut,
1975
+ setHoveredNodeId: Zt,
1976
+ focusedPath: Xe,
1977
+ setFocusedPath: At,
1978
+ pathHighlight: qt,
1979
+ hoveredNodeStates: Hr,
1980
+ edgesForRender: Kr
1981
+ } = xn(st, Mt, b.hoverHighlight), dr = pt(Ut);
1982
+ dr.current = Ut;
1983
+ const hr = k(
1984
+ () => ({
1985
+ graph: e,
1986
+ nodes: st,
1987
+ edges: Mt,
1988
+ config: b,
1989
+ viewport: F,
1990
+ selection: f
1991
+ }),
1992
+ [b, e, Mt, st, f, F]
1993
+ ), Jt = K(
1994
+ (n, d, p = "pointer") => {
1995
+ Pt == null || Pt(n, d, {
1996
+ viewport: F,
1997
+ selection: f,
1998
+ trigger: p
1999
+ });
2000
+ },
2001
+ [Pt, f, F]
2002
+ ), pr = K(
2003
+ (n, d, p = "pointer") => {
2004
+ Yt == null || Yt(n, d, {
2005
+ viewport: F,
2006
+ selection: f,
2007
+ trigger: p
2008
+ });
2009
+ },
2010
+ [Yt, f, F]
2011
+ ), Be = K(
2012
+ (n) => {
2013
+ if (!Lt) {
2014
+ C(n.id), Rt == null || Rt(n);
2015
+ return;
2016
+ }
2017
+ tt((d) => ({
2018
+ nodeIds: Rr(d.nodeIds, n.id, Q),
2019
+ edgeIds: Q === "single" ? [] : d.edgeIds
2020
+ })), C(n.id), Rt == null || Rt(n);
2021
+ },
2022
+ [Lt, Rt, Q, C, tt]
2023
+ ), Gr = K(
2024
+ (n) => {
2025
+ if (!Tt) {
2026
+ yt == null || yt(n);
2027
+ return;
2028
+ }
2029
+ tt((d) => ({
2030
+ nodeIds: Q === "single" ? [] : d.nodeIds,
2031
+ edgeIds: Rr(d.edgeIds, n.id, Q)
2032
+ })), yt == null || yt(n);
2033
+ },
2034
+ [Tt, yt, Q, tt]
2035
+ ), Vr = K(
2036
+ (n) => {
2037
+ var U, St;
2038
+ const d = n.target, p = !!d.closest('[data-graph-node-interactive="true"], [data-graph-edge-interactive="true"]'), P = Qe(Ot.current, n.clientX, n.clientY);
2039
+ if (!p && Q === "multiple" && E && n.shiftKey) {
2040
+ ae({
2041
+ startX: P.x,
2042
+ startY: P.y,
2043
+ endX: P.x,
2044
+ endY: P.y
2045
+ }), xt.current.active = !1;
2046
+ return;
2047
+ }
2048
+ if (n.pointerType === "touch" && (wt.current.set(n.pointerId, P), l && I && wt.current.size === 2)) {
2049
+ const [zt, et] = Array.from(wt.current.values()), Qt = Lr(zt, et);
2050
+ bt.current = {
2051
+ active: !0,
2052
+ startDistance: Sr(zt, et),
2053
+ startZoom: F.zoom,
2054
+ worldX: (Qt.x - F.x) / F.zoom,
2055
+ worldY: (Qt.y - F.y) / F.zoom
2056
+ }, xt.current.active = !1, (U = d.setPointerCapture) == null || U.call(d, n.pointerId);
2057
+ return;
2058
+ }
2059
+ !g || n.button !== 0 || p || (xt.current = {
2060
+ active: !0,
2061
+ startX: P.x,
2062
+ startY: P.y,
2063
+ originX: F.x,
2064
+ originY: F.y
2065
+ }, Ie(!0), (St = d.setPointerCapture) == null || St.call(d, n.pointerId));
2066
+ },
2067
+ [E, g, l, Q, F, I]
2068
+ ), Zr = K(
2069
+ (n) => {
2070
+ const d = Qe(Ot.current, n.clientX, n.clientY);
2071
+ if (n.pointerType === "touch" && wt.current.has(n.pointerId) && (wt.current.set(n.pointerId, d), bt.current.active && wt.current.size >= 2)) {
2072
+ const [p, P] = Array.from(wt.current.values()), U = Lr(p, P), St = Sr(p, P), zt = Ae(
2073
+ bt.current.startZoom * (St / Math.max(1, bt.current.startDistance)),
2074
+ lt,
2075
+ ht
2076
+ );
2077
+ $({
2078
+ zoom: zt,
2079
+ x: U.x - bt.current.worldX * zt,
2080
+ y: U.y - bt.current.worldY * zt
2081
+ });
2082
+ return;
2083
+ }
2084
+ if (kt) {
2085
+ ae(
2086
+ (p) => p && {
2087
+ ...p,
2088
+ endX: d.x,
2089
+ endY: d.y
2090
+ }
2091
+ );
2092
+ return;
2093
+ }
2094
+ !g || !xt.current.active || $({
2095
+ x: xt.current.originX + (d.x - xt.current.startX),
2096
+ y: xt.current.originY + (d.y - xt.current.startY)
2097
+ });
2098
+ },
2099
+ [g, ht, lt, kt, $]
2100
+ ), mr = K(
2101
+ (n) => {
2102
+ var d, p;
2103
+ if (wt.current.delete(n.pointerId), wt.current.size < 2 && (bt.current.active = !1), kt) {
2104
+ const P = kr(kt), U = {
2105
+ x: (P.x - F.x) / F.zoom,
2106
+ y: (P.y - F.y) / F.zoom,
2107
+ width: P.width / F.zoom,
2108
+ height: P.height / F.zoom
2109
+ }, St = st.filter((et) => {
2110
+ var le, gr;
2111
+ const Qt = ((le = et.size) == null ? void 0 : le.width) ?? 0, Ce = ((gr = et.size) == null ? void 0 : gr.height) ?? 0;
2112
+ return !(et.position.x + Qt < U.x || et.position.x > U.x + U.width || et.position.y + Ce < U.y || et.position.y > U.y + U.height);
2113
+ }).map((et) => et.id), zt = Mt.filter((et) => {
2114
+ const Qt = et.points.some(
2115
+ (le) => Or(le.x, le.y, U)
2116
+ ), Ce = !!et.labelPosition && Or(et.labelPosition.x, et.labelPosition.y, U);
2117
+ return Qt || Ce;
2118
+ }).map((et) => et.id);
2119
+ tt((et) => ({
2120
+ nodeIds: Array.from(/* @__PURE__ */ new Set([...et.nodeIds, ...St])),
2121
+ edgeIds: Array.from(/* @__PURE__ */ new Set([...et.edgeIds, ...zt]))
2122
+ })), ae(null);
2123
+ }
2124
+ xt.current.active = !1, Ie(!1), (p = (d = n.target).releasePointerCapture) == null || p.call(d, n.pointerId);
2125
+ },
2126
+ [Mt, st, kt, tt, F]
2127
+ ), qr = K(
2128
+ (n) => {
2129
+ if (!I || !Ot.current)
2130
+ return;
2131
+ n.preventDefault();
2132
+ const d = Qe(Ot.current, n.clientX, n.clientY), p = t.current, P = (d.x - p.x) / p.zoom, U = (d.y - p.y) / p.zoom, St = Ae(
2133
+ p.zoom + (n.deltaY < 0 ? m : -m),
2134
+ lt,
2135
+ ht
2136
+ );
2137
+ $({
2138
+ zoom: St,
2139
+ x: d.x - P * St,
2140
+ y: d.y - U * St
2141
+ });
2142
+ },
2143
+ [ht, lt, $, I, m]
2144
+ ), Jr = K(
2145
+ (n) => {
2146
+ if (L)
2147
+ switch (n.key) {
2148
+ case "+":
2149
+ case "=":
2150
+ n.preventDefault(), $((d) => ({ zoom: d.zoom + m }));
2151
+ break;
2152
+ case "-":
2153
+ case "_":
2154
+ n.preventDefault(), $((d) => ({ zoom: d.zoom - m }));
2155
+ break;
2156
+ case "0":
2157
+ n.preventDefault(), Ct();
2158
+ break;
2159
+ case "ArrowLeft":
2160
+ case "ArrowRight":
2161
+ case "ArrowUp":
2162
+ case "ArrowDown": {
2163
+ if (n.preventDefault(), M) {
2164
+ const d = It.get(M);
2165
+ if (d) {
2166
+ const p = n.key === "ArrowLeft" ? "left" : n.key === "ArrowRight" ? "right" : n.key === "ArrowUp" ? "up" : "down", P = Kn(d, st, p);
2167
+ P && (C(P.id), Oe(P.id));
2168
+ break;
2169
+ }
2170
+ }
2171
+ $((d) => n.key === "ArrowLeft" ? { x: d.x + 32 } : n.key === "ArrowRight" ? { x: d.x - 32 } : n.key === "ArrowUp" ? { y: d.y + 32 } : { y: d.y - 32 });
2172
+ break;
2173
+ }
2174
+ case "Enter":
2175
+ case " ": {
2176
+ if (!M)
2177
+ break;
2178
+ n.preventDefault();
2179
+ const d = It.get(M);
2180
+ d && Be(d);
2181
+ break;
2182
+ }
2183
+ case "Escape":
2184
+ n.preventDefault(), At(null), tt(Ge), C(null);
2185
+ break;
2186
+ }
2187
+ },
2188
+ [
2189
+ Oe,
2190
+ Ct,
2191
+ M,
2192
+ Be,
2193
+ L,
2194
+ It,
2195
+ st,
2196
+ At,
2197
+ C,
2198
+ tt,
2199
+ $,
2200
+ m
2201
+ ]
2202
+ ), Qr = K(
2203
+ (n) => {
2204
+ Zt(n);
2205
+ const d = It.get(n);
2206
+ d && Jt(d, !0);
2207
+ },
2208
+ [Jt, It, Zt]
2209
+ ), tn = K(() => {
2210
+ const n = dr.current;
2211
+ if (n) {
2212
+ const d = It.get(n);
2213
+ d && Jt(d, !1);
2214
+ }
2215
+ Zt(null), At(null);
2216
+ }, [Jt, It, At, Zt]), en = K(
2217
+ (n, d, p) => {
2218
+ At({ nodeId: n, sourceIndex: d, pathKey: p });
2219
+ const P = It.get(n);
2220
+ P && Jt(P, !0, "path");
2221
+ },
2222
+ [Jt, It, At]
2223
+ ), rn = K(() => {
2224
+ At(null);
2225
+ }, [At]), nn = K(
2226
+ (n, d) => {
2227
+ const p = ar.get(n);
2228
+ p && pr(p, d), b.hoverHighlight && (fr(d ? n : null), d && Zt(null));
2229
+ },
2230
+ [b.hoverHighlight, pr, ar, fr, Zt]
2231
+ ), on = k(
2232
+ () => ({
2233
+ background: gt.background,
2234
+ fontFamily: gt.fontFamily,
2235
+ cursor: be ? "grabbing" : g ? "grab" : "default",
2236
+ outline: "none",
2237
+ touchAction: g || I ? "none" : "auto",
2238
+ overflow: "hidden",
2239
+ userSelect: "none"
2240
+ }),
2241
+ [be, gt.background, gt.fontFamily, g, I]
2242
+ ), yr = k(
2243
+ () => Bn(b.width, b.height, y),
2244
+ [b.height, b.width, y]
2245
+ ), ue = kt ? kr(kt) : null, sn = X ? /* @__PURE__ */ N.jsx(
2246
+ "g",
2247
+ {
2248
+ "aria-label": "viewport-controls",
2249
+ transform: `translate(${yr.x}, ${yr.y})`,
2250
+ children: [
2251
+ {
2252
+ key: "zoom-in",
2253
+ label: "+",
2254
+ width: Ht,
2255
+ onClick: () => $((n) => ({ zoom: n.zoom + m }))
2256
+ },
2257
+ {
2258
+ key: "zoom-out",
2259
+ label: "−",
2260
+ width: Ht,
2261
+ onClick: () => $((n) => ({ zoom: n.zoom - m }))
2262
+ },
2263
+ {
2264
+ key: "fit-view",
2265
+ label: "Fit",
2266
+ width: ir,
2267
+ onClick: () => Ct()
2268
+ },
2269
+ {
2270
+ key: "reset-view",
2271
+ label: "1:1",
2272
+ width: ir,
2273
+ onClick: () => $(Ke)
2274
+ }
2275
+ ].reduce(
2276
+ (n, d) => ({
2277
+ x: n.x + d.width + Xr,
2278
+ controls: [...n.controls, { ...d, x: n.x }]
2279
+ }),
2280
+ { x: 0, controls: [] }
2281
+ ).controls.map((n) => /* @__PURE__ */ N.jsxs(
2282
+ "g",
2283
+ {
2284
+ transform: `translate(${n.x}, 0)`,
2285
+ role: "button",
2286
+ tabIndex: 0,
2287
+ onClick: (d) => {
2288
+ d.stopPropagation(), n.onClick();
2289
+ },
2290
+ onKeyDown: (d) => {
2291
+ (d.key === "Enter" || d.key === " ") && (d.preventDefault(), d.stopPropagation(), n.onClick());
2292
+ },
2293
+ children: [
2294
+ /* @__PURE__ */ N.jsx(
2295
+ "rect",
2296
+ {
2297
+ width: n.width,
2298
+ height: Ht,
2299
+ rx: 7,
2300
+ ry: 7,
2301
+ fill: "rgba(255,255,255,0.92)",
2302
+ stroke: "rgba(15,23,42,0.18)"
2303
+ }
2304
+ ),
2305
+ /* @__PURE__ */ N.jsx(
2306
+ "text",
2307
+ {
2308
+ x: n.width / 2,
2309
+ y: Ht / 2 + 4,
2310
+ textAnchor: "middle",
2311
+ fontSize: n.label.length > 1 ? 10 : 16,
2312
+ fontWeight: 700,
2313
+ fill: "#0f172a",
2314
+ children: n.label
2315
+ }
2316
+ )
2317
+ ]
2318
+ },
2319
+ n.key
2320
+ ))
2321
+ }
2322
+ ) : null;
2323
+ return /* @__PURE__ */ N.jsxs(
2324
+ "svg",
2325
+ {
2326
+ ref: Ot,
2327
+ width: b.width,
2328
+ height: b.height,
2329
+ role: "figure",
2330
+ "aria-label": "Graph",
2331
+ tabIndex: 0,
2332
+ style: on,
2333
+ onClick: (n) => {
2334
+ n.target === n.currentTarget && (tt(Ge), At(null), C(null));
2335
+ },
2336
+ onPointerDown: Vr,
2337
+ onPointerMove: Zr,
2338
+ onPointerUp: mr,
2339
+ onPointerLeave: mr,
2340
+ onWheel: qr,
2341
+ onKeyDown: Jr,
2342
+ children: [
2343
+ Bt ? /* @__PURE__ */ N.jsxs("defs", { children: [
2344
+ /* @__PURE__ */ N.jsx(
2345
+ "marker",
2346
+ {
2347
+ id: ce,
2348
+ viewBox: "0 0 10 10",
2349
+ refX: "6",
2350
+ refY: "5",
2351
+ markerWidth: "6",
2352
+ markerHeight: "6",
2353
+ orient: "auto-start-reverse",
2354
+ children: /* @__PURE__ */ N.jsx("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: Ee })
2355
+ }
2356
+ ),
2357
+ /* @__PURE__ */ N.jsx(
2358
+ "marker",
2359
+ {
2360
+ id: Re,
2361
+ viewBox: "0 0 10 10",
2362
+ refX: "6",
2363
+ refY: "5",
2364
+ markerWidth: "6",
2365
+ markerHeight: "6",
2366
+ orient: "auto-start-reverse",
2367
+ children: /* @__PURE__ */ N.jsx("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: b.hoverEdgeColor })
2368
+ }
2369
+ ),
2370
+ /* @__PURE__ */ N.jsx(
2371
+ "marker",
2372
+ {
2373
+ id: Se,
2374
+ viewBox: "0 0 10 10",
2375
+ refX: "6",
2376
+ refY: "5",
2377
+ markerWidth: "6",
2378
+ markerHeight: "6",
2379
+ orient: "auto-start-reverse",
2380
+ children: /* @__PURE__ */ N.jsx("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: b.hoverNodeOutColor })
2381
+ }
2382
+ ),
2383
+ /* @__PURE__ */ N.jsx(
2384
+ "marker",
2385
+ {
2386
+ id: Le,
2387
+ viewBox: "0 0 10 10",
2388
+ refX: "6",
2389
+ refY: "5",
2390
+ markerWidth: "6",
2391
+ markerHeight: "6",
2392
+ orient: "auto-start-reverse",
2393
+ children: /* @__PURE__ */ N.jsx("path", { d: "M 0 0 L 10 5 L 0 10 z", fill: _e })
2394
+ }
2395
+ )
2396
+ ] }) : null,
2397
+ /* @__PURE__ */ N.jsx("g", { transform: `translate(${F.x}, ${F.y}) scale(${F.zoom})`, children: /* @__PURE__ */ N.jsxs("g", { ref: Dt, children: [
2398
+ ne == null ? void 0 : ne(hr),
2399
+ /* @__PURE__ */ N.jsx(
2400
+ zn,
2401
+ {
2402
+ positionedNodes: st,
2403
+ layout: b.layout,
2404
+ layoutDirection: b.layoutDirection,
2405
+ labels: b.labels,
2406
+ autoLabels: b.autoLabels,
2407
+ labelOffset: b.labelOffset,
2408
+ pillBackground: b.labelPillBackground,
2409
+ pillBorderColor: b.labelPillBorderColor,
2410
+ pillTextColor: b.labelPillTextColor
2411
+ }
2412
+ ),
2413
+ /* @__PURE__ */ N.jsx("g", { "aria-label": "edges", children: Kr.map((n) => {
2414
+ const d = b.hoverHighlight && (lr === n.id || Ut && (n.source === Ut || n.target === Ut)) || (qt == null ? void 0 : qt.edges.has(n.id)), p = Ut && !lr && n.type !== "undirected" && n.target === Ut;
2415
+ return /* @__PURE__ */ N.jsx(
2416
+ s,
2417
+ {
2418
+ edge: n,
2419
+ color: Ee,
2420
+ width: Xt,
2421
+ curveEdges: b.curveEdges && b.routingStyle !== "orthogonal",
2422
+ curveStrength: b.curveStrength,
2423
+ markerEnd: Bt ? `url(#${ce})` : void 0,
2424
+ isHovered: d,
2425
+ isSelected: ft.has(n.id) || We.has(n.id),
2426
+ hoverColor: p ? b.hoverNodeOutColor : b.hoverEdgeColor,
2427
+ selectionColor: ft.has(n.id) ? _e : J,
2428
+ labelColor: b.edgeLabelColor,
2429
+ selectionMarker: Bt ? `url(#${Le})` : void 0,
2430
+ hoverMarker: Bt ? p ? `url(#${Se})` : `url(#${Re})` : void 0,
2431
+ hoverEnabled: b.hoverHighlight,
2432
+ hitStrokeWidth: Xt + 8,
2433
+ hoverStrokeWidth: Xt + 1.5,
2434
+ selectedStrokeWidth: Xt + 1.5,
2435
+ onHoverChange: (P) => nn(n.id, P),
2436
+ onClick: () => Gr(n)
2437
+ },
2438
+ n.id
2439
+ );
2440
+ }) }),
2441
+ /* @__PURE__ */ N.jsx("g", { "aria-label": "nodes", children: st.map((n) => /* @__PURE__ */ N.jsx(
2442
+ Yr,
2443
+ {
2444
+ node: n,
2445
+ Vertex: r,
2446
+ isSelected: Z.has(n.id),
2447
+ isFocused: M === n.id,
2448
+ isHighlighted: $e.has(n.id),
2449
+ activePathKey: Xe == null ? void 0 : Xe.pathKey,
2450
+ activePathNodeIds: qt == null ? void 0 : qt.nodes,
2451
+ highlightColor: J,
2452
+ selectionColor: mt,
2453
+ nodeBorderColor: Fe,
2454
+ nodeBorderWidth: Ye,
2455
+ hoverNodeBorderColor: Te,
2456
+ hoverNodeBothColor: Pe,
2457
+ hoverNodeInColor: b.hoverNodeInColor,
2458
+ hoverNodeOutColor: b.hoverNodeOutColor,
2459
+ hoverNodeHighlight: b.hoverNodeHighlight,
2460
+ hoveredNodeStates: Hr ?? void 0,
2461
+ onNodeMeasure: Cr,
2462
+ onNodeFocus: C,
2463
+ onNodeClick: Be,
2464
+ onNodeDoubleClick: Ur,
2465
+ onNodeMouseEnter: Qr,
2466
+ onNodeMouseLeave: tn,
2467
+ onPathHover: en,
2468
+ onPathLeave: rn
2469
+ },
2470
+ n.id
2471
+ )) }),
2472
+ ie == null ? void 0 : ie(hr)
2473
+ ] }) }),
2474
+ ue ? /* @__PURE__ */ N.jsx(
2475
+ "rect",
2476
+ {
2477
+ x: ue.x,
2478
+ y: ue.y,
2479
+ width: ue.width,
2480
+ height: ue.height,
2481
+ fill: "rgba(59, 130, 246, 0.12)",
2482
+ stroke: "rgba(59, 130, 246, 0.8)",
2483
+ strokeDasharray: "6 4",
2484
+ pointerEvents: "none"
2485
+ }
2486
+ ) : null,
2487
+ sn
2488
+ ]
2489
+ }
2490
+ );
2491
+ }, Br = re.memo(
2492
+ re.forwardRef(Gn)
2493
+ );
2494
+ Br.displayName = "Graph";
2495
+ const Jn = Br;
2496
+ export {
2497
+ Ln as EdgePath,
2498
+ ei as EdgeType,
2499
+ Jn as Graph,
2500
+ ri as LayoutDirection,
2501
+ ni as LayoutType,
2502
+ ii as NodeSide,
2503
+ si as buildEdgePath,
2504
+ ai as fromNxGraph,
2505
+ jr as groupPositionedNodesByColumn,
2506
+ ci as layoutNodes,
2507
+ ui as renderGraphToSvg,
2508
+ li as routeEdges
2509
+ };