@html-graph/html-graph 1.3.0 → 2.0.1

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