@html-graph/html-graph 3.14.0 → 3.15.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.
@@ -51,8 +51,8 @@ class ue {
51
51
  this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
52
52
  }
53
53
  updateNodePosition(e) {
54
- const t = this.graphStore.getNode(e), { width: s, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, h = t.centerFn(s, i), a = t.x - n * h.x, d = t.y - n * h.y;
55
- t.element.style.transform = `translate(${a}px, ${d}px)`;
54
+ const t = this.graphStore.getNode(e), { width: s, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, a = t.centerFn(s, i), h = t.x - n * a.x, d = t.y - n * a.y;
55
+ t.element.style.transform = `translate(${h}px, ${d}px)`;
56
56
  }
57
57
  updateNodePriority(e) {
58
58
  const t = this.graphStore.getNode(e);
@@ -65,17 +65,17 @@ class ue {
65
65
  this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg);
66
66
  }
67
67
  renderEdge(e) {
68
- const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to), n = s.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), a = this.host.getBoundingClientRect(), d = this.viewportStore.getViewportMatrix(), c = this.createEdgeRenderPort(
68
+ const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to), n = s.element.getBoundingClientRect(), a = i.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), d = this.viewportStore.getViewportMatrix(), c = this.createEdgeRenderPort(
69
69
  t.from,
70
70
  s,
71
71
  n,
72
- a,
72
+ h,
73
73
  d
74
74
  ), l = this.createEdgeRenderPort(
75
75
  t.to,
76
76
  i,
77
- h,
78
77
  a,
78
+ h,
79
79
  d
80
80
  );
81
81
  t.shape.render({ from: c, to: l });
@@ -85,13 +85,13 @@ class ue {
85
85
  t.shape.svg.style.zIndex = `${t.priority}`;
86
86
  }
