@html-graph/html-graph 0.1.4 → 0.1.5

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,75 +1,75 @@
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
- const _ = (e, t) => ({
1
+ var K = Object.defineProperty;
2
+ var _ = (e, t, o) => t in e ? K(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var n = (e, t, o) => _(e, typeof t != "symbol" ? t + "" : t, o);
4
+ const J = (e, t) => ({
5
5
  x: e / 2,
6
6
  y: t / 2
7
- }), f = (e, t, o) => ({
7
+ }), v = (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
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
- }, E = (e, t, o, r) => {
13
+ }, T = (e, t, o, r) => {
14
14
  const s = [
15
15
  w,
16
16
  { x: o, y: r },
17
17
  { x: o, y: -r }
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
- }, N = (e, t) => {
18
+ ].map((l) => v(l, e, w)).map((l) => ({ x: l.x + t.x, y: l.y + t.y })), h = `M ${s[0].x} ${s[0].y}`, c = `L ${s[1].x} ${s[1].y}`, d = `L ${s[2].x} ${s[2].y}`;
19
+ return `${h} ${c} ${d}`;
20
+ }, P = (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
24
  let i = 0, s = 0, h = 0;
25
- e.forEach((d, c) => {
25
+ e.forEach((c, d) => {
26
26
  let l = 0, a = 0, g = 0;
27
- const y = c > 0, x = c < r, v = y && x;
27
+ const y = d > 0, x = d < r, f = y && x;
28
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);
29
+ const z = e[d + 1];
30
+ i = z.x - c.x, s = z.y - c.y, h = Math.sqrt(i * i + s * s);
31
31
  }
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}`
32
+ const E = h !== 0 ? Math.min((f ? t : 0) / h, d < r - 1 ? 0.5 : 1) : 0, N = f ? { x: c.x + i * E, y: c.y + s * E } : c, k = g !== 0 ? Math.min((f ? t : 0) / g, d > 1 ? 0.5 : 1) : 0, B = f ? { x: c.x + l * k, y: c.y + a * k } : c;
33
+ d > 0 && o.push(`L ${B.x} ${B.y}`), f && o.push(
34
+ `C ${c.x} ${c.y} ${c.x} ${c.y} ${N.x} ${N.y}`
35
35
  );
36
36
  });
37
37
  }
38
38
  return o.join(" ");
39
- }, I = () => {
39
+ }, $ = () => {
40
40
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
41
41
  return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
42
- }, $ = () => {
42
+ }, p = () => {
43
43
  const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
44
44
  return e.style.transformOrigin = "50% 50%", e;
45
- }, m = (e, t) => {
45
+ }, b = (e, t) => {
46
46
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
47
47
  return o.setAttribute("stroke", e), o.setAttribute("stroke-width", `${t}`), o.setAttribute("fill", "none"), o;
48
- }, T = (e) => {
48
+ }, M = (e) => {
49
49
  const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
50
50
  return t.setAttribute("fill", e), t;
51
- }, b = (e, t) => {
51
+ }, V = (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), 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;
58
+ }, i = Math.min(o.x, r.x), s = Math.min(o.y, r.y), h = Math.abs(r.x - o.x), c = Math.abs(r.y - o.y), d = o.x <= r.x ? 1 : -1, l = o.y <= r.y ? 1 : -1;
59
59
  return {
60
60
  x: i,
61
61
  y: s,
62
62
  width: h,
63
- height: d,
64
- flipX: c,
63
+ height: c,
64
+ flipX: d,
65
65
  flipY: l
66
66
  };
67
- }, J = (e) => {
68
- const t = f(
67
+ }, Q = (e) => {
68
+ const t = v(
69
69
  { x: e.arrowLength, y: w.y },
70
70
  e.fromVect,
71
71
  w
72
- ), o = f(
72
+ ), o = v(
73
73
  { x: e.to.x - e.arrowLength, y: e.to.y },
74
74
  e.toVect,
75
75
  e.to
@@ -79,131 +79,131 @@ 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
- }, 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
- }, Q = (e) => {
85
- const t = e.hasSourceArrow ? f(
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} `, c = e.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${e.to.x} ${e.to.y}`;
83
+ return `${h}${s}${c}`;
84
+ }, Z = (e) => {
85
+ const t = e.hasSourceArrow ? v(
86
86
  { x: e.arrowLength, y: w.y },
87
87
  e.fromVect,
88
88
  w
89
- ) : w, o = e.hasTargetArrow ? f(
89
+ ) : w, o = e.hasTargetArrow ? v(
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, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, d = s * e.flipY, c = f(
93
+ ) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, s = Math.sin(e.detourDirection) * e.detourDistance, h = i * e.flipX, c = s * e.flipY, d = v(
94
94
  { x: r, y: w.y },
95
95
  e.fromVect,
96
96
  w
97
97
  ), l = {
98
- x: c.x + h,
99
- y: c.y + d
100
- }, a = f(
98
+ x: d.x + h,
99
+ y: d.y + c
100
+ }, a = v(
101
101
  { x: e.to.x - r, y: e.to.y },
102
102
  e.toVect,
103
103
  e.to
104
104
  ), g = {
105
105
  x: a.x + h,
106
- y: a.y + d
106
+ y: a.y + c
107
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
- }, v = {
108
+ x: d.x + e.curvature * e.fromVect.x,
109
+ y: d.y + e.curvature * e.fromVect.y
110
+ }, f = {
111
111
  x: a.x - e.curvature * e.toVect.x,
112
112
  y: a.y - e.curvature * e.toVect.y
113
- }, p = {
114
- x: c.x + h,
115
- y: c.y + d
116
- }, M = {
113
+ }, C = {
114
+ x: d.x + h,
115
+ y: d.y + c
116
+ }, E = {
117
117
  x: a.x + h,
118
- y: a.y + d
118
+ y: a.y + c
119
119
  };
120
120
  return [
121
121
  `M ${t.x} ${t.y}`,
122
- `L ${c.x} ${c.y}`,
123
- `C ${x.x} ${x.y} ${p.x} ${p.y} ${y.x} ${y.y}`,
124
- `C ${M.x} ${M.y} ${v.x} ${v.y} ${a.x} ${a.y}`,
122
+ `L ${d.x} ${d.y}`,
123
+ `C ${x.x} ${x.y} ${C.x} ${C.y} ${y.x} ${y.y}`,
124
+ `C ${E.x} ${E.y} ${f.x} ${f.y} ${a.x} ${a.y}`,
125
125
  `L ${o.x} ${o.y}`
126
126
  ].join(" ");
127
- }, Z = (e) => {
128
- const t = e.hasSourceArrow ? f(
127
+ }, O = (e) => {
128
+ const t = e.hasSourceArrow ? v(
129
129
  { x: e.arrowLength, y: w.y },
130
130
  e.fromVect,
131
131
  w
132
- ) : w, o = e.hasTargetArrow ? f(
132
+ ) : w, o = e.hasTargetArrow ? v(
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, s = f({ x: i, y: w.y }, e.fromVect, w), h = f(
136
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = v({ x: i, y: w.y }, e.fromVect, w), h = v(
137
137
  { x: e.to.x - i, y: e.to.y },
138
138
  e.toVect,
139
139
  e.to
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,
140
+ ), c = Math.max((s.x + h.x) / 2, r), d = e.to.y / 2, l = { x: e.flipX > 0 ? c : -r, y: s.y }, a = { x: l.x, y: d }, g = {
141
+ x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
142
142
  y: h.y
143
- }, y = { x: g.x, y: c };
144
- return N(
143
+ }, y = { x: g.x, y: d };
144
+ return P(
145
145
  [t, s, l, a, y, g, h, o],
146
146
  e.roundness
147
147
  );
148
- }, R = (e) => {
149
- const t = e.hasSourceArrow ? f(
148
+ }, Y = (e) => {
149
+ const t = e.hasSourceArrow ? v(
150
150
  { x: e.arrowLength, y: w.y },
151
151
  e.fromVect,
152
152
  w
153
- ) : w, o = e.hasTargetArrow ? f(
153
+ ) : w, o = e.hasTargetArrow ? v(
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, i = v(
158
158
  { x: r, y: w.y },
159
159
  e.fromVect,
160
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(
161
+ ), s = Math.cos(e.detourDirection) * e.detourDistance, h = Math.sin(e.detourDirection) * e.detourDistance, c = s * e.flipX, d = h * e.flipY, l = { x: i.x + c, y: i.y + d }, a = v(
162
162
  { x: e.to.x - r, y: e.to.y },
163
163
  e.toVect,
164
164
  e.to
165
- ), g = { x: a.x + d, y: a.y + c };
166
- return N(
165
+ ), g = { x: a.x + c, y: a.y + d };
166
+ return P(
167
167
  [t, i, l, g, a, o],
168
168
  e.roundness
169
169
  );
170
170
  }, q = (e) => {
171
- const t = e.hasSourceArrow ? f(
171
+ const t = e.hasSourceArrow ? v(
172
172
  { x: e.arrowLength, y: w.y },
173
173
  e.fromVect,
174
174
  w
175
- ) : w, o = e.hasTargetArrow ? f(
175
+ ) : w, o = e.hasTargetArrow ? v(
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: w.y }, e.fromVect, w), s = f(
179
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = v({ x: r, y: w.y }, e.fromVect, w), s = v(
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, s, o], e.roundness);
184
+ return P([t, i, s, o], e.roundness);
185
185
  }, tt = (e) => {
186
- const t = e.hasSourceArrow ? f(
186
+ const t = e.hasSourceArrow ? v(
187
187
  { x: e.arrowLength, y: w.y },
188
188
  e.fromVect,
189
189
  w
190
- ) : w, o = e.hasTargetArrow ? f(
190
+ ) : w, o = e.hasTargetArrow ? v(
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, s = f({ x: i, y: w.y }, e.fromVect, w), h = f(
194
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = r - e.roundness, s = v({ x: i, y: w.y }, e.fromVect, w), h = v(
195
195
  { x: e.to.x - i, y: e.to.y },
196
196
  e.toVect,
197
197
  e.to
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 = {
198
+ ), c = Math.max((s.y + h.y) / 2, r), d = e.to.x / 2, l = { x: s.x, y: e.flipY > 0 ? c : -r }, a = { x: d, y: l.y }, g = {
199
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 N(
200
+ y: e.flipY > 0 ? e.to.y - c : e.to.y + r
201
+ }, y = { x: d, y: g.y };
202
+ return P(
203
203
  [t, s, l, a, y, g, h, o],
204
204
  e.roundness
205
205
  );
206
- }, Y = (e) => {
206
+ }, X = (e) => {
207
207
  const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, h = [
208
208
  { x: e.arrowLength, y: w.y },
209
209
  { x: r, y: w.y },
@@ -214,20 +214,20 @@ const _ = (e, t) => ({
214
214
  { x: r, y: w.y },
215
215
  { x: e.arrowLength, y: w.y }
216
216
  ].map(
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}${N(h, e.roundness)}`;
217
+ (d) => v(d, e.fromVect, w)
218
+ ), c = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
219
+ return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${P(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, s = e.arrowLength + r * (1 - o / i), h = t * o / i, c = [
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, d = [
222
222
  { x: e.arrowLength, y: w.y },
223
223
  { x: s, y: h },
224
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} `;
225
+ ].map((g) => v(g, e.fromVect, w)), l = [
226
+ `M ${d[0].x} ${d[0].y}`,
227
+ `A ${t} ${t} 0 0 1 ${d[1].x} ${d[1].y}`,
228
+ `A ${o} ${o} 0 1 0 ${d[2].x} ${d[2].y}`,
229
+ `A ${t} ${t} 0 0 1 ${d[0].x} ${d[0].y}`
230
+ ].join(" "), a = `M 0 0 L ${d[0].x} ${d[0].y} `;
231
231
  return `${e.hasSourceArrow || e.hasTargetArrow ? "" : a}${l}`;
232
232
  }, u = Object.freeze({
233
233
  color: "#5c5c5c",
@@ -248,8 +248,8 @@ const _ = (e, t) => ({
248
248
  });
249
249
  class ot {
250
250
  constructor(t) {
251
- n(this, "svg", I());
252
- n(this, "group", $());
251
+ n(this, "svg", $());
252
+ n(this, "group", p());
253
253
  n(this, "line");
254
254
  n(this, "sourceArrow", null);
255
255
  n(this, "targetArrow", null);
@@ -264,78 +264,78 @@ class ot {
264
264
  n(this, "hasTargetArrow");
265
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
266
  const o = (t == null ? void 0 : t.color) ?? u.color, r = (t == null ? void 0 : t.width) ?? u.width;
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
+ this.svg.appendChild(this.group), this.line = b(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(o), this.group.appendChild(this.targetArrow));
268
268
  }
269
269
  render(t) {
270
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
270
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
271
271
  t.source,
272
272
  t.target
273
273
  );
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(
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}, ${c})`;
275
+ const d = A(
276
276
  t.source.direction,
277
277
  h,
278
- d
278
+ c
279
279
  ), l = A(
280
280
  t.target.direction,
281
281
  h,
282
- d
282
+ c
283
283
  ), a = {
284
284
  x: i,
285
285
  y: s
286
286
  };
287
287
  let g, y = l, x = -this.arrowLength;
288
288
  if (t.source.portId === t.target.portId ? (g = et({
289
- fromVect: c,
289
+ fromVect: d,
290
290
  radius: this.portCycleRadius,
291
291
  smallRadius: this.portCycleSmallRadius,
292
292
  arrowLength: this.arrowLength,
293
293
  hasSourceArrow: this.hasSourceArrow,
294
294
  hasTargetArrow: this.hasTargetArrow
295
- }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Q({
295
+ }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Z({
296
296
  to: a,
297
- fromVect: c,
297
+ fromVect: d,
298
298
  toVect: l,
299
299
  flipX: h,
300
- flipY: d,
300
+ flipY: c,
301
301
  arrowLength: this.arrowLength,
302
302
  detourDirection: this.detourDirection,
303
303
  detourDistance: this.detourDistance,
304
304
  curvature: this.curvature,
305
305
  hasSourceArrow: this.hasSourceArrow,
306
306
  hasTargetArrow: this.hasTargetArrow
307
- }) : g = J({
307
+ }) : g = Q({
308
308
  to: a,
309
- fromVect: c,
309
+ fromVect: d,
310
310
  toVect: l,
311
311
  arrowLength: this.arrowLength,
312
312
  curvature: this.curvature,
313
313
  hasSourceArrow: this.hasSourceArrow,
314
314
  hasTargetArrow: this.hasTargetArrow
315
315
  }), this.line.setAttribute("d", g), this.sourceArrow) {
316
- const v = E(
317
- c,
316
+ const f = T(
317
+ d,
318
318
  w,
319
319
  this.arrowLength,
320
320
  this.arrowWidth
321
321
  );
322
- this.sourceArrow.setAttribute("d", v);
322
+ this.sourceArrow.setAttribute("d", f);
323
323
  }
324
324
  if (this.targetArrow) {
325
- const v = E(
325
+ const f = T(
326
326
  y,
327
327
  a,
328
328
  x,
329
329
  this.arrowWidth
330
330
  );
331
- this.targetArrow.setAttribute("d", v);
331
+ this.targetArrow.setAttribute("d", f);
332
332
  }
333
333
  }
334
334
  }
335
335
  class rt {
336
336
  constructor(t) {
337
- n(this, "svg", I());
338
- n(this, "group", $());
337
+ n(this, "svg", $());
338
+ n(this, "group", p());
339
339
  n(this, "line");
340
340
  n(this, "sourceArrow", null);
341
341
  n(this, "targetArrow", null);
@@ -356,41 +356,41 @@ class rt {
356
356
  this.cycleSquareSide / 2
357
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
358
  const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
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
+ this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
360
360
  }
361
361
  render(t) {
362
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
362
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
363
363
  t.source,
364
364
  t.target
365
365
  );
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(
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}, ${c})`;
367
+ const d = A(
368
368
  t.source.direction,
369
369
  h,
370
- d
370
+ c
371
371
  ), l = A(
372
372
  t.target.direction,
373
373
  h,
374
- d
374
+ c
375
375
  ), a = {
376
376
  x: i,
377
377
  y: s
378
378
  };
379
379
  let g, y = l, x = -this.arrowLength;
380
- if (t.source.portId === t.target.portId ? (g = Y({
381
- fromVect: c,
380
+ if (t.source.portId === t.target.portId ? (g = X({
381
+ fromVect: d,
382
382
  arrowLength: this.arrowLength,
383
383
  side: this.cycleSquareSide,
384
384
  arrowOffset: this.arrowOffset,
385
385
  roundness: this.roundness,
386
386
  hasSourceArrow: this.hasSourceArrow,
387
387
  hasTargetArrow: this.hasTargetArrow
388
- }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
388
+ }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
389
389
  to: a,
390
- fromVect: c,
390
+ fromVect: d,
391
391
  toVect: l,
392
392
  flipX: h,
393
- flipY: d,
393
+ flipY: c,
394
394
  arrowLength: this.arrowLength,
395
395
  arrowOffset: this.arrowOffset,
396
396
  roundness: this.roundness,
@@ -398,9 +398,9 @@ class rt {
398
398
  detourDistance: this.detourDistance,
399
399
  hasSourceArrow: this.hasSourceArrow,
400
400
  hasTargetArrow: this.hasTargetArrow
401
- }) : g = Z({
401
+ }) : g = O({
402
402
  to: a,
403
- fromVect: c,
403
+ fromVect: d,
404
404
  toVect: l,
405
405
  flipX: h,
406
406
  arrowLength: this.arrowLength,
@@ -409,29 +409,29 @@ class rt {
409
409
  hasSourceArrow: this.hasSourceArrow,
410
410
  hasTargetArrow: this.hasTargetArrow
411
411
  }), this.line.setAttribute("d", g), this.sourceArrow) {
412
- const v = E(
413
- c,
412
+ const f = T(
413
+ d,
414
414
  w,
415
415
  this.arrowLength,
416
416
  this.arrowWidth
417
417
  );
418
- this.sourceArrow.setAttribute("d", v);
418
+ this.sourceArrow.setAttribute("d", f);
419
419
  }
420
420
  if (this.targetArrow) {
421
- const v = E(
421
+ const f = T(
422
422
  y,
423
423
  a,
424
424
  x,
425
425
  this.arrowWidth
426
426
  );
427
- this.targetArrow.setAttribute("d", v);
427
+ this.targetArrow.setAttribute("d", f);
428
428
  }
429
429
  }
430
430
  }
431
431
  class it {
432
432
  constructor(t) {
433
- n(this, "svg", I());
434
- n(this, "group", $());
433
+ n(this, "svg", $());
434
+ n(this, "group", p());
435
435
  n(this, "line");
436
436
  n(this, "sourceArrow", null);
437
437
  n(this, "targetArrow", null);
@@ -452,41 +452,41 @@ class it {
452
452
  this.cycleSquareSide / 2
453
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
454
  const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
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
+ this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
456
456
  }
457
457
  render(t) {
458
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
458
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
459
459
  t.source,
460
460
  t.target
461
461
  );
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(
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}, ${c})`;
463
+ const d = A(
464
464
  t.source.direction,
465
465
  h,
466
- d
466
+ c
467
467
  ), l = A(
468
468
  t.target.direction,
469
469
  h,
470
- d
470
+ c
471
471
  ), a = {
472
472
  x: i,
473
473
  y: s
474
474
  };
475
475
  let g, y = l, x = -this.arrowLength;
476
- if (t.source.portId === t.target.portId ? (g = Y({
477
- fromVect: c,
476
+ if (t.source.portId === t.target.portId ? (g = X({
477
+ fromVect: d,
478
478
  arrowLength: this.arrowLength,
479
479
  side: this.cycleSquareSide,
480
480
  arrowOffset: this.arrowOffset,
481
481
  roundness: this.roundness,
482
482
  hasSourceArrow: this.hasSourceArrow,
483
483
  hasTargetArrow: this.hasTargetArrow
484
- }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
484
+ }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
485
485
  to: a,
486
- fromVect: c,
486
+ fromVect: d,
487
487
  toVect: l,
488
488
  flipX: h,
489
- flipY: d,
489
+ flipY: c,
490
490
  arrowLength: this.arrowLength,
491
491
  arrowOffset: this.arrowOffset,
492
492
  roundness: this.roundness,
@@ -496,7 +496,7 @@ class it {
496
496
  hasTargetArrow: this.hasTargetArrow
497
497
  }) : g = q({
498
498
  to: a,
499
- fromVect: c,
499
+ fromVect: d,
500
500
  toVect: l,
501
501
  arrowLength: this.arrowLength,
502
502
  arrowOffset: this.arrowOffset,
@@ -504,29 +504,29 @@ class it {
504
504
  hasSourceArrow: this.hasSourceArrow,
505
505
  hasTargetArrow: this.hasTargetArrow
506
506
  }), this.line.setAttribute("d", g), this.sourceArrow) {
507
- const v = E(
508
- c,
507
+ const f = T(
508
+ d,
509
509
  w,
510
510
  this.arrowLength,
511
511
  this.arrowWidth
512
512
  );
513
- this.sourceArrow.setAttribute("d", v);
513
+ this.sourceArrow.setAttribute("d", f);
514
514
  }
515
515
  if (this.targetArrow) {
516
- const v = E(
516
+ const f = T(
517
517
  y,
518
518
  a,
519
519
  x,
520
520
  this.arrowWidth
521
521
  );
522
- this.targetArrow.setAttribute("d", v);
522
+ this.targetArrow.setAttribute("d", f);
523
523
  }
524
524
  }
525
525
  }
526
526
  class nt {
527
527
  constructor(t) {
528
- n(this, "svg", I());
529
- n(this, "group", $());
528
+ n(this, "svg", $());
529
+ n(this, "group", p());
530
530
  n(this, "line");
531
531
  n(this, "sourceArrow", null);
532
532
  n(this, "targetArrow", null);
@@ -547,41 +547,41 @@ class nt {
547
547
  this.cycleSquareSide / 2
548
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
549
  const r = (t == null ? void 0 : t.color) ?? u.color, i = (t == null ? void 0 : t.width) ?? u.width;
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
+ this.svg.appendChild(this.group), this.line = b(r, i), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = M(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = M(r), this.group.appendChild(this.targetArrow));
551
551
  }
552
552
  render(t) {
553
- const { x: o, y: r, width: i, height: s, flipX: h, flipY: d } = b(
553
+ const { x: o, y: r, width: i, height: s, flipX: h, flipY: c } = V(
554
554
  t.source,
555
555
  t.target
556
556
  );
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(
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}, ${c})`;
558
+ const d = A(
559
559
  t.source.direction,
560
560
  h,
561
- d
561
+ c
562
562
  ), l = A(
563
563
  t.target.direction,
564
564
  h,
565
- d
565
+ c
566
566
  ), a = {
567
567
  x: i,
568
568
  y: s
569
569
  };
570
570
  let g, y = l, x = -this.arrowLength;
571
- if (t.source.portId === t.target.portId ? (g = Y({
572
- fromVect: c,
571
+ if (t.source.portId === t.target.portId ? (g = X({
572
+ fromVect: d,
573
573
  arrowLength: this.arrowLength,
574
574
  side: this.cycleSquareSide,
575
575
  arrowOffset: this.arrowOffset,
576
576
  roundness: this.roundness,
577
577
  hasSourceArrow: this.hasSourceArrow,
578
578
  hasTargetArrow: this.hasTargetArrow
579
- }), y = c, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = R({
579
+ }), y = d, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? g = Y({
580
580
  to: a,
581
- fromVect: c,
581
+ fromVect: d,
582
582
  toVect: l,
583
583
  flipX: h,
584
- flipY: d,
584
+ flipY: c,
585
585
  arrowLength: this.arrowLength,
586
586
  arrowOffset: this.arrowOffset,
587
587
  roundness: this.roundness,
@@ -591,31 +591,31 @@ class nt {
591
591
  hasTargetArrow: this.hasTargetArrow
592
592
  }) : g = tt({
593
593
  to: a,
594
- fromVect: c,
594
+ fromVect: d,
595
595
  toVect: l,
596
- flipY: d,
596
+ flipY: c,
597
597
  arrowLength: this.arrowLength,
598
598
  arrowOffset: this.arrowOffset,
599
599
  roundness: this.roundness,
600
600
  hasSourceArrow: this.hasSourceArrow,
601
601
  hasTargetArrow: this.hasTargetArrow
602
602
  }), this.line.setAttribute("d", g), this.sourceArrow) {
603
- const v = E(
604
- c,
603
+ const f = T(
604
+ d,
605
605
  w,
606
606
  this.arrowLength,
607
607
  this.arrowWidth
608
608
  );
609
- this.sourceArrow.setAttribute("d", v);
609
+ this.sourceArrow.setAttribute("d", f);
610
610
  }
611
611
  if (this.targetArrow) {
612
- const v = E(
612
+ const f = T(
613
613
  y,
614
614
  a,
615
615
  x,
616
616
  this.arrowWidth
617
617
  );
618
- this.targetArrow.setAttribute("d", v);
618
+ this.targetArrow.setAttribute("d", f);
619
619
  }
620
620
  }
621
621
  }
@@ -680,18 +680,18 @@ const st = (e) => {
680
680
  detourDirection: e.detourDirection
681
681
  });
682
682
  }
683
- }, F = (e) => () => e, G = F(0), V = () => {
683
+ }, R = (e) => () => e, G = R(0), W = () => {
684
684
  let e = 0;
685
685
  return () => e++;
686
686
  }, ht = (e, t) => {
687
687
  let o = G, r = G;
688
- e === "incremental" && (o = V()), t === "incremental" && (r = V());
689
- const i = V();
690
- 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), {
688
+ e === "incremental" && (o = W()), t === "incremental" && (r = W());
689
+ const i = W();
690
+ return e === "shared-incremental" && (o = i), t === "shared-incremental" && (r = i), typeof e == "number" && (o = R(e)), typeof t == "number" && (r = R(t)), typeof e == "function" && (o = e), typeof t == "function" && (r = t), {
691
691
  nodesPriorityFn: o,
692
692
  edgesPriorityFn: r
693
693
  };
694
- }, dt = (e) => {
694
+ }, ct = (e) => {
695
695
  var o, r, i, s, h;
696
696
  const t = ht(
697
697
  (o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
@@ -699,7 +699,7 @@ const st = (e) => {
699
699
  );
700
700
  return {
701
701
  nodes: {
702
- centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? _,
702
+ centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? J,
703
703
  priorityFn: t.nodesPriorityFn
704
704
  },
705
705
  ports: {
@@ -711,7 +711,7 @@ const st = (e) => {
711
711
  }
712
712
  };
713
713
  };
714
- class ct {
714
+ class dt {
715
715
  constructor() {
716
716
  n(this, "nodes", /* @__PURE__ */ new Map());
717
717
  n(this, "ports", /* @__PURE__ */ new Map());
@@ -1017,8 +1017,8 @@ class ft {
1017
1017
  this.clear(), this.detach(), this.host.removeChild(this.container);
1018
1018
  }
1019
1019
  updateNodeCoordinates(t) {
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)`;
1020
+ const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: s } = r.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, c = r.centerFn(i, s), d = r.x - h * c.x, l = r.y - h * c.y;
1021
+ o.style.transform = `translate(${d}px, ${l}px)`;
1022
1022
  }
1023
1023
  updateNodePriority(t) {
1024
1024
  const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
@@ -1031,25 +1031,25 @@ class ft {
1031
1031
  this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
1032
1032
  }
1033
1033
  renderEdge(t) {
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
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(), c = this.host.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix(), l = {
1035
+ x: d.scale * (s.left - c.left) + d.dx,
1036
+ y: d.scale * (s.top - c.top) + d.dy
1037
1037
  }, a = {
1038
- x: c.scale * (h.left - d.left) + c.dx,
1039
- y: c.scale * (h.top - d.top) + c.dy
1038
+ x: d.scale * (h.left - c.left) + d.dx,
1039
+ y: d.scale * (h.top - c.top) + d.dy
1040
1040
  }, g = {
1041
1041
  x: l.x,
1042
1042
  y: l.y,
1043
- width: s.width * c.scale,
1044
- height: s.height * c.scale,
1043
+ width: s.width * d.scale,
1044
+ height: s.height * d.scale,
1045
1045
  direction: r.direction,
1046
1046
  portId: o.from,
1047
1047
  nodeId: this.graphStore.getPortNodeId(o.from)
1048
1048
  }, y = {
1049
1049
  x: a.x,
1050
1050
  y: a.y,
1051
- width: h.width * c.scale,
1052
- height: h.height * c.scale,
1051
+ width: h.width * d.scale,
1052
+ height: h.height * d.scale,
1053
1053
  direction: i.direction,
1054
1054
  portId: o.to,
1055
1055
  nodeId: this.graphStore.getPortNodeId(o.to)
@@ -1064,7 +1064,7 @@ class ft {
1064
1064
  o.shape.svg.style.zIndex = `${o.priority}`;
1065
1065
  }
1066
1066
  }
1067
- class C {
1067
+ class L {
1068
1068
  constructor(t) {
1069
1069
  n(this, "counter", 0);
1070
1070
  this.checkExists = t;
@@ -1087,17 +1087,17 @@ class S extends Error {
1087
1087
  }
1088
1088
  }
1089
1089
  class vt {
1090
- constructor(t, o, r, i, s, h, d) {
1091
- n(this, "nodeIdGenerator", new C(
1090
+ constructor(t, o, r, i, s, h, c) {
1091
+ n(this, "nodeIdGenerator", new L(
1092
1092
  (t) => this.graphStore.getNode(t) !== void 0
1093
1093
  ));
1094
- n(this, "portIdGenerator", new C(
1094
+ n(this, "portIdGenerator", new L(
1095
1095
  (t) => this.graphStore.getPort(t) !== void 0
1096
1096
  ));
1097
- n(this, "edgeIdGenerator", new C(
1097
+ n(this, "edgeIdGenerator", new L(
1098
1098
  (t) => this.graphStore.getEdge(t) !== void 0
1099
1099
  ));
1100
- this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = d;
1100
+ this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = s, this.defaultNodesPriorityFn = h, this.defaultEdgesPriorityFn = c;
1101
1101
  }
1102
1102
  attach(t) {
1103
1103
  this.htmlController.attach(t);
@@ -1215,7 +1215,7 @@ class xt {
1215
1215
  n(this, "canvasController");
1216
1216
  n(this, "edgeShapeFactory");
1217
1217
  this.apiOptions = t;
1218
- const o = dt(this.apiOptions), r = new at(), i = new ct();
1218
+ const o = ct(this.apiOptions), r = new at(), i = new dt();
1219
1219
  this.model = new lt(i), this.transformation = new gt(r);
1220
1220
  const s = new ft(i, r);
1221
1221
  this.canvasController = new vt(
@@ -1306,41 +1306,52 @@ class xt {
1306
1306
  this.clear(), this.canvasController.destroy();
1307
1307
  }
1308
1308
  }
1309
- const P = (e, t, o) => {
1309
+ const D = (e, t, o) => {
1310
1310
  const { x: r, y: i, width: s, height: h } = e.getBoundingClientRect();
1311
1311
  return t >= r && t <= r + s && o >= i && o <= i + h;
1312
- }, L = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, D = (e, t) => {
1312
+ }, I = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, m = (e, t) => {
1313
1313
  t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
1314
+ }, St = (e) => {
1315
+ var g, y, x, f, C, E;
1316
+ const t = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1317
+ }), o = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onNodeDragFinished) ?? (() => {
1318
+ }), i = (e == null ? void 0 : e.moveOnTop) === !1, s = (f = e == null ? void 0 : e.mouse) == null ? void 0 : f.dragCursor, h = s !== void 0 ? s : "grab", c = (C = e == null ? void 0 : e.mouse) == null ? void 0 : C.mouseDownEventValidator, d = c !== void 0 ? c : (N) => N.button === 0, l = (E = e == null ? void 0 : e.mouse) == null ? void 0 : E.mouseUpEventValidator;
1319
+ return {
1320
+ freezePriority: i,
1321
+ dragCursor: h,
1322
+ mouseDownEventValidator: d,
1323
+ mouseUpEventValidator: l !== void 0 ? l : (N) => N.button === 0,
1324
+ onNodeDrag: t,
1325
+ onBeforeNodeDrag: o,
1326
+ onNodeDragFinished: r
1327
+ };
1314
1328
  };
1315
- class St {
1329
+ class Et {
1316
1330
  constructor(t, o) {
1317
1331
  n(this, "model");
1318
1332
  n(this, "transformation");
1319
1333
  n(this, "maxNodePriority", 0);
1320
1334
  n(this, "nodes", /* @__PURE__ */ new Map());
1321
1335
  n(this, "grabbedNodeId", null);
1322
- n(this, "onNodeDrag");
1323
- n(this, "onBeforeNodeDrag");
1324
- n(this, "onNodeDragFinished");
1325
- n(this, "nodeIdGenerator", new C(
1336
+ n(this, "nodeIdGenerator", new L(
1326
1337
  (t) => this.nodes.has(t)
1327
1338
  ));
1328
1339
  n(this, "element", null);
1329
1340
  n(this, "onWindowMouseMove", (t) => {
1330
- if (this.element !== null && (!P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY))) {
1341
+ if (this.element !== null && (!D(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY))) {
1331
1342
  this.cancelMouseDrag();
1332
1343
  return;
1333
1344
  }
1334
1345
  this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
1335
1346
  });
1336
1347
  n(this, "onWindowMouseUp", (t) => {
1337
- t.button === 0 && this.cancelMouseDrag();
1348
+ this.options.mouseUpEventValidator(t) && this.cancelMouseDrag();
1338
1349
  });
1339
1350
  n(this, "onWindowTouchMove", (t) => {
1340
1351
  if (t.touches.length !== 1)
1341
1352
  return;
1342
1353
  const o = t.touches[0];
1343
- if (this.element !== null && (!P(this.element, o.clientX, o.clientY) || !L(this.window, o.clientX, o.clientY))) {
1354
+ if (this.element !== null && (!D(this.element, o.clientX, o.clientY) || !I(this.window, o.clientX, o.clientY))) {
1344
1355
  this.cancelTouchDrag();
1345
1356
  return;
1346
1357
  }
@@ -1356,13 +1367,9 @@ class St {
1356
1367
  this.previousTouchCoords = null, this.cancelTouchDrag();
1357
1368
  });
1358
1369
  n(this, "previousTouchCoords", null);
1359
- n(this, "freezePriority");
1360
1370
  n(this, "window", window);
1361
- n(this, "dragCursor");
1362
- var r, i, s;
1363
- 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) ?? (() => {
1364
- }), 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) ?? (() => {
1365
- }), this.freezePriority = (o == null ? void 0 : o.moveOnTop) === !1, this.dragCursor = (o == null ? void 0 : o.dragCursor) !== void 0 ? o.dragCursor : "grab";
1371
+ n(this, "options");
1372
+ this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.options = St(o ?? {});
1366
1373
  }
1367
1374
  attach(t) {
1368
1375
  return this.detach(), this.element = t, this.canvas.attach(this.element), this;
@@ -1374,15 +1381,15 @@ class St {
1374
1381
  const o = this.nodeIdGenerator.create(t.id);
1375
1382
  this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
1376
1383
  const r = (s) => {
1377
- if (this.element === null || s.button !== 0)
1384
+ if (this.element === null || !this.options.mouseDownEventValidator(s))
1378
1385
  return;
1379
1386
  const h = this.model.getNode(o);
1380
- this.onBeforeNodeDrag({
1387
+ this.options.onBeforeNodeDrag({
1381
1388
  nodeId: o,
1382
1389
  element: t.element,
1383
1390
  x: h.x,
1384
1391
  y: h.y
1385
- }) && (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));
1392
+ }) && (s.stopImmediatePropagation(), this.grabbedNodeId = o, m(this.element, this.options.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1386
1393
  }, i = (s) => {
1387
1394
  if (s.touches.length !== 1)
1388
1395
  return;
@@ -1391,7 +1398,7 @@ class St {
1391
1398
  y: s.touches[0].clientY
1392
1399
  };
1393
1400
  const h = this.model.getNode(o);
1394
- this.onBeforeNodeDrag({
1401
+ this.options.onBeforeNodeDrag({
1395
1402
  nodeId: o,
1396
1403
  element: t.element,
1397
1404
  x: h.x,
@@ -1447,8 +1454,8 @@ class St {
1447
1454
  const i = this.model.getNode(t);
1448
1455
  if (i === null)
1449
1456
  return;
1450
- 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;
1451
- this.canvas.updateNode(t, { x: g, y }), this.onNodeDrag({
1457
+ const s = this.canvas.transformation.getContentMatrix(), h = s.scale * i.x + s.dx, c = s.scale * i.y + s.dy, d = h + o, l = c + r, a = this.canvas.transformation.getViewportMatrix(), g = a.scale * d + a.dx, y = a.scale * l + a.dy;
1458
+ this.canvas.updateNode(t, { x: g, y }), this.options.onNodeDrag({
1452
1459
  nodeId: t,
1453
1460
  element: i.element,
1454
1461
  x: i.x,
@@ -1460,7 +1467,7 @@ class St {
1460
1467
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
1461
1468
  }
1462
1469
  moveNodeOnTop(t) {
1463
- if (this.freezePriority)
1470
+ if (this.options.freezePriority)
1464
1471
  return;
1465
1472
  this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
1466
1473
  const o = this.maxNodePriority - 1;
@@ -1470,12 +1477,12 @@ class St {
1470
1477
  }
1471
1478
  cancelMouseDrag() {
1472
1479
  const t = this.model.getNode(this.grabbedNodeId);
1473
- t !== null && this.onNodeDragFinished({
1480
+ t !== null && this.options.onNodeDragFinished({
1474
1481
  nodeId: this.grabbedNodeId,
1475
1482
  element: t.element,
1476
1483
  x: t.x,
1477
1484
  y: t.y
1478
- }), this.grabbedNodeId = null, this.element !== null && D(this.element, null), this.removeMouseDragListeners();
1485
+ }), this.grabbedNodeId = null, this.element !== null && m(this.element, null), this.removeMouseDragListeners();
1479
1486
  }
1480
1487
  removeMouseDragListeners() {
1481
1488
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -1483,7 +1490,7 @@ class St {
1483
1490
  cancelTouchDrag() {
1484
1491
  this.previousTouchCoords = null;
1485
1492
  const t = this.model.getNode(this.grabbedNodeId);
1486
- t !== null && this.onNodeDragFinished({
1493
+ t !== null && this.options.onNodeDragFinished({
1487
1494
  nodeId: this.grabbedNodeId,
1488
1495
  element: t.element,
1489
1496
  x: t.x,
@@ -1497,35 +1504,35 @@ class St {
1497
1504
  const At = (e) => {
1498
1505
  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;
1499
1506
  return (s) => {
1500
- let h = s.nextTransform.dx, d = s.nextTransform.dy;
1507
+ let h = s.nextTransform.dx, c = s.nextTransform.dy;
1501
1508
  h < t && h < s.prevTransform.dx && (h = Math.min(s.prevTransform.dx, t));
1502
- const c = s.canvasWidth * s.prevTransform.scale;
1503
- 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));
1509
+ const d = s.canvasWidth * s.prevTransform.scale;
1510
+ h > o - d && h > s.prevTransform.dx && (h = Math.max(s.prevTransform.dx, o - d)), c < r && c < s.prevTransform.dy && (c = Math.min(s.prevTransform.dy, r));
1504
1511
  const l = s.canvasHeight * s.prevTransform.scale;
1505
- return d > i - l && d > s.prevTransform.dy && (d = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: d };
1512
+ return c > i - l && c > s.prevTransform.dy && (c = Math.max(s.prevTransform.dy, i - l)), { scale: s.nextTransform.scale, dx: h, dy: c };
1506
1513
  };
1507
- }, Et = (e) => {
1514
+ }, Tt = (e) => {
1508
1515
  const t = e.maxContentScale, o = e.minContentScale, r = t !== null ? 1 / t : 0, i = o !== null ? 1 / o : 1 / 0;
1509
1516
  return (s) => {
1510
- const h = s.prevTransform, d = s.nextTransform;
1511
- let c = d.scale, l = d.dx, a = d.dy;
1512
- if (d.scale > i && d.scale > h.scale) {
1513
- c = Math.max(h.scale, i), l = h.dx, a = h.dy;
1514
- const g = (c - h.scale) / (d.scale - h.scale);
1515
- l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
1517
+ const h = s.prevTransform, c = s.nextTransform;
1518
+ let d = c.scale, l = c.dx, a = c.dy;
1519
+ if (c.scale > i && c.scale > h.scale) {
1520
+ d = Math.max(h.scale, i), l = h.dx, a = h.dy;
1521
+ const g = (d - h.scale) / (c.scale - h.scale);
1522
+ l = h.dx + (c.dx - h.dx) * g, a = h.dy + (c.dy - h.dy) * g;
1516
1523
  }
1517
- if (d.scale < r && d.scale < h.scale) {
1518
- c = Math.min(h.scale, r), l = h.dx, a = h.dy;
1519
- const g = (c - h.scale) / (d.scale - h.scale);
1520
- l = h.dx + (d.dx - h.dx) * g, a = h.dy + (d.dy - h.dy) * g;
1524
+ if (c.scale < r && c.scale < h.scale) {
1525
+ d = Math.min(h.scale, r), l = h.dx, a = h.dy;
1526
+ const g = (d - h.scale) / (c.scale - h.scale);
1527
+ l = h.dx + (c.dx - h.dx) * g, a = h.dy + (c.dy - h.dy) * g;
1521
1528
  }
1522
1529
  return {
1523
- scale: c,
1530
+ scale: d,
1524
1531
  dx: l,
1525
1532
  dy: a
1526
1533
  };
1527
1534
  };
1528
- }, Tt = (e) => (t) => e.reduce(
1535
+ }, Mt = (e) => (t) => e.reduce(
1529
1536
  (o, r) => r({
1530
1537
  prevTransform: t.prevTransform,
1531
1538
  nextTransform: o,
@@ -1538,7 +1545,7 @@ const At = (e) => {
1538
1545
  return e;
1539
1546
  switch (e.type) {
1540
1547
  case "scale-limit":
1541
- return Et({
1548
+ return Tt({
1542
1549
  minContentScale: e.minContentScale ?? 0,
1543
1550
  maxContentScale: e.maxContentScale ?? 1 / 0
1544
1551
  });
@@ -1550,34 +1557,38 @@ const At = (e) => {
1550
1557
  maxY: e.maxY ?? 1 / 0
1551
1558
  });
1552
1559
  }
1553
- }, Mt = (e) => {
1554
- var c, l, a, g;
1555
- 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;
1560
+ }, Ct = (e) => {
1561
+ var d, l, a, g, y, x;
1562
+ const t = (d = e == null ? void 0 : e.scale) == null ? void 0 : d.mouseWheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1556
1563
  let i;
1557
- r !== void 0 ? Array.isArray(r) ? i = Tt(
1564
+ r !== void 0 ? Array.isArray(r) ? i = Mt(
1558
1565
  r.map(
1559
- (y) => U(y)
1566
+ (f) => U(f)
1560
1567
  )
1561
- ) : i = U(r) : i = (y) => y.nextTransform;
1568
+ ) : i = U(r) : i = (f) => f.nextTransform;
1562
1569
  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.onBeforeTransformChange) ?? (() => {
1563
- }), d = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformChange) ?? (() => {
1570
+ }), c = ((g = e == null ? void 0 : e.events) == null ? void 0 : g.onTransformChange) ?? (() => {
1564
1571
  });
1565
1572
  return {
1566
1573
  wheelSensitivity: o,
1567
- onBeforeTransformStarted: h,
1568
- onTransformFinished: d,
1574
+ onTransformStarted: ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onTransformStarted) ?? (() => {
1575
+ }),
1576
+ onTransformFinished: ((x = e == null ? void 0 : e.events) == null ? void 0 : x.onTransformFinished) ?? (() => {
1577
+ }),
1578
+ onBeforeTransformChange: h,
1579
+ onTransformChange: c,
1569
1580
  transformPreprocessor: i,
1570
1581
  shiftCursor: s
1571
1582
  };
1572
- }, W = (e) => {
1583
+ }, F = (e) => {
1573
1584
  const t = [], o = e.touches.length;
1574
- for (let d = 0; d < o; d++)
1575
- t.push([e.touches[d].clientX, e.touches[d].clientY]);
1585
+ for (let c = 0; c < o; c++)
1586
+ t.push([e.touches[c].clientX, e.touches[c].clientY]);
1576
1587
  const r = t.reduce(
1577
- (d, c) => [d[0] + c[0], d[1] + c[1]],
1588
+ (c, d) => [c[0] + d[0], c[1] + d[1]],
1578
1589
  [0, 0]
1579
- ), i = [r[0] / o, r[1] / o], h = t.map((d) => [d[0] - i[0], d[1] - i[1]]).reduce(
1580
- (d, c) => d + Math.sqrt(c[0] * c[0] + c[1] * c[1]),
1590
+ ), i = [r[0] / o, r[1] / o], h = t.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
1591
+ (c, d) => c + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1581
1592
  0
1582
1593
  );
1583
1594
  return {
@@ -1587,11 +1598,11 @@ const At = (e) => {
1587
1598
  touchesCnt: o,
1588
1599
  touches: t
1589
1600
  };
1590
- }, Ct = (e, t, o) => ({
1601
+ }, Nt = (e, t, o) => ({
1591
1602
  scale: e.scale,
1592
1603
  dx: e.dx + e.scale * t,
1593
1604
  dy: e.dy + e.scale * o
1594
- }), Nt = (e, t, o, r) => ({
1605
+ }), Lt = (e, t, o, r) => ({
1595
1606
  scale: e.scale * t,
1596
1607
  dx: e.scale * (1 - t) * o + e.dx,
1597
1608
  dy: e.scale * (1 - t) * r + e.dy
@@ -1604,10 +1615,10 @@ class Pt {
1604
1615
  n(this, "prevTouches", null);
1605
1616
  n(this, "window", window);
1606
1617
  n(this, "onMouseDown", (t) => {
1607
- this.element === null || t.button !== 0 || (D(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
1618
+ this.element === null || t.button !== 0 || (m(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.options.onTransformStarted());
1608
1619
  });
1609
1620
  n(this, "onWindowMouseMove", (t) => {
1610
- if (this.element === null || !P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY)) {
1621
+ if (this.element === null || !D(this.element, t.clientX, t.clientY) || !I(this.window, t.clientX, t.clientY)) {
1611
1622
  this.stopMouseDrag();
1612
1623
  return;
1613
1624
  }
@@ -1619,19 +1630,19 @@ class Pt {
1619
1630
  });
1620
1631
  n(this, "onWheelScroll", (t) => {
1621
1632
  t.preventDefault();
1622
- 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);
1623
- this.scaleViewport(this.element, d, i, s);
1633
+ const { left: o, top: r } = this.element.getBoundingClientRect(), i = t.clientX - o, s = t.clientY - r, c = 1 / (t.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1634
+ this.scaleViewport(this.element, c, i, s);
1624
1635
  });
1625
1636
  n(this, "onTouchStart", (t) => {
1626
- this.prevTouches = W(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
1637
+ this.prevTouches = F(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.options.onTransformStarted();
1627
1638
  });
1628
1639
  n(this, "onWindowTouchMove", (t) => {
1629
1640
  const o = this.element;
1630
1641
  if (o === null)
1631
1642
  return;
1632
- const r = W(t);
1643
+ const r = F(t);
1633
1644
  if (!r.touches.every(
1634
- (s) => P(o, s[0], s[1]) && L(this.window, s[0], s[1])
1645
+ (s) => D(o, s[0], s[1]) && I(this.window, s[0], s[1])
1635
1646
  )) {
1636
1647
  this.stopTouchDrag();
1637
1648
  return;
@@ -1641,13 +1652,13 @@ class Pt {
1641
1652
  -(r.x - this.prevTouches.x),
1642
1653
  -(r.y - this.prevTouches.y)
1643
1654
  ), r.touchesCnt === 2) {
1644
- const { left: s, top: h } = o.getBoundingClientRect(), d = this.prevTouches.x - s, c = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
1645
- this.scaleViewport(o, a, d, c);
1655
+ const { left: s, top: h } = o.getBoundingClientRect(), c = this.prevTouches.x - s, d = this.prevTouches.y - h, a = 1 / (r.scale / this.prevTouches.scale);
1656
+ this.scaleViewport(o, a, c, d);
1646
1657
  }
1647
1658
  this.prevTouches = r;
1648
1659
  });
1649
1660
  n(this, "onWindowTouchFinish", (t) => {
1650
- t.touches.length > 0 ? this.prevTouches = W(t) : this.stopTouchDrag();
1661
+ t.touches.length > 0 ? this.prevTouches = F(t) : this.stopTouchDrag();
1651
1662
  });
1652
1663
  n(this, "observer", new ResizeObserver(() => {
1653
1664
  const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
@@ -1656,10 +1667,10 @@ class Pt {
1656
1667
  canvasWidth: o,
1657
1668
  canvasHeight: r
1658
1669
  });
1659
- this.canvas.patchViewportMatrix(i), this.options.onTransformFinished();
1670
+ this.canvas.patchViewportMatrix(i), this.options.onTransformChange();
1660
1671
  }));
1661
1672
  n(this, "options");
1662
- this.canvas = t, this.options = Mt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1673
+ this.canvas = t, this.options = Ct(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1663
1674
  }
1664
1675
  attach(t) {
1665
1676
  return this.detach(), this.element = t, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
@@ -1707,39 +1718,39 @@ class Pt {
1707
1718
  this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1708
1719
  }
1709
1720
  moveViewport(t, o, r) {
1710
- this.options.onBeforeTransformStarted();
1711
- const i = this.transformation.getViewportMatrix(), s = Ct(i, o, r), { width: h, height: d } = t.getBoundingClientRect(), c = this.options.transformPreprocessor({
1721
+ this.options.onBeforeTransformChange();
1722
+ const i = this.transformation.getViewportMatrix(), s = Nt(i, o, r), { width: h, height: c } = t.getBoundingClientRect(), d = this.options.transformPreprocessor({
1712
1723
  prevTransform: i,
1713
1724
  nextTransform: s,
1714
1725
  canvasWidth: h,
1715
- canvasHeight: d
1726
+ canvasHeight: c
1716
1727
  });
1717
- this.canvas.patchViewportMatrix(c), this.options.onTransformFinished();
1728
+ this.canvas.patchViewportMatrix(d), this.options.onTransformChange();
1718
1729
  }
1719
1730
  scaleViewport(t, o, r, i) {
1720
- this.options.onBeforeTransformStarted();
1721
- const s = this.canvas.transformation.getViewportMatrix(), h = Nt(s, o, r, i), { width: d, height: c } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1731
+ this.options.onBeforeTransformChange();
1732
+ const s = this.canvas.transformation.getViewportMatrix(), h = Lt(s, o, r, i), { width: c, height: d } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1722
1733
  prevTransform: s,
1723
1734
  nextTransform: h,
1724
- canvasWidth: d,
1725
- canvasHeight: c
1735
+ canvasWidth: c,
1736
+ canvasHeight: d
1726
1737
  });
1727
- this.canvas.patchViewportMatrix(l), this.options.onTransformFinished();
1738
+ this.canvas.patchViewportMatrix(l), this.options.onTransformChange();
1728
1739
  }
1729
1740
  stopMouseDrag() {
1730
- this.element !== null && D(this.element, null), this.removeMouseDragListeners();
1741
+ this.element !== null && m(this.element, null), this.removeMouseDragListeners(), this.options.onTransformFinished();
1731
1742
  }
1732
1743
  removeMouseDragListeners() {
1733
1744
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
1734
1745
  }
1735
1746
  stopTouchDrag() {
1736
- this.prevTouches = null, this.removeTouchDragListeners();
1747
+ this.prevTouches = null, this.removeTouchDragListeners(), this.options.onTransformFinished();
1737
1748
  }
1738
1749
  removeTouchDragListeners() {
1739
1750
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
1740
1751
  }
1741
1752
  }
1742
- class Lt {
1753
+ class Dt {
1743
1754
  constructor() {
1744
1755
  n(this, "keyMap", /* @__PURE__ */ new Map());
1745
1756
  n(this, "valueMap", /* @__PURE__ */ new Map());
@@ -1776,12 +1787,12 @@ class Lt {
1776
1787
  this.keyMap.clear(), this.valueMap.clear();
1777
1788
  }
1778
1789
  }
1779
- class Dt {
1790
+ class It {
1780
1791
  constructor(t) {
1781
1792
  n(this, "transformation");
1782
1793
  n(this, "model");
1783
- n(this, "nodes", new Lt());
1784
- n(this, "nodeIdGenerator", new C(
1794
+ n(this, "nodes", new Dt());
1795
+ n(this, "nodeIdGenerator", new L(
1785
1796
  (t) => this.nodes.hasKey(t)
1786
1797
  ));
1787
1798
  n(this, "nodesResizeObserver");
@@ -1850,7 +1861,7 @@ class Dt {
1850
1861
  });
1851
1862
  }
1852
1863
  }
1853
- class mt {
1864
+ class pt {
1854
1865
  constructor() {
1855
1866
  n(this, "coreOptions");
1856
1867
  n(this, "dragOptions");
@@ -1873,18 +1884,18 @@ class mt {
1873
1884
  }
1874
1885
  build() {
1875
1886
  let t = new xt(this.coreOptions);
1876
- return this.hasResizeReactiveNodes && (t = new Dt(t)), this.isDraggable && (t = new St(t, this.dragOptions)), this.isTransformable && (t = new Pt(t, this.transformOptions)), t;
1887
+ return this.hasResizeReactiveNodes && (t = new It(t)), this.isDraggable && (t = new Et(t, this.dragOptions)), this.isTransformable && (t = new Pt(t, this.transformOptions)), t;
1877
1888
  }
1878
1889
  }
1879
1890
  export {
1880
1891
  ot as BezierEdgeShape,
1881
1892
  xt as CanvasCore,
1882
1893
  rt as HorizontalEdgeShape,
1883
- mt as HtmlGraphBuilder,
1894
+ pt as HtmlGraphBuilder,
1884
1895
  S as HtmlGraphError,
1885
- Dt as ResizeReactiveNodesCanvas,
1896
+ It as ResizeReactiveNodesCanvas,
1886
1897
  it as StraightEdgeShape,
1887
- St as UserDraggableNodesCanvas,
1898
+ Et as UserDraggableNodesCanvas,
1888
1899
  Pt as UserTransformableCanvas,
1889
1900
  nt as VerticalEdgeShape
1890
1901
  };