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