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