@oomol-lab/open-flow 0.1.0-beta.90 → 0.1.0-beta.91

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 (37) hide show
  1. package/dist/browser/{FlowCanvas-C4iuvVKB.js → FlowCanvas-CZEphIhX.js} +169 -2324
  2. package/dist/browser/{createResourceDialog-BstGO0m4.js → createResourceDialog-CJbZa2gA.js} +2 -2
  3. package/dist/browser/{dialog-Bi-MVTGj.js → dialog-E1WkapJU.js} +10 -2
  4. package/dist/browser/{exportPng-DMsB9ku_.js → exportPng-c4or5th8.js} +2 -2
  5. package/dist/browser/{flowChanges-SKYJBr6X.js → flowChanges-DsLZdENA.js} +20 -37
  6. package/dist/browser/{flowWorkspace-4UHRaHcz.js → flowWorkspace-CxLQWUdj.js} +54 -19
  7. package/dist/browser/{markdownContent-B75ojl0E.js → markdownContent-BsdTdwBU.js} +1 -1
  8. package/dist/browser/preview.js +231 -68
  9. package/dist/browser/workbench.js +6 -6
  10. package/dist/browser/{workbenchSelect-CHOeceKA.js → workbenchSelect-BfQfMWuY.js} +1 -1
  11. package/dist/browser/{wrapLayout-DU5HG1qH.js → wrapLayout-ZOG4AikN.js} +2493 -200
  12. package/dist/command/index.js +58 -55
  13. package/dist/common/control-api-conformance.js +896 -8
  14. package/dist/common/control-api.js +896 -8
  15. package/dist/common/control-requests.js +17 -6
  16. package/dist/common/decision.js +10 -2
  17. package/dist/common/flow-authoring.js +896 -8
  18. package/dist/common/flow-change.js +896 -8
  19. package/dist/common/flow-encoding.js +896 -8
  20. package/dist/common/flow-semantics.js +10 -2
  21. package/dist/common/integration-trigger.js +10 -2
  22. package/dist/common/licenses.md +2 -0
  23. package/dist/common/mcp.js +896 -8
  24. package/dist/common/openapi.js +10 -2
  25. package/dist/common/poll-trigger.js +10 -2
  26. package/dist/common/provider-triggers.js +1 -1
  27. package/dist/common/scheduler.js +10 -2
  28. package/dist/common/webhook-trigger.js +890 -2
  29. package/dist/common/workflow.js +14 -3
  30. package/dist/render/browser/runtime.js +966 -59
  31. package/dist/render/node/index.js +792 -4
  32. package/package.json +1 -1
  33. package/src/control/common/authoringTools.ts +4 -2
  34. package/src/flow/common/schemaComparer.ts +12 -2
  35. package/src/json-schema-subset/checker/equals.ts +3 -0
  36. package/src/trigger/providers/catalog.generated.json +9 -1
  37. package/src/workflow/common/workflow.ts +4 -3
@@ -1,8 +1,8 @@
1
1
  import { o as __toESM, t as __commonJSMin } from "./rolldown-runtime-CEgmsyvS.js";
2
- import { $ as waitBranchDescription, A as DropdownMenuItem, B as CompositeItem, D as DropdownMenuCheckboxItem, E as DropdownMenu, G as MenuPopup, H as MenuRoot, J as ContextMenuRootContext, K as MenuItem, M as DropdownMenuRadioGroup, N as DropdownMenuRadioItem, O as DropdownMenuContent, P as DropdownMenuSeparator, Q as uiLocales, R as DropdownMenuTrigger, U as MenuPositioner, W as MenuPortal, X as MenuRootContext, Y as useContextMenuRootContext, Z as useMenuRootContext, a as CompositeRoot, at as ja_default, c as PopoverContent, ct as I18n, dt as useAriaLabelledBy, f as PopoverTitle, ft as useFieldItemContext, h as ScrollArea, ht as IconThemeContext, i as Textarea, it as ko_default, j as DropdownMenuLabel, k as DropdownMenuGroup, m as NativeScrollArea, n as wrapLayout, nt as zh_CN_default, o as ACTIVE_COMPOSITE_ITEM, ot as fr_default, p as PopoverTrigger, q as MenuGroup, r as canvasDirection, rt as ru_default, s as Popover, st as en_default, t as layoutAxes, tt as zh_TW_default, ut as Checkbox, v as ContentIcon, z as findRootOwnerId } from "./wrapLayout-DU5HG1qH.js";
2
+ import { $ as useMenuRootContext, A as DropdownMenuContent, B as DropdownMenuTrigger, F as DropdownMenuRadioItem, G as MenuPositioner, H as CompositeItem, I as DropdownMenuSeparator, J as MenuItem, K as MenuPortal, M as DropdownMenuItem, N as DropdownMenuLabel, O as DropdownMenu, P as DropdownMenuRadioGroup, Q as MenuRootContext, V as findRootOwnerId, W as MenuRoot, X as ContextMenuRootContext, Y as MenuGroup, Z as useContextMenuRootContext, _ as ScrollArea, _t as IconThemeContext, a as canvasDirection, at as ru_default, b as ContentIcon, c as ACTIVE_COMPOSITE_ITEM, ct as fr_default, et as uiLocales, ft as Checkbox, g as NativeScrollArea, h as PopoverTrigger, i as ie, it as zh_CN_default, j as DropdownMenuGroup, k as DropdownMenuCheckboxItem, l as Popover, lt as en_default, m as PopoverTitle, mt as useFieldItemContext, n as wrapLayout, o as Textarea, ot as ko_default, pt as useAriaLabelledBy, q as MenuPopup, r as graphLayout, rt as zh_TW_default, s as CompositeRoot, st as ja_default, t as layoutAxes, tt as waitBranchDescription, u as PopoverContent, ut as I18n } from "./wrapLayout-ZOG4AikN.js";
3
3
  import { a as derive, c as strictEqual, i as compute, l as val, n as attachSetter, r as combine, s as readonlyVal } from "./dist-bO8nvHFH.js";
4
4
  import { c as useLang, i as isString, l as useTranslate, n as isBoolean, o as I18nProvider, r as isPlainObject, t as isArray$1, u as useVal } from "./dist-BFmpkX4P.js";
5
- import { A as string, Bn as transitionStatusMapping, Br as useStableCallback, C as literal, Cr as cn$1, Dn as getTarget, En as contains, Er as useRenderElement, Fn as createLucideIcon, Fr as formatErrorMessage, J as SHIFT, Kn as cancelOpen, Lr as useIsoLayoutEffect, Mn as ownerDocument, Mr as useButton, Nn as useLabelableId, Or as EMPTY_OBJECT, Sn as stopEvent$1, T as number, Tr as clsx, Un as useValueChanged, Wn as createChangeEventDetails, Yt as addEventListener, _r as fieldValidityMapping, br as useControlled, cr as triggerPress, dr as useFormContext, fr as useRegisterFieldControl, gt as serializeValue, hr as useId$1, i as TooltipTrigger, jr as useMergedRefs, k as strictObject, kr as NOOP, mr as useBaseUiId, n as TooltipContent, p as timeZoneOffsetMinutes, pr as useFieldRootContext, pt as pressableTriggerOpenStateMapping, r as TooltipProvider, rr as none$1, sn as useTimeout, t as Tooltip, tn as require_with_selector, ur as useLabelableContext, vr as visuallyHidden, xr as Button, y as discriminatedUnion, yr as visuallyHiddenInput } from "./tooltip-BZ6tpqnr.js";
5
+ import { A as string, Bn as transitionStatusMapping, Br as useStableCallback, C as literal, Cr as cn, Dn as getTarget, En as contains, Er as useRenderElement, Fn as createLucideIcon, Fr as formatErrorMessage, J as SHIFT, Kn as cancelOpen, Lr as useIsoLayoutEffect, Mn as ownerDocument, Mr as useButton, Nn as useLabelableId, Or as EMPTY_OBJECT, Sn as stopEvent$1, T as number, Tr as clsx, Un as useValueChanged, Wn as createChangeEventDetails, Yt as addEventListener, _r as fieldValidityMapping, br as useControlled, cr as triggerPress, dr as useFormContext, fr as useRegisterFieldControl, gt as serializeValue, hr as useId$1, i as TooltipTrigger, jr as useMergedRefs, k as strictObject, kr as NOOP, mr as useBaseUiId, n as TooltipContent, p as timeZoneOffsetMinutes, pr as useFieldRootContext, pt as pressableTriggerOpenStateMapping, r as TooltipProvider, rr as none$1, sn as useTimeout, t as Tooltip, tn as require_with_selector, ur as useLabelableContext, vr as visuallyHidden, xr as Button, y as discriminatedUnion, yr as visuallyHiddenInput } from "./tooltip-BZ6tpqnr.js";
6
6
  import { r as resolveUiLanguage } from "./languages-gYzoQqCi.js";
7
7
  import * as React from "react";
