@html-graph/html-graph 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,832 +1,932 @@
1
- var Q = Object.defineProperty;
2
- var Z = (r, e, t) => e in r ? Q(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var a = (r, e, t) => Z(r, typeof e != "symbol" ? e + "" : e, t);
4
- const H = (r, e) => ({
5
- x: r / 2,
6
- y: e / 2
7
- }), v = (r, e, t) => ({
8
- x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
9
- y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
10
- }), x = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) }), l = {
1
+ var U = Object.defineProperty;
2
+ var K = (e, t, o) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : e[t] = o;
3
+ var s = (e, t, o) => K(e, typeof t != "symbol" ? t + "" : t, o);
4
+ const _ = (e, t) => ({
5
+ x: e / 2,
6
+ y: t / 2
7
+ }), f = (e, t, o) => ({
8
+ x: t.x * e.x - t.y * e.y + ((1 - t.x) * o.x + t.y * o.y),
9
+ y: t.y * e.x + t.x * e.y + ((1 - t.x) * o.y - t.y * o.x)
10
+ }), A = (e, t, o) => ({ x: t * Math.cos(e), y: o * Math.sin(e) }), u = {
11
11
  x: 0,
12
12
  y: 0
13
- }, f = (r, e, t, s) => {
14
- const o = [
15
- l,
16
- { x: t, y: s },
17
- { x: t, y: -s }
18
- ].map((c) => v(c, r, l)).map((c) => ({ x: c.x + e.x, y: c.y + e.y })), h = `M ${o[0].x} ${o[0].y}`, i = `L ${o[1].x} ${o[1].y}`, d = `L ${o[2].x} ${o[2].y}`;
19
- return `${h} ${i} ${d}`;
20
- }, W = (r, e) => {
21
- const t = [];
22
- if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
23
- const s = r.length - 1;
24
- let n = 0, o = 0, h = 0;
25
- r.forEach((i, d) => {
26
- let c = 0, u = 0, w = 0;
27
- const m = d > 0, y = d < s, p = m && y;
28
- if (m && (c = -n, u = -o, w = h), y) {
29
- const j = r[d + 1];
30
- n = j.x - i.x, o = j.y - i.y, h = Math.sqrt(n * n + o * o);
13
+ }, E = (e, t, o, r) => {
14
+ const n = [
15
+ u,
16
+ { x: o, y: r },
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) => {
21
+ const o = [];
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
+ const r = e.length - 1;
24
+ let i = 0, n = 0, d = 0;
25
+ e.forEach((c, h) => {
26
+ let l = 0, a = 0, w = 0;
27
+ const y = h > 0, x = h < r, v = y && x;
28
+ if (y && (l = -i, a = -n, w = d), x) {
29
+ const z = e[h + 1];
30
+ i = z.x - c.x, n = z.y - c.y, d = Math.sqrt(i * i + n * n);
31
31
  }
32
- const P = h !== 0 ? Math.min((p ? e : 0) / h, d < s - 1 ? 0.5 : 1) : 0, S = p ? { x: i.x + n * P, y: i.y + o * P } : i, L = w !== 0 ? Math.min((p ? e : 0) / w, d > 1 ? 0.5 : 1) : 0, F = p ? { x: i.x + c * L, y: i.y + u * L } : i;
33
- d > 0 && t.push(`L ${F.x} ${F.y}`), p && t.push(
34
- `C ${i.x} ${i.y} ${i.x} ${i.y} ${S.x} ${S.y}`
32
+ const M = d !== 0 ? Math.min((v ? t : 0) / d, h < r - 1 ? 0.5 : 1) : 0, X = v ? { x: c.x + i * M, y: c.y + n * M } : c, k = w !== 0 ? Math.min((v ? t : 0) / w, h > 1 ? 0.5 : 1) : 0, B = v ? { x: c.x + l * k, y: c.y + a * k } : c;
33
+ h > 0 && o.push(`L ${B.x} ${B.y}`), v && o.push(
34
+ `C ${c.x} ${c.y} ${c.x} ${c.y} ${X.x} ${X.y}`
35
35
  );
36
36
  });
37
37
  }
38
- return t.join(" ");
39
- }, N = () => {
40
- const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
41
- return r.style.pointerEvents = "none", r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.overflow = "visible", r;
38
+ return o.join(" ");
42
39
  }, I = () => {
43
- const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
44
- return r.style.transformOrigin = "50% 50%", r;
45
- }, T = (r, e) => {
40
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
41
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e;
42
+ }, $ = () => {
43
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "g");
44
+ return e.style.transformOrigin = "50% 50%", e;
45
+ }, m = (e, t) => {
46
+ const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
47
+ return o.setAttribute("stroke", e), o.setAttribute("stroke-width", `${t}`), o.setAttribute("fill", "none"), o;
48
+ }, T = (e) => {
46
49
  const t = document.createElementNS("http://www.w3.org/2000/svg", "path");
47
- return t.setAttribute("stroke", r), t.setAttribute("stroke-width", `${e}`), t.setAttribute("fill", "none"), t;
48
- }, E = (r) => {
49
- const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
50
- return e.setAttribute("fill", r), e;
51
- };
52
- class O {
53
- constructor(e, t, s, n, o, h, i) {
54
- a(this, "svg", N());
55
- a(this, "group", I());
56
- a(this, "line");
57
- a(this, "sourceArrow", null);
58
- a(this, "targetArrow", null);
59
- this.curvature = s, this.arrowLength = n, this.arrowWidth = o, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
60
- }
61
- update(e, t, s, n, o) {
62
- this.group.style.transform = `scale(${t}, ${s})`;
63
- const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i);
64
- if (this.line.setAttribute("d", d), this.sourceArrow) {
65
- const c = f(
50
+ return t.setAttribute("fill", e), t;
51
+ }, p = (e, t) => {
52
+ const o = {
53
+ x: e.x + e.width / 2,
54
+ y: e.y + e.height / 2
55
+ }, r = {
56
+ x: t.x + t.width / 2,
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;
59
+ return {
60
+ x: i,
61
+ y: n,
62
+ width: d,
63
+ height: c,
64
+ flipX: h,
65
+ flipY: l
66
+ };
67
+ }, J = (e) => {
68
+ const t = f(
69
+ { x: e.arrowLength, y: u.y },
70
+ e.fromVect,
71
+ u
72
+ ), o = f(
73
+ { x: e.to.x - e.arrowLength, y: e.to.y },
74
+ e.toVect,
75
+ e.to
76
+ ), r = {
77
+ x: t.x + e.fromVect.x * e.curvature,
78
+ y: t.y + e.fromVect.y * e.curvature
79
+ }, i = {
80
+ x: o.x - e.toVect.x * e.curvature,
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}`;
84
+ }, Q = (e) => {
85
+ const t = e.hasSourceArrow ? f(
86
+ { x: e.arrowLength, y: u.y },
87
+ e.fromVect,
88
+ u
89
+ ) : u, o = e.hasTargetArrow ? f(
90
+ { x: e.to.x - e.arrowLength, y: e.to.y },
91
+ e.toVect,
92
+ e.to
93
+ ) : e.to, r = e.arrowLength, i = Math.cos(e.detourDirection) * e.detourDistance, n = Math.sin(e.detourDirection) * e.detourDistance, d = i * e.flipX, c = n * e.flipY, h = f(
94
+ { x: r, y: u.y },
95
+ e.fromVect,
96
+ u
97
+ ), l = {
98
+ x: h.x + d,
99
+ y: h.y + c
100
+ }, a = f(
101
+ { x: e.to.x - r, y: e.to.y },
102
+ e.toVect,
103
+ e.to
104
+ ), w = {
105
+ x: a.x + d,
106
+ y: a.y + c
107
+ }, y = { x: (l.x + w.x) / 2, y: (l.y + w.y) / 2 }, x = {
108
+ x: h.x + e.curvature * e.fromVect.x,
109
+ y: h.y + e.curvature * e.fromVect.y
110
+ }, v = {
111
+ x: a.x - e.curvature * e.toVect.x,
112
+ y: a.y - e.curvature * e.toVect.y
113
+ }, b = {
114
+ x: h.x + d,
115
+ y: h.y + c
116
+ }, M = {
117
+ x: a.x + d,
118
+ y: a.y + c
119
+ };
120
+ return [
121
+ `M ${t.x} ${t.y}`,
122
+ `L ${h.x} ${h.y}`,
123
+ `C ${x.x} ${x.y} ${b.x} ${b.y} ${y.x} ${y.y}`,
124
+ `C ${M.x} ${M.y} ${v.x} ${v.y} ${a.x} ${a.y}`,
125
+ `L ${o.x} ${o.y}`
126
+ ].join(" ");
127
+ }, Z = (e) => {
128
+ const t = e.hasSourceArrow ? f(
129
+ { x: e.arrowLength, y: u.y },
130
+ e.fromVect,
131
+ u
132
+ ) : u, o = e.hasTargetArrow ? f(
133
+ { x: e.to.x - e.arrowLength, y: e.to.y },
134
+ e.toVect,
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 },
138
+ e.toVect,
139
+ e.to
140
+ ), c = Math.max((n.x + d.x) / 2, r), h = e.to.y / 2, l = { x: e.flipX > 0 ? c : -r, y: n.y }, a = { x: l.x, y: h }, w = {
141
+ x: e.flipX > 0 ? e.to.x - c : e.to.x + r,
142
+ y: d.y
143
+ }, y = { x: w.x, y: h };
144
+ return N(
145
+ [t, n, l, a, y, w, d, o],
146
+ e.roundness
147
+ );
148
+ }, R = (e) => {
149
+ const t = e.hasSourceArrow ? f(
150
+ { x: e.arrowLength, y: u.y },
151
+ e.fromVect,
152
+ u
153
+ ) : u, o = e.hasTargetArrow ? f(
154
+ { x: e.to.x - e.arrowLength, y: e.to.y },
155
+ e.toVect,
156
+ e.to
157
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = f(
158
+ { x: r, y: u.y },
159
+ e.fromVect,
160
+ u
161
+ ), n = Math.cos(e.detourDirection) * e.detourDistance, d = Math.sin(e.detourDirection) * e.detourDistance, c = n * e.flipX, h = d * e.flipY, l = { x: i.x + c, y: i.y + h }, a = f(
162
+ { x: e.to.x - r, y: e.to.y },
163
+ e.toVect,
164
+ e.to
165
+ ), w = { x: a.x + c, y: a.y + h };
166
+ return N(
167
+ [t, i, l, w, a, o],
168
+ e.roundness
169
+ );
170
+ }, q = (e) => {
171
+ const t = e.hasSourceArrow ? f(
172
+ { x: e.arrowLength, y: u.y },
173
+ e.fromVect,
174
+ u
175
+ ) : u, o = e.hasTargetArrow ? f(
176
+ { x: e.to.x - e.arrowLength, y: e.to.y },
177
+ e.toVect,
178
+ e.to
179
+ ) : e.to, r = e.arrowLength + e.arrowOffset, i = f({ x: r, y: u.y }, e.fromVect, u), n = f(
180
+ { x: e.to.x - r, y: e.to.y },
181
+ e.toVect,
182
+ e.to
183
+ );
184
+ return N([t, i, n, o], e.roundness);
185
+ }, tt = (e) => {
186
+ const t = e.hasSourceArrow ? f(
187
+ { x: e.arrowLength, y: u.y },
188
+ e.fromVect,
189
+ u
190
+ ) : u, o = e.hasTargetArrow ? f(
191
+ { x: e.to.x - e.arrowLength, y: e.to.y },
192
+ e.toVect,
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 },
196
+ e.toVect,
197
+ e.to
198
+ ), c = Math.max((n.y + d.y) / 2, r), h = e.to.x / 2, l = { x: n.x, y: e.flipY > 0 ? c : -r }, a = { x: h, y: l.y }, w = {
199
+ x: d.x,
200
+ y: e.flipY > 0 ? e.to.y - c : e.to.y + r
201
+ }, y = { x: h, y: w.y };
202
+ return N(
203
+ [t, n, l, a, y, w, d, o],
204
+ e.roundness
205
+ );
206
+ }, Y = (e) => {
207
+ const t = e.arrowOffset, o = e.side, r = e.arrowLength + t, i = r + 2 * o, d = [
208
+ { x: e.arrowLength, y: u.y },
209
+ { x: r, y: u.y },
210
+ { x: r, y: e.side },
211
+ { x: i, y: e.side },
212
+ { x: i, y: -e.side },
213
+ { x: r, y: -e.side },
214
+ { x: r, y: u.y },
215
+ { x: e.arrowLength, y: u.y }
216
+ ].map(
217
+ (h) => f(h, e.fromVect, u)
218
+ ), c = `M ${u.x} ${u.y} L ${d[0].x} ${d[0].y} `;
219
+ return `${e.hasSourceArrow || e.hasTargetArrow ? "" : c}${N(d, e.roundness)}`;
220
+ }, et = (e) => {
221
+ const t = e.smallRadius, o = e.radius, r = Math.sqrt(t * t + o * o), i = t + o, n = e.arrowLength + r * (1 - o / i), d = t * o / i, h = [
222
+ { x: e.arrowLength, y: u.y },
223
+ { x: n, y: d },
224
+ { x: n, y: -d }
225
+ ].map((w) => f(w, e.fromVect, u)), l = [
226
+ `M ${h[0].x} ${h[0].y}`,
227
+ `A ${t} ${t} 0 0 1 ${h[1].x} ${h[1].y}`,
228
+ `A ${o} ${o} 0 1 0 ${h[2].x} ${h[2].y}`,
229
+ `A ${t} ${t} 0 0 1 ${h[0].x} ${h[0].y}`
230
+ ].join(" "), a = `M 0 0 L ${h[0].x} ${h[0].y} `;
231
+ return `${e.hasSourceArrow || e.hasTargetArrow ? "" : a}${l}`;
232
+ }, g = Object.freeze({
233
+ color: "#5c5c5c",
234
+ width: 1,
235
+ arrowLength: 15,
236
+ arrowWidth: 4,
237
+ arrowOffset: 15,
238
+ hasSourceArrow: !1,
239
+ hasTargetArrow: !1,
240
+ cycleRadius: 30,
241
+ cycleSquareSide: 30,
242
+ roundness: 10,
243
+ detourDistance: 100,
244
+ detourDirection: -Math.PI / 2,
245
+ smallCycleRadius: 15,
246
+ curvature: 90
247
+ });
248
+ class ot {
249
+ constructor(t) {
250
+ s(this, "svg", I());
251
+ s(this, "group", $());
252
+ s(this, "line");
253
+ s(this, "sourceArrow", null);
254
+ s(this, "targetArrow", null);
255
+ s(this, "arrowLength");
256
+ s(this, "arrowWidth");
257
+ s(this, "curvature");
258
+ s(this, "portCycleRadius");
259
+ s(this, "portCycleSmallRadius");
260
+ s(this, "detourDirection");
261
+ s(this, "detourDistance");
262
+ s(this, "hasSourceArrow");
263
+ s(this, "hasTargetArrow");
264
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.curvature = (t == null ? void 0 : t.curvature) ?? g.curvature, this.portCycleRadius = (t == null ? void 0 : t.cycleRadius) ?? g.cycleRadius, this.portCycleSmallRadius = (t == null ? void 0 : t.smallCycleRadius) ?? g.smallCycleRadius, this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
265
+ const o = (t == null ? void 0 : t.color) ?? g.color, r = (t == null ? void 0 : t.width) ?? g.width;
266
+ 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
+ render(t) {
269
+ const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
270
+ t.source,
271
+ t.target
272
+ );
273
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
274
+ const h = A(
275
+ t.source.direction,
276
+ d,
277
+ c
278
+ ), l = A(
279
+ t.target.direction,
280
+ d,
281
+ c
282
+ ), a = {
283
+ x: i,
284
+ y: n
285
+ };
286
+ let w, y = l, x = -this.arrowLength;
287
+ if (t.source.portId === t.target.portId ? (w = et({
288
+ fromVect: h,
289
+ radius: this.portCycleRadius,
290
+ smallRadius: this.portCycleSmallRadius,
291
+ arrowLength: this.arrowLength,
292
+ hasSourceArrow: this.hasSourceArrow,
293
+ hasTargetArrow: this.hasTargetArrow
294
+ }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = Q({
295
+ to: a,
296
+ fromVect: h,
297
+ toVect: l,
298
+ flipX: d,
299
+ flipY: c,
300
+ arrowLength: this.arrowLength,
301
+ detourDirection: this.detourDirection,
302
+ detourDistance: this.detourDistance,
303
+ curvature: this.curvature,
304
+ hasSourceArrow: this.hasSourceArrow,
305
+ hasTargetArrow: this.hasTargetArrow
306
+ }) : w = J({
307
+ to: a,
308
+ fromVect: h,
309
+ toVect: l,
310
+ arrowLength: this.arrowLength,
311
+ curvature: this.curvature,
312
+ hasSourceArrow: this.hasSourceArrow,
313
+ hasTargetArrow: this.hasTargetArrow
314
+ }), this.line.setAttribute("d", w), this.sourceArrow) {
315
+ const v = E(
66
316
  h,
67
- l,
317
+ u,
68
318
  this.arrowLength,
69
319
  this.arrowWidth
70
320
  );
71
- this.sourceArrow.setAttribute("d", c);
321
+ this.sourceArrow.setAttribute("d", v);
72
322
  }
73
323
  if (this.targetArrow) {
74
- const c = f(
75
- i,
76
- e,
77
- -this.arrowLength,
324
+ const v = E(
325
+ y,
326
+ a,
327
+ x,
78
328
  this.arrowWidth
79
329
  );
80
- this.targetArrow.setAttribute("d", c);
330
+ this.targetArrow.setAttribute("d", v);
81
331
  }
82
332
  }
83
- createLinePath(e, t, s) {
84
- const n = v(
85
- { x: this.arrowLength, y: l.y },
86
- t,
87
- l
88
- ), o = v(
89
- { x: e.x - this.arrowLength, y: e.y },
90
- s,
91
- e
92
- ), h = {
93
- x: n.x + t.x * this.curvature,
94
- y: n.y + t.y * this.curvature
95
- }, i = {
96
- x: o.x - s.x * this.curvature,
97
- y: o.y - s.y * this.curvature
98
- }, d = `M ${n.x} ${n.y} C ${h.x} ${h.y}, ${i.x} ${i.y}, ${o.x} ${o.y}`, c = this.sourceArrow ? "" : `M ${l.x} ${l.y} L ${n.x} ${n.y} `, u = this.targetArrow ? "" : ` M ${o.x} ${o.y} L ${e.x} ${e.y}`;
99
- return `${c}${d}${u}`;
100
- }
101
333
  }
102
- class q {
103
- constructor(e, t, s, n, o, h, i, d) {
104
- a(this, "svg", N());
105
- a(this, "group", I());
106
- a(this, "line");
107
- a(this, "sourceArrow", null);
108
- a(this, "targetArrow", null);
109
- this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
110
- }
111
- update(e, t, s, n, o) {
112
- this.group.style.transform = `scale(${t}, ${s})`;
113
- const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i);
114
- if (this.line.setAttribute("d", d), this.sourceArrow) {
115
- const c = f(
334
+ class rt {
335
+ constructor(t) {
336
+ s(this, "svg", I());
337
+ s(this, "group", $());
338
+ s(this, "line");
339
+ s(this, "sourceArrow", null);
340
+ s(this, "targetArrow", null);
341
+ s(this, "arrowLength");
342
+ s(this, "arrowWidth");
343
+ s(this, "arrowOffset");
344
+ s(this, "roundness");
345
+ s(this, "cycleSquareSide");
346
+ s(this, "detourDirection");
347
+ s(this, "detourDistance");
348
+ s(this, "hasSourceArrow");
349
+ s(this, "hasTargetArrow");
350
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? g.cycleSquareSide;
351
+ const o = (t == null ? void 0 : t.roundness) ?? g.roundness;
352
+ this.roundness = Math.min(
353
+ o,
354
+ this.arrowOffset,
355
+ this.cycleSquareSide / 2
356
+ ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
357
+ const r = (t == null ? void 0 : t.color) ?? g.color, i = (t == null ? void 0 : t.width) ?? g.width;
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));
359
+ }
360
+ render(t) {
361
+ const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
362
+ t.source,
363
+ t.target
364
+ );
365
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
366
+ const h = A(
367
+ t.source.direction,
368
+ d,
369
+ c
370
+ ), l = A(
371
+ t.target.direction,
372
+ d,
373
+ c
374
+ ), a = {
375
+ x: i,
376
+ y: n
377
+ };
378
+ let w, y = l, x = -this.arrowLength;
379
+ if (t.source.portId === t.target.portId ? (w = Y({
380
+ fromVect: h,
381
+ arrowLength: this.arrowLength,
382
+ side: this.cycleSquareSide,
383
+ arrowOffset: this.arrowOffset,
384
+ roundness: this.roundness,
385
+ hasSourceArrow: this.hasSourceArrow,
386
+ hasTargetArrow: this.hasTargetArrow
387
+ }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = R({
388
+ to: a,
389
+ fromVect: h,
390
+ toVect: l,
391
+ flipX: d,
392
+ flipY: c,
393
+ arrowLength: this.arrowLength,
394
+ arrowOffset: this.arrowOffset,
395
+ roundness: this.roundness,
396
+ detourDirection: this.detourDirection,
397
+ detourDistance: this.detourDistance,
398
+ hasSourceArrow: this.hasSourceArrow,
399
+ hasTargetArrow: this.hasTargetArrow
400
+ }) : w = Z({
401
+ to: a,
402
+ fromVect: h,
403
+ toVect: l,
404
+ flipX: d,
405
+ arrowLength: this.arrowLength,
406
+ arrowOffset: this.arrowOffset,
407
+ roundness: this.roundness,
408
+ hasSourceArrow: this.hasSourceArrow,
409
+ hasTargetArrow: this.hasTargetArrow
410
+ }), this.line.setAttribute("d", w), this.sourceArrow) {
411
+ const v = E(
116
412
  h,
117
- l,
413
+ u,
118
414
  this.arrowLength,
119
415
  this.arrowWidth
120
416
  );
121
- this.sourceArrow.setAttribute("d", c);
417
+ this.sourceArrow.setAttribute("d", v);
122
418
  }
123
419
  if (this.targetArrow) {
124
- const c = f(
125
- i,
126
- e,
127
- -this.arrowLength,
420
+ const v = E(
421
+ y,
422
+ a,
423
+ x,
128
424
  this.arrowWidth
129
425
  );
130
- this.targetArrow.setAttribute("d", c);
426
+ this.targetArrow.setAttribute("d", v);
131
427
  }
132
428
  }
133
- createLinePath(e, t, s) {
134
- const n = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, o = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, h = this.arrowLength + this.arrowOffset, i = v({ x: h, y: l.y }, t, l), d = v({ x: e.x - h, y: e.y }, s, e);
135
- return W([n, i, d, o], this.roundness);
136
- }
137
429
  }
138
- class ee {
139
- constructor(e, t, s, n, o, h, i, d) {
140
- a(this, "svg", N());
141
- a(this, "group", I());
142
- a(this, "line");
143
- a(this, "sourceArrow", null);
144
- a(this, "targetArrow", null);
145
- this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
146
- }
147
- update(e, t, s, n, o) {
148
- this.group.style.transform = `scale(${t}, ${s})`;
149
- const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, t);
150
- if (this.line.setAttribute("d", d), this.sourceArrow) {
151
- const c = f(
152
- h,
153
- l,
154
- this.arrowLength,
155
- this.arrowWidth
156
- );
157
- this.sourceArrow.setAttribute("d", c);
158
- }
159
- if (this.targetArrow) {
160
- const c = f(
161
- i,
162
- e,
163
- -this.arrowLength,
164
- this.arrowWidth
165
- );
166
- this.targetArrow.setAttribute("d", c);
167
- }
168
- }
169
- createLinePath(e, t, s, n) {
170
- const o = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, i = this.arrowLength + this.arrowOffset, d = i - this.roundness, c = v({ x: d, y: l.y }, t, l), u = v({ x: e.x - d, y: e.y }, s, e), w = Math.max((c.x + u.x) / 2, i), m = e.y / 2, y = { x: n > 0 ? w : -i, y: c.y }, p = { x: y.x, y: m }, M = { x: n > 0 ? e.x - w : e.x + i, y: u.y }, P = { x: M.x, y: m };
171
- return W(
172
- [o, c, y, p, P, M, u, h],
173
- this.roundness
430
+ class it {
431
+ constructor(t) {
432
+ s(this, "svg", I());
433
+ s(this, "group", $());
434
+ s(this, "line");
435
+ s(this, "sourceArrow", null);
436
+ s(this, "targetArrow", null);
437
+ s(this, "arrowLength");
438
+ s(this, "arrowWidth");
439
+ s(this, "arrowOffset");
440
+ s(this, "roundness");
441
+ s(this, "cycleSquareSide");
442
+ s(this, "detourDirection");
443
+ s(this, "detourDistance");
444
+ s(this, "hasSourceArrow");
445
+ s(this, "hasTargetArrow");
446
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? g.cycleSquareSide;
447
+ const o = (t == null ? void 0 : t.roundness) ?? g.roundness;
448
+ this.roundness = Math.min(
449
+ o,
450
+ this.arrowOffset,
451
+ this.cycleSquareSide / 2
452
+ ), this.detourDirection = (t == null ? void 0 : t.detourDirection) ?? g.detourDirection, this.detourDistance = (t == null ? void 0 : t.detourDistance) ?? g.detourDistance, this.hasSourceArrow = (t == null ? void 0 : t.hasSourceArrow) ?? g.hasSourceArrow, this.hasTargetArrow = (t == null ? void 0 : t.hasTargetArrow) ?? g.hasTargetArrow;
453
+ const r = (t == null ? void 0 : t.color) ?? g.color, i = (t == null ? void 0 : t.width) ?? g.width;
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));
455
+ }
456
+ render(t) {
457
+ const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
458
+ t.source,
459
+ t.target
174
460
  );
175
- }
176
- }
177
- class te {
178
- constructor(e, t, s, n, o, h, i, d) {
179
- a(this, "svg", N());
180
- a(this, "group", I());
181
- a(this, "line");
182
- a(this, "sourceArrow", null);
183
- a(this, "targetArrow", null);
184
- this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
185
- }
186
- update(e, t, s, n, o) {
187
- this.group.style.transform = `scale(${t}, ${s})`;
188
- const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, s);
189
- if (this.line.setAttribute("d", d), this.sourceArrow) {
190
- const c = f(
461
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
462
+ const h = A(
463
+ t.source.direction,
464
+ d,
465
+ c
466
+ ), l = A(
467
+ t.target.direction,
468
+ d,
469
+ c
470
+ ), a = {
471
+ x: i,
472
+ y: n
473
+ };
474
+ let w, y = l, x = -this.arrowLength;
475
+ if (t.source.portId === t.target.portId ? (w = Y({
476
+ fromVect: h,
477
+ arrowLength: this.arrowLength,
478
+ side: this.cycleSquareSide,
479
+ arrowOffset: this.arrowOffset,
480
+ roundness: this.roundness,
481
+ hasSourceArrow: this.hasSourceArrow,
482
+ hasTargetArrow: this.hasTargetArrow
483
+ }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = R({
484
+ to: a,
485
+ fromVect: h,
486
+ toVect: l,
487
+ flipX: d,
488
+ flipY: c,
489
+ arrowLength: this.arrowLength,
490
+ arrowOffset: this.arrowOffset,
491
+ roundness: this.roundness,
492
+ detourDirection: this.detourDirection,
493
+ detourDistance: this.detourDistance,
494
+ hasSourceArrow: this.hasSourceArrow,
495
+ hasTargetArrow: this.hasTargetArrow
496
+ }) : w = q({
497
+ to: a,
498
+ fromVect: h,
499
+ toVect: l,
500
+ arrowLength: this.arrowLength,
501
+ arrowOffset: this.arrowOffset,
502
+ roundness: this.roundness,
503
+ hasSourceArrow: this.hasSourceArrow,
504
+ hasTargetArrow: this.hasTargetArrow
505
+ }), this.line.setAttribute("d", w), this.sourceArrow) {
506
+ const v = E(
191
507
  h,
192
- l,
508
+ u,
193
509
  this.arrowLength,
194
510
  this.arrowWidth
195
511
  );
196
- this.sourceArrow.setAttribute("d", c);
512
+ this.sourceArrow.setAttribute("d", v);
197
513
  }
198
514
  if (this.targetArrow) {
199
- const c = f(
200
- i,
201
- e,
202
- -this.arrowLength,
203
- this.arrowWidth
204
- );
205
- this.targetArrow.setAttribute("d", c);
206
- }
207
- }
208
- createLinePath(e, t, s, n) {
209
- const o = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, h = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, i = this.arrowLength + this.arrowOffset, d = i - this.roundness, c = v({ x: d, y: l.y }, t, l), u = v({ x: e.x - d, y: e.y }, s, e), w = Math.max((c.y + u.y) / 2, i), m = e.x / 2, y = { x: c.x, y: n > 0 ? w : -i }, p = { x: m, y: y.y }, M = {
210
- x: u.x,
211
- y: n > 0 ? e.y - w : e.y + i
212
- }, P = { x: m, y: M.y };
213
- return W(
214
- [o, c, y, p, P, M, u, h],
215
- this.roundness
216
- );
217
- }
218
- }
219
- class re {
220
- constructor(e, t, s, n, o, h, i) {
221
- a(this, "svg", N());
222
- a(this, "line");
223
- a(this, "arrow", null);
224
- this.arrowLength = s, this.arrowWidth = n, this.radius = h, this.smallRadius = i, this.line = T(e, t), this.svg.appendChild(this.line), o && (this.arrow = E(e), this.svg.appendChild(this.arrow));
225
- }
226
- update(e, t, s, n) {
227
- const o = x(n, t, s), h = this.createLinePath(o);
228
- if (this.line.setAttribute("d", h), this.arrow) {
229
- const i = f(
230
- o,
231
- l,
232
- this.arrowLength,
233
- this.arrowWidth
234
- );
235
- this.arrow.setAttribute("d", i);
236
- }
237
- }
238
- createLinePath(e) {
239
- const t = this.smallRadius, s = this.radius, n = Math.sqrt(t * t + s * s), o = t + s, h = this.arrowLength + n * (1 - s / o), i = t * s / o, c = [
240
- { x: this.arrowLength, y: l.y },
241
- { x: h, y: i },
242
- { x: h, y: -i }
243
- ].map((m) => v(m, e, l)), u = [
244
- `M ${c[0].x} ${c[0].y}`,
245
- `A ${t} ${t} 0 0 1 ${c[1].x} ${c[1].y}`,
246
- `A ${s} ${s} 0 1 0 ${c[2].x} ${c[2].y}`,
247
- `A ${t} ${t} 0 0 1 ${c[0].x} ${c[0].y}`
248
- ].join(" "), w = `M 0 0 L ${c[0].x} ${c[0].y} `;
249
- return `${this.arrow !== null ? "" : w}${u}`;
250
- }
251
- }
252
- class X {
253
- constructor(e, t, s, n, o, h, i, d) {
254
- a(this, "svg", N());
255
- a(this, "line");
256
- a(this, "arrow", null);
257
- a(this, "roundness");
258
- a(this, "linePoints");
259
- this.arrowLength = s, this.arrowWidth = n, this.side = h, this.minPortOffset = i, this.roundness = Math.min(d, this.minPortOffset, this.side / 2), this.line = T(e, t), this.svg.appendChild(this.line), o && (this.arrow = E(e), this.svg.appendChild(this.arrow));
260
- const c = this.minPortOffset, u = this.side, w = this.arrowLength + c, m = w + 2 * u;
261
- this.linePoints = [
262
- { x: this.arrowLength, y: l.y },
263
- { x: w, y: l.y },
264
- { x: w, y: this.side },
265
- { x: m, y: this.side },
266
- { x: m, y: -this.side },
267
- { x: w, y: -this.side },
268
- { x: w, y: l.y },
269
- { x: this.arrowLength, y: l.y }
270
- ];
271
- }
272
- update(e, t, s, n) {
273
- const o = x(n, t, s), h = this.createLinePath(o);
274
- if (this.line.setAttribute("d", h), this.arrow) {
275
- const i = f(
276
- o,
277
- l,
278
- this.arrowLength,
515
+ const v = E(
516
+ y,
517
+ a,
518
+ x,
279
519
  this.arrowWidth
280
520
  );
281
- this.arrow.setAttribute("d", i);
521
+ this.targetArrow.setAttribute("d", v);
282
522
  }
283
523
  }
284
- createLinePath(e) {
285
- const t = this.linePoints.map(
286
- (n) => v(n, e, l)
287
- ), s = `M ${l.x} ${l.y} L ${t[0].x} ${t[0].y} `;
288
- return `${this.arrow ? "" : s}${W(t, this.roundness)}`;
289
- }
290
524
  }
291
- class se {
292
- constructor(e, t, s, n, o, h, i, d, c) {
293
- a(this, "svg", N());
294
- a(this, "group", I());
295
- a(this, "line");
296
- a(this, "sourceArrow", null);
297
- a(this, "targetArrow", null);
298
- a(this, "detourX");
299
- a(this, "detourY");
300
- this.curvature = s, this.arrowLength = n, this.arrowWidth = o, this.detourX = Math.cos(c) * d, this.detourY = Math.sin(c) * d, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
301
- }
302
- update(e, t, s, n, o) {
303
- this.group.style.transform = `scale(${t}, ${s})`;
304
- const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, t, s);
305
- if (this.line.setAttribute("d", d), this.sourceArrow) {
306
- const c = f(
307
- h,
308
- l,
309
- this.arrowLength,
310
- this.arrowWidth
311
- );
312
- this.sourceArrow.setAttribute("d", c);
313
- }
314
- if (this.targetArrow) {
315
- const c = f(
316
- i,
317
- e,
318
- -this.arrowLength,
319
- this.arrowWidth
320
- );
321
- this.targetArrow.setAttribute("d", c);
322
- }
323
- }
324
- createLinePath(e, t, s, n, o) {
325
- const h = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, d = this.arrowLength, c = this.detourX * n, u = this.detourY * o, w = v(
326
- { x: d, y: l.y },
327
- t,
328
- l
329
- ), m = {
330
- x: w.x + c,
331
- y: w.y + u
332
- }, y = v(
333
- { x: e.x - d, y: e.y },
334
- s,
335
- e
336
- ), p = {
337
- x: y.x + c,
338
- y: y.y + u
339
- }, M = { x: (m.x + p.x) / 2, y: (m.y + p.y) / 2 }, P = {
340
- x: w.x + this.curvature * t.x,
341
- y: w.y + this.curvature * t.y
342
- }, S = {
343
- x: y.x - this.curvature * s.x,
344
- y: y.y - this.curvature * s.y
345
- }, b = {
346
- x: w.x + c,
347
- y: w.y + u
348
- }, L = {
349
- x: y.x + c,
350
- y: y.y + u
525
+ class nt {
526
+ constructor(t) {
527
+ s(this, "svg", I());
528
+ s(this, "group", $());
529
+ s(this, "line");
530
+ s(this, "sourceArrow", null);
531
+ s(this, "targetArrow", null);
532
+ s(this, "arrowLength");
533
+ s(this, "arrowWidth");
534
+ s(this, "arrowOffset");
535
+ s(this, "roundness");
536
+ s(this, "cycleSquareSide");
537
+ s(this, "detourDirection");
538
+ s(this, "detourDistance");
539
+ s(this, "hasSourceArrow");
540
+ s(this, "hasTargetArrow");
541
+ this.arrowLength = (t == null ? void 0 : t.arrowLength) ?? g.arrowLength, this.arrowWidth = (t == null ? void 0 : t.arrowWidth) ?? g.arrowWidth, this.arrowOffset = (t == null ? void 0 : t.arrowOffset) ?? g.arrowOffset, this.cycleSquareSide = (t == null ? void 0 : t.cycleSquareSide) ?? g.cycleSquareSide;
542
+ const o = (t == null ? void 0 : t.roundness) ?? g.roundness;
543
+ this.roundness = Math.min(
544
+ o,
545
+ this.arrowOffset,
546
+ 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));
550
+ }
551
+ render(t) {
552
+ const { x: o, y: r, width: i, height: n, flipX: d, flipY: c } = p(
553
+ t.source,
554
+ t.target
555
+ );
556
+ this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${i}px`, this.svg.style.height = `${n}px`, this.group.style.transform = `scale(${d}, ${c})`;
557
+ const h = A(
558
+ t.source.direction,
559
+ d,
560
+ c
561
+ ), l = A(
562
+ t.target.direction,
563
+ d,
564
+ c
565
+ ), a = {
566
+ x: i,
567
+ y: n
351
568
  };
352
- return [
353
- `M ${h.x} ${h.y}`,
354
- `L ${w.x} ${w.y}`,
355
- `C ${P.x} ${P.y} ${b.x} ${b.y} ${M.x} ${M.y}`,
356
- `C ${L.x} ${L.y} ${S.x} ${S.y} ${y.x} ${y.y}`,
357
- `L ${i.x} ${i.y}`
358
- ].join(" ");
359
- }
360
- }
361
- class G {
362
- constructor(e, t, s, n, o, h, i, d, c, u) {
363
- a(this, "svg", N());
364
- a(this, "group", I());
365
- a(this, "line");
366
- a(this, "sourceArrow", null);
367
- a(this, "targetArrow", null);
368
- a(this, "detourX");
369
- a(this, "detourY");
370
- this.arrowLength = s, this.arrowWidth = n, this.arrowOffset = o, this.roundness = d, this.detourX = Math.cos(u) * c, this.detourY = Math.sin(u) * c, this.svg.appendChild(this.group), this.line = T(e, t), this.group.appendChild(this.line), h && (this.sourceArrow = E(e), this.group.appendChild(this.sourceArrow)), i && (this.targetArrow = E(e), this.group.appendChild(this.targetArrow));
371
- }
372
- update(e, t, s, n, o) {
373
- this.group.style.transform = `scale(${t}, ${s})`;
374
- const h = x(n, t, s), i = x(o, t, s), d = this.createLinePath(e, h, i, t, s);
375
- if (this.line.setAttribute("d", d), this.sourceArrow) {
376
- const c = f(
569
+ let w, y = l, x = -this.arrowLength;
570
+ if (t.source.portId === t.target.portId ? (w = Y({
571
+ fromVect: h,
572
+ arrowLength: this.arrowLength,
573
+ side: this.cycleSquareSide,
574
+ arrowOffset: this.arrowOffset,
575
+ roundness: this.roundness,
576
+ hasSourceArrow: this.hasSourceArrow,
577
+ hasTargetArrow: this.hasTargetArrow
578
+ }), y = h, x = this.arrowLength) : t.source.nodeId === t.target.nodeId ? w = R({
579
+ to: a,
580
+ fromVect: h,
581
+ toVect: l,
582
+ flipX: d,
583
+ flipY: c,
584
+ arrowLength: this.arrowLength,
585
+ arrowOffset: this.arrowOffset,
586
+ roundness: this.roundness,
587
+ detourDirection: this.detourDirection,
588
+ detourDistance: this.detourDistance,
589
+ hasSourceArrow: this.hasSourceArrow,
590
+ hasTargetArrow: this.hasTargetArrow
591
+ }) : w = tt({
592
+ to: a,
593
+ fromVect: h,
594
+ toVect: l,
595
+ flipY: c,
596
+ arrowLength: this.arrowLength,
597
+ arrowOffset: this.arrowOffset,
598
+ roundness: this.roundness,
599
+ hasSourceArrow: this.hasSourceArrow,
600
+ hasTargetArrow: this.hasTargetArrow
601
+ }), this.line.setAttribute("d", w), this.sourceArrow) {
602
+ const v = E(
377
603
  h,
378
- l,
604
+ u,
379
605
  this.arrowLength,
380
606
  this.arrowWidth
381
607
  );
382
- this.sourceArrow.setAttribute("d", c);
608
+ this.sourceArrow.setAttribute("d", v);
383
609
  }
384
610
  if (this.targetArrow) {
385
- const c = f(
386
- i,
387
- e,
388
- -this.arrowLength,
611
+ const v = E(
612
+ y,
613
+ a,
614
+ x,
389
615
  this.arrowWidth
390
616
  );
391
- this.targetArrow.setAttribute("d", c);
617
+ this.targetArrow.setAttribute("d", v);
392
618
  }
393
619
  }
394
- createLinePath(e, t, s, n, o) {
395
- const h = this.sourceArrow ? v({ x: this.arrowLength, y: l.y }, t, l) : l, i = this.targetArrow ? v({ x: e.x - this.arrowLength, y: e.y }, s, e) : e, d = this.arrowLength + this.arrowOffset, c = v(
396
- { x: d, y: l.y },
397
- t,
398
- l
399
- ), u = this.detourX * n, w = this.detourY * o, m = { x: c.x + u, y: c.y + w }, y = v(
400
- { x: e.x - d, y: e.y },
401
- s,
402
- e
403
- ), p = { x: y.x + u, y: y.y + w };
404
- return W(
405
- [h, c, m, p, y, i],
406
- this.roundness
407
- );
408
- }
409
620
  }
410
- var C = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(C || {});
411
- const oe = (r) => (e) => e === C.PortCycle ? new re(
412
- r.color,
413
- r.width,
414
- r.arrowLength,
415
- r.arrowWidth,
416
- r.hasSourceArrow || r.hasTargetArrow,
417
- r.cycleRadius,
418
- r.smallCycleRadius
419
- ) : e === C.NodeCycle ? new se(
420
- r.color,
421
- r.width,
422
- r.curvature,
423
- r.arrowLength,
424
- r.arrowWidth,
425
- r.hasSourceArrow,
426
- r.hasTargetArrow,
427
- r.detourDistance,
428
- r.detourDirection
429
- ) : new O(
430
- r.color,
431
- r.width,
432
- r.curvature,
433
- r.arrowLength,
434
- r.arrowWidth,
435
- r.hasSourceArrow,
436
- r.hasTargetArrow
437
- ), ne = (r) => (e) => e === C.PortCycle ? new X(
438
- r.color,
439
- r.width,
440
- r.arrowLength,
441
- r.arrowWidth,
442
- r.hasSourceArrow || r.hasTargetArrow,
443
- r.cycleSquareSide,
444
- r.arrowOffset,
445
- r.roundness
446
- ) : e === C.NodeCycle ? new G(
447
- r.color,
448
- r.width,
449
- r.arrowLength,
450
- r.arrowWidth,
451
- r.arrowOffset,
452
- r.hasSourceArrow,
453
- r.hasTargetArrow,
454
- r.roundness,
455
- r.detourDistance,
456
- r.detourDirection
457
- ) : new q(
458
- r.color,
459
- r.width,
460
- r.arrowLength,
461
- r.arrowWidth,
462
- r.arrowOffset,
463
- r.hasSourceArrow,
464
- r.hasTargetArrow,
465
- r.roundness
466
- ), ie = (r) => (e) => e === C.PortCycle ? new X(
467
- r.color,
468
- r.width,
469
- r.arrowLength,
470
- r.arrowWidth,
471
- r.hasSourceArrow || r.hasTargetArrow,
472
- r.cycleSquareSide,
473
- r.arrowOffset,
474
- r.roundness
475
- ) : e === C.NodeCycle ? new G(
476
- r.color,
477
- r.width,
478
- r.arrowLength,
479
- r.arrowWidth,
480
- r.arrowOffset,
481
- r.hasSourceArrow,
482
- r.hasTargetArrow,
483
- r.roundness,
484
- r.detourDistance,
485
- r.detourDirection
486
- ) : new te(
487
- r.color,
488
- r.width,
489
- r.arrowLength,
490
- r.arrowWidth,
491
- r.arrowOffset,
492
- r.hasSourceArrow,
493
- r.hasTargetArrow,
494
- r.roundness
495
- ), ae = (r) => (e) => e === C.PortCycle ? new X(
496
- r.color,
497
- r.width,
498
- r.arrowLength,
499
- r.arrowWidth,
500
- r.hasSourceArrow || r.hasTargetArrow,
501
- r.cycleSquareSide,
502
- r.arrowOffset,
503
- r.roundness
504
- ) : e === C.NodeCycle ? new G(
505
- r.color,
506
- r.width,
507
- r.arrowLength,
508
- r.arrowWidth,
509
- r.arrowOffset,
510
- r.hasSourceArrow,
511
- r.hasTargetArrow,
512
- r.roundness,
513
- r.detourDistance,
514
- r.detourDirection
515
- ) : new ee(
516
- r.color,
517
- r.width,
518
- r.arrowLength,
519
- r.arrowWidth,
520
- r.arrowOffset,
521
- r.hasSourceArrow,
522
- r.hasTargetArrow,
523
- r.roundness
524
- ), g = {
525
- edgeColor: "#5c5c5c",
526
- edgeWidth: 1,
527
- edgeArrowLength: 15,
528
- edgeArrowWidth: 4,
529
- edgeArrowOffset: 15,
530
- hasSourceArrow: !1,
531
- hasTargetArrow: !1,
532
- cycleSize: 30,
533
- roundness: 10,
534
- detourDistance: 100,
535
- detourDirection: -Math.PI / 2,
536
- smallCycleSize: 15,
537
- curvature: 90
538
- }, B = (r) => {
539
- switch (r == null ? void 0 : r.type) {
540
- case "custom":
541
- return r.factory;
621
+ const st = (e) => {
622
+ if (typeof e == "function")
623
+ return e;
624
+ switch (e == null ? void 0 : e.type) {
542
625
  case "straight":
543
- return ne({
544
- color: r.color ?? g.edgeColor,
545
- width: r.width ?? g.edgeWidth,
546
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
547
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
548
- arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
549
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
550
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
551
- cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
552
- roundness: r.roundness ?? g.roundness,
553
- detourDistance: r.detourDistance ?? g.detourDistance,
554
- detourDirection: r.detourDirection ?? g.detourDirection
626
+ return () => new it({
627
+ color: e.color,
628
+ width: e.width,
629
+ arrowLength: e.arrowLength,
630
+ arrowWidth: e.arrowWidth,
631
+ arrowOffset: e.arrowOffset,
632
+ hasSourceArrow: e.hasSourceArrow,
633
+ hasTargetArrow: e.hasTargetArrow,
634
+ cycleSquareSide: e.cycleSquareSide,
635
+ roundness: e.roundness,
636
+ detourDistance: e.detourDistance,
637
+ detourDirection: e.detourDirection
555
638
  });
556
639
  case "horizontal":
557
- return ae({
558
- color: r.color ?? g.edgeColor,
559
- width: r.width ?? g.edgeWidth,
560
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
561
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
562
- arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
563
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
564
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
565
- cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
566
- roundness: r.roundness ?? g.roundness,
567
- detourDistance: r.detourDistance ?? g.detourDistance,
568
- detourDirection: r.detourDirection ?? g.detourDirection
640
+ return () => new rt({
641
+ color: e.color,
642
+ width: e.width,
643
+ arrowLength: e.arrowLength,
644
+ arrowWidth: e.arrowWidth,
645
+ arrowOffset: e.arrowOffset,
646
+ hasSourceArrow: e.hasSourceArrow,
647
+ hasTargetArrow: e.hasTargetArrow,
648
+ cycleSquareSide: e.cycleSquareSide,
649
+ roundness: e.roundness,
650
+ detourDistance: e.detourDistance,
651
+ detourDirection: e.detourDirection
569
652
  });
570
653
  case "vertical":
571
- return ie({
572
- color: r.color ?? g.edgeColor,
573
- width: r.width ?? g.edgeWidth,
574
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
575
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
576
- arrowOffset: r.arrowOffset ?? g.edgeArrowOffset,
577
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
578
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
579
- cycleSquareSide: r.cycleSquareSide ?? g.cycleSize,
580
- roundness: r.roundness ?? g.roundness,
581
- detourDistance: r.detourDistance ?? g.detourDistance,
582
- detourDirection: r.detourDirection ?? g.detourDirection
654
+ return () => new nt({
655
+ color: e.color,
656
+ width: e.width,
657
+ arrowLength: e.arrowLength,
658
+ arrowWidth: e.arrowWidth,
659
+ arrowOffset: e.arrowOffset,
660
+ hasSourceArrow: e.hasSourceArrow,
661
+ hasTargetArrow: e.hasTargetArrow,
662
+ cycleSquareSide: e.cycleSquareSide,
663
+ roundness: e.roundness,
664
+ detourDistance: e.detourDistance,
665
+ detourDirection: e.detourDirection
583
666
  });
584
667
  default:
585
- return oe({
586
- color: r.color ?? g.edgeColor,
587
- width: r.width ?? g.edgeWidth,
588
- arrowLength: r.arrowLength ?? g.edgeArrowLength,
589
- arrowWidth: r.arrowWidth ?? g.edgeArrowWidth,
590
- hasSourceArrow: r.hasSourceArrow ?? g.hasSourceArrow,
591
- hasTargetArrow: r.hasTargetArrow ?? g.hasTargetArrow,
592
- cycleRadius: r.cycleRadius ?? g.cycleSize,
593
- smallCycleRadius: r.smallCycleRadius ?? g.smallCycleSize,
594
- curvature: r.curvature ?? g.curvature,
595
- detourDistance: r.detourDistance ?? g.detourDistance,
596
- detourDirection: r.detourDirection ?? g.detourDirection
668
+ return () => new ot({
669
+ color: e.color,
670
+ width: e.width,
671
+ arrowLength: e.arrowLength,
672
+ arrowWidth: e.arrowWidth,
673
+ hasSourceArrow: e.hasSourceArrow,
674
+ hasTargetArrow: e.hasTargetArrow,
675
+ cycleRadius: e.cycleRadius,
676
+ smallCycleRadius: e.smallCycleRadius,
677
+ curvature: e.curvature,
678
+ detourDistance: e.detourDistance,
679
+ detourDirection: e.detourDirection
597
680
  });
598
681
  }
599
- }, Y = (r) => () => r, U = Y(0), R = () => {
600
- let r = 0;
601
- return () => r++;
602
- }, he = (r, e) => {
603
- let t = U, s = U;
604
- r === "incremental" && (t = R()), e === "incremental" && (s = R());
605
- const n = R();
606
- return r === "shared-incremental" && (t = n), e === "shared-incremental" && (s = n), typeof r == "number" && (t = Y(r)), typeof e == "number" && (s = Y(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
607
- nodesPriorityFn: t,
608
- edgesPriorityFn: s
682
+ }, F = (e) => () => e, G = F(0), V = () => {
683
+ let e = 0;
684
+ return () => e++;
685
+ }, ht = (e, t) => {
686
+ let o = G, r = G;
687
+ 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), {
690
+ nodesPriorityFn: o,
691
+ edgesPriorityFn: r
609
692
  };
610
- }, de = (r) => {
611
- var t, s, n, o, h, i;
612
- const e = he(
613
- (t = r == null ? void 0 : r.nodes) == null ? void 0 : t.priority,
614
- (s = r == null ? void 0 : r.edges) == null ? void 0 : s.priority
693
+ }, ct = (e) => {
694
+ var o, r, i, n, d;
695
+ const t = ht(
696
+ (o = e == null ? void 0 : e.nodes) == null ? void 0 : o.priority,
697
+ (r = e == null ? void 0 : e.edges) == null ? void 0 : r.priority
615
698
  );
616
699
  return {
617
700
  nodes: {
618
- centerFn: ((n = r == null ? void 0 : r.nodes) == null ? void 0 : n.centerFn) ?? H,
619
- priorityFn: e.nodesPriorityFn
701
+ centerFn: ((i = e == null ? void 0 : e.nodes) == null ? void 0 : i.centerFn) ?? _,
702
+ priorityFn: t.nodesPriorityFn
620
703
  },
621
704
  ports: {
622
- centerFn: ((o = r == null ? void 0 : r.ports) == null ? void 0 : o.centerFn) ?? H,
623
- direction: ((h = r == null ? void 0 : r.ports) == null ? void 0 : h.direction) ?? 0
705
+ direction: ((n = e == null ? void 0 : e.ports) == null ? void 0 : n.direction) ?? 0
624
706
  },
625
707
  edges: {
626
- shapeFactory: B(((i = r == null ? void 0 : r.edges) == null ? void 0 : i.shape) ?? {}),
627
- priorityFn: e.edgesPriorityFn
708
+ shapeFactory: st(((d = e == null ? void 0 : e.edges) == null ? void 0 : d.shape) ?? {}),
709
+ priorityFn: t.edgesPriorityFn
628
710
  }
629
711
  };
630
712
  };
631
- class ce {
713
+ class dt {
632
714
  constructor() {
633
- a(this, "nodes", /* @__PURE__ */ new Map());
634
- a(this, "ports", /* @__PURE__ */ new Map());
635
- a(this, "nodePorts", /* @__PURE__ */ new Map());
636
- a(this, "portNodeId", /* @__PURE__ */ new Map());
637
- a(this, "edges", /* @__PURE__ */ new Map());
638
- a(this, "incommingEdges", /* @__PURE__ */ new Map());
639
- a(this, "outcommingEdges", /* @__PURE__ */ new Map());
640
- a(this, "cycleEdges", /* @__PURE__ */ new Map());
641
- }
642
- addNode(e) {
643
- this.nodes.set(e.nodeId, {
644
- element: e.element,
645
- x: e.x,
646
- y: e.y,
647
- centerFn: e.centerFn,
648
- priority: e.priority
649
- }), this.nodePorts.set(e.nodeId, /* @__PURE__ */ new Map());
715
+ s(this, "nodes", /* @__PURE__ */ new Map());
716
+ s(this, "ports", /* @__PURE__ */ new Map());
717
+ s(this, "nodePorts", /* @__PURE__ */ new Map());
718
+ s(this, "portNodeId", /* @__PURE__ */ new Map());
719
+ s(this, "edges", /* @__PURE__ */ new Map());
720
+ s(this, "incommingEdges", /* @__PURE__ */ new Map());
721
+ s(this, "outcommingEdges", /* @__PURE__ */ new Map());
722
+ s(this, "cycleEdges", /* @__PURE__ */ new Map());
723
+ }
724
+ addNode(t) {
725
+ this.nodes.set(t.nodeId, {
726
+ element: t.element,
727
+ x: t.x,
728
+ y: t.y,
729
+ centerFn: t.centerFn,
730
+ priority: t.priority
731
+ }), this.nodePorts.set(t.nodeId, /* @__PURE__ */ new Map());
650
732
  }
651
733
  getAllNodeIds() {
652
734
  return Array.from(this.nodes.keys());
653
735
  }
654
- getNode(e) {
655
- return this.nodes.get(e);
736
+ getNode(t) {
737
+ return this.nodes.get(t);
656
738
  }
657
- removeNode(e) {
658
- this.nodes.delete(e), this.nodePorts.delete(e);
739
+ removeNode(t) {
740
+ this.nodes.delete(t), this.nodePorts.delete(t);
659
741
  }
660
- addPort(e) {
661
- this.ports.set(e.portId, {
662
- element: e.element,
663
- centerFn: e.centerFn,
664
- direction: e.direction
665
- }), this.cycleEdges.set(e.portId, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.portId, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.portId, /* @__PURE__ */ new Set()), this.portNodeId.set(e.portId, e.nodeId), this.nodePorts.get(e.nodeId).set(e.portId, e.element);
742
+ addPort(t) {
743
+ this.ports.set(t.portId, {
744
+ element: t.element,
745
+ direction: t.direction
746
+ }), this.cycleEdges.set(t.portId, /* @__PURE__ */ new Set()), this.incommingEdges.set(t.portId, /* @__PURE__ */ new Set()), this.outcommingEdges.set(t.portId, /* @__PURE__ */ new Set()), this.portNodeId.set(t.portId, t.nodeId), this.nodePorts.get(t.nodeId).set(t.portId, t.element);
666
747
  }
667
- getPort(e) {
668
- return this.ports.get(e);
748
+ getPort(t) {
749
+ return this.ports.get(t);
669
750
  }
670
751
  getAllPortIds() {
671
752
  return Array.from(this.ports.keys());
672
753
  }
673
- getNodePortIds(e) {
674
- const t = this.nodePorts.get(e);
675
- if (t !== void 0)
676
- return Array.from(t.keys());
754
+ getNodePortIds(t) {
755
+ const o = this.nodePorts.get(t);
756
+ if (o !== void 0)
757
+ return Array.from(o.keys());
677
758
  }
678
- getPortNodeId(e) {
679
- return this.portNodeId.get(e);
759
+ getPortNodeId(t) {
760
+ return this.portNodeId.get(t);
680
761
  }
681
- removePort(e) {
682
- const t = this.portNodeId.get(e);
683
- this.portNodeId.delete(e), this.nodePorts.get(t).delete(e), this.ports.delete(e);
762
+ removePort(t) {
763
+ const o = this.portNodeId.get(t);
764
+ this.portNodeId.delete(t), this.nodePorts.get(o).delete(t), this.ports.delete(t);
684
765
  }
685
- addEdge(e) {
686
- this.edges.set(e.edgeId, {
687
- from: e.from,
688
- to: e.to,
689
- shape: e.shape,
690
- priority: e.priority
691
- }), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.edgeId), this.incommingEdges.get(e.to).add(e.edgeId)) : this.cycleEdges.get(e.from).add(e.edgeId);
766
+ addEdge(t) {
767
+ this.edges.set(t.edgeId, {
768
+ from: t.from,
769
+ to: t.to,
770
+ shape: t.shape,
771
+ priority: t.priority
772
+ }), t.from !== t.to ? (this.outcommingEdges.get(t.from).add(t.edgeId), this.incommingEdges.get(t.to).add(t.edgeId)) : this.cycleEdges.get(t.from).add(t.edgeId);
773
+ }
774
+ updateEdgeFrom(t, o) {
775
+ const r = this.edges.get(t);
776
+ this.removeEdge(t), this.addEdge({
777
+ edgeId: t,
778
+ from: o,
779
+ to: r.to,
780
+ shape: r.shape,
781
+ priority: r.priority
782
+ });
783
+ }
784
+ updateEdgeTo(t, o) {
785
+ const r = this.edges.get(t);
786
+ this.removeEdge(t), this.addEdge({
787
+ edgeId: t,
788
+ from: r.from,
789
+ to: o,
790
+ shape: r.shape,
791
+ priority: r.priority
792
+ });
692
793
  }
693
794
  getAllEdgeIds() {
694
795
  return Array.from(this.edges.keys());
695
796
  }
696
- getEdge(e) {
697
- return this.edges.get(e);
797
+ getEdge(t) {
798
+ return this.edges.get(t);
698
799
  }
699
- removeEdge(e) {
700
- const t = this.edges.get(e), s = t.from, n = t.to;
701
- this.cycleEdges.get(s).delete(e), this.cycleEdges.get(n).delete(e), this.incommingEdges.get(s).delete(e), this.incommingEdges.get(n).delete(e), this.outcommingEdges.get(s).delete(e), this.outcommingEdges.get(n).delete(e), this.edges.delete(e);
800
+ 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);
702
803
  }
703
804
  clear() {
704
805
  this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
705
806
  }
706
- getPortIncomingEdgeIds(e) {
707
- return Array.from(this.incommingEdges.get(e));
807
+ getPortIncomingEdgeIds(t) {
808
+ return Array.from(this.incommingEdges.get(t));
708
809
  }
709
- getPortOutcomingEdgeIds(e) {
710
- return Array.from(this.outcommingEdges.get(e));
810
+ getPortOutcomingEdgeIds(t) {
811
+ return Array.from(this.outcommingEdges.get(t));
711
812
  }
712
- getPortCycleEdgeIds(e) {
713
- return Array.from(this.cycleEdges.get(e));
813
+ getPortCycleEdgeIds(t) {
814
+ return Array.from(this.cycleEdges.get(t));
714
815
  }
715
- getPortAdjacentEdgeIds(e) {
816
+ getPortAdjacentEdgeIds(t) {
716
817
  return [
717
- ...this.getPortIncomingEdgeIds(e),
718
- ...this.getPortOutcomingEdgeIds(e),
719
- ...this.getPortCycleEdgeIds(e)
818
+ ...this.getPortIncomingEdgeIds(t),
819
+ ...this.getPortOutcomingEdgeIds(t),
820
+ ...this.getPortCycleEdgeIds(t)
720
821
  ];
721
822
  }
722
- getNodeIncomingEdgeIds(e) {
723
- const t = Array.from(this.nodePorts.get(e).keys());
724
- let s = [];
725
- return t.forEach((n) => {
726
- s = [...s, ...this.getPortIncomingEdgeIds(n)];
727
- }), s;
728
- }
729
- getNodeOutcomingEdgeIds(e) {
730
- const t = Array.from(this.nodePorts.get(e).keys());
731
- let s = [];
732
- return t.forEach((n) => {
733
- s = [...s, ...this.getPortOutcomingEdgeIds(n)];
734
- }), s;
735
- }
736
- getNodeCycleEdgeIds(e) {
737
- const t = Array.from(this.nodePorts.get(e).keys());
738
- let s = [];
739
- return t.forEach((n) => {
740
- s = [...s, ...this.getPortCycleEdgeIds(n)];
741
- }), s;
742
- }
743
- getNodeAdjacentEdgeIds(e) {
823
+ getNodeIncomingEdgeIds(t) {
824
+ const o = Array.from(this.nodePorts.get(t).keys());
825
+ let r = [];
826
+ return o.forEach((i) => {
827
+ r = [...r, ...this.getPortIncomingEdgeIds(i)];
828
+ }), r;
829
+ }
830
+ getNodeOutcomingEdgeIds(t) {
831
+ const o = Array.from(this.nodePorts.get(t).keys());
832
+ let r = [];
833
+ return o.forEach((i) => {
834
+ r = [...r, ...this.getPortOutcomingEdgeIds(i)];
835
+ }), r;
836
+ }
837
+ getNodeCycleEdgeIds(t) {
838
+ const o = Array.from(this.nodePorts.get(t).keys());
839
+ let r = [];
840
+ return o.forEach((i) => {
841
+ r = [...r, ...this.getPortCycleEdgeIds(i)];
842
+ }), r;
843
+ }
844
+ getNodeAdjacentEdgeIds(t) {
744
845
  return [
745
- ...this.getNodeIncomingEdgeIds(e),
746
- ...this.getNodeOutcomingEdgeIds(e),
747
- ...this.getNodeCycleEdgeIds(e)
846
+ ...this.getNodeIncomingEdgeIds(t),
847
+ ...this.getNodeOutcomingEdgeIds(t),
848
+ ...this.getNodeCycleEdgeIds(t)
748
849
  ];
749
850
  }
750
851
  }
751
- class le {
752
- constructor(e) {
753
- this.graphStore = e;
754
- }
755
- getNode(e) {
756
- const t = this.graphStore.getNode(e);
757
- return t === void 0 ? null : {
758
- element: t.element,
759
- x: t.x,
760
- y: t.y,
761
- centerFn: t.centerFn,
762
- priority: t.priority
852
+ class lt {
853
+ constructor(t) {
854
+ this.graphStore = t;
855
+ }
856
+ getNode(t) {
857
+ const o = this.graphStore.getNode(t);
858
+ return o === void 0 ? null : {
859
+ element: o.element,
860
+ x: o.x,
861
+ y: o.y,
862
+ centerFn: o.centerFn,
863
+ priority: o.priority
763
864
  };
764
865
  }
765
866
  getAllNodeIds() {
766
867
  return this.graphStore.getAllNodeIds();
767
868
  }
768
- getPort(e) {
769
- const t = this.graphStore.getPort(e);
770
- return t === void 0 ? null : {
771
- element: t.element,
772
- centerFn: t.centerFn,
773
- direction: t.direction
869
+ getPort(t) {
870
+ const o = this.graphStore.getPort(t);
871
+ return o === void 0 ? null : {
872
+ element: o.element,
873
+ direction: o.direction
774
874
  };
775
875
  }
776
876
  getAllPortIds() {
777
877
  return this.graphStore.getAllPortIds();
778
878
  }
779
- getNodePortIds(e) {
780
- return this.graphStore.getNodePortIds(e);
879
+ getNodePortIds(t) {
880
+ return this.graphStore.getNodePortIds(t);
781
881
  }
782
- getPortNodeId(e) {
783
- return this.graphStore.getPortNodeId(e) ?? null;
882
+ getPortNodeId(t) {
883
+ return this.graphStore.getPortNodeId(t) ?? null;
784
884
  }
785
885
  getAllEdgeIds() {
786
886
  return this.graphStore.getAllEdgeIds();
787
887
  }
788
- getEdge(e) {
789
- const t = this.graphStore.getEdge(e);
790
- return t === void 0 ? null : { from: t.from, to: t.to, priority: t.priority };
888
+ getEdge(t) {
889
+ const o = this.graphStore.getEdge(t);
890
+ return o === void 0 ? null : { from: o.from, to: o.to, priority: o.priority };
791
891
  }
792
- getPortIncomingEdgeIds(e) {
793
- return this.graphStore.getPortIncomingEdgeIds(e);
892
+ getPortIncomingEdgeIds(t) {
893
+ return this.graphStore.getPortIncomingEdgeIds(t);
794
894
  }
795
- getPortOutcomingEdgeIds(e) {
796
- return this.graphStore.getPortOutcomingEdgeIds(e);
895
+ getPortOutcomingEdgeIds(t) {
896
+ return this.graphStore.getPortOutcomingEdgeIds(t);
797
897
  }
798
- getPortCycleEdgeIds(e) {
799
- return this.graphStore.getPortCycleEdgeIds(e);
898
+ getPortCycleEdgeIds(t) {
899
+ return this.graphStore.getPortCycleEdgeIds(t);
800
900
  }
801
- getPortAdjacentEdgeIds(e) {
802
- return this.graphStore.getPortAdjacentEdgeIds(e);
901
+ getPortAdjacentEdgeIds(t) {
902
+ return this.graphStore.getPortAdjacentEdgeIds(t);
803
903
  }
804
- getNodeIncomingEdgeIds(e) {
805
- return this.graphStore.getNodeIncomingEdgeIds(e);
904
+ getNodeIncomingEdgeIds(t) {
905
+ return this.graphStore.getNodeIncomingEdgeIds(t);
806
906
  }
807
- getNodeOutcomingEdgeIds(e) {
808
- return this.graphStore.getNodeOutcomingEdgeIds(e);
907
+ getNodeOutcomingEdgeIds(t) {
908
+ return this.graphStore.getNodeOutcomingEdgeIds(t);
809
909
  }
810
- getNodeCycleEdgeIds(e) {
811
- return this.graphStore.getNodeCycleEdgeIds(e);
910
+ getNodeCycleEdgeIds(t) {
911
+ return this.graphStore.getNodeCycleEdgeIds(t);
812
912
  }
813
- getNodeAdjacentEdgeIds(e) {
814
- return this.graphStore.getNodeAdjacentEdgeIds(e);
913
+ getNodeAdjacentEdgeIds(t) {
914
+ return this.graphStore.getNodeAdjacentEdgeIds(t);
815
915
  }
816
916
  }
817
- const K = (r) => ({
818
- scale: 1 / r.scale,
819
- dx: -r.dx / r.scale,
820
- dy: -r.dy / r.scale
821
- }), _ = {
917
+ const j = (e) => ({
918
+ scale: 1 / e.scale,
919
+ dx: -e.dx / e.scale,
920
+ dy: -e.dy / e.scale
921
+ }), H = {
822
922
  scale: 1,
823
923
  dx: 0,
824
924
  dy: 0
825
925
  };
826
- class ge {
926
+ class at {
827
927
  constructor() {
828
- a(this, "viewportMatrix", _);
829
- a(this, "contentMatrix", _);
928
+ s(this, "viewportMatrix", H);
929
+ s(this, "contentMatrix", H);
830
930
  }
831
931
  getViewportMatrix() {
832
932
  return this.viewportMatrix;
@@ -834,24 +934,24 @@ class ge {
834
934
  getContentMatrix() {
835
935
  return this.contentMatrix;
836
936
  }
837
- patchViewportMatrix(e) {
937
+ patchViewportMatrix(t) {
838
938
  this.viewportMatrix = {
839
- scale: e.scale ?? this.viewportMatrix.scale,
840
- dx: e.dx ?? this.viewportMatrix.dx,
841
- dy: e.dy ?? this.viewportMatrix.dy
842
- }, this.contentMatrix = K(this.viewportMatrix);
939
+ scale: t.scale ?? this.viewportMatrix.scale,
940
+ dx: t.dx ?? this.viewportMatrix.dx,
941
+ dy: t.dy ?? this.viewportMatrix.dy
942
+ }, this.contentMatrix = j(this.viewportMatrix);
843
943
  }
844
- patchContentMatrix(e) {
944
+ patchContentMatrix(t) {
845
945
  this.contentMatrix = {
846
- scale: e.scale ?? this.contentMatrix.scale,
847
- dx: e.dx ?? this.contentMatrix.dx,
848
- dy: e.dy ?? this.contentMatrix.dy
849
- }, this.viewportMatrix = K(this.contentMatrix);
946
+ scale: t.scale ?? this.contentMatrix.scale,
947
+ dx: t.dx ?? this.contentMatrix.dx,
948
+ dy: t.dy ?? this.contentMatrix.dy
949
+ }, this.viewportMatrix = j(this.contentMatrix);
850
950
  }
851
951
  }
852
- class ue {
853
- constructor(e) {
854
- this.transformer = e;
952
+ class gt {
953
+ constructor(t) {
954
+ this.transformer = t;
855
955
  }
856
956
  getViewportMatrix() {
857
957
  return { ...this.transformer.getViewportMatrix() };
@@ -860,118 +960,117 @@ class ue {
860
960
  return { ...this.transformer.getContentMatrix() };
861
961
  }
862
962
  }
863
- const we = () => {
864
- const r = document.createElement("div");
865
- return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
866
- }, ye = () => {
867
- const r = document.createElement("div");
868
- return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
869
- }, me = () => {
870
- const r = document.createElement("div");
871
- return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden", r;
963
+ const ut = () => {
964
+ const e = document.createElement("div");
965
+ return e.style.width = "100%", e.style.height = "100%", e.style.position = "relative", e.style.overflow = "hidden", e;
966
+ }, wt = () => {
967
+ const e = document.createElement("div");
968
+ return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "0", e.style.height = "0", e;
969
+ }, yt = () => {
970
+ const e = document.createElement("div");
971
+ return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.visibility = "hidden", e;
872
972
  };
873
- class ve {
874
- constructor(e, t) {
875
- a(this, "canvasWrapper", null);
876
- a(this, "host", we());
877
- a(this, "container", ye());
878
- a(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
879
- a(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
880
- this.graphStore = e, this.viewportTransformer = t, this.host.appendChild(this.container);
881
- }
882
- attach(e) {
883
- this.detach(), this.canvasWrapper = e, this.canvasWrapper.appendChild(this.host);
973
+ class ft {
974
+ constructor(t, o) {
975
+ s(this, "canvasWrapper", null);
976
+ s(this, "host", ut());
977
+ s(this, "container", wt());
978
+ s(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
979
+ s(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
980
+ this.graphStore = t, this.viewportTransformer = o, this.host.appendChild(this.container);
981
+ }
982
+ attach(t) {
983
+ this.detach(), this.canvasWrapper = t, this.canvasWrapper.appendChild(this.host);
884
984
  }
885
985
  detach() {
886
986
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
887
987
  }
888
988
  applyTransform() {
889
- const e = this.viewportTransformer.getContentMatrix();
890
- this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.dx}, ${e.dy})`;
989
+ const t = this.viewportTransformer.getContentMatrix();
990
+ this.container.style.transform = `matrix(${t.scale}, 0, 0, ${t.scale}, ${t.dx}, ${t.dy})`;
891
991
  }
892
- attachNode(e) {
893
- const t = this.graphStore.getNode(e), s = me();
894
- s.appendChild(t.element), this.container.appendChild(s), this.nodeIdToWrapperElementMap.set(e, s), this.updateNodeCoordinates(e), this.updateNodePriority(e), s.style.visibility = "visible";
992
+ attachNode(t) {
993
+ const o = this.graphStore.getNode(t), r = yt();
994
+ r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(t, r), this.updateNodeCoordinates(t), this.updateNodePriority(t), r.style.visibility = "visible";
895
995
  }
896
- detachNode(e) {
897
- const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.get(e);
898
- s.removeChild(t.element), this.container.removeChild(s), this.nodeIdToWrapperElementMap.delete(e);
996
+ detachNode(t) {
997
+ const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
998
+ r.removeChild(o.element), this.container.removeChild(r), this.nodeIdToWrapperElementMap.delete(t);
899
999
  }
900
- attachEdge(e) {
901
- const t = this.graphStore.getEdge(e);
902
- this.edgeIdToElementMap.set(e, t.shape.svg), this.container.appendChild(t.shape.svg), this.updateEdge(e), this.updateEdgePriority(e);
1000
+ attachEdge(t) {
1001
+ const o = this.graphStore.getEdge(t);
1002
+ this.edgeIdToElementMap.set(t, o.shape.svg), this.container.appendChild(o.shape.svg), this.renderEdge(t), this.updateEdgePriority(t);
903
1003
  }
904
- detachEdge(e) {
905
- const t = this.graphStore.getEdge(e);
906
- this.container.removeChild(t.shape.svg), this.edgeIdToElementMap.delete(e);
1004
+ detachEdge(t) {
1005
+ const o = this.graphStore.getEdge(t);
1006
+ this.container.removeChild(o.shape.svg), this.edgeIdToElementMap.delete(t);
907
1007
  }
908
1008
  clear() {
909
- this.edgeIdToElementMap.forEach((e, t) => {
910
- this.detachEdge(t);
911
- }), this.nodeIdToWrapperElementMap.forEach((e, t) => {
912
- this.detachNode(t);
1009
+ this.edgeIdToElementMap.forEach((t, o) => {
1010
+ this.detachEdge(o);
1011
+ }), this.nodeIdToWrapperElementMap.forEach((t, o) => {
1012
+ this.detachNode(o);
913
1013
  });
914
1014
  }
915
1015
  destroy() {
916
1016
  this.clear(), this.detach(), this.host.removeChild(this.container);
917
1017
  }
918
- updateNodeCoordinates(e) {
919
- const t = this.nodeIdToWrapperElementMap.get(e), s = this.graphStore.getNode(e), { width: n, height: o } = s.element.getBoundingClientRect(), h = this.viewportTransformer.getViewportMatrix().scale, i = s.centerFn(n, o), d = s.x - h * i.x, c = s.y - h * i.y;
920
- t.style.transform = `translate(${d}px, ${c}px)`;
921
- }
922
- updateNodePriority(e) {
923
- const t = this.graphStore.getNode(e), s = this.nodeIdToWrapperElementMap.get(e);
924
- s.style.zIndex = `${t.priority}`;
925
- }
926
- updateEdgeShape(e) {
927
- const t = this.edgeIdToElementMap.get(e);
928
- this.container.removeChild(t);
929
- const s = this.graphStore.getEdge(e);
930
- this.edgeIdToElementMap.set(e, s.shape.svg), this.container.appendChild(s.shape.svg);
931
- }
932
- updateEdge(e) {
933
- const t = this.graphStore.getEdge(e), s = this.graphStore.getPort(t.from), n = this.graphStore.getPort(t.to), o = s.element.getBoundingClientRect(), h = n.element.getBoundingClientRect(), i = this.host.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix(), c = {
934
- x: d.scale * (o.left - i.left) + d.dx,
935
- y: d.scale * (o.top - i.top) + d.dy
936
- }, u = {
937
- x: d.scale * (h.left - i.left) + d.dx,
938
- y: d.scale * (h.top - i.top) + d.dy
939
- }, w = s.centerFn(
940
- o.width * d.scale,
941
- o.height * d.scale
942
- ), m = n.centerFn(
943
- h.width * d.scale,
944
- h.height * d.scale
945
- ), y = {
946
- x: c.x + w.x,
947
- y: c.y + w.y
948
- }, p = {
949
- x: u.x + m.x,
950
- y: u.y + m.y
951
- }, M = Math.min(y.x, p.x), P = Math.min(y.y, p.y), S = Math.abs(p.x - y.x), b = Math.abs(p.y - y.y);
952
- t.shape.svg.style.width = `${S}px`, t.shape.svg.style.height = `${b}px`, t.shape.svg.style.transform = `translate(${M}px, ${P}px)`;
953
- const L = y.x <= p.x ? 1 : -1, F = y.y <= p.y ? 1 : -1;
954
- t.shape.update(
955
- { x: S, y: b },
956
- L,
957
- F,
958
- s.direction,
959
- n.direction
960
- );
1018
+ updateNodeCoordinates(t) {
1019
+ const o = this.nodeIdToWrapperElementMap.get(t), r = this.graphStore.getNode(t), { width: i, height: n } = r.element.getBoundingClientRect(), d = this.viewportTransformer.getViewportMatrix().scale, c = r.centerFn(i, n), h = r.x - d * c.x, l = r.y - d * c.y;
1020
+ o.style.transform = `translate(${h}px, ${l}px)`;
1021
+ }
1022
+ updateNodePriority(t) {
1023
+ const o = this.graphStore.getNode(t), r = this.nodeIdToWrapperElementMap.get(t);
1024
+ r.style.zIndex = `${o.priority}`;
1025
+ }
1026
+ updateEdgeShape(t) {
1027
+ const o = this.edgeIdToElementMap.get(t);
1028
+ this.container.removeChild(o);
1029
+ const r = this.graphStore.getEdge(t);
1030
+ this.edgeIdToElementMap.set(t, r.shape.svg), this.container.appendChild(r.shape.svg);
1031
+ }
1032
+ 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
1036
+ }, a = {
1037
+ x: h.scale * (d.left - c.left) + h.dx,
1038
+ y: h.scale * (d.top - c.top) + h.dy
1039
+ }, w = {
1040
+ x: l.x,
1041
+ y: l.y,
1042
+ width: n.width * h.scale,
1043
+ height: n.height * h.scale,
1044
+ direction: r.direction,
1045
+ portId: o.from,
1046
+ nodeId: this.graphStore.getPortNodeId(o.from)
1047
+ }, y = {
1048
+ x: a.x,
1049
+ y: a.y,
1050
+ width: d.width * h.scale,
1051
+ height: d.height * h.scale,
1052
+ direction: i.direction,
1053
+ portId: o.to,
1054
+ nodeId: this.graphStore.getPortNodeId(o.to)
1055
+ };
1056
+ o.shape.render({
1057
+ source: w,
1058
+ target: y
1059
+ });
961
1060
  }
962
- updateEdgePriority(e) {
963
- const t = this.graphStore.getEdge(e);
964
- t.shape.svg.style.zIndex = `${t.priority}`;
1061
+ updateEdgePriority(t) {
1062
+ const o = this.graphStore.getEdge(t);
1063
+ o.shape.svg.style.zIndex = `${o.priority}`;
965
1064
  }
966
1065
  }
967
- class $ {
968
- constructor(e) {
969
- a(this, "counter", 0);
970
- this.checkExists = e;
971
- }
972
- create(e) {
973
- if (e !== void 0)
974
- return e;
1066
+ class C {
1067
+ constructor(t) {
1068
+ s(this, "counter", 0);
1069
+ this.checkExists = t;
1070
+ }
1071
+ create(t) {
1072
+ if (t !== void 0)
1073
+ return t;
975
1074
  for (; this.checkExists(this.counter); )
976
1075
  this.counter++;
977
1076
  return this.counter;
@@ -980,133 +1079,126 @@ class $ {
980
1079
  this.counter = 0;
981
1080
  }
982
1081
  }
983
- class A extends Error {
1082
+ class S extends Error {
984
1083
  constructor() {
985
1084
  super(...arguments);
986
- a(this, "name", "HtmlGraphError");
1085
+ s(this, "name", "HtmlGraphError");
987
1086
  }
988
1087
  }
989
- class pe {
990
- constructor(e, t, s, n, o, h, i, d) {
991
- a(this, "nodeIdGenerator", new $(
992
- (e) => this.graphStore.getNode(e) !== void 0
1088
+ class vt {
1089
+ constructor(t, o, r, i, n, d, c) {
1090
+ s(this, "nodeIdGenerator", new C(
1091
+ (t) => this.graphStore.getNode(t) !== void 0
993
1092
  ));
994
- a(this, "portIdGenerator", new $(
995
- (e) => this.graphStore.getPort(e) !== void 0
1093
+ s(this, "portIdGenerator", new C(
1094
+ (t) => this.graphStore.getPort(t) !== void 0
996
1095
  ));
997
- a(this, "edgeIdGenerator", new $(
998
- (e) => this.graphStore.getEdge(e) !== void 0
1096
+ s(this, "edgeIdGenerator", new C(
1097
+ (t) => this.graphStore.getEdge(t) !== void 0
999
1098
  ));
1000
- this.graphStore = e, this.htmlController = t, this.viewportTransformer = s, this.defaultNodesCenterFn = n, this.defaultPortsCenterFn = o, this.defaultPortsDirection = h, this.defaultNodesPriorityFn = i, this.defaultEdgesPriorityFn = d;
1099
+ this.graphStore = t, this.htmlController = o, this.viewportTransformer = r, this.defaultNodesCenterFn = i, this.defaultPortsDirection = n, this.defaultNodesPriorityFn = d, this.defaultEdgesPriorityFn = c;
1001
1100
  }
1002
- attach(e) {
1003
- this.htmlController.attach(e);
1101
+ attach(t) {
1102
+ this.htmlController.attach(t);
1004
1103
  }
1005
1104
  detach() {
1006
1105
  this.htmlController.detach();
1007
1106
  }
1008
- addNode(e) {
1009
- const t = this.nodeIdGenerator.create(e.nodeId);
1010
- if (this.graphStore.getNode(t) !== void 0)
1011
- throw new A("failed to add node with existing id");
1107
+ addNode(t) {
1108
+ const o = this.nodeIdGenerator.create(t.nodeId);
1109
+ if (this.graphStore.getNode(o) !== void 0)
1110
+ throw new S("failed to add node with existing id");
1012
1111
  this.graphStore.addNode({
1013
- nodeId: t,
1014
- element: e.element,
1015
- x: e.x,
1016
- y: e.y,
1017
- centerFn: e.centerFn ?? this.defaultNodesCenterFn,
1018
- priority: e.priority ?? this.defaultNodesPriorityFn()
1019
- }), this.htmlController.attachNode(t), Array.from(e.ports ?? []).forEach((s) => {
1112
+ nodeId: o,
1113
+ element: t.element,
1114
+ x: t.x,
1115
+ y: t.y,
1116
+ centerFn: t.centerFn ?? this.defaultNodesCenterFn,
1117
+ priority: t.priority ?? this.defaultNodesPriorityFn()
1118
+ }), this.htmlController.attachNode(o), Array.from(t.ports ?? []).forEach((r) => {
1020
1119
  this.markPort({
1021
- portId: s.id,
1022
- element: s.element,
1023
- nodeId: t,
1024
- centerFn: s.centerFn,
1025
- direction: s.direction
1120
+ portId: r.id,
1121
+ element: r.element,
1122
+ nodeId: o,
1123
+ direction: r.direction
1026
1124
  });
1027
1125
  });
1028
1126
  }
1029
- markPort(e) {
1030
- const t = this.portIdGenerator.create(e.portId);
1031
- if (this.graphStore.getPort(t) !== void 0)
1032
- throw new A("failed to add port with existing id");
1033
- if (this.graphStore.getNode(e.nodeId) === void 0)
1034
- throw new A("failed to set port on nonexisting node");
1127
+ markPort(t) {
1128
+ const o = this.portIdGenerator.create(t.portId);
1129
+ if (this.graphStore.getPort(o) !== void 0)
1130
+ throw new S("failed to add port with existing id");
1131
+ if (this.graphStore.getNode(t.nodeId) === void 0)
1132
+ throw new S("failed to set port on nonexisting node");
1035
1133
  this.graphStore.addPort({
1036
- portId: t,
1037
- element: e.element,
1038
- nodeId: e.nodeId,
1039
- centerFn: e.centerFn ?? this.defaultPortsCenterFn,
1040
- direction: e.direction ?? this.defaultPortsDirection
1134
+ portId: o,
1135
+ element: t.element,
1136
+ nodeId: t.nodeId,
1137
+ direction: t.direction ?? this.defaultPortsDirection
1041
1138
  });
1042
1139
  }
1043
- addEdge(e) {
1044
- const t = this.edgeIdGenerator.create(e.edgeId);
1045
- if (this.graphStore.getEdge(t) !== void 0)
1046
- throw new A("failed to add edge with existing id");
1047
- if (this.graphStore.getPort(e.from) === void 0)
1048
- throw new A("failed to add edge from nonexisting port");
1049
- if (this.graphStore.getPort(e.to) === void 0)
1050
- throw new A("failed to add edge to nonexisting port");
1051
- const s = this.resolveEdgeType(e.from, e.to);
1140
+ addEdge(t) {
1141
+ const o = this.edgeIdGenerator.create(t.edgeId);
1142
+ if (this.graphStore.getEdge(o) !== void 0)
1143
+ throw new S("failed to add edge with existing id");
1144
+ if (this.graphStore.getPort(t.from) === void 0)
1145
+ throw new S("failed to add edge from nonexisting port");
1146
+ if (this.graphStore.getPort(t.to) === void 0)
1147
+ throw new S("failed to add edge to nonexisting port");
1052
1148
  this.graphStore.addEdge({
1053
- edgeId: t,
1054
- from: e.from,
1055
- to: e.to,
1056
- shape: e.shapeFactory(s),
1057
- priority: e.priority ?? this.defaultEdgesPriorityFn()
1058
- }), this.htmlController.attachEdge(t);
1059
- }
1060
- updateEdge(e) {
1061
- const t = this.graphStore.getEdge(e.edgeId);
1062
- if (t === void 0)
1063
- throw new A("failed to update nonexisting edge");
1064
- if (e.shape !== void 0) {
1065
- const s = this.resolveEdgeType(t.from, t.to);
1066
- t.shape = e.shape(s), this.htmlController.updateEdgeShape(e.edgeId);
1067
- }
1068
- e.priority !== void 0 && (t.priority = e.priority, this.htmlController.updateEdgePriority(e.edgeId)), this.htmlController.updateEdge(e.edgeId);
1069
- }
1070
- updatePort(e, t) {
1071
- const s = this.graphStore.getPort(e);
1072
- if (s === void 0)
1073
- throw new A("failed to unset nonexisting port");
1074
- s.direction = t.direction ?? s.direction, s.centerFn = t.centerFn ?? s.centerFn, this.graphStore.getPortAdjacentEdgeIds(e).forEach((o) => {
1075
- this.htmlController.updateEdge(o);
1149
+ edgeId: o,
1150
+ from: t.from,
1151
+ to: t.to,
1152
+ shape: t.shape,
1153
+ priority: t.priority ?? this.defaultEdgesPriorityFn()
1154
+ }), this.htmlController.attachEdge(o);
1155
+ }
1156
+ updateEdge(t) {
1157
+ const o = this.graphStore.getEdge(t.edgeId);
1158
+ if (o === void 0)
1159
+ throw new S("failed to update nonexisting edge");
1160
+ t.shape !== void 0 && (o.shape = t.shape, this.htmlController.updateEdgeShape(t.edgeId)), t.priority !== void 0 && (o.priority = t.priority, this.htmlController.updateEdgePriority(t.edgeId)), t.from !== void 0 && this.graphStore.updateEdgeFrom(t.edgeId, t.from), t.to !== void 0 && this.graphStore.updateEdgeTo(t.edgeId, t.to), this.htmlController.renderEdge(t.edgeId);
1161
+ }
1162
+ updatePort(t, o) {
1163
+ const r = this.graphStore.getPort(t);
1164
+ if (r === void 0)
1165
+ 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);
1076
1168
  });
1077
1169
  }
1078
- updateNode(e, t) {
1079
- const s = this.graphStore.getNode(e);
1080
- if (s === void 0)
1081
- throw new A("failed to update nonexisting node");
1082
- s.x = (t == null ? void 0 : t.x) ?? s.x, s.y = (t == null ? void 0 : t.y) ?? s.y, s.centerFn = (t == null ? void 0 : t.centerFn) ?? s.centerFn, s.priority = (t == null ? void 0 : t.priority) ?? s.priority, this.htmlController.updateNodeCoordinates(e), this.htmlController.updateNodePriority(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((o) => {
1083
- this.htmlController.updateEdge(o);
1170
+ updateNode(t, o) {
1171
+ const r = this.graphStore.getNode(t);
1172
+ if (r === void 0)
1173
+ 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);
1084
1176
  });
1085
1177
  }
1086
- removeEdge(e) {
1087
- if (this.graphStore.getEdge(e) === void 0)
1088
- throw new A("failed to remove nonexisting edge");
1089
- this.htmlController.detachEdge(e), this.graphStore.removeEdge(e);
1178
+ removeEdge(t) {
1179
+ if (this.graphStore.getEdge(t) === void 0)
1180
+ throw new S("failed to remove nonexisting edge");
1181
+ this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
1090
1182
  }
1091
- unmarkPort(e) {
1092
- if (this.graphStore.getPort(e) === void 0)
1093
- throw new A("failed to unset nonexisting port");
1094
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
1095
- this.removeEdge(t);
1096
- }), this.graphStore.removePort(e);
1183
+ unmarkPort(t) {
1184
+ if (this.graphStore.getPort(t) === void 0)
1185
+ throw new S("failed to unset nonexisting port");
1186
+ this.graphStore.getPortAdjacentEdgeIds(t).forEach((o) => {
1187
+ this.removeEdge(o);
1188
+ }), this.graphStore.removePort(t);
1097
1189
  }
1098
- removeNode(e) {
1099
- if (this.graphStore.getNode(e) === void 0)
1100
- throw new A("failed to remove nonexisting node");
1101
- this.graphStore.getNodePortIds(e).forEach((t) => {
1102
- this.unmarkPort(t);
1103
- }), this.htmlController.detachNode(e), this.graphStore.removeNode(e);
1190
+ removeNode(t) {
1191
+ if (this.graphStore.getNode(t) === void 0)
1192
+ throw new S("failed to remove nonexisting node");
1193
+ this.graphStore.getNodePortIds(t).forEach((o) => {
1194
+ this.unmarkPort(o);
1195
+ }), this.htmlController.detachNode(t), this.graphStore.removeNode(t);
1104
1196
  }
1105
- patchViewportMatrix(e) {
1106
- this.viewportTransformer.patchViewportMatrix(e), this.htmlController.applyTransform();
1197
+ patchViewportMatrix(t) {
1198
+ this.viewportTransformer.patchViewportMatrix(t), this.htmlController.applyTransform();
1107
1199
  }
1108
- patchContentMatrix(e) {
1109
- this.viewportTransformer.patchContentMatrix(e), this.htmlController.applyTransform();
1200
+ patchContentMatrix(t) {
1201
+ this.viewportTransformer.patchContentMatrix(t), this.htmlController.applyTransform();
1110
1202
  }
1111
1203
  clear() {
1112
1204
  this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
@@ -1114,106 +1206,97 @@ class pe {
1114
1206
  destroy() {
1115
1207
  this.clear(), this.htmlController.destroy();
1116
1208
  }
1117
- resolveEdgeType(e, t) {
1118
- if (e === t)
1119
- return C.PortCycle;
1120
- const s = this.graphStore.getPortNodeId(e), n = this.graphStore.getPortNodeId(t);
1121
- return s === n ? C.NodeCycle : C.Regular;
1122
- }
1123
1209
  }
1124
- class xe {
1125
- constructor(e) {
1126
- a(this, "transformation");
1127
- a(this, "model");
1128
- a(this, "canvasController");
1129
- a(this, "edgeShapeFactory");
1130
- this.apiOptions = e;
1131
- const t = de(this.apiOptions), s = new ge(), n = new ce();
1132
- this.model = new le(n), this.transformation = new ue(s);
1133
- const o = new ve(n, s);
1134
- this.canvasController = new pe(
1210
+ class xt {
1211
+ constructor(t) {
1212
+ s(this, "transformation");
1213
+ s(this, "model");
1214
+ s(this, "canvasController");
1215
+ s(this, "edgeShapeFactory");
1216
+ 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);
1220
+ this.canvasController = new vt(
1221
+ i,
1135
1222
  n,
1136
- o,
1137
- s,
1138
- t.nodes.centerFn,
1139
- t.ports.centerFn,
1140
- t.ports.direction,
1141
- t.nodes.priorityFn,
1142
- t.edges.priorityFn
1143
- ), this.edgeShapeFactory = t.edges.shapeFactory;
1223
+ r,
1224
+ o.nodes.centerFn,
1225
+ o.ports.direction,
1226
+ o.nodes.priorityFn,
1227
+ o.edges.priorityFn
1228
+ ), this.edgeShapeFactory = o.edges.shapeFactory;
1144
1229
  }
1145
- attach(e) {
1146
- return this.canvasController.attach(e), this;
1230
+ attach(t) {
1231
+ return this.canvasController.attach(t), this;
1147
1232
  }
1148
1233
  detach() {
1149
1234
  return this.canvasController.detach(), this;
1150
1235
  }
1151
- addNode(e) {
1236
+ addNode(t) {
1152
1237
  return this.canvasController.addNode({
1153
- nodeId: e.id,
1154
- element: e.element,
1155
- x: e.x,
1156
- y: e.y,
1157
- ports: e.ports,
1158
- centerFn: e.centerFn,
1159
- priority: e.priority
1238
+ nodeId: t.id,
1239
+ element: t.element,
1240
+ x: t.x,
1241
+ y: t.y,
1242
+ ports: t.ports,
1243
+ centerFn: t.centerFn,
1244
+ priority: t.priority
1160
1245
  }), this;
1161
1246
  }
1162
- updateNode(e, t) {
1163
- return this.canvasController.updateNode(e, {
1164
- x: t == null ? void 0 : t.x,
1165
- y: t == null ? void 0 : t.y,
1166
- priority: t == null ? void 0 : t.priority,
1167
- centerFn: t == null ? void 0 : t.centerFn
1247
+ updateNode(t, o) {
1248
+ return this.canvasController.updateNode(t, {
1249
+ x: o == null ? void 0 : o.x,
1250
+ y: o == null ? void 0 : o.y,
1251
+ priority: o == null ? void 0 : o.priority,
1252
+ centerFn: o == null ? void 0 : o.centerFn
1168
1253
  }), this;
1169
1254
  }
1170
- removeNode(e) {
1171
- return this.canvasController.removeNode(e), this;
1255
+ removeNode(t) {
1256
+ return this.canvasController.removeNode(t), this;
1172
1257
  }
1173
- addEdge(e) {
1174
- const t = e.shape !== void 0 ? B(e.shape) : this.edgeShapeFactory;
1258
+ addEdge(t) {
1175
1259
  return this.canvasController.addEdge({
1176
- edgeId: e.id,
1177
- from: e.from,
1178
- to: e.to,
1179
- shapeFactory: t,
1180
- priority: e.priority
1260
+ edgeId: t.id,
1261
+ from: t.from,
1262
+ to: t.to,
1263
+ shape: t.shape ?? this.edgeShapeFactory(),
1264
+ priority: t.priority
1181
1265
  }), this;
1182
1266
  }
1183
- updateEdge(e, t) {
1184
- const s = (t == null ? void 0 : t.shape) !== void 0 ? B(t.shape) : void 0;
1267
+ updateEdge(t, o) {
1185
1268
  return this.canvasController.updateEdge({
1186
- edgeId: e,
1187
- shape: s,
1188
- priority: t == null ? void 0 : t.priority
1269
+ edgeId: t,
1270
+ shape: o == null ? void 0 : o.shape,
1271
+ priority: o == null ? void 0 : o.priority,
1272
+ from: o == null ? void 0 : o.from,
1273
+ to: o == null ? void 0 : o.to
1189
1274
  }), this;
1190
1275
  }
1191
- removeEdge(e) {
1192
- return this.canvasController.removeEdge(e), this;
1276
+ removeEdge(t) {
1277
+ return this.canvasController.removeEdge(t), this;
1193
1278
  }
1194
- markPort(e) {
1279
+ markPort(t) {
1195
1280
  return this.canvasController.markPort({
1196
- portId: e.id,
1197
- element: e.element,
1198
- nodeId: e.nodeId,
1199
- centerFn: e.centerFn,
1200
- direction: e.direction
1281
+ portId: t.id,
1282
+ element: t.element,
1283
+ nodeId: t.nodeId,
1284
+ direction: t.direction
1201
1285
  }), this;
1202
1286
  }
1203
- updatePortMark(e, t) {
1204
- return this.canvasController.updatePort(e, {
1205
- direction: t == null ? void 0 : t.direction,
1206
- centerFn: t == null ? void 0 : t.centerFn
1287
+ updatePort(t, o) {
1288
+ return this.canvasController.updatePort(t, {
1289
+ direction: o == null ? void 0 : o.direction
1207
1290
  }), this;
1208
1291
  }
1209
- unmarkPort(e) {
1210
- return this.canvasController.unmarkPort(e), this;
1292
+ unmarkPort(t) {
1293
+ return this.canvasController.unmarkPort(t), this;
1211
1294
  }
1212
- patchViewportMatrix(e) {
1213
- return this.canvasController.patchViewportMatrix(e), this;
1295
+ patchViewportMatrix(t) {
1296
+ return this.canvasController.patchViewportMatrix(t), this;
1214
1297
  }
1215
- patchContentMatrix(e) {
1216
- return this.canvasController.patchContentMatrix(e), this;
1298
+ patchContentMatrix(t) {
1299
+ return this.canvasController.patchContentMatrix(t), this;
1217
1300
  }
1218
1301
  clear() {
1219
1302
  return this.canvasController.clear(), this;
@@ -1222,169 +1305,169 @@ class xe {
1222
1305
  this.clear(), this.canvasController.destroy();
1223
1306
  }
1224
1307
  }
1225
- const D = (r, e, t) => {
1226
- const { x: s, y: n, width: o, height: h } = r.getBoundingClientRect();
1227
- return e >= s && e <= s + o && t >= n && t <= n + h;
1228
- }, k = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, V = (r, e) => {
1229
- e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
1308
+ 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;
1311
+ }, L = (e, t, o) => t >= 0 && t <= e.innerWidth && o >= 0 && o <= e.innerHeight, D = (e, t) => {
1312
+ t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
1230
1313
  };
1231
- class fe {
1232
- constructor(e, t) {
1233
- a(this, "model");
1234
- a(this, "transformation");
1235
- a(this, "maxNodePriority", 0);
1236
- a(this, "nodes", /* @__PURE__ */ new Map());
1237
- a(this, "grabbedNodeId", null);
1238
- a(this, "onNodeDrag");
1239
- a(this, "onBeforeNodeDrag");
1240
- a(this, "nodeIdGenerator", new $(
1241
- (e) => this.nodes.has(e)
1314
+ class St {
1315
+ constructor(t, o) {
1316
+ s(this, "model");
1317
+ s(this, "transformation");
1318
+ s(this, "maxNodePriority", 0);
1319
+ s(this, "nodes", /* @__PURE__ */ new Map());
1320
+ s(this, "grabbedNodeId", null);
1321
+ s(this, "onNodeDrag");
1322
+ s(this, "onBeforeNodeDrag");
1323
+ s(this, "nodeIdGenerator", new C(
1324
+ (t) => this.nodes.has(t)
1242
1325
  ));
1243
- a(this, "element", null);
1244
- a(this, "onWindowMouseMove", (e) => {
1245
- if (this.element !== null && (!D(this.element, e.clientX, e.clientY) || !k(this.window, e.clientX, e.clientY))) {
1326
+ s(this, "element", null);
1327
+ s(this, "onWindowMouseMove", (t) => {
1328
+ if (this.element !== null && (!P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY))) {
1246
1329
  this.cancelMouseDrag();
1247
1330
  return;
1248
1331
  }
1249
- this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, e.movementX, e.movementY);
1332
+ this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
1250
1333
  });
1251
- a(this, "onWindowMouseUp", (e) => {
1252
- e.button === 0 && this.cancelMouseDrag();
1334
+ s(this, "onWindowMouseUp", (t) => {
1335
+ t.button === 0 && this.cancelMouseDrag();
1253
1336
  });
1254
- a(this, "onWindowTouchMove", (e) => {
1255
- if (e.touches.length !== 1)
1337
+ s(this, "onWindowTouchMove", (t) => {
1338
+ if (t.touches.length !== 1)
1256
1339
  return;
1257
- const t = e.touches[0];
1258
- if (this.element !== null && (!D(this.element, t.clientX, t.clientY) || !k(this.window, t.clientX, t.clientY))) {
1340
+ const o = t.touches[0];
1341
+ if (this.element !== null && (!P(this.element, o.clientX, o.clientY) || !L(this.window, o.clientX, o.clientY))) {
1259
1342
  this.cancelTouchDrag();
1260
1343
  return;
1261
1344
  }
1262
1345
  if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1263
- const s = t.clientX - this.previousTouchCoords.x, n = t.clientY - this.previousTouchCoords.y;
1264
- this.dragNode(this.grabbedNodeId, s, n), this.previousTouchCoords = {
1265
- x: e.touches[0].clientX,
1266
- y: e.touches[0].clientY
1346
+ const r = o.clientX - this.previousTouchCoords.x, i = o.clientY - this.previousTouchCoords.y;
1347
+ this.dragNode(this.grabbedNodeId, r, i), this.previousTouchCoords = {
1348
+ x: t.touches[0].clientX,
1349
+ y: t.touches[0].clientY
1267
1350
  };
1268
1351
  }
1269
1352
  });
1270
- a(this, "onWindowTouchFinish", (e) => {
1271
- e.touches.length > 0 ? this.previousTouchCoords = {
1272
- x: e.touches[0].clientX,
1273
- y: e.touches[0].clientY
1353
+ s(this, "onWindowTouchFinish", (t) => {
1354
+ t.touches.length > 0 ? this.previousTouchCoords = {
1355
+ x: t.touches[0].clientX,
1356
+ y: t.touches[0].clientY
1274
1357
  } : this.cancelTouchDrag();
1275
1358
  });
1276
- a(this, "previousTouchCoords", null);
1277
- a(this, "freezePriority");
1278
- a(this, "window", window);
1279
- a(this, "dragCursor");
1280
- var s, n;
1281
- this.canvas = e, this.transformation = this.canvas.transformation, this.model = this.canvas.model, this.onNodeDrag = ((s = t == null ? void 0 : t.events) == null ? void 0 : s.onNodeDrag) ?? (() => {
1282
- }), this.onBeforeNodeDrag = ((n = t == null ? void 0 : t.events) == null ? void 0 : n.onBeforeNodeDrag) ?? (() => !0), this.freezePriority = (t == null ? void 0 : t.moveOnTop) === !1, this.dragCursor = (t == null ? void 0 : t.dragCursor) !== void 0 ? t.dragCursor : "grab";
1359
+ s(this, "previousTouchCoords", null);
1360
+ s(this, "freezePriority");
1361
+ s(this, "window", window);
1362
+ s(this, "dragCursor");
1363
+ var r, i;
1364
+ 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";
1283
1366
  }
1284
- attach(e) {
1285
- return this.detach(), this.element = e, this.canvas.attach(this.element), this;
1367
+ attach(t) {
1368
+ return this.detach(), this.element = t, this.canvas.attach(this.element), this;
1286
1369
  }
1287
1370
  detach() {
1288
1371
  return this.canvas.detach(), this.element !== null && (this.element = null), this;
1289
1372
  }
1290
- addNode(e) {
1291
- const t = this.nodeIdGenerator.create(e.id);
1292
- this.canvas.addNode({ ...e, id: t }), this.updateMaxNodePriority(t);
1293
- const s = (o) => {
1294
- if (this.element === null || o.button !== 0)
1373
+ addNode(t) {
1374
+ const o = this.nodeIdGenerator.create(t.id);
1375
+ this.canvas.addNode({ ...t, id: o }), this.updateMaxNodePriority(o);
1376
+ const r = (n) => {
1377
+ if (this.element === null || n.button !== 0)
1295
1378
  return;
1296
- const h = this.model.getNode(t);
1379
+ const d = this.model.getNode(o);
1297
1380
  this.onBeforeNodeDrag({
1298
- nodeId: t,
1299
- element: e.element,
1300
- x: h.x,
1301
- y: h.y
1302
- }) && (o.stopImmediatePropagation(), this.grabbedNodeId = t, V(this.element, this.dragCursor), this.moveNodeOnTop(t), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1303
- }, n = (o) => {
1304
- o.stopImmediatePropagation(), this.previousTouchCoords = {
1305
- x: o.touches[0].clientX,
1306
- y: o.touches[0].clientY
1381
+ nodeId: o,
1382
+ 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
1307
1390
  };
1308
- const h = this.model.getNode(t);
1391
+ const d = this.model.getNode(o);
1309
1392
  this.onBeforeNodeDrag({
1310
- nodeId: t,
1311
- element: e.element,
1312
- x: h.x,
1313
- y: h.y
1314
- }) && o.touches.length === 1 && (this.grabbedNodeId = t, this.moveNodeOnTop(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
1393
+ nodeId: o,
1394
+ 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));
1315
1398
  };
1316
- return this.nodes.set(t, {
1317
- element: e.element,
1318
- onMouseDown: s,
1319
- onTouchStart: n
1320
- }), e.element.addEventListener("mousedown", s), e.element.addEventListener("touchstart", n), this;
1399
+ return this.nodes.set(o, {
1400
+ element: t.element,
1401
+ onMouseDown: r,
1402
+ onTouchStart: i
1403
+ }), t.element.addEventListener("mousedown", r), t.element.addEventListener("touchstart", i), this;
1321
1404
  }
1322
- updateNode(e, t) {
1323
- return this.canvas.updateNode(e, t), this.updateMaxNodePriority(e), this;
1405
+ updateNode(t, o) {
1406
+ return this.canvas.updateNode(t, o), this.updateMaxNodePriority(t), this;
1324
1407
  }
1325
- removeNode(e) {
1326
- const t = this.nodes.get(e);
1327
- return t !== void 0 && (t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart)), this.nodes.delete(e), this.canvas.removeNode(e), this;
1408
+ removeNode(t) {
1409
+ const o = this.nodes.get(t);
1410
+ return o !== void 0 && (o.element.removeEventListener("mousedown", o.onMouseDown), o.element.removeEventListener("touchstart", o.onTouchStart)), this.nodes.delete(t), this.canvas.removeNode(t), this;
1328
1411
  }
1329
- markPort(e) {
1330
- return this.canvas.markPort(e), this;
1412
+ markPort(t) {
1413
+ return this.canvas.markPort(t), this;
1331
1414
  }
1332
- updatePortMark(e, t) {
1333
- return this.canvas.updatePortMark(e, t), this;
1415
+ updatePort(t, o) {
1416
+ return this.canvas.updatePort(t, o), this;
1334
1417
  }
1335
- unmarkPort(e) {
1336
- return this.canvas.unmarkPort(e), this;
1418
+ unmarkPort(t) {
1419
+ return this.canvas.unmarkPort(t), this;
1337
1420
  }
1338
- addEdge(e) {
1339
- return this.canvas.addEdge(e), this;
1421
+ addEdge(t) {
1422
+ return this.canvas.addEdge(t), this;
1340
1423
  }
1341
- updateEdge(e, t) {
1342
- return this.canvas.updateEdge(e, t), this;
1424
+ updateEdge(t, o) {
1425
+ return this.canvas.updateEdge(t, o), this;
1343
1426
  }
1344
- removeEdge(e) {
1345
- return this.canvas.removeEdge(e), this;
1427
+ removeEdge(t) {
1428
+ return this.canvas.removeEdge(t), this;
1346
1429
  }
1347
- patchViewportMatrix(e) {
1348
- return this.canvas.patchViewportMatrix(e), this;
1430
+ patchViewportMatrix(t) {
1431
+ return this.canvas.patchViewportMatrix(t), this;
1349
1432
  }
1350
- patchContentMatrix(e) {
1351
- return this.canvas.patchContentMatrix(e), this;
1433
+ patchContentMatrix(t) {
1434
+ return this.canvas.patchContentMatrix(t), this;
1352
1435
  }
1353
1436
  clear() {
1354
- return this.canvas.clear(), this.nodes.forEach((e) => {
1355
- e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart);
1437
+ return this.canvas.clear(), this.nodes.forEach((t) => {
1438
+ t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart);
1356
1439
  }), this.nodes.clear(), this.maxNodePriority = 0, this;
1357
1440
  }
1358
1441
  destroy() {
1359
1442
  this.detach(), this.clear(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1360
1443
  }
1361
- dragNode(e, t, s) {
1362
- const n = this.model.getNode(e);
1363
- if (n === null)
1444
+ dragNode(t, o, r) {
1445
+ const i = this.model.getNode(t);
1446
+ if (i === null)
1364
1447
  return;
1365
- const o = this.canvas.transformation.getContentMatrix(), h = o.scale * n.x + o.dx, i = o.scale * n.y + o.dy, d = h + t, c = i + s, u = this.canvas.transformation.getViewportMatrix(), w = u.scale * d + u.dx, m = u.scale * c + u.dy;
1366
- this.canvas.updateNode(e, { x: w, y: m }), this.onNodeDrag({
1367
- nodeId: e,
1368
- element: n.element,
1369
- x: n.x,
1370
- y: n.y
1448
+ const n = this.canvas.transformation.getContentMatrix(), d = n.scale * i.x + n.dx, c = n.scale * i.y + n.dy, h = d + o, l = c + r, a = this.canvas.transformation.getViewportMatrix(), w = a.scale * h + a.dx, y = a.scale * l + a.dy;
1449
+ this.canvas.updateNode(t, { x: w, y }), this.onNodeDrag({
1450
+ nodeId: t,
1451
+ element: i.element,
1452
+ x: i.x,
1453
+ y: i.y
1371
1454
  });
1372
1455
  }
1373
- updateMaxNodePriority(e) {
1374
- const t = this.model.getNode(e).priority;
1375
- this.maxNodePriority = Math.max(this.maxNodePriority, t);
1456
+ updateMaxNodePriority(t) {
1457
+ const o = this.model.getNode(t).priority;
1458
+ this.maxNodePriority = Math.max(this.maxNodePriority, o);
1376
1459
  }
1377
- moveNodeOnTop(e) {
1460
+ moveNodeOnTop(t) {
1378
1461
  if (this.freezePriority)
1379
1462
  return;
1380
- this.maxNodePriority += 2, this.updateNode(e, { priority: this.maxNodePriority });
1381
- const t = this.maxNodePriority - 1;
1382
- this.model.getNodeAdjacentEdgeIds(e).forEach((n) => {
1383
- this.updateEdge(n, { priority: t });
1463
+ this.maxNodePriority += 2, this.updateNode(t, { priority: this.maxNodePriority });
1464
+ const o = this.maxNodePriority - 1;
1465
+ this.model.getNodeAdjacentEdgeIds(t).forEach((i) => {
1466
+ this.updateEdge(i, { priority: o });
1384
1467
  });
1385
1468
  }
1386
1469
  cancelMouseDrag() {
1387
- this.grabbedNodeId = null, this.element !== null && V(this.element, null), this.removeMouseDragListeners();
1470
+ this.grabbedNodeId = null, this.element !== null && D(this.element, null), this.removeMouseDragListeners();
1388
1471
  }
1389
1472
  removeMouseDragListeners() {
1390
1473
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -1396,200 +1479,200 @@ class fe {
1396
1479
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
1397
1480
  }
1398
1481
  }
1399
- const Ee = (r) => {
1400
- const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, n = t !== null ? 1 / t : 1 / 0;
1401
- return (o) => {
1402
- let h = o.nextTransform.scale, i = o.nextTransform.dx, d = o.nextTransform.dy;
1403
- return o.nextTransform.scale > n && o.nextTransform.scale > o.prevTransform.scale && (h = Math.max(o.prevTransform.scale, n), i = o.prevTransform.dx, d = o.prevTransform.dy), o.nextTransform.scale < s && o.nextTransform.scale < o.prevTransform.scale && (h = Math.min(o.prevTransform.scale, s), i = o.prevTransform.dx, d = o.prevTransform.dy), {
1404
- scale: h,
1405
- dx: i,
1406
- dy: d
1407
- };
1482
+ 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 };
1408
1491
  };
1409
- }, Ae = (r) => {
1410
- const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, n = r.maxY !== null ? r.maxY : 1 / 0;
1411
- return (o) => {
1412
- let h = o.nextTransform.dx, i = o.nextTransform.dy;
1413
- h < e && h < o.prevTransform.dx && (h = Math.min(o.prevTransform.dx, e));
1414
- const d = o.canvasWidth * o.prevTransform.scale;
1415
- h > t - d && h > o.prevTransform.dx && (h = Math.max(o.prevTransform.dx, t - d)), i < s && i < o.prevTransform.dy && (i = Math.min(o.prevTransform.dy, s));
1416
- const c = o.canvasHeight * o.prevTransform.scale;
1417
- return i > n - c && i > o.prevTransform.dy && (i = Math.max(o.prevTransform.dy, n - c)), { scale: o.nextTransform.scale, dx: h, dy: i };
1492
+ }, 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,
1499
+ dy: h
1500
+ };
1418
1501
  };
1419
- }, J = (r) => {
1420
- if (typeof r == "function")
1421
- return r;
1422
- switch (r.type) {
1502
+ }, Tt = (e) => (t) => e.reduce(
1503
+ (o, r) => r({
1504
+ prevTransform: t.prevTransform,
1505
+ nextTransform: o,
1506
+ canvasWidth: t.canvasWidth,
1507
+ canvasHeight: t.canvasHeight
1508
+ }),
1509
+ t.nextTransform
1510
+ ), O = (e) => {
1511
+ if (typeof e == "function")
1512
+ return e;
1513
+ switch (e.type) {
1423
1514
  case "scale-limit":
1424
- return Ee({
1425
- minContentScale: r.minContentScale ?? 0,
1426
- maxContentScale: r.maxContentScale ?? 1 / 0
1515
+ return Et({
1516
+ minContentScale: e.minContentScale ?? 0,
1517
+ maxContentScale: e.maxContentScale ?? 1 / 0
1427
1518
  });
1428
1519
  case "shift-limit":
1429
- return Ae({
1430
- minX: r.minX ?? -1 / 0,
1431
- maxX: r.maxX ?? 1 / 0,
1432
- minY: r.minY ?? -1 / 0,
1433
- maxY: r.maxY ?? 1 / 0
1520
+ return At({
1521
+ minX: e.minX ?? -1 / 0,
1522
+ maxX: e.maxX ?? 1 / 0,
1523
+ minY: e.minY ?? -1 / 0,
1524
+ maxY: e.maxY ?? 1 / 0
1434
1525
  });
1435
1526
  }
1436
- }, Ce = (r) => (e) => r.reduce(
1437
- (t, s) => s({
1438
- prevTransform: e.prevTransform,
1439
- nextTransform: t,
1440
- canvasWidth: e.canvasWidth,
1441
- canvasHeight: e.canvasHeight
1442
- }),
1443
- e.nextTransform
1444
- ), Me = (r) => {
1445
- var d, c, u, w;
1446
- const e = (d = r == null ? void 0 : r.scale) == null ? void 0 : d.wheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
1447
- let n;
1448
- s !== void 0 ? Array.isArray(s) ? n = Ce(
1449
- s.map(
1450
- (m) => J(m)
1527
+ }, Mt = (e) => {
1528
+ var h, l, a, w;
1529
+ const t = (h = e == null ? void 0 : e.scale) == null ? void 0 : h.wheelSensitivity, o = t !== void 0 ? t : 1.2, r = e == null ? void 0 : e.transformPreprocessor;
1530
+ let i;
1531
+ r !== void 0 ? Array.isArray(r) ? i = Tt(
1532
+ r.map(
1533
+ (y) => O(y)
1451
1534
  )
1452
- ) : n = J(s) : n = (m) => m.nextTransform;
1453
- const o = ((c = r == null ? void 0 : r.shift) == null ? void 0 : c.cursor) !== void 0 ? r.shift.cursor : "grab", h = ((u = r == null ? void 0 : r.events) == null ? void 0 : u.onBeforeTransformStarted) ?? (() => {
1454
- }), i = ((w = r == null ? void 0 : r.events) == null ? void 0 : w.onTransformFinished) ?? (() => {
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) ?? (() => {
1455
1538
  });
1456
1539
  return {
1457
- wheelSensitivity: t,
1458
- onBeforeTransformStarted: h,
1459
- onTransformFinished: i,
1460
- transformPreprocessor: n,
1461
- shiftCursor: o
1540
+ wheelSensitivity: o,
1541
+ onBeforeTransformStarted: d,
1542
+ onTransformFinished: c,
1543
+ transformPreprocessor: i,
1544
+ shiftCursor: n
1462
1545
  };
1463
- }, z = (r) => {
1464
- const e = [], t = r.touches.length;
1465
- for (let i = 0; i < t; i++)
1466
- e.push([r.touches[i].clientX, r.touches[i].clientY]);
1467
- const s = e.reduce(
1468
- (i, d) => [i[0] + d[0], i[1] + d[1]],
1546
+ }, W = (e) => {
1547
+ 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]);
1550
+ const r = t.reduce(
1551
+ (c, h) => [c[0] + h[0], c[1] + h[1]],
1469
1552
  [0, 0]
1470
- ), n = [s[0] / t, s[1] / t], h = e.map((i) => [i[0] - n[0], i[1] - n[1]]).reduce(
1471
- (i, d) => i + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
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]),
1472
1555
  0
1473
1556
  );
1474
1557
  return {
1475
- x: n[0],
1476
- y: n[1],
1477
- scale: h / t,
1478
- touchesCnt: t,
1479
- touches: e
1558
+ x: i[0],
1559
+ y: i[1],
1560
+ scale: d / o,
1561
+ touchesCnt: o,
1562
+ touches: t
1480
1563
  };
1481
- }, Pe = (r, e, t) => ({
1482
- scale: r.scale,
1483
- dx: r.dx + r.scale * e,
1484
- dy: r.dy + r.scale * t
1485
- }), Se = (r, e, t, s) => ({
1486
- scale: r.scale * e,
1487
- dx: r.scale * (1 - e) * t + r.dx,
1488
- dy: r.scale * (1 - e) * s + r.dy
1564
+ }, Ct = (e, t, o) => ({
1565
+ scale: e.scale,
1566
+ dx: e.dx + e.scale * t,
1567
+ dy: e.dy + e.scale * o
1568
+ }), Nt = (e, t, o, r) => ({
1569
+ scale: e.scale * t,
1570
+ dx: e.scale * (1 - t) * o + e.dx,
1571
+ dy: e.scale * (1 - t) * r + e.dy
1489
1572
  });
1490
- class Ne {
1491
- constructor(e, t) {
1492
- a(this, "model");
1493
- a(this, "transformation");
1494
- a(this, "element", null);
1495
- a(this, "prevTouches", null);
1496
- a(this, "window", window);
1497
- a(this, "onMouseDown", (e) => {
1498
- this.element === null || e.button !== 0 || (V(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
1573
+ class Pt {
1574
+ constructor(t, o) {
1575
+ s(this, "model");
1576
+ s(this, "transformation");
1577
+ s(this, "element", null);
1578
+ s(this, "prevTouches", null);
1579
+ s(this, "window", window);
1580
+ s(this, "onMouseDown", (t) => {
1581
+ this.element === null || t.button !== 0 || (D(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
1499
1582
  });
1500
- a(this, "onWindowMouseMove", (e) => {
1501
- if (this.element === null || !D(this.element, e.clientX, e.clientY) || !k(this.window, e.clientX, e.clientY)) {
1583
+ s(this, "onWindowMouseMove", (t) => {
1584
+ if (this.element === null || !P(this.element, t.clientX, t.clientY) || !L(this.window, t.clientX, t.clientY)) {
1502
1585
  this.stopMouseDrag();
1503
1586
  return;
1504
1587
  }
1505
- const t = -e.movementX, s = -e.movementY;
1506
- this.moveViewport(this.element, t, s);
1588
+ const o = -t.movementX, r = -t.movementY;
1589
+ this.moveViewport(this.element, o, r);
1507
1590
  });
1508
- a(this, "onWindowMouseUp", (e) => {
1509
- this.element === null || e.button !== 0 || this.stopMouseDrag();
1591
+ s(this, "onWindowMouseUp", (t) => {
1592
+ this.element === null || t.button !== 0 || this.stopMouseDrag();
1510
1593
  });
1511
- a(this, "onWheelScroll", (e) => {
1512
- e.preventDefault();
1513
- const { left: t, top: s } = this.element.getBoundingClientRect(), n = e.clientX - t, o = e.clientY - s, i = 1 / (e.deltaY < 0 ? this.options.wheelSensitivity : 1 / this.options.wheelSensitivity);
1514
- this.scaleViewport(this.element, i, n, o);
1594
+ s(this, "onWheelScroll", (t) => {
1595
+ 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);
1515
1598
  });
1516
- a(this, "onTouchStart", (e) => {
1517
- this.prevTouches = z(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
1599
+ s(this, "onTouchStart", (t) => {
1600
+ this.prevTouches = W(t), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
1518
1601
  });
1519
- a(this, "onWindowTouchMove", (e) => {
1520
- const t = this.element;
1521
- if (t === null)
1602
+ s(this, "onWindowTouchMove", (t) => {
1603
+ const o = this.element;
1604
+ if (o === null)
1522
1605
  return;
1523
- const s = z(e);
1524
- if (!s.touches.every(
1525
- (o) => D(t, o[0], o[1]) && k(this.window, o[0], o[1])
1606
+ const r = W(t);
1607
+ if (!r.touches.every(
1608
+ (n) => P(o, n[0], n[1]) && L(this.window, n[0], n[1])
1526
1609
  )) {
1527
1610
  this.stopTouchDrag();
1528
1611
  return;
1529
1612
  }
1530
- if ((s.touchesCnt === 1 || s.touchesCnt === 2) && this.moveViewport(
1531
- t,
1532
- -(s.x - this.prevTouches.x),
1533
- -(s.y - this.prevTouches.y)
1534
- ), s.touchesCnt === 2) {
1535
- const { left: o, top: h } = t.getBoundingClientRect(), i = this.prevTouches.x - o, d = this.prevTouches.y - h, u = 1 / (s.scale / this.prevTouches.scale);
1536
- this.scaleViewport(t, u, i, d);
1613
+ if ((r.touchesCnt === 1 || r.touchesCnt === 2) && this.moveViewport(
1614
+ o,
1615
+ -(r.x - this.prevTouches.x),
1616
+ -(r.y - this.prevTouches.y)
1617
+ ), 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);
1537
1620
  }
1538
- this.prevTouches = s;
1621
+ this.prevTouches = r;
1539
1622
  });
1540
- a(this, "onWindowTouchFinish", (e) => {
1541
- e.touches.length > 0 ? this.prevTouches = z(e) : this.stopTouchDrag();
1623
+ s(this, "onWindowTouchFinish", (t) => {
1624
+ t.touches.length > 0 ? this.prevTouches = W(t) : this.stopTouchDrag();
1542
1625
  });
1543
- a(this, "observer", new ResizeObserver(() => {
1544
- const e = this.canvas.transformation.getViewportMatrix(), { width: t, height: s } = this.element.getBoundingClientRect(), n = this.options.transformPreprocessor({
1545
- prevTransform: e,
1546
- nextTransform: e,
1547
- canvasWidth: t,
1548
- canvasHeight: s
1626
+ s(this, "observer", new ResizeObserver(() => {
1627
+ const t = this.canvas.transformation.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), i = this.options.transformPreprocessor({
1628
+ prevTransform: t,
1629
+ nextTransform: t,
1630
+ canvasWidth: o,
1631
+ canvasHeight: r
1549
1632
  });
1550
- this.canvas.patchViewportMatrix(n), this.options.onTransformFinished();
1633
+ this.canvas.patchViewportMatrix(i), this.options.onTransformFinished();
1551
1634
  }));
1552
- a(this, "options");
1553
- this.canvas = e, this.options = Me(t), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1635
+ s(this, "options");
1636
+ this.canvas = t, this.options = Mt(o), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1554
1637
  }
1555
- attach(e) {
1556
- return this.detach(), this.element = e, 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;
1638
+ attach(t) {
1639
+ 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;
1557
1640
  }
1558
1641
  detach() {
1559
1642
  return this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null), this;
1560
1643
  }
1561
- addNode(e) {
1562
- return this.canvas.addNode(e), this;
1644
+ addNode(t) {
1645
+ return this.canvas.addNode(t), this;
1563
1646
  }
1564
- updateNode(e, t) {
1565
- return this.canvas.updateNode(e, t), this;
1647
+ updateNode(t, o) {
1648
+ return this.canvas.updateNode(t, o), this;
1566
1649
  }
1567
- removeNode(e) {
1568
- return this.canvas.removeNode(e), this;
1650
+ removeNode(t) {
1651
+ return this.canvas.removeNode(t), this;
1569
1652
  }
1570
- markPort(e) {
1571
- return this.canvas.markPort(e), this;
1653
+ markPort(t) {
1654
+ return this.canvas.markPort(t), this;
1572
1655
  }
1573
- updatePortMark(e, t) {
1574
- return this.canvas.updatePortMark(e, t), this;
1656
+ updatePort(t, o) {
1657
+ return this.canvas.updatePort(t, o), this;
1575
1658
  }
1576
- unmarkPort(e) {
1577
- return this.canvas.unmarkPort(e), this;
1659
+ unmarkPort(t) {
1660
+ return this.canvas.unmarkPort(t), this;
1578
1661
  }
1579
- addEdge(e) {
1580
- return this.canvas.addEdge(e), this;
1662
+ addEdge(t) {
1663
+ return this.canvas.addEdge(t), this;
1581
1664
  }
1582
- updateEdge(e, t) {
1583
- return this.canvas.updateEdge(e, t), this;
1665
+ updateEdge(t, o) {
1666
+ return this.canvas.updateEdge(t, o), this;
1584
1667
  }
1585
- removeEdge(e) {
1586
- return this.canvas.removeEdge(e), this;
1668
+ removeEdge(t) {
1669
+ return this.canvas.removeEdge(t), this;
1587
1670
  }
1588
- patchViewportMatrix(e) {
1589
- return this.canvas.patchViewportMatrix(e), this;
1671
+ patchViewportMatrix(t) {
1672
+ return this.canvas.patchViewportMatrix(t), this;
1590
1673
  }
1591
- patchContentMatrix(e) {
1592
- return this.canvas.patchContentMatrix(e), this;
1674
+ patchContentMatrix(t) {
1675
+ return this.canvas.patchContentMatrix(t), this;
1593
1676
  }
1594
1677
  clear() {
1595
1678
  return this.canvas.clear(), this;
@@ -1597,28 +1680,28 @@ class Ne {
1597
1680
  destroy() {
1598
1681
  this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1599
1682
  }
1600
- moveViewport(e, t, s) {
1683
+ moveViewport(t, o, r) {
1601
1684
  this.options.onBeforeTransformStarted();
1602
- const n = this.transformation.getViewportMatrix(), o = Pe(n, t, s), { width: h, height: i } = e.getBoundingClientRect(), d = this.options.transformPreprocessor({
1603
- prevTransform: n,
1604
- nextTransform: o,
1605
- canvasWidth: h,
1606
- canvasHeight: i
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
1607
1690
  });
1608
- this.canvas.patchViewportMatrix(d), this.options.onTransformFinished();
1691
+ this.canvas.patchViewportMatrix(h), this.options.onTransformFinished();
1609
1692
  }
1610
- scaleViewport(e, t, s, n) {
1693
+ scaleViewport(t, o, r, i) {
1611
1694
  this.options.onBeforeTransformStarted();
1612
- const o = this.canvas.transformation.getViewportMatrix(), h = Se(o, t, s, n), { width: i, height: d } = e.getBoundingClientRect(), c = this.options.transformPreprocessor({
1613
- prevTransform: o,
1614
- nextTransform: h,
1615
- canvasWidth: i,
1616
- canvasHeight: d
1695
+ const n = this.canvas.transformation.getViewportMatrix(), d = Nt(n, o, r, i), { width: c, height: h } = t.getBoundingClientRect(), l = this.options.transformPreprocessor({
1696
+ prevTransform: n,
1697
+ nextTransform: d,
1698
+ canvasWidth: c,
1699
+ canvasHeight: h
1617
1700
  });
1618
- this.canvas.patchViewportMatrix(c), this.options.onTransformFinished();
1701
+ this.canvas.patchViewportMatrix(l), this.options.onTransformFinished();
1619
1702
  }
1620
1703
  stopMouseDrag() {
1621
- this.element !== null && V(this.element, null), this.removeMouseDragListeners();
1704
+ this.element !== null && D(this.element, null), this.removeMouseDragListeners();
1622
1705
  }
1623
1706
  removeMouseDragListeners() {
1624
1707
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -1630,103 +1713,103 @@ class Ne {
1630
1713
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
1631
1714
  }
1632
1715
  }
1633
- class Te {
1716
+ class Lt {
1634
1717
  constructor() {
1635
- a(this, "keyMap", /* @__PURE__ */ new Map());
1636
- a(this, "valueMap", /* @__PURE__ */ new Map());
1718
+ s(this, "keyMap", /* @__PURE__ */ new Map());
1719
+ s(this, "valueMap", /* @__PURE__ */ new Map());
1637
1720
  }
1638
- set(e, t) {
1639
- this.keyMap.set(e, t), this.valueMap.set(t, e);
1721
+ set(t, o) {
1722
+ this.keyMap.set(t, o), this.valueMap.set(o, t);
1640
1723
  }
1641
- hasKey(e) {
1642
- return this.keyMap.has(e);
1724
+ hasKey(t) {
1725
+ return this.keyMap.has(t);
1643
1726
  }
1644
- hasValue(e) {
1645
- return this.valueMap.has(e);
1727
+ hasValue(t) {
1728
+ return this.valueMap.has(t);
1646
1729
  }
1647
- getByKey(e) {
1648
- return this.keyMap.get(e);
1730
+ getByKey(t) {
1731
+ return this.keyMap.get(t);
1649
1732
  }
1650
- getByValue(e) {
1651
- return this.valueMap.get(e);
1733
+ getByValue(t) {
1734
+ return this.valueMap.get(t);
1652
1735
  }
1653
- deleteByKey(e) {
1654
- const t = this.keyMap.get(e);
1655
- t !== void 0 && this.valueMap.delete(t), this.keyMap.delete(e);
1736
+ deleteByKey(t) {
1737
+ const o = this.keyMap.get(t);
1738
+ o !== void 0 && this.valueMap.delete(o), this.keyMap.delete(t);
1656
1739
  }
1657
- deleteByValue(e) {
1658
- const t = this.valueMap.get(e);
1659
- t !== void 0 && this.keyMap.delete(t), this.valueMap.delete(e);
1740
+ deleteByValue(t) {
1741
+ const o = this.valueMap.get(t);
1742
+ o !== void 0 && this.keyMap.delete(o), this.valueMap.delete(t);
1660
1743
  }
1661
- forEach(e) {
1662
- this.keyMap.forEach((t, s) => {
1663
- e(t, s);
1744
+ forEach(t) {
1745
+ this.keyMap.forEach((o, r) => {
1746
+ t(o, r);
1664
1747
  });
1665
1748
  }
1666
1749
  clear() {
1667
1750
  this.keyMap.clear(), this.valueMap.clear();
1668
1751
  }
1669
1752
  }
1670
- class Le {
1671
- constructor(e) {
1672
- a(this, "transformation");
1673
- a(this, "model");
1674
- a(this, "nodes", new Te());
1675
- a(this, "nodeIdGenerator", new $(
1676
- (e) => this.nodes.hasKey(e)
1753
+ class Dt {
1754
+ constructor(t) {
1755
+ s(this, "transformation");
1756
+ s(this, "model");
1757
+ s(this, "nodes", new Lt());
1758
+ s(this, "nodeIdGenerator", new C(
1759
+ (t) => this.nodes.hasKey(t)
1677
1760
  ));
1678
- a(this, "nodesResizeObserver");
1679
- this.canvas = e, this.nodesResizeObserver = new window.ResizeObserver((t) => {
1680
- t.forEach((s) => {
1681
- const n = s.target;
1682
- this.reactNodeChange(n);
1761
+ s(this, "nodesResizeObserver");
1762
+ this.canvas = t, this.nodesResizeObserver = new window.ResizeObserver((o) => {
1763
+ o.forEach((r) => {
1764
+ const i = r.target;
1765
+ this.reactNodeChange(i);
1683
1766
  });
1684
1767
  }), this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1685
1768
  }
1686
- attach(e) {
1687
- return this.canvas.attach(e), this;
1769
+ attach(t) {
1770
+ return this.canvas.attach(t), this;
1688
1771
  }
1689
1772
  detach() {
1690
1773
  return this.canvas.detach(), this;
1691
1774
  }
1692
- addNode(e) {
1693
- const t = this.nodeIdGenerator.create(e.id);
1775
+ addNode(t) {
1776
+ const o = this.nodeIdGenerator.create(t.id);
1694
1777
  return this.canvas.addNode({
1695
- ...e,
1696
- id: t
1697
- }), this.nodes.set(t, e.element), this.nodesResizeObserver.observe(e.element), this;
1778
+ ...t,
1779
+ id: o
1780
+ }), this.nodes.set(o, t.element), this.nodesResizeObserver.observe(t.element), this;
1698
1781
  }
1699
- updateNode(e, t) {
1700
- return this.canvas.updateNode(e, t), this;
1782
+ updateNode(t, o) {
1783
+ return this.canvas.updateNode(t, o), this;
1701
1784
  }
1702
- removeNode(e) {
1703
- this.canvas.removeNode(e);
1704
- const t = this.nodes.getByKey(e);
1705
- return this.nodes.deleteByKey(e), this.nodesResizeObserver.unobserve(t), this;
1785
+ removeNode(t) {
1786
+ this.canvas.removeNode(t);
1787
+ const o = this.nodes.getByKey(t);
1788
+ return this.nodes.deleteByKey(t), this.nodesResizeObserver.unobserve(o), this;
1706
1789
  }
1707
- markPort(e) {
1708
- return this.canvas.markPort(e), this;
1790
+ markPort(t) {
1791
+ return this.canvas.markPort(t), this;
1709
1792
  }
1710
- updatePortMark(e, t) {
1711
- return this.canvas.updatePortMark(e, t), this;
1793
+ updatePort(t, o) {
1794
+ return this.canvas.updatePort(t, o), this;
1712
1795
  }
1713
- unmarkPort(e) {
1714
- return this.canvas.unmarkPort(e), this;
1796
+ unmarkPort(t) {
1797
+ return this.canvas.unmarkPort(t), this;
1715
1798
  }
1716
- addEdge(e) {
1717
- return this.canvas.addEdge(e), this;
1799
+ addEdge(t) {
1800
+ return this.canvas.addEdge(t), this;
1718
1801
  }
1719
- updateEdge(e, t) {
1720
- return this.canvas.updateEdge(e, t), this;
1802
+ updateEdge(t, o) {
1803
+ return this.canvas.updateEdge(t, o), this;
1721
1804
  }
1722
- removeEdge(e) {
1723
- return this.canvas.removeEdge(e), this;
1805
+ removeEdge(t) {
1806
+ return this.canvas.removeEdge(t), this;
1724
1807
  }
1725
- patchViewportMatrix(e) {
1726
- return this.canvas.patchViewportMatrix(e), this;
1808
+ patchViewportMatrix(t) {
1809
+ return this.canvas.patchViewportMatrix(t), this;
1727
1810
  }
1728
- patchContentMatrix(e) {
1729
- return this.canvas.patchContentMatrix(e), this;
1811
+ patchContentMatrix(t) {
1812
+ return this.canvas.patchContentMatrix(t), this;
1730
1813
  }
1731
1814
  clear() {
1732
1815
  return this.canvas.clear(), this.nodesResizeObserver.disconnect(), this.nodes.clear(), this;
@@ -1734,57 +1817,48 @@ class Le {
1734
1817
  destroy() {
1735
1818
  this.clear(), this.canvas.destroy();
1736
1819
  }
1737
- reactNodeChange(e) {
1738
- const t = this.nodes.getByValue(e);
1739
- this.canvas.updateNode(t), this.model.getNodeAdjacentEdgeIds(t).forEach((n) => {
1740
- this.canvas.updateEdge(n);
1820
+ reactNodeChange(t) {
1821
+ const o = this.nodes.getByValue(t);
1822
+ this.canvas.updateNode(o), this.model.getNodeAdjacentEdgeIds(o).forEach((i) => {
1823
+ this.canvas.updateEdge(i);
1741
1824
  });
1742
1825
  }
1743
1826
  }
1744
- class Ie {
1827
+ class mt {
1745
1828
  constructor() {
1746
- a(this, "coreOptions");
1747
- a(this, "dragOptions");
1748
- a(this, "transformOptions");
1749
- a(this, "isDraggable", !1);
1750
- a(this, "isTransformable", !1);
1751
- a(this, "hasResizeReactiveNodes", !1);
1829
+ s(this, "coreOptions");
1830
+ s(this, "dragOptions");
1831
+ s(this, "transformOptions");
1832
+ s(this, "isDraggable", !1);
1833
+ s(this, "isTransformable", !1);
1834
+ s(this, "hasResizeReactiveNodes", !1);
1752
1835
  }
1753
- setOptions(e) {
1754
- return this.coreOptions = e, this;
1836
+ setOptions(t) {
1837
+ return this.coreOptions = t, this;
1755
1838
  }
1756
- setUserDraggableNodes(e) {
1757
- return this.isDraggable = !0, this.dragOptions = e, this;
1839
+ setUserDraggableNodes(t) {
1840
+ return this.isDraggable = !0, this.dragOptions = t, this;
1758
1841
  }
1759
- setUserTransformableCanvas(e) {
1760
- return this.isTransformable = !0, this.transformOptions = e, this;
1842
+ setUserTransformableCanvas(t) {
1843
+ return this.isTransformable = !0, this.transformOptions = t, this;
1761
1844
  }
1762
- setResizableReactiveNodes() {
1845
+ setResizeReactiveNodes() {
1763
1846
  return this.hasResizeReactiveNodes = !0, this;
1764
1847
  }
1765
1848
  build() {
1766
- let e = new xe(this.coreOptions);
1767
- return this.hasResizeReactiveNodes && (e = new Le(e)), this.isDraggable && (e = new fe(e, this.dragOptions)), this.isTransformable && (e = new Ne(e, this.transformOptions)), e;
1849
+ let t = new xt(this.coreOptions);
1850
+ return this.hasResizeReactiveNodes && (t = new Dt(t)), this.isDraggable && (t = new St(t, this.dragOptions)), this.isTransformable && (t = new Pt(t, this.transformOptions)), t;
1768
1851
  }
1769
1852
  }
1770
1853
  export {
1771
- O as BezierEdgeShape,
1772
- xe as CanvasCore,
1773
- re as CycleCircleEdgeShape,
1774
- X as CycleSquareEdgeShape,
1775
- se as DetourBezierEdgeShape,
1776
- G as DetourStraightEdgeShape,
1777
- C as EdgeType,
1778
- ee as HorizontalEdgeShape,
1779
- Ie as HtmlGraphBuilder,
1780
- A as HtmlGraphError,
1781
- Le as ResizeReactiveNodesCanvas,
1782
- q as StraightEdgeShape,
1783
- fe as UserDraggableNodesCanvas,
1784
- Ne as UserTransformableCanvas,
1785
- te as VerticalEdgeShape,
1786
- oe as createBezierEdgeShapeFactory,
1787
- ae as createHorizontalEdgeShapeFactory,
1788
- ne as createStraightEdgeShareFactory,
1789
- ie as createVerticalEdgeShapeFactory
1854
+ ot as BezierEdgeShape,
1855
+ xt as CanvasCore,
1856
+ rt as HorizontalEdgeShape,
1857
+ mt as HtmlGraphBuilder,
1858
+ S as HtmlGraphError,
1859
+ Dt as ResizeReactiveNodesCanvas,
1860
+ it as StraightEdgeShape,
1861
+ St as UserDraggableNodesCanvas,
1862
+ Pt as UserTransformableCanvas,
1863
+ nt as VerticalEdgeShape
1790
1864
  };