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