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