@linkurious/ogma-annotations 1.1.22 → 1.1.23
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.js +11 -11
- package/dist/index.mjs +511 -506
- package/dist/types/index.d.ts +12 -2
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Fn = Object.defineProperty;
|
|
2
|
-
var Rn = (a,
|
|
3
|
-
var m = (a,
|
|
4
|
-
let Qt = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((
|
|
2
|
+
var Rn = (a, h, t) => h in a ? Fn(a, h, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[h] = t;
|
|
3
|
+
var m = (a, h, t) => Rn(a, typeof h != "symbol" ? h + "" : h, t);
|
|
4
|
+
let Qt = (a = 21) => crypto.getRandomValues(new Uint8Array(a)).reduce((h, t) => (t &= 63, t < 36 ? h += t.toString(36) : t < 62 ? h += (t - 26).toString(36).toUpperCase() : t > 62 ? h += "-" : h += "_", h), "");
|
|
5
5
|
const Nt = {
|
|
6
6
|
strokeType: "plain",
|
|
7
7
|
strokeColor: "#202020",
|
|
@@ -34,20 +34,20 @@ const Nt = {
|
|
|
34
34
|
// tail: 'arrow-plain',
|
|
35
35
|
// start: { x: 0, y: 0 },
|
|
36
36
|
// end: { x: 100, y: 100 }
|
|
37
|
-
}, qn = (a = 0,
|
|
37
|
+
}, qn = (a = 0, h = 0, t = 0, r = 0, o = { ...Nt }) => ({
|
|
38
38
|
id: Qt(),
|
|
39
39
|
type: "Feature",
|
|
40
40
|
properties: {
|
|
41
41
|
type: "arrow",
|
|
42
42
|
style: {
|
|
43
43
|
...Nt,
|
|
44
|
-
...
|
|
44
|
+
...o
|
|
45
45
|
}
|
|
46
46
|
},
|
|
47
47
|
geometry: {
|
|
48
48
|
type: "LineString",
|
|
49
49
|
coordinates: [
|
|
50
|
-
[a,
|
|
50
|
+
[a, h],
|
|
51
51
|
[t, r]
|
|
52
52
|
]
|
|
53
53
|
}
|
|
@@ -59,59 +59,59 @@ function Ge(a) {
|
|
|
59
59
|
return a.geometry.bbox || jn(a), a.geometry.bbox;
|
|
60
60
|
}
|
|
61
61
|
function ut(a) {
|
|
62
|
-
const
|
|
62
|
+
const h = Ge(a);
|
|
63
63
|
return {
|
|
64
|
-
width:
|
|
65
|
-
height:
|
|
64
|
+
width: h[2] - h[0],
|
|
65
|
+
height: h[3] - h[1]
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
function ct(a) {
|
|
69
|
-
const
|
|
70
|
-
return { x:
|
|
69
|
+
const h = Ge(a);
|
|
70
|
+
return { x: h[0], y: h[1] };
|
|
71
71
|
}
|
|
72
72
|
function jn(a) {
|
|
73
|
-
const [
|
|
74
|
-
a.geometry.bbox = [
|
|
73
|
+
const [h, t] = a.geometry.coordinates[0][0], [r, o] = a.geometry.coordinates[0][2];
|
|
74
|
+
a.geometry.bbox = [h, t, r, o];
|
|
75
75
|
}
|
|
76
|
-
function Vn(a,
|
|
77
|
-
a.geometry.bbox = [
|
|
76
|
+
function Vn(a, h, t, r, o) {
|
|
77
|
+
a.geometry.bbox = [h, t, h + r, t + o], a.geometry.coordinates = [
|
|
78
78
|
[
|
|
79
|
-
[
|
|
80
|
-
[
|
|
81
|
-
[
|
|
82
|
-
[
|
|
83
|
-
[
|
|
79
|
+
[h, t],
|
|
80
|
+
[h + r, t],
|
|
81
|
+
[h + r, t + o],
|
|
82
|
+
[h, t + o],
|
|
83
|
+
[h, t]
|
|
84
84
|
]
|
|
85
85
|
];
|
|
86
86
|
}
|
|
87
87
|
function zt(a) {
|
|
88
|
-
const [
|
|
89
|
-
return { x:
|
|
88
|
+
const [h, t] = a.geometry.coordinates[0];
|
|
89
|
+
return { x: h, y: t };
|
|
90
90
|
}
|
|
91
|
-
function Vt(a,
|
|
92
|
-
const [t, r] = a.geometry.coordinates[
|
|
91
|
+
function Vt(a, h) {
|
|
92
|
+
const [t, r] = a.geometry.coordinates[h === "start" ? 0 : 1];
|
|
93
93
|
return { x: t, y: r };
|
|
94
94
|
}
|
|
95
95
|
function Xt(a) {
|
|
96
|
-
const [
|
|
97
|
-
return { x:
|
|
96
|
+
const [h, t] = a.geometry.coordinates[1];
|
|
97
|
+
return { x: h, y: t };
|
|
98
98
|
}
|
|
99
|
-
function Ye(a,
|
|
100
|
-
a.geometry.coordinates[0] = [
|
|
99
|
+
function Ye(a, h, t) {
|
|
100
|
+
a.geometry.coordinates[0] = [h, t];
|
|
101
101
|
}
|
|
102
|
-
function Xe(a,
|
|
103
|
-
a.geometry.coordinates[1] = [
|
|
102
|
+
function Xe(a, h, t) {
|
|
103
|
+
a.geometry.coordinates[1] = [h, t];
|
|
104
104
|
}
|
|
105
105
|
function Zt(a) {
|
|
106
106
|
return { start: zt(a), end: Xt(a) };
|
|
107
107
|
}
|
|
108
|
-
function kt(a,
|
|
109
|
-
|
|
108
|
+
function kt(a, h, t, r) {
|
|
109
|
+
h === "start" ? Ye(a, t, r) : Xe(a, t, r);
|
|
110
110
|
}
|
|
111
111
|
const Ze = (a) => parseInt(a.getAttribute("data-handle-id") || "-1");
|
|
112
|
-
function
|
|
112
|
+
function yr(a) {
|
|
113
113
|
return Gt(a).reduce(
|
|
114
|
-
(
|
|
114
|
+
(h, t) => (h[0] = Math.min(t[0], h[0]), h[1] = Math.min(t[1], h[1]), h[2] = Math.max(t[0], h[2]), h[3] = Math.max(t[1], h[3]), h),
|
|
115
115
|
[
|
|
116
116
|
Number.POSITIVE_INFINITY,
|
|
117
117
|
Number.POSITIVE_INFINITY,
|
|
@@ -123,146 +123,152 @@ function mr(a) {
|
|
|
123
123
|
function Un(a) {
|
|
124
124
|
return Array.isArray(a) && a.length === 2 && a.every(isFinite);
|
|
125
125
|
}
|
|
126
|
-
function Wn(a,
|
|
127
|
-
for (let
|
|
128
|
-
const
|
|
129
|
-
if (Un(
|
|
130
|
-
|
|
126
|
+
function Wn(a, h, t, r) {
|
|
127
|
+
for (let o = 0; o < a.coordinates.length; o++) {
|
|
128
|
+
const l = a.coordinates[o];
|
|
129
|
+
if (Un(l))
|
|
130
|
+
l[0] = t + (l[0] - t) * h, l[1] = r + (l[1] - r) * h;
|
|
131
131
|
else
|
|
132
|
-
for (let u = 0; u <
|
|
133
|
-
const d =
|
|
134
|
-
d[0] = t + (d[0] - t) *
|
|
132
|
+
for (let u = 0; u < l.length; u++) {
|
|
133
|
+
const d = l[u];
|
|
134
|
+
d[0] = t + (d[0] - t) * h, d[1] = r + (d[1] - r) * h;
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
return a;
|
|
138
138
|
}
|
|
139
139
|
function Gt(a) {
|
|
140
|
-
let
|
|
141
|
-
return a.type == "Point" ?
|
|
140
|
+
let h = [];
|
|
141
|
+
return a.type == "Point" ? h = [a.coordinates] : a.type == "LineString" || a.type == "MultiPoint" ? h = a.coordinates : a.type == "Polygon" || a.type == "MultiLineString" ? h = a.coordinates.reduce(function(t, r) {
|
|
142
142
|
return t.concat(r);
|
|
143
|
-
}, []) : a.type == "MultiPolygon" ?
|
|
144
|
-
(t, r) => t.concat(r.reduce((
|
|
143
|
+
}, []) : a.type == "MultiPolygon" ? h = a.coordinates.reduce(
|
|
144
|
+
(t, r) => t.concat(r.reduce((o, l) => o.concat(l), [])),
|
|
145
145
|
[]
|
|
146
|
-
) : a.type == "Feature" ?
|
|
146
|
+
) : a.type == "Feature" ? h = Gt(a.geometry) : a.type == "GeometryCollection" ? h = a.geometries.reduce(
|
|
147
147
|
(t, r) => t.concat(Gt(r)),
|
|
148
148
|
[]
|
|
149
|
-
) : a.type == "FeatureCollection" && (
|
|
149
|
+
) : a.type == "FeatureCollection" && (h = a.features.reduce(
|
|
150
150
|
(t, r) => t.concat(Gt(r)),
|
|
151
151
|
[]
|
|
152
|
-
)),
|
|
152
|
+
)), h;
|
|
153
153
|
}
|
|
154
|
-
function Ut(a,
|
|
155
|
-
const r = Math.atan2(a.y -
|
|
154
|
+
function Ut(a, h, t) {
|
|
155
|
+
const r = Math.atan2(a.y - h.y, a.x - h.x);
|
|
156
156
|
return {
|
|
157
|
-
x:
|
|
158
|
-
y:
|
|
157
|
+
x: h.x + t * Math.cos(r),
|
|
158
|
+
y: h.y + t * Math.sin(r)
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
|
-
function fe(a,
|
|
162
|
-
if (!
|
|
163
|
-
const t =
|
|
161
|
+
function fe(a, h) {
|
|
162
|
+
if (!h) return { x: a.clientX, y: a.clientY };
|
|
163
|
+
const t = h.getBoundingClientRect();
|
|
164
164
|
return {
|
|
165
|
-
x: a.clientX - t.left -
|
|
166
|
-
y: a.clientY - t.top -
|
|
165
|
+
x: a.clientX - t.left - h.clientLeft,
|
|
166
|
+
y: a.clientY - t.top - h.clientTop
|
|
167
167
|
};
|
|
168
168
|
}
|
|
169
|
-
function
|
|
170
|
-
return a.startsWith("#") ?
|
|
169
|
+
function mr(a, h) {
|
|
170
|
+
return a.startsWith("#") ? Yn(a, h) : a.startsWith("rgb") ? Xn(a, h) : a;
|
|
171
171
|
}
|
|
172
|
-
function
|
|
173
|
-
return a.length === 4 ? a.split("").map((
|
|
172
|
+
function Gn(a) {
|
|
173
|
+
return a.length === 4 ? a.split("").map((h) => h + h).join("") : a;
|
|
174
174
|
}
|
|
175
|
-
function
|
|
176
|
-
const [t, r,
|
|
177
|
-
return `rgba(${t}, ${r}, ${
|
|
175
|
+
function Yn(a, h) {
|
|
176
|
+
const [t, r, o] = Gn(a).match(/\w\w/g).map((l) => parseInt(l, 16));
|
|
177
|
+
return `rgba(${t}, ${r}, ${o}, ${h})`;
|
|
178
178
|
}
|
|
179
|
-
function
|
|
180
|
-
const [t, r,
|
|
181
|
-
return `rgba(${t}, ${r}, ${
|
|
179
|
+
function Xn(a, h) {
|
|
180
|
+
const [t, r, o] = a.match(/\d+/g).map((l) => parseInt(l, 10));
|
|
181
|
+
return `rgba(${t}, ${r}, ${o}, ${h})`;
|
|
182
182
|
}
|
|
183
|
-
const wt = (a,
|
|
184
|
-
x: a.x -
|
|
185
|
-
y: a.y -
|
|
183
|
+
const wt = (a, h) => ({
|
|
184
|
+
x: a.x - h.x,
|
|
185
|
+
y: a.y - h.y
|
|
186
186
|
}), Tt = (a) => Math.sqrt(a.x * a.x + a.y * a.y), Ke = (a) => ({
|
|
187
187
|
x: -a.x,
|
|
188
188
|
y: -a.y
|
|
189
189
|
}), Je = (a) => {
|
|
190
|
-
const
|
|
191
|
-
return
|
|
192
|
-
x: a.x /
|
|
193
|
-
y: a.y /
|
|
190
|
+
const h = Tt(a);
|
|
191
|
+
return h === 0 ? { x: 0, y: 0 } : {
|
|
192
|
+
x: a.x / h,
|
|
193
|
+
y: a.y / h
|
|
194
194
|
};
|
|
195
|
-
}, St = (a,
|
|
196
|
-
x: a.x +
|
|
197
|
-
y: a.y +
|
|
198
|
-
}), Qe = (a,
|
|
199
|
-
x: a.x *
|
|
200
|
-
y: a.y *
|
|
201
|
-
}), Wt = (a,
|
|
202
|
-
x: a.x *
|
|
203
|
-
y: a.y *
|
|
204
|
-
}), rt = (a,
|
|
205
|
-
const t = Math.sin(
|
|
195
|
+
}, St = (a, h) => ({
|
|
196
|
+
x: a.x + h.x,
|
|
197
|
+
y: a.y + h.y
|
|
198
|
+
}), Qe = (a, h) => ({
|
|
199
|
+
x: a.x * h,
|
|
200
|
+
y: a.y * h
|
|
201
|
+
}), Wt = (a, h) => ({
|
|
202
|
+
x: a.x * h.x,
|
|
203
|
+
y: a.y * h.y
|
|
204
|
+
}), rt = (a, h) => {
|
|
205
|
+
const t = Math.sin(h), r = Math.cos(h);
|
|
206
206
|
return {
|
|
207
207
|
x: a.x * r - a.y * t,
|
|
208
208
|
y: a.x * t + a.y * r
|
|
209
209
|
};
|
|
210
|
-
},
|
|
211
|
-
x: a.x /
|
|
212
|
-
y: a.y /
|
|
213
|
-
}), Le = (a,
|
|
214
|
-
function tn(a,
|
|
210
|
+
}, Zn = (a, h) => ({
|
|
211
|
+
x: a.x / h,
|
|
212
|
+
y: a.y / h
|
|
213
|
+
}), Le = (a, h) => a.x * h.x + a.y * h.y, Kn = 0.5;
|
|
214
|
+
function tn(a, h = 5, t = 30) {
|
|
215
215
|
var d;
|
|
216
|
-
const { start: r, end:
|
|
217
|
-
return Math.min(t, Math.max(3 * u, Tt(
|
|
216
|
+
const { start: r, end: o } = Zt(a), l = wt(o, r), u = a.properties.style && a.properties.style.strokeWidth ? (d = a.properties.style) == null ? void 0 : d.strokeWidth : 0;
|
|
217
|
+
return Math.min(t, Math.max(3 * u, Tt(l) * 0.01, h));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
const
|
|
219
|
+
function $e(a, h, t, r) {
|
|
220
|
+
const o = Qe(Ke(Je(h)), r);
|
|
221
221
|
if (!t || t !== "arrow" && t !== "arrow-plain") return "";
|
|
222
|
-
const
|
|
223
|
-
return `M ${
|
|
222
|
+
const l = St(a, rt(o, Math.PI / 10)), u = St(a, rt(o, -Math.PI / 10)), d = `${a.x} ${a.y}`;
|
|
223
|
+
return `M ${l.x} ${l.y} L ${d} ${u.x} ${u.y} ${t === "arrow" ? "" : `${l.x} ${l.y}`}`;
|
|
224
224
|
}
|
|
225
|
-
function
|
|
226
|
-
const { start:
|
|
225
|
+
function Jn(a, h, t, r, o) {
|
|
226
|
+
const { start: l, end: u } = Zt(a), {
|
|
227
227
|
tail: d,
|
|
228
228
|
head: g,
|
|
229
229
|
strokeColor: f,
|
|
230
230
|
strokeWidth: y = 0
|
|
231
|
-
} = a.properties.style || t, v = wt(u,
|
|
231
|
+
} = a.properties.style || t, v = wt(u, l), k = tn(a, r, o), b = xt("g"), w = xt("path");
|
|
232
232
|
b.setAttribute("data-annotation", `${a.id}`), b.setAttribute("data-annotation-type", "arrow");
|
|
233
|
-
const
|
|
234
|
-
w.setAttribute("stroke", E), w.setAttribute("stroke-width", `${y}`), w.setAttribute("fill",
|
|
235
|
-
const
|
|
236
|
-
w.setAttribute("d", D), b.appendChild(w),
|
|
233
|
+
const C = g === "arrow-plain" || d === "arrow", E = f || "none";
|
|
234
|
+
w.setAttribute("stroke", E), w.setAttribute("stroke-width", `${y}`), w.setAttribute("fill", C ? f || "" : "none"), w.setAttribute("stroke-linecap", "round"), w.setAttribute("stroke-linejoin", "round");
|
|
235
|
+
const $ = $e(l, Ke(v), d, k), N = $e(u, v, g, k), D = $ + `M ${l.x} ${l.y} ${u.x} ${u.y}` + N;
|
|
236
|
+
w.setAttribute("d", D), b.appendChild(w), Ce(b, l, E, d, y), Ce(b, u, E, g, y), h.appendChild(b);
|
|
237
237
|
}
|
|
238
|
-
function
|
|
239
|
-
r === "halo-dot" && Pe(
|
|
238
|
+
function Ce(a, h, t, r, o) {
|
|
239
|
+
r === "halo-dot" && Pe(
|
|
240
|
+
a,
|
|
241
|
+
h,
|
|
242
|
+
Qn(t),
|
|
243
|
+
Kn,
|
|
244
|
+
o * 4
|
|
245
|
+
), (r === "dot" || r === "halo-dot") && Pe(a, h, t, 1, o * 2);
|
|
240
246
|
}
|
|
241
|
-
function
|
|
242
|
-
return a === "none" ? "none" :
|
|
247
|
+
function Qn(a) {
|
|
248
|
+
return a === "none" ? "none" : a;
|
|
243
249
|
}
|
|
244
|
-
function Pe(a,
|
|
245
|
-
const
|
|
246
|
-
|
|
250
|
+
function Pe(a, h, t, r, o) {
|
|
251
|
+
const l = xt("circle");
|
|
252
|
+
l.setAttribute("cx", `${h.x}`), l.setAttribute("cy", `${h.y}`), l.setAttribute("r", `${o}`), l.setAttribute("fill-opacity", `${r}`), l.setAttribute("fill", t), a.appendChild(l);
|
|
247
253
|
}
|
|
248
|
-
const W = -1, Kt = "dragging", Jt = "dragstart", It = "dragend", pe = "select", ge = "unselect",
|
|
254
|
+
const W = -1, Kt = "dragging", Jt = "dragstart", It = "dragend", pe = "select", ge = "unselect", tr = "hover", er = "unhover", ye = "remove", me = "add", nr = "cancelDrawing", ve = "update", rr = "link";
|
|
249
255
|
function en(a) {
|
|
250
256
|
return a && a.__esModule && Object.prototype.hasOwnProperty.call(a, "default") ? a.default : a;
|
|
251
257
|
}
|
|
252
258
|
var he = { exports: {} }, ze;
|
|
253
|
-
function
|
|
259
|
+
function ir() {
|
|
254
260
|
return ze || (ze = 1, function(a) {
|
|
255
|
-
var
|
|
261
|
+
var h = Object.prototype.hasOwnProperty, t = "~";
|
|
256
262
|
function r() {
|
|
257
263
|
}
|
|
258
264
|
Object.create && (r.prototype = /* @__PURE__ */ Object.create(null), new r().__proto__ || (t = !1));
|
|
259
|
-
function
|
|
265
|
+
function o(g, f, y) {
|
|
260
266
|
this.fn = g, this.context = f, this.once = y || !1;
|
|
261
267
|
}
|
|
262
|
-
function
|
|
268
|
+
function l(g, f, y, v, k) {
|
|
263
269
|
if (typeof y != "function")
|
|
264
270
|
throw new TypeError("The listener must be a function");
|
|
265
|
-
var b = new
|
|
271
|
+
var b = new o(y, v || g, k), w = t ? t + f : f;
|
|
266
272
|
return g._events[w] ? g._events[w].fn ? g._events[w] = [g._events[w], b] : g._events[w].push(b) : (g._events[w] = b, g._eventsCount++), g;
|
|
267
273
|
}
|
|
268
274
|
function u(g, f) {
|
|
@@ -275,7 +281,7 @@ function sr() {
|
|
|
275
281
|
var f = [], y, v;
|
|
276
282
|
if (this._eventsCount === 0) return f;
|
|
277
283
|
for (v in y = this._events)
|
|
278
|
-
|
|
284
|
+
h.call(y, v) && f.push(t ? v.slice(1) : v);
|
|
279
285
|
return Object.getOwnPropertySymbols ? f.concat(Object.getOwnPropertySymbols(y)) : f;
|
|
280
286
|
}, d.prototype.listeners = function(f) {
|
|
281
287
|
var y = t ? t + f : f, v = this._events[y];
|
|
@@ -288,11 +294,11 @@ function sr() {
|
|
|
288
294
|
var y = t ? t + f : f, v = this._events[y];
|
|
289
295
|
return v ? v.fn ? 1 : v.length : 0;
|
|
290
296
|
}, d.prototype.emit = function(f, y, v, k, b, w) {
|
|
291
|
-
var
|
|
292
|
-
if (!this._events[
|
|
293
|
-
var E = this._events[
|
|
297
|
+
var C = t ? t + f : f;
|
|
298
|
+
if (!this._events[C]) return !1;
|
|
299
|
+
var E = this._events[C], $ = arguments.length, N, D;
|
|
294
300
|
if (E.fn) {
|
|
295
|
-
switch (E.once && this.removeListener(f, E.fn, void 0, !0),
|
|
301
|
+
switch (E.once && this.removeListener(f, E.fn, void 0, !0), $) {
|
|
296
302
|
case 1:
|
|
297
303
|
return E.fn.call(E.context), !0;
|
|
298
304
|
case 2:
|
|
@@ -306,13 +312,13 @@ function sr() {
|
|
|
306
312
|
case 6:
|
|
307
313
|
return E.fn.call(E.context, y, v, k, b, w), !0;
|
|
308
314
|
}
|
|
309
|
-
for (D = 1, N = new Array(
|
|
315
|
+
for (D = 1, N = new Array($ - 1); D < $; D++)
|
|
310
316
|
N[D - 1] = arguments[D];
|
|
311
317
|
E.fn.apply(E.context, N);
|
|
312
318
|
} else {
|
|
313
319
|
var z = E.length, R;
|
|
314
320
|
for (D = 0; D < z; D++)
|
|
315
|
-
switch (E[D].once && this.removeListener(f, E[D].fn, void 0, !0),
|
|
321
|
+
switch (E[D].once && this.removeListener(f, E[D].fn, void 0, !0), $) {
|
|
316
322
|
case 1:
|
|
317
323
|
E[D].fn.call(E[D].context);
|
|
318
324
|
break;
|
|
@@ -326,16 +332,16 @@ function sr() {
|
|
|
326
332
|
E[D].fn.call(E[D].context, y, v, k);
|
|
327
333
|
break;
|
|
328
334
|
default:
|
|
329
|
-
if (!N) for (R = 1, N = new Array(
|
|
335
|
+
if (!N) for (R = 1, N = new Array($ - 1); R < $; R++)
|
|
330
336
|
N[R - 1] = arguments[R];
|
|
331
337
|
E[D].fn.apply(E[D].context, N);
|
|
332
338
|
}
|
|
333
339
|
}
|
|
334
340
|
return !0;
|
|
335
341
|
}, d.prototype.on = function(f, y, v) {
|
|
336
|
-
return
|
|
342
|
+
return l(this, f, y, v, !1);
|
|
337
343
|
}, d.prototype.once = function(f, y, v) {
|
|
338
|
-
return
|
|
344
|
+
return l(this, f, y, v, !0);
|
|
339
345
|
}, d.prototype.removeListener = function(f, y, v, k) {
|
|
340
346
|
var b = t ? t + f : f;
|
|
341
347
|
if (!this._events[b]) return this;
|
|
@@ -345,8 +351,8 @@ function sr() {
|
|
|
345
351
|
if (w.fn)
|
|
346
352
|
w.fn === y && (!k || w.once) && (!v || w.context === v) && u(this, b);
|
|
347
353
|
else {
|
|
348
|
-
for (var
|
|
349
|
-
(w[
|
|
354
|
+
for (var C = 0, E = [], $ = w.length; C < $; C++)
|
|
355
|
+
(w[C].fn !== y || k && !w[C].once || v && w[C].context !== v) && E.push(w[C]);
|
|
350
356
|
E.length ? this._events[b] = E.length === 1 ? E[0] : E : u(this, b);
|
|
351
357
|
}
|
|
352
358
|
return this;
|
|
@@ -356,8 +362,8 @@ function sr() {
|
|
|
356
362
|
}, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = t, d.EventEmitter = d, a.exports = d;
|
|
357
363
|
}(he)), he.exports;
|
|
358
364
|
}
|
|
359
|
-
var
|
|
360
|
-
const nn = /* @__PURE__ */ en(
|
|
365
|
+
var sr = ir();
|
|
366
|
+
const nn = /* @__PURE__ */ en(sr);
|
|
361
367
|
class rn extends nn {
|
|
362
368
|
constructor(t, r) {
|
|
363
369
|
super();
|
|
@@ -379,13 +385,13 @@ class rn extends nn {
|
|
|
379
385
|
m(this, "_onClickMouseMove", (t) => {
|
|
380
386
|
if (!t.domEvent || this.isDragging || !this.shouldDetect || t.domEvent.type !== "mousemove" && t.domEvent.target && t.domEvent.target.tagName === "a")
|
|
381
387
|
return;
|
|
382
|
-
const r = this.ogma.view.screenToGraphCoordinates(t),
|
|
383
|
-
t.domEvent.type === "mousemove" ?
|
|
388
|
+
const r = this.ogma.view.screenToGraphCoordinates(t), o = this.shouldDetect || !this.shouldDetect && +this.selectedId > -1 ? this.detect(r, 0) : void 0;
|
|
389
|
+
t.domEvent.type === "mousemove" ? o ? this.hover(o.id) : this.hoveredId !== W && this.unhover() : o ? this.select(o.id) : this.selectedId !== W && this.unselect();
|
|
384
390
|
});
|
|
385
391
|
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", () => {
|
|
386
392
|
this.refreshEditor(), this.refreshDrawing();
|
|
387
393
|
}), this.layer = t.layers.addSVGLayer({
|
|
388
|
-
draw: (
|
|
394
|
+
draw: (o) => this.draw(o)
|
|
389
395
|
}), this.layer.moveToTop(), this.editor = t.layers.addLayer(r), this.editor.hide();
|
|
390
396
|
}
|
|
391
397
|
_canRemove() {
|
|
@@ -397,7 +403,7 @@ class rn extends nn {
|
|
|
397
403
|
* @returns the added annotation
|
|
398
404
|
*/
|
|
399
405
|
add(t) {
|
|
400
|
-
const r = this.getDefaultOptions(),
|
|
406
|
+
const r = this.getDefaultOptions(), o = Object.assign(t, {
|
|
401
407
|
id: t.id === void 0 ? Qt() : t.id,
|
|
402
408
|
type: t.type,
|
|
403
409
|
properties: {
|
|
@@ -411,7 +417,7 @@ class rn extends nn {
|
|
|
411
417
|
...t.geometry
|
|
412
418
|
}
|
|
413
419
|
});
|
|
414
|
-
return this.elements.push(
|
|
420
|
+
return this.elements.push(o), this.layer.refresh(), this.emit(me, o), o;
|
|
415
421
|
}
|
|
416
422
|
updateStyle(t, r) {
|
|
417
423
|
this.updateAnnotation(t, {
|
|
@@ -425,10 +431,10 @@ class rn extends nn {
|
|
|
425
431
|
geometry: r
|
|
426
432
|
});
|
|
427
433
|
}
|
|
428
|
-
scale(t, r,
|
|
434
|
+
scale(t, r, o, l) {
|
|
429
435
|
this.updateGeometry(
|
|
430
436
|
t,
|
|
431
|
-
Wn(t.geometry, r,
|
|
437
|
+
Wn(t.geometry, r, o, l)
|
|
432
438
|
);
|
|
433
439
|
}
|
|
434
440
|
/**
|
|
@@ -438,15 +444,15 @@ class rn extends nn {
|
|
|
438
444
|
* @param element params of the annotation
|
|
439
445
|
*/
|
|
440
446
|
update(t, r) {
|
|
441
|
-
const
|
|
442
|
-
this.updateAnnotation(
|
|
447
|
+
const o = this.getById(t);
|
|
448
|
+
this.updateAnnotation(o, r);
|
|
443
449
|
}
|
|
444
450
|
updateAnnotation(t, r) {
|
|
445
451
|
if (!t) return;
|
|
446
|
-
const
|
|
447
|
-
Object.keys(r).forEach((
|
|
448
|
-
if (
|
|
449
|
-
if (
|
|
452
|
+
const o = t.id;
|
|
453
|
+
Object.keys(r).forEach((l) => {
|
|
454
|
+
if (l !== "id")
|
|
455
|
+
if (l === "properties") {
|
|
450
456
|
const u = r.properties || { style: {} };
|
|
451
457
|
t.properties = {
|
|
452
458
|
...t.properties || {},
|
|
@@ -456,18 +462,18 @@ class rn extends nn {
|
|
|
456
462
|
...u.style || {}
|
|
457
463
|
}
|
|
458
464
|
};
|
|
459
|
-
} else
|
|
465
|
+
} else l === "geometry" ? t.geometry = {
|
|
460
466
|
...t.geometry,
|
|
461
467
|
...r.geometry
|
|
462
|
-
} : t[
|
|
463
|
-
}),
|
|
468
|
+
} : t[l] = r[l];
|
|
469
|
+
}), o === this.selectedId && this.refreshEditor(), this.layer.refresh();
|
|
464
470
|
}
|
|
465
471
|
getById(t) {
|
|
466
472
|
const r = Number(t);
|
|
467
|
-
for (let
|
|
468
|
-
const
|
|
469
|
-
if (!(
|
|
470
|
-
return
|
|
473
|
+
for (let o = 0; o < this.elements.length; o++) {
|
|
474
|
+
const l = this.elements[o];
|
|
475
|
+
if (!(l.id !== t && l.id !== r))
|
|
476
|
+
return l;
|
|
471
477
|
}
|
|
472
478
|
}
|
|
473
479
|
/**
|
|
@@ -481,7 +487,7 @@ class rn extends nn {
|
|
|
481
487
|
}
|
|
482
488
|
hover(t) {
|
|
483
489
|
const r = this.getById(t);
|
|
484
|
-
r && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(
|
|
490
|
+
r && (this.showeditorOnHover && this.editor.show(), this.hoveredId = t, this.refreshEditor(), this.layer.refresh(), this.emit(tr, r));
|
|
485
491
|
}
|
|
486
492
|
getSelectedFeature() {
|
|
487
493
|
return this.selectedId === W ? null : this.getById(this.selectedId);
|
|
@@ -492,7 +498,7 @@ class rn extends nn {
|
|
|
492
498
|
}
|
|
493
499
|
unhover() {
|
|
494
500
|
const t = this.getById(this.hoveredId);
|
|
495
|
-
return this.emit(
|
|
501
|
+
return this.emit(er, t), this.hoveredId = W, this.selectedId === W && this.editor.hide(), this.layer.refresh(), this;
|
|
496
502
|
}
|
|
497
503
|
/**
|
|
498
504
|
* @method remove
|
|
@@ -501,7 +507,7 @@ class rn extends nn {
|
|
|
501
507
|
*/
|
|
502
508
|
remove(t) {
|
|
503
509
|
const r = this.getById(t);
|
|
504
|
-
t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((
|
|
510
|
+
t === this.hoveredId && this.unhover(), t === this.selectedId && this.unselect(), this.elements = this.elements.filter((o) => o.id !== t), r && this.emit(ye, r), this.layer.refresh();
|
|
505
511
|
}
|
|
506
512
|
/**
|
|
507
513
|
* @method disableDragging
|
|
@@ -552,7 +558,7 @@ class rn extends nn {
|
|
|
552
558
|
}
|
|
553
559
|
}
|
|
554
560
|
const Ne = "handle-line", He = "handle-start", Fe = "handle-end";
|
|
555
|
-
class
|
|
561
|
+
class or extends rn {
|
|
556
562
|
constructor(t, r = {}) {
|
|
557
563
|
super(
|
|
558
564
|
t,
|
|
@@ -577,22 +583,22 @@ class ar extends rn {
|
|
|
577
583
|
m(this, "onHandleMouseDown", (t) => {
|
|
578
584
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
579
585
|
if (!r) return;
|
|
580
|
-
const { x:
|
|
581
|
-
this.startDragging(r,
|
|
586
|
+
const { x: o, y: l } = fe(t, this.ogma.getContainer());
|
|
587
|
+
this.startDragging(r, o, l), this.draggedHandle = Ze(t.target);
|
|
582
588
|
});
|
|
583
589
|
m(this, "onMouseUp", () => {
|
|
584
590
|
this.draggedHandle !== -1 && (this.restoreDragging(), this.isDragging = !1, this.draggedHandle = W, this.emit(It, this.arrow));
|
|
585
591
|
});
|
|
586
592
|
m(this, "onMouseMove", (t) => {
|
|
587
593
|
if (!this.isDragging || this.draggedHandle === W) return;
|
|
588
|
-
const r = this.handles[this.draggedHandle],
|
|
589
|
-
|
|
594
|
+
const r = this.handles[this.draggedHandle], o = this.ogma.view.getAngle(), { x: l, y: u } = rt(
|
|
595
|
+
Zn(
|
|
590
596
|
{ x: t.x - this.startX, y: t.y - this.startY },
|
|
591
597
|
this.ogma.view.getZoom()
|
|
592
598
|
),
|
|
593
|
-
|
|
599
|
+
o
|
|
594
600
|
), d = r.id === Ne, g = r.id === He, f = r.id === Fe;
|
|
595
|
-
(d || g) && Ye(this.arrow, this.start.x +
|
|
601
|
+
(d || g) && Ye(this.arrow, this.start.x + l, this.start.y + u), (d || f) && Xe(this.arrow, this.end.x + l, this.end.y + u), this.emit(
|
|
596
602
|
Kt,
|
|
597
603
|
this.arrow,
|
|
598
604
|
d ? "line" : g ? "start" : "end"
|
|
@@ -601,7 +607,7 @@ class ar extends rn {
|
|
|
601
607
|
this.minArrowHeight = r.minArrowHeight || 0, this.maxArrowHeight = r.maxArrowHeight || 1e6, this.handles = Array.prototype.slice.call(
|
|
602
608
|
this.editor.element.querySelectorAll(".arrow-handle>.handle")
|
|
603
609
|
), this.handles.forEach(
|
|
604
|
-
(
|
|
610
|
+
(o) => o.addEventListener("mousedown", this.onHandleMouseDown)
|
|
605
611
|
), document.addEventListener("mousemove", this.onMouseMove, !0), document.addEventListener("mouseup", this.onMouseUp);
|
|
606
612
|
}
|
|
607
613
|
/**
|
|
@@ -610,44 +616,44 @@ class ar extends rn {
|
|
|
610
616
|
* @param y
|
|
611
617
|
* @param arrow
|
|
612
618
|
*/
|
|
613
|
-
startDrawing(t, r,
|
|
619
|
+
startDrawing(t, r, o = qn(t, r, t, r, Nt)) {
|
|
614
620
|
var d;
|
|
615
|
-
this.disableDragging(), this.add(
|
|
616
|
-
const
|
|
621
|
+
this.disableDragging(), this.add(o), this.hoveredId = o.id;
|
|
622
|
+
const l = this.ogma.view.graphToScreenCoordinates({ x: t, y: r }), u = ((d = this.ogma.getContainer()) == null ? void 0 : d.getBoundingClientRect()) || {
|
|
617
623
|
left: 0,
|
|
618
624
|
top: 0
|
|
619
625
|
};
|
|
620
626
|
this.startDragging(
|
|
621
|
-
this.getById(
|
|
622
|
-
|
|
623
|
-
|
|
627
|
+
this.getById(o.id),
|
|
628
|
+
l.x + (u == null ? void 0 : u.left),
|
|
629
|
+
l.y + u.top
|
|
624
630
|
), this.draggedHandle = 2;
|
|
625
631
|
}
|
|
626
632
|
cancelDrawing() {
|
|
627
633
|
this.isDragging && (this.remove(this.arrow.id), this.emit(It, this.arrow), this.restoreDragging(), this.isDragging = !1, this.draggedHandle = W);
|
|
628
634
|
}
|
|
629
|
-
startDragging(t, r,
|
|
630
|
-
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY =
|
|
635
|
+
startDragging(t, r, o) {
|
|
636
|
+
this.selectedId !== t.id && this.select(this.hoveredId), this.arrow = t, this.startX = r, this.startY = o, this.start = zt(this.arrow), this.end = Xt(this.arrow), this.disableDragging(), this.emit(Jt, this.arrow), this.isDragging = !0;
|
|
631
637
|
}
|
|
632
638
|
detect(t, r = 0) {
|
|
633
|
-
return this.elements.find((
|
|
634
|
-
const { start:
|
|
635
|
-
x: (
|
|
636
|
-
y: (
|
|
637
|
-
}), g = wt(u,
|
|
639
|
+
return this.elements.find((o) => {
|
|
640
|
+
const { start: l, end: u } = Zt(o), d = wt(t, {
|
|
641
|
+
x: (l.x + u.x) / 2,
|
|
642
|
+
y: (l.y + u.y) / 2
|
|
643
|
+
}), g = wt(u, l), f = Tt(g), y = Je(g), v = tn(o);
|
|
638
644
|
return Math.abs(Le(y, d)) < f / 2 + r && Math.abs(Le(rt(y, Math.PI / 2), d)) < v / 2 + r;
|
|
639
645
|
});
|
|
640
646
|
}
|
|
641
647
|
refreshEditor() {
|
|
642
648
|
if (+this.selectedId < 0 && +this.hoveredId < 0) return;
|
|
643
|
-
const t = this.selectedId !== W ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Zt(t),
|
|
649
|
+
const t = this.selectedId !== W ? this.getById(this.selectedId) : this.getById(this.hoveredId), r = Zt(t), o = this.ogma.view.graphToScreenCoordinates(r.start), l = this.ogma.view.graphToScreenCoordinates(r.end), [u, d, g] = Array.prototype.slice.call(
|
|
644
650
|
this.editor.element.querySelectorAll(".handle")
|
|
645
651
|
);
|
|
646
|
-
d.style.transform = `translate(${
|
|
652
|
+
d.style.transform = `translate(${o.x}px, ${o.y}px) translate(-50%, -50%)`, g.style.transform = `translate(${l.x}px, ${l.y}px) translate(-50%, -50%)`;
|
|
647
653
|
const f = {
|
|
648
|
-
x: (
|
|
649
|
-
y: (
|
|
650
|
-
}, y = wt(
|
|
654
|
+
x: (l.x + o.x) / 2,
|
|
655
|
+
y: (l.y + o.y) / 2
|
|
656
|
+
}, y = wt(l, o), v = Qe(y, 1 / Tt(y)), k = Math.atan2(v.y, v.x);
|
|
651
657
|
u.style.width = `${Tt(y)}px`, u.style.left = `${f.x}px`, u.style.top = `${f.y}px`, u.style.transform = `translate(-50%, -50%) rotate(${k}rad)`;
|
|
652
658
|
}
|
|
653
659
|
getDefaultOptions() {
|
|
@@ -655,9 +661,9 @@ class ar extends rn {
|
|
|
655
661
|
}
|
|
656
662
|
draw(t) {
|
|
657
663
|
t.innerHTML = "";
|
|
658
|
-
const r = xt("g"),
|
|
659
|
-
|
|
660
|
-
(
|
|
664
|
+
const r = xt("g"), o = this.ogma.view.getAngle();
|
|
665
|
+
o !== 0 && r.setAttribute("transform", `rotate(${-o * (180 / Math.PI)})`), this.elements.forEach(
|
|
666
|
+
(l) => Jn(l, r, Nt, this.minArrowHeight, this.maxArrowHeight)
|
|
661
667
|
), t.appendChild(r);
|
|
662
668
|
}
|
|
663
669
|
refreshDrawing() {
|
|
@@ -705,100 +711,100 @@ const _t = {
|
|
|
705
711
|
}, Re = {
|
|
706
712
|
handleSize: 3.5,
|
|
707
713
|
placeholder: "Your text..."
|
|
708
|
-
},
|
|
714
|
+
}, ar = (a = 0, h = 0, t = 100, r = 50, o = "", l = { ..._t }) => ({
|
|
709
715
|
id: Qt(),
|
|
710
716
|
type: "Feature",
|
|
711
717
|
properties: {
|
|
712
718
|
type: "text",
|
|
713
|
-
content:
|
|
714
|
-
style: { ..._t, ...
|
|
719
|
+
content: o,
|
|
720
|
+
style: { ..._t, ...l }
|
|
715
721
|
},
|
|
716
722
|
geometry: {
|
|
717
723
|
type: "Polygon",
|
|
718
724
|
coordinates: [
|
|
719
725
|
[
|
|
720
|
-
[a,
|
|
721
|
-
[a + t,
|
|
722
|
-
[a + t,
|
|
723
|
-
[a,
|
|
724
|
-
[a,
|
|
726
|
+
[a, h],
|
|
727
|
+
[a + t, h],
|
|
728
|
+
[a + t, h + r],
|
|
729
|
+
[a, h + r],
|
|
730
|
+
[a, h]
|
|
725
731
|
]
|
|
726
732
|
]
|
|
727
733
|
}
|
|
728
734
|
});
|
|
729
|
-
var Yt = { exports: {} },
|
|
730
|
-
function
|
|
731
|
-
return qe || (qe = 1, function(a,
|
|
735
|
+
var Yt = { exports: {} }, lr = Yt.exports, qe;
|
|
736
|
+
function hr() {
|
|
737
|
+
return qe || (qe = 1, function(a, h) {
|
|
732
738
|
(function(t, r) {
|
|
733
739
|
a.exports = r();
|
|
734
|
-
})(
|
|
740
|
+
})(lr, () => (() => {
|
|
735
741
|
var t = { d: (e, n) => {
|
|
736
|
-
for (var
|
|
742
|
+
for (var s in n) t.o(n, s) && !t.o(e, s) && Object.defineProperty(e, s, { enumerable: !0, get: n[s] });
|
|
737
743
|
}, o: (e, n) => Object.prototype.hasOwnProperty.call(e, n) }, r = {};
|
|
738
|
-
function
|
|
739
|
-
return
|
|
744
|
+
function o(e) {
|
|
745
|
+
return o = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
740
746
|
return typeof n;
|
|
741
747
|
} : function(n) {
|
|
742
748
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
743
|
-
},
|
|
749
|
+
}, o(e);
|
|
744
750
|
}
|
|
745
751
|
t.d(r, { default: () => Nn });
|
|
746
|
-
var
|
|
752
|
+
var l = /^((?:[a-z\d-]+\s+)*)([\d.]+(%|em|px)|(?:x+-)?large|(?:x+-)?small|medium)(?:\s*\/\s*(normal|[\d.]+(%|px|em)?))?(\s.+)?$/, u = /\bsmall-caps\b/, d = /\b(?:italic|oblique)\b/, g = /\bbold(?:er)?\b/, f = 13.3333333, y = { "xx-small": 9, "x-small": 10, smaller: 13.3333, small: 13, medium: 16, large: 18, larger: 19.2, "x-large": 24, "xx-large": 32 };
|
|
747
753
|
function v(e) {
|
|
748
|
-
var n = "",
|
|
749
|
-
return
|
|
754
|
+
var n = "", s = this;
|
|
755
|
+
return s.style && s.style !== "normal" && (n += s.style), s.variant && s.variant !== "normal" && (n += (n ? " " : "") + s.variant), s.weight && s.weight !== "normal" && (n += (n ? " " : "") + s.weight), s.size && (n += (n ? " " : "") + s.size + "px", s.height !== s.size && (n += "/" + s.height + "px")), s.family && (n += (n ? " " : "") + s.family), e && (n += "::" + s.baseline), e && (n += "::" + s.color), n;
|
|
750
756
|
}
|
|
751
757
|
var k = { id: "", family: "sans-serif", height: 14, size: 12, variant: "", style: "", weight: "", baseline: "", color: null, toString: v, valueOf: v };
|
|
752
758
|
function b(e) {
|
|
753
|
-
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {},
|
|
754
|
-
n.family = (
|
|
755
|
-
var i = y[
|
|
756
|
-
|
|
757
|
-
var c = parseFloat(
|
|
758
|
-
if (c !== "normal" && c !== "inherit" && c ?
|
|
759
|
+
var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, s = l.exec(e);
|
|
760
|
+
n.family = (s[6] || "").trim();
|
|
761
|
+
var i = y[s[2]] || parseFloat(s[2]);
|
|
762
|
+
s[3] === "%" ? i *= 0.16 : s[3] === "em" ? i *= 16 : s[3] === "pt" && (i *= f), n.size = i;
|
|
763
|
+
var c = parseFloat(s[4]);
|
|
764
|
+
if (c !== "normal" && c !== "inherit" && c ? s[5] && s[5] !== "em" ? s[5] === "pt" ? n.height = c * f : s[5] === "%" ? n.height = 0.01 * i : n.height = c : n.height = c * i : n.height = Math.round(i * (7 / 6)), u.test(s[1]) && (n.variant = "small-caps"), d.test(s[1]) && (n.style = "italic"), g.test(s[1])) n.weight = "bold";
|
|
759
765
|
else {
|
|
760
|
-
var p = parseInt(/\b(\d+)\b/.exec(
|
|
766
|
+
var p = parseInt(/\b(\d+)\b/.exec(s[1]), 10);
|
|
761
767
|
p >= 100 && p !== 400 && (n.weight = p);
|
|
762
768
|
}
|
|
763
769
|
return n;
|
|
764
770
|
}
|
|
765
771
|
function w() {
|
|
766
|
-
var e, n,
|
|
772
|
+
var e, n, s, i = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "12px/14px sans-serif", c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, p = 14, A = 12, x = null, S = null, T = "";
|
|
767
773
|
if (i && i.nodeType) {
|
|
768
774
|
var M = i && (i.ownerDocument && i.ownerDocument.defaultView || i.document && i || i.defaultView), O = M.getComputedStyle(i, null);
|
|
769
775
|
e = O.getPropertyValue("font-family") || "", A = parseFloat(O.getPropertyValue("font-size")), p = O.getPropertyValue("line-height"), x = O.getPropertyValue("font-weight"), S = O.getPropertyValue("font-style"), T = O.getPropertyValue("font-variant") || "";
|
|
770
776
|
} else if (typeof i == "string") {
|
|
771
777
|
var _ = b(i);
|
|
772
778
|
e = _.family, A = _.size, p = _.height, T = _.variant, S = _.style, x = _.weight;
|
|
773
|
-
} else
|
|
779
|
+
} else o(i) === "object" && (e = i.family, A = i.size, p = i.height, T = i.variant, x = i.weight, S = i.style, n = i.baseline, s = i.color);
|
|
774
780
|
c.size && c.size < 3 && (A *= c.size), p = p !== "normal" && p ? parseFloat(p) : A * (7 / 6), c.height && c.height < 3 && (p *= c.height);
|
|
775
781
|
var L = Object.create(k);
|
|
776
|
-
return L.family = c.family || e || "sans-serif", L.height = p ?? 14, L.size = A ?? 12, L.variant = c.variant || T || "", L.style = c.style || S || "", L.weight = c.weight || x || "", L.baseline = n || 0, c.baseline != null && (L.baseline = c.baseline), L.color = c.color ||
|
|
782
|
+
return L.family = c.family || e || "sans-serif", L.height = p ?? 14, L.size = A ?? 12, L.variant = c.variant || T || "", L.style = c.style || S || "", L.weight = c.weight || x || "", L.baseline = n || 0, c.baseline != null && (L.baseline = c.baseline), L.color = c.color || s || "", L.id = v.call(L, !0), L;
|
|
777
783
|
}
|
|
778
|
-
const
|
|
779
|
-
var E,
|
|
784
|
+
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 };
|
|
785
|
+
var E, $ = function(e) {
|
|
780
786
|
var n = typeof OffscreenCanvas < "u" && new OffscreenCanvas(100, 100) || e && e.createElement("canvas");
|
|
781
787
|
if (n && n.getContext) {
|
|
782
|
-
var
|
|
783
|
-
if (
|
|
784
|
-
return
|
|
788
|
+
var s = n.getContext("2d");
|
|
789
|
+
if (s && typeof s.measureText == "function") return function(i, c) {
|
|
790
|
+
return s.font = String(c), s.measureText(i).width;
|
|
785
791
|
};
|
|
786
792
|
}
|
|
787
793
|
}(typeof document < "u" ? document : null) || (E = {}, function(e, n) {
|
|
788
794
|
if (!E[n]) {
|
|
789
|
-
var
|
|
790
|
-
E[n] =
|
|
795
|
+
var s = w(n);
|
|
796
|
+
E[n] = s, /\bmonospace\b/.test(s.family) ? s.size *= 0.6 : (s.size *= 0.45, s.weight && (s.size *= 1.18));
|
|
791
797
|
}
|
|
792
798
|
return e.length * E[n].size;
|
|
793
799
|
}), N = {}, D = { trim: !0, collapse: !0 };
|
|
794
|
-
function z(e, n,
|
|
795
|
-
var i = Object.assign({}, D,
|
|
800
|
+
function z(e, n, s) {
|
|
801
|
+
var i = Object.assign({}, D, s), c = String(e);
|
|
796
802
|
if (!c) return 0;
|
|
797
|
-
if (c in
|
|
803
|
+
if (c in C) {
|
|
798
804
|
var p = n.id + "/" + c;
|
|
799
|
-
return p in N || (N[p] =
|
|
805
|
+
return p in N || (N[p] = $("_".concat(c, "_"), n) - $("__", n)), N[p];
|
|
800
806
|
}
|
|
801
|
-
return i.trim && i.collapse ? i.trim ? c = c.trim() : i.collapse && (c = c.replace(/\s+/g, " ")) : c = c.replace(/\n/g, " "),
|
|
807
|
+
return i.trim && i.collapse ? i.trim ? c = c.trim() : i.collapse && (c = c.replace(/\s+/g, " ")) : c = c.replace(/\n/g, " "), $(c, n) + n.size * (e.tracking || 0);
|
|
802
808
|
}
|
|
803
809
|
function R(e) {
|
|
804
810
|
return R = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
@@ -812,8 +818,8 @@ function cr() {
|
|
|
812
818
|
e.prototype = Object.create(n && n.prototype, { constructor: { value: e, writable: !0, configurable: !0 } }), Object.defineProperty(e, "prototype", { writable: !1 }), n && Dt(e, n);
|
|
813
819
|
}
|
|
814
820
|
function Dt(e, n) {
|
|
815
|
-
return Dt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(
|
|
816
|
-
return
|
|
821
|
+
return Dt = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function(s, i) {
|
|
822
|
+
return s.__proto__ = i, s;
|
|
817
823
|
}, Dt(e, n);
|
|
818
824
|
}
|
|
819
825
|
function Mt(e) {
|
|
@@ -828,20 +834,20 @@ function cr() {
|
|
|
828
834
|
}
|
|
829
835
|
}();
|
|
830
836
|
return function() {
|
|
831
|
-
var
|
|
837
|
+
var s, i = Ht(e);
|
|
832
838
|
if (n) {
|
|
833
839
|
var c = Ht(this).constructor;
|
|
834
|
-
|
|
835
|
-
} else
|
|
836
|
-
return sn(this,
|
|
840
|
+
s = Reflect.construct(i, arguments, c);
|
|
841
|
+
} else s = i.apply(this, arguments);
|
|
842
|
+
return sn(this, s);
|
|
837
843
|
};
|
|
838
844
|
}
|
|
839
845
|
function sn(e, n) {
|
|
840
846
|
if (n && (R(n) === "object" || typeof n == "function")) return n;
|
|
841
847
|
if (n !== void 0) throw new TypeError("Derived constructors may only return object or undefined");
|
|
842
|
-
return function(
|
|
843
|
-
if (
|
|
844
|
-
return
|
|
848
|
+
return function(s) {
|
|
849
|
+
if (s === void 0) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
850
|
+
return s;
|
|
845
851
|
}(e);
|
|
846
852
|
}
|
|
847
853
|
function Ht(e) {
|
|
@@ -853,8 +859,8 @@ function cr() {
|
|
|
853
859
|
if (!(e instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
854
860
|
}
|
|
855
861
|
function on(e, n) {
|
|
856
|
-
for (var
|
|
857
|
-
var i = n[
|
|
862
|
+
for (var s = 0; s < n.length; s++) {
|
|
863
|
+
var i = n[s];
|
|
858
864
|
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(p, A) {
|
|
859
865
|
if (R(p) !== "object" || p === null) return p;
|
|
860
866
|
var x = p[Symbol.toPrimitive];
|
|
@@ -868,7 +874,7 @@ function cr() {
|
|
|
868
874
|
}
|
|
869
875
|
var c;
|
|
870
876
|
}
|
|
871
|
-
function Rt(e, n,
|
|
877
|
+
function Rt(e, n, s) {
|
|
872
878
|
return n && on(e.prototype, n), Object.defineProperty(e, "prototype", { writable: !1 }), e;
|
|
873
879
|
}
|
|
874
880
|
var q = function() {
|
|
@@ -885,37 +891,37 @@ function cr() {
|
|
|
885
891
|
return this.value;
|
|
886
892
|
} }]), e;
|
|
887
893
|
}(), Ot = function(e) {
|
|
888
|
-
dt(
|
|
889
|
-
var n = Mt(
|
|
890
|
-
function
|
|
891
|
-
return Ft(this,
|
|
894
|
+
dt(s, e);
|
|
895
|
+
var n = Mt(s);
|
|
896
|
+
function s() {
|
|
897
|
+
return Ft(this, s), n.apply(this, arguments);
|
|
892
898
|
}
|
|
893
|
-
return Rt(
|
|
899
|
+
return Rt(s);
|
|
894
900
|
}(q), et = function(e) {
|
|
895
|
-
dt(
|
|
896
|
-
var n = Mt(
|
|
897
|
-
function
|
|
898
|
-
return Ft(this,
|
|
901
|
+
dt(s, e);
|
|
902
|
+
var n = Mt(s);
|
|
903
|
+
function s() {
|
|
904
|
+
return Ft(this, s), n.apply(this, arguments);
|
|
899
905
|
}
|
|
900
|
-
return Rt(
|
|
906
|
+
return Rt(s);
|
|
901
907
|
}(q), yt = function(e) {
|
|
902
|
-
dt(
|
|
903
|
-
var n = Mt(
|
|
904
|
-
function
|
|
905
|
-
return Ft(this,
|
|
908
|
+
dt(s, e);
|
|
909
|
+
var n = Mt(s);
|
|
910
|
+
function s() {
|
|
911
|
+
return Ft(this, s), n.apply(this, arguments);
|
|
906
912
|
}
|
|
907
|
-
return Rt(
|
|
913
|
+
return Rt(s);
|
|
908
914
|
}(q), te = /^[\n\r\t\x20\xA0\u2000-\u200B\u205F\u3000]/, an = /^[^\n\r\t\u0020\u2000-\u200B\u205F\u3000]{2,}/, xe = /^[\xA0\u2011\u202F\u2060\uFEFF]/, ln = /^(?:[;\xAD%?…]|,(?!\d))/, hn = /^[´±°¢£¤$¥\u2212]/;
|
|
909
915
|
function qt(e, n) {
|
|
910
916
|
n !== !1 && (e = e.trim());
|
|
911
|
-
for (var
|
|
912
|
-
|
|
913
|
-
var T = te.test(p), M = te.test(
|
|
914
|
-
if ((hn.test(
|
|
917
|
+
for (var s, i, c = [], p = e.charAt(0), A = 0, x = 1, S = e.length; x < S; x++) {
|
|
918
|
+
s = e.charAt(x), i = e.charAt(x + 1);
|
|
919
|
+
var T = te.test(p), M = te.test(s), O = M || T, _ = void 0;
|
|
920
|
+
if ((hn.test(s) && !xe.test(p) || ln.test(p + i) && !xe.test(s)) && (O = !0), p !== "-" && p !== "‐" && p !== "–" && p !== "—" || ((_ = te.test(e.charAt(x - 2))) && !M && (O = !1), !_ && an.test(s + i) && (O = !0)), O) {
|
|
915
921
|
var L = e.slice(A, x);
|
|
916
922
|
/\u00AD$/.test(L) ? (c.push(new q(L.slice(0, -1))), c.push(new yt())) : (c.push(new q(L)), c.push(new Ot())), A = x;
|
|
917
923
|
}
|
|
918
|
-
p =
|
|
924
|
+
p = s;
|
|
919
925
|
}
|
|
920
926
|
return c.push(new q(e.slice(A))), c;
|
|
921
927
|
}
|
|
@@ -948,10 +954,10 @@ function cr() {
|
|
|
948
954
|
e.sup = !0;
|
|
949
955
|
} }, gn = { 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 };
|
|
950
956
|
function Ae(e) {
|
|
951
|
-
return e.replace(pn, function(n,
|
|
952
|
-
if (
|
|
953
|
-
var p =
|
|
954
|
-
return String.fromCharCode(parseInt(
|
|
957
|
+
return e.replace(pn, function(n, s, i, c) {
|
|
958
|
+
if (s || i) {
|
|
959
|
+
var p = s ? 10 : 16;
|
|
960
|
+
return String.fromCharCode(parseInt(s || i, p));
|
|
955
961
|
}
|
|
956
962
|
return c in we ? we[c] : n;
|
|
957
963
|
});
|
|
@@ -961,17 +967,17 @@ function cr() {
|
|
|
961
967
|
}
|
|
962
968
|
var mn = /^\s*([^=\s&]+)(?:\s*=\s*("[^"]+"|'[^']+'|[^>\s]+))?/;
|
|
963
969
|
function vn(e) {
|
|
964
|
-
var n,
|
|
970
|
+
var n, s = {};
|
|
965
971
|
if (e) {
|
|
966
972
|
do
|
|
967
973
|
if (n = mn.exec(e)) {
|
|
968
974
|
var i = Ae(yn(n[2] || "")).replace(/[ \r\n\t]+/g, " ").trim();
|
|
969
|
-
if (
|
|
975
|
+
if (s[n[1]] = i, (e = e.slice(n[0].length)).length && /^\S/.test(e[0])) throw new Error("Attribute error");
|
|
970
976
|
}
|
|
971
977
|
while (n && e.length);
|
|
972
978
|
if (/\S/.test(e)) throw new Error("Attribute error");
|
|
973
979
|
}
|
|
974
|
-
return
|
|
980
|
+
return s;
|
|
975
981
|
}
|
|
976
982
|
const Ee = { copyright: "©", textcopyright: "©", dag: "†", textdagger: "†", ddag: "‡", textdaggerdbl: "‡", guillemotleft: "«", guillemotright: "»", guilsinglleft: "‹", guilsinglright: "›", ldots: "…", dots: "…", textellipsis: "…", lq: "‘", P: "¶", textparagraph: "¶", pounds: "£", textsterling: "£", quotedblbase: "„", quotesinglbase: "‚", rq: "’", S: "§", sim: "~", textasciicircum: "^", textasciitilde: "˜", texttildelow: "~", textasteriskcentered: "*", textbackslash: "'", textbar: "|", textbardbl: "╎", textbigcircle: "◯", textbraceleft: "{", textbraceright: "}", textbullet: "•", textdollar: "$", textemdash: "—", textendash: "—", texteuro: "€", eurosym: "€", euro: "€", textexclamdown: "¡", textgreater: ">", textless: "<", textordfeminine: "ª", textordmasculine: "º", textperiodcentered: "·", cdot: "·", textquestiondown: "¿", textquotedblleft: "“", textquotedblright: "”", textquoteleft: "‘", textquoteright: "’", textquotestraightbase: "‚", textquotestraightdblbase: "„", textregistered: "®", textthreequartersemdash: "-", texttrademark: "™", texttwelveudash: "-", textunderscore: "_", textvisiblespace: "␣", gets: "←", textleftarrow: "←", to: "→", textrightarrow: "→", textdegree: "°", infty: "∞", triangle: "△", triangledown: "▽", blacktriangle: "▲", blacktriangledown: "▼", angle: "∠", sphericalangle: "∢", aleph: "ℵ", hbar: "ħ", imath: "𝚤", jmath: "𝚥", ell: "ℓ", wp: "℘", Re: "ℜ", Im: "ℑ", mho: "℧", prime: "′", emptyset: "∅", nabla: "∇", surd: "√", partial: "∂", top: "⟙", bot: "⟂", vdash: "⟝", dashv: "⟞", forall: "∀", exists: "∃", nexists: "∄", neg: "¬", lnot: "¬", flat: "♭", natural: "♮", sharp: "♯", backslash: "\\", Box: "□", Diamond: "♢", clubsuit: "♣", diamondsuit: "♦", heartsuit: "♥", spadesuit: "♠", Join: "⨝", blacksquare: "■", bigstar: "★", diagdown: "╲", diagup: "╱", blacklozenge: "⧫", rfloor: "⌋", lfloor: "⌊", rceil: "⌉", lceil: "⌈", rangle: "⟩", langle: "⟨", sum: "∑", int: "∫", oint: "∮", prod: "∏", coprod: "∏", bigcap: "∩", bigcup: "∪", bigsqcup: "⊔", bigvee: "∨", bigwedge: "∧", bigodot: "⊙", bigotimes: "⊗", bigoplus: "⊕", biguplus: "⊎", alpha: "α", beta: "β", chi: "χ", delta: "δ", epsilon: "ε", eta: "η", gamma: "γ", iota: "ι", kappa: "κ", lambda: "λ", mu: "μ", nu: "ν", omega: "ω", phi: "φ", pi: "π", psi: "ψ", rho: "ρ", sigma: "σ", tau: "τ", theta: "θ", upsilon: "υ", xi: "ξ", zeta: "ζ", Alpha: "Α", Beta: "Β", Chi: "Χ", Delta: "Δ", Epsilon: "Ε", Eta: "Η", Gamma: "Γ", Iota: "Ι", Kappa: "Κ", Lambda: "Λ", Mu: "Μ", Nu: "Ν", Omega: "Ω", Phi: "Φ", Pi: "Π", Psi: "Ψ", Rho: "Ρ", Sigma: "Σ", Tau: "Τ", Theta: "Θ", Upsilon: "Υ", Xi: "Ξ", Zeta: "Ζ", aa: "å", AA: "Å", ae: "æ", AE: "Æ", dh: "ð", DH: "Ð", dj: "đ", DJ: "Đ", ij: "ij", IJ: "IJ", l: "ł", L: "Ł", ng: "ŋ", NG: "Ŋ", o: "ø", O: "Ø", oe: "œ", OE: "Œ", ss: "ß", SS: "SS", th: "þ", TH: "Þ" };
|
|
977
983
|
var xn = /^(\^|_|\\[^#$%&~_^\\{}()\s]+)(\{)?/, wn = /^%[^\n]+(?:\n|$)/, bn = /^[^#$%&~_^\\{}]+/, An = /^\\([&{}$%#_])/, En = /(?:\\[\\@,!:;-]|-{2,3}|[!?]`|``?|,,|''?|~|<<|>>)/g, kn = { "---": "—", "--": "–", "!`": "¡", "?`": "¿", "``": "“", ",,": "„", "''": "”", "`": "‘", "'": "’", "<<": "«", ">>": "»", "~": " ", "\\-": "", "\\,": " ", "\\;": " ", "\\:": " ", "\\!": " ", "\\@": "\uFEFF", "\\\\": "\\newline{}" }, G = { bf: function(e) {
|
|
@@ -999,12 +1005,12 @@ function cr() {
|
|
|
999
1005
|
var Sn = /[\r\n\xA0]+/g;
|
|
1000
1006
|
function Tn(e, n) {
|
|
1001
1007
|
e.sup && (e.baseline = 0.45, e.size = 0.7), e.sub && (e.baseline = -0.3, e.size = 0.7);
|
|
1002
|
-
var
|
|
1003
|
-
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (
|
|
1008
|
+
var s = n;
|
|
1009
|
+
return (e.style || e.weight || e.baseline || e.color || e.size || e.family) && (s = w(n, e)), s;
|
|
1004
1010
|
}
|
|
1005
|
-
function ke(e, n,
|
|
1006
|
-
for (var i, c, p = e.width; p +
|
|
1007
|
-
e[e.length - 1] instanceof yt && e.pop(), i = e[e.length - 1] || i || {},
|
|
1011
|
+
function ke(e, n, s) {
|
|
1012
|
+
for (var i, c, p = e.width; p + s.width > n && e.length; ) c = (i = e[e.length - 1]).width, i.width > s.width ? (i.value = i.value.slice(0, -1), i.width = z(i, i.font), p += i.width) : e.pop(), p -= c;
|
|
1013
|
+
e[e.length - 1] instanceof yt && e.pop(), i = e[e.length - 1] || i || {}, s.font = w(s.font, i.bold, i.italic, ""), s.href = e.length ? i.href : null, s.rel = e.length ? i.rel : null, s.target = e.length ? i.target : null, e.push(s);
|
|
1008
1014
|
}
|
|
1009
1015
|
function bt(e) {
|
|
1010
1016
|
return Math.round(1e6 * e) / 1e6;
|
|
@@ -1014,11 +1020,11 @@ function cr() {
|
|
|
1014
1020
|
if (Array.isArray(n)) return ee(n);
|
|
1015
1021
|
}(e) || function(n) {
|
|
1016
1022
|
if (typeof Symbol < "u" && n[Symbol.iterator] != null || n["@@iterator"] != null) return Array.from(n);
|
|
1017
|
-
}(e) || function(n,
|
|
1023
|
+
}(e) || function(n, s) {
|
|
1018
1024
|
if (n) {
|
|
1019
|
-
if (typeof n == "string") return ee(n,
|
|
1025
|
+
if (typeof n == "string") return ee(n, s);
|
|
1020
1026
|
var i = Object.prototype.toString.call(n).slice(8, -1);
|
|
1021
|
-
return i === "Object" && n.constructor && (i = n.constructor.name), i === "Map" || i === "Set" ? Array.from(n) : i === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i) ? ee(n,
|
|
1027
|
+
return i === "Object" && n.constructor && (i = n.constructor.name), i === "Map" || i === "Set" ? Array.from(n) : i === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i) ? ee(n, s) : void 0;
|
|
1022
1028
|
}
|
|
1023
1029
|
}(e) || function() {
|
|
1024
1030
|
throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
@@ -1027,14 +1033,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1027
1033
|
}
|
|
1028
1034
|
function ee(e, n) {
|
|
1029
1035
|
(n == null || n > e.length) && (n = e.length);
|
|
1030
|
-
for (var
|
|
1036
|
+
for (var s = 0, i = new Array(n); s < n; s++) i[s] = e[s];
|
|
1031
1037
|
return i;
|
|
1032
1038
|
}
|
|
1033
1039
|
var _n = { center: "middle", right: "end" }, In = { middle: 0.5, center: 0.5, bottom: 1, end: 1 }, ne = function(e, n) {
|
|
1034
1040
|
return !e && !n || e === n;
|
|
1035
1041
|
};
|
|
1036
1042
|
function Dn(e, n) {
|
|
1037
|
-
var
|
|
1043
|
+
var s = [], i = n.font(), c = i.size, p = i.family, A = n.align(), x = n.createElement();
|
|
1038
1044
|
if (e.length) {
|
|
1039
1045
|
var S = i.height, T = n.valign(), M = n.height()(), O = n.width()(0), _ = !isFinite(O) && e.length === 1, L = _ ? null : n.x(), B = bt(S / c), J = _ ? null : bt(S / (1.15 * c + (S - c) / 2));
|
|
1040
1046
|
if (In[T] && isFinite(M)) {
|
|
@@ -1053,24 +1059,24 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1053
1059
|
var at = "", ft = "", ot = 0, lt = e[nt];
|
|
1054
1060
|
if (lt.length) {
|
|
1055
1061
|
F = [];
|
|
1056
|
-
for (var At = 0,
|
|
1062
|
+
for (var At = 0, Ct = 0, ht = void 0, X = 0, Bt = lt.length; X < Bt; X++) {
|
|
1057
1063
|
var U = lt[X], Z = U.font;
|
|
1058
|
-
U.whitespace && At++,
|
|
1064
|
+
U.whitespace && At++, Ct += U.width, X && !U.tracking && !ot && ne(Z.id, at) && ne(U.class, ft) && ne(ht, U.href) ? V += U.value : (I(), V = U.value, Y = { fontFamily: Z.family !== p ? Z.family : null, fontSize: Z.size !== c ? Z.size : null, fontWeight: Z.weight || null, fontStyle: Z.style || null, fontVariant: Z.variant !== "normal" && Z.variant || null, fill: Z.color || null, baselineShift: Z.baseline ? 100 * Z.baseline + "%" : null, className: U.class || null }, ot && (Y.dx = bt(ot), ot = 0), U.tracking && (ot = Z.size * U.tracking), U.href && !ht ? (ht = U.href, Q = "a", Y.href = ht, Y.rel = U.rel, Y.target = U.target) : ht = null, at = Z.id, ft = U.class);
|
|
1059
1065
|
}
|
|
1060
|
-
if (I(), _)
|
|
1066
|
+
if (I(), _) s.push.apply(s, Se(F));
|
|
1061
1067
|
else {
|
|
1062
1068
|
var jt = null, Pt = nt === tt - 1 || lt[lt.length - 1] instanceof et;
|
|
1063
|
-
P && lt.length > 1 && !Pt && (jt = bt((O -
|
|
1069
|
+
P && lt.length > 1 && !Pt && (jt = bt((O - Ct) / At)), s.push(x.apply(void 0, ["tspan", { wordSpacing: jt, x: L(nt) + j, dy: bt(nt ? B : J) + "em" }].concat(Se(F))));
|
|
1064
1070
|
}
|
|
1065
|
-
} else
|
|
1071
|
+
} else s.push(x("tspan", { x: L(nt), dy: bt(nt ? B : J) + "em" }, " "));
|
|
1066
1072
|
}
|
|
1067
1073
|
}
|
|
1068
|
-
return x.apply(void 0, ["text", { fontFamily: p, fontSize: c, textAnchor: _n[A] || "start" }].concat(
|
|
1074
|
+
return x.apply(void 0, ["text", { fontFamily: p, fontSize: c, textAnchor: _n[A] || "start" }].concat(s));
|
|
1069
1075
|
}
|
|
1070
1076
|
var Mn = { middle: 0.5, center: 0.5, bottom: 1, end: 1 };
|
|
1071
|
-
function On(e, n,
|
|
1077
|
+
function On(e, n, s) {
|
|
1072
1078
|
if (e.length) {
|
|
1073
|
-
|
|
1079
|
+
s.textBaseline = "middle";
|
|
1074
1080
|
var i = n.font(), c = i.height, p = i.size, A = n.valign(), x = n.height()(), S = n.width()(0), T = n.align(), M = T === "justify", O = 0.5 * c, _ = Mn[A];
|
|
1075
1081
|
if (_ && isFinite(x)) {
|
|
1076
1082
|
var L = e.length * c;
|
|
@@ -1083,16 +1089,16 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1083
1089
|
});
|
|
1084
1090
|
var Q = 0, Y = J === e.length - 1 || B[B.length - 1] instanceof et;
|
|
1085
1091
|
M && B.length > 1 && !Y && (Q = (S - F) / j), B.forEach(function(V) {
|
|
1086
|
-
|
|
1092
|
+
s.font = V.font;
|
|
1087
1093
|
var I = V.font, nt = I.baseline ? p * -I.baseline + 0.15 * p : 0;
|
|
1088
|
-
|
|
1094
|
+
s.fillStyle = function(ft, ot) {
|
|
1089
1095
|
return ft.color ? ft.color : ot.href ? "#00C" : "#000";
|
|
1090
1096
|
}(I, V);
|
|
1091
1097
|
var tt = 0;
|
|
1092
|
-
if (T === "right" ? tt += S - F : T === "center" ? tt += S / 2 - F / 2 : T === "justify" && (V.whitespace || V instanceof et) && (H += Q),
|
|
1093
|
-
|
|
1098
|
+
if (T === "right" ? tt += S - F : T === "center" ? tt += S / 2 - F / 2 : T === "justify" && (V.whitespace || V instanceof et) && (H += Q), s.fillText(V.value, H + tt, P + nt), V.href) {
|
|
1099
|
+
s.beginPath(), s.strokeStyle = s.fillStyle;
|
|
1094
1100
|
var at = Math.floor(P + 0.45 * p) + 0.5;
|
|
1095
|
-
|
|
1101
|
+
s.moveTo(H + tt, at), s.lineTo(H + tt + V.width, at), s.stroke();
|
|
1096
1102
|
}
|
|
1097
1103
|
H += V.width;
|
|
1098
1104
|
});
|
|
@@ -1107,8 +1113,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1107
1113
|
}, re(e);
|
|
1108
1114
|
}
|
|
1109
1115
|
function Te(e) {
|
|
1110
|
-
for (var n = {},
|
|
1111
|
-
var i = e[
|
|
1116
|
+
for (var n = {}, s = 0; s < e.length; s++) {
|
|
1117
|
+
var i = e[s];
|
|
1112
1118
|
typeof i != "number" && i != null && (typeof i == "string" ? n.text = i : typeof i == "function" ? n.fn = i : re(i) === "object" && i._groups ? n.d3 = i : i && i.nodeType && i.getContext ? n.ctx = i.getContext("2d") : i && i.fillText && i.beginPath ? n.ctx = i : i && (n.text = i));
|
|
1113
1119
|
}
|
|
1114
1120
|
return n;
|
|
@@ -1121,8 +1127,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1121
1127
|
}, Lt(e);
|
|
1122
1128
|
}
|
|
1123
1129
|
function Ln(e, n) {
|
|
1124
|
-
for (var
|
|
1125
|
-
var i = n[
|
|
1130
|
+
for (var s = 0; s < n.length; s++) {
|
|
1131
|
+
var i = n[s];
|
|
1126
1132
|
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(p, A) {
|
|
1127
1133
|
if (Lt(p) !== "object" || p === null) return p;
|
|
1128
1134
|
var x = p[Symbol.toPrimitive];
|
|
@@ -1136,7 +1142,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1136
1142
|
}
|
|
1137
1143
|
var c;
|
|
1138
1144
|
}
|
|
1139
|
-
var
|
|
1145
|
+
var $n = w(), ie = function(e) {
|
|
1140
1146
|
return typeof e == "function" ? e : function() {
|
|
1141
1147
|
return e;
|
|
1142
1148
|
};
|
|
@@ -1152,15 +1158,15 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1152
1158
|
return 0;
|
|
1153
1159
|
}, font: null, tAnchor: 0, parser: e.defaultparser }, i) for (var c in i) typeof this[c] == "function" && this[c](i[c]);
|
|
1154
1160
|
}
|
|
1155
|
-
var n,
|
|
1156
|
-
return n = e,
|
|
1161
|
+
var n, s;
|
|
1162
|
+
return n = e, s = [{ key: "linebreak", value: function(i) {
|
|
1157
1163
|
var c = this, p = this.props.parser(String(i)), A = this.font(), x = function(S, T, M) {
|
|
1158
1164
|
if (!S.length) return [];
|
|
1159
1165
|
var O = T.height(), _ = T.width(), L = T.overflowLine(), B = T.overflowWrap(), J = w(M, !0, !1), H = isFinite(O()) ? Math.floor(O() / M.height) : 1 / 0;
|
|
1160
1166
|
if (!O() && !_(0) || !H) return [];
|
|
1161
1167
|
for (var P = 0, j = 0, F = 0, Q = [], Y = [], V = !1; P < S.length && j < H; ) {
|
|
1162
1168
|
var I = S[P], nt = Tn(I, M);
|
|
1163
|
-
if (I.width = z(I, nt), I.font = nt, I.line = j, I.whitespace = I.value in
|
|
1169
|
+
if (I.width = z(I, nt), I.font = nt, I.line = j, I.whitespace = I.value in C, I.value && (I.value = I.value.replace(Sn, " ")), !(!F && I.whitespace || V && I.whitespace)) if (I instanceof et) F = 0, Y = [], Q.push(P + 1), j++;
|
|
1164
1170
|
else if (I instanceof Ot || I instanceof yt) Y.push({ index: P, width: F });
|
|
1165
1171
|
else if (I.whitespace || F + I.width < _(j)) F += I.width;
|
|
1166
1172
|
else if (Y.length) {
|
|
@@ -1185,10 +1191,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1185
1191
|
P++, V = I.whitespace;
|
|
1186
1192
|
}
|
|
1187
1193
|
P !== Q[Q.length - 1] && Q.push(P);
|
|
1188
|
-
var
|
|
1189
|
-
for (var K, vt =
|
|
1194
|
+
var Ct = 0, ht = 0, X = Q.map(function(mt) {
|
|
1195
|
+
for (var K, vt = Ct; (K = S[vt]) && (K.whitespace || !K.value); ) vt++;
|
|
1190
1196
|
for (var pt = mt, ae = null; pt > vt && (K = S[pt - 1]) && (K.whitespace || !(K.value || K instanceof yt)); ) K instanceof et && (ae = K), pt--;
|
|
1191
|
-
K instanceof yt && (K.value = "-", K.width = z("-", K.font)),
|
|
1197
|
+
K instanceof yt && (K.value = "-", K.width = z("-", K.font)), Ct = mt;
|
|
1192
1198
|
var Et = S.slice(vt, pt).filter(function(le) {
|
|
1193
1199
|
return le.value;
|
|
1194
1200
|
});
|
|
@@ -1217,7 +1223,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1217
1223
|
return c.render(x, S);
|
|
1218
1224
|
}, x.svg = x.render, x.draw = x.render, x;
|
|
1219
1225
|
} }, { key: "font", value: function(i) {
|
|
1220
|
-
return arguments.length ? (this.props.font = w(i), this) : this.props.font || w(
|
|
1226
|
+
return arguments.length ? (this.props.font = w(i), this) : this.props.font || w($n);
|
|
1221
1227
|
} }, { key: "overflow", value: function(i) {
|
|
1222
1228
|
return arguments.length ? (this.props.overflow = String(i), this) : this.props.overflow;
|
|
1223
1229
|
} }, { key: "overflowLine", value: function(i) {
|
|
@@ -1251,33 +1257,33 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1251
1257
|
} }, { key: "render", value: function() {
|
|
1252
1258
|
var i = Te(arguments);
|
|
1253
1259
|
return typeof i.text == "string" && (i.text = this.linebreak(i.text)), i.ctx ? On(i.text, this, i.ctx) : Dn(i.text, this);
|
|
1254
|
-
} }],
|
|
1260
|
+
} }], s && Ln(n.prototype, s), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1255
1261
|
}();
|
|
1256
|
-
function
|
|
1257
|
-
return
|
|
1262
|
+
function $t(e) {
|
|
1263
|
+
return $t = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(n) {
|
|
1258
1264
|
return typeof n;
|
|
1259
1265
|
} : function(n) {
|
|
1260
1266
|
return n && typeof Symbol == "function" && n.constructor === Symbol && n !== Symbol.prototype ? "symbol" : typeof n;
|
|
1261
|
-
},
|
|
1267
|
+
}, $t(e);
|
|
1262
1268
|
}
|
|
1263
1269
|
function se(e, n) {
|
|
1264
1270
|
(n == null || n > e.length) && (n = e.length);
|
|
1265
|
-
for (var
|
|
1271
|
+
for (var s = 0, i = new Array(n); s < n; s++) i[s] = e[s];
|
|
1266
1272
|
return i;
|
|
1267
1273
|
}
|
|
1268
|
-
function
|
|
1269
|
-
for (var
|
|
1270
|
-
var i = n[
|
|
1274
|
+
function Cn(e, n) {
|
|
1275
|
+
for (var s = 0; s < n.length; s++) {
|
|
1276
|
+
var i = n[s];
|
|
1271
1277
|
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0), Object.defineProperty(e, (c = function(p, A) {
|
|
1272
|
-
if (
|
|
1278
|
+
if ($t(p) !== "object" || p === null) return p;
|
|
1273
1279
|
var x = p[Symbol.toPrimitive];
|
|
1274
1280
|
if (x !== void 0) {
|
|
1275
1281
|
var S = x.call(p, A);
|
|
1276
|
-
if (
|
|
1282
|
+
if ($t(S) !== "object") return S;
|
|
1277
1283
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
1278
1284
|
}
|
|
1279
1285
|
return String(p);
|
|
1280
|
-
}(i.key, "string"),
|
|
1286
|
+
}(i.key, "string"), $t(c) === "symbol" ? c : String(c)), i);
|
|
1281
1287
|
}
|
|
1282
1288
|
var c;
|
|
1283
1289
|
}
|
|
@@ -1296,8 +1302,8 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1296
1302
|
}, rotation: 0, vAnchor: 0, hAnchor: 0 }, i) for (var c in i) typeof this[c] == "function" && this[c](i[c]);
|
|
1297
1303
|
this.render = this.render.bind(this);
|
|
1298
1304
|
}
|
|
1299
|
-
var n,
|
|
1300
|
-
return n = e,
|
|
1305
|
+
var n, s;
|
|
1306
|
+
return n = e, s = [{ key: "anchor", value: function(i) {
|
|
1301
1307
|
var c = this.props, p = c.hAnchor, A = c.vAnchor, x = c.width, S = c.height;
|
|
1302
1308
|
if (!arguments.length) return [p * x(0), A * S(0)];
|
|
1303
1309
|
if (typeof i == "string") {
|
|
@@ -1339,32 +1345,32 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1339
1345
|
var c = typeof i.text.render == "function" ? i.text.render() : i.text;
|
|
1340
1346
|
return this.createElement()("g", { transform: "rotate(".concat(this.rotate(), ") translate(").concat(this.anchor(), ")") }, c);
|
|
1341
1347
|
}
|
|
1342
|
-
} }],
|
|
1348
|
+
} }], s && Cn(n.prototype, s), Object.defineProperty(n, "prototype", { writable: !1 }), e;
|
|
1343
1349
|
}(), Pn = Object.prototype.hasOwnProperty, oe = {};
|
|
1344
1350
|
function zn(e) {
|
|
1345
|
-
return oe[e] || (oe[e] = e.replace(/([a-z])([A-Z])/g, function(n,
|
|
1346
|
-
return
|
|
1351
|
+
return oe[e] || (oe[e] = e.replace(/([a-z])([A-Z])/g, function(n, s, i) {
|
|
1352
|
+
return s + "-" + i.toLowerCase();
|
|
1347
1353
|
})), oe[e];
|
|
1348
1354
|
}
|
|
1349
1355
|
function De(e, n) {
|
|
1350
|
-
if (Array.isArray(n)) return n.forEach(function(
|
|
1351
|
-
return De(e,
|
|
1356
|
+
if (Array.isArray(n)) return n.forEach(function(s) {
|
|
1357
|
+
return De(e, s);
|
|
1352
1358
|
});
|
|
1353
1359
|
typeof n == "string" && (n = document.createTextNode(n)), e.appendChild(n);
|
|
1354
1360
|
}
|
|
1355
1361
|
function Me(e, n) {
|
|
1356
1362
|
if (typeof document < "u") {
|
|
1357
|
-
var
|
|
1358
|
-
if (n &&
|
|
1363
|
+
var s = typeof e == "string" ? document.createElementNS("http://www.w3.org/2000/svg", e) : e;
|
|
1364
|
+
if (n && s.setAttribute) for (var i in n) Pn.call(n, i) && n[i] != null && s.setAttribute(i === "className" ? "class" : zn(i), n[i]);
|
|
1359
1365
|
for (var c = arguments.length, p = new Array(c > 2 ? c - 2 : 0), A = 2; A < c; A++) p[A - 2] = arguments[A];
|
|
1360
1366
|
return p != null && p.length && p.forEach(function(x) {
|
|
1361
|
-
De(
|
|
1362
|
-
}),
|
|
1367
|
+
De(s, x);
|
|
1368
|
+
}), s;
|
|
1363
1369
|
}
|
|
1364
1370
|
}
|
|
1365
1371
|
it.createElement = Me, it.textparser = qt, it.defaultparser = qt, it.htmlparser = function(e) {
|
|
1366
1372
|
e = String(e || "").trim();
|
|
1367
|
-
for (var n,
|
|
1373
|
+
for (var n, s, i = { weight: null, style: null, sub: !1, sup: !1, href: null, color: null, rel: null, target: null }, c = [], p = [], A = function(O) {
|
|
1368
1374
|
for (var _ in i) i[_] && (O[_] = i[_]);
|
|
1369
1375
|
c.push(O);
|
|
1370
1376
|
}, x = function(O) {
|
|
@@ -1381,7 +1387,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1381
1387
|
var S = n[1];
|
|
1382
1388
|
x(S), p.push(i), i = Object.create(i), be[S] && be[S](i, "");
|
|
1383
1389
|
var T = vn(n[2]);
|
|
1384
|
-
S === "a" && (T.href && (i.href = T.href), T.rel && (i.rel = T.rel), T.target && (i.target = T.target)), T.class && (i.class = i.class ? i.class + " " + T.class : T.class), T.style && (
|
|
1390
|
+
S === "a" && (T.href && (i.href = T.href), T.rel && (i.rel = T.rel), T.target && (i.target = T.target)), T.class && (i.class = i.class ? i.class + " " + T.class : T.class), T.style && (s = /(?:^|\s|;)color\s*:\s*([^;\s"']+)/.exec(T.style)) && s[1] && (i.color = s[1]), S === "br" && c.push(new et());
|
|
1385
1391
|
} else n = [e.slice(0, 1)], A(new q(n[0]));
|
|
1386
1392
|
e = e.slice(n[0].length);
|
|
1387
1393
|
}
|
|
@@ -1405,7 +1411,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1405
1411
|
}).replace(/\\verb,(.*?),/, function(H, P) {
|
|
1406
1412
|
return "\\verb,".concat(n[+P], ",");
|
|
1407
1413
|
});
|
|
1408
|
-
for (var
|
|
1414
|
+
for (var s, i = { weight: null, italic: null, variant: null, sub: !1, sup: !1, href: null }, c = [], p = [], A = function(H) {
|
|
1409
1415
|
for (var P in i) i[P] && (H[P] = i[P]);
|
|
1410
1416
|
return c.push(H), H;
|
|
1411
1417
|
}, x = function() {
|
|
@@ -1414,14 +1420,14 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1414
1420
|
if (!p.length) throw new Error("Unexpected }");
|
|
1415
1421
|
i = p.pop();
|
|
1416
1422
|
}, T = { tokens: c, open_context: x, close_context: S, add_token: A }; e.length; ) {
|
|
1417
|
-
if (
|
|
1418
|
-
else if (
|
|
1419
|
-
else if (!(
|
|
1420
|
-
if (
|
|
1421
|
-
else if (
|
|
1422
|
-
else if (!(
|
|
1423
|
-
else if (
|
|
1424
|
-
var M =
|
|
1423
|
+
if (s = bn.exec(e)) qt(s[0], !1).forEach(A);
|
|
1424
|
+
else if (s = An.exec(e)) A(new q(s[1]));
|
|
1425
|
+
else if (!(s = wn.exec(e))) {
|
|
1426
|
+
if (s = /^\{/.exec(e)) x();
|
|
1427
|
+
else if (s = /^\}/.exec(e)) S();
|
|
1428
|
+
else if (!(s = /^\$/.exec(e))) if (s = /^\\verb,([^,]+),/.exec(e)) A(new q(s[1]));
|
|
1429
|
+
else if (s = xn.exec(e)) {
|
|
1430
|
+
var M = s[1].slice(1) || s[1], O = !!s[2];
|
|
1425
1431
|
if (/^(La)?TeX$/i.test(M)) {
|
|
1426
1432
|
x(), i.family = "serif";
|
|
1427
1433
|
var _ = void 0;
|
|
@@ -1430,42 +1436,42 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
1430
1436
|
else if (M in G) {
|
|
1431
1437
|
var L = [], B = G[M].length - 1, J = void 0;
|
|
1432
1438
|
if (B) {
|
|
1433
|
-
for (O = !1, e = e.slice(
|
|
1439
|
+
for (O = !1, e = e.slice(s[0].length - 1); B--; ) {
|
|
1434
1440
|
if (!(J = /^\{([^}]+)\}/.exec(e))) throw new Error(M + " is missing an argument");
|
|
1435
1441
|
L.push(J[1]), e = e.slice(J[0].length);
|
|
1436
1442
|
}
|
|
1437
|
-
|
|
1443
|
+
s[0] = /^\{/.exec(e) ? "{" : "", O = !!s[0];
|
|
1438
1444
|
}
|
|
1439
1445
|
O && x(), G[M].apply(T, [i].concat(L));
|
|
1440
|
-
} else console.warn("unknown latex command", M), A(new q(
|
|
1441
|
-
} else
|
|
1446
|
+
} else console.warn("unknown latex command", M), A(new q(s[1])), O && x();
|
|
1447
|
+
} else s = [e.slice(0, 1)], A(new q(s[0]));
|
|
1442
1448
|
}
|
|
1443
|
-
e = e.slice(
|
|
1449
|
+
e = e.slice(s[0].length);
|
|
1444
1450
|
}
|
|
1445
1451
|
return c;
|
|
1446
|
-
}, it.measureText = function(e, n,
|
|
1447
|
-
return z(e, w(n),
|
|
1452
|
+
}, it.measureText = function(e, n, s) {
|
|
1453
|
+
return z(e, w(n), s);
|
|
1448
1454
|
}, it.Token = q, it.Break = Ot, it.LineBreak = et, it.SoftHyphen = yt, it.Rotator = Ie, Ie.createElement = Me;
|
|
1449
1455
|
const Nn = it;
|
|
1450
1456
|
return r.default;
|
|
1451
1457
|
})());
|
|
1452
1458
|
}(Yt)), Yt.exports;
|
|
1453
1459
|
}
|
|
1454
|
-
var
|
|
1455
|
-
const Be = /* @__PURE__ */ en(
|
|
1460
|
+
var cr = hr();
|
|
1461
|
+
const Be = /* @__PURE__ */ en(cr);
|
|
1456
1462
|
function ue(a) {
|
|
1457
1463
|
return a.replace(/…$/, "");
|
|
1458
1464
|
}
|
|
1459
1465
|
function de(a) {
|
|
1460
1466
|
return a.children[0].innerHTML;
|
|
1461
1467
|
}
|
|
1462
|
-
function
|
|
1463
|
-
const t = ut(a), { fontSize: r, font:
|
|
1468
|
+
function ur(a, h) {
|
|
1469
|
+
const t = ut(a), { fontSize: r, font: o, padding: l = 0 } = a.properties.style || {};
|
|
1464
1470
|
if (t.width === t.height && t.width === 0) return;
|
|
1465
1471
|
const u = new Be({
|
|
1466
|
-
font: `${r}px/${r}px ${
|
|
1467
|
-
width: t.width -
|
|
1468
|
-
height: t.height -
|
|
1472
|
+
font: `${r}px/${r}px ${o}`.replace(/(px)+/g, "px"),
|
|
1473
|
+
width: t.width - l * 2,
|
|
1474
|
+
height: t.height - l * 2,
|
|
1469
1475
|
align: "left",
|
|
1470
1476
|
valign: "top",
|
|
1471
1477
|
x: 0,
|
|
@@ -1482,39 +1488,39 @@ function dr(a, l) {
|
|
|
1482
1488
|
const v = [];
|
|
1483
1489
|
a.properties.content.split(`
|
|
1484
1490
|
`).forEach((w) => {
|
|
1485
|
-
let
|
|
1486
|
-
for (;
|
|
1491
|
+
let C = w;
|
|
1492
|
+
for (; C.length && y < f.length; ) {
|
|
1487
1493
|
if (f[y].innerHTML === " ") {
|
|
1488
|
-
|
|
1494
|
+
C.startsWith(`
|
|
1489
1495
|
`) || v.push(y), y++;
|
|
1490
1496
|
break;
|
|
1491
1497
|
}
|
|
1492
1498
|
const E = ue(de(f[y]));
|
|
1493
|
-
|
|
1499
|
+
C.startsWith(E) && (C = C.slice(E.length).trim()), y++;
|
|
1494
1500
|
}
|
|
1495
1501
|
}), v.forEach((w) => g.removeChild(f[w]));
|
|
1496
1502
|
const k = a.properties.content.match(/(https?:\/\/.*)/gm), b = k ? k.map((w) => w.split(" ")[0]) : [];
|
|
1497
|
-
g.setAttribute("transform", `translate(${
|
|
1498
|
-
let
|
|
1503
|
+
g.setAttribute("transform", `translate(${l}, ${l})`), b.forEach((w) => {
|
|
1504
|
+
let C = w;
|
|
1499
1505
|
const E = [];
|
|
1500
|
-
for (;
|
|
1501
|
-
const
|
|
1502
|
-
(D) => !!D.children[0] && D.children[0].tagName === "tspan" &&
|
|
1506
|
+
for (; C.length > 0; ) {
|
|
1507
|
+
const $ = f.find(
|
|
1508
|
+
(D) => !!D.children[0] && D.children[0].tagName === "tspan" && C.startsWith(ue(de(D)))
|
|
1503
1509
|
);
|
|
1504
|
-
if (
|
|
1505
|
-
E.push(
|
|
1506
|
-
const N = ue(
|
|
1510
|
+
if (!$) break;
|
|
1511
|
+
E.push($);
|
|
1512
|
+
const N = ue($.children[0].innerHTML).length;
|
|
1507
1513
|
if (!N) break;
|
|
1508
|
-
|
|
1514
|
+
C = C.slice(N);
|
|
1509
1515
|
}
|
|
1510
|
-
E.forEach((
|
|
1516
|
+
E.forEach(($) => {
|
|
1511
1517
|
const N = document.createElementNS("http://www.w3.org/2000/svg", "a");
|
|
1512
|
-
N.setAttribute("href", w), N.setAttribute("target", "_blank"), N.innerHTML = de(
|
|
1518
|
+
N.setAttribute("href", w), N.setAttribute("target", "_blank"), N.innerHTML = de($), $.children[0].innerHTML = "", $.children[0].appendChild(N);
|
|
1513
1519
|
});
|
|
1514
|
-
}),
|
|
1520
|
+
}), h.appendChild(g);
|
|
1515
1521
|
}
|
|
1516
1522
|
const je = 20;
|
|
1517
|
-
class
|
|
1523
|
+
class dr extends rn {
|
|
1518
1524
|
constructor(t, r = {}) {
|
|
1519
1525
|
super(
|
|
1520
1526
|
t,
|
|
@@ -1548,25 +1554,25 @@ class fr extends rn {
|
|
|
1548
1554
|
m(this, "_onBlur", () => {
|
|
1549
1555
|
this.isFocused = !1;
|
|
1550
1556
|
});
|
|
1551
|
-
m(this, "startDrawing", (t, r,
|
|
1552
|
-
this.add(
|
|
1553
|
-
const
|
|
1554
|
-
this.select(
|
|
1557
|
+
m(this, "startDrawing", (t, r, o = ar(t, r, 0, 0, "", _t)) => {
|
|
1558
|
+
this.add(o);
|
|
1559
|
+
const l = this.ogma.view.graphToScreenCoordinates({ x: t, y: r });
|
|
1560
|
+
this.select(o.id), this.startDragging(this.getById(o.id), l.x, l.y), this.draggedHandle = 6;
|
|
1555
1561
|
});
|
|
1556
1562
|
m(this, "cancelDrawing", () => {
|
|
1557
1563
|
this.isDragging && (this.remove(this.annotation.id), this.annotation = { ...ce }, this.draggedHandle = W, this.isDragging = !1, this.emit(It, this.annotation));
|
|
1558
1564
|
});
|
|
1559
|
-
m(this, "startDragging", (t, r,
|
|
1565
|
+
m(this, "startDragging", (t, r, o) => {
|
|
1560
1566
|
this.annotation = t;
|
|
1561
|
-
const
|
|
1562
|
-
this.rect.x =
|
|
1567
|
+
const l = ct(this.annotation), u = ut(this.annotation);
|
|
1568
|
+
this.rect.x = l.x, this.rect.y = l.y, this.rect.width = u.width, this.rect.height = u.height, this.startX = r, this.startY = o, this.disableDragging(), this.textArea.classList.add("noevents"), this.textArea.setAttribute("disabled", "disabled"), this.emit(Jt, this.annotation), this.isDragging = !0;
|
|
1563
1569
|
});
|
|
1564
1570
|
m(this, "onHandleMouseDown", (t) => {
|
|
1565
1571
|
const r = this.getById(this.selectedId) || this.getById(this.hoveredId);
|
|
1566
1572
|
if (!r) return;
|
|
1567
1573
|
this.selectedId !== r.id && this.select(this.hoveredId);
|
|
1568
|
-
const { x:
|
|
1569
|
-
this.startDragging(r,
|
|
1574
|
+
const { x: o, y: l } = fe(t, this.ogma.getContainer());
|
|
1575
|
+
this.startDragging(r, o, l), this.draggedHandle = Ze(t.target);
|
|
1570
1576
|
});
|
|
1571
1577
|
m(this, "onMouseMove", (t) => {
|
|
1572
1578
|
requestAnimationFrame(() => this._onMouseMove(t));
|
|
@@ -1575,17 +1581,17 @@ class fr extends rn {
|
|
|
1575
1581
|
if (!this.isDragging) return;
|
|
1576
1582
|
t.stopPropagation(), t.preventDefault();
|
|
1577
1583
|
const r = this.handles[this.draggedHandle];
|
|
1578
|
-
let
|
|
1579
|
-
const
|
|
1584
|
+
let o = r.classList.contains("top");
|
|
1585
|
+
const l = r.classList.contains("left"), u = r.classList.contains("right"), d = r.classList.contains("bottom");
|
|
1580
1586
|
let g = r.classList.contains("line-handle");
|
|
1581
|
-
!g && !
|
|
1587
|
+
!g && !o && !d && !l && !u && (o = !0, g = !0);
|
|
1582
1588
|
const { x: f, y } = fe(
|
|
1583
1589
|
t,
|
|
1584
1590
|
this.ogma.getContainer()
|
|
1585
1591
|
);
|
|
1586
1592
|
let v = this.rect.x, k = this.rect.y, b = Math.max(this.rect.width, je), w = Math.max(this.rect.height, je);
|
|
1587
|
-
const
|
|
1588
|
-
g ? (v = this.rect.x + D.x, k = this.rect.y + D.y) :
|
|
1593
|
+
const C = this.ogma.view.getZoom(), E = (f - this.startX) / C, $ = (y - this.startY) / C, N = this.ogma.view.getAngle(), D = rt({ x: E, y: $ }, N), z = rt({ x: E, y: $ }, -N);
|
|
1594
|
+
g ? (v = this.rect.x + D.x, k = this.rect.y + D.y) : l && o ? (v += D.x, k += D.y, b -= E, w -= $) : u && d ? (b += E, w += $) : l && d ? (v += z.x, b -= z.x, w += z.y) : u && o && (k += z.y, b += z.x, w -= z.y), Vn(this.annotation, v, k, b, w), this.emit(Kt, this.annotation, "text"), this.refreshEditor(), this.layer.refresh();
|
|
1589
1595
|
});
|
|
1590
1596
|
m(this, "onMouseUp", () => {
|
|
1591
1597
|
!this.isDragging || this.draggedHandle === W || (this.restoreDragging(), this.textArea.classList.remove("noevents"), this.textArea.removeAttribute("disabled"), this.emit(It, this.annotation), this.isDragging = !1, this.draggedHandle = W);
|
|
@@ -1602,26 +1608,26 @@ class fr extends rn {
|
|
|
1602
1608
|
t && (this.textArea.value = this.textArea.value.replace(/ +(?= )/g, ""), this.textArea.focus(), t.properties.content = this.textArea.value, this.emit(ve, t), this.layer.refresh());
|
|
1603
1609
|
});
|
|
1604
1610
|
this.showeditorOnHover = !1, this.handleSize = Re.handleSize || r.textHandleSize, this.placeholder = Re.placeholder || r.textPlaceholder || "";
|
|
1605
|
-
const
|
|
1606
|
-
|
|
1611
|
+
const o = this.textArea = this.editor.element.querySelector("textarea");
|
|
1612
|
+
o.addEventListener("input", this._onInput), o.addEventListener("focus", this._onFocus), o.addEventListener("blur", this._onBlur), o.addEventListener("mousedown", this._onMousedown), o.spellcheck = !1, this.handles = Array.prototype.slice.call(
|
|
1607
1613
|
this.editor.element.querySelectorAll(".annotation-text-handle > .handle")
|
|
1608
1614
|
), this.handles.push(this.editor.element), this.handles.forEach(
|
|
1609
|
-
(
|
|
1615
|
+
(l) => l.addEventListener("mousedown", this.onHandleMouseDown)
|
|
1610
1616
|
), document.addEventListener("mouseup", this.onMouseUp), document.addEventListener("mousemove", this.onMouseMove, !0), t.events.on(["viewChanged", "zoom"], this.onViewChanged);
|
|
1611
1617
|
}
|
|
1612
1618
|
_canRemove() {
|
|
1613
1619
|
return !this.isFocused;
|
|
1614
1620
|
}
|
|
1615
|
-
detect({ x: t, y: r },
|
|
1616
|
-
const
|
|
1621
|
+
detect({ x: t, y: r }, o = 0) {
|
|
1622
|
+
const l = { x: t, y: r }, u = this.ogma.view.getAngle();
|
|
1617
1623
|
return this.elements.find((d) => {
|
|
1618
|
-
const { x: g, y: f } = ct(d), { width: y, height: v } = ut(d), k = { x: g, y: f }, { x: b, y: w } = rt(wt(
|
|
1619
|
-
return b > -
|
|
1624
|
+
const { x: g, y: f } = ct(d), { width: y, height: v } = ut(d), k = { x: g, y: f }, { x: b, y: w } = rt(wt(l, k), -u);
|
|
1625
|
+
return b > -o && b < y + o && w > -o && w < v + o;
|
|
1620
1626
|
});
|
|
1621
1627
|
}
|
|
1622
1628
|
draw(t) {
|
|
1623
1629
|
t.innerHTML = "";
|
|
1624
|
-
const r = "",
|
|
1630
|
+
const r = "", o = this.ogma.view.getAngle();
|
|
1625
1631
|
for (let u = 0; u < this.elements.length; u++) {
|
|
1626
1632
|
const d = this.elements[u], g = `class${u}`, f = ut(d), y = ct(d);
|
|
1627
1633
|
if (d.id === this.selectedId) continue;
|
|
@@ -1629,9 +1635,9 @@ class fr extends rn {
|
|
|
1629
1635
|
color: k,
|
|
1630
1636
|
fontSize: b,
|
|
1631
1637
|
font: w,
|
|
1632
|
-
strokeColor:
|
|
1638
|
+
strokeColor: C,
|
|
1633
1639
|
strokeWidth: E,
|
|
1634
|
-
strokeType:
|
|
1640
|
+
strokeType: $,
|
|
1635
1641
|
background: N,
|
|
1636
1642
|
borderRadius: D
|
|
1637
1643
|
} = d.properties.style || _t, z = xt("g");
|
|
@@ -1639,20 +1645,20 @@ class fr extends rn {
|
|
|
1639
1645
|
const R = xt("rect");
|
|
1640
1646
|
D && (R.setAttribute("rx", `${D}`), R.setAttribute("ry", `${D}`));
|
|
1641
1647
|
let dt = !1;
|
|
1642
|
-
|
|
1643
|
-
const { x: Dt, y: Mt } = rt(y, -
|
|
1648
|
+
$ && $ !== "none" && (dt = !0, R.setAttribute("stroke", C || "black"), R.setAttribute("stroke-width", `${E}`), $ === "dashed" && R.setAttribute("stroke-dasharray", "5,5")), (N && N.length || dt) && (dt = !0, R.setAttribute("fill", N || "transparent")), dt && (R.setAttribute("width", `${f.width}`), R.setAttribute("height", `${f.height}`)), z.appendChild(R), ur(d, z);
|
|
1649
|
+
const { x: Dt, y: Mt } = rt(y, -o);
|
|
1644
1650
|
z.setAttribute("transform", `translate(${Dt},${Mt})`), z.classList.add(g), z.setAttribute("data-annotation", `${d.id}`), z.setAttribute("data-annotation-type", "text"), t.appendChild(z);
|
|
1645
1651
|
}
|
|
1646
|
-
const
|
|
1647
|
-
|
|
1652
|
+
const l = xt("style");
|
|
1653
|
+
l.innerHTML = r, t.firstChild && t.insertBefore(l, t.firstChild);
|
|
1648
1654
|
}
|
|
1649
1655
|
refreshDrawing() {
|
|
1650
1656
|
const t = this.ogma.view.getAngle(), r = this.layer.element.children;
|
|
1651
|
-
for (let
|
|
1652
|
-
const
|
|
1653
|
-
if (!
|
|
1654
|
-
const u =
|
|
1655
|
-
|
|
1657
|
+
for (let o = 0; o < r.length; o++) {
|
|
1658
|
+
const l = r[o];
|
|
1659
|
+
if (!l.hasAttribute("data-annotation")) continue;
|
|
1660
|
+
const u = l.getAttribute("data-annotation"), d = ct(this.getById(u)), { x: g, y: f } = rt(d, -t);
|
|
1661
|
+
l.setAttribute("transform", `translate(${g},${f})`);
|
|
1656
1662
|
}
|
|
1657
1663
|
}
|
|
1658
1664
|
getDefaultOptions() {
|
|
@@ -1660,20 +1666,20 @@ class fr extends rn {
|
|
|
1660
1666
|
}
|
|
1661
1667
|
refreshEditor() {
|
|
1662
1668
|
if (+this.selectedId < 0 && +this.hoveredId < 0) return;
|
|
1663
|
-
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = ut(t),
|
|
1669
|
+
const t = this.getById(this.selectedId) || this.getById(this.hoveredId), r = ut(t), o = this.ogma.view.graphToScreenCoordinates(
|
|
1664
1670
|
ct(t)
|
|
1665
|
-
),
|
|
1671
|
+
), l = this.ogma.view.getZoom(), {
|
|
1666
1672
|
font: u,
|
|
1667
1673
|
fontSize: d,
|
|
1668
1674
|
color: g,
|
|
1669
1675
|
background: f,
|
|
1670
1676
|
padding: y = 0
|
|
1671
|
-
} = t.properties.style || _t, v = (d || 1) *
|
|
1677
|
+
} = t.properties.style || _t, v = (d || 1) * l;
|
|
1672
1678
|
this.textArea.value = t.properties.content;
|
|
1673
1679
|
const k = this.editor.element.style;
|
|
1674
|
-
k.transform = `translate(${
|
|
1680
|
+
k.transform = `translate(${o.x}px, ${o.y}px)translate(-50%, -50%)translate(${r.width / 2 * l}px, ${r.height / 2 * l}px)`, k.width = `${r.width * l}px`, k.height = `${r.height * l}px`;
|
|
1675
1681
|
const b = this.textArea.style;
|
|
1676
|
-
b.font = `${v} ${u}`, b.fontFamily = u || "sans-serif", b.fontSize = `${v}px`, b.padding = `${
|
|
1682
|
+
b.font = `${v} ${u}`, b.fontFamily = u || "sans-serif", b.fontSize = `${v}px`, b.padding = `${l * y}px`, b.lineHeight = `${v}px`, b.boxSizing = "border-box", b.color = g || "black", b.background = f || "transparent", this.textArea.placeholder = this.placeholder, this.layer.refresh();
|
|
1677
1683
|
}
|
|
1678
1684
|
select(t) {
|
|
1679
1685
|
super.select(t), this.textArea.classList.add("noevents");
|
|
@@ -1682,61 +1688,61 @@ class fr extends rn {
|
|
|
1682
1688
|
super.destroy(), document.removeEventListener("mouseup", this.onMouseUp), document.removeEventListener("mousemove", this.onMouseMove, !0), this.ogma.events.off(this.onViewChanged);
|
|
1683
1689
|
}
|
|
1684
1690
|
}
|
|
1685
|
-
class
|
|
1691
|
+
class fr {
|
|
1686
1692
|
constructor() {
|
|
1687
1693
|
m(this, "links", {});
|
|
1688
1694
|
m(this, "linksByTargetId", {});
|
|
1689
1695
|
m(this, "linksByArrowId", {});
|
|
1690
1696
|
}
|
|
1691
|
-
add(
|
|
1692
|
-
const u = Qt(), d =
|
|
1697
|
+
add(h, t, r, o, l) {
|
|
1698
|
+
const u = Qt(), d = h.id, g = {
|
|
1693
1699
|
id: u,
|
|
1694
1700
|
arrow: d,
|
|
1695
1701
|
target: r,
|
|
1696
|
-
targetType:
|
|
1697
|
-
connectionPoint:
|
|
1702
|
+
targetType: o,
|
|
1703
|
+
connectionPoint: l,
|
|
1698
1704
|
side: t
|
|
1699
1705
|
};
|
|
1700
|
-
return this.links[u] = g, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(u), this.linksByArrowId[d] || (this.linksByArrowId[d] = {}), this.linksByArrowId[d][t] = u,
|
|
1706
|
+
return this.links[u] = g, this.linksByTargetId[r] || (this.linksByTargetId[r] = []), this.linksByTargetId[r].push(u), this.linksByArrowId[d] || (this.linksByArrowId[d] = {}), this.linksByArrowId[d][t] = u, h.properties.link = h.properties.link || {}, h.properties.link[t] = {
|
|
1701
1707
|
id: r,
|
|
1702
1708
|
side: t,
|
|
1703
|
-
type:
|
|
1704
|
-
magnet:
|
|
1709
|
+
type: o,
|
|
1710
|
+
magnet: l
|
|
1705
1711
|
}, this;
|
|
1706
1712
|
}
|
|
1707
|
-
arrowIsLinked(
|
|
1713
|
+
arrowIsLinked(h, t) {
|
|
1708
1714
|
var r;
|
|
1709
|
-
return !!((r = this.linksByArrowId[
|
|
1715
|
+
return !!((r = this.linksByArrowId[h]) != null && r[t]);
|
|
1710
1716
|
}
|
|
1711
1717
|
// remove the link between the arrow and the target by arrow id and side
|
|
1712
|
-
remove(
|
|
1718
|
+
remove(h, t) {
|
|
1713
1719
|
var d, g;
|
|
1714
|
-
const r =
|
|
1715
|
-
if ((g =
|
|
1716
|
-
const
|
|
1717
|
-
delete this.links[
|
|
1718
|
-
const u = this.linksByTargetId[
|
|
1720
|
+
const r = h.id, o = (d = this.linksByArrowId[r]) == null ? void 0 : d[t];
|
|
1721
|
+
if ((g = h.properties.link) == null || delete g[t], !o) return this;
|
|
1722
|
+
const l = this.links[o];
|
|
1723
|
+
delete this.links[o];
|
|
1724
|
+
const u = this.linksByTargetId[l.target];
|
|
1719
1725
|
for (let f = 0; f < u.length; f++)
|
|
1720
|
-
if (u[f] ===
|
|
1726
|
+
if (u[f] === o) {
|
|
1721
1727
|
u.splice(f, 1);
|
|
1722
1728
|
break;
|
|
1723
1729
|
}
|
|
1724
1730
|
return delete this.linksByArrowId[r][t], this;
|
|
1725
1731
|
}
|
|
1726
|
-
getArrowLink(
|
|
1727
|
-
var
|
|
1728
|
-
const r = (
|
|
1732
|
+
getArrowLink(h, t) {
|
|
1733
|
+
var o;
|
|
1734
|
+
const r = (o = this.linksByArrowId[h]) == null ? void 0 : o[t];
|
|
1729
1735
|
return r ? this.links[r] : null;
|
|
1730
1736
|
}
|
|
1731
|
-
getTargetLinks(
|
|
1737
|
+
getTargetLinks(h, t) {
|
|
1732
1738
|
var r;
|
|
1733
|
-
return ((r = this.linksByTargetId[
|
|
1739
|
+
return ((r = this.linksByTargetId[h]) == null ? void 0 : r.map((o) => this.links[o]).filter((o) => o.targetType === t)) ?? [];
|
|
1734
1740
|
}
|
|
1735
|
-
forEach(
|
|
1736
|
-
Object.values(this.links).forEach(
|
|
1741
|
+
forEach(h) {
|
|
1742
|
+
Object.values(this.links).forEach(h);
|
|
1737
1743
|
}
|
|
1738
1744
|
}
|
|
1739
|
-
const st = (a) => a.properties.type === "arrow", gt = (a) => a.properties.type === "text", Ve = (a) => a.type === "FeatureCollection",
|
|
1745
|
+
const st = (a) => a.properties.type === "arrow", gt = (a) => a.properties.type === "text", Ve = (a) => a.type === "FeatureCollection", pr = {
|
|
1740
1746
|
magnetColor: "#3e8",
|
|
1741
1747
|
detectMargin: 20,
|
|
1742
1748
|
magnetHandleRadius: 5,
|
|
@@ -1761,7 +1767,7 @@ class vr extends nn {
|
|
|
1761
1767
|
super();
|
|
1762
1768
|
m(this, "arrows");
|
|
1763
1769
|
m(this, "texts");
|
|
1764
|
-
m(this, "links", new
|
|
1770
|
+
m(this, "links", new fr());
|
|
1765
1771
|
m(this, "layer");
|
|
1766
1772
|
m(this, "annotations");
|
|
1767
1773
|
m(this, "ogma");
|
|
@@ -1776,31 +1782,31 @@ class vr extends nn {
|
|
|
1776
1782
|
if (!this.dragged || this.textToMagnet === void 0) return;
|
|
1777
1783
|
t.beginPath(), t.fillStyle = "green";
|
|
1778
1784
|
const r = this.ogma.view.getZoom();
|
|
1779
|
-
We.forEach((
|
|
1785
|
+
We.forEach((o) => {
|
|
1780
1786
|
if (!this.textToMagnet) return;
|
|
1781
|
-
const
|
|
1787
|
+
const l = ut(this.textToMagnet), u = ct(this.textToMagnet), d = Wt(o, { x: l.width, y: l.height }), g = rt(d, this.ogma.view.getAngle()), { x: f, y } = St(g, u);
|
|
1782
1788
|
t.moveTo(f, y), t.arc(f, y, this.options.magnetHandleRadius / r, 0, Math.PI * 2);
|
|
1783
1789
|
}), t.fill(), t.closePath();
|
|
1784
1790
|
});
|
|
1785
1791
|
m(this, "_onFeatureDrag", (t, r) => {
|
|
1786
|
-
const
|
|
1787
|
-
if (st(t) &&
|
|
1788
|
-
["start", "end"].find((
|
|
1789
|
-
const u =
|
|
1790
|
-
return this._snapToText(t,
|
|
1792
|
+
const o = r;
|
|
1793
|
+
if (st(t) && o === "line")
|
|
1794
|
+
["start", "end"].find((l) => {
|
|
1795
|
+
const u = l === "start" ? zt(t) : Xt(t);
|
|
1796
|
+
return this._snapToText(t, o, u) || this._findAndSnapToNode(t, l, u);
|
|
1791
1797
|
});
|
|
1792
|
-
else if (st(t) &&
|
|
1793
|
-
const
|
|
1794
|
-
this._snapToText(t,
|
|
1795
|
-
} else gt(t) && (this.activeLinks.forEach(({ arrow:
|
|
1796
|
-
const g = this.getAnnotation(
|
|
1798
|
+
else if (st(t) && o !== "line") {
|
|
1799
|
+
const l = o === "start" ? zt(t) : Xt(t);
|
|
1800
|
+
this._snapToText(t, o, l) || this._findAndSnapToNode(t, o, l);
|
|
1801
|
+
} else gt(t) && (this.activeLinks.forEach(({ arrow: l, side: u, connectionPoint: d }) => {
|
|
1802
|
+
const g = this.getAnnotation(l), f = ut(t), y = ct(t), v = Wt(d, { x: f.width, y: f.height }), k = rt(v, this.ogma.view.getAngle()), b = St(k, y);
|
|
1797
1803
|
g.geometry.coordinates[u === "start" ? 0 : 1] = [b.x, b.y];
|
|
1798
1804
|
}), this.activeLinks.length && this.arrows.refreshLayer());
|
|
1799
1805
|
this.layer.refresh(), this.emit(Kt, t, r);
|
|
1800
1806
|
});
|
|
1801
1807
|
m(this, "_onFeatureDragEnd", (t) => {
|
|
1802
1808
|
this.dragged !== null && st(t) && zt(this.dragged) && Ue.forEach((r) => {
|
|
1803
|
-
this.links.getArrowLink(t.id, r) && this.emit(
|
|
1809
|
+
this.links.getArrowLink(t.id, r) && this.emit(rr, {
|
|
1804
1810
|
arrow: t,
|
|
1805
1811
|
link: this.links.getArrowLink(t.id, r)
|
|
1806
1812
|
});
|
|
@@ -1808,24 +1814,24 @@ class vr extends nn {
|
|
|
1808
1814
|
});
|
|
1809
1815
|
m(this, "_onFeatureDragStart", (t) => {
|
|
1810
1816
|
this.textToMagnet = void 0, st(t) ? this.dragged = t : gt(t) && this.activeLinks.push(...this.links.getTargetLinks(t.id, "text")), this.annotations.forEach((r) => {
|
|
1811
|
-
const
|
|
1812
|
-
|
|
1817
|
+
const o = r.getSelectedFeature();
|
|
1818
|
+
o && o !== t && r.unhover().unselect(), r.disableDetection();
|
|
1813
1819
|
}), this.emit(Jt, t);
|
|
1814
1820
|
});
|
|
1815
1821
|
m(this, "_onNodesDragStart", () => {
|
|
1816
1822
|
this.arrows.unhover().unselect(), this.texts.unhover().unselect();
|
|
1817
1823
|
});
|
|
1818
1824
|
m(this, "_onNodesDrag", (t) => {
|
|
1819
|
-
const { dx: r, dy:
|
|
1820
|
-
this._moveNodes(t.nodes, r,
|
|
1825
|
+
const { dx: r, dy: o } = t;
|
|
1826
|
+
this._moveNodes(t.nodes, r, o);
|
|
1821
1827
|
});
|
|
1822
1828
|
m(this, "_onLayoutEnd", (t) => {
|
|
1823
|
-
t.ids.forEach((r,
|
|
1829
|
+
t.ids.forEach((r, o) => {
|
|
1824
1830
|
this.links.getTargetLinks(r, "node").forEach((u) => {
|
|
1825
1831
|
const d = this.getAnnotation(u.arrow), g = u.side, f = Vt(
|
|
1826
1832
|
d,
|
|
1827
1833
|
g === "start" ? "end" : "start"
|
|
1828
|
-
), y = t.positions.current[
|
|
1834
|
+
), y = t.positions.current[o], v = this.ogma.getNode(r).getAttribute("radius"), k = Ut(f, y, +v);
|
|
1829
1835
|
kt(d, g, k.x, k.y);
|
|
1830
1836
|
});
|
|
1831
1837
|
}), this.arrows.refreshLayer(), this.texts.refreshLayer();
|
|
@@ -1854,56 +1860,56 @@ class vr extends nn {
|
|
|
1854
1860
|
m(this, "_onUpdate", (t) => {
|
|
1855
1861
|
this.emit(ve, t);
|
|
1856
1862
|
});
|
|
1857
|
-
this.options = this.setOptions({ ...
|
|
1858
|
-
|
|
1863
|
+
this.options = this.setOptions({ ...pr, ...r }), this.ogma = t, this.arrows = new or(t, this.options), this.texts = new dr(t, this.options), this.annotations = [this.arrows, this.texts], this.annotations.forEach((o) => {
|
|
1864
|
+
o.on(Jt, this._onFeatureDragStart).on(Kt, this._onFeatureDrag).on(It, this._onFeatureDragEnd).on(ve, this.onUpdate).on(ge, this._onUnselect).on(pe, this._onSelect).on(me, this._onAdded).on(ye, this._onRemoved);
|
|
1859
1865
|
}), this.ogma.events.on("nodesDragStart", this._onNodesDragStart).on("nodesDragProgress", this._onNodesDrag).on("layoutEnd", this._onLayoutEnd).on(["viewChanged", "rotate"], () => {
|
|
1860
1866
|
this.refreshTextLinks();
|
|
1861
1867
|
}), this.layer = t.layers.addCanvasLayer(this._render), this.layer.moveToBottom();
|
|
1862
1868
|
}
|
|
1863
|
-
_moveNodes(t, r,
|
|
1864
|
-
t.forEach((
|
|
1865
|
-
const u = this.links.getTargetLinks(
|
|
1869
|
+
_moveNodes(t, r, o) {
|
|
1870
|
+
t.forEach((l) => {
|
|
1871
|
+
const u = this.links.getTargetLinks(l.getId(), "node"), d = l.getPosition();
|
|
1866
1872
|
u.forEach((g) => {
|
|
1867
1873
|
const f = this.getAnnotation(g.arrow), y = g.side, v = Vt(
|
|
1868
1874
|
f,
|
|
1869
1875
|
y === "start" ? "end" : "start"
|
|
1870
1876
|
);
|
|
1871
1877
|
let k = d;
|
|
1872
|
-
const b = +
|
|
1873
|
-
(g.connectionPoint.x - (d.x - r) > w || g.connectionPoint.y - (d.y -
|
|
1878
|
+
const b = +l.getAttribute("radius"), w = 1e-6;
|
|
1879
|
+
(g.connectionPoint.x - (d.x - r) > w || g.connectionPoint.y - (d.y - o) > w) && (k = Ut(v, d, b)), kt(f, y, k.x, k.y);
|
|
1874
1880
|
});
|
|
1875
1881
|
}), this.arrows.refreshLayer();
|
|
1876
1882
|
}
|
|
1877
|
-
_snapToText(t, r,
|
|
1878
|
-
const
|
|
1879
|
-
if (this.links.remove(t, r), !
|
|
1880
|
-
this.textToMagnet =
|
|
1881
|
-
const u = this.findMagnetPoint(We,
|
|
1882
|
-
return u ? (kt(t, r, u.point.x, u.point.y), this.links.add(t, r,
|
|
1883
|
+
_snapToText(t, r, o) {
|
|
1884
|
+
const l = this.texts.detect(o, this.options.detectMargin);
|
|
1885
|
+
if (this.links.remove(t, r), !l) return !1;
|
|
1886
|
+
this.textToMagnet = l;
|
|
1887
|
+
const u = this.findMagnetPoint(We, l, o);
|
|
1888
|
+
return u ? (kt(t, r, u.point.x, u.point.y), this.links.add(t, r, l.id, "text", u.magnet), !0) : !1;
|
|
1883
1889
|
}
|
|
1884
|
-
_findAndSnapToNode(t, r,
|
|
1890
|
+
_findAndSnapToNode(t, r, o) {
|
|
1885
1891
|
var d, g;
|
|
1886
|
-
const
|
|
1887
|
-
this.links.remove(t, r), u && u.isNode ? ((d = this.hoveredNode) == null || d.setSelected(!1), this.hoveredNode = u, u.setSelected(!0), this._snapToNode(t, r, u,
|
|
1892
|
+
const l = this.ogma.view.graphToScreenCoordinates(o), u = this.ogma.view.getElementAt(l);
|
|
1893
|
+
this.links.remove(t, r), u && u.isNode ? ((d = this.hoveredNode) == null || d.setSelected(!1), this.hoveredNode = u, u.setSelected(!0), this._snapToNode(t, r, u, l)) : ((g = this.hoveredNode) == null || g.setSelected(!1), this.hoveredNode = null);
|
|
1888
1894
|
}
|
|
1889
|
-
_snapToNode(t, r,
|
|
1890
|
-
const u =
|
|
1895
|
+
_snapToNode(t, r, o, l) {
|
|
1896
|
+
const u = o.getPositionOnScreen(), d = +o.getAttribute("radius"), g = d * this.ogma.view.getZoom(), f = l.x - u.x, y = l.y - u.y, v = Math.sqrt(f * f + y * y), k = o.getPosition();
|
|
1891
1897
|
if (v < g + this.options.detectMargin) {
|
|
1892
1898
|
let b = k;
|
|
1893
1899
|
if (v > g / 2) {
|
|
1894
1900
|
const w = Vt(t, r === "end" ? "start" : "end");
|
|
1895
1901
|
b = Ut(w, b, d);
|
|
1896
1902
|
}
|
|
1897
|
-
kt(t, r, b.x, b.y), this.links.add(t, r,
|
|
1903
|
+
kt(t, r, b.x, b.y), this.links.add(t, r, o.getId(), "node", b);
|
|
1898
1904
|
}
|
|
1899
1905
|
}
|
|
1900
1906
|
refreshTextLinks() {
|
|
1901
1907
|
let t = !1;
|
|
1902
1908
|
this.links.forEach(
|
|
1903
|
-
({ connectionPoint: r, targetType:
|
|
1904
|
-
if (
|
|
1909
|
+
({ connectionPoint: r, targetType: o, target: l, arrow: u, side: d }) => {
|
|
1910
|
+
if (o !== "text") return;
|
|
1905
1911
|
t = !0;
|
|
1906
|
-
const g = this.getAnnotation(
|
|
1912
|
+
const g = this.getAnnotation(l), f = this.getAnnotation(u), y = ut(g), v = ct(g), k = Wt(r, { x: y.width, y: y.height }), b = rt(k, this.ogma.view.getAngle()), w = St(b, v);
|
|
1907
1913
|
kt(f, d, w.x, w.y);
|
|
1908
1914
|
}
|
|
1909
1915
|
), t && this.arrows.refreshLayer();
|
|
@@ -1914,24 +1920,24 @@ class vr extends nn {
|
|
|
1914
1920
|
getSelected() {
|
|
1915
1921
|
return this.selected;
|
|
1916
1922
|
}
|
|
1917
|
-
findMagnetPoint(t, r,
|
|
1918
|
-
let
|
|
1923
|
+
findMagnetPoint(t, r, o) {
|
|
1924
|
+
let l;
|
|
1919
1925
|
for (const u of t) {
|
|
1920
|
-
const d = ut(r), g = ct(r), f = Wt(u, { x: d.width, y: d.height }), y = rt(f, this.ogma.view.getAngle()), v = St(y, g), k = Tt(wt(v,
|
|
1926
|
+
const d = ut(r), g = ct(r), f = Wt(u, { x: d.width, y: d.height }), y = rt(f, this.ogma.view.getAngle()), v = St(y, g), k = Tt(wt(v, o)), b = Math.min(
|
|
1921
1927
|
this.options.magnetRadius * this.ogma.view.getZoom(),
|
|
1922
1928
|
// when really zoomed in: avoid to snap on too far away magnets
|
|
1923
1929
|
d.width / 2,
|
|
1924
1930
|
d.height / 2
|
|
1925
1931
|
);
|
|
1926
1932
|
if (k < Math.max(b, this.options.magnetHandleRadius)) {
|
|
1927
|
-
|
|
1933
|
+
l = {
|
|
1928
1934
|
point: v,
|
|
1929
1935
|
magnet: u
|
|
1930
1936
|
};
|
|
1931
1937
|
break;
|
|
1932
1938
|
}
|
|
1933
1939
|
}
|
|
1934
|
-
return
|
|
1940
|
+
return l;
|
|
1935
1941
|
}
|
|
1936
1942
|
/**
|
|
1937
1943
|
* Set the options for the controller
|
|
@@ -1949,7 +1955,7 @@ class vr extends nn {
|
|
|
1949
1955
|
* @param id the id of the annotation to select
|
|
1950
1956
|
*/
|
|
1951
1957
|
select(t) {
|
|
1952
|
-
const r = this.getAnnotations().features.find((
|
|
1958
|
+
const r = this.getAnnotations().features.find((o) => o.id === t);
|
|
1953
1959
|
return r ? (st(r) ? this.arrows.select(r.id) : gt(r) && this.texts.select(r.id), this) : this;
|
|
1954
1960
|
}
|
|
1955
1961
|
/**
|
|
@@ -1964,11 +1970,11 @@ class vr extends nn {
|
|
|
1964
1970
|
*/
|
|
1965
1971
|
add(t) {
|
|
1966
1972
|
if (Ve(t)) {
|
|
1967
|
-
const [r,
|
|
1968
|
-
(
|
|
1973
|
+
const [r, o] = t.features.reduce(
|
|
1974
|
+
(l, u) => (st(u) ? l[1].push(u) : gt(u) && l[0].push(u), l),
|
|
1969
1975
|
[[], []]
|
|
1970
1976
|
);
|
|
1971
|
-
return r.forEach((
|
|
1977
|
+
return r.forEach((l) => this.add(l)), o.forEach((l) => this.add(l)), this.arrows.refreshLayer(), this;
|
|
1972
1978
|
}
|
|
1973
1979
|
switch (t.properties.type) {
|
|
1974
1980
|
case "text":
|
|
@@ -1993,15 +1999,15 @@ class vr extends nn {
|
|
|
1993
1999
|
loadLink(t) {
|
|
1994
2000
|
if (t.properties.link)
|
|
1995
2001
|
for (const r of Ue) {
|
|
1996
|
-
const
|
|
1997
|
-
if (!
|
|
1998
|
-
const
|
|
1999
|
-
if (
|
|
2000
|
-
this.links.add(t, r,
|
|
2001
|
-
else if (
|
|
2002
|
-
const u = this.ogma.getNode(
|
|
2002
|
+
const o = t.properties.link[r];
|
|
2003
|
+
if (!o) continue;
|
|
2004
|
+
const l = this.getAnnotation(o.id);
|
|
2005
|
+
if (o.type === "text" && l)
|
|
2006
|
+
this.links.add(t, r, o.id, o.type, o.magnet);
|
|
2007
|
+
else if (o.type === "node") {
|
|
2008
|
+
const u = this.ogma.getNode(o.id);
|
|
2003
2009
|
if (!u) continue;
|
|
2004
|
-
this.links.add(t, r,
|
|
2010
|
+
this.links.add(t, r, o.id, o.type, o.magnet);
|
|
2005
2011
|
const d = u.getPosition(), g = u.getAttribute("radius") || 0, f = Vt(
|
|
2006
2012
|
t,
|
|
2007
2013
|
r === "start" ? "end" : "start"
|
|
@@ -2016,8 +2022,8 @@ class vr extends nn {
|
|
|
2016
2022
|
* @param y coord of the first point
|
|
2017
2023
|
* @param arrow The arrow to add
|
|
2018
2024
|
*/
|
|
2019
|
-
startArrow(t, r,
|
|
2020
|
-
this.cancelDrawing(), this.arrows.startDrawing(t, r,
|
|
2025
|
+
startArrow(t, r, o) {
|
|
2026
|
+
this.cancelDrawing(), this.arrows.startDrawing(t, r, o);
|
|
2021
2027
|
}
|
|
2022
2028
|
/**
|
|
2023
2029
|
* Start adding a text (add it, and give control to the user)
|
|
@@ -2025,14 +2031,14 @@ class vr extends nn {
|
|
|
2025
2031
|
* @param y coord of the top left point
|
|
2026
2032
|
* @param text The text to add
|
|
2027
2033
|
*/
|
|
2028
|
-
startText(t, r,
|
|
2029
|
-
this.cancelDrawing(), this.texts.startDrawing(t, r,
|
|
2034
|
+
startText(t, r, o) {
|
|
2035
|
+
this.cancelDrawing(), this.texts.startDrawing(t, r, o);
|
|
2030
2036
|
}
|
|
2031
2037
|
/**
|
|
2032
2038
|
* Cancel drawing on the current frame
|
|
2033
2039
|
*/
|
|
2034
2040
|
cancelDrawing() {
|
|
2035
|
-
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(
|
|
2041
|
+
this.annotations.forEach((t) => t.cancelDrawing()), this.emit(nr);
|
|
2036
2042
|
}
|
|
2037
2043
|
/**
|
|
2038
2044
|
* Update the style of the annotation with the given id
|
|
@@ -2040,15 +2046,14 @@ class vr extends nn {
|
|
|
2040
2046
|
* @param style The new style
|
|
2041
2047
|
*/
|
|
2042
2048
|
updateStyle(t, r) {
|
|
2043
|
-
const
|
|
2044
|
-
return
|
|
2049
|
+
const o = this.getAnnotations().features.find((l) => l.id === t);
|
|
2050
|
+
return o ? (st(o) ? this.arrows.updateStyle(o, r) : gt(o) && this.texts.updateStyle(o, r), this.onUpdate(o), this) : this;
|
|
2045
2051
|
}
|
|
2046
|
-
setScale(t, r,
|
|
2052
|
+
setScale(t, r, o, l) {
|
|
2047
2053
|
const u = this.getAnnotations().features.find((d) => d.id === t);
|
|
2048
|
-
return u ? (st(u) ? this.arrows.scale(u, r,
|
|
2054
|
+
return u ? (st(u) ? this.arrows.scale(u, r, o, l) : gt(u) && this.texts.scale(u, r, o, l), this.onUpdate(u), this) : this;
|
|
2049
2055
|
}
|
|
2050
2056
|
/**
|
|
2051
|
-
*
|
|
2052
2057
|
* @returns the annotations in the controller
|
|
2053
2058
|
*/
|
|
2054
2059
|
getAnnotations() {
|
|
@@ -2076,33 +2081,33 @@ class vr extends nn {
|
|
|
2076
2081
|
}
|
|
2077
2082
|
}
|
|
2078
2083
|
export {
|
|
2079
|
-
|
|
2084
|
+
or as Arrows,
|
|
2080
2085
|
vr as Control,
|
|
2081
2086
|
me as EVT_ADD,
|
|
2082
|
-
|
|
2087
|
+
nr as EVT_CANCEL_DRAWING,
|
|
2083
2088
|
Kt as EVT_DRAG,
|
|
2084
2089
|
It as EVT_DRAG_END,
|
|
2085
2090
|
Jt as EVT_DRAG_START,
|
|
2086
|
-
|
|
2087
|
-
|
|
2091
|
+
tr as EVT_HOVER,
|
|
2092
|
+
rr as EVT_LINK,
|
|
2088
2093
|
ye as EVT_REMOVE,
|
|
2089
2094
|
pe as EVT_SELECT,
|
|
2090
|
-
|
|
2095
|
+
er as EVT_UNHOVER,
|
|
2091
2096
|
ge as EVT_UNSELECT,
|
|
2092
2097
|
ve as EVT_UPDATE,
|
|
2093
2098
|
W as NONE,
|
|
2094
|
-
|
|
2099
|
+
dr as Texts,
|
|
2095
2100
|
fe as clientToContainerPosition,
|
|
2096
|
-
|
|
2101
|
+
mr as colorToRgba,
|
|
2097
2102
|
qn as createArrow,
|
|
2098
2103
|
xt as createSVGElement,
|
|
2099
|
-
|
|
2104
|
+
ar as createText,
|
|
2100
2105
|
Oe as defaultArrowOptions,
|
|
2101
2106
|
Nt as defaultArrowStyle,
|
|
2102
2107
|
Re as defaultControllerOptions,
|
|
2103
2108
|
ce as defaultTextOptions,
|
|
2104
2109
|
_t as defaultTextStyle,
|
|
2105
|
-
|
|
2110
|
+
yr as getAnnotationsBounds,
|
|
2106
2111
|
Xt as getArrowEnd,
|
|
2107
2112
|
Zt as getArrowEndPoints,
|
|
2108
2113
|
Vt as getArrowSide,
|
|
@@ -2112,12 +2117,12 @@ export {
|
|
|
2112
2117
|
Ge as getTextBbox,
|
|
2113
2118
|
ct as getTextPosition,
|
|
2114
2119
|
ut as getTextSize,
|
|
2115
|
-
|
|
2116
|
-
|
|
2120
|
+
Gn as hexShortToLong,
|
|
2121
|
+
Yn as hexToRgba,
|
|
2117
2122
|
Ve as isAnnotationCollection,
|
|
2118
2123
|
st as isArrow,
|
|
2119
2124
|
gt as isText,
|
|
2120
|
-
|
|
2125
|
+
Xn as rgbToRgba,
|
|
2121
2126
|
Wn as scaleGeometry,
|
|
2122
2127
|
Xe as setArrowEnd,
|
|
2123
2128
|
kt as setArrowEndPoint,
|