@html-graph/html-graph 0.0.55 → 0.0.56

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 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 = () => {
1
+ var _ = Object.defineProperty;
2
+ var J = (e, t, r) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
+ var h = (e, t, r) => J(e, typeof t != "symbol" ? t + "" : t, r);
4
+ const K = () => {
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
- }, _ = () => {
7
+ }, Q = () => {
8
8
  const e = document.createElement("canvas");
9
9
  return e.style.position = "absolute", e.style.inset = "0", e;
10
- }, J = () => {
10
+ }, Z = () => {
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 K {
14
+ class q {
15
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());
16
+ h(this, "canvasWrapper", null);
17
+ h(this, "host", K());
18
+ h(this, "canvas", Q());
19
+ h(this, "container", Z());
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
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)
@@ -63,7 +63,7 @@ class K {
63
63
  }
64
64
  attachEdge(t) {
65
65
  const s = this.graphStore.getEdge(t).shape.svg;
66
- s.style.position = "absolute", s.style.top = "0", s.style.left = "0", this.edgeIdToElementMap.set(t, s), this.updateEdgeCoords(t), this.updateEdgePriority(t), this.container.appendChild(s);
66
+ this.edgeIdToElementMap.set(t, s), this.container.appendChild(s), this.updateEdgeCoords(t), this.updateEdgePriority(t);
67
67
  }
68
68
  detachEdge(t) {
69
69
  const r = this.edgeIdToElementMap.get(t);
@@ -108,29 +108,29 @@ class K {
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, n = this.graphStore.getNode(t), { x: c, y: h } = n.centerFn(s, o), l = n.x - i * c, d = n.y - i * h;
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: a } = n.centerFn(s, o), l = n.x - i * c, d = n.y - i * a;
112
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(), 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);
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(), a = this.viewportTransformer.getViewportMatrix(), l = a.scale * (i.left - c.left) + a.dx, d = a.scale * (i.top - c.top) + a.dy, g = a.scale * (n.left - c.left) + a.dx, u = a.scale * (n.top - c.top) + a.dy, { x: y, y: w } = s.centerFn(
116
+ i.width * a.scale,
117
+ i.height * a.scale
118
+ ), { x: v, y: p } = o.centerFn(
119
+ n.width * a.scale,
120
+ n.height * a.scale
121
+ ), f = y + l, m = w + d, x = v + g, A = p + u, C = Math.min(f, x), P = Math.min(m, A), T = Math.abs(x - f), L = Math.abs(A - m);
122
122
  r.shape.update(C, P, T, L, s, o);
123
123
  }
124
124
  }
