@recogito/text-annotator 3.0.0-rc.54 → 3.0.0-rc.56
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,13 +1,13 @@
|
|
|
1
|
-
const re = "not-annotatable",
|
|
1
|
+
const re = "not-annotatable", et = `.${re}`, it = (t) => {
|
|
2
2
|
var n;
|
|
3
|
-
return !!(t instanceof HTMLElement ? t.closest(
|
|
3
|
+
return !!(t instanceof HTMLElement ? t.closest(et) : (n = t.parentElement) == null ? void 0 : n.closest(et));
|
|
4
4
|
}, Ce = (t) => {
|
|
5
5
|
const e = t.commonAncestorContainer;
|
|
6
6
|
return !it(e);
|
|
7
7
|
}, Le = (t) => t.addEventListener("click", (e) => {
|
|
8
8
|
// Allow clicks within not-annotatable elements
|
|
9
|
-
!e.target.closest(
|
|
10
|
-
}),
|
|
9
|
+
!e.target.closest(et) && !e.target.closest("a") && e.preventDefault();
|
|
10
|
+
}), vt = (t) => ({
|
|
11
11
|
...t,
|
|
12
12
|
type: t.type,
|
|
13
13
|
x: t.x,
|
|
@@ -51,16 +51,16 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
51
51
|
timeStamp: t.timeStamp
|
|
52
52
|
}), Te = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Oe = (t) => {
|
|
53
53
|
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
54
|
-
},
|
|
54
|
+
}, Dt = (t, e = 10) => {
|
|
55
55
|
let n;
|
|
56
56
|
return (...o) => {
|
|
57
57
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
58
58
|
};
|
|
59
|
-
},
|
|
59
|
+
}, Re = function* (t) {
|
|
60
60
|
const e = document.createNodeIterator(
|
|
61
61
|
t.commonAncestorContainer,
|
|
62
62
|
NodeFilter.SHOW_ELEMENT,
|
|
63
|
-
(o) => o instanceof HTMLElement && o.classList.contains(re) && !o.parentElement.closest(
|
|
63
|
+
(o) => o instanceof HTMLElement && o.classList.contains(re) && !o.parentElement.closest(et) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
64
64
|
);
|
|
65
65
|
let n;
|
|
66
66
|
for (; n = e.nextNode(); )
|
|
@@ -69,7 +69,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
69
69
|
if (!Ce(t)) return [];
|
|
70
70
|
const e = [];
|
|
71
71
|
let n = null;
|
|
72
|
-
for (const o of
|
|
72
|
+
for (const o of Re(t)) {
|
|
73
73
|
let i;
|
|
74
74
|
n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
|
|
75
75
|
}
|
|
@@ -78,20 +78,20 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
78
78
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
79
79
|
}
|
|
80
80
|
return e.length > 0 ? e : [t];
|
|
81
|
-
},
|
|
81
|
+
}, Nt = (t) => {
|
|
82
82
|
const e = t.cloneContents();
|
|
83
|
-
return e.querySelectorAll(
|
|
84
|
-
},
|
|
83
|
+
return e.querySelectorAll(et).forEach((n) => n.remove()), e;
|
|
84
|
+
}, Be = (t, e, n = 10, o) => {
|
|
85
85
|
const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
|
|
86
86
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
87
|
-
const a =
|
|
87
|
+
const a = Nt(s).textContent, r = document.createRange();
|
|
88
88
|
r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
|
|
89
|
-
const
|
|
89
|
+
const l = Nt(r).textContent;
|
|
90
90
|
return {
|
|
91
91
|
prefix: a.substring(a.length - n),
|
|
92
|
-
suffix:
|
|
92
|
+
suffix: l.substring(0, n)
|
|
93
93
|
};
|
|
94
|
-
},
|
|
94
|
+
}, q = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()), Ue = (t, e) => {
|
|
95
95
|
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
96
96
|
top: n(t.top),
|
|
97
97
|
bottom: n(t.bottom),
|
|
@@ -115,17 +115,17 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
115
115
|
return "block-contains";
|
|
116
116
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
117
117
|
return "block-is-contained";
|
|
118
|
-
},
|
|
118
|
+
}, _e = (t, e) => {
|
|
119
119
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
|
|
120
120
|
return new DOMRect(n, i, o - n, s - i);
|
|
121
|
-
},
|
|
121
|
+
}, Ne = (t) => t.reduce((e, n) => {
|
|
122
122
|
if (n.width === 0 || n.height === 0)
|
|
123
123
|
return e;
|
|
124
124
|
let o = [...e], i = !1;
|
|
125
125
|
for (const s of e) {
|
|
126
|
-
const a =
|
|
126
|
+
const a = Ue(n, s);
|
|
127
127
|
if (a === "inline-adjacent") {
|
|
128
|
-
o = o.map((r) => r === s ?
|
|
128
|
+
o = o.map((r) => r === s ? _e(n, s) : r), i = !0;
|
|
129
129
|
break;
|
|
130
130
|
} else if (a === "inline-contains") {
|
|
131
131
|
o = o.map((r) => r === s ? n : r), i = !0;
|
|
@@ -149,50 +149,50 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
149
149
|
}), Ve = (t, e, n) => {
|
|
150
150
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
151
151
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
152
|
-
const s =
|
|
153
|
-
return n ? { quote: a, start: r, end:
|
|
152
|
+
const s = Nt(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
|
|
153
|
+
return n ? { quote: a, start: r, end: l, range: t, offsetReference: i } : { quote: a, start: r, end: l, range: t };
|
|
154
154
|
}, ae = (t, e) => {
|
|
155
155
|
var h, u;
|
|
156
156
|
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
157
157
|
e,
|
|
158
158
|
NodeFilter.SHOW_TEXT,
|
|
159
|
-
(
|
|
159
|
+
(p) => {
|
|
160
160
|
var v;
|
|
161
|
-
return (v =
|
|
161
|
+
return (v = p.parentElement) != null && v.closest(et) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
162
162
|
}
|
|
163
163
|
);
|
|
164
164
|
let a = 0;
|
|
165
165
|
const r = document.createRange();
|
|
166
|
-
let
|
|
167
|
-
|
|
166
|
+
let l = s.nextNode();
|
|
167
|
+
l === null && console.error("Could not revive annotation target. Content missing.");
|
|
168
168
|
let f = !i;
|
|
169
|
-
for (;
|
|
170
|
-
if (f || (f = i == null ? void 0 : i.contains(
|
|
171
|
-
const
|
|
172
|
-
if (a +
|
|
173
|
-
r.setStart(
|
|
169
|
+
for (; l !== null; ) {
|
|
170
|
+
if (f || (f = typeof (i == null ? void 0 : i.contains) == "function" ? i.contains(l) : !1), f) {
|
|
171
|
+
const p = ((h = l.textContent) == null ? void 0 : h.length) || 0;
|
|
172
|
+
if (a + p > n) {
|
|
173
|
+
r.setStart(l, n - a);
|
|
174
174
|
break;
|
|
175
175
|
}
|
|
176
|
-
a +=
|
|
176
|
+
a += p;
|
|
177
177
|
}
|
|
178
|
-
|
|
178
|
+
l = s.nextNode();
|
|
179
179
|
}
|
|
180
|
-
for (;
|
|
181
|
-
const
|
|
182
|
-
if (a +
|
|
183
|
-
r.setEnd(
|
|
180
|
+
for (; l !== null; ) {
|
|
181
|
+
const p = ((u = l.textContent) == null ? void 0 : u.length) || 0;
|
|
182
|
+
if (a + p >= o) {
|
|
183
|
+
r.setEnd(l, o - a);
|
|
184
184
|
break;
|
|
185
185
|
}
|
|
186
|
-
a +=
|
|
186
|
+
a += p, l = s.nextNode();
|
|
187
187
|
}
|
|
188
188
|
return {
|
|
189
189
|
...t,
|
|
190
190
|
range: r
|
|
191
191
|
};
|
|
192
|
-
},
|
|
192
|
+
}, At = (t, e) => q(t.selector) ? t : {
|
|
193
193
|
...t,
|
|
194
194
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ae(n, e))
|
|
195
|
-
},
|
|
195
|
+
}, Et = (t, e) => q(t.target.selector) ? t : { ...t, target: At(t.target, e) }, De = (t, e) => {
|
|
196
196
|
const n = t.cloneRange();
|
|
197
197
|
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
198
198
|
}, ce = (t) => {
|
|
@@ -200,82 +200,82 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
200
200
|
return document.scrollingElement;
|
|
201
201
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
202
202
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
|
|
203
|
-
},
|
|
203
|
+
}, Ye = (t, e) => (n) => {
|
|
204
204
|
const o = typeof n == "string" ? n : n.id, i = (a) => {
|
|
205
|
-
const r = s.getBoundingClientRect(),
|
|
206
|
-
s.scroll({ top:
|
|
205
|
+
const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), v = h.top - r.top, g = h.left - r.left, m = s.parentElement ? s.scrollTop : 0, A = s.parentElement ? s.scrollLeft : 0, d = v + m - (l - p) / 2, c = g + A - (f - u) / 2;
|
|
206
|
+
s.scroll({ top: d, left: c, behavior: "smooth" });
|
|
207
207
|
}, s = ce(t);
|
|
208
208
|
if (s) {
|
|
209
209
|
const a = e.getAnnotation(o), { range: r } = a.target.selector[0];
|
|
210
210
|
if (r && !r.collapsed)
|
|
211
211
|
return i(a.target), !0;
|
|
212
212
|
{
|
|
213
|
-
const
|
|
213
|
+
const l = At(a.target, t), { range: f } = l.selector[0];
|
|
214
214
|
if (f && !f.collapsed)
|
|
215
|
-
return i(
|
|
215
|
+
return i(l), !0;
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
return !1;
|
|
219
|
-
},
|
|
219
|
+
}, G = {
|
|
220
220
|
fill: "rgb(0, 128, 255)",
|
|
221
221
|
fillOpacity: 0.18
|
|
222
|
-
},
|
|
222
|
+
}, xt = {
|
|
223
223
|
fill: "rgb(0, 128, 255)",
|
|
224
224
|
fillOpacity: 0.45
|
|
225
225
|
}, Ke = (t, e, n, o, i) => {
|
|
226
226
|
var a, r;
|
|
227
|
-
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ?
|
|
227
|
+
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? xt : G) : n : (r = t.state) != null && r.selected ? xt : G;
|
|
228
228
|
return o && o.paint(t, e) || s;
|
|
229
229
|
}, Xe = (t) => {
|
|
230
|
-
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n,
|
|
231
|
-
return { top: e, left: n, minX: s, minY: a, maxX: r, maxY:
|
|
230
|
+
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n, l = i - e;
|
|
231
|
+
return { top: e, left: n, minX: s, minY: a, maxX: r, maxY: l };
|
|
232
232
|
}, Pe = (t) => {
|
|
233
233
|
let e = /* @__PURE__ */ new Set();
|
|
234
234
|
return (o) => {
|
|
235
235
|
const i = o.map((s) => s.id);
|
|
236
236
|
(e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
|
|
237
237
|
};
|
|
238
|
-
},
|
|
238
|
+
}, Yt = (t, e, n, o) => {
|
|
239
239
|
const { store: i, selection: s, hover: a } = e;
|
|
240
|
-
let r,
|
|
241
|
-
const h = Pe(n), u = (
|
|
242
|
-
const { x: T, y:
|
|
243
|
-
|
|
240
|
+
let r, l, f;
|
|
241
|
+
const h = Pe(n), u = (M) => {
|
|
242
|
+
const { x: T, y: I } = t.getBoundingClientRect(), D = i.getAt(M.clientX - T, M.clientY - I, !1, l);
|
|
243
|
+
D ? a.current !== D.id && (t.classList.add("hovered"), a.set(D.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
244
244
|
};
|
|
245
245
|
t.addEventListener("pointermove", u);
|
|
246
|
-
const
|
|
246
|
+
const p = (M = !1) => {
|
|
247
247
|
f && f.clear();
|
|
248
|
-
const T = Xe(t), { minX:
|
|
249
|
-
const
|
|
250
|
-
return { annotation:
|
|
248
|
+
const T = Xe(t), { minX: I, minY: D, maxX: y, maxY: x } = T, w = l ? i.getIntersecting(I, D, y, x).filter(({ annotation: O }) => l(O)) : i.getIntersecting(I, D, y, x), L = s.selected.map(({ id: O }) => O), B = w.map(({ annotation: O, rects: U }) => {
|
|
249
|
+
const P = L.includes(O.id), Se = O.id === a.current;
|
|
250
|
+
return { annotation: O, rects: U, state: { selected: P, hover: Se } };
|
|
251
251
|
});
|
|
252
|
-
o.redraw(
|
|
253
|
-
}, v = (
|
|
254
|
-
f =
|
|
255
|
-
},
|
|
256
|
-
r =
|
|
257
|
-
},
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
i.observe(
|
|
261
|
-
const
|
|
252
|
+
o.redraw(B, T, r, f, M), setTimeout(() => h(w.map(({ annotation: O }) => O)), 1);
|
|
253
|
+
}, v = (M) => {
|
|
254
|
+
f = M, p();
|
|
255
|
+
}, g = (M) => {
|
|
256
|
+
r = M, p();
|
|
257
|
+
}, m = (M) => {
|
|
258
|
+
l = M, p(!1);
|
|
259
|
+
}, A = () => p();
|
|
260
|
+
i.observe(A);
|
|
261
|
+
const d = s.subscribe(() => p()), c = () => p(!0);
|
|
262
262
|
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
263
|
-
const b =
|
|
264
|
-
i.recalculatePositions(), f && f.reset(),
|
|
263
|
+
const b = Dt(() => {
|
|
264
|
+
i.recalculatePositions(), f && f.reset(), p();
|
|
265
265
|
});
|
|
266
266
|
window.addEventListener("resize", b);
|
|
267
267
|
const S = new ResizeObserver(b);
|
|
268
268
|
S.observe(t);
|
|
269
|
-
const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((
|
|
270
|
-
|
|
269
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
|
|
270
|
+
M.every((I) => I.target === t || t.contains(I.target)) || p(!0);
|
|
271
271
|
});
|
|
272
272
|
return C.observe(document.body, E), {
|
|
273
273
|
destroy: () => {
|
|
274
|
-
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(
|
|
274
|
+
t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(A), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), S.disconnect(), C.disconnect();
|
|
275
275
|
},
|
|
276
|
-
redraw:
|
|
277
|
-
setStyle:
|
|
278
|
-
setFilter:
|
|
276
|
+
redraw: p,
|
|
277
|
+
setStyle: g,
|
|
278
|
+
setFilter: m,
|
|
279
279
|
setPainter: v,
|
|
280
280
|
setVisible: o.setVisible
|
|
281
281
|
};
|
|
@@ -288,32 +288,32 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
288
288
|
t.classList.add("r6o-annotatable");
|
|
289
289
|
const e = $e(), n = e.getContext("2d");
|
|
290
290
|
document.body.appendChild(e);
|
|
291
|
-
const o = (r,
|
|
292
|
-
const { width: u, height:
|
|
293
|
-
n.clearRect(-0.5, -0.5, u + 1,
|
|
294
|
-
const { top: v, left:
|
|
295
|
-
[...r].sort((
|
|
296
|
-
const { annotation: { target: { created: c } } } =
|
|
291
|
+
const o = (r, l, f, h) => requestAnimationFrame(() => {
|
|
292
|
+
const { width: u, height: p } = e;
|
|
293
|
+
n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
|
|
294
|
+
const { top: v, left: g } = l;
|
|
295
|
+
[...r].sort((A, d) => {
|
|
296
|
+
const { annotation: { target: { created: c } } } = A, { annotation: { target: { created: b } } } = d;
|
|
297
297
|
return c.getTime() - b.getTime();
|
|
298
|
-
}).forEach((
|
|
298
|
+
}).forEach((A) => {
|
|
299
299
|
var S;
|
|
300
|
-
const
|
|
301
|
-
x: E +
|
|
300
|
+
const d = f ? typeof f == "function" ? f(A.annotation, A.state) : f : (S = A.state) != null && S.selected ? xt : G, c = h && h.paint(A, l) || d, b = A.rects.map(({ x: E, y: C, width: R, height: M }) => ({
|
|
301
|
+
x: E + g,
|
|
302
302
|
y: C + v,
|
|
303
|
-
width:
|
|
304
|
-
height:
|
|
303
|
+
width: R,
|
|
304
|
+
height: M
|
|
305
305
|
}));
|
|
306
306
|
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(
|
|
307
|
-
({ x: E, y: C, width:
|
|
307
|
+
({ x: E, y: C, width: R, height: M }) => n.fillRect(E, C, R, M)
|
|
308
308
|
), c.underlineColor) {
|
|
309
309
|
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
310
310
|
const E = c.underlineOffset ?? 0;
|
|
311
|
-
b.forEach(({ x: C, y:
|
|
312
|
-
n.beginPath(), n.moveTo(C,
|
|
311
|
+
b.forEach(({ x: C, y: R, width: M, height: T }) => {
|
|
312
|
+
n.beginPath(), n.moveTo(C, R + T + E), n.lineTo(C + M, R + T + E), n.stroke();
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
315
|
});
|
|
316
|
-
}), i =
|
|
316
|
+
}), i = Dt(() => {
|
|
317
317
|
He(e);
|
|
318
318
|
});
|
|
319
319
|
return window.addEventListener("resize", i), {
|
|
@@ -325,18 +325,18 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
|
|
|
325
325
|
},
|
|
326
326
|
redraw: o
|
|
327
327
|
};
|
|
328
|
-
}, ze = (t, e, n) =>
|
|
329
|
-
var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) },
|
|
328
|
+
}, ze = (t, e, n) => Yt(t, e, n, je(t));
|
|
329
|
+
var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, F = function(t) {
|
|
330
330
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
331
331
|
}, V = function(t, e, n) {
|
|
332
332
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
333
|
-
},
|
|
333
|
+
}, $ = function(t, e, n) {
|
|
334
334
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
335
335
|
}, le = function(t) {
|
|
336
336
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
337
337
|
}, Pt = function(t) {
|
|
338
|
-
return { r:
|
|
339
|
-
},
|
|
338
|
+
return { r: $(t.r, 0, 255), g: $(t.g, 0, 255), b: $(t.b, 0, 255), a: $(t.a) };
|
|
339
|
+
}, St = function(t) {
|
|
340
340
|
return { r: V(t.r), g: V(t.g), b: V(t.b), a: V(t.a, 3) };
|
|
341
341
|
}, We = /^#([0-9a-f]{3,8})$/i, ht = function(t) {
|
|
342
342
|
var e = t.toString(16);
|
|
@@ -347,10 +347,10 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
347
347
|
}, ue = function(t) {
|
|
348
348
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
349
349
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
350
|
-
var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n),
|
|
351
|
-
return { r: 255 * [o, r, a, a,
|
|
350
|
+
var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), f = s % 6;
|
|
351
|
+
return { r: 255 * [o, r, a, a, l, o][f], g: 255 * [l, o, o, r, a, a][f], b: 255 * [a, a, l, o, o, r][f], a: i };
|
|
352
352
|
}, $t = function(t) {
|
|
353
|
-
return { h: le(t.h), s:
|
|
353
|
+
return { h: le(t.h), s: $(t.s, 0, 100), l: $(t.l, 0, 100), a: $(t.a) };
|
|
354
354
|
}, Ht = function(t) {
|
|
355
355
|
return { h: V(t.h), s: V(t.s), l: V(t.l), a: V(t.a, 3) };
|
|
356
356
|
}, jt = function(t) {
|
|
@@ -372,17 +372,17 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
372
372
|
return jt(i);
|
|
373
373
|
}, "hsl"]], object: [[function(t) {
|
|
374
374
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
|
|
375
|
-
return
|
|
375
|
+
return F(e) && F(n) && F(o) ? Pt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
|
|
376
376
|
}, "rgb"], [function(t) {
|
|
377
377
|
var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
|
|
378
|
-
if (!
|
|
378
|
+
if (!F(e) || !F(n) || !F(o)) return null;
|
|
379
379
|
var a = $t({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
|
|
380
380
|
return jt(a);
|
|
381
381
|
}, "hsl"], [function(t) {
|
|
382
382
|
var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
|
|
383
|
-
if (!
|
|
383
|
+
if (!F(e) || !F(n) || !F(o)) return null;
|
|
384
384
|
var a = function(r) {
|
|
385
|
-
return { h: le(r.h), s:
|
|
385
|
+
return { h: le(r.h), s: $(r.s, 0, 100), v: $(r.v, 0, 100), a: $(r.a) };
|
|
386
386
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
|
|
387
387
|
return ue(a);
|
|
388
388
|
}, "hsv"]] }, Ft = function(t, e) {
|
|
@@ -393,14 +393,14 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
393
393
|
return [null, void 0];
|
|
394
394
|
}, Ze = function(t) {
|
|
395
395
|
return typeof t == "string" ? Ft(t.trim(), zt.string) : typeof t == "object" && t !== null ? Ft(t, zt.object) : [null, void 0];
|
|
396
|
-
},
|
|
396
|
+
}, Ct = function(t, e) {
|
|
397
397
|
var n = at(t);
|
|
398
|
-
return { h: n.h, s:
|
|
399
|
-
},
|
|
398
|
+
return { h: n.h, s: $(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
399
|
+
}, Lt = function(t) {
|
|
400
400
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
401
401
|
}, Wt = function(t, e) {
|
|
402
402
|
var n = at(t);
|
|
403
|
-
return { h: n.h, s: n.s, l:
|
|
403
|
+
return { h: n.h, s: n.s, l: $(n.l + 100 * e, 0, 100), a: n.a };
|
|
404
404
|
}, qt = function() {
|
|
405
405
|
function t(e) {
|
|
406
406
|
this.parsed = Ze(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
@@ -408,18 +408,18 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
408
408
|
return t.prototype.isValid = function() {
|
|
409
409
|
return this.parsed !== null;
|
|
410
410
|
}, t.prototype.brightness = function() {
|
|
411
|
-
return V(
|
|
411
|
+
return V(Lt(this.rgba), 2);
|
|
412
412
|
}, t.prototype.isDark = function() {
|
|
413
|
-
return
|
|
413
|
+
return Lt(this.rgba) < 0.5;
|
|
414
414
|
}, t.prototype.isLight = function() {
|
|
415
|
-
return
|
|
415
|
+
return Lt(this.rgba) >= 0.5;
|
|
416
416
|
}, t.prototype.toHex = function() {
|
|
417
|
-
return e =
|
|
417
|
+
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? ht(V(255 * s)) : "", "#" + ht(n) + ht(o) + ht(i) + a;
|
|
418
418
|
var e, n, o, i, s, a;
|
|
419
419
|
}, t.prototype.toRgb = function() {
|
|
420
|
-
return
|
|
420
|
+
return St(this.rgba);
|
|
421
421
|
}, t.prototype.toRgbString = function() {
|
|
422
|
-
return e =
|
|
422
|
+
return e = St(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
423
423
|
var e, n, o, i, s;
|
|
424
424
|
}, t.prototype.toHsl = function() {
|
|
425
425
|
return Ht(at(this.rgba));
|
|
@@ -430,34 +430,34 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
|
|
|
430
430
|
return e = de(this.rgba), { h: V(e.h), s: V(e.s), v: V(e.v), a: V(e.a, 3) };
|
|
431
431
|
var e;
|
|
432
432
|
}, t.prototype.invert = function() {
|
|
433
|
-
return
|
|
433
|
+
return j({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
434
434
|
var e;
|
|
435
435
|
}, t.prototype.saturate = function(e) {
|
|
436
|
-
return e === void 0 && (e = 0.1),
|
|
436
|
+
return e === void 0 && (e = 0.1), j(Ct(this.rgba, e));
|
|
437
437
|
}, t.prototype.desaturate = function(e) {
|
|
438
|
-
return e === void 0 && (e = 0.1),
|
|
438
|
+
return e === void 0 && (e = 0.1), j(Ct(this.rgba, -e));
|
|
439
439
|
}, t.prototype.grayscale = function() {
|
|
440
|
-
return
|
|
440
|
+
return j(Ct(this.rgba, -1));
|
|
441
441
|
}, t.prototype.lighten = function(e) {
|
|
442
|
-
return e === void 0 && (e = 0.1),
|
|
442
|
+
return e === void 0 && (e = 0.1), j(Wt(this.rgba, e));
|
|
443
443
|
}, t.prototype.darken = function(e) {
|
|
444
|
-
return e === void 0 && (e = 0.1),
|
|
444
|
+
return e === void 0 && (e = 0.1), j(Wt(this.rgba, -e));
|
|
445
445
|
}, t.prototype.rotate = function(e) {
|
|
446
446
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
447
447
|
}, t.prototype.alpha = function(e) {
|
|
448
|
-
return typeof e == "number" ?
|
|
448
|
+
return typeof e == "number" ? j({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : V(this.rgba.a, 3);
|
|
449
449
|
var n;
|
|
450
450
|
}, t.prototype.hue = function(e) {
|
|
451
451
|
var n = at(this.rgba);
|
|
452
|
-
return typeof e == "number" ?
|
|
452
|
+
return typeof e == "number" ? j({ h: e, s: n.s, l: n.l, a: n.a }) : V(n.h);
|
|
453
453
|
}, t.prototype.isEqual = function(e) {
|
|
454
|
-
return this.toHex() ===
|
|
454
|
+
return this.toHex() === j(e).toHex();
|
|
455
455
|
}, t;
|
|
456
|
-
}(),
|
|
456
|
+
}(), j = function(t) {
|
|
457
457
|
return t instanceof qt ? t : new qt(t);
|
|
458
458
|
};
|
|
459
459
|
const tn = (t) => [
|
|
460
|
-
`background-color:${
|
|
460
|
+
`background-color:${j((t == null ? void 0 : t.fill) || G.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? G.fillOpacity : t.fillOpacity).toHex()}`,
|
|
461
461
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
462
462
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
463
463
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
@@ -473,23 +473,23 @@ const tn = (t) => [
|
|
|
473
473
|
setVisible: (s) => {
|
|
474
474
|
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
475
475
|
},
|
|
476
|
-
redraw: (s, a, r,
|
|
477
|
-
|
|
476
|
+
redraw: (s, a, r, l) => {
|
|
477
|
+
l && l.clear();
|
|
478
478
|
const f = new Set(s.map((u) => u.annotation.id));
|
|
479
479
|
Array.from(e).filter((u) => !f.has(u));
|
|
480
480
|
const h = s.map((u) => {
|
|
481
|
-
var
|
|
482
|
-
const
|
|
481
|
+
var g;
|
|
482
|
+
const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (g = u.state) != null && g.selected ? xt : G, v = l && l.paint(u, a) || p;
|
|
483
483
|
return `::highlight(_${u.annotation.id}) { ${tn(v)} }`;
|
|
484
484
|
});
|
|
485
485
|
t.innerHTML = h.join(`
|
|
486
486
|
`), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
|
|
487
|
-
const
|
|
487
|
+
const p = u.target.selector.map((g) => g.range), v = new Highlight(...p);
|
|
488
488
|
CSS.highlights.set(`_${u.id}`, v);
|
|
489
489
|
}), e = f;
|
|
490
490
|
}
|
|
491
491
|
};
|
|
492
|
-
}, nn = (t, e, n) =>
|
|
492
|
+
}, nn = (t, e, n) => Yt(t, e, n, en());
|
|
493
493
|
var Gt = Object.prototype.hasOwnProperty;
|
|
494
494
|
function Vt(t, e) {
|
|
495
495
|
var n, o;
|
|
@@ -523,18 +523,18 @@ const on = (t, e) => {
|
|
|
523
523
|
destroy: () => {
|
|
524
524
|
e.remove();
|
|
525
525
|
},
|
|
526
|
-
redraw: (a, r,
|
|
527
|
-
const
|
|
528
|
-
if (!f && !
|
|
529
|
-
|
|
530
|
-
const { annotation: { target: { created:
|
|
531
|
-
return
|
|
532
|
-
}).forEach((
|
|
533
|
-
|
|
534
|
-
const
|
|
535
|
-
if (
|
|
526
|
+
redraw: (a, r, l, f, h) => {
|
|
527
|
+
const p = !(Vt(n, a) && h);
|
|
528
|
+
if (!f && !p) return;
|
|
529
|
+
p && (e.innerHTML = ""), [...a].sort((g, m) => {
|
|
530
|
+
const { annotation: { target: { created: A } } } = g, { annotation: { target: { created: d } } } = m;
|
|
531
|
+
return A && d ? A.getTime() - d.getTime() : 0;
|
|
532
|
+
}).forEach((g) => {
|
|
533
|
+
g.rects.map((m) => {
|
|
534
|
+
const A = on(m, a), d = Ke(g, r, l, f, A);
|
|
535
|
+
if (p) {
|
|
536
536
|
const c = document.createElement("span");
|
|
537
|
-
c.className = "r6o-annotation", c.dataset.annotation =
|
|
537
|
+
c.className = "r6o-annotation", c.dataset.annotation = g.annotation.id, c.style.left = `${m.x}px`, c.style.top = `${m.y}px`, c.style.width = `${m.width}px`, c.style.height = `${m.height}px`, c.style.backgroundColor = j((d == null ? void 0 : d.fill) || G.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? G.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
|
|
538
538
|
}
|
|
539
539
|
});
|
|
540
540
|
}), n = a;
|
|
@@ -543,32 +543,35 @@ const on = (t, e) => {
|
|
|
543
543
|
a ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
544
544
|
}
|
|
545
545
|
};
|
|
546
|
-
}, rn = (t, e, n) =>
|
|
546
|
+
}, rn = (t, e, n) => Yt(t, e, n, sn(t)), Y = [];
|
|
547
547
|
for (let t = 0; t < 256; ++t)
|
|
548
548
|
Y.push((t + 256).toString(16).slice(1));
|
|
549
549
|
function an(t, e = 0) {
|
|
550
550
|
return (Y[t[e + 0]] + Y[t[e + 1]] + Y[t[e + 2]] + Y[t[e + 3]] + "-" + Y[t[e + 4]] + Y[t[e + 5]] + "-" + Y[t[e + 6]] + Y[t[e + 7]] + "-" + Y[t[e + 8]] + Y[t[e + 9]] + "-" + Y[t[e + 10]] + Y[t[e + 11]] + Y[t[e + 12]] + Y[t[e + 13]] + Y[t[e + 14]] + Y[t[e + 15]]).toLowerCase();
|
|
551
551
|
}
|
|
552
|
-
let
|
|
552
|
+
let Tt;
|
|
553
553
|
const cn = new Uint8Array(16);
|
|
554
554
|
function ln() {
|
|
555
|
-
if (!
|
|
555
|
+
if (!Tt) {
|
|
556
556
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
557
557
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
558
|
-
|
|
558
|
+
Tt = crypto.getRandomValues.bind(crypto);
|
|
559
559
|
}
|
|
560
|
-
return
|
|
560
|
+
return Tt(cn);
|
|
561
561
|
}
|
|
562
562
|
const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qt = { randomUUID: dn };
|
|
563
563
|
function fe(t, e, n) {
|
|
564
|
-
|
|
564
|
+
var i;
|
|
565
|
+
if (Qt.randomUUID && !t)
|
|
565
566
|
return Qt.randomUUID();
|
|
566
567
|
t = t || {};
|
|
567
|
-
const o = t.random
|
|
568
|
+
const o = t.random ?? ((i = t.rng) == null ? void 0 : i.call(t)) ?? ln();
|
|
569
|
+
if (o.length < 16)
|
|
570
|
+
throw new Error("Random bytes length must be >= 16");
|
|
568
571
|
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, an(o);
|
|
569
572
|
}
|
|
570
573
|
var Jt = Object.prototype.hasOwnProperty;
|
|
571
|
-
function
|
|
574
|
+
function Q(t, e) {
|
|
572
575
|
var n, o;
|
|
573
576
|
if (t === e) return !0;
|
|
574
577
|
if (t && e && (n = t.constructor) === e.constructor) {
|
|
@@ -576,45 +579,45 @@ function G(t, e) {
|
|
|
576
579
|
if (n === RegExp) return t.toString() === e.toString();
|
|
577
580
|
if (n === Array) {
|
|
578
581
|
if ((o = t.length) === e.length)
|
|
579
|
-
for (; o-- &&
|
|
582
|
+
for (; o-- && Q(t[o], e[o]); ) ;
|
|
580
583
|
return o === -1;
|
|
581
584
|
}
|
|
582
585
|
if (!n || typeof t == "object") {
|
|
583
586
|
o = 0;
|
|
584
587
|
for (n in t)
|
|
585
|
-
if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !
|
|
588
|
+
if (Jt.call(t, n) && ++o && !Jt.call(e, n) || !(n in e) || !Q(t[n], e[n])) return !1;
|
|
586
589
|
return Object.keys(e).length === o;
|
|
587
590
|
}
|
|
588
591
|
}
|
|
589
592
|
return t !== t && e !== e;
|
|
590
593
|
}
|
|
591
|
-
function
|
|
594
|
+
function Ot() {
|
|
592
595
|
}
|
|
593
596
|
function un(t, e) {
|
|
594
597
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
595
598
|
}
|
|
596
|
-
const
|
|
597
|
-
function Kt(t, e =
|
|
599
|
+
const J = [];
|
|
600
|
+
function Kt(t, e = Ot) {
|
|
598
601
|
let n;
|
|
599
602
|
const o = /* @__PURE__ */ new Set();
|
|
600
603
|
function i(r) {
|
|
601
604
|
if (un(t, r) && (t = r, n)) {
|
|
602
|
-
const
|
|
605
|
+
const l = !J.length;
|
|
603
606
|
for (const f of o)
|
|
604
|
-
f[1](),
|
|
605
|
-
if (
|
|
606
|
-
for (let f = 0; f <
|
|
607
|
-
|
|
608
|
-
|
|
607
|
+
f[1](), J.push(f, t);
|
|
608
|
+
if (l) {
|
|
609
|
+
for (let f = 0; f < J.length; f += 2)
|
|
610
|
+
J[f][0](J[f + 1]);
|
|
611
|
+
J.length = 0;
|
|
609
612
|
}
|
|
610
613
|
}
|
|
611
614
|
}
|
|
612
615
|
function s(r) {
|
|
613
616
|
i(r(t));
|
|
614
617
|
}
|
|
615
|
-
function a(r,
|
|
616
|
-
const f = [r,
|
|
617
|
-
return o.add(f), o.size === 1 && (n = e(i, s) ||
|
|
618
|
+
function a(r, l = Ot) {
|
|
619
|
+
const f = [r, l];
|
|
620
|
+
return o.add(f), o.size === 1 && (n = e(i, s) || Ot), r(t), () => {
|
|
618
621
|
o.delete(f), o.size === 0 && n && (n(), n = null);
|
|
619
622
|
};
|
|
620
623
|
}
|
|
@@ -638,56 +641,58 @@ const fn = (t) => {
|
|
|
638
641
|
};
|
|
639
642
|
};
|
|
640
643
|
var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(hn || {});
|
|
641
|
-
const
|
|
642
|
-
const { subscribe: o, set: i } = Kt(
|
|
643
|
-
let s = e, a =
|
|
644
|
-
o((
|
|
644
|
+
const pt = { selected: [] }, pn = (t, e, n) => {
|
|
645
|
+
const { subscribe: o, set: i } = Kt(pt);
|
|
646
|
+
let s = e, a = pt;
|
|
647
|
+
o((g) => a = g);
|
|
645
648
|
const r = () => {
|
|
646
|
-
|
|
647
|
-
},
|
|
648
|
-
var
|
|
649
|
-
return ((
|
|
650
|
-
}, f = (
|
|
651
|
-
if (
|
|
649
|
+
Q(a, pt) || i(pt);
|
|
650
|
+
}, l = () => {
|
|
651
|
+
var g;
|
|
652
|
+
return ((g = a.selected) == null ? void 0 : g.length) === 0;
|
|
653
|
+
}, f = (g) => {
|
|
654
|
+
if (l())
|
|
652
655
|
return !1;
|
|
653
|
-
const
|
|
654
|
-
return a.selected.some((
|
|
655
|
-
}, h = (
|
|
656
|
-
let
|
|
657
|
-
if (Array.isArray(
|
|
658
|
-
if (
|
|
659
|
-
console.warn("Invalid selection: " +
|
|
656
|
+
const m = typeof g == "string" ? g : g.id;
|
|
657
|
+
return a.selected.some((A) => A.id === m);
|
|
658
|
+
}, h = (g, m) => {
|
|
659
|
+
let A;
|
|
660
|
+
if (Array.isArray(g)) {
|
|
661
|
+
if (A = g.map((c) => t.getAnnotation(c)).filter(Boolean), A.length < g.length) {
|
|
662
|
+
console.warn("Invalid selection: " + g.filter((c) => !A.some((b) => b.id === c)));
|
|
660
663
|
return;
|
|
661
664
|
}
|
|
662
665
|
} else {
|
|
663
|
-
const c = t.getAnnotation(
|
|
666
|
+
const c = t.getAnnotation(g);
|
|
664
667
|
if (!c) {
|
|
665
|
-
console.warn("Invalid selection: " +
|
|
668
|
+
console.warn("Invalid selection: " + g);
|
|
666
669
|
return;
|
|
667
670
|
}
|
|
668
|
-
|
|
671
|
+
A = [c];
|
|
669
672
|
}
|
|
670
|
-
const
|
|
673
|
+
const d = A.reduce((c, b) => {
|
|
671
674
|
const S = Zt(b, s);
|
|
672
675
|
return S === "EDIT" ? [...c, { id: b.id, editable: !0 }] : S === "SELECT" ? [...c, { id: b.id }] : c;
|
|
673
676
|
}, []);
|
|
674
|
-
i({ selected:
|
|
675
|
-
}, u = (
|
|
676
|
-
const
|
|
677
|
+
i({ selected: d, event: m });
|
|
678
|
+
}, u = (g, m) => {
|
|
679
|
+
const A = Array.isArray(g) ? g : [g], d = A.map((c) => t.getAnnotation(c)).filter((c) => !!c);
|
|
677
680
|
i({
|
|
678
|
-
selected:
|
|
679
|
-
const b =
|
|
681
|
+
selected: d.map((c) => {
|
|
682
|
+
const b = m === void 0 ? Zt(c, s) === "EDIT" : m;
|
|
680
683
|
return { id: c.id, editable: b };
|
|
681
684
|
})
|
|
682
|
-
}),
|
|
683
|
-
},
|
|
684
|
-
if (
|
|
685
|
+
}), d.length !== A.length && console.warn("Invalid selection", g);
|
|
686
|
+
}, p = (g) => {
|
|
687
|
+
if (l())
|
|
685
688
|
return !1;
|
|
686
|
-
const { selected:
|
|
687
|
-
|
|
688
|
-
}, v = (
|
|
689
|
+
const { selected: m } = a;
|
|
690
|
+
m.some(({ id: A }) => g.includes(A)) && i({ selected: m.filter(({ id: A }) => !g.includes(A)) });
|
|
691
|
+
}, v = (g) => {
|
|
692
|
+
s = g, u(a.selected.map(({ id: m }) => m));
|
|
693
|
+
};
|
|
689
694
|
return t.observe(
|
|
690
|
-
({ changes:
|
|
695
|
+
({ changes: g }) => p((g.deleted || []).map((m) => m.id))
|
|
691
696
|
), {
|
|
692
697
|
get event() {
|
|
693
698
|
return a ? a.event : null;
|
|
@@ -699,38 +704,41 @@ const gt = { selected: [] }, gn = (t, e, n) => {
|
|
|
699
704
|
return s;
|
|
700
705
|
},
|
|
701
706
|
clear: r,
|
|
702
|
-
isEmpty:
|
|
707
|
+
isEmpty: l,
|
|
703
708
|
isSelected: f,
|
|
704
709
|
setSelected: u,
|
|
705
710
|
setUserSelectAction: v,
|
|
706
711
|
subscribe: o,
|
|
707
712
|
userSelect: h
|
|
708
713
|
};
|
|
709
|
-
}, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT",
|
|
714
|
+
}, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT", K = [];
|
|
710
715
|
for (let t = 0; t < 256; ++t)
|
|
711
|
-
|
|
712
|
-
function
|
|
713
|
-
return (
|
|
716
|
+
K.push((t + 256).toString(16).slice(1));
|
|
717
|
+
function gn(t, e = 0) {
|
|
718
|
+
return (K[t[e + 0]] + K[t[e + 1]] + K[t[e + 2]] + K[t[e + 3]] + "-" + K[t[e + 4]] + K[t[e + 5]] + "-" + K[t[e + 6]] + K[t[e + 7]] + "-" + K[t[e + 8]] + K[t[e + 9]] + "-" + K[t[e + 10]] + K[t[e + 11]] + K[t[e + 12]] + K[t[e + 13]] + K[t[e + 14]] + K[t[e + 15]]).toLowerCase();
|
|
714
719
|
}
|
|
715
|
-
let
|
|
720
|
+
let Rt;
|
|
716
721
|
const mn = new Uint8Array(16);
|
|
717
722
|
function yn() {
|
|
718
|
-
if (!
|
|
723
|
+
if (!Rt) {
|
|
719
724
|
if (typeof crypto > "u" || !crypto.getRandomValues)
|
|
720
725
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
721
|
-
|
|
726
|
+
Rt = crypto.getRandomValues.bind(crypto);
|
|
722
727
|
}
|
|
723
|
-
return
|
|
728
|
+
return Rt(mn);
|
|
724
729
|
}
|
|
725
730
|
const bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), te = { randomUUID: bn };
|
|
726
731
|
function he(t, e, n) {
|
|
727
|
-
|
|
732
|
+
var o;
|
|
733
|
+
if (te.randomUUID && !t)
|
|
728
734
|
return te.randomUUID();
|
|
729
735
|
t = t || {};
|
|
730
|
-
const
|
|
731
|
-
|
|
736
|
+
const i = t.random ?? ((o = t.rng) == null ? void 0 : o.call(t)) ?? yn();
|
|
737
|
+
if (i.length < 16)
|
|
738
|
+
throw new Error("Random bytes length must be >= 16");
|
|
739
|
+
return i[6] = i[6] & 15 | 64, i[8] = i[8] & 63 | 128, gn(i);
|
|
732
740
|
}
|
|
733
|
-
const
|
|
741
|
+
const Mt = (t) => {
|
|
734
742
|
const e = (n) => {
|
|
735
743
|
const o = { ...n };
|
|
736
744
|
return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
|
|
@@ -754,8 +762,8 @@ const Bt = (t) => {
|
|
|
754
762
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
755
763
|
}, xn = (t, e) => e.bodies.map((n) => {
|
|
756
764
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
757
|
-
return { newBody: n, oldBody: o && !
|
|
758
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !
|
|
765
|
+
return { newBody: n, oldBody: o && !Q(o, n) ? o : void 0 };
|
|
766
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !Q(t.target, e.target), pe = (t, e) => {
|
|
759
767
|
const n = wn(t, e), o = An(t, e), i = xn(t, e);
|
|
760
768
|
return {
|
|
761
769
|
oldValue: t,
|
|
@@ -773,10 +781,10 @@ const En = (t, e) => {
|
|
|
773
781
|
if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
|
|
774
782
|
return !1;
|
|
775
783
|
if (t.options.ignore) {
|
|
776
|
-
const { ignore: a } = t.options, r = (
|
|
784
|
+
const { ignore: a } = t.options, r = (l) => l && l.length > 0;
|
|
777
785
|
if (!(r(i.created) || r(i.deleted))) {
|
|
778
|
-
const
|
|
779
|
-
if (a === "BODY_ONLY" &&
|
|
786
|
+
const l = (n = i.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
|
|
787
|
+
if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
|
|
780
788
|
return !1;
|
|
781
789
|
}
|
|
782
790
|
}
|
|
@@ -790,25 +798,25 @@ const En = (t, e) => {
|
|
|
790
798
|
} else
|
|
791
799
|
return !0;
|
|
792
800
|
}, Sn = (t, e) => {
|
|
793
|
-
const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)),
|
|
794
|
-
...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue:
|
|
801
|
+
const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), l = [
|
|
802
|
+
...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: p }) => p.id === u.id).newValue : u),
|
|
795
803
|
...e.created || []
|
|
796
804
|
], f = [
|
|
797
805
|
...(t.deleted || []).filter((u) => !i.has(u.id)),
|
|
798
806
|
...(e.deleted || []).filter((u) => !n.has(u.id))
|
|
799
807
|
], h = [
|
|
800
808
|
...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
|
|
801
|
-
const { oldValue:
|
|
809
|
+
const { oldValue: p, newValue: v } = u;
|
|
802
810
|
if (a.has(v.id)) {
|
|
803
|
-
const
|
|
804
|
-
return
|
|
811
|
+
const g = e.updated.find((m) => m.oldValue.id === v.id).newValue;
|
|
812
|
+
return pe(p, g);
|
|
805
813
|
} else
|
|
806
814
|
return u;
|
|
807
815
|
}),
|
|
808
816
|
...(e.updated || []).filter(({ oldValue: u }) => !r.has(u.id))
|
|
809
817
|
];
|
|
810
|
-
return { created:
|
|
811
|
-
},
|
|
818
|
+
return { created: l, deleted: f, updated: h };
|
|
819
|
+
}, gt = (t) => {
|
|
812
820
|
const e = t.id === void 0 ? he() : t.id;
|
|
813
821
|
return {
|
|
814
822
|
...t,
|
|
@@ -823,202 +831,211 @@ const En = (t, e) => {
|
|
|
823
831
|
}
|
|
824
832
|
};
|
|
825
833
|
}, Cn = (t) => t.id !== void 0, Ln = () => {
|
|
826
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
827
|
-
n.push({ onChange:
|
|
828
|
-
}, i = (
|
|
829
|
-
const
|
|
830
|
-
|
|
831
|
-
}, s = (
|
|
834
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (y, x = {}) => {
|
|
835
|
+
n.push({ onChange: y, options: x });
|
|
836
|
+
}, i = (y) => {
|
|
837
|
+
const x = n.findIndex((w) => w.onChange == y);
|
|
838
|
+
x > -1 && n.splice(x, 1);
|
|
839
|
+
}, s = (y, x) => {
|
|
832
840
|
const w = {
|
|
833
|
-
origin:
|
|
841
|
+
origin: y,
|
|
834
842
|
changes: {
|
|
835
|
-
created:
|
|
836
|
-
updated:
|
|
837
|
-
deleted:
|
|
843
|
+
created: x.created || [],
|
|
844
|
+
updated: x.updated || [],
|
|
845
|
+
deleted: x.deleted || []
|
|
838
846
|
},
|
|
839
847
|
state: [...t.values()]
|
|
840
848
|
};
|
|
841
849
|
n.forEach((L) => {
|
|
842
850
|
En(L, w) && L.onChange(w);
|
|
843
851
|
});
|
|
844
|
-
}, a = (
|
|
845
|
-
if (
|
|
846
|
-
throw Error(`Cannot add annotation ${
|
|
852
|
+
}, a = (y, x = k.LOCAL) => {
|
|
853
|
+
if (y.id && t.get(y.id))
|
|
854
|
+
throw Error(`Cannot add annotation ${y.id} - exists already`);
|
|
847
855
|
{
|
|
848
|
-
const w =
|
|
849
|
-
t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), s(
|
|
856
|
+
const w = gt(y);
|
|
857
|
+
t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), s(x, { created: [w] });
|
|
850
858
|
}
|
|
851
|
-
}, r = (
|
|
852
|
-
const w =
|
|
853
|
-
if (
|
|
854
|
-
const
|
|
855
|
-
return L === w.id ? t.set(L, w) : (t.delete(L), t.set(w.id, w)),
|
|
859
|
+
}, r = (y, x) => {
|
|
860
|
+
const w = gt(typeof y == "string" ? x : y), L = typeof y == "string" ? y : y.id, B = L && t.get(L);
|
|
861
|
+
if (B) {
|
|
862
|
+
const O = pe(B, w);
|
|
863
|
+
return L === w.id ? t.set(L, w) : (t.delete(L), t.set(w.id, w)), B.bodies.forEach((U) => e.delete(U.id)), w.bodies.forEach((U) => e.set(U.id, w.id)), O;
|
|
856
864
|
} else
|
|
857
865
|
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
858
|
-
},
|
|
859
|
-
const L = Cn(
|
|
860
|
-
|
|
861
|
-
}, f = (
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
866
|
+
}, l = (y, x = k.LOCAL, w = k.LOCAL) => {
|
|
867
|
+
const L = Cn(x) ? w : x, B = r(y, x);
|
|
868
|
+
B && s(L, { updated: [B] });
|
|
869
|
+
}, f = (y, x = k.LOCAL) => {
|
|
870
|
+
t.get(y.id) ? l(y, x) : a(y, x);
|
|
871
|
+
}, h = (y, x = k.LOCAL) => {
|
|
872
|
+
const w = y.reduce((L, B) => {
|
|
873
|
+
const O = r(B);
|
|
874
|
+
return O ? [...L, O] : L;
|
|
865
875
|
}, []);
|
|
866
|
-
w.length > 0 && s(
|
|
867
|
-
},
|
|
868
|
-
const w = t.get(
|
|
876
|
+
w.length > 0 && s(x, { updated: w });
|
|
877
|
+
}, u = (y, x = k.LOCAL) => {
|
|
878
|
+
const w = y.map(gt), { toAdd: L, toUpdate: B } = w.reduce((U, P) => t.get(P.id) ? { ...U, toUpdate: [...U.toUpdate, P] } : { ...U, toAdd: [...U.toAdd, P] }, { toAdd: [], toUpdate: [] }), O = B.map((U) => r(U, x)).filter(Boolean);
|
|
879
|
+
L.forEach((U) => {
|
|
880
|
+
t.set(U.id, U), U.bodies.forEach((P) => e.set(P.id, U.id));
|
|
881
|
+
}), s(x, { created: L, updated: O });
|
|
882
|
+
}, p = (y, x = k.LOCAL) => {
|
|
883
|
+
const w = t.get(y.annotation);
|
|
869
884
|
if (w) {
|
|
870
885
|
const L = {
|
|
871
886
|
...w,
|
|
872
|
-
bodies: [...w.bodies,
|
|
887
|
+
bodies: [...w.bodies, y]
|
|
873
888
|
};
|
|
874
|
-
t.set(w.id, L), e.set(
|
|
889
|
+
t.set(w.id, L), e.set(y.id, L.id), s(x, { updated: [{
|
|
875
890
|
oldValue: w,
|
|
876
891
|
newValue: L,
|
|
877
|
-
bodiesCreated: [
|
|
892
|
+
bodiesCreated: [y]
|
|
878
893
|
}] });
|
|
879
894
|
} else
|
|
880
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
881
|
-
},
|
|
882
|
-
const
|
|
883
|
-
t.clear(), e.clear(), s(
|
|
884
|
-
},
|
|
885
|
-
const L =
|
|
886
|
-
if (
|
|
887
|
-
const
|
|
888
|
-
t.clear(), e.clear(), L.forEach((
|
|
889
|
-
t.set(
|
|
890
|
-
}), s(w, { created: L, deleted:
|
|
895
|
+
console.warn(`Attempt to add body to missing annotation: ${y.annotation}`);
|
|
896
|
+
}, v = () => [...t.values()], g = (y = k.LOCAL) => {
|
|
897
|
+
const x = [...t.values()];
|
|
898
|
+
t.clear(), e.clear(), s(y, { deleted: x });
|
|
899
|
+
}, m = (y, x = !0, w = k.LOCAL) => {
|
|
900
|
+
const L = y.map(gt);
|
|
901
|
+
if (x) {
|
|
902
|
+
const B = [...t.values()];
|
|
903
|
+
t.clear(), e.clear(), L.forEach((O) => {
|
|
904
|
+
t.set(O.id, O), O.bodies.forEach((U) => e.set(U.id, O.id));
|
|
905
|
+
}), s(w, { created: L, deleted: B });
|
|
891
906
|
} else {
|
|
892
|
-
const
|
|
893
|
-
const
|
|
894
|
-
return
|
|
907
|
+
const B = y.reduce((O, U) => {
|
|
908
|
+
const P = U.id && t.get(U.id);
|
|
909
|
+
return P ? [...O, P] : O;
|
|
895
910
|
}, []);
|
|
896
|
-
if (
|
|
897
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
898
|
-
L.forEach((
|
|
899
|
-
t.set(
|
|
911
|
+
if (B.length > 0)
|
|
912
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((O) => O.id).join(", ")}`);
|
|
913
|
+
L.forEach((O) => {
|
|
914
|
+
t.set(O.id, O), O.bodies.forEach((U) => e.set(U.id, O.id));
|
|
900
915
|
}), s(w, { created: L });
|
|
901
916
|
}
|
|
902
|
-
},
|
|
903
|
-
const
|
|
917
|
+
}, A = (y) => {
|
|
918
|
+
const x = typeof y == "string" ? y : y.id, w = t.get(x);
|
|
904
919
|
if (w)
|
|
905
|
-
return t.delete(
|
|
906
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
907
|
-
},
|
|
908
|
-
const w =
|
|
909
|
-
w && s(
|
|
910
|
-
},
|
|
911
|
-
const w =
|
|
912
|
-
const
|
|
913
|
-
return
|
|
920
|
+
return t.delete(x), w.bodies.forEach((L) => e.delete(L.id)), w;
|
|
921
|
+
console.warn(`Attempt to delete missing annotation: ${x}`);
|
|
922
|
+
}, d = (y, x = k.LOCAL) => {
|
|
923
|
+
const w = A(y);
|
|
924
|
+
w && s(x, { deleted: [w] });
|
|
925
|
+
}, c = (y, x = k.LOCAL) => {
|
|
926
|
+
const w = y.reduce((L, B) => {
|
|
927
|
+
const O = A(B);
|
|
928
|
+
return O ? [...L, O] : L;
|
|
914
929
|
}, []);
|
|
915
|
-
w.length > 0 && s(
|
|
916
|
-
},
|
|
917
|
-
const
|
|
918
|
-
if (
|
|
919
|
-
const w =
|
|
930
|
+
w.length > 0 && s(x, { deleted: w });
|
|
931
|
+
}, b = (y) => {
|
|
932
|
+
const x = t.get(y.annotation);
|
|
933
|
+
if (x) {
|
|
934
|
+
const w = x.bodies.find((L) => L.id === y.id);
|
|
920
935
|
if (w) {
|
|
921
936
|
e.delete(w.id);
|
|
922
937
|
const L = {
|
|
923
|
-
...
|
|
924
|
-
bodies:
|
|
938
|
+
...x,
|
|
939
|
+
bodies: x.bodies.filter((B) => B.id !== y.id)
|
|
925
940
|
};
|
|
926
|
-
return t.set(
|
|
927
|
-
oldValue:
|
|
941
|
+
return t.set(x.id, L), {
|
|
942
|
+
oldValue: x,
|
|
928
943
|
newValue: L,
|
|
929
944
|
bodiesDeleted: [w]
|
|
930
945
|
};
|
|
931
946
|
} else
|
|
932
|
-
console.warn(`Attempt to delete missing body ${
|
|
947
|
+
console.warn(`Attempt to delete missing body ${y.id} from annotation ${y.annotation}`);
|
|
933
948
|
} else
|
|
934
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
935
|
-
},
|
|
936
|
-
const w =
|
|
937
|
-
w && s(
|
|
938
|
-
},
|
|
939
|
-
const w =
|
|
940
|
-
w.length > 0 && s(
|
|
941
|
-
},
|
|
942
|
-
const
|
|
943
|
-
return
|
|
944
|
-
},
|
|
945
|
-
const
|
|
946
|
-
if (
|
|
947
|
-
const w =
|
|
949
|
+
console.warn(`Attempt to delete body from missing annotation ${y.annotation}`);
|
|
950
|
+
}, S = (y, x = k.LOCAL) => {
|
|
951
|
+
const w = b(y);
|
|
952
|
+
w && s(x, { updated: [w] });
|
|
953
|
+
}, E = (y, x = k.LOCAL) => {
|
|
954
|
+
const w = y.map((L) => b(L)).filter(Boolean);
|
|
955
|
+
w.length > 0 && s(x, { updated: w });
|
|
956
|
+
}, C = (y) => {
|
|
957
|
+
const x = t.get(y);
|
|
958
|
+
return x ? { ...x } : void 0;
|
|
959
|
+
}, R = (y) => {
|
|
960
|
+
const x = e.get(y);
|
|
961
|
+
if (x) {
|
|
962
|
+
const w = C(x).bodies.find((L) => L.id === y);
|
|
948
963
|
if (w)
|
|
949
964
|
return w;
|
|
950
|
-
console.error(`Store integrity error: body ${
|
|
965
|
+
console.error(`Store integrity error: body ${y} in index, but not in annotation`);
|
|
951
966
|
} else
|
|
952
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
953
|
-
},
|
|
954
|
-
if (
|
|
967
|
+
console.warn(`Attempt to retrieve missing body: ${y}`);
|
|
968
|
+
}, M = (y, x) => {
|
|
969
|
+
if (y.annotation !== x.annotation)
|
|
955
970
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
956
|
-
const w = t.get(
|
|
971
|
+
const w = t.get(y.annotation);
|
|
957
972
|
if (w) {
|
|
958
|
-
const L = w.bodies.find((
|
|
973
|
+
const L = w.bodies.find((O) => O.id === y.id), B = {
|
|
959
974
|
...w,
|
|
960
|
-
bodies: w.bodies.map((
|
|
975
|
+
bodies: w.bodies.map((O) => O.id === L.id ? x : O)
|
|
961
976
|
};
|
|
962
|
-
return t.set(w.id,
|
|
977
|
+
return t.set(w.id, B), L.id !== x.id && (e.delete(L.id), e.set(x.id, B.id)), {
|
|
963
978
|
oldValue: w,
|
|
964
|
-
newValue:
|
|
965
|
-
bodiesUpdated: [{ oldBody: L, newBody:
|
|
979
|
+
newValue: B,
|
|
980
|
+
bodiesUpdated: [{ oldBody: L, newBody: x }]
|
|
966
981
|
};
|
|
967
982
|
} else
|
|
968
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
969
|
-
},
|
|
970
|
-
const L =
|
|
983
|
+
console.warn(`Attempt to add body to missing annotation ${y.annotation}`);
|
|
984
|
+
}, T = (y, x, w = k.LOCAL) => {
|
|
985
|
+
const L = M(y, x);
|
|
971
986
|
L && s(w, { updated: [L] });
|
|
972
|
-
},
|
|
973
|
-
const w =
|
|
974
|
-
s(
|
|
975
|
-
},
|
|
976
|
-
const
|
|
977
|
-
if (
|
|
987
|
+
}, I = (y, x = k.LOCAL) => {
|
|
988
|
+
const w = y.map((L) => M({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
989
|
+
s(x, { updated: w });
|
|
990
|
+
}, D = (y) => {
|
|
991
|
+
const x = t.get(y.annotation);
|
|
992
|
+
if (x) {
|
|
978
993
|
const w = {
|
|
979
|
-
...
|
|
994
|
+
...x,
|
|
980
995
|
target: {
|
|
981
|
-
...
|
|
982
|
-
...
|
|
996
|
+
...x.target,
|
|
997
|
+
...y
|
|
983
998
|
}
|
|
984
999
|
};
|
|
985
|
-
return t.set(
|
|
986
|
-
oldValue:
|
|
1000
|
+
return t.set(x.id, w), {
|
|
1001
|
+
oldValue: x,
|
|
987
1002
|
newValue: w,
|
|
988
1003
|
targetUpdated: {
|
|
989
|
-
oldTarget:
|
|
990
|
-
newTarget:
|
|
1004
|
+
oldTarget: x.target,
|
|
1005
|
+
newTarget: y
|
|
991
1006
|
}
|
|
992
1007
|
};
|
|
993
1008
|
} else
|
|
994
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
1009
|
+
console.warn(`Attempt to update target on missing annotation: ${y.annotation}`);
|
|
995
1010
|
};
|
|
996
1011
|
return {
|
|
997
1012
|
addAnnotation: a,
|
|
998
|
-
addBody:
|
|
999
|
-
all:
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
bulkDeleteBodies:
|
|
1003
|
-
|
|
1004
|
-
bulkUpdateBodies:
|
|
1005
|
-
bulkUpdateTargets: (
|
|
1006
|
-
const w =
|
|
1007
|
-
w.length > 0 && s(
|
|
1013
|
+
addBody: p,
|
|
1014
|
+
all: v,
|
|
1015
|
+
bulkAddAnnotations: m,
|
|
1016
|
+
bulkDeleteAnnotations: c,
|
|
1017
|
+
bulkDeleteBodies: E,
|
|
1018
|
+
bulkUpdateAnnotations: h,
|
|
1019
|
+
bulkUpdateBodies: I,
|
|
1020
|
+
bulkUpdateTargets: (y, x = k.LOCAL) => {
|
|
1021
|
+
const w = y.map((L) => D(L)).filter(Boolean);
|
|
1022
|
+
w.length > 0 && s(x, { updated: w });
|
|
1008
1023
|
},
|
|
1024
|
+
bulkUpsertAnnotations: u,
|
|
1009
1025
|
clear: g,
|
|
1010
|
-
deleteAnnotation:
|
|
1011
|
-
deleteBody:
|
|
1012
|
-
getAnnotation:
|
|
1013
|
-
getBody:
|
|
1026
|
+
deleteAnnotation: d,
|
|
1027
|
+
deleteBody: S,
|
|
1028
|
+
getAnnotation: C,
|
|
1029
|
+
getBody: R,
|
|
1014
1030
|
observe: o,
|
|
1015
1031
|
unobserve: i,
|
|
1016
|
-
updateAnnotation:
|
|
1017
|
-
updateBody:
|
|
1018
|
-
updateTarget: (
|
|
1019
|
-
const w =
|
|
1020
|
-
w && s(
|
|
1021
|
-
}
|
|
1032
|
+
updateAnnotation: l,
|
|
1033
|
+
updateBody: T,
|
|
1034
|
+
updateTarget: (y, x = k.LOCAL) => {
|
|
1035
|
+
const w = D(y);
|
|
1036
|
+
w && s(x, { updated: [w] });
|
|
1037
|
+
},
|
|
1038
|
+
upsertAnnotation: f
|
|
1022
1039
|
};
|
|
1023
1040
|
};
|
|
1024
1041
|
let Tn = () => ({
|
|
@@ -1035,42 +1052,42 @@ let Tn = () => ({
|
|
|
1035
1052
|
};
|
|
1036
1053
|
}
|
|
1037
1054
|
});
|
|
1038
|
-
const On = 250,
|
|
1055
|
+
const On = 250, Rn = (t, e) => {
|
|
1039
1056
|
const n = Tn(), o = [];
|
|
1040
1057
|
let i = -1, s = !1, a = 0;
|
|
1041
|
-
const r = (
|
|
1058
|
+
const r = (g) => {
|
|
1042
1059
|
if (!s) {
|
|
1043
|
-
const { changes:
|
|
1044
|
-
if (
|
|
1045
|
-
o.splice(i + 1), o.push(
|
|
1060
|
+
const { changes: m } = g, A = performance.now();
|
|
1061
|
+
if (A - a > On)
|
|
1062
|
+
o.splice(i + 1), o.push(m), i = o.length - 1;
|
|
1046
1063
|
else {
|
|
1047
|
-
const
|
|
1048
|
-
o[
|
|
1064
|
+
const d = o.length - 1;
|
|
1065
|
+
o[d] = Sn(o[d], m);
|
|
1049
1066
|
}
|
|
1050
|
-
a =
|
|
1067
|
+
a = A;
|
|
1051
1068
|
}
|
|
1052
1069
|
s = !1;
|
|
1053
1070
|
};
|
|
1054
1071
|
t.observe(r, { origin: k.LOCAL });
|
|
1055
|
-
const
|
|
1072
|
+
const l = (g) => g && g.length > 0 && t.bulkDeleteAnnotations(g), f = (g) => g && g.length > 0 && t.bulkAddAnnotations(g, !1), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotations(g.map(({ oldValue: m }) => m)), u = (g) => g && g.length > 0 && t.bulkUpdateAnnotations(g.map(({ newValue: m }) => m)), p = (g) => g && g.length > 0 && t.bulkAddAnnotations(g, !1), v = (g) => g && g.length > 0 && t.bulkDeleteAnnotations(g);
|
|
1056
1073
|
return {
|
|
1057
1074
|
canRedo: () => o.length - 1 > i,
|
|
1058
1075
|
canUndo: () => i > -1,
|
|
1059
1076
|
destroy: () => t.unobserve(r),
|
|
1060
1077
|
getHistory: () => ({ changes: [...o], pointer: i }),
|
|
1061
|
-
on: (
|
|
1078
|
+
on: (g, m) => n.on(g, m),
|
|
1062
1079
|
redo: () => {
|
|
1063
1080
|
if (o.length - 1 > i) {
|
|
1064
1081
|
s = !0;
|
|
1065
|
-
const { created:
|
|
1066
|
-
f(
|
|
1082
|
+
const { created: g, updated: m, deleted: A } = o[i + 1];
|
|
1083
|
+
f(g), u(m), v(A), n.emit("redo", o[i + 1]), i += 1;
|
|
1067
1084
|
}
|
|
1068
1085
|
},
|
|
1069
1086
|
undo: () => {
|
|
1070
1087
|
if (i > -1) {
|
|
1071
1088
|
s = !0;
|
|
1072
|
-
const { created:
|
|
1073
|
-
|
|
1089
|
+
const { created: g, updated: m, deleted: A } = o[i];
|
|
1090
|
+
l(g), h(m), p(A), n.emit("undo", o[i]), i -= 1;
|
|
1074
1091
|
}
|
|
1075
1092
|
}
|
|
1076
1093
|
};
|
|
@@ -1080,56 +1097,56 @@ const On = 250, Bn = (t, e) => {
|
|
|
1080
1097
|
subscribe: t,
|
|
1081
1098
|
set: e
|
|
1082
1099
|
};
|
|
1083
|
-
},
|
|
1084
|
-
const { hover: i, selection: s, store: a, viewport: r } = t,
|
|
1100
|
+
}, Bn = (t, e, n, o) => {
|
|
1101
|
+
const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
|
|
1085
1102
|
let f = [], h;
|
|
1086
|
-
const u = (
|
|
1087
|
-
|
|
1088
|
-
},
|
|
1089
|
-
const
|
|
1090
|
-
if (
|
|
1091
|
-
const c =
|
|
1092
|
-
c !== -1 &&
|
|
1103
|
+
const u = (m, A) => {
|
|
1104
|
+
l.has(m) ? l.get(m).push(A) : l.set(m, [A]);
|
|
1105
|
+
}, p = (m, A) => {
|
|
1106
|
+
const d = l.get(m);
|
|
1107
|
+
if (d) {
|
|
1108
|
+
const c = d.indexOf(A);
|
|
1109
|
+
c !== -1 && d.splice(c, 1);
|
|
1093
1110
|
}
|
|
1094
|
-
}, v = (
|
|
1095
|
-
|
|
1096
|
-
|
|
1111
|
+
}, v = (m, A, d) => {
|
|
1112
|
+
l.has(m) && setTimeout(() => {
|
|
1113
|
+
l.get(m).forEach((c) => {
|
|
1097
1114
|
if (n) {
|
|
1098
|
-
const b = Array.isArray(
|
|
1115
|
+
const b = Array.isArray(A) ? A.map((E) => n.serialize(E)) : n.serialize(A), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
|
|
1099
1116
|
c(b, S);
|
|
1100
1117
|
} else
|
|
1101
|
-
c(
|
|
1118
|
+
c(A, d);
|
|
1102
1119
|
});
|
|
1103
1120
|
}, 1);
|
|
1104
1121
|
};
|
|
1105
|
-
s.subscribe(({ selected:
|
|
1106
|
-
if (!(f.length === 0 &&
|
|
1107
|
-
if (f.length === 0 &&
|
|
1108
|
-
f =
|
|
1109
|
-
else if (f.length > 0 &&
|
|
1110
|
-
f.forEach((
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1122
|
+
s.subscribe(({ selected: m }) => {
|
|
1123
|
+
if (!(f.length === 0 && m.length === 0)) {
|
|
1124
|
+
if (f.length === 0 && m.length > 0)
|
|
1125
|
+
f = m.map(({ id: A }) => a.getAnnotation(A));
|
|
1126
|
+
else if (f.length > 0 && m.length === 0)
|
|
1127
|
+
f.forEach((A) => {
|
|
1128
|
+
const d = a.getAnnotation(A.id);
|
|
1129
|
+
d && !Q(d, A) && v("updateAnnotation", d, A);
|
|
1113
1130
|
}), f = [];
|
|
1114
1131
|
else {
|
|
1115
|
-
const
|
|
1116
|
-
f.filter((c) => !
|
|
1132
|
+
const A = new Set(f.map((c) => c.id)), d = new Set(m.map(({ id: c }) => c));
|
|
1133
|
+
f.filter((c) => !d.has(c.id)).forEach((c) => {
|
|
1117
1134
|
const b = a.getAnnotation(c.id);
|
|
1118
|
-
b && !
|
|
1135
|
+
b && !Q(b, c) && v("updateAnnotation", b, c);
|
|
1119
1136
|
}), f = [
|
|
1120
1137
|
// Remove annotations that were deselected
|
|
1121
|
-
...f.filter((c) =>
|
|
1138
|
+
...f.filter((c) => d.has(c.id)),
|
|
1122
1139
|
// Add editable annotations that were selected
|
|
1123
|
-
...
|
|
1140
|
+
...m.filter(({ id: c }) => !A.has(c)).map(({ id: c }) => a.getAnnotation(c))
|
|
1124
1141
|
];
|
|
1125
1142
|
}
|
|
1126
1143
|
v("selectionChanged", f);
|
|
1127
1144
|
}
|
|
1128
|
-
}), i.subscribe((
|
|
1129
|
-
!h &&
|
|
1130
|
-
}), r == null || r.subscribe((
|
|
1131
|
-
const { created:
|
|
1132
|
-
(
|
|
1145
|
+
}), i.subscribe((m) => {
|
|
1146
|
+
!h && m ? v("mouseEnterAnnotation", a.getAnnotation(m)) : h && !m ? v("mouseLeaveAnnotation", a.getAnnotation(h)) : h && m && (v("mouseLeaveAnnotation", a.getAnnotation(h)), v("mouseEnterAnnotation", a.getAnnotation(m))), h = m;
|
|
1147
|
+
}), r == null || r.subscribe((m) => v("viewportIntersect", m.map((A) => a.getAnnotation(A)))), a.observe((m) => {
|
|
1148
|
+
const { created: A, deleted: d } = m.changes;
|
|
1149
|
+
(A || []).forEach((c) => v("createAnnotation", c)), (d || []).forEach((c) => v("deleteAnnotation", c)), (m.changes.updated || []).filter((c) => [
|
|
1133
1150
|
...c.bodiesCreated || [],
|
|
1134
1151
|
...c.bodiesDeleted || [],
|
|
1135
1152
|
...c.bodiesUpdated || []
|
|
@@ -1137,17 +1154,17 @@ const On = 250, Bn = (t, e) => {
|
|
|
1137
1154
|
const S = f.find((E) => E.id === c.id) || c;
|
|
1138
1155
|
f = f.map((E) => E.id === c.id ? b : E), v("updateAnnotation", b, S);
|
|
1139
1156
|
});
|
|
1140
|
-
}, { origin: k.LOCAL }), a.observe((
|
|
1157
|
+
}, { origin: k.LOCAL }), a.observe((m) => {
|
|
1141
1158
|
if (f) {
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1159
|
+
const A = new Set(f.map((c) => c.id)), d = (m.changes.updated || []).filter(({ newValue: c }) => A.has(c.id)).map(({ newValue: c }) => c);
|
|
1160
|
+
d.length > 0 && (f = f.map((c) => d.find((S) => S.id === c.id) || c));
|
|
1144
1161
|
}
|
|
1145
1162
|
}, { origin: k.REMOTE });
|
|
1146
|
-
const
|
|
1147
|
-
const { updated:
|
|
1148
|
-
|
|
1163
|
+
const g = (m) => (A) => {
|
|
1164
|
+
const { updated: d } = A;
|
|
1165
|
+
m ? (d || []).forEach((c) => v("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => v("updateAnnotation", c.newValue, c.oldValue));
|
|
1149
1166
|
};
|
|
1150
|
-
return e.on("undo",
|
|
1167
|
+
return e.on("undo", g(!0)), e.on("redo", g(!1)), { on: u, off: p, emit: v };
|
|
1151
1168
|
}, kn = (t) => (e) => e.reduce((n, o) => {
|
|
1152
1169
|
const { parsed: i, error: s } = t.parse(o);
|
|
1153
1170
|
return s ? {
|
|
@@ -1160,46 +1177,46 @@ const On = 250, Bn = (t, e) => {
|
|
|
1160
1177
|
...n
|
|
1161
1178
|
};
|
|
1162
1179
|
}, { parsed: [], failed: [] }), In = (t, e, n) => {
|
|
1163
|
-
const { store: o, selection: i } = t, s = (
|
|
1180
|
+
const { store: o, selection: i } = t, s = (d) => {
|
|
1164
1181
|
if (n) {
|
|
1165
|
-
const { parsed: c, error: b } = n.parse(
|
|
1182
|
+
const { parsed: c, error: b } = n.parse(d);
|
|
1166
1183
|
c ? o.addAnnotation(c, k.REMOTE) : console.error(b);
|
|
1167
1184
|
} else
|
|
1168
|
-
o.addAnnotation(
|
|
1169
|
-
}, a = () => i.clear(), r = () => o.clear(),
|
|
1170
|
-
const c = o.getAnnotation(
|
|
1185
|
+
o.addAnnotation(Mt(d), k.REMOTE);
|
|
1186
|
+
}, a = () => i.clear(), r = () => o.clear(), l = (d) => {
|
|
1187
|
+
const c = o.getAnnotation(d);
|
|
1171
1188
|
return n && c ? n.serialize(c) : c;
|
|
1172
1189
|
}, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
|
|
1173
|
-
var
|
|
1174
|
-
const c = (((
|
|
1190
|
+
var d;
|
|
1191
|
+
const c = (((d = i.selected) == null ? void 0 : d.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
|
|
1175
1192
|
return n ? c.map(n.serialize) : c;
|
|
1176
|
-
}, u = (
|
|
1177
|
-
if (typeof
|
|
1178
|
-
const c = o.getAnnotation(
|
|
1179
|
-
if (o.deleteAnnotation(
|
|
1193
|
+
}, u = (d, c = !0) => fetch(d).then((b) => b.json()).then((b) => (v(b, c), b)), p = (d) => {
|
|
1194
|
+
if (typeof d == "string") {
|
|
1195
|
+
const c = o.getAnnotation(d);
|
|
1196
|
+
if (o.deleteAnnotation(d), c)
|
|
1180
1197
|
return n ? n.serialize(c) : c;
|
|
1181
1198
|
} else {
|
|
1182
|
-
const c = n ? n.parse(
|
|
1199
|
+
const c = n ? n.parse(d).parsed : d;
|
|
1183
1200
|
if (c)
|
|
1184
|
-
return o.deleteAnnotation(c),
|
|
1201
|
+
return o.deleteAnnotation(c), d;
|
|
1185
1202
|
}
|
|
1186
|
-
}, v = (
|
|
1203
|
+
}, v = (d, c = !0) => {
|
|
1187
1204
|
if (n) {
|
|
1188
|
-
const b = n.parseAll || kn(n), { parsed: S, failed: E } = b(
|
|
1189
|
-
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.
|
|
1205
|
+
const b = n.parseAll || kn(n), { parsed: S, failed: E } = b(d);
|
|
1206
|
+
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotations(S, c, k.REMOTE);
|
|
1190
1207
|
} else
|
|
1191
|
-
o.
|
|
1192
|
-
},
|
|
1193
|
-
|
|
1194
|
-
},
|
|
1195
|
-
i.clear(), i.setUserSelectAction(
|
|
1196
|
-
},
|
|
1208
|
+
o.bulkAddAnnotations(d.map(Mt), c, k.REMOTE);
|
|
1209
|
+
}, g = (d, c) => {
|
|
1210
|
+
d ? i.setSelected(d, c) : i.clear();
|
|
1211
|
+
}, m = (d) => {
|
|
1212
|
+
i.clear(), i.setUserSelectAction(d);
|
|
1213
|
+
}, A = (d) => {
|
|
1197
1214
|
if (n) {
|
|
1198
|
-
const c = n.parse(
|
|
1215
|
+
const c = n.parse(d).parsed, b = n.serialize(o.getAnnotation(c.id));
|
|
1199
1216
|
return o.updateAnnotation(c), b;
|
|
1200
1217
|
} else {
|
|
1201
|
-
const c = o.getAnnotation(
|
|
1202
|
-
return o.updateAnnotation(
|
|
1218
|
+
const c = o.getAnnotation(d.id);
|
|
1219
|
+
return o.updateAnnotation(Mt(d)), c;
|
|
1203
1220
|
}
|
|
1204
1221
|
};
|
|
1205
1222
|
return {
|
|
@@ -1208,37 +1225,37 @@ const On = 250, Bn = (t, e) => {
|
|
|
1208
1225
|
canRedo: e.canRedo,
|
|
1209
1226
|
canUndo: e.canUndo,
|
|
1210
1227
|
clearAnnotations: r,
|
|
1211
|
-
getAnnotationById:
|
|
1228
|
+
getAnnotationById: l,
|
|
1212
1229
|
getAnnotations: f,
|
|
1213
1230
|
getHistory: e.getHistory,
|
|
1214
1231
|
getSelected: h,
|
|
1215
1232
|
loadAnnotations: u,
|
|
1216
1233
|
redo: e.redo,
|
|
1217
|
-
removeAnnotation:
|
|
1234
|
+
removeAnnotation: p,
|
|
1218
1235
|
setAnnotations: v,
|
|
1219
|
-
setSelected:
|
|
1220
|
-
setUserSelectAction:
|
|
1236
|
+
setSelected: g,
|
|
1237
|
+
setUserSelectAction: m,
|
|
1221
1238
|
undo: e.undo,
|
|
1222
|
-
updateAnnotation:
|
|
1239
|
+
updateAnnotation: A
|
|
1223
1240
|
};
|
|
1224
|
-
},
|
|
1225
|
-
let
|
|
1241
|
+
}, Un = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1242
|
+
let _n = (t) => crypto.getRandomValues(new Uint8Array(t)), Nn = (t, e, n) => {
|
|
1226
1243
|
let o = (2 << Math.log2(t.length - 1)) - 1, i = -~(1.6 * o * e / t.length);
|
|
1227
1244
|
return (s = e) => {
|
|
1228
1245
|
let a = "";
|
|
1229
1246
|
for (; ; ) {
|
|
1230
|
-
let r = n(i),
|
|
1231
|
-
for (;
|
|
1232
|
-
if (a += t[r[
|
|
1247
|
+
let r = n(i), l = i | 0;
|
|
1248
|
+
for (; l--; )
|
|
1249
|
+
if (a += t[r[l] & o] || "", a.length >= s) return a;
|
|
1233
1250
|
}
|
|
1234
1251
|
};
|
|
1235
|
-
}, Vn = (t, e = 21) =>
|
|
1252
|
+
}, Vn = (t, e = 21) => Nn(t, e | 0, _n), Dn = (t = 21) => {
|
|
1236
1253
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
|
|
1237
1254
|
for (; t--; )
|
|
1238
|
-
e +=
|
|
1255
|
+
e += Un[n[t] & 63];
|
|
1239
1256
|
return e;
|
|
1240
1257
|
};
|
|
1241
|
-
const
|
|
1258
|
+
const Yn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Kn = (t) => {
|
|
1242
1259
|
const e = JSON.stringify(t);
|
|
1243
1260
|
let n = 0;
|
|
1244
1261
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1246,17 +1263,17 @@ const Dn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1246
1263
|
n = (n << 5) - n + s, n |= 0;
|
|
1247
1264
|
}
|
|
1248
1265
|
return `${n}`;
|
|
1249
|
-
},
|
|
1250
|
-
const { id: o, type: i, purpose: s, value: a, created: r, modified:
|
|
1266
|
+
}, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1267
|
+
const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...h } = n;
|
|
1251
1268
|
return {
|
|
1252
1269
|
id: o || `temp-${Kn(n)}`,
|
|
1253
1270
|
annotation: e,
|
|
1254
1271
|
type: i,
|
|
1255
1272
|
purpose: s,
|
|
1256
1273
|
value: a,
|
|
1257
|
-
creator:
|
|
1274
|
+
creator: ge(f),
|
|
1258
1275
|
created: r ? new Date(r) : void 0,
|
|
1259
|
-
updated:
|
|
1276
|
+
updated: l ? new Date(l) : void 0,
|
|
1260
1277
|
...h
|
|
1261
1278
|
};
|
|
1262
1279
|
}), Pn = (t) => t.map((e) => {
|
|
@@ -1268,7 +1285,7 @@ const Dn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1268
1285
|
};
|
|
1269
1286
|
return (n = r.id) != null && n.startsWith("temp-") && delete r.id, r;
|
|
1270
1287
|
});
|
|
1271
|
-
|
|
1288
|
+
Dn();
|
|
1272
1289
|
const xo = (t, e) => ({
|
|
1273
1290
|
parse: (n) => jn(n),
|
|
1274
1291
|
serialize: (n) => zn(n, t, e)
|
|
@@ -1283,7 +1300,7 @@ const xo = (t, e) => ({
|
|
|
1283
1300
|
if (a.length === 0)
|
|
1284
1301
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1285
1302
|
const r = {
|
|
1286
|
-
creator:
|
|
1303
|
+
creator: ge(n),
|
|
1287
1304
|
created: o ? new Date(o) : void 0,
|
|
1288
1305
|
updated: i ? new Date(i) : void 0,
|
|
1289
1306
|
annotation: e,
|
|
@@ -1291,14 +1308,14 @@ const xo = (t, e) => ({
|
|
|
1291
1308
|
// @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
|
|
1292
1309
|
styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
|
|
1293
1310
|
};
|
|
1294
|
-
for (const
|
|
1295
|
-
const h = (Array.isArray(
|
|
1296
|
-
switch (
|
|
1311
|
+
for (const l of a) {
|
|
1312
|
+
const h = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, p) => {
|
|
1313
|
+
switch (p.type) {
|
|
1297
1314
|
case "TextQuoteSelector":
|
|
1298
|
-
u.quote =
|
|
1315
|
+
u.quote = p.exact;
|
|
1299
1316
|
break;
|
|
1300
1317
|
case "TextPositionSelector":
|
|
1301
|
-
u.start =
|
|
1318
|
+
u.start = p.start, u.end = p.end;
|
|
1302
1319
|
break;
|
|
1303
1320
|
}
|
|
1304
1321
|
return u;
|
|
@@ -1307,9 +1324,9 @@ const xo = (t, e) => ({
|
|
|
1307
1324
|
r.selector.push(
|
|
1308
1325
|
{
|
|
1309
1326
|
...h,
|
|
1310
|
-
id:
|
|
1327
|
+
id: l.id,
|
|
1311
1328
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1312
|
-
scope:
|
|
1329
|
+
scope: l.scope
|
|
1313
1330
|
}
|
|
1314
1331
|
);
|
|
1315
1332
|
else {
|
|
@@ -1328,38 +1345,38 @@ const xo = (t, e) => ({
|
|
|
1328
1345
|
modified: i,
|
|
1329
1346
|
body: s,
|
|
1330
1347
|
...a
|
|
1331
|
-
} = t, r = Xn(s, e),
|
|
1332
|
-
return "error" in
|
|
1348
|
+
} = t, r = Xn(s, e), l = Hn(t);
|
|
1349
|
+
return "error" in l ? { error: l.error } : {
|
|
1333
1350
|
parsed: {
|
|
1334
1351
|
...a,
|
|
1335
1352
|
id: e,
|
|
1336
1353
|
bodies: r,
|
|
1337
|
-
target:
|
|
1354
|
+
target: l.parsed
|
|
1338
1355
|
}
|
|
1339
1356
|
};
|
|
1340
1357
|
}, zn = (t, e, n) => {
|
|
1341
1358
|
const { bodies: o, target: i, ...s } = t, {
|
|
1342
1359
|
selector: a,
|
|
1343
1360
|
creator: r,
|
|
1344
|
-
created:
|
|
1361
|
+
created: l,
|
|
1345
1362
|
updated: f,
|
|
1346
1363
|
...h
|
|
1347
|
-
} = i, u = a.map((
|
|
1348
|
-
const { id: v, quote:
|
|
1364
|
+
} = i, u = a.map((p) => {
|
|
1365
|
+
const { id: v, quote: g, start: m, end: A, range: d } = p, { prefix: c, suffix: b } = Be(d, n), S = [{
|
|
1349
1366
|
type: "TextQuoteSelector",
|
|
1350
|
-
exact:
|
|
1367
|
+
exact: g,
|
|
1351
1368
|
prefix: c,
|
|
1352
1369
|
suffix: b
|
|
1353
1370
|
}, {
|
|
1354
1371
|
type: "TextPositionSelector",
|
|
1355
|
-
start:
|
|
1356
|
-
end:
|
|
1372
|
+
start: m,
|
|
1373
|
+
end: A
|
|
1357
1374
|
}];
|
|
1358
1375
|
return {
|
|
1359
1376
|
...h,
|
|
1360
1377
|
id: v,
|
|
1361
1378
|
// @ts-expect-error: `scope` is not part of the core `TextSelector` type
|
|
1362
|
-
scope: "scope" in
|
|
1379
|
+
scope: "scope" in p ? p.scope : void 0,
|
|
1363
1380
|
source: e,
|
|
1364
1381
|
selector: S
|
|
1365
1382
|
};
|
|
@@ -1371,7 +1388,7 @@ const xo = (t, e) => ({
|
|
|
1371
1388
|
type: "Annotation",
|
|
1372
1389
|
body: Pn(t.bodies),
|
|
1373
1390
|
creator: r,
|
|
1374
|
-
created:
|
|
1391
|
+
created: l == null ? void 0 : l.toISOString(),
|
|
1375
1392
|
modified: f == null ? void 0 : f.toISOString(),
|
|
1376
1393
|
target: u
|
|
1377
1394
|
};
|
|
@@ -1379,8 +1396,8 @@ const xo = (t, e) => ({
|
|
|
1379
1396
|
function me(t, e, n = 0, o = t.length - 1, i = Fn) {
|
|
1380
1397
|
for (; o > n; ) {
|
|
1381
1398
|
if (o - n > 600) {
|
|
1382
|
-
const
|
|
1383
|
-
me(t, e, v,
|
|
1399
|
+
const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), v = Math.max(n, Math.floor(e - f * u / l + p)), g = Math.min(o, Math.floor(e + (l - f) * u / l + p));
|
|
1400
|
+
me(t, e, v, g, i);
|
|
1384
1401
|
}
|
|
1385
1402
|
const s = t[e];
|
|
1386
1403
|
let a = n, r = o;
|
|
@@ -1408,12 +1425,12 @@ class Wn {
|
|
|
1408
1425
|
search(e) {
|
|
1409
1426
|
let n = this.data;
|
|
1410
1427
|
const o = [];
|
|
1411
|
-
if (!
|
|
1428
|
+
if (!yt(e, n)) return o;
|
|
1412
1429
|
const i = this.toBBox, s = [];
|
|
1413
1430
|
for (; n; ) {
|
|
1414
1431
|
for (let a = 0; a < n.children.length; a++) {
|
|
1415
|
-
const r = n.children[a],
|
|
1416
|
-
|
|
1432
|
+
const r = n.children[a], l = n.leaf ? i(r) : r;
|
|
1433
|
+
yt(e, l) && (n.leaf ? o.push(r) : kt(e, l) ? this._all(r, o) : s.push(r));
|
|
1417
1434
|
}
|
|
1418
1435
|
n = s.pop();
|
|
1419
1436
|
}
|
|
@@ -1421,12 +1438,12 @@ class Wn {
|
|
|
1421
1438
|
}
|
|
1422
1439
|
collides(e) {
|
|
1423
1440
|
let n = this.data;
|
|
1424
|
-
if (!
|
|
1441
|
+
if (!yt(e, n)) return !1;
|
|
1425
1442
|
const o = [];
|
|
1426
1443
|
for (; n; ) {
|
|
1427
1444
|
for (let i = 0; i < n.children.length; i++) {
|
|
1428
1445
|
const s = n.children[i], a = n.leaf ? this.toBBox(s) : s;
|
|
1429
|
-
if (
|
|
1446
|
+
if (yt(e, a)) {
|
|
1430
1447
|
if (n.leaf || kt(e, a)) return !0;
|
|
1431
1448
|
o.push(s);
|
|
1432
1449
|
}
|
|
@@ -1460,20 +1477,20 @@ class Wn {
|
|
|
1460
1477
|
return e && this._insert(e, this.data.height - 1), this;
|
|
1461
1478
|
}
|
|
1462
1479
|
clear() {
|
|
1463
|
-
return this.data =
|
|
1480
|
+
return this.data = tt([]), this;
|
|
1464
1481
|
}
|
|
1465
1482
|
remove(e, n) {
|
|
1466
1483
|
if (!e) return this;
|
|
1467
1484
|
let o = this.data;
|
|
1468
1485
|
const i = this.toBBox(e), s = [], a = [];
|
|
1469
|
-
let r,
|
|
1486
|
+
let r, l, f;
|
|
1470
1487
|
for (; o || s.length; ) {
|
|
1471
|
-
if (o || (o = s.pop(),
|
|
1488
|
+
if (o || (o = s.pop(), l = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
|
|
1472
1489
|
const h = qn(e, o.children, n);
|
|
1473
1490
|
if (h !== -1)
|
|
1474
1491
|
return o.children.splice(h, 1), s.push(o), this._condense(s), this;
|
|
1475
1492
|
}
|
|
1476
|
-
!f && !o.leaf && kt(o, i) ? (s.push(o), a.push(r), r = 0,
|
|
1493
|
+
!f && !o.leaf && kt(o, i) ? (s.push(o), a.push(r), r = 0, l = o, o = o.children[0]) : l ? (r++, o = l.children[r], f = !1) : o = null;
|
|
1477
1494
|
}
|
|
1478
1495
|
return this;
|
|
1479
1496
|
}
|
|
@@ -1502,25 +1519,25 @@ class Wn {
|
|
|
1502
1519
|
const s = o - n + 1;
|
|
1503
1520
|
let a = this._maxEntries, r;
|
|
1504
1521
|
if (s <= a)
|
|
1505
|
-
return r =
|
|
1506
|
-
i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r =
|
|
1507
|
-
const
|
|
1522
|
+
return r = tt(e.slice(n, o + 1)), Z(r, this.toBBox), r;
|
|
1523
|
+
i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r = tt([]), r.leaf = !1, r.height = i;
|
|
1524
|
+
const l = Math.ceil(s / a), f = l * Math.ceil(Math.sqrt(a));
|
|
1508
1525
|
ee(e, n, o, f, this.compareMinX);
|
|
1509
1526
|
for (let h = n; h <= o; h += f) {
|
|
1510
1527
|
const u = Math.min(h + f - 1, o);
|
|
1511
|
-
ee(e, h, u,
|
|
1512
|
-
for (let
|
|
1513
|
-
const v = Math.min(
|
|
1514
|
-
r.children.push(this._build(e,
|
|
1528
|
+
ee(e, h, u, l, this.compareMinY);
|
|
1529
|
+
for (let p = h; p <= u; p += l) {
|
|
1530
|
+
const v = Math.min(p + l - 1, u);
|
|
1531
|
+
r.children.push(this._build(e, p, v, i - 1));
|
|
1515
1532
|
}
|
|
1516
1533
|
}
|
|
1517
|
-
return
|
|
1534
|
+
return Z(r, this.toBBox), r;
|
|
1518
1535
|
}
|
|
1519
1536
|
_chooseSubtree(e, n, o, i) {
|
|
1520
1537
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1521
1538
|
let s = 1 / 0, a = 1 / 0, r;
|
|
1522
|
-
for (let
|
|
1523
|
-
const f = n.children[
|
|
1539
|
+
for (let l = 0; l < n.children.length; l++) {
|
|
1540
|
+
const f = n.children[l], h = Bt(f), u = Jn(e, f) - h;
|
|
1524
1541
|
u < a ? (a = u, s = h < s ? h : s, r = f) : u === a && h < s && (s = h, r = f);
|
|
1525
1542
|
}
|
|
1526
1543
|
n = r || n.children[0];
|
|
@@ -1537,16 +1554,16 @@ class Wn {
|
|
|
1537
1554
|
_split(e, n) {
|
|
1538
1555
|
const o = e[n], i = o.children.length, s = this._minEntries;
|
|
1539
1556
|
this._chooseSplitAxis(o, s, i);
|
|
1540
|
-
const a = this._chooseSplitIndex(o, s, i), r =
|
|
1541
|
-
r.height = o.height, r.leaf = o.leaf,
|
|
1557
|
+
const a = this._chooseSplitIndex(o, s, i), r = tt(o.children.splice(a, o.children.length - a));
|
|
1558
|
+
r.height = o.height, r.leaf = o.leaf, Z(o, this.toBBox), Z(r, this.toBBox), n ? e[n - 1].children.push(r) : this._splitRoot(o, r);
|
|
1542
1559
|
}
|
|
1543
1560
|
_splitRoot(e, n) {
|
|
1544
|
-
this.data =
|
|
1561
|
+
this.data = tt([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, Z(this.data, this.toBBox);
|
|
1545
1562
|
}
|
|
1546
1563
|
_chooseSplitIndex(e, n, o) {
|
|
1547
1564
|
let i, s = 1 / 0, a = 1 / 0;
|
|
1548
1565
|
for (let r = n; r <= o - n; r++) {
|
|
1549
|
-
const
|
|
1566
|
+
const l = st(e, 0, r, this.toBBox), f = st(e, r, o, this.toBBox), h = Zn(l, f), u = Bt(l) + Bt(f);
|
|
1550
1567
|
h < s ? (s = h, i = r, a = u < a ? u : a) : h === s && u < a && (a = u, i = r);
|
|
1551
1568
|
}
|
|
1552
1569
|
return i || o - n;
|
|
@@ -1560,16 +1577,16 @@ class Wn {
|
|
|
1560
1577
|
_allDistMargin(e, n, o, i) {
|
|
1561
1578
|
e.children.sort(i);
|
|
1562
1579
|
const s = this.toBBox, a = st(e, 0, n, s), r = st(e, o - n, o, s);
|
|
1563
|
-
let
|
|
1580
|
+
let l = mt(a) + mt(r);
|
|
1564
1581
|
for (let f = n; f < o - n; f++) {
|
|
1565
1582
|
const h = e.children[f];
|
|
1566
|
-
rt(a, e.leaf ? s(h) : h),
|
|
1583
|
+
rt(a, e.leaf ? s(h) : h), l += mt(a);
|
|
1567
1584
|
}
|
|
1568
1585
|
for (let f = o - n - 1; f >= n; f--) {
|
|
1569
1586
|
const h = e.children[f];
|
|
1570
|
-
rt(r, e.leaf ? s(h) : h),
|
|
1587
|
+
rt(r, e.leaf ? s(h) : h), l += mt(r);
|
|
1571
1588
|
}
|
|
1572
|
-
return
|
|
1589
|
+
return l;
|
|
1573
1590
|
}
|
|
1574
1591
|
_adjustParentBBoxes(e, n, o) {
|
|
1575
1592
|
for (let i = o; i >= 0; i--)
|
|
@@ -1577,7 +1594,7 @@ class Wn {
|
|
|
1577
1594
|
}
|
|
1578
1595
|
_condense(e) {
|
|
1579
1596
|
for (let n = e.length - 1, o; n >= 0; n--)
|
|
1580
|
-
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() :
|
|
1597
|
+
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : Z(e[n], this.toBBox);
|
|
1581
1598
|
}
|
|
1582
1599
|
}
|
|
1583
1600
|
function qn(t, e, n) {
|
|
@@ -1586,11 +1603,11 @@ function qn(t, e, n) {
|
|
|
1586
1603
|
if (n(t, e[o])) return o;
|
|
1587
1604
|
return -1;
|
|
1588
1605
|
}
|
|
1589
|
-
function
|
|
1606
|
+
function Z(t, e) {
|
|
1590
1607
|
st(t, 0, t.children.length, e, t);
|
|
1591
1608
|
}
|
|
1592
1609
|
function st(t, e, n, o, i) {
|
|
1593
|
-
i || (i =
|
|
1610
|
+
i || (i = tt(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
|
|
1594
1611
|
for (let s = e; s < n; s++) {
|
|
1595
1612
|
const a = t.children[s];
|
|
1596
1613
|
rt(i, t.leaf ? o(a) : a);
|
|
@@ -1606,10 +1623,10 @@ function Gn(t, e) {
|
|
|
1606
1623
|
function Qn(t, e) {
|
|
1607
1624
|
return t.minY - e.minY;
|
|
1608
1625
|
}
|
|
1609
|
-
function
|
|
1626
|
+
function Bt(t) {
|
|
1610
1627
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1611
1628
|
}
|
|
1612
|
-
function
|
|
1629
|
+
function mt(t) {
|
|
1613
1630
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1614
1631
|
}
|
|
1615
1632
|
function Jn(t, e) {
|
|
@@ -1622,10 +1639,10 @@ function Zn(t, e) {
|
|
|
1622
1639
|
function kt(t, e) {
|
|
1623
1640
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1624
1641
|
}
|
|
1625
|
-
function
|
|
1642
|
+
function yt(t, e) {
|
|
1626
1643
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1627
1644
|
}
|
|
1628
|
-
function
|
|
1645
|
+
function tt(t) {
|
|
1629
1646
|
return {
|
|
1630
1647
|
children: t,
|
|
1631
1648
|
height: 1,
|
|
@@ -1645,129 +1662,129 @@ function ee(t, e, n, o, i) {
|
|
|
1645
1662
|
}
|
|
1646
1663
|
}
|
|
1647
1664
|
const to = (t, e) => {
|
|
1648
|
-
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (
|
|
1649
|
-
const b =
|
|
1650
|
-
const C =
|
|
1665
|
+
const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
|
|
1666
|
+
const b = d.selector.flatMap((E) => {
|
|
1667
|
+
const C = q([E]) ? E.range : ae(E, e).range;
|
|
1651
1668
|
return Array.from(C.getClientRects());
|
|
1652
|
-
}), S =
|
|
1669
|
+
}), S = Ne(b).map(({ left: E, top: C, right: R, bottom: M }) => new DOMRect(E - c.left, C - c.top, R - E, M - C));
|
|
1653
1670
|
return S.map((E) => {
|
|
1654
|
-
const { x: C, y:
|
|
1671
|
+
const { x: C, y: R, width: M, height: T } = E;
|
|
1655
1672
|
return {
|
|
1656
1673
|
minX: C,
|
|
1657
|
-
minY:
|
|
1658
|
-
maxX: C +
|
|
1659
|
-
maxY:
|
|
1674
|
+
minY: R,
|
|
1675
|
+
maxX: C + M,
|
|
1676
|
+
maxY: R + T,
|
|
1660
1677
|
annotation: {
|
|
1661
|
-
id:
|
|
1678
|
+
id: d.annotation,
|
|
1662
1679
|
rects: S
|
|
1663
1680
|
}
|
|
1664
1681
|
};
|
|
1665
1682
|
});
|
|
1666
1683
|
}, s = () => [...o.values()], a = () => {
|
|
1667
1684
|
n.clear(), o.clear();
|
|
1668
|
-
}, r = (
|
|
1669
|
-
const c = i(
|
|
1670
|
-
c.length !== 0 && (c.forEach((b) => n.insert(b)), o.set(
|
|
1671
|
-
},
|
|
1672
|
-
const c = o.get(
|
|
1673
|
-
c && (c.forEach((b) => n.remove(b)), o.delete(
|
|
1674
|
-
}, f = (
|
|
1675
|
-
d
|
|
1676
|
-
}, h = (
|
|
1685
|
+
}, r = (d) => {
|
|
1686
|
+
const c = i(d, e.getBoundingClientRect());
|
|
1687
|
+
c.length !== 0 && (c.forEach((b) => n.insert(b)), o.set(d.annotation, c));
|
|
1688
|
+
}, l = (d) => {
|
|
1689
|
+
const c = o.get(d.annotation);
|
|
1690
|
+
c && (c.forEach((b) => n.remove(b)), o.delete(d.annotation));
|
|
1691
|
+
}, f = (d) => {
|
|
1692
|
+
l(d), r(d);
|
|
1693
|
+
}, h = (d, c = !0) => {
|
|
1677
1694
|
c && a();
|
|
1678
|
-
const b = e.getBoundingClientRect(), S =
|
|
1679
|
-
S.forEach(({ target: C, rects:
|
|
1680
|
-
|
|
1695
|
+
const b = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: i(C, b) }));
|
|
1696
|
+
S.forEach(({ target: C, rects: R }) => {
|
|
1697
|
+
R.length > 0 && o.set(C.annotation, R);
|
|
1681
1698
|
});
|
|
1682
1699
|
const E = S.flatMap(({ rects: C }) => C);
|
|
1683
1700
|
n.load(E);
|
|
1684
|
-
}, u = (
|
|
1701
|
+
}, u = (d, c, b = !1) => {
|
|
1685
1702
|
const S = n.search({
|
|
1686
|
-
minX:
|
|
1703
|
+
minX: d,
|
|
1687
1704
|
minY: c,
|
|
1688
|
-
maxX:
|
|
1705
|
+
maxX: d,
|
|
1689
1706
|
maxY: c
|
|
1690
|
-
}), E = (C) => C.annotation.rects.reduce((
|
|
1691
|
-
return S.length > 0 ? (S.sort((C,
|
|
1692
|
-
},
|
|
1693
|
-
const c = v(
|
|
1707
|
+
}), E = (C) => C.annotation.rects.reduce((R, M) => R + M.width * M.height, 0);
|
|
1708
|
+
return S.length > 0 ? (S.sort((C, R) => E(C) - E(R)), b ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
|
|
1709
|
+
}, p = (d) => {
|
|
1710
|
+
const c = v(d);
|
|
1694
1711
|
if (c.length === 0)
|
|
1695
1712
|
return;
|
|
1696
1713
|
let b = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
|
|
1697
|
-
for (let
|
|
1698
|
-
const
|
|
1699
|
-
b = Math.min(b,
|
|
1714
|
+
for (let R = 1; R < c.length; R++) {
|
|
1715
|
+
const M = c[R];
|
|
1716
|
+
b = Math.min(b, M.left), S = Math.min(S, M.top), E = Math.max(E, M.right), C = Math.max(C, M.bottom);
|
|
1700
1717
|
}
|
|
1701
1718
|
return new DOMRect(b, S, E - b, C - S);
|
|
1702
|
-
}, v = (
|
|
1703
|
-
const c = o.get(
|
|
1719
|
+
}, v = (d) => {
|
|
1720
|
+
const c = o.get(d);
|
|
1704
1721
|
return c ? c[0].annotation.rects : [];
|
|
1705
1722
|
};
|
|
1706
1723
|
return {
|
|
1707
1724
|
all: s,
|
|
1708
1725
|
clear: a,
|
|
1709
1726
|
getAt: u,
|
|
1710
|
-
getAnnotationBounds:
|
|
1727
|
+
getAnnotationBounds: p,
|
|
1711
1728
|
getAnnotationRects: v,
|
|
1712
|
-
getIntersecting: (
|
|
1713
|
-
const E = n.search({ minX:
|
|
1714
|
-
return Array.from(C).map((
|
|
1715
|
-
annotation: t.getAnnotation(
|
|
1716
|
-
rects: v(
|
|
1717
|
-
})).filter((
|
|
1729
|
+
getIntersecting: (d, c, b, S) => {
|
|
1730
|
+
const E = n.search({ minX: d, minY: c, maxX: b, maxY: S }), C = new Set(E.map((R) => R.annotation.id));
|
|
1731
|
+
return Array.from(C).map((R) => ({
|
|
1732
|
+
annotation: t.getAnnotation(R),
|
|
1733
|
+
rects: v(R)
|
|
1734
|
+
})).filter((R) => !!R.annotation);
|
|
1718
1735
|
},
|
|
1719
1736
|
insert: r,
|
|
1720
|
-
recalculate: () => h(t.all().map((
|
|
1721
|
-
remove:
|
|
1737
|
+
recalculate: () => h(t.all().map((d) => d.target), !0),
|
|
1738
|
+
remove: l,
|
|
1722
1739
|
set: h,
|
|
1723
1740
|
size: () => n.all().length,
|
|
1724
1741
|
update: f
|
|
1725
1742
|
};
|
|
1726
1743
|
}, eo = (t, e) => {
|
|
1727
|
-
const n = Ln(), o = to(n, t), i =
|
|
1744
|
+
const n = Ln(), o = to(n, t), i = pn(n);
|
|
1728
1745
|
i.setUserSelectAction(e);
|
|
1729
|
-
const s = fn(n), a = Mn(), r = (
|
|
1730
|
-
const b =
|
|
1746
|
+
const s = fn(n), a = Mn(), r = (d, c = k.LOCAL) => {
|
|
1747
|
+
const b = Et(d, t), S = q(b.target.selector);
|
|
1731
1748
|
return S && n.addAnnotation(b, c), S;
|
|
1732
|
-
},
|
|
1733
|
-
const S =
|
|
1734
|
-
return n.
|
|
1735
|
-
}, f = (
|
|
1736
|
-
const b =
|
|
1749
|
+
}, l = (d, c = !0, b = k.LOCAL) => {
|
|
1750
|
+
const S = d.map((C) => Et(C, t)), E = S.filter((C) => !q(C.target.selector));
|
|
1751
|
+
return n.bulkAddAnnotations(S, c, b), E;
|
|
1752
|
+
}, f = (d, c = k.LOCAL) => {
|
|
1753
|
+
const b = d.map((E) => Et(E, t)), S = b.filter((E) => !q(E.target.selector));
|
|
1737
1754
|
return b.forEach((E) => {
|
|
1738
1755
|
n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
|
|
1739
1756
|
}), S;
|
|
1740
|
-
}, h = (
|
|
1741
|
-
const b =
|
|
1757
|
+
}, h = (d, c = k.LOCAL) => {
|
|
1758
|
+
const b = At(d, t);
|
|
1742
1759
|
n.updateTarget(b, c);
|
|
1743
|
-
}, u = (
|
|
1744
|
-
const b =
|
|
1760
|
+
}, u = (d, c = k.LOCAL) => {
|
|
1761
|
+
const b = d.map((S) => At(S, t));
|
|
1745
1762
|
n.bulkUpdateTargets(b, c);
|
|
1746
1763
|
};
|
|
1747
|
-
function
|
|
1748
|
-
const E = b || !!S, C = o.getAt(
|
|
1749
|
-
if (
|
|
1750
|
-
return b ?
|
|
1764
|
+
function p(d, c, b, S) {
|
|
1765
|
+
const E = b || !!S, C = o.getAt(d, c, E).map((M) => n.getAnnotation(M)), R = S ? C.filter(S) : C;
|
|
1766
|
+
if (R.length !== 0)
|
|
1767
|
+
return b ? R : R[0];
|
|
1751
1768
|
}
|
|
1752
|
-
const v = (
|
|
1753
|
-
if (o.getAnnotationRects(
|
|
1754
|
-
return o.getAnnotationBounds(
|
|
1755
|
-
},
|
|
1756
|
-
return n.observe(({ changes:
|
|
1757
|
-
const c = (
|
|
1769
|
+
const v = (d) => {
|
|
1770
|
+
if (o.getAnnotationRects(d).length !== 0)
|
|
1771
|
+
return o.getAnnotationBounds(d);
|
|
1772
|
+
}, g = (d, c, b, S) => o.getIntersecting(d, c, b, S), m = (d) => o.getAnnotationRects(d), A = () => o.recalculate();
|
|
1773
|
+
return n.observe(({ changes: d }) => {
|
|
1774
|
+
const c = (d.deleted || []).filter((E) => q(E.target.selector)), b = (d.created || []).filter((E) => q(E.target.selector)), S = (d.updated || []).filter((E) => q(E.newValue.target.selector));
|
|
1758
1775
|
(c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), b.length > 0 && o.set(b.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
|
|
1759
1776
|
}), {
|
|
1760
1777
|
store: {
|
|
1761
1778
|
...n,
|
|
1762
1779
|
addAnnotation: r,
|
|
1763
|
-
bulkAddAnnotation:
|
|
1780
|
+
bulkAddAnnotation: l,
|
|
1764
1781
|
bulkUpdateTargets: u,
|
|
1765
1782
|
bulkUpsertAnnotations: f,
|
|
1766
1783
|
getAnnotationBounds: v,
|
|
1767
|
-
getAnnotationRects:
|
|
1768
|
-
getIntersecting:
|
|
1769
|
-
getAt:
|
|
1770
|
-
recalculatePositions:
|
|
1784
|
+
getAnnotationRects: m,
|
|
1785
|
+
getIntersecting: g,
|
|
1786
|
+
getAt: p,
|
|
1787
|
+
recalculatePositions: A,
|
|
1771
1788
|
updateTarget: h
|
|
1772
1789
|
},
|
|
1773
1790
|
selection: i,
|
|
@@ -1782,7 +1799,7 @@ const to = (t, e) => {
|
|
|
1782
1799
|
}, oo = (t, e = {}) => {
|
|
1783
1800
|
const n = no(), o = n.getContext("2d");
|
|
1784
1801
|
document.body.appendChild(n);
|
|
1785
|
-
const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u,
|
|
1802
|
+
const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u, p]) => p.presenceKey === h.presenceKey).map(([u, p]) => u);
|
|
1786
1803
|
return t.on("selectionChange", (h, u) => {
|
|
1787
1804
|
s(h).forEach((v) => i.delete(v)), u && u.forEach((v) => i.set(v, h));
|
|
1788
1805
|
}), {
|
|
@@ -1793,16 +1810,16 @@ const to = (t, e) => {
|
|
|
1793
1810
|
destroy: () => {
|
|
1794
1811
|
n.remove();
|
|
1795
1812
|
},
|
|
1796
|
-
paint: (h, u,
|
|
1813
|
+
paint: (h, u, p) => {
|
|
1797
1814
|
e.font && (o.font = e.font);
|
|
1798
1815
|
const v = i.get(h.annotation.id);
|
|
1799
1816
|
if (v) {
|
|
1800
|
-
const { height:
|
|
1801
|
-
o.fillStyle = v.appearance.color, o.fillRect(
|
|
1802
|
-
const
|
|
1803
|
-
return o.fillRect(
|
|
1817
|
+
const { height: g } = h.rects[0], m = h.rects[0].x + u.left, A = h.rects[0].y + u.top;
|
|
1818
|
+
o.fillStyle = v.appearance.color, o.fillRect(m - 2, A - 2.5, 2, g + 5);
|
|
1819
|
+
const d = o.measureText(v.appearance.label), c = d.width + 6, b = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1820
|
+
return o.fillRect(m - 2, A - 2.5 - b, c, b), o.fillStyle = "#fff", o.fillText(v.appearance.label, m + 1, A - S), {
|
|
1804
1821
|
fill: v.appearance.color,
|
|
1805
|
-
fillOpacity:
|
|
1822
|
+
fillOpacity: p ? 0.45 : 0.18
|
|
1806
1823
|
};
|
|
1807
1824
|
}
|
|
1808
1825
|
},
|
|
@@ -1813,7 +1830,7 @@ const to = (t, e) => {
|
|
|
1813
1830
|
}
|
|
1814
1831
|
};
|
|
1815
1832
|
}, It = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
1816
|
-
function
|
|
1833
|
+
function Ut(t, e, n, o) {
|
|
1817
1834
|
t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
|
|
1818
1835
|
}
|
|
1819
1836
|
function ot(t, e, n, o) {
|
|
@@ -1891,7 +1908,7 @@ const lt = {
|
|
|
1891
1908
|
"[": 219,
|
|
1892
1909
|
"]": 221,
|
|
1893
1910
|
"\\": 220
|
|
1894
|
-
},
|
|
1911
|
+
}, z = {
|
|
1895
1912
|
// shiftKey
|
|
1896
1913
|
"⇧": 16,
|
|
1897
1914
|
shift: 16,
|
|
@@ -1907,7 +1924,7 @@ const lt = {
|
|
|
1907
1924
|
"⌘": 91,
|
|
1908
1925
|
cmd: 91,
|
|
1909
1926
|
command: 91
|
|
1910
|
-
},
|
|
1927
|
+
}, wt = {
|
|
1911
1928
|
16: "shiftKey",
|
|
1912
1929
|
18: "altKey",
|
|
1913
1930
|
17: "ctrlKey",
|
|
@@ -1916,16 +1933,16 @@ const lt = {
|
|
|
1916
1933
|
ctrlKey: 17,
|
|
1917
1934
|
altKey: 18,
|
|
1918
1935
|
metaKey: 91
|
|
1919
|
-
},
|
|
1936
|
+
}, X = {
|
|
1920
1937
|
16: !1,
|
|
1921
1938
|
18: !1,
|
|
1922
1939
|
17: !1,
|
|
1923
1940
|
91: !1
|
|
1924
|
-
},
|
|
1941
|
+
}, N = {};
|
|
1925
1942
|
for (let t = 1; t < 20; t++)
|
|
1926
1943
|
lt["f".concat(t)] = 111 + t;
|
|
1927
|
-
let
|
|
1928
|
-
const
|
|
1944
|
+
let _ = [], ct = null, we = "all";
|
|
1945
|
+
const W = /* @__PURE__ */ new Map(), ut = (t) => lt[t.toLowerCase()] || z[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), so = (t) => Object.keys(lt).find((e) => lt[e] === t), ro = (t) => Object.keys(z).find((e) => z[e] === t);
|
|
1929
1946
|
function Ae(t) {
|
|
1930
1947
|
we = t || "all";
|
|
1931
1948
|
}
|
|
@@ -1933,15 +1950,15 @@ function dt() {
|
|
|
1933
1950
|
return we || "all";
|
|
1934
1951
|
}
|
|
1935
1952
|
function ao() {
|
|
1936
|
-
return
|
|
1953
|
+
return _.slice(0);
|
|
1937
1954
|
}
|
|
1938
1955
|
function co() {
|
|
1939
|
-
return
|
|
1956
|
+
return _.map((t) => so(t) || ro(t) || String.fromCharCode(t));
|
|
1940
1957
|
}
|
|
1941
1958
|
function lo() {
|
|
1942
1959
|
const t = [];
|
|
1943
|
-
return Object.keys(
|
|
1944
|
-
|
|
1960
|
+
return Object.keys(N).forEach((e) => {
|
|
1961
|
+
N[e].forEach((n) => {
|
|
1945
1962
|
let {
|
|
1946
1963
|
key: o,
|
|
1947
1964
|
scope: i,
|
|
@@ -1966,14 +1983,14 @@ function uo(t) {
|
|
|
1966
1983
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
|
|
1967
1984
|
}
|
|
1968
1985
|
function fo(t) {
|
|
1969
|
-
return typeof t == "string" && (t = ut(t)),
|
|
1986
|
+
return typeof t == "string" && (t = ut(t)), _.indexOf(t) !== -1;
|
|
1970
1987
|
}
|
|
1971
1988
|
function ho(t, e) {
|
|
1972
1989
|
let n, o;
|
|
1973
1990
|
t || (t = dt());
|
|
1974
|
-
for (const i in
|
|
1975
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
1976
|
-
for (n =
|
|
1991
|
+
for (const i in N)
|
|
1992
|
+
if (Object.prototype.hasOwnProperty.call(N, i))
|
|
1993
|
+
for (n = N[i], o = 0; o < n.length; )
|
|
1977
1994
|
n[o].scope === t ? n.splice(o, 1).forEach((a) => {
|
|
1978
1995
|
let {
|
|
1979
1996
|
element: r
|
|
@@ -1982,30 +1999,30 @@ function ho(t, e) {
|
|
|
1982
1999
|
}) : o++;
|
|
1983
2000
|
dt() === t && Ae(e || "all");
|
|
1984
2001
|
}
|
|
1985
|
-
function
|
|
2002
|
+
function po(t) {
|
|
1986
2003
|
let e = t.keyCode || t.which || t.charCode;
|
|
1987
|
-
const n =
|
|
1988
|
-
if (n >= 0 &&
|
|
1989
|
-
|
|
1990
|
-
for (const o in
|
|
2004
|
+
const n = _.indexOf(e);
|
|
2005
|
+
if (n >= 0 && _.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && _.splice(0, _.length), (e === 93 || e === 224) && (e = 91), e in X) {
|
|
2006
|
+
X[e] = !1;
|
|
2007
|
+
for (const o in z) z[o] === e && (H[o] = !1);
|
|
1991
2008
|
}
|
|
1992
2009
|
}
|
|
1993
2010
|
function xe(t) {
|
|
1994
2011
|
if (typeof t > "u")
|
|
1995
|
-
Object.keys(
|
|
1996
|
-
Array.isArray(
|
|
2012
|
+
Object.keys(N).forEach((i) => {
|
|
2013
|
+
Array.isArray(N[i]) && N[i].forEach((s) => bt(s)), delete N[i];
|
|
1997
2014
|
}), Xt(null);
|
|
1998
2015
|
else if (Array.isArray(t))
|
|
1999
2016
|
t.forEach((i) => {
|
|
2000
|
-
i.key &&
|
|
2017
|
+
i.key && bt(i);
|
|
2001
2018
|
});
|
|
2002
2019
|
else if (typeof t == "object")
|
|
2003
|
-
t.key &&
|
|
2020
|
+
t.key && bt(t);
|
|
2004
2021
|
else if (typeof t == "string") {
|
|
2005
2022
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
2006
2023
|
n[o - 1] = arguments[o];
|
|
2007
2024
|
let [i, s] = n;
|
|
2008
|
-
typeof i == "function" && (s = i, i = ""),
|
|
2025
|
+
typeof i == "function" && (s = i, i = ""), bt({
|
|
2009
2026
|
key: t,
|
|
2010
2027
|
scope: i,
|
|
2011
2028
|
method: s,
|
|
@@ -2013,7 +2030,7 @@ function xe(t) {
|
|
|
2013
2030
|
});
|
|
2014
2031
|
}
|
|
2015
2032
|
}
|
|
2016
|
-
const
|
|
2033
|
+
const bt = (t) => {
|
|
2017
2034
|
let {
|
|
2018
2035
|
key: e,
|
|
2019
2036
|
scope: n,
|
|
@@ -2021,14 +2038,14 @@ const yt = (t) => {
|
|
|
2021
2038
|
splitKey: i = "+"
|
|
2022
2039
|
} = t;
|
|
2023
2040
|
be(e).forEach((a) => {
|
|
2024
|
-
const r = a.split(i),
|
|
2025
|
-
if (!
|
|
2041
|
+
const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ut(f);
|
|
2042
|
+
if (!N[h]) return;
|
|
2026
2043
|
n || (n = dt());
|
|
2027
|
-
const u =
|
|
2028
|
-
|
|
2029
|
-
const
|
|
2030
|
-
return
|
|
2031
|
-
}),
|
|
2044
|
+
const u = l > 1 ? ye(z, r) : [], p = [];
|
|
2045
|
+
N[h] = N[h].filter((v) => {
|
|
2046
|
+
const m = (o ? v.method === o : !0) && v.scope === n && io(v.mods, u);
|
|
2047
|
+
return m && p.push(v.element), !m;
|
|
2048
|
+
}), p.forEach((v) => Xt(v));
|
|
2032
2049
|
});
|
|
2033
2050
|
};
|
|
2034
2051
|
function ne(t, e, n, o) {
|
|
@@ -2037,50 +2054,50 @@ function ne(t, e, n, o) {
|
|
|
2037
2054
|
let i;
|
|
2038
2055
|
if (e.scope === n || e.scope === "all") {
|
|
2039
2056
|
i = e.mods.length > 0;
|
|
2040
|
-
for (const s in
|
|
2041
|
-
Object.prototype.hasOwnProperty.call(
|
|
2042
|
-
(e.mods.length === 0 && !
|
|
2057
|
+
for (const s in X)
|
|
2058
|
+
Object.prototype.hasOwnProperty.call(X, s) && (!X[s] && e.mods.indexOf(+s) > -1 || X[s] && e.mods.indexOf(+s) === -1) && (i = !1);
|
|
2059
|
+
(e.mods.length === 0 && !X[16] && !X[18] && !X[17] && !X[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(_), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2043
2060
|
}
|
|
2044
2061
|
}
|
|
2045
2062
|
function oe(t, e) {
|
|
2046
|
-
const n =
|
|
2063
|
+
const n = N["*"];
|
|
2047
2064
|
let o = t.keyCode || t.which || t.charCode;
|
|
2048
|
-
if (!
|
|
2049
|
-
if ((o === 93 || o === 224) && (o = 91),
|
|
2050
|
-
const
|
|
2051
|
-
t[r] &&
|
|
2052
|
-
}), o in
|
|
2053
|
-
|
|
2054
|
-
for (const r in
|
|
2055
|
-
|
|
2065
|
+
if (!H.filter.call(this, t)) return;
|
|
2066
|
+
if ((o === 93 || o === 224) && (o = 91), _.indexOf(o) === -1 && o !== 229 && _.push(o), ["metaKey", "ctrlKey", "altKey", "shiftKey"].forEach((r) => {
|
|
2067
|
+
const l = wt[r];
|
|
2068
|
+
t[r] && _.indexOf(l) === -1 ? _.push(l) : !t[r] && _.indexOf(l) > -1 ? _.splice(_.indexOf(l), 1) : r === "metaKey" && t[r] && (_ = _.filter((f) => f in wt || f === o));
|
|
2069
|
+
}), o in X) {
|
|
2070
|
+
X[o] = !0;
|
|
2071
|
+
for (const r in z)
|
|
2072
|
+
z[r] === o && (H[r] = !0);
|
|
2056
2073
|
if (!n) return;
|
|
2057
2074
|
}
|
|
2058
|
-
for (const r in
|
|
2059
|
-
Object.prototype.hasOwnProperty.call(
|
|
2060
|
-
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (
|
|
2075
|
+
for (const r in X)
|
|
2076
|
+
Object.prototype.hasOwnProperty.call(X, r) && (X[r] = t[wt[r]]);
|
|
2077
|
+
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (_.indexOf(17) === -1 && _.push(17), _.indexOf(18) === -1 && _.push(18), X[17] = !0, X[18] = !0);
|
|
2061
2078
|
const i = dt();
|
|
2062
2079
|
if (n)
|
|
2063
2080
|
for (let r = 0; r < n.length; r++)
|
|
2064
2081
|
n[r].scope === i && (t.type === "keydown" && n[r].keydown || t.type === "keyup" && n[r].keyup) && ne(t, n[r], i, e);
|
|
2065
|
-
if (!(o in
|
|
2066
|
-
const s =
|
|
2082
|
+
if (!(o in N)) return;
|
|
2083
|
+
const s = N[o], a = s.length;
|
|
2067
2084
|
for (let r = 0; r < a; r++)
|
|
2068
2085
|
if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
|
|
2069
|
-
const
|
|
2086
|
+
const l = s[r], {
|
|
2070
2087
|
splitKey: f
|
|
2071
|
-
} =
|
|
2072
|
-
for (let
|
|
2073
|
-
u.push(ut(h[
|
|
2074
|
-
u.sort().join("") ===
|
|
2088
|
+
} = l, h = l.key.split(f), u = [];
|
|
2089
|
+
for (let p = 0; p < h.length; p++)
|
|
2090
|
+
u.push(ut(h[p]));
|
|
2091
|
+
u.sort().join("") === _.sort().join("") && ne(t, l, i, e);
|
|
2075
2092
|
}
|
|
2076
2093
|
}
|
|
2077
|
-
function
|
|
2078
|
-
|
|
2094
|
+
function H(t, e, n) {
|
|
2095
|
+
_ = [];
|
|
2079
2096
|
const o = be(t);
|
|
2080
|
-
let i = [], s = "all", a = document, r = 0,
|
|
2081
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (
|
|
2082
|
-
t = o[r].split(h), i = [], t.length > 1 && (i = ye(
|
|
2083
|
-
keyup:
|
|
2097
|
+
let i = [], s = "all", a = document, r = 0, l = !1, f = !0, h = "+", u = !1, p = !1;
|
|
2098
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (s = e), p && xe(t, s); r < o.length; r++)
|
|
2099
|
+
t = o[r].split(h), i = [], t.length > 1 && (i = ye(z, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in N || (N[t] = []), N[t].push({
|
|
2100
|
+
keyup: l,
|
|
2084
2101
|
keydown: f,
|
|
2085
2102
|
scope: s,
|
|
2086
2103
|
mods: i,
|
|
@@ -2091,41 +2108,41 @@ function P(t, e, n) {
|
|
|
2091
2108
|
element: a
|
|
2092
2109
|
});
|
|
2093
2110
|
if (typeof a < "u" && window) {
|
|
2094
|
-
if (!
|
|
2111
|
+
if (!W.has(a)) {
|
|
2095
2112
|
const v = function() {
|
|
2096
|
-
let
|
|
2097
|
-
return oe(
|
|
2098
|
-
},
|
|
2099
|
-
let
|
|
2100
|
-
oe(
|
|
2113
|
+
let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2114
|
+
return oe(m, a);
|
|
2115
|
+
}, g = function() {
|
|
2116
|
+
let m = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2117
|
+
oe(m, a), po(m);
|
|
2101
2118
|
};
|
|
2102
|
-
|
|
2119
|
+
W.set(a, {
|
|
2103
2120
|
keydownListener: v,
|
|
2104
|
-
keyupListenr:
|
|
2121
|
+
keyupListenr: g,
|
|
2105
2122
|
capture: u
|
|
2106
|
-
}),
|
|
2123
|
+
}), Ut(a, "keydown", v, u), Ut(a, "keyup", g, u);
|
|
2107
2124
|
}
|
|
2108
2125
|
if (!ct) {
|
|
2109
2126
|
const v = () => {
|
|
2110
|
-
|
|
2127
|
+
_ = [];
|
|
2111
2128
|
};
|
|
2112
2129
|
ct = {
|
|
2113
2130
|
listener: v,
|
|
2114
2131
|
capture: u
|
|
2115
|
-
},
|
|
2132
|
+
}, Ut(window, "focus", v, u);
|
|
2116
2133
|
}
|
|
2117
2134
|
}
|
|
2118
2135
|
}
|
|
2119
|
-
function
|
|
2136
|
+
function go(t) {
|
|
2120
2137
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2121
|
-
Object.keys(
|
|
2122
|
-
|
|
2138
|
+
Object.keys(N).forEach((n) => {
|
|
2139
|
+
N[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
2123
2140
|
i && i.method && i.method();
|
|
2124
2141
|
});
|
|
2125
2142
|
});
|
|
2126
2143
|
}
|
|
2127
2144
|
function Xt(t) {
|
|
2128
|
-
const e = Object.values(
|
|
2145
|
+
const e = Object.values(N).flat();
|
|
2129
2146
|
if (e.findIndex((o) => {
|
|
2130
2147
|
let {
|
|
2131
2148
|
element: i
|
|
@@ -2136,17 +2153,17 @@ function Xt(t) {
|
|
|
2136
2153
|
keydownListener: o,
|
|
2137
2154
|
keyupListenr: i,
|
|
2138
2155
|
capture: s
|
|
2139
|
-
} =
|
|
2140
|
-
o && i && (ot(t, "keyup", i, s), ot(t, "keydown", o, s),
|
|
2156
|
+
} = W.get(t) || {};
|
|
2157
|
+
o && i && (ot(t, "keyup", i, s), ot(t, "keydown", o, s), W.delete(t));
|
|
2141
2158
|
}
|
|
2142
|
-
if ((e.length <= 0 ||
|
|
2159
|
+
if ((e.length <= 0 || W.size <= 0) && (Object.keys(W).forEach((i) => {
|
|
2143
2160
|
const {
|
|
2144
2161
|
keydownListener: s,
|
|
2145
2162
|
keyupListenr: a,
|
|
2146
2163
|
capture: r
|
|
2147
|
-
} =
|
|
2148
|
-
s && a && (ot(i, "keyup", a, r), ot(i, "keydown", s, r),
|
|
2149
|
-
}),
|
|
2164
|
+
} = W.get(i) || {};
|
|
2165
|
+
s && a && (ot(i, "keyup", a, r), ot(i, "keydown", s, r), W.delete(i));
|
|
2166
|
+
}), W.clear(), Object.keys(N).forEach((i) => delete N[i]), ct)) {
|
|
2150
2167
|
const {
|
|
2151
2168
|
listener: i,
|
|
2152
2169
|
capture: s
|
|
@@ -2154,7 +2171,7 @@ function Xt(t) {
|
|
|
2154
2171
|
ot(window, "focus", i, s), ct = null;
|
|
2155
2172
|
}
|
|
2156
2173
|
}
|
|
2157
|
-
const
|
|
2174
|
+
const _t = {
|
|
2158
2175
|
getPressedKeyString: co,
|
|
2159
2176
|
setScope: Ae,
|
|
2160
2177
|
getScope: dt,
|
|
@@ -2163,17 +2180,17 @@ const Nt = {
|
|
|
2163
2180
|
getAllKeyCodes: lo,
|
|
2164
2181
|
isPressed: fo,
|
|
2165
2182
|
filter: uo,
|
|
2166
|
-
trigger:
|
|
2183
|
+
trigger: go,
|
|
2167
2184
|
unbind: xe,
|
|
2168
2185
|
keyMap: lt,
|
|
2169
|
-
modifier:
|
|
2170
|
-
modifierMap:
|
|
2186
|
+
modifier: z,
|
|
2187
|
+
modifierMap: wt
|
|
2171
2188
|
};
|
|
2172
|
-
for (const t in
|
|
2173
|
-
Object.prototype.hasOwnProperty.call(
|
|
2189
|
+
for (const t in _t)
|
|
2190
|
+
Object.prototype.hasOwnProperty.call(_t, t) && (H[t] = _t[t]);
|
|
2174
2191
|
if (typeof window < "u") {
|
|
2175
2192
|
const t = window.hotkeys;
|
|
2176
|
-
|
|
2193
|
+
H.noConflict = (e) => (e && window.hotkeys === H && (window.hotkeys = t), H), window.hotkeys = H;
|
|
2177
2194
|
}
|
|
2178
2195
|
const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+a", mo = [
|
|
2179
2196
|
...ve.map((t) => `shift+${t}`),
|
|
@@ -2181,97 +2198,97 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2181
2198
|
], yo = (t, e, n) => {
|
|
2182
2199
|
let o;
|
|
2183
2200
|
const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (T) => o = T;
|
|
2184
|
-
let
|
|
2185
|
-
const f = (T) =>
|
|
2186
|
-
let
|
|
2187
|
-
const
|
|
2188
|
-
v !== !1 && (
|
|
2201
|
+
let l;
|
|
2202
|
+
const f = (T) => l = T, { store: h, selection: u } = e;
|
|
2203
|
+
let p, v, g;
|
|
2204
|
+
const m = (T) => {
|
|
2205
|
+
v !== !1 && (p = it(T.target) ? void 0 : {
|
|
2189
2206
|
annotation: fe(),
|
|
2190
2207
|
selector: [],
|
|
2191
2208
|
creator: o,
|
|
2192
2209
|
created: /* @__PURE__ */ new Date()
|
|
2193
2210
|
});
|
|
2194
|
-
},
|
|
2195
|
-
const
|
|
2196
|
-
if (!(
|
|
2211
|
+
}, A = Dt((T) => {
|
|
2212
|
+
const I = document.getSelection();
|
|
2213
|
+
if (!(I != null && I.anchorNode))
|
|
2197
2214
|
return;
|
|
2198
|
-
if (it(
|
|
2199
|
-
|
|
2215
|
+
if (it(I.anchorNode)) {
|
|
2216
|
+
p = void 0;
|
|
2200
2217
|
return;
|
|
2201
2218
|
}
|
|
2202
|
-
const
|
|
2203
|
-
if ((
|
|
2204
|
-
if (
|
|
2205
|
-
h.getAnnotation(
|
|
2219
|
+
const D = T.timeStamp - ((g == null ? void 0 : g.timeStamp) || T.timeStamp);
|
|
2220
|
+
if ((g == null ? void 0 : g.type) === "pointerdown" && (D < 1e3 && !p || I.isCollapsed && D < ie) && m(g || T), !p) return;
|
|
2221
|
+
if (I.isCollapsed) {
|
|
2222
|
+
h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
|
|
2206
2223
|
return;
|
|
2207
2224
|
}
|
|
2208
|
-
const
|
|
2209
|
-
if (Ie(
|
|
2210
|
-
const
|
|
2211
|
-
(
|
|
2212
|
-
var
|
|
2213
|
-
return
|
|
2214
|
-
})) && (
|
|
2215
|
-
...
|
|
2216
|
-
selector:
|
|
2225
|
+
const y = I.getRangeAt(0), x = De(y, t);
|
|
2226
|
+
if (Ie(x)) return;
|
|
2227
|
+
const w = Me(x.cloneRange());
|
|
2228
|
+
(w.length !== p.selector.length || w.some((B, O) => {
|
|
2229
|
+
var U;
|
|
2230
|
+
return B.toString() !== ((U = p.selector[O]) == null ? void 0 : U.quote);
|
|
2231
|
+
})) && (p = {
|
|
2232
|
+
...p,
|
|
2233
|
+
selector: w.map((B) => Ve(B, t, s)),
|
|
2217
2234
|
updated: /* @__PURE__ */ new Date()
|
|
2218
|
-
}, h.getAnnotation(
|
|
2219
|
-
}),
|
|
2220
|
-
it(T.target) || (
|
|
2235
|
+
}, h.getAnnotation(p.annotation) ? h.updateTarget(p, k.LOCAL) : u.clear());
|
|
2236
|
+
}), d = (T) => {
|
|
2237
|
+
it(T.target) || (g = vt(T), v = g.button === 0);
|
|
2221
2238
|
}, c = (T) => {
|
|
2222
2239
|
if (it(T.target) || !v) return;
|
|
2223
|
-
const
|
|
2224
|
-
const { x:
|
|
2225
|
-
if (
|
|
2226
|
-
const { selected:
|
|
2227
|
-
(
|
|
2240
|
+
const I = () => {
|
|
2241
|
+
const { x: y, y: x } = t.getBoundingClientRect(), w = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - y, T.clientY - x, a === "all", l);
|
|
2242
|
+
if (w) {
|
|
2243
|
+
const { selected: L } = u, B = new Set(L.map((P) => P.id)), O = Array.isArray(w) ? w.map((P) => P.id) : [w.id];
|
|
2244
|
+
(B.size !== O.length || !O.every((P) => B.has(P))) && u.userSelect(O, T);
|
|
2228
2245
|
} else
|
|
2229
2246
|
u.clear();
|
|
2230
|
-
},
|
|
2247
|
+
}, D = T.timeStamp - g.timeStamp;
|
|
2231
2248
|
setTimeout(() => {
|
|
2232
|
-
const
|
|
2233
|
-
|
|
2249
|
+
const y = document.getSelection();
|
|
2250
|
+
y != null && y.isCollapsed && D < ie ? (p = void 0, I()) : p && p.selector.length > 0 && (R(), u.userSelect(p.annotation, vt(T)));
|
|
2234
2251
|
});
|
|
2235
2252
|
}, b = (T) => {
|
|
2236
|
-
const
|
|
2237
|
-
|
|
2253
|
+
const I = document.getSelection();
|
|
2254
|
+
I != null && I.isCollapsed || ((!p || p.selector.length === 0) && A(T), R(), u.userSelect(p.annotation, vt(T)));
|
|
2238
2255
|
}, S = (T) => {
|
|
2239
|
-
T.key === "Shift" &&
|
|
2256
|
+
T.key === "Shift" && p && (document.getSelection().isCollapsed || (R(), u.userSelect(p.annotation, ft(T))));
|
|
2240
2257
|
}, E = (T) => {
|
|
2241
|
-
const
|
|
2242
|
-
(
|
|
2243
|
-
id:
|
|
2258
|
+
const I = () => setTimeout(() => {
|
|
2259
|
+
(p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
|
|
2260
|
+
id: p.annotation,
|
|
2244
2261
|
bodies: [],
|
|
2245
|
-
target:
|
|
2246
|
-
}), u.userSelect(
|
|
2262
|
+
target: p
|
|
2263
|
+
}), u.userSelect(p.annotation, ft(T))), document.removeEventListener("selectionchange", I);
|
|
2247
2264
|
}, 100);
|
|
2248
|
-
document.addEventListener("selectionchange",
|
|
2265
|
+
document.addEventListener("selectionchange", I), m(T);
|
|
2249
2266
|
};
|
|
2250
|
-
|
|
2251
|
-
T.repeat || (
|
|
2252
|
-
}),
|
|
2253
|
-
|
|
2267
|
+
H(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
|
|
2268
|
+
T.repeat || (g = ft(T));
|
|
2269
|
+
}), H(Ee, { keydown: !0, keyup: !1 }, (T) => {
|
|
2270
|
+
g = ft(T), E(T);
|
|
2254
2271
|
});
|
|
2255
2272
|
const C = (T) => {
|
|
2256
|
-
T.repeat || T.target !== t && T.target !== document.body || (
|
|
2273
|
+
T.repeat || T.target !== t && T.target !== document.body || (p = void 0, u.clear());
|
|
2257
2274
|
};
|
|
2258
|
-
|
|
2259
|
-
const
|
|
2260
|
-
const T = h.getAnnotation(
|
|
2275
|
+
H(ve.join(","), { keydown: !0, keyup: !1 }, C);
|
|
2276
|
+
const R = () => {
|
|
2277
|
+
const T = h.getAnnotation(p.annotation);
|
|
2261
2278
|
if (!T) {
|
|
2262
2279
|
h.addAnnotation({
|
|
2263
|
-
id:
|
|
2280
|
+
id: p.annotation,
|
|
2264
2281
|
bodies: [],
|
|
2265
|
-
target:
|
|
2282
|
+
target: p
|
|
2266
2283
|
});
|
|
2267
2284
|
return;
|
|
2268
2285
|
}
|
|
2269
|
-
const { target: { updated:
|
|
2270
|
-
(!
|
|
2286
|
+
const { target: { updated: I } } = T, { updated: D } = p;
|
|
2287
|
+
(!I || !D || I < D) && h.updateTarget(p);
|
|
2271
2288
|
};
|
|
2272
|
-
return t.addEventListener("pointerdown",
|
|
2289
|
+
return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", b), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", A)), {
|
|
2273
2290
|
destroy: () => {
|
|
2274
|
-
t.removeEventListener("pointerdown",
|
|
2291
|
+
t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", b), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", A), H.unbind();
|
|
2275
2292
|
},
|
|
2276
2293
|
setFilter: f,
|
|
2277
2294
|
setUser: r
|
|
@@ -2284,27 +2301,27 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2284
2301
|
Le(t), Oe(t);
|
|
2285
2302
|
const n = bo(e, {
|
|
2286
2303
|
annotatingEnabled: !0,
|
|
2287
|
-
user:
|
|
2288
|
-
}), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r =
|
|
2304
|
+
user: Yn()
|
|
2305
|
+
}), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Rn(a), l = Bn(o, r, n.adapter);
|
|
2289
2306
|
let f = n.user;
|
|
2290
2307
|
const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : se : n.renderer || se, u = h === "SPANS" ? rn(t, o, s) : h === "CSS_HIGHLIGHTS" ? nn(t, o, s) : h === "CANVAS" ? ze(t, o, s) : void 0;
|
|
2291
2308
|
if (!u)
|
|
2292
2309
|
throw `Unknown renderer implementation: ${h}`;
|
|
2293
2310
|
console.debug(`Using ${h} renderer`), n.style && u.setStyle(n.style);
|
|
2294
|
-
const
|
|
2295
|
-
return
|
|
2311
|
+
const p = yo(t, o, n);
|
|
2312
|
+
return p.setUser(f), {
|
|
2296
2313
|
...In(o, r, n.adapter),
|
|
2297
2314
|
destroy: () => {
|
|
2298
|
-
u.destroy(),
|
|
2315
|
+
u.destroy(), p.destroy(), r.destroy();
|
|
2299
2316
|
},
|
|
2300
2317
|
element: t,
|
|
2301
2318
|
getUser: () => f,
|
|
2302
2319
|
setFilter: (C) => {
|
|
2303
|
-
u.setFilter(C),
|
|
2320
|
+
u.setFilter(C), p.setFilter(C);
|
|
2304
2321
|
},
|
|
2305
2322
|
setStyle: (C) => u.setStyle(C),
|
|
2306
2323
|
setUser: (C) => {
|
|
2307
|
-
f = C,
|
|
2324
|
+
f = C, p.setUser(C);
|
|
2308
2325
|
},
|
|
2309
2326
|
setSelected: (C) => {
|
|
2310
2327
|
C ? i.setSelected(C) : i.clear();
|
|
@@ -2313,24 +2330,24 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
|
|
|
2313
2330
|
C && (u.setPainter(oo(C, n.presence)), C.on("selectionChange", () => u.redraw()));
|
|
2314
2331
|
},
|
|
2315
2332
|
setVisible: (C) => u.setVisible(C),
|
|
2316
|
-
on:
|
|
2317
|
-
off:
|
|
2318
|
-
scrollIntoView:
|
|
2333
|
+
on: l.on,
|
|
2334
|
+
off: l.off,
|
|
2335
|
+
scrollIntoView: Ye(t, a),
|
|
2319
2336
|
state: o
|
|
2320
2337
|
};
|
|
2321
2338
|
};
|
|
2322
2339
|
export {
|
|
2323
|
-
|
|
2324
|
-
|
|
2340
|
+
xt as DEFAULT_SELECTED_STYLE,
|
|
2341
|
+
G as DEFAULT_STYLE,
|
|
2325
2342
|
re as NOT_ANNOTATABLE_CLASS,
|
|
2326
|
-
|
|
2343
|
+
et as NOT_ANNOTATABLE_SELECTOR,
|
|
2327
2344
|
k as Origin,
|
|
2328
2345
|
yo as SelectionHandler,
|
|
2329
2346
|
hn as UserSelectAction,
|
|
2330
2347
|
xo as W3CTextFormat,
|
|
2331
2348
|
Le as cancelSingleClickEvents,
|
|
2332
2349
|
ft as cloneKeyboardEvent,
|
|
2333
|
-
|
|
2350
|
+
vt as clonePointerEvent,
|
|
2334
2351
|
Ao as createBody,
|
|
2335
2352
|
ze as createCanvasRenderer,
|
|
2336
2353
|
nn as createHighlightsRenderer,
|
|
@@ -2339,28 +2356,28 @@ export {
|
|
|
2339
2356
|
rn as createSpansRenderer,
|
|
2340
2357
|
vo as createTextAnnotator,
|
|
2341
2358
|
eo as createTextAnnotatorState,
|
|
2342
|
-
|
|
2359
|
+
Dt as debounce,
|
|
2343
2360
|
bo as fillDefaults,
|
|
2344
|
-
|
|
2345
|
-
|
|
2361
|
+
Be as getQuoteContext,
|
|
2362
|
+
Nt as getRangeAnnotatableContents,
|
|
2346
2363
|
Te as isMac,
|
|
2347
2364
|
it as isNotAnnotatable,
|
|
2348
2365
|
Ce as isRangeAnnotatable,
|
|
2349
|
-
|
|
2366
|
+
q as isRevived,
|
|
2350
2367
|
Ie as isWhitespaceOrEmpty,
|
|
2351
|
-
|
|
2368
|
+
Ne as mergeClientRects,
|
|
2352
2369
|
Ke as paint,
|
|
2353
2370
|
jn as parseW3CTextAnnotation,
|
|
2354
2371
|
Oe as programmaticallyFocusable,
|
|
2355
2372
|
Ve as rangeToSelector,
|
|
2356
|
-
|
|
2373
|
+
Et as reviveAnnotation,
|
|
2357
2374
|
ae as reviveSelector,
|
|
2358
|
-
|
|
2359
|
-
|
|
2375
|
+
At as reviveTarget,
|
|
2376
|
+
Ye as scrollIntoView,
|
|
2360
2377
|
zn as serializeW3CTextAnnotation,
|
|
2361
2378
|
Me as splitAnnotatableRanges,
|
|
2362
2379
|
wo as toDomRectList,
|
|
2363
|
-
|
|
2380
|
+
De as trimRangeToContainer,
|
|
2364
2381
|
ke as whitespaceOrEmptyRegex
|
|
2365
2382
|
};
|
|
2366
2383
|
//# sourceMappingURL=text-annotator.es.js.map
|