@soomo/text-annotator 3.0.0-staging.47 → 3.0.0-staging.48
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.
|
@@ -20,27 +20,27 @@ function oe(t, e = 100, n = {}) {
|
|
|
20
20
|
throw new RangeError("`wait` must not be negative.");
|
|
21
21
|
const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
|
|
22
22
|
let i, r, a, s, l;
|
|
23
|
-
function
|
|
24
|
-
const p = i,
|
|
25
|
-
return i = void 0, r = void 0, l = t.apply(p,
|
|
23
|
+
function f() {
|
|
24
|
+
const p = i, u = r;
|
|
25
|
+
return i = void 0, r = void 0, l = t.apply(p, u), l;
|
|
26
26
|
}
|
|
27
27
|
function g() {
|
|
28
28
|
const p = Date.now() - s;
|
|
29
|
-
p < e && p >= 0 ? a = setTimeout(g, e - p) : (a = void 0, o || (l =
|
|
29
|
+
p < e && p >= 0 ? a = setTimeout(g, e - p) : (a = void 0, o || (l = f()));
|
|
30
30
|
}
|
|
31
31
|
const c = function(...p) {
|
|
32
32
|
if (i && this !== i)
|
|
33
33
|
throw new Error("Debounced method called with different contexts.");
|
|
34
34
|
i = this, r = p, s = Date.now();
|
|
35
|
-
const
|
|
36
|
-
return a || (a = setTimeout(g, e)),
|
|
35
|
+
const u = o && !a;
|
|
36
|
+
return a || (a = setTimeout(g, e)), u && (l = f()), l;
|
|
37
37
|
};
|
|
38
38
|
return c.clear = () => {
|
|
39
39
|
a && (clearTimeout(a), a = void 0);
|
|
40
40
|
}, c.flush = () => {
|
|
41
41
|
a && c.trigger();
|
|
42
42
|
}, c.trigger = () => {
|
|
43
|
-
l =
|
|
43
|
+
l = f(), c.clear();
|
|
44
44
|
}, c;
|
|
45
45
|
}
|
|
46
46
|
Nt.exports.debounce = oe;
|
|
@@ -57,31 +57,31 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
57
57
|
};
|
|
58
58
|
}, _t = (t, e, n, o) => {
|
|
59
59
|
const { store: i, selection: r, hover: a } = e;
|
|
60
|
-
let s, l,
|
|
60
|
+
let s, l, f;
|
|
61
61
|
const g = Le(n), c = (L) => {
|
|
62
62
|
const { x: T, y: m } = t.getBoundingClientRect(), A = i.getAt(L.clientX - T, L.clientY - m, l);
|
|
63
63
|
A ? a.current !== A.id && (t.classList.add("hovered"), a.set(A.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
64
64
|
};
|
|
65
65
|
t.addEventListener("pointermove", c);
|
|
66
66
|
const p = (L = !1) => {
|
|
67
|
-
|
|
67
|
+
f && f.clear();
|
|
68
68
|
const T = Ce(t), { minX: m, minY: A, maxX: S, maxY: C } = T, R = l ? i.getIntersecting(m, A, S, C).filter(({ annotation: Y }) => l(Y)) : i.getIntersecting(m, A, S, C), N = r.selected.map(({ id: Y }) => Y), $ = R.map(({ annotation: Y, rects: we }) => {
|
|
69
69
|
const ve = N.includes(Y.id), xe = Y.id === a.current;
|
|
70
70
|
return { annotation: Y, rects: we, state: { selected: ve, hover: xe } };
|
|
71
71
|
});
|
|
72
|
-
o.redraw($, T, s,
|
|
73
|
-
},
|
|
74
|
-
|
|
72
|
+
o.redraw($, T, s, f, L), setTimeout(() => g(R.map(({ annotation: Y }) => Y)), 1);
|
|
73
|
+
}, u = (L) => {
|
|
74
|
+
f = L, p();
|
|
75
75
|
}, x = (L) => {
|
|
76
76
|
s = L, p();
|
|
77
|
-
},
|
|
77
|
+
}, b = (L) => {
|
|
78
78
|
l = L, p(!1);
|
|
79
|
-
},
|
|
80
|
-
i.observe(
|
|
81
|
-
const h = r.subscribe(() => p()),
|
|
82
|
-
document.addEventListener("scroll",
|
|
79
|
+
}, v = () => p();
|
|
80
|
+
i.observe(v);
|
|
81
|
+
const h = r.subscribe(() => p()), d = () => p(!0);
|
|
82
|
+
document.addEventListener("scroll", d, { capture: !0, passive: !0 });
|
|
83
83
|
const y = It(() => {
|
|
84
|
-
i.recalculatePositions(),
|
|
84
|
+
i.recalculatePositions(), f && f.reset(), p();
|
|
85
85
|
}, 10);
|
|
86
86
|
window.addEventListener("resize", y);
|
|
87
87
|
const E = new ResizeObserver(y);
|
|
@@ -91,12 +91,12 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
91
91
|
});
|
|
92
92
|
return O.observe(document.body, w), {
|
|
93
93
|
destroy: () => {
|
|
94
|
-
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(
|
|
94
|
+
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(v), h(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), E.disconnect(), O.disconnect();
|
|
95
95
|
},
|
|
96
96
|
redraw: p,
|
|
97
97
|
setStyle: x,
|
|
98
|
-
setFilter:
|
|
99
|
-
setPainter:
|
|
98
|
+
setFilter: b,
|
|
99
|
+
setPainter: u,
|
|
100
100
|
setVisible: o.setVisible
|
|
101
101
|
};
|
|
102
102
|
}, Oe = () => {
|
|
@@ -108,26 +108,26 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
108
108
|
t.classList.add("r6o-annotatable");
|
|
109
109
|
const e = Oe(), n = e.getContext("2d");
|
|
110
110
|
document.body.appendChild(e);
|
|
111
|
-
const o = (s, l,
|
|
111
|
+
const o = (s, l, f, g) => requestAnimationFrame(() => {
|
|
112
112
|
const { width: c, height: p } = e;
|
|
113
113
|
n.clearRect(-0.5, -0.5, c + 1, p + 1), g && g.clear();
|
|
114
|
-
const { top:
|
|
115
|
-
[...s].sort((
|
|
116
|
-
const { annotation: { target: { created:
|
|
117
|
-
return
|
|
118
|
-
}).forEach((
|
|
114
|
+
const { top: u, left: x } = l;
|
|
115
|
+
[...s].sort((v, h) => {
|
|
116
|
+
const { annotation: { target: { created: d } } } = v, { annotation: { target: { created: y } } } = h;
|
|
117
|
+
return d.getTime() - y.getTime();
|
|
118
|
+
}).forEach((v) => {
|
|
119
119
|
var E;
|
|
120
|
-
const h =
|
|
120
|
+
const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (E = v.state) != null && E.selected ? gt : q, d = g && g.paint(v, l) || h, y = v.rects.map(({ x: w, y: O, width: B, height: L }) => ({
|
|
121
121
|
x: w + x,
|
|
122
|
-
y: O +
|
|
122
|
+
y: O + u,
|
|
123
123
|
width: B,
|
|
124
124
|
height: L
|
|
125
125
|
}));
|
|
126
|
-
if (n.fillStyle =
|
|
126
|
+
if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, y.forEach(
|
|
127
127
|
({ x: w, y: O, width: B, height: L }) => n.fillRect(w, O, B, L)
|
|
128
|
-
),
|
|
129
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
130
|
-
const w =
|
|
128
|
+
), d.underlineColor) {
|
|
129
|
+
n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
|
|
130
|
+
const w = d.underlineOffset ?? 0;
|
|
131
131
|
y.forEach(({ x: O, y: B, width: L, height: T }) => {
|
|
132
132
|
n.beginPath(), n.moveTo(O, B + T + w), n.lineTo(O + L, B + T + w), n.stroke();
|
|
133
133
|
});
|
|
@@ -165,8 +165,8 @@ var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
165
165
|
}, se = function(t) {
|
|
166
166
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
167
167
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
168
|
-
var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), l = o * (1 - (1 - e + r) * n),
|
|
169
|
-
return { r: 255 * [o, s, a, a, l, o][
|
|
168
|
+
var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), l = o * (1 - (1 - e + r) * n), f = r % 6;
|
|
169
|
+
return { r: 255 * [o, s, a, a, l, o][f], g: 255 * [l, o, o, s, a, a][f], b: 255 * [a, a, l, o, o, s][f], a: i };
|
|
170
170
|
}, Yt = function(t) {
|
|
171
171
|
return { h: ie(t.h), s: K(t.s, 0, 100), l: K(t.l, 0, 100), a: K(t.a) };
|
|
172
172
|
}, Kt = function(t) {
|
|
@@ -293,18 +293,18 @@ const De = (t) => [
|
|
|
293
293
|
},
|
|
294
294
|
redraw: (r, a, s, l) => {
|
|
295
295
|
l && l.clear();
|
|
296
|
-
const
|
|
297
|
-
Array.from(e).filter((c) => !
|
|
296
|
+
const f = new Set(r.map((c) => c.annotation.id));
|
|
297
|
+
Array.from(e).filter((c) => !f.has(c));
|
|
298
298
|
const g = r.map((c) => {
|
|
299
299
|
var x;
|
|
300
|
-
const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? gt : q,
|
|
301
|
-
return `::highlight(_${c.annotation.id}) { ${De(
|
|
300
|
+
const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? gt : q, u = l && l.paint(c, a) || p;
|
|
301
|
+
return `::highlight(_${c.annotation.id}) { ${De(u)} }`;
|
|
302
302
|
});
|
|
303
303
|
t.innerHTML = g.join(`
|
|
304
304
|
`), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
|
|
305
|
-
const p = c.target.selector.map((x) => x.range),
|
|
306
|
-
CSS.highlights.set(`_${c.id}`,
|
|
307
|
-
}), e =
|
|
305
|
+
const p = c.target.selector.map((x) => x.range), u = new Highlight(...p);
|
|
306
|
+
CSS.highlights.set(`_${c.id}`, u);
|
|
307
|
+
}), e = f;
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
310
|
}, Ke = (t, e, n) => _t(t, e, n, Ye());
|
|
@@ -341,17 +341,21 @@ const Xe = (t, e) => {
|
|
|
341
341
|
destroy: () => {
|
|
342
342
|
e.remove();
|
|
343
343
|
},
|
|
344
|
-
redraw: (a, s, l,
|
|
344
|
+
redraw: (a, s, l, f, g) => {
|
|
345
345
|
const p = !(Bt(n, a) && g);
|
|
346
|
-
!
|
|
347
|
-
|
|
348
|
-
|
|
346
|
+
if (!f && !p) return;
|
|
347
|
+
p && (e.innerHTML = ""), [...a].sort((x, b) => {
|
|
348
|
+
const { annotation: { target: { created: v } } } = x, { annotation: { target: { created: h } } } = b;
|
|
349
|
+
return v.getTime() - h.getTime();
|
|
350
|
+
}).forEach((x) => {
|
|
351
|
+
x.rects.map((b) => {
|
|
352
|
+
const v = Xe(b, a), h = Ae(x, s, l, f, v);
|
|
349
353
|
if (p) {
|
|
350
|
-
const
|
|
351
|
-
|
|
354
|
+
const d = document.createElement("span");
|
|
355
|
+
d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = X((h == null ? void 0 : h.fill) || q.fill).alpha((h == null ? void 0 : h.fillOpacity) === void 0 ? q.fillOpacity : h.fillOpacity).toHex(), h.underlineStyle && (d.style.borderStyle = h.underlineStyle), h.underlineColor && (d.style.borderColor = h.underlineColor), h.underlineThickness && (d.style.borderBottomWidth = `${h.underlineThickness}px`), h.underlineOffset && (d.style.paddingBottom = `${h.underlineOffset}px`), e.appendChild(d);
|
|
352
356
|
}
|
|
353
357
|
});
|
|
354
|
-
}), n = a
|
|
358
|
+
}), n = a;
|
|
355
359
|
},
|
|
356
360
|
setVisible: (a) => {
|
|
357
361
|
a ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
@@ -414,11 +418,11 @@ function Ut(t, e = xt) {
|
|
|
414
418
|
function i(s) {
|
|
415
419
|
if (We(t, s) && (t = s, n)) {
|
|
416
420
|
const l = !G.length;
|
|
417
|
-
for (const
|
|
418
|
-
|
|
421
|
+
for (const f of o)
|
|
422
|
+
f[1](), G.push(f, t);
|
|
419
423
|
if (l) {
|
|
420
|
-
for (let
|
|
421
|
-
G[
|
|
424
|
+
for (let f = 0; f < G.length; f += 2)
|
|
425
|
+
G[f][0](G[f + 1]);
|
|
422
426
|
G.length = 0;
|
|
423
427
|
}
|
|
424
428
|
}
|
|
@@ -427,9 +431,9 @@ function Ut(t, e = xt) {
|
|
|
427
431
|
i(s(t));
|
|
428
432
|
}
|
|
429
433
|
function a(s, l = xt) {
|
|
430
|
-
const
|
|
431
|
-
return o.add(
|
|
432
|
-
o.delete(
|
|
434
|
+
const f = [s, l];
|
|
435
|
+
return o.add(f), o.size === 1 && (n = e(i, r) || xt), s(t), () => {
|
|
436
|
+
o.delete(f), o.size === 0 && n && (n(), n = null);
|
|
433
437
|
};
|
|
434
438
|
}
|
|
435
439
|
return { set: i, update: r, subscribe: a };
|
|
@@ -455,47 +459,47 @@ var Ge = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE =
|
|
|
455
459
|
const At = { selected: [] }, Qe = (t, e = "EDIT") => {
|
|
456
460
|
const { subscribe: n, set: o } = Ut(At);
|
|
457
461
|
let i = e, r = At;
|
|
458
|
-
n((
|
|
462
|
+
n((u) => r = u);
|
|
459
463
|
const a = () => o(At), s = () => {
|
|
460
|
-
var
|
|
461
|
-
return ((
|
|
462
|
-
}, l = (
|
|
464
|
+
var u;
|
|
465
|
+
return ((u = r.selected) == null ? void 0 : u.length) === 0;
|
|
466
|
+
}, l = (u) => {
|
|
463
467
|
if (s())
|
|
464
468
|
return !1;
|
|
465
|
-
const x = typeof
|
|
466
|
-
return r.selected.some((
|
|
467
|
-
},
|
|
468
|
-
const
|
|
469
|
-
if (!
|
|
470
|
-
console.warn("Invalid selection: " +
|
|
469
|
+
const x = typeof u == "string" ? u : u.id;
|
|
470
|
+
return r.selected.some((b) => b.id === x);
|
|
471
|
+
}, f = (u, x) => {
|
|
472
|
+
const b = t.getAnnotation(u);
|
|
473
|
+
if (!b) {
|
|
474
|
+
console.warn("Invalid selection: " + u);
|
|
471
475
|
return;
|
|
472
476
|
}
|
|
473
|
-
switch (qt(
|
|
477
|
+
switch (qt(b, i)) {
|
|
474
478
|
case "EDIT":
|
|
475
|
-
o({ selected: [{ id:
|
|
479
|
+
o({ selected: [{ id: u, editable: !0 }], event: x });
|
|
476
480
|
break;
|
|
477
481
|
case "SELECT":
|
|
478
|
-
o({ selected: [{ id:
|
|
482
|
+
o({ selected: [{ id: u }], event: x });
|
|
479
483
|
break;
|
|
480
484
|
default:
|
|
481
485
|
o({ selected: [], event: x });
|
|
482
486
|
}
|
|
483
|
-
}, g = (
|
|
484
|
-
const
|
|
487
|
+
}, g = (u, x) => {
|
|
488
|
+
const b = Array.isArray(u) ? u : [u], v = b.map((h) => t.getAnnotation(h)).filter((h) => !!h);
|
|
485
489
|
o({
|
|
486
|
-
selected:
|
|
487
|
-
const
|
|
488
|
-
return { id: h.id, editable:
|
|
490
|
+
selected: v.map((h) => {
|
|
491
|
+
const d = x === void 0 ? qt(h, i) === "EDIT" : x;
|
|
492
|
+
return { id: h.id, editable: d };
|
|
489
493
|
})
|
|
490
|
-
}),
|
|
491
|
-
}, c = (
|
|
494
|
+
}), v.length !== b.length && console.warn("Invalid selection", u);
|
|
495
|
+
}, c = (u) => {
|
|
492
496
|
if (s())
|
|
493
497
|
return !1;
|
|
494
498
|
const { selected: x } = r;
|
|
495
|
-
x.some(({ id:
|
|
496
|
-
}, p = (
|
|
499
|
+
x.some(({ id: b }) => u.includes(b)) && o({ selected: x.filter(({ id: b }) => !u.includes(b)) });
|
|
500
|
+
}, p = (u) => i = u;
|
|
497
501
|
return t.observe(
|
|
498
|
-
({ changes:
|
|
502
|
+
({ changes: u }) => c((u.deleted || []).map((x) => x.id))
|
|
499
503
|
), {
|
|
500
504
|
get event() {
|
|
501
505
|
return r ? r.event : null;
|
|
@@ -509,7 +513,7 @@ const At = { selected: [] }, Qe = (t, e = "EDIT") => {
|
|
|
509
513
|
setSelected: g,
|
|
510
514
|
setUserSelectAction: p,
|
|
511
515
|
subscribe: n,
|
|
512
|
-
userSelect:
|
|
516
|
+
userSelect: f
|
|
513
517
|
};
|
|
514
518
|
}, qt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
515
519
|
var V = [];
|
|
@@ -570,8 +574,8 @@ const cn = (t, e) => {
|
|
|
570
574
|
if (t.options.ignore) {
|
|
571
575
|
const { ignore: a } = t.options, s = (l) => l && l.length > 0;
|
|
572
576
|
if (!(s(i.created) || s(i.deleted))) {
|
|
573
|
-
const l = (n = i.updated) == null ? void 0 : n.some((g) => s(g.bodiesCreated) || s(g.bodiesDeleted) || s(g.bodiesUpdated)),
|
|
574
|
-
if (a === "BODY_ONLY" && l && !
|
|
577
|
+
const l = (n = i.updated) == null ? void 0 : n.some((g) => s(g.bodiesCreated) || s(g.bodiesDeleted) || s(g.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((g) => g.targetUpdated);
|
|
578
|
+
if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
|
|
575
579
|
return !1;
|
|
576
580
|
}
|
|
577
581
|
}
|
|
@@ -588,21 +592,21 @@ const cn = (t, e) => {
|
|
|
588
592
|
const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), r = new Set((e.deleted || []).map((c) => c.id)), a = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), s = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), l = [
|
|
589
593
|
...(t.created || []).filter((c) => !r.has(c.id)).map((c) => a.has(c.id) ? e.updated.find(({ oldValue: p }) => p.id === c.id).newValue : c),
|
|
590
594
|
...e.created || []
|
|
591
|
-
],
|
|
595
|
+
], f = [
|
|
592
596
|
...(t.deleted || []).filter((c) => !i.has(c.id)),
|
|
593
597
|
...(e.deleted || []).filter((c) => !n.has(c.id))
|
|
594
598
|
], g = [
|
|
595
599
|
...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
|
|
596
|
-
const { oldValue: p, newValue:
|
|
597
|
-
if (a.has(
|
|
598
|
-
const x = e.updated.find((
|
|
600
|
+
const { oldValue: p, newValue: u } = c;
|
|
601
|
+
if (a.has(u.id)) {
|
|
602
|
+
const x = e.updated.find((b) => b.oldValue.id === u.id).newValue;
|
|
599
603
|
return ce(p, x);
|
|
600
604
|
} else
|
|
601
605
|
return c;
|
|
602
606
|
}),
|
|
603
607
|
...(e.updated || []).filter(({ oldValue: c }) => !s.has(c.id))
|
|
604
608
|
];
|
|
605
|
-
return { created: l, deleted:
|
|
609
|
+
return { created: l, deleted: f, updated: g };
|
|
606
610
|
}, dn = (t) => t.id !== void 0, un = () => {
|
|
607
611
|
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, A = {}) => n.push({ onChange: m, options: A }), i = (m) => {
|
|
608
612
|
const A = n.findIndex((S) => S.onChange == m);
|
|
@@ -634,7 +638,7 @@ const cn = (t, e) => {
|
|
|
634
638
|
}, l = (m, A = M.LOCAL, S = M.LOCAL) => {
|
|
635
639
|
const C = dn(A) ? S : A, R = s(m, A);
|
|
636
640
|
R && r(C, { updated: [R] });
|
|
637
|
-
},
|
|
641
|
+
}, f = (m, A = M.LOCAL) => {
|
|
638
642
|
const S = m.reduce((C, R) => {
|
|
639
643
|
const N = s(R);
|
|
640
644
|
return N ? [...C, N] : C;
|
|
@@ -657,7 +661,7 @@ const cn = (t, e) => {
|
|
|
657
661
|
}, c = () => [...t.values()], p = (m = M.LOCAL) => {
|
|
658
662
|
const A = [...t.values()];
|
|
659
663
|
t.clear(), e.clear(), r(m, { deleted: A });
|
|
660
|
-
},
|
|
664
|
+
}, u = (m, A = !0, S = M.LOCAL) => {
|
|
661
665
|
if (A) {
|
|
662
666
|
const C = [...t.values()];
|
|
663
667
|
t.clear(), e.clear(), m.forEach((R) => {
|
|
@@ -679,10 +683,10 @@ const cn = (t, e) => {
|
|
|
679
683
|
if (S)
|
|
680
684
|
return t.delete(A), S.bodies.forEach((C) => e.delete(C.id)), S;
|
|
681
685
|
console.warn(`Attempt to delete missing annotation: ${A}`);
|
|
682
|
-
},
|
|
686
|
+
}, b = (m, A = M.LOCAL) => {
|
|
683
687
|
const S = x(m);
|
|
684
688
|
S && r(A, { deleted: [S] });
|
|
685
|
-
},
|
|
689
|
+
}, v = (m, A = M.LOCAL) => {
|
|
686
690
|
const S = m.reduce((C, R) => {
|
|
687
691
|
const N = x(R);
|
|
688
692
|
return N ? [...C, N] : C;
|
|
@@ -707,7 +711,7 @@ const cn = (t, e) => {
|
|
|
707
711
|
console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
|
|
708
712
|
} else
|
|
709
713
|
console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
|
|
710
|
-
},
|
|
714
|
+
}, d = (m, A = M.LOCAL) => {
|
|
711
715
|
const S = h(m);
|
|
712
716
|
S && r(A, { updated: [S] });
|
|
713
717
|
}, y = (m, A = M.LOCAL) => {
|
|
@@ -772,18 +776,18 @@ const cn = (t, e) => {
|
|
|
772
776
|
addAnnotation: a,
|
|
773
777
|
addBody: g,
|
|
774
778
|
all: c,
|
|
775
|
-
bulkAddAnnotation:
|
|
776
|
-
bulkDeleteAnnotation:
|
|
779
|
+
bulkAddAnnotation: u,
|
|
780
|
+
bulkDeleteAnnotation: v,
|
|
777
781
|
bulkDeleteBodies: y,
|
|
778
|
-
bulkUpdateAnnotation:
|
|
782
|
+
bulkUpdateAnnotation: f,
|
|
779
783
|
bulkUpdateBodies: L,
|
|
780
784
|
bulkUpdateTargets: (m, A = M.LOCAL) => {
|
|
781
785
|
const S = m.map((C) => T(C)).filter(Boolean);
|
|
782
786
|
S.length > 0 && r(A, { updated: S });
|
|
783
787
|
},
|
|
784
788
|
clear: p,
|
|
785
|
-
deleteAnnotation:
|
|
786
|
-
deleteBody:
|
|
789
|
+
deleteAnnotation: b,
|
|
790
|
+
deleteBody: d,
|
|
787
791
|
getAnnotation: E,
|
|
788
792
|
getBody: w,
|
|
789
793
|
observe: o,
|
|
@@ -813,38 +817,38 @@ let fn = () => ({
|
|
|
813
817
|
const hn = 250, pn = (t) => {
|
|
814
818
|
const e = fn(), n = [];
|
|
815
819
|
let o = -1, i = !1, r = 0;
|
|
816
|
-
const a = (
|
|
820
|
+
const a = (u) => {
|
|
817
821
|
if (!i) {
|
|
818
|
-
const { changes: x } =
|
|
819
|
-
if (
|
|
822
|
+
const { changes: x } = u, b = performance.now();
|
|
823
|
+
if (b - r > hn)
|
|
820
824
|
n.splice(o + 1), n.push(x), o = n.length - 1;
|
|
821
825
|
else {
|
|
822
|
-
const
|
|
823
|
-
n[
|
|
826
|
+
const v = n.length - 1;
|
|
827
|
+
n[v] = ln(n[v], x);
|
|
824
828
|
}
|
|
825
|
-
r =
|
|
829
|
+
r = b;
|
|
826
830
|
}
|
|
827
831
|
i = !1;
|
|
828
832
|
};
|
|
829
833
|
t.observe(a, { origin: M.LOCAL });
|
|
830
|
-
const s = (
|
|
834
|
+
const s = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u), l = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), f = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ oldValue: x }) => x)), g = (u) => u && u.length > 0 && t.bulkUpdateAnnotation(u.map(({ newValue: x }) => x)), c = (u) => u && u.length > 0 && t.bulkAddAnnotation(u, !1), p = (u) => u && u.length > 0 && t.bulkDeleteAnnotation(u);
|
|
831
835
|
return {
|
|
832
836
|
canRedo: () => n.length - 1 > o,
|
|
833
837
|
canUndo: () => o > -1,
|
|
834
838
|
destroy: () => t.unobserve(a),
|
|
835
|
-
on: (
|
|
839
|
+
on: (u, x) => e.on(u, x),
|
|
836
840
|
redo: () => {
|
|
837
841
|
if (n.length - 1 > o) {
|
|
838
842
|
i = !0;
|
|
839
|
-
const { created:
|
|
840
|
-
l(
|
|
843
|
+
const { created: u, updated: x, deleted: b } = n[o + 1];
|
|
844
|
+
l(u), g(x), p(b), e.emit("redo", n[o + 1]), o += 1;
|
|
841
845
|
}
|
|
842
846
|
},
|
|
843
847
|
undo: () => {
|
|
844
848
|
if (o > -1) {
|
|
845
849
|
i = !0;
|
|
846
|
-
const { created:
|
|
847
|
-
s(
|
|
850
|
+
const { created: u, updated: x, deleted: b } = n[o];
|
|
851
|
+
s(u), f(x), c(b), e.emit("undo", n[o]), o -= 1;
|
|
848
852
|
}
|
|
849
853
|
}
|
|
850
854
|
};
|
|
@@ -856,72 +860,72 @@ const hn = 250, pn = (t) => {
|
|
|
856
860
|
};
|
|
857
861
|
}, mn = (t, e, n, o) => {
|
|
858
862
|
const { store: i, selection: r, hover: a, viewport: s } = t, l = /* @__PURE__ */ new Map();
|
|
859
|
-
let
|
|
860
|
-
const c = (
|
|
861
|
-
l.has(
|
|
862
|
-
}, p = (
|
|
863
|
-
const h = l.get(
|
|
863
|
+
let f = [], g;
|
|
864
|
+
const c = (b, v) => {
|
|
865
|
+
l.has(b) ? l.get(b).push(v) : l.set(b, [v]);
|
|
866
|
+
}, p = (b, v) => {
|
|
867
|
+
const h = l.get(b);
|
|
864
868
|
if (h) {
|
|
865
|
-
const
|
|
866
|
-
|
|
869
|
+
const d = h.indexOf(v);
|
|
870
|
+
d !== -1 && h.splice(d, 1);
|
|
867
871
|
}
|
|
868
|
-
},
|
|
869
|
-
l.has(
|
|
870
|
-
l.get(
|
|
872
|
+
}, u = (b, v, h) => {
|
|
873
|
+
l.has(b) && setTimeout(() => {
|
|
874
|
+
l.get(b).forEach((d) => {
|
|
871
875
|
if (n) {
|
|
872
|
-
const y = Array.isArray(
|
|
873
|
-
|
|
876
|
+
const y = Array.isArray(v) ? v.map((w) => n.serialize(w)) : n.serialize(v), E = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
|
|
877
|
+
d(y, E);
|
|
874
878
|
} else
|
|
875
|
-
|
|
879
|
+
d(v, h);
|
|
876
880
|
});
|
|
877
881
|
}, 1);
|
|
878
882
|
};
|
|
879
|
-
r.subscribe(({ selected:
|
|
880
|
-
if (!(
|
|
881
|
-
if (
|
|
882
|
-
|
|
883
|
-
else if (
|
|
884
|
-
|
|
885
|
-
const h = i.getAnnotation(
|
|
886
|
-
h && !Z(h,
|
|
887
|
-
}),
|
|
883
|
+
r.subscribe(({ selected: b }) => {
|
|
884
|
+
if (!(f.length === 0 && b.length === 0)) {
|
|
885
|
+
if (f.length === 0 && b.length > 0)
|
|
886
|
+
f = b.map(({ id: v }) => i.getAnnotation(v));
|
|
887
|
+
else if (f.length > 0 && b.length === 0)
|
|
888
|
+
f.forEach((v) => {
|
|
889
|
+
const h = i.getAnnotation(v.id);
|
|
890
|
+
h && !Z(h, v) && u("updateAnnotation", h, v);
|
|
891
|
+
}), f = [];
|
|
888
892
|
else {
|
|
889
|
-
const
|
|
890
|
-
|
|
891
|
-
const y = i.getAnnotation(
|
|
892
|
-
y && !Z(y,
|
|
893
|
-
}),
|
|
893
|
+
const v = new Set(f.map((d) => d.id)), h = new Set(b.map(({ id: d }) => d));
|
|
894
|
+
f.filter((d) => !h.has(d.id)).forEach((d) => {
|
|
895
|
+
const y = i.getAnnotation(d.id);
|
|
896
|
+
y && !Z(y, d) && u("updateAnnotation", y, d);
|
|
897
|
+
}), f = [
|
|
894
898
|
// Remove annotations that were deselected
|
|
895
|
-
...
|
|
899
|
+
...f.filter((d) => h.has(d.id)),
|
|
896
900
|
// Add editable annotations that were selected
|
|
897
|
-
...
|
|
901
|
+
...b.filter(({ id: d }) => !v.has(d)).map(({ id: d }) => i.getAnnotation(d))
|
|
898
902
|
];
|
|
899
903
|
}
|
|
900
|
-
|
|
904
|
+
u("selectionChanged", f);
|
|
901
905
|
}
|
|
902
|
-
}), a.subscribe((
|
|
903
|
-
!g &&
|
|
904
|
-
}), s == null || s.subscribe((
|
|
905
|
-
const { created:
|
|
906
|
-
(
|
|
907
|
-
...
|
|
908
|
-
...
|
|
909
|
-
...
|
|
910
|
-
].length > 0).forEach(({ oldValue:
|
|
911
|
-
const E =
|
|
912
|
-
|
|
906
|
+
}), a.subscribe((b) => {
|
|
907
|
+
!g && b ? u("mouseEnterAnnotation", i.getAnnotation(b)) : g && !b ? u("mouseLeaveAnnotation", i.getAnnotation(g)) : g && b && (u("mouseLeaveAnnotation", i.getAnnotation(g)), u("mouseEnterAnnotation", i.getAnnotation(b))), g = b;
|
|
908
|
+
}), s == null || s.subscribe((b) => u("viewportIntersect", b.map((v) => i.getAnnotation(v)))), i.observe((b) => {
|
|
909
|
+
const { created: v, deleted: h } = b.changes;
|
|
910
|
+
(v || []).forEach((d) => u("createAnnotation", d)), (h || []).forEach((d) => u("deleteAnnotation", d)), (b.changes.updated || []).filter((d) => [
|
|
911
|
+
...d.bodiesCreated || [],
|
|
912
|
+
...d.bodiesDeleted || [],
|
|
913
|
+
...d.bodiesUpdated || []
|
|
914
|
+
].length > 0).forEach(({ oldValue: d, newValue: y }) => {
|
|
915
|
+
const E = f.find((w) => w.id === d.id) || d;
|
|
916
|
+
f = f.map((w) => w.id === d.id ? y : w), u("updateAnnotation", y, E);
|
|
913
917
|
});
|
|
914
|
-
}, { origin: M.LOCAL }), i.observe((
|
|
915
|
-
if (
|
|
916
|
-
const
|
|
917
|
-
h.length > 0 && (
|
|
918
|
+
}, { origin: M.LOCAL }), i.observe((b) => {
|
|
919
|
+
if (f) {
|
|
920
|
+
const v = new Set(f.map((d) => d.id)), h = (b.changes.updated || []).filter(({ newValue: d }) => v.has(d.id)).map(({ newValue: d }) => d);
|
|
921
|
+
h.length > 0 && (f = f.map((d) => h.find((E) => E.id === d.id) || d));
|
|
918
922
|
}
|
|
919
923
|
}, { origin: M.REMOTE });
|
|
920
|
-
const x = (
|
|
921
|
-
const { updated: h } =
|
|
922
|
-
|
|
924
|
+
const x = (b) => (v) => {
|
|
925
|
+
const { updated: h } = v;
|
|
926
|
+
b ? (h || []).forEach((d) => u("updateAnnotation", d.oldValue, d.newValue)) : (h || []).forEach((d) => u("updateAnnotation", d.newValue, d.oldValue));
|
|
923
927
|
};
|
|
924
|
-
return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: c, off: p, emit:
|
|
928
|
+
return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: c, off: p, emit: u };
|
|
925
929
|
}, yn = (t) => (e) => e.reduce((n, o) => {
|
|
926
930
|
const { parsed: i, error: r } = t.parse(o);
|
|
927
931
|
return r ? {
|
|
@@ -936,44 +940,44 @@ const hn = 250, pn = (t) => {
|
|
|
936
940
|
}, { parsed: [], failed: [] }), bn = (t, e, n) => {
|
|
937
941
|
const { store: o, selection: i } = t, r = (h) => {
|
|
938
942
|
if (n) {
|
|
939
|
-
const { parsed:
|
|
940
|
-
|
|
943
|
+
const { parsed: d, error: y } = n.parse(h);
|
|
944
|
+
d ? o.addAnnotation(d, M.REMOTE) : console.error(y);
|
|
941
945
|
} else
|
|
942
946
|
o.addAnnotation(h, M.REMOTE);
|
|
943
947
|
}, a = () => i.clear(), s = () => o.clear(), l = (h) => {
|
|
944
|
-
const
|
|
945
|
-
return n &&
|
|
946
|
-
},
|
|
948
|
+
const d = o.getAnnotation(h);
|
|
949
|
+
return n && d ? n.serialize(d) : d;
|
|
950
|
+
}, f = () => n ? o.all().map(n.serialize) : o.all(), g = () => {
|
|
947
951
|
var h;
|
|
948
|
-
const
|
|
949
|
-
return n ?
|
|
950
|
-
}, c = (h,
|
|
952
|
+
const d = (((h = i.selected) == null ? void 0 : h.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
|
|
953
|
+
return n ? d.map(n.serialize) : d;
|
|
954
|
+
}, c = (h, d = !0) => fetch(h).then((y) => y.json()).then((y) => (u(y, d), y)), p = (h) => {
|
|
951
955
|
if (typeof h == "string") {
|
|
952
|
-
const
|
|
953
|
-
if (o.deleteAnnotation(h),
|
|
954
|
-
return n ? n.serialize(
|
|
956
|
+
const d = o.getAnnotation(h);
|
|
957
|
+
if (o.deleteAnnotation(h), d)
|
|
958
|
+
return n ? n.serialize(d) : d;
|
|
955
959
|
} else {
|
|
956
|
-
const
|
|
957
|
-
if (
|
|
958
|
-
return o.deleteAnnotation(
|
|
960
|
+
const d = n ? n.parse(h).parsed : h;
|
|
961
|
+
if (d)
|
|
962
|
+
return o.deleteAnnotation(d), h;
|
|
959
963
|
}
|
|
960
|
-
},
|
|
964
|
+
}, u = (h, d = !0) => {
|
|
961
965
|
if (n) {
|
|
962
966
|
const { parsed: y, failed: E } = yn(n)(h);
|
|
963
|
-
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(y,
|
|
967
|
+
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(y, d, M.REMOTE);
|
|
964
968
|
} else
|
|
965
|
-
o.bulkAddAnnotation(h,
|
|
966
|
-
}, x = (h,
|
|
967
|
-
h ? i.setSelected(h,
|
|
968
|
-
}, v = (h) => {
|
|
969
|
-
i.clear(), i.setUserSelectAction(h);
|
|
969
|
+
o.bulkAddAnnotation(h, d, M.REMOTE);
|
|
970
|
+
}, x = (h, d) => {
|
|
971
|
+
h ? i.setSelected(h, d) : i.clear();
|
|
970
972
|
}, b = (h) => {
|
|
973
|
+
i.clear(), i.setUserSelectAction(h);
|
|
974
|
+
}, v = (h) => {
|
|
971
975
|
if (n) {
|
|
972
|
-
const
|
|
973
|
-
return o.updateAnnotation(
|
|
976
|
+
const d = n.parse(h).parsed, y = n.serialize(o.getAnnotation(d.id));
|
|
977
|
+
return o.updateAnnotation(d), y;
|
|
974
978
|
} else {
|
|
975
|
-
const
|
|
976
|
-
return o.updateAnnotation(h),
|
|
979
|
+
const d = o.getAnnotation(h.id);
|
|
980
|
+
return o.updateAnnotation(h), d;
|
|
977
981
|
}
|
|
978
982
|
};
|
|
979
983
|
return {
|
|
@@ -983,16 +987,16 @@ const hn = 250, pn = (t) => {
|
|
|
983
987
|
canUndo: e.canUndo,
|
|
984
988
|
clearAnnotations: s,
|
|
985
989
|
getAnnotationById: l,
|
|
986
|
-
getAnnotations:
|
|
990
|
+
getAnnotations: f,
|
|
987
991
|
getSelected: g,
|
|
988
992
|
loadAnnotations: c,
|
|
989
993
|
redo: e.redo,
|
|
990
994
|
removeAnnotation: p,
|
|
991
|
-
setAnnotations:
|
|
995
|
+
setAnnotations: u,
|
|
992
996
|
setSelected: x,
|
|
993
|
-
setUserSelectAction:
|
|
997
|
+
setUserSelectAction: b,
|
|
994
998
|
undo: e.undo,
|
|
995
|
-
updateAnnotation:
|
|
999
|
+
updateAnnotation: v
|
|
996
1000
|
};
|
|
997
1001
|
}, wn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
998
1002
|
let vn = (t) => crypto.getRandomValues(new Uint8Array(t)), xn = (t, e, n) => {
|
|
@@ -1020,14 +1024,14 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1020
1024
|
}
|
|
1021
1025
|
return `${n}`;
|
|
1022
1026
|
}, le = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Ln = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1023
|
-
const { id: o, type: i, purpose: r, value: a, created: s, modified: l, creator:
|
|
1027
|
+
const { id: o, type: i, purpose: r, value: a, created: s, modified: l, creator: f, ...g } = n;
|
|
1024
1028
|
return {
|
|
1025
1029
|
id: o || `temp-${Cn(n)}`,
|
|
1026
1030
|
annotation: e,
|
|
1027
1031
|
type: i,
|
|
1028
1032
|
purpose: r,
|
|
1029
1033
|
value: a,
|
|
1030
|
-
creator: le(
|
|
1034
|
+
creator: le(f),
|
|
1031
1035
|
created: s ? new Date(s) : void 0,
|
|
1032
1036
|
updated: l ? new Date(l) : void 0,
|
|
1033
1037
|
...g
|
|
@@ -1103,11 +1107,11 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1103
1107
|
} = t, a = Array.from(e.childNodes).map((c) => {
|
|
1104
1108
|
const p = c.cloneNode(!0);
|
|
1105
1109
|
return c.nodeName === "CANVAS" ? c : p;
|
|
1106
|
-
}), s = Qt(n, e), l = Qt(i, e),
|
|
1110
|
+
}), s = Qt(n, e), l = Qt(i, e), f = () => {
|
|
1107
1111
|
const c = e;
|
|
1108
1112
|
c.replaceChildren(...a);
|
|
1109
|
-
const p = Jt(s, c),
|
|
1110
|
-
return t.setStart(p, o), t.setEnd(
|
|
1113
|
+
const p = Jt(s, c), u = Jt(l, c);
|
|
1114
|
+
return t.setStart(p, o), t.setEnd(u, r), t;
|
|
1111
1115
|
}, g = (c) => {
|
|
1112
1116
|
const p = document.createElement("SPAN");
|
|
1113
1117
|
return c.surroundContents(p), p;
|
|
@@ -1117,14 +1121,14 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1117
1121
|
{
|
|
1118
1122
|
const c = document.createRange();
|
|
1119
1123
|
c.selectNodeContents(n), c.setStart(n, o);
|
|
1120
|
-
const p = g(c),
|
|
1121
|
-
|
|
1122
|
-
const x = g(
|
|
1124
|
+
const p = g(c), u = document.createRange();
|
|
1125
|
+
u.selectNode(i), u.setEnd(i, r);
|
|
1126
|
+
const x = g(u), v = In(t).reverse().map((h) => {
|
|
1123
1127
|
var y;
|
|
1124
|
-
const
|
|
1125
|
-
return (y = h.parentNode) == null || y.insertBefore(
|
|
1128
|
+
const d = document.createElement("SPAN");
|
|
1129
|
+
return (y = h.parentNode) == null || y.insertBefore(d, h), d.appendChild(h), d;
|
|
1126
1130
|
});
|
|
1127
|
-
return { unwrap:
|
|
1131
|
+
return { unwrap: f, nodes: [p, ...v, x] };
|
|
1128
1132
|
}
|
|
1129
1133
|
}, In = (t) => {
|
|
1130
1134
|
const {
|
|
@@ -1221,17 +1225,17 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1221
1225
|
e,
|
|
1222
1226
|
NodeFilter.SHOW_TEXT,
|
|
1223
1227
|
(p) => {
|
|
1224
|
-
var
|
|
1225
|
-
return (
|
|
1228
|
+
var u;
|
|
1229
|
+
return (u = p.parentElement) != null && u.closest(H) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
1226
1230
|
}
|
|
1227
1231
|
);
|
|
1228
1232
|
let a = 0;
|
|
1229
1233
|
const s = document.createRange();
|
|
1230
1234
|
let l = r.nextNode();
|
|
1231
1235
|
l === null && console.error("Could not revive annotation target. Content missing.");
|
|
1232
|
-
let
|
|
1236
|
+
let f = !i;
|
|
1233
1237
|
for (; l !== null; ) {
|
|
1234
|
-
if (
|
|
1238
|
+
if (f || (f = i == null ? void 0 : i.contains(l)), f) {
|
|
1235
1239
|
const p = ((g = l.textContent) == null ? void 0 : g.length) || 0;
|
|
1236
1240
|
if (a + p > n) {
|
|
1237
1241
|
s.setStart(l, n - a);
|
|
@@ -1372,18 +1376,18 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1372
1376
|
selector: a,
|
|
1373
1377
|
creator: s,
|
|
1374
1378
|
created: l,
|
|
1375
|
-
updated:
|
|
1379
|
+
updated: f,
|
|
1376
1380
|
...g
|
|
1377
1381
|
} = i, c = a.map((p) => {
|
|
1378
|
-
const { quote:
|
|
1382
|
+
const { quote: u, start: x, end: b, range: v } = p, { prefix: h, suffix: d } = _n(v, n), y = [{
|
|
1379
1383
|
type: "TextQuoteSelector",
|
|
1380
|
-
exact:
|
|
1384
|
+
exact: u,
|
|
1381
1385
|
prefix: h,
|
|
1382
|
-
suffix:
|
|
1386
|
+
suffix: d
|
|
1383
1387
|
}, {
|
|
1384
1388
|
type: "TextPositionSelector",
|
|
1385
1389
|
start: x,
|
|
1386
|
-
end:
|
|
1390
|
+
end: b
|
|
1387
1391
|
}];
|
|
1388
1392
|
return {
|
|
1389
1393
|
...g,
|
|
@@ -1400,15 +1404,15 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1400
1404
|
body: On(t.bodies),
|
|
1401
1405
|
creator: s,
|
|
1402
1406
|
created: l == null ? void 0 : l.toISOString(),
|
|
1403
|
-
modified:
|
|
1407
|
+
modified: f == null ? void 0 : f.toISOString(),
|
|
1404
1408
|
target: c
|
|
1405
1409
|
};
|
|
1406
1410
|
};
|
|
1407
1411
|
function fe(t, e, n = 0, o = t.length - 1, i = Gn) {
|
|
1408
1412
|
for (; o > n; ) {
|
|
1409
1413
|
if (o - n > 600) {
|
|
1410
|
-
const l = o - n + 1,
|
|
1411
|
-
fe(t, e,
|
|
1414
|
+
const l = o - n + 1, f = e - n + 1, g = Math.log(l), c = 0.5 * Math.exp(2 * g / 3), p = 0.5 * Math.sqrt(g * c * (l - c) / l) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + p)), x = Math.min(o, Math.floor(e + (l - f) * c / l + p));
|
|
1415
|
+
fe(t, e, u, x, i);
|
|
1412
1416
|
}
|
|
1413
1417
|
const r = t[e];
|
|
1414
1418
|
let a = n, s = o;
|
|
@@ -1494,14 +1498,14 @@ class Qn {
|
|
|
1494
1498
|
if (!e) return this;
|
|
1495
1499
|
let o = this.data;
|
|
1496
1500
|
const i = this.toBBox(e), r = [], a = [];
|
|
1497
|
-
let s, l,
|
|
1501
|
+
let s, l, f;
|
|
1498
1502
|
for (; o || r.length; ) {
|
|
1499
|
-
if (o || (o = r.pop(), l = r[r.length - 1], s = a.pop(),
|
|
1503
|
+
if (o || (o = r.pop(), l = r[r.length - 1], s = a.pop(), f = !0), o.leaf) {
|
|
1500
1504
|
const g = Jn(e, o.children, n);
|
|
1501
1505
|
if (g !== -1)
|
|
1502
1506
|
return o.children.splice(g, 1), r.push(o), this._condense(r), this;
|
|
1503
1507
|
}
|
|
1504
|
-
!
|
|
1508
|
+
!f && !o.leaf && Lt(o, i) ? (r.push(o), a.push(s), s = 0, l = o, o = o.children[0]) : l ? (s++, o = l.children[s], f = !1) : o = null;
|
|
1505
1509
|
}
|
|
1506
1510
|
return this;
|
|
1507
1511
|
}
|
|
@@ -1532,14 +1536,14 @@ class Qn {
|
|
|
1532
1536
|
if (r <= a)
|
|
1533
1537
|
return s = J(e.slice(n, o + 1)), Q(s, this.toBBox), s;
|
|
1534
1538
|
i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s = J([]), s.leaf = !1, s.height = i;
|
|
1535
|
-
const l = Math.ceil(r / a),
|
|
1536
|
-
Zt(e, n, o,
|
|
1537
|
-
for (let g = n; g <= o; g +=
|
|
1538
|
-
const c = Math.min(g +
|
|
1539
|
+
const l = Math.ceil(r / a), f = l * Math.ceil(Math.sqrt(a));
|
|
1540
|
+
Zt(e, n, o, f, this.compareMinX);
|
|
1541
|
+
for (let g = n; g <= o; g += f) {
|
|
1542
|
+
const c = Math.min(g + f - 1, o);
|
|
1539
1543
|
Zt(e, g, c, l, this.compareMinY);
|
|
1540
1544
|
for (let p = g; p <= c; p += l) {
|
|
1541
|
-
const
|
|
1542
|
-
s.children.push(this._build(e, p,
|
|
1545
|
+
const u = Math.min(p + l - 1, c);
|
|
1546
|
+
s.children.push(this._build(e, p, u, i - 1));
|
|
1543
1547
|
}
|
|
1544
1548
|
}
|
|
1545
1549
|
return Q(s, this.toBBox), s;
|
|
@@ -1548,8 +1552,8 @@ class Qn {
|
|
|
1548
1552
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1549
1553
|
let r = 1 / 0, a = 1 / 0, s;
|
|
1550
1554
|
for (let l = 0; l < n.children.length; l++) {
|
|
1551
|
-
const
|
|
1552
|
-
c < a ? (a = c, r = g < r ? g : r, s =
|
|
1555
|
+
const f = n.children[l], g = Ct(f), c = eo(e, f) - g;
|
|
1556
|
+
c < a ? (a = c, r = g < r ? g : r, s = f) : c === a && g < r && (r = g, s = f);
|
|
1553
1557
|
}
|
|
1554
1558
|
n = s || n.children[0];
|
|
1555
1559
|
}
|
|
@@ -1574,7 +1578,7 @@ class Qn {
|
|
|
1574
1578
|
_chooseSplitIndex(e, n, o) {
|
|
1575
1579
|
let i, r = 1 / 0, a = 1 / 0;
|
|
1576
1580
|
for (let s = n; s <= o - n; s++) {
|
|
1577
|
-
const l = nt(e, 0, s, this.toBBox),
|
|
1581
|
+
const l = nt(e, 0, s, this.toBBox), f = nt(e, s, o, this.toBBox), g = no(l, f), c = Ct(l) + Ct(f);
|
|
1578
1582
|
g < r ? (r = g, i = s, a = c < a ? c : a) : g === r && c < a && (a = c, i = s);
|
|
1579
1583
|
}
|
|
1580
1584
|
return i || o - n;
|
|
@@ -1589,12 +1593,12 @@ class Qn {
|
|
|
1589
1593
|
e.children.sort(i);
|
|
1590
1594
|
const r = this.toBBox, a = nt(e, 0, n, r), s = nt(e, o - n, o, r);
|
|
1591
1595
|
let l = ft(a) + ft(s);
|
|
1592
|
-
for (let
|
|
1593
|
-
const g = e.children[
|
|
1596
|
+
for (let f = n; f < o - n; f++) {
|
|
1597
|
+
const g = e.children[f];
|
|
1594
1598
|
ot(a, e.leaf ? r(g) : g), l += ft(a);
|
|
1595
1599
|
}
|
|
1596
|
-
for (let
|
|
1597
|
-
const g = e.children[
|
|
1600
|
+
for (let f = o - n - 1; f >= n; f--) {
|
|
1601
|
+
const g = e.children[f];
|
|
1598
1602
|
ot(s, e.leaf ? r(g) : g), l += ft(s);
|
|
1599
1603
|
}
|
|
1600
1604
|
return l;
|
|
@@ -1710,11 +1714,11 @@ const io = (t, e) => {
|
|
|
1710
1714
|
}, l = (y) => {
|
|
1711
1715
|
const E = r(y, e.getBoundingClientRect());
|
|
1712
1716
|
E.forEach((w) => n.insert(w)), o.set(y.annotation, E);
|
|
1713
|
-
},
|
|
1717
|
+
}, f = (y) => {
|
|
1714
1718
|
const E = o.get(y.annotation);
|
|
1715
1719
|
E && (E.forEach((w) => n.remove(w)), o.delete(y.annotation));
|
|
1716
1720
|
}, g = (y) => {
|
|
1717
|
-
|
|
1721
|
+
f(y), l(y);
|
|
1718
1722
|
}, c = (y, E = !0) => {
|
|
1719
1723
|
E && s();
|
|
1720
1724
|
const w = e.getBoundingClientRect(), O = y.map((L) => ({ target: L, rects: r(L, w) }));
|
|
@@ -1729,7 +1733,7 @@ const io = (t, e) => {
|
|
|
1729
1733
|
maxY: E
|
|
1730
1734
|
}), B = (L) => L.annotation.rects.reduce((T, m) => T + m.width * m.height, 0);
|
|
1731
1735
|
return O.length > 0 ? (O.sort((L, T) => B(L) - B(T)), w ? O.map((L) => L.annotation.id) : [O[0].annotation.id]) : [];
|
|
1732
|
-
},
|
|
1736
|
+
}, u = (y) => {
|
|
1733
1737
|
const E = x(y);
|
|
1734
1738
|
if (E.length === 0)
|
|
1735
1739
|
return;
|
|
@@ -1747,7 +1751,7 @@ const io = (t, e) => {
|
|
|
1747
1751
|
all: a,
|
|
1748
1752
|
clear: s,
|
|
1749
1753
|
getAt: p,
|
|
1750
|
-
getAnnotationBounds:
|
|
1754
|
+
getAnnotationBounds: u,
|
|
1751
1755
|
getAnnotationRects: x,
|
|
1752
1756
|
getIntersecting: (y, E, w, O) => {
|
|
1753
1757
|
const B = n.search({ minX: y, minY: E, maxX: w, maxY: O }), L = new Set(B.map((T) => T.annotation.id));
|
|
@@ -1760,59 +1764,59 @@ const io = (t, e) => {
|
|
|
1760
1764
|
recalculate: () => {
|
|
1761
1765
|
c(t.all().map((y) => y.target), !0), i.emit("recalculate");
|
|
1762
1766
|
},
|
|
1763
|
-
remove:
|
|
1767
|
+
remove: f,
|
|
1764
1768
|
set: c,
|
|
1765
1769
|
size: () => n.all().length,
|
|
1766
1770
|
update: g,
|
|
1767
1771
|
on: (y, E) => i.on(y, E)
|
|
1768
1772
|
};
|
|
1769
1773
|
}, ro = (t, e) => {
|
|
1770
|
-
const n = un(), o = io(n, t), i = Qe(n, e), r = qe(n), a = gn(), s = (
|
|
1771
|
-
const
|
|
1772
|
-
return y && n.addAnnotation(
|
|
1773
|
-
}, l = (
|
|
1774
|
-
const y =
|
|
1775
|
-
return E.length > 0 ? (console.warn("Could not revive all targets for these annotations:", E), n.bulkAddAnnotation(y, h,
|
|
1776
|
-
},
|
|
1777
|
-
const
|
|
1778
|
-
return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y),
|
|
1774
|
+
const n = un(), o = io(n, t), i = Qe(n, e), r = qe(n), a = gn(), s = (v, h = M.LOCAL) => {
|
|
1775
|
+
const d = St(v, t), y = W(d.target.selector);
|
|
1776
|
+
return y && n.addAnnotation(d, h), y;
|
|
1777
|
+
}, l = (v, h = !0, d = M.LOCAL) => {
|
|
1778
|
+
const y = v.map((w) => St(w, t)), E = y.filter((w) => !W(w.target.selector));
|
|
1779
|
+
return E.length > 0 ? (console.warn("Could not revive all targets for these annotations:", E), n.bulkAddAnnotation(y, h, d), E) : (n.bulkAddAnnotation(y, h, d), []);
|
|
1780
|
+
}, f = (v, h = M.LOCAL) => {
|
|
1781
|
+
const d = v.map((E) => St(E, t)), y = d.filter((E) => !W(E.target.selector));
|
|
1782
|
+
return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y), d.forEach((E) => {
|
|
1779
1783
|
n.getAnnotation(E.id) ? n.updateAnnotation(E, h) : n.addAnnotation(E, h);
|
|
1780
1784
|
}), y;
|
|
1781
|
-
}, g = (
|
|
1782
|
-
const
|
|
1783
|
-
n.updateTarget(
|
|
1784
|
-
}, c = (
|
|
1785
|
-
const
|
|
1786
|
-
n.bulkUpdateTargets(
|
|
1787
|
-
}, p = (
|
|
1788
|
-
const y = o.getAt(
|
|
1785
|
+
}, g = (v, h = M.LOCAL) => {
|
|
1786
|
+
const d = mt(v, t);
|
|
1787
|
+
n.updateTarget(d, h);
|
|
1788
|
+
}, c = (v, h = M.LOCAL) => {
|
|
1789
|
+
const d = v.map((y) => mt(y, t));
|
|
1790
|
+
n.bulkUpdateTargets(d, h);
|
|
1791
|
+
}, p = (v, h, d) => {
|
|
1792
|
+
const y = o.getAt(v, h, !!d).map((w) => n.getAnnotation(w)), E = d ? y.filter(d) : y;
|
|
1789
1793
|
return E.length > 0 ? E[0] : void 0;
|
|
1790
|
-
},
|
|
1791
|
-
const E = o.getAnnotationRects(
|
|
1794
|
+
}, u = (v, h, d, y = 5) => {
|
|
1795
|
+
const E = o.getAnnotationRects(v);
|
|
1792
1796
|
if (E.length !== 0) {
|
|
1793
|
-
if (h &&
|
|
1794
|
-
const w = E.find(({ top: O, right: B, bottom: L, left: T }) => h >= T - y && h <= B + y &&
|
|
1797
|
+
if (h && d) {
|
|
1798
|
+
const w = E.find(({ top: O, right: B, bottom: L, left: T }) => h >= T - y && h <= B + y && d >= O - y && d <= L + y);
|
|
1795
1799
|
if (w) return w;
|
|
1796
1800
|
}
|
|
1797
|
-
return o.getAnnotationBounds(
|
|
1801
|
+
return o.getAnnotationBounds(v);
|
|
1798
1802
|
}
|
|
1799
|
-
}, x = () => o.recalculate(),
|
|
1800
|
-
return n.observe(({ changes:
|
|
1801
|
-
const h = (
|
|
1802
|
-
(h == null ? void 0 : h.length) > 0 && h.forEach((E) => o.remove(E.target)),
|
|
1803
|
+
}, x = () => o.recalculate(), b = (v) => o.on("recalculate", v);
|
|
1804
|
+
return n.observe(({ changes: v }) => {
|
|
1805
|
+
const h = (v.deleted || []).filter((E) => W(E.target.selector)), d = (v.created || []).filter((E) => W(E.target.selector)), y = (v.updated || []).filter((E) => W(E.newValue.target.selector));
|
|
1806
|
+
(h == null ? void 0 : h.length) > 0 && h.forEach((E) => o.remove(E.target)), d.length > 0 && o.set(d.map((E) => E.target), !1), (y == null ? void 0 : y.length) > 0 && y.forEach(({ newValue: E }) => o.update(E.target));
|
|
1803
1807
|
}), {
|
|
1804
1808
|
store: {
|
|
1805
1809
|
...n,
|
|
1806
1810
|
addAnnotation: s,
|
|
1807
1811
|
bulkAddAnnotation: l,
|
|
1808
1812
|
bulkUpdateTargets: c,
|
|
1809
|
-
bulkUpsertAnnotations:
|
|
1810
|
-
getAnnotationBounds:
|
|
1813
|
+
bulkUpsertAnnotations: f,
|
|
1814
|
+
getAnnotationBounds: u,
|
|
1811
1815
|
getAt: p,
|
|
1812
1816
|
getIntersecting: o.getIntersecting.bind(o),
|
|
1813
1817
|
getAnnotationRects: o.getAnnotationRects.bind(o),
|
|
1814
1818
|
recalculatePositions: x,
|
|
1815
|
-
onRecalculatePositions:
|
|
1819
|
+
onRecalculatePositions: b,
|
|
1816
1820
|
updateTarget: g
|
|
1817
1821
|
},
|
|
1818
1822
|
selection: i,
|
|
@@ -1827,7 +1831,7 @@ const io = (t, e) => {
|
|
|
1827
1831
|
}, ao = (t, e, n = {}) => {
|
|
1828
1832
|
const o = so(), i = o.getContext("2d");
|
|
1829
1833
|
document.body.appendChild(o);
|
|
1830
|
-
const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([p,
|
|
1834
|
+
const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([p, u]) => u.presenceKey === c.presenceKey).map(([p, u]) => p);
|
|
1831
1835
|
return e.on("selectionChange", (c, p) => {
|
|
1832
1836
|
a(c).forEach((x) => r.delete(x)), p && p.forEach((x) => r.set(x, c));
|
|
1833
1837
|
}), {
|
|
@@ -1838,16 +1842,16 @@ const io = (t, e) => {
|
|
|
1838
1842
|
destroy: () => {
|
|
1839
1843
|
o.remove();
|
|
1840
1844
|
},
|
|
1841
|
-
paint: (c, p,
|
|
1845
|
+
paint: (c, p, u) => {
|
|
1842
1846
|
n.font && (i.font = n.font);
|
|
1843
1847
|
const x = r.get(c.annotation.id);
|
|
1844
1848
|
if (x) {
|
|
1845
|
-
const { height:
|
|
1846
|
-
i.fillStyle = x.appearance.color, i.fillRect(
|
|
1847
|
-
const
|
|
1848
|
-
return i.fillRect(
|
|
1849
|
+
const { height: b } = c.rects[0], v = c.rects[0].x + p.left, h = c.rects[0].y + p.top;
|
|
1850
|
+
i.fillStyle = x.appearance.color, i.fillRect(v - 2, h - 2.5, 2, b + 5);
|
|
1851
|
+
const d = i.measureText(x.appearance.label), y = d.width + 6, E = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, w = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1852
|
+
return i.fillRect(v - 2, h - 2.5 - E, y, E), i.fillStyle = "#fff", i.fillText(x.appearance.label, v + 1, h - w), {
|
|
1849
1853
|
fill: x.appearance.color,
|
|
1850
|
-
fillOpacity:
|
|
1854
|
+
fillOpacity: u ? 0.45 : 0.18
|
|
1851
1855
|
};
|
|
1852
1856
|
}
|
|
1853
1857
|
},
|
|
@@ -1864,16 +1868,16 @@ const io = (t, e) => {
|
|
|
1864
1868
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : he(t.parentElement);
|
|
1865
1869
|
}, co = (t, e) => (n) => {
|
|
1866
1870
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
1867
|
-
const s = r.getBoundingClientRect(), l = r.clientHeight,
|
|
1868
|
-
r.scroll({ top: h, left:
|
|
1871
|
+
const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: c, height: p } = e.getAnnotationBounds(o), u = g.top - s.top, x = g.left - s.left, b = r.parentElement ? r.scrollTop : 0, v = r.parentElement ? r.scrollLeft : 0, h = u + b - (l - p) / 2, d = x + v - (f - c) / 2;
|
|
1872
|
+
r.scroll({ top: h, left: d, behavior: "smooth" });
|
|
1869
1873
|
}, r = he(t);
|
|
1870
1874
|
if (r) {
|
|
1871
1875
|
const a = e.getAnnotation(o), { range: s } = a.target.selector[0];
|
|
1872
1876
|
if (s && !s.collapsed)
|
|
1873
1877
|
return i(a.target), !0;
|
|
1874
1878
|
{
|
|
1875
|
-
const l = mt(a.target, t), { range:
|
|
1876
|
-
if (
|
|
1879
|
+
const l = mt(a.target, t), { range: f } = l.selector[0];
|
|
1880
|
+
if (f && !f.collapsed)
|
|
1877
1881
|
return i(l), !0;
|
|
1878
1882
|
}
|
|
1879
1883
|
}
|
|
@@ -2091,14 +2095,14 @@ const pt = (t) => {
|
|
|
2091
2095
|
splitKey: i = "+"
|
|
2092
2096
|
} = t;
|
|
2093
2097
|
ge(e).forEach((a) => {
|
|
2094
|
-
const s = a.split(i), l = s.length,
|
|
2098
|
+
const s = a.split(i), l = s.length, f = s[l - 1], g = f === "*" ? "*" : ct(f);
|
|
2095
2099
|
if (!I[g]) return;
|
|
2096
2100
|
n || (n = at());
|
|
2097
2101
|
const c = l > 1 ? pe(j, s) : [], p = [];
|
|
2098
|
-
I[g] = I[g].filter((
|
|
2099
|
-
const
|
|
2100
|
-
return
|
|
2101
|
-
}), p.forEach((
|
|
2102
|
+
I[g] = I[g].filter((u) => {
|
|
2103
|
+
const b = (o ? u.method === o : !0) && u.scope === n && uo(u.mods, c);
|
|
2104
|
+
return b && p.push(u.element), !b;
|
|
2105
|
+
}), p.forEach((u) => Vt(u));
|
|
2102
2106
|
});
|
|
2103
2107
|
};
|
|
2104
2108
|
function te(t, e, n, o) {
|
|
@@ -2137,8 +2141,8 @@ function ee(t, e) {
|
|
|
2137
2141
|
for (let s = 0; s < a; s++)
|
|
2138
2142
|
if ((t.type === "keydown" && r[s].keydown || t.type === "keyup" && r[s].keyup) && r[s].key) {
|
|
2139
2143
|
const l = r[s], {
|
|
2140
|
-
splitKey:
|
|
2141
|
-
} = l, g = l.key.split(
|
|
2144
|
+
splitKey: f
|
|
2145
|
+
} = l, g = l.key.split(f), c = [];
|
|
2142
2146
|
for (let p = 0; p < g.length; p++)
|
|
2143
2147
|
c.push(ct(g[p]));
|
|
2144
2148
|
c.sort().join("") === k.sort().join("") && te(t, l, i, e);
|
|
@@ -2147,11 +2151,11 @@ function ee(t, e) {
|
|
|
2147
2151
|
function P(t, e, n) {
|
|
2148
2152
|
k = [];
|
|
2149
2153
|
const o = ge(t);
|
|
2150
|
-
let i = [], r = "all", a = document, s = 0, l = !1,
|
|
2151
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (r = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (
|
|
2154
|
+
let i = [], r = "all", a = document, s = 0, l = !1, f = !0, g = "+", c = !1, p = !1;
|
|
2155
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (r = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (c = e.capture), typeof e.splitKey == "string" && (g = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (r = e), p && be(t, r); s < o.length; s++)
|
|
2152
2156
|
t = o[s].split(g), i = [], t.length > 1 && (i = pe(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : ct(t), t in I || (I[t] = []), I[t].push({
|
|
2153
2157
|
keyup: l,
|
|
2154
|
-
keydown:
|
|
2158
|
+
keydown: f,
|
|
2155
2159
|
scope: r,
|
|
2156
2160
|
mods: i,
|
|
2157
2161
|
shortcut: o[s],
|
|
@@ -2162,27 +2166,27 @@ function P(t, e, n) {
|
|
|
2162
2166
|
});
|
|
2163
2167
|
if (typeof a < "u" && window) {
|
|
2164
2168
|
if (!F.has(a)) {
|
|
2165
|
-
const
|
|
2166
|
-
let
|
|
2167
|
-
return ee(
|
|
2169
|
+
const u = function() {
|
|
2170
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2171
|
+
return ee(b, a);
|
|
2168
2172
|
}, x = function() {
|
|
2169
|
-
let
|
|
2170
|
-
ee(
|
|
2173
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2174
|
+
ee(b, a), vo(b);
|
|
2171
2175
|
};
|
|
2172
2176
|
F.set(a, {
|
|
2173
|
-
keydownListener:
|
|
2177
|
+
keydownListener: u,
|
|
2174
2178
|
keyupListenr: x,
|
|
2175
2179
|
capture: c
|
|
2176
|
-
}), Tt(a, "keydown",
|
|
2180
|
+
}), Tt(a, "keydown", u, c), Tt(a, "keyup", x, c);
|
|
2177
2181
|
}
|
|
2178
2182
|
if (!rt) {
|
|
2179
|
-
const
|
|
2183
|
+
const u = () => {
|
|
2180
2184
|
k = [];
|
|
2181
2185
|
};
|
|
2182
2186
|
rt = {
|
|
2183
|
-
listener:
|
|
2187
|
+
listener: u,
|
|
2184
2188
|
capture: c
|
|
2185
|
-
}, Tt(window, "focus",
|
|
2189
|
+
}, Tt(window, "focus", u, c);
|
|
2186
2190
|
}
|
|
2187
2191
|
}
|
|
2188
2192
|
}
|
|
@@ -2252,9 +2256,9 @@ const Ao = (t, e, n) => {
|
|
|
2252
2256
|
const a = (w) => r = w;
|
|
2253
2257
|
let s = !0;
|
|
2254
2258
|
const l = (w) => {
|
|
2255
|
-
s = w,
|
|
2256
|
-
}, { store:
|
|
2257
|
-
let c, p,
|
|
2259
|
+
s = w, b.clear(), w || (c = void 0, p = void 0, u = void 0);
|
|
2260
|
+
}, { store: f, selection: g } = e;
|
|
2261
|
+
let c, p, u;
|
|
2258
2262
|
const x = (w) => {
|
|
2259
2263
|
var B;
|
|
2260
2264
|
if (!s || p === !1)
|
|
@@ -2267,7 +2271,7 @@ const Ao = (t, e, n) => {
|
|
|
2267
2271
|
} : void 0;
|
|
2268
2272
|
};
|
|
2269
2273
|
t.addEventListener("selectstart", x);
|
|
2270
|
-
const
|
|
2274
|
+
const b = It((w) => {
|
|
2271
2275
|
var C, R;
|
|
2272
2276
|
if (!s) return;
|
|
2273
2277
|
const O = document.getSelection();
|
|
@@ -2275,9 +2279,9 @@ const Ao = (t, e, n) => {
|
|
|
2275
2279
|
c = void 0;
|
|
2276
2280
|
return;
|
|
2277
2281
|
}
|
|
2278
|
-
if (w.timeStamp - ((
|
|
2282
|
+
if (w.timeStamp - ((u == null ? void 0 : u.timeStamp) || w.timeStamp) < 1e3 && !c && x(u || w), !c) return;
|
|
2279
2283
|
if (O.isCollapsed) {
|
|
2280
|
-
|
|
2284
|
+
f.getAnnotation(c.annotation) && (g.clear(), f.deleteAnnotation(c.annotation));
|
|
2281
2285
|
return;
|
|
2282
2286
|
}
|
|
2283
2287
|
const T = O.getRangeAt(0), m = Pn(T, t);
|
|
@@ -2290,46 +2294,46 @@ const Ao = (t, e, n) => {
|
|
|
2290
2294
|
...c,
|
|
2291
2295
|
selector: A.map((N) => Xn(N, t, n)),
|
|
2292
2296
|
updated: /* @__PURE__ */ new Date()
|
|
2293
|
-
},
|
|
2297
|
+
}, f.getAnnotation(c.annotation) ? f.updateTarget(c, M.LOCAL) : (g.clear(), f.addAnnotation({
|
|
2294
2298
|
id: c.annotation,
|
|
2295
2299
|
bodies: [],
|
|
2296
2300
|
target: c
|
|
2297
|
-
}, M.LOCAL), g.userSelect(c.annotation,
|
|
2301
|
+
}, M.LOCAL), g.userSelect(c.annotation, u)));
|
|
2298
2302
|
}, 10);
|
|
2299
|
-
document.addEventListener("selectionchange",
|
|
2300
|
-
const
|
|
2301
|
-
|
|
2303
|
+
document.addEventListener("selectionchange", b);
|
|
2304
|
+
const v = (w) => {
|
|
2305
|
+
u = Hn(w), p = u.button === 0, c = void 0;
|
|
2302
2306
|
};
|
|
2303
|
-
document.addEventListener("pointerdown",
|
|
2307
|
+
document.addEventListener("pointerdown", v);
|
|
2304
2308
|
const h = (w) => {
|
|
2305
2309
|
var T;
|
|
2306
2310
|
if (!!((T = w.target.parentElement) != null && T.closest(H)) || !p)
|
|
2307
2311
|
return;
|
|
2308
2312
|
const B = () => {
|
|
2309
|
-
const { x: m, y: A } = t.getBoundingClientRect(), S = w.target instanceof Node && t.contains(w.target) &&
|
|
2313
|
+
const { x: m, y: A } = t.getBoundingClientRect(), S = w.target instanceof Node && t.contains(w.target) && f.getAt(w.clientX - m, w.clientY - A, r);
|
|
2310
2314
|
if (S) {
|
|
2311
2315
|
const { selected: C } = g;
|
|
2312
2316
|
(C.length !== 1 || C[0].id !== S.id) && g.userSelect(S.id, w);
|
|
2313
2317
|
} else g.isEmpty() || g.clear();
|
|
2314
|
-
}, L = w.timeStamp -
|
|
2318
|
+
}, L = w.timeStamp - u.timeStamp;
|
|
2315
2319
|
setTimeout(() => {
|
|
2316
2320
|
const m = document.getSelection();
|
|
2317
2321
|
m != null && m.isCollapsed && L < 300 ? B() : c && g.userSelect(c.annotation, w);
|
|
2318
2322
|
});
|
|
2319
2323
|
};
|
|
2320
2324
|
document.addEventListener("pointerup", h);
|
|
2321
|
-
const
|
|
2322
|
-
...
|
|
2325
|
+
const d = ["up", "down", "left", "right"], y = [
|
|
2326
|
+
...d.map((w) => `shift+${w}`),
|
|
2323
2327
|
"ctrl+a",
|
|
2324
2328
|
"⌘+a"
|
|
2325
2329
|
];
|
|
2326
2330
|
return P(y.join(","), { element: t, keydown: !0, keyup: !1 }, (w) => {
|
|
2327
|
-
w.repeat || (
|
|
2328
|
-
}), P(
|
|
2331
|
+
w.repeat || (u = jn(w));
|
|
2332
|
+
}), P(d.join(","), { element: t, keydown: !0, keyup: !1 }, (w) => {
|
|
2329
2333
|
w.repeat || (c = void 0, g.clear());
|
|
2330
2334
|
}), {
|
|
2331
2335
|
destroy: () => {
|
|
2332
|
-
c = void 0, p = void 0,
|
|
2336
|
+
c = void 0, p = void 0, u = void 0, b.clear(), t.removeEventListener("selectstart", x), document.removeEventListener("selectionchange", b), document.removeEventListener("pointerdown", v), document.removeEventListener("pointerup", h), P.unbind();
|
|
2333
2337
|
},
|
|
2334
2338
|
setFilter: a,
|
|
2335
2339
|
setUser: i,
|
|
@@ -2341,40 +2345,40 @@ const Ao = (t, e, n) => {
|
|
|
2341
2345
|
annotatingEnabled: !0,
|
|
2342
2346
|
user: Sn()
|
|
2343
2347
|
}), o = ro(t, n.userSelectAction), { selection: i, viewport: r } = o, a = o.store, s = pn(a), l = mn(o, s, n.adapter);
|
|
2344
|
-
let
|
|
2348
|
+
let f = n.user;
|
|
2345
2349
|
const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ne : n.renderer || ne, c = g === "SPANS" ? $e(t, o, r) : g === "CSS_HIGHLIGHTS" ? Ke(t, o, r) : g === "CANVAS" ? Be(t, o, r) : void 0;
|
|
2346
2350
|
if (!c)
|
|
2347
2351
|
throw `Unknown renderer implementation: ${g}`;
|
|
2348
2352
|
console.debug(`Using ${g} renderer`), n.style && c.setStyle(n.style);
|
|
2349
2353
|
const p = Ao(t, o, n.offsetReferenceSelector);
|
|
2350
|
-
p.setUser(
|
|
2351
|
-
const
|
|
2354
|
+
p.setUser(f), p.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2355
|
+
const u = bn(o, s, n.adapter), x = () => f, b = (w) => {
|
|
2352
2356
|
p.setAnnotatingEnabled(
|
|
2353
2357
|
w === void 0 ? !0 : w
|
|
2354
2358
|
);
|
|
2355
|
-
},
|
|
2359
|
+
}, v = (w) => {
|
|
2356
2360
|
c.setFilter(w), p.setFilter(w);
|
|
2357
2361
|
}, h = (w) => {
|
|
2358
|
-
|
|
2359
|
-
},
|
|
2362
|
+
f = w, p.setUser(w);
|
|
2363
|
+
}, d = (w) => {
|
|
2360
2364
|
w && (c.setPainter(ao(t, w, n.presence)), w.on("selectionChange", () => c.redraw()));
|
|
2361
2365
|
}, y = (w) => {
|
|
2362
2366
|
w ? i.setSelected(w) : i.clear();
|
|
2363
2367
|
};
|
|
2364
2368
|
return {
|
|
2365
|
-
...
|
|
2369
|
+
...u,
|
|
2366
2370
|
destroy: () => {
|
|
2367
2371
|
c.destroy(), p.destroy(), s.destroy();
|
|
2368
2372
|
},
|
|
2369
2373
|
element: t,
|
|
2370
2374
|
getUser: x,
|
|
2371
|
-
setAnnotatingEnabled:
|
|
2372
|
-
setFilter:
|
|
2375
|
+
setAnnotatingEnabled: b,
|
|
2376
|
+
setFilter: v,
|
|
2373
2377
|
setStyle: c.setStyle.bind(c),
|
|
2374
2378
|
redraw: c.redraw.bind(c),
|
|
2375
2379
|
setUser: h,
|
|
2376
2380
|
setSelected: y,
|
|
2377
|
-
setPresenceProvider:
|
|
2381
|
+
setPresenceProvider: d,
|
|
2378
2382
|
setVisible: c.setVisible.bind(c),
|
|
2379
2383
|
on: l.on,
|
|
2380
2384
|
off: l.off,
|