@html-graph/html-graph 5.1.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,24 +1,24 @@
1
- var Me = Object.defineProperty;
2
- var Re = (r, e, t) => e in r ? Me(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var s = (r, e, t) => Re(r, typeof e != "symbol" ? e + "" : e, t);
1
+ var Ce = Object.defineProperty;
2
+ var Ve = (r, e, t) => e in r ? Ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var s = (r, e, t) => Ve(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  const T = (r, e) => ({
5
5
  x: r.scale * e.x + r.x,
6
6
  y: r.scale * e.y + r.y
7
7
  });
8
- var L = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(L || {});
9
- const Le = () => {
8
+ var R = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(R || {});
9
+ const $e = () => {
10
10
  const r = document.createElement("div");
11
11
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
12
- }, Ce = () => {
12
+ }, Ue = () => {
13
13
  const r = document.createElement("div");
14
14
  return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
15
- }, Ve = (r) => {
15
+ }, Ie = (r) => {
16
16
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
17
17
  };
18
- class ue {
18
+ class ye {
19
19
  constructor(e, t, o) {
20
- s(this, "host", Le());
21
- s(this, "container", Ce());
20
+ s(this, "host", $e());
21
+ s(this, "container", Ue());
22
22
  s(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
23
23
  s(this, "attachedNodeIds", /* @__PURE__ */ new Set());
24
24
  s(this, "applyTransform", () => {
@@ -29,7 +29,7 @@ class ue {
29
29
  }
30
30
  attachNode(e) {
31
31
  const t = this.graphStore.getNode(e);
32
- Ve(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
32
+ Ie(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
33
33
  }
34
34
  detachNode(e) {
35
35
  const t = this.graphStore.getNode(e);
@@ -79,8 +79,8 @@ class ue {
79
79
  h,
80
80
  d
81
81
  );
82
- let g = L.Line;
83
- o.element === i.element ? g = L.PortCycle : o.nodeId === i.nodeId && (g = L.NodeCycle), t.payload.shape.render({ from: c, to: l, category: g });
82
+ let g = R.Line;
83
+ o.element === i.element ? g = R.PortCycle : o.nodeId === i.nodeId && (g = R.NodeCycle), t.payload.shape.render({ from: c, to: l, category: g });
84
84
  }
85
85
  updateEdgePriority(e) {
86
86
  const t = this.graphStore.getEdge(e);
@@ -100,7 +100,7 @@ class ue {
100
100
  };
101
101
  }
102
102
  }
103
- class $e {
103
+ class Be {
104
104
  constructor(e) {
105
105
  s(this, "xFrom", 1 / 0);
106
106
  s(this, "yFrom", 1 / 0);
@@ -120,7 +120,7 @@ class $e {
120
120
  return h <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
121
121
  }
122
122
  }
123
- class Ue {
123
+ class Oe {
124
124
  constructor(e, t, o, i) {
125
125
  s(this, "attachedNodes", /* @__PURE__ */ new Set());
126
126
  s(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -144,7 +144,7 @@ class Ue {
144
144
  this.handleAttachEdge(a);
145
145
  });
146
146
  });
147
- this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = i, this.renderingBox = new $e(this.graphStore), this.trigger.subscribe(this.updateViewport);
147
+ this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = i, this.renderingBox = new Be(this.graphStore), this.trigger.subscribe(this.updateViewport);
148
148
  }
149
149
  attachNode(e) {
150
150
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -198,7 +198,7 @@ class Ue {
198
198
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
199
199
  }
200
200
  }
201
- class Ie {
201
+ class Fe {
202
202
  constructor(e, t) {
203
203
  s(this, "deferredNodes", /* @__PURE__ */ new Set());
204
204
  s(this, "deferredEdges", /* @__PURE__ */ new Set());
@@ -252,7 +252,7 @@ class Ie {
252
252
  this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
253
253
  }
254
254
  }
255
- class pe {
255
+ class j {
256
256
  constructor() {
257
257
  s(this, "callbacks", /* @__PURE__ */ new Set());
258
258
  }
@@ -269,7 +269,7 @@ class pe {
269
269
  }
270
270
  }
271
271
  const E = () => {
272
- const r = new pe();
272
+ const r = new j();
273
273
  return [r, r];
274
274
  };
275
275
  class X {
@@ -294,7 +294,7 @@ class S extends Error {
294
294
  s(this, "name", "CanvasError");
295
295
  }
296
296
  }
297
- class we {
297
+ class me {
298
298
  constructor(e, t, o, i, n, a) {
299
299
  s(this, "nodeIdGenerator", new X(
300
300
  (e) => this.graphStore.getNode(e) !== void 0
@@ -510,7 +510,7 @@ class we {
510
510
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.destroyed = !0);
511
511
  }
512
512
  }
513
- class Be {
513
+ class We {
514
514
  constructor() {
515
515
  s(this, "singleToMultiMap", /* @__PURE__ */ new Map());
516
516
  s(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -550,16 +550,16 @@ class Be {
550
550
  return this.multiToSingleMap.get(e) !== void 0;
551
551
  }
552
552
  }
553
- class fe {
553
+ class ve {
554
554
  constructor() {
555
555
  s(this, "nodes", /* @__PURE__ */ new Map());
556
556
  s(this, "ports", /* @__PURE__ */ new Map());
557
557
  s(this, "edges", /* @__PURE__ */ new Map());
558
558
  s(this, "nodesElementsMap", /* @__PURE__ */ new Map());
559
- s(this, "incomingEdges", /* @__PURE__ */ new Map());
560
- s(this, "outcomingEdges", /* @__PURE__ */ new Map());
561
- s(this, "cycleEdges", /* @__PURE__ */ new Map());
562
- s(this, "elementPorts", new Be());
559
+ s(this, "portIncomingEdges", /* @__PURE__ */ new Map());
560
+ s(this, "portOutcomingEdges", /* @__PURE__ */ new Map());
561
+ s(this, "portCycleEdges", /* @__PURE__ */ new Map());
562
+ s(this, "elementPorts", new We());
563
563
  s(this, "afterNodeAddedEmitter");
564
564
  s(this, "onAfterNodeAdded");
565
565
  s(this, "afterNodeUpdatedEmitter");
@@ -626,7 +626,7 @@ class fe {
626
626
  direction: e.direction
627
627
  },
628
628
  nodeId: e.nodeId
629
- }), this.elementPorts.addRecord(e.element, e.id), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
629
+ }), this.elementPorts.addRecord(e.element, e.id), this.portCycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.portIncomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.portOutcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
630
630
  }
631
631
  getPort(e) {
632
632
  return this.ports.get(e);
@@ -677,16 +677,16 @@ class fe {
677
677
  this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
678
678
  }
679
679
  clear() {
680
- this.beforeClearEmitter.emit(), this.incomingEdges.clear(), this.outcomingEdges.clear(), this.cycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
680
+ this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutcomingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
681
681
  }
682
682
  getPortIncomingEdgeIds(e) {
683
- return Array.from(this.incomingEdges.get(e));
683
+ return Array.from(this.portIncomingEdges.get(e));
684
684
  }
685
685
  getPortOutgoingEdgeIds(e) {
686
- return Array.from(this.outcomingEdges.get(e));
686
+ return Array.from(this.portOutcomingEdges.get(e));
687
687
  }
688
688
  getPortCycleEdgeIds(e) {
689
- return Array.from(this.cycleEdges.get(e));
689
+ return Array.from(this.portCycleEdges.get(e));
690
690
  }
691
691
  getPortAdjacentEdgeIds(e) {
692
692
  return [
@@ -696,32 +696,51 @@ class fe {
696
696
  ];
697
697
  }
698
698
  getNodeIncomingEdgeIds(e) {
699
- const t = Array.from(this.nodes.get(e).ports.keys());
700
- let o = [];
699
+ const t = Array.from(this.nodes.get(e).ports.keys()), o = [];
701
700
  return t.forEach((i) => {
702
- o = [...o, ...this.getPortIncomingEdgeIds(i)];
701
+ this.getPortIncomingEdgeIds(i).filter((n) => {
702
+ const a = this.getEdge(n);
703
+ return this.getPort(a.from).nodeId !== e;
704
+ }).forEach((n) => {
705
+ o.push(n);
706
+ });
703
707
  }), o;
704
708
  }
705
709
  getNodeOutgoingEdgeIds(e) {
706
- const t = Array.from(this.nodes.get(e).ports.keys());
707
- let o = [];
710
+ const t = Array.from(this.nodes.get(e).ports.keys()), o = [];
708
711
  return t.forEach((i) => {
709
- o = [...o, ...this.getPortOutgoingEdgeIds(i)];
712
+ this.getPortOutgoingEdgeIds(i).filter((n) => {
713
+ const a = this.getEdge(n);
714
+ return this.getPort(a.to).nodeId !== e;
715
+ }).forEach((n) => {
716
+ o.push(n);
717
+ });
710
718
  }), o;
711
719
  }
712
720
  getNodeCycleEdgeIds(e) {
713
- const t = Array.from(this.nodes.get(e).ports.keys());
714
- let o = [];
721
+ const t = Array.from(this.nodes.get(e).ports.keys()), o = [];
715
722
  return t.forEach((i) => {
716
- o = [...o, ...this.getPortCycleEdgeIds(i)];
723
+ this.getPortCycleEdgeIds(i).forEach((n) => {
724
+ o.push(n);
725
+ }), this.getPortIncomingEdgeIds(i).filter((n) => {
726
+ const a = this.getEdge(n);
727
+ return this.getPort(a.to).nodeId === e;
728
+ }).forEach((n) => {
729
+ o.push(n);
730
+ });
717
731
  }), o;
718
732
  }
719
733
  getNodeAdjacentEdgeIds(e) {
720
- return [
721
- ...this.getNodeIncomingEdgeIds(e),
722
- ...this.getNodeOutgoingEdgeIds(e),
723
- ...this.getNodeCycleEdgeIds(e)
724
- ];
734
+ const t = Array.from(this.nodes.get(e).ports.keys()), o = [];
735
+ return t.forEach((i) => {
736
+ this.getPortIncomingEdgeIds(i).forEach((n) => {
737
+ o.push(n);
738
+ }), this.getPortOutgoingEdgeIds(i).forEach((n) => {
739
+ o.push(n);
740
+ }), this.getPortCycleEdgeIds(i).forEach((n) => {
741
+ o.push(n);
742
+ });
743
+ }), o;
725
744
  }
726
745
  addEdgeInternal(e) {
727
746
  this.edges.set(e.id, {
@@ -731,26 +750,26 @@ class fe {
731
750
  shape: e.shape,
732
751
  priority: e.priority
733
752
  }
734
- }), e.from !== e.to ? (this.outcomingEdges.get(e.from).add(e.id), this.incomingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
753
+ }), e.from !== e.to ? (this.portOutcomingEdges.get(e.from).add(e.id), this.portIncomingEdges.get(e.to).add(e.id)) : this.portCycleEdges.get(e.from).add(e.id);
735
754
  }
736
755
  removeEdgeInternal(e) {
737
756
  const t = this.edges.get(e), o = t.from, i = t.to;
738
- this.cycleEdges.get(o).delete(e), this.cycleEdges.get(i).delete(e), this.incomingEdges.get(o).delete(e), this.incomingEdges.get(i).delete(e), this.outcomingEdges.get(o).delete(e), this.outcomingEdges.get(i).delete(e), this.edges.delete(e);
757
+ this.portCycleEdges.get(o).delete(e), this.portCycleEdges.get(i).delete(e), this.portIncomingEdges.get(o).delete(e), this.portIncomingEdges.get(i).delete(e), this.portOutcomingEdges.get(o).delete(e), this.portOutcomingEdges.get(i).delete(e), this.edges.delete(e);
739
758
  }
740
759
  }
741
- const ie = (r) => ({
760
+ const de = (r) => ({
742
761
  scale: 1 / r.scale,
743
762
  x: -r.x / r.scale,
744
763
  y: -r.y / r.scale
745
- }), ne = {
764
+ }), ce = {
746
765
  scale: 1,
747
766
  x: 0,
748
767
  y: 0
749
768
  };
750
- class Fe {
769
+ class ke {
751
770
  constructor() {
752
- s(this, "viewportMatrix", ne);
753
- s(this, "contentMatrix", ne);
771
+ s(this, "viewportMatrix", ce);
772
+ s(this, "contentMatrix", ce);
754
773
  s(this, "afterUpdateEmitter");
755
774
  s(this, "onAfterUpdated");
756
775
  [this.afterUpdateEmitter, this.onAfterUpdated] = E();
@@ -766,17 +785,17 @@ class Fe {
766
785
  scale: e.scale ?? this.viewportMatrix.scale,
767
786
  x: e.x ?? this.viewportMatrix.x,
768
787
  y: e.y ?? this.viewportMatrix.y
769
- }, this.contentMatrix = ie(this.viewportMatrix), this.afterUpdateEmitter.emit();
788
+ }, this.contentMatrix = de(this.viewportMatrix), this.afterUpdateEmitter.emit();
770
789
  }
771
790
  patchContentMatrix(e) {
772
791
  this.contentMatrix = {
773
792
  scale: e.scale ?? this.contentMatrix.scale,
774
793
  x: e.x ?? this.contentMatrix.x,
775
794
  y: e.y ?? this.contentMatrix.y
776
- }, this.viewportMatrix = ie(this.contentMatrix), this.afterUpdateEmitter.emit();
795
+ }, this.viewportMatrix = de(this.contentMatrix), this.afterUpdateEmitter.emit();
777
796
  }
778
797
  }
779
- class j {
798
+ class G {
780
799
  constructor(e) {
781
800
  s(this, "elementToNodeId", /* @__PURE__ */ new Map());
782
801
  s(this, "nodesResizeObserver");
@@ -799,17 +818,17 @@ class j {
799
818
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
800
819
  }
801
820
  static configure(e) {
802
- new j(e);
821
+ new G(e);
803
822
  }
804
823
  handleNodeResize(e) {
805
824
  const t = this.elementToNodeId.get(e);
806
825
  this.canvas.updateNode(t);
807
826
  }
808
827
  }
809
- const Oe = (r, e, t) => {
828
+ const ze = (r, e, t) => {
810
829
  const { x: o, y: i, width: n, height: a } = r.getBoundingClientRect();
811
830
  return e >= o && e <= o + n && t >= i && t <= i + a;
812
- }, We = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, C = (r, e, t, o) => Oe(e, t, o) && We(r, t, o), I = (r, e) => {
831
+ }, Xe = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, C = (r, e, t, o) => ze(e, t, o) && Xe(r, t, o), I = (r, e) => {
813
832
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
814
833
  }, B = (r) => {
815
834
  const e = document.createElement("div");
@@ -826,22 +845,22 @@ const Oe = (r, e, t) => {
826
845
  }
827
846
  ]
828
847
  };
829
- }, ke = (r, e) => {
848
+ }, Ye = (r, e) => {
830
849
  let t = e, o = null;
831
850
  for (; t !== null && (o = r.getElementPortIds(t)[0] ?? null, o === null); )
832
851
  t = t.parentElement;
833
852
  return o;
834
- }, ye = (r, e) => {
853
+ }, Ee = (r, e) => {
835
854
  const t = document.elementsFromPoint(e.x, e.y);
836
855
  for (const o of t) {
837
- const i = ke(r, o);
856
+ const i = Ye(r, o);
838
857
  if (i !== null)
839
858
  return i;
840
859
  }
841
860
  return null;
842
861
  };
843
862
  var P = /* @__PURE__ */ ((r) => (r.Static = "static", r.Dragging = "dragging", r.Edge = "edge", r))(P || {});
844
- const me = (r, e) => ({
863
+ const Ae = (r, e) => ({
845
864
  x: r / 2,
846
865
  y: e / 2
847
866
  }), u = {
@@ -850,7 +869,7 @@ const me = (r, e) => ({
850
869
  }, m = (r, e, t) => ({
851
870
  x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
852
871
  y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
853
- }), ve = (r, e) => {
872
+ }), xe = (r, e) => {
854
873
  const t = {
855
874
  x: r.x + r.width / 2,
856
875
  y: r.y + r.height / 2
@@ -866,11 +885,11 @@ const me = (r, e) => ({
866
885
  flipX: d,
867
886
  flipY: c
868
887
  };
869
- }, O = (r, e, t, o) => ({
888
+ }, F = (r, e, t, o) => ({
870
889
  x: e * r.x + (1 - e) / 2 * o.x,
871
890
  y: t * r.y + (1 - t) / 2 * o.y
872
891
  });
873
- class ze {
892
+ class He {
874
893
  constructor(e) {
875
894
  s(this, "path");
876
895
  s(this, "midpoint");
@@ -895,7 +914,7 @@ class ze {
895
914
  this.path = `${d}${h}${c}`;
896
915
  }
897
916
  }
898
- class Xe {
917
+ class je {
899
918
  constructor(e) {
900
919
  s(this, "path");
901
920
  s(this, "midpoint");
@@ -947,26 +966,26 @@ class Xe {
947
966
  `C ${y.x} ${y.y} ${x.x} ${x.y} ${f.x} ${f.y}`,
948
967
  `C ${A.x} ${A.y} ${v.x} ${v.y} ${g.x} ${g.y}`,
949
968
  `L ${o.x} ${o.y}`
950
- ].join(" "), this.midpoint = O(f, e.flipX, e.flipY, e.to);
969
+ ].join(" "), this.midpoint = F(f, e.flipX, e.flipY, e.to);
951
970
  }
952
971
  }
953
- const G = Object.freeze({
972
+ const K = Object.freeze({
954
973
  edgeColor: "--edge-color"
955
- }), Ee = (r) => {
974
+ }), Se = (r) => {
956
975
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
957
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(G.edgeColor, r), e;
958
- }, Ae = (r) => {
976
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(K.edgeColor, r), e;
977
+ }, Pe = (r) => {
959
978
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
960
- return e.setAttribute("stroke", `var(${G.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
961
- }, F = () => {
979
+ return e.setAttribute("stroke", `var(${K.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
980
+ }, O = () => {
962
981
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
963
- return r.setAttribute("fill", `var(${G.edgeColor})`), r;
964
- }, xe = () => {
982
+ return r.setAttribute("fill", `var(${K.edgeColor})`), r;
983
+ }, be = () => {
965
984
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
966
985
  return r.style.transformOrigin = "50% 50%", r;
967
- }, Se = (r, e) => {
986
+ }, Te = (r, e) => {
968
987
  r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${Math.max(e.width, 1)}px`, r.style.height = `${Math.max(e.height, 1)}px`;
969
- }, M = (r, e) => {
988
+ }, L = (r, e) => {
970
989
  const t = [];
971
990
  if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
972
991
  const o = r.length - 1;
@@ -978,15 +997,15 @@ const G = Object.freeze({
978
997
  const V = r[d + 1];
979
998
  i = V.x - h.x, n = V.y - h.y, a = Math.sqrt(i * i + n * n);
980
999
  }
981
- const x = a !== 0 ? Math.min((y ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, A = y ? { x: h.x + i * x, y: h.y + n * x } : h, b = g !== 0 ? Math.min((y ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, D = y ? { x: h.x + c * b, y: h.y + l * b } : h;
982
- d > 0 && t.push(`L ${D.x} ${D.y}`), y && t.push(
1000
+ const x = a !== 0 ? Math.min((y ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, A = y ? { x: h.x + i * x, y: h.y + n * x } : h, b = g !== 0 ? Math.min((y ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, N = y ? { x: h.x + c * b, y: h.y + l * b } : h;
1001
+ d > 0 && t.push(`L ${N.x} ${N.y}`), y && t.push(
983
1002
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${A.x} ${A.y}`
984
1003
  );
985
1004
  });
986
1005
  }
987
1006
  return t.join(" ");
988
1007
  };
989
- class Ye {
1008
+ class Ge {
990
1009
  constructor(e) {
991
1010
  s(this, "path");
992
1011
  s(this, "midpoint");
@@ -1019,13 +1038,13 @@ class Ye {
1019
1038
  x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
1020
1039
  y: d.y
1021
1040
  }, y = { x: f.x, y: l };
1022
- this.path = M(
1041
+ this.path = L(
1023
1042
  [o, h, g, p, y, f, d, i],
1024
1043
  this.params.roundness
1025
1044
  );
1026
1045
  }
1027
1046
  }
1028
- class He {
1047
+ class Ke {
1029
1048
  constructor(e) {
1030
1049
  s(this, "path");
1031
1050
  s(this, "midpoint");
@@ -1050,13 +1069,13 @@ class He {
1050
1069
  this.params.targetDirection,
1051
1070
  this.params.to
1052
1071
  ), p = { x: g.x + d, y: g.y + c }, f = { x: (l.x + p.x) / 2, y: (l.y + p.y) / 2 };
1053
- this.midpoint = O(f, e.flipX, e.flipY, e.to), this.path = M(
1072
+ this.midpoint = F(f, e.flipX, e.flipY, e.to), this.path = L(
1054
1073
  [t, n, l, p, g, o],
1055
1074
  this.params.roundness
1056
1075
  );
1057
1076
  }
1058
1077
  }
1059
- class je {
1078
+ class Ze {
1060
1079
  constructor(e) {
1061
1080
  s(this, "path");
1062
1081
  s(this, "midpoint");
@@ -1083,10 +1102,10 @@ class je {
1083
1102
  this.params.targetDirection,
1084
1103
  this.params.to
1085
1104
  );
1086
- this.path = M([o, a, h, i], this.params.roundness);
1105
+ this.path = L([o, a, h, i], this.params.roundness);
1087
1106
  }
1088
1107
  }
1089
- class Ge {
1108
+ class Je {
1090
1109
  constructor(e) {
1091
1110
  s(this, "path");
1092
1111
  s(this, "midpoint");
@@ -1119,13 +1138,13 @@ class Ge {
1119
1138
  x: d.x,
1120
1139
  y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
1121
1140
  }, y = { x: l, y: f.y };
1122
- this.path = M(
1141
+ this.path = L(
1123
1142
  [o, h, g, p, y, f, d, i],
1124
1143
  this.params.roundness
1125
1144
  );
1126
1145
  }
1127
1146
  }
1128
- class K {
1147
+ class Z {
1129
1148
  constructor(e) {
1130
1149
  s(this, "path");
1131
1150
  s(this, "midpoint");
@@ -1142,10 +1161,10 @@ class K {
1142
1161
  ].map(
1143
1162
  (c) => m(c, this.params.sourceDirection, u)
1144
1163
  ), d = `M ${u.x} ${u.y} L ${h[0].x} ${h[0].y} `;
1145
- this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${M(h, this.params.roundness)}`, this.midpoint = { x: (h[3].x + h[4].x) / 2, y: (h[3].y + h[4].y) / 2 };
1164
+ this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${L(h, this.params.roundness)}`, this.midpoint = { x: (h[3].x + h[4].x) / 2, y: (h[3].y + h[4].y) / 2 };
1146
1165
  }
1147
1166
  }
1148
- class Ke {
1167
+ class Qe {
1149
1168
  constructor(e) {
1150
1169
  s(this, "path");
1151
1170
  s(this, "midpoint");
@@ -1166,7 +1185,7 @@ class Ke {
1166
1185
  this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : f}${p}`, this.midpoint = g[3];
1167
1186
  }
1168
1187
  }
1169
- class Ze {
1188
+ class _e {
1170
1189
  constructor(e) {
1171
1190
  s(this, "path");
1172
1191
  s(this, "midpoint");
@@ -1202,7 +1221,7 @@ class Ze {
1202
1221
  };
1203
1222
  }
1204
1223
  }
1205
- class Je {
1224
+ class qe {
1206
1225
  constructor(e) {
1207
1226
  s(this, "path");
1208
1227
  s(this, "midpoint");
@@ -1230,7 +1249,7 @@ class Je {
1230
1249
  x: (n.x + a.x) / 2,
1231
1250
  y: l
1232
1251
  };
1233
- this.midpoint = O(g, e.flipX, e.flipY, e.to), this.path = M(
1252
+ this.midpoint = F(g, e.flipX, e.flipY, e.to), this.path = L(
1234
1253
  [
1235
1254
  t,
1236
1255
  n,
@@ -1243,7 +1262,7 @@ class Je {
1243
1262
  );
1244
1263
  }
1245
1264
  }
1246
- class Qe {
1265
+ class et {
1247
1266
  constructor(e) {
1248
1267
  s(this, "path");
1249
1268
  s(this, "midpoint");
@@ -1271,7 +1290,7 @@ class Qe {
1271
1290
  x: l,
1272
1291
  y: (n.y + a.y) / 2
1273
1292
  };
1274
- this.midpoint = O(g, e.flipX, e.flipY, e.to), this.path = M(
1293
+ this.midpoint = F(g, e.flipX, e.flipY, e.to), this.path = L(
1275
1294
  [
1276
1295
  t,
1277
1296
  n,
@@ -1306,30 +1325,30 @@ const w = Object.freeze({
1306
1325
  curvature: 90,
1307
1326
  interactiveWidth: 10,
1308
1327
  preOffset: 0
1309
- }), ae = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1328
+ }), ge = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1310
1329
  class W {
1311
1330
  constructor(e) {
1312
1331
  s(this, "svg");
1313
- s(this, "group", xe());
1332
+ s(this, "group", be());
1314
1333
  s(this, "line");
1315
1334
  s(this, "sourceArrow", null);
1316
1335
  s(this, "targetArrow", null);
1317
1336
  s(this, "onAfterRender");
1318
1337
  s(this, "afterRenderEmitter");
1319
1338
  s(this, "arrowRenderer");
1320
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ee(e.color), this.svg.appendChild(this.group), this.line = Ae(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = F(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = F(), this.group.appendChild(this.targetArrow));
1339
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Se(e.color), this.svg.appendChild(this.group), this.line = Pe(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = O(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = O(), this.group.appendChild(this.targetArrow));
1321
1340
  }
1322
1341
  render(e) {
1323
- const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = ve(
1342
+ const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = xe(
1324
1343
  e.from,
1325
1344
  e.to
1326
1345
  );
1327
- Se(this.svg, { x: t, y: o, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1328
- const d = ae(
1346
+ Te(this.svg, { x: t, y: o, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1347
+ const d = ge(
1329
1348
  e.from.direction,
1330
1349
  a,
1331
1350
  h
1332
- ), c = ae(
1351
+ ), c = ge(
1333
1352
  e.to.direction,
1334
1353
  a,
1335
1354
  h
@@ -1338,7 +1357,7 @@ class W {
1338
1357
  y: n
1339
1358
  };
1340
1359
  let g = { x: -c.x, y: -c.y }, p;
1341
- e.category === L.PortCycle ? (p = this.params.createCyclePath, g = d) : e.category === L.NodeCycle ? p = this.params.createDetourPath : p = this.params.createLinePath;
1360
+ e.category === R.PortCycle ? (p = this.params.createCyclePath, g = d) : e.category === R.NodeCycle ? p = this.params.createDetourPath : p = this.params.createLinePath;
1342
1361
  const f = p(
1343
1362
  d,
1344
1363
  c,
@@ -1365,7 +1384,7 @@ class W {
1365
1384
  });
1366
1385
  }
1367
1386
  }
1368
- const _e = (r) => (e) => {
1387
+ const tt = (r) => (e) => {
1369
1388
  const o = [
1370
1389
  u,
1371
1390
  { x: e.arrowLength, y: r.radius },
@@ -1377,7 +1396,7 @@ const _e = (r) => (e) => {
1377
1396
  y: h.y + e.shift.y
1378
1397
  })), i = `M ${o[0].x} ${o[0].y}`, n = `L ${o[1].x} ${o[1].y}`, a = `L ${o[2].x} ${o[2].y}`;
1379
1398
  return `${i} ${n} ${a} Z`;
1380
- }, qe = (r) => (e) => {
1399
+ }, rt = (r) => (e) => {
1381
1400
  const t = r.radius, o = e.arrowLength, i = (o * o + 2 * o * t) / (2 * t), n = i + t, a = o + t - t * (o + t) / n, h = t * i / n, c = [u, { x: a, y: -h }, { x: a, y: h }].map(
1382
1401
  (y) => m(y, e.direction, u)
1383
1402
  ).map((y) => ({
@@ -1385,7 +1404,7 @@ const _e = (r) => (e) => {
1385
1404
  y: y.y + e.shift.y
1386
1405
  })), l = `M ${c[0].x} ${c[0].y}`, g = `A ${i} ${i} 0 0 0 ${c[1].x} ${c[1].y}`, p = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, f = `A ${i} ${i} 0 0 0 ${c[0].x} ${c[0].y}`;
1387
1406
  return `${l} ${g} ${p} ${f}`;
1388
- }, et = (r) => (e) => {
1407
+ }, ot = (r) => (e) => {
1389
1408
  const t = r.smallRadius, o = r.radius, i = m(
1390
1409
  {
1391
1410
  x: e.arrowLength,
@@ -1411,22 +1430,22 @@ const _e = (r) => (e) => {
1411
1430
  return r;
1412
1431
  switch (r.type) {
1413
1432
  case "triangle":
1414
- return _e({
1433
+ return tt({
1415
1434
  radius: r.radius ?? w.polygonArrowRadius
1416
1435
  });
1417
1436
  case "arc":
1418
- return qe({
1437
+ return rt({
1419
1438
  radius: r.radius ?? w.circleArrowRadius
1420
1439
  });
1421
1440
  default:
1422
- return et({
1441
+ return ot({
1423
1442
  smallRadius: r.smallRadius ?? w.wedgeArrowSmallRadius,
1424
1443
  angle: r.angle ?? w.wedgeArrowAngle,
1425
1444
  radius: r.radius ?? w.wedgeArrowRadius
1426
1445
  });
1427
1446
  }
1428
1447
  };
1429
- class tt {
1448
+ class st {
1430
1449
  constructor(e) {
1431
1450
  s(this, "svg");
1432
1451
  s(this, "group");
@@ -1443,7 +1462,7 @@ class tt {
1443
1462
  s(this, "hasSourceArrow");
1444
1463
  s(this, "hasTargetArrow");
1445
1464
  s(this, "pathShape");
1446
- s(this, "createCyclePath", (e) => new Ke({
1465
+ s(this, "createCyclePath", (e) => new Qe({
1447
1466
  sourceDirection: e,
1448
1467
  radius: this.portCycleRadius,
1449
1468
  smallRadius: this.portCycleSmallRadius,
@@ -1451,7 +1470,7 @@ class tt {
1451
1470
  hasSourceArrow: this.hasSourceArrow,
1452
1471
  hasTargetArrow: this.hasTargetArrow
1453
1472
  }));
1454
- s(this, "createDetourPath", (e, t, o, i, n) => new Xe({
1473
+ s(this, "createDetourPath", (e, t, o, i, n) => new je({
1455
1474
  to: o,
1456
1475
  sourceDirection: e,
1457
1476
  targetDirection: t,
@@ -1464,7 +1483,7 @@ class tt {
1464
1483
  hasSourceArrow: this.hasSourceArrow,
1465
1484
  hasTargetArrow: this.hasTargetArrow
1466
1485
  }));
1467
- s(this, "createLinePath", (e, t, o) => new ze({
1486
+ s(this, "createLinePath", (e, t, o) => new He({
1468
1487
  to: o,
1469
1488
  sourceDirection: e,
1470
1489
  targetDirection: t,
@@ -1489,7 +1508,7 @@ class tt {
1489
1508
  this.pathShape.render(e);
1490
1509
  }
1491
1510
  }
1492
- class rt {
1511
+ class it {
1493
1512
  constructor(e) {
1494
1513
  s(this, "svg");
1495
1514
  s(this, "group");
@@ -1505,7 +1524,7 @@ class rt {
1505
1524
  s(this, "hasSourceArrow");
1506
1525
  s(this, "hasTargetArrow");
1507
1526
  s(this, "pathShape");
1508
- s(this, "createCyclePath", (e) => new K({
1527
+ s(this, "createCyclePath", (e) => new Z({
1509
1528
  sourceDirection: e,
1510
1529
  arrowLength: this.arrowLength,
1511
1530
  side: this.cycleSquareSide,
@@ -1514,7 +1533,7 @@ class rt {
1514
1533
  hasSourceArrow: this.hasSourceArrow,
1515
1534
  hasTargetArrow: this.hasTargetArrow
1516
1535
  }));
1517
- s(this, "createDetourPath", (e, t, o, i, n) => new Je({
1536
+ s(this, "createDetourPath", (e, t, o, i, n) => new qe({
1518
1537
  to: o,
1519
1538
  sourceDirection: e,
1520
1539
  targetDirection: t,
@@ -1527,7 +1546,7 @@ class rt {
1527
1546
  hasSourceArrow: this.hasSourceArrow,
1528
1547
  hasTargetArrow: this.hasTargetArrow
1529
1548
  }));
1530
- s(this, "createLinePath", (e, t, o, i) => new Ye({
1549
+ s(this, "createLinePath", (e, t, o, i) => new Ge({
1531
1550
  to: o,
1532
1551
  sourceDirection: e,
1533
1552
  targetDirection: t,
@@ -1560,7 +1579,7 @@ class rt {
1560
1579
  this.pathShape.render(e);
1561
1580
  }
1562
1581
  }
1563
- class ot {
1582
+ class nt {
1564
1583
  constructor(e) {
1565
1584
  s(this, "svg");
1566
1585
  s(this, "group");
@@ -1577,7 +1596,7 @@ class ot {
1577
1596
  s(this, "hasSourceArrow");
1578
1597
  s(this, "hasTargetArrow");
1579
1598
  s(this, "pathShape");
1580
- s(this, "createCyclePath", (e) => new K({
1599
+ s(this, "createCyclePath", (e) => new Z({
1581
1600
  sourceDirection: e,
1582
1601
  arrowLength: this.arrowLength,
1583
1602
  side: this.cycleSquareSide,
@@ -1586,7 +1605,7 @@ class ot {
1586
1605
  hasSourceArrow: this.hasSourceArrow,
1587
1606
  hasTargetArrow: this.hasTargetArrow
1588
1607
  }));
1589
- s(this, "createDetourPath", (e, t, o, i, n) => new He({
1608
+ s(this, "createDetourPath", (e, t, o, i, n) => new Ke({
1590
1609
  to: o,
1591
1610
  sourceDirection: e,
1592
1611
  targetDirection: t,
@@ -1600,7 +1619,7 @@ class ot {
1600
1619
  hasSourceArrow: this.hasSourceArrow,
1601
1620
  hasTargetArrow: this.hasTargetArrow
1602
1621
  }));
1603
- s(this, "createLinePath", (e, t, o) => new je({
1622
+ s(this, "createLinePath", (e, t, o) => new Ze({
1604
1623
  to: o,
1605
1624
  sourceDirection: e,
1606
1625
  targetDirection: t,
@@ -1632,7 +1651,7 @@ class ot {
1632
1651
  this.pathShape.render(e);
1633
1652
  }
1634
1653
  }
1635
- class st {
1654
+ class at {
1636
1655
  constructor(e) {
1637
1656
  s(this, "svg");
1638
1657
  s(this, "group");
@@ -1648,7 +1667,7 @@ class st {
1648
1667
  s(this, "hasSourceArrow");
1649
1668
  s(this, "hasTargetArrow");
1650
1669
  s(this, "pathShape");
1651
- s(this, "createCyclePath", (e) => new K({
1670
+ s(this, "createCyclePath", (e) => new Z({
1652
1671
  sourceDirection: e,
1653
1672
  arrowLength: this.arrowLength,
1654
1673
  side: this.cycleSquareSide,
@@ -1657,7 +1676,7 @@ class st {
1657
1676
  hasSourceArrow: this.hasSourceArrow,
1658
1677
  hasTargetArrow: this.hasTargetArrow
1659
1678
  }));
1660
- s(this, "createDetourPath", (e, t, o, i, n) => new Qe({
1679
+ s(this, "createDetourPath", (e, t, o, i, n) => new et({
1661
1680
  to: o,
1662
1681
  sourceDirection: e,
1663
1682
  targetDirection: t,
@@ -1670,7 +1689,7 @@ class st {
1670
1689
  hasSourceArrow: this.hasSourceArrow,
1671
1690
  hasTargetArrow: this.hasTargetArrow
1672
1691
  }));
1673
- s(this, "createLinePath", (e, t, o, i, n) => new Ge({
1692
+ s(this, "createLinePath", (e, t, o, i, n) => new Je({
1674
1693
  to: o,
1675
1694
  sourceDirection: e,
1676
1695
  targetDirection: t,
@@ -1703,10 +1722,10 @@ class st {
1703
1722
  this.pathShape.render(e);
1704
1723
  }
1705
1724
  }
1706
- class Pe {
1725
+ class Ne {
1707
1726
  constructor(e) {
1708
1727
  s(this, "svg");
1709
- s(this, "group", xe());
1728
+ s(this, "group", be());
1710
1729
  s(this, "line");
1711
1730
  s(this, "sourceArrow", null);
1712
1731
  s(this, "targetArrow", null);
@@ -1718,15 +1737,15 @@ class Pe {
1718
1737
  s(this, "onAfterRender");
1719
1738
  s(this, "afterRenderEmitter");
1720
1739
  s(this, "arrowRenderer");
1721
- [this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? w.color, this.width = (e == null ? void 0 : e.width) ?? w.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? w.arrowLength, this.arrowRenderer = $((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? w.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? w.preOffset, this.svg = Ee(this.color), this.svg.appendChild(this.group), this.line = Ae(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = F(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = F(), this.group.appendChild(this.targetArrow));
1740
+ [this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? w.color, this.width = (e == null ? void 0 : e.width) ?? w.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? w.arrowLength, this.arrowRenderer = $((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? w.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? w.preOffset, this.svg = Se(this.color), this.svg.appendChild(this.group), this.line = Pe(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = O(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = O(), this.group.appendChild(this.targetArrow));
1722
1741
  }
1723
1742
  render(e) {
1724
- const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = ve(
1743
+ const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = xe(
1725
1744
  e.from,
1726
1745
  e.to
1727
1746
  );
1728
- Se(this.svg, { x: t, y: o, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1729
- const d = { x: i, y: n }, c = new Ze({
1747
+ Te(this.svg, { x: t, y: o, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1748
+ const d = { x: i, y: n }, c = new _e({
1730
1749
  to: d,
1731
1750
  sourceOffset: this.sourceOffset,
1732
1751
  targetOffset: this.targetOffset,
@@ -1777,40 +1796,40 @@ class Pe {
1777
1796
  });
1778
1797
  }
1779
1798
  }
1780
- const it = () => {
1799
+ const ht = () => {
1781
1800
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1782
1801
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1783
- }, nt = (r) => {
1802
+ }, dt = (r) => {
1784
1803
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1785
1804
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1786
- }, he = (r) => {
1805
+ }, le = (r) => {
1787
1806
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1788
1807
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1789
1808
  };
1790
- class at extends Error {
1809
+ class ct extends Error {
1791
1810
  constructor(e) {
1792
1811
  super(e), this.name = "InteractiveEdgeError";
1793
1812
  }
1794
1813
  }
1795
- class be {
1814
+ class De {
1796
1815
  constructor(e, t) {
1797
1816
  s(this, "svg");
1798
1817
  s(this, "group");
1799
1818
  s(this, "line");
1800
1819
  s(this, "sourceArrow");
1801
1820
  s(this, "targetArrow");
1802
- s(this, "handle", it());
1821
+ s(this, "handle", ht());
1803
1822
  s(this, "onAfterRender");
1804
1823
  s(this, "interactiveLine");
1805
1824
  s(this, "interactiveSourceArrow", null);
1806
1825
  s(this, "interactiveTargetArrow", null);
1807
- if (this.baseEdge = e, e instanceof be)
1808
- throw new at(
1826
+ if (this.baseEdge = e, e instanceof De)
1827
+ throw new ct(
1809
1828
  "interactive edge can be configured only once"
1810
1829
  );
1811
1830
  this.svg = this.baseEdge.svg, this.group = this.baseEdge.group, this.line = this.baseEdge.line, this.sourceArrow = this.baseEdge.sourceArrow, this.targetArrow = this.baseEdge.targetArrow, this.onAfterRender = this.baseEdge.onAfterRender;
1812
1831
  const o = (t == null ? void 0 : t.distance) ?? w.interactiveWidth;
1813
- this.interactiveLine = nt(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = he(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = he(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((i) => {
1832
+ this.interactiveLine = dt(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = le(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = le(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((i) => {
1814
1833
  this.interactiveLine.setAttribute("d", i.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", i.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", i.targetArrowPath);
1815
1834
  });
1816
1835
  }
@@ -1818,7 +1837,7 @@ class be {
1818
1837
  this.baseEdge.render(e);
1819
1838
  }
1820
1839
  }
1821
- class Lt {
1840
+ class kt {
1822
1841
  constructor(e, t) {
1823
1842
  s(this, "group");
1824
1843
  s(this, "line");
@@ -1835,7 +1854,7 @@ class Lt {
1835
1854
  this.baseShape.render(e);
1836
1855
  }
1837
1856
  }
1838
- class Te {
1857
+ class Le {
1839
1858
  constructor(e) {
1840
1859
  s(this, "onAfterNodeAdded");
1841
1860
  s(this, "onAfterNodeUpdated");
@@ -1928,7 +1947,7 @@ class Te {
1928
1947
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
1929
1948
  }
1930
1949
  }
1931
- class De {
1950
+ class Me {
1932
1951
  constructor(e) {
1933
1952
  s(this, "onAfterUpdated");
1934
1953
  this.viewportStore = e, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
@@ -1940,21 +1959,21 @@ class De {
1940
1959
  return { ...this.viewportStore.getContentMatrix() };
1941
1960
  }
1942
1961
  }
1943
- const Ne = (r, e) => {
1944
- const t = new fe(), o = new Te(t), i = new De(e), n = new ue(t, e, r), a = {
1962
+ const Re = (r, e) => {
1963
+ const t = new ve(), o = new Le(t), i = new Me(e), n = new ye(t, e, r), a = {
1945
1964
  nodes: {
1946
- centerFn: me,
1965
+ centerFn: Ae,
1947
1966
  priorityFn: () => 0
1948
1967
  },
1949
1968
  edges: {
1950
- shapeFactory: () => new Pe(),
1969
+ shapeFactory: () => new Ne(),
1951
1970
  priorityFn: () => 0
1952
1971
  },
1953
1972
  ports: {
1954
1973
  direction: 0
1955
1974
  }
1956
1975
  };
1957
- return new we(
1976
+ return new me(
1958
1977
  o,
1959
1978
  i,
1960
1979
  t,
@@ -2070,7 +2089,7 @@ class k {
2070
2089
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2071
2090
  }
2072
2091
  }
2073
- class Z {
2092
+ class J {
2074
2093
  constructor(e, t, o, i) {
2075
2094
  s(this, "grabbedNode", null);
2076
2095
  s(this, "maxNodePriority", 0);
@@ -2191,7 +2210,7 @@ class Z {
2191
2210
  this.canvas = e, this.element = t, this.window = o, this.params = i, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2192
2211
  }
2193
2212
  static configure(e, t, o, i) {
2194
- new Z(e, t, o, i);
2213
+ new J(e, t, o, i);
2195
2214
  }
2196
2215
  moveNode(e, t) {
2197
2216
  if (this.graph.getNode(e.nodeId) === null)
@@ -2260,11 +2279,11 @@ class Z {
2260
2279
  return e;
2261
2280
  }
2262
2281
  }
2263
- const ht = (r, e, t) => ({
2282
+ const gt = (r, e, t) => ({
2264
2283
  scale: r.scale,
2265
2284
  x: r.x + r.scale * e,
2266
2285
  y: r.y + r.scale * t
2267
- }), dt = (r, e, t, o) => ({
2286
+ }), lt = (r, e, t, o) => ({
2268
2287
  scale: r.scale * e,
2269
2288
  x: r.scale * (1 - e) * t + r.x,
2270
2289
  y: r.scale * (1 - e) * o + r.y
@@ -2387,7 +2406,7 @@ class z {
2387
2406
  new z(e, t, o, i);
2388
2407
  }
2389
2408
  moveViewport(e, t) {
2390
- const o = this.viewport.getViewportMatrix(), i = ht(o, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2409
+ const o = this.viewport.getViewportMatrix(), i = gt(o, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2391
2410
  prevTransform: o,
2392
2411
  nextTransform: i,
2393
2412
  canvasWidth: n,
@@ -2396,7 +2415,7 @@ class z {
2396
2415
  this.performTransform(h);
2397
2416
  }
2398
2417
  scaleViewport(e, t, o) {
2399
- const i = this.canvas.viewport.getViewportMatrix(), n = dt(i, e, t, o), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2418
+ const i = this.canvas.viewport.getViewportMatrix(), n = lt(i, e, t, o), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2400
2419
  prevTransform: i,
2401
2420
  nextTransform: n,
2402
2421
  canvasWidth: a,
@@ -2426,7 +2445,7 @@ class z {
2426
2445
  this.transformInProgress = !1, this.params.onTransformFinished();
2427
2446
  }
2428
2447
  }
2429
- class J {
2448
+ class Q {
2430
2449
  constructor(e, t, o, i, n, a) {
2431
2450
  s(this, "canvasResizeObserver");
2432
2451
  s(this, "nodeHorizontal");
@@ -2485,7 +2504,7 @@ class J {
2485
2504
  ), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
2486
2505
  }
2487
2506
  static configure(e, t, o, i, n, a) {
2488
- new J(
2507
+ new Q(
2489
2508
  e,
2490
2509
  t,
2491
2510
  o,
@@ -2508,24 +2527,24 @@ class J {
2508
2527
  this.trigger.emit({ x: o, y: i, width: n, height: a });
2509
2528
  }
2510
2529
  }
2511
- const ct = () => {
2530
+ const ut = () => {
2512
2531
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2513
2532
  return r.style.position = "absolute", r.style.inset = "0", r;
2514
- }, gt = () => {
2533
+ }, pt = () => {
2515
2534
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2516
2535
  return r.setAttribute("fill", "url(#pattern)"), r;
2517
- }, lt = () => {
2536
+ }, wt = () => {
2518
2537
  const r = document.createElementNS(
2519
2538
  "http://www.w3.org/2000/svg",
2520
2539
  "pattern"
2521
2540
  );
2522
2541
  return r.setAttribute("id", "pattern"), r;
2523
2542
  };
2524
- class Q {
2543
+ class _ {
2525
2544
  constructor(e, t, o) {
2526
- s(this, "svg", ct());
2527
- s(this, "patternRenderingRectangle", gt());
2528
- s(this, "pattern", lt());
2545
+ s(this, "svg", ut());
2546
+ s(this, "patternRenderingRectangle", pt());
2547
+ s(this, "pattern", wt());
2529
2548
  s(this, "patternContent");
2530
2549
  s(this, "tileWidth");
2531
2550
  s(this, "tileHeight");
@@ -2550,14 +2569,14 @@ class Q {
2550
2569
  n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.backgroundHost), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
2551
2570
  }
2552
2571
  static configure(e, t, o) {
2553
- new Q(e, t, o);
2572
+ new _(e, t, o);
2554
2573
  }
2555
2574
  updateVisibility() {
2556
2575
  const t = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
2557
2576
  t && this.visible ? (this.visible = !1, this.backgroundHost.removeChild(this.svg)) : !t && !this.visible && (this.visible = !0, this.backgroundHost.appendChild(this.svg));
2558
2577
  }
2559
2578
  }
2560
- class _ {
2579
+ class q {
2561
2580
  constructor(e, t, o, i, n) {
2562
2581
  s(this, "overlayCanvas");
2563
2582
  s(this, "staticPortId", null);
@@ -2565,7 +2584,7 @@ class _ {
2565
2584
  s(this, "onEdgeCreated", (e) => {
2566
2585
  this.params.onAfterEdgeCreated(e);
2567
2586
  });
2568
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Ne(
2587
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Re(
2569
2588
  this.overlayLayer,
2570
2589
  this.viewportStore
2571
2590
  ), k.configure(
@@ -2592,7 +2611,7 @@ class _ {
2592
2611
  );
2593
2612
  }
2594
2613
  static configure(e, t, o, i, n) {
2595
- new _(
2614
+ new q(
2596
2615
  e,
2597
2616
  t,
2598
2617
  o,
@@ -2630,7 +2649,7 @@ class _ {
2630
2649
  this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
2631
2650
  }
2632
2651
  tryCreateConnection(e) {
2633
- const t = ye(this.canvas.graph, e), o = this.staticPortId;
2652
+ const t = Ee(this.canvas.graph, e), o = this.staticPortId;
2634
2653
  if (t === null) {
2635
2654
  this.params.onEdgeCreationInterrupted({
2636
2655
  staticPortId: o,
@@ -2652,7 +2671,7 @@ class _ {
2652
2671
  });
2653
2672
  }
2654
2673
  }
2655
- class q {
2674
+ class ee {
2656
2675
  constructor(e, t, o, i, n) {
2657
2676
  s(this, "overlayCanvas");
2658
2677
  s(this, "staticPortId", null);
@@ -2661,7 +2680,7 @@ class q {
2661
2680
  s(this, "onEdgeReattached", (e) => {
2662
2681
  this.params.onAfterEdgeReattached(e);
2663
2682
  });
2664
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Ne(
2683
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Re(
2665
2684
  this.overlayLayer,
2666
2685
  this.viewportStore
2667
2686
  ), k.configure(
@@ -2685,7 +2704,7 @@ class q {
2685
2704
  );
2686
2705
  }
2687
2706
  static configure(e, t, o, i, n) {
2688
- new q(
2707
+ new ee(
2689
2708
  e,
2690
2709
  t,
2691
2710
  o,
@@ -2727,14 +2746,14 @@ class q {
2727
2746
  overlayId: P.Dragging,
2728
2747
  portCoords: v,
2729
2748
  portDirection: d.direction
2730
- }, [R, b] = this.isTargetDragging ? [x, A] : [A, x];
2731
- this.overlayCanvas.addNode(B(R)), this.overlayCanvas.addNode(B(b));
2732
- const D = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(P.Edge) : i.shape;
2749
+ }, [M, b] = this.isTargetDragging ? [x, A] : [A, x];
2750
+ this.overlayCanvas.addNode(B(M)), this.overlayCanvas.addNode(B(b));
2751
+ const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(P.Edge) : i.shape;
2733
2752
  return this.overlayCanvas.addEdge({
2734
2753
  id: P.Edge,
2735
- from: R.overlayId,
2754
+ from: M.overlayId,
2736
2755
  to: b.overlayId,
2737
- shape: D
2756
+ shape: N
2738
2757
  }), !0;
2739
2758
  }
2740
2759
  resetDragState() {
@@ -2751,7 +2770,7 @@ class q {
2751
2770
  });
2752
2771
  }
2753
2772
  tryCreateConnection(e) {
2754
- const t = ye(this.canvas.graph, e);
2773
+ const t = Ee(this.canvas.graph, e);
2755
2774
  if (this.overlayCanvas.removeEdge(P.Edge), t === null) {
2756
2775
  const d = this.draggingEdgePayload;
2757
2776
  this.params.onEdgeReattachInterrupted({
@@ -2784,45 +2803,147 @@ class q {
2784
2803
  }
2785
2804
  }
2786
2805
  }
2787
- const ut = () => {
2806
+ class te {
2807
+ constructor(e, t, o) {
2808
+ this.canvas = e, this.layoutAlgorithm = t, this.trigger = o, this.trigger.subscribe(() => {
2809
+ this.applyLayout();
2810
+ });
2811
+ }
2812
+ static configure(e, t, o) {
2813
+ new te(
2814
+ e,
2815
+ t,
2816
+ o
2817
+ );
2818
+ }
2819
+ applyLayout() {
2820
+ this.layoutAlgorithm.calculateCoordinates(this.canvas.graph).forEach((t, o) => {
2821
+ this.canvas.updateNode(o, t);
2822
+ });
2823
+ }
2824
+ }
2825
+ class re {
2826
+ constructor(e, t) {
2827
+ s(this, "applyScheduled", !1);
2828
+ this.canvas = e, this.layoutAlgorithm = t, this.canvas.graph.onAfterNodeAdded.subscribe(() => {
2829
+ this.scheduleApply();
2830
+ }), this.canvas.graph.onBeforeNodeRemoved.subscribe(() => {
2831
+ this.scheduleApply();
2832
+ }), this.canvas.graph.onAfterEdgeAdded.subscribe(() => {
2833
+ this.scheduleApply();
2834
+ }), this.canvas.graph.onBeforeEdgeRemoved.subscribe(() => {
2835
+ this.scheduleApply();
2836
+ });
2837
+ }
2838
+ static configure(e, t) {
2839
+ new re(
2840
+ e,
2841
+ t
2842
+ );
2843
+ }
2844
+ scheduleApply() {
2845
+ this.applyScheduled || (this.applyScheduled = !0, setTimeout(() => {
2846
+ this.applyScheduled = !1, this.applyLayout();
2847
+ }));
2848
+ }
2849
+ applyLayout() {
2850
+ this.layoutAlgorithm.calculateCoordinates(this.canvas.graph).forEach((t, o) => {
2851
+ this.canvas.updateNode(o, t);
2852
+ });
2853
+ }
2854
+ }
2855
+ class ft {
2856
+ static configure(e, t) {
2857
+ const o = t.applyOn;
2858
+ switch (o.type) {
2859
+ case "manual": {
2860
+ te.configure(
2861
+ e,
2862
+ t.algorithm,
2863
+ o.trigger
2864
+ );
2865
+ break;
2866
+ }
2867
+ case "topologyChangeTimeout": {
2868
+ re.configure(
2869
+ e,
2870
+ t.algorithm
2871
+ );
2872
+ break;
2873
+ }
2874
+ }
2875
+ }
2876
+ }
2877
+ class yt {
2878
+ constructor(e, t) {
2879
+ s(this, "previousTimeStamp");
2880
+ s(this, "step", (e) => {
2881
+ if (this.previousTimeStamp === void 0)
2882
+ this.previousTimeStamp = e;
2883
+ else {
2884
+ const t = (e - this.previousTimeStamp) / 1e3;
2885
+ this.previousTimeStamp = e, this.callback(t);
2886
+ }
2887
+ this.win.requestAnimationFrame(this.step);
2888
+ });
2889
+ this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
2890
+ }
2891
+ }
2892
+ class oe {
2893
+ constructor(e, t, o, i) {
2894
+ s(this, "step", (e) => {
2895
+ this.params.algorithm.calculateNextCoordinates(
2896
+ this.canvas.graph,
2897
+ e
2898
+ ).forEach((o, i) => {
2899
+ this.staticNodes.has(i) || this.canvas.updateNode(i, { x: o.x, y: o.y });
2900
+ });
2901
+ });
2902
+ this.canvas = e, this.params = t, this.staticNodes = o, this.win = i, new yt(this.win, this.step);
2903
+ }
2904
+ static configure(e, t, o, i) {
2905
+ new oe(e, t, o, i);
2906
+ }
2907
+ }
2908
+ const mt = () => {
2788
2909
  const r = document.createElement("div");
2789
2910
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
2790
2911
  }, Y = () => {
2791
2912
  const r = document.createElement("div");
2792
2913
  return r.style.position = "absolute", r.style.inset = "0", r;
2793
- }, de = () => {
2914
+ }, ue = () => {
2794
2915
  const r = Y();
2795
2916
  return r.style.pointerEvents = "none", r;
2796
2917
  };
2797
- class pt {
2918
+ class vt {
2798
2919
  constructor(e) {
2799
2920
  s(this, "background", Y());
2800
2921
  s(this, "main", Y());
2801
- s(this, "overlayConnectablePorts", de());
2802
- s(this, "overlayDraggableEdges", de());
2803
- s(this, "host", ut());
2922
+ s(this, "overlayConnectablePorts", ue());
2923
+ s(this, "overlayDraggableEdges", ue());
2924
+ s(this, "host", mt());
2804
2925
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.host.appendChild(this.overlayConnectablePorts), this.host.appendChild(this.overlayDraggableEdges);
2805
2926
  }
2806
2927
  destroy() {
2807
2928
  this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlayConnectablePorts), this.host.removeChild(this.overlayDraggableEdges), this.element.removeChild(this.host);
2808
2929
  }
2809
2930
  }
2810
- const H = (r) => () => r, ce = H(0), wt = () => {
2931
+ const H = (r) => () => r, pe = H(0), Et = () => {
2811
2932
  let r = 0;
2812
2933
  return () => r++;
2813
- }, ft = (r, e) => {
2814
- let t = ce, o = ce;
2815
- const i = wt();
2934
+ }, At = (r, e) => {
2935
+ let t = pe, o = pe;
2936
+ const i = Et();
2816
2937
  return r === "incremental" && (t = i), e === "incremental" && (o = i), typeof r == "number" && (t = H(r)), typeof e == "number" && (o = H(e)), typeof r == "function" && (t = r), typeof e == "function" && (o = e), {
2817
2938
  nodesPriorityFn: t,
2818
2939
  edgesPriorityFn: o
2819
2940
  };
2820
- }, ee = (r) => {
2941
+ }, se = (r) => {
2821
2942
  if (typeof r == "function")
2822
2943
  return r;
2823
2944
  switch (r.type) {
2824
2945
  case "straight":
2825
- return () => new ot({
2946
+ return () => new nt({
2826
2947
  color: r.color,
2827
2948
  width: r.width,
2828
2949
  arrowLength: r.arrowLength,
@@ -2836,7 +2957,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2836
2957
  detourDirection: r.detourDirection
2837
2958
  });
2838
2959
  case "horizontal":
2839
- return () => new rt({
2960
+ return () => new it({
2840
2961
  color: r.color,
2841
2962
  width: r.width,
2842
2963
  arrowLength: r.arrowLength,
@@ -2849,7 +2970,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2849
2970
  detourDistance: r.detourDistance
2850
2971
  });
2851
2972
  case "vertical":
2852
- return () => new st({
2973
+ return () => new at({
2853
2974
  color: r.color,
2854
2975
  width: r.width,
2855
2976
  arrowLength: r.arrowLength,
@@ -2862,7 +2983,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2862
2983
  detourDistance: r.detourDistance
2863
2984
  });
2864
2985
  case "direct":
2865
- return () => new Pe({
2986
+ return () => new Ne({
2866
2987
  color: r.color,
2867
2988
  width: r.width,
2868
2989
  arrowLength: r.arrowLength,
@@ -2873,7 +2994,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2873
2994
  targetOffset: r.targetOffset
2874
2995
  });
2875
2996
  default:
2876
- return () => new tt({
2997
+ return () => new st({
2877
2998
  color: r.color,
2878
2999
  width: r.width,
2879
3000
  arrowLength: r.arrowLength,
@@ -2887,26 +3008,26 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2887
3008
  detourDirection: r.detourDirection
2888
3009
  });
2889
3010
  }
2890
- }, yt = (r) => {
3011
+ }, xt = (r) => {
2891
3012
  var t, o, i, n, a;
2892
- const e = ft(
3013
+ const e = At(
2893
3014
  (t = r.nodes) == null ? void 0 : t.priority,
2894
3015
  (o = r.edges) == null ? void 0 : o.priority
2895
3016
  );
2896
3017
  return {
2897
3018
  nodes: {
2898
- centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? me,
3019
+ centerFn: ((i = r.nodes) == null ? void 0 : i.centerFn) ?? Ae,
2899
3020
  priorityFn: e.nodesPriorityFn
2900
3021
  },
2901
3022
  ports: {
2902
3023
  direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
2903
3024
  },
2904
3025
  edges: {
2905
- shapeFactory: ee(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
3026
+ shapeFactory: se(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
2906
3027
  priorityFn: e.edgesPriorityFn
2907
3028
  }
2908
3029
  };
2909
- }, mt = (r) => {
3030
+ }, St = (r) => {
2910
3031
  var p, f, y, v, x;
2911
3032
  const e = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
2912
3033
  }), t = r.nodeDragVerifier ?? (() => !0), o = ((f = r.events) == null ? void 0 : f.onNodeDragFinished) ?? (() => {
@@ -2922,7 +3043,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2922
3043
  nodeDragVerifier: t,
2923
3044
  onNodeDragFinished: o
2924
3045
  };
2925
- }, vt = (r) => {
3046
+ }, Pt = (r) => {
2926
3047
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, o = r.minY !== null ? r.minY : -1 / 0, i = r.maxY !== null ? r.maxY : 1 / 0;
2927
3048
  return (n) => {
2928
3049
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -2932,7 +3053,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2932
3053
  const l = n.canvasHeight * n.prevTransform.scale, g = i - l;
2933
3054
  return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
2934
3055
  };
2935
- }, Et = (r) => {
3056
+ }, bt = (r) => {
2936
3057
  const e = r.maxContentScale, t = r.minContentScale, o = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
2937
3058
  return (n) => {
2938
3059
  const a = n.prevTransform, h = n.nextTransform;
@@ -2953,7 +3074,7 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2953
3074
  y: l
2954
3075
  };
2955
3076
  };
2956
- }, At = (r) => (e) => r.reduce(
3077
+ }, Tt = (r) => (e) => r.reduce(
2957
3078
  (t, o) => o({
2958
3079
  prevTransform: e.prevTransform,
2959
3080
  nextTransform: t,
@@ -2961,40 +3082,40 @@ const H = (r) => () => r, ce = H(0), wt = () => {
2961
3082
  canvasHeight: e.canvasHeight
2962
3083
  }),
2963
3084
  e.nextTransform
2964
- ), ge = (r) => {
3085
+ ), we = (r) => {
2965
3086
  if (typeof r == "function")
2966
3087
  return r;
2967
3088
  switch (r.type) {
2968
3089
  case "scale-limit":
2969
- return Et({
3090
+ return bt({
2970
3091
  minContentScale: r.minContentScale ?? 0,
2971
3092
  maxContentScale: r.maxContentScale ?? 1 / 0
2972
3093
  });
2973
3094
  case "shift-limit":
2974
- return vt({
3095
+ return Pt({
2975
3096
  minX: r.minX ?? -1 / 0,
2976
3097
  maxX: r.maxX ?? 1 / 0,
2977
3098
  minY: r.minY ?? -1 / 0,
2978
3099
  maxY: r.maxY ?? 1 / 0
2979
3100
  });
2980
3101
  }
2981
- }, le = (r) => {
2982
- var y, v, x, A, R, b, D, V, te, re, oe, se;
3102
+ }, fe = (r) => {
3103
+ var y, v, x, A, M, b, N, V, ie, ne, ae, he;
2983
3104
  const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, o = r == null ? void 0 : r.transformPreprocessor;
2984
3105
  let i;
2985
- o !== void 0 ? Array.isArray(o) ? i = At(
3106
+ o !== void 0 ? Array.isArray(o) ? i = Tt(
2986
3107
  o.map(
2987
- (N) => ge(N)
3108
+ (D) => we(D)
2988
3109
  )
2989
- ) : i = ge(o) : i = (N) => N.nextTransform;
3110
+ ) : i = we(o) : i = (D) => D.nextTransform;
2990
3111
  const n = ((v = r == null ? void 0 : r.shift) == null ? void 0 : v.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
2991
3112
  }), h = ((A = r == null ? void 0 : r.events) == null ? void 0 : A.onTransformChange) ?? (() => {
2992
- }), d = (R = r == null ? void 0 : r.shift) == null ? void 0 : R.mouseDownEventVerifier, c = d !== void 0 ? d : (N) => N.button === 0, l = (b = r == null ? void 0 : r.shift) == null ? void 0 : b.mouseUpEventVerifier, g = l !== void 0 ? l : (N) => N.button === 0, p = (D = r == null ? void 0 : r.scale) == null ? void 0 : D.mouseWheelEventVerifier, f = p !== void 0 ? p : () => !0;
3113
+ }), d = (M = r == null ? void 0 : r.shift) == null ? void 0 : M.mouseDownEventVerifier, c = d !== void 0 ? d : (D) => D.button === 0, l = (b = r == null ? void 0 : r.shift) == null ? void 0 : b.mouseUpEventVerifier, g = l !== void 0 ? l : (D) => D.button === 0, p = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, f = p !== void 0 ? p : () => !0;
2993
3114
  return {
2994
3115
  wheelSensitivity: t,
2995
3116
  onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
2996
3117
  }),
2997
- onTransformFinished: ((te = r == null ? void 0 : r.events) == null ? void 0 : te.onTransformFinished) ?? (() => {
3118
+ onTransformFinished: ((ie = r == null ? void 0 : r.events) == null ? void 0 : ie.onTransformFinished) ?? (() => {
2998
3119
  }),
2999
3120
  onBeforeTransformChange: a,
3000
3121
  onTransformChange: h,
@@ -3003,30 +3124,30 @@ const H = (r) => () => r, ce = H(0), wt = () => {
3003
3124
  mouseDownEventVerifier: c,
3004
3125
  mouseUpEventVerifier: g,
3005
3126
  mouseWheelEventVerifier: f,
3006
- scaleWheelFinishTimeout: ((re = r == null ? void 0 : r.scale) == null ? void 0 : re.wheelFinishTimeout) ?? 500,
3007
- onResizeTransformStarted: ((oe = r == null ? void 0 : r.events) == null ? void 0 : oe.onResizeTransformStarted) ?? (() => {
3127
+ scaleWheelFinishTimeout: ((ne = r == null ? void 0 : r.scale) == null ? void 0 : ne.wheelFinishTimeout) ?? 500,
3128
+ onResizeTransformStarted: ((ae = r == null ? void 0 : r.events) == null ? void 0 : ae.onResizeTransformStarted) ?? (() => {
3008
3129
  }),
3009
- onResizeTransformFinished: ((se = r == null ? void 0 : r.events) == null ? void 0 : se.onResizeTransformFinished) ?? (() => {
3130
+ onResizeTransformFinished: ((he = r == null ? void 0 : r.events) == null ? void 0 : he.onResizeTransformFinished) ?? (() => {
3010
3131
  })
3011
3132
  };
3012
- }, xt = (r, e) => {
3133
+ }, Nt = (r, e) => {
3013
3134
  const t = document.createElementNS(
3014
3135
  "http://www.w3.org/2000/svg",
3015
3136
  "circle"
3016
3137
  );
3017
3138
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
3018
- }, St = (r) => r instanceof SVGElement ? r : xt(
3139
+ }, Dt = (r) => r instanceof SVGElement ? r : Nt(
3019
3140
  (r == null ? void 0 : r.radius) ?? 1.5,
3020
3141
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
3021
- ), Pt = (r) => {
3022
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, i = St(r.renderer ?? {});
3142
+ ), Lt = (r) => {
3143
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, i = Dt(r.renderer ?? {});
3023
3144
  return {
3024
3145
  tileWidth: t,
3025
3146
  tileHeight: o,
3026
3147
  renderer: i,
3027
3148
  maxViewportScale: r.maxViewportScale ?? 10
3028
3149
  };
3029
- }, bt = (r, e, t) => {
3150
+ }, Mt = (r, e, t) => {
3030
3151
  var c, l, g;
3031
3152
  const o = () => "direct", i = (p) => p, n = (p) => p.button === 0, a = () => {
3032
3153
  }, h = () => {
@@ -3041,9 +3162,9 @@ const H = (r) => () => r, ce = H(0), wt = () => {
3041
3162
  onEdgeCreationInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeCreationInterrupted) ?? d,
3042
3163
  onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? h,
3043
3164
  dragPortDirection: r.dragPortDirection ?? t,
3044
- edgeShapeFactory: r.edgeShape !== void 0 ? ee(r.edgeShape) : e
3165
+ edgeShapeFactory: r.edgeShape !== void 0 ? se(r.edgeShape) : e
3045
3166
  };
3046
- }, Tt = (r, e) => {
3167
+ }, Rt = (r, e) => {
3047
3168
  var c, l, g;
3048
3169
  const t = (p) => p, o = (p) => p.button === 0 && p.ctrlKey, i = (p) => p.button === 0, n = (p) => {
3049
3170
  const f = e.getPortAdjacentEdgeIds(p);
@@ -3057,15 +3178,15 @@ const H = (r) => () => r, ce = H(0), wt = () => {
3057
3178
  mouseDownEventVerifier: r.mouseDownEventVerifier ?? o,
3058
3179
  mouseUpEventVerifier: r.mouseUpEventVerifier ?? i,
3059
3180
  draggingEdgeResolver: r.draggingEdgeResolver ?? n,
3060
- draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ee(r.draggingEdgeShape) : null,
3181
+ draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? se(r.draggingEdgeShape) : null,
3061
3182
  onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
3062
3183
  onEdgeReattachInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeReattachInterrupted) ?? d,
3063
3184
  onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
3064
3185
  };
3065
- }, Dt = (r) => ({
3186
+ }, Ct = (r) => ({
3066
3187
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3067
3188
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3068
- }), Nt = (r) => {
3189
+ }), Vt = (r) => {
3069
3190
  var e, t;
3070
3191
  return {
3071
3192
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3074,13 +3195,36 @@ const H = (r) => () => r, ce = H(0), wt = () => {
3074
3195
  })
3075
3196
  };
3076
3197
  };
3077
- class Mt extends Error {
3198
+ class $t extends Error {
3078
3199
  constructor() {
3079
3200
  super(...arguments);
3080
3201
  s(this, "name", "CanvasBuilderError");
3081
3202
  }
3082
3203
  }
3083
- class Ct {
3204
+ const Ut = (r) => ({
3205
+ algorithm: r.algorithm
3206
+ }), It = (r) => r instanceof j ? {
3207
+ type: "manual",
3208
+ trigger: r
3209
+ } : {
3210
+ type: "topologyChangeTimeout"
3211
+ }, Bt = (r) => ({
3212
+ algorithm: r.algorithm,
3213
+ applyOn: It(r.applyOn)
3214
+ }), Ot = (r, e) => ({
3215
+ ...r,
3216
+ nodeDragVerifier: (t) => (e.add(t), r.nodeDragVerifier(t)),
3217
+ onNodeDragFinished: (t) => {
3218
+ e.delete(t), r.onNodeDragFinished(t);
3219
+ }
3220
+ }), Ft = (r, e) => {
3221
+ r.onBeforeNodeRemoved.subscribe((t) => {
3222
+ e.delete(t);
3223
+ }), r.onBeforeClear.subscribe(() => {
3224
+ e.clear();
3225
+ });
3226
+ };
3227
+ class zt {
3084
3228
  constructor(e) {
3085
3229
  s(this, "used", !1);
3086
3230
  s(this, "canvasDefaults", {});
@@ -3090,18 +3234,21 @@ class Ct {
3090
3234
  s(this, "connectablePortsConfig", {});
3091
3235
  s(this, "draggableEdgesConfig", {});
3092
3236
  s(this, "virtualScrollConfig");
3093
- s(this, "hasDraggableNode", !1);
3237
+ s(this, "layoutConfig");
3238
+ s(this, "animatedLayoutConfig");
3239
+ s(this, "hasDraggableNodes", !1);
3094
3240
  s(this, "hasTransformableViewport", !1);
3095
3241
  s(this, "hasNodeResizeReactiveEdges", !1);
3096
3242
  s(this, "hasBackground", !1);
3097
3243
  s(this, "hasUserConnectablePorts", !1);
3098
3244
  s(this, "hasUserDraggableEdges", !1);
3099
- s(this, "boxRenderingTrigger", new pe());
3100
- s(this, "graphStore", new fe());
3101
- s(this, "viewportStore", new Fe());
3102
- s(this, "graph", new Te(this.graphStore));
3103
- s(this, "viewport", new De(this.viewportStore));
3245
+ s(this, "boxRenderingTrigger", new j());
3246
+ s(this, "graphStore", new ve());
3247
+ s(this, "viewportStore", new ke());
3248
+ s(this, "graph", new Le(this.graphStore));
3249
+ s(this, "viewport", new Me(this.viewportStore));
3104
3250
  s(this, "window", window);
3251
+ s(this, "animationStaticNodes", /* @__PURE__ */ new Set());
3105
3252
  this.element = e;
3106
3253
  }
3107
3254
  /**
@@ -3114,7 +3261,7 @@ class Ct {
3114
3261
  * enables nodes draggable by user
3115
3262
  */
3116
3263
  enableUserDraggableNodes(e) {
3117
- return this.hasDraggableNode = !0, this.dragConfig = e ?? {}, this;
3264
+ return this.hasDraggableNodes = !0, this.dragConfig = e ?? {}, this;
3118
3265
  }
3119
3266
  /**
3120
3267
  * enables viewport transformable by user
@@ -3147,29 +3294,44 @@ class Ct {
3147
3294
  enableUserConnectablePorts(e) {
3148
3295
  return this.hasUserConnectablePorts = !0, this.connectablePortsConfig = e ?? {}, this;
3149
3296
  }
3297
+ /**
3298
+ * enables edges dragging by dragging one of the adjacent ports
3299
+ */
3150
3300
  enableUserDraggableEdges(e) {
3151
3301
  return this.hasUserDraggableEdges = !0, this.draggableEdgesConfig = e ?? {}, this;
3152
3302
  }
3303
+ /**
3304
+ * enables nodes positioning with specified layout
3305
+ */
3306
+ enableLayout(e) {
3307
+ return this.layoutConfig = e, this.animatedLayoutConfig = void 0, this;
3308
+ }
3309
+ /**
3310
+ * enables animated nodes positioning with specified layout
3311
+ */
3312
+ enableAnimatedLayout(e) {
3313
+ return this.animatedLayoutConfig = e, this.layoutConfig = void 0, this;
3314
+ }
3153
3315
  /**
3154
3316
  * builds final canvas
3155
3317
  */
3156
3318
  build() {
3157
3319
  if (this.used)
3158
- throw new Mt("CanvasBuilder is a single use object");
3320
+ throw new $t("CanvasBuilder is a single use object");
3159
3321
  this.used = !0;
3160
- const e = new pt(this.element);
3161
- let t = new ue(
3322
+ const e = new vt(this.element);
3323
+ let t = new ye(
3162
3324
  this.graphStore,
3163
3325
  this.viewportStore,
3164
3326
  e.main
3165
3327
  );
3166
- this.virtualScrollConfig !== void 0 && (t = new Ue(
3328
+ this.virtualScrollConfig !== void 0 && (t = new Oe(
3167
3329
  t,
3168
3330
  this.graphStore,
3169
3331
  this.boxRenderingTrigger,
3170
- Nt(this.virtualScrollConfig)
3171
- )), t = new Ie(t, this.graphStore);
3172
- const o = yt(this.canvasDefaults), i = new we(
3332
+ Vt(this.virtualScrollConfig)
3333
+ )), t = new Fe(t, this.graphStore);
3334
+ const o = xt(this.canvasDefaults), i = new me(
3173
3335
  this.graph,
3174
3336
  this.viewport,
3175
3337
  this.graphStore,
@@ -3177,22 +3339,29 @@ class Ct {
3177
3339
  t,
3178
3340
  o
3179
3341
  );
3180
- if (this.hasBackground && Q.configure(
3342
+ if (this.hasBackground && _.configure(
3181
3343
  i,
3182
- Pt(this.backgroundConfig),
3344
+ Lt(this.backgroundConfig),
3183
3345
  e.background
3184
- ), this.hasNodeResizeReactiveEdges && j.configure(i), this.hasDraggableNode && Z.configure(
3185
- i,
3186
- e.main,
3187
- this.window,
3188
- mt(this.dragConfig)
3189
- ), this.hasUserConnectablePorts) {
3190
- const a = bt(
3346
+ ), this.hasNodeResizeReactiveEdges && G.configure(i), this.hasDraggableNodes) {
3347
+ let a = St(this.dragConfig);
3348
+ this.animatedLayoutConfig !== void 0 && (a = Ot(
3349
+ a,
3350
+ this.animationStaticNodes
3351
+ )), J.configure(
3352
+ i,
3353
+ e.main,
3354
+ this.window,
3355
+ a
3356
+ );
3357
+ }
3358
+ if (this.hasUserConnectablePorts) {
3359
+ const a = Mt(
3191
3360
  this.connectablePortsConfig,
3192
3361
  o.edges.shapeFactory,
3193
3362
  o.ports.direction
3194
3363
  );
3195
- _.configure(
3364
+ q.configure(
3196
3365
  i,
3197
3366
  e.overlayConnectablePorts,
3198
3367
  this.viewportStore,
@@ -3201,11 +3370,11 @@ class Ct {
3201
3370
  );
3202
3371
  }
3203
3372
  if (this.hasUserDraggableEdges) {
3204
- const a = Tt(
3373
+ const a = Rt(
3205
3374
  this.draggableEdgesConfig,
3206
3375
  i.graph
3207
3376
  );
3208
- q.configure(
3377
+ ee.configure(
3209
3378
  i,
3210
3379
  e.overlayDraggableEdges,
3211
3380
  this.viewportStore,
@@ -3213,19 +3382,30 @@ class Ct {
3213
3382
  a
3214
3383
  );
3215
3384
  }
3216
- this.virtualScrollConfig !== void 0 ? J.configure(
3385
+ this.virtualScrollConfig !== void 0 ? Q.configure(
3217
3386
  i,
3218
3387
  e.main,
3219
3388
  this.window,
3220
- le(this.transformConfig),
3389
+ fe(this.transformConfig),
3221
3390
  this.boxRenderingTrigger,
3222
- Dt(this.virtualScrollConfig)
3391
+ Ct(this.virtualScrollConfig)
3223
3392
  ) : this.hasTransformableViewport && z.configure(
3224
3393
  i,
3225
3394
  e.main,
3226
3395
  this.window,
3227
- le(this.transformConfig)
3228
- );
3396
+ fe(this.transformConfig)
3397
+ ), this.layoutConfig !== void 0 && ft.configure(
3398
+ i,
3399
+ Bt(this.layoutConfig)
3400
+ ), this.animatedLayoutConfig !== void 0 && (Ft(
3401
+ i.graph,
3402
+ this.animationStaticNodes
3403
+ ), oe.configure(
3404
+ i,
3405
+ Ut(this.animatedLayoutConfig),
3406
+ this.animationStaticNodes,
3407
+ this.window
3408
+ ));
3229
3409
  const n = () => {
3230
3410
  e.destroy(), i.onBeforeDestroy.unsubscribe(n);
3231
3411
  };
@@ -3233,15 +3413,16 @@ class Ct {
3233
3413
  }
3234
3414
  }
3235
3415
  export {
3236
- tt as BezierEdgeShape,
3237
- Ct as CanvasBuilder,
3238
- Mt as CanvasBuilderError,
3416
+ st as BezierEdgeShape,
3417
+ zt as CanvasBuilder,
3418
+ $t as CanvasBuilderError,
3239
3419
  S as CanvasError,
3240
- Pe as DirectEdgeShape,
3241
- rt as HorizontalEdgeShape,
3242
- at as InteractiveEdgeError,
3243
- be as InteractiveEdgeShape,
3244
- Lt as MidpointEdgeShape,
3245
- ot as StraightEdgeShape,
3246
- st as VerticalEdgeShape
3420
+ Ne as DirectEdgeShape,
3421
+ j as EventSubject,
3422
+ it as HorizontalEdgeShape,
3423
+ ct as InteractiveEdgeError,
3424
+ De as InteractiveEdgeShape,
3425
+ kt as MidpointEdgeShape,
3426
+ nt as StraightEdgeShape,
3427
+ at as VerticalEdgeShape
3247
3428
  };