@soomo/text-annotator 3.0.0-staging.33 → 3.0.0-staging.35
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/state/TextAnnotationStore.d.ts +3 -0
- package/dist/src/state/spatialTree.d.ts +5 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/trimRangeToContainer.d.ts +1 -0
- package/dist/text-annotator.es.js +995 -973
- 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 +2 -1
|
@@ -4,24 +4,24 @@ const q = {
|
|
|
4
4
|
}, gt = {
|
|
5
5
|
fill: "rgb(0, 128, 255)",
|
|
6
6
|
fillOpacity: 0.45
|
|
7
|
-
},
|
|
7
|
+
}, ve = (e, t, n, o, i) => {
|
|
8
8
|
var s, a;
|
|
9
9
|
const r = n ? typeof n == "function" ? n(e.annotation, e.state, i) || ((s = e.state) != null && s.selected ? gt : q) : n : (a = e.state) != null && a.selected ? gt : q;
|
|
10
10
|
return o && o.paint(e, t) || r;
|
|
11
|
-
}, ne = "not-annotatable",
|
|
11
|
+
}, ne = "not-annotatable", X = `.${ne}`, Ce = (e) => {
|
|
12
12
|
var n;
|
|
13
13
|
const t = e.commonAncestorContainer;
|
|
14
|
-
return t instanceof HTMLElement ? !t.closest(
|
|
14
|
+
return t instanceof HTMLElement ? !t.closest(X) : !((n = t.parentElement) != null && n.closest(X));
|
|
15
15
|
}, xe = function* (e) {
|
|
16
16
|
const t = document.createNodeIterator(
|
|
17
17
|
e.commonAncestorContainer,
|
|
18
18
|
NodeFilter.SHOW_ELEMENT,
|
|
19
|
-
(o) => o instanceof HTMLElement && o.classList.contains(ne) && !o.parentElement.closest(
|
|
19
|
+
(o) => o instanceof HTMLElement && o.classList.contains(ne) && !o.parentElement.closest(X) && e.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
20
20
|
);
|
|
21
21
|
let n;
|
|
22
22
|
for (; n = t.nextNode(); )
|
|
23
23
|
n instanceof HTMLElement && (yield n);
|
|
24
|
-
},
|
|
24
|
+
}, Ee = (e) => {
|
|
25
25
|
if (!Ce(e)) return [];
|
|
26
26
|
const t = [];
|
|
27
27
|
let n = null;
|
|
@@ -34,22 +34,22 @@ const q = {
|
|
|
34
34
|
o.setStartAfter(n), o.collapsed || t.push(o);
|
|
35
35
|
}
|
|
36
36
|
return t.length > 0 ? t : [e];
|
|
37
|
-
},
|
|
37
|
+
}, kt = (e) => {
|
|
38
38
|
const t = e.cloneContents();
|
|
39
|
-
return t.querySelectorAll(
|
|
40
|
-
},
|
|
39
|
+
return t.querySelectorAll(X).forEach((n) => n.remove()), t;
|
|
40
|
+
}, Le = (e) => e.addEventListener("click", (t) => {
|
|
41
41
|
// Allow clicks within not-annotatable elements
|
|
42
|
-
!t.target.closest(
|
|
42
|
+
!t.target.closest(X) && !t.target.closest("a") && t.preventDefault();
|
|
43
43
|
}), Te = (e) => {
|
|
44
44
|
!e.hasAttribute("tabindex") && e.tabIndex < 0 && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
|
|
45
|
-
},
|
|
45
|
+
}, Nt = (e, t = 10) => {
|
|
46
46
|
let n;
|
|
47
47
|
return (...o) => {
|
|
48
48
|
clearTimeout(n), n = setTimeout(() => e.apply(void 0, o), t);
|
|
49
49
|
};
|
|
50
|
-
},
|
|
50
|
+
}, vo = (e) => {
|
|
51
51
|
const t = e.cloneContents();
|
|
52
|
-
return t.querySelectorAll(
|
|
52
|
+
return t.querySelectorAll(X).forEach((n) => n.remove()), t;
|
|
53
53
|
}, Dt = (e, t) => {
|
|
54
54
|
const n = document.createNodeIterator(t);
|
|
55
55
|
let o = 0, i = n.nextNode();
|
|
@@ -72,30 +72,30 @@ const q = {
|
|
|
72
72
|
endContainer: i,
|
|
73
73
|
endOffset: r
|
|
74
74
|
} = e, s = Array.from(t.childNodes).map((l) => {
|
|
75
|
-
const
|
|
76
|
-
return l.nodeName === "CANVAS" ? l :
|
|
77
|
-
}), a = Dt(n, t),
|
|
75
|
+
const m = l.cloneNode(!0);
|
|
76
|
+
return l.nodeName === "CANVAS" ? l : m;
|
|
77
|
+
}), a = Dt(n, t), d = Dt(i, t), f = () => {
|
|
78
78
|
const l = t;
|
|
79
79
|
l.replaceChildren(...s);
|
|
80
|
-
const
|
|
81
|
-
return e.setStart(
|
|
82
|
-
},
|
|
83
|
-
const
|
|
84
|
-
return l.surroundContents(
|
|
80
|
+
const m = yt(a, l), c = yt(d, l);
|
|
81
|
+
return e.setStart(m, o), e.setEnd(c, r), e;
|
|
82
|
+
}, g = (l) => {
|
|
83
|
+
const m = document.createElement("SPAN");
|
|
84
|
+
return l.surroundContents(m), m;
|
|
85
85
|
};
|
|
86
86
|
if (n === i)
|
|
87
87
|
throw "Not implemented";
|
|
88
88
|
{
|
|
89
89
|
const l = document.createRange();
|
|
90
90
|
l.selectNodeContents(n), l.setStart(n, o);
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
return (
|
|
91
|
+
const m = g(l), c = document.createRange();
|
|
92
|
+
c.selectNode(i), c.setEnd(i, r);
|
|
93
|
+
const S = g(c), w = Be(e).reverse().map((p) => {
|
|
94
|
+
var A;
|
|
95
|
+
const u = document.createElement("SPAN");
|
|
96
|
+
return (A = p.parentNode) == null || A.insertBefore(u, p), u.appendChild(p), u;
|
|
97
97
|
});
|
|
98
|
-
return { unwrap:
|
|
98
|
+
return { unwrap: f, nodes: [m, ...w, S] };
|
|
99
99
|
}
|
|
100
100
|
}, Be = (e) => {
|
|
101
101
|
const {
|
|
@@ -108,7 +108,7 @@ const q = {
|
|
|
108
108
|
for (; r != null; )
|
|
109
109
|
r === o && (s = !1), s && a.push(r), r === n && (s = !0), r = i.nextNode();
|
|
110
110
|
return a;
|
|
111
|
-
},
|
|
111
|
+
}, Co = (e) => {
|
|
112
112
|
const { startContainer: t, endContainer: n } = e;
|
|
113
113
|
if (t === n)
|
|
114
114
|
return Array.from(e.getClientRects());
|
|
@@ -116,17 +116,17 @@ const q = {
|
|
|
116
116
|
const { unwrap: o, nodes: i } = Me(e), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
|
|
117
117
|
return o(), r;
|
|
118
118
|
}
|
|
119
|
-
},
|
|
119
|
+
}, Re = (e, t, n = 10, o) => {
|
|
120
120
|
const i = o ? e.startContainer.parentElement.closest(o) : t, r = document.createRange();
|
|
121
121
|
r.setStart(i, 0), r.setEnd(e.startContainer, e.startOffset);
|
|
122
|
-
const s =
|
|
122
|
+
const s = kt(r).textContent, a = document.createRange();
|
|
123
123
|
a.setStart(e.endContainer, e.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
124
|
-
const
|
|
124
|
+
const d = kt(a).textContent;
|
|
125
125
|
return {
|
|
126
126
|
prefix: s.substring(s.length - n),
|
|
127
|
-
suffix:
|
|
127
|
+
suffix: d.substring(0, n)
|
|
128
128
|
};
|
|
129
|
-
},
|
|
129
|
+
}, ke = /^\s*$/, Ve = (e) => ke.test(e.toString()), z = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), Oe = (e, t) => {
|
|
130
130
|
const n = (r) => Math.round(r * 10) / 10, o = {
|
|
131
131
|
top: n(e.top),
|
|
132
132
|
bottom: n(e.bottom),
|
|
@@ -150,17 +150,17 @@ const q = {
|
|
|
150
150
|
return "block-contains";
|
|
151
151
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
152
152
|
return "block-is-contained";
|
|
153
|
-
},
|
|
153
|
+
}, Ne = (e, t) => {
|
|
154
154
|
const n = Math.min(e.left, t.left), o = Math.max(e.right, t.right), i = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom);
|
|
155
155
|
return new DOMRect(n, i, o - n, r - i);
|
|
156
|
-
},
|
|
156
|
+
}, Ie = (e) => e.reduce((t, n) => {
|
|
157
157
|
if (n.width === 0 || n.height === 0)
|
|
158
158
|
return t;
|
|
159
159
|
let o = [...t], i = !1;
|
|
160
160
|
for (const r of t) {
|
|
161
161
|
const s = Oe(n, r);
|
|
162
162
|
if (s === "inline-adjacent") {
|
|
163
|
-
o = o.map((a) => a === r ?
|
|
163
|
+
o = o.map((a) => a === r ? Ne(n, r) : a), i = !0;
|
|
164
164
|
break;
|
|
165
165
|
} else if (s === "inline-contains") {
|
|
166
166
|
o = o.map((a) => a === r ? n : a), i = !0;
|
|
@@ -174,7 +174,7 @@ const q = {
|
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
return i ? o : [...o, n];
|
|
177
|
-
}, []),
|
|
177
|
+
}, []), xo = (e) => ({
|
|
178
178
|
length: e.length,
|
|
179
179
|
item: (t) => e[t],
|
|
180
180
|
[Symbol.iterator]: function* () {
|
|
@@ -184,56 +184,59 @@ const q = {
|
|
|
184
184
|
}), Fe = (e, t, n) => {
|
|
185
185
|
const o = document.createRange(), i = n ? e.startContainer.parentElement.closest(n) : t;
|
|
186
186
|
o.setStart(i, 0), o.setEnd(e.startContainer, e.startOffset);
|
|
187
|
-
const r =
|
|
188
|
-
return n ? { quote: s, start: a, end:
|
|
187
|
+
const r = kt(o).textContent, s = e.toString(), a = r.length || 0, d = a + s.length;
|
|
188
|
+
return n ? { quote: s, start: a, end: d, range: e, offsetReference: i } : { quote: s, start: a, end: d, range: e };
|
|
189
189
|
}, oe = (e, t) => {
|
|
190
|
-
var
|
|
190
|
+
var g, l;
|
|
191
191
|
const { start: n, end: o } = e, i = e.offsetReference || t, r = document.createNodeIterator(
|
|
192
192
|
t,
|
|
193
193
|
NodeFilter.SHOW_TEXT,
|
|
194
|
-
(
|
|
195
|
-
var
|
|
196
|
-
return (
|
|
194
|
+
(m) => {
|
|
195
|
+
var c;
|
|
196
|
+
return (c = m.parentElement) != null && c.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
197
197
|
}
|
|
198
198
|
);
|
|
199
199
|
let s = 0;
|
|
200
200
|
const a = document.createRange();
|
|
201
|
-
let
|
|
202
|
-
|
|
203
|
-
let
|
|
204
|
-
for (;
|
|
205
|
-
if (
|
|
206
|
-
const
|
|
207
|
-
if (s +
|
|
208
|
-
a.setStart(
|
|
201
|
+
let d = r.nextNode();
|
|
202
|
+
d === null && console.error("Could not revive annotation target. Content missing.");
|
|
203
|
+
let f = !i;
|
|
204
|
+
for (; d !== null; ) {
|
|
205
|
+
if (f || (f = i == null ? void 0 : i.contains(d)), f) {
|
|
206
|
+
const m = ((g = d.textContent) == null ? void 0 : g.length) || 0;
|
|
207
|
+
if (s + m > n) {
|
|
208
|
+
a.setStart(d, n - s);
|
|
209
209
|
break;
|
|
210
210
|
}
|
|
211
|
-
s +=
|
|
211
|
+
s += m;
|
|
212
212
|
}
|
|
213
|
-
|
|
213
|
+
d = r.nextNode();
|
|
214
214
|
}
|
|
215
|
-
for (;
|
|
216
|
-
const
|
|
217
|
-
if (s +
|
|
218
|
-
a.setEnd(
|
|
215
|
+
for (; d !== null; ) {
|
|
216
|
+
const m = ((l = d.textContent) == null ? void 0 : l.length) || 0;
|
|
217
|
+
if (s + m >= o) {
|
|
218
|
+
a.setEnd(d, o - s);
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
|
-
s +=
|
|
221
|
+
s += m, d = r.nextNode();
|
|
222
222
|
}
|
|
223
223
|
return {
|
|
224
224
|
...e,
|
|
225
225
|
range: a
|
|
226
226
|
};
|
|
227
|
-
}, mt = (e, t) =>
|
|
227
|
+
}, mt = (e, t) => z(e.selector) ? e : {
|
|
228
228
|
...e,
|
|
229
229
|
selector: e.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : oe(n, t))
|
|
230
|
-
}, bt = (e, t) =>
|
|
230
|
+
}, bt = (e, t) => z(e.target.selector) ? e : { ...e, target: mt(e.target, t) }, Pe = (e, t) => {
|
|
231
|
+
const n = e.cloneRange();
|
|
232
|
+
return t.contains(n.startContainer) || n.setStart(t, 0), t.contains(n.endContainer) || n.setEnd(t, t.childNodes.length), n;
|
|
233
|
+
}, De = (e, t) => {
|
|
231
234
|
const { left: n, top: o, right: i, bottom: r } = e;
|
|
232
235
|
return new DOMRect(n - t.left, o - t.top, i - n, r - o);
|
|
233
|
-
},
|
|
236
|
+
}, Eo = (e, t) => {
|
|
234
237
|
const { left: n, top: o, right: i, bottom: r } = e;
|
|
235
238
|
return new DOMRect(n + t.left, o + t.top, i - n, r - o);
|
|
236
|
-
},
|
|
239
|
+
}, ye = (e) => ({
|
|
237
240
|
...e,
|
|
238
241
|
type: e.type,
|
|
239
242
|
x: e.x,
|
|
@@ -259,7 +262,7 @@ const q = {
|
|
|
259
262
|
pointerId: e.pointerId,
|
|
260
263
|
pointerType: e.pointerType,
|
|
261
264
|
timeStamp: e.timeStamp
|
|
262
|
-
}),
|
|
265
|
+
}), Ue = (e) => ({
|
|
263
266
|
...e,
|
|
264
267
|
type: e.type,
|
|
265
268
|
key: e.key,
|
|
@@ -275,95 +278,95 @@ const q = {
|
|
|
275
278
|
defaultPrevented: e.defaultPrevented,
|
|
276
279
|
detail: e.detail,
|
|
277
280
|
timeStamp: e.timeStamp
|
|
278
|
-
}),
|
|
279
|
-
const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n,
|
|
280
|
-
return { top: t, left: n, minX: r, minY: s, maxX: a, maxY:
|
|
281
|
-
},
|
|
281
|
+
}), He = (e) => {
|
|
282
|
+
const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n, d = i - t;
|
|
283
|
+
return { top: t, left: n, minX: r, minY: s, maxX: a, maxY: d };
|
|
284
|
+
}, _e = (e) => {
|
|
282
285
|
let t = /* @__PURE__ */ new Set();
|
|
283
286
|
return (o) => {
|
|
284
287
|
const i = o.map((r) => r.id);
|
|
285
288
|
(t.size !== i.length || i.some((r) => !t.has(r))) && e.set(i), t = new Set(i);
|
|
286
289
|
};
|
|
287
|
-
},
|
|
290
|
+
}, It = (e, t, n, o) => {
|
|
288
291
|
const { store: i, selection: r, hover: s } = t;
|
|
289
|
-
let a,
|
|
290
|
-
const
|
|
291
|
-
const { x:
|
|
292
|
-
|
|
292
|
+
let a, d, f;
|
|
293
|
+
const g = _e(n), l = (T) => {
|
|
294
|
+
const { x: B, y: b } = e.getBoundingClientRect(), C = i.getAt(T.clientX - B, T.clientY - b, d);
|
|
295
|
+
C ? s.current !== C.id && (e.classList.add("hovered"), s.set(C.id)) : s.current && (e.classList.remove("hovered"), s.set(null));
|
|
293
296
|
};
|
|
294
297
|
e.addEventListener("pointermove", l);
|
|
295
|
-
const
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
const Ae = I.includes(
|
|
299
|
-
return { annotation:
|
|
298
|
+
const m = (T = !1) => {
|
|
299
|
+
f && f.clear();
|
|
300
|
+
const B = He(e), { minX: b, minY: C, maxX: x, maxY: L } = B, R = d ? i.getIntersecting(b, C, x, L).filter(({ annotation: j }) => d(j)) : i.getIntersecting(b, C, x, L), I = r.selected.map(({ id: j }) => j), _ = R.map(({ annotation: j, rects: we }) => {
|
|
301
|
+
const Ae = I.includes(j.id), Se = j.id === s.current;
|
|
302
|
+
return { annotation: j, rects: we, state: { selected: Ae, hover: Se } };
|
|
300
303
|
});
|
|
301
|
-
o.redraw(
|
|
302
|
-
},
|
|
303
|
-
|
|
304
|
-
},
|
|
305
|
-
a =
|
|
306
|
-
},
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
i.observe(
|
|
310
|
-
const
|
|
311
|
-
document.addEventListener("scroll",
|
|
312
|
-
const
|
|
313
|
-
i.recalculatePositions(),
|
|
304
|
+
o.redraw(_, B, a, f, T), setTimeout(() => g(R.map(({ annotation: j }) => j)), 1);
|
|
305
|
+
}, c = (T) => {
|
|
306
|
+
f = T, m();
|
|
307
|
+
}, S = (T) => {
|
|
308
|
+
a = T, m();
|
|
309
|
+
}, v = (T) => {
|
|
310
|
+
d = T, m(!1);
|
|
311
|
+
}, w = () => m();
|
|
312
|
+
i.observe(w);
|
|
313
|
+
const p = r.subscribe(() => m()), u = () => m(!0);
|
|
314
|
+
document.addEventListener("scroll", u, { capture: !0, passive: !0 });
|
|
315
|
+
const A = Nt(() => {
|
|
316
|
+
i.recalculatePositions(), f && f.reset(), m();
|
|
314
317
|
});
|
|
315
|
-
window.addEventListener("resize",
|
|
316
|
-
const
|
|
317
|
-
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
window.addEventListener("resize", A);
|
|
319
|
+
const h = new ResizeObserver(A);
|
|
320
|
+
h.observe(e);
|
|
321
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, M = new MutationObserver((T) => {
|
|
322
|
+
T.every((b) => b.target === e || e.contains(b.target)) || m(!0);
|
|
320
323
|
});
|
|
321
|
-
return
|
|
324
|
+
return M.observe(document.body, E), {
|
|
322
325
|
destroy: () => {
|
|
323
|
-
e.removeEventListener("pointermove", l), o.destroy(), i.unobserve(
|
|
326
|
+
e.removeEventListener("pointermove", l), o.destroy(), i.unobserve(w), p(), document.removeEventListener("scroll", u), window.removeEventListener("resize", A), h.disconnect(), M.disconnect();
|
|
324
327
|
},
|
|
325
|
-
redraw:
|
|
326
|
-
setStyle:
|
|
327
|
-
setFilter:
|
|
328
|
-
setPainter:
|
|
328
|
+
redraw: m,
|
|
329
|
+
setStyle: S,
|
|
330
|
+
setFilter: v,
|
|
331
|
+
setPainter: c,
|
|
329
332
|
setVisible: o.setVisible
|
|
330
333
|
};
|
|
331
|
-
},
|
|
334
|
+
}, Ye = () => {
|
|
332
335
|
const e = document.createElement("canvas");
|
|
333
336
|
return e.width = window.innerWidth, e.height = window.innerHeight, e.className = "r6o-canvas-highlight-layer bg", e;
|
|
334
|
-
},
|
|
337
|
+
}, Xe = (e, t) => {
|
|
335
338
|
e.width = window.innerWidth, e.height = window.innerHeight;
|
|
336
|
-
},
|
|
339
|
+
}, $e = (e) => {
|
|
337
340
|
e.classList.add("r6o-annotatable");
|
|
338
|
-
const t =
|
|
341
|
+
const t = Ye(), n = t.getContext("2d");
|
|
339
342
|
document.body.appendChild(t);
|
|
340
|
-
const o = (a,
|
|
341
|
-
const { width: l, height:
|
|
342
|
-
n.clearRect(-0.5, -0.5, l + 1,
|
|
343
|
-
const { top:
|
|
344
|
-
[...a].sort((
|
|
345
|
-
const { annotation: { target: { created:
|
|
346
|
-
return
|
|
347
|
-
}).forEach((
|
|
348
|
-
var
|
|
349
|
-
const
|
|
350
|
-
x:
|
|
351
|
-
y:
|
|
343
|
+
const o = (a, d, f, g) => requestAnimationFrame(() => {
|
|
344
|
+
const { width: l, height: m } = t;
|
|
345
|
+
n.clearRect(-0.5, -0.5, l + 1, m + 1), g && g.clear();
|
|
346
|
+
const { top: c, left: S } = d;
|
|
347
|
+
[...a].sort((w, p) => {
|
|
348
|
+
const { annotation: { target: { created: u } } } = w, { annotation: { target: { created: A } } } = p;
|
|
349
|
+
return u.getTime() - A.getTime();
|
|
350
|
+
}).forEach((w) => {
|
|
351
|
+
var h;
|
|
352
|
+
const p = f ? typeof f == "function" ? f(w.annotation, w.state) : f : (h = w.state) != null && h.selected ? gt : q, u = g && g.paint(w, d) || p, A = w.rects.map(({ x: E, y: M, width: k, height: T }) => ({
|
|
353
|
+
x: E + S,
|
|
354
|
+
y: M + c,
|
|
352
355
|
width: k,
|
|
353
|
-
height:
|
|
356
|
+
height: T
|
|
354
357
|
}));
|
|
355
|
-
if (n.fillStyle =
|
|
356
|
-
({ x:
|
|
357
|
-
),
|
|
358
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
n.beginPath(), n.moveTo(
|
|
358
|
+
if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, A.forEach(
|
|
359
|
+
({ x: E, y: M, width: k, height: T }) => n.fillRect(E, M, k, T)
|
|
360
|
+
), u.underlineColor) {
|
|
361
|
+
n.globalAlpha = 1, n.strokeStyle = u.underlineColor, n.lineWidth = u.underlineThickness ?? 1;
|
|
362
|
+
const E = u.underlineOffset ?? 0;
|
|
363
|
+
A.forEach(({ x: M, y: k, width: T, height: B }) => {
|
|
364
|
+
n.beginPath(), n.moveTo(M, k + B + E), n.lineTo(M + T, k + B + E), n.stroke();
|
|
362
365
|
});
|
|
363
366
|
}
|
|
364
367
|
});
|
|
365
|
-
}), i =
|
|
366
|
-
|
|
368
|
+
}), i = Nt(() => {
|
|
369
|
+
Xe(t);
|
|
367
370
|
});
|
|
368
371
|
return window.addEventListener("resize", i), {
|
|
369
372
|
destroy: () => {
|
|
@@ -374,10 +377,10 @@ const q = {
|
|
|
374
377
|
},
|
|
375
378
|
redraw: o
|
|
376
379
|
};
|
|
377
|
-
},
|
|
378
|
-
var
|
|
380
|
+
}, je = (e, t, n) => It(e, t, n, $e(e));
|
|
381
|
+
var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
|
|
379
382
|
return typeof e == "string" ? e.length > 0 : typeof e == "number";
|
|
380
|
-
},
|
|
383
|
+
}, F = function(e, t, n) {
|
|
381
384
|
return t === void 0 && (t = 0), n === void 0 && (n = Math.pow(10, t)), Math.round(n * e) / n + 0;
|
|
382
385
|
}, H = function(e, t, n) {
|
|
383
386
|
return t === void 0 && (t = 0), n === void 0 && (n = 1), e > n ? n : e > t ? e : t;
|
|
@@ -386,8 +389,8 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
386
389
|
}, Ut = function(e) {
|
|
387
390
|
return { r: H(e.r, 0, 255), g: H(e.g, 0, 255), b: H(e.b, 0, 255), a: H(e.a) };
|
|
388
391
|
}, wt = function(e) {
|
|
389
|
-
return { r:
|
|
390
|
-
},
|
|
392
|
+
return { r: F(e.r), g: F(e.g), b: F(e.b), a: F(e.a, 3) };
|
|
393
|
+
}, We = /^#([0-9a-f]{3,8})$/i, ct = function(e) {
|
|
391
394
|
var t = e.toString(16);
|
|
392
395
|
return t.length < 2 ? "0" + t : t;
|
|
393
396
|
}, re = function(e) {
|
|
@@ -396,40 +399,40 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
396
399
|
}, ae = function(e) {
|
|
397
400
|
var t = e.h, n = e.s, o = e.v, i = e.a;
|
|
398
401
|
t = t / 360 * 6, n /= 100, o /= 100;
|
|
399
|
-
var r = Math.floor(t), s = o * (1 - n), a = o * (1 - (t - r) * n),
|
|
400
|
-
return { r: 255 * [o, a, s, s,
|
|
402
|
+
var r = Math.floor(t), s = o * (1 - n), a = o * (1 - (t - r) * n), d = o * (1 - (1 - t + r) * n), f = r % 6;
|
|
403
|
+
return { r: 255 * [o, a, s, s, d, o][f], g: 255 * [d, o, o, a, s, s][f], b: 255 * [s, s, d, o, o, a][f], a: i };
|
|
401
404
|
}, Ht = function(e) {
|
|
402
405
|
return { h: ie(e.h), s: H(e.s, 0, 100), l: H(e.l, 0, 100), a: H(e.a) };
|
|
403
406
|
}, _t = function(e) {
|
|
404
|
-
return { h:
|
|
407
|
+
return { h: F(e.h), s: F(e.s), l: F(e.l), a: F(e.a, 3) };
|
|
405
408
|
}, Yt = function(e) {
|
|
406
409
|
return ae((n = (t = e).s, { h: t.h, s: (n *= ((o = t.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: t.a }));
|
|
407
410
|
var t, n, o;
|
|
408
411
|
}, it = function(e) {
|
|
409
412
|
return { h: (t = re(e)).h, s: (i = (200 - (n = t.s)) * (o = t.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: t.a };
|
|
410
413
|
var t, n, o, i;
|
|
411
|
-
},
|
|
412
|
-
var t =
|
|
413
|
-
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ?
|
|
414
|
+
}, ze = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ze = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Je = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Xt = { string: [[function(e) {
|
|
415
|
+
var t = We.exec(e);
|
|
416
|
+
return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? F(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? F(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
414
417
|
}, "hex"], [function(e) {
|
|
415
|
-
var t =
|
|
418
|
+
var t = Ze.exec(e) || Je.exec(e);
|
|
416
419
|
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Ut({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
|
|
417
420
|
}, "rgb"], [function(e) {
|
|
418
|
-
var t =
|
|
421
|
+
var t = ze.exec(e) || qe.exec(e);
|
|
419
422
|
if (!t) return null;
|
|
420
|
-
var n, o, i = Ht({ h: (n = t[1], o = t[2], o === void 0 && (o = "deg"), Number(n) * (
|
|
423
|
+
var n, o, i = Ht({ h: (n = t[1], o = t[2], o === void 0 && (o = "deg"), Number(n) * (Ge[o] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
|
|
421
424
|
return Yt(i);
|
|
422
425
|
}, "hsl"]], object: [[function(e) {
|
|
423
426
|
var t = e.r, n = e.g, o = e.b, i = e.a, r = i === void 0 ? 1 : i;
|
|
424
|
-
return
|
|
427
|
+
return G(t) && G(n) && G(o) ? Ut({ r: Number(t), g: Number(n), b: Number(o), a: Number(r) }) : null;
|
|
425
428
|
}, "rgb"], [function(e) {
|
|
426
429
|
var t = e.h, n = e.s, o = e.l, i = e.a, r = i === void 0 ? 1 : i;
|
|
427
|
-
if (!
|
|
430
|
+
if (!G(t) || !G(n) || !G(o)) return null;
|
|
428
431
|
var s = Ht({ h: Number(t), s: Number(n), l: Number(o), a: Number(r) });
|
|
429
432
|
return Yt(s);
|
|
430
433
|
}, "hsl"], [function(e) {
|
|
431
434
|
var t = e.h, n = e.s, o = e.v, i = e.a, r = i === void 0 ? 1 : i;
|
|
432
|
-
if (!
|
|
435
|
+
if (!G(t) || !G(n) || !G(o)) return null;
|
|
433
436
|
var s = function(a) {
|
|
434
437
|
return { h: ie(a.h), s: H(a.s, 0, 100), v: H(a.v, 0, 100), a: H(a.a) };
|
|
435
438
|
}({ h: Number(t), s: Number(n), v: Number(o), a: Number(r) });
|
|
@@ -440,30 +443,30 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
440
443
|
if (o) return [o, t[n][1]];
|
|
441
444
|
}
|
|
442
445
|
return [null, void 0];
|
|
443
|
-
},
|
|
446
|
+
}, Qe = function(e) {
|
|
444
447
|
return typeof e == "string" ? $t(e.trim(), Xt.string) : typeof e == "object" && e !== null ? $t(e, Xt.object) : [null, void 0];
|
|
445
448
|
}, At = function(e, t) {
|
|
446
449
|
var n = it(e);
|
|
447
450
|
return { h: n.h, s: H(n.s + 100 * t, 0, 100), l: n.l, a: n.a };
|
|
448
|
-
},
|
|
451
|
+
}, St = function(e) {
|
|
449
452
|
return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
|
|
450
453
|
}, jt = function(e, t) {
|
|
451
454
|
var n = it(e);
|
|
452
455
|
return { h: n.h, s: n.s, l: H(n.l + 100 * t, 0, 100), a: n.a };
|
|
453
456
|
}, Gt = function() {
|
|
454
457
|
function e(t) {
|
|
455
|
-
this.parsed =
|
|
458
|
+
this.parsed = Qe(t)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
456
459
|
}
|
|
457
460
|
return e.prototype.isValid = function() {
|
|
458
461
|
return this.parsed !== null;
|
|
459
462
|
}, e.prototype.brightness = function() {
|
|
460
|
-
return
|
|
463
|
+
return F(St(this.rgba), 2);
|
|
461
464
|
}, e.prototype.isDark = function() {
|
|
462
|
-
return
|
|
465
|
+
return St(this.rgba) < 0.5;
|
|
463
466
|
}, e.prototype.isLight = function() {
|
|
464
|
-
return
|
|
467
|
+
return St(this.rgba) >= 0.5;
|
|
465
468
|
}, e.prototype.toHex = function() {
|
|
466
|
-
return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(
|
|
469
|
+
return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(F(255 * r)) : "", "#" + ct(n) + ct(o) + ct(i) + s;
|
|
467
470
|
var t, n, o, i, r, s;
|
|
468
471
|
}, e.prototype.toRgb = function() {
|
|
469
472
|
return wt(this.rgba);
|
|
@@ -476,42 +479,42 @@ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(e) {
|
|
|
476
479
|
return t = _t(it(this.rgba)), n = t.h, o = t.s, i = t.l, (r = t.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
477
480
|
var t, n, o, i, r;
|
|
478
481
|
}, e.prototype.toHsv = function() {
|
|
479
|
-
return t = re(this.rgba), { h:
|
|
482
|
+
return t = re(this.rgba), { h: F(t.h), s: F(t.s), v: F(t.v), a: F(t.a, 3) };
|
|
480
483
|
var t;
|
|
481
484
|
}, e.prototype.invert = function() {
|
|
482
|
-
return
|
|
485
|
+
return Y({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
|
|
483
486
|
var t;
|
|
484
487
|
}, e.prototype.saturate = function(t) {
|
|
485
|
-
return t === void 0 && (t = 0.1),
|
|
488
|
+
return t === void 0 && (t = 0.1), Y(At(this.rgba, t));
|
|
486
489
|
}, e.prototype.desaturate = function(t) {
|
|
487
|
-
return t === void 0 && (t = 0.1),
|
|
490
|
+
return t === void 0 && (t = 0.1), Y(At(this.rgba, -t));
|
|
488
491
|
}, e.prototype.grayscale = function() {
|
|
489
|
-
return
|
|
492
|
+
return Y(At(this.rgba, -1));
|
|
490
493
|
}, e.prototype.lighten = function(t) {
|
|
491
|
-
return t === void 0 && (t = 0.1),
|
|
494
|
+
return t === void 0 && (t = 0.1), Y(jt(this.rgba, t));
|
|
492
495
|
}, e.prototype.darken = function(t) {
|
|
493
|
-
return t === void 0 && (t = 0.1),
|
|
496
|
+
return t === void 0 && (t = 0.1), Y(jt(this.rgba, -t));
|
|
494
497
|
}, e.prototype.rotate = function(t) {
|
|
495
498
|
return t === void 0 && (t = 15), this.hue(this.hue() + t);
|
|
496
499
|
}, e.prototype.alpha = function(t) {
|
|
497
|
-
return typeof t == "number" ?
|
|
500
|
+
return typeof t == "number" ? Y({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) : F(this.rgba.a, 3);
|
|
498
501
|
var n;
|
|
499
502
|
}, e.prototype.hue = function(t) {
|
|
500
503
|
var n = it(this.rgba);
|
|
501
|
-
return typeof t == "number" ?
|
|
504
|
+
return typeof t == "number" ? Y({ h: t, s: n.s, l: n.l, a: n.a }) : F(n.h);
|
|
502
505
|
}, e.prototype.isEqual = function(t) {
|
|
503
|
-
return this.toHex() ===
|
|
506
|
+
return this.toHex() === Y(t).toHex();
|
|
504
507
|
}, e;
|
|
505
|
-
}(),
|
|
508
|
+
}(), Y = function(e) {
|
|
506
509
|
return e instanceof Gt ? e : new Gt(e);
|
|
507
510
|
};
|
|
508
|
-
const
|
|
509
|
-
`background-color:${
|
|
511
|
+
const Ke = (e) => [
|
|
512
|
+
`background-color:${Y((e == null ? void 0 : e.fill) || q.fill).alpha((e == null ? void 0 : e.fillOpacity) === void 0 ? q.fillOpacity : e.fillOpacity).toHex()}`,
|
|
510
513
|
e != null && e.underlineThickness ? "text-decoration:underline" : void 0,
|
|
511
514
|
e != null && e.underlineColor ? `text-decoration-color:${e.underlineColor}` : void 0,
|
|
512
515
|
e != null && e.underlineOffset ? `text-underline-offset:${e.underlineOffset}px` : void 0,
|
|
513
516
|
e != null && e.underlineThickness ? `text-decoration-thickness:${e.underlineThickness}px` : void 0
|
|
514
|
-
].filter(Boolean).join(";"),
|
|
517
|
+
].filter(Boolean).join(";"), tn = () => {
|
|
515
518
|
const e = document.createElement("style");
|
|
516
519
|
document.getElementsByTagName("head")[0].appendChild(e);
|
|
517
520
|
let t = /* @__PURE__ */ new Set();
|
|
@@ -522,23 +525,23 @@ const Qe = (e) => [
|
|
|
522
525
|
setVisible: (r) => {
|
|
523
526
|
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
524
527
|
},
|
|
525
|
-
redraw: (r, s, a,
|
|
526
|
-
|
|
527
|
-
const
|
|
528
|
-
Array.from(t).filter((l) => !
|
|
529
|
-
const
|
|
530
|
-
var
|
|
531
|
-
const
|
|
532
|
-
return `::highlight(_${l.annotation.id}) { ${
|
|
528
|
+
redraw: (r, s, a, d) => {
|
|
529
|
+
d && d.clear();
|
|
530
|
+
const f = new Set(r.map((l) => l.annotation.id));
|
|
531
|
+
Array.from(t).filter((l) => !f.has(l));
|
|
532
|
+
const g = r.map((l) => {
|
|
533
|
+
var S;
|
|
534
|
+
const m = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (S = l.state) != null && S.selected ? gt : q, c = d && d.paint(l, s) || m;
|
|
535
|
+
return `::highlight(_${l.annotation.id}) { ${Ke(c)} }`;
|
|
533
536
|
});
|
|
534
|
-
e.innerHTML =
|
|
537
|
+
e.innerHTML = g.join(`
|
|
535
538
|
`), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
|
|
536
|
-
const
|
|
537
|
-
CSS.highlights.set(`_${l.id}`,
|
|
538
|
-
}), t =
|
|
539
|
+
const m = l.target.selector.map((S) => S.range), c = new Highlight(...m);
|
|
540
|
+
CSS.highlights.set(`_${l.id}`, c);
|
|
541
|
+
}), t = f;
|
|
539
542
|
}
|
|
540
543
|
};
|
|
541
|
-
},
|
|
544
|
+
}, en = (e, t, n) => It(e, t, n, tn());
|
|
542
545
|
var Wt = Object.prototype.hasOwnProperty;
|
|
543
546
|
function Vt(e, t) {
|
|
544
547
|
var n, o;
|
|
@@ -560,10 +563,10 @@ function Vt(e, t) {
|
|
|
560
563
|
}
|
|
561
564
|
return e !== e && t !== t;
|
|
562
565
|
}
|
|
563
|
-
const
|
|
566
|
+
const nn = (e, t) => {
|
|
564
567
|
const n = (r, s) => r.x <= s.x + s.width && r.x + r.width >= s.x && r.y <= s.y + s.height && r.y + r.height >= s.y, o = (r) => r.rects.reduce((s, a) => s + a.width, 0), i = t.filter(({ rects: r }) => r.some((s) => n(e, s)));
|
|
565
568
|
return i.sort((r, s) => o(s) - o(r)), i.findIndex((r) => r.rects.includes(e));
|
|
566
|
-
},
|
|
569
|
+
}, on = (e) => {
|
|
567
570
|
e.classList.add("r6o-annotatable");
|
|
568
571
|
const t = document.createElement("div");
|
|
569
572
|
t.className = "r6o-span-highlight-layer", e.insertBefore(t, e.firstChild);
|
|
@@ -572,14 +575,14 @@ const en = (e, t) => {
|
|
|
572
575
|
destroy: () => {
|
|
573
576
|
t.remove();
|
|
574
577
|
},
|
|
575
|
-
redraw: (s, a,
|
|
576
|
-
const
|
|
577
|
-
!
|
|
578
|
-
|
|
579
|
-
const
|
|
580
|
-
if (
|
|
581
|
-
const
|
|
582
|
-
|
|
578
|
+
redraw: (s, a, d, f, g) => {
|
|
579
|
+
const m = !(Vt(n, s) && g);
|
|
580
|
+
!f && !m || (m && (t.innerHTML = ""), s.forEach((c) => {
|
|
581
|
+
c.rects.map((S) => {
|
|
582
|
+
const v = nn(S, s), w = ve(c, a, d, f, v);
|
|
583
|
+
if (m) {
|
|
584
|
+
const p = document.createElement("span");
|
|
585
|
+
p.className = "r6o-annotation", p.dataset.annotation = c.annotation.id, p.style.left = `${S.x}px`, p.style.top = `${S.y}px`, p.style.width = `${S.width}px`, p.style.height = `${S.height}px`, p.style.backgroundColor = Y((w == null ? void 0 : w.fill) || q.fill).alpha((w == null ? void 0 : w.fillOpacity) === void 0 ? q.fillOpacity : w.fillOpacity).toHex(), w.underlineStyle && (p.style.borderStyle = w.underlineStyle), w.underlineColor && (p.style.borderColor = w.underlineColor), w.underlineThickness && (p.style.borderBottomWidth = `${w.underlineThickness}px`), w.underlineOffset && (p.style.paddingBottom = `${w.underlineOffset}px`), t.appendChild(p);
|
|
583
586
|
}
|
|
584
587
|
});
|
|
585
588
|
}), n = s);
|
|
@@ -588,29 +591,29 @@ const en = (e, t) => {
|
|
|
588
591
|
s ? t.classList.remove("hidden") : t.classList.add("hidden");
|
|
589
592
|
}
|
|
590
593
|
};
|
|
591
|
-
},
|
|
592
|
-
var
|
|
593
|
-
for (var
|
|
594
|
-
|
|
595
|
-
function
|
|
596
|
-
return (
|
|
594
|
+
}, rn = (e, t, n) => It(e, t, n, on(e));
|
|
595
|
+
var P = [];
|
|
596
|
+
for (var vt = 0; vt < 256; ++vt)
|
|
597
|
+
P.push((vt + 256).toString(16).slice(1));
|
|
598
|
+
function an(e, t = 0) {
|
|
599
|
+
return (P[e[t + 0]] + P[e[t + 1]] + P[e[t + 2]] + P[e[t + 3]] + "-" + P[e[t + 4]] + P[e[t + 5]] + "-" + P[e[t + 6]] + P[e[t + 7]] + "-" + P[e[t + 8]] + P[e[t + 9]] + "-" + P[e[t + 10]] + P[e[t + 11]] + P[e[t + 12]] + P[e[t + 13]] + P[e[t + 14]] + P[e[t + 15]]).toLowerCase();
|
|
597
600
|
}
|
|
598
|
-
var dt,
|
|
599
|
-
function
|
|
601
|
+
var dt, sn = new Uint8Array(16);
|
|
602
|
+
function ln() {
|
|
600
603
|
if (!dt && (dt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !dt))
|
|
601
604
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
602
|
-
return dt(
|
|
605
|
+
return dt(sn);
|
|
603
606
|
}
|
|
604
|
-
var
|
|
607
|
+
var cn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
605
608
|
const zt = {
|
|
606
|
-
randomUUID:
|
|
609
|
+
randomUUID: cn
|
|
607
610
|
};
|
|
608
611
|
function se(e, t, n) {
|
|
609
612
|
if (zt.randomUUID && !t && !e)
|
|
610
613
|
return zt.randomUUID();
|
|
611
614
|
e = e || {};
|
|
612
|
-
var o = e.random || (e.rng ||
|
|
613
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
615
|
+
var o = e.random || (e.rng || ln)();
|
|
616
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, an(o);
|
|
614
617
|
}
|
|
615
618
|
var qt = Object.prototype.hasOwnProperty;
|
|
616
619
|
function K(e, t) {
|
|
@@ -635,7 +638,7 @@ function K(e, t) {
|
|
|
635
638
|
}
|
|
636
639
|
function Ct() {
|
|
637
640
|
}
|
|
638
|
-
function
|
|
641
|
+
function dn(e, t) {
|
|
639
642
|
return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
|
|
640
643
|
}
|
|
641
644
|
const Z = [];
|
|
@@ -643,13 +646,13 @@ function Ft(e, t = Ct) {
|
|
|
643
646
|
let n;
|
|
644
647
|
const o = /* @__PURE__ */ new Set();
|
|
645
648
|
function i(a) {
|
|
646
|
-
if (
|
|
647
|
-
const
|
|
648
|
-
for (const
|
|
649
|
-
|
|
650
|
-
if (
|
|
651
|
-
for (let
|
|
652
|
-
Z[
|
|
649
|
+
if (dn(e, a) && (e = a, n)) {
|
|
650
|
+
const d = !Z.length;
|
|
651
|
+
for (const f of o)
|
|
652
|
+
f[1](), Z.push(f, e);
|
|
653
|
+
if (d) {
|
|
654
|
+
for (let f = 0; f < Z.length; f += 2)
|
|
655
|
+
Z[f][0](Z[f + 1]);
|
|
653
656
|
Z.length = 0;
|
|
654
657
|
}
|
|
655
658
|
}
|
|
@@ -657,15 +660,15 @@ function Ft(e, t = Ct) {
|
|
|
657
660
|
function r(a) {
|
|
658
661
|
i(a(e));
|
|
659
662
|
}
|
|
660
|
-
function s(a,
|
|
661
|
-
const
|
|
662
|
-
return o.add(
|
|
663
|
-
o.delete(
|
|
663
|
+
function s(a, d = Ct) {
|
|
664
|
+
const f = [a, d];
|
|
665
|
+
return o.add(f), o.size === 1 && (n = t(i, r) || Ct), a(e), () => {
|
|
666
|
+
o.delete(f), o.size === 0 && n && (n(), n = null);
|
|
664
667
|
};
|
|
665
668
|
}
|
|
666
669
|
return { set: i, update: r, subscribe: s };
|
|
667
670
|
}
|
|
668
|
-
const
|
|
671
|
+
const un = (e) => {
|
|
669
672
|
const { subscribe: t, set: n } = Ft();
|
|
670
673
|
let o;
|
|
671
674
|
return t((i) => o = i), e.observe(({ changes: i }) => {
|
|
@@ -682,51 +685,51 @@ const dn = (e) => {
|
|
|
682
685
|
set: n
|
|
683
686
|
};
|
|
684
687
|
};
|
|
685
|
-
var
|
|
686
|
-
const xt = { selected: [] },
|
|
688
|
+
var fn = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(fn || {});
|
|
689
|
+
const xt = { selected: [] }, pn = (e, t = "EDIT") => {
|
|
687
690
|
const { subscribe: n, set: o } = Ft(xt);
|
|
688
691
|
let i = t, r = xt;
|
|
689
|
-
n((
|
|
692
|
+
n((c) => r = c);
|
|
690
693
|
const s = () => o(xt), a = () => {
|
|
691
|
-
var
|
|
692
|
-
return ((
|
|
693
|
-
},
|
|
694
|
+
var c;
|
|
695
|
+
return ((c = r.selected) == null ? void 0 : c.length) === 0;
|
|
696
|
+
}, d = (c) => {
|
|
694
697
|
if (a())
|
|
695
698
|
return !1;
|
|
696
|
-
const
|
|
697
|
-
return r.selected.some((
|
|
698
|
-
},
|
|
699
|
-
const
|
|
700
|
-
if (!
|
|
701
|
-
console.warn("Invalid selection: " +
|
|
699
|
+
const S = typeof c == "string" ? c : c.id;
|
|
700
|
+
return r.selected.some((v) => v.id === S);
|
|
701
|
+
}, f = (c, S) => {
|
|
702
|
+
const v = e.getAnnotation(c);
|
|
703
|
+
if (!v) {
|
|
704
|
+
console.warn("Invalid selection: " + c);
|
|
702
705
|
return;
|
|
703
706
|
}
|
|
704
|
-
switch (Zt(
|
|
707
|
+
switch (Zt(v, i)) {
|
|
705
708
|
case "EDIT":
|
|
706
|
-
o({ selected: [{ id:
|
|
709
|
+
o({ selected: [{ id: c, editable: !0 }], event: S });
|
|
707
710
|
break;
|
|
708
711
|
case "SELECT":
|
|
709
|
-
o({ selected: [{ id:
|
|
712
|
+
o({ selected: [{ id: c }], event: S });
|
|
710
713
|
break;
|
|
711
714
|
default:
|
|
712
|
-
o({ selected: [], event:
|
|
715
|
+
o({ selected: [], event: S });
|
|
713
716
|
}
|
|
714
|
-
},
|
|
715
|
-
const
|
|
717
|
+
}, g = (c, S) => {
|
|
718
|
+
const v = Array.isArray(c) ? c : [c], w = v.map((p) => e.getAnnotation(p)).filter((p) => !!p);
|
|
716
719
|
o({
|
|
717
|
-
selected:
|
|
718
|
-
const
|
|
719
|
-
return { id:
|
|
720
|
+
selected: w.map((p) => {
|
|
721
|
+
const u = S === void 0 ? Zt(p, i) === "EDIT" : S;
|
|
722
|
+
return { id: p.id, editable: u };
|
|
720
723
|
})
|
|
721
|
-
}),
|
|
722
|
-
}, l = (
|
|
724
|
+
}), w.length !== v.length && console.warn("Invalid selection", c);
|
|
725
|
+
}, l = (c) => {
|
|
723
726
|
if (a())
|
|
724
727
|
return !1;
|
|
725
|
-
const { selected:
|
|
726
|
-
|
|
727
|
-
},
|
|
728
|
+
const { selected: S } = r;
|
|
729
|
+
S.some(({ id: v }) => c.includes(v)) && o({ selected: S.filter(({ id: v }) => !c.includes(v)) });
|
|
730
|
+
}, m = (c) => i = c;
|
|
728
731
|
return e.observe(
|
|
729
|
-
({ changes:
|
|
732
|
+
({ changes: c }) => l((c.deleted || []).map((S) => S.id))
|
|
730
733
|
), {
|
|
731
734
|
get event() {
|
|
732
735
|
return r ? r.event : null;
|
|
@@ -736,73 +739,73 @@ const xt = { selected: [] }, fn = (e, t = "EDIT") => {
|
|
|
736
739
|
},
|
|
737
740
|
clear: s,
|
|
738
741
|
isEmpty: a,
|
|
739
|
-
isSelected:
|
|
740
|
-
setSelected:
|
|
741
|
-
setUserSelectAction:
|
|
742
|
+
isSelected: d,
|
|
743
|
+
setSelected: g,
|
|
744
|
+
setUserSelectAction: m,
|
|
742
745
|
subscribe: n,
|
|
743
|
-
userSelect:
|
|
746
|
+
userSelect: f
|
|
744
747
|
};
|
|
745
748
|
}, Zt = (e, t) => typeof t == "function" ? t(e) : t || "EDIT";
|
|
746
|
-
var
|
|
747
|
-
for (var
|
|
748
|
-
|
|
749
|
-
function
|
|
750
|
-
return (
|
|
749
|
+
var D = [];
|
|
750
|
+
for (var Et = 0; Et < 256; ++Et)
|
|
751
|
+
D.push((Et + 256).toString(16).slice(1));
|
|
752
|
+
function hn(e, t = 0) {
|
|
753
|
+
return (D[e[t + 0]] + D[e[t + 1]] + D[e[t + 2]] + D[e[t + 3]] + "-" + D[e[t + 4]] + D[e[t + 5]] + "-" + D[e[t + 6]] + D[e[t + 7]] + "-" + D[e[t + 8]] + D[e[t + 9]] + "-" + D[e[t + 10]] + D[e[t + 11]] + D[e[t + 12]] + D[e[t + 13]] + D[e[t + 14]] + D[e[t + 15]]).toLowerCase();
|
|
751
754
|
}
|
|
752
|
-
var ut,
|
|
753
|
-
function
|
|
755
|
+
var ut, gn = new Uint8Array(16);
|
|
756
|
+
function mn() {
|
|
754
757
|
if (!ut && (ut = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ut))
|
|
755
758
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
756
|
-
return ut(
|
|
759
|
+
return ut(gn);
|
|
757
760
|
}
|
|
758
|
-
var
|
|
761
|
+
var bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
759
762
|
const Jt = {
|
|
760
|
-
randomUUID:
|
|
763
|
+
randomUUID: bn
|
|
761
764
|
};
|
|
762
|
-
function
|
|
765
|
+
function wn(e, t, n) {
|
|
763
766
|
if (Jt.randomUUID && !t && !e)
|
|
764
767
|
return Jt.randomUUID();
|
|
765
768
|
e = e || {};
|
|
766
|
-
var o = e.random || (e.rng ||
|
|
767
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
769
|
+
var o = e.random || (e.rng || mn)();
|
|
770
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, hn(o);
|
|
768
771
|
}
|
|
769
|
-
const
|
|
770
|
-
id:
|
|
772
|
+
const Lo = (e, t, n, o) => ({
|
|
773
|
+
id: wn(),
|
|
771
774
|
annotation: typeof e == "string" ? e : e.id,
|
|
772
775
|
created: n || /* @__PURE__ */ new Date(),
|
|
773
776
|
creator: o,
|
|
774
777
|
...t
|
|
775
|
-
}),
|
|
778
|
+
}), An = (e, t) => {
|
|
776
779
|
const n = new Set(e.bodies.map((o) => o.id));
|
|
777
780
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
778
|
-
},
|
|
781
|
+
}, Sn = (e, t) => {
|
|
779
782
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
780
783
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
781
784
|
}, vn = (e, t) => t.bodies.map((n) => {
|
|
782
785
|
const o = e.bodies.find((i) => i.id === n.id);
|
|
783
786
|
return { newBody: n, oldBody: o && !K(o, n) ? o : void 0 };
|
|
784
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
785
|
-
const n =
|
|
787
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Cn = (e, t) => !K(e.target, t.target), le = (e, t) => {
|
|
788
|
+
const n = An(e, t), o = Sn(e, t), i = vn(e, t);
|
|
786
789
|
return {
|
|
787
790
|
oldValue: e,
|
|
788
791
|
newValue: t,
|
|
789
792
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
790
793
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
791
794
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
792
|
-
targetUpdated:
|
|
795
|
+
targetUpdated: Cn(e, t) ? { oldTarget: e.target, newTarget: t.target } : void 0
|
|
793
796
|
};
|
|
794
797
|
};
|
|
795
|
-
var
|
|
796
|
-
const
|
|
798
|
+
var V = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(V || {});
|
|
799
|
+
const xn = (e, t) => {
|
|
797
800
|
var n, o;
|
|
798
801
|
const { changes: i, origin: r } = t;
|
|
799
802
|
if (!(!e.options.origin || e.options.origin === r))
|
|
800
803
|
return !1;
|
|
801
804
|
if (e.options.ignore) {
|
|
802
|
-
const { ignore: s } = e.options, a = (
|
|
805
|
+
const { ignore: s } = e.options, a = (d) => d && d.length > 0;
|
|
803
806
|
if (!(a(i.created) || a(i.deleted))) {
|
|
804
|
-
const
|
|
805
|
-
if (s === "BODY_ONLY" &&
|
|
807
|
+
const d = (n = i.updated) == null ? void 0 : n.some((g) => a(g.bodiesCreated) || a(g.bodiesDeleted) || a(g.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((g) => g.targetUpdated);
|
|
808
|
+
if (s === "BODY_ONLY" && d && !f || s === "TARGET_ONLY" && f && !d)
|
|
806
809
|
return !1;
|
|
807
810
|
}
|
|
808
811
|
}
|
|
@@ -815,219 +818,219 @@ const Cn = (e, t) => {
|
|
|
815
818
|
return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((a) => s.has(a));
|
|
816
819
|
} else
|
|
817
820
|
return !0;
|
|
818
|
-
},
|
|
819
|
-
const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), i = new Set((t.created || []).map((l) => l.id)), r = new Set((t.deleted || []).map((l) => l.id)), s = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)),
|
|
820
|
-
...(e.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? t.updated.find(({ oldValue:
|
|
821
|
+
}, En = (e, t) => {
|
|
822
|
+
const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), i = new Set((t.created || []).map((l) => l.id)), r = new Set((t.deleted || []).map((l) => l.id)), s = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), d = [
|
|
823
|
+
...(e.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? t.updated.find(({ oldValue: m }) => m.id === l.id).newValue : l),
|
|
821
824
|
...t.created || []
|
|
822
|
-
],
|
|
825
|
+
], f = [
|
|
823
826
|
...(e.deleted || []).filter((l) => !i.has(l.id)),
|
|
824
827
|
...(t.deleted || []).filter((l) => !n.has(l.id))
|
|
825
|
-
],
|
|
828
|
+
], g = [
|
|
826
829
|
...(e.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
|
|
827
|
-
const { oldValue:
|
|
828
|
-
if (s.has(
|
|
829
|
-
const
|
|
830
|
-
return le(
|
|
830
|
+
const { oldValue: m, newValue: c } = l;
|
|
831
|
+
if (s.has(c.id)) {
|
|
832
|
+
const S = t.updated.find((v) => v.oldValue.id === c.id).newValue;
|
|
833
|
+
return le(m, S);
|
|
831
834
|
} else
|
|
832
835
|
return l;
|
|
833
836
|
}),
|
|
834
837
|
...(t.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
|
|
835
838
|
];
|
|
836
|
-
return { created:
|
|
837
|
-
}, Ln = (e) => e.id !== void 0,
|
|
838
|
-
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (
|
|
839
|
-
const
|
|
840
|
-
|
|
841
|
-
}, r = (
|
|
842
|
-
const
|
|
843
|
-
origin:
|
|
839
|
+
return { created: d, deleted: f, updated: g };
|
|
840
|
+
}, Ln = (e) => e.id !== void 0, Tn = () => {
|
|
841
|
+
const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (b, C = {}) => n.push({ onChange: b, options: C }), i = (b) => {
|
|
842
|
+
const C = n.findIndex((x) => x.onChange == b);
|
|
843
|
+
C > -1 && n.splice(C, 1);
|
|
844
|
+
}, r = (b, C) => {
|
|
845
|
+
const x = {
|
|
846
|
+
origin: b,
|
|
844
847
|
changes: {
|
|
845
|
-
created:
|
|
846
|
-
updated:
|
|
847
|
-
deleted:
|
|
848
|
+
created: C.created || [],
|
|
849
|
+
updated: C.updated || [],
|
|
850
|
+
deleted: C.deleted || []
|
|
848
851
|
},
|
|
849
852
|
state: [...e.values()]
|
|
850
853
|
};
|
|
851
|
-
n.forEach((
|
|
852
|
-
|
|
854
|
+
n.forEach((L) => {
|
|
855
|
+
xn(L, x) && L.onChange(x);
|
|
853
856
|
});
|
|
854
|
-
}, s = (
|
|
855
|
-
if (e.get(
|
|
856
|
-
throw Error(`Cannot add annotation ${
|
|
857
|
-
e.set(
|
|
858
|
-
}, a = (
|
|
859
|
-
const
|
|
860
|
-
if (
|
|
861
|
-
const I = le(
|
|
862
|
-
return
|
|
857
|
+
}, s = (b, C = V.LOCAL) => {
|
|
858
|
+
if (e.get(b.id))
|
|
859
|
+
throw Error(`Cannot add annotation ${b.id} - exists already`);
|
|
860
|
+
e.set(b.id, b), b.bodies.forEach((x) => t.set(x.id, b.id)), r(C, { created: [b] });
|
|
861
|
+
}, a = (b, C) => {
|
|
862
|
+
const x = typeof b == "string" ? C : b, L = typeof b == "string" ? b : b.id, R = e.get(L);
|
|
863
|
+
if (R) {
|
|
864
|
+
const I = le(R, x);
|
|
865
|
+
return L === x.id ? e.set(L, x) : (e.delete(L), e.set(x.id, x)), R.bodies.forEach((_) => t.delete(_.id)), x.bodies.forEach((_) => t.set(_.id, x.id)), I;
|
|
863
866
|
} else
|
|
864
|
-
console.warn(`Cannot update annotation ${
|
|
865
|
-
},
|
|
866
|
-
const
|
|
867
|
-
|
|
868
|
-
},
|
|
869
|
-
const
|
|
870
|
-
const I = a(
|
|
871
|
-
return I ? [...
|
|
867
|
+
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
868
|
+
}, d = (b, C = V.LOCAL, x = V.LOCAL) => {
|
|
869
|
+
const L = Ln(C) ? x : C, R = a(b, C);
|
|
870
|
+
R && r(L, { updated: [R] });
|
|
871
|
+
}, f = (b, C = V.LOCAL) => {
|
|
872
|
+
const x = b.reduce((L, R) => {
|
|
873
|
+
const I = a(R);
|
|
874
|
+
return I ? [...L, I] : L;
|
|
872
875
|
}, []);
|
|
873
|
-
|
|
874
|
-
},
|
|
875
|
-
const
|
|
876
|
-
if (
|
|
877
|
-
const
|
|
878
|
-
...
|
|
879
|
-
bodies: [...
|
|
876
|
+
x.length > 0 && r(C, { updated: x });
|
|
877
|
+
}, g = (b, C = V.LOCAL) => {
|
|
878
|
+
const x = e.get(b.annotation);
|
|
879
|
+
if (x) {
|
|
880
|
+
const L = {
|
|
881
|
+
...x,
|
|
882
|
+
bodies: [...x.bodies, b]
|
|
880
883
|
};
|
|
881
|
-
e.set(
|
|
882
|
-
oldValue:
|
|
883
|
-
newValue:
|
|
884
|
-
bodiesCreated: [
|
|
884
|
+
e.set(x.id, L), t.set(b.id, L.id), r(C, { updated: [{
|
|
885
|
+
oldValue: x,
|
|
886
|
+
newValue: L,
|
|
887
|
+
bodiesCreated: [b]
|
|
885
888
|
}] });
|
|
886
889
|
} else
|
|
887
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
888
|
-
}, l = () => [...e.values()],
|
|
889
|
-
const
|
|
890
|
-
e.clear(), t.clear(), r(
|
|
891
|
-
},
|
|
892
|
-
if (
|
|
893
|
-
const
|
|
894
|
-
e.clear(), t.clear(),
|
|
895
|
-
e.set(
|
|
896
|
-
}), r(
|
|
890
|
+
console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
|
|
891
|
+
}, l = () => [...e.values()], m = (b = V.LOCAL) => {
|
|
892
|
+
const C = [...e.values()];
|
|
893
|
+
e.clear(), t.clear(), r(b, { deleted: C });
|
|
894
|
+
}, c = (b, C = !0, x = V.LOCAL) => {
|
|
895
|
+
if (C) {
|
|
896
|
+
const L = [...e.values()];
|
|
897
|
+
e.clear(), t.clear(), b.forEach((R) => {
|
|
898
|
+
e.set(R.id, R), R.bodies.forEach((I) => t.set(I.id, R.id));
|
|
899
|
+
}), r(x, { created: b, deleted: L });
|
|
897
900
|
} else {
|
|
898
|
-
const
|
|
899
|
-
const
|
|
900
|
-
return
|
|
901
|
+
const L = b.reduce((R, I) => {
|
|
902
|
+
const _ = e.get(I.id);
|
|
903
|
+
return _ ? [...R, _] : R;
|
|
901
904
|
}, []);
|
|
902
|
-
if (
|
|
903
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
904
|
-
|
|
905
|
-
e.set(
|
|
906
|
-
}), r(
|
|
905
|
+
if (L.length > 0)
|
|
906
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${L.map((R) => R.id).join(", ")}`);
|
|
907
|
+
b.forEach((R) => {
|
|
908
|
+
e.set(R.id, R), R.bodies.forEach((I) => t.set(I.id, R.id));
|
|
909
|
+
}), r(x, { created: b });
|
|
907
910
|
}
|
|
908
|
-
},
|
|
909
|
-
const
|
|
910
|
-
if (
|
|
911
|
-
return e.delete(
|
|
912
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
913
|
-
},
|
|
914
|
-
const
|
|
915
|
-
|
|
916
|
-
},
|
|
917
|
-
const
|
|
918
|
-
const I =
|
|
919
|
-
return I ? [...
|
|
911
|
+
}, S = (b) => {
|
|
912
|
+
const C = typeof b == "string" ? b : b.id, x = e.get(C);
|
|
913
|
+
if (x)
|
|
914
|
+
return e.delete(C), x.bodies.forEach((L) => t.delete(L.id)), x;
|
|
915
|
+
console.warn(`Attempt to delete missing annotation: ${C}`);
|
|
916
|
+
}, v = (b, C = V.LOCAL) => {
|
|
917
|
+
const x = S(b);
|
|
918
|
+
x && r(C, { deleted: [x] });
|
|
919
|
+
}, w = (b, C = V.LOCAL) => {
|
|
920
|
+
const x = b.reduce((L, R) => {
|
|
921
|
+
const I = S(R);
|
|
922
|
+
return I ? [...L, I] : L;
|
|
920
923
|
}, []);
|
|
921
|
-
|
|
922
|
-
},
|
|
923
|
-
const
|
|
924
|
-
if (
|
|
925
|
-
const
|
|
926
|
-
if (
|
|
927
|
-
t.delete(
|
|
928
|
-
const
|
|
929
|
-
...
|
|
930
|
-
bodies:
|
|
924
|
+
x.length > 0 && r(C, { deleted: x });
|
|
925
|
+
}, p = (b) => {
|
|
926
|
+
const C = e.get(b.annotation);
|
|
927
|
+
if (C) {
|
|
928
|
+
const x = C.bodies.find((L) => L.id === b.id);
|
|
929
|
+
if (x) {
|
|
930
|
+
t.delete(x.id);
|
|
931
|
+
const L = {
|
|
932
|
+
...C,
|
|
933
|
+
bodies: C.bodies.filter((R) => R.id !== b.id)
|
|
931
934
|
};
|
|
932
|
-
return e.set(
|
|
933
|
-
oldValue:
|
|
934
|
-
newValue:
|
|
935
|
-
bodiesDeleted: [
|
|
935
|
+
return e.set(C.id, L), {
|
|
936
|
+
oldValue: C,
|
|
937
|
+
newValue: L,
|
|
938
|
+
bodiesDeleted: [x]
|
|
936
939
|
};
|
|
937
940
|
} else
|
|
938
|
-
console.warn(`Attempt to delete missing body ${
|
|
941
|
+
console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
|
|
939
942
|
} else
|
|
940
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
941
|
-
},
|
|
942
|
-
const
|
|
943
|
-
|
|
944
|
-
},
|
|
945
|
-
const
|
|
946
|
-
|
|
947
|
-
},
|
|
948
|
-
const
|
|
949
|
-
return
|
|
950
|
-
},
|
|
951
|
-
const
|
|
952
|
-
if (
|
|
953
|
-
const
|
|
954
|
-
if (
|
|
955
|
-
return
|
|
956
|
-
console.error(`Store integrity error: body ${
|
|
943
|
+
console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
|
|
944
|
+
}, u = (b, C = V.LOCAL) => {
|
|
945
|
+
const x = p(b);
|
|
946
|
+
x && r(C, { updated: [x] });
|
|
947
|
+
}, A = (b, C = V.LOCAL) => {
|
|
948
|
+
const x = b.map((L) => p(L)).filter(Boolean);
|
|
949
|
+
x.length > 0 && r(C, { updated: x });
|
|
950
|
+
}, h = (b) => {
|
|
951
|
+
const C = e.get(b);
|
|
952
|
+
return C ? { ...C } : void 0;
|
|
953
|
+
}, E = (b) => {
|
|
954
|
+
const C = t.get(b);
|
|
955
|
+
if (C) {
|
|
956
|
+
const x = h(C).bodies.find((L) => L.id === b);
|
|
957
|
+
if (x)
|
|
958
|
+
return x;
|
|
959
|
+
console.error(`Store integrity error: body ${b} in index, but not in annotation`);
|
|
957
960
|
} else
|
|
958
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
959
|
-
},
|
|
960
|
-
if (
|
|
961
|
+
console.warn(`Attempt to retrieve missing body: ${b}`);
|
|
962
|
+
}, M = (b, C) => {
|
|
963
|
+
if (b.annotation !== C.annotation)
|
|
961
964
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
962
|
-
const
|
|
963
|
-
if (
|
|
964
|
-
const
|
|
965
|
-
...
|
|
966
|
-
bodies:
|
|
965
|
+
const x = e.get(b.annotation);
|
|
966
|
+
if (x) {
|
|
967
|
+
const L = x.bodies.find((I) => I.id === b.id), R = {
|
|
968
|
+
...x,
|
|
969
|
+
bodies: x.bodies.map((I) => I.id === L.id ? C : I)
|
|
967
970
|
};
|
|
968
|
-
return e.set(
|
|
969
|
-
oldValue:
|
|
970
|
-
newValue:
|
|
971
|
-
bodiesUpdated: [{ oldBody:
|
|
971
|
+
return e.set(x.id, R), L.id !== C.id && (t.delete(L.id), t.set(C.id, R.id)), {
|
|
972
|
+
oldValue: x,
|
|
973
|
+
newValue: R,
|
|
974
|
+
bodiesUpdated: [{ oldBody: L, newBody: C }]
|
|
972
975
|
};
|
|
973
976
|
} else
|
|
974
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
975
|
-
}, k = (
|
|
976
|
-
const
|
|
977
|
-
|
|
978
|
-
},
|
|
979
|
-
const
|
|
980
|
-
r(
|
|
981
|
-
},
|
|
982
|
-
const
|
|
983
|
-
if (
|
|
984
|
-
const
|
|
985
|
-
...
|
|
977
|
+
console.warn(`Attempt to add body to missing annotation ${b.annotation}`);
|
|
978
|
+
}, k = (b, C, x = V.LOCAL) => {
|
|
979
|
+
const L = M(b, C);
|
|
980
|
+
L && r(x, { updated: [L] });
|
|
981
|
+
}, T = (b, C = V.LOCAL) => {
|
|
982
|
+
const x = b.map((L) => M({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
983
|
+
r(C, { updated: x });
|
|
984
|
+
}, B = (b) => {
|
|
985
|
+
const C = e.get(b.annotation);
|
|
986
|
+
if (C) {
|
|
987
|
+
const x = {
|
|
988
|
+
...C,
|
|
986
989
|
target: {
|
|
987
|
-
...
|
|
988
|
-
...
|
|
990
|
+
...C.target,
|
|
991
|
+
...b
|
|
989
992
|
}
|
|
990
993
|
};
|
|
991
|
-
return e.set(
|
|
992
|
-
oldValue:
|
|
993
|
-
newValue:
|
|
994
|
+
return e.set(C.id, x), {
|
|
995
|
+
oldValue: C,
|
|
996
|
+
newValue: x,
|
|
994
997
|
targetUpdated: {
|
|
995
|
-
oldTarget:
|
|
996
|
-
newTarget:
|
|
998
|
+
oldTarget: C.target,
|
|
999
|
+
newTarget: b
|
|
997
1000
|
}
|
|
998
1001
|
};
|
|
999
1002
|
} else
|
|
1000
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
1003
|
+
console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);
|
|
1001
1004
|
};
|
|
1002
1005
|
return {
|
|
1003
1006
|
addAnnotation: s,
|
|
1004
|
-
addBody:
|
|
1007
|
+
addBody: g,
|
|
1005
1008
|
all: l,
|
|
1006
|
-
bulkAddAnnotation:
|
|
1007
|
-
bulkDeleteAnnotation:
|
|
1008
|
-
bulkDeleteBodies:
|
|
1009
|
-
bulkUpdateAnnotation:
|
|
1010
|
-
bulkUpdateBodies:
|
|
1011
|
-
bulkUpdateTargets: (
|
|
1012
|
-
const
|
|
1013
|
-
|
|
1009
|
+
bulkAddAnnotation: c,
|
|
1010
|
+
bulkDeleteAnnotation: w,
|
|
1011
|
+
bulkDeleteBodies: A,
|
|
1012
|
+
bulkUpdateAnnotation: f,
|
|
1013
|
+
bulkUpdateBodies: T,
|
|
1014
|
+
bulkUpdateTargets: (b, C = V.LOCAL) => {
|
|
1015
|
+
const x = b.map((L) => B(L)).filter(Boolean);
|
|
1016
|
+
x.length > 0 && r(C, { updated: x });
|
|
1014
1017
|
},
|
|
1015
|
-
clear:
|
|
1016
|
-
deleteAnnotation:
|
|
1017
|
-
deleteBody:
|
|
1018
|
-
getAnnotation:
|
|
1019
|
-
getBody:
|
|
1018
|
+
clear: m,
|
|
1019
|
+
deleteAnnotation: v,
|
|
1020
|
+
deleteBody: u,
|
|
1021
|
+
getAnnotation: h,
|
|
1022
|
+
getBody: E,
|
|
1020
1023
|
observe: o,
|
|
1021
1024
|
unobserve: i,
|
|
1022
|
-
updateAnnotation:
|
|
1025
|
+
updateAnnotation: d,
|
|
1023
1026
|
updateBody: k,
|
|
1024
|
-
updateTarget: (
|
|
1025
|
-
const
|
|
1026
|
-
|
|
1027
|
+
updateTarget: (b, C = V.LOCAL) => {
|
|
1028
|
+
const x = B(b);
|
|
1029
|
+
x && r(C, { updated: [x] });
|
|
1027
1030
|
}
|
|
1028
1031
|
};
|
|
1029
1032
|
};
|
|
1030
|
-
let
|
|
1033
|
+
let Mn = () => ({
|
|
1031
1034
|
emit(e, ...t) {
|
|
1032
1035
|
for (let n = 0, o = this.events[e] || [], i = o.length; n < i; n++)
|
|
1033
1036
|
o[n](...t);
|
|
@@ -1041,41 +1044,41 @@ let Tn = () => ({
|
|
|
1041
1044
|
};
|
|
1042
1045
|
}
|
|
1043
1046
|
});
|
|
1044
|
-
const
|
|
1045
|
-
const t =
|
|
1047
|
+
const Bn = 250, Rn = (e) => {
|
|
1048
|
+
const t = Mn(), n = [];
|
|
1046
1049
|
let o = -1, i = !1, r = 0;
|
|
1047
|
-
const s = (
|
|
1050
|
+
const s = (c) => {
|
|
1048
1051
|
if (!i) {
|
|
1049
|
-
const { changes:
|
|
1050
|
-
if (
|
|
1051
|
-
n.splice(o + 1), n.push(
|
|
1052
|
+
const { changes: S } = c, v = performance.now();
|
|
1053
|
+
if (v - r > Bn)
|
|
1054
|
+
n.splice(o + 1), n.push(S), o = n.length - 1;
|
|
1052
1055
|
else {
|
|
1053
|
-
const
|
|
1054
|
-
n[
|
|
1056
|
+
const w = n.length - 1;
|
|
1057
|
+
n[w] = En(n[w], S);
|
|
1055
1058
|
}
|
|
1056
|
-
r =
|
|
1059
|
+
r = v;
|
|
1057
1060
|
}
|
|
1058
1061
|
i = !1;
|
|
1059
1062
|
};
|
|
1060
|
-
e.observe(s, { origin:
|
|
1061
|
-
const a = (
|
|
1063
|
+
e.observe(s, { origin: V.LOCAL });
|
|
1064
|
+
const a = (c) => c && c.length > 0 && e.bulkDeleteAnnotation(c), d = (c) => c && c.length > 0 && e.bulkAddAnnotation(c, !1), f = (c) => c && c.length > 0 && e.bulkUpdateAnnotation(c.map(({ oldValue: S }) => S)), g = (c) => c && c.length > 0 && e.bulkUpdateAnnotation(c.map(({ newValue: S }) => S)), l = (c) => c && c.length > 0 && e.bulkAddAnnotation(c, !1), m = (c) => c && c.length > 0 && e.bulkDeleteAnnotation(c);
|
|
1062
1065
|
return {
|
|
1063
1066
|
canRedo: () => n.length - 1 > o,
|
|
1064
1067
|
canUndo: () => o > -1,
|
|
1065
1068
|
destroy: () => e.unobserve(s),
|
|
1066
|
-
on: (
|
|
1069
|
+
on: (c, S) => t.on(c, S),
|
|
1067
1070
|
redo: () => {
|
|
1068
1071
|
if (n.length - 1 > o) {
|
|
1069
1072
|
i = !0;
|
|
1070
|
-
const { created:
|
|
1071
|
-
|
|
1073
|
+
const { created: c, updated: S, deleted: v } = n[o + 1];
|
|
1074
|
+
d(c), g(S), m(v), t.emit("redo", n[o + 1]), o += 1;
|
|
1072
1075
|
}
|
|
1073
1076
|
},
|
|
1074
1077
|
undo: () => {
|
|
1075
1078
|
if (o > -1) {
|
|
1076
1079
|
i = !0;
|
|
1077
|
-
const { created:
|
|
1078
|
-
a(
|
|
1080
|
+
const { created: c, updated: S, deleted: v } = n[o];
|
|
1081
|
+
a(c), f(S), l(v), t.emit("undo", n[o]), o -= 1;
|
|
1079
1082
|
}
|
|
1080
1083
|
}
|
|
1081
1084
|
};
|
|
@@ -1085,75 +1088,75 @@ const Mn = 250, Bn = (e) => {
|
|
|
1085
1088
|
subscribe: e,
|
|
1086
1089
|
set: t
|
|
1087
1090
|
};
|
|
1088
|
-
},
|
|
1089
|
-
const { store: i, selection: r, hover: s, viewport: a } = e,
|
|
1090
|
-
let
|
|
1091
|
-
const l = (
|
|
1092
|
-
|
|
1093
|
-
},
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1091
|
+
}, Vn = (e, t, n, o) => {
|
|
1092
|
+
const { store: i, selection: r, hover: s, viewport: a } = e, d = /* @__PURE__ */ new Map();
|
|
1093
|
+
let f = [], g;
|
|
1094
|
+
const l = (v, w) => {
|
|
1095
|
+
d.has(v) ? d.get(v).push(w) : d.set(v, [w]);
|
|
1096
|
+
}, m = (v, w) => {
|
|
1097
|
+
const p = d.get(v);
|
|
1098
|
+
if (p) {
|
|
1099
|
+
const u = p.indexOf(w);
|
|
1100
|
+
u !== -1 && p.splice(u, 1);
|
|
1098
1101
|
}
|
|
1099
|
-
},
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
+
}, c = (v, w, p) => {
|
|
1103
|
+
d.has(v) && setTimeout(() => {
|
|
1104
|
+
d.get(v).forEach((u) => {
|
|
1102
1105
|
if (n) {
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1106
|
+
const A = Array.isArray(w) ? w.map((E) => n.serialize(E)) : n.serialize(w), h = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
|
|
1107
|
+
u(A, h);
|
|
1105
1108
|
} else
|
|
1106
|
-
|
|
1109
|
+
u(w, p);
|
|
1107
1110
|
});
|
|
1108
1111
|
}, 1);
|
|
1109
1112
|
};
|
|
1110
|
-
r.subscribe(({ selected:
|
|
1111
|
-
if (!(
|
|
1112
|
-
if (
|
|
1113
|
-
|
|
1114
|
-
else if (
|
|
1115
|
-
|
|
1116
|
-
const
|
|
1117
|
-
|
|
1118
|
-
}),
|
|
1113
|
+
r.subscribe(({ selected: v }) => {
|
|
1114
|
+
if (!(f.length === 0 && v.length === 0)) {
|
|
1115
|
+
if (f.length === 0 && v.length > 0)
|
|
1116
|
+
f = v.map(({ id: w }) => i.getAnnotation(w));
|
|
1117
|
+
else if (f.length > 0 && v.length === 0)
|
|
1118
|
+
f.forEach((w) => {
|
|
1119
|
+
const p = i.getAnnotation(w.id);
|
|
1120
|
+
p && !K(p, w) && c("updateAnnotation", p, w);
|
|
1121
|
+
}), f = [];
|
|
1119
1122
|
else {
|
|
1120
|
-
const
|
|
1121
|
-
|
|
1122
|
-
const
|
|
1123
|
-
|
|
1124
|
-
}),
|
|
1123
|
+
const w = new Set(f.map((u) => u.id)), p = new Set(v.map(({ id: u }) => u));
|
|
1124
|
+
f.filter((u) => !p.has(u.id)).forEach((u) => {
|
|
1125
|
+
const A = i.getAnnotation(u.id);
|
|
1126
|
+
A && !K(A, u) && c("updateAnnotation", A, u);
|
|
1127
|
+
}), f = [
|
|
1125
1128
|
// Remove annotations that were deselected
|
|
1126
|
-
...
|
|
1129
|
+
...f.filter((u) => p.has(u.id)),
|
|
1127
1130
|
// Add editable annotations that were selected
|
|
1128
|
-
...
|
|
1131
|
+
...v.filter(({ id: u }) => !w.has(u)).map(({ id: u }) => i.getAnnotation(u))
|
|
1129
1132
|
];
|
|
1130
1133
|
}
|
|
1131
|
-
|
|
1134
|
+
c("selectionChanged", f);
|
|
1132
1135
|
}
|
|
1133
|
-
}), s.subscribe((
|
|
1134
|
-
!
|
|
1135
|
-
}), a == null || a.subscribe((
|
|
1136
|
-
const { created:
|
|
1137
|
-
(
|
|
1138
|
-
...
|
|
1139
|
-
...
|
|
1140
|
-
...
|
|
1141
|
-
].length > 0).forEach(({ oldValue:
|
|
1142
|
-
const
|
|
1143
|
-
|
|
1136
|
+
}), s.subscribe((v) => {
|
|
1137
|
+
!g && v ? c("mouseEnterAnnotation", i.getAnnotation(v)) : g && !v ? c("mouseLeaveAnnotation", i.getAnnotation(g)) : g && v && (c("mouseLeaveAnnotation", i.getAnnotation(g)), c("mouseEnterAnnotation", i.getAnnotation(v))), g = v;
|
|
1138
|
+
}), a == null || a.subscribe((v) => c("viewportIntersect", v.map((w) => i.getAnnotation(w)))), i.observe((v) => {
|
|
1139
|
+
const { created: w, deleted: p } = v.changes;
|
|
1140
|
+
(w || []).forEach((u) => c("createAnnotation", u)), (p || []).forEach((u) => c("deleteAnnotation", u)), (v.changes.updated || []).filter((u) => [
|
|
1141
|
+
...u.bodiesCreated || [],
|
|
1142
|
+
...u.bodiesDeleted || [],
|
|
1143
|
+
...u.bodiesUpdated || []
|
|
1144
|
+
].length > 0).forEach(({ oldValue: u, newValue: A }) => {
|
|
1145
|
+
const h = f.find((E) => E.id === u.id) || u;
|
|
1146
|
+
f = f.map((E) => E.id === u.id ? A : E), c("updateAnnotation", A, h);
|
|
1144
1147
|
});
|
|
1145
|
-
}, { origin:
|
|
1146
|
-
if (
|
|
1147
|
-
const
|
|
1148
|
-
|
|
1148
|
+
}, { origin: V.LOCAL }), i.observe((v) => {
|
|
1149
|
+
if (f) {
|
|
1150
|
+
const w = new Set(f.map((u) => u.id)), p = (v.changes.updated || []).filter(({ newValue: u }) => w.has(u.id)).map(({ newValue: u }) => u);
|
|
1151
|
+
p.length > 0 && (f = f.map((u) => p.find((h) => h.id === u.id) || u));
|
|
1149
1152
|
}
|
|
1150
|
-
}, { origin:
|
|
1151
|
-
const
|
|
1152
|
-
const { updated:
|
|
1153
|
-
|
|
1153
|
+
}, { origin: V.REMOTE });
|
|
1154
|
+
const S = (v) => (w) => {
|
|
1155
|
+
const { updated: p } = w;
|
|
1156
|
+
v ? (p || []).forEach((u) => c("updateAnnotation", u.oldValue, u.newValue)) : (p || []).forEach((u) => c("updateAnnotation", u.newValue, u.oldValue));
|
|
1154
1157
|
};
|
|
1155
|
-
return t.on("undo",
|
|
1156
|
-
},
|
|
1158
|
+
return t.on("undo", S(!0)), t.on("redo", S(!1)), { on: l, off: m, emit: c };
|
|
1159
|
+
}, On = (e) => (t) => t.reduce((n, o) => {
|
|
1157
1160
|
const { parsed: i, error: r } = e.parse(o);
|
|
1158
1161
|
return r ? {
|
|
1159
1162
|
parsed: n.parsed,
|
|
@@ -1164,47 +1167,47 @@ const Mn = 250, Bn = (e) => {
|
|
|
1164
1167
|
} : {
|
|
1165
1168
|
...n
|
|
1166
1169
|
};
|
|
1167
|
-
}, { parsed: [], failed: [] }),
|
|
1168
|
-
const { store: o, selection: i } = e, r = (
|
|
1170
|
+
}, { parsed: [], failed: [] }), Nn = (e, t, n) => {
|
|
1171
|
+
const { store: o, selection: i } = e, r = (p) => {
|
|
1169
1172
|
if (n) {
|
|
1170
|
-
const { parsed:
|
|
1171
|
-
|
|
1173
|
+
const { parsed: u, error: A } = n.parse(p);
|
|
1174
|
+
u ? o.addAnnotation(u, V.REMOTE) : console.error(A);
|
|
1172
1175
|
} else
|
|
1173
|
-
o.addAnnotation(
|
|
1174
|
-
}, s = () => i.clear(), a = () => o.clear(),
|
|
1175
|
-
const
|
|
1176
|
-
return n &&
|
|
1177
|
-
},
|
|
1178
|
-
var
|
|
1179
|
-
const
|
|
1180
|
-
return n ?
|
|
1181
|
-
}, l = (
|
|
1182
|
-
if (typeof
|
|
1183
|
-
const
|
|
1184
|
-
if (o.deleteAnnotation(
|
|
1185
|
-
return n ? n.serialize(
|
|
1176
|
+
o.addAnnotation(p, V.REMOTE);
|
|
1177
|
+
}, s = () => i.clear(), a = () => o.clear(), d = (p) => {
|
|
1178
|
+
const u = o.getAnnotation(p);
|
|
1179
|
+
return n && u ? n.serialize(u) : u;
|
|
1180
|
+
}, f = () => n ? o.all().map(n.serialize) : o.all(), g = () => {
|
|
1181
|
+
var p;
|
|
1182
|
+
const u = (((p = i.selected) == null ? void 0 : p.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
|
|
1183
|
+
return n ? u.map(n.serialize) : u;
|
|
1184
|
+
}, l = (p, u = !0) => fetch(p).then((A) => A.json()).then((A) => (c(A, u), A)), m = (p) => {
|
|
1185
|
+
if (typeof p == "string") {
|
|
1186
|
+
const u = o.getAnnotation(p);
|
|
1187
|
+
if (o.deleteAnnotation(p), u)
|
|
1188
|
+
return n ? n.serialize(u) : u;
|
|
1186
1189
|
} else {
|
|
1187
|
-
const
|
|
1188
|
-
if (
|
|
1189
|
-
return o.deleteAnnotation(
|
|
1190
|
+
const u = n ? n.parse(p).parsed : p;
|
|
1191
|
+
if (u)
|
|
1192
|
+
return o.deleteAnnotation(u), p;
|
|
1190
1193
|
}
|
|
1191
|
-
},
|
|
1194
|
+
}, c = (p, u = !0) => {
|
|
1192
1195
|
if (n) {
|
|
1193
|
-
const { parsed:
|
|
1194
|
-
|
|
1196
|
+
const { parsed: A, failed: h } = On(n)(p);
|
|
1197
|
+
h.length > 0 && console.warn(`Discarded ${h.length} invalid annotations`, h), o.bulkAddAnnotation(A, u, V.REMOTE);
|
|
1195
1198
|
} else
|
|
1196
|
-
o.bulkAddAnnotation(
|
|
1197
|
-
},
|
|
1198
|
-
|
|
1199
|
-
},
|
|
1200
|
-
i.clear(), i.setUserSelectAction(
|
|
1201
|
-
},
|
|
1199
|
+
o.bulkAddAnnotation(p, u, V.REMOTE);
|
|
1200
|
+
}, S = (p, u) => {
|
|
1201
|
+
p ? i.setSelected(p, u) : i.clear();
|
|
1202
|
+
}, v = (p) => {
|
|
1203
|
+
i.clear(), i.setUserSelectAction(p);
|
|
1204
|
+
}, w = (p) => {
|
|
1202
1205
|
if (n) {
|
|
1203
|
-
const
|
|
1204
|
-
return o.updateAnnotation(
|
|
1206
|
+
const u = n.parse(p).parsed, A = n.serialize(o.getAnnotation(u.id));
|
|
1207
|
+
return o.updateAnnotation(u), A;
|
|
1205
1208
|
} else {
|
|
1206
|
-
const
|
|
1207
|
-
return o.updateAnnotation(
|
|
1209
|
+
const u = o.getAnnotation(p.id);
|
|
1210
|
+
return o.updateAnnotation(p), u;
|
|
1208
1211
|
}
|
|
1209
1212
|
};
|
|
1210
1213
|
return {
|
|
@@ -1213,36 +1216,36 @@ const Mn = 250, Bn = (e) => {
|
|
|
1213
1216
|
canRedo: t.canRedo,
|
|
1214
1217
|
canUndo: t.canUndo,
|
|
1215
1218
|
clearAnnotations: a,
|
|
1216
|
-
getAnnotationById:
|
|
1217
|
-
getAnnotations:
|
|
1218
|
-
getSelected:
|
|
1219
|
+
getAnnotationById: d,
|
|
1220
|
+
getAnnotations: f,
|
|
1221
|
+
getSelected: g,
|
|
1219
1222
|
loadAnnotations: l,
|
|
1220
1223
|
redo: t.redo,
|
|
1221
|
-
removeAnnotation:
|
|
1222
|
-
setAnnotations:
|
|
1223
|
-
setSelected:
|
|
1224
|
-
setUserSelectAction:
|
|
1224
|
+
removeAnnotation: m,
|
|
1225
|
+
setAnnotations: c,
|
|
1226
|
+
setSelected: S,
|
|
1227
|
+
setUserSelectAction: v,
|
|
1225
1228
|
undo: t.undo,
|
|
1226
|
-
updateAnnotation:
|
|
1229
|
+
updateAnnotation: w
|
|
1227
1230
|
};
|
|
1228
1231
|
}, In = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1229
|
-
let
|
|
1232
|
+
let Fn = (e) => crypto.getRandomValues(new Uint8Array(e)), Pn = (e, t, n) => {
|
|
1230
1233
|
let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * t / e.length);
|
|
1231
1234
|
return (r = t) => {
|
|
1232
1235
|
let s = "";
|
|
1233
1236
|
for (; ; ) {
|
|
1234
|
-
let a = n(i),
|
|
1235
|
-
for (;
|
|
1236
|
-
if (s += e[a[
|
|
1237
|
+
let a = n(i), d = i;
|
|
1238
|
+
for (; d--; )
|
|
1239
|
+
if (s += e[a[d] & o] || "", s.length === r) return s;
|
|
1237
1240
|
}
|
|
1238
1241
|
};
|
|
1239
|
-
},
|
|
1242
|
+
}, Dn = (e, t = 21) => Pn(e, t, Fn), yn = (e = 21) => {
|
|
1240
1243
|
let t = "", n = crypto.getRandomValues(new Uint8Array(e));
|
|
1241
1244
|
for (; e--; )
|
|
1242
1245
|
t += In[n[e] & 63];
|
|
1243
1246
|
return t;
|
|
1244
1247
|
};
|
|
1245
|
-
const
|
|
1248
|
+
const Un = () => ({ isGuest: !0, id: Dn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Hn = (e) => {
|
|
1246
1249
|
const t = JSON.stringify(e);
|
|
1247
1250
|
let n = 0;
|
|
1248
1251
|
for (let o = 0, i = t.length; o < i; o++) {
|
|
@@ -1250,20 +1253,20 @@ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1250
1253
|
n = (n << 5) - n + r, n |= 0;
|
|
1251
1254
|
}
|
|
1252
1255
|
return `${n}`;
|
|
1253
|
-
}, ce = (e) => e ? typeof e == "object" ? { ...e } : e : void 0,
|
|
1254
|
-
const { id: o, type: i, purpose: r, value: s, created: a, modified:
|
|
1256
|
+
}, ce = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, _n = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
|
|
1257
|
+
const { id: o, type: i, purpose: r, value: s, created: a, modified: d, creator: f, ...g } = n;
|
|
1255
1258
|
return {
|
|
1256
|
-
id: o || `temp-${
|
|
1259
|
+
id: o || `temp-${Hn(n)}`,
|
|
1257
1260
|
annotation: t,
|
|
1258
1261
|
type: i,
|
|
1259
1262
|
purpose: r,
|
|
1260
1263
|
value: s,
|
|
1261
|
-
creator: ce(
|
|
1264
|
+
creator: ce(f),
|
|
1262
1265
|
created: a ? new Date(a) : void 0,
|
|
1263
|
-
updated:
|
|
1264
|
-
...
|
|
1266
|
+
updated: d ? new Date(d) : void 0,
|
|
1267
|
+
...g
|
|
1265
1268
|
};
|
|
1266
|
-
}),
|
|
1269
|
+
}), Yn = (e) => e.map((t) => {
|
|
1267
1270
|
var n;
|
|
1268
1271
|
const { annotation: o, created: i, updated: r, ...s } = t, a = {
|
|
1269
1272
|
...s,
|
|
@@ -1272,11 +1275,11 @@ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1272
1275
|
};
|
|
1273
1276
|
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
1274
1277
|
});
|
|
1275
|
-
|
|
1276
|
-
const
|
|
1277
|
-
parse: (n) =>
|
|
1278
|
-
serialize: (n) =>
|
|
1279
|
-
}),
|
|
1278
|
+
yn();
|
|
1279
|
+
const To = (e, t) => ({
|
|
1280
|
+
parse: (n) => jn(n),
|
|
1281
|
+
serialize: (n) => Gn(n, e, t)
|
|
1282
|
+
}), Xn = (e) => e.quote !== void 0 && e.start !== void 0 && e.end !== void 0, $n = (e) => {
|
|
1280
1283
|
const {
|
|
1281
1284
|
id: t,
|
|
1282
1285
|
creator: n,
|
|
@@ -1294,68 +1297,68 @@ const Lo = (e, t) => ({
|
|
|
1294
1297
|
selector: [],
|
|
1295
1298
|
styleClass: s[0].styleClass
|
|
1296
1299
|
};
|
|
1297
|
-
for (const
|
|
1298
|
-
const
|
|
1299
|
-
switch (
|
|
1300
|
+
for (const d of s) {
|
|
1301
|
+
const g = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, m) => {
|
|
1302
|
+
switch (m.type) {
|
|
1300
1303
|
case "TextQuoteSelector":
|
|
1301
|
-
l.quote =
|
|
1304
|
+
l.quote = m.exact;
|
|
1302
1305
|
break;
|
|
1303
1306
|
case "TextPositionSelector":
|
|
1304
|
-
l.start =
|
|
1307
|
+
l.start = m.start, l.end = m.end;
|
|
1305
1308
|
break;
|
|
1306
1309
|
}
|
|
1307
1310
|
return l;
|
|
1308
1311
|
}, {});
|
|
1309
|
-
if (
|
|
1310
|
-
a.selector.push({ id:
|
|
1312
|
+
if (Xn(g))
|
|
1313
|
+
a.selector.push({ id: d.id, ...g });
|
|
1311
1314
|
else {
|
|
1312
1315
|
const l = [
|
|
1313
|
-
|
|
1314
|
-
|
|
1316
|
+
g.start ? void 0 : "TextPositionSelector",
|
|
1317
|
+
g.quote ? void 0 : "TextQuoteSelector"
|
|
1315
1318
|
].filter(Boolean);
|
|
1316
1319
|
return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${e.id}`) };
|
|
1317
1320
|
}
|
|
1318
1321
|
}
|
|
1319
1322
|
return { parsed: a };
|
|
1320
|
-
},
|
|
1323
|
+
}, jn = (e) => {
|
|
1321
1324
|
const t = e.id || se(), {
|
|
1322
1325
|
creator: n,
|
|
1323
1326
|
created: o,
|
|
1324
1327
|
modified: i,
|
|
1325
1328
|
body: r,
|
|
1326
1329
|
...s
|
|
1327
|
-
} = e, a =
|
|
1328
|
-
return "error" in
|
|
1330
|
+
} = e, a = _n(r, t), d = $n(e);
|
|
1331
|
+
return "error" in d ? { error: d.error } : {
|
|
1329
1332
|
parsed: {
|
|
1330
1333
|
...s,
|
|
1331
1334
|
id: t,
|
|
1332
1335
|
bodies: a,
|
|
1333
|
-
target:
|
|
1336
|
+
target: d.parsed
|
|
1334
1337
|
}
|
|
1335
1338
|
};
|
|
1336
|
-
},
|
|
1339
|
+
}, Gn = (e, t, n) => {
|
|
1337
1340
|
const { bodies: o, target: i, ...r } = e, {
|
|
1338
1341
|
selector: s,
|
|
1339
1342
|
creator: a,
|
|
1340
|
-
created:
|
|
1341
|
-
updated:
|
|
1342
|
-
...
|
|
1343
|
-
} = i, l = s.map((
|
|
1344
|
-
const { quote:
|
|
1343
|
+
created: d,
|
|
1344
|
+
updated: f,
|
|
1345
|
+
...g
|
|
1346
|
+
} = i, l = s.map((m) => {
|
|
1347
|
+
const { quote: c, start: S, end: v, range: w } = m, { prefix: p, suffix: u } = Re(w, n), A = [{
|
|
1345
1348
|
type: "TextQuoteSelector",
|
|
1346
|
-
exact:
|
|
1347
|
-
prefix:
|
|
1348
|
-
suffix:
|
|
1349
|
+
exact: c,
|
|
1350
|
+
prefix: p,
|
|
1351
|
+
suffix: u
|
|
1349
1352
|
}, {
|
|
1350
1353
|
type: "TextPositionSelector",
|
|
1351
|
-
start:
|
|
1352
|
-
end:
|
|
1354
|
+
start: S,
|
|
1355
|
+
end: v
|
|
1353
1356
|
}];
|
|
1354
1357
|
return {
|
|
1355
|
-
...
|
|
1356
|
-
id:
|
|
1358
|
+
...g,
|
|
1359
|
+
id: m.id,
|
|
1357
1360
|
source: t,
|
|
1358
|
-
selector:
|
|
1361
|
+
selector: A
|
|
1359
1362
|
};
|
|
1360
1363
|
});
|
|
1361
1364
|
return {
|
|
@@ -1363,38 +1366,38 @@ const Lo = (e, t) => ({
|
|
|
1363
1366
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1364
1367
|
id: e.id,
|
|
1365
1368
|
type: "Annotation",
|
|
1366
|
-
body:
|
|
1369
|
+
body: Yn(e.bodies),
|
|
1367
1370
|
creator: a,
|
|
1368
|
-
created:
|
|
1369
|
-
modified:
|
|
1371
|
+
created: d == null ? void 0 : d.toISOString(),
|
|
1372
|
+
modified: f == null ? void 0 : f.toISOString(),
|
|
1370
1373
|
target: l
|
|
1371
1374
|
};
|
|
1372
1375
|
};
|
|
1373
|
-
function
|
|
1374
|
-
de(e, t, n || 0, o || e.length - 1, i ||
|
|
1376
|
+
function Wn(e, t, n, o, i) {
|
|
1377
|
+
de(e, t, n || 0, o || e.length - 1, i || zn);
|
|
1375
1378
|
}
|
|
1376
1379
|
function de(e, t, n, o, i) {
|
|
1377
1380
|
for (; o > n; ) {
|
|
1378
1381
|
if (o - n > 600) {
|
|
1379
|
-
var r = o - n + 1, s = t - n + 1, a = Math.log(r),
|
|
1380
|
-
de(e, t,
|
|
1382
|
+
var r = o - n + 1, s = t - n + 1, a = Math.log(r), d = 0.5 * Math.exp(2 * a / 3), f = 0.5 * Math.sqrt(a * d * (r - d) / r) * (s - r / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(t - s * d / r + f)), l = Math.min(o, Math.floor(t + (r - s) * d / r + f));
|
|
1383
|
+
de(e, t, g, l, i);
|
|
1381
1384
|
}
|
|
1382
|
-
var
|
|
1383
|
-
for (tt(e, n, t), i(e[o],
|
|
1384
|
-
for (tt(e,
|
|
1385
|
-
for (; i(e[
|
|
1385
|
+
var m = e[t], c = n, S = o;
|
|
1386
|
+
for (tt(e, n, t), i(e[o], m) > 0 && tt(e, n, o); c < S; ) {
|
|
1387
|
+
for (tt(e, c, S), c++, S--; i(e[c], m) < 0; ) c++;
|
|
1388
|
+
for (; i(e[S], m) > 0; ) S--;
|
|
1386
1389
|
}
|
|
1387
|
-
i(e[n],
|
|
1390
|
+
i(e[n], m) === 0 ? tt(e, n, S) : (S++, tt(e, S, o)), S <= t && (n = S + 1), t <= S && (o = S - 1);
|
|
1388
1391
|
}
|
|
1389
1392
|
}
|
|
1390
1393
|
function tt(e, t, n) {
|
|
1391
1394
|
var o = e[t];
|
|
1392
1395
|
e[t] = e[n], e[n] = o;
|
|
1393
1396
|
}
|
|
1394
|
-
function
|
|
1397
|
+
function zn(e, t) {
|
|
1395
1398
|
return e < t ? -1 : e > t ? 1 : 0;
|
|
1396
1399
|
}
|
|
1397
|
-
class
|
|
1400
|
+
class qn {
|
|
1398
1401
|
constructor(t = 9) {
|
|
1399
1402
|
this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1400
1403
|
}
|
|
@@ -1408,8 +1411,8 @@ class zn {
|
|
|
1408
1411
|
const i = this.toBBox, r = [];
|
|
1409
1412
|
for (; n; ) {
|
|
1410
1413
|
for (let s = 0; s < n.children.length; s++) {
|
|
1411
|
-
const a = n.children[s],
|
|
1412
|
-
pt(t,
|
|
1414
|
+
const a = n.children[s], d = n.leaf ? i(a) : a;
|
|
1415
|
+
pt(t, d) && (n.leaf ? o.push(a) : Tt(t, d) ? this._all(a, o) : r.push(a));
|
|
1413
1416
|
}
|
|
1414
1417
|
n = r.pop();
|
|
1415
1418
|
}
|
|
@@ -1462,14 +1465,14 @@ class zn {
|
|
|
1462
1465
|
if (!t) return this;
|
|
1463
1466
|
let o = this.data;
|
|
1464
1467
|
const i = this.toBBox(t), r = [], s = [];
|
|
1465
|
-
let a,
|
|
1468
|
+
let a, d, f;
|
|
1466
1469
|
for (; o || r.length; ) {
|
|
1467
|
-
if (o || (o = r.pop(),
|
|
1468
|
-
const
|
|
1469
|
-
if (
|
|
1470
|
-
return o.children.splice(
|
|
1470
|
+
if (o || (o = r.pop(), d = r[r.length - 1], a = s.pop(), f = !0), o.leaf) {
|
|
1471
|
+
const g = Zn(t, o.children, n);
|
|
1472
|
+
if (g !== -1)
|
|
1473
|
+
return o.children.splice(g, 1), r.push(o), this._condense(r), this;
|
|
1471
1474
|
}
|
|
1472
|
-
!
|
|
1475
|
+
!f && !o.leaf && Tt(o, i) ? (r.push(o), s.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], f = !1) : o = null;
|
|
1473
1476
|
}
|
|
1474
1477
|
return this;
|
|
1475
1478
|
}
|
|
@@ -1500,14 +1503,14 @@ class zn {
|
|
|
1500
1503
|
if (r <= s)
|
|
1501
1504
|
return a = Q(t.slice(n, o + 1)), J(a, this.toBBox), a;
|
|
1502
1505
|
i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = Q([]), a.leaf = !1, a.height = i;
|
|
1503
|
-
const
|
|
1504
|
-
Qt(t, n, o,
|
|
1505
|
-
for (let
|
|
1506
|
-
const l = Math.min(
|
|
1507
|
-
Qt(t,
|
|
1508
|
-
for (let
|
|
1509
|
-
const
|
|
1510
|
-
a.children.push(this._build(t,
|
|
1506
|
+
const d = Math.ceil(r / s), f = d * Math.ceil(Math.sqrt(s));
|
|
1507
|
+
Qt(t, n, o, f, this.compareMinX);
|
|
1508
|
+
for (let g = n; g <= o; g += f) {
|
|
1509
|
+
const l = Math.min(g + f - 1, o);
|
|
1510
|
+
Qt(t, g, l, d, this.compareMinY);
|
|
1511
|
+
for (let m = g; m <= l; m += d) {
|
|
1512
|
+
const c = Math.min(m + d - 1, l);
|
|
1513
|
+
a.children.push(this._build(t, m, c, i - 1));
|
|
1511
1514
|
}
|
|
1512
1515
|
}
|
|
1513
1516
|
return J(a, this.toBBox), a;
|
|
@@ -1515,9 +1518,9 @@ class zn {
|
|
|
1515
1518
|
_chooseSubtree(t, n, o, i) {
|
|
1516
1519
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1517
1520
|
let r = 1 / 0, s = 1 / 0, a;
|
|
1518
|
-
for (let
|
|
1519
|
-
const
|
|
1520
|
-
l < s ? (s = l, r =
|
|
1521
|
+
for (let d = 0; d < n.children.length; d++) {
|
|
1522
|
+
const f = n.children[d], g = Lt(f), l = Kn(t, f) - g;
|
|
1523
|
+
l < s ? (s = l, r = g < r ? g : r, a = f) : l === s && g < r && (r = g, a = f);
|
|
1521
1524
|
}
|
|
1522
1525
|
n = a || n.children[0];
|
|
1523
1526
|
}
|
|
@@ -1542,30 +1545,30 @@ class zn {
|
|
|
1542
1545
|
_chooseSplitIndex(t, n, o) {
|
|
1543
1546
|
let i, r = 1 / 0, s = 1 / 0;
|
|
1544
1547
|
for (let a = n; a <= o - n; a++) {
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1548
|
+
const d = nt(t, 0, a, this.toBBox), f = nt(t, a, o, this.toBBox), g = to(d, f), l = Lt(d) + Lt(f);
|
|
1549
|
+
g < r ? (r = g, i = a, s = l < s ? l : s) : g === r && l < s && (s = l, i = a);
|
|
1547
1550
|
}
|
|
1548
1551
|
return i || o - n;
|
|
1549
1552
|
}
|
|
1550
1553
|
// sorts node children by the best axis for split
|
|
1551
1554
|
_chooseSplitAxis(t, n, o) {
|
|
1552
|
-
const i = t.leaf ? this.compareMinX :
|
|
1555
|
+
const i = t.leaf ? this.compareMinX : Jn, r = t.leaf ? this.compareMinY : Qn, s = this._allDistMargin(t, n, o, i), a = this._allDistMargin(t, n, o, r);
|
|
1553
1556
|
s < a && t.children.sort(i);
|
|
1554
1557
|
}
|
|
1555
1558
|
// total margin of all possible split distributions where each node is at least m full
|
|
1556
1559
|
_allDistMargin(t, n, o, i) {
|
|
1557
1560
|
t.children.sort(i);
|
|
1558
1561
|
const r = this.toBBox, s = nt(t, 0, n, r), a = nt(t, o - n, o, r);
|
|
1559
|
-
let
|
|
1560
|
-
for (let
|
|
1561
|
-
const
|
|
1562
|
-
ot(s, t.leaf ? r(
|
|
1562
|
+
let d = ft(s) + ft(a);
|
|
1563
|
+
for (let f = n; f < o - n; f++) {
|
|
1564
|
+
const g = t.children[f];
|
|
1565
|
+
ot(s, t.leaf ? r(g) : g), d += ft(s);
|
|
1563
1566
|
}
|
|
1564
|
-
for (let
|
|
1565
|
-
const
|
|
1566
|
-
ot(a, t.leaf ? r(
|
|
1567
|
+
for (let f = o - n - 1; f >= n; f--) {
|
|
1568
|
+
const g = t.children[f];
|
|
1569
|
+
ot(a, t.leaf ? r(g) : g), d += ft(a);
|
|
1567
1570
|
}
|
|
1568
|
-
return
|
|
1571
|
+
return d;
|
|
1569
1572
|
}
|
|
1570
1573
|
_adjustParentBBoxes(t, n, o) {
|
|
1571
1574
|
for (let i = o; i >= 0; i--)
|
|
@@ -1576,7 +1579,7 @@ class zn {
|
|
|
1576
1579
|
t[n].children.length === 0 ? n > 0 ? (o = t[n - 1].children, o.splice(o.indexOf(t[n]), 1)) : this.clear() : J(t[n], this.toBBox);
|
|
1577
1580
|
}
|
|
1578
1581
|
}
|
|
1579
|
-
function
|
|
1582
|
+
function Zn(e, t, n) {
|
|
1580
1583
|
if (!n) return t.indexOf(e);
|
|
1581
1584
|
for (let o = 0; o < t.length; o++)
|
|
1582
1585
|
if (n(e, t[o])) return o;
|
|
@@ -1596,22 +1599,22 @@ function nt(e, t, n, o, i) {
|
|
|
1596
1599
|
function ot(e, t) {
|
|
1597
1600
|
return e.minX = Math.min(e.minX, t.minX), e.minY = Math.min(e.minY, t.minY), e.maxX = Math.max(e.maxX, t.maxX), e.maxY = Math.max(e.maxY, t.maxY), e;
|
|
1598
1601
|
}
|
|
1599
|
-
function
|
|
1602
|
+
function Jn(e, t) {
|
|
1600
1603
|
return e.minX - t.minX;
|
|
1601
1604
|
}
|
|
1602
|
-
function
|
|
1605
|
+
function Qn(e, t) {
|
|
1603
1606
|
return e.minY - t.minY;
|
|
1604
1607
|
}
|
|
1605
|
-
function
|
|
1608
|
+
function Lt(e) {
|
|
1606
1609
|
return (e.maxX - e.minX) * (e.maxY - e.minY);
|
|
1607
1610
|
}
|
|
1608
1611
|
function ft(e) {
|
|
1609
1612
|
return e.maxX - e.minX + (e.maxY - e.minY);
|
|
1610
1613
|
}
|
|
1611
|
-
function
|
|
1614
|
+
function Kn(e, t) {
|
|
1612
1615
|
return (Math.max(t.maxX, e.maxX) - Math.min(t.minX, e.minX)) * (Math.max(t.maxY, e.maxY) - Math.min(t.minY, e.minY));
|
|
1613
1616
|
}
|
|
1614
|
-
function
|
|
1617
|
+
function to(e, t) {
|
|
1615
1618
|
const n = Math.max(e.minX, t.minX), o = Math.max(e.minY, t.minY), i = Math.min(e.maxX, t.maxX), r = Math.min(e.maxY, t.maxY);
|
|
1616
1619
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1617
1620
|
}
|
|
@@ -1637,167 +1640,185 @@ function Qt(e, t, n, o, i) {
|
|
|
1637
1640
|
for (; r.length; ) {
|
|
1638
1641
|
if (n = r.pop(), t = r.pop(), n - t <= o) continue;
|
|
1639
1642
|
const s = t + Math.ceil((n - t) / o / 2) * o;
|
|
1640
|
-
|
|
1643
|
+
Wn(e, s, t, n, i), r.push(t, s, s, n);
|
|
1641
1644
|
}
|
|
1642
1645
|
}
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1646
|
+
let eo = () => ({
|
|
1647
|
+
emit(e, ...t) {
|
|
1648
|
+
for (let n = 0, o = this.events[e] || [], i = o.length; n < i; n++)
|
|
1649
|
+
o[n](...t);
|
|
1650
|
+
},
|
|
1651
|
+
events: {},
|
|
1652
|
+
on(e, t) {
|
|
1653
|
+
var n;
|
|
1654
|
+
return ((n = this.events)[e] || (n[e] = [])).push(t), () => {
|
|
1655
|
+
var o;
|
|
1656
|
+
this.events[e] = (o = this.events[e]) == null ? void 0 : o.filter((i) => t !== i);
|
|
1657
|
+
};
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1660
|
+
const no = (e, t) => {
|
|
1661
|
+
const n = new qn(), o = /* @__PURE__ */ new Map(), i = eo(), r = (A, h) => {
|
|
1662
|
+
const E = A.selector.flatMap((k) => {
|
|
1663
|
+
const T = z([k]) ? k.range : oe(k, t).range;
|
|
1647
1664
|
return Array.from(T.getClientRects());
|
|
1648
|
-
}),
|
|
1649
|
-
return
|
|
1650
|
-
const { x: T, y:
|
|
1665
|
+
}), M = Ie(E).map((k) => De(k, h));
|
|
1666
|
+
return M.map((k) => {
|
|
1667
|
+
const { x: T, y: B, width: b, height: C } = k;
|
|
1651
1668
|
return {
|
|
1652
1669
|
minX: T,
|
|
1653
|
-
minY:
|
|
1654
|
-
maxX: T +
|
|
1655
|
-
maxY:
|
|
1670
|
+
minY: B,
|
|
1671
|
+
maxX: T + b,
|
|
1672
|
+
maxY: B + C,
|
|
1656
1673
|
annotation: {
|
|
1657
|
-
id:
|
|
1658
|
-
rects:
|
|
1674
|
+
id: A.annotation,
|
|
1675
|
+
rects: M
|
|
1659
1676
|
}
|
|
1660
1677
|
};
|
|
1661
1678
|
});
|
|
1662
|
-
},
|
|
1679
|
+
}, s = () => [...o.values()], a = () => {
|
|
1663
1680
|
n.clear(), o.clear();
|
|
1664
|
-
},
|
|
1665
|
-
const
|
|
1666
|
-
|
|
1667
|
-
}, f = (
|
|
1668
|
-
const
|
|
1669
|
-
|
|
1670
|
-
},
|
|
1671
|
-
f(
|
|
1672
|
-
},
|
|
1673
|
-
|
|
1674
|
-
const
|
|
1675
|
-
|
|
1676
|
-
const
|
|
1677
|
-
n.load(
|
|
1678
|
-
},
|
|
1679
|
-
const
|
|
1680
|
-
minX:
|
|
1681
|
-
minY:
|
|
1682
|
-
maxX:
|
|
1683
|
-
maxY:
|
|
1684
|
-
}),
|
|
1685
|
-
return
|
|
1686
|
-
},
|
|
1687
|
-
const
|
|
1688
|
-
if (
|
|
1681
|
+
}, d = (A) => {
|
|
1682
|
+
const h = r(A, t.getBoundingClientRect());
|
|
1683
|
+
h.forEach((E) => n.insert(E)), o.set(A.annotation, h);
|
|
1684
|
+
}, f = (A) => {
|
|
1685
|
+
const h = o.get(A.annotation);
|
|
1686
|
+
h && (h.forEach((E) => n.remove(E)), o.delete(A.annotation));
|
|
1687
|
+
}, g = (A) => {
|
|
1688
|
+
f(A), d(A);
|
|
1689
|
+
}, l = (A, h = !0) => {
|
|
1690
|
+
h && a();
|
|
1691
|
+
const E = t.getBoundingClientRect(), M = A.map((T) => ({ target: T, rects: r(T, E) }));
|
|
1692
|
+
M.forEach(({ target: T, rects: B }) => o.set(T.annotation, B));
|
|
1693
|
+
const k = M.flatMap(({ rects: T }) => T);
|
|
1694
|
+
n.load(k);
|
|
1695
|
+
}, m = (A, h, E = !1) => {
|
|
1696
|
+
const M = n.search({
|
|
1697
|
+
minX: A,
|
|
1698
|
+
minY: h,
|
|
1699
|
+
maxX: A,
|
|
1700
|
+
maxY: h
|
|
1701
|
+
}), k = (T) => T.annotation.rects.reduce((B, b) => B + b.width * b.height, 0);
|
|
1702
|
+
return M.length > 0 ? (M.sort((T, B) => k(T) - k(B)), E ? M.map((T) => T.annotation.id) : [M[0].annotation.id]) : [];
|
|
1703
|
+
}, c = (A) => {
|
|
1704
|
+
const h = S(A);
|
|
1705
|
+
if (h.length === 0)
|
|
1689
1706
|
return;
|
|
1690
|
-
let
|
|
1691
|
-
for (let
|
|
1692
|
-
const
|
|
1693
|
-
|
|
1707
|
+
let E = h[0].left, M = h[0].top, k = h[0].right, T = h[0].bottom;
|
|
1708
|
+
for (let B = 1; B < h.length; B++) {
|
|
1709
|
+
const b = h[B];
|
|
1710
|
+
E = Math.min(E, b.left), M = Math.min(M, b.top), k = Math.max(k, b.right), T = Math.max(T, b.bottom);
|
|
1694
1711
|
}
|
|
1695
|
-
return new DOMRect(
|
|
1696
|
-
},
|
|
1697
|
-
const
|
|
1698
|
-
return
|
|
1712
|
+
return new DOMRect(E, M, k - E, T - M);
|
|
1713
|
+
}, S = (A) => {
|
|
1714
|
+
const h = o.get(A);
|
|
1715
|
+
return h ? h[0].annotation.rects : [];
|
|
1699
1716
|
};
|
|
1700
1717
|
return {
|
|
1701
|
-
all:
|
|
1702
|
-
clear:
|
|
1703
|
-
getAt:
|
|
1704
|
-
getAnnotationBounds:
|
|
1705
|
-
getAnnotationRects:
|
|
1706
|
-
getIntersecting: (
|
|
1707
|
-
const
|
|
1708
|
-
return Array.from(T).map((
|
|
1709
|
-
annotation: e.getAnnotation(
|
|
1710
|
-
rects:
|
|
1711
|
-
})).filter((
|
|
1718
|
+
all: s,
|
|
1719
|
+
clear: a,
|
|
1720
|
+
getAt: m,
|
|
1721
|
+
getAnnotationBounds: c,
|
|
1722
|
+
getAnnotationRects: S,
|
|
1723
|
+
getIntersecting: (A, h, E, M) => {
|
|
1724
|
+
const k = n.search({ minX: A, minY: h, maxX: E, maxY: M }), T = new Set(k.map((B) => B.annotation.id));
|
|
1725
|
+
return Array.from(T).map((B) => ({
|
|
1726
|
+
annotation: e.getAnnotation(B),
|
|
1727
|
+
rects: S(B)
|
|
1728
|
+
})).filter((B) => !!B.annotation);
|
|
1729
|
+
},
|
|
1730
|
+
insert: d,
|
|
1731
|
+
recalculate: () => {
|
|
1732
|
+
l(e.all().map((A) => A.target), !0), i.emit("recalculate");
|
|
1712
1733
|
},
|
|
1713
|
-
insert: a,
|
|
1714
|
-
recalculate: () => h(e.all().map((u) => u.target), !0),
|
|
1715
1734
|
remove: f,
|
|
1716
|
-
set:
|
|
1735
|
+
set: l,
|
|
1717
1736
|
size: () => n.all().length,
|
|
1718
|
-
update:
|
|
1737
|
+
update: g,
|
|
1738
|
+
on: (A, h) => i.on(A, h)
|
|
1719
1739
|
};
|
|
1720
|
-
},
|
|
1721
|
-
const n =
|
|
1722
|
-
const u = bt(
|
|
1723
|
-
return
|
|
1724
|
-
},
|
|
1725
|
-
const
|
|
1726
|
-
return
|
|
1727
|
-
},
|
|
1728
|
-
const u =
|
|
1729
|
-
return
|
|
1730
|
-
n.getAnnotation(
|
|
1731
|
-
}),
|
|
1732
|
-
},
|
|
1733
|
-
const u = mt(
|
|
1734
|
-
n.updateTarget(u,
|
|
1735
|
-
}, l = (
|
|
1736
|
-
const u =
|
|
1737
|
-
n.bulkUpdateTargets(u,
|
|
1738
|
-
},
|
|
1739
|
-
const
|
|
1740
|
-
return
|
|
1741
|
-
},
|
|
1742
|
-
const
|
|
1743
|
-
if (
|
|
1744
|
-
if (
|
|
1745
|
-
const
|
|
1746
|
-
if (
|
|
1740
|
+
}, oo = (e, t) => {
|
|
1741
|
+
const n = Tn(), o = no(n, e), i = pn(n, t), r = un(n), s = kn(), a = (w, p = V.LOCAL) => {
|
|
1742
|
+
const u = bt(w, e), A = z(u.target.selector);
|
|
1743
|
+
return A && n.addAnnotation(u, p), A;
|
|
1744
|
+
}, d = (w, p = !0, u = V.LOCAL) => {
|
|
1745
|
+
const A = w.map((E) => bt(E, e)), h = A.filter((E) => !z(E.target.selector));
|
|
1746
|
+
return h.length > 0 ? (console.warn("Could not revive all targets for these annotations:", h), n.bulkAddAnnotation(A, p, u), h) : (n.bulkAddAnnotation(A, p, u), []);
|
|
1747
|
+
}, f = (w, p = V.LOCAL) => {
|
|
1748
|
+
const u = w.map((h) => bt(h, e)), A = u.filter((h) => !z(h.target.selector));
|
|
1749
|
+
return A.length > 0 && console.warn("Could not revive all targets for these annotations:", A), u.forEach((h) => {
|
|
1750
|
+
n.getAnnotation(h.id) ? n.updateAnnotation(h, p) : n.addAnnotation(h, p);
|
|
1751
|
+
}), A;
|
|
1752
|
+
}, g = (w, p = V.LOCAL) => {
|
|
1753
|
+
const u = mt(w, e);
|
|
1754
|
+
n.updateTarget(u, p);
|
|
1755
|
+
}, l = (w, p = V.LOCAL) => {
|
|
1756
|
+
const u = w.map((A) => mt(A, e));
|
|
1757
|
+
n.bulkUpdateTargets(u, p);
|
|
1758
|
+
}, m = (w, p, u) => {
|
|
1759
|
+
const A = o.getAt(w, p, !!u).map((E) => n.getAnnotation(E)), h = u ? A.filter(u) : A;
|
|
1760
|
+
return h.length > 0 ? h[0] : void 0;
|
|
1761
|
+
}, c = (w, p, u, A = 5) => {
|
|
1762
|
+
const h = o.getAnnotationRects(w);
|
|
1763
|
+
if (h.length !== 0) {
|
|
1764
|
+
if (p && u) {
|
|
1765
|
+
const E = h.find(({ top: M, right: k, bottom: T, left: B }) => p >= B - A && p <= k + A && u >= M - A && u <= T + A);
|
|
1766
|
+
if (E) return E;
|
|
1747
1767
|
}
|
|
1748
|
-
return o.getAnnotationBounds(
|
|
1768
|
+
return o.getAnnotationBounds(w);
|
|
1749
1769
|
}
|
|
1750
|
-
},
|
|
1751
|
-
return n.observe(({ changes:
|
|
1752
|
-
const
|
|
1753
|
-
(
|
|
1770
|
+
}, S = () => o.recalculate(), v = (w) => o.on("recalculate", w);
|
|
1771
|
+
return n.observe(({ changes: w }) => {
|
|
1772
|
+
const p = (w.deleted || []).filter((h) => z(h.target.selector)), u = (w.created || []).filter((h) => z(h.target.selector)), A = (w.updated || []).filter((h) => z(h.newValue.target.selector));
|
|
1773
|
+
(p == null ? void 0 : p.length) > 0 && p.forEach((h) => o.remove(h.target)), u.length > 0 && o.set(u.map((h) => h.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: h }) => o.update(h.target));
|
|
1754
1774
|
}), {
|
|
1755
1775
|
store: {
|
|
1756
1776
|
...n,
|
|
1757
1777
|
addAnnotation: a,
|
|
1758
|
-
bulkAddAnnotation:
|
|
1778
|
+
bulkAddAnnotation: d,
|
|
1759
1779
|
bulkUpdateTargets: l,
|
|
1760
|
-
bulkUpsertAnnotations:
|
|
1761
|
-
getAnnotationBounds:
|
|
1762
|
-
getAt:
|
|
1780
|
+
bulkUpsertAnnotations: f,
|
|
1781
|
+
getAnnotationBounds: c,
|
|
1782
|
+
getAt: m,
|
|
1763
1783
|
getIntersecting: o.getIntersecting.bind(o),
|
|
1764
1784
|
getAnnotationRects: o.getAnnotationRects.bind(o),
|
|
1765
|
-
recalculatePositions:
|
|
1766
|
-
|
|
1785
|
+
recalculatePositions: S,
|
|
1786
|
+
onRecalculatePositions: v,
|
|
1787
|
+
updateTarget: g
|
|
1767
1788
|
},
|
|
1768
1789
|
selection: i,
|
|
1769
1790
|
hover: r,
|
|
1770
1791
|
viewport: s
|
|
1771
1792
|
};
|
|
1772
|
-
},
|
|
1793
|
+
}, io = () => {
|
|
1773
1794
|
const e = document.createElement("canvas");
|
|
1774
1795
|
e.width = 2 * window.innerWidth, e.height = 2 * window.innerHeight, e.className = "r6o-presence-layer";
|
|
1775
1796
|
const t = e.getContext("2d");
|
|
1776
1797
|
return t.scale(2, 2), t.translate(0.5, 0.5), e;
|
|
1777
|
-
},
|
|
1778
|
-
const o =
|
|
1798
|
+
}, ro = (e, t, n = {}) => {
|
|
1799
|
+
const o = io(), i = o.getContext("2d");
|
|
1779
1800
|
document.body.appendChild(o);
|
|
1780
|
-
const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([
|
|
1781
|
-
return t.on("selectionChange", (l,
|
|
1782
|
-
s(l).forEach((
|
|
1801
|
+
const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([m, c]) => c.presenceKey === l.presenceKey).map(([m, c]) => m);
|
|
1802
|
+
return t.on("selectionChange", (l, m) => {
|
|
1803
|
+
s(l).forEach((S) => r.delete(S)), m && m.forEach((S) => r.set(S, l));
|
|
1783
1804
|
}), {
|
|
1784
1805
|
clear: () => {
|
|
1785
|
-
const { width: l, height:
|
|
1786
|
-
i.clearRect(-0.5, -0.5, l + 1,
|
|
1806
|
+
const { width: l, height: m } = o;
|
|
1807
|
+
i.clearRect(-0.5, -0.5, l + 1, m + 1);
|
|
1787
1808
|
},
|
|
1788
1809
|
destroy: () => {
|
|
1789
1810
|
o.remove();
|
|
1790
1811
|
},
|
|
1791
|
-
paint: (l,
|
|
1812
|
+
paint: (l, m, c) => {
|
|
1792
1813
|
n.font && (i.font = n.font);
|
|
1793
|
-
const
|
|
1794
|
-
if (
|
|
1795
|
-
const { height:
|
|
1796
|
-
i.fillStyle =
|
|
1797
|
-
const
|
|
1798
|
-
return i.fillRect(
|
|
1799
|
-
fill:
|
|
1800
|
-
fillOpacity:
|
|
1814
|
+
const S = r.get(l.annotation.id);
|
|
1815
|
+
if (S) {
|
|
1816
|
+
const { height: v } = l.rects[0], w = l.rects[0].x + m.left, p = l.rects[0].y + m.top;
|
|
1817
|
+
i.fillStyle = S.appearance.color, i.fillRect(w - 2, p - 2.5, 2, v + 5);
|
|
1818
|
+
const u = i.measureText(S.appearance.label), A = u.width + 6, h = u.actualBoundingBoxAscent + u.actualBoundingBoxDescent + 8, E = u.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1819
|
+
return i.fillRect(w - 2, p - 2.5 - h, A, h), i.fillStyle = "#fff", i.fillText(S.appearance.label, w + 1, p - E), {
|
|
1820
|
+
fill: S.appearance.color,
|
|
1821
|
+
fillOpacity: c ? 0.45 : 0.18
|
|
1801
1822
|
};
|
|
1802
1823
|
}
|
|
1803
1824
|
},
|
|
@@ -1812,23 +1833,23 @@ const to = (e, t) => {
|
|
|
1812
1833
|
return document.scrollingElement;
|
|
1813
1834
|
const { overflowY: t } = window.getComputedStyle(e);
|
|
1814
1835
|
return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e : ue(e.parentElement);
|
|
1815
|
-
},
|
|
1836
|
+
}, ao = (e, t) => (n) => {
|
|
1816
1837
|
const o = typeof n == "string" ? n : n.id, i = (s) => {
|
|
1817
|
-
const a = r.getBoundingClientRect(),
|
|
1818
|
-
r.scroll({ top:
|
|
1838
|
+
const a = r.getBoundingClientRect(), d = r.clientHeight, f = r.clientWidth, g = s.selector[0].range.getBoundingClientRect(), { width: l, height: m } = t.getAnnotationBounds(o), c = g.top - a.top, S = g.left - a.left, v = r.parentElement ? r.scrollTop : 0, w = r.parentElement ? r.scrollLeft : 0, p = c + v - (d - m) / 2, u = S + w - (f - l) / 2;
|
|
1839
|
+
r.scroll({ top: p, left: u, behavior: "smooth" });
|
|
1819
1840
|
}, r = ue(e);
|
|
1820
1841
|
if (r) {
|
|
1821
1842
|
const s = t.getAnnotation(o), { range: a } = s.target.selector[0];
|
|
1822
1843
|
if (a && !a.collapsed)
|
|
1823
1844
|
return i(s.target), !0;
|
|
1824
1845
|
{
|
|
1825
|
-
const
|
|
1826
|
-
if (
|
|
1827
|
-
return i(
|
|
1846
|
+
const d = mt(s.target, e), { range: f } = d.selector[0];
|
|
1847
|
+
if (f && !f.collapsed)
|
|
1848
|
+
return i(d), !0;
|
|
1828
1849
|
}
|
|
1829
1850
|
}
|
|
1830
1851
|
return !1;
|
|
1831
|
-
},
|
|
1852
|
+
}, so = (e, t) => ({
|
|
1832
1853
|
...e,
|
|
1833
1854
|
annotatingEnabled: e.annotatingEnabled ?? t.annotatingEnabled,
|
|
1834
1855
|
user: e.user || t.user
|
|
@@ -1852,7 +1873,7 @@ function pe(e) {
|
|
|
1852
1873
|
t[n - 1] += ",", t.splice(n, 1), n = t.lastIndexOf("");
|
|
1853
1874
|
return t;
|
|
1854
1875
|
}
|
|
1855
|
-
function
|
|
1876
|
+
function lo(e, t) {
|
|
1856
1877
|
const n = e.length >= t.length ? e : t, o = e.length >= t.length ? t : e;
|
|
1857
1878
|
let i = !0;
|
|
1858
1879
|
for (let r = 0; r < n.length; r++)
|
|
@@ -1911,7 +1932,7 @@ const at = {
|
|
|
1911
1932
|
"[": 219,
|
|
1912
1933
|
"]": 221,
|
|
1913
1934
|
"\\": 220
|
|
1914
|
-
},
|
|
1935
|
+
}, $ = {
|
|
1915
1936
|
// shiftKey
|
|
1916
1937
|
"⇧": 16,
|
|
1917
1938
|
shift: 16,
|
|
@@ -1936,32 +1957,32 @@ const at = {
|
|
|
1936
1957
|
ctrlKey: 17,
|
|
1937
1958
|
altKey: 18,
|
|
1938
1959
|
metaKey: 91
|
|
1939
|
-
},
|
|
1960
|
+
}, y = {
|
|
1940
1961
|
16: !1,
|
|
1941
1962
|
18: !1,
|
|
1942
1963
|
17: !1,
|
|
1943
1964
|
91: !1
|
|
1944
|
-
},
|
|
1965
|
+
}, N = {};
|
|
1945
1966
|
for (let e = 1; e < 20; e++)
|
|
1946
1967
|
at["f".concat(e)] = 111 + e;
|
|
1947
|
-
let
|
|
1948
|
-
const
|
|
1968
|
+
let O = [], rt = null, he = "all";
|
|
1969
|
+
const W = /* @__PURE__ */ new Map(), lt = (e) => at[e.toLowerCase()] || $[e.toLowerCase()] || e.toUpperCase().charCodeAt(0), co = (e) => Object.keys(at).find((t) => at[t] === e), uo = (e) => Object.keys($).find((t) => $[t] === e);
|
|
1949
1970
|
function ge(e) {
|
|
1950
1971
|
he = e || "all";
|
|
1951
1972
|
}
|
|
1952
1973
|
function st() {
|
|
1953
1974
|
return he || "all";
|
|
1954
1975
|
}
|
|
1955
|
-
function
|
|
1956
|
-
return
|
|
1976
|
+
function fo() {
|
|
1977
|
+
return O.slice(0);
|
|
1957
1978
|
}
|
|
1958
|
-
function
|
|
1959
|
-
return
|
|
1979
|
+
function po() {
|
|
1980
|
+
return O.map((e) => co(e) || uo(e) || String.fromCharCode(e));
|
|
1960
1981
|
}
|
|
1961
|
-
function
|
|
1982
|
+
function ho() {
|
|
1962
1983
|
const e = [];
|
|
1963
|
-
return Object.keys(
|
|
1964
|
-
|
|
1984
|
+
return Object.keys(N).forEach((t) => {
|
|
1985
|
+
N[t].forEach((n) => {
|
|
1965
1986
|
let {
|
|
1966
1987
|
key: o,
|
|
1967
1988
|
scope: i,
|
|
@@ -1977,7 +1998,7 @@ function fo() {
|
|
|
1977
1998
|
});
|
|
1978
1999
|
}), e;
|
|
1979
2000
|
}
|
|
1980
|
-
function
|
|
2001
|
+
function go(e) {
|
|
1981
2002
|
const t = e.target || e.srcElement, {
|
|
1982
2003
|
tagName: n
|
|
1983
2004
|
} = t;
|
|
@@ -1985,15 +2006,15 @@ function po(e) {
|
|
|
1985
2006
|
const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(t.type);
|
|
1986
2007
|
return (t.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !t.readOnly) && (o = !1), o;
|
|
1987
2008
|
}
|
|
1988
|
-
function
|
|
1989
|
-
return typeof e == "string" && (e = lt(e)),
|
|
2009
|
+
function mo(e) {
|
|
2010
|
+
return typeof e == "string" && (e = lt(e)), O.indexOf(e) !== -1;
|
|
1990
2011
|
}
|
|
1991
|
-
function
|
|
2012
|
+
function bo(e, t) {
|
|
1992
2013
|
let n, o;
|
|
1993
2014
|
e || (e = st());
|
|
1994
|
-
for (const i in
|
|
1995
|
-
if (Object.prototype.hasOwnProperty.call(
|
|
1996
|
-
for (n =
|
|
2015
|
+
for (const i in N)
|
|
2016
|
+
if (Object.prototype.hasOwnProperty.call(N, i))
|
|
2017
|
+
for (n = N[i], o = 0; o < n.length; )
|
|
1997
2018
|
n[o].scope === e ? n.splice(o, 1).forEach((s) => {
|
|
1998
2019
|
let {
|
|
1999
2020
|
element: a
|
|
@@ -2002,18 +2023,18 @@ function go(e, t) {
|
|
|
2002
2023
|
}) : o++;
|
|
2003
2024
|
st() === e && ge(t || "all");
|
|
2004
2025
|
}
|
|
2005
|
-
function
|
|
2026
|
+
function wo(e) {
|
|
2006
2027
|
let t = e.keyCode || e.which || e.charCode;
|
|
2007
|
-
const n =
|
|
2008
|
-
if (n >= 0 &&
|
|
2009
|
-
|
|
2010
|
-
for (const o in
|
|
2028
|
+
const n = O.indexOf(t);
|
|
2029
|
+
if (n >= 0 && O.splice(n, 1), e.key && e.key.toLowerCase() === "meta" && O.splice(0, O.length), (t === 93 || t === 224) && (t = 91), t in y) {
|
|
2030
|
+
y[t] = !1;
|
|
2031
|
+
for (const o in $) $[o] === t && (U[o] = !1);
|
|
2011
2032
|
}
|
|
2012
2033
|
}
|
|
2013
2034
|
function me(e) {
|
|
2014
2035
|
if (typeof e > "u")
|
|
2015
|
-
Object.keys(
|
|
2016
|
-
Array.isArray(
|
|
2036
|
+
Object.keys(N).forEach((i) => {
|
|
2037
|
+
Array.isArray(N[i]) && N[i].forEach((r) => ht(r)), delete N[i];
|
|
2017
2038
|
}), Pt(null);
|
|
2018
2039
|
else if (Array.isArray(e))
|
|
2019
2040
|
e.forEach((i) => {
|
|
@@ -2041,14 +2062,14 @@ const ht = (e) => {
|
|
|
2041
2062
|
splitKey: i = "+"
|
|
2042
2063
|
} = e;
|
|
2043
2064
|
pe(t).forEach((s) => {
|
|
2044
|
-
const a = s.split(i),
|
|
2045
|
-
if (!
|
|
2065
|
+
const a = s.split(i), d = a.length, f = a[d - 1], g = f === "*" ? "*" : lt(f);
|
|
2066
|
+
if (!N[g]) return;
|
|
2046
2067
|
n || (n = st());
|
|
2047
|
-
const l =
|
|
2048
|
-
|
|
2049
|
-
const
|
|
2050
|
-
return
|
|
2051
|
-
}),
|
|
2068
|
+
const l = d > 1 ? fe($, a) : [], m = [];
|
|
2069
|
+
N[g] = N[g].filter((c) => {
|
|
2070
|
+
const v = (o ? c.method === o : !0) && c.scope === n && lo(c.mods, l);
|
|
2071
|
+
return v && m.push(c.element), !v;
|
|
2072
|
+
}), m.forEach((c) => Pt(c));
|
|
2052
2073
|
});
|
|
2053
2074
|
};
|
|
2054
2075
|
function Kt(e, t, n, o) {
|
|
@@ -2057,95 +2078,95 @@ function Kt(e, t, n, o) {
|
|
|
2057
2078
|
let i;
|
|
2058
2079
|
if (t.scope === n || t.scope === "all") {
|
|
2059
2080
|
i = t.mods.length > 0;
|
|
2060
|
-
for (const r in
|
|
2061
|
-
Object.prototype.hasOwnProperty.call(
|
|
2062
|
-
(t.mods.length === 0 && !
|
|
2081
|
+
for (const r in y)
|
|
2082
|
+
Object.prototype.hasOwnProperty.call(y, r) && (!y[r] && t.mods.indexOf(+r) > -1 || y[r] && t.mods.indexOf(+r) === -1) && (i = !1);
|
|
2083
|
+
(t.mods.length === 0 && !y[16] && !y[18] && !y[17] && !y[91] || i || t.shortcut === "*") && (t.keys = [], t.keys = t.keys.concat(O), t.method(e, t) === !1 && (e.preventDefault ? e.preventDefault() : e.returnValue = !1, e.stopPropagation && e.stopPropagation(), e.cancelBubble && (e.cancelBubble = !0)));
|
|
2063
2084
|
}
|
|
2064
2085
|
}
|
|
2065
2086
|
function te(e, t) {
|
|
2066
|
-
const n =
|
|
2087
|
+
const n = N["*"];
|
|
2067
2088
|
let o = e.keyCode || e.which || e.charCode;
|
|
2068
2089
|
if (!U.filter.call(this, e)) return;
|
|
2069
|
-
if ((o === 93 || o === 224) && (o = 91),
|
|
2070
|
-
const
|
|
2071
|
-
e[a] &&
|
|
2072
|
-
}), o in
|
|
2073
|
-
|
|
2074
|
-
for (const a in
|
|
2075
|
-
|
|
2090
|
+
if ((o === 93 || o === 224) && (o = 91), O.indexOf(o) === -1 && o !== 229 && O.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
|
|
2091
|
+
const d = Ot[a];
|
|
2092
|
+
e[a] && O.indexOf(d) === -1 ? O.push(d) : !e[a] && O.indexOf(d) > -1 ? O.splice(O.indexOf(d), 1) : a === "metaKey" && e[a] && O.length === 3 && (e.ctrlKey || e.shiftKey || e.altKey || (O = O.slice(O.indexOf(d))));
|
|
2093
|
+
}), o in y) {
|
|
2094
|
+
y[o] = !0;
|
|
2095
|
+
for (const a in $)
|
|
2096
|
+
$[a] === o && (U[a] = !0);
|
|
2076
2097
|
if (!n) return;
|
|
2077
2098
|
}
|
|
2078
|
-
for (const a in
|
|
2079
|
-
Object.prototype.hasOwnProperty.call(
|
|
2080
|
-
e.getModifierState && !(e.altKey && !e.ctrlKey) && e.getModifierState("AltGraph") && (
|
|
2099
|
+
for (const a in y)
|
|
2100
|
+
Object.prototype.hasOwnProperty.call(y, a) && (y[a] = e[Ot[a]]);
|
|
2101
|
+
e.getModifierState && !(e.altKey && !e.ctrlKey) && e.getModifierState("AltGraph") && (O.indexOf(17) === -1 && O.push(17), O.indexOf(18) === -1 && O.push(18), y[17] = !0, y[18] = !0);
|
|
2081
2102
|
const i = st();
|
|
2082
2103
|
if (n)
|
|
2083
2104
|
for (let a = 0; a < n.length; a++)
|
|
2084
2105
|
n[a].scope === i && (e.type === "keydown" && n[a].keydown || e.type === "keyup" && n[a].keyup) && Kt(e, n[a], i, t);
|
|
2085
|
-
if (!(o in
|
|
2086
|
-
const r =
|
|
2106
|
+
if (!(o in N)) return;
|
|
2107
|
+
const r = N[o], s = r.length;
|
|
2087
2108
|
for (let a = 0; a < s; a++)
|
|
2088
2109
|
if ((e.type === "keydown" && r[a].keydown || e.type === "keyup" && r[a].keyup) && r[a].key) {
|
|
2089
|
-
const
|
|
2090
|
-
splitKey:
|
|
2091
|
-
} =
|
|
2092
|
-
for (let
|
|
2093
|
-
l.push(lt(
|
|
2094
|
-
l.sort().join("") ===
|
|
2110
|
+
const d = r[a], {
|
|
2111
|
+
splitKey: f
|
|
2112
|
+
} = d, g = d.key.split(f), l = [];
|
|
2113
|
+
for (let m = 0; m < g.length; m++)
|
|
2114
|
+
l.push(lt(g[m]));
|
|
2115
|
+
l.sort().join("") === O.sort().join("") && Kt(e, d, i, t);
|
|
2095
2116
|
}
|
|
2096
2117
|
}
|
|
2097
2118
|
function U(e, t, n) {
|
|
2098
|
-
|
|
2119
|
+
O = [];
|
|
2099
2120
|
const o = pe(e);
|
|
2100
|
-
let i = [], r = "all", s = document, a = 0,
|
|
2101
|
-
for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (
|
|
2102
|
-
e = o[a].split(
|
|
2103
|
-
keyup:
|
|
2104
|
-
keydown:
|
|
2121
|
+
let i = [], r = "all", s = document, a = 0, d = !1, f = !0, g = "+", l = !1, m = !1;
|
|
2122
|
+
for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (d = t.keyup), t.keydown !== void 0 && (f = t.keydown), t.capture !== void 0 && (l = t.capture), typeof t.splitKey == "string" && (g = t.splitKey), t.single === !0 && (m = !0)), typeof t == "string" && (r = t), m && me(e, r); a < o.length; a++)
|
|
2123
|
+
e = o[a].split(g), i = [], e.length > 1 && (i = fe($, e)), e = e[e.length - 1], e = e === "*" ? "*" : lt(e), e in N || (N[e] = []), N[e].push({
|
|
2124
|
+
keyup: d,
|
|
2125
|
+
keydown: f,
|
|
2105
2126
|
scope: r,
|
|
2106
2127
|
mods: i,
|
|
2107
2128
|
shortcut: o[a],
|
|
2108
2129
|
method: n,
|
|
2109
2130
|
key: o[a],
|
|
2110
|
-
splitKey:
|
|
2131
|
+
splitKey: g,
|
|
2111
2132
|
element: s
|
|
2112
2133
|
});
|
|
2113
2134
|
if (typeof s < "u" && window) {
|
|
2114
|
-
if (!
|
|
2115
|
-
const
|
|
2116
|
-
let
|
|
2117
|
-
return te(
|
|
2118
|
-
},
|
|
2119
|
-
let
|
|
2120
|
-
te(
|
|
2135
|
+
if (!W.has(s)) {
|
|
2136
|
+
const c = function() {
|
|
2137
|
+
let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2138
|
+
return te(v, s);
|
|
2139
|
+
}, S = function() {
|
|
2140
|
+
let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2141
|
+
te(v, s), wo(v);
|
|
2121
2142
|
};
|
|
2122
|
-
|
|
2123
|
-
keydownListener:
|
|
2124
|
-
keyupListenr:
|
|
2143
|
+
W.set(s, {
|
|
2144
|
+
keydownListener: c,
|
|
2145
|
+
keyupListenr: S,
|
|
2125
2146
|
capture: l
|
|
2126
|
-
}), Bt(s, "keydown",
|
|
2147
|
+
}), Bt(s, "keydown", c, l), Bt(s, "keyup", S, l);
|
|
2127
2148
|
}
|
|
2128
2149
|
if (!rt) {
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2150
|
+
const c = () => {
|
|
2151
|
+
O = [];
|
|
2131
2152
|
};
|
|
2132
2153
|
rt = {
|
|
2133
|
-
listener:
|
|
2154
|
+
listener: c,
|
|
2134
2155
|
capture: l
|
|
2135
|
-
}, Bt(window, "focus",
|
|
2156
|
+
}, Bt(window, "focus", c, l);
|
|
2136
2157
|
}
|
|
2137
2158
|
}
|
|
2138
2159
|
}
|
|
2139
|
-
function
|
|
2160
|
+
function Ao(e) {
|
|
2140
2161
|
let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
|
|
2141
|
-
Object.keys(
|
|
2142
|
-
|
|
2162
|
+
Object.keys(N).forEach((n) => {
|
|
2163
|
+
N[n].filter((i) => i.scope === t && i.shortcut === e).forEach((i) => {
|
|
2143
2164
|
i && i.method && i.method();
|
|
2144
2165
|
});
|
|
2145
2166
|
});
|
|
2146
2167
|
}
|
|
2147
2168
|
function Pt(e) {
|
|
2148
|
-
const t = Object.values(
|
|
2169
|
+
const t = Object.values(N).flat();
|
|
2149
2170
|
if (t.findIndex((o) => {
|
|
2150
2171
|
let {
|
|
2151
2172
|
element: i
|
|
@@ -2156,17 +2177,17 @@ function Pt(e) {
|
|
|
2156
2177
|
keydownListener: o,
|
|
2157
2178
|
keyupListenr: i,
|
|
2158
2179
|
capture: r
|
|
2159
|
-
} =
|
|
2160
|
-
o && i && (et(e, "keyup", i, r), et(e, "keydown", o, r),
|
|
2180
|
+
} = W.get(e) || {};
|
|
2181
|
+
o && i && (et(e, "keyup", i, r), et(e, "keydown", o, r), W.delete(e));
|
|
2161
2182
|
}
|
|
2162
|
-
if ((t.length <= 0 ||
|
|
2183
|
+
if ((t.length <= 0 || W.size <= 0) && (Object.keys(W).forEach((i) => {
|
|
2163
2184
|
const {
|
|
2164
2185
|
keydownListener: r,
|
|
2165
2186
|
keyupListenr: s,
|
|
2166
2187
|
capture: a
|
|
2167
|
-
} =
|
|
2168
|
-
r && s && (et(i, "keyup", s, a), et(i, "keydown", r, a),
|
|
2169
|
-
}),
|
|
2188
|
+
} = W.get(i) || {};
|
|
2189
|
+
r && s && (et(i, "keyup", s, a), et(i, "keydown", r, a), W.delete(i));
|
|
2190
|
+
}), W.clear(), Object.keys(N).forEach((i) => delete N[i]), rt)) {
|
|
2170
2191
|
const {
|
|
2171
2192
|
listener: i,
|
|
2172
2193
|
capture: r
|
|
@@ -2174,23 +2195,23 @@ function Pt(e) {
|
|
|
2174
2195
|
et(window, "focus", i, r), rt = null;
|
|
2175
2196
|
}
|
|
2176
2197
|
}
|
|
2177
|
-
const
|
|
2178
|
-
getPressedKeyString:
|
|
2198
|
+
const Rt = {
|
|
2199
|
+
getPressedKeyString: po,
|
|
2179
2200
|
setScope: ge,
|
|
2180
2201
|
getScope: st,
|
|
2181
|
-
deleteScope:
|
|
2182
|
-
getPressedKeyCodes:
|
|
2183
|
-
getAllKeyCodes:
|
|
2184
|
-
isPressed:
|
|
2185
|
-
filter:
|
|
2186
|
-
trigger:
|
|
2202
|
+
deleteScope: bo,
|
|
2203
|
+
getPressedKeyCodes: fo,
|
|
2204
|
+
getAllKeyCodes: ho,
|
|
2205
|
+
isPressed: mo,
|
|
2206
|
+
filter: go,
|
|
2207
|
+
trigger: Ao,
|
|
2187
2208
|
unbind: me,
|
|
2188
2209
|
keyMap: at,
|
|
2189
|
-
modifier:
|
|
2210
|
+
modifier: $,
|
|
2190
2211
|
modifierMap: Ot
|
|
2191
2212
|
};
|
|
2192
|
-
for (const e in
|
|
2193
|
-
Object.prototype.hasOwnProperty.call(
|
|
2213
|
+
for (const e in Rt)
|
|
2214
|
+
Object.prototype.hasOwnProperty.call(Rt, e) && (U[e] = Rt[e]);
|
|
2194
2215
|
if (typeof window < "u") {
|
|
2195
2216
|
const e = window.hotkeys;
|
|
2196
2217
|
U.noConflict = (t) => (t && window.hotkeys === U && (window.hotkeys = e), U), window.hotkeys = U;
|
|
@@ -2201,130 +2222,130 @@ var be = {};
|
|
|
2201
2222
|
t.Unidentified = "Unidentified", t.Alt = "Alt", t.AltGraph = "AltGraph", t.CapsLock = "CapsLock", t.Control = "Control", t.Fn = "Fn", t.FnLock = "FnLock", t.Hyper = "Hyper", t.Meta = "Meta", t.NumLock = "NumLock", t.ScrollLock = "ScrollLock", t.Shift = "Shift", t.Super = "Super", t.Symbol = "Symbol", t.SymbolLock = "SymbolLock", t.Enter = "Enter", t.Tab = "Tab", t.ArrowDown = "ArrowDown", t.ArrowLeft = "ArrowLeft", t.ArrowRight = "ArrowRight", t.ArrowUp = "ArrowUp", t.End = "End", t.Home = "Home", t.PageDown = "PageDown", t.PageUp = "PageUp", t.Backspace = "Backspace", t.Clear = "Clear", t.Copy = "Copy", t.CrSel = "CrSel", t.Cut = "Cut", t.Delete = "Delete", t.EraseEof = "EraseEof", t.ExSel = "ExSel", t.Insert = "Insert", t.Paste = "Paste", t.Redo = "Redo", t.Undo = "Undo", t.Accept = "Accept", t.Again = "Again", t.Attn = "Attn", t.Cancel = "Cancel", t.ContextMenu = "ContextMenu", t.Escape = "Escape", t.Execute = "Execute", t.Find = "Find", t.Finish = "Finish", t.Help = "Help", t.Pause = "Pause", t.Play = "Play", t.Props = "Props", t.Select = "Select", t.ZoomIn = "ZoomIn", t.ZoomOut = "ZoomOut", t.BrightnessDown = "BrightnessDown", t.BrightnessUp = "BrightnessUp", t.Eject = "Eject", t.LogOff = "LogOff", t.Power = "Power", t.PowerOff = "PowerOff", t.PrintScreen = "PrintScreen", t.Hibernate = "Hibernate", t.Standby = "Standby", t.WakeUp = "WakeUp", t.AllCandidates = "AllCandidates", t.Alphanumeric = "Alphanumeric", t.CodeInput = "CodeInput", t.Compose = "Compose", t.Convert = "Convert", t.Dead = "Dead", t.FinalMode = "FinalMode", t.GroupFirst = "GroupFirst", t.GroupLast = "GroupLast", t.GroupNext = "GroupNext", t.GroupPrevious = "GroupPrevious", t.ModeChange = "ModeChange", t.NextCandidate = "NextCandidate", t.NonConvert = "NonConvert", t.PreviousCandidate = "PreviousCandidate", t.Process = "Process", t.SingleCandidate = "SingleCandidate", t.HangulMode = "HangulMode", t.HanjaMode = "HanjaMode", t.JunjaMode = "JunjaMode", t.Eisu = "Eisu", t.Hankaku = "Hankaku", t.Hiragana = "Hiragana", t.HiraganaKatakana = "HiraganaKatakana", t.KanaMode = "KanaMode", t.KanjiMode = "KanjiMode", t.Katakana = "Katakana", t.Romaji = "Romaji", t.Zenkaku = "Zenkaku", t.ZenkakuHanaku = "ZenkakuHanaku", t.F1 = "F1", t.F2 = "F2", t.F3 = "F3", t.F4 = "F4", t.F5 = "F5", t.F6 = "F6", t.F7 = "F7", t.F8 = "F8", t.F9 = "F9", t.F10 = "F10", t.F11 = "F11", t.F12 = "F12", t.F13 = "F13", t.F14 = "F14", t.F15 = "F15", t.F16 = "F16", t.F17 = "F17", t.F18 = "F18", t.F19 = "F19", t.F20 = "F20", t.Soft1 = "Soft1", t.Soft2 = "Soft2", t.Soft3 = "Soft3", t.Soft4 = "Soft4", t.AppSwitch = "AppSwitch", t.Call = "Call", t.Camera = "Camera", t.CameraFocus = "CameraFocus", t.EndCall = "EndCall", t.GoBack = "GoBack", t.GoHome = "GoHome", t.HeadsetHook = "HeadsetHook", t.LastNumberRedial = "LastNumberRedial", t.Notification = "Notification", t.MannerMode = "MannerMode", t.VoiceDial = "VoiceDial", t.ChannelDown = "ChannelDown", t.ChannelUp = "ChannelUp", t.MediaFastForward = "MediaFastForward", t.MediaPause = "MediaPause", t.MediaPlay = "MediaPlay", t.MediaPlayPause = "MediaPlayPause", t.MediaRecord = "MediaRecord", t.MediaRewind = "MediaRewind", t.MediaStop = "MediaStop", t.MediaTrackNext = "MediaTrackNext", t.MediaTrackPrevious = "MediaTrackPrevious", t.AudioBalanceLeft = "AudioBalanceLeft", t.AudioBalanceRight = "AudioBalanceRight", t.AudioBassDown = "AudioBassDown", t.AudioBassBoostDown = "AudioBassBoostDown", t.AudioBassBoostToggle = "AudioBassBoostToggle", t.AudioBassBoostUp = "AudioBassBoostUp", t.AudioBassUp = "AudioBassUp", t.AudioFaderFront = "AudioFaderFront", t.AudioFaderRear = "AudioFaderRear", t.AudioSurroundModeNext = "AudioSurroundModeNext", t.AudioTrebleDown = "AudioTrebleDown", t.AudioTrebleUp = "AudioTrebleUp", t.AudioVolumeDown = "AudioVolumeDown", t.AudioVolumeMute = "AudioVolumeMute", t.AudioVolumeUp = "AudioVolumeUp", t.MicrophoneToggle = "MicrophoneToggle", t.MicrophoneVolumeDown = "MicrophoneVolumeDown", t.MicrophoneVolumeMute = "MicrophoneVolumeMute", t.MicrophoneVolumeUp = "MicrophoneVolumeUp", t.TV = "TV", t.TV3DMode = "TV3DMode", t.TVAntennaCable = "TVAntennaCable", t.TVAudioDescription = "TVAudioDescription", t.TVAudioDescriptionMixDown = "TVAudioDescriptionMixDown", t.TVAudioDescriptionMixUp = "TVAudioDescriptionMixUp", t.TVContentsMenu = "TVContentsMenu", t.TVDataService = "TVDataService", t.TVInput = "TVInput", t.TVInputComponent1 = "TVInputComponent1", t.TVInputComponent2 = "TVInputComponent2", t.TVInputComposite1 = "TVInputComposite1", t.TVInputComposite2 = "TVInputComposite2", t.TVInputHDMI1 = "TVInputHDMI1", t.TVInputHDMI2 = "TVInputHDMI2", t.TVInputHDMI3 = "TVInputHDMI3", t.TVInputHDMI4 = "TVInputHDMI4", t.TVInputVGA1 = "TVInputVGA1", t.TVMediaContext = "TVMediaContext", t.TVNetwork = "TVNetwork", t.TVNumberEntry = "TVNumberEntry", t.TVPower = "TVPower", t.TVRadioService = "TVRadioService", t.TVSatellite = "TVSatellite", t.TVSatelliteBS = "TVSatelliteBS", t.TVSatelliteCS = "TVSatelliteCS", t.TVSatelliteToggle = "TVSatelliteToggle", t.TVTerrestrialAnalog = "TVTerrestrialAnalog", t.TVTerrestrialDigital = "TVTerrestrialDigital", t.TVTimer = "TVTimer", t.AVRInput = "AVRInput", t.AVRPower = "AVRPower", t.ColorF0Red = "ColorF0Red", t.ColorF1Green = "ColorF1Green", t.ColorF2Yellow = "ColorF2Yellow", t.ColorF3Blue = "ColorF3Blue", t.ColorF4Grey = "ColorF4Grey", t.ColorF5Brown = "ColorF5Brown", t.ClosedCaptionToggle = "ClosedCaptionToggle", t.Dimmer = "Dimmer", t.DisplaySwap = "DisplaySwap", t.DVR = "DVR", t.Exit = "Exit", t.FavoriteClear0 = "FavoriteClear0", t.FavoriteClear1 = "FavoriteClear1", t.FavoriteClear2 = "FavoriteClear2", t.FavoriteClear3 = "FavoriteClear3", t.FavoriteRecall0 = "FavoriteRecall0", t.FavoriteRecall1 = "FavoriteRecall1", t.FavoriteRecall2 = "FavoriteRecall2", t.FavoriteRecall3 = "FavoriteRecall3", t.FavoriteStore0 = "FavoriteStore0", t.FavoriteStore1 = "FavoriteStore1", t.FavoriteStore2 = "FavoriteStore2", t.FavoriteStore3 = "FavoriteStore3", t.Guide = "Guide", t.GuideNextDay = "GuideNextDay", t.GuidePreviousDay = "GuidePreviousDay", t.Info = "Info", t.InstantReplay = "InstantReplay", t.Link = "Link", t.ListProgram = "ListProgram", t.LiveContent = "LiveContent", t.Lock = "Lock", t.MediaApps = "MediaApps", t.MediaAudioTrack = "MediaAudioTrack", t.MediaLast = "MediaLast", t.MediaSkipBackward = "MediaSkipBackward", t.MediaSkipForward = "MediaSkipForward", t.MediaStepBackward = "MediaStepBackward", t.MediaStepForward = "MediaStepForward", t.MediaTopMenu = "MediaTopMenu", t.NavigateIn = "NavigateIn", t.NavigateNext = "NavigateNext", t.NavigateOut = "NavigateOut", t.NavigatePrevious = "NavigatePrevious", t.NextFavoriteChannel = "NextFavoriteChannel", t.NextUserProfile = "NextUserProfile", t.OnDemand = "OnDemand", t.Pairing = "Pairing", t.PinPDown = "PinPDown", t.PinPMove = "PinPMove", t.PinPToggle = "PinPToggle", t.PinPUp = "PinPUp", t.PlaySpeedDown = "PlaySpeedDown", t.PlaySpeedReset = "PlaySpeedReset", t.PlaySpeedUp = "PlaySpeedUp", t.RandomToggle = "RandomToggle", t.RcLowBattery = "RcLowBattery", t.RecordSpeedNext = "RecordSpeedNext", t.RfBypass = "RfBypass", t.ScanChannelsToggle = "ScanChannelsToggle", t.ScreenModeNext = "ScreenModeNext", t.Settings = "Settings", t.SplitScreenToggle = "SplitScreenToggle", t.STBInput = "STBInput", t.STBPower = "STBPower", t.Subtitle = "Subtitle", t.Teletext = "Teletext", t.VideoModeNext = "VideoModeNext", t.Wink = "Wink", t.ZoomToggle = "ZoomToggle", t.SpeechCorrectionList = "SpeechCorrectionList", t.SpeechInputToggle = "SpeechInputToggle", t.Close = "Close", t.New = "New", t.Open = "Open", t.Print = "Print", t.Save = "Save", t.SpellCheck = "SpellCheck", t.MailForward = "MailForward", t.MailReply = "MailReply", t.MailSend = "MailSend", t.LaunchCalculator = "LaunchCalculator", t.LaunchCalendar = "LaunchCalendar", t.LaunchContacts = "LaunchContacts", t.LaunchMail = "LaunchMail", t.LaunchMediaPlayer = "LaunchMediaPlayer", t.LaunchMusicPlayer = "LaunchMusicPlayer", t.LaunchMyComputer = "LaunchMyComputer", t.LaunchPhone = "LaunchPhone", t.LaunchScreenSaver = "LaunchScreenSaver", t.LaunchSpreadsheet = "LaunchSpreadsheet", t.LaunchWebBrowser = "LaunchWebBrowser", t.LaunchWebCam = "LaunchWebCam", t.LaunchWordProcessor = "LaunchWordProcessor", t.LaunchApplication1 = "LaunchApplication1", t.LaunchApplication2 = "LaunchApplication2", t.LaunchApplication3 = "LaunchApplication3", t.LaunchApplication4 = "LaunchApplication4", t.LaunchApplication5 = "LaunchApplication5", t.LaunchApplication6 = "LaunchApplication6", t.LaunchApplication7 = "LaunchApplication7", t.LaunchApplication8 = "LaunchApplication8", t.LaunchApplication9 = "LaunchApplication9", t.LaunchApplication10 = "LaunchApplication10", t.LaunchApplication11 = "LaunchApplication11", t.LaunchApplication12 = "LaunchApplication12", t.LaunchApplication13 = "LaunchApplication13", t.LaunchApplication14 = "LaunchApplication14", t.LaunchApplication15 = "LaunchApplication15", t.LaunchApplication16 = "LaunchApplication16", t.BrowserBack = "BrowserBack", t.BrowserFavorites = "BrowserFavorites", t.BrowserForward = "BrowserForward", t.BrowserHome = "BrowserHome", t.BrowserRefresh = "BrowserRefresh", t.BrowserSearch = "BrowserSearch", t.BrowserStop = "BrowserStop", t.Decimal = "Decimal", t.Key11 = "Key11", t.Key12 = "Key12", t.Multiply = "Multiply", t.Add = "Add", t.Divide = "Divide", t.Subtract = "Subtract", t.Separator = "Separator";
|
|
2202
2223
|
}(e.Key || (e.Key = {}));
|
|
2203
2224
|
})(be);
|
|
2204
|
-
const
|
|
2225
|
+
const So = (e, t, n) => {
|
|
2205
2226
|
let o;
|
|
2206
|
-
const i = (
|
|
2227
|
+
const i = (h) => o = h;
|
|
2207
2228
|
let r;
|
|
2208
|
-
const s = (
|
|
2229
|
+
const s = (h) => r = h;
|
|
2209
2230
|
let a = !0;
|
|
2210
|
-
const
|
|
2211
|
-
let l,
|
|
2212
|
-
const
|
|
2213
|
-
var
|
|
2214
|
-
if (!a ||
|
|
2231
|
+
const d = (h) => a = h, { store: f, selection: g } = t;
|
|
2232
|
+
let l, m, c;
|
|
2233
|
+
const S = (h) => {
|
|
2234
|
+
var M;
|
|
2235
|
+
if (!a || m === !1)
|
|
2215
2236
|
return;
|
|
2216
|
-
l = !((
|
|
2237
|
+
l = !((M = h.target.parentElement) != null && M.closest(X)) ? {
|
|
2217
2238
|
annotation: se(),
|
|
2218
2239
|
selector: [],
|
|
2219
2240
|
creator: o,
|
|
2220
2241
|
created: /* @__PURE__ */ new Date()
|
|
2221
2242
|
} : void 0;
|
|
2222
2243
|
};
|
|
2223
|
-
e.addEventListener("selectstart",
|
|
2224
|
-
const
|
|
2225
|
-
var
|
|
2244
|
+
e.addEventListener("selectstart", S);
|
|
2245
|
+
const v = Nt((h) => {
|
|
2246
|
+
var x, L;
|
|
2226
2247
|
if (!a) return;
|
|
2227
|
-
const
|
|
2228
|
-
if (!!((
|
|
2248
|
+
const E = document.getSelection();
|
|
2249
|
+
if (!!((L = (x = E.anchorNode) == null ? void 0 : x.parentElement) != null && L.closest(X))) {
|
|
2229
2250
|
l = void 0;
|
|
2230
2251
|
return;
|
|
2231
2252
|
}
|
|
2232
|
-
if (
|
|
2253
|
+
if (h.timeStamp - ((c == null ? void 0 : c.timeStamp) || h.timeStamp) < 1e3 && !l && S(c || h), E.isCollapsed || !l || m === !1)
|
|
2233
2254
|
return;
|
|
2234
|
-
const
|
|
2235
|
-
if (Ve(
|
|
2236
|
-
const
|
|
2237
|
-
(
|
|
2238
|
-
var
|
|
2239
|
-
return
|
|
2255
|
+
const T = E.getRangeAt(0), B = Pe(T, e);
|
|
2256
|
+
if (Ve(B)) return;
|
|
2257
|
+
const b = Ee(B.cloneRange());
|
|
2258
|
+
(b.length !== l.selector.length || b.some((R, I) => {
|
|
2259
|
+
var _;
|
|
2260
|
+
return R.toString() !== ((_ = l.selector[I]) == null ? void 0 : _.quote);
|
|
2240
2261
|
})) && (l = {
|
|
2241
2262
|
...l,
|
|
2242
|
-
selector:
|
|
2263
|
+
selector: b.map((R) => Fe(R, e, n)),
|
|
2243
2264
|
updated: /* @__PURE__ */ new Date()
|
|
2244
|
-
},
|
|
2265
|
+
}, f.getAnnotation(l.annotation) ? f.updateTarget(l, V.LOCAL) : (g.clear(), f.addAnnotation({
|
|
2245
2266
|
id: l.annotation,
|
|
2246
2267
|
bodies: [],
|
|
2247
2268
|
target: l
|
|
2248
|
-
},
|
|
2269
|
+
}, V.LOCAL), g.userSelect(l.annotation, c)));
|
|
2249
2270
|
});
|
|
2250
|
-
document.addEventListener("selectionchange",
|
|
2251
|
-
const
|
|
2252
|
-
|
|
2271
|
+
document.addEventListener("selectionchange", v);
|
|
2272
|
+
const w = (h) => {
|
|
2273
|
+
c = ye(h), m = c.button === 0;
|
|
2253
2274
|
};
|
|
2254
|
-
|
|
2255
|
-
const
|
|
2256
|
-
var
|
|
2257
|
-
if (!!((
|
|
2275
|
+
document.addEventListener("pointerdown", w);
|
|
2276
|
+
const p = (h) => {
|
|
2277
|
+
var T;
|
|
2278
|
+
if (!!((T = h.target.parentElement) != null && T.closest(X)) || !m)
|
|
2258
2279
|
return;
|
|
2259
|
-
const
|
|
2260
|
-
const { x:
|
|
2261
|
-
if (
|
|
2262
|
-
const { selected:
|
|
2263
|
-
(
|
|
2264
|
-
} else
|
|
2265
|
-
}, k =
|
|
2266
|
-
document.getSelection().isCollapsed && k < 300 ? (l = void 0,
|
|
2280
|
+
const M = () => {
|
|
2281
|
+
const { x: B, y: b } = e.getBoundingClientRect(), C = h.target instanceof Node && e.contains(h.target) && f.getAt(h.clientX - B, h.clientY - b, r);
|
|
2282
|
+
if (C) {
|
|
2283
|
+
const { selected: x } = g;
|
|
2284
|
+
(x.length !== 1 || x[0].id !== C.id) && g.userSelect(C.id, h);
|
|
2285
|
+
} else g.isEmpty() || g.clear();
|
|
2286
|
+
}, k = h.timeStamp - c.timeStamp;
|
|
2287
|
+
document.getSelection().isCollapsed && k < 300 ? (l = void 0, M()) : l && g.userSelect(l.annotation, h);
|
|
2267
2288
|
};
|
|
2268
|
-
document.addEventListener("pointerup",
|
|
2269
|
-
|
|
2270
|
-
}), U("*", { keyup: !0, keydown: !1 }, (
|
|
2271
|
-
U.shift &&
|
|
2289
|
+
document.addEventListener("pointerup", p), U("*", { element: e, keyup: !1, keydown: !0 }, (h, E) => {
|
|
2290
|
+
h.repeat || (c = Ue(h));
|
|
2291
|
+
}), U("*", { keyup: !0, keydown: !1 }, (h) => {
|
|
2292
|
+
U.shift && h.key === be.Key.Shift && !h.repeat && l && g.userSelect(l.annotation, h);
|
|
2272
2293
|
});
|
|
2273
|
-
let
|
|
2294
|
+
let u = !1;
|
|
2274
2295
|
return U("ctrl+a, ⌘+a", { keyup: !1, keydown: !0 }, () => {
|
|
2275
|
-
|
|
2276
|
-
}), U("*", { keyup: !0, keydown: !1 }, (
|
|
2277
|
-
|
|
2296
|
+
u = !0;
|
|
2297
|
+
}), U("*", { keyup: !0, keydown: !1 }, (h) => {
|
|
2298
|
+
u && !h.repeat && l && g.userSelect(l.annotation, h), u = !1;
|
|
2278
2299
|
}), {
|
|
2279
2300
|
destroy: () => {
|
|
2280
|
-
e.removeEventListener("selectstart",
|
|
2301
|
+
e.removeEventListener("selectstart", S), document.removeEventListener("selectionchange", v), document.removeEventListener("pointerdown", w), document.removeEventListener("pointerup", p), U.unbind();
|
|
2281
2302
|
},
|
|
2282
2303
|
setFilter: s,
|
|
2283
2304
|
setUser: i,
|
|
2284
|
-
setAnnotatingEnabled:
|
|
2305
|
+
setAnnotatingEnabled: d
|
|
2285
2306
|
};
|
|
2286
|
-
}, ee = "SPANS",
|
|
2287
|
-
|
|
2288
|
-
const n =
|
|
2307
|
+
}, ee = "SPANS", Mo = (e, t = {}) => {
|
|
2308
|
+
Le(e), Te(e);
|
|
2309
|
+
const n = so(t, {
|
|
2289
2310
|
annotatingEnabled: !0,
|
|
2290
|
-
user:
|
|
2291
|
-
}), o =
|
|
2292
|
-
let
|
|
2293
|
-
const
|
|
2311
|
+
user: Un()
|
|
2312
|
+
}), o = oo(e, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = Rn(s), d = Vn(o, a, n.adapter);
|
|
2313
|
+
let f = n.user;
|
|
2314
|
+
const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee, l = g === "SPANS" ? rn(e, o, r) : g === "CSS_HIGHLIGHTS" ? en(e, o, r) : g === "CANVAS" ? je(e, o, r) : void 0;
|
|
2294
2315
|
if (!l)
|
|
2295
|
-
throw `Unknown renderer implementation: ${
|
|
2296
|
-
console.debug(`Using ${
|
|
2297
|
-
const
|
|
2298
|
-
|
|
2299
|
-
const
|
|
2300
|
-
|
|
2301
|
-
},
|
|
2302
|
-
l.setFilter(
|
|
2303
|
-
},
|
|
2304
|
-
|
|
2305
|
-
},
|
|
2306
|
-
|
|
2307
|
-
},
|
|
2308
|
-
|
|
2316
|
+
throw `Unknown renderer implementation: ${g}`;
|
|
2317
|
+
console.debug(`Using ${g} renderer`), n.style && l.setStyle(n.style);
|
|
2318
|
+
const m = So(e, o, n.offsetReferenceSelector);
|
|
2319
|
+
m.setUser(f), m.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2320
|
+
const c = Nn(o, a, n.adapter), S = () => f, v = (E) => {
|
|
2321
|
+
m.setAnnotatingEnabled(E);
|
|
2322
|
+
}, w = (E) => {
|
|
2323
|
+
l.setFilter(E), m.setFilter(E);
|
|
2324
|
+
}, p = (E) => {
|
|
2325
|
+
f = E, m.setUser(E);
|
|
2326
|
+
}, u = (E) => {
|
|
2327
|
+
E && (l.setPainter(ro(e, E, n.presence)), E.on("selectionChange", () => l.redraw()));
|
|
2328
|
+
}, A = (E) => {
|
|
2329
|
+
E ? i.setSelected(E) : i.clear();
|
|
2309
2330
|
};
|
|
2310
2331
|
return {
|
|
2311
|
-
...
|
|
2332
|
+
...c,
|
|
2312
2333
|
destroy: () => {
|
|
2313
|
-
l.destroy(),
|
|
2334
|
+
l.destroy(), m.destroy(), a.destroy();
|
|
2314
2335
|
},
|
|
2315
2336
|
element: e,
|
|
2316
|
-
getUser:
|
|
2317
|
-
setAnnotatingEnabled:
|
|
2318
|
-
setFilter:
|
|
2337
|
+
getUser: S,
|
|
2338
|
+
setAnnotatingEnabled: v,
|
|
2339
|
+
setFilter: w,
|
|
2319
2340
|
setStyle: l.setStyle.bind(l),
|
|
2320
2341
|
redraw: l.redraw.bind(l),
|
|
2321
|
-
setUser:
|
|
2322
|
-
setSelected:
|
|
2323
|
-
setPresenceProvider:
|
|
2342
|
+
setUser: p,
|
|
2343
|
+
setSelected: A,
|
|
2344
|
+
setPresenceProvider: u,
|
|
2324
2345
|
setVisible: l.setVisible.bind(l),
|
|
2325
|
-
on:
|
|
2326
|
-
off:
|
|
2327
|
-
scrollIntoView:
|
|
2346
|
+
on: d.on,
|
|
2347
|
+
off: d.off,
|
|
2348
|
+
scrollIntoView: ao(e, s),
|
|
2328
2349
|
state: o
|
|
2329
2350
|
};
|
|
2330
2351
|
};
|
|
@@ -2332,41 +2353,42 @@ export {
|
|
|
2332
2353
|
gt as DEFAULT_SELECTED_STYLE,
|
|
2333
2354
|
q as DEFAULT_STYLE,
|
|
2334
2355
|
ne as NOT_ANNOTATABLE_CLASS,
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2355
|
-
|
|
2356
|
-
|
|
2356
|
+
X as NOT_ANNOTATABLE_SELECTOR,
|
|
2357
|
+
V as Origin,
|
|
2358
|
+
fn as UserSelectAction,
|
|
2359
|
+
To as W3CTextFormat,
|
|
2360
|
+
Le as cancelSingleClickEvents,
|
|
2361
|
+
Ue as cloneKeyboardEvent,
|
|
2362
|
+
ye as clonePointerEvent,
|
|
2363
|
+
Lo as createBody,
|
|
2364
|
+
je as createCanvasRenderer,
|
|
2365
|
+
en as createHighlightsRenderer,
|
|
2366
|
+
tn as createRenderer,
|
|
2367
|
+
rn as createSpansRenderer,
|
|
2368
|
+
Mo as createTextAnnotator,
|
|
2369
|
+
oo as createTextAnnotatorState,
|
|
2370
|
+
Nt as debounce,
|
|
2371
|
+
Eo as denormalizeRectWithOffset,
|
|
2372
|
+
so as fillDefaults,
|
|
2373
|
+
vo as getAnnotatableFragment,
|
|
2374
|
+
Co as getClientRectsPonyfill,
|
|
2375
|
+
Re as getQuoteContext,
|
|
2376
|
+
kt as getRangeAnnotatableContents,
|
|
2377
|
+
z as isRevived,
|
|
2357
2378
|
Ve as isWhitespaceOrEmpty,
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2379
|
+
Ie as mergeClientRects,
|
|
2380
|
+
De as normalizeRectWithOffset,
|
|
2381
|
+
ve as paint,
|
|
2382
|
+
jn as parseW3CTextAnnotation,
|
|
2362
2383
|
Te as programmaticallyFocusable,
|
|
2363
2384
|
Fe as rangeToSelector,
|
|
2364
2385
|
bt as reviveAnnotation,
|
|
2365
2386
|
oe as reviveSelector,
|
|
2366
2387
|
mt as reviveTarget,
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2388
|
+
Gn as serializeW3CTextAnnotation,
|
|
2389
|
+
Ee as splitAnnotatableRanges,
|
|
2390
|
+
xo as toDomRectList,
|
|
2391
|
+
Pe as trimRangeToContainer,
|
|
2392
|
+
ke as whitespaceOrEmptyRegex
|
|
2371
2393
|
};
|
|
2372
2394
|
//# sourceMappingURL=text-annotator.es.js.map
|