@html-graph/html-graph 3.5.1 → 3.6.0

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.
@@ -1,20 +1,20 @@
1
- var ae = Object.defineProperty;
2
- var le = (t, e, o) => e in t ? ae(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var i = (t, e, o) => le(t, typeof e != "symbol" ? e + "" : e, o);
4
- const ge = () => {
1
+ var he = Object.defineProperty;
2
+ var de = (t, e, o) => e in t ? he(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var i = (t, e, o) => de(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const ce = () => {
5
5
  const t = document.createElement("div");
6
6
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
7
- }, ue = () => {
7
+ }, ae = () => {
8
8
  const t = document.createElement("div");
9
9
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
10
- }, we = () => {
10
+ }, le = () => {
11
11
  const t = document.createElement("div");
12
12
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
13
13
  };
14
- class ne {
14
+ class re {
15
15
  constructor(e, o, r) {
16
- i(this, "host", we());
17
- i(this, "container", ge());
16
+ i(this, "host", le());
17
+ i(this, "container", ce());
18
18
  i(this, "nodeIdToWrapperElementMap", /* @__PURE__ */ new Map());
19
19
  i(this, "edgeIdToElementMap", /* @__PURE__ */ new Map());
20
20
  i(this, "applyTransform", () => {
@@ -24,7 +24,7 @@ class ne {
24
24
  this.graphStore = e, this.viewportStore = o, this.element = r, this.element.appendChild(this.host), this.host.appendChild(this.container), this.viewportStore.onAfterUpdated.subscribe(this.applyTransform);
25
25
  }
26
26
  attachNode(e) {
27
- const o = this.graphStore.getNode(e), r = ue();
27
+ const o = this.graphStore.getNode(e), r = ae();
28
28
  r.appendChild(o.element), this.container.appendChild(r), this.nodeIdToWrapperElementMap.set(e, r), this.updateNodePosition(e), this.updateNodePriority(e), r.style.visibility = "visible";
29
29
  }
30
30
  detachNode(e) {
@@ -64,15 +64,15 @@ class ne {
64
64
  this.edgeIdToElementMap.set(e, r.shape.svg), this.container.appendChild(r.shape.svg);
65
65
  }
66
66
  renderEdge(e) {
67
- const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, v = {
67
+ const o = this.graphStore.getEdge(e), r = this.graphStore.getPort(o.from), s = this.graphStore.getPort(o.to), h = r.element.getBoundingClientRect(), n = s.element.getBoundingClientRect(), d = this.host.getBoundingClientRect(), c = this.viewportStore.getViewportMatrix(), a = h.left - d.left, l = h.top - d.top, g = n.left - d.left, y = n.top - d.top, p = {
68
68
  x: c.scale * a + c.x,
69
69
  y: c.scale * l + c.y
70
70
  }, f = {
71
71
  x: c.scale * g + c.x,
72
72
  y: c.scale * y + c.y
73
- }, A = {
74
- x: v.x,
75
- y: v.y,
73
+ }, E = {
74
+ x: p.x,
75
+ y: p.y,
76
76
  width: h.width * c.scale,
77
77
  height: h.height * c.scale,
78
78
  direction: r.direction,
@@ -87,14 +87,14 @@ class ne {
87
87
  portId: o.to,
88
88
  nodeId: s.nodeId
89
89
  };
90
- o.shape.render({ from: A, to: x });
90
+ o.shape.render({ from: E, to: x });
91
91
  }
92
92
  updateEdgePriority(e) {
93
93
  const o = this.graphStore.getEdge(e);
94
94
  o.shape.svg.style.zIndex = `${o.priority}`;
95
95
  }
96
96
  }
97
- class fe {
97
+ class ge {
98
98
  constructor(e) {
99
99
  i(this, "xFrom", 1 / 0);
100
100
  i(this, "yFrom", 1 / 0);
@@ -114,7 +114,7 @@ class fe {
114
114
  return d <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
115
115
  }
116
116
  }
117
- class ye {
117
+ class ue {
118
118
  constructor(e, o, r) {
119
119
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
120
120
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -138,7 +138,7 @@ class ye {
138
138
  this.handleAttachEdge(n);
139
139
  });
140
140
  });
141
- this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new fe(this.graphStore), this.trigger.subscribe(this.updateViewport);
141
+ this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ge(this.graphStore), this.trigger.subscribe(this.updateViewport);
142
142
  }
143
143
  attachNode(e) {
144
144
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -192,7 +192,7 @@ class ye {
192
192
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
193
193
  }
194
194
  }
195
- class he {
195
+ class ie {
196
196
  constructor() {
197
197
  i(this, "callbacks", /* @__PURE__ */ new Set());
198
198
  }
@@ -208,11 +208,11 @@ class he {
208
208
  });
209
209
  }
210
210
  }
211
- const E = () => {
212
- const t = new he();
211
+ const A = () => {
212
+ const t = new ie();
213
213
  return [t, t];
214
214
  };
215
- class ve {
215
+ class we {
216
216
  constructor(e) {
217
217
  i(this, "onBeforeUpdated");
218
218
  i(this, "onAfterUpdated");
@@ -225,7 +225,7 @@ class ve {
225
225
  return { ...this.viewportStore.getContentMatrix() };
226
226
  }
227
227
  }
228
- class pe {
228
+ class fe {
229
229
  constructor(e) {
230
230
  i(this, "onAfterNodeAdded");
231
231
  i(this, "onAfterNodeUpdated");
@@ -301,7 +301,7 @@ class pe {
301
301
  return this.graphStore.getNode(e) === void 0 ? null : this.graphStore.getNodeAdjacentEdgeIds(e);
302
302
  }
303
303
  }
304
- class O {
304
+ class C {
305
305
  constructor(e) {
306
306
  i(this, "counter", 0);
307
307
  this.checkExists = e;
@@ -323,85 +323,31 @@ class S extends Error {
323
323
  i(this, "name", "HtmlGraphError");
324
324
  }
325
325
  }
326
- const xe = (t, e) => ({
326
+ const ve = (t, e) => ({
327
327
  x: t / 2,
328
328
  y: e / 2
329
- }), X = (t) => () => t, oe = X(0), Ae = () => {
329
+ }), $ = (t) => () => t, Q = $(0), ye = () => {
330
330
  let t = 0;
331
331
  return () => t++;
332
- }, Ee = (t, e) => {
333
- let o = oe, r = oe;
334
- const s = Ae();
335
- return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = X(t)), typeof e == "number" && (r = X(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
332
+ }, pe = (t, e) => {
333
+ let o = Q, r = Q;
334
+ const s = ye();
335
+ return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = $(t)), typeof e == "number" && (r = $(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
336
336
  nodesPriorityFn: o,
337
337
  edgesPriorityFn: r
338
338
  };
339
- }, p = (t, e, o) => ({
339
+ }, v = (t, e, o) => ({
340
340
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
341
341
  y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
342
- }), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
342
+ }), w = {
343
343
  x: 0,
344
344
  y: 0
345
- }, N = (t, e, o, r) => {
346
- const h = [
347
- w,
348
- { x: o, y: r },
349
- { x: o, y: -r }
350
- ].map((a) => p(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
351
- return `${n} ${d} ${c}`;
352
- }, I = (t, e) => {
353
- const o = [];
354
- if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
355
- const r = t.length - 1;
356
- let s = 0, h = 0, n = 0;
357
- t.forEach((d, c) => {
358
- let a = 0, l = 0, g = 0;
359
- const y = c > 0, v = c < r, f = y && v;
360
- if (y && (a = -s, l = -h, g = n), v) {
361
- const B = t[c + 1];
362
- s = B.x - d.x, h = B.y - d.y, n = Math.sqrt(s * s + h * h);
363
- }
364
- const x = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, b = f ? { x: d.x + s * x, y: d.y + h * x } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, R = f ? { x: d.x + a * m, y: d.y + l * m } : d;
365
- c > 0 && o.push(`L ${R.x} ${R.y}`), f && o.push(
366
- `C ${d.x} ${d.y} ${d.x} ${d.y} ${b.x} ${b.y}`
367
- );
368
- });
369
- }
370
- return o.join(" ");
371
- }, $ = () => {
372
- const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
373
- return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
374
- }, W = () => {
375
- const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
376
- return t.style.transformOrigin = "50% 50%", t;
377
- }, F = (t, e) => {
378
- const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
379
- return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
380
- }, P = (t) => {
381
- const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
382
- return e.setAttribute("fill", t), e;
383
- }, z = (t, e) => {
384
- const o = {
385
- x: t.x + t.width / 2,
386
- y: t.y + t.height / 2
387
- }, r = {
388
- x: e.x + e.width / 2,
389
- y: e.y + e.height / 2
390
- }, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
391
- return {
392
- x: s,
393
- y: h,
394
- width: n,
395
- height: d,
396
- flipX: c,
397
- flipY: a
398
- };
399
- }, Se = (t) => {
400
- const e = p(
345
+ }, xe = (t) => {
346
+ const e = v(
401
347
  { x: t.arrowLength, y: w.y },
402
348
  t.fromVector,
403
349
  w
404
- ), o = p(
350
+ ), o = v(
405
351
  { x: t.to.x - t.arrowLength, y: t.to.y },
406
352
  t.toVector,
407
353
  t.to
@@ -413,36 +359,36 @@ const xe = (t, e) => ({
413
359
  y: o.y - t.toVector.y * t.curvature
414
360
  }, h = `M ${e.x} ${e.y} C ${r.x} ${r.y}, ${s.x} ${s.y}, ${o.x} ${o.y}`, n = t.hasSourceArrow ? "" : `M ${w.x} ${w.y} L ${e.x} ${e.y} `, d = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
415
361
  return `${n}${h}${d}`;
416
- }, be = (t) => {
417
- const e = t.hasSourceArrow ? p(
362
+ }, Ee = (t) => {
363
+ const e = t.hasSourceArrow ? v(
418
364
  { x: t.arrowLength, y: w.y },
419
365
  t.fromVector,
420
366
  w
421
- ) : w, o = t.hasTargetArrow ? p(
367
+ ) : w, o = t.hasTargetArrow ? v(
422
368
  { x: t.to.x - t.arrowLength, y: t.to.y },
423
369
  t.toVector,
424
370
  t.to
425
- ) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = p(
371
+ ) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, h = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, d = h * t.flipY, c = v(
426
372
  { x: r, y: w.y },
427
373
  t.fromVector,
428
374
  w
429
375
  ), a = {
430
376
  x: c.x + n,
431
377
  y: c.y + d
432
- }, l = p(
378
+ }, l = v(
433
379
  { x: t.to.x - r, y: t.to.y },
434
380
  t.toVector,
435
381
  t.to
436
382
  ), g = {
437
383
  x: l.x + n,
438
384
  y: l.y + d
439
- }, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
385
+ }, y = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, p = {
440
386
  x: c.x + t.curvature * t.fromVector.x,
441
387
  y: c.y + t.curvature * t.fromVector.y
442
388
  }, f = {
443
389
  x: l.x - t.curvature * t.toVector.x,
444
390
  y: l.y - t.curvature * t.toVector.y
445
- }, A = {
391
+ }, E = {
446
392
  x: c.x + n,
447
393
  y: c.y + d
448
394
  }, x = {
@@ -452,24 +398,43 @@ const xe = (t, e) => ({
452
398
  return [
453
399
  `M ${e.x} ${e.y}`,
454
400
  `L ${c.x} ${c.y}`,
455
- `C ${v.x} ${v.y} ${A.x} ${A.y} ${y.x} ${y.y}`,
401
+ `C ${p.x} ${p.y} ${E.x} ${E.y} ${y.x} ${y.y}`,
456
402
  `C ${x.x} ${x.y} ${f.x} ${f.y} ${l.x} ${l.y}`,
457
403
  `L ${o.x} ${o.y}`
458
404
  ].join(" ");
459
- }, me = (t) => {
460
- const e = t.hasSourceArrow ? p(
405
+ }, L = (t, e) => {
406
+ const o = [];
407
+ if (t.length > 0 && o.push(`M ${t[0].x} ${t[0].y}`), t.length === 2 && o.push(`L ${t[1].x} ${t[1].y}`), t.length > 2) {
408
+ const r = t.length - 1;
409
+ let s = 0, h = 0, n = 0;
410
+ t.forEach((d, c) => {
411
+ let a = 0, l = 0, g = 0;
412
+ const y = c > 0, p = c < r, f = y && p;
413
+ if (y && (a = -s, l = -h, g = n), p) {
414
+ const V = t[c + 1];
415
+ s = V.x - d.x, h = V.y - d.y, n = Math.sqrt(s * s + h * h);
416
+ }
417
+ const x = n !== 0 ? Math.min((f ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = f ? { x: d.x + s * x, y: d.y + h * x } : d, m = g !== 0 ? Math.min((f ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, D = f ? { x: d.x + a * m, y: d.y + l * m } : d;
418
+ c > 0 && o.push(`L ${D.x} ${D.y}`), f && o.push(
419
+ `C ${d.x} ${d.y} ${d.x} ${d.y} ${T.x} ${T.y}`
420
+ );
421
+ });
422
+ }
423
+ return o.join(" ");
424
+ }, Ae = (t) => {
425
+ const e = t.hasSourceArrow ? v(
461
426
  { x: t.arrowLength, y: w.y },
462
427
  t.fromVector,
463
428
  w
464
- ) : w, o = t.hasTargetArrow ? p(
429
+ ) : w, o = t.hasTargetArrow ? v(
465
430
  { x: t.to.x - t.arrowLength, y: t.to.y },
466
431
  t.toVector,
467
432
  t.to
468
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = p(
433
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
469
434
  { x: s, y: w.y },
470
435
  t.fromVector,
471
436
  w
472
- ), n = p(
437
+ ), n = v(
473
438
  { x: t.to.x - s, y: t.to.y },
474
439
  t.toVector,
475
440
  t.to
@@ -480,65 +445,65 @@ const xe = (t, e) => ({
480
445
  x: t.flipX > 0 ? t.to.x - d : t.to.x + r,
481
446
  y: n.y
482
447
  }, y = { x: g.x, y: c };
483
- return I(
448
+ return L(
484
449
  [e, h, a, l, y, g, n, o],
485
450
  t.roundness
486
451
  );
487
- }, H = (t) => {
488
- const e = t.hasSourceArrow ? p(
452
+ }, F = (t) => {
453
+ const e = t.hasSourceArrow ? v(
489
454
  { x: t.arrowLength, y: w.y },
490
455
  t.fromVector,
491
456
  w
492
- ) : w, o = t.hasTargetArrow ? p(
457
+ ) : w, o = t.hasTargetArrow ? v(
493
458
  { x: t.to.x - t.arrowLength, y: t.to.y },
494
459
  t.toVector,
495
460
  t.to
496
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = p(
461
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
497
462
  { x: r, y: w.y },
498
463
  t.fromVector,
499
464
  w
500
- ), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = p(
465
+ ), h = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, d = h * t.flipX, c = n * t.flipY, a = { x: s.x + d, y: s.y + c }, l = v(
501
466
  { x: t.to.x - r, y: t.to.y },
502
467
  t.toVector,
503
468
  t.to
504
469
  ), g = { x: l.x + d, y: l.y + c };
505
- return I(
470
+ return L(
506
471
  [e, s, a, g, l, o],
507
472
  t.roundness
508
473
  );
509
- }, Te = (t) => {
510
- const e = t.hasSourceArrow ? p(
474
+ }, Se = (t) => {
475
+ const e = t.hasSourceArrow ? v(
511
476
  { x: t.arrowLength, y: w.y },
512
477
  t.fromVector,
513
478
  w
514
- ) : w, o = t.hasTargetArrow ? p(
479
+ ) : w, o = t.hasTargetArrow ? v(
515
480
  { x: t.to.x - t.arrowLength, y: t.to.y },
516
481
  t.toVector,
517
482
  t.to
518
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = p(
483
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = v(
519
484
  { x: r, y: w.y },
520
485
  t.fromVector,
521
486
  w
522
- ), h = p(
487
+ ), h = v(
523
488
  { x: t.to.x - r, y: t.to.y },
524
489
  t.toVector,
525
490
  t.to
526
491
  );
527
- return I([e, s, h, o], t.roundness);
528
- }, Ne = (t) => {
529
- const e = t.hasSourceArrow ? p(
492
+ return L([e, s, h, o], t.roundness);
493
+ }, Te = (t) => {
494
+ const e = t.hasSourceArrow ? v(
530
495
  { x: t.arrowLength, y: w.y },
531
496
  t.fromVector,
532
497
  w
533
- ) : w, o = t.hasTargetArrow ? p(
498
+ ) : w, o = t.hasTargetArrow ? v(
534
499
  { x: t.to.x - t.arrowLength, y: t.to.y },
535
500
  t.toVector,
536
501
  t.to
537
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = p(
502
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, h = v(
538
503
  { x: s, y: w.y },
539
504
  t.fromVector,
540
505
  w
541
- ), n = p(
506
+ ), n = v(
542
507
  { x: t.to.x - s, y: t.to.y },
543
508
  t.toVector,
544
509
  t.to
@@ -549,11 +514,11 @@ const xe = (t, e) => ({
549
514
  x: n.x,
550
515
  y: t.flipY > 0 ? t.to.y - d : t.to.y + r
551
516
  }, y = { x: c, y: g.y };
552
- return I(
517
+ return L(
553
518
  [e, h, a, l, y, g, n, o],
554
519
  t.roundness
555
520
  );
556
- }, j = (t) => {
521
+ }, z = (t) => {
557
522
  const e = t.arrowOffset, o = t.side, r = t.arrowLength + e, s = r + 2 * o, n = [
558
523
  { x: t.arrowLength, y: w.y },
559
524
  { x: r, y: w.y },
@@ -564,16 +529,16 @@ const xe = (t, e) => ({
564
529
  { x: r, y: w.y },
565
530
  { x: t.arrowLength, y: w.y }
566
531
  ].map(
567
- (c) => p(c, t.fromVector, w)
532
+ (c) => v(c, t.fromVector, w)
568
533
  ), d = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
569
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${I(n, t.roundness)}`;
570
- }, Pe = (t) => {
534
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : d}${L(n, t.roundness)}`;
535
+ }, me = (t) => {
571
536
  const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, h = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
572
537
  { x: t.arrowLength, y: w.y },
573
538
  { x: h, y: n },
574
539
  { x: h, y: -n }
575
540
  ].map(
576
- (g) => p(g, t.fromVector, w)
541
+ (g) => v(g, t.fromVector, w)
577
542
  ), a = [
578
543
  `M ${c[0].x} ${c[0].y}`,
579
544
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
@@ -597,96 +562,170 @@ const xe = (t, e) => ({
597
562
  detourDirectionVertical: 0,
598
563
  smallCycleRadius: 15,
599
564
  curvature: 90
600
- });
601
- class Me {
565
+ }), Z = (t, e, o, r) => {
566
+ const h = [
567
+ w,
568
+ { x: o, y: r },
569
+ { x: o, y: -r }
570
+ ].map((a) => v(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${h[0].x} ${h[0].y}`, d = `L ${h[1].x} ${h[1].y}`, c = `L ${h[2].x} ${h[2].y}`;
571
+ return `${n} ${d} ${c}`;
572
+ }, _ = (t) => {
573
+ const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
574
+ return e.setAttribute("fill", t), e;
575
+ }, be = () => {
576
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
577
+ return t.style.transformOrigin = "50% 50%", t;
578
+ }, Pe = (t, e) => {
579
+ const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
580
+ return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
581
+ }, Ne = (t, e) => {
582
+ const o = {
583
+ x: t.x + t.width / 2,
584
+ y: t.y + t.height / 2
585
+ }, r = {
586
+ x: e.x + e.width / 2,
587
+ y: e.y + e.height / 2
588
+ }, s = Math.min(o.x, r.x), h = Math.min(o.y, r.y), n = Math.abs(r.x - o.x), d = Math.abs(r.y - o.y), c = o.x <= r.x ? 1 : -1, a = o.y <= r.y ? 1 : -1;
589
+ return {
590
+ x: s,
591
+ y: h,
592
+ width: n,
593
+ height: d,
594
+ flipX: c,
595
+ flipY: a
596
+ };
597
+ }, Me = () => {
598
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
599
+ return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
600
+ }, q = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) });
601
+ class I {
602
602
  constructor(e) {
603
- i(this, "svg", $());
604
- i(this, "group", W());
603
+ i(this, "svg", Me());
604
+ i(this, "group", be());
605
605
  i(this, "line");
606
606
  i(this, "sourceArrow", null);
607
607
  i(this, "targetArrow", null);
608
- i(this, "arrowLength");
609
- i(this, "arrowWidth");
610
- i(this, "curvature");
611
- i(this, "portCycleRadius");
612
- i(this, "portCycleSmallRadius");
613
- i(this, "detourDirection");
614
- i(this, "detourDistance");
615
- i(this, "hasSourceArrow");
616
- i(this, "hasTargetArrow");
617
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
618
- const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
619
- this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(o), this.group.appendChild(this.targetArrow));
608
+ this.params = e, this.svg.appendChild(this.group), this.line = Pe(e.color, e.width), this.group.appendChild(this.line), e.hasSourceArrow && (this.sourceArrow = _(e.color), this.group.appendChild(this.sourceArrow)), e.hasTargetArrow && (this.targetArrow = _(e.color), this.group.appendChild(this.targetArrow));
620
609
  }
621
610
  render(e) {
622
- const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
611
+ const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = Ne(
623
612
  e.from,
624
613
  e.to
625
614
  );
626
615
  this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
627
- const c = T(
616
+ const c = q(
628
617
  e.from.direction,
629
618
  n,
630
619
  d
631
- ), a = T(e.to.direction, n, d), l = {
620
+ ), a = q(
621
+ e.to.direction,
622
+ n,
623
+ d
624
+ ), l = {
632
625
  x: s,
633
626
  y: h
634
627
  };
635
- let g, y = a, v = -this.arrowLength;
636
- if (e.from.portId === e.to.portId ? (g = Pe({
637
- fromVector: c,
628
+ let g, y = a, p = -this.params.arrowLength;
629
+ if (e.from.portId === e.to.portId ? (g = this.params.createCyclePath(
630
+ c,
631
+ a,
632
+ l,
633
+ n,
634
+ d
635
+ ), y = c, p = this.params.arrowLength) : e.from.nodeId === e.to.nodeId ? g = this.params.createDetourPath(
636
+ c,
637
+ a,
638
+ l,
639
+ n,
640
+ d
641
+ ) : g = this.params.createLinePath(
642
+ c,
643
+ a,
644
+ l,
645
+ n,
646
+ d
647
+ ), this.line.setAttribute("d", g), this.sourceArrow) {
648
+ const f = Z(
649
+ c,
650
+ w,
651
+ this.params.arrowLength,
652
+ this.params.arrowWidth
653
+ );
654
+ this.sourceArrow.setAttribute("d", f);
655
+ }
656
+ if (this.targetArrow) {
657
+ const f = Z(
658
+ y,
659
+ l,
660
+ p,
661
+ this.params.arrowWidth
662
+ );
663
+ this.targetArrow.setAttribute("d", f);
664
+ }
665
+ }
666
+ }
667
+ class De {
668
+ constructor(e) {
669
+ i(this, "svg");
670
+ i(this, "arrowLength");
671
+ i(this, "arrowWidth");
672
+ i(this, "curvature");
673
+ i(this, "portCycleRadius");
674
+ i(this, "portCycleSmallRadius");
675
+ i(this, "detourDirection");
676
+ i(this, "detourDistance");
677
+ i(this, "hasSourceArrow");
678
+ i(this, "hasTargetArrow");
679
+ i(this, "genericShape");
680
+ i(this, "createCyclePath", (e) => me({
681
+ fromVector: e,
638
682
  radius: this.portCycleRadius,
639
683
  smallRadius: this.portCycleSmallRadius,
640
684
  arrowLength: this.arrowLength,
641
685
  hasSourceArrow: this.hasSourceArrow,
642
686
  hasTargetArrow: this.hasTargetArrow
643
- }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = be({
644
- to: l,
645
- fromVector: c,
646
- toVector: a,
647
- flipX: n,
648
- flipY: d,
687
+ }));
688
+ i(this, "createDetourPath", (e, o, r, s, h) => Ee({
689
+ to: r,
690
+ fromVector: e,
691
+ toVector: o,
692
+ flipX: s,
693
+ flipY: h,
649
694
  arrowLength: this.arrowLength,
650
695
  detourDirection: this.detourDirection,
651
696
  detourDistance: this.detourDistance,
652
697
  curvature: this.curvature,
653
698
  hasSourceArrow: this.hasSourceArrow,
654
699
  hasTargetArrow: this.hasTargetArrow
655
- }) : g = Se({
656
- to: l,
657
- fromVector: c,
658
- toVector: a,
700
+ }));
701
+ i(this, "createLinePath", (e, o, r) => xe({
702
+ to: r,
703
+ fromVector: e,
704
+ toVector: o,
659
705
  arrowLength: this.arrowLength,
660
706
  curvature: this.curvature,
661
707
  hasSourceArrow: this.hasSourceArrow,
662
708
  hasTargetArrow: this.hasTargetArrow
663
- }), this.line.setAttribute("d", g), this.sourceArrow) {
664
- const f = N(
665
- c,
666
- w,
667
- this.arrowLength,
668
- this.arrowWidth
669
- );
670
- this.sourceArrow.setAttribute("d", f);
671
- }
672
- if (this.targetArrow) {
673
- const f = N(
674
- y,
675
- l,
676
- v,
677
- this.arrowWidth
678
- );
679
- this.targetArrow.setAttribute("d", f);
680
- }
709
+ }));
710
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.curvature = (e == null ? void 0 : e.curvature) ?? u.curvature, this.portCycleRadius = (e == null ? void 0 : e.cycleRadius) ?? u.cycleRadius, this.portCycleSmallRadius = (e == null ? void 0 : e.smallCycleRadius) ?? u.smallCycleRadius, this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
711
+ color: (e == null ? void 0 : e.color) ?? u.color,
712
+ width: (e == null ? void 0 : e.width) ?? u.width,
713
+ arrowLength: this.arrowLength,
714
+ arrowWidth: this.arrowWidth,
715
+ hasSourceArrow: this.hasSourceArrow,
716
+ hasTargetArrow: this.hasTargetArrow,
717
+ createCyclePath: this.createCyclePath,
718
+ createDetourPath: this.createDetourPath,
719
+ createLinePath: this.createLinePath
720
+ }), this.svg = this.genericShape.svg;
721
+ }
722
+ render(e) {
723
+ this.genericShape.render(e);
681
724
  }
682
725
  }
683
- class De {
726
+ class Ve {
684
727
  constructor(e) {
685
- i(this, "svg", $());
686
- i(this, "group", W());
687
- i(this, "line");
688
- i(this, "sourceArrow", null);
689
- i(this, "targetArrow", null);
728
+ i(this, "svg");
690
729
  i(this, "arrowLength");
691
730
  i(this, "arrowWidth");
692
731
  i(this, "arrowOffset");
@@ -696,45 +735,22 @@ class De {
696
735
  i(this, "detourDistance");
697
736
  i(this, "hasSourceArrow");
698
737
  i(this, "hasTargetArrow");
699
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
700
- const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
701
- this.roundness = Math.min(
702
- o,
703
- this.arrowOffset,
704
- this.cycleSquareSide / 2
705
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
706
- const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
707
- this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
708
- }
709
- render(e) {
710
- const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
711
- e.from,
712
- e.to
713
- );
714
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
715
- const c = T(
716
- e.from.direction,
717
- n,
718
- d
719
- ), a = T(e.to.direction, n, d), l = {
720
- x: s,
721
- y: h
722
- };
723
- let g, y = a, v = -this.arrowLength;
724
- if (e.from.portId === e.to.portId ? (g = j({
725
- fromVector: c,
738
+ i(this, "genericShape");
739
+ i(this, "createCyclePath", (e) => z({
740
+ fromVector: e,
726
741
  arrowLength: this.arrowLength,
727
742
  side: this.cycleSquareSide,
728
743
  arrowOffset: this.arrowOffset,
729
744
  roundness: this.roundness,
730
745
  hasSourceArrow: this.hasSourceArrow,
731
746
  hasTargetArrow: this.hasTargetArrow
732
- }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
733
- to: l,
734
- fromVector: c,
735
- toVector: a,
736
- flipX: n,
737
- flipY: d,
747
+ }));
748
+ i(this, "createDetourPath", (e, o, r, s, h) => F({
749
+ to: r,
750
+ fromVector: e,
751
+ toVector: o,
752
+ flipX: s,
753
+ flipY: h,
738
754
  arrowLength: this.arrowLength,
739
755
  arrowOffset: this.arrowOffset,
740
756
  roundness: this.roundness,
@@ -742,43 +758,43 @@ class De {
742
758
  detourDistance: this.detourDistance,
743
759
  hasSourceArrow: this.hasSourceArrow,
744
760
  hasTargetArrow: this.hasTargetArrow
745
- }) : g = me({
746
- to: l,
747
- fromVector: c,
748
- toVector: a,
749
- flipX: n,
761
+ }));
762
+ i(this, "createLinePath", (e, o, r, s) => Ae({
763
+ to: r,
764
+ fromVector: e,
765
+ toVector: o,
766
+ flipX: s,
750
767
  arrowLength: this.arrowLength,
751
768
  arrowOffset: this.arrowOffset,
752
769
  roundness: this.roundness,
753
770
  hasSourceArrow: this.hasSourceArrow,
754
771
  hasTargetArrow: this.hasTargetArrow
755
- }), this.line.setAttribute("d", g), this.sourceArrow) {
756
- const f = N(
757
- c,
758
- w,
759
- this.arrowLength,
760
- this.arrowWidth
761
- );
762
- this.sourceArrow.setAttribute("d", f);
763
- }
764
- if (this.targetArrow) {
765
- const f = N(
766
- y,
767
- l,
768
- v,
769
- this.arrowWidth
770
- );
771
- this.targetArrow.setAttribute("d", f);
772
- }
772
+ }));
773
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
774
+ const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
775
+ this.roundness = Math.min(
776
+ o,
777
+ this.arrowOffset,
778
+ this.cycleSquareSide / 2
779
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
780
+ color: (e == null ? void 0 : e.color) ?? u.color,
781
+ width: (e == null ? void 0 : e.width) ?? u.width,
782
+ arrowLength: this.arrowLength,
783
+ arrowWidth: this.arrowWidth,
784
+ hasSourceArrow: this.hasSourceArrow,
785
+ hasTargetArrow: this.hasTargetArrow,
786
+ createCyclePath: this.createCyclePath,
787
+ createDetourPath: this.createDetourPath,
788
+ createLinePath: this.createLinePath
789
+ }), this.svg = this.genericShape.svg;
790
+ }
791
+ render(e) {
792
+ this.genericShape.render(e);
773
793
  }
774
794
  }
775
- class Ve {
795
+ class Le {
776
796
  constructor(e) {
777
- i(this, "svg", $());
778
- i(this, "group", W());
779
- i(this, "line");
780
- i(this, "sourceArrow", null);
781
- i(this, "targetArrow", null);
797
+ i(this, "svg");
782
798
  i(this, "arrowLength");
783
799
  i(this, "arrowWidth");
784
800
  i(this, "arrowOffset");
@@ -788,45 +804,22 @@ class Ve {
788
804
  i(this, "detourDistance");
789
805
  i(this, "hasSourceArrow");
790
806
  i(this, "hasTargetArrow");
791
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
792
- const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
793
- this.roundness = Math.min(
794
- o,
795
- this.arrowOffset,
796
- this.cycleSquareSide / 2
797
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
798
- const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
799
- this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
800
- }
801
- render(e) {
802
- const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
803
- e.from,
804
- e.to
805
- );
806
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
807
- const c = T(
808
- e.from.direction,
809
- n,
810
- d
811
- ), a = T(e.to.direction, n, d), l = {
812
- x: s,
813
- y: h
814
- };
815
- let g, y = a, v = -this.arrowLength;
816
- if (e.from.portId === e.to.portId ? (g = j({
817
- fromVector: c,
807
+ i(this, "genericShape");
808
+ i(this, "createCyclePath", (e) => z({
809
+ fromVector: e,
818
810
  arrowLength: this.arrowLength,
819
811
  side: this.cycleSquareSide,
820
812
  arrowOffset: this.arrowOffset,
821
813
  roundness: this.roundness,
822
814
  hasSourceArrow: this.hasSourceArrow,
823
815
  hasTargetArrow: this.hasTargetArrow
824
- }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
825
- to: l,
826
- fromVector: c,
827
- toVector: a,
828
- flipX: n,
829
- flipY: d,
816
+ }));
817
+ i(this, "createDetourPath", (e, o, r, s, h) => F({
818
+ to: r,
819
+ fromVector: e,
820
+ toVector: o,
821
+ flipX: s,
822
+ flipY: h,
830
823
  arrowLength: this.arrowLength,
831
824
  arrowOffset: this.arrowOffset,
832
825
  roundness: this.roundness,
@@ -834,42 +827,42 @@ class Ve {
834
827
  detourDistance: this.detourDistance,
835
828
  hasSourceArrow: this.hasSourceArrow,
836
829
  hasTargetArrow: this.hasTargetArrow
837
- }) : g = Te({
838
- to: l,
839
- fromVector: c,
840
- toVector: a,
830
+ }));
831
+ i(this, "createLinePath", (e, o, r) => Se({
832
+ to: r,
833
+ fromVector: e,
834
+ toVector: o,
841
835
  arrowLength: this.arrowLength,
842
836
  arrowOffset: this.arrowOffset,
843
837
  roundness: this.roundness,
844
838
  hasSourceArrow: this.hasSourceArrow,
845
839
  hasTargetArrow: this.hasTargetArrow
846
- }), this.line.setAttribute("d", g), this.sourceArrow) {
847
- const f = N(
848
- c,
849
- w,
850
- this.arrowLength,
851
- this.arrowWidth
852
- );
853
- this.sourceArrow.setAttribute("d", f);
854
- }
855
- if (this.targetArrow) {
856
- const f = N(
857
- y,
858
- l,
859
- v,
860
- this.arrowWidth
861
- );
862
- this.targetArrow.setAttribute("d", f);
863
- }
840
+ }));
841
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
842
+ const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
843
+ this.roundness = Math.min(
844
+ o,
845
+ this.arrowOffset,
846
+ this.cycleSquareSide / 2
847
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirection, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
848
+ color: (e == null ? void 0 : e.color) ?? u.color,
849
+ width: (e == null ? void 0 : e.width) ?? u.width,
850
+ arrowLength: this.arrowLength,
851
+ arrowWidth: this.arrowWidth,
852
+ hasSourceArrow: this.hasSourceArrow,
853
+ hasTargetArrow: this.hasTargetArrow,
854
+ createCyclePath: this.createCyclePath,
855
+ createDetourPath: this.createDetourPath,
856
+ createLinePath: this.createLinePath
857
+ }), this.svg = this.genericShape.svg;
858
+ }
859
+ render(e) {
860
+ this.genericShape.render(e);
864
861
  }
865
862
  }
866
- class Le {
863
+ class Re {
867
864
  constructor(e) {
868
- i(this, "svg", $());
869
- i(this, "group", W());
870
- i(this, "line");
871
- i(this, "sourceArrow", null);
872
- i(this, "targetArrow", null);
865
+ i(this, "svg");
873
866
  i(this, "arrowLength");
874
867
  i(this, "arrowWidth");
875
868
  i(this, "arrowOffset");
@@ -879,45 +872,22 @@ class Le {
879
872
  i(this, "detourDistance");
880
873
  i(this, "hasSourceArrow");
881
874
  i(this, "hasTargetArrow");
882
- this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
883
- const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
884
- this.roundness = Math.min(
885
- o,
886
- this.arrowOffset,
887
- this.cycleSquareSide / 2
888
- ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow;
889
- const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
890
- this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = P(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = P(r), this.group.appendChild(this.targetArrow));
891
- }
892
- render(e) {
893
- const { x: o, y: r, width: s, height: h, flipX: n, flipY: d } = z(
894
- e.from,
895
- e.to
896
- );
897
- this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${Math.max(s, 1)}px`, this.svg.style.height = `${Math.max(h, 1)}px`, this.group.style.transform = `scale(${n}, ${d})`;
898
- const c = T(
899
- e.from.direction,
900
- n,
901
- d
902
- ), a = T(e.to.direction, n, d), l = {
903
- x: s,
904
- y: h
905
- };
906
- let g, y = a, v = -this.arrowLength;
907
- if (e.from.portId === e.to.portId ? (g = j({
908
- fromVector: c,
875
+ i(this, "genericShape");
876
+ i(this, "createCyclePath", (e) => z({
877
+ fromVector: e,
909
878
  arrowLength: this.arrowLength,
910
879
  side: this.cycleSquareSide,
911
880
  arrowOffset: this.arrowOffset,
912
881
  roundness: this.roundness,
913
882
  hasSourceArrow: this.hasSourceArrow,
914
883
  hasTargetArrow: this.hasTargetArrow
915
- }), y = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
916
- to: l,
917
- fromVector: c,
918
- toVector: a,
919
- flipX: n,
920
- flipY: d,
884
+ }));
885
+ i(this, "createDetourPath", (e, o, r, s, h) => F({
886
+ to: r,
887
+ fromVector: e,
888
+ toVector: o,
889
+ flipX: s,
890
+ flipY: h,
921
891
  arrowLength: this.arrowLength,
922
892
  arrowOffset: this.arrowOffset,
923
893
  roundness: this.roundness,
@@ -925,42 +895,46 @@ class Le {
925
895
  detourDistance: this.detourDistance,
926
896
  hasSourceArrow: this.hasSourceArrow,
927
897
  hasTargetArrow: this.hasTargetArrow
928
- }) : g = Ne({
929
- to: l,
930
- fromVector: c,
931
- toVector: a,
932
- flipY: d,
898
+ }));
899
+ i(this, "createLinePath", (e, o, r, s, h) => Te({
900
+ to: r,
901
+ fromVector: e,
902
+ toVector: o,
903
+ flipY: h,
933
904
  arrowLength: this.arrowLength,
934
905
  arrowOffset: this.arrowOffset,
935
906
  roundness: this.roundness,
936
907
  hasSourceArrow: this.hasSourceArrow,
937
908
  hasTargetArrow: this.hasTargetArrow
938
- }), this.line.setAttribute("d", g), this.sourceArrow) {
939
- const f = N(
940
- c,
941
- w,
942
- this.arrowLength,
943
- this.arrowWidth
944
- );
945
- this.sourceArrow.setAttribute("d", f);
946
- }
947
- if (this.targetArrow) {
948
- const f = N(
949
- y,
950
- l,
951
- v,
952
- this.arrowWidth
953
- );
954
- this.targetArrow.setAttribute("d", f);
955
- }
909
+ }));
910
+ this.arrowLength = (e == null ? void 0 : e.arrowLength) ?? u.arrowLength, this.arrowWidth = (e == null ? void 0 : e.arrowWidth) ?? u.arrowWidth, this.arrowOffset = (e == null ? void 0 : e.arrowOffset) ?? u.arrowOffset, this.cycleSquareSide = (e == null ? void 0 : e.cycleSquareSide) ?? u.cycleSquareSide;
911
+ const o = (e == null ? void 0 : e.roundness) ?? u.roundness;
912
+ this.roundness = Math.min(
913
+ o,
914
+ this.arrowOffset,
915
+ this.cycleSquareSide / 2
916
+ ), this.detourDirection = (e == null ? void 0 : e.detourDirection) ?? u.detourDirectionVertical, this.detourDistance = (e == null ? void 0 : e.detourDistance) ?? u.detourDistance, this.hasSourceArrow = (e == null ? void 0 : e.hasSourceArrow) ?? u.hasSourceArrow, this.hasTargetArrow = (e == null ? void 0 : e.hasTargetArrow) ?? u.hasTargetArrow, this.genericShape = new I({
917
+ color: (e == null ? void 0 : e.color) ?? u.color,
918
+ width: (e == null ? void 0 : e.width) ?? u.width,
919
+ arrowLength: this.arrowLength,
920
+ arrowWidth: this.arrowWidth,
921
+ hasSourceArrow: this.hasSourceArrow,
922
+ hasTargetArrow: this.hasTargetArrow,
923
+ createCyclePath: this.createCyclePath,
924
+ createDetourPath: this.createDetourPath,
925
+ createLinePath: this.createLinePath
926
+ }), this.svg = this.genericShape.svg;
927
+ }
928
+ render(e) {
929
+ this.genericShape.render(e);
956
930
  }
957
931
  }
958
- const Re = (t) => {
932
+ const Be = (t) => {
959
933
  if (typeof t == "function")
960
934
  return t;
961
935
  switch (t == null ? void 0 : t.type) {
962
936
  case "straight":
963
- return () => new Ve({
937
+ return () => new Le({
964
938
  color: t.color,
965
939
  width: t.width,
966
940
  arrowLength: t.arrowLength,
@@ -974,7 +948,7 @@ const Re = (t) => {
974
948
  detourDirection: t.detourDirection
975
949
  });
976
950
  case "horizontal":
977
- return () => new De({
951
+ return () => new Ve({
978
952
  color: t.color,
979
953
  width: t.width,
980
954
  arrowLength: t.arrowLength,
@@ -988,7 +962,7 @@ const Re = (t) => {
988
962
  detourDirection: t.detourDirection
989
963
  });
990
964
  case "vertical":
991
- return () => new Le({
965
+ return () => new Re({
992
966
  color: t.color,
993
967
  width: t.width,
994
968
  arrowLength: t.arrowLength,
@@ -1002,7 +976,7 @@ const Re = (t) => {
1002
976
  detourDirection: t.detourDirection
1003
977
  });
1004
978
  default:
1005
- return () => new Me({
979
+ return () => new De({
1006
980
  color: t.color,
1007
981
  width: t.width,
1008
982
  arrowLength: t.arrowLength,
@@ -1016,27 +990,27 @@ const Re = (t) => {
1016
990
  detourDirection: t.detourDirection
1017
991
  });
1018
992
  }
1019
- }, Be = (t) => {
993
+ }, Ie = (t) => {
1020
994
  var o, r, s, h, n;
1021
- const e = Ee(
995
+ const e = pe(
1022
996
  (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
1023
997
  (r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
1024
998
  );
1025
999
  return {
1026
1000
  nodes: {
1027
- centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? xe,
1001
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? ve,
1028
1002
  priorityFn: e.nodesPriorityFn
1029
1003
  },
1030
1004
  ports: {
1031
1005
  direction: ((h = t == null ? void 0 : t.ports) == null ? void 0 : h.direction) ?? 0
1032
1006
  },
1033
1007
  edges: {
1034
- shapeFactory: Re(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1008
+ shapeFactory: Be(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1035
1009
  priorityFn: e.edgesPriorityFn
1036
1010
  }
1037
1011
  };
1038
1012
  };
1039
- class de {
1013
+ class se {
1040
1014
  constructor(e, o, r, s, h) {
1041
1015
  /**
1042
1016
  * provides api for accessing model of rendered graph
@@ -1047,13 +1021,13 @@ class de {
1047
1021
  */
1048
1022
  i(this, "viewport");
1049
1023
  i(this, "defaults");
1050
- i(this, "nodeIdGenerator", new O(
1024
+ i(this, "nodeIdGenerator", new C(
1051
1025
  (e) => this.graph.getNode(e) !== null
1052
1026
  ));
1053
- i(this, "portIdGenerator", new O(
1027
+ i(this, "portIdGenerator", new C(
1054
1028
  (e) => this.graph.getPort(e) !== null
1055
1029
  ));
1056
- i(this, "edgeIdGenerator", new O(
1030
+ i(this, "edgeIdGenerator", new C(
1057
1031
  (e) => this.graph.getEdge(e) !== null
1058
1032
  ));
1059
1033
  i(this, "onAfterNodeAdded", (e) => {
@@ -1105,13 +1079,13 @@ class de {
1105
1079
  * emits event just before destruction of canvas
1106
1080
  */
1107
1081
  i(this, "onBeforeDestroy");
1108
- this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Be(h), this.graph = new pe(this.graphStore), this.viewport = new ve(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1082
+ this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Ie(h), this.graph = new fe(this.graphStore), this.viewport = new we(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1109
1083
  this.onAfterNodePriorityUpdated
1110
1084
  ), this.graphStore.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graphStore.onAfterPortUpdated.subscribe(this.onAfterPortUpdated), this.graphStore.onBeforePortRemoved.subscribe(this.onBeforePortUnmarked), this.graphStore.onAfterEdgeAdded.subscribe(this.onAfterEdgeAdded), this.graphStore.onAfterEdgeShapeUpdated.subscribe(
1111
1085
  this.onAfterEdgeShapeUpdated
1112
1086
  ), this.graphStore.onAfterEdgeUpdated.subscribe(this.onAfterEdgeUpdated), this.graphStore.onAfterEdgePriorityUpdated.subscribe(
1113
1087
  this.onAfterEdgePriorityUpdated
1114
- ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = E();
1088
+ ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
1115
1089
  }
1116
1090
  /**
1117
1091
  * adds new node
@@ -1256,7 +1230,7 @@ class de {
1256
1230
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.htmlView.destroy();
1257
1231
  }
1258
1232
  }
1259
- class ce {
1233
+ class ne {
1260
1234
  constructor() {
1261
1235
  i(this, "nodes", /* @__PURE__ */ new Map());
1262
1236
  i(this, "ports", /* @__PURE__ */ new Map());
@@ -1290,7 +1264,7 @@ class ce {
1290
1264
  i(this, "onBeforeEdgeRemoved");
1291
1265
  i(this, "beforeClearEmitter");
1292
1266
  i(this, "onBeforeClear");
1293
- [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = E(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = E(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = E(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = E(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = E(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = E(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = E(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = E(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = E(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = E(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = E(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = E(), [this.beforeClearEmitter, this.onBeforeClear] = E();
1267
+ [this.afterNodeAddedEmitter, this.onAfterNodeAdded] = A(), [this.afterNodeUpdatedEmitter, this.onAfterNodeUpdated] = A(), [this.afterNodePriorityUpdatedEmitter, this.onAfterNodePriorityUpdated] = A(), [this.beforeNodeRemovedEmitter, this.onBeforeNodeRemoved] = A(), [this.afterPortAddedEmitter, this.onAfterPortAdded] = A(), [this.afterPortUpdatedEmitter, this.onAfterPortUpdated] = A(), [this.beforePortRemovedEmitter, this.onBeforePortRemoved] = A(), [this.afterEdgeAddedEmitter, this.onAfterEdgeAdded] = A(), [this.afterEdgeShapeUpdatedEmitter, this.onAfterEdgeShapeUpdated] = A(), [this.afterEdgeUpdatedEmitter, this.onAfterEdgeUpdated] = A(), [this.afterEdgePriorityUpdatedEmitter, this.onAfterEdgePriorityUpdated] = A(), [this.beforeEdgeRemovedEmitter, this.onBeforeEdgeRemoved] = A(), [this.beforeClearEmitter, this.onBeforeClear] = A();
1294
1268
  }
1295
1269
  addNode(e) {
1296
1270
  const o = /* @__PURE__ */ new Map(), r = {
@@ -1428,24 +1402,24 @@ class ce {
1428
1402
  this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incomingEdges.get(r).delete(e), this.incomingEdges.get(s).delete(e), this.outcomingEdges.get(r).delete(e), this.outcomingEdges.get(s).delete(e), this.edges.delete(e);
1429
1403
  }
1430
1404
  }
1431
- const re = (t) => ({
1405
+ const ee = (t) => ({
1432
1406
  scale: 1 / t.scale,
1433
1407
  x: -t.x / t.scale,
1434
1408
  y: -t.y / t.scale
1435
- }), ie = {
1409
+ }), te = {
1436
1410
  scale: 1,
1437
1411
  x: 0,
1438
1412
  y: 0
1439
1413
  };
1440
- class Ie {
1414
+ class Ue {
1441
1415
  constructor() {
1442
- i(this, "viewportMatrix", ie);
1443
- i(this, "contentMatrix", ie);
1416
+ i(this, "viewportMatrix", te);
1417
+ i(this, "contentMatrix", te);
1444
1418
  i(this, "afterUpdateEmitter");
1445
1419
  i(this, "onAfterUpdated");
1446
1420
  i(this, "beforeUpdateEmitter");
1447
1421
  i(this, "onBeforeUpdated");
1448
- [this.afterUpdateEmitter, this.onAfterUpdated] = E(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = E();
1422
+ [this.afterUpdateEmitter, this.onAfterUpdated] = A(), [this.beforeUpdateEmitter, this.onBeforeUpdated] = A();
1449
1423
  }
1450
1424
  getViewportMatrix() {
1451
1425
  return this.viewportMatrix;
@@ -1458,17 +1432,17 @@ class Ie {
1458
1432
  scale: e.scale ?? this.viewportMatrix.scale,
1459
1433
  x: e.x ?? this.viewportMatrix.x,
1460
1434
  y: e.y ?? this.viewportMatrix.y
1461
- }, this.contentMatrix = re(this.viewportMatrix), this.afterUpdateEmitter.emit();
1435
+ }, this.contentMatrix = ee(this.viewportMatrix), this.afterUpdateEmitter.emit();
1462
1436
  }
1463
1437
  patchContentMatrix(e) {
1464
1438
  this.beforeUpdateEmitter.emit(), this.contentMatrix = {
1465
1439
  scale: e.scale ?? this.contentMatrix.scale,
1466
1440
  x: e.x ?? this.contentMatrix.x,
1467
1441
  y: e.y ?? this.contentMatrix.y
1468
- }, this.viewportMatrix = re(this.contentMatrix), this.afterUpdateEmitter.emit();
1442
+ }, this.viewportMatrix = ee(this.contentMatrix), this.afterUpdateEmitter.emit();
1469
1443
  }
1470
1444
  }
1471
- class G {
1445
+ class k {
1472
1446
  constructor(e) {
1473
1447
  i(this, "elementToNodeId", /* @__PURE__ */ new Map());
1474
1448
  i(this, "nodesResizeObserver");
@@ -1494,37 +1468,37 @@ class G {
1494
1468
  }), this.canvas.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.canvas.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1495
1469
  }
1496
1470
  static configure(e) {
1497
- new G(e);
1471
+ new k(e);
1498
1472
  }
1499
1473
  handleNodeResize(e) {
1500
1474
  const o = this.elementToNodeId.get(e);
1501
1475
  this.canvas.updateNode(o);
1502
1476
  }
1503
1477
  }
1504
- const Ue = (t) => {
1505
- var g, y, v, f, A, x;
1478
+ const Ce = (t) => {
1479
+ var g, y, p, f, E, x;
1506
1480
  const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1507
- }), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
1508
- }), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (A = t == null ? void 0 : t.mouse) == null ? void 0 : A.mouseDownEventVerifier, c = d !== void 0 ? d : (b) => b.button === 0, a = (x = t == null ? void 0 : t.mouse) == null ? void 0 : x.mouseUpEventVerifier;
1481
+ }), o = ((y = t == null ? void 0 : t.events) == null ? void 0 : y.onBeforeNodeDrag) ?? (() => !0), r = ((p = t == null ? void 0 : t.events) == null ? void 0 : p.onNodeDragFinished) ?? (() => {
1482
+ }), s = (t == null ? void 0 : t.moveOnTop) === !1, h = (f = t == null ? void 0 : t.mouse) == null ? void 0 : f.dragCursor, n = h !== void 0 ? h : "grab", d = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseDownEventVerifier, c = d !== void 0 ? d : (T) => T.button === 0, a = (x = t == null ? void 0 : t.mouse) == null ? void 0 : x.mouseUpEventVerifier;
1509
1483
  return {
1510
1484
  freezePriority: s,
1511
1485
  dragCursor: n,
1512
1486
  mouseDownEventVerifier: c,
1513
- mouseUpEventVerifier: a !== void 0 ? a : (b) => b.button === 0,
1487
+ mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
1514
1488
  onNodeDrag: e,
1515
1489
  onBeforeNodeDrag: o,
1516
1490
  onNodeDragFinished: r
1517
1491
  };
1518
- }, Ce = (t, e, o) => {
1492
+ }, We = (t, e, o) => {
1519
1493
  const { x: r, y: s, width: h, height: n } = t.getBoundingClientRect();
1520
1494
  return e >= r && e <= r + h && o >= s && o <= s + n;
1521
- }, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, L = (t, e, o, r) => Ce(e, o, r) && $e(t, o, r), C = (t, e) => {
1495
+ }, $e = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, M = (t, e, o, r) => We(e, o, r) && $e(t, o, r), B = (t, e) => {
1522
1496
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
1523
- }, V = (t, e) => ({
1497
+ }, N = (t, e) => ({
1524
1498
  x: t.scale * e.x + t.x,
1525
1499
  y: t.scale * e.y + t.y
1526
1500
  });
1527
- class J {
1501
+ class O {
1528
1502
  constructor(e, o, r, s) {
1529
1503
  i(this, "grabbedNodeId", null);
1530
1504
  i(this, "maxNodePriority", 0);
@@ -1534,7 +1508,11 @@ class J {
1534
1508
  i(this, "onAfterNodeAdded", (e) => {
1535
1509
  this.updateMaxNodePriority(e);
1536
1510
  const o = this.graph.getNode(e);
1537
- this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown), o.element.addEventListener("touchstart", this.onTouchStart);
1511
+ this.nodeIds.set(o.element, e), o.element.addEventListener("mousedown", this.onMouseDown, {
1512
+ passive: !0
1513
+ }), o.element.addEventListener("touchstart", this.onTouchStart, {
1514
+ passive: !0
1515
+ });
1538
1516
  });
1539
1517
  i(this, "onAfterNodeUpdated", (e) => {
1540
1518
  this.updateMaxNodePriority(e);
@@ -1560,7 +1538,11 @@ class J {
1560
1538
  element: s.element,
1561
1539
  x: s.x,
1562
1540
  y: s.y
1563
- }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, C(this.element, this.config.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1541
+ }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, B(this.element, this.config.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
1542
+ passive: !0
1543
+ }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
1544
+ passive: !0
1545
+ }));
1564
1546
  });
1565
1547
  i(this, "onTouchStart", (e) => {
1566
1548
  if (e.touches.length !== 1)
@@ -1575,10 +1557,16 @@ class J {
1575
1557
  element: s.element,
1576
1558
  x: s.x,
1577
1559
  y: s.y
1578
- }) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish));
1560
+ }) && (this.grabbedNodeId = r, this.moveNodeOnTop(r), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
1561
+ passive: !0
1562
+ }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
1563
+ passive: !0
1564
+ }), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
1565
+ passive: !0
1566
+ }));
1579
1567
  });
1580
1568
  i(this, "onWindowMouseMove", (e) => {
1581
- if (!L(
1569
+ if (!M(
1582
1570
  this.window,
1583
1571
  this.element,
1584
1572
  e.clientX,
@@ -1596,7 +1584,7 @@ class J {
1596
1584
  if (e.touches.length !== 1)
1597
1585
  return;
1598
1586
  const o = e.touches[0];
1599
- if (!L(
1587
+ if (!M(
1600
1588
  this.window,
1601
1589
  this.element,
1602
1590
  o.clientX,
@@ -1617,22 +1605,22 @@ class J {
1617
1605
  this.previousTouchCoordinates = null, this.cancelTouchDrag();
1618
1606
  });
1619
1607
  i(this, "config");
1620
- this.canvas = e, this.element = o, this.window = r, this.config = Ue(s), this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1608
+ this.canvas = e, this.element = o, this.window = r, this.config = Ce(s), this.graph = e.graph, this.graph.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graph.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graph.onBeforeNodeRemoved.subscribe(this.onBeforeNodeRemoved), this.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1621
1609
  }
1622
1610
  static configure(e, o, r, s) {
1623
- new J(e, o, r, s);
1611
+ new O(e, o, r, s);
1624
1612
  }
1625
1613
  dragNode(e, o, r) {
1626
1614
  const s = this.graph.getNode(e);
1627
1615
  if (s === null)
1628
1616
  return;
1629
- const h = this.canvas.viewport.getContentMatrix(), n = V(h, {
1617
+ const h = this.canvas.viewport.getContentMatrix(), n = N(h, {
1630
1618
  x: s.x,
1631
1619
  y: s.y
1632
- }), d = V(
1620
+ }), d = N(
1633
1621
  { scale: 1, x: o, y: r },
1634
1622
  n
1635
- ), c = this.canvas.viewport.getViewportMatrix(), a = V(c, d);
1623
+ ), c = this.canvas.viewport.getViewportMatrix(), a = N(c, d);
1636
1624
  this.canvas.updateNode(e, { x: a.x, y: a.y }), this.config.onNodeDrag({
1637
1625
  nodeId: e,
1638
1626
  element: s.element,
@@ -1656,7 +1644,7 @@ class J {
1656
1644
  element: e.element,
1657
1645
  x: e.x,
1658
1646
  y: e.y
1659
- }), this.grabbedNodeId = null, C(this.element, null), this.removeMouseDragListeners();
1647
+ }), this.grabbedNodeId = null, B(this.element, null), this.removeMouseDragListeners();
1660
1648
  }
1661
1649
  removeMouseDragListeners() {
1662
1650
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
@@ -1679,7 +1667,7 @@ class J {
1679
1667
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
1680
1668
  }
1681
1669
  }
1682
- const We = (t) => {
1670
+ const Fe = (t) => {
1683
1671
  const e = t.minX !== null ? t.minX : -1 / 0, o = t.maxX !== null ? t.maxX : 1 / 0, r = t.minY !== null ? t.minY : -1 / 0, s = t.maxY !== null ? t.maxY : 1 / 0;
1684
1672
  return (h) => {
1685
1673
  let n = h.nextTransform.x, d = h.nextTransform.y;
@@ -1689,7 +1677,7 @@ const We = (t) => {
1689
1677
  const l = h.canvasHeight * h.prevTransform.scale, g = s - l;
1690
1678
  return d > g && d > h.prevTransform.y && (d = Math.max(h.prevTransform.y, g)), { scale: h.nextTransform.scale, x: n, y: d };
1691
1679
  };
1692
- }, Fe = (t) => {
1680
+ }, ze = (t) => {
1693
1681
  const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
1694
1682
  return (h) => {
1695
1683
  const n = h.prevTransform, d = h.nextTransform;
@@ -1710,7 +1698,7 @@ const We = (t) => {
1710
1698
  y: l
1711
1699
  };
1712
1700
  };
1713
- }, ze = (t) => (e) => t.reduce(
1701
+ }, ke = (t) => (e) => t.reduce(
1714
1702
  (o, r) => r({
1715
1703
  prevTransform: e.prevTransform,
1716
1704
  nextTransform: o,
@@ -1718,40 +1706,40 @@ const We = (t) => {
1718
1706
  canvasHeight: e.canvasHeight
1719
1707
  }),
1720
1708
  e.nextTransform
1721
- ), se = (t) => {
1709
+ ), oe = (t) => {
1722
1710
  if (typeof t == "function")
1723
1711
  return t;
1724
1712
  switch (t.type) {
1725
1713
  case "scale-limit":
1726
- return Fe({
1714
+ return ze({
1727
1715
  minContentScale: t.minContentScale ?? 0,
1728
1716
  maxContentScale: t.maxContentScale ?? 1 / 0
1729
1717
  });
1730
1718
  case "shift-limit":
1731
- return We({
1719
+ return Fe({
1732
1720
  minX: t.minX ?? -1 / 0,
1733
1721
  maxX: t.maxX ?? 1 / 0,
1734
1722
  minY: t.minY ?? -1 / 0,
1735
1723
  maxY: t.maxY ?? 1 / 0
1736
1724
  });
1737
1725
  }
1738
- }, ke = (t) => {
1739
- var f, A, x, b, M, m, R, B, _, q, ee, te;
1726
+ }, Oe = (t) => {
1727
+ var f, E, x, T, b, m, D, V, j, G, J, K;
1740
1728
  const e = (f = t == null ? void 0 : t.scale) == null ? void 0 : f.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
1741
1729
  let s;
1742
- r !== void 0 ? Array.isArray(r) ? s = ze(
1730
+ r !== void 0 ? Array.isArray(r) ? s = ke(
1743
1731
  r.map(
1744
- (D) => se(D)
1732
+ (P) => oe(P)
1745
1733
  )
1746
- ) : s = se(r) : s = (D) => D.nextTransform;
1747
- const h = ((A = t == null ? void 0 : t.shift) == null ? void 0 : A.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
1748
- }), d = ((b = t == null ? void 0 : t.events) == null ? void 0 : b.onTransformChange) ?? (() => {
1749
- }), c = (M = t == null ? void 0 : t.shift) == null ? void 0 : M.mouseDownEventVerifier, a = c !== void 0 ? c : (D) => D.button === 0, l = (m = t == null ? void 0 : t.shift) == null ? void 0 : m.mouseUpEventVerifier, g = l !== void 0 ? l : (D) => D.button === 0, y = (R = t == null ? void 0 : t.scale) == null ? void 0 : R.mouseWheelEventVerifier, v = y !== void 0 ? y : () => !0;
1734
+ ) : s = oe(r) : s = (P) => P.nextTransform;
1735
+ const h = ((E = t == null ? void 0 : t.shift) == null ? void 0 : E.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((x = t == null ? void 0 : t.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
1736
+ }), d = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
1737
+ }), c = (b = t == null ? void 0 : t.shift) == null ? void 0 : b.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (m = t == null ? void 0 : t.shift) == null ? void 0 : m.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, y = (D = t == null ? void 0 : t.scale) == null ? void 0 : D.mouseWheelEventVerifier, p = y !== void 0 ? y : () => !0;
1750
1738
  return {
1751
1739
  wheelSensitivity: o,
1752
- onTransformStarted: ((B = t == null ? void 0 : t.events) == null ? void 0 : B.onTransformStarted) ?? (() => {
1740
+ onTransformStarted: ((V = t == null ? void 0 : t.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
1753
1741
  }),
1754
- onTransformFinished: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onTransformFinished) ?? (() => {
1742
+ onTransformFinished: ((j = t == null ? void 0 : t.events) == null ? void 0 : j.onTransformFinished) ?? (() => {
1755
1743
  }),
1756
1744
  onBeforeTransformChange: n,
1757
1745
  onTransformChange: d,
@@ -1759,14 +1747,14 @@ const We = (t) => {
1759
1747
  shiftCursor: h,
1760
1748
  mouseDownEventVerifier: a,
1761
1749
  mouseUpEventVerifier: g,
1762
- mouseWheelEventVerifier: v,
1763
- scaleWheelFinishTimeout: ((q = t == null ? void 0 : t.scale) == null ? void 0 : q.wheelFinishTimeout) ?? 500,
1764
- onResizeTransformStarted: ((ee = t == null ? void 0 : t.events) == null ? void 0 : ee.onResizeTransformStarted) ?? (() => {
1750
+ mouseWheelEventVerifier: p,
1751
+ scaleWheelFinishTimeout: ((G = t == null ? void 0 : t.scale) == null ? void 0 : G.wheelFinishTimeout) ?? 500,
1752
+ onResizeTransformStarted: ((J = t == null ? void 0 : t.events) == null ? void 0 : J.onResizeTransformStarted) ?? (() => {
1765
1753
  }),
1766
- onResizeTransformFinished: ((te = t == null ? void 0 : t.events) == null ? void 0 : te.onResizeTransformFinished) ?? (() => {
1754
+ onResizeTransformFinished: ((K = t == null ? void 0 : t.events) == null ? void 0 : K.onResizeTransformFinished) ?? (() => {
1767
1755
  })
1768
1756
  };
1769
- }, Oe = (t, e, o) => ({
1757
+ }, Xe = (t, e, o) => ({
1770
1758
  scale: t.scale,
1771
1759
  x: t.x + t.scale * e,
1772
1760
  y: t.y + t.scale * o
@@ -1774,7 +1762,7 @@ const We = (t) => {
1774
1762
  scale: t.scale * e,
1775
1763
  x: t.scale * (1 - e) * o + t.x,
1776
1764
  y: t.scale * (1 - e) * r + t.y
1777
- }), U = (t) => {
1765
+ }), R = (t) => {
1778
1766
  const e = [], o = t.touches.length;
1779
1767
  for (let d = 0; d < o; d++)
1780
1768
  e.push([t.touches[d].clientX, t.touches[d].clientY]);
@@ -1793,20 +1781,24 @@ const We = (t) => {
1793
1781
  touches: e
1794
1782
  };
1795
1783
  };
1796
- class k {
1784
+ class U {
1797
1785
  constructor(e, o, r, s) {
1798
1786
  i(this, "viewport");
1799
1787
  i(this, "prevTouches", null);
1800
1788
  i(this, "wheelFinishTimer", null);
1801
1789
  i(this, "transformInProgress", !1);
1802
1790
  i(this, "onBeforeDestroy", () => {
1803
- this.removeMouseDragListeners(), this.removeTouchDragListeners(), this.observer.unobserve(this.element), this.element.removeEventListener("mousedown", this.onMouseDown), this.element.removeEventListener("wheel", this.onWheelScroll), this.element.removeEventListener("touchstart", this.onTouchStart), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1791
+ this.removeMouseDragListeners(), this.removeTouchDragListeners(), 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.removeEventListener("wheel", this.preventWheelScaleListener), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
1804
1792
  });
1805
1793
  i(this, "onMouseDown", (e) => {
1806
- this.element === null || !this.config.mouseDownEventVerifier(e) || (C(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
1794
+ this.element === null || !this.config.mouseDownEventVerifier(e) || (B(this.element, this.config.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
1795
+ passive: !0
1796
+ }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
1797
+ passive: !0
1798
+ }), this.startRegisteredTransform());
1807
1799
  });
1808
1800
  i(this, "onWindowMouseMove", (e) => {
1809
- const o = L(
1801
+ const o = M(
1810
1802
  this.window,
1811
1803
  this.element,
1812
1804
  e.clientX,
@@ -1825,7 +1817,6 @@ class k {
1825
1817
  i(this, "onWheelScroll", (e) => {
1826
1818
  if (!this.config.mouseWheelEventVerifier(e))
1827
1819
  return;
1828
- e.preventDefault();
1829
1820
  const { left: o, top: r } = this.element.getBoundingClientRect(), s = e.clientX - o, h = e.clientY - r, d = 1 / (e.deltaY < 0 ? this.config.wheelSensitivity : 1 / this.config.wheelSensitivity);
1830
1821
  this.wheelFinishTimer === null && this.config.onTransformStarted(), this.scaleViewport(d, s, h), this.wheelFinishTimer !== null && clearTimeout(this.wheelFinishTimer), this.wheelFinishTimer = setTimeout(() => {
1831
1822
  this.transformInProgress || this.config.onTransformFinished(), this.wheelFinishTimer = null;
@@ -1833,15 +1824,21 @@ class k {
1833
1824
  });
1834
1825
  i(this, "onTouchStart", (e) => {
1835
1826
  if (this.prevTouches !== null) {
1836
- this.prevTouches = U(e);
1827
+ this.prevTouches = R(e);
1837
1828
  return;
1838
1829
  }
1839
- this.prevTouches = U(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
1830
+ this.prevTouches = R(e), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
1831
+ passive: !0
1832
+ }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
1833
+ passive: !0
1834
+ }), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
1835
+ passive: !0
1836
+ }), this.startRegisteredTransform();
1840
1837
  });
1841
1838
  i(this, "onWindowTouchMove", (e) => {
1842
- const o = U(e);
1839
+ const o = R(e);
1843
1840
  if (!o.touches.every(
1844
- (s) => L(this.window, this.element, s[0], s[1])
1841
+ (s) => M(this.window, this.element, s[0], s[1])
1845
1842
  )) {
1846
1843
  this.stopTouchDrag();
1847
1844
  return;
@@ -1856,7 +1853,7 @@ class k {
1856
1853
  this.prevTouches = o;
1857
1854
  });
1858
1855
  i(this, "onWindowTouchFinish", (e) => {
1859
- e.touches.length > 0 ? this.prevTouches = U(e) : this.stopTouchDrag();
1856
+ e.touches.length > 0 ? this.prevTouches = R(e) : this.stopTouchDrag();
1860
1857
  });
1861
1858
  i(this, "observer", new ResizeObserver(() => {
1862
1859
  const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.config.transformPreprocessor({
@@ -1868,10 +1865,21 @@ class k {
1868
1865
  this.config.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.config.onResizeTransformFinished();
1869
1866
  }));
1870
1867
  i(this, "config");
1871
- this.canvas = e, this.element = o, this.window = r, this.config = ke(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown), this.element.addEventListener("wheel", this.onWheelScroll), this.element.addEventListener("touchstart", this.onTouchStart), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1868
+ i(this, "preventWheelScaleListener", (e) => {
1869
+ e.preventDefault();
1870
+ });
1871
+ this.canvas = e, this.element = o, this.window = r, this.element.addEventListener("wheel", this.preventWheelScaleListener, {
1872
+ passive: !1
1873
+ }), this.config = Oe(s), this.viewport = e.viewport, this.observer.observe(this.element), this.element.addEventListener("mousedown", this.onMouseDown, {
1874
+ passive: !0
1875
+ }), this.element.addEventListener("wheel", this.onWheelScroll, {
1876
+ passive: !0
1877
+ }), this.element.addEventListener("touchstart", this.onTouchStart, {
1878
+ passive: !0
1879
+ }), e.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1872
1880
  }
1873
1881
  static configure(e, o, r, s) {
1874
- new k(
1882
+ new U(
1875
1883
  e,
1876
1884
  o,
1877
1885
  r,
@@ -1879,7 +1887,7 @@ class k {
1879
1887
  );
1880
1888
  }
1881
1889
  moveViewport(e, o) {
1882
- const r = this.viewport.getViewportMatrix(), s = Oe(r, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
1890
+ const r = this.viewport.getViewportMatrix(), s = Xe(r, e, o), { width: h, height: n } = this.element.getBoundingClientRect(), d = this.config.transformPreprocessor({
1883
1891
  prevTransform: r,
1884
1892
  nextTransform: s,
1885
1893
  canvasWidth: h,
@@ -1897,7 +1905,7 @@ class k {
1897
1905
  this.performTransform(c);
1898
1906
  }
1899
1907
  stopMouseDrag() {
1900
- C(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1908
+ B(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1901
1909
  }
1902
1910
  removeMouseDragListeners() {
1903
1911
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -1918,7 +1926,7 @@ class k {
1918
1926
  this.transformInProgress = !1, this.config.onTransformFinished();
1919
1927
  }
1920
1928
  }
1921
- class K {
1929
+ class X {
1922
1930
  constructor(e, o, r, s, h, n) {
1923
1931
  i(this, "canvasResizeObserver");
1924
1932
  i(this, "nodeHorizontal");
@@ -1950,16 +1958,16 @@ class K {
1950
1958
  this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
1951
1959
  });
1952
1960
  i(this, "userTransformInProgress", !1);
1953
- var v, f, A, x, b;
1954
- this.canvas = e, this.element = o, this.window = r, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((M) => {
1955
- const m = M[0];
1961
+ var p, f, E, x, T;
1962
+ this.canvas = e, this.element = o, this.window = r, this.trigger = h, this.virtualScrollOptions = n, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new ResizeObserver((b) => {
1963
+ const m = b[0];
1956
1964
  this.viewportWidth = m.contentRect.width, this.viewportHeight = m.contentRect.height, this.scheduleLoadAreaAroundViewport();
1957
1965
  }), this.viewport = e.viewport;
1958
- const d = ((v = s == null ? void 0 : s.events) == null ? void 0 : v.onResizeTransformStarted) ?? (() => {
1966
+ const d = ((p = s == null ? void 0 : s.events) == null ? void 0 : p.onResizeTransformStarted) ?? (() => {
1959
1967
  }), c = ((f = s == null ? void 0 : s.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
1960
- }), a = ((A = s == null ? void 0 : s.events) == null ? void 0 : A.onTransformChange) ?? (() => {
1968
+ }), a = ((E = s == null ? void 0 : s.events) == null ? void 0 : E.onTransformChange) ?? (() => {
1961
1969
  }), l = ((x = s == null ? void 0 : s.events) == null ? void 0 : x.onBeforeTransformChange) ?? (() => {
1962
- }), g = ((b = s == null ? void 0 : s.events) == null ? void 0 : b.onTransformFinished) ?? (() => {
1970
+ }), g = ((T = s == null ? void 0 : s.events) == null ? void 0 : T.onTransformFinished) ?? (() => {
1963
1971
  }), y = {
1964
1972
  ...s,
1965
1973
  events: {
@@ -1975,15 +1983,15 @@ class K {
1975
1983
  },
1976
1984
  onTransformChange: () => {
1977
1985
  this.userTransformInProgress = !1;
1978
- const M = this.viewportMatrix;
1979
- this.viewportMatrix = this.viewport.getViewportMatrix(), M.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
1986
+ const b = this.viewportMatrix;
1987
+ this.viewportMatrix = this.viewport.getViewportMatrix(), b.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), a();
1980
1988
  },
1981
1989
  onTransformFinished: () => {
1982
1990
  this.scheduleLoadAreaAroundViewport(), g();
1983
1991
  }
1984
1992
  }
1985
1993
  };
1986
- k.configure(
1994
+ U.configure(
1987
1995
  e,
1988
1996
  this.element,
1989
1997
  this.window,
@@ -1991,7 +1999,7 @@ class K {
1991
1999
  ), this.viewportMatrix = this.viewport.getViewportMatrix(), this.trigger.subscribe(this.updateLoadedArea), this.canvasResizeObserver.observe(this.element), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterViewportUpdated), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
1992
2000
  }
1993
2001
  static configure(e, o, r, s, h, n) {
1994
- new K(
2002
+ new X(
1995
2003
  e,
1996
2004
  o,
1997
2005
  r,
@@ -2014,29 +2022,29 @@ class K {
2014
2022
  this.trigger.emit({ x: r, y: s, width: h, height: n });
2015
2023
  }
2016
2024
  }
2017
- const Xe = () => {
2025
+ const He = () => {
2018
2026
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2019
2027
  return t.style.position = "absolute", t.style.inset = "0", t;
2020
- }, He = () => {
2028
+ }, je = () => {
2021
2029
  const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
2022
2030
  return t.setAttribute("fill", "url(#pattern)"), t;
2023
- }, je = () => {
2031
+ }, Ge = () => {
2024
2032
  const t = document.createElementNS(
2025
2033
  "http://www.w3.org/2000/svg",
2026
2034
  "pattern"
2027
2035
  );
2028
2036
  return t.setAttribute("id", "pattern"), t;
2029
- }, Ge = (t, e) => {
2037
+ }, Je = (t, e) => {
2030
2038
  const o = document.createElementNS(
2031
2039
  "http://www.w3.org/2000/svg",
2032
2040
  "circle"
2033
2041
  );
2034
2042
  return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
2035
- }, Je = (t) => t instanceof SVGElement ? t : Ge(
2043
+ }, Ke = (t) => t instanceof SVGElement ? t : Je(
2036
2044
  (t == null ? void 0 : t.radius) ?? 1.5,
2037
2045
  (t == null ? void 0 : t.color) ?? "#d8d8d8"
2038
- ), Ke = (t) => {
2039
- const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Je(t.renderer ?? {});
2046
+ ), Qe = (t) => {
2047
+ const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = Ke(t.renderer ?? {});
2040
2048
  return {
2041
2049
  tileWidth: o,
2042
2050
  tileHeight: r,
@@ -2044,11 +2052,11 @@ const Xe = () => {
2044
2052
  maxViewportScale: t.maxViewportScale ?? 10
2045
2053
  };
2046
2054
  };
2047
- class Q {
2055
+ class Y {
2048
2056
  constructor(e, o, r) {
2049
- i(this, "svg", Xe());
2050
- i(this, "patternRenderingRectangle", He());
2051
- i(this, "pattern", je());
2057
+ i(this, "svg", He());
2058
+ i(this, "patternRenderingRectangle", je());
2059
+ i(this, "pattern", Ge());
2052
2060
  i(this, "patternContent");
2053
2061
  i(this, "tileWidth");
2054
2062
  i(this, "tileHeight");
@@ -2072,7 +2080,7 @@ class Q {
2072
2080
  ), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
2073
2081
  });
2074
2082
  this.canvas = e, this.host = r;
2075
- const s = Ke(o);
2083
+ const s = Qe(o);
2076
2084
  this.tileWidth = s.tileWidth, this.tileHeight = s.tileHeight, this.halfTileWidth = this.tileWidth / 2, this.halfTileHeight = this.tileHeight / 2, this.patternContent = s.renderer, this.maxViewportScale = s.maxViewportScale;
2077
2085
  const h = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
2078
2086
  this.patternContent.setAttribute("transform", h), this.pattern.appendChild(this.patternContent);
@@ -2080,25 +2088,31 @@ class Q {
2080
2088
  n.appendChild(this.pattern), this.svg.appendChild(n), this.svg.appendChild(this.patternRenderingRectangle), this.resizeObserver.observe(this.host), this.canvas.viewport.onAfterUpdated.subscribe(this.onAfterTransformUpdated), this.onAfterTransformUpdated(), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2081
2089
  }
2082
2090
  static configure(e, o, r) {
2083
- new Q(e, o, r);
2091
+ new Y(e, o, r);
2084
2092
  }
2085
2093
  updateVisibility() {
2086
2094
  const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
2087
2095
  o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
2088
2096
  }
2089
2097
  }
2090
- const Qe = () => "direct", Ze = (t) => t, _e = (t) => t.button === 0, qe = () => {
2091
- }, et = (t) => t.button === 0, tt = (t) => {
2092
- var e;
2098
+ const Ze = (t) => {
2099
+ var d, c, a;
2100
+ const e = () => "direct", o = (l) => l, r = (l) => l.button === 0, s = () => {
2101
+ }, h = () => {
2102
+ }, n = () => {
2103
+ };
2093
2104
  return {
2094
- connectionTypeResolver: t.connectionTypeResolver ?? Qe,
2095
- connectionPreprocessor: t.connectionPreprocessor ?? Ze,
2096
- mouseDownEventVerifier: t.mouseDownEventVerifier ?? _e,
2097
- mouseUpEventVerifier: t.mouseUpEventVerifier ?? et,
2098
- onAfterEdgeCreated: ((e = t.events) == null ? void 0 : e.onAfterEdgeCreated) ?? qe
2105
+ connectionTypeResolver: t.connectionTypeResolver ?? e,
2106
+ connectionPreprocessor: t.connectionPreprocessor ?? o,
2107
+ mouseDownEventVerifier: t.mouseDownEventVerifier ?? r,
2108
+ mouseUpEventVerifier: t.mouseUpEventVerifier ?? r,
2109
+ onAfterEdgeCreated: ((d = t.events) == null ? void 0 : d.onAfterEdgeCreated) ?? s,
2110
+ onEdgeCreationInterrupted: ((c = t.events) == null ? void 0 : c.onEdgeCreationInterrupted) ?? n,
2111
+ onEdgeCreationPrevented: ((a = t.events) == null ? void 0 : a.onEdgeCreationPrevented) ?? h,
2112
+ dragPortDirection: t.dragPortDirection ?? void 0
2099
2113
  };
2100
2114
  };
2101
- class ot {
2115
+ class _e {
2102
2116
  constructor() {
2103
2117
  i(this, "singleToMultiMap", /* @__PURE__ */ new Map());
2104
2118
  i(this, "multiToSingleMap", /* @__PURE__ */ new Map());
@@ -2138,11 +2152,11 @@ class ot {
2138
2152
  return this.multiToSingleMap.get(e) !== void 0;
2139
2153
  }
2140
2154
  }
2141
- class Z {
2155
+ class H {
2142
2156
  constructor(e, o, r, s, h, n) {
2143
2157
  i(this, "config");
2144
2158
  i(this, "overlayCanvas");
2145
- i(this, "ports", new ot());
2159
+ i(this, "ports", new _e());
2146
2160
  i(this, "staticOverlayPortId", "static");
2147
2161
  i(this, "draggingOverlayPortId", "dragging");
2148
2162
  i(this, "staticPortId", null);
@@ -2157,10 +2171,14 @@ class Z {
2157
2171
  });
2158
2172
  i(this, "onPortMouseDown", (e) => {
2159
2173
  const o = e.currentTarget;
2160
- this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp));
2174
+ this.config.mouseDownEventVerifier(e) && this.isPortConnectionAllowed(o) && (e.stopPropagation(), this.grabPort(o, { x: e.clientX, y: e.clientY }), this.window.addEventListener("mousemove", this.onWindowMouseMove, {
2175
+ passive: !0
2176
+ }), this.window.addEventListener("mouseup", this.onWindowMouseUp, {
2177
+ passive: !0
2178
+ }));
2161
2179
  });
2162
2180
  i(this, "onWindowMouseMove", (e) => {
2163
- if (!L(
2181
+ if (!M(
2164
2182
  this.window,
2165
2183
  this.overlayLayer,
2166
2184
  e.clientX,
@@ -2180,11 +2198,17 @@ class Z {
2180
2198
  return;
2181
2199
  e.stopPropagation();
2182
2200
  const s = e.touches[0];
2183
- this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish);
2201
+ this.grabPort(o, { x: s.clientX, y: s.clientY }), this.window.addEventListener("touchmove", this.onWindowTouchMove, {
2202
+ passive: !0
2203
+ }), this.window.addEventListener("touchend", this.onWindowTouchFinish, {
2204
+ passive: !0
2205
+ }), this.window.addEventListener("touchcancel", this.onWindowTouchFinish, {
2206
+ passive: !0
2207
+ });
2184
2208
  });
2185
2209
  i(this, "onWindowTouchMove", (e) => {
2186
2210
  const o = e.touches[0];
2187
- if (!L(
2211
+ if (!M(
2188
2212
  this.window,
2189
2213
  this.overlayLayer,
2190
2214
  o.clientX,
@@ -2212,13 +2236,13 @@ class Z {
2212
2236
  i(this, "onEdgeCreated", (e) => {
2213
2237
  this.config.onAfterEdgeCreated(e);
2214
2238
  });
2215
- this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.config = tt(n);
2216
- const d = new ce(), c = new ne(
2239
+ this.canvas = e, this.overlayLayer = o, this.viewportStore = r, this.window = s, this.config = Ze(n);
2240
+ const d = new ne(), c = new re(
2217
2241
  d,
2218
2242
  this.viewportStore,
2219
2243
  this.overlayLayer
2220
2244
  );
2221
- this.overlayCanvas = new de(
2245
+ this.overlayCanvas = new se(
2222
2246
  this.overlayLayer,
2223
2247
  d,
2224
2248
  this.viewportStore,
@@ -2227,7 +2251,7 @@ class Z {
2227
2251
  ), this.canvas.graph.onAfterPortMarked.subscribe(this.onAfterPortMarked), this.canvas.graph.onBeforePortUnmarked.subscribe(this.onBeforePortUnmarked), this.canvas.graph.onBeforeClear.subscribe(this.onBeforeClear), this.canvas.onBeforeDestroy.subscribe(this.onBeforeDestroy);
2228
2252
  }
2229
2253
  static configure(e, o, r, s, h, n) {
2230
- new Z(
2254
+ new H(
2231
2255
  e,
2232
2256
  o,
2233
2257
  r,
@@ -2239,27 +2263,31 @@ class Z {
2239
2263
  grabPort(e, o) {
2240
2264
  const r = this.ports.getFirstBySingle(e), s = this.canvas.graph.getPort(r);
2241
2265
  this.staticPortId = r;
2242
- const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = V(l, {
2266
+ const h = this.config.connectionTypeResolver(this.staticPortId), n = e.getBoundingClientRect(), d = n.x + n.width / 2, c = n.y + n.height / 2, a = this.overlayLayer.getBoundingClientRect(), l = this.canvas.viewport.getViewportMatrix(), g = N(l, {
2243
2267
  x: d - a.x,
2244
2268
  y: c - a.y
2245
- }), y = V(l, {
2269
+ }), y = N(l, {
2246
2270
  x: o.x - a.x,
2247
2271
  y: o.y - a.y
2248
- }), v = {
2272
+ }), p = {
2249
2273
  overlayId: this.staticOverlayPortId,
2250
2274
  portCoords: g,
2251
2275
  portDirection: s.direction
2252
2276
  }, f = {
2253
2277
  overlayId: this.draggingOverlayPortId,
2254
2278
  portCoords: y,
2255
- portDirection: void 0
2279
+ portDirection: this.config.dragPortDirection
2256
2280
  };
2257
2281
  this.isDirect = h === "direct";
2258
- const A = this.isDirect ? v : f, x = this.isDirect ? f : v;
2259
- this.createOverlayGraph(A, x);
2282
+ const E = this.isDirect ? p : f, x = this.isDirect ? f : p;
2283
+ this.createOverlayGraph(E, x);
2260
2284
  }
2261
2285
  hookPortEvents(e) {
2262
- e.addEventListener("mousedown", this.onPortMouseDown), e.addEventListener("touchstart", this.onPortTouchStart);
2286
+ e.addEventListener("mousedown", this.onPortMouseDown, {
2287
+ passive: !0
2288
+ }), e.addEventListener("touchstart", this.onPortTouchStart, {
2289
+ passive: !0
2290
+ });
2263
2291
  }
2264
2292
  unhookPortEvents(e) {
2265
2293
  e.removeEventListener("mousedown", this.onPortMouseDown), e.removeEventListener("touchstart", this.onPortTouchStart);
@@ -2300,16 +2328,18 @@ class Z {
2300
2328
  }
2301
2329
  tryCreateConnection(e) {
2302
2330
  const o = this.findPortAtPoint(e);
2303
- if (o === null)
2331
+ if (o === null) {
2332
+ this.config.onEdgeCreationInterrupted(this.staticPortId, this.isDirect);
2304
2333
  return;
2334
+ }
2305
2335
  const r = this.isDirect ? this.staticPortId : o, s = this.isDirect ? o : this.staticPortId, h = { from: r, to: s }, n = this.config.connectionPreprocessor(h);
2306
- n !== null && (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated));
2336
+ n !== null ? (this.canvas.graph.onAfterEdgeAdded.subscribe(this.onEdgeCreated), this.canvas.addEdge(n), this.canvas.graph.onAfterEdgeAdded.unsubscribe(this.onEdgeCreated)) : this.config.onEdgeCreationPrevented(h);
2307
2337
  }
2308
2338
  moveDraggingNode(e) {
2309
2339
  const o = this.overlayLayer.getBoundingClientRect(), r = {
2310
2340
  x: e.x - o.x,
2311
2341
  y: e.y - o.y
2312
- }, s = this.canvas.viewport.getViewportMatrix(), h = V(s, r);
2342
+ }, s = this.canvas.viewport.getViewportMatrix(), h = N(s, r);
2313
2343
  this.overlayCanvas.updateNode(this.draggingOverlayPortId, {
2314
2344
  x: h.x,
2315
2345
  y: h.y
@@ -2335,26 +2365,26 @@ class Z {
2335
2365
  return this.config.connectionTypeResolver(o) !== null;
2336
2366
  }
2337
2367
  }
2338
- const rt = () => {
2368
+ const qe = () => {
2339
2369
  const t = document.createElement("div");
2340
2370
  return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
2341
- }, Y = () => {
2371
+ }, W = () => {
2342
2372
  const t = document.createElement("div");
2343
2373
  return t.style.position = "absolute", t.style.inset = "0", t;
2344
2374
  };
2345
- class it {
2375
+ class et {
2346
2376
  constructor(e) {
2347
- i(this, "background", Y());
2348
- i(this, "main", Y());
2349
- i(this, "overlay", Y());
2350
- i(this, "host", rt());
2377
+ i(this, "background", W());
2378
+ i(this, "main", W());
2379
+ i(this, "overlay", W());
2380
+ i(this, "host", qe());
2351
2381
  this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main), this.overlay.style.pointerEvents = "none", this.host.appendChild(this.overlay);
2352
2382
  }
2353
2383
  destroy() {
2354
2384
  this.host.removeChild(this.background), this.host.removeChild(this.main), this.host.removeChild(this.overlay), this.element.removeChild(this.host);
2355
2385
  }
2356
2386
  }
2357
- class nt {
2387
+ class ot {
2358
2388
  constructor(e) {
2359
2389
  i(this, "element", null);
2360
2390
  i(this, "canvasDefaults", {});
@@ -2437,15 +2467,15 @@ class nt {
2437
2467
  "unable to build canvas when no attach element specified"
2438
2468
  );
2439
2469
  let e = this.boxRenderingTrigger;
2440
- this.virtualScrollConfig !== void 0 && e === void 0 && (e = new he());
2441
- const o = new ce(), r = new Ie(), s = new it(this.element);
2442
- let h = new ne(
2470
+ this.virtualScrollConfig !== void 0 && e === void 0 && (e = new ie());
2471
+ const o = new ne(), r = new Ue(), s = new et(this.element);
2472
+ let h = new re(
2443
2473
  o,
2444
2474
  r,
2445
2475
  s.main
2446
2476
  );
2447
- e !== void 0 && (h = new ye(h, o, e));
2448
- const n = new de(
2477
+ e !== void 0 && (h = new ue(h, o, e));
2478
+ const n = new se(
2449
2479
  this.element,
2450
2480
  o,
2451
2481
  r,
@@ -2454,30 +2484,30 @@ class nt {
2454
2484
  ), d = () => {
2455
2485
  s.destroy(), n.onBeforeDestroy.unsubscribe(d);
2456
2486
  };
2457
- return n.onBeforeDestroy.subscribe(d), this.hasBackground && Q.configure(
2487
+ return n.onBeforeDestroy.subscribe(d), this.hasBackground && Y.configure(
2458
2488
  n,
2459
2489
  this.backgroundConfig,
2460
2490
  s.background
2461
- ), this.hasResizeReactiveNodes && G.configure(n), this.hasDraggableNode && J.configure(
2491
+ ), this.hasResizeReactiveNodes && k.configure(n), this.hasDraggableNode && O.configure(
2462
2492
  n,
2463
2493
  s.main,
2464
2494
  this.window,
2465
2495
  this.dragConfig
2466
- ), this.hasUserConnectablePorts && Z.configure(
2496
+ ), this.hasUserConnectablePorts && H.configure(
2467
2497
  n,
2468
2498
  s.overlay,
2469
2499
  r,
2470
2500
  this.window,
2471
2501
  this.canvasDefaults,
2472
2502
  this.connectablePortsConfig
2473
- ), this.virtualScrollConfig !== void 0 ? K.configure(
2503
+ ), this.virtualScrollConfig !== void 0 ? X.configure(
2474
2504
  n,
2475
2505
  s.main,
2476
2506
  this.window,
2477
2507
  this.transformConfig,
2478
2508
  e,
2479
2509
  this.virtualScrollConfig
2480
- ) : this.hasTransformableViewport && k.configure(
2510
+ ) : this.hasTransformableViewport && U.configure(
2481
2511
  n,
2482
2512
  s.main,
2483
2513
  this.window,
@@ -2493,11 +2523,11 @@ class nt {
2493
2523
  }
2494
2524
  }
2495
2525
  export {
2496
- Me as BezierEdgeShape,
2497
- nt as CanvasBuilder,
2498
- he as EventSubject,
2499
- De as HorizontalEdgeShape,
2526
+ De as BezierEdgeShape,
2527
+ ot as CanvasBuilder,
2528
+ ie as EventSubject,
2529
+ Ve as HorizontalEdgeShape,
2500
2530
  S as HtmlGraphError,
2501
- Ve as StraightEdgeShape,
2502
- Le as VerticalEdgeShape
2531
+ Le as StraightEdgeShape,
2532
+ Re as VerticalEdgeShape
2503
2533
  };