125
- const Y = {
125
+ const G = {
126
126
  scale: 1,
127
127
  dx: 0,
128
128
  dy: 0
129
129
  };
130
- class Q {
130
+ class I {
131
131
  constructor() {
132
- a(this, "viewportMatrix", Y);
133
- a(this, "contentMatrix", Y);
132
+ h(this, "viewportMatrix", G);
133
+ h(this, "contentMatrix", G);
134
134
  }
135
135
  getViewportMatrix() {
136
136
  return this.viewportMatrix;
@@ -160,7 +160,7 @@ class Q {
160
160
  };
161
161
  }
162
162
  }
163
- class Z {
163
+ class tt {
164
164
  constructor(t) {
165
165
  this.transformer = t;
166
166
  }
@@ -171,16 +171,16 @@ class Z {
171
171
  return { ...this.transformer.getContentMatrix() };
172
172
  }
173
173
  }
174
- class q {
174
+ class et {
175
175
  constructor() {
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());
176
+ h(this, "nodes", /* @__PURE__ */ new Map());
177
+ h(this, "ports", /* @__PURE__ */ new Map());
178
+ h(this, "nodePorts", /* @__PURE__ */ new Map());
179
+ h(this, "portNodeId", /* @__PURE__ */ new Map());
180
+ h(this, "edges", /* @__PURE__ */ new Map());
181
+ h(this, "incommingEdges", /* @__PURE__ */ new Map());
182
+ h(this, "outcommingEdges", /* @__PURE__ */ new Map());
183
+ h(this, "cycleEdges", /* @__PURE__ */ new Map());
184
184
  }
185
185
  addNode(t, r, s, o, i, n) {
186
186
  this.nodes.set(t, { element: r, x: s, y: o, centerFn: i, priority: n }), this.nodePorts.set(t, /* @__PURE__ */ new Map());
@@ -292,7 +292,7 @@ class q {
292
292
  }), s;
293
293
  }
294
294
  }
295
- class I {
295
+ class rt {
296
296
  constructor(t) {
297
297
  this.graphStore = t;
298
298
  }
@@ -364,22 +364,41 @@ const M = (e) => {
364
364
  }, E = (e, t, r) => ({
365
365
  x: t.x * e.x - t.y * e.y + ((1 - t.x) * r.x + t.y * r.y),
366
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) => {
367
+ }), S = (e, t, r) => ({ x: t * Math.cos(e), y: r * Math.sin(e) }), b = (e, t, r, s, o) => {
368
368
  const n = [
369
369
  { x: 0, y: 0 },
370
370
  { x: s, y: o },
371
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}`;
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}`, a = `L ${n[1].x} ${n[1].y}`, l = `L ${n[2].x} ${n[2].y}`;
373
+ return `${c} ${a} ${l}`;
374
+ }, D = (e, t) => {
375
+ const r = [];
376
+ 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) {
377
+ const s = e.length - 1;
378
+ let o = 0, i = 0, n = 0;
379
+ e.forEach((c, a) => {
380
+ let l = 0, d = 0, g = 0;
381
+ const u = a > 0, y = a < s, w = u && y;
382
+ if (u && (l = -o, d = -i, g = n), y) {
383
+ const C = e[a + 1];
384
+ o = C.x - c.x, i = C.y - c.y, n = Math.sqrt(o * o + i * i);
385
+ }
386
+ const p = Math.min((w ? t : 0) / n, a < s - 1 ? 0.5 : 1), f = w ? { x: c.x + o * p, y: c.y + i * p } : c, x = Math.min((w ? t : 0) / g, a > 1 ? 0.5 : 1), A = w ? { x: c.x + l * x, y: c.y + d * x } : c;
387
+ a > 0 && r.push(`L ${A.x} ${A.y}`), w && r.push(
388
+ `C ${c.x} ${c.y} ${c.x} ${c.y} ${f.x} ${f.y}`
389
+ );
390
+ });
391
+ }
392
+ return r.join(" ");
374
393
  };
375
- class tt {
394
+ class st {
376
395
  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(
396
+ h(this, "svg");
397
+ h(this, "group");
398
+ h(this, "line");
399
+ h(this, "sourceArrow", null);
400
+ h(this, "targetArrow", null);
401
+ 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.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
383
402
  "http://www.w3.org/2000/svg",
384
403
  "path"
385
404
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = document.createElementNS(
@@ -389,28 +408,28 @@ class tt {
389
408
  }
390
409
  update(t, r, s, o, i, n) {
391
410
  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;
411
+ const c = M(i), a = M(n), l = c.x <= a.x ? 1 : -1, d = c.y <= a.y ? 1 : -1;
393
412
  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, {
413
+ const g = S(i.direction, l, d), u = S(n.direction, l, d), y = E({ x: this.arrowLength, y: 0 }, g, {
395
414
  x: 0,
396
415
  y: 0
397
416
  }), w = E(
398
417
  { x: s - this.arrowLength, y: o },
399
- g,
418
+ u,
400
419
  {
401
420
  x: s,
402
421
  y: o
403
422
  }
404
423
  ), 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}`;
424
+ x: y.x + g.x * this.curvature,
425
+ y: y.y + g.y * this.curvature
426
+ }, p = {
427
+ x: w.x - u.x * this.curvature,
428
+ y: w.y - u.y * this.curvature
429
+ }, f = `M ${y.x} ${y.y} C ${v.x} ${v.y}, ${p.x} ${p.y}, ${w.x} ${w.y}`, m = this.sourceArrow ? "" : `M 0 0 L ${y.x} ${y.y} `, x = this.targetArrow ? "" : ` M ${w.x} ${w.y} L ${s} ${o}`, A = `${m}${f}${x}`;
411
430
  if (this.line.setAttribute("d", A), this.sourceArrow) {
412
- const C = N(
413
- u,
431
+ const C = b(
432
+ g,
414
433
  0,
415
434
  0,
416
435
  this.arrowLength,
@@ -419,8 +438,8 @@ class tt {
419
438
  this.sourceArrow.setAttribute("d", C);
420
439
  }
421
440
  if (this.targetArrow) {
422
- const C = N(
423
- g,
441
+ const C = b(
442
+ u,
424
443
  s,
425
444
  o,
426
445
  -this.arrowLength,
@@ -430,34 +449,14 @@ class tt {
430
449
  }
431
450
  }
432
451
  }
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);
444
- }
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}`
448
- );
449
- });
450
- }
451
- return r.join(" ");
452
- };
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(
452
+ class ot {
453
+ constructor(t, r, s, o, i, n, c, a) {
454
+ h(this, "svg");
455
+ h(this, "group");
456
+ h(this, "line");
457
+ h(this, "sourceArrow", null);
458
+ h(this, "targetArrow", null);
459
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
461
460
  "http://www.w3.org/2000/svg",
462
461
  "path"
463
462
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = document.createElementNS(
@@ -467,21 +466,21 @@ class et {
467
466
  }
468
467
  update(t, r, s, o, i, n) {
469
468
  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;
469
+ const c = M(i), a = M(n), l = c.x <= a.x ? 1 : -1, d = c.y <= a.y ? 1 : -1;
471
470
  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, {
471
+ const g = S(i.direction, l, d), u = S(n.direction, l, d), y = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, g, {
473
472
  x: 0,
474
473
  y: 0
475
- }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, g, {
474
+ }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, u, {
476
475
  x: s,
477
476
  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, {
477
+ }) : { x: s, y: o }, v = this.arrowLength + this.arrowOffset, p = E({ x: v, y: 0 }, g, { x: 0, y: 0 }), f = E({ x: s - v, y: o }, u, {
479
478
  x: s,
480
479
  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
+ }), m = D([y, p, f, w], this.roundness);
481
+ if (this.line.setAttribute("d", m), this.sourceArrow) {
482
+ const x = b(
483
+ g,
485
484
  0,
486
485
  0,
487
486
  this.arrowLength,
@@ -490,8 +489,8 @@ class et {
490
489
  this.sourceArrow.setAttribute("d", x);
491
490
  }
492
491
  if (this.targetArrow) {
493
- const x = N(
494
- g,
492
+ const x = b(
493
+ u,
495
494
  s,
496
495
  o,
497
496
  -this.arrowLength,
@@ -501,14 +500,14 @@ class et {
501
500
  }
502
501
  }
503
502
  }
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(
503
+ class it {
504
+ constructor(t, r, s, o, i, n, c, a) {
505
+ h(this, "svg");
506
+ h(this, "group");
507
+ h(this, "line");
508
+ h(this, "sourceArrow", null);
509
+ h(this, "targetArrow", null);
510
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
512
511
  "http://www.w3.org/2000/svg",
513
512
  "path"
514
513
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = document.createElementNS(
@@ -518,24 +517,24 @@ class rt {
518
517
  }
519
518
  update(t, r, s, o, i, n) {
520
519
  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;
520
+ const c = M(i), a = M(n), l = c.x <= a.x ? 1 : -1, d = c.y <= a.y ? 1 : -1;
522
521
  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, {
522
+ const g = S(i.direction, l, d), u = S(n.direction, l, d), y = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, g, {
524
523
  x: 0,
525
524
  y: 0
526
- }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, g, {
525
+ }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, u, {
527
526
  x: s,
528
527
  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, {
528
+ }) : { x: s, y: o }, v = this.arrowLength + this.arrowOffset, p = E({ x: v, y: 0 }, g, { x: 0, y: 0 }), f = E({ x: s - v, y: o }, u, {
530
529
  x: s,
531
530
  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],
531
+ }), m = Math.max((p.x + f.x) / 2, v), x = o / 2, A = { x: l > 0 ? m : -v, y: p.y }, C = { x: A.x, y: x }, P = { x: l > 0 ? s - m : s + v, y: f.y }, T = { x: P.x, y: x }, L = D(
532
+ [y, p, A, C, T, P, f, w],
534
533
  this.roundness
535
534
  );
536
535
  if (this.line.setAttribute("d", L), this.sourceArrow) {
537
- const $ = N(
538
- u,
536
+ const $ = b(
537
+ g,
539
538
  0,
540
539
  0,
541
540
  this.arrowLength,
@@ -544,8 +543,8 @@ class rt {
544
543
  this.sourceArrow.setAttribute("d", $);
545
544
  }
546
545
  if (this.targetArrow) {
547
- const $ = N(
548
- g,
546
+ const $ = b(
547
+ u,
549
548
  s,
550
549
  o,
551
550
  -this.arrowLength,
@@ -555,14 +554,14 @@ class rt {
555
554
  }
556
555
  }
557
556
  }
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(
557
+ class nt {
558
+ constructor(t, r, s, o, i, n, c, a) {
559
+ h(this, "svg");
560
+ h(this, "group");
561
+ h(this, "line");
562
+ h(this, "sourceArrow", null);
563
+ h(this, "targetArrow", null);
564
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
566
565
  "http://www.w3.org/2000/svg",
567
566
  "path"
568
567
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = document.createElementNS(
@@ -572,27 +571,27 @@ class st {
572
571
  }
573
572
  update(t, r, s, o, i, n) {
574
573
  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;
574
+ const c = M(i), a = M(n), l = c.x <= a.x ? 1 : -1, d = c.y <= a.y ? 1 : -1;
576
575
  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, {
576
+ const g = S(i.direction, l, d), u = S(n.direction, l, d), y = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, g, {
578
577
  x: 0,
579
578
  y: 0
580
- }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, g, {
579
+ }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, u, {
581
580
  x: s,
582
581
  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, {
582
+ }) : { x: s, y: o }, v = this.arrowLength + this.arrowOffset, p = E({ x: v, y: 0 }, g, { x: 0, y: 0 }), f = E({ x: s - v, y: o }, u, {
584
583
  x: s,
585
584
  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 = {
585
+ }), m = Math.max((p.y + f.y) / 2, v), x = s / 2, A = { x: p.x, y: d > 0 ? m : -v }, C = { x, y: A.y }, P = {
587
586
  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],
587
+ y: d > 0 ? o - m : o + v
588
+ }, T = { x, y: P.y }, L = D(
589
+ [y, p, A, C, T, P, f, w],
591
590
  this.roundness
592
591
  );
593
592
  if (this.line.setAttribute("d", L), this.sourceArrow) {
594
- const $ = N(
595
- u,
593
+ const $ = b(
594
+ g,
596
595
  0,
597
596
  0,
598
597
  this.arrowLength,
@@ -601,8 +600,8 @@ class st {
601
600
  this.sourceArrow.setAttribute("d", $);
602
601
  }
603
602
  if (this.targetArrow) {
604
- const $ = N(
605
- g,
603
+ const $ = b(
604
+ u,
606
605
  s,
607
606
  o,
608
607
  -this.arrowLength,
@@ -612,64 +611,64 @@ class st {
612
611
  }
613
612
  }
614
613
  }
615
- class ot {
614
+ class ht {
616
615
  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(
616
+ h(this, "svg");
617
+ h(this, "group");
618
+ h(this, "line");
619
+ h(this, "arrow", null);
620
+ 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.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
622
621
  "http://www.w3.org/2000/svg",
623
622
  "path"
624
623
  ), 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";
625
624
  }
626
625
  update(t, r, s, o, i) {
627
626
  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 = [
627
+ const n = S(i.direction, 1, 1), c = this.smallRadius, a = this.radius, l = Math.sqrt(c * c + a * a), d = c + a, g = this.arrowLength + l * (1 - a / d), u = c * a / d, w = [
629
628
  { x: this.arrowLength, y: 0 },
630
- { x: u, y: g },
631
- { x: u, y: -g }
629
+ { x: g, y: u },
630
+ { x: g, y: -u }
632
631
  ].map(
633
- (p) => E(p, n, { x: 0, y: 0 })
632
+ (m) => E(m, n, { x: 0, y: 0 })
634
633
  ), v = [
635
634
  `M ${w[0].x} ${w[0].y}`,
636
635
  `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}`,
636
+ `A ${a} ${a} 0 1 0 ${w[2].x} ${w[2].y}`,
638
637
  `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}`;
638
+ ].join(" "), p = `M 0 0 L ${w[0].x} ${w[0].y} `, f = `${this.arrow !== null ? "" : p}${v}`;
640
639
  if (this.line.setAttribute("d", f), this.arrow) {
641
- const p = N(
640
+ const m = b(
642
641
  n,
643
642
  0,
644
643
  0,
645
644
  this.arrowLength,
646
645
  this.arrowWidth
647
646
  );
648
- this.arrow.setAttribute("d", p);
647
+ this.arrow.setAttribute("d", m);
649
648
  }
650
649
  }
651
650
  }
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(
651
+ class z {
652
+ constructor(t, r, s, o, i, n, c, a) {
653
+ h(this, "svg");
654
+ h(this, "group");
655
+ h(this, "line");
656
+ h(this, "arrow", null);
657
+ h(this, "roundness");
658
+ h(this, "linePoints");
659
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.side = n, this.minPortOffset = c, this.roundness = Math.min(a, this.minPortOffset, this.side / 2), this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
661
660
  "http://www.w3.org/2000/svg",
662
661
  "path"
663
662
  ), 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";
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 = [
663
+ const l = this.minPortOffset, d = this.side, g = this.arrowLength + l, u = this.roundness, y = g + 2 * d;
664
+ console.log(u), this.linePoints = [
666
665
  { x: this.arrowLength, y: 0 },
667
- { x: u, y: 0 },
668
- { x: u, y: this.side },
666
+ { x: g, y: 0 },
667
+ { x: g, y: this.side },
669
668
  { x: y, y: this.side },
670
669
  { x: y, y: -this.side },
671
- { x: u, y: -this.side },
672
- { x: u, y: 0 },
670
+ { x: g, y: -this.side },
671
+ { x: g, y: 0 },
673
672
  { x: this.arrowLength, y: 0 }
674
673
  ];
675
674
  }
@@ -677,9 +676,9 @@ class k {
677
676
  this.svg.style.transform = `translate(${t}px, ${r}px)`;
678
677
  const n = S(i.direction, 1, 1), c = this.linePoints.map(
679
678
  (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)}`;
679
+ ), a = `M 0 0 L ${c[0].x} ${c[0].y} `, l = `${this.arrow ? "" : a}${D(c, this.roundness)}`;
681
680
  if (this.line.setAttribute("d", l), this.arrow) {
682
- const d = N(
681
+ const d = b(
683
682
  n,
684
683
  0,
685
684
  0,
@@ -690,16 +689,16 @@ class k {
690
689
  }
691
690
  }
692
691
  }
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(
692
+ class B {
693
+ constructor(t, r, s, o, i, n, c, a, l, d) {
694
+ h(this, "svg");
695
+ h(this, "group");
696
+ h(this, "line");
697
+ h(this, "sourceArrow", null);
698
+ h(this, "targetArrow", null);
699
+ h(this, "detourX");
700
+ h(this, "detourY");
701
+ this.color = t, this.width = r, this.arrowLength = s, this.arrowWidth = o, this.arrowOffset = i, this.roundness = a, 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.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
703
702
  "http://www.w3.org/2000/svg",
704
703
  "path"
705
704
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = document.createElementNS(
@@ -709,31 +708,31 @@ class R {
709
708
  }
710
709
  update(t, r, s, o, i, n) {
711
710
  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;
711
+ const c = M(i), a = M(n), l = c.x <= a.x ? 1 : -1, d = c.y <= a.y ? 1 : -1;
713
712
  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, {
713
+ const g = S(i.direction, l, d), u = S(n.direction, l, d), y = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, g, {
715
714
  x: 0,
716
715
  y: 0
717
- }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, g, {
716
+ }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, u, {
718
717
  x: s,
719
718
  y: o
720
- }) : { x: s, y: o }, v = this.arrowLength + this.arrowOffset, m = E({ x: v, y: 0 }, u, {
719
+ }) : { x: s, y: o }, v = this.arrowLength + this.arrowOffset, p = E({ x: v, y: 0 }, g, {
721
720
  x: 0,
722
721
  y: 0
723
- }), f = { x: m.x + this.detourX, y: m.y + this.detourY }, p = E(
722
+ }), f = { x: p.x + this.detourX, y: p.y + this.detourY }, m = E(
724
723
  { x: s - v, y: o },
725
- g,
724
+ u,
726
725
  {
727
726
  x: s,
728
727
  y: o
729
728
  }
730
- ), x = { x: p.x + this.detourX, y: p.y + this.detourY }, A = F(
731
- [y, m, f, x, p, w],
729
+ ), x = { x: m.x + this.detourX, y: m.y + this.detourY }, A = D(
730
+ [y, p, f, x, m, w],
732
731
  this.roundness
733
732
  );
734
733
  if (this.line.setAttribute("d", A), this.sourceArrow) {
735
- const C = N(
736
- u,
734
+ const C = b(
735
+ g,
737
736
  0,
738
737
  0,
739
738
  this.arrowLength,
@@ -742,8 +741,8 @@ class R {
742
741
  this.sourceArrow.setAttribute("d", C);
743
742
  }
744
743
  if (this.targetArrow) {
745
- const C = N(
746
- g,
744
+ const C = b(
745
+ u,
747
746
  s,
748
747
  o,
749
748
  -this.arrowLength,
@@ -753,17 +752,17 @@ class R {
753
752
  }
754
753
  }
755
754
  }
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(
755
+ var N = /* @__PURE__ */ ((e) => (e.Regular = "regular", e.PortCycle = "port-cycle", e.NodeCycle = "node-cycle", e))(N || {});
756
+ class at {
757
+ constructor(t, r, s, o, i, n, c, a, l) {
758
+ h(this, "svg");
759
+ h(this, "group");
760
+ h(this, "line");
761
+ h(this, "sourceArrow", null);
762
+ h(this, "targetArrow", null);
763
+ h(this, "detourX");
764
+ h(this, "detourY");
765
+ this.color = t, this.width = r, this.curvature = s, this.arrowLength = o, this.arrowWidth = i, this.detourX = Math.cos(l) * a, this.detourY = Math.sin(l) * a, this.svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"), this.svg.style.pointerEvents = "none", this.svg.style.position = "absolute", this.svg.style.top = "0", this.svg.style.left = "0", 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(
767
766
  "http://www.w3.org/2000/svg",
768
767
  "path"
769
768
  ), this.sourceArrow.setAttribute("fill", this.color), this.group.appendChild(this.sourceArrow)), c && (this.targetArrow = document.createElementNS(
@@ -773,60 +772,60 @@ class it {
773
772
  }
774
773
  update(t, r, s, o, i, n) {
775
774
  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;
775
+ const c = M(i), a = M(n), l = c.x <= a.x ? 1 : -1, d = c.y <= a.y ? 1 : -1;
777
776
  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, {
777
+ const g = S(i.direction, l, d), u = S(n.direction, l, d), y = this.sourceArrow ? E({ x: this.arrowLength, y: 0 }, g, {
779
778
  x: 0,
780
779
  y: 0
781
- }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, g, {
780
+ }) : { x: 0, y: 0 }, w = this.targetArrow ? E({ x: s - this.arrowLength, y: o }, u, {
782
781
  x: s,
783
782
  y: o
784
- }) : { x: s, y: o }, v = this.arrowLength, m = E({ x: v, y: 0 }, u, {
783
+ }) : { x: s, y: o }, v = this.arrowLength, p = E({ x: v, y: 0 }, g, {
785
784
  x: 0,
786
785
  y: 0
787
- }), f = { x: m.x + this.detourX, y: m.y + this.detourY }, p = E(
786
+ }), f = { x: p.x + this.detourX, y: p.y + this.detourY }, m = E(
788
787
  { x: s - v, y: o },
789
- g,
788
+ u,
790
789
  {
791
790
  x: s,
792
791
  y: o
793
792
  }
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)
793
+ ), x = { x: m.x + this.detourX, y: m.y + this.detourY }, A = { x: (f.x + x.x) / 2, y: (f.y + x.y) / 2 }, C = {
794
+ x: p.x - this.curvature * Math.cos(i.direction),
795
+ y: p.y - this.curvature * Math.sin(i.direction)
797
796
  }, 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 }, $ = [
797
+ x: m.x + this.curvature * Math.cos(n.direction),
798
+ y: m.y + this.curvature * Math.sin(n.direction)
799
+ }, T = { x: p.x + this.detourX, y: p.y + this.detourY }, L = { x: m.x + this.detourX, y: m.y + this.detourY }, $ = [
801
800
  `M ${y.x} ${y.y}`,
802
- `L ${m.x} ${m.y}`,
801
+ `L ${p.x} ${p.y}`,
803
802
  `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}`,
803
+ `C ${L.x} ${L.y} ${P.x} ${P.y} ${m.x} ${m.y}`,
805
804
  `L ${w.x} ${w.y}`
806
805
  ].join(" ");
807
806
  if (this.line.setAttribute("d", $), this.sourceArrow) {
808
- const V = N(
809
- u,
807
+ const k = b(
808
+ g,
810
809
  0,
811
810
  0,
812
811
  this.arrowLength,
813
812
  this.arrowWidth
814
813
  );
815
- this.sourceArrow.setAttribute("d", V);
814
+ this.sourceArrow.setAttribute("d", k);
816
815
  }
817
816
  if (this.targetArrow) {
818
- const V = N(
819
- g,
817
+ const k = b(
818
+ u,
820
819
  s,
821
820
  o,
822
821
  -this.arrowLength,
823
822
  this.arrowWidth
824
823
  );
825
- this.targetArrow.setAttribute("d", V);
824
+ this.targetArrow.setAttribute("d", k);
826
825
  }
827
826
  }
828
827
  }
829
- const nt = (e) => (t) => t === b.PortCycle ? new ot(
828
+ const ct = (e) => (t) => t === N.PortCycle ? new ht(
830
829
  e.color,
831
830
  e.width,
832
831
  e.arrowLength,
@@ -834,7 +833,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
834
833
  e.hasSourceArrow || e.hasTargetArrow,
835
834
  e.cycleRadius,
836
835
  e.smallCycleRadius
837
- ) : t === b.NodeCycle ? new it(
836
+ ) : t === N.NodeCycle ? new at(
838
837
  e.color,
839
838
  e.width,
840
839
  e.curvature,
@@ -844,7 +843,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
844
843
  e.hasTargetArrow,
845
844
  e.detourDistance,
846
845
  e.detourDirection
847
- ) : new tt(
846
+ ) : new st(
848
847
  e.color,
849
848
  e.width,
850
849
  e.curvature,
@@ -852,7 +851,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
852
851
  e.arrowWidth,
853
852
  e.hasSourceArrow,
854
853
  e.hasTargetArrow
855
- ), at = (e) => (t) => t === b.PortCycle ? new k(
854
+ ), lt = (e) => (t) => t === N.PortCycle ? new z(
856
855
  e.color,
857
856
  e.width,
858
857
  e.arrowLength,
@@ -861,7 +860,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
861
860
  e.cycleSquareSide,
862
861
  e.arrowOffset,
863
862
  e.roundness
864
- ) : t === b.NodeCycle ? new R(
863
+ ) : t === N.NodeCycle ? new B(
865
864
  e.color,
866
865
  e.width,
867
866
  e.arrowLength,
@@ -872,7 +871,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
872
871
  e.roundness,
873
872
  e.detourDistance,
874
873
  e.detourDirection
875
- ) : new et(
874
+ ) : new ot(
876
875
  e.color,
877
876
  e.width,
878
877
  e.arrowLength,
@@ -881,7 +880,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
881
880
  e.hasSourceArrow,
882
881
  e.hasTargetArrow,
883
882
  e.roundness
884
- ), ht = (e) => (t) => t === b.PortCycle ? new k(
883
+ ), dt = (e) => (t) => t === N.PortCycle ? new z(
885
884
  e.color,
886
885
  e.width,
887
886
  e.arrowLength,
@@ -890,7 +889,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
890
889
  e.cycleSquareSide,
891
890
  e.arrowOffset,
892
891
  e.roundness
893
- ) : t === b.NodeCycle ? new R(
892
+ ) : t === N.NodeCycle ? new B(
894
893
  e.color,
895
894
  e.width,
896
895
  e.arrowLength,
@@ -901,7 +900,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
901
900
  e.roundness,
902
901
  e.detourDistance,
903
902
  e.detourDirection
904
- ) : new rt(
903
+ ) : new it(
905
904
  e.color,
906
905
  e.width,
907
906
  e.arrowLength,
@@ -910,7 +909,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
910
909
  e.hasSourceArrow,
911
910
  e.hasTargetArrow,
912
911
  e.roundness
913
- ), ct = (e) => (t) => t === b.PortCycle ? new k(
912
+ ), gt = (e) => (t) => t === N.PortCycle ? new z(
914
913
  e.color,
915
914
  e.width,
916
915
  e.arrowLength,
@@ -919,7 +918,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
919
918
  e.cycleSquareSide,
920
919
  e.arrowOffset,
921
920
  e.roundness
922
- ) : t === b.NodeCycle ? new R(
921
+ ) : t === N.NodeCycle ? new B(
923
922
  e.color,
924
923
  e.width,
925
924
  e.arrowLength,
@@ -930,7 +929,7 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
930
929
  e.roundness,
931
930
  e.detourDistance,
932
931
  e.detourDirection
933
- ) : new st(
932
+ ) : new nt(
934
933
  e.color,
935
934
  e.width,
936
935
  e.arrowLength,
@@ -940,9 +939,9 @@ const nt = (e) => (t) => t === b.PortCycle ? new ot(
940
939
  e.hasTargetArrow,
941
940
  e.roundness
942
941
  );
943
- class D {
942
+ class F {
944
943
  constructor() {
945
- a(this, "counter", 0);
944
+ h(this, "counter", 0);
946
945
  }
947
946
  create() {
948
947
  const t = this.counter;
@@ -952,12 +951,12 @@ class D {
952
951
  this.counter = 0;
953
952
  }
954
953
  }
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;
954
+ class ut {
955
+ constructor(t, r, s, o, i, n, c, a) {
956
+ h(this, "nodeIdGenerator", new F());
957
+ h(this, "portIdGenerator", new F());
958
+ h(this, "edgeIdGenerator", new F());
959
+ this.graphStore = t, this.htmlController = r, this.viewportTransformer = s, this.nodesCenterFn = o, this.portsCenterFn = i, this.portsDirection = n, this.nodesPriorityFn = c, this.edgesPriorityFn = a;
961
960
  }
962
961
  addNode(t, r, s, o, i, n, c) {
963
962
  if (t === void 0)
@@ -973,19 +972,13 @@ class lt {
973
972
  o,
974
973
  n ?? this.nodesCenterFn,
975
974
  c ?? this.nodesPriorityFn()
976
- ), this.htmlController.attachNode(t), new Map(i ?? []).forEach((l, d) => {
977
- l instanceof HTMLElement ? this.markPort(
978
- d,
979
- l,
975
+ ), this.htmlController.attachNode(t), Array.from(i ?? []).forEach((a) => {
976
+ this.markPort(
977
+ a.id ?? this.generatePortId(),
978
+ a.element,
980
979
  t,
981
- this.portsCenterFn,
982
- this.portsDirection
983
- ) : this.markPort(
984
- d,
985
- l.element,
986
- t,
987
- l.centerFn ?? this.portsCenterFn,
988
- l.direction ?? this.portsDirection
980
+ a.centerFn ?? this.portsCenterFn,
981
+ a.direction ?? this.portsDirection
989
982
  );
990
983
  });
991
984
  }
@@ -1036,9 +1029,8 @@ class lt {
1036
1029
  throw new Error("failed to add edge to nonexisting port");
1037
1030
  if (this.graphStore.getEdge(t) !== void 0)
1038
1031
  throw new Error("failed to add edge with existing id");
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(
1032
+ const n = this.resolveEdgeType(r, s);
1033
+ this.graphStore.addEdge(
1042
1034
  t,
1043
1035
  r,
1044
1036
  s,
@@ -1046,11 +1038,15 @@ class lt {
1046
1038
  i ?? this.edgesPriorityFn()
1047
1039
  ), this.htmlController.attachEdge(t);
1048
1040
  }
1049
- updateEdge(t, r) {
1050
- const s = this.graphStore.getEdge(t);
1051
- if (s === void 0)
1041
+ updateEdge(t, r, s) {
1042
+ const o = this.graphStore.getEdge(t);
1043
+ if (o === void 0)
1052
1044
  throw new Error("failed to update nonexisting edge");
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));
1045
+ if (r !== void 0) {
1046
+ const i = this.resolveEdgeType(o.from, o.to);
1047
+ this.htmlController.detachEdge(t), o.shape = r(i), this.htmlController.attachEdge(t);
1048
+ }
1049
+ s !== void 0 && (o.priority = s, this.htmlController.updateEdgePriority(t));
1054
1050
  }
1055
1051
  removeEdge(t) {
1056
1052
  if (this.graphStore.getEdge(t) === void 0)
@@ -1080,24 +1076,36 @@ class lt {
1080
1076
  destroy() {
1081
1077
  this.htmlController.destroy();
1082
1078
  }
1079
+ generatePortId() {
1080
+ let t;
1081
+ do
1082
+ t = this.nodeIdGenerator.create();
1083
+ while (this.graphStore.getPort(t) !== void 0);
1084
+ return t;
1085
+ }
1086
+ resolveEdgeType(t, r) {
1087
+ let s = N.Regular;
1088
+ const o = this.graphStore.getPortNode(t), i = this.graphStore.getPortNode(r);
1089
+ return t === r ? s = N.PortCycle : o === i && (s = N.NodeCycle), s;
1090
+ }
1083
1091
  }
1084
- class dt {
1092
+ class wt {
1085
1093
  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(
1094
+ h(this, "publicViewportTransformer");
1095
+ h(this, "publicGraphStore");
1096
+ h(this, "canvasController");
1097
+ const c = new I(), a = new et();
1098
+ this.publicGraphStore = new rt(a), this.publicViewportTransformer = new tt(
1091
1099
  c
1092
1100
  );
1093
- const l = new K(
1094
- h,
1101
+ const l = new q(
1102
+ a,
1095
1103
  c,
1096
1104
  this.publicViewportTransformer,
1097
1105
  t
1098
1106
  );
1099
- this.canvasController = new lt(
1100
- h,
1107
+ this.canvasController = new ut(
1108
+ a,
1101
1109
  l,
1102
1110
  c,
1103
1111
  r,
@@ -1108,24 +1116,24 @@ class dt {
1108
1116
  );
1109
1117
  }
1110
1118
  }
1111
- const X = (e, t) => ({
1119
+ const j = (e, t) => ({
1112
1120
  x: e / 2,
1113
1121
  y: t / 2
1114
- }), ut = () => () => {
1115
- }, gt = (e, t, r, s, o, i) => {
1122
+ }), pt = () => () => {
1123
+ }, mt = (e, t, r, s, o, i) => {
1116
1124
  e.clearRect(0, 0, e.canvas.width, e.canvas.height), e.fillStyle = i, e.fillRect(0, 0, e.canvas.width, e.canvas.height);
1117
1125
  const n = t.getContentMatrix(), c = s * n.scale;
1118
- let h = 0, l = 0, d = c / 2;
1126
+ let a = 0, l = 0, d = c / 2;
1119
1127
  do
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;
1128
+ d *= 2, a = e.canvas.width / d, l = e.canvas.height / d;
1129
+ while (a * l > 1e4);
1130
+ const g = n.dx - Math.floor(n.dx / d) * d, u = n.dy - Math.floor(n.dy / d) * d, y = o * n.scale, w = 2 * Math.PI, v = g - d, p = u - d, f = e.canvas.width + g, m = e.canvas.height + u;
1123
1131
  e.fillStyle = r;
1124
1132
  for (let x = v; x <= f; x += d)
1125
- for (let A = m; A <= p; A += d)
1133
+ for (let A = p; A <= m; A += d)
1126
1134
  e.beginPath(), e.arc(x, A, y, 0, w), e.closePath(), e.fill();
1127
- }, wt = (e, t, r, s) => (o, i) => {
1128
- gt(
1135
+ }, vt = (e, t, r, s) => (o, i) => {
1136
+ mt(
1129
1137
  o,
1130
1138
  i,
1131
1139
  e,
@@ -1133,26 +1141,26 @@ const X = (e, t) => ({
1133
1141
  r,
1134
1142
  s
1135
1143
  );
1136
- }, mt = (e) => {
1144
+ }, yt = (e) => {
1137
1145
  switch (e == null ? void 0 : e.type) {
1138
1146
  case "custom":
1139
1147
  return e.drawingFn;
1140
1148
  case "dots":
1141
- return wt(
1149
+ return vt(
1142
1150
  e.dotColor ?? "#d8d8d8",
1143
1151
  e.dotGap ?? 25,
1144
1152
  e.dotRadius ?? 1.5,
1145
1153
  e.color ?? "#ffffff"
1146
1154
  );
1147
1155
  default:
1148
- return ut();
1156
+ return pt();
1149
1157
  }
1150
- }, G = (e) => {
1158
+ }, Y = (e) => {
1151
1159
  switch (e == null ? void 0 : e.type) {
1152
1160
  case "custom":
1153
- return e.controllerFactory;
1161
+ return e.factory;
1154
1162
  case "straight":
1155
- return at({
1163
+ return lt({
1156
1164
  color: e.color ?? "#5c5c5c",
1157
1165
  width: e.width ?? 1,
1158
1166
  arrowLength: e.arrowLength ?? 15,
@@ -1166,7 +1174,7 @@ const X = (e, t) => ({
1166
1174
  detourDirection: e.detourDirection ?? -Math.PI / 2
1167
1175
  });
1168
1176
  case "horizontal":
1169
- return ht({
1177
+ return dt({
1170
1178
  color: e.color ?? "#5c5c5c",
1171
1179
  width: e.width ?? 1,
1172
1180
  arrowLength: e.arrowLength ?? 15,
@@ -1180,7 +1188,7 @@ const X = (e, t) => ({
1180
1188
  detourDirection: e.detourDirection ?? -Math.PI / 2
1181
1189
  });
1182
1190
  case "vertical":
1183
- return ct({
1191
+ return gt({
1184
1192
  color: e.color ?? "#5c5c5c",
1185
1193
  width: e.width ?? 1,
1186
1194
  arrowLength: e.arrowLength ?? 15,
@@ -1194,7 +1202,7 @@ const X = (e, t) => ({
1194
1202
  detourDirection: e.detourDirection ?? -Math.PI / 2
1195
1203
  });
1196
1204
  default:
1197
- return nt({
1205
+ return ct({
1198
1206
  color: e.color ?? "#5c5c5c",
1199
1207
  width: e.width ?? 1,
1200
1208
  curvature: e.curvature ?? 90,
@@ -1208,52 +1216,52 @@ const X = (e, t) => ({
1208
1216
  detourDirection: e.detourDirection ?? -Math.PI / 2
1209
1217
  });
1210
1218
  }
1211
- }, O = (e) => () => e, z = O(0), W = () => {
1219
+ }, X = (e) => () => e, H = X(0), R = () => {
1212
1220
  let e = 0;
1213
1221
  return () => e++;
1214
- }, pt = (e, t) => {
1222
+ }, ft = (e, t) => {
1215
1223
  const r = [
1216
- z,
1217
- z
1224
+ H,
1225
+ H
1218
1226
  ];
1219
- e === "incremental" && (r[0] = W()), t === "incremental" && (r[1] = W());
1220
- const s = W();
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(
1227
+ e === "incremental" && (r[0] = R()), t === "incremental" && (r[1] = R());
1228
+ const s = R();
1229
+ return e === "shared-incremental" && (r[0] = s), t === "shared-incremental" && (r[1] = s), typeof e == "number" && (r[0] = X(e)), typeof t == "number" && (r[1] = X(t)), typeof e == "function" && (r[0] = e), typeof t == "function" && (r[1] = t), r;
1230
+ }, xt = (e) => {
1231
+ var s, o, i, n, c, a;
1232
+ const [t, r] = ft(
1225
1233
  (s = e.nodes) == null ? void 0 : s.priority,
1226
1234
  (o = e.edges) == null ? void 0 : o.priority
1227
1235
  );
1228
1236
  return {
1229
1237
  background: {
1230
- drawingFn: mt(
1238
+ drawingFn: yt(
1231
1239
  e.background ?? { type: "none" }
1232
1240
  )
1233
1241
  },
1234
1242
  nodes: {
1235
- centerFn: ((i = e.nodes) == null ? void 0 : i.centerFn) ?? X,
1243
+ centerFn: ((i = e.nodes) == null ? void 0 : i.centerFn) ?? j,
1236
1244
  priorityFn: t
1237
1245
  },
1238
1246
  ports: {
1239
- centerFn: ((n = e.ports) == null ? void 0 : n.centerFn) ?? X,
1247
+ centerFn: ((n = e.ports) == null ? void 0 : n.centerFn) ?? j,
1240
1248
  direction: ((c = e.ports) == null ? void 0 : c.direction) ?? 0
1241
1249
  },
1242
1250
  edges: {
1243
- shapeFactory: G(((h = e.edges) == null ? void 0 : h.shape) ?? {}),
1251
+ shapeFactory: Y(((a = e.edges) == null ? void 0 : a.shape) ?? {}),
1244
1252
  priorityFn: r
1245
1253
  }
1246
1254
  };
1247
1255
  };
1248
- class yt {
1256
+ class Et {
1249
1257
  constructor(t) {
1250
- a(this, "transformation");
1251
- a(this, "model");
1252
- a(this, "di");
1253
- a(this, "edgeShapeFactory");
1258
+ h(this, "transformation");
1259
+ h(this, "model");
1260
+ h(this, "di");
1261
+ h(this, "edgeShapeFactory");
1254
1262
  this.apiOptions = t;
1255
- const r = vt(this.apiOptions ?? {});
1256
- this.di = new dt(
1263
+ const r = xt(this.apiOptions ?? {});
1264
+ this.di = new wt(
1257
1265
  r.background.drawingFn,
1258
1266
  r.nodes.centerFn,
1259
1267
  r.ports.centerFn,
@@ -1301,7 +1309,7 @@ class yt {
1301
1309
  return this.di.canvasController.unmarkPort(t), this;
1302
1310
  }
1303
1311
  addEdge(t) {
1304
- const r = t.options !== void 0 ? G(t.options) : this.edgeShapeFactory;
1312
+ const r = t.shape !== void 0 ? Y(t.shape) : this.edgeShapeFactory;
1305
1313
  return this.di.canvasController.addEdge(
1306
1314
  t.id,
1307
1315
  t.from,
@@ -1311,7 +1319,8 @@ class yt {
1311
1319
  ), this;
1312
1320
  }
1313
1321
  updateEdge(t, r) {
1314
- return this.di.canvasController.updateEdge(t, r), this;
1322
+ const s = r.shape !== void 0 ? Y(r.shape) : void 0;
1323
+ return this.di.canvasController.updateEdge(t, s, r.priority), this;
1315
1324
  }
1316
1325
  removeEdge(t) {
1317
1326
  return this.di.canvasController.removeEdge(t), this;
@@ -1343,50 +1352,65 @@ class yt {
1343
1352
  this.di.canvasController.destroy();
1344
1353
  }
1345
1354
  }
1346
- class ft {
1355
+ const V = (e, t, r) => {
1356
+ const { x: s, y: o, width: i, height: n } = e.getBoundingClientRect();
1357
+ return t >= s && t < s + i && r >= o && r <= o + n;
1358
+ }, W = (e, t, r) => t >= 0 && t < e.innerWidth && r >= 0 && r <= e.innerHeight, O = (e, t) => {
1359
+ t !== null ? e.style.cursor = t : e.style.removeProperty("cursor");
1360
+ };
1361
+ class At {
1347
1362
  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", () => {
1358
- this.setCursor(null), this.grabbedNodeId = null;
1363
+ h(this, "model");
1364
+ h(this, "transformation");
1365
+ h(this, "maxNodePriority", 0);
1366
+ h(this, "nodes", /* @__PURE__ */ new Map());
1367
+ h(this, "grabbedNodeId", null);
1368
+ h(this, "onNodeDrag");
1369
+ h(this, "onBeforeNodeDrag");
1370
+ h(this, "nodeIdGenerator", new F());
1371
+ h(this, "element", null);
1372
+ h(this, "onCanvasMouseUp", () => {
1373
+ this.cancelMouseDrag();
1359
1374
  });
1360
- a(this, "onCanvasMouseMove", (t) => {
1361
- this.grabbedNodeId !== null && (t.stopPropagation(), this.dragNode(this.grabbedNodeId, t.movementX, t.movementY));
1375
+ h(this, "onCanvasMouseMove", (t) => {
1376
+ if (this.element !== null && (!V(this.element, t.clientX, t.clientY) || !W(this.window, t.clientX, t.clientY))) {
1377
+ this.cancelMouseDrag();
1378
+ return;
1379
+ }
1380
+ this.grabbedNodeId !== null && this.dragNode(this.grabbedNodeId, t.movementX, t.movementY);
1362
1381
  });
1363
- a(this, "onCanvasTouchStart", (t) => {
1382
+ h(this, "onCanvasTouchStart", (t) => {
1364
1383
  this.previousTouchCoords = [
1365
1384
  t.touches[0].clientX,
1366
1385
  t.touches[0].clientY
1367
1386
  ];
1368
1387
  });
1369
- a(this, "onCanvasTouchMove", (t) => {
1370
- if (this.grabbedNodeId === null || t.touches.length !== 1 || this.previousTouchCoords === null)
1371
- return;
1372
- t.stopImmediatePropagation();
1373
- const [r, s] = [
1374
- t.touches[0].clientX - this.previousTouchCoords[0],
1375
- t.touches[0].clientY - this.previousTouchCoords[1]
1376
- ];
1377
- this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = [
1378
- t.touches[0].clientX,
1379
- t.touches[0].clientY
1380
- ];
1388
+ h(this, "onCanvasTouchMove", (t) => {
1389
+ if (t.touches.length === 1) {
1390
+ const r = t.touches[0];
1391
+ if (this.element !== null && (!V(this.element, r.clientX, r.clientY) || !W(this.window, r.clientX, r.clientY))) {
1392
+ this.cancelTouchDrag();
1393
+ return;
1394
+ }
1395
+ if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1396
+ t.stopImmediatePropagation();
1397
+ const s = r.clientX - this.previousTouchCoords[0], o = r.clientY - this.previousTouchCoords[1];
1398
+ this.dragNode(this.grabbedNodeId, s, o), this.previousTouchCoords = [
1399
+ t.touches[0].clientX,
1400
+ t.touches[0].clientY
1401
+ ];
1402
+ }
1403
+ }
1381
1404
  });
1382
- a(this, "onCanvasTouchEnd", (t) => {
1405
+ h(this, "onCanvasTouchEnd", (t) => {
1383
1406
  t.touches.length > 0 ? this.previousTouchCoords = [
1384
1407
  t.touches[0].clientX,
1385
1408
  t.touches[0].clientY
1386
- ] : (this.previousTouchCoords = null, this.grabbedNodeId = null);
1409
+ ] : this.cancelTouchDrag();
1387
1410
  });
1388
- a(this, "previousTouchCoords", null);
1389
- a(this, "freezePriority");
1411
+ h(this, "previousTouchCoords", null);
1412
+ h(this, "freezePriority");
1413
+ h(this, "window", window);
1390
1414
  var i, n;
1391
1415
  this.canvas = t, this.transformation = this.canvas.transformation, this.model = this.canvas.model;
1392
1416
  const s = () => {
@@ -1403,13 +1427,15 @@ class ft {
1403
1427
  while (this.nodes.has(r));
1404
1428
  this.canvas.addNode({ ...t, id: r }), this.updateMaxNodePriority(r);
1405
1429
  const s = (i) => {
1430
+ if (this.element === null)
1431
+ return;
1406
1432
  const n = this.model.getNode(r);
1407
1433
  this.onBeforeNodeDrag({
1408
1434
  nodeId: r,
1409
1435
  element: t.element,
1410
1436
  x: n.x,
1411
1437
  y: n.y
1412
- }) && (i.stopImmediatePropagation(), this.grabbedNodeId = r, this.setCursor("grab"), this.moveNodeOnTop(r));
1438
+ }) && (i.stopImmediatePropagation(), this.grabbedNodeId = r, O(this.element, "grab"), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onCanvasMouseUp), this.window.addEventListener("mousemove", this.onCanvasMouseMove));
1413
1439
  }, o = (i) => {
1414
1440
  const n = this.model.getNode(r);
1415
1441
  this.onBeforeNodeDrag({
@@ -1417,7 +1443,7 @@ class ft {
1417
1443
  element: t.element,
1418
1444
  x: n.x,
1419
1445
  y: n.y
1420
- }) && i.touches.length === 1 && (this.grabbedNodeId = r, this.moveNodeOnTop(r));
1446
+ }) && i.touches.length === 1 && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onCanvasTouchMove), this.window.addEventListener("touchend", this.onCanvasTouchEnd), this.window.addEventListener("touchcancel", this.onCanvasTouchEnd));
1421
1447
  };
1422
1448
  return this.nodes.set(r, {
1423
1449
  element: t.element,
@@ -1462,25 +1488,22 @@ class ft {
1462
1488
  }), this.nodes.clear(), this.maxNodePriority = 0, this;
1463
1489
  }
1464
1490
  attach(t) {
1465
- return this.detach(), this.element = t, this.canvas.attach(this.element), this.element.addEventListener("mouseup", this.onCanvasMouseUp), this.element.addEventListener("mousemove", this.onCanvasMouseMove), this.element.addEventListener("touchstart", this.onCanvasTouchStart), this.element.addEventListener("touchmove", this.onCanvasTouchMove), this.element.addEventListener("touchend", this.onCanvasTouchEnd), this.element.addEventListener("touchcancel", this.onCanvasTouchEnd), this;
1491
+ return this.detach(), this.element = t, this.element.addEventListener("touchstart", this.onCanvasTouchStart), this.canvas.attach(this.element), this;
1466
1492
  }
1467
1493
  detach() {
1468
- return this.canvas.detach(), this.element !== null && (this.element.removeEventListener("mouseup", this.onCanvasMouseUp), this.element.removeEventListener("mousemove", this.onCanvasMouseMove), this.element.removeEventListener("touchstart", this.onCanvasTouchStart), this.element.removeEventListener("touchmove", this.onCanvasTouchMove), this.element.removeEventListener("touchend", this.onCanvasTouchEnd), this.element.removeEventListener("touchcancel", this.onCanvasTouchEnd), this.element = null), this;
1494
+ return this.canvas.detach(), this.element !== null && (this.element.removeEventListener("touchstart", this.onCanvasTouchStart), this.element = null), this;
1469
1495
  }
1470
1496
  destroy() {
1471
- this.detach(), this.nodes.forEach((t) => {
1497
+ this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.nodes.forEach((t) => {
1472
1498
  t.element.removeEventListener("mousedown", t.onMouseDown), t.element.removeEventListener("touchstart", t.onTouchStart);
1473
1499
  }), this.nodes.clear(), this.canvas.destroy();
1474
1500
  }
1475
- setCursor(t) {
1476
- this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1477
- }
1478
1501
  dragNode(t, r, s) {
1479
1502
  const o = this.model.getNode(t);
1480
1503
  if (o === null)
1481
1504
  throw new Error("failed to drag nonexisting node");
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({
1505
+ const i = this.canvas.transformation.getContentMatrix(), n = i.scale * o.x + i.dx, c = i.scale * o.y + i.dy, a = n + r, l = c + s, d = this.canvas.transformation.getViewportMatrix(), g = d.scale * a + d.dx, u = d.scale * l + d.dy;
1506
+ this.canvas.updateNode(t, { x: g, y: u }), this.onNodeDrag({
1484
1507
  nodeId: t,
1485
1508
  element: o.element,
1486
1509
  x: o.x,
@@ -1500,27 +1523,39 @@ class ft {
1500
1523
  this.updateEdge(o, { priority: r });
1501
1524
  });
1502
1525
  }
1526
+ cancelMouseDrag() {
1527
+ this.grabbedNodeId = null, this.element !== null && O(this.element, null), this.removeMouseDragListeners();
1528
+ }
1529
+ removeMouseDragListeners() {
1530
+ this.window.removeEventListener("mouseup", this.onCanvasMouseUp), this.window.removeEventListener("mousemove", this.onCanvasMouseMove);
1531
+ }
1532
+ cancelTouchDrag() {
1533
+ this.previousTouchCoords = null, this.grabbedNodeId = null, this.removeTouchDragListeners();
1534
+ }
1535
+ removeTouchDragListeners() {
1536
+ this.window.removeEventListener("touchmove", this.onCanvasTouchMove), this.window.removeEventListener("touchend", this.onCanvasTouchEnd), this.window.removeEventListener("touchcancel", this.onCanvasTouchEnd);
1537
+ }
1503
1538
  }
1504
- const xt = () => {
1505
- }, Et = (e, t) => t, At = (e, t) => {
1539
+ const Ct = () => {
1540
+ }, St = (e, t) => t, bt = (e, t) => {
1506
1541
  const r = t !== null ? 1 / t : null, s = e !== null ? 1 / e : null;
1507
1542
  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);
1543
+ }, Nt = (e, t, r, s) => (o, i, n, c) => {
1544
+ let a = i.dx, l = i.dy;
1545
+ e !== null && a < e && a < o.dx && (a = o.dx);
1511
1546
  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) => {
1547
+ t !== null && a > t - d && a > o.dx && (a = o.dx), r !== null && l < r && l < o.dy && (l = o.dy);
1548
+ const g = c * o.scale;
1549
+ return s !== null && l > s - g && l > o.dy && (l = o.dy), { scale: i.scale, dx: a, dy: l };
1550
+ }, U = (e) => {
1516
1551
  switch (e.type) {
1517
1552
  case "scale-limit":
1518
- return At(
1553
+ return bt(
1519
1554
  e.minContentScale ?? null,
1520
1555
  e.maxContentScale ?? null
1521
1556
  );
1522
1557
  case "shift-limit":
1523
- return Ct(
1558
+ return Nt(
1524
1559
  e.minX ?? null,
1525
1560
  e.maxX ?? null,
1526
1561
  e.minY ?? null,
@@ -1529,61 +1564,71 @@ const xt = () => {
1529
1564
  default:
1530
1565
  return e.preprocessorFn;
1531
1566
  }
1532
- }, St = (e) => (t, r, s, o) => e.reduce(
1567
+ }, Mt = (e) => (t, r, s, o) => e.reduce(
1533
1568
  (i, n) => n(t, i, s, o),
1534
1569
  r
1535
1570
  );
1536
- class Nt {
1571
+ class Pt {
1537
1572
  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", () => {
1549
- this.setCursor("grab"), this.isMoving = !0;
1573
+ h(this, "model");
1574
+ h(this, "transformation");
1575
+ h(this, "element", null);
1576
+ h(this, "prevTouches", null);
1577
+ h(this, "onTransformFinished");
1578
+ h(this, "transformPreprocessor");
1579
+ h(this, "isScalable");
1580
+ h(this, "isShiftable");
1581
+ h(this, "wheelSensitivity");
1582
+ h(this, "window", window);
1583
+ h(this, "onMouseDown", () => {
1584
+ this.element !== null && (O(this.element, "grab"), this.window.addEventListener("mousemove", this.onMouseMove), this.window.addEventListener("mouseup", this.onMouseUp));
1550
1585
  });
1551
- a(this, "onMouseMove", (t) => {
1552
- if (!this.isMoving || !this.isShiftable)
1586
+ h(this, "onMouseMove", (t) => {
1587
+ if (!this.isShiftable || this.element === null)
1553
1588
  return;
1589
+ if (!V(this.element, t.clientX, t.clientY) || !W(this.window, t.clientX, t.clientY)) {
1590
+ this.stopMouseDrag();
1591
+ return;
1592
+ }
1554
1593
  const r = -t.movementX, s = -t.movementY;
1555
1594
  this.moveViewport(r, s);
1556
1595
  });
1557
- a(this, "onMouseUp", () => {
1558
- this.setCursor(null), this.isMoving = !1;
1596
+ h(this, "onMouseUp", () => {
1597
+ this.stopMouseDrag();
1559
1598
  });
1560
- a(this, "onWheelScroll", (t) => {
1599
+ h(this, "onWheelScroll", (t) => {
1561
1600
  if (this.element === null || this.isScalable === !1)
1562
1601
  return;
1563
1602
  t.preventDefault();
1564
1603
  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
1604
  this.scaleViewport(c, o, i);
1566
1605
  });
1567
- a(this, "onTouchStart", (t) => {
1568
- this.prevTouches = this.getAverageTouch(t);
1606
+ h(this, "onTouchStart", (t) => {
1607
+ this.prevTouches = this.getAverageTouch(t), this.window.addEventListener("touchmove", this.onTouchMove), this.window.addEventListener("touchend", this.onTouchEnd), this.window.addEventListener("touchcancel", this.onTouchEnd);
1569
1608
  });
1570
- a(this, "onTouchMove", (t) => {
1571
- if (this.prevTouches === null || this.element === null || !this.isShiftable)
1609
+ h(this, "onTouchMove", (t) => {
1610
+ if (this.prevTouches === null || !this.isShiftable || this.element === null)
1572
1611
  return;
1573
1612
  const r = this.getAverageTouch(t);
1613
+ if (!r.touches.every(
1614
+ (o) => V(this.element, o[0], o[1]) && W(this.window, o[0], o[1])
1615
+ )) {
1616
+ this.stopTouchDrag();
1617
+ return;
1618
+ }
1574
1619
  if ((r.touchesCnt === 1 || r.touchesCnt === 2) && this.moveViewport(
1575
1620
  -(r.x - this.prevTouches.x),
1576
1621
  -(r.y - this.prevTouches.y)
1577
1622
  ), 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);
1623
+ const { left: o, top: i } = this.element.getBoundingClientRect(), n = this.prevTouches.x - o, c = this.prevTouches.y - i, l = 1 / (r.scale / this.prevTouches.scale);
1624
+ this.scaleViewport(l, n, c);
1580
1625
  }
1581
- this.prevTouches = r, t.preventDefault();
1626
+ this.prevTouches = r;
1582
1627
  });
1583
- a(this, "onTouchEnd", (t) => {
1584
- t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.prevTouches = null;
1628
+ h(this, "onTouchEnd", (t) => {
1629
+ t.touches.length > 0 ? this.prevTouches = this.getAverageTouch(t) : this.stopTouchDrag();
1585
1630
  });
1586
- a(this, "observer", new ResizeObserver(() => {
1631
+ h(this, "observer", new ResizeObserver(() => {
1587
1632
  if (this.element !== null) {
1588
1633
  const t = this.canvas.transformation.getViewportMatrix(), { width: r, height: s } = this.element.getBoundingClientRect(), o = this.transformPreprocessor(
1589
1634
  t,
@@ -1594,16 +1639,16 @@ class Nt {
1594
1639
  this.canvas.patchViewportMatrix(o), this.onTransformFinished(o);
1595
1640
  }
1596
1641
  }));
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;
1642
+ var i, n, c, a, l, d, g;
1643
+ 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 = ((a = (c = this.options) == null ? void 0 : c.shift) == null ? void 0 : a.enabled) !== !1;
1599
1644
  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;
1645
+ this.wheelSensitivity = s !== void 0 ? s : 1.2, this.onTransformFinished = ((g = r == null ? void 0 : r.events) == null ? void 0 : g.onTransformFinished) ?? Ct;
1601
1646
  const o = r == null ? void 0 : r.transformPreprocessor;
1602
- o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = St(
1647
+ o !== void 0 ? Array.isArray(o) ? this.transformPreprocessor = Mt(
1603
1648
  o.map(
1604
- (g) => B(g)
1649
+ (u) => U(u)
1605
1650
  )
1606
- ) : this.transformPreprocessor = B(o) : this.transformPreprocessor = Et;
1651
+ ) : this.transformPreprocessor = U(o) : this.transformPreprocessor = St;
1607
1652
  }
1608
1653
  addNode(t) {
1609
1654
  return this.canvas.addNode(t), this;
@@ -1642,29 +1687,32 @@ class Nt {
1642
1687
  return this.canvas.clear(), this;
1643
1688
  }
1644
1689
  attach(t) {
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;
1690
+ return this.detach(), this.element = t, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), this.canvas.attach(this.element), this;
1646
1691
  }
1647
1692
  detach() {
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;
1693
+ return this.canvas.detach(), this.element !== null && (this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.element = null), this;
1649
1694
  }
1650
1695
  destroy() {
1651
- this.detach(), this.canvas.destroy();
1696
+ this.detach(), this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.canvas.destroy();
1652
1697
  }
1653
1698
  getAverageTouch(t) {
1654
1699
  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]);
1700
+ for (let a = 0; a < s; a++)
1701
+ r.push([t.touches[a].clientX, t.touches[a].clientY]);
1657
1702
  const o = r.reduce(
1658
- (h, l) => [h[0] + l[0], h[1] + l[1]],
1703
+ (a, l) => [a[0] + l[0], a[1] + l[1]],
1659
1704
  [0, 0]
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]),
1705
+ ), i = [o[0] / s, o[1] / s], c = r.map((a) => [a[0] - i[0], a[1] - i[1]]).reduce(
1706
+ (a, l) => a + Math.sqrt(l[0] * l[0] + l[1] * l[1]),
1662
1707
  0
1663
1708
  );
1664
- return { x: i[0], y: i[1], scale: c / s, touchesCnt: s };
1665
- }
1666
- setCursor(t) {
1667
- this.element !== null && (t !== null ? this.element.style.cursor = t : this.element.style.removeProperty("cursor"));
1709
+ return {
1710
+ x: i[0],
1711
+ y: i[1],
1712
+ scale: c / s,
1713
+ touchesCnt: s,
1714
+ touches: r
1715
+ };
1668
1716
  }
1669
1717
  moveViewport(t, r) {
1670
1718
  const s = this.transformation.getViewportMatrix(), o = {
@@ -1683,29 +1731,40 @@ class Nt {
1683
1731
  }
1684
1732
  }
1685
1733
  scaleViewport(t, r, s) {
1734
+ if (this.element === null)
1735
+ return;
1686
1736
  const o = this.canvas.transformation.getViewportMatrix(), i = {
1687
1737
  scale: o.scale * t,
1688
1738
  dx: o.scale * (1 - t) * r + o.dx,
1689
1739
  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
- }
1740
+ }, { width: n, height: c } = this.element.getBoundingClientRect(), a = this.transformPreprocessor(
1741
+ o,
1742
+ i,
1743
+ n,
1744
+ c
1745
+ );
1746
+ this.canvas.patchViewportMatrix(a), this.onTransformFinished(a);
1747
+ }
1748
+ stopMouseDrag() {
1749
+ this.element !== null && O(this.element, null), this.removeMouseDragListeners();
1750
+ }
1751
+ removeMouseDragListeners() {
1752
+ this.window.removeEventListener("mousemove", this.onMouseMove), this.window.removeEventListener("mouseup", this.onMouseUp);
1753
+ }
1754
+ stopTouchDrag() {
1755
+ this.prevTouches = null, this.removeTouchDragListeners();
1756
+ }
1757
+ removeTouchDragListeners() {
1758
+ this.window.removeEventListener("touchmove", this.onTouchMove), this.window.removeEventListener("touchend", this.onTouchEnd), this.window.removeEventListener("touchcancel", this.onTouchEnd);
1700
1759
  }
1701
1760
  }
1702
- class Mt {
1761
+ class Tt {
1703
1762
  constructor() {
1704
- a(this, "coreOptions");
1705
- a(this, "dragOptions");
1706
- a(this, "transformOptions");
1707
- a(this, "isDraggable", !1);
1708
- a(this, "isTransformable", !1);
1763
+ h(this, "coreOptions");
1764
+ h(this, "dragOptions");
1765
+ h(this, "transformOptions");
1766
+ h(this, "isDraggable", !1);
1767
+ h(this, "isTransformable", !1);
1709
1768
  }
1710
1769
  setOptions(t) {
1711
1770
  return this.coreOptions = t, this;
@@ -1717,25 +1776,25 @@ class Mt {
1717
1776
  return this.isTransformable = !0, this.transformOptions = t, this;
1718
1777
  }
1719
1778
  build() {
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;
1779
+ let t = new Et(this.coreOptions);
1780
+ return this.isDraggable && (t = new At(t, this.dragOptions)), this.isTransformable && (t = new Pt(t, this.transformOptions)), t;
1722
1781
  }
1723
1782
  }
1724
1783
  export {
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
1784
+ st as BezierEdgeShape,
1785
+ Et as CanvasCore,
1786
+ ht as CycleCircleEdgeShape,
1787
+ z as CycleSquareEdgeShape,
1788
+ B as DetourStraightEdgeShape,
1789
+ N as EdgeType,
1790
+ it as HorizontalEdgeShape,
1791
+ Tt as HtmlGraphBuilder,
1792
+ ot as StraightEdgeShape,
1793
+ At as UserDraggableNodesCanvas,
1794
+ Pt as UserTransformableCanvas,
1795
+ nt as VerticalEdgeShape,
1796
+ ct as createBezierEdgeShapeFactory,
1797
+ dt as createHorizontalEdgeShapeFactory,
1798
+ lt as createStraightEdgeShareFactory,
1799
+ gt as createVerticalEdgeShapeFactory
1741
1800
  };