@html-graph/html-graph 8.5.0 → 8.6.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,20 +1,22 @@
1
- var Ye = Object.defineProperty;
2
- var Xe = (r, e, t) => e in r ? Ye(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => Xe(r, typeof e != "symbol" ? e + "" : e, t);
4
- var D = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(D || {});
5
- const Ge = () => {
1
+ var Ke = Object.defineProperty;
2
+ var Qe = (r, e, t) => e in r ? Ke(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var i = (r, e, t) => Qe(r, typeof e != "symbol" ? e + "" : e, t);
4
+ var R = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(R || {});
5
+ const Ze = () => {
6
6
  const r = document.createElement("div");
7
7
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r.style.overflow = "hidden", r;
8
- }, je = () => {
8
+ }, Je = () => {
9
9
  const r = document.createElement("div");
10
10
  return r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.width = "0", r.style.height = "0", r;
11
- }, qe = (r) => {
11
+ }, _e = (r) => {
12
12
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
13
+ }, et = (r) => {
14
+ r.style.removeProperty("position"), r.style.removeProperty("top"), r.style.removeProperty("left"), r.style.removeProperty("visibility"), r.style.removeProperty("transform");
13
15
  };
14
- class xe {
16
+ class Ee {
15
17
  constructor(e, t, s) {
16
- i(this, "host", Ge());
17
- i(this, "container", je());
18
+ i(this, "host", Ze());
19
+ i(this, "container", Je());
18
20
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
19
21
  i(this, "attachedNodeIds", /* @__PURE__ */ new Set());
20
22
  i(this, "applyTransform", () => {
@@ -25,11 +27,11 @@ class xe {
25
27
  }
26
28
  attachNode(e) {
27
29
  const t = this.graphStore.getNode(e);
28
- qe(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
30
+ _e(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
29
31
  }
30
32
  detachNode(e) {
31
33
  const t = this.graphStore.getNode(e);
32
- this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
34
+ et(t.element), this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
33
35
  }
34
36
  attachEdge(e) {
35
37
  const t = this.graphStore.getEdge(e).payload.shape.svg;
@@ -47,7 +49,7 @@ class xe {
47
49
  });
48
50
  }
49
51
  destroy() {
50
- this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.element.removeChild(this.host), this.host.removeChild(this.container);
52
+ this.clear(), this.viewportStore.onAfterUpdated.unsubscribe(this.applyTransform), this.element.removeChild(this.host), this.host.removeChild(this.container);
51
53
  }
52
54
  updateNodePosition(e) {
53
55
  const t = this.graphStore.getNode(e), { width: s, height: o } = t.element.getBoundingClientRect(), n = this.viewportStore.getViewportMatrix().scale, { payload: a } = t, h = a.centerFn(s, o), d = a.x - n * h.x, c = a.y - n * h.y;
@@ -70,8 +72,8 @@ class xe {
70
72
  h,
71
73
  d
72
74
  ), g = this.createEdgeRenderPort(o, a, h, d);
73
- let l = D.Line;
74
- s.element === o.element ? l = D.PortCycle : s.nodeId === o.nodeId && (l = D.NodeCycle), t.payload.shape.render({ from: c, to: g, category: l });
75
+ let l = R.Line;
76
+ s.element === o.element ? l = R.PortCycle : s.nodeId === o.nodeId && (l = R.NodeCycle), t.payload.shape.render({ from: c, to: g, category: l });
75
77
  }
76
78
  updateEdgePriority(e) {
77
79
  const t = this.graphStore.getEdge(e);
@@ -91,7 +93,7 @@ class xe {
91
93
  };
92
94
  }
93
95
  }
94
- class Ke {
96
+ class tt {
95
97
  constructor(e) {
96
98
  i(this, "xFrom", 1 / 0);
97
99
  i(this, "yFrom", 1 / 0);
@@ -111,7 +113,7 @@ class Ke {
111
113
  return h <= this.xTo && d >= this.xFrom && c <= this.yTo && g >= this.yFrom;
112
114
  }
113
115
  }
114
- class Qe {
116
+ class rt {
115
117
  constructor(e, t, s, o) {
116
118
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
117
119
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -135,7 +137,7 @@ class Qe {
135
137
  this.handleAttachEdge(a);
136
138
  });
137
139
  });
138
- this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = o, this.renderingBox = new Ke(this.graphStore), this.trigger.subscribe(this.updateViewport);
140
+ this.htmlView = e, this.graphStore = t, this.trigger = s, this.params = o, this.renderingBox = new tt(this.graphStore), this.trigger.subscribe(this.updateViewport);
139
141
  }
140
142
  attachNode(e) {
141
143
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -189,7 +191,7 @@ class Qe {
189
191
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
190
192
  }
191
193
  }
192
- class Ze {
194
+ class st {
193
195
  constructor(e, t) {
194
196
  i(this, "deferredNodes", /* @__PURE__ */ new Set());
195
197
  i(this, "deferredEdges", /* @__PURE__ */ new Set());
@@ -243,7 +245,7 @@ class Ze {
243
245
  this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
244
246
  }
245
247
  }
246
- class Q {
248
+ class K {
247
249
  constructor() {
248
250
  i(this, "callbacks", /* @__PURE__ */ new Set());
249
251
  }
@@ -259,215 +261,64 @@ class Q {
259
261
  });
260
262
  }
261
263
  }
262
- const E = () => {
263
- const r = new Q();
264
+ const S = () => {
265
+ const r = new K();
264
266
  return [r, r];
265
267
  };
266
- class G {
267
- constructor(e) {
268
- i(this, "counter", 0);
269
- this.checkExists = e;
270
- }
271
- create(e) {
272
- if (e !== void 0)
273
- return e;
274
- for (; this.checkExists(this.counter); )
275
- this.counter++;
276
- return this.counter;
277
- }
278
- reset() {
279
- this.counter = 0;
280
- }
281
- }
282
- class Ee {
283
- constructor(e, t, s, o, n, a) {
284
- i(this, "nodeIdGenerator", new G(
285
- (e) => this.graphStore.hasNode(e)
286
- ));
287
- i(this, "portIdGenerator", new G(
288
- (e) => this.graphStore.hasPort(e)
289
- ));
290
- i(this, "edgeIdGenerator", new G(
291
- (e) => this.graphStore.hasEdge(e)
292
- ));
293
- i(this, "onAfterNodeAdded", (e) => {
294
- this.htmlView.attachNode(e);
295
- });
296
- i(this, "onAfterNodeUpdated", (e) => {
297
- this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((t) => {
298
- this.htmlView.renderEdge(t);
299
- });
300
- });
301
- i(this, "onAfterNodePriorityUpdated", (e) => {
302
- this.htmlView.updateNodePriority(e);
303
- });
304
- i(this, "onBeforeNodeRemoved", (e) => {
305
- this.graphStore.getNodePortIds(e).forEach((t) => {
306
- this.unmarkPort(t);
307
- }), this.htmlView.detachNode(e);
308
- });
309
- i(this, "onAfterPortUpdated", (e) => {
310
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
311
- this.htmlView.renderEdge(t);
312
- });
313
- });
314
- i(this, "onBeforePortUnmarked", (e) => {
315
- this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
316
- this.removeEdge(t);
317
- });
318
- });
319
- i(this, "onAfterEdgeAdded", (e) => {
320
- this.htmlView.attachEdge(e);
321
- });
322
- i(this, "onAfterEdgeShapeUpdated", (e) => {
323
- this.htmlView.updateEdgeShape(e);
324
- });
325
- i(this, "onAfterEdgeUpdated", (e) => {
326
- this.htmlView.renderEdge(e);
327
- });
328
- i(this, "onAfterEdgePriorityUpdated", (e) => {
329
- this.htmlView.updateEdgePriority(e);
330
- });
331
- i(this, "onBeforeEdgeRemoved", (e) => {
332
- this.htmlView.detachEdge(e);
333
- });
334
- i(this, "onBeforeClear", () => {
335
- this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
336
- });
337
- i(this, "onBeforeDestroyEmitter");
268
+ class Se {
269
+ constructor(e, t, s, o) {
270
+ i(this, "beforeDestroyEmitter");
338
271
  i(this, "destroyed", !1);
339
- /**
340
- * emits event just before destruction of canvas
341
- */
342
272
  i(this, "onBeforeDestroy");
343
- this.graph = e, this.viewport = t, this.graphStore = s, this.viewportStore = o, this.htmlView = n, this.params = a, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
344
- this.onAfterNodePriorityUpdated
345
- ), 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(
346
- this.onAfterEdgeShapeUpdated
347
- ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
348
- this.onAfterEdgePriorityUpdated
349
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
273
+ this.graph = e, this.viewport = t, this.graphController = s, this.viewportController = o, [this.beforeDestroyEmitter, this.onBeforeDestroy] = S();
350
274
  }
351
- /**
352
- * adds new node
353
- */
354
275
  addNode(e) {
355
- const t = this.nodeIdGenerator.create(e.id);
356
- if (this.graphStore.addNode({
357
- id: t,
358
- element: e.element,
359
- x: e.x ?? null,
360
- y: e.y ?? null,
361
- centerFn: e.centerFn ?? this.params.nodes.centerFn,
362
- priority: e.priority ?? this.params.nodes.priorityFn()
363
- }), e.ports !== void 0)
364
- for (const s of e.ports)
365
- this.markPort({
366
- id: s.id,
367
- element: s.element,
368
- nodeId: t,
369
- direction: s.direction
370
- });
371
- return this;
276
+ return this.graphController.addNode(e), this;
372
277
  }
373
- /**
374
- * updates node parameters
375
- */
376
278
  updateNode(e, t) {
377
- return this.graphStore.updateNode(e, t ?? {}), this;
279
+ return this.graphController.updateNode(e, t), this;
378
280
  }
379
- /**
380
- * removes specified node
381
- * all the ports of node get unmarked
382
- * all the edges adjacent to node get removed
383
- */
384
281
  removeNode(e) {
385
- return this.graphStore.removeNode(e), this;
282
+ return this.graphController.removeNode(e), this;
386
283
  }
387
- /**
388
- * marks specified element as a port for specified node
389
- */
390
284
  markPort(e) {
391
- const t = this.portIdGenerator.create(e.id);
392
- return this.graphStore.addPort({
393
- id: t,
394
- element: e.element,
395
- nodeId: e.nodeId,
396
- direction: e.direction ?? this.params.ports.direction
397
- }), this;
285
+ return this.graphController.markPort(e), this;
398
286
  }
399
- /**
400
- * updates port and edges attached to it
401
- */
402
287
  updatePort(e, t) {
403
- return this.graphStore.updatePort(e, t ?? {}), this;
288
+ return this.graphController.updatePort(e, t), this;
404
289
  }
405
- /**
406
- * unmarks specified port
407
- * all the edges adjacent to the port get removed
408
- */
409
290
  unmarkPort(e) {
410
- return this.graphStore.removePort(e), this;
291
+ return this.graphController.unmarkPort(e), this;
411
292
  }
412
- /**
413
- * adds new edge
414
- */
415
293
  addEdge(e) {
416
- const t = this.edgeIdGenerator.create(e.id);
417
- return this.graphStore.addEdge({
418
- id: t,
419
- from: e.from,
420
- to: e.to,
421
- shape: e.shape ?? this.params.edges.shapeFactory(t),
422
- priority: e.priority ?? this.params.edges.priorityFn()
423
- }), this;
294
+ return this.graphController.addEdge(e), this;
424
295
  }
425
- /**
426
- * updates specified edge
427
- */
428
296
  updateEdge(e, t) {
429
- return this.graphStore.updateEdge(e, t ?? {}), this;
297
+ return this.graphController.updateEdge(e, t), this;
430
298
  }
431
- /**
432
- * removes specified edge
433
- */
434
299
  removeEdge(e) {
435
- return this.graphStore.removeEdge(e), this;
300
+ return this.graphController.removeEdge(e), this;
436
301
  }
437
- /**
438
- * clears canvas from nodes and edges
439
- * canvas gets rolled back to initial state and can be reused
440
- */
441
302
  clear() {
442
- return this.graphStore.clear(), this;
303
+ return this.graphController.clear(), this;
304
+ }
305
+ focus(e) {
306
+ return this.viewportController.focus(e), this;
307
+ }
308
+ center(e, t) {
309
+ return this.viewportController.center(e, t), this;
443
310
  }
444
- /**
445
- * applies transformation for viewport matrix
446
- */
447
311
  patchViewportMatrix(e) {
448
- return this.viewportStore.patchViewportMatrix(e), this;
312
+ return this.viewportController.patchViewportMatrix(e), this;
449
313
  }
450
- /**
451
- * applies transformation for content matrix
452
- */
453
314
  patchContentMatrix(e) {
454
- return this.viewportStore.patchContentMatrix(e), this;
315
+ return this.viewportController.patchContentMatrix(e), this;
455
316
  }
456
- /**
457
- * destroys canvas
458
- * canvas element gets rolled back to initial state, and can not be reused
459
- */
460
317
  destroy() {
461
- this.destroyed || (this.clear(), this.onBeforeDestroyEmitter.emit(), this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
462
- this.onAfterNodePriorityUpdated
463
- ), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
464
- this.onAfterEdgeShapeUpdated
465
- ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
466
- this.onAfterEdgePriorityUpdated
467
- ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy(), this.viewportStore.destroy(), this.destroyed = !0);
318
+ this.destroyed || (this.destroyed = !0, this.beforeDestroyEmitter.emit(), this.graphController.destroy(), this.viewportController.destroy());
468
319
  }
469
320
  }
470
- class Je {
321
+ class ot {
471
322
  constructor() {
472
323
  i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
473
324
  i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -507,22 +358,22 @@ class Je {
507
358
  return this.multiToSingleMap.get(e) !== void 0;
508
359
  }
509
360
  }
510
- class x extends Error {
361
+ class E extends Error {
511
362
  constructor() {
512
363
  super(...arguments);
513
364
  i(this, "name", "CanvasError");
514
365
  }
515
366
  }
516
- class Se {
367
+ class be {
517
368
  constructor() {
518
369
  i(this, "nodes", /* @__PURE__ */ new Map());
519
370
  i(this, "ports", /* @__PURE__ */ new Map());
520
371
  i(this, "edges", /* @__PURE__ */ new Map());
521
372
  i(this, "nodesElementsMap", /* @__PURE__ */ new Map());
522
373
  i(this, "portIncomingEdges", /* @__PURE__ */ new Map());
523
- i(this, "portOutcomingEdges", /* @__PURE__ */ new Map());
374
+ i(this, "portOutgoingEdges", /* @__PURE__ */ new Map());
524
375
  i(this, "portCycleEdges", /* @__PURE__ */ new Map());
525
- i(this, "elementPorts", new Je());
376
+ i(this, "elementPorts", new ot());
526
377
  i(this, "afterNodeAddedEmitter");
527
378
  i(this, "onAfterNodeAdded");
528
379
  i(this, "afterNodeUpdatedEmitter");
@@ -549,7 +400,7 @@ class Se {
549
400
  i(this, "onBeforeEdgeRemoved");
550
401
  i(this, "beforeClearEmitter");
551
402
  i(this, "onBeforeClear");
552
- [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();
403
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = S(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = S(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = S(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = S(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = S(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = S(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = S(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = S(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = S(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = S(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = S(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = S(), [this.beforeClearEmitter, this.onBeforeClear] = S();
553
404
  }
554
405
  hasNode(e) {
555
406
  return this.nodes.has(e);
@@ -557,14 +408,14 @@ class Se {
557
408
  getNode(e) {
558
409
  const t = this.nodes.get(e);
559
410
  if (t === void 0)
560
- throw new x("failed to access nonexistent node");
411
+ throw new E("failed to access nonexistent node");
561
412
  return t;
562
413
  }
563
414
  addNode(e) {
564
415
  if (this.hasNode(e.id))
565
- throw new x("failed to add node with existing id");
416
+ throw new E("failed to add node with existing id");
566
417
  if (this.findNodeIdByElement(e.element) !== void 0)
567
- throw new x(
418
+ throw new E(
568
419
  "failed to add node with html element already in use by another node"
569
420
  );
570
421
  const t = /* @__PURE__ */ new Map(), s = {
@@ -587,13 +438,13 @@ class Se {
587
438
  }
588
439
  updateNode(e, t) {
589
440
  if (!this.hasNode(e))
590
- throw new x("failed to update nonexistent node");
441
+ throw new E("failed to update nonexistent node");
591
442
  const { payload: s } = this.nodes.get(e);
592
443
  s.x = t.x ?? s.x, s.y = t.y ?? s.y, s.centerFn = t.centerFn ?? s.centerFn, t.priority !== void 0 && (s.priority = t.priority, this.afterNodePriorityUpdatedEmitter.emit(e)), this.afterNodeUpdatedEmitter.emit(e);
593
444
  }
594
445
  removeNode(e) {
595
446
  if (!this.hasNode(e))
596
- throw new x("failed to remove nonexistent node");
447
+ throw new E("failed to remove nonexistent node");
597
448
  this.beforeNodeRemovedEmitter.emit(e);
598
449
  const t = this.nodes.get(e);
599
450
  this.nodesElementsMap.delete(t.element), this.nodes.delete(e);
@@ -604,25 +455,25 @@ class Se {
604
455
  getPort(e) {
605
456
  const t = this.ports.get(e);
606
457
  if (t === void 0)
607
- throw new x("failed to access nonexistent port");
458
+ throw new E("failed to access nonexistent port");
608
459
  return t;
609
460
  }
610
461
  addPort(e) {
611
462
  if (this.hasPort(e.id))
612
- throw new x("failed to add port with existing id");
463
+ throw new E("failed to add port with existing id");
613
464
  if (!this.hasNode(e.nodeId))
614
- throw new x("failed to add port to nonexistent node");
465
+ throw new E("failed to add port to nonexistent node");
615
466
  this.ports.set(e.id, {
616
467
  element: e.element,
617
468
  payload: {
618
469
  direction: e.direction
619
470
  },
620
471
  nodeId: e.nodeId
621
- }), this.elementPorts.addRecord(e.element, e.id), this.portCycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.portIncomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.portOutcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
472
+ }), this.elementPorts.addRecord(e.element, e.id), this.portCycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.portIncomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.portOutgoingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
622
473
  }
623
474
  updatePort(e, t) {
624
475
  if (!this.hasPort(e))
625
- throw new x("failed to update nonexistent port");
476
+ throw new E("failed to update nonexistent port");
626
477
  const s = this.ports.get(e).payload;
627
478
  s.direction = t.direction ?? s.direction, this.afterPortUpdatedEmitter.emit(e);
628
479
  }
@@ -635,12 +486,12 @@ class Se {
635
486
  getNodePortIds(e) {
636
487
  const t = this.nodes.get(e);
637
488
  if (t === void 0)
638
- throw new x("failed to access port ids of nonexistent node");
489
+ throw new E("failed to access port ids of nonexistent node");
639
490
  return Array.from(t.ports.keys());
640
491
  }
641
492
  removePort(e) {
642
493
  if (!this.hasPort(e))
643
- throw new x("failed to remove nonexistent port");
494
+ throw new E("failed to remove nonexistent port");
644
495
  const t = this.ports.get(e).nodeId;
645
496
  this.beforePortRemovedEmitter.emit(e), this.nodes.get(t).ports.delete(e), this.ports.delete(e), this.elementPorts.removeByMulti(e);
646
497
  }
@@ -650,21 +501,21 @@ class Se {
650
501
  getEdge(e) {
651
502
  const t = this.edges.get(e);
652
503
  if (t === void 0)
653
- throw new x("failed to access nonexistent edge");
504
+ throw new E("failed to access nonexistent edge");
654
505
  return t;
655
506
  }
656
507
  addEdge(e) {
657
508
  if (this.hasEdge(e.id))
658
- throw new x("failed to add edge with existing id");
509
+ throw new E("failed to add edge with existing id");
659
510
  if (!this.hasPort(e.from))
660
- throw new x("failed to add edge from nonexistent port");
511
+ throw new E("failed to add edge from nonexistent port");
661
512
  if (!this.hasPort(e.to))
662
- throw new x("failed to add edge to nonexistent port");
513
+ throw new E("failed to add edge to nonexistent port");
663
514
  this.addEdgeInternal(e), this.afterEdgeAddedEmitter.emit(e.id);
664
515
  }
665
516
  updateEdge(e, t) {
666
517
  if (!this.hasEdge(e))
667
- throw new x("failed to update nonexistent edge");
518
+ throw new E("failed to update nonexistent edge");
668
519
  if (t.from !== void 0 || t.to !== void 0) {
669
520
  const o = this.edges.get(e), n = o.payload;
670
521
  this.removeEdgeInternal(e), this.addEdgeInternal({
@@ -683,28 +534,28 @@ class Se {
683
534
  }
684
535
  removeEdge(e) {
685
536
  if (!this.hasEdge(e))
686
- throw new x("failed to remove nonexistent edge");
537
+ throw new E("failed to remove nonexistent edge");
687
538
  this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
688
539
  }
689
540
  clear() {
690
- this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutcomingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
541
+ this.beforeClearEmitter.emit(), this.portIncomingEdges.clear(), this.portOutgoingEdges.clear(), this.portCycleEdges.clear(), this.elementPorts.clear(), this.nodesElementsMap.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
691
542
  }
692
543
  getPortIncomingEdgeIds(e) {
693
544
  const t = this.portIncomingEdges.get(e);
694
545
  if (t === void 0)
695
- throw new x("failed to access edges for nonexistent port");
546
+ throw new E("failed to access edges for nonexistent port");
696
547
  return Array.from(t);
697
548
  }
698
549
  getPortOutgoingEdgeIds(e) {
699
- const t = this.portOutcomingEdges.get(e);
550
+ const t = this.portOutgoingEdges.get(e);
700
551
  if (t === void 0)
701
- throw new x("failed to access edges for nonexistent port");
552
+ throw new E("failed to access edges for nonexistent port");
702
553
  return Array.from(t);
703
554
  }
704
555
  getPortCycleEdgeIds(e) {
705
556
  const t = this.portCycleEdges.get(e);
706
557
  if (t === void 0)
707
- throw new x("failed to access edges for nonexistent port");
558
+ throw new E("failed to access edges for nonexistent port");
708
559
  return Array.from(t);
709
560
  }
710
561
  getPortAdjacentEdgeIds(e) {
@@ -769,29 +620,29 @@ class Se {
769
620
  shape: e.shape,
770
621
  priority: e.priority
771
622
  }
772
- }), e.from !== e.to ? (this.portOutcomingEdges.get(e.from).add(e.id), this.portIncomingEdges.get(e.to).add(e.id)) : this.portCycleEdges.get(e.from).add(e.id);
623
+ }), e.from !== e.to ? (this.portOutgoingEdges.get(e.from).add(e.id), this.portIncomingEdges.get(e.to).add(e.id)) : this.portCycleEdges.get(e.from).add(e.id);
773
624
  }
774
625
  removeEdgeInternal(e) {
775
626
  const t = this.edges.get(e), s = t.from, o = t.to;
776
- this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(s).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutcomingEdges.get(s).delete(e), this.portOutcomingEdges.get(o).delete(e), this.edges.delete(e);
627
+ this.portCycleEdges.get(s).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(s).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutgoingEdges.get(s).delete(e), this.portOutgoingEdges.get(o).delete(e), this.edges.delete(e);
777
628
  }
778
629
  }
779
- const ge = (r) => ({
630
+ const ue = (r) => ({
780
631
  scale: 1 / r.scale,
781
632
  x: -r.x / r.scale,
782
633
  y: -r.y / r.scale
783
- }), ue = {
634
+ }), pe = {
784
635
  scale: 1,
785
636
  x: 0,
786
637
  y: 0
787
- }, pe = (r, e) => ({
638
+ }, we = (r, e) => ({
788
639
  x: r.scale * e.x + r.x,
789
640
  y: r.scale * e.y + r.y
790
641
  });
791
- class _e {
642
+ class it {
792
643
  constructor(e) {
793
- i(this, "viewportMatrix", ue);
794
- i(this, "contentMatrix", ue);
644
+ i(this, "viewportMatrix", pe);
645
+ i(this, "contentMatrix", pe);
795
646
  i(this, "beforeUpdateEmitter");
796
647
  i(this, "onBeforeUpdated");
797
648
  i(this, "afterUpdateEmitter");
@@ -801,7 +652,7 @@ class _e {
801
652
  i(this, "observer", new ResizeObserver(() => {
802
653
  this.afterResizeEmitter.emit();
803
654
  }));
804
- this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E(), [this.afterResizeEmitter, this.onAfterResize] = E(), this.observer.observe(this.host);
655
+ this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = S(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = S(), [this.afterResizeEmitter, this.onAfterResize] = S(), this.observer.observe(this.host);
805
656
  }
806
657
  getViewportMatrix() {
807
658
  return this.viewportMatrix;
@@ -814,30 +665,30 @@ class _e {
814
665
  scale: e.scale ?? this.viewportMatrix.scale,
815
666
  x: e.x ?? this.viewportMatrix.x,
816
667
  y: e.y ?? this.viewportMatrix.y
817
- }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ge(this.viewportMatrix), this.afterUpdateEmitter.emit();
668
+ }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ue(this.viewportMatrix), this.afterUpdateEmitter.emit();
818
669
  }
819
670
  patchContentMatrix(e) {
820
671
  this.contentMatrix = {
821
672
  scale: e.scale ?? this.contentMatrix.scale,
822
673
  x: e.x ?? this.contentMatrix.x,
823
674
  y: e.y ?? this.contentMatrix.y
824
- }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ge(this.contentMatrix), this.afterUpdateEmitter.emit();
675
+ }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ue(this.contentMatrix), this.afterUpdateEmitter.emit();
825
676
  }
826
677
  getDimensions() {
827
678
  const { width: e, height: t } = this.host.getBoundingClientRect();
828
679
  return { width: e, height: t };
829
680
  }
830
681
  createContentCoords(e) {
831
- return pe(this.viewportMatrix, e);
682
+ return we(this.viewportMatrix, e);
832
683
  }
833
684
  createViewportCoords(e) {
834
- return pe(this.contentMatrix, e);
685
+ return we(this.contentMatrix, e);
835
686
  }
836
687
  destroy() {
837
688
  this.observer.disconnect();
838
689
  }
839
690
  }
840
- class Z {
691
+ class Q {
841
692
  constructor(e) {
842
693
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
843
694
  i(this, "nodesResizeObserver");
@@ -849,28 +700,31 @@ class Z {
849
700
  const t = this.canvas.graph.getNode(e);
850
701
  this.elementToNodeId.delete(t.element), this.nodesResizeObserver.unobserve(t.element);
851
702
  });
852
- i(this, "onBeforeClear", () => {
703
+ i(this, "reset", () => {
853
704
  this.nodesResizeObserver.disconnect(), this.elementToNodeId.clear();
854
705
  });
706
+ i(this, "revert", () => {
707
+ this.reset();
708
+ });
855
709
  this.canvas = e, this.nodesResizeObserver = new ResizeObserver((t) => {
856
710
  t.forEach((s) => {
857
711
  const o = s.target;
858
712
  this.handleNodeResize(o);
859
713
  });
860
- }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear);
714
+ }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.revert);
861
715
  }
862
716
  static configure(e) {
863
- new Z(e);
717
+ new Q(e);
864
718
  }
865
719
  handleNodeResize(e) {
866
720
  const t = this.elementToNodeId.get(e);
867
721
  this.canvas.updateNode(t);
868
722
  }
869
723
  }
870
- const et = (r, e, t) => {
724
+ const nt = (r, e, t) => {
871
725
  const { x: s, y: o, width: n, height: a } = r.getBoundingClientRect();
872
726
  return e >= s && e <= s + n && t >= o && t <= o + a;
873
- }, tt = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, R = (r, e, t, s) => et(e, t, s) && tt(r, t, s), U = (r, e) => {
727
+ }, at = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight, D = (r, e, t, s) => nt(e, t, s) && at(r, t, s), U = (r, e) => {
874
728
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
875
729
  }, O = (r) => {
876
730
  const e = document.createElement("div");
@@ -887,7 +741,7 @@ const et = (r, e, t) => {
887
741
  }
888
742
  ]
889
743
  };
890
- }, rt = (r, e) => {
744
+ }, ht = (r, e) => {
891
745
  let t = e;
892
746
  for (; t !== null; ) {
893
747
  const s = r.findPortIdsByElement(t)[0] ?? null;
@@ -906,21 +760,21 @@ const et = (r, e, t) => {
906
760
  status: "notFound"
907
761
  };
908
762
  };
909
- function* be(r, e) {
763
+ function* Pe(r, e) {
910
764
  const t = r.elementsFromPoint(e.x, e.y);
911
765
  for (const s of t) {
912
766
  if (s.shadowRoot !== null) {
913
- const o = be(s.shadowRoot, e);
767
+ const o = Pe(s.shadowRoot, e);
914
768
  for (const n of o)
915
769
  yield n;
916
770
  }
917
771
  yield s;
918
772
  }
919
773
  }
920
- const Pe = (r, e) => {
921
- const t = be(document, e);
774
+ const Ce = (r, e) => {
775
+ const t = Pe(document, e);
922
776
  for (const s of t) {
923
- const o = rt(r, s);
777
+ const o = ht(r, s);
924
778
  if (o.status === "portFound")
925
779
  return o.portId;
926
780
  if (o.status === "nodeEncountered")
@@ -932,7 +786,7 @@ var N = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "
932
786
  const Ne = (r, e) => ({
933
787
  x: r / 2,
934
788
  y: e / 2
935
- }), p = {
789
+ }), w = {
936
790
  x: 0,
937
791
  y: 0
938
792
  }, m = (r, e, t) => ({
@@ -954,11 +808,11 @@ const Ne = (r, e) => ({
954
808
  flipX: d,
955
809
  flipY: c
956
810
  };
957
- }, k = (r, e, t, s) => ({
811
+ }, z = (r, e, t, s) => ({
958
812
  x: e * r.x + (1 - e) / 2 * s.x,
959
813
  y: t * r.y + (1 - t) / 2 * s.y
960
814
  });
961
- class st {
815
+ class dt {
962
816
  constructor(e) {
963
817
  i(this, "path");
964
818
  i(this, "midpoint");
@@ -966,9 +820,9 @@ class st {
966
820
  const t = this.params.to;
967
821
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
968
822
  const s = m(
969
- { x: this.params.arrowLength, y: p.y },
823
+ { x: this.params.arrowLength, y: w.y },
970
824
  this.params.sourceDirection,
971
- p
825
+ w
972
826
  ), o = m(
973
827
  { x: this.params.to.x - this.params.arrowLength, y: this.params.to.y },
974
828
  this.params.targetDirection,
@@ -979,20 +833,20 @@ class st {
979
833
  }, a = {
980
834
  x: o.x - this.params.targetDirection.x * this.params.curvature,
981
835
  y: o.y - this.params.targetDirection.y * this.params.curvature
982
- }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${p.x} ${p.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
836
+ }, h = `M ${s.x} ${s.y} C ${n.x} ${n.y}, ${a.x} ${a.y}, ${o.x} ${o.y}`, d = this.params.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${s.x} ${s.y} `, c = this.params.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${this.params.to.x} ${this.params.to.y}`;
983
837
  this.path = `${d}${h}${c}`;
984
838
  }
985
839
  }
986
- class ot {
840
+ class ct {
987
841
  constructor(e) {
988
842
  i(this, "path");
989
843
  i(this, "midpoint");
990
844
  this.params = e;
991
845
  const t = this.params.hasSourceArrow ? m(
992
- { x: this.params.arrowLength, y: p.y },
846
+ { x: this.params.arrowLength, y: w.y },
993
847
  this.params.sourceDirection,
994
- p
995
- ) : p, s = this.params.hasTargetArrow ? m(
848
+ w
849
+ ) : w, s = this.params.hasTargetArrow ? m(
996
850
  {
997
851
  x: this.params.to.x - this.params.arrowLength,
998
852
  y: this.params.to.y
@@ -1000,9 +854,9 @@ class ot {
1000
854
  this.params.targetDirection,
1001
855
  this.params.to
1002
856
  ) : this.params.to, o = this.params.arrowLength, n = Math.cos(this.params.detourDirection) * this.params.detourDistance, a = Math.sin(this.params.detourDirection) * this.params.detourDistance, h = n * this.params.flipX, d = a * this.params.flipY, c = m(
1003
- { x: o, y: p.y },
857
+ { x: o, y: w.y },
1004
858
  this.params.sourceDirection,
1005
- p
859
+ w
1006
860
  ), g = {
1007
861
  x: c.x + h,
1008
862
  y: c.y + d
@@ -1013,16 +867,16 @@ class ot {
1013
867
  ), u = {
1014
868
  x: l.x + h,
1015
869
  y: l.y + d
1016
- }, w = {
870
+ }, p = {
1017
871
  x: (g.x + u.x) / 2,
1018
872
  y: (g.y + u.y) / 2
1019
- }, f = {
873
+ }, y = {
1020
874
  x: c.x + this.params.curvature * this.params.sourceDirection.x,
1021
875
  y: c.y + this.params.curvature * this.params.sourceDirection.y
1022
876
  }, v = {
1023
877
  x: l.x - this.params.curvature * this.params.targetDirection.x,
1024
878
  y: l.y - this.params.curvature * this.params.targetDirection.y
1025
- }, S = {
879
+ }, x = {
1026
880
  x: c.x + h,
1027
881
  y: c.y + d
1028
882
  }, b = {
@@ -1032,27 +886,27 @@ class ot {
1032
886
  this.path = [
1033
887
  `M ${t.x} ${t.y}`,
1034
888
  `L ${c.x} ${c.y}`,
1035
- `C ${f.x} ${f.y} ${S.x} ${S.y} ${w.x} ${w.y}`,
889
+ `C ${y.x} ${y.y} ${x.x} ${x.y} ${p.x} ${p.y}`,
1036
890
  `C ${b.x} ${b.y} ${v.x} ${v.y} ${l.x} ${l.y}`,
1037
891
  `L ${s.x} ${s.y}`
1038
- ].join(" "), this.midpoint = k(w, e.flipX, e.flipY, e.to);
892
+ ].join(" "), this.midpoint = z(p, e.flipX, e.flipY, e.to);
1039
893
  }
1040
894
  }
1041
- const J = Object.freeze({
895
+ const Z = Object.freeze({
1042
896
  edgeColor: "--edge-color"
1043
- }), Ce = (r) => {
897
+ }), Me = (r) => {
1044
898
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1045
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(J.edgeColor, r), e;
1046
- }, Me = (r) => {
899
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(Z.edgeColor, r), e;
900
+ }, Re = (r) => {
1047
901
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1048
- return e.setAttribute("stroke", `var(${J.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
902
+ return e.setAttribute("stroke", `var(${Z.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
1049
903
  }, W = () => {
1050
904
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
1051
- return r.setAttribute("fill", `var(${J.edgeColor})`), r;
905
+ return r.setAttribute("fill", `var(${Z.edgeColor})`), r;
1052
906
  }, De = () => {
1053
907
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1054
908
  return r.style.transformOrigin = "50% 50%", r;
1055
- }, Re = (r, e) => {
909
+ }, Le = (r, e) => {
1056
910
  r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${Math.max(e.width, 1)}px`, r.style.height = `${Math.max(e.height, 1)}px`;
1057
911
  }, M = (r, e) => {
1058
912
  const t = [];
@@ -1061,20 +915,20 @@ const J = Object.freeze({
1061
915
  let o = 0, n = 0, a = 0;
1062
916
  r.forEach((h, d) => {
1063
917
  let c = 0, g = 0, l = 0;
1064
- const u = d > 0, w = d < s, f = u && w;
1065
- if (u && (c = -o, g = -n, l = a), w) {
918
+ const u = d > 0, p = d < s, y = u && p;
919
+ if (u && (c = -o, g = -n, l = a), p) {
1066
920
  const V = r[d + 1];
1067
921
  o = V.x - h.x, n = V.y - h.y, a = Math.sqrt(o * o + n * n);
1068
922
  }
1069
- const S = a !== 0 ? Math.min((f ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = f ? { x: h.x + o * S, y: h.y + n * S } : h, P = l !== 0 ? Math.min((f ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, L = f ? { x: h.x + c * P, y: h.y + g * P } : h;
1070
- d > 0 && t.push(`L ${L.x} ${L.y}`), f && t.push(
923
+ const x = a !== 0 ? Math.min((y ? e : 0) / a, d < s - 1 ? 0.5 : 1) : 0, b = y ? { x: h.x + o * x, y: h.y + n * x } : h, C = l !== 0 ? Math.min((y ? e : 0) / l, d > 1 ? 0.5 : 1) : 0, L = y ? { x: h.x + c * C, y: h.y + g * C } : h;
924
+ d > 0 && t.push(`L ${L.x} ${L.y}`), y && t.push(
1071
925
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${b.x} ${b.y}`
1072
926
  );
1073
927
  });
1074
928
  }
1075
929
  return t.join(" ");
1076
930
  };
1077
- class it {
931
+ class lt {
1078
932
  constructor(e) {
1079
933
  i(this, "path");
1080
934
  i(this, "midpoint");
@@ -1082,10 +936,10 @@ class it {
1082
936
  const t = this.params.to;
1083
937
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1084
938
  const s = this.params.hasSourceArrow ? m(
1085
- { x: this.params.arrowLength, y: p.y },
939
+ { x: this.params.arrowLength, y: w.y },
1086
940
  this.params.sourceDirection,
1087
- p
1088
- ) : p, o = this.params.hasTargetArrow ? m(
941
+ w
942
+ ) : w, o = this.params.hasTargetArrow ? m(
1089
943
  {
1090
944
  x: this.params.to.x - this.params.arrowLength,
1091
945
  y: this.params.to.y
@@ -1093,9 +947,9 @@ class it {
1093
947
  this.params.targetDirection,
1094
948
  this.params.to
1095
949
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1096
- { x: a, y: p.y },
950
+ { x: a, y: w.y },
1097
951
  this.params.sourceDirection,
1098
- p
952
+ w
1099
953
  ), d = m(
1100
954
  { x: this.params.to.x - a, y: this.params.to.y },
1101
955
  this.params.targetDirection,
@@ -1103,26 +957,26 @@ class it {
1103
957
  ), c = Math.max((h.x + d.x) / 2, n), g = this.params.to.y / 2, l = {
1104
958
  x: this.params.flipX > 0 ? c : -n,
1105
959
  y: h.y
1106
- }, u = { x: l.x, y: g }, w = {
960
+ }, u = { x: l.x, y: g }, p = {
1107
961
  x: this.params.flipX > 0 ? this.params.to.x - c : this.params.to.x + n,
1108
962
  y: d.y
1109
- }, f = { x: w.x, y: g };
963
+ }, y = { x: p.x, y: g };
1110
964
  this.path = M(
1111
- [s, h, l, u, f, w, d, o],
965
+ [s, h, l, u, y, p, d, o],
1112
966
  this.params.roundness
1113
967
  );
1114
968
  }
1115
969
  }
1116
- class nt {
970
+ class gt {
1117
971
  constructor(e) {
1118
972
  i(this, "path");
1119
973
  i(this, "midpoint");
1120
974
  this.params = e;
1121
975
  const t = this.params.hasSourceArrow ? m(
1122
- { x: this.params.arrowLength, y: p.y },
976
+ { x: this.params.arrowLength, y: w.y },
1123
977
  this.params.sourceDirection,
1124
- p
1125
- ) : p, s = this.params.hasTargetArrow ? m(
978
+ w
979
+ ) : w, s = this.params.hasTargetArrow ? m(
1126
980
  {
1127
981
  x: this.params.to.x - this.params.arrowLength,
1128
982
  y: this.params.to.y
@@ -1130,21 +984,21 @@ class nt {
1130
984
  this.params.targetDirection,
1131
985
  this.params.to
1132
986
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1133
- { x: o, y: p.y },
987
+ { x: o, y: w.y },
1134
988
  this.params.sourceDirection,
1135
- p
989
+ w
1136
990
  ), a = Math.cos(this.params.detourDirection) * this.params.detourDistance, h = Math.sin(this.params.detourDirection) * this.params.detourDistance, d = a * this.params.flipX, c = h * this.params.flipY, g = { x: n.x + d, y: n.y + c }, l = m(
1137
991
  { x: this.params.to.x - o, y: this.params.to.y },
1138
992
  this.params.targetDirection,
1139
993
  this.params.to
1140
- ), u = { x: l.x + d, y: l.y + c }, w = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
1141
- this.midpoint = k(w, e.flipX, e.flipY, e.to), this.path = M(
994
+ ), u = { x: l.x + d, y: l.y + c }, p = { x: (g.x + u.x) / 2, y: (g.y + u.y) / 2 };
995
+ this.midpoint = z(p, e.flipX, e.flipY, e.to), this.path = M(
1142
996
  [t, n, g, u, l, s],
1143
997
  this.params.roundness
1144
998
  );
1145
999
  }
1146
1000
  }
1147
- class at {
1001
+ class ut {
1148
1002
  constructor(e) {
1149
1003
  i(this, "path");
1150
1004
  i(this, "midpoint");
@@ -1152,10 +1006,10 @@ class at {
1152
1006
  const t = this.params.to;
1153
1007
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1154
1008
  const s = this.params.hasSourceArrow ? m(
1155
- { x: this.params.arrowLength, y: p.y },
1009
+ { x: this.params.arrowLength, y: w.y },
1156
1010
  this.params.sourceDirection,
1157
- p
1158
- ) : p, o = this.params.hasTargetArrow ? m(
1011
+ w
1012
+ ) : w, o = this.params.hasTargetArrow ? m(
1159
1013
  {
1160
1014
  x: this.params.to.x - this.params.arrowLength,
1161
1015
  y: this.params.to.y
@@ -1163,9 +1017,9 @@ class at {
1163
1017
  this.params.targetDirection,
1164
1018
  this.params.to
1165
1019
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = m(
1166
- { x: n, y: p.y },
1020
+ { x: n, y: w.y },
1167
1021
  this.params.sourceDirection,
1168
- p
1022
+ w
1169
1023
  ), h = m(
1170
1024
  { x: this.params.to.x - n, y: this.params.to.y },
1171
1025
  this.params.targetDirection,
@@ -1174,7 +1028,7 @@ class at {
1174
1028
  this.path = M([s, a, h, o], this.params.roundness);
1175
1029
  }
1176
1030
  }
1177
- class ht {
1031
+ class pt {
1178
1032
  constructor(e) {
1179
1033
  i(this, "path");
1180
1034
  i(this, "midpoint");
@@ -1182,10 +1036,10 @@ class ht {
1182
1036
  const t = this.params.to;
1183
1037
  this.midpoint = { x: t.x / 2, y: t.y / 2 };
1184
1038
  const s = this.params.hasSourceArrow ? m(
1185
- { x: this.params.arrowLength, y: p.y },
1039
+ { x: this.params.arrowLength, y: w.y },
1186
1040
  this.params.sourceDirection,
1187
- p
1188
- ) : p, o = this.params.hasTargetArrow ? m(
1041
+ w
1042
+ ) : w, o = this.params.hasTargetArrow ? m(
1189
1043
  {
1190
1044
  x: this.params.to.x - this.params.arrowLength,
1191
1045
  y: this.params.to.y
@@ -1193,9 +1047,9 @@ class ht {
1193
1047
  this.params.targetDirection,
1194
1048
  this.params.to
1195
1049
  ) : this.params.to, n = this.params.arrowLength + this.params.arrowOffset, a = n - this.params.roundness, h = m(
1196
- { x: a, y: p.y },
1050
+ { x: a, y: w.y },
1197
1051
  this.params.sourceDirection,
1198
- p
1052
+ w
1199
1053
  ), d = m(
1200
1054
  { x: this.params.to.x - a, y: this.params.to.y },
1201
1055
  this.params.targetDirection,
@@ -1203,58 +1057,58 @@ class ht {
1203
1057
  ), c = Math.max((h.y + d.y) / 2, n), g = this.params.to.x / 2, l = {
1204
1058
  x: h.x,
1205
1059
  y: this.params.flipY > 0 ? c : -n
1206
- }, u = { x: g, y: l.y }, w = {
1060
+ }, u = { x: g, y: l.y }, p = {
1207
1061
  x: d.x,
1208
1062
  y: this.params.flipY > 0 ? this.params.to.y - c : this.params.to.y + n
1209
- }, f = { x: g, y: w.y };
1063
+ }, y = { x: g, y: p.y };
1210
1064
  this.path = M(
1211
- [s, h, l, u, f, w, d, o],
1065
+ [s, h, l, u, y, p, d, o],
1212
1066
  this.params.roundness
1213
1067
  );
1214
1068
  }
1215
1069
  }
1216
- class _ {
1070
+ class J {
1217
1071
  constructor(e) {
1218
1072
  i(this, "path");
1219
1073
  i(this, "midpoint");
1220
1074
  this.params = e;
1221
1075
  const t = this.params.arrowOffset, s = this.params.side, o = this.params.arrowLength + t, n = o + 2 * s, h = [
1222
- { x: this.params.arrowLength, y: p.y },
1223
- { x: o, y: p.y },
1076
+ { x: this.params.arrowLength, y: w.y },
1077
+ { x: o, y: w.y },
1224
1078
  { x: o, y: this.params.side },
1225
1079
  { x: n, y: this.params.side },
1226
1080
  { x: n, y: -this.params.side },
1227
1081
  { x: o, y: -this.params.side },
1228
- { x: o, y: p.y },
1229
- { x: this.params.arrowLength, y: p.y }
1082
+ { x: o, y: w.y },
1083
+ { x: this.params.arrowLength, y: w.y }
1230
1084
  ].map(
1231
- (c) => m(c, this.params.sourceDirection, p)
1232
- ), d = `M ${p.x} ${p.y} L ${h[0].x} ${h[0].y} `;
1085
+ (c) => m(c, this.params.sourceDirection, w)
1086
+ ), d = `M ${w.x} ${w.y} L ${h[0].x} ${h[0].y} `;
1233
1087
  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 };
1234
1088
  }
1235
1089
  }
1236
- class dt {
1090
+ class wt {
1237
1091
  constructor(e) {
1238
1092
  i(this, "path");
1239
1093
  i(this, "midpoint");
1240
1094
  this.params = e;
1241
1095
  const t = this.params.smallRadius, s = this.params.radius, o = t + s, n = t * s / o, a = Math.sqrt(o * o - t * t), h = a * t / o, d = a + s + this.params.arrowLength, c = this.params.arrowLength + h, l = [
1242
- { x: this.params.arrowLength, y: p.y },
1096
+ { x: this.params.arrowLength, y: w.y },
1243
1097
  { x: c, y: n },
1244
1098
  { x: c, y: -n },
1245
1099
  { x: d, y: 0 }
1246
1100
  ].map(
1247
- (f) => m(f, this.params.sourceDirection, p)
1101
+ (y) => m(y, this.params.sourceDirection, w)
1248
1102
  ), u = [
1249
1103
  `M ${l[0].x} ${l[0].y}`,
1250
1104
  `A ${t} ${t} 0 0 1 ${l[1].x} ${l[1].y}`,
1251
1105
  `A ${s} ${s} 0 1 0 ${l[2].x} ${l[2].y}`,
1252
1106
  `A ${t} ${t} 0 0 1 ${l[0].x} ${l[0].y}`
1253
- ].join(" "), w = `M 0 0 L ${l[0].x} ${l[0].y} `;
1254
- this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : w}${u}`, this.midpoint = l[3];
1107
+ ].join(" "), p = `M 0 0 L ${l[0].x} ${l[0].y} `;
1108
+ this.path = `${this.params.hasSourceArrow || this.params.hasTargetArrow ? "" : p}${u}`, this.midpoint = l[3];
1255
1109
  }
1256
1110
  }
1257
- class ct {
1111
+ class yt {
1258
1112
  constructor(e) {
1259
1113
  i(this, "path");
1260
1114
  i(this, "midpoint");
@@ -1273,7 +1127,7 @@ class ct {
1273
1127
  offset: this.params.sourceOffset,
1274
1128
  hasArrow: this.params.hasSourceArrow,
1275
1129
  flip: 1,
1276
- shift: p
1130
+ shift: w
1277
1131
  }), n = this.createDirectLinePoint({
1278
1132
  offset: this.params.targetOffset,
1279
1133
  hasArrow: this.params.hasTargetArrow,
@@ -1290,16 +1144,16 @@ class ct {
1290
1144
  };
1291
1145
  }
1292
1146
  }
1293
- class lt {
1147
+ class ft {
1294
1148
  constructor(e) {
1295
1149
  i(this, "path");
1296
1150
  i(this, "midpoint");
1297
1151
  this.params = e;
1298
1152
  const t = this.params.hasSourceArrow ? m(
1299
- { x: this.params.arrowLength, y: p.y },
1153
+ { x: this.params.arrowLength, y: w.y },
1300
1154
  this.params.sourceDirection,
1301
- p
1302
- ) : p, s = this.params.hasTargetArrow ? m(
1155
+ w
1156
+ ) : w, s = this.params.hasTargetArrow ? m(
1303
1157
  {
1304
1158
  x: this.params.to.x - this.params.arrowLength,
1305
1159
  y: this.params.to.y
@@ -1307,9 +1161,9 @@ class lt {
1307
1161
  this.params.targetDirection,
1308
1162
  this.params.to
1309
1163
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1310
- { x: o, y: p.y },
1164
+ { x: o, y: w.y },
1311
1165
  this.params.sourceDirection,
1312
- p
1166
+ w
1313
1167
  ), a = m(
1314
1168
  { x: this.params.to.x - o, y: this.params.to.y },
1315
1169
  this.params.targetDirection,
@@ -1318,7 +1172,7 @@ class lt {
1318
1172
  x: (n.x + a.x) / 2,
1319
1173
  y: g
1320
1174
  };
1321
- this.midpoint = k(l, e.flipX, e.flipY, e.to), this.path = M(
1175
+ this.midpoint = z(l, e.flipX, e.flipY, e.to), this.path = M(
1322
1176
  [
1323
1177
  t,
1324
1178
  n,
@@ -1331,16 +1185,16 @@ class lt {
1331
1185
  );
1332
1186
  }
1333
1187
  }
1334
- class gt {
1188
+ class mt {
1335
1189
  constructor(e) {
1336
1190
  i(this, "path");
1337
1191
  i(this, "midpoint");
1338
1192
  this.params = e;
1339
1193
  const t = this.params.hasSourceArrow ? m(
1340
- { x: this.params.arrowLength, y: p.y },
1194
+ { x: this.params.arrowLength, y: w.y },
1341
1195
  this.params.sourceDirection,
1342
- p
1343
- ) : p, s = this.params.hasTargetArrow ? m(
1196
+ w
1197
+ ) : w, s = this.params.hasTargetArrow ? m(
1344
1198
  {
1345
1199
  x: this.params.to.x - this.params.arrowLength,
1346
1200
  y: this.params.to.y
@@ -1348,9 +1202,9 @@ class gt {
1348
1202
  this.params.targetDirection,
1349
1203
  this.params.to
1350
1204
  ) : this.params.to, o = this.params.arrowLength + this.params.arrowOffset, n = m(
1351
- { x: o, y: p.y },
1205
+ { x: o, y: w.y },
1352
1206
  this.params.sourceDirection,
1353
- p
1207
+ w
1354
1208
  ), a = m(
1355
1209
  { x: this.params.to.x - o, y: this.params.to.y },
1356
1210
  this.params.targetDirection,
@@ -1359,7 +1213,7 @@ class gt {
1359
1213
  x: g,
1360
1214
  y: (n.y + a.y) / 2
1361
1215
  };
1362
- this.midpoint = k(l, e.flipX, e.flipY, e.to), this.path = M(
1216
+ this.midpoint = z(l, e.flipX, e.flipY, e.to), this.path = M(
1363
1217
  [
1364
1218
  t,
1365
1219
  n,
@@ -1372,7 +1226,7 @@ class gt {
1372
1226
  );
1373
1227
  }
1374
1228
  }
1375
- const y = Object.freeze({
1229
+ const f = Object.freeze({
1376
1230
  color: "#777777",
1377
1231
  width: 1,
1378
1232
  arrowLength: 20,
@@ -1394,8 +1248,8 @@ const y = Object.freeze({
1394
1248
  curvature: 90,
1395
1249
  interactiveWidth: 10,
1396
1250
  preOffset: 0
1397
- }), we = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1398
- class H {
1251
+ }), ye = (r, e, t) => ({ x: e * Math.cos(r), y: t * Math.sin(r) });
1252
+ class k {
1399
1253
  constructor(e) {
1400
1254
  i(this, "svg");
1401
1255
  i(this, "group", De());
@@ -1405,19 +1259,19 @@ class H {
1405
1259
  i(this, "onAfterRender");
1406
1260
  i(this, "afterRenderEmitter");
1407
1261
  i(this, "arrowRenderer");
1408
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = E(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ce(e.color), this.svg.appendChild(this.group), this.line = Me(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1262
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = S(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Me(e.color), this.svg.appendChild(this.group), this.line = Re(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1409
1263
  }
1410
1264
  render(e) {
1411
1265
  const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = Te(
1412
1266
  e.from,
1413
1267
  e.to
1414
1268
  );
1415
- Re(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1416
- const d = we(
1269
+ Le(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1270
+ const d = ye(
1417
1271
  e.from.direction,
1418
1272
  a,
1419
1273
  h
1420
- ), c = we(
1274
+ ), c = ye(
1421
1275
  e.to.direction,
1422
1276
  a,
1423
1277
  h
@@ -1426,54 +1280,54 @@ class H {
1426
1280
  y: n
1427
1281
  };
1428
1282
  let l = { x: -c.x, y: -c.y }, u;
1429
- e.category === D.PortCycle ? (u = this.params.createCyclePath, l = d) : e.category === D.NodeCycle ? u = this.params.createDetourPath : u = this.params.createLinePath;
1430
- const w = u(
1283
+ e.category === R.PortCycle ? (u = this.params.createCyclePath, l = d) : e.category === R.NodeCycle ? u = this.params.createDetourPath : u = this.params.createLinePath;
1284
+ const p = u(
1431
1285
  d,
1432
1286
  c,
1433
1287
  g,
1434
1288
  a,
1435
1289
  h
1436
1290
  );
1437
- this.line.setAttribute("d", w.path);
1438
- let f = null;
1439
- this.sourceArrow && (f = this.arrowRenderer({
1291
+ this.line.setAttribute("d", p.path);
1292
+ let y = null;
1293
+ this.sourceArrow && (y = this.arrowRenderer({
1440
1294
  direction: d,
1441
- shift: p,
1295
+ shift: w,
1442
1296
  arrowLength: this.params.arrowLength
1443
- }), this.sourceArrow.setAttribute("d", f));
1297
+ }), this.sourceArrow.setAttribute("d", y));
1444
1298
  let v = null;
1445
1299
  this.targetArrow && (v = this.arrowRenderer({
1446
1300
  direction: l,
1447
1301
  shift: g,
1448
1302
  arrowLength: this.params.arrowLength
1449
1303
  }), this.targetArrow.setAttribute("d", v)), this.afterRenderEmitter.emit({
1450
- edgePath: w,
1451
- sourceArrowPath: f,
1304
+ edgePath: p,
1305
+ sourceArrowPath: y,
1452
1306
  targetArrowPath: v
1453
1307
  });
1454
1308
  }
1455
1309
  }
1456
- const ut = (r) => (e) => {
1310
+ const vt = (r) => (e) => {
1457
1311
  const s = [
1458
- p,
1312
+ w,
1459
1313
  { x: e.arrowLength, y: r.radius },
1460
1314
  { x: e.arrowLength, y: -r.radius }
1461
1315
  ].map(
1462
- (h) => m(h, e.direction, p)
1316
+ (h) => m(h, e.direction, w)
1463
1317
  ).map((h) => ({
1464
1318
  x: h.x + e.shift.x,
1465
1319
  y: h.y + e.shift.y
1466
1320
  })), o = `M ${s[0].x} ${s[0].y}`, n = `L ${s[1].x} ${s[1].y}`, a = `L ${s[2].x} ${s[2].y}`;
1467
1321
  return `${o} ${n} ${a} Z`;
1468
- }, pt = (r) => (e) => {
1469
- const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [p, { x: a, y: -h }, { x: a, y: h }].map(
1470
- (f) => m(f, e.direction, p)
1471
- ).map((f) => ({
1472
- x: f.x + e.shift.x,
1473
- y: f.y + e.shift.y
1474
- })), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
1475
- return `${g} ${l} ${u} ${w}`;
1476
- }, wt = (r) => (e) => {
1322
+ }, At = (r) => (e) => {
1323
+ const t = r.radius, s = e.arrowLength, o = (s * s + 2 * s * t) / (2 * t), n = o + t, a = s + t - t * (s + t) / n, h = t * o / n, c = [w, { x: a, y: -h }, { x: a, y: h }].map(
1324
+ (y) => m(y, e.direction, w)
1325
+ ).map((y) => ({
1326
+ x: y.x + e.shift.x,
1327
+ y: y.y + e.shift.y
1328
+ })), g = `M ${c[0].x} ${c[0].y}`, l = `A ${o} ${o} 0 0 0 ${c[1].x} ${c[1].y}`, u = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, p = `A ${o} ${o} 0 0 0 ${c[0].x} ${c[0].y}`;
1329
+ return `${g} ${l} ${u} ${p}`;
1330
+ }, xt = (r) => (e) => {
1477
1331
  const t = r.smallRadius, s = r.radius, o = m(
1478
1332
  {
1479
1333
  x: e.arrowLength,
@@ -1487,8 +1341,8 @@ const ut = (r) => (e) => {
1487
1341
  x: e.arrowLength + r.smallRadius,
1488
1342
  y: 0
1489
1343
  }
1490
- ), a = [p, { x: o.x, y: -o.y }, o].map(
1491
- (l) => m(l, e.direction, p)
1344
+ ), a = [w, { x: o.x, y: -o.y }, o].map(
1345
+ (l) => m(l, e.direction, w)
1492
1346
  ).map((l) => ({
1493
1347
  x: l.x + e.shift.x,
1494
1348
  y: l.y + e.shift.y
@@ -1499,22 +1353,22 @@ const ut = (r) => (e) => {
1499
1353
  return r;
1500
1354
  switch (r.type) {
1501
1355
  case "triangle":
1502
- return ut({
1503
- radius: r.radius ?? y.polygonArrowRadius
1356
+ return vt({
1357
+ radius: r.radius ?? f.polygonArrowRadius
1504
1358
  });
1505
1359
  case "arc":
1506
- return pt({
1507
- radius: r.radius ?? y.circleArrowRadius
1360
+ return At({
1361
+ radius: r.radius ?? f.circleArrowRadius
1508
1362
  });
1509
1363
  default:
1510
- return wt({
1511
- smallRadius: r.smallRadius ?? y.wedgeArrowSmallRadius,
1512
- angle: r.angle ?? y.wedgeArrowAngle,
1513
- radius: r.radius ?? y.wedgeArrowRadius
1364
+ return xt({
1365
+ smallRadius: r.smallRadius ?? f.wedgeArrowSmallRadius,
1366
+ angle: r.angle ?? f.wedgeArrowAngle,
1367
+ radius: r.radius ?? f.wedgeArrowRadius
1514
1368
  });
1515
1369
  }
1516
1370
  };
1517
- class ft {
1371
+ class Et {
1518
1372
  constructor(e) {
1519
1373
  i(this, "svg");
1520
1374
  i(this, "group");
@@ -1531,7 +1385,7 @@ class ft {
1531
1385
  i(this, "hasSourceArrow");
1532
1386
  i(this, "hasTargetArrow");
1533
1387
  i(this, "pathShape");
1534
- i(this, "createCyclePath", (e) => new dt({
1388
+ i(this, "createCyclePath", (e) => new wt({
1535
1389
  sourceDirection: e,
1536
1390
  radius: this.portCycleRadius,
1537
1391
  smallRadius: this.portCycleSmallRadius,
@@ -1539,7 +1393,7 @@ class ft {
1539
1393
  hasSourceArrow: this.hasSourceArrow,
1540
1394
  hasTargetArrow: this.hasTargetArrow
1541
1395
  }));
1542
- i(this, "createDetourPath", (e, t, s, o, n) => new ot({
1396
+ i(this, "createDetourPath", (e, t, s, o, n) => new ct({
1543
1397
  to: s,
1544
1398
  sourceDirection: e,
1545
1399
  targetDirection: t,
@@ -1552,7 +1406,7 @@ class ft {
1552
1406
  hasSourceArrow: this.hasSourceArrow,
1553
1407
  hasTargetArrow: this.hasTargetArrow
1554
1408
  }));
1555
- i(this, "createLinePath", (e, t, s) => new st({
1409
+ i(this, "createLinePath", (e, t, s) => new dt({
1556
1410
  to: s,
1557
1411
  sourceDirection: e,
1558
1412
  targetDirection: t,
@@ -1561,9 +1415,9 @@ class ft {
1561
1415
  hasSourceArrow: this.hasSourceArrow,
1562
1416
  hasTargetArrow: this.hasTargetArrow
1563
1417
  }));
1564
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? y.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? y.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? y.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1565
- color: (e == null ? void 0 : e.color) ?? y.color,
1566
- width: (e == null ? void 0 : e.width) ?? y.width,
1418
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? f.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? f.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? f.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1419
+ color: (e == null ? void 0 : e.color) ?? f.color,
1420
+ width: (e == null ? void 0 : e.width) ?? f.width,
1567
1421
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
1568
1422
  arrowLength: this.arrowLength,
1569
1423
  hasSourceArrow: this.hasSourceArrow,
@@ -1577,7 +1431,7 @@ class ft {
1577
1431
  this.pathShape.render(e);
1578
1432
  }
1579
1433
  }
1580
- class yt {
1434
+ class St {
1581
1435
  constructor(e) {
1582
1436
  i(this, "svg");
1583
1437
  i(this, "group");
@@ -1593,7 +1447,7 @@ class yt {
1593
1447
  i(this, "hasSourceArrow");
1594
1448
  i(this, "hasTargetArrow");
1595
1449
  i(this, "pathShape");
1596
- i(this, "createCyclePath", (e) => new _({
1450
+ i(this, "createCyclePath", (e) => new J({
1597
1451
  sourceDirection: e,
1598
1452
  arrowLength: this.arrowLength,
1599
1453
  side: this.cycleSquareSide,
@@ -1602,7 +1456,7 @@ class yt {
1602
1456
  hasSourceArrow: this.hasSourceArrow,
1603
1457
  hasTargetArrow: this.hasTargetArrow
1604
1458
  }));
1605
- i(this, "createDetourPath", (e, t, s, o, n) => new lt({
1459
+ i(this, "createDetourPath", (e, t, s, o, n) => new ft({
1606
1460
  to: s,
1607
1461
  sourceDirection: e,
1608
1462
  targetDirection: t,
@@ -1615,7 +1469,7 @@ class yt {
1615
1469
  hasSourceArrow: this.hasSourceArrow,
1616
1470
  hasTargetArrow: this.hasTargetArrow
1617
1471
  }));
1618
- i(this, "createLinePath", (e, t, s, o) => new it({
1472
+ i(this, "createLinePath", (e, t, s, o) => new lt({
1619
1473
  to: s,
1620
1474
  sourceDirection: e,
1621
1475
  targetDirection: t,
@@ -1626,15 +1480,15 @@ class yt {
1626
1480
  hasSourceArrow: this.hasSourceArrow,
1627
1481
  hasTargetArrow: this.hasTargetArrow
1628
1482
  }));
1629
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? y.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? y.cycleSquareSide;
1630
- const t = (e == null ? void 0 : e.roundness) ?? y.roundness;
1483
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? f.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? f.cycleSquareSide;
1484
+ const t = (e == null ? void 0 : e.roundness) ?? f.roundness;
1631
1485
  this.roundness = Math.min(
1632
1486
  t,
1633
1487
  this.arrowOffset,
1634
1488
  this.cycleSquareSide / 2
1635
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1636
- color: (e == null ? void 0 : e.color) ?? y.color,
1637
- width: (e == null ? void 0 : e.width) ?? y.width,
1489
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1490
+ color: (e == null ? void 0 : e.color) ?? f.color,
1491
+ width: (e == null ? void 0 : e.width) ?? f.width,
1638
1492
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
1639
1493
  arrowLength: this.arrowLength,
1640
1494
  hasSourceArrow: this.hasSourceArrow,
@@ -1648,7 +1502,7 @@ class yt {
1648
1502
  this.pathShape.render(e);
1649
1503
  }
1650
1504
  }
1651
- class mt {
1505
+ class bt {
1652
1506
  constructor(e) {
1653
1507
  i(this, "svg");
1654
1508
  i(this, "group");
@@ -1665,7 +1519,7 @@ class mt {
1665
1519
  i(this, "hasSourceArrow");
1666
1520
  i(this, "hasTargetArrow");
1667
1521
  i(this, "pathShape");
1668
- i(this, "createCyclePath", (e) => new _({
1522
+ i(this, "createCyclePath", (e) => new J({
1669
1523
  sourceDirection: e,
1670
1524
  arrowLength: this.arrowLength,
1671
1525
  side: this.cycleSquareSide,
@@ -1674,7 +1528,7 @@ class mt {
1674
1528
  hasSourceArrow: this.hasSourceArrow,
1675
1529
  hasTargetArrow: this.hasTargetArrow
1676
1530
  }));
1677
- i(this, "createDetourPath", (e, t, s, o, n) => new nt({
1531
+ i(this, "createDetourPath", (e, t, s, o, n) => new gt({
1678
1532
  to: s,
1679
1533
  sourceDirection: e,
1680
1534
  targetDirection: t,
@@ -1688,7 +1542,7 @@ class mt {
1688
1542
  hasSourceArrow: this.hasSourceArrow,
1689
1543
  hasTargetArrow: this.hasTargetArrow
1690
1544
  }));
1691
- i(this, "createLinePath", (e, t, s) => new at({
1545
+ i(this, "createLinePath", (e, t, s) => new ut({
1692
1546
  to: s,
1693
1547
  sourceDirection: e,
1694
1548
  targetDirection: t,
@@ -1698,15 +1552,15 @@ class mt {
1698
1552
  hasSourceArrow: this.hasSourceArrow,
1699
1553
  hasTargetArrow: this.hasTargetArrow
1700
1554
  }));
1701
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? y.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? y.cycleSquareSide;
1702
- const t = (e == null ? void 0 : e.roundness) ?? y.roundness;
1555
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? f.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? f.cycleSquareSide;
1556
+ const t = (e == null ? void 0 : e.roundness) ?? f.roundness;
1703
1557
  this.roundness = Math.min(
1704
1558
  t,
1705
1559
  this.arrowOffset,
1706
1560
  this.cycleSquareSide / 2
1707
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? y.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1708
- color: (e == null ? void 0 : e.color) ?? y.color,
1709
- width: (e == null ? void 0 : e.width) ?? y.width,
1561
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? f.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1562
+ color: (e == null ? void 0 : e.color) ?? f.color,
1563
+ width: (e == null ? void 0 : e.width) ?? f.width,
1710
1564
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
1711
1565
  arrowLength: this.arrowLength,
1712
1566
  hasSourceArrow: this.hasSourceArrow,
@@ -1720,7 +1574,7 @@ class mt {
1720
1574
  this.pathShape.render(e);
1721
1575
  }
1722
1576
  }
1723
- class vt {
1577
+ class Pt {
1724
1578
  constructor(e) {
1725
1579
  i(this, "svg");
1726
1580
  i(this, "group");
@@ -1736,7 +1590,7 @@ class vt {
1736
1590
  i(this, "hasSourceArrow");
1737
1591
  i(this, "hasTargetArrow");
1738
1592
  i(this, "pathShape");
1739
- i(this, "createCyclePath", (e) => new _({
1593
+ i(this, "createCyclePath", (e) => new J({
1740
1594
  sourceDirection: e,
1741
1595
  arrowLength: this.arrowLength,
1742
1596
  side: this.cycleSquareSide,
@@ -1745,7 +1599,7 @@ class vt {
1745
1599
  hasSourceArrow: this.hasSourceArrow,
1746
1600
  hasTargetArrow: this.hasTargetArrow
1747
1601
  }));
1748
- i(this, "createDetourPath", (e, t, s, o, n) => new gt({
1602
+ i(this, "createDetourPath", (e, t, s, o, n) => new mt({
1749
1603
  to: s,
1750
1604
  sourceDirection: e,
1751
1605
  targetDirection: t,
@@ -1758,7 +1612,7 @@ class vt {
1758
1612
  hasSourceArrow: this.hasSourceArrow,
1759
1613
  hasTargetArrow: this.hasTargetArrow
1760
1614
  }));
1761
- i(this, "createLinePath", (e, t, s, o, n) => new ht({
1615
+ i(this, "createLinePath", (e, t, s, o, n) => new pt({
1762
1616
  to: s,
1763
1617
  sourceDirection: e,
1764
1618
  targetDirection: t,
@@ -1769,15 +1623,15 @@ class vt {
1769
1623
  hasSourceArrow: this.hasSourceArrow,
1770
1624
  hasTargetArrow: this.hasTargetArrow
1771
1625
  }));
1772
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? y.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? y.cycleSquareSide;
1773
- const t = (e == null ? void 0 : e.roundness) ?? y.roundness;
1626
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? f.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? f.cycleSquareSide;
1627
+ const t = (e == null ? void 0 : e.roundness) ?? f.roundness;
1774
1628
  this.roundness = Math.min(
1775
1629
  t,
1776
1630
  this.arrowOffset,
1777
1631
  this.cycleSquareSide / 2
1778
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? y.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? y.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? y.hasTargetArrow, this.pathShape = new H({
1779
- color: (e == null ? void 0 : e.color) ?? y.color,
1780
- width: (e == null ? void 0 : e.width) ?? y.width,
1632
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? f.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? f.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? f.hasTargetArrow, this.pathShape = new k({
1633
+ color: (e == null ? void 0 : e.color) ?? f.color,
1634
+ width: (e == null ? void 0 : e.width) ?? f.width,
1781
1635
  arrowRenderer: I((e == null ? void 0 : e.arrowRenderer) ?? {}),
1782
1636
  arrowLength: this.arrowLength,
1783
1637
  hasSourceArrow: this.hasSourceArrow,
@@ -1791,7 +1645,7 @@ class vt {
1791
1645
  this.pathShape.render(e);
1792
1646
  }
1793
1647
  }
1794
- class Le {
1648
+ class Ve {
1795
1649
  constructor(e) {
1796
1650
  i(this, "svg");
1797
1651
  i(this, "group", De());
@@ -1806,15 +1660,15 @@ class Le {
1806
1660
  i(this, "onAfterRender");
1807
1661
  i(this, "afterRenderEmitter");
1808
1662
  i(this, "arrowRenderer");
1809
- [this.afterRenderEmitter, this.onAfterRender] = E(), this.color = (e == null ? void 0 : e.color) ?? y.color, this.width = (e == null ? void 0 : e.width) ?? y.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? y.arrowLength, this.arrowRenderer = I((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? y.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? y.preOffset, this.svg = Ce(this.color), this.svg.appendChild(this.group), this.line = Me(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1663
+ [this.afterRenderEmitter, this.onAfterRender] = S(), this.color = (e == null ? void 0 : e.color) ?? f.color, this.width = (e == null ? void 0 : e.width) ?? f.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? f.arrowLength, this.arrowRenderer = I((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? f.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? f.preOffset, this.svg = Me(this.color), this.svg.appendChild(this.group), this.line = Re(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = W(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = W(), this.group.appendChild(this.targetArrow));
1810
1664
  }
1811
1665
  render(e) {
1812
1666
  const { x: t, y: s, width: o, height: n, flipX: a, flipY: h } = Te(
1813
1667
  e.from,
1814
1668
  e.to
1815
1669
  );
1816
- Re(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1817
- const d = { x: o, y: n }, c = new ct({
1670
+ Le(this.svg, { x: t, y: s, width: o, height: n }), this.group.style.transform = `scale(${a}, ${h})`;
1671
+ const d = { x: o, y: n }, c = new yt({
1818
1672
  to: d,
1819
1673
  sourceOffset: this.sourceOffset,
1820
1674
  targetOffset: this.targetOffset,
@@ -1828,31 +1682,31 @@ class Le {
1828
1682
  if (u === 0)
1829
1683
  this.sourceArrow !== null && (g = "", this.sourceArrow.setAttribute("d", g)), this.targetArrow !== null && (l = "", this.targetArrow.setAttribute("d", l));
1830
1684
  else {
1831
- const w = {
1685
+ const p = {
1832
1686
  x: d.x / u,
1833
1687
  y: d.y / u
1834
1688
  };
1835
1689
  if (this.sourceArrow) {
1836
- const f = {
1837
- x: w.x * this.sourceOffset,
1838
- y: w.y * this.sourceOffset
1690
+ const y = {
1691
+ x: p.x * this.sourceOffset,
1692
+ y: p.y * this.sourceOffset
1839
1693
  };
1840
1694
  g = this.arrowRenderer({
1841
- direction: w,
1842
- shift: f,
1695
+ direction: p,
1696
+ shift: y,
1843
1697
  arrowLength: this.arrowLength
1844
1698
  }), this.sourceArrow.setAttribute("d", g);
1845
1699
  }
1846
1700
  if (this.targetArrow) {
1847
- const f = {
1848
- x: w.x * this.targetOffset,
1849
- y: w.y * this.targetOffset
1701
+ const y = {
1702
+ x: p.x * this.targetOffset,
1703
+ y: p.y * this.targetOffset
1850
1704
  };
1851
1705
  l = this.arrowRenderer({
1852
- direction: { x: -w.x, y: -w.y },
1706
+ direction: { x: -p.x, y: -p.y },
1853
1707
  shift: {
1854
- x: d.x - f.x,
1855
- y: d.y - f.y
1708
+ x: d.x - y.x,
1709
+ y: d.y - y.y
1856
1710
  },
1857
1711
  arrowLength: this.arrowLength
1858
1712
  }), this.targetArrow.setAttribute("d", l);
@@ -1865,40 +1719,40 @@ class Le {
1865
1719
  });
1866
1720
  }
1867
1721
  }
1868
- const At = () => {
1722
+ const Ct = () => {
1869
1723
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1870
1724
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1871
- }, xt = (r) => {
1725
+ }, Nt = (r) => {
1872
1726
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1873
1727
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1874
1728
  }, fe = (r) => {
1875
1729
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1876
1730
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1877
1731
  };
1878
- class Et extends Error {
1732
+ class Tt extends Error {
1879
1733
  constructor(e) {
1880
1734
  super(e), this.name = "InteractiveEdgeError";
1881
1735
  }
1882
1736
  }
1883
- class Ve {
1737
+ class Fe {
1884
1738
  constructor(e, t) {
1885
1739
  i(this, "svg");
1886
1740
  i(this, "group");
1887
1741
  i(this, "line");
1888
1742
  i(this, "sourceArrow");
1889
1743
  i(this, "targetArrow");
1890
- i(this, "handle", At());
1744
+ i(this, "handle", Ct());
1891
1745
  i(this, "onAfterRender");
1892
1746
  i(this, "interactiveLine");
1893
1747
  i(this, "interactiveSourceArrow", null);
1894
1748
  i(this, "interactiveTargetArrow", null);
1895
- if (this.baseEdge = e, e instanceof Ve)
1896
- throw new Et(
1749
+ if (this.baseEdge = e, e instanceof Fe)
1750
+ throw new Tt(
1897
1751
  "interactive edge can be configured only once"
1898
1752
  );
1899
1753
  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;
1900
- const s = (t == null ? void 0 : t.distance) ?? y.interactiveWidth;
1901
- this.interactiveLine = xt(s), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = fe(s), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = fe(s), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((o) => {
1754
+ const s = (t == null ? void 0 : t.distance) ?? f.interactiveWidth;
1755
+ this.interactiveLine = Nt(s), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = fe(s), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = fe(s), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((o) => {
1902
1756
  this.interactiveLine.setAttribute("d", o.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", o.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", o.targetArrowPath);
1903
1757
  });
1904
1758
  }
@@ -1906,7 +1760,7 @@ class Ve {
1906
1760
  this.baseEdge.render(e);
1907
1761
  }
1908
1762
  }
1909
- class yr {
1763
+ class Cr {
1910
1764
  constructor(e, t) {
1911
1765
  i(this, "group");
1912
1766
  i(this, "line");
@@ -1923,7 +1777,7 @@ class yr {
1923
1777
  this.baseShape.render(e);
1924
1778
  }
1925
1779
  }
1926
- class Fe {
1780
+ class Ie {
1927
1781
  constructor(e) {
1928
1782
  i(this, "onAfterNodeAdded");
1929
1783
  i(this, "onAfterNodeUpdated");
@@ -2019,7 +1873,165 @@ class Fe {
2019
1873
  return this.graphStore.getNodeAdjacentEdgeIds(e);
2020
1874
  }
2021
1875
  }
2022
- class Ie {
1876
+ class X {
1877
+ constructor(e) {
1878
+ i(this, "counter", 0);
1879
+ this.checkExists = e;
1880
+ }
1881
+ create(e) {
1882
+ if (e !== void 0)
1883
+ return e;
1884
+ for (; this.checkExists(this.counter); )
1885
+ this.counter++;
1886
+ return this.counter;
1887
+ }
1888
+ reset() {
1889
+ this.counter = 0;
1890
+ }
1891
+ }
1892
+ class Be {
1893
+ constructor(e, t, s) {
1894
+ i(this, "nodeIdGenerator", new X(
1895
+ (e) => this.graphStore.hasNode(e)
1896
+ ));
1897
+ i(this, "portIdGenerator", new X(
1898
+ (e) => this.graphStore.hasPort(e)
1899
+ ));
1900
+ i(this, "edgeIdGenerator", new X(
1901
+ (e) => this.graphStore.hasEdge(e)
1902
+ ));
1903
+ i(this, "onAfterNodeAdded", (e) => {
1904
+ this.htmlView.attachNode(e);
1905
+ });
1906
+ i(this, "onAfterNodeUpdated", (e) => {
1907
+ this.htmlView.updateNodePosition(e), this.graphStore.getNodeAdjacentEdgeIds(e).forEach((t) => {
1908
+ this.htmlView.renderEdge(t);
1909
+ });
1910
+ });
1911
+ i(this, "onAfterNodePriorityUpdated", (e) => {
1912
+ this.htmlView.updateNodePriority(e);
1913
+ });
1914
+ i(this, "onBeforeNodeRemoved", (e) => {
1915
+ this.graphStore.getNodePortIds(e).forEach((t) => {
1916
+ this.unmarkPort(t);
1917
+ }), this.htmlView.detachNode(e);
1918
+ });
1919
+ i(this, "onAfterPortUpdated", (e) => {
1920
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
1921
+ this.htmlView.renderEdge(t);
1922
+ });
1923
+ });
1924
+ i(this, "onBeforePortUnmarked", (e) => {
1925
+ this.graphStore.getPortAdjacentEdgeIds(e).forEach((t) => {
1926
+ this.removeEdge(t);
1927
+ });
1928
+ });
1929
+ i(this, "onAfterEdgeAdded", (e) => {
1930
+ this.htmlView.attachEdge(e);
1931
+ });
1932
+ i(this, "onAfterEdgeShapeUpdated", (e) => {
1933
+ this.htmlView.updateEdgeShape(e);
1934
+ });
1935
+ i(this, "onAfterEdgeUpdated", (e) => {
1936
+ this.htmlView.renderEdge(e);
1937
+ });
1938
+ i(this, "onAfterEdgePriorityUpdated", (e) => {
1939
+ this.htmlView.updateEdgePriority(e);
1940
+ });
1941
+ i(this, "onBeforeEdgeRemoved", (e) => {
1942
+ this.htmlView.detachEdge(e);
1943
+ });
1944
+ i(this, "onBeforeClear", () => {
1945
+ this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.htmlView.clear();
1946
+ });
1947
+ this.graphStore = e, this.htmlView = t, this.params = s, this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1948
+ this.onAfterNodePriorityUpdated
1949
+ ), 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(
1950
+ this.onAfterEdgeShapeUpdated
1951
+ ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
1952
+ this.onAfterEdgePriorityUpdated
1953
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear);
1954
+ }
1955
+ addNode(e) {
1956
+ const t = this.nodeIdGenerator.create(e.id);
1957
+ if (this.graphStore.addNode({
1958
+ id: t,
1959
+ element: e.element,
1960
+ x: e.x ?? null,
1961
+ y: e.y ?? null,
1962
+ centerFn: e.centerFn ?? this.params.nodes.centerFn,
1963
+ priority: e.priority ?? this.params.nodes.priorityFn()
1964
+ }), e.ports !== void 0)
1965
+ for (const s of e.ports)
1966
+ this.markPort({
1967
+ id: s.id,
1968
+ element: s.element,
1969
+ nodeId: t,
1970
+ direction: s.direction
1971
+ });
1972
+ }
1973
+ updateNode(e, t) {
1974
+ this.graphStore.updateNode(e, t ?? {});
1975
+ }
1976
+ removeNode(e) {
1977
+ this.graphStore.removeNode(e);
1978
+ }
1979
+ markPort(e) {
1980
+ const t = this.portIdGenerator.create(e.id);
1981
+ this.graphStore.addPort({
1982
+ id: t,
1983
+ element: e.element,
1984
+ nodeId: e.nodeId,
1985
+ direction: e.direction ?? this.params.ports.direction
1986
+ });
1987
+ }
1988
+ updatePort(e, t) {
1989
+ this.graphStore.updatePort(e, t ?? {});
1990
+ }
1991
+ unmarkPort(e) {
1992
+ this.graphStore.removePort(e);
1993
+ }
1994
+ addEdge(e) {
1995
+ const t = this.edgeIdGenerator.create(e.id);
1996
+ this.graphStore.addEdge({
1997
+ id: t,
1998
+ from: e.from,
1999
+ to: e.to,
2000
+ shape: e.shape ?? this.params.edges.shapeFactory(t),
2001
+ priority: e.priority ?? this.params.edges.priorityFn()
2002
+ });
2003
+ }
2004
+ updateEdge(e, t) {
2005
+ this.graphStore.updateEdge(e, t ?? {});
2006
+ }
2007
+ removeEdge(e) {
2008
+ this.graphStore.removeEdge(e);
2009
+ }
2010
+ clear() {
2011
+ this.graphStore.clear();
2012
+ }
2013
+ destroy() {
2014
+ this.graphStore.onAfterNodeAdded.unsubscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.unsubscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.unsubscribe(
2015
+ this.onAfterNodePriorityUpdated
2016
+ ), this.graphStore.onBeforeNodeRemoved.unsubscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.unsubscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.unsubscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.unsubscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.unsubscribe(
2017
+ this.onAfterEdgeShapeUpdated
2018
+ ), this.graphStore.onAfterEdgeUpdated.unsubscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.unsubscribe(
2019
+ this.onAfterEdgePriorityUpdated
2020
+ ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
2021
+ }
2022
+ }
2023
+ const Mt = (r) => {
2024
+ setTimeout(() => {
2025
+ r();
2026
+ });
2027
+ }, Rt = (r) => {
2028
+ queueMicrotask(() => {
2029
+ r();
2030
+ });
2031
+ }, _ = (r) => {
2032
+ r();
2033
+ };
2034
+ class $e {
2023
2035
  constructor(e) {
2024
2036
  i(this, "onBeforeUpdated");
2025
2037
  i(this, "onAfterUpdated");
@@ -2042,30 +2054,109 @@ class Ie {
2042
2054
  return this.viewportStore.createViewportCoords(e);
2043
2055
  }
2044
2056
  }
2045
- const Be = (r, e) => {
2046
- const t = new Se(), s = new Fe(t), o = new Ie(e), n = new xe(t, e, r), a = {
2057
+ const Dt = (r, e) => Symbol.iterator in r ? {
2058
+ minContentScale: e.focus.minContentScale,
2059
+ nodes: r,
2060
+ contentOffset: e.focus.contentOffset
2061
+ } : {
2062
+ minContentScale: r.minContentScale ?? e.focus.minContentScale,
2063
+ nodes: r.nodes ?? [],
2064
+ contentOffset: r.contentOffset ?? e.focus.contentOffset
2065
+ }, Ue = (r, e, t) => ({
2066
+ scale: r.scale,
2067
+ x: r.x + r.scale * e,
2068
+ y: r.y + r.scale * t
2069
+ }), Oe = (r, e, t, s) => ({
2070
+ scale: r.scale * e,
2071
+ x: r.scale * (1 - e) * t + r.x,
2072
+ y: r.scale * (1 - e) * s + r.y
2073
+ });
2074
+ class We {
2075
+ constructor(e, t, s) {
2076
+ this.graphStore = e, this.viewportStore = t, this.params = s;
2077
+ }
2078
+ patchViewportMatrix(e) {
2079
+ this.viewportStore.patchViewportMatrix(e);
2080
+ }
2081
+ patchContentMatrix(e) {
2082
+ this.viewportStore.patchContentMatrix(e);
2083
+ }
2084
+ center(e, t) {
2085
+ const { width: s, height: o } = this.viewportStore.getDimensions(), n = { x: s / 2, y: o / 2 }, a = this.viewportStore.getViewportMatrix(), h = this.viewportStore.createViewportCoords(e), d = h.x - n.x, c = h.y - n.y;
2086
+ let g = Ue(a, d, c);
2087
+ const l = t == null ? void 0 : t.contentScale;
2088
+ if (l !== void 0) {
2089
+ const u = 1 / l;
2090
+ g = Oe(
2091
+ g,
2092
+ u / a.scale,
2093
+ n.x,
2094
+ n.y
2095
+ );
2096
+ }
2097
+ this.viewportStore.patchViewportMatrix(g);
2098
+ }
2099
+ focus(e) {
2100
+ const t = Dt(e ?? {}, this.params);
2101
+ this.params.focus.schedule(() => {
2102
+ this.navigate(t);
2103
+ });
2104
+ }
2105
+ destroy() {
2106
+ this.viewportStore.destroy();
2107
+ }
2108
+ navigate(e) {
2109
+ let t = 1 / 0, s = -1 / 0, o = 1 / 0, n = -1 / 0, a = 0;
2110
+ const h = /* @__PURE__ */ new Set();
2111
+ for (const d of e.nodes)
2112
+ h.add(d);
2113
+ if (this.graphStore.getAllNodeIds().forEach((d) => {
2114
+ const { payload: c } = this.graphStore.getNode(d);
2115
+ c.x !== null && c.y !== null && (h.size === 0 || h.has(d)) && (t = Math.min(c.x, t), s = Math.max(c.x, s), o = Math.min(c.y, o), n = Math.max(c.y, n), a++);
2116
+ }), a > 0) {
2117
+ t -= e.contentOffset, o -= e.contentOffset, s += e.contentOffset, n += e.contentOffset;
2118
+ const d = {
2119
+ x: (t + s) / 2,
2120
+ y: (o + n) / 2
2121
+ }, c = (s - t) / 2, g = (n - o) / 2, { width: l, height: u } = this.viewportStore.getDimensions(), p = l / 2, y = u / 2, v = Math.max(
2122
+ c / p,
2123
+ g / y
2124
+ ), { scale: x } = this.viewportStore.getContentMatrix(), b = v > 1 ? x / v : x, P = Math.max(b, e.minContentScale);
2125
+ this.center(d, { contentScale: P });
2126
+ }
2127
+ }
2128
+ }
2129
+ const ze = (r, e) => {
2130
+ const t = new be(), s = new Ie(t), o = new $e(e), n = new Ee(t, e, r), a = {
2047
2131
  nodes: {
2048
2132
  centerFn: Ne,
2049
2133
  priorityFn: () => 0
2050
2134
  },
2051
2135
  edges: {
2052
- shapeFactory: () => new Le(),
2136
+ shapeFactory: () => new Ve(),
2053
2137
  priorityFn: () => 0
2054
2138
  },
2055
2139
  ports: {
2056
2140
  direction: 0
2057
2141
  }
2058
- };
2059
- return new Ee(
2060
- s,
2061
- o,
2142
+ }, h = new Be(
2062
2143
  t,
2063
- e,
2064
2144
  n,
2065
2145
  a
2146
+ ), d = {
2147
+ focus: {
2148
+ contentOffset: 0,
2149
+ minContentScale: 0,
2150
+ schedule: _
2151
+ }
2152
+ }, c = new We(
2153
+ t,
2154
+ e,
2155
+ d
2066
2156
  );
2157
+ return new Se(s, o, h, c);
2067
2158
  };
2068
- class Y {
2159
+ class H {
2069
2160
  constructor(e, t, s, o) {
2070
2161
  i(this, "onAfterPortMarked", (e) => {
2071
2162
  const t = this.canvas.graph.getPort(e);
@@ -2090,7 +2181,7 @@ class Y {
2090
2181
  }));
2091
2182
  });
2092
2183
  i(this, "onWindowMouseMove", (e) => {
2093
- if (!R(
2184
+ if (!D(
2094
2185
  this.window,
2095
2186
  this.element,
2096
2187
  e.clientX,
@@ -2122,7 +2213,7 @@ class Y {
2122
2213
  });
2123
2214
  i(this, "onWindowTouchMove", (e) => {
2124
2215
  const t = e.touches[0];
2125
- if (!R(
2216
+ if (!D(
2126
2217
  this.window,
2127
2218
  this.element,
2128
2219
  t.clientX,
@@ -2137,19 +2228,19 @@ class Y {
2137
2228
  const t = e.changedTouches[0];
2138
2229
  this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
2139
2230
  });
2140
- i(this, "onBeforeClear", () => {
2231
+ i(this, "reset", () => {
2141
2232
  this.canvas.graph.getAllPortIds().forEach((e) => {
2142
2233
  const t = this.canvas.graph.getPort(e);
2143
2234
  this.unhookPortEvents(t.element);
2144
2235
  });
2145
2236
  });
2146
- i(this, "onBeforeDestroy", () => {
2147
- this.params.onStopDrag(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
2237
+ i(this, "revert", () => {
2238
+ this.params.onStopDrag(), this.reset(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
2148
2239
  });
2149
- this.canvas = e, this.element = t, this.window = s, this.params = o, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2240
+ this.canvas = e, this.element = t, this.window = s, this.params = o, this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.revert);
2150
2241
  }
2151
2242
  static configure(e, t, s, o) {
2152
- new Y(e, t, s, o);
2243
+ new H(e, t, s, o);
2153
2244
  }
2154
2245
  hookPortEvents(e) {
2155
2246
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -2174,7 +2265,7 @@ class Y {
2174
2265
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2175
2266
  }
2176
2267
  }
2177
- class St {
2268
+ class Lt {
2178
2269
  constructor(e, t, s) {
2179
2270
  this.canvas = e, this.layoutAlgorithm = t, this.params = s;
2180
2271
  }
@@ -2188,7 +2279,7 @@ class St {
2188
2279
  }), this.params.onAfterApplied();
2189
2280
  }
2190
2281
  }
2191
- class bt {
2282
+ class Vt {
2192
2283
  constructor(e, t, s) {
2193
2284
  this.canvas = e, this.layoutAlgorithm = t, this.params = s;
2194
2285
  }
@@ -2224,15 +2315,6 @@ class ee {
2224
2315
  const { element: t } = this.graph.getNode(e);
2225
2316
  t.removeEventListener("mousedown", this.onMouseDown), t.removeEventListener("touchstart", this.onTouchStart);
2226
2317
  });
2227
- i(this, "onBeforeDestroy", () => {
2228
- this.removeMouseDragListeners(), this.removeTouchDragListeners();
2229
- });
2230
- i(this, "onBeforeClear", () => {
2231
- this.canvas.graph.getAllNodeIds().forEach((e) => {
2232
- const { element: t } = this.canvas.graph.getNode(e);
2233
- t.removeEventListener("mousedown", this.onMouseDown), t.removeEventListener("touchstart", this.onTouchStart);
2234
- }), this.maxNodePriority = 0;
2235
- });
2236
2318
  i(this, "onMouseDown", (e) => {
2237
2319
  const t = e;
2238
2320
  if (!this.params.mouseDownEventVerifier(t))
@@ -2285,7 +2367,7 @@ class ee {
2285
2367
  });
2286
2368
  });
2287
2369
  i(this, "onWindowMouseMove", (e) => {
2288
- if (!R(
2370
+ if (!D(
2289
2371
  this.window,
2290
2372
  this.element,
2291
2373
  e.clientX,
@@ -2306,7 +2388,7 @@ class ee {
2306
2388
  if (e.touches.length !== 1)
2307
2389
  return;
2308
2390
  const t = e.touches[0];
2309
- if (!R(
2391
+ if (!D(
2310
2392
  this.window,
2311
2393
  this.element,
2312
2394
  t.clientX,
@@ -2323,7 +2405,16 @@ class ee {
2323
2405
  i(this, "onWindowTouchFinish", () => {
2324
2406
  this.cancelTouchDrag();
2325
2407
  });
2326
- this.canvas = e, this.element = t, this.window = s, this.params = o, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2408
+ i(this, "reset", () => {
2409
+ this.canvas.graph.getAllNodeIds().forEach((e) => {
2410
+ const { element: t } = this.canvas.graph.getNode(e);
2411
+ t.removeEventListener("mousedown", this.onMouseDown), t.removeEventListener("touchstart", this.onTouchStart);
2412
+ }), this.maxNodePriority = 0;
2413
+ });
2414
+ i(this, "revert", () => {
2415
+ this.reset(), this.removeMouseDragListeners(), this.removeTouchDragListeners();
2416
+ });
2417
+ this.canvas = e, this.element = t, this.window = s, this.params = o, this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.revert);
2327
2418
  }
2328
2419
  static configure(e, t, s, o) {
2329
2420
  new ee(e, t, s, o);
@@ -2395,15 +2486,7 @@ class ee {
2395
2486
  return e;
2396
2487
  }
2397
2488
  }
2398
- const Pt = (r, e, t) => ({
2399
- scale: r.scale,
2400
- x: r.x + r.scale * e,
2401
- y: r.y + r.scale * t
2402
- }), Nt = (r, e, t, s) => ({
2403
- scale: r.scale * e,
2404
- x: r.scale * (1 - e) * t + r.x,
2405
- y: r.scale * (1 - e) * s + r.y
2406
- }), B = (r) => {
2489
+ const B = (r) => {
2407
2490
  const e = [], t = r.touches.length;
2408
2491
  for (let h = 0; h < t; h++)
2409
2492
  e.push([r.touches[h].clientX, r.touches[h].clientY]);
@@ -2422,13 +2505,13 @@ const Pt = (r, e, t) => ({
2422
2505
  touches: e
2423
2506
  };
2424
2507
  };
2425
- class X {
2508
+ class Y {
2426
2509
  constructor(e, t, s, o) {
2427
2510
  i(this, "viewport");
2428
2511
  i(this, "prevTouches", null);
2429
2512
  i(this, "wheelFinishTimer", null);
2430
2513
  i(this, "transformInProgress", !1);
2431
- i(this, "onBeforeDestroy", () => {
2514
+ i(this, "revert", () => {
2432
2515
  this.removeMouseDragListeners(), this.removeTouchDragListeners();
2433
2516
  });
2434
2517
  i(this, "onMouseDown", (e) => {
@@ -2439,7 +2522,7 @@ class X {
2439
2522
  }), this.startRegisteredTransform());
2440
2523
  });
2441
2524
  i(this, "onWindowMouseMove", (e) => {
2442
- const t = R(
2525
+ const t = D(
2443
2526
  this.window,
2444
2527
  this.element,
2445
2528
  e.clientX,
@@ -2479,7 +2562,7 @@ class X {
2479
2562
  i(this, "onWindowTouchMove", (e) => {
2480
2563
  const t = B(e);
2481
2564
  if (!t.touches.every(
2482
- (o) => R(this.window, this.element, o[0], o[1])
2565
+ (o) => D(this.window, this.element, o[0], o[1])
2483
2566
  )) {
2484
2567
  this.stopTouchDrag();
2485
2568
  return;
@@ -2509,13 +2592,13 @@ class X {
2509
2592
  passive: !0
2510
2593
  }), this.element.addEventListener("touchstart", this.onTouchStart, {
2511
2594
  passive: !0
2512
- }), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2595
+ }), e.onBeforeDestroy.subscribe(this.revert);
2513
2596
  }
2514
2597
  static configure(e, t, s, o) {
2515
- new X(e, t, s, o);
2598
+ new Y(e, t, s, o);
2516
2599
  }
2517
2600
  moveViewport(e, t) {
2518
- const s = this.viewport.getViewportMatrix(), o = Pt(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2601
+ const s = this.viewport.getViewportMatrix(), o = Ue(s, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2519
2602
  prevTransform: s,
2520
2603
  nextTransform: o,
2521
2604
  canvasWidth: n,
@@ -2524,7 +2607,7 @@ class X {
2524
2607
  this.performTransform(h);
2525
2608
  }
2526
2609
  scaleViewport(e, t, s) {
2527
- const o = this.canvas.viewport.getViewportMatrix(), n = Nt(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2610
+ const o = this.canvas.viewport.getViewportMatrix(), n = Oe(o, e, t, s), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2528
2611
  prevTransform: o,
2529
2612
  nextTransform: n,
2530
2613
  canvasWidth: a,
@@ -2610,7 +2693,7 @@ class te {
2610
2693
  this.scheduleLoadAreaAroundViewport(), o.onTransformFinished();
2611
2694
  }
2612
2695
  };
2613
- X.configure(
2696
+ Y.configure(
2614
2697
  e,
2615
2698
  this.element,
2616
2699
  this.window,
@@ -2648,13 +2731,13 @@ class te {
2648
2731
  });
2649
2732
  }
2650
2733
  }
2651
- const Tt = () => {
2734
+ const Ft = () => {
2652
2735
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2653
2736
  return r.style.position = "absolute", r.style.inset = "0", r;
2654
- }, Ct = () => {
2737
+ }, It = () => {
2655
2738
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2656
2739
  return r.setAttribute("fill", "url(#pattern)"), r;
2657
- }, Mt = () => {
2740
+ }, Bt = () => {
2658
2741
  const r = document.createElementNS(
2659
2742
  "http://www.w3.org/2000/svg",
2660
2743
  "pattern"
@@ -2663,9 +2746,9 @@ const Tt = () => {
2663
2746
  };
2664
2747
  class re {
2665
2748
  constructor(e, t, s) {
2666
- i(this, "svg", Tt());
2667
- i(this, "patternRenderingRectangle", Ct());
2668
- i(this, "pattern", Mt());
2749
+ i(this, "svg", Ft());
2750
+ i(this, "patternRenderingRectangle", It());
2751
+ i(this, "pattern", Bt());
2669
2752
  i(this, "patternContent");
2670
2753
  i(this, "tileWidth");
2671
2754
  i(this, "tileHeight");
@@ -2707,10 +2790,10 @@ class se {
2707
2790
  i(this, "onEdgeCreated", (e) => {
2708
2791
  this.params.onAfterEdgeCreated(e);
2709
2792
  });
2710
- this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Be(
2793
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = ze(
2711
2794
  this.overlayLayer,
2712
2795
  this.viewportStore
2713
- ), Y.configure(
2796
+ ), H.configure(
2714
2797
  this.canvas,
2715
2798
  this.overlayLayer,
2716
2799
  this.window,
@@ -2761,10 +2844,10 @@ class se {
2761
2844
  portDirection: this.params.dragPortDirection
2762
2845
  };
2763
2846
  this.isTargetDragging = s === "direct";
2764
- const [w, f] = this.isTargetDragging ? [l, u] : [u, l];
2765
- this.overlayCanvas.addNode(O(w)), this.overlayCanvas.addNode(O(f)), this.overlayCanvas.addEdge({
2766
- from: w.overlayNodeId,
2767
- to: f.overlayNodeId,
2847
+ const [p, y] = this.isTargetDragging ? [l, u] : [u, l];
2848
+ this.overlayCanvas.addNode(O(p)), this.overlayCanvas.addNode(O(y)), this.overlayCanvas.addEdge({
2849
+ from: p.overlayNodeId,
2850
+ to: y.overlayNodeId,
2768
2851
  shape: this.params.edgeShapeFactory(N.EdgeId)
2769
2852
  });
2770
2853
  }
@@ -2772,7 +2855,7 @@ class se {
2772
2855
  this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
2773
2856
  }
2774
2857
  tryCreateConnection(e) {
2775
- const t = Pe(this.canvas.graph, e), s = this.staticPortId;
2858
+ const t = Ce(this.canvas.graph, e), s = this.staticPortId;
2776
2859
  if (t === null) {
2777
2860
  this.params.onEdgeCreationInterrupted({
2778
2861
  staticPortId: s,
@@ -2803,10 +2886,10 @@ class oe {
2803
2886
  i(this, "onEdgeReattached", (e) => {
2804
2887
  this.params.onAfterEdgeReattached(e);
2805
2888
  });
2806
- this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = Be(
2889
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = s, this.window = o, this.params = n, this.overlayCanvas = ze(
2807
2890
  this.overlayLayer,
2808
2891
  this.viewportStore
2809
- ), Y.configure(
2892
+ ), H.configure(
2810
2893
  this.canvas,
2811
2894
  this.overlayLayer,
2812
2895
  this.window,
@@ -2844,10 +2927,10 @@ class oe {
2844
2927
  const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), g = c.element.getBoundingClientRect(), l = {
2845
2928
  x: g.x + g.width / 2,
2846
2929
  y: g.y + g.height / 2
2847
- }, u = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
2930
+ }, u = this.overlayLayer.getBoundingClientRect(), p = this.canvas.viewport.createContentCoords({
2848
2931
  x: l.x - u.x,
2849
2932
  y: l.y - u.y
2850
- }), f = this.canvas.viewport.createContentCoords({
2933
+ }), y = this.canvas.viewport.createContentCoords({
2851
2934
  x: t.x - u.x,
2852
2935
  y: t.y - u.y
2853
2936
  });
@@ -2860,20 +2943,20 @@ class oe {
2860
2943
  }, this.canvas.removeEdge(s);
2861
2944
  const v = {
2862
2945
  overlayNodeId: N.StaticNodeId,
2863
- portCoords: w,
2946
+ portCoords: p,
2864
2947
  portDirection: c.direction
2865
- }, S = {
2948
+ }, x = {
2866
2949
  overlayNodeId: N.DraggingNodeId,
2867
- portCoords: f,
2950
+ portCoords: y,
2868
2951
  portDirection: d.direction
2869
- }, [b, T] = this.isTargetDragging ? [v, S] : [S, v];
2870
- this.overlayCanvas.addNode(O(b)), this.overlayCanvas.addNode(O(T));
2871
- const P = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(N.EdgeId) : o.shape;
2952
+ }, [b, P] = this.isTargetDragging ? [v, x] : [x, v];
2953
+ this.overlayCanvas.addNode(O(b)), this.overlayCanvas.addNode(O(P));
2954
+ const C = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(N.EdgeId) : o.shape;
2872
2955
  return this.overlayCanvas.addEdge({
2873
2956
  id: N.EdgeId,
2874
2957
  from: b.overlayNodeId,
2875
- to: T.overlayNodeId,
2876
- shape: P
2958
+ to: P.overlayNodeId,
2959
+ shape: C
2877
2960
  }), !0;
2878
2961
  }
2879
2962
  resetDragState() {
@@ -2890,7 +2973,7 @@ class oe {
2890
2973
  });
2891
2974
  }
2892
2975
  tryCreateConnection(e) {
2893
- const t = Pe(this.canvas.graph, e);
2976
+ const t = Ce(this.canvas.graph, e);
2894
2977
  if (this.overlayCanvas.removeEdge(N.EdgeId), t === null) {
2895
2978
  const d = this.draggingEdgePayload;
2896
2979
  this.params.onEdgeReattachInterrupted({
@@ -2933,7 +3016,7 @@ class ie {
2933
3016
  new ie(e, t);
2934
3017
  }
2935
3018
  }
2936
- class z {
3019
+ class ne {
2937
3020
  constructor(e, t, s) {
2938
3021
  i(this, "applyScheduled", !1);
2939
3022
  i(this, "apply", () => {
@@ -2950,7 +3033,7 @@ class z {
2950
3033
  });
2951
3034
  }
2952
3035
  static configure(e, t, s) {
2953
- new z(
3036
+ new ne(
2954
3037
  e,
2955
3038
  t,
2956
3039
  s
@@ -2960,49 +3043,33 @@ class z {
2960
3043
  this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
2961
3044
  }
2962
3045
  }
2963
- class Dt {
3046
+ class $t {
2964
3047
  static configure(e, t) {
2965
- const s = t.applyOn, o = new St(e, t.algorithm, {
3048
+ const s = t.applyOn, o = new Lt(e, t.algorithm, {
2966
3049
  staticNodeResolver: t.staticNodeResolver,
2967
3050
  onBeforeApplied: t.onBeforeApplied,
2968
3051
  onAfterApplied: t.onAfterApplied
2969
3052
  });
2970
3053
  switch (s.type) {
2971
- case "manual": {
3054
+ case "trigger": {
2972
3055
  ie.configure(
2973
3056
  o,
2974
3057
  s.trigger
2975
3058
  );
2976
3059
  break;
2977
3060
  }
2978
- case "topologyChangeMacrotask": {
2979
- z.configure(
2980
- e.graph,
2981
- o,
2982
- (n) => {
2983
- setTimeout(() => {
2984
- n();
2985
- });
2986
- }
2987
- );
2988
- break;
2989
- }
2990
- case "topologyChangeMicrotask": {
2991
- z.configure(
3061
+ case "topologyChangeSchedule": {
3062
+ ne.configure(
2992
3063
  e.graph,
2993
3064
  o,
2994
- (n) => {
2995
- queueMicrotask(() => {
2996
- n();
2997
- });
2998
- }
3065
+ s.schedule
2999
3066
  );
3000
3067
  break;
3001
3068
  }
3002
3069
  }
3003
3070
  }
3004
3071
  }
3005
- class Rt {
3072
+ class Ut {
3006
3073
  constructor(e, t) {
3007
3074
  i(this, "previousTimeStamp");
3008
3075
  i(this, "step", (e) => {
@@ -3017,150 +3084,51 @@ class Rt {
3017
3084
  this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
3018
3085
  }
3019
3086
  }
3020
- class ne {
3087
+ class ae {
3021
3088
  constructor(e, t, s) {
3022
3089
  i(this, "applier");
3023
3090
  i(this, "step", (e) => {
3024
3091
  this.applier.apply(e);
3025
3092
  });
3026
- this.win = s, this.applier = new bt(e, t.algorithm, {
3093
+ this.win = s, this.applier = new Vt(e, t.algorithm, {
3027
3094
  staticNodeResolver: t.staticNodeResolver,
3028
3095
  onBeforeApplied: t.onBeforeApplied,
3029
3096
  onAfterApplied: t.onAfterApplied
3030
- }), new Rt(this.win, this.step);
3097
+ }), new Ut(this.win, this.step);
3031
3098
  }
3032
3099
  static configure(e, t, s) {
3033
- new ne(e, t, s);
3100
+ new ae(e, t, s);
3034
3101
  }
3035
3102
  }
3036
- const Lt = () => {
3103
+ const Ot = () => {
3037
3104
  const r = document.createElement("div");
3038
3105
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
3039
- }, q = () => {
3106
+ }, j = () => {
3040
3107
  const r = document.createElement("div");
3041
3108
  return r.style.position = "absolute", r.style.inset = "0", r;
3042
- }, ye = () => {
3043
- const r = q();
3109
+ }, me = () => {
3110
+ const r = j();
3044
3111
  return r.style.pointerEvents = "none", r;
3045
3112
  };
3046
- class Vt {
3113
+ class Wt {
3047
3114
  constructor(e) {
3048
- i(this, "background", q());
3049
- i(this, "main", q());
3050
- i(this, "overlayConnectablePorts", ye());
3051
- i(this, "overlayDraggableEdges", ye());
3052
- i(this, "host", Lt());
3115
+ i(this, "background", j());
3116
+ i(this, "main", j());
3117
+ i(this, "overlayConnectablePorts", me());
3118
+ i(this, "overlayDraggableEdges", me());
3119
+ i(this, "host", Ot());
3053
3120
  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);
3054
3121
  }
3055
3122
  destroy() {
3056
3123
  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);
3057
3124
  }
3058
3125
  }
3059
- const K = (r) => () => r, me = K(0), Ft = () => {
3060
- let r = 0;
3061
- return () => r++;
3062
- }, It = (r, e) => {
3063
- let t = me, s = me;
3064
- const o = Ft();
3065
- return r === "incremental" && (t = o), e === "incremental" && (s = o), typeof r == "number" && (t = K(r)), typeof e == "number" && (s = K(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
3066
- nodesPriorityFn: t,
3067
- edgesPriorityFn: s
3068
- };
3069
- }, ae = (r) => {
3070
- if (typeof r == "function")
3071
- return r;
3072
- switch (r.type) {
3073
- case "straight":
3074
- return () => new mt({
3075
- color: r.color,
3076
- width: r.width,
3077
- arrowLength: r.arrowLength,
3078
- arrowOffset: r.arrowOffset,
3079
- arrowRenderer: r.arrowRenderer,
3080
- hasSourceArrow: r.hasSourceArrow,
3081
- hasTargetArrow: r.hasTargetArrow,
3082
- cycleSquareSide: r.cycleSquareSide,
3083
- roundness: r.roundness,
3084
- detourDistance: r.detourDistance,
3085
- detourDirection: r.detourDirection
3086
- });
3087
- case "horizontal":
3088
- return () => new yt({
3089
- color: r.color,
3090
- width: r.width,
3091
- arrowLength: r.arrowLength,
3092
- arrowOffset: r.arrowOffset,
3093
- arrowRenderer: r.arrowRenderer,
3094
- hasSourceArrow: r.hasSourceArrow,
3095
- hasTargetArrow: r.hasTargetArrow,
3096
- cycleSquareSide: r.cycleSquareSide,
3097
- roundness: r.roundness,
3098
- detourDistance: r.detourDistance
3099
- });
3100
- case "vertical":
3101
- return () => new vt({
3102
- color: r.color,
3103
- width: r.width,
3104
- arrowLength: r.arrowLength,
3105
- arrowOffset: r.arrowOffset,
3106
- arrowRenderer: r.arrowRenderer,
3107
- hasSourceArrow: r.hasSourceArrow,
3108
- hasTargetArrow: r.hasTargetArrow,
3109
- cycleSquareSide: r.cycleSquareSide,
3110
- roundness: r.roundness,
3111
- detourDistance: r.detourDistance
3112
- });
3113
- case "direct":
3114
- return () => new Le({
3115
- color: r.color,
3116
- width: r.width,
3117
- arrowLength: r.arrowLength,
3118
- arrowRenderer: r.arrowRenderer,
3119
- hasSourceArrow: r.hasSourceArrow,
3120
- hasTargetArrow: r.hasTargetArrow,
3121
- sourceOffset: r.sourceOffset,
3122
- targetOffset: r.targetOffset
3123
- });
3124
- default:
3125
- return () => new ft({
3126
- color: r.color,
3127
- width: r.width,
3128
- arrowLength: r.arrowLength,
3129
- arrowRenderer: r.arrowRenderer,
3130
- hasSourceArrow: r.hasSourceArrow,
3131
- hasTargetArrow: r.hasTargetArrow,
3132
- cycleRadius: r.cycleRadius,
3133
- smallCycleRadius: r.smallCycleRadius,
3134
- curvature: r.curvature,
3135
- detourDistance: r.detourDistance,
3136
- detourDirection: r.detourDirection
3137
- });
3138
- }
3139
- }, Bt = (r) => {
3140
- var t, s, o, n, a;
3141
- const e = It(
3142
- (t = r.nodes) == null ? void 0 : t.priority,
3143
- (s = r.edges) == null ? void 0 : s.priority
3144
- );
3145
- return {
3146
- nodes: {
3147
- centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Ne,
3148
- priorityFn: e.nodesPriorityFn
3149
- },
3150
- ports: {
3151
- direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
3152
- },
3153
- edges: {
3154
- shapeFactory: ae(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
3155
- priorityFn: e.edgesPriorityFn
3156
- }
3157
- };
3158
- }, $t = (r) => {
3159
- var w, f, v, S, b, T;
3160
- const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3161
- }), t = ((f = r.events) == null ? void 0 : f.onNodeDrag) ?? (() => {
3126
+ const zt = (r) => {
3127
+ var p, y, v, x, b, P;
3128
+ const e = ((p = r.events) == null ? void 0 : p.onNodeDragStarted) ?? (() => {
3129
+ }), t = ((y = r.events) == null ? void 0 : y.onNodeDrag) ?? (() => {
3162
3130
  }), s = r.nodeDragVerifier ?? (() => !0), o = ((v = r.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
3163
- }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (S = r.mouse) == null ? void 0 : S.dragCursor, d = h !== void 0 ? h : "grab", c = (b = r.mouse) == null ? void 0 : b.mouseDownEventVerifier, g = c !== void 0 ? c : (P) => P.button === 0, l = (T = r.mouse) == null ? void 0 : T.mouseUpEventVerifier, u = l !== void 0 ? l : (P) => P.button === 0;
3131
+ }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (x = r.mouse) == null ? void 0 : x.dragCursor, d = h !== void 0 ? h : "grab", c = (b = r.mouse) == null ? void 0 : b.mouseDownEventVerifier, g = c !== void 0 ? c : (C) => C.button === 0, l = (P = r.mouse) == null ? void 0 : P.mouseUpEventVerifier, u = l !== void 0 ? l : (C) => C.button === 0;
3164
3132
  return {
3165
3133
  moveOnTop: n,
3166
3134
  moveEdgesOnTop: a,
@@ -3173,7 +3141,7 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3173
3141
  nodeDragVerifier: s,
3174
3142
  onNodeDragFinished: o
3175
3143
  };
3176
- }, Ut = (r) => {
3144
+ }, kt = (r) => {
3177
3145
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, s = r.minY !== null ? r.minY : -1 / 0, o = r.maxY !== null ? r.maxY : 1 / 0;
3178
3146
  return (n) => {
3179
3147
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -3183,7 +3151,7 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3183
3151
  const g = n.canvasHeight * n.prevTransform.scale, l = o - g;
3184
3152
  return h > l && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, l)), { scale: n.nextTransform.scale, x: a, y: h };
3185
3153
  };
3186
- }, Ot = (r) => {
3154
+ }, Ht = (r) => {
3187
3155
  const e = r.maxContentScale, t = r.minContentScale, s = e !== null ? 1 / e : 0, o = t !== null ? 1 / t : 1 / 0;
3188
3156
  return (n) => {
3189
3157
  const a = n.prevTransform, h = n.nextTransform;
@@ -3204,7 +3172,7 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3204
3172
  y: g
3205
3173
  };
3206
3174
  };
3207
- }, Wt = (r) => (e) => r.reduce(
3175
+ }, Yt = (r) => (e) => r.reduce(
3208
3176
  (t, s) => s({
3209
3177
  prevTransform: e.prevTransform,
3210
3178
  nextTransform: t,
@@ -3217,12 +3185,12 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3217
3185
  return r;
3218
3186
  switch (r.type) {
3219
3187
  case "scale-limit":
3220
- return Ot({
3188
+ return Ht({
3221
3189
  minContentScale: r.minContentScale ?? 0,
3222
3190
  maxContentScale: r.maxContentScale ?? 1 / 0
3223
3191
  });
3224
3192
  case "shift-limit":
3225
- return Ut({
3193
+ return kt({
3226
3194
  minX: r.minX ?? -1 / 0,
3227
3195
  maxX: r.maxX ?? 1 / 0,
3228
3196
  minY: r.minY ?? -1 / 0,
@@ -3230,22 +3198,22 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3230
3198
  });
3231
3199
  }
3232
3200
  }, Ae = (r) => {
3233
- var f, v, S, b, T, P, L, V, he, de, ce, le;
3234
- const e = (f = r == null ? void 0 : r.scale) == null ? void 0 : f.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
3201
+ var y, v, x, b, P, C, L, V, de, ce, le, ge;
3202
+ const e = (y = r == null ? void 0 : r.scale) == null ? void 0 : y.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, s = r == null ? void 0 : r.transformPreprocessor;
3235
3203
  let o;
3236
- s !== void 0 ? Array.isArray(s) ? o = Wt(
3204
+ s !== void 0 ? Array.isArray(s) ? o = Yt(
3237
3205
  s.map(
3238
- (C) => ve(C)
3206
+ (T) => ve(T)
3239
3207
  )
3240
- ) : o = ve(s) : o = (C) => C.nextTransform;
3241
- const n = ((v = r == null ? void 0 : r.shift) == null ? void 0 : v.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((S = r == null ? void 0 : r.events) == null ? void 0 : S.onBeforeTransformChange) ?? (() => {
3208
+ ) : o = ve(s) : o = (T) => T.nextTransform;
3209
+ 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) ?? (() => {
3242
3210
  }), h = ((b = r == null ? void 0 : r.events) == null ? void 0 : b.onTransformChange) ?? (() => {
3243
- }), d = (T = r == null ? void 0 : r.shift) == null ? void 0 : T.mouseDownEventVerifier, c = d !== void 0 ? d : (C) => C.button === 0, g = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseUpEventVerifier, l = g !== void 0 ? g : (C) => C.button === 0, u = (L = r == null ? void 0 : r.scale) == null ? void 0 : L.mouseWheelEventVerifier, w = u !== void 0 ? u : () => !0;
3211
+ }), d = (P = r == null ? void 0 : r.shift) == null ? void 0 : P.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, g = (C = r == null ? void 0 : r.shift) == null ? void 0 : C.mouseUpEventVerifier, l = g !== void 0 ? g : (T) => T.button === 0, u = (L = r == null ? void 0 : r.scale) == null ? void 0 : L.mouseWheelEventVerifier, p = u !== void 0 ? u : () => !0;
3244
3212
  return {
3245
3213
  wheelSensitivity: t,
3246
3214
  onTransformStarted: ((V = r == null ? void 0 : r.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
3247
3215
  }),
3248
- onTransformFinished: ((he = r == null ? void 0 : r.events) == null ? void 0 : he.onTransformFinished) ?? (() => {
3216
+ onTransformFinished: ((de = r == null ? void 0 : r.events) == null ? void 0 : de.onTransformFinished) ?? (() => {
3249
3217
  }),
3250
3218
  onBeforeTransformChange: a,
3251
3219
  onTransformChange: h,
@@ -3253,31 +3221,101 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3253
3221
  shiftCursor: n,
3254
3222
  mouseDownEventVerifier: c,
3255
3223
  mouseUpEventVerifier: l,
3256
- mouseWheelEventVerifier: w,
3257
- scaleWheelFinishTimeout: ((de = r == null ? void 0 : r.scale) == null ? void 0 : de.wheelFinishTimeout) ?? 500,
3258
- onResizeTransformStarted: ((ce = r == null ? void 0 : r.events) == null ? void 0 : ce.onResizeTransformStarted) ?? (() => {
3224
+ mouseWheelEventVerifier: p,
3225
+ scaleWheelFinishTimeout: ((ce = r == null ? void 0 : r.scale) == null ? void 0 : ce.wheelFinishTimeout) ?? 500,
3226
+ onResizeTransformStarted: ((le = r == null ? void 0 : r.events) == null ? void 0 : le.onResizeTransformStarted) ?? (() => {
3259
3227
  }),
3260
- onResizeTransformFinished: ((le = r == null ? void 0 : r.events) == null ? void 0 : le.onResizeTransformFinished) ?? (() => {
3228
+ onResizeTransformFinished: ((ge = r == null ? void 0 : r.events) == null ? void 0 : ge.onResizeTransformFinished) ?? (() => {
3261
3229
  })
3262
3230
  };
3263
- }, zt = (r, e) => {
3231
+ }, Xt = (r, e) => {
3264
3232
  const t = document.createElementNS(
3265
3233
  "http://www.w3.org/2000/svg",
3266
3234
  "circle"
3267
3235
  );
3268
3236
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
3269
- }, kt = (r) => r instanceof SVGElement ? r : zt(
3237
+ }, Gt = (r) => r instanceof SVGElement ? r : Xt(
3270
3238
  (r == null ? void 0 : r.radius) ?? 1.5,
3271
3239
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
3272
- ), Ht = (r) => {
3273
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, o = kt(r.renderer ?? {});
3240
+ ), jt = (r) => {
3241
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, s = (e == null ? void 0 : e.height) ?? 25, o = Gt(r.renderer ?? {});
3274
3242
  return {
3275
3243
  tileWidth: t,
3276
3244
  tileHeight: s,
3277
3245
  renderer: o,
3278
3246
  maxViewportScale: r.maxViewportScale ?? 10
3279
3247
  };
3280
- }, Yt = (r, e, t) => {
3248
+ }, he = (r) => {
3249
+ if (typeof r == "function")
3250
+ return r;
3251
+ switch (r.type) {
3252
+ case "straight":
3253
+ return () => new bt({
3254
+ color: r.color,
3255
+ width: r.width,
3256
+ arrowLength: r.arrowLength,
3257
+ arrowOffset: r.arrowOffset,
3258
+ arrowRenderer: r.arrowRenderer,
3259
+ hasSourceArrow: r.hasSourceArrow,
3260
+ hasTargetArrow: r.hasTargetArrow,
3261
+ cycleSquareSide: r.cycleSquareSide,
3262
+ roundness: r.roundness,
3263
+ detourDistance: r.detourDistance,
3264
+ detourDirection: r.detourDirection
3265
+ });
3266
+ case "horizontal":
3267
+ return () => new St({
3268
+ color: r.color,
3269
+ width: r.width,
3270
+ arrowLength: r.arrowLength,
3271
+ arrowOffset: r.arrowOffset,
3272
+ arrowRenderer: r.arrowRenderer,
3273
+ hasSourceArrow: r.hasSourceArrow,
3274
+ hasTargetArrow: r.hasTargetArrow,
3275
+ cycleSquareSide: r.cycleSquareSide,
3276
+ roundness: r.roundness,
3277
+ detourDistance: r.detourDistance
3278
+ });
3279
+ case "vertical":
3280
+ return () => new Pt({
3281
+ color: r.color,
3282
+ width: r.width,
3283
+ arrowLength: r.arrowLength,
3284
+ arrowOffset: r.arrowOffset,
3285
+ arrowRenderer: r.arrowRenderer,
3286
+ hasSourceArrow: r.hasSourceArrow,
3287
+ hasTargetArrow: r.hasTargetArrow,
3288
+ cycleSquareSide: r.cycleSquareSide,
3289
+ roundness: r.roundness,
3290
+ detourDistance: r.detourDistance
3291
+ });
3292
+ case "direct":
3293
+ return () => new Ve({
3294
+ color: r.color,
3295
+ width: r.width,
3296
+ arrowLength: r.arrowLength,
3297
+ arrowRenderer: r.arrowRenderer,
3298
+ hasSourceArrow: r.hasSourceArrow,
3299
+ hasTargetArrow: r.hasTargetArrow,
3300
+ sourceOffset: r.sourceOffset,
3301
+ targetOffset: r.targetOffset
3302
+ });
3303
+ default:
3304
+ return () => new Et({
3305
+ color: r.color,
3306
+ width: r.width,
3307
+ arrowLength: r.arrowLength,
3308
+ arrowRenderer: r.arrowRenderer,
3309
+ hasSourceArrow: r.hasSourceArrow,
3310
+ hasTargetArrow: r.hasTargetArrow,
3311
+ cycleRadius: r.cycleRadius,
3312
+ smallCycleRadius: r.smallCycleRadius,
3313
+ curvature: r.curvature,
3314
+ detourDistance: r.detourDistance,
3315
+ detourDirection: r.detourDirection
3316
+ });
3317
+ }
3318
+ }, qt = (r, e, t) => {
3281
3319
  var c, g, l;
3282
3320
  const s = () => "direct", o = (u) => u, n = (u) => u.button === 0, a = () => {
3283
3321
  }, h = () => {
@@ -3292,13 +3330,13 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3292
3330
  onEdgeCreationInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeCreationInterrupted) ?? d,
3293
3331
  onEdgeCreationPrevented: ((l = r.events) == null ? void 0 : l.onEdgeCreationPrevented) ?? h,
3294
3332
  dragPortDirection: r.dragPortDirection ?? t,
3295
- edgeShapeFactory: r.edgeShape !== void 0 ? ae(r.edgeShape) : e
3333
+ edgeShapeFactory: r.edgeShape !== void 0 ? he(r.edgeShape) : e
3296
3334
  };
3297
- }, Xt = (r, e) => {
3335
+ }, Kt = (r, e) => {
3298
3336
  var c, g, l;
3299
3337
  const t = (u) => u, s = (u) => u.button === 0 && u.ctrlKey, o = (u) => u.button === 0, n = (u) => {
3300
- const w = e.getPortAdjacentEdgeIds(u);
3301
- return w.length > 0 ? w[w.length - 1] : null;
3338
+ const p = e.getPortAdjacentEdgeIds(u);
3339
+ return p.length > 0 ? p[p.length - 1] : null;
3302
3340
  }, a = () => {
3303
3341
  }, h = () => {
3304
3342
  }, d = () => {
@@ -3308,15 +3346,15 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3308
3346
  mouseDownEventVerifier: r.mouseDownEventVerifier ?? s,
3309
3347
  mouseUpEventVerifier: r.mouseUpEventVerifier ?? o,
3310
3348
  draggingEdgeResolver: r.draggingEdgeResolver ?? n,
3311
- draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ae(r.draggingEdgeShape) : null,
3349
+ draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? he(r.draggingEdgeShape) : null,
3312
3350
  onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
3313
3351
  onEdgeReattachInterrupted: ((g = r.events) == null ? void 0 : g.onEdgeReattachInterrupted) ?? d,
3314
3352
  onEdgeReattachPrevented: ((l = r.events) == null ? void 0 : l.onEdgeReattachPrevented) ?? h
3315
3353
  };
3316
- }, Gt = (r) => ({
3354
+ }, Qt = (r) => ({
3317
3355
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3318
3356
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3319
- }), jt = (r) => {
3357
+ }), Zt = (r) => {
3320
3358
  var e, t;
3321
3359
  return {
3322
3360
  onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
@@ -3325,13 +3363,13 @@ const K = (r) => () => r, me = K(0), Ft = () => {
3325
3363
  })
3326
3364
  };
3327
3365
  };
3328
- class qt extends Error {
3366
+ class Jt extends Error {
3329
3367
  constructor() {
3330
3368
  super(...arguments);
3331
3369
  i(this, "name", "CanvasBuilderError");
3332
3370
  }
3333
3371
  }
3334
- class $e {
3372
+ class ke {
3335
3373
  constructor(e, t, s) {
3336
3374
  i(this, "dt");
3337
3375
  i(this, "nodeMass");
@@ -3364,12 +3402,12 @@ class $e {
3364
3402
  const s = this.graph.getEdge(t), o = this.graph.getPort(s.from), n = this.graph.getPort(s.to), a = this.currentCoords.get(o.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
3365
3403
  a,
3366
3404
  h
3367
- ), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, w = e.get(o.nodeId), f = e.get(n.nodeId);
3368
- w.x += l, w.y += u, f.x -= l, f.y -= u;
3405
+ ), g = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, l = d.ex * g, u = d.ey * g, p = e.get(o.nodeId), y = e.get(n.nodeId);
3406
+ p.x += l, p.y += u, y.x -= l, y.y -= u;
3369
3407
  });
3370
3408
  }
3371
3409
  }
3372
- class Ue {
3410
+ class He {
3373
3411
  constructor(e) {
3374
3412
  i(this, "PI2", 2 * Math.PI);
3375
3413
  this.rand = e;
@@ -3388,13 +3426,13 @@ class Ue {
3388
3426
  return { ex: h, ey: d, d: a };
3389
3427
  }
3390
3428
  }
3391
- const Oe = (r) => {
3429
+ const Ye = (r) => {
3392
3430
  if (r.distance === 0)
3393
3431
  return r.maxForce;
3394
3432
  const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
3395
3433
  return Math.min(e, r.maxForce);
3396
3434
  };
3397
- class Kt {
3435
+ class _t {
3398
3436
  constructor(e) {
3399
3437
  i(this, "nodeCharge");
3400
3438
  i(this, "distanceVectorGenerator");
@@ -3409,19 +3447,19 @@ class Kt {
3409
3447
  const d = s[h], c = e.get(a), g = e.get(d), l = this.distanceVectorGenerator.create(
3410
3448
  c,
3411
3449
  g
3412
- ), u = Oe({
3450
+ ), u = Ye({
3413
3451
  coefficient: 1,
3414
3452
  sourceCharge: this.nodeCharge,
3415
3453
  targetCharge: this.nodeCharge,
3416
3454
  distance: l.d,
3417
3455
  maxForce: this.maxForce
3418
- }), w = u * l.ex, f = u * l.ey, v = t.get(a), S = t.get(d);
3419
- v.x -= w, v.y -= f, S.x += w, S.y += f;
3456
+ }), p = u * l.ex, y = u * l.ey, v = t.get(a), x = t.get(d);
3457
+ v.x -= p, v.y -= y, x.x += p, x.y += y;
3420
3458
  }
3421
3459
  }
3422
3460
  }
3423
3461
  }
3424
- const Qt = (r) => {
3462
+ const er = (r) => {
3425
3463
  if (r.size === 0)
3426
3464
  return {
3427
3465
  centerX: 0,
@@ -3439,7 +3477,7 @@ const Qt = (r) => {
3439
3477
  radius: h / 2
3440
3478
  };
3441
3479
  };
3442
- class Zt {
3480
+ class tr {
3443
3481
  constructor(e) {
3444
3482
  i(this, "root");
3445
3483
  i(this, "leaves", /* @__PURE__ */ new Map());
@@ -3494,8 +3532,8 @@ class Zt {
3494
3532
  this.sortedParentNodes.push(e);
3495
3533
  const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = o / 2;
3496
3534
  e.nodeIds.forEach((u) => {
3497
- const { x: w, y: f } = this.coords.get(u);
3498
- w < t ? f < s ? d.add(u) : h.add(u) : f < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
3535
+ const { x: p, y } = this.coords.get(u);
3536
+ p < t ? y < s ? d.add(u) : h.add(u) : y < s ? a.add(u) : n.add(u), e.nodeIds.delete(u);
3499
3537
  });
3500
3538
  const g = {
3501
3539
  parent: e,
@@ -3596,7 +3634,7 @@ class Zt {
3596
3634
  }), { x: t / e.size, y: s / e.size };
3597
3635
  }
3598
3636
  }
3599
- class Jt {
3637
+ class rr {
3600
3638
  constructor(e) {
3601
3639
  i(this, "areaRadiusThreshold");
3602
3640
  i(this, "nodeMass");
@@ -3608,7 +3646,7 @@ class Jt {
3608
3646
  this.areaRadiusThreshold = e.areaRadiusThreshold, this.nodeMass = e.nodeMass, this.nodeCharge = e.nodeCharge, this.theta = e.theta, this.distanceVectorGenerator = e.distanceVectorGenerator, this.nodeForceCoefficient = e.nodeForceCoefficient, this.maxForce = e.maxForce;
3609
3647
  }
3610
3648
  apply(e, t) {
3611
- const s = Qt(e), o = new Zt({
3649
+ const s = er(e), o = new tr({
3612
3650
  box: s,
3613
3651
  coords: e,
3614
3652
  areaRadiusThreshold: this.areaRadiusThreshold,
@@ -3723,7 +3761,7 @@ class Jt {
3723
3761
  const t = this.distanceVectorGenerator.create(
3724
3762
  e.sourceCoords,
3725
3763
  e.targetCoords
3726
- ), s = Oe({
3764
+ ), s = Ye({
3727
3765
  coefficient: this.nodeForceCoefficient,
3728
3766
  sourceCharge: e.sourceCharge,
3729
3767
  targetCharge: e.targetCharge,
@@ -3758,7 +3796,7 @@ class Jt {
3758
3796
  }
3759
3797
  }
3760
3798
  }
3761
- const We = (r) => r.theta !== 0 ? new Jt({
3799
+ const Xe = (r) => r.theta !== 0 ? new rr({
3762
3800
  nodeCharge: r.nodeCharge,
3763
3801
  nodeForceCoefficient: r.nodeForceCoefficient,
3764
3802
  distanceVectorGenerator: r.distanceVectorGenerator,
@@ -3766,36 +3804,36 @@ const We = (r) => r.theta !== 0 ? new Jt({
3766
3804
  theta: r.theta,
3767
3805
  nodeMass: r.nodeMass,
3768
3806
  areaRadiusThreshold: r.areaRadiusThreshold
3769
- }) : new Kt({
3807
+ }) : new _t({
3770
3808
  nodeCharge: r.nodeCharge,
3771
3809
  nodeForceCoefficient: r.nodeForceCoefficient,
3772
3810
  distanceVectorGenerator: r.distanceVectorGenerator,
3773
3811
  maxForce: r.maxForce
3774
3812
  });
3775
- class ze {
3813
+ class Ge {
3776
3814
  constructor(e) {
3777
3815
  i(this, "rand");
3778
3816
  i(this, "sparsity");
3779
3817
  this.rand = e.rand, this.sparsity = e.sparsity;
3780
3818
  }
3781
3819
  calculateCoordinates(e) {
3782
- const { graph: t, viewport: s } = e, o = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((f) => {
3783
- const v = t.getNode(f);
3820
+ const { graph: t, viewport: s } = e, o = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((y) => {
3821
+ const v = t.getNode(y);
3784
3822
  return v.x === null || v.y === null;
3785
3823
  }), a = Math.sqrt(n.length) * this.sparsity, { width: h, height: d } = s.getDimensions(), c = { x: h / 2, y: d / 2 }, g = s.createContentCoords(c), l = a / 2, u = {
3786
3824
  x: g.x - l,
3787
3825
  y: g.y - l
3788
3826
  };
3789
- return t.getAllNodeIds().forEach((f) => {
3790
- const v = t.getNode(f);
3791
- o.set(f, {
3827
+ return t.getAllNodeIds().forEach((y) => {
3828
+ const v = t.getNode(y);
3829
+ o.set(y, {
3792
3830
  x: v.x ?? u.x + a * this.rand(),
3793
3831
  y: v.y ?? u.y + a * this.rand()
3794
3832
  });
3795
3833
  }), o;
3796
3834
  }
3797
3835
  }
3798
- class _t {
3836
+ class sr {
3799
3837
  constructor(e) {
3800
3838
  i(this, "distanceVectorGenerator");
3801
3839
  i(this, "nodeForcesApplicationStrategy");
@@ -3806,7 +3844,7 @@ class _t {
3806
3844
  i(this, "edgeEquilibriumLength");
3807
3845
  i(this, "edgeStiffness");
3808
3846
  i(this, "convergenceVelocity");
3809
- this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new Ue(e.rand), this.nodeForcesApplicationStrategy = We({
3847
+ this.maxIterations = e.maxIterations, this.dtSec = e.dtSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.convergenceVelocity = e.convergenceVelocity, this.distanceVectorGenerator = new He(e.rand), this.nodeForcesApplicationStrategy = Xe({
3810
3848
  distanceVectorGenerator: this.distanceVectorGenerator,
3811
3849
  nodeCharge: e.nodeCharge,
3812
3850
  maxForce: e.maxForce,
@@ -3814,7 +3852,7 @@ class _t {
3814
3852
  theta: e.barnesHutTheta,
3815
3853
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
3816
3854
  nodeMass: e.nodeMass
3817
- }), this.fillerLayoutAlgorithm = new ze({
3855
+ }), this.fillerLayoutAlgorithm = new Ge({
3818
3856
  rand: e.rand,
3819
3857
  sparsity: e.edgeEquilibriumLength
3820
3858
  });
@@ -3824,7 +3862,7 @@ class _t {
3824
3862
  graph: t,
3825
3863
  viewport: s
3826
3864
  });
3827
- for (let n = 0; n < this.maxIterations && !(new $e(
3865
+ for (let n = 0; n < this.maxIterations && !(new ke(
3828
3866
  t,
3829
3867
  o,
3830
3868
  {
@@ -3840,7 +3878,7 @@ class _t {
3840
3878
  return o;
3841
3879
  }
3842
3880
  }
3843
- class er {
3881
+ class or {
3844
3882
  constructor(e) {
3845
3883
  i(this, "forest", /* @__PURE__ */ new Set());
3846
3884
  i(this, "remainingNodeIds");
@@ -3883,7 +3921,7 @@ class er {
3883
3921
  }
3884
3922
  }
3885
3923
  }
3886
- class tr {
3924
+ class ir {
3887
3925
  constructor(e) {
3888
3926
  i(this, "baseRadius");
3889
3927
  this.baseRadius = e.radius;
@@ -3911,12 +3949,12 @@ class tr {
3911
3949
  };
3912
3950
  }
3913
3951
  }
3914
- class rr {
3952
+ class nr {
3915
3953
  constructor(e, t) {
3916
3954
  i(this, "offsets", /* @__PURE__ */ new Map());
3917
3955
  i(this, "childrenRadii", /* @__PURE__ */ new Map());
3918
3956
  i(this, "layerNodePlacementResolver");
3919
- this.tree = e, this.layerNodePlacementResolver = new tr({
3957
+ this.tree = e, this.layerNodePlacementResolver = new ir({
3920
3958
  radius: t.spaceAroundRadius
3921
3959
  }), [...this.tree.sequence].reverse().forEach((s) => {
3922
3960
  if (s.children.size === 0)
@@ -3937,16 +3975,16 @@ class rr {
3937
3975
  return this.offsets;
3938
3976
  }
3939
3977
  }
3940
- class sr {
3978
+ class ar {
3941
3979
  constructor(e) {
3942
3980
  this.params = e;
3943
3981
  }
3944
3982
  calculateCoordinates(e) {
3945
- const t = /* @__PURE__ */ new Map(), o = new er(e.graph).generate();
3983
+ const t = /* @__PURE__ */ new Map(), o = new or(e.graph).generate();
3946
3984
  let n = 0;
3947
3985
  return o.forEach((a) => {
3948
3986
  t.set(a.root.nodeId, { x: n, y: 0 });
3949
- const d = new rr(a, {
3987
+ const d = new nr(a, {
3950
3988
  spaceAroundRadius: this.params.layerSpace / 2
3951
3989
  }).generate();
3952
3990
  let c = [a.root];
@@ -3954,9 +3992,9 @@ class sr {
3954
3992
  const g = [];
3955
3993
  n += this.params.layerWidth, c.forEach((l) => {
3956
3994
  l.children.forEach((u) => {
3957
- const w = t.get(l.nodeId).y;
3995
+ const p = t.get(l.nodeId).y;
3958
3996
  t.set(u.nodeId, {
3959
- y: w + d.get(u.nodeId),
3997
+ y: p + d.get(u.nodeId),
3960
3998
  x: n
3961
3999
  }), g.push(u);
3962
4000
  });
@@ -3968,7 +4006,7 @@ class sr {
3968
4006
  }), t;
3969
4007
  }
3970
4008
  }
3971
- class or {
4009
+ class hr {
3972
4010
  constructor(e) {
3973
4011
  i(this, "distanceVectorGenerator");
3974
4012
  i(this, "nodeForcesApplicationStrategy");
@@ -3978,7 +4016,7 @@ class or {
3978
4016
  i(this, "edgeEquilibriumLength");
3979
4017
  i(this, "edgeStiffness");
3980
4018
  i(this, "fillerLayoutAlgorithm");
3981
- this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Ue(e.rand), this.nodeForcesApplicationStrategy = We({
4019
+ this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new He(e.rand), this.nodeForcesApplicationStrategy = Xe({
3982
4020
  distanceVectorGenerator: this.distanceVectorGenerator,
3983
4021
  nodeCharge: e.nodeCharge,
3984
4022
  maxForce: e.maxForce,
@@ -3986,7 +4024,7 @@ class or {
3986
4024
  theta: e.barnesHutTheta,
3987
4025
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
3988
4026
  nodeMass: e.nodeMass
3989
- }), this.fillerLayoutAlgorithm = new ze({
4027
+ }), this.fillerLayoutAlgorithm = new Ge({
3990
4028
  rand: e.rand,
3991
4029
  sparsity: e.edgeEquilibriumLength
3992
4030
  });
@@ -3996,7 +4034,7 @@ class or {
3996
4034
  graph: t,
3997
4035
  viewport: s
3998
4036
  });
3999
- return new $e(
4037
+ return new ke(
4000
4038
  t,
4001
4039
  n,
4002
4040
  {
@@ -4013,12 +4051,12 @@ class or {
4013
4051
  }) ? /* @__PURE__ */ new Map() : n;
4014
4052
  }
4015
4053
  }
4016
- const ke = (r) => {
4054
+ const je = (r) => {
4017
4055
  let e = 1779033703, t = 3144134277, s = 1013904242, o = 2773480762;
4018
4056
  for (let n = 0, a; n < r.length; n++)
4019
4057
  a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = s ^ Math.imul(t ^ a, 2869860233), s = o ^ Math.imul(s ^ a, 951274213), o = e ^ Math.imul(o ^ a, 2716044179);
4020
4058
  return e = Math.imul(s ^ e >>> 18, 597399067), t = Math.imul(o ^ t >>> 22, 2869860233), s = Math.imul(e ^ s >>> 17, 951274213), o = Math.imul(t ^ o >>> 19, 2716044179), e ^= t ^ s ^ o, t ^= e, s ^= e, o ^= e, [e >>> 0, t >>> 0, s >>> 0, o >>> 0];
4021
- }, He = (r, e, t, s) => function() {
4059
+ }, qe = (r, e, t, s) => function() {
4022
4060
  r |= 0, e |= 0, t |= 0, s |= 0;
4023
4061
  const o = (r + e | 0) + s | 0;
4024
4062
  return s = s + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t + o | 0, (o >>> 0) / 4294967296;
@@ -4036,14 +4074,14 @@ const ke = (r) => {
4036
4074
  nodeForceCoefficient: 1,
4037
4075
  barnesHutAreaRadiusThreshold: 0.01,
4038
4076
  barnesHutTheta: 1
4039
- }), ir = (r) => {
4077
+ }), dr = (r) => {
4040
4078
  var e, t;
4041
4079
  switch (r == null ? void 0 : r.type) {
4042
4080
  case "custom":
4043
4081
  return r.instance;
4044
4082
  default: {
4045
- const s = ke((r == null ? void 0 : r.seed) ?? A.seed), o = He(s[0], s[1], s[2], s[3]);
4046
- return new or({
4083
+ const s = je((r == null ? void 0 : r.seed) ?? A.seed), o = qe(s[0], s[1], s[2], s[3]);
4084
+ return new hr({
4047
4085
  rand: o,
4048
4086
  maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? A.maxTimeDeltaSec,
4049
4087
  nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? A.nodeCharge,
@@ -4058,27 +4096,29 @@ const ke = (r) => {
4058
4096
  });
4059
4097
  }
4060
4098
  }
4061
- }, j = {
4099
+ }, G = {
4062
4100
  staticNodeResolver: () => !1,
4063
4101
  onBeforeApplied: () => {
4064
4102
  },
4065
4103
  onAfterApplied: () => {
4066
4104
  }
4067
- }, nr = (r) => {
4105
+ }, cr = (r) => {
4068
4106
  var t, s;
4069
4107
  return {
4070
- algorithm: ir((r == null ? void 0 : r.algorithm) ?? {}),
4071
- staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? j.staticNodeResolver,
4072
- onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? j.onBeforeApplied,
4073
- onAfterApplied: ((s = r == null ? void 0 : r.events) == null ? void 0 : s.onAfterApplied) ?? j.onAfterApplied
4108
+ algorithm: dr((r == null ? void 0 : r.algorithm) ?? {}),
4109
+ staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? G.staticNodeResolver,
4110
+ onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? G.onBeforeApplied,
4111
+ onAfterApplied: ((s = r == null ? void 0 : r.events) == null ? void 0 : s.onAfterApplied) ?? G.onAfterApplied
4074
4112
  };
4075
- }, ar = (r) => r instanceof Q ? {
4076
- type: "manual",
4113
+ }, lr = (r) => r instanceof K ? {
4114
+ type: "trigger",
4077
4115
  trigger: r
4078
4116
  } : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
4079
- type: "topologyChangeMacrotask"
4117
+ type: "topologyChangeSchedule",
4118
+ schedule: Mt
4080
4119
  } : {
4081
- type: "topologyChangeMicrotask"
4120
+ type: "topologyChangeSchedule",
4121
+ schedule: Rt
4082
4122
  }, F = Object.freeze({
4083
4123
  staticNodeResolver: () => !1,
4084
4124
  onBeforeApplied: () => {
@@ -4096,7 +4136,7 @@ const ke = (r) => {
4096
4136
  d: r.d * e.a + r.e * e.d,
4097
4137
  e: r.d * e.b + r.e * e.e,
4098
4138
  f: r.d * e.c + r.e * e.f + r.f
4099
- }), hr = (r) => {
4139
+ }), gr = (r) => {
4100
4140
  const { a: e, b: t, c: s, d: o, e: n, f: a } = r, h = e * n - t * o;
4101
4141
  return {
4102
4142
  a: n / h,
@@ -4107,7 +4147,7 @@ const ke = (r) => {
4107
4147
  f: (s * o - e * a) / h
4108
4148
  };
4109
4149
  };
4110
- class dr {
4150
+ class ur {
4111
4151
  resolve(e) {
4112
4152
  if ("shift" in e)
4113
4153
  return this.createShiftBaseMatrix(e.shift);
@@ -4151,7 +4191,7 @@ class dr {
4151
4191
  const s = $(
4152
4192
  t,
4153
4193
  e
4154
- ), o = hr(t);
4194
+ ), o = gr(t);
4155
4195
  return $(s, o);
4156
4196
  }
4157
4197
  createShiftBaseMatrix(e) {
@@ -4196,7 +4236,7 @@ class dr {
4196
4236
  };
4197
4237
  }
4198
4238
  }
4199
- const cr = (r) => {
4239
+ const pr = (r) => {
4200
4240
  if (r === void 0)
4201
4241
  return (o) => o;
4202
4242
  if (typeof r == "function")
@@ -4210,7 +4250,7 @@ const cr = (r) => {
4210
4250
  e: 1,
4211
4251
  f: 0
4212
4252
  };
4213
- const s = new dr();
4253
+ const s = new ur();
4214
4254
  return e.forEach((o) => {
4215
4255
  const n = s.resolve(o);
4216
4256
  t = $(t, n);
@@ -4221,20 +4261,20 @@ const cr = (r) => {
4221
4261
  y: t.d * n + t.e * a + t.f
4222
4262
  };
4223
4263
  };
4224
- }, lr = (r) => {
4264
+ }, wr = (r) => {
4225
4265
  var e, t;
4226
4266
  switch (r == null ? void 0 : r.type) {
4227
4267
  case "custom":
4228
4268
  return r.instance;
4229
4269
  case "hierarchical":
4230
- return new sr({
4270
+ return new ar({
4231
4271
  layerWidth: r.layerWidth ?? F.hierarchicalLayout.layerWidth,
4232
4272
  layerSpace: r.layerSpace ?? F.hierarchicalLayout.layerSpace,
4233
- transform: cr(r.transform)
4273
+ transform: pr(r.transform)
4234
4274
  });
4235
4275
  default: {
4236
- const s = ke((r == null ? void 0 : r.seed) ?? A.seed), o = He(s[0], s[1], s[2], s[3]);
4237
- return new _t({
4276
+ const s = je((r == null ? void 0 : r.seed) ?? A.seed), o = qe(s[0], s[1], s[2], s[3]);
4277
+ return new sr({
4238
4278
  dtSec: (r == null ? void 0 : r.dtSec) ?? A.dtSec,
4239
4279
  maxIterations: (r == null ? void 0 : r.maxIterations) ?? A.maxIterations,
4240
4280
  rand: o,
@@ -4250,16 +4290,16 @@ const cr = (r) => {
4250
4290
  });
4251
4291
  }
4252
4292
  }
4253
- }, gr = (r) => {
4293
+ }, yr = (r) => {
4254
4294
  var e, t;
4255
4295
  return {
4256
- algorithm: lr(r == null ? void 0 : r.algorithm),
4257
- applyOn: ar(r == null ? void 0 : r.applyOn),
4258
- staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? F.staticNodeResolver,
4259
- onBeforeApplied: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onBeforeApplied) ?? F.onBeforeApplied,
4260
- onAfterApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onAfterApplied) ?? F.onAfterApplied
4296
+ algorithm: wr(r.algorithm),
4297
+ applyOn: lr(r.applyOn),
4298
+ staticNodeResolver: r.staticNodeResolver ?? F.staticNodeResolver,
4299
+ onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? F.onBeforeApplied,
4300
+ onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? F.onAfterApplied
4261
4301
  };
4262
- }, ur = (r, e) => ({
4302
+ }, fr = (r, e) => ({
4263
4303
  ...r,
4264
4304
  onNodeDragStarted: (t) => {
4265
4305
  e.add(t), r.onNodeDragStarted(t);
@@ -4267,17 +4307,58 @@ const cr = (r) => {
4267
4307
  onNodeDragFinished: (t) => {
4268
4308
  e.delete(t), r.onNodeDragFinished(t);
4269
4309
  }
4270
- }), pr = (r, e) => {
4271
- r.onBeforeNodeRemoved.subscribe((t) => {
4310
+ }), mr = (r, e) => {
4311
+ r.graph.onBeforeNodeRemoved.subscribe((t) => {
4272
4312
  e.delete(t);
4273
- }), r.onBeforeClear.subscribe(() => {
4313
+ }), r.graph.onBeforeClear.subscribe(() => {
4314
+ e.clear();
4315
+ }), r.onBeforeDestroy.subscribe(() => {
4274
4316
  e.clear();
4275
4317
  });
4276
- }, wr = (r, e) => ({
4318
+ }, vr = (r, e) => ({
4277
4319
  ...r,
4278
4320
  staticNodeResolver: (t) => r.staticNodeResolver(t) || e.has(t)
4279
- });
4280
- class mr {
4321
+ }), q = (r) => () => r, xe = q(0), Ar = () => {
4322
+ let r = 0;
4323
+ return () => r++;
4324
+ }, xr = (r, e) => {
4325
+ let t = xe, s = xe;
4326
+ const o = Ar();
4327
+ return r === "incremental" && (t = o), e === "incremental" && (s = o), typeof r == "number" && (t = q(r)), typeof e == "number" && (s = q(e)), typeof r == "function" && (t = r), typeof e == "function" && (s = e), {
4328
+ nodesPriorityFn: t,
4329
+ edgesPriorityFn: s
4330
+ };
4331
+ }, Er = (r) => {
4332
+ var t, s, o, n, a;
4333
+ const e = xr(
4334
+ (t = r.nodes) == null ? void 0 : t.priority,
4335
+ (s = r.edges) == null ? void 0 : s.priority
4336
+ );
4337
+ return {
4338
+ nodes: {
4339
+ centerFn: ((o = r.nodes) == null ? void 0 : o.centerFn) ?? Ne,
4340
+ priorityFn: e.nodesPriorityFn
4341
+ },
4342
+ ports: {
4343
+ direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
4344
+ },
4345
+ edges: {
4346
+ shapeFactory: he(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4347
+ priorityFn: e.edgesPriorityFn
4348
+ }
4349
+ };
4350
+ }, Sr = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : _, br = (r) => {
4351
+ var s, o;
4352
+ const { canvasDefaults: e } = r, t = r.hasLayout ? Sr(r.layoutParams) : _;
4353
+ return {
4354
+ focus: {
4355
+ contentOffset: ((s = e.focus) == null ? void 0 : s.contentOffset) ?? 100,
4356
+ minContentScale: ((o = e.focus) == null ? void 0 : o.minContentScale) ?? 0,
4357
+ schedule: t
4358
+ }
4359
+ };
4360
+ };
4361
+ class Nr {
4281
4362
  constructor(e) {
4282
4363
  i(this, "used", !1);
4283
4364
  i(this, "canvasDefaults", {});
@@ -4297,192 +4378,167 @@ class mr {
4297
4378
  i(this, "hasUserDraggableEdges", !1);
4298
4379
  i(this, "hasAnimatedLayout", !1);
4299
4380
  i(this, "hasLayout", !1);
4300
- i(this, "boxRenderingTrigger", new Q());
4381
+ i(this, "boxRenderingTrigger", new K());
4301
4382
  i(this, "graphStore");
4302
4383
  i(this, "viewportStore");
4303
4384
  i(this, "graph");
4304
4385
  i(this, "viewport");
4305
4386
  i(this, "window", window);
4306
4387
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
4307
- this.element = e, this.viewportStore = new _e(this.element), this.viewport = new Ie(this.viewportStore), this.graphStore = new Se(), this.graph = new Fe(this.graphStore);
4388
+ this.element = e, this.viewportStore = new it(this.element), this.viewport = new $e(this.viewportStore), this.graphStore = new be(), this.graph = new Ie(this.graphStore);
4308
4389
  }
4309
- /**
4310
- * specifies default values for graph entities
4311
- */
4312
4390
  setDefaults(e) {
4313
4391
  return this.canvasDefaults = e, this;
4314
4392
  }
4315
- /**
4316
- * enables nodes draggable by user
4317
- */
4318
4393
  enableUserDraggableNodes(e) {
4319
4394
  return this.hasDraggableNodes = !0, this.dragConfig = e ?? {}, this;
4320
4395
  }
4321
- /**
4322
- * enables viewport transformable by user
4323
- */
4324
4396
  enableUserTransformableViewport(e) {
4325
4397
  return this.hasTransformableViewport = !0, this.transformConfig = e ?? {}, this;
4326
4398
  }
4327
- /**
4328
- * enables automatic edges update on node resize
4329
- */
4330
4399
  enableNodeResizeReactiveEdges() {
4331
4400
  return this.hasNodeResizeReactiveEdges = !0, this;
4332
4401
  }
4333
- /**
4334
- * enables built-in virtual scroll behavior, when only nodes and edges close
4335
- * to viewport are rendered
4336
- */
4337
4402
  enableVirtualScroll(e) {
4338
4403
  return this.virtualScrollConfig = e, this;
4339
4404
  }
4340
- /**
4341
- * enables built-in background rendering
4342
- */
4343
4405
  enableBackground(e) {
4344
4406
  return this.hasBackground = !0, this.backgroundConfig = e ?? {}, this;
4345
4407
  }
4346
- /**
4347
- * enables edge creation by dragging one port to another
4348
- */
4349
4408
  enableUserConnectablePorts(e) {
4350
4409
  return this.hasUserConnectablePorts = !0, this.connectablePortsConfig = e ?? {}, this;
4351
4410
  }
4352
- /**
4353
- * enables edges dragging by dragging one of the adjacent ports
4354
- */
4355
4411
  enableUserDraggableEdges(e) {
4356
4412
  return this.hasUserDraggableEdges = !0, this.draggableEdgesConfig = e ?? {}, this;
4357
4413
  }
4358
- /**
4359
- * enables nodes positioning with specified layout
4360
- */
4361
4414
  enableLayout(e) {
4362
4415
  return this.layoutConfig = e ?? {}, this.hasLayout = !0, this.hasAnimatedLayout = !1, this;
4363
4416
  }
4364
- /**
4365
- * enables animated nodes positioning with specified layout
4366
- */
4367
4417
  enableAnimatedLayout(e) {
4368
4418
  return this.animatedLayoutConfig = e ?? {}, this.hasAnimatedLayout = !0, this.hasLayout = !1, this;
4369
4419
  }
4370
- /**
4371
- * builds final canvas
4372
- */
4373
4420
  build() {
4374
4421
  if (this.used)
4375
- throw new qt("CanvasBuilder is a single use object");
4422
+ throw new Jt("CanvasBuilder is a single use object");
4376
4423
  this.used = !0;
4377
- const e = new Vt(this.element), t = this.createHtmlView(e.main), s = Bt(this.canvasDefaults), o = new Ee(
4378
- this.graph,
4379
- this.viewport,
4424
+ const e = new Wt(this.element), t = this.createHtmlView(e.main), s = Er(
4425
+ this.canvasDefaults
4426
+ ), o = new Be(
4380
4427
  this.graphStore,
4381
- this.viewportStore,
4382
4428
  t,
4383
4429
  s
4430
+ ), n = yr(this.layoutConfig), a = br({
4431
+ canvasDefaults: this.canvasDefaults,
4432
+ hasLayout: this.hasLayout,
4433
+ layoutParams: n
4434
+ }), h = new We(
4435
+ this.graphStore,
4436
+ this.viewportStore,
4437
+ a
4438
+ ), d = new Se(
4439
+ this.graph,
4440
+ this.viewport,
4441
+ o,
4442
+ h
4384
4443
  );
4385
4444
  if (this.hasBackground && re.configure(
4386
- o,
4387
- Ht(this.backgroundConfig),
4445
+ d,
4446
+ jt(this.backgroundConfig),
4388
4447
  e.background
4389
- ), this.hasNodeResizeReactiveEdges && Z.configure(o), this.hasDraggableNodes) {
4390
- let a = $t(this.dragConfig);
4391
- this.hasAnimatedLayout && (a = ur(
4392
- a,
4448
+ ), this.hasNodeResizeReactiveEdges && Q.configure(d), this.hasDraggableNodes) {
4449
+ let g = zt(this.dragConfig);
4450
+ this.hasAnimatedLayout && (g = fr(
4451
+ g,
4393
4452
  this.animationStaticNodes
4394
4453
  )), ee.configure(
4395
- o,
4454
+ d,
4396
4455
  e.main,
4397
4456
  this.window,
4398
- a
4457
+ g
4399
4458
  );
4400
4459
  }
4401
4460
  if (this.hasUserConnectablePorts) {
4402
- const a = Yt(
4461
+ const g = qt(
4403
4462
  this.connectablePortsConfig,
4404
4463
  s.edges.shapeFactory,
4405
4464
  s.ports.direction
4406
4465
  );
4407
4466
  se.configure(
4408
- o,
4467
+ d,
4409
4468
  e.overlayConnectablePorts,
4410
4469
  this.viewportStore,
4411
4470
  this.window,
4412
- a
4471
+ g
4413
4472
  );
4414
4473
  }
4415
4474
  if (this.hasUserDraggableEdges) {
4416
- const a = Xt(
4475
+ const g = Kt(
4417
4476
  this.draggableEdgesConfig,
4418
- o.graph
4477
+ d.graph
4419
4478
  );
4420
4479
  oe.configure(
4421
- o,
4480
+ d,
4422
4481
  e.overlayDraggableEdges,
4423
4482
  this.viewportStore,
4424
4483
  this.window,
4425
- a
4484
+ g
4426
4485
  );
4427
4486
  }
4428
4487
  if (this.virtualScrollConfig !== void 0 ? te.configure(
4429
- o,
4488
+ d,
4430
4489
  e.main,
4431
4490
  this.window,
4432
4491
  Ae(this.transformConfig),
4433
4492
  this.boxRenderingTrigger,
4434
- Gt(this.virtualScrollConfig)
4435
- ) : this.hasTransformableViewport && X.configure(
4436
- o,
4493
+ Qt(this.virtualScrollConfig)
4494
+ ) : this.hasTransformableViewport && Y.configure(
4495
+ d,
4437
4496
  e.main,
4438
4497
  this.window,
4439
4498
  Ae(this.transformConfig)
4440
- ), this.hasLayout && Dt.configure(
4441
- o,
4442
- gr(this.layoutConfig)
4443
- ), this.hasAnimatedLayout) {
4444
- let a = nr(
4499
+ ), this.hasLayout && $t.configure(d, n), this.hasAnimatedLayout) {
4500
+ let g = cr(
4445
4501
  this.animatedLayoutConfig
4446
4502
  );
4447
- this.hasDraggableNodes && (pr(
4448
- o.graph,
4503
+ this.hasDraggableNodes && (mr(
4504
+ d,
4449
4505
  this.animationStaticNodes
4450
- ), a = wr(
4451
- a,
4506
+ ), g = vr(
4507
+ g,
4452
4508
  this.animationStaticNodes
4453
- )), ne.configure(o, a, this.window);
4509
+ )), ae.configure(d, g, this.window);
4454
4510
  }
4455
- const n = () => {
4456
- e.destroy(), o.onBeforeDestroy.unsubscribe(n);
4511
+ const c = () => {
4512
+ e.destroy(), d.onBeforeDestroy.unsubscribe(c);
4457
4513
  };
4458
- return o.onBeforeDestroy.subscribe(n), o;
4514
+ return d.onBeforeDestroy.subscribe(c), d;
4459
4515
  }
4460
4516
  createHtmlView(e) {
4461
- let t = new xe(
4517
+ let t = new Ee(
4462
4518
  this.graphStore,
4463
4519
  this.viewportStore,
4464
4520
  e
4465
4521
  );
4466
- return this.virtualScrollConfig !== void 0 && (t = new Qe(
4522
+ return this.virtualScrollConfig !== void 0 && (t = new rt(
4467
4523
  t,
4468
4524
  this.graphStore,
4469
4525
  this.boxRenderingTrigger,
4470
- jt(this.virtualScrollConfig)
4471
- )), new Ze(t, this.graphStore);
4526
+ Zt(this.virtualScrollConfig)
4527
+ )), t = new st(t, this.graphStore), t;
4472
4528
  }
4473
4529
  }
4474
4530
  export {
4475
- ft as BezierEdgeShape,
4476
- mr as CanvasBuilder,
4477
- qt as CanvasBuilderError,
4478
- x as CanvasError,
4479
- D as ConnectionCategory,
4480
- Le as DirectEdgeShape,
4481
- Q as EventSubject,
4482
- yt as HorizontalEdgeShape,
4483
- Et as InteractiveEdgeError,
4484
- Ve as InteractiveEdgeShape,
4485
- yr as MidpointEdgeShape,
4486
- mt as StraightEdgeShape,
4487
- vt as VerticalEdgeShape
4531
+ Et as BezierEdgeShape,
4532
+ Nr as CanvasBuilder,
4533
+ Jt as CanvasBuilderError,
4534
+ E as CanvasError,
4535
+ R as ConnectionCategory,
4536
+ Ve as DirectEdgeShape,
4537
+ K as EventSubject,
4538
+ St as HorizontalEdgeShape,
4539
+ Tt as InteractiveEdgeError,
4540
+ Fe as InteractiveEdgeShape,
4541
+ Cr as MidpointEdgeShape,
4542
+ bt as StraightEdgeShape,
4543
+ Pt as VerticalEdgeShape
4488
4544
  };