@html-graph/html-graph 0.0.53 → 0.0.55

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