@html-graph/html-graph 5.0.0 → 5.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,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, a = t.payload.centerFn(o, i), { payload: h } = t, d = h.x - n * a.x, c = h.y - n * a.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,68 @@ 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() };
227
- }
228
- getContentMatrix() {
229
- return { ...this.viewportStore.getContentMatrix() };
230
- }
231
- }
232
201
  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;
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;
248
206
  }
249
- getNode(e) {
207
+ attachNode(e) {
250
208
  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
- };
261
- }
262
- getElementNodeId(e) {
263
- return this.graphStore.getElementNodeId(e) ?? null;
264
- }
265
- getAllNodeIds() {
266
- return this.graphStore.getAllNodeIds();
209
+ t.payload.x !== null && t.payload.y !== null ? this.htmlView.attachNode(e) : this.deferredNodes.add(e);
267
210
  }
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
- };
211
+ detachNode(e) {
212
+ this.deferredNodes.has(e) ? this.deferredNodes.delete(e) : this.htmlView.detachNode(e);
275
213
  }
276
- getAllPortIds() {
277
- return this.graphStore.getAllPortIds();
214
+ attachEdge(e) {
215
+ const t = this.graphStore.getEdge(e), o = this.graphStore.getPort(t.from), i = this.graphStore.getPort(t.to);
216
+ this.deferredNodes.has(o.nodeId) || this.deferredNodes.has(i.nodeId) ? this.deferredEdges.add(e) : this.htmlView.attachEdge(e);
278
217
  }
279
- getNodePortIds(e) {
280
- return this.graphStore.getNodePortIds(e) ?? null;
218
+ detachEdge(e) {
219
+ this.deferredEdges.has(e) ? this.deferredEdges.delete(e) : this.htmlView.detachEdge(e);
281
220
  }
282
- getElementPortIds(e) {
283
- return [...this.graphStore.getElementPortIds(e)];
221
+ updateNodePosition(e) {
222
+ this.deferredNodes.has(e) || this.htmlView.updateNodePosition(e);
284
223
  }
285
- getAllEdgeIds() {
286
- return this.graphStore.getAllEdgeIds();
224
+ updateNodePriority(e) {
225
+ this.deferredNodes.has(e) || this.htmlView.updateNodePriority(e);
287
226
  }
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
- };
227
+ updateEdgeShape(e) {
228
+ this.deferredEdges.has(e) || this.htmlView.updateEdgeShape(e);
299
229
  }
300
- getPortIncomingEdgeIds(e) {
301
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
230
+ renderEdge(e) {
231
+ this.deferredEdges.has(e) || this.htmlView.renderEdge(e);
302
232
  }
303
- getPortOutgoingEdgeIds(e) {
304
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutgoingEdgeIds(e);
233
+ updateEdgePriority(e) {
234
+ this.deferredEdges.has(e) || this.htmlView.updateEdgePriority(e);
305
235
  }
306
- getPortCycleEdgeIds(e) {
307
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
236
+ clear() {
237
+ this.deferredNodes.clear(), this.deferredEdges.clear(), this.htmlView.clear();
308
238
  }
309
- getPortAdjacentEdgeIds(e) {
310
- return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
239
+ destroy() {
240
+ this.htmlView.destroy();
311
241
  }
312
- getNodeIncomingEdgeIds(e) {
313
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
242
+ }
243
+ class pe {
244
+ constructor() {
245
+ s(this, "callbacks", /* @__PURE__ */ new Set());
314
246
  }
315
- getNodeOutgoingEdgeIds(e) {
316
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutgoingEdgeIds(e);
247
+ subscribe(e) {
248
+ this.callbacks.add(e);
317
249
  }
318
- getNodeCycleEdgeIds(e) {
319
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
250
+ unsubscribe(e) {
251
+ this.callbacks.delete(e);
320
252
  }
321
- getNodeAdjacentEdgeIds(e) {
322
- return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
253
+ emit(e) {
254
+ this.callbacks.forEach((t) => {
255
+ t(e);
256
+ });
323
257
  }
324
258
  }
259
+ const E = () => {
260
+ const r = new pe();
261
+ return [r, r];
262
+ };
325
263
  class X {
326
264
  constructor(e) {
327
265
  s(this, "counter", 0);
@@ -345,15 +283,7 @@ class S extends Error {
345
283
  }
346
284
  }
347
285
  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");
286
+ constructor(e, t, o, i, n, a) {
357
287
  s(this, "nodeIdGenerator", new X(
358
288
  (e) => this.graph.getNode(e) !== null
359
289
  ));
@@ -413,13 +343,13 @@ class we {
413
343
  * emits event just before destruction of canvas
414
344
  */
415
345
  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(
346
+ 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
347
  this.onAfterNodePriorityUpdated
418
348
  ), 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
349
  this.onAfterEdgeShapeUpdated
420
350
  ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
421
351
  this.onAfterEdgePriorityUpdated
422
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
352
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
423
353
  }
424
354
  /**
425
355
  * adds new node
@@ -454,7 +384,7 @@ class we {
454
384
  */
455
385
  updateNode(e, t) {
456
386
  if (this.graphStore.getNode(e) === void 0)
457
- throw new S("failed to update non existing node");
387
+ throw new S("failed to update nonexistent node");
458
388
  return this.graphStore.updateNode(e, t ?? {}), this;
459
389
  }
460
390
  /**
@@ -464,7 +394,7 @@ class we {
464
394
  */
465
395
  removeNode(e) {
466
396
  if (this.graphStore.getNode(e) === void 0)
467
- throw new S("failed to remove non existing node");
397
+ throw new S("failed to remove nonexistent node");
468
398
  return this.graphStore.removeNode(e), this;
469
399
  }
470
400
  /**
@@ -497,7 +427,7 @@ class we {
497
427
  */
498
428
  unmarkPort(e) {
499
429
  if (this.graphStore.getPort(e) === void 0)
500
- throw new S("failed to unmark non existing port");
430
+ throw new S("failed to unmark nonexistent port");
501
431
  return this.graphStore.removePort(e), this;
502
432
  }
503
433
  /**
@@ -535,6 +465,13 @@ class we {
535
465
  throw new S("failed to remove nonexistent edge");
536
466
  return this.graphStore.removeEdge(e), this;
537
467
  }
468
+ /**
469
+ * clears canvas from nodes and edges
470
+ * canvas gets rolled back to initial state and can be reused
471
+ */
472
+ clear() {
473
+ return this.graphStore.clear(), this;
474
+ }
538
475
  /**
539
476
  * applies transformation for viewport matrix
540
477
  */
@@ -547,13 +484,6 @@ class we {
547
484
  patchContentMatrix(e) {
548
485
  return this.viewportStore.patchContentMatrix(e), this;
549
486
  }
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
487
  /**
558
488
  * destroys canvas
559
489
  * canvas element gets rolled back to initial state, and can not be reused
@@ -568,7 +498,7 @@ class we {
568
498
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.destroyed = !0);
569
499
  }
570
500
  }
571
- class Ue {
501
+ class Be {
572
502
  constructor() {
573
503
  s(this, "singleToMultiMap", /* @__PURE__ */ new Map());
574
504
  s(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -617,7 +547,7 @@ class fe {
617
547
  s(this, "incomingEdges", /* @__PURE__ */ new Map());
618
548
  s(this, "outcomingEdges", /* @__PURE__ */ new Map());
619
549
  s(this, "cycleEdges", /* @__PURE__ */ new Map());
620
- s(this, "elementPorts", new Ue());
550
+ s(this, "elementPorts", new Be());
621
551
  s(this, "afterNodeAddedEmitter");
622
552
  s(this, "onAfterNodeAdded");
623
553
  s(this, "afterNodeUpdatedEmitter");
@@ -644,7 +574,7 @@ class fe {
644
574
  s(this, "onBeforeEdgeRemoved");
645
575
  s(this, "beforeClearEmitter");
646
576
  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();
577
+ [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
578
  }
649
579
  addNode(e) {
650
580
  const t = /* @__PURE__ */ new Map(), o = {
@@ -805,13 +735,13 @@ const ie = (r) => ({
805
735
  x: 0,
806
736
  y: 0
807
737
  };
808
- class Be {
738
+ class Fe {
809
739
  constructor() {
810
740
  s(this, "viewportMatrix", ne);
811
741
  s(this, "contentMatrix", ne);
812
742
  s(this, "afterUpdateEmitter");
813
743
  s(this, "onAfterUpdated");
814
- [this.afterUpdateEmitter, this.onAfterUpdated] = A();
744
+ [this.afterUpdateEmitter, this.onAfterUpdated] = E();
815
745
  }
816
746
  getViewportMatrix() {
817
747
  return this.viewportMatrix;
@@ -864,10 +794,10 @@ class j {
864
794
  this.canvas.updateNode(t);
865
795
  }
866
796
  }
867
- const Fe = (r, e, t) => {
797
+ const Oe = (r, e, t) => {
868
798
  const { x: o, y: i, width: n, height: a } = r.getBoundingClientRect();
869
799
  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) => {
800
+ }, 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
801
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
872
802
  }, B = (r) => {
873
803
  const e = document.createElement("div");
@@ -884,7 +814,7 @@ const Fe = (r, e, t) => {
884
814
  }
885
815
  ]
886
816
  };
887
- }, We = (r, e) => {
817
+ }, ke = (r, e) => {
888
818
  let t = e, o = null;
889
819
  for (; t !== null && (o = r.getElementPortIds(t)[0] ?? null, o === null); )
890
820
  t = t.parentElement;
@@ -892,7 +822,7 @@ const Fe = (r, e, t) => {
892
822
  }, ye = (r, e) => {
893
823
  const t = document.elementsFromPoint(e.x, e.y);
894
824
  for (const o of t) {
895
- const i = We(r, o);
825
+ const i = ke(r, o);
896
826
  if (i !== null)
897
827
  return i;
898
828
  }
@@ -928,7 +858,7 @@ const me = (r, e) => ({
928
858
  x: e * r.x + (1 - e) / 2 * o.x,
929
859
  y: t * r.y + (1 - t) / 2 * o.y
930
860
  });
931
- class ke {
861
+ class ze {
932
862
  constructor(e) {
933
863
  s(this, "path");
934
864
  s(this, "midpoint");
@@ -953,7 +883,7 @@ class ke {
953
883
  this.path = `${d}${h}${c}`;
954
884
  }
955
885
  }
956
- class ze {
886
+ class Xe {
957
887
  constructor(e) {
958
888
  s(this, "path");
959
889
  s(this, "midpoint");
@@ -995,7 +925,7 @@ class ze {
995
925
  }, x = {
996
926
  x: c.x + h,
997
927
  y: c.y + d
998
- }, E = {
928
+ }, A = {
999
929
  x: g.x + h,
1000
930
  y: g.y + d
1001
931
  };
@@ -1003,17 +933,17 @@ class ze {
1003
933
  `M ${t.x} ${t.y}`,
1004
934
  `L ${c.x} ${c.y}`,
1005
935
  `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}`,
936
+ `C ${A.x} ${A.y} ${v.x} ${v.y} ${g.x} ${g.y}`,
1007
937
  `L ${o.x} ${o.y}`
1008
938
  ].join(" "), this.midpoint = O(f, e.flipX, e.flipY, e.to);
1009
939
  }
1010
940
  }
1011
941
  const G = Object.freeze({
1012
942
  edgeColor: "--edge-color"
1013
- }), Ae = (r) => {
943
+ }), Ee = (r) => {
1014
944
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1015
945
  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) => {
946
+ }, Ae = (r) => {
1017
947
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1018
948
  return e.setAttribute("stroke", `var(${G.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
1019
949
  }, F = () => {
@@ -1036,15 +966,15 @@ const G = Object.freeze({
1036
966
  const V = r[d + 1];
1037
967
  i = V.x - h.x, n = V.y - h.y, a = Math.sqrt(i * i + n * n);
1038
968
  }
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;
969
+ 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
970
  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}`
971
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${A.x} ${A.y}`
1042
972
  );
1043
973
  });
1044
974
  }
1045
975
  return t.join(" ");
1046
976
  };
1047
- class Xe {
977
+ class Ye {
1048
978
  constructor(e) {
1049
979
  s(this, "path");
1050
980
  s(this, "midpoint");
@@ -1083,7 +1013,7 @@ class Xe {
1083
1013
  );
1084
1014
  }
1085
1015
  }
1086
- class Ye {
1016
+ class He {
1087
1017
  constructor(e) {
1088
1018
  s(this, "path");
1089
1019
  s(this, "midpoint");
@@ -1114,7 +1044,7 @@ class Ye {
1114
1044
  );
1115
1045
  }
1116
1046
  }
1117
- class He {
1047
+ class je {
1118
1048
  constructor(e) {
1119
1049
  s(this, "path");
1120
1050
  s(this, "midpoint");
@@ -1144,7 +1074,7 @@ class He {
1144
1074
  this.path = M([o, a, h, i], this.params.roundness);
1145
1075
  }
1146
1076
  }
1147
- class je {
1077
+ class Ge {
1148
1078
  constructor(e) {
1149
1079
  s(this, "path");
1150
1080
  s(this, "midpoint");
@@ -1203,7 +1133,7 @@ class K {
1203
1133
  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
1134
  }
1205
1135
  }
1206
- class Ge {
1136
+ class Ke {
1207
1137
  constructor(e) {
1208
1138
  s(this, "path");
1209
1139
  s(this, "midpoint");
@@ -1224,7 +1154,7 @@ class Ge {
1224
1154
  this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : f}${p}`, this.midpoint = g[3];
1225
1155
  }
1226
1156
  }
1227
- class Ke {
1157
+ class Ze {
1228
1158
  constructor(e) {
1229
1159
  s(this, "path");
1230
1160
  s(this, "midpoint");
@@ -1260,7 +1190,7 @@ class Ke {
1260
1190
  };
1261
1191
  }
1262
1192
  }
1263
- class Ze {
1193
+ class Je {
1264
1194
  constructor(e) {
1265
1195
  s(this, "path");
1266
1196
  s(this, "midpoint");
@@ -1301,7 +1231,7 @@ class Ze {
1301
1231
  );
1302
1232
  }
1303
1233
  }
1304
- class Je {
1234
+ class Qe {
1305
1235
  constructor(e) {
1306
1236
  s(this, "path");
1307
1237
  s(this, "midpoint");
@@ -1375,7 +1305,7 @@ class W {
1375
1305
  s(this, "onAfterRender");
1376
1306
  s(this, "afterRenderEmitter");
1377
1307
  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));
1308
+ 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
1309
  }
1380
1310
  render(e) {
1381
1311
  const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = ve(
@@ -1423,7 +1353,7 @@ class W {
1423
1353
  });
1424
1354
  }
1425
1355
  }
1426
- const Qe = (r) => (e) => {
1356
+ const _e = (r) => (e) => {
1427
1357
  const o = [
1428
1358
  u,
1429
1359
  { x: e.arrowLength, y: r.radius },
@@ -1435,7 +1365,7 @@ const Qe = (r) => (e) => {
1435
1365
  y: h.y + e.shift.y
1436
1366
  })), 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
1367
  return `${i} ${n} ${a} Z`;
1438
- }, _e = (r) => (e) => {
1368
+ }, qe = (r) => (e) => {
1439
1369
  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
1370
  (y) => m(y, e.direction, u)
1441
1371
  ).map((y) => ({
@@ -1443,7 +1373,7 @@ const Qe = (r) => (e) => {
1443
1373
  y: y.y + e.shift.y
1444
1374
  })), 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
1375
  return `${l} ${g} ${p} ${f}`;
1446
- }, qe = (r) => (e) => {
1376
+ }, et = (r) => (e) => {
1447
1377
  const t = r.smallRadius, o = r.radius, i = m(
1448
1378
  {
1449
1379
  x: e.arrowLength,
@@ -1469,22 +1399,22 @@ const Qe = (r) => (e) => {
1469
1399
  return r;
1470
1400
  switch (r.type) {
1471
1401
  case "triangle":
1472
- return Qe({
1402
+ return _e({
1473
1403
  radius: r.radius ?? w.polygonArrowRadius
1474
1404
  });
1475
1405
  case "arc":
1476
- return _e({
1406
+ return qe({
1477
1407
  radius: r.radius ?? w.circleArrowRadius
1478
1408
  });
1479
1409
  default:
1480
- return qe({
1410
+ return et({
1481
1411
  smallRadius: r.smallRadius ?? w.wedgeArrowSmallRadius,
1482
1412
  angle: r.angle ?? w.wedgeArrowAngle,
1483
1413
  radius: r.radius ?? w.wedgeArrowRadius
1484
1414
  });
1485
1415
  }
1486
1416
  };
1487
- class et {
1417
+ class tt {
1488
1418
  constructor(e) {
1489
1419
  s(this, "svg");
1490
1420
  s(this, "group");
@@ -1501,7 +1431,7 @@ class et {
1501
1431
  s(this, "hasSourceArrow");
1502
1432
  s(this, "hasTargetArrow");
1503
1433
  s(this, "pathShape");
1504
- s(this, "createCyclePath", (e) => new Ge({
1434
+ s(this, "createCyclePath", (e) => new Ke({
1505
1435
  sourceDirection: e,
1506
1436
  radius: this.portCycleRadius,
1507
1437
  smallRadius: this.portCycleSmallRadius,
@@ -1509,7 +1439,7 @@ class et {
1509
1439
  hasSourceArrow: this.hasSourceArrow,
1510
1440
  hasTargetArrow: this.hasTargetArrow
1511
1441
  }));
1512
- s(this, "createDetourPath", (e, t, o, i, n) => new ze({
1442
+ s(this, "createDetourPath", (e, t, o, i, n) => new Xe({
1513
1443
  to: o,
1514
1444
  sourceDirection: e,
1515
1445
  targetDirection: t,
@@ -1522,7 +1452,7 @@ class et {
1522
1452
  hasSourceArrow: this.hasSourceArrow,
1523
1453
  hasTargetArrow: this.hasTargetArrow
1524
1454
  }));
1525
- s(this, "createLinePath", (e, t, o) => new ke({
1455
+ s(this, "createLinePath", (e, t, o) => new ze({
1526
1456
  to: o,
1527
1457
  sourceDirection: e,
1528
1458
  targetDirection: t,
@@ -1547,7 +1477,7 @@ class et {
1547
1477
  this.pathShape.render(e);
1548
1478
  }
1549
1479
  }
1550
- class tt {
1480
+ class rt {
1551
1481
  constructor(e) {
1552
1482
  s(this, "svg");
1553
1483
  s(this, "group");
@@ -1572,7 +1502,7 @@ class tt {
1572
1502
  hasSourceArrow: this.hasSourceArrow,
1573
1503
  hasTargetArrow: this.hasTargetArrow
1574
1504
  }));
1575
- s(this, "createDetourPath", (e, t, o, i, n) => new Ze({
1505
+ s(this, "createDetourPath", (e, t, o, i, n) => new Je({
1576
1506
  to: o,
1577
1507
  sourceDirection: e,
1578
1508
  targetDirection: t,
@@ -1585,7 +1515,7 @@ class tt {
1585
1515
  hasSourceArrow: this.hasSourceArrow,
1586
1516
  hasTargetArrow: this.hasTargetArrow
1587
1517
  }));
1588
- s(this, "createLinePath", (e, t, o, i) => new Xe({
1518
+ s(this, "createLinePath", (e, t, o, i) => new Ye({
1589
1519
  to: o,
1590
1520
  sourceDirection: e,
1591
1521
  targetDirection: t,
@@ -1618,7 +1548,7 @@ class tt {
1618
1548
  this.pathShape.render(e);
1619
1549
  }
1620
1550
  }
1621
- class rt {
1551
+ class ot {
1622
1552
  constructor(e) {
1623
1553
  s(this, "svg");
1624
1554
  s(this, "group");
@@ -1644,7 +1574,7 @@ class rt {
1644
1574
  hasSourceArrow: this.hasSourceArrow,
1645
1575
  hasTargetArrow: this.hasTargetArrow
1646
1576
  }));
1647
- s(this, "createDetourPath", (e, t, o, i, n) => new Ye({
1577
+ s(this, "createDetourPath", (e, t, o, i, n) => new He({
1648
1578
  to: o,
1649
1579
  sourceDirection: e,
1650
1580
  targetDirection: t,
@@ -1658,7 +1588,7 @@ class rt {
1658
1588
  hasSourceArrow: this.hasSourceArrow,
1659
1589
  hasTargetArrow: this.hasTargetArrow
1660
1590
  }));
1661
- s(this, "createLinePath", (e, t, o) => new He({
1591
+ s(this, "createLinePath", (e, t, o) => new je({
1662
1592
  to: o,
1663
1593
  sourceDirection: e,
1664
1594
  targetDirection: t,
@@ -1690,7 +1620,7 @@ class rt {
1690
1620
  this.pathShape.render(e);
1691
1621
  }
1692
1622
  }
1693
- class ot {
1623
+ class st {
1694
1624
  constructor(e) {
1695
1625
  s(this, "svg");
1696
1626
  s(this, "group");
@@ -1715,7 +1645,7 @@ class ot {
1715
1645
  hasSourceArrow: this.hasSourceArrow,
1716
1646
  hasTargetArrow: this.hasTargetArrow
1717
1647
  }));
1718
- s(this, "createDetourPath", (e, t, o, i, n) => new Je({
1648
+ s(this, "createDetourPath", (e, t, o, i, n) => new Qe({
1719
1649
  to: o,
1720
1650
  sourceDirection: e,
1721
1651
  targetDirection: t,
@@ -1728,7 +1658,7 @@ class ot {
1728
1658
  hasSourceArrow: this.hasSourceArrow,
1729
1659
  hasTargetArrow: this.hasTargetArrow
1730
1660
  }));
1731
- s(this, "createLinePath", (e, t, o, i, n) => new je({
1661
+ s(this, "createLinePath", (e, t, o, i, n) => new Ge({
1732
1662
  to: o,
1733
1663
  sourceDirection: e,
1734
1664
  targetDirection: t,
@@ -1776,7 +1706,7 @@ class Pe {
1776
1706
  s(this, "onAfterRender");
1777
1707
  s(this, "afterRenderEmitter");
1778
1708
  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));
1709
+ [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
1710
  }
1781
1711
  render(e) {
1782
1712
  const { x: t, y: o, width: i, height: n, flipX: a, flipY: h } = ve(
@@ -1784,7 +1714,7 @@ class Pe {
1784
1714
  e.to
1785
1715
  );
1786
1716
  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({
1717
+ const d = { x: i, y: n }, c = new Ze({
1788
1718
  to: d,
1789
1719
  sourceOffset: this.sourceOffset,
1790
1720
  targetOffset: this.targetOffset,
@@ -1835,17 +1765,17 @@ class Pe {
1835
1765
  });
1836
1766
  }
1837
1767
  }
1838
- const st = () => {
1768
+ const it = () => {
1839
1769
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1840
1770
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1841
- }, it = (r) => {
1771
+ }, nt = (r) => {
1842
1772
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1843
1773
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1844
1774
  }, he = (r) => {
1845
1775
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1846
1776
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1847
1777
  };
1848
- class nt extends Error {
1778
+ class at extends Error {
1849
1779
  constructor(e) {
1850
1780
  super(e), this.name = "InteractiveEdgeError";
1851
1781
  }
@@ -1857,18 +1787,18 @@ class be {
1857
1787
  s(this, "line");
1858
1788
  s(this, "sourceArrow");
1859
1789
  s(this, "targetArrow");
1860
- s(this, "handle", st());
1790
+ s(this, "handle", it());
1861
1791
  s(this, "onAfterRender");
1862
1792
  s(this, "interactiveLine");
1863
1793
  s(this, "interactiveSourceArrow", null);
1864
1794
  s(this, "interactiveTargetArrow", null);
1865
1795
  if (this.baseEdge = e, e instanceof be)
1866
- throw new nt(
1796
+ throw new at(
1867
1797
  "interactive edge can be configured only once"
1868
1798
  );
1869
1799
  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
1800
  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) => {
1801
+ 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
1802
  this.interactiveLine.setAttribute("d", i.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", i.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", i.targetArrowPath);
1873
1803
  });
1874
1804
  }
@@ -1876,7 +1806,7 @@ class be {
1876
1806
  this.baseEdge.render(e);
1877
1807
  }
1878
1808
  }
1879
- class Rt {
1809
+ class Lt {
1880
1810
  constructor(e, t) {
1881
1811
  s(this, "group");
1882
1812
  s(this, "line");
@@ -1893,8 +1823,113 @@ class Rt {
1893
1823
  this.baseShape.render(e);
1894
1824
  }
1895
1825
  }
1896
- const Te = (r, e) => {
1897
- const t = new fe(), o = new ue(t, e, r), i = {
1826
+ class Te {
1827
+ constructor(e) {
1828
+ s(this, "onAfterNodeAdded");
1829
+ s(this, "onAfterNodeUpdated");
1830
+ s(this, "onAfterNodePriorityUpdated");
1831
+ s(this, "onBeforeNodeRemoved");
1832
+ s(this, "onAfterPortMarked");
1833
+ s(this, "onAfterPortUpdated");
1834
+ s(this, "onBeforePortUnmarked");
1835
+ s(this, "onAfterEdgeAdded");
1836
+ s(this, "onAfterEdgeShapeUpdated");
1837
+ s(this, "onAfterEdgeUpdated");
1838
+ s(this, "onAfterEdgePriorityUpdated");
1839
+ s(this, "onBeforeEdgeRemoved");
1840
+ s(this, "onBeforeClear");
1841
+ 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;
1842
+ }
1843
+ getNode(e) {
1844
+ const t = this.graphStore.getNode(e);
1845
+ if (t === void 0)
1846
+ return null;
1847
+ const o = t.payload;
1848
+ return {
1849
+ element: t.element,
1850
+ x: o.x,
1851
+ y: o.y,
1852
+ centerFn: o.centerFn,
1853
+ priority: o.priority
1854
+ };
1855
+ }
1856
+ getElementNodeId(e) {
1857
+ return this.graphStore.getElementNodeId(e) ?? null;
1858
+ }
1859
+ getAllNodeIds() {
1860
+ return this.graphStore.getAllNodeIds();
1861
+ }
1862
+ getPort(e) {
1863
+ const t = this.graphStore.getPort(e);
1864
+ return t === void 0 ? null : {
1865
+ element: t.element,
1866
+ direction: t.payload.direction,
1867
+ nodeId: t.nodeId
1868
+ };
1869
+ }
1870
+ getAllPortIds() {
1871
+ return this.graphStore.getAllPortIds();
1872
+ }
1873
+ getNodePortIds(e) {
1874
+ return this.graphStore.getNodePortIds(e) ?? null;
1875
+ }
1876
+ getElementPortIds(e) {
1877
+ return [...this.graphStore.getElementPortIds(e)];
1878
+ }
1879
+ getAllEdgeIds() {
1880
+ return this.graphStore.getAllEdgeIds();
1881
+ }
1882
+ getEdge(e) {
1883
+ const t = this.graphStore.getEdge(e);
1884
+ if (t === void 0)
1885
+ return null;
1886
+ const o = t.payload;
1887
+ return {
1888
+ from: t.from,
1889
+ to: t.to,
1890
+ priority: o.priority,
1891
+ shape: o.shape
1892
+ };
1893
+ }
1894
+ getPortIncomingEdgeIds(e) {
1895
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortIncomingEdgeIds(e);
1896
+ }
1897
+ getPortOutgoingEdgeIds(e) {
1898
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortOutgoingEdgeIds(e);
1899
+ }
1900
+ getPortCycleEdgeIds(e) {
1901
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortCycleEdgeIds(e);
1902
+ }
1903
+ getPortAdjacentEdgeIds(e) {
1904
+ return this.graphStore.getPort(e) === void 0 ? null : this.graphStore.getPortAdjacentEdgeIds(e);
1905
+ }
1906
+ getNodeIncomingEdgeIds(e) {
1907
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeIncomingEdgeIds(e);
1908
+ }
1909
+ getNodeOutgoingEdgeIds(e) {
1910
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeOutgoingEdgeIds(e);
1911
+ }
1912
+ getNodeCycleEdgeIds(e) {
1913
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeCycleEdgeIds(e);
1914
+ }
1915
+ getNodeAdjacentEdgeIds(e) {
1916
+ return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
1917
+ }
1918
+ }
1919
+ class De {
1920
+ constructor(e) {
1921
+ s(this, "onAfterUpdated");
1922
+ this.viewportStore = e, this.onAfterUpdated = this.viewportStore.onAfterUpdated;
1923
+ }
1924
+ getViewportMatrix() {
1925
+ return { ...this.viewportStore.getViewportMatrix() };
1926
+ }
1927
+ getContentMatrix() {
1928
+ return { ...this.viewportStore.getContentMatrix() };
1929
+ }
1930
+ }
1931
+ const Ne = (r, e) => {
1932
+ const t = new fe(), o = new Te(t), i = new De(e), n = new ue(t, e, r), a = {
1898
1933
  nodes: {
1899
1934
  centerFn: me,
1900
1935
  priorityFn: () => 0
@@ -1907,7 +1942,14 @@ const Te = (r, e) => {
1907
1942
  direction: 0
1908
1943
  }
1909
1944
  };
1910
- return new we(t, e, o, i);
1945
+ return new we(
1946
+ o,
1947
+ i,
1948
+ t,
1949
+ e,
1950
+ n,
1951
+ a
1952
+ );
1911
1953
  };
1912
1954
  class k {
1913
1955
  constructor(e, t, o, i) {
@@ -2061,7 +2103,7 @@ class Z {
2061
2103
  nodeId: o,
2062
2104
  dx: a.x - i.x,
2063
2105
  dy: a.y - i.y
2064
- }, U(this.element, this.params.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2106
+ }, I(this.element, this.params.dragCursor), this.moveNodeOnTop(o), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2065
2107
  passive: !0
2066
2108
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2067
2109
  passive: !0
@@ -2163,7 +2205,7 @@ class Z {
2163
2205
  }
2164
2206
  }
2165
2207
  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();
2208
+ 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
2209
  }
2168
2210
  removeMouseDragListeners() {
2169
2211
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -2206,15 +2248,15 @@ class Z {
2206
2248
  return e;
2207
2249
  }
2208
2250
  }
2209
- const at = (r, e, t) => ({
2251
+ const ht = (r, e, t) => ({
2210
2252
  scale: r.scale,
2211
2253
  x: r.x + r.scale * e,
2212
2254
  y: r.y + r.scale * t
2213
- }), ht = (r, e, t, o) => ({
2255
+ }), dt = (r, e, t, o) => ({
2214
2256
  scale: r.scale * e,
2215
2257
  x: r.scale * (1 - e) * t + r.x,
2216
2258
  y: r.scale * (1 - e) * o + r.y
2217
- }), I = (r) => {
2259
+ }), U = (r) => {
2218
2260
  const e = [], t = r.touches.length;
2219
2261
  for (let h = 0; h < t; h++)
2220
2262
  e.push([r.touches[h].clientX, r.touches[h].clientY]);
@@ -2243,7 +2285,7 @@ class z {
2243
2285
  this.removeMouseDragListeners(), this.removeTouchDragListeners();
2244
2286
  });
2245
2287
  s(this, "onMouseDown", (e) => {
2246
- this.element === null || !this.params.mouseDownEventVerifier(e) || (U(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2288
+ this.element === null || !this.params.mouseDownEventVerifier(e) || (I(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2247
2289
  passive: !0
2248
2290
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2249
2291
  passive: !0
@@ -2276,10 +2318,10 @@ class z {
2276
2318
  });
2277
2319
  s(this, "onTouchStart", (e) => {
2278
2320
  if (this.prevTouches !== null) {
2279
- this.prevTouches = I(e);
2321
+ this.prevTouches = U(e);
2280
2322
  return;
2281
2323
  }
2282
- this.prevTouches = I(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2324
+ this.prevTouches = U(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2283
2325
  passive: !0
2284
2326
  }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
2285
2327
  passive: !0
@@ -2288,7 +2330,7 @@ class z {
2288
2330
  }), this.startRegisteredTransform();
2289
2331
  });
2290
2332
  s(this, "onWindowTouchMove", (e) => {
2291
- const t = I(e);
2333
+ const t = U(e);
2292
2334
  if (!t.touches.every(
2293
2335
  (i) => C(this.window, this.element, i[0], i[1])
2294
2336
  )) {
@@ -2305,7 +2347,7 @@ class z {
2305
2347
  this.prevTouches = t;
2306
2348
  });
2307
2349
  s(this, "onWindowTouchFinish", (e) => {
2308
- e.touches.length > 0 ? this.prevTouches = I(e) : this.stopTouchDrag();
2350
+ e.touches.length > 0 ? this.prevTouches = U(e) : this.stopTouchDrag();
2309
2351
  });
2310
2352
  s(this, "observer", new ResizeObserver(() => {
2311
2353
  const e = this.viewport.getViewportMatrix(), { width: t, height: o } = this.element.getBoundingClientRect(), i = this.params.transformPreprocessor({
@@ -2333,7 +2375,7 @@ class z {
2333
2375
  new z(e, t, o, i);
2334
2376
  }
2335
2377
  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({
2378
+ const o = this.viewport.getViewportMatrix(), i = ht(o, e, t), { width: n, height: a } = this.element.getBoundingClientRect(), h = this.params.transformPreprocessor({
2337
2379
  prevTransform: o,
2338
2380
  nextTransform: i,
2339
2381
  canvasWidth: n,
@@ -2342,7 +2384,7 @@ class z {
2342
2384
  this.performTransform(h);
2343
2385
  }
2344
2386
  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({
2387
+ const i = this.canvas.viewport.getViewportMatrix(), n = dt(i, e, t, o), { width: a, height: h } = this.element.getBoundingClientRect(), d = this.params.transformPreprocessor({
2346
2388
  prevTransform: i,
2347
2389
  nextTransform: n,
2348
2390
  canvasWidth: a,
@@ -2351,7 +2393,7 @@ class z {
2351
2393
  this.performTransform(d);
2352
2394
  }
2353
2395
  stopMouseDrag() {
2354
- U(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2396
+ I(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2355
2397
  }
2356
2398
  removeMouseDragListeners() {
2357
2399
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -2454,13 +2496,13 @@ class J {
2454
2496
  this.trigger.emit({ x: o, y: i, width: n, height: a });
2455
2497
  }
2456
2498
  }
2457
- const dt = () => {
2499
+ const ct = () => {
2458
2500
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2459
2501
  return r.style.position = "absolute", r.style.inset = "0", r;
2460
- }, ct = () => {
2502
+ }, gt = () => {
2461
2503
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2462
2504
  return r.setAttribute("fill", "url(#pattern)"), r;
2463
- }, gt = () => {
2505
+ }, lt = () => {
2464
2506
  const r = document.createElementNS(
2465
2507
  "http://www.w3.org/2000/svg",
2466
2508
  "pattern"
@@ -2469,9 +2511,9 @@ const dt = () => {
2469
2511
  };
2470
2512
  class Q {
2471
2513
  constructor(e, t, o) {
2472
- s(this, "svg", dt());
2473
- s(this, "patternRenderingRectangle", ct());
2474
- s(this, "pattern", gt());
2514
+ s(this, "svg", ct());
2515
+ s(this, "patternRenderingRectangle", gt());
2516
+ s(this, "pattern", lt());
2475
2517
  s(this, "patternContent");
2476
2518
  s(this, "tileWidth");
2477
2519
  s(this, "tileHeight");
@@ -2511,7 +2553,7 @@ class _ {
2511
2553
  s(this, "onEdgeCreated", (e) => {
2512
2554
  this.params.onAfterEdgeCreated(e);
2513
2555
  });
2514
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Te(
2556
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Ne(
2515
2557
  this.overlayLayer,
2516
2558
  this.viewportStore
2517
2559
  ), k.configure(
@@ -2607,7 +2649,7 @@ class q {
2607
2649
  s(this, "onEdgeReattached", (e) => {
2608
2650
  this.params.onAfterEdgeReattached(e);
2609
2651
  });
2610
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Te(
2652
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = i, this.params = n, this.overlayCanvas = Ne(
2611
2653
  this.overlayLayer,
2612
2654
  this.viewportStore
2613
2655
  ), k.configure(
@@ -2669,11 +2711,11 @@ class q {
2669
2711
  overlayId: P.Static,
2670
2712
  portCoords: y,
2671
2713
  portDirection: c.direction
2672
- }, E = {
2714
+ }, A = {
2673
2715
  overlayId: P.Dragging,
2674
2716
  portCoords: v,
2675
2717
  portDirection: d.direction
2676
- }, [R, b] = this.isTargetDragging ? [x, E] : [E, x];
2718
+ }, [R, b] = this.isTargetDragging ? [x, A] : [A, x];
2677
2719
  this.overlayCanvas.addNode(B(R)), this.overlayCanvas.addNode(B(b));
2678
2720
  const D = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(P.Edge) : i.shape;
2679
2721
  return this.overlayCanvas.addEdge({
@@ -2730,7 +2772,7 @@ class q {
2730
2772
  }
2731
2773
  }
2732
2774
  }
2733
- const lt = () => {
2775
+ const ut = () => {
2734
2776
  const r = document.createElement("div");
2735
2777
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
2736
2778
  }, Y = () => {
@@ -2740,25 +2782,25 @@ const lt = () => {
2740
2782
  const r = Y();
2741
2783
  return r.style.pointerEvents = "none", r;
2742
2784
  };
2743
- class ut {
2785
+ class pt {
2744
2786
  constructor(e) {
2745
2787
  s(this, "background", Y());
2746
2788
  s(this, "main", Y());
2747
2789
  s(this, "overlayConnectablePorts", de());
2748
2790
  s(this, "overlayDraggableEdges", de());
2749
- s(this, "host", lt());
2791
+ s(this, "host", ut());
2750
2792
  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
2793
  }
2752
2794
  destroy() {
2753
2795
  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
2796
  }
2755
2797
  }
2756
- const H = (r) => () => r, ce = H(0), pt = () => {
2798
+ const H = (r) => () => r, ce = H(0), wt = () => {
2757
2799
  let r = 0;
2758
2800
  return () => r++;
2759
- }, wt = (r, e) => {
2801
+ }, ft = (r, e) => {
2760
2802
  let t = ce, o = ce;
2761
- const i = pt();
2803
+ const i = wt();
2762
2804
  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
2805
  nodesPriorityFn: t,
2764
2806
  edgesPriorityFn: o
@@ -2768,7 +2810,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2768
2810
  return r;
2769
2811
  switch (r.type) {
2770
2812
  case "straight":
2771
- return () => new rt({
2813
+ return () => new ot({
2772
2814
  color: r.color,
2773
2815
  width: r.width,
2774
2816
  arrowLength: r.arrowLength,
@@ -2782,7 +2824,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2782
2824
  detourDirection: r.detourDirection
2783
2825
  });
2784
2826
  case "horizontal":
2785
- return () => new tt({
2827
+ return () => new rt({
2786
2828
  color: r.color,
2787
2829
  width: r.width,
2788
2830
  arrowLength: r.arrowLength,
@@ -2795,7 +2837,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2795
2837
  detourDistance: r.detourDistance
2796
2838
  });
2797
2839
  case "vertical":
2798
- return () => new ot({
2840
+ return () => new st({
2799
2841
  color: r.color,
2800
2842
  width: r.width,
2801
2843
  arrowLength: r.arrowLength,
@@ -2819,7 +2861,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2819
2861
  targetOffset: r.targetOffset
2820
2862
  });
2821
2863
  default:
2822
- return () => new et({
2864
+ return () => new tt({
2823
2865
  color: r.color,
2824
2866
  width: r.width,
2825
2867
  arrowLength: r.arrowLength,
@@ -2833,9 +2875,9 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2833
2875
  detourDirection: r.detourDirection
2834
2876
  });
2835
2877
  }
2836
- }, ft = (r) => {
2878
+ }, yt = (r) => {
2837
2879
  var t, o, i, n, a;
2838
- const e = wt(
2880
+ const e = ft(
2839
2881
  (t = r.nodes) == null ? void 0 : t.priority,
2840
2882
  (o = r.edges) == null ? void 0 : o.priority
2841
2883
  );
@@ -2852,11 +2894,11 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2852
2894
  priorityFn: e.edgesPriorityFn
2853
2895
  }
2854
2896
  };
2855
- }, yt = (r) => {
2897
+ }, mt = (r) => {
2856
2898
  var p, f, y, v, x;
2857
2899
  const e = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
2858
2900
  }), 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;
2901
+ }), 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
2902
  return {
2861
2903
  moveOnTop: i,
2862
2904
  moveEdgesOnTop: n,
@@ -2868,7 +2910,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2868
2910
  nodeDragVerifier: t,
2869
2911
  onNodeDragFinished: o
2870
2912
  };
2871
- }, mt = (r) => {
2913
+ }, vt = (r) => {
2872
2914
  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
2915
  return (n) => {
2874
2916
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -2878,7 +2920,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2878
2920
  const l = n.canvasHeight * n.prevTransform.scale, g = i - l;
2879
2921
  return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
2880
2922
  };
2881
- }, vt = (r) => {
2923
+ }, Et = (r) => {
2882
2924
  const e = r.maxContentScale, t = r.minContentScale, o = e !== null ? 1 / e : 0, i = t !== null ? 1 / t : 1 / 0;
2883
2925
  return (n) => {
2884
2926
  const a = n.prevTransform, h = n.nextTransform;
@@ -2912,12 +2954,12 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2912
2954
  return r;
2913
2955
  switch (r.type) {
2914
2956
  case "scale-limit":
2915
- return vt({
2957
+ return Et({
2916
2958
  minContentScale: r.minContentScale ?? 0,
2917
2959
  maxContentScale: r.maxContentScale ?? 1 / 0
2918
2960
  });
2919
2961
  case "shift-limit":
2920
- return mt({
2962
+ return vt({
2921
2963
  minX: r.minX ?? -1 / 0,
2922
2964
  maxX: r.maxX ?? 1 / 0,
2923
2965
  minY: r.minY ?? -1 / 0,
@@ -2925,7 +2967,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2925
2967
  });
2926
2968
  }
2927
2969
  }, le = (r) => {
2928
- var y, v, x, E, R, b, D, V, te, re, oe, se;
2970
+ var y, v, x, A, R, b, D, V, te, re, oe, se;
2929
2971
  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
2972
  let i;
2931
2973
  o !== void 0 ? Array.isArray(o) ? i = At(
@@ -2934,7 +2976,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2934
2976
  )
2935
2977
  ) : i = ge(o) : i = (N) => N.nextTransform;
2936
2978
  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) ?? (() => {
2979
+ }), h = ((A = r == null ? void 0 : r.events) == null ? void 0 : A.onTransformChange) ?? (() => {
2938
2980
  }), 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
2981
  return {
2940
2982
  wheelSensitivity: t,
@@ -2955,24 +2997,24 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2955
2997
  onResizeTransformFinished: ((se = r == null ? void 0 : r.events) == null ? void 0 : se.onResizeTransformFinished) ?? (() => {
2956
2998
  })
2957
2999
  };
2958
- }, Et = (r, e) => {
3000
+ }, xt = (r, e) => {
2959
3001
  const t = document.createElementNS(
2960
3002
  "http://www.w3.org/2000/svg",
2961
3003
  "circle"
2962
3004
  );
2963
3005
  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(
3006
+ }, St = (r) => r instanceof SVGElement ? r : xt(
2965
3007
  (r == null ? void 0 : r.radius) ?? 1.5,
2966
3008
  (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 ?? {});
3009
+ ), Pt = (r) => {
3010
+ 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
3011
  return {
2970
3012
  tileWidth: t,
2971
3013
  tileHeight: o,
2972
3014
  renderer: i,
2973
3015
  maxViewportScale: r.maxViewportScale ?? 10
2974
3016
  };
2975
- }, Pt = (r, e, t) => {
3017
+ }, bt = (r, e, t) => {
2976
3018
  var c, l, g;
2977
3019
  const o = () => "direct", i = (p) => p, n = (p) => p.button === 0, a = () => {
2978
3020
  }, h = () => {
@@ -2989,7 +3031,7 @@ const H = (r) => () => r, ce = H(0), pt = () => {
2989
3031
  dragPortDirection: r.dragPortDirection ?? t,
2990
3032
  edgeShapeFactory: r.edgeShape !== void 0 ? ee(r.edgeShape) : e
2991
3033
  };
2992
- }, bt = (r, e) => {
3034
+ }, Tt = (r, e) => {
2993
3035
  var c, l, g;
2994
3036
  const t = (p) => p, o = (p) => p.button === 0 && p.ctrlKey, i = (p) => p.button === 0, n = (p) => {
2995
3037
  const f = e.getPortAdjacentEdgeIds(p);
@@ -3008,10 +3050,10 @@ const H = (r) => () => r, ce = H(0), pt = () => {
3008
3050
  onEdgeReattachInterrupted: ((l = r.events) == null ? void 0 : l.onEdgeReattachInterrupted) ?? d,
3009
3051
  onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
3010
3052
  };
3011
- }, Tt = (r) => ({
3053
+ }, Dt = (r) => ({
3012
3054
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3013
3055
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3014
- }), Dt = (r) => {
3056
+ }), Nt = (r) => {
3015
3057
  var e, t;
3016
3058
  return {
3017
3059
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3020,13 +3062,13 @@ const H = (r) => () => r, ce = H(0), pt = () => {
3020
3062
  })
3021
3063
  };
3022
3064
  };
3023
- class Nt extends Error {
3065
+ class Mt extends Error {
3024
3066
  constructor() {
3025
3067
  super(...arguments);
3026
3068
  s(this, "name", "CanvasBuilderError");
3027
3069
  }
3028
3070
  }
3029
- class Lt {
3071
+ class Ct {
3030
3072
  constructor(e) {
3031
3073
  s(this, "used", !1);
3032
3074
  s(this, "canvasDefaults", {});
@@ -3044,7 +3086,9 @@ class Lt {
3044
3086
  s(this, "hasUserDraggableEdges", !1);
3045
3087
  s(this, "boxRenderingTrigger", new pe());
3046
3088
  s(this, "graphStore", new fe());
3047
- s(this, "viewportStore", new Be());
3089
+ s(this, "viewportStore", new Fe());
3090
+ s(this, "graph", new Te(this.graphStore));
3091
+ s(this, "viewport", new De(this.viewportStore));
3048
3092
  s(this, "window", window);
3049
3093
  this.element = e;
3050
3094
  }
@@ -3099,21 +3143,23 @@ class Lt {
3099
3143
  */
3100
3144
  build() {
3101
3145
  if (this.used)
3102
- throw new Nt("CanvasBuilder is a single use object");
3146
+ throw new Mt("CanvasBuilder is a single use object");
3103
3147
  this.used = !0;
3104
- const e = new ut(this.element);
3148
+ const e = new pt(this.element);
3105
3149
  let t = new ue(
3106
3150
  this.graphStore,
3107
3151
  this.viewportStore,
3108
3152
  e.main
3109
3153
  );
3110
- this.virtualScrollConfig !== void 0 && (t = new Ve(
3154
+ this.virtualScrollConfig !== void 0 && (t = new Ue(
3111
3155
  t,
3112
3156
  this.graphStore,
3113
3157
  this.boxRenderingTrigger,
3114
- Dt(this.virtualScrollConfig)
3115
- ));
3116
- const o = ft(this.canvasDefaults), i = new we(
3158
+ Nt(this.virtualScrollConfig)
3159
+ )), t = new Ie(t, this.graphStore);
3160
+ const o = yt(this.canvasDefaults), i = new we(
3161
+ this.graph,
3162
+ this.viewport,
3117
3163
  this.graphStore,
3118
3164
  this.viewportStore,
3119
3165
  t,
@@ -3121,15 +3167,15 @@ class Lt {
3121
3167
  );
3122
3168
  if (this.hasBackground && Q.configure(
3123
3169
  i,
3124
- St(this.backgroundConfig),
3170
+ Pt(this.backgroundConfig),
3125
3171
  e.background
3126
3172
  ), this.hasNodeResizeReactiveEdges && j.configure(i), this.hasDraggableNode && Z.configure(
3127
3173
  i,
3128
3174
  e.main,
3129
3175
  this.window,
3130
- yt(this.dragConfig)
3176
+ mt(this.dragConfig)
3131
3177
  ), this.hasUserConnectablePorts) {
3132
- const a = Pt(
3178
+ const a = bt(
3133
3179
  this.connectablePortsConfig,
3134
3180
  o.edges.shapeFactory,
3135
3181
  o.ports.direction
@@ -3143,7 +3189,7 @@ class Lt {
3143
3189
  );
3144
3190
  }
3145
3191
  if (this.hasUserDraggableEdges) {
3146
- const a = bt(
3192
+ const a = Tt(
3147
3193
  this.draggableEdgesConfig,
3148
3194
  i.graph
3149
3195
  );
@@ -3161,7 +3207,7 @@ class Lt {
3161
3207
  this.window,
3162
3208
  le(this.transformConfig),
3163
3209
  this.boxRenderingTrigger,
3164
- Tt(this.virtualScrollConfig)
3210
+ Dt(this.virtualScrollConfig)
3165
3211
  ) : this.hasTransformableViewport && z.configure(
3166
3212
  i,
3167
3213
  e.main,
@@ -3175,15 +3221,15 @@ class Lt {
3175
3221
  }
3176
3222
  }
3177
3223
  export {
3178
- et as BezierEdgeShape,
3179
- Lt as CanvasBuilder,
3180
- Nt as CanvasBuilderError,
3224
+ tt as BezierEdgeShape,
3225
+ Ct as CanvasBuilder,
3226
+ Mt as CanvasBuilderError,
3181
3227
  S as CanvasError,
3182
3228
  Pe as DirectEdgeShape,
3183
- tt as HorizontalEdgeShape,
3184
- nt as InteractiveEdgeError,
3229
+ rt as HorizontalEdgeShape,
3230
+ at as InteractiveEdgeError,
3185
3231
  be as InteractiveEdgeShape,
3186
- Rt as MidpointEdgeShape,
3187
- rt as StraightEdgeShape,
3188
- ot as VerticalEdgeShape
3232
+ Lt as MidpointEdgeShape,
3233
+ ot as StraightEdgeShape,
3234
+ st as VerticalEdgeShape
3189
3235
  };