@html-graph/html-graph 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,25 +1,26 @@
1
- var De = Object.defineProperty;
2
- var Ne = (r, e, t) => e in r ? De(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var s = (r, e, t) => Ne(r, typeof e != "symbol" ? e + "" : e, t);
1
+ var Me = Object.defineProperty;
2
+ var Re = (r, e, t) => e in r ? Me(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var s = (r, e, t) => Re(r, typeof e != "symbol" ? e + "" : e, t);
4
4
  const T = (r, e) => ({
5
5
  x: r.scale * e.x + r.x,
6
6
  y: r.scale * e.y + r.y
7
7
  });
8
8
  var L = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(L || {});
9
- const Me = () => {
9
+ const Le = () => {
10
10
  const r = document.createElement("div");
11
11
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
12
- }, Re = () => {
12
+ }, Ce = () => {
13
13
  const r = document.createElement("div");
14
14
  return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
15
- }, Le = (r) => {
15
+ }, Ve = (r) => {
16
16
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
17
17
  };
18
18
  class ue {
19
19
  constructor(e, t, o) {
20
- s(this, "host", Me());
21
- s(this, "container", Re());
20
+ s(this, "host", Le());
21
+ s(this, "container", Ce());
22
22
  s(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
23
+ s(this, "attachedNodeIds", /* @__PURE__ */ new Set());
23
24
  s(this, "applyTransform", () => {
24
25
  const e = this.viewportStore.getContentMatrix();
25
26
  this.container.style.transform = `matrix(${e.scale}, 0, 0, ${e.scale}, ${e.x}, ${e.y})`;
@@ -28,11 +29,11 @@ class ue {
28
29
  }
29
30
  attachNode(e) {
30
31
  const t = this.graphStore.getNode(e);
31
- Le(t.element), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
32
+ Ve(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
32
33
  }
33
34
  detachNode(e) {
34
35
  const t = this.graphStore.getNode(e);
35
- this.container.removeChild(t.element);
36
+ this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
36
37
  }
37
38
  attachEdge(e) {
38
39
  const t = this.graphStore.getEdge(e).payload.shape.svg;
@@ -45,16 +46,16 @@ class ue {
45
46
  clear() {
46
47
  this.edgeIdToElementMap.forEach((e, t) => {
47
48
  this.detachEdge(t);
48
- }), this.graphStore.getAllNodeIds().forEach((e) => {
49
+ }), this.attachedNodeIds.forEach((e) => {
49
50
  this.detachNode(e);
50
51
  });
51
52
  }
52
53
  destroy() {
53
- this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.clear(), this.element.removeChild(this.host), this.host.removeChild(this.container);
54
+ this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.element.removeChild(this.host), this.host.removeChild(this.container);
54
55
  }
55
56
  updateNodePosition(e) {
56
- const t = this.graphStore.getNode(e), { width: o, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, a = t.payload.centerFn(o, i), h = t.payload.x - n * a.x, d = t.payload.y - n * a.y;
57
- t.element.style.transform = `translate(${h}px, ${d}px)`;
57
+ const t = this.graphStore.getNode(e), { width: o, height: i } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, { payload: a } = t, h = a.centerFn(o, i), d = a.x - n * h.x, c = a.y - n * h.y;
58
+ t.element.style.transform = `translate(${d}px, ${c}px)`;
58
59
  }
59
60
  updateNodePriority(e) {
60
61
  const t = this.graphStore.getNode(e);
@@ -99,7 +100,7 @@ class ue {
99
100
  };
100
101
  }
101
102
  }
102
- class Ce {
103
+ class $e {
103
104
  constructor(e) {
104
105
  s(this, "xFrom", 1 / 0);
105
106
  s(this, "yFrom", 1 / 0);
@@ -111,15 +112,15 @@ class Ce {
111
112
  this.xFrom = e.x, this.xTo = e.x + e.width, this.yFrom = e.y, this.yTo = e.y + e.height;
112
113
  }
113
114
  hasNode(e) {
114
- const t = this.graphStore.getNode(e).payload;
115
- return t.x >= this.xFrom && t.x <= this.xTo && t.y >= this.yFrom && t.y <= this.yTo;
115
+ const t = this.graphStore.getNode(e).payload, { x: o, y: i } = t;
116
+ return o >= this.xFrom && o <= this.xTo && i >= this.yFrom && i <= this.yTo;
116
117
  }
117
118
  hasEdge(e) {
118
119
  const t = this.graphStore.getEdge(e), o = this.graphStore.getPort(t.from).nodeId, i = this.graphStore.getPort(t.to).nodeId, n = this.graphStore.getNode(o).payload, a = this.graphStore.getNode(i).payload, h = Math.min(n.x, a.x), d = Math.max(n.x, a.x), c = Math.min(n.y, a.y), l = Math.max(n.y, a.y);
119
120
  return h <= this.xTo && d >= this.xFrom && c <= this.yTo && l >= this.yFrom;
120
121
  }
121
122
  }
122
- class Ve {
123
+ class Ue {
123
124
  constructor(e, t, o, i) {
124
125
  s(this, "attachedNodes", /* @__PURE__ */ new Set());
125
126
  s(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -143,7 +144,7 @@ class Ve {
143
144
  this.handleAttachEdge(a);
144
145
  });
145
146
  });
146
- this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = i, this.renderingBox = new Ce(this.graphStore), this.trigger.subscribe(this.updateViewport);
147
+ this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = i, this.renderingBox = new $e(this.graphStore), this.trigger.subscribe(this.updateViewport);
147
148
  }
148
149
  attachNode(e) {
149
150
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -197,131 +198,80 @@ class Ve {
197
198
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
198
199
  }
199
200
  }
200
- class pe {
201
- constructor() {
202
- s(this, "callbacks", /* @__PURE__ */ new Set());
203
- }
204
- subscribe(e) {
205
- this.callbacks.add(e);
206
- }
207
- unsubscribe(e) {
208
- this.callbacks.delete(e);
209
- }
210
- emit(e) {
211
- this.callbacks.forEach((t) => {
212
- t(e);
213
- });
214
- }
215
- }
216
- const A = () => {
217
- const r = new pe();
218
- return [r, r];
219
- };
220
- class $e {
221
- constructor(e) {
222
- s(this, "onAfterUpdated");
223
- this.viewportStore = e, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
224
- }
225
- getViewportMatrix() {
226
- return { ...this.viewportStore.getViewportMatrix() };
201
+ class Ie {
202
+ constructor(e, t) {
203
+ s(this, "deferredNodes", /* @__PURE__ */ new Set());
204
+ s(this, "deferredEdges", /* @__PURE__ */ new Set());
205
+ this.htmlView = e, this.graphStore = t;
227
206
  }
228
- getContentMatrix() {
229
- return { ...this.viewportStore.getContentMatrix() };
207
+ attachNode(e) {
208
+ this.isNodeValid(e) ? this.htmlView.attachNode(e) : this.deferredNodes.add(e);
230
209
  }
231
- }
232
- class Ie {
233
- constructor(e) {
234
- s(this, "onAfterNodeAdded");
235
- s(this, "onAfterNodeUpdated");
236
- s(this, "onAfterNodePriorityUpdated");
237
- s(this, "onBeforeNodeRemoved");
238
- s(this, "onAfterPortMarked");
239
- s(this, "onAfterPortUpdated");
240
- s(this, "onBeforePortUnmarked");
241
- s(this, "onAfterEdgeAdded");
242
- s(this, "onAfterEdgeShapeUpdated");
243
- s(this, "onAfterEdgeUpdated");
244
- s(this, "onAfterEdgePriorityUpdated");
245
- s(this, "onBeforeEdgeRemoved");
246
- s(this, "onBeforeClear");
247
- this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortMarked = this.graphStore.onAfterPortAdded, this.onAfterPortUpdated = this.graphStore.onAfterPortUpdated, this.onBeforePortUnmarked = this.graphStore.onBeforePortRemoved, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeUpdated = this.graphStore.onAfterEdgeUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
210
+ detachNode(e) {
211
+ this.deferredNodes.has(e) ? this.deferredNodes.delete(e) : this.htmlView.detachNode(e);
248
212
  }
249
- getNode(e) {
250
- const t = this.graphStore.getNode(e);
251
- if (t === void 0)
252
- return null;
253
- const o = t.payload;
254
- return {
255
- element: t.element,
256
- x: o.x,
257
- y: o.y,
258
- centerFn: o.centerFn,
259
- priority: o.priority
260
- };
213
+ attachEdge(e) {
214
+ this.isEdgeValid(e) ? this.htmlView.attachEdge(e) : this.deferredEdges.add(e);
261
215
  }
262
- getElementNodeId(e) {
263
- return this.graphStore.getElementNodeId(e) ?? null;
216
+ detachEdge(e) {
217
+ this.deferredEdges.has(e) ? this.deferredEdges.delete(e) : this.htmlView.detachEdge(e);
264
218
  }
265
- getAllNodeIds() {
266
- return this.graphStore.getAllNodeIds();
219
+ updateNodePosition(e) {
220
+ this.deferredNodes.has(e) ? this.tryAttachNode(e) : this.htmlView.updateNodePosition(e);
267
221
  }
268
- getPort(e) {
269
- const t = this.graphStore.getPort(e);
270
- return t === void 0 ? null : {
271
- element: t.element,
272
- direction: t.payload.direction,
273
- nodeId: t.nodeId
274
- };
222
+ updateNodePriority(e) {
223
+ this.deferredNodes.has(e) ? this.tryAttachNode(e) : this.htmlView.updateNodePriority(e);
275
224
  }
276
- getAllPortIds() {
277
- return this.graphStore.getAllPortIds();
225
+ updateEdgeShape(e) {
226
+ this.deferredEdges.has(e) ? this.tryAttachEdge(e) : this.htmlView.updateEdgeShape(e);
278
227
  }
279
- getNodePortIds(e) {
280
- return this.graphStore.getNodePortIds(e) ?? null;
228
+ renderEdge(e) {
229
+ this.deferredEdges.has(e) ? this.tryAttachEdge(e) : this.htmlView.renderEdge(e);
281
230
  }
282
- getElementPortIds(e) {
283
- return [...this.graphStore.getElementPortIds(e)];
231
+ updateEdgePriority(e) {
232
+ this.deferredEdges.has(e) ? this.tryAttachEdge(e) : this.htmlView.updateEdgePriority(e);
284
233
  }
285
- getAllEdgeIds() {
286
- return this.graphStore.getAllEdgeIds();
234
+ clear() {
235
+ this.deferredNodes.clear(), this.deferredEdges.clear(), this.htmlView.clear();
287
236
  }
288
- getEdge(e) {
289
- const t = this.graphStore.getEdge(e);
290
- if (t === void 0)
291
- return null;
292
- const o = t.payload;
293
- return {
294
- from: t.from,
295
- to: t.to,
296
- priority: o.priority,
297
- shape: o.shape
298
- };
237
+ destroy() {
238
+ this.htmlView.destroy();
299
239
  }
300
- getPortIncomingEdgeIds(e) {
301
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
240
+ isNodeValid(e) {
241
+ const t = this.graphStore.getNode(e);
242
+ return !(t.payload.x === null || t.payload.y === null);
302
243
  }
303
- getPortOutgoingEdgeIds(e) {
304
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutgoingEdgeIds(e);
244
+ tryAttachNode(e) {
245
+ this.isNodeValid(e) && (this.deferredNodes.delete(e), this.htmlView.attachNode(e));
305
246
  }
306
- getPortCycleEdgeIds(e) {
307
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
247
+ isEdgeValid(e) {
248
+ const t = this.graphStore.getEdge(e), o = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to);
249
+ return !(this.deferredNodes.has(o.nodeId) || this.deferredNodes.has(i.nodeId));
308
250
  }
309
- getPortAdjacentEdgeIds(e) {
310
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
251
+ tryAttachEdge(e) {
252
+ this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
311
253
  }
312
- getNodeIncomingEdgeIds(e) {
313
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
254
+ }
255
+ class pe {
256
+ constructor() {
257
+ s(this, "callbacks", /* @__PURE__ */ new Set());
314
258
  }
315
- getNodeOutgoingEdgeIds(e) {
316
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutgoingEdgeIds(e);
259
+ subscribe(e) {
260
+ this.callbacks.add(e);
317
261
  }
318
- getNodeCycleEdgeIds(e) {
319
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
262
+ unsubscribe(e) {
263
+ this.callbacks.delete(e);
320
264
  }
321
- getNodeAdjacentEdgeIds(e) {
322
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
265
+ emit(e) {
266
+ this.callbacks.forEach((t) => {
267
+ t(e);
268
+ });
323
269
  }
324
270
  }
271
+ const E = () => {
272
+ const r = new pe();
273
+ return [r, r];
274
+ };
325
275
  class X {
326
276
  constructor(e) {
327
277
  s(this, "counter", 0);
@@ -345,23 +295,15 @@ class S extends Error {
345
295
  }
346
296
  }
347
297
  class we {
348
- constructor(e, t, o, i) {
349
- /**
350
- * provides api for accessing model of rendered graph
351
- */
352
- s(this, "graph");
353
- /**
354
- * provides api for accessing viewport state
355
- */
356
- s(this, "viewport");
298
+ constructor(e, t, o, i, n, a) {
357
299
  s(this, "nodeIdGenerator", new X(
358
- (e) => this.graph.getNode(e) !== null
300
+ (e) => this.graphStore.getNode(e) !== void 0
359
301
  ));
360
302
  s(this, "portIdGenerator", new X(
361
- (e) => this.graph.getPort(e) !== null
303
+ (e) => this.graphStore.getPort(e) !== void 0
362
304
  ));
363
305
  s(this, "edgeIdGenerator", new X(
364
- (e) => this.graph.getEdge(e) !== null
306
+ (e) => this.graphStore.getEdge(e) !== void 0
365
307
  ));
366
308
  s(this, "onAfterNodeAdded", (e) => {
367
309
  this.htmlView.attachNode(e);
@@ -413,13 +355,13 @@ class we {
413
355
  * emits event just before destruction of canvas
414
356
  */
415
357
  s(this, "onBeforeDestroy");
416
- this.graphStore = e, this.viewportStore = t, this.htmlView = o, this.params = i, this.graph = new Ie(this.graphStore), this.viewport = new $e(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
358
+ this.graph = e, this.viewport = t, this.graphStore = o, this.viewportStore = i, this.htmlView = n, this.params = a, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
417
359
  this.onAfterNodePriorityUpdated
418
360
  ), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
419
361
  this.onAfterEdgeShapeUpdated
420
362
  ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
421
363
  this.onAfterEdgePriorityUpdated
422
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
364
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
423
365
  }
424
366
  /**
425
367
  * adds new node
@@ -435,8 +377,8 @@ class we {
435
377
  if (this.graphStore.addNode({
436
378
  id: t,
437
379
  element: e.element,
438
- x: e.x,
439
- y: e.y,
380
+ x: e.x ?? null,
381
+ y: e.y ?? null,
440
382
  centerFn: e.centerFn ?? this.params.nodes.centerFn,
441
383
  priority: e.priority ?? this.params.nodes.priorityFn()
442
384
  }), e.ports !== void 0)
@@ -454,7 +396,7 @@ class we {
454
396
  */
455
397
  updateNode(e, t) {
456
398
  if (this.graphStore.getNode(e) === void 0)
457
- throw new S("failed to update non existing node");
399
+ throw new S("failed to update nonexistent node");
458
400
  return this.graphStore.updateNode(e, t ?? {}), this;
459
401
  }
460
402
  /**
@@ -464,7 +406,7 @@ class we {
464
406
  */
465
407
  removeNode(e) {
466
408
  if (this.graphStore.getNode(e) === void 0)
467
- throw new S("failed to remove non existing node");
409
+ throw new S("failed to remove nonexistent node");
468
410
  return this.graphStore.removeNode(e), this;
469
411
  }
470
412
  /**
@@ -497,7 +439,7 @@ class we {
497
439
  */
498
440
  unmarkPort(e) {
499
441
  if (this.graphStore.getPort(e) === void 0)
500
- throw new S("failed to unmark non existing port");
442
+ throw new S("failed to unmark nonexistent port");
501
443
  return this.graphStore.removePort(e), this;
502
444
  }
503
445
  /**
@@ -535,6 +477,13 @@ class we {
535
477
  throw new S("failed to remove nonexistent edge");
536
478
  return this.graphStore.removeEdge(e), this;
537
479
  }
480
+ /**
481
+ * clears canvas from nodes and edges
482
+ * canvas gets rolled back to initial state and can be reused
483
+ */
484
+ clear() {
485
+ return this.graphStore.clear(), this;
486
+ }
538
487
  /**
539
488
  * applies transformation for viewport matrix
540
489
  */
@@ -547,13 +496,6 @@ class we {
547
496
  patchContentMatrix(e) {
548
497
  return this.viewportStore.patchContentMatrix(e), this;
549
498
  }
550
- /**
551
- * clears canvas from nodes and edges
552
- * canvas gets rolled back to initial state and can be reused
553
- */
554
- clear() {
555
- return this.graphStore.clear(), this;
556
- }
557
499
  /**
558
500
  * destroys canvas
559
501
  * canvas element gets rolled back to initial state, and can not be reused
@@ -568,7 +510,7 @@ class we {
568
510
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.destroyed = !0);
569
511
  }
570
512
  }
571
- class Ue {
513
+ class Be {
572
514
  constructor() {
573
515
  s(this, "singleToMultiMap", /* @__PURE__ */ new Map());
574
516
  s(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -617,7 +559,7 @@ class fe {
617
559
  s(this, "incomingEdges", /* @__PURE__ */ new Map());
618
560
  s(this, "outcomingEdges", /* @__PURE__ */ new Map());
619
561
  s(this, "cycleEdges", /* @__PURE__ */ new Map());
620
- s(this, "elementPorts", new Ue());
562
+ s(this, "elementPorts", new Be());
621
563
  s(this, "afterNodeAddedEmitter");
622
564
  s(this, "onAfterNodeAdded");
623
565
  s(this, "afterNodeUpdatedEmitter");
@@ -644,7 +586,7 @@ class fe {
644
586
  s(this, "onBeforeEdgeRemoved");
645
587
  s(this, "beforeClearEmitter");
646
588
  s(this, "onBeforeClear");
647
- [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
589
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
648
590
  }
649
591
  addNode(e) {
650
592
  const t = /* @__PURE__ */ new Map(), o = {
@@ -805,13 +747,13 @@ const ie = (r) => ({
805
747
  x: 0,
806
748
  y: 0
807
749
  };
808
- class Be {
750
+ class Fe {
809
751
  constructor() {
810
752
  s(this, "viewportMatrix", ne);
811
753
  s(this, "contentMatrix", ne);
812
754
  s(this, "afterUpdateEmitter");
813
755
  s(this, "onAfterUpdated");
814
- [this.afterUpdateEmitter, this.onAfterUpdated] = A();
756
+ [this.afterUpdateEmitter, this.onAfterUpdated] = E();
815
757
  }
816
758
  getViewportMatrix() {
817
759
  return this.viewportMatrix;
@@ -864,10 +806,10 @@ class j {
864
806
  this.canvas.updateNode(t);
865
807
  }
866
808
  }
867
- const Fe = (r, e, t) => {
809
+ const Oe = (r, e, t) => {
868
810
  const { x: o, y: i, width: n, height: a } = r.getBoundingClientRect();
869
811
  return e >= o && e <= o + n && t >= i && t <= i + a;
870
- }, Oe = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, C = (r, e, t, o) => Fe(e, t, o) && Oe(r, t, o), U = (r, e) => {
812
+ }, We = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, C = (r, e, t, o) => Oe(e, t, o) && We(r, t, o), I = (r, e) => {
871
813
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
872
814
  }, B = (r) => {
873
815
  const e = document.createElement("div");
@@ -884,7 +826,7 @@ const Fe = (r, e, t) => {
884
826
  }
885
827
  ]
886
828
  };
887
- }, We = (r, e) => {
829
+ }, ke = (r, e) => {
888
830
  let t = e, o = null;
889
831
  for (; t !== null && (o = r.getElementPortIds(t)[0] ?? null, o === null); )
890
832
  t = t.parentElement;
@@ -892,7 +834,7 @@ const Fe = (r, e, t) => {
892
834
  }, ye = (r, e) => {
893
835
  const t = document.elementsFromPoint(e.x, e.y);
894
836
  for (const o of t) {
895
- const i = We(r, o);
837
+ const i = ke(r, o);
896
838
  if (i !== null)
897
839
  return i;
898
840
  }
@@ -928,7 +870,7 @@ const me = (r, e) => ({
928
870
  x: e * r.x + (1 - e) / 2 * o.x,
929
871
  y: t * r.y + (1 - t) / 2 * o.y
930
872
  });
931
- class ke {
873
+ class ze {
932
874
  constructor(e) {
933
875
  s(this, "path");
934
876
  s(this, "midpoint");
@@ -953,7 +895,7 @@ class ke {
953
895
  this.path = `${d}${h}${c}`;
954
896
  }
955
897
  }
956
- class ze {
898
+ class Xe {
957
899
  constructor(e) {
958
900
  s(this, "path");
959
901
  s(this, "midpoint");
@@ -995,7 +937,7 @@ class ze {
995
937
  }, x = {
996
938
  x: c.x + h,
997
939
  y: c.y + d
998
- }, E = {
940
+ }, A = {
999
941
  x: g.x + h,
1000
942
  y: g.y + d
1001
943
  };
@@ -1003,17 +945,17 @@ class ze {
1003
945
  `M ${t.x} ${t.y}`,
1004
946
  `L ${c.x} ${c.y}`,
1005
947
  `C ${y.x} ${y.y} ${x.x} ${x.y} ${f.x} ${f.y}`,
1006
- `C ${E.x} ${E.y} ${v.x} ${v.y} ${g.x} ${g.y}`,
948
+ `C ${A.x} ${A.y} ${v.x} ${v.y} ${g.x} ${g.y}`,
1007
949
  `L ${o.x} ${o.y}`
1008
950
  ].join(" "), this.midpoint = O(f, e.flipX, e.flipY, e.to);
1009
951
  }
1010
952
  }
1011
953
  const G = Object.freeze({
1012
954
  edgeColor: "--edge-color"
1013
- }), Ae = (r) => {
955
+ }), Ee = (r) => {
1014
956
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1015
957
  return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(G.edgeColor, r), e;
1016
- }, Ee = (r) => {
958
+ }, Ae = (r) => {
1017
959
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1018
960
  return e.setAttribute("stroke", `var(${G.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
1019
961
  }, F = () => {
@@ -1036,15 +978,15 @@ const G = Object.freeze({
1036
978
  const V = r[d + 1];
1037
979
  i = V.x - h.x, n = V.y - h.y, a = Math.sqrt(i * i + n * n);
1038
980
  }
1039
- const x = a !== 0 ? Math.min((y ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, E = y ? { x: h.x + i * x, y: h.y + n * x } : h, b = g !== 0 ? Math.min((y ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, D = y ? { x: h.x + c * b, y: h.y + l * b } : h;
981
+ const x = a !== 0 ? Math.min((y ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, A = y ? { x: h.x + i * x, y: h.y + n * x } : h, b = g !== 0 ? Math.min((y ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, D = y ? { x: h.x + c * b, y: h.y + l * b } : h;
1040
982
  d > 0 && t.push(`L ${D.x} ${D.y}`), y && t.push(
1041
- `C ${h.x} ${h.y} ${h.x} ${h.y} ${E.x} ${E.y}`
983
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${A.x} ${A.y}`
1042
984
  );
1043
985
  });
1044
986
  }
1045
987
  return t.join(" ");
1046
988
  };
1047
- class Xe {
989
+ class Ye {
1048
990
  constructor(e) {
1049
991
  s(this, "path");
1050
992
  s(this, "midpoint");
@@ -1083,7 +1025,7 @@ class Xe {
1083
1025
  );
1084
1026
  }
1085
1027
  }
1086
- class Ye {
1028
+ class He {
1087
1029
  constructor(e) {
1088
1030
  s(this, "path");
1089
1031
  s(this, "midpoint");
@@ -1114,7 +1056,7 @@ class Ye {
1114
1056
  );
1115
1057
  }
1116
1058
  }
1117
- class He {
1059
+ class je {
1118
1060
  constructor(e) {
1119
1061
  s(this, "path");
1120
1062
  s(this, "midpoint");
@@ -1144,7 +1086,7 @@ class He {
1144
1086
  this.path = M([o, a, h, i], this.params.roundness);
1145
1087
  }
1146
1088
  }
1147
- class je {
1089
+ class Ge {
1148
1090
  constructor(e) {
1149
1091
  s(this, "path");
1150
1092
  s(this, "midpoint");
@@ -1203,7 +1145,7 @@ class K {
1203
1145
  this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : d}${M(h, this.params.roundness)}`, this.midpoint = { x: (h[3].x + h[4].x) / 2, y: (h[3].y + h[4].y) / 2 };
1204
1146
  }
1205
1147
  }
1206
- class Ge {
1148
+ class Ke {
1207
1149
  constructor(e) {
1208
1150
  s(this, "path");
1209
1151
  s(this, "midpoint");
@@ -1224,7 +1166,7 @@ class Ge {
1224
1166
  this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : f}${p}`, this.midpoint = g[3];
1225
1167
  }
1226
1168
  }
1227
- class Ke {
1169
+ class Ze {
1228
1170
  constructor(e) {
1229
1171
  s(this, "path");
1230
1172
  s(this, "midpoint");
@@ -1260,7 +1202,7 @@ class Ke {
1260
1202
  };
1261
1203
  }
1262
1204
  }
1263
- class Ze {
1205
+ class Je {
1264
1206
  constructor(e) {
1265
1207
  s(this, "path");
1266
1208
  s(this, "midpoint");
@@ -1301,7 +1243,7 @@ class Ze {
1301
1243
  );
1302
1244
  }
1303
1245
  }
1304
- class Je {
1246
+ class Qe {
1305
1247
  constructor(e) {
1306
1248
  s(this, "path");
1307
1249
  s(this, "midpoint");
@@ -1375,7 +1317,7 @@ class W {
1375
1317
  s(this, "onAfterRender");
1376
1318
  s(this, "afterRenderEmitter");
1377
1319
  s(this, "arrowRenderer");
1378
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = A(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ae(e.color), this.svg.appendChild(this.group), this.line = Ee(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = F(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = F(), this.group.appendChild(this.targetArrow));
1320
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ee(e.color), this.svg.appendChild(this.group), this.line = Ae(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = F(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = F(), this.group.appendChild(this.targetArrow));
1379
1321
  }
1380
1322
  render(e) {
1381
1323
  const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = ve(
@@ -1423,7 +1365,7 @@ class W {
1423
1365
  });
1424
1366
  }
1425
1367
  }
1426
- const Qe = (r) => (e) => {
1368
+ const _e = (r) => (e) => {
1427
1369
  const o = [
1428
1370
  u,
1429
1371
  { x: e.arrowLength, y: r.radius },
@@ -1435,7 +1377,7 @@ const Qe = (r) => (e) => {
1435
1377
  y: h.y + e.shift.y
1436
1378
  })), i = `M ${o[0].x} ${o[0].y}`, n = `L ${o[1].x} ${o[1].y}`, a = `L ${o[2].x} ${o[2].y}`;
1437
1379
  return `${i} ${n} ${a} Z`;
1438
- }, _e = (r) => (e) => {
1380
+ }, qe = (r) => (e) => {
1439
1381
  const t = r.radius, o = e.arrowLength, i = (o * o + 2 * o * t) / (2 * t), n = i + t, a = o + t - t * (o + t) / n, h = t * i / n, c = [u, { x: a, y: -h }, { x: a, y: h }].map(
1440
1382
  (y) => m(y, e.direction, u)
1441
1383
  ).map((y) => ({
@@ -1443,7 +1385,7 @@ const Qe = (r) => (e) => {
1443
1385
  y: y.y + e.shift.y
1444
1386
  })), l = `M ${c[0].x} ${c[0].y}`, g = `A ${i} ${i} 0 0 0 ${c[1].x} ${c[1].y}`, p = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, f = `A ${i} ${i} 0 0 0 ${c[0].x} ${c[0].y}`;
1445
1387
  return `${l} ${g} ${p} ${f}`;
1446
- }, qe = (r) => (e) => {
1388
+ }, et = (r) => (e) => {
1447
1389
  const t = r.smallRadius, o = r.radius, i = m(
1448
1390
  {
1449
1391
  x: e.arrowLength,
@@ -1469,22 +1411,22 @@ const Qe = (r) => (e) => {
1469
1411
  return r;
1470
1412
  switch (r.type) {
1471
1413
  case "triangle":
1472
- return Qe({
1414
+ return _e({
1473
1415
  radius: r.radius ?? w.polygonArrowRadius
1474
1416
  });
1475
1417
  case "arc":
1476
- return _e({
1418
+ return qe({
1477
1419
  radius: r.radius ?? w.circleArrowRadius
1478
1420
  });
1479
1421
  default:
1480
- return qe({
1422
+ return et({
1481
1423
  smallRadius: r.smallRadius ?? w.wedgeArrowSmallRadius,
1482
1424
  angle: r.angle ?? w.wedgeArrowAngle,
1483
1425
  radius: r.radius ?? w.wedgeArrowRadius
1484
1426
  });
1485
1427
  }
1486
1428
  };
1487
- class et {
1429
+ class tt {
1488
1430
  constructor(e) {
1489
1431
  s(this, "svg");
1490
1432
  s(this, "group");
@@ -1501,7 +1443,7 @@ class et {
1501
1443
  s(this, "hasSourceArrow");
1502
1444
  s(this, "hasTargetArrow");
1503
1445
  s(this, "pathShape");
1504
- s(this, "createCyclePath", (e) => new Ge({
1446
+ s(this, "createCyclePath", (e) => new Ke({
1505
1447
  sourceDirection: e,
1506
1448
  radius: this.portCycleRadius,
1507
1449
  smallRadius: this.portCycleSmallRadius,
@@ -1509,7 +1451,7 @@ class et {
1509
1451
  hasSourceArrow: this.hasSourceArrow,
1510
1452
  hasTargetArrow: this.hasTargetArrow
1511
1453
  }));
1512
- s(this, "createDetourPath", (e, t, o, i, n) => new ze({
1454
+ s(this, "createDetourPath", (e, t, o, i, n) => new Xe({
1513
1455
  to: o,
1514
1456
  sourceDirection: e,
1515
1457
  targetDirection: t,
@@ -1522,7 +1464,7 @@ class et {
1522
1464
  hasSourceArrow: this.hasSourceArrow,
1523
1465
  hasTargetArrow: this.hasTargetArrow
1524
1466
  }));
1525
- s(this, "createLinePath", (e, t, o) => new ke({
1467
+ s(this, "createLinePath", (e, t, o) => new ze({
1526
1468
  to: o,
1527
1469
  sourceDirection: e,
1528
1470
  targetDirection: t,
@@ -1547,7 +1489,7 @@ class et {
1547
1489
  this.pathShape.render(e);
1548
1490
  }
1549
1491
  }
1550
- class tt {
1492
+ class rt {
1551
1493
  constructor(e) {
1552
1494
  s(this, "svg");
1553
1495
  s(this, "group");
@@ -1572,7 +1514,7 @@ class tt {
1572
1514
  hasSourceArrow: this.hasSourceArrow,
1573
1515
  hasTargetArrow: this.hasTargetArrow
1574
1516
  }));
1575
- s(this, "createDetourPath", (e, t, o, i, n) => new Ze({
1517
+ s(this, "createDetourPath", (e, t, o, i, n) => new Je({
1576
1518
  to: o,
1577
1519
  sourceDirection: e,
1578
1520
  targetDirection: t,
@@ -1585,7 +1527,7 @@ class tt {
1585
1527
  hasSourceArrow: this.hasSourceArrow,
1586
1528
  hasTargetArrow: this.hasTargetArrow
1587
1529
  }));
1588
- s(this, "createLinePath", (e, t, o, i) => new Xe({
1530
+ s(this, "createLinePath", (e, t, o, i) => new Ye({
1589
1531
  to: o,
1590
1532
  sourceDirection: e,
1591
1533
  targetDirection: t,
@@ -1618,7 +1560,7 @@ class tt {
1618
1560
  this.pathShape.render(e);
1619
1561
  }
1620
1562
  }
1621
- class rt {
1563
+ class ot {
1622
1564
  constructor(e) {
1623
1565
  s(this, "svg");
1624
1566
  s(this, "group");
@@ -1644,7 +1586,7 @@ class rt {
1644
1586
  hasSourceArrow: this.hasSourceArrow,
1645
1587
  hasTargetArrow: this.hasTargetArrow
1646
1588
  }));
1647
- s(this, "createDetourPath", (e, t, o, i, n) => new Ye({
1589
+ s(this, "createDetourPath", (e, t, o, i, n) => new He({
1648
1590
  to: o,
1649
1591
  sourceDirection: e,
1650
1592
  targetDirection: t,
@@ -1658,7 +1600,7 @@ class rt {
1658
1600
  hasSourceArrow: this.hasSourceArrow,
1659
1601
  hasTargetArrow: this.hasTargetArrow
1660
1602
  }));
1661
- s(this, "createLinePath", (e, t, o) => new He({
1603
+ s(this, "createLinePath", (e, t, o) => new je({
1662
1604
  to: o,
1663
1605
  sourceDirection: e,
1664
1606
  targetDirection: t,
@@ -1690,7 +1632,7 @@ class rt {
1690
1632
  this.pathShape.render(e);
1691
1633
  }
1692
1634
  }
1693
- class ot {
1635
+ class st {
1694
1636
  constructor(e) {
1695
1637
  s(this, "svg");
1696
1638
  s(this, "group");
@@ -1715,7 +1657,7 @@ class ot {
1715
1657
  hasSourceArrow: this.hasSourceArrow,
1716
1658
  hasTargetArrow: this.hasTargetArrow
1717
1659
  }));
1718
- s(this, "createDetourPath", (e, t, o, i, n) => new Je({
1660
+ s(this, "createDetourPath", (e, t, o, i, n) => new Qe({
1719
1661
  to: o,
1720
1662
  sourceDirection: e,
1721
1663
  targetDirection: t,
@@ -1728,7 +1670,7 @@ class ot {
1728
1670
  hasSourceArrow: this.hasSourceArrow,
1729
1671
  hasTargetArrow: this.hasTargetArrow
1730
1672
  }));
1731
- s(this, "createLinePath", (e, t, o, i, n) => new je({
1673
+ s(this, "createLinePath", (e, t, o, i, n) => new Ge({
1732
1674
  to: o,
1733
1675
  sourceDirection: e,
1734
1676
  targetDirection: t,
@@ -1776,7 +1718,7 @@ class Pe {
1776
1718
  s(this, "onAfterRender");
1777
1719
  s(this, "afterRenderEmitter");
1778
1720
  s(this, "arrowRenderer");
1779
- [this.afterRenderEmitter, this.onAfterRender] = A(), this.color = (e == null ? void 0 : e.color) ?? w.color, this.width = (e == null ? void 0 : e.width) ?? w.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? w.arrowLength, this.arrowRenderer = $((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? w.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? w.preOffset, this.svg = Ae(this.color), this.svg.appendChild(this.group), this.line = Ee(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = F(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = F(), this.group.appendChild(this.targetArrow));
1721
+ [this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? w.color, this.width = (e == null ? void 0 : e.width) ?? w.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? w.arrowLength, this.arrowRenderer = $((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? w.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? w.preOffset, this.svg = Ee(this.color), this.svg.appendChild(this.group), this.line = Ae(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = F(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = F(), this.group.appendChild(this.targetArrow));
1780
1722
  }
1781
1723
  render(e) {
1782
1724
  const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = ve(
@@ -1784,7 +1726,7 @@ class Pe {
1784
1726
  e.to
1785
1727
  );
1786
1728
  Se(this.svg, { x: t, y: o, width: i, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1787
- const d = { x: i, y: n }, c = new Ke({
1729
+ const d = { x: i, y: n }, c = new Ze({
1788
1730
  to: d,
1789
1731
  sourceOffset: this.sourceOffset,
1790
1732
  targetOffset: this.targetOffset,
@@ -1835,17 +1777,17 @@ class Pe {
1835
1777
  });
1836
1778
  }
1837
1779
  }
1838
- const st = () => {
1780
+ const it = () => {
1839
1781
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1840
1782
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1841
- }, it = (r) => {
1783
+ }, nt = (r) => {
1842
1784
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1843
1785
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1844
1786
  }, he = (r) => {
1845
1787
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1846
1788
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1847
1789
  };
1848
- class nt extends Error {
1790
+ class at extends Error {
1849
1791
  constructor(e) {
1850
1792
  super(e), this.name = "InteractiveEdgeError";
1851
1793
  }
@@ -1857,18 +1799,18 @@ class be {
1857
1799
  s(this, "line");
1858
1800
  s(this, "sourceArrow");
1859
1801
  s(this, "targetArrow");
1860
- s(this, "handle", st());
1802
+ s(this, "handle", it());
1861
1803
  s(this, "onAfterRender");
1862
1804
  s(this, "interactiveLine");
1863
1805
  s(this, "interactiveSourceArrow", null);
1864
1806
  s(this, "interactiveTargetArrow", null);
1865
1807
  if (this.baseEdge = e, e instanceof be)
1866
- throw new nt(
1808
+ throw new at(
1867
1809
  "interactive edge can be configured only once"
1868
1810
  );
1869
1811
  this.svg = this.baseEdge.svg, this.group = this.baseEdge.group, this.line = this.baseEdge.line, this.sourceArrow = this.baseEdge.sourceArrow, this.targetArrow = this.baseEdge.targetArrow, this.onAfterRender = this.baseEdge.onAfterRender;
1870
1812
  const o = (t == null ? void 0 : t.distance) ?? w.interactiveWidth;
1871
- this.interactiveLine = it(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = he(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = he(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((i) => {
1813
+ this.interactiveLine = nt(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = he(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = he(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((i) => {
1872
1814
  this.interactiveLine.setAttribute("d", i.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", i.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", i.targetArrowPath);
1873
1815
  });
1874
1816
  }
@@ -1876,7 +1818,7 @@ class be {
1876
1818
  this.baseEdge.render(e);
1877
1819
  }
1878
1820
  }
1879
- class Rt {
1821
+ class Lt {
1880
1822
  constructor(e, t) {
1881
1823
  s(this, "group");
1882
1824
  s(this, "line");
@@ -1893,8 +1835,113 @@ class Rt {
1893
1835
  this.baseShape.render(e);
1894
1836
  }
1895
1837
  }
1896
- const Te = (r, e) => {
1897
- const t = new fe(), o = new ue(t, e, r), i = {
1838
+ class Te {
1839
+ constructor(e) {
1840
+ s(this, "onAfterNodeAdded");
1841
+ s(this, "onAfterNodeUpdated");
1842
+ s(this, "onAfterNodePriorityUpdated");
1843
+ s(this, "onBeforeNodeRemoved");
1844
+ s(this, "onAfterPortMarked");
1845
+ s(this, "onAfterPortUpdated");
1846
+ s(this, "onBeforePortUnmarked");
1847
+ s(this, "onAfterEdgeAdded");
1848
+ s(this, "onAfterEdgeShapeUpdated");
1849
+ s(this, "onAfterEdgeUpdated");
1850
+ s(this, "onAfterEdgePriorityUpdated");
1851
+ s(this, "onBeforeEdgeRemoved");
1852
+ s(this, "onBeforeClear");
1853
+ this.graphStore = e, this.onAfterNodeAdded = this.graphStore.onAfterNodeAdded, this.onAfterNodeUpdated = this.graphStore.onAfterNodeUpdated, this.onAfterNodePriorityUpdated = this.graphStore.onAfterNodePriorityUpdated, this.onBeforeNodeRemoved = this.graphStore.onBeforeNodeRemoved, this.onAfterPortMarked = this.graphStore.onAfterPortAdded, this.onAfterPortUpdated = this.graphStore.onAfterPortUpdated, this.onBeforePortUnmarked = this.graphStore.onBeforePortRemoved, this.onAfterEdgeAdded = this.graphStore.onAfterEdgeAdded, this.onAfterEdgeShapeUpdated = this.graphStore.onAfterEdgeShapeUpdated, this.onAfterEdgeUpdated = this.graphStore.onAfterEdgeUpdated, this.onAfterEdgePriorityUpdated = this.graphStore.onAfterEdgePriorityUpdated, this.onBeforeEdgeRemoved = this.graphStore.onBeforeEdgeRemoved, this.onBeforeClear = this.graphStore.onBeforeClear;
1854
+ }
1855
+ getNode(e) {
1856
+ const t = this.graphStore.getNode(e);
1857
+ if (t === void 0)
1858
+ return null;
1859
+ const o = t.payload;
1860
+ return {
1861
+ element: t.element,
1862
+ x: o.x,
1863
+ y: o.y,
1864
+ centerFn: o.centerFn,
1865
+ priority: o.priority
1866
+ };
1867
+ }
1868
+ getElementNodeId(e) {
1869
+ return this.graphStore.getElementNodeId(e) ?? null;
1870
+ }
1871
+ getAllNodeIds() {
1872
+ return this.graphStore.getAllNodeIds();
1873
+ }
1874
+ getPort(e) {
1875
+ const t = this.graphStore.getPort(e);
1876
+ return t === void 0 ? null : {
1877
+ element: t.element,
1878
+ direction: t.payload.direction,
1879
+ nodeId: t.nodeId
1880
+ };
1881
+ }
1882
+ getAllPortIds() {
1883
+ return this.graphStore.getAllPortIds();
1884
+ }
1885
+ getNodePortIds(e) {
1886
+ return this.graphStore.getNodePortIds(e) ?? null;
1887
+ }
1888
+ getElementPortIds(e) {
1889
+ return [...this.graphStore.getElementPortIds(e)];
1890
+ }
1891
+ getAllEdgeIds() {
1892
+ return this.graphStore.getAllEdgeIds();
1893
+ }
1894
+ getEdge(e) {
1895
+ const t = this.graphStore.getEdge(e);
1896
+ if (t === void 0)
1897
+ return null;
1898
+ const o = t.payload;
1899
+ return {
1900
+ from: t.from,
1901
+ to: t.to,
1902
+ priority: o.priority,
1903
+ shape: o.shape
1904
+ };
1905
+ }
1906
+ getPortIncomingEdgeIds(e) {
1907
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
1908
+ }
1909
+ getPortOutgoingEdgeIds(e) {
1910
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutgoingEdgeIds(e);
1911
+ }
1912
+ getPortCycleEdgeIds(e) {
1913
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
1914
+ }
1915
+ getPortAdjacentEdgeIds(e) {
1916
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
1917
+ }
1918
+ getNodeIncomingEdgeIds(e) {
1919
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
1920
+ }
1921
+ getNodeOutgoingEdgeIds(e) {
1922
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutgoingEdgeIds(e);
1923
+ }
1924
+ getNodeCycleEdgeIds(e) {
1925
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
1926
+ }
1927
+ getNodeAdjacentEdgeIds(e) {
1928
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
1929
+ }
1930
+ }
1931
+ class De {
1932
+ constructor(e) {
1933
+ s(this, "onAfterUpdated");
1934
+ this.viewportStore = e, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
1935
+ }
1936
+ getViewportMatrix() {
1937
+ return { ...this.viewportStore.getViewportMatrix() };
1938
+ }
1939
+ getContentMatrix() {
1940
+ return { ...this.viewportStore.getContentMatrix() };
1941
+ }
1942
+ }
1943
+ const Ne = (r, e) => {
1944
+ const t = new fe(), o = new Te(t), i = new De(e), n = new ue(t, e, r), a = {
1898
1945
  nodes: {
1899
1946
  centerFn: me,
1900
1947
  priorityFn: () => 0
@@ -1907,7 +1954,14 @@ const Te = (r, e) => {
1907
1954
  direction: 0
1908
1955
  }
1909
1956
  };
1910
- return new we(t, e, o, i);
1957
+ return new we(
1958
+ o,
1959
+ i,
1960
+ t,
1961
+ e,
1962
+ n,
1963
+ a
1964
+ );
1911
1965
  };
1912
1966
  class k {
1913
1967
  constructor(e, t, o, i) {
@@ -2061,7 +2115,7 @@ class Z {
2061
2115
  nodeId: o,
2062
2116
  dx: a.x - i.x,
2063
2117
  dy: a.y - i.y
2064
- }, U(this.element, this.params.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2118
+ }, I(this.element, this.params.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2065
2119
  passive: !0
2066
2120
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2067
2121
  passive: !0
@@ -2163,7 +2217,7 @@ class Z {
2163
2217
  }
2164
2218
  }
2165
2219
  cancelMouseDrag() {
2166
- this.grabbedNode !== null && this.graph.getNode(this.grabbedNode.nodeId) !== null && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, U(this.element, null), this.removeMouseDragListeners();
2220
+ this.grabbedNode !== null && this.graph.getNode(this.grabbedNode.nodeId) !== null && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, I(this.element, null), this.removeMouseDragListeners();
2167
2221
  }
2168
2222
  removeMouseDragListeners() {
2169
2223
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -2206,15 +2260,15 @@ class Z {
2206
2260
  return e;
2207
2261
  }
2208
2262
  }
2209
- const at = (r, e, t) => ({
2263
+ const ht = (r, e, t) => ({
2210
2264
  scale: r.scale,
2211
2265
  x: r.x + r.scale * e,
2212
2266
  y: r.y + r.scale * t
2213
- }), ht = (r, e, t, o) => ({
2267
+ }), dt = (r, e, t, o) => ({
2214
2268
  scale: r.scale * e,
2215
2269
  x: r.scale * (1 - e) * t + r.x,
2216
2270
  y: r.scale * (1 - e) * o + r.y
2217
- }), I = (r) => {
2271
+ }), U = (r) => {
2218
2272
  const e = [], t = r.touches.length;
2219
2273
  for (let h = 0; h < t; h++)
2220
2274
  e.push([r.touches[h].clientX, r.touches[h].clientY]);
@@ -2243,7 +2297,7 @@ class z {
2243
2297
  this.removeMouseDragListeners(), this.removeTouchDragListeners();
2244
2298
  });
2245
2299
  s(this, "onMouseDown", (e) => {
2246
- this.element === null || !this.params.mouseDownEventVerifier(e) || (U(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2300
+ this.element === null || !this.params.mouseDownEventVerifier(e) || (I(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2247
2301
  passive: !0
2248
2302
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2249
2303
  passive: !0
@@ -2276,10 +2330,10 @@ class z {
2276
2330
  });
2277
2331
  s(this, "onTouchStart", (e) => {
2278
2332
  if (this.prevTouches !== null) {
2279
- this.prevTouches = I(e);
2333
+ this.prevTouches = U(e);
2280
2334
  return;
2281
2335
  }
2282
- this.prevTouches = I(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2336
+ this.prevTouches = U(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2283
2337
  passive: !0
2284
2338
  }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
2285
2339
  passive: !0
@@ -2288,7 +2342,7 @@ class z {
2288
2342
  }), this.startRegisteredTransform();
2289
2343
  });
2290
2344
  s(this, "onWindowTouchMove", (e) => {
2291
- const t = I(e);
2345
+ const t = U(e);
2292
2346
  if (!t.touches.every(
2293
2347
  (i) => C(this.window, this.element, i[0], i[1])
2294
2348
  )) {
@@ -2305,7 +2359,7 @@ class z {
2305
2359
  this.prevTouches = t;
2306
2360
  });
2307
2361
  s(this, "onWindowTouchFinish", (e) => {
2308
- e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
2362
+ e.touches.length > 0 ? this.prevTouches = U(e) : this.stopTouchDrag();
2309
2363
  });
2310
2364
  s(this, "observer", new ResizeObserver(() => {
2311
2365
  const e = this.viewport.getViewportMatrix(), { width: t, height: o } = this.element.getBoundingClientRect(), i = this.params.transformPreprocessor({
@@ -2333,7 +2387,7 @@ class z {
2333
2387
  new z(e, t, o, i);
2334
2388
  }
2335
2389
  moveViewport(e, t) {
2336
- const o = this.viewport.getViewportMatrix(), i = at(o, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2390
+ const o = this.viewport.getViewportMatrix(), i = ht(o, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2337
2391
  prevTransform: o,
2338
2392
  nextTransform: i,
2339
2393
  canvasWidth: n,
@@ -2342,7 +2396,7 @@ class z {
2342
2396
  this.performTransform(h);
2343
2397
  }
2344
2398
  scaleViewport(e, t, o) {
2345
- const i = this.canvas.viewport.getViewportMatrix(), n = ht(i, e, t, o), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2399
+ const i = this.canvas.viewport.getViewportMatrix(), n = dt(i, e, t, o), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2346
2400
  prevTransform: i,
2347
2401
  nextTransform: n,
2348
2402
  canvasWidth: a,
@@ -2351,7 +2405,7 @@ class z {
2351
2405
  this.performTransform(d);
2352
2406
  }
2353
2407
  stopMouseDrag() {
2354
- U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2408
+ I(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2355
2409
  }
2356
2410
  removeMouseDragListeners() {
2357
2411
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -2454,13 +2508,13 @@ class J {
2454
2508
  this.trigger.emit({ x: o, y: i, width: n, height: a });
2455
2509
  }
2456
2510
  }
2457
- const dt = () => {
2511
+ const ct = () => {
2458
2512
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2459
2513
  return r.style.position = "absolute", r.style.inset = "0", r;
2460
- }, ct = () => {
2514
+ }, gt = () => {
2461
2515
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2462
2516
  return r.setAttribute("fill", "url(#pattern)"), r;
2463
- }, gt = () => {
2517
+ }, lt = () => {
2464
2518
  const r = document.createElementNS(
2465
2519
  "http://www.w3.org/2000/svg",
2466
2520
  "pattern"
@@ -2469,9 +2523,9 @@ const dt = () => {
2469
2523
  };
2470
2524
  class Q {
2471
2525
  constructor(e, t, o) {
2472
- s(this, "svg", dt());
2473
- s(this, "patternRenderingRectangle", ct());
2474
- s(this, "pattern", gt());
2526
+ s(this, "svg", ct());
2527
+ s(this, "patternRenderingRectangle", gt());
2528
+ s(this, "pattern", lt());
2475
2529
  s(this, "patternContent");
2476
2530
  s(this, "tileWidth");
2477
2531
  s(this, "tileHeight");
@@ -2511,7 +2565,7 @@ class _ {
2511
2565
  s(this, "onEdgeCreated", (e) => {
2512
2566
  this.params.onAfterEdgeCreated(e);
2513
2567
  });
2514
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Te(
2568
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Ne(
2515
2569
  this.overlayLayer,
2516
2570
  this.viewportStore
2517
2571
  ), k.configure(
@@ -2607,7 +2661,7 @@ class q {
2607
2661
  s(this, "onEdgeReattached", (e) => {
2608
2662
  this.params.onAfterEdgeReattached(e);
2609
2663
  });
2610
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Te(
2664
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Ne(
2611
2665
  this.overlayLayer,
2612
2666
  this.viewportStore
2613
2667
  ), k.configure(
@@ -2669,11 +2723,11 @@ class q {
2669
2723
  overlayId: P.Static,
2670
2724
  portCoords: y,
2671
2725
  portDirection: c.direction
2672
- }, E = {
2726
+ }, A = {
2673
2727
  overlayId: P.Dragging,
2674
2728
  portCoords: v,
2675
2729
  portDirection: d.direction
2676
- }, [R, b] = this.isTargetDragging ? [x, E] : [E, x];
2730
+ }, [R, b] = this.isTargetDragging ? [x, A] : [A, x];
2677
2731
  this.overlayCanvas.addNode(B(R)), this.overlayCanvas.addNode(B(b));
2678
2732
  const D = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(P.Edge) : i.shape;
2679
2733
  return this.overlayCanvas.addEdge({
@@ -2730,7 +2784,7 @@ class q {
2730
2784
  }
2731
2785
  }
2732
2786
  }
2733
- const lt = () => {
2787
+ const ut = () => {
2734
2788
  const r = document.createElement("div");
2735
2789
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
2736
2790
  }, Y = () => {
@@ -2740,25 +2794,25 @@ const lt = () => {
2740
2794
  const r = Y();
2741
2795
  return r.style.pointerEvents = "none", r;
2742
2796
  };
2743
- class ut {
2797
+ class pt {
2744
2798
  constructor(e) {
2745
2799
  s(this, "background", Y());
2746
2800
  s(this, "main", Y());
2747
2801
  s(this, "overlayConnectablePorts", de());
2748
2802
  s(this, "overlayDraggableEdges", de());
2749
- s(this, "host", lt());
2803
+ s(this, "host", ut());
2750
2804
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.host.appendChild(this.overlayConnectablePorts), this.host.appendChild(this.overlayDraggableEdges);
2751
2805
  }
2752
2806
  destroy() {
2753
2807
  this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlayConnectablePorts), this.host.removeChild(this.overlayDraggableEdges), this.element.removeChild(this.host);
2754
2808
  }
2755
2809
  }
2756
- const H = (r) => () => r, ce = H(0), pt = () => {
2810
+ const H = (r) => () => r, ce = H(0), wt = () => {
2757
2811
  let r = 0;
2758
2812
  return () => r++;
2759
- }, wt = (r, e) => {
2813
+ }, ft = (r, e) => {
2760
2814
  let t = ce, o = ce;
2761
- const i = pt();
2815
+ const i = wt();
2762
2816
  return r === "incremental" && (t = i), e === "incremental" && (o = i), typeof r == "number" && (t = H(r)), typeof e == "number" && (o = H(e)), typeof r == "function" && (t = r), typeof e == "function" && (o = e), {
2763
2817
  nodesPriorityFn: t,
2764
2818
  edgesPriorityFn: o
@@ -2768,7 +2822,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2768
2822
  return r;
2769
2823
  switch (r.type) {
2770
2824
  case "straight":
2771
- return () => new rt({
2825
+ return () => new ot({
2772
2826
  color: r.color,
2773
2827
  width: r.width,
2774
2828
  arrowLength: r.arrowLength,
@@ -2782,7 +2836,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2782
2836
  detourDirection: r.detourDirection
2783
2837
  });
2784
2838
  case "horizontal":
2785
- return () => new tt({
2839
+ return () => new rt({
2786
2840
  color: r.color,
2787
2841
  width: r.width,
2788
2842
  arrowLength: r.arrowLength,
@@ -2795,7 +2849,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2795
2849
  detourDistance: r.detourDistance
2796
2850
  });
2797
2851
  case "vertical":
2798
- return () => new ot({
2852
+ return () => new st({
2799
2853
  color: r.color,
2800
2854
  width: r.width,
2801
2855
  arrowLength: r.arrowLength,
@@ -2819,7 +2873,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2819
2873
  targetOffset: r.targetOffset
2820
2874
  });
2821
2875
  default:
2822
- return () => new et({
2876
+ return () => new tt({
2823
2877
  color: r.color,
2824
2878
  width: r.width,
2825
2879
  arrowLength: r.arrowLength,
@@ -2833,9 +2887,9 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2833
2887
  detourDirection: r.detourDirection
2834
2888
  });
2835
2889
  }
2836
- }, ft = (r) => {
2890
+ }, yt = (r) => {
2837
2891
  var t, o, i, n, a;
2838
- const e = wt(
2892
+ const e = ft(
2839
2893
  (t = r.nodes) == null ? void 0 : t.priority,
2840
2894
  (o = r.edges) == null ? void 0 : o.priority
2841
2895
  );
@@ -2852,11 +2906,11 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2852
2906
  priorityFn: e.edgesPriorityFn
2853
2907
  }
2854
2908
  };
2855
- }, yt = (r) => {
2909
+ }, mt = (r) => {
2856
2910
  var p, f, y, v, x;
2857
2911
  const e = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
2858
2912
  }), t = r.nodeDragVerifier ?? (() => !0), o = ((f = r.events) == null ? void 0 : f.onNodeDragFinished) ?? (() => {
2859
- }), i = r.moveOnTop !== !1, n = r.moveEdgesOnTop !== !1 && i, a = (y = r.mouse) == null ? void 0 : y.dragCursor, h = a !== void 0 ? a : "grab", d = (v = r.mouse) == null ? void 0 : v.mouseDownEventVerifier, c = d !== void 0 ? d : (E) => E.button === 0, l = (x = r.mouse) == null ? void 0 : x.mouseUpEventVerifier, g = l !== void 0 ? l : (E) => E.button === 0;
2913
+ }), i = r.moveOnTop !== !1, n = r.moveEdgesOnTop !== !1 && i, a = (y = r.mouse) == null ? void 0 : y.dragCursor, h = a !== void 0 ? a : "grab", d = (v = r.mouse) == null ? void 0 : v.mouseDownEventVerifier, c = d !== void 0 ? d : (A) => A.button === 0, l = (x = r.mouse) == null ? void 0 : x.mouseUpEventVerifier, g = l !== void 0 ? l : (A) => A.button === 0;
2860
2914
  return {
2861
2915
  moveOnTop: i,
2862
2916
  moveEdgesOnTop: n,
@@ -2868,7 +2922,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2868
2922
  nodeDragVerifier: t,
2869
2923
  onNodeDragFinished: o
2870
2924
  };
2871
- }, mt = (r) => {
2925
+ }, vt = (r) => {
2872
2926
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, o = r.minY !== null ? r.minY : -1 / 0, i = r.maxY !== null ? r.maxY : 1 / 0;
2873
2927
  return (n) => {
2874
2928
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -2878,7 +2932,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2878
2932
  const l = n.canvasHeight * n.prevTransform.scale, g = i - l;
2879
2933
  return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
2880
2934
  };
2881
- }, vt = (r) => {
2935
+ }, Et = (r) => {
2882
2936
  const e = r.maxContentScale, t = r.minContentScale, o = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
2883
2937
  return (n) => {
2884
2938
  const a = n.prevTransform, h = n.nextTransform;
@@ -2912,12 +2966,12 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2912
2966
  return r;
2913
2967
  switch (r.type) {
2914
2968
  case "scale-limit":
2915
- return vt({
2969
+ return Et({
2916
2970
  minContentScale: r.minContentScale ?? 0,
2917
2971
  maxContentScale: r.maxContentScale ?? 1 / 0
2918
2972
  });
2919
2973
  case "shift-limit":
2920
- return mt({
2974
+ return vt({
2921
2975
  minX: r.minX ?? -1 / 0,
2922
2976
  maxX: r.maxX ?? 1 / 0,
2923
2977
  minY: r.minY ?? -1 / 0,
@@ -2925,7 +2979,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2925
2979
  });
2926
2980
  }
2927
2981
  }, le = (r) => {
2928
- var y, v, x, E, R, b, D, V, te, re, oe, se;
2982
+ var y, v, x, A, R, b, D, V, te, re, oe, se;
2929
2983
  const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, o = r == null ? void 0 : r.transformPreprocessor;
2930
2984
  let i;
2931
2985
  o !== void 0 ? Array.isArray(o) ? i = At(
@@ -2934,7 +2988,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2934
2988
  )
2935
2989
  ) : i = ge(o) : i = (N) => N.nextTransform;
2936
2990
  const n = ((v = r == null ? void 0 : r.shift) == null ? void 0 : v.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
2937
- }), h = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onTransformChange) ?? (() => {
2991
+ }), h = ((A = r == null ? void 0 : r.events) == null ? void 0 : A.onTransformChange) ?? (() => {
2938
2992
  }), d = (R = r == null ? void 0 : r.shift) == null ? void 0 : R.mouseDownEventVerifier, c = d !== void 0 ? d : (N) => N.button === 0, l = (b = r == null ? void 0 : r.shift) == null ? void 0 : b.mouseUpEventVerifier, g = l !== void 0 ? l : (N) => N.button === 0, p = (D = r == null ? void 0 : r.scale) == null ? void 0 : D.mouseWheelEventVerifier, f = p !== void 0 ? p : () => !0;
2939
2993
  return {
2940
2994
  wheelSensitivity: t,
@@ -2955,24 +3009,24 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2955
3009
  onResizeTransformFinished: ((se = r == null ? void 0 : r.events) == null ? void 0 : se.onResizeTransformFinished) ?? (() => {
2956
3010
  })
2957
3011
  };
2958
- }, Et = (r, e) => {
3012
+ }, xt = (r, e) => {
2959
3013
  const t = document.createElementNS(
2960
3014
  "http://www.w3.org/2000/svg",
2961
3015
  "circle"
2962
3016
  );
2963
3017
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
2964
- }, xt = (r) => r instanceof SVGElement ? r : Et(
3018
+ }, St = (r) => r instanceof SVGElement ? r : xt(
2965
3019
  (r == null ? void 0 : r.radius) ?? 1.5,
2966
3020
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
2967
- ), St = (r) => {
2968
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, i = xt(r.renderer ?? {});
3021
+ ), Pt = (r) => {
3022
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, i = St(r.renderer ?? {});
2969
3023
  return {
2970
3024
  tileWidth: t,
2971
3025
  tileHeight: o,
2972
3026
  renderer: i,
2973
3027
  maxViewportScale: r.maxViewportScale ?? 10
2974
3028
  };
2975
- }, Pt = (r, e, t) => {
3029
+ }, bt = (r, e, t) => {
2976
3030
  var c, l, g;
2977
3031
  const o = () => "direct", i = (p) => p, n = (p) => p.button === 0, a = () => {
2978
3032
  }, h = () => {
@@ -2989,7 +3043,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2989
3043
  dragPortDirection: r.dragPortDirection ?? t,
2990
3044
  edgeShapeFactory: r.edgeShape !== void 0 ? ee(r.edgeShape) : e
2991
3045
  };
2992
- }, bt = (r, e) => {
3046
+ }, Tt = (r, e) => {
2993
3047
  var c, l, g;
2994
3048
  const t = (p) => p, o = (p) => p.button === 0 && p.ctrlKey, i = (p) => p.button === 0, n = (p) => {
2995
3049
  const f = e.getPortAdjacentEdgeIds(p);
@@ -3008,10 +3062,10 @@ const H = (r) => () => r, ce = H(0), pt = () => {
3008
3062
  onEdgeReattachInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeReattachInterrupted) ?? d,
3009
3063
  onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
3010
3064
  };
3011
- }, Tt = (r) => ({
3065
+ }, Dt = (r) => ({
3012
3066
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3013
3067
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3014
- }), Dt = (r) => {
3068
+ }), Nt = (r) => {
3015
3069
  var e, t;
3016
3070
  return {
3017
3071
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3020,13 +3074,13 @@ const H = (r) => () => r, ce = H(0), pt = () => {
3020
3074
  })
3021
3075
  };
3022
3076
  };
3023
- class Nt extends Error {
3077
+ class Mt extends Error {
3024
3078
  constructor() {
3025
3079
  super(...arguments);
3026
3080
  s(this, "name", "CanvasBuilderError");
3027
3081
  }
3028
3082
  }
3029
- class Lt {
3083
+ class Ct {
3030
3084
  constructor(e) {
3031
3085
  s(this, "used", !1);
3032
3086
  s(this, "canvasDefaults", {});
@@ -3044,7 +3098,9 @@ class Lt {
3044
3098
  s(this, "hasUserDraggableEdges", !1);
3045
3099
  s(this, "boxRenderingTrigger", new pe());
3046
3100
  s(this, "graphStore", new fe());
3047
- s(this, "viewportStore", new Be());
3101
+ s(this, "viewportStore", new Fe());
3102
+ s(this, "graph", new Te(this.graphStore));
3103
+ s(this, "viewport", new De(this.viewportStore));
3048
3104
  s(this, "window", window);
3049
3105
  this.element = e;
3050
3106
  }
@@ -3099,21 +3155,23 @@ class Lt {
3099
3155
  */
3100
3156
  build() {
3101
3157
  if (this.used)
3102
- throw new Nt("CanvasBuilder is a single use object");
3158
+ throw new Mt("CanvasBuilder is a single use object");
3103
3159
  this.used = !0;
3104
- const e = new ut(this.element);
3160
+ const e = new pt(this.element);
3105
3161
  let t = new ue(
3106
3162
  this.graphStore,
3107
3163
  this.viewportStore,
3108
3164
  e.main
3109
3165
  );
3110
- this.virtualScrollConfig !== void 0 && (t = new Ve(
3166
+ this.virtualScrollConfig !== void 0 && (t = new Ue(
3111
3167
  t,
3112
3168
  this.graphStore,
3113
3169
  this.boxRenderingTrigger,
3114
- Dt(this.virtualScrollConfig)
3115
- ));
3116
- const o = ft(this.canvasDefaults), i = new we(
3170
+ Nt(this.virtualScrollConfig)
3171
+ )), t = new Ie(t, this.graphStore);
3172
+ const o = yt(this.canvasDefaults), i = new we(
3173
+ this.graph,
3174
+ this.viewport,
3117
3175
  this.graphStore,
3118
3176
  this.viewportStore,
3119
3177
  t,
@@ -3121,15 +3179,15 @@ class Lt {
3121
3179
  );
3122
3180
  if (this.hasBackground && Q.configure(
3123
3181
  i,
3124
- St(this.backgroundConfig),
3182
+ Pt(this.backgroundConfig),
3125
3183
  e.background
3126
3184
  ), this.hasNodeResizeReactiveEdges && j.configure(i), this.hasDraggableNode && Z.configure(
3127
3185
  i,
3128
3186
  e.main,
3129
3187
  this.window,
3130
- yt(this.dragConfig)
3188
+ mt(this.dragConfig)
3131
3189
  ), this.hasUserConnectablePorts) {
3132
- const a = Pt(
3190
+ const a = bt(
3133
3191
  this.connectablePortsConfig,
3134
3192
  o.edges.shapeFactory,
3135
3193
  o.ports.direction
@@ -3143,7 +3201,7 @@ class Lt {
3143
3201
  );
3144
3202
  }
3145
3203
  if (this.hasUserDraggableEdges) {
3146
- const a = bt(
3204
+ const a = Tt(
3147
3205
  this.draggableEdgesConfig,
3148
3206
  i.graph
3149
3207
  );
@@ -3161,7 +3219,7 @@ class Lt {
3161
3219
  this.window,
3162
3220
  le(this.transformConfig),
3163
3221
  this.boxRenderingTrigger,
3164
- Tt(this.virtualScrollConfig)
3222
+ Dt(this.virtualScrollConfig)
3165
3223
  ) : this.hasTransformableViewport && z.configure(
3166
3224
  i,
3167
3225
  e.main,
@@ -3175,15 +3233,15 @@ class Lt {
3175
3233
  }
3176
3234
  }
3177
3235
  export {
3178
- et as BezierEdgeShape,
3179
- Lt as CanvasBuilder,
3180
- Nt as CanvasBuilderError,
3236
+ tt as BezierEdgeShape,
3237
+ Ct as CanvasBuilder,
3238
+ Mt as CanvasBuilderError,
3181
3239
  S as CanvasError,
3182
3240
  Pe as DirectEdgeShape,
3183
- tt as HorizontalEdgeShape,
3184
- nt as InteractiveEdgeError,
3241
+ rt as HorizontalEdgeShape,
3242
+ at as InteractiveEdgeError,
3185
3243
  be as InteractiveEdgeShape,
3186
- Rt as MidpointEdgeShape,
3187
- rt as StraightEdgeShape,
3188
- ot as VerticalEdgeShape
3244
+ Lt as MidpointEdgeShape,
3245
+ ot as StraightEdgeShape,
3246
+ st as VerticalEdgeShape
3189
3247
  };