@html-graph/html-graph 0.1.1 → 0.1.2

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,5 +1,5 @@
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;
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
3
  var s = (e, t, o) => K(e, typeof t != "symbol" ? t + "" : t, o);
4
4
  const _ = (e, t) => ({
5
5
  x: e / 2,
@@ -11,27 +11,27 @@ const _ = (e, t) => ({
11
11
  x: 0,
12
12
  y: 0
13
13
  }, E = (e, t, o, r) => {
14
- const n = [
14
+ const i = [
15
15
  u,
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, u)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), c = `M ${i[0].x} ${i[0].y}`, d = `L ${i[1].x} ${i[1].y}`, h = `L ${i[2].x} ${i[2].y}`;
19
+ return `${c} ${d} ${h}`;
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) => {
24
+ let n = 0, i = 0, c = 0;
25
+ e.forEach((d, h) => {
26
26
  let l = 0, a = 0, w = 0;
27
27
  const y = h > 0, x = h < r, v = y && x;
28
- if (y && (l = -i, a = -n, w = d), x) {
28
+ if (y && (l = -n, a = -i, w = c), x) {
29
29
  const z = e[h + 1];
30
- i = z.x - c.x, n = z.y - c.y, d = Math.sqrt(i * i + n * n);
30
+ n = z.x - d.x, i = z.y - d.y, c = Math.sqrt(n * n + i * i);
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;
32
+ const M = c !== 0 ? Math.min((v ? t : 0) / c, h < r - 1 ? 0.5 : 1) : 0, X = v ? { x: d.x + n * M, y: d.y + i * M } : d, k = w !== 0 ? Math.min((v ? t : 0) / w, h > 1 ? 0.5 : 1) : 0, B = v ? { x: d.x + l * k, y: d.y + a * k } : d;
33
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}`
34
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${X.x} ${X.y}`
35
35
  );
36
36
  });
37
37
  }
@@ -48,19 +48,19 @@ 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
+ }, n = Math.min(o.x, r.x), i = Math.min(o.y, r.y), c = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), h = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
59
59
  return {
60
- x: i,
61
- y: n,
62
- width: d,
63
- height: c,
60
+ x: n,
61
+ y: i,
62
+ width: c,
63
+ height: d,
64
64
  flipX: h,
65
65
  flipY: l
66
66
  };
@@ -76,11 +76,11 @@ const _ = (e, t) => ({
76
76
  ), r = {
77
77
  x: t.x + e.fromVect.x * e.curvature,
78
78
  y: t.y + e.fromVect.y * e.curvature
79
- }, i = {
79
+ }, n = {
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
+ }, i = `M ${t.x} ${t.y} C ${r.x} ${r.y}, ${n.x} ${n.y}, ${o.x} ${o.y}`, c = e.hasSourceArrow ? "" : `M ${u.x} ${u.y} L ${t.x} ${t.y} `, d = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
83
+ return `${c}${i}${d}`;
84
84
  }, Q = (e) => {
85
85
  const t = e.hasSourceArrow ? f(
86
86
  { x: e.arrowLength, y: u.y },
@@ -90,37 +90,37 @@ const _ = (e, t) => ({
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(
93
+ ) : e.to, r = e.arrowLength, n = Math.cos(e.detourDirection) * e.detourDistance, i = Math.sin(e.detourDirection) * e.detourDistance, c = n * e.flipX, d = i * e.flipY, h = f(
94
94
  { x: r, y: u.y },
95
95
  e.fromVect,
96
96
  u
97
97
  ), l = {
98
- x: h.x + d,
99
- y: h.y + c
98
+ x: h.x + c,
99
+ y: h.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
104
  ), w = {
105
- x: a.x + d,
106
- y: a.y + c
105
+ x: a.x + c,
106
+ y: a.y + d
107
107
  }, y = { x: (l.x + w.x) / 2, y: (l.y + w.y) / 2 }, x = {
108
108
  x: h.x + e.curvature * e.fromVect.x,
109
109
  y: h.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: h.x + c,
115
+ y: h.y + d
116
116
  }, M = {
117
- x: a.x + d,
118
- y: a.y + c
117
+ x: a.x + c,
118
+ y: a.y + d
119
119
  };
120
120
  return [
121
121
  `M ${t.x} ${t.y}`,
122
122
  `L ${h.x} ${h.y}`,
123
- `C ${x.x} ${x.y} ${b.x} ${b.y} ${y.x} ${y.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(" ");
@@ -133,16 +133,16 @@ const _ = (e, t) => ({
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(
137
- { x: e.to.x - i, y: e.to.y },
136
+ ) : e.to, r = e.arrowLength + e.arrowOffset, n = r - e.roundness, i = f({ x: n, y: u.y }, e.fromVect, u), c = f(
137
+ { x: e.to.x - n, 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
140
+ ), d = Math.max((i.x + c.x) / 2, r), h = e.to.y / 2, l = { x: e.flipX > 0 ? d : -r, y: i.y }, a = { x: l.x, y: h }, w = {
141
+ x: e.flipX > 0 ? e.to.x - d : e.to.x + r,
142
+ y: c.y
143
143
  }, y = { x: w.x, y: h };
144
- return N(
145
- [t, n, l, a, y, w, d, o],
144
+ return C(
145
+ [t, i, l, a, y, w, c, o],
146
146
  e.roundness
147
147
  );
148
148
  }, R = (e) => {
@@ -154,17 +154,17 @@ const _ = (e, t) => ({
154
154
  { x: e.to.x - e.arrowLength, y: e.to.y },
155
155
  e.toVect,
156
156
  e.to
157
- ) : e.to, r = e.arrowLength + e.arrowOffset, i = f(
157
+ ) : e.to, r = e.arrowLength + e.arrowOffset, n = f(
158
158
  { x: r, y: u.y },
159
159
  e.fromVect,
160
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(
161
+ ), i = Math.cos(e.detourDirection) * e.detourDistance, c = Math.sin(e.detourDirection) * e.detourDistance, d = i * e.flipX, h = c * e.flipY, l = { x: n.x + d, y: n.y + h }, 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
+ ), w = { x: a.x + d, y: a.y + h };
166
+ return C(
167
+ [t, n, l, w, a, o],
168
168
  e.roundness
169
169
  );
170
170
  }, q = (e) => {
@@ -176,12 +176,12 @@ const _ = (e, t) => ({
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, n = f({ x: r, y: u.y }, e.fromVect, u), i = 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, n, i, o], e.roundness);
185
185
  }, tt = (e) => {
186
186
  const t = e.hasSourceArrow ? f(
187
187
  { x: e.arrowLength, y: u.y },
@@ -191,37 +191,37 @@ const _ = (e, t) => ({
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(
195
- { x: e.to.x - i, y: e.to.y },
194
+ ) : e.to, r = e.arrowLength + e.arrowOffset, n = r - e.roundness, i = f({ x: n, y: u.y }, e.fromVect, u), c = f(
195
+ { x: e.to.x - n, 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
198
+ ), d = Math.max((i.y + c.y) / 2, r), h = e.to.x / 2, l = { x: i.x, y: e.flipY > 0 ? d : -r }, a = { x: h, y: l.y }, w = {
199
+ x: c.x,
200
+ y: e.flipY > 0 ? e.to.y - d : e.to.y + r
201
201
  }, y = { x: h, y: w.y };
202
- return N(
203
- [t, n, l, a, y, w, d, o],
202
+ return C(
203
+ [t, i, l, a, y, w, c, 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 = [
207
+ const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, n = r + 2 * o, c = [
208
208
  { x: e.arrowLength, y: u.y },
209
209
  { x: r, y: u.y },
210
210
  { x: r, y: e.side },
211
- { x: i, y: e.side },
212
- { x: i, y: -e.side },
211
+ { x: n, y: e.side },
212
+ { x: n, y: -e.side },
213
213
  { x: r, y: -e.side },
214
214
  { x: r, y: u.y },
215
215
  { x: e.arrowLength, y: u.y }
216
216
  ].map(
217
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)}`;
218
+ ), d = `M ${u.x} ${u.y} L ${c[0].x} ${c[0].y} `;
219
+ return `${e.hasSourceArrow || e.hasTargetArrow ? "" : d}${C(c, 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 = [
221
+ const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), n = t + o, i = e.arrowLength + r * (1 - o / n), c = t * o / n, h = [
222
222
  { x: e.arrowLength, y: u.y },
223
- { x: n, y: d },
224
- { x: n, y: -d }
223
+ { x: i, y: c },
224
+ { x: i, y: -c }
225
225
  ].map((w) => f(w, e.fromVect, u)), l = [
226
226
  `M ${h[0].x} ${h[0].y}`,
227
227
  `A ${t} ${t} 0 0 1 ${h[1].x} ${h[1].y}`,
@@ -242,6 +242,7 @@ 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
  });
@@ -266,22 +267,22 @@ class ot {
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: n, height: i, flipX: c, 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
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${i}px`, this.group.style.transform = `scale(${c}, ${d})`;
274
275
  const h = A(
275
276
  t.source.direction,
276
- d,
277
- c
277
+ c,
278
+ d
278
279
  ), l = A(
279
280
  t.target.direction,
280
- d,
281
- c
281
+ c,
282
+ d
282
283
  ), a = {
283
- x: i,
284
- y: n
284
+ x: n,
285
+ y: i
285
286
  };
286
287
  let w, y = l, x = -this.arrowLength;
287
288
  if (t.source.portId === t.target.portId ? (w = et({
@@ -295,8 +296,8 @@ class ot {
295
296
  to: a,
296
297
  fromVect: h,
297
298
  toVect: l,
298
- flipX: d,
299
- flipY: c,
299
+ flipX: c,
300
+ flipY: d,
300
301
  arrowLength: this.arrowLength,
301
302
  detourDirection: this.detourDirection,
302
303
  detourDistance: this.detourDistance,
@@ -354,26 +355,26 @@ class rt {
354
355
  this.arrowOffset,
355
356
  this.cycleSquareSide / 2
356
357
  ), 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;
358
- 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));
358
+ const r = (t == null ? void 0 : t.color) ?? g.color, n = (t == null ? void 0 : t.width) ?? g.width;
359
+ this.svg.appendChild(this.group), this.line = m(r, n), 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: n, height: i, flipX: c, 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
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${i}px`, this.group.style.transform = `scale(${c}, ${d})`;
366
367
  const h = A(
367
368
  t.source.direction,
368
- d,
369
- c
369
+ c,
370
+ d
370
371
  ), l = A(
371
372
  t.target.direction,
372
- d,
373
- c
373
+ c,
374
+ d
374
375
  ), a = {
375
- x: i,
376
- y: n
376
+ x: n,
377
+ y: i
377
378
  };
378
379
  let w, y = l, x = -this.arrowLength;
379
380
  if (t.source.portId === t.target.portId ? (w = Y({
@@ -388,8 +389,8 @@ class rt {
388
389
  to: a,
389
390
  fromVect: h,
390
391
  toVect: l,
391
- flipX: d,
392
- flipY: c,
392
+ flipX: c,
393
+ flipY: d,
393
394
  arrowLength: this.arrowLength,
394
395
  arrowOffset: this.arrowOffset,
395
396
  roundness: this.roundness,
@@ -401,7 +402,7 @@ class rt {
401
402
  to: a,
402
403
  fromVect: h,
403
404
  toVect: l,
404
- flipX: d,
405
+ flipX: c,
405
406
  arrowLength: this.arrowLength,
406
407
  arrowOffset: this.arrowOffset,
407
408
  roundness: this.roundness,
@@ -450,26 +451,26 @@ class it {
450
451
  this.arrowOffset,
451
452
  this.cycleSquareSide / 2
452
453
  ), 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;
454
- 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));
454
+ const r = (t == null ? void 0 : t.color) ?? g.color, n = (t == null ? void 0 : t.width) ?? g.width;
455
+ this.svg.appendChild(this.group), this.line = m(r, n), 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: n, height: i, flipX: c, 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
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${i}px`, this.group.style.transform = `scale(${c}, ${d})`;
462
463
  const h = A(
463
464
  t.source.direction,
464
- d,
465
- c
465
+ c,
466
+ d
466
467
  ), l = A(
467
468
  t.target.direction,
468
- d,
469
- c
469
+ c,
470
+ d
470
471
  ), a = {
471
- x: i,
472
- y: n
472
+ x: n,
473
+ y: i
473
474
  };
474
475
  let w, y = l, x = -this.arrowLength;
475
476
  if (t.source.portId === t.target.portId ? (w = Y({
@@ -484,8 +485,8 @@ class it {
484
485
  to: a,
485
486
  fromVect: h,
486
487
  toVect: l,
487
- flipX: d,
488
- flipY: c,
488
+ flipX: c,
489
+ flipY: d,
489
490
  arrowLength: this.arrowLength,
490
491
  arrowOffset: this.arrowOffset,
491
492
  roundness: this.roundness,
@@ -544,27 +545,27 @@ class nt {
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;
549
- 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));
548
+ ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirectionVertical, 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;
549
+ const r = (t == null ? void 0 : t.color) ?? g.color, n = (t == null ? void 0 : t.width) ?? g.width;
550
+ this.svg.appendChild(this.group), this.line = m(r, n), 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: n, height: i, flipX: c, 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
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${n}px`, this.svg.style.height = `${i}px`, this.group.style.transform = `scale(${c}, ${d})`;
557
558
  const h = A(
558
559
  t.source.direction,
559
- d,
560
- c
560
+ c,
561
+ d
561
562
  ), l = A(
562
563
  t.target.direction,
563
- d,
564
- c
564
+ c,
565
+ d
565
566
  ), a = {
566
- x: i,
567
- y: n
567
+ x: n,
568
+ y: i
568
569
  };
569
570
  let w, y = l, x = -this.arrowLength;
570
571
  if (t.source.portId === t.target.portId ? (w = Y({
@@ -579,8 +580,8 @@ class nt {
579
580
  to: a,
580
581
  fromVect: h,
581
582
  toVect: l,
582
- flipX: d,
583
- flipY: c,
583
+ flipX: c,
584
+ flipY: d,
584
585
  arrowLength: this.arrowLength,
585
586
  arrowOffset: this.arrowOffset,
586
587
  roundness: this.roundness,
@@ -592,7 +593,7 @@ class nt {
592
593
  to: a,
593
594
  fromVect: h,
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,
@@ -685,32 +686,32 @@ const st = (e) => {
685
686
  }, ht = (e, t) => {
686
687
  let o = G, r = G;
687
688
  e === "incremental" && (o = V()), t === "incremental" && (r = V());
688
- const i = V();
689
- return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = F(e)), typeof t == "number" && (r = F(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
689
+ const n = V();
690
+ return e === "shared-incremental" && (o = n), t === "shared-incremental" && (r = n), typeof e == "number" && (o = F(e)), typeof t == "number" && (r = F(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
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, n, i, c;
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
698
699
  );
699
700
  return {
700
701
  nodes: {
701
- centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? _,
702
+ centerFn: ((n = e == null ? void 0 : e.nodes) == null ? void 0 : n.centerFn) ?? _,
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: ((i = e == null ? void 0 : e.ports) == null ? void 0 : i.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(((c = e == null ? void 0 : e.edges) == null ? void 0 : c.shape) ?? {}),
709
710
  priorityFn: t.edgesPriorityFn
710
711
  }
711
712
  };
712
713
  };
713
- class dt {
714
+ class ct {
714
715
  constructor() {
715
716
  s(this, "nodes", /* @__PURE__ */ new Map());
716
717
  s(this, "ports", /* @__PURE__ */ new Map());
@@ -798,8 +799,8 @@ class dt {
798
799
  return this.edges.get(t);
799
800
  }
800
801
  removeEdge(t) {
801
- const o = this.edges.get(t), r = o.from, i = o.to;
802
- this.cycleEdges.get(r).delete(t), this.cycleEdges.get(i).delete(t), this.incommingEdges.get(r).delete(t), this.incommingEdges.get(i).delete(t), this.outcommingEdges.get(r).delete(t), this.outcommingEdges.get(i).delete(t), this.edges.delete(t);
802
+ const o = this.edges.get(t), r = o.from, n = o.to;
803
+ this.cycleEdges.get(r).delete(t), this.cycleEdges.get(n).delete(t), this.incommingEdges.get(r).delete(t), this.incommingEdges.get(n).delete(t), this.outcommingEdges.get(r).delete(t), this.outcommingEdges.get(n).delete(t), this.edges.delete(t);
803
804
  }
804
805
  clear() {
805
806
  this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
@@ -823,22 +824,22 @@ class dt {
823
824
  getNodeIncomingEdgeIds(t) {
824
825
  const o = Array.from(this.nodePorts.get(t).keys());
825
826
  let r = [];
826
- return o.forEach((i) => {
827
- r = [...r, ...this.getPortIncomingEdgeIds(i)];
827
+ return o.forEach((n) => {
828
+ r = [...r, ...this.getPortIncomingEdgeIds(n)];
828
829
  }), r;
829
830
  }
830
831
  getNodeOutcomingEdgeIds(t) {
831
832
  const o = Array.from(this.nodePorts.get(t).keys());
832
833
  let r = [];
833
- return o.forEach((i) => {
834
- r = [...r, ...this.getPortOutcomingEdgeIds(i)];
834
+ return o.forEach((n) => {
835
+ r = [...r, ...this.getPortOutcomingEdgeIds(n)];
835
836
  }), r;
836
837
  }
837
838
  getNodeCycleEdgeIds(t) {
838
839
  const o = Array.from(this.nodePorts.get(t).keys());
839
840
  let r = [];
840
- return o.forEach((i) => {
841
- r = [...r, ...this.getPortCycleEdgeIds(i)];
841
+ return o.forEach((n) => {
842
+ r = [...r, ...this.getPortCycleEdgeIds(n)];
842
843
  }), r;
843
844
  }
844
845
  getNodeAdjacentEdgeIds(t) {
@@ -1016,7 +1017,7 @@ 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
+ const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: n, height: i } = r.element.getBoundingClientRect(), c = this.viewportTransformer.getViewportMatrix().scale, d = r.centerFn(n, i), h = r.x - c * d.x, l = r.y - c * d.y;
1020
1021
  o.style.transform = `translate(${h}px, ${l}px)`;
1021
1022
  }
1022
1023
  updateNodePriority(t) {
@@ -1030,26 +1031,26 @@ 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), n = this.graphStore.getPort(o.to), i = r.element.getBoundingClientRect(), c = n.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix(), l = {
1035
+ x: h.scale * (i.left - d.left) + h.dx,
1036
+ y: h.scale * (i.top - d.top) + h.dy
1036
1037
  }, a = {
1037
- x: h.scale * (d.left - c.left) + h.dx,
1038
- y: h.scale * (d.top - c.top) + h.dy
1038
+ x: h.scale * (c.left - d.left) + h.dx,
1039
+ y: h.scale * (c.top - d.top) + h.dy
1039
1040
  }, w = {
1040
1041
  x: l.x,
1041
1042
  y: l.y,
1042
- width: n.width * h.scale,
1043
- height: n.height * h.scale,
1043
+ width: i.width * h.scale,
1044
+ height: i.height * h.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,
1052
- direction: i.direction,
1051
+ width: c.width * h.scale,
1052
+ height: c.height * h.scale,
1053
+ direction: n.direction,
1053
1054
  portId: o.to,
1054
1055
  nodeId: this.graphStore.getPortNodeId(o.to)
1055
1056
  };
@@ -1063,7 +1064,7 @@ 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
1069
  s(this, "counter", 0);
1069
1070
  this.checkExists = t;
@@ -1086,17 +1087,17 @@ class S extends Error {
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, n, i, c, d) {
1091
+ s(this, "nodeIdGenerator", new N(
1091
1092
  (t) => this.graphStore.getNode(t) !== void 0
1092
1093
  ));
1093
- s(this, "portIdGenerator", new C(
1094
+ s(this, "portIdGenerator", new N(
1094
1095
  (t) => this.graphStore.getPort(t) !== void 0
1095
1096
  ));
1096
- s(this, "edgeIdGenerator", new C(
1097
+ s(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 = n, this.defaultPortsDirection = i, this.defaultNodesPriorityFn = c, 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((i) => {
1168
+ this.htmlController.renderEdge(i);
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((i) => {
1176
+ this.htmlController.renderEdge(i);
1176
1177
  });
1177
1178
  }
1178
1179
  removeEdge(t) {
@@ -1214,12 +1215,12 @@ class xt {
1214
1215
  s(this, "canvasController");
1215
1216
  s(this, "edgeShapeFactory");
1216
1217
  this.apiOptions = t;
1217
- const o = ct(this.apiOptions), r = new at(), i = new dt();
1218
- this.model = new lt(i), this.transformation = new gt(r);
1219
- const n = new ft(i, r);
1218
+ const o = dt(this.apiOptions), r = new at(), n = new ct();
1219
+ this.model = new lt(n), this.transformation = new gt(r);
1220
+ const i = new ft(n, r);
1220
1221
  this.canvasController = new vt(
1221
- i,
1222
1222
  n,
1223
+ i,
1223
1224
  r,
1224
1225
  o.nodes.centerFn,
1225
1226
  o.ports.direction,
@@ -1306,8 +1307,8 @@ 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: n, width: i, height: c } = e.getBoundingClientRect();
1311
+ return t >= r && t <= r + i && o >= n && o <= n + c;
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
  };
@@ -1320,7 +1321,8 @@ class St {
1320
1321
  s(this, "grabbedNodeId", null);
1321
1322
  s(this, "onNodeDrag");
1322
1323
  s(this, "onBeforeNodeDrag");
1323
- s(this, "nodeIdGenerator", new C(
1324
+ s(this, "onNodeDragFinished");
1325
+ s(this, "nodeIdGenerator", new N(
1324
1326
  (t) => this.nodes.has(t)
1325
1327
  ));
1326
1328
  s(this, "element", null);
@@ -1343,8 +1345,8 @@ class St {
1343
1345
  return;
1344
1346
  }
1345
1347
  if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1346
- const r = o.clientX - this.previousTouchCoords.x, i = o.clientY - this.previousTouchCoords.y;
1347
- this.dragNode(this.grabbedNodeId, r, i), this.previousTouchCoords = {
1348
+ const r = o.clientX - this.previousTouchCoords.x, n = o.clientY - this.previousTouchCoords.y;
1349
+ this.dragNode(this.grabbedNodeId, r, n), this.previousTouchCoords = {
1348
1350
  x: t.touches[0].clientX,
1349
1351
  y: t.touches[0].clientY
1350
1352
  };
@@ -1360,9 +1362,10 @@ class St {
1360
1362
  s(this, "freezePriority");
1361
1363
  s(this, "window", window);
1362
1364
  s(this, "dragCursor");
1363
- var r, i;
1365
+ var r, n, i;
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 = ((n = o == null ? void 0 : o.events) == null ? void 0 : n.onBeforeNodeDrag) ?? (() => !0), this.onNodeDragFinished = ((i = o == null ? void 0 : o.events) == null ? void 0 : i.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,34 +1376,34 @@ 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 = (i) => {
1380
+ if (this.element === null || i.button !== 0)
1378
1381
  return;
1379
- const d = this.model.getNode(o);
1382
+ const c = 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: c.x,
1387
+ y: c.y
1388
+ }) && (i.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
+ }, n = (i) => {
1390
+ i.stopImmediatePropagation(), this.previousTouchCoords = {
1391
+ x: i.touches[0].clientX,
1392
+ y: i.touches[0].clientY
1390
1393
  };
1391
- const d = this.model.getNode(o);
1394
+ const c = 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: c.x,
1399
+ y: c.y
1400
+ }) && i.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,
1401
1404
  onMouseDown: r,
1402
- onTouchStart: i
1403
- }), t.element.addEventListener("mousedown", r), t.element.addEventListener("touchstart", i), this;
1405
+ onTouchStart: n
1406
+ }), t.element.addEventListener("mousedown", r), t.element.addEventListener("touchstart", n), this;
1404
1407
  }
1405
1408
  updateNode(t, o) {
1406
1409
  return this.canvas.updateNode(t, o), this.updateMaxNodePriority(t), this;
@@ -1442,15 +1445,15 @@ class St {
1442
1445
  this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1443
1446
  }
1444
1447
  dragNode(t, o, r) {
1445
- const i = this.model.getNode(t);
1446
- if (i === null)
1448
+ const n = this.model.getNode(t);
1449
+ if (n === 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;
1451
+ const i = this.canvas.transformation.getContentMatrix(), c = i.scale * n.x + i.dx, d = i.scale * n.y + i.dy, h = c + o, l = d + r, a = this.canvas.transformation.getViewportMatrix(), w = a.scale * h + a.dx, y = a.scale * l + a.dy;
1449
1452
  this.canvas.updateNode(t, { x: w, y }), this.onNodeDrag({
1450
1453
  nodeId: t,
1451
- element: i.element,
1452
- x: i.x,
1453
- y: i.y
1454
+ element: n.element,
1455
+ x: n.x,
1456
+ y: n.y
1454
1457
  });
1455
1458
  }
1456
1459
  updateMaxNodePriority(t) {
@@ -1462,40 +1465,53 @@ class St {
1462
1465
  return;
1463
1466
  this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
1464
1467
  const o = this.maxNodePriority - 1;
1465
- this.model.getNodeAdjacentEdgeIds(t).forEach((i) => {
1466
- this.updateEdge(i, { priority: o });
1468
+ this.model.getNodeAdjacentEdgeIds(t).forEach((n) => {
1469
+ this.updateEdge(n, { priority: o });
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);
1480
1496
  }
1481
1497
  }
1482
1498
  const At = (e) => {
1483
- 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 };
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, n = e.maxY !== null ? e.maxY : 1 / 0;
1500
+ return (i) => {
1501
+ let c = i.nextTransform.dx, d = i.nextTransform.dy;
1502
+ c < t && c < i.prevTransform.dx && (c = Math.min(i.prevTransform.dx, t));
1503
+ const h = i.canvasWidth * i.prevTransform.scale;
1504
+ c > o - h && c > i.prevTransform.dx && (c = Math.max(i.prevTransform.dx, o - h)), d < r && d < i.prevTransform.dy && (d = Math.min(i.prevTransform.dy, r));
1505
+ const l = i.canvasHeight * i.prevTransform.scale;
1506
+ return d > n - l && d > i.prevTransform.dy && (d = Math.max(i.prevTransform.dy, n - l)), { scale: i.nextTransform.scale, dx: c, dy: d };
1491
1507
  };
1492
1508
  }, Et = (e) => {
1493
- 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,
1509
+ const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, n = o !== null ? 1 / o : 1 / 0;
1510
+ return (i) => {
1511
+ let c = i.nextTransform.scale, d = i.nextTransform.dx, h = i.nextTransform.dy;
1512
+ return i.nextTransform.scale > n && i.nextTransform.scale > i.prevTransform.scale && (c = Math.max(i.prevTransform.scale, n), d = i.prevTransform.dx, h = i.prevTransform.dy), i.nextTransform.scale < r && i.nextTransform.scale < i.prevTransform.scale && (c = Math.min(i.prevTransform.scale, r), d = i.prevTransform.dx, h = i.prevTransform.dy), {
1513
+ scale: c,
1514
+ dx: d,
1499
1515
  dy: h
1500
1516
  };
1501
1517
  };
@@ -1507,7 +1523,7 @@ const At = (e) => {
1507
1523
  canvasHeight: t.canvasHeight
1508
1524
  }),
1509
1525
  t.nextTransform
1510
- ), O = (e) => {
1526
+ ), U = (e) => {
1511
1527
  if (typeof e == "function")
1512
1528
  return e;
1513
1529
  switch (e.type) {
@@ -1526,46 +1542,46 @@ const At = (e) => {
1526
1542
  }
1527
1543
  }, Mt = (e) => {
1528
1544
  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;
1530
- let i;
1531
- r !== void 0 ? Array.isArray(r) ? i = Tt(
1545
+ const t = (h = e == null ? void 0 : e.scale) == null ? void 0 : h.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1546
+ let n;
1547
+ r !== void 0 ? Array.isArray(r) ? n = Tt(
1532
1548
  r.map(
1533
- (y) => O(y)
1549
+ (y) => U(y)
1534
1550
  )
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) ?? (() => {
1551
+ ) : n = U(r) : n = (y) => y.nextTransform;
1552
+ const i = ((l = e == null ? void 0 : e.shift) == null ? void 0 : l.cursor) !== void 0 ? e.shift.cursor : "grab", c = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onBeforeTransformStarted) ?? (() => {
1553
+ }), d = ((w = e == null ? void 0 : e.events) == null ? void 0 : w.onTransformFinished) ?? (() => {
1538
1554
  });
1539
1555
  return {
1540
1556
  wheelSensitivity: o,
1541
- onBeforeTransformStarted: d,
1542
- onTransformFinished: c,
1543
- transformPreprocessor: i,
1544
- shiftCursor: n
1557
+ onBeforeTransformStarted: c,
1558
+ onTransformFinished: d,
1559
+ transformPreprocessor: n,
1560
+ shiftCursor: i
1545
1561
  };
1546
1562
  }, W = (e) => {
1547
1563
  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]);
1564
+ for (let d = 0; d < o; d++)
1565
+ t.push([e.touches[d].clientX, e.touches[d].clientY]);
1550
1566
  const r = t.reduce(
1551
- (c, h) => [c[0] + h[0], c[1] + h[1]],
1567
+ (d, h) => [d[0] + h[0], d[1] + h[1]],
1552
1568
  [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]),
1569
+ ), n = [r[0] / o, r[1] / o], c = t.map((d) => [d[0] - n[0], d[1] - n[1]]).reduce(
1570
+ (d, h) => d + Math.sqrt(h[0] * h[0] + h[1] * h[1]),
1555
1571
  0
1556
1572
  );
1557
1573
  return {
1558
- x: i[0],
1559
- y: i[1],
1560
- scale: d / o,
1574
+ x: n[0],
1575
+ y: n[1],
1576
+ scale: c / o,
1561
1577
  touchesCnt: o,
1562
1578
  touches: t
1563
1579
  };
1564
- }, Ct = (e, t, o) => ({
1580
+ }, Nt = (e, t, o) => ({
1565
1581
  scale: e.scale,
1566
1582
  dx: e.dx + e.scale * t,
1567
1583
  dy: e.dy + e.scale * o
1568
- }), Nt = (e, t, o, r) => ({
1584
+ }), Ct = (e, t, o, r) => ({
1569
1585
  scale: e.scale * t,
1570
1586
  dx: e.scale * (1 - t) * o + e.dx,
1571
1587
  dy: e.scale * (1 - t) * r + e.dy
@@ -1593,8 +1609,8 @@ class Pt {
1593
1609
  });
1594
1610
  s(this, "onWheelScroll", (t) => {
1595
1611
  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);
1612
+ const { left: o, top: r } = this.element.getBoundingClientRect(), n = t.clientX - o, i = t.clientY - r, d = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1613
+ this.scaleViewport(this.element, d, n, i);
1598
1614
  });
1599
1615
  s(this, "onTouchStart", (t) => {
1600
1616
  this.prevTouches = W(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
@@ -1605,7 +1621,7 @@ class Pt {
1605
1621
  return;
1606
1622
  const r = W(t);
1607
1623
  if (!r.touches.every(
1608
- (n) => P(o, n[0], n[1]) && L(this.window, n[0], n[1])
1624
+ (i) => P(o, i[0], i[1]) && L(this.window, i[0], i[1])
1609
1625
  )) {
1610
1626
  this.stopTouchDrag();
1611
1627
  return;
@@ -1615,8 +1631,8 @@ class Pt {
1615
1631
  -(r.x - this.prevTouches.x),
1616
1632
  -(r.y - this.prevTouches.y)
1617
1633
  ), 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);
1634
+ const { left: i, top: c } = o.getBoundingClientRect(), d = this.prevTouches.x - i, h = this.prevTouches.y - c, a = 1 / (r.scale / this.prevTouches.scale);
1635
+ this.scaleViewport(o, a, d, h);
1620
1636
  }
1621
1637
  this.prevTouches = r;
1622
1638
  });
@@ -1624,13 +1640,13 @@ class Pt {
1624
1640
  t.touches.length > 0 ? this.prevTouches = W(t) : this.stopTouchDrag();
1625
1641
  });
1626
1642
  s(this, "observer", new ResizeObserver(() => {
1627
- const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
1643
+ const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
1628
1644
  prevTransform: t,
1629
1645
  nextTransform: t,
1630
1646
  canvasWidth: o,
1631
1647
  canvasHeight: r
1632
1648
  });
1633
- this.canvas.patchViewportMatrix(i), this.options.onTransformFinished();
1649
+ this.canvas.patchViewportMatrix(n), this.options.onTransformFinished();
1634
1650
  }));
1635
1651
  s(this, "options");
1636
1652
  this.canvas = t, this.options = Mt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
@@ -1682,20 +1698,20 @@ class Pt {
1682
1698
  }
1683
1699
  moveViewport(t, o, r) {
1684
1700
  this.options.onBeforeTransformStarted();
1685
- const i = this.transformation.getViewportMatrix(), n = Ct(i, o, r), { width: d, height: c } = t.getBoundingClientRect(), h = this.options.transformPreprocessor({
1686
- prevTransform: i,
1687
- nextTransform: n,
1688
- canvasWidth: d,
1689
- canvasHeight: c
1701
+ const n = this.transformation.getViewportMatrix(), i = Nt(n, o, r), { width: c, height: d } = t.getBoundingClientRect(), h = this.options.transformPreprocessor({
1702
+ prevTransform: n,
1703
+ nextTransform: i,
1704
+ canvasWidth: c,
1705
+ canvasHeight: d
1690
1706
  });
1691
1707
  this.canvas.patchViewportMatrix(h), this.options.onTransformFinished();
1692
1708
  }
1693
- scaleViewport(t, o, r, i) {
1709
+ scaleViewport(t, o, r, n) {
1694
1710
  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,
1711
+ const i = this.canvas.transformation.getViewportMatrix(), c = Ct(i, o, r, n), { width: d, height: h } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1712
+ prevTransform: i,
1713
+ nextTransform: c,
1714
+ canvasWidth: d,
1699
1715
  canvasHeight: h
1700
1716
  });
1701
1717
  this.canvas.patchViewportMatrix(l), this.options.onTransformFinished();
@@ -1755,14 +1771,14 @@ class Dt {
1755
1771
  s(this, "transformation");
1756
1772
  s(this, "model");
1757
1773
  s(this, "nodes", new Lt());
1758
- s(this, "nodeIdGenerator", new C(
1774
+ s(this, "nodeIdGenerator", new N(
1759
1775
  (t) => this.nodes.hasKey(t)
1760
1776
  ));
1761
1777
  s(this, "nodesResizeObserver");
1762
1778
  this.canvas = t, this.nodesResizeObserver = new window.ResizeObserver((o) => {
1763
1779
  o.forEach((r) => {
1764
- const i = r.target;
1765
- this.reactNodeChange(i);
1780
+ const n = r.target;
1781
+ this.reactNodeChange(n);
1766
1782
  });
1767
1783
  }), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1768
1784
  }
@@ -1819,8 +1835,8 @@ class Dt {
1819
1835
  }
1820
1836
  reactNodeChange(t) {
1821
1837
  const o = this.nodes.getByValue(t);
1822
- this.canvas.updateNode(o), this.model.getNodeAdjacentEdgeIds(o).forEach((i) => {
1823
- this.canvas.updateEdge(i);
1838
+ this.canvas.updateNode(o), this.model.getNodeAdjacentEdgeIds(o).forEach((n) => {
1839
+ this.canvas.updateEdge(n);
1824
1840
  });
1825
1841
  }
1826
1842
  }