@html-graph/html-graph 8.16.0 → 8.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,22 @@
1
- var qe = Object.defineProperty;
2
- var et = (r, e, t) => e in r ? qe(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => et(r, typeof e != "symbol" ? e + "" : e, t);
4
- var V = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(V || {});
5
- const tt = () => {
1
+ var tt = Object.defineProperty;
2
+ var rt = (r, e, t) => e in r ? tt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var i = (r, e, t) => rt(r, typeof e != "symbol" ? e + "" : e, t);
4
+ var I = /* @__PURE__ */ ((r) => (r.Line = "line", r.NodeCycle = "node-cycle", r.PortCycle = "port-cycle", r))(I || {});
5
+ const ot = () => {
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
- }, rt = () => {
8
+ }, st = () => {
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
- }, ot = (r) => {
11
+ }, it = (r) => {
12
12
  r.style.position = "absolute", r.style.top = "0", r.style.left = "0", r.style.visibility = "hidden";
13
- }, st = (r) => {
13
+ }, nt = (r) => {
14
14
  r.style.removeProperty("position"), r.style.removeProperty("top"), r.style.removeProperty("left"), r.style.removeProperty("visibility"), r.style.removeProperty("transform");
15
15
  };
16
- class Ce {
16
+ class Te {
17
17
  constructor(e, t, o) {
18
- i(this, "host", tt());
19
- i(this, "container", rt());
18
+ i(this, "host", ot());
19
+ i(this, "container", st());
20
20
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
21
21
  i(this, "attachedNodeIds", /* @__PURE__ */ new Set());
22
22
  i(this, "applyTransform", () => {
@@ -27,11 +27,11 @@ class Ce {
27
27
  }
28
28
  attachNode(e) {
29
29
  const t = this.graphStore.getNode(e);
30
- ot(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
30
+ it(t.element), this.attachedNodeIds.add(e), this.container.appendChild(t.element), this.updateNodePosition(e), this.updateNodePriority(e), t.element.style.visibility = "visible";
31
31
  }
32
32
  detachNode(e) {
33
33
  const t = this.graphStore.getNode(e);
34
- st(t.element), this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
34
+ nt(t.element), this.container.removeChild(t.element), this.attachedNodeIds.delete(e);
35
35
  }
36
36
  attachEdge(e) {
37
37
  const t = this.graphStore.getEdge(e).payload.shape.svg;
@@ -72,8 +72,8 @@ class Ce {
72
72
  h,
73
73
  d
74
74
  ), u = this.createEdgeRenderPort(s, a, h, d);
75
- let g = V.Line;
76
- o.element === s.element ? g = V.PortCycle : o.nodeId === s.nodeId && (g = V.NodeCycle), t.payload.shape.render({ from: c, to: u, category: g });
75
+ let g = I.Line;
76
+ o.element === s.element ? g = I.PortCycle : o.nodeId === s.nodeId && (g = I.NodeCycle), t.payload.shape.render({ from: c, to: u, category: g });
77
77
  }
78
78
  updateEdgePriority(e) {
79
79
  const t = this.graphStore.getEdge(e);
@@ -93,7 +93,7 @@ class Ce {
93
93
  };
94
94
  }
95
95
  }
96
- class it {
96
+ class at {
97
97
  constructor(e) {
98
98
  i(this, "xFrom", 1 / 0);
99
99
  i(this, "yFrom", 1 / 0);
@@ -113,7 +113,7 @@ class it {
113
113
  return h <= this.xTo && d >= this.xFrom && c <= this.yTo && u >= this.yFrom;
114
114
  }
115
115
  }
116
- class nt {
116
+ class ht {
117
117
  constructor(e, t, o, s) {
118
118
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
119
119
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -137,7 +137,7 @@ class nt {
137
137
  this.handleAttachEdge(a);
138
138
  });
139
139
  });
140
- this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = s, this.renderingBox = new it(this.graphStore), this.trigger.subscribe(this.updateViewport);
140
+ this.htmlView = e, this.graphStore = t, this.trigger = o, this.params = s, this.renderingBox = new at(this.graphStore), this.trigger.subscribe(this.updateViewport);
141
141
  }
142
142
  attachNode(e) {
143
143
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -191,7 +191,7 @@ class nt {
191
191
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
192
192
  }
193
193
  }
194
- class at {
194
+ class dt {
195
195
  constructor(e, t) {
196
196
  i(this, "deferredNodes", /* @__PURE__ */ new Set());
197
197
  i(this, "deferredEdges", /* @__PURE__ */ new Set());
@@ -245,7 +245,7 @@ class at {
245
245
  this.isEdgeValid(e) && (this.deferredEdges.delete(e), this.htmlView.attachEdge(e));
246
246
  }
247
247
  }
248
- class _ {
248
+ class q {
249
249
  constructor() {
250
250
  i(this, "callbacks", /* @__PURE__ */ new Set());
251
251
  }
@@ -261,16 +261,16 @@ class _ {
261
261
  });
262
262
  }
263
263
  }
264
- const P = () => {
265
- const r = new _();
264
+ const C = () => {
265
+ const r = new q();
266
266
  return [r, r];
267
267
  };
268
- class Te {
268
+ class Me {
269
269
  constructor(e, t, o, s) {
270
270
  i(this, "beforeDestroyEmitter");
271
271
  i(this, "destroyed", !1);
272
272
  i(this, "onBeforeDestroy");
273
- this.graph = e, this.viewport = t, this.graphController = o, this.viewportController = s, [this.beforeDestroyEmitter, this.onBeforeDestroy] = P();
273
+ this.graph = e, this.viewport = t, this.graphController = o, this.viewportController = s, [this.beforeDestroyEmitter, this.onBeforeDestroy] = C();
274
274
  }
275
275
  addNode(e) {
276
276
  return this.graphController.addNode(e), this;
@@ -318,7 +318,7 @@ class Te {
318
318
  this.destroyed || (this.destroyed = !0, this.beforeDestroyEmitter.emit(), this.graphController.destroy(), this.viewportController.destroy());
319
319
  }
320
320
  }
321
- class ht {
321
+ class ct {
322
322
  constructor() {
323
323
  i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
324
324
  i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -387,7 +387,7 @@ const S = Object.freeze({
387
387
  removeNonexistentEdge: (r) => `Failed to remove edge with ID ${JSON.stringify(r)} because it does not exist`,
388
388
  accessEdgesForNonexistentPort: (r) => `Failed to access edges for port with ID ${JSON.stringify(r)} because the port does not exist`
389
389
  });
390
- class Me {
390
+ class De {
391
391
  constructor() {
392
392
  i(this, "nodes", /* @__PURE__ */ new Map());
393
393
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -396,7 +396,7 @@ class Me {
396
396
  i(this, "portIncomingEdges", /* @__PURE__ */ new Map());
397
397
  i(this, "portOutgoingEdges", /* @__PURE__ */ new Map());
398
398
  i(this, "portCycleEdges", /* @__PURE__ */ new Map());
399
- i(this, "elementPorts", new ht());
399
+ i(this, "elementPorts", new ct());
400
400
  i(this, "edgesElementsMap", /* @__PURE__ */ new Map());
401
401
  i(this, "afterNodeAddedEmitter");
402
402
  i(this, "onAfterNodeAdded");
@@ -424,7 +424,7 @@ class Me {
424
424
  i(this, "onBeforeEdgeRemoved");
425
425
  i(this, "beforeClearEmitter");
426
426
  i(this, "onBeforeClear");
427
- [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = P(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = P(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = P(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = P(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = P(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = P(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = P(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = P(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = P(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = P(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = P(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = P(), [this.beforeClearEmitter, this.onBeforeClear] = P();
427
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = C(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = C(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = C(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = C(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = C(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = C(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = C(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = C(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = C(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = C(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = C(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = C(), [this.beforeClearEmitter, this.onBeforeClear] = C();
428
428
  }
429
429
  hasNode(e) {
430
430
  return this.nodes.has(e);
@@ -682,22 +682,22 @@ class Me {
682
682
  this.portCycleEdges.get(t).delete(e), this.portCycleEdges.get(o).delete(e), this.portIncomingEdges.get(t).delete(e), this.portIncomingEdges.get(o).delete(e), this.portOutgoingEdges.get(t).delete(e), this.portOutgoingEdges.get(o).delete(e), this.edges.delete(e), this.edgesElementsMap.delete(s.shape.svg);
683
683
  }
684
684
  }
685
- const ve = (r) => ({
685
+ const me = (r) => ({
686
686
  scale: 1 / r.scale,
687
687
  x: -r.x / r.scale,
688
688
  y: -r.y / r.scale
689
- }), me = {
689
+ }), xe = {
690
690
  scale: 1,
691
691
  x: 0,
692
692
  y: 0
693
- }, xe = (r, e) => ({
693
+ }, Ee = (r, e) => ({
694
694
  x: r.scale * e.x + r.x,
695
695
  y: r.scale * e.y + r.y
696
696
  });
697
- class dt {
697
+ class lt {
698
698
  constructor(e) {
699
- i(this, "viewportMatrix", me);
700
- i(this, "contentMatrix", me);
699
+ i(this, "viewportMatrix", xe);
700
+ i(this, "contentMatrix", xe);
701
701
  i(this, "beforeUpdateEmitter");
702
702
  i(this, "onBeforeUpdated");
703
703
  i(this, "afterUpdateEmitter");
@@ -707,7 +707,7 @@ class dt {
707
707
  i(this, "observer", new ResizeObserver(() => {
708
708
  this.afterResizeEmitter.emit();
709
709
  }));
710
- this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = P(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = P(), [this.afterResizeEmitter, this.onAfterResize] = P(), this.observer.observe(this.host);
710
+ this.host = e, [this.afterUpdateEmitter, this.onAfterUpdated] = C(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = C(), [this.afterResizeEmitter, this.onAfterResize] = C(), this.observer.observe(this.host);
711
711
  }
712
712
  getViewportMatrix() {
713
713
  return this.viewportMatrix;
@@ -720,30 +720,30 @@ class dt {
720
720
  scale: e.scale ?? this.viewportMatrix.scale,
721
721
  x: e.x ?? this.viewportMatrix.x,
722
722
  y: e.y ?? this.viewportMatrix.y
723
- }, this.beforeUpdateEmitter.emit(), this.contentMatrix = ve(this.viewportMatrix), this.afterUpdateEmitter.emit();
723
+ }, this.beforeUpdateEmitter.emit(), this.contentMatrix = me(this.viewportMatrix), this.afterUpdateEmitter.emit();
724
724
  }
725
725
  patchContentMatrix(e) {
726
726
  this.contentMatrix = {
727
727
  scale: e.scale ?? this.contentMatrix.scale,
728
728
  x: e.x ?? this.contentMatrix.x,
729
729
  y: e.y ?? this.contentMatrix.y
730
- }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = ve(this.contentMatrix), this.afterUpdateEmitter.emit();
730
+ }, this.beforeUpdateEmitter.emit(), this.viewportMatrix = me(this.contentMatrix), this.afterUpdateEmitter.emit();
731
731
  }
732
732
  getDimensions() {
733
733
  const { width: e, height: t } = this.host.getBoundingClientRect();
734
734
  return { width: e, height: t };
735
735
  }
736
736
  createContentCoords(e) {
737
- return xe(this.viewportMatrix, e);
737
+ return Ee(this.viewportMatrix, e);
738
738
  }
739
739
  createViewportCoords(e) {
740
- return xe(this.contentMatrix, e);
740
+ return Ee(this.contentMatrix, e);
741
741
  }
742
742
  destroy() {
743
743
  this.observer.disconnect();
744
744
  }
745
745
  }
746
- class q {
746
+ class ee {
747
747
  constructor(e) {
748
748
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
749
749
  i(this, "nodesResizeObserver");
@@ -769,28 +769,28 @@ class q {
769
769
  }), 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);
770
770
  }
771
771
  static configure(e) {
772
- new q(e);
772
+ new ee(e);
773
773
  }
774
774
  handleNodeResize(e) {
775
775
  const t = this.elementToNodeId.get(e);
776
776
  this.canvas.updateNode(t);
777
777
  }
778
778
  }
779
- const ct = (r, e, t) => {
779
+ const ut = (r, e, t) => {
780
780
  const { x: o, y: s, width: n, height: a } = r.getBoundingClientRect();
781
781
  return e >= o && e <= o + n && t >= s && t <= s + a;
782
- }, lt = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight;
783
- class ut {
782
+ }, gt = (r, e, t) => e >= 0 && e <= r.innerWidth && t >= 0 && t <= r.innerHeight;
783
+ class pt {
784
784
  constructor(e, t) {
785
785
  this.element = e, this.win = t;
786
786
  }
787
787
  verify(e, t) {
788
- return ct(this.element, e, t) && lt(this.win, e, t);
788
+ return ut(this.element, e, t) && gt(this.win, e, t);
789
789
  }
790
790
  }
791
- const k = (r, e) => {
791
+ const H = (r, e) => {
792
792
  e !== null ? r.style.cursor = e : r.style.removeProperty("cursor");
793
- }, H = (r) => {
793
+ }, Y = (r) => {
794
794
  const e = document.createElement("div");
795
795
  return {
796
796
  id: r.overlayNodeId,
@@ -805,7 +805,7 @@ const k = (r, e) => {
805
805
  }
806
806
  ]
807
807
  };
808
- }, gt = (r, e) => {
808
+ }, wt = (r, e) => {
809
809
  let t = e;
810
810
  for (; t !== null; ) {
811
811
  const o = r.findPortIdsByElement(t)[0] ?? null;
@@ -824,21 +824,21 @@ const k = (r, e) => {
824
824
  status: "notFound"
825
825
  };
826
826
  };
827
- function* De(r, e) {
827
+ function* Re(r, e) {
828
828
  const t = r.elementsFromPoint(e.x, e.y);
829
829
  for (const o of t) {
830
830
  if (o.shadowRoot !== null) {
831
- const s = De(o.shadowRoot, e);
831
+ const s = Re(o.shadowRoot, e);
832
832
  for (const n of s)
833
833
  yield n;
834
834
  }
835
835
  yield o;
836
836
  }
837
837
  }
838
- const Re = (r, e) => {
839
- const t = De(document, e);
838
+ const Le = (r, e) => {
839
+ const t = Re(document, e);
840
840
  for (const o of t) {
841
- const s = gt(r, o);
841
+ const s = wt(r, o);
842
842
  if (s.status === "portFound")
843
843
  return s.portId;
844
844
  if (s.status === "nodeEncountered")
@@ -847,13 +847,13 @@ const Re = (r, e) => {
847
847
  return null;
848
848
  };
849
849
  var M = /* @__PURE__ */ ((r) => (r.StaticNodeId = "static", r.DraggingNodeId = "dragging", r.EdgeId = "edge", r))(M || {});
850
- const Le = (r, e) => ({
850
+ const Ve = (r, e) => ({
851
851
  x: r / 2,
852
852
  y: e / 2
853
853
  }), m = (r, e, t) => ({
854
854
  x: e.x * r.x - e.y * r.y + ((1 - e.x) * t.x + e.y * t.y),
855
855
  y: e.y * r.x + e.x * r.y + ((1 - e.x) * t.y - e.y * t.x)
856
- }), Ve = (r, e, t) => {
856
+ }), Ie = (r, e, t) => {
857
857
  const o = {
858
858
  x: r.x + r.width / 2,
859
859
  y: r.y + r.height / 2
@@ -870,7 +870,7 @@ const Le = (r, e) => ({
870
870
  to: { x: s.x - n, y: s.y - a }
871
871
  };
872
872
  };
873
- class pt {
873
+ class yt {
874
874
  constructor(e) {
875
875
  i(this, "path");
876
876
  i(this, "midpoint");
@@ -889,21 +889,21 @@ class pt {
889
889
  { x: t.x + s, y: t.y },
890
890
  n,
891
891
  t
892
- ), w = m(
892
+ ), p = m(
893
893
  { x: o.x - s, y: o.y },
894
894
  a,
895
895
  o
896
- ), p = {
896
+ ), w = {
897
897
  x: l.x + n.x * h,
898
898
  y: l.y + n.y * h
899
899
  }, y = {
900
- x: w.x - a.x * h,
901
- y: w.y - a.y * h
902
- }, f = `M ${l.x} ${l.y} C ${p.x} ${p.y}, ${y.x} ${y.y}, ${w.x} ${w.y}`, x = d ? "" : `M ${t.x} ${t.y} L ${l.x} ${l.y} `, E = c ? "" : ` M ${w.x} ${w.y} L ${o.x} ${o.y}`;
900
+ x: p.x - a.x * h,
901
+ y: p.y - a.y * h
902
+ }, f = `M ${l.x} ${l.y} C ${w.x} ${w.y}, ${y.x} ${y.y}, ${p.x} ${p.y}`, x = d ? "" : `M ${t.x} ${t.y} L ${l.x} ${l.y} `, E = c ? "" : ` M ${p.x} ${p.y} L ${o.x} ${o.y}`;
903
903
  this.path = `${x}${f}${E}`;
904
904
  }
905
905
  }
906
- class wt {
906
+ class ft {
907
907
  constructor(e) {
908
908
  i(this, "path");
909
909
  i(this, "midpoint");
@@ -922,85 +922,85 @@ class wt {
922
922
  { x: d.x + u, y: d.y },
923
923
  n,
924
924
  d
925
- ) : d, w = o ? m(
925
+ ) : d, p = o ? m(
926
926
  {
927
927
  x: c.x - u,
928
928
  y: c.y
929
929
  },
930
930
  a,
931
931
  c
932
- ) : c, p = Math.cos(h) * g, y = Math.sin(h) * g, f = m(
932
+ ) : c, w = Math.cos(h) * g, y = Math.sin(h) * g, f = m(
933
933
  { x: d.x + u, y: d.y },
934
934
  n,
935
935
  d
936
936
  ), x = {
937
- x: f.x + p,
937
+ x: f.x + w,
938
938
  y: f.y + y
939
939
  }, E = m(
940
940
  { x: c.x - u, y: c.y },
941
941
  a,
942
942
  c
943
- ), N = {
944
- x: E.x + p,
943
+ ), P = {
944
+ x: E.x + w,
945
945
  y: E.y + y
946
- }, C = {
947
- x: (x.x + N.x) / 2,
948
- y: (x.y + N.y) / 2
949
946
  }, T = {
947
+ x: (x.x + P.x) / 2,
948
+ y: (x.y + P.y) / 2
949
+ }, D = {
950
950
  x: f.x + s * n.x,
951
951
  y: f.y + s * n.y
952
- }, I = {
952
+ }, F = {
953
953
  x: E.x - s * a.x,
954
954
  y: E.y - s * a.y
955
- }, F = {
956
- x: f.x + p,
957
- y: f.y + y
958
955
  }, U = {
959
- x: E.x + p,
956
+ x: f.x + w,
957
+ y: f.y + y
958
+ }, R = {
959
+ x: E.x + w,
960
960
  y: E.y + y
961
961
  };
962
962
  this.path = [
963
963
  `M ${l.x} ${l.y}`,
964
964
  `L ${f.x} ${f.y}`,
965
- `C ${T.x} ${T.y} ${F.x} ${F.y} ${C.x} ${C.y}`,
966
- `C ${U.x} ${U.y} ${I.x} ${I.y} ${E.x} ${E.y}`,
967
- `L ${w.x} ${w.y}`
968
- ].join(" "), this.midpoint = C;
965
+ `C ${D.x} ${D.y} ${U.x} ${U.y} ${T.x} ${T.y}`,
966
+ `C ${R.x} ${R.y} ${F.x} ${F.y} ${E.x} ${E.y}`,
967
+ `L ${p.x} ${p.y}`
968
+ ].join(" "), this.midpoint = T;
969
969
  }
970
970
  }
971
- const ee = Object.freeze({
971
+ const te = Object.freeze({
972
972
  edgeColor: "--edge-color"
973
- }), Ie = (r) => {
973
+ }), Fe = (r) => {
974
974
  const e = document.createElementNS("http://www.w3.org/2000/svg", "svg");
975
- return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(ee.edgeColor, r), e;
976
- }, Fe = (r) => {
975
+ return e.style.pointerEvents = "none", e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.overflow = "visible", e.style.setProperty(te.edgeColor, r), e;
976
+ }, Ue = (r) => {
977
977
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
978
- return e.setAttribute("stroke", `var(${ee.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
979
- }, Y = () => {
978
+ return e.setAttribute("stroke", `var(${te.edgeColor})`), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e;
979
+ }, X = () => {
980
980
  const r = document.createElementNS("http://www.w3.org/2000/svg", "path");
981
- return r.setAttribute("fill", `var(${ee.edgeColor})`), r;
982
- }, Ue = (r, e) => {
981
+ return r.setAttribute("fill", `var(${te.edgeColor})`), r;
982
+ }, $e = (r, e) => {
983
983
  r.style.transform = `translate(${e.x}px, ${e.y}px)`, r.style.width = `${e.width}px`, r.style.height = `${e.height}px`;
984
- }, L = (r, e) => {
984
+ }, V = (r, e) => {
985
985
  const t = [];
986
986
  if (r.length > 0 && t.push(`M ${r[0].x} ${r[0].y}`), r.length === 2 && t.push(`L ${r[1].x} ${r[1].y}`), r.length > 2) {
987
987
  const o = r.length - 1;
988
988
  let s = 0, n = 0, a = 0;
989
989
  r.forEach((h, d) => {
990
990
  let c = 0, u = 0, g = 0;
991
- const l = d > 0, w = d < o, p = l && w;
992
- if (l && (c = -s, u = -n, g = a), w) {
993
- const T = r[d + 1];
994
- s = T.x - h.x, n = T.y - h.y, a = Math.sqrt(s * s + n * n);
991
+ const l = d > 0, p = d < o, w = l && p;
992
+ if (l && (c = -s, u = -n, g = a), p) {
993
+ const D = r[d + 1];
994
+ s = D.x - h.x, n = D.y - h.y, a = Math.sqrt(s * s + n * n);
995
995
  }
996
- const f = a !== 0 ? Math.min((p ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, x = p ? { x: h.x + s * f, y: h.y + n * f } : h, N = g !== 0 ? Math.min((p ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, C = p ? { x: h.x + c * N, y: h.y + u * N } : h;
997
- d > 0 && t.push(`L ${C.x} ${C.y}`), p && t.push(
996
+ const f = a !== 0 ? Math.min((w ? e : 0) / a, d < o - 1 ? 0.5 : 1) : 0, x = w ? { x: h.x + s * f, y: h.y + n * f } : h, P = g !== 0 ? Math.min((w ? e : 0) / g, d > 1 ? 0.5 : 1) : 0, T = w ? { x: h.x + c * P, y: h.y + u * P } : h;
997
+ d > 0 && t.push(`L ${T.x} ${T.y}`), w && t.push(
998
998
  `C ${h.x} ${h.y} ${h.x} ${h.y} ${x.x} ${x.y}`
999
999
  );
1000
1000
  });
1001
1001
  }
1002
1002
  return t.join(" ");
1003
- }, yt = (r, e) => {
1003
+ }, vt = (r, e) => {
1004
1004
  const t = e.x - r.x >= 0, o = r.dirX >= 0, s = e.dirX >= 0;
1005
1005
  if (o === s) {
1006
1006
  const c = o === t, u = (r.x + e.x) / 2, g = (r.y + e.y) / 2, l = { x: u, y: g };
@@ -1036,7 +1036,7 @@ const ee = Object.freeze({
1036
1036
  midpoint: { x: d.x, y: h }
1037
1037
  };
1038
1038
  };
1039
- class ft {
1039
+ class mt {
1040
1040
  constructor(e) {
1041
1041
  i(this, "path");
1042
1042
  i(this, "midpoint");
@@ -1061,14 +1061,14 @@ class ft {
1061
1061
  },
1062
1062
  n,
1063
1063
  o
1064
- ) : o, w = a + h, p = m(
1065
- { x: t.x + w, y: t.y },
1064
+ ) : o, p = a + h, w = m(
1065
+ { x: t.x + p, y: t.y },
1066
1066
  s,
1067
1067
  t
1068
- ), y = m({ x: o.x - w, y: o.y }, n, o), f = yt(
1068
+ ), y = m({ x: o.x - p, y: o.y }, n, o), f = vt(
1069
1069
  {
1070
- x: p.x,
1071
- y: p.y,
1070
+ x: w.x,
1071
+ y: w.y,
1072
1072
  dirX: s.x
1073
1073
  },
1074
1074
  {
@@ -1077,13 +1077,13 @@ class ft {
1077
1077
  dirX: n.x
1078
1078
  }
1079
1079
  );
1080
- this.path = L(
1080
+ this.path = V(
1081
1081
  [g, ...f.points, l],
1082
1082
  d
1083
1083
  ), this.midpoint = f.midpoint;
1084
1084
  }
1085
1085
  }
1086
- class vt {
1086
+ class xt {
1087
1087
  constructor(e) {
1088
1088
  i(this, "path");
1089
1089
  i(this, "midpoint");
@@ -1099,11 +1099,11 @@ class vt {
1099
1099
  detourDir: u,
1100
1100
  detourDistance: g,
1101
1101
  roundness: l
1102
- } = e, w = t ? m(
1102
+ } = e, p = t ? m(
1103
1103
  { x: s.x + a, y: s.y },
1104
1104
  h,
1105
1105
  s
1106
- ) : s, p = o ? m(
1106
+ ) : s, w = o ? m(
1107
1107
  {
1108
1108
  x: n.x - a,
1109
1109
  y: n.y
@@ -1114,27 +1114,27 @@ class vt {
1114
1114
  { x: s.x + y, y: s.y },
1115
1115
  h,
1116
1116
  s
1117
- ), N = {
1117
+ ), P = {
1118
1118
  x: E.x + f,
1119
1119
  y: E.y + x
1120
- }, C = m(
1120
+ }, T = m(
1121
1121
  { x: n.x - y, y: n.y },
1122
1122
  d,
1123
1123
  n
1124
- ), T = {
1125
- x: C.x + f,
1126
- y: C.y + x
1124
+ ), D = {
1125
+ x: T.x + f,
1126
+ y: T.y + x
1127
1127
  };
1128
1128
  this.midpoint = {
1129
- x: (N.x + T.x) / 2,
1130
- y: (N.y + T.y) / 2
1131
- }, this.path = L(
1132
- [w, E, N, T, C, p],
1129
+ x: (P.x + D.x) / 2,
1130
+ y: (P.y + D.y) / 2
1131
+ }, this.path = V(
1132
+ [p, E, P, D, T, w],
1133
1133
  l
1134
1134
  );
1135
1135
  }
1136
1136
  }
1137
- class mt {
1137
+ class Et {
1138
1138
  constructor(e) {
1139
1139
  i(this, "path");
1140
1140
  i(this, "midpoint");
@@ -1158,13 +1158,13 @@ class mt {
1158
1158
  d,
1159
1159
  o,
1160
1160
  -a
1161
- ), w = a + c, p = { x: t.x + w, y: t.y }, y = m(p, h, t), f = { x: o.x - w, y: o.y }, x = m(f, d, o);
1162
- this.path = L(
1161
+ ), p = a + c, w = { x: t.x + p, y: t.y }, y = m(w, h, t), f = { x: o.x - p, y: o.y }, x = m(f, d, o);
1162
+ this.path = V(
1163
1163
  [g, y, x, l],
1164
1164
  u
1165
1165
  );
1166
- const E = (y.x + x.x) / 2, N = (y.y + x.y) / 2;
1167
- this.midpoint = { x: E, y: N };
1166
+ const E = (y.x + x.x) / 2, P = (y.y + x.y) / 2;
1167
+ this.midpoint = { x: E, y: P };
1168
1168
  }
1169
1169
  createArrowPoint(e, t, o, s) {
1170
1170
  if (!e)
@@ -1176,7 +1176,7 @@ class mt {
1176
1176
  return m(n, t, o);
1177
1177
  }
1178
1178
  }
1179
- const xt = (r, e) => {
1179
+ const At = (r, e) => {
1180
1180
  const t = e.y - r.y >= 0, o = r.dirY >= 0, s = e.dirY >= 0;
1181
1181
  if (o === s) {
1182
1182
  const c = o === t, u = (r.x + e.x) / 2, g = (r.y + e.y) / 2, l = { x: u, y: g };
@@ -1212,7 +1212,7 @@ const xt = (r, e) => {
1212
1212
  midpoint: { x: h, y: d.y }
1213
1213
  };
1214
1214
  };
1215
- class Et {
1215
+ class St {
1216
1216
  constructor(e) {
1217
1217
  i(this, "path");
1218
1218
  i(this, "midpoint");
@@ -1237,14 +1237,14 @@ class Et {
1237
1237
  },
1238
1238
  c,
1239
1239
  o
1240
- ) : o, w = a + h, p = m(
1241
- { x: t.x + w, y: t.y },
1240
+ ) : o, p = a + h, w = m(
1241
+ { x: t.x + p, y: t.y },
1242
1242
  d,
1243
1243
  t
1244
- ), y = m({ x: o.x - w, y: o.y }, c, o), f = xt(
1244
+ ), y = m({ x: o.x - p, y: o.y }, c, o), f = At(
1245
1245
  {
1246
- x: p.x,
1247
- y: p.y,
1246
+ x: w.x,
1247
+ y: w.y,
1248
1248
  dirY: d.y
1249
1249
  },
1250
1250
  {
@@ -1253,13 +1253,13 @@ class Et {
1253
1253
  dirY: c.y
1254
1254
  }
1255
1255
  );
1256
- this.path = L(
1256
+ this.path = V(
1257
1257
  [g, ...f.points, l],
1258
1258
  u
1259
1259
  ), this.midpoint = f.midpoint;
1260
1260
  }
1261
1261
  }
1262
- class te {
1262
+ class re {
1263
1263
  constructor(e) {
1264
1264
  i(this, "path");
1265
1265
  i(this, "midpoint");
@@ -1272,18 +1272,18 @@ class te {
1272
1272
  { x: d, y: -t },
1273
1273
  { x: d, y: 0 },
1274
1274
  { x: o, y: 0 }
1275
- ].map((w) => m(w, n, { x: 0, y: 0 })).map((w) => ({ x: w.x + a.x, y: w.y + a.y })), l = `M ${a.x} ${a.y} L ${g[0].x} ${g[0].y} `;
1276
- this.path = `${h ? "" : l}${L(g, e.roundness)}`, this.midpoint = { x: (g[3].x + g[4].x) / 2, y: (g[3].y + g[4].y) / 2 };
1275
+ ].map((p) => m(p, n, { x: 0, y: 0 })).map((p) => ({ x: p.x + a.x, y: p.y + a.y })), l = `M ${a.x} ${a.y} L ${g[0].x} ${g[0].y} `;
1276
+ this.path = `${h ? "" : l}${V(g, e.roundness)}`, this.midpoint = { x: (g[3].x + g[4].x) / 2, y: (g[3].y + g[4].y) / 2 };
1277
1277
  }
1278
1278
  }
1279
- class At {
1279
+ class bt {
1280
1280
  constructor(e) {
1281
1281
  i(this, "path");
1282
1282
  i(this, "midpoint");
1283
- const { arrowLength: t, radius: o, smallRadius: s, dir: n, origin: a, hasArrow: h } = e, d = s + o, c = s * o / d, u = Math.sqrt(d * d - s * s), g = u * s / d, l = u + o + t, w = t + g, y = [
1283
+ const { arrowLength: t, radius: o, smallRadius: s, dir: n, origin: a, hasArrow: h } = e, d = s + o, c = s * o / d, u = Math.sqrt(d * d - s * s), g = u * s / d, l = u + o + t, p = t + g, y = [
1284
1284
  { x: t, y: 0 },
1285
- { x: w, y: c },
1286
- { x: w, y: -c },
1285
+ { x: p, y: c },
1286
+ { x: p, y: -c },
1287
1287
  { x: l, y: 0 }
1288
1288
  ].map((E) => m(E, n, { x: 0, y: 0 })).map((E) => ({ x: E.x + a.x, y: E.y + a.y })), f = [
1289
1289
  `M ${y[0].x} ${y[0].y}`,
@@ -1294,7 +1294,7 @@ class At {
1294
1294
  this.path = `${h ? "" : x}${f}`, this.midpoint = y[3];
1295
1295
  }
1296
1296
  }
1297
- class St {
1297
+ class Nt {
1298
1298
  constructor(e) {
1299
1299
  i(this, "path");
1300
1300
  i(this, "midpoint");
@@ -1321,7 +1321,7 @@ class St {
1321
1321
  shift: t,
1322
1322
  arrowLength: d,
1323
1323
  dir: g
1324
- }), w = this.createDirectLinePoint({
1324
+ }), p = this.createDirectLinePoint({
1325
1325
  offset: n,
1326
1326
  hasArrow: h,
1327
1327
  flip: -1,
@@ -1329,7 +1329,7 @@ class St {
1329
1329
  arrowLength: d,
1330
1330
  dir: g
1331
1331
  });
1332
- this.path = `M ${l.x} ${l.y} L ${w.x} ${w.y}`;
1332
+ this.path = `M ${l.x} ${l.y} L ${p.x} ${p.y}`;
1333
1333
  }
1334
1334
  createDirectLinePoint(e) {
1335
1335
  const t = e.hasArrow ? e.arrowLength : 0, o = e.offset + t, s = e.flip * o / this.diagonalDistance, { dir: n, shift: a } = e;
@@ -1339,11 +1339,11 @@ class St {
1339
1339
  };
1340
1340
  }
1341
1341
  }
1342
- const bt = (r, e, t) => {
1342
+ const Pt = (r, e, t) => {
1343
1343
  const o = Math.max(r.y, e.y), s = Math.min(r.y, e.y);
1344
1344
  return (t >= 0 ? o : s) + t;
1345
1345
  };
1346
- class Nt {
1346
+ class Ct {
1347
1347
  constructor(e) {
1348
1348
  i(this, "path");
1349
1349
  i(this, "midpoint");
@@ -1362,43 +1362,43 @@ class Nt {
1362
1362
  { x: n.x + s, y: n.y },
1363
1363
  h,
1364
1364
  n
1365
- ) : n, w = o ? m(
1365
+ ) : n, p = o ? m(
1366
1366
  {
1367
1367
  x: a.x - s,
1368
1368
  y: a.y
1369
1369
  },
1370
1370
  d,
1371
1371
  a
1372
- ) : a, p = s + c, y = m(
1373
- { x: n.x + p, y: n.y },
1372
+ ) : a, w = s + c, y = m(
1373
+ { x: n.x + w, y: n.y },
1374
1374
  h,
1375
1375
  n
1376
1376
  ), f = m(
1377
- { x: a.x - p, y: a.y },
1377
+ { x: a.x - w, y: a.y },
1378
1378
  d,
1379
1379
  a
1380
- ), x = bt(y, f, g);
1380
+ ), x = Pt(y, f, g);
1381
1381
  this.midpoint = {
1382
1382
  x: (y.x + f.x) / 2,
1383
1383
  y: x
1384
- }, this.path = L(
1384
+ }, this.path = V(
1385
1385
  [
1386
1386
  l,
1387
1387
  y,
1388
1388
  { x: y.x, y: x },
1389
1389
  { x: f.x, y: x },
1390
1390
  f,
1391
- w
1391
+ p
1392
1392
  ],
1393
1393
  u
1394
1394
  );
1395
1395
  }
1396
1396
  }
1397
- const Pt = (r, e, t) => {
1397
+ const Tt = (r, e, t) => {
1398
1398
  const o = Math.max(r.x, e.x), s = Math.min(r.x, e.x);
1399
1399
  return (t >= 0 ? o : s) + t;
1400
1400
  };
1401
- class Ct {
1401
+ class Mt {
1402
1402
  constructor(e) {
1403
1403
  i(this, "path");
1404
1404
  i(this, "midpoint");
@@ -1417,33 +1417,33 @@ class Ct {
1417
1417
  { x: h.x + s, y: h.y },
1418
1418
  n,
1419
1419
  h
1420
- ) : h, w = o ? m(
1420
+ ) : h, p = o ? m(
1421
1421
  {
1422
1422
  x: d.x - s,
1423
1423
  y: d.y
1424
1424
  },
1425
1425
  a,
1426
1426
  d
1427
- ) : d, p = s + c, y = m(
1428
- { x: h.x + p, y: h.y },
1427
+ ) : d, w = s + c, y = m(
1428
+ { x: h.x + w, y: h.y },
1429
1429
  n,
1430
1430
  h
1431
1431
  ), f = m(
1432
- { x: d.x - p, y: d.y },
1432
+ { x: d.x - w, y: d.y },
1433
1433
  a,
1434
1434
  d
1435
- ), x = Pt(y, f, u);
1435
+ ), x = Tt(y, f, u);
1436
1436
  this.midpoint = {
1437
1437
  x,
1438
1438
  y: (y.y + f.y) / 2
1439
- }, this.path = L(
1439
+ }, this.path = V(
1440
1440
  [
1441
1441
  l,
1442
1442
  y,
1443
1443
  { x, y: y.y },
1444
1444
  { x, y: f.y },
1445
1445
  f,
1446
- w
1446
+ p
1447
1447
  ],
1448
1448
  g
1449
1449
  );
@@ -1471,8 +1471,8 @@ const v = Object.freeze({
1471
1471
  curvature: 90,
1472
1472
  interactiveWidth: 10,
1473
1473
  preOffset: 0
1474
- }), Ee = (r) => ({ x: Math.cos(r), y: Math.sin(r) });
1475
- class X {
1474
+ }), Ae = (r) => ({ x: Math.cos(r), y: Math.sin(r) });
1475
+ class G {
1476
1476
  constructor(e) {
1477
1477
  i(this, "svg");
1478
1478
  i(this, "group", document.createElementNS(
@@ -1485,39 +1485,39 @@ class X {
1485
1485
  i(this, "onAfterRender");
1486
1486
  i(this, "afterRenderEmitter");
1487
1487
  i(this, "arrowRenderer");
1488
- this.params = e, [this.afterRenderEmitter, this.onAfterRender] = P(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Ie(e.color), this.svg.appendChild(this.group), this.line = Fe(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = Y(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = Y(), this.group.appendChild(this.targetArrow));
1488
+ this.params = e, [this.afterRenderEmitter, this.onAfterRender] = C(), this.arrowRenderer = this.params.arrowRenderer, this.svg = Fe(e.color), this.svg.appendChild(this.group), this.line = Ue(e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = X(), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = X(), this.group.appendChild(this.targetArrow));
1489
1489
  }
1490
1490
  render(e) {
1491
- const { x: t, y: o, width: s, height: n, from: a, to: h } = Ve(
1491
+ const { x: t, y: o, width: s, height: n, from: a, to: h } = Ie(
1492
1492
  e.from,
1493
1493
  e.to,
1494
1494
  this.params.padding
1495
1495
  );
1496
- Ue(this.svg, { x: t, y: o, width: s, height: n });
1497
- const d = Ee(e.from.direction), c = Ee(e.to.direction);
1496
+ $e(this.svg, { x: t, y: o, width: s, height: n });
1497
+ const d = Ae(e.from.direction), c = Ae(e.to.direction);
1498
1498
  let u = { x: -c.x, y: -c.y }, g;
1499
- e.category === V.PortCycle ? (g = this.params.createCyclePath, u = d) : e.category === V.NodeCycle ? g = this.params.createDetourPath : g = this.params.createLinePath;
1499
+ e.category === I.PortCycle ? (g = this.params.createCyclePath, u = d) : e.category === I.NodeCycle ? g = this.params.createDetourPath : g = this.params.createLinePath;
1500
1500
  const l = g(a, h, d, c);
1501
1501
  this.line.setAttribute("d", l.path);
1502
- let w = null;
1503
- this.sourceArrow && (w = this.arrowRenderer({
1502
+ let p = null;
1503
+ this.sourceArrow && (p = this.arrowRenderer({
1504
1504
  direction: d,
1505
1505
  shift: a,
1506
1506
  arrowLength: this.params.arrowLength
1507
- }), this.sourceArrow.setAttribute("d", w));
1508
- let p = null;
1509
- this.targetArrow && (p = this.arrowRenderer({
1507
+ }), this.sourceArrow.setAttribute("d", p));
1508
+ let w = null;
1509
+ this.targetArrow && (w = this.arrowRenderer({
1510
1510
  direction: u,
1511
1511
  shift: h,
1512
1512
  arrowLength: this.params.arrowLength
1513
- }), this.targetArrow.setAttribute("d", p)), this.afterRenderEmitter.emit({
1513
+ }), this.targetArrow.setAttribute("d", w)), this.afterRenderEmitter.emit({
1514
1514
  edgePath: l,
1515
- sourceArrowPath: w,
1516
- targetArrowPath: p
1515
+ sourceArrowPath: p,
1516
+ targetArrowPath: w
1517
1517
  });
1518
1518
  }
1519
1519
  }
1520
- const Tt = (r) => (e) => {
1520
+ const Dt = (r) => (e) => {
1521
1521
  const o = [
1522
1522
  { x: 0, y: 0 },
1523
1523
  { x: e.arrowLength, y: r.radius },
@@ -1529,19 +1529,19 @@ const Tt = (r) => (e) => {
1529
1529
  y: h.y + e.shift.y
1530
1530
  })), s = `M ${o[0].x} ${o[0].y}`, n = `L ${o[1].x} ${o[1].y}`, a = `L ${o[2].x} ${o[2].y}`;
1531
1531
  return `${s} ${n} ${a} Z`;
1532
- }, Mt = (r) => (e) => {
1532
+ }, Rt = (r) => (e) => {
1533
1533
  const t = r.radius, o = e.arrowLength, s = (o * o + 2 * o * t) / (2 * t), n = s + t, a = o + t - t * (o + t) / n, h = t * s / n, c = [
1534
1534
  { x: 0, y: 0 },
1535
1535
  { x: a, y: -h },
1536
1536
  { x: a, y: h }
1537
1537
  ].map(
1538
- (p) => m(p, e.direction, { x: 0, y: 0 })
1539
- ).map((p) => ({
1540
- x: p.x + e.shift.x,
1541
- y: p.y + e.shift.y
1542
- })), u = `M ${c[0].x} ${c[0].y}`, g = `A ${s} ${s} 0 0 0 ${c[1].x} ${c[1].y}`, l = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, w = `A ${s} ${s} 0 0 0 ${c[0].x} ${c[0].y}`;
1543
- return `${u} ${g} ${l} ${w}`;
1544
- }, Dt = (r) => (e) => {
1538
+ (w) => m(w, e.direction, { x: 0, y: 0 })
1539
+ ).map((w) => ({
1540
+ x: w.x + e.shift.x,
1541
+ y: w.y + e.shift.y
1542
+ })), u = `M ${c[0].x} ${c[0].y}`, g = `A ${s} ${s} 0 0 0 ${c[1].x} ${c[1].y}`, l = `A ${t} ${t} 0 0 0 ${c[2].x} ${c[2].y}`, p = `A ${s} ${s} 0 0 0 ${c[0].x} ${c[0].y}`;
1543
+ return `${u} ${g} ${l} ${p}`;
1544
+ }, Lt = (r) => (e) => {
1545
1545
  const t = r.smallRadius, o = r.radius, s = m(
1546
1546
  {
1547
1547
  x: e.arrowLength,
@@ -1567,22 +1567,22 @@ const Tt = (r) => (e) => {
1567
1567
  return r;
1568
1568
  switch (r.type) {
1569
1569
  case "triangle":
1570
- return Tt({
1570
+ return Dt({
1571
1571
  radius: r.radius ?? v.polygonArrowRadius
1572
1572
  });
1573
1573
  case "arc":
1574
- return Mt({
1574
+ return Rt({
1575
1575
  radius: r.radius ?? v.circleArrowRadius
1576
1576
  });
1577
1577
  default:
1578
- return Dt({
1578
+ return Lt({
1579
1579
  smallRadius: r.smallRadius ?? v.wedgeArrowSmallRadius,
1580
1580
  angle: r.angle ?? v.wedgeArrowAngle,
1581
1581
  radius: r.radius ?? v.wedgeArrowRadius
1582
1582
  });
1583
1583
  }
1584
1584
  }, O = 50;
1585
- class Rt {
1585
+ class Vt {
1586
1586
  constructor(e) {
1587
1587
  i(this, "svg");
1588
1588
  i(this, "group");
@@ -1599,7 +1599,7 @@ class Rt {
1599
1599
  i(this, "hasSourceArrow");
1600
1600
  i(this, "hasTargetArrow");
1601
1601
  i(this, "pathShape");
1602
- i(this, "createCyclePath", (e, t, o) => new At({
1602
+ i(this, "createCyclePath", (e, t, o) => new bt({
1603
1603
  origin: e,
1604
1604
  dir: o,
1605
1605
  radius: this.portCycleRadius,
@@ -1607,7 +1607,7 @@ class Rt {
1607
1607
  arrowLength: this.arrowLength,
1608
1608
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1609
1609
  }));
1610
- i(this, "createDetourPath", (e, t, o, s) => new wt({
1610
+ i(this, "createDetourPath", (e, t, o, s) => new ft({
1611
1611
  from: e,
1612
1612
  to: t,
1613
1613
  fromDir: o,
@@ -1619,7 +1619,7 @@ class Rt {
1619
1619
  hasSourceArrow: this.hasSourceArrow,
1620
1620
  hasTargetArrow: this.hasTargetArrow
1621
1621
  }));
1622
- i(this, "createLinePath", (e, t, o, s) => new pt({
1622
+ i(this, "createLinePath", (e, t, o, s) => new yt({
1623
1623
  from: e,
1624
1624
  to: t,
1625
1625
  fromDir: o,
@@ -1629,7 +1629,7 @@ class Rt {
1629
1629
  hasSourceArrow: this.hasSourceArrow,
1630
1630
  hasTargetArrow: this.hasTargetArrow
1631
1631
  }));
1632
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? v.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? v.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? v.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1632
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.curvature = (e == null ? void 0 : e.curvature) ?? v.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? v.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? v.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new G({
1633
1633
  color: (e == null ? void 0 : e.color) ?? v.color,
1634
1634
  width: (e == null ? void 0 : e.width) ?? v.width,
1635
1635
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1646,7 +1646,7 @@ class Rt {
1646
1646
  this.pathShape.render(e);
1647
1647
  }
1648
1648
  }
1649
- class Lt {
1649
+ class It {
1650
1650
  constructor(e) {
1651
1651
  i(this, "svg");
1652
1652
  i(this, "group");
@@ -1662,7 +1662,7 @@ class Lt {
1662
1662
  i(this, "hasSourceArrow");
1663
1663
  i(this, "hasTargetArrow");
1664
1664
  i(this, "pathShape");
1665
- i(this, "createCyclePath", (e, t, o) => new te({
1665
+ i(this, "createCyclePath", (e, t, o) => new re({
1666
1666
  origin: e,
1667
1667
  dir: o,
1668
1668
  arrowLength: this.arrowLength,
@@ -1671,7 +1671,7 @@ class Lt {
1671
1671
  roundness: this.roundness,
1672
1672
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1673
1673
  }));
1674
- i(this, "createDetourPath", (e, t, o, s) => new Nt({
1674
+ i(this, "createDetourPath", (e, t, o, s) => new Ct({
1675
1675
  from: e,
1676
1676
  to: t,
1677
1677
  fromDir: o,
@@ -1683,7 +1683,7 @@ class Lt {
1683
1683
  hasSourceArrow: this.hasSourceArrow,
1684
1684
  hasTargetArrow: this.hasTargetArrow
1685
1685
  }));
1686
- i(this, "createLinePath", (e, t, o, s) => new ft({
1686
+ i(this, "createLinePath", (e, t, o, s) => new mt({
1687
1687
  from: e,
1688
1688
  to: t,
1689
1689
  fromDir: o,
@@ -1700,7 +1700,7 @@ class Lt {
1700
1700
  t,
1701
1701
  this.arrowOffset,
1702
1702
  this.cycleSquareSide / 2
1703
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1703
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new G({
1704
1704
  color: (e == null ? void 0 : e.color) ?? v.color,
1705
1705
  width: (e == null ? void 0 : e.width) ?? v.width,
1706
1706
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1717,7 +1717,7 @@ class Lt {
1717
1717
  this.pathShape.render(e);
1718
1718
  }
1719
1719
  }
1720
- class Vt {
1720
+ class Ft {
1721
1721
  constructor(e) {
1722
1722
  i(this, "svg");
1723
1723
  i(this, "group");
@@ -1734,7 +1734,7 @@ class Vt {
1734
1734
  i(this, "hasSourceArrow");
1735
1735
  i(this, "hasTargetArrow");
1736
1736
  i(this, "pathShape");
1737
- i(this, "createCyclePath", (e, t, o) => new te({
1737
+ i(this, "createCyclePath", (e, t, o) => new re({
1738
1738
  origin: e,
1739
1739
  dir: o,
1740
1740
  arrowLength: this.arrowLength,
@@ -1743,7 +1743,7 @@ class Vt {
1743
1743
  roundness: this.roundness,
1744
1744
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1745
1745
  }));
1746
- i(this, "createDetourPath", (e, t, o, s) => new vt({
1746
+ i(this, "createDetourPath", (e, t, o, s) => new xt({
1747
1747
  from: e,
1748
1748
  to: t,
1749
1749
  fromDir: o,
@@ -1756,7 +1756,7 @@ class Vt {
1756
1756
  hasSourceArrow: this.hasSourceArrow,
1757
1757
  hasTargetArrow: this.hasTargetArrow
1758
1758
  }));
1759
- i(this, "createLinePath", (e, t, o, s) => new mt({
1759
+ i(this, "createLinePath", (e, t, o, s) => new Et({
1760
1760
  from: e,
1761
1761
  to: t,
1762
1762
  fromDir: o,
@@ -1773,7 +1773,7 @@ class Vt {
1773
1773
  t,
1774
1774
  this.arrowOffset,
1775
1775
  this.cycleSquareSide / 2
1776
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1776
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? v.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new G({
1777
1777
  color: (e == null ? void 0 : e.color) ?? v.color,
1778
1778
  width: (e == null ? void 0 : e.width) ?? v.width,
1779
1779
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1790,7 +1790,7 @@ class Vt {
1790
1790
  this.pathShape.render(e);
1791
1791
  }
1792
1792
  }
1793
- class It {
1793
+ class Ut {
1794
1794
  constructor(e) {
1795
1795
  i(this, "svg");
1796
1796
  i(this, "group");
@@ -1806,7 +1806,7 @@ class It {
1806
1806
  i(this, "hasSourceArrow");
1807
1807
  i(this, "hasTargetArrow");
1808
1808
  i(this, "pathShape");
1809
- i(this, "createCyclePath", (e, t, o) => new te({
1809
+ i(this, "createCyclePath", (e, t, o) => new re({
1810
1810
  origin: e,
1811
1811
  dir: o,
1812
1812
  arrowLength: this.arrowLength,
@@ -1815,7 +1815,7 @@ class It {
1815
1815
  roundness: this.roundness,
1816
1816
  hasArrow: this.hasSourceArrow || this.hasTargetArrow
1817
1817
  }));
1818
- i(this, "createDetourPath", (e, t, o, s) => new Ct({
1818
+ i(this, "createDetourPath", (e, t, o, s) => new Mt({
1819
1819
  from: e,
1820
1820
  to: t,
1821
1821
  fromDir: o,
@@ -1827,7 +1827,7 @@ class It {
1827
1827
  hasSourceArrow: this.hasSourceArrow,
1828
1828
  hasTargetArrow: this.hasTargetArrow
1829
1829
  }));
1830
- i(this, "createLinePath", (e, t, o, s) => new Et({
1830
+ i(this, "createLinePath", (e, t, o, s) => new St({
1831
1831
  from: e,
1832
1832
  to: t,
1833
1833
  fromDir: o,
@@ -1844,7 +1844,7 @@ class It {
1844
1844
  t,
1845
1845
  this.arrowOffset,
1846
1846
  this.cycleSquareSide / 2
1847
- ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new X({
1847
+ ), this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? v.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? v.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? v.hasTargetArrow, this.pathShape = new G({
1848
1848
  color: (e == null ? void 0 : e.color) ?? v.color,
1849
1849
  width: (e == null ? void 0 : e.width) ?? v.width,
1850
1850
  arrowRenderer: B((e == null ? void 0 : e.arrowRenderer) ?? {}),
@@ -1861,7 +1861,7 @@ class It {
1861
1861
  this.pathShape.render(e);
1862
1862
  }
1863
1863
  }
1864
- class $e {
1864
+ class Be {
1865
1865
  constructor(e) {
1866
1866
  i(this, "svg");
1867
1867
  i(this, "group", document.createElementNS(
@@ -1879,16 +1879,16 @@ class $e {
1879
1879
  i(this, "onAfterRender");
1880
1880
  i(this, "afterRenderEmitter");
1881
1881
  i(this, "arrowRenderer");
1882
- [this.afterRenderEmitter, this.onAfterRender] = P(), this.color = (e == null ? void 0 : e.color) ?? v.color, this.width = (e == null ? void 0 : e.width) ?? v.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.arrowRenderer = B((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? v.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? v.preOffset, this.svg = Ie(this.color), this.svg.appendChild(this.group), this.line = Fe(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = Y(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = Y(), this.group.appendChild(this.targetArrow));
1882
+ [this.afterRenderEmitter, this.onAfterRender] = C(), this.color = (e == null ? void 0 : e.color) ?? v.color, this.width = (e == null ? void 0 : e.width) ?? v.width, this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? v.arrowLength, this.arrowRenderer = B((e == null ? void 0 : e.arrowRenderer) ?? {}), this.sourceOffset = (e == null ? void 0 : e.sourceOffset) ?? v.preOffset, this.targetOffset = (e == null ? void 0 : e.targetOffset) ?? v.preOffset, this.svg = Fe(this.color), this.svg.appendChild(this.group), this.line = Ue(this.width), this.group.appendChild(this.line), e != null && e.hasSourceArrow && (this.sourceArrow = X(), this.group.appendChild(this.sourceArrow)), e != null && e.hasTargetArrow && (this.targetArrow = X(), this.group.appendChild(this.targetArrow));
1883
1883
  }
1884
1884
  render(e) {
1885
- const { x: t, y: o, width: s, height: n, from: a, to: h } = Ve(
1885
+ const { x: t, y: o, width: s, height: n, from: a, to: h } = Ie(
1886
1886
  e.from,
1887
1887
  e.to,
1888
1888
  O
1889
1889
  );
1890
- Ue(this.svg, { x: t, y: o, width: s, height: n });
1891
- const d = new St({
1890
+ $e(this.svg, { x: t, y: o, width: s, height: n });
1891
+ const d = new Nt({
1892
1892
  from: a,
1893
1893
  to: h,
1894
1894
  sourceOffset: this.sourceOffset,
@@ -1908,26 +1908,26 @@ class $e {
1908
1908
  y: (h.y - a.y) / g
1909
1909
  };
1910
1910
  if (this.sourceArrow) {
1911
- const w = {
1911
+ const p = {
1912
1912
  x: l.x * this.sourceOffset,
1913
1913
  y: l.y * this.sourceOffset
1914
1914
  };
1915
1915
  c = this.arrowRenderer({
1916
1916
  direction: l,
1917
- shift: w,
1917
+ shift: p,
1918
1918
  arrowLength: this.arrowLength
1919
1919
  }), this.sourceArrow.setAttribute("d", c);
1920
1920
  }
1921
1921
  if (this.targetArrow) {
1922
- const w = {
1922
+ const p = {
1923
1923
  x: l.x * this.targetOffset,
1924
1924
  y: l.y * this.targetOffset
1925
1925
  };
1926
1926
  u = this.arrowRenderer({
1927
1927
  direction: { x: -l.x, y: -l.y },
1928
1928
  shift: {
1929
- x: h.x - w.x,
1930
- y: h.y - w.y
1929
+ x: h.x - p.x,
1930
+ y: h.y - p.y
1931
1931
  },
1932
1932
  arrowLength: this.arrowLength
1933
1933
  }), this.targetArrow.setAttribute("d", u);
@@ -1940,40 +1940,45 @@ class $e {
1940
1940
  });
1941
1941
  }
1942
1942
  }
1943
- const Ft = () => {
1943
+ const $t = () => {
1944
1944
  const r = document.createElementNS("http://www.w3.org/2000/svg", "g");
1945
1945
  return r.style.pointerEvents = "auto", r.style.cursor = "pointer", r;
1946
- }, Ut = (r) => {
1946
+ }, Bt = (r) => {
1947
1947
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1948
1948
  return e.setAttribute("stroke", "transparent"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "none"), e.setAttribute("stroke-linecap", "round"), e;
1949
- }, Ae = (r) => {
1949
+ }, Se = (r) => {
1950
1950
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
1951
1951
  return e.setAttribute("stroke-linejoin", "round"), e.setAttribute("stroke-width", `${r}`), e.setAttribute("fill", "transparent"), e.setAttribute("stroke", "transparent"), e;
1952
1952
  };
1953
- class $t extends Error {
1953
+ class Ot extends Error {
1954
1954
  constructor(e) {
1955
1955
  super(e), this.name = "InteractiveEdgeError";
1956
1956
  }
1957
1957
  }
1958
- class Be {
1958
+ class Oe {
1959
1959
  constructor(e, t) {
1960
1960
  i(this, "svg");
1961
1961
  i(this, "group");
1962
1962
  i(this, "line");
1963
1963
  i(this, "sourceArrow");
1964
1964
  i(this, "targetArrow");
1965
- i(this, "handle", Ft());
1965
+ // TODO: make private
1966
+ /**
1967
+ * @deprecated
1968
+ * do use shape.svg instead
1969
+ */
1970
+ i(this, "handle", $t());
1966
1971
  i(this, "onAfterRender");
1967
1972
  i(this, "interactiveLine");
1968
1973
  i(this, "interactiveSourceArrow", null);
1969
1974
  i(this, "interactiveTargetArrow", null);
1970
- if (this.baseEdge = e, e instanceof Be)
1971
- throw new $t(
1975
+ if (this.baseEdge = e, e instanceof Oe)
1976
+ throw new Ot(
1972
1977
  "interactive edge can be configured only once"
1973
1978
  );
1974
1979
  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;
1975
1980
  const o = (t == null ? void 0 : t.distance) ?? v.interactiveWidth;
1976
- this.interactiveLine = Ut(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = Ae(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = Ae(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((s) => {
1981
+ this.interactiveLine = Bt(o), this.handle.appendChild(this.interactiveLine), this.sourceArrow && (this.interactiveSourceArrow = Se(o), this.handle.appendChild(this.interactiveSourceArrow)), this.targetArrow && (this.interactiveTargetArrow = Se(o), this.handle.appendChild(this.interactiveTargetArrow)), this.group.appendChild(this.handle), this.baseEdge.onAfterRender.subscribe((s) => {
1977
1982
  this.interactiveLine.setAttribute("d", s.edgePath.path), this.interactiveSourceArrow && this.interactiveSourceArrow.setAttribute("d", s.sourceArrowPath), this.interactiveTargetArrow && this.interactiveTargetArrow.setAttribute("d", s.targetArrowPath);
1978
1983
  });
1979
1984
  }
@@ -1981,7 +1986,7 @@ class Be {
1981
1986
  this.baseEdge.render(e);
1982
1987
  }
1983
1988
  }
1984
- class Hr {
1989
+ class Jr {
1985
1990
  constructor(e, t) {
1986
1991
  i(this, "group");
1987
1992
  i(this, "line");
@@ -1998,7 +2003,7 @@ class Hr {
1998
2003
  this.baseShape.render(e);
1999
2004
  }
2000
2005
  }
2001
- class Oe {
2006
+ class We {
2002
2007
  constructor(e) {
2003
2008
  i(this, "onAfterNodeAdded");
2004
2009
  i(this, "onAfterNodeUpdated");
@@ -2097,7 +2102,7 @@ class Oe {
2097
2102
  return this.graphStore.getNodeAdjacentEdgeIds(e);
2098
2103
  }
2099
2104
  }
2100
- class J {
2105
+ class K {
2101
2106
  constructor(e) {
2102
2107
  i(this, "counter", 0);
2103
2108
  this.checkExists = e;
@@ -2113,15 +2118,15 @@ class J {
2113
2118
  this.counter = 0;
2114
2119
  }
2115
2120
  }
2116
- class We {
2121
+ class ze {
2117
2122
  constructor(e, t, o) {
2118
- i(this, "nodeIdGenerator", new J(
2123
+ i(this, "nodeIdGenerator", new K(
2119
2124
  (e) => this.graphStore.hasNode(e)
2120
2125
  ));
2121
- i(this, "portIdGenerator", new J(
2126
+ i(this, "portIdGenerator", new K(
2122
2127
  (e) => this.graphStore.hasPort(e)
2123
2128
  ));
2124
- i(this, "edgeIdGenerator", new J(
2129
+ i(this, "edgeIdGenerator", new K(
2125
2130
  (e) => this.graphStore.hasEdge(e)
2126
2131
  ));
2127
2132
  i(this, "onAfterNodeAdded", (e) => {
@@ -2244,18 +2249,18 @@ class We {
2244
2249
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
2245
2250
  }
2246
2251
  }
2247
- const Bt = (r) => {
2252
+ const Wt = (r) => {
2248
2253
  setTimeout(() => {
2249
2254
  r();
2250
2255
  });
2251
- }, Ot = (r) => {
2256
+ }, zt = (r) => {
2252
2257
  queueMicrotask(() => {
2253
2258
  r();
2254
2259
  });
2255
- }, re = (r) => {
2260
+ }, oe = (r) => {
2256
2261
  r();
2257
2262
  };
2258
- class ze {
2263
+ class ke {
2259
2264
  constructor(e) {
2260
2265
  i(this, "onBeforeUpdated");
2261
2266
  i(this, "onAfterUpdated");
@@ -2278,7 +2283,7 @@ class ze {
2278
2283
  return this.viewportStore.createViewportCoords(e);
2279
2284
  }
2280
2285
  }
2281
- const Wt = (r, e) => Symbol.iterator in r ? {
2286
+ const kt = (r, e) => Symbol.iterator in r ? {
2282
2287
  minContentScale: e.focus.minContentScale,
2283
2288
  nodes: r,
2284
2289
  contentPadding: e.focus.contentPadding,
@@ -2288,16 +2293,16 @@ const Wt = (r, e) => Symbol.iterator in r ? {
2288
2293
  nodes: r.nodes ?? [],
2289
2294
  contentPadding: r.contentPadding ?? r.contentOffset ?? e.focus.contentPadding,
2290
2295
  animationDuration: r.animationDuration ?? e.focus.animationDuration
2291
- }, ke = (r, e, t) => ({
2296
+ }, He = (r, e, t) => ({
2292
2297
  scale: r.scale,
2293
2298
  x: r.x + r.scale * e,
2294
2299
  y: r.y + r.scale * t
2295
- }), He = (r, e, t, o) => ({
2300
+ }), Ye = (r, e, t, o) => ({
2296
2301
  scale: r.scale * e,
2297
2302
  x: r.scale * (1 - e) * t + r.x,
2298
2303
  y: r.scale * (1 - e) * o + r.y
2299
2304
  });
2300
- class Ye {
2305
+ class Xe {
2301
2306
  constructor(e, t, o, s) {
2302
2307
  this.graphStore = e, this.viewportStore = t, this.params = o, this.win = s;
2303
2308
  }
@@ -2309,13 +2314,13 @@ class Ye {
2309
2314
  }
2310
2315
  center(e, t) {
2311
2316
  const { width: o, height: s } = this.viewportStore.getDimensions(), n = { x: o / 2, y: s / 2 }, a = this.viewportStore.getViewportMatrix(), h = this.viewportStore.createViewportCoords(e), d = h.x - n.x, c = h.y - n.y;
2312
- let u = ke(a, d, c);
2317
+ let u = He(a, d, c);
2313
2318
  const g = t == null ? void 0 : t.contentScale;
2314
2319
  if (g !== void 0) {
2315
- const w = 1 / g;
2316
- u = He(
2320
+ const p = 1 / g;
2321
+ u = Ye(
2317
2322
  u,
2318
- w / a.scale,
2323
+ p / a.scale,
2319
2324
  n.x,
2320
2325
  n.y
2321
2326
  );
@@ -2324,7 +2329,7 @@ class Ye {
2324
2329
  l > 0 ? this.animateNavigation(a, u, l) : this.viewportStore.patchViewportMatrix(u);
2325
2330
  }
2326
2331
  focus(e) {
2327
- const t = Wt(e ?? {}, this.params);
2332
+ const t = kt(e ?? {}, this.params);
2328
2333
  this.params.focus.schedule(() => {
2329
2334
  this.navigate(t);
2330
2335
  });
@@ -2345,10 +2350,10 @@ class Ye {
2345
2350
  const d = {
2346
2351
  x: (t + o) / 2,
2347
2352
  y: (s + n) / 2
2348
- }, { scale: c } = this.viewportStore.getContentMatrix(), u = (n - s) * c, g = (o - t) * c, { width: l, height: w } = this.viewportStore.getDimensions(), p = Math.max(
2353
+ }, { scale: c } = this.viewportStore.getContentMatrix(), u = (n - s) * c, g = (o - t) * c, { width: l, height: p } = this.viewportStore.getDimensions(), w = Math.max(
2349
2354
  g / l,
2350
- u / w
2351
- ), y = p > 1 ? c / p : c, f = Math.max(y, e.minContentScale);
2355
+ u / p
2356
+ ), y = w > 1 ? c / w : c, f = Math.max(y, e.minContentScale);
2352
2357
  this.center(d, {
2353
2358
  contentScale: f,
2354
2359
  animationDuration: e.animationDuration
@@ -2373,20 +2378,20 @@ class Ye {
2373
2378
  this.win.requestAnimationFrame(a);
2374
2379
  }
2375
2380
  }
2376
- const Xe = (r, e, t) => {
2377
- const o = new Me(), s = new Oe(o), n = new ze(e), a = new Ce(o, e, r), h = {
2381
+ const Ge = (r, e, t) => {
2382
+ const o = new De(), s = new We(o), n = new ke(e), a = new Te(o, e, r), h = {
2378
2383
  nodes: {
2379
- centerFn: Le,
2384
+ centerFn: Ve,
2380
2385
  priorityFn: () => 0
2381
2386
  },
2382
2387
  edges: {
2383
- shapeFactory: () => new $e(),
2388
+ shapeFactory: () => new Be(),
2384
2389
  priorityFn: () => 0
2385
2390
  },
2386
2391
  ports: {
2387
2392
  direction: 0
2388
2393
  }
2389
- }, d = new We(
2394
+ }, d = new ze(
2390
2395
  o,
2391
2396
  a,
2392
2397
  h
@@ -2394,18 +2399,18 @@ const Xe = (r, e, t) => {
2394
2399
  focus: {
2395
2400
  contentPadding: 0,
2396
2401
  minContentScale: 0,
2397
- schedule: re,
2402
+ schedule: oe,
2398
2403
  animationDuration: 0
2399
2404
  }
2400
- }, u = new Ye(
2405
+ }, u = new Xe(
2401
2406
  o,
2402
2407
  e,
2403
2408
  c,
2404
2409
  t
2405
2410
  );
2406
- return new Te(s, n, d, u);
2411
+ return new Me(s, n, d, u);
2407
2412
  };
2408
- class G {
2413
+ class j {
2409
2414
  constructor(e, t, o, s) {
2410
2415
  i(this, "onAfterPortMarked", (e) => {
2411
2416
  const t = this.canvas.graph.getPort(e);
@@ -2420,7 +2425,7 @@ class G {
2420
2425
  if (!this.params.mouseDownEventVerifier(t))
2421
2426
  return;
2422
2427
  const o = e.currentTarget, s = this.canvas.graph.findPortIdsByElement(o)[0];
2423
- this.params.onPortPointerDown(s, {
2428
+ this.params.onPointerDownVerifier(s, {
2424
2429
  x: t.clientX,
2425
2430
  y: t.clientY
2426
2431
  }) && (e.stopPropagation(), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
@@ -2434,20 +2439,20 @@ class G {
2434
2439
  e.clientX,
2435
2440
  e.clientY
2436
2441
  )) {
2437
- this.params.onPointerMoveOutside(), this.stopMouseDrag();
2442
+ this.removeWindowMouseListeners(), this.params.onPointerOutside();
2438
2443
  return;
2439
2444
  }
2440
2445
  this.params.onPointerMove({ x: e.clientX, y: e.clientY });
2441
2446
  });
2442
2447
  i(this, "onWindowMouseUp", (e) => {
2443
- this.params.mouseUpEventVerifier(e) && (this.params.onPointerUp({ x: e.clientX, y: e.clientY }), this.stopMouseDrag());
2448
+ this.params.mouseUpEventVerifier(e) && (this.removeWindowMouseListeners(), this.params.onPointerUp({ x: e.clientX, y: e.clientY }));
2444
2449
  });
2445
2450
  i(this, "onPortTouchStart", (e) => {
2446
2451
  const t = e;
2447
2452
  if (t.touches.length !== 1)
2448
2453
  return;
2449
2454
  const o = t.touches[0], s = e.currentTarget, n = this.canvas.graph.findPortIdsByElement(s)[0];
2450
- this.params.onPortPointerDown(n, {
2455
+ this.params.onPointerDownVerifier(n, {
2451
2456
  x: o.clientX,
2452
2457
  y: o.clientY
2453
2458
  }) && (e.stopPropagation(), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
@@ -2464,14 +2469,15 @@ class G {
2464
2469
  t.clientX,
2465
2470
  t.clientY
2466
2471
  )) {
2467
- this.params.onPointerMoveOutside(), this.stopTouchDrag();
2472
+ this.removeWindowTouchListeners(), this.params.onPointerOutside();
2468
2473
  return;
2469
2474
  }
2470
2475
  this.params.onPointerMove({ x: t.clientX, y: t.clientY });
2471
2476
  });
2472
2477
  i(this, "onWindowTouchFinish", (e) => {
2478
+ this.removeWindowTouchListeners();
2473
2479
  const t = e.changedTouches[0];
2474
- this.params.onPointerUp({ x: t.clientX, y: t.clientY }), this.stopTouchDrag();
2480
+ this.params.onPointerUp({ x: t.clientX, y: t.clientY });
2475
2481
  });
2476
2482
  i(this, "reset", () => {
2477
2483
  this.canvas.graph.getAllPortIds().forEach((e) => {
@@ -2480,12 +2486,12 @@ class G {
2480
2486
  });
2481
2487
  });
2482
2488
  i(this, "revert", () => {
2483
- this.params.onStopDrag(), this.reset(), this.removeWindowMouseListeners(), this.removeWindowTouchListeners();
2489
+ this.removeWindowMouseListeners(), this.removeWindowTouchListeners(), this.reset();
2484
2490
  });
2485
2491
  this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.params = s, 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);
2486
2492
  }
2487
2493
  static configure(e, t, o, s) {
2488
- new G(e, t, o, s);
2494
+ new j(e, t, o, s);
2489
2495
  }
2490
2496
  hookPortEvents(e) {
2491
2497
  e.addEventListener("mousedown", this.onPortMouseDown, {
@@ -2497,12 +2503,6 @@ class G {
2497
2503
  unhookPortEvents(e) {
2498
2504
  e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
2499
2505
  }
2500
- stopMouseDrag() {
2501
- this.params.onStopDrag(), this.removeWindowMouseListeners();
2502
- }
2503
- stopTouchDrag() {
2504
- this.params.onStopDrag(), this.removeWindowTouchListeners();
2505
- }
2506
2506
  removeWindowMouseListeners() {
2507
2507
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
2508
2508
  }
@@ -2510,35 +2510,6 @@ class G {
2510
2510
  this.window.removeEventListener("touchmove", this.onWindowTouchMove), this.window.removeEventListener("touchend", this.onWindowTouchFinish), this.window.removeEventListener("touchcancel", this.onWindowTouchFinish);
2511
2511
  }
2512
2512
  }
2513
- class zt {
2514
- constructor(e, t, o) {
2515
- this.canvas = e, this.layoutAlgorithm = t, this.params = o;
2516
- }
2517
- apply() {
2518
- const e = this.layoutAlgorithm.calculateCoordinates({
2519
- graph: this.canvas.graph,
2520
- viewport: this.canvas.viewport
2521
- });
2522
- this.params.onBeforeApplied(), e.forEach((t, o) => {
2523
- this.params.staticNodeResolver(o) || this.canvas.updateNode(o, t);
2524
- }), this.params.onAfterApplied();
2525
- }
2526
- }
2527
- class kt {
2528
- constructor(e, t, o) {
2529
- this.canvas = e, this.layoutAlgorithm = t, this.params = o;
2530
- }
2531
- apply(e) {
2532
- const t = this.layoutAlgorithm.calculateNextCoordinates({
2533
- graph: this.canvas.graph,
2534
- viewport: this.canvas.viewport,
2535
- dt: e
2536
- });
2537
- this.params.onBeforeApplied(), t.forEach((o, s) => {
2538
- this.params.staticNodeResolver(s) || this.canvas.updateNode(s, o);
2539
- }), this.params.onAfterApplied();
2540
- }
2541
- }
2542
2513
  class Ht {
2543
2514
  constructor() {
2544
2515
  i(this, "field", "_htmlGraphTags");
@@ -2552,8 +2523,8 @@ class Ht {
2552
2523
  s === void 0 ? o[this.field] = /* @__PURE__ */ new Set([t]) : s.add(t);
2553
2524
  }
2554
2525
  }
2555
- const oe = Symbol();
2556
- class se {
2526
+ const se = Symbol();
2527
+ class ie {
2557
2528
  constructor(e, t, o) {
2558
2529
  i(this, "onSelected");
2559
2530
  i(this, "mouseDownEventVerifier");
@@ -2643,7 +2614,38 @@ class se {
2643
2614
  this.movedDistance += s, this.movedDistance > this.movementThreshold && o();
2644
2615
  }
2645
2616
  }
2646
- class ie {
2617
+ const ne = (r, e) => ({
2618
+ from: r.isDirect ? r.staticPortId : e,
2619
+ to: r.isDirect ? e : r.staticPortId
2620
+ });
2621
+ class Yt {
2622
+ constructor(e, t) {
2623
+ this.graph = e, this.connectionAllowedVerifier = t;
2624
+ }
2625
+ resolve(e) {
2626
+ let t, o = 1 / 0;
2627
+ const { cursor: s } = e;
2628
+ return this.graph.getAllPortIds().forEach((n) => {
2629
+ const { element: a, direction: h, nodeId: d } = this.graph.getPort(n), { x: c, y: u } = this.graph.getNode(d);
2630
+ if (c === null || u === null)
2631
+ return;
2632
+ const g = ne(e, n);
2633
+ if (!this.connectionAllowedVerifier(g))
2634
+ return;
2635
+ const { top: l, left: p, width: w, height: y } = a.getBoundingClientRect(), f = { x: p + w / 2, y: l + y / 2 }, x = s.x - f.x, E = s.y - f.y, P = Math.sqrt(x * x + E * E);
2636
+ P < o && (o = P, t = h);
2637
+ }), t;
2638
+ }
2639
+ }
2640
+ class Xt {
2641
+ constructor(e) {
2642
+ this.direction = e;
2643
+ }
2644
+ resolve() {
2645
+ return this.direction;
2646
+ }
2647
+ }
2648
+ class ae {
2647
2649
  constructor(e, t, o, s, n) {
2648
2650
  i(this, "grabbedNode", null);
2649
2651
  i(this, "maxNodePriority", 0);
@@ -2680,7 +2682,7 @@ class ie {
2680
2682
  nodeId: s,
2681
2683
  dx: h.x - n.x,
2682
2684
  dy: h.y - n.y
2683
- }, k(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2685
+ }, H(this.element, this.params.dragCursor), this.moveNodeOnTop(s), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2684
2686
  passive: !0
2685
2687
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2686
2688
  passive: !0
@@ -2762,7 +2764,7 @@ class ie {
2762
2764
  this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.params = n, 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);
2763
2765
  }
2764
2766
  static configure(e, t, o, s, n) {
2765
- new ie(
2767
+ new ae(
2766
2768
  e,
2767
2769
  t,
2768
2770
  o,
@@ -2794,7 +2796,7 @@ class ie {
2794
2796
  }
2795
2797
  }
2796
2798
  stopMouseDrag() {
2797
- this.grabbedNode !== null && this.graph.hasNode(this.grabbedNode.nodeId) && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, k(this.element, null), this.removeMouseDragListeners();
2799
+ this.grabbedNode !== null && this.graph.hasNode(this.grabbedNode.nodeId) && this.params.onNodeDragFinished(this.grabbedNode.nodeId), this.grabbedNode = null, H(this.element, null), this.removeMouseDragListeners();
2798
2800
  }
2799
2801
  removeMouseDragListeners() {
2800
2802
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -2856,7 +2858,7 @@ const W = (r) => {
2856
2858
  touches: e
2857
2859
  };
2858
2860
  };
2859
- class j {
2861
+ class J {
2860
2862
  constructor(e, t, o, s, n) {
2861
2863
  i(this, "viewport");
2862
2864
  i(this, "prevTouches", null);
@@ -2866,7 +2868,7 @@ class j {
2866
2868
  this.removeMouseDragListeners(), this.removeTouchDragListeners();
2867
2869
  });
2868
2870
  i(this, "onMouseDown", (e) => {
2869
- this.params.mouseDownEventVerifier(e) && (k(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2871
+ this.params.mouseDownEventVerifier(e) && (H(this.element, this.params.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2870
2872
  passive: !0
2871
2873
  }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2872
2874
  passive: !0
@@ -2944,7 +2946,7 @@ class j {
2944
2946
  }), e.onBeforeDestroy.subscribe(this.revert);
2945
2947
  }
2946
2948
  static configure(e, t, o, s, n) {
2947
- new j(
2949
+ new J(
2948
2950
  e,
2949
2951
  t,
2950
2952
  o,
@@ -2953,7 +2955,7 @@ class j {
2953
2955
  );
2954
2956
  }
2955
2957
  moveViewport(e, t) {
2956
- const o = this.viewport.getViewportMatrix(), s = ke(o, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2958
+ const o = this.viewport.getViewportMatrix(), s = He(o, e, t), { width: n, height: a } = this.viewport.getDimensions(), h = this.params.transformPreprocessor({
2957
2959
  prevTransform: o,
2958
2960
  nextTransform: s,
2959
2961
  canvasWidth: n,
@@ -2962,7 +2964,7 @@ class j {
2962
2964
  this.performTransform(h);
2963
2965
  }
2964
2966
  scaleViewport(e, t, o) {
2965
- const s = this.canvas.viewport.getViewportMatrix(), n = He(s, e, t, o), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2967
+ const s = this.canvas.viewport.getViewportMatrix(), n = Ye(s, e, t, o), { width: a, height: h } = this.viewport.getDimensions(), d = this.params.transformPreprocessor({
2966
2968
  prevTransform: s,
2967
2969
  nextTransform: n,
2968
2970
  canvasWidth: a,
@@ -2971,7 +2973,7 @@ class j {
2971
2973
  this.performTransform(d);
2972
2974
  }
2973
2975
  stopMouseDrag() {
2974
- k(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2976
+ H(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
2975
2977
  }
2976
2978
  removeMouseDragListeners() {
2977
2979
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -3001,7 +3003,7 @@ class j {
3001
3003
  this.params.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.params.onResizeTransformFinished();
3002
3004
  }
3003
3005
  }
3004
- class ne {
3006
+ class he {
3005
3007
  constructor(e, t, o, s, n, a, h) {
3006
3008
  i(this, "nodeHorizontal");
3007
3009
  i(this, "nodeVertical");
@@ -3048,7 +3050,7 @@ class ne {
3048
3050
  this.scheduleLoadAreaAroundViewport(), s.onTransformFinished();
3049
3051
  }
3050
3052
  };
3051
- j.configure(
3053
+ J.configure(
3052
3054
  e,
3053
3055
  this.element,
3054
3056
  this.window,
@@ -3057,7 +3059,7 @@ class ne {
3057
3059
  ), this.trigger.subscribe(this.updateLoadedArea), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated);
3058
3060
  }
3059
3061
  static configure(e, t, o, s, n, a, h) {
3060
- new ne(
3062
+ new he(
3061
3063
  e,
3062
3064
  t,
3063
3065
  o,
@@ -3088,24 +3090,24 @@ class ne {
3088
3090
  });
3089
3091
  }
3090
3092
  }
3091
- const Yt = () => {
3093
+ const Gt = () => {
3092
3094
  const r = document.createElementNS("http://www.w3.org/2000/svg", "svg");
3093
3095
  return r.style.position = "absolute", r.style.inset = "0", r;
3094
- }, Xt = () => {
3096
+ }, jt = () => {
3095
3097
  const r = document.createElementNS("http://www.w3.org/2000/svg", "rect");
3096
3098
  return r.setAttribute("fill", "url(#pattern)"), r;
3097
- }, Gt = () => {
3099
+ }, Jt = () => {
3098
3100
  const r = document.createElementNS(
3099
3101
  "http://www.w3.org/2000/svg",
3100
3102
  "pattern"
3101
3103
  );
3102
3104
  return r.setAttribute("id", "pattern"), r;
3103
3105
  };
3104
- class ae {
3106
+ class de {
3105
3107
  constructor(e, t, o) {
3106
- i(this, "svg", Yt());
3107
- i(this, "patternRenderingRectangle", Xt());
3108
- i(this, "pattern", Gt());
3108
+ i(this, "svg", Gt());
3109
+ i(this, "patternRenderingRectangle", jt());
3110
+ i(this, "pattern", Jt());
3109
3111
  i(this, "patternContent");
3110
3112
  i(this, "tileWidth");
3111
3113
  i(this, "tileHeight");
@@ -3126,7 +3128,7 @@ class ae {
3126
3128
  }), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated();
3127
3129
  }
3128
3130
  static configure(e, t, o) {
3129
- new ae(e, t, o);
3131
+ new de(e, t, o);
3130
3132
  }
3131
3133
  updateVisibility() {
3132
3134
  const { scale: e } = this.canvas.viewport.getViewportMatrix(), t = e > this.maxViewportScale;
@@ -3140,46 +3142,45 @@ class ae {
3140
3142
  }
3141
3143
  }
3142
3144
  }
3143
- class he {
3145
+ class ce {
3144
3146
  constructor(e, t, o, s, n, a) {
3145
3147
  i(this, "overlayCanvas");
3146
- i(this, "staticPortId", null);
3147
- i(this, "isTargetDragging", !0);
3148
+ i(this, "edgeInProgress", null);
3148
3149
  i(this, "onEdgeCreated", (e) => {
3149
3150
  this.params.onAfterEdgeCreated(e);
3150
3151
  });
3151
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Xe(
3152
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Ge(
3152
3153
  this.overlayLayer,
3153
3154
  this.viewportStore,
3154
3155
  this.window
3155
- ), G.configure(
3156
+ );
3157
+ const h = {
3158
+ mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3159
+ mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3160
+ onPointerDownVerifier: (d, c) => {
3161
+ const u = this.params.connectionTypeResolver(d);
3162
+ return u === null ? !1 : (this.grabPort(d, c, u), !0);
3163
+ },
3164
+ onPointerMove: (d) => {
3165
+ this.moveDraggingPort(d);
3166
+ },
3167
+ onPointerUp: (d) => {
3168
+ this.tryCreateConnection(d), this.resetDragState();
3169
+ },
3170
+ onPointerOutside: () => {
3171
+ const d = this.edgeInProgress;
3172
+ this.resetDragState(), this.params.onEdgeCreationInterrupted(d);
3173
+ }
3174
+ };
3175
+ j.configure(
3156
3176
  this.canvas,
3157
3177
  this.window,
3158
3178
  this.pointInsideVerifier,
3159
- {
3160
- mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3161
- mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3162
- onStopDrag: () => {
3163
- this.resetDragState();
3164
- },
3165
- onPortPointerDown: (h, d) => {
3166
- const c = this.params.connectionTypeResolver(h);
3167
- return c === null ? !1 : (this.grabPort(h, d, c), !0);
3168
- },
3169
- onPointerMove: (h) => {
3170
- this.moveDraggingPort(h);
3171
- },
3172
- onPointerMoveOutside: () => {
3173
- this.handleEdgeCreationInterrupted();
3174
- },
3175
- onPointerUp: (h) => {
3176
- this.tryCreateConnection(h);
3177
- }
3178
- }
3179
+ h
3179
3180
  );
3180
3181
  }
3181
3182
  static configure(e, t, o, s, n, a) {
3182
- new he(
3183
+ new ce(
3183
3184
  e,
3184
3185
  t,
3185
3186
  o,
@@ -3189,9 +3190,7 @@ class he {
3189
3190
  );
3190
3191
  }
3191
3192
  grabPort(e, t, o) {
3192
- const s = this.canvas.graph.getPort(e);
3193
- this.staticPortId = e;
3194
- const n = s.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.createContentCoords({
3193
+ const s = this.canvas.graph.getPort(e), n = s.element.getBoundingClientRect(), a = n.x + n.width / 2, h = n.y + n.height / 2, d = this.overlayLayer.getBoundingClientRect(), c = this.canvas.viewport.createContentCoords({
3195
3194
  x: a - d.x,
3196
3195
  y: h - d.y
3197
3196
  }), u = this.canvas.viewport.createContentCoords({
@@ -3201,96 +3200,100 @@ class he {
3201
3200
  overlayNodeId: M.StaticNodeId,
3202
3201
  portCoords: c,
3203
3202
  portDirection: s.direction
3204
- }, l = {
3203
+ }, l = o === "direct";
3204
+ this.edgeInProgress = {
3205
+ staticPortId: e,
3206
+ isDirect: l
3207
+ };
3208
+ const p = {
3205
3209
  overlayNodeId: M.DraggingNodeId,
3206
3210
  portCoords: u,
3207
- portDirection: this.params.dragPortDirection
3208
- };
3209
- this.isTargetDragging = o === "direct";
3210
- const [w, p] = this.isTargetDragging ? [g, l] : [l, g];
3211
- this.overlayCanvas.addNode(H(w)), this.overlayCanvas.addNode(H(p)), this.overlayCanvas.addEdge({
3211
+ portDirection: this.params.draggingPortDirectionResolver.resolve({
3212
+ cursor: t,
3213
+ ...this.edgeInProgress
3214
+ }) ?? s.direction
3215
+ }, [w, y] = l ? [g, p] : [p, g];
3216
+ this.overlayCanvas.addNode(Y(w)), this.overlayCanvas.addNode(Y(y)), this.overlayCanvas.addEdge({
3212
3217
  from: w.overlayNodeId,
3213
- to: p.overlayNodeId,
3218
+ to: y.overlayNodeId,
3214
3219
  shape: this.params.edgeShapeFactory(M.EdgeId)
3215
3220
  });
3216
3221
  }
3217
3222
  resetDragState() {
3218
- this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
3223
+ this.edgeInProgress = null, this.overlayCanvas.clear();
3219
3224
  }
3220
3225
  tryCreateConnection(e) {
3221
- const t = Re(this.canvas.graph, e);
3226
+ const t = Le(this.canvas.graph, e);
3222
3227
  if (t === null) {
3223
- this.handleEdgeCreationInterrupted();
3228
+ this.params.onEdgeCreationInterrupted(this.edgeInProgress);
3224
3229
  return;
3225
3230
  }
3226
- const o = this.staticPortId, s = this.isTargetDragging ? o : t, n = this.isTargetDragging ? t : o, a = { from: s, to: n }, h = this.params.connectionPreprocessor(a);
3227
- h !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(a);
3231
+ const o = ne(
3232
+ this.edgeInProgress,
3233
+ t
3234
+ ), s = this.params.connectionAllowedVerifier(o), n = this.params.connectionPreprocessor({
3235
+ from: o.from,
3236
+ to: o.to
3237
+ });
3238
+ s && n !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.params.onEdgeCreationPrevented(o);
3228
3239
  }
3229
3240
  moveDraggingPort(e) {
3230
3241
  const t = this.overlayLayer.getBoundingClientRect(), o = this.canvas.viewport.createContentCoords({
3231
3242
  x: e.x - t.x,
3232
3243
  y: e.y - t.y
3244
+ }), s = this.params.draggingPortDirectionResolver.resolve({
3245
+ cursor: e,
3246
+ ...this.edgeInProgress
3233
3247
  });
3234
3248
  this.overlayCanvas.updateNode(M.DraggingNodeId, {
3235
3249
  x: o.x,
3236
3250
  y: o.y
3237
- });
3238
- }
3239
- handleEdgeCreationInterrupted() {
3240
- const e = this.staticPortId;
3241
- this.params.onEdgeCreationInterrupted({
3242
- staticPortId: e,
3243
- isDirect: this.isTargetDragging
3244
- });
3251
+ }).updatePort(M.DraggingNodeId, { direction: s });
3245
3252
  }
3246
3253
  }
3247
- class de {
3254
+ class le {
3248
3255
  constructor(e, t, o, s, n, a) {
3249
3256
  i(this, "overlayCanvas");
3250
- i(this, "staticPortId", null);
3251
- i(this, "isTargetDragging", !0);
3257
+ i(this, "edgeInProgress", null);
3252
3258
  i(this, "draggingEdgePayload", null);
3253
3259
  i(this, "onEdgeReattached", (e) => {
3254
3260
  this.params.onAfterEdgeReattached(e);
3255
3261
  });
3256
- this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Xe(
3262
+ this.canvas = e, this.overlayLayer = t, this.viewportStore = o, this.window = s, this.pointInsideVerifier = n, this.params = a, this.overlayCanvas = Ge(
3257
3263
  this.overlayLayer,
3258
3264
  this.viewportStore,
3259
3265
  this.window
3260
- ), G.configure(
3266
+ );
3267
+ const h = {
3268
+ mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3269
+ mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3270
+ onPointerDownVerifier: (d, c) => this.tryStartEdgeDragging(d, c),
3271
+ onPointerMove: (d) => {
3272
+ this.moveDraggingPort(d);
3273
+ },
3274
+ onPointerUp: (d) => {
3275
+ this.tryCreateConnection(d), this.resetDragState();
3276
+ },
3277
+ onPointerOutside: () => {
3278
+ const d = this.draggingEdgePayload;
3279
+ this.resetDragState(), this.params.onEdgeReattachInterrupted({
3280
+ id: d.id,
3281
+ from: d.from,
3282
+ to: d.to,
3283
+ shape: d.shape,
3284
+ priority: d.priority
3285
+ });
3286
+ }
3287
+ };
3288
+ j.configure(
3261
3289
  this.canvas,
3262
3290
  this.window,
3263
3291
  this.pointInsideVerifier,
3264
- {
3265
- mouseDownEventVerifier: this.params.mouseDownEventVerifier,
3266
- mouseUpEventVerifier: this.params.mouseUpEventVerifier,
3267
- onStopDrag: () => {
3268
- this.resetDragState();
3269
- },
3270
- onPortPointerDown: (h, d) => this.tryStartEdgeDragging(h, d),
3271
- onPointerMove: (h) => {
3272
- this.moveDraggingPort(h);
3273
- },
3274
- onPointerMoveOutside: () => {
3275
- const h = this.draggingEdgePayload;
3276
- queueMicrotask(() => {
3277
- this.params.onEdgeReattachInterrupted({
3278
- id: h.id,
3279
- from: h.from,
3280
- to: h.to,
3281
- shape: h.shape,
3282
- priority: h.priority
3283
- });
3284
- });
3285
- },
3286
- onPointerUp: (h) => {
3287
- this.tryCreateConnection(h);
3288
- }
3289
- }
3292
+ h
3290
3293
  );
3291
3294
  }
3292
3295
  static configure(e, t, o, s, n, a) {
3293
- new de(
3296
+ new le(
3294
3297
  e,
3295
3298
  t,
3296
3299
  o,
@@ -3301,17 +3304,17 @@ class de {
3301
3304
  }
3302
3305
  tryStartEdgeDragging(e, t) {
3303
3306
  const o = this.params.draggingEdgeResolver(e);
3304
- if (o === null || !this.canvas.graph.hasEdge(o))
3307
+ if (o === null)
3305
3308
  return !1;
3306
3309
  const s = this.canvas.graph.getEdge(o), n = e === s.from, a = e === s.to, h = n ? s.to : s.from;
3307
- this.staticPortId = h, this.isTargetDragging = a;
3310
+ this.edgeInProgress = { staticPortId: h, isDirect: a };
3308
3311
  const d = this.canvas.graph.getPort(e), c = this.canvas.graph.getPort(h), u = c.element.getBoundingClientRect(), g = {
3309
3312
  x: u.x + u.width / 2,
3310
3313
  y: u.y + u.height / 2
3311
- }, l = this.overlayLayer.getBoundingClientRect(), w = this.canvas.viewport.createContentCoords({
3314
+ }, l = this.overlayLayer.getBoundingClientRect(), p = this.canvas.viewport.createContentCoords({
3312
3315
  x: g.x - l.x,
3313
3316
  y: g.y - l.y
3314
- }), p = this.canvas.viewport.createContentCoords({
3317
+ }), w = this.canvas.viewport.createContentCoords({
3315
3318
  x: t.x - l.x,
3316
3319
  y: t.y - l.y
3317
3320
  });
@@ -3324,83 +3327,92 @@ class de {
3324
3327
  }, this.canvas.removeEdge(o);
3325
3328
  const y = {
3326
3329
  overlayNodeId: M.StaticNodeId,
3327
- portCoords: w,
3330
+ portCoords: p,
3328
3331
  portDirection: c.direction
3329
- }, f = {
3332
+ }, f = this.params.draggingPortDirectionResolver.resolve({
3333
+ cursor: t,
3334
+ ...this.edgeInProgress
3335
+ }), x = {
3330
3336
  overlayNodeId: M.DraggingNodeId,
3331
- portCoords: p,
3332
- portDirection: d.direction
3333
- }, [x, E] = this.isTargetDragging ? [y, f] : [f, y];
3334
- this.overlayCanvas.addNode(H(x)), this.overlayCanvas.addNode(H(E));
3335
- const N = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(M.EdgeId) : s.shape;
3337
+ portCoords: w,
3338
+ portDirection: f ?? d.direction
3339
+ }, [E, P] = a ? [y, x] : [x, y];
3340
+ this.overlayCanvas.addNode(Y(E)), this.overlayCanvas.addNode(Y(P));
3341
+ const T = this.params.draggingEdgeShapeFactory !== null ? this.params.draggingEdgeShapeFactory(M.EdgeId) : s.shape;
3336
3342
  return this.overlayCanvas.addEdge({
3337
3343
  id: M.EdgeId,
3338
- from: x.overlayNodeId,
3339
- to: E.overlayNodeId,
3340
- shape: N
3344
+ from: E.overlayNodeId,
3345
+ to: P.overlayNodeId,
3346
+ shape: T
3341
3347
  }), !0;
3342
3348
  }
3343
3349
  resetDragState() {
3344
- this.draggingEdgePayload = null, this.staticPortId = null, this.isTargetDragging = !0, this.overlayCanvas.clear();
3350
+ this.draggingEdgePayload = null, this.edgeInProgress = null, this.overlayCanvas.clear();
3345
3351
  }
3346
3352
  moveDraggingPort(e) {
3347
3353
  const t = this.overlayLayer.getBoundingClientRect(), o = {
3348
3354
  x: e.x - t.x,
3349
3355
  y: e.y - t.y
3350
- }, s = this.canvas.viewport.createContentCoords(o);
3356
+ }, s = this.canvas.viewport.createContentCoords(o), n = this.params.draggingPortDirectionResolver.resolve({
3357
+ cursor: e,
3358
+ ...this.edgeInProgress
3359
+ });
3351
3360
  this.overlayCanvas.updateNode(M.DraggingNodeId, {
3352
3361
  x: s.x,
3353
3362
  y: s.y
3354
- });
3363
+ }).updatePort(M.DraggingNodeId, { direction: n });
3355
3364
  }
3356
3365
  tryCreateConnection(e) {
3357
- const t = Re(this.canvas.graph, e);
3366
+ const t = Le(this.canvas.graph, e);
3358
3367
  if (this.overlayCanvas.removeEdge(M.EdgeId), t === null) {
3359
- this.handleEdgeReattachInterrupted();
3368
+ const c = this.draggingEdgePayload;
3369
+ this.params.onEdgeReattachInterrupted({
3370
+ id: c.id,
3371
+ from: c.from,
3372
+ to: c.to,
3373
+ shape: c.shape,
3374
+ priority: c.priority
3375
+ });
3360
3376
  return;
3361
3377
  }
3362
- const [o, s] = this.isTargetDragging ? [this.staticPortId, t] : [t, this.staticPortId], n = this.draggingEdgePayload, a = {
3378
+ const { from: o, to: s } = ne(
3379
+ this.edgeInProgress,
3380
+ t
3381
+ ), n = this.draggingEdgePayload, a = {
3363
3382
  id: n.id,
3364
3383
  from: o,
3365
3384
  to: s,
3366
3385
  shape: n.shape,
3367
3386
  priority: n.priority
3368
- }, h = this.params.connectionPreprocessor(a);
3369
- if (h !== null)
3370
- this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(h), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
3387
+ }, h = this.params.connectionAllowedVerifier({
3388
+ from: o,
3389
+ to: s
3390
+ }), d = this.params.connectionPreprocessor(a);
3391
+ if (h && d !== null)
3392
+ this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeReattached), this.canvas.addEdge(d), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeReattached);
3371
3393
  else {
3372
- const d = this.draggingEdgePayload;
3394
+ const c = this.draggingEdgePayload;
3373
3395
  this.params.onEdgeReattachPrevented({
3374
- id: d.id,
3375
- from: d.from,
3376
- to: d.to,
3377
- shape: d.shape,
3378
- priority: d.priority
3396
+ id: c.id,
3397
+ from: c.from,
3398
+ to: c.to,
3399
+ shape: c.shape,
3400
+ priority: c.priority
3379
3401
  });
3380
3402
  }
3381
3403
  }
3382
- handleEdgeReattachInterrupted() {
3383
- const e = this.draggingEdgePayload;
3384
- this.params.onEdgeReattachInterrupted({
3385
- id: e.id,
3386
- from: e.from,
3387
- to: e.to,
3388
- shape: e.shape,
3389
- priority: e.priority
3390
- });
3391
- }
3392
3404
  }
3393
- class ce {
3405
+ class ue {
3394
3406
  constructor(e, t) {
3395
3407
  this.applier = e, this.trigger = t, this.trigger.subscribe(() => {
3396
3408
  this.applier.apply();
3397
3409
  });
3398
3410
  }
3399
3411
  static configure(e, t) {
3400
- new ce(e, t);
3412
+ new ue(e, t);
3401
3413
  }
3402
3414
  }
3403
- class le {
3415
+ class ge {
3404
3416
  constructor(e, t, o) {
3405
3417
  i(this, "applyScheduled", !1);
3406
3418
  i(this, "apply", () => {
@@ -3417,7 +3429,7 @@ class le {
3417
3429
  });
3418
3430
  }
3419
3431
  static configure(e, t, o) {
3420
- new le(
3432
+ new ge(
3421
3433
  e,
3422
3434
  t,
3423
3435
  o
@@ -3427,23 +3439,37 @@ class le {
3427
3439
  this.applyScheduled || (this.applyScheduled = !0, this.defererFn(this.apply));
3428
3440
  }
3429
3441
  }
3430
- class jt {
3442
+ class Kt {
3443
+ constructor(e, t, o) {
3444
+ this.canvas = e, this.layoutAlgorithm = t, this.params = o;
3445
+ }
3446
+ apply() {
3447
+ const e = this.layoutAlgorithm.calculateCoordinates({
3448
+ graph: this.canvas.graph,
3449
+ viewport: this.canvas.viewport
3450
+ });
3451
+ this.params.onBeforeApplied(), e.forEach((t, o) => {
3452
+ this.params.staticNodeResolver(o) || this.canvas.updateNode(o, t);
3453
+ }), this.params.onAfterApplied();
3454
+ }
3455
+ }
3456
+ class Qt {
3431
3457
  static configure(e, t) {
3432
- const o = t.applyOn, s = new zt(e, t.algorithm, {
3458
+ const o = t.applyOn, s = new Kt(e, t.algorithm, {
3433
3459
  staticNodeResolver: t.staticNodeResolver,
3434
3460
  onBeforeApplied: t.onBeforeApplied,
3435
3461
  onAfterApplied: t.onAfterApplied
3436
3462
  });
3437
3463
  switch (o.type) {
3438
3464
  case "trigger": {
3439
- ce.configure(
3465
+ ue.configure(
3440
3466
  s,
3441
3467
  o.trigger
3442
3468
  );
3443
3469
  break;
3444
3470
  }
3445
3471
  case "topologyChangeSchedule": {
3446
- le.configure(
3472
+ ge.configure(
3447
3473
  e.graph,
3448
3474
  s,
3449
3475
  o.schedule
@@ -3453,7 +3479,7 @@ class jt {
3453
3479
  }
3454
3480
  }
3455
3481
  }
3456
- class Jt {
3482
+ class Zt {
3457
3483
  constructor(e, t) {
3458
3484
  i(this, "previousTimeStamp");
3459
3485
  i(this, "step", (e) => {
@@ -3468,27 +3494,42 @@ class Jt {
3468
3494
  this.win = e, this.callback = t, this.win.requestAnimationFrame(this.step);
3469
3495
  }
3470
3496
  }
3471
- class ue {
3497
+ class _t {
3498
+ constructor(e, t, o) {
3499
+ this.canvas = e, this.layoutAlgorithm = t, this.params = o;
3500
+ }
3501
+ apply(e) {
3502
+ const t = this.layoutAlgorithm.calculateNextCoordinates({
3503
+ graph: this.canvas.graph,
3504
+ viewport: this.canvas.viewport,
3505
+ dt: e
3506
+ });
3507
+ this.params.onBeforeApplied(), t.forEach((o, s) => {
3508
+ this.params.staticNodeResolver(s) || this.canvas.updateNode(s, o);
3509
+ }), this.params.onAfterApplied();
3510
+ }
3511
+ }
3512
+ class pe {
3472
3513
  constructor(e, t, o) {
3473
3514
  i(this, "applier");
3474
3515
  i(this, "step", (e) => {
3475
3516
  this.applier.apply(e);
3476
3517
  });
3477
- this.win = o, this.applier = new kt(e, t.algorithm, {
3518
+ this.win = o, this.applier = new _t(e, t.algorithm, {
3478
3519
  staticNodeResolver: t.staticNodeResolver,
3479
3520
  onBeforeApplied: t.onBeforeApplied,
3480
3521
  onAfterApplied: t.onAfterApplied
3481
- }), new Jt(this.win, this.step);
3522
+ }), new Zt(this.win, this.step);
3482
3523
  }
3483
3524
  static configure(e, t, o) {
3484
- new ue(e, t, o);
3525
+ new pe(e, t, o);
3485
3526
  }
3486
3527
  }
3487
- class ge {
3528
+ class we {
3488
3529
  constructor(e, t, o, s, n) {
3489
3530
  i(this, "configurator");
3490
3531
  i(this, "onNodeSelected");
3491
- i(this, "selectionHandledTag", oe);
3532
+ i(this, "selectionHandledTag", se);
3492
3533
  i(this, "onAfterNodeAdded", (e) => {
3493
3534
  const { element: t } = this.canvas.graph.getNode(e);
3494
3535
  this.configurator.enable(t);
@@ -3503,7 +3544,7 @@ class ge {
3503
3544
  this.configurator.disable(t);
3504
3545
  });
3505
3546
  });
3506
- this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onNodeSelected = n.onNodeSelected, this.configurator = new se(
3547
+ this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onNodeSelected = n.onNodeSelected, this.configurator = new ie(
3507
3548
  this.window,
3508
3549
  this.pointInsideVerifier,
3509
3550
  {
@@ -3518,7 +3559,7 @@ class ge {
3518
3559
  ), 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.reset);
3519
3560
  }
3520
3561
  static configure(e, t, o, s, n) {
3521
- new ge(
3562
+ new we(
3522
3563
  e,
3523
3564
  t,
3524
3565
  o,
@@ -3527,10 +3568,10 @@ class ge {
3527
3568
  );
3528
3569
  }
3529
3570
  }
3530
- class pe {
3571
+ class ye {
3531
3572
  constructor(e, t, o, s, n) {
3532
3573
  i(this, "configurator");
3533
- i(this, "selectionHandledTag", oe);
3574
+ i(this, "selectionHandledTag", se);
3534
3575
  i(this, "onEdgeSelected");
3535
3576
  i(this, "onAfterEdgeAdded", (e) => {
3536
3577
  const { shape: t } = this.canvas.graph.getEdge(e);
@@ -3546,7 +3587,7 @@ class pe {
3546
3587
  this.configurator.disable(t.svg);
3547
3588
  });
3548
3589
  });
3549
- this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onEdgeSelected = n.onEdgeSelected, this.configurator = new se(
3590
+ this.canvas = e, this.window = t, this.pointInsideVerifier = o, this.eventTagger = s, this.onEdgeSelected = n.onEdgeSelected, this.configurator = new ie(
3550
3591
  this.window,
3551
3592
  this.pointInsideVerifier,
3552
3593
  {
@@ -3561,7 +3602,7 @@ class pe {
3561
3602
  ), this.canvas.graph.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.canvas.graph.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.reset), this.canvas.onBeforeDestroy.subscribe(this.reset);
3562
3603
  }
3563
3604
  static configure(e, t, o, s, n) {
3564
- new pe(
3605
+ new ye(
3565
3606
  e,
3566
3607
  t,
3567
3608
  o,
@@ -3570,15 +3611,12 @@ class pe {
3570
3611
  );
3571
3612
  }
3572
3613
  }
3573
- class we {
3614
+ class fe {
3574
3615
  constructor(e, t, o, s, n, a) {
3575
3616
  i(this, "configurator");
3576
3617
  i(this, "onCanvasSelected");
3577
- i(this, "selectionHandledTag", oe);
3578
- i(this, "restore", () => {
3579
- this.configurator.disable(this.element);
3580
- });
3581
- this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.eventTagger = n, this.onCanvasSelected = a.onCanvasSelected, this.configurator = new se(
3618
+ i(this, "selectionHandledTag", se);
3619
+ this.canvas = e, this.element = t, this.window = o, this.pointInsideVerifier = s, this.eventTagger = n, this.onCanvasSelected = a.onCanvasSelected, this.configurator = new ie(
3582
3620
  this.window,
3583
3621
  this.pointInsideVerifier,
3584
3622
  {
@@ -3589,10 +3627,12 @@ class we {
3589
3627
  mouseDownEventVerifier: a.mouseDownEventVerifier,
3590
3628
  mouseUpEventVerifier: a.mouseUpEventVerifier
3591
3629
  }
3592
- ), this.configurator.enable(this.element), this.canvas.onBeforeDestroy.subscribe(this.restore);
3630
+ ), this.configurator.enable(this.element), this.canvas.onBeforeDestroy.subscribe(() => {
3631
+ this.configurator.disable(this.element);
3632
+ });
3593
3633
  }
3594
3634
  static configure(e, t, o, s, n, a) {
3595
- new we(
3635
+ new fe(
3596
3636
  e,
3597
3637
  t,
3598
3638
  o,
@@ -3602,48 +3642,137 @@ class we {
3602
3642
  );
3603
3643
  }
3604
3644
  }
3605
- const Kt = () => {
3645
+ const qt = () => {
3606
3646
  const r = document.createElement("div");
3607
3647
  return r.style.width = "100%", r.style.height = "100%", r.style.position = "relative", r;
3608
3648
  }, Q = () => {
3609
3649
  const r = document.createElement("div");
3610
3650
  return r.style.position = "absolute", r.style.inset = "0", r;
3611
- }, Se = () => {
3651
+ }, be = () => {
3612
3652
  const r = Q();
3613
3653
  return r.style.pointerEvents = "none", r;
3614
3654
  };
3615
- class Qt {
3655
+ class er {
3616
3656
  constructor(e) {
3617
3657
  i(this, "background", Q());
3618
3658
  i(this, "main", Q());
3619
- i(this, "overlayConnectablePorts", Se());
3620
- i(this, "overlayDraggableEdges", Se());
3621
- i(this, "host", Kt());
3659
+ i(this, "overlayConnectablePorts", be());
3660
+ i(this, "overlayDraggableEdges", be());
3661
+ i(this, "host", qt());
3622
3662
  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);
3623
3663
  }
3624
3664
  destroy() {
3625
3665
  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);
3626
3666
  }
3627
3667
  }
3628
- const Zt = (r) => {
3629
- var w, p, y, f, x, E;
3630
- const e = ((w = r.events) == null ? void 0 : w.onNodeDragStarted) ?? (() => {
3631
- }), t = ((p = r.events) == null ? void 0 : p.onNodeDrag) ?? (() => {
3632
- }), o = r.nodeDragVerifier ?? (() => !0), s = ((y = r.events) == null ? void 0 : y.onNodeDragFinished) ?? (() => {
3633
- }), n = r.moveOnTop !== !1, a = r.moveEdgesOnTop !== !1 && n, h = (f = r.mouse) == null ? void 0 : f.dragCursor, d = h !== void 0 ? h : "grab", c = (x = r.mouse) == null ? void 0 : x.mouseDownEventVerifier, u = c !== void 0 ? c : (N) => N.button === 0, g = (E = r.mouse) == null ? void 0 : E.mouseUpEventVerifier, l = g !== void 0 ? g : (N) => N.button === 0;
3668
+ const b = Object.freeze({
3669
+ seed: "HTMLGraph is awesome",
3670
+ maxTimeDeltaSec: 0.01,
3671
+ nodeCharge: 1e5,
3672
+ nodeMass: 1,
3673
+ edgeEquilibriumLength: 300,
3674
+ edgeStiffness: 1e3,
3675
+ dtSec: 0.01,
3676
+ maxIterations: 1e3,
3677
+ convergenceVelocity: 10,
3678
+ maxForce: 1e7,
3679
+ nodeForceCoefficient: 1,
3680
+ barnesHutAreaRadiusThreshold: 0.01,
3681
+ barnesHutTheta: 1
3682
+ }), L = Object.freeze({
3683
+ mouseDownEventVerifier: (r) => r.button === 0,
3684
+ mouseUpEventVerifier: (r) => r.button === 0,
3685
+ movementThreshold: 10
3686
+ }), N = () => {
3687
+ }, je = (r, e, t) => r === "closest-connectable-port" ? new Yt(
3688
+ e,
3689
+ t
3690
+ ) : new Xt(r), ve = (r) => {
3691
+ if (typeof r == "function")
3692
+ return r;
3693
+ switch (r.type) {
3694
+ case "straight":
3695
+ return () => new Ft({
3696
+ color: r.color,
3697
+ width: r.width,
3698
+ arrowLength: r.arrowLength,
3699
+ arrowOffset: r.arrowOffset,
3700
+ arrowRenderer: r.arrowRenderer,
3701
+ hasSourceArrow: r.hasSourceArrow,
3702
+ hasTargetArrow: r.hasTargetArrow,
3703
+ cycleSquareSide: r.cycleSquareSide,
3704
+ roundness: r.roundness,
3705
+ detourDistance: r.detourDistance,
3706
+ detourDirection: r.detourDirection
3707
+ });
3708
+ case "horizontal":
3709
+ return () => new It({
3710
+ color: r.color,
3711
+ width: r.width,
3712
+ arrowLength: r.arrowLength,
3713
+ arrowOffset: r.arrowOffset,
3714
+ arrowRenderer: r.arrowRenderer,
3715
+ hasSourceArrow: r.hasSourceArrow,
3716
+ hasTargetArrow: r.hasTargetArrow,
3717
+ cycleSquareSide: r.cycleSquareSide,
3718
+ roundness: r.roundness,
3719
+ detourDistance: r.detourDistance
3720
+ });
3721
+ case "vertical":
3722
+ return () => new Ut({
3723
+ color: r.color,
3724
+ width: r.width,
3725
+ arrowLength: r.arrowLength,
3726
+ arrowOffset: r.arrowOffset,
3727
+ arrowRenderer: r.arrowRenderer,
3728
+ hasSourceArrow: r.hasSourceArrow,
3729
+ hasTargetArrow: r.hasTargetArrow,
3730
+ cycleSquareSide: r.cycleSquareSide,
3731
+ roundness: r.roundness,
3732
+ detourDistance: r.detourDistance
3733
+ });
3734
+ case "direct":
3735
+ return () => new Be({
3736
+ color: r.color,
3737
+ width: r.width,
3738
+ arrowLength: r.arrowLength,
3739
+ arrowRenderer: r.arrowRenderer,
3740
+ hasSourceArrow: r.hasSourceArrow,
3741
+ hasTargetArrow: r.hasTargetArrow,
3742
+ sourceOffset: r.sourceOffset,
3743
+ targetOffset: r.targetOffset
3744
+ });
3745
+ default:
3746
+ return () => new Vt({
3747
+ color: r.color,
3748
+ width: r.width,
3749
+ arrowLength: r.arrowLength,
3750
+ arrowRenderer: r.arrowRenderer,
3751
+ hasSourceArrow: r.hasSourceArrow,
3752
+ hasTargetArrow: r.hasTargetArrow,
3753
+ cycleRadius: r.cycleRadius,
3754
+ smallCycleRadius: r.smallCycleRadius,
3755
+ curvature: r.curvature,
3756
+ detourDistance: r.detourDistance,
3757
+ detourDirection: r.detourDirection
3758
+ });
3759
+ }
3760
+ }, tr = (r) => {
3761
+ var u, g, l, p, w, y;
3762
+ const e = r.nodeDragVerifier ?? (() => !0), t = r.moveOnTop !== !1, o = r.moveEdgesOnTop !== !1 && t, s = (u = r.mouse) == null ? void 0 : u.dragCursor, n = s !== void 0 ? s : "grab", a = (g = r.mouse) == null ? void 0 : g.mouseDownEventVerifier, h = a !== void 0 ? a : (f) => f.button === 0, d = (l = r.mouse) == null ? void 0 : l.mouseUpEventVerifier, c = d !== void 0 ? d : (f) => f.button === 0;
3634
3763
  return {
3635
- moveOnTop: n,
3636
- moveEdgesOnTop: a,
3637
- dragCursor: d,
3764
+ moveOnTop: t,
3765
+ moveEdgesOnTop: o,
3766
+ dragCursor: n,
3638
3767
  gridSize: r.gridSize ?? null,
3639
- mouseDownEventVerifier: u,
3640
- mouseUpEventVerifier: l,
3641
- onNodeDragStarted: e,
3642
- onNodeDrag: t,
3643
- nodeDragVerifier: o,
3644
- onNodeDragFinished: s
3768
+ mouseDownEventVerifier: h,
3769
+ mouseUpEventVerifier: c,
3770
+ onNodeDragStarted: ((p = r.events) == null ? void 0 : p.onNodeDragStarted) ?? N,
3771
+ onNodeDrag: ((w = r.events) == null ? void 0 : w.onNodeDrag) ?? N,
3772
+ nodeDragVerifier: e,
3773
+ onNodeDragFinished: ((y = r.events) == null ? void 0 : y.onNodeDragFinished) ?? N
3645
3774
  };
3646
- }, _t = (r) => {
3775
+ }, rr = (r) => {
3647
3776
  const e = r.minX !== null ? r.minX : -1 / 0, t = r.maxX !== null ? r.maxX : 1 / 0, o = r.minY !== null ? r.minY : -1 / 0, s = r.maxY !== null ? r.maxY : 1 / 0;
3648
3777
  return (n) => {
3649
3778
  let a = n.nextTransform.x, h = n.nextTransform.y;
@@ -3653,7 +3782,7 @@ const Zt = (r) => {
3653
3782
  const u = n.canvasHeight * n.prevTransform.scale, g = s - u;
3654
3783
  return h > g && h > n.prevTransform.y && (h = Math.max(n.prevTransform.y, g)), { scale: n.nextTransform.scale, x: a, y: h };
3655
3784
  };
3656
- }, qt = (r) => {
3785
+ }, or = (r) => {
3657
3786
  const e = r.maxContentScale, t = r.minContentScale, o = e !== null ? 1 / e : 0, s = t !== null ? 1 / t : 1 / 0;
3658
3787
  return (n) => {
3659
3788
  const a = n.prevTransform, h = n.nextTransform;
@@ -3674,7 +3803,7 @@ const Zt = (r) => {
3674
3803
  y: u
3675
3804
  };
3676
3805
  };
3677
- }, er = (r) => (e) => r.reduce(
3806
+ }, sr = (r) => (e) => r.reduce(
3678
3807
  (t, o) => o({
3679
3808
  prevTransform: e.prevTransform,
3680
3809
  nextTransform: t,
@@ -3682,196 +3811,134 @@ const Zt = (r) => {
3682
3811
  canvasHeight: e.canvasHeight
3683
3812
  }),
3684
3813
  e.nextTransform
3685
- ), be = (r) => {
3814
+ ), Ne = (r) => {
3686
3815
  if (typeof r == "function")
3687
3816
  return r;
3688
3817
  switch (r.type) {
3689
3818
  case "scale-limit":
3690
- return qt({
3819
+ return or({
3691
3820
  minContentScale: r.minContentScale ?? 0,
3692
3821
  maxContentScale: r.maxContentScale ?? 1 / 0
3693
3822
  });
3694
3823
  case "shift-limit":
3695
- return _t({
3824
+ return rr({
3696
3825
  minX: r.minX ?? -1 / 0,
3697
3826
  maxX: r.maxX ?? 1 / 0,
3698
3827
  minY: r.minY ?? -1 / 0,
3699
3828
  maxY: r.maxY ?? 1 / 0
3700
3829
  });
3701
3830
  }
3702
- }, Ne = (r) => {
3703
- var p, y, f, x, E, N, C, T, I, F, U, fe;
3704
- const e = (p = r == null ? void 0 : r.scale) == null ? void 0 : p.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, o = r == null ? void 0 : r.transformPreprocessor;
3831
+ }, Pe = (r) => {
3832
+ var l, p, w, y, f, x, E, P, T, D, F, U;
3833
+ const e = (l = r == null ? void 0 : r.scale) == null ? void 0 : l.mouseWheelSensitivity, t = e !== void 0 ? e : 1.2, o = r == null ? void 0 : r.transformPreprocessor;
3705
3834
  let s;
3706
- o !== void 0 ? Array.isArray(o) ? s = er(
3835
+ o !== void 0 ? Array.isArray(o) ? s = sr(
3707
3836
  o.map(
3708
- (R) => be(R)
3837
+ (R) => Ne(R)
3709
3838
  )
3710
- ) : s = be(o) : s = (R) => R.nextTransform;
3711
- const n = ((y = r == null ? void 0 : r.shift) == null ? void 0 : y.cursor) !== void 0 ? r.shift.cursor : "grab", a = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onBeforeTransformChange) ?? (() => {
3712
- }), h = ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformChange) ?? (() => {
3713
- }), d = (E = r == null ? void 0 : r.shift) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (R) => R.button === 0, u = (N = r == null ? void 0 : r.shift) == null ? void 0 : N.mouseUpEventVerifier, g = u !== void 0 ? u : (R) => R.button === 0, l = (C = r == null ? void 0 : r.scale) == null ? void 0 : C.mouseWheelEventVerifier, w = l !== void 0 ? l : () => !0;
3839
+ ) : s = Ne(o) : s = (R) => R.nextTransform;
3840
+ const n = ((p = r == null ? void 0 : r.shift) == null ? void 0 : p.cursor) !== void 0 ? r.shift.cursor : "grab", a = (w = r == null ? void 0 : r.shift) == null ? void 0 : w.mouseDownEventVerifier, h = a !== void 0 ? a : (R) => R.button === 0, d = (y = r == null ? void 0 : r.shift) == null ? void 0 : y.mouseUpEventVerifier, c = d !== void 0 ? d : (R) => R.button === 0, u = (f = r == null ? void 0 : r.scale) == null ? void 0 : f.mouseWheelEventVerifier, g = u !== void 0 ? u : () => !0;
3714
3841
  return {
3715
3842
  wheelSensitivity: t,
3716
- onTransformStarted: ((T = r == null ? void 0 : r.events) == null ? void 0 : T.onTransformStarted) ?? (() => {
3717
- }),
3718
- onTransformFinished: ((I = r == null ? void 0 : r.events) == null ? void 0 : I.onTransformFinished) ?? (() => {
3719
- }),
3720
- onBeforeTransformChange: a,
3721
- onTransformChange: h,
3843
+ onTransformStarted: ((x = r == null ? void 0 : r.events) == null ? void 0 : x.onTransformStarted) ?? N,
3844
+ onTransformFinished: ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onTransformFinished) ?? N,
3845
+ onBeforeTransformChange: ((P = r == null ? void 0 : r.events) == null ? void 0 : P.onBeforeTransformChange) ?? N,
3846
+ onTransformChange: ((T = r == null ? void 0 : r.events) == null ? void 0 : T.onTransformChange) ?? N,
3722
3847
  transformPreprocessor: s,
3723
3848
  shiftCursor: n,
3724
- mouseDownEventVerifier: c,
3725
- mouseUpEventVerifier: g,
3726
- mouseWheelEventVerifier: w,
3727
- scaleWheelFinishTimeout: ((F = r == null ? void 0 : r.scale) == null ? void 0 : F.wheelFinishTimeout) ?? 500,
3728
- onResizeTransformStarted: ((U = r == null ? void 0 : r.events) == null ? void 0 : U.onResizeTransformStarted) ?? (() => {
3729
- }),
3730
- onResizeTransformFinished: ((fe = r == null ? void 0 : r.events) == null ? void 0 : fe.onResizeTransformFinished) ?? (() => {
3731
- })
3849
+ mouseDownEventVerifier: h,
3850
+ mouseUpEventVerifier: c,
3851
+ mouseWheelEventVerifier: g,
3852
+ scaleWheelFinishTimeout: ((D = r == null ? void 0 : r.scale) == null ? void 0 : D.wheelFinishTimeout) ?? 500,
3853
+ onResizeTransformStarted: ((F = r == null ? void 0 : r.events) == null ? void 0 : F.onResizeTransformStarted) ?? N,
3854
+ onResizeTransformFinished: ((U = r == null ? void 0 : r.events) == null ? void 0 : U.onResizeTransformFinished) ?? N
3732
3855
  };
3733
- }, tr = (r, e) => {
3856
+ }, ir = (r, e) => {
3734
3857
  const t = document.createElementNS(
3735
3858
  "http://www.w3.org/2000/svg",
3736
3859
  "circle"
3737
3860
  );
3738
3861
  return t.setAttribute("cx", "0"), t.setAttribute("cy", "0"), t.setAttribute("r", `${r}`), t.setAttribute("fill", `${e}`), t;
3739
- }, rr = (r) => r instanceof SVGElement ? r : tr(
3862
+ }, nr = (r) => r instanceof SVGElement ? r : ir(
3740
3863
  (r == null ? void 0 : r.radius) ?? 1.5,
3741
3864
  (r == null ? void 0 : r.color) ?? "#d8d8d8"
3742
- ), or = (r) => {
3743
- const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, s = rr(r.renderer ?? {});
3865
+ ), ar = (r) => {
3866
+ const e = r.tileDimensions, t = (e == null ? void 0 : e.width) ?? 25, o = (e == null ? void 0 : e.height) ?? 25, s = nr(r.renderer ?? {});
3744
3867
  return {
3745
3868
  tileWidth: t,
3746
3869
  tileHeight: o,
3747
3870
  renderer: s,
3748
3871
  maxViewportScale: r.maxViewportScale ?? 10
3749
3872
  };
3750
- }, ye = (r) => {
3751
- if (typeof r == "function")
3752
- return r;
3753
- switch (r.type) {
3754
- case "straight":
3755
- return () => new Vt({
3756
- color: r.color,
3757
- width: r.width,
3758
- arrowLength: r.arrowLength,
3759
- arrowOffset: r.arrowOffset,
3760
- arrowRenderer: r.arrowRenderer,
3761
- hasSourceArrow: r.hasSourceArrow,
3762
- hasTargetArrow: r.hasTargetArrow,
3763
- cycleSquareSide: r.cycleSquareSide,
3764
- roundness: r.roundness,
3765
- detourDistance: r.detourDistance,
3766
- detourDirection: r.detourDirection
3767
- });
3768
- case "horizontal":
3769
- return () => new Lt({
3770
- color: r.color,
3771
- width: r.width,
3772
- arrowLength: r.arrowLength,
3773
- arrowOffset: r.arrowOffset,
3774
- arrowRenderer: r.arrowRenderer,
3775
- hasSourceArrow: r.hasSourceArrow,
3776
- hasTargetArrow: r.hasTargetArrow,
3777
- cycleSquareSide: r.cycleSquareSide,
3778
- roundness: r.roundness,
3779
- detourDistance: r.detourDistance
3780
- });
3781
- case "vertical":
3782
- return () => new It({
3783
- color: r.color,
3784
- width: r.width,
3785
- arrowLength: r.arrowLength,
3786
- arrowOffset: r.arrowOffset,
3787
- arrowRenderer: r.arrowRenderer,
3788
- hasSourceArrow: r.hasSourceArrow,
3789
- hasTargetArrow: r.hasTargetArrow,
3790
- cycleSquareSide: r.cycleSquareSide,
3791
- roundness: r.roundness,
3792
- detourDistance: r.detourDistance
3793
- });
3794
- case "direct":
3795
- return () => new $e({
3796
- color: r.color,
3797
- width: r.width,
3798
- arrowLength: r.arrowLength,
3799
- arrowRenderer: r.arrowRenderer,
3800
- hasSourceArrow: r.hasSourceArrow,
3801
- hasTargetArrow: r.hasTargetArrow,
3802
- sourceOffset: r.sourceOffset,
3803
- targetOffset: r.targetOffset
3804
- });
3805
- default:
3806
- return () => new Rt({
3807
- color: r.color,
3808
- width: r.width,
3809
- arrowLength: r.arrowLength,
3810
- arrowRenderer: r.arrowRenderer,
3811
- hasSourceArrow: r.hasSourceArrow,
3812
- hasTargetArrow: r.hasTargetArrow,
3813
- cycleRadius: r.cycleRadius,
3814
- smallCycleRadius: r.smallCycleRadius,
3815
- curvature: r.curvature,
3816
- detourDistance: r.detourDistance,
3817
- detourDirection: r.detourDirection
3818
- });
3819
- }
3820
- }, sr = (r, e, t) => {
3821
- var c, u, g;
3822
- const o = () => "direct", s = (l) => l, n = (l) => l.button === 0, a = () => {
3823
- }, h = () => {
3824
- }, d = () => {
3825
- };
3873
+ }, $ = Object.freeze({
3874
+ connectionTypeResolver: () => "direct",
3875
+ connectionPreprocessor: (r) => r,
3876
+ connectionAllowedVerifier: () => !0,
3877
+ mouseEventVerifier: (r) => r.button === 0
3878
+ }), hr = (r, e, t) => {
3879
+ var s, n, a;
3880
+ const o = r.connectionAllowedVerifier ?? $.connectionAllowedVerifier;
3826
3881
  return {
3827
- connectionTypeResolver: r.connectionTypeResolver ?? o,
3828
- connectionPreprocessor: r.connectionPreprocessor ?? s,
3829
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? n,
3830
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? n,
3831
- onAfterEdgeCreated: ((c = r.events) == null ? void 0 : c.onAfterEdgeCreated) ?? a,
3832
- onEdgeCreationInterrupted: ((u = r.events) == null ? void 0 : u.onEdgeCreationInterrupted) ?? d,
3833
- onEdgeCreationPrevented: ((g = r.events) == null ? void 0 : g.onEdgeCreationPrevented) ?? h,
3834
- dragPortDirection: r.dragPortDirection ?? t,
3835
- edgeShapeFactory: r.edgeShape !== void 0 ? ye(r.edgeShape) : e
3836
- };
3837
- }, ir = (r, e) => {
3838
- var c, u, g;
3839
- const t = (l) => l, o = (l) => l.button === 0 && l.ctrlKey, s = (l) => l.button === 0, n = (l) => {
3840
- const w = e.getPortAdjacentEdgeIds(l);
3841
- return w.length > 0 ? w[w.length - 1] : null;
3842
- }, a = () => {
3843
- }, h = () => {
3844
- }, d = () => {
3882
+ connectionTypeResolver: r.connectionTypeResolver ?? $.connectionTypeResolver,
3883
+ connectionAllowedVerifier: o,
3884
+ draggingPortDirectionResolver: je(
3885
+ r.dragPortDirection,
3886
+ t,
3887
+ o
3888
+ ),
3889
+ edgeShapeFactory: r.edgeShape !== void 0 ? ve(r.edgeShape) : e,
3890
+ connectionPreprocessor: r.connectionPreprocessor ?? $.connectionPreprocessor,
3891
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? $.mouseEventVerifier,
3892
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? $.mouseEventVerifier,
3893
+ onAfterEdgeCreated: ((s = r.events) == null ? void 0 : s.onAfterEdgeCreated) ?? N,
3894
+ onEdgeCreationInterrupted: ((n = r.events) == null ? void 0 : n.onEdgeCreationInterrupted) ?? N,
3895
+ onEdgeCreationPrevented: ((a = r.events) == null ? void 0 : a.onEdgeCreationPrevented) ?? N
3845
3896
  };
3897
+ }, z = Object.freeze({
3898
+ connectionAllowedVerifier: () => !0,
3899
+ connectionPreprocessor: (r) => r,
3900
+ // TODO: remove ctrl key
3901
+ mouseDownEventVerifier: (r) => r.button === 0 && r.ctrlKey,
3902
+ mouseUpEventVerifier: (r) => r.button === 0
3903
+ }), dr = (r, e) => {
3904
+ var s, n, a;
3905
+ const t = (h) => {
3906
+ const d = e.getPortAdjacentEdgeIds(h);
3907
+ return d.length > 0 ? d[d.length - 1] : null;
3908
+ }, o = r.connectionAllowedVerifier ?? z.connectionAllowedVerifier;
3846
3909
  return {
3847
- connectionPreprocessor: r.connectionPreprocessor ?? t,
3848
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? o,
3849
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? s,
3850
- draggingEdgeResolver: r.draggingEdgeResolver ?? n,
3851
- draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ye(r.draggingEdgeShape) : null,
3852
- onAfterEdgeReattached: ((c = r.events) == null ? void 0 : c.onAfterEdgeReattached) ?? a,
3853
- onEdgeReattachInterrupted: ((u = r.events) == null ? void 0 : u.onEdgeReattachInterrupted) ?? d,
3854
- onEdgeReattachPrevented: ((g = r.events) == null ? void 0 : g.onEdgeReattachPrevented) ?? h
3910
+ connectionPreprocessor: r.connectionPreprocessor ?? z.connectionPreprocessor,
3911
+ connectionAllowedVerifier: o,
3912
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? z.mouseDownEventVerifier,
3913
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? z.mouseUpEventVerifier,
3914
+ draggingEdgeResolver: r.draggingEdgeResolver ?? t,
3915
+ draggingEdgeShapeFactory: r.draggingEdgeShape !== void 0 ? ve(r.draggingEdgeShape) : null,
3916
+ onAfterEdgeReattached: ((s = r.events) == null ? void 0 : s.onAfterEdgeReattached) ?? N,
3917
+ onEdgeReattachInterrupted: ((n = r.events) == null ? void 0 : n.onEdgeReattachInterrupted) ?? N,
3918
+ onEdgeReattachPrevented: ((a = r.events) == null ? void 0 : a.onEdgeReattachPrevented) ?? N,
3919
+ draggingPortDirectionResolver: je(
3920
+ r.dragPortDirection,
3921
+ e,
3922
+ o
3923
+ )
3855
3924
  };
3856
- }, nr = (r) => ({
3925
+ }, cr = (r) => ({
3857
3926
  nodeVerticalRadius: r.nodeContainingRadius.vertical,
3858
3927
  nodeHorizontalRadius: r.nodeContainingRadius.horizontal
3859
- }), ar = (r) => {
3928
+ }), lr = (r) => {
3860
3929
  var e, t;
3861
3930
  return {
3862
- onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? (() => {
3863
- }),
3864
- onBeforeNodeAttached: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeNodeAttached) ?? (() => {
3865
- })
3931
+ onAfterNodeDetached: ((e = r == null ? void 0 : r.events) == null ? void 0 : e.onAfterNodeDetached) ?? N,
3932
+ onBeforeNodeAttached: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeNodeAttached) ?? N
3866
3933
  };
3867
3934
  };
3868
- class hr extends Error {
3935
+ class ur extends Error {
3869
3936
  constructor() {
3870
3937
  super(...arguments);
3871
3938
  i(this, "name", "CanvasBuilderError");
3872
3939
  }
3873
3940
  }
3874
- class Ge {
3941
+ class Je {
3875
3942
  constructor(e, t, o) {
3876
3943
  i(this, "dt");
3877
3944
  i(this, "nodeMass");
@@ -3904,12 +3971,12 @@ class Ge {
3904
3971
  const o = this.graph.getEdge(t), s = this.graph.getPort(o.from), n = this.graph.getPort(o.to), a = this.currentCoords.get(s.nodeId), h = this.currentCoords.get(n.nodeId), d = this.distanceVectorGenerator.create(
3905
3972
  a,
3906
3973
  h
3907
- ), u = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, g = d.ex * u, l = d.ey * u, w = e.get(s.nodeId), p = e.get(n.nodeId);
3908
- w.x += g, w.y += l, p.x -= g, p.y -= l;
3974
+ ), u = (d.d - this.edgeEquilibriumLength) * this.edgeStiffness, g = d.ex * u, l = d.ey * u, p = e.get(s.nodeId), w = e.get(n.nodeId);
3975
+ p.x += g, p.y += l, w.x -= g, w.y -= l;
3909
3976
  });
3910
3977
  }
3911
3978
  }
3912
- class je {
3979
+ class Ke {
3913
3980
  constructor(e) {
3914
3981
  i(this, "PI2", 2 * Math.PI);
3915
3982
  this.rand = e;
@@ -3928,13 +3995,13 @@ class je {
3928
3995
  return { ex: h, ey: d, d: a };
3929
3996
  }
3930
3997
  }
3931
- const Je = (r) => {
3998
+ const Qe = (r) => {
3932
3999
  if (r.distance === 0)
3933
4000
  return r.maxForce;
3934
4001
  const e = r.coefficient * (r.sourceCharge * r.targetCharge / (r.distance * r.distance));
3935
4002
  return Math.min(e, r.maxForce);
3936
4003
  };
3937
- class dr {
4004
+ class gr {
3938
4005
  constructor(e) {
3939
4006
  i(this, "nodeCharge");
3940
4007
  i(this, "distanceVectorGenerator");
@@ -3949,19 +4016,19 @@ class dr {
3949
4016
  const d = o[h], c = e.get(a), u = e.get(d), g = this.distanceVectorGenerator.create(
3950
4017
  c,
3951
4018
  u
3952
- ), l = Je({
4019
+ ), l = Qe({
3953
4020
  coefficient: 1,
3954
4021
  sourceCharge: this.nodeCharge,
3955
4022
  targetCharge: this.nodeCharge,
3956
4023
  distance: g.d,
3957
4024
  maxForce: this.maxForce
3958
- }), w = l * g.ex, p = l * g.ey, y = t.get(a), f = t.get(d);
3959
- y.x -= w, y.y -= p, f.x += w, f.y += p;
4025
+ }), p = l * g.ex, w = l * g.ey, y = t.get(a), f = t.get(d);
4026
+ y.x -= p, y.y -= w, f.x += p, f.y += w;
3960
4027
  }
3961
4028
  }
3962
4029
  }
3963
4030
  }
3964
- const cr = (r) => {
4031
+ const pr = (r) => {
3965
4032
  if (r.size === 0)
3966
4033
  return {
3967
4034
  centerX: 0,
@@ -3979,7 +4046,7 @@ const cr = (r) => {
3979
4046
  radius: h / 2
3980
4047
  };
3981
4048
  };
3982
- class lr {
4049
+ class wr {
3983
4050
  constructor(e) {
3984
4051
  i(this, "root");
3985
4052
  i(this, "leaves", /* @__PURE__ */ new Map());
@@ -4034,8 +4101,8 @@ class lr {
4034
4101
  this.sortedParentNodes.push(e);
4035
4102
  const n = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), h = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), c = s / 2;
4036
4103
  e.nodeIds.forEach((l) => {
4037
- const { x: w, y: p } = this.coords.get(l);
4038
- w < t ? p < o ? d.add(l) : h.add(l) : p < o ? a.add(l) : n.add(l), e.nodeIds.delete(l);
4104
+ const { x: p, y: w } = this.coords.get(l);
4105
+ p < t ? w < o ? d.add(l) : h.add(l) : w < o ? a.add(l) : n.add(l), e.nodeIds.delete(l);
4039
4106
  });
4040
4107
  const u = {
4041
4108
  parent: e,
@@ -4136,7 +4203,7 @@ class lr {
4136
4203
  }), { x: t / e.size, y: o / e.size };
4137
4204
  }
4138
4205
  }
4139
- class ur {
4206
+ class yr {
4140
4207
  constructor(e) {
4141
4208
  i(this, "areaRadiusThreshold");
4142
4209
  i(this, "nodeMass");
@@ -4148,7 +4215,7 @@ class ur {
4148
4215
  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;
4149
4216
  }
4150
4217
  apply(e, t) {
4151
- const o = cr(e), s = new lr({
4218
+ const o = pr(e), s = new wr({
4152
4219
  box: o,
4153
4220
  coords: e,
4154
4221
  areaRadiusThreshold: this.areaRadiusThreshold,
@@ -4263,7 +4330,7 @@ class ur {
4263
4330
  const t = this.distanceVectorGenerator.create(
4264
4331
  e.sourceCoords,
4265
4332
  e.targetCoords
4266
- ), o = Je({
4333
+ ), o = Qe({
4267
4334
  coefficient: this.nodeForceCoefficient,
4268
4335
  sourceCharge: e.sourceCharge,
4269
4336
  targetCharge: e.targetCharge,
@@ -4298,7 +4365,7 @@ class ur {
4298
4365
  }
4299
4366
  }
4300
4367
  }
4301
- const Ke = (r) => r.theta !== 0 ? new ur({
4368
+ const Ze = (r) => r.theta !== 0 ? new yr({
4302
4369
  nodeCharge: r.nodeCharge,
4303
4370
  nodeForceCoefficient: r.nodeForceCoefficient,
4304
4371
  distanceVectorGenerator: r.distanceVectorGenerator,
@@ -4306,36 +4373,36 @@ const Ke = (r) => r.theta !== 0 ? new ur({
4306
4373
  theta: r.theta,
4307
4374
  nodeMass: r.nodeMass,
4308
4375
  areaRadiusThreshold: r.areaRadiusThreshold
4309
- }) : new dr({
4376
+ }) : new gr({
4310
4377
  nodeCharge: r.nodeCharge,
4311
4378
  nodeForceCoefficient: r.nodeForceCoefficient,
4312
4379
  distanceVectorGenerator: r.distanceVectorGenerator,
4313
4380
  maxForce: r.maxForce
4314
4381
  });
4315
- class Qe {
4382
+ class _e {
4316
4383
  constructor(e) {
4317
4384
  i(this, "rand");
4318
4385
  i(this, "sparsity");
4319
4386
  this.rand = e.rand, this.sparsity = e.sparsity;
4320
4387
  }
4321
4388
  calculateCoordinates(e) {
4322
- const { graph: t, viewport: o } = e, s = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((p) => {
4323
- const y = t.getNode(p);
4389
+ const { graph: t, viewport: o } = e, s = /* @__PURE__ */ new Map(), n = t.getAllNodeIds().filter((w) => {
4390
+ const y = t.getNode(w);
4324
4391
  return y.x === null || y.y === null;
4325
4392
  }), a = Math.sqrt(n.length) * this.sparsity, { width: h, height: d } = o.getDimensions(), c = { x: h / 2, y: d / 2 }, u = o.createContentCoords(c), g = a / 2, l = {
4326
4393
  x: u.x - g,
4327
4394
  y: u.y - g
4328
4395
  };
4329
- return t.getAllNodeIds().forEach((p) => {
4330
- const y = t.getNode(p);
4331
- s.set(p, {
4396
+ return t.getAllNodeIds().forEach((w) => {
4397
+ const y = t.getNode(w);
4398
+ s.set(w, {
4332
4399
  x: y.x ?? l.x + a * this.rand(),
4333
4400
  y: y.y ?? l.y + a * this.rand()
4334
4401
  });
4335
4402
  }), s;
4336
4403
  }
4337
4404
  }
4338
- class gr {
4405
+ class fr {
4339
4406
  constructor(e) {
4340
4407
  i(this, "distanceVectorGenerator");
4341
4408
  i(this, "nodeForcesApplicationStrategy");
@@ -4346,7 +4413,7 @@ class gr {
4346
4413
  i(this, "edgeEquilibriumLength");
4347
4414
  i(this, "edgeStiffness");
4348
4415
  i(this, "convergenceVelocity");
4349
- 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 je(e.rand), this.nodeForcesApplicationStrategy = Ke({
4416
+ 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 Ke(e.rand), this.nodeForcesApplicationStrategy = Ze({
4350
4417
  distanceVectorGenerator: this.distanceVectorGenerator,
4351
4418
  nodeCharge: e.nodeCharge,
4352
4419
  maxForce: e.maxForce,
@@ -4354,7 +4421,7 @@ class gr {
4354
4421
  theta: e.barnesHutTheta,
4355
4422
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
4356
4423
  nodeMass: e.nodeMass
4357
- }), this.fillerLayoutAlgorithm = new Qe({
4424
+ }), this.fillerLayoutAlgorithm = new _e({
4358
4425
  rand: e.rand,
4359
4426
  sparsity: e.edgeEquilibriumLength
4360
4427
  });
@@ -4364,7 +4431,7 @@ class gr {
4364
4431
  graph: t,
4365
4432
  viewport: o
4366
4433
  });
4367
- for (let n = 0; n < this.maxIterations && !(new Ge(
4434
+ for (let n = 0; n < this.maxIterations && !(new Je(
4368
4435
  t,
4369
4436
  s,
4370
4437
  {
@@ -4380,7 +4447,7 @@ class gr {
4380
4447
  return s;
4381
4448
  }
4382
4449
  }
4383
- class pr {
4450
+ class vr {
4384
4451
  constructor(e, t) {
4385
4452
  i(this, "forest", /* @__PURE__ */ new Set());
4386
4453
  i(this, "remainingNodeIds");
@@ -4421,7 +4488,7 @@ class pr {
4421
4488
  }
4422
4489
  }
4423
4490
  }
4424
- class wr {
4491
+ class mr {
4425
4492
  constructor(e) {
4426
4493
  this.params = e;
4427
4494
  }
@@ -4462,12 +4529,12 @@ class wr {
4462
4529
  return o - 2 * this.params.spaceAroundRadius;
4463
4530
  }
4464
4531
  }
4465
- class yr {
4532
+ class xr {
4466
4533
  constructor(e, t) {
4467
4534
  i(this, "offsets", /* @__PURE__ */ new Map());
4468
4535
  i(this, "treeSpans", /* @__PURE__ */ new Map());
4469
4536
  this.tree = e;
4470
- const o = t.spaceAroundRadius, s = new wr({
4537
+ const o = t.spaceAroundRadius, s = new mr({
4471
4538
  spaceAroundRadius: o
4472
4539
  });
4473
4540
  [...this.tree.sequence].reverse().forEach((n) => {
@@ -4489,19 +4556,19 @@ class yr {
4489
4556
  return this.offsets;
4490
4557
  }
4491
4558
  }
4492
- class fr {
4559
+ class Er {
4493
4560
  constructor(e) {
4494
4561
  this.params = e;
4495
4562
  }
4496
4563
  calculateCoordinates(e) {
4497
- const t = /* @__PURE__ */ new Map(), s = new pr(
4564
+ const t = /* @__PURE__ */ new Map(), s = new vr(
4498
4565
  e.graph,
4499
4566
  this.params.nextLayerNodesResolver
4500
4567
  ).generate();
4501
4568
  let n = 0;
4502
4569
  return s.forEach((a) => {
4503
4570
  t.set(a.root.nodeId, { x: n, y: 0 });
4504
- const d = new yr(a, {
4571
+ const d = new xr(a, {
4505
4572
  spaceAroundRadius: this.params.layerSpace / 2
4506
4573
  }).generate();
4507
4574
  let c = [a.root];
@@ -4509,9 +4576,9 @@ class fr {
4509
4576
  const u = [];
4510
4577
  n += this.params.layerWidth, c.forEach((g) => {
4511
4578
  g.children.forEach((l) => {
4512
- const w = t.get(g.nodeId).y;
4579
+ const p = t.get(g.nodeId).y;
4513
4580
  t.set(l.nodeId, {
4514
- y: w + d.get(l.nodeId),
4581
+ y: p + d.get(l.nodeId),
4515
4582
  x: n
4516
4583
  }), u.push(l);
4517
4584
  });
@@ -4522,7 +4589,7 @@ class fr {
4522
4589
  }), t;
4523
4590
  }
4524
4591
  }
4525
- const vr = (r) => {
4592
+ const Ar = (r) => {
4526
4593
  const { graph: e, currentNodeId: t } = r, o = e.getNodeOutgoingEdgeIds(t).map((n) => {
4527
4594
  const a = e.getEdge(n);
4528
4595
  return e.getPort(a.to).nodeId;
@@ -4531,20 +4598,20 @@ const vr = (r) => {
4531
4598
  return e.getPort(a.from).nodeId;
4532
4599
  });
4533
4600
  return /* @__PURE__ */ new Set([...o, ...s]);
4534
- }, mr = (r) => {
4601
+ }, Sr = (r) => {
4535
4602
  const { graph: e, currentNodeId: t } = r, o = e.getNodeOutgoingEdgeIds(t).map((s) => {
4536
4603
  const n = e.getEdge(s);
4537
4604
  return e.getPort(n.to).nodeId;
4538
4605
  });
4539
4606
  return new Set(o);
4540
- }, xr = (r) => {
4607
+ }, br = (r) => {
4541
4608
  const { graph: e, currentNodeId: t } = r, o = e.getNodeIncomingEdgeIds(t).map((s) => {
4542
4609
  const n = e.getEdge(s);
4543
4610
  return e.getPort(n.from).nodeId;
4544
4611
  });
4545
4612
  return new Set(o);
4546
4613
  };
4547
- class Er {
4614
+ class Nr {
4548
4615
  constructor(e) {
4549
4616
  i(this, "distanceVectorGenerator");
4550
4617
  i(this, "nodeForcesApplicationStrategy");
@@ -4554,7 +4621,7 @@ class Er {
4554
4621
  i(this, "edgeEquilibriumLength");
4555
4622
  i(this, "edgeStiffness");
4556
4623
  i(this, "fillerLayoutAlgorithm");
4557
- this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new je(e.rand), this.nodeForcesApplicationStrategy = Ke({
4624
+ this.convergenceVelocity = e.convergenceVelocity, this.maxTimeDeltaSec = e.maxTimeDeltaSec, this.nodeMass = e.nodeMass, this.edgeEquilibriumLength = e.edgeEquilibriumLength, this.edgeStiffness = e.edgeStiffness, this.distanceVectorGenerator = new Ke(e.rand), this.nodeForcesApplicationStrategy = Ze({
4558
4625
  distanceVectorGenerator: this.distanceVectorGenerator,
4559
4626
  nodeCharge: e.nodeCharge,
4560
4627
  maxForce: e.maxForce,
@@ -4562,7 +4629,7 @@ class Er {
4562
4629
  theta: e.barnesHutTheta,
4563
4630
  areaRadiusThreshold: e.barnesHutAreaRadiusThreshold,
4564
4631
  nodeMass: e.nodeMass
4565
- }), this.fillerLayoutAlgorithm = new Qe({
4632
+ }), this.fillerLayoutAlgorithm = new _e({
4566
4633
  rand: e.rand,
4567
4634
  sparsity: e.edgeEquilibriumLength
4568
4635
  });
@@ -4572,7 +4639,7 @@ class Er {
4572
4639
  graph: t,
4573
4640
  viewport: o
4574
4641
  });
4575
- return new Ge(
4642
+ return new Je(
4576
4643
  t,
4577
4644
  n,
4578
4645
  {
@@ -4589,41 +4656,23 @@ class Er {
4589
4656
  }) ? /* @__PURE__ */ new Map() : n;
4590
4657
  }
4591
4658
  }
4592
- const Ze = (r) => {
4659
+ const qe = (r) => {
4593
4660
  let e = 1779033703, t = 3144134277, o = 1013904242, s = 2773480762;
4594
4661
  for (let n = 0, a; n < r.length; n++)
4595
4662
  a = r.charCodeAt(n), e = t ^ Math.imul(e ^ a, 597399067), t = o ^ Math.imul(t ^ a, 2869860233), o = s ^ Math.imul(o ^ a, 951274213), s = e ^ Math.imul(s ^ a, 2716044179);
4596
4663
  return e = Math.imul(o ^ e >>> 18, 597399067), t = Math.imul(s ^ t >>> 22, 2869860233), o = Math.imul(e ^ o >>> 17, 951274213), s = Math.imul(t ^ s >>> 19, 2716044179), e ^= t ^ o ^ s, t ^= e, o ^= e, s ^= e, [e >>> 0, t >>> 0, o >>> 0, s >>> 0];
4597
- }, _e = (r, e, t, o) => function() {
4664
+ }, et = (r, e, t, o) => function() {
4598
4665
  r |= 0, e |= 0, t |= 0, o |= 0;
4599
4666
  const s = (r + e | 0) + o | 0;
4600
4667
  return o = o + 1 | 0, r = e ^ e >>> 9, e = t + (t << 3) | 0, t = t << 21 | t >>> 11, t = t + s | 0, (s >>> 0) / 4294967296;
4601
- }, b = Object.freeze({
4602
- seed: "HTMLGraph is awesome",
4603
- maxTimeDeltaSec: 0.01,
4604
- nodeCharge: 1e5,
4605
- nodeMass: 1,
4606
- edgeEquilibriumLength: 300,
4607
- edgeStiffness: 1e3,
4608
- dtSec: 0.01,
4609
- maxIterations: 1e3,
4610
- convergenceVelocity: 10,
4611
- maxForce: 1e7,
4612
- nodeForceCoefficient: 1,
4613
- barnesHutAreaRadiusThreshold: 0.01,
4614
- barnesHutTheta: 1
4615
- }), D = Object.freeze({
4616
- mouseDownEventVerifier: (r) => r.button === 0,
4617
- mouseUpEventVerifier: (r) => r.button === 0,
4618
- movementThreshold: 10
4619
- }), Ar = (r) => {
4668
+ }, Pr = (r) => {
4620
4669
  var e, t;
4621
4670
  switch (r == null ? void 0 : r.type) {
4622
4671
  case "custom":
4623
4672
  return r.instance;
4624
4673
  default: {
4625
- const o = Ze((r == null ? void 0 : r.seed) ?? b.seed), s = _e(o[0], o[1], o[2], o[3]);
4626
- return new Er({
4674
+ const o = qe((r == null ? void 0 : r.seed) ?? b.seed), s = et(o[0], o[1], o[2], o[3]);
4675
+ return new Nr({
4627
4676
  rand: s,
4628
4677
  maxTimeDeltaSec: (r == null ? void 0 : r.maxTimeDeltaSec) ?? b.maxTimeDeltaSec,
4629
4678
  nodeCharge: (r == null ? void 0 : r.nodeCharge) ?? b.nodeCharge,
@@ -4638,47 +4687,39 @@ const Ze = (r) => {
4638
4687
  });
4639
4688
  }
4640
4689
  }
4641
- }, K = {
4642
- staticNodeResolver: () => !1,
4643
- onBeforeApplied: () => {
4644
- },
4645
- onAfterApplied: () => {
4646
- }
4647
- }, Sr = (r) => {
4690
+ }, Cr = {
4691
+ staticNodeResolver: () => !1
4692
+ }, Tr = (r) => {
4648
4693
  var t, o;
4649
4694
  return {
4650
- algorithm: Ar((r == null ? void 0 : r.algorithm) ?? {}),
4651
- staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? K.staticNodeResolver,
4652
- onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? K.onBeforeApplied,
4653
- onAfterApplied: ((o = r == null ? void 0 : r.events) == null ? void 0 : o.onAfterApplied) ?? K.onAfterApplied
4695
+ algorithm: Pr((r == null ? void 0 : r.algorithm) ?? {}),
4696
+ staticNodeResolver: (r == null ? void 0 : r.staticNodeResolver) ?? Cr.staticNodeResolver,
4697
+ onBeforeApplied: ((t = r == null ? void 0 : r.events) == null ? void 0 : t.onBeforeApplied) ?? N,
4698
+ onAfterApplied: ((o = r == null ? void 0 : r.events) == null ? void 0 : o.onAfterApplied) ?? N
4654
4699
  };
4655
- }, br = (r) => r instanceof _ ? {
4700
+ }, Mr = (r) => r instanceof q ? {
4656
4701
  type: "trigger",
4657
4702
  trigger: r
4658
4703
  } : (r == null ? void 0 : r.type) === "topologyChangeMacrotask" ? {
4659
4704
  type: "topologyChangeSchedule",
4660
- schedule: Bt
4705
+ schedule: Wt
4661
4706
  } : {
4662
4707
  type: "topologyChangeSchedule",
4663
- schedule: Ot
4664
- }, $ = Object.freeze({
4708
+ schedule: zt
4709
+ }, Z = Object.freeze({
4665
4710
  staticNodeResolver: () => !1,
4666
- onBeforeApplied: () => {
4667
- },
4668
- onAfterApplied: () => {
4669
- },
4670
4711
  hierarchicalLayout: {
4671
4712
  layerWidth: 300,
4672
4713
  layerSpace: 300
4673
4714
  }
4674
- }), z = (r, e) => ({
4715
+ }), k = (r, e) => ({
4675
4716
  a: r.a * e.a + r.b * e.d,
4676
4717
  b: r.a * e.b + r.b * e.e,
4677
4718
  c: r.a * e.c + r.b * e.f + r.c,
4678
4719
  d: r.d * e.a + r.e * e.d,
4679
4720
  e: r.d * e.b + r.e * e.e,
4680
4721
  f: r.d * e.c + r.e * e.f + r.f
4681
- }), Nr = (r) => {
4722
+ }), Dr = (r) => {
4682
4723
  const { a: e, b: t, c: o, d: s, e: n, f: a } = r, h = e * n - t * s;
4683
4724
  return {
4684
4725
  a: n / h,
@@ -4689,7 +4730,7 @@ const Ze = (r) => {
4689
4730
  f: (o * s - e * a) / h
4690
4731
  };
4691
4732
  };
4692
- class Pr {
4733
+ class Rr {
4693
4734
  resolve(e) {
4694
4735
  if ("shift" in e)
4695
4736
  return this.createShiftBaseMatrix(e.shift);
@@ -4723,18 +4764,18 @@ class Pr {
4723
4764
  return this.createRelativeTransform(o, s);
4724
4765
  }
4725
4766
  createMirrorRelativeMatrix(e, t) {
4726
- const o = this.createMirrorYBaseMatrix(), s = z(
4767
+ const o = this.createMirrorYBaseMatrix(), s = k(
4727
4768
  this.createShiftBaseMatrix(t),
4728
4769
  this.createRotateBaseMatrix(e)
4729
4770
  );
4730
4771
  return this.createRelativeTransform(o, s);
4731
4772
  }
4732
4773
  createRelativeTransform(e, t) {
4733
- const o = z(
4774
+ const o = k(
4734
4775
  t,
4735
4776
  e
4736
- ), s = Nr(t);
4737
- return z(o, s);
4777
+ ), s = Dr(t);
4778
+ return k(o, s);
4738
4779
  }
4739
4780
  createShiftBaseMatrix(e) {
4740
4781
  return {
@@ -4778,7 +4819,7 @@ class Pr {
4778
4819
  };
4779
4820
  }
4780
4821
  }
4781
- const Cr = (r) => {
4822
+ const Lr = (r) => {
4782
4823
  if (r === void 0)
4783
4824
  return (s) => s;
4784
4825
  if (typeof r == "function")
@@ -4792,10 +4833,10 @@ const Cr = (r) => {
4792
4833
  e: 1,
4793
4834
  f: 0
4794
4835
  };
4795
- const o = new Pr();
4836
+ const o = new Rr();
4796
4837
  return e.forEach((s) => {
4797
4838
  const n = o.resolve(s);
4798
- t = z(t, n);
4839
+ t = k(t, n);
4799
4840
  }), (s) => {
4800
4841
  const { x: n, y: a } = s;
4801
4842
  return {
@@ -4803,34 +4844,34 @@ const Cr = (r) => {
4803
4844
  y: t.d * n + t.e * a + t.f
4804
4845
  };
4805
4846
  };
4806
- }, Tr = (r) => {
4847
+ }, Vr = (r) => {
4807
4848
  if (typeof r == "function")
4808
4849
  return r;
4809
4850
  switch (r) {
4810
4851
  case "outgoing":
4811
- return mr;
4852
+ return Sr;
4812
4853
  case "incoming":
4813
- return xr;
4854
+ return br;
4814
4855
  default:
4815
- return vr;
4856
+ return Ar;
4816
4857
  }
4817
- }, Mr = (r) => {
4858
+ }, Ir = (r) => {
4818
4859
  var e, t;
4819
4860
  switch (r == null ? void 0 : r.type) {
4820
4861
  case "custom":
4821
4862
  return r.instance;
4822
4863
  case "hierarchical":
4823
- return new fr({
4824
- layerWidth: r.layerWidth ?? $.hierarchicalLayout.layerWidth,
4825
- layerSpace: r.layerSpace ?? $.hierarchicalLayout.layerSpace,
4826
- transform: Cr(r.transform),
4827
- nextLayerNodesResolver: Tr(
4864
+ return new Er({
4865
+ layerWidth: r.layerWidth ?? Z.hierarchicalLayout.layerWidth,
4866
+ layerSpace: r.layerSpace ?? Z.hierarchicalLayout.layerSpace,
4867
+ transform: Lr(r.transform),
4868
+ nextLayerNodesResolver: Vr(
4828
4869
  r.nextLayerNodesResolver
4829
4870
  )
4830
4871
  });
4831
4872
  default: {
4832
- const o = Ze((r == null ? void 0 : r.seed) ?? b.seed), s = _e(o[0], o[1], o[2], o[3]);
4833
- return new gr({
4873
+ const o = qe((r == null ? void 0 : r.seed) ?? b.seed), s = et(o[0], o[1], o[2], o[3]);
4874
+ return new fr({
4834
4875
  dtSec: (r == null ? void 0 : r.dtSec) ?? b.dtSec,
4835
4876
  maxIterations: (r == null ? void 0 : r.maxIterations) ?? b.maxIterations,
4836
4877
  rand: s,
@@ -4846,16 +4887,16 @@ const Cr = (r) => {
4846
4887
  });
4847
4888
  }
4848
4889
  }
4849
- }, Dr = (r) => {
4890
+ }, Fr = (r) => {
4850
4891
  var e, t;
4851
4892
  return {
4852
- algorithm: Mr(r.algorithm),
4853
- applyOn: br(r.applyOn),
4854
- staticNodeResolver: r.staticNodeResolver ?? $.staticNodeResolver,
4855
- onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? $.onBeforeApplied,
4856
- onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? $.onAfterApplied
4893
+ algorithm: Ir(r.algorithm),
4894
+ applyOn: Mr(r.applyOn),
4895
+ staticNodeResolver: r.staticNodeResolver ?? Z.staticNodeResolver,
4896
+ onBeforeApplied: ((e = r.events) == null ? void 0 : e.onBeforeApplied) ?? N,
4897
+ onAfterApplied: ((t = r.events) == null ? void 0 : t.onAfterApplied) ?? N
4857
4898
  };
4858
- }, Rr = (r, e) => ({
4899
+ }, Ur = (r, e) => ({
4859
4900
  ...r,
4860
4901
  onNodeDragStarted: (t) => {
4861
4902
  e.add(t), r.onNodeDragStarted(t);
@@ -4863,7 +4904,7 @@ const Cr = (r) => {
4863
4904
  onNodeDragFinished: (t) => {
4864
4905
  e.delete(t), r.onNodeDragFinished(t);
4865
4906
  }
4866
- }), Lr = (r, e) => {
4907
+ }), $r = (r, e) => {
4867
4908
  r.graph.onBeforeNodeRemoved.subscribe((t) => {
4868
4909
  e.delete(t);
4869
4910
  }), r.graph.onBeforeClear.subscribe(() => {
@@ -4871,41 +4912,41 @@ const Cr = (r) => {
4871
4912
  }), r.onBeforeDestroy.subscribe(() => {
4872
4913
  e.clear();
4873
4914
  });
4874
- }, Vr = (r, e) => ({
4915
+ }, Br = (r, e) => ({
4875
4916
  ...r,
4876
4917
  staticNodeResolver: (t) => r.staticNodeResolver(t) || e.has(t)
4877
- }), Z = (r) => () => r, Pe = Z(0), Ir = () => {
4918
+ }), _ = (r) => () => r, Ce = _(0), Or = () => {
4878
4919
  let r = 0;
4879
4920
  return () => r++;
4880
- }, Fr = (r, e) => {
4881
- let t = Pe, o = Pe;
4882
- const s = Ir();
4883
- return r === "incremental" && (t = s), e === "incremental" && (o = s), typeof r == "number" && (t = Z(r)), typeof e == "number" && (o = Z(e)), typeof r == "function" && (t = r), typeof e == "function" && (o = e), {
4921
+ }, Wr = (r, e) => {
4922
+ let t = Ce, o = Ce;
4923
+ const s = Or();
4924
+ return r === "incremental" && (t = s), e === "incremental" && (o = s), typeof r == "number" && (t = _(r)), typeof e == "number" && (o = _(e)), typeof r == "function" && (t = r), typeof e == "function" && (o = e), {
4884
4925
  nodesPriorityFn: t,
4885
4926
  edgesPriorityFn: o
4886
4927
  };
4887
- }, Ur = (r) => {
4928
+ }, zr = (r) => {
4888
4929
  var t, o, s, n, a;
4889
- const e = Fr(
4930
+ const e = Wr(
4890
4931
  (t = r.nodes) == null ? void 0 : t.priority,
4891
4932
  (o = r.edges) == null ? void 0 : o.priority
4892
4933
  );
4893
4934
  return {
4894
4935
  nodes: {
4895
- centerFn: ((s = r.nodes) == null ? void 0 : s.centerFn) ?? Le,
4936
+ centerFn: ((s = r.nodes) == null ? void 0 : s.centerFn) ?? Ve,
4896
4937
  priorityFn: e.nodesPriorityFn
4897
4938
  },
4898
4939
  ports: {
4899
4940
  direction: ((n = r.ports) == null ? void 0 : n.direction) ?? 0
4900
4941
  },
4901
4942
  edges: {
4902
- shapeFactory: ye(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4943
+ shapeFactory: ve(((a = r.edges) == null ? void 0 : a.shape) ?? {}),
4903
4944
  priorityFn: e.edgesPriorityFn
4904
4945
  }
4905
4946
  };
4906
- }, $r = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : re, Br = (r) => {
4947
+ }, kr = (r) => r.applyOn.type === "topologyChangeSchedule" ? r.applyOn.schedule : oe, Hr = (r) => {
4907
4948
  var o, s, n, a;
4908
- const { canvasDefaults: e } = r, t = r.hasLayout ? $r(r.layoutParams) : re;
4949
+ const { canvasDefaults: e } = r, t = r.hasLayout ? kr(r.layoutParams) : oe;
4909
4950
  return {
4910
4951
  focus: {
4911
4952
  contentPadding: ((o = e.focus) == null ? void 0 : o.contentPadding) ?? ((s = e.focus) == null ? void 0 : s.contentOffset) ?? 100,
@@ -4914,23 +4955,23 @@ const Cr = (r) => {
4914
4955
  animationDuration: ((a = e.focus) == null ? void 0 : a.animationDuration) ?? 0
4915
4956
  }
4916
4957
  };
4917
- }, Or = (r) => ({
4958
+ }, Yr = (r) => ({
4918
4959
  onNodeSelected: r.onNodeSelected,
4919
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? D.mouseDownEventVerifier,
4920
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? D.mouseUpEventVerifier,
4921
- movementThreshold: r.movementThreshold ?? D.movementThreshold
4922
- }), Wr = (r) => ({
4960
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? L.mouseDownEventVerifier,
4961
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? L.mouseUpEventVerifier,
4962
+ movementThreshold: r.movementThreshold ?? L.movementThreshold
4963
+ }), Xr = (r) => ({
4923
4964
  onCanvasSelected: r.onCanvasSelected,
4924
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? D.mouseDownEventVerifier,
4925
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? D.mouseUpEventVerifier,
4926
- movementThreshold: r.movementThreshold ?? D.movementThreshold
4927
- }), zr = (r) => ({
4965
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? L.mouseDownEventVerifier,
4966
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? L.mouseUpEventVerifier,
4967
+ movementThreshold: r.movementThreshold ?? L.movementThreshold
4968
+ }), Gr = (r) => ({
4928
4969
  onEdgeSelected: r.onEdgeSelected,
4929
- mouseDownEventVerifier: r.mouseDownEventVerifier ?? D.mouseDownEventVerifier,
4930
- mouseUpEventVerifier: r.mouseUpEventVerifier ?? D.mouseUpEventVerifier,
4931
- movementThreshold: r.movementThreshold ?? D.movementThreshold
4970
+ mouseDownEventVerifier: r.mouseDownEventVerifier ?? L.mouseDownEventVerifier,
4971
+ mouseUpEventVerifier: r.mouseUpEventVerifier ?? L.mouseUpEventVerifier,
4972
+ movementThreshold: r.movementThreshold ?? L.movementThreshold
4932
4973
  });
4933
- class Yr {
4974
+ class Kr {
4934
4975
  constructor(e) {
4935
4976
  i(this, "used", !1);
4936
4977
  i(this, "canvasDefaults", {});
@@ -4953,12 +4994,12 @@ class Yr {
4953
4994
  i(this, "hasUserDraggableEdges", !1);
4954
4995
  i(this, "hasAnimatedLayout", !1);
4955
4996
  i(this, "hasLayout", !1);
4956
- i(this, "boxRenderingTrigger", new _());
4997
+ i(this, "boxRenderingTrigger", new q());
4957
4998
  i(this, "window", window);
4958
4999
  i(this, "animationStaticNodes", /* @__PURE__ */ new Set());
4959
5000
  i(this, "pointInsideVerifier");
4960
5001
  i(this, "eventTagger", new Ht());
4961
- this.element = e, this.pointInsideVerifier = new ut(e, this.window);
5002
+ this.element = e, this.pointInsideVerifier = new pt(e, this.window);
4962
5003
  }
4963
5004
  setDefaults(e) {
4964
5005
  return this.canvasDefaults = e, this;
@@ -5001,44 +5042,44 @@ class Yr {
5001
5042
  }
5002
5043
  build() {
5003
5044
  if (this.used)
5004
- throw new hr(
5045
+ throw new ur(
5005
5046
  "Failed to build Canvas because CanvasBuilder is a single-use object"
5006
5047
  );
5007
5048
  this.used = !0;
5008
- const e = new dt(this.element), t = new Me(), o = new Qt(this.element), s = this.createHtmlView(
5049
+ const e = new lt(this.element), t = new De(), o = new er(this.element), s = this.createHtmlView(
5009
5050
  o.main,
5010
5051
  t,
5011
5052
  e
5012
- ), n = Ur(
5053
+ ), n = zr(
5013
5054
  this.canvasDefaults
5014
- ), a = new We(
5055
+ ), a = new ze(
5015
5056
  t,
5016
5057
  s,
5017
5058
  n
5018
- ), h = Dr(this.layoutConfig), d = Br({
5059
+ ), h = Fr(this.layoutConfig), d = Hr({
5019
5060
  canvasDefaults: this.canvasDefaults,
5020
5061
  hasLayout: this.hasLayout,
5021
5062
  layoutParams: h
5022
- }), c = new Ye(
5063
+ }), c = new Xe(
5023
5064
  t,
5024
5065
  e,
5025
5066
  d,
5026
5067
  this.window
5027
- ), u = new ze(e), g = new Oe(t), l = new Te(
5068
+ ), u = new ke(e), g = new We(t), l = new Me(
5028
5069
  g,
5029
5070
  u,
5030
5071
  a,
5031
5072
  c
5032
5073
  );
5033
- if (this.hasBackground && ae.configure(
5074
+ if (this.hasBackground && de.configure(
5034
5075
  l,
5035
- or(this.backgroundConfig),
5076
+ ar(this.backgroundConfig),
5036
5077
  o.background
5037
- ), this.hasNodeResizeReactiveEdges && q.configure(l), this.userSelectableEdgesConfig !== void 0) {
5038
- const p = zr(
5078
+ ), this.hasNodeResizeReactiveEdges && ee.configure(l), this.userSelectableEdgesConfig !== void 0) {
5079
+ const p = Gr(
5039
5080
  this.userSelectableEdgesConfig
5040
5081
  );
5041
- pe.configure(
5082
+ ye.configure(
5042
5083
  l,
5043
5084
  this.window,
5044
5085
  this.pointInsideVerifier,
@@ -5047,10 +5088,10 @@ class Yr {
5047
5088
  );
5048
5089
  }
5049
5090
  if (this.userSelectableNodesConfig !== void 0) {
5050
- const p = Or(
5091
+ const p = Yr(
5051
5092
  this.userSelectableNodesConfig
5052
5093
  );
5053
- ge.configure(
5094
+ we.configure(
5054
5095
  l,
5055
5096
  this.window,
5056
5097
  this.pointInsideVerifier,
@@ -5059,10 +5100,10 @@ class Yr {
5059
5100
  );
5060
5101
  }
5061
5102
  if (this.userSelectableCanvasConfig !== void 0) {
5062
- const p = Wr(
5103
+ const p = Xr(
5063
5104
  this.userSelectableCanvasConfig
5064
5105
  );
5065
- we.configure(
5106
+ fe.configure(
5066
5107
  l,
5067
5108
  o.main,
5068
5109
  this.window,
@@ -5072,11 +5113,11 @@ class Yr {
5072
5113
  );
5073
5114
  }
5074
5115
  if (this.hasDraggableNodes) {
5075
- let p = Zt(this.dragConfig);
5076
- this.hasAnimatedLayout && (p = Rr(
5116
+ let p = tr(this.dragConfig);
5117
+ this.hasAnimatedLayout && (p = Ur(
5077
5118
  p,
5078
5119
  this.animationStaticNodes
5079
- )), ie.configure(
5120
+ )), ae.configure(
5080
5121
  l,
5081
5122
  o.main,
5082
5123
  this.window,
@@ -5085,12 +5126,12 @@ class Yr {
5085
5126
  );
5086
5127
  }
5087
5128
  if (this.hasUserConnectablePorts) {
5088
- const p = sr(
5129
+ const p = hr(
5089
5130
  this.connectablePortsConfig,
5090
5131
  n.edges.shapeFactory,
5091
- n.ports.direction
5132
+ l.graph
5092
5133
  );
5093
- he.configure(
5134
+ ce.configure(
5094
5135
  l,
5095
5136
  o.overlayConnectablePorts,
5096
5137
  e,
@@ -5100,11 +5141,11 @@ class Yr {
5100
5141
  );
5101
5142
  }
5102
5143
  if (this.hasUserDraggableEdges) {
5103
- const p = ir(
5144
+ const p = dr(
5104
5145
  this.draggableEdgesConfig,
5105
5146
  l.graph
5106
5147
  );
5107
- de.configure(
5148
+ le.configure(
5108
5149
  l,
5109
5150
  o.overlayDraggableEdges,
5110
5151
  e,
@@ -5113,59 +5154,56 @@ class Yr {
5113
5154
  p
5114
5155
  );
5115
5156
  }
5116
- if (this.virtualScrollConfig !== void 0 ? ne.configure(
5157
+ if (this.virtualScrollConfig !== void 0 ? he.configure(
5117
5158
  l,
5118
5159
  o.main,
5119
5160
  this.window,
5120
- Ne(this.transformConfig),
5161
+ Pe(this.transformConfig),
5121
5162
  this.boxRenderingTrigger,
5122
5163
  this.pointInsideVerifier,
5123
- nr(this.virtualScrollConfig)
5124
- ) : this.hasTransformableViewport && j.configure(
5164
+ cr(this.virtualScrollConfig)
5165
+ ) : this.hasTransformableViewport && J.configure(
5125
5166
  l,
5126
5167
  o.main,
5127
5168
  this.window,
5128
5169
  this.pointInsideVerifier,
5129
- Ne(this.transformConfig)
5130
- ), this.hasLayout && jt.configure(l, h), this.hasAnimatedLayout) {
5131
- let p = Sr(
5132
- this.animatedLayoutConfig
5133
- );
5134
- this.hasDraggableNodes && (Lr(
5170
+ Pe(this.transformConfig)
5171
+ ), this.hasLayout && Qt.configure(l, h), this.hasAnimatedLayout) {
5172
+ let p = Tr(this.animatedLayoutConfig);
5173
+ this.hasDraggableNodes && ($r(
5135
5174
  l,
5136
5175
  this.animationStaticNodes
5137
- ), p = Vr(
5176
+ ), p = Br(
5138
5177
  p,
5139
5178
  this.animationStaticNodes
5140
- )), ue.configure(l, p, this.window);
5179
+ )), pe.configure(l, p, this.window);
5141
5180
  }
5142
- const w = () => {
5143
- o.destroy(), l.onBeforeDestroy.unsubscribe(w);
5144
- };
5145
- return l.onBeforeDestroy.subscribe(w), l;
5181
+ return l.onBeforeDestroy.subscribe(() => {
5182
+ o.destroy();
5183
+ }), l;
5146
5184
  }
5147
5185
  createHtmlView(e, t, o) {
5148
- let s = new Ce(t, o, e);
5149
- return this.virtualScrollConfig !== void 0 && (s = new nt(
5186
+ let s = new Te(t, o, e);
5187
+ return this.virtualScrollConfig !== void 0 && (s = new ht(
5150
5188
  s,
5151
5189
  t,
5152
5190
  this.boxRenderingTrigger,
5153
- ar(this.virtualScrollConfig)
5154
- )), s = new at(s, t), s;
5191
+ lr(this.virtualScrollConfig)
5192
+ )), s = new dt(s, t), s;
5155
5193
  }
5156
5194
  }
5157
5195
  export {
5158
- Rt as BezierEdgeShape,
5159
- Yr as CanvasBuilder,
5160
- hr as CanvasBuilderError,
5196
+ Vt as BezierEdgeShape,
5197
+ Kr as CanvasBuilder,
5198
+ ur as CanvasBuilderError,
5161
5199
  A as CanvasError,
5162
- V as ConnectionCategory,
5163
- $e as DirectEdgeShape,
5164
- _ as EventSubject,
5165
- Lt as HorizontalEdgeShape,
5166
- $t as InteractiveEdgeError,
5167
- Be as InteractiveEdgeShape,
5168
- Hr as MidpointEdgeShape,
5169
- Vt as StraightEdgeShape,
5170
- It as VerticalEdgeShape
5200
+ I as ConnectionCategory,
5201
+ Be as DirectEdgeShape,
5202
+ q as EventSubject,
5203
+ It as HorizontalEdgeShape,
5204
+ Ot as InteractiveEdgeError,
5205
+ Oe as InteractiveEdgeShape,
5206
+ Jr as MidpointEdgeShape,
5207
+ Ft as StraightEdgeShape,
5208
+ Ut as VerticalEdgeShape
5171
5209
  };