@linkurious/ogma-annotations 1.1.5 → 1.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +464 -455
- package/dist/index.umd.js +6 -7
- package/dist/types/Editor/Arrows/index.d.ts +1 -0
- package/package.json +10 -7
- package/dist/index.mjs.map +0 -1
- package/dist/index.umd.js.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -5,39 +5,39 @@ var In = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : t
|
|
|
5
5
|
function ce(u) {
|
|
6
6
|
return u && u.__esModule && Object.prototype.hasOwnProperty.call(u, "default") ? u.default : u;
|
|
7
7
|
}
|
|
8
|
-
var
|
|
8
|
+
var $e = { exports: {} };
|
|
9
9
|
(function(u) {
|
|
10
10
|
(function(l, t) {
|
|
11
11
|
u.exports = t();
|
|
12
12
|
})("Vector", function() {
|
|
13
13
|
var l = function() {
|
|
14
14
|
var t = Math.PI * 2, r = 180 / Math.PI, a = Math.PI / 180;
|
|
15
|
-
function
|
|
15
|
+
function h(s) {
|
|
16
16
|
return Math.round(s * 1e8) / 1e8;
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
var m =
|
|
18
|
+
function d(s, f) {
|
|
19
|
+
var m = f.x - s.x, A = f.y - s.y;
|
|
20
20
|
return Math.sqrt(m * m + A * A);
|
|
21
21
|
}
|
|
22
|
-
function g(s,
|
|
23
|
-
var A =
|
|
22
|
+
function g(s, f, m) {
|
|
23
|
+
var A = f.y - s.y, T = f.x - s.x, S = Math.atan2(A, T);
|
|
24
24
|
if (m)
|
|
25
25
|
for (; S < 0; )
|
|
26
26
|
S += t;
|
|
27
27
|
return S;
|
|
28
28
|
}
|
|
29
|
-
function p(s,
|
|
30
|
-
this.x = s !== void 0 ? s : 0, this.y =
|
|
29
|
+
function p(s, f) {
|
|
30
|
+
this.x = s !== void 0 ? s : 0, this.y = f !== void 0 ? f : 0;
|
|
31
31
|
}
|
|
32
32
|
return p.fromRadians = function(s) {
|
|
33
|
-
var
|
|
34
|
-
return new p(
|
|
33
|
+
var f = Math.cos(s), m = Math.sin(s);
|
|
34
|
+
return new p(f, m);
|
|
35
35
|
}, p.fromDegrees = function(s) {
|
|
36
|
-
var
|
|
37
|
-
return p.fromRadians(
|
|
36
|
+
var f = s * (Math.PI / 180);
|
|
37
|
+
return p.fromRadians(f);
|
|
38
38
|
}, p.fromString = function(s) {
|
|
39
|
-
var
|
|
40
|
-
return new p(parseFloat(
|
|
39
|
+
var f = s.split(",");
|
|
40
|
+
return new p(parseFloat(f[0]), parseFloat(f[1]));
|
|
41
41
|
}, p.fromArray = function(s) {
|
|
42
42
|
return new p(s[0], s[1]);
|
|
43
43
|
}, p.prototype = {
|
|
@@ -100,8 +100,8 @@ var Pe = { exports: {} };
|
|
|
100
100
|
// @param x - optional x component to set.
|
|
101
101
|
// @param y - optional y component to set.
|
|
102
102
|
// @return self.
|
|
103
|
-
set: function(s,
|
|
104
|
-
return s !== void 0 && (this.x = s),
|
|
103
|
+
set: function(s, f) {
|
|
104
|
+
return s !== void 0 && (this.x = s), f !== void 0 && (this.y = f), this;
|
|
105
105
|
},
|
|
106
106
|
// [API]
|
|
107
107
|
// [chainable, clone]
|
|
@@ -137,7 +137,7 @@ var Pe = { exports: {} };
|
|
|
137
137
|
// @param other - vector to get distance from.
|
|
138
138
|
// @return distance between vectors.
|
|
139
139
|
distanceFrom: function(s) {
|
|
140
|
-
return
|
|
140
|
+
return d(this, s);
|
|
141
141
|
},
|
|
142
142
|
// [API]
|
|
143
143
|
// []
|
|
@@ -191,8 +191,8 @@ var Pe = { exports: {} };
|
|
|
191
191
|
// @param radians - radians to rotate this vector by (can be positive or negative).
|
|
192
192
|
// @return self.
|
|
193
193
|
rotateRadiansSelf: function(s) {
|
|
194
|
-
var
|
|
195
|
-
return this.x =
|
|
194
|
+
var f = Math.cos(s), m = Math.sin(s), A = this.x * f - this.y * m, T = this.x * m + this.y * f;
|
|
195
|
+
return this.x = h(A), this.y = h(T), this;
|
|
196
196
|
},
|
|
197
197
|
// [API]
|
|
198
198
|
// [chainable]
|
|
@@ -368,8 +368,8 @@ var Pe = { exports: {} };
|
|
|
368
368
|
// @param min - min value for x, y components.
|
|
369
369
|
// @param max - max value for x, y components.
|
|
370
370
|
// @return self.
|
|
371
|
-
clampSelf: function(s,
|
|
372
|
-
return this.x < s.x && (this.x = s.x), this.y < s.y && (this.y = s.y), this.x >
|
|
371
|
+
clampSelf: function(s, f) {
|
|
372
|
+
return this.x < s.x && (this.x = s.x), this.y < s.y && (this.y = s.y), this.x > f.x && (this.x = f.x), this.y > f.y && (this.y = f.y), this;
|
|
373
373
|
},
|
|
374
374
|
// [API]
|
|
375
375
|
// [chainable, clone]
|
|
@@ -378,8 +378,8 @@ var Pe = { exports: {} };
|
|
|
378
378
|
// @param min - min value for x, y components.
|
|
379
379
|
// @param max - max value for x, y components.
|
|
380
380
|
// @return cloned vector in range.
|
|
381
|
-
clamp: function(s,
|
|
382
|
-
return this.clone().clampSelf(s,
|
|
381
|
+
clamp: function(s, f) {
|
|
382
|
+
return this.clone().clampSelf(s, f);
|
|
383
383
|
},
|
|
384
384
|
// [API]
|
|
385
385
|
// [chainable, changeSelf]
|
|
@@ -450,8 +450,8 @@ var Pe = { exports: {} };
|
|
|
450
450
|
// @param x - default value for x if undefined (0 if not defined).
|
|
451
451
|
// @param y - default value for y if undefined (0 if not defined).
|
|
452
452
|
// @return self.
|
|
453
|
-
repairSelf: function(s,
|
|
454
|
-
return (typeof this.x != "number" || isNaN(this.x + 1)) && (this.x = s || 0), (typeof this.y != "number" || isNaN(this.y + 1)) && (this.y =
|
|
453
|
+
repairSelf: function(s, f) {
|
|
454
|
+
return (typeof this.x != "number" || isNaN(this.x + 1)) && (this.x = s || 0), (typeof this.y != "number" || isNaN(this.y + 1)) && (this.y = f || 0), this;
|
|
455
455
|
},
|
|
456
456
|
// [API]
|
|
457
457
|
// [chainable, clone]
|
|
@@ -460,8 +460,8 @@ var Pe = { exports: {} };
|
|
|
460
460
|
// @param x - default value for x if undefined (0 if not defined).
|
|
461
461
|
// @param y - default value for y if undefined (0 if not defined).
|
|
462
462
|
// @return repaired clone.
|
|
463
|
-
repair: function(s,
|
|
464
|
-
return this.clone().repairSelf(s,
|
|
463
|
+
repair: function(s, f) {
|
|
464
|
+
return this.clone().repairSelf(s, f);
|
|
465
465
|
},
|
|
466
466
|
// [API]
|
|
467
467
|
// []
|
|
@@ -482,11 +482,11 @@ var Pe = { exports: {} };
|
|
|
482
482
|
}();
|
|
483
483
|
return l.zero = new l(0, 0), l.one = new l(1, 1), l.up = new l(0, -1), l.down = new l(0, 1), l.left = new l(-1, 0), l.right = new l(1, 0), l.upLeft = new l(-1, -1), l.downLeft = new l(-1, 1), l.upRight = new l(1, -1), l.downRight = new l(1, 1), l.prototype.magnitude = l.prototype.length, Object.freeze && (Object.freeze(l.zero), Object.freeze(l.one), Object.freeze(l.up), Object.freeze(l.down), Object.freeze(l.left), Object.freeze(l.right), Object.freeze(l.upLeft), Object.freeze(l.downLeft), Object.freeze(l.upRight), Object.freeze(l.downRight)), l;
|
|
484
484
|
});
|
|
485
|
-
})(
|
|
486
|
-
var _n =
|
|
487
|
-
const
|
|
488
|
-
let
|
|
489
|
-
const
|
|
485
|
+
})($e);
|
|
486
|
+
var _n = $e.exports;
|
|
487
|
+
const U = /* @__PURE__ */ ce(_n);
|
|
488
|
+
let Xt = (u = 21) => crypto.getRandomValues(new Uint8Array(u)).reduce((l, t) => (t &= 63, t < 36 ? l += t.toString(36) : t < 62 ? l += (t - 26).toString(36).toUpperCase() : t > 62 ? l += "-" : l += "_", l), "");
|
|
489
|
+
const Lt = {
|
|
490
490
|
strokeType: "plain",
|
|
491
491
|
strokeColor: "black",
|
|
492
492
|
strokeWidth: 1,
|
|
@@ -498,7 +498,7 @@ const Mt = {
|
|
|
498
498
|
properties: {
|
|
499
499
|
type: "arrow",
|
|
500
500
|
style: {
|
|
501
|
-
...
|
|
501
|
+
...Lt
|
|
502
502
|
}
|
|
503
503
|
},
|
|
504
504
|
geometry: {
|
|
@@ -518,13 +518,13 @@ const Mt = {
|
|
|
518
518
|
// tail: 'arrow-plain',
|
|
519
519
|
// start: { x: 0, y: 0 },
|
|
520
520
|
// end: { x: 100, y: 100 }
|
|
521
|
-
}, Dn = (u = 0, l = 0, t = 0, r = 0, a = { ...
|
|
522
|
-
id:
|
|
521
|
+
}, Dn = (u = 0, l = 0, t = 0, r = 0, a = { ...Lt }) => ({
|
|
522
|
+
id: Xt(),
|
|
523
523
|
type: "Feature",
|
|
524
524
|
properties: {
|
|
525
525
|
type: "arrow",
|
|
526
526
|
style: {
|
|
527
|
-
...
|
|
527
|
+
...Lt,
|
|
528
528
|
...a
|
|
529
529
|
}
|
|
530
530
|
},
|
|
@@ -536,21 +536,21 @@ const Mt = {
|
|
|
536
536
|
]
|
|
537
537
|
}
|
|
538
538
|
}), On = "http://www.w3.org/2000/svg";
|
|
539
|
-
function
|
|
539
|
+
function Mt(u) {
|
|
540
540
|
return document.createElementNS(On, u);
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function Pe(u) {
|
|
543
543
|
return u.geometry.bbox || Mn(u), u.geometry.bbox;
|
|
544
544
|
}
|
|
545
|
-
function
|
|
546
|
-
const l =
|
|
545
|
+
function ut(u) {
|
|
546
|
+
const l = Pe(u);
|
|
547
547
|
return {
|
|
548
548
|
width: l[2] - l[0],
|
|
549
549
|
height: l[3] - l[1]
|
|
550
550
|
};
|
|
551
551
|
}
|
|
552
|
-
function
|
|
553
|
-
const l =
|
|
552
|
+
function ct(u) {
|
|
553
|
+
const l = Pe(u);
|
|
554
554
|
return { x: l[0], y: l[1] };
|
|
555
555
|
}
|
|
556
556
|
function Mn(u) {
|
|
@@ -568,15 +568,15 @@ function zn(u, l, t, r, a) {
|
|
|
568
568
|
]
|
|
569
569
|
];
|
|
570
570
|
}
|
|
571
|
-
function
|
|
571
|
+
function zt(u) {
|
|
572
572
|
const [l, t] = u.geometry.coordinates[0];
|
|
573
573
|
return { x: l, y: t };
|
|
574
574
|
}
|
|
575
|
-
function
|
|
575
|
+
function jt(u, l) {
|
|
576
576
|
const [t, r] = u.geometry.coordinates[l === "start" ? 0 : 1];
|
|
577
577
|
return { x: t, y: r };
|
|
578
578
|
}
|
|
579
|
-
function
|
|
579
|
+
function qt(u) {
|
|
580
580
|
const [l, t] = u.geometry.coordinates[1];
|
|
581
581
|
return { x: l, y: t };
|
|
582
582
|
}
|
|
@@ -586,15 +586,15 @@ function Ne(u, l, t) {
|
|
|
586
586
|
function Re(u, l, t) {
|
|
587
587
|
u.geometry.coordinates[1] = [l, t];
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
return { start:
|
|
589
|
+
function Vt(u) {
|
|
590
|
+
return { start: zt(u), end: qt(u) };
|
|
591
591
|
}
|
|
592
592
|
function bt(u, l, t, r) {
|
|
593
593
|
l === "start" ? Ne(u, t, r) : Re(u, t, r);
|
|
594
594
|
}
|
|
595
595
|
const He = (u) => parseInt(u.getAttribute("data-handle-id") || "-1");
|
|
596
596
|
function Xn(u) {
|
|
597
|
-
return
|
|
597
|
+
return Bt(u).reduce(
|
|
598
598
|
(l, t) => (l[0] = Math.min(t[0], l[0]), l[1] = Math.min(t[1], l[1]), l[2] = Math.max(t[0], l[2]), l[3] = Math.max(t[1], l[3]), l),
|
|
599
599
|
[
|
|
600
600
|
Number.POSITIVE_INFINITY,
|
|
@@ -604,22 +604,22 @@ function Xn(u) {
|
|
|
604
604
|
]
|
|
605
605
|
);
|
|
606
606
|
}
|
|
607
|
-
function
|
|
607
|
+
function Bt(u) {
|
|
608
608
|
let l = [];
|
|
609
609
|
return u.type == "Point" ? l = [u.coordinates] : u.type == "LineString" || u.type == "MultiPoint" ? l = u.coordinates : u.type == "Polygon" || u.type == "MultiLineString" ? l = u.coordinates.reduce(function(t, r) {
|
|
610
610
|
return t.concat(r);
|
|
611
611
|
}, []) : u.type == "MultiPolygon" ? l = u.coordinates.reduce(
|
|
612
|
-
(t, r) => t.concat(r.reduce((a,
|
|
612
|
+
(t, r) => t.concat(r.reduce((a, h) => a.concat(h), [])),
|
|
613
613
|
[]
|
|
614
|
-
) : u.type == "Feature" ? l =
|
|
615
|
-
(t, r) => t.concat(
|
|
614
|
+
) : u.type == "Feature" ? l = Bt(u.geometry) : u.type == "GeometryCollection" ? l = u.geometries.reduce(
|
|
615
|
+
(t, r) => t.concat(Bt(r)),
|
|
616
616
|
[]
|
|
617
617
|
) : u.type == "FeatureCollection" && (l = u.features.reduce(
|
|
618
|
-
(t, r) => t.concat(
|
|
618
|
+
(t, r) => t.concat(Bt(r)),
|
|
619
619
|
[]
|
|
620
620
|
)), l;
|
|
621
621
|
}
|
|
622
|
-
function
|
|
622
|
+
function Ft(u, l, t) {
|
|
623
623
|
const r = Math.atan2(u.y - l.y, u.x - l.x);
|
|
624
624
|
return {
|
|
625
625
|
x: l.x + t * Math.cos(r),
|
|
@@ -628,55 +628,55 @@ function Ht(u, l, t) {
|
|
|
628
628
|
}
|
|
629
629
|
function je(u, l = 5, t = 30) {
|
|
630
630
|
var s;
|
|
631
|
-
const { start: r, end: a } =
|
|
631
|
+
const { start: r, end: a } = Vt(u), h = new U(r.x, r.y), g = new U(a.x, a.y).sub(h), p = u.properties.style && u.properties.style.strokeWidth ? (s = u.properties.style) == null ? void 0 : s.strokeWidth : 0;
|
|
632
632
|
return Math.min(t, Math.max(3 * p, g.length() * 0.1, l));
|
|
633
633
|
}
|
|
634
634
|
function ke(u, l, t, r) {
|
|
635
635
|
const a = l.clone().normalize().invert().mul(r);
|
|
636
636
|
if (!t || t === "none")
|
|
637
637
|
return "";
|
|
638
|
-
const
|
|
639
|
-
return `M ${
|
|
638
|
+
const h = u.clone().add(a.rotateRadians(Math.PI / 8)), d = u.clone().add(a.rotateRadians(-Math.PI / 8)), g = `${u.x} ${u.y}`;
|
|
639
|
+
return `M ${h.x} ${h.y} L ${g} ${d.x} ${d.y} ${t === "arrow" ? "" : `${h.x} ${h.y}`}`;
|
|
640
640
|
}
|
|
641
641
|
function Ln(u, l, t, r, a) {
|
|
642
|
-
const { start:
|
|
642
|
+
const { start: h, end: d } = Vt(u), { tail: g, head: p, strokeColor: s, strokeWidth: f } = u.properties.style || t, m = new U(h.x, h.y), A = new U(d.x, d.y), T = A.clone().sub(m), S = je(u, r, a), C = Mt("path");
|
|
643
643
|
C.setAttribute("data-annotation", `${u.id}`), C.setAttribute("data-annotation-type", "arrow");
|
|
644
644
|
const k = p === "arrow-plain" || g === "arrow";
|
|
645
|
-
C.setAttribute("stroke", s || "none"), C.setAttribute("stroke-width", `${
|
|
646
|
-
const F = ke(m, T.clone().invert(), g, S),
|
|
645
|
+
C.setAttribute("stroke", s || "none"), C.setAttribute("stroke-width", `${f}`), C.setAttribute("fill", k ? s || "" : "none"), C.setAttribute("stroke-linecap", "round"), C.setAttribute("stroke-linejoin", "round");
|
|
646
|
+
const F = ke(m, T.clone().invert(), g, S), X = ke(A, T, p, S), D = F + `M ${m.x} ${m.y} ${A.x} ${A.y}` + X;
|
|
647
647
|
C.setAttribute("d", D), l.appendChild(C);
|
|
648
648
|
}
|
|
649
|
-
const
|
|
649
|
+
const q = -1, Ut = "dragging", Yt = "dragstart", St = "dragend", se = "select", oe = "unselect", Cn = "hover", $n = "unhover", ae = "remove", le = "add", Pn = "cancelDrawing", he = "update", Nn = "link";
|
|
650
650
|
var Fe = { exports: {} };
|
|
651
651
|
(function(u) {
|
|
652
652
|
var l = Object.prototype.hasOwnProperty, t = "~";
|
|
653
653
|
function r() {
|
|
654
654
|
}
|
|
655
655
|
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1));
|
|
656
|
-
function a(p, s,
|
|
657
|
-
this.fn = p, this.context = s, this.once =
|
|
656
|
+
function a(p, s, f) {
|
|
657
|
+
this.fn = p, this.context = s, this.once = f || !1;
|
|
658
658
|
}
|
|
659
|
-
function
|
|
660
|
-
if (typeof
|
|
659
|
+
function h(p, s, f, m, A) {
|
|
660
|
+
if (typeof f != "function")
|
|
661
661
|
throw new TypeError("The listener must be a function");
|
|
662
|
-
var T = new a(
|
|
662
|
+
var T = new a(f, m || p, A), S = t ? t + s : s;
|
|
663
663
|
return p._events[S] ? p._events[S].fn ? p._events[S] = [p._events[S], T] : p._events[S].push(T) : (p._events[S] = T, p._eventsCount++), p;
|
|
664
664
|
}
|
|
665
|
-
function
|
|
665
|
+
function d(p, s) {
|
|
666
666
|
--p._eventsCount === 0 ? p._events = new r() : delete p._events[s];
|
|
667
667
|
}
|
|
668
668
|
function g() {
|
|
669
669
|
this._events = new r(), this._eventsCount = 0;
|
|
670
670
|
}
|
|
671
671
|
g.prototype.eventNames = function() {
|
|
672
|
-
var s = [],
|
|
672
|
+
var s = [], f, m;
|
|
673
673
|
if (this._eventsCount === 0)
|
|
674
674
|
return s;
|
|
675
|
-
for (m in
|
|
676
|
-
l.call(
|
|
677
|
-
return Object.getOwnPropertySymbols ? s.concat(Object.getOwnPropertySymbols(
|
|
675
|
+
for (m in f = this._events)
|
|
676
|
+
l.call(f, m) && s.push(t ? m.slice(1) : m);
|
|
677
|
+
return Object.getOwnPropertySymbols ? s.concat(Object.getOwnPropertySymbols(f)) : s;
|
|
678
678
|
}, g.prototype.listeners = function(s) {
|
|
679
|
-
var
|
|
679
|
+
var f = t ? t + s : s, m = this._events[f];
|
|
680
680
|
if (!m)
|
|
681
681
|
return [];
|
|
682
682
|
if (m.fn)
|
|
@@ -685,82 +685,82 @@ var Fe = { exports: {} };
|
|
|
685
685
|
S[A] = m[A].fn;
|
|
686
686
|
return S;
|
|
687
687
|
}, g.prototype.listenerCount = function(s) {
|
|
688
|
-
var
|
|
688
|
+
var f = t ? t + s : s, m = this._events[f];
|
|
689
689
|
return m ? m.fn ? 1 : m.length : 0;
|
|
690
|
-
}, g.prototype.emit = function(s,
|
|
690
|
+
}, g.prototype.emit = function(s, f, m, A, T, S) {
|
|
691
691
|
var C = t ? t + s : s;
|
|
692
692
|
if (!this._events[C])
|
|
693
693
|
return !1;
|
|
694
|
-
var k = this._events[C], F = arguments.length,
|
|
694
|
+
var k = this._events[C], F = arguments.length, X, D;
|
|
695
695
|
if (k.fn) {
|
|
696
696
|
switch (k.once && this.removeListener(s, k.fn, void 0, !0), F) {
|
|
697
697
|
case 1:
|
|
698
698
|
return k.fn.call(k.context), !0;
|
|
699
699
|
case 2:
|
|
700
|
-
return k.fn.call(k.context,
|
|
700
|
+
return k.fn.call(k.context, f), !0;
|
|
701
701
|
case 3:
|
|
702
|
-
return k.fn.call(k.context,
|
|
702
|
+
return k.fn.call(k.context, f, m), !0;
|
|
703
703
|
case 4:
|
|
704
|
-
return k.fn.call(k.context,
|
|
704
|
+
return k.fn.call(k.context, f, m, A), !0;
|
|
705
705
|
case 5:
|
|
706
|
-
return k.fn.call(k.context,
|
|
706
|
+
return k.fn.call(k.context, f, m, A, T), !0;
|
|
707
707
|
case 6:
|
|
708
|
-
return k.fn.call(k.context,
|
|
708
|
+
return k.fn.call(k.context, f, m, A, T, S), !0;
|
|
709
709
|
}
|
|
710
|
-
for (D = 1,
|
|
711
|
-
|
|
712
|
-
k.fn.apply(k.context,
|
|
710
|
+
for (D = 1, X = new Array(F - 1); D < F; D++)
|
|
711
|
+
X[D - 1] = arguments[D];
|
|
712
|
+
k.fn.apply(k.context, X);
|
|
713
713
|
} else {
|
|
714
|
-
var
|
|
715
|
-
for (D = 0; D <
|
|
714
|
+
var Y = k.length, G;
|
|
715
|
+
for (D = 0; D < Y; D++)
|
|
716
716
|
switch (k[D].once && this.removeListener(s, k[D].fn, void 0, !0), F) {
|
|
717
717
|
case 1:
|
|
718
718
|
k[D].fn.call(k[D].context);
|
|
719
719
|
break;
|
|
720
720
|
case 2:
|
|
721
|
-
k[D].fn.call(k[D].context,
|
|
721
|
+
k[D].fn.call(k[D].context, f);
|
|
722
722
|
break;
|
|
723
723
|
case 3:
|
|
724
|
-
k[D].fn.call(k[D].context,
|
|
724
|
+
k[D].fn.call(k[D].context, f, m);
|
|
725
725
|
break;
|
|
726
726
|
case 4:
|
|
727
|
-
k[D].fn.call(k[D].context,
|
|
727
|
+
k[D].fn.call(k[D].context, f, m, A);
|
|
728
728
|
break;
|
|
729
729
|
default:
|
|
730
|
-
if (!
|
|
731
|
-
for (
|
|
732
|
-
|
|
733
|
-
k[D].fn.apply(k[D].context,
|
|
730
|
+
if (!X)
|
|
731
|
+
for (G = 1, X = new Array(F - 1); G < F; G++)
|
|
732
|
+
X[G - 1] = arguments[G];
|
|
733
|
+
k[D].fn.apply(k[D].context, X);
|
|
734
734
|
}
|
|
735
735
|
}
|
|
736
736
|
return !0;
|
|
737
|
-
}, g.prototype.on = function(s,
|
|
738
|
-
return
|
|
739
|
-
}, g.prototype.once = function(s,
|
|
740
|
-
return
|
|
741
|
-
}, g.prototype.removeListener = function(s,
|
|
737
|
+
}, g.prototype.on = function(s, f, m) {
|
|
738
|
+
return h(this, s, f, m, !1);
|
|
739
|
+
}, g.prototype.once = function(s, f, m) {
|
|
740
|
+
return h(this, s, f, m, !0);
|
|
741
|
+
}, g.prototype.removeListener = function(s, f, m, A) {
|
|
742
742
|
var T = t ? t + s : s;
|
|
743
743
|
if (!this._events[T])
|
|
744
744
|
return this;
|
|
745
|
-
if (!
|
|
746
|
-
return
|
|
745
|
+
if (!f)
|
|
746
|
+
return d(this, T), this;
|
|
747
747
|
var S = this._events[T];
|
|
748
748
|
if (S.fn)
|
|
749
|
-
S.fn ===
|
|
749
|
+
S.fn === f && (!A || S.once) && (!m || S.context === m) && d(this, T);
|
|
750
750
|
else {
|
|
751
751
|
for (var C = 0, k = [], F = S.length; C < F; C++)
|
|
752
|
-
(S[C].fn !==
|
|
753
|
-
k.length ? this._events[T] = k.length === 1 ? k[0] : k :
|
|
752
|
+
(S[C].fn !== f || A && !S[C].once || m && S[C].context !== m) && k.push(S[C]);
|
|
753
|
+
k.length ? this._events[T] = k.length === 1 ? k[0] : k : d(this, T);
|
|
754
754
|
}
|
|
755
755
|
return this;
|
|
756
756
|
}, g.prototype.removeAllListeners = function(s) {
|
|
757
|
-
var
|
|
758
|
-
return s ? (
|
|
757
|
+
var f;
|
|
758
|
+
return s ? (f = t ? t + s : s, this._events[f] && d(this, f)) : (this._events = new r(), this._eventsCount = 0), this;
|
|
759
759
|
}, g.prototype.off = g.prototype.removeListener, g.prototype.addListener = g.prototype.on, g.prefixed = t, g.EventEmitter = g, u.exports = g;
|
|
760
760
|
})(Fe);
|
|
761
761
|
var Rn = Fe.exports;
|
|
762
|
-
const
|
|
763
|
-
class
|
|
762
|
+
const Be = /* @__PURE__ */ ce(Rn);
|
|
763
|
+
class qe extends Be {
|
|
764
764
|
constructor(t, r) {
|
|
765
765
|
super();
|
|
766
766
|
v(this, "ogma");
|
|
@@ -768,8 +768,8 @@ class Be extends qe {
|
|
|
768
768
|
// layer to draw elements
|
|
769
769
|
v(this, "layer");
|
|
770
770
|
v(this, "editor");
|
|
771
|
-
v(this, "selectedId",
|
|
772
|
-
v(this, "hoveredId",
|
|
771
|
+
v(this, "selectedId", q);
|
|
772
|
+
v(this, "hoveredId", q);
|
|
773
773
|
// used to remember ogma options before we change them
|
|
774
774
|
v(this, "ogmaOptions");
|
|
775
775
|
v(this, "shouldDetect");
|
|
@@ -777,15 +777,15 @@ class Be extends qe {
|
|
|
777
777
|
v(this, "showeditorOnHover");
|
|
778
778
|
v(this, "maxHandleScale", 1.5);
|
|
779
779
|
v(this, "_onKeyUp", (t) => {
|
|
780
|
-
t.code === 27 && this.selectedId !==
|
|
780
|
+
t.code === 27 && this.selectedId !== q ? this.unselect() : (t.code === 46 || t.code === 8) && this.selectedId !== q && this._canRemove() && this.remove(this.selectedId);
|
|
781
781
|
});
|
|
782
782
|
v(this, "_onClickMouseMove", (t) => {
|
|
783
783
|
if (!t.domEvent || this.isDragging || !this.shouldDetect)
|
|
784
784
|
return;
|
|
785
785
|
const r = this.ogma.view.screenToGraphCoordinates(t), a = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(r, 0) : void 0;
|
|
786
|
-
t.domEvent.type === "mousemove" ? a ? this.hover(a.id) : this.hoveredId !==
|
|
786
|
+
t.domEvent.type === "mousemove" ? a ? this.hover(a.id) : this.hoveredId !== q && this.unhover() : a ? this.select(a.id) : this.selectedId !== q && this.unselect();
|
|
787
787
|
});
|
|
788
|
-
this.ogma = t, this.elements = [], this.shouldDetect = !0, this.isDragging = !1, this.showeditorOnHover = !0, this.ogmaOptions = t.getOptions(), t.events.on(["click", "mousemove"], this._onClickMouseMove).on("keyup", this._onKeyUp).on("
|
|
788
|
+
this.ogma = t, this.elements = [], this.shouldDetect = !0, this.isDragging = !1, this.showeditorOnHover = !0, this.ogmaOptions = t.getOptions(), t.events.on(["click", "mousemove"], this._onClickMouseMove).on("keyup", this._onKeyUp).on("frame", () => {
|
|
789
789
|
this.refreshEditor(), this.refreshDrawing();
|
|
790
790
|
}), this.layer = t.layers.addSVGLayer({
|
|
791
791
|
draw: (a) => this.draw(a)
|
|
@@ -801,7 +801,7 @@ class Be extends qe {
|
|
|
801
801
|
*/
|
|
802
802
|
add(t) {
|
|
803
803
|
const r = this.getDefaultOptions(), a = Object.assign(t, {
|
|
804
|
-
id: t.id === void 0 ?
|
|
804
|
+
id: t.id === void 0 ? Xt() : t.id,
|
|
805
805
|
type: t.type,
|
|
806
806
|
properties: {
|
|
807
807
|
...r.properties,
|
|
@@ -842,30 +842,31 @@ class Be extends qe {
|
|
|
842
842
|
if (!t)
|
|
843
843
|
return;
|
|
844
844
|
const a = t.id;
|
|
845
|
-
Object.keys(r).forEach((
|
|
846
|
-
if (
|
|
847
|
-
if (
|
|
848
|
-
const
|
|
845
|
+
Object.keys(r).forEach((h) => {
|
|
846
|
+
if (h !== "id")
|
|
847
|
+
if (h === "properties") {
|
|
848
|
+
const d = r.properties || { style: {} };
|
|
849
849
|
t.properties = {
|
|
850
850
|
...t.properties || {},
|
|
851
|
-
...
|
|
851
|
+
...d || {},
|
|
852
852
|
style: {
|
|
853
853
|
...t.properties.style || {},
|
|
854
|
-
...
|
|
854
|
+
...d.style || {}
|
|
855
855
|
}
|
|
856
856
|
};
|
|
857
857
|
} else
|
|
858
|
-
|
|
858
|
+
h === "geometry" ? t.geometry = {
|
|
859
859
|
...t.geometry,
|
|
860
860
|
...r.geometry
|
|
861
|
-
} : t[
|
|
861
|
+
} : t[h] = r[h];
|
|
862
862
|
}), a === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
863
863
|
}
|
|
864
864
|
getById(t) {
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
865
|
+
const r = Number(t);
|
|
866
|
+
for (let a = 0; a < this.elements.length; a++) {
|
|
867
|
+
const h = this.elements[a];
|
|
868
|
+
if (!(h.id !== t && h.id !== r))
|
|
869
|
+
return h;
|
|
869
870
|
}
|
|
870
871
|
}
|
|
871
872
|
/**
|
|
@@ -882,15 +883,15 @@ class Be extends qe {
|
|
|
882
883
|
r && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(Cn, r));
|
|
883
884
|
}
|
|
884
885
|
getSelectedFeature() {
|
|
885
|
-
return this.selectedId ===
|
|
886
|
+
return this.selectedId === q ? null : this.getById(this.selectedId);
|
|
886
887
|
}
|
|
887
888
|
unselect() {
|
|
888
889
|
const t = this.getById(this.selectedId);
|
|
889
|
-
return t && this.emit(oe, t), this.selectedId =
|
|
890
|
+
return t && this.emit(oe, t), this.selectedId = q, this.hoveredId === q && this.editor.hide(), this.layer.refresh(), this;
|
|
890
891
|
}
|
|
891
892
|
unhover() {
|
|
892
893
|
const t = this.getById(this.hoveredId);
|
|
893
|
-
return this.emit(
|
|
894
|
+
return this.emit($n, t), this.hoveredId = q, this.selectedId === q && this.editor.hide(), this.layer.refresh(), this;
|
|
894
895
|
}
|
|
895
896
|
/**
|
|
896
897
|
* @method remove
|
|
@@ -950,7 +951,7 @@ class Be extends qe {
|
|
|
950
951
|
}
|
|
951
952
|
}
|
|
952
953
|
const Te = "handle-line", Ie = "handle-start", _e = "handle-end";
|
|
953
|
-
class Hn extends
|
|
954
|
+
class Hn extends qe {
|
|
954
955
|
constructor(t, r = {}) {
|
|
955
956
|
super(
|
|
956
957
|
t,
|
|
@@ -963,7 +964,7 @@ class Hn extends Be {
|
|
|
963
964
|
`
|
|
964
965
|
);
|
|
965
966
|
// active handle id
|
|
966
|
-
v(this, "draggedHandle",
|
|
967
|
+
v(this, "draggedHandle", q);
|
|
967
968
|
v(this, "start", { x: 0, y: 0 });
|
|
968
969
|
v(this, "end", { x: 0, y: 0 });
|
|
969
970
|
v(this, "arrow", { ...Ee });
|
|
@@ -977,14 +978,14 @@ class Hn extends Be {
|
|
|
977
978
|
r && (this.startDragging(r, t.clientX, t.clientY), this.draggedHandle = He(t.target));
|
|
978
979
|
});
|
|
979
980
|
v(this, "onMouseUp", () => {
|
|
980
|
-
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle =
|
|
981
|
+
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = q, this.emit(St, this.arrow));
|
|
981
982
|
});
|
|
982
983
|
v(this, "onMouseMove", (t) => {
|
|
983
|
-
if (!this.isDragging || this.draggedHandle ===
|
|
984
|
+
if (!this.isDragging || this.draggedHandle === q)
|
|
984
985
|
return;
|
|
985
|
-
const r = this.handles[this.draggedHandle], a = this.ogma.view.getAngle(), { x:
|
|
986
|
-
(g || p) && Ne(this.arrow, this.start.x +
|
|
987
|
-
|
|
986
|
+
const r = this.handles[this.draggedHandle], a = this.ogma.view.getAngle(), { x: h, y: d } = new U(t.clientX - this.startX, t.clientY - this.startY).divScalar(this.ogma.view.getZoom()).rotateRadians(a), g = r.id === Te, p = r.id === Ie, s = r.id === _e;
|
|
987
|
+
(g || p) && Ne(this.arrow, this.start.x + h, this.start.y + d), (g || s) && Re(this.arrow, this.end.x + h, this.end.y + d), this.emit(
|
|
988
|
+
Ut,
|
|
988
989
|
this.arrow,
|
|
989
990
|
g ? "line" : p ? "start" : "end"
|
|
990
991
|
), this.refreshEditor(), this.layer.refresh();
|
|
@@ -1001,49 +1002,53 @@ class Hn extends Be {
|
|
|
1001
1002
|
* @param y
|
|
1002
1003
|
* @param arrow
|
|
1003
1004
|
*/
|
|
1004
|
-
startDrawing(t, r, a = Dn(t, r, t, r,
|
|
1005
|
+
startDrawing(t, r, a = Dn(t, r, t, r, Lt)) {
|
|
1005
1006
|
var g;
|
|
1006
1007
|
this.add(a), this.hoveredId = a.id;
|
|
1007
|
-
const
|
|
1008
|
-
this.startDragging(this.getById(a.id),
|
|
1008
|
+
const h = this.ogma.view.graphToScreenCoordinates({ x: t, y: r }), d = ((g = this.ogma.getContainer()) == null ? void 0 : g.getBoundingClientRect()) || { left: 0, top: 0 };
|
|
1009
|
+
this.startDragging(this.getById(a.id), h.x + (d == null ? void 0 : d.left), h.y + d.top), this.draggedHandle = 2;
|
|
1009
1010
|
}
|
|
1010
1011
|
cancelDrawing() {
|
|
1011
|
-
this.isDragging && (this.remove(this.arrow.id), this.emit(St, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle =
|
|
1012
|
+
this.isDragging && (this.remove(this.arrow.id), this.emit(St, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = q);
|
|
1012
1013
|
}
|
|
1013
1014
|
startDragging(t, r, a) {
|
|
1014
|
-
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = a, this.start =
|
|
1015
|
+
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = a, this.start = zt(this.arrow), this.end = qt(this.arrow), this.disableDragging(), this.emit(Yt, this.arrow), this.isDragging = !0;
|
|
1015
1016
|
}
|
|
1016
1017
|
detect(t, r = 0) {
|
|
1017
1018
|
return this.elements.find((a) => {
|
|
1018
|
-
const { start:
|
|
1019
|
-
new
|
|
1020
|
-
), p = new
|
|
1021
|
-
return Math.abs(
|
|
1019
|
+
const { start: h, end: d } = Vt(a), g = new U(t.x, t.y).sub(
|
|
1020
|
+
new U((h.x + d.x) / 2, (h.y + d.y) / 2)
|
|
1021
|
+
), p = new U(d.x, d.y).sub(new U(h.x, h.y)), s = p.length(), f = p.normalize(), m = je(a);
|
|
1022
|
+
return Math.abs(f.dot(g)) < s / 2 + r && Math.abs(f.rotateRadians(Math.PI / 2).dot(g)) < m / 2 + r;
|
|
1022
1023
|
});
|
|
1023
1024
|
}
|
|
1024
1025
|
refreshEditor() {
|
|
1025
1026
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
1026
1027
|
return;
|
|
1027
|
-
const t = this.selectedId !==
|
|
1028
|
+
const t = this.selectedId !== q ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Vt(t), a = this.ogma.view.graphToScreenCoordinates(r.start), h = this.ogma.view.graphToScreenCoordinates(r.end), d = Math.min(this.ogma.view.getZoom(), this.maxHandleScale), [g, p, s] = Array.prototype.slice.call(
|
|
1028
1029
|
this.editor.element.querySelectorAll(".handle")
|
|
1029
1030
|
);
|
|
1030
|
-
p.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${
|
|
1031
|
-
const
|
|
1032
|
-
x: (
|
|
1033
|
-
y: (
|
|
1034
|
-
}, m = new
|
|
1035
|
-
g.style.width = `${m.length()}px`, g.style.left = `${
|
|
1031
|
+
p.style.transform = `translate(${a.x}px, ${a.y}px) translate(-50%, -50%) scale(${d})`, s.style.transform = `translate(${h.x}px, ${h.y}px) translate(-50%, -50%) scale(${d}`;
|
|
1032
|
+
const f = {
|
|
1033
|
+
x: (h.x + a.x) / 2,
|
|
1034
|
+
y: (h.y + a.y) / 2
|
|
1035
|
+
}, m = new U(h.x - a.x, h.y - a.y), A = m.mul(1 / m.length()), T = Math.atan2(A.y, A.x);
|
|
1036
|
+
g.style.width = `${m.length()}px`, g.style.left = `${f.x}px`, g.style.top = `${f.y}px`, g.style.transform = `translate(-50%, -50%) rotate(${T}rad)`;
|
|
1036
1037
|
}
|
|
1037
1038
|
getDefaultOptions() {
|
|
1038
1039
|
return Ee;
|
|
1039
1040
|
}
|
|
1040
1041
|
draw(t) {
|
|
1041
1042
|
t.innerHTML = "";
|
|
1042
|
-
const r =
|
|
1043
|
-
this.elements.forEach(
|
|
1044
|
-
(
|
|
1043
|
+
const r = Mt("g"), a = this.ogma.view.getAngle();
|
|
1044
|
+
r.setAttribute("transform", `rotate(${-a * (180 / Math.PI)})`), this.elements.forEach(
|
|
1045
|
+
(h) => Ln(h, r, Lt, this.minArrowHeight, this.maxArrowHeight)
|
|
1045
1046
|
), t.appendChild(r);
|
|
1046
1047
|
}
|
|
1048
|
+
refreshDrawing() {
|
|
1049
|
+
const t = this.ogma.view.getAngle();
|
|
1050
|
+
this.layer.element.children[0].setAttribute("transform", `rotate(${-t * (180 / Math.PI)})`);
|
|
1051
|
+
}
|
|
1047
1052
|
destroy() {
|
|
1048
1053
|
super.destroy(), document.removeEventListener("mousemove", this.onMouseMove, !0), document.removeEventListener("mouseup", this.onMouseUp);
|
|
1049
1054
|
}
|
|
@@ -1081,13 +1086,13 @@ const At = {
|
|
|
1081
1086
|
}, De = {
|
|
1082
1087
|
handleSize: 3.5,
|
|
1083
1088
|
placeholder: "Your text..."
|
|
1084
|
-
}, jn = (u = 0, l = 0, t = 100, r = 50, a = "",
|
|
1085
|
-
id:
|
|
1089
|
+
}, jn = (u = 0, l = 0, t = 100, r = 50, a = "", h = { ...At }) => ({
|
|
1090
|
+
id: Xt(),
|
|
1086
1091
|
type: "Feature",
|
|
1087
1092
|
properties: {
|
|
1088
1093
|
type: "text",
|
|
1089
1094
|
content: a,
|
|
1090
|
-
style: { ...At, ...
|
|
1095
|
+
style: { ...At, ...h }
|
|
1091
1096
|
},
|
|
1092
1097
|
geometry: {
|
|
1093
1098
|
type: "Polygon",
|
|
@@ -1119,19 +1124,19 @@ var Ve = { exports: {} };
|
|
|
1119
1124
|
}, a(e);
|
|
1120
1125
|
}
|
|
1121
1126
|
t.d(r, { default: () => Sn });
|
|
1122
|
-
var
|
|
1127
|
+
var h = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, d = /\bsmall-caps\b/, g = /\b(?:italic|oblique)\b/, p = /\bbold(?:er)?\b/, s = 13.3333333, f = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
1123
1128
|
function m(e) {
|
|
1124
1129
|
var n = "", o = this;
|
|
1125
1130
|
return o.style && o.style !== "normal" && (n += o.style), o.variant && o.variant !== "normal" && (n += (n ? " " : "") + o.variant), o.weight && o.weight !== "normal" && (n += (n ? " " : "") + o.weight), o.size && (n += (n ? " " : "") + o.size + "px", o.height !== o.size && (n += "/" + o.height + "px")), o.family && (n += (n ? " " : "") + o.family), e && (n += "::" + o.baseline), e && (n += "::" + o.color), n;
|
|
1126
1131
|
}
|
|
1127
1132
|
var A = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: m, valueOf: m };
|
|
1128
1133
|
function T(e) {
|
|
1129
|
-
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o =
|
|
1134
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, o = h.exec(e);
|
|
1130
1135
|
n.family = (o[6] || "").trim();
|
|
1131
|
-
var i =
|
|
1136
|
+
var i = f[o[2]] || parseFloat(o[2]);
|
|
1132
1137
|
o[3] === "%" ? i *= 0.16 : o[3] === "em" ? i *= 16 : o[3] === "pt" && (i *= s), n.size = i;
|
|
1133
|
-
var
|
|
1134
|
-
if (
|
|
1138
|
+
var c = parseFloat(o[4]);
|
|
1139
|
+
if (c !== "normal" && c !== "inherit" && c ? o[5] && o[5] !== "em" ? o[5] === "pt" ? n.height = c * s : o[5] === "%" ? n.height = 0.01 * i : n.height = c : n.height = c * i : n.height = Math.round(i * (7 / 6)), d.test(o[1]) && (n.variant = "small-caps"), g.test(o[1]) && (n.style = "italic"), p.test(o[1]))
|
|
1135
1140
|
n.weight = "bold";
|
|
1136
1141
|
else {
|
|
1137
1142
|
var y = parseInt(/\b(\d+)\b/.exec(o[1]), 10);
|
|
@@ -1140,7 +1145,7 @@ var Ve = { exports: {} };
|
|
|
1140
1145
|
return n;
|
|
1141
1146
|
}
|
|
1142
1147
|
function S() {
|
|
1143
|
-
var e, n, o, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif",
|
|
1148
|
+
var e, n, o, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, y = 14, w = 12, x = null, b = null, E = "";
|
|
1144
1149
|
if (i && i.nodeType) {
|
|
1145
1150
|
var O = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView), M = O.getComputedStyle(i, null);
|
|
1146
1151
|
e = M.getPropertyValue("font-family") || "", w = parseFloat(M.getPropertyValue("font-size")), y = M.getPropertyValue("line-height"), x = M.getPropertyValue("font-weight"), b = M.getPropertyValue("font-style"), E = M.getPropertyValue("font-variant") || "";
|
|
@@ -1149,9 +1154,9 @@ var Ve = { exports: {} };
|
|
|
1149
1154
|
e = I.family, w = I.size, y = I.height, E = I.variant, b = I.style, x = I.weight;
|
|
1150
1155
|
} else
|
|
1151
1156
|
a(i) === "object" && (e = i.family, w = i.size, y = i.height, E = i.variant, x = i.weight, b = i.style, n = i.baseline, o = i.color);
|
|
1152
|
-
|
|
1157
|
+
c.size && c.size < 3 && (w *= c.size), y = y !== "normal" && y ? parseFloat(y) : w * (7 / 6), c.height && c.height < 3 && (y *= c.height);
|
|
1153
1158
|
var z = Object.create(A);
|
|
1154
|
-
return z.family =
|
|
1159
|
+
return z.family = c.family || e || "sans-serif", z.height = y ?? 14, z.size = w ?? 12, z.variant = c.variant || E || "", z.style = c.style || b || "", z.weight = c.weight || x || "", z.baseline = n || 0, c.baseline != null && (z.baseline = c.baseline), z.color = c.color || o || "", z.id = m.call(z, !0), z;
|
|
1155
1160
|
}
|
|
1156
1161
|
const C = { "\n": 0.28, "\r": 0.28, " ": 0.28, " ": 0.28, " ": 0.28, "": 0, " ": 0.5, " ": 1, " ": 0.5, " ": 1, " ": 0.33, " ": 0.25, " ": 0.16, " ": 0.56, " ": 0.28, " ": 0.2, " ": 0.15, "": 0, " ": 0.16, " ": 0.22, " ": 1, "\uFEFF": 0 };
|
|
1157
1162
|
var k, F = function(e) {
|
|
@@ -1159,8 +1164,8 @@ var Ve = { exports: {} };
|
|
|
1159
1164
|
if (n && n.getContext) {
|
|
1160
1165
|
var o = n.getContext("2d");
|
|
1161
1166
|
if (o && typeof o.measureText == "function")
|
|
1162
|
-
return function(i,
|
|
1163
|
-
return o.font = String(
|
|
1167
|
+
return function(i, c) {
|
|
1168
|
+
return o.font = String(c), o.measureText(i).width;
|
|
1164
1169
|
};
|
|
1165
1170
|
}
|
|
1166
1171
|
}(typeof document < "u" ? document : null) || (k = {}, function(e, n) {
|
|
@@ -1169,33 +1174,33 @@ var Ve = { exports: {} };
|
|
|
1169
1174
|
k[n] = o, /\bmonospace\b/.test(o.family) ? o.size *= 0.6 : (o.size *= 0.45, o.weight && (o.size *= 1.18));
|
|
1170
1175
|
}
|
|
1171
1176
|
return e.length * k[n].size;
|
|
1172
|
-
}),
|
|
1173
|
-
function
|
|
1174
|
-
var i = Object.assign({}, D, o),
|
|
1175
|
-
if (!
|
|
1177
|
+
}), X = {}, D = { trim: !0, collapse: !0 };
|
|
1178
|
+
function Y(e, n, o) {
|
|
1179
|
+
var i = Object.assign({}, D, o), c = String(e);
|
|
1180
|
+
if (!c)
|
|
1176
1181
|
return 0;
|
|
1177
|
-
if (
|
|
1178
|
-
var y = n.id + "/" +
|
|
1179
|
-
return y in
|
|
1182
|
+
if (c in C) {
|
|
1183
|
+
var y = n.id + "/" + c;
|
|
1184
|
+
return y in X || (X[y] = F("_".concat(c, "_"), n) - F("__", n)), X[y];
|
|
1180
1185
|
}
|
|
1181
|
-
return i.trim && i.collapse ? i.trim ?
|
|
1186
|
+
return i.trim && i.collapse ? i.trim ? c = c.trim() : i.collapse && (c = c.replace(/\s+/g, " ")) : c = c.replace(/\n/g, " "), F(c, n) + n.size * (e.tracking || 0);
|
|
1182
1187
|
}
|
|
1183
|
-
function
|
|
1184
|
-
return
|
|
1188
|
+
function G(e) {
|
|
1189
|
+
return G = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1185
1190
|
return typeof n;
|
|
1186
1191
|
} : function(n) {
|
|
1187
1192
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1188
|
-
},
|
|
1193
|
+
}, G(e);
|
|
1189
1194
|
}
|
|
1190
|
-
function
|
|
1195
|
+
function Et(e, n) {
|
|
1191
1196
|
if (typeof n != "function" && n !== null)
|
|
1192
1197
|
throw new TypeError("Super expression must either be null or a function");
|
|
1193
|
-
e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n &&
|
|
1198
|
+
e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n && kt(e, n);
|
|
1194
1199
|
}
|
|
1195
|
-
function
|
|
1196
|
-
return
|
|
1200
|
+
function kt(e, n) {
|
|
1201
|
+
return kt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(o, i) {
|
|
1197
1202
|
return o.__proto__ = i, o;
|
|
1198
|
-
},
|
|
1203
|
+
}, kt(e, n);
|
|
1199
1204
|
}
|
|
1200
1205
|
function Gt(e) {
|
|
1201
1206
|
var n = function() {
|
|
@@ -1211,17 +1216,17 @@ var Ve = { exports: {} };
|
|
|
1211
1216
|
}
|
|
1212
1217
|
}();
|
|
1213
1218
|
return function() {
|
|
1214
|
-
var o, i =
|
|
1219
|
+
var o, i = Ct(e);
|
|
1215
1220
|
if (n) {
|
|
1216
|
-
var
|
|
1217
|
-
o = Reflect.construct(i, arguments,
|
|
1221
|
+
var c = Ct(this).constructor;
|
|
1222
|
+
o = Reflect.construct(i, arguments, c);
|
|
1218
1223
|
} else
|
|
1219
1224
|
o = i.apply(this, arguments);
|
|
1220
1225
|
return Ue(this, o);
|
|
1221
1226
|
};
|
|
1222
1227
|
}
|
|
1223
1228
|
function Ue(e, n) {
|
|
1224
|
-
if (n && (
|
|
1229
|
+
if (n && (G(n) === "object" || typeof n == "function"))
|
|
1225
1230
|
return n;
|
|
1226
1231
|
if (n !== void 0)
|
|
1227
1232
|
throw new TypeError("Derived constructors may only return object or undefined");
|
|
@@ -1231,42 +1236,42 @@ var Ve = { exports: {} };
|
|
|
1231
1236
|
return o;
|
|
1232
1237
|
}(e);
|
|
1233
1238
|
}
|
|
1234
|
-
function
|
|
1235
|
-
return
|
|
1239
|
+
function Ct(e) {
|
|
1240
|
+
return Ct = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function(n) {
|
|
1236
1241
|
return n.__proto__ || Object.getPrototypeOf(n);
|
|
1237
|
-
},
|
|
1242
|
+
}, Ct(e);
|
|
1238
1243
|
}
|
|
1239
|
-
function
|
|
1244
|
+
function $t(e, n) {
|
|
1240
1245
|
if (!(e instanceof n))
|
|
1241
1246
|
throw new TypeError("Cannot call a class as a function");
|
|
1242
1247
|
}
|
|
1243
1248
|
function ue(e, n) {
|
|
1244
1249
|
for (var o = 0; o < n.length; o++) {
|
|
1245
1250
|
var i = n[o];
|
|
1246
|
-
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (
|
|
1247
|
-
if (
|
|
1251
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(y, w) {
|
|
1252
|
+
if (G(y) !== "object" || y === null)
|
|
1248
1253
|
return y;
|
|
1249
1254
|
var x = y[Symbol.toPrimitive];
|
|
1250
1255
|
if (x !== void 0) {
|
|
1251
1256
|
var b = x.call(y, w);
|
|
1252
|
-
if (
|
|
1257
|
+
if (G(b) !== "object")
|
|
1253
1258
|
return b;
|
|
1254
1259
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1255
1260
|
}
|
|
1256
1261
|
return String(y);
|
|
1257
|
-
}(i.key, "string"),
|
|
1262
|
+
}(i.key, "string"), G(c) === "symbol" ? c : String(c)), i);
|
|
1258
1263
|
}
|
|
1259
|
-
var
|
|
1264
|
+
var c;
|
|
1260
1265
|
}
|
|
1261
|
-
function
|
|
1266
|
+
function Pt(e, n, o) {
|
|
1262
1267
|
return n && ue(e.prototype, n), o && ue(e, o), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
1263
1268
|
}
|
|
1264
1269
|
var N = function() {
|
|
1265
1270
|
function e() {
|
|
1266
1271
|
var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "";
|
|
1267
|
-
|
|
1272
|
+
$t(this, e), this.value = n, this.weight = null, this.style = null, this.font = null, this.href = null, this.sub = !1, this.sup = !1;
|
|
1268
1273
|
}
|
|
1269
|
-
return
|
|
1274
|
+
return Pt(e, [{ key: "clone", value: function() {
|
|
1270
1275
|
var n = new e(this.value);
|
|
1271
1276
|
return n.value = this.value, n.weight = this.weight, n.style = this.style, n.font = this.font, n.href = this.href, n.sub = this.sub, n.sup = this.sup, n;
|
|
1272
1277
|
} }, { key: "valueOf", value: function() {
|
|
@@ -1274,40 +1279,40 @@ var Ve = { exports: {} };
|
|
|
1274
1279
|
} }, { key: "toString", value: function() {
|
|
1275
1280
|
return this.value;
|
|
1276
1281
|
} }]), e;
|
|
1277
|
-
}(),
|
|
1278
|
-
|
|
1282
|
+
}(), Tt = function(e) {
|
|
1283
|
+
Et(o, e);
|
|
1279
1284
|
var n = Gt(o);
|
|
1280
1285
|
function o() {
|
|
1281
|
-
return
|
|
1286
|
+
return $t(this, o), n.apply(this, arguments);
|
|
1282
1287
|
}
|
|
1283
|
-
return
|
|
1288
|
+
return Pt(o);
|
|
1284
1289
|
}(N), nt = function(e) {
|
|
1285
|
-
|
|
1290
|
+
Et(o, e);
|
|
1286
1291
|
var n = Gt(o);
|
|
1287
1292
|
function o() {
|
|
1288
|
-
return
|
|
1293
|
+
return $t(this, o), n.apply(this, arguments);
|
|
1289
1294
|
}
|
|
1290
|
-
return
|
|
1295
|
+
return Pt(o);
|
|
1291
1296
|
}(N), pt = function(e) {
|
|
1292
|
-
|
|
1297
|
+
Et(o, e);
|
|
1293
1298
|
var n = Gt(o);
|
|
1294
1299
|
function o() {
|
|
1295
|
-
return
|
|
1300
|
+
return $t(this, o), n.apply(this, arguments);
|
|
1296
1301
|
}
|
|
1297
|
-
return
|
|
1302
|
+
return Pt(o);
|
|
1298
1303
|
}(N), Zt = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, Ye = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, de = /^[\xA0\u2011\u202F\u2060\uFEFF]/, Xe = /^(?:[;\xAD%?…]|,(?!\d))/, Ge = /^[´±°¢£¤$¥\u2212]/;
|
|
1299
|
-
function
|
|
1304
|
+
function Nt(e, n) {
|
|
1300
1305
|
n !== !1 && (e = e.trim());
|
|
1301
|
-
for (var o, i,
|
|
1306
|
+
for (var o, i, c = [], y = e.charAt(0), w = 0, x = 1, b = e.length; x < b; x++) {
|
|
1302
1307
|
o = e.charAt(x), i = e.charAt(x + 1);
|
|
1303
1308
|
var E = Zt.test(y), O = Zt.test(o), M = O || E, I = void 0;
|
|
1304
1309
|
if ((Ge.test(o) && !de.test(y) || Xe.test(y + i) && !de.test(o)) && (M = !0), y !== "-" && y !== "‐" && y !== "–" && y !== "—" || ((I = Zt.test(e.charAt(x - 2))) && !O && (M = !1), !I && Ye.test(o + i) && (M = !0)), M) {
|
|
1305
1310
|
var z = e.slice(w, x);
|
|
1306
|
-
/\u00AD$/.test(z) ? (
|
|
1311
|
+
/\u00AD$/.test(z) ? (c.push(new N(z.slice(0, -1))), c.push(new pt())) : (c.push(new N(z)), c.push(new Tt())), w = x;
|
|
1307
1312
|
}
|
|
1308
1313
|
y = o;
|
|
1309
1314
|
}
|
|
1310
|
-
return
|
|
1315
|
+
return c.push(new N(e.slice(w))), c;
|
|
1311
1316
|
}
|
|
1312
1317
|
const fe = { nbsp: " ", iexcl: "¡", cent: "¢", pound: "£", curren: "¤", yen: "¥", brvbar: "¦", sect: "§", uml: "¨", copy: "©", ordf: "ª", laquo: "«", not: "¬", shy: "", reg: "®", macr: "¯", deg: "°", plusmn: "±", sup2: "²", sup3: "³", acute: "´", micro: "µ", para: "¶", middot: "·", cedil: "¸", sup1: "¹", ordm: "º", raquo: "»", frac14: "¼", frac12: "½", frac34: "¾", iquest: "¿", Agrave: "À", Aacute: "Á", Acirc: "Â", Atilde: "Ã", Auml: "Ä", Aring: "Å", AElig: "Æ", Ccedil: "Ç", Egrave: "È", Eacute: "É", Ecirc: "Ê", Euml: "Ë", Igrave: "Ì", Iacute: "Í", Icirc: "Î", Iuml: "Ï", ETH: "Ð", Ntilde: "Ñ", Ograve: "Ò", Oacute: "Ó", Ocirc: "Ô", Otilde: "Õ", Ouml: "Ö", times: "×", Oslash: "Ø", Ugrave: "Ù", Uacute: "Ú", Ucirc: "Û", Uuml: "Ü", Yacute: "Ý", THORN: "Þ", szlig: "ß", agrave: "à", aacute: "á", acirc: "â", atilde: "ã", auml: "ä", aring: "å", aelig: "æ", ccedil: "ç", egrave: "è", eacute: "é", ecirc: "ê", euml: "ë", igrave: "ì", iacute: "í", icirc: "î", iuml: "ï", eth: "ð", ntilde: "ñ", ograve: "ò", oacute: "ó", ocirc: "ô", otilde: "õ", ouml: "ö", divide: "÷", oslash: "ø", ugrave: "ù", uacute: "ú", ucirc: "û", uuml: "ü", yacute: "ý", thorn: "þ", yuml: "ÿ", fnof: "ƒ", Alpha: "Α", Beta: "Β", Gamma: "Γ", Delta: "Δ", Epsilon: "Ε", Zeta: "Ζ", Eta: "Η", Theta: "Θ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Xi: "Ξ", Omicron: "Ο", Pi: "Π", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Upsilon: "Υ", Phi: "Φ", Chi: "Χ", Psi: "Ψ", Omega: "Ω", alpha: "α", beta: "β", gamma: "γ", delta: "δ", epsilon: "ε", zeta: "ζ", eta: "η", theta: "θ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", xi: "ξ", omicron: "ο", pi: "π", rho: "ρ", sigmaf: "ς", sigma: "σ", tau: "τ", upsilon: "υ", phi: "φ", chi: "χ", psi: "ψ", omega: "ω", thetasym: "ϑ", upsih: "ϒ", piv: "ϖ", bull: "•", hellip: "…", prime: "′", Prime: "″", oline: "‾", frasl: "⁄", weierp: "℘", image: "ℑ", real: "ℜ", trade: "™", alefsym: "ℵ", larr: "←", uarr: "↑", rarr: "→", darr: "↓", harr: "↔", crarr: "↵", lArr: "⇐", uArr: "⇑", rArr: "⇒", dArr: "⇓", hArr: "⇔", forall: "∀", part: "∂", exist: "∃", empty: "∅", nabla: "∇", isin: "∈", notin: "∉", ni: "∋", prod: "∏", sum: "∑", minus: "−", lowast: "∗", radic: "√", prop: "∝", infin: "∞", ang: "∠", and: "⊥", or: "⊦", cap: "∩", cup: "∪", int: "∫", there4: "∴", sim: "∼", cong: "≅", asymp: "≈", ne: "≠", equiv: "≡", le: "≤", ge: "≥", sub: "⊂", sup: "⊃", nsub: "⊄", sube: "⊆", supe: "⊇", oplus: "⊕", otimes: "⊗", perp: "⊥", sdot: "⋅", lceil: "⌈", rceil: "⌉", lfloor: "⌊", rfloor: "⌋", lang: "〈", rang: "〉", loz: "◊", spades: "♠", clubs: "♣", hearts: "♥", diams: "♦", quot: '"', amp: "&", lt: "<", gt: ">", OElig: "Œ", oelig: "œ", Scaron: "Š", scaron: "š", Yuml: "Ÿ", circ: "ˆ", tilde: "˜", ensp: " ", emsp: " ", thinsp: " ", zwnj: "", zwj: "", lrm: "", rlm: "", ndash: "–", mdash: "—", lsquo: "‘", rsquo: "’", sbquo: "‚", ldquo: "“", rdquo: "”", bdquo: "„", dagger: "†", Dagger: "‡", permil: "‰", lsaquo: "‹", rsaquo: "›" };
|
|
1313
1318
|
var Ze = /^[\n\r\x20\u2000-\u200B\u205F\u3000]/, We = /^<\/([a-zA-Z0-9]+)([^>]*)>/, Ke = /^<([a-zA-Z0-9]+)((?:\s[^=\s/]+(?:\s*=\s*(?:"[^"]+"|'[^']+'|[^>\\s]+))?)+)?\s*(\/?)>(\n*)/, Je = /^<!--(.+?)-->/, Qe = /&(?:#(\d\d{2,})|#x([\da-fA-F]{2,})|([a-zA-Z][a-zA-Z1-4]{1,8}));/g, pe = { b: function(e) {
|
|
@@ -1338,12 +1343,12 @@ var Ve = { exports: {} };
|
|
|
1338
1343
|
e.sup = !0;
|
|
1339
1344
|
} }, tn = { div: 1, li: 1, blockquote: 2, h1: 2, h2: 2, h3: 2, h4: 2, h5: 2, h6: 2, ul: 2, ol: 2, hr: 2, p: 2 };
|
|
1340
1345
|
function ge(e) {
|
|
1341
|
-
return e.replace(Qe, function(n, o, i,
|
|
1346
|
+
return e.replace(Qe, function(n, o, i, c) {
|
|
1342
1347
|
if (o || i) {
|
|
1343
1348
|
var y = o ? 10 : 16;
|
|
1344
1349
|
return String.fromCharCode(parseInt(o || i, y));
|
|
1345
1350
|
}
|
|
1346
|
-
return
|
|
1351
|
+
return c in fe ? fe[c] : n;
|
|
1347
1352
|
});
|
|
1348
1353
|
}
|
|
1349
1354
|
function en(e) {
|
|
@@ -1395,8 +1400,8 @@ var Ve = { exports: {} };
|
|
|
1395
1400
|
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (o = S(n, e)), o;
|
|
1396
1401
|
}
|
|
1397
1402
|
function me(e, n, o) {
|
|
1398
|
-
for (var i,
|
|
1399
|
-
|
|
1403
|
+
for (var i, c, y = e.width; y + o.width > n && e.length; )
|
|
1404
|
+
c = (i = e[e.length - 1]).width, i.width > o.width ? (i.value = i.value.slice(0, -1), i.width = Y(i, i.font), y += i.width) : e.pop(), y -= c;
|
|
1400
1405
|
e[e.length - 1] instanceof pt && e.pop(), i = e[e.length - 1] || i || {}, o.font = S(o.font, i.bold, i.italic, ""), o.href = e.length ? i.href : null, o.rel = e.length ? i.rel : null, o.target = e.length ? i.target : null, e.push(o);
|
|
1401
1406
|
}
|
|
1402
1407
|
function vt(e) {
|
|
@@ -1431,69 +1436,69 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1431
1436
|
return !e && !n || e === n;
|
|
1432
1437
|
};
|
|
1433
1438
|
function gn(e, n) {
|
|
1434
|
-
var o = [], i = n.font(),
|
|
1439
|
+
var o = [], i = n.font(), c = i.size, y = i.family, w = n.align(), x = n.createElement();
|
|
1435
1440
|
if (e.length) {
|
|
1436
|
-
var b = i.height, E = n.valign(), O = n.height()(), M = n.width()(0), I = !isFinite(M) && e.length === 1, z = I ? null : n.x(), R = vt(b /
|
|
1441
|
+
var b = i.height, E = n.valign(), O = n.height()(), M = n.width()(0), I = !isFinite(M) && e.length === 1, z = I ? null : n.x(), R = vt(b / c), Q = I ? null : vt(b / (1.15 * c + (b - c) / 2));
|
|
1437
1442
|
if (pn[E] && isFinite(O)) {
|
|
1438
|
-
var
|
|
1439
|
-
Q += (O *
|
|
1443
|
+
var $ = E === "bottom" ? 1 : 0.5;
|
|
1444
|
+
Q += (O * $ - b * e.length * $) / c;
|
|
1440
1445
|
}
|
|
1441
1446
|
var L = w === "justify", H = 0;
|
|
1442
1447
|
w === "right" ? H = M : w === "center" && (H = M / 2);
|
|
1443
|
-
for (var
|
|
1448
|
+
for (var P = [], tt = "tspan", Z = null, j = "", _ = function() {
|
|
1444
1449
|
if (j) {
|
|
1445
1450
|
var gt = x(tt, Z, j);
|
|
1446
|
-
|
|
1451
|
+
P.push(gt);
|
|
1447
1452
|
}
|
|
1448
1453
|
tt = "tspan", Z = null, j = "";
|
|
1449
1454
|
}, it = 0, et = e.length; it < et; it++) {
|
|
1450
|
-
var at = "",
|
|
1455
|
+
var at = "", dt = "", st = 0, lt = e[it];
|
|
1451
1456
|
if (lt.length) {
|
|
1452
|
-
|
|
1453
|
-
for (var xt = 0,
|
|
1454
|
-
var
|
|
1455
|
-
|
|
1457
|
+
P = [];
|
|
1458
|
+
for (var xt = 0, Dt = 0, ht = void 0, W = 0, Rt = lt.length; W < Rt; W++) {
|
|
1459
|
+
var B = lt[W], K = B.font;
|
|
1460
|
+
B.whitespace && xt++, Dt += B.width, W && !B.tracking && !st && Kt(K.id, at) && Kt(B.class, dt) && Kt(ht, B.href) ? j += B.value : (_(), j = B.value, Z = { fontFamily: K.family !== y ? K.family : null, fontSize: K.size !== c ? K.size : null, fontWeight: K.weight || null, fontStyle: K.style || null, fontVariant: K.variant !== "normal" && K.variant || null, fill: K.color || null, baselineShift: K.baseline ? 100 * K.baseline + "%" : null, className: B.class || null }, st && (Z.dx = vt(st), st = 0), B.tracking && (st = K.size * B.tracking), B.href && !ht ? (ht = B.href, tt = "a", Z.href = ht, Z.rel = B.rel, Z.target = B.target) : ht = null, at = K.id, dt = B.class);
|
|
1456
1461
|
}
|
|
1457
1462
|
if (_(), I)
|
|
1458
|
-
o.push.apply(o, ve(
|
|
1463
|
+
o.push.apply(o, ve(P));
|
|
1459
1464
|
else {
|
|
1460
|
-
var
|
|
1461
|
-
L && lt.length > 1 && !
|
|
1465
|
+
var Ht = null, Ot = it === et - 1 || lt[lt.length - 1] instanceof nt;
|
|
1466
|
+
L && lt.length > 1 && !Ot && (Ht = vt((M - Dt) / xt)), o.push(x.apply(void 0, ["tspan", { wordSpacing: Ht, x: z(it) + H, dy: vt(it ? R : Q) + "em" }].concat(ve(P))));
|
|
1462
1467
|
}
|
|
1463
1468
|
} else
|
|
1464
1469
|
o.push(x("tspan", { x: z(it), dy: vt(it ? R : Q) + "em" }, " "));
|
|
1465
1470
|
}
|
|
1466
1471
|
}
|
|
1467
|
-
return x.apply(void 0, ["text", { fontFamily: y, fontSize:
|
|
1472
|
+
return x.apply(void 0, ["text", { fontFamily: y, fontSize: c, textAnchor: fn[w] || "start" }].concat(o));
|
|
1468
1473
|
}
|
|
1469
1474
|
var yn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 };
|
|
1470
1475
|
function mn(e, n, o) {
|
|
1471
1476
|
if (e.length) {
|
|
1472
1477
|
o.textBaseline = "middle";
|
|
1473
|
-
var i = n.font(),
|
|
1478
|
+
var i = n.font(), c = i.height, y = i.size, w = n.valign(), x = n.height()(), b = n.width()(0), E = n.align(), O = E === "justify", M = 0.5 * c, I = yn[w];
|
|
1474
1479
|
if (I && isFinite(x)) {
|
|
1475
|
-
var z = e.length *
|
|
1480
|
+
var z = e.length * c;
|
|
1476
1481
|
M += x * I - z * I;
|
|
1477
1482
|
}
|
|
1478
1483
|
e.forEach(function(R, Q) {
|
|
1479
|
-
var
|
|
1484
|
+
var $ = n.x()(Q), L = Q * c + M, H = 0, P = 0;
|
|
1480
1485
|
R.forEach(function(j) {
|
|
1481
|
-
j.whitespace && H++,
|
|
1486
|
+
j.whitespace && H++, P += j.width;
|
|
1482
1487
|
});
|
|
1483
1488
|
var tt = 0, Z = Q === e.length - 1 || R[R.length - 1] instanceof nt;
|
|
1484
|
-
O && R.length > 1 && !Z && (tt = (b -
|
|
1489
|
+
O && R.length > 1 && !Z && (tt = (b - P) / H), R.forEach(function(j) {
|
|
1485
1490
|
o.font = j.font;
|
|
1486
1491
|
var _ = j.font, it = _.baseline ? y * -_.baseline + 0.15 * y : 0;
|
|
1487
|
-
o.fillStyle = function(
|
|
1488
|
-
return
|
|
1492
|
+
o.fillStyle = function(dt, st) {
|
|
1493
|
+
return dt.color ? dt.color : st.href ? "#00C" : "#000";
|
|
1489
1494
|
}(_, j);
|
|
1490
1495
|
var et = 0;
|
|
1491
|
-
if (E === "right" ? et += b -
|
|
1496
|
+
if (E === "right" ? et += b - P : E === "center" ? et += b / 2 - P / 2 : E === "justify" && (j.whitespace || j instanceof nt) && ($ += tt), o.fillText(j.value, $ + et, L + it), j.href) {
|
|
1492
1497
|
o.beginPath(), o.strokeStyle = o.fillStyle;
|
|
1493
1498
|
var at = Math.floor(L + 0.45 * y) + 0.5;
|
|
1494
|
-
o.moveTo(
|
|
1499
|
+
o.moveTo($ + et, at), o.lineTo($ + et + j.width, at), o.stroke();
|
|
1495
1500
|
}
|
|
1496
|
-
|
|
1501
|
+
$ += j.width;
|
|
1497
1502
|
});
|
|
1498
1503
|
});
|
|
1499
1504
|
}
|
|
@@ -1512,30 +1517,30 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1512
1517
|
}
|
|
1513
1518
|
return n;
|
|
1514
1519
|
}
|
|
1515
|
-
function
|
|
1516
|
-
return
|
|
1520
|
+
function It(e) {
|
|
1521
|
+
return It = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1517
1522
|
return typeof n;
|
|
1518
1523
|
} : function(n) {
|
|
1519
1524
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1520
|
-
},
|
|
1525
|
+
}, It(e);
|
|
1521
1526
|
}
|
|
1522
1527
|
function vn(e, n) {
|
|
1523
1528
|
for (var o = 0; o < n.length; o++) {
|
|
1524
1529
|
var i = n[o];
|
|
1525
|
-
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (
|
|
1526
|
-
if (
|
|
1530
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(y, w) {
|
|
1531
|
+
if (It(y) !== "object" || y === null)
|
|
1527
1532
|
return y;
|
|
1528
1533
|
var x = y[Symbol.toPrimitive];
|
|
1529
1534
|
if (x !== void 0) {
|
|
1530
1535
|
var b = x.call(y, w);
|
|
1531
|
-
if (
|
|
1536
|
+
if (It(b) !== "object")
|
|
1532
1537
|
return b;
|
|
1533
1538
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1534
1539
|
}
|
|
1535
1540
|
return String(y);
|
|
1536
|
-
}(i.key, "string"),
|
|
1541
|
+
}(i.key, "string"), It(c) === "symbol" ? c : String(c)), i);
|
|
1537
1542
|
}
|
|
1538
|
-
var
|
|
1543
|
+
var c;
|
|
1539
1544
|
}
|
|
1540
1545
|
var xn = S(), Qt = function(e) {
|
|
1541
1546
|
return typeof e == "function" ? e : function() {
|
|
@@ -1553,56 +1558,56 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1553
1558
|
}, x: function() {
|
|
1554
1559
|
return 0;
|
|
1555
1560
|
}, font: null, tAnchor: 0, parser: e.defaultparser }, i)
|
|
1556
|
-
for (var
|
|
1557
|
-
typeof this[
|
|
1561
|
+
for (var c in i)
|
|
1562
|
+
typeof this[c] == "function" && this[c](i[c]);
|
|
1558
1563
|
}
|
|
1559
1564
|
var n, o;
|
|
1560
1565
|
return n = e, o = [{ key: "linebreak", value: function(i) {
|
|
1561
|
-
var
|
|
1566
|
+
var c = this, y = this.props.parser(String(i)), w = this.font(), x = function(b, E, O) {
|
|
1562
1567
|
if (!b.length)
|
|
1563
1568
|
return [];
|
|
1564
|
-
var M = E.height(), I = E.width(), z = E.overflowLine(), R = E.overflowWrap(), Q = S(O, !0, !1),
|
|
1565
|
-
if (!M() && !I(0) ||
|
|
1569
|
+
var M = E.height(), I = E.width(), z = E.overflowLine(), R = E.overflowWrap(), Q = S(O, !0, !1), $ = isFinite(M()) ? Math.floor(M() / O.height) : 1 / 0;
|
|
1570
|
+
if (!M() && !I(0) || !$)
|
|
1566
1571
|
return [];
|
|
1567
|
-
for (var L = 0, H = 0,
|
|
1572
|
+
for (var L = 0, H = 0, P = 0, tt = [], Z = [], j = !1; L < b.length && H < $; ) {
|
|
1568
1573
|
var _ = b[L], it = dn(_, O);
|
|
1569
|
-
if (_.width =
|
|
1574
|
+
if (_.width = Y(_, it), _.font = it, _.line = H, _.whitespace = _.value in C, _.value && (_.value = _.value.replace(un, " ")), !(!P && _.whitespace || j && _.whitespace))
|
|
1570
1575
|
if (_ instanceof nt)
|
|
1571
|
-
|
|
1572
|
-
else if (_ instanceof
|
|
1573
|
-
Z.push({ index: L, width:
|
|
1574
|
-
else if (_.whitespace ||
|
|
1575
|
-
|
|
1576
|
+
P = 0, Z = [], tt.push(L + 1), H++;
|
|
1577
|
+
else if (_ instanceof Tt || _ instanceof pt)
|
|
1578
|
+
Z.push({ index: L, width: P });
|
|
1579
|
+
else if (_.whitespace || P + _.width < I(H))
|
|
1580
|
+
P += _.width;
|
|
1576
1581
|
else if (Z.length) {
|
|
1577
1582
|
var et = void 0, at = void 0;
|
|
1578
1583
|
do {
|
|
1579
1584
|
at = !0, et = Z.pop();
|
|
1580
|
-
var
|
|
1581
|
-
|
|
1585
|
+
var dt = b[et.index], st = void 0;
|
|
1586
|
+
dt instanceof pt && (st = Y("-", dt.font), et.width + st > I(H) && (at = !Z.length));
|
|
1582
1587
|
} while (!at);
|
|
1583
|
-
tt.push(et.index + 1),
|
|
1588
|
+
tt.push(et.index + 1), P = 0, H++, L = et.index, Z = [];
|
|
1584
1589
|
} else if (R === "break-word") {
|
|
1585
1590
|
var lt = I(H);
|
|
1586
|
-
if (
|
|
1591
|
+
if (P + _.width > lt) {
|
|
1587
1592
|
var xt = _.clone();
|
|
1588
1593
|
do
|
|
1589
|
-
_.value = _.value.slice(0, -1), _.width =
|
|
1594
|
+
_.value = _.value.slice(0, -1), _.width = Y(_, _.font), P += _.width;
|
|
1590
1595
|
while (_.value && _.width > lt);
|
|
1591
|
-
xt.value = xt.value.slice(_.value.length), b.splice(L + 1, 0, new
|
|
1596
|
+
xt.value = xt.value.slice(_.value.length), b.splice(L + 1, 0, new Tt(), xt);
|
|
1592
1597
|
}
|
|
1593
|
-
tt.push(L + 1),
|
|
1598
|
+
tt.push(L + 1), P = 0, H++;
|
|
1594
1599
|
} else
|
|
1595
|
-
|
|
1600
|
+
P += _.width;
|
|
1596
1601
|
L++, j = _.whitespace;
|
|
1597
1602
|
}
|
|
1598
1603
|
L !== tt[tt.length - 1] && tt.push(L);
|
|
1599
|
-
var
|
|
1600
|
-
for (var J, yt =
|
|
1604
|
+
var Dt = 0, ht = 0, W = tt.map(function(gt) {
|
|
1605
|
+
for (var J, yt = Dt; (J = b[yt]) && (J.whitespace || !J.value); )
|
|
1601
1606
|
yt++;
|
|
1602
|
-
for (var
|
|
1603
|
-
J instanceof nt && (ne = J),
|
|
1604
|
-
J instanceof pt && (J.value = "-", J.width =
|
|
1605
|
-
var wt = b.slice(yt,
|
|
1607
|
+
for (var ft = gt, ne = null; ft > yt && (J = b[ft - 1]) && (J.whitespace || !(J.value || J instanceof pt)); )
|
|
1608
|
+
J instanceof nt && (ne = J), ft--;
|
|
1609
|
+
J instanceof pt && (J.value = "-", J.width = Y("-", J.font)), Dt = gt;
|
|
1610
|
+
var wt = b.slice(yt, ft).filter(function(ie) {
|
|
1606
1611
|
return ie.value;
|
|
1607
1612
|
});
|
|
1608
1613
|
return ne && wt.push(ne), wt.width = wt.reduce(function(ie, En) {
|
|
@@ -1610,25 +1615,25 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1610
1615
|
}, 0), wt.width > ht && (ht = wt.width), wt;
|
|
1611
1616
|
});
|
|
1612
1617
|
if (W.hasLineOverflow = !1, z) {
|
|
1613
|
-
var
|
|
1618
|
+
var Rt = z === "ellipsis" ? "…" : z;
|
|
1614
1619
|
W.forEach(function(gt, J) {
|
|
1615
1620
|
var yt = I(J);
|
|
1616
1621
|
if (gt.width > yt) {
|
|
1617
|
-
var
|
|
1618
|
-
|
|
1622
|
+
var ft = new N(Rt);
|
|
1623
|
+
ft.font = O, ft.width = Y(Rt, Q), me(gt, yt, ft), W.hasLineOverflow = !0;
|
|
1619
1624
|
}
|
|
1620
1625
|
});
|
|
1621
1626
|
}
|
|
1622
|
-
var
|
|
1623
|
-
if (
|
|
1624
|
-
var K = I(W.length - 1),
|
|
1625
|
-
|
|
1627
|
+
var B = E.overflow() === "ellipsis" ? "…" : E.overflow();
|
|
1628
|
+
if (B && L !== b.length) {
|
|
1629
|
+
var K = I(W.length - 1), Ht = W[W.length - 1], Ot = new N(B);
|
|
1630
|
+
Ot.font = O, Ot.width = Y(B, Q), me(Ht, K, Ot), W.hasOverflow = !0;
|
|
1626
1631
|
} else
|
|
1627
1632
|
W.hasOverflow = !1;
|
|
1628
1633
|
return W.font = O, W.width = ht, W;
|
|
1629
1634
|
}(y, this, w);
|
|
1630
1635
|
return x.height = x.length * w.height, x.render = function(b) {
|
|
1631
|
-
return
|
|
1636
|
+
return c.render(x, b);
|
|
1632
1637
|
}, x.svg = x.render, x.draw = x.render, x;
|
|
1633
1638
|
} }, { key: "font", value: function(i) {
|
|
1634
1639
|
return arguments.length ? (this.props.font = S(i), this) : this.props.font || S(xn);
|
|
@@ -1641,13 +1646,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1641
1646
|
} }, { key: "align", value: function(i) {
|
|
1642
1647
|
if (!arguments.length)
|
|
1643
1648
|
return this.props.align;
|
|
1644
|
-
var
|
|
1645
|
-
return
|
|
1649
|
+
var c = String(i).toLowerCase();
|
|
1650
|
+
return c === "left" || c === "start" ? (this.props.align = "left", this.props.tAnchor = 0) : c === "center" || c === "middle" ? (this.props.align = "center", this.props.tAnchor = -0.5) : c === "end" || c === "right" ? (this.props.align = "right", this.props.tAnchor = -1) : c === "justify" && (this.props.align = i, this.props.tAnchor = 0), this;
|
|
1646
1651
|
} }, { key: "overflowWrap", value: function(i) {
|
|
1647
1652
|
if (!arguments.length)
|
|
1648
1653
|
return this.props.overflowWrap || "normal";
|
|
1649
|
-
var
|
|
1650
|
-
return
|
|
1654
|
+
var c = String(i).toLowerCase();
|
|
1655
|
+
return c === "break-word" ? this.props.overflowWrap = "break-word" : c !== "normal" && i != null || (this.props.overflowWrap = null), this;
|
|
1651
1656
|
} }, { key: "width", value: function(i) {
|
|
1652
1657
|
return arguments.length ? (this.props.width = Qt(i), this) : this.props.width;
|
|
1653
1658
|
} }, { key: "height", value: function(i) {
|
|
@@ -1658,8 +1663,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1658
1663
|
if (!arguments.length)
|
|
1659
1664
|
return this.props.parser;
|
|
1660
1665
|
if (typeof i == "string") {
|
|
1661
|
-
var
|
|
1662
|
-
typeof
|
|
1666
|
+
var c = e[i] || e[i + "parser"];
|
|
1667
|
+
typeof c == "function" && (i = c);
|
|
1663
1668
|
}
|
|
1664
1669
|
if (typeof i != "function")
|
|
1665
1670
|
throw new Error("Unknown parser: " + i);
|
|
@@ -1671,12 +1676,12 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1671
1676
|
return typeof i.text == "string" && (i.text = this.linebreak(i.text)), i.ctx ? mn(i.text, this, i.ctx) : gn(i.text, this);
|
|
1672
1677
|
} }], o && vn(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1673
1678
|
}();
|
|
1674
|
-
function
|
|
1675
|
-
return
|
|
1679
|
+
function _t(e) {
|
|
1680
|
+
return _t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1676
1681
|
return typeof n;
|
|
1677
1682
|
} : function(n) {
|
|
1678
1683
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1679
|
-
},
|
|
1684
|
+
}, _t(e);
|
|
1680
1685
|
}
|
|
1681
1686
|
function te(e, n) {
|
|
1682
1687
|
(n == null || n > e.length) && (n = e.length);
|
|
@@ -1687,20 +1692,20 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1687
1692
|
function wn(e, n) {
|
|
1688
1693
|
for (var o = 0; o < n.length; o++) {
|
|
1689
1694
|
var i = n[o];
|
|
1690
|
-
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (
|
|
1691
|
-
if (
|
|
1695
|
+
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(y, w) {
|
|
1696
|
+
if (_t(y) !== "object" || y === null)
|
|
1692
1697
|
return y;
|
|
1693
1698
|
var x = y[Symbol.toPrimitive];
|
|
1694
1699
|
if (x !== void 0) {
|
|
1695
1700
|
var b = x.call(y, w);
|
|
1696
|
-
if (
|
|
1701
|
+
if (_t(b) !== "object")
|
|
1697
1702
|
return b;
|
|
1698
1703
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1699
1704
|
}
|
|
1700
1705
|
return String(y);
|
|
1701
|
-
}(i.key, "string"),
|
|
1706
|
+
}(i.key, "string"), _t(c) === "symbol" ? c : String(c)), i);
|
|
1702
1707
|
}
|
|
1703
|
-
var
|
|
1708
|
+
var c;
|
|
1704
1709
|
}
|
|
1705
1710
|
var we = function(e) {
|
|
1706
1711
|
return typeof e == "function" ? e : function() {
|
|
@@ -1716,13 +1721,13 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1716
1721
|
}, height: function() {
|
|
1717
1722
|
return 1 / 0;
|
|
1718
1723
|
}, rotation: 0, vAnchor: 0, hAnchor: 0 }, i)
|
|
1719
|
-
for (var
|
|
1720
|
-
typeof this[
|
|
1724
|
+
for (var c in i)
|
|
1725
|
+
typeof this[c] == "function" && this[c](i[c]);
|
|
1721
1726
|
this.render = this.render.bind(this);
|
|
1722
1727
|
}
|
|
1723
1728
|
var n, o;
|
|
1724
1729
|
return n = e, o = [{ key: "anchor", value: function(i) {
|
|
1725
|
-
var
|
|
1730
|
+
var c = this.props, y = c.hAnchor, w = c.vAnchor, x = c.width, b = c.height;
|
|
1726
1731
|
if (!arguments.length)
|
|
1727
1732
|
return [y * x(0), w * b(0)];
|
|
1728
1733
|
if (typeof i == "string") {
|
|
@@ -1740,7 +1745,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1740
1745
|
return arguments.length ? (this.props.rotation = i, this) : this.props.rotation;
|
|
1741
1746
|
} }, { key: "createElement", value: function(i) {
|
|
1742
1747
|
return arguments.length ? (this.props.createElement = i, this) : this.props.createElement || e.createElement;
|
|
1743
|
-
} }, { key: "canvas", value: function(i,
|
|
1748
|
+
} }, { key: "canvas", value: function(i, c) {
|
|
1744
1749
|
var y, w = i.getContext ? i.getContext("2d") : i;
|
|
1745
1750
|
return w.save(), w.rotate(this.rotate() * Math.PI / 180), w.translate.apply(w, function(x) {
|
|
1746
1751
|
if (Array.isArray(x))
|
|
@@ -1758,7 +1763,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1758
1763
|
}(y) || function() {
|
|
1759
1764
|
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
1760
1765
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`);
|
|
1761
|
-
}()),
|
|
1766
|
+
}()), c(w), w.restore(), w;
|
|
1762
1767
|
} }, { key: "render", value: function() {
|
|
1763
1768
|
var i = xe(arguments);
|
|
1764
1769
|
if (i.d3)
|
|
@@ -1766,8 +1771,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1766
1771
|
if (i.ctx)
|
|
1767
1772
|
return this.canvas(i.ctx, i.fn);
|
|
1768
1773
|
if (i.text) {
|
|
1769
|
-
var
|
|
1770
|
-
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") },
|
|
1774
|
+
var c = typeof i.text.render == "function" ? i.text.render() : i.text;
|
|
1775
|
+
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, c);
|
|
1771
1776
|
}
|
|
1772
1777
|
} }], o && wn(n.prototype, o), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1773
1778
|
}(), bn = Object.prototype.hasOwnProperty, ee = {};
|
|
@@ -1789,32 +1794,32 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1789
1794
|
if (n && o.setAttribute)
|
|
1790
1795
|
for (var i in n)
|
|
1791
1796
|
bn.call(n, i) && n[i] != null && o.setAttribute(i === "className" ? "class" : An(i), n[i]);
|
|
1792
|
-
for (var
|
|
1797
|
+
for (var c = arguments.length, y = new Array(c > 2 ? c - 2 : 0), w = 2; w < c; w++)
|
|
1793
1798
|
y[w - 2] = arguments[w];
|
|
1794
1799
|
return y != null && y.length && y.forEach(function(x) {
|
|
1795
1800
|
Ae(o, x);
|
|
1796
1801
|
}), o;
|
|
1797
1802
|
}
|
|
1798
1803
|
}
|
|
1799
|
-
rt.createElement = Se, rt.textparser =
|
|
1804
|
+
rt.createElement = Se, rt.textparser = Nt, rt.defaultparser = Nt, rt.htmlparser = function(e) {
|
|
1800
1805
|
e = String(e || "").trim();
|
|
1801
|
-
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null },
|
|
1806
|
+
for (var n, o, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, c = [], y = [], w = function(M) {
|
|
1802
1807
|
for (var I in i)
|
|
1803
1808
|
i[I] && (M[I] = i[I]);
|
|
1804
|
-
|
|
1809
|
+
c.push(M);
|
|
1805
1810
|
}, x = function(M) {
|
|
1806
|
-
var I =
|
|
1811
|
+
var I = c.length, z = tn[M];
|
|
1807
1812
|
if (I && z) {
|
|
1808
|
-
for (var R = I - 1;
|
|
1813
|
+
for (var R = I - 1; c[R] && (c[R] instanceof Tt || Ze.test(c[R].value)); )
|
|
1809
1814
|
R--;
|
|
1810
|
-
for (; z &&
|
|
1815
|
+
for (; z && c[R] && c[R] instanceof nt; )
|
|
1811
1816
|
R--, z--;
|
|
1812
1817
|
for (; z-- > 0; )
|
|
1813
|
-
|
|
1818
|
+
c.push(new nt());
|
|
1814
1819
|
}
|
|
1815
1820
|
}; e.length; ) {
|
|
1816
1821
|
if (n = /^[^<]+/.exec(e))
|
|
1817
|
-
|
|
1822
|
+
Nt(ge(n[0]), !1).forEach(w);
|
|
1818
1823
|
else if (!(n = Je.exec(e)))
|
|
1819
1824
|
if (n = We.exec(e))
|
|
1820
1825
|
y.length && (i = y.pop()), x(n[1]);
|
|
@@ -1822,45 +1827,45 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1822
1827
|
var b = n[1];
|
|
1823
1828
|
x(b), y.push(i), i = Object.create(i), pe[b] && pe[b](i, "");
|
|
1824
1829
|
var E = rn(n[2]);
|
|
1825
|
-
b === "a" && (E.href && (i.href = E.href), E.rel && (i.rel = E.rel), E.target && (i.target = E.target)), E.class && (i.class = i.class ? i.class + " " + E.class : E.class), E.style && (o = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(E.style)) && o[1] && (i.color = o[1]), b === "br" &&
|
|
1830
|
+
b === "a" && (E.href && (i.href = E.href), E.rel && (i.rel = E.rel), E.target && (i.target = E.target)), E.class && (i.class = i.class ? i.class + " " + E.class : E.class), E.style && (o = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(E.style)) && o[1] && (i.color = o[1]), b === "br" && c.push(new nt());
|
|
1826
1831
|
} else
|
|
1827
1832
|
n = [e.slice(0, 1)], w(new N(n[0]));
|
|
1828
1833
|
e = e.slice(n[0].length);
|
|
1829
1834
|
}
|
|
1830
|
-
for (var O =
|
|
1831
|
-
|
|
1832
|
-
return
|
|
1835
|
+
for (var O = c[c.length - 1]; O instanceof nt; )
|
|
1836
|
+
c.pop(), O = c[c.length - 1];
|
|
1837
|
+
return c;
|
|
1833
1838
|
}, rt.latexparser = function(e) {
|
|
1834
1839
|
e = String(e || "").trim();
|
|
1835
1840
|
var n = [0];
|
|
1836
|
-
e = e.replace(/\\verb,(.*?),/, function(
|
|
1841
|
+
e = e.replace(/\\verb,(.*?),/, function($, L) {
|
|
1837
1842
|
return n.push(L), "\\verb," + (n.length - 1) + ",";
|
|
1838
1843
|
}).replace(/\\\\\n/g, function() {
|
|
1839
1844
|
return "\\\\";
|
|
1840
|
-
}).replace(hn, function(
|
|
1841
|
-
return H.charAt(L - 1) === "\\" ?
|
|
1842
|
-
}).replace(/\n\s+/g, function(
|
|
1843
|
-
return /\n/.test(
|
|
1844
|
-
}).replace(/\\symbol\{(\d+)\}/, function(
|
|
1845
|
-
return
|
|
1846
|
-
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function(
|
|
1847
|
-
return L + H + "{" +
|
|
1848
|
-
}).replace(/\\verb,(.*?),/, function(
|
|
1845
|
+
}).replace(hn, function($, L, H) {
|
|
1846
|
+
return H.charAt(L - 1) === "\\" ? $ : cn[$];
|
|
1847
|
+
}).replace(/\n\s+/g, function($) {
|
|
1848
|
+
return /\n/.test($.slice(1)) ? "\\par " : $;
|
|
1849
|
+
}).replace(/\\symbol\{(\d+)\}/, function($, L, H, P) {
|
|
1850
|
+
return P.charAt(H - 1) === "\\" ? $ : String.fromCharCode(1 * L);
|
|
1851
|
+
}).replace(/(^|[^\\])(\^|_)(\d|[^{]\S*)/g, function($, L, H, P) {
|
|
1852
|
+
return L + H + "{" + P + "}";
|
|
1853
|
+
}).replace(/\\verb,(.*?),/, function($, L) {
|
|
1849
1854
|
return "\\verb,".concat(n[+L], ",");
|
|
1850
1855
|
});
|
|
1851
|
-
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null },
|
|
1856
|
+
for (var o, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, c = [], y = [], w = function($) {
|
|
1852
1857
|
for (var L in i)
|
|
1853
|
-
i[L] && (
|
|
1854
|
-
return
|
|
1858
|
+
i[L] && ($[L] = i[L]);
|
|
1859
|
+
return c.push($), $;
|
|
1855
1860
|
}, x = function() {
|
|
1856
1861
|
y.push(i), i = Object.create(i);
|
|
1857
1862
|
}, b = function() {
|
|
1858
1863
|
if (!y.length)
|
|
1859
1864
|
throw new Error("Unexpected }");
|
|
1860
1865
|
i = y.pop();
|
|
1861
|
-
}, E = { tokens:
|
|
1866
|
+
}, E = { tokens: c, open_context: x, close_context: b, add_token: w }; e.length; ) {
|
|
1862
1867
|
if (o = an.exec(e))
|
|
1863
|
-
|
|
1868
|
+
Nt(o[0], !1).forEach(w);
|
|
1864
1869
|
else if (o = ln.exec(e))
|
|
1865
1870
|
w(new N(o[1]));
|
|
1866
1871
|
else if (!(o = on.exec(e))) {
|
|
@@ -1897,24 +1902,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1897
1902
|
}
|
|
1898
1903
|
e = e.slice(o[0].length);
|
|
1899
1904
|
}
|
|
1900
|
-
return
|
|
1905
|
+
return c;
|
|
1901
1906
|
}, rt.measureText = function(e, n, o) {
|
|
1902
|
-
return
|
|
1903
|
-
}, rt.Token = N, rt.Break =
|
|
1907
|
+
return Y(e, S(n), o);
|
|
1908
|
+
}, rt.Token = N, rt.Break = Tt, rt.LineBreak = nt, rt.SoftHyphen = pt, rt.Rotator = be, be.createElement = Se;
|
|
1904
1909
|
const Sn = rt;
|
|
1905
1910
|
return r.default;
|
|
1906
1911
|
})());
|
|
1907
1912
|
})(Ve);
|
|
1908
1913
|
var Fn = Ve.exports;
|
|
1909
1914
|
const Oe = /* @__PURE__ */ ce(Fn);
|
|
1910
|
-
function
|
|
1911
|
-
const t =
|
|
1915
|
+
function Bn(u, l) {
|
|
1916
|
+
const t = ut(u), { fontSize: r, font: a, padding: h = 0 } = u.properties.style || {};
|
|
1912
1917
|
if (t.width === t.height && t.width === 0)
|
|
1913
1918
|
return;
|
|
1914
1919
|
const p = new Oe({
|
|
1915
1920
|
font: `${r}px/${r}px ${a}`.replace(/(px)+/g, "px"),
|
|
1916
|
-
width: t.width -
|
|
1917
|
-
height: t.height -
|
|
1921
|
+
width: t.width - h * 2,
|
|
1922
|
+
height: t.height - h * 2,
|
|
1918
1923
|
align: "left",
|
|
1919
1924
|
valign: "top",
|
|
1920
1925
|
x: 0,
|
|
@@ -1925,10 +1930,10 @@ function qn(u, l) {
|
|
|
1925
1930
|
u.properties.content.replaceAll(`
|
|
1926
1931
|
`, "<br>")
|
|
1927
1932
|
).render();
|
|
1928
|
-
p.setAttribute("transform", `translate(${
|
|
1933
|
+
p.setAttribute("transform", `translate(${h}, ${h})`), l.appendChild(p);
|
|
1929
1934
|
}
|
|
1930
1935
|
const Me = 20;
|
|
1931
|
-
class
|
|
1936
|
+
class qn extends qe {
|
|
1932
1937
|
constructor(t, r = {}) {
|
|
1933
1938
|
super(
|
|
1934
1939
|
t,
|
|
@@ -1953,7 +1958,7 @@ class Bn extends Be {
|
|
|
1953
1958
|
v(this, "startX", 0);
|
|
1954
1959
|
v(this, "startY", 0);
|
|
1955
1960
|
v(this, "handles", []);
|
|
1956
|
-
v(this, "draggedHandle",
|
|
1961
|
+
v(this, "draggedHandle", q);
|
|
1957
1962
|
v(this, "isFocused", !1);
|
|
1958
1963
|
v(this, "placeholder", "Type your text here...");
|
|
1959
1964
|
v(this, "_onFocus", () => {
|
|
@@ -1964,16 +1969,16 @@ class Bn extends Be {
|
|
|
1964
1969
|
});
|
|
1965
1970
|
v(this, "startDrawing", (t, r, a = jn(t, r, 0, 0, "", At)) => {
|
|
1966
1971
|
this.add(a);
|
|
1967
|
-
const
|
|
1968
|
-
this.select(a.id), this.startDragging(this.getById(a.id),
|
|
1972
|
+
const h = this.ogma.view.graphToScreenCoordinates({ x: t, y: r });
|
|
1973
|
+
this.select(a.id), this.startDragging(this.getById(a.id), h.x, h.y), this.draggedHandle = 6;
|
|
1969
1974
|
});
|
|
1970
1975
|
v(this, "cancelDrawing", () => {
|
|
1971
|
-
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...re }, this.draggedHandle =
|
|
1976
|
+
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...re }, this.draggedHandle = q, this.isDragging = !1, this.emit(St, this.annotation));
|
|
1972
1977
|
});
|
|
1973
1978
|
v(this, "startDragging", (t, r, a) => {
|
|
1974
1979
|
this.annotation = t;
|
|
1975
|
-
const
|
|
1976
|
-
this.rect.x =
|
|
1980
|
+
const h = ct(this.annotation), d = ut(this.annotation);
|
|
1981
|
+
this.rect.x = h.x, this.rect.y = h.y, this.rect.width = d.width, this.rect.height = d.height, this.startX = r, this.startY = a, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Yt, this.annotation), this.isDragging = !0;
|
|
1977
1982
|
});
|
|
1978
1983
|
v(this, "onHandleMouseDown", (t) => {
|
|
1979
1984
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
@@ -1986,19 +1991,19 @@ class Bn extends Be {
|
|
|
1986
1991
|
if (!this.isDragging)
|
|
1987
1992
|
return;
|
|
1988
1993
|
t.stopPropagation(), t.preventDefault();
|
|
1989
|
-
const r = this.handles[this.draggedHandle], a = r.classList.contains("top"),
|
|
1990
|
-
(g &&
|
|
1991
|
-
const S =
|
|
1992
|
-
this.rect.width +
|
|
1994
|
+
const r = this.handles[this.draggedHandle], a = r.classList.contains("top"), h = r.classList.contains("left"), d = r.classList.contains("right"), g = r.classList.contains("bottom"), p = r.classList.contains("line-handle"), s = this.ogma.view.getZoom(), f = (t.clientX - this.startX) / s, m = (t.clientY - this.startY) / s, A = this.ogma.view.getAngle(), T = new U(f, m).rotateRadians(A);
|
|
1995
|
+
(g && h || a && d) && (T.y = 0, T.x = 0);
|
|
1996
|
+
const S = h || p ? this.rect.x + T.x : this.rect.x, C = a || p ? this.rect.y + T.y : this.rect.y, k = Math.max(
|
|
1997
|
+
this.rect.width + f * (p || h ? 0 : 1),
|
|
1993
1998
|
Me
|
|
1994
1999
|
), F = Math.max(
|
|
1995
2000
|
this.rect.height + m * (p || a ? 0 : 1),
|
|
1996
2001
|
Me
|
|
1997
2002
|
);
|
|
1998
|
-
zn(this.annotation, S, C, k, F), this.emit(
|
|
2003
|
+
zn(this.annotation, S, C, k, F), this.emit(Ut, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
|
|
1999
2004
|
});
|
|
2000
2005
|
v(this, "onMouseUp", () => {
|
|
2001
|
-
!this.isDragging || this.draggedHandle ===
|
|
2006
|
+
!this.isDragging || this.draggedHandle === q || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(St, this.annotation), this.isDragging = !1, this.draggedHandle = q);
|
|
2002
2007
|
});
|
|
2003
2008
|
v(this, "onViewChanged", () => {
|
|
2004
2009
|
const t = Math.max(2, this.handleSize / this.ogma.view.getZoom());
|
|
@@ -2013,48 +2018,53 @@ class Bn extends Be {
|
|
|
2013
2018
|
a.addEventListener("input", this._onInput), a.addEventListener("focus", this._onFocus), a.addEventListener("blur", this._onBlur), a.spellcheck = !1, this.handles = Array.prototype.slice.call(
|
|
2014
2019
|
this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
|
|
2015
2020
|
), this.handles.forEach(
|
|
2016
|
-
(
|
|
2021
|
+
(h) => h.addEventListener("mousedown", this.onHandleMouseDown)
|
|
2017
2022
|
), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), t.events.on(["viewChanged", "zoom"], this.onViewChanged);
|
|
2018
2023
|
}
|
|
2019
2024
|
_canRemove() {
|
|
2020
2025
|
return !this.isFocused;
|
|
2021
2026
|
}
|
|
2022
2027
|
detect({ x: t, y: r }, a = 0) {
|
|
2023
|
-
const
|
|
2028
|
+
const h = new U(t, r), d = this.ogma.view.getAngle();
|
|
2024
2029
|
return this.elements.find((g) => {
|
|
2025
|
-
const { x: p, y: s } =
|
|
2026
|
-
return T > -a && T <
|
|
2030
|
+
const { x: p, y: s } = ct(g), { width: f, height: m } = ut(g), A = new U(p, s), { x: T, y: S } = h.sub(A).rotateRadians(-d);
|
|
2031
|
+
return T > -a && T < f + a && S > -a && S < m + a;
|
|
2027
2032
|
});
|
|
2028
2033
|
}
|
|
2029
2034
|
draw(t) {
|
|
2030
2035
|
t.innerHTML = "";
|
|
2031
|
-
const r = "", a = this.ogma.view.getAngle()
|
|
2032
|
-
this.elements.forEach((
|
|
2033
|
-
const p = `class${g}`, s =
|
|
2036
|
+
const r = "", a = this.ogma.view.getAngle();
|
|
2037
|
+
this.elements.forEach((d, g) => {
|
|
2038
|
+
const p = `class${g}`, s = ut(d), f = ct(d), m = d.id, {
|
|
2034
2039
|
color: A,
|
|
2035
2040
|
fontSize: T,
|
|
2036
2041
|
font: S,
|
|
2037
2042
|
strokeColor: C,
|
|
2038
2043
|
strokeWidth: k,
|
|
2039
2044
|
strokeType: F,
|
|
2040
|
-
background:
|
|
2041
|
-
} =
|
|
2045
|
+
background: X
|
|
2046
|
+
} = d.properties.style || At;
|
|
2042
2047
|
if (m === this.selectedId)
|
|
2043
2048
|
return;
|
|
2044
|
-
const D =
|
|
2049
|
+
const D = Mt("g");
|
|
2045
2050
|
D.classList.add("annotation-text"), D.setAttribute("fill", `${A}`), D.setAttribute("font-size", `${T}px`), D.setAttribute("font-family", `${S}`);
|
|
2046
|
-
const
|
|
2047
|
-
let
|
|
2048
|
-
F && F !== "none" && (
|
|
2051
|
+
const Y = Mt("rect");
|
|
2052
|
+
let G = !1;
|
|
2053
|
+
F && F !== "none" && (G = !0, Y.setAttribute("stroke", C || "black"), Y.setAttribute("stroke-width", `${k}`), F === "dashed" && Y.setAttribute("stroke-dasharray", "5,5")), (X && X.length || G) && (G = !0, Y.setAttribute("fill", X || "transparent")), G && (Y.setAttribute("width", `${s.width}`), Y.setAttribute("height", `${s.height}`)), D.appendChild(Y), Bn(d, D);
|
|
2054
|
+
const { x: Et, y: kt } = new U(f.x, f.y).rotateRadians(-a);
|
|
2055
|
+
D.setAttribute("transform", `translate(${Et},${kt})`), D.classList.add(p), D.setAttribute("data-annotation", `${d.id}`), D.setAttribute("data-annotation-type", "text"), t.appendChild(D);
|
|
2049
2056
|
});
|
|
2050
|
-
const
|
|
2051
|
-
|
|
2057
|
+
const h = Mt("style");
|
|
2058
|
+
h.innerHTML = r, t.firstChild && t.insertBefore(h, t.firstChild);
|
|
2052
2059
|
}
|
|
2053
2060
|
refreshDrawing() {
|
|
2054
|
-
const t = this.ogma.view.getAngle()
|
|
2061
|
+
const t = this.ogma.view.getAngle();
|
|
2055
2062
|
[...this.layer.element.children].forEach((r) => {
|
|
2056
|
-
const a = r.getAttribute("
|
|
2057
|
-
|
|
2063
|
+
const a = r.getAttribute("data-annotation");
|
|
2064
|
+
if (!a)
|
|
2065
|
+
return;
|
|
2066
|
+
const h = ct(this.getById(a)), { x: d, y: g } = new U(h.x, h.y).rotateRadians(-t);
|
|
2067
|
+
r.setAttribute("transform", `translate(${d},${g})`);
|
|
2058
2068
|
});
|
|
2059
2069
|
}
|
|
2060
2070
|
getDefaultOptions() {
|
|
@@ -2063,14 +2073,14 @@ class Bn extends Be {
|
|
|
2063
2073
|
refreshEditor() {
|
|
2064
2074
|
if (+this.selectedId < 0 && +this.hoveredId < 0)
|
|
2065
2075
|
return;
|
|
2066
|
-
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r =
|
|
2067
|
-
font:
|
|
2076
|
+
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = ut(t), a = this.ogma.view.graphToScreenCoordinates(ct(t)), h = this.ogma.view.getZoom(), {
|
|
2077
|
+
font: d,
|
|
2068
2078
|
fontSize: g,
|
|
2069
2079
|
color: p,
|
|
2070
2080
|
background: s,
|
|
2071
|
-
padding:
|
|
2072
|
-
} = t.properties.style || At, m = (g || 1) *
|
|
2073
|
-
this.textArea.value = t.properties.content, this.editor.element.style.transform = `translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width / 2 *
|
|
2081
|
+
padding: f = 0
|
|
2082
|
+
} = t.properties.style || At, m = (g || 1) * h;
|
|
2083
|
+
this.textArea.value = t.properties.content, this.editor.element.style.transform = `translate(${a.x}px, ${a.y}px)translate(-50%, -50%)translate(${r.width / 2 * h}px, ${r.height / 2 * h}px)`, this.editor.element.style.width = `${r.width * h}px`, this.editor.element.style.height = `${r.height * h}px`, this.textArea.style.font = `${m} ${d}`, this.textArea.style.fontFamily = d || "sans-serif", this.textArea.style.fontSize = `${m}px`, this.textArea.style.padding = `${h * f}px`, this.textArea.style.lineHeight = `${m}px`, this.textArea.style.boxSizing = "border-box", this.textArea.style.color = p || "black", this.textArea.style.background = s || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
2074
2084
|
}
|
|
2075
2085
|
select(t) {
|
|
2076
2086
|
super.select(t), this.textArea.focus();
|
|
@@ -2085,20 +2095,20 @@ class Vn {
|
|
|
2085
2095
|
v(this, "linksByTargetId", {});
|
|
2086
2096
|
v(this, "linksByArrowId", {});
|
|
2087
2097
|
}
|
|
2088
|
-
add(l, t, r, a,
|
|
2089
|
-
const
|
|
2090
|
-
id:
|
|
2098
|
+
add(l, t, r, a, h) {
|
|
2099
|
+
const d = Xt(), g = l.id, p = {
|
|
2100
|
+
id: d,
|
|
2091
2101
|
arrow: g,
|
|
2092
2102
|
target: r,
|
|
2093
2103
|
targetType: a,
|
|
2094
|
-
connectionPoint:
|
|
2104
|
+
connectionPoint: h,
|
|
2095
2105
|
side: t
|
|
2096
2106
|
};
|
|
2097
|
-
return this.links[
|
|
2107
|
+
return this.links[d] = p, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(d), this.linksByArrowId[g] || (this.linksByArrowId[g] = {}), this.linksByArrowId[g][t] = d, l.properties.link = l.properties.link || {}, l.properties.link[t] = {
|
|
2098
2108
|
id: r,
|
|
2099
2109
|
side: t,
|
|
2100
2110
|
type: a,
|
|
2101
|
-
magnet:
|
|
2111
|
+
magnet: h
|
|
2102
2112
|
}, this;
|
|
2103
2113
|
}
|
|
2104
2114
|
arrowIsLinked(l, t) {
|
|
@@ -2111,12 +2121,12 @@ class Vn {
|
|
|
2111
2121
|
const r = l.id, a = (g = this.linksByArrowId[r]) == null ? void 0 : g[t];
|
|
2112
2122
|
if ((p = l.properties.link) == null || delete p[t], !a)
|
|
2113
2123
|
return this;
|
|
2114
|
-
const
|
|
2124
|
+
const h = this.links[a];
|
|
2115
2125
|
delete this.links[a];
|
|
2116
|
-
const
|
|
2117
|
-
for (let s = 0; s <
|
|
2118
|
-
if (
|
|
2119
|
-
|
|
2126
|
+
const d = this.linksByTargetId[h.target];
|
|
2127
|
+
for (let s = 0; s < d.length; s++)
|
|
2128
|
+
if (d[s] === a) {
|
|
2129
|
+
d.splice(s, 1);
|
|
2120
2130
|
break;
|
|
2121
2131
|
}
|
|
2122
2132
|
return delete this.linksByArrowId[r][t], this;
|
|
@@ -2154,7 +2164,7 @@ const ot = (u) => u.properties.type === "arrow", mt = (u) => u.properties.type =
|
|
|
2154
2164
|
{ x: 0.5, y: 1 },
|
|
2155
2165
|
{ x: 1, y: 1 }
|
|
2156
2166
|
];
|
|
2157
|
-
class Gn extends
|
|
2167
|
+
class Gn extends Be {
|
|
2158
2168
|
constructor(t, r = {}) {
|
|
2159
2169
|
super();
|
|
2160
2170
|
v(this, "arrows");
|
|
@@ -2178,29 +2188,29 @@ class Gn extends qe {
|
|
|
2178
2188
|
Ce.forEach((a) => {
|
|
2179
2189
|
if (!this.textToMagnet)
|
|
2180
2190
|
return;
|
|
2181
|
-
const
|
|
2191
|
+
const h = ut(this.textToMagnet), d = ct(this.textToMagnet), { x: g, y: p } = new U(a.x, a.y).mul({ x: h.width, y: h.height }).rotateRadians(this.ogma.view.getAngle()).add(d);
|
|
2182
2192
|
t.moveTo(g, p), t.arc(g, p, this.options.magnetHandleRadius / r, 0, Math.PI * 2);
|
|
2183
2193
|
}), t.fill(), t.closePath();
|
|
2184
2194
|
});
|
|
2185
2195
|
v(this, "_onFeatureDrag", (t, r) => {
|
|
2186
2196
|
const a = r;
|
|
2187
2197
|
if (ot(t) && a === "line")
|
|
2188
|
-
["start", "end"].find((
|
|
2189
|
-
const
|
|
2190
|
-
return this._snapToText(t, a,
|
|
2198
|
+
["start", "end"].find((h) => {
|
|
2199
|
+
const d = h === "start" ? zt(t) : qt(t);
|
|
2200
|
+
return this._snapToText(t, a, d) || this._findAndSnapToNode(t, h, d);
|
|
2191
2201
|
});
|
|
2192
2202
|
else if (ot(t) && a !== "line") {
|
|
2193
|
-
const
|
|
2194
|
-
this._snapToText(t, a,
|
|
2203
|
+
const h = a === "start" ? zt(t) : qt(t);
|
|
2204
|
+
this._snapToText(t, a, h) || this._findAndSnapToNode(t, a, h);
|
|
2195
2205
|
} else
|
|
2196
|
-
mt(t) && (this.activeLinks.forEach(({ arrow:
|
|
2197
|
-
const p = this.getAnnotation(
|
|
2198
|
-
p.geometry.coordinates[
|
|
2206
|
+
mt(t) && (this.activeLinks.forEach(({ arrow: h, side: d, connectionPoint: g }) => {
|
|
2207
|
+
const p = this.getAnnotation(h), s = ut(t), f = ct(t), m = new U(g.x, g.y).mul({ x: s.width, y: s.height }).rotateRadians(this.ogma.view.getAngle()).add(f);
|
|
2208
|
+
p.geometry.coordinates[d === "start" ? 0 : 1] = [m.x, m.y];
|
|
2199
2209
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
2200
|
-
this.layer.refresh(), this.emit(
|
|
2210
|
+
this.layer.refresh(), this.emit(Ut, t, r);
|
|
2201
2211
|
});
|
|
2202
2212
|
v(this, "_onFeatureDragEnd", (t) => {
|
|
2203
|
-
this.dragged !== null && ot(t) &&
|
|
2213
|
+
this.dragged !== null && ot(t) && zt(this.dragged) && Le.forEach((r) => {
|
|
2204
2214
|
this.links.getArrowLink(t.id, r) && this.emit(Nn, {
|
|
2205
2215
|
arrow: t,
|
|
2206
2216
|
link: this.links.getArrowLink(t.id, r)
|
|
@@ -2211,7 +2221,7 @@ class Gn extends qe {
|
|
|
2211
2221
|
this.textToMagnet = void 0, ot(t) ? this.dragged = t : mt(t) && this.activeLinks.push(...this.links.getTargetLinks(t.id, "text")), this.annotations.forEach((r) => {
|
|
2212
2222
|
const a = r.getSelectedFeature();
|
|
2213
2223
|
a && a !== t && r.unhover().unselect(), r.disableDetection();
|
|
2214
|
-
}), this.emit(
|
|
2224
|
+
}), this.emit(Yt, t);
|
|
2215
2225
|
});
|
|
2216
2226
|
v(this, "_onNodesDragStart", () => {
|
|
2217
2227
|
this.arrows.unhover().unselect(), this.texts.unhover().unselect();
|
|
@@ -2222,11 +2232,11 @@ class Gn extends qe {
|
|
|
2222
2232
|
});
|
|
2223
2233
|
v(this, "_onLayoutEnd", (t) => {
|
|
2224
2234
|
t.ids.forEach((r, a) => {
|
|
2225
|
-
this.links.getTargetLinks(r, "node").forEach((
|
|
2226
|
-
const g = this.getAnnotation(
|
|
2235
|
+
this.links.getTargetLinks(r, "node").forEach((d) => {
|
|
2236
|
+
const g = this.getAnnotation(d.arrow), p = d.side, s = jt(
|
|
2227
2237
|
g,
|
|
2228
2238
|
p === "start" ? "end" : "start"
|
|
2229
|
-
),
|
|
2239
|
+
), f = t.positions.current[a], m = this.ogma.getNode(r).getAttribute("radius"), A = Ft(s, f, +m);
|
|
2230
2240
|
bt(g, p, A.x, A.y);
|
|
2231
2241
|
});
|
|
2232
2242
|
}), this.arrows.refreshLayer(), this.texts.refreshLayer();
|
|
@@ -2255,56 +2265,56 @@ class Gn extends qe {
|
|
|
2255
2265
|
v(this, "_onUpdate", (t) => {
|
|
2256
2266
|
this.emit(he, t);
|
|
2257
2267
|
});
|
|
2258
|
-
this.options = this.setOptions({ ...Un, ...r }), this.ogma = t, this.arrows = new Hn(t, this.options), this.texts = new
|
|
2259
|
-
a.on(
|
|
2268
|
+
this.options = this.setOptions({ ...Un, ...r }), this.ogma = t, this.arrows = new Hn(t, this.options), this.texts = new qn(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((a) => {
|
|
2269
|
+
a.on(Yt, this._onFeatureDragStart).on(Ut, this._onFeatureDrag).on(St, this._onFeatureDragEnd).on(he, this.onUpdate).on(oe, this._onUnselect).on(se, this._onSelect).on(le, this._onAdded).on(ae, this._onRemoved);
|
|
2260
2270
|
}), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd).on(["viewChanged", "rotate"], () => {
|
|
2261
2271
|
this.refreshTextLinks();
|
|
2262
2272
|
}), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
2263
2273
|
}
|
|
2264
2274
|
_moveNodes(t, r, a) {
|
|
2265
|
-
t.forEach((
|
|
2266
|
-
const
|
|
2267
|
-
|
|
2268
|
-
const s = this.getAnnotation(p.arrow),
|
|
2275
|
+
t.forEach((h) => {
|
|
2276
|
+
const d = this.links.getTargetLinks(h.getId(), "node"), g = h.getPosition();
|
|
2277
|
+
d.forEach((p) => {
|
|
2278
|
+
const s = this.getAnnotation(p.arrow), f = p.side, m = jt(
|
|
2269
2279
|
s,
|
|
2270
|
-
|
|
2280
|
+
f === "start" ? "end" : "start"
|
|
2271
2281
|
);
|
|
2272
2282
|
let A = g;
|
|
2273
|
-
const T = +
|
|
2274
|
-
(p.connectionPoint.x - (g.x - r) > S || p.connectionPoint.y - (g.y - a) > S) && (A =
|
|
2283
|
+
const T = +h.getAttribute("radius"), S = 1e-6;
|
|
2284
|
+
(p.connectionPoint.x - (g.x - r) > S || p.connectionPoint.y - (g.y - a) > S) && (A = Ft(m, g, T)), bt(s, f, A.x, A.y);
|
|
2275
2285
|
});
|
|
2276
2286
|
}), this.arrows.refreshLayer();
|
|
2277
2287
|
}
|
|
2278
2288
|
_snapToText(t, r, a) {
|
|
2279
|
-
const
|
|
2280
|
-
if (this.links.remove(t, r), !
|
|
2289
|
+
const h = this.texts.detect(a, this.options.detectMargin);
|
|
2290
|
+
if (this.links.remove(t, r), !h)
|
|
2281
2291
|
return !1;
|
|
2282
|
-
this.textToMagnet =
|
|
2283
|
-
const
|
|
2284
|
-
return
|
|
2292
|
+
this.textToMagnet = h;
|
|
2293
|
+
const d = this.findMagnetPoint(Ce, h, a);
|
|
2294
|
+
return d ? (bt(t, r, d.point.x, d.point.y), this.links.add(t, r, h.id, "text", d.magnet), !0) : !1;
|
|
2285
2295
|
}
|
|
2286
2296
|
_findAndSnapToNode(t, r, a) {
|
|
2287
|
-
const
|
|
2288
|
-
this.links.remove(t, r),
|
|
2297
|
+
const h = this.ogma.view.graphToScreenCoordinates(a), d = this.ogma.view.getElementAt(h);
|
|
2298
|
+
this.links.remove(t, r), d && d.isNode ? (this.hoveredNode = d, this.hoveredNode.setSelected(!0), this._snapToNode(t, r, d, h)) : (this.hoveredNode && this.hoveredNode.setSelected(!1), this.hoveredNode = null);
|
|
2289
2299
|
}
|
|
2290
|
-
_snapToNode(t, r, a,
|
|
2291
|
-
const
|
|
2300
|
+
_snapToNode(t, r, a, h) {
|
|
2301
|
+
const d = a.getPositionOnScreen(), g = +a.getAttribute("radius"), p = g * this.ogma.view.getZoom(), s = h.x - d.x, f = h.y - d.y, m = Math.sqrt(s * s + f * f), A = a.getPosition();
|
|
2292
2302
|
if (m < p + this.options.detectMargin) {
|
|
2293
2303
|
let T = A;
|
|
2294
2304
|
if (m > p / 2) {
|
|
2295
|
-
const S =
|
|
2296
|
-
T =
|
|
2305
|
+
const S = jt(t, r === "end" ? "start" : "end");
|
|
2306
|
+
T = Ft(S, T, g);
|
|
2297
2307
|
}
|
|
2298
2308
|
bt(t, r, T.x, T.y), this.links.add(t, r, a.getId(), "node", T);
|
|
2299
2309
|
}
|
|
2300
2310
|
}
|
|
2301
2311
|
refreshTextLinks() {
|
|
2302
2312
|
let t = !1;
|
|
2303
|
-
this.links.forEach(({ connectionPoint: r, targetType: a, target:
|
|
2313
|
+
this.links.forEach(({ connectionPoint: r, targetType: a, target: h, arrow: d, side: g }) => {
|
|
2304
2314
|
if (a !== "text")
|
|
2305
2315
|
return;
|
|
2306
2316
|
t = !0;
|
|
2307
|
-
const p = this.getAnnotation(
|
|
2317
|
+
const p = this.getAnnotation(h), s = this.getAnnotation(d), f = ut(p), m = ct(p), A = new U(r.x, r.y).mul({ x: f.width, y: f.height }).rotateRadians(this.ogma.view.getAngle()).add(m);
|
|
2308
2318
|
bt(s, g, A.x, A.y);
|
|
2309
2319
|
}), t && this.arrows.refreshLayer();
|
|
2310
2320
|
}
|
|
@@ -2315,23 +2325,23 @@ class Gn extends qe {
|
|
|
2315
2325
|
return this.selected;
|
|
2316
2326
|
}
|
|
2317
2327
|
findMagnetPoint(t, r, a) {
|
|
2318
|
-
let
|
|
2319
|
-
for (const
|
|
2320
|
-
const g =
|
|
2328
|
+
let h;
|
|
2329
|
+
for (const d of t) {
|
|
2330
|
+
const g = ut(r), p = ct(r), s = new U(d.x, d.y).mul({ x: g.width, y: g.height }).rotateRadians(this.ogma.view.getAngle()).add(p), f = s.sub(a).length(), m = Math.min(
|
|
2321
2331
|
this.options.magnetRadius * this.ogma.view.getZoom(),
|
|
2322
2332
|
// when really zoomed in: avoid to snap on too far away magnets
|
|
2323
2333
|
g.width / 2,
|
|
2324
2334
|
g.height / 2
|
|
2325
2335
|
);
|
|
2326
|
-
if (
|
|
2327
|
-
|
|
2336
|
+
if (f < Math.max(m, this.options.magnetHandleRadius)) {
|
|
2337
|
+
h = {
|
|
2328
2338
|
point: s,
|
|
2329
|
-
magnet:
|
|
2339
|
+
magnet: d
|
|
2330
2340
|
};
|
|
2331
2341
|
break;
|
|
2332
2342
|
}
|
|
2333
2343
|
}
|
|
2334
|
-
return
|
|
2344
|
+
return h;
|
|
2335
2345
|
}
|
|
2336
2346
|
/**
|
|
2337
2347
|
* Set the options for the controller
|
|
@@ -2364,11 +2374,11 @@ class Gn extends qe {
|
|
|
2364
2374
|
*/
|
|
2365
2375
|
add(t) {
|
|
2366
2376
|
if (ze(t)) {
|
|
2367
|
-
const [r, a] = t.features.reduce((
|
|
2377
|
+
const [r, a] = t.features.reduce((h, d) => (ot(d) ? h[1].push(d) : mt(d) && h[0].push(d), h), [[], []]);
|
|
2368
2378
|
return r.forEach(
|
|
2369
|
-
(
|
|
2379
|
+
(h) => this.add(h)
|
|
2370
2380
|
), a.forEach(
|
|
2371
|
-
(
|
|
2381
|
+
(h) => this.add(h)
|
|
2372
2382
|
), this.arrows.refreshLayer(), this;
|
|
2373
2383
|
}
|
|
2374
2384
|
switch (t.properties.type) {
|
|
@@ -2396,16 +2406,16 @@ class Gn extends qe {
|
|
|
2396
2406
|
const a = t.properties.link[r];
|
|
2397
2407
|
if (!a)
|
|
2398
2408
|
continue;
|
|
2399
|
-
const
|
|
2400
|
-
if (a.type === "text" &&
|
|
2409
|
+
const h = this.getAnnotation(a.id);
|
|
2410
|
+
if (a.type === "text" && h)
|
|
2401
2411
|
this.links.add(t, r, a.id, a.type, a.magnet);
|
|
2402
2412
|
else if (a.type === "node") {
|
|
2403
|
-
const
|
|
2404
|
-
if (!
|
|
2413
|
+
const d = this.ogma.getNode(a.id);
|
|
2414
|
+
if (!d)
|
|
2405
2415
|
continue;
|
|
2406
2416
|
this.links.add(t, r, a.id, a.type, a.magnet);
|
|
2407
|
-
const g =
|
|
2408
|
-
bt(t, r,
|
|
2417
|
+
const g = d.getPosition(), p = d.getAttribute("radius") || 0, s = jt(t, r === "start" ? "end" : "start"), f = Ft(s, g, +p);
|
|
2418
|
+
bt(t, r, f.x, f.y);
|
|
2409
2419
|
}
|
|
2410
2420
|
}
|
|
2411
2421
|
}
|
|
@@ -2431,7 +2441,7 @@ class Gn extends qe {
|
|
|
2431
2441
|
* Cancel drawing on the current frame
|
|
2432
2442
|
*/
|
|
2433
2443
|
cancelDrawing() {
|
|
2434
|
-
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(
|
|
2444
|
+
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(Pn);
|
|
2435
2445
|
}
|
|
2436
2446
|
/**
|
|
2437
2447
|
* Update the style of the annotation with the given id
|
|
@@ -2439,7 +2449,7 @@ class Gn extends qe {
|
|
|
2439
2449
|
* @param style The new style
|
|
2440
2450
|
*/
|
|
2441
2451
|
updateStyle(t, r) {
|
|
2442
|
-
const a = this.getAnnotations().features.find((
|
|
2452
|
+
const a = this.getAnnotations().features.find((h) => h.id === t);
|
|
2443
2453
|
return a ? (ot(a) ? this.arrows.updateStyle(a, r) : mt(a) && this.texts.updateStyle(a, r), this.onUpdate(a), this) : this;
|
|
2444
2454
|
}
|
|
2445
2455
|
/**
|
|
@@ -2473,25 +2483,25 @@ class Gn extends qe {
|
|
|
2473
2483
|
export {
|
|
2474
2484
|
Hn as Arrows,
|
|
2475
2485
|
Gn as Control,
|
|
2476
|
-
|
|
2486
|
+
qn as Texts,
|
|
2477
2487
|
Dn as createArrow,
|
|
2478
|
-
|
|
2488
|
+
Mt as createSVGElement,
|
|
2479
2489
|
jn as createText,
|
|
2480
2490
|
Ee as defaultArrowOptions,
|
|
2481
|
-
|
|
2491
|
+
Lt as defaultArrowStyle,
|
|
2482
2492
|
De as defaultControllerOptions,
|
|
2483
2493
|
re as defaultTextOptions,
|
|
2484
2494
|
At as defaultTextStyle,
|
|
2485
2495
|
Xn as getAnnotationsBounds,
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2496
|
+
qt as getArrowEnd,
|
|
2497
|
+
Vt as getArrowEndPoints,
|
|
2498
|
+
jt as getArrowSide,
|
|
2499
|
+
zt as getArrowStart,
|
|
2500
|
+
Ft as getAttachmentPointOnNode,
|
|
2491
2501
|
He as getHandleId,
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2502
|
+
Pe as getTextBbox,
|
|
2503
|
+
ct as getTextPosition,
|
|
2504
|
+
ut as getTextSize,
|
|
2495
2505
|
ze as isAnnotationCollection,
|
|
2496
2506
|
ot as isArrow,
|
|
2497
2507
|
mt as isText,
|
|
@@ -2501,4 +2511,3 @@ export {
|
|
|
2501
2511
|
zn as setTextBbox,
|
|
2502
2512
|
Mn as updateTextBbox
|
|
2503
2513
|
};
|
|
2504
|
-
//# sourceMappingURL=index.mjs.map
|