@html-graph/html-graph 0.0.49 → 0.0.50

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,12 +1,12 @@
1
- var D = Object.defineProperty;
2
- var F = (o, t, e) => t in o ? D(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var n = (o, t, e) => F(o, typeof t != "symbol" ? t + "" : t, e);
4
- class k {
5
- constructor(t, e, s, r, a) {
1
+ var j = Object.defineProperty;
2
+ var R = (r, t, e) => t in r ? j(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var n = (r, t, e) => R(r, typeof t != "symbol" ? t + "" : t, e);
4
+ class W {
5
+ constructor(t, e, s, o, a) {
6
6
  n(this, "canvasWrapper", null);
7
7
  n(this, "host");
8
8
  n(this, "nodesContainer");
9
- n(this, "connectionsContainer");
9
+ n(this, "edgesContainer");
10
10
  n(this, "canvas");
11
11
  n(this, "canvasCtx");
12
12
  n(this, "hostResizeObserver");
@@ -14,15 +14,15 @@ class k {
14
14
  n(this, "nodeElementToIdMap", /* @__PURE__ */ new Map());
15
15
  n(this, "nodeWrapperElementToIdMap", /* @__PURE__ */ new Map());
16
16
  n(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
17
- n(this, "connectionIdToElementMap", /* @__PURE__ */ new Map());
17
+ n(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
18
18
  n(this, "currentZIndex", 0);
19
19
  n(this, "layers", {
20
20
  "edges-on-top": {
21
21
  create: () => {
22
- this.host.appendChild(this.nodesContainer), this.host.appendChild(this.connectionsContainer);
22
+ this.host.appendChild(this.nodesContainer), this.host.appendChild(this.edgesContainer);
23
23
  },
24
24
  update: (t, e, s) => {
25
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.connectionsContainer.style.transform = `matrix(${t}, 0, 0, ${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
26
  },
27
27
  moveOnTop: (t) => {
28
28
  this.currentZIndex += 1;
@@ -32,24 +32,24 @@ class k {
32
32
  },
33
33
  "edges-follow-node": {
34
34
  create: () => {
35
- this.host.appendChild(this.nodesContainer), this.connectionsContainer = this.nodesContainer;
35
+ this.host.appendChild(this.nodesContainer), this.edgesContainer = this.nodesContainer;
36
36
  },
37
37
  update: (t, e, s) => {
38
38
  this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`;
39
39
  },
40
40
  moveOnTop: (t) => {
41
41
  const e = this.nodeIdToWrapperElementMap.get(t);
42
- this.currentZIndex += 2, e.style.zIndex = `${this.currentZIndex}`, this.graphStore.getNodeAdjacentConnections(t).forEach((r) => {
43
- this.connectionIdToElementMap.get(r).style.zIndex = `${this.currentZIndex - 1}`;
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
44
  });
45
45
  }
46
46
  },
47
47
  "nodes-on-top": {
48
48
  create: () => {
49
- this.host.appendChild(this.connectionsContainer), this.host.appendChild(this.nodesContainer);
49
+ this.host.appendChild(this.edgesContainer), this.host.appendChild(this.nodesContainer);
50
50
  },
51
51
  update: (t, e, s) => {
52
- this.nodesContainer.style.transform = `matrix(${t}, 0, 0, ${t}, ${e}, ${s})`, this.connectionsContainer.style.transform = `matrix(${t}, 0, 0, ${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
53
  },
54
54
  moveOnTop: (t) => {
55
55
  this.currentZIndex += 1;
@@ -58,15 +58,15 @@ class k {
58
58
  }
59
59
  }
60
60
  });
61
- this.graphStore = t, this.viewportTransformer = e, this.publicViewportTransformer = s, this.layersMode = r, this.backgroundDrawingFn = a, this.host = this.createHost(), this.canvas = this.createCanvas(), this.nodesContainer = this.createNodesContainer(), this.connectionsContainer = this.createConnectionsContainer();
61
+ this.graphStore = t, this.viewportTransformer = e, this.publicViewportTransformer = s, this.layersMode = o, this.backgroundDrawingFn = a, this.host = this.createHost(), this.canvas = this.createCanvas(), this.nodesContainer = this.createNodesContainer(), this.edgesContainer = this.createEdgesContainer();
62
62
  const c = this.canvas.getContext("2d");
63
63
  if (c === null)
64
64
  throw new Error("unable to get canvas context");
65
65
  this.canvasCtx = c, this.host.appendChild(this.canvas), this.layers[this.layersMode].create(), this.hostResizeObserver = this.createHostResizeObserver(), this.hostResizeObserver.observe(this.host), this.nodesResizeObserver = this.createNodesResizeObserver();
66
66
  }
67
67
  clear() {
68
- Array.from(this.connectionIdToElementMap.keys()).forEach((t) => {
69
- this.detachConnection(t);
68
+ Array.from(this.edgeIdToElementMap.keys()).forEach((t) => {
69
+ this.detachEdge(t);
70
70
  }), Array.from(this.nodeElementToIdMap.values()).forEach((t) => {
71
71
  this.detachNode(t);
72
72
  });
@@ -78,7 +78,7 @@ class k {
78
78
  this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
79
79
  }
80
80
  destroy() {
81
- this.hostResizeObserver.disconnect(), this.nodesResizeObserver.disconnect(), this.host.removeChild(this.canvas), this.host.removeChild(this.connectionsContainer), this.host.removeChild(this.nodesContainer), this.canvasWrapper !== null && (this.canvasWrapper.removeChild(this.host), this.canvasWrapper = null);
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);
82
82
  }
83
83
  applyTransform() {
84
84
  this.backgroundDrawingFn(this.canvasCtx, this.publicViewportTransformer);
@@ -95,26 +95,26 @@ class k {
95
95
  const s = this.nodeIdToWrapperElementMap.get(t);
96
96
  s.removeChild(e.element), this.nodeElementToIdMap.delete(e.element), this.nodeWrapperElementToIdMap.delete(s), this.nodeIdToWrapperElementMap.delete(t);
97
97
  }
98
- attachConnection(t) {
99
- const s = this.graphStore.getConnection(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.connectionIdToElementMap.set(t, s), this.updateConnectionCoords(t), this.connectionsContainer.appendChild(s);
98
+ attachEdge(t) {
99
+ 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);
101
101
  }
102
- detachConnection(t) {
103
- const e = this.connectionIdToElementMap.get(t);
104
- this.connectionIdToElementMap.delete(t), this.connectionsContainer.removeChild(e);
102
+ detachEdge(t) {
103
+ const e = this.edgeIdToElementMap.get(t);
104
+ this.edgeIdToElementMap.delete(t), this.edgesContainer.removeChild(e);
105
105
  }
106
106
  moveNodeOnTop(t) {
107
107
  this.layers[this.layersMode].moveOnTop(t);
108
108
  }
109
109
  updateNodeCoordinates(t) {
110
- const e = this.graphStore.getNode(t), s = this.graphStore.getNodeAdjacentConnections(t);
111
- this.updateNodeCoords(t, e.x, e.y), s.forEach((r) => {
112
- this.updateConnectionCoords(r);
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);
113
113
  });
114
114
  }
115
- updatePortConnections(t) {
116
- this.graphStore.getPortAdjacentConnections(t).forEach((s) => {
117
- this.updateConnectionCoords(s);
115
+ updatePortEdges(t) {
116
+ this.graphStore.getPortAdjacentEdges(t).forEach((s) => {
117
+ this.updateEdgeCoords(s);
118
118
  });
119
119
  }
120
120
  getViewportDimensions() {
@@ -133,7 +133,7 @@ class k {
133
133
  const t = document.createElement("div");
134
134
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
135
135
  }
136
- createConnectionsContainer() {
136
+ createEdgesContainer() {
137
137
  const t = document.createElement("div");
138
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
139
  }
@@ -145,9 +145,9 @@ class k {
145
145
  createNodesResizeObserver() {
146
146
  return new ResizeObserver((t) => {
147
147
  t.forEach((e) => {
148
- const s = e.target, r = this.nodeWrapperElementToIdMap.get(s), a = this.graphStore.getNode(r);
149
- this.updateNodeCoords(r, a.x, a.y), this.graphStore.getNodeAdjacentConnections(r).forEach((h) => {
150
- this.updateConnectionCoords(h);
148
+ const s = e.target, o = this.nodeWrapperElementToIdMap.get(s), a = this.graphStore.getNode(o);
149
+ this.updateNodeCoords(o, a.x, a.y), this.graphStore.getNodeAdjacentEdges(o).forEach((h) => {
150
+ this.updateEdgeCoords(h);
151
151
  });
152
152
  });
153
153
  });
@@ -157,27 +157,27 @@ class k {
157
157
  this.canvas.width = t, this.canvas.height = e;
158
158
  }
159
159
  updateNodeCoords(t, e, s) {
160
- const r = this.nodeIdToWrapperElementMap.get(t), { width: a, height: c } = r.getBoundingClientRect(), h = this.viewportTransformer.getAbsScale(), i = this.graphStore.getNode(t), [d, g] = i.centerFn(a, c);
161
- r.style.transform = `matrix(1, 0, 0, 1, ${e - h * d}, ${s - h * g})`;
160
+ const o = this.nodeIdToWrapperElementMap.get(t), { width: a, height: c } = o.getBoundingClientRect(), h = this.viewportTransformer.getAbsScale(), i = this.graphStore.getNode(t), [d, g] = i.centerFn(a, c);
161
+ o.style.transform = `matrix(1, 0, 0, 1, ${e - h * d}, ${s - h * g})`;
162
162
  }
163
- updateConnectionCoords(t) {
164
- const e = this.graphStore.getConnection(t), s = this.graphStore.getPort(e.from), r = this.graphStore.getPort(e.to), a = s.element.getBoundingClientRect(), c = r.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), [i, d] = this.viewportTransformer.getAbsCoords(
163
+ updateEdgeCoords(t) {
164
+ const e = this.graphStore.getEdge(t), s = this.graphStore.getPort(e.from), o = this.graphStore.getPort(e.to), a = s.element.getBoundingClientRect(), c = o.element.getBoundingClientRect(), h = this.host.getBoundingClientRect(), [i, d] = this.viewportTransformer.getAbsCoords(
165
165
  a.left - h.left,
166
166
  a.top - h.top
167
167
  ), [g, l] = this.viewportTransformer.getAbsCoords(
168
168
  c.left - h.left,
169
169
  c.top - h.top
170
- ), u = this.viewportTransformer.getAbsScale(), [w, m] = s.centerFn(
170
+ ), u = this.viewportTransformer.getAbsScale(), [v, m] = s.centerFn(
171
171
  a.width * u,
172
172
  a.height * u
173
- ), [p, C] = r.centerFn(
173
+ ), [w, f] = o.centerFn(
174
174
  c.width * u,
175
175
  c.height * u
176
- ), f = w + i, y = m + d, b = p + g, E = C + l, $ = Math.min(f, b), N = Math.min(y, E), A = Math.abs(b - f), P = Math.abs(E - y);
177
- e.controller.update($, N, A, P, s, r);
176
+ ), C = v + i, E = m + d, b = w + g, $ = f + l, y = Math.min(C, b), T = Math.min(E, $), S = Math.abs(b - C), N = Math.abs($ - E);
177
+ e.controller.update(y, T, S, N, s, o);
178
178
  }
179
179
  }
180
- class W {
180
+ class B {
181
181
  constructor() {
182
182
  n(this, "state", {
183
183
  scale: 1,
@@ -211,7 +211,7 @@ class W {
211
211
  };
212
212
  }
213
213
  }
214
- class j {
214
+ class z {
215
215
  constructor(t) {
216
216
  this.transformer = t;
217
217
  }
@@ -244,22 +244,19 @@ class j {
244
244
  return this.transformer.getAbsScale();
245
245
  }
246
246
  }
247
- class R {
247
+ class Y {
248
248
  constructor() {
249
249
  n(this, "nodes", /* @__PURE__ */ Object.create(null));
250
250
  n(this, "ports", /* @__PURE__ */ Object.create(null));
251
251
  n(this, "nodePorts", /* @__PURE__ */ Object.create(null));
252
252
  n(this, "portNodeId", /* @__PURE__ */ Object.create(null));
253
- n(this, "connections", /* @__PURE__ */ Object.create(null));
254
- n(this, "incommingConnections", /* @__PURE__ */ Object.create(null));
255
- n(this, "outcommingConnections", /* @__PURE__ */ Object.create(null));
256
- n(this, "cycleConnections", /* @__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
257
  }
258
- getAllNodes() {
259
- return this.nodes;
260
- }
261
- addNode(t, e, s, r, a) {
262
- this.nodes[t] = { element: e, x: s, y: r, centerFn: a }, this.nodePorts[t] = /* @__PURE__ */ Object.create(null);
258
+ addNode(t, e, s, o, a) {
259
+ this.nodes[t] = { element: e, x: s, y: o, centerFn: a }, this.nodePorts[t] = /* @__PURE__ */ Object.create(null);
263
260
  }
264
261
  hasNode(t) {
265
262
  return this.nodes[t] !== void 0;
@@ -270,20 +267,20 @@ class R {
270
267
  updateNodeCoords(t, e, s) {
271
268
  this.nodes[t].x = e, this.nodes[t].y = s;
272
269
  }
273
- updateConnectionController(t, e) {
274
- this.connections[t].controller = e;
270
+ updateEdgeController(t, e) {
271
+ this.edges[t].controller = e;
275
272
  }
276
273
  removeNode(t) {
277
- this.getNodeAdjacentConnections(t).forEach((r) => {
278
- this.removeConnection(r);
274
+ this.getNodeAdjacentEdges(t).forEach((o) => {
275
+ this.removeEdge(o);
279
276
  }), delete this.nodes[t];
280
277
  const s = this.nodePorts[t];
281
- Object.keys(s).forEach((r) => {
282
- delete this.portNodeId[r];
278
+ Object.keys(s).forEach((o) => {
279
+ delete this.portNodeId[o];
283
280
  }), delete this.nodePorts[t];
284
281
  }
285
- addPort(t, e, s, r, a) {
286
- this.ports[t] = { element: e, centerFn: r, direction: a }, this.cycleConnections[t] = {}, this.incommingConnections[t] = {}, this.outcommingConnections[t] = {}, this.portNodeId[t] = s;
282
+ addPort(t, e, s, o, a) {
283
+ this.ports[t] = { element: e, centerFn: o, direction: a }, this.cycleEdges[t] = {}, this.incommingEdges[t] = {}, this.outcommingEdges[t] = {}, this.portNodeId[t] = s;
287
284
  const c = this.nodePorts[s];
288
285
  c !== void 0 && (c[t] = e);
289
286
  }
@@ -297,86 +294,86 @@ class R {
297
294
  return this.portNodeId[t] !== void 0;
298
295
  }
299
296
  removePort(t) {
300
- Object.keys(this.cycleConnections[t]).forEach((r) => {
301
- this.removeConnection(r);
302
- }), delete this.cycleConnections[t], Object.keys(this.incommingConnections[t]).forEach((r) => {
303
- this.removeConnection(r);
304
- }), delete this.incommingConnections[t], Object.keys(this.outcommingConnections[t]).forEach((r) => {
305
- this.removeConnection(r);
306
- }), delete this.outcommingConnections[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];
307
304
  const e = this.portNodeId[t];
308
305
  delete this.portNodeId[t];
309
306
  const s = this.nodePorts[e];
310
307
  delete s[t], delete this.ports[t];
311
308
  }
312
- addConnection(t, e, s, r) {
313
- this.connections[t] = {
309
+ addEdge(t, e, s, o) {
310
+ this.edges[t] = {
314
311
  from: e,
315
312
  to: s,
316
- controller: r
317
- }, e !== s ? (this.outcommingConnections[e][t] = !0, this.incommingConnections[s][t] = !0) : this.cycleConnections[e][t] = !0;
313
+ controller: o
314
+ }, e !== s ? (this.outcommingEdges[e][t] = !0, this.incommingEdges[s][t] = !0) : this.cycleEdges[e][t] = !0;
318
315
  }
319
- getConnection(t) {
320
- return this.connections[t];
316
+ getEdge(t) {
317
+ return this.edges[t];
321
318
  }
322
- hasConnection(t) {
323
- return this.connections[t] !== void 0;
319
+ hasEdge(t) {
320
+ return this.edges[t] !== void 0;
324
321
  }
325
- removeConnection(t) {
326
- const e = this.connections[t], s = e.from, r = e.to;
327
- delete this.cycleConnections[s][t], delete this.cycleConnections[r][t], delete this.incommingConnections[s][t], delete this.incommingConnections[r][t], delete this.outcommingConnections[s][t], delete this.outcommingConnections[r][t], delete this.connections[t];
322
+ 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];
328
325
  }
329
- getPortAdjacentConnections(t) {
326
+ getPortAdjacentEdges(t) {
330
327
  return [
331
- ...this.getPortIncomingConnections(t),
332
- ...this.getPortOutcomingConnections(t),
333
- ...this.getPortCycleConnections(t)
328
+ ...this.getPortIncomingEdges(t),
329
+ ...this.getPortOutcomingEdges(t),
330
+ ...this.getPortCycleEdges(t)
334
331
  ];
335
332
  }
336
- getNodeAdjacentConnections(t) {
333
+ getNodeAdjacentEdges(t) {
337
334
  return [
338
- ...this.getNodeIncomingConnections(t),
339
- ...this.getNodeOutcomingConnections(t),
340
- ...this.getNodeCycleConnections(t)
335
+ ...this.getNodeIncomingEdges(t),
336
+ ...this.getNodeOutcomingEdges(t),
337
+ ...this.getNodeCycleEdges(t)
341
338
  ];
342
339
  }
343
340
  clear() {
344
- 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.connections = /* @__PURE__ */ Object.create(null), this.incommingConnections = /* @__PURE__ */ Object.create(null), this.outcommingConnections = /* @__PURE__ */ Object.create(null), this.cycleConnections = /* @__PURE__ */ Object.create(null);
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);
345
342
  }
346
- getPortIncomingConnections(t) {
347
- return Object.keys(this.incommingConnections[t] ?? {});
343
+ getPortIncomingEdges(t) {
344
+ return Object.keys(this.incommingEdges[t] ?? {});
348
345
  }
349
- getPortOutcomingConnections(t) {
350
- return Object.keys(this.outcommingConnections[t] ?? {});
346
+ getPortOutcomingEdges(t) {
347
+ return Object.keys(this.outcommingEdges[t] ?? {});
351
348
  }
352
- getPortCycleConnections(t) {
353
- return Object.keys(this.cycleConnections[t] ?? {});
349
+ getPortCycleEdges(t) {
350
+ return Object.keys(this.cycleEdges[t] ?? {});
354
351
  }
355
- getNodeIncomingConnections(t) {
352
+ getNodeIncomingEdges(t) {
356
353
  const e = Object.keys(this.nodePorts[t]);
357
354
  let s = [];
358
- return e.forEach((r) => {
359
- s = [...s, ...this.getPortIncomingConnections(r)];
355
+ return e.forEach((o) => {
356
+ s = [...s, ...this.getPortIncomingEdges(o)];
360
357
  }), s;
361
358
  }
362
- getNodeOutcomingConnections(t) {
359
+ getNodeOutcomingEdges(t) {
363
360
  const e = Object.keys(this.nodePorts[t]);
364
361
  let s = [];
365
- return e.forEach((r) => {
366
- s = [...s, ...this.getPortOutcomingConnections(r)];
362
+ return e.forEach((o) => {
363
+ s = [...s, ...this.getPortOutcomingEdges(o)];
367
364
  }), s;
368
365
  }
369
- getNodeCycleConnections(t) {
366
+ getNodeCycleEdges(t) {
370
367
  const e = Object.keys(this.nodePorts[t]);
371
368
  let s = [];
372
- return e.forEach((r) => {
373
- s = [...s, ...this.getPortCycleConnections(r)];
369
+ return e.forEach((o) => {
370
+ s = [...s, ...this.getPortCycleEdges(o)];
374
371
  }), s;
375
372
  }
376
373
  }
377
- class v {
374
+ class p {
378
375
  static getPortCenter(t) {
379
- const { top: e, left: s, width: r, height: a } = t.element.getBoundingClientRect(), c = t.centerFn(r, a);
376
+ const { top: e, left: s, width: o, height: a } = t.element.getBoundingClientRect(), c = t.centerFn(o, a);
380
377
  return [s + c[0], e + c[1]];
381
378
  }
382
379
  static rotate(t, e, s) {
@@ -388,18 +385,18 @@ class v {
388
385
  static getDirectionVector(t, e, s) {
389
386
  return [e * Math.cos(t ?? 0), s * Math.sin(t ?? 0)];
390
387
  }
391
- static getArrowPath(t, e, s, r, a) {
388
+ static getArrowPath(t, e, s, o, a) {
392
389
  const h = [
393
390
  [0, 0],
394
- [r, a],
395
- [r, -a]
391
+ [o, a],
392
+ [o, -a]
396
393
  ].map((l) => this.rotate(l, t, [0, 0])).map((l) => [l[0] + e, l[1] + s]), i = `M ${h[0][0]} ${h[0][1]}`, d = `L ${h[1][0]} ${h[1][1]}`, g = `L ${h[2][0]} ${h[2][1]}`;
397
394
  return `${i} ${d} ${g}`;
398
395
  }
399
- static getArrowOffsetPath(t, e, s, r, a) {
396
+ static getArrowOffsetPath(t, e, s, o, a) {
400
397
  const h = [
401
- [r, 0],
402
- [r + a, 0]
398
+ [o, 0],
399
+ [o + a, 0]
403
400
  ].map((i) => this.rotate(i, t, [0, 0])).map((i) => [i[0] + e, i[1] + s]);
404
401
  return `M ${h[0][0]} ${h[0][1]} L ${h[1][0]} ${h[1][1]}`;
405
402
  }
@@ -407,14 +404,14 @@ class v {
407
404
  return t.map((e, s) => `${s === 0 ? "M" : "L"} ${e[0]} ${e[1]}`).join(" ");
408
405
  }
409
406
  }
410
- class B {
411
- constructor(t, e, s, r, a, c, h) {
407
+ class G {
408
+ constructor(t, e, s, o, a, c, h) {
412
409
  n(this, "svg");
413
410
  n(this, "group");
414
411
  n(this, "line");
415
412
  n(this, "sourceArrow", null);
416
413
  n(this, "targetArrow", null);
417
- this.color = t, this.width = e, this.curvature = s, this.arrowLength = r, this.arrowWidth = 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%", c && (this.sourceArrow = document.createElementNS(
414
+ this.color = t, this.width = e, this.curvature = s, this.arrowLength = o, this.arrowWidth = 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%", c && (this.sourceArrow = document.createElementNS(
418
415
  "http://www.w3.org/2000/svg",
419
416
  "path"
420
417
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = document.createElementNS(
@@ -422,51 +419,51 @@ class B {
422
419
  "path"
423
420
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
424
421
  }
425
- update(t, e, s, r, a, c) {
426
- this.svg.style.width = `${s}px`, this.svg.style.height = `${r}px`;
427
- const h = v.getPortCenter(a), i = v.getPortCenter(c), d = h[0] <= i[0] ? 1 : -1, g = h[1] <= i[1] ? 1 : -1;
422
+ update(t, e, s, o, a, c) {
423
+ this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
424
+ const h = p.getPortCenter(a), i = p.getPortCenter(c), d = h[0] <= i[0] ? 1 : -1, g = h[1] <= i[1] ? 1 : -1;
428
425
  this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${d}, ${g})`;
429
- const l = v.getDirectionVector(a.direction, d, g), u = v.getDirectionVector(c.direction, d, g), w = v.rotate([this.arrowLength, 0], l, [0, 0]), m = v.rotate([s - this.arrowLength, r], u, [
426
+ const l = p.getDirectionVector(a.direction, d, g), u = p.getDirectionVector(c.direction, d, g), v = p.rotate([this.arrowLength, 0], l, [0, 0]), m = p.rotate([s - this.arrowLength, o], u, [
430
427
  s,
431
- r
432
- ]), p = [
433
- w[0] + l[0] * this.curvature,
434
- w[1] + l[1] * this.curvature
435
- ], C = [
428
+ o
429
+ ]), w = [
430
+ v[0] + l[0] * this.curvature,
431
+ v[1] + l[1] * this.curvature
432
+ ], f = [
436
433
  m[0] - u[0] * this.curvature,
437
434
  m[1] - u[1] * this.curvature
438
- ], f = `M ${w[0]} ${w[1]} C ${p[0]} ${p[1]}, ${C[0]} ${C[1]}, ${m[0]} ${m[1]}`, y = this.sourceArrow ? "" : `M 0 0 L ${w[0]} ${w[1]} `, b = this.targetArrow ? "" : ` M ${m[0]} ${m[1]} L ${s} ${r}`, E = `${y}${f}${b}`;
439
- if (this.line.setAttribute("d", E), this.sourceArrow) {
440
- const $ = v.getArrowPath(
435
+ ], C = `M ${v[0]} ${v[1]} C ${w[0]} ${w[1]}, ${f[0]} ${f[1]}, ${m[0]} ${m[1]}`, E = this.sourceArrow ? "" : `M 0 0 L ${v[0]} ${v[1]} `, b = this.targetArrow ? "" : ` M ${m[0]} ${m[1]} L ${s} ${o}`, $ = `${E}${C}${b}`;
436
+ if (this.line.setAttribute("d", $), this.sourceArrow) {
437
+ const y = p.getArrowPath(
441
438
  l,
442
439
  0,
443
440
  0,
444
441
  this.arrowLength,
445
442
  this.arrowWidth
446
443
  );
447
- this.sourceArrow.setAttribute("d", $);
444
+ this.sourceArrow.setAttribute("d", y);
448
445
  }
449
446
  if (this.targetArrow) {
450
- const $ = v.getArrowPath(
447
+ const y = p.getArrowPath(
451
448
  u,
452
449
  s,
453
- r,
450
+ o,
454
451
  -this.arrowLength,
455
452
  this.arrowWidth
456
453
  );
457
- this.targetArrow.setAttribute("d", $);
454
+ this.targetArrow.setAttribute("d", y);
458
455
  }
459
456
  }
460
457
  }
461
- class z {
462
- constructor(t, e, s, r, a, c, h, i) {
458
+ class X {
459
+ constructor(t, e, s, o, a, c, h, i) {
463
460
  n(this, "svg");
464
461
  n(this, "group");
465
462
  n(this, "line");
466
463
  n(this, "sourceArrow", null);
467
464
  n(this, "targetArrow", null);
468
465
  n(this, "roundness");
469
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.minPortOffset = a, this.roundness = Math.min(this.minPortOffset, 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%", c && (this.sourceArrow = document.createElementNS(
466
+ this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = a, this.roundness = Math.min(this.arrowOffset, 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%", c && (this.sourceArrow = document.createElementNS(
470
467
  "http://www.w3.org/2000/svg",
471
468
  "path"
472
469
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), h && (this.targetArrow = document.createElementNS(
@@ -474,123 +471,115 @@ class z {
474
471
  "path"
475
472
  ), this.targetArrow.setAttribute("fill", this.color), this.group.appendChild(this.targetArrow)), this.svg.style.overflow = "visible";
476
473
  }
477
- update(t, e, s, r, a, c) {
478
- this.svg.style.width = `${s}px`, this.svg.style.height = `${r}px`;
479
- const h = v.getPortCenter(a), i = v.getPortCenter(c), d = h[0] <= i[0] ? 1 : -1, g = h[1] <= i[1] ? 1 : -1;
474
+ update(t, e, s, o, a, c) {
475
+ this.svg.style.width = `${s}px`, this.svg.style.height = `${o}px`;
476
+ const h = p.getPortCenter(a), i = p.getPortCenter(c), d = h[0] <= i[0] ? 1 : -1, g = h[1] <= i[1] ? 1 : -1;
480
477
  this.svg.style.transform = `translate(${t}px, ${e}px)`, this.group.style.transform = `scale(${d}, ${g})`;
481
- const l = v.getDirectionVector(a.direction, d, g), u = v.getDirectionVector(c.direction, d, g);
482
- console.log(this.roundness);
483
- const w = this.arrowLength + this.minPortOffset, m = v.rotate([w, 0], l, [0, 0]), p = v.rotate([s - w, r], u, [s, r]), [C, f] = [s / 2, r / 2], b = d * (p[0] - m[0]) > 0 ? v.createStraightPath([
484
- [m[0], m[1]],
485
- [C, m[1]],
486
- [C, p[1]],
487
- [p[0], p[1]]
488
- ]) : v.createStraightPath([
489
- [m[0], m[1]],
490
- [m[0], f],
491
- [p[0], f],
492
- [p[0], p[1]]
493
- ]), E = v.getArrowOffsetPath(
494
- l,
495
- 0,
496
- 0,
497
- this.arrowLength,
498
- this.minPortOffset
499
- ), $ = v.getArrowOffsetPath(
500
- u,
478
+ const l = p.getDirectionVector(a.direction, d, g), u = p.getDirectionVector(c.direction, d, g), v = this.sourceArrow ? p.rotate([this.arrowLength, 0], l, [0, 0]) : [0, 0], m = this.targetArrow ? p.rotate([s - this.arrowLength, o], u, [
479
+ s,
480
+ o
481
+ ]) : [s, o], w = this.arrowLength + this.arrowOffset, f = w - this.roundness, C = s - w * 2 * d, E = Math.sqrt(C * C + o * o) / 2, b = Math.min(this.roundness, E), $ = p.rotate([f, 0], l, [0, 0]), y = p.rotate([s - f, o], u, [
501
482
  s,
502
- r,
503
- -this.arrowLength,
504
- -this.minPortOffset
505
- ), N = `M 0 0 L ${m[0]} ${m[1]} `, A = ` M ${p[0]} ${p[1]} L ${s} ${r}`, P = this.sourceArrow ? E : N, L = this.targetArrow ? $ : A, V = `${P}${b}${L}`;
506
- if (this.line.setAttribute("d", V), this.sourceArrow) {
507
- const x = v.getArrowPath(
483
+ o
484
+ ]), T = p.rotate([w, 0], l, [0, 0]), S = p.rotate([s - w, o], u, [
485
+ s,
486
+ o
487
+ ]), N = (S[0] - T[0]) / 2, L = (S[1] - T[1]) / 2, A = b / E, O = [T[0] + N * A, T[1] + L * A], V = [S[0] - N * A, S[1] - L * A], k = [
488
+ `M ${v[0]} ${v[1]}`,
489
+ `L ${$[0]} ${$[1]}`,
490
+ `C ${T[0]} ${T[1]} ${T[0]} ${T[1]} ${O[0]} ${O[1]}`,
491
+ `L ${V[0]} ${V[1]}`,
492
+ `C ${S[0]} ${S[1]} ${S[0]} ${S[1]} ${y[0]} ${y[1]}`,
493
+ `L ${m[0]} ${m[1]}`
494
+ ].join(" ");
495
+ if (this.line.setAttribute("d", k), this.sourceArrow) {
496
+ const P = p.getArrowPath(
508
497
  l,
509
498
  0,
510
499
  0,
511
500
  this.arrowLength,
512
501
  this.arrowWidth
513
502
  );
514
- this.sourceArrow.setAttribute("d", x);
503
+ this.sourceArrow.setAttribute("d", P);
515
504
  }
516
505
  if (this.targetArrow) {
517
- const x = v.getArrowPath(
506
+ const P = p.getArrowPath(
518
507
  u,
519
508
  s,
520
- r,
509
+ o,
521
510
  -this.arrowLength,
522
511
  this.arrowWidth
523
512
  );
524
- this.targetArrow.setAttribute("d", x);
513
+ this.targetArrow.setAttribute("d", P);
525
514
  }
526
515
  }
527
516
  }
528
- class Y {
529
- constructor(t, e, s, r, a, c, h) {
517
+ class Z {
518
+ constructor(t, e, s, o, a, c, h) {
530
519
  n(this, "svg");
531
520
  n(this, "group");
532
521
  n(this, "line");
533
522
  n(this, "arrow", null);
534
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.radius = c, this.smallRadius = h, 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%", a && (this.arrow = document.createElementNS(
523
+ this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.radius = c, this.smallRadius = h, 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%", a && (this.arrow = document.createElementNS(
535
524
  "http://www.w3.org/2000/svg",
536
525
  "path"
537
526
  ), 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";
538
527
  }
539
- update(t, e, s, r, a) {
528
+ update(t, e, s, o, a) {
540
529
  this.svg.style.transform = `translate(${t}px, ${e}px)`;
541
- const c = v.getDirectionVector(a.direction, 1, 1), h = this.smallRadius, i = this.radius, d = Math.sqrt(h * h + i * i), g = h + i, l = this.arrowLength + d * (1 - i / g), u = h * i / g, m = [
530
+ const c = p.getDirectionVector(a.direction, 1, 1), h = this.smallRadius, i = this.radius, d = Math.sqrt(h * h + i * i), g = h + i, l = this.arrowLength + d * (1 - i / g), u = h * i / g, m = [
542
531
  [this.arrowLength, 0],
543
532
  [l, u],
544
533
  [l, -u]
545
- ].map((y) => v.rotate(y, c, [0, 0])), p = [
534
+ ].map((E) => p.rotate(E, c, [0, 0])), w = [
546
535
  `M ${m[0][0]} ${m[0][1]}`,
547
536
  `A ${h} ${h} 0 0 1 ${m[1][0]} ${m[1][1]}`,
548
537
  `A ${i} ${i} 0 1 0 ${m[2][0]} ${m[2][1]}`,
549
538
  `A ${h} ${h} 0 0 1 ${m[0][0]} ${m[0][1]}`
550
- ].join(" "), C = `M 0 0 L ${m[0][0]} ${m[0][1]} `, f = `${this.arrow !== null ? "" : C}${p}`;
551
- if (this.line.setAttribute("d", f), this.arrow) {
552
- const y = v.getArrowPath(
539
+ ].join(" "), f = `M 0 0 L ${m[0][0]} ${m[0][1]} `, C = `${this.arrow !== null ? "" : f}${w}`;
540
+ if (this.line.setAttribute("d", C), this.arrow) {
541
+ const E = p.getArrowPath(
553
542
  c,
554
543
  0,
555
544
  0,
556
545
  this.arrowLength,
557
546
  this.arrowWidth
558
547
  );
559
- this.arrow.setAttribute("d", y);
548
+ this.arrow.setAttribute("d", E);
560
549
  }
561
550
  }
562
551
  }
563
- class G {
564
- constructor(t, e, s, r, a, c, h, i) {
552
+ class U {
553
+ constructor(t, e, s, o, a, c, h, i) {
565
554
  n(this, "svg");
566
555
  n(this, "group");
567
556
  n(this, "line");
568
557
  n(this, "arrow", null);
569
558
  n(this, "roundness");
570
559
  n(this, "points");
571
- this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = r, this.side = c, this.minPortOffset = h, this.roundness = Math.min(i, 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%", a && (this.arrow = document.createElementNS(
560
+ this.color = t, this.width = e, this.arrowLength = s, this.arrowWidth = o, this.side = c, this.minPortOffset = h, this.roundness = Math.min(i, 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%", a && (this.arrow = document.createElementNS(
572
561
  "http://www.w3.org/2000/svg",
573
562
  "path"
574
563
  ), 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";
575
- const d = this.minPortOffset, g = this.side, l = this.arrowLength + d, u = this.roundness, w = l - u, m = l + u, p = g - u, C = l + 2 * g, f = C - u;
564
+ const d = this.minPortOffset, g = this.side, l = this.arrowLength + d, u = this.roundness, v = l - u, m = l + u, w = g - u, f = l + 2 * g, C = f - u;
576
565
  console.log(u), this.points = [
577
566
  [this.arrowLength, 0],
578
- [w, 0],
567
+ [v, 0],
579
568
  [l, u],
580
- [l, p],
569
+ [l, w],
581
570
  [m, g],
582
- [f, g],
583
- [C, p],
584
- [C, -p],
585
- [f, -g],
571
+ [C, g],
572
+ [f, w],
573
+ [f, -w],
574
+ [C, -g],
586
575
  [m, -g],
587
- [l, -p],
576
+ [l, -w],
588
577
  [l, -u]
589
578
  ];
590
579
  }
591
- update(t, e, s, r, a) {
580
+ update(t, e, s, o, a) {
592
581
  this.svg.style.transform = `translate(${t}px, ${e}px)`;
593
- const c = v.getDirectionVector(a.direction, 1, 1), h = this.roundness, i = this.points.map((u) => v.rotate(u, c, [0, 0])), d = [
582
+ const c = p.getDirectionVector(a.direction, 1, 1), h = this.roundness, i = this.points.map((u) => p.rotate(u, c, [0, 0])), d = [
594
583
  `M ${i[0][0]} ${i[0][1]}`,
595
584
  `L ${i[1][0]} ${i[1][1]}`,
596
585
  `A ${h} ${h} 0 0 1 ${i[2][0]} ${i[2][1]}`,
@@ -606,7 +595,7 @@ class G {
606
595
  `A ${h} ${h} 0 0 1 ${i[1][0]} ${i[1][1]}`
607
596
  ].join(" "), g = `M 0 0 L ${i[0][0]} ${i[0][1]} `, l = `${this.arrow ? "" : g}${d}`;
608
597
  if (this.line.setAttribute("d", l), this.arrow) {
609
- const u = v.getArrowPath(
598
+ const u = p.getArrowPath(
610
599
  c,
611
600
  0,
612
601
  0,
@@ -617,43 +606,43 @@ class G {
617
606
  }
618
607
  }
619
608
  }
620
- var T = /* @__PURE__ */ ((o) => (o.Regular = "regular", o.Cycle = "cycle", o))(T || {});
621
- const X = (o) => (t) => t === "cycle" ? new Y(
622
- o.color,
623
- o.width,
624
- o.arrowLength,
625
- o.arrowWidth,
626
- o.hasSourceArrow || o.hasTargetArrow,
627
- o.cycleRadius,
628
- o.smallCycleRadius
629
- ) : new B(
630
- o.color,
631
- o.width,
632
- o.curvature,
633
- o.arrowLength,
634
- o.arrowWidth,
635
- o.hasSourceArrow,
636
- o.hasTargetArrow
637
- ), Z = (o) => (t) => t === T.Cycle && t === "cycle" ? new G(
638
- o.color,
639
- o.width,
640
- o.arrowLength,
641
- o.arrowWidth,
642
- o.hasSourceArrow || o.hasTargetArrow,
643
- o.cycleSquareSide,
644
- o.minPortOffset,
645
- o.roundness
646
- ) : new z(
647
- o.color,
648
- o.width,
649
- o.arrowLength,
650
- o.arrowWidth,
651
- o.minPortOffset,
652
- o.hasSourceArrow,
653
- o.hasTargetArrow,
654
- o.roundness
609
+ var M = /* @__PURE__ */ ((r) => (r.Regular = "regular", r.Cycle = "cycle", r))(M || {});
610
+ const H = (r) => (t) => t === "cycle" ? new Z(
611
+ r.color,
612
+ r.width,
613
+ r.arrowLength,
614
+ r.arrowWidth,
615
+ r.hasSourceArrow || r.hasTargetArrow,
616
+ r.cycleRadius,
617
+ r.smallCycleRadius
618
+ ) : new G(
619
+ r.color,
620
+ r.width,
621
+ r.curvature,
622
+ r.arrowLength,
623
+ r.arrowWidth,
624
+ r.hasSourceArrow,
625
+ r.hasTargetArrow
626
+ ), q = (r) => (t) => t === M.Cycle && t === "cycle" ? new U(
627
+ r.color,
628
+ r.width,
629
+ r.arrowLength,
630
+ r.arrowWidth,
631
+ r.hasSourceArrow || r.hasTargetArrow,
632
+ r.cycleSquareSide,
633
+ r.arrowOffset,
634
+ r.roundness
635
+ ) : new X(
636
+ r.color,
637
+ r.width,
638
+ r.arrowLength,
639
+ r.arrowWidth,
640
+ r.arrowOffset,
641
+ r.hasSourceArrow,
642
+ r.hasTargetArrow,
643
+ r.roundness
655
644
  );
656
- class S {
645
+ class x {
657
646
  constructor() {
658
647
  n(this, "counter", 0);
659
648
  }
@@ -665,19 +654,19 @@ class S {
665
654
  this.counter = 0;
666
655
  }
667
656
  }
668
- class U {
669
- constructor(t, e, s, r, a) {
670
- n(this, "nodeIdGenerator", new S());
671
- n(this, "portIdGenerator", new S());
672
- n(this, "connectionIdGenerator", new S());
673
- this.graphStore = t, this.htmlController = e, this.viewportTransformer = s, this.nodesCenterFn = r, this.portsCenterFn = a;
657
+ class _ {
658
+ constructor(t, e, s, o, a) {
659
+ n(this, "nodeIdGenerator", new x());
660
+ n(this, "portIdGenerator", new x());
661
+ n(this, "edgeIdGenerator", new x());
662
+ this.graphStore = t, this.htmlController = e, this.viewportTransformer = s, this.nodesCenterFn = o, this.portsCenterFn = a;
674
663
  }
675
664
  moveNodeOnTop(t) {
676
665
  if (!this.graphStore.hasNode(t))
677
666
  throw new Error("failed to move on top nonexisting node");
678
667
  this.htmlController.moveNodeOnTop(t);
679
668
  }
680
- addNode(t, e, s, r, a, c) {
669
+ addNode(t, e, s, o, a, c) {
681
670
  if (t === void 0)
682
671
  do
683
672
  t = this.nodeIdGenerator.next();
@@ -688,7 +677,7 @@ class U {
688
677
  t,
689
678
  e,
690
679
  s,
691
- r,
680
+ o,
692
681
  c ?? this.nodesCenterFn
693
682
  ), this.htmlController.attachNode(t), a !== void 0 && Object.entries(a).forEach(([h, i]) => {
694
683
  i instanceof HTMLElement ? this.markPort(h, i, t, this.portsCenterFn, null) : this.markPort(
@@ -700,7 +689,7 @@ class U {
700
689
  );
701
690
  });
702
691
  }
703
- markPort(t, e, s, r, a) {
692
+ markPort(t, e, s, o, a) {
704
693
  if (t === void 0)
705
694
  do
706
695
  t = this.portIdGenerator.next();
@@ -713,43 +702,43 @@ class U {
713
702
  t,
714
703
  e,
715
704
  s,
716
- r ?? this.portsCenterFn,
705
+ o ?? this.portsCenterFn,
717
706
  a ?? null
718
707
  );
719
708
  }
720
- updatePortConnections(t) {
709
+ updatePortEdges(t) {
721
710
  if (!this.graphStore.hasPort(t))
722
711
  throw new Error("failed to unset nonexisting port");
723
- this.htmlController.updatePortConnections(t);
712
+ this.htmlController.updatePortEdges(t);
724
713
  }
725
714
  unmarkPort(t) {
726
715
  if (!this.graphStore.hasPort(t))
727
716
  throw new Error("failed to unset nonexisting port");
728
- this.graphStore.getPortAdjacentConnections(t).forEach((e) => {
729
- this.removeConnection(e);
717
+ this.graphStore.getPortAdjacentEdges(t).forEach((e) => {
718
+ this.removeEdge(e);
730
719
  }), this.graphStore.removePort(t);
731
720
  }
732
- addConnection(t, e, s, r) {
721
+ addEdge(t, e, s, o) {
733
722
  if (t === void 0)
734
723
  do
735
- t = this.connectionIdGenerator.next();
736
- while (this.graphStore.hasConnection(t));
724
+ t = this.edgeIdGenerator.next();
725
+ while (this.graphStore.hasEdge(t));
737
726
  if (!this.graphStore.hasPort(e))
738
- throw new Error("failed to add connection from nonexisting port");
727
+ throw new Error("failed to add edge from nonexisting port");
739
728
  if (!this.graphStore.hasPort(s))
740
- throw new Error("failed to add connection to nonexisting port");
741
- let a = T.Regular;
742
- e === s && (a = T.Cycle), this.graphStore.addConnection(
729
+ throw new Error("failed to add edge to nonexisting port");
730
+ let a = M.Regular;
731
+ e === s && (a = M.Cycle), this.graphStore.addEdge(
743
732
  t,
744
733
  e,
745
734
  s,
746
- r(a)
747
- ), this.htmlController.attachConnection(t);
735
+ o(a)
736
+ ), this.htmlController.attachEdge(t);
748
737
  }
749
- removeConnection(t) {
750
- if (!this.graphStore.hasConnection(t))
751
- throw new Error("failed to remove nonexisting connection");
752
- this.htmlController.detachConnection(t), this.graphStore.removeConnection(t);
738
+ removeEdge(t) {
739
+ if (!this.graphStore.hasEdge(t))
740
+ throw new Error("failed to remove nonexisting edge");
741
+ this.htmlController.detachEdge(t), this.graphStore.removeEdge(t);
753
742
  }
754
743
  removeNode(t) {
755
744
  if (!this.graphStore.hasNode(t))
@@ -765,10 +754,10 @@ class U {
765
754
  const e = t.map((u) => this.graphStore.getNode(u)).filter((u) => u !== void 0);
766
755
  if (e.length < t.length)
767
756
  throw new Error("failed to move to nonexisting node");
768
- const [s, r] = e.reduce(
769
- (u, w) => [u[0] + w.x, u[1] + w.y],
757
+ const [s, o] = e.reduce(
758
+ (u, v) => [u[0] + v.x, u[1] + v.y],
770
759
  [0, 0]
771
- ), a = s / e.length, c = r / e.length, [h, i] = this.htmlController.getViewportDimensions(), d = this.viewportTransformer.getAbsScale(), g = a - d * h / 2, l = c - d * i / 2;
760
+ ), a = s / e.length, c = o / e.length, [h, i] = this.htmlController.getViewportDimensions(), d = this.viewportTransformer.getAbsScale(), g = a - d * h / 2, l = c - d * i / 2;
772
761
  this.patchViewportState(null, g, l);
773
762
  }
774
763
  updateNodeCoordinates(t, e, s) {
@@ -776,10 +765,10 @@ class U {
776
765
  throw new Error("failed to update coordinates of nonexisting node");
777
766
  this.graphStore.updateNodeCoords(t, e, s), this.htmlController.updateNodeCoordinates(t);
778
767
  }
779
- updateConnectionController(t, e) {
780
- if (!this.graphStore.hasConnection(t))
781
- throw new Error("failed to update nonexisting connection");
782
- this.htmlController.detachConnection(t), this.graphStore.updateConnectionController(t, e), this.htmlController.attachConnection(t);
768
+ updateEdgeController(t, e) {
769
+ if (!this.graphStore.hasEdge(t))
770
+ throw new Error("failed to update nonexisting edge");
771
+ this.htmlController.detachEdge(t), this.graphStore.updateEdgeController(t, e), this.htmlController.attachEdge(t);
783
772
  }
784
773
  attach(t) {
785
774
  this.htmlController.attach(t);
@@ -788,145 +777,145 @@ class U {
788
777
  this.htmlController.detach();
789
778
  }
790
779
  clear() {
791
- this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.connectionIdGenerator.reset();
780
+ this.htmlController.clear(), this.graphStore.clear(), this.nodeIdGenerator.reset(), this.portIdGenerator.reset(), this.edgeIdGenerator.reset();
792
781
  }
793
782
  destroy() {
794
783
  this.htmlController.destroy();
795
784
  }
796
785
  }
797
- class H {
798
- constructor(t, e, s, r) {
786
+ class J {
787
+ constructor(t, e, s, o) {
799
788
  n(this, "publicViewportTransformer");
800
789
  n(this, "canvasController");
801
- const a = new W(), c = new R();
802
- this.publicViewportTransformer = new j(
790
+ const a = new B(), c = new Y();
791
+ this.publicViewportTransformer = new z(
803
792
  a
804
793
  );
805
- const h = new k(
794
+ const h = new W(
806
795
  c,
807
796
  a,
808
797
  this.publicViewportTransformer,
809
798
  t,
810
799
  e
811
800
  );
812
- this.canvasController = new U(
801
+ this.canvasController = new _(
813
802
  c,
814
803
  h,
815
804
  a,
816
805
  s,
817
- r
806
+ o
818
807
  );
819
808
  }
820
809
  }
821
- const M = (o, t) => [
822
- o / 2,
810
+ const D = (r, t) => [
811
+ r / 2,
823
812
  t / 2
824
- ], _ = () => () => {
825
- }, q = (o, t, e, s, r, a) => {
826
- o.clearRect(0, 0, o.canvas.width, o.canvas.height), o.fillStyle = a, o.fillRect(0, 0, o.canvas.width, o.canvas.height);
813
+ ], K = () => () => {
814
+ }, Q = (r, t, e, s, o, a) => {
815
+ r.clearRect(0, 0, r.canvas.width, r.canvas.height), r.fillStyle = a, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
827
816
  const c = t.getViewCoords(0, 0), h = t.getViewScale(), i = s * h;
828
817
  let d = 0, g = 0, l = i / 2;
829
818
  do
830
- l *= 2, d = o.canvas.width / l, g = o.canvas.height / l;
819
+ l *= 2, d = r.canvas.width / l, g = r.canvas.height / l;
831
820
  while (d * g > 1e4);
832
- const u = c[0] - Math.floor(c[0] / l) * l, w = c[1] - Math.floor(c[1] / l) * l, m = r * h, p = 2 * Math.PI, C = u - l, f = w - l, y = o.canvas.width + u, b = o.canvas.height + w;
833
- o.fillStyle = e;
834
- for (let E = C; E <= y; E += l)
835
- for (let $ = f; $ <= b; $ += l)
836
- o.beginPath(), o.arc(E, $, m, 0, p), o.closePath(), o.fill();
837
- }, J = (o, t, e, s) => (r, a) => {
838
- q(
839
- r,
840
- a,
821
+ const u = c[0] - Math.floor(c[0] / l) * l, v = c[1] - Math.floor(c[1] / l) * l, m = o * h, w = 2 * Math.PI, f = u - l, C = v - l, E = r.canvas.width + u, b = r.canvas.height + v;
822
+ r.fillStyle = e;
823
+ for (let $ = f; $ <= E; $ += l)
824
+ for (let y = C; y <= b; y += l)
825
+ r.beginPath(), r.arc($, y, m, 0, w), r.closePath(), r.fill();
826
+ }, I = (r, t, e, s) => (o, a) => {
827
+ Q(
841
828
  o,
829
+ a,
830
+ r,
842
831
  t,
843
832
  e,
844
833
  s
845
834
  );
846
- }, K = (o, t) => {
847
- o.fillStyle = t, o.fillRect(0, 0, o.canvas.width, o.canvas.height);
848
- }, Q = (o) => (t) => {
849
- K(t, o);
850
- }, I = (o) => {
851
- switch (o == null ? void 0 : o.type) {
835
+ }, tt = (r, t) => {
836
+ r.fillStyle = t, r.fillRect(0, 0, r.canvas.width, r.canvas.height);
837
+ }, et = (r) => (t) => {
838
+ tt(t, r);
839
+ }, st = (r) => {
840
+ switch (r == null ? void 0 : r.type) {
852
841
  case "custom":
853
- return o.drawingFn;
842
+ return r.drawingFn;
854
843
  case "dots":
855
- return J(
856
- o.dotColor ?? "#d8d8d8",
857
- o.dotGap ?? 25,
858
- o.dotRadius ?? 1.5,
859
- o.color ?? "#ffffff"
844
+ return I(
845
+ r.dotColor ?? "#d8d8d8",
846
+ r.dotGap ?? 25,
847
+ r.dotRadius ?? 1.5,
848
+ r.color ?? "#ffffff"
860
849
  );
861
850
  case "color":
862
- return Q(o.color ?? "#ffffff");
851
+ return et(r.color ?? "#ffffff");
863
852
  default:
864
- return _();
853
+ return K();
865
854
  }
866
- }, O = (o) => {
867
- switch (o == null ? void 0 : o.type) {
855
+ }, F = (r) => {
856
+ switch (r == null ? void 0 : r.type) {
868
857
  case "custom":
869
- return o.controllerFactory;
858
+ return r.controllerFactory;
870
859
  case "straight":
871
- return Z({
872
- color: o.color ?? "#5c5c5c",
873
- width: o.width ?? 1,
874
- arrowLength: o.arrowLength ?? 15,
875
- arrowWidth: o.arrowWidth ?? 4,
876
- minPortOffset: o.minPortOffset ?? 15,
877
- hasSourceArrow: o.hasSourceArrow ?? !1,
878
- hasTargetArrow: o.hasTargetArrow ?? !1,
879
- cycleSquareSide: o.cycleSquareSide ?? 30,
880
- roundness: o.roundness ?? 5
860
+ return q({
861
+ color: r.color ?? "#5c5c5c",
862
+ width: r.width ?? 1,
863
+ arrowLength: r.arrowLength ?? 15,
864
+ arrowWidth: r.arrowWidth ?? 4,
865
+ arrowOffset: r.arrowOffset ?? 15,
866
+ hasSourceArrow: r.hasSourceArrow ?? !1,
867
+ hasTargetArrow: r.hasTargetArrow ?? !1,
868
+ cycleSquareSide: r.cycleSquareSide ?? 30,
869
+ roundness: r.roundness ?? 5
881
870
  });
882
871
  default:
883
- return X({
884
- color: o.color ?? "#5c5c5c",
885
- width: o.width ?? 1,
886
- curvature: o.curvature ?? 90,
887
- arrowLength: o.arrowLength ?? 15,
888
- arrowWidth: o.arrowWidth ?? 4,
889
- hasSourceArrow: o.hasSourceArrow ?? !1,
890
- hasTargetArrow: o.hasTargetArrow ?? !1,
891
- cycleRadius: o.cycleRadius ?? 30,
892
- smallCycleRadius: o.smallCycleRadius ?? 15
872
+ return H({
873
+ color: r.color ?? "#5c5c5c",
874
+ width: r.width ?? 1,
875
+ curvature: r.curvature ?? 90,
876
+ arrowLength: r.arrowLength ?? 15,
877
+ arrowWidth: r.arrowWidth ?? 4,
878
+ hasSourceArrow: r.hasSourceArrow ?? !1,
879
+ hasTargetArrow: r.hasTargetArrow ?? !1,
880
+ cycleRadius: r.cycleRadius ?? 30,
881
+ smallCycleRadius: r.smallCycleRadius ?? 15
893
882
  });
894
883
  }
895
- }, tt = (o) => {
884
+ }, rt = (r) => {
896
885
  var t, e, s;
897
886
  return {
898
887
  background: {
899
- drawingFn: I(
900
- o.background ?? { type: "none" }
888
+ drawingFn: st(
889
+ r.background ?? { type: "none" }
901
890
  )
902
891
  },
903
892
  nodes: {
904
- centerFn: ((t = o.nodes) == null ? void 0 : t.centerFn) ?? M
893
+ centerFn: ((t = r.nodes) == null ? void 0 : t.centerFn) ?? D
905
894
  },
906
895
  ports: {
907
- centerFn: ((e = o.ports) == null ? void 0 : e.centerFn) ?? M
896
+ centerFn: ((e = r.ports) == null ? void 0 : e.centerFn) ?? D
908
897
  },
909
898
  edges: {
910
- controllerFactory: O(o.edges ?? {})
899
+ controllerFactory: F(r.edges ?? {})
911
900
  },
912
901
  layers: {
913
- mode: ((s = o.layers) == null ? void 0 : s.mode) ?? "edges-follow-node"
902
+ mode: ((s = r.layers) == null ? void 0 : s.mode) ?? "edges-follow-node"
914
903
  }
915
904
  };
916
905
  };
917
- class et {
906
+ class ot {
918
907
  constructor(t) {
919
908
  n(this, "transformation");
920
909
  n(this, "di");
921
- n(this, "connectionControllerFactory");
910
+ n(this, "edgeControllerFactory");
922
911
  this.apiOptions = t;
923
- const e = tt(this.apiOptions ?? {});
924
- this.di = new H(
912
+ const e = rt(this.apiOptions ?? {});
913
+ this.di = new J(
925
914
  e.layers.mode,
926
915
  e.background.drawingFn,
927
916
  e.nodes.centerFn,
928
917
  e.ports.centerFn
929
- ), this.transformation = this.di.publicViewportTransformer, this.connectionControllerFactory = e.edges.controllerFactory;
918
+ ), this.transformation = this.di.publicViewportTransformer, this.edgeControllerFactory = e.edges.controllerFactory;
930
919
  }
931
920
  addNode(t) {
932
921
  return this.di.canvasController.addNode(
@@ -954,14 +943,14 @@ class et {
954
943
  ), this;
955
944
  }
956
945
  updatePortEdges(t) {
957
- return this.di.canvasController.updatePortConnections(t), this;
946
+ return this.di.canvasController.updatePortEdges(t), this;
958
947
  }
959
948
  unmarkPort(t) {
960
949
  return this.di.canvasController.unmarkPort(t), this;
961
950
  }
962
951
  addEdge(t) {
963
- const e = t.options !== void 0 ? O(t.options) : this.connectionControllerFactory;
964
- return this.di.canvasController.addConnection(
952
+ const e = t.options !== void 0 ? F(t.options) : this.edgeControllerFactory;
953
+ return this.di.canvasController.addEdge(
965
954
  t.id,
966
955
  t.from,
967
956
  t.to,
@@ -969,7 +958,7 @@ class et {
969
958
  ), this;
970
959
  }
971
960
  removeEdge(t) {
972
- return this.di.canvasController.removeConnection(t), this;
961
+ return this.di.canvasController.removeEdge(t), this;
973
962
  }
974
963
  patchViewportState(t) {
975
964
  return this.di.canvasController.patchViewportState(
@@ -984,11 +973,8 @@ class et {
984
973
  updateNodeCoordinates(t, e, s) {
985
974
  return this.di.canvasController.updateNodeCoordinates(t, e, s), this;
986
975
  }
987
- updateConnection(t, e) {
988
- return e.controller !== void 0 && this.di.canvasController.updateConnectionController(
989
- t,
990
- e.controller
991
- ), this;
976
+ updateEdge(t, e) {
977
+ return e.controller !== void 0 && this.di.canvasController.updateEdgeController(t, e.controller), this;
992
978
  }
993
979
  clear() {
994
980
  return this.di.canvasController.clear(), this;
@@ -1003,14 +989,14 @@ class et {
1003
989
  this.di.canvasController.destroy();
1004
990
  }
1005
991
  }
1006
- class st {
992
+ class nt {
1007
993
  constructor(t, e) {
1008
994
  n(this, "transformation");
1009
995
  n(this, "nodes", /* @__PURE__ */ new Map());
1010
996
  n(this, "grabbedNodeId", null);
1011
997
  n(this, "onNodeDrag");
1012
998
  n(this, "onBeforeNodeDrag");
1013
- n(this, "nodeIdGenerator", new S());
999
+ n(this, "nodeIdGenerator", new x());
1014
1000
  n(this, "element", null);
1015
1001
  n(this, "onCanvasMouseUp", () => {
1016
1002
  this.setCursor(null), this.grabbedNodeId = null;
@@ -1049,8 +1035,8 @@ class st {
1049
1035
  const s = () => {
1050
1036
  };
1051
1037
  this.onNodeDrag = ((a = e == null ? void 0 : e.events) == null ? void 0 : a.onNodeDrag) ?? s;
1052
- const r = () => !0;
1053
- this.onBeforeNodeDrag = ((c = e == null ? void 0 : e.events) == null ? void 0 : c.onBeforeNodeDrag) ?? r;
1038
+ const o = () => !0;
1039
+ this.onBeforeNodeDrag = ((c = e == null ? void 0 : e.events) == null ? void 0 : c.onBeforeNodeDrag) ?? o;
1054
1040
  }
1055
1041
  addNode(t) {
1056
1042
  let e = t.id;
@@ -1066,7 +1052,7 @@ class st {
1066
1052
  x: t.x,
1067
1053
  y: t.y
1068
1054
  }) && (a.stopImmediatePropagation(), this.grabbedNodeId = e, this.setCursor("grab"), this.canvas.moveNodeOnTop(e));
1069
- }, r = (a) => {
1055
+ }, o = (a) => {
1070
1056
  this.onBeforeNodeDrag({
1071
1057
  nodeId: e,
1072
1058
  element: t.element,
@@ -1077,10 +1063,10 @@ class st {
1077
1063
  return this.nodes.set(e, {
1078
1064
  element: t.element,
1079
1065
  onMouseDown: s,
1080
- onTouchStart: r,
1066
+ onTouchStart: o,
1081
1067
  x: t.x,
1082
1068
  y: t.y
1083
- }), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", r), this;
1069
+ }), t.element.addEventListener("mousedown", s), t.element.addEventListener("touchstart", o), this;
1084
1070
  }
1085
1071
  removeNode(t) {
1086
1072
  const e = this.nodes.get(t);
@@ -1110,8 +1096,8 @@ class st {
1110
1096
  updateNodeCoordinates(t, e, s) {
1111
1097
  return this.canvas.updateNodeCoordinates(t, e, s), this;
1112
1098
  }
1113
- updateConnection(t, e) {
1114
- return this.canvas.updateConnection(t, e), this;
1099
+ updateEdge(t, e) {
1100
+ return this.canvas.updateEdge(t, e), this;
1115
1101
  }
1116
1102
  moveNodeOnTop(t) {
1117
1103
  return this.canvas.moveNodeOnTop(t), this;
@@ -1136,19 +1122,19 @@ class st {
1136
1122
  this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1137
1123
  }
1138
1124
  dragNode(t, e, s) {
1139
- const r = this.nodes.get(t);
1140
- if (r === void 0)
1125
+ const o = this.nodes.get(t);
1126
+ if (o === void 0)
1141
1127
  throw new Error("failed to drag nonexisting node");
1142
- const [a, c] = this.transformation.getViewCoords(r.x, r.y), h = a + e, i = c + s, [d, g] = this.transformation.getAbsCoords(h, i);
1143
- r.x = d, r.y = g, this.canvas.updateNodeCoordinates(t, d, g), this.onNodeDrag({
1128
+ const [a, c] = this.transformation.getViewCoords(o.x, o.y), h = a + e, i = c + s, [d, g] = this.transformation.getAbsCoords(h, i);
1129
+ o.x = d, o.y = g, this.canvas.updateNodeCoordinates(t, d, g), this.onNodeDrag({
1144
1130
  nodeId: t,
1145
- element: r.element,
1146
- x: r.x,
1147
- y: r.y
1131
+ element: o.element,
1132
+ x: o.x,
1133
+ y: o.y
1148
1134
  });
1149
1135
  }
1150
1136
  }
1151
- class ot {
1137
+ class it {
1152
1138
  constructor(t, e) {
1153
1139
  n(this, "transformation");
1154
1140
  n(this, "element", null);
@@ -1177,8 +1163,8 @@ class ot {
1177
1163
  if (this.element === null || this.isScalable === !1)
1178
1164
  return;
1179
1165
  t.preventDefault();
1180
- const { left: e, top: s } = this.element.getBoundingClientRect(), r = t.clientX - e, a = t.clientY - s, h = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1181
- this.scaleViewport(h, r, a);
1166
+ const { left: e, top: s } = this.element.getBoundingClientRect(), o = t.clientX - e, a = t.clientY - s, h = 1 / (t.deltaY < 0 ? this.wheelSensitivity : 1 / this.wheelSensitivity);
1167
+ this.scaleViewport(h, o, a);
1182
1168
  });
1183
1169
  n(this, "onTouchStart", (t) => {
1184
1170
  this.prevTouches = this.getAverageTouch(t);
@@ -1191,7 +1177,7 @@ class ot {
1191
1177
  -(e.x - this.prevTouches.x),
1192
1178
  -(e.y - this.prevTouches.y)
1193
1179
  ), e.touchesCnt === 2 && this.isScalable) {
1194
- const { left: s, top: r } = this.element.getBoundingClientRect(), a = this.prevTouches.x - s, c = this.prevTouches.y - r, i = 1 / (e.scale / this.prevTouches.scale);
1180
+ const { left: s, top: o } = this.element.getBoundingClientRect(), a = this.prevTouches.x - s, c = this.prevTouches.y - o, i = 1 / (e.scale / this.prevTouches.scale);
1195
1181
  this.scaleViewport(i, a, c);
1196
1182
  }
1197
1183
  this.prevTouches = e, t.preventDefault();
@@ -1199,15 +1185,15 @@ class ot {
1199
1185
  n(this, "onTouchEnd", (t) => {
1200
1186
  t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.prevTouches = null;
1201
1187
  });
1202
- var i, d, g, l, u, w, m, p, C, f, y, b;
1188
+ var i, d, g, l, u, v, m, w, f, C, E, b;
1203
1189
  this.canvas = t, this.options = e, this.transformation = this.canvas.transformation;
1204
- const s = ((d = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : d.min) ?? null, r = ((l = (g = this.options) == null ? void 0 : g.scale) == null ? void 0 : l.max) ?? null;
1205
- this.isScalable = ((w = (u = this.options) == null ? void 0 : u.scale) == null ? void 0 : w.enabled) !== !1, this.minViewScale = r !== null ? 1 / r : null, this.maxViewScale = s !== null ? 1 / s : null, this.isShiftable = ((p = (m = this.options) == null ? void 0 : m.shift) == null ? void 0 : p.enabled) !== !1;
1206
- const a = (f = (C = this.options) == null ? void 0 : C.scale) == null ? void 0 : f.wheelSensitivity;
1190
+ const s = ((d = (i = this.options) == null ? void 0 : i.scale) == null ? void 0 : d.min) ?? null, o = ((l = (g = this.options) == null ? void 0 : g.scale) == null ? void 0 : l.max) ?? null;
1191
+ this.isScalable = ((v = (u = this.options) == null ? void 0 : u.scale) == null ? void 0 : v.enabled) !== !1, this.minViewScale = o !== null ? 1 / o : null, this.maxViewScale = s !== null ? 1 / s : null, this.isShiftable = ((w = (m = this.options) == null ? void 0 : m.shift) == null ? void 0 : w.enabled) !== !1;
1192
+ const a = (C = (f = this.options) == null ? void 0 : f.scale) == null ? void 0 : C.wheelSensitivity;
1207
1193
  this.wheelSensitivity = a !== void 0 ? a : 1.2;
1208
1194
  const c = () => {
1209
1195
  };
1210
- this.onTransform = ((y = e == null ? void 0 : e.events) == null ? void 0 : y.onTransform) ?? c;
1196
+ this.onTransform = ((E = e == null ? void 0 : e.events) == null ? void 0 : E.onTransform) ?? c;
1211
1197
  const h = () => !0;
1212
1198
  this.onBeforeTransform = ((b = e == null ? void 0 : e.events) == null ? void 0 : b.onBeforeTransform) ?? h;
1213
1199
  }
@@ -1241,8 +1227,8 @@ class ot {
1241
1227
  updateNodeCoordinates(t, e, s) {
1242
1228
  return this.canvas.updateNodeCoordinates(t, e, s), this;
1243
1229
  }
1244
- updateConnection(t, e) {
1245
- return this.canvas.updateConnection(t, e), this;
1230
+ updateEdge(t, e) {
1231
+ return this.canvas.updateEdge(t, e), this;
1246
1232
  }
1247
1233
  moveNodeOnTop(t) {
1248
1234
  return this.canvas.moveNodeOnTop(t), this;
@@ -1263,10 +1249,10 @@ class ot {
1263
1249
  const e = [], s = t.touches.length;
1264
1250
  for (let i = 0; i < s; i++)
1265
1251
  e.push([t.touches[i].clientX, t.touches[i].clientY]);
1266
- const r = e.reduce(
1252
+ const o = e.reduce(
1267
1253
  (i, d) => [i[0] + d[0], i[1] + d[1]],
1268
1254
  [0, 0]
1269
- ), a = [r[0] / s, r[1] / s], h = e.map((i) => [i[0] - a[0], i[1] - a[1]]).reduce(
1255
+ ), a = [o[0] / s, o[1] / s], h = e.map((i) => [i[0] - a[0], i[1] - a[1]]).reduce(
1270
1256
  (i, d) => i + Math.sqrt(d[0] * d[0] + d[1] * d[1]),
1271
1257
  0
1272
1258
  );
@@ -1276,22 +1262,22 @@ class ot {
1276
1262
  this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1277
1263
  }
1278
1264
  moveViewport(t, e) {
1279
- const [s, r] = this.transformation.getAbsCoords(0, 0), a = this.canvas.transformation.getAbsScale(), c = {
1265
+ const [s, o] = this.transformation.getAbsCoords(0, 0), a = this.canvas.transformation.getAbsScale(), c = {
1280
1266
  scale: a,
1281
1267
  x: s + a * t,
1282
- y: r + a * e
1268
+ y: o + a * e
1283
1269
  };
1284
1270
  this.onBeforeTransform({ ...c }) && (this.canvas.patchViewportState(c), this.onTransform(c));
1285
1271
  }
1286
1272
  scaleViewport(t, e, s) {
1287
- const [r, a] = this.canvas.transformation.getAbsCoords(0, 0), c = this.canvas.transformation.getAbsScale(), h = c * t, i = c * (1 - t) * e + r, d = c * (1 - t) * s + a;
1273
+ const [o, a] = this.canvas.transformation.getAbsCoords(0, 0), c = this.canvas.transformation.getAbsScale(), h = c * t, i = c * (1 - t) * e + o, d = c * (1 - t) * s + a;
1288
1274
  if (this.maxViewScale !== null && h > this.maxViewScale && h > c || this.minViewScale !== null && h < this.minViewScale && h < c)
1289
1275
  return;
1290
1276
  const g = { scale: h, x: i, y: d };
1291
1277
  this.onBeforeTransform({ ...g }) && (this.canvas.patchViewportState(g), this.onTransform(g));
1292
1278
  }
1293
1279
  }
1294
- class nt {
1280
+ class ht {
1295
1281
  constructor() {
1296
1282
  n(this, "coreOptions");
1297
1283
  n(this, "dragOptions");
@@ -1309,21 +1295,21 @@ class nt {
1309
1295
  return this.isTransformable = !0, this.transformOptions = t, this;
1310
1296
  }
1311
1297
  build() {
1312
- let t = new et(this.coreOptions);
1313
- return this.isDraggable && (t = new st(t, this.dragOptions)), this.isTransformable && (t = new ot(t, this.transformOptions)), t;
1298
+ let t = new ot(this.coreOptions);
1299
+ return this.isDraggable && (t = new nt(t, this.dragOptions)), this.isTransformable && (t = new it(t, this.transformOptions)), t;
1314
1300
  }
1315
1301
  }
1316
1302
  export {
1317
- B as BezierEdgeController,
1318
- et as CanvasCore,
1319
- Y as CycleCircleEdgeController,
1320
- G as CycleSquareEdgeController,
1321
- T as EdgeType,
1322
- v as EdgeUtils,
1323
- nt as HtmlGraphBuilder,
1324
- z as StraightEdgeController,
1325
- st as UserDraggableNodesCanvas,
1326
- ot as UserTransformableCanvas,
1327
- X as createBezierEdgeControllerFactory,
1328
- Z as createStraightEdgeControllerFactory
1303
+ G as BezierEdgeController,
1304
+ ot as CanvasCore,
1305
+ Z as CycleCircleEdgeController,
1306
+ U as CycleSquareEdgeController,
1307
+ M as EdgeType,
1308
+ p as EdgeUtils,
1309
+ ht as HtmlGraphBuilder,
1310
+ X as StraightEdgeController,
1311
+ nt as UserDraggableNodesCanvas,
1312
+ it as UserTransformableCanvas,
1313
+ H as createBezierEdgeControllerFactory,
1314
+ q as createStraightEdgeControllerFactory
1329
1315
  };