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