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