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