87
87
  createEdgeRenderPort(e, t, s, i, n) {
88
- const h = {
88
+ const a = {
89
89
  x: s.left - i.left,
90
90
  y: s.top - i.top
91
- }, a = T(n, h);
91
+ }, h = T(n, a);
92
92
  return {
93
- x: a.x,
94
- y: a.y,
93
+ x: h.x,
94
+ y: h.y,
95
95
  width: s.width * n.scale,
96
96
  height: s.height * n.scale,
97
97
  direction: t.direction,
@@ -116,8 +116,8 @@ class Ie {
116
116
  return t.x >= this.xFrom && t.x <= this.xTo && t.y >= this.yFrom && t.y <= this.yTo;
117
117
  }
118
118
  hasEdge(e) {
119
- const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(s), h = this.graphStore.getNode(i), a = Math.min(n.x, h.x), d = Math.max(n.x, h.x), c = Math.min(n.y, h.y), l = Math.max(n.y, h.y);
120
- return a <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
119
+ const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(s), a = this.graphStore.getNode(i), h = Math.min(n.x, a.x), d = Math.max(n.x, a.x), c = Math.min(n.y, a.y), l = Math.max(n.y, a.y);
120
+ return h <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
121
121
  }
122
122
  }
123
123
  class Ue {
@@ -128,20 +128,20 @@ class Ue {
128
128
  o(this, "updateViewport", (e) => {
129
129
  this.renderingBox.setRenderingBox(e);
130
130
  const t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
131
- this.graphStore.getAllNodeIds().forEach((h) => {
132
- const a = this.renderingBox.hasNode(h), d = this.attachedNodes.has(h);
133
- a && !d ? t.add(h) : !a && d && s.add(h);
134
- }), this.graphStore.getAllEdgeIds().forEach((h) => {
135
- const a = this.renderingBox.hasEdge(h), d = this.attachedEdges.has(h), c = this.graphStore.getEdge(h), l = this.graphStore.getPort(c.from).nodeId, g = this.graphStore.getPort(c.to).nodeId;
136
- a && (this.renderingBox.hasNode(l) || (t.add(l), s.delete(l)), this.renderingBox.hasNode(g) || (t.add(g), s.delete(g))), a && !d ? i.add(h) : !a && d && n.add(h);
137
- }), n.forEach((h) => {
138
- this.handleDetachEdge(h);
139
- }), s.forEach((h) => {
140
- this.handleDetachNode(h);
141
- }), t.forEach((h) => {
142
- this.attachedNodes.has(h) || this.handleAttachNode(h);
143
- }), i.forEach((h) => {
144
- this.handleAttachEdge(h);
131
+ this.graphStore.getAllNodeIds().forEach((a) => {
132
+ const h = this.renderingBox.hasNode(a), d = this.attachedNodes.has(a);
133
+ h && !d ? t.add(a) : !h && d && s.add(a);
134
+ }), this.graphStore.getAllEdgeIds().forEach((a) => {
135
+ const h = this.renderingBox.hasEdge(a), d = this.attachedEdges.has(a), c = this.graphStore.getEdge(a), l = this.graphStore.getPort(c.from).nodeId, g = this.graphStore.getPort(c.to).nodeId;
136
+ h && (this.renderingBox.hasNode(l) || (t.add(l), s.delete(l)), this.renderingBox.hasNode(g) || (t.add(g), s.delete(g))), h && !d ? i.add(a) : !h && d && n.add(a);
137
+ }), n.forEach((a) => {
138
+ this.handleDetachEdge(a);
139
+ }), s.forEach((a) => {
140
+ this.handleDetachNode(a);
141
+ }), t.forEach((a) => {
142
+ this.attachedNodes.has(a) || this.handleAttachNode(a);
143
+ }), i.forEach((a) => {
144
+ this.handleAttachEdge(a);
145
145
  });
146
146
  });
147
147
  this.htmlView = e, this.graphStore = t, this.trigger = s, this.renderingBox = new Ie(this.graphStore), this.trigger.subscribe(this.updateViewport);
@@ -880,8 +880,8 @@ class Y {
880
880
  }
881
881
  }
882
882
  const Fe = (r, e, t) => {
883
- const { x: s, y: i, width: n, height: h } = r.getBoundingClientRect();
884
- return e >= s && e <= s + n && t >= i && t <= i + h;
883
+ const { x: s, y: i, width: n, height: a } = r.getBoundingClientRect();
884
+ return e >= s && e <= s + n && t >= i && t <= i + a;
885
885
  }, Oe = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, L = (r, e, t, s) => Fe(e, t, s) && Oe(r, t, s), U = (r, e) => {
886
886
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
887
887
  }, V = (r) => {
@@ -942,11 +942,11 @@ class ze {
942
942
  ), n = {
943
943
  x: s.x + this.params.sourceDirection.x * this.params.curvature,
944
944
  y: s.y + this.params.sourceDirection.y * this.params.curvature
945
- }, h = {
945
+ }, a = {
946
946
  x: i.x - this.params.targetDirection.x * this.params.curvature,
947
947
  y: i.y - this.params.targetDirection.y * this.params.curvature
948
- }, a = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${h.x} ${h.y}, ${i.x} ${i.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${i.x} ${i.y} L ${this.params.to.x} ${this.params.to.y}`;
949
- this.path = `${d}${a}${c}`;
948
+ }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${i.x} ${i.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${i.x} ${i.y} L ${this.params.to.x} ${this.params.to.y}`;
949
+ this.path = `${d}${h}${c}`;
950
950
  }
951
951
  }
952
952
  const ye = (r, e, t, s) => ({
@@ -969,19 +969,19 @@ class Xe {
969
969
  },
970
970
  this.params.targetDirection,
971
971
  this.params.to
972
- ) : this.params.to, i = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, a = n * this.params.flipX, d = h * this.params.flipY, c = m(
972
+ ) : this.params.to, i = 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(
973
973
  { x: i, y: w.y },
974
974
  this.params.sourceDirection,
975
975
  w
976
976
  ), l = {
977
- x: c.x + a,
977
+ x: c.x + h,
978
978
  y: c.y + d
979
979
  }, g = m(
980
980
  { x: this.params.to.x - i, y: this.params.to.y },
981
981
  this.params.targetDirection,
982
982
  this.params.to
983
983
  ), p = {
984
- x: g.x + a,
984
+ x: g.x + h,
985
985
  y: g.y + d
986
986
  }, f = {
987
987
  x: (l.x + p.x) / 2,
@@ -993,10 +993,10 @@ class Xe {
993
993
  x: g.x - this.params.curvature * this.params.targetDirection.x,
994
994
  y: g.y - this.params.curvature * this.params.targetDirection.y
995
995
  }, E = {
996
- x: c.x + a,
996
+ x: c.x + h,
997
997
  y: c.y + d
998
998
  }, x = {
999
- x: g.x + a,
999
+ x: g.x + h,
1000
1000
  y: g.y + d
1001
1001
  };
1002
1002
  this.path = [
@@ -1012,17 +1012,17 @@ const C = (r, e) => {
1012
1012
  const t = [];
1013
1013
  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) {
1014
1014
  const s = r.length - 1;
1015
- let i = 0, n = 0, h = 0;
1016
- r.forEach((a, d) => {
1015
+ let i = 0, n = 0, a = 0;
1016
+ r.forEach((h, d) => {
1017
1017
  let c = 0, l = 0, g = 0;
1018
1018
  const p = d > 0, f = d < s, v = p && f;
1019
- if (p && (c = -i, l = -n, g = h), f) {
1019
+ if (p && (c = -i, l = -n, g = a), f) {
1020
1020
  const R = r[d + 1];
1021
- i = R.x - a.x, n = R.y - a.y, h = Math.sqrt(i * i + n * n);
1021
+ i = R.x - h.x, n = R.y - h.y, a = Math.sqrt(i * i + n * n);
1022
1022
  }
1023
- const E = h !== 0 ? Math.min((v ? e : 0) / h, d < s - 1 ? 0.5 : 1) : 0, x = v ? { x: a.x + i * E, y: a.y + n * E } : a, D = g !== 0 ? Math.min((v ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, N = v ? { x: a.x + c * D, y: a.y + l * D } : a;
1023
+ const E = a !== 0 ? Math.min((v ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, x = v ? { x: h.x + i * E, y: h.y + n * E } : h, D = g !== 0 ? Math.min((v ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, N = v ? { x: h.x + c * D, y: h.y + l * D } : h;
1024
1024
  d > 0 && t.push(`L ${N.x} ${N.y}`), v && t.push(
1025
- `C ${a.x} ${a.y} ${a.x} ${a.y} ${x.x} ${x.y}`
1025
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${x.x} ${x.y}`
1026
1026
  );
1027
1027
  });
1028
1028
  }
@@ -1046,23 +1046,23 @@ class Ye {
1046
1046
  },
1047
1047
  this.params.targetDirection,
1048
1048
  this.params.to
1049
- ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = m(
1050
- { x: h, y: w.y },
1049
+ ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1050
+ { x: a, y: w.y },
1051
1051
  this.params.sourceDirection,
1052
1052
  w
1053
1053
  ), d = m(
1054
- { x: this.params.to.x - h, y: this.params.to.y },
1054
+ { x: this.params.to.x - a, y: this.params.to.y },
1055
1055
  this.params.targetDirection,
1056
1056
  this.params.to
1057
- ), c = Math.max((a.x + d.x) / 2, n), l = this.params.to.y / 2, g = {
1057
+ ), c = Math.max((h.x + d.x) / 2, n), l = this.params.to.y / 2, g = {
1058
1058
  x: this.params.flipX > 0 ? c : -n,
1059
- y: a.y
1059
+ y: h.y
1060
1060
  }, p = { x: g.x, y: l }, f = {
1061
1061
  x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
1062
1062
  y: d.y
1063
1063
  }, v = { x: f.x, y: l };
1064
1064
  this.path = C(
1065
- [s, a, g, p, v, f, d, i],
1065
+ [s, h, g, p, v, f, d, i],
1066
1066
  this.params.roundness
1067
1067
  );
1068
1068
  }
@@ -1087,7 +1087,7 @@ class H {
1087
1087
  { x: i, y: w.y },
1088
1088
  this.params.sourceDirection,
1089
1089
  w
1090
- ), h = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = h * this.params.flipX, c = a * this.params.flipY, l = { x: n.x + d, y: n.y + c }, g = m(
1090
+ ), 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, l = { x: n.x + d, y: n.y + c }, g = m(
1091
1091
  { x: this.params.to.x - i, y: this.params.to.y },
1092
1092
  this.params.targetDirection,
1093
1093
  this.params.to
@@ -1116,16 +1116,16 @@ class He {
1116
1116
  },
1117
1117
  this.params.targetDirection,
1118
1118
  this.params.to
1119
- ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = m(
1119
+ ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = m(
1120
1120
  { x: n, y: w.y },
1121
1121
  this.params.sourceDirection,
1122
1122
  w
1123
- ), a = m(
1123
+ ), h = m(
1124
1124
  { x: this.params.to.x - n, y: this.params.to.y },
1125
1125
  this.params.targetDirection,
1126
1126
  this.params.to
1127
1127
  );
1128
- this.path = C([s, h, a, i], this.params.roundness);
1128
+ this.path = C([s, a, h, i], this.params.roundness);
1129
1129
  }
1130
1130
  }
1131
1131
  class je {
@@ -1146,23 +1146,23 @@ class je {
1146
1146
  },
1147
1147
  this.params.targetDirection,
1148
1148
  this.params.to
1149
- ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, h = n - this.params.roundness, a = m(
1150
- { x: h, y: w.y },
1149
+ ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1150
+ { x: a, y: w.y },
1151
1151
  this.params.sourceDirection,
1152
1152
  w
1153
1153
  ), d = m(
1154
- { x: this.params.to.x - h, y: this.params.to.y },
1154
+ { x: this.params.to.x - a, y: this.params.to.y },
1155
1155
  this.params.targetDirection,
1156
1156
  this.params.to
1157
- ), c = Math.max((a.y + d.y) / 2, n), l = this.params.to.x / 2, g = {
1158
- x: a.x,
1157
+ ), c = Math.max((h.y + d.y) / 2, n), l = this.params.to.x / 2, g = {
1158
+ x: h.x,
1159
1159
  y: this.params.flipY > 0 ? c : -n
1160
1160
  }, p = { x: l, y: g.y }, f = {
1161
1161
  x: d.x,
1162
1162
  y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
1163
1163
  }, v = { x: l, y: f.y };
1164
1164
  this.path = C(
1165
- [s, a, g, p, v, f, d, i],
1165
+ [s, h, g, p, v, f, d, i],
1166
1166
  this.params.roundness
1167
1167
  );
1168
1168
  }
@@ -1172,7 +1172,7 @@ class j {
1172
1172
  o(this, "path");
1173
1173
  o(this, "midpoint");
1174
1174
  this.params = e;
1175
- const t = this.params.arrowOffset, s = this.params.side, i = this.params.arrowLength + t, n = i + 2 * s, a = [
1175
+ const t = this.params.arrowOffset, s = this.params.side, i = this.params.arrowLength + t, n = i + 2 * s, h = [
1176
1176
  { x: this.params.arrowLength, y: w.y },
1177
1177
  { x: i, y: w.y },
1178
1178
  { x: i, y: this.params.side },
@@ -1183,8 +1183,8 @@ class j {
1183
1183
  { x: this.params.arrowLength, y: w.y }
1184
1184
  ].map(
1185
1185
  (c) => m(c, this.params.sourceDirection, w)
1186
- ), d = `M ${w.x} ${w.y} L ${a[0].x} ${a[0].y} `;
1187
- this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${C(a, this.params.roundness)}`, this.midpoint = { x: (a[3].x + a[4].x) / 2, y: (a[3].y + a[4].y) / 2 };
1186
+ ), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
1187
+ this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${C(h, this.params.roundness)}`, this.midpoint = { x: (h[3].x + h[4].x) / 2, y: (h[3].y + h[4].y) / 2 };
1188
1188
  }
1189
1189
  }
1190
1190
  class Ge {
@@ -1192,7 +1192,7 @@ class Ge {
1192
1192
  o(this, "path");
1193
1193
  o(this, "midpoint");
1194
1194
  this.params = e;
1195
- const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i, h = Math.sqrt(i * i - t * t), a = h * t / i, d = h + s + this.params.arrowLength, c = this.params.arrowLength + a, g = [
1195
+ const t = this.params.smallRadius, s = this.params.radius, i = t + s, n = t * s / i, a = Math.sqrt(i * i - t * t), h = a * t / i, d = a + s + this.params.arrowLength, c = this.params.arrowLength + h, g = [
1196
1196
  { x: this.params.arrowLength, y: w.y },
1197
1197
  { x: c, y: n },
1198
1198
  { x: c, y: -n },
@@ -1267,12 +1267,12 @@ const Ee = (r, e) => {
1267
1267
  }, s = {
1268
1268
  x: e.x + e.width / 2,
1269
1269
  y: e.y + e.height / 2
1270
- }, i = Math.min(t.x, s.x), n = Math.min(t.y, s.y), h = Math.abs(s.x - t.x), a = Math.abs(s.y - t.y), d = t.x <= s.x ? 1 : -1, c = t.y <= s.y ? 1 : -1;
1270
+ }, i = Math.min(t.x, s.x), n = Math.min(t.y, s.y), a = Math.abs(s.x - t.x), h = Math.abs(s.y - t.y), d = t.x <= s.x ? 1 : -1, c = t.y <= s.y ? 1 : -1;
1271
1271
  return {
1272
1272
  x: i,
1273
1273
  y: n,
1274
- width: h,
1275
- height: a,
1274
+ width: a,
1275
+ height: h,
1276
1276
  flipX: d,
1277
1277
  flipY: c
1278
1278
  };
@@ -1281,8 +1281,8 @@ const Ee = (r, e) => {
1281
1281
  w,
1282
1282
  { x: t, y: s },
1283
1283
  { x: t, y: -s }
1284
- ].map((c) => m(c, r, w)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })), h = `M ${n[0].x} ${n[0].y}`, a = `L ${n[1].x} ${n[1].y}`, d = `L ${n[2].x} ${n[2].y}`;
1285
- return `${h} ${a} ${d} Z`;
1284
+ ].map((c) => m(c, r, w)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })), a = `M ${n[0].x} ${n[0].y}`, h = `L ${n[1].x} ${n[1].y}`, d = `L ${n[2].x} ${n[2].y}`;
1285
+ return `${a} ${h} ${d} Z`;
1286
1286
  }, u = Object.freeze({
1287
1287
  color: "#777777",
1288
1288
  width: 1,
@@ -1314,19 +1314,19 @@ class W {
1314
1314
  this.params = e, [this.afterRenderEmitter, this.onAfterRender] = A(), this.svg = Ae(e.color), this.svg.appendChild(this.group), this.line = Se(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = B(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = B(), this.group.appendChild(this.targetArrow));
1315
1315
  }
1316
1316
  render(e) {
1317
- const { x: t, y: s, width: i, height: n, flipX: h, flipY: a } = be(
1317
+ const { x: t, y: s, width: i, height: n, flipX: a, flipY: h } = be(
1318
1318
  e.from,
1319
1319
  e.to
1320
1320
  );
1321
- Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${h}, ${a})`;
1321
+ Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1322
1322
  const d = ne(
1323
1323
  e.from.direction,
1324
- h,
1325
- a
1324
+ a,
1325
+ h
1326
1326
  ), c = ne(
1327
1327
  e.to.direction,
1328
- h,
1329
- a
1328
+ a,
1329
+ h
1330
1330
  ), l = {
1331
1331
  x: i,
1332
1332
  y: n
@@ -1337,8 +1337,8 @@ class W {
1337
1337
  d,
1338
1338
  c,
1339
1339
  l,
1340
- h,
1341
- a
1340
+ a,
1341
+ h
1342
1342
  );
1343
1343
  this.line.setAttribute("d", v.path);
1344
1344
  let y = null;
@@ -1681,11 +1681,11 @@ class Pe {
1681
1681
  [this.afterRenderEmitter, this.onAfterRender] = A(), this.color = (e == null ? void 0 : e.color) ?? u.color, this.width = (e == null ? void 0 : e.width) ?? u.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? u.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? u.preOffset, this.svg = Ae(this.color), this.svg.appendChild(this.group), this.line = Se(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = B(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = B(), this.group.appendChild(this.targetArrow));
1682
1682
  }
1683
1683
  render(e) {
1684
- const { x: t, y: s, width: i, height: n, flipX: h, flipY: a } = be(
1684
+ const { x: t, y: s, width: i, height: n, flipX: a, flipY: h } = be(
1685
1685
  e.from,
1686
1686
  e.to
1687
1687
  );
1688
- Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${h}, ${a})`;
1688
+ Ee(this.svg, { x: t, y: s, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1689
1689
  const d = { x: i, y: n }, c = new Ke({
1690
1690
  to: d,
1691
1691
  sourceOffset: this.sourceOffset,
@@ -1921,13 +1921,13 @@ class K {
1921
1921
  const i = this.graph.getNode(e);
1922
1922
  if (i === null)
1923
1923
  return;
1924
- const n = this.canvas.viewport.getContentMatrix(), h = T(n, {
1924
+ const n = this.canvas.viewport.getContentMatrix(), a = T(n, {
1925
1925
  x: i.x,
1926
1926
  y: i.y
1927
- }), a = T(
1927
+ }), h = T(
1928
1928
  { scale: 1, x: t, y: s },
1929
- h
1930
- ), d = this.canvas.viewport.getViewportMatrix(), c = T(d, a);
1929
+ a
1930
+ ), d = this.canvas.viewport.getViewportMatrix(), c = T(d, h);
1931
1931
  this.canvas.updateNode(e, { x: c.x, y: c.y }), this.config.onNodeDrag({
1932
1932
  nodeId: e,
1933
1933
  element: i.element,
@@ -1986,19 +1986,19 @@ const rt = (r, e, t) => ({
1986
1986
  y: r.scale * (1 - e) * s + r.y
1987
1987
  }), I = (r) => {
1988
1988
  const e = [], t = r.touches.length;
1989
- for (let a = 0; a < t; a++)
1990
- e.push([r.touches[a].clientX, r.touches[a].clientY]);
1989
+ for (let h = 0; h < t; h++)
1990
+ e.push([r.touches[h].clientX, r.touches[h].clientY]);
1991
1991
  const s = e.reduce(
1992
- (a, d) => [a[0] + d[0], a[1] + d[1]],
1992
+ (h, d) => [h[0] + d[0], h[1] + d[1]],
1993
1993
  [0, 0]
1994
- ), i = [s[0] / t, s[1] / t], h = e.map((a) => [a[0] - i[0], a[1] - i[1]]).reduce(
1995
- (a, d) => a + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1994
+ ), i = [s[0] / t, s[1] / t], a = e.map((h) => [h[0] - i[0], h[1] - i[1]]).reduce(
1995
+ (h, d) => h + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1996
1996
  0
1997
1997
  );
1998
1998
  return {
1999
1999
  x: i[0],
2000
2000
  y: i[1],
2001
- scale: h / t,
2001
+ scale: a / t,
2002
2002
  touchesCnt: t,
2003
2003
  touches: e
2004
2004
  };
@@ -2039,8 +2039,8 @@ class $ {
2039
2039
  o(this, "onWheelScroll", (e) => {
2040
2040
  if (!this.params.mouseWheelEventVerifier(e))
2041
2041
  return;
2042
- const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s, a = 1 / (e.deltaY < 0 ? this.params.wheelSensitivity : 1 / this.params.wheelSensitivity);
2043
- this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(a, i, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
2042
+ const { left: t, top: s } = this.element.getBoundingClientRect(), i = e.clientX - t, n = e.clientY - s, h = 1 / (e.deltaY < 0 ? this.params.wheelSensitivity : 1 / this.params.wheelSensitivity);
2043
+ this.wheelFinishTimer === null && this.params.onTransformStarted(), this.scaleViewport(h, i, n), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
2044
2044
  this.transformInProgress || this.params.onTransformFinished(), this.wheelFinishTimer = null;
2045
2045
  }, this.params.scaleWheelFinishTimeout);
2046
2046
  });
@@ -2069,8 +2069,8 @@ class $ {
2069
2069
  -(t.x - this.prevTouches.x),
2070
2070
  -(t.y - this.prevTouches.y)
2071
2071
  ), t.touchesCnt === 2) {
2072
- const { left: i, top: n } = this.element.getBoundingClientRect(), h = this.prevTouches.x - i, a = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
2073
- this.scaleViewport(c, h, a);
2072
+ const { left: i, top: n } = this.element.getBoundingClientRect(), a = this.prevTouches.x - i, h = this.prevTouches.y - n, c = 1 / (t.scale / this.prevTouches.scale);
2073
+ this.scaleViewport(c, a, h);
2074
2074
  }
2075
2075
  this.prevTouches = t;
2076
2076
  });
@@ -2103,20 +2103,20 @@ class $ {
2103
2103
  new $(e, t, s, i);
2104
2104
  }
2105
2105
  moveViewport(e, t) {
2106
- const s = this.viewport.getViewportMatrix(), i = rt(s, e, t), { width: n, height: h } = this.element.getBoundingClientRect(), a = this.params.transformPreprocessor({
2106
+ const s = this.viewport.getViewportMatrix(), i = rt(s, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2107
2107
  prevTransform: s,
2108
2108
  nextTransform: i,
2109
2109
  canvasWidth: n,
2110
- canvasHeight: h
2110
+ canvasHeight: a
2111
2111
  });
2112
- this.performTransform(a);
2112
+ this.performTransform(h);
2113
2113
  }
2114
2114
  scaleViewport(e, t, s) {
2115
- const i = this.canvas.viewport.getViewportMatrix(), n = ot(i, e, t, s), { width: h, height: a } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2115
+ const i = this.canvas.viewport.getViewportMatrix(), n = ot(i, e, t, s), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2116
2116
  prevTransform: i,
2117
2117
  nextTransform: n,
2118
- canvasWidth: h,
2119
- canvasHeight: a
2118
+ canvasWidth: a,
2119
+ canvasHeight: h
2120
2120
  });
2121
2121
  this.performTransform(d);
2122
2122
  }
@@ -2143,7 +2143,7 @@ class $ {
2143
2143
  }
2144
2144
  }
2145
2145
  class Z {
2146
- constructor(e, t, s, i, n, h) {
2146
+ constructor(e, t, s, i, n, a) {
2147
2147
  o(this, "canvasResizeObserver");
2148
2148
  o(this, "nodeHorizontal");
2149
2149
  o(this, "nodeVertical");
@@ -2174,11 +2174,11 @@ class Z {
2174
2174
  this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
2175
2175
  });
2176
2176
  o(this, "userTransformInProgress", !1);
2177
- this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = h, this.nodeHorizontal = this.params.nodeContainingRadius.horizontal, this.nodeVertical = this.params.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((d) => {
2177
+ this.canvas = e, this.element = t, this.window = s, this.trigger = n, this.params = a, this.nodeHorizontal = this.params.nodeContainingRadius.horizontal, this.nodeVertical = this.params.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((d) => {
2178
2178
  const c = d[0];
2179
2179
  this.viewportWidth = c.contentRect.width, this.viewportHeight = c.contentRect.height, this.scheduleLoadAreaAroundViewport();
2180
2180
  }), this.viewport = e.viewport;
2181
- const a = {
2181
+ const h = {
2182
2182
  ...i,
2183
2183
  onResizeTransformStarted: () => {
2184
2184
  this.userTransformInProgress = !0, i.onResizeTransformStarted();
@@ -2202,17 +2202,17 @@ class Z {
2202
2202
  e,
2203
2203
  this.element,
2204
2204
  this.window,
2205
- a
2205
+ h
2206
2206
  ), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2207
2207
  }
2208
- static configure(e, t, s, i, n, h) {
2208
+ static configure(e, t, s, i, n, a) {
2209
2209
  new Z(
2210
2210
  e,
2211
2211
  t,
2212
2212
  s,
2213
2213
  i,
2214
2214
  n,
2215
- h
2215
+ a
2216
2216
  );
2217
2217
  }
2218
2218
  scheduleLoadAreaAroundViewport() {
@@ -2221,12 +2221,12 @@ class Z {
2221
2221
  });
2222
2222
  }
2223
2223
  scheduleEnsureViewportAreaLoaded() {
2224
- const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, i = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal, h = this.viewportMatrix.y + t + this.nodeVertical;
2225
- this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < i && this.loadedArea.yTo > h || this.scheduleLoadAreaAroundViewport();
2224
+ const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - this.nodeHorizontal, i = this.viewportMatrix.y - this.nodeVertical, n = this.viewportMatrix.x + e + this.nodeHorizontal, a = this.viewportMatrix.y + t + this.nodeVertical;
2225
+ this.loadedArea.xFrom < s && this.loadedArea.xTo > n && this.loadedArea.yFrom < i && this.loadedArea.yTo > a || this.scheduleLoadAreaAroundViewport();
2226
2226
  }
2227
2227
  loadAreaAroundViewport() {
2228
- const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, i = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal, h = 3 * t + 2 * this.nodeVertical;
2229
- this.trigger.emit({ x: s, y: i, width: n, height: h });
2228
+ const e = this.viewportWidth * this.viewportMatrix.scale, t = this.viewportHeight * this.viewportMatrix.scale, s = this.viewportMatrix.x - e - this.nodeHorizontal, i = this.viewportMatrix.y - t - this.nodeVertical, n = 3 * e + 2 * this.nodeHorizontal, a = 3 * t + 2 * this.nodeVertical;
2229
+ this.trigger.emit({ x: s, y: i, width: n, height: a });
2230
2230
  }
2231
2231
  }
2232
2232
  const st = () => {
@@ -2257,8 +2257,8 @@ class J {
2257
2257
  o(this, "resizeObserver", new ResizeObserver((e) => {
2258
2258
  const t = e[0], { width: s, height: i } = t.contentRect;
2259
2259
  this.svg.setAttribute("width", `${s}`), this.svg.setAttribute("height", `${i}`), this.patternRenderingRectangle.setAttribute("width", `${s}`), this.patternRenderingRectangle.setAttribute("height", `${i}`);
2260
- const n = this.tileWidth / s, h = this.tileHeight / i;
2261
- this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${h}`);
2260
+ const n = this.tileWidth / s, a = this.tileHeight / i;
2261
+ this.pattern.setAttribute("width", `${n}`), this.pattern.setAttribute("height", `${a}`);
2262
2262
  }));
2263
2263
  o(this, "onAfterTransformUpdated", () => {
2264
2264
  const e = this.canvas.viewport.getContentMatrix(), t = e.x - this.halfTileWidth * e.scale, s = e.y - this.halfTileHeight * e.scale, i = `matrix(${e.scale}, 0, 0, ${e.scale}, ${t}, ${s})`;
@@ -2407,15 +2407,15 @@ class Q {
2407
2407
  onStopDrag: () => {
2408
2408
  this.resetDragState();
2409
2409
  },
2410
- onPortPointerDown: (h, a) => {
2411
- const d = this.params.connectionTypeResolver(h);
2412
- return d === null ? !1 : (this.grabPort(h, a, d), !0);
2410
+ onPortPointerDown: (a, h) => {
2411
+ const d = this.params.connectionTypeResolver(a);
2412
+ return d === null ? !1 : (this.grabPort(a, h, d), !0);
2413
2413
  },
2414
- onPointerMove: (h) => {
2415
- this.moveDraggingPort(h);
2414
+ onPointerMove: (a) => {
2415
+ this.moveDraggingPort(a);
2416
2416
  },
2417
- onPointerUp: (h) => {
2418
- this.tryCreateConnection(h);
2417
+ onPointerUp: (a) => {
2418
+ this.tryCreateConnection(a);
2419
2419
  }
2420
2420
  }
2421
2421
  );
@@ -2432,9 +2432,9 @@ class Q {
2432
2432
  grabPort(e, t, s) {
2433
2433
  const i = this.canvas.graph.getPort(e);
2434
2434
  this.staticPortId = e;
2435
- const n = i.element.getBoundingClientRect(), h = n.x + n.width / 2, a = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), l = T(c, {
2436
- x: h - d.x,
2437
- y: a - d.y
2435
+ const n = i.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.getViewportMatrix(), l = T(c, {
2436
+ x: a - d.x,
2437
+ y: h - d.y
2438
2438
  }), g = T(c, {
2439
2439
  x: t.x - d.x,
2440
2440
  y: t.y - d.y
@@ -2467,8 +2467,8 @@ class Q {
2467
2467
  );
2468
2468
  return;
2469
2469
  }
2470
- const s = this.isTargetDragging ? this.staticPortId : t, i = this.isTargetDragging ? t : this.staticPortId, n = { from: s, to: i }, h = this.params.connectionPreprocessor(n);
2471
- h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(n);
2470
+ const s = this.isTargetDragging ? this.staticPortId : t, i = this.isTargetDragging ? t : this.staticPortId, n = { from: s, to: i }, a = this.params.connectionPreprocessor(n);
2471
+ a !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(a), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(n);
2472
2472
  }
2473
2473
  moveDraggingPort(e) {
2474
2474
  const t = this.overlayLayer.getBoundingClientRect(), s = {
@@ -2486,7 +2486,7 @@ class _ {
2486
2486
  o(this, "overlayCanvas");
2487
2487
  o(this, "staticPortId", null);
2488
2488
  o(this, "isTargetDragging", !0);
2489
- o(this, "draggingEdge", null);
2489
+ o(this, "draggingEdgePayload", null);
2490
2490
  o(this, "onEdgeReattached", (e) => {
2491
2491
  this.params.onAfterEdgeReattached(e);
2492
2492
  });
@@ -2503,12 +2503,12 @@ class _ {
2503
2503
  onStopDrag: () => {
2504
2504
  this.resetDragState();
2505
2505
  },
2506
- onPortPointerDown: (h, a) => this.tryStartEdgeDragging(h, a),
2507
- onPointerMove: (h) => {
2508
- this.moveDraggingPort(h);
2506
+ onPortPointerDown: (a, h) => this.tryStartEdgeDragging(a, h),
2507
+ onPointerMove: (a) => {
2508
+ this.moveDraggingPort(a);
2509
2509
  },
2510
- onPointerUp: (h) => {
2511
- this.tryCreateConnection(h);
2510
+ onPointerUp: (a) => {
2511
+ this.tryCreateConnection(a);
2512
2512
  }
2513
2513
  }
2514
2514
  );
@@ -2529,9 +2529,9 @@ class _ {
2529
2529
  const i = this.canvas.graph.getEdge(s);
2530
2530
  if (i === null)
2531
2531
  return !1;
2532
- const n = e === i.from, h = e === i.to, a = n ? i.to : i.from;
2533
- this.staticPortId = a, this.isTargetDragging = h;
2534
- const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(a), l = c.element.getBoundingClientRect(), g = {
2532
+ const n = e === i.from, a = e === i.to, h = n ? i.to : i.from;
2533
+ this.staticPortId = h, this.isTargetDragging = a;
2534
+ const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), l = c.element.getBoundingClientRect(), g = {
2535
2535
  x: l.x + l.width / 2,
2536
2536
  y: l.y + l.height / 2
2537
2537
  }, p = this.canvas.viewport.getViewportMatrix(), f = this.overlayLayer.getBoundingClientRect(), v = T(p, {
@@ -2541,7 +2541,13 @@ class _ {
2541
2541
  x: t.x - f.x,
2542
2542
  y: t.y - f.y
2543
2543
  });
2544
- this.draggingEdge = i, this.canvas.removeEdge(s);
2544
+ this.draggingEdgePayload = {
2545
+ id: s,
2546
+ from: i.from,
2547
+ to: i.to,
2548
+ shape: i.shape,
2549
+ priority: i.priority
2550
+ }, this.canvas.removeEdge(s);
2545
2551
  const E = {
2546
2552
  overlayId: b.Static,
2547
2553
  portCoords: v,
@@ -2561,7 +2567,7 @@ class _ {
2561
2567
  }), !0;
2562
2568
  }
2563
2569
  resetDragState() {
2564
- this.draggingEdge = null, this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
2570
+ this.draggingEdgePayload = null, this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
2565
2571
  }
2566
2572
  moveDraggingPort(e) {
2567
2573
  const t = this.overlayLayer.getBoundingClientRect(), s = {
@@ -2576,16 +2582,34 @@ class _ {
2576
2582
  tryCreateConnection(e) {
2577
2583
  const t = ve(this.canvas.graph, e);
2578
2584
  if (this.overlayCanvas.removeEdge(b.Edge), t === null) {
2579
- this.params.onEdgeReattachInterrupted(this.draggingEdge);
2585
+ const h = this.draggingEdgePayload;
2586
+ this.params.onEdgeReattachInterrupted({
2587
+ id: h.id,
2588
+ from: h.from,
2589
+ to: h.to,
2590
+ shape: h.shape,
2591
+ priority: h.priority
2592
+ });
2580
2593
  return;
2581
2594
  }
2582
2595
  const [s, i] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = {
2583
2596
  from: s,
2584
2597
  to: i,
2585
- shape: this.draggingEdge.shape,
2586
- priority: this.draggingEdge.priority
2587
- }, h = this.params.connectionPreprocessor(n);
2588
- h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached)) : this.params.onEdgeReattachPrevented(this.draggingEdge);
2598
+ shape: this.draggingEdgePayload.shape,
2599
+ priority: this.draggingEdgePayload.priority
2600
+ }, a = this.params.connectionPreprocessor(n);
2601
+ if (a !== null)
2602
+ this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(a), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
2603
+ else {
2604
+ const h = this.draggingEdgePayload;
2605
+ this.params.onEdgeReattachPrevented({
2606
+ id: h.id,
2607
+ from: h.from,
2608
+ to: h.to,
2609
+ shape: h.shape,
2610
+ priority: h.priority
2611
+ });
2612
+ }
2589
2613
  }
2590
2614
  }
2591
2615
  const ht = () => {
@@ -2694,7 +2718,7 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2694
2718
  });
2695
2719
  }
2696
2720
  }, gt = (r) => {
2697
- var t, s, i, n, h;
2721
+ var t, s, i, n, a;
2698
2722
  const e = ct(
2699
2723
  (t = r.nodes) == null ? void 0 : t.priority,
2700
2724
  (s = r.edges) == null ? void 0 : s.priority
@@ -2708,7 +2732,7 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2708
2732
  direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
2709
2733
  },
2710
2734
  edges: {
2711
- shapeFactory: q(((h = r.edges) == null ? void 0 : h.shape) ?? {}),
2735
+ shapeFactory: q(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
2712
2736
  priorityFn: e.edgesPriorityFn
2713
2737
  }
2714
2738
  };
@@ -2716,11 +2740,11 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2716
2740
  var p, f, v, y, E, x;
2717
2741
  const e = ((p = r == null ? void 0 : r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
2718
2742
  }), t = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), s = ((v = r == null ? void 0 : r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
2719
- }), i = (r == null ? void 0 : r.moveOnTop) !== !1, n = (r == null ? void 0 : r.moveEdgesOnTop) !== !1 && i, h = (y = r == null ? void 0 : r.mouse) == null ? void 0 : y.dragCursor, a = h !== void 0 ? h : "grab", d = (E = r == null ? void 0 : r.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (P) => P.button === 0, l = (x = r == null ? void 0 : r.mouse) == null ? void 0 : x.mouseUpEventVerifier;
2743
+ }), i = (r == null ? void 0 : r.moveOnTop) !== !1, n = (r == null ? void 0 : r.moveEdgesOnTop) !== !1 && i, a = (y = r == null ? void 0 : r.mouse) == null ? void 0 : y.dragCursor, h = a !== void 0 ? a : "grab", d = (E = r == null ? void 0 : r.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (P) => P.button === 0, l = (x = r == null ? void 0 : r.mouse) == null ? void 0 : x.mouseUpEventVerifier;
2720
2744
  return {
2721
2745
  moveOnTop: i,
2722
2746
  moveEdgesOnTop: n,
2723
- dragCursor: a,
2747
+ dragCursor: h,
2724
2748
  mouseDownEventVerifier: c,
2725
2749
  mouseUpEventVerifier: l !== void 0 ? l : (P) => P.button === 0,
2726
2750
  onNodeDrag: e,
@@ -2730,27 +2754,27 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2730
2754
  }, ut = (r) => {
2731
2755
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, i = r.maxY !== null ? r.maxY : 1 / 0;
2732
2756
  return (n) => {
2733
- let h = n.nextTransform.x, a = n.nextTransform.y;
2734
- h < e && h < n.prevTransform.x && (h = Math.min(n.prevTransform.x, e));
2757
+ let a = n.nextTransform.x, h = n.nextTransform.y;
2758
+ a < e && a < n.prevTransform.x && (a = Math.min(n.prevTransform.x, e));
2735
2759
  const d = n.canvasWidth * n.prevTransform.scale, c = t - d;
2736
- h > c && h > n.prevTransform.x && (h = Math.max(n.prevTransform.x, c)), a < s && a < n.prevTransform.y && (a = Math.min(n.prevTransform.y, s));
2760
+ a > c && a > n.prevTransform.x && (a = Math.max(n.prevTransform.x, c)), h < s && h < n.prevTransform.y && (h = Math.min(n.prevTransform.y, s));
2737
2761
  const l = n.canvasHeight * n.prevTransform.scale, g = i - l;
2738
- return a > g && a > n.prevTransform.y && (a = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: h, y: a };
2762
+ return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
2739
2763
  };
2740
2764
  }, pt = (r) => {
2741
2765
  const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
2742
2766
  return (n) => {
2743
- const h = n.prevTransform, a = n.nextTransform;
2744
- let d = a.scale, c = a.x, l = a.y;
2745
- if (a.scale > i && a.scale > h.scale) {
2746
- d = Math.max(h.scale, i), c = h.x, l = h.y;
2747
- const g = (d - h.scale) / (a.scale - h.scale);
2748
- c = h.x + (a.x - h.x) * g, l = h.y + (a.y - h.y) * g;
2767
+ const a = n.prevTransform, h = n.nextTransform;
2768
+ let d = h.scale, c = h.x, l = h.y;
2769
+ if (h.scale > i && h.scale > a.scale) {
2770
+ d = Math.max(a.scale, i), c = a.x, l = a.y;
2771
+ const g = (d - a.scale) / (h.scale - a.scale);
2772
+ c = a.x + (h.x - a.x) * g, l = a.y + (h.y - a.y) * g;
2749
2773
  }
2750
- if (a.scale < s && a.scale < h.scale) {
2751
- d = Math.min(h.scale, s), c = h.x, l = h.y;
2752
- const g = (d - h.scale) / (a.scale - h.scale);
2753
- c = h.x + (a.x - h.x) * g, l = h.y + (a.y - h.y) * g;
2774
+ if (h.scale < s && h.scale < a.scale) {
2775
+ d = Math.min(a.scale, s), c = a.x, l = a.y;
2776
+ const g = (d - a.scale) / (h.scale - a.scale);
2777
+ c = a.x + (h.x - a.x) * g, l = a.y + (h.y - a.y) * g;
2754
2778
  }
2755
2779
  return {
2756
2780
  scale: d,
@@ -2792,8 +2816,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2792
2816
  (M) => ge(M)
2793
2817
  )
2794
2818
  ) : i = ge(s) : i = (M) => M.nextTransform;
2795
- const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab", h = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
2796
- }), a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
2819
+ const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
2820
+ }), h = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
2797
2821
  }), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (M) => M.button === 0, l = (D = r == null ? void 0 : r.shift) == null ? void 0 : D.mouseUpEventVerifier, g = l !== void 0 ? l : (M) => M.button === 0, p = (N = r == null ? void 0 : r.scale) == null ? void 0 : N.mouseWheelEventVerifier, f = p !== void 0 ? p : () => !0;
2798
2822
  return {
2799
2823
  wheelSensitivity: t,
@@ -2801,8 +2825,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2801
2825
  }),
2802
2826
  onTransformFinished: ((ee = r == null ? void 0 : r.events) == null ? void 0 : ee.onTransformFinished) ?? (() => {
2803
2827
  }),
2804
- onBeforeTransformChange: h,
2805
- onTransformChange: a,
2828
+ onBeforeTransformChange: a,
2829
+ onTransformChange: h,
2806
2830
  transformPreprocessor: i,
2807
2831
  shiftCursor: n,
2808
2832
  mouseDownEventVerifier: c,
@@ -2833,8 +2857,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2833
2857
  };
2834
2858
  }, yt = (r, e, t) => {
2835
2859
  var c, l, g;
2836
- const s = () => "direct", i = (p) => p, n = (p) => p.button === 0, h = () => {
2837
- }, a = () => {
2860
+ const s = () => "direct", i = (p) => p, n = (p) => p.button === 0, a = () => {
2861
+ }, h = () => {
2838
2862
  }, d = () => {
2839
2863
  };
2840
2864
  return {
@@ -2842,9 +2866,9 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2842
2866
  connectionPreprocessor: r.connectionPreprocessor ?? i,
2843
2867
  mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
2844
2868
  mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
2845
- onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? h,
2869
+ onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
2846
2870
  onEdgeCreationInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeCreationInterrupted) ?? d,
2847
- onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? a,
2871
+ onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? h,
2848
2872
  dragPortDirection: r.dragPortDirection ?? t,
2849
2873
  edgeShapeFactory: r.edgeShape !== void 0 ? q(r.edgeShape) : e
2850
2874
  };
@@ -2853,8 +2877,8 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2853
2877
  const t = (p) => p, s = (p) => p.button === 0 && p.ctrlKey, i = (p) => p.button === 0, n = (p) => {
2854
2878
  const f = e.getPortAdjacentEdgeIds(p);
2855
2879
  return f.length > 0 ? f[f.length - 1] : null;
2856
- }, h = () => {
2857
2880
  }, a = () => {
2881
+ }, h = () => {
2858
2882
  }, d = () => {
2859
2883
  };
2860
2884
  return {
@@ -2863,9 +2887,9 @@ const X = (r) => () => r, ce = X(0), dt = () => {
2863
2887
  mouseUpEventVerifier: r.mouseUpEventVerifier ?? i,
2864
2888
  draggingEdgeResolver: r.draggingEdgeResolver ?? n,
2865
2889
  draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? q(r.draggingEdgeShape) : null,
2866
- onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? h,
2890
+ onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
2867
2891
  onEdgeReattachInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeReattachInterrupted) ?? d,
2868
- onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? a
2892
+ onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
2869
2893
  };
2870
2894
  };
2871
2895
  class St {
@@ -2964,30 +2988,30 @@ class St {
2964
2988
  i.main
2965
2989
  );
2966
2990
  e !== void 0 && (n = new Ue(n, t, e));
2967
- const h = gt(this.canvasDefaults), a = new we(
2991
+ const a = gt(this.canvasDefaults), h = new we(
2968
2992
  this.element,
2969
2993
  t,
2970
2994
  s,
2971
2995
  n,
2972
- h
2996
+ a
2973
2997
  );
2974
2998
  if (this.hasBackground && J.configure(
2975
- a,
2999
+ h,
2976
3000
  mt(this.backgroundConfig),
2977
3001
  i.background
2978
- ), this.hasResizeReactiveNodes && Y.configure(a), this.hasDraggableNode && K.configure(
2979
- a,
3002
+ ), this.hasResizeReactiveNodes && Y.configure(h), this.hasDraggableNode && K.configure(
3003
+ h,
2980
3004
  i.main,
2981
3005
  this.window,
2982
3006
  lt(this.dragConfig)
2983
3007
  ), this.hasUserConnectablePorts) {
2984
3008
  const c = yt(
2985
3009
  this.connectablePortsConfig,
2986
- h.edges.shapeFactory,
2987
- h.ports.direction
3010
+ a.edges.shapeFactory,
3011
+ a.ports.direction
2988
3012
  );
2989
3013
  Q.configure(
2990
- a,
3014
+ h,
2991
3015
  i.overlayConnectablePorts,
2992
3016
  s,
2993
3017
  this.window,
@@ -2997,10 +3021,10 @@ class St {
2997
3021
  if (this.hasUserDraggableEdges) {
2998
3022
  const c = Et(
2999
3023
  this.draggableEdgesConfig,
3000
- a.graph
3024
+ h.graph
3001
3025
  );
3002
3026
  _.configure(
3003
- a,
3027
+ h,
3004
3028
  i.overlayDraggableEdges,
3005
3029
  s,
3006
3030
  this.window,
@@ -3008,22 +3032,22 @@ class St {
3008
3032
  );
3009
3033
  }
3010
3034
  this.virtualScrollConfig !== void 0 ? Z.configure(
3011
- a,
3035
+ h,
3012
3036
  i.main,
3013
3037
  this.window,
3014
3038
  le(this.transformConfig),
3015
3039
  e,
3016
3040
  this.virtualScrollConfig
3017
3041
  ) : this.hasTransformableViewport && $.configure(
3018
- a,
3042
+ h,
3019
3043
  i.main,
3020
3044
  this.window,
3021
3045
  le(this.transformConfig)
3022
3046
  ), this.reset();
3023
3047
  const d = () => {
3024
- i.destroy(), a.onBeforeDestroy.unsubscribe(d);
3048
+ i.destroy(), h.onBeforeDestroy.unsubscribe(d);
3025
3049
  };
3026
- return a.onBeforeDestroy.subscribe(d), a;
3050
+ return h.onBeforeDestroy.subscribe(d), h;
3027
3051
  }
3028
3052
  /**
3029
3053
  * @deprecated