@html-graph/html-graph 0.0.51 → 0.0.52

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.
package/dist/main.js CHANGED
@@ -1,68 +1,113 @@
1
- var W = Object.defineProperty;
2
- var j = (r, t, e) => t in r ? W(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var n = (r, t, e) => j(r, typeof t != "symbol" ? t + "" : t, e);
4
- class R {
5
- constructor(t, e, s, o, i) {
6
- n(this, "canvasWrapper", null);
7
- n(this, "host");
8
- n(this, "nodesContainer");
9
- n(this, "edgesContainer");
10
- n(this, "canvas");
11
- n(this, "canvasCtx");
12
- n(this, "hostResizeObserver");
13
- n(this, "nodesResizeObserver");
14
- n(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
15
- n(this, "nodeWrapperElementToIdMap", /* @__PURE__ */ new Map());
16
- n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
17
- n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
18
- n(this, "currentZIndex", 0);
19
- n(this, "layers", {
20
- "edges-on-top": {
21
- create: () => {
22
- this.host.appendChild(this.nodesContainer), this.host.appendChild(this.edgesContainer);
23
- },
24
- update: (t, e, s) => {
25
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.edgesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
26
- },
27
- moveOnTop: (t) => {
28
- this.currentZIndex += 1;
29
- const e = this.nodeIdToWrapperElementMap.get(t);
30
- e.style.zIndex = `${this.currentZIndex}`;
31
- }
32
- },
33
- "edges-follow-node": {
34
- create: () => {
35
- this.host.appendChild(this.nodesContainer), this.edgesContainer = this.nodesContainer;
36
- },
37
- update: (t, e, s) => {
38
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
39
- },
40
- moveOnTop: (t) => {
41
- const e = this.nodeIdToWrapperElementMap.get(t);
42
- this.currentZIndex += 2, e.style.zIndex = `${this.currentZIndex}`, this.graphStore.getNodeAdjacentEdges(t).forEach((o) => {
43
- this.edgeIdToElementMap.get(o).style.zIndex = `${this.currentZIndex - 1}`;
44
- });
45
- }
46
- },
47
- "nodes-on-top": {
48
- create: () => {
49
- this.host.appendChild(this.edgesContainer), this.host.appendChild(this.nodesContainer);
50
- },
51
- update: (t, e, s) => {
52
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.edgesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
53
- },
54
- moveOnTop: (t) => {
55
- this.currentZIndex += 1;
56
- const e = this.nodeIdToWrapperElementMap.get(t);
57
- e.style.zIndex = `${this.currentZIndex}`;
58
- }
59
- }
60
- });
61
- this.graphStore = t, this.viewportTransformer = e, this.publicViewportTransformer = s, this.layersMode = o, this.backgroundDrawingFn = i, this.host = this.createHost(), this.canvas = this.createCanvas(), this.nodesContainer = this.createNodesContainer(), this.edgesContainer = this.createEdgesContainer();
62
- const h = this.canvas.getContext("2d");
63
- if (h === null)
1
+ var B = Object.defineProperty;
2
+ var X = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var h = (e, t, r) => X(e, typeof t != "symbol" ? t + "" : t, r);
4
+ const z = () => {
5
+ const e = document.createElement("div");
6
+ return e.style.width = "100%", e.style.height = "100%", e.style.position = "relative", e.style.overflow = "hidden", e;
7
+ }, G = () => {
8
+ const e = document.createElement("canvas");
9
+ return e.style.position = "absolute", e.style.inset = "0", e;
10
+ }, D = () => {
11
+ const e = document.createElement("div");
12
+ return e.style.position = "absolute", e.style.top = "0", e.style.left = "0", e.style.width = "0", e.style.height = "0", e;
13
+ };
14
+ class j {
15
+ constructor(t) {
16
+ h(this, "nodesContainer", D());
17
+ h(this, "edgesContainer", D());
18
+ this.host = t, this.host.appendChild(this.edgesContainer), this.host.appendChild(this.nodesContainer);
19
+ }
20
+ appendNodeElement(t) {
21
+ this.nodesContainer.appendChild(t);
22
+ }
23
+ removeNodeElement(t) {
24
+ this.nodesContainer.removeChild(t);
25
+ }
26
+ appendEdgeElement(t) {
27
+ this.edgesContainer.appendChild(t);
28
+ }
29
+ removeEdgeElement(t) {
30
+ this.edgesContainer.removeChild(t);
31
+ }
32
+ update(t, r, s) {
33
+ this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${r}, ${s})`, this.edgesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${r}, ${s})`;
34
+ }
35
+ destroy() {
36
+ this.host.removeChild(this.nodesContainer), this.host.removeChild(this.edgesContainer);
37
+ }
38
+ }
39
+ class H {
40
+ constructor(t) {
41
+ h(this, "nodesContainer", D());
42
+ h(this, "edgesContainer", D());
43
+ this.host = t, this.host.appendChild(this.nodesContainer), this.host.appendChild(this.edgesContainer);
44
+ }
45
+ appendNodeElement(t) {
46
+ this.nodesContainer.appendChild(t);
47
+ }
48
+ removeNodeElement(t) {
49
+ this.nodesContainer.removeChild(t);
50
+ }
51
+ appendEdgeElement(t) {
52
+ this.edgesContainer.appendChild(t);
53
+ }
54
+ removeEdgeElement(t) {
55
+ this.edgesContainer.removeChild(t);
56
+ }
57
+ update(t, r, s) {
58
+ this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${r}, ${s})`, this.edgesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${r}, ${s})`;
59
+ }
60
+ destroy() {
61
+ this.host.removeChild(this.nodesContainer), this.host.removeChild(this.edgesContainer);
62
+ }
63
+ }
64
+ class U {
65
+ constructor(t) {
66
+ h(this, "container", D());
67
+ this.host = t, this.host.appendChild(this.container);
68
+ }
69
+ appendNodeElement(t) {
70
+ this.container.appendChild(t);
71
+ }
72
+ removeNodeElement(t) {
73
+ this.container.removeChild(t);
74
+ }
75
+ appendEdgeElement(t) {
76
+ this.container.appendChild(t);
77
+ }
78
+ removeEdgeElement(t) {
79
+ this.container.removeChild(t);
80
+ }
81
+ update(t, r, s) {
82
+ this.container.style.transform = `matrix(${t}, 0, 0, ${t}, ${r}, ${s})`;
83
+ }
84
+ destroy() {
85
+ this.host.removeChild(this.container);
86
+ }
87
+ }
88
+ const _ = {
89
+ "edges-on-top": (e) => new H(e),
90
+ "edges-follow-node": (e) => new U(e),
91
+ "nodes-on-top": (e) => new j(e)
92
+ };
93
+ class J {
94
+ constructor(t, r, s, o, n) {
95
+ h(this, "canvasWrapper", null);
96
+ h(this, "host", z());
97
+ h(this, "canvas", G());
98
+ h(this, "canvasCtx");
99
+ h(this, "hostResizeObserver");
100
+ h(this, "nodesResizeObserver");
101
+ h(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
102
+ h(this, "nodeWrapperElementToIdMap", /* @__PURE__ */ new Map());
103
+ h(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
104
+ h(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
105
+ h(this, "layer");
106
+ this.graphStore = t, this.viewportTransformer = r, this.publicViewportTransformer = s, this.layersMode = o, this.backgroundDrawingFn = n;
107
+ const i = this.canvas.getContext("2d");
108
+ if (i === null)
64
109
  throw new Error("unable to get canvas context");
65
- this.canvasCtx = h, this.host.appendChild(this.canvas), this.layers[this.layersMode].create(), this.hostResizeObserver = this.createHostResizeObserver(), this.hostResizeObserver.observe(this.host), this.nodesResizeObserver = this.createNodesResizeObserver();
110
+ this.canvasCtx = i, this.host.appendChild(this.canvas), this.layer = _[this.layersMode](this.host), this.hostResizeObserver = this.createHostResizeObserver(), this.hostResizeObserver.observe(this.host), this.nodesResizeObserver = this.createNodesResizeObserver();
66
111
  }
67
112
  clear() {
68
113
  Array.from(this.edgeIdToElementMap.keys()).forEach((t) => {
@@ -78,38 +123,43 @@ class R {
78
123
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
79
124
  }
80
125
  destroy() {
81
- this.hostResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.edgesContainer), this.host.removeChild(this.nodesContainer), this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
126
+ this.hostResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.layer.destroy(), this.detach();
82
127
  }
83
128
  applyTransform() {
84
129
  this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
85
- const [t, e] = this.viewportTransformer.getViewCoords(0, 0), s = this.viewportTransformer.getViewScale();
86
- this.layers[this.layersMode].update(s, t, e);
130
+ const [t, r] = this.viewportTransformer.getViewCoords(0, 0), s = this.viewportTransformer.getViewScale();
131
+ this.layer.update(s, t, r);
87
132
  }
88
133
  attachNode(t) {
89
- const e = this.graphStore.getNode(t), s = document.createElement("div");
90
- s.appendChild(e.element), s.style.position = "absolute", s.style.top = "0", s.style.left = "0", s.style.zIndex = `${this.currentZIndex}`, this.currentZIndex += 1, s.style.visibility = "hidden", this.nodesContainer.appendChild(s), this.nodeElementToIdMap.set(e.element, t), this.nodeWrapperElementToIdMap.set(s, t), this.nodeIdToWrapperElementMap.set(t, s), this.updateNodeCoords(t, e.x, e.y), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
134
+ const r = this.graphStore.getNode(t), s = document.createElement("div");
135
+ s.appendChild(r.element), s.style.position = "absolute", s.style.top = "0", s.style.left = "0", s.style.visibility = "hidden", this.layer.appendNodeElement(s), this.nodeElementToIdMap.set(r.element, t), this.nodeWrapperElementToIdMap.set(s, t), this.nodeIdToWrapperElementMap.set(t, s), this.updateNodeCoords(t), this.updateNodePriority(t), this.nodesResizeObserver.observe(s), s.style.visibility = "visible";
91
136
  }
92
137
  detachNode(t) {
93
- const e = this.graphStore.getNode(t);
94
- this.nodesResizeObserver.unobserve(e.element), this.nodesContainer.removeChild(e.element);
138
+ const r = this.graphStore.getNode(t);
139
+ this.nodesResizeObserver.unobserve(r.element);
95
140
  const s = this.nodeIdToWrapperElementMap.get(t);
96
- s.removeChild(e.element), this.nodeElementToIdMap.delete(e.element), this.nodeWrapperElementToIdMap.delete(s), this.nodeIdToWrapperElementMap.delete(t);
141
+ s.removeChild(r.element), this.layer.removeNodeElement(s), this.nodeElementToIdMap.delete(r.element), this.nodeWrapperElementToIdMap.delete(s), this.nodeIdToWrapperElementMap.delete(t);
97
142
  }
98
143
  attachEdge(t) {
99
144
  const s = this.graphStore.getEdge(t).controller.svg;
100
- s.style.transformOrigin = "50% 50%", s.style.position = "absolute", s.style.top = "0", s.style.left = "0", s.style.zIndex = `${this.currentZIndex}`, this.currentZIndex += 1, this.edgeIdToElementMap.set(t, s), this.updateEdgeCoords(t), this.edgesContainer.appendChild(s);
145
+ s.style.position = "absolute", s.style.top = "0", s.style.left = "0", this.edgeIdToElementMap.set(t, s), this.updateEdgeCoords(t), this.updateEdgePriority(t), this.layer.appendEdgeElement(s);
101
146
  }
102
147
  detachEdge(t) {
103
- const e = this.edgeIdToElementMap.get(t);
104
- this.edgeIdToElementMap.delete(t), this.edgesContainer.removeChild(e);
148
+ const r = this.edgeIdToElementMap.get(t);
149
+ this.edgeIdToElementMap.delete(t), this.layer.removeEdgeElement(r);
105
150
  }
106
- moveNodeOnTop(t) {
107
- this.layers[this.layersMode].moveOnTop(t);
151
+ updateNodePriority(t) {
152
+ const r = this.graphStore.getNode(t), s = this.nodeIdToWrapperElementMap.get(t);
153
+ s.style.zIndex = `${r.priority}`;
154
+ }
155
+ updateEdgePriority(t) {
156
+ const r = this.graphStore.getEdge(t);
157
+ this.edgeIdToElementMap.get(t).style.zIndex = `${r.priority}`;
108
158
  }
109
159
  updateNodeCoordinates(t) {
110
- const e = this.graphStore.getNode(t), s = this.graphStore.getNodeAdjacentEdges(t);
111
- this.updateNodeCoords(t, e.x, e.y), s.forEach((o) => {
112
- this.updateEdgeCoords(o);
160
+ const r = this.graphStore.getNodeAdjacentEdges(t);
161
+ this.updateNodeCoords(t), r.forEach((s) => {
162
+ this.updateEdgeCoords(s);
113
163
  });
114
164
  }
115
165
  updatePortEdges(t) {
@@ -121,22 +171,6 @@ class R {
121
171
  const t = this.host.getBoundingClientRect();
122
172
  return [t.width, t.height];
123
173
  }
124
- createHost() {
125
- const t = document.createElement("div");
126
- return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
127
- }
128
- createCanvas() {
129
- const t = document.createElement("canvas");
130
- return t.style.position = "absolute", t.style.inset = "0", t;
131
- }
132
- createNodesContainer() {
133
- const t = document.createElement("div");
134
- return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
135
- }
136
- createEdgesContainer() {
137
- const t = document.createElement("div");
138
- return t.style.position = "absolute", t.style.pointerEvents = "none", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
139
- }
140
174
  createHostResizeObserver() {
141
175
  return new ResizeObserver(() => {
142
176
  this.updateCanvasDimensions(), this.applyTransform();
@@ -144,74 +178,74 @@ class R {
144
178
  }
145
179
  createNodesResizeObserver() {
146
180
  return new ResizeObserver((t) => {
147
- t.forEach((e) => {
148
- const s = e.target, o = this.nodeWrapperElementToIdMap.get(s), i = this.graphStore.getNode(o);
149
- this.updateNodeCoords(o, i.x, i.y), this.graphStore.getNodeAdjacentEdges(o).forEach((a) => {
150
- this.updateEdgeCoords(a);
181
+ t.forEach((r) => {
182
+ const s = r.target, o = this.nodeWrapperElementToIdMap.get(s);
183
+ this.updateNodeCoords(o), this.graphStore.getNodeAdjacentEdges(o).forEach((i) => {
184
+ this.updateEdgeCoords(i);
151
185
  });
152
186
  });
153
187
  });
154
188
  }
155
189
  updateCanvasDimensions() {
156
- const { width: t, height: e } = this.host.getBoundingClientRect();
157
- this.canvas.width = t, this.canvas.height = e;
190
+ const { width: t, height: r } = this.host.getBoundingClientRect();
191
+ this.canvas.width = t, this.canvas.height = r;
158
192
  }
159
- updateNodeCoords(t, e, s) {
160
- const o = this.nodeIdToWrapperElementMap.get(t), { width: i, height: h } = o.getBoundingClientRect(), a = this.viewportTransformer.getAbsScale(), c = this.graphStore.getNode(t), [l, d] = c.centerFn(i, h);
161
- o.style.transform = `matrix(1, 0, 0, 1, ${e - a * l}, ${s - a * d})`;
193
+ updateNodeCoords(t) {
194
+ const r = this.nodeIdToWrapperElementMap.get(t), { width: s, height: o } = r.getBoundingClientRect(), n = this.viewportTransformer.getAbsScale(), i = this.graphStore.getNode(t), [a, c] = i.centerFn(s, o);
195
+ r.style.transform = `matrix(1, 0, 0, 1, ${i.x - n * a}, ${i.y - n * c})`;
162
196
  }
163
197
  updateEdgeCoords(t) {
164
- const e = this.graphStore.getEdge(t), s = this.graphStore.getPort(e.from), o = this.graphStore.getPort(e.to), i = s.element.getBoundingClientRect(), h = o.element.getBoundingClientRect(), a = this.host.getBoundingClientRect(), [c, l] = this.viewportTransformer.getAbsCoords(
198
+ const r = this.graphStore.getEdge(t), s = this.graphStore.getPort(r.from), o = this.graphStore.getPort(r.to), n = s.element.getBoundingClientRect(), i = o.element.getBoundingClientRect(), a = this.host.getBoundingClientRect(), [c, l] = this.viewportTransformer.getAbsCoords(
199
+ n.left - a.left,
200
+ n.top - a.top
201
+ ), [d, g] = this.viewportTransformer.getAbsCoords(
165
202
  i.left - a.left,
166
203
  i.top - a.top
167
- ), [d, u] = this.viewportTransformer.getAbsCoords(
168
- h.left - a.left,
169
- h.top - a.top
170
- ), g = this.viewportTransformer.getAbsScale(), [w, m] = s.centerFn(
171
- i.width * g,
172
- i.height * g
173
- ), [f, p] = o.centerFn(
174
- h.width * g,
175
- h.height * g
176
- ), C = w + c, v = m + l, E = f + d, A = p + u, y = Math.min(C, E), x = Math.min(v, A), P = Math.abs(E - C), M = Math.abs(A - v);
177
- e.controller.update(y, x, P, M, s, o);
204
+ ), u = this.viewportTransformer.getAbsScale(), [p, w] = s.centerFn(
205
+ n.width * u,
206
+ n.height * u
207
+ ), [f, m] = o.centerFn(
208
+ i.width * u,
209
+ i.height * u
210
+ ), E = p + c, v = w + l, C = f + d, S = m + g, A = Math.min(E, C), P = Math.min(v, S), M = Math.abs(C - E), x = Math.abs(S - v);
211
+ r.controller.update(A, P, M, x, s, o);
178
212
  }
179
213
  }
180
- class B {
214
+ class K {
181
215
  constructor() {
182
- n(this, "state", {
216
+ h(this, "state", {
183
217
  scale: 1,
184
218
  x: 0,
185
219
  y: 0
186
220
  });
187
221
  }
188
- getViewCoords(t, e) {
222
+ getViewCoords(t, r) {
189
223
  return [
190
224
  (t - this.state.x) / this.state.scale,
191
- (e - this.state.y) / this.state.scale
225
+ (r - this.state.y) / this.state.scale
192
226
  ];
193
227
  }
194
228
  getViewScale() {
195
229
  return 1 / this.state.scale;
196
230
  }
197
- getAbsCoords(t, e) {
231
+ getAbsCoords(t, r) {
198
232
  return [
199
233
  t * this.state.scale + this.state.x,
200
- e * this.state.scale + this.state.y
234
+ r * this.state.scale + this.state.y
201
235
  ];
202
236
  }
203
237
  getAbsScale() {
204
238
  return this.state.scale;
205
239
  }
206
- patchState(t, e, s) {
240
+ patchState(t, r, s) {
207
241
  this.state = {
208
242
  scale: t ?? this.state.scale,
209
- x: e ?? this.state.x,
243
+ x: r ?? this.state.x,
210
244
  y: s ?? this.state.y
211
245
  };
212
246
  }
213
247
  }
214
- class Y {
248
+ class Q {
215
249
  constructor(t) {
216
250
  this.transformer = t;
217
251
  }
@@ -219,8 +253,8 @@ class Y {
219
253
  * for given absolute coordinates returns viewport coordinates
220
254
  * viewport coordinated represent actual coordinates on screen for given absolute coordinates
221
255
  */
222
- getViewCoords(t, e) {
223
- return this.transformer.getViewCoords(t, e);
256
+ getViewCoords(t, r) {
257
+ return this.transformer.getViewCoords(t, r);
224
258
  }
225
259
  /**
226
260
  * returns viewport scale
@@ -233,8 +267,8 @@ class Y {
233
267
  * for given viewport coordinates returns absolute coordinates
234
268
  * absolute coordinates represent actual coordinates, which stay constant even for transformed canvas
235
269
  */
236
- getAbsCoords(t, e) {
237
- return this.transformer.getAbsCoords(t, e);
270
+ getAbsCoords(t, r) {
271
+ return this.transformer.getAbsCoords(t, r);
238
272
  }
239
273
  /**
240
274
  * returns absolute scale
@@ -244,84 +278,64 @@ class Y {
244
278
  return this.transformer.getAbsScale();
245
279
  }
246
280
  }
247
- class X {
281
+ class Z {
248
282
  constructor() {
249
- n(this, "nodes", /* @__PURE__ */ Object.create(null));
250
- n(this, "ports", /* @__PURE__ */ Object.create(null));
251
- n(this, "nodePorts", /* @__PURE__ */ Object.create(null));
252
- n(this, "portNodeId", /* @__PURE__ */ Object.create(null));
253
- n(this, "edges", /* @__PURE__ */ Object.create(null));
254
- n(this, "incommingEdges", /* @__PURE__ */ Object.create(null));
255
- n(this, "outcommingEdges", /* @__PURE__ */ Object.create(null));
256
- n(this, "cycleEdges", /* @__PURE__ */ Object.create(null));
257
- }
258
- addNode(t, e, s, o, i) {
259
- this.nodes[t] = { element: e, x: s, y: o, centerFn: i }, this.nodePorts[t] = /* @__PURE__ */ Object.create(null);
260
- }
261
- hasNode(t) {
262
- return this.nodes[t] !== void 0;
283
+ h(this, "nodes", /* @__PURE__ */ new Map());
284
+ h(this, "ports", /* @__PURE__ */ new Map());
285
+ h(this, "nodePorts", /* @__PURE__ */ new Map());
286
+ h(this, "portNodeId", /* @__PURE__ */ new Map());
287
+ h(this, "edges", /* @__PURE__ */ new Map());
288
+ h(this, "incommingEdges", /* @__PURE__ */ new Map());
289
+ h(this, "outcommingEdges", /* @__PURE__ */ new Map());
290
+ h(this, "cycleEdges", /* @__PURE__ */ new Map());
291
+ }
292
+ addNode(t, r, s, o, n, i) {
293
+ this.nodes.set(t, { element: r, x: s, y: o, centerFn: n, priority: i }), this.nodePorts.set(t, /* @__PURE__ */ new Map());
263
294
  }
264
295
  getNode(t) {
265
- return this.nodes[t];
266
- }
267
- updateNodeCoords(t, e, s) {
268
- this.nodes[t].x = e, this.nodes[t].y = s;
269
- }
270
- updateEdgeController(t, e) {
271
- this.edges[t].controller = e;
296
+ return this.nodes.get(t);
272
297
  }
273
298
  removeNode(t) {
274
299
  this.getNodeAdjacentEdges(t).forEach((o) => {
275
300
  this.removeEdge(o);
276
- }), delete this.nodes[t];
277
- const s = this.nodePorts[t];
278
- Object.keys(s).forEach((o) => {
279
- delete this.portNodeId[o];
280
- }), delete this.nodePorts[t];
301
+ }), this.nodes.delete(t), this.nodePorts.get(t).forEach((o, n) => {
302
+ this.portNodeId.delete(n);
303
+ }), this.nodePorts.delete(t);
281
304
  }
282
- addPort(t, e, s, o, i) {
283
- this.ports[t] = { element: e, centerFn: o, direction: i }, this.cycleEdges[t] = {}, this.incommingEdges[t] = {}, this.outcommingEdges[t] = {}, this.portNodeId[t] = s;
284
- const h = this.nodePorts[s];
285
- h !== void 0 && (h[t] = e);
305
+ addPort(t, r, s, o, n) {
306
+ this.ports.set(t, { element: r, centerFn: o, direction: n }), this.cycleEdges.set(t, /* @__PURE__ */ new Set()), this.incommingEdges.set(t, /* @__PURE__ */ new Set()), this.outcommingEdges.set(t, /* @__PURE__ */ new Set()), this.portNodeId.set(t, s), this.nodePorts.get(s).set(t, r);
286
307
  }
287
308
  getPort(t) {
288
- return this.ports[t];
309
+ return this.ports.get(t);
289
310
  }
290
311
  getPortNode(t) {
291
- return this.portNodeId[t];
292
- }
293
- hasPort(t) {
294
- return this.portNodeId[t] !== void 0;
312
+ return this.portNodeId.get(t);
295
313
  }
296
314
  removePort(t) {
297
- Object.keys(this.cycleEdges[t]).forEach((o) => {
298
- this.removeEdge(o);
299
- }), delete this.cycleEdges[t], Object.keys(this.incommingEdges[t]).forEach((o) => {
300
- this.removeEdge(o);
301
- }), delete this.incommingEdges[t], Object.keys(this.outcommingEdges[t]).forEach((o) => {
302
- this.removeEdge(o);
303
- }), delete this.outcommingEdges[t];
304
- const e = this.portNodeId[t];
305
- delete this.portNodeId[t];
306
- const s = this.nodePorts[e];
307
- delete s[t], delete this.ports[t];
308
- }
309
- addEdge(t, e, s, o) {
310
- this.edges[t] = {
311
- from: e,
315
+ this.cycleEdges.get(t).forEach((s) => {
316
+ this.removeEdge(s);
317
+ }), this.cycleEdges.delete(t), this.incommingEdges.get(t).forEach((s) => {
318
+ this.removeEdge(s);
319
+ }), this.incommingEdges.delete(t), this.outcommingEdges.get(t).forEach((s) => {
320
+ this.removeEdge(s);
321
+ }), this.outcommingEdges.get(t);
322
+ const r = this.portNodeId.get(t);
323
+ this.portNodeId.delete(t), this.nodePorts.get(r).delete(t), this.ports.delete(t);
324
+ }
325
+ addEdge(t, r, s, o, n) {
326
+ this.edges.set(t, {
327
+ from: r,
312
328
  to: s,
313
- controller: o
314
- }, e !== s ? (this.outcommingEdges[e][t] = !0, this.incommingEdges[s][t] = !0) : this.cycleEdges[e][t] = !0;
329
+ controller: o,
330
+ priority: n
331
+ }), r !== s ? (this.outcommingEdges.get(r).add(t), this.incommingEdges.get(s).add(t)) : this.cycleEdges.get(r).add(t);
315
332
  }
316
333
  getEdge(t) {
317
- return this.edges[t];
318
- }
319
- hasEdge(t) {
320
- return this.edges[t] !== void 0;
334
+ return this.edges.get(t);
321
335
  }
322
336
  removeEdge(t) {
323
- const e = this.edges[t], s = e.from, o = e.to;
324
- delete this.cycleEdges[s][t], delete this.cycleEdges[o][t], delete this.incommingEdges[s][t], delete this.incommingEdges[o][t], delete this.outcommingEdges[s][t], delete this.outcommingEdges[o][t], delete this.edges[t];
337
+ const r = this.edges.get(t), s = r.from, o = r.to;
338
+ this.cycleEdges.get(s).delete(t), this.cycleEdges.get(o).delete(t), this.incommingEdges.get(s).delete(t), this.incommingEdges.get(o).delete(t), this.outcommingEdges.get(s).delete(t), this.outcommingEdges.get(o).delete(t), this.edges.delete(t);
325
339
  }
326
340
  getPortAdjacentEdges(t) {
327
341
  return [
@@ -338,61 +352,61 @@ class X {
338
352
  ];
339
353
  }
340
354
  clear() {
341
- this.nodes = /* @__PURE__ */ Object.create(null), this.ports = /* @__PURE__ */ Object.create(null), this.nodePorts = /* @__PURE__ */ Object.create(null), this.portNodeId = /* @__PURE__ */ Object.create(null), this.edges = /* @__PURE__ */ Object.create(null), this.incommingEdges = /* @__PURE__ */ Object.create(null), this.outcommingEdges = /* @__PURE__ */ Object.create(null), this.cycleEdges = /* @__PURE__ */ Object.create(null);
355
+ this.nodes.clear(), this.ports.clear(), this.nodePorts.clear(), this.portNodeId.clear(), this.edges.clear(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear();
342
356
  }
343
357
  getPortIncomingEdges(t) {
344
- return Object.keys(this.incommingEdges[t] ?? {});
358
+ return Array.from(this.incommingEdges.get(t));
345
359
  }
346
360
  getPortOutcomingEdges(t) {
347
- return Object.keys(this.outcommingEdges[t] ?? {});
361
+ return Array.from(this.outcommingEdges.get(t));
348
362
  }
349
363
  getPortCycleEdges(t) {
350
- return Object.keys(this.cycleEdges[t] ?? {});
364
+ return Array.from(this.cycleEdges.get(t));
351
365
  }
352
366
  getNodeIncomingEdges(t) {
353
- const e = Object.keys(this.nodePorts[t]);
367
+ const r = Array.from(this.nodePorts.get(t).keys());
354
368
  let s = [];
355
- return e.forEach((o) => {
369
+ return r.forEach((o) => {
356
370
  s = [...s, ...this.getPortIncomingEdges(o)];
357
371
  }), s;
358
372
  }
359
373
  getNodeOutcomingEdges(t) {
360
- const e = Object.keys(this.nodePorts[t]);
374
+ const r = Array.from(this.nodePorts.get(t).keys());
361
375
  let s = [];
362
- return e.forEach((o) => {
376
+ return r.forEach((o) => {
363
377
  s = [...s, ...this.getPortOutcomingEdges(o)];
364
378
  }), s;
365
379
  }
366
380
  getNodeCycleEdges(t) {
367
- const e = Object.keys(this.nodePorts[t]);
381
+ const r = Array.from(this.nodePorts.get(t).keys());
368
382
  let s = [];
369
- return e.forEach((o) => {
383
+ return r.forEach((o) => {
370
384
  s = [...s, ...this.getPortCycleEdges(o)];
371
385
  }), s;
372
386
  }
373
387
  }
374
- const $ = (r) => {
375
- const { top: t, left: e, width: s, height: o } = r.element.getBoundingClientRect(), i = r.centerFn(s, o);
376
- return [e + i[0], t + i[1]];
377
- }, b = (r, t, e) => [
378
- t[0] * r[0] - t[1] * r[1] + ((1 - t[0]) * e[0] + t[1] * e[1]),
379
- t[1] * r[0] + t[0] * r[1] + ((1 - t[0]) * e[1] - t[1] * e[0])
380
- ], N = (r, t, e) => [t * Math.cos(r), e * Math.sin(r)], S = (r, t, e, s, o) => {
381
- const h = [
388
+ const T = (e) => {
389
+ const { top: t, left: r, width: s, height: o } = e.element.getBoundingClientRect(), n = e.centerFn(s, o);
390
+ return [r + n[0], t + n[1]];
391
+ }, y = (e, t, r) => [
392
+ t[0] * e[0] - t[1] * e[1] + ((1 - t[0]) * r[0] + t[1] * r[1]),
393
+ t[1] * e[0] + t[0] * e[1] + ((1 - t[0]) * r[1] - t[1] * r[0])
394
+ ], b = (e, t, r) => [t * Math.cos(e), r * Math.sin(e)], N = (e, t, r, s, o) => {
395
+ const i = [
382
396
  [0, 0],
383
397
  [s, o],
384
398
  [s, -o]
385
- ].map((d) => b(d, r, [0, 0])).map((d) => [d[0] + t, d[1] + e]), a = `M ${h[0][0]} ${h[0][1]}`, c = `L ${h[1][0]} ${h[1][1]}`, l = `L ${h[2][0]} ${h[2][1]}`;
399
+ ].map((d) => y(d, e, [0, 0])).map((d) => [d[0] + t, d[1] + r]), a = `M ${i[0][0]} ${i[0][1]}`, c = `L ${i[1][0]} ${i[1][1]}`, l = `L ${i[2][0]} ${i[2][1]}`;
386
400
  return `${a} ${c} ${l}`;
387
401
  };
388
- class z {
389
- constructor(t, e, s, o, i, h, a) {
390
- n(this, "svg");
391
- n(this, "group");
392
- n(this, "line");
393
- n(this, "sourceArrow", null);
394
- n(this, "targetArrow", null);
395
- this.color = t, this.width = e, this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", h && (this.sourceArrow = document.createElementNS(
402
+ class q {
403
+ constructor(t, r, s, o, n, i, a) {
404
+ h(this, "svg");
405
+ h(this, "group");
406
+ h(this, "line");
407
+ h(this, "sourceArrow", null);
408
+ h(this, "targetArrow", null);
409
+ this.color = t, this.width = r, this.curvature = s, this.arrowLength = o, this.arrowWidth = n, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.sourceArrow = document.createElementNS(
396
410
  "http://www.w3.org/2000/svg",
397
411
  "path"
398
412
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
@@ -400,70 +414,70 @@ class z {
400
414
  "path"
401
415
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
402
416
  }
403
- update(t, e, s, o, i, h) {
417
+ update(t, r, s, o, n, i) {
404
418
  this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
405
- const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
406
- this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
407
- const u = N(i.direction, l, d), g = N(h.direction, l, d), w = b([this.arrowLength, 0], u, [0, 0]), m = b([s - this.arrowLength, o], g, [
419
+ const a = T(n), c = T(i), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
420
+ this.svg.style.transform = `translate(${t}px, ${r}px)`, this.group.style.transform = `scale(${l}, ${d})`;
421
+ const g = b(n.direction, l, d), u = b(i.direction, l, d), p = y([this.arrowLength, 0], g, [0, 0]), w = y([s - this.arrowLength, o], u, [
408
422
  s,
409
423
  o
410
424
  ]), f = [
411
- w[0] + u[0] * this.curvature,
412
- w[1] + u[1] * this.curvature
413
- ], p = [
414
- m[0] - g[0] * this.curvature,
415
- m[1] - g[1] * this.curvature
416
- ], C = `M ${w[0]} ${w[1]} C ${f[0]} ${f[1]}, ${p[0]} ${p[1]}, ${m[0]} ${m[1]}`, v = this.sourceArrow ? "" : `M 0 0 L ${w[0]} ${w[1]} `, E = this.targetArrow ? "" : ` M ${m[0]} ${m[1]} L ${s} ${o}`, A = `${v}${C}${E}`;
417
- if (this.line.setAttribute("d", A), this.sourceArrow) {
418
- const y = S(
419
- u,
425
+ p[0] + g[0] * this.curvature,
426
+ p[1] + g[1] * this.curvature
427
+ ], m = [
428
+ w[0] - u[0] * this.curvature,
429
+ w[1] - u[1] * this.curvature
430
+ ], E = `M ${p[0]} ${p[1]} C ${f[0]} ${f[1]}, ${m[0]} ${m[1]}, ${w[0]} ${w[1]}`, v = this.sourceArrow ? "" : `M 0 0 L ${p[0]} ${p[1]} `, C = this.targetArrow ? "" : ` M ${w[0]} ${w[1]} L ${s} ${o}`, S = `${v}${E}${C}`;
431
+ if (this.line.setAttribute("d", S), this.sourceArrow) {
432
+ const A = N(
433
+ g,
420
434
  0,
421
435
  0,
422
436
  this.arrowLength,
423
437
  this.arrowWidth
424
438
  );
425
- this.sourceArrow.setAttribute("d", y);
439
+ this.sourceArrow.setAttribute("d", A);
426
440
  }
427
441
  if (this.targetArrow) {
428
- const y = S(
429
- g,
442
+ const A = N(
443
+ u,
430
444
  s,
431
445
  o,
432
446
  -this.arrowLength,
433
447
  this.arrowWidth
434
448
  );
435
- this.targetArrow.setAttribute("d", y);
449
+ this.targetArrow.setAttribute("d", A);
436
450
  }
437
451
  }
438
452
  }
439
- const V = (r, t) => {
440
- const e = [];
441
- if (r.length > 0 && e.push(`M ${r[0][0]} ${r[0][1]}`), r.length === 2 && e.push(`L ${r[1][0]} ${r[1][1]}`), r.length > 2) {
442
- const s = r.length - 1;
443
- let o = 0, i = 0, h = 0;
444
- r.forEach((a, c) => {
445
- let l = 0, d = 0, u = 0;
446
- const g = c > 0, w = c < s, m = g && w;
447
- if (g && (l = -o, d = -i, u = h), w) {
448
- const y = r[c + 1];
449
- o = y[0] - a[0], i = y[1] - a[1], h = Math.sqrt(o * o + i * i);
453
+ const V = (e, t) => {
454
+ const r = [];
455
+ if (e.length > 0 && r.push(`M ${e[0][0]} ${e[0][1]}`), e.length === 2 && r.push(`L ${e[1][0]} ${e[1][1]}`), e.length > 2) {
456
+ const s = e.length - 1;
457
+ let o = 0, n = 0, i = 0;
458
+ e.forEach((a, c) => {
459
+ let l = 0, d = 0, g = 0;
460
+ const u = c > 0, p = c < s, w = u && p;
461
+ if (u && (l = -o, d = -n, g = i), p) {
462
+ const A = e[c + 1];
463
+ o = A[0] - a[0], n = A[1] - a[1], i = Math.sqrt(o * o + n * n);
450
464
  }
451
- const p = Math.min((m ? t : 0) / h, c < s - 1 ? 0.5 : 1), C = m ? [a[0] + o * p, a[1] + i * p] : a, E = Math.min((m ? t : 0) / u, c > 1 ? 0.5 : 1), A = m ? [a[0] + l * E, a[1] + d * E] : a;
452
- c > 0 && e.push(`L ${A[0]} ${A[1]}`), m && e.push(
453
- `C ${a[0]} ${a[1]} ${a[0]} ${a[1]} ${C[0]} ${C[1]}`
465
+ const m = Math.min((w ? t : 0) / i, c < s - 1 ? 0.5 : 1), E = w ? [a[0] + o * m, a[1] + n * m] : a, C = Math.min((w ? t : 0) / g, c > 1 ? 0.5 : 1), S = w ? [a[0] + l * C, a[1] + d * C] : a;
466
+ c > 0 && r.push(`L ${S[0]} ${S[1]}`), w && r.push(
467
+ `C ${a[0]} ${a[1]} ${a[0]} ${a[1]} ${E[0]} ${E[1]}`
454
468
  );
455
469
  });
456
470
  }
457
- return e.join(" ");
471
+ return r.join(" ");
458
472
  };
459
- class G {
460
- constructor(t, e, s, o, i, h, a, c) {
461
- n(this, "svg");
462
- n(this, "group");
463
- n(this, "line");
464
- n(this, "sourceArrow", null);
465
- n(this, "targetArrow", null);
466
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", h && (this.sourceArrow = document.createElementNS(
473
+ class I {
474
+ constructor(t, r, s, o, n, i, a, c) {
475
+ h(this, "svg");
476
+ h(this, "group");
477
+ h(this, "line");
478
+ h(this, "sourceArrow", null);
479
+ h(this, "targetArrow", null);
480
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = n, this.roundness = c, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.sourceArrow = document.createElementNS(
467
481
  "http://www.w3.org/2000/svg",
468
482
  "path"
469
483
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
@@ -471,65 +485,167 @@ class G {
471
485
  "path"
472
486
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
473
487
  }
474
- update(t, e, s, o, i, h) {
488
+ update(t, r, s, o, n, i) {
475
489
  this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
476
- const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
477
- this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
478
- const u = N(i.direction, l, d), g = N(h.direction, l, d), w = this.sourceArrow ? b([this.arrowLength, 0], u, [0, 0]) : [0, 0], m = this.targetArrow ? b([s - this.arrowLength, o], g, [
490
+ const a = T(n), c = T(i), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
491
+ this.svg.style.transform = `translate(${t}px, ${r}px)`, this.group.style.transform = `scale(${l}, ${d})`;
492
+ const g = b(n.direction, l, d), u = b(i.direction, l, d), p = this.sourceArrow ? y([this.arrowLength, 0], g, [0, 0]) : [0, 0], w = this.targetArrow ? y([s - this.arrowLength, o], u, [
479
493
  s,
480
494
  o
481
- ]) : [s, o], f = this.arrowLength + this.arrowOffset, p = b([f, 0], u, [0, 0]), C = b([s - f, o], g, [
495
+ ]) : [s, o], f = this.arrowLength + this.arrowOffset, m = y([f, 0], g, [0, 0]), E = y([s - f, o], u, [
482
496
  s,
483
497
  o
484
- ]), v = V([w, p, C, m], this.roundness);
498
+ ]), v = V([p, m, E, w], this.roundness);
485
499
  if (this.line.setAttribute("d", v), this.sourceArrow) {
486
- const E = S(
500
+ const C = N(
501
+ g,
502
+ 0,
503
+ 0,
504
+ this.arrowLength,
505
+ this.arrowWidth
506
+ );
507
+ this.sourceArrow.setAttribute("d", C);
508
+ }
509
+ if (this.targetArrow) {
510
+ const C = N(
487
511
  u,
512
+ s,
513
+ o,
514
+ -this.arrowLength,
515
+ this.arrowWidth
516
+ );
517
+ this.targetArrow.setAttribute("d", C);
518
+ }
519
+ }
520
+ }
521
+ class tt {
522
+ constructor(t, r, s, o, n, i, a, c) {
523
+ h(this, "svg");
524
+ h(this, "group");
525
+ h(this, "line");
526
+ h(this, "sourceArrow", null);
527
+ h(this, "targetArrow", null);
528
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = n, this.roundness = c, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.sourceArrow = document.createElementNS(
529
+ "http://www.w3.org/2000/svg",
530
+ "path"
531
+ ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
532
+ "http://www.w3.org/2000/svg",
533
+ "path"
534
+ ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
535
+ }
536
+ update(t, r, s, o, n, i) {
537
+ this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
538
+ const a = T(n), c = T(i), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
539
+ this.svg.style.transform = `translate(${t}px, ${r}px)`, this.group.style.transform = `scale(${l}, ${d})`;
540
+ const g = b(n.direction, l, d), u = b(i.direction, l, d), p = this.sourceArrow ? y([this.arrowLength, 0], g, [0, 0]) : [0, 0], w = this.targetArrow ? y([s - this.arrowLength, o], u, [
541
+ s,
542
+ o
543
+ ]) : [s, o], f = this.arrowLength + this.arrowOffset, m = y([f, 0], g, [0, 0]), E = y([s - f, o], u, [
544
+ s,
545
+ o
546
+ ]), v = Math.max((m[0] + E[0]) / 2, f), C = o / 2, S = [l > 0 ? v : -f, m[1]], A = [S[0], C], P = [l > 0 ? s - v : s + f, E[1]], M = [P[0], C], x = V(
547
+ [p, m, S, A, M, P, E, w],
548
+ this.roundness
549
+ );
550
+ if (this.line.setAttribute("d", x), this.sourceArrow) {
551
+ const L = N(
552
+ g,
488
553
  0,
489
554
  0,
490
555
  this.arrowLength,
491
556
  this.arrowWidth
492
557
  );
493
- this.sourceArrow.setAttribute("d", E);
558
+ this.sourceArrow.setAttribute("d", L);
494
559
  }
495
560
  if (this.targetArrow) {
496
- const E = S(
561
+ const L = N(
562
+ u,
563
+ s,
564
+ o,
565
+ -this.arrowLength,
566
+ this.arrowWidth
567
+ );
568
+ this.targetArrow.setAttribute("d", L);
569
+ }
570
+ }
571
+ }
572
+ class et {
573
+ constructor(t, r, s, o, n, i, a, c) {
574
+ h(this, "svg");
575
+ h(this, "group");
576
+ h(this, "line");
577
+ h(this, "sourceArrow", null);
578
+ h(this, "targetArrow", null);
579
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = n, this.roundness = c, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.sourceArrow = document.createElementNS(
580
+ "http://www.w3.org/2000/svg",
581
+ "path"
582
+ ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
583
+ "http://www.w3.org/2000/svg",
584
+ "path"
585
+ ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
586
+ }
587
+ update(t, r, s, o, n, i) {
588
+ this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
589
+ const a = T(n), c = T(i), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
590
+ this.svg.style.transform = `translate(${t}px, ${r}px)`, this.group.style.transform = `scale(${l}, ${d})`;
591
+ const g = b(n.direction, l, d), u = b(i.direction, l, d), p = this.sourceArrow ? y([this.arrowLength, 0], g, [0, 0]) : [0, 0], w = this.targetArrow ? y([s - this.arrowLength, o], u, [
592
+ s,
593
+ o
594
+ ]) : [s, o], f = this.arrowLength + this.arrowOffset, m = y([f, 0], g, [0, 0]), E = y([s - f, o], u, [
595
+ s,
596
+ o
597
+ ]), v = Math.max((m[1] + E[1]) / 2, f), C = s / 2, S = [m[0], d > 0 ? v : -f], A = [C, S[1]], P = [E[0], d > 0 ? o - v : o + f], M = [C, P[1]], x = V(
598
+ [p, m, S, A, M, P, E, w],
599
+ this.roundness
600
+ );
601
+ if (this.line.setAttribute("d", x), this.sourceArrow) {
602
+ const L = N(
497
603
  g,
604
+ 0,
605
+ 0,
606
+ this.arrowLength,
607
+ this.arrowWidth
608
+ );
609
+ this.sourceArrow.setAttribute("d", L);
610
+ }
611
+ if (this.targetArrow) {
612
+ const L = N(
613
+ u,
498
614
  s,
499
615
  o,
500
616
  -this.arrowLength,
501
617
  this.arrowWidth
502
618
  );
503
- this.targetArrow.setAttribute("d", E);
619
+ this.targetArrow.setAttribute("d", L);
504
620
  }
505
621
  }
506
622
  }
507
- class Z {
508
- constructor(t, e, s, o, i, h, a) {
509
- n(this, "svg");
510
- n(this, "group");
511
- n(this, "line");
512
- n(this, "arrow", null);
513
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.radius = h, this.smallRadius = a, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.arrow = document.createElementNS(
623
+ class rt {
624
+ constructor(t, r, s, o, n, i, a) {
625
+ h(this, "svg");
626
+ h(this, "group");
627
+ h(this, "line");
628
+ h(this, "arrow", null);
629
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.radius = i, this.smallRadius = a, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", n && (this.arrow = document.createElementNS(
514
630
  "http://www.w3.org/2000/svg",
515
631
  "path"
516
632
  ), this.arrow.setAttribute("fill", this.color), this.group.appendChild(this.arrow)), this.svg.style.overflow = "visible", this.svg.style.width = "0px", this.svg.style.height = "0px";
517
633
  }
518
- update(t, e, s, o, i) {
519
- this.svg.style.transform = `translate(${t}px, ${e}px)`;
520
- const h = N(i.direction, 1, 1), a = this.smallRadius, c = this.radius, l = Math.sqrt(a * a + c * c), d = a + c, u = this.arrowLength + l * (1 - c / d), g = a * c / d, m = [
634
+ update(t, r, s, o, n) {
635
+ this.svg.style.transform = `translate(${t}px, ${r}px)`;
636
+ const i = b(n.direction, 1, 1), a = this.smallRadius, c = this.radius, l = Math.sqrt(a * a + c * c), d = a + c, g = this.arrowLength + l * (1 - c / d), u = a * c / d, w = [
521
637
  [this.arrowLength, 0],
522
- [u, g],
523
- [u, -g]
524
- ].map((v) => b(v, h, [0, 0])), f = [
525
- `M ${m[0][0]} ${m[0][1]}`,
526
- `A ${a} ${a} 0 0 1 ${m[1][0]} ${m[1][1]}`,
527
- `A ${c} ${c} 0 1 0 ${m[2][0]} ${m[2][1]}`,
528
- `A ${a} ${a} 0 0 1 ${m[0][0]} ${m[0][1]}`
529
- ].join(" "), p = `M 0 0 L ${m[0][0]} ${m[0][1]} `, C = `${this.arrow !== null ? "" : p}${f}`;
530
- if (this.line.setAttribute("d", C), this.arrow) {
531
- const v = S(
532
- h,
638
+ [g, u],
639
+ [g, -u]
640
+ ].map((v) => y(v, i, [0, 0])), f = [
641
+ `M ${w[0][0]} ${w[0][1]}`,
642
+ `A ${a} ${a} 0 0 1 ${w[1][0]} ${w[1][1]}`,
643
+ `A ${c} ${c} 0 1 0 ${w[2][0]} ${w[2][1]}`,
644
+ `A ${a} ${a} 0 0 1 ${w[0][0]} ${w[0][1]}`
645
+ ].join(" "), m = `M 0 0 L ${w[0][0]} ${w[0][1]} `, E = `${this.arrow !== null ? "" : m}${f}`;
646
+ if (this.line.setAttribute("d", E), this.arrow) {
647
+ const v = N(
648
+ i,
533
649
  0,
534
650
  0,
535
651
  this.arrowLength,
@@ -539,38 +655,38 @@ class Z {
539
655
  }
540
656
  }
541
657
  }
542
- class U {
543
- constructor(t, e, s, o, i, h, a, c) {
544
- n(this, "svg");
545
- n(this, "group");
546
- n(this, "line");
547
- n(this, "arrow", null);
548
- n(this, "roundness");
549
- n(this, "linePoints");
550
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.side = h, this.minPortOffset = a, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.arrow = document.createElementNS(
658
+ class W {
659
+ constructor(t, r, s, o, n, i, a, c) {
660
+ h(this, "svg");
661
+ h(this, "group");
662
+ h(this, "line");
663
+ h(this, "arrow", null);
664
+ h(this, "roundness");
665
+ h(this, "linePoints");
666
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.side = i, this.minPortOffset = a, this.roundness = Math.min(c, this.minPortOffset, this.side / 2), this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", n && (this.arrow = document.createElementNS(
551
667
  "http://www.w3.org/2000/svg",
552
668
  "path"
553
669
  ), this.arrow.setAttribute("fill", this.color), this.group.appendChild(this.arrow)), this.svg.style.overflow = "visible", this.svg.style.width = "0px", this.svg.style.height = "0px";
554
- const l = this.minPortOffset, d = this.side, u = this.arrowLength + l, g = this.roundness, w = u + 2 * d;
555
- console.log(g), this.linePoints = [
670
+ const l = this.minPortOffset, d = this.side, g = this.arrowLength + l, u = this.roundness, p = g + 2 * d;
671
+ console.log(u), this.linePoints = [
556
672
  [this.arrowLength, 0],
557
- [u, 0],
558
- [u, this.side],
559
- [w, this.side],
560
- [w, -this.side],
561
- [u, -this.side],
562
- [u, 0],
673
+ [g, 0],
674
+ [g, this.side],
675
+ [p, this.side],
676
+ [p, -this.side],
677
+ [g, -this.side],
678
+ [g, 0],
563
679
  [this.arrowLength, 0]
564
680
  ];
565
681
  }
566
- update(t, e, s, o, i) {
567
- this.svg.style.transform = `translate(${t}px, ${e}px)`;
568
- const h = N(i.direction, 1, 1), a = this.linePoints.map(
569
- (d) => b(d, h, [0, 0])
682
+ update(t, r, s, o, n) {
683
+ this.svg.style.transform = `translate(${t}px, ${r}px)`;
684
+ const i = b(n.direction, 1, 1), a = this.linePoints.map(
685
+ (d) => y(d, i, [0, 0])
570
686
  ), c = `M 0 0 L ${a[0][0]} ${a[0][1]} `, l = `${this.arrow ? "" : c}${V(a, this.roundness)}`;
571
687
  if (this.line.setAttribute("d", l), this.arrow) {
572
- const d = S(
573
- h,
688
+ const d = N(
689
+ i,
574
690
  0,
575
691
  0,
576
692
  this.arrowLength,
@@ -580,16 +696,16 @@ class U {
580
696
  }
581
697
  }
582
698
  }
583
- class H {
584
- constructor(t, e, s, o, i, h, a, c, l, d) {
585
- n(this, "svg");
586
- n(this, "group");
587
- n(this, "line");
588
- n(this, "sourceArrow", null);
589
- n(this, "targetArrow", null);
590
- n(this, "detourX");
591
- n(this, "detourY");
592
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = c, this.detourX = Math.cos(d) * l, this.detourY = Math.sin(d) * l, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", h && (this.sourceArrow = document.createElementNS(
699
+ class k {
700
+ constructor(t, r, s, o, n, i, a, c, l, d) {
701
+ h(this, "svg");
702
+ h(this, "group");
703
+ h(this, "line");
704
+ h(this, "sourceArrow", null);
705
+ h(this, "targetArrow", null);
706
+ h(this, "detourX");
707
+ h(this, "detourY");
708
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = n, this.roundness = c, this.detourX = Math.cos(d) * l, this.detourY = Math.sin(d) * l, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.sourceArrow = document.createElementNS(
593
709
  "http://www.w3.org/2000/svg",
594
710
  "path"
595
711
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
@@ -597,53 +713,53 @@ class H {
597
713
  "path"
598
714
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
599
715
  }
600
- update(t, e, s, o, i, h) {
716
+ update(t, r, s, o, n, i) {
601
717
  this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
602
- const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
603
- this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
604
- const u = N(i.direction, l, d), g = N(h.direction, l, d), w = this.sourceArrow ? b([this.arrowLength, 0], u, [0, 0]) : [0, 0], m = this.targetArrow ? b([s - this.arrowLength, o], g, [
718
+ const a = T(n), c = T(i), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
719
+ this.svg.style.transform = `translate(${t}px, ${r}px)`, this.group.style.transform = `scale(${l}, ${d})`;
720
+ const g = b(n.direction, l, d), u = b(i.direction, l, d), p = this.sourceArrow ? y([this.arrowLength, 0], g, [0, 0]) : [0, 0], w = this.targetArrow ? y([s - this.arrowLength, o], u, [
605
721
  s,
606
722
  o
607
- ]) : [s, o], f = this.arrowLength + this.arrowOffset, p = b([f, 0], u, [0, 0]), C = [p[0] + this.detourX, p[1] + this.detourY], v = b([s - f, o], g, [
723
+ ]) : [s, o], f = this.arrowLength + this.arrowOffset, m = y([f, 0], g, [0, 0]), E = [m[0] + this.detourX, m[1] + this.detourY], v = y([s - f, o], u, [
608
724
  s,
609
725
  o
610
- ]), E = [v[0] + this.detourX, v[1] + this.detourY], A = V(
611
- [w, p, C, E, v, m],
726
+ ]), C = [v[0] + this.detourX, v[1] + this.detourY], S = V(
727
+ [p, m, E, C, v, w],
612
728
  this.roundness
613
729
  );
614
- if (this.line.setAttribute("d", A), this.sourceArrow) {
615
- const y = S(
616
- u,
730
+ if (this.line.setAttribute("d", S), this.sourceArrow) {
731
+ const A = N(
732
+ g,
617
733
  0,
618
734
  0,
619
735
  this.arrowLength,
620
736
  this.arrowWidth
621
737
  );
622
- this.sourceArrow.setAttribute("d", y);
738
+ this.sourceArrow.setAttribute("d", A);
623
739
  }
624
740
  if (this.targetArrow) {
625
- const y = S(
626
- g,
741
+ const A = N(
742
+ u,
627
743
  s,
628
744
  o,
629
745
  -this.arrowLength,
630
746
  this.arrowWidth
631
747
  );
632
- this.targetArrow.setAttribute("d", y);
748
+ this.targetArrow.setAttribute("d", A);
633
749
  }
634
750
  }
635
751
  }
636
- var T = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.PortCycle = "port-cycle", r.NodeCycle = "node-cycle", r))(T || {});
637
- class q {
638
- constructor(t, e, s, o, i, h, a, c, l) {
639
- n(this, "svg");
640
- n(this, "group");
641
- n(this, "line");
642
- n(this, "sourceArrow", null);
643
- n(this, "targetArrow", null);
644
- n(this, "detourX");
645
- n(this, "detourY");
646
- this.color = t, this.width = e, this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(l) * c, this.detourY = Math.sin(l) * c, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", h && (this.sourceArrow = document.createElementNS(
752
+ var $ = /* @__PURE__ */ ((e) => (e.Regular = "regular", e.PortCycle = "port-cycle", e.NodeCycle = "node-cycle", e))($ || {});
753
+ class st {
754
+ constructor(t, r, s, o, n, i, a, c, l) {
755
+ h(this, "svg");
756
+ h(this, "group");
757
+ h(this, "line");
758
+ h(this, "sourceArrow", null);
759
+ h(this, "targetArrow", null);
760
+ h(this, "detourX");
761
+ h(this, "detourY");
762
+ this.color = t, this.width = r, this.curvature = s, this.arrowLength = o, this.arrowWidth = n, this.detourX = Math.cos(l) * c, this.detourY = Math.sin(l) * c, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.group = document.createElementNS("http://www.w3.org/2000/svg", "g"), this.svg.appendChild(this.group), this.line = document.createElementNS("http://www.w3.org/2000/svg", "path"), this.line.setAttribute("stroke", this.color), this.line.setAttribute("stroke-width", `${this.width}`), this.line.setAttribute("fill", "none"), this.group.appendChild(this.line), this.group.style.transformOrigin = "50% 50%", i && (this.sourceArrow = document.createElementNS(
647
763
  "http://www.w3.org/2000/svg",
648
764
  "path"
649
765
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), a && (this.targetArrow = document.createElementNS(
@@ -651,112 +767,170 @@ class q {
651
767
  "path"
652
768
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
653
769
  }
654
- update(t, e, s, o, i, h) {
770
+ update(t, r, s, o, n, i) {
655
771
  this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
656
- const a = $(i), c = $(h), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
657
- this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${l}, ${d})`;
658
- const u = N(i.direction, l, d), g = N(h.direction, l, d), w = this.sourceArrow ? b([this.arrowLength, 0], u, [0, 0]) : [0, 0], m = this.targetArrow ? b([s - this.arrowLength, o], g, [
772
+ const a = T(n), c = T(i), l = a[0] <= c[0] ? 1 : -1, d = a[1] <= c[1] ? 1 : -1;
773
+ this.svg.style.transform = `translate(${t}px, ${r}px)`, this.group.style.transform = `scale(${l}, ${d})`;
774
+ const g = b(n.direction, l, d), u = b(i.direction, l, d), p = this.sourceArrow ? y([this.arrowLength, 0], g, [0, 0]) : [0, 0], w = this.targetArrow ? y([s - this.arrowLength, o], u, [
659
775
  s,
660
776
  o
661
- ]) : [s, o], f = this.arrowLength, p = b([f, 0], u, [0, 0]), C = [p[0] + this.detourX, p[1] + this.detourY], v = b([s - f, o], g, [
777
+ ]) : [s, o], f = this.arrowLength, m = y([f, 0], g, [0, 0]), E = [m[0] + this.detourX, m[1] + this.detourY], v = y([s - f, o], u, [
662
778
  s,
663
779
  o
664
- ]), E = [v[0] + this.detourX, v[1] + this.detourY], A = [(C[0] + E[0]) / 2, (C[1] + E[1]) / 2], y = [
665
- p[0] - this.curvature * Math.cos(i.direction),
666
- p[1] - this.curvature * Math.sin(i.direction)
667
- ], x = [
668
- v[0] + this.curvature * Math.cos(h.direction),
669
- v[1] + this.curvature * Math.sin(h.direction)
670
- ], P = [p[0] + this.detourX, p[1] + this.detourY], M = [v[0] + this.detourX, v[1] + this.detourY], k = [
671
- `M ${w[0]} ${w[1]}`,
672
- `L ${p[0]} ${p[1]}`,
673
- `C ${y[0]} ${y[1]} ${P[0]} ${P[1]} ${A[0]} ${A[1]}`,
674
- `C ${M[0]} ${M[1]} ${x[0]} ${x[1]} ${v[0]} ${v[1]}`,
675
- `L ${m[0]} ${m[1]}`
780
+ ]), C = [v[0] + this.detourX, v[1] + this.detourY], S = [(E[0] + C[0]) / 2, (E[1] + C[1]) / 2], A = [
781
+ m[0] - this.curvature * Math.cos(n.direction),
782
+ m[1] - this.curvature * Math.sin(n.direction)
783
+ ], P = [
784
+ v[0] + this.curvature * Math.cos(i.direction),
785
+ v[1] + this.curvature * Math.sin(i.direction)
786
+ ], M = [m[0] + this.detourX, m[1] + this.detourY], x = [v[0] + this.detourX, v[1] + this.detourY], L = [
787
+ `M ${p[0]} ${p[1]}`,
788
+ `L ${m[0]} ${m[1]}`,
789
+ `C ${A[0]} ${A[1]} ${M[0]} ${M[1]} ${S[0]} ${S[1]}`,
790
+ `C ${x[0]} ${x[1]} ${P[0]} ${P[1]} ${v[0]} ${v[1]}`,
791
+ `L ${w[0]} ${w[1]}`
676
792
  ].join(" ");
677
- if (this.line.setAttribute("d", k), this.sourceArrow) {
678
- const O = S(
679
- u,
793
+ if (this.line.setAttribute("d", L), this.sourceArrow) {
794
+ const F = N(
795
+ g,
680
796
  0,
681
797
  0,
682
798
  this.arrowLength,
683
799
  this.arrowWidth
684
800
  );
685
- this.sourceArrow.setAttribute("d", O);
801
+ this.sourceArrow.setAttribute("d", F);
686
802
  }
687
803
  if (this.targetArrow) {
688
- const O = S(
689
- g,
804
+ const F = N(
805
+ u,
690
806
  s,
691
807
  o,
692
808
  -this.arrowLength,
693
809
  this.arrowWidth
694
810
  );
695
- this.targetArrow.setAttribute("d", O);
811
+ this.targetArrow.setAttribute("d", F);
696
812
  }
697
813
  }
698
814
  }
699
- const _ = (r) => (t) => t === T.PortCycle ? new Z(
700
- r.color,
701
- r.width,
702
- r.arrowLength,
703
- r.arrowWidth,
704
- r.hasSourceArrow || r.hasTargetArrow,
705
- r.cycleRadius,
706
- r.smallCycleRadius
707
- ) : t === T.NodeCycle ? new q(
708
- r.color,
709
- r.width,
710
- r.curvature,
711
- r.arrowLength,
712
- r.arrowWidth,
713
- r.hasSourceArrow,
714
- r.hasTargetArrow,
715
- r.detourDistance,
716
- r.detourDirection
717
- ) : new z(
718
- r.color,
719
- r.width,
720
- r.curvature,
721
- r.arrowLength,
722
- r.arrowWidth,
723
- r.hasSourceArrow,
724
- r.hasTargetArrow
725
- ), J = (r) => (t) => t === T.PortCycle ? new U(
726
- r.color,
727
- r.width,
728
- r.arrowLength,
729
- r.arrowWidth,
730
- r.hasSourceArrow || r.hasTargetArrow,
731
- r.cycleSquareSide,
732
- r.arrowOffset,
733
- r.roundness
734
- ) : t === T.NodeCycle ? new H(
735
- r.color,
736
- r.width,
737
- r.arrowLength,
738
- r.arrowWidth,
739
- r.arrowOffset,
740
- r.hasSourceArrow,
741
- r.hasTargetArrow,
742
- r.roundness,
743
- r.detourDistance,
744
- r.detourDirection
745
- ) : new G(
746
- r.color,
747
- r.width,
748
- r.arrowLength,
749
- r.arrowWidth,
750
- r.arrowOffset,
751
- r.hasSourceArrow,
752
- r.hasTargetArrow,
753
- r.roundness
815
+ const ot = (e) => (t) => t === $.PortCycle ? new rt(
816
+ e.color,
817
+ e.width,
818
+ e.arrowLength,
819
+ e.arrowWidth,
820
+ e.hasSourceArrow || e.hasTargetArrow,
821
+ e.cycleRadius,
822
+ e.smallCycleRadius
823
+ ) : t === $.NodeCycle ? new st(
824
+ e.color,
825
+ e.width,
826
+ e.curvature,
827
+ e.arrowLength,
828
+ e.arrowWidth,
829
+ e.hasSourceArrow,
830
+ e.hasTargetArrow,
831
+ e.detourDistance,
832
+ e.detourDirection
833
+ ) : new q(
834
+ e.color,
835
+ e.width,
836
+ e.curvature,
837
+ e.arrowLength,
838
+ e.arrowWidth,
839
+ e.hasSourceArrow,
840
+ e.hasTargetArrow
841
+ ), it = (e) => (t) => t === $.PortCycle ? new W(
842
+ e.color,
843
+ e.width,
844
+ e.arrowLength,
845
+ e.arrowWidth,
846
+ e.hasSourceArrow || e.hasTargetArrow,
847
+ e.cycleSquareSide,
848
+ e.arrowOffset,
849
+ e.roundness
850
+ ) : t === $.NodeCycle ? new k(
851
+ e.color,
852
+ e.width,
853
+ e.arrowLength,
854
+ e.arrowWidth,
855
+ e.arrowOffset,
856
+ e.hasSourceArrow,
857
+ e.hasTargetArrow,
858
+ e.roundness,
859
+ e.detourDistance,
860
+ e.detourDirection
861
+ ) : new I(
862
+ e.color,
863
+ e.width,
864
+ e.arrowLength,
865
+ e.arrowWidth,
866
+ e.arrowOffset,
867
+ e.hasSourceArrow,
868
+ e.hasTargetArrow,
869
+ e.roundness
870
+ ), nt = (e) => (t) => t === $.PortCycle ? new W(
871
+ e.color,
872
+ e.width,
873
+ e.arrowLength,
874
+ e.arrowWidth,
875
+ e.hasSourceArrow || e.hasTargetArrow,
876
+ e.cycleSquareSide,
877
+ e.arrowOffset,
878
+ e.roundness
879
+ ) : t === $.NodeCycle ? new k(
880
+ e.color,
881
+ e.width,
882
+ e.arrowLength,
883
+ e.arrowWidth,
884
+ e.arrowOffset,
885
+ e.hasSourceArrow,
886
+ e.hasTargetArrow,
887
+ e.roundness,
888
+ e.detourDistance,
889
+ e.detourDirection
890
+ ) : new tt(
891
+ e.color,
892
+ e.width,
893
+ e.arrowLength,
894
+ e.arrowWidth,
895
+ e.arrowOffset,
896
+ e.hasSourceArrow,
897
+ e.hasTargetArrow,
898
+ e.roundness
899
+ ), ht = (e) => (t) => t === $.PortCycle ? new W(
900
+ e.color,
901
+ e.width,
902
+ e.arrowLength,
903
+ e.arrowWidth,
904
+ e.hasSourceArrow || e.hasTargetArrow,
905
+ e.cycleSquareSide,
906
+ e.arrowOffset,
907
+ e.roundness
908
+ ) : t === $.NodeCycle ? new k(
909
+ e.color,
910
+ e.width,
911
+ e.arrowLength,
912
+ e.arrowWidth,
913
+ e.arrowOffset,
914
+ e.hasSourceArrow,
915
+ e.hasTargetArrow,
916
+ e.roundness,
917
+ e.detourDistance,
918
+ e.detourDirection
919
+ ) : new et(
920
+ e.color,
921
+ e.width,
922
+ e.arrowLength,
923
+ e.arrowWidth,
924
+ e.arrowOffset,
925
+ e.hasSourceArrow,
926
+ e.hasTargetArrow,
927
+ e.roundness
754
928
  );
755
- class L {
929
+ class O {
756
930
  constructor() {
757
- n(this, "counter", 0);
931
+ h(this, "counter", 0);
758
932
  }
759
- next() {
933
+ create() {
760
934
  const t = `${this.counter}`;
761
935
  return this.counter++, t;
762
936
  }
@@ -764,40 +938,62 @@ class L {
764
938
  this.counter = 0;
765
939
  }
766
940
  }
767
- class K {
768
- constructor(t, e, s, o, i, h) {
769
- n(this, "nodeIdGenerator", new L());
770
- n(this, "portIdGenerator", new L());
771
- n(this, "edgeIdGenerator", new L());
772
- this.graphStore = t, this.htmlController = e, this.viewportTransformer = s, this.nodesCenterFn = o, this.portsCenterFn = i, this.portsDirection = h;
941
+ class at {
942
+ constructor() {
943
+ h(this, "priority", 0);
944
+ }
945
+ create() {
946
+ const t = this.priority;
947
+ return this.priority++, t;
948
+ }
949
+ push(t) {
950
+ this.priority = Math.max(this.priority, t);
951
+ }
952
+ reset() {
953
+ this.priority = 0;
954
+ }
955
+ }
956
+ class ct {
957
+ constructor(t, r, s, o, n, i) {
958
+ h(this, "nodeIdGenerator", new O());
959
+ h(this, "portIdGenerator", new O());
960
+ h(this, "edgeIdGenerator", new O());
961
+ h(this, "priorityGenerator", new at());
962
+ this.graphStore = t, this.htmlController = r, this.viewportTransformer = s, this.nodesCenterFn = o, this.portsCenterFn = n, this.portsDirection = i;
773
963
  }
774
964
  moveNodeOnTop(t) {
775
- if (!this.graphStore.hasNode(t))
965
+ const r = this.graphStore.getNode(t);
966
+ if (r === void 0)
776
967
  throw new Error("failed to move on top nonexisting node");
777
- this.htmlController.moveNodeOnTop(t);
968
+ const s = this.priorityGenerator.create(), o = this.priorityGenerator.create();
969
+ r.priority = o, this.htmlController.updateNodePriority(t), this.graphStore.getNodeAdjacentEdges(t).forEach((i) => {
970
+ const a = this.graphStore.getEdge(i);
971
+ a.priority = s, this.htmlController.updateEdgePriority(i);
972
+ });
778
973
  }
779
- addNode(t, e, s, o, i, h) {
974
+ addNode(t, r, s, o, n, i, a) {
780
975
  if (t === void 0)
781
976
  do
782
- t = this.nodeIdGenerator.next();
783
- while (this.graphStore.hasNode(t));
784
- if (this.graphStore.hasNode(t))
977
+ t = this.nodeIdGenerator.create();
978
+ while (this.graphStore.getNode(t) !== void 0);
979
+ if (this.graphStore.getNode(t) !== void 0)
785
980
  throw new Error("failed to add node with existing id");
786
- this.graphStore.addNode(
981
+ a !== void 0 && this.priorityGenerator.push(a), this.graphStore.addNode(
787
982
  t,
788
- e,
983
+ r,
789
984
  s,
790
985
  o,
791
- h ?? this.nodesCenterFn
792
- ), this.htmlController.attachNode(t), i !== void 0 && Object.entries(i).forEach(([a, c]) => {
986
+ i ?? this.nodesCenterFn,
987
+ a ?? this.priorityGenerator.create()
988
+ ), this.htmlController.attachNode(t), n !== void 0 && n.forEach((c, l) => {
793
989
  c instanceof HTMLElement ? this.markPort(
794
- a,
990
+ l,
795
991
  c,
796
992
  t,
797
993
  this.portsCenterFn,
798
994
  this.portsDirection
799
995
  ) : this.markPort(
800
- a,
996
+ l,
801
997
  c.element,
802
998
  t,
803
999
  c.centerFn ?? this.portsCenterFn,
@@ -805,87 +1001,93 @@ class K {
805
1001
  );
806
1002
  });
807
1003
  }
808
- markPort(t, e, s, o, i) {
1004
+ updateNode(t, r, s, o, n) {
1005
+ const i = this.graphStore.getNode(t);
1006
+ if (i === void 0)
1007
+ throw new Error("failed to update nonexisting node");
1008
+ i.x = r ?? i.x, i.y = s ?? i.y, i.centerFn = n ?? i.centerFn, this.htmlController.updateNodeCoordinates(t), o !== void 0 && (i.priority = o, this.htmlController.updateNodePriority(t));
1009
+ }
1010
+ markPort(t, r, s, o, n) {
809
1011
  if (t === void 0)
810
1012
  do
811
- t = this.portIdGenerator.next();
812
- while (this.graphStore.hasPort(t));
813
- if (!this.graphStore.hasNode(s))
1013
+ t = this.portIdGenerator.create();
1014
+ while (this.graphStore.getPort(t) !== void 0);
1015
+ if (this.graphStore.getNode(s) === void 0)
814
1016
  throw new Error("failed to set port on nonexisting node");
815
- if (this.graphStore.hasPort(t))
1017
+ if (this.graphStore.getPort(t) !== void 0)
816
1018
  throw new Error("failed to add port with existing id");
817
1019
  this.graphStore.addPort(
818
1020
  t,
819
- e,
1021
+ r,
820
1022
  s,
821
1023
  o ?? this.portsCenterFn,
822
- i ?? 0
1024
+ n ?? 0
823
1025
  );
824
1026
  }
825
- updatePortEdges(t) {
826
- if (!this.graphStore.hasPort(t))
1027
+ updatePort(t, r) {
1028
+ const s = this.graphStore.getPort(t);
1029
+ if (s === void 0)
827
1030
  throw new Error("failed to unset nonexisting port");
828
- this.htmlController.updatePortEdges(t);
1031
+ s.direction = (r == null ? void 0 : r.direction) ?? s.direction, s.centerFn = (r == null ? void 0 : r.centerFn) ?? s.centerFn, this.htmlController.updatePortEdges(t);
829
1032
  }
830
1033
  unmarkPort(t) {
831
- if (!this.graphStore.hasPort(t))
1034
+ if (this.graphStore.getPort(t) === void 0)
832
1035
  throw new Error("failed to unset nonexisting port");
833
- this.graphStore.getPortAdjacentEdges(t).forEach((e) => {
834
- this.removeEdge(e);
1036
+ this.graphStore.getPortAdjacentEdges(t).forEach((r) => {
1037
+ this.removeEdge(r);
835
1038
  }), this.graphStore.removePort(t);
836
1039
  }
837
- addEdge(t, e, s, o) {
1040
+ addEdge(t, r, s, o, n) {
838
1041
  if (t === void 0)
839
1042
  do
840
- t = this.edgeIdGenerator.next();
841
- while (this.graphStore.hasEdge(t));
842
- if (!this.graphStore.hasPort(e))
1043
+ t = this.edgeIdGenerator.create();
1044
+ while (this.graphStore.getEdge(t) !== void 0);
1045
+ if (this.graphStore.getPort(r) === void 0)
843
1046
  throw new Error("failed to add edge from nonexisting port");
844
- if (!this.graphStore.hasPort(s))
1047
+ if (this.graphStore.getPort(s) === void 0)
845
1048
  throw new Error("failed to add edge to nonexisting port");
846
- let i = T.Regular;
847
- const h = this.graphStore.getPortNode(e), a = this.graphStore.getPortNode(s);
848
- e === s ? i = T.PortCycle : h === a && (i = T.NodeCycle), this.graphStore.addEdge(
1049
+ if (this.graphStore.getEdge(t) !== void 0)
1050
+ throw new Error("failed to add edge with existing id");
1051
+ let i = $.Regular;
1052
+ const a = this.graphStore.getPortNode(r), c = this.graphStore.getPortNode(s);
1053
+ r === s ? i = $.PortCycle : a === c && (i = $.NodeCycle), n !== void 0 && this.priorityGenerator.push(n), this.graphStore.addEdge(
849
1054
  t,
850
- e,
1055
+ r,
851
1056
  s,
852
- o(i)
1057
+ o(i),
1058
+ n ?? this.priorityGenerator.create()
853
1059
  ), this.htmlController.attachEdge(t);
854
1060
  }
1061
+ updateEdge(t, r) {
1062
+ const s = this.graphStore.getEdge(t);
1063
+ if (s === void 0)
1064
+ throw new Error("failed to update nonexisting edge");
1065
+ r.controller !== void 0 && (this.htmlController.detachEdge(t), s.controller = r.controller, this.htmlController.attachEdge(t)), r.priority !== void 0 && (s.priority = r.priority, this.htmlController.updateEdgePriority(t));
1066
+ }
855
1067
  removeEdge(t) {
856
- if (!this.graphStore.hasEdge(t))
1068
+ if (this.graphStore.getEdge(t) === void 0)
857
1069
  throw new Error("failed to remove nonexisting edge");
858
1070
  this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
859
1071
  }
860
1072
  removeNode(t) {
861
- if (!this.graphStore.hasNode(t))
1073
+ if (this.graphStore.getNode(t) === void 0)
862
1074
  throw new Error("failed to remove nonexisting node");
863
1075
  this.htmlController.detachNode(t), this.graphStore.removeNode(t);
864
1076
  }
865
- patchViewportState(t, e, s) {
866
- this.viewportTransformer.patchState(t, e, s), this.htmlController.applyTransform();
1077
+ patchViewportState(t, r, s) {
1078
+ this.viewportTransformer.patchState(t, r, s), this.htmlController.applyTransform();
867
1079
  }
868
1080
  moveToNodes(t) {
869
1081
  if (t.length === 0)
870
1082
  return;
871
- const e = t.map((g) => this.graphStore.getNode(g)).filter((g) => g !== void 0);
872
- if (e.length < t.length)
1083
+ const r = t.map((u) => this.graphStore.getNode(u)).filter((u) => u !== void 0);
1084
+ if (r.length < t.length)
873
1085
  throw new Error("failed to move to nonexisting node");
874
- const [s, o] = e.reduce(
875
- (g, w) => [g[0] + w.x, g[1] + w.y],
1086
+ const [s, o] = r.reduce(
1087
+ (u, p) => [u[0] + p.x, u[1] + p.y],
876
1088
  [0, 0]
877
- ), i = s / e.length, h = o / e.length, [a, c] = this.htmlController.getViewportDimensions(), l = this.viewportTransformer.getAbsScale(), d = i - l * a / 2, u = h - l * c / 2;
878
- this.patchViewportState(null, d, u);
879
- }
880
- updateNodeCoordinates(t, e, s) {
881
- if (!this.graphStore.hasNode(t))
882
- throw new Error("failed to update coordinates of nonexisting node");
883
- this.graphStore.updateNodeCoords(t, e, s), this.htmlController.updateNodeCoordinates(t);
884
- }
885
- updateEdgeController(t, e) {
886
- if (!this.graphStore.hasEdge(t))
887
- throw new Error("failed to update nonexisting edge");
888
- this.htmlController.detachEdge(t), this.graphStore.updateEdgeController(t, e), this.htmlController.attachEdge(t);
1089
+ ), n = s / r.length, i = o / r.length, [a, c] = this.htmlController.getViewportDimensions(), l = this.viewportTransformer.getAbsScale(), d = n - l * a / 2, g = i - l * c / 2;
1090
+ this.patchViewportState(null, d, g);
889
1091
  }
890
1092
  attach(t) {
891
1093
  this.htmlController.attach(t);
@@ -894,152 +1096,180 @@ class K {
894
1096
  this.htmlController.detach();
895
1097
  }
896
1098
  clear() {
897
- this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
1099
+ this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset(), this.priorityGenerator.reset();
898
1100
  }
899
1101
  destroy() {
900
1102
  this.htmlController.destroy();
901
1103
  }
902
1104
  }
903
- class Q {
904
- constructor(t, e, s, o, i) {
905
- n(this, "publicViewportTransformer");
906
- n(this, "canvasController");
907
- const h = new B(), a = new X();
908
- this.publicViewportTransformer = new Y(
909
- h
1105
+ class lt {
1106
+ constructor(t, r, s, o, n) {
1107
+ h(this, "publicViewportTransformer");
1108
+ h(this, "canvasController");
1109
+ const i = new K(), a = new Z();
1110
+ this.publicViewportTransformer = new Q(
1111
+ i
910
1112
  );
911
- const c = new R(
1113
+ const c = new J(
912
1114
  a,
913
- h,
1115
+ i,
914
1116
  this.publicViewportTransformer,
915
1117
  t,
916
- e
1118
+ r
917
1119
  );
918
- this.canvasController = new K(
1120
+ this.canvasController = new ct(
919
1121
  a,
920
1122
  c,
921
- h,
1123
+ i,
922
1124
  s,
923
1125
  o,
924
- i
1126
+ n
925
1127
  );
926
1128
  }
927
1129
  }
928
- const D = (r, t) => [
929
- r / 2,
1130
+ const R = (e, t) => [
1131
+ e / 2,
930
1132
  t / 2
931
- ], I = () => () => {
932
- }, tt = (r, t, e, s, o, i) => {
933
- r.clearRect(0, 0, r.canvas.width, r.canvas.height), r.fillStyle = i, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
934
- const h = t.getViewCoords(0, 0), a = t.getViewScale(), c = s * a;
935
- let l = 0, d = 0, u = c / 2;
1133
+ ], dt = () => () => {
1134
+ }, gt = (e, t, r, s, o, n) => {
1135
+ e.clearRect(0, 0, e.canvas.width, e.canvas.height), e.fillStyle = n, e.fillRect(0, 0, e.canvas.width, e.canvas.height);
1136
+ const i = t.getViewCoords(0, 0), a = t.getViewScale(), c = s * a;
1137
+ let l = 0, d = 0, g = c / 2;
936
1138
  do
937
- u *= 2, l = r.canvas.width / u, d = r.canvas.height / u;
1139
+ g *= 2, l = e.canvas.width / g, d = e.canvas.height / g;
938
1140
  while (l * d > 1e4);
939
- const g = h[0] - Math.floor(h[0] / u) * u, w = h[1] - Math.floor(h[1] / u) * u, m = o * a, f = 2 * Math.PI, p = g - u, C = w - u, v = r.canvas.width + g, E = r.canvas.height + w;
940
- r.fillStyle = e;
941
- for (let A = p; A <= v; A += u)
942
- for (let y = C; y <= E; y += u)
943
- r.beginPath(), r.arc(A, y, m, 0, f), r.closePath(), r.fill();
944
- }, et = (r, t, e, s) => (o, i) => {
945
- tt(
1141
+ const u = i[0] - Math.floor(i[0] / g) * g, p = i[1] - Math.floor(i[1] / g) * g, w = o * a, f = 2 * Math.PI, m = u - g, E = p - g, v = e.canvas.width + u, C = e.canvas.height + p;
1142
+ e.fillStyle = r;
1143
+ for (let S = m; S <= v; S += g)
1144
+ for (let A = E; A <= C; A += g)
1145
+ e.beginPath(), e.arc(S, A, w, 0, f), e.closePath(), e.fill();
1146
+ }, ut = (e, t, r, s) => (o, n) => {
1147
+ gt(
946
1148
  o,
947
- i,
948
- r,
949
- t,
1149
+ n,
950
1150
  e,
1151
+ t,
1152
+ r,
951
1153
  s
952
1154
  );
953
- }, st = (r, t) => {
954
- r.fillStyle = t, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
955
- }, rt = (r) => (t) => {
956
- st(t, r);
957
- }, ot = (r) => {
958
- switch (r == null ? void 0 : r.type) {
1155
+ }, wt = (e, t) => {
1156
+ e.fillStyle = t, e.fillRect(0, 0, e.canvas.width, e.canvas.height);
1157
+ }, mt = (e) => (t) => {
1158
+ wt(t, e);
1159
+ }, pt = (e) => {
1160
+ switch (e == null ? void 0 : e.type) {
959
1161
  case "custom":
960
- return r.drawingFn;
1162
+ return e.drawingFn;
961
1163
  case "dots":
962
- return et(
963
- r.dotColor ?? "#d8d8d8",
964
- r.dotGap ?? 25,
965
- r.dotRadius ?? 1.5,
966
- r.color ?? "#ffffff"
1164
+ return ut(
1165
+ e.dotColor ?? "#d8d8d8",
1166
+ e.dotGap ?? 25,
1167
+ e.dotRadius ?? 1.5,
1168
+ e.color ?? "#ffffff"
967
1169
  );
968
1170
  case "color":
969
- return rt(r.color ?? "#ffffff");
1171
+ return mt(e.color ?? "#ffffff");
970
1172
  default:
971
- return I();
1173
+ return dt();
972
1174
  }
973
- }, F = (r) => {
974
- switch (r == null ? void 0 : r.type) {
1175
+ }, Y = (e) => {
1176
+ switch (e == null ? void 0 : e.type) {
975
1177
  case "custom":
976
- return r.controllerFactory;
1178
+ return e.controllerFactory;
977
1179
  case "straight":
978
- return J({
979
- color: r.color ?? "#5c5c5c",
980
- width: r.width ?? 1,
981
- arrowLength: r.arrowLength ?? 15,
982
- arrowWidth: r.arrowWidth ?? 4,
983
- arrowOffset: r.arrowOffset ?? 15,
984
- hasSourceArrow: r.hasSourceArrow ?? !1,
985
- hasTargetArrow: r.hasTargetArrow ?? !1,
986
- cycleSquareSide: r.cycleSquareSide ?? 30,
987
- roundness: r.roundness ?? 10,
988
- detourDistance: r.detourDistance ?? 100,
989
- detourDirection: r.detourDirection ?? -Math.PI / 2
1180
+ return it({
1181
+ color: e.color ?? "#5c5c5c",
1182
+ width: e.width ?? 1,
1183
+ arrowLength: e.arrowLength ?? 15,
1184
+ arrowWidth: e.arrowWidth ?? 4,
1185
+ arrowOffset: e.arrowOffset ?? 15,
1186
+ hasSourceArrow: e.hasSourceArrow ?? !1,
1187
+ hasTargetArrow: e.hasTargetArrow ?? !1,
1188
+ cycleSquareSide: e.cycleSquareSide ?? 30,
1189
+ roundness: e.roundness ?? 10,
1190
+ detourDistance: e.detourDistance ?? 100,
1191
+ detourDirection: e.detourDirection ?? -Math.PI / 2
1192
+ });
1193
+ case "horizontal":
1194
+ return nt({
1195
+ color: e.color ?? "#5c5c5c",
1196
+ width: e.width ?? 1,
1197
+ arrowLength: e.arrowLength ?? 15,
1198
+ arrowWidth: e.arrowWidth ?? 4,
1199
+ arrowOffset: e.arrowOffset ?? 15,
1200
+ hasSourceArrow: e.hasSourceArrow ?? !1,
1201
+ hasTargetArrow: e.hasTargetArrow ?? !1,
1202
+ cycleSquareSide: e.cycleSquareSide ?? 30,
1203
+ roundness: e.roundness ?? 10,
1204
+ detourDistance: e.detourDistance ?? 100,
1205
+ detourDirection: e.detourDirection ?? -Math.PI / 2
1206
+ });
1207
+ case "vertical":
1208
+ return ht({
1209
+ color: e.color ?? "#5c5c5c",
1210
+ width: e.width ?? 1,
1211
+ arrowLength: e.arrowLength ?? 15,
1212
+ arrowWidth: e.arrowWidth ?? 4,
1213
+ arrowOffset: e.arrowOffset ?? 15,
1214
+ hasSourceArrow: e.hasSourceArrow ?? !1,
1215
+ hasTargetArrow: e.hasTargetArrow ?? !1,
1216
+ cycleSquareSide: e.cycleSquareSide ?? 30,
1217
+ roundness: e.roundness ?? 10,
1218
+ detourDistance: e.detourDistance ?? 100,
1219
+ detourDirection: e.detourDirection ?? -Math.PI / 2
990
1220
  });
991
1221
  default:
992
- return _({
993
- color: r.color ?? "#5c5c5c",
994
- width: r.width ?? 1,
995
- curvature: r.curvature ?? 90,
996
- arrowLength: r.arrowLength ?? 15,
997
- arrowWidth: r.arrowWidth ?? 4,
998
- hasSourceArrow: r.hasSourceArrow ?? !1,
999
- hasTargetArrow: r.hasTargetArrow ?? !1,
1000
- cycleRadius: r.cycleRadius ?? 30,
1001
- smallCycleRadius: r.smallCycleRadius ?? 15,
1002
- detourDistance: r.detourDistance ?? 100,
1003
- detourDirection: r.detourDirection ?? -Math.PI / 2
1222
+ return ot({
1223
+ color: e.color ?? "#5c5c5c",
1224
+ width: e.width ?? 1,
1225
+ curvature: e.curvature ?? 90,
1226
+ arrowLength: e.arrowLength ?? 15,
1227
+ arrowWidth: e.arrowWidth ?? 4,
1228
+ hasSourceArrow: e.hasSourceArrow ?? !1,
1229
+ hasTargetArrow: e.hasTargetArrow ?? !1,
1230
+ cycleRadius: e.cycleRadius ?? 30,
1231
+ smallCycleRadius: e.smallCycleRadius ?? 15,
1232
+ detourDistance: e.detourDistance ?? 100,
1233
+ detourDirection: e.detourDirection ?? -Math.PI / 2
1004
1234
  });
1005
1235
  }
1006
- }, nt = (r) => {
1007
- var t, e, s, o;
1236
+ }, vt = (e) => {
1237
+ var t, r, s, o;
1008
1238
  return {
1009
1239
  background: {
1010
- drawingFn: ot(
1011
- r.background ?? { type: "none" }
1240
+ drawingFn: pt(
1241
+ e.background ?? { type: "none" }
1012
1242
  )
1013
1243
  },
1014
1244
  nodes: {
1015
- centerFn: ((t = r.nodes) == null ? void 0 : t.centerFn) ?? D
1245
+ centerFn: ((t = e.nodes) == null ? void 0 : t.centerFn) ?? R
1016
1246
  },
1017
1247
  ports: {
1018
- centerFn: ((e = r.ports) == null ? void 0 : e.centerFn) ?? D,
1019
- direction: ((s = r.ports) == null ? void 0 : s.direction) ?? 0
1248
+ centerFn: ((r = e.ports) == null ? void 0 : r.centerFn) ?? R,
1249
+ direction: ((s = e.ports) == null ? void 0 : s.direction) ?? 0
1020
1250
  },
1021
1251
  edges: {
1022
- controllerFactory: F(r.edges ?? {})
1252
+ controllerFactory: Y(e.edges ?? {})
1023
1253
  },
1024
1254
  layers: {
1025
- mode: ((o = r.layers) == null ? void 0 : o.mode) ?? "edges-follow-node"
1255
+ mode: ((o = e.layers) == null ? void 0 : o.mode) ?? "edges-follow-node"
1026
1256
  }
1027
1257
  };
1028
1258
  };
1029
- class it {
1259
+ class ft {
1030
1260
  constructor(t) {
1031
- n(this, "transformation");
1032
- n(this, "di");
1033
- n(this, "edgeControllerFactory");
1261
+ h(this, "transformation");
1262
+ h(this, "di");
1263
+ h(this, "edgeControllerFactory");
1034
1264
  this.apiOptions = t;
1035
- const e = nt(this.apiOptions ?? {});
1036
- this.di = new Q(
1037
- e.layers.mode,
1038
- e.background.drawingFn,
1039
- e.nodes.centerFn,
1040
- e.ports.centerFn,
1041
- e.ports.direction
1042
- ), this.transformation = this.di.publicViewportTransformer, this.edgeControllerFactory = e.edges.controllerFactory;
1265
+ const r = vt(this.apiOptions ?? {});
1266
+ this.di = new lt(
1267
+ r.layers.mode,
1268
+ r.background.drawingFn,
1269
+ r.nodes.centerFn,
1270
+ r.ports.centerFn,
1271
+ r.ports.direction
1272
+ ), this.transformation = this.di.publicViewportTransformer, this.edgeControllerFactory = r.edges.controllerFactory;
1043
1273
  }
1044
1274
  addNode(t) {
1045
1275
  return this.di.canvasController.addNode(
@@ -1048,15 +1278,25 @@ class it {
1048
1278
  t.x,
1049
1279
  t.y,
1050
1280
  t.ports,
1051
- t.centerFn
1281
+ t.centerFn,
1282
+ t.priority
1052
1283
  ), this;
1053
1284
  }
1054
- moveNodeOnTop(t) {
1055
- return this.di.canvasController.moveNodeOnTop(t), this;
1285
+ updateNode(t, r) {
1286
+ return this.di.canvasController.updateNode(
1287
+ t,
1288
+ r.x,
1289
+ r.y,
1290
+ r.priority,
1291
+ r.centerFn
1292
+ ), this;
1056
1293
  }
1057
1294
  removeNode(t) {
1058
1295
  return this.di.canvasController.removeNode(t), this;
1059
1296
  }
1297
+ moveNodeOnTop(t) {
1298
+ return this.di.canvasController.moveNodeOnTop(t), this;
1299
+ }
1060
1300
  markPort(t) {
1061
1301
  return this.di.canvasController.markPort(
1062
1302
  t.id,
@@ -1066,21 +1306,25 @@ class it {
1066
1306
  t.direction
1067
1307
  ), this;
1068
1308
  }
1069
- updatePortEdges(t) {
1070
- return this.di.canvasController.updatePortEdges(t), this;
1309
+ updatePort(t, r) {
1310
+ return this.di.canvasController.updatePort(t, r), this;
1071
1311
  }
1072
1312
  unmarkPort(t) {
1073
1313
  return this.di.canvasController.unmarkPort(t), this;
1074
1314
  }
1075
1315
  addEdge(t) {
1076
- const e = t.options !== void 0 ? F(t.options) : this.edgeControllerFactory;
1316
+ const r = t.options !== void 0 ? Y(t.options) : this.edgeControllerFactory;
1077
1317
  return this.di.canvasController.addEdge(
1078
1318
  t.id,
1079
1319
  t.from,
1080
1320
  t.to,
1081
- e
1321
+ r,
1322
+ t.priority
1082
1323
  ), this;
1083
1324
  }
1325
+ updateEdge(t, r) {
1326
+ return this.di.canvasController.updateEdge(t, r), this;
1327
+ }
1084
1328
  removeEdge(t) {
1085
1329
  return this.di.canvasController.removeEdge(t), this;
1086
1330
  }
@@ -1094,12 +1338,6 @@ class it {
1094
1338
  moveToNodes(t) {
1095
1339
  return this.di.canvasController.moveToNodes(t), this;
1096
1340
  }
1097
- updateNodeCoordinates(t, e, s) {
1098
- return this.di.canvasController.updateNodeCoordinates(t, e, s), this;
1099
- }
1100
- updateEdge(t, e) {
1101
- return e.controller !== void 0 && this.di.canvasController.updateEdgeController(t, e.controller), this;
1102
- }
1103
1341
  clear() {
1104
1342
  return this.di.canvasController.clear(), this;
1105
1343
  }
@@ -1113,78 +1351,78 @@ class it {
1113
1351
  this.di.canvasController.destroy();
1114
1352
  }
1115
1353
  }
1116
- class ht {
1117
- constructor(t, e) {
1118
- n(this, "transformation");
1119
- n(this, "nodes", /* @__PURE__ */ new Map());
1120
- n(this, "grabbedNodeId", null);
1121
- n(this, "onNodeDrag");
1122
- n(this, "onBeforeNodeDrag");
1123
- n(this, "nodeIdGenerator", new L());
1124
- n(this, "element", null);
1125
- n(this, "onCanvasMouseUp", () => {
1354
+ class Et {
1355
+ constructor(t, r) {
1356
+ h(this, "transformation");
1357
+ h(this, "nodes", /* @__PURE__ */ new Map());
1358
+ h(this, "grabbedNodeId", null);
1359
+ h(this, "onNodeDrag");
1360
+ h(this, "onBeforeNodeDrag");
1361
+ h(this, "nodeIdGenerator", new O());
1362
+ h(this, "element", null);
1363
+ h(this, "onCanvasMouseUp", () => {
1126
1364
  this.setCursor(null), this.grabbedNodeId = null;
1127
1365
  });
1128
- n(this, "onCanvasMouseMove", (t) => {
1366
+ h(this, "onCanvasMouseMove", (t) => {
1129
1367
  this.grabbedNodeId !== null && (t.stopPropagation(), this.dragNode(this.grabbedNodeId, t.movementX, t.movementY));
1130
1368
  });
1131
- n(this, "onCanvasTouchStart", (t) => {
1369
+ h(this, "onCanvasTouchStart", (t) => {
1132
1370
  this.previousTouchCoords = [
1133
1371
  t.touches[0].clientX,
1134
1372
  t.touches[0].clientY
1135
1373
  ];
1136
1374
  });
1137
- n(this, "onCanvasTouchMove", (t) => {
1375
+ h(this, "onCanvasTouchMove", (t) => {
1138
1376
  if (this.grabbedNodeId === null || t.touches.length !== 1 || this.previousTouchCoords === null)
1139
1377
  return;
1140
1378
  t.stopImmediatePropagation();
1141
- const [e, s] = [
1379
+ const [r, s] = [
1142
1380
  t.touches[0].clientX - this.previousTouchCoords[0],
1143
1381
  t.touches[0].clientY - this.previousTouchCoords[1]
1144
1382
  ];
1145
- this.dragNode(this.grabbedNodeId, e, s), this.previousTouchCoords = [
1383
+ this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = [
1146
1384
  t.touches[0].clientX,
1147
1385
  t.touches[0].clientY
1148
1386
  ];
1149
1387
  });
1150
- n(this, "onCanvasTouchEnd", (t) => {
1388
+ h(this, "onCanvasTouchEnd", (t) => {
1151
1389
  t.touches.length > 0 ? this.previousTouchCoords = [
1152
1390
  t.touches[0].clientX,
1153
1391
  t.touches[0].clientY
1154
1392
  ] : (this.previousTouchCoords = null, this.grabbedNodeId = null);
1155
1393
  });
1156
- n(this, "previousTouchCoords", null);
1157
- var i, h;
1394
+ h(this, "previousTouchCoords", null);
1395
+ var n, i;
1158
1396
  this.canvas = t, this.transformation = this.canvas.transformation;
1159
1397
  const s = () => {
1160
1398
  };
1161
- this.onNodeDrag = ((i = e == null ? void 0 : e.events) == null ? void 0 : i.onNodeDrag) ?? s;
1399
+ this.onNodeDrag = ((n = r == null ? void 0 : r.events) == null ? void 0 : n.onNodeDrag) ?? s;
1162
1400
  const o = () => !0;
1163
- this.onBeforeNodeDrag = ((h = e == null ? void 0 : e.events) == null ? void 0 : h.onBeforeNodeDrag) ?? o;
1401
+ this.onBeforeNodeDrag = ((i = r == null ? void 0 : r.events) == null ? void 0 : i.onBeforeNodeDrag) ?? o;
1164
1402
  }
1165
1403
  addNode(t) {
1166
- let e = t.id;
1167
- if (e === void 0)
1404
+ let r = t.id;
1405
+ if (r === void 0)
1168
1406
  do
1169
- e = this.nodeIdGenerator.next();
1170
- while (this.nodes.has(e));
1407
+ r = this.nodeIdGenerator.create();
1408
+ while (this.nodes.has(r));
1171
1409
  this.canvas.addNode(t);
1172
- const s = (i) => {
1410
+ const s = (n) => {
1173
1411
  this.onBeforeNodeDrag({
1174
- nodeId: e,
1412
+ nodeId: r,
1175
1413
  element: t.element,
1176
1414
  x: t.x,
1177
1415
  y: t.y
1178
- }) && (i.stopImmediatePropagation(), this.grabbedNodeId = e, this.setCursor("grab"), this.canvas.moveNodeOnTop(e));
1179
- }, o = (i) => {
1416
+ }) && (n.stopImmediatePropagation(), this.grabbedNodeId = r, this.setCursor("grab"), this.canvas.moveNodeOnTop(r));
1417
+ }, o = (n) => {
1180
1418
  this.onBeforeNodeDrag({
1181
- nodeId: e,
1419
+ nodeId: r,
1182
1420
  element: t.element,
1183
1421
  x: t.x,
1184
1422
  y: t.y
1185
- }) && i.touches.length === 1 && (this.grabbedNodeId = e, this.canvas.moveNodeOnTop(e));
1423
+ }) && n.touches.length === 1 && (this.grabbedNodeId = r, this.canvas.moveNodeOnTop(r));
1186
1424
  };
1187
- return this.nodes.set(e, {
1425
+ return this.nodes.set(r, {
1188
1426
  element: t.element,
1189
1427
  onMouseDown: s,
1190
1428
  onTouchStart: o,
@@ -1192,15 +1430,18 @@ class ht {
1192
1430
  y: t.y
1193
1431
  }), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", o), this;
1194
1432
  }
1433
+ updateNode(t, r) {
1434
+ return this.canvas.updateNode(t, r), this;
1435
+ }
1195
1436
  removeNode(t) {
1196
- const e = this.nodes.get(t);
1197
- return e !== void 0 && (e.element.removeEventListener("mousedown", e.onMouseDown), e.element.removeEventListener("touchstart", e.onTouchStart)), this.canvas.removeNode(t), this.nodes.delete(t), this;
1437
+ const r = this.nodes.get(t);
1438
+ return r !== void 0 && (r.element.removeEventListener("mousedown", r.onMouseDown), r.element.removeEventListener("touchstart", r.onTouchStart)), this.canvas.removeNode(t), this.nodes.delete(t), this;
1198
1439
  }
1199
1440
  markPort(t) {
1200
1441
  return this.canvas.markPort(t), this;
1201
1442
  }
1202
- updatePortEdges(t) {
1203
- return this.canvas.updatePortEdges(t), this;
1443
+ updatePort(t, r) {
1444
+ return this.canvas.updatePort(t, r), this;
1204
1445
  }
1205
1446
  unmarkPort(t) {
1206
1447
  return this.canvas.unmarkPort(t), this;
@@ -1208,6 +1449,9 @@ class ht {
1208
1449
  addEdge(t) {
1209
1450
  return this.canvas.addEdge(t), this;
1210
1451
  }
1452
+ updateEdge(t, r) {
1453
+ return this.canvas.updateEdge(t, r), this;
1454
+ }
1211
1455
  removeEdge(t) {
1212
1456
  return this.canvas.removeEdge(t), this;
1213
1457
  }
@@ -1217,12 +1461,6 @@ class ht {
1217
1461
  moveToNodes(t) {
1218
1462
  return this.canvas.moveToNodes(t), this;
1219
1463
  }
1220
- updateNodeCoordinates(t, e, s) {
1221
- return this.canvas.updateNodeCoordinates(t, e, s), this;
1222
- }
1223
- updateEdge(t, e) {
1224
- return this.canvas.updateEdge(t, e), this;
1225
- }
1226
1464
  moveNodeOnTop(t) {
1227
1465
  return this.canvas.moveNodeOnTop(t), this;
1228
1466
  }
@@ -1245,12 +1483,12 @@ class ht {
1245
1483
  setCursor(t) {
1246
1484
  this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1247
1485
  }
1248
- dragNode(t, e, s) {
1486
+ dragNode(t, r, s) {
1249
1487
  const o = this.nodes.get(t);
1250
1488
  if (o === void 0)
1251
1489
  throw new Error("failed to drag nonexisting node");
1252
- const [i, h] = this.transformation.getViewCoords(o.x, o.y), a = i + e, c = h + s, [l, d] = this.transformation.getAbsCoords(a, c);
1253
- o.x = l, o.y = d, this.canvas.updateNodeCoordinates(t, l, d), this.onNodeDrag({
1490
+ const [n, i] = this.transformation.getViewCoords(o.x, o.y), a = n + r, c = i + s, [l, d] = this.transformation.getAbsCoords(a, c);
1491
+ o.x = l, o.y = d, this.canvas.updateNode(t, { x: l, y: d }), this.onNodeDrag({
1254
1492
  nodeId: t,
1255
1493
  element: o.element,
1256
1494
  x: o.x,
@@ -1258,80 +1496,83 @@ class ht {
1258
1496
  });
1259
1497
  }
1260
1498
  }
1261
- class at {
1262
- constructor(t, e) {
1263
- n(this, "transformation");
1264
- n(this, "element", null);
1265
- n(this, "isMoving", !1);
1266
- n(this, "prevTouches", null);
1267
- n(this, "onTransform");
1268
- n(this, "onBeforeTransform");
1269
- n(this, "isScalable");
1270
- n(this, "isShiftable");
1271
- n(this, "minViewScale");
1272
- n(this, "maxViewScale");
1273
- n(this, "wheelSensitivity");
1274
- n(this, "onMouseDown", () => {
1499
+ class Ct {
1500
+ constructor(t, r) {
1501
+ h(this, "transformation");
1502
+ h(this, "element", null);
1503
+ h(this, "isMoving", !1);
1504
+ h(this, "prevTouches", null);
1505
+ h(this, "onTransform");
1506
+ h(this, "onBeforeTransform");
1507
+ h(this, "isScalable");
1508
+ h(this, "isShiftable");
1509
+ h(this, "minViewScale");
1510
+ h(this, "maxViewScale");
1511
+ h(this, "wheelSensitivity");
1512
+ h(this, "onMouseDown", () => {
1275
1513
  this.setCursor("grab"), this.isMoving = !0;
1276
1514
  });
1277
- n(this, "onMouseMove", (t) => {
1515
+ h(this, "onMouseMove", (t) => {
1278
1516
  if (!this.isMoving || !this.isShiftable)
1279
1517
  return;
1280
- const e = -t.movementX, s = -t.movementY;
1281
- this.moveViewport(e, s);
1518
+ const r = -t.movementX, s = -t.movementY;
1519
+ this.moveViewport(r, s);
1282
1520
  });
1283
- n(this, "onMouseUp", () => {
1521
+ h(this, "onMouseUp", () => {
1284
1522
  this.setCursor(null), this.isMoving = !1;
1285
1523
  });
1286
- n(this, "onWheelScroll", (t) => {
1524
+ h(this, "onWheelScroll", (t) => {
1287
1525
  if (this.element === null || this.isScalable === !1)
1288
1526
  return;
1289
1527
  t.preventDefault();
1290
- const { left: e, top: s } = this.element.getBoundingClientRect(), o = t.clientX - e, i = t.clientY - s, a = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1291
- this.scaleViewport(a, o, i);
1528
+ const { left: r, top: s } = this.element.getBoundingClientRect(), o = t.clientX - r, n = t.clientY - s, a = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1529
+ this.scaleViewport(a, o, n);
1292
1530
  });
1293
- n(this, "onTouchStart", (t) => {
1531
+ h(this, "onTouchStart", (t) => {
1294
1532
  this.prevTouches = this.getAverageTouch(t);
1295
1533
  });
1296
- n(this, "onTouchMove", (t) => {
1534
+ h(this, "onTouchMove", (t) => {
1297
1535
  if (this.prevTouches === null || this.element === null || !this.isShiftable)
1298
1536
  return;
1299
- const e = this.getAverageTouch(t);
1300
- if ((e.touchesCnt === 1 || e.touchesCnt === 2) && this.moveViewport(
1301
- -(e.x - this.prevTouches.x),
1302
- -(e.y - this.prevTouches.y)
1303
- ), e.touchesCnt === 2 && this.isScalable) {
1304
- const { left: s, top: o } = this.element.getBoundingClientRect(), i = this.prevTouches.x - s, h = this.prevTouches.y - o, c = 1 / (e.scale / this.prevTouches.scale);
1305
- this.scaleViewport(c, i, h);
1537
+ const r = this.getAverageTouch(t);
1538
+ if ((r.touchesCnt === 1 || r.touchesCnt === 2) && this.moveViewport(
1539
+ -(r.x - this.prevTouches.x),
1540
+ -(r.y - this.prevTouches.y)
1541
+ ), r.touchesCnt === 2 && this.isScalable) {
1542
+ const { left: s, top: o } = this.element.getBoundingClientRect(), n = this.prevTouches.x - s, i = this.prevTouches.y - o, c = 1 / (r.scale / this.prevTouches.scale);
1543
+ this.scaleViewport(c, n, i);
1306
1544
  }
1307
- this.prevTouches = e, t.preventDefault();
1545
+ this.prevTouches = r, t.preventDefault();
1308
1546
  });
1309
- n(this, "onTouchEnd", (t) => {
1547
+ h(this, "onTouchEnd", (t) => {
1310
1548
  t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.prevTouches = null;
1311
1549
  });
1312
- var c, l, d, u, g, w, m, f, p, C, v, E;
1313
- this.canvas = t, this.options = e, this.transformation = this.canvas.transformation;
1314
- const s = ((l = (c = this.options) == null ? void 0 : c.scale) == null ? void 0 : l.min) ?? null, o = ((u = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : u.max) ?? null;
1315
- this.isScalable = ((w = (g = this.options) == null ? void 0 : g.scale) == null ? void 0 : w.enabled) !== !1, this.minViewScale = o !== null ? 1 / o : null, this.maxViewScale = s !== null ? 1 / s : null, this.isShiftable = ((f = (m = this.options) == null ? void 0 : m.shift) == null ? void 0 : f.enabled) !== !1;
1316
- const i = (C = (p = this.options) == null ? void 0 : p.scale) == null ? void 0 : C.wheelSensitivity;
1317
- this.wheelSensitivity = i !== void 0 ? i : 1.2;
1318
- const h = () => {
1550
+ var c, l, d, g, u, p, w, f, m, E, v, C;
1551
+ this.canvas = t, this.options = r, this.transformation = this.canvas.transformation;
1552
+ const s = ((l = (c = this.options) == null ? void 0 : c.scale) == null ? void 0 : l.min) ?? null, o = ((g = (d = this.options) == null ? void 0 : d.scale) == null ? void 0 : g.max) ?? null;
1553
+ this.isScalable = ((p = (u = this.options) == null ? void 0 : u.scale) == null ? void 0 : p.enabled) !== !1, this.minViewScale = o !== null ? 1 / o : null, this.maxViewScale = s !== null ? 1 / s : null, this.isShiftable = ((f = (w = this.options) == null ? void 0 : w.shift) == null ? void 0 : f.enabled) !== !1;
1554
+ const n = (E = (m = this.options) == null ? void 0 : m.scale) == null ? void 0 : E.wheelSensitivity;
1555
+ this.wheelSensitivity = n !== void 0 ? n : 1.2;
1556
+ const i = () => {
1319
1557
  };
1320
- this.onTransform = ((v = e == null ? void 0 : e.events) == null ? void 0 : v.onTransform) ?? h;
1558
+ this.onTransform = ((v = r == null ? void 0 : r.events) == null ? void 0 : v.onTransform) ?? i;
1321
1559
  const a = () => !0;
1322
- this.onBeforeTransform = ((E = e == null ? void 0 : e.events) == null ? void 0 : E.onBeforeTransform) ?? a;
1560
+ this.onBeforeTransform = ((C = r == null ? void 0 : r.events) == null ? void 0 : C.onBeforeTransform) ?? a;
1323
1561
  }
1324
1562
  addNode(t) {
1325
1563
  return this.canvas.addNode(t), this;
1326
1564
  }
1565
+ updateNode(t, r) {
1566
+ return this.canvas.updateNode(t, r), this;
1567
+ }
1327
1568
  removeNode(t) {
1328
1569
  return this.canvas.removeNode(t), this;
1329
1570
  }
1330
1571
  markPort(t) {
1331
1572
  return this.canvas.markPort(t), this;
1332
1573
  }
1333
- updatePortEdges(t) {
1334
- return this.canvas.updatePortEdges(t), this;
1574
+ updatePort(t, r) {
1575
+ return this.canvas.updatePort(t, r), this;
1335
1576
  }
1336
1577
  unmarkPort(t) {
1337
1578
  return this.canvas.unmarkPort(t), this;
@@ -1339,6 +1580,9 @@ class at {
1339
1580
  addEdge(t) {
1340
1581
  return this.canvas.addEdge(t), this;
1341
1582
  }
1583
+ updateEdge(t, r) {
1584
+ return this.canvas.updateEdge(t, r), this;
1585
+ }
1342
1586
  removeEdge(t) {
1343
1587
  return this.canvas.removeEdge(t), this;
1344
1588
  }
@@ -1348,12 +1592,6 @@ class at {
1348
1592
  moveToNodes(t) {
1349
1593
  return this.canvas.moveToNodes(t), this;
1350
1594
  }
1351
- updateNodeCoordinates(t, e, s) {
1352
- return this.canvas.updateNodeCoordinates(t, e, s), this;
1353
- }
1354
- updateEdge(t, e) {
1355
- return this.canvas.updateEdge(t, e), this;
1356
- }
1357
1595
  moveNodeOnTop(t) {
1358
1596
  return this.canvas.moveNodeOnTop(t), this;
1359
1597
  }
@@ -1370,44 +1608,44 @@ class at {
1370
1608
  this.detach(), this.canvas.destroy();
1371
1609
  }
1372
1610
  getAverageTouch(t) {
1373
- const e = [], s = t.touches.length;
1611
+ const r = [], s = t.touches.length;
1374
1612
  for (let c = 0; c < s; c++)
1375
- e.push([t.touches[c].clientX, t.touches[c].clientY]);
1376
- const o = e.reduce(
1613
+ r.push([t.touches[c].clientX, t.touches[c].clientY]);
1614
+ const o = r.reduce(
1377
1615
  (c, l) => [c[0] + l[0], c[1] + l[1]],
1378
1616
  [0, 0]
1379
- ), i = [o[0] / s, o[1] / s], a = e.map((c) => [c[0] - i[0], c[1] - i[1]]).reduce(
1617
+ ), n = [o[0] / s, o[1] / s], a = r.map((c) => [c[0] - n[0], c[1] - n[1]]).reduce(
1380
1618
  (c, l) => c + Math.sqrt(l[0] * l[0] + l[1] * l[1]),
1381
1619
  0
1382
1620
  );
1383
- return { x: i[0], y: i[1], scale: a / s, touchesCnt: s };
1621
+ return { x: n[0], y: n[1], scale: a / s, touchesCnt: s };
1384
1622
  }
1385
1623
  setCursor(t) {
1386
1624
  this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1387
1625
  }
1388
- moveViewport(t, e) {
1389
- const [s, o] = this.transformation.getAbsCoords(0, 0), i = this.canvas.transformation.getAbsScale(), h = {
1390
- scale: i,
1391
- x: s + i * t,
1392
- y: o + i * e
1626
+ moveViewport(t, r) {
1627
+ const [s, o] = this.transformation.getAbsCoords(0, 0), n = this.canvas.transformation.getAbsScale(), i = {
1628
+ scale: n,
1629
+ x: s + n * t,
1630
+ y: o + n * r
1393
1631
  };
1394
- this.onBeforeTransform({ ...h }) && (this.canvas.patchViewportState(h), this.onTransform(h));
1632
+ this.onBeforeTransform({ ...i }) && (this.canvas.patchViewportState(i), this.onTransform(i));
1395
1633
  }
1396
- scaleViewport(t, e, s) {
1397
- const [o, i] = this.canvas.transformation.getAbsCoords(0, 0), h = this.canvas.transformation.getAbsScale(), a = h * t, c = h * (1 - t) * e + o, l = h * (1 - t) * s + i;
1398
- if (this.maxViewScale !== null && a > this.maxViewScale && a > h || this.minViewScale !== null && a < this.minViewScale && a < h)
1634
+ scaleViewport(t, r, s) {
1635
+ const [o, n] = this.canvas.transformation.getAbsCoords(0, 0), i = this.canvas.transformation.getAbsScale(), a = i * t, c = i * (1 - t) * r + o, l = i * (1 - t) * s + n;
1636
+ if (this.maxViewScale !== null && a > this.maxViewScale && a > i || this.minViewScale !== null && a < this.minViewScale && a < i)
1399
1637
  return;
1400
1638
  const d = { scale: a, x: c, y: l };
1401
1639
  this.onBeforeTransform({ ...d }) && (this.canvas.patchViewportState(d), this.onTransform(d));
1402
1640
  }
1403
1641
  }
1404
- class lt {
1642
+ class At {
1405
1643
  constructor() {
1406
- n(this, "coreOptions");
1407
- n(this, "dragOptions");
1408
- n(this, "transformOptions");
1409
- n(this, "isDraggable", !1);
1410
- n(this, "isTransformable", !1);
1644
+ h(this, "coreOptions");
1645
+ h(this, "dragOptions");
1646
+ h(this, "transformOptions");
1647
+ h(this, "isDraggable", !1);
1648
+ h(this, "isTransformable", !1);
1411
1649
  }
1412
1650
  setOptions(t) {
1413
1651
  return this.coreOptions = t, this;
@@ -1419,21 +1657,25 @@ class lt {
1419
1657
  return this.isTransformable = !0, this.transformOptions = t, this;
1420
1658
  }
1421
1659
  build() {
1422
- let t = new it(this.coreOptions);
1423
- return this.isDraggable && (t = new ht(t, this.dragOptions)), this.isTransformable && (t = new at(t, this.transformOptions)), t;
1660
+ let t = new ft(this.coreOptions);
1661
+ return this.isDraggable && (t = new Et(t, this.dragOptions)), this.isTransformable && (t = new Ct(t, this.transformOptions)), t;
1424
1662
  }
1425
1663
  }
1426
1664
  export {
1427
- z as BezierEdgeController,
1428
- it as CanvasCore,
1429
- Z as CycleCircleEdgeController,
1430
- U as CycleSquareEdgeController,
1431
- H as DetourStraightEdgeController,
1432
- T as EdgeType,
1433
- lt as HtmlGraphBuilder,
1434
- G as StraightEdgeController,
1435
- ht as UserDraggableNodesCanvas,
1436
- at as UserTransformableCanvas,
1437
- _ as createBezierEdgeControllerFactory,
1438
- J as createStraightEdgeControllerFactory
1665
+ q as BezierEdgeController,
1666
+ ft as CanvasCore,
1667
+ rt as CycleCircleEdgeController,
1668
+ W as CycleSquareEdgeController,
1669
+ k as DetourStraightEdgeController,
1670
+ $ as EdgeType,
1671
+ tt as HorizontalEdgeController,
1672
+ At as HtmlGraphBuilder,
1673
+ I as StraightEdgeController,
1674
+ Et as UserDraggableNodesCanvas,
1675
+ Ct as UserTransformableCanvas,
1676
+ et as VerticalEdgeController,
1677
+ ot as createBezierEdgeControllerFactory,
1678
+ nt as createHorizontalEdgeControllerFactory,
1679
+ it as createStraightEdgeControllerFactory,
1680
+ ht as createVerticalEdgeControllerFactory
1439
1681
  };