@html-graph/html-graph 3.1.0 → 3.2.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 ie = Object.defineProperty;
2
- var se = (t, e, o) => e in t ? ie(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
- var i = (t, e, o) => se(t, typeof e != "symbol" ? e + "" : e, o);
4
- const ne = () => {
5
- const t = document.createElement("div");
6
- return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
7
- }, he = () => {
1
+ var ne = Object.defineProperty;
2
+ var he = (t, e, o) => e in t ? ne(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var i = (t, e, o) => he(t, typeof e != "symbol" ? e + "" : e, o);
4
+ const de = () => {
8
5
  const t = document.createElement("div");
9
6
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.width = "0", t.style.height = "0", t;
10
- }, de = () => {
7
+ }, ce = () => {
11
8
  const t = document.createElement("div");
12
9
  return t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.visibility = "hidden", t;
10
+ }, ae = () => {
11
+ const t = document.createElement("div");
12
+ return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t.style.overflow = "hidden", t;
13
13
  };
14
- class ce {
14
+ class le {
15
15
  constructor(e, o, r) {
16
- i(this, "host", ne());
17
- i(this, "container", he());
16
+ i(this, "host", ae());
17
+ i(this, "container", de());
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 ce {
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 = de();
27
+ const o = this.graphStore.getNode(e), r = ce();
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) {
@@ -97,7 +97,7 @@ class ce {
97
97
  o.shape.svg.style.zIndex = `${o.priority}`;
98
98
  }
99
99
  }
100
- class ae {
100
+ class ge {
101
101
  constructor(e) {
102
102
  i(this, "xFrom", 1 / 0);
103
103
  i(this, "yFrom", 1 / 0);
@@ -117,7 +117,7 @@ class ae {
117
117
  return h <= this.xTo && c >= this.xFrom && a <= this.yTo && l >= this.yFrom;
118
118
  }
119
119
  }
120
- class le {
120
+ class ue {
121
121
  constructor(e, o, r) {
122
122
  i(this, "attachedNodes", /* @__PURE__ */ new Set());
123
123
  i(this, "attachedEdges", /* @__PURE__ */ new Set());
@@ -141,7 +141,7 @@ class le {
141
141
  this.handleAttachEdge(n);
142
142
  });
143
143
  });
144
- this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ae(this.graphStore), this.trigger.subscribe(this.updateViewport);
144
+ this.htmlView = e, this.graphStore = o, this.trigger = r, this.renderingBox = new ge(this.graphStore), this.trigger.subscribe(this.updateViewport);
145
145
  }
146
146
  attachNode(e) {
147
147
  this.renderingBox.hasNode(e) && this.handleAttachNode(e);
@@ -195,7 +195,7 @@ class le {
195
195
  this.htmlView.detachEdge(e), this.attachedEdges.delete(e);
196
196
  }
197
197
  }
198
- class re {
198
+ class se {
199
199
  constructor() {
200
200
  i(this, "callbacks", /* @__PURE__ */ new Set());
201
201
  }
@@ -212,10 +212,10 @@ class re {
212
212
  }
213
213
  }
214
214
  const A = () => {
215
- const t = new re();
215
+ const t = new se();
216
216
  return [t, t];
217
217
  };
218
- class ge {
218
+ class we {
219
219
  constructor(e) {
220
220
  i(this, "onBeforeUpdated");
221
221
  i(this, "onAfterUpdated");
@@ -228,7 +228,7 @@ class ge {
228
228
  return { ...this.transformer.getContentMatrix() };
229
229
  }
230
230
  }
231
- class ue {
231
+ class fe {
232
232
  constructor(e) {
233
233
  i(this, "onAfterNodeAdded");
234
234
  i(this, "onAfterNodeUpdated");
@@ -320,39 +320,39 @@ class X {
320
320
  this.counter = 0;
321
321
  }
322
322
  }
323
- class S extends Error {
323
+ class b extends Error {
324
324
  constructor() {
325
325
  super(...arguments);
326
326
  i(this, "name", "HtmlGraphError");
327
327
  }
328
328
  }
329
- const we = (t, e) => ({
329
+ const ye = (t, e) => ({
330
330
  x: t / 2,
331
331
  y: e / 2
332
- }), k = (t) => () => t, O = k(0), fe = () => {
332
+ }), H = (t) => () => t, ee = H(0), ve = () => {
333
333
  let t = 0;
334
334
  return () => t++;
335
- }, ye = (t, e) => {
336
- let o = O, r = O;
337
- const s = fe();
338
- return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = k(t)), typeof e == "number" && (r = k(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
335
+ }, xe = (t, e) => {
336
+ let o = ee, r = ee;
337
+ const s = ve();
338
+ return t === "incremental" && (o = s), e === "incremental" && (r = s), typeof t == "number" && (o = H(t)), typeof e == "number" && (r = H(e)), typeof t == "function" && (o = t), typeof e == "function" && (r = e), {
339
339
  nodesPriorityFn: o,
340
340
  edgesPriorityFn: r
341
341
  };
342
342
  }, x = (t, e, o) => ({
343
343
  x: e.x * t.x - e.y * t.y + ((1 - e.x) * o.x + e.y * o.y),
344
344
  y: e.y * t.x + e.x * t.y + ((1 - e.x) * o.y - e.y * o.x)
345
- }), b = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
345
+ }), T = (t, e, o) => ({ x: e * Math.cos(t), y: o * Math.sin(t) }), w = {
346
346
  x: 0,
347
347
  y: 0
348
- }, N = (t, e, o, r) => {
348
+ }, m = (t, e, o, r) => {
349
349
  const d = [
350
350
  w,
351
351
  { x: o, y: r },
352
352
  { x: o, y: -r }
353
353
  ].map((a) => x(a, t, w)).map((a) => ({ x: a.x + e.x, y: a.y + e.y })), n = `M ${d[0].x} ${d[0].y}`, h = `L ${d[1].x} ${d[1].y}`, c = `L ${d[2].x} ${d[2].y}`;
354
354
  return `${n} ${h} ${c}`;
355
- }, L = (t, e) => {
355
+ }, C = (t, e) => {
356
356
  const o = [];
357
357
  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) {
358
358
  const r = t.length - 1;
@@ -361,29 +361,29 @@ const we = (t, e) => ({
361
361
  let a = 0, l = 0, g = 0;
362
362
  const f = c > 0, v = c < r, y = f && v;
363
363
  if (f && (a = -s, l = -d, g = n), v) {
364
- const V = t[c + 1];
365
- s = V.x - h.x, d = V.y - h.y, n = Math.sqrt(s * s + d * d);
364
+ const L = t[c + 1];
365
+ s = L.x - h.x, d = L.y - h.y, n = Math.sqrt(s * s + d * d);
366
366
  }
367
- const E = n !== 0 ? Math.min((y ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, T = y ? { x: h.x + s * E, y: h.y + d * E } : h, D = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, M = y ? { x: h.x + a * D, y: h.y + l * D } : h;
367
+ const E = n !== 0 ? Math.min((y ? e : 0) / n, c < r - 1 ? 0.5 : 1) : 0, S = y ? { x: h.x + s * E, y: h.y + d * E } : h, D = g !== 0 ? Math.min((y ? e : 0) / g, c > 1 ? 0.5 : 1) : 0, M = y ? { x: h.x + a * D, y: h.y + l * D } : h;
368
368
  c > 0 && o.push(`L ${M.x} ${M.y}`), y && o.push(
369
- `C ${h.x} ${h.y} ${h.x} ${h.y} ${T.x} ${T.y}`
369
+ `C ${h.x} ${h.y} ${h.x} ${h.y} ${S.x} ${S.y}`
370
370
  );
371
371
  });
372
372
  }
373
373
  return o.join(" ");
374
- }, B = () => {
374
+ }, I = () => {
375
375
  const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
376
376
  return t.style.pointerEvents = "none", t.style.position = "absolute", t.style.top = "0", t.style.left = "0", t.style.overflow = "visible", t;
377
- }, $ = () => {
377
+ }, W = () => {
378
378
  const t = document.createElementNS("http://www.w3.org/2000/svg", "g");
379
379
  return t.style.transformOrigin = "50% 50%", t;
380
- }, W = (t, e) => {
380
+ }, F = (t, e) => {
381
381
  const o = document.createElementNS("http://www.w3.org/2000/svg", "path");
382
382
  return o.setAttribute("stroke", t), o.setAttribute("stroke-width", `${e}`), o.setAttribute("fill", "none"), o;
383
- }, m = (t) => {
383
+ }, N = (t) => {
384
384
  const e = document.createElementNS("http://www.w3.org/2000/svg", "path");
385
385
  return e.setAttribute("fill", t), e;
386
- }, F = (t, e) => {
386
+ }, z = (t, e) => {
387
387
  const o = {
388
388
  x: t.x + t.width / 2,
389
389
  y: t.y + t.height / 2
@@ -399,52 +399,52 @@ const we = (t, e) => ({
399
399
  flipX: c,
400
400
  flipY: a
401
401
  };
402
- }, ve = (t) => {
402
+ }, Ae = (t) => {
403
403
  const e = x(
404
404
  { x: t.arrowLength, y: w.y },
405
- t.fromVect,
405
+ t.fromVector,
406
406
  w
407
407
  ), o = x(
408
408
  { x: t.to.x - t.arrowLength, y: t.to.y },
409
- t.toVect,
409
+ t.toVector,
410
410
  t.to
411
411
  ), r = {
412
- x: e.x + t.fromVect.x * t.curvature,
413
- y: e.y + t.fromVect.y * t.curvature
412
+ x: e.x + t.fromVector.x * t.curvature,
413
+ y: e.y + t.fromVector.y * t.curvature
414
414
  }, s = {
415
- x: o.x - t.toVect.x * t.curvature,
416
- y: o.y - t.toVect.y * t.curvature
415
+ x: o.x - t.toVector.x * t.curvature,
416
+ y: o.y - t.toVector.y * t.curvature
417
417
  }, d = `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} `, h = t.hasTargetArrow ? "" : ` M ${o.x} ${o.y} L ${t.to.x} ${t.to.y}`;
418
418
  return `${n}${d}${h}`;
419
- }, xe = (t) => {
419
+ }, Ee = (t) => {
420
420
  const e = t.hasSourceArrow ? x(
421
421
  { x: t.arrowLength, y: w.y },
422
- t.fromVect,
422
+ t.fromVector,
423
423
  w
424
424
  ) : w, o = t.hasTargetArrow ? x(
425
425
  { x: t.to.x - t.arrowLength, y: t.to.y },
426
- t.toVect,
426
+ t.toVector,
427
427
  t.to
428
428
  ) : t.to, r = t.arrowLength, s = Math.cos(t.detourDirection) * t.detourDistance, d = Math.sin(t.detourDirection) * t.detourDistance, n = s * t.flipX, h = d * t.flipY, c = x(
429
429
  { x: r, y: w.y },
430
- t.fromVect,
430
+ t.fromVector,
431
431
  w
432
432
  ), a = {
433
433
  x: c.x + n,
434
434
  y: c.y + h
435
435
  }, l = x(
436
436
  { x: t.to.x - r, y: t.to.y },
437
- t.toVect,
437
+ t.toVector,
438
438
  t.to
439
439
  ), g = {
440
440
  x: l.x + n,
441
441
  y: l.y + h
442
442
  }, f = { x: (a.x + g.x) / 2, y: (a.y + g.y) / 2 }, v = {
443
- x: c.x + t.curvature * t.fromVect.x,
444
- y: c.y + t.curvature * t.fromVect.y
443
+ x: c.x + t.curvature * t.fromVector.x,
444
+ y: c.y + t.curvature * t.fromVector.y
445
445
  }, y = {
446
- x: l.x - t.curvature * t.toVect.x,
447
- y: l.y - t.curvature * t.toVect.y
446
+ x: l.x - t.curvature * t.toVector.x,
447
+ y: l.y - t.curvature * t.toVector.y
448
448
  }, p = {
449
449
  x: c.x + n,
450
450
  y: c.y + h
@@ -459,82 +459,100 @@ const we = (t, e) => ({
459
459
  `C ${E.x} ${E.y} ${y.x} ${y.y} ${l.x} ${l.y}`,
460
460
  `L ${o.x} ${o.y}`
461
461
  ].join(" ");
462
- }, Ae = (t) => {
462
+ }, Se = (t) => {
463
463
  const e = t.hasSourceArrow ? x(
464
464
  { x: t.arrowLength, y: w.y },
465
- t.fromVect,
465
+ t.fromVector,
466
466
  w
467
467
  ) : w, o = t.hasTargetArrow ? x(
468
468
  { x: t.to.x - t.arrowLength, y: t.to.y },
469
- t.toVect,
469
+ t.toVector,
470
470
  t.to
471
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x({ x: s, y: w.y }, t.fromVect, w), n = x(
471
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x(
472
+ { x: s, y: w.y },
473
+ t.fromVector,
474
+ w
475
+ ), n = x(
472
476
  { x: t.to.x - s, y: t.to.y },
473
- t.toVect,
477
+ t.toVector,
474
478
  t.to
475
- ), h = Math.max((d.x + n.x) / 2, r), c = t.to.y / 2, a = { x: t.flipX > 0 ? h : -r, y: d.y }, l = { x: a.x, y: c }, g = {
479
+ ), h = Math.max((d.x + n.x) / 2, r), c = t.to.y / 2, a = {
480
+ x: t.flipX > 0 ? h : -r,
481
+ y: d.y
482
+ }, l = { x: a.x, y: c }, g = {
476
483
  x: t.flipX > 0 ? t.to.x - h : t.to.x + r,
477
484
  y: n.y
478
485
  }, f = { x: g.x, y: c };
479
- return L(
486
+ return C(
480
487
  [e, d, a, l, f, g, n, o],
481
488
  t.roundness
482
489
  );
483
- }, H = (t) => {
490
+ }, k = (t) => {
484
491
  const e = t.hasSourceArrow ? x(
485
492
  { x: t.arrowLength, y: w.y },
486
- t.fromVect,
493
+ t.fromVector,
487
494
  w
488
495
  ) : w, o = t.hasTargetArrow ? x(
489
496
  { x: t.to.x - t.arrowLength, y: t.to.y },
490
- t.toVect,
497
+ t.toVector,
491
498
  t.to
492
499
  ) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
493
500
  { x: r, y: w.y },
494
- t.fromVect,
501
+ t.fromVector,
495
502
  w
496
503
  ), d = Math.cos(t.detourDirection) * t.detourDistance, n = Math.sin(t.detourDirection) * t.detourDistance, h = d * t.flipX, c = n * t.flipY, a = { x: s.x + h, y: s.y + c }, l = x(
497
504
  { x: t.to.x - r, y: t.to.y },
498
- t.toVect,
505
+ t.toVector,
499
506
  t.to
500
507
  ), g = { x: l.x + h, y: l.y + c };
501
- return L(
508
+ return C(
502
509
  [e, s, a, g, l, o],
503
510
  t.roundness
504
511
  );
505
- }, Ee = (t) => {
512
+ }, be = (t) => {
506
513
  const e = t.hasSourceArrow ? x(
507
514
  { x: t.arrowLength, y: w.y },
508
- t.fromVect,
515
+ t.fromVector,
509
516
  w
510
517
  ) : w, o = t.hasTargetArrow ? x(
511
518
  { x: t.to.x - t.arrowLength, y: t.to.y },
512
- t.toVect,
519
+ t.toVector,
513
520
  t.to
514
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = x({ x: r, y: w.y }, t.fromVect, w), d = x(
521
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = x(
522
+ { x: r, y: w.y },
523
+ t.fromVector,
524
+ w
525
+ ), d = x(
515
526
  { x: t.to.x - r, y: t.to.y },
516
- t.toVect,
527
+ t.toVector,
517
528
  t.to
518
529
  );
519
- return L([e, s, d, o], t.roundness);
520
- }, Se = (t) => {
530
+ return C([e, s, d, o], t.roundness);
531
+ }, pe = (t) => {
521
532
  const e = t.hasSourceArrow ? x(
522
533
  { x: t.arrowLength, y: w.y },
523
- t.fromVect,
534
+ t.fromVector,
524
535
  w
525
536
  ) : w, o = t.hasTargetArrow ? x(
526
537
  { x: t.to.x - t.arrowLength, y: t.to.y },
527
- t.toVect,
538
+ t.toVector,
528
539
  t.to
529
- ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x({ x: s, y: w.y }, t.fromVect, w), n = x(
540
+ ) : t.to, r = t.arrowLength + t.arrowOffset, s = r - t.roundness, d = x(
541
+ { x: s, y: w.y },
542
+ t.fromVector,
543
+ w
544
+ ), n = x(
530
545
  { x: t.to.x - s, y: t.to.y },
531
- t.toVect,
546
+ t.toVector,
532
547
  t.to
533
- ), h = Math.max((d.y + n.y) / 2, r), c = t.to.x / 2, a = { x: d.x, y: t.flipY > 0 ? h : -r }, l = { x: c, y: a.y }, g = {
548
+ ), h = Math.max((d.y + n.y) / 2, r), c = t.to.x / 2, a = {
549
+ x: d.x,
550
+ y: t.flipY > 0 ? h : -r
551
+ }, l = { x: c, y: a.y }, g = {
534
552
  x: n.x,
535
553
  y: t.flipY > 0 ? t.to.y - h : t.to.y + r
536
554
  }, f = { x: c, y: g.y };
537
- return L(
555
+ return C(
538
556
  [e, d, a, l, f, g, n, o],
539
557
  t.roundness
540
558
  );
@@ -549,15 +567,17 @@ const we = (t, e) => ({
549
567
  { x: r, y: w.y },
550
568
  { x: t.arrowLength, y: w.y }
551
569
  ].map(
552
- (c) => x(c, t.fromVect, w)
570
+ (c) => x(c, t.fromVector, w)
553
571
  ), h = `M ${w.x} ${w.y} L ${n[0].x} ${n[0].y} `;
554
- return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${L(n, t.roundness)}`;
555
- }, pe = (t) => {
572
+ return `${t.hasSourceArrow || t.hasTargetArrow ? "" : h}${C(n, t.roundness)}`;
573
+ }, Te = (t) => {
556
574
  const e = t.smallRadius, o = t.radius, r = Math.sqrt(e * e + o * o), s = e + o, d = t.arrowLength + r * (1 - o / s), n = e * o / s, c = [
557
575
  { x: t.arrowLength, y: w.y },
558
576
  { x: d, y: n },
559
577
  { x: d, y: -n }
560
- ].map((g) => x(g, t.fromVect, w)), a = [
578
+ ].map(
579
+ (g) => x(g, t.fromVector, w)
580
+ ), a = [
561
581
  `M ${c[0].x} ${c[0].y}`,
562
582
  `A ${e} ${e} 0 0 1 ${c[1].x} ${c[1].y}`,
563
583
  `A ${o} ${o} 0 1 0 ${c[2].x} ${c[2].y}`,
@@ -581,10 +601,10 @@ const we = (t, e) => ({
581
601
  smallCycleRadius: 15,
582
602
  curvature: 90
583
603
  });
584
- class Te {
604
+ class me {
585
605
  constructor(e) {
586
- i(this, "svg", B());
587
- i(this, "group", $());
606
+ i(this, "svg", I());
607
+ i(this, "group", W());
588
608
  i(this, "line");
589
609
  i(this, "sourceArrow", null);
590
610
  i(this, "targetArrow", null);
@@ -599,34 +619,34 @@ class Te {
599
619
  i(this, "hasTargetArrow");
600
620
  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;
601
621
  const o = (e == null ? void 0 : e.color) ?? u.color, r = (e == null ? void 0 : e.width) ?? u.width;
602
- this.svg.appendChild(this.group), this.line = W(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(o), this.group.appendChild(this.targetArrow));
622
+ this.svg.appendChild(this.group), this.line = F(o, r), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(o), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(o), this.group.appendChild(this.targetArrow));
603
623
  }
604
624
  render(e) {
605
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
625
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = z(
606
626
  e.from,
607
627
  e.to
608
628
  );
609
629
  this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
610
- const c = b(
630
+ const c = T(
611
631
  e.from.direction,
612
632
  n,
613
633
  h
614
- ), a = b(e.to.direction, n, h), l = {
634
+ ), a = T(e.to.direction, n, h), l = {
615
635
  x: s,
616
636
  y: d
617
637
  };
618
638
  let g, f = a, v = -this.arrowLength;
619
- if (e.from.portId === e.to.portId ? (g = pe({
620
- fromVect: c,
639
+ if (e.from.portId === e.to.portId ? (g = Te({
640
+ fromVector: c,
621
641
  radius: this.portCycleRadius,
622
642
  smallRadius: this.portCycleSmallRadius,
623
643
  arrowLength: this.arrowLength,
624
644
  hasSourceArrow: this.hasSourceArrow,
625
645
  hasTargetArrow: this.hasTargetArrow
626
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = xe({
646
+ }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = Ee({
627
647
  to: l,
628
- fromVect: c,
629
- toVect: a,
648
+ fromVector: c,
649
+ toVector: a,
630
650
  flipX: n,
631
651
  flipY: h,
632
652
  arrowLength: this.arrowLength,
@@ -635,16 +655,16 @@ class Te {
635
655
  curvature: this.curvature,
636
656
  hasSourceArrow: this.hasSourceArrow,
637
657
  hasTargetArrow: this.hasTargetArrow
638
- }) : g = ve({
658
+ }) : g = Ae({
639
659
  to: l,
640
- fromVect: c,
641
- toVect: a,
660
+ fromVector: c,
661
+ toVector: a,
642
662
  arrowLength: this.arrowLength,
643
663
  curvature: this.curvature,
644
664
  hasSourceArrow: this.hasSourceArrow,
645
665
  hasTargetArrow: this.hasTargetArrow
646
666
  }), this.line.setAttribute("d", g), this.sourceArrow) {
647
- const y = N(
667
+ const y = m(
648
668
  c,
649
669
  w,
650
670
  this.arrowLength,
@@ -653,7 +673,7 @@ class Te {
653
673
  this.sourceArrow.setAttribute("d", y);
654
674
  }
655
675
  if (this.targetArrow) {
656
- const y = N(
676
+ const y = m(
657
677
  f,
658
678
  l,
659
679
  v,
@@ -663,10 +683,10 @@ class Te {
663
683
  }
664
684
  }
665
685
  }
666
- class be {
686
+ class Ne {
667
687
  constructor(e) {
668
- i(this, "svg", B());
669
- i(this, "group", $());
688
+ i(this, "svg", I());
689
+ i(this, "group", W());
670
690
  i(this, "line");
671
691
  i(this, "sourceArrow", null);
672
692
  i(this, "targetArrow", null);
@@ -687,35 +707,35 @@ class be {
687
707
  this.cycleSquareSide / 2
688
708
  ), 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;
689
709
  const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
690
- this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
710
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
691
711
  }
692
712
  render(e) {
693
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
713
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = z(
694
714
  e.from,
695
715
  e.to
696
716
  );
697
717
  this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
698
- const c = b(
718
+ const c = T(
699
719
  e.from.direction,
700
720
  n,
701
721
  h
702
- ), a = b(e.to.direction, n, h), l = {
722
+ ), a = T(e.to.direction, n, h), l = {
703
723
  x: s,
704
724
  y: d
705
725
  };
706
726
  let g, f = a, v = -this.arrowLength;
707
727
  if (e.from.portId === e.to.portId ? (g = j({
708
- fromVect: c,
728
+ fromVector: c,
709
729
  arrowLength: this.arrowLength,
710
730
  side: this.cycleSquareSide,
711
731
  arrowOffset: this.arrowOffset,
712
732
  roundness: this.roundness,
713
733
  hasSourceArrow: this.hasSourceArrow,
714
734
  hasTargetArrow: this.hasTargetArrow
715
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
735
+ }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = k({
716
736
  to: l,
717
- fromVect: c,
718
- toVect: a,
737
+ fromVector: c,
738
+ toVector: a,
719
739
  flipX: n,
720
740
  flipY: h,
721
741
  arrowLength: this.arrowLength,
@@ -725,10 +745,10 @@ class be {
725
745
  detourDistance: this.detourDistance,
726
746
  hasSourceArrow: this.hasSourceArrow,
727
747
  hasTargetArrow: this.hasTargetArrow
728
- }) : g = Ae({
748
+ }) : g = Se({
729
749
  to: l,
730
- fromVect: c,
731
- toVect: a,
750
+ fromVector: c,
751
+ toVector: a,
732
752
  flipX: n,
733
753
  arrowLength: this.arrowLength,
734
754
  arrowOffset: this.arrowOffset,
@@ -736,7 +756,7 @@ class be {
736
756
  hasSourceArrow: this.hasSourceArrow,
737
757
  hasTargetArrow: this.hasTargetArrow
738
758
  }), this.line.setAttribute("d", g), this.sourceArrow) {
739
- const y = N(
759
+ const y = m(
740
760
  c,
741
761
  w,
742
762
  this.arrowLength,
@@ -745,7 +765,7 @@ class be {
745
765
  this.sourceArrow.setAttribute("d", y);
746
766
  }
747
767
  if (this.targetArrow) {
748
- const y = N(
768
+ const y = m(
749
769
  f,
750
770
  l,
751
771
  v,
@@ -755,10 +775,10 @@ class be {
755
775
  }
756
776
  }
757
777
  }
758
- class Ne {
778
+ class Pe {
759
779
  constructor(e) {
760
- i(this, "svg", B());
761
- i(this, "group", $());
780
+ i(this, "svg", I());
781
+ i(this, "group", W());
762
782
  i(this, "line");
763
783
  i(this, "sourceArrow", null);
764
784
  i(this, "targetArrow", null);
@@ -779,35 +799,35 @@ class Ne {
779
799
  this.cycleSquareSide / 2
780
800
  ), 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;
781
801
  const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
782
- this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
802
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
783
803
  }
784
804
  render(e) {
785
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
805
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = z(
786
806
  e.from,
787
807
  e.to
788
808
  );
789
809
  this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
790
- const c = b(
810
+ const c = T(
791
811
  e.from.direction,
792
812
  n,
793
813
  h
794
- ), a = b(e.to.direction, n, h), l = {
814
+ ), a = T(e.to.direction, n, h), l = {
795
815
  x: s,
796
816
  y: d
797
817
  };
798
818
  let g, f = a, v = -this.arrowLength;
799
819
  if (e.from.portId === e.to.portId ? (g = j({
800
- fromVect: c,
820
+ fromVector: c,
801
821
  arrowLength: this.arrowLength,
802
822
  side: this.cycleSquareSide,
803
823
  arrowOffset: this.arrowOffset,
804
824
  roundness: this.roundness,
805
825
  hasSourceArrow: this.hasSourceArrow,
806
826
  hasTargetArrow: this.hasTargetArrow
807
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
827
+ }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = k({
808
828
  to: l,
809
- fromVect: c,
810
- toVect: a,
829
+ fromVector: c,
830
+ toVector: a,
811
831
  flipX: n,
812
832
  flipY: h,
813
833
  arrowLength: this.arrowLength,
@@ -817,17 +837,17 @@ class Ne {
817
837
  detourDistance: this.detourDistance,
818
838
  hasSourceArrow: this.hasSourceArrow,
819
839
  hasTargetArrow: this.hasTargetArrow
820
- }) : g = Ee({
840
+ }) : g = be({
821
841
  to: l,
822
- fromVect: c,
823
- toVect: a,
842
+ fromVector: c,
843
+ toVector: a,
824
844
  arrowLength: this.arrowLength,
825
845
  arrowOffset: this.arrowOffset,
826
846
  roundness: this.roundness,
827
847
  hasSourceArrow: this.hasSourceArrow,
828
848
  hasTargetArrow: this.hasTargetArrow
829
849
  }), this.line.setAttribute("d", g), this.sourceArrow) {
830
- const y = N(
850
+ const y = m(
831
851
  c,
832
852
  w,
833
853
  this.arrowLength,
@@ -836,7 +856,7 @@ class Ne {
836
856
  this.sourceArrow.setAttribute("d", y);
837
857
  }
838
858
  if (this.targetArrow) {
839
- const y = N(
859
+ const y = m(
840
860
  f,
841
861
  l,
842
862
  v,
@@ -846,10 +866,10 @@ class Ne {
846
866
  }
847
867
  }
848
868
  }
849
- class me {
869
+ class Ve {
850
870
  constructor(e) {
851
- i(this, "svg", B());
852
- i(this, "group", $());
871
+ i(this, "svg", I());
872
+ i(this, "group", W());
853
873
  i(this, "line");
854
874
  i(this, "sourceArrow", null);
855
875
  i(this, "targetArrow", null);
@@ -870,35 +890,35 @@ class me {
870
890
  this.cycleSquareSide / 2
871
891
  ), 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;
872
892
  const r = (e == null ? void 0 : e.color) ?? u.color, s = (e == null ? void 0 : e.width) ?? u.width;
873
- this.svg.appendChild(this.group), this.line = W(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = m(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = m(r), this.group.appendChild(this.targetArrow));
893
+ this.svg.appendChild(this.group), this.line = F(r, s), this.group.appendChild(this.line), this.hasSourceArrow && (this.sourceArrow = N(r), this.group.appendChild(this.sourceArrow)), this.hasTargetArrow && (this.targetArrow = N(r), this.group.appendChild(this.targetArrow));
874
894
  }
875
895
  render(e) {
876
- const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = F(
896
+ const { x: o, y: r, width: s, height: d, flipX: n, flipY: h } = z(
877
897
  e.from,
878
898
  e.to
879
899
  );
880
900
  this.svg.style.transform = `translate(${o}px, ${r}px)`, this.svg.style.width = `${s}px`, this.svg.style.height = `${d}px`, this.group.style.transform = `scale(${n}, ${h})`;
881
- const c = b(
901
+ const c = T(
882
902
  e.from.direction,
883
903
  n,
884
904
  h
885
- ), a = b(e.to.direction, n, h), l = {
905
+ ), a = T(e.to.direction, n, h), l = {
886
906
  x: s,
887
907
  y: d
888
908
  };
889
909
  let g, f = a, v = -this.arrowLength;
890
910
  if (e.from.portId === e.to.portId ? (g = j({
891
- fromVect: c,
911
+ fromVector: c,
892
912
  arrowLength: this.arrowLength,
893
913
  side: this.cycleSquareSide,
894
914
  arrowOffset: this.arrowOffset,
895
915
  roundness: this.roundness,
896
916
  hasSourceArrow: this.hasSourceArrow,
897
917
  hasTargetArrow: this.hasTargetArrow
898
- }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = H({
918
+ }), f = c, v = this.arrowLength) : e.from.nodeId === e.to.nodeId ? g = k({
899
919
  to: l,
900
- fromVect: c,
901
- toVect: a,
920
+ fromVector: c,
921
+ toVector: a,
902
922
  flipX: n,
903
923
  flipY: h,
904
924
  arrowLength: this.arrowLength,
@@ -908,10 +928,10 @@ class me {
908
928
  detourDistance: this.detourDistance,
909
929
  hasSourceArrow: this.hasSourceArrow,
910
930
  hasTargetArrow: this.hasTargetArrow
911
- }) : g = Se({
931
+ }) : g = pe({
912
932
  to: l,
913
- fromVect: c,
914
- toVect: a,
933
+ fromVector: c,
934
+ toVector: a,
915
935
  flipY: h,
916
936
  arrowLength: this.arrowLength,
917
937
  arrowOffset: this.arrowOffset,
@@ -919,7 +939,7 @@ class me {
919
939
  hasSourceArrow: this.hasSourceArrow,
920
940
  hasTargetArrow: this.hasTargetArrow
921
941
  }), this.line.setAttribute("d", g), this.sourceArrow) {
922
- const y = N(
942
+ const y = m(
923
943
  c,
924
944
  w,
925
945
  this.arrowLength,
@@ -928,7 +948,7 @@ class me {
928
948
  this.sourceArrow.setAttribute("d", y);
929
949
  }
930
950
  if (this.targetArrow) {
931
- const y = N(
951
+ const y = m(
932
952
  f,
933
953
  l,
934
954
  v,
@@ -938,12 +958,12 @@ class me {
938
958
  }
939
959
  }
940
960
  }
941
- const Pe = (t) => {
961
+ const De = (t) => {
942
962
  if (typeof t == "function")
943
963
  return t;
944
964
  switch (t == null ? void 0 : t.type) {
945
965
  case "straight":
946
- return () => new Ne({
966
+ return () => new Pe({
947
967
  color: t.color,
948
968
  width: t.width,
949
969
  arrowLength: t.arrowLength,
@@ -957,7 +977,7 @@ const Pe = (t) => {
957
977
  detourDirection: t.detourDirection
958
978
  });
959
979
  case "horizontal":
960
- return () => new be({
980
+ return () => new Ne({
961
981
  color: t.color,
962
982
  width: t.width,
963
983
  arrowLength: t.arrowLength,
@@ -971,7 +991,7 @@ const Pe = (t) => {
971
991
  detourDirection: t.detourDirection
972
992
  });
973
993
  case "vertical":
974
- return () => new me({
994
+ return () => new Ve({
975
995
  color: t.color,
976
996
  width: t.width,
977
997
  arrowLength: t.arrowLength,
@@ -985,7 +1005,7 @@ const Pe = (t) => {
985
1005
  detourDirection: t.detourDirection
986
1006
  });
987
1007
  default:
988
- return () => new Te({
1008
+ return () => new me({
989
1009
  color: t.color,
990
1010
  width: t.width,
991
1011
  arrowLength: t.arrowLength,
@@ -999,30 +1019,30 @@ const Pe = (t) => {
999
1019
  detourDirection: t.detourDirection
1000
1020
  });
1001
1021
  }
1002
- }, De = (t) => {
1022
+ }, Me = (t) => {
1003
1023
  var o, r, s, d, n;
1004
- const e = ye(
1024
+ const e = xe(
1005
1025
  (o = t == null ? void 0 : t.nodes) == null ? void 0 : o.priority,
1006
1026
  (r = t == null ? void 0 : t.edges) == null ? void 0 : r.priority
1007
1027
  );
1008
1028
  return {
1009
1029
  nodes: {
1010
- centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? we,
1030
+ centerFn: ((s = t == null ? void 0 : t.nodes) == null ? void 0 : s.centerFn) ?? ye,
1011
1031
  priorityFn: e.nodesPriorityFn
1012
1032
  },
1013
1033
  ports: {
1014
1034
  direction: ((d = t == null ? void 0 : t.ports) == null ? void 0 : d.direction) ?? 0
1015
1035
  },
1016
1036
  edges: {
1017
- shapeFactory: Pe(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1037
+ shapeFactory: De(((n = t == null ? void 0 : t.edges) == null ? void 0 : n.shape) ?? {}),
1018
1038
  priorityFn: e.edgesPriorityFn
1019
1039
  }
1020
1040
  };
1021
1041
  };
1022
- class Me {
1042
+ class Le {
1023
1043
  constructor(e, o, r, s, d) {
1024
1044
  /**
1025
- * provides api for accessing graph model
1045
+ * provides api for accessing model of rendered graph
1026
1046
  */
1027
1047
  i(this, "graph");
1028
1048
  /**
@@ -1085,7 +1105,7 @@ class Me {
1085
1105
  });
1086
1106
  i(this, "onBeforeDestroyEmitter");
1087
1107
  i(this, "onBeforeDestroy");
1088
- this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = De(d), this.graph = new ue(this.graphStore), this.viewport = new ge(this.viewportStore), this.graphStore.onAfterNodeAdded.subscribe(this.onAfterNodeAdded), this.graphStore.onAfterNodeUpdated.subscribe(this.onAfterNodeUpdated), this.graphStore.onAfterNodePriorityUpdated.subscribe(
1108
+ this.element = e, this.graphStore = o, this.viewportStore = r, this.htmlView = s, this.defaults = Me(d), 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(
1089
1109
  this.onAfterNodePriorityUpdated
1090
1110
  ), 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(
1091
1111
  this.onAfterEdgeShapeUpdated
@@ -1094,12 +1114,12 @@ class Me {
1094
1114
  ), this.graphStore.onBeforeEdgeRemoved.subscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.subscribe(this.onBeforeClear), [this.onBeforeDestroyEmitter, this.onBeforeDestroy] = A();
1095
1115
  }
1096
1116
  /**
1097
- * adds node to graph
1117
+ * adds new node
1098
1118
  */
1099
1119
  addNode(e) {
1100
1120
  const o = this.nodeIdGenerator.create(e.id);
1101
1121
  if (this.graph.getNode(o) !== null)
1102
- throw new S("failed to add node with existing id");
1122
+ throw new b("failed to add node with existing id");
1103
1123
  if (this.graphStore.addNode({
1104
1124
  id: o,
1105
1125
  element: e.element,
@@ -1122,28 +1142,28 @@ class Me {
1122
1142
  */
1123
1143
  updateNode(e, o) {
1124
1144
  if (this.graph.getNode(e) === null)
1125
- throw new S("failed to update nonexisting node");
1145
+ throw new b("failed to update non existing node");
1126
1146
  return this.graphStore.updateNode(e, o ?? {}), this;
1127
1147
  }
1128
1148
  /**
1129
- * removes node from graph
1149
+ * removes specified node
1130
1150
  * all the ports of node get unmarked
1131
1151
  * all the edges adjacent to node get removed
1132
1152
  */
1133
1153
  removeNode(e) {
1134
1154
  if (this.graph.getNode(e) === null)
1135
- throw new S("failed to remove nonexisting node");
1155
+ throw new b("failed to remove non existing node");
1136
1156
  return this.graphStore.removeNode(e), this;
1137
1157
  }
1138
1158
  /**
1139
- * marks element as port of node
1159
+ * marks specified element as a port for specified node
1140
1160
  */
1141
1161
  markPort(e) {
1142
1162
  const o = this.portIdGenerator.create(e.id);
1143
1163
  if (this.graph.getPort(o) !== null)
1144
- throw new S("failed to add port with existing id");
1164
+ throw new b("failed to add port with existing id");
1145
1165
  if (this.graph.getNode(e.nodeId) === null)
1146
- throw new S("failed to mark port for nonexisting node");
1166
+ throw new b("failed to mark port for nonexistent node");
1147
1167
  return this.graphStore.addPort({
1148
1168
  id: o,
1149
1169
  element: e.element,
@@ -1152,33 +1172,33 @@ class Me {
1152
1172
  }), this;
1153
1173
  }
1154
1174
  /**
1155
- * updates port and attached edges
1175
+ * updates port and edges attached to it
1156
1176
  */
1157
1177
  updatePort(e, o) {
1158
1178
  if (this.graph.getPort(e) === null)
1159
- throw new S("failed to update nonexisting port");
1179
+ throw new b("failed to update nonexistent port");
1160
1180
  return this.graphStore.updatePort(e, o ?? {}), this;
1161
1181
  }
1162
1182
  /**
1163
- * ummarks element as port of node
1164
- * all the edges adjacent to port get removed
1183
+ * unmarks specified port
1184
+ * all the edges adjacent to the port get removed
1165
1185
  */
1166
1186
  unmarkPort(e) {
1167
1187
  if (this.graph.getPort(e) === null)
1168
- throw new S("failed to unmark nonexisting port");
1188
+ throw new b("failed to unmark non existing port");
1169
1189
  return this.graphStore.removePort(e), this;
1170
1190
  }
1171
1191
  /**
1172
- * adds edge to graph
1192
+ * adds new edge
1173
1193
  */
1174
1194
  addEdge(e) {
1175
1195
  const o = this.edgeIdGenerator.create(e.id);
1176
1196
  if (this.graph.getEdge(o) !== null)
1177
- throw new S("failed to add edge with existing id");
1197
+ throw new b("failed to add edge with existing id");
1178
1198
  if (this.graph.getPort(e.from) === null)
1179
- throw new S("failed to add edge from nonexisting port");
1199
+ throw new b("failed to add edge from nonexistent port");
1180
1200
  if (this.graph.getPort(e.to) === null)
1181
- throw new S("failed to add edge to nonexisting port");
1201
+ throw new b("failed to add edge to nonexistent port");
1182
1202
  return this.graphStore.addEdge({
1183
1203
  id: o,
1184
1204
  from: e.from,
@@ -1188,29 +1208,29 @@ class Me {
1188
1208
  }), this;
1189
1209
  }
1190
1210
  /**
1191
- * updates edge
1211
+ * updates specified edge
1192
1212
  */
1193
1213
  updateEdge(e, o) {
1194
1214
  if (this.graph.getEdge(e) === null)
1195
- throw new S("failed to update nonexisting edge");
1215
+ throw new b("failed to update nonexistent edge");
1196
1216
  return this.graphStore.updateEdge(e, o ?? {}), this;
1197
1217
  }
1198
1218
  /**
1199
- * removes edge from graph
1219
+ * removes specified edge
1200
1220
  */
1201
1221
  removeEdge(e) {
1202
1222
  if (this.graph.getEdge(e) === null)
1203
- throw new S("failed to remove nonexisting edge");
1223
+ throw new b("failed to remove nonexistent edge");
1204
1224
  return this.graphStore.removeEdge(e), this;
1205
1225
  }
1206
1226
  /**
1207
- * applies transformation for viewport
1227
+ * applies transformation for viewport matrix
1208
1228
  */
1209
1229
  patchViewportMatrix(e) {
1210
1230
  return this.viewportStore.patchViewportMatrix(e), this;
1211
1231
  }
1212
1232
  /**
1213
- * applies transformation for content
1233
+ * applies transformation for content matrix
1214
1234
  */
1215
1235
  patchContentMatrix(e) {
1216
1236
  return this.viewportStore.patchContentMatrix(e), this;
@@ -1236,13 +1256,13 @@ class Me {
1236
1256
  ), this.graphStore.onBeforeEdgeRemoved.unsubscribe(this.onBeforeEdgeRemoved), this.graphStore.onBeforeClear.unsubscribe(this.onBeforeClear), this.clear(), this.htmlView.destroy();
1237
1257
  }
1238
1258
  }
1239
- class Ve {
1259
+ class Ce {
1240
1260
  constructor() {
1241
1261
  i(this, "nodes", /* @__PURE__ */ new Map());
1242
1262
  i(this, "ports", /* @__PURE__ */ new Map());
1243
1263
  i(this, "edges", /* @__PURE__ */ new Map());
1244
- i(this, "incommingEdges", /* @__PURE__ */ new Map());
1245
- i(this, "outcommingEdges", /* @__PURE__ */ new Map());
1264
+ i(this, "incomingEdges", /* @__PURE__ */ new Map());
1265
+ i(this, "outcomingEdges", /* @__PURE__ */ new Map());
1246
1266
  i(this, "cycleEdges", /* @__PURE__ */ new Map());
1247
1267
  i(this, "afterNodeAddedEmitter");
1248
1268
  i(this, "onAfterNodeAdded");
@@ -1301,7 +1321,7 @@ class Ve {
1301
1321
  element: e.element,
1302
1322
  direction: e.direction,
1303
1323
  nodeId: e.nodeId
1304
- }), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcommingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
1324
+ }), this.cycleEdges.set(e.id, /* @__PURE__ */ new Set()), this.incomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.outcomingEdges.set(e.id, /* @__PURE__ */ new Set()), this.nodes.get(e.nodeId).ports.set(e.id, e.element), this.afterPortAddedEmitter.emit(e.id);
1305
1325
  }
1306
1326
  getPort(e) {
1307
1327
  return this.ports.get(e);
@@ -1349,13 +1369,13 @@ class Ve {
1349
1369
  this.beforeEdgeRemovedEmitter.emit(e), this.removeEdgeInternal(e);
1350
1370
  }
1351
1371
  clear() {
1352
- this.beforeClearEmitter.emit(), this.incommingEdges.clear(), this.outcommingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
1372
+ this.beforeClearEmitter.emit(), this.incomingEdges.clear(), this.outcomingEdges.clear(), this.cycleEdges.clear(), this.edges.clear(), this.ports.clear(), this.nodes.clear();
1353
1373
  }
1354
1374
  getPortIncomingEdgeIds(e) {
1355
- return Array.from(this.incommingEdges.get(e));
1375
+ return Array.from(this.incomingEdges.get(e));
1356
1376
  }
1357
1377
  getPortOutcomingEdgeIds(e) {
1358
- return Array.from(this.outcommingEdges.get(e));
1378
+ return Array.from(this.outcomingEdges.get(e));
1359
1379
  }
1360
1380
  getPortCycleEdgeIds(e) {
1361
1381
  return Array.from(this.cycleEdges.get(e));
@@ -1401,26 +1421,26 @@ class Ve {
1401
1421
  to: e.to,
1402
1422
  shape: e.shape,
1403
1423
  priority: e.priority
1404
- }), e.from !== e.to ? (this.outcommingEdges.get(e.from).add(e.id), this.incommingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
1424
+ }), e.from !== e.to ? (this.outcomingEdges.get(e.from).add(e.id), this.incomingEdges.get(e.to).add(e.id)) : this.cycleEdges.get(e.from).add(e.id);
1405
1425
  }
1406
1426
  removeEdgeInternal(e) {
1407
1427
  const o = this.edges.get(e), r = o.from, s = o.to;
1408
- this.cycleEdges.get(r).delete(e), this.cycleEdges.get(s).delete(e), this.incommingEdges.get(r).delete(e), this.incommingEdges.get(s).delete(e), this.outcommingEdges.get(r).delete(e), this.outcommingEdges.get(s).delete(e), this.edges.delete(e);
1428
+ 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);
1409
1429
  }
1410
1430
  }
1411
- const ee = (t) => ({
1431
+ const te = (t) => ({
1412
1432
  scale: 1 / t.scale,
1413
1433
  x: -t.x / t.scale,
1414
1434
  y: -t.y / t.scale
1415
- }), te = {
1435
+ }), oe = {
1416
1436
  scale: 1,
1417
1437
  x: 0,
1418
1438
  y: 0
1419
1439
  };
1420
- class Le {
1440
+ class Re {
1421
1441
  constructor() {
1422
- i(this, "viewportMatrix", te);
1423
- i(this, "contentMatrix", te);
1442
+ i(this, "viewportMatrix", oe);
1443
+ i(this, "contentMatrix", oe);
1424
1444
  i(this, "afterUpdateEmitter");
1425
1445
  i(this, "onAfterUpdated");
1426
1446
  i(this, "beforeUpdateEmitter");
@@ -1438,14 +1458,14 @@ class Le {
1438
1458
  scale: e.scale ?? this.viewportMatrix.scale,
1439
1459
  x: e.x ?? this.viewportMatrix.x,
1440
1460
  y: e.y ?? this.viewportMatrix.y
1441
- }, this.contentMatrix = ee(this.viewportMatrix), this.afterUpdateEmitter.emit();
1461
+ }, this.contentMatrix = te(this.viewportMatrix), this.afterUpdateEmitter.emit();
1442
1462
  }
1443
1463
  patchContentMatrix(e) {
1444
1464
  this.beforeUpdateEmitter.emit(), this.contentMatrix = {
1445
1465
  scale: e.scale ?? this.contentMatrix.scale,
1446
1466
  x: e.x ?? this.contentMatrix.x,
1447
1467
  y: e.y ?? this.contentMatrix.y
1448
- }, this.viewportMatrix = ee(this.contentMatrix), this.afterUpdateEmitter.emit();
1468
+ }, this.viewportMatrix = te(this.contentMatrix), this.afterUpdateEmitter.emit();
1449
1469
  }
1450
1470
  }
1451
1471
  class G {
@@ -1483,35 +1503,34 @@ class G {
1483
1503
  });
1484
1504
  }
1485
1505
  }
1486
- const Ce = (t) => {
1506
+ const Ue = (t) => {
1487
1507
  var g, f, v, y, p, E;
1488
1508
  const e = ((g = t == null ? void 0 : t.events) == null ? void 0 : g.onNodeDrag) ?? (() => {
1489
1509
  }), o = ((f = t == null ? void 0 : t.events) == null ? void 0 : f.onBeforeNodeDrag) ?? (() => !0), r = ((v = t == null ? void 0 : t.events) == null ? void 0 : v.onNodeDragFinished) ?? (() => {
1490
- }), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (T) => T.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
1510
+ }), s = (t == null ? void 0 : t.moveOnTop) === !1, d = (y = t == null ? void 0 : t.mouse) == null ? void 0 : y.dragCursor, n = d !== void 0 ? d : "grab", h = (p = t == null ? void 0 : t.mouse) == null ? void 0 : p.mouseDownEventVerifier, c = h !== void 0 ? h : (S) => S.button === 0, a = (E = t == null ? void 0 : t.mouse) == null ? void 0 : E.mouseUpEventVerifier;
1491
1511
  return {
1492
1512
  freezePriority: s,
1493
1513
  dragCursor: n,
1494
1514
  mouseDownEventVerifier: c,
1495
- mouseUpEventVerifier: a !== void 0 ? a : (T) => T.button === 0,
1515
+ mouseUpEventVerifier: a !== void 0 ? a : (S) => S.button === 0,
1496
1516
  onNodeDrag: e,
1497
1517
  onBeforeNodeDrag: o,
1498
1518
  onNodeDragFinished: r
1499
1519
  };
1500
- }, R = (t, e, o) => {
1520
+ }, U = (t, e, o) => {
1501
1521
  const { x: r, y: s, width: d, height: n } = t.getBoundingClientRect();
1502
1522
  return e >= r && e <= r + d && o >= s && o <= s + n;
1503
- }, U = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, I = (t, e) => {
1523
+ }, B = (t, e, o) => e >= 0 && e <= t.innerWidth && o >= 0 && o <= t.innerHeight, $ = (t, e) => {
1504
1524
  e !== null ? t.style.cursor = e : t.style.removeProperty("cursor");
1505
1525
  };
1506
1526
  class J {
1507
- constructor(e, o) {
1527
+ constructor(e, o, r) {
1508
1528
  i(this, "grabbedNodeId", null);
1509
1529
  i(this, "maxNodePriority", 0);
1510
- i(this, "previousTouchCoords", null);
1530
+ i(this, "previousTouchCoordinates", null);
1511
1531
  i(this, "nodeIds", /* @__PURE__ */ new Map());
1512
1532
  i(this, "window", window);
1513
1533
  i(this, "graph");
1514
- i(this, "element");
1515
1534
  i(this, "onAfterNodeAdded", (e) => {
1516
1535
  this.updateMaxNodePriority(e);
1517
1536
  const o = this.graph.getNode(e);
@@ -1541,12 +1560,12 @@ class J {
1541
1560
  element: s.element,
1542
1561
  x: s.x,
1543
1562
  y: s.y
1544
- }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, I(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1563
+ }) && (e.stopImmediatePropagation(), this.grabbedNodeId = r, $(this.element, this.options.dragCursor), this.moveNodeOnTop(r), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.window.addEventListener("mousemove", this.onWindowMouseMove));
1545
1564
  });
1546
1565
  i(this, "onTouchStart", (e) => {
1547
1566
  if (e.touches.length !== 1)
1548
1567
  return;
1549
- e.stopImmediatePropagation(), this.previousTouchCoords = {
1568
+ e.stopImmediatePropagation(), this.previousTouchCoordinates = {
1550
1569
  x: e.touches[0].clientX,
1551
1570
  y: e.touches[0].clientY
1552
1571
  };
@@ -1559,7 +1578,7 @@ class J {
1559
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
1579
  });
1561
1580
  i(this, "onWindowMouseMove", (e) => {
1562
- if (!R(this.element, e.clientX, e.clientY) || !U(this.window, e.clientX, e.clientY)) {
1581
+ if (!U(this.element, e.clientX, e.clientY) || !B(this.window, e.clientX, e.clientY)) {
1563
1582
  this.cancelMouseDrag();
1564
1583
  return;
1565
1584
  }
@@ -1572,26 +1591,26 @@ class J {
1572
1591
  if (e.touches.length !== 1)
1573
1592
  return;
1574
1593
  const o = e.touches[0];
1575
- if (!R(this.element, o.clientX, o.clientY) || !U(this.window, o.clientX, o.clientY)) {
1594
+ if (!U(this.element, o.clientX, o.clientY) || !B(this.window, o.clientX, o.clientY)) {
1576
1595
  this.cancelTouchDrag();
1577
1596
  return;
1578
1597
  }
1579
- if (this.grabbedNodeId !== null && this.previousTouchCoords !== null) {
1580
- const r = o.clientX - this.previousTouchCoords.x, s = o.clientY - this.previousTouchCoords.y;
1581
- this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoords = {
1598
+ if (this.grabbedNodeId !== null && this.previousTouchCoordinates !== null) {
1599
+ const r = o.clientX - this.previousTouchCoordinates.x, s = o.clientY - this.previousTouchCoordinates.y;
1600
+ this.dragNode(this.grabbedNodeId, r, s), this.previousTouchCoordinates = {
1582
1601
  x: e.touches[0].clientX,
1583
1602
  y: e.touches[0].clientY
1584
1603
  };
1585
1604
  }
1586
1605
  });
1587
1606
  i(this, "onWindowTouchFinish", () => {
1588
- this.previousTouchCoords = null, this.cancelTouchDrag();
1607
+ this.previousTouchCoordinates = null, this.cancelTouchDrag();
1589
1608
  });
1590
1609
  i(this, "options");
1591
- this.canvas = e, this.options = Ce(o), this.graph = e.graph, this.element = e.element, 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);
1610
+ this.canvas = e, this.element = o, this.options = Ue(r), 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);
1592
1611
  }
1593
- static configure(e, o) {
1594
- new J(e, o);
1612
+ static configure(e, o, r) {
1613
+ new J(e, o, r);
1595
1614
  }
1596
1615
  dragNode(e, o, r) {
1597
1616
  const s = this.graph.getNode(e);
@@ -1621,13 +1640,13 @@ class J {
1621
1640
  element: e.element,
1622
1641
  x: e.x,
1623
1642
  y: e.y
1624
- }), this.grabbedNodeId = null, I(this.canvas.element, null), this.removeMouseDragListeners();
1643
+ }), this.grabbedNodeId = null, $(this.element, null), this.removeMouseDragListeners();
1625
1644
  }
1626
1645
  removeMouseDragListeners() {
1627
1646
  this.window.removeEventListener("mouseup", this.onWindowMouseUp), this.window.removeEventListener("mousemove", this.onWindowMouseMove);
1628
1647
  }
1629
1648
  cancelTouchDrag() {
1630
- this.previousTouchCoords = null;
1649
+ this.previousTouchCoordinates = null;
1631
1650
  const e = this.graph.getNode(this.grabbedNodeId);
1632
1651
  e !== null && this.options.onNodeDragFinished({
1633
1652
  nodeId: this.grabbedNodeId,
@@ -1644,7 +1663,7 @@ class J {
1644
1663
  this.maxNodePriority = Math.max(this.maxNodePriority, o);
1645
1664
  }
1646
1665
  }
1647
- const Re = (t) => {
1666
+ const Be = (t) => {
1648
1667
  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;
1649
1668
  return (d) => {
1650
1669
  let n = d.nextTransform.x, h = d.nextTransform.y;
@@ -1654,7 +1673,7 @@ const Re = (t) => {
1654
1673
  const l = d.canvasHeight * d.prevTransform.scale, g = s - l;
1655
1674
  return h > g && h > d.prevTransform.y && (h = Math.max(d.prevTransform.y, g)), { scale: d.nextTransform.scale, x: n, y: h };
1656
1675
  };
1657
- }, Ue = (t) => {
1676
+ }, $e = (t) => {
1658
1677
  const e = t.maxContentScale, o = t.minContentScale, r = e !== null ? 1 / e : 0, s = o !== null ? 1 / o : 1 / 0;
1659
1678
  return (d) => {
1660
1679
  const n = d.prevTransform, h = d.nextTransform;
@@ -1683,40 +1702,40 @@ const Re = (t) => {
1683
1702
  canvasHeight: e.canvasHeight
1684
1703
  }),
1685
1704
  e.nextTransform
1686
- ), oe = (t) => {
1705
+ ), re = (t) => {
1687
1706
  if (typeof t == "function")
1688
1707
  return t;
1689
1708
  switch (t.type) {
1690
1709
  case "scale-limit":
1691
- return Ue({
1710
+ return $e({
1692
1711
  minContentScale: t.minContentScale ?? 0,
1693
1712
  maxContentScale: t.maxContentScale ?? 1 / 0
1694
1713
  });
1695
1714
  case "shift-limit":
1696
- return Re({
1715
+ return Be({
1697
1716
  minX: t.minX ?? -1 / 0,
1698
1717
  maxX: t.maxX ?? 1 / 0,
1699
1718
  minY: t.minY ?? -1 / 0,
1700
1719
  maxY: t.maxY ?? 1 / 0
1701
1720
  });
1702
1721
  }
1703
- }, Be = (t) => {
1704
- var y, p, E, T, Y, D, M, V, Q, Z, _, q;
1722
+ }, We = (t) => {
1723
+ var y, p, E, S, V, D, M, L, Z, _, q, O;
1705
1724
  const e = (y = t == null ? void 0 : t.scale) == null ? void 0 : y.mouseWheelSensitivity, o = e !== void 0 ? e : 1.2, r = t == null ? void 0 : t.transformPreprocessor;
1706
1725
  let s;
1707
1726
  r !== void 0 ? Array.isArray(r) ? s = Ie(
1708
1727
  r.map(
1709
- (P) => oe(P)
1728
+ (P) => re(P)
1710
1729
  )
1711
- ) : s = oe(r) : s = (P) => P.nextTransform;
1730
+ ) : s = re(r) : s = (P) => P.nextTransform;
1712
1731
  const d = ((p = t == null ? void 0 : t.shift) == null ? void 0 : p.cursor) !== void 0 ? t.shift.cursor : "grab", n = ((E = t == null ? void 0 : t.events) == null ? void 0 : E.onBeforeTransformChange) ?? (() => {
1713
- }), h = ((T = t == null ? void 0 : t.events) == null ? void 0 : T.onTransformChange) ?? (() => {
1714
- }), c = (Y = t == null ? void 0 : t.shift) == null ? void 0 : Y.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (D = t == null ? void 0 : t.shift) == null ? void 0 : D.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (M = t == null ? void 0 : t.scale) == null ? void 0 : M.mouseWheelEventVerifier, v = f !== void 0 ? f : () => !0;
1732
+ }), h = ((S = t == null ? void 0 : t.events) == null ? void 0 : S.onTransformChange) ?? (() => {
1733
+ }), c = (V = t == null ? void 0 : t.shift) == null ? void 0 : V.mouseDownEventVerifier, a = c !== void 0 ? c : (P) => P.button === 0, l = (D = t == null ? void 0 : t.shift) == null ? void 0 : D.mouseUpEventVerifier, g = l !== void 0 ? l : (P) => P.button === 0, f = (M = t == null ? void 0 : t.scale) == null ? void 0 : M.mouseWheelEventVerifier, v = f !== void 0 ? f : () => !0;
1715
1734
  return {
1716
1735
  wheelSensitivity: o,
1717
- onTransformStarted: ((V = t == null ? void 0 : t.events) == null ? void 0 : V.onTransformStarted) ?? (() => {
1736
+ onTransformStarted: ((L = t == null ? void 0 : t.events) == null ? void 0 : L.onTransformStarted) ?? (() => {
1718
1737
  }),
1719
- onTransformFinished: ((Q = t == null ? void 0 : t.events) == null ? void 0 : Q.onTransformFinished) ?? (() => {
1738
+ onTransformFinished: ((Z = t == null ? void 0 : t.events) == null ? void 0 : Z.onTransformFinished) ?? (() => {
1720
1739
  }),
1721
1740
  onBeforeTransformChange: n,
1722
1741
  onTransformChange: h,
@@ -1725,21 +1744,21 @@ const Re = (t) => {
1725
1744
  mouseDownEventVerifier: a,
1726
1745
  mouseUpEventVerifier: g,
1727
1746
  mouseWheelEventVerifier: v,
1728
- scaleWheelFinishTimeout: ((Z = t == null ? void 0 : t.scale) == null ? void 0 : Z.wheelFinishTimeout) ?? 500,
1729
- onResizeTransformStarted: ((_ = t == null ? void 0 : t.events) == null ? void 0 : _.onResizeTransformStarted) ?? (() => {
1747
+ scaleWheelFinishTimeout: ((_ = t == null ? void 0 : t.scale) == null ? void 0 : _.wheelFinishTimeout) ?? 500,
1748
+ onResizeTransformStarted: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onResizeTransformStarted) ?? (() => {
1730
1749
  }),
1731
- onResizeTransformFinished: ((q = t == null ? void 0 : t.events) == null ? void 0 : q.onResizeTransformFinished) ?? (() => {
1750
+ onResizeTransformFinished: ((O = t == null ? void 0 : t.events) == null ? void 0 : O.onResizeTransformFinished) ?? (() => {
1732
1751
  })
1733
1752
  };
1734
- }, $e = (t, e, o) => ({
1753
+ }, Fe = (t, e, o) => ({
1735
1754
  scale: t.scale,
1736
1755
  x: t.x + t.scale * e,
1737
1756
  y: t.y + t.scale * o
1738
- }), We = (t, e, o, r) => ({
1757
+ }), ze = (t, e, o, r) => ({
1739
1758
  scale: t.scale * e,
1740
1759
  x: t.scale * (1 - e) * o + t.x,
1741
1760
  y: t.scale * (1 - e) * r + t.y
1742
- }), C = (t) => {
1761
+ }), R = (t) => {
1743
1762
  const e = [], o = t.touches.length;
1744
1763
  for (let h = 0; h < o; h++)
1745
1764
  e.push([t.touches[h].clientX, t.touches[h].clientY]);
@@ -1758,9 +1777,8 @@ const Re = (t) => {
1758
1777
  touches: e
1759
1778
  };
1760
1779
  };
1761
- class z {
1762
- constructor(e, o) {
1763
- i(this, "element");
1780
+ class Y {
1781
+ constructor(e, o, r) {
1764
1782
  i(this, "window", window);
1765
1783
  i(this, "viewport");
1766
1784
  i(this, "prevTouches", null);
@@ -1770,10 +1788,10 @@ class z {
1770
1788
  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);
1771
1789
  });
1772
1790
  i(this, "onMouseDown", (e) => {
1773
- this.element === null || !this.options.mouseDownEventVerifier(e) || (I(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
1791
+ this.element === null || !this.options.mouseDownEventVerifier(e) || ($(this.element, this.options.shiftCursor), this.window.addEventListener("mousemove", this.onWindowMouseMove), this.window.addEventListener("mouseup", this.onWindowMouseUp), this.startRegisteredTransform());
1774
1792
  });
1775
1793
  i(this, "onWindowMouseMove", (e) => {
1776
- if (this.element === null || !R(this.element, e.clientX, e.clientY) || !U(this.window, e.clientX, e.clientY)) {
1794
+ if (this.element === null || !U(this.element, e.clientX, e.clientY) || !B(this.window, e.clientX, e.clientY)) {
1777
1795
  this.stopMouseDrag();
1778
1796
  return;
1779
1797
  }
@@ -1794,15 +1812,15 @@ class z {
1794
1812
  });
1795
1813
  i(this, "onTouchStart", (e) => {
1796
1814
  if (this.prevTouches !== null) {
1797
- this.prevTouches = C(e);
1815
+ this.prevTouches = R(e);
1798
1816
  return;
1799
1817
  }
1800
- this.prevTouches = C(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
1818
+ this.prevTouches = R(e), this.window.addEventListener("touchmove", this.onWindowTouchMove), this.window.addEventListener("touchend", this.onWindowTouchFinish), this.window.addEventListener("touchcancel", this.onWindowTouchFinish), this.startRegisteredTransform();
1801
1819
  });
1802
1820
  i(this, "onWindowTouchMove", (e) => {
1803
- const o = C(e);
1821
+ const o = R(e);
1804
1822
  if (!o.touches.every(
1805
- (s) => R(this.element, s[0], s[1]) && U(this.window, s[0], s[1])
1823
+ (s) => U(this.element, s[0], s[1]) && B(this.window, s[0], s[1])
1806
1824
  )) {
1807
1825
  this.stopTouchDrag();
1808
1826
  return;
@@ -1817,7 +1835,7 @@ class z {
1817
1835
  this.prevTouches = o;
1818
1836
  });
1819
1837
  i(this, "onWindowTouchFinish", (e) => {
1820
- e.touches.length > 0 ? this.prevTouches = C(e) : this.stopTouchDrag();
1838
+ e.touches.length > 0 ? this.prevTouches = R(e) : this.stopTouchDrag();
1821
1839
  });
1822
1840
  i(this, "observer", new ResizeObserver(() => {
1823
1841
  const e = this.viewport.getViewportMatrix(), { width: o, height: r } = this.element.getBoundingClientRect(), s = this.options.transformPreprocessor({
@@ -1829,13 +1847,17 @@ class z {
1829
1847
  this.options.onResizeTransformStarted(), this.canvas.patchViewportMatrix(s), this.options.onResizeTransformFinished();
1830
1848
  }));
1831
1849
  i(this, "options");
1832
- this.canvas = e, this.options = Be(o), this.element = e.element, 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);
1850
+ this.canvas = e, this.element = o, this.options = We(r), 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);
1833
1851
  }
1834
- static configure(e, o) {
1835
- new z(e, o);
1852
+ static configure(e, o, r) {
1853
+ new Y(
1854
+ e,
1855
+ o,
1856
+ r
1857
+ );
1836
1858
  }
1837
1859
  moveViewport(e, o) {
1838
- const r = this.viewport.getViewportMatrix(), s = $e(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
1860
+ const r = this.viewport.getViewportMatrix(), s = Fe(r, e, o), { width: d, height: n } = this.element.getBoundingClientRect(), h = this.options.transformPreprocessor({
1839
1861
  prevTransform: r,
1840
1862
  nextTransform: s,
1841
1863
  canvasWidth: d,
@@ -1844,7 +1866,7 @@ class z {
1844
1866
  this.performTransform(h);
1845
1867
  }
1846
1868
  scaleViewport(e, o, r) {
1847
- const s = this.canvas.viewport.getViewportMatrix(), d = We(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
1869
+ const s = this.canvas.viewport.getViewportMatrix(), d = ze(s, e, o, r), { width: n, height: h } = this.element.getBoundingClientRect(), c = this.options.transformPreprocessor({
1848
1870
  prevTransform: s,
1849
1871
  nextTransform: d,
1850
1872
  canvasWidth: n,
@@ -1853,7 +1875,7 @@ class z {
1853
1875
  this.performTransform(c);
1854
1876
  }
1855
1877
  stopMouseDrag() {
1856
- I(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1878
+ $(this.element, null), this.removeMouseDragListeners(), this.finishRegisteredTransform();
1857
1879
  }
1858
1880
  removeMouseDragListeners() {
1859
1881
  this.window.removeEventListener("mousemove", this.onWindowMouseMove), this.window.removeEventListener("mouseup", this.onWindowMouseUp);
@@ -1875,13 +1897,12 @@ class z {
1875
1897
  }
1876
1898
  }
1877
1899
  class K {
1878
- constructor(e, o, r, s) {
1900
+ constructor(e, o, r, s, d) {
1879
1901
  i(this, "canvasResizeObserver");
1880
1902
  i(this, "window", window);
1881
1903
  i(this, "nodeHorizontal");
1882
1904
  i(this, "nodeVertical");
1883
1905
  i(this, "viewport");
1884
- i(this, "element");
1885
1906
  i(this, "viewportWidth", 0);
1886
1907
  i(this, "viewportHeight", 0);
1887
1908
  i(this, "viewportMatrix");
@@ -1908,50 +1929,52 @@ class K {
1908
1929
  this.userTransformInProgress || (this.viewportMatrix = this.viewport.getViewportMatrix(), this.loadAreaAroundViewport());
1909
1930
  });
1910
1931
  i(this, "userTransformInProgress", !1);
1911
- var g, f, v, y, p;
1912
- this.canvas = e, this.trigger = r, this.virtualScrollOptions = s, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((E) => {
1913
- const T = E[0];
1914
- this.viewportWidth = T.contentRect.width, this.viewportHeight = T.contentRect.height, this.scheduleLoadAreaAroundViewport();
1915
- }), this.viewport = e.viewport, this.element = e.element;
1916
- const d = ((g = o == null ? void 0 : o.events) == null ? void 0 : g.onResizeTransformStarted) ?? (() => {
1917
- }), n = ((f = o == null ? void 0 : o.events) == null ? void 0 : f.onResizeTransformFinished) ?? (() => {
1918
- }), h = ((v = o == null ? void 0 : o.events) == null ? void 0 : v.onTransformChange) ?? (() => {
1919
- }), c = ((y = o == null ? void 0 : o.events) == null ? void 0 : y.onBeforeTransformChange) ?? (() => {
1920
- }), a = ((p = o == null ? void 0 : o.events) == null ? void 0 : p.onTransformFinished) ?? (() => {
1921
- }), l = {
1922
- ...o,
1932
+ var f, v, y, p, E;
1933
+ this.canvas = e, this.element = o, this.trigger = s, this.virtualScrollOptions = d, this.nodeHorizontal = this.virtualScrollOptions.nodeContainingRadius.horizontal, this.nodeVertical = this.virtualScrollOptions.nodeContainingRadius.vertical, this.canvasResizeObserver = new this.window.ResizeObserver((S) => {
1934
+ const V = S[0];
1935
+ this.viewportWidth = V.contentRect.width, this.viewportHeight = V.contentRect.height, this.scheduleLoadAreaAroundViewport();
1936
+ }), this.viewport = e.viewport;
1937
+ const n = ((f = r == null ? void 0 : r.events) == null ? void 0 : f.onResizeTransformStarted) ?? (() => {
1938
+ }), h = ((v = r == null ? void 0 : r.events) == null ? void 0 : v.onResizeTransformFinished) ?? (() => {
1939
+ }), c = ((y = r == null ? void 0 : r.events) == null ? void 0 : y.onTransformChange) ?? (() => {
1940
+ }), a = ((p = r == null ? void 0 : r.events) == null ? void 0 : p.onBeforeTransformChange) ?? (() => {
1941
+ }), l = ((E = r == null ? void 0 : r.events) == null ? void 0 : E.onTransformFinished) ?? (() => {
1942
+ }), g = {
1943
+ ...r,
1923
1944
  events: {
1924
- ...o == null ? void 0 : o.events,
1945
+ ...r == null ? void 0 : r.events,
1925
1946
  onResizeTransformStarted: () => {
1926
- this.userTransformInProgress = !0, d();
1947
+ this.userTransformInProgress = !0, n();
1927
1948
  },
1928
1949
  onResizeTransformFinished: () => {
1929
- this.userTransformInProgress = !1, n();
1950
+ this.userTransformInProgress = !1, h();
1930
1951
  },
1931
1952
  onBeforeTransformChange: () => {
1932
- this.userTransformInProgress = !0, c();
1953
+ this.userTransformInProgress = !0, a();
1933
1954
  },
1934
1955
  onTransformChange: () => {
1935
1956
  this.userTransformInProgress = !1;
1936
- const E = this.viewportMatrix;
1937
- this.viewportMatrix = this.viewport.getViewportMatrix(), E.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), h();
1957
+ const S = this.viewportMatrix;
1958
+ this.viewportMatrix = this.viewport.getViewportMatrix(), S.scale !== this.viewportMatrix.scale && this.scheduleEnsureViewportAreaLoaded(), c();
1938
1959
  },
1939
1960
  onTransformFinished: () => {
1940
- this.scheduleLoadAreaAroundViewport(), a();
1961
+ this.scheduleLoadAreaAroundViewport(), l();
1941
1962
  }
1942
1963
  }
1943
1964
  };
1944
- z.configure(
1965
+ Y.configure(
1945
1966
  e,
1946
- l
1967
+ this.element,
1968
+ g
1947
1969
  ), 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);
1948
1970
  }
1949
- static configure(e, o, r, s) {
1971
+ static configure(e, o, r, s, d) {
1950
1972
  new K(
1951
1973
  e,
1952
1974
  o,
1953
1975
  r,
1954
- s
1976
+ s,
1977
+ d
1955
1978
  );
1956
1979
  }
1957
1980
  scheduleLoadAreaAroundViewport() {
@@ -1968,16 +1991,109 @@ class K {
1968
1991
  this.trigger.emit({ x: r, y: s, width: d, height: n });
1969
1992
  }
1970
1993
  }
1971
- class ze {
1994
+ const Ye = () => {
1995
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "svg");
1996
+ return t.style.position = "absolute", t.style.inset = "0", t;
1997
+ }, Xe = () => {
1998
+ const t = document.createElementNS("http://www.w3.org/2000/svg", "rect");
1999
+ return t.setAttribute("fill", "url(#pattern)"), t;
2000
+ }, He = () => {
2001
+ const t = document.createElementNS(
2002
+ "http://www.w3.org/2000/svg",
2003
+ "pattern"
2004
+ );
2005
+ return t.setAttribute("id", "pattern"), t;
2006
+ }, ke = (t, e) => {
2007
+ const o = document.createElementNS(
2008
+ "http://www.w3.org/2000/svg",
2009
+ "circle"
2010
+ );
2011
+ return o.setAttribute("cx", "0"), o.setAttribute("cy", "0"), o.setAttribute("r", `${t}`), o.setAttribute("fill", `${e}`), o;
2012
+ }, je = (t) => t instanceof SVGElement ? t : ke(
2013
+ (t == null ? void 0 : t.radius) ?? 1.5,
2014
+ (t == null ? void 0 : t.color) ?? "#d8d8d8"
2015
+ ), Ge = (t) => {
2016
+ const e = t.tileDimensions, o = (e == null ? void 0 : e.width) ?? 25, r = (e == null ? void 0 : e.height) ?? 25, s = je(t.renderer ?? {});
2017
+ return {
2018
+ tileWidth: o,
2019
+ tileHeight: r,
2020
+ renderer: s,
2021
+ maxViewportScale: t.maxViewportScale ?? 10
2022
+ };
2023
+ };
2024
+ class Q {
2025
+ constructor(e, o, r) {
2026
+ i(this, "svg", Ye());
2027
+ i(this, "patternRenderingRectangle", Xe());
2028
+ i(this, "pattern", He());
2029
+ i(this, "patternContent");
2030
+ i(this, "tileWidth");
2031
+ i(this, "tileHeight");
2032
+ i(this, "halfTileWidth");
2033
+ i(this, "halfTileHeight");
2034
+ i(this, "maxViewportScale");
2035
+ i(this, "visible", !1);
2036
+ i(this, "resizeObserver", new ResizeObserver((e) => {
2037
+ const o = e[0], { width: r, height: s } = o.contentRect;
2038
+ this.svg.setAttribute("width", `${r}`), this.svg.setAttribute("height", `${s}`), this.patternRenderingRectangle.setAttribute("width", `${r}`), this.patternRenderingRectangle.setAttribute("height", `${s}`);
2039
+ const d = this.tileWidth / r, n = this.tileHeight / s;
2040
+ this.pattern.setAttribute("width", `${d}`), this.pattern.setAttribute("height", `${n}`);
2041
+ }));
2042
+ i(this, "onAfterTransformUpdated", () => {
2043
+ const e = this.canvas.viewport.getContentMatrix(), o = e.x - this.halfTileWidth * e.scale, r = e.y - this.halfTileHeight * e.scale, s = `matrix(${e.scale}, 0, 0, ${e.scale}, ${o}, ${r})`;
2044
+ this.pattern.setAttribute("patternTransform", s), this.updateVisibility();
2045
+ });
2046
+ i(this, "onBeforeDestroy", () => {
2047
+ this.resizeObserver.unobserve(this.host), this.host.removeChild(this.svg), this.canvas.viewport.onAfterUpdated.unsubscribe(
2048
+ this.onAfterTransformUpdated
2049
+ ), this.canvas.onBeforeDestroy.unsubscribe(this.onBeforeDestroy);
2050
+ });
2051
+ this.canvas = e, this.host = r;
2052
+ const s = Ge(o);
2053
+ 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;
2054
+ const d = `translate(${this.halfTileWidth}, ${this.halfTileHeight})`;
2055
+ this.patternContent.setAttribute("transform", d), this.pattern.appendChild(this.patternContent);
2056
+ const n = document.createElementNS("http://www.w3.org/2000/svg", "defs");
2057
+ 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);
2058
+ }
2059
+ static configure(e, o, r) {
2060
+ new Q(e, o, r);
2061
+ }
2062
+ updateVisibility() {
2063
+ const o = this.canvas.viewport.getViewportMatrix().scale > this.maxViewportScale;
2064
+ o && this.visible ? (this.visible = !1, this.host.removeChild(this.svg)) : !o && !this.visible && (this.visible = !0, this.host.appendChild(this.svg));
2065
+ }
2066
+ }
2067
+ const Je = () => {
2068
+ const t = document.createElement("div");
2069
+ return t.style.width = "100%", t.style.height = "100%", t.style.position = "relative", t;
2070
+ }, ie = () => {
2071
+ const t = document.createElement("div");
2072
+ return t.style.position = "absolute", t.style.inset = "0", t;
2073
+ };
2074
+ class Ke {
2075
+ constructor(e) {
2076
+ i(this, "background", ie());
2077
+ i(this, "main", ie());
2078
+ i(this, "host", Je());
2079
+ this.element = e, this.element.appendChild(this.host), this.host.appendChild(this.background), this.host.appendChild(this.main);
2080
+ }
2081
+ destroy() {
2082
+ this.host.removeChild(this.main), this.host.removeChild(this.background), this.element.removeChild(this.host);
2083
+ }
2084
+ }
2085
+ class Ze {
1972
2086
  constructor() {
1973
2087
  i(this, "element", null);
1974
2088
  i(this, "canvasDefaults", {});
1975
2089
  i(this, "dragOptions", {});
1976
2090
  i(this, "transformOptions", {});
2091
+ i(this, "backgroundOptions", {});
1977
2092
  i(this, "virtualScrollOptions");
1978
2093
  i(this, "hasDraggableNode", !1);
1979
2094
  i(this, "hasTransformableViewport", !1);
1980
2095
  i(this, "hasResizeReactiveNodes", !1);
2096
+ i(this, "hasBackground", !1);
1981
2097
  i(this, "boxRenderingTrigger");
1982
2098
  }
1983
2099
  setElement(e) {
@@ -2016,50 +2132,69 @@ class ze {
2016
2132
  enableVirtualScroll(e) {
2017
2133
  return this.virtualScrollOptions = e, this;
2018
2134
  }
2135
+ enableBackground(e) {
2136
+ return this.hasBackground = !0, this.backgroundOptions = e ?? {}, this;
2137
+ }
2019
2138
  /**
2020
2139
  * builds final canvas
2021
2140
  */
2022
2141
  build() {
2023
2142
  if (this.element === null)
2024
- throw new S(
2143
+ throw new b(
2025
2144
  "unable to build canvas when no attach element specified"
2026
2145
  );
2027
2146
  let e = this.boxRenderingTrigger;
2028
- this.virtualScrollOptions !== void 0 && e === void 0 && (e = new re());
2029
- const o = new Ve(), r = new Le();
2030
- let s = new ce(
2147
+ this.virtualScrollOptions !== void 0 && e === void 0 && (e = new se());
2148
+ const o = new Ce(), r = new Re(), s = new Ke(this.element);
2149
+ let d = new le(
2031
2150
  o,
2032
2151
  r,
2033
- this.element
2152
+ s.main
2034
2153
  );
2035
- e !== void 0 && (s = new le(s, o, e));
2036
- const d = new Me(
2154
+ e !== void 0 && (d = new ue(d, o, e));
2155
+ const n = new Le(
2037
2156
  this.element,
2038
2157
  o,
2039
2158
  r,
2040
- s,
2041
- this.canvasDefaults
2042
- );
2043
- return this.hasResizeReactiveNodes && G.configure(d), this.hasDraggableNode && J.configure(d, this.dragOptions), this.virtualScrollOptions !== void 0 ? K.configure(
2044
2159
  d,
2160
+ this.canvasDefaults
2161
+ ), h = () => {
2162
+ s.destroy(), n.onBeforeDestroy.unsubscribe(h);
2163
+ };
2164
+ return n.onBeforeDestroy.subscribe(h), this.hasBackground && Q.configure(
2165
+ n,
2166
+ this.backgroundOptions,
2167
+ s.background
2168
+ ), this.hasResizeReactiveNodes && G.configure(n), this.hasDraggableNode && J.configure(
2169
+ n,
2170
+ s.main,
2171
+ this.dragOptions
2172
+ ), this.virtualScrollOptions !== void 0 ? K.configure(
2173
+ n,
2174
+ s.main,
2045
2175
  this.transformOptions,
2046
2176
  e,
2047
2177
  this.virtualScrollOptions
2048
- ) : this.hasTransformableViewport && z.configure(
2049
- d,
2178
+ ) : this.hasTransformableViewport && Y.configure(
2179
+ n,
2180
+ s.main,
2050
2181
  this.transformOptions
2051
- ), this.reset(), d;
2182
+ ), this.reset(), n;
2052
2183
  }
2184
+ /**
2185
+ * @deprecated
2186
+ * CanvasBuilder should be single use object
2187
+ */
2053
2188
  reset() {
2054
- this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.boxRenderingTrigger = void 0;
2189
+ this.element = null, this.canvasDefaults = {}, this.dragOptions = {}, this.transformOptions = {}, this.backgroundOptions = {}, this.virtualScrollOptions = void 0, this.hasDraggableNode = !1, this.hasTransformableViewport = !1, this.hasResizeReactiveNodes = !1, this.hasBackground = !1, this.boxRenderingTrigger = void 0;
2055
2190
  }
2056
2191
  }
2057
2192
  export {
2058
- Te as BezierEdgeShape,
2059
- ze as CanvasBuilder,
2060
- re as EventSubject,
2061
- be as HorizontalEdgeShape,
2062
- S as HtmlGraphError,
2063
- Ne as StraightEdgeShape,
2064
- me as VerticalEdgeShape
2193
+ me as BezierEdgeShape,
2194
+ Ze as CanvasBuilder,
2195
+ se as EventSubject,
2196
+ Ne as HorizontalEdgeShape,
2197
+ b as HtmlGraphError,
2198
+ Pe as StraightEdgeShape,
2199
+ Ve as VerticalEdgeShape
2065
2200
  };