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