8
8
  import reactExports, { Children, Suspense, createContext, forwardRef, isValidElement, lazy, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
@@ -261,2242 +261,6 @@ var ReactiveMapImpl = class extends Map {
261
261
  };
262
262
  var reactiveMap = (entries, config) => new ReactiveMapImpl(entries, config);
263
263
  //#endregion
264
- //#region ../../node_modules/.bun/@dagrejs+dagre@3.1.1/node_modules/@dagrejs/dagre/dist/dagre.esm.js
265
- var Te = Object.defineProperty;
266
- var In = (e, n, t) => n in e ? Te(e, n, {
267
- enumerable: !0,
268
- configurable: !0,
269
- writable: !0,
270
- value: t
271
- }) : e[n] = t;
272
- var Sn = (e, n) => {
273
- for (var t in n) Te(e, t, {
274
- get: n[t],
275
- enumerable: !0
276
- });
277
- };
278
- var je = (e, n, t) => In(e, typeof n != "symbol" ? n + "" : n, t);
279
- var ie = {};
280
- Sn(ie, {
281
- Graph: () => T$1,
282
- alg: () => H
283
- });
284
- var Mn = Object.defineProperty;
285
- var Se = (e, n) => {
286
- for (var t in n) Mn(e, t, {
287
- get: n[t],
288
- enumerable: !0
289
- });
290
- };
291
- var Q = class {
292
- constructor(e) {
293
- this._isDirected = !0, this._isMultigraph = !1, this._isCompound = !1, this._nodes = {}, this._in = {}, this._preds = {}, this._out = {}, this._sucs = {}, this._edgeObjs = {}, this._edgeLabels = {}, this._nodeCount = 0, this._edgeCount = 0, this._defaultNodeLabelFn = () => {}, this._defaultEdgeLabelFn = () => {}, e && (this._isDirected = "directed" in e ? e.directed : !0, this._isMultigraph = "multigraph" in e ? e.multigraph : !1, this._isCompound = "compound" in e ? e.compound : !1), this._isCompound && (this._parent = {}, this._children = {}, this._children["\0"] = {});
294
- }
295
- isDirected() {
296
- return this._isDirected;
297
- }
298
- isMultigraph() {
299
- return this._isMultigraph;
300
- }
301
- isCompound() {
302
- return this._isCompound;
303
- }
304
- setGraph(e) {
305
- return this._label = e, this;
306
- }
307
- graph() {
308
- return this._label;
309
- }
310
- setDefaultNodeLabel(e) {
311
- return typeof e != "function" ? this._defaultNodeLabelFn = () => e : this._defaultNodeLabelFn = e, this;
312
- }
313
- nodeCount() {
314
- return this._nodeCount;
315
- }
316
- nodes() {
317
- return Object.keys(this._nodes);
318
- }
319
- sources() {
320
- return this.nodes().filter((e) => Object.keys(this._in[e]).length === 0);
321
- }
322
- sinks() {
323
- return this.nodes().filter((e) => Object.keys(this._out[e]).length === 0);
324
- }
325
- setNodes(e, n) {
326
- return e.forEach((t) => {
327
- n !== void 0 ? this.setNode(t, n) : this.setNode(t);
328
- }), this;
329
- }
330
- setNode(e, n) {
331
- return e in this._nodes ? (arguments.length > 1 && (this._nodes[e] = n), this) : (this._nodes[e] = arguments.length > 1 ? n : this._defaultNodeLabelFn(e), this._isCompound && (this._parent[e] = "\0", this._children[e] = {}, this._children["\0"][e] = !0), this._in[e] = {}, this._preds[e] = {}, this._out[e] = {}, this._sucs[e] = {}, ++this._nodeCount, this);
332
- }
333
- node(e) {
334
- return this._nodes[e];
335
- }
336
- hasNode(e) {
337
- return e in this._nodes;
338
- }
339
- removeNode(e) {
340
- if (e in this._nodes) {
341
- let n = (t) => this.removeEdge(this._edgeObjs[t]);
342
- delete this._nodes[e], this._isCompound && (this._removeFromParentsChildList(e), delete this._parent[e], this.children(e).forEach((t) => {
343
- this.setParent(t);
344
- }), delete this._children[e]), Object.keys(this._in[e]).forEach(n), delete this._in[e], delete this._preds[e], Object.keys(this._out[e]).forEach(n), delete this._out[e], delete this._sucs[e], --this._nodeCount;
345
- }
346
- return this;
347
- }
348
- setParent(e, n) {
349
- if (!this._isCompound) throw new Error("Cannot set parent in a non-compound graph");
350
- if (n === void 0) n = "\0";
351
- else {
352
- n += "";
353
- for (let t = n; t !== void 0; t = this.parent(t)) if (t === e) throw new Error("Setting " + n + " as parent of " + e + " would create a cycle");
354
- this.setNode(n);
355
- }
356
- return this.setNode(e), this._removeFromParentsChildList(e), this._parent[e] = n, this._children[n][e] = !0, this;
357
- }
358
- parent(e) {
359
- if (this._isCompound) {
360
- let n = this._parent[e];
361
- if (n !== "\0") return n;
362
- }
363
- }
364
- children(e = "\0") {
365
- if (this._isCompound) {
366
- let n = this._children[e];
367
- if (n) return Object.keys(n);
368
- } else {
369
- if (e === "\0") return this.nodes();
370
- if (this.hasNode(e)) return [];
371
- }
372
- return [];
373
- }
374
- predecessors(e) {
375
- let n = this._preds[e];
376
- if (n) return Object.keys(n);
377
- }
378
- successors(e) {
379
- let n = this._sucs[e];
380
- if (n) return Object.keys(n);
381
- }
382
- neighbors(e) {
383
- let n = this.predecessors(e);
384
- if (n) {
385
- let t = new Set(n), r = this.successors(e);
386
- if (r) for (let o of r) t.add(o);
387
- return Array.from(t.values());
388
- }
389
- }
390
- isLeaf(e) {
391
- var n;
392
- let t;
393
- return this.isDirected() ? t = this.successors(e) : t = this.neighbors(e), ((n = t == null ? void 0 : t.length) != null ? n : 0) === 0;
394
- }
395
- filterNodes(e) {
396
- let n = new this.constructor({
397
- directed: this._isDirected,
398
- multigraph: this._isMultigraph,
399
- compound: this._isCompound
400
- });
401
- n.setGraph(this.graph()), Object.entries(this._nodes).forEach(([o, i]) => {
402
- e(o) && n.setNode(o, i);
403
- }), Object.values(this._edgeObjs).forEach((o) => {
404
- n.hasNode(o.v) && n.hasNode(o.w) && n.setEdge(o, this.edge(o));
405
- });
406
- let t = {}, r = (o) => {
407
- let i = this.parent(o);
408
- return !i || n.hasNode(i) ? (t[o] = i, i) : i in t ? t[i] : r(i);
409
- };
410
- return this._isCompound && n.nodes().forEach((o) => n.setParent(o, r(o))), n;
411
- }
412
- setDefaultEdgeLabel(e) {
413
- return typeof e != "function" ? this._defaultEdgeLabelFn = () => e : this._defaultEdgeLabelFn = e, this;
414
- }
415
- edgeCount() {
416
- return this._edgeCount;
417
- }
418
- edges() {
419
- return Object.values(this._edgeObjs);
420
- }
421
- setPath(e, n) {
422
- return e.reduce((t, r) => (n !== void 0 ? this.setEdge(t, r, n) : this.setEdge(t, r), r)), this;
423
- }
424
- setEdge(e, n, t, r) {
425
- let o, i, s, a, l = !1;
426
- typeof e == "object" && e !== null && "v" in e ? (o = e.v, i = e.w, s = e.name, arguments.length === 2 && (a = n, l = !0)) : (o = e, i = n, s = r, arguments.length > 2 && (a = t, l = !0)), o = "" + o, i = "" + i, s !== void 0 && (s = "" + s);
427
- let u = z(this._isDirected, o, i, s);
428
- if (u in this._edgeLabels) return l && (this._edgeLabels[u] = a), this;
429
- if (s !== void 0 && !this._isMultigraph) throw new Error("Cannot set a named edge when isMultigraph = false");
430
- this.setNode(o), this.setNode(i), this._edgeLabels[u] = l ? a : this._defaultEdgeLabelFn(o, i, s);
431
- let d = Pn(this._isDirected, o, i, s);
432
- return o = d.v, i = d.w, Object.freeze(d), this._edgeObjs[u] = d, Re(this._preds[i], o), Re(this._sucs[o], i), this._in[i][u] = d, this._out[o][u] = d, this._edgeCount++, this;
433
- }
434
- edge(e, n, t) {
435
- let r = arguments.length === 1 ? oe(this._isDirected, e) : z(this._isDirected, e, n, t);
436
- return this._edgeLabels[r];
437
- }
438
- edgeAsObj(e, n, t) {
439
- let r = arguments.length === 1 ? this.edge(e) : this.edge(e, n, t);
440
- return typeof r != "object" || r === null ? { label: r } : r;
441
- }
442
- hasEdge(e, n, t) {
443
- return (arguments.length === 1 ? oe(this._isDirected, e) : z(this._isDirected, e, n, t)) in this._edgeLabels;
444
- }
445
- removeEdge(e, n, t) {
446
- let r = arguments.length === 1 ? oe(this._isDirected, e) : z(this._isDirected, e, n, t), o = this._edgeObjs[r];
447
- if (o) {
448
- let i = o.v, s = o.w;
449
- delete this._edgeLabels[r], delete this._edgeObjs[r], Ie(this._preds[s], i), Ie(this._sucs[i], s), delete this._in[s][r], delete this._out[i][r], this._edgeCount--;
450
- }
451
- return this;
452
- }
453
- inEdges(e, n) {
454
- return this.isDirected() ? this.filterEdges(this._in[e], e, n) : this.nodeEdges(e, n);
455
- }
456
- outEdges(e, n) {
457
- return this.isDirected() ? this.filterEdges(this._out[e], e, n) : this.nodeEdges(e, n);
458
- }
459
- nodeEdges(e, n) {
460
- if (e in this._nodes) return this.filterEdges({
461
- ...this._in[e],
462
- ...this._out[e]
463
- }, e, n);
464
- }
465
- _removeFromParentsChildList(e) {
466
- delete this._children[this._parent[e]][e];
467
- }
468
- filterEdges(e, n, t) {
469
- if (!e) return;
470
- let r = Object.values(e);
471
- return t ? r.filter((o) => o.v === n && o.w === t || o.v === t && o.w === n) : r;
472
- }
473
- };
474
- function Re(e, n) {
475
- e[n] ? e[n]++ : e[n] = 1;
476
- }
477
- function Ie(e, n) {
478
- e[n] !== void 0 && !--e[n] && delete e[n];
479
- }
480
- function z(e, n, t, r) {
481
- let o = "" + n, i = "" + t;
482
- if (!e && o > i) {
483
- let s = o;
484
- o = i, i = s;
485
- }
486
- return o + "" + i + "" + (r === void 0 ? "\0" : r);
487
- }
488
- function Pn(e, n, t, r) {
489
- let o = "" + n, i = "" + t;
490
- if (!e && o > i) {
491
- let a = o;
492
- o = i, i = a;
493
- }
494
- let s = {
495
- v: o,
496
- w: i
497
- };
498
- return r && (s.name = r), s;
499
- }
500
- function oe(e, n) {
501
- return z(e, n.v, n.w, n.name);
502
- }
503
- Se({}, {
504
- read: () => Yn,
505
- write: () => An
506
- });
507
- function An(e) {
508
- let n = {
509
- options: {
510
- directed: e.isDirected(),
511
- multigraph: e.isMultigraph(),
512
- compound: e.isCompound()
513
- },
514
- nodes: Vn(e),
515
- edges: Dn(e)
516
- }, t = e.graph();
517
- return t !== void 0 && (n.value = structuredClone(t)), n;
518
- }
519
- function Vn(e) {
520
- return e.nodes().map((n) => {
521
- let t = e.node(n), r = e.parent(n), o = { v: n };
522
- return t !== void 0 && (o.value = t), r !== void 0 && (o.parent = r), o;
523
- });
524
- }
525
- function Dn(e) {
526
- return e.edges().map((n) => {
527
- let t = e.edge(n), r = {
528
- v: n.v,
529
- w: n.w
530
- };
531
- return n.name !== void 0 && (r.name = n.name), t !== void 0 && (r.value = t), r;
532
- });
533
- }
534
- function Yn(e) {
535
- let n = new Q(e.options);
536
- return e.value !== void 0 && n.setGraph(e.value), e.nodes.forEach((t) => {
537
- n.setNode(t.v, t.value), t.parent && n.setParent(t.v, t.parent);
538
- }), e.edges.forEach((t) => {
539
- n.setEdge({
540
- v: t.v,
541
- w: t.w,
542
- name: t.name
543
- }, t.value);
544
- }), n;
545
- }
546
- var H = {};
547
- Se(H, {
548
- CycleException: () => K,
549
- bellmanFord: () => Me,
550
- components: () => Xn,
551
- dijkstra: () => J,
552
- dijkstraAll: () => qn,
553
- findCycles: () => $n,
554
- floydWarshall: () => Jn,
555
- isAcyclic: () => Qn,
556
- postorder: () => et,
557
- preorder: () => nt,
558
- prim: () => tt,
559
- shortestPaths: () => rt,
560
- tarjan: () => Fe,
561
- topsort: () => Ae
562
- });
563
- var Wn = () => 1;
564
- function Me(e, n, t, r) {
565
- return Bn(e, String(n), t || Wn, r || function(o) {
566
- var i;
567
- return (i = e.outEdges(o)) != null ? i : [];
568
- });
569
- }
570
- function Bn(e, n, t, r) {
571
- let o = {}, i, s = 0, a = e.nodes(), l = function(c) {
572
- let f = o[c.v], h = o[c.w];
573
- if (!f || !h) return;
574
- let p = t(c);
575
- f.distance + p < h.distance && (o[c.w] = {
576
- distance: f.distance + p,
577
- predecessor: c.v
578
- }, i = !0);
579
- }, u = function() {
580
- a.forEach(function(c) {
581
- r(c).forEach(function(f) {
582
- let h = f.v === c ? f.v : f.w, p = h === f.v ? f.w : f.v;
583
- l({
584
- v: h,
585
- w: p
586
- });
587
- });
588
- });
589
- };
590
- a.forEach(function(c) {
591
- let f = c === n ? 0 : Number.POSITIVE_INFINITY;
592
- o[c] = {
593
- distance: f,
594
- predecessor: ""
595
- };
596
- });
597
- let d = a.length;
598
- for (let c = 1; c < d && (i = !1, s++, u(), !!i); c++);
599
- if (s === d - 1 && (i = !1, u(), i)) throw new Error("The graph contains a negative weight cycle");
600
- return o;
601
- }
602
- function Xn(e) {
603
- let n = {}, t = [], r;
604
- function o(i) {
605
- var s, a;
606
- i in n || (n[i] = !0, r.push(i), (s = e.successors(i)) == null || s.forEach(o), (a = e.predecessors(i)) == null || a.forEach(o));
607
- }
608
- return e.nodes().forEach(function(i) {
609
- r = [], o(i), r.length && t.push(r);
610
- }), t;
611
- }
612
- var Pe = class {
613
- constructor() {
614
- this._arr = [], this._keyIndices = {};
615
- }
616
- size() {
617
- return this._arr.length;
618
- }
619
- keys() {
620
- return this._arr.map((e) => e.key);
621
- }
622
- has(e) {
623
- return e in this._keyIndices;
624
- }
625
- priority(e) {
626
- let n = this._keyIndices[e];
627
- if (n !== void 0) return this._arr[n].priority;
628
- }
629
- min() {
630
- if (this.size() === 0) throw new Error("Queue underflow");
631
- return this._arr[0].key;
632
- }
633
- add(e, n) {
634
- let t = this._keyIndices, r = String(e);
635
- if (!(r in t)) {
636
- let o = this._arr, i = o.length;
637
- return t[r] = i, o.push({
638
- key: r,
639
- priority: n
640
- }), this._decrease(i), !0;
641
- }
642
- return !1;
643
- }
644
- removeMin() {
645
- if (this.size() === 0) throw new Error("Queue underflow");
646
- this._swap(0, this._arr.length - 1);
647
- let e = this._arr.pop();
648
- return delete this._keyIndices[e.key], this._heapify(0), e.key;
649
- }
650
- decrease(e, n) {
651
- let t = this._keyIndices[e];
652
- if (t === void 0) throw new Error(`Key not found: ${e}`);
653
- let r = this._arr[t].priority;
654
- if (n > r) throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${n}`);
655
- this._arr[t].priority = n, this._decrease(t);
656
- }
657
- _heapify(e) {
658
- let n = this._arr, t = 2 * e, r = t + 1, o = e;
659
- t < n.length && (o = n[t].priority < n[o].priority ? t : o, r < n.length && (o = n[r].priority < n[o].priority ? r : o), o !== e && (this._swap(e, o), this._heapify(o)));
660
- }
661
- _decrease(e) {
662
- let n = this._arr, t = n[e].priority, r;
663
- for (; e !== 0 && (r = e >> 1, !(n[r].priority < t));) this._swap(e, r), e = r;
664
- }
665
- _swap(e, n) {
666
- let t = this._arr, r = this._keyIndices, o = t[e], i = t[n];
667
- t[e] = i, t[n] = o, r[i.key] = e, r[o.key] = n;
668
- }
669
- };
670
- var zn = () => 1;
671
- function J(e, n, t, r) {
672
- let o = function(i) {
673
- var s;
674
- return (s = e.outEdges(i)) != null ? s : [];
675
- };
676
- return Hn(e, String(n), t || zn, r || o);
677
- }
678
- function Hn(e, n, t, r) {
679
- let o = {}, i = new Pe(), s, a, l = function(u) {
680
- let d = u.v !== s ? u.v : u.w, c = o[d];
681
- if (!c) return;
682
- let f = t(u), h = a.distance + f;
683
- if (f < 0) throw new Error("dijkstra does not allow negative edge weights. Bad edge: " + u + " Weight: " + f);
684
- h < c.distance && (c.distance = h, c.predecessor = s, i.decrease(d, h));
685
- };
686
- for (e.nodes().forEach(function(u) {
687
- let d = u === n ? 0 : Number.POSITIVE_INFINITY;
688
- o[u] = {
689
- distance: d,
690
- predecessor: ""
691
- }, i.add(u, d);
692
- }); i.size() > 0;) {
693
- s = i.removeMin();
694
- let u = o[s];
695
- if (!u || u.distance === Number.POSITIVE_INFINITY) break;
696
- a = u, r(s).forEach(l);
697
- }
698
- return o;
699
- }
700
- function qn(e, n, t) {
701
- return e.nodes().reduce(function(r, o) {
702
- return r[o] = J(e, o, n, t), r;
703
- }, {});
704
- }
705
- function Fe(e) {
706
- let n = 0, t = [], r = {}, o = [];
707
- function i(s) {
708
- var a;
709
- let l = r[s] = {
710
- onStack: !0,
711
- lowlink: n,
712
- index: n++
713
- };
714
- if (t.push(s), (a = e.successors(s)) == null || a.forEach(function(u) {
715
- if (u in r) {
716
- let d = r[u];
717
- d != null && d.onStack && (l.lowlink = Math.min(l.lowlink, d.index));
718
- } else {
719
- i(u);
720
- let d = r[u];
721
- d && (l.lowlink = Math.min(l.lowlink, d.lowlink));
722
- }
723
- }), l.lowlink === l.index) {
724
- let u = [], d;
725
- do {
726
- d = t.pop();
727
- let c = r[d];
728
- c && (c.onStack = !1), u.push(d);
729
- } while (s !== d);
730
- o.push(u);
731
- }
732
- }
733
- return e.nodes().forEach(function(s) {
734
- s in r || i(s);
735
- }), o;
736
- }
737
- function $n(e) {
738
- return Fe(e).filter(function(n) {
739
- var t;
740
- let r = n[0];
741
- return r ? n.length > 1 || n.length === 1 && ((t = e.outEdges(r, r)) != null ? t : []).length > 0 : !1;
742
- });
743
- }
744
- var Un = () => 1;
745
- function Jn(e, n, t) {
746
- return Kn(e, n || Un, t || function(r) {
747
- var o;
748
- return (o = e.outEdges(r)) != null ? o : [];
749
- });
750
- }
751
- function Kn(e, n, t) {
752
- let r = {}, o = e.nodes();
753
- return o.forEach(function(i) {
754
- let s = {};
755
- r[i] = s, s[i] = {
756
- distance: 0,
757
- predecessor: ""
758
- }, o.forEach(function(a) {
759
- i !== a && (s[a] = {
760
- distance: Number.POSITIVE_INFINITY,
761
- predecessor: ""
762
- });
763
- }), t(i).forEach(function(a) {
764
- let l = a.v === i ? a.w : a.v, u = n(a);
765
- s[l] = {
766
- distance: u,
767
- predecessor: i
768
- };
769
- });
770
- }), o.forEach(function(i) {
771
- let s = r[i];
772
- s && o.forEach(function(a) {
773
- let l = r[a];
774
- l && o.forEach(function(u) {
775
- let d = l[i], c = s[u], f = l[u];
776
- if (d && c && f) {
777
- let h = d.distance + c.distance;
778
- h < f.distance && (f.distance = h, f.predecessor = c.predecessor);
779
- }
780
- });
781
- });
782
- }), r;
783
- }
784
- var K = class extends Error {
785
- constructor(e) {
786
- super(e), this.name = "CycleException";
787
- }
788
- };
789
- function Ae(e) {
790
- let n = {}, t = {}, r = [];
791
- function o(i) {
792
- var s;
793
- if (i in t) throw new K();
794
- i in n || (t[i] = !0, n[i] = !0, (s = e.predecessors(i)) == null || s.forEach(o), delete t[i], r.push(i));
795
- }
796
- if (e.sinks().forEach(o), Object.keys(n).length !== e.nodeCount()) throw new K();
797
- return r;
798
- }
799
- function Qn(e) {
800
- try {
801
- Ae(e);
802
- } catch (n) {
803
- if (n instanceof K) return !1;
804
- throw n;
805
- }
806
- return !0;
807
- }
808
- function Zn(e, n, t, r, o) {
809
- Array.isArray(n) || (n = [n]);
810
- let i = ((a) => {
811
- var l;
812
- return (l = e.isDirected() ? e.successors(a) : e.neighbors(a)) != null ? l : [];
813
- }), s = {};
814
- return n.forEach(function(a) {
815
- if (!e.hasNode(a)) throw new Error("Graph does not have node: " + a);
816
- o = Ve(e, a, t === "post", s, i, r, o);
817
- }), o;
818
- }
819
- function Ve(e, n, t, r, o, i, s) {
820
- return n in r || (r[n] = !0, t || (s = i(s, n)), o(n).forEach(function(a) {
821
- s = Ve(e, a, t, r, o, i, s);
822
- }), t && (s = i(s, n))), s;
823
- }
824
- function De(e, n, t) {
825
- return Zn(e, n, t, function(r, o) {
826
- return r.push(o), r;
827
- }, []);
828
- }
829
- function et(e, n) {
830
- return De(e, n, "post");
831
- }
832
- function nt(e, n) {
833
- return De(e, n, "pre");
834
- }
835
- function tt(e, n) {
836
- var t;
837
- let r = new Q(), o = {}, i = new Pe(), s;
838
- function a(d) {
839
- let c = d.v === s ? d.w : d.v, f = i.priority(c);
840
- if (f !== void 0) {
841
- let h = n(d);
842
- h < f && (o[c] = s, i.decrease(c, h));
843
- }
844
- }
845
- if (e.nodeCount() === 0) return r;
846
- e.nodes().forEach(function(d) {
847
- i.add(d, Number.POSITIVE_INFINITY), r.setNode(d);
848
- });
849
- let l = e.nodes()[0];
850
- l !== void 0 && i.decrease(l, 0);
851
- let u = !1;
852
- for (; i.size() > 0;) {
853
- if (s = i.removeMin(), s in o) r.setEdge(s, o[s]);
854
- else {
855
- if (u) throw new Error("Input graph is not connected: " + e);
856
- u = !0;
857
- }
858
- (t = e.nodeEdges(s)) == null || t.forEach(a);
859
- }
860
- return r;
861
- }
862
- function rt(e, n, t, r) {
863
- return ot(e, n, t, r != null ? r : ((o) => {
864
- var i;
865
- return (i = e.outEdges(o)) != null ? i : [];
866
- }));
867
- }
868
- function ot(e, n, t, r) {
869
- if (t === void 0) return J(e, n, t, r);
870
- let o = !1, i = e.nodes();
871
- for (let s = 0; s < i.length; s++) {
872
- let a = i[s];
873
- if (a === void 0) continue;
874
- let l = r(a);
875
- for (let u = 0; u < l.length; u++) {
876
- let d = l[u];
877
- if (!d) continue;
878
- let c = d.v === a ? d.v : d.w;
879
- t({
880
- v: c,
881
- w: c === d.v ? d.w : d.v
882
- }) < 0 && (o = !0);
883
- }
884
- if (o) return Me(e, n, t, r);
885
- }
886
- return J(e, n, t, r);
887
- }
888
- var T$1 = Q;
889
- function M(e, n, t, r) {
890
- let o = r;
891
- for (; e.hasNode(o);) o = $(r);
892
- return t.dummy = n, e.setNode(o, t), o;
893
- }
894
- function Ye(e) {
895
- let n = new T$1().setGraph(e.graph());
896
- return e.nodes().forEach((t) => n.setNode(t, e.node(t))), e.edges().forEach((t) => {
897
- let r = n.edge(t.v, t.w) || {
898
- weight: 0,
899
- minlen: 1
900
- }, o = e.edge(t);
901
- n.setEdge(t.v, t.w, {
902
- weight: r.weight + o.weight,
903
- minlen: Math.max(r.minlen, o.minlen)
904
- });
905
- }), n;
906
- }
907
- function Z(e) {
908
- let n = new T$1({ multigraph: e.isMultigraph() }).setGraph(e.graph());
909
- return e.nodes().forEach((t) => {
910
- e.children(t).length || n.setNode(t, e.node(t));
911
- }), e.edges().forEach((t) => {
912
- n.setEdge(t, e.edge(t));
913
- }), n;
914
- }
915
- function se(e, n) {
916
- let t = e.x, r = e.y, o = n.x - t, i = n.y - r, s = e.width / 2, a = e.height / 2;
917
- if (!o && !i) throw new Error("Not possible to find intersection inside of the rectangle");
918
- let l, u;
919
- return Math.abs(i) * s > Math.abs(o) * a ? (i < 0 && (a = -a), l = a * o / i, u = a) : (o < 0 && (s = -s), l = s, u = s * i / o), {
920
- x: t + l,
921
- y: r + u
922
- };
923
- }
924
- function P$1(e) {
925
- let n = A$1(de(e) + 1).map(() => []);
926
- return e.nodes().forEach((t) => {
927
- let r = e.node(t), o = r.rank;
928
- o !== void 0 && (n[o] || (n[o] = []), n[o][r.order] = t);
929
- }), n;
930
- }
931
- function We(e) {
932
- let n = e.nodes().map((r) => {
933
- let o = e.node(r).rank;
934
- return o === void 0 ? Number.MAX_VALUE : o;
935
- }), t = R$1(Math.min, n);
936
- e.nodes().forEach((r) => {
937
- let o = e.node(r);
938
- Object.hasOwn(o, "rank") && (o.rank -= t);
939
- });
940
- }
941
- function Be(e) {
942
- let n = e.nodes().map((s) => e.node(s).rank).filter((s) => s !== void 0), t = R$1(Math.min, n), r = [];
943
- e.nodes().forEach((s) => {
944
- let a = e.node(s).rank - t;
945
- r[a] || (r[a] = []), r[a].push(s);
946
- });
947
- let o = 0, i = e.graph().nodeRankFactor;
948
- Array.from(r).forEach((s, a) => {
949
- s === void 0 && a % i !== 0 ? --o : s !== void 0 && o && s.forEach((l) => e.node(l).rank += o);
950
- });
951
- }
952
- function ae(e, n, t, r) {
953
- let o = {
954
- width: 0,
955
- height: 0
956
- };
957
- return arguments.length >= 4 && (o.rank = t, o.order = r), M(e, "border", o, n);
958
- }
959
- function it(e, n = Xe) {
960
- let t = [];
961
- for (let r = 0; r < e.length; r += n) {
962
- let o = e.slice(r, r + n);
963
- t.push(o);
964
- }
965
- return t;
966
- }
967
- var Xe = 65535;
968
- function R$1(e, n) {
969
- if (n.length > Xe) return e(...it(n).map((r) => e(...r)));
970
- else return e(...n);
971
- }
972
- function de(e) {
973
- let t = e.nodes().map((r) => {
974
- let o = e.node(r).rank;
975
- return o === void 0 ? Number.MIN_VALUE : o;
976
- });
977
- return R$1(Math.max, t);
978
- }
979
- function ze(e, n) {
980
- let t = {
981
- lhs: [],
982
- rhs: []
983
- };
984
- return e.forEach((r) => {
985
- n(r) ? t.lhs.push(r) : t.rhs.push(r);
986
- }), t;
987
- }
988
- function q(e, n) {
989
- return n();
990
- }
991
- var st = 0;
992
- function $(e) {
993
- return e + ("" + ++st);
994
- }
995
- function A$1(e, n, t = 1) {
996
- n ?? (n = e, e = 0);
997
- let r = (i) => i < n;
998
- t < 0 && (r = (i) => n < i);
999
- let o = [];
1000
- for (let i = e; r(i); i += t) o.push(i);
1001
- return o;
1002
- }
1003
- function B(e, n) {
1004
- let t = {};
1005
- for (let r of n) e[r] !== void 0 && (t[r] = e[r]);
1006
- return t;
1007
- }
1008
- function X(e, n) {
1009
- let t;
1010
- return typeof n == "string" ? t = (r) => r[n] : t = n, Object.entries(e).reduce((r, [o, i]) => (r[o] = t(i, o), r), {});
1011
- }
1012
- function He(e, n) {
1013
- return e.reduce((t, r, o) => (t[r] = n[o], t), {});
1014
- }
1015
- var D$1 = "\0";
1016
- function ee(e, n, t) {
1017
- var u, d, c, f, h, p;
1018
- if (!(e && n && t && n.dummy === "edge" && t.dummy === "edge" && n.edgeObj && t.edgeObj && e[n.edgeObj.v] && e[t.edgeObj.v] && e[n.edgeObj.w] && e[t.edgeObj.w])) return 0;
1019
- let r = !0;
1020
- n.edgeObj.w === t.edgeObj.w && (r = !1);
1021
- let o = r ? (d = (u = e[n.edgeObj.v]) == null ? void 0 : u.rank) != null ? d : NaN : (f = (c = e[n.edgeObj.w]) == null ? void 0 : c.rank) != null ? f : NaN, i = Object.entries(e).find((E) => {
1022
- var y, L;
1023
- return ((y = E[1].edgeObj) == null ? void 0 : y.v) === n.edgeObj.v && ((L = E[1].edgeObj) == null ? void 0 : L.w) === n.edgeObj.w && E[1].rank === o;
1024
- }), s = Object.entries(e).find((E) => {
1025
- var y, L;
1026
- return ((y = E[1].edgeObj) == null ? void 0 : y.v) === t.edgeObj.v && ((L = E[1].edgeObj) == null ? void 0 : L.w) === t.edgeObj.w && E[1].rank === o;
1027
- });
1028
- if (!i || !s) return 0;
1029
- let a = (h = i[1].order) != null ? h : NaN, l = (p = s[1].order) != null ? p : NaN;
1030
- return isNaN(a - l) ? 0 : a - l;
1031
- }
1032
- var ce = class {
1033
- constructor() {
1034
- je(this, "_sentinel");
1035
- let n = {};
1036
- n._next = n._prev = n, this._sentinel = n;
1037
- }
1038
- dequeue() {
1039
- let n = this._sentinel, t = n._prev;
1040
- if (t !== n) return qe(t), t;
1041
- }
1042
- enqueue(n) {
1043
- let t = this._sentinel;
1044
- n._prev && n._next && qe(n), n._next = t._next, t._next._prev = n, t._next = n, n._prev = t;
1045
- }
1046
- toString() {
1047
- let n = [], t = this._sentinel, r = t._prev;
1048
- for (; r !== t;) n.push(JSON.stringify(r, at)), r = r._prev;
1049
- return "[" + n.join(", ") + "]";
1050
- }
1051
- };
1052
- function qe(e) {
1053
- e._prev._next = e._next, e._next._prev = e._prev, delete e._next, delete e._prev;
1054
- }
1055
- function at(e, n) {
1056
- if (e !== "_next" && e !== "_prev") return n;
1057
- }
1058
- var $e = ce;
1059
- var dt = () => 1;
1060
- function be(e, n) {
1061
- if (e.nodeCount() <= 1) return [];
1062
- let t = ut(e, n || dt);
1063
- return lt(t.graph, t.buckets, t.zeroIdx).flatMap((o) => e.outEdges(o.v, o.w) || []);
1064
- }
1065
- function lt(e, n, t) {
1066
- var a;
1067
- let r = [], o = n[n.length - 1], i = n[0], s;
1068
- for (; e.nodeCount();) {
1069
- for (; s = i.dequeue();) fe(e, n, t, s);
1070
- for (; s = o.dequeue();) fe(e, n, t, s);
1071
- if (e.nodeCount()) {
1072
- for (let l = n.length - 2; l > 0; --l) if (s = (a = n[l]) == null ? void 0 : a.dequeue(), s) {
1073
- r = r.concat(fe(e, n, t, s, !0) || []);
1074
- break;
1075
- }
1076
- }
1077
- }
1078
- return r;
1079
- }
1080
- function fe(e, n, t, r, o) {
1081
- let i = [], s = o ? i : void 0;
1082
- return (e.inEdges(r.v) || []).forEach((a) => {
1083
- let l = e.edge(a), u = e.node(a.v);
1084
- o && i.push({
1085
- v: a.v,
1086
- w: a.w
1087
- }), u.out -= l, he(n, t, u);
1088
- }), (e.outEdges(r.v) || []).forEach((a) => {
1089
- let l = e.edge(a), u = a.w, d = e.node(u);
1090
- d.in -= l, he(n, t, d);
1091
- }), e.removeNode(r.v), s;
1092
- }
1093
- function ut(e, n) {
1094
- let t = new T$1(), r = 0, o = 0;
1095
- e.nodes().forEach((a) => {
1096
- t.setNode(a, {
1097
- v: a,
1098
- in: 0,
1099
- out: 0
1100
- });
1101
- }), e.edges().forEach((a) => {
1102
- let l = t.edge(a.v, a.w) || 0, u = n(a), d = l + u;
1103
- t.setEdge(a.v, a.w, d);
1104
- let c = t.node(a.v), f = t.node(a.w);
1105
- o = Math.max(o, c.out += u), r = Math.max(r, f.in += u);
1106
- });
1107
- let i = ct(o + r + 3).map(() => new $e()), s = r + 1;
1108
- return t.nodes().forEach((a) => {
1109
- he(i, s, t.node(a));
1110
- }), {
1111
- graph: t,
1112
- buckets: i,
1113
- zeroIdx: s
1114
- };
1115
- }
1116
- function he(e, n, t) {
1117
- var r, o, i;
1118
- t.out ? t.in ? (i = e[t.out - t.in + n]) == null || i.enqueue(t) : (o = e[e.length - 1]) == null || o.enqueue(t) : (r = e[0]) == null || r.enqueue(t);
1119
- }
1120
- function ct(e) {
1121
- let n = [];
1122
- for (let t = 0; t < e; t++) n.push(t);
1123
- return n;
1124
- }
1125
- function Ue(e, n) {
1126
- (e.graph().acyclicer === "greedy" ? be(e, r(e)) : ft(e, n != null ? n : null)).forEach((o) => {
1127
- let i = e.edge(o);
1128
- e.removeEdge(o), i.forwardName = o.name, i.reversed = !0, e.setEdge(o.w, o.v, i, $("rev"));
1129
- });
1130
- function r(o) {
1131
- return (i) => o.edge(i).weight;
1132
- }
1133
- }
1134
- function ft(e, n) {
1135
- let t = [], r = {}, o = {};
1136
- function i(l) {
1137
- Object.hasOwn(o, l) || (o[l] = !0, r[l] = !0, e.outEdges(l).forEach((u) => {
1138
- Object.hasOwn(r, u.w) ? t.push(u) : i(u.w);
1139
- }), delete r[l]);
1140
- }
1141
- function s(l) {
1142
- var u;
1143
- Object.hasOwn(o, l) || (o[l] = !0, r[l] = !0, (u = e.outEdges(l)) == null || u.forEach((d) => {
1144
- var c, f;
1145
- Object.hasOwn(r, d.w) || ((c = n.node(l)) == null ? void 0 : c.rank) > ((f = n.node(d.w)) == null ? void 0 : f.rank) && ht(e, d.w, d) ? t.push(d) : s(d.w);
1146
- }), delete r[l]);
1147
- }
1148
- let a = i;
1149
- return n && typeof n.node == "function" && (a = s), e.sources().forEach(a), e.nodes().forEach(a), t;
1150
- }
1151
- function Je(e) {
1152
- e.edges().forEach((n) => {
1153
- let t = e.edge(n);
1154
- if (t.reversed) {
1155
- e.removeEdge(n);
1156
- let r = t.forwardName;
1157
- delete t.reversed, delete t.forwardName, e.setEdge(n.w, n.v, t, r);
1158
- }
1159
- });
1160
- }
1161
- function ht(e, n, t) {
1162
- let r = /* @__PURE__ */ new Set();
1163
- function o(i) {
1164
- var s;
1165
- if (e.sources().includes(i)) return !0;
1166
- r.add(i);
1167
- for (let a of (s = e.inEdges(i)) != null ? s : []) if (!(a.v === t.v && a.w === t.w) && !r.has(a.v) && o(a.v)) return !0;
1168
- return !1;
1169
- }
1170
- return o(n);
1171
- }
1172
- function Ke(e) {
1173
- e.graph().dummyChains = [], e.edges().forEach((n) => gt(e, n));
1174
- }
1175
- function gt(e, n) {
1176
- let t = n.v, r = e.node(t).rank, o = n.w, i = e.node(o).rank, s = n.name, a = e.edge(n), l = a.labelRank;
1177
- if (i === r + 1) return;
1178
- e.removeEdge(n);
1179
- let u, d, c;
1180
- for (c = 0, ++r; r < i; ++c, ++r) a.points = [], d = {
1181
- width: 0,
1182
- height: 0,
1183
- edgeLabel: a,
1184
- edgeObj: n,
1185
- rank: r
1186
- }, u = M(e, "edge", d, "_d"), r === l && (d.width = a.width, d.height = a.height, d.dummy = "edge-label", d.labelpos = a.labelpos), e.setEdge(t, u, { weight: a.weight }, s), c === 0 && e.graph().dummyChains.push(u), t = u;
1187
- e.setEdge(t, o, { weight: a.weight }, s);
1188
- }
1189
- function Qe(e) {
1190
- e.graph().dummyChains.forEach((n) => {
1191
- let t = e.node(n), r = t.edgeLabel, o;
1192
- for (e.setEdge(t.edgeObj, r); t.dummy;) o = e.successors(n)[0], e.removeNode(n), r.points.push({
1193
- x: t.x,
1194
- y: t.y
1195
- }), t.dummy === "edge-label" && (r.x = t.x, r.y = t.y, r.width = t.width, r.height = t.height), n = o, t = e.node(n);
1196
- });
1197
- }
1198
- function U(e) {
1199
- let n = {};
1200
- function t(r) {
1201
- let o = e.node(r);
1202
- if (Object.hasOwn(n, r)) return o.rank;
1203
- n[r] = !0;
1204
- let i = e.outEdges(r), s = i ? i.map((l) => l == null ? Number.POSITIVE_INFINITY : t(l.w) - e.edge(l).minlen) : [], a = R$1(Math.min, s);
1205
- return a === Number.POSITIVE_INFINITY && (a = 0), o.rank = a;
1206
- }
1207
- e.sources().forEach(t);
1208
- }
1209
- function V(e, n) {
1210
- return e.node(n.w).rank - e.node(n.v).rank - e.edge(n).minlen;
1211
- }
1212
- var ne = mt;
1213
- function mt(e) {
1214
- let n = new T$1({ directed: !1 }), t = e.nodes();
1215
- if (t.length === 0) throw new Error("Graph must have at least one node");
1216
- let r = t[0], o = e.nodeCount();
1217
- n.setNode(r, {});
1218
- let i, s;
1219
- for (; Et(n, e) < o && (i = Lt(n, e), !!i);) s = n.hasNode(i.v) ? V(e, i) : -V(e, i), yt(n, e, s);
1220
- return n;
1221
- }
1222
- function Et(e, n) {
1223
- function t(r) {
1224
- let o = n.nodeEdges(r);
1225
- o && o.forEach((i) => {
1226
- let s = i.v, a = r === s ? i.w : s;
1227
- !e.hasNode(a) && !V(n, i) && (e.setNode(a, {}), e.setEdge(r, a, {}), t(a));
1228
- });
1229
- }
1230
- return e.nodes().forEach(t), e.nodeCount();
1231
- }
1232
- function Lt(e, n) {
1233
- return n.edges().reduce((r, o) => {
1234
- let i = Number.POSITIVE_INFINITY;
1235
- return e.hasNode(o.v) !== e.hasNode(o.w) && (i = V(n, o)), i < r[0] ? [i, o] : r;
1236
- }, [Number.POSITIVE_INFINITY, null])[1];
1237
- }
1238
- function yt(e, n, t) {
1239
- e.nodes().forEach((r) => n.node(r).rank += t);
1240
- }
1241
- var { preorder: wt, postorder: Nt } = H, en = Y;
1242
- Y.initLowLimValues = pe;
1243
- Y.initCutValues = ge;
1244
- Y.calcCutValue = nn;
1245
- Y.leaveEdge = rn;
1246
- Y.enterEdge = on;
1247
- Y.exchangeEdges = sn;
1248
- function Y(e) {
1249
- e = Ye(e), U(e);
1250
- let n = ne(e);
1251
- pe(n), ge(n, e);
1252
- let t, r;
1253
- for (; t = rn(n);) r = on(n, e, t), sn(n, e, t, r);
1254
- }
1255
- function ge(e, n) {
1256
- let t = Nt(e, e.nodes());
1257
- t = t.slice(0, t.length - 1), t.forEach((r) => Gt(e, n, r));
1258
- }
1259
- function Gt(e, n, t) {
1260
- let o = e.node(t).parent, i = e.edge(t, o);
1261
- i.cutvalue = nn(e, n, t);
1262
- }
1263
- function nn(e, n, t) {
1264
- let o = e.node(t).parent, i = !0, s = n.edge(t, o), a = 0;
1265
- s || (i = !1, s = n.edge(o, t)), a = s.weight;
1266
- let l = n.nodeEdges(t);
1267
- return l && l.forEach((u) => {
1268
- let d = u.v === t, c = d ? u.w : u.v;
1269
- if (c !== o) {
1270
- let f = d === i, h = n.edge(u).weight;
1271
- if (a += f ? h : -h, kt(e, t, c)) {
1272
- let E = e.edge(t, c).cutvalue;
1273
- a += f ? -E : E;
1274
- }
1275
- }
1276
- }), a;
1277
- }
1278
- function pe(e, n) {
1279
- arguments.length < 2 && (n = e.nodes()[0]), tn(e, {}, 1, n);
1280
- }
1281
- function tn(e, n, t, r, o) {
1282
- let i = t, s = e.node(r);
1283
- n[r] = !0;
1284
- let a = e.neighbors(r);
1285
- return a && a.forEach((l) => {
1286
- Object.hasOwn(n, l) || (t = tn(e, n, t, l, r));
1287
- }), s.low = i, s.lim = t++, o ? s.parent = o : delete s.parent, t;
1288
- }
1289
- function rn(e) {
1290
- return e.edges().find((n) => e.edge(n).cutvalue < 0);
1291
- }
1292
- function on(e, n, t) {
1293
- let r = t.v, o = t.w;
1294
- n.hasEdge(r, o) || (r = t.w, o = t.v);
1295
- let i = e.node(r), s = e.node(o), a = i, l = !1;
1296
- return i.lim > s.lim && (a = s, l = !0), n.edges().filter((d) => l === Ze(e, e.node(d.v), a) && l !== Ze(e, e.node(d.w), a)).reduce((d, c) => V(n, c) < V(n, d) ? c : d);
1297
- }
1298
- function sn(e, n, t, r) {
1299
- let o = t.v, i = t.w;
1300
- e.removeEdge(o, i), e.setEdge(r.v, r.w, {}), pe(e), ge(e, n), vt(e, n);
1301
- }
1302
- function vt(e, n) {
1303
- let t = e.nodes().find((o) => !e.node(o).parent);
1304
- if (!t) return;
1305
- let r = wt(e, [t]);
1306
- r = r.slice(1), r.forEach((o) => {
1307
- let s = e.node(o).parent, a = n.edge(o, s), l = !1;
1308
- a || (a = n.edge(s, o), l = !0), n.node(o).rank = n.node(s).rank + (l ? a.minlen : -a.minlen);
1309
- });
1310
- }
1311
- function kt(e, n, t) {
1312
- return e.hasEdge(n, t);
1313
- }
1314
- function Ze(e, n, t) {
1315
- return t.low <= n.lim && n.lim <= t.lim;
1316
- }
1317
- var dn = xt;
1318
- function xt(e) {
1319
- let n = e.graph().ranker;
1320
- if (typeof n == "function") return n(e);
1321
- switch (n) {
1322
- case "network-simplex":
1323
- an(e);
1324
- break;
1325
- case "tight-tree":
1326
- Ot(e);
1327
- break;
1328
- case "longest-path":
1329
- _t(e);
1330
- break;
1331
- case "none": break;
1332
- default: an(e);
1333
- }
1334
- }
1335
- var _t = U;
1336
- function Ot(e) {
1337
- U(e), ne(e);
1338
- }
1339
- function an(e) {
1340
- en(e);
1341
- }
1342
- var ln = Ct;
1343
- function Ct(e) {
1344
- let n = jt(e), t = e.graph();
1345
- if (!Array.isArray(t.dummyChains)) return;
1346
- t.dummyChains.forEach((o) => {
1347
- let i = e.node(o), s = i.edgeObj, a = Tt(e, n, s.v, s.w), l = a.path, u = a.lca, d = 0, c = l[d], f = !0;
1348
- for (; o !== s.w;) {
1349
- if (i = e.node(o), f) {
1350
- for (; (c = l[d]) !== u && e.node(c).maxRank < i.rank;) d++;
1351
- c === u && (f = !1);
1352
- }
1353
- if (!f) {
1354
- for (; d < l.length - 1 && e.node(l[d + 1]).minRank <= i.rank;) d++;
1355
- c = l[d];
1356
- }
1357
- c !== void 0 && e.setParent(o, c), o = e.successors(o)[0];
1358
- }
1359
- });
1360
- }
1361
- function Tt(e, n, t, r) {
1362
- let o = [], i = [], s = Math.min(n[t].low, n[r].low), a = Math.max(n[t].lim, n[r].lim), l;
1363
- l = t;
1364
- do
1365
- l = e.parent(l), o.push(l);
1366
- while (l && (n[l].low > s || a > n[l].lim));
1367
- let u = l, d = r;
1368
- for (; (d = e.parent(d)) !== u;) i.push(d);
1369
- return {
1370
- path: o.concat(i.reverse()),
1371
- lca: u
1372
- };
1373
- }
1374
- function jt(e) {
1375
- let n = {}, t = 0;
1376
- function r(o) {
1377
- let i = t;
1378
- e.children(o).forEach(r), n[o] = {
1379
- low: i,
1380
- lim: t++
1381
- };
1382
- }
1383
- return e.children(D$1).forEach(r), n;
1384
- }
1385
- function un(e) {
1386
- let n = M(e, "root", {}, "_root"), t = Rt(e), r = Object.values(t), o = R$1(Math.max, r) - 1, i = 2 * o + 1;
1387
- e.graph().nestingRoot = n, e.edges().forEach((a) => e.edge(a).minlen *= i);
1388
- let s = It(e) + 1;
1389
- e.children(D$1).forEach((a) => {
1390
- cn(e, n, i, s, o, t, a);
1391
- }), e.graph().nodeRankFactor = i;
1392
- }
1393
- function cn(e, n, t, r, o, i, s) {
1394
- var c;
1395
- let a = e.children(s);
1396
- if (!a.length) {
1397
- s !== n && e.setEdge(n, s, {
1398
- weight: 0,
1399
- minlen: t
1400
- });
1401
- return;
1402
- }
1403
- let l = ae(e, "_bt"), u = ae(e, "_bb"), d = e.node(s);
1404
- e.setParent(l, s), d.borderTop = l, e.setParent(u, s), d.borderBottom = u, a.forEach((f) => {
1405
- var b;
1406
- cn(e, n, t, r, o, i, f);
1407
- let h = e.node(f), p = h.borderTop ? h.borderTop : f, E = h.borderBottom ? h.borderBottom : f, y = h.borderTop ? r : 2 * r, L = p !== E ? 1 : o - ((b = i[s]) != null ? b : 0) + 1;
1408
- e.setEdge(l, p, {
1409
- weight: y,
1410
- minlen: L,
1411
- nestingEdge: !0
1412
- }), e.setEdge(E, u, {
1413
- weight: y,
1414
- minlen: L,
1415
- nestingEdge: !0
1416
- });
1417
- }), e.parent(s) || e.setEdge(n, l, {
1418
- weight: 0,
1419
- minlen: o + ((c = i[s]) != null ? c : 0)
1420
- });
1421
- }
1422
- function Rt(e) {
1423
- let n = {};
1424
- function t(r, o) {
1425
- let i = e.children(r);
1426
- i && i.length && i.forEach((s) => t(s, o + 1)), n[r] = o;
1427
- }
1428
- return e.children(D$1).forEach((r) => t(r, 1)), n;
1429
- }
1430
- function It(e) {
1431
- return e.edges().reduce((n, t) => n + e.edge(t).weight, 0);
1432
- }
1433
- function fn(e) {
1434
- let n = e.graph();
1435
- e.removeNode(n.nestingRoot), delete n.nestingRoot, e.edges().forEach((t) => {
1436
- e.edge(t).nestingEdge && e.removeEdge(t);
1437
- });
1438
- }
1439
- var bn = Mt;
1440
- function Mt(e) {
1441
- function n(t) {
1442
- let r = e.children(t), o = e.node(t);
1443
- if (r.length && r.forEach(n), o && Object.hasOwn(o, "minRank")) {
1444
- o.borderLeft = [], o.borderRight = [];
1445
- for (let i = o.minRank, s = o.maxRank + 1; i < s; ++i) hn(e, "borderLeft", "_bl", t, o, i), hn(e, "borderRight", "_br", t, o, i);
1446
- }
1447
- }
1448
- e.children(D$1).forEach(n);
1449
- }
1450
- function hn(e, n, t, r, o, i) {
1451
- let s = {
1452
- width: 0,
1453
- height: 0,
1454
- rank: i,
1455
- borderType: n
1456
- }, a = o[n][i - 1], l = M(e, "border", s, t);
1457
- o[n][i] = l, e.setParent(l, r), a && e.setEdge(a, l, { weight: 1 });
1458
- }
1459
- function pn(e) {
1460
- var t;
1461
- let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
1462
- (n === "lr" || n === "rl") && En(e);
1463
- }
1464
- function mn(e) {
1465
- var t;
1466
- let n = (t = e.graph().rankdir) == null ? void 0 : t.toLowerCase();
1467
- (n === "bt" || n === "rl") && Pt(e), (n === "lr" || n === "rl") && (Ft(e), En(e));
1468
- }
1469
- function En(e) {
1470
- e.nodes().forEach((n) => gn(e.node(n))), e.edges().forEach((n) => gn(e.edge(n)));
1471
- }
1472
- function gn(e) {
1473
- let n = e.width;
1474
- e.width = e.height, e.height = n;
1475
- }
1476
- function Pt(e) {
1477
- e.nodes().forEach((n) => me(e.node(n))), e.edges().forEach((n) => {
1478
- var r;
1479
- let t = e.edge(n);
1480
- (r = t.points) == null || r.forEach(me), Object.hasOwn(t, "y") && me(t);
1481
- });
1482
- }
1483
- function me(e) {
1484
- e.y = -e.y;
1485
- }
1486
- function Ft(e) {
1487
- e.nodes().forEach((n) => Ee(e.node(n))), e.edges().forEach((n) => {
1488
- var r;
1489
- let t = e.edge(n);
1490
- (r = t.points) == null || r.forEach(Ee), Object.hasOwn(t, "x") && Ee(t);
1491
- });
1492
- }
1493
- function Ee(e) {
1494
- let n = e.x;
1495
- e.x = e.y, e.y = n;
1496
- }
1497
- function Le(e, n = null) {
1498
- let t = {}, r = e.nodes().filter((d) => !e.children(d).length), o = r.map((d) => e.node(d).rank), s = A$1(R$1(Math.max, o) + 1).map(() => []);
1499
- function a(d) {
1500
- if (t[d]) return;
1501
- t[d] = !0;
1502
- let c = e.node(d);
1503
- s[c.rank].push(d);
1504
- let f = e.successors(d);
1505
- f && [...f].sort((p, E) => u(p, E)).forEach(a);
1506
- }
1507
- r.sort((d, c) => e.node(d).rank - e.node(c).rank).forEach(a);
1508
- function u(d, c) {
1509
- return ee(n, e.node(d), e.node(c));
1510
- }
1511
- return s;
1512
- }
1513
- function ye(e, n) {
1514
- let t = 0;
1515
- for (let r = 1; r < n.length; ++r) t += Vt(e, n[r - 1], n[r]);
1516
- return t;
1517
- }
1518
- function Vt(e, n, t) {
1519
- let r = He(t, t.map((u, d) => d)), o = n.flatMap((u) => {
1520
- let d = e.outEdges(u);
1521
- return d ? d.map((c) => ({
1522
- pos: r[c.w],
1523
- weight: e.edge(c).weight
1524
- })).sort((c, f) => c.pos - f.pos) : [];
1525
- }), i = 1;
1526
- for (; i < t.length;) i <<= 1;
1527
- let s = 2 * i - 1;
1528
- i -= 1;
1529
- let a = new Array(s).fill(0), l = 0;
1530
- return o.forEach((u) => {
1531
- let d = u.pos + i;
1532
- a[d] += u.weight;
1533
- let c = 0;
1534
- for (; d > 0;) d % 2 && (c += a[d + 1]), d = d - 1 >> 1, a[d] += u.weight;
1535
- l += u.weight * c;
1536
- }), l;
1537
- }
1538
- function we(e, n = []) {
1539
- return n.map((t) => {
1540
- let r = e.inEdges(t);
1541
- if (!r || !r.length) return { v: t };
1542
- {
1543
- let o = r.reduce((i, s) => {
1544
- let a = e.edge(s), l = e.node(s.v);
1545
- return {
1546
- sum: i.sum + a.weight * l.order,
1547
- weight: i.weight + a.weight
1548
- };
1549
- }, {
1550
- sum: 0,
1551
- weight: 0
1552
- });
1553
- return {
1554
- v: t,
1555
- barycenter: o.sum / o.weight,
1556
- weight: o.weight
1557
- };
1558
- }
1559
- });
1560
- }
1561
- function Ne(e, n) {
1562
- let t = {};
1563
- e.forEach((o, i) => {
1564
- let s = {
1565
- indegree: 0,
1566
- in: [],
1567
- out: [],
1568
- vs: [o.v],
1569
- i
1570
- };
1571
- o.barycenter !== void 0 && (s.barycenter = o.barycenter, s.weight = o.weight), t[o.v] = s;
1572
- }), n.edges().forEach((o) => {
1573
- let i = t[o.v], s = t[o.w];
1574
- i !== void 0 && s !== void 0 && (s.indegree++, i.out.push(s));
1575
- });
1576
- return Dt(Object.values(t).filter((o) => !o.indegree));
1577
- }
1578
- function Dt(e) {
1579
- let n = [];
1580
- function t(o) {
1581
- return (i) => {
1582
- i.merged || (i.barycenter === void 0 || o.barycenter === void 0 || i.barycenter >= o.barycenter) && Yt(o, i);
1583
- };
1584
- }
1585
- function r(o) {
1586
- return (i) => {
1587
- i.in.push(o), --i.indegree === 0 && e.push(i);
1588
- };
1589
- }
1590
- for (; e.length;) {
1591
- let o = e.pop();
1592
- n.push(o), o.in.reverse().forEach(t(o)), o.out.forEach(r(o));
1593
- }
1594
- return n.filter((o) => !o.merged).map((o) => B(o, [
1595
- "vs",
1596
- "i",
1597
- "barycenter",
1598
- "weight"
1599
- ]));
1600
- }
1601
- function Yt(e, n) {
1602
- let t = 0, r = 0;
1603
- e.weight && (t += e.barycenter * e.weight, r += e.weight), n.weight && (t += n.barycenter * n.weight, r += n.weight), e.vs = n.vs.concat(e.vs), e.barycenter = t / r, e.weight = r, e.i = Math.min(n.i, e.i), n.merged = !0;
1604
- }
1605
- function Ge(e, n, t, r, o) {
1606
- let i = {}, s = null, a = null, l = o;
1607
- typeof n == "boolean" ? (l = n, i = {}) : n && (i = n, s = t != null ? t : null, a = r != null ? r : null);
1608
- let u = ze(e, (L) => Object.hasOwn(L, "barycenter")), d = u.lhs, c = u.rhs.sort((L, b) => b.i - L.i), f = [], h = 0, p = 0, E = 0;
1609
- d.sort(Wt(a, s, !!l));
1610
- for (let [L, b] of Object.entries(i)) {
1611
- let g = d.findIndex((m) => m.vs[0] === L);
1612
- d.splice(g + 1, 0, b);
1613
- }
1614
- E = Ln(f, c, E), d.forEach((L) => {
1615
- E += L.vs.length, f.push(L.vs), h += L.barycenter * L.weight, p += L.weight, E = Ln(f, c, E);
1616
- });
1617
- let y = { vs: f.flat(1) };
1618
- return p && (y.barycenter = h / p, y.weight = p), y;
1619
- }
1620
- function Ln(e, n, t) {
1621
- let r;
1622
- for (; n.length && (r = n[n.length - 1]).i <= t;) n.pop(), e.push(r.vs), t++;
1623
- return t;
1624
- }
1625
- function Wt(e, n, t) {
1626
- return (r, o) => {
1627
- if (r.barycenter < o.barycenter) return -1;
1628
- if (r.barycenter > o.barycenter) return 1;
1629
- if (e && (typeof r.vs[0] == "string" || typeof o.vs[0] == "string")) {
1630
- let a = ee(n, e.node(r.vs[0]), e.node(o.vs[0]));
1631
- if (a !== 0) return a;
1632
- }
1633
- return t ? o.i - r.i : r.i - o.i;
1634
- };
1635
- }
1636
- function te(e, n, t, r, o) {
1637
- var L, b, g, m, w, k, _, C, j, I, S;
1638
- let i = null, s = o;
1639
- typeof r == "boolean" ? (s = r, i = null) : r !== void 0 && (i = r);
1640
- let a = e.children(n), l = e.node(n), u = l ? l.borderLeft : void 0, d = l ? l.borderRight : void 0, c = {};
1641
- u && (a = a.filter((G) => G !== u && G !== d));
1642
- let f = we(e, a);
1643
- f.forEach((G) => {
1644
- if (e.children(G.v).length) {
1645
- let { result: x } = te(e, G.v, t, i, s);
1646
- c[G.v] = x, Object.hasOwn(x, "barycenter") && Xt(G, x);
1647
- }
1648
- });
1649
- let h = Ne(f, t);
1650
- Bt(h, c);
1651
- let p = {}, E = !1;
1652
- for (let G = 0; G < h.length; G++) for (let x = G + 1; x < h.length; x++) if (!(!h[G] || !h[x] || !((L = h[G]) != null && L.barycenter) || !((b = h[x]) != null && b.barycenter)) && ((g = h[G]) == null ? void 0 : g.barycenter) === h[x].barycenter) {
1653
- let v = (w = (m = h[G]) == null ? void 0 : m.vs[0]) != null ? w : "", N = (_ = (k = h[x]) == null ? void 0 : k.vs[0]) != null ? _ : "", O = e.node(v), W = e.node(N);
1654
- if (O.dummy === "edge" && W.dummy === "edge" && ((C = O.edgeObj) == null ? void 0 : C.v) === ((j = W.edgeObj) == null ? void 0 : j.v) && ((I = O.edgeObj) == null ? void 0 : I.w) === ((S = W.edgeObj) == null ? void 0 : S.w)) if (O.edgeLabel.reversed) {
1655
- p[N] = h[G], h.splice(G, 1), G--;
1656
- break;
1657
- } else p[v] = h[x], h.splice(x, 1), x--;
1658
- else E = !0;
1659
- }
1660
- let y = Ge(h, p, i, e, s);
1661
- if (u && d) {
1662
- y.vs = [
1663
- u,
1664
- y.vs,
1665
- d
1666
- ].flat(1);
1667
- let G = e.predecessors(u);
1668
- if (G && G.length) {
1669
- let x = e.node(G[0]), v = e.predecessors(d), N = e.node(v[0]);
1670
- Object.hasOwn(y, "barycenter") || (y.barycenter = 0, y.weight = 0), y.barycenter = (y.barycenter * y.weight + x.order + N.order) / (y.weight + 2), y.weight += 2;
1671
- }
1672
- }
1673
- return Object.defineProperty(y, "result", {
1674
- value: y,
1675
- enumerable: !1,
1676
- configurable: !0,
1677
- writable: !0
1678
- }), Object.defineProperty(y, "usedBias", {
1679
- value: E,
1680
- enumerable: !1,
1681
- configurable: !0,
1682
- writable: !0
1683
- }), y;
1684
- }
1685
- function Bt(e, n) {
1686
- e.forEach((t) => {
1687
- t.vs = t.vs.flatMap((r) => n[r] ? n[r].vs : r);
1688
- });
1689
- }
1690
- function Xt(e, n) {
1691
- e.barycenter !== void 0 ? (e.barycenter = (e.barycenter * e.weight + n.barycenter * n.weight) / (e.weight + n.weight), e.weight += n.weight) : (e.barycenter = n.barycenter, e.weight = n.weight);
1692
- }
1693
- function ve(e, n, t, r) {
1694
- r || (r = e.nodes());
1695
- let o = zt(e), i = new T$1({ compound: !0 }).setGraph({ root: o }).setDefaultNodeLabel((s) => e.node(s));
1696
- return r.forEach((s) => {
1697
- let a = e.node(s), l = e.parent(s);
1698
- if (a.rank === n || a.minRank <= n && n <= a.maxRank) {
1699
- i.setNode(s), i.setParent(s, l || o);
1700
- let u = e[t](s);
1701
- u && u.forEach((d) => {
1702
- let c = d.v === s ? d.w : d.v, f = i.edge(c, s), h = f !== void 0 ? f.weight : 0;
1703
- i.setEdge(c, s, { weight: e.edge(d).weight + h });
1704
- }), Object.hasOwn(a, "minRank") && i.setNode(s, {
1705
- borderLeft: a.borderLeft[n],
1706
- borderRight: a.borderRight[n]
1707
- });
1708
- }
1709
- }), i;
1710
- }
1711
- function zt(e) {
1712
- let n;
1713
- for (; e.hasNode(n = $("_root")););
1714
- return n;
1715
- }
1716
- function ke(e, n, t) {
1717
- let r = {}, o;
1718
- t.forEach((i) => {
1719
- let s = e.parent(i), a, l;
1720
- for (; s;) {
1721
- if (a = e.parent(s), a ? (l = r[a], r[a] = s) : (l = o, o = s), l && l !== s) {
1722
- n.setEdge(l, s);
1723
- return;
1724
- }
1725
- s = a;
1726
- }
1727
- });
1728
- }
1729
- function re(e, n = {}, t = null) {
1730
- if (typeof n.customOrder == "function") {
1731
- n.customOrder(e, re);
1732
- return;
1733
- }
1734
- let r = de(e), o = yn(e, A$1(1, r + 1), "inEdges"), i = yn(e, A$1(r - 1, -1, -1), "outEdges"), s = Le(e, t);
1735
- if (wn(e, s), n.disableOptimalOrderHeuristic) return;
1736
- let a = Number.POSITIVE_INFINITY, l, u = n.constraints || [];
1737
- for (let d = 0, c = 0; c < 4; ++d, ++c) {
1738
- Ht(d % 2 ? o : i, d % 4 >= 2, u, t), s = P$1(e);
1739
- let f = ye(e, s);
1740
- f < a ? (c = 0, l = Object.assign({}, s), a = f) : f === a && (l = structuredClone(s));
1741
- }
1742
- wn(e, l);
1743
- }
1744
- function yn(e, n, t) {
1745
- let r = /* @__PURE__ */ new Map(), o = (i, s) => {
1746
- r.has(i) || r.set(i, []), r.get(i).push(s);
1747
- };
1748
- for (let i of e.nodes()) {
1749
- let s = e.node(i);
1750
- if (typeof s.rank == "number" && o(s.rank, i), typeof s.minRank == "number" && typeof s.maxRank == "number") for (let a = s.minRank; a <= s.maxRank; a++) a !== s.rank && o(a, i);
1751
- }
1752
- return n.map(function(i) {
1753
- return ve(e, i, t, r.get(i) || []);
1754
- });
1755
- }
1756
- function Ht(e, n, t, r) {
1757
- let o = !0, i = new T$1();
1758
- e.forEach(function(s) {
1759
- t.forEach((d) => i.setEdge(d.left, d.right));
1760
- let a = s.graph().root, { result: l, usedBias: u } = te(s, a, i, r, o);
1761
- n && u && (o = !o), l.vs.forEach((d, c) => s.node(d).order = c), ke(s, i, l.vs);
1762
- });
1763
- }
1764
- function wn(e, n) {
1765
- Object.values(n).forEach((t) => t.forEach((r, o) => e.node(r).order = o));
1766
- }
1767
- function qt(e, n) {
1768
- let t = {};
1769
- function r(o, i) {
1770
- let s = 0, a = 0, l = o.length, u = i[i.length - 1];
1771
- return i.forEach((d, c) => {
1772
- let f = Ut(e, d), h = f ? e.node(f).order : l;
1773
- (f || d === u) && (i.slice(a, c + 1).forEach((p) => {
1774
- let E = e.predecessors(p);
1775
- E && E.forEach((y) => {
1776
- let L = e.node(y), b = L.order;
1777
- (b < s || h < b) && !(L.dummy && e.node(p).dummy) && Gn(t, y, p);
1778
- });
1779
- }), a = c + 1, s = h);
1780
- }), i;
1781
- }
1782
- return n.length && n.reduce(r), t;
1783
- }
1784
- function $t(e, n) {
1785
- let t = {};
1786
- function r(i, s, a, l, u) {
1787
- A$1(s, a).forEach((d) => {
1788
- let c = i[d];
1789
- if (c !== void 0 && e.node(c).dummy) {
1790
- let f = e.predecessors(c);
1791
- f && f.forEach((h) => {
1792
- if (h === void 0) return;
1793
- let p = e.node(h);
1794
- p.dummy && (p.order < l || p.order > u) && Gn(t, h, c);
1795
- });
1796
- }
1797
- });
1798
- }
1799
- function o(i, s) {
1800
- let a = -1, l = -1, u = 0;
1801
- return s.forEach((d, c) => {
1802
- if (e.node(d).dummy === "border") {
1803
- let f = e.predecessors(d);
1804
- if (f && f.length) {
1805
- let h = f[0];
1806
- if (h === void 0) return;
1807
- l = e.node(h).order, r(s, u, c, a, l), u = c, a = l;
1808
- }
1809
- }
1810
- r(s, u, s.length, l, i.length);
1811
- }), s;
1812
- }
1813
- return n.length && n.reduce(o), t;
1814
- }
1815
- function Ut(e, n) {
1816
- if (e.node(n).dummy) {
1817
- let t = e.predecessors(n);
1818
- if (t) return t.find((r) => e.node(r).dummy);
1819
- }
1820
- }
1821
- function Gn(e, n, t) {
1822
- if (n > t) {
1823
- let o = n;
1824
- n = t, t = o;
1825
- }
1826
- let r = e[n];
1827
- r || (e[n] = r = {}), r[t] = !0;
1828
- }
1829
- function Jt(e, n, t) {
1830
- if (n > t) {
1831
- let o = n;
1832
- n = t, t = o;
1833
- }
1834
- let r = e[n];
1835
- return r !== void 0 && Object.hasOwn(r, t);
1836
- }
1837
- function Kt(e, n, t, r, o) {
1838
- let i = {}, s = {}, a = {};
1839
- return n.forEach((l) => {
1840
- l.forEach((u, d) => {
1841
- i[u] = u, s[u] = u, a[u] = d;
1842
- });
1843
- }), n.forEach((l) => {
1844
- let u = -1, d = -1, c = !1, f = l, h = l.findIndex((p) => (o == null ? void 0 : o.includes(p)) || Nn(p, e, o));
1845
- h > 0 && (f = [
1846
- l[h],
1847
- ...l.slice(0, h),
1848
- ...l.slice(h + 1)
1849
- ], c = !0), f.forEach((p) => {
1850
- var y;
1851
- let E = r(p);
1852
- if (E && E.length) {
1853
- o != null && o.includes(p) && (E = E.filter((g) => Nn(g, e, o)));
1854
- let L = E.sort((g, m) => {
1855
- let w = a[g], k = a[m];
1856
- return (w !== void 0 ? w : 0) - (k !== void 0 ? k : 0);
1857
- }), b = (L.length - 1) / 2;
1858
- for (let g = Math.floor(b), m = Math.ceil(b); g <= m; ++g) {
1859
- let w = L[g];
1860
- if (w === void 0) continue;
1861
- let k = a[w];
1862
- if (k !== void 0 && s[p] === p && u < k && a[w] !== d && !Jt(t, p, w)) {
1863
- let _ = i[w];
1864
- _ !== void 0 && (s[w] = p, s[p] = i[p] = _, u = k, c && (u = -1, d = (y = a[w]) != null ? y : -1, c = !1));
1865
- }
1866
- }
1867
- }
1868
- });
1869
- }), {
1870
- root: i,
1871
- align: s
1872
- };
1873
- }
1874
- function Qt(e, n, t, r, o = !1) {
1875
- let i = {}, s = Zt(e, n, t, o), a = o ? "borderLeft" : "borderRight";
1876
- function l(h, p) {
1877
- let E = s.nodes().slice(), y = {}, L = E.pop();
1878
- for (; L;) {
1879
- if (y[L]) h(L);
1880
- else {
1881
- y[L] = !0, E.push(L);
1882
- for (let b of p(L)) E.push(b);
1883
- }
1884
- L = E.pop();
1885
- }
1886
- }
1887
- function u(h) {
1888
- let p = s.inEdges(h);
1889
- p ? i[h] = p.reduce((E, y) => {
1890
- var g;
1891
- let L = (g = i[y.v]) != null ? g : 0, b = s.edge(y);
1892
- return Math.max(E, L + (b !== void 0 ? b : 0));
1893
- }, 0) : i[h] = 0;
1894
- }
1895
- function d(h) {
1896
- let p = s.outEdges(h), E = Number.POSITIVE_INFINITY;
1897
- p && (E = p.reduce((L, b) => {
1898
- let g = i[b.w], m = s.edge(b);
1899
- return Math.min(L, (g !== void 0 ? g : 0) - (m !== void 0 ? m : 0));
1900
- }, Number.POSITIVE_INFINITY));
1901
- let y = e.node(h);
1902
- E !== Number.POSITIVE_INFINITY && y.borderType !== a && (i[h] = Math.max(i[h] !== void 0 ? i[h] : 0, E));
1903
- }
1904
- function c(h) {
1905
- return s.predecessors(h) || [];
1906
- }
1907
- function f(h) {
1908
- return s.successors(h) || [];
1909
- }
1910
- return l(u, c), l(d, f), Object.keys(r).forEach((h) => {
1911
- var E;
1912
- let p = t[h];
1913
- p !== void 0 && (i[h] = (E = i[p]) != null ? E : 0);
1914
- }), i;
1915
- }
1916
- function Zt(e, n, t, r) {
1917
- let o = new T$1(), i = e.graph(), s = rr(i.nodesep, i.edgesep, r);
1918
- return n.forEach((a) => {
1919
- let l;
1920
- a.forEach((u) => {
1921
- let d = t[u];
1922
- if (d !== void 0) {
1923
- if (o.setNode(d), l !== void 0) {
1924
- let c = t[l];
1925
- if (c !== void 0) {
1926
- let f = o.edge(c, d);
1927
- o.setEdge(c, d, Math.max(s(e, u, l), f || 0));
1928
- }
1929
- }
1930
- l = u;
1931
- }
1932
- });
1933
- }), o;
1934
- }
1935
- function er(e, n) {
1936
- return Object.values(n).reduce((t, r) => {
1937
- let o = Number.NEGATIVE_INFINITY, i = Number.POSITIVE_INFINITY;
1938
- Object.entries(r).forEach(([a, l]) => {
1939
- let u = or(e, a) / 2;
1940
- o = Math.max(l + u, o), i = Math.min(l - u, i);
1941
- });
1942
- let s = o - i;
1943
- return s < t[0] && (t = [s, r]), t;
1944
- }, [Number.POSITIVE_INFINITY, null])[1];
1945
- }
1946
- function nr(e, n) {
1947
- let t = Object.values(n), r = R$1(Math.min, t), o = R$1(Math.max, t);
1948
- ["u", "d"].forEach((i) => {
1949
- ["l", "r"].forEach((s) => {
1950
- let a = i + s, l = e[a];
1951
- if (!l || l === n) return;
1952
- let u = Object.values(l), d = r - R$1(Math.min, u);
1953
- s !== "l" && (d = o - R$1(Math.max, u)), d && (e[a] = X(l, (c) => c + d));
1954
- });
1955
- });
1956
- }
1957
- function tr(e, n = void 0) {
1958
- let t = e.ul;
1959
- return t ? X(t, (r, o) => {
1960
- var s, a;
1961
- if (n) {
1962
- let u = e[n.toLowerCase()];
1963
- if (u && u[o] !== void 0) return u[o];
1964
- }
1965
- let i = Object.values(e).map((l) => {
1966
- let u = l[o];
1967
- return u !== void 0 ? u : 0;
1968
- }).sort((l, u) => l - u);
1969
- return (((s = i[1]) != null ? s : 0) + ((a = i[2]) != null ? a : 0)) / 2;
1970
- }) : {};
1971
- }
1972
- function vn(e, n) {
1973
- let t = P$1(e), r = Object.assign(qt(e, t), $t(e, t)), o = {}, i;
1974
- ["u", "d"].forEach((a) => {
1975
- i = a === "u" ? t : Object.values(t).reverse(), ["l", "r"].forEach((l) => {
1976
- l === "r" && (i = i.map((f) => Object.values(f).reverse()));
1977
- let d = Kt(e, i, r, (f) => (a === "u" ? e.predecessors(f) : e.successors(f)) || [], n), c = Qt(e, i, d.root, d.align, l === "r");
1978
- l === "r" && (c = X(c, (f) => -f)), o[a + l] = c;
1979
- });
1980
- });
1981
- return nr(o, er(e, o)), tr(o, e.graph().align);
1982
- }
1983
- function rr(e, n, t) {
1984
- return (r, o, i) => {
1985
- let s = r.node(o), a = r.node(i), l = 0, u;
1986
- if (l += s.width / 2, Object.hasOwn(s, "labelpos")) switch (s.labelpos.toLowerCase()) {
1987
- case "l":
1988
- u = -s.width / 2;
1989
- break;
1990
- case "r":
1991
- u = s.width / 2;
1992
- break;
1993
- }
1994
- if (u && (l += t ? u : -u), u = void 0, l += (s.dummy ? n : e) / 2, l += (a.dummy ? n : e) / 2, l += a.width / 2, Object.hasOwn(a, "labelpos")) switch (a.labelpos.toLowerCase()) {
1995
- case "l":
1996
- u = a.width / 2;
1997
- break;
1998
- case "r":
1999
- u = -a.width / 2;
2000
- break;
2001
- }
2002
- return u && (l += t ? u : -u), l;
2003
- };
2004
- }
2005
- function or(e, n) {
2006
- return e.node(n).width;
2007
- }
2008
- function Nn(e, n, t) {
2009
- var s;
2010
- if (!t) return !1;
2011
- let r = (s = n.node(e)) == null ? void 0 : s.edgeObj;
2012
- if (!r || n.node(e).edgeLabel.reversed) return !1;
2013
- let o = t.indexOf(r == null ? void 0 : r.v), i = t.indexOf(r == null ? void 0 : r.w);
2014
- return o !== -1 && i !== -1 && o === (i + 1) % t.length || o === (i - 1) % t.length;
2015
- }
2016
- function kn(e, n) {
2017
- e = Z(e), ir(e), Object.entries(vn(e, n)).forEach(([t, r]) => e.node(t).x = r);
2018
- }
2019
- function ir(e) {
2020
- let n = P$1(e), t = e.graph(), r = t.ranksep, o = t.rankalign, i = 0;
2021
- n.forEach((s) => {
2022
- let a = s.reduce((l, u) => {
2023
- var c;
2024
- let d = (c = e.node(u).height) != null ? c : 0;
2025
- return l > d ? l : d;
2026
- }, 0);
2027
- s.forEach((l) => {
2028
- let u = e.node(l);
2029
- o === "top" ? u.y = i + u.height / 2 : o === "bottom" ? u.y = i + a - u.height / 2 : u.y = i + a / 2;
2030
- }), i += a + r;
2031
- });
2032
- }
2033
- var xn = /* @__PURE__ */ new WeakMap();
2034
- function Oe(e, n = {}) {
2035
- return Rn(e, q, n), e;
2036
- }
2037
- function _n(e, n, t) {
2038
- let r = n;
2039
- for (; r !== void 0;) {
2040
- let o = e.parent(r);
2041
- if (o === t) return r;
2042
- r = o;
2043
- }
2044
- }
2045
- function Rn(e, n, t) {
2046
- var L;
2047
- let r = e.nodes().filter((b) => e.children(b).length), o = {};
2048
- r.forEach((b) => {
2049
- let g = e.node(b);
2050
- if (g && g.rankdir) {
2051
- let m = new T$1({
2052
- multigraph: !0,
2053
- compound: !0
2054
- });
2055
- m.setGraph({ rankdir: g.rankdir });
2056
- let w = e.children(b);
2057
- w.forEach((v) => {
2058
- let N = { ...e.node(v) };
2059
- m.setNode(v, N);
2060
- let O = e.parent(v);
2061
- O && O !== b && w.includes(O) && m.setParent(v, O);
2062
- });
2063
- let k = /* @__PURE__ */ new Set();
2064
- e.edges().forEach((v) => {
2065
- let N = _n(e, v.v, b), O = _n(e, v.w, b);
2066
- if (N && O && N !== O) {
2067
- let W = `${N}\0${O}`;
2068
- k.has(W) || (k.add(W), m.setEdge(N, O, { ...e.edge(v) }));
2069
- }
2070
- }), Rn(m, n, t);
2071
- let _ = jn(m);
2072
- On(_, n, t, null), Cn(m, _);
2073
- let C = 1 / 0, j = 1 / 0, I = -1 / 0, S = -1 / 0;
2074
- m.nodes().forEach((v) => {
2075
- if (v === b) return;
2076
- let N = m.node(v);
2077
- N && typeof N.x == "number" && typeof N.y == "number" && typeof N.width == "number" && typeof N.height == "number" && (C = Math.min(C, N.x - N.width / 2), I = Math.max(I, N.x + N.width / 2), j = Math.min(j, N.y - N.height / 2), S = Math.max(S, N.y + N.height / 2));
2078
- }), (!isFinite(C) || !isFinite(j) || !isFinite(I) || !isFinite(S)) && (C = j = 0, I = S = 0);
2079
- let G = I - C, x = S - j;
2080
- o[b] = {
2081
- minX: C,
2082
- minY: j,
2083
- maxX: I,
2084
- maxY: S,
2085
- width: G,
2086
- height: x,
2087
- offsetX: C,
2088
- offsetY: j
2089
- }, g._dagreClusterSubgraph = m;
2090
- }
2091
- });
2092
- let i = [], s = (b) => {
2093
- let g = [], m = (e.children(b) || []).filter((w) => w !== b);
2094
- for (; m.length > 0;) {
2095
- let w = m.shift();
2096
- g.push(w), (e.children(w) || []).filter((k) => k !== w).forEach((k) => m.push(k));
2097
- }
2098
- return g;
2099
- }, a = /* @__PURE__ */ new Map();
2100
- r.forEach((b) => {
2101
- let g = e.node(b);
2102
- g && g.rankdir && o[b] && a.set(b, (e.children(b) || []).filter((m) => m !== b));
2103
- });
2104
- let l = new Set([...a.values()].flat()), u = /* @__PURE__ */ new Map();
2105
- a.forEach((b, g) => {
2106
- l.has(g) || u.set(g, s(g));
2107
- });
2108
- let d = new Set([...u.values()].flat()), c = (b) => {
2109
- for (let [g, m] of u) if (m.includes(b)) return g;
2110
- return b;
2111
- }, f = [];
2112
- e.edges().forEach((b) => {
2113
- (d.has(b.v) || d.has(b.w)) && f.push({
2114
- edge: b,
2115
- label: e.edge(b)
2116
- });
2117
- });
2118
- let h = /* @__PURE__ */ new Map();
2119
- d.forEach((b) => {
2120
- let g = e.parent(b);
2121
- h.set(b, typeof g == "string" ? g : void 0);
2122
- }), u.forEach((b, g) => {
2123
- let m = e.node(g), w = [];
2124
- b.forEach((C) => {
2125
- let j = e.node(C);
2126
- j && (w.push({
2127
- id: C,
2128
- node: j,
2129
- parent: h.get(C)
2130
- }), e.removeNode(C));
2131
- });
2132
- let k = f.filter(({ edge: C }) => b.includes(C.v) || b.includes(C.w)), _ = o[g];
2133
- m && (i.push({
2134
- clusterId: g,
2135
- subgraph: m._dagreClusterSubgraph,
2136
- bounds: _,
2137
- children: b,
2138
- removedNodes: w,
2139
- removedEdges: k
2140
- }), m.width = _.width, m.height = _.height);
2141
- });
2142
- let p = /* @__PURE__ */ new Set();
2143
- f.forEach(({ edge: b, label: g }) => {
2144
- let m = c(b.v), w = c(b.w);
2145
- if (m !== w && e.hasNode(m) && e.hasNode(w)) {
2146
- let k = `${m}\0${w}`;
2147
- p.has(k) || (p.add(k), e.setEdge(m, w, {
2148
- ...g,
2149
- width: 0,
2150
- height: 0
2151
- }));
2152
- }
2153
- });
2154
- let E = jn(e), y = On(E, n, t, (L = xn.get(e)) != null ? L : null);
2155
- xn.set(e, y), Cn(e, E), p.forEach((b) => {
2156
- let g = b.indexOf("\0"), m = b.slice(0, g), w = b.slice(g + 1);
2157
- e.hasEdge(m, w) && e.removeEdge(m, w);
2158
- }), i.forEach(({ clusterId: b, subgraph: g, bounds: m, removedNodes: w, removedEdges: k }) => {
2159
- var G, x;
2160
- let _ = e.node(b), C = (G = _ == null ? void 0 : _.x) != null ? G : 0, j = (x = _ == null ? void 0 : _.y) != null ? x : 0, I = (m.minX + m.maxX) / 2, S = (m.minY + m.maxY) / 2;
2161
- w.forEach(({ id: v, node: N, parent: O }) => {
2162
- e.setNode(v, N), O !== void 0 && e.setParent(v, O);
2163
- }), k.forEach(({ edge: v, label: N }) => {
2164
- e.setEdge(v, N);
2165
- }), g.nodes().forEach((v) => {
2166
- if (v === b) return;
2167
- let N = g.node(v), O = e.node(v);
2168
- O && N && typeof N.x == "number" && typeof N.y == "number" && (O.x = C + (N.x - I), O.y = j + (N.y - S));
2169
- }), delete _._dagreClusterSubgraph;
2170
- }), r.forEach((b) => {
2171
- var w, k;
2172
- let g = e.node(b), m = o[b];
2173
- if (g && g.rankdir && g._dagreClusterSubgraph && m) {
2174
- let _ = g._dagreClusterSubgraph, C = (w = g.x) != null ? w : 0, j = (k = g.y) != null ? k : 0, I = (m.minX + m.maxX) / 2, S = (m.minY + m.maxY) / 2;
2175
- _.nodes().forEach((G) => {
2176
- if (G === b) return;
2177
- let x = _.node(G), v = e.node(G);
2178
- if (v && x && typeof x.x == "number" && typeof x.y == "number") {
2179
- let N = x.x - I, O = x.y - S;
2180
- v.x = C + N, v.y = j + O;
2181
- }
2182
- }), delete g._dagreClusterSubgraph;
2183
- }
2184
- });
2185
- }
2186
- function On(e, n, t, r = null) {
2187
- var l, u;
2188
- let o = (t == null ? void 0 : t.useDynamic) !== !1, i = o && (l = r == null ? void 0 : r.graph) != null ? l : null, s = o && (u = r == null ? void 0 : r.rawNodes) != null ? u : null;
2189
- n(" makeSpaceForEdgeLabels", () => hr(e)), n(" removeSelfEdges", () => Nr(e)), n(" acyclic", () => Ue(e, i)), n(" nestingGraph.run", () => un(e)), n(" rank", () => dn(Z(e))), n(" injectEdgeLabelProxies", () => br(e)), n(" removeEmptyRanks", () => Be(e)), n(" nestingGraph.cleanup", () => fn(e)), n(" normalizeRanks", () => We(e)), n(" assignRankMinMax", () => gr(e)), n(" removeEdgeLabelProxies", () => pr(e)), n(" normalize.run", () => Ke(e)), n(" parentDummyChains", () => ln(e)), n(" addBorderSegments", () => bn(e)), n(" order", () => re(e, t, s)), n(" insertSelfEdges", () => Gr(e)), n(" adjustCoordinateSystem", () => pn(e)), n(" position", () => kn(e, t.corePath)), n(" positionSelfEdges", () => vr(e));
2190
- let a = JSON.parse(JSON.stringify(e._nodes));
2191
- return n(" removeBorderNodes", () => wr(e)), n(" normalize.undo", () => Qe(e)), n(" fixupEdgeLabelCoords", () => Lr(e)), n(" undoCoordinateSystem", () => mn(e)), n(" translateGraph", () => mr(e)), n(" assignNodeIntersects", () => Er(e)), n(" reversePoints", () => yr(e)), n(" acyclic.undo", () => Je(e)), {
2192
- graph: e,
2193
- rawNodes: a
2194
- };
2195
- }
2196
- function Cn(e, n) {
2197
- e.nodes().forEach((t) => {
2198
- let r = e.node(t), o = n.node(t);
2199
- r && (r.x = o.x, r.y = o.y, r.order = o.order, r.rank = o.rank, n.children(t).length && (r.width = o.width, r.height = o.height));
2200
- }), e.edges().forEach((t) => {
2201
- let r = e.edge(t), o = n.edge(t);
2202
- r.points = o.points, Object.hasOwn(o, "x") && (r.x = o.x, r.y = o.y);
2203
- }), e.graph().width = n.graph().width, e.graph().height = n.graph().height;
2204
- }
2205
- var sr = [
2206
- "nodesep",
2207
- "edgesep",
2208
- "ranksep",
2209
- "marginx",
2210
- "marginy"
2211
- ];
2212
- var ar = {
2213
- ranksep: 50,
2214
- edgesep: 20,
2215
- nodesep: 50,
2216
- rankdir: "TB",
2217
- rankalign: "center"
2218
- };
2219
- var dr = [
2220
- "acyclicer",
2221
- "ranker",
2222
- "rankdir",
2223
- "align",
2224
- "rankalign"
2225
- ];
2226
- var lr = [
2227
- "width",
2228
- "height",
2229
- "rank"
2230
- ];
2231
- var Tn = {
2232
- width: 0,
2233
- height: 0
2234
- };
2235
- var ur = [
2236
- "minlen",
2237
- "weight",
2238
- "width",
2239
- "height",
2240
- "labeloffset"
2241
- ];
2242
- var cr = {
2243
- minlen: 1,
2244
- weight: 1,
2245
- width: 0,
2246
- height: 0,
2247
- labeloffset: 10,
2248
- labelpos: "r"
2249
- };
2250
- var fr = ["labelpos"];
2251
- function jn(e) {
2252
- let n = new T$1({
2253
- multigraph: !0,
2254
- compound: !0
2255
- }), t = _e(e.graph());
2256
- return n.setGraph(Object.assign({}, ar, xe(t, sr), B(t, dr))), e.nodes().forEach((r) => {
2257
- let i = xe(_e(e.node(r)), lr);
2258
- Object.keys(Tn).forEach((a) => {
2259
- i[a] === void 0 && (i[a] = Tn[a]);
2260
- }), n.setNode(r, i);
2261
- let s = e.parent(r);
2262
- s !== void 0 && n.setParent(r, s);
2263
- }), e.edges().forEach((r) => {
2264
- let o = _e(e.edge(r));
2265
- n.setEdge(r, Object.assign({}, cr, xe(o, ur), B(o, fr)));
2266
- }), n;
2267
- }
2268
- function hr(e) {
2269
- let n = e.graph();
2270
- n.ranksep /= 2, e.edges().forEach((t) => {
2271
- var o;
2272
- let r = e.edge(t);
2273
- r.minlen *= 2, ((o = r.labelpos) != null ? o : "r").toLowerCase() !== "c" && (n.rankdir === "TB" || n.rankdir === "BT" ? r.width += r.labeloffset : r.height += r.labeloffset);
2274
- });
2275
- }
2276
- function br(e) {
2277
- e.edges().forEach((n) => {
2278
- let t = e.edge(n);
2279
- if (t.width && t.height) {
2280
- let r = e.node(n.v);
2281
- M(e, "edge-proxy", {
2282
- rank: (e.node(n.w).rank - r.rank) / 2 + r.rank,
2283
- e: n
2284
- }, "_ep");
2285
- }
2286
- });
2287
- }
2288
- function gr(e) {
2289
- let n = 0;
2290
- e.nodes().forEach((t) => {
2291
- let r = e.node(t);
2292
- r.borderTop && (r.minRank = e.node(r.borderTop).rank, r.maxRank = e.node(r.borderBottom).rank, n = Math.max(n, r.maxRank));
2293
- }), e.graph().maxRank = n;
2294
- }
2295
- function pr(e) {
2296
- e.nodes().forEach((n) => {
2297
- let t = e.node(n);
2298
- if (t.dummy === "edge-proxy") {
2299
- let r = t;
2300
- e.edge(r.e).labelRank = t.rank, e.removeNode(n);
2301
- }
2302
- });
2303
- }
2304
- function mr(e) {
2305
- let n = Number.POSITIVE_INFINITY, t = 0, r = Number.POSITIVE_INFINITY, o = 0, i = e.graph(), s = i.marginx || 0, a = i.marginy || 0;
2306
- function l(u) {
2307
- let d = u.x, c = u.y, f = u.width, h = u.height;
2308
- n = Math.min(n, d - f / 2), t = Math.max(t, d + f / 2), r = Math.min(r, c - h / 2), o = Math.max(o, c + h / 2);
2309
- }
2310
- e.nodes().forEach((u) => l(e.node(u))), e.edges().forEach((u) => {
2311
- let d = e.edge(u);
2312
- Object.hasOwn(d, "x") && l(d);
2313
- }), n -= s, r -= a, e.nodes().forEach((u) => {
2314
- let d = e.node(u);
2315
- d.x -= n, d.y -= r;
2316
- }), e.edges().forEach((u) => {
2317
- let d = e.edge(u);
2318
- d.points.forEach((c) => {
2319
- c.x -= n, c.y -= r;
2320
- }), Object.hasOwn(d, "x") && (d.x -= n), Object.hasOwn(d, "y") && (d.y -= r);
2321
- }), i.width = t - n + s, i.height = o - r + a;
2322
- }
2323
- function Er(e) {
2324
- e.edges().forEach((n) => {
2325
- if (n.v === n.w) return;
2326
- let t = e.edge(n), r = e.node(n.v), o = e.node(n.w), i, s;
2327
- t.points ? (i = t.points[0], s = t.points[t.points.length - 1]) : (t.points = [], i = o, s = r), t.points.unshift(se(r, i)), t.points.push(se(o, s));
2328
- });
2329
- }
2330
- function Lr(e) {
2331
- e.edges().forEach((n) => {
2332
- let t = e.edge(n);
2333
- if (Object.hasOwn(t, "x")) switch ((t.labelpos === "l" || t.labelpos === "r") && (t.width -= t.labeloffset), t.labelpos) {
2334
- case "l":
2335
- t.x -= t.width / 2 + t.labeloffset;
2336
- break;
2337
- case "r":
2338
- t.x += t.width / 2 + t.labeloffset;
2339
- break;
2340
- }
2341
- });
2342
- }
2343
- function yr(e) {
2344
- e.edges().forEach((n) => {
2345
- let t = e.edge(n);
2346
- t.reversed && t.points.reverse();
2347
- });
2348
- }
2349
- function wr(e) {
2350
- e.nodes().forEach((n) => {
2351
- if (e.children(n).length) {
2352
- let t = e.node(n), r = e.node(t.borderTop), o = e.node(t.borderBottom), i = e.node(t.borderLeft[t.borderLeft.length - 1]), s = e.node(t.borderRight[t.borderRight.length - 1]);
2353
- t.width = Math.abs(s.x - i.x), t.height = Math.abs(o.y - r.y), t.x = i.x + t.width / 2, t.y = r.y + t.height / 2;
2354
- }
2355
- }), e.nodes().forEach((n) => {
2356
- e.node(n).dummy === "border" && e.removeNode(n);
2357
- });
2358
- }
2359
- function Nr(e) {
2360
- e.edges().forEach((n) => {
2361
- if (n.v === n.w) {
2362
- let t = e.node(n.v);
2363
- t.selfEdges || (t.selfEdges = []), t.selfEdges.push({
2364
- e: n,
2365
- label: e.edge(n)
2366
- }), e.removeEdge(n);
2367
- }
2368
- });
2369
- }
2370
- function Gr(e) {
2371
- P$1(e).forEach((t) => {
2372
- let r = 0;
2373
- t.forEach((o, i) => {
2374
- let s = e.node(o);
2375
- typeof s.rank != "number" && (s.rank = 0), s.order = i + r, (s.selfEdges || []).forEach((a) => {
2376
- M(e, "selfedge", {
2377
- width: a.label.width,
2378
- height: a.label.height,
2379
- rank: s.rank,
2380
- order: i + ++r,
2381
- e: a.e,
2382
- edgeLabel: a.label
2383
- }, "_se"), (!Array.isArray(a.label.points) || a.label.points.length !== 7) && (a.label.points = [
2384
- {
2385
- x: 0,
2386
- y: -10
2387
- },
2388
- {
2389
- x: 0,
2390
- y: -10
2391
- },
2392
- {
2393
- x: 0,
2394
- y: 0
2395
- },
2396
- {
2397
- x: 0,
2398
- y: 10
2399
- },
2400
- {
2401
- x: 0,
2402
- y: 10
2403
- },
2404
- {
2405
- x: 0,
2406
- y: 0
2407
- },
2408
- {
2409
- x: 0,
2410
- y: 0
2411
- }
2412
- ]);
2413
- }), delete s.selfEdges;
2414
- });
2415
- });
2416
- }
2417
- function vr(e) {
2418
- e.nodes().forEach((n) => {
2419
- let t = e.node(n), r = (o) => typeof o == "number" && isFinite(o);
2420
- if (t.dummy === "selfedge") {
2421
- let o = t, i = e.node(o.e.v), s = r(i == null ? void 0 : i.x) ? i.x : 0, a = r(i == null ? void 0 : i.y) ? i.y : 0, l = r(i == null ? void 0 : i.width) ? i.width : 0, u = r(i == null ? void 0 : i.height) ? i.height : 0, d = r(t.x) ? t.x : s, c = r(t.y) ? t.y : a, f = l / 2, h = u / 2;
2422
- o.edgeLabel.points = [
2423
- {
2424
- x: d + f,
2425
- y: c - h
2426
- },
2427
- {
2428
- x: d + f,
2429
- y: c - h
2430
- },
2431
- {
2432
- x: d,
2433
- y: c
2434
- },
2435
- {
2436
- x: d - f,
2437
- y: c + h
2438
- },
2439
- {
2440
- x: d - f,
2441
- y: c + h
2442
- },
2443
- {
2444
- x: d,
2445
- y: c
2446
- },
2447
- {
2448
- x: d,
2449
- y: c
2450
- }
2451
- ], o.edgeLabel.x = d, o.edgeLabel.y = c, e.setEdge(o.e, o.edgeLabel), e.removeNode(n);
2452
- } else t && Array.isArray(t.selfEdges) && t.selfEdges.forEach((o) => {
2453
- if (!Array.isArray(o.label.points) || o.label.points.length !== 7) {
2454
- let i = r(t.x) ? t.x : 0, s = r(t.y) ? t.y : 0, a = r(t.width) ? t.width : 0, l = r(t.height) ? t.height : 0, u = a / 2, d = l / 2;
2455
- o.label.points = [
2456
- {
2457
- x: i + u,
2458
- y: s - d
2459
- },
2460
- {
2461
- x: i + u,
2462
- y: s - d
2463
- },
2464
- {
2465
- x: i,
2466
- y: s
2467
- },
2468
- {
2469
- x: i - u,
2470
- y: s + d
2471
- },
2472
- {
2473
- x: i - u,
2474
- y: s + d
2475
- },
2476
- {
2477
- x: i,
2478
- y: s
2479
- },
2480
- {
2481
- x: i,
2482
- y: s
2483
- }
2484
- ];
2485
- }
2486
- });
2487
- });
2488
- }
2489
- function xe(e, n) {
2490
- return X(B(e, n), Number);
2491
- }
2492
- function _e(e) {
2493
- let n = {};
2494
- return e && Object.entries(e).forEach(([t, r]) => {
2495
- typeof t == "string" && (t = t.toLowerCase()), n[t] = r;
2496
- }), n;
2497
- }
2498
- /*! For license information please see dagre.esm.js.LEGAL.txt */
2499
- //#endregion
2500
264
  //#region src/canvas/browser/base/routeCrossings.ts
2501
265
  var epsilon = 1e-6;
2502
266
  function samePoint(a, b) {
@@ -2570,9 +334,24 @@ function hasRouteCrossings(routes) {
2570
334
  //#region src/canvas/browser/base/routeLayout.ts
2571
335
  var clearance = 16;
2572
336
  var portOffset = 24;
337
+ function componentIndex(sets) {
338
+ return new Map(sets.flatMap((ids, index) => ids.map((id) => [id, index])));
339
+ }
2573
340
  /** Orthogonal channels around the measured cards, in primary/cross coordinates. */
2574
- function routeLayout(nodes, edges) {
341
+ function routeLayout(nodes, edges, options = {}) {
2575
342
  const byId = new Map(nodes.map((node) => [node.id, node]));
343
+ const graph = new ie.Graph();
344
+ for (const node of nodes) graph.setNode(node.id);
345
+ for (const edge of edges) graph.setEdge(edge.source, edge.target);
346
+ const components = componentIndex(ie.alg.components(graph));
347
+ const cycles = componentIndex(ie.alg.tarjan(graph));
348
+ const obstacles = nodes.map((node) => ({
349
+ component: components.get(node.id),
350
+ left: node.x - clearance,
351
+ right: node.x + node.width + clearance,
352
+ top: node.y - clearance,
353
+ bottom: node.y + node.height + clearance
354
+ }));
2576
355
  const connections = edges.map((edge) => {
2577
356
  const source = byId.get(edge.source);
2578
357
  const target = byId.get(edge.target);
@@ -2585,11 +364,15 @@ function routeLayout(nodes, edges) {
2585
364
  y: target.y + (edge.targetOffset?.y ?? target.height / 2)
2586
365
  };
2587
366
  const offset = output.x < input.x ? Math.min(portOffset, (input.x - output.x) / 2) : portOffset;
367
+ const feedback = input.x <= output.x && cycles.get(edge.source) === cycles.get(edge.target);
2588
368
  return {
2589
369
  id: edge.id,
370
+ component: components.get(edge.source),
2590
371
  source: output,
2591
372
  target: input,
2592
373
  returnSide: input.x <= output.x ? Math.sign(input.y - output.y) : 0,
374
+ feedback,
375
+ returnLane: void 0,
2593
376
  start: {
2594
377
  x: output.x + offset,
2595
378
  y: output.y
@@ -2600,12 +383,23 @@ function routeLayout(nodes, edges) {
2600
383
  }
2601
384
  };
2602
385
  });
2603
- const obstacles = nodes.map((node) => ({
2604
- left: node.x - clearance,
2605
- right: node.x + node.width + clearance,
2606
- top: node.y - clearance,
2607
- bottom: node.y + node.height + clearance
2608
- }));
386
+ const feedback = connections.filter((edge) => edge.feedback).toSorted((a, b) => a.source.x - a.target.x - (b.source.x - b.target.x));
387
+ for (const [index, edge] of feedback.entries()) {
388
+ const side = edge.source.y <= edge.target.y ? -1 : 1;
389
+ const span = obstacles.filter((rect) => rect.component === edge.component && rect.right >= edge.end.x && rect.left <= edge.start.x);
390
+ let lane = side < 0 ? Math.min(...span.map((rect) => rect.top)) : Math.max(...span.map((rect) => rect.bottom));
391
+ let previousLane;
392
+ do {
393
+ previousLane = lane;
394
+ for (const rect of obstacles) if (rect.right >= edge.end.x && rect.left <= edge.start.x && lane > rect.top && lane < rect.bottom) lane = side < 0 ? rect.top : rect.bottom;
395
+ for (const other of feedback.slice(0, index)) {
396
+ if (other.component !== edge.component || other.start.x < edge.end.x || other.end.x > edge.start.x) continue;
397
+ if (side < 0 && other.returnLane <= lane) lane = other.returnLane - clearance;
398
+ if (side > 0 && other.returnLane >= lane) lane = other.returnLane + clearance;
399
+ }
400
+ } while (lane !== previousLane);
401
+ edge.returnLane = lane;
402
+ }
2609
403
  const routes = /* @__PURE__ */ new Map();
2610
404
  const pending = connections.filter((edge) => {
2611
405
  if (edge.start.x > edge.end.x) return true;
@@ -2637,7 +431,11 @@ function routeLayout(nodes, edges) {
2637
431
  });
2638
432
  if (!pending.length) return routes;
2639
433
  const xs = [.../* @__PURE__ */ new Set([...obstacles.flatMap((rect) => [rect.left, rect.right]), ...pending.flatMap((edge) => [edge.start.x, edge.end.x])])].toSorted((a, b) => a - b);
2640
- const ys = [.../* @__PURE__ */ new Set([...obstacles.flatMap((rect) => [rect.top, rect.bottom]), ...pending.flatMap((edge) => [edge.start.y, edge.end.y])])].toSorted((a, b) => a - b);
434
+ const ys = [.../* @__PURE__ */ new Set([...obstacles.flatMap((rect) => [rect.top, rect.bottom]), ...pending.flatMap((edge) => edge.returnLane == null ? [edge.start.y, edge.end.y] : [
435
+ edge.start.y,
436
+ edge.end.y,
437
+ edge.returnLane
438
+ ])])].toSorted((a, b) => a - b);
2641
439
  const xIndex = new Map(xs.map((value, index) => [value, index]));
2642
440
  const yIndex = new Map(ys.map((value, index) => [value, index]));
2643
441
  const columns = xs.length;
@@ -2687,7 +485,9 @@ function routeLayout(nodes, edges) {
2687
485
  ];
2688
486
  for (const [index, next] of moves.entries()) {
2689
487
  if (next < 0 || vertex === start && index === 0 || next === end && index === 0) continue;
2690
- if (edge.returnSide * (ys[Math.floor(next / columns)] - edge.start.y) < -1e-6) continue;
488
+ if (edge.returnLane != null) {
489
+ if (index === 0 && ys[y] !== edge.returnLane) continue;
490
+ } else if (edge.returnSide * (ys[Math.floor(next / columns)] - edge.start.y) < -1e-6) continue;
2691
491
  const axis = index < 2 ? 0 : 1;
2692
492
  const state = next * 2 + axis;
2693
493
  const length = Math.abs(xs[next % columns] - xs[x]) + Math.abs(ys[Math.floor(next / columns)] - ys[y]);
@@ -2702,7 +502,10 @@ function routeLayout(nodes, edges) {
2702
502
  });
2703
503
  }
2704
504
  }
2705
- if (finish < 0) throw new Error("Could not route the compact workflow connection.");
505
+ if (finish < 0) {
506
+ if (options.allowBlockedPorts) continue;
507
+ throw new Error("Could not route the compact workflow connection.");
508
+ }
2706
509
  const points = [];
2707
510
  for (let state = finish; state >= 0; state = previous[state]) {
2708
511
  const vertex = Math.floor(state / 2);
@@ -3121,63 +924,6 @@ function isInside(target, selector) {
3121
924
  return target?.closest?.(selector) != null;
3122
925
  }
3123
926
  //#endregion
3124
- //#region src/canvas/browser/base/graphLayout.ts
3125
- /** The measured dependency layout shared by canvas arrangement and image export. */
3126
- function graphLayout(nodes, edges, direction) {
3127
- if (!nodes.length) return {
3128
- nodes: [],
3129
- edges: []
3130
- };
3131
- const graph = new ie.Graph().setDefaultEdgeLabel(() => ({}));
3132
- graph.setGraph({
3133
- rankdir: direction === "vertical" ? "TB" : "LR",
3134
- ranksep: direction === "vertical" ? 48 : 80
3135
- });
3136
- const singles = new Set(nodes.map((node) => node.id));
3137
- for (const node of nodes) graph.setNode(node.id, {
3138
- width: node.width,
3139
- height: node.height
3140
- });
3141
- const connections = edges.filter((edge) => graph.hasNode(edge.source) && graph.hasNode(edge.target));
3142
- for (const edge of connections) {
3143
- singles.delete(edge.source);
3144
- singles.delete(edge.target);
3145
- graph.setEdge(edge.source, edge.target);
3146
- }
3147
- const isolated = [...singles];
3148
- for (let start = 0; start < isolated.length; start += 10) for (let index = start; index < Math.min(start + 9, isolated.length - 1); index++) graph.setEdge(isolated[index], isolated[index + 1]);
3149
- const constraints = [];
3150
- const ordering = new ie.Graph();
3151
- for (const node of nodes) {
3152
- const targets = [...new Set(node.branchHandles?.flatMap((handle) => connections.filter((edge) => edge.source === node.id && edge.sourceHandle === handle).map((edge) => edge.target)))];
3153
- for (let index = 1; index < targets.length; index++) {
3154
- const left = targets[index - 1];
3155
- const right = targets[index];
3156
- ordering.setEdge(left, right);
3157
- if (ie.alg.isAcyclic(ordering)) constraints.push({
3158
- left,
3159
- right
3160
- });
3161
- else ordering.removeEdge(left, right);
3162
- }
3163
- }
3164
- Oe(graph, { constraints });
3165
- return {
3166
- nodes: nodes.map((node) => {
3167
- const { x, y, width, height, rank } = graph.node(node.id);
3168
- return {
3169
- id: node.id,
3170
- column: rank,
3171
- x: x - width / 2,
3172
- y: y - height / 2,
3173
- width,
3174
- height
3175
- };
3176
- }),
3177
- edges: connections.map((edge) => Object.assign({}, edge, { points: graph.edge(edge.source, edge.target).points }))
3178
- };
3179
- }
3180
- //#endregion
3181
927
  //#region src/canvas/browser/stores/node/constants.ts
3182
928
  var NODE_TYPE = /* @__PURE__ */ function(NODE_TYPE) {
3183
929
  NODE_TYPE["TaskNode"] = "task_node";
@@ -3811,7 +1557,8 @@ var CanvasStore = class {
3811
1557
  constructor(model, editable, language, callbacks, options = {}) {
3812
1558
  this.canDeleteNodes = true;
3813
1559
  this.dispose = disposableStore();
3814
- this.connectionRoutes = this.dispose.add(val(/* @__PURE__ */ new Map()));
1560
+ this.exportRoutes = this.dispose.add(val(/* @__PURE__ */ new Map()));
1561
+ this.layoutRequest = this.dispose.add(val(0));
3815
1562
  this.ignoredNodeIds = this.dispose.add(val([]));
3816
1563
  this.ignoreNodes = (nodeIds, ignored) => {
3817
1564
  if (this.$.editable.value) this.#callbacks.onIgnoreNodes?.(nodeIds, ignored);
@@ -3838,16 +1585,27 @@ var CanvasStore = class {
3838
1585
  };
3839
1586
  this.disposed = false;
3840
1587
  this.layoutMeasurementAttempts = 0;
1588
+ this.initialLayoutPending = false;
3841
1589
  this.#modelDirection = "horizontal";
3842
1590
  this.pendingNodeDeletes = /* @__PURE__ */ new Set();
3843
1591
  this.pendingDisconnects = /* @__PURE__ */ new Map();
3844
1592
  this.#entries = /* @__PURE__ */ new Map();
3845
1593
  this.#modelPositions = /* @__PURE__ */ new Map();
3846
1594
  this.#selectedNodeIds = /* @__PURE__ */ new Set();
1595
+ this.requestLayout = () => {
1596
+ if (this.disposed) return;
1597
+ this.layoutComplete = false;
1598
+ this.layoutMeasurementAttempts = 0;
1599
+ this.initialLayoutPending = true;
1600
+ this.layoutRequest.set(this.layoutRequest.value + 1);
1601
+ };
3847
1602
  this.completeLayout = (availableWidth) => {
3848
1603
  if (this.disposed || this.layoutComplete) return true;
3849
1604
  const nodes = this.allLayoutNodes();
3850
- if (nodes.length === 0 && !this.$.changingDirection.value) return true;
1605
+ if (nodes.length === 0 && !this.$.changingDirection.value) {
1606
+ this.resolveInitialLayout(void 0);
1607
+ return true;
1608
+ }
3851
1609
  for (const node of nodes) {
3852
1610
  const measured = node.$.measured.value;
3853
1611
  if (!measured?.width || !measured.height) {
@@ -3855,6 +1613,7 @@ var CanvasStore = class {
3855
1613
  this.layoutMeasurementAttempts = 0;
3856
1614
  this.layoutComplete = true;
3857
1615
  this.#restoreDirection();
1616
+ this.resolveInitialLayout(void 0);
3858
1617
  return true;
3859
1618
  }
3860
1619
  }
@@ -3862,6 +1621,10 @@ var CanvasStore = class {
3862
1621
  this.applyPositions(positions);
3863
1622
  this.layoutMeasurementAttempts = 0;
3864
1623
  this.layoutComplete = true;
1624
+ this.resolveInitialLayout({
1625
+ direction: this.$.direction.value,
1626
+ positions
1627
+ });
3865
1628
  if (this.$.changingDirection.value) this.#saveDirection(positions);
3866
1629
  else this.#callbacks.onMoveNodes(positions);
3867
1630
  return "relayout";
@@ -3996,7 +1759,7 @@ var CanvasStore = class {
3996
1759
  const commentNodes = this.dispose.add(reactiveMap(null, { onDeleted: dispose }));
3997
1760
  const viewport = this.dispose.add(val(model.viewport, { equal: isSameViewport }));
3998
1761
  this.rfCommand = this.dispose.add(createRFCommand(nodes));
3999
- this.layoutComplete = !options.autoLayout;
1762
+ this.layoutComplete = true;
4000
1763
  this.#runStatus = this.dispose.add(val(model.runStatus == "running" ? FLOW_RUN_STATUS.Running : FLOW_RUN_STATUS.Idle));
4001
1764
  this.#connections = this.dispose.add(val([]));
4002
1765
  const edges = this.dispose.add(deriveEdges(this.#connections, nodes));
@@ -4033,8 +1796,14 @@ var CanvasStore = class {
4033
1796
  nodeMiniMapPhase: this.dispose.add(compute((get) => getNodeMinimap(get(nodes.$).size + get(commentNodes.$).size, get(viewport)?.zoom ?? 1)))
4034
1797
  };
4035
1798
  this.#syncModel(model);
1799
+ if (options.autoLayout) this.requestLayout();
4036
1800
  if (options.defaultDirection != null) this.changeDirection(options.defaultDirection);
4037
1801
  }
1802
+ resolveInitialLayout(layout) {
1803
+ if (!this.initialLayoutPending) return;
1804
+ this.initialLayoutPending = false;
1805
+ this.#callbacks.onInitialLayout?.(layout);
1806
+ }
4038
1807
  async #saveDirection(positions) {
4039
1808
  try {
4040
1809
  if (!await this.#callbacks.onChangeDirection?.(this.$.direction.value, positions) && !this.disposed) this.#restoreDirection();
@@ -4140,7 +1909,7 @@ var CanvasStore = class {
4140
1909
  edges
4141
1910
  }, insets, aspectRatio);
4142
1911
  this.applyPositions(result.positions);
4143
- this.connectionRoutes.set(result.routes);
1912
+ this.exportRoutes.set(result.routes);
4144
1913
  return result.bounds;
4145
1914
  }
4146
1915
  doRemoveNodes(nodes) {
@@ -15465,6 +13234,70 @@ function roundedConnectionPath(input) {
15465
13234
  return `${path} L ${end.x} ${end.y}`;
15466
13235
  }
15467
13236
  //#endregion
13237
+ //#region src/canvas/browser/graph/Edges/ConnectionRoutes.tsx
13238
+ var emptyRoutes = /* @__PURE__ */ new Map();
13239
+ var emptyNodes = [];
13240
+ var emptyEdges = [];
13241
+ var ConnectionRoutesContext = createContext(emptyRoutes);
13242
+ function inactiveNodes() {
13243
+ return emptyNodes;
13244
+ }
13245
+ function measuredNodes(state) {
13246
+ return [...state.nodeLookup.values()].flatMap((node) => node.hidden || !node.measured.width || !node.measured.height ? [] : [{
13247
+ id: node.id,
13248
+ ...layoutAxes(node.internals.positionAbsolute, "vertical"),
13249
+ width: node.measured.height,
13250
+ height: node.measured.width,
13251
+ column: 0,
13252
+ handles: node.internals.handleBounds
13253
+ }]);
13254
+ }
13255
+ function sameNodes(a, b) {
13256
+ return a.length === b.length && a.every((node, index) => shallowPlainObjectEqual(node, b[index]));
13257
+ }
13258
+ /** Share obstacle-aware routes using React Flow's measured cards and actual ports. */
13259
+ function ConnectionRoutesProvider({ direction, routes$, children }) {
13260
+ const planned = useVal(routes$);
13261
+ const active = direction === "vertical" && !planned?.size;
13262
+ const nodes = useStore(active ? measuredNodes : inactiveNodes, sameNodes);
13263
+ const edges = useStore((state) => active ? state.edges : emptyEdges);
13264
+ const routes = useMemo(() => {
13265
+ if (planned?.size) return planned;
13266
+ if (direction !== "vertical") return emptyRoutes;
13267
+ const byId = new Map(nodes.map((node) => [node.id, node]));
13268
+ const connections = edges.flatMap((edge) => {
13269
+ const source = byId.get(edge.source);
13270
+ const target = byId.get(edge.target);
13271
+ const output = source?.handles?.source?.find((handle) => edge.sourceHandle == null || handle.id === edge.sourceHandle);
13272
+ const input = target?.handles?.target?.find((handle) => edge.targetHandle == null || handle.id === edge.targetHandle);
13273
+ if (edge.hidden || !source || !target || output?.position !== Position.Bottom || input?.position !== Position.Top) return [];
13274
+ return [{
13275
+ id: edge.id,
13276
+ source: edge.source,
13277
+ target: edge.target,
13278
+ sourceOffset: {
13279
+ x: output.y + output.height,
13280
+ y: output.x + output.width / 2
13281
+ },
13282
+ targetOffset: {
13283
+ x: input.y,
13284
+ y: input.x + input.width / 2
13285
+ }
13286
+ }];
13287
+ });
13288
+ return new Map([...routeLayout(nodes, connections, { allowBlockedPorts: true })].map(([id, points]) => [id, points.map((point) => layoutAxes(point, "vertical"))]));
13289
+ }, [
13290
+ direction,
13291
+ nodes,
13292
+ edges,
13293
+ planned
13294
+ ]);
13295
+ return /* @__PURE__ */ jsx(ConnectionRoutesContext.Provider, {
13296
+ value: routes,
13297
+ children
13298
+ });
13299
+ }
13300
+ //#endregion
15468
13301
  //#region src/canvas/browser/graph/Edges/EdgeGradient.tsx
15469
13302
  function EdgeGradient({ id, sourceX, sourceY, targetX, targetY, sourceColor, targetColor }) {
15470
13303
  return /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", {
@@ -15491,7 +13324,7 @@ function BasicEdge(props) {
15491
13324
  const error = useVal(edgeStore?.$.error);
15492
13325
  const canvasStore = useCanvasStore();
15493
13326
  const scale = useVal(canvasStore.$.scale);
15494
- const routes = useVal(canvasStore.connectionRoutes);
13327
+ const routes = useContext(ConnectionRoutesContext);
15495
13328
  const gap = 3;
15496
13329
  const targetX = props.targetX + (props.targetPosition == Position.Left ? -3 : props.targetPosition == Position.Right ? gap : 0);
15497
13330
  const targetY = props.targetY + (props.targetPosition == Position.Top ? -3 : props.targetPosition == Position.Bottom ? gap : 0);
@@ -19423,7 +17256,7 @@ function timeZoneLabel(timezone, t, language) {
19423
17256
  //#region src/ui/browser/icon-stack.tsx
19424
17257
  /** A visual summary; the caller supplies an accessible label and tooltip. */
19425
17258
  function IconStack({ icons, count, limit = 3, size = "default", countClassName }) {
19426
- const frame = cn$1("relative flex shrink-0 items-center justify-center rounded-[6px] border border-border/50 bg-popover", size === "sm" ? "size-5" : "size-6");
17259
+ const frame = cn("relative flex shrink-0 items-center justify-center rounded-[6px] border border-border/50 bg-popover", size === "sm" ? "size-5" : "size-6");
19427
17260
  return /* @__PURE__ */ jsxs("span", {
19428
17261
  "aria-hidden": "true",
19429
17262
  className: "inline-flex shrink-0 items-center gap-1",
@@ -19433,11 +17266,11 @@ function IconStack({ icons, count, limit = 3, size = "default", countClassName }
19433
17266
  className: frame,
19434
17267
  children: /* @__PURE__ */ jsx(ContentIcon, {
19435
17268
  src: item.icon,
19436
- className: cn$1(size === "sm" ? "size-3.5" : "size-4", "data-[icon-kind=initials]:text-[20px]")
17269
+ className: cn(size === "sm" ? "size-3.5" : "size-4", "data-[icon-kind=initials]:text-[20px]")
19437
17270
  })
19438
17271
  }, item.id))
19439
17272
  }), /* @__PURE__ */ jsxs("span", {
19440
- className: cn$1("text-[10px] font-normal tabular-nums text-muted-foreground", countClassName),
17273
+ className: cn("text-[10px] font-normal tabular-nums text-muted-foreground", countClassName),
19441
17274
  children: ["+", count]
19442
17275
  })]
19443
17276
  });
@@ -20935,7 +18768,7 @@ var markdownPreview_module_default = {
20935
18768
  };
20936
18769
  //#endregion
20937
18770
  //#region src/canvas/browser/preview/markdownPreview.tsx
20938
- var MarkdownContent = lazy(() => import("./markdownContent-B75ojl0E.js"));
18771
+ var MarkdownContent = lazy(() => import("./markdownContent-BsdTdwBU.js"));
20939
18772
  var MarkdownPreview = /* @__PURE__ */ memo(({ dark, unstyled, components, contentClassName, content, draggable, onDoubleClick }) => {
20940
18773
  const [focus, setFocus] = useState(false);
20941
18774
  return /* @__PURE__ */ jsx("div", {
@@ -21558,7 +19391,7 @@ function ContextMenuContent({ align = "start", alignOffset = 0, className, conta
21558
19391
  side,
21559
19392
  sideOffset,
21560
19393
  children: /* @__PURE__ */ jsx(MenuPopup, {
21561
- className: cn$1("z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto overscroll-contain rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:animate-none motion-reduce:transition-none", className),
19394
+ className: cn("z-50 max-h-(--available-height) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto overscroll-contain rounded-lg bg-popover p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 motion-reduce:animate-none motion-reduce:transition-none", className),
21562
19395
  "data-slot": "context-menu-content",
21563
19396
  ...props
21564
19397
  })
@@ -21573,7 +19406,7 @@ function ContextMenuGroup(props) {
21573
19406
  }
21574
19407
  function ContextMenuItem({ className, variant = "default", ...props }) {
21575
19408
  return /* @__PURE__ */ jsx(MenuItem, {
21576
- className: cn$1("relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", className),
19409
+ className: cn("relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[variant=destructive]:text-destructive data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0", className),
21577
19410
  "data-slot": "context-menu-item",
21578
19411
  "data-variant": variant,
21579
19412
  ...props
@@ -22936,7 +20769,7 @@ function CanvasViewControls({ direction, changingDirection, onChangeDirection, i
22936
20769
  const [popupContainer, setPopupContainer] = useState(null);
22937
20770
  return /* @__PURE__ */ jsxs(Panel, {
22938
20771
  position: "bottom-left",
22939
- className: cn$1("open-flow-control-island open-flow-control-island-compact", ReactFlowContainer_module_default.dock, ReactFlowContainer_module_default.viewDock),
20772
+ className: cn("open-flow-control-island open-flow-control-island-compact", ReactFlowContainer_module_default.dock, ReactFlowContainer_module_default.viewDock),
22940
20773
  "data-canvas-control-scope": true,
22941
20774
  "data-tooltip-toolbar": true,
22942
20775
  ref: setPopupContainer,
@@ -23127,7 +20960,7 @@ function CanvasViewControls({ direction, changingDirection, onChangeDirection, i
23127
20960
  function CanvasToolbar({ children }) {
23128
20961
  return /* @__PURE__ */ jsx(Panel, {
23129
20962
  position: "bottom-center",
23130
- className: cn$1("open-flow-control-island", ReactFlowContainer_module_default.dock, ReactFlowContainer_module_default.createDock),
20963
+ className: cn("open-flow-control-island", ReactFlowContainer_module_default.dock, ReactFlowContainer_module_default.createDock),
23131
20964
  "data-canvas-control-scope": true,
23132
20965
  "data-tooltip-toolbar": true,
23133
20966
  children: /* @__PURE__ */ jsx("div", {
@@ -23139,7 +20972,7 @@ function CanvasToolbar({ children }) {
23139
20972
  function CanvasBottomRightControls({ children }) {
23140
20973
  return /* @__PURE__ */ jsx(Panel, {
23141
20974
  position: "bottom-right",
23142
- className: cn$1("open-flow-control-island open-flow-control-island-compact", ReactFlowContainer_module_default.dock),
20975
+ className: cn("open-flow-control-island open-flow-control-island-compact", ReactFlowContainer_module_default.dock),
23143
20976
  "data-canvas-control-scope": true,
23144
20977
  "data-tooltip-toolbar": true,
23145
20978
  children
@@ -23202,7 +21035,7 @@ var CornerControls = /* @__PURE__ */ memo(function(props) {
23202
21035
  "data-canvas-control-scope": true,
23203
21036
  position: "top-right",
23204
21037
  children: [props.before, props.children != null && /* @__PURE__ */ jsx(Controls, {
23205
- className: cn$1("open-flow-control-island open-flow-control-island-compact open-flow-control-island-soft-shadow", CornerControls_module_default.corner),
21038
+ className: cn("open-flow-control-island open-flow-control-island-compact open-flow-control-island-soft-shadow", CornerControls_module_default.corner),
23206
21039
  orientation: "horizontal",
23207
21040
  position: "top-right",
23208
21041
  showFitView: false,
@@ -23437,9 +21270,13 @@ var ReactFlowContainer = (props) => {
23437
21270
  i18n: props.i18n,
23438
21271
  children: /* @__PURE__ */ jsx(TooltipProvider, {
23439
21272
  delay: 300,
23440
- children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(HandleContextProvider, {
23441
- Handle: Handle$1,
23442
- children: /* @__PURE__ */ jsx(ReactFlowContainerInner, { ...props })
21273
+ children: /* @__PURE__ */ jsx(ReactFlowProvider, { children: /* @__PURE__ */ jsx(ConnectionRoutesProvider, {
21274
+ direction: props.direction,
21275
+ routes$: props.connectionRoutes$,
21276
+ children: /* @__PURE__ */ jsx(HandleContextProvider, {
21277
+ Handle: Handle$1,
21278
+ children: /* @__PURE__ */ jsx(ReactFlowContainerInner, { ...props })
21279
+ })
23443
21280
  }) })
23444
21281
  })
23445
21282
  })
@@ -23691,7 +21528,11 @@ var ReactFlowContainerInner = (props) => {
23691
21528
  ]);
23692
21529
  useLayoutEffect(() => {
23693
21530
  setLayoutReady(props.layoutMotion !== false || props.onLayoutMeasured == null);
23694
- }, [props.layoutMotion, props.onLayoutMeasured]);
21531
+ }, [
21532
+ props.layoutMotion,
21533
+ props.onLayoutMeasured,
21534
+ props.layoutRequest
21535
+ ]);
23695
21536
  useEffect(() => {
23696
21537
  let active = true;
23697
21538
  let measurementFrame = 0;
@@ -23738,6 +21579,7 @@ var ReactFlowContainerInner = (props) => {
23738
21579
  onBeforeFitView,
23739
21580
  props.layoutMotion,
23740
21581
  props.onLayoutMeasured,
21582
+ props.layoutRequest,
23741
21583
  props.direction,
23742
21584
  rf,
23743
21585
  updateNodeInternals
@@ -24163,6 +22005,7 @@ function tooShort(from, to) {
24163
22005
  var FlowCanvas = ({ flowCanvasStore, annotationContext, onActivateSelection, onSelectionStart, onSelectionEnd, onInspectSelection, inspectorOpen = false, onRequestAddNode, cornerTools, cornerLeading, topLeftTools, bottomRightTools, toolbar, dark, dottedBackground, fitView, nodesDraggable, layoutMotion, className, addNodeRequest, addItemRequest, onInit, onMove, onMoveEnd, onNodeDragStop, onSelectionChange, isValidConnection, onDropAddItem }) => {
24164
22006
  const editable = useVal(flowCanvasStore.$.editable);
24165
22007
  const direction = useVal(flowCanvasStore.$.direction);
22008
+ const layoutRequest = useVal(flowCanvasStore.layoutRequest);
24166
22009
  const changingDirection = useVal(flowCanvasStore.$.changingDirection);
24167
22010
  const nodeMiniMapPhase = useVal(flowCanvasStore.$.nodeMiniMapPhase);
24168
22011
  useEffect(flowCanvasStore.setupForceDelete, []);
@@ -24196,12 +22039,14 @@ var FlowCanvas = ({ flowCanvasStore, annotationContext, onActivateSelection, onS
24196
22039
  fitView: fitView ?? !editable,
24197
22040
  fitViewOptions,
24198
22041
  layoutMotion,
22042
+ layoutRequest,
24199
22043
  nodeTypes: NODE_TYPES,
24200
22044
  edgeTypes: EDGE_TYPES,
24201
22045
  miniMapExpanded$: flowCanvasStore.$$.miniMapExpanded,
24202
22046
  interactiveMode$: flowCanvasStore.$$.interactiveMode,
24203
22047
  nodes$: flowCanvasStore.$.rfNodes,
24204
22048
  edges$: flowCanvasStore.$.rfEdges,
22049
+ connectionRoutes$: flowCanvasStore.exportRoutes,
24205
22050
  viewport$: flowCanvasStore.$$.viewport,
24206
22051
  onRequestAddNode,
24207
22052
  addNodeRequest,