@soomo/text-annotator 3.0.0-staging.47 → 3.0.0-staging.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,52 +1,52 @@
|
|
|
1
1
|
const q = {
|
|
2
2
|
fill: "rgb(0, 128, 255)",
|
|
3
3
|
fillOpacity: 0.18
|
|
4
|
-
},
|
|
4
|
+
}, mt = {
|
|
5
5
|
fill: "rgb(0, 128, 255)",
|
|
6
6
|
fillOpacity: 0.45
|
|
7
7
|
}, Ae = (t, e, n, o, i) => {
|
|
8
8
|
var a, s;
|
|
9
|
-
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ?
|
|
9
|
+
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? mt : q) : n : (s = t.state) != null && s.selected ? mt : q;
|
|
10
10
|
return o && o.paint(t, e) || r;
|
|
11
11
|
};
|
|
12
12
|
function Ee(t) {
|
|
13
13
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
14
14
|
}
|
|
15
|
-
var
|
|
16
|
-
function
|
|
15
|
+
var It = { exports: {} };
|
|
16
|
+
function ie(t, e = 100, n = {}) {
|
|
17
17
|
if (typeof t != "function")
|
|
18
18
|
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
|
|
19
19
|
if (e < 0)
|
|
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
|
-
|
|
47
|
-
|
|
48
|
-
var Se =
|
|
49
|
-
const
|
|
46
|
+
It.exports.debounce = ie;
|
|
47
|
+
It.exports = ie;
|
|
48
|
+
var Se = It.exports;
|
|
49
|
+
const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
50
50
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, l = i - e;
|
|
51
51
|
return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: l };
|
|
52
52
|
}, Le = (t) => {
|
|
@@ -55,48 +55,48 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
55
55
|
const i = o.map((r) => r.id);
|
|
56
56
|
(e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
|
|
57
57
|
};
|
|
58
|
-
},
|
|
58
|
+
}, Ut = (t, e, n, o) => {
|
|
59
59
|
const { store: i, selection: r, hover: a } = e;
|
|
60
|
-
let s, l,
|
|
61
|
-
const g = Le(n), c = (
|
|
62
|
-
const { x:
|
|
63
|
-
|
|
60
|
+
let s, l, f;
|
|
61
|
+
const g = Le(n), c = (O) => {
|
|
62
|
+
const { x: B, y: m } = t.getBoundingClientRect(), w = i.getAt(O.clientX - B, O.clientY - m, l);
|
|
63
|
+
w ? a.current !== w.id && (t.classList.add("hovered"), a.set(w.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
64
64
|
};
|
|
65
65
|
t.addEventListener("pointermove", c);
|
|
66
|
-
const p = (
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
const ve = N.includes(
|
|
70
|
-
return { annotation:
|
|
66
|
+
const p = (O = !1) => {
|
|
67
|
+
f && f.clear();
|
|
68
|
+
const B = Ce(t), { minX: m, minY: w, maxX: E, maxY: L } = B, T = l ? i.getIntersecting(m, w, E, L).filter(({ annotation: P }) => l(P)) : i.getIntersecting(m, w, E, L), N = r.selected.map(({ id: P }) => P), K = T.map(({ annotation: P, rects: lt }) => {
|
|
69
|
+
const ve = N.includes(P.id), xe = P.id === a.current;
|
|
70
|
+
return { annotation: P, rects: lt, state: { selected: ve, hover: xe } };
|
|
71
71
|
});
|
|
72
|
-
o.redraw(
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
}, x = (
|
|
76
|
-
s =
|
|
77
|
-
},
|
|
78
|
-
l =
|
|
79
|
-
},
|
|
80
|
-
i.observe(
|
|
81
|
-
const h = r.subscribe(() => p()),
|
|
82
|
-
document.addEventListener("scroll",
|
|
83
|
-
const y =
|
|
84
|
-
i.recalculatePositions(),
|
|
72
|
+
o.redraw(K, B, s, f, O), setTimeout(() => g(T.map(({ annotation: P }) => P)), 1);
|
|
73
|
+
}, u = (O) => {
|
|
74
|
+
f = O, p();
|
|
75
|
+
}, x = (O) => {
|
|
76
|
+
s = O, p();
|
|
77
|
+
}, b = (O) => {
|
|
78
|
+
l = O, p(!1);
|
|
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
|
+
const y = _t(() => {
|
|
84
|
+
i.recalculatePositions(), f && f.reset(), p();
|
|
85
85
|
}, 10);
|
|
86
86
|
window.addEventListener("resize", y);
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
87
|
+
const A = new ResizeObserver(y);
|
|
88
|
+
A.observe(t);
|
|
89
|
+
const C = { attributes: !0, childList: !0, subtree: !0 }, S = new MutationObserver((O) => {
|
|
90
|
+
O.every((m) => m.target === t || t.contains(m.target)) || p(!0);
|
|
91
91
|
});
|
|
92
|
-
return
|
|
92
|
+
return S.observe(document.body, C), {
|
|
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), A.disconnect(), S.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,32 +108,32 @@ 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((
|
|
119
|
-
var
|
|
120
|
-
const h =
|
|
121
|
-
x:
|
|
122
|
-
y:
|
|
123
|
-
width:
|
|
124
|
-
height:
|
|
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
|
+
var A;
|
|
120
|
+
const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (A = v.state) != null && A.selected ? mt : q, d = g && g.paint(v, l) || h, y = v.rects.map(({ x: C, y: S, width: R, height: O }) => ({
|
|
121
|
+
x: C + x,
|
|
122
|
+
y: S + u,
|
|
123
|
+
width: R,
|
|
124
|
+
height: O
|
|
125
125
|
}));
|
|
126
|
-
if (n.fillStyle =
|
|
127
|
-
({ x:
|
|
128
|
-
),
|
|
129
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
130
|
-
const
|
|
131
|
-
y.forEach(({ x:
|
|
132
|
-
n.beginPath(), n.moveTo(
|
|
126
|
+
if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, y.forEach(
|
|
127
|
+
({ x: C, y: S, width: R, height: O }) => n.fillRect(C, S, R, O)
|
|
128
|
+
), d.underlineColor) {
|
|
129
|
+
n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
|
|
130
|
+
const C = d.underlineOffset ?? 0;
|
|
131
|
+
y.forEach(({ x: S, y: R, width: O, height: B }) => {
|
|
132
|
+
n.beginPath(), n.moveTo(S, R + B + C), n.lineTo(S + O, R + B + C), n.stroke();
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
});
|
|
136
|
-
}), i =
|
|
136
|
+
}), i = _t(() => Te(e), 10);
|
|
137
137
|
return window.addEventListener("resize", i), {
|
|
138
138
|
destroy: () => {
|
|
139
139
|
e.remove(), i.clear(), window.removeEventListener("resize", i);
|
|
@@ -143,144 +143,144 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
|
|
|
143
143
|
},
|
|
144
144
|
redraw: o
|
|
145
145
|
};
|
|
146
|
-
}, Be = (t, e, n) =>
|
|
146
|
+
}, Be = (t, e, n) => Ut(t, e, n, Re(t));
|
|
147
147
|
var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
148
148
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
149
149
|
}, _ = function(t, e, n) {
|
|
150
150
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
151
|
-
},
|
|
151
|
+
}, Y = function(t, e, n) {
|
|
152
152
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
153
|
-
},
|
|
153
|
+
}, re = function(t) {
|
|
154
154
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
155
|
-
},
|
|
156
|
-
return { r:
|
|
157
|
-
},
|
|
155
|
+
}, Kt = function(t) {
|
|
156
|
+
return { r: Y(t.r, 0, 255), g: Y(t.g, 0, 255), b: Y(t.b, 0, 255), a: Y(t.a) };
|
|
157
|
+
}, bt = function(t) {
|
|
158
158
|
return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
|
|
159
|
-
}, ke = /^#([0-9a-f]{3,8})$/i,
|
|
159
|
+
}, ke = /^#([0-9a-f]{3,8})$/i, dt = function(t) {
|
|
160
160
|
var e = t.toString(16);
|
|
161
161
|
return e.length < 2 ? "0" + e : e;
|
|
162
|
-
},
|
|
162
|
+
}, se = function(t) {
|
|
163
163
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), a = r - Math.min(e, n, o), s = a ? r === e ? (n - o) / a : r === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
|
|
164
164
|
return { h: 60 * (s < 0 ? s + 6 : s), s: r ? a / r * 100 : 0, v: r / 255 * 100, a: i };
|
|
165
|
-
},
|
|
165
|
+
}, ae = 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
|
-
return { h:
|
|
172
|
-
}, Kt = function(t) {
|
|
173
|
-
return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
|
|
171
|
+
return { h: re(t.h), s: Y(t.s, 0, 100), l: Y(t.l, 0, 100), a: Y(t.a) };
|
|
174
172
|
}, Xt = function(t) {
|
|
175
|
-
return
|
|
173
|
+
return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
|
|
174
|
+
}, Pt = function(t) {
|
|
175
|
+
return ae((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
|
|
176
176
|
var e, n, o;
|
|
177
177
|
}, it = function(t) {
|
|
178
|
-
return { h: (e =
|
|
178
|
+
return { h: (e = se(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
|
|
179
179
|
var e, n, o, i;
|
|
180
|
-
}, Ne = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ie = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, _e = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ue = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,
|
|
180
|
+
}, Ne = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ie = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, _e = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ue = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, $t = { string: [[function(t) {
|
|
181
181
|
var e = ke.exec(t);
|
|
182
182
|
return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? _(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? _(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
183
183
|
}, "hex"], [function(t) {
|
|
184
184
|
var e = _e.exec(t) || Ue.exec(t);
|
|
185
|
-
return e ? e[2] !== e[4] || e[4] !== e[6] ? null :
|
|
185
|
+
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Kt({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
|
|
186
186
|
}, "rgb"], [function(t) {
|
|
187
187
|
var e = Ne.exec(t) || Ie.exec(t);
|
|
188
188
|
if (!e) return null;
|
|
189
189
|
var n, o, i = Yt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Me[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
190
|
-
return
|
|
190
|
+
return Pt(i);
|
|
191
191
|
}, "hsl"]], object: [[function(t) {
|
|
192
192
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
|
|
193
|
-
return z(e) && z(n) && z(o) ?
|
|
193
|
+
return z(e) && z(n) && z(o) ? Kt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
|
|
194
194
|
}, "rgb"], [function(t) {
|
|
195
195
|
var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
|
|
196
196
|
if (!z(e) || !z(n) || !z(o)) return null;
|
|
197
197
|
var a = Yt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
|
|
198
|
-
return
|
|
198
|
+
return Pt(a);
|
|
199
199
|
}, "hsl"], [function(t) {
|
|
200
200
|
var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
|
|
201
201
|
if (!z(e) || !z(n) || !z(o)) return null;
|
|
202
202
|
var a = function(s) {
|
|
203
|
-
return { h:
|
|
203
|
+
return { h: re(s.h), s: Y(s.s, 0, 100), v: Y(s.v, 0, 100), a: Y(s.a) };
|
|
204
204
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
|
|
205
|
-
return
|
|
206
|
-
}, "hsv"]] },
|
|
205
|
+
return ae(a);
|
|
206
|
+
}, "hsv"]] }, Ht = function(t, e) {
|
|
207
207
|
for (var n = 0; n < e.length; n++) {
|
|
208
208
|
var o = e[n][0](t);
|
|
209
209
|
if (o) return [o, e[n][1]];
|
|
210
210
|
}
|
|
211
211
|
return [null, void 0];
|
|
212
212
|
}, Ve = function(t) {
|
|
213
|
-
return typeof t == "string" ?
|
|
214
|
-
},
|
|
213
|
+
return typeof t == "string" ? Ht(t.trim(), $t.string) : typeof t == "object" && t !== null ? Ht(t, $t.object) : [null, void 0];
|
|
214
|
+
}, wt = function(t, e) {
|
|
215
215
|
var n = it(t);
|
|
216
|
-
return { h: n.h, s:
|
|
217
|
-
},
|
|
216
|
+
return { h: n.h, s: Y(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
217
|
+
}, vt = function(t) {
|
|
218
218
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
219
|
-
},
|
|
219
|
+
}, jt = function(t, e) {
|
|
220
220
|
var n = it(t);
|
|
221
|
-
return { h: n.h, s: n.s, l:
|
|
222
|
-
},
|
|
221
|
+
return { h: n.h, s: n.s, l: Y(n.l + 100 * e, 0, 100), a: n.a };
|
|
222
|
+
}, zt = function() {
|
|
223
223
|
function t(e) {
|
|
224
224
|
this.parsed = Ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
225
225
|
}
|
|
226
226
|
return t.prototype.isValid = function() {
|
|
227
227
|
return this.parsed !== null;
|
|
228
228
|
}, t.prototype.brightness = function() {
|
|
229
|
-
return _(
|
|
229
|
+
return _(vt(this.rgba), 2);
|
|
230
230
|
}, t.prototype.isDark = function() {
|
|
231
|
-
return
|
|
231
|
+
return vt(this.rgba) < 0.5;
|
|
232
232
|
}, t.prototype.isLight = function() {
|
|
233
|
-
return
|
|
233
|
+
return vt(this.rgba) >= 0.5;
|
|
234
234
|
}, t.prototype.toHex = function() {
|
|
235
|
-
return e =
|
|
235
|
+
return e = bt(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? dt(_(255 * r)) : "", "#" + dt(n) + dt(o) + dt(i) + a;
|
|
236
236
|
var e, n, o, i, r, a;
|
|
237
237
|
}, t.prototype.toRgb = function() {
|
|
238
|
-
return
|
|
238
|
+
return bt(this.rgba);
|
|
239
239
|
}, t.prototype.toRgbString = function() {
|
|
240
|
-
return e =
|
|
240
|
+
return e = bt(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
241
241
|
var e, n, o, i, r;
|
|
242
242
|
}, t.prototype.toHsl = function() {
|
|
243
|
-
return
|
|
243
|
+
return Xt(it(this.rgba));
|
|
244
244
|
}, t.prototype.toHslString = function() {
|
|
245
|
-
return e =
|
|
245
|
+
return e = Xt(it(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
246
246
|
var e, n, o, i, r;
|
|
247
247
|
}, t.prototype.toHsv = function() {
|
|
248
|
-
return e =
|
|
248
|
+
return e = se(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
|
|
249
249
|
var e;
|
|
250
250
|
}, t.prototype.invert = function() {
|
|
251
|
-
return
|
|
251
|
+
return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
252
252
|
var e;
|
|
253
253
|
}, t.prototype.saturate = function(e) {
|
|
254
|
-
return e === void 0 && (e = 0.1),
|
|
254
|
+
return e === void 0 && (e = 0.1), $(wt(this.rgba, e));
|
|
255
255
|
}, t.prototype.desaturate = function(e) {
|
|
256
|
-
return e === void 0 && (e = 0.1),
|
|
256
|
+
return e === void 0 && (e = 0.1), $(wt(this.rgba, -e));
|
|
257
257
|
}, t.prototype.grayscale = function() {
|
|
258
|
-
return
|
|
258
|
+
return $(wt(this.rgba, -1));
|
|
259
259
|
}, t.prototype.lighten = function(e) {
|
|
260
|
-
return e === void 0 && (e = 0.1),
|
|
260
|
+
return e === void 0 && (e = 0.1), $(jt(this.rgba, e));
|
|
261
261
|
}, t.prototype.darken = function(e) {
|
|
262
|
-
return e === void 0 && (e = 0.1),
|
|
262
|
+
return e === void 0 && (e = 0.1), $(jt(this.rgba, -e));
|
|
263
263
|
}, t.prototype.rotate = function(e) {
|
|
264
264
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
265
265
|
}, t.prototype.alpha = function(e) {
|
|
266
|
-
return typeof e == "number" ?
|
|
266
|
+
return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
|
|
267
267
|
var n;
|
|
268
268
|
}, t.prototype.hue = function(e) {
|
|
269
269
|
var n = it(this.rgba);
|
|
270
|
-
return typeof e == "number" ?
|
|
270
|
+
return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
|
|
271
271
|
}, t.prototype.isEqual = function(e) {
|
|
272
|
-
return this.toHex() ===
|
|
272
|
+
return this.toHex() === $(e).toHex();
|
|
273
273
|
}, t;
|
|
274
|
-
}(),
|
|
275
|
-
return t instanceof
|
|
274
|
+
}(), $ = function(t) {
|
|
275
|
+
return t instanceof zt ? t : new zt(t);
|
|
276
276
|
};
|
|
277
277
|
const De = (t) => [
|
|
278
|
-
`background-color:${
|
|
278
|
+
`background-color:${$((t == null ? void 0 : t.fill) || q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? q.fillOpacity : t.fillOpacity).toHex()}`,
|
|
279
279
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
280
280
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
281
281
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
282
282
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
283
|
-
].filter(Boolean).join(";"),
|
|
283
|
+
].filter(Boolean).join(";"), Ke = () => {
|
|
284
284
|
const t = document.createElement("style");
|
|
285
285
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
286
286
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -293,23 +293,23 @@ 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 ?
|
|
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 ? mt : 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
|
-
},
|
|
311
|
-
var
|
|
312
|
-
function
|
|
310
|
+
}, Ye = (t, e, n) => Ut(t, e, n, Ke());
|
|
311
|
+
var Ft = Object.prototype.hasOwnProperty;
|
|
312
|
+
function Mt(t, e) {
|
|
313
313
|
var n, o;
|
|
314
314
|
if (t === e) return !0;
|
|
315
315
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -317,13 +317,13 @@ function Bt(t, e) {
|
|
|
317
317
|
if (n === RegExp) return t.toString() === e.toString();
|
|
318
318
|
if (n === Array) {
|
|
319
319
|
if ((o = t.length) === e.length)
|
|
320
|
-
for (; o-- &&
|
|
320
|
+
for (; o-- && Mt(t[o], e[o]); ) ;
|
|
321
321
|
return o === -1;
|
|
322
322
|
}
|
|
323
323
|
if (!n || typeof t == "object") {
|
|
324
324
|
o = 0;
|
|
325
325
|
for (n in t)
|
|
326
|
-
if (
|
|
326
|
+
if (Ft.call(t, n) && ++o && !Ft.call(e, n) || !(n in e) || !Mt(t[n], e[n])) return !1;
|
|
327
327
|
return Object.keys(e).length === o;
|
|
328
328
|
}
|
|
329
329
|
}
|
|
@@ -341,47 +341,51 @@ const Xe = (t, e) => {
|
|
|
341
341
|
destroy: () => {
|
|
342
342
|
e.remove();
|
|
343
343
|
},
|
|
344
|
-
redraw: (a, s, l,
|
|
345
|
-
const p = !(
|
|
346
|
-
!
|
|
347
|
-
|
|
348
|
-
|
|
344
|
+
redraw: (a, s, l, f, g) => {
|
|
345
|
+
const p = !(Mt(n, a) && g);
|
|
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 = $((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");
|
|
358
362
|
}
|
|
359
363
|
};
|
|
360
|
-
}, $e = (t, e, n) =>
|
|
364
|
+
}, $e = (t, e, n) => Ut(t, e, n, Pe(t));
|
|
361
365
|
var U = [];
|
|
362
|
-
for (var
|
|
363
|
-
U.push((
|
|
366
|
+
for (var xt = 0; xt < 256; ++xt)
|
|
367
|
+
U.push((xt + 256).toString(16).slice(1));
|
|
364
368
|
function He(t, e = 0) {
|
|
365
369
|
return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
|
|
366
370
|
}
|
|
367
|
-
var
|
|
371
|
+
var ut, je = new Uint8Array(16);
|
|
368
372
|
function ze() {
|
|
369
|
-
if (!
|
|
373
|
+
if (!ut && (ut = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ut))
|
|
370
374
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
371
|
-
return
|
|
375
|
+
return ut(je);
|
|
372
376
|
}
|
|
373
377
|
var Fe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
374
|
-
const
|
|
378
|
+
const Wt = {
|
|
375
379
|
randomUUID: Fe
|
|
376
380
|
};
|
|
377
|
-
function
|
|
378
|
-
if (
|
|
379
|
-
return
|
|
381
|
+
function ce(t, e, n) {
|
|
382
|
+
if (Wt.randomUUID && !e && !t)
|
|
383
|
+
return Wt.randomUUID();
|
|
380
384
|
t = t || {};
|
|
381
385
|
var o = t.random || (t.rng || ze)();
|
|
382
386
|
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, He(o);
|
|
383
387
|
}
|
|
384
|
-
var
|
|
388
|
+
var qt = Object.prototype.hasOwnProperty;
|
|
385
389
|
function Z(t, e) {
|
|
386
390
|
var n, o;
|
|
387
391
|
if (t === e) return !0;
|
|
@@ -396,29 +400,29 @@ function Z(t, e) {
|
|
|
396
400
|
if (!n || typeof t == "object") {
|
|
397
401
|
o = 0;
|
|
398
402
|
for (n in t)
|
|
399
|
-
if (
|
|
403
|
+
if (qt.call(t, n) && ++o && !qt.call(e, n) || !(n in e) || !Z(t[n], e[n])) return !1;
|
|
400
404
|
return Object.keys(e).length === o;
|
|
401
405
|
}
|
|
402
406
|
}
|
|
403
407
|
return t !== t && e !== e;
|
|
404
408
|
}
|
|
405
|
-
function
|
|
409
|
+
function At() {
|
|
406
410
|
}
|
|
407
411
|
function We(t, e) {
|
|
408
412
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
409
413
|
}
|
|
410
414
|
const G = [];
|
|
411
|
-
function
|
|
415
|
+
function Vt(t, e = At) {
|
|
412
416
|
let n;
|
|
413
417
|
const o = /* @__PURE__ */ new Set();
|
|
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
|
}
|
|
@@ -426,16 +430,16 @@ function Ut(t, e = xt) {
|
|
|
426
430
|
function r(s) {
|
|
427
431
|
i(s(t));
|
|
428
432
|
}
|
|
429
|
-
function a(s, l =
|
|
430
|
-
const
|
|
431
|
-
return o.add(
|
|
432
|
-
o.delete(
|
|
433
|
+
function a(s, l = At) {
|
|
434
|
+
const f = [s, l];
|
|
435
|
+
return o.add(f), o.size === 1 && (n = e(i, r) || At), 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 };
|
|
436
440
|
}
|
|
437
441
|
const qe = (t) => {
|
|
438
|
-
const { subscribe: e, set: n } =
|
|
442
|
+
const { subscribe: e, set: n } = Vt();
|
|
439
443
|
let o;
|
|
440
444
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
441
445
|
if (o) {
|
|
@@ -452,50 +456,50 @@ const qe = (t) => {
|
|
|
452
456
|
};
|
|
453
457
|
};
|
|
454
458
|
var Ge = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Ge || {});
|
|
455
|
-
const
|
|
456
|
-
const { subscribe: n, set: o } =
|
|
457
|
-
let i = e, r =
|
|
458
|
-
n((
|
|
459
|
-
const a = () => o(
|
|
460
|
-
var
|
|
461
|
-
return ((
|
|
462
|
-
}, l = (
|
|
459
|
+
const Et = { selected: [] }, Qe = (t, e = "EDIT") => {
|
|
460
|
+
const { subscribe: n, set: o } = Vt(Et);
|
|
461
|
+
let i = e, r = Et;
|
|
462
|
+
n((u) => r = u);
|
|
463
|
+
const a = () => o(Et), s = () => {
|
|
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 (
|
|
477
|
+
switch (Gt(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 ? Gt(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,28 +513,28 @@ 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
|
+
}, Gt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
515
519
|
var V = [];
|
|
516
|
-
for (var
|
|
517
|
-
V.push((
|
|
520
|
+
for (var St = 0; St < 256; ++St)
|
|
521
|
+
V.push((St + 256).toString(16).slice(1));
|
|
518
522
|
function Je(t, e = 0) {
|
|
519
523
|
return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
|
|
520
524
|
}
|
|
521
|
-
var
|
|
525
|
+
var ft, Ze = new Uint8Array(16);
|
|
522
526
|
function tn() {
|
|
523
|
-
if (!
|
|
527
|
+
if (!ft && (ft = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ft))
|
|
524
528
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
525
|
-
return
|
|
529
|
+
return ft(Ze);
|
|
526
530
|
}
|
|
527
531
|
var en = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
528
|
-
const
|
|
532
|
+
const Qt = {
|
|
529
533
|
randomUUID: en
|
|
530
534
|
};
|
|
531
535
|
function nn(t, e, n) {
|
|
532
|
-
if (
|
|
533
|
-
return
|
|
536
|
+
if (Qt.randomUUID && !e && !t)
|
|
537
|
+
return Qt.randomUUID();
|
|
534
538
|
t = t || {};
|
|
535
539
|
var o = t.random || (t.rng || tn)();
|
|
536
540
|
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Je(o);
|
|
@@ -550,7 +554,7 @@ const Eo = (t, e, n, o) => ({
|
|
|
550
554
|
}, sn = (t, e) => e.bodies.map((n) => {
|
|
551
555
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
552
556
|
return { newBody: n, oldBody: o && !Z(o, n) ? o : void 0 };
|
|
553
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), an = (t, e) => !Z(t.target, e.target),
|
|
557
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), an = (t, e) => !Z(t.target, e.target), le = (t, e) => {
|
|
554
558
|
const n = on(t, e), o = rn(t, e), i = sn(t, e);
|
|
555
559
|
return {
|
|
556
560
|
oldValue: t,
|
|
@@ -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,180 +592,180 @@ 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((
|
|
599
|
-
return
|
|
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;
|
|
603
|
+
return le(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
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m,
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
}, r = (m,
|
|
611
|
-
const
|
|
611
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, w = {}) => n.push({ onChange: m, options: w }), i = (m) => {
|
|
612
|
+
const w = n.findIndex((E) => E.onChange == m);
|
|
613
|
+
w > -1 && n.splice(w, 1);
|
|
614
|
+
}, r = (m, w) => {
|
|
615
|
+
const E = {
|
|
612
616
|
origin: m,
|
|
613
617
|
changes: {
|
|
614
|
-
created:
|
|
615
|
-
updated:
|
|
616
|
-
deleted:
|
|
618
|
+
created: w.created || [],
|
|
619
|
+
updated: w.updated || [],
|
|
620
|
+
deleted: w.deleted || []
|
|
617
621
|
},
|
|
618
622
|
state: [...t.values()]
|
|
619
623
|
};
|
|
620
|
-
n.forEach((
|
|
621
|
-
cn(
|
|
624
|
+
n.forEach((L) => {
|
|
625
|
+
cn(L, E) && L.onChange(E);
|
|
622
626
|
});
|
|
623
|
-
}, a = (m,
|
|
627
|
+
}, a = (m, w = M.LOCAL) => {
|
|
624
628
|
if (t.get(m.id))
|
|
625
629
|
throw Error(`Cannot add annotation ${m.id} - exists already`);
|
|
626
|
-
t.set(m.id, m), m.bodies.forEach((
|
|
627
|
-
}, s = (m,
|
|
628
|
-
const
|
|
629
|
-
if (
|
|
630
|
-
const N =
|
|
631
|
-
return
|
|
630
|
+
t.set(m.id, m), m.bodies.forEach((E) => e.set(E.id, m.id)), r(w, { created: [m] });
|
|
631
|
+
}, s = (m, w) => {
|
|
632
|
+
const E = typeof m == "string" ? w : m, L = typeof m == "string" ? m : m.id, T = t.get(L);
|
|
633
|
+
if (T) {
|
|
634
|
+
const N = le(T, E);
|
|
635
|
+
return L === E.id ? t.set(L, E) : (t.delete(L), t.set(E.id, E)), T.bodies.forEach((K) => e.delete(K.id)), E.bodies.forEach((K) => e.set(K.id, E.id)), N;
|
|
632
636
|
} else
|
|
633
|
-
console.warn(`Cannot update annotation ${
|
|
634
|
-
}, l = (m,
|
|
635
|
-
const
|
|
636
|
-
|
|
637
|
-
},
|
|
638
|
-
const
|
|
639
|
-
const N = s(
|
|
640
|
-
return N ? [...
|
|
637
|
+
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
638
|
+
}, l = (m, w = M.LOCAL, E = M.LOCAL) => {
|
|
639
|
+
const L = dn(w) ? E : w, T = s(m, w);
|
|
640
|
+
T && r(L, { updated: [T] });
|
|
641
|
+
}, f = (m, w = M.LOCAL) => {
|
|
642
|
+
const E = m.reduce((L, T) => {
|
|
643
|
+
const N = s(T);
|
|
644
|
+
return N ? [...L, N] : L;
|
|
641
645
|
}, []);
|
|
642
|
-
|
|
643
|
-
}, g = (m,
|
|
644
|
-
const
|
|
645
|
-
if (
|
|
646
|
-
const
|
|
647
|
-
...
|
|
648
|
-
bodies: [...
|
|
646
|
+
E.length > 0 && r(w, { updated: E });
|
|
647
|
+
}, g = (m, w = M.LOCAL) => {
|
|
648
|
+
const E = t.get(m.annotation);
|
|
649
|
+
if (E) {
|
|
650
|
+
const L = {
|
|
651
|
+
...E,
|
|
652
|
+
bodies: [...E.bodies, m]
|
|
649
653
|
};
|
|
650
|
-
t.set(
|
|
651
|
-
oldValue:
|
|
652
|
-
newValue:
|
|
654
|
+
t.set(E.id, L), e.set(m.id, L.id), r(w, { updated: [{
|
|
655
|
+
oldValue: E,
|
|
656
|
+
newValue: L,
|
|
653
657
|
bodiesCreated: [m]
|
|
654
658
|
}] });
|
|
655
659
|
} else
|
|
656
660
|
console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
|
|
657
661
|
}, c = () => [...t.values()], p = (m = M.LOCAL) => {
|
|
658
|
-
const
|
|
659
|
-
t.clear(), e.clear(), r(m, { deleted:
|
|
660
|
-
},
|
|
661
|
-
if (
|
|
662
|
-
const
|
|
663
|
-
t.clear(), e.clear(), m.forEach((
|
|
664
|
-
t.set(
|
|
665
|
-
}), r(
|
|
662
|
+
const w = [...t.values()];
|
|
663
|
+
t.clear(), e.clear(), r(m, { deleted: w });
|
|
664
|
+
}, u = (m, w = !0, E = M.LOCAL) => {
|
|
665
|
+
if (w) {
|
|
666
|
+
const L = [...t.values()];
|
|
667
|
+
t.clear(), e.clear(), m.forEach((T) => {
|
|
668
|
+
t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
|
|
669
|
+
}), r(E, { created: m, deleted: L });
|
|
666
670
|
} else {
|
|
667
|
-
const
|
|
668
|
-
const
|
|
669
|
-
return
|
|
671
|
+
const L = m.reduce((T, N) => {
|
|
672
|
+
const K = t.get(N.id);
|
|
673
|
+
return K ? [...T, K] : T;
|
|
670
674
|
}, []);
|
|
671
|
-
if (
|
|
672
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
673
|
-
m.forEach((
|
|
674
|
-
t.set(
|
|
675
|
-
}), r(
|
|
675
|
+
if (L.length > 0)
|
|
676
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${L.map((T) => T.id).join(", ")}`);
|
|
677
|
+
m.forEach((T) => {
|
|
678
|
+
t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
|
|
679
|
+
}), r(E, { created: m });
|
|
676
680
|
}
|
|
677
681
|
}, x = (m) => {
|
|
678
|
-
const
|
|
679
|
-
if (
|
|
680
|
-
return t.delete(
|
|
681
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
682
|
-
},
|
|
683
|
-
const
|
|
684
|
-
|
|
685
|
-
},
|
|
686
|
-
const
|
|
687
|
-
const N = x(
|
|
688
|
-
return N ? [...
|
|
682
|
+
const w = typeof m == "string" ? m : m.id, E = t.get(w);
|
|
683
|
+
if (E)
|
|
684
|
+
return t.delete(w), E.bodies.forEach((L) => e.delete(L.id)), E;
|
|
685
|
+
console.warn(`Attempt to delete missing annotation: ${w}`);
|
|
686
|
+
}, b = (m, w = M.LOCAL) => {
|
|
687
|
+
const E = x(m);
|
|
688
|
+
E && r(w, { deleted: [E] });
|
|
689
|
+
}, v = (m, w = M.LOCAL) => {
|
|
690
|
+
const E = m.reduce((L, T) => {
|
|
691
|
+
const N = x(T);
|
|
692
|
+
return N ? [...L, N] : L;
|
|
689
693
|
}, []);
|
|
690
|
-
|
|
694
|
+
E.length > 0 && r(w, { deleted: E });
|
|
691
695
|
}, h = (m) => {
|
|
692
|
-
const
|
|
693
|
-
if (
|
|
694
|
-
const
|
|
695
|
-
if (
|
|
696
|
-
e.delete(
|
|
697
|
-
const
|
|
698
|
-
...
|
|
699
|
-
bodies:
|
|
696
|
+
const w = t.get(m.annotation);
|
|
697
|
+
if (w) {
|
|
698
|
+
const E = w.bodies.find((L) => L.id === m.id);
|
|
699
|
+
if (E) {
|
|
700
|
+
e.delete(E.id);
|
|
701
|
+
const L = {
|
|
702
|
+
...w,
|
|
703
|
+
bodies: w.bodies.filter((T) => T.id !== m.id)
|
|
700
704
|
};
|
|
701
|
-
return t.set(
|
|
702
|
-
oldValue:
|
|
703
|
-
newValue:
|
|
704
|
-
bodiesDeleted: [
|
|
705
|
+
return t.set(w.id, L), {
|
|
706
|
+
oldValue: w,
|
|
707
|
+
newValue: L,
|
|
708
|
+
bodiesDeleted: [E]
|
|
705
709
|
};
|
|
706
710
|
} else
|
|
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
|
-
},
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
}, y = (m,
|
|
714
|
-
const
|
|
715
|
-
|
|
716
|
-
},
|
|
717
|
-
const
|
|
718
|
-
return
|
|
719
|
-
},
|
|
720
|
-
const
|
|
721
|
-
if (
|
|
722
|
-
const
|
|
723
|
-
if (
|
|
724
|
-
return
|
|
714
|
+
}, d = (m, w = M.LOCAL) => {
|
|
715
|
+
const E = h(m);
|
|
716
|
+
E && r(w, { updated: [E] });
|
|
717
|
+
}, y = (m, w = M.LOCAL) => {
|
|
718
|
+
const E = m.map((L) => h(L)).filter(Boolean);
|
|
719
|
+
E.length > 0 && r(w, { updated: E });
|
|
720
|
+
}, A = (m) => {
|
|
721
|
+
const w = t.get(m);
|
|
722
|
+
return w ? { ...w } : void 0;
|
|
723
|
+
}, C = (m) => {
|
|
724
|
+
const w = e.get(m);
|
|
725
|
+
if (w) {
|
|
726
|
+
const E = A(w).bodies.find((L) => L.id === m);
|
|
727
|
+
if (E)
|
|
728
|
+
return E;
|
|
725
729
|
console.error(`Store integrity error: body ${m} in index, but not in annotation`);
|
|
726
730
|
} else
|
|
727
731
|
console.warn(`Attempt to retrieve missing body: ${m}`);
|
|
728
|
-
},
|
|
729
|
-
if (m.annotation !==
|
|
732
|
+
}, S = (m, w) => {
|
|
733
|
+
if (m.annotation !== w.annotation)
|
|
730
734
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
731
|
-
const
|
|
732
|
-
if (
|
|
733
|
-
const
|
|
734
|
-
...
|
|
735
|
-
bodies:
|
|
735
|
+
const E = t.get(m.annotation);
|
|
736
|
+
if (E) {
|
|
737
|
+
const L = E.bodies.find((N) => N.id === m.id), T = {
|
|
738
|
+
...E,
|
|
739
|
+
bodies: E.bodies.map((N) => N.id === L.id ? w : N)
|
|
736
740
|
};
|
|
737
|
-
return t.set(
|
|
738
|
-
oldValue:
|
|
739
|
-
newValue:
|
|
740
|
-
bodiesUpdated: [{ oldBody:
|
|
741
|
+
return t.set(E.id, T), L.id !== w.id && (e.delete(L.id), e.set(w.id, T.id)), {
|
|
742
|
+
oldValue: E,
|
|
743
|
+
newValue: T,
|
|
744
|
+
bodiesUpdated: [{ oldBody: L, newBody: w }]
|
|
741
745
|
};
|
|
742
746
|
} else
|
|
743
747
|
console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
|
|
744
|
-
},
|
|
745
|
-
const
|
|
746
|
-
|
|
747
|
-
},
|
|
748
|
-
const
|
|
749
|
-
r(
|
|
750
|
-
},
|
|
751
|
-
const
|
|
752
|
-
if (
|
|
753
|
-
const
|
|
754
|
-
...
|
|
748
|
+
}, R = (m, w, E = M.LOCAL) => {
|
|
749
|
+
const L = S(m, w);
|
|
750
|
+
L && r(E, { updated: [L] });
|
|
751
|
+
}, O = (m, w = M.LOCAL) => {
|
|
752
|
+
const E = m.map((L) => S({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
753
|
+
r(w, { updated: E });
|
|
754
|
+
}, B = (m) => {
|
|
755
|
+
const w = t.get(m.annotation);
|
|
756
|
+
if (w) {
|
|
757
|
+
const E = {
|
|
758
|
+
...w,
|
|
755
759
|
target: {
|
|
756
|
-
...
|
|
760
|
+
...w.target,
|
|
757
761
|
...m
|
|
758
762
|
}
|
|
759
763
|
};
|
|
760
|
-
return t.set(
|
|
761
|
-
oldValue:
|
|
762
|
-
newValue:
|
|
764
|
+
return t.set(w.id, E), {
|
|
765
|
+
oldValue: w,
|
|
766
|
+
newValue: E,
|
|
763
767
|
targetUpdated: {
|
|
764
|
-
oldTarget:
|
|
768
|
+
oldTarget: w.target,
|
|
765
769
|
newTarget: m
|
|
766
770
|
}
|
|
767
771
|
};
|
|
@@ -772,27 +776,27 @@ 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:
|
|
779
|
-
bulkUpdateBodies:
|
|
780
|
-
bulkUpdateTargets: (m,
|
|
781
|
-
const
|
|
782
|
-
|
|
782
|
+
bulkUpdateAnnotation: f,
|
|
783
|
+
bulkUpdateBodies: O,
|
|
784
|
+
bulkUpdateTargets: (m, w = M.LOCAL) => {
|
|
785
|
+
const E = m.map((L) => B(L)).filter(Boolean);
|
|
786
|
+
E.length > 0 && r(w, { updated: E });
|
|
783
787
|
},
|
|
784
788
|
clear: p,
|
|
785
|
-
deleteAnnotation:
|
|
786
|
-
deleteBody:
|
|
787
|
-
getAnnotation:
|
|
788
|
-
getBody:
|
|
789
|
+
deleteAnnotation: b,
|
|
790
|
+
deleteBody: d,
|
|
791
|
+
getAnnotation: A,
|
|
792
|
+
getBody: C,
|
|
789
793
|
observe: o,
|
|
790
794
|
unobserve: i,
|
|
791
795
|
updateAnnotation: l,
|
|
792
|
-
updateBody:
|
|
793
|
-
updateTarget: (m,
|
|
794
|
-
const
|
|
795
|
-
|
|
796
|
+
updateBody: R,
|
|
797
|
+
updateTarget: (m, w = M.LOCAL) => {
|
|
798
|
+
const E = B(m);
|
|
799
|
+
E && r(w, { updated: [E] });
|
|
796
800
|
}
|
|
797
801
|
};
|
|
798
802
|
};
|
|
@@ -813,115 +817,115 @@ 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
|
};
|
|
851
855
|
}, gn = () => {
|
|
852
|
-
const { subscribe: t, set: e } =
|
|
856
|
+
const { subscribe: t, set: e } = Vt([]);
|
|
853
857
|
return {
|
|
854
858
|
subscribe: t,
|
|
855
859
|
set: e
|
|
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((C) => n.serialize(C)) : n.serialize(v), A = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
|
|
877
|
+
d(y, A);
|
|
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
|
|
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 A = f.find((C) => C.id === d.id) || d;
|
|
916
|
+
f = f.map((C) => C.id === d.id ? y : C), u("updateAnnotation", y, A);
|
|
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((A) => A.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
|
-
const { parsed: y, failed:
|
|
963
|
-
|
|
966
|
+
const { parsed: y, failed: A } = yn(n)(h);
|
|
967
|
+
A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), 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) => {
|
|
@@ -1019,15 +1023,15 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1019
1023
|
n = (n << 5) - n + r, n |= 0;
|
|
1020
1024
|
}
|
|
1021
1025
|
return `${n}`;
|
|
1022
|
-
},
|
|
1023
|
-
const { id: o, type: i, purpose: r, value: a, created: s, modified: l, creator:
|
|
1026
|
+
}, de = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Ln = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
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:
|
|
1034
|
+
creator: de(f),
|
|
1031
1035
|
created: s ? new Date(s) : void 0,
|
|
1032
1036
|
updated: l ? new Date(l) : void 0,
|
|
1033
1037
|
...g
|
|
@@ -1042,7 +1046,7 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1042
1046
|
return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
|
|
1043
1047
|
});
|
|
1044
1048
|
En();
|
|
1045
|
-
const
|
|
1049
|
+
const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
|
|
1046
1050
|
var n;
|
|
1047
1051
|
const e = t.commonAncestorContainer;
|
|
1048
1052
|
return e instanceof HTMLElement ? !e.closest(H) : !((n = e.parentElement) != null && n.closest(H));
|
|
@@ -1050,7 +1054,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1050
1054
|
const e = document.createNodeIterator(
|
|
1051
1055
|
t.commonAncestorContainer,
|
|
1052
1056
|
NodeFilter.SHOW_ELEMENT,
|
|
1053
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
1057
|
+
(o) => o instanceof HTMLElement && o.classList.contains(ue) && !o.parentElement.closest(H) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
1054
1058
|
);
|
|
1055
1059
|
let n;
|
|
1056
1060
|
for (; n = e.nextNode(); )
|
|
@@ -1068,7 +1072,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1068
1072
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
1069
1073
|
}
|
|
1070
1074
|
return e.length > 0 ? e : [t];
|
|
1071
|
-
},
|
|
1075
|
+
}, kt = (t) => {
|
|
1072
1076
|
const e = t.cloneContents();
|
|
1073
1077
|
return e.querySelectorAll(H).forEach((n) => n.remove()), e;
|
|
1074
1078
|
}, Mn = (t) => t.addEventListener("click", (e) => {
|
|
@@ -1079,7 +1083,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1079
1083
|
}, So = (t) => {
|
|
1080
1084
|
const e = t.cloneContents();
|
|
1081
1085
|
return e.querySelectorAll(H).forEach((n) => n.remove()), e;
|
|
1082
|
-
},
|
|
1086
|
+
}, Jt = (t, e) => {
|
|
1083
1087
|
const n = document.createNodeIterator(e);
|
|
1084
1088
|
let o = 0, i = n.nextNode();
|
|
1085
1089
|
for (; i !== null; ) {
|
|
@@ -1087,7 +1091,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1087
1091
|
return o;
|
|
1088
1092
|
o += 1, i = n.nextNode();
|
|
1089
1093
|
}
|
|
1090
|
-
},
|
|
1094
|
+
}, Zt = (t, e) => {
|
|
1091
1095
|
const n = document.createNodeIterator(e);
|
|
1092
1096
|
let o = null;
|
|
1093
1097
|
for (let i = 0; i < t + 1; i++)
|
|
@@ -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 =
|
|
1110
|
+
}), s = Jt(n, e), l = Jt(i, e), f = () => {
|
|
1107
1111
|
const c = e;
|
|
1108
1112
|
c.replaceChildren(...a);
|
|
1109
|
-
const p =
|
|
1110
|
-
return t.setStart(p, o), t.setEnd(
|
|
1113
|
+
const p = Zt(s, c), u = Zt(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 {
|
|
@@ -1148,9 +1152,9 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1148
1152
|
}, _n = (t, e, n = 10, o) => {
|
|
1149
1153
|
const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
|
|
1150
1154
|
r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
1151
|
-
const a =
|
|
1155
|
+
const a = kt(r).textContent, s = document.createRange();
|
|
1152
1156
|
s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
|
|
1153
|
-
const l =
|
|
1157
|
+
const l = kt(s).textContent;
|
|
1154
1158
|
return {
|
|
1155
1159
|
prefix: a.substring(a.length - n),
|
|
1156
1160
|
suffix: l.substring(0, n)
|
|
@@ -1179,17 +1183,17 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1179
1183
|
return "block-contains";
|
|
1180
1184
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
1181
1185
|
return "block-is-contained";
|
|
1182
|
-
},
|
|
1186
|
+
}, Kn = (t, e) => {
|
|
1183
1187
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
|
|
1184
1188
|
return new DOMRect(n, i, o - n, r - i);
|
|
1185
|
-
},
|
|
1189
|
+
}, Yn = (t) => t.reduce((e, n) => {
|
|
1186
1190
|
if (n.width === 0 || n.height === 0)
|
|
1187
1191
|
return e;
|
|
1188
1192
|
let o = [...e], i = !1;
|
|
1189
1193
|
for (const r of e) {
|
|
1190
1194
|
const a = Dn(n, r);
|
|
1191
1195
|
if (a === "inline-adjacent") {
|
|
1192
|
-
o = o.map((s) => s === r ?
|
|
1196
|
+
o = o.map((s) => s === r ? Kn(n, r) : s), i = !0;
|
|
1193
1197
|
break;
|
|
1194
1198
|
} else if (a === "inline-contains") {
|
|
1195
1199
|
o = o.map((s) => s === r ? n : s), i = !0;
|
|
@@ -1213,25 +1217,25 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1213
1217
|
}), Xn = (t, e, n) => {
|
|
1214
1218
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
1215
1219
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
1216
|
-
const r =
|
|
1220
|
+
const r = kt(o).textContent, a = t.toString(), s = r.length || 0, l = s + a.length;
|
|
1217
1221
|
return n ? { quote: a, start: s, end: l, range: t, offsetReference: i } : { quote: a, start: s, end: l, range: t };
|
|
1218
|
-
},
|
|
1222
|
+
}, fe = (t, e) => {
|
|
1219
1223
|
var g, c;
|
|
1220
1224
|
const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
|
|
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);
|
|
@@ -1253,10 +1257,10 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1253
1257
|
...t,
|
|
1254
1258
|
range: s
|
|
1255
1259
|
};
|
|
1256
|
-
},
|
|
1260
|
+
}, yt = (t, e) => W(t.selector) ? t : {
|
|
1257
1261
|
...t,
|
|
1258
|
-
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
1259
|
-
},
|
|
1262
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : fe(n, e))
|
|
1263
|
+
}, Ct = (t, e) => W(t.target.selector) ? t : { ...t, target: yt(t.target, e) }, Pn = (t, e) => {
|
|
1260
1264
|
const n = t.cloneRange();
|
|
1261
1265
|
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
1262
1266
|
}, $n = (t, e) => {
|
|
@@ -1321,7 +1325,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1321
1325
|
if (a.length === 0)
|
|
1322
1326
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1323
1327
|
const s = {
|
|
1324
|
-
creator:
|
|
1328
|
+
creator: de(n),
|
|
1325
1329
|
created: o ? new Date(o) : void 0,
|
|
1326
1330
|
updated: i ? new Date(i) : void 0,
|
|
1327
1331
|
annotation: e,
|
|
@@ -1352,7 +1356,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
|
|
|
1352
1356
|
}
|
|
1353
1357
|
return { parsed: s };
|
|
1354
1358
|
}, Wn = (t) => {
|
|
1355
|
-
const e = t.id ||
|
|
1359
|
+
const e = t.id || ce(), {
|
|
1356
1360
|
creator: n,
|
|
1357
1361
|
created: o,
|
|
1358
1362
|
modified: i,
|
|
@@ -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
|
-
function
|
|
1411
|
+
function he(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
|
-
|
|
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
|
+
he(t, e, u, x, i);
|
|
1412
1416
|
}
|
|
1413
1417
|
const r = t[e];
|
|
1414
1418
|
let a = n, s = o;
|
|
@@ -1436,12 +1440,12 @@ class Qn {
|
|
|
1436
1440
|
search(e) {
|
|
1437
1441
|
let n = this.data;
|
|
1438
1442
|
const o = [];
|
|
1439
|
-
if (!
|
|
1443
|
+
if (!pt(e, n)) return o;
|
|
1440
1444
|
const i = this.toBBox, r = [];
|
|
1441
1445
|
for (; n; ) {
|
|
1442
1446
|
for (let a = 0; a < n.children.length; a++) {
|
|
1443
1447
|
const s = n.children[a], l = n.leaf ? i(s) : s;
|
|
1444
|
-
|
|
1448
|
+
pt(e, l) && (n.leaf ? o.push(s) : Ot(e, l) ? this._all(s, o) : r.push(s));
|
|
1445
1449
|
}
|
|
1446
1450
|
n = r.pop();
|
|
1447
1451
|
}
|
|
@@ -1449,13 +1453,13 @@ class Qn {
|
|
|
1449
1453
|
}
|
|
1450
1454
|
collides(e) {
|
|
1451
1455
|
let n = this.data;
|
|
1452
|
-
if (!
|
|
1456
|
+
if (!pt(e, n)) return !1;
|
|
1453
1457
|
const o = [];
|
|
1454
1458
|
for (; n; ) {
|
|
1455
1459
|
for (let i = 0; i < n.children.length; i++) {
|
|
1456
1460
|
const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;
|
|
1457
|
-
if (
|
|
1458
|
-
if (n.leaf ||
|
|
1461
|
+
if (pt(e, a)) {
|
|
1462
|
+
if (n.leaf || Ot(e, a)) return !0;
|
|
1459
1463
|
o.push(r);
|
|
1460
1464
|
}
|
|
1461
1465
|
}
|
|
@@ -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 && Ot(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
|
-
|
|
1537
|
-
for (let g = n; g <= o; g +=
|
|
1538
|
-
const c = Math.min(g +
|
|
1539
|
-
|
|
1539
|
+
const l = Math.ceil(r / a), f = l * Math.ceil(Math.sqrt(a));
|
|
1540
|
+
te(e, n, o, f, this.compareMinX);
|
|
1541
|
+
for (let g = n; g <= o; g += f) {
|
|
1542
|
+
const c = Math.min(g + f - 1, o);
|
|
1543
|
+
te(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 = Lt(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 = Lt(l) + Lt(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;
|
|
@@ -1588,14 +1592,14 @@ class Qn {
|
|
|
1588
1592
|
_allDistMargin(e, n, o, i) {
|
|
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
|
-
let l =
|
|
1592
|
-
for (let
|
|
1593
|
-
const g = e.children[
|
|
1594
|
-
ot(a, e.leaf ? r(g) : g), l +=
|
|
1595
|
+
let l = ht(a) + ht(s);
|
|
1596
|
+
for (let f = n; f < o - n; f++) {
|
|
1597
|
+
const g = e.children[f];
|
|
1598
|
+
ot(a, e.leaf ? r(g) : g), l += ht(a);
|
|
1595
1599
|
}
|
|
1596
|
-
for (let
|
|
1597
|
-
const g = e.children[
|
|
1598
|
-
ot(s, e.leaf ? r(g) : g), l +=
|
|
1600
|
+
for (let f = o - n - 1; f >= n; f--) {
|
|
1601
|
+
const g = e.children[f];
|
|
1602
|
+
ot(s, e.leaf ? r(g) : g), l += ht(s);
|
|
1599
1603
|
}
|
|
1600
1604
|
return l;
|
|
1601
1605
|
}
|
|
@@ -1634,10 +1638,10 @@ function Zn(t, e) {
|
|
|
1634
1638
|
function to(t, e) {
|
|
1635
1639
|
return t.minY - e.minY;
|
|
1636
1640
|
}
|
|
1637
|
-
function
|
|
1641
|
+
function Lt(t) {
|
|
1638
1642
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1639
1643
|
}
|
|
1640
|
-
function
|
|
1644
|
+
function ht(t) {
|
|
1641
1645
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1642
1646
|
}
|
|
1643
1647
|
function eo(t, e) {
|
|
@@ -1647,10 +1651,10 @@ function no(t, e) {
|
|
|
1647
1651
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);
|
|
1648
1652
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1649
1653
|
}
|
|
1650
|
-
function
|
|
1654
|
+
function Ot(t, e) {
|
|
1651
1655
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1652
1656
|
}
|
|
1653
|
-
function
|
|
1657
|
+
function pt(t, e) {
|
|
1654
1658
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1655
1659
|
}
|
|
1656
1660
|
function J(t) {
|
|
@@ -1664,12 +1668,12 @@ function J(t) {
|
|
|
1664
1668
|
maxY: -1 / 0
|
|
1665
1669
|
};
|
|
1666
1670
|
}
|
|
1667
|
-
function
|
|
1671
|
+
function te(t, e, n, o, i) {
|
|
1668
1672
|
const r = [e, n];
|
|
1669
1673
|
for (; r.length; ) {
|
|
1670
1674
|
if (n = r.pop(), e = r.pop(), n - e <= o) continue;
|
|
1671
1675
|
const a = e + Math.ceil((n - e) / o / 2) * o;
|
|
1672
|
-
|
|
1676
|
+
he(t, a, e, n, i), r.push(e, a, a, n);
|
|
1673
1677
|
}
|
|
1674
1678
|
}
|
|
1675
1679
|
let oo = () => ({
|
|
@@ -1687,132 +1691,132 @@ let oo = () => ({
|
|
|
1687
1691
|
}
|
|
1688
1692
|
});
|
|
1689
1693
|
const io = (t, e) => {
|
|
1690
|
-
const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(), r = (y,
|
|
1691
|
-
const
|
|
1692
|
-
const
|
|
1693
|
-
return Array.from(
|
|
1694
|
-
}),
|
|
1695
|
-
return
|
|
1696
|
-
const { x:
|
|
1694
|
+
const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(), r = (y, A) => {
|
|
1695
|
+
const C = y.selector.flatMap((R) => {
|
|
1696
|
+
const O = W([R]) ? R.range : fe(R, e).range;
|
|
1697
|
+
return Array.from(O.getClientRects());
|
|
1698
|
+
}), S = Yn(C).map((R) => $n(R, A));
|
|
1699
|
+
return S.map((R) => {
|
|
1700
|
+
const { x: O, y: B, width: m, height: w } = R;
|
|
1697
1701
|
return {
|
|
1698
|
-
minX:
|
|
1699
|
-
minY:
|
|
1700
|
-
maxX:
|
|
1701
|
-
maxY:
|
|
1702
|
+
minX: O,
|
|
1703
|
+
minY: B,
|
|
1704
|
+
maxX: O + m,
|
|
1705
|
+
maxY: B + w,
|
|
1702
1706
|
annotation: {
|
|
1703
1707
|
id: y.annotation,
|
|
1704
|
-
rects:
|
|
1708
|
+
rects: S
|
|
1705
1709
|
}
|
|
1706
1710
|
};
|
|
1707
1711
|
});
|
|
1708
1712
|
}, a = () => [...o.values()], s = () => {
|
|
1709
1713
|
n.clear(), o.clear();
|
|
1710
1714
|
}, l = (y) => {
|
|
1711
|
-
const
|
|
1712
|
-
|
|
1713
|
-
},
|
|
1714
|
-
const
|
|
1715
|
-
|
|
1715
|
+
const A = r(y, e.getBoundingClientRect());
|
|
1716
|
+
A.forEach((C) => n.insert(C)), o.set(y.annotation, A);
|
|
1717
|
+
}, f = (y) => {
|
|
1718
|
+
const A = o.get(y.annotation);
|
|
1719
|
+
A && (A.forEach((C) => n.remove(C)), o.delete(y.annotation));
|
|
1716
1720
|
}, g = (y) => {
|
|
1717
|
-
|
|
1718
|
-
}, c = (y,
|
|
1719
|
-
|
|
1720
|
-
const
|
|
1721
|
-
|
|
1722
|
-
const
|
|
1723
|
-
n.load(
|
|
1724
|
-
}, p = (y,
|
|
1725
|
-
const
|
|
1721
|
+
f(y), l(y);
|
|
1722
|
+
}, c = (y, A = !0) => {
|
|
1723
|
+
A && s();
|
|
1724
|
+
const C = e.getBoundingClientRect(), S = y.map((O) => ({ target: O, rects: r(O, C) }));
|
|
1725
|
+
S.forEach(({ target: O, rects: B }) => o.set(O.annotation, B));
|
|
1726
|
+
const R = S.flatMap(({ rects: O }) => O);
|
|
1727
|
+
n.load(R);
|
|
1728
|
+
}, p = (y, A, C = !1) => {
|
|
1729
|
+
const S = n.search({
|
|
1726
1730
|
minX: y,
|
|
1727
|
-
minY:
|
|
1731
|
+
minY: A,
|
|
1728
1732
|
maxX: y,
|
|
1729
|
-
maxY:
|
|
1730
|
-
}),
|
|
1731
|
-
return
|
|
1732
|
-
},
|
|
1733
|
-
const
|
|
1734
|
-
if (
|
|
1733
|
+
maxY: A
|
|
1734
|
+
}), R = (O) => O.annotation.rects.reduce((B, m) => B + m.width * m.height, 0);
|
|
1735
|
+
return S.length > 0 ? (S.sort((O, B) => R(O) - R(B)), C ? S.map((O) => O.annotation.id) : [S[0].annotation.id]) : [];
|
|
1736
|
+
}, u = (y) => {
|
|
1737
|
+
const A = x(y);
|
|
1738
|
+
if (A.length === 0)
|
|
1735
1739
|
return;
|
|
1736
|
-
let
|
|
1737
|
-
for (let
|
|
1738
|
-
const m =
|
|
1739
|
-
|
|
1740
|
+
let C = A[0].left, S = A[0].top, R = A[0].right, O = A[0].bottom;
|
|
1741
|
+
for (let B = 1; B < A.length; B++) {
|
|
1742
|
+
const m = A[B];
|
|
1743
|
+
C = Math.min(C, m.left), S = Math.min(S, m.top), R = Math.max(R, m.right), O = Math.max(O, m.bottom);
|
|
1740
1744
|
}
|
|
1741
|
-
return new DOMRect(
|
|
1745
|
+
return new DOMRect(C, S, R - C, O - S);
|
|
1742
1746
|
}, x = (y) => {
|
|
1743
|
-
const
|
|
1744
|
-
return
|
|
1747
|
+
const A = o.get(y);
|
|
1748
|
+
return A ? A[0].annotation.rects : [];
|
|
1745
1749
|
};
|
|
1746
1750
|
return {
|
|
1747
1751
|
all: a,
|
|
1748
1752
|
clear: s,
|
|
1749
1753
|
getAt: p,
|
|
1750
|
-
getAnnotationBounds:
|
|
1754
|
+
getAnnotationBounds: u,
|
|
1751
1755
|
getAnnotationRects: x,
|
|
1752
|
-
getIntersecting: (y,
|
|
1753
|
-
const
|
|
1754
|
-
return Array.from(
|
|
1755
|
-
annotation: t.getAnnotation(
|
|
1756
|
-
rects: x(
|
|
1757
|
-
})).filter((
|
|
1756
|
+
getIntersecting: (y, A, C, S) => {
|
|
1757
|
+
const R = n.search({ minX: y, minY: A, maxX: C, maxY: S }), O = new Set(R.map((B) => B.annotation.id));
|
|
1758
|
+
return Array.from(O).map((B) => ({
|
|
1759
|
+
annotation: t.getAnnotation(B),
|
|
1760
|
+
rects: x(B)
|
|
1761
|
+
})).filter((B) => !!B.annotation);
|
|
1758
1762
|
},
|
|
1759
1763
|
insert: l,
|
|
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
|
-
on: (y,
|
|
1771
|
+
on: (y, A) => i.on(y, A)
|
|
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
|
|
1776
|
-
},
|
|
1777
|
-
const
|
|
1778
|
-
return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y),
|
|
1779
|
-
n.getAnnotation(
|
|
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 = Ct(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((C) => Ct(C, t)), A = y.filter((C) => !W(C.target.selector));
|
|
1779
|
+
return A.length > 0 ? (console.warn("Could not revive all targets for these annotations:", A), n.bulkAddAnnotation(y, h, d), A) : (n.bulkAddAnnotation(y, h, d), []);
|
|
1780
|
+
}, f = (v, h = M.LOCAL) => {
|
|
1781
|
+
const d = v.map((A) => Ct(A, t)), y = d.filter((A) => !W(A.target.selector));
|
|
1782
|
+
return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y), d.forEach((A) => {
|
|
1783
|
+
n.getAnnotation(A.id) ? n.updateAnnotation(A, h) : n.addAnnotation(A, 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(
|
|
1789
|
-
return
|
|
1790
|
-
},
|
|
1791
|
-
const
|
|
1792
|
-
if (
|
|
1793
|
-
if (h &&
|
|
1794
|
-
const
|
|
1795
|
-
if (
|
|
1785
|
+
}, g = (v, h = M.LOCAL) => {
|
|
1786
|
+
const d = yt(v, t);
|
|
1787
|
+
n.updateTarget(d, h);
|
|
1788
|
+
}, c = (v, h = M.LOCAL) => {
|
|
1789
|
+
const d = v.map((y) => yt(y, t));
|
|
1790
|
+
n.bulkUpdateTargets(d, h);
|
|
1791
|
+
}, p = (v, h, d) => {
|
|
1792
|
+
const y = o.getAt(v, h, !!d).map((C) => n.getAnnotation(C)), A = d ? y.filter(d) : y;
|
|
1793
|
+
return A.length > 0 ? A[0] : void 0;
|
|
1794
|
+
}, u = (v, h, d, y = 5) => {
|
|
1795
|
+
const A = o.getAnnotationRects(v);
|
|
1796
|
+
if (A.length !== 0) {
|
|
1797
|
+
if (h && d) {
|
|
1798
|
+
const C = A.find(({ top: S, right: R, bottom: O, left: B }) => h >= B - y && h <= R + y && d >= S - y && d <= O + y);
|
|
1799
|
+
if (C) return C;
|
|
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((
|
|
1803
|
+
}, x = () => o.recalculate(), b = (v) => o.on("recalculate", v);
|
|
1804
|
+
return n.observe(({ changes: v }) => {
|
|
1805
|
+
const h = (v.deleted || []).filter((A) => W(A.target.selector)), d = (v.created || []).filter((A) => W(A.target.selector)), y = (v.updated || []).filter((A) => W(A.newValue.target.selector));
|
|
1806
|
+
(h == null ? void 0 : h.length) > 0 && h.forEach((A) => o.remove(A.target)), d.length > 0 && o.set(d.map((A) => A.target), !1), (y == null ? void 0 : y.length) > 0 && y.forEach(({ newValue: A }) => o.update(A.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, A = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, C = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1852
|
+
return i.fillRect(v - 2, h - 2.5 - A, y, A), i.fillStyle = "#fff", i.fillText(x.appearance.label, v + 1, h - C), {
|
|
1849
1853
|
fill: x.appearance.color,
|
|
1850
|
-
fillOpacity:
|
|
1854
|
+
fillOpacity: u ? 0.45 : 0.18
|
|
1851
1855
|
};
|
|
1852
1856
|
}
|
|
1853
1857
|
},
|
|
@@ -1857,23 +1861,23 @@ const io = (t, e) => {
|
|
|
1857
1861
|
c.scale(2, 2), c.translate(0.5, 0.5);
|
|
1858
1862
|
}
|
|
1859
1863
|
};
|
|
1860
|
-
},
|
|
1864
|
+
}, pe = (t) => {
|
|
1861
1865
|
if (t === null)
|
|
1862
1866
|
return document.scrollingElement;
|
|
1863
1867
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
1864
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
1868
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : pe(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:
|
|
1869
|
-
}, r =
|
|
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" });
|
|
1873
|
+
}, r = pe(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 =
|
|
1876
|
-
if (
|
|
1879
|
+
const l = yt(a.target, t), { range: f } = l.selector[0];
|
|
1880
|
+
if (f && !f.collapsed)
|
|
1877
1881
|
return i(l), !0;
|
|
1878
1882
|
}
|
|
1879
1883
|
}
|
|
@@ -1882,19 +1886,19 @@ const io = (t, e) => {
|
|
|
1882
1886
|
...t,
|
|
1883
1887
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
1884
1888
|
user: t.user || e.user
|
|
1885
|
-
}),
|
|
1886
|
-
function
|
|
1889
|
+
}), Tt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1890
|
+
function Rt(t, e, n, o) {
|
|
1887
1891
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
1888
1892
|
}
|
|
1889
1893
|
function et(t, e, n, o) {
|
|
1890
1894
|
t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
|
|
1891
1895
|
}
|
|
1892
|
-
function
|
|
1896
|
+
function ge(t, e) {
|
|
1893
1897
|
const n = e.slice(0, e.length - 1);
|
|
1894
1898
|
for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
|
|
1895
1899
|
return n;
|
|
1896
1900
|
}
|
|
1897
|
-
function
|
|
1901
|
+
function me(t) {
|
|
1898
1902
|
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
1899
1903
|
const e = t.split(",");
|
|
1900
1904
|
let n = e.lastIndexOf("");
|
|
@@ -1954,9 +1958,9 @@ const st = {
|
|
|
1954
1958
|
".": 190,
|
|
1955
1959
|
"/": 191,
|
|
1956
1960
|
"`": 192,
|
|
1957
|
-
"-":
|
|
1958
|
-
"=":
|
|
1959
|
-
";":
|
|
1961
|
+
"-": Tt ? 173 : 189,
|
|
1962
|
+
"=": Tt ? 61 : 187,
|
|
1963
|
+
";": Tt ? 59 : 186,
|
|
1960
1964
|
"'": 222,
|
|
1961
1965
|
"[": 219,
|
|
1962
1966
|
"]": 221,
|
|
@@ -1977,7 +1981,7 @@ const st = {
|
|
|
1977
1981
|
"⌘": 91,
|
|
1978
1982
|
cmd: 91,
|
|
1979
1983
|
command: 91
|
|
1980
|
-
},
|
|
1984
|
+
}, Nt = {
|
|
1981
1985
|
16: "shiftKey",
|
|
1982
1986
|
18: "altKey",
|
|
1983
1987
|
17: "ctrlKey",
|
|
@@ -1994,13 +1998,13 @@ const st = {
|
|
|
1994
1998
|
}, I = {};
|
|
1995
1999
|
for (let t = 1; t < 20; t++)
|
|
1996
2000
|
st["f".concat(t)] = 111 + t;
|
|
1997
|
-
let k = [], rt = null,
|
|
2001
|
+
let k = [], rt = null, ye = "all";
|
|
1998
2002
|
const F = /* @__PURE__ */ new Map(), ct = (t) => st[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), fo = (t) => Object.keys(st).find((e) => st[e] === t), ho = (t) => Object.keys(j).find((e) => j[e] === t);
|
|
1999
|
-
function
|
|
2000
|
-
|
|
2003
|
+
function be(t) {
|
|
2004
|
+
ye = t || "all";
|
|
2001
2005
|
}
|
|
2002
2006
|
function at() {
|
|
2003
|
-
return
|
|
2007
|
+
return ye || "all";
|
|
2004
2008
|
}
|
|
2005
2009
|
function po() {
|
|
2006
2010
|
return k.slice(0);
|
|
@@ -2048,34 +2052,34 @@ function wo(t, e) {
|
|
|
2048
2052
|
let {
|
|
2049
2053
|
element: s
|
|
2050
2054
|
} = a;
|
|
2051
|
-
return
|
|
2055
|
+
return Dt(s);
|
|
2052
2056
|
}) : o++;
|
|
2053
|
-
at() === t &&
|
|
2057
|
+
at() === t && be(e || "all");
|
|
2054
2058
|
}
|
|
2055
2059
|
function vo(t) {
|
|
2056
2060
|
let e = t.keyCode || t.which || t.charCode;
|
|
2057
2061
|
const n = k.indexOf(e);
|
|
2058
2062
|
if (n >= 0 && k.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && k.splice(0, k.length), (e === 93 || e === 224) && (e = 91), e in D) {
|
|
2059
2063
|
D[e] = !1;
|
|
2060
|
-
for (const o in j) j[o] === e && (
|
|
2064
|
+
for (const o in j) j[o] === e && (X[o] = !1);
|
|
2061
2065
|
}
|
|
2062
2066
|
}
|
|
2063
|
-
function
|
|
2067
|
+
function we(t) {
|
|
2064
2068
|
if (typeof t > "u")
|
|
2065
2069
|
Object.keys(I).forEach((i) => {
|
|
2066
|
-
Array.isArray(I[i]) && I[i].forEach((r) =>
|
|
2067
|
-
}),
|
|
2070
|
+
Array.isArray(I[i]) && I[i].forEach((r) => gt(r)), delete I[i];
|
|
2071
|
+
}), Dt(null);
|
|
2068
2072
|
else if (Array.isArray(t))
|
|
2069
2073
|
t.forEach((i) => {
|
|
2070
|
-
i.key &&
|
|
2074
|
+
i.key && gt(i);
|
|
2071
2075
|
});
|
|
2072
2076
|
else if (typeof t == "object")
|
|
2073
|
-
t.key &&
|
|
2077
|
+
t.key && gt(t);
|
|
2074
2078
|
else if (typeof t == "string") {
|
|
2075
2079
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
2076
2080
|
n[o - 1] = arguments[o];
|
|
2077
2081
|
let [i, r] = n;
|
|
2078
|
-
typeof i == "function" && (r = i, i = ""),
|
|
2082
|
+
typeof i == "function" && (r = i, i = ""), gt({
|
|
2079
2083
|
key: t,
|
|
2080
2084
|
scope: i,
|
|
2081
2085
|
method: r,
|
|
@@ -2083,25 +2087,25 @@ function be(t) {
|
|
|
2083
2087
|
});
|
|
2084
2088
|
}
|
|
2085
2089
|
}
|
|
2086
|
-
const
|
|
2090
|
+
const gt = (t) => {
|
|
2087
2091
|
let {
|
|
2088
2092
|
key: e,
|
|
2089
2093
|
scope: n,
|
|
2090
2094
|
method: o,
|
|
2091
2095
|
splitKey: i = "+"
|
|
2092
2096
|
} = t;
|
|
2093
|
-
|
|
2094
|
-
const s = a.split(i), l = s.length,
|
|
2097
|
+
me(e).forEach((a) => {
|
|
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
|
-
const c = l > 1 ?
|
|
2098
|
-
I[g] = I[g].filter((
|
|
2099
|
-
const
|
|
2100
|
-
return
|
|
2101
|
-
}), p.forEach((
|
|
2101
|
+
const c = l > 1 ? ge(j, s) : [], p = [];
|
|
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) => Dt(u));
|
|
2102
2106
|
});
|
|
2103
2107
|
};
|
|
2104
|
-
function
|
|
2108
|
+
function ee(t, e, n, o) {
|
|
2105
2109
|
if (e.element !== o)
|
|
2106
2110
|
return;
|
|
2107
2111
|
let i;
|
|
@@ -2112,46 +2116,46 @@ function te(t, e, n, o) {
|
|
|
2112
2116
|
(e.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(k), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2113
2117
|
}
|
|
2114
2118
|
}
|
|
2115
|
-
function
|
|
2119
|
+
function ne(t, e) {
|
|
2116
2120
|
const n = I["*"];
|
|
2117
2121
|
let o = t.keyCode || t.which || t.charCode;
|
|
2118
|
-
if (!
|
|
2122
|
+
if (!X.filter.call(this, t)) return;
|
|
2119
2123
|
if ((o === 93 || o === 224) && (o = 91), k.indexOf(o) === -1 && o !== 229 && k.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((s) => {
|
|
2120
|
-
const l =
|
|
2124
|
+
const l = Nt[s];
|
|
2121
2125
|
t[s] && k.indexOf(l) === -1 ? k.push(l) : !t[s] && k.indexOf(l) > -1 ? k.splice(k.indexOf(l), 1) : s === "metaKey" && t[s] && k.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (k = k.slice(k.indexOf(l))));
|
|
2122
2126
|
}), o in D) {
|
|
2123
2127
|
D[o] = !0;
|
|
2124
2128
|
for (const s in j)
|
|
2125
|
-
j[s] === o && (
|
|
2129
|
+
j[s] === o && (X[s] = !0);
|
|
2126
2130
|
if (!n) return;
|
|
2127
2131
|
}
|
|
2128
2132
|
for (const s in D)
|
|
2129
|
-
Object.prototype.hasOwnProperty.call(D, s) && (D[s] = t[
|
|
2133
|
+
Object.prototype.hasOwnProperty.call(D, s) && (D[s] = t[Nt[s]]);
|
|
2130
2134
|
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (k.indexOf(17) === -1 && k.push(17), k.indexOf(18) === -1 && k.push(18), D[17] = !0, D[18] = !0);
|
|
2131
2135
|
const i = at();
|
|
2132
2136
|
if (n)
|
|
2133
2137
|
for (let s = 0; s < n.length; s++)
|
|
2134
|
-
n[s].scope === i && (t.type === "keydown" && n[s].keydown || t.type === "keyup" && n[s].keyup) &&
|
|
2138
|
+
n[s].scope === i && (t.type === "keydown" && n[s].keydown || t.type === "keyup" && n[s].keyup) && ee(t, n[s], i, e);
|
|
2135
2139
|
if (!(o in I)) return;
|
|
2136
2140
|
const r = I[o], a = r.length;
|
|
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
|
-
c.sort().join("") === k.sort().join("") &&
|
|
2148
|
+
c.sort().join("") === k.sort().join("") && ee(t, l, i, e);
|
|
2145
2149
|
}
|
|
2146
2150
|
}
|
|
2147
|
-
function
|
|
2151
|
+
function X(t, e, n) {
|
|
2148
2152
|
k = [];
|
|
2149
|
-
const o =
|
|
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 && (
|
|
2152
|
-
t = o[s].split(g), i = [], t.length > 1 && (i =
|
|
2153
|
+
const o = me(t);
|
|
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 && we(t, r); s < o.length; s++)
|
|
2156
|
+
t = o[s].split(g), i = [], t.length > 1 && (i = ge(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
|
|
2169
|
+
const u = function() {
|
|
2170
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2171
|
+
return ne(b, a);
|
|
2168
2172
|
}, x = function() {
|
|
2169
|
-
let
|
|
2170
|
-
|
|
2173
|
+
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2174
|
+
ne(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
|
-
}),
|
|
2180
|
+
}), Rt(a, "keydown", u, c), Rt(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
|
-
},
|
|
2189
|
+
}, Rt(window, "focus", u, c);
|
|
2186
2190
|
}
|
|
2187
2191
|
}
|
|
2188
2192
|
}
|
|
@@ -2194,7 +2198,7 @@ function xo(t) {
|
|
|
2194
2198
|
});
|
|
2195
2199
|
});
|
|
2196
2200
|
}
|
|
2197
|
-
function
|
|
2201
|
+
function Dt(t) {
|
|
2198
2202
|
const e = Object.values(I).flat();
|
|
2199
2203
|
if (e.findIndex((o) => {
|
|
2200
2204
|
let {
|
|
@@ -2224,9 +2228,9 @@ function Vt(t) {
|
|
|
2224
2228
|
et(window, "focus", i, r), rt = null;
|
|
2225
2229
|
}
|
|
2226
2230
|
}
|
|
2227
|
-
const
|
|
2231
|
+
const Bt = {
|
|
2228
2232
|
getPressedKeyString: go,
|
|
2229
|
-
setScope:
|
|
2233
|
+
setScope: be,
|
|
2230
2234
|
getScope: at,
|
|
2231
2235
|
deleteScope: wo,
|
|
2232
2236
|
getPressedKeyCodes: po,
|
|
@@ -2234,147 +2238,149 @@ const Rt = {
|
|
|
2234
2238
|
isPressed: bo,
|
|
2235
2239
|
filter: yo,
|
|
2236
2240
|
trigger: xo,
|
|
2237
|
-
unbind:
|
|
2241
|
+
unbind: we,
|
|
2238
2242
|
keyMap: st,
|
|
2239
2243
|
modifier: j,
|
|
2240
|
-
modifierMap:
|
|
2244
|
+
modifierMap: Nt
|
|
2241
2245
|
};
|
|
2242
|
-
for (const t in
|
|
2243
|
-
Object.prototype.hasOwnProperty.call(
|
|
2246
|
+
for (const t in Bt)
|
|
2247
|
+
Object.prototype.hasOwnProperty.call(Bt, t) && (X[t] = Bt[t]);
|
|
2244
2248
|
if (typeof window < "u") {
|
|
2245
2249
|
const t = window.hotkeys;
|
|
2246
|
-
|
|
2250
|
+
X.noConflict = (e) => (e && window.hotkeys === X && (window.hotkeys = t), X), window.hotkeys = X;
|
|
2247
2251
|
}
|
|
2248
2252
|
const Ao = (t, e, n) => {
|
|
2249
2253
|
let o;
|
|
2250
|
-
const i = (
|
|
2254
|
+
const i = (S) => o = S;
|
|
2251
2255
|
let r;
|
|
2252
|
-
const a = (
|
|
2256
|
+
const a = (S) => r = S;
|
|
2253
2257
|
let s = !0;
|
|
2254
|
-
const l = (
|
|
2255
|
-
s =
|
|
2256
|
-
}, { store:
|
|
2257
|
-
let c, p,
|
|
2258
|
-
const x = (
|
|
2259
|
-
var
|
|
2258
|
+
const l = (S) => {
|
|
2259
|
+
s = S, b.clear(), S || (c = void 0, p = void 0, u = void 0);
|
|
2260
|
+
}, { store: f, selection: g } = e;
|
|
2261
|
+
let c, p, u;
|
|
2262
|
+
const x = (S) => {
|
|
2263
|
+
var O;
|
|
2260
2264
|
if (!s || p === !1)
|
|
2261
2265
|
return;
|
|
2262
|
-
c = !((
|
|
2263
|
-
annotation:
|
|
2266
|
+
c = !((O = S.target.parentElement) != null && O.closest(H)) ? {
|
|
2267
|
+
annotation: ce(),
|
|
2264
2268
|
selector: [],
|
|
2265
2269
|
creator: o,
|
|
2266
2270
|
created: /* @__PURE__ */ new Date()
|
|
2267
2271
|
} : void 0;
|
|
2268
2272
|
};
|
|
2269
2273
|
t.addEventListener("selectstart", x);
|
|
2270
|
-
const
|
|
2271
|
-
var
|
|
2274
|
+
const b = _t((S) => {
|
|
2275
|
+
var T, N;
|
|
2272
2276
|
if (!s) return;
|
|
2273
|
-
const
|
|
2274
|
-
if (!!((
|
|
2277
|
+
const R = document.getSelection();
|
|
2278
|
+
if (!!((N = (T = R.anchorNode) == null ? void 0 : T.parentElement) != null && N.closest(H))) {
|
|
2275
2279
|
c = void 0;
|
|
2276
2280
|
return;
|
|
2277
2281
|
}
|
|
2278
|
-
if (
|
|
2279
|
-
if (
|
|
2280
|
-
|
|
2282
|
+
if (S.timeStamp - ((u == null ? void 0 : u.timeStamp) || S.timeStamp) < 1e3 && !c && x(u || S), !c) return;
|
|
2283
|
+
if (R.isCollapsed) {
|
|
2284
|
+
f.getAnnotation(c.annotation) && (g.clear(), f.deleteAnnotation(c.annotation));
|
|
2281
2285
|
return;
|
|
2282
2286
|
}
|
|
2283
|
-
const
|
|
2284
|
-
if (Vn(
|
|
2285
|
-
const
|
|
2286
|
-
(
|
|
2287
|
-
var
|
|
2288
|
-
return
|
|
2287
|
+
const m = R.getRangeAt(0), w = Pn(m, t);
|
|
2288
|
+
if (Vn(w)) return;
|
|
2289
|
+
const E = Bn(w.cloneRange());
|
|
2290
|
+
(E.length !== c.selector.length || E.some((K, P) => {
|
|
2291
|
+
var lt;
|
|
2292
|
+
return K.toString() !== ((lt = c.selector[P]) == null ? void 0 : lt.quote);
|
|
2289
2293
|
})) && (c = {
|
|
2290
2294
|
...c,
|
|
2291
|
-
selector:
|
|
2295
|
+
selector: E.map((K) => Xn(K, 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 = (S) => {
|
|
2305
|
+
u = Hn(S), p = u.button === 0, c = void 0;
|
|
2302
2306
|
};
|
|
2303
|
-
document.addEventListener("pointerdown",
|
|
2304
|
-
const h = (
|
|
2305
|
-
var
|
|
2306
|
-
if (!!((
|
|
2307
|
+
document.addEventListener("pointerdown", v);
|
|
2308
|
+
const h = (S) => {
|
|
2309
|
+
var m;
|
|
2310
|
+
if (!!((m = S.target.parentElement) != null && m.closest(H)) || !p)
|
|
2307
2311
|
return;
|
|
2308
|
-
const
|
|
2309
|
-
const { x:
|
|
2310
|
-
if (
|
|
2311
|
-
const { selected:
|
|
2312
|
-
(
|
|
2312
|
+
const O = () => {
|
|
2313
|
+
const { x: w, y: E } = t.getBoundingClientRect(), L = S.target instanceof Node && t.contains(S.target) && f.getAt(S.clientX - w, S.clientY - E, r);
|
|
2314
|
+
if (L) {
|
|
2315
|
+
const { selected: T } = g;
|
|
2316
|
+
(T.length !== 1 || T[0].id !== L.id) && g.userSelect(L.id, S);
|
|
2313
2317
|
} else g.isEmpty() || g.clear();
|
|
2314
|
-
},
|
|
2318
|
+
}, B = S.timeStamp - u.timeStamp;
|
|
2315
2319
|
setTimeout(() => {
|
|
2316
|
-
const
|
|
2317
|
-
|
|
2320
|
+
const w = document.getSelection();
|
|
2321
|
+
w != null && w.isCollapsed && B < 300 ? O() : c && g.userSelect(c.annotation, S);
|
|
2318
2322
|
});
|
|
2319
2323
|
};
|
|
2320
2324
|
document.addEventListener("pointerup", h);
|
|
2321
|
-
const
|
|
2322
|
-
...
|
|
2325
|
+
const d = ["up", "down", "left", "right"], y = [
|
|
2326
|
+
...d.map((S) => `shift+${S}`),
|
|
2323
2327
|
"ctrl+a",
|
|
2324
2328
|
"⌘+a"
|
|
2325
2329
|
];
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
})
|
|
2329
|
-
|
|
2330
|
-
|
|
2330
|
+
X(y.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
|
|
2331
|
+
S.repeat || (u = jn(S));
|
|
2332
|
+
});
|
|
2333
|
+
const A = (S) => {
|
|
2334
|
+
S.repeat || (c = void 0, g.clear());
|
|
2335
|
+
};
|
|
2336
|
+
return X(d.join(","), { element: document.body, keydown: !0, keyup: !1 }, A), X(d.join(","), { element: t, keydown: !0, keyup: !1 }, A), {
|
|
2331
2337
|
destroy: () => {
|
|
2332
|
-
c = void 0, p = void 0,
|
|
2338
|
+
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), X.unbind();
|
|
2333
2339
|
},
|
|
2334
2340
|
setFilter: a,
|
|
2335
2341
|
setUser: i,
|
|
2336
2342
|
setAnnotatingEnabled: l
|
|
2337
2343
|
};
|
|
2338
|
-
},
|
|
2344
|
+
}, oe = "SPANS", Ro = (t, e = {}) => {
|
|
2339
2345
|
Mn(t), kn(t);
|
|
2340
2346
|
const n = lo(e, {
|
|
2341
2347
|
annotatingEnabled: !0,
|
|
2342
2348
|
user: Sn()
|
|
2343
2349
|
}), o = ro(t, n.userSelectAction), { selection: i, viewport: r } = o, a = o.store, s = pn(a), l = mn(o, s, n.adapter);
|
|
2344
|
-
let
|
|
2345
|
-
const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" :
|
|
2350
|
+
let f = n.user;
|
|
2351
|
+
const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : oe : n.renderer || oe, c = g === "SPANS" ? $e(t, o, r) : g === "CSS_HIGHLIGHTS" ? Ye(t, o, r) : g === "CANVAS" ? Be(t, o, r) : void 0;
|
|
2346
2352
|
if (!c)
|
|
2347
2353
|
throw `Unknown renderer implementation: ${g}`;
|
|
2348
2354
|
console.debug(`Using ${g} renderer`), n.style && c.setStyle(n.style);
|
|
2349
2355
|
const p = Ao(t, o, n.offsetReferenceSelector);
|
|
2350
|
-
p.setUser(
|
|
2351
|
-
const
|
|
2356
|
+
p.setUser(f), p.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2357
|
+
const u = bn(o, s, n.adapter), x = () => f, b = (C) => {
|
|
2352
2358
|
p.setAnnotatingEnabled(
|
|
2353
|
-
|
|
2359
|
+
C === void 0 ? !0 : C
|
|
2354
2360
|
);
|
|
2355
|
-
},
|
|
2356
|
-
c.setFilter(
|
|
2357
|
-
}, h = (
|
|
2358
|
-
|
|
2359
|
-
},
|
|
2360
|
-
|
|
2361
|
-
}, y = (
|
|
2362
|
-
|
|
2361
|
+
}, v = (C) => {
|
|
2362
|
+
c.setFilter(C), p.setFilter(C);
|
|
2363
|
+
}, h = (C) => {
|
|
2364
|
+
f = C, p.setUser(C);
|
|
2365
|
+
}, d = (C) => {
|
|
2366
|
+
C && (c.setPainter(ao(t, C, n.presence)), C.on("selectionChange", () => c.redraw()));
|
|
2367
|
+
}, y = (C) => {
|
|
2368
|
+
C ? i.setSelected(C) : i.clear();
|
|
2363
2369
|
};
|
|
2364
2370
|
return {
|
|
2365
|
-
...
|
|
2371
|
+
...u,
|
|
2366
2372
|
destroy: () => {
|
|
2367
2373
|
c.destroy(), p.destroy(), s.destroy();
|
|
2368
2374
|
},
|
|
2369
2375
|
element: t,
|
|
2370
2376
|
getUser: x,
|
|
2371
|
-
setAnnotatingEnabled:
|
|
2372
|
-
setFilter:
|
|
2377
|
+
setAnnotatingEnabled: b,
|
|
2378
|
+
setFilter: v,
|
|
2373
2379
|
setStyle: c.setStyle.bind(c),
|
|
2374
2380
|
redraw: c.redraw.bind(c),
|
|
2375
2381
|
setUser: h,
|
|
2376
2382
|
setSelected: y,
|
|
2377
|
-
setPresenceProvider:
|
|
2383
|
+
setPresenceProvider: d,
|
|
2378
2384
|
setVisible: c.setVisible.bind(c),
|
|
2379
2385
|
on: l.on,
|
|
2380
2386
|
off: l.off,
|
|
@@ -2383,9 +2389,9 @@ const Ao = (t, e, n) => {
|
|
|
2383
2389
|
};
|
|
2384
2390
|
};
|
|
2385
2391
|
export {
|
|
2386
|
-
|
|
2392
|
+
mt as DEFAULT_SELECTED_STYLE,
|
|
2387
2393
|
q as DEFAULT_STYLE,
|
|
2388
|
-
|
|
2394
|
+
ue as NOT_ANNOTATABLE_CLASS,
|
|
2389
2395
|
H as NOT_ANNOTATABLE_SELECTOR,
|
|
2390
2396
|
M as Origin,
|
|
2391
2397
|
Ge as UserSelectAction,
|
|
@@ -2395,8 +2401,8 @@ export {
|
|
|
2395
2401
|
Hn as clonePointerEvent,
|
|
2396
2402
|
Eo as createBody,
|
|
2397
2403
|
Be as createCanvasRenderer,
|
|
2398
|
-
|
|
2399
|
-
|
|
2404
|
+
Ye as createHighlightsRenderer,
|
|
2405
|
+
Ke as createRenderer,
|
|
2400
2406
|
$e as createSpansRenderer,
|
|
2401
2407
|
Ro as createTextAnnotator,
|
|
2402
2408
|
ro as createTextAnnotatorState,
|
|
@@ -2405,18 +2411,18 @@ export {
|
|
|
2405
2411
|
So as getAnnotatableFragment,
|
|
2406
2412
|
Co as getClientRectsPonyfill,
|
|
2407
2413
|
_n as getQuoteContext,
|
|
2408
|
-
|
|
2414
|
+
kt as getRangeAnnotatableContents,
|
|
2409
2415
|
W as isRevived,
|
|
2410
2416
|
Vn as isWhitespaceOrEmpty,
|
|
2411
|
-
|
|
2417
|
+
Yn as mergeClientRects,
|
|
2412
2418
|
$n as normalizeRectWithOffset,
|
|
2413
2419
|
Ae as paint,
|
|
2414
2420
|
Wn as parseW3CTextAnnotation,
|
|
2415
2421
|
kn as programmaticallyFocusable,
|
|
2416
2422
|
Xn as rangeToSelector,
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2423
|
+
Ct as reviveAnnotation,
|
|
2424
|
+
fe as reviveSelector,
|
|
2425
|
+
yt as reviveTarget,
|
|
2420
2426
|
qn as serializeW3CTextAnnotation,
|
|
2421
2427
|
Bn as splitAnnotatableRanges,
|
|
2422
2428
|
Lo as toDomRectList,
|