@html-graph/html-graph 0.1.1 → 0.1.3

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.
package/dist/main.js CHANGED
@@ -1,37 +1,37 @@
1
- var U = Object.defineProperty;
2
- var K = (e, t, o) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
- var s = (e, t, o) => K(e, typeof t != "symbol" ? t + "" : t, o);
1
+ var O = Object.defineProperty;
2
+ var K = (e, t, o) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var n = (e, t, o) => K(e, typeof t != "symbol" ? t + "" : t, o);
4
4
  const _ = (e, t) => ({
5
5
  x: e / 2,
6
6
  y: t / 2
7
7
  }), f = (e, t, o) => ({
8
8
  x: t.x * e.x - t.y * e.y + ((1 - t.x) * o.x + t.y * o.y),
9
9
  y: t.y * e.x + t.x * e.y + ((1 - t.x) * o.y - t.y * o.x)
10
- }), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), u = {
10
+ }), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), w = {
11
11
  x: 0,
12
12
  y: 0
13
13
  }, E = (e, t, o, r) => {
14
- const n = [
15
- u,
14
+ const s = [
15
+ w,
16
16
  { x: o, y: r },
17
17
  { x: o, y: -r }
18
- ].map((l) => f(l, e, u)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), d = `M ${n[0].x} ${n[0].y}`, c = `L ${n[1].x} ${n[1].y}`, h = `L ${n[2].x} ${n[2].y}`;
19
- return `${d} ${c} ${h}`;
20
- }, N = (e, t) => {
18
+ ].map((l) => f(l, e, w)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), h = `M ${s[0].x} ${s[0].y}`, d = `L ${s[1].x} ${s[1].y}`, c = `L ${s[2].x} ${s[2].y}`;
19
+ return `${h} ${d} ${c}`;
20
+ }, C = (e, t) => {
21
21
  const o = [];
22
22
  if (e.length > 0 && o.push(`M ${e[0].x} ${e[0].y}`), e.length === 2 && o.push(`L ${e[1].x} ${e[1].y}`), e.length > 2) {
23
23
  const r = e.length - 1;
24
- let i = 0, n = 0, d = 0;
25
- e.forEach((c, h) => {
26
- let l = 0, a = 0, w = 0;
27
- const y = h > 0, x = h < r, v = y && x;
28
- if (y && (l = -i, a = -n, w = d), x) {
29
- const z = e[h + 1];
30
- i = z.x - c.x, n = z.y - c.y, d = Math.sqrt(i * i + n * n);
24
+ let i = 0, s = 0, h = 0;
25
+ e.forEach((d, c) => {
26
+ let l = 0, a = 0, g = 0;
27
+ const y = c > 0, x = c < r, v = y && x;
28
+ if (y && (l = -i, a = -s, g = h), x) {
29
+ const z = e[c + 1];
30
+ i = z.x - d.x, s = z.y - d.y, h = Math.sqrt(i * i + s * s);
31
31
  }
32
- const M = d !== 0 ? Math.min((v ? t : 0) / d, h < r - 1 ? 0.5 : 1) : 0, X = v ? { x: c.x + i * M, y: c.y + n * M } : c, k = w !== 0 ? Math.min((v ? t : 0) / w, h > 1 ? 0.5 : 1) : 0, B = v ? { x: c.x + l * k, y: c.y + a * k } : c;
33
- h > 0 && o.push(`L ${B.x} ${B.y}`), v && o.push(
34
- `C ${c.x} ${c.y} ${c.x} ${c.y} ${X.x} ${X.y}`
32
+ const M = h !== 0 ? Math.min((v ? t : 0) / h, c < r - 1 ? 0.5 : 1) : 0, X = v ? { x: d.x + i * M, y: d.y + s * M } : d, k = g !== 0 ? Math.min((v ? t : 0) / g, c > 1 ? 0.5 : 1) : 0, B = v ? { x: d.x + l * k, y: d.y + a * k } : d;
33
+ c > 0 && o.push(`L ${B.x} ${B.y}`), v && o.push(
34
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${X.x} ${X.y}`
35
35
  );
36
36
  });
37
37
  }
@@ -48,27 +48,27 @@ const _ = (e, t) => ({
48
48
  }, T = (e) => {
49
49
  const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
50
50
  return t.setAttribute("fill", e), t;
51
- }, p = (e, t) => {
51
+ }, b = (e, t) => {
52
52
  const o = {
53
53
  x: e.x + e.width / 2,
54
54
  y: e.y + e.height / 2
55
55
  }, r = {
56
56
  x: t.x + t.width / 2,
57
57
  y: t.y + t.height / 2
58
- }, i = Math.min(o.x, r.x), n = Math.min(o.y, r.y), d = Math.abs(r.x - o.x), c = Math.abs(r.y - o.y), h = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
58
+ }, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
59
59
  return {
60
60
  x: i,
61
- y: n,
62
- width: d,
63
- height: c,
64
- flipX: h,
61
+ y: s,
62
+ width: h,
63
+ height: d,
64
+ flipX: c,
65
65
  flipY: l
66
66
  };
67
67
  }, J = (e) => {
68
68
  const t = f(
69
- { x: e.arrowLength, y: u.y },
69
+ { x: e.arrowLength, y: w.y },
70
70
  e.fromVect,
71
- u
71
+ w
72
72
  ), o = f(
73
73
  { x: e.to.x - e.arrowLength, y: e.to.y },
74
74
  e.toVect,
@@ -79,157 +79,157 @@ const _ = (e, t) => ({
79
79
  }, i = {
80
80
  x: o.x - e.toVect.x * e.curvature,
81
81
  y: o.y - e.toVect.y * e.curvature
82
- }, n = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, d = e.hasSourceArrow ? "" : `M ${u.x} ${u.y} L ${t.x} ${t.y} `, c = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
83
- return `${d}${n}${c}`;
82
+ }, s = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, h = e.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${t.x} ${t.y} `, d = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
83
+ return `${h}${s}${d}`;
84
84
  }, Q = (e) => {
85
85
  const t = e.hasSourceArrow ? f(
86
- { x: e.arrowLength, y: u.y },
86
+ { x: e.arrowLength, y: w.y },
87
87
  e.fromVect,
88
- u
89
- ) : u, o = e.hasTargetArrow ? f(
88
+ w
89
+ ) : w, o = e.hasTargetArrow ? f(
90
90
  { x: e.to.x - e.arrowLength, y: e.to.y },
91
91
  e.toVect,
92
92
  e.to
93
- ) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, n = Math.sin(e.detourDirection) * e.detourDistance, d = i * e.flipX, c = n * e.flipY, h = f(
94
- { x: r, y: u.y },
93
+ ) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, d = s * e.flipY, c = f(
94
+ { x: r, y: w.y },
95
95
  e.fromVect,
96
- u
96
+ w
97
97
  ), l = {
98
- x: h.x + d,
99
- y: h.y + c
98
+ x: c.x + h,
99
+ y: c.y + d
100
100
  }, a = f(
101
101
  { x: e.to.x - r, y: e.to.y },
102
102
  e.toVect,
103
103
  e.to
104
- ), w = {
105
- x: a.x + d,
106
- y: a.y + c
107
- }, y = { x: (l.x + w.x) / 2, y: (l.y + w.y) / 2 }, x = {
108
- x: h.x + e.curvature * e.fromVect.x,
109
- y: h.y + e.curvature * e.fromVect.y
104
+ ), g = {
105
+ x: a.x + h,
106
+ y: a.y + d
107
+ }, y = { x: (l.x + g.x) / 2, y: (l.y + g.y) / 2 }, x = {
108
+ x: c.x + e.curvature * e.fromVect.x,
109
+ y: c.y + e.curvature * e.fromVect.y
110
110
  }, v = {
111
111
  x: a.x - e.curvature * e.toVect.x,
112
112
  y: a.y - e.curvature * e.toVect.y
113
- }, b = {
114
- x: h.x + d,
115
- y: h.y + c
113
+ }, p = {
114
+ x: c.x + h,
115
+ y: c.y + d
116
116
  }, M = {
117
- x: a.x + d,
118
- y: a.y + c
117
+ x: a.x + h,
118
+ y: a.y + d
119
119
  };
120
120
  return [
121
121
  `M ${t.x} ${t.y}`,
122
- `L ${h.x} ${h.y}`,
123
- `C ${x.x} ${x.y} ${b.x} ${b.y} ${y.x} ${y.y}`,
122
+ `L ${c.x} ${c.y}`,
123
+ `C ${x.x} ${x.y} ${p.x} ${p.y} ${y.x} ${y.y}`,
124
124
  `C ${M.x} ${M.y} ${v.x} ${v.y} ${a.x} ${a.y}`,
125
125
  `L ${o.x} ${o.y}`
126
126
  ].join(" ");
127
127
  }, Z = (e) => {
128
128
  const t = e.hasSourceArrow ? f(
129
- { x: e.arrowLength, y: u.y },
129
+ { x: e.arrowLength, y: w.y },
130
130
  e.fromVect,
131
- u
132
- ) : u, o = e.hasTargetArrow ? f(
131
+ w
132
+ ) : w, o = e.hasTargetArrow ? f(
133
133
  { x: e.to.x - e.arrowLength, y: e.to.y },
134
134
  e.toVect,
135
135
  e.to
136
- ) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, n = f({ x: i, y: u.y }, e.fromVect, u), d = f(
136
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = f({ x: i, y: w.y }, e.fromVect, w), h = f(
137
137
  { x: e.to.x - i, y: e.to.y },
138
138
  e.toVect,
139
139
  e.to
140
- ), c = Math.max((n.x + d.x) / 2, r), h = e.to.y / 2, l = { x: e.flipX > 0 ? c : -r, y: n.y }, a = { x: l.x, y: h }, w = {
141
- x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
142
- y: d.y
143
- }, y = { x: w.x, y: h };
144
- return N(
145
- [t, n, l, a, y, w, d, o],
140
+ ), d = Math.max((s.x + h.x) / 2, r), c = e.to.y / 2, l = { x: e.flipX > 0 ? d : -r, y: s.y }, a = { x: l.x, y: c }, g = {
141
+ x: e.flipX > 0 ? e.to.x - d : e.to.x + r,
142
+ y: h.y
143
+ }, y = { x: g.x, y: c };
144
+ return C(
145
+ [t, s, l, a, y, g, h, o],
146
146
  e.roundness
147
147
  );
148
148
  }, R = (e) => {
149
149
  const t = e.hasSourceArrow ? f(
150
- { x: e.arrowLength, y: u.y },
150
+ { x: e.arrowLength, y: w.y },
151
151
  e.fromVect,
152
- u
153
- ) : u, o = e.hasTargetArrow ? f(
152
+ w
153
+ ) : w, o = e.hasTargetArrow ? f(
154
154
  { x: e.to.x - e.arrowLength, y: e.to.y },
155
155
  e.toVect,
156
156
  e.to
157
157
  ) : e.to, r = e.arrowLength + e.arrowOffset, i = f(
158
- { x: r, y: u.y },
158
+ { x: r, y: w.y },
159
159
  e.fromVect,
160
- u
161
- ), n = Math.cos(e.detourDirection) * e.detourDistance, d = Math.sin(e.detourDirection) * e.detourDistance, c = n * e.flipX, h = d * e.flipY, l = { x: i.x + c, y: i.y + h }, a = f(
160
+ w
161
+ ), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, d = s * e.flipX, c = h * e.flipY, l = { x: i.x + d, y: i.y + c }, a = f(
162
162
  { x: e.to.x - r, y: e.to.y },
163
163
  e.toVect,
164
164
  e.to
165
- ), w = { x: a.x + c, y: a.y + h };
166
- return N(
167
- [t, i, l, w, a, o],
165
+ ), g = { x: a.x + d, y: a.y + c };
166
+ return C(
167
+ [t, i, l, g, a, o],
168
168
  e.roundness
169
169
  );
170
170
  }, q = (e) => {
171
171
  const t = e.hasSourceArrow ? f(
172
- { x: e.arrowLength, y: u.y },
172
+ { x: e.arrowLength, y: w.y },
173
173
  e.fromVect,
174
- u
175
- ) : u, o = e.hasTargetArrow ? f(
174
+ w
175
+ ) : w, o = e.hasTargetArrow ? f(
176
176
  { x: e.to.x - e.arrowLength, y: e.to.y },
177
177
  e.toVect,
178
178
  e.to
179
- ) : e.to, r = e.arrowLength + e.arrowOffset, i = f({ x: r, y: u.y }, e.fromVect, u), n = f(
179
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = f({ x: r, y: w.y }, e.fromVect, w), s = f(
180
180
  { x: e.to.x - r, y: e.to.y },
181
181
  e.toVect,
182
182
  e.to
183
183
  );
184
- return N([t, i, n, o], e.roundness);
184
+ return C([t, i, s, o], e.roundness);
185
185
  }, tt = (e) => {
186
186
  const t = e.hasSourceArrow ? f(
187
- { x: e.arrowLength, y: u.y },
187
+ { x: e.arrowLength, y: w.y },
188
188
  e.fromVect,
189
- u
190
- ) : u, o = e.hasTargetArrow ? f(
189
+ w
190
+ ) : w, o = e.hasTargetArrow ? f(
191
191
  { x: e.to.x - e.arrowLength, y: e.to.y },
192
192
  e.toVect,
193
193
  e.to
194
- ) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, n = f({ x: i, y: u.y }, e.fromVect, u), d = f(
194
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = f({ x: i, y: w.y }, e.fromVect, w), h = f(
195
195
  { x: e.to.x - i, y: e.to.y },
196
196
  e.toVect,
197
197
  e.to
198
- ), c = Math.max((n.y + d.y) / 2, r), h = e.to.x / 2, l = { x: n.x, y: e.flipY > 0 ? c : -r }, a = { x: h, y: l.y }, w = {
199
- x: d.x,
200
- y: e.flipY > 0 ? e.to.y - c : e.to.y + r
201
- }, y = { x: h, y: w.y };
202
- return N(
203
- [t, n, l, a, y, w, d, o],
198
+ ), d = Math.max((s.y + h.y) / 2, r), c = e.to.x / 2, l = { x: s.x, y: e.flipY > 0 ? d : -r }, a = { x: c, y: l.y }, g = {
199
+ x: h.x,
200
+ y: e.flipY > 0 ? e.to.y - d : e.to.y + r
201
+ }, y = { x: c, y: g.y };
202
+ return C(
203
+ [t, s, l, a, y, g, h, o],
204
204
  e.roundness
205
205
  );
206
206
  }, Y = (e) => {
207
- const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, d = [
208
- { x: e.arrowLength, y: u.y },
209
- { x: r, y: u.y },
207
+ const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, h = [
208
+ { x: e.arrowLength, y: w.y },
209
+ { x: r, y: w.y },
210
210
  { x: r, y: e.side },
211
211
  { x: i, y: e.side },
212
212
  { x: i, y: -e.side },
213
213
  { x: r, y: -e.side },
214
- { x: r, y: u.y },
215
- { x: e.arrowLength, y: u.y }
214
+ { x: r, y: w.y },
215
+ { x: e.arrowLength, y: w.y }
216
216
  ].map(
217
- (h) => f(h, e.fromVect, u)
218
- ), c = `M ${u.x} ${u.y} L ${d[0].x} ${d[0].y} `;
219
- return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${N(d, e.roundness)}`;
217
+ (c) => f(c, e.fromVect, w)
218
+ ), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
219
+ return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${C(h, e.roundness)}`;
220
220
  }, et = (e) => {
221
- const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, n = e.arrowLength + r * (1 - o / i), d = t * o / i, h = [
222
- { x: e.arrowLength, y: u.y },
223
- { x: n, y: d },
224
- { x: n, y: -d }
225
- ].map((w) => f(w, e.fromVect, u)), l = [
226
- `M ${h[0].x} ${h[0].y}`,
227
- `A ${t} ${t} 0 0 1 ${h[1].x} ${h[1].y}`,
228
- `A ${o} ${o} 0 1 0 ${h[2].x} ${h[2].y}`,
229
- `A ${t} ${t} 0 0 1 ${h[0].x} ${h[0].y}`
230
- ].join(" "), a = `M 0 0 L ${h[0].x} ${h[0].y} `;
221
+ const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, s = e.arrowLength + r * (1 - o / i), h = t * o / i, c = [
222
+ { x: e.arrowLength, y: w.y },
223
+ { x: s, y: h },
224
+ { x: s, y: -h }
225
+ ].map((g) => f(g, e.fromVect, w)), l = [
226
+ `M ${c[0].x} ${c[0].y}`,
227
+ `A ${t} ${t} 0 0 1 ${c[1].x} ${c[1].y}`,
228
+ `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
229
+ `A ${t} ${t} 0 0 1 ${c[0].x} ${c[0].y}`
230
+ ].join(" "), a = `M 0 0 L ${c[0].x} ${c[0].y} `;
231
231
  return `${e.hasSourceArrow || e.hasTargetArrow ? "" : a}${l}`;
232
- }, g = Object.freeze({
232
+ }, u = Object.freeze({
233
233
  color: "#5c5c5c",
234
234
  width: 1,
235
235
  arrowLength: 15,
@@ -242,79 +242,80 @@ const _ = (e, t) => ({
242
242
  roundness: 10,
243
243
  detourDistance: 100,
244
244
  detourDirection: -Math.PI / 2,
245
+ detourDirectionVertical: 0,
245
246
  smallCycleRadius: 15,
246
247
  curvature: 90
247
248
  });
248
249
  class ot {
249
250
  constructor(t) {
250
- s(this, "svg", I());
251
- s(this, "group", $());
252
- s(this, "line");
253
- s(this, "sourceArrow", null);
254
- s(this, "targetArrow", null);
255
- s(this, "arrowLength");
256
- s(this, "arrowWidth");
257
- s(this, "curvature");
258
- s(this, "portCycleRadius");
259
- s(this, "portCycleSmallRadius");
260
- s(this, "detourDirection");
261
- s(this, "detourDistance");
262
- s(this, "hasSourceArrow");
263
- s(this, "hasTargetArrow");
264
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? g.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? g.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? g.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
265
- const o = (t == null ? void 0 : t.color) ?? g.color, r = (t == null ? void 0 : t.width) ?? g.width;
251
+ n(this, "svg", I());
252
+ n(this, "group", $());
253
+ n(this, "line");
254
+ n(this, "sourceArrow", null);
255
+ n(this, "targetArrow", null);
256
+ n(this, "arrowLength");
257
+ n(this, "arrowWidth");
258
+ n(this, "curvature");
259
+ n(this, "portCycleRadius");
260
+ n(this, "portCycleSmallRadius");
261
+ n(this, "detourDirection");
262
+ n(this, "detourDistance");
263
+ n(this, "hasSourceArrow");
264
+ n(this, "hasTargetArrow");
265
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? u.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
266
+ const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
266
267
  this.svg.appendChild(this.group), this.line = m(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(o), this.group.appendChild(this.targetArrow));
267
268
  }
268
269
  render(t) {
269
- const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
270
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
270
271
  t.source,
271
272
  t.target
272
273
  );
273
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
274
- const h = A(
274
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
275
+ const c = A(
275
276
  t.source.direction,
276
- d,
277
- c
277
+ h,
278
+ d
278
279
  ), l = A(
279
280
  t.target.direction,
280
- d,
281
- c
281
+ h,
282
+ d
282
283
  ), a = {
283
284
  x: i,
284
- y: n
285
+ y: s
285
286
  };
286
- let w, y = l, x = -this.arrowLength;
287
- if (t.source.portId === t.target.portId ? (w = et({
288
- fromVect: h,
287
+ let g, y = l, x = -this.arrowLength;
288
+ if (t.source.portId === t.target.portId ? (g = et({
289
+ fromVect: c,
289
290
  radius: this.portCycleRadius,
290
291
  smallRadius: this.portCycleSmallRadius,
291
292
  arrowLength: this.arrowLength,
292
293
  hasSourceArrow: this.hasSourceArrow,
293
294
  hasTargetArrow: this.hasTargetArrow
294
- }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = Q({
295
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Q({
295
296
  to: a,
296
- fromVect: h,
297
+ fromVect: c,
297
298
  toVect: l,
298
- flipX: d,
299
- flipY: c,
299
+ flipX: h,
300
+ flipY: d,
300
301
  arrowLength: this.arrowLength,
301
302
  detourDirection: this.detourDirection,
302
303
  detourDistance: this.detourDistance,
303
304
  curvature: this.curvature,
304
305
  hasSourceArrow: this.hasSourceArrow,
305
306
  hasTargetArrow: this.hasTargetArrow
306
- }) : w = J({
307
+ }) : g = J({
307
308
  to: a,
308
- fromVect: h,
309
+ fromVect: c,
309
310
  toVect: l,
310
311
  arrowLength: this.arrowLength,
311
312
  curvature: this.curvature,
312
313
  hasSourceArrow: this.hasSourceArrow,
313
314
  hasTargetArrow: this.hasTargetArrow
314
- }), this.line.setAttribute("d", w), this.sourceArrow) {
315
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
315
316
  const v = E(
316
- h,
317
- u,
317
+ c,
318
+ w,
318
319
  this.arrowLength,
319
320
  this.arrowWidth
320
321
  );
@@ -333,63 +334,63 @@ class ot {
333
334
  }
334
335
  class rt {
335
336
  constructor(t) {
336
- s(this, "svg", I());
337
- s(this, "group", $());
338
- s(this, "line");
339
- s(this, "sourceArrow", null);
340
- s(this, "targetArrow", null);
341
- s(this, "arrowLength");
342
- s(this, "arrowWidth");
343
- s(this, "arrowOffset");
344
- s(this, "roundness");
345
- s(this, "cycleSquareSide");
346
- s(this, "detourDirection");
347
- s(this, "detourDistance");
348
- s(this, "hasSourceArrow");
349
- s(this, "hasTargetArrow");
350
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? g.cycleSquareSide;
351
- const o = (t == null ? void 0 : t.roundness) ?? g.roundness;
337
+ n(this, "svg", I());
338
+ n(this, "group", $());
339
+ n(this, "line");
340
+ n(this, "sourceArrow", null);
341
+ n(this, "targetArrow", null);
342
+ n(this, "arrowLength");
343
+ n(this, "arrowWidth");
344
+ n(this, "arrowOffset");
345
+ n(this, "roundness");
346
+ n(this, "cycleSquareSide");
347
+ n(this, "detourDirection");
348
+ n(this, "detourDistance");
349
+ n(this, "hasSourceArrow");
350
+ n(this, "hasTargetArrow");
351
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
352
+ const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
352
353
  this.roundness = Math.min(
353
354
  o,
354
355
  this.arrowOffset,
355
356
  this.cycleSquareSide / 2
356
- ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
357
- const r = (t == null ? void 0 : t.color) ?? g.color, i = (t == null ? void 0 : t.width) ?? g.width;
357
+ ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
358
+ const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
358
359
  this.svg.appendChild(this.group), this.line = m(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(r), this.group.appendChild(this.targetArrow));
359
360
  }
360
361
  render(t) {
361
- const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
362
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
362
363
  t.source,
363
364
  t.target
364
365
  );
365
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
366
- const h = A(
366
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
367
+ const c = A(
367
368
  t.source.direction,
368
- d,
369
- c
369
+ h,
370
+ d
370
371
  ), l = A(
371
372
  t.target.direction,
372
- d,
373
- c
373
+ h,
374
+ d
374
375
  ), a = {
375
376
  x: i,
376
- y: n
377
+ y: s
377
378
  };
378
- let w, y = l, x = -this.arrowLength;
379
- if (t.source.portId === t.target.portId ? (w = Y({
380
- fromVect: h,
379
+ let g, y = l, x = -this.arrowLength;
380
+ if (t.source.portId === t.target.portId ? (g = Y({
381
+ fromVect: c,
381
382
  arrowLength: this.arrowLength,
382
383
  side: this.cycleSquareSide,
383
384
  arrowOffset: this.arrowOffset,
384
385
  roundness: this.roundness,
385
386
  hasSourceArrow: this.hasSourceArrow,
386
387
  hasTargetArrow: this.hasTargetArrow
387
- }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = R({
388
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
388
389
  to: a,
389
- fromVect: h,
390
+ fromVect: c,
390
391
  toVect: l,
391
- flipX: d,
392
- flipY: c,
392
+ flipX: h,
393
+ flipY: d,
393
394
  arrowLength: this.arrowLength,
394
395
  arrowOffset: this.arrowOffset,
395
396
  roundness: this.roundness,
@@ -397,20 +398,20 @@ class rt {
397
398
  detourDistance: this.detourDistance,
398
399
  hasSourceArrow: this.hasSourceArrow,
399
400
  hasTargetArrow: this.hasTargetArrow
400
- }) : w = Z({
401
+ }) : g = Z({
401
402
  to: a,
402
- fromVect: h,
403
+ fromVect: c,
403
404
  toVect: l,
404
- flipX: d,
405
+ flipX: h,
405
406
  arrowLength: this.arrowLength,
406
407
  arrowOffset: this.arrowOffset,
407
408
  roundness: this.roundness,
408
409
  hasSourceArrow: this.hasSourceArrow,
409
410
  hasTargetArrow: this.hasTargetArrow
410
- }), this.line.setAttribute("d", w), this.sourceArrow) {
411
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
411
412
  const v = E(
412
- h,
413
- u,
413
+ c,
414
+ w,
414
415
  this.arrowLength,
415
416
  this.arrowWidth
416
417
  );
@@ -429,63 +430,63 @@ class rt {
429
430
  }
430
431
  class it {
431
432
  constructor(t) {
432
- s(this, "svg", I());
433
- s(this, "group", $());
434
- s(this, "line");
435
- s(this, "sourceArrow", null);
436
- s(this, "targetArrow", null);
437
- s(this, "arrowLength");
438
- s(this, "arrowWidth");
439
- s(this, "arrowOffset");
440
- s(this, "roundness");
441
- s(this, "cycleSquareSide");
442
- s(this, "detourDirection");
443
- s(this, "detourDistance");
444
- s(this, "hasSourceArrow");
445
- s(this, "hasTargetArrow");
446
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? g.cycleSquareSide;
447
- const o = (t == null ? void 0 : t.roundness) ?? g.roundness;
433
+ n(this, "svg", I());
434
+ n(this, "group", $());
435
+ n(this, "line");
436
+ n(this, "sourceArrow", null);
437
+ n(this, "targetArrow", null);
438
+ n(this, "arrowLength");
439
+ n(this, "arrowWidth");
440
+ n(this, "arrowOffset");
441
+ n(this, "roundness");
442
+ n(this, "cycleSquareSide");
443
+ n(this, "detourDirection");
444
+ n(this, "detourDistance");
445
+ n(this, "hasSourceArrow");
446
+ n(this, "hasTargetArrow");
447
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
448
+ const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
448
449
  this.roundness = Math.min(
449
450
  o,
450
451
  this.arrowOffset,
451
452
  this.cycleSquareSide / 2
452
- ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
453
- const r = (t == null ? void 0 : t.color) ?? g.color, i = (t == null ? void 0 : t.width) ?? g.width;
453
+ ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
454
+ const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
454
455
  this.svg.appendChild(this.group), this.line = m(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(r), this.group.appendChild(this.targetArrow));
455
456
  }
456
457
  render(t) {
457
- const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
458
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
458
459
  t.source,
459
460
  t.target
460
461
  );
461
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
462
- const h = A(
462
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
463
+ const c = A(
463
464
  t.source.direction,
464
- d,
465
- c
465
+ h,
466
+ d
466
467
  ), l = A(
467
468
  t.target.direction,
468
- d,
469
- c
469
+ h,
470
+ d
470
471
  ), a = {
471
472
  x: i,
472
- y: n
473
+ y: s
473
474
  };
474
- let w, y = l, x = -this.arrowLength;
475
- if (t.source.portId === t.target.portId ? (w = Y({
476
- fromVect: h,
475
+ let g, y = l, x = -this.arrowLength;
476
+ if (t.source.portId === t.target.portId ? (g = Y({
477
+ fromVect: c,
477
478
  arrowLength: this.arrowLength,
478
479
  side: this.cycleSquareSide,
479
480
  arrowOffset: this.arrowOffset,
480
481
  roundness: this.roundness,
481
482
  hasSourceArrow: this.hasSourceArrow,
482
483
  hasTargetArrow: this.hasTargetArrow
483
- }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = R({
484
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
484
485
  to: a,
485
- fromVect: h,
486
+ fromVect: c,
486
487
  toVect: l,
487
- flipX: d,
488
- flipY: c,
488
+ flipX: h,
489
+ flipY: d,
489
490
  arrowLength: this.arrowLength,
490
491
  arrowOffset: this.arrowOffset,
491
492
  roundness: this.roundness,
@@ -493,19 +494,19 @@ class it {
493
494
  detourDistance: this.detourDistance,
494
495
  hasSourceArrow: this.hasSourceArrow,
495
496
  hasTargetArrow: this.hasTargetArrow
496
- }) : w = q({
497
+ }) : g = q({
497
498
  to: a,
498
- fromVect: h,
499
+ fromVect: c,
499
500
  toVect: l,
500
501
  arrowLength: this.arrowLength,
501
502
  arrowOffset: this.arrowOffset,
502
503
  roundness: this.roundness,
503
504
  hasSourceArrow: this.hasSourceArrow,
504
505
  hasTargetArrow: this.hasTargetArrow
505
- }), this.line.setAttribute("d", w), this.sourceArrow) {
506
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
506
507
  const v = E(
507
- h,
508
- u,
508
+ c,
509
+ w,
509
510
  this.arrowLength,
510
511
  this.arrowWidth
511
512
  );
@@ -524,63 +525,63 @@ class it {
524
525
  }
525
526
  class nt {
526
527
  constructor(t) {
527
- s(this, "svg", I());
528
- s(this, "group", $());
529
- s(this, "line");
530
- s(this, "sourceArrow", null);
531
- s(this, "targetArrow", null);
532
- s(this, "arrowLength");
533
- s(this, "arrowWidth");
534
- s(this, "arrowOffset");
535
- s(this, "roundness");
536
- s(this, "cycleSquareSide");
537
- s(this, "detourDirection");
538
- s(this, "detourDistance");
539
- s(this, "hasSourceArrow");
540
- s(this, "hasTargetArrow");
541
- this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? g.cycleSquareSide;
542
- const o = (t == null ? void 0 : t.roundness) ?? g.roundness;
528
+ n(this, "svg", I());
529
+ n(this, "group", $());
530
+ n(this, "line");
531
+ n(this, "sourceArrow", null);
532
+ n(this, "targetArrow", null);
533
+ n(this, "arrowLength");
534
+ n(this, "arrowWidth");
535
+ n(this, "arrowOffset");
536
+ n(this, "roundness");
537
+ n(this, "cycleSquareSide");
538
+ n(this, "detourDirection");
539
+ n(this, "detourDistance");
540
+ n(this, "hasSourceArrow");
541
+ n(this, "hasTargetArrow");
542
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? u.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? u.cycleSquareSide;
543
+ const o = (t == null ? void 0 : t.roundness) ?? u.roundness;
543
544
  this.roundness = Math.min(
544
545
  o,
545
546
  this.arrowOffset,
546
547
  this.cycleSquareSide / 2
547
- ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
548
- const r = (t == null ? void 0 : t.color) ?? g.color, i = (t == null ? void 0 : t.width) ?? g.width;
548
+ ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? u.hasTargetArrow;
549
+ const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
549
550
  this.svg.appendChild(this.group), this.line = m(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = T(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = T(r), this.group.appendChild(this.targetArrow));
550
551
  }
551
552
  render(t) {
552
- const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
553
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
553
554
  t.source,
554
555
  t.target
555
556
  );
556
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
557
- const h = A(
557
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${s}px`, this.group.style.transform = `scale(${h}, ${d})`;
558
+ const c = A(
558
559
  t.source.direction,
559
- d,
560
- c
560
+ h,
561
+ d
561
562
  ), l = A(
562
563
  t.target.direction,
563
- d,
564
- c
564
+ h,
565
+ d
565
566
  ), a = {
566
567
  x: i,
567
- y: n
568
+ y: s
568
569
  };
569
- let w, y = l, x = -this.arrowLength;
570
- if (t.source.portId === t.target.portId ? (w = Y({
571
- fromVect: h,
570
+ let g, y = l, x = -this.arrowLength;
571
+ if (t.source.portId === t.target.portId ? (g = Y({
572
+ fromVect: c,
572
573
  arrowLength: this.arrowLength,
573
574
  side: this.cycleSquareSide,
574
575
  arrowOffset: this.arrowOffset,
575
576
  roundness: this.roundness,
576
577
  hasSourceArrow: this.hasSourceArrow,
577
578
  hasTargetArrow: this.hasTargetArrow
578
- }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = R({
579
+ }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
579
580
  to: a,
580
- fromVect: h,
581
+ fromVect: c,
581
582
  toVect: l,
582
- flipX: d,
583
- flipY: c,
583
+ flipX: h,
584
+ flipY: d,
584
585
  arrowLength: this.arrowLength,
585
586
  arrowOffset: this.arrowOffset,
586
587
  roundness: this.roundness,
@@ -588,20 +589,20 @@ class nt {
588
589
  detourDistance: this.detourDistance,
589
590
  hasSourceArrow: this.hasSourceArrow,
590
591
  hasTargetArrow: this.hasTargetArrow
591
- }) : w = tt({
592
+ }) : g = tt({
592
593
  to: a,
593
- fromVect: h,
594
+ fromVect: c,
594
595
  toVect: l,
595
- flipY: c,
596
+ flipY: d,
596
597
  arrowLength: this.arrowLength,
597
598
  arrowOffset: this.arrowOffset,
598
599
  roundness: this.roundness,
599
600
  hasSourceArrow: this.hasSourceArrow,
600
601
  hasTargetArrow: this.hasTargetArrow
601
- }), this.line.setAttribute("d", w), this.sourceArrow) {
602
+ }), this.line.setAttribute("d", g), this.sourceArrow) {
602
603
  const v = E(
603
- h,
604
- u,
604
+ c,
605
+ w,
605
606
  this.arrowLength,
606
607
  this.arrowWidth
607
608
  );
@@ -690,8 +691,8 @@ const st = (e) => {
690
691
  nodesPriorityFn: o,
691
692
  edgesPriorityFn: r
692
693
  };
693
- }, ct = (e) => {
694
- var o, r, i, n, d;
694
+ }, dt = (e) => {
695
+ var o, r, i, s, h;
695
696
  const t = ht(
696
697
  (o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
697
698
  (r = e == null ? void 0 : e.edges) == null ? void 0 : r.priority
@@ -702,24 +703,24 @@ const st = (e) => {
702
703
  priorityFn: t.nodesPriorityFn
703
704
  },
704
705
  ports: {
705
- direction: ((n = e == null ? void 0 : e.ports) == null ? void 0 : n.direction) ?? 0
706
+ direction: ((s = e == null ? void 0 : e.ports) == null ? void 0 : s.direction) ?? 0
706
707
  },
707
708
  edges: {
708
- shapeFactory: st(((d = e == null ? void 0 : e.edges) == null ? void 0 : d.shape) ?? {}),
709
+ shapeFactory: st(((h = e == null ? void 0 : e.edges) == null ? void 0 : h.shape) ?? {}),
709
710
  priorityFn: t.edgesPriorityFn
710
711
  }
711
712
  };
712
713
  };
713
- class dt {
714
+ class ct {
714
715
  constructor() {
715
- s(this, "nodes", /* @__PURE__ */ new Map());
716
- s(this, "ports", /* @__PURE__ */ new Map());
717
- s(this, "nodePorts", /* @__PURE__ */ new Map());
718
- s(this, "portNodeId", /* @__PURE__ */ new Map());
719
- s(this, "edges", /* @__PURE__ */ new Map());
720
- s(this, "incommingEdges", /* @__PURE__ */ new Map());
721
- s(this, "outcommingEdges", /* @__PURE__ */ new Map());
722
- s(this, "cycleEdges", /* @__PURE__ */ new Map());
716
+ n(this, "nodes", /* @__PURE__ */ new Map());
717
+ n(this, "ports", /* @__PURE__ */ new Map());
718
+ n(this, "nodePorts", /* @__PURE__ */ new Map());
719
+ n(this, "portNodeId", /* @__PURE__ */ new Map());
720
+ n(this, "edges", /* @__PURE__ */ new Map());
721
+ n(this, "incommingEdges", /* @__PURE__ */ new Map());
722
+ n(this, "outcommingEdges", /* @__PURE__ */ new Map());
723
+ n(this, "cycleEdges", /* @__PURE__ */ new Map());
723
724
  }
724
725
  addNode(t) {
725
726
  this.nodes.set(t.nodeId, {
@@ -925,8 +926,8 @@ const j = (e) => ({
925
926
  };
926
927
  class at {
927
928
  constructor() {
928
- s(this, "viewportMatrix", H);
929
- s(this, "contentMatrix", H);
929
+ n(this, "viewportMatrix", H);
930
+ n(this, "contentMatrix", H);
930
931
  }
931
932
  getViewportMatrix() {
932
933
  return this.viewportMatrix;
@@ -972,11 +973,11 @@ const ut = () => {
972
973
  };
973
974
  class ft {
974
975
  constructor(t, o) {
975
- s(this, "canvasWrapper", null);
976
- s(this, "host", ut());
977
- s(this, "container", wt());
978
- s(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
979
- s(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
976
+ n(this, "canvasWrapper", null);
977
+ n(this, "host", ut());
978
+ n(this, "container", wt());
979
+ n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
980
+ n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
980
981
  this.graphStore = t, this.viewportTransformer = o, this.host.appendChild(this.container);
981
982
  }
982
983
  attach(t) {
@@ -1016,8 +1017,8 @@ class ft {
1016
1017
  this.clear(), this.detach(), this.host.removeChild(this.container);
1017
1018
  }
1018
1019
  updateNodeCoordinates(t) {
1019
- const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: n } = r.element.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix().scale, c = r.centerFn(i, n), h = r.x - d * c.x, l = r.y - d * c.y;
1020
- o.style.transform = `translate(${h}px, ${l}px)`;
1020
+ const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, d = r.centerFn(i, s), c = r.x - h * d.x, l = r.y - h * d.y;
1021
+ o.style.transform = `translate(${c}px, ${l}px)`;
1021
1022
  }
1022
1023
  updateNodePriority(t) {
1023
1024
  const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
@@ -1030,31 +1031,31 @@ class ft {
1030
1031
  this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
1031
1032
  }
1032
1033
  renderEdge(t) {
1033
- const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), n = r.element.getBoundingClientRect(), d = i.element.getBoundingClientRect(), c = this.host.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix(), l = {
1034
- x: h.scale * (n.left - c.left) + h.dx,
1035
- y: h.scale * (n.top - c.top) + h.dy
1034
+ const o = this.graphStore.getEdge(t), r = this.graphStore.getPort(o.from), i = this.graphStore.getPort(o.to), s = r.element.getBoundingClientRect(), h = i.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix(), l = {
1035
+ x: c.scale * (s.left - d.left) + c.dx,
1036
+ y: c.scale * (s.top - d.top) + c.dy
1036
1037
  }, a = {
1037
- x: h.scale * (d.left - c.left) + h.dx,
1038
- y: h.scale * (d.top - c.top) + h.dy
1039
- }, w = {
1038
+ x: c.scale * (h.left - d.left) + c.dx,
1039
+ y: c.scale * (h.top - d.top) + c.dy
1040
+ }, g = {
1040
1041
  x: l.x,
1041
1042
  y: l.y,
1042
- width: n.width * h.scale,
1043
- height: n.height * h.scale,
1043
+ width: s.width * c.scale,
1044
+ height: s.height * c.scale,
1044
1045
  direction: r.direction,
1045
1046
  portId: o.from,
1046
1047
  nodeId: this.graphStore.getPortNodeId(o.from)
1047
1048
  }, y = {
1048
1049
  x: a.x,
1049
1050
  y: a.y,
1050
- width: d.width * h.scale,
1051
- height: d.height * h.scale,
1051
+ width: h.width * c.scale,
1052
+ height: h.height * c.scale,
1052
1053
  direction: i.direction,
1053
1054
  portId: o.to,
1054
1055
  nodeId: this.graphStore.getPortNodeId(o.to)
1055
1056
  };
1056
1057
  o.shape.render({
1057
- source: w,
1058
+ source: g,
1058
1059
  target: y
1059
1060
  });
1060
1061
  }
@@ -1063,9 +1064,9 @@ class ft {
1063
1064
  o.shape.svg.style.zIndex = `${o.priority}`;
1064
1065
  }
1065
1066
  }
1066
- class C {
1067
+ class N {
1067
1068
  constructor(t) {
1068
- s(this, "counter", 0);
1069
+ n(this, "counter", 0);
1069
1070
  this.checkExists = t;
1070
1071
  }
1071
1072
  create(t) {
@@ -1082,21 +1083,21 @@ class C {
1082
1083
  class S extends Error {
1083
1084
  constructor() {
1084
1085
  super(...arguments);
1085
- s(this, "name", "HtmlGraphError");
1086
+ n(this, "name", "HtmlGraphError");
1086
1087
  }
1087
1088
  }
1088
1089
  class vt {
1089
- constructor(t, o, r, i, n, d, c) {
1090
- s(this, "nodeIdGenerator", new C(
1090
+ constructor(t, o, r, i, s, h, d) {
1091
+ n(this, "nodeIdGenerator", new N(
1091
1092
  (t) => this.graphStore.getNode(t) !== void 0
1092
1093
  ));
1093
- s(this, "portIdGenerator", new C(
1094
+ n(this, "portIdGenerator", new N(
1094
1095
  (t) => this.graphStore.getPort(t) !== void 0
1095
1096
  ));
1096
- s(this, "edgeIdGenerator", new C(
1097
+ n(this, "edgeIdGenerator", new N(
1097
1098
  (t) => this.graphStore.getEdge(t) !== void 0
1098
1099
  ));
1099
- this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = n, this.defaultNodesPriorityFn = d, this.defaultEdgesPriorityFn = c;
1100
+ this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = d;
1100
1101
  }
1101
1102
  attach(t) {
1102
1103
  this.htmlController.attach(t);
@@ -1163,16 +1164,16 @@ class vt {
1163
1164
  const r = this.graphStore.getPort(t);
1164
1165
  if (r === void 0)
1165
1166
  throw new S("failed to unset nonexisting port");
1166
- r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((n) => {
1167
- this.htmlController.renderEdge(n);
1167
+ r.direction = o.direction ?? r.direction, this.graphStore.getPortAdjacentEdgeIds(t).forEach((s) => {
1168
+ this.htmlController.renderEdge(s);
1168
1169
  });
1169
1170
  }
1170
1171
  updateNode(t, o) {
1171
1172
  const r = this.graphStore.getNode(t);
1172
1173
  if (r === void 0)
1173
1174
  throw new S("failed to update nonexisting node");
1174
- r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = (o == null ? void 0 : o.centerFn) ?? r.centerFn, r.priority = (o == null ? void 0 : o.priority) ?? r.priority, this.htmlController.updateNodeCoordinates(t), this.htmlController.updateNodePriority(t), this.graphStore.getNodeAdjacentEdgeIds(t).forEach((n) => {
1175
- this.htmlController.renderEdge(n);
1175
+ r.x = (o == null ? void 0 : o.x) ?? r.x, r.y = (o == null ? void 0 : o.y) ?? r.y, r.centerFn = (o == null ? void 0 : o.centerFn) ?? r.centerFn, r.priority = (o == null ? void 0 : o.priority) ?? r.priority, this.htmlController.updateNodeCoordinates(t), this.htmlController.updateNodePriority(t), this.graphStore.getNodeAdjacentEdgeIds(t).forEach((s) => {
1176
+ this.htmlController.renderEdge(s);
1176
1177
  });
1177
1178
  }
1178
1179
  removeEdge(t) {
@@ -1209,17 +1210,17 @@ class vt {
1209
1210
  }
1210
1211
  class xt {
1211
1212
  constructor(t) {
1212
- s(this, "transformation");
1213
- s(this, "model");
1214
- s(this, "canvasController");
1215
- s(this, "edgeShapeFactory");
1213
+ n(this, "transformation");
1214
+ n(this, "model");
1215
+ n(this, "canvasController");
1216
+ n(this, "edgeShapeFactory");
1216
1217
  this.apiOptions = t;
1217
- const o = ct(this.apiOptions), r = new at(), i = new dt();
1218
+ const o = dt(this.apiOptions), r = new at(), i = new ct();
1218
1219
  this.model = new lt(i), this.transformation = new gt(r);
1219
- const n = new ft(i, r);
1220
+ const s = new ft(i, r);
1220
1221
  this.canvasController = new vt(
1221
1222
  i,
1222
- n,
1223
+ s,
1223
1224
  r,
1224
1225
  o.nodes.centerFn,
1225
1226
  o.ports.direction,
@@ -1306,35 +1307,36 @@ class xt {
1306
1307
  }
1307
1308
  }
1308
1309
  const P = (e, t, o) => {
1309
- const { x: r, y: i, width: n, height: d } = e.getBoundingClientRect();
1310
- return t >= r && t <= r + n && o >= i && o <= i + d;
1310
+ const { x: r, y: i, width: s, height: h } = e.getBoundingClientRect();
1311
+ return t >= r && t <= r + s && o >= i && o <= i + h;
1311
1312
  }, L = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, D = (e, t) => {
1312
1313
  t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
1313
1314
  };
1314
1315
  class St {
1315
1316
  constructor(t, o) {
1316
- s(this, "model");
1317
- s(this, "transformation");
1318
- s(this, "maxNodePriority", 0);
1319
- s(this, "nodes", /* @__PURE__ */ new Map());
1320
- s(this, "grabbedNodeId", null);
1321
- s(this, "onNodeDrag");
1322
- s(this, "onBeforeNodeDrag");
1323
- s(this, "nodeIdGenerator", new C(
1317
+ n(this, "model");
1318
+ n(this, "transformation");
1319
+ n(this, "maxNodePriority", 0);
1320
+ n(this, "nodes", /* @__PURE__ */ new Map());
1321
+ n(this, "grabbedNodeId", null);
1322
+ n(this, "onNodeDrag");
1323
+ n(this, "onBeforeNodeDrag");
1324
+ n(this, "onNodeDragFinished");
1325
+ n(this, "nodeIdGenerator", new N(
1324
1326
  (t) => this.nodes.has(t)
1325
1327
  ));
1326
- s(this, "element", null);
1327
- s(this, "onWindowMouseMove", (t) => {
1328
+ n(this, "element", null);
1329
+ n(this, "onWindowMouseMove", (t) => {
1328
1330
  if (this.element !== null && (!P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY))) {
1329
1331
  this.cancelMouseDrag();
1330
1332
  return;
1331
1333
  }
1332
1334
  this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
1333
1335
  });
1334
- s(this, "onWindowMouseUp", (t) => {
1336
+ n(this, "onWindowMouseUp", (t) => {
1335
1337
  t.button === 0 && this.cancelMouseDrag();
1336
1338
  });
1337
- s(this, "onWindowTouchMove", (t) => {
1339
+ n(this, "onWindowTouchMove", (t) => {
1338
1340
  if (t.touches.length !== 1)
1339
1341
  return;
1340
1342
  const o = t.touches[0];
@@ -1350,19 +1352,20 @@ class St {
1350
1352
  };
1351
1353
  }
1352
1354
  });
1353
- s(this, "onWindowTouchFinish", (t) => {
1355
+ n(this, "onWindowTouchFinish", (t) => {
1354
1356
  t.touches.length > 0 ? this.previousTouchCoords = {
1355
1357
  x: t.touches[0].clientX,
1356
1358
  y: t.touches[0].clientY
1357
1359
  } : this.cancelTouchDrag();
1358
1360
  });
1359
- s(this, "previousTouchCoords", null);
1360
- s(this, "freezePriority");
1361
- s(this, "window", window);
1362
- s(this, "dragCursor");
1363
- var r, i;
1361
+ n(this, "previousTouchCoords", null);
1362
+ n(this, "freezePriority");
1363
+ n(this, "window", window);
1364
+ n(this, "dragCursor");
1365
+ var r, i, s;
1364
1366
  this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.onNodeDrag = ((r = o == null ? void 0 : o.events) == null ? void 0 : r.onNodeDrag) ?? (() => {
1365
- }), this.onBeforeNodeDrag = ((i = o == null ? void 0 : o.events) == null ? void 0 : i.onBeforeNodeDrag) ?? (() => !0), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
1367
+ }), this.onBeforeNodeDrag = ((i = o == null ? void 0 : o.events) == null ? void 0 : i.onBeforeNodeDrag) ?? (() => !0), this.onNodeDragFinished = ((s = o == null ? void 0 : o.events) == null ? void 0 : s.onNodeDragFinished) ?? (() => {
1368
+ }), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
1366
1369
  }
1367
1370
  attach(t) {
1368
1371
  return this.detach(), this.element = t, this.canvas.attach(this.element), this;
@@ -1373,28 +1376,28 @@ class St {
1373
1376
  addNode(t) {
1374
1377
  const o = this.nodeIdGenerator.create(t.id);
1375
1378
  this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
1376
- const r = (n) => {
1377
- if (this.element === null || n.button !== 0)
1379
+ const r = (s) => {
1380
+ if (this.element === null || s.button !== 0)
1378
1381
  return;
1379
- const d = this.model.getNode(o);
1382
+ const h = this.model.getNode(o);
1380
1383
  this.onBeforeNodeDrag({
1381
1384
  nodeId: o,
1382
1385
  element: t.element,
1383
- x: d.x,
1384
- y: d.y
1385
- }) && (n.stopImmediatePropagation(), this.grabbedNodeId = o, D(this.element, this.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1386
- }, i = (n) => {
1387
- n.stopImmediatePropagation(), this.previousTouchCoords = {
1388
- x: n.touches[0].clientX,
1389
- y: n.touches[0].clientY
1386
+ x: h.x,
1387
+ y: h.y
1388
+ }) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, D(this.element, this.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1389
+ }, i = (s) => {
1390
+ s.stopImmediatePropagation(), this.previousTouchCoords = {
1391
+ x: s.touches[0].clientX,
1392
+ y: s.touches[0].clientY
1390
1393
  };
1391
- const d = this.model.getNode(o);
1394
+ const h = this.model.getNode(o);
1392
1395
  this.onBeforeNodeDrag({
1393
1396
  nodeId: o,
1394
1397
  element: t.element,
1395
- x: d.x,
1396
- y: d.y
1397
- }) && n.touches.length === 1 && (this.grabbedNodeId = o, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
1398
+ x: h.x,
1399
+ y: h.y
1400
+ }) && s.touches.length === 1 && (this.grabbedNodeId = o, this.moveNodeOnTop(o), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
1398
1401
  };
1399
1402
  return this.nodes.set(o, {
1400
1403
  element: t.element,
@@ -1445,8 +1448,8 @@ class St {
1445
1448
  const i = this.model.getNode(t);
1446
1449
  if (i === null)
1447
1450
  return;
1448
- const n = this.canvas.transformation.getContentMatrix(), d = n.scale * i.x + n.dx, c = n.scale * i.y + n.dy, h = d + o, l = c + r, a = this.canvas.transformation.getViewportMatrix(), w = a.scale * h + a.dx, y = a.scale * l + a.dy;
1449
- this.canvas.updateNode(t, { x: w, y }), this.onNodeDrag({
1451
+ const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx, d = s.scale * i.y + s.dy, c = h + o, l = d + r, a = this.canvas.transformation.getViewportMatrix(), g = a.scale * c + a.dx, y = a.scale * l + a.dy;
1452
+ this.canvas.updateNode(t, { x: g, y }), this.onNodeDrag({
1450
1453
  nodeId: t,
1451
1454
  element: i.element,
1452
1455
  x: i.x,
@@ -1467,13 +1470,26 @@ class St {
1467
1470
  });
1468
1471
  }
1469
1472
  cancelMouseDrag() {
1470
- this.grabbedNodeId = null, this.element !== null && D(this.element, null), this.removeMouseDragListeners();
1473
+ const t = this.model.getNode(this.grabbedNodeId);
1474
+ t !== null && this.onNodeDragFinished({
1475
+ nodeId: this.grabbedNodeId,
1476
+ element: t.element,
1477
+ x: t.x,
1478
+ y: t.y
1479
+ }), this.grabbedNodeId = null, this.element !== null && D(this.element, null), this.removeMouseDragListeners();
1471
1480
  }
1472
1481
  removeMouseDragListeners() {
1473
1482
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
1474
1483
  }
1475
1484
  cancelTouchDrag() {
1476
- this.previousTouchCoords = null, this.grabbedNodeId = null, this.removeTouchDragListeners();
1485
+ this.previousTouchCoords = null;
1486
+ const t = this.model.getNode(this.grabbedNodeId);
1487
+ t !== null && this.onNodeDragFinished({
1488
+ nodeId: this.grabbedNodeId,
1489
+ element: t.element,
1490
+ x: t.x,
1491
+ y: t.y
1492
+ }), this.grabbedNodeId = null, this.removeTouchDragListeners();
1477
1493
  }
1478
1494
  removeTouchDragListeners() {
1479
1495
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
@@ -1481,22 +1497,33 @@ class St {
1481
1497
  }
1482
1498
  const At = (e) => {
1483
1499
  const t = e.minX !== null ? e.minX : -1 / 0, o = e.maxX !== null ? e.maxX : 1 / 0, r = e.minY !== null ? e.minY : -1 / 0, i = e.maxY !== null ? e.maxY : 1 / 0;
1484
- return (n) => {
1485
- let d = n.nextTransform.dx, c = n.nextTransform.dy;
1486
- d < t && d < n.prevTransform.dx && (d = Math.min(n.prevTransform.dx, t));
1487
- const h = n.canvasWidth * n.prevTransform.scale;
1488
- d > o - h && d > n.prevTransform.dx && (d = Math.max(n.prevTransform.dx, o - h)), c < r && c < n.prevTransform.dy && (c = Math.min(n.prevTransform.dy, r));
1489
- const l = n.canvasHeight * n.prevTransform.scale;
1490
- return c > i - l && c > n.prevTransform.dy && (c = Math.max(n.prevTransform.dy, i - l)), { scale: n.nextTransform.scale, dx: d, dy: c };
1500
+ return (s) => {
1501
+ let h = s.nextTransform.dx, d = s.nextTransform.dy;
1502
+ h < t && h < s.prevTransform.dx && (h = Math.min(s.prevTransform.dx, t));
1503
+ const c = s.canvasWidth * s.prevTransform.scale;
1504
+ h > o - c && h > s.prevTransform.dx && (h = Math.max(s.prevTransform.dx, o - c)), d < r && d < s.prevTransform.dy && (d = Math.min(s.prevTransform.dy, r));
1505
+ const l = s.canvasHeight * s.prevTransform.scale;
1506
+ return d > i - l && d > s.prevTransform.dy && (d = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: d };
1491
1507
  };
1492
1508
  }, Et = (e) => {
1493
1509
  const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
1494
- return (n) => {
1495
- let d = n.nextTransform.scale, c = n.nextTransform.dx, h = n.nextTransform.dy;
1496
- return n.nextTransform.scale > i && n.nextTransform.scale > n.prevTransform.scale && (d = Math.max(n.prevTransform.scale, i), c = n.prevTransform.dx, h = n.prevTransform.dy), n.nextTransform.scale < r && n.nextTransform.scale < n.prevTransform.scale && (d = Math.min(n.prevTransform.scale, r), c = n.prevTransform.dx, h = n.prevTransform.dy), {
1497
- scale: d,
1498
- dx: c,
1499
- dy: h
1510
+ return (s) => {
1511
+ const h = s.prevTransform, d = s.nextTransform;
1512
+ let c = d.scale, l = d.dx, a = d.dy;
1513
+ if (d.scale > i && d.scale > h.scale) {
1514
+ c = Math.max(h.scale, i), l = h.dx, a = h.dy;
1515
+ const g = (c - h.scale) / (d.scale - h.scale);
1516
+ l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
1517
+ }
1518
+ if (d.scale < r && d.scale < h.scale) {
1519
+ c = Math.min(h.scale, r), l = h.dx, a = h.dy;
1520
+ const g = (c - h.scale) / (d.scale - h.scale);
1521
+ l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
1522
+ }
1523
+ return {
1524
+ scale: c,
1525
+ dx: l,
1526
+ dy: a
1500
1527
  };
1501
1528
  };
1502
1529
  }, Tt = (e) => (t) => e.reduce(
@@ -1507,7 +1534,7 @@ const At = (e) => {
1507
1534
  canvasHeight: t.canvasHeight
1508
1535
  }),
1509
1536
  t.nextTransform
1510
- ), O = (e) => {
1537
+ ), U = (e) => {
1511
1538
  if (typeof e == "function")
1512
1539
  return e;
1513
1540
  switch (e.type) {
@@ -1525,62 +1552,62 @@ const At = (e) => {
1525
1552
  });
1526
1553
  }
1527
1554
  }, Mt = (e) => {
1528
- var h, l, a, w;
1529
- const t = (h = e == null ? void 0 : e.scale) == null ? void 0 : h.wheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1555
+ var c, l, a, g;
1556
+ const t = (c = e == null ? void 0 : e.scale) == null ? void 0 : c.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1530
1557
  let i;
1531
1558
  r !== void 0 ? Array.isArray(r) ? i = Tt(
1532
1559
  r.map(
1533
- (y) => O(y)
1560
+ (y) => U(y)
1534
1561
  )
1535
- ) : i = O(r) : i = (y) => y.nextTransform;
1536
- const n = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", d = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onBeforeTransformStarted) ?? (() => {
1537
- }), c = ((w = e == null ? void 0 : e.events) == null ? void 0 : w.onTransformFinished) ?? (() => {
1562
+ ) : i = U(r) : i = (y) => y.nextTransform;
1563
+ const s = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", h = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onBeforeTransformStarted) ?? (() => {
1564
+ }), d = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformFinished) ?? (() => {
1538
1565
  });
1539
1566
  return {
1540
1567
  wheelSensitivity: o,
1541
- onBeforeTransformStarted: d,
1542
- onTransformFinished: c,
1568
+ onBeforeTransformStarted: h,
1569
+ onTransformFinished: d,
1543
1570
  transformPreprocessor: i,
1544
- shiftCursor: n
1571
+ shiftCursor: s
1545
1572
  };
1546
1573
  }, W = (e) => {
1547
1574
  const t = [], o = e.touches.length;
1548
- for (let c = 0; c < o; c++)
1549
- t.push([e.touches[c].clientX, e.touches[c].clientY]);
1575
+ for (let d = 0; d < o; d++)
1576
+ t.push([e.touches[d].clientX, e.touches[d].clientY]);
1550
1577
  const r = t.reduce(
1551
- (c, h) => [c[0] + h[0], c[1] + h[1]],
1578
+ (d, c) => [d[0] + c[0], d[1] + c[1]],
1552
1579
  [0, 0]
1553
- ), i = [r[0] / o, r[1] / o], d = t.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
1554
- (c, h) => c + Math.sqrt(h[0] * h[0] + h[1] * h[1]),
1580
+ ), i = [r[0] / o, r[1] / o], h = t.map((d) => [d[0] - i[0], d[1] - i[1]]).reduce(
1581
+ (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1555
1582
  0
1556
1583
  );
1557
1584
  return {
1558
1585
  x: i[0],
1559
1586
  y: i[1],
1560
- scale: d / o,
1587
+ scale: h / o,
1561
1588
  touchesCnt: o,
1562
1589
  touches: t
1563
1590
  };
1564
- }, Ct = (e, t, o) => ({
1591
+ }, Nt = (e, t, o) => ({
1565
1592
  scale: e.scale,
1566
1593
  dx: e.dx + e.scale * t,
1567
1594
  dy: e.dy + e.scale * o
1568
- }), Nt = (e, t, o, r) => ({
1595
+ }), Ct = (e, t, o, r) => ({
1569
1596
  scale: e.scale * t,
1570
1597
  dx: e.scale * (1 - t) * o + e.dx,
1571
1598
  dy: e.scale * (1 - t) * r + e.dy
1572
1599
  });
1573
1600
  class Pt {
1574
1601
  constructor(t, o) {
1575
- s(this, "model");
1576
- s(this, "transformation");
1577
- s(this, "element", null);
1578
- s(this, "prevTouches", null);
1579
- s(this, "window", window);
1580
- s(this, "onMouseDown", (t) => {
1602
+ n(this, "model");
1603
+ n(this, "transformation");
1604
+ n(this, "element", null);
1605
+ n(this, "prevTouches", null);
1606
+ n(this, "window", window);
1607
+ n(this, "onMouseDown", (t) => {
1581
1608
  this.element === null || t.button !== 0 || (D(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
1582
1609
  });
1583
- s(this, "onWindowMouseMove", (t) => {
1610
+ n(this, "onWindowMouseMove", (t) => {
1584
1611
  if (this.element === null || !P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY)) {
1585
1612
  this.stopMouseDrag();
1586
1613
  return;
@@ -1588,24 +1615,24 @@ class Pt {
1588
1615
  const o = -t.movementX, r = -t.movementY;
1589
1616
  this.moveViewport(this.element, o, r);
1590
1617
  });
1591
- s(this, "onWindowMouseUp", (t) => {
1618
+ n(this, "onWindowMouseUp", (t) => {
1592
1619
  this.element === null || t.button !== 0 || this.stopMouseDrag();
1593
1620
  });
1594
- s(this, "onWheelScroll", (t) => {
1621
+ n(this, "onWheelScroll", (t) => {
1595
1622
  t.preventDefault();
1596
- const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, n = t.clientY - r, c = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1597
- this.scaleViewport(this.element, c, i, n);
1623
+ const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, d = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1624
+ this.scaleViewport(this.element, d, i, s);
1598
1625
  });
1599
- s(this, "onTouchStart", (t) => {
1626
+ n(this, "onTouchStart", (t) => {
1600
1627
  this.prevTouches = W(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
1601
1628
  });
1602
- s(this, "onWindowTouchMove", (t) => {
1629
+ n(this, "onWindowTouchMove", (t) => {
1603
1630
  const o = this.element;
1604
1631
  if (o === null)
1605
1632
  return;
1606
1633
  const r = W(t);
1607
1634
  if (!r.touches.every(
1608
- (n) => P(o, n[0], n[1]) && L(this.window, n[0], n[1])
1635
+ (s) => P(o, s[0], s[1]) && L(this.window, s[0], s[1])
1609
1636
  )) {
1610
1637
  this.stopTouchDrag();
1611
1638
  return;
@@ -1615,15 +1642,15 @@ class Pt {
1615
1642
  -(r.x - this.prevTouches.x),
1616
1643
  -(r.y - this.prevTouches.y)
1617
1644
  ), r.touchesCnt === 2) {
1618
- const { left: n, top: d } = o.getBoundingClientRect(), c = this.prevTouches.x - n, h = this.prevTouches.y - d, a = 1 / (r.scale / this.prevTouches.scale);
1619
- this.scaleViewport(o, a, c, h);
1645
+ const { left: s, top: h } = o.getBoundingClientRect(), d = this.prevTouches.x - s, c = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
1646
+ this.scaleViewport(o, a, d, c);
1620
1647
  }
1621
1648
  this.prevTouches = r;
1622
1649
  });
1623
- s(this, "onWindowTouchFinish", (t) => {
1650
+ n(this, "onWindowTouchFinish", (t) => {
1624
1651
  t.touches.length > 0 ? this.prevTouches = W(t) : this.stopTouchDrag();
1625
1652
  });
1626
- s(this, "observer", new ResizeObserver(() => {
1653
+ n(this, "observer", new ResizeObserver(() => {
1627
1654
  const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
1628
1655
  prevTransform: t,
1629
1656
  nextTransform: t,
@@ -1632,7 +1659,7 @@ class Pt {
1632
1659
  });
1633
1660
  this.canvas.patchViewportMatrix(i), this.options.onTransformFinished();
1634
1661
  }));
1635
- s(this, "options");
1662
+ n(this, "options");
1636
1663
  this.canvas = t, this.options = Mt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1637
1664
  }
1638
1665
  attach(t) {
@@ -1682,21 +1709,21 @@ class Pt {
1682
1709
  }
1683
1710
  moveViewport(t, o, r) {
1684
1711
  this.options.onBeforeTransformStarted();
1685
- const i = this.transformation.getViewportMatrix(), n = Ct(i, o, r), { width: d, height: c } = t.getBoundingClientRect(), h = this.options.transformPreprocessor({
1712
+ const i = this.transformation.getViewportMatrix(), s = Nt(i, o, r), { width: h, height: d } = t.getBoundingClientRect(), c = this.options.transformPreprocessor({
1686
1713
  prevTransform: i,
1687
- nextTransform: n,
1688
- canvasWidth: d,
1689
- canvasHeight: c
1714
+ nextTransform: s,
1715
+ canvasWidth: h,
1716
+ canvasHeight: d
1690
1717
  });
1691
- this.canvas.patchViewportMatrix(h), this.options.onTransformFinished();
1718
+ this.canvas.patchViewportMatrix(c), this.options.onTransformFinished();
1692
1719
  }
1693
1720
  scaleViewport(t, o, r, i) {
1694
1721
  this.options.onBeforeTransformStarted();
1695
- const n = this.canvas.transformation.getViewportMatrix(), d = Nt(n, o, r, i), { width: c, height: h } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1696
- prevTransform: n,
1697
- nextTransform: d,
1698
- canvasWidth: c,
1699
- canvasHeight: h
1722
+ const s = this.canvas.transformation.getViewportMatrix(), h = Ct(s, o, r, i), { width: d, height: c } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1723
+ prevTransform: s,
1724
+ nextTransform: h,
1725
+ canvasWidth: d,
1726
+ canvasHeight: c
1700
1727
  });
1701
1728
  this.canvas.patchViewportMatrix(l), this.options.onTransformFinished();
1702
1729
  }
@@ -1715,8 +1742,8 @@ class Pt {
1715
1742
  }
1716
1743
  class Lt {
1717
1744
  constructor() {
1718
- s(this, "keyMap", /* @__PURE__ */ new Map());
1719
- s(this, "valueMap", /* @__PURE__ */ new Map());
1745
+ n(this, "keyMap", /* @__PURE__ */ new Map());
1746
+ n(this, "valueMap", /* @__PURE__ */ new Map());
1720
1747
  }
1721
1748
  set(t, o) {
1722
1749
  this.keyMap.set(t, o), this.valueMap.set(o, t);
@@ -1752,13 +1779,13 @@ class Lt {
1752
1779
  }
1753
1780
  class Dt {
1754
1781
  constructor(t) {
1755
- s(this, "transformation");
1756
- s(this, "model");
1757
- s(this, "nodes", new Lt());
1758
- s(this, "nodeIdGenerator", new C(
1782
+ n(this, "transformation");
1783
+ n(this, "model");
1784
+ n(this, "nodes", new Lt());
1785
+ n(this, "nodeIdGenerator", new N(
1759
1786
  (t) => this.nodes.hasKey(t)
1760
1787
  ));
1761
- s(this, "nodesResizeObserver");
1788
+ n(this, "nodesResizeObserver");
1762
1789
  this.canvas = t, this.nodesResizeObserver = new window.ResizeObserver((o) => {
1763
1790
  o.forEach((r) => {
1764
1791
  const i = r.target;
@@ -1826,12 +1853,12 @@ class Dt {
1826
1853
  }
1827
1854
  class mt {
1828
1855
  constructor() {
1829
- s(this, "coreOptions");
1830
- s(this, "dragOptions");
1831
- s(this, "transformOptions");
1832
- s(this, "isDraggable", !1);
1833
- s(this, "isTransformable", !1);
1834
- s(this, "hasResizeReactiveNodes", !1);
1856
+ n(this, "coreOptions");
1857
+ n(this, "dragOptions");
1858
+ n(this, "transformOptions");
1859
+ n(this, "isDraggable", !1);
1860
+ n(this, "isTransformable", !1);
1861
+ n(this, "hasResizeReactiveNodes", !1);
1835
1862
  }
1836
1863
  setOptions(t) {
1837
1864
  return this.coreOptions = t, this;