@html-graph/html-graph 2.2.1 → 2.3.0

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