@html-graph/html-graph 0.0.52 → 0.0.54

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