@soomo/text-annotator 3.0.0-staging.59 → 3.0.0-staging.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/SelectionHandler.d.ts +2 -1
- package/dist/src/TextAnnotator.d.ts +3 -3
- package/dist/src/TextAnnotatorOptions.d.ts +1 -1
- package/dist/src/highlight/baseRenderer.d.ts +1 -1
- package/dist/src/highlight/canvas/canvasRenderer.d.ts +2 -1
- package/dist/src/highlight/highlights/highlightsRenderer.d.ts +2 -1
- package/dist/src/highlight/span/spansRenderer.d.ts +2 -1
- package/dist/src/state/TextAnnotatorState.d.ts +5 -5
- package/dist/text-annotator.es.js +882 -882
- 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 +7 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const se = "not-annotatable", P = `.${se}`, Se = (t) => {
|
|
2
2
|
var n;
|
|
3
3
|
const e = t.commonAncestorContainer;
|
|
4
4
|
return e instanceof HTMLElement ? !e.closest(P) : !((n = e.parentElement) != null && n.closest(P));
|
|
@@ -6,7 +6,7 @@ const re = "not-annotatable", P = `.${re}`, Se = (t) => {
|
|
|
6
6
|
const e = document.createNodeIterator(
|
|
7
7
|
t.commonAncestorContainer,
|
|
8
8
|
NodeFilter.SHOW_ELEMENT,
|
|
9
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
9
|
+
(o) => o instanceof HTMLElement && o.classList.contains(se) && !o.parentElement.closest(P) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
10
10
|
);
|
|
11
11
|
let n;
|
|
12
12
|
for (; n = e.nextNode(); )
|
|
@@ -32,21 +32,21 @@ const re = "not-annotatable", P = `.${re}`, Se = (t) => {
|
|
|
32
32
|
!e.target.closest(P) && !e.target.closest("a") && e.preventDefault();
|
|
33
33
|
}), Te = (t) => {
|
|
34
34
|
!t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
|
|
35
|
-
},
|
|
35
|
+
}, xo = (t) => {
|
|
36
36
|
const e = t.cloneContents();
|
|
37
37
|
return e.querySelectorAll(P).forEach((n) => n.remove()), e;
|
|
38
38
|
}, Re = (t, e, n = 10, o) => {
|
|
39
|
-
const i = o ? t.startContainer.parentElement.closest(o) : e,
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
const
|
|
39
|
+
const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
|
|
40
|
+
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
41
|
+
const r = It(s).textContent, a = document.createRange();
|
|
42
|
+
a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
43
|
+
const l = It(a).textContent;
|
|
44
44
|
return {
|
|
45
|
-
prefix:
|
|
46
|
-
suffix:
|
|
45
|
+
prefix: r.substring(r.length - n),
|
|
46
|
+
suffix: l.substring(0, n)
|
|
47
47
|
};
|
|
48
48
|
}, Me = /^\s*$/, Be = (t) => Me.test(t.toString()), W = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = (t, e) => {
|
|
49
|
-
const n = (
|
|
49
|
+
const n = (s) => Math.round(s * 10) / 10, o = {
|
|
50
50
|
top: n(t.top),
|
|
51
51
|
bottom: n(t.bottom),
|
|
52
52
|
left: n(t.left),
|
|
@@ -70,25 +70,25 @@ const re = "not-annotatable", P = `.${re}`, Se = (t) => {
|
|
|
70
70
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
71
71
|
return "block-is-contained";
|
|
72
72
|
}, Ie = (t, e) => {
|
|
73
|
-
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top),
|
|
74
|
-
return new DOMRect(n, i, o - n,
|
|
73
|
+
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
|
|
74
|
+
return new DOMRect(n, i, o - n, s - i);
|
|
75
75
|
}, _e = (t) => t.reduce((e, n) => {
|
|
76
76
|
if (n.width === 0 || n.height === 0)
|
|
77
77
|
return e;
|
|
78
78
|
let o = [...e], i = !1;
|
|
79
|
-
for (const
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
o = o.map((
|
|
79
|
+
for (const s of e) {
|
|
80
|
+
const r = ke(n, s);
|
|
81
|
+
if (r === "inline-adjacent") {
|
|
82
|
+
o = o.map((a) => a === s ? Ie(n, s) : a), i = !0;
|
|
83
83
|
break;
|
|
84
|
-
} else if (
|
|
85
|
-
o = o.map((
|
|
84
|
+
} else if (r === "inline-contains") {
|
|
85
|
+
o = o.map((a) => a === s ? n : a), i = !0;
|
|
86
86
|
break;
|
|
87
|
-
} else if (
|
|
87
|
+
} else if (r === "inline-is-contained") {
|
|
88
88
|
i = !0;
|
|
89
89
|
break;
|
|
90
|
-
} else if (
|
|
91
|
-
n.width <
|
|
90
|
+
} else if (r === "block-contains" || r === "block-is-contained") {
|
|
91
|
+
n.width < s.width && (o = o.map((a) => a === s ? n : a)), i = !0;
|
|
92
92
|
break;
|
|
93
93
|
}
|
|
94
94
|
}
|
|
@@ -103,58 +103,58 @@ const re = "not-annotatable", P = `.${re}`, Se = (t) => {
|
|
|
103
103
|
}), Ne = (t, e, n) => {
|
|
104
104
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
105
105
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
106
|
-
const
|
|
107
|
-
return n ? { quote:
|
|
108
|
-
},
|
|
109
|
-
var
|
|
110
|
-
const { start: n, end: o } = t, i = t.offsetReference || e,
|
|
106
|
+
const s = It(o).textContent, r = t.toString(), a = s.length || 0, l = a + r.length;
|
|
107
|
+
return n ? { quote: r, start: a, end: l, range: t, offsetReference: i } : { quote: r, start: a, end: l, range: t };
|
|
108
|
+
}, re = (t, e) => {
|
|
109
|
+
var f, c;
|
|
110
|
+
const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
|
|
111
111
|
e,
|
|
112
112
|
NodeFilter.SHOW_TEXT,
|
|
113
|
-
(
|
|
114
|
-
var
|
|
115
|
-
return (
|
|
113
|
+
(g) => {
|
|
114
|
+
var h;
|
|
115
|
+
return (h = g.parentElement) != null && h.closest(P) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
116
116
|
}
|
|
117
117
|
);
|
|
118
|
-
let
|
|
119
|
-
const
|
|
120
|
-
let
|
|
121
|
-
|
|
122
|
-
let
|
|
123
|
-
for (;
|
|
124
|
-
if (
|
|
125
|
-
const
|
|
126
|
-
if (
|
|
127
|
-
|
|
118
|
+
let r = 0;
|
|
119
|
+
const a = document.createRange();
|
|
120
|
+
let l = s.nextNode();
|
|
121
|
+
l === null && console.error("Could not revive annotation target. Content missing.");
|
|
122
|
+
let u = !i;
|
|
123
|
+
for (; l !== null; ) {
|
|
124
|
+
if (u || (u = i == null ? void 0 : i.contains(l)), u) {
|
|
125
|
+
const g = ((f = l.textContent) == null ? void 0 : f.length) || 0;
|
|
126
|
+
if (r + g > n) {
|
|
127
|
+
a.setStart(l, n - r);
|
|
128
128
|
break;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
r += g;
|
|
131
131
|
}
|
|
132
|
-
|
|
132
|
+
l = s.nextNode();
|
|
133
133
|
}
|
|
134
|
-
for (;
|
|
135
|
-
const
|
|
136
|
-
if (
|
|
137
|
-
|
|
134
|
+
for (; l !== null; ) {
|
|
135
|
+
const g = ((c = l.textContent) == null ? void 0 : c.length) || 0;
|
|
136
|
+
if (r + g >= o) {
|
|
137
|
+
a.setEnd(l, o - r);
|
|
138
138
|
break;
|
|
139
139
|
}
|
|
140
|
-
|
|
140
|
+
r += g, l = s.nextNode();
|
|
141
141
|
}
|
|
142
142
|
return {
|
|
143
143
|
...t,
|
|
144
|
-
range:
|
|
144
|
+
range: a
|
|
145
145
|
};
|
|
146
146
|
}, yt = (t, e) => W(t.selector) ? t : {
|
|
147
147
|
...t,
|
|
148
|
-
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
148
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : re(n, e))
|
|
149
149
|
}, wt = (t, e) => W(t.target.selector) ? t : { ...t, target: yt(t.target, e) }, Ue = (t, e) => {
|
|
150
150
|
const n = t.cloneRange();
|
|
151
151
|
return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
|
|
152
152
|
}, Ve = (t, e) => {
|
|
153
|
-
const { left: n, top: o, right: i, bottom:
|
|
154
|
-
return new DOMRect(n - e.left, o - e.top, i - n,
|
|
153
|
+
const { left: n, top: o, right: i, bottom: s } = t;
|
|
154
|
+
return new DOMRect(n - e.left, o - e.top, i - n, s - o);
|
|
155
155
|
}, So = (t, e) => {
|
|
156
|
-
const { left: n, top: o, right: i, bottom:
|
|
157
|
-
return new DOMRect(n + e.left, o + e.top, i - n,
|
|
156
|
+
const { left: n, top: o, right: i, bottom: s } = t;
|
|
157
|
+
return new DOMRect(n + e.left, o + e.top, i - n, s - o);
|
|
158
158
|
}, De = (t) => ({
|
|
159
159
|
...t,
|
|
160
160
|
type: t.type,
|
|
@@ -203,18 +203,18 @@ const re = "not-annotatable", P = `.${re}`, Se = (t) => {
|
|
|
203
203
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
204
204
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ae(t.parentElement);
|
|
205
205
|
}, Ye = (t, e) => (n) => {
|
|
206
|
-
const o = typeof n == "string" ? n : n.id, i = (
|
|
207
|
-
const
|
|
208
|
-
|
|
209
|
-
},
|
|
210
|
-
if (
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
213
|
-
return i(
|
|
206
|
+
const o = typeof n == "string" ? n : n.id, i = (r) => {
|
|
207
|
+
const a = s.getBoundingClientRect(), l = s.clientHeight, u = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: c, height: g } = e.getAnnotationBounds(o), h = f.top - a.top, A = f.left - a.left, b = s.parentElement ? s.scrollTop : 0, S = s.parentElement ? s.scrollLeft : 0, p = h + b - (l - g) / 2, d = A + S - (u - c) / 2;
|
|
208
|
+
s.scroll({ top: p, left: d, behavior: "smooth" });
|
|
209
|
+
}, s = ae(t);
|
|
210
|
+
if (s) {
|
|
211
|
+
const r = e.getAnnotation(o), { range: a } = r.target.selector[0];
|
|
212
|
+
if (a && !a.collapsed)
|
|
213
|
+
return i(r.target), !0;
|
|
214
214
|
{
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
return i(
|
|
215
|
+
const l = yt(r.target, t), { range: u } = l.selector[0];
|
|
216
|
+
if (u && !u.collapsed)
|
|
217
|
+
return i(l), !0;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
220
|
return !1;
|
|
@@ -225,98 +225,98 @@ const re = "not-annotatable", P = `.${re}`, Se = (t) => {
|
|
|
225
225
|
fill: "rgb(0, 128, 255)",
|
|
226
226
|
fillOpacity: 0.45
|
|
227
227
|
}, Xe = (t, e, n, o, i) => {
|
|
228
|
-
var
|
|
229
|
-
const
|
|
230
|
-
return o && o.paint(t, e) ||
|
|
228
|
+
var r, a;
|
|
229
|
+
const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? bt : q) : n : (a = t.state) != null && a.selected ? bt : q;
|
|
230
|
+
return o && o.paint(t, e) || s;
|
|
231
231
|
};
|
|
232
232
|
function $e(t) {
|
|
233
233
|
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
234
234
|
}
|
|
235
235
|
var Ut = { exports: {} };
|
|
236
|
-
function
|
|
236
|
+
function ce(t, e = 100, n = {}) {
|
|
237
237
|
if (typeof t != "function")
|
|
238
238
|
throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
|
|
239
239
|
if (e < 0)
|
|
240
240
|
throw new RangeError("`wait` must not be negative.");
|
|
241
241
|
const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
|
|
242
|
-
let i, r, a,
|
|
243
|
-
function
|
|
244
|
-
const
|
|
245
|
-
return i = void 0,
|
|
242
|
+
let i, s, r, a, l;
|
|
243
|
+
function u() {
|
|
244
|
+
const g = i, h = s;
|
|
245
|
+
return i = void 0, s = void 0, l = t.apply(g, h), l;
|
|
246
246
|
}
|
|
247
|
-
function
|
|
248
|
-
const
|
|
249
|
-
|
|
247
|
+
function f() {
|
|
248
|
+
const g = Date.now() - a;
|
|
249
|
+
g < e && g >= 0 ? r = setTimeout(f, e - g) : (r = void 0, o || (l = u()));
|
|
250
250
|
}
|
|
251
|
-
const
|
|
251
|
+
const c = function(...g) {
|
|
252
252
|
if (i && this !== i && Object.getPrototypeOf(this) === Object.getPrototypeOf(i))
|
|
253
253
|
throw new Error("Debounced method called with different contexts of the same prototype.");
|
|
254
|
-
i = this,
|
|
255
|
-
const
|
|
256
|
-
return
|
|
254
|
+
i = this, s = g, a = Date.now();
|
|
255
|
+
const h = o && !r;
|
|
256
|
+
return r || (r = setTimeout(f, e)), h && (l = u()), l;
|
|
257
257
|
};
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
},
|
|
261
|
-
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
},
|
|
258
|
+
return c.clear = () => {
|
|
259
|
+
r && (clearTimeout(r), r = void 0);
|
|
260
|
+
}, c.flush = () => {
|
|
261
|
+
r && c.trigger();
|
|
262
|
+
}, c.trigger = () => {
|
|
263
|
+
l = u(), c.clear();
|
|
264
|
+
}, c;
|
|
265
265
|
}
|
|
266
|
-
Ut.exports.debounce =
|
|
267
|
-
Ut.exports =
|
|
266
|
+
Ut.exports.debounce = ce;
|
|
267
|
+
Ut.exports = ce;
|
|
268
268
|
var Pe = Ut.exports;
|
|
269
269
|
const Vt = /* @__PURE__ */ $e(Pe), je = (t) => {
|
|
270
|
-
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window,
|
|
271
|
-
return { top: e, left: n, minX:
|
|
270
|
+
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, l = i - e;
|
|
271
|
+
return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: l };
|
|
272
272
|
}, He = (t) => {
|
|
273
273
|
let e = /* @__PURE__ */ new Set();
|
|
274
274
|
return (o) => {
|
|
275
|
-
const i = o.map((
|
|
276
|
-
(e.size !== i.length || i.some((
|
|
275
|
+
const i = o.map((s) => s.id);
|
|
276
|
+
(e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
|
|
277
277
|
};
|
|
278
278
|
}, Dt = (t, e, n, o) => {
|
|
279
|
-
const { store: i, selection:
|
|
280
|
-
let
|
|
281
|
-
const
|
|
282
|
-
const { x: R, y: m } = t.getBoundingClientRect(), v = i.getAt(O.clientX - R, O.clientY - m,
|
|
283
|
-
v ?
|
|
279
|
+
const { store: i, selection: s, hover: r } = e;
|
|
280
|
+
let a, l, u;
|
|
281
|
+
const f = He(n), c = (O) => {
|
|
282
|
+
const { x: R, y: m } = t.getBoundingClientRect(), v = i.getAt(O.clientX - R, O.clientY - m, l);
|
|
283
|
+
v ? r.current !== v.id && (t.classList.add("hovered"), r.set(v.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
|
|
284
284
|
};
|
|
285
|
-
t.addEventListener("pointermove",
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
const R = je(t), { minX: m, minY: v, maxX: x, maxY: L } = R, B =
|
|
289
|
-
const
|
|
290
|
-
return { annotation: Y, rects:
|
|
285
|
+
t.addEventListener("pointermove", c);
|
|
286
|
+
const g = (O = !1) => {
|
|
287
|
+
u && u.clear();
|
|
288
|
+
const R = je(t), { minX: m, minY: v, maxX: x, maxY: L } = R, B = l ? i.getIntersecting(m, v, x, L).filter(({ annotation: Y }) => l(Y)) : i.getIntersecting(m, v, x, L), M = s.selected.map(({ id: Y }) => Y), K = B.map(({ annotation: Y, rects: lt }) => {
|
|
289
|
+
const xe = M.includes(Y.id), Ee = Y.id === r.current;
|
|
290
|
+
return { annotation: Y, rects: lt, state: { selected: xe, hover: Ee } };
|
|
291
291
|
});
|
|
292
|
-
o.redraw(K, R,
|
|
293
|
-
},
|
|
294
|
-
|
|
295
|
-
},
|
|
296
|
-
|
|
292
|
+
o.redraw(K, R, a, u, O), setTimeout(() => f(B.map(({ annotation: Y }) => Y)), 1);
|
|
293
|
+
}, h = (O) => {
|
|
294
|
+
u = O, g();
|
|
295
|
+
}, A = (O) => {
|
|
296
|
+
a = O, g();
|
|
297
297
|
}, b = (O) => {
|
|
298
|
-
|
|
299
|
-
},
|
|
300
|
-
i.observe(
|
|
301
|
-
const
|
|
302
|
-
document.addEventListener("scroll",
|
|
298
|
+
l = O, g(!1);
|
|
299
|
+
}, S = () => g();
|
|
300
|
+
i.observe(S);
|
|
301
|
+
const p = s.subscribe(() => g()), d = () => g(!0);
|
|
302
|
+
document.addEventListener("scroll", d, { capture: !0, passive: !0 });
|
|
303
303
|
const y = Vt(() => {
|
|
304
|
-
i.recalculatePositions(),
|
|
304
|
+
i.recalculatePositions(), u == null || u.reset(), g();
|
|
305
305
|
}, 10);
|
|
306
306
|
window.addEventListener("resize", y);
|
|
307
|
-
const
|
|
308
|
-
|
|
309
|
-
const
|
|
310
|
-
O.every((m) => m.target === t || t.contains(m.target)) ||
|
|
307
|
+
const C = new ResizeObserver(y);
|
|
308
|
+
C.observe(t);
|
|
309
|
+
const E = { attributes: !0, childList: !0, subtree: !0 }, w = new MutationObserver((O) => {
|
|
310
|
+
O.every((m) => m.target === t || t.contains(m.target)) || g(!0);
|
|
311
311
|
});
|
|
312
|
-
return w.observe(document.body,
|
|
312
|
+
return w.observe(document.body, E), {
|
|
313
313
|
destroy: () => {
|
|
314
|
-
t.removeEventListener("pointermove",
|
|
314
|
+
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(S), p(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), C.disconnect(), w.disconnect();
|
|
315
315
|
},
|
|
316
|
-
redraw:
|
|
317
|
-
setStyle:
|
|
316
|
+
redraw: g,
|
|
317
|
+
setStyle: A,
|
|
318
318
|
setFilter: b,
|
|
319
|
-
setPainter:
|
|
319
|
+
setPainter: h,
|
|
320
320
|
setVisible: o.setVisible
|
|
321
321
|
};
|
|
322
322
|
}, ze = () => {
|
|
@@ -328,28 +328,28 @@ const Vt = /* @__PURE__ */ $e(Pe), je = (t) => {
|
|
|
328
328
|
t.classList.add("r6o-annotatable");
|
|
329
329
|
const e = ze(), n = e.getContext("2d");
|
|
330
330
|
document.body.appendChild(e);
|
|
331
|
-
const o = (
|
|
332
|
-
const { width:
|
|
333
|
-
n.clearRect(-0.5, -0.5,
|
|
334
|
-
const { top:
|
|
335
|
-
[...
|
|
336
|
-
const { annotation: { target: { created:
|
|
337
|
-
return
|
|
338
|
-
}).forEach((
|
|
339
|
-
var
|
|
340
|
-
const
|
|
341
|
-
x:
|
|
342
|
-
y: w +
|
|
331
|
+
const o = (a, l, u, f) => requestAnimationFrame(() => {
|
|
332
|
+
const { width: c, height: g } = e;
|
|
333
|
+
n.clearRect(-0.5, -0.5, c + 1, g + 1), f && f.clear();
|
|
334
|
+
const { top: h, left: A } = l;
|
|
335
|
+
[...a].sort((S, p) => {
|
|
336
|
+
const { annotation: { target: { created: d } } } = S, { annotation: { target: { created: y } } } = p;
|
|
337
|
+
return d.getTime() - y.getTime();
|
|
338
|
+
}).forEach((S) => {
|
|
339
|
+
var C;
|
|
340
|
+
const p = u ? typeof u == "function" ? u(S.annotation, S.state) : u : (C = S.state) != null && C.selected ? bt : q, d = f && f.paint(S, l) || p, y = S.rects.map(({ x: E, y: w, width: T, height: O }) => ({
|
|
341
|
+
x: E + A,
|
|
342
|
+
y: w + h,
|
|
343
343
|
width: T,
|
|
344
344
|
height: O
|
|
345
345
|
}));
|
|
346
|
-
if (n.fillStyle =
|
|
347
|
-
({ x:
|
|
348
|
-
),
|
|
349
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
350
|
-
const
|
|
346
|
+
if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, y.forEach(
|
|
347
|
+
({ x: E, y: w, width: T, height: O }) => n.fillRect(E, w, T, O)
|
|
348
|
+
), d.underlineColor) {
|
|
349
|
+
n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
|
|
350
|
+
const E = d.underlineOffset ?? 0;
|
|
351
351
|
y.forEach(({ x: w, y: T, width: O, height: R }) => {
|
|
352
|
-
n.beginPath(), n.moveTo(w, T + R +
|
|
352
|
+
n.beginPath(), n.moveTo(w, T + R + E), n.lineTo(w + O, T + R + E), n.stroke();
|
|
353
353
|
});
|
|
354
354
|
}
|
|
355
355
|
});
|
|
@@ -358,7 +358,7 @@ const Vt = /* @__PURE__ */ $e(Pe), je = (t) => {
|
|
|
358
358
|
destroy: () => {
|
|
359
359
|
e.remove(), i.clear(), window.removeEventListener("resize", i);
|
|
360
360
|
},
|
|
361
|
-
setVisible: (
|
|
361
|
+
setVisible: (a) => {
|
|
362
362
|
console.log("setVisible not implemented on Canvas renderer");
|
|
363
363
|
},
|
|
364
364
|
redraw: o
|
|
@@ -370,7 +370,7 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
370
370
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
371
371
|
}, X = function(t, e, n) {
|
|
372
372
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
373
|
-
},
|
|
373
|
+
}, le = function(t) {
|
|
374
374
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
375
375
|
}, Xt = function(t) {
|
|
376
376
|
return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
|
|
@@ -380,15 +380,15 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
380
380
|
var e = t.toString(16);
|
|
381
381
|
return e.length < 2 ? "0" + e : e;
|
|
382
382
|
}, de = function(t) {
|
|
383
|
-
var e = t.r, n = t.g, o = t.b, i = t.a,
|
|
384
|
-
return { h: 60 * (
|
|
383
|
+
var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), r = s - Math.min(e, n, o), a = r ? s === e ? (n - o) / r : s === n ? 2 + (o - e) / r : 4 + (e - n) / r : 0;
|
|
384
|
+
return { h: 60 * (a < 0 ? a + 6 : a), s: s ? r / s * 100 : 0, v: s / 255 * 100, a: i };
|
|
385
385
|
}, ue = function(t) {
|
|
386
386
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
387
387
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
388
|
-
var
|
|
389
|
-
return { r: 255 * [o,
|
|
388
|
+
var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), u = s % 6;
|
|
389
|
+
return { r: 255 * [o, a, r, r, l, o][u], g: 255 * [l, o, o, a, r, r][u], b: 255 * [r, r, l, o, o, a][u], a: i };
|
|
390
390
|
}, $t = function(t) {
|
|
391
|
-
return { h:
|
|
391
|
+
return { h: le(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
|
|
392
392
|
}, Pt = function(t) {
|
|
393
393
|
return { h: N(t.h), s: N(t.s), l: N(t.l), a: N(t.a, 3) };
|
|
394
394
|
}, jt = function(t) {
|
|
@@ -409,20 +409,20 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
409
409
|
var n, o, i = $t({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (Ge[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
410
410
|
return jt(i);
|
|
411
411
|
}, "hsl"]], object: [[function(t) {
|
|
412
|
-
var e = t.r, n = t.g, o = t.b, i = t.a,
|
|
413
|
-
return z(e) && z(n) && z(o) ? Xt({ r: Number(e), g: Number(n), b: Number(o), a: Number(
|
|
412
|
+
var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
|
|
413
|
+
return z(e) && z(n) && z(o) ? Xt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
|
|
414
414
|
}, "rgb"], [function(t) {
|
|
415
|
-
var e = t.h, n = t.s, o = t.l, i = t.a,
|
|
415
|
+
var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
|
|
416
416
|
if (!z(e) || !z(n) || !z(o)) return null;
|
|
417
|
-
var
|
|
418
|
-
return jt(
|
|
417
|
+
var r = $t({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
|
|
418
|
+
return jt(r);
|
|
419
419
|
}, "hsl"], [function(t) {
|
|
420
|
-
var e = t.h, n = t.s, o = t.v, i = t.a,
|
|
420
|
+
var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
|
|
421
421
|
if (!z(e) || !z(n) || !z(o)) return null;
|
|
422
|
-
var
|
|
423
|
-
return { h:
|
|
424
|
-
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(
|
|
425
|
-
return ue(
|
|
422
|
+
var r = function(a) {
|
|
423
|
+
return { h: le(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
|
|
424
|
+
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
|
|
425
|
+
return ue(r);
|
|
426
426
|
}, "hsv"]] }, zt = function(t, e) {
|
|
427
427
|
for (var n = 0; n < e.length; n++) {
|
|
428
428
|
var o = e[n][0](t);
|
|
@@ -431,10 +431,10 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
431
431
|
return [null, void 0];
|
|
432
432
|
}, nn = function(t) {
|
|
433
433
|
return typeof t == "string" ? zt(t.trim(), Ht.string) : typeof t == "object" && t !== null ? zt(t, Ht.object) : [null, void 0];
|
|
434
|
-
},
|
|
434
|
+
}, At = function(t, e) {
|
|
435
435
|
var n = it(t);
|
|
436
436
|
return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
437
|
-
},
|
|
437
|
+
}, xt = function(t) {
|
|
438
438
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
439
439
|
}, Ft = function(t, e) {
|
|
440
440
|
var n = it(t);
|
|
@@ -446,24 +446,24 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
446
446
|
return t.prototype.isValid = function() {
|
|
447
447
|
return this.parsed !== null;
|
|
448
448
|
}, t.prototype.brightness = function() {
|
|
449
|
-
return N(
|
|
449
|
+
return N(xt(this.rgba), 2);
|
|
450
450
|
}, t.prototype.isDark = function() {
|
|
451
|
-
return
|
|
451
|
+
return xt(this.rgba) < 0.5;
|
|
452
452
|
}, t.prototype.isLight = function() {
|
|
453
|
-
return
|
|
453
|
+
return xt(this.rgba) >= 0.5;
|
|
454
454
|
}, t.prototype.toHex = function() {
|
|
455
|
-
return e = vt(this.rgba), n = e.r, o = e.g, i = e.b,
|
|
456
|
-
var e, n, o, i,
|
|
455
|
+
return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? dt(N(255 * s)) : "", "#" + dt(n) + dt(o) + dt(i) + r;
|
|
456
|
+
var e, n, o, i, s, r;
|
|
457
457
|
}, t.prototype.toRgb = function() {
|
|
458
458
|
return vt(this.rgba);
|
|
459
459
|
}, t.prototype.toRgbString = function() {
|
|
460
|
-
return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, (
|
|
461
|
-
var e, n, o, i,
|
|
460
|
+
return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
461
|
+
var e, n, o, i, s;
|
|
462
462
|
}, t.prototype.toHsl = function() {
|
|
463
463
|
return Pt(it(this.rgba));
|
|
464
464
|
}, t.prototype.toHslString = function() {
|
|
465
|
-
return e = Pt(it(this.rgba)), n = e.h, o = e.s, i = e.l, (
|
|
466
|
-
var e, n, o, i,
|
|
465
|
+
return e = Pt(it(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
466
|
+
var e, n, o, i, s;
|
|
467
467
|
}, t.prototype.toHsv = function() {
|
|
468
468
|
return e = de(this.rgba), { h: N(e.h), s: N(e.s), v: N(e.v), a: N(e.a, 3) };
|
|
469
469
|
var e;
|
|
@@ -471,11 +471,11 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
|
|
|
471
471
|
return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
472
472
|
var e;
|
|
473
473
|
}, t.prototype.saturate = function(e) {
|
|
474
|
-
return e === void 0 && (e = 0.1), $(
|
|
474
|
+
return e === void 0 && (e = 0.1), $(At(this.rgba, e));
|
|
475
475
|
}, t.prototype.desaturate = function(e) {
|
|
476
|
-
return e === void 0 && (e = 0.1), $(
|
|
476
|
+
return e === void 0 && (e = 0.1), $(At(this.rgba, -e));
|
|
477
477
|
}, t.prototype.grayscale = function() {
|
|
478
|
-
return $(
|
|
478
|
+
return $(At(this.rgba, -1));
|
|
479
479
|
}, t.prototype.lighten = function(e) {
|
|
480
480
|
return e === void 0 && (e = 0.1), $(Ft(this.rgba, e));
|
|
481
481
|
}, t.prototype.darken = function(e) {
|
|
@@ -500,7 +500,7 @@ const on = (t) => [
|
|
|
500
500
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
501
501
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
502
502
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
503
|
-
].filter(Boolean).join(";"),
|
|
503
|
+
].filter(Boolean).join(";"), sn = () => {
|
|
504
504
|
const t = document.createElement("style");
|
|
505
505
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
506
506
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -508,26 +508,26 @@ const on = (t) => [
|
|
|
508
508
|
destroy: () => {
|
|
509
509
|
CSS.highlights.clear(), t.remove();
|
|
510
510
|
},
|
|
511
|
-
setVisible: (
|
|
511
|
+
setVisible: (s) => {
|
|
512
512
|
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
513
513
|
},
|
|
514
|
-
redraw: (r, a,
|
|
515
|
-
|
|
516
|
-
const
|
|
517
|
-
Array.from(e).filter((
|
|
518
|
-
const
|
|
519
|
-
var
|
|
520
|
-
const
|
|
521
|
-
return `::highlight(_${
|
|
514
|
+
redraw: (s, r, a, l) => {
|
|
515
|
+
l && l.clear();
|
|
516
|
+
const u = new Set(s.map((c) => c.annotation.id));
|
|
517
|
+
Array.from(e).filter((c) => !u.has(c));
|
|
518
|
+
const f = s.map((c) => {
|
|
519
|
+
var A;
|
|
520
|
+
const g = a ? typeof a == "function" ? a(c.annotation, c.state) : a : (A = c.state) != null && A.selected ? bt : q, h = l && l.paint(c, r) || g;
|
|
521
|
+
return `::highlight(_${c.annotation.id}) { ${on(h)} }`;
|
|
522
522
|
});
|
|
523
|
-
t.innerHTML =
|
|
524
|
-
`), CSS.highlights.clear(),
|
|
525
|
-
const
|
|
526
|
-
CSS.highlights.set(`_${
|
|
527
|
-
}), e =
|
|
523
|
+
t.innerHTML = f.join(`
|
|
524
|
+
`), CSS.highlights.clear(), s.forEach(({ annotation: c }) => {
|
|
525
|
+
const g = c.target.selector.map((A) => A.range), h = new Highlight(...g);
|
|
526
|
+
CSS.highlights.set(`_${c.id}`, h);
|
|
527
|
+
}), e = u;
|
|
528
528
|
}
|
|
529
529
|
};
|
|
530
|
-
},
|
|
530
|
+
}, rn = (t, e, n) => Dt(t, e, n, sn());
|
|
531
531
|
var qt = Object.prototype.hasOwnProperty;
|
|
532
532
|
function _t(t, e) {
|
|
533
533
|
var n, o;
|
|
@@ -550,9 +550,9 @@ function _t(t, e) {
|
|
|
550
550
|
return t !== t && e !== e;
|
|
551
551
|
}
|
|
552
552
|
const an = (t, e) => {
|
|
553
|
-
const n = (
|
|
554
|
-
return i.sort((
|
|
555
|
-
},
|
|
553
|
+
const n = (s, r) => s.x <= r.x + r.width && s.x + s.width >= r.x && s.y <= r.y + r.height && s.y + s.height >= r.y, o = (s) => s.rects.reduce((r, a) => r + a.width, 0), i = e.filter(({ rects: s }) => s.some((r) => n(t, r)));
|
|
554
|
+
return i.sort((s, r) => o(r) - o(s)), i.findIndex((s) => s.rects.includes(t));
|
|
555
|
+
}, cn = (t) => {
|
|
556
556
|
t.classList.add("r6o-annotatable");
|
|
557
557
|
const e = document.createElement("div");
|
|
558
558
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -561,27 +561,27 @@ const an = (t, e) => {
|
|
|
561
561
|
destroy: () => {
|
|
562
562
|
e.remove();
|
|
563
563
|
},
|
|
564
|
-
redraw: (a,
|
|
565
|
-
const
|
|
566
|
-
if (!
|
|
567
|
-
|
|
568
|
-
const { annotation: { target: { created:
|
|
569
|
-
return
|
|
570
|
-
}).forEach((
|
|
571
|
-
|
|
572
|
-
const
|
|
573
|
-
if (
|
|
574
|
-
const
|
|
575
|
-
|
|
564
|
+
redraw: (r, a, l, u, f) => {
|
|
565
|
+
const g = !(_t(n, r) && f);
|
|
566
|
+
if (!u && !g) return;
|
|
567
|
+
g && (e.innerHTML = ""), [...r].sort((A, b) => {
|
|
568
|
+
const { annotation: { target: { created: S } } } = A, { annotation: { target: { created: p } } } = b;
|
|
569
|
+
return S && p ? S.getTime() - p.getTime() : 0;
|
|
570
|
+
}).forEach((A) => {
|
|
571
|
+
A.rects.map((b) => {
|
|
572
|
+
const S = an(b, r), p = Xe(A, a, l, u, S);
|
|
573
|
+
if (g) {
|
|
574
|
+
const d = document.createElement("span");
|
|
575
|
+
d.className = "r6o-annotation", d.dataset.annotation = A.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = $((p == null ? void 0 : p.fill) || q.fill).alpha((p == null ? void 0 : p.fillOpacity) === void 0 ? q.fillOpacity : p.fillOpacity).toHex(), p.underlineStyle && (d.style.borderStyle = p.underlineStyle), p.underlineColor && (d.style.borderColor = p.underlineColor), p.underlineThickness && (d.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (d.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(d);
|
|
576
576
|
}
|
|
577
577
|
});
|
|
578
|
-
}), n =
|
|
578
|
+
}), n = r;
|
|
579
579
|
},
|
|
580
|
-
setVisible: (
|
|
581
|
-
|
|
580
|
+
setVisible: (r) => {
|
|
581
|
+
r ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
582
582
|
}
|
|
583
583
|
};
|
|
584
|
-
},
|
|
584
|
+
}, ln = (t, e, n) => Dt(t, e, n, cn(t));
|
|
585
585
|
var U = [];
|
|
586
586
|
for (var Et = 0; Et < 256; ++Et)
|
|
587
587
|
U.push((Et + 256).toString(16).slice(1));
|
|
@@ -628,44 +628,44 @@ function G(t, e) {
|
|
|
628
628
|
}
|
|
629
629
|
function St() {
|
|
630
630
|
}
|
|
631
|
-
function
|
|
631
|
+
function pn(t, e) {
|
|
632
632
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
633
633
|
}
|
|
634
634
|
const Q = [];
|
|
635
635
|
function Kt(t, e = St) {
|
|
636
636
|
let n;
|
|
637
637
|
const o = /* @__PURE__ */ new Set();
|
|
638
|
-
function i(
|
|
639
|
-
if (
|
|
640
|
-
const
|
|
641
|
-
for (const
|
|
642
|
-
|
|
643
|
-
if (
|
|
644
|
-
for (let
|
|
645
|
-
Q[
|
|
638
|
+
function i(a) {
|
|
639
|
+
if (pn(t, a) && (t = a, n)) {
|
|
640
|
+
const l = !Q.length;
|
|
641
|
+
for (const u of o)
|
|
642
|
+
u[1](), Q.push(u, t);
|
|
643
|
+
if (l) {
|
|
644
|
+
for (let u = 0; u < Q.length; u += 2)
|
|
645
|
+
Q[u][0](Q[u + 1]);
|
|
646
646
|
Q.length = 0;
|
|
647
647
|
}
|
|
648
648
|
}
|
|
649
649
|
}
|
|
650
|
-
function
|
|
651
|
-
i(
|
|
650
|
+
function s(a) {
|
|
651
|
+
i(a(t));
|
|
652
652
|
}
|
|
653
|
-
function a
|
|
654
|
-
const
|
|
655
|
-
return o.add(
|
|
656
|
-
o.delete(
|
|
653
|
+
function r(a, l = St) {
|
|
654
|
+
const u = [a, l];
|
|
655
|
+
return o.add(u), o.size === 1 && (n = e(i, s) || St), a(t), () => {
|
|
656
|
+
o.delete(u), o.size === 0 && n && (n(), n = null);
|
|
657
657
|
};
|
|
658
658
|
}
|
|
659
|
-
return { set: i, update:
|
|
659
|
+
return { set: i, update: s, subscribe: r };
|
|
660
660
|
}
|
|
661
|
-
const
|
|
661
|
+
const gn = (t) => {
|
|
662
662
|
const { subscribe: e, set: n } = Kt();
|
|
663
663
|
let o;
|
|
664
664
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
665
665
|
if (o) {
|
|
666
|
-
(i.deleted || []).some((
|
|
667
|
-
const
|
|
668
|
-
|
|
666
|
+
(i.deleted || []).some((r) => r.id === o) && n(void 0);
|
|
667
|
+
const s = (i.updated || []).find(({ oldValue: r }) => r.id === o);
|
|
668
|
+
s && n(s.newValue.id);
|
|
669
669
|
}
|
|
670
670
|
}), {
|
|
671
671
|
get current() {
|
|
@@ -676,52 +676,52 @@ const pn = (t) => {
|
|
|
676
676
|
};
|
|
677
677
|
};
|
|
678
678
|
var mn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(mn || {});
|
|
679
|
-
const ft = { selected: [] }, yn = (t, e) => {
|
|
680
|
-
const { subscribe:
|
|
681
|
-
let
|
|
682
|
-
|
|
679
|
+
const ft = { selected: [] }, yn = (t, e, n) => {
|
|
680
|
+
const { subscribe: o, set: i } = Kt(ft);
|
|
681
|
+
let s = e, r = ft;
|
|
682
|
+
o((A) => r = A);
|
|
683
683
|
const a = () => {
|
|
684
|
-
G(r, ft) ||
|
|
685
|
-
},
|
|
686
|
-
var
|
|
687
|
-
return ((
|
|
688
|
-
},
|
|
689
|
-
if (
|
|
684
|
+
G(r, ft) || i(ft);
|
|
685
|
+
}, l = () => {
|
|
686
|
+
var A;
|
|
687
|
+
return ((A = r.selected) == null ? void 0 : A.length) === 0;
|
|
688
|
+
}, u = (A) => {
|
|
689
|
+
if (l())
|
|
690
690
|
return !1;
|
|
691
|
-
const
|
|
692
|
-
return r.selected.some((
|
|
693
|
-
}, f = (
|
|
694
|
-
const
|
|
695
|
-
if (!
|
|
696
|
-
console.warn("Invalid selection: " +
|
|
691
|
+
const b = typeof A == "string" ? A : A.id;
|
|
692
|
+
return r.selected.some((S) => S.id === b);
|
|
693
|
+
}, f = (A, b) => {
|
|
694
|
+
const S = t.getAnnotation(A);
|
|
695
|
+
if (!S) {
|
|
696
|
+
console.warn("Invalid selection: " + A);
|
|
697
697
|
return;
|
|
698
698
|
}
|
|
699
|
-
switch (Jt(
|
|
699
|
+
switch (Jt(S, s)) {
|
|
700
700
|
case "EDIT":
|
|
701
|
-
|
|
701
|
+
i({ selected: [{ id: A, editable: !0 }], event: b });
|
|
702
702
|
break;
|
|
703
703
|
case "SELECT":
|
|
704
|
-
|
|
704
|
+
i({ selected: [{ id: A }], event: b });
|
|
705
705
|
break;
|
|
706
706
|
default:
|
|
707
|
-
|
|
707
|
+
i({ selected: [], event: b });
|
|
708
708
|
}
|
|
709
|
-
},
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
selected:
|
|
713
|
-
const
|
|
714
|
-
return { id:
|
|
709
|
+
}, c = (A, b) => {
|
|
710
|
+
const S = Array.isArray(A) ? A : [A], p = S.map((d) => t.getAnnotation(d)).filter((d) => !!d);
|
|
711
|
+
i({
|
|
712
|
+
selected: p.map((d) => {
|
|
713
|
+
const y = b === void 0 ? Jt(d, s) === "EDIT" : b;
|
|
714
|
+
return { id: d.id, editable: y };
|
|
715
715
|
})
|
|
716
|
-
}),
|
|
717
|
-
},
|
|
718
|
-
if (
|
|
716
|
+
}), p.length !== S.length && console.warn("Invalid selection", A);
|
|
717
|
+
}, g = (A) => {
|
|
718
|
+
if (l())
|
|
719
719
|
return !1;
|
|
720
|
-
const { selected:
|
|
721
|
-
|
|
722
|
-
},
|
|
720
|
+
const { selected: b } = r;
|
|
721
|
+
b.some(({ id: S }) => A.includes(S)) && i({ selected: b.filter(({ id: S }) => !A.includes(S)) });
|
|
722
|
+
}, h = (A) => s = A;
|
|
723
723
|
return t.observe(
|
|
724
|
-
({ changes:
|
|
724
|
+
({ changes: A }) => g((A.deleted || []).map((b) => b.id))
|
|
725
725
|
), {
|
|
726
726
|
get event() {
|
|
727
727
|
return r ? r.event : null;
|
|
@@ -730,17 +730,17 @@ const ft = { selected: [] }, yn = (t, e) => {
|
|
|
730
730
|
return r ? [...r.selected] : null;
|
|
731
731
|
},
|
|
732
732
|
get userSelectAction() {
|
|
733
|
-
return
|
|
733
|
+
return s;
|
|
734
734
|
},
|
|
735
735
|
clear: a,
|
|
736
|
-
isEmpty:
|
|
737
|
-
isSelected:
|
|
738
|
-
setSelected:
|
|
739
|
-
setUserSelectAction:
|
|
740
|
-
subscribe:
|
|
736
|
+
isEmpty: l,
|
|
737
|
+
isSelected: u,
|
|
738
|
+
setSelected: c,
|
|
739
|
+
setUserSelectAction: h,
|
|
740
|
+
subscribe: o,
|
|
741
741
|
userSelect: f
|
|
742
742
|
};
|
|
743
|
-
}, Jt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
743
|
+
}, Jt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
|
|
744
744
|
var V = [];
|
|
745
745
|
for (var Ct = 0; Ct < 256; ++Ct)
|
|
746
746
|
V.push((Ct + 256).toString(16).slice(1));
|
|
@@ -753,9 +753,9 @@ function vn() {
|
|
|
753
753
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
754
754
|
return ht(wn);
|
|
755
755
|
}
|
|
756
|
-
var
|
|
756
|
+
var An = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
757
757
|
const Zt = {
|
|
758
|
-
randomUUID:
|
|
758
|
+
randomUUID: An
|
|
759
759
|
};
|
|
760
760
|
function he(t, e, n) {
|
|
761
761
|
if (Zt.randomUUID && !e && !t)
|
|
@@ -780,7 +780,7 @@ const Lt = (t) => {
|
|
|
780
780
|
created: n || /* @__PURE__ */ new Date(),
|
|
781
781
|
creator: o,
|
|
782
782
|
...e
|
|
783
|
-
}),
|
|
783
|
+
}), xn = (t, e) => {
|
|
784
784
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
785
785
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
786
786
|
}, En = (t, e) => {
|
|
@@ -789,8 +789,8 @@ const Lt = (t) => {
|
|
|
789
789
|
}, Sn = (t, e) => e.bodies.map((n) => {
|
|
790
790
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
791
791
|
return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
|
|
792
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Cn = (t, e) => !G(t.target, e.target),
|
|
793
|
-
const n =
|
|
792
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Cn = (t, e) => !G(t.target, e.target), pe = (t, e) => {
|
|
793
|
+
const n = xn(t, e), o = En(t, e), i = Sn(t, e);
|
|
794
794
|
return {
|
|
795
795
|
oldValue: t,
|
|
796
796
|
newValue: e,
|
|
@@ -803,45 +803,45 @@ const Lt = (t) => {
|
|
|
803
803
|
var k = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(k || {});
|
|
804
804
|
const Ln = (t, e) => {
|
|
805
805
|
var n, o;
|
|
806
|
-
const { changes: i, origin:
|
|
807
|
-
if (!(t.options.origin ? t.options.origin ===
|
|
806
|
+
const { changes: i, origin: s } = e;
|
|
807
|
+
if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
|
|
808
808
|
return !1;
|
|
809
809
|
if (t.options.ignore) {
|
|
810
|
-
const { ignore:
|
|
811
|
-
if (!(
|
|
812
|
-
const
|
|
813
|
-
if (
|
|
810
|
+
const { ignore: r } = t.options, a = (l) => l && l.length > 0;
|
|
811
|
+
if (!(a(i.created) || a(i.deleted))) {
|
|
812
|
+
const l = (n = i.updated) == null ? void 0 : n.some((f) => a(f.bodiesCreated) || a(f.bodiesDeleted) || a(f.bodiesUpdated)), u = (o = i.updated) == null ? void 0 : o.some((f) => f.targetUpdated);
|
|
813
|
+
if (r === "BODY_ONLY" && l && !u || r === "TARGET_ONLY" && u && !l)
|
|
814
814
|
return !1;
|
|
815
815
|
}
|
|
816
816
|
}
|
|
817
817
|
if (t.options.annotations) {
|
|
818
|
-
const
|
|
819
|
-
...(i.created || []).map((
|
|
820
|
-
...(i.deleted || []).map((
|
|
821
|
-
...(i.updated || []).map(({ oldValue:
|
|
818
|
+
const r = /* @__PURE__ */ new Set([
|
|
819
|
+
...(i.created || []).map((a) => a.id),
|
|
820
|
+
...(i.deleted || []).map((a) => a.id),
|
|
821
|
+
...(i.updated || []).map(({ oldValue: a }) => a.id)
|
|
822
822
|
]);
|
|
823
|
-
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((
|
|
823
|
+
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => r.has(a));
|
|
824
824
|
} else
|
|
825
825
|
return !0;
|
|
826
826
|
}, On = (t, e) => {
|
|
827
|
-
const n = new Set((t.created || []).map((
|
|
828
|
-
...(t.created || []).filter((
|
|
827
|
+
const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), s = new Set((e.deleted || []).map((c) => c.id)), r = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), a = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), l = [
|
|
828
|
+
...(t.created || []).filter((c) => !s.has(c.id)).map((c) => r.has(c.id) ? e.updated.find(({ oldValue: g }) => g.id === c.id).newValue : c),
|
|
829
829
|
...e.created || []
|
|
830
|
+
], u = [
|
|
831
|
+
...(t.deleted || []).filter((c) => !i.has(c.id)),
|
|
832
|
+
...(e.deleted || []).filter((c) => !n.has(c.id))
|
|
830
833
|
], f = [
|
|
831
|
-
...(t.
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
if (a.has(d.id)) {
|
|
837
|
-
const E = e.updated.find((b) => b.oldValue.id === d.id).newValue;
|
|
838
|
-
return ge(p, E);
|
|
834
|
+
...(t.updated || []).filter(({ newValue: c }) => !s.has(c.id)).map((c) => {
|
|
835
|
+
const { oldValue: g, newValue: h } = c;
|
|
836
|
+
if (r.has(h.id)) {
|
|
837
|
+
const A = e.updated.find((b) => b.oldValue.id === h.id).newValue;
|
|
838
|
+
return pe(g, A);
|
|
839
839
|
} else
|
|
840
|
-
return
|
|
840
|
+
return c;
|
|
841
841
|
}),
|
|
842
|
-
...(e.updated || []).filter(({ oldValue:
|
|
842
|
+
...(e.updated || []).filter(({ oldValue: c }) => !a.has(c.id))
|
|
843
843
|
];
|
|
844
|
-
return { created:
|
|
844
|
+
return { created: l, deleted: u, updated: f };
|
|
845
845
|
}, Ot = (t) => {
|
|
846
846
|
const e = t.id === void 0 ? he() : t.id;
|
|
847
847
|
return {
|
|
@@ -862,7 +862,7 @@ const Ln = (t, e) => {
|
|
|
862
862
|
}, i = (m) => {
|
|
863
863
|
const v = n.findIndex((x) => x.onChange == m);
|
|
864
864
|
v > -1 && n.splice(v, 1);
|
|
865
|
-
},
|
|
865
|
+
}, s = (m, v) => {
|
|
866
866
|
const x = {
|
|
867
867
|
origin: m,
|
|
868
868
|
changes: {
|
|
@@ -875,53 +875,53 @@ const Ln = (t, e) => {
|
|
|
875
875
|
n.forEach((L) => {
|
|
876
876
|
Ln(L, x) && L.onChange(x);
|
|
877
877
|
});
|
|
878
|
-
},
|
|
878
|
+
}, r = (m, v = k.LOCAL) => {
|
|
879
879
|
if (m.id && t.get(m.id))
|
|
880
880
|
throw Error(`Cannot add annotation ${m.id} - exists already`);
|
|
881
881
|
{
|
|
882
882
|
const x = Ot(m);
|
|
883
|
-
t.set(x.id, x), x.bodies.forEach((L) => e.set(L.id, x.id)),
|
|
883
|
+
t.set(x.id, x), x.bodies.forEach((L) => e.set(L.id, x.id)), s(v, { created: [x] });
|
|
884
884
|
}
|
|
885
|
-
},
|
|
885
|
+
}, a = (m, v) => {
|
|
886
886
|
const x = Ot(typeof m == "string" ? v : m), L = typeof m == "string" ? m : m.id, B = L && t.get(L);
|
|
887
887
|
if (B) {
|
|
888
|
-
const M =
|
|
888
|
+
const M = pe(B, x);
|
|
889
889
|
return L === x.id ? t.set(L, x) : (t.delete(L), t.set(x.id, x)), B.bodies.forEach((K) => e.delete(K.id)), x.bodies.forEach((K) => e.set(K.id, x.id)), M;
|
|
890
890
|
} else
|
|
891
891
|
console.warn(`Cannot update annotation ${L} - does not exist`);
|
|
892
|
-
},
|
|
893
|
-
const L = Tn(v) ? x : v, B =
|
|
894
|
-
B &&
|
|
895
|
-
},
|
|
892
|
+
}, l = (m, v = k.LOCAL, x = k.LOCAL) => {
|
|
893
|
+
const L = Tn(v) ? x : v, B = a(m, v);
|
|
894
|
+
B && s(L, { updated: [B] });
|
|
895
|
+
}, u = (m, v = k.LOCAL) => {
|
|
896
896
|
const x = m.reduce((L, B) => {
|
|
897
|
-
const M =
|
|
897
|
+
const M = a(B);
|
|
898
898
|
return M ? [...L, M] : L;
|
|
899
899
|
}, []);
|
|
900
|
-
x.length > 0 &&
|
|
901
|
-
},
|
|
900
|
+
x.length > 0 && s(v, { updated: x });
|
|
901
|
+
}, f = (m, v = k.LOCAL) => {
|
|
902
902
|
const x = t.get(m.annotation);
|
|
903
903
|
if (x) {
|
|
904
904
|
const L = {
|
|
905
905
|
...x,
|
|
906
906
|
bodies: [...x.bodies, m]
|
|
907
907
|
};
|
|
908
|
-
t.set(x.id, L), e.set(m.id, L.id),
|
|
908
|
+
t.set(x.id, L), e.set(m.id, L.id), s(v, { updated: [{
|
|
909
909
|
oldValue: x,
|
|
910
910
|
newValue: L,
|
|
911
911
|
bodiesCreated: [m]
|
|
912
912
|
}] });
|
|
913
913
|
} else
|
|
914
914
|
console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
|
|
915
|
-
},
|
|
915
|
+
}, c = () => [...t.values()], g = (m = k.LOCAL) => {
|
|
916
916
|
const v = [...t.values()];
|
|
917
|
-
t.clear(), e.clear(),
|
|
918
|
-
},
|
|
917
|
+
t.clear(), e.clear(), s(m, { deleted: v });
|
|
918
|
+
}, h = (m, v = !0, x = k.LOCAL) => {
|
|
919
919
|
const L = m.map(Ot);
|
|
920
920
|
if (v) {
|
|
921
921
|
const B = [...t.values()];
|
|
922
922
|
t.clear(), e.clear(), L.forEach((M) => {
|
|
923
923
|
t.set(M.id, M), M.bodies.forEach((K) => e.set(K.id, M.id));
|
|
924
|
-
}),
|
|
924
|
+
}), s(x, { created: L, deleted: B });
|
|
925
925
|
} else {
|
|
926
926
|
const B = m.reduce((M, K) => {
|
|
927
927
|
const Y = K.id && t.get(K.id);
|
|
@@ -931,23 +931,23 @@ const Ln = (t, e) => {
|
|
|
931
931
|
throw Error(`Bulk insert would overwrite the following annotations: ${B.map((M) => M.id).join(", ")}`);
|
|
932
932
|
L.forEach((M) => {
|
|
933
933
|
t.set(M.id, M), M.bodies.forEach((K) => e.set(K.id, M.id));
|
|
934
|
-
}),
|
|
934
|
+
}), s(x, { created: L });
|
|
935
935
|
}
|
|
936
|
-
},
|
|
936
|
+
}, A = (m) => {
|
|
937
937
|
const v = typeof m == "string" ? m : m.id, x = t.get(v);
|
|
938
938
|
if (x)
|
|
939
939
|
return t.delete(v), x.bodies.forEach((L) => e.delete(L.id)), x;
|
|
940
940
|
console.warn(`Attempt to delete missing annotation: ${v}`);
|
|
941
941
|
}, b = (m, v = k.LOCAL) => {
|
|
942
|
-
const x =
|
|
943
|
-
x &&
|
|
944
|
-
},
|
|
942
|
+
const x = A(m);
|
|
943
|
+
x && s(v, { deleted: [x] });
|
|
944
|
+
}, S = (m, v = k.LOCAL) => {
|
|
945
945
|
const x = m.reduce((L, B) => {
|
|
946
|
-
const M =
|
|
946
|
+
const M = A(B);
|
|
947
947
|
return M ? [...L, M] : L;
|
|
948
948
|
}, []);
|
|
949
|
-
x.length > 0 &&
|
|
950
|
-
},
|
|
949
|
+
x.length > 0 && s(v, { deleted: x });
|
|
950
|
+
}, p = (m) => {
|
|
951
951
|
const v = t.get(m.annotation);
|
|
952
952
|
if (v) {
|
|
953
953
|
const x = v.bodies.find((L) => L.id === m.id);
|
|
@@ -966,19 +966,19 @@ const Ln = (t, e) => {
|
|
|
966
966
|
console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
|
|
967
967
|
} else
|
|
968
968
|
console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
|
|
969
|
-
},
|
|
970
|
-
const x =
|
|
971
|
-
x &&
|
|
969
|
+
}, d = (m, v = k.LOCAL) => {
|
|
970
|
+
const x = p(m);
|
|
971
|
+
x && s(v, { updated: [x] });
|
|
972
972
|
}, y = (m, v = k.LOCAL) => {
|
|
973
|
-
const x = m.map((L) =>
|
|
974
|
-
x.length > 0 &&
|
|
975
|
-
},
|
|
973
|
+
const x = m.map((L) => p(L)).filter(Boolean);
|
|
974
|
+
x.length > 0 && s(v, { updated: x });
|
|
975
|
+
}, C = (m) => {
|
|
976
976
|
const v = t.get(m);
|
|
977
977
|
return v ? { ...v } : void 0;
|
|
978
|
-
},
|
|
978
|
+
}, E = (m) => {
|
|
979
979
|
const v = e.get(m);
|
|
980
980
|
if (v) {
|
|
981
|
-
const x =
|
|
981
|
+
const x = C(v).bodies.find((L) => L.id === m);
|
|
982
982
|
if (x)
|
|
983
983
|
return x;
|
|
984
984
|
console.error(`Store integrity error: body ${m} in index, but not in annotation`);
|
|
@@ -1002,10 +1002,10 @@ const Ln = (t, e) => {
|
|
|
1002
1002
|
console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
|
|
1003
1003
|
}, T = (m, v, x = k.LOCAL) => {
|
|
1004
1004
|
const L = w(m, v);
|
|
1005
|
-
L &&
|
|
1005
|
+
L && s(x, { updated: [L] });
|
|
1006
1006
|
}, O = (m, v = k.LOCAL) => {
|
|
1007
1007
|
const x = m.map((L) => w({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
|
|
1008
|
-
|
|
1008
|
+
s(v, { updated: x });
|
|
1009
1009
|
}, R = (m) => {
|
|
1010
1010
|
const v = t.get(m.annotation);
|
|
1011
1011
|
if (v) {
|
|
@@ -1028,30 +1028,30 @@ const Ln = (t, e) => {
|
|
|
1028
1028
|
console.warn(`Attempt to update target on missing annotation: ${m.annotation}`);
|
|
1029
1029
|
};
|
|
1030
1030
|
return {
|
|
1031
|
-
addAnnotation:
|
|
1032
|
-
addBody:
|
|
1033
|
-
all:
|
|
1034
|
-
bulkAddAnnotation:
|
|
1035
|
-
bulkDeleteAnnotation:
|
|
1031
|
+
addAnnotation: r,
|
|
1032
|
+
addBody: f,
|
|
1033
|
+
all: c,
|
|
1034
|
+
bulkAddAnnotation: h,
|
|
1035
|
+
bulkDeleteAnnotation: S,
|
|
1036
1036
|
bulkDeleteBodies: y,
|
|
1037
|
-
bulkUpdateAnnotation:
|
|
1037
|
+
bulkUpdateAnnotation: u,
|
|
1038
1038
|
bulkUpdateBodies: O,
|
|
1039
1039
|
bulkUpdateTargets: (m, v = k.LOCAL) => {
|
|
1040
1040
|
const x = m.map((L) => R(L)).filter(Boolean);
|
|
1041
|
-
x.length > 0 &&
|
|
1041
|
+
x.length > 0 && s(v, { updated: x });
|
|
1042
1042
|
},
|
|
1043
|
-
clear:
|
|
1043
|
+
clear: g,
|
|
1044
1044
|
deleteAnnotation: b,
|
|
1045
|
-
deleteBody:
|
|
1046
|
-
getAnnotation:
|
|
1047
|
-
getBody:
|
|
1045
|
+
deleteBody: d,
|
|
1046
|
+
getAnnotation: C,
|
|
1047
|
+
getBody: E,
|
|
1048
1048
|
observe: o,
|
|
1049
1049
|
unobserve: i,
|
|
1050
|
-
updateAnnotation:
|
|
1050
|
+
updateAnnotation: l,
|
|
1051
1051
|
updateBody: T,
|
|
1052
1052
|
updateTarget: (m, v = k.LOCAL) => {
|
|
1053
1053
|
const x = R(m);
|
|
1054
|
-
x &&
|
|
1054
|
+
x && s(v, { updated: [x] });
|
|
1055
1055
|
}
|
|
1056
1056
|
};
|
|
1057
1057
|
};
|
|
@@ -1071,39 +1071,39 @@ let Mn = () => ({
|
|
|
1071
1071
|
});
|
|
1072
1072
|
const Bn = 250, kn = (t) => {
|
|
1073
1073
|
const e = Mn(), n = [];
|
|
1074
|
-
let o = -1, i = !1,
|
|
1075
|
-
const
|
|
1074
|
+
let o = -1, i = !1, s = 0;
|
|
1075
|
+
const r = (h) => {
|
|
1076
1076
|
if (!i) {
|
|
1077
|
-
const { changes:
|
|
1078
|
-
if (b -
|
|
1079
|
-
n.splice(o + 1), n.push(
|
|
1077
|
+
const { changes: A } = h, b = performance.now();
|
|
1078
|
+
if (b - s > Bn)
|
|
1079
|
+
n.splice(o + 1), n.push(A), o = n.length - 1;
|
|
1080
1080
|
else {
|
|
1081
|
-
const
|
|
1082
|
-
n[
|
|
1081
|
+
const S = n.length - 1;
|
|
1082
|
+
n[S] = On(n[S], A);
|
|
1083
1083
|
}
|
|
1084
|
-
|
|
1084
|
+
s = b;
|
|
1085
1085
|
}
|
|
1086
1086
|
i = !1;
|
|
1087
1087
|
};
|
|
1088
|
-
t.observe(
|
|
1089
|
-
const
|
|
1088
|
+
t.observe(r, { origin: k.LOCAL });
|
|
1089
|
+
const a = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), l = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), u = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: A }) => A)), f = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: A }) => A)), c = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), g = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h);
|
|
1090
1090
|
return {
|
|
1091
1091
|
canRedo: () => n.length - 1 > o,
|
|
1092
1092
|
canUndo: () => o > -1,
|
|
1093
|
-
destroy: () => t.unobserve(
|
|
1094
|
-
on: (
|
|
1093
|
+
destroy: () => t.unobserve(r),
|
|
1094
|
+
on: (h, A) => e.on(h, A),
|
|
1095
1095
|
redo: () => {
|
|
1096
1096
|
if (n.length - 1 > o) {
|
|
1097
1097
|
i = !0;
|
|
1098
|
-
const { created:
|
|
1099
|
-
|
|
1098
|
+
const { created: h, updated: A, deleted: b } = n[o + 1];
|
|
1099
|
+
l(h), f(A), g(b), e.emit("redo", n[o + 1]), o += 1;
|
|
1100
1100
|
}
|
|
1101
1101
|
},
|
|
1102
1102
|
undo: () => {
|
|
1103
1103
|
if (o > -1) {
|
|
1104
1104
|
i = !0;
|
|
1105
|
-
const { created:
|
|
1106
|
-
|
|
1105
|
+
const { created: h, updated: A, deleted: b } = n[o];
|
|
1106
|
+
a(h), u(A), c(b), e.emit("undo", n[o]), o -= 1;
|
|
1107
1107
|
}
|
|
1108
1108
|
}
|
|
1109
1109
|
};
|
|
@@ -1114,76 +1114,76 @@ const Bn = 250, kn = (t) => {
|
|
|
1114
1114
|
set: e
|
|
1115
1115
|
};
|
|
1116
1116
|
}, _n = (t, e, n, o) => {
|
|
1117
|
-
const {
|
|
1118
|
-
let
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1121
|
-
},
|
|
1122
|
-
const
|
|
1123
|
-
if (
|
|
1124
|
-
const
|
|
1125
|
-
|
|
1117
|
+
const { hover: i, selection: s, store: r, viewport: a } = t, l = /* @__PURE__ */ new Map();
|
|
1118
|
+
let u = [], f;
|
|
1119
|
+
const c = (b, S) => {
|
|
1120
|
+
l.has(b) ? l.get(b).push(S) : l.set(b, [S]);
|
|
1121
|
+
}, g = (b, S) => {
|
|
1122
|
+
const p = l.get(b);
|
|
1123
|
+
if (p) {
|
|
1124
|
+
const d = p.indexOf(S);
|
|
1125
|
+
d !== -1 && p.splice(d, 1);
|
|
1126
1126
|
}
|
|
1127
|
-
},
|
|
1128
|
-
|
|
1129
|
-
|
|
1127
|
+
}, h = (b, S, p) => {
|
|
1128
|
+
l.has(b) && setTimeout(() => {
|
|
1129
|
+
l.get(b).forEach((d) => {
|
|
1130
1130
|
if (n) {
|
|
1131
|
-
const y = Array.isArray(
|
|
1132
|
-
|
|
1131
|
+
const y = Array.isArray(S) ? S.map((E) => n.serialize(E)) : n.serialize(S), C = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
|
|
1132
|
+
d(y, C);
|
|
1133
1133
|
} else
|
|
1134
|
-
|
|
1134
|
+
d(S, p);
|
|
1135
1135
|
});
|
|
1136
1136
|
}, 1);
|
|
1137
1137
|
};
|
|
1138
|
-
|
|
1139
|
-
if (!(
|
|
1140
|
-
if (
|
|
1141
|
-
|
|
1142
|
-
else if (
|
|
1143
|
-
|
|
1144
|
-
const
|
|
1145
|
-
|
|
1146
|
-
}),
|
|
1138
|
+
s.subscribe(({ selected: b }) => {
|
|
1139
|
+
if (!(u.length === 0 && b.length === 0)) {
|
|
1140
|
+
if (u.length === 0 && b.length > 0)
|
|
1141
|
+
u = b.map(({ id: S }) => r.getAnnotation(S));
|
|
1142
|
+
else if (u.length > 0 && b.length === 0)
|
|
1143
|
+
u.forEach((S) => {
|
|
1144
|
+
const p = r.getAnnotation(S.id);
|
|
1145
|
+
p && !G(p, S) && h("updateAnnotation", p, S);
|
|
1146
|
+
}), u = [];
|
|
1147
1147
|
else {
|
|
1148
|
-
const
|
|
1149
|
-
|
|
1150
|
-
const y =
|
|
1151
|
-
y && !G(y,
|
|
1152
|
-
}),
|
|
1148
|
+
const S = new Set(u.map((d) => d.id)), p = new Set(b.map(({ id: d }) => d));
|
|
1149
|
+
u.filter((d) => !p.has(d.id)).forEach((d) => {
|
|
1150
|
+
const y = r.getAnnotation(d.id);
|
|
1151
|
+
y && !G(y, d) && h("updateAnnotation", y, d);
|
|
1152
|
+
}), u = [
|
|
1153
1153
|
// Remove annotations that were deselected
|
|
1154
|
-
...
|
|
1154
|
+
...u.filter((d) => p.has(d.id)),
|
|
1155
1155
|
// Add editable annotations that were selected
|
|
1156
|
-
...b.filter(({ id:
|
|
1156
|
+
...b.filter(({ id: d }) => !S.has(d)).map(({ id: d }) => r.getAnnotation(d))
|
|
1157
1157
|
];
|
|
1158
1158
|
}
|
|
1159
|
-
|
|
1159
|
+
h("selectionChanged", u);
|
|
1160
1160
|
}
|
|
1161
|
-
}),
|
|
1162
|
-
!
|
|
1163
|
-
}),
|
|
1164
|
-
const { created:
|
|
1165
|
-
(
|
|
1166
|
-
...
|
|
1167
|
-
...
|
|
1168
|
-
...
|
|
1169
|
-
].length > 0).forEach(({ oldValue:
|
|
1170
|
-
const
|
|
1171
|
-
|
|
1161
|
+
}), i.subscribe((b) => {
|
|
1162
|
+
!f && b ? h("mouseEnterAnnotation", r.getAnnotation(b)) : f && !b ? h("mouseLeaveAnnotation", r.getAnnotation(f)) : f && b && (h("mouseLeaveAnnotation", r.getAnnotation(f)), h("mouseEnterAnnotation", r.getAnnotation(b))), f = b;
|
|
1163
|
+
}), a == null || a.subscribe((b) => h("viewportIntersect", b.map((S) => r.getAnnotation(S)))), r.observe((b) => {
|
|
1164
|
+
const { created: S, deleted: p } = b.changes;
|
|
1165
|
+
(S || []).forEach((d) => h("createAnnotation", d)), (p || []).forEach((d) => h("deleteAnnotation", d)), (b.changes.updated || []).filter((d) => [
|
|
1166
|
+
...d.bodiesCreated || [],
|
|
1167
|
+
...d.bodiesDeleted || [],
|
|
1168
|
+
...d.bodiesUpdated || []
|
|
1169
|
+
].length > 0).forEach(({ oldValue: d, newValue: y }) => {
|
|
1170
|
+
const C = u.find((E) => E.id === d.id) || d;
|
|
1171
|
+
u = u.map((E) => E.id === d.id ? y : E), h("updateAnnotation", y, C);
|
|
1172
1172
|
});
|
|
1173
|
-
}, { origin: k.LOCAL }),
|
|
1174
|
-
if (
|
|
1175
|
-
const
|
|
1176
|
-
|
|
1173
|
+
}, { origin: k.LOCAL }), r.observe((b) => {
|
|
1174
|
+
if (u) {
|
|
1175
|
+
const S = new Set(u.map((d) => d.id)), p = (b.changes.updated || []).filter(({ newValue: d }) => S.has(d.id)).map(({ newValue: d }) => d);
|
|
1176
|
+
p.length > 0 && (u = u.map((d) => p.find((C) => C.id === d.id) || d));
|
|
1177
1177
|
}
|
|
1178
1178
|
}, { origin: k.REMOTE });
|
|
1179
|
-
const
|
|
1180
|
-
const { updated:
|
|
1181
|
-
b ? (
|
|
1179
|
+
const A = (b) => (S) => {
|
|
1180
|
+
const { updated: p } = S;
|
|
1181
|
+
b ? (p || []).forEach((d) => h("updateAnnotation", d.oldValue, d.newValue)) : (p || []).forEach((d) => h("updateAnnotation", d.newValue, d.oldValue));
|
|
1182
1182
|
};
|
|
1183
|
-
return e.on("undo",
|
|
1183
|
+
return e.on("undo", A(!0)), e.on("redo", A(!1)), { on: c, off: g, emit: h };
|
|
1184
1184
|
}, Nn = (t) => (e) => e.reduce((n, o) => {
|
|
1185
|
-
const { parsed: i, error:
|
|
1186
|
-
return
|
|
1185
|
+
const { parsed: i, error: s } = t.parse(o);
|
|
1186
|
+
return s ? {
|
|
1187
1187
|
parsed: n.parsed,
|
|
1188
1188
|
failed: [...n.failed, o]
|
|
1189
1189
|
} : i ? {
|
|
@@ -1193,75 +1193,75 @@ const Bn = 250, kn = (t) => {
|
|
|
1193
1193
|
...n
|
|
1194
1194
|
};
|
|
1195
1195
|
}, { parsed: [], failed: [] }), Un = (t, e, n) => {
|
|
1196
|
-
const { store: o, selection: i } = t,
|
|
1196
|
+
const { store: o, selection: i } = t, s = (p) => {
|
|
1197
1197
|
if (n) {
|
|
1198
|
-
const { parsed:
|
|
1199
|
-
|
|
1198
|
+
const { parsed: d, error: y } = n.parse(p);
|
|
1199
|
+
d ? o.addAnnotation(d, k.REMOTE) : console.error(y);
|
|
1200
1200
|
} else
|
|
1201
|
-
o.addAnnotation(Lt(
|
|
1202
|
-
},
|
|
1203
|
-
const
|
|
1204
|
-
return n &&
|
|
1205
|
-
},
|
|
1206
|
-
var
|
|
1207
|
-
const
|
|
1208
|
-
return n ?
|
|
1209
|
-
},
|
|
1210
|
-
if (typeof
|
|
1211
|
-
const
|
|
1212
|
-
if (o.deleteAnnotation(
|
|
1213
|
-
return n ? n.serialize(
|
|
1201
|
+
o.addAnnotation(Lt(p), k.REMOTE);
|
|
1202
|
+
}, r = () => i.clear(), a = () => o.clear(), l = (p) => {
|
|
1203
|
+
const d = o.getAnnotation(p);
|
|
1204
|
+
return n && d ? n.serialize(d) : d;
|
|
1205
|
+
}, u = () => n ? o.all().map(n.serialize) : o.all(), f = () => {
|
|
1206
|
+
var p;
|
|
1207
|
+
const d = (((p = i.selected) == null ? void 0 : p.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
|
|
1208
|
+
return n ? d.map(n.serialize) : d;
|
|
1209
|
+
}, c = (p, d = !0) => fetch(p).then((y) => y.json()).then((y) => (h(y, d), y)), g = (p) => {
|
|
1210
|
+
if (typeof p == "string") {
|
|
1211
|
+
const d = o.getAnnotation(p);
|
|
1212
|
+
if (o.deleteAnnotation(p), d)
|
|
1213
|
+
return n ? n.serialize(d) : d;
|
|
1214
1214
|
} else {
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1217
|
-
return o.deleteAnnotation(
|
|
1215
|
+
const d = n ? n.parse(p).parsed : p;
|
|
1216
|
+
if (d)
|
|
1217
|
+
return o.deleteAnnotation(d), p;
|
|
1218
1218
|
}
|
|
1219
|
-
},
|
|
1219
|
+
}, h = (p, d = !0) => {
|
|
1220
1220
|
if (n) {
|
|
1221
|
-
const y = n.parseAll || Nn(n), { parsed:
|
|
1222
|
-
|
|
1221
|
+
const y = n.parseAll || Nn(n), { parsed: C, failed: E } = y(p);
|
|
1222
|
+
E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(C, d, k.REMOTE);
|
|
1223
1223
|
} else
|
|
1224
|
-
o.bulkAddAnnotation(
|
|
1225
|
-
},
|
|
1226
|
-
|
|
1227
|
-
}, b = (
|
|
1228
|
-
i.clear(), i.setUserSelectAction(
|
|
1229
|
-
},
|
|
1224
|
+
o.bulkAddAnnotation(p.map(Lt), d, k.REMOTE);
|
|
1225
|
+
}, A = (p, d) => {
|
|
1226
|
+
p ? i.setSelected(p, d) : i.clear();
|
|
1227
|
+
}, b = (p) => {
|
|
1228
|
+
i.clear(), i.setUserSelectAction(p);
|
|
1229
|
+
}, S = (p) => {
|
|
1230
1230
|
if (n) {
|
|
1231
|
-
const
|
|
1232
|
-
return o.updateAnnotation(
|
|
1231
|
+
const d = n.parse(p).parsed, y = n.serialize(o.getAnnotation(d.id));
|
|
1232
|
+
return o.updateAnnotation(d), y;
|
|
1233
1233
|
} else {
|
|
1234
|
-
const
|
|
1235
|
-
return o.updateAnnotation(Lt(
|
|
1234
|
+
const d = o.getAnnotation(p.id);
|
|
1235
|
+
return o.updateAnnotation(Lt(p)), d;
|
|
1236
1236
|
}
|
|
1237
1237
|
};
|
|
1238
1238
|
return {
|
|
1239
|
-
addAnnotation:
|
|
1240
|
-
cancelSelected:
|
|
1239
|
+
addAnnotation: s,
|
|
1240
|
+
cancelSelected: r,
|
|
1241
1241
|
canRedo: e.canRedo,
|
|
1242
1242
|
canUndo: e.canUndo,
|
|
1243
|
-
clearAnnotations:
|
|
1244
|
-
getAnnotationById:
|
|
1245
|
-
getAnnotations:
|
|
1246
|
-
getSelected:
|
|
1247
|
-
loadAnnotations:
|
|
1243
|
+
clearAnnotations: a,
|
|
1244
|
+
getAnnotationById: l,
|
|
1245
|
+
getAnnotations: u,
|
|
1246
|
+
getSelected: f,
|
|
1247
|
+
loadAnnotations: c,
|
|
1248
1248
|
redo: e.redo,
|
|
1249
|
-
removeAnnotation:
|
|
1250
|
-
setAnnotations:
|
|
1251
|
-
setSelected:
|
|
1249
|
+
removeAnnotation: g,
|
|
1250
|
+
setAnnotations: h,
|
|
1251
|
+
setSelected: A,
|
|
1252
1252
|
setUserSelectAction: b,
|
|
1253
1253
|
undo: e.undo,
|
|
1254
|
-
updateAnnotation:
|
|
1254
|
+
updateAnnotation: S
|
|
1255
1255
|
};
|
|
1256
1256
|
}, Vn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1257
1257
|
let Dn = (t) => crypto.getRandomValues(new Uint8Array(t)), Kn = (t, e, n) => {
|
|
1258
1258
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1259
|
-
return (
|
|
1260
|
-
let
|
|
1259
|
+
return (s = e) => {
|
|
1260
|
+
let r = "";
|
|
1261
1261
|
for (; ; ) {
|
|
1262
|
-
let
|
|
1263
|
-
for (;
|
|
1264
|
-
if (
|
|
1262
|
+
let a = n(i), l = i;
|
|
1263
|
+
for (; l--; )
|
|
1264
|
+
if (r += t[a[l] & o] || "", r.length === s) return r;
|
|
1265
1265
|
}
|
|
1266
1266
|
};
|
|
1267
1267
|
}, Yn = (t, e = 21) => Kn(t, e, Dn), Xn = (t = 21) => {
|
|
@@ -1274,31 +1274,31 @@ const $n = () => ({ isGuest: !0, id: Yn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1274
1274
|
const e = JSON.stringify(t);
|
|
1275
1275
|
let n = 0;
|
|
1276
1276
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
1277
|
-
let
|
|
1278
|
-
n = (n << 5) - n +
|
|
1277
|
+
let s = e.charCodeAt(o);
|
|
1278
|
+
n = (n << 5) - n + s, n |= 0;
|
|
1279
1279
|
}
|
|
1280
1280
|
return `${n}`;
|
|
1281
|
-
},
|
|
1282
|
-
const { id: o, type: i, purpose:
|
|
1281
|
+
}, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, jn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1282
|
+
const { id: o, type: i, purpose: s, value: r, created: a, modified: l, creator: u, ...f } = n;
|
|
1283
1283
|
return {
|
|
1284
1284
|
id: o || `temp-${Pn(n)}`,
|
|
1285
1285
|
annotation: e,
|
|
1286
1286
|
type: i,
|
|
1287
|
-
purpose:
|
|
1288
|
-
value:
|
|
1289
|
-
creator:
|
|
1290
|
-
created:
|
|
1291
|
-
updated:
|
|
1292
|
-
...
|
|
1287
|
+
purpose: s,
|
|
1288
|
+
value: r,
|
|
1289
|
+
creator: ge(u),
|
|
1290
|
+
created: a ? new Date(a) : void 0,
|
|
1291
|
+
updated: l ? new Date(l) : void 0,
|
|
1292
|
+
...f
|
|
1293
1293
|
};
|
|
1294
1294
|
}), Hn = (t) => t.map((e) => {
|
|
1295
1295
|
var n;
|
|
1296
|
-
const { annotation: o, created: i, updated:
|
|
1297
|
-
...
|
|
1296
|
+
const { annotation: o, created: i, updated: s, ...r } = e, a = {
|
|
1297
|
+
...r,
|
|
1298
1298
|
created: i == null ? void 0 : i.toISOString(),
|
|
1299
|
-
modified:
|
|
1299
|
+
modified: s == null ? void 0 : s.toISOString()
|
|
1300
1300
|
};
|
|
1301
|
-
return (n =
|
|
1301
|
+
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
1302
1302
|
});
|
|
1303
1303
|
Xn();
|
|
1304
1304
|
const Lo = (t, e) => ({
|
|
@@ -1310,107 +1310,107 @@ const Lo = (t, e) => ({
|
|
|
1310
1310
|
creator: n,
|
|
1311
1311
|
created: o,
|
|
1312
1312
|
modified: i,
|
|
1313
|
-
target:
|
|
1314
|
-
} = t,
|
|
1315
|
-
if (
|
|
1313
|
+
target: s
|
|
1314
|
+
} = t, r = Array.isArray(s) ? s : [s];
|
|
1315
|
+
if (r.length === 0)
|
|
1316
1316
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1317
|
-
const
|
|
1318
|
-
creator:
|
|
1317
|
+
const a = {
|
|
1318
|
+
creator: ge(n),
|
|
1319
1319
|
created: o ? new Date(o) : void 0,
|
|
1320
1320
|
updated: i ? new Date(i) : void 0,
|
|
1321
1321
|
annotation: e,
|
|
1322
1322
|
selector: [],
|
|
1323
|
-
styleClass:
|
|
1323
|
+
styleClass: r[0].styleClass
|
|
1324
1324
|
};
|
|
1325
|
-
for (const
|
|
1326
|
-
const
|
|
1327
|
-
switch (
|
|
1325
|
+
for (const l of r) {
|
|
1326
|
+
const f = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((c, g) => {
|
|
1327
|
+
switch (g.type) {
|
|
1328
1328
|
case "TextQuoteSelector":
|
|
1329
|
-
|
|
1329
|
+
c.quote = g.exact;
|
|
1330
1330
|
break;
|
|
1331
1331
|
case "TextPositionSelector":
|
|
1332
|
-
|
|
1332
|
+
c.start = g.start, c.end = g.end;
|
|
1333
1333
|
break;
|
|
1334
1334
|
}
|
|
1335
|
-
return
|
|
1335
|
+
return c;
|
|
1336
1336
|
}, {});
|
|
1337
|
-
if (zn(
|
|
1338
|
-
|
|
1337
|
+
if (zn(f))
|
|
1338
|
+
a.selector.push({ id: l.id, ...f });
|
|
1339
1339
|
else {
|
|
1340
|
-
const
|
|
1341
|
-
|
|
1342
|
-
|
|
1340
|
+
const c = [
|
|
1341
|
+
f.start ? void 0 : "TextPositionSelector",
|
|
1342
|
+
f.quote ? void 0 : "TextQuoteSelector"
|
|
1343
1343
|
].filter(Boolean);
|
|
1344
|
-
return { error: Error(`Missing selector types: ${
|
|
1344
|
+
return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`) };
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
|
-
return { parsed:
|
|
1347
|
+
return { parsed: a };
|
|
1348
1348
|
}, Wn = (t) => {
|
|
1349
1349
|
const e = t.id || fe(), {
|
|
1350
1350
|
creator: n,
|
|
1351
1351
|
created: o,
|
|
1352
1352
|
modified: i,
|
|
1353
|
-
body:
|
|
1354
|
-
...
|
|
1355
|
-
} = t,
|
|
1356
|
-
return "error" in
|
|
1353
|
+
body: s,
|
|
1354
|
+
...r
|
|
1355
|
+
} = t, a = jn(s, e), l = Fn(t);
|
|
1356
|
+
return "error" in l ? { error: l.error } : {
|
|
1357
1357
|
parsed: {
|
|
1358
|
-
...
|
|
1358
|
+
...r,
|
|
1359
1359
|
id: e,
|
|
1360
|
-
bodies:
|
|
1361
|
-
target:
|
|
1360
|
+
bodies: a,
|
|
1361
|
+
target: l.parsed
|
|
1362
1362
|
}
|
|
1363
1363
|
};
|
|
1364
1364
|
}, qn = (t, e, n) => {
|
|
1365
|
-
const { bodies: o, target: i, ...
|
|
1366
|
-
selector:
|
|
1367
|
-
creator:
|
|
1368
|
-
created:
|
|
1369
|
-
updated:
|
|
1370
|
-
...
|
|
1371
|
-
} = i,
|
|
1372
|
-
const { quote:
|
|
1365
|
+
const { bodies: o, target: i, ...s } = t, {
|
|
1366
|
+
selector: r,
|
|
1367
|
+
creator: a,
|
|
1368
|
+
created: l,
|
|
1369
|
+
updated: u,
|
|
1370
|
+
...f
|
|
1371
|
+
} = i, c = r.map((g) => {
|
|
1372
|
+
const { quote: h, start: A, end: b, range: S } = g, { prefix: p, suffix: d } = Re(S, n), y = [{
|
|
1373
1373
|
type: "TextQuoteSelector",
|
|
1374
|
-
exact:
|
|
1375
|
-
prefix:
|
|
1376
|
-
suffix:
|
|
1374
|
+
exact: h,
|
|
1375
|
+
prefix: p,
|
|
1376
|
+
suffix: d
|
|
1377
1377
|
}, {
|
|
1378
1378
|
type: "TextPositionSelector",
|
|
1379
|
-
start:
|
|
1379
|
+
start: A,
|
|
1380
1380
|
end: b
|
|
1381
1381
|
}];
|
|
1382
1382
|
return {
|
|
1383
|
-
...
|
|
1384
|
-
id:
|
|
1383
|
+
...f,
|
|
1384
|
+
id: g.id,
|
|
1385
1385
|
source: e,
|
|
1386
1386
|
selector: y
|
|
1387
1387
|
};
|
|
1388
1388
|
});
|
|
1389
1389
|
return {
|
|
1390
|
-
...
|
|
1390
|
+
...s,
|
|
1391
1391
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1392
1392
|
id: t.id,
|
|
1393
1393
|
type: "Annotation",
|
|
1394
1394
|
body: Hn(t.bodies),
|
|
1395
|
-
creator:
|
|
1396
|
-
created:
|
|
1397
|
-
modified:
|
|
1398
|
-
target:
|
|
1395
|
+
creator: a,
|
|
1396
|
+
created: l == null ? void 0 : l.toISOString(),
|
|
1397
|
+
modified: u == null ? void 0 : u.toISOString(),
|
|
1398
|
+
target: c
|
|
1399
1399
|
};
|
|
1400
1400
|
};
|
|
1401
1401
|
function me(t, e, n = 0, o = t.length - 1, i = Gn) {
|
|
1402
1402
|
for (; o > n; ) {
|
|
1403
1403
|
if (o - n > 600) {
|
|
1404
|
-
const
|
|
1405
|
-
me(t, e,
|
|
1404
|
+
const l = o - n + 1, u = e - n + 1, f = Math.log(l), c = 0.5 * Math.exp(2 * f / 3), g = 0.5 * Math.sqrt(f * c * (l - c) / l) * (u - l / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(e - u * c / l + g)), A = Math.min(o, Math.floor(e + (l - u) * c / l + g));
|
|
1405
|
+
me(t, e, h, A, i);
|
|
1406
1406
|
}
|
|
1407
|
-
const
|
|
1408
|
-
let
|
|
1409
|
-
for (tt(t, n, e), i(t[o],
|
|
1410
|
-
for (tt(t,
|
|
1411
|
-
for (; i(t[
|
|
1407
|
+
const s = t[e];
|
|
1408
|
+
let r = n, a = o;
|
|
1409
|
+
for (tt(t, n, e), i(t[o], s) > 0 && tt(t, n, o); r < a; ) {
|
|
1410
|
+
for (tt(t, r, a), r++, a--; i(t[r], s) < 0; ) r++;
|
|
1411
|
+
for (; i(t[a], s) > 0; ) a--;
|
|
1412
1412
|
}
|
|
1413
|
-
i(t[n],
|
|
1413
|
+
i(t[n], s) === 0 ? tt(t, n, a) : (a++, tt(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);
|
|
1414
1414
|
}
|
|
1415
1415
|
}
|
|
1416
1416
|
function tt(t, e, n) {
|
|
@@ -1430,27 +1430,27 @@ class Qn {
|
|
|
1430
1430
|
search(e) {
|
|
1431
1431
|
let n = this.data;
|
|
1432
1432
|
const o = [];
|
|
1433
|
-
if (!
|
|
1434
|
-
const i = this.toBBox,
|
|
1433
|
+
if (!gt(e, n)) return o;
|
|
1434
|
+
const i = this.toBBox, s = [];
|
|
1435
1435
|
for (; n; ) {
|
|
1436
|
-
for (let
|
|
1437
|
-
const
|
|
1438
|
-
|
|
1436
|
+
for (let r = 0; r < n.children.length; r++) {
|
|
1437
|
+
const a = n.children[r], l = n.leaf ? i(a) : a;
|
|
1438
|
+
gt(e, l) && (n.leaf ? o.push(a) : Rt(e, l) ? this._all(a, o) : s.push(a));
|
|
1439
1439
|
}
|
|
1440
|
-
n =
|
|
1440
|
+
n = s.pop();
|
|
1441
1441
|
}
|
|
1442
1442
|
return o;
|
|
1443
1443
|
}
|
|
1444
1444
|
collides(e) {
|
|
1445
1445
|
let n = this.data;
|
|
1446
|
-
if (!
|
|
1446
|
+
if (!gt(e, n)) return !1;
|
|
1447
1447
|
const o = [];
|
|
1448
1448
|
for (; n; ) {
|
|
1449
1449
|
for (let i = 0; i < n.children.length; i++) {
|
|
1450
|
-
const
|
|
1451
|
-
if (
|
|
1452
|
-
if (n.leaf || Rt(e,
|
|
1453
|
-
o.push(
|
|
1450
|
+
const s = n.children[i], r = n.leaf ? this.toBBox(s) : s;
|
|
1451
|
+
if (gt(e, r)) {
|
|
1452
|
+
if (n.leaf || Rt(e, r)) return !0;
|
|
1453
|
+
o.push(s);
|
|
1454
1454
|
}
|
|
1455
1455
|
}
|
|
1456
1456
|
n = o.pop();
|
|
@@ -1487,15 +1487,15 @@ class Qn {
|
|
|
1487
1487
|
remove(e, n) {
|
|
1488
1488
|
if (!e) return this;
|
|
1489
1489
|
let o = this.data;
|
|
1490
|
-
const i = this.toBBox(e),
|
|
1491
|
-
let
|
|
1492
|
-
for (; o ||
|
|
1493
|
-
if (o || (o =
|
|
1494
|
-
const
|
|
1495
|
-
if (
|
|
1496
|
-
return o.children.splice(
|
|
1490
|
+
const i = this.toBBox(e), s = [], r = [];
|
|
1491
|
+
let a, l, u;
|
|
1492
|
+
for (; o || s.length; ) {
|
|
1493
|
+
if (o || (o = s.pop(), l = s[s.length - 1], a = r.pop(), u = !0), o.leaf) {
|
|
1494
|
+
const f = Jn(e, o.children, n);
|
|
1495
|
+
if (f !== -1)
|
|
1496
|
+
return o.children.splice(f, 1), s.push(o), this._condense(s), this;
|
|
1497
1497
|
}
|
|
1498
|
-
!
|
|
1498
|
+
!u && !o.leaf && Rt(o, i) ? (s.push(o), r.push(a), a = 0, l = o, o = o.children[0]) : l ? (a++, o = l.children[a], u = !1) : o = null;
|
|
1499
1499
|
}
|
|
1500
1500
|
return this;
|
|
1501
1501
|
}
|
|
@@ -1521,77 +1521,77 @@ class Qn {
|
|
|
1521
1521
|
return n;
|
|
1522
1522
|
}
|
|
1523
1523
|
_build(e, n, o, i) {
|
|
1524
|
-
const
|
|
1525
|
-
let
|
|
1526
|
-
if (
|
|
1527
|
-
return
|
|
1528
|
-
i || (i = Math.ceil(Math.log(
|
|
1529
|
-
const
|
|
1530
|
-
te(e, n, o,
|
|
1531
|
-
for (let
|
|
1532
|
-
const
|
|
1533
|
-
te(e,
|
|
1534
|
-
for (let
|
|
1535
|
-
const
|
|
1536
|
-
|
|
1524
|
+
const s = o - n + 1;
|
|
1525
|
+
let r = this._maxEntries, a;
|
|
1526
|
+
if (s <= r)
|
|
1527
|
+
return a = Z(e.slice(n, o + 1)), J(a, this.toBBox), a;
|
|
1528
|
+
i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = Z([]), a.leaf = !1, a.height = i;
|
|
1529
|
+
const l = Math.ceil(s / r), u = l * Math.ceil(Math.sqrt(r));
|
|
1530
|
+
te(e, n, o, u, this.compareMinX);
|
|
1531
|
+
for (let f = n; f <= o; f += u) {
|
|
1532
|
+
const c = Math.min(f + u - 1, o);
|
|
1533
|
+
te(e, f, c, l, this.compareMinY);
|
|
1534
|
+
for (let g = f; g <= c; g += l) {
|
|
1535
|
+
const h = Math.min(g + l - 1, c);
|
|
1536
|
+
a.children.push(this._build(e, g, h, i - 1));
|
|
1537
1537
|
}
|
|
1538
1538
|
}
|
|
1539
|
-
return J(
|
|
1539
|
+
return J(a, this.toBBox), a;
|
|
1540
1540
|
}
|
|
1541
1541
|
_chooseSubtree(e, n, o, i) {
|
|
1542
1542
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1543
|
-
let
|
|
1544
|
-
for (let
|
|
1545
|
-
const
|
|
1546
|
-
|
|
1543
|
+
let s = 1 / 0, r = 1 / 0, a;
|
|
1544
|
+
for (let l = 0; l < n.children.length; l++) {
|
|
1545
|
+
const u = n.children[l], f = Tt(u), c = eo(e, u) - f;
|
|
1546
|
+
c < r ? (r = c, s = f < s ? f : s, a = u) : c === r && f < s && (s = f, a = u);
|
|
1547
1547
|
}
|
|
1548
|
-
n =
|
|
1548
|
+
n = a || n.children[0];
|
|
1549
1549
|
}
|
|
1550
1550
|
return n;
|
|
1551
1551
|
}
|
|
1552
1552
|
_insert(e, n, o) {
|
|
1553
|
-
const i = o ? e : this.toBBox(e),
|
|
1554
|
-
for (
|
|
1555
|
-
this._split(
|
|
1556
|
-
this._adjustParentBBoxes(i,
|
|
1553
|
+
const i = o ? e : this.toBBox(e), s = [], r = this._chooseSubtree(i, this.data, n, s);
|
|
1554
|
+
for (r.children.push(e), ot(r, i); n >= 0 && s[n].children.length > this._maxEntries; )
|
|
1555
|
+
this._split(s, n), n--;
|
|
1556
|
+
this._adjustParentBBoxes(i, s, n);
|
|
1557
1557
|
}
|
|
1558
1558
|
// split overflowed node into two
|
|
1559
1559
|
_split(e, n) {
|
|
1560
|
-
const o = e[n], i = o.children.length,
|
|
1561
|
-
this._chooseSplitAxis(o,
|
|
1562
|
-
const
|
|
1563
|
-
|
|
1560
|
+
const o = e[n], i = o.children.length, s = this._minEntries;
|
|
1561
|
+
this._chooseSplitAxis(o, s, i);
|
|
1562
|
+
const r = this._chooseSplitIndex(o, s, i), a = Z(o.children.splice(r, o.children.length - r));
|
|
1563
|
+
a.height = o.height, a.leaf = o.leaf, J(o, this.toBBox), J(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
|
|
1564
1564
|
}
|
|
1565
1565
|
_splitRoot(e, n) {
|
|
1566
1566
|
this.data = Z([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, J(this.data, this.toBBox);
|
|
1567
1567
|
}
|
|
1568
1568
|
_chooseSplitIndex(e, n, o) {
|
|
1569
|
-
let i,
|
|
1570
|
-
for (let
|
|
1571
|
-
const
|
|
1572
|
-
|
|
1569
|
+
let i, s = 1 / 0, r = 1 / 0;
|
|
1570
|
+
for (let a = n; a <= o - n; a++) {
|
|
1571
|
+
const l = nt(e, 0, a, this.toBBox), u = nt(e, a, o, this.toBBox), f = no(l, u), c = Tt(l) + Tt(u);
|
|
1572
|
+
f < s ? (s = f, i = a, r = c < r ? c : r) : f === s && c < r && (r = c, i = a);
|
|
1573
1573
|
}
|
|
1574
1574
|
return i || o - n;
|
|
1575
1575
|
}
|
|
1576
1576
|
// sorts node children by the best axis for split
|
|
1577
1577
|
_chooseSplitAxis(e, n, o) {
|
|
1578
|
-
const i = e.leaf ? this.compareMinX : Zn,
|
|
1579
|
-
|
|
1578
|
+
const i = e.leaf ? this.compareMinX : Zn, s = e.leaf ? this.compareMinY : to, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
|
|
1579
|
+
r < a && e.children.sort(i);
|
|
1580
1580
|
}
|
|
1581
1581
|
// total margin of all possible split distributions where each node is at least m full
|
|
1582
1582
|
_allDistMargin(e, n, o, i) {
|
|
1583
1583
|
e.children.sort(i);
|
|
1584
|
-
const
|
|
1585
|
-
let
|
|
1586
|
-
for (let
|
|
1587
|
-
const
|
|
1588
|
-
ot(
|
|
1584
|
+
const s = this.toBBox, r = nt(e, 0, n, s), a = nt(e, o - n, o, s);
|
|
1585
|
+
let l = pt(r) + pt(a);
|
|
1586
|
+
for (let u = n; u < o - n; u++) {
|
|
1587
|
+
const f = e.children[u];
|
|
1588
|
+
ot(r, e.leaf ? s(f) : f), l += pt(r);
|
|
1589
1589
|
}
|
|
1590
|
-
for (let
|
|
1591
|
-
const
|
|
1592
|
-
ot(
|
|
1590
|
+
for (let u = o - n - 1; u >= n; u--) {
|
|
1591
|
+
const f = e.children[u];
|
|
1592
|
+
ot(a, e.leaf ? s(f) : f), l += pt(a);
|
|
1593
1593
|
}
|
|
1594
|
-
return
|
|
1594
|
+
return l;
|
|
1595
1595
|
}
|
|
1596
1596
|
_adjustParentBBoxes(e, n, o) {
|
|
1597
1597
|
for (let i = o; i >= 0; i--)
|
|
@@ -1613,9 +1613,9 @@ function J(t, e) {
|
|
|
1613
1613
|
}
|
|
1614
1614
|
function nt(t, e, n, o, i) {
|
|
1615
1615
|
i || (i = Z(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
|
|
1616
|
-
for (let
|
|
1617
|
-
const
|
|
1618
|
-
ot(i, t.leaf ? o(
|
|
1616
|
+
for (let s = e; s < n; s++) {
|
|
1617
|
+
const r = t.children[s];
|
|
1618
|
+
ot(i, t.leaf ? o(r) : r);
|
|
1619
1619
|
}
|
|
1620
1620
|
return i;
|
|
1621
1621
|
}
|
|
@@ -1631,20 +1631,20 @@ function to(t, e) {
|
|
|
1631
1631
|
function Tt(t) {
|
|
1632
1632
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1633
1633
|
}
|
|
1634
|
-
function
|
|
1634
|
+
function pt(t) {
|
|
1635
1635
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1636
1636
|
}
|
|
1637
1637
|
function eo(t, e) {
|
|
1638
1638
|
return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
|
|
1639
1639
|
}
|
|
1640
1640
|
function no(t, e) {
|
|
1641
|
-
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX),
|
|
1642
|
-
return Math.max(0, i - n) * Math.max(0,
|
|
1641
|
+
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
|
|
1642
|
+
return Math.max(0, i - n) * Math.max(0, s - o);
|
|
1643
1643
|
}
|
|
1644
1644
|
function Rt(t, e) {
|
|
1645
1645
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1646
1646
|
}
|
|
1647
|
-
function
|
|
1647
|
+
function gt(t, e) {
|
|
1648
1648
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1649
1649
|
}
|
|
1650
1650
|
function Z(t) {
|
|
@@ -1659,11 +1659,11 @@ function Z(t) {
|
|
|
1659
1659
|
};
|
|
1660
1660
|
}
|
|
1661
1661
|
function te(t, e, n, o, i) {
|
|
1662
|
-
const
|
|
1663
|
-
for (;
|
|
1664
|
-
if (n =
|
|
1665
|
-
const
|
|
1666
|
-
me(t,
|
|
1662
|
+
const s = [e, n];
|
|
1663
|
+
for (; s.length; ) {
|
|
1664
|
+
if (n = s.pop(), e = s.pop(), n - e <= o) continue;
|
|
1665
|
+
const r = e + Math.ceil((n - e) / o / 2) * o;
|
|
1666
|
+
me(t, r, e, n, i), s.push(e, r, r, n);
|
|
1667
1667
|
}
|
|
1668
1668
|
}
|
|
1669
1669
|
let oo = () => ({
|
|
@@ -1681,11 +1681,11 @@ let oo = () => ({
|
|
|
1681
1681
|
}
|
|
1682
1682
|
});
|
|
1683
1683
|
const io = (t, e) => {
|
|
1684
|
-
const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(),
|
|
1685
|
-
const
|
|
1686
|
-
const O = W([T]) ? T.range :
|
|
1684
|
+
const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(), s = (y, C) => {
|
|
1685
|
+
const E = y.selector.flatMap((T) => {
|
|
1686
|
+
const O = W([T]) ? T.range : re(T, e).range;
|
|
1687
1687
|
return Array.from(O.getClientRects());
|
|
1688
|
-
}), w = _e(
|
|
1688
|
+
}), w = _e(E).map((T) => Ve(T, C));
|
|
1689
1689
|
return w.map((T) => {
|
|
1690
1690
|
const { x: O, y: R, width: m, height: v } = T;
|
|
1691
1691
|
return {
|
|
@@ -1699,158 +1699,158 @@ const io = (t, e) => {
|
|
|
1699
1699
|
}
|
|
1700
1700
|
};
|
|
1701
1701
|
});
|
|
1702
|
-
},
|
|
1702
|
+
}, r = () => [...o.values()], a = () => {
|
|
1703
1703
|
n.clear(), o.clear();
|
|
1704
|
-
},
|
|
1705
|
-
const
|
|
1706
|
-
|
|
1704
|
+
}, l = (y) => {
|
|
1705
|
+
const C = s(y, e.getBoundingClientRect());
|
|
1706
|
+
C.forEach((E) => n.insert(E)), o.set(y.annotation, C);
|
|
1707
|
+
}, u = (y) => {
|
|
1708
|
+
const C = o.get(y.annotation);
|
|
1709
|
+
C && (C.forEach((E) => n.remove(E)), o.delete(y.annotation));
|
|
1707
1710
|
}, f = (y) => {
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
}, l = (y, S = !0) => {
|
|
1713
|
-
S && s();
|
|
1714
|
-
const A = e.getBoundingClientRect(), w = y.map((O) => ({ target: O, rects: r(O, A) }));
|
|
1711
|
+
u(y), l(y);
|
|
1712
|
+
}, c = (y, C = !0) => {
|
|
1713
|
+
C && a();
|
|
1714
|
+
const E = e.getBoundingClientRect(), w = y.map((O) => ({ target: O, rects: s(O, E) }));
|
|
1715
1715
|
w.forEach(({ target: O, rects: R }) => o.set(O.annotation, R));
|
|
1716
1716
|
const T = w.flatMap(({ rects: O }) => O);
|
|
1717
1717
|
n.load(T);
|
|
1718
|
-
},
|
|
1718
|
+
}, g = (y, C, E = !1) => {
|
|
1719
1719
|
const w = n.search({
|
|
1720
1720
|
minX: y,
|
|
1721
|
-
minY:
|
|
1721
|
+
minY: C,
|
|
1722
1722
|
maxX: y,
|
|
1723
|
-
maxY:
|
|
1723
|
+
maxY: C
|
|
1724
1724
|
}), T = (O) => O.annotation.rects.reduce((R, m) => R + m.width * m.height, 0);
|
|
1725
|
-
return w.length > 0 ? (w.sort((O, R) => T(O) - T(R)),
|
|
1726
|
-
},
|
|
1727
|
-
const
|
|
1728
|
-
if (
|
|
1725
|
+
return w.length > 0 ? (w.sort((O, R) => T(O) - T(R)), E ? w.map((O) => O.annotation.id) : [w[0].annotation.id]) : [];
|
|
1726
|
+
}, h = (y) => {
|
|
1727
|
+
const C = A(y);
|
|
1728
|
+
if (C.length === 0)
|
|
1729
1729
|
return;
|
|
1730
|
-
let
|
|
1731
|
-
for (let R = 1; R <
|
|
1732
|
-
const m =
|
|
1733
|
-
|
|
1730
|
+
let E = C[0].left, w = C[0].top, T = C[0].right, O = C[0].bottom;
|
|
1731
|
+
for (let R = 1; R < C.length; R++) {
|
|
1732
|
+
const m = C[R];
|
|
1733
|
+
E = Math.min(E, m.left), w = Math.min(w, m.top), T = Math.max(T, m.right), O = Math.max(O, m.bottom);
|
|
1734
1734
|
}
|
|
1735
|
-
return new DOMRect(
|
|
1736
|
-
},
|
|
1737
|
-
const
|
|
1738
|
-
return
|
|
1735
|
+
return new DOMRect(E, w, T - E, O - w);
|
|
1736
|
+
}, A = (y) => {
|
|
1737
|
+
const C = o.get(y);
|
|
1738
|
+
return C ? C[0].annotation.rects : [];
|
|
1739
1739
|
};
|
|
1740
1740
|
return {
|
|
1741
|
-
all:
|
|
1742
|
-
clear:
|
|
1743
|
-
getAt:
|
|
1744
|
-
getAnnotationBounds:
|
|
1745
|
-
getAnnotationRects:
|
|
1746
|
-
getIntersecting: (y,
|
|
1747
|
-
const T = n.search({ minX: y, minY:
|
|
1741
|
+
all: r,
|
|
1742
|
+
clear: a,
|
|
1743
|
+
getAt: g,
|
|
1744
|
+
getAnnotationBounds: h,
|
|
1745
|
+
getAnnotationRects: A,
|
|
1746
|
+
getIntersecting: (y, C, E, w) => {
|
|
1747
|
+
const T = n.search({ minX: y, minY: C, maxX: E, maxY: w }), O = new Set(T.map((R) => R.annotation.id));
|
|
1748
1748
|
return Array.from(O).map((R) => ({
|
|
1749
1749
|
annotation: t.getAnnotation(R),
|
|
1750
|
-
rects:
|
|
1750
|
+
rects: A(R)
|
|
1751
1751
|
})).filter((R) => !!R.annotation);
|
|
1752
1752
|
},
|
|
1753
|
-
insert:
|
|
1753
|
+
insert: l,
|
|
1754
1754
|
recalculate: () => {
|
|
1755
|
-
|
|
1755
|
+
c(t.all().map((y) => y.target), !0), i.emit("recalculate");
|
|
1756
1756
|
},
|
|
1757
|
-
remove:
|
|
1758
|
-
set:
|
|
1757
|
+
remove: u,
|
|
1758
|
+
set: c,
|
|
1759
1759
|
size: () => n.all().length,
|
|
1760
|
-
update:
|
|
1761
|
-
on: (y,
|
|
1760
|
+
update: f,
|
|
1761
|
+
on: (y, C) => i.on(y, C)
|
|
1762
1762
|
};
|
|
1763
|
-
},
|
|
1763
|
+
}, so = (t, e) => {
|
|
1764
1764
|
const n = Rn(), o = io(n, t), i = yn(n);
|
|
1765
1765
|
i.setUserSelectAction(e);
|
|
1766
|
-
const
|
|
1767
|
-
const
|
|
1768
|
-
return
|
|
1769
|
-
},
|
|
1770
|
-
const
|
|
1771
|
-
return w.length > 0 ? (console.warn("Could not revive all targets for these annotations:", w), n.bulkAddAnnotation(
|
|
1772
|
-
},
|
|
1773
|
-
const
|
|
1774
|
-
return
|
|
1766
|
+
const s = gn(n), r = In(), a = (d, y = k.LOCAL) => {
|
|
1767
|
+
const C = wt(d, t), E = W(C.target.selector);
|
|
1768
|
+
return E && n.addAnnotation(C, y), E;
|
|
1769
|
+
}, l = (d, y = !0, C = k.LOCAL) => {
|
|
1770
|
+
const E = d.map((T) => wt(T, t)), w = E.filter((T) => !W(T.target.selector));
|
|
1771
|
+
return w.length > 0 ? (console.warn("Could not revive all targets for these annotations:", w), n.bulkAddAnnotation(E, y, C), w) : (n.bulkAddAnnotation(E, y, C), []);
|
|
1772
|
+
}, u = (d, y = k.LOCAL) => {
|
|
1773
|
+
const C = d.map((w) => wt(w, t)), E = C.filter((w) => !W(w.target.selector));
|
|
1774
|
+
return E.length > 0 && console.warn("Could not revive all targets for these annotations:", E), C.forEach((w) => {
|
|
1775
1775
|
n.getAnnotation(w.id) ? n.updateAnnotation(w, y) : n.addAnnotation(w, y);
|
|
1776
|
-
}),
|
|
1777
|
-
},
|
|
1778
|
-
const
|
|
1779
|
-
n.updateTarget(
|
|
1780
|
-
},
|
|
1781
|
-
const
|
|
1782
|
-
n.bulkUpdateTargets(
|
|
1783
|
-
},
|
|
1784
|
-
const
|
|
1776
|
+
}), E;
|
|
1777
|
+
}, f = (d, y = k.LOCAL) => {
|
|
1778
|
+
const C = yt(d, t);
|
|
1779
|
+
n.updateTarget(C, y);
|
|
1780
|
+
}, c = (d, y = k.LOCAL) => {
|
|
1781
|
+
const C = d.map((E) => yt(E, t));
|
|
1782
|
+
n.bulkUpdateTargets(C, y);
|
|
1783
|
+
}, g = (d, y, C) => {
|
|
1784
|
+
const E = o.getAt(d, y, !!C).map((T) => n.getAnnotation(T)), w = C ? E.filter(C) : E;
|
|
1785
1785
|
return w.length > 0 ? w[0] : void 0;
|
|
1786
|
-
},
|
|
1787
|
-
const w = o.getAnnotationRects(
|
|
1786
|
+
}, h = (d, y, C, E = 5) => {
|
|
1787
|
+
const w = o.getAnnotationRects(d);
|
|
1788
1788
|
if (w.length !== 0) {
|
|
1789
|
-
if (y &&
|
|
1790
|
-
const T = w.find(({ top: O, right: R, bottom: m, left: v }) => y >= v -
|
|
1789
|
+
if (y && C) {
|
|
1790
|
+
const T = w.find(({ top: O, right: R, bottom: m, left: v }) => y >= v - E && y <= R + E && C >= O - E && C <= m + E);
|
|
1791
1791
|
if (T) return T;
|
|
1792
1792
|
}
|
|
1793
|
-
return o.getAnnotationBounds(
|
|
1793
|
+
return o.getAnnotationBounds(d);
|
|
1794
1794
|
}
|
|
1795
|
-
},
|
|
1796
|
-
return n.observe(({ changes:
|
|
1797
|
-
const y = (
|
|
1798
|
-
(y == null ? void 0 : y.length) > 0 && y.forEach((w) => o.remove(w.target)),
|
|
1795
|
+
}, A = (d, y, C, E) => o.getIntersecting(d, y, C, E), b = (d) => o.getAnnotationRects(d), S = () => o.recalculate(), p = (d) => o.on("recalculate", d);
|
|
1796
|
+
return n.observe(({ changes: d }) => {
|
|
1797
|
+
const y = (d.deleted || []).filter((w) => W(w.target.selector)), C = (d.created || []).filter((w) => W(w.target.selector)), E = (d.updated || []).filter((w) => W(w.newValue.target.selector));
|
|
1798
|
+
(y == null ? void 0 : y.length) > 0 && y.forEach((w) => o.remove(w.target)), C.length > 0 && o.set(C.map((w) => w.target), !1), (E == null ? void 0 : E.length) > 0 && E.forEach(({ newValue: w }) => o.update(w.target));
|
|
1799
1799
|
}), {
|
|
1800
1800
|
store: {
|
|
1801
1801
|
...n,
|
|
1802
|
-
addAnnotation:
|
|
1803
|
-
bulkAddAnnotation:
|
|
1804
|
-
bulkUpdateTargets:
|
|
1805
|
-
bulkUpsertAnnotations:
|
|
1806
|
-
getAnnotationBounds:
|
|
1802
|
+
addAnnotation: a,
|
|
1803
|
+
bulkAddAnnotation: l,
|
|
1804
|
+
bulkUpdateTargets: c,
|
|
1805
|
+
bulkUpsertAnnotations: u,
|
|
1806
|
+
getAnnotationBounds: h,
|
|
1807
1807
|
getAnnotationRects: b,
|
|
1808
|
-
getIntersecting:
|
|
1809
|
-
getAt:
|
|
1810
|
-
recalculatePositions:
|
|
1811
|
-
onRecalculatePositions:
|
|
1812
|
-
updateTarget:
|
|
1808
|
+
getIntersecting: A,
|
|
1809
|
+
getAt: g,
|
|
1810
|
+
recalculatePositions: S,
|
|
1811
|
+
onRecalculatePositions: p,
|
|
1812
|
+
updateTarget: f
|
|
1813
1813
|
},
|
|
1814
1814
|
selection: i,
|
|
1815
|
-
hover:
|
|
1816
|
-
viewport:
|
|
1815
|
+
hover: s,
|
|
1816
|
+
viewport: r
|
|
1817
1817
|
};
|
|
1818
|
-
},
|
|
1818
|
+
}, ro = () => {
|
|
1819
1819
|
const t = document.createElement("canvas");
|
|
1820
1820
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
|
|
1821
1821
|
const e = t.getContext("2d");
|
|
1822
1822
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
1823
1823
|
}, ao = (t, e = {}) => {
|
|
1824
|
-
const n =
|
|
1824
|
+
const n = ro(), o = n.getContext("2d");
|
|
1825
1825
|
document.body.appendChild(n);
|
|
1826
|
-
const i = /* @__PURE__ */ new Map(),
|
|
1827
|
-
return t.on("selectionChange", (
|
|
1828
|
-
|
|
1826
|
+
const i = /* @__PURE__ */ new Map(), s = (f) => Array.from(i.entries()).filter(([c, g]) => g.presenceKey === f.presenceKey).map(([c, g]) => c);
|
|
1827
|
+
return t.on("selectionChange", (f, c) => {
|
|
1828
|
+
s(f).forEach((h) => i.delete(h)), c && c.forEach((h) => i.set(h, f));
|
|
1829
1829
|
}), {
|
|
1830
1830
|
clear: () => {
|
|
1831
|
-
const { width:
|
|
1832
|
-
o.clearRect(-0.5, -0.5,
|
|
1831
|
+
const { width: f, height: c } = n;
|
|
1832
|
+
o.clearRect(-0.5, -0.5, f + 1, c + 1);
|
|
1833
1833
|
},
|
|
1834
1834
|
destroy: () => {
|
|
1835
1835
|
n.remove();
|
|
1836
1836
|
},
|
|
1837
|
-
paint: (
|
|
1837
|
+
paint: (f, c, g) => {
|
|
1838
1838
|
e.font && (o.font = e.font);
|
|
1839
|
-
const
|
|
1840
|
-
if (
|
|
1841
|
-
const { height:
|
|
1842
|
-
o.fillStyle =
|
|
1843
|
-
const
|
|
1844
|
-
return o.fillRect(b - 2,
|
|
1845
|
-
fill:
|
|
1846
|
-
fillOpacity:
|
|
1839
|
+
const h = i.get(f.annotation.id);
|
|
1840
|
+
if (h) {
|
|
1841
|
+
const { height: A } = f.rects[0], b = f.rects[0].x + c.left, S = f.rects[0].y + c.top;
|
|
1842
|
+
o.fillStyle = h.appearance.color, o.fillRect(b - 2, S - 2.5, 2, A + 5);
|
|
1843
|
+
const p = o.measureText(h.appearance.label), d = p.width + 6, y = p.actualBoundingBoxAscent + p.actualBoundingBoxDescent + 8, C = p.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1844
|
+
return o.fillRect(b - 2, S - 2.5 - y, d, y), o.fillStyle = "#fff", o.fillText(h.appearance.label, b + 1, S - C), {
|
|
1845
|
+
fill: h.appearance.color,
|
|
1846
|
+
fillOpacity: g ? 0.45 : 0.18
|
|
1847
1847
|
};
|
|
1848
1848
|
}
|
|
1849
1849
|
},
|
|
1850
1850
|
reset: () => {
|
|
1851
1851
|
n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
|
|
1852
|
-
const
|
|
1853
|
-
|
|
1852
|
+
const f = n.getContext("2d");
|
|
1853
|
+
f.scale(2, 2), f.translate(0.5, 0.5);
|
|
1854
1854
|
}
|
|
1855
1855
|
};
|
|
1856
1856
|
}, Mt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
|
|
@@ -1873,14 +1873,14 @@ function be(t) {
|
|
|
1873
1873
|
e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
|
|
1874
1874
|
return e;
|
|
1875
1875
|
}
|
|
1876
|
-
function
|
|
1876
|
+
function co(t, e) {
|
|
1877
1877
|
const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
|
|
1878
1878
|
let i = !0;
|
|
1879
|
-
for (let
|
|
1880
|
-
o.indexOf(n[
|
|
1879
|
+
for (let s = 0; s < n.length; s++)
|
|
1880
|
+
o.indexOf(n[s]) === -1 && (i = !1);
|
|
1881
1881
|
return i;
|
|
1882
1882
|
}
|
|
1883
|
-
const
|
|
1883
|
+
const rt = {
|
|
1884
1884
|
backspace: 8,
|
|
1885
1885
|
"⌫": 8,
|
|
1886
1886
|
tab: 9,
|
|
@@ -1964,9 +1964,9 @@ const st = {
|
|
|
1964
1964
|
91: !1
|
|
1965
1965
|
}, _ = {};
|
|
1966
1966
|
for (let t = 1; t < 20; t++)
|
|
1967
|
-
|
|
1968
|
-
let I = [],
|
|
1969
|
-
const F = /* @__PURE__ */ new Map(),
|
|
1967
|
+
rt["f".concat(t)] = 111 + t;
|
|
1968
|
+
let I = [], st = null, we = "all";
|
|
1969
|
+
const F = /* @__PURE__ */ new Map(), ct = (t) => rt[t.toLowerCase()] || H[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), lo = (t) => Object.keys(rt).find((e) => rt[e] === t), uo = (t) => Object.keys(H).find((e) => H[e] === t);
|
|
1970
1970
|
function ve(t) {
|
|
1971
1971
|
we = t || "all";
|
|
1972
1972
|
}
|
|
@@ -1977,28 +1977,28 @@ function fo() {
|
|
|
1977
1977
|
return I.slice(0);
|
|
1978
1978
|
}
|
|
1979
1979
|
function ho() {
|
|
1980
|
-
return I.map((t) =>
|
|
1980
|
+
return I.map((t) => lo(t) || uo(t) || String.fromCharCode(t));
|
|
1981
1981
|
}
|
|
1982
|
-
function
|
|
1982
|
+
function po() {
|
|
1983
1983
|
const t = [];
|
|
1984
1984
|
return Object.keys(_).forEach((e) => {
|
|
1985
1985
|
_[e].forEach((n) => {
|
|
1986
1986
|
let {
|
|
1987
1987
|
key: o,
|
|
1988
1988
|
scope: i,
|
|
1989
|
-
mods:
|
|
1990
|
-
shortcut:
|
|
1989
|
+
mods: s,
|
|
1990
|
+
shortcut: r
|
|
1991
1991
|
} = n;
|
|
1992
1992
|
t.push({
|
|
1993
1993
|
scope: i,
|
|
1994
|
-
shortcut:
|
|
1995
|
-
mods:
|
|
1996
|
-
keys: o.split("+").map((
|
|
1994
|
+
shortcut: r,
|
|
1995
|
+
mods: s,
|
|
1996
|
+
keys: o.split("+").map((a) => ct(a))
|
|
1997
1997
|
});
|
|
1998
1998
|
});
|
|
1999
1999
|
}), t;
|
|
2000
2000
|
}
|
|
2001
|
-
function
|
|
2001
|
+
function go(t) {
|
|
2002
2002
|
const e = t.target || t.srcElement, {
|
|
2003
2003
|
tagName: n
|
|
2004
2004
|
} = e;
|
|
@@ -2007,7 +2007,7 @@ function po(t) {
|
|
|
2007
2007
|
return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
|
|
2008
2008
|
}
|
|
2009
2009
|
function mo(t) {
|
|
2010
|
-
return typeof t == "string" && (t =
|
|
2010
|
+
return typeof t == "string" && (t = ct(t)), I.indexOf(t) !== -1;
|
|
2011
2011
|
}
|
|
2012
2012
|
function yo(t, e) {
|
|
2013
2013
|
let n, o;
|
|
@@ -2015,11 +2015,11 @@ function yo(t, e) {
|
|
|
2015
2015
|
for (const i in _)
|
|
2016
2016
|
if (Object.prototype.hasOwnProperty.call(_, i))
|
|
2017
2017
|
for (n = _[i], o = 0; o < n.length; )
|
|
2018
|
-
n[o].scope === t ? n.splice(o, 1).forEach((
|
|
2018
|
+
n[o].scope === t ? n.splice(o, 1).forEach((r) => {
|
|
2019
2019
|
let {
|
|
2020
|
-
element:
|
|
2021
|
-
} =
|
|
2022
|
-
return Yt(
|
|
2020
|
+
element: a
|
|
2021
|
+
} = r;
|
|
2022
|
+
return Yt(a);
|
|
2023
2023
|
}) : o++;
|
|
2024
2024
|
at() === t && ve(e || "all");
|
|
2025
2025
|
}
|
|
@@ -2031,10 +2031,10 @@ function bo(t) {
|
|
|
2031
2031
|
for (const o in H) H[o] === e && (j[o] = !1);
|
|
2032
2032
|
}
|
|
2033
2033
|
}
|
|
2034
|
-
function
|
|
2034
|
+
function Ae(t) {
|
|
2035
2035
|
if (typeof t > "u")
|
|
2036
2036
|
Object.keys(_).forEach((i) => {
|
|
2037
|
-
Array.isArray(_[i]) && _[i].forEach((
|
|
2037
|
+
Array.isArray(_[i]) && _[i].forEach((s) => mt(s)), delete _[i];
|
|
2038
2038
|
}), Yt(null);
|
|
2039
2039
|
else if (Array.isArray(t))
|
|
2040
2040
|
t.forEach((i) => {
|
|
@@ -2045,11 +2045,11 @@ function xe(t) {
|
|
|
2045
2045
|
else if (typeof t == "string") {
|
|
2046
2046
|
for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
|
|
2047
2047
|
n[o - 1] = arguments[o];
|
|
2048
|
-
let [i,
|
|
2049
|
-
typeof i == "function" && (
|
|
2048
|
+
let [i, s] = n;
|
|
2049
|
+
typeof i == "function" && (s = i, i = ""), mt({
|
|
2050
2050
|
key: t,
|
|
2051
2051
|
scope: i,
|
|
2052
|
-
method:
|
|
2052
|
+
method: s,
|
|
2053
2053
|
splitKey: "+"
|
|
2054
2054
|
});
|
|
2055
2055
|
}
|
|
@@ -2061,15 +2061,15 @@ const mt = (t) => {
|
|
|
2061
2061
|
method: o,
|
|
2062
2062
|
splitKey: i = "+"
|
|
2063
2063
|
} = t;
|
|
2064
|
-
be(e).forEach((
|
|
2065
|
-
const
|
|
2066
|
-
if (!_[
|
|
2064
|
+
be(e).forEach((r) => {
|
|
2065
|
+
const a = r.split(i), l = a.length, u = a[l - 1], f = u === "*" ? "*" : ct(u);
|
|
2066
|
+
if (!_[f]) return;
|
|
2067
2067
|
n || (n = at());
|
|
2068
|
-
const
|
|
2069
|
-
_[
|
|
2070
|
-
const b = (o ?
|
|
2071
|
-
return b &&
|
|
2072
|
-
}),
|
|
2068
|
+
const c = l > 1 ? ye(H, a) : [], g = [];
|
|
2069
|
+
_[f] = _[f].filter((h) => {
|
|
2070
|
+
const b = (o ? h.method === o : !0) && h.scope === n && co(h.mods, c);
|
|
2071
|
+
return b && g.push(h.element), !b;
|
|
2072
|
+
}), g.forEach((h) => Yt(h));
|
|
2073
2073
|
});
|
|
2074
2074
|
};
|
|
2075
2075
|
function ee(t, e, n, o) {
|
|
@@ -2078,8 +2078,8 @@ function ee(t, e, n, o) {
|
|
|
2078
2078
|
let i;
|
|
2079
2079
|
if (e.scope === n || e.scope === "all") {
|
|
2080
2080
|
i = e.mods.length > 0;
|
|
2081
|
-
for (const
|
|
2082
|
-
Object.prototype.hasOwnProperty.call(D,
|
|
2081
|
+
for (const s in D)
|
|
2082
|
+
Object.prototype.hasOwnProperty.call(D, s) && (!D[s] && e.mods.indexOf(+s) > -1 || D[s] && e.mods.indexOf(+s) === -1) && (i = !1);
|
|
2083
2083
|
(e.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
|
|
2084
2084
|
}
|
|
2085
2085
|
}
|
|
@@ -2087,73 +2087,73 @@ function ne(t, e) {
|
|
|
2087
2087
|
const n = _["*"];
|
|
2088
2088
|
let o = t.keyCode || t.which || t.charCode;
|
|
2089
2089
|
if (!j.filter.call(this, t)) return;
|
|
2090
|
-
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((
|
|
2091
|
-
const
|
|
2092
|
-
t[
|
|
2090
|
+
if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
|
|
2091
|
+
const l = Nt[a];
|
|
2092
|
+
t[a] && I.indexOf(l) === -1 ? I.push(l) : !t[a] && I.indexOf(l) > -1 ? I.splice(I.indexOf(l), 1) : a === "metaKey" && t[a] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(l))));
|
|
2093
2093
|
}), o in D) {
|
|
2094
2094
|
D[o] = !0;
|
|
2095
|
-
for (const
|
|
2096
|
-
H[
|
|
2095
|
+
for (const a in H)
|
|
2096
|
+
H[a] === o && (j[a] = !0);
|
|
2097
2097
|
if (!n) return;
|
|
2098
2098
|
}
|
|
2099
|
-
for (const
|
|
2100
|
-
Object.prototype.hasOwnProperty.call(D,
|
|
2099
|
+
for (const a in D)
|
|
2100
|
+
Object.prototype.hasOwnProperty.call(D, a) && (D[a] = t[Nt[a]]);
|
|
2101
2101
|
t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), D[17] = !0, D[18] = !0);
|
|
2102
2102
|
const i = at();
|
|
2103
2103
|
if (n)
|
|
2104
|
-
for (let
|
|
2105
|
-
n[
|
|
2104
|
+
for (let a = 0; a < n.length; a++)
|
|
2105
|
+
n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && ee(t, n[a], i, e);
|
|
2106
2106
|
if (!(o in _)) return;
|
|
2107
|
-
const
|
|
2108
|
-
for (let
|
|
2109
|
-
if ((t.type === "keydown" &&
|
|
2110
|
-
const
|
|
2111
|
-
splitKey:
|
|
2112
|
-
} =
|
|
2113
|
-
for (let
|
|
2114
|
-
|
|
2115
|
-
|
|
2107
|
+
const s = _[o], r = s.length;
|
|
2108
|
+
for (let a = 0; a < r; a++)
|
|
2109
|
+
if ((t.type === "keydown" && s[a].keydown || t.type === "keyup" && s[a].keyup) && s[a].key) {
|
|
2110
|
+
const l = s[a], {
|
|
2111
|
+
splitKey: u
|
|
2112
|
+
} = l, f = l.key.split(u), c = [];
|
|
2113
|
+
for (let g = 0; g < f.length; g++)
|
|
2114
|
+
c.push(ct(f[g]));
|
|
2115
|
+
c.sort().join("") === I.sort().join("") && ee(t, l, i, e);
|
|
2116
2116
|
}
|
|
2117
2117
|
}
|
|
2118
2118
|
function j(t, e, n) {
|
|
2119
2119
|
I = [];
|
|
2120
2120
|
const o = be(t);
|
|
2121
|
-
let i = [],
|
|
2122
|
-
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (
|
|
2123
|
-
t = o[
|
|
2124
|
-
keyup:
|
|
2125
|
-
keydown:
|
|
2126
|
-
scope:
|
|
2121
|
+
let i = [], s = "all", r = document, a = 0, l = !1, u = !0, f = "+", c = !1, g = !1;
|
|
2122
|
+
for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (u = e.keydown), e.capture !== void 0 && (c = e.capture), typeof e.splitKey == "string" && (f = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && Ae(t, s); a < o.length; a++)
|
|
2123
|
+
t = o[a].split(f), i = [], t.length > 1 && (i = ye(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ct(t), t in _ || (_[t] = []), _[t].push({
|
|
2124
|
+
keyup: l,
|
|
2125
|
+
keydown: u,
|
|
2126
|
+
scope: s,
|
|
2127
2127
|
mods: i,
|
|
2128
|
-
shortcut: o[
|
|
2128
|
+
shortcut: o[a],
|
|
2129
2129
|
method: n,
|
|
2130
|
-
key: o[
|
|
2131
|
-
splitKey:
|
|
2132
|
-
element:
|
|
2130
|
+
key: o[a],
|
|
2131
|
+
splitKey: f,
|
|
2132
|
+
element: r
|
|
2133
2133
|
});
|
|
2134
|
-
if (typeof
|
|
2135
|
-
if (!F.has(
|
|
2136
|
-
const
|
|
2134
|
+
if (typeof r < "u" && window) {
|
|
2135
|
+
if (!F.has(r)) {
|
|
2136
|
+
const h = function() {
|
|
2137
2137
|
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2138
|
-
return ne(b,
|
|
2139
|
-
},
|
|
2138
|
+
return ne(b, r);
|
|
2139
|
+
}, A = function() {
|
|
2140
2140
|
let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
|
|
2141
|
-
ne(b,
|
|
2141
|
+
ne(b, r), bo(b);
|
|
2142
2142
|
};
|
|
2143
|
-
F.set(
|
|
2144
|
-
keydownListener:
|
|
2145
|
-
keyupListenr:
|
|
2146
|
-
capture:
|
|
2147
|
-
}), Bt(
|
|
2143
|
+
F.set(r, {
|
|
2144
|
+
keydownListener: h,
|
|
2145
|
+
keyupListenr: A,
|
|
2146
|
+
capture: c
|
|
2147
|
+
}), Bt(r, "keydown", h, c), Bt(r, "keyup", A, c);
|
|
2148
2148
|
}
|
|
2149
|
-
if (!
|
|
2150
|
-
const
|
|
2149
|
+
if (!st) {
|
|
2150
|
+
const h = () => {
|
|
2151
2151
|
I = [];
|
|
2152
2152
|
};
|
|
2153
|
-
|
|
2154
|
-
listener:
|
|
2155
|
-
capture:
|
|
2156
|
-
}, Bt(window, "focus",
|
|
2153
|
+
st = {
|
|
2154
|
+
listener: h,
|
|
2155
|
+
capture: c
|
|
2156
|
+
}, Bt(window, "focus", h, c);
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
2159
|
}
|
|
@@ -2176,23 +2176,23 @@ function Yt(t) {
|
|
|
2176
2176
|
const {
|
|
2177
2177
|
keydownListener: o,
|
|
2178
2178
|
keyupListenr: i,
|
|
2179
|
-
capture:
|
|
2179
|
+
capture: s
|
|
2180
2180
|
} = F.get(t) || {};
|
|
2181
|
-
o && i && (et(t, "keyup", i,
|
|
2181
|
+
o && i && (et(t, "keyup", i, s), et(t, "keydown", o, s), F.delete(t));
|
|
2182
2182
|
}
|
|
2183
2183
|
if ((e.length <= 0 || F.size <= 0) && (Object.keys(F).forEach((i) => {
|
|
2184
2184
|
const {
|
|
2185
|
-
keydownListener:
|
|
2186
|
-
keyupListenr:
|
|
2187
|
-
capture:
|
|
2185
|
+
keydownListener: s,
|
|
2186
|
+
keyupListenr: r,
|
|
2187
|
+
capture: a
|
|
2188
2188
|
} = F.get(i) || {};
|
|
2189
|
-
|
|
2190
|
-
}), F.clear(), Object.keys(_).forEach((i) => delete _[i]),
|
|
2189
|
+
s && r && (et(i, "keyup", r, a), et(i, "keydown", s, a), F.delete(i));
|
|
2190
|
+
}), F.clear(), Object.keys(_).forEach((i) => delete _[i]), st)) {
|
|
2191
2191
|
const {
|
|
2192
2192
|
listener: i,
|
|
2193
|
-
capture:
|
|
2194
|
-
} =
|
|
2195
|
-
et(window, "focus", i,
|
|
2193
|
+
capture: s
|
|
2194
|
+
} = st;
|
|
2195
|
+
et(window, "focus", i, s), st = null;
|
|
2196
2196
|
}
|
|
2197
2197
|
}
|
|
2198
2198
|
const kt = {
|
|
@@ -2201,12 +2201,12 @@ const kt = {
|
|
|
2201
2201
|
getScope: at,
|
|
2202
2202
|
deleteScope: yo,
|
|
2203
2203
|
getPressedKeyCodes: fo,
|
|
2204
|
-
getAllKeyCodes:
|
|
2204
|
+
getAllKeyCodes: po,
|
|
2205
2205
|
isPressed: mo,
|
|
2206
|
-
filter:
|
|
2206
|
+
filter: go,
|
|
2207
2207
|
trigger: wo,
|
|
2208
|
-
unbind:
|
|
2209
|
-
keyMap:
|
|
2208
|
+
unbind: Ae,
|
|
2209
|
+
keyMap: rt,
|
|
2210
2210
|
modifier: H,
|
|
2211
2211
|
modifierMap: Nt
|
|
2212
2212
|
};
|
|
@@ -2219,17 +2219,17 @@ if (typeof window < "u") {
|
|
|
2219
2219
|
const oe = 300, vo = (t, e, n) => {
|
|
2220
2220
|
let o;
|
|
2221
2221
|
const i = (w) => o = w;
|
|
2222
|
-
let
|
|
2223
|
-
const
|
|
2224
|
-
let
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2227
|
-
}, { store:
|
|
2228
|
-
let
|
|
2229
|
-
const
|
|
2222
|
+
let s;
|
|
2223
|
+
const r = (w) => s = w;
|
|
2224
|
+
let a = !0;
|
|
2225
|
+
const l = (w) => {
|
|
2226
|
+
a = w, b.clear(), w || (c = void 0, g = void 0, h = void 0);
|
|
2227
|
+
}, { store: u, selection: f } = e;
|
|
2228
|
+
let c, g, h;
|
|
2229
|
+
const A = (w) => {
|
|
2230
2230
|
var O;
|
|
2231
|
-
if (!
|
|
2232
|
-
|
|
2231
|
+
if (!a || g === !1) return;
|
|
2232
|
+
c = !((O = w.target.parentElement) != null && O.closest(P)) ? {
|
|
2233
2233
|
annotation: fe(),
|
|
2234
2234
|
selector: [],
|
|
2235
2235
|
creator: o,
|
|
@@ -2237,126 +2237,126 @@ const oe = 300, vo = (t, e, n) => {
|
|
|
2237
2237
|
} : void 0;
|
|
2238
2238
|
}, b = Vt((w) => {
|
|
2239
2239
|
var B, M;
|
|
2240
|
-
if (!
|
|
2240
|
+
if (!a) return;
|
|
2241
2241
|
const T = document.getSelection();
|
|
2242
2242
|
if (!!((M = (B = T.anchorNode) == null ? void 0 : B.parentElement) != null && M.closest(P))) {
|
|
2243
|
-
|
|
2243
|
+
c = void 0;
|
|
2244
2244
|
return;
|
|
2245
2245
|
}
|
|
2246
|
-
const R = w.timeStamp - ((
|
|
2247
|
-
if ((
|
|
2246
|
+
const R = w.timeStamp - ((h == null ? void 0 : h.timeStamp) || w.timeStamp);
|
|
2247
|
+
if ((h == null ? void 0 : h.type) === "pointerdown" && (R < 1e3 && !c || T.isCollapsed && R < oe) && A(h), !c) return;
|
|
2248
2248
|
if (T.isCollapsed) {
|
|
2249
|
-
|
|
2249
|
+
u.getAnnotation(c.annotation) && (f.clear(), u.deleteAnnotation(c.annotation));
|
|
2250
2250
|
return;
|
|
2251
2251
|
}
|
|
2252
2252
|
const m = T.getRangeAt(0), v = Ue(m, t);
|
|
2253
2253
|
if (Be(v)) return;
|
|
2254
2254
|
const x = Le(v.cloneRange());
|
|
2255
|
-
(x.length !==
|
|
2256
|
-
var
|
|
2257
|
-
return K.toString() !== ((
|
|
2258
|
-
})) && (
|
|
2259
|
-
...
|
|
2255
|
+
(x.length !== c.selector.length || x.some((K, Y) => {
|
|
2256
|
+
var lt;
|
|
2257
|
+
return K.toString() !== ((lt = c.selector[Y]) == null ? void 0 : lt.quote);
|
|
2258
|
+
})) && (c = {
|
|
2259
|
+
...c,
|
|
2260
2260
|
selector: x.map((K) => Ne(K, t, n)),
|
|
2261
2261
|
updated: /* @__PURE__ */ new Date()
|
|
2262
|
-
},
|
|
2263
|
-
id:
|
|
2262
|
+
}, u.getAnnotation(c.annotation) ? u.updateTarget(c, k.LOCAL) : (f.clear(), u.addAnnotation({
|
|
2263
|
+
id: c.annotation,
|
|
2264
2264
|
bodies: [],
|
|
2265
|
-
target:
|
|
2266
|
-
}, k.LOCAL),
|
|
2267
|
-
}, 10),
|
|
2265
|
+
target: c
|
|
2266
|
+
}, k.LOCAL), f.userSelect(c.annotation, h)));
|
|
2267
|
+
}, 10), S = (w) => {
|
|
2268
2268
|
var O;
|
|
2269
|
-
(O = w.target.parentElement) != null && O.closest(P) || (
|
|
2270
|
-
},
|
|
2269
|
+
(O = w.target.parentElement) != null && O.closest(P) || (h = De(w), g = h.button === 0);
|
|
2270
|
+
}, p = (w) => {
|
|
2271
2271
|
var m;
|
|
2272
|
-
if (!!((m = w.target.parentElement) != null && m.closest(P)) || !
|
|
2272
|
+
if (!!((m = w.target.parentElement) != null && m.closest(P)) || !g) return;
|
|
2273
2273
|
const O = () => {
|
|
2274
|
-
const { x: v, y: x } = t.getBoundingClientRect(), L = w.target instanceof Node && t.contains(w.target) &&
|
|
2274
|
+
const { x: v, y: x } = t.getBoundingClientRect(), L = w.target instanceof Node && t.contains(w.target) && u.getAt(w.clientX - v, w.clientY - x, s);
|
|
2275
2275
|
if (L) {
|
|
2276
|
-
const { selected: B } =
|
|
2277
|
-
(B.length !== 1 || B[0].id !== L.id) &&
|
|
2278
|
-
} else
|
|
2279
|
-
}, R = w.timeStamp -
|
|
2276
|
+
const { selected: B } = f;
|
|
2277
|
+
(B.length !== 1 || B[0].id !== L.id) && f.userSelect(L.id, w);
|
|
2278
|
+
} else f.isEmpty() || f.clear();
|
|
2279
|
+
}, R = w.timeStamp - h.timeStamp;
|
|
2280
2280
|
setTimeout(() => {
|
|
2281
2281
|
const v = document.getSelection();
|
|
2282
|
-
v != null && v.isCollapsed && R < oe ? (
|
|
2282
|
+
v != null && v.isCollapsed && R < oe ? (c = void 0, O()) : c && u.getAnnotation(c.annotation) && f.userSelect(c.annotation, w);
|
|
2283
2283
|
});
|
|
2284
2284
|
};
|
|
2285
|
-
document.addEventListener("pointerdown",
|
|
2286
|
-
const
|
|
2287
|
-
...
|
|
2285
|
+
document.addEventListener("pointerdown", S), document.addEventListener("pointerup", p), t.addEventListener("selectstart", A), document.addEventListener("selectionchange", b);
|
|
2286
|
+
const d = ["up", "down", "left", "right"], y = [
|
|
2287
|
+
...d.map((w) => `shift+${w}`),
|
|
2288
2288
|
"ctrl+a",
|
|
2289
2289
|
"⌘+a"
|
|
2290
2290
|
];
|
|
2291
2291
|
j(y.join(","), { element: t, keydown: !0, keyup: !1 }, (w) => {
|
|
2292
|
-
w.repeat || (
|
|
2292
|
+
w.repeat || (h = Ke(w));
|
|
2293
2293
|
});
|
|
2294
|
-
const
|
|
2295
|
-
w.repeat || w.target !== t && w.target !== document.body || (
|
|
2294
|
+
const C = (w) => {
|
|
2295
|
+
w.repeat || w.target !== t && w.target !== document.body || (c = void 0, f.clear());
|
|
2296
2296
|
};
|
|
2297
|
-
return j(
|
|
2297
|
+
return j(d.join(","), { keydown: !0, keyup: !1 }, C), {
|
|
2298
2298
|
destroy: () => {
|
|
2299
|
-
|
|
2299
|
+
c = void 0, g = void 0, h = void 0, b.clear(), document.removeEventListener("pointerdown", S), document.removeEventListener("pointerup", p), t.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", b), j.unbind();
|
|
2300
2300
|
},
|
|
2301
|
-
setFilter:
|
|
2301
|
+
setFilter: r,
|
|
2302
2302
|
setUser: i,
|
|
2303
|
-
setAnnotatingEnabled:
|
|
2303
|
+
setAnnotatingEnabled: l
|
|
2304
2304
|
};
|
|
2305
|
-
},
|
|
2305
|
+
}, Ao = (t, e) => ({
|
|
2306
2306
|
...t,
|
|
2307
2307
|
annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
|
|
2308
2308
|
user: t.user || e.user
|
|
2309
2309
|
}), ie = "SPANS", Oo = (t, e = {}) => {
|
|
2310
2310
|
Oe(t), Te(t);
|
|
2311
|
-
const n =
|
|
2311
|
+
const n = Ao(e, {
|
|
2312
2312
|
annotatingEnabled: !0,
|
|
2313
2313
|
user: $n()
|
|
2314
|
-
}), o =
|
|
2315
|
-
let
|
|
2316
|
-
const
|
|
2317
|
-
if (!
|
|
2318
|
-
throw `Unknown renderer implementation: ${
|
|
2319
|
-
console.debug(`Using ${
|
|
2320
|
-
const
|
|
2321
|
-
|
|
2322
|
-
const
|
|
2323
|
-
|
|
2324
|
-
|
|
2314
|
+
}), o = so(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = kn(r), l = _n(o, a, n.adapter);
|
|
2315
|
+
let u = n.user;
|
|
2316
|
+
const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ie : n.renderer || ie, c = f === "SPANS" ? ln(t, o, s) : f === "CSS_HIGHLIGHTS" ? rn(t, o, s) : f === "CANVAS" ? qe(t, o, s) : void 0;
|
|
2317
|
+
if (!c)
|
|
2318
|
+
throw `Unknown renderer implementation: ${f}`;
|
|
2319
|
+
console.debug(`Using ${f} renderer`), n.style && c.setStyle(n.style);
|
|
2320
|
+
const g = vo(t, o, n.offsetReferenceSelector);
|
|
2321
|
+
g.setUser(u), g.setAnnotatingEnabled(n.annotatingEnabled);
|
|
2322
|
+
const h = Un(o, a, n.adapter), A = () => u, b = (E) => {
|
|
2323
|
+
g.setAnnotatingEnabled(
|
|
2324
|
+
E === void 0 ? !0 : E
|
|
2325
2325
|
);
|
|
2326
|
-
},
|
|
2327
|
-
|
|
2328
|
-
},
|
|
2329
|
-
|
|
2330
|
-
},
|
|
2331
|
-
|
|
2332
|
-
}, y = (
|
|
2333
|
-
|
|
2326
|
+
}, S = (E) => {
|
|
2327
|
+
c.setFilter(E), g.setFilter(E);
|
|
2328
|
+
}, p = (E) => {
|
|
2329
|
+
u = E, g.setUser(E);
|
|
2330
|
+
}, d = (E) => {
|
|
2331
|
+
E && (c.setPainter(ao(E, n.presence)), E.on("selectionChange", () => c.redraw()));
|
|
2332
|
+
}, y = (E) => {
|
|
2333
|
+
E ? i.setSelected(E) : i.clear();
|
|
2334
2334
|
};
|
|
2335
2335
|
return {
|
|
2336
|
-
...
|
|
2336
|
+
...h,
|
|
2337
2337
|
destroy: () => {
|
|
2338
|
-
|
|
2338
|
+
c.destroy(), g.destroy(), a.destroy();
|
|
2339
2339
|
},
|
|
2340
2340
|
element: t,
|
|
2341
|
-
getUser:
|
|
2341
|
+
getUser: A,
|
|
2342
2342
|
setAnnotatingEnabled: b,
|
|
2343
|
-
setFilter:
|
|
2344
|
-
setStyle:
|
|
2345
|
-
redraw:
|
|
2346
|
-
setUser:
|
|
2343
|
+
setFilter: S,
|
|
2344
|
+
setStyle: c.setStyle.bind(c),
|
|
2345
|
+
redraw: c.redraw.bind(c),
|
|
2346
|
+
setUser: p,
|
|
2347
2347
|
setSelected: y,
|
|
2348
|
-
setPresenceProvider:
|
|
2349
|
-
setVisible:
|
|
2350
|
-
on:
|
|
2351
|
-
off:
|
|
2352
|
-
scrollIntoView: Ye(t,
|
|
2348
|
+
setPresenceProvider: d,
|
|
2349
|
+
setVisible: c.setVisible.bind(c),
|
|
2350
|
+
on: l.on,
|
|
2351
|
+
off: l.off,
|
|
2352
|
+
scrollIntoView: Ye(t, r),
|
|
2353
2353
|
state: o
|
|
2354
2354
|
};
|
|
2355
2355
|
};
|
|
2356
2356
|
export {
|
|
2357
2357
|
bt as DEFAULT_SELECTED_STYLE,
|
|
2358
2358
|
q as DEFAULT_STYLE,
|
|
2359
|
-
|
|
2359
|
+
se as NOT_ANNOTATABLE_CLASS,
|
|
2360
2360
|
P as NOT_ANNOTATABLE_SELECTOR,
|
|
2361
2361
|
k as Origin,
|
|
2362
2362
|
mn as UserSelectAction,
|
|
@@ -2366,16 +2366,16 @@ export {
|
|
|
2366
2366
|
De as clonePointerEvent,
|
|
2367
2367
|
Co as createBody,
|
|
2368
2368
|
qe as createCanvasRenderer,
|
|
2369
|
-
|
|
2369
|
+
rn as createHighlightsRenderer,
|
|
2370
2370
|
ao as createPresencePainter,
|
|
2371
|
-
|
|
2371
|
+
sn as createRenderer,
|
|
2372
2372
|
vo as createSelectionHandler,
|
|
2373
|
-
|
|
2373
|
+
ln as createSpansRenderer,
|
|
2374
2374
|
Oo as createTextAnnotator,
|
|
2375
|
-
|
|
2375
|
+
so as createTextAnnotatorState,
|
|
2376
2376
|
So as denormalizeRectWithOffset,
|
|
2377
|
-
|
|
2378
|
-
|
|
2377
|
+
Ao as fillDefaults,
|
|
2378
|
+
xo as getAnnotatableFragment,
|
|
2379
2379
|
Re as getQuoteContext,
|
|
2380
2380
|
It as getRangeAnnotatableContents,
|
|
2381
2381
|
W as isRevived,
|
|
@@ -2387,7 +2387,7 @@ export {
|
|
|
2387
2387
|
Te as programmaticallyFocusable,
|
|
2388
2388
|
Ne as rangeToSelector,
|
|
2389
2389
|
wt as reviveAnnotation,
|
|
2390
|
-
|
|
2390
|
+
re as reviveSelector,
|
|
2391
2391
|
yt as reviveTarget,
|
|
2392
2392
|
Ye as scrollIntoView,
|
|
2393
2393
|
qn as serializeW3CTextAnnotation,
|