@html-graph/html-graph 8.6.1 → 8.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  var Ke = Object.defineProperty;
2
2
  var Qe = (r, e, t) => e in r ? Ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
3
  var i = (r, e, t) => Qe(r, typeof e != "symbol" ? e + "" : e, t);
4
- var R = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(R || {});
4
+ var D = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(D || {});
5
5
  const Ze = () => {
6
6
  const r = document.createElement("div");
7
7
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
@@ -72,8 +72,8 @@ class Ee {
72
72
  h,
73
73
  d
74
74
  ), g = this.createEdgeRenderPort(o, a, h, d);
75
- let l = R.Line;
76
- s.element === o.element ? l = R.PortCycle : s.nodeId === o.nodeId && (l = R.NodeCycle), t.payload.shape.render({ from: c, to: g, category: l });
75
+ let l = D.Line;
76
+ s.element === o.element ? l = D.PortCycle : s.nodeId === o.nodeId && (l = D.NodeCycle), t.payload.shape.render({ from: c, to: g, category: l });
77
77
  }
78
78
  updateEdgePriority(e) {
79
79
  const t = this.graphStore.getEdge(e);
@@ -724,7 +724,7 @@ class Q {
724
724
  const nt = (r, e, t) => {
725
725
  const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
726
726
  return e >= s && e <= s + n && t >= o && t <= o + a;
727
- }, at = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, D = (r, e, t, s) => nt(e, t, s) && at(r, t, s), U = (r, e) => {
727
+ }, at = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e, t, s) => nt(e, t, s) && at(r, t, s), U = (r, e) => {
728
728
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
729
729
  }, O = (r) => {
730
730
  const e = document.createElement("div");
@@ -786,7 +786,7 @@ var N = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "
786
786
  const Ne = (r, e) => ({
787
787
  x: r / 2,
788
788
  y: e / 2
789
- }), w = {
789
+ }), y = {
790
790
  x: 0,
791
791
  y: 0
792
792
  }, m = (r, e, t) => ({
@@ -820,9 +820,9 @@ class dt {
820
820
  const t = this.params.to;
821
821
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
822
822
  const s = m(
823
- { x: this.params.arrowLength, y: w.y },
823
+ { x: this.params.arrowLength, y: y.y },
824
824
  this.params.sourceDirection,
825
- w
825
+ y
826
826
  ), o = m(
827
827
  { x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
828
828
  this.params.targetDirection,
@@ -833,7 +833,7 @@ class dt {
833
833
  }, a = {
834
834
  x: o.x - this.params.targetDirection.x * this.params.curvature,
835
835
  y: o.y - this.params.targetDirection.y * this.params.curvature
836
- }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
836
+ }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${y.x} ${y.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
837
837
  this.path = `${d}${h}${c}`;
838
838
  }
839
839
  }
@@ -843,10 +843,10 @@ class ct {
843
843
  i(this, "midpoint");
844
844
  this.params = e;
845
845
  const t = this.params.hasSourceArrow ? m(
846
- { x: this.params.arrowLength, y: w.y },
846
+ { x: this.params.arrowLength, y: y.y },
847
847
  this.params.sourceDirection,
848
- w
849
- ) : w, s = this.params.hasTargetArrow ? m(
848
+ y
849
+ ) : y, s = this.params.hasTargetArrow ? m(
850
850
  {
851
851
  x: this.params.to.x - this.params.arrowLength,
852
852
  y: this.params.to.y
@@ -854,9 +854,9 @@ class ct {
854
854
  this.params.targetDirection,
855
855
  this.params.to
856
856
  ) : this.params.to, o = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, h = n * this.params.flipX, d = a * this.params.flipY, c = m(
857
- { x: o, y: w.y },
857
+ { x: o, y: y.y },
858
858
  this.params.sourceDirection,
859
- w
859
+ y
860
860
  ), g = {
861
861
  x: c.x + h,
862
862
  y: c.y + d
@@ -867,10 +867,10 @@ class ct {
867
867
  ), u = {
868
868
  x: l.x + h,
869
869
  y: l.y + d
870
- }, p = {
870
+ }, w = {
871
871
  x: (g.x + u.x) / 2,
872
872
  y: (g.y + u.y) / 2
873
- }, y = {
873
+ }, p = {
874
874
  x: c.x + this.params.curvature * this.params.sourceDirection.x,
875
875
  y: c.y + this.params.curvature * this.params.sourceDirection.y
876
876
  }, v = {
@@ -886,10 +886,10 @@ class ct {
886
886
  this.path = [
887
887
  `M ${t.x} ${t.y}`,
888
888
  `L ${c.x} ${c.y}`,
889
- `C ${y.x} ${y.y} ${x.x} ${x.y} ${p.x} ${p.y}`,
889
+ `C ${p.x} ${p.y} ${x.x} ${x.y} ${w.x} ${w.y}`,
890
890
  `C ${b.x} ${b.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
891
891
  `L ${s.x} ${s.y}`
892
- ].join(" "), this.midpoint = z(p, e.flipX, e.flipY, e.to);
892
+ ].join(" "), this.midpoint = z(w, e.flipX, e.flipY, e.to);
893
893
  }
894
894
  }
895
895
  const Z = Object.freeze({
@@ -897,13 +897,13 @@ const Z = Object.freeze({
897
897
  }), Me = (r) => {
898
898
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
899
899
  return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(Z.edgeColor, r), e;
900
- }, Re = (r) => {
900
+ }, De = (r) => {
901
901
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
902
902
  return e.setAttribute("stroke", `var(${Z.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
903
903
  }, W = () => {
904
904
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
905
905
  return r.setAttribute("fill", `var(${Z.edgeColor})`), r;
906
- }, De = () => {
906
+ }, Re = () => {
907
907
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
908
908
  return r.style.transformOrigin = "50% 50%", r;
909
909
  }, Le = (r, e) => {
@@ -915,13 +915,13 @@ const Z = Object.freeze({
915
915
  let o = 0, n = 0, a = 0;
916
916
  r.forEach((h, d) => {
917
917
  let c = 0, g = 0, l = 0;
918
- const u = d > 0, p = d < s, y = u && p;
919
- if (u && (c = -o, g = -n, l = a), p) {
918
+ const u = d > 0, w = d < s, p = u && w;
919
+ if (u && (c = -o, g = -n, l = a), w) {
920
920
  const V = r[d + 1];
921
921
  o = V.x - h.x, n = V.y - h.y, a = Math.sqrt(o * o + n * n);
922
922
  }
923
- const x = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = y ? { x: h.x + o * x, y: h.y + n * x } : h, C = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, L = y ? { x: h.x + c * C, y: h.y + g * C } : h;
924
- d > 0 && t.push(`L ${L.x} ${L.y}`), y && t.push(
923
+ const x = a !== 0 ? Math.min((p ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = p ? { x: h.x + o * x, y: h.y + n * x } : h, C = l !== 0 ? Math.min((p ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, L = p ? { x: h.x + c * C, y: h.y + g * C } : h;
924
+ d > 0 && t.push(`L ${L.x} ${L.y}`), p && t.push(
925
925
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${b.x} ${b.y}`
926
926
  );
927
927
  });
@@ -936,10 +936,10 @@ class lt {
936
936
  const t = this.params.to;
937
937
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
938
938
  const s = this.params.hasSourceArrow ? m(
939
- { x: this.params.arrowLength, y: w.y },
939
+ { x: this.params.arrowLength, y: y.y },
940
940
  this.params.sourceDirection,
941
- w
942
- ) : w, o = this.params.hasTargetArrow ? m(
941
+ y
942
+ ) : y, o = this.params.hasTargetArrow ? m(
943
943
  {
944
944
  x: this.params.to.x - this.params.arrowLength,
945
945
  y: this.params.to.y
@@ -947,9 +947,9 @@ class lt {
947
947
  this.params.targetDirection,
948
948
  this.params.to
949
949
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
950
- { x: a, y: w.y },
950
+ { x: a, y: y.y },
951
951
  this.params.sourceDirection,
952
- w
952
+ y
953
953
  ), d = m(
954
954
  { x: this.params.to.x - a, y: this.params.to.y },
955
955
  this.params.targetDirection,
@@ -957,12 +957,12 @@ class lt {
957
957
  ), c = Math.max((h.x + d.x) / 2, n), g = this.params.to.y / 2, l = {
958
958
  x: this.params.flipX > 0 ? c : -n,
959
959
  y: h.y
960
- }, u = { x: l.x, y: g }, p = {
960
+ }, u = { x: l.x, y: g }, w = {
961
961
  x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
962
962
  y: d.y
963
- }, y = { x: p.x, y: g };
963
+ }, p = { x: w.x, y: g };
964
964
  this.path = M(
965
- [s, h, l, u, y, p, d, o],
965
+ [s, h, l, u, p, w, d, o],
966
966
  this.params.roundness
967
967
  );
968
968
  }
@@ -973,10 +973,10 @@ class gt {
973
973
  i(this, "midpoint");
974
974
  this.params = e;
975
975
  const t = this.params.hasSourceArrow ? m(
976
- { x: this.params.arrowLength, y: w.y },
976
+ { x: this.params.arrowLength, y: y.y },
977
977
  this.params.sourceDirection,
978
- w
979
- ) : w, s = this.params.hasTargetArrow ? m(
978
+ y
979
+ ) : y, s = this.params.hasTargetArrow ? m(
980
980
  {
981
981
  x: this.params.to.x - this.params.arrowLength,
982
982
  y: this.params.to.y
@@ -984,15 +984,15 @@ class gt {
984
984
  this.params.targetDirection,
985
985
  this.params.to
986
986
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
987
- { x: o, y: w.y },
987
+ { x: o, y: y.y },
988
988
  this.params.sourceDirection,
989
- w
989
+ y
990
990
  ), a = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = a * this.params.flipX, c = h * this.params.flipY, g = { x: n.x + d, y: n.y + c }, l = m(
991
991
  { x: this.params.to.x - o, y: this.params.to.y },
992
992
  this.params.targetDirection,
993
993
  this.params.to
994
- ), u = { x: l.x + d, y: l.y + c }, p = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
995
- this.midpoint = z(p, e.flipX, e.flipY, e.to), this.path = M(
994
+ ), u = { x: l.x + d, y: l.y + c }, w = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
995
+ this.midpoint = z(w, e.flipX, e.flipY, e.to), this.path = M(
996
996
  [t, n, g, u, l, s],
997
997
  this.params.roundness
998
998
  );
@@ -1006,10 +1006,10 @@ class ut {
1006
1006
  const t = this.params.to;
1007
1007
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1008
1008
  const s = this.params.hasSourceArrow ? m(
1009
- { x: this.params.arrowLength, y: w.y },
1009
+ { x: this.params.arrowLength, y: y.y },
1010
1010
  this.params.sourceDirection,
1011
- w
1012
- ) : w, o = this.params.hasTargetArrow ? m(
1011
+ y
1012
+ ) : y, o = this.params.hasTargetArrow ? m(
1013
1013
  {
1014
1014
  x: this.params.to.x - this.params.arrowLength,
1015
1015
  y: this.params.to.y
@@ -1017,9 +1017,9 @@ class ut {
1017
1017
  this.params.targetDirection,
1018
1018
  this.params.to
1019
1019
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = m(
1020
- { x: n, y: w.y },
1020
+ { x: n, y: y.y },
1021
1021
  this.params.sourceDirection,
1022
- w
1022
+ y
1023
1023
  ), h = m(
1024
1024
  { x: this.params.to.x - n, y: this.params.to.y },
1025
1025
  this.params.targetDirection,
@@ -1036,10 +1036,10 @@ class pt {
1036
1036
  const t = this.params.to;
1037
1037
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1038
1038
  const s = this.params.hasSourceArrow ? m(
1039
- { x: this.params.arrowLength, y: w.y },
1039
+ { x: this.params.arrowLength, y: y.y },
1040
1040
  this.params.sourceDirection,
1041
- w
1042
- ) : w, o = this.params.hasTargetArrow ? m(
1041
+ y
1042
+ ) : y, o = this.params.hasTargetArrow ? m(
1043
1043
  {
1044
1044
  x: this.params.to.x - this.params.arrowLength,
1045
1045
  y: this.params.to.y
@@ -1047,9 +1047,9 @@ class pt {
1047
1047
  this.params.targetDirection,
1048
1048
  this.params.to
1049
1049
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1050
- { x: a, y: w.y },
1050
+ { x: a, y: y.y },
1051
1051
  this.params.sourceDirection,
1052
- w
1052
+ y
1053
1053
  ), d = m(
1054
1054
  { x: this.params.to.x - a, y: this.params.to.y },
1055
1055
  this.params.targetDirection,
@@ -1057,12 +1057,12 @@ class pt {
1057
1057
  ), c = Math.max((h.y + d.y) / 2, n), g = this.params.to.x / 2, l = {
1058
1058
  x: h.x,
1059
1059
  y: this.params.flipY > 0 ? c : -n
1060
- }, u = { x: g, y: l.y }, p = {
1060
+ }, u = { x: g, y: l.y }, w = {
1061
1061
  x: d.x,
1062
1062
  y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
1063
- }, y = { x: g, y: p.y };
1063
+ }, p = { x: g, y: w.y };
1064
1064
  this.path = M(
1065
- [s, h, l, u, y, p, d, o],
1065
+ [s, h, l, u, p, w, d, o],
1066
1066
  this.params.roundness
1067
1067
  );
1068
1068
  }
@@ -1073,17 +1073,17 @@ class J {
1073
1073
  i(this, "midpoint");
1074
1074
  this.params = e;
1075
1075
  const t = this.params.arrowOffset, s = this.params.side, o = this.params.arrowLength + t, n = o + 2 * s, h = [
1076
- { x: this.params.arrowLength, y: w.y },
1077
- { x: o, y: w.y },
1076
+ { x: this.params.arrowLength, y: y.y },
1077
+ { x: o, y: y.y },
1078
1078
  { x: o, y: this.params.side },
1079
1079
  { x: n, y: this.params.side },
1080
1080
  { x: n, y: -this.params.side },
1081
1081
  { x: o, y: -this.params.side },
1082
- { x: o, y: w.y },
1083
- { x: this.params.arrowLength, y: w.y }
1082
+ { x: o, y: y.y },
1083
+ { x: this.params.arrowLength, y: y.y }
1084
1084
  ].map(
1085
- (c) => m(c, this.params.sourceDirection, w)
1086
- ), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
1085
+ (c) => m(c, this.params.sourceDirection, y)
1086
+ ), d = `M ${y.x} ${y.y} L ${h[0].x} ${h[0].y} `;
1087
1087
  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 };
1088
1088
  }
1089
1089
  }
@@ -1093,19 +1093,19 @@ class wt {
1093
1093
  i(this, "midpoint");
1094
1094
  this.params = e;
1095
1095
  const t = this.params.smallRadius, s = this.params.radius, o = t + s, n = t * s / o, a = Math.sqrt(o * o - t * t), h = a * t / o, d = a + s + this.params.arrowLength, c = this.params.arrowLength + h, l = [
1096
- { x: this.params.arrowLength, y: w.y },
1096
+ { x: this.params.arrowLength, y: y.y },
1097
1097
  { x: c, y: n },
1098
1098
  { x: c, y: -n },
1099
1099
  { x: d, y: 0 }
1100
1100
  ].map(
1101
- (y) => m(y, this.params.sourceDirection, w)
1101
+ (p) => m(p, this.params.sourceDirection, y)
1102
1102
  ), u = [
1103
1103
  `M ${l[0].x} ${l[0].y}`,
1104
1104
  `A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
1105
1105
  `A ${s} ${s} 0 1 0 ${l[2].x} ${l[2].y}`,
1106
1106
  `A ${t} ${t} 0 0 1 ${l[0].x} ${l[0].y}`
1107
- ].join(" "), p = `M 0 0 L ${l[0].x} ${l[0].y} `;
1108
- this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : p}${u}`, this.midpoint = l[3];
1107
+ ].join(" "), w = `M 0 0 L ${l[0].x} ${l[0].y} `;
1108
+ this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : w}${u}`, this.midpoint = l[3];
1109
1109
  }
1110
1110
  }
1111
1111
  class yt {
@@ -1127,7 +1127,7 @@ class yt {
1127
1127
  offset: this.params.sourceOffset,
1128
1128
  hasArrow: this.params.hasSourceArrow,
1129
1129
  flip: 1,
1130
- shift: w
1130
+ shift: y
1131
1131
  }), n = this.createDirectLinePoint({
1132
1132
  offset: this.params.targetOffset,
1133
1133
  hasArrow: this.params.hasTargetArrow,
@@ -1150,10 +1150,10 @@ class ft {
1150
1150
  i(this, "midpoint");
1151
1151
  this.params = e;
1152
1152
  const t = this.params.hasSourceArrow ? m(
1153
- { x: this.params.arrowLength, y: w.y },
1153
+ { x: this.params.arrowLength, y: y.y },
1154
1154
  this.params.sourceDirection,
1155
- w
1156
- ) : w, s = this.params.hasTargetArrow ? m(
1155
+ y
1156
+ ) : y, s = this.params.hasTargetArrow ? m(
1157
1157
  {
1158
1158
  x: this.params.to.x - this.params.arrowLength,
1159
1159
  y: this.params.to.y
@@ -1161,9 +1161,9 @@ class ft {
1161
1161
  this.params.targetDirection,
1162
1162
  this.params.to
1163
1163
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1164
- { x: o, y: w.y },
1164
+ { x: o, y: y.y },
1165
1165
  this.params.sourceDirection,
1166
- w
1166
+ y
1167
1167
  ), a = m(
1168
1168
  { x: this.params.to.x - o, y: this.params.to.y },
1169
1169
  this.params.targetDirection,
@@ -1191,10 +1191,10 @@ class mt {
1191
1191
  i(this, "midpoint");
1192
1192
  this.params = e;
1193
1193
  const t = this.params.hasSourceArrow ? m(
1194
- { x: this.params.arrowLength, y: w.y },
1194
+ { x: this.params.arrowLength, y: y.y },
1195
1195
  this.params.sourceDirection,
1196
- w
1197
- ) : w, s = this.params.hasTargetArrow ? m(
1196
+ y
1197
+ ) : y, s = this.params.hasTargetArrow ? m(
1198
1198
  {
1199
1199
  x: this.params.to.x - this.params.arrowLength,
1200
1200
  y: this.params.to.y
@@ -1202,9 +1202,9 @@ class mt {
1202
1202
  this.params.targetDirection,
1203
1203
  this.params.to
1204
1204
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1205
- { x: o, y: w.y },
1205
+ { x: o, y: y.y },
1206
1206
  this.params.sourceDirection,
1207
- w
1207
+ y
1208
1208
  ), a = m(
1209
1209
  { x: this.params.to.x - o, y: this.params.to.y },
1210
1210
  this.params.targetDirection,
@@ -1252,14 +1252,14 @@ const f = Object.freeze({
1252
1252
  class k {
1253
1253
  constructor(e) {
1254
1254
  i(this, "svg");
1255
- i(this, "group", De());
1255
+ i(this, "group", Re());
1256
1256
  i(this, "line");
1257
1257
  i(this, "sourceArrow", null);
1258
1258
  i(this, "targetArrow", null);
1259
1259
  i(this, "onAfterRender");
1260
1260
  i(this, "afterRenderEmitter");
1261
1261
  i(this, "arrowRenderer");
1262
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = S(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Me(e.color), this.svg.appendChild(this.group), this.line = Re(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1262
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = S(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Me(e.color), this.svg.appendChild(this.group), this.line = De(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1263
1263
  }
1264
1264
  render(e) {
1265
1265
  const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = Te(
@@ -1280,53 +1280,53 @@ class k {
1280
1280
  y: n
1281
1281
  };
1282
1282
  let l = { x: -c.x, y: -c.y }, u;
1283
- e.category === R.PortCycle ? (u = this.params.createCyclePath, l = d) : e.category === R.NodeCycle ? u = this.params.createDetourPath : u = this.params.createLinePath;
1284
- const p = u(
1283
+ e.category === D.PortCycle ? (u = this.params.createCyclePath, l = d) : e.category === D.NodeCycle ? u = this.params.createDetourPath : u = this.params.createLinePath;
1284
+ const w = u(
1285
1285
  d,
1286
1286
  c,
1287
1287
  g,
1288
1288
  a,
1289
1289
  h
1290
1290
  );
1291
- this.line.setAttribute("d", p.path);
1292
- let y = null;
1293
- this.sourceArrow && (y = this.arrowRenderer({
1291
+ this.line.setAttribute("d", w.path);
1292
+ let p = null;
1293
+ this.sourceArrow && (p = this.arrowRenderer({
1294
1294
  direction: d,
1295
- shift: w,
1295
+ shift: y,
1296
1296
  arrowLength: this.params.arrowLength
1297
- }), this.sourceArrow.setAttribute("d", y));
1297
+ }), this.sourceArrow.setAttribute("d", p));
1298
1298
  let v = null;
1299
1299
  this.targetArrow && (v = this.arrowRenderer({
1300
1300
  direction: l,
1301
1301
  shift: g,
1302
1302
  arrowLength: this.params.arrowLength
1303
1303
  }), this.targetArrow.setAttribute("d", v)), this.afterRenderEmitter.emit({
1304
- edgePath: p,
1305
- sourceArrowPath: y,
1304
+ edgePath: w,
1305
+ sourceArrowPath: p,
1306
1306
  targetArrowPath: v
1307
1307
  });
1308
1308
  }
1309
1309
  }
1310
1310
  const vt = (r) => (e) => {
1311
1311
  const s = [
1312
- w,
1312
+ y,
1313
1313
  { x: e.arrowLength, y: r.radius },
1314
1314
  { x: e.arrowLength, y: -r.radius }
1315
1315
  ].map(
1316
- (h) => m(h, e.direction, w)
1316
+ (h) => m(h, e.direction, y)
1317
1317
  ).map((h) => ({
1318
1318
  x: h.x + e.shift.x,
1319
1319
  y: h.y + e.shift.y
1320
1320
  })), o = `M ${s[0].x} ${s[0].y}`, n = `L ${s[1].x} ${s[1].y}`, a = `L ${s[2].x} ${s[2].y}`;
1321
1321
  return `${o} ${n} ${a} Z`;
1322
1322
  }, At = (r) => (e) => {
1323
- const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [w, { x: a, y: -h }, { x: a, y: h }].map(
1324
- (y) => m(y, e.direction, w)
1325
- ).map((y) => ({
1326
- x: y.x + e.shift.x,
1327
- y: y.y + e.shift.y
1328
- })), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, p = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
1329
- return `${g} ${l} ${u} ${p}`;
1323
+ const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [y, { x: a, y: -h }, { x: a, y: h }].map(
1324
+ (p) => m(p, e.direction, y)
1325
+ ).map((p) => ({
1326
+ x: p.x + e.shift.x,
1327
+ y: p.y + e.shift.y
1328
+ })), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
1329
+ return `${g} ${l} ${u} ${w}`;
1330
1330
  }, xt = (r) => (e) => {
1331
1331
  const t = r.smallRadius, s = r.radius, o = m(
1332
1332
  {
@@ -1341,8 +1341,8 @@ const vt = (r) => (e) => {
1341
1341
  x: e.arrowLength + r.smallRadius,
1342
1342
  y: 0
1343
1343
  }
1344
- ), a = [w, { x: o.x, y: -o.y }, o].map(
1345
- (l) => m(l, e.direction, w)
1344
+ ), a = [y, { x: o.x, y: -o.y }, o].map(
1345
+ (l) => m(l, e.direction, y)
1346
1346
  ).map((l) => ({
1347
1347
  x: l.x + e.shift.x,
1348
1348
  y: l.y + e.shift.y
@@ -1648,7 +1648,7 @@ class Pt {
1648
1648
  class Ve {
1649
1649
  constructor(e) {
1650
1650
  i(this, "svg");
1651
- i(this, "group", De());
1651
+ i(this, "group", Re());
1652
1652
  i(this, "line");
1653
1653
  i(this, "sourceArrow", null);
1654
1654
  i(this, "targetArrow", null);
@@ -1660,7 +1660,7 @@ class Ve {
1660
1660
  i(this, "onAfterRender");
1661
1661
  i(this, "afterRenderEmitter");
1662
1662
  i(this, "arrowRenderer");
1663
- [this.afterRenderEmitter, this.onAfterRender] = S(), this.color = (e == null ? void 0 : e.color) ?? f.color, this.width = (e == null ? void 0 : e.width) ?? f.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowRenderer = I((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? f.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? f.preOffset, this.svg = Me(this.color), this.svg.appendChild(this.group), this.line = Re(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1663
+ [this.afterRenderEmitter, this.onAfterRender] = S(), this.color = (e == null ? void 0 : e.color) ?? f.color, this.width = (e == null ? void 0 : e.width) ?? f.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowRenderer = I((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? f.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? f.preOffset, this.svg = Me(this.color), this.svg.appendChild(this.group), this.line = De(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1664
1664
  }
1665
1665
  render(e) {
1666
1666
  const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = Te(
@@ -1682,31 +1682,31 @@ class Ve {
1682
1682
  if (u === 0)
1683
1683
  this.sourceArrow !== null && (g = "", this.sourceArrow.setAttribute("d", g)), this.targetArrow !== null && (l = "", this.targetArrow.setAttribute("d", l));
1684
1684
  else {
1685
- const p = {
1685
+ const w = {
1686
1686
  x: d.x / u,
1687
1687
  y: d.y / u
1688
1688
  };
1689
1689
  if (this.sourceArrow) {
1690
- const y = {
1691
- x: p.x * this.sourceOffset,
1692
- y: p.y * this.sourceOffset
1690
+ const p = {
1691
+ x: w.x * this.sourceOffset,
1692
+ y: w.y * this.sourceOffset
1693
1693
  };
1694
1694
  g = this.arrowRenderer({
1695
- direction: p,
1696
- shift: y,
1695
+ direction: w,
1696
+ shift: p,
1697
1697
  arrowLength: this.arrowLength
1698
1698
  }), this.sourceArrow.setAttribute("d", g);
1699
1699
  }
1700
1700
  if (this.targetArrow) {
1701
- const y = {
1702
- x: p.x * this.targetOffset,
1703
- y: p.y * this.targetOffset
1701
+ const p = {
1702
+ x: w.x * this.targetOffset,
1703
+ y: w.y * this.targetOffset
1704
1704
  };
1705
1705
  l = this.arrowRenderer({
1706
- direction: { x: -p.x, y: -p.y },
1706
+ direction: { x: -w.x, y: -w.y },
1707
1707
  shift: {
1708
- x: d.x - y.x,
1709
- y: d.y - y.y
1708
+ x: d.x - p.x,
1709
+ y: d.y - p.y
1710
1710
  },
1711
1711
  arrowLength: this.arrowLength
1712
1712
  }), this.targetArrow.setAttribute("d", l);
@@ -2024,7 +2024,7 @@ const Mt = (r) => {
2024
2024
  setTimeout(() => {
2025
2025
  r();
2026
2026
  });
2027
- }, Rt = (r) => {
2027
+ }, Dt = (r) => {
2028
2028
  queueMicrotask(() => {
2029
2029
  r();
2030
2030
  });
@@ -2054,7 +2054,7 @@ class $e {
2054
2054
  return this.viewportStore.createViewportCoords(e);
2055
2055
  }
2056
2056
  }
2057
- const Dt = (r, e) => Symbol.iterator in r ? {
2057
+ const Rt = (r, e) => Symbol.iterator in r ? {
2058
2058
  minContentScale: e.focus.minContentScale,
2059
2059
  nodes: r,
2060
2060
  contentOffset: e.focus.contentOffset
@@ -2097,7 +2097,7 @@ class We {
2097
2097
  this.viewportStore.patchViewportMatrix(g);
2098
2098
  }
2099
2099
  focus(e) {
2100
- const t = Dt(e ?? {}, this.params);
2100
+ const t = Rt(e ?? {}, this.params);
2101
2101
  this.params.focus.schedule(() => {
2102
2102
  this.navigate(t);
2103
2103
  });
@@ -2118,9 +2118,9 @@ class We {
2118
2118
  const d = {
2119
2119
  x: (t + s) / 2,
2120
2120
  y: (o + n) / 2
2121
- }, c = (s - t) / 2, g = (n - o) / 2, { width: l, height: u } = this.viewportStore.getDimensions(), p = l / 2, y = u / 2, v = Math.max(
2122
- c / p,
2123
- g / y
2121
+ }, c = (s - t) / 2, g = (n - o) / 2, { width: l, height: u } = this.viewportStore.getDimensions(), w = l / 2, p = u / 2, v = Math.max(
2122
+ c / w,
2123
+ g / p
2124
2124
  ), { scale: x } = this.viewportStore.getContentMatrix(), b = v > 1 ? x / v : x, P = Math.max(b, e.minContentScale);
2125
2125
  this.center(d, { contentScale: P });
2126
2126
  }
@@ -2181,7 +2181,7 @@ class H {
2181
2181
  }));
2182
2182
  });
2183
2183
  i(this, "onWindowMouseMove", (e) => {
2184
- if (!D(
2184
+ if (!R(
2185
2185
  this.window,
2186
2186
  this.element,
2187
2187
  e.clientX,
@@ -2213,7 +2213,7 @@ class H {
2213
2213
  });
2214
2214
  i(this, "onWindowTouchMove", (e) => {
2215
2215
  const t = e.touches[0];
2216
- if (!D(
2216
+ if (!R(
2217
2217
  this.window,
2218
2218
  this.element,
2219
2219
  t.clientX,
@@ -2367,7 +2367,7 @@ class ee {
2367
2367
  });
2368
2368
  });
2369
2369
  i(this, "onWindowMouseMove", (e) => {
2370
- if (!D(
2370
+ if (!R(
2371
2371
  this.window,
2372
2372
  this.element,
2373
2373
  e.clientX,
@@ -2388,7 +2388,7 @@ class ee {
2388
2388
  if (e.touches.length !== 1)
2389
2389
  return;
2390
2390
  const t = e.touches[0];
2391
- if (!D(
2391
+ if (!R(
2392
2392
  this.window,
2393
2393
  this.element,
2394
2394
  t.clientX,
@@ -2522,7 +2522,7 @@ class Y {
2522
2522
  }), this.startRegisteredTransform());
2523
2523
  });
2524
2524
  i(this, "onWindowMouseMove", (e) => {
2525
- const t = D(
2525
+ const t = R(
2526
2526
  this.window,
2527
2527
  this.element,
2528
2528
  e.clientX,
@@ -2562,7 +2562,7 @@ class Y {
2562
2562
  i(this, "onWindowTouchMove", (e) => {
2563
2563
  const t = B(e);
2564
2564
  if (!t.touches.every(
2565
- (o) => D(this.window, this.element, o[0], o[1])
2565
+ (o) => R(this.window, this.element, o[0], o[1])
2566
2566
  )) {
2567
2567
  this.stopTouchDrag();
2568
2568
  return;
@@ -2844,10 +2844,10 @@ class se {
2844
2844
  portDirection: this.params.dragPortDirection
2845
2845
  };
2846
2846
  this.isTargetDragging = s === "direct";
2847
- const [p, y] = this.isTargetDragging ? [l, u] : [u, l];
2848
- this.overlayCanvas.addNode(O(p)), this.overlayCanvas.addNode(O(y)), this.overlayCanvas.addEdge({
2849
- from: p.overlayNodeId,
2850
- to: y.overlayNodeId,
2847
+ const [w, p] = this.isTargetDragging ? [l, u] : [u, l];
2848
+ this.overlayCanvas.addNode(O(w)), this.overlayCanvas.addNode(O(p)), this.overlayCanvas.addEdge({
2849
+ from: w.overlayNodeId,
2850
+ to: p.overlayNodeId,
2851
2851
  shape: this.params.edgeShapeFactory(N.EdgeId)
2852
2852
  });
2853
2853
  }
@@ -2927,10 +2927,10 @@ class oe {
2927
2927
  const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
2928
2928
  x: g.x + g.width / 2,
2929
2929
  y: g.y + g.height / 2
2930
- }, u = this.overlayLayer.getBoundingClientRect(), p = this.canvas.viewport.createContentCoords({
2930
+ }, u = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
2931
2931
  x: l.x - u.x,
2932
2932
  y: l.y - u.y
2933
- }), y = this.canvas.viewport.createContentCoords({
2933
+ }), p = this.canvas.viewport.createContentCoords({
2934
2934
  x: t.x - u.x,
2935
2935
  y: t.y - u.y
2936
2936
  });
@@ -2943,11 +2943,11 @@ class oe {
2943
2943
  }, this.canvas.removeEdge(s);
2944
2944
  const v = {
2945
2945
  overlayNodeId: N.StaticNodeId,
2946
- portCoords: p,
2946
+ portCoords: w,
2947
2947
  portDirection: c.direction
2948
2948
  }, x = {
2949
2949
  overlayNodeId: N.DraggingNodeId,
2950
- portCoords: y,
2950
+ portCoords: p,
2951
2951
  portDirection: d.direction
2952
2952
  }, [b, P] = this.isTargetDragging ? [v, x] : [x, v];
2953
2953
  this.overlayCanvas.addNode(O(b)), this.overlayCanvas.addNode(O(P));
@@ -3124,9 +3124,9 @@ class Wt {
3124
3124
  }
3125
3125
  }
3126
3126
  const zt = (r) => {
3127
- var p, y, v, x, b, P;
3128
- const e = ((p = r.events) == null ? void 0 : p.onNodeDragStarted) ?? (() => {
3129
- }), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
3127
+ var w, p, v, x, b, P;
3128
+ const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3129
+ }), t = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
3130
3130
  }), s = r.nodeDragVerifier ?? (() => !0), o = ((v = r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
3131
3131
  }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (b = r.mouse) == null ? void 0 : b.mouseDownEventVerifier, g = c !== void 0 ? c : (C) => C.button === 0, l = (P = r.mouse) == null ? void 0 : P.mouseUpEventVerifier, u = l !== void 0 ? l : (C) => C.button === 0;
3132
3132
  return {
@@ -3198,8 +3198,8 @@ const zt = (r) => {
3198
3198
  });
3199
3199
  }
3200
3200
  }, Ae = (r) => {
3201
- var y, v, x, b, P, C, L, V, de, ce, le, ge;
3202
- const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
3201
+ var p, v, x, b, P, C, L, V, de, ce, le, ge;
3202
+ const e = (p = r == null ? void 0 : r.scale) == null ? void 0 : p.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
3203
3203
  let o;
3204
3204
  s !== void 0 ? Array.isArray(s) ? o = Yt(
3205
3205
  s.map(
@@ -3208,7 +3208,7 @@ const zt = (r) => {
3208
3208
  ) : o = ve(s) : o = (T) => T.nextTransform;
3209
3209
  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) ?? (() => {
3210
3210
  }), h = ((b = r == null ? void 0 : r.events) == null ? void 0 : b.onTransformChange) ?? (() => {
3211
- }), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, g = (C = r == null ? void 0 : r.shift) == null ? void 0 : C.mouseUpEventVerifier, l = g !== void 0 ? g : (T) => T.button === 0, u = (L = r == null ? void 0 : r.scale) == null ? void 0 : L.mouseWheelEventVerifier, p = u !== void 0 ? u : () => !0;
3211
+ }), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, g = (C = r == null ? void 0 : r.shift) == null ? void 0 : C.mouseUpEventVerifier, l = g !== void 0 ? g : (T) => T.button === 0, u = (L = r == null ? void 0 : r.scale) == null ? void 0 : L.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
3212
3212
  return {
3213
3213
  wheelSensitivity: t,
3214
3214
  onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
@@ -3221,7 +3221,7 @@ const zt = (r) => {
3221
3221
  shiftCursor: n,
3222
3222
  mouseDownEventVerifier: c,
3223
3223
  mouseUpEventVerifier: l,
3224
- mouseWheelEventVerifier: p,
3224
+ mouseWheelEventVerifier: w,
3225
3225
  scaleWheelFinishTimeout: ((ce = r == null ? void 0 : r.scale) == null ? void 0 : ce.wheelFinishTimeout) ?? 500,
3226
3226
  onResizeTransformStarted: ((le = r == null ? void 0 : r.events) == null ? void 0 : le.onResizeTransformStarted) ?? (() => {
3227
3227
  }),
@@ -3335,8 +3335,8 @@ const zt = (r) => {
3335
3335
  }, Kt = (r, e) => {
3336
3336
  var c, g, l;
3337
3337
  const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, o = (u) => u.button === 0, n = (u) => {
3338
- const p = e.getPortAdjacentEdgeIds(u);
3339
- return p.length > 0 ? p[p.length - 1] : null;
3338
+ const w = e.getPortAdjacentEdgeIds(u);
3339
+ return w.length > 0 ? w[w.length - 1] : null;
3340
3340
  }, a = () => {
3341
3341
  }, h = () => {
3342
3342
  }, d = () => {
@@ -3402,8 +3402,8 @@ class ke {
3402
3402
  const s = this.graph.getEdge(t), o = this.graph.getPort(s.from), n = this.graph.getPort(s.to), a = this.currentCoords.get(o.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
3403
3403
  a,
3404
3404
  h
3405
- ), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, p = e.get(o.nodeId), y = e.get(n.nodeId);
3406
- p.x += l, p.y += u, y.x -= l, y.y -= u;
3405
+ ), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(o.nodeId), p = e.get(n.nodeId);
3406
+ w.x += l, w.y += u, p.x -= l, p.y -= u;
3407
3407
  });
3408
3408
  }
3409
3409
  }
@@ -3453,8 +3453,8 @@ class _t {
3453
3453
  targetCharge: this.nodeCharge,
3454
3454
  distance: l.d,
3455
3455
  maxForce: this.maxForce
3456
- }), p = u * l.ex, y = u * l.ey, v = t.get(a), x = t.get(d);
3457
- v.x -= p, v.y -= y, x.x += p, x.y += y;
3456
+ }), w = u * l.ex, p = u * l.ey, v = t.get(a), x = t.get(d);
3457
+ v.x -= w, v.y -= p, x.x += w, x.y += p;
3458
3458
  }
3459
3459
  }
3460
3460
  }
@@ -3532,8 +3532,8 @@ class tr {
3532
3532
  this.sortedParentNodes.push(e);
3533
3533
  const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = o / 2;
3534
3534
  e.nodeIds.forEach((u) => {
3535
- const { x: p, y } = this.coords.get(u);
3536
- p < t ? y < s ? d.add(u) : h.add(u) : y < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
3535
+ const { x: w, y: p } = this.coords.get(u);
3536
+ w < t ? p < s ? d.add(u) : h.add(u) : p < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
3537
3537
  });
3538
3538
  const g = {
3539
3539
  parent: e,
@@ -3817,16 +3817,16 @@ class Ge {
3817
3817
  this.rand = e.rand, this.sparsity = e.sparsity;
3818
3818
  }
3819
3819
  calculateCoordinates(e) {
3820
- const { graph: t, viewport: s } = e, o = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((y) => {
3821
- const v = t.getNode(y);
3820
+ const { graph: t, viewport: s } = e, o = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((p) => {
3821
+ const v = t.getNode(p);
3822
3822
  return v.x === null || v.y === null;
3823
3823
  }), a = Math.sqrt(n.length) * this.sparsity, { width: h, height: d } = s.getDimensions(), c = { x: h / 2, y: d / 2 }, g = s.createContentCoords(c), l = a / 2, u = {
3824
3824
  x: g.x - l,
3825
3825
  y: g.y - l
3826
3826
  };
3827
- return t.getAllNodeIds().forEach((y) => {
3828
- const v = t.getNode(y);
3829
- o.set(y, {
3827
+ return t.getAllNodeIds().forEach((p) => {
3828
+ const v = t.getNode(p);
3829
+ o.set(p, {
3830
3830
  x: v.x ?? u.x + a * this.rand(),
3831
3831
  y: v.y ?? u.y + a * this.rand()
3832
3832
  });
@@ -3923,52 +3923,71 @@ class or {
3923
3923
  }
3924
3924
  class ir {
3925
3925
  constructor(e) {
3926
- i(this, "baseRadius");
3927
- this.baseRadius = e.radius;
3926
+ this.params = e;
3928
3927
  }
3929
- resolve(e) {
3930
- let t = 0, s = -1 / 0;
3931
- const o = [];
3932
- e.forEach((h) => {
3933
- h === null ? (t += this.baseRadius, o.push(t), t += this.baseRadius) : t + this.baseRadius - h < s ? (s += h, o.push(s), t = s + this.baseRadius, s += h) : (t += this.baseRadius, o.push(t), s = t + h, t += this.baseRadius);
3928
+ generate(e) {
3929
+ let t = 0;
3930
+ const s = [], o = e.length - 1, n = [];
3931
+ e.forEach((h, d) => {
3932
+ if (t += this.params.spaceAroundRadius, h.forEach((c, g) => {
3933
+ n[g] === void 0 ? n[g] = {
3934
+ start: t + c.start,
3935
+ end: t + c.end
3936
+ } : n[g].end = t + c.end;
3937
+ }), s.push(t), d !== o) {
3938
+ const c = e[d + 1];
3939
+ t += this.calculateMaxDiff(
3940
+ // subtree,
3941
+ // TODO: consider finer options
3942
+ n.map((g) => ({
3943
+ start: g.start - t,
3944
+ end: g.end - t
3945
+ })),
3946
+ c
3947
+ );
3948
+ }
3949
+ t += this.params.spaceAroundRadius;
3934
3950
  });
3935
- const n = t / 2;
3936
- let a = 0;
3937
- if (e.length > 0) {
3938
- const h = e[e.length - 1] ?? 0, d = o[o.length - 1];
3939
- a = Math.max(
3940
- a,
3941
- d + h - t
3942
- );
3943
- const c = e[0] ?? 0, g = o[0];
3944
- a = Math.max(a, c - g);
3945
- }
3951
+ const a = t / 2;
3946
3952
  return {
3947
- offsets: o.map((h) => h - n),
3948
- radius: n + a
3953
+ childOffsets: s.map((h) => h - a),
3954
+ subtreeSpans: n.map((h) => ({
3955
+ start: h.start - a,
3956
+ end: h.end - a
3957
+ }))
3949
3958
  };
3950
3959
  }
3960
+ calculateMaxDiff(e, t) {
3961
+ let s = 0;
3962
+ const o = Math.min(e.length, t.length);
3963
+ for (let n = 0; n < o; n++) {
3964
+ const a = e[n].end - t[n].start;
3965
+ s = Math.max(s, a);
3966
+ }
3967
+ return s - 2 * this.params.spaceAroundRadius;
3968
+ }
3951
3969
  }
3952
3970
  class nr {
3953
3971
  constructor(e, t) {
3954
3972
  i(this, "offsets", /* @__PURE__ */ new Map());
3955
- i(this, "childrenRadii", /* @__PURE__ */ new Map());
3956
- i(this, "layerNodePlacementResolver");
3957
- this.tree = e, this.layerNodePlacementResolver = new ir({
3958
- radius: t.spaceAroundRadius
3959
- }), [...this.tree.sequence].reverse().forEach((s) => {
3960
- if (s.children.size === 0)
3961
- this.childrenRadii.set(s.nodeId, null);
3962
- else {
3963
- const o = Array.from(s.children).map(
3964
- (h) => this.childrenRadii.get(h.nodeId)
3965
- ), n = this.layerNodePlacementResolver.resolve(o);
3966
- this.childrenRadii.set(s.nodeId, n.radius);
3967
- let a = 0;
3968
- s.children.forEach((h) => {
3969
- this.offsets.set(h.nodeId, n.offsets[a]), a++;
3970
- });
3971
- }
3973
+ i(this, "treeSpans", /* @__PURE__ */ new Map());
3974
+ this.tree = e;
3975
+ const s = t.spaceAroundRadius, o = new ir({
3976
+ spaceAroundRadius: s
3977
+ });
3978
+ [...this.tree.sequence].reverse().forEach((n) => {
3979
+ const a = Array.from(n.children).map(
3980
+ (c) => this.treeSpans.get(c.nodeId)
3981
+ ), h = o.generate(a);
3982
+ let d = 0;
3983
+ n.children.forEach((c) => {
3984
+ this.offsets.set(c.nodeId, h.childOffsets[d]), d++;
3985
+ }), this.treeSpans.set(n.nodeId, [
3986
+ { start: -s, end: s },
3987
+ ...h.subtreeSpans
3988
+ ]), n.children.forEach((c) => {
3989
+ this.treeSpans.delete(c.nodeId);
3990
+ });
3972
3991
  }), this.offsets.set(this.tree.root.nodeId, 0);
3973
3992
  }
3974
3993
  generate() {
@@ -3992,17 +4011,16 @@ class ar {
3992
4011
  const g = [];
3993
4012
  n += this.params.layerWidth, c.forEach((l) => {
3994
4013
  l.children.forEach((u) => {
3995
- const p = t.get(l.nodeId).y;
4014
+ const w = t.get(l.nodeId).y;
3996
4015
  t.set(u.nodeId, {
3997
- y: p + d.get(u.nodeId),
4016
+ y: w + d.get(u.nodeId),
3998
4017
  x: n
3999
4018
  }), g.push(u);
4000
4019
  });
4001
4020
  }), c = g;
4002
4021
  }
4003
- }), t.forEach((a) => {
4004
- const h = this.params.transform(a);
4005
- a.x = h.x, a.y = h.y;
4022
+ }), t.forEach((a, h) => {
4023
+ t.set(h, this.params.transform(a));
4006
4024
  }), t;
4007
4025
  }
4008
4026
  }
@@ -4118,7 +4136,7 @@ const je = (r) => {
4118
4136
  schedule: Mt
4119
4137
  } : {
4120
4138
  type: "topologyChangeSchedule",
4121
- schedule: Rt
4139
+ schedule: Dt
4122
4140
  }, F = Object.freeze({
4123
4141
  staticNodeResolver: () => !1,
4124
4142
  onBeforeApplied: () => {
@@ -4379,13 +4397,9 @@ class Nr {
4379
4397
  i(this, "hasAnimatedLayout", !1);
4380
4398
  i(this, "hasLayout", !1);
4381
4399
  i(this, "boxRenderingTrigger", new K());
4382
- i(this, "graphStore");
4383
- i(this, "viewportStore");
4384
- i(this, "graph");
4385
- i(this, "viewport");
4386
4400
  i(this, "window", window);
4387
4401
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
4388
- this.element = e, this.viewportStore = new it(this.element), this.viewport = new $e(this.viewportStore), this.graphStore = new be(), this.graph = new Ie(this.graphStore);
4402
+ this.element = e;
4389
4403
  }
4390
4404
  setDefaults(e) {
4391
4405
  return this.canvasDefaults = e, this;
@@ -4421,110 +4435,110 @@ class Nr {
4421
4435
  if (this.used)
4422
4436
  throw new Jt("CanvasBuilder is a single use object");
4423
4437
  this.used = !0;
4424
- const e = new Wt(this.element), t = this.createHtmlView(e.main), s = Er(
4438
+ const e = new it(this.element), t = new be(), s = new Wt(this.element), o = this.createHtmlView(
4439
+ s.main,
4440
+ t,
4441
+ e
4442
+ ), n = Er(
4425
4443
  this.canvasDefaults
4426
- ), o = new Be(
4427
- this.graphStore,
4444
+ ), a = new Be(
4428
4445
  t,
4429
- s
4430
- ), n = yr(this.layoutConfig), a = br({
4446
+ o,
4447
+ n
4448
+ ), h = yr(this.layoutConfig), d = br({
4431
4449
  canvasDefaults: this.canvasDefaults,
4432
4450
  hasLayout: this.hasLayout,
4433
- layoutParams: n
4434
- }), h = new We(
4435
- this.graphStore,
4436
- this.viewportStore,
4437
- a
4438
- ), d = new Se(
4439
- this.graph,
4440
- this.viewport,
4441
- o,
4442
- h
4451
+ layoutParams: h
4452
+ }), c = new We(
4453
+ t,
4454
+ e,
4455
+ d
4456
+ ), g = new $e(e), l = new Ie(t), u = new Se(
4457
+ l,
4458
+ g,
4459
+ a,
4460
+ c
4443
4461
  );
4444
4462
  if (this.hasBackground && re.configure(
4445
- d,
4463
+ u,
4446
4464
  jt(this.backgroundConfig),
4447
- e.background
4448
- ), this.hasNodeResizeReactiveEdges && Q.configure(d), this.hasDraggableNodes) {
4449
- let g = zt(this.dragConfig);
4450
- this.hasAnimatedLayout && (g = fr(
4451
- g,
4465
+ s.background
4466
+ ), this.hasNodeResizeReactiveEdges && Q.configure(u), this.hasDraggableNodes) {
4467
+ let p = zt(this.dragConfig);
4468
+ this.hasAnimatedLayout && (p = fr(
4469
+ p,
4452
4470
  this.animationStaticNodes
4453
4471
  )), ee.configure(
4454
- d,
4455
- e.main,
4472
+ u,
4473
+ s.main,
4456
4474
  this.window,
4457
- g
4475
+ p
4458
4476
  );
4459
4477
  }
4460
4478
  if (this.hasUserConnectablePorts) {
4461
- const g = qt(
4479
+ const p = qt(
4462
4480
  this.connectablePortsConfig,
4463
- s.edges.shapeFactory,
4464
- s.ports.direction
4481
+ n.edges.shapeFactory,
4482
+ n.ports.direction
4465
4483
  );
4466
4484
  se.configure(
4467
- d,
4468
- e.overlayConnectablePorts,
4469
- this.viewportStore,
4485
+ u,
4486
+ s.overlayConnectablePorts,
4487
+ e,
4470
4488
  this.window,
4471
- g
4489
+ p
4472
4490
  );
4473
4491
  }
4474
4492
  if (this.hasUserDraggableEdges) {
4475
- const g = Kt(
4493
+ const p = Kt(
4476
4494
  this.draggableEdgesConfig,
4477
- d.graph
4495
+ u.graph
4478
4496
  );
4479
4497
  oe.configure(
4480
- d,
4481
- e.overlayDraggableEdges,
4482
- this.viewportStore,
4498
+ u,
4499
+ s.overlayDraggableEdges,
4500
+ e,
4483
4501
  this.window,
4484
- g
4502
+ p
4485
4503
  );
4486
4504
  }
4487
4505
  if (this.virtualScrollConfig !== void 0 ? te.configure(
4488
- d,
4489
- e.main,
4506
+ u,
4507
+ s.main,
4490
4508
  this.window,
4491
4509
  Ae(this.transformConfig),
4492
4510
  this.boxRenderingTrigger,
4493
4511
  Qt(this.virtualScrollConfig)
4494
4512
  ) : this.hasTransformableViewport && Y.configure(
4495
- d,
4496
- e.main,
4513
+ u,
4514
+ s.main,
4497
4515
  this.window,
4498
4516
  Ae(this.transformConfig)
4499
- ), this.hasLayout && $t.configure(d, n), this.hasAnimatedLayout) {
4500
- let g = cr(
4517
+ ), this.hasLayout && $t.configure(u, h), this.hasAnimatedLayout) {
4518
+ let p = cr(
4501
4519
  this.animatedLayoutConfig
4502
4520
  );
4503
4521
  this.hasDraggableNodes && (mr(
4504
- d,
4522
+ u,
4505
4523
  this.animationStaticNodes
4506
- ), g = vr(
4507
- g,
4524
+ ), p = vr(
4525
+ p,
4508
4526
  this.animationStaticNodes
4509
- )), ae.configure(d, g, this.window);
4527
+ )), ae.configure(u, p, this.window);
4510
4528
  }
4511
- const c = () => {
4512
- e.destroy(), d.onBeforeDestroy.unsubscribe(c);
4529
+ const w = () => {
4530
+ s.destroy(), u.onBeforeDestroy.unsubscribe(w);
4513
4531
  };
4514
- return d.onBeforeDestroy.subscribe(c), d;
4532
+ return u.onBeforeDestroy.subscribe(w), u;
4515
4533
  }
4516
- createHtmlView(e) {
4517
- let t = new Ee(
4518
- this.graphStore,
4519
- this.viewportStore,
4520
- e
4521
- );
4522
- return this.virtualScrollConfig !== void 0 && (t = new rt(
4534
+ createHtmlView(e, t, s) {
4535
+ let o = new Ee(t, s, e);
4536
+ return this.virtualScrollConfig !== void 0 && (o = new rt(
4537
+ o,
4523
4538
  t,
4524
- this.graphStore,
4525
4539
  this.boxRenderingTrigger,
4526
4540
  Zt(this.virtualScrollConfig)
4527
- )), t = new st(t, this.graphStore), t;
4541
+ )), o = new st(o, t), o;
4528
4542
  }
4529
4543
  }
4530
4544
  export {
@@ -4532,7 +4546,7 @@ export {
4532
4546
  Nr as CanvasBuilder,
4533
4547
  Jt as CanvasBuilderError,
4534
4548
  E as CanvasError,
4535
- R as ConnectionCategory,
4549
+ D as ConnectionCategory,
4536
4550
  Ve as DirectEdgeShape,
4537
4551
  K as EventSubject,
4538
4552
  St as HorizontalEdgeShape,