@soomo/text-annotator 3.1.0-staging.0 → 3.1.0-staging.2
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,8 +1,8 @@
|
|
|
1
|
-
const de = "not-annotatable", j = `.${de}`,
|
|
1
|
+
const de = "not-annotatable", j = `.${de}`, Me = (t) => {
|
|
2
2
|
var n;
|
|
3
3
|
const e = t.commonAncestorContainer;
|
|
4
4
|
return e instanceof HTMLElement ? !e.closest(j) : !((n = e.parentElement) != null && n.closest(j));
|
|
5
|
-
},
|
|
5
|
+
}, Be = function* (t) {
|
|
6
6
|
const e = document.createNodeIterator(
|
|
7
7
|
t.commonAncestorContainer,
|
|
8
8
|
NodeFilter.SHOW_ELEMENT,
|
|
@@ -11,11 +11,11 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
11
11
|
let n;
|
|
12
12
|
for (; n = e.nextNode(); )
|
|
13
13
|
n instanceof HTMLElement && (yield n);
|
|
14
|
-
},
|
|
15
|
-
if (!
|
|
14
|
+
}, ke = (t) => {
|
|
15
|
+
if (!Me(t)) return [];
|
|
16
16
|
const e = [];
|
|
17
17
|
let n = null;
|
|
18
|
-
for (const o of
|
|
18
|
+
for (const o of Be(t)) {
|
|
19
19
|
let i;
|
|
20
20
|
n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
|
|
21
21
|
}
|
|
@@ -27,15 +27,15 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
27
27
|
}, Dt = (t) => {
|
|
28
28
|
const e = t.cloneContents();
|
|
29
29
|
return e.querySelectorAll(j).forEach((n) => n.remove()), e;
|
|
30
|
-
},
|
|
30
|
+
}, Ie = (t) => t.addEventListener("click", (e) => {
|
|
31
31
|
// Allow clicks within not-annotatable elements
|
|
32
32
|
!e.target.closest(j) && !e.target.closest("a") && e.preventDefault();
|
|
33
|
-
}),
|
|
33
|
+
}), _e = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Ne = (t) => {
|
|
34
34
|
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
35
|
-
},
|
|
35
|
+
}, Ro = (t) => {
|
|
36
36
|
const e = t.cloneContents();
|
|
37
37
|
return e.querySelectorAll(j).forEach((n) => n.remove()), e;
|
|
38
|
-
},
|
|
38
|
+
}, Ue = (t, e, n = 10, o) => {
|
|
39
39
|
const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
|
|
40
40
|
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
41
41
|
const r = Dt(s).textContent, a = document.createRange();
|
|
@@ -45,7 +45,7 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
45
45
|
prefix: r.substring(r.length - n),
|
|
46
46
|
suffix: d.substring(0, n)
|
|
47
47
|
};
|
|
48
|
-
},
|
|
48
|
+
}, De = /^\s*$/, Ve = (t) => De.test(t.toString()), W = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Ke = (t, e) => {
|
|
49
49
|
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
50
50
|
top: n(t.top),
|
|
51
51
|
bottom: n(t.bottom),
|
|
@@ -69,17 +69,17 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
69
69
|
return "block-contains";
|
|
70
70
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
71
71
|
return "block-is-contained";
|
|
72
|
-
},
|
|
72
|
+
}, Ye = (t, e) => {
|
|
73
73
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
|
|
74
74
|
return new DOMRect(n, i, o - n, s - i);
|
|
75
|
-
},
|
|
75
|
+
}, Xe = (t) => t.reduce((e, n) => {
|
|
76
76
|
if (n.width === 0 || n.height === 0)
|
|
77
77
|
return e;
|
|
78
78
|
let o = [...e], i = !1;
|
|
79
79
|
for (const s of e) {
|
|
80
|
-
const r =
|
|
80
|
+
const r = Ke(n, s);
|
|
81
81
|
if (r === "inline-adjacent") {
|
|
82
|
-
o = o.map((a) => a === s ?
|
|
82
|
+
o = o.map((a) => a === s ? Ye(n, s) : a), i = !0;
|
|
83
83
|
break;
|
|
84
84
|
} else if (r === "inline-contains") {
|
|
85
85
|
o = o.map((a) => a === s ? n : a), i = !0;
|
|
@@ -93,14 +93,14 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
return i ? o : [...o, n];
|
|
96
|
-
}, []),
|
|
96
|
+
}, []), Mo = (t) => ({
|
|
97
97
|
length: t.length,
|
|
98
98
|
item: (e) => t[e],
|
|
99
99
|
[Symbol.iterator]: function* () {
|
|
100
100
|
for (let e = 0; e < this.length; e++)
|
|
101
101
|
yield this.item(e);
|
|
102
102
|
}
|
|
103
|
-
}),
|
|
103
|
+
}), $e = (t, e, n) => {
|
|
104
104
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
105
105
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
106
106
|
const s = Dt(o).textContent, r = t.toString(), a = s.length || 0, d = a + r.length;
|
|
@@ -110,9 +110,9 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
110
110
|
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
111
111
|
e,
|
|
112
112
|
NodeFilter.SHOW_TEXT,
|
|
113
|
-
(
|
|
113
|
+
(p) => {
|
|
114
114
|
var h;
|
|
115
|
-
return (h =
|
|
115
|
+
return (h = p.parentElement) != null && h.closest(j) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
116
116
|
}
|
|
117
117
|
);
|
|
118
118
|
let r = 0;
|
|
@@ -122,22 +122,22 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
122
122
|
let c = !i;
|
|
123
123
|
for (; d !== null; ) {
|
|
124
124
|
if (c || (c = i == null ? void 0 : i.contains(d)), c) {
|
|
125
|
-
const
|
|
126
|
-
if (r +
|
|
125
|
+
const p = ((f = d.textContent) == null ? void 0 : f.length) || 0;
|
|
126
|
+
if (r + p > n) {
|
|
127
127
|
a.setStart(d, n - r);
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
|
-
r +=
|
|
130
|
+
r += p;
|
|
131
131
|
}
|
|
132
132
|
d = s.nextNode();
|
|
133
133
|
}
|
|
134
134
|
for (; d !== null; ) {
|
|
135
|
-
const
|
|
136
|
-
if (r +
|
|
135
|
+
const p = ((l = d.textContent) == null ? void 0 : l.length) || 0;
|
|
136
|
+
if (r + p >= o) {
|
|
137
137
|
a.setEnd(d, o - r);
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
|
-
r +=
|
|
140
|
+
r += p, d = s.nextNode();
|
|
141
141
|
}
|
|
142
142
|
return {
|
|
143
143
|
...t,
|
|
@@ -146,9 +146,19 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
146
146
|
}, wt = (t, e) => W(t.selector) ? t : {
|
|
147
147
|
...t,
|
|
148
148
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ue(n, e))
|
|
149
|
-
}, xt = (t, e) => W(t.target.selector) ? t : { ...t, target: wt(t.target, e) },
|
|
149
|
+
}, xt = (t, e) => W(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, fe = (t, e) => {
|
|
150
|
+
if (t.isEqualNode(e))
|
|
151
|
+
return !0;
|
|
152
|
+
for (let n of t.childNodes)
|
|
153
|
+
if (fe(n, e))
|
|
154
|
+
return !0;
|
|
155
|
+
return !1;
|
|
156
|
+
}, Pe = (t, e) => {
|
|
157
|
+
const n = t.cloneContents();
|
|
158
|
+
return fe(n, e);
|
|
159
|
+
}, je = (t, e) => {
|
|
150
160
|
const n = t.cloneRange(), o = e.contains(n.startContainer), i = e.contains(n.endContainer);
|
|
151
|
-
return !o && !i ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
|
|
161
|
+
return !o && !i && !Pe(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
|
|
152
162
|
}, Et = (t) => ({
|
|
153
163
|
...t,
|
|
154
164
|
type: t.type,
|
|
@@ -191,22 +201,22 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
191
201
|
defaultPrevented: t.defaultPrevented,
|
|
192
202
|
detail: t.detail,
|
|
193
203
|
timeStamp: t.timeStamp
|
|
194
|
-
}),
|
|
204
|
+
}), He = (t, e) => {
|
|
195
205
|
const { left: n, top: o, right: i, bottom: s } = t;
|
|
196
206
|
return new DOMRect(n - e.left, o - e.top, i - n, s - o);
|
|
197
|
-
},
|
|
207
|
+
}, Bo = (t, e) => {
|
|
198
208
|
const { left: n, top: o, right: i, bottom: s } = t;
|
|
199
209
|
return new DOMRect(n + e.left, o + e.top, i - n, s - o);
|
|
200
|
-
},
|
|
210
|
+
}, he = (t) => {
|
|
201
211
|
if (t === null)
|
|
202
212
|
return document.scrollingElement;
|
|
203
213
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
204
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
205
|
-
},
|
|
214
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : he(t.parentElement);
|
|
215
|
+
}, ze = (t, e) => (n) => {
|
|
206
216
|
const o = typeof n == "string" ? n : n.id, i = (r) => {
|
|
207
|
-
const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: l, height:
|
|
217
|
+
const a = s.getBoundingClientRect(), d = s.clientHeight, c = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: l, height: p } = e.getAnnotationBounds(o), h = f.top - a.top, v = f.left - a.left, b = s.parentElement ? s.scrollTop : 0, E = s.parentElement ? s.scrollLeft : 0, m = h + b - (d - p) / 2, u = v + E - (c - l) / 2;
|
|
208
218
|
s.scroll({ top: m, left: u, behavior: "smooth" });
|
|
209
|
-
}, s =
|
|
219
|
+
}, s = he(t);
|
|
210
220
|
if (s) {
|
|
211
221
|
const r = e.getAnnotation(o), { range: a } = r.target.selector[0];
|
|
212
222
|
if (a && !a.collapsed)
|
|
@@ -224,16 +234,16 @@ const de = "not-annotatable", j = `.${de}`, Re = (t) => {
|
|
|
224
234
|
}, vt = {
|
|
225
235
|
fill: "rgb(0, 128, 255)",
|
|
226
236
|
fillOpacity: 0.45
|
|
227
|
-
},
|
|
237
|
+
}, Fe = (t, e, n, o, i) => {
|
|
228
238
|
var r, a;
|
|
229
239
|
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? vt : q) : n : (a = t.state) != null && a.selected ? vt : q;
|
|
230
240
|
return o && o.paint(t, e) || s;
|
|
231
241
|
};
|
|
232
|
-
function
|
|
242
|
+
function We(t) {
|
|
233
243
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
234
244
|
}
|
|
235
245
|
var Yt = { exports: {} };
|
|
236
|
-
function
|
|
246
|
+
function ge(t, e = 100, n = {}) {
|
|
237
247
|
if (typeof t != "function")
|
|
238
248
|
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
|
|
239
249
|
if (e < 0)
|
|
@@ -241,17 +251,17 @@ function he(t, e = 100, n = {}) {
|
|
|
241
251
|
const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
|
|
242
252
|
let i, s, r, a, d;
|
|
243
253
|
function c() {
|
|
244
|
-
const
|
|
245
|
-
return i = void 0, s = void 0, d = t.apply(
|
|
254
|
+
const p = i, h = s;
|
|
255
|
+
return i = void 0, s = void 0, d = t.apply(p, h), d;
|
|
246
256
|
}
|
|
247
257
|
function f() {
|
|
248
|
-
const
|
|
249
|
-
|
|
258
|
+
const p = Date.now() - a;
|
|
259
|
+
p < e && p >= 0 ? r = setTimeout(f, e - p) : (r = void 0, o || (d = c()));
|
|
250
260
|
}
|
|
251
|
-
const l = function(...
|
|
261
|
+
const l = function(...p) {
|
|
252
262
|
if (i && this !== i && Object.getPrototypeOf(this) === Object.getPrototypeOf(i))
|
|
253
263
|
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
254
|
-
i = this, s =
|
|
264
|
+
i = this, s = p, a = Date.now();
|
|
255
265
|
const h = o && !r;
|
|
256
266
|
return r || (r = setTimeout(f, e)), h && (d = c()), d;
|
|
257
267
|
};
|
|
@@ -263,13 +273,13 @@ function he(t, e = 100, n = {}) {
|
|
|
263
273
|
d = c(), l.clear();
|
|
264
274
|
}, l;
|
|
265
275
|
}
|
|
266
|
-
Yt.exports.debounce =
|
|
267
|
-
Yt.exports =
|
|
268
|
-
var
|
|
269
|
-
const Xt = /* @__PURE__ */
|
|
276
|
+
Yt.exports.debounce = ge;
|
|
277
|
+
Yt.exports = ge;
|
|
278
|
+
var qe = Yt.exports;
|
|
279
|
+
const Xt = /* @__PURE__ */ We(qe), Ge = (t) => {
|
|
270
280
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, d = i - e;
|
|
271
281
|
return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: d };
|
|
272
|
-
},
|
|
282
|
+
}, Qe = (t) => {
|
|
273
283
|
let e = /* @__PURE__ */ new Set();
|
|
274
284
|
return (o) => {
|
|
275
285
|
const i = o.map((s) => s.id);
|
|
@@ -278,59 +288,59 @@ const Xt = /* @__PURE__ */ ze(Fe), We = (t) => {
|
|
|
278
288
|
}, $t = (t, e, n, o) => {
|
|
279
289
|
const { store: i, selection: s, hover: r } = e;
|
|
280
290
|
let a, d, c;
|
|
281
|
-
const f =
|
|
282
|
-
const { x: S, y:
|
|
291
|
+
const f = Qe(n), l = (T) => {
|
|
292
|
+
const { x: S, y: g } = t.getBoundingClientRect(), w = i.getAt(T.clientX - S, T.clientY - g, d);
|
|
283
293
|
w ? r.current !== w.id && (t.classList.add("hovered"), r.set(w.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
|
|
284
294
|
};
|
|
285
295
|
t.addEventListener("pointermove", l);
|
|
286
|
-
const
|
|
296
|
+
const p = (T = !1) => {
|
|
287
297
|
c && c.clear();
|
|
288
|
-
const S =
|
|
298
|
+
const S = Ge(t), { minX: g, minY: w, maxX: x, maxY: O } = S, B = d ? i.getIntersecting(g, w, x, O).filter(({ annotation: N }) => d(N)) : i.getIntersecting(g, w, x, O), M = s.selected.map(({ id: N }) => N), D = B.map(({ annotation: N, rects: dt }) => {
|
|
289
299
|
const tt = M.includes(N.id), At = N.id === r.current;
|
|
290
300
|
return { annotation: N, rects: dt, state: { selected: tt, hover: At } };
|
|
291
301
|
});
|
|
292
302
|
o.redraw(D, S, a, c, T), setTimeout(() => f(B.map(({ annotation: N }) => N)), 1);
|
|
293
303
|
}, h = (T) => {
|
|
294
|
-
c = T,
|
|
304
|
+
c = T, p();
|
|
295
305
|
}, v = (T) => {
|
|
296
|
-
a = T,
|
|
306
|
+
a = T, p();
|
|
297
307
|
}, b = (T) => {
|
|
298
|
-
d = T,
|
|
299
|
-
}, E = () =>
|
|
308
|
+
d = T, p(!1);
|
|
309
|
+
}, E = () => p();
|
|
300
310
|
i.observe(E);
|
|
301
|
-
const m = s.subscribe(() =>
|
|
311
|
+
const m = s.subscribe(() => p()), u = () => p(!0);
|
|
302
312
|
document.addEventListener("scroll", u, { capture: !0, passive: !0 });
|
|
303
313
|
const y = Xt(() => {
|
|
304
|
-
i.recalculatePositions(), c == null || c.reset(),
|
|
314
|
+
i.recalculatePositions(), c == null || c.reset(), p();
|
|
305
315
|
}, 10);
|
|
306
316
|
window.addEventListener("resize", y);
|
|
307
317
|
const C = new ResizeObserver(y);
|
|
308
318
|
C.observe(t);
|
|
309
319
|
const A = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((T) => {
|
|
310
|
-
T.every((
|
|
320
|
+
T.every((g) => g.target === t || t.contains(g.target)) || p(!0);
|
|
311
321
|
});
|
|
312
322
|
return L.observe(document.body, A), {
|
|
313
323
|
destroy: () => {
|
|
314
324
|
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(E), m(), document.removeEventListener("scroll", u), y.clear(), window.removeEventListener("resize", y), C.disconnect(), L.disconnect();
|
|
315
325
|
},
|
|
316
|
-
redraw:
|
|
326
|
+
redraw: p,
|
|
317
327
|
setStyle: v,
|
|
318
328
|
setFilter: b,
|
|
319
329
|
setPainter: h,
|
|
320
330
|
setVisible: o.setVisible
|
|
321
331
|
};
|
|
322
|
-
},
|
|
332
|
+
}, Je = () => {
|
|
323
333
|
const t = document.createElement("canvas");
|
|
324
334
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
|
|
325
|
-
},
|
|
335
|
+
}, Ze = (t, e) => {
|
|
326
336
|
t.width = window.innerWidth, t.height = window.innerHeight;
|
|
327
|
-
},
|
|
337
|
+
}, tn = (t) => {
|
|
328
338
|
t.classList.add("r6o-annotatable");
|
|
329
|
-
const e =
|
|
339
|
+
const e = Je(), n = e.getContext("2d");
|
|
330
340
|
document.body.appendChild(e);
|
|
331
341
|
const o = (a, d, c, f) => requestAnimationFrame(() => {
|
|
332
|
-
const { width: l, height:
|
|
333
|
-
n.clearRect(-0.5, -0.5, l + 1,
|
|
342
|
+
const { width: l, height: p } = e;
|
|
343
|
+
n.clearRect(-0.5, -0.5, l + 1, p + 1), f && f.clear();
|
|
334
344
|
const { top: h, left: v } = d;
|
|
335
345
|
[...a].sort((E, m) => {
|
|
336
346
|
const { annotation: { target: { created: u } } } = E, { annotation: { target: { created: y } } } = m;
|
|
@@ -353,7 +363,7 @@ const Xt = /* @__PURE__ */ ze(Fe), We = (t) => {
|
|
|
353
363
|
});
|
|
354
364
|
}
|
|
355
365
|
});
|
|
356
|
-
}), i = Xt(() =>
|
|
366
|
+
}), i = Xt(() => Ze(e), 10);
|
|
357
367
|
return window.addEventListener("resize", i), {
|
|
358
368
|
destroy: () => {
|
|
359
369
|
e.remove(), i.clear(), window.removeEventListener("resize", i);
|
|
@@ -363,8 +373,8 @@ const Xt = /* @__PURE__ */ ze(Fe), We = (t) => {
|
|
|
363
373
|
},
|
|
364
374
|
redraw: o
|
|
365
375
|
};
|
|
366
|
-
},
|
|
367
|
-
var
|
|
376
|
+
}, en = (t, e, n) => $t(t, e, n, tn(t));
|
|
377
|
+
var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
368
378
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
369
379
|
}, U = function(t, e, n) {
|
|
370
380
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
@@ -376,13 +386,13 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
376
386
|
return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
|
|
377
387
|
}, St = function(t) {
|
|
378
388
|
return { r: U(t.r), g: U(t.g), b: U(t.b), a: U(t.a, 3) };
|
|
379
|
-
},
|
|
389
|
+
}, on = /^#([0-9a-f]{3,8})$/i, ft = function(t) {
|
|
380
390
|
var e = t.toString(16);
|
|
381
391
|
return e.length < 2 ? "0" + e : e;
|
|
382
|
-
},
|
|
392
|
+
}, me = function(t) {
|
|
383
393
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), r = s - Math.min(e, n, o), a = r ? s === e ? (n - o) / r : s === n ? 2 + (o - e) / r : 4 + (e - n) / r : 0;
|
|
384
394
|
return { h: 60 * (a < 0 ? a + 6 : a), s: s ? r / s * 100 : 0, v: s / 255 * 100, a: i };
|
|
385
|
-
},
|
|
395
|
+
}, ye = function(t) {
|
|
386
396
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
387
397
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
388
398
|
var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), c = s % 6;
|
|
@@ -392,21 +402,21 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
392
402
|
}, Wt = function(t) {
|
|
393
403
|
return { h: U(t.h), s: U(t.s), l: U(t.l), a: U(t.a, 3) };
|
|
394
404
|
}, qt = function(t) {
|
|
395
|
-
return
|
|
405
|
+
return ye((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 }));
|
|
396
406
|
var e, n, o;
|
|
397
407
|
}, st = function(t) {
|
|
398
|
-
return { h: (e =
|
|
408
|
+
return { h: (e = me(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 };
|
|
399
409
|
var e, n, o, i;
|
|
400
|
-
},
|
|
401
|
-
var e =
|
|
410
|
+
}, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Gt = { string: [[function(t) {
|
|
411
|
+
var e = on.exec(t);
|
|
402
412
|
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 ? U(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 ? U(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
403
413
|
}, "hex"], [function(t) {
|
|
404
|
-
var e =
|
|
414
|
+
var e = an.exec(t) || cn.exec(t);
|
|
405
415
|
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : zt({ 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;
|
|
406
416
|
}, "rgb"], [function(t) {
|
|
407
|
-
var e =
|
|
417
|
+
var e = sn.exec(t) || rn.exec(t);
|
|
408
418
|
if (!e) return null;
|
|
409
|
-
var n, o, i = Ft({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (
|
|
419
|
+
var n, o, i = Ft({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (nn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
410
420
|
return qt(i);
|
|
411
421
|
}, "hsl"]], object: [[function(t) {
|
|
412
422
|
var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
|
|
@@ -422,14 +432,14 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
422
432
|
var r = function(a) {
|
|
423
433
|
return { h: pe(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
|
|
424
434
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
|
|
425
|
-
return
|
|
435
|
+
return ye(r);
|
|
426
436
|
}, "hsv"]] }, Qt = function(t, e) {
|
|
427
437
|
for (var n = 0; n < e.length; n++) {
|
|
428
438
|
var o = e[n][0](t);
|
|
429
439
|
if (o) return [o, e[n][1]];
|
|
430
440
|
}
|
|
431
441
|
return [null, void 0];
|
|
432
|
-
},
|
|
442
|
+
}, ln = function(t) {
|
|
433
443
|
return typeof t == "string" ? Qt(t.trim(), Gt.string) : typeof t == "object" && t !== null ? Qt(t, Gt.object) : [null, void 0];
|
|
434
444
|
}, Ct = function(t, e) {
|
|
435
445
|
var n = st(t);
|
|
@@ -441,7 +451,7 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
441
451
|
return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
|
|
442
452
|
}, Zt = function() {
|
|
443
453
|
function t(e) {
|
|
444
|
-
this.parsed =
|
|
454
|
+
this.parsed = ln(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
445
455
|
}
|
|
446
456
|
return t.prototype.isValid = function() {
|
|
447
457
|
return this.parsed !== null;
|
|
@@ -465,7 +475,7 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
465
475
|
return e = Wt(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
466
476
|
var e, n, o, i, s;
|
|
467
477
|
}, t.prototype.toHsv = function() {
|
|
468
|
-
return e =
|
|
478
|
+
return e = me(this.rgba), { h: U(e.h), s: U(e.s), v: U(e.v), a: U(e.a, 3) };
|
|
469
479
|
var e;
|
|
470
480
|
}, t.prototype.invert = function() {
|
|
471
481
|
return P({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
@@ -494,13 +504,13 @@ var tn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
494
504
|
}(), P = function(t) {
|
|
495
505
|
return t instanceof Zt ? t : new Zt(t);
|
|
496
506
|
};
|
|
497
|
-
const
|
|
507
|
+
const dn = (t) => [
|
|
498
508
|
`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()}`,
|
|
499
509
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
500
510
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
501
511
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
502
512
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
503
|
-
].filter(Boolean).join(";"),
|
|
513
|
+
].filter(Boolean).join(";"), un = () => {
|
|
504
514
|
const t = document.createElement("style");
|
|
505
515
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
506
516
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -517,17 +527,17 @@ const cn = (t) => [
|
|
|
517
527
|
Array.from(e).filter((l) => !c.has(l));
|
|
518
528
|
const f = s.map((l) => {
|
|
519
529
|
var v;
|
|
520
|
-
const
|
|
521
|
-
return `::highlight(_${l.annotation.id}) { ${
|
|
530
|
+
const p = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (v = l.state) != null && v.selected ? vt : q, h = d && d.paint(l, r) || p;
|
|
531
|
+
return `::highlight(_${l.annotation.id}) { ${dn(h)} }`;
|
|
522
532
|
});
|
|
523
533
|
t.innerHTML = f.join(`
|
|
524
534
|
`), CSS.highlights.clear(), s.forEach(({ annotation: l }) => {
|
|
525
|
-
const
|
|
535
|
+
const p = l.target.selector.map((v) => v.range), h = new Highlight(...p);
|
|
526
536
|
CSS.highlights.set(`_${l.id}`, h);
|
|
527
537
|
}), e = c;
|
|
528
538
|
}
|
|
529
539
|
};
|
|
530
|
-
},
|
|
540
|
+
}, fn = (t, e, n) => $t(t, e, n, un());
|
|
531
541
|
var te = Object.prototype.hasOwnProperty;
|
|
532
542
|
function Vt(t, e) {
|
|
533
543
|
var n, o;
|
|
@@ -549,10 +559,10 @@ function Vt(t, e) {
|
|
|
549
559
|
}
|
|
550
560
|
return t !== t && e !== e;
|
|
551
561
|
}
|
|
552
|
-
const
|
|
562
|
+
const hn = (t, e) => {
|
|
553
563
|
const n = (s, r) => s.x <= r.x + r.width && s.x + s.width >= r.x && s.y <= r.y + r.height && s.y + s.height >= r.y, o = (s) => s.rects.reduce((r, a) => r + a.width, 0), i = e.filter(({ rects: s }) => s.some((r) => n(t, r)));
|
|
554
564
|
return i.sort((s, r) => o(r) - o(s)), i.findIndex((s) => s.rects.includes(t));
|
|
555
|
-
},
|
|
565
|
+
}, gn = (t) => {
|
|
556
566
|
t.classList.add("r6o-annotatable");
|
|
557
567
|
const e = document.createElement("div");
|
|
558
568
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -562,15 +572,15 @@ const un = (t, e) => {
|
|
|
562
572
|
e.remove();
|
|
563
573
|
},
|
|
564
574
|
redraw: (r, a, d, c, f) => {
|
|
565
|
-
const
|
|
566
|
-
if (!c && !
|
|
567
|
-
|
|
575
|
+
const p = !(Vt(n, r) && f);
|
|
576
|
+
if (!c && !p) return;
|
|
577
|
+
p && (e.innerHTML = ""), [...r].sort((v, b) => {
|
|
568
578
|
const { annotation: { target: { created: E } } } = v, { annotation: { target: { created: m } } } = b;
|
|
569
579
|
return E && m ? E.getTime() - m.getTime() : 0;
|
|
570
580
|
}).forEach((v) => {
|
|
571
581
|
v.rects.map((b) => {
|
|
572
|
-
const E =
|
|
573
|
-
if (
|
|
582
|
+
const E = hn(b, r), m = Fe(v, a, d, c, E);
|
|
583
|
+
if (p) {
|
|
574
584
|
const u = document.createElement("span");
|
|
575
585
|
u.className = "r6o-annotation", u.dataset.annotation = v.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((m == null ? void 0 : m.fill) || q.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? q.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (u.style.borderStyle = m.underlineStyle), m.underlineColor && (u.style.borderColor = m.underlineColor), m.underlineThickness && (u.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (u.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(u);
|
|
576
586
|
}
|
|
@@ -581,29 +591,29 @@ const un = (t, e) => {
|
|
|
581
591
|
r ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
582
592
|
}
|
|
583
593
|
};
|
|
584
|
-
},
|
|
594
|
+
}, pn = (t, e, n) => $t(t, e, n, gn(t));
|
|
585
595
|
var V = [];
|
|
586
596
|
for (var Ot = 0; Ot < 256; ++Ot)
|
|
587
597
|
V.push((Ot + 256).toString(16).slice(1));
|
|
588
|
-
function
|
|
598
|
+
function mn(t, e = 0) {
|
|
589
599
|
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();
|
|
590
600
|
}
|
|
591
|
-
var ht,
|
|
592
|
-
function
|
|
601
|
+
var ht, yn = new Uint8Array(16);
|
|
602
|
+
function bn() {
|
|
593
603
|
if (!ht && (ht = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ht))
|
|
594
604
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
595
|
-
return ht(
|
|
605
|
+
return ht(yn);
|
|
596
606
|
}
|
|
597
|
-
var
|
|
607
|
+
var wn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
598
608
|
const ee = {
|
|
599
|
-
randomUUID:
|
|
609
|
+
randomUUID: wn
|
|
600
610
|
};
|
|
601
|
-
function
|
|
611
|
+
function be(t, e, n) {
|
|
602
612
|
if (ee.randomUUID && !e && !t)
|
|
603
613
|
return ee.randomUUID();
|
|
604
614
|
t = t || {};
|
|
605
|
-
var o = t.random || (t.rng ||
|
|
606
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
615
|
+
var o = t.random || (t.rng || bn)();
|
|
616
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, mn(o);
|
|
607
617
|
}
|
|
608
618
|
var ne = Object.prototype.hasOwnProperty;
|
|
609
619
|
function G(t, e) {
|
|
@@ -628,7 +638,7 @@ function G(t, e) {
|
|
|
628
638
|
}
|
|
629
639
|
function Tt() {
|
|
630
640
|
}
|
|
631
|
-
function
|
|
641
|
+
function vn(t, e) {
|
|
632
642
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
633
643
|
}
|
|
634
644
|
const Q = [];
|
|
@@ -636,7 +646,7 @@ function Pt(t, e = Tt) {
|
|
|
636
646
|
let n;
|
|
637
647
|
const o = /* @__PURE__ */ new Set();
|
|
638
648
|
function i(a) {
|
|
639
|
-
if (
|
|
649
|
+
if (vn(t, a) && (t = a, n)) {
|
|
640
650
|
const d = !Q.length;
|
|
641
651
|
for (const c of o)
|
|
642
652
|
c[1](), Q.push(c, t);
|
|
@@ -658,7 +668,7 @@ function Pt(t, e = Tt) {
|
|
|
658
668
|
}
|
|
659
669
|
return { set: i, update: s, subscribe: r };
|
|
660
670
|
}
|
|
661
|
-
const
|
|
671
|
+
const An = (t) => {
|
|
662
672
|
const { subscribe: e, set: n } = Pt();
|
|
663
673
|
let o;
|
|
664
674
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
@@ -675,13 +685,13 @@ const wn = (t) => {
|
|
|
675
685
|
set: n
|
|
676
686
|
};
|
|
677
687
|
};
|
|
678
|
-
var
|
|
679
|
-
const
|
|
680
|
-
const { subscribe: o, set: i } = Pt(
|
|
681
|
-
let s = e, r =
|
|
688
|
+
var xn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(xn || {});
|
|
689
|
+
const gt = { selected: [] }, En = (t, e, n) => {
|
|
690
|
+
const { subscribe: o, set: i } = Pt(gt);
|
|
691
|
+
let s = e, r = gt;
|
|
682
692
|
o((v) => r = v);
|
|
683
693
|
const a = () => {
|
|
684
|
-
G(r,
|
|
694
|
+
G(r, gt) || i(gt);
|
|
685
695
|
}, d = () => {
|
|
686
696
|
var v;
|
|
687
697
|
return ((v = r.selected) == null ? void 0 : v.length) === 0;
|
|
@@ -714,14 +724,14 @@ const pt = { selected: [] }, An = (t, e, n) => {
|
|
|
714
724
|
return { id: u.id, editable: y };
|
|
715
725
|
})
|
|
716
726
|
}), m.length !== E.length && console.warn("Invalid selection", v);
|
|
717
|
-
},
|
|
727
|
+
}, p = (v) => {
|
|
718
728
|
if (d())
|
|
719
729
|
return !1;
|
|
720
730
|
const { selected: b } = r;
|
|
721
731
|
b.some(({ id: E }) => v.includes(E)) && i({ selected: b.filter(({ id: E }) => !v.includes(E)) });
|
|
722
732
|
}, h = (v) => s = v;
|
|
723
733
|
return t.observe(
|
|
724
|
-
({ changes: v }) =>
|
|
734
|
+
({ changes: v }) => p((v.deleted || []).map((b) => b.id))
|
|
725
735
|
), {
|
|
726
736
|
get event() {
|
|
727
737
|
return r ? r.event : null;
|
|
@@ -744,25 +754,25 @@ const pt = { selected: [] }, An = (t, e, n) => {
|
|
|
744
754
|
var K = [];
|
|
745
755
|
for (var Rt = 0; Rt < 256; ++Rt)
|
|
746
756
|
K.push((Rt + 256).toString(16).slice(1));
|
|
747
|
-
function
|
|
757
|
+
function Sn(t, e = 0) {
|
|
748
758
|
return (K[t[e + 0]] + K[t[e + 1]] + K[t[e + 2]] + K[t[e + 3]] + "-" + K[t[e + 4]] + K[t[e + 5]] + "-" + K[t[e + 6]] + K[t[e + 7]] + "-" + K[t[e + 8]] + K[t[e + 9]] + "-" + K[t[e + 10]] + K[t[e + 11]] + K[t[e + 12]] + K[t[e + 13]] + K[t[e + 14]] + K[t[e + 15]]).toLowerCase();
|
|
749
759
|
}
|
|
750
|
-
var
|
|
751
|
-
function
|
|
752
|
-
if (!
|
|
760
|
+
var pt, Cn = new Uint8Array(16);
|
|
761
|
+
function Ln() {
|
|
762
|
+
if (!pt && (pt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !pt))
|
|
753
763
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
754
|
-
return
|
|
764
|
+
return pt(Cn);
|
|
755
765
|
}
|
|
756
|
-
var
|
|
766
|
+
var On = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
757
767
|
const ie = {
|
|
758
|
-
randomUUID:
|
|
768
|
+
randomUUID: On
|
|
759
769
|
};
|
|
760
|
-
function
|
|
770
|
+
function we(t, e, n) {
|
|
761
771
|
if (ie.randomUUID && !e && !t)
|
|
762
772
|
return ie.randomUUID();
|
|
763
773
|
t = t || {};
|
|
764
|
-
var o = t.random || (t.rng ||
|
|
765
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
774
|
+
var o = t.random || (t.rng || Ln)();
|
|
775
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Sn(o);
|
|
766
776
|
}
|
|
767
777
|
const Mt = (t) => {
|
|
768
778
|
const e = (n) => {
|
|
@@ -774,34 +784,34 @@ const Mt = (t) => {
|
|
|
774
784
|
bodies: (t.bodies || []).map(e),
|
|
775
785
|
target: e(t.target)
|
|
776
786
|
};
|
|
777
|
-
},
|
|
778
|
-
id:
|
|
787
|
+
}, ko = (t, e, n, o) => ({
|
|
788
|
+
id: we(),
|
|
779
789
|
annotation: typeof t == "string" ? t : t.id,
|
|
780
790
|
created: n || /* @__PURE__ */ new Date(),
|
|
781
791
|
creator: o,
|
|
782
792
|
...e
|
|
783
|
-
}),
|
|
793
|
+
}), Tn = (t, e) => {
|
|
784
794
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
785
795
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
786
|
-
},
|
|
796
|
+
}, Rn = (t, e) => {
|
|
787
797
|
const n = new Set(e.bodies.map((o) => o.id));
|
|
788
798
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
789
|
-
},
|
|
799
|
+
}, Mn = (t, e) => e.bodies.map((n) => {
|
|
790
800
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
791
801
|
return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
|
|
792
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
793
|
-
const n =
|
|
802
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !G(t.target, e.target), ve = (t, e) => {
|
|
803
|
+
const n = Tn(t, e), o = Rn(t, e), i = Mn(t, e);
|
|
794
804
|
return {
|
|
795
805
|
oldValue: t,
|
|
796
806
|
newValue: e,
|
|
797
807
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
798
808
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
799
809
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
800
|
-
targetUpdated:
|
|
810
|
+
targetUpdated: Bn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
801
811
|
};
|
|
802
812
|
};
|
|
803
813
|
var k = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(k || {});
|
|
804
|
-
const
|
|
814
|
+
const kn = (t, e) => {
|
|
805
815
|
var n, o;
|
|
806
816
|
const { changes: i, origin: s } = e;
|
|
807
817
|
if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
|
|
@@ -823,19 +833,19 @@ const Mn = (t, e) => {
|
|
|
823
833
|
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => r.has(a));
|
|
824
834
|
} else
|
|
825
835
|
return !0;
|
|
826
|
-
},
|
|
836
|
+
}, In = (t, e) => {
|
|
827
837
|
const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), s = new Set((e.deleted || []).map((l) => l.id)), r = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), d = [
|
|
828
|
-
...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue:
|
|
838
|
+
...(t.created || []).filter((l) => !s.has(l.id)).map((l) => r.has(l.id) ? e.updated.find(({ oldValue: p }) => p.id === l.id).newValue : l),
|
|
829
839
|
...e.created || []
|
|
830
840
|
], c = [
|
|
831
841
|
...(t.deleted || []).filter((l) => !i.has(l.id)),
|
|
832
842
|
...(e.deleted || []).filter((l) => !n.has(l.id))
|
|
833
843
|
], f = [
|
|
834
844
|
...(t.updated || []).filter(({ newValue: l }) => !s.has(l.id)).map((l) => {
|
|
835
|
-
const { oldValue:
|
|
845
|
+
const { oldValue: p, newValue: h } = l;
|
|
836
846
|
if (r.has(h.id)) {
|
|
837
847
|
const v = e.updated.find((b) => b.oldValue.id === h.id).newValue;
|
|
838
|
-
return
|
|
848
|
+
return ve(p, v);
|
|
839
849
|
} else
|
|
840
850
|
return l;
|
|
841
851
|
}),
|
|
@@ -843,7 +853,7 @@ const Mn = (t, e) => {
|
|
|
843
853
|
];
|
|
844
854
|
return { created: d, deleted: c, updated: f };
|
|
845
855
|
}, Bt = (t) => {
|
|
846
|
-
const e = t.id === void 0 ?
|
|
856
|
+
const e = t.id === void 0 ? we() : t.id;
|
|
847
857
|
return {
|
|
848
858
|
...t,
|
|
849
859
|
id: e,
|
|
@@ -856,15 +866,15 @@ const Mn = (t, e) => {
|
|
|
856
866
|
annotation: e
|
|
857
867
|
}
|
|
858
868
|
};
|
|
859
|
-
},
|
|
860
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
861
|
-
n.push({ onChange:
|
|
862
|
-
}, i = (
|
|
863
|
-
const w = n.findIndex((x) => x.onChange ==
|
|
869
|
+
}, _n = (t) => t.id !== void 0, Nn = () => {
|
|
870
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (g, w = {}) => {
|
|
871
|
+
n.push({ onChange: g, options: w });
|
|
872
|
+
}, i = (g) => {
|
|
873
|
+
const w = n.findIndex((x) => x.onChange == g);
|
|
864
874
|
w > -1 && n.splice(w, 1);
|
|
865
|
-
}, s = (
|
|
875
|
+
}, s = (g, w) => {
|
|
866
876
|
const x = {
|
|
867
|
-
origin:
|
|
877
|
+
origin: g,
|
|
868
878
|
changes: {
|
|
869
879
|
created: w.created || [],
|
|
870
880
|
updated: w.updated || [],
|
|
@@ -873,57 +883,57 @@ const Mn = (t, e) => {
|
|
|
873
883
|
state: [...t.values()]
|
|
874
884
|
};
|
|
875
885
|
n.forEach((O) => {
|
|
876
|
-
|
|
886
|
+
kn(O, x) && O.onChange(x);
|
|
877
887
|
});
|
|
878
|
-
}, r = (
|
|
879
|
-
if (
|
|
880
|
-
throw Error(`Cannot add annotation ${
|
|
888
|
+
}, r = (g, w = k.LOCAL) => {
|
|
889
|
+
if (g.id && t.get(g.id))
|
|
890
|
+
throw Error(`Cannot add annotation ${g.id} - exists already`);
|
|
881
891
|
{
|
|
882
|
-
const x = Bt(
|
|
892
|
+
const x = Bt(g);
|
|
883
893
|
t.set(x.id, x), x.bodies.forEach((O) => e.set(O.id, x.id)), s(w, { created: [x] });
|
|
884
894
|
}
|
|
885
|
-
}, a = (
|
|
886
|
-
const x = Bt(typeof
|
|
895
|
+
}, a = (g, w) => {
|
|
896
|
+
const x = Bt(typeof g == "string" ? w : g), O = typeof g == "string" ? g : g.id, B = O && t.get(O);
|
|
887
897
|
if (B) {
|
|
888
|
-
const M =
|
|
898
|
+
const M = ve(B, x);
|
|
889
899
|
return O === x.id ? t.set(O, x) : (t.delete(O), t.set(x.id, x)), B.bodies.forEach((D) => e.delete(D.id)), x.bodies.forEach((D) => e.set(D.id, x.id)), M;
|
|
890
900
|
} else
|
|
891
901
|
console.warn(`Cannot update annotation ${O} - does not exist`);
|
|
892
|
-
}, d = (
|
|
893
|
-
const O =
|
|
902
|
+
}, d = (g, w = k.LOCAL, x = k.LOCAL) => {
|
|
903
|
+
const O = _n(w) ? x : w, B = a(g, w);
|
|
894
904
|
B && s(O, { updated: [B] });
|
|
895
|
-
}, c = (
|
|
896
|
-
const x =
|
|
905
|
+
}, c = (g, w = k.LOCAL) => {
|
|
906
|
+
const x = g.reduce((O, B) => {
|
|
897
907
|
const M = a(B);
|
|
898
908
|
return M ? [...O, M] : O;
|
|
899
909
|
}, []);
|
|
900
910
|
x.length > 0 && s(w, { updated: x });
|
|
901
|
-
}, f = (
|
|
902
|
-
const x = t.get(
|
|
911
|
+
}, f = (g, w = k.LOCAL) => {
|
|
912
|
+
const x = t.get(g.annotation);
|
|
903
913
|
if (x) {
|
|
904
914
|
const O = {
|
|
905
915
|
...x,
|
|
906
|
-
bodies: [...x.bodies,
|
|
916
|
+
bodies: [...x.bodies, g]
|
|
907
917
|
};
|
|
908
|
-
t.set(x.id, O), e.set(
|
|
918
|
+
t.set(x.id, O), e.set(g.id, O.id), s(w, { updated: [{
|
|
909
919
|
oldValue: x,
|
|
910
920
|
newValue: O,
|
|
911
|
-
bodiesCreated: [
|
|
921
|
+
bodiesCreated: [g]
|
|
912
922
|
}] });
|
|
913
923
|
} else
|
|
914
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
915
|
-
}, l = () => [...t.values()],
|
|
924
|
+
console.warn(`Attempt to add body to missing annotation: ${g.annotation}`);
|
|
925
|
+
}, l = () => [...t.values()], p = (g = k.LOCAL) => {
|
|
916
926
|
const w = [...t.values()];
|
|
917
|
-
t.clear(), e.clear(), s(
|
|
918
|
-
}, h = (
|
|
919
|
-
const O =
|
|
927
|
+
t.clear(), e.clear(), s(g, { deleted: w });
|
|
928
|
+
}, h = (g, w = !0, x = k.LOCAL) => {
|
|
929
|
+
const O = g.map(Bt);
|
|
920
930
|
if (w) {
|
|
921
931
|
const B = [...t.values()];
|
|
922
932
|
t.clear(), e.clear(), O.forEach((M) => {
|
|
923
933
|
t.set(M.id, M), M.bodies.forEach((D) => e.set(D.id, M.id));
|
|
924
934
|
}), s(x, { created: O, deleted: B });
|
|
925
935
|
} else {
|
|
926
|
-
const B =
|
|
936
|
+
const B = g.reduce((M, D) => {
|
|
927
937
|
const N = D.id && t.get(D.id);
|
|
928
938
|
return N ? [...M, N] : M;
|
|
929
939
|
}, []);
|
|
@@ -933,29 +943,29 @@ const Mn = (t, e) => {
|
|
|
933
943
|
t.set(M.id, M), M.bodies.forEach((D) => e.set(D.id, M.id));
|
|
934
944
|
}), s(x, { created: O });
|
|
935
945
|
}
|
|
936
|
-
}, v = (
|
|
937
|
-
const w = typeof
|
|
946
|
+
}, v = (g) => {
|
|
947
|
+
const w = typeof g == "string" ? g : g.id, x = t.get(w);
|
|
938
948
|
if (x)
|
|
939
949
|
return t.delete(w), x.bodies.forEach((O) => e.delete(O.id)), x;
|
|
940
950
|
console.warn(`Attempt to delete missing annotation: ${w}`);
|
|
941
|
-
}, b = (
|
|
942
|
-
const x = v(
|
|
951
|
+
}, b = (g, w = k.LOCAL) => {
|
|
952
|
+
const x = v(g);
|
|
943
953
|
x && s(w, { deleted: [x] });
|
|
944
|
-
}, E = (
|
|
945
|
-
const x =
|
|
954
|
+
}, E = (g, w = k.LOCAL) => {
|
|
955
|
+
const x = g.reduce((O, B) => {
|
|
946
956
|
const M = v(B);
|
|
947
957
|
return M ? [...O, M] : O;
|
|
948
958
|
}, []);
|
|
949
959
|
x.length > 0 && s(w, { deleted: x });
|
|
950
|
-
}, m = (
|
|
951
|
-
const w = t.get(
|
|
960
|
+
}, m = (g) => {
|
|
961
|
+
const w = t.get(g.annotation);
|
|
952
962
|
if (w) {
|
|
953
|
-
const x = w.bodies.find((O) => O.id ===
|
|
963
|
+
const x = w.bodies.find((O) => O.id === g.id);
|
|
954
964
|
if (x) {
|
|
955
965
|
e.delete(x.id);
|
|
956
966
|
const O = {
|
|
957
967
|
...w,
|
|
958
|
-
bodies: w.bodies.filter((B) => B.id !==
|
|
968
|
+
bodies: w.bodies.filter((B) => B.id !== g.id)
|
|
959
969
|
};
|
|
960
970
|
return t.set(w.id, O), {
|
|
961
971
|
oldValue: w,
|
|
@@ -963,33 +973,33 @@ const Mn = (t, e) => {
|
|
|
963
973
|
bodiesDeleted: [x]
|
|
964
974
|
};
|
|
965
975
|
} else
|
|
966
|
-
console.warn(`Attempt to delete missing body ${
|
|
976
|
+
console.warn(`Attempt to delete missing body ${g.id} from annotation ${g.annotation}`);
|
|
967
977
|
} else
|
|
968
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
969
|
-
}, u = (
|
|
970
|
-
const x = m(
|
|
978
|
+
console.warn(`Attempt to delete body from missing annotation ${g.annotation}`);
|
|
979
|
+
}, u = (g, w = k.LOCAL) => {
|
|
980
|
+
const x = m(g);
|
|
971
981
|
x && s(w, { updated: [x] });
|
|
972
|
-
}, y = (
|
|
973
|
-
const x =
|
|
982
|
+
}, y = (g, w = k.LOCAL) => {
|
|
983
|
+
const x = g.map((O) => m(O)).filter(Boolean);
|
|
974
984
|
x.length > 0 && s(w, { updated: x });
|
|
975
|
-
}, C = (
|
|
976
|
-
const w = t.get(
|
|
985
|
+
}, C = (g) => {
|
|
986
|
+
const w = t.get(g);
|
|
977
987
|
return w ? { ...w } : void 0;
|
|
978
|
-
}, A = (
|
|
979
|
-
const w = e.get(
|
|
988
|
+
}, A = (g) => {
|
|
989
|
+
const w = e.get(g);
|
|
980
990
|
if (w) {
|
|
981
|
-
const x = C(w).bodies.find((O) => O.id ===
|
|
991
|
+
const x = C(w).bodies.find((O) => O.id === g);
|
|
982
992
|
if (x)
|
|
983
993
|
return x;
|
|
984
|
-
console.error(`Store integrity error: body ${
|
|
994
|
+
console.error(`Store integrity error: body ${g} in index, but not in annotation`);
|
|
985
995
|
} else
|
|
986
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
987
|
-
}, L = (
|
|
988
|
-
if (
|
|
996
|
+
console.warn(`Attempt to retrieve missing body: ${g}`);
|
|
997
|
+
}, L = (g, w) => {
|
|
998
|
+
if (g.annotation !== w.annotation)
|
|
989
999
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
990
|
-
const x = t.get(
|
|
1000
|
+
const x = t.get(g.annotation);
|
|
991
1001
|
if (x) {
|
|
992
|
-
const O = x.bodies.find((M) => M.id ===
|
|
1002
|
+
const O = x.bodies.find((M) => M.id === g.id), B = {
|
|
993
1003
|
...x,
|
|
994
1004
|
bodies: x.bodies.map((M) => M.id === O.id ? w : M)
|
|
995
1005
|
};
|
|
@@ -999,21 +1009,21 @@ const Mn = (t, e) => {
|
|
|
999
1009
|
bodiesUpdated: [{ oldBody: O, newBody: w }]
|
|
1000
1010
|
};
|
|
1001
1011
|
} else
|
|
1002
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
1003
|
-
}, R = (
|
|
1004
|
-
const O = L(
|
|
1012
|
+
console.warn(`Attempt to add body to missing annotation ${g.annotation}`);
|
|
1013
|
+
}, R = (g, w, x = k.LOCAL) => {
|
|
1014
|
+
const O = L(g, w);
|
|
1005
1015
|
O && s(x, { updated: [O] });
|
|
1006
|
-
}, T = (
|
|
1007
|
-
const x =
|
|
1016
|
+
}, T = (g, w = k.LOCAL) => {
|
|
1017
|
+
const x = g.map((O) => L({ id: O.id, annotation: O.annotation }, O)).filter(Boolean);
|
|
1008
1018
|
s(w, { updated: x });
|
|
1009
|
-
}, S = (
|
|
1010
|
-
const w = t.get(
|
|
1019
|
+
}, S = (g) => {
|
|
1020
|
+
const w = t.get(g.annotation);
|
|
1011
1021
|
if (w) {
|
|
1012
1022
|
const x = {
|
|
1013
1023
|
...w,
|
|
1014
1024
|
target: {
|
|
1015
1025
|
...w.target,
|
|
1016
|
-
...
|
|
1026
|
+
...g
|
|
1017
1027
|
}
|
|
1018
1028
|
};
|
|
1019
1029
|
return t.set(w.id, x), {
|
|
@@ -1021,11 +1031,11 @@ const Mn = (t, e) => {
|
|
|
1021
1031
|
newValue: x,
|
|
1022
1032
|
targetUpdated: {
|
|
1023
1033
|
oldTarget: w.target,
|
|
1024
|
-
newTarget:
|
|
1034
|
+
newTarget: g
|
|
1025
1035
|
}
|
|
1026
1036
|
};
|
|
1027
1037
|
} else
|
|
1028
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
1038
|
+
console.warn(`Attempt to update target on missing annotation: ${g.annotation}`);
|
|
1029
1039
|
};
|
|
1030
1040
|
return {
|
|
1031
1041
|
addAnnotation: r,
|
|
@@ -1036,11 +1046,11 @@ const Mn = (t, e) => {
|
|
|
1036
1046
|
bulkDeleteBodies: y,
|
|
1037
1047
|
bulkUpdateAnnotation: c,
|
|
1038
1048
|
bulkUpdateBodies: T,
|
|
1039
|
-
bulkUpdateTargets: (
|
|
1040
|
-
const x =
|
|
1049
|
+
bulkUpdateTargets: (g, w = k.LOCAL) => {
|
|
1050
|
+
const x = g.map((O) => S(O)).filter(Boolean);
|
|
1041
1051
|
x.length > 0 && s(w, { updated: x });
|
|
1042
1052
|
},
|
|
1043
|
-
clear:
|
|
1053
|
+
clear: p,
|
|
1044
1054
|
deleteAnnotation: b,
|
|
1045
1055
|
deleteBody: u,
|
|
1046
1056
|
getAnnotation: C,
|
|
@@ -1049,13 +1059,13 @@ const Mn = (t, e) => {
|
|
|
1049
1059
|
unobserve: i,
|
|
1050
1060
|
updateAnnotation: d,
|
|
1051
1061
|
updateBody: R,
|
|
1052
|
-
updateTarget: (
|
|
1053
|
-
const x = S(
|
|
1062
|
+
updateTarget: (g, w = k.LOCAL) => {
|
|
1063
|
+
const x = S(g);
|
|
1054
1064
|
x && s(w, { updated: [x] });
|
|
1055
1065
|
}
|
|
1056
1066
|
};
|
|
1057
1067
|
};
|
|
1058
|
-
let
|
|
1068
|
+
let Un = () => ({
|
|
1059
1069
|
emit(t, ...e) {
|
|
1060
1070
|
for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
|
|
1061
1071
|
o[n](...e);
|
|
@@ -1069,24 +1079,24 @@ let _n = () => ({
|
|
|
1069
1079
|
};
|
|
1070
1080
|
}
|
|
1071
1081
|
});
|
|
1072
|
-
const
|
|
1073
|
-
const e =
|
|
1082
|
+
const Dn = 250, Vn = (t) => {
|
|
1083
|
+
const e = Un(), n = [];
|
|
1074
1084
|
let o = -1, i = !1, s = 0;
|
|
1075
1085
|
const r = (h) => {
|
|
1076
1086
|
if (!i) {
|
|
1077
1087
|
const { changes: v } = h, b = performance.now();
|
|
1078
|
-
if (b - s >
|
|
1088
|
+
if (b - s > Dn)
|
|
1079
1089
|
n.splice(o + 1), n.push(v), o = n.length - 1;
|
|
1080
1090
|
else {
|
|
1081
1091
|
const E = n.length - 1;
|
|
1082
|
-
n[E] =
|
|
1092
|
+
n[E] = In(n[E], v);
|
|
1083
1093
|
}
|
|
1084
1094
|
s = b;
|
|
1085
1095
|
}
|
|
1086
1096
|
i = !1;
|
|
1087
1097
|
};
|
|
1088
1098
|
t.observe(r, { origin: k.LOCAL });
|
|
1089
|
-
const a = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), d = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), c = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: v }) => v)), f = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: v }) => v)), l = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1),
|
|
1099
|
+
const a = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), d = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), c = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: v }) => v)), f = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: v }) => v)), l = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), p = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h);
|
|
1090
1100
|
return {
|
|
1091
1101
|
canRedo: () => n.length - 1 > o,
|
|
1092
1102
|
canUndo: () => o > -1,
|
|
@@ -1096,7 +1106,7 @@ const Nn = 250, Un = (t) => {
|
|
|
1096
1106
|
if (n.length - 1 > o) {
|
|
1097
1107
|
i = !0;
|
|
1098
1108
|
const { created: h, updated: v, deleted: b } = n[o + 1];
|
|
1099
|
-
d(h), f(v),
|
|
1109
|
+
d(h), f(v), p(b), e.emit("redo", n[o + 1]), o += 1;
|
|
1100
1110
|
}
|
|
1101
1111
|
},
|
|
1102
1112
|
undo: () => {
|
|
@@ -1107,18 +1117,18 @@ const Nn = 250, Un = (t) => {
|
|
|
1107
1117
|
}
|
|
1108
1118
|
}
|
|
1109
1119
|
};
|
|
1110
|
-
},
|
|
1120
|
+
}, Kn = () => {
|
|
1111
1121
|
const { subscribe: t, set: e } = Pt([]);
|
|
1112
1122
|
return {
|
|
1113
1123
|
subscribe: t,
|
|
1114
1124
|
set: e
|
|
1115
1125
|
};
|
|
1116
|
-
},
|
|
1126
|
+
}, Yn = (t, e, n, o) => {
|
|
1117
1127
|
const { hover: i, selection: s, store: r, viewport: a } = t, d = /* @__PURE__ */ new Map();
|
|
1118
1128
|
let c = [], f;
|
|
1119
1129
|
const l = (b, E) => {
|
|
1120
1130
|
d.has(b) ? d.get(b).push(E) : d.set(b, [E]);
|
|
1121
|
-
},
|
|
1131
|
+
}, p = (b, E) => {
|
|
1122
1132
|
const m = d.get(b);
|
|
1123
1133
|
if (m) {
|
|
1124
1134
|
const u = m.indexOf(E);
|
|
@@ -1180,8 +1190,8 @@ const Nn = 250, Un = (t) => {
|
|
|
1180
1190
|
const { updated: m } = E;
|
|
1181
1191
|
b ? (m || []).forEach((u) => h("updateAnnotation", u.oldValue, u.newValue)) : (m || []).forEach((u) => h("updateAnnotation", u.newValue, u.oldValue));
|
|
1182
1192
|
};
|
|
1183
|
-
return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: l, off:
|
|
1184
|
-
},
|
|
1193
|
+
return e.on("undo", v(!0)), e.on("redo", v(!1)), { on: l, off: p, emit: h };
|
|
1194
|
+
}, Xn = (t) => (e) => e.reduce((n, o) => {
|
|
1185
1195
|
const { parsed: i, error: s } = t.parse(o);
|
|
1186
1196
|
return s ? {
|
|
1187
1197
|
parsed: n.parsed,
|
|
@@ -1192,7 +1202,7 @@ const Nn = 250, Un = (t) => {
|
|
|
1192
1202
|
} : {
|
|
1193
1203
|
...n
|
|
1194
1204
|
};
|
|
1195
|
-
}, { parsed: [], failed: [] }),
|
|
1205
|
+
}, { parsed: [], failed: [] }), $n = (t, e, n) => {
|
|
1196
1206
|
const { store: o, selection: i } = t, s = (m) => {
|
|
1197
1207
|
if (n) {
|
|
1198
1208
|
const { parsed: u, error: y } = n.parse(m);
|
|
@@ -1206,7 +1216,7 @@ const Nn = 250, Un = (t) => {
|
|
|
1206
1216
|
var m;
|
|
1207
1217
|
const u = (((m = i.selected) == null ? void 0 : m.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
|
|
1208
1218
|
return n ? u.map(n.serialize) : u;
|
|
1209
|
-
}, l = (m, u = !0) => fetch(m).then((y) => y.json()).then((y) => (h(y, u), y)),
|
|
1219
|
+
}, l = (m, u = !0) => fetch(m).then((y) => y.json()).then((y) => (h(y, u), y)), p = (m) => {
|
|
1210
1220
|
if (typeof m == "string") {
|
|
1211
1221
|
const u = o.getAnnotation(m);
|
|
1212
1222
|
if (o.deleteAnnotation(m), u)
|
|
@@ -1218,7 +1228,7 @@ const Nn = 250, Un = (t) => {
|
|
|
1218
1228
|
}
|
|
1219
1229
|
}, h = (m, u = !0) => {
|
|
1220
1230
|
if (n) {
|
|
1221
|
-
const y = n.parseAll ||
|
|
1231
|
+
const y = n.parseAll || Xn(n), { parsed: C, failed: A } = y(m);
|
|
1222
1232
|
A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(C, u, k.REMOTE);
|
|
1223
1233
|
} else
|
|
1224
1234
|
o.bulkAddAnnotation(m.map(Mt), u, k.REMOTE);
|
|
@@ -1246,15 +1256,15 @@ const Nn = 250, Un = (t) => {
|
|
|
1246
1256
|
getSelected: f,
|
|
1247
1257
|
loadAnnotations: l,
|
|
1248
1258
|
redo: e.redo,
|
|
1249
|
-
removeAnnotation:
|
|
1259
|
+
removeAnnotation: p,
|
|
1250
1260
|
setAnnotations: h,
|
|
1251
1261
|
setSelected: v,
|
|
1252
1262
|
setUserSelectAction: b,
|
|
1253
1263
|
undo: e.undo,
|
|
1254
1264
|
updateAnnotation: E
|
|
1255
1265
|
};
|
|
1256
|
-
},
|
|
1257
|
-
let
|
|
1266
|
+
}, Pn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1267
|
+
let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
|
|
1258
1268
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1259
1269
|
return (s = e) => {
|
|
1260
1270
|
let r = "";
|
|
@@ -1264,13 +1274,13 @@ let $n = (t) => crypto.getRandomValues(new Uint8Array(t)), Pn = (t, e, n) => {
|
|
|
1264
1274
|
if (r += t[a[d] & o] || "", r.length === s) return r;
|
|
1265
1275
|
}
|
|
1266
1276
|
};
|
|
1267
|
-
},
|
|
1277
|
+
}, zn = (t, e = 21) => Hn(t, e, jn), Fn = (t = 21) => {
|
|
1268
1278
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1269
1279
|
for (; t--; )
|
|
1270
|
-
e +=
|
|
1280
|
+
e += Pn[n[t] & 63];
|
|
1271
1281
|
return e;
|
|
1272
1282
|
};
|
|
1273
|
-
const
|
|
1283
|
+
const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), qn = (t) => {
|
|
1274
1284
|
const e = JSON.stringify(t);
|
|
1275
1285
|
let n = 0;
|
|
1276
1286
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1278,20 +1288,20 @@ const zn = () => ({ isGuest: !0, id: jn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1278
1288
|
n = (n << 5) - n + s, n |= 0;
|
|
1279
1289
|
}
|
|
1280
1290
|
return `${n}`;
|
|
1281
|
-
},
|
|
1291
|
+
}, Ae = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Gn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1282
1292
|
const { id: o, type: i, purpose: s, value: r, created: a, modified: d, creator: c, ...f } = n;
|
|
1283
1293
|
return {
|
|
1284
|
-
id: o || `temp-${
|
|
1294
|
+
id: o || `temp-${qn(n)}`,
|
|
1285
1295
|
annotation: e,
|
|
1286
1296
|
type: i,
|
|
1287
1297
|
purpose: s,
|
|
1288
1298
|
value: r,
|
|
1289
|
-
creator:
|
|
1299
|
+
creator: Ae(c),
|
|
1290
1300
|
created: a ? new Date(a) : void 0,
|
|
1291
1301
|
updated: d ? new Date(d) : void 0,
|
|
1292
1302
|
...f
|
|
1293
1303
|
};
|
|
1294
|
-
}),
|
|
1304
|
+
}), Qn = (t) => t.map((e) => {
|
|
1295
1305
|
var n;
|
|
1296
1306
|
const { annotation: o, created: i, updated: s, ...r } = e, a = {
|
|
1297
1307
|
...r,
|
|
@@ -1300,11 +1310,11 @@ const zn = () => ({ isGuest: !0, id: jn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1300
1310
|
};
|
|
1301
1311
|
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
1302
1312
|
});
|
|
1303
|
-
|
|
1304
|
-
const
|
|
1305
|
-
parse: (n) =>
|
|
1306
|
-
serialize: (n) =>
|
|
1307
|
-
}),
|
|
1313
|
+
Fn();
|
|
1314
|
+
const Io = (t, e) => ({
|
|
1315
|
+
parse: (n) => to(n),
|
|
1316
|
+
serialize: (n) => eo(n, t, e)
|
|
1317
|
+
}), Jn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Zn = (t) => {
|
|
1308
1318
|
const {
|
|
1309
1319
|
id: e,
|
|
1310
1320
|
creator: n,
|
|
@@ -1315,7 +1325,7 @@ const Bo = (t, e) => ({
|
|
|
1315
1325
|
if (r.length === 0)
|
|
1316
1326
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1317
1327
|
const a = {
|
|
1318
|
-
creator:
|
|
1328
|
+
creator: Ae(n),
|
|
1319
1329
|
created: o ? new Date(o) : void 0,
|
|
1320
1330
|
updated: i ? new Date(i) : void 0,
|
|
1321
1331
|
annotation: e,
|
|
@@ -1323,18 +1333,18 @@ const Bo = (t, e) => ({
|
|
|
1323
1333
|
styleClass: r[0].styleClass
|
|
1324
1334
|
};
|
|
1325
1335
|
for (const d of r) {
|
|
1326
|
-
const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l,
|
|
1327
|
-
switch (
|
|
1336
|
+
const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, p) => {
|
|
1337
|
+
switch (p.type) {
|
|
1328
1338
|
case "TextQuoteSelector":
|
|
1329
|
-
l.quote =
|
|
1339
|
+
l.quote = p.exact;
|
|
1330
1340
|
break;
|
|
1331
1341
|
case "TextPositionSelector":
|
|
1332
|
-
l.start =
|
|
1342
|
+
l.start = p.start, l.end = p.end;
|
|
1333
1343
|
break;
|
|
1334
1344
|
}
|
|
1335
1345
|
return l;
|
|
1336
1346
|
}, {});
|
|
1337
|
-
if (
|
|
1347
|
+
if (Jn(f))
|
|
1338
1348
|
a.selector.push({ id: d.id, ...f });
|
|
1339
1349
|
else {
|
|
1340
1350
|
const l = [
|
|
@@ -1345,14 +1355,14 @@ const Bo = (t, e) => ({
|
|
|
1345
1355
|
}
|
|
1346
1356
|
}
|
|
1347
1357
|
return { parsed: a };
|
|
1348
|
-
},
|
|
1349
|
-
const e = t.id ||
|
|
1358
|
+
}, to = (t) => {
|
|
1359
|
+
const e = t.id || be(), {
|
|
1350
1360
|
creator: n,
|
|
1351
1361
|
created: o,
|
|
1352
1362
|
modified: i,
|
|
1353
1363
|
body: s,
|
|
1354
1364
|
...r
|
|
1355
|
-
} = t, a =
|
|
1365
|
+
} = t, a = Gn(s, e), d = Zn(t);
|
|
1356
1366
|
return "error" in d ? { error: d.error } : {
|
|
1357
1367
|
parsed: {
|
|
1358
1368
|
...r,
|
|
@@ -1361,15 +1371,15 @@ const Bo = (t, e) => ({
|
|
|
1361
1371
|
target: d.parsed
|
|
1362
1372
|
}
|
|
1363
1373
|
};
|
|
1364
|
-
},
|
|
1374
|
+
}, eo = (t, e, n) => {
|
|
1365
1375
|
const { bodies: o, target: i, ...s } = t, {
|
|
1366
1376
|
selector: r,
|
|
1367
1377
|
creator: a,
|
|
1368
1378
|
created: d,
|
|
1369
1379
|
updated: c,
|
|
1370
1380
|
...f
|
|
1371
|
-
} = i, l = r.map((
|
|
1372
|
-
const { quote: h, start: v, end: b, range: E } =
|
|
1381
|
+
} = i, l = r.map((p) => {
|
|
1382
|
+
const { quote: h, start: v, end: b, range: E } = p, { prefix: m, suffix: u } = Ue(E, n), y = [{
|
|
1373
1383
|
type: "TextQuoteSelector",
|
|
1374
1384
|
exact: h,
|
|
1375
1385
|
prefix: m,
|
|
@@ -1381,7 +1391,7 @@ const Bo = (t, e) => ({
|
|
|
1381
1391
|
}];
|
|
1382
1392
|
return {
|
|
1383
1393
|
...f,
|
|
1384
|
-
id:
|
|
1394
|
+
id: p.id,
|
|
1385
1395
|
source: e,
|
|
1386
1396
|
selector: y
|
|
1387
1397
|
};
|
|
@@ -1391,18 +1401,18 @@ const Bo = (t, e) => ({
|
|
|
1391
1401
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1392
1402
|
id: t.id,
|
|
1393
1403
|
type: "Annotation",
|
|
1394
|
-
body:
|
|
1404
|
+
body: Qn(t.bodies),
|
|
1395
1405
|
creator: a,
|
|
1396
1406
|
created: d == null ? void 0 : d.toISOString(),
|
|
1397
1407
|
modified: c == null ? void 0 : c.toISOString(),
|
|
1398
1408
|
target: l
|
|
1399
1409
|
};
|
|
1400
1410
|
};
|
|
1401
|
-
function
|
|
1411
|
+
function xe(t, e, n = 0, o = t.length - 1, i = no) {
|
|
1402
1412
|
for (; o > n; ) {
|
|
1403
1413
|
if (o - n > 600) {
|
|
1404
|
-
const d = o - n + 1, c = e - n + 1, f = Math.log(d), l = 0.5 * Math.exp(2 * f / 3),
|
|
1405
|
-
|
|
1414
|
+
const d = o - n + 1, c = e - n + 1, f = Math.log(d), l = 0.5 * Math.exp(2 * f / 3), p = 0.5 * Math.sqrt(f * l * (d - l) / d) * (c - d / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(e - c * l / d + p)), v = Math.min(o, Math.floor(e + (d - c) * l / d + p));
|
|
1415
|
+
xe(t, e, h, v, i);
|
|
1406
1416
|
}
|
|
1407
1417
|
const s = t[e];
|
|
1408
1418
|
let r = n, a = o;
|
|
@@ -1417,10 +1427,10 @@ function et(t, e, n) {
|
|
|
1417
1427
|
const o = t[e];
|
|
1418
1428
|
t[e] = t[n], t[n] = o;
|
|
1419
1429
|
}
|
|
1420
|
-
function
|
|
1430
|
+
function no(t, e) {
|
|
1421
1431
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1422
1432
|
}
|
|
1423
|
-
class
|
|
1433
|
+
class oo {
|
|
1424
1434
|
constructor(e = 9) {
|
|
1425
1435
|
this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1426
1436
|
}
|
|
@@ -1491,7 +1501,7 @@ class eo {
|
|
|
1491
1501
|
let a, d, c;
|
|
1492
1502
|
for (; o || s.length; ) {
|
|
1493
1503
|
if (o || (o = s.pop(), d = s[s.length - 1], a = r.pop(), c = !0), o.leaf) {
|
|
1494
|
-
const f =
|
|
1504
|
+
const f = io(e, o.children, n);
|
|
1495
1505
|
if (f !== -1)
|
|
1496
1506
|
return o.children.splice(f, 1), s.push(o), this._condense(s), this;
|
|
1497
1507
|
}
|
|
@@ -1531,9 +1541,9 @@ class eo {
|
|
|
1531
1541
|
for (let f = n; f <= o; f += c) {
|
|
1532
1542
|
const l = Math.min(f + c - 1, o);
|
|
1533
1543
|
se(e, f, l, d, this.compareMinY);
|
|
1534
|
-
for (let
|
|
1535
|
-
const h = Math.min(
|
|
1536
|
-
a.children.push(this._build(e,
|
|
1544
|
+
for (let p = f; p <= l; p += d) {
|
|
1545
|
+
const h = Math.min(p + d - 1, l);
|
|
1546
|
+
a.children.push(this._build(e, p, h, i - 1));
|
|
1537
1547
|
}
|
|
1538
1548
|
}
|
|
1539
1549
|
return J(a, this.toBBox), a;
|
|
@@ -1542,7 +1552,7 @@ class eo {
|
|
|
1542
1552
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1543
1553
|
let s = 1 / 0, r = 1 / 0, a;
|
|
1544
1554
|
for (let d = 0; d < n.children.length; d++) {
|
|
1545
|
-
const c = n.children[d], f = kt(c), l =
|
|
1555
|
+
const c = n.children[d], f = kt(c), l = ao(e, c) - f;
|
|
1546
1556
|
l < r ? (r = l, s = f < s ? f : s, a = c) : l === r && f < s && (s = f, a = c);
|
|
1547
1557
|
}
|
|
1548
1558
|
n = a || n.children[0];
|
|
@@ -1568,14 +1578,14 @@ class eo {
|
|
|
1568
1578
|
_chooseSplitIndex(e, n, o) {
|
|
1569
1579
|
let i, s = 1 / 0, r = 1 / 0;
|
|
1570
1580
|
for (let a = n; a <= o - n; a++) {
|
|
1571
|
-
const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), f =
|
|
1581
|
+
const d = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), f = co(d, c), l = kt(d) + kt(c);
|
|
1572
1582
|
f < s ? (s = f, i = a, r = l < r ? l : r) : f === s && l < r && (r = l, i = a);
|
|
1573
1583
|
}
|
|
1574
1584
|
return i || o - n;
|
|
1575
1585
|
}
|
|
1576
1586
|
// sorts node children by the best axis for split
|
|
1577
1587
|
_chooseSplitAxis(e, n, o) {
|
|
1578
|
-
const i = e.leaf ? this.compareMinX :
|
|
1588
|
+
const i = e.leaf ? this.compareMinX : so, s = e.leaf ? this.compareMinY : ro, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
|
|
1579
1589
|
r < a && e.children.sort(i);
|
|
1580
1590
|
}
|
|
1581
1591
|
// total margin of all possible split distributions where each node is at least m full
|
|
@@ -1602,7 +1612,7 @@ class eo {
|
|
|
1602
1612
|
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);
|
|
1603
1613
|
}
|
|
1604
1614
|
}
|
|
1605
|
-
function
|
|
1615
|
+
function io(t, e, n) {
|
|
1606
1616
|
if (!n) return e.indexOf(t);
|
|
1607
1617
|
for (let o = 0; o < e.length; o++)
|
|
1608
1618
|
if (n(t, e[o])) return o;
|
|
@@ -1622,10 +1632,10 @@ function ot(t, e, n, o, i) {
|
|
|
1622
1632
|
function it(t, e) {
|
|
1623
1633
|
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;
|
|
1624
1634
|
}
|
|
1625
|
-
function
|
|
1635
|
+
function so(t, e) {
|
|
1626
1636
|
return t.minX - e.minX;
|
|
1627
1637
|
}
|
|
1628
|
-
function
|
|
1638
|
+
function ro(t, e) {
|
|
1629
1639
|
return t.minY - e.minY;
|
|
1630
1640
|
}
|
|
1631
1641
|
function kt(t) {
|
|
@@ -1634,10 +1644,10 @@ function kt(t) {
|
|
|
1634
1644
|
function mt(t) {
|
|
1635
1645
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1636
1646
|
}
|
|
1637
|
-
function
|
|
1647
|
+
function ao(t, e) {
|
|
1638
1648
|
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));
|
|
1639
1649
|
}
|
|
1640
|
-
function
|
|
1650
|
+
function co(t, e) {
|
|
1641
1651
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
|
|
1642
1652
|
return Math.max(0, i - n) * Math.max(0, s - o);
|
|
1643
1653
|
}
|
|
@@ -1663,10 +1673,10 @@ function se(t, e, n, o, i) {
|
|
|
1663
1673
|
for (; s.length; ) {
|
|
1664
1674
|
if (n = s.pop(), e = s.pop(), n - e <= o) continue;
|
|
1665
1675
|
const r = e + Math.ceil((n - e) / o / 2) * o;
|
|
1666
|
-
|
|
1676
|
+
xe(t, r, e, n, i), s.push(e, r, r, n);
|
|
1667
1677
|
}
|
|
1668
1678
|
}
|
|
1669
|
-
let
|
|
1679
|
+
let lo = () => ({
|
|
1670
1680
|
emit(t, ...e) {
|
|
1671
1681
|
for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
|
|
1672
1682
|
o[n](...e);
|
|
@@ -1680,18 +1690,18 @@ let ao = () => ({
|
|
|
1680
1690
|
};
|
|
1681
1691
|
}
|
|
1682
1692
|
});
|
|
1683
|
-
const
|
|
1684
|
-
const n = new
|
|
1693
|
+
const uo = (t, e) => {
|
|
1694
|
+
const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (y, C) => {
|
|
1685
1695
|
const A = y.selector.flatMap((R) => {
|
|
1686
1696
|
const T = W([R]) ? R.range : ue(R, e).range;
|
|
1687
1697
|
return Array.from(T.getClientRects());
|
|
1688
|
-
}), L =
|
|
1698
|
+
}), L = Xe(A).map((R) => He(R, C));
|
|
1689
1699
|
return L.map((R) => {
|
|
1690
|
-
const { x: T, y: S, width:
|
|
1700
|
+
const { x: T, y: S, width: g, height: w } = R;
|
|
1691
1701
|
return {
|
|
1692
1702
|
minX: T,
|
|
1693
1703
|
minY: S,
|
|
1694
|
-
maxX: T +
|
|
1704
|
+
maxX: T + g,
|
|
1695
1705
|
maxY: S + w,
|
|
1696
1706
|
annotation: {
|
|
1697
1707
|
id: y.annotation,
|
|
@@ -1715,13 +1725,13 @@ const co = (t, e) => {
|
|
|
1715
1725
|
L.forEach(({ target: T, rects: S }) => o.set(T.annotation, S));
|
|
1716
1726
|
const R = L.flatMap(({ rects: T }) => T);
|
|
1717
1727
|
n.load(R);
|
|
1718
|
-
},
|
|
1728
|
+
}, p = (y, C, A = !1) => {
|
|
1719
1729
|
const L = n.search({
|
|
1720
1730
|
minX: y,
|
|
1721
1731
|
minY: C,
|
|
1722
1732
|
maxX: y,
|
|
1723
1733
|
maxY: C
|
|
1724
|
-
}), R = (T) => T.annotation.rects.reduce((S,
|
|
1734
|
+
}), R = (T) => T.annotation.rects.reduce((S, g) => S + g.width * g.height, 0);
|
|
1725
1735
|
return L.length > 0 ? (L.sort((T, S) => R(T) - R(S)), A ? L.map((T) => T.annotation.id) : [L[0].annotation.id]) : [];
|
|
1726
1736
|
}, h = (y) => {
|
|
1727
1737
|
const C = v(y);
|
|
@@ -1729,8 +1739,8 @@ const co = (t, e) => {
|
|
|
1729
1739
|
return;
|
|
1730
1740
|
let A = C[0].left, L = C[0].top, R = C[0].right, T = C[0].bottom;
|
|
1731
1741
|
for (let S = 1; S < C.length; S++) {
|
|
1732
|
-
const
|
|
1733
|
-
A = Math.min(A,
|
|
1742
|
+
const g = C[S];
|
|
1743
|
+
A = Math.min(A, g.left), L = Math.min(L, g.top), R = Math.max(R, g.right), T = Math.max(T, g.bottom);
|
|
1734
1744
|
}
|
|
1735
1745
|
return new DOMRect(A, L, R - A, T - L);
|
|
1736
1746
|
}, v = (y) => {
|
|
@@ -1740,7 +1750,7 @@ const co = (t, e) => {
|
|
|
1740
1750
|
return {
|
|
1741
1751
|
all: r,
|
|
1742
1752
|
clear: a,
|
|
1743
|
-
getAt:
|
|
1753
|
+
getAt: p,
|
|
1744
1754
|
getAnnotationBounds: h,
|
|
1745
1755
|
getAnnotationRects: v,
|
|
1746
1756
|
getIntersecting: (y, C, A, L) => {
|
|
@@ -1760,10 +1770,10 @@ const co = (t, e) => {
|
|
|
1760
1770
|
update: f,
|
|
1761
1771
|
on: (y, C) => i.on(y, C)
|
|
1762
1772
|
};
|
|
1763
|
-
},
|
|
1764
|
-
const n =
|
|
1773
|
+
}, fo = (t, e) => {
|
|
1774
|
+
const n = Nn(), o = uo(n, t), i = En(n);
|
|
1765
1775
|
i.setUserSelectAction(e);
|
|
1766
|
-
const s =
|
|
1776
|
+
const s = An(n), r = Kn(), a = (u, y = k.LOCAL) => {
|
|
1767
1777
|
const C = xt(u, t), A = W(C.target.selector);
|
|
1768
1778
|
return A && n.addAnnotation(C, y), A;
|
|
1769
1779
|
}, d = (u, y = !0, C = k.LOCAL) => {
|
|
@@ -1780,14 +1790,14 @@ const co = (t, e) => {
|
|
|
1780
1790
|
}, l = (u, y = k.LOCAL) => {
|
|
1781
1791
|
const C = u.map((A) => wt(A, t));
|
|
1782
1792
|
n.bulkUpdateTargets(C, y);
|
|
1783
|
-
},
|
|
1793
|
+
}, p = (u, y, C) => {
|
|
1784
1794
|
const A = o.getAt(u, y, !!C).map((R) => n.getAnnotation(R)), L = C ? A.filter(C) : A;
|
|
1785
1795
|
return L.length > 0 ? L[0] : void 0;
|
|
1786
1796
|
}, h = (u, y, C, A = 5) => {
|
|
1787
1797
|
const L = o.getAnnotationRects(u);
|
|
1788
1798
|
if (L.length !== 0) {
|
|
1789
1799
|
if (y && C) {
|
|
1790
|
-
const R = L.find(({ top: T, right: S, bottom:
|
|
1800
|
+
const R = L.find(({ top: T, right: S, bottom: g, left: w }) => y >= w - A && y <= S + A && C >= T - A && C <= g + A);
|
|
1791
1801
|
if (R) return R;
|
|
1792
1802
|
}
|
|
1793
1803
|
return o.getAnnotationBounds(u);
|
|
@@ -1806,7 +1816,7 @@ const co = (t, e) => {
|
|
|
1806
1816
|
getAnnotationBounds: h,
|
|
1807
1817
|
getAnnotationRects: b,
|
|
1808
1818
|
getIntersecting: v,
|
|
1809
|
-
getAt:
|
|
1819
|
+
getAt: p,
|
|
1810
1820
|
recalculatePositions: E,
|
|
1811
1821
|
onRecalculatePositions: m,
|
|
1812
1822
|
updateTarget: f
|
|
@@ -1815,15 +1825,15 @@ const co = (t, e) => {
|
|
|
1815
1825
|
hover: s,
|
|
1816
1826
|
viewport: r
|
|
1817
1827
|
};
|
|
1818
|
-
},
|
|
1828
|
+
}, ho = () => {
|
|
1819
1829
|
const t = document.createElement("canvas");
|
|
1820
1830
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
|
|
1821
1831
|
const e = t.getContext("2d");
|
|
1822
1832
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
1823
|
-
},
|
|
1824
|
-
const n =
|
|
1833
|
+
}, go = (t, e = {}) => {
|
|
1834
|
+
const n = ho(), o = n.getContext("2d");
|
|
1825
1835
|
document.body.appendChild(n);
|
|
1826
|
-
const i = /* @__PURE__ */ new Map(), s = (f) => Array.from(i.entries()).filter(([l,
|
|
1836
|
+
const i = /* @__PURE__ */ new Map(), s = (f) => Array.from(i.entries()).filter(([l, p]) => p.presenceKey === f.presenceKey).map(([l, p]) => l);
|
|
1827
1837
|
return t.on("selectionChange", (f, l) => {
|
|
1828
1838
|
s(f).forEach((h) => i.delete(h)), l && l.forEach((h) => i.set(h, f));
|
|
1829
1839
|
}), {
|
|
@@ -1834,7 +1844,7 @@ const co = (t, e) => {
|
|
|
1834
1844
|
destroy: () => {
|
|
1835
1845
|
n.remove();
|
|
1836
1846
|
},
|
|
1837
|
-
paint: (f, l,
|
|
1847
|
+
paint: (f, l, p) => {
|
|
1838
1848
|
e.font && (o.font = e.font);
|
|
1839
1849
|
const h = i.get(f.annotation.id);
|
|
1840
1850
|
if (h) {
|
|
@@ -1843,7 +1853,7 @@ const co = (t, e) => {
|
|
|
1843
1853
|
const m = o.measureText(h.appearance.label), u = m.width + 6, y = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, C = m.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1844
1854
|
return o.fillRect(b - 2, E - 2.5 - y, u, y), o.fillStyle = "#fff", o.fillText(h.appearance.label, b + 1, E - C), {
|
|
1845
1855
|
fill: h.appearance.color,
|
|
1846
|
-
fillOpacity:
|
|
1856
|
+
fillOpacity: p ? 0.45 : 0.18
|
|
1847
1857
|
};
|
|
1848
1858
|
}
|
|
1849
1859
|
},
|
|
@@ -1860,12 +1870,12 @@ function Nt(t, e, n, o) {
|
|
|
1860
1870
|
function nt(t, e, n, o) {
|
|
1861
1871
|
t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
|
|
1862
1872
|
}
|
|
1863
|
-
function
|
|
1873
|
+
function Ee(t, e) {
|
|
1864
1874
|
const n = e.slice(0, e.length - 1);
|
|
1865
1875
|
for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
|
|
1866
1876
|
return n;
|
|
1867
1877
|
}
|
|
1868
|
-
function
|
|
1878
|
+
function Se(t) {
|
|
1869
1879
|
typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
|
|
1870
1880
|
const e = t.split(",");
|
|
1871
1881
|
let n = e.lastIndexOf("");
|
|
@@ -1873,7 +1883,7 @@ function Ee(t) {
|
|
|
1873
1883
|
e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
|
|
1874
1884
|
return e;
|
|
1875
1885
|
}
|
|
1876
|
-
function
|
|
1886
|
+
function po(t, e) {
|
|
1877
1887
|
const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
|
|
1878
1888
|
let i = !0;
|
|
1879
1889
|
for (let s = 0; s < n.length; s++)
|
|
@@ -1965,21 +1975,21 @@ const at = {
|
|
|
1965
1975
|
}, _ = {};
|
|
1966
1976
|
for (let t = 1; t < 20; t++)
|
|
1967
1977
|
at["f".concat(t)] = 111 + t;
|
|
1968
|
-
let I = [], rt = null,
|
|
1969
|
-
const F = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0),
|
|
1970
|
-
function
|
|
1971
|
-
|
|
1978
|
+
let I = [], rt = null, Ce = "all";
|
|
1979
|
+
const F = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), mo = (t) => Object.keys(at).find((e) => at[e] === t), yo = (t) => Object.keys(H).find((e) => H[e] === t);
|
|
1980
|
+
function Le(t) {
|
|
1981
|
+
Ce = t || "all";
|
|
1972
1982
|
}
|
|
1973
1983
|
function ct() {
|
|
1974
|
-
return
|
|
1984
|
+
return Ce || "all";
|
|
1975
1985
|
}
|
|
1976
|
-
function
|
|
1986
|
+
function bo() {
|
|
1977
1987
|
return I.slice(0);
|
|
1978
1988
|
}
|
|
1979
|
-
function
|
|
1980
|
-
return I.map((t) =>
|
|
1989
|
+
function wo() {
|
|
1990
|
+
return I.map((t) => mo(t) || yo(t) || String.fromCharCode(t));
|
|
1981
1991
|
}
|
|
1982
|
-
function
|
|
1992
|
+
function vo() {
|
|
1983
1993
|
const t = [];
|
|
1984
1994
|
return Object.keys(_).forEach((e) => {
|
|
1985
1995
|
_[e].forEach((n) => {
|
|
@@ -1998,7 +2008,7 @@ function bo() {
|
|
|
1998
2008
|
});
|
|
1999
2009
|
}), t;
|
|
2000
2010
|
}
|
|
2001
|
-
function
|
|
2011
|
+
function Ao(t) {
|
|
2002
2012
|
const e = t.target || t.srcElement, {
|
|
2003
2013
|
tagName: n
|
|
2004
2014
|
} = e;
|
|
@@ -2006,10 +2016,10 @@ function wo(t) {
|
|
|
2006
2016
|
const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
|
|
2007
2017
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
|
|
2008
2018
|
}
|
|
2009
|
-
function
|
|
2019
|
+
function xo(t) {
|
|
2010
2020
|
return typeof t == "string" && (t = lt(t)), I.indexOf(t) !== -1;
|
|
2011
2021
|
}
|
|
2012
|
-
function
|
|
2022
|
+
function Eo(t, e) {
|
|
2013
2023
|
let n, o;
|
|
2014
2024
|
t || (t = ct());
|
|
2015
2025
|
for (const i in _)
|
|
@@ -2021,9 +2031,9 @@ function Ao(t, e) {
|
|
|
2021
2031
|
} = r;
|
|
2022
2032
|
return jt(a);
|
|
2023
2033
|
}) : o++;
|
|
2024
|
-
ct() === t &&
|
|
2034
|
+
ct() === t && Le(e || "all");
|
|
2025
2035
|
}
|
|
2026
|
-
function
|
|
2036
|
+
function So(t) {
|
|
2027
2037
|
let e = t.keyCode || t.which || t.charCode;
|
|
2028
2038
|
const n = I.indexOf(e);
|
|
2029
2039
|
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 Y) {
|
|
@@ -2031,7 +2041,7 @@ function xo(t) {
|
|
|
2031
2041
|
for (const o in H) H[o] === e && ($[o] = !1);
|
|
2032
2042
|
}
|
|
2033
2043
|
}
|
|
2034
|
-
function
|
|
2044
|
+
function Oe(t) {
|
|
2035
2045
|
if (typeof t > "u")
|
|
2036
2046
|
Object.keys(_).forEach((i) => {
|
|
2037
2047
|
Array.isArray(_[i]) && _[i].forEach((s) => bt(s)), delete _[i];
|
|
@@ -2061,15 +2071,15 @@ const bt = (t) => {
|
|
|
2061
2071
|
method: o,
|
|
2062
2072
|
splitKey: i = "+"
|
|
2063
2073
|
} = t;
|
|
2064
|
-
|
|
2074
|
+
Se(e).forEach((r) => {
|
|
2065
2075
|
const a = r.split(i), d = a.length, c = a[d - 1], f = c === "*" ? "*" : lt(c);
|
|
2066
2076
|
if (!_[f]) return;
|
|
2067
2077
|
n || (n = ct());
|
|
2068
|
-
const l = d > 1 ?
|
|
2078
|
+
const l = d > 1 ? Ee(H, a) : [], p = [];
|
|
2069
2079
|
_[f] = _[f].filter((h) => {
|
|
2070
|
-
const b = (o ? h.method === o : !0) && h.scope === n &&
|
|
2071
|
-
return b &&
|
|
2072
|
-
}),
|
|
2080
|
+
const b = (o ? h.method === o : !0) && h.scope === n && po(h.mods, l);
|
|
2081
|
+
return b && p.push(h.element), !b;
|
|
2082
|
+
}), p.forEach((h) => jt(h));
|
|
2073
2083
|
});
|
|
2074
2084
|
};
|
|
2075
2085
|
function re(t, e, n, o) {
|
|
@@ -2110,17 +2120,17 @@ function ae(t, e) {
|
|
|
2110
2120
|
const d = s[a], {
|
|
2111
2121
|
splitKey: c
|
|
2112
2122
|
} = d, f = d.key.split(c), l = [];
|
|
2113
|
-
for (let
|
|
2114
|
-
l.push(lt(f[
|
|
2123
|
+
for (let p = 0; p < f.length; p++)
|
|
2124
|
+
l.push(lt(f[p]));
|
|
2115
2125
|
l.sort().join("") === I.sort().join("") && re(t, d, i, e);
|
|
2116
2126
|
}
|
|
2117
2127
|
}
|
|
2118
2128
|
function $(t, e, n) {
|
|
2119
2129
|
I = [];
|
|
2120
|
-
const o =
|
|
2121
|
-
let i = [], s = "all", r = document, a = 0, d = !1, c = !0, f = "+", l = !1,
|
|
2122
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (f = e.splitKey), e.single === !0 && (
|
|
2123
|
-
t = o[a].split(f), i = [], t.length > 1 && (i =
|
|
2130
|
+
const o = Se(t);
|
|
2131
|
+
let i = [], s = "all", r = document, a = 0, d = !1, c = !0, f = "+", l = !1, p = !1;
|
|
2132
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (l = e.capture), typeof e.splitKey == "string" && (f = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (s = e), p && Oe(t, s); a < o.length; a++)
|
|
2133
|
+
t = o[a].split(f), i = [], t.length > 1 && (i = Ee(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in _ || (_[t] = []), _[t].push({
|
|
2124
2134
|
keyup: d,
|
|
2125
2135
|
keydown: c,
|
|
2126
2136
|
scope: s,
|
|
@@ -2138,7 +2148,7 @@ function $(t, e, n) {
|
|
|
2138
2148
|
return ae(b, r);
|
|
2139
2149
|
}, v = function() {
|
|
2140
2150
|
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2141
|
-
ae(b, r),
|
|
2151
|
+
ae(b, r), So(b);
|
|
2142
2152
|
};
|
|
2143
2153
|
F.set(r, {
|
|
2144
2154
|
keydownListener: h,
|
|
@@ -2157,7 +2167,7 @@ function $(t, e, n) {
|
|
|
2157
2167
|
}
|
|
2158
2168
|
}
|
|
2159
2169
|
}
|
|
2160
|
-
function
|
|
2170
|
+
function Co(t) {
|
|
2161
2171
|
let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2162
2172
|
Object.keys(_).forEach((n) => {
|
|
2163
2173
|
_[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
|
|
@@ -2196,16 +2206,16 @@ function jt(t) {
|
|
|
2196
2206
|
}
|
|
2197
2207
|
}
|
|
2198
2208
|
const Ut = {
|
|
2199
|
-
getPressedKeyString:
|
|
2200
|
-
setScope:
|
|
2209
|
+
getPressedKeyString: wo,
|
|
2210
|
+
setScope: Le,
|
|
2201
2211
|
getScope: ct,
|
|
2202
|
-
deleteScope:
|
|
2203
|
-
getPressedKeyCodes:
|
|
2204
|
-
getAllKeyCodes:
|
|
2205
|
-
isPressed:
|
|
2206
|
-
filter:
|
|
2207
|
-
trigger:
|
|
2208
|
-
unbind:
|
|
2212
|
+
deleteScope: Eo,
|
|
2213
|
+
getPressedKeyCodes: bo,
|
|
2214
|
+
getAllKeyCodes: vo,
|
|
2215
|
+
isPressed: xo,
|
|
2216
|
+
filter: Ao,
|
|
2217
|
+
trigger: Co,
|
|
2218
|
+
unbind: Oe,
|
|
2209
2219
|
keyMap: at,
|
|
2210
2220
|
modifier: H,
|
|
2211
2221
|
modifierMap: Kt
|
|
@@ -2216,23 +2226,23 @@ if (typeof window < "u") {
|
|
|
2216
2226
|
const t = window.hotkeys;
|
|
2217
2227
|
$.noConflict = (e) => (e && window.hotkeys === $ && (window.hotkeys = t), $), window.hotkeys = $;
|
|
2218
2228
|
}
|
|
2219
|
-
const ce = 300,
|
|
2220
|
-
...
|
|
2221
|
-
|
|
2222
|
-
],
|
|
2229
|
+
const ce = 300, Te = ["up", "down", "left", "right"], Re = _e ? "⌘+a" : "ctrl+a", Lo = [
|
|
2230
|
+
...Te.map((t) => `shift+${t}`),
|
|
2231
|
+
Re
|
|
2232
|
+
], Oo = (t, e, n) => {
|
|
2223
2233
|
const { store: o, selection: i } = e;
|
|
2224
2234
|
let s;
|
|
2225
2235
|
const r = (S) => s = S;
|
|
2226
2236
|
let a;
|
|
2227
2237
|
const d = (S) => a = S;
|
|
2228
|
-
let c, f, l,
|
|
2238
|
+
let c, f, l, p = !1, h = !0;
|
|
2229
2239
|
const v = (S) => {
|
|
2230
|
-
h = S, E.clear(), S || (c = void 0, l = void 0,
|
|
2240
|
+
h = S, E.clear(), S || (c = void 0, l = void 0, p = !1);
|
|
2231
2241
|
}, b = (S) => {
|
|
2232
2242
|
var w;
|
|
2233
|
-
if (!h || (
|
|
2243
|
+
if (!h || (p = !1, f === !1)) return;
|
|
2234
2244
|
c = !((w = S.target.parentElement) != null && w.closest(j)) ? {
|
|
2235
|
-
annotation:
|
|
2245
|
+
annotation: be(),
|
|
2236
2246
|
selector: [],
|
|
2237
2247
|
creator: s,
|
|
2238
2248
|
created: /* @__PURE__ */ new Date()
|
|
@@ -2240,31 +2250,31 @@ const ce = 300, Oe = ["up", "down", "left", "right"], Te = Ie ? "⌘+a" : "ctrl+
|
|
|
2240
2250
|
}, E = Xt((S) => {
|
|
2241
2251
|
var N, dt;
|
|
2242
2252
|
if (!h) return;
|
|
2243
|
-
const
|
|
2244
|
-
if (!!((dt = (N =
|
|
2253
|
+
const g = document.getSelection();
|
|
2254
|
+
if (!!((dt = (N = g.anchorNode) == null ? void 0 : N.parentElement) != null && dt.closest(j))) {
|
|
2245
2255
|
c = void 0;
|
|
2246
2256
|
return;
|
|
2247
2257
|
}
|
|
2248
2258
|
const x = S.timeStamp - ((l == null ? void 0 : l.timeStamp) || S.timeStamp);
|
|
2249
|
-
if ((l == null ? void 0 : l.type) === "pointerdown" && (x < 1e3 && !c ||
|
|
2250
|
-
if (
|
|
2259
|
+
if ((l == null ? void 0 : l.type) === "pointerdown" && (x < 1e3 && !c || g.isCollapsed && x < ce) && b(l || S), !c) return;
|
|
2260
|
+
if (g.isCollapsed) {
|
|
2251
2261
|
o.getAnnotation(c.annotation) && (i.clear(), o.deleteAnnotation(c.annotation));
|
|
2252
2262
|
return;
|
|
2253
2263
|
}
|
|
2254
|
-
const O =
|
|
2255
|
-
if (
|
|
2256
|
-
const M =
|
|
2264
|
+
const O = g.getRangeAt(0), B = je(O, t);
|
|
2265
|
+
if (Ve(B)) return;
|
|
2266
|
+
const M = ke(B.cloneRange());
|
|
2257
2267
|
(M.length !== c.selector.length || M.some((tt, At) => {
|
|
2258
2268
|
var Ht;
|
|
2259
2269
|
return tt.toString() !== ((Ht = c.selector[At]) == null ? void 0 : Ht.quote);
|
|
2260
2270
|
})) && (c = {
|
|
2261
2271
|
...c,
|
|
2262
|
-
selector: M.map((tt) =>
|
|
2272
|
+
selector: M.map((tt) => $e(tt, t, n)),
|
|
2263
2273
|
updated: /* @__PURE__ */ new Date()
|
|
2264
|
-
}, o.getAnnotation(c.annotation)
|
|
2274
|
+
}, o.getAnnotation(c.annotation) ? o.updateTarget(c, k.LOCAL) : i.clear());
|
|
2265
2275
|
}, 10), m = (S) => {
|
|
2266
2276
|
var w;
|
|
2267
|
-
|
|
2277
|
+
p || (w = S.target.parentElement) != null && w.closest(j) || (l = Et(S), f = l.button === 0);
|
|
2268
2278
|
}, u = () => {
|
|
2269
2279
|
o.getAnnotation(c.annotation) ? o.updateTarget(c) : o.addAnnotation({
|
|
2270
2280
|
id: c.annotation,
|
|
@@ -2273,84 +2283,85 @@ const ce = 300, Oe = ["up", "down", "left", "right"], Te = Ie ? "⌘+a" : "ctrl+
|
|
|
2273
2283
|
});
|
|
2274
2284
|
}, y = (S) => {
|
|
2275
2285
|
var O;
|
|
2276
|
-
if (
|
|
2286
|
+
if (p || !!((O = S.target.parentElement) != null && O.closest(j)) || !f) return;
|
|
2277
2287
|
const w = () => {
|
|
2278
2288
|
const { x: B, y: M } = t.getBoundingClientRect(), D = S.target instanceof Node && t.contains(S.target) && o.getAt(S.clientX - B, S.clientY - M, a);
|
|
2279
2289
|
if (D) {
|
|
2280
2290
|
const { selected: N } = i;
|
|
2281
2291
|
(N.length !== 1 || N[0].id !== D.id) && i.userSelect(D.id, S);
|
|
2282
|
-
} else
|
|
2292
|
+
} else
|
|
2293
|
+
i.clear();
|
|
2283
2294
|
}, x = S.timeStamp - l.timeStamp;
|
|
2284
2295
|
setTimeout(() => {
|
|
2285
2296
|
const B = document.getSelection();
|
|
2286
2297
|
B != null && B.isCollapsed && x < ce ? (c = void 0, w()) : c && c.selector.length > 0 && (i.clear(), u(), i.userSelect(c.annotation, Et(S)));
|
|
2287
2298
|
});
|
|
2288
2299
|
}, C = (S) => {
|
|
2289
|
-
|
|
2290
|
-
const
|
|
2291
|
-
|
|
2300
|
+
p = !0;
|
|
2301
|
+
const g = document.getSelection();
|
|
2302
|
+
g != null && g.isCollapsed || ((!c || c.selector.length === 0) && E(S), u(), i.userSelect(c.annotation, Et(S)));
|
|
2292
2303
|
}, A = (S) => {
|
|
2293
2304
|
h && S.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), u(), i.userSelect(c.annotation, ut(S))));
|
|
2294
2305
|
}, L = (S) => {
|
|
2295
|
-
const
|
|
2306
|
+
const g = () => setTimeout(() => {
|
|
2296
2307
|
(c == null ? void 0 : c.selector.length) > 0 && (i.clear(), o.addAnnotation({
|
|
2297
2308
|
id: c.annotation,
|
|
2298
2309
|
bodies: [],
|
|
2299
2310
|
target: c
|
|
2300
|
-
}), i.userSelect(c.annotation, ut(S))), document.removeEventListener("selectionchange",
|
|
2311
|
+
}), i.userSelect(c.annotation, ut(S))), document.removeEventListener("selectionchange", g);
|
|
2301
2312
|
}, 100);
|
|
2302
|
-
document.addEventListener("selectionchange",
|
|
2313
|
+
document.addEventListener("selectionchange", g), b(S);
|
|
2303
2314
|
};
|
|
2304
|
-
$(
|
|
2315
|
+
$(Lo.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
|
|
2305
2316
|
S.repeat || (l = ut(S));
|
|
2306
|
-
}), $(
|
|
2317
|
+
}), $(Re, { keydown: !0, keyup: !1 }, (S) => {
|
|
2307
2318
|
l = ut(S), L(S);
|
|
2308
2319
|
});
|
|
2309
2320
|
const R = (S) => {
|
|
2310
2321
|
S.repeat || S.target !== t && S.target !== document.body || (c = void 0, i.clear());
|
|
2311
2322
|
};
|
|
2312
|
-
return $(
|
|
2323
|
+
return $(Te.join(","), { keydown: !0, keyup: !1 }, R), document.addEventListener("pointerdown", m), document.addEventListener("pointerup", y), document.addEventListener("contextmenu", C), t.addEventListener("keyup", A), t.addEventListener("selectstart", b), document.addEventListener("selectionchange", E), {
|
|
2313
2324
|
destroy: () => {
|
|
2314
|
-
c = void 0, f = void 0, l = void 0,
|
|
2325
|
+
c = void 0, f = void 0, l = void 0, p = !1, E.clear(), document.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", y), document.removeEventListener("contextmenu", C), t.removeEventListener("keyup", A), t.removeEventListener("selectstart", b), document.removeEventListener("selectionchange", E), $.unbind();
|
|
2315
2326
|
},
|
|
2316
2327
|
setFilter: d,
|
|
2317
2328
|
setUser: r,
|
|
2318
2329
|
setAnnotatingEnabled: v
|
|
2319
2330
|
};
|
|
2320
|
-
},
|
|
2331
|
+
}, To = (t, e) => ({
|
|
2321
2332
|
...t,
|
|
2322
2333
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
2323
2334
|
user: t.user || e.user
|
|
2324
|
-
}), le = "SPANS",
|
|
2325
|
-
|
|
2326
|
-
const n =
|
|
2335
|
+
}), le = "SPANS", _o = (t, e = {}) => {
|
|
2336
|
+
Ie(t), Ne(t);
|
|
2337
|
+
const n = To(e, {
|
|
2327
2338
|
annotatingEnabled: !0,
|
|
2328
|
-
user:
|
|
2329
|
-
}), o =
|
|
2339
|
+
user: Wn()
|
|
2340
|
+
}), o = fo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Vn(r), d = Yn(o, a, n.adapter);
|
|
2330
2341
|
let c = n.user;
|
|
2331
|
-
const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : le : n.renderer || le, l = f === "SPANS" ?
|
|
2342
|
+
const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : le : n.renderer || le, l = f === "SPANS" ? pn(t, o, s) : f === "CSS_HIGHLIGHTS" ? fn(t, o, s) : f === "CANVAS" ? en(t, o, s) : void 0;
|
|
2332
2343
|
if (!l)
|
|
2333
2344
|
throw `Unknown renderer implementation: ${f}`;
|
|
2334
2345
|
console.debug(`Using ${f} renderer`), n.style && l.setStyle(n.style);
|
|
2335
|
-
const
|
|
2336
|
-
|
|
2337
|
-
const h =
|
|
2338
|
-
|
|
2346
|
+
const p = Oo(t, o, n.offsetReferenceSelector);
|
|
2347
|
+
p.setUser(c), p.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2348
|
+
const h = $n(o, a, n.adapter), v = () => c, b = (A) => {
|
|
2349
|
+
p.setAnnotatingEnabled(
|
|
2339
2350
|
A === void 0 ? !0 : A
|
|
2340
2351
|
);
|
|
2341
2352
|
}, E = (A) => {
|
|
2342
|
-
l.setFilter(A),
|
|
2353
|
+
l.setFilter(A), p.setFilter(A);
|
|
2343
2354
|
}, m = (A) => {
|
|
2344
|
-
c = A,
|
|
2355
|
+
c = A, p.setUser(A);
|
|
2345
2356
|
}, u = (A) => {
|
|
2346
|
-
A && (l.setPainter(
|
|
2357
|
+
A && (l.setPainter(go(A, n.presence)), A.on("selectionChange", () => l.redraw()));
|
|
2347
2358
|
}, y = (A) => {
|
|
2348
2359
|
A ? i.setSelected(A) : i.clear();
|
|
2349
2360
|
};
|
|
2350
2361
|
return {
|
|
2351
2362
|
...h,
|
|
2352
2363
|
destroy: () => {
|
|
2353
|
-
l.destroy(),
|
|
2364
|
+
l.destroy(), p.destroy(), a.destroy();
|
|
2354
2365
|
},
|
|
2355
2366
|
element: t,
|
|
2356
2367
|
getUser: v,
|
|
@@ -2364,7 +2375,7 @@ const ce = 300, Oe = ["up", "down", "left", "right"], Te = Ie ? "⌘+a" : "ctrl+
|
|
|
2364
2375
|
setVisible: l.setVisible.bind(l),
|
|
2365
2376
|
on: d.on,
|
|
2366
2377
|
off: d.off,
|
|
2367
|
-
scrollIntoView:
|
|
2378
|
+
scrollIntoView: ze(t, r),
|
|
2368
2379
|
state: o
|
|
2369
2380
|
};
|
|
2370
2381
|
};
|
|
@@ -2374,42 +2385,43 @@ export {
|
|
|
2374
2385
|
de as NOT_ANNOTATABLE_CLASS,
|
|
2375
2386
|
j as NOT_ANNOTATABLE_SELECTOR,
|
|
2376
2387
|
k as Origin,
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2388
|
+
xn as UserSelectAction,
|
|
2389
|
+
Io as W3CTextFormat,
|
|
2390
|
+
Ie as cancelSingleClickEvents,
|
|
2380
2391
|
ut as cloneKeyboardEvent,
|
|
2381
2392
|
Et as clonePointerEvent,
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2393
|
+
ko as createBody,
|
|
2394
|
+
en as createCanvasRenderer,
|
|
2395
|
+
fn as createHighlightsRenderer,
|
|
2396
|
+
go as createPresencePainter,
|
|
2397
|
+
un as createRenderer,
|
|
2398
|
+
Oo as createSelectionHandler,
|
|
2399
|
+
pn as createSpansRenderer,
|
|
2400
|
+
_o as createTextAnnotator,
|
|
2401
|
+
fo as createTextAnnotatorState,
|
|
2402
|
+
Bo as denormalizeRectWithOffset,
|
|
2403
|
+
To as fillDefaults,
|
|
2404
|
+
Ro as getAnnotatableFragment,
|
|
2405
|
+
Ue as getQuoteContext,
|
|
2395
2406
|
Dt as getRangeAnnotatableContents,
|
|
2396
|
-
|
|
2407
|
+
_e as isMac,
|
|
2397
2408
|
W as isRevived,
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2409
|
+
Ve as isWhitespaceOrEmpty,
|
|
2410
|
+
Xe as mergeClientRects,
|
|
2411
|
+
He as normalizeRectWithOffset,
|
|
2412
|
+
Fe as paint,
|
|
2413
|
+
to as parseW3CTextAnnotation,
|
|
2414
|
+
Ne as programmaticallyFocusable,
|
|
2415
|
+
Pe as rangeContains,
|
|
2416
|
+
$e as rangeToSelector,
|
|
2405
2417
|
xt as reviveAnnotation,
|
|
2406
2418
|
ue as reviveSelector,
|
|
2407
2419
|
wt as reviveTarget,
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2420
|
+
ze as scrollIntoView,
|
|
2421
|
+
eo as serializeW3CTextAnnotation,
|
|
2422
|
+
ke as splitAnnotatableRanges,
|
|
2423
|
+
Mo as toDomRectList,
|
|
2424
|
+
je as trimRangeToContainer,
|
|
2425
|
+
De as whitespaceOrEmptyRegex
|
|
2414
2426
|
};
|
|
2415
2427
|
//# sourceMappingURL=text-annotator.es.js.map
|