@recogito/text-annotator 3.0.0-rc.26 → 3.0.0-rc.28
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 +1 -1
- package/dist/src/TextAnnotator.d.ts +4 -4
- package/dist/src/TextAnnotatorOptions.d.ts +3 -3
- package/dist/src/api/scrollIntoView.d.ts +1 -1
- package/dist/src/highlight/Highlight.d.ts +1 -1
- package/dist/src/highlight/HighlightPainter.d.ts +2 -2
- package/dist/src/highlight/HighlightStyle.d.ts +1 -1
- package/dist/src/highlight/baseRenderer.d.ts +5 -5
- package/dist/src/highlight/canvas/canvasRenderer.d.ts +1 -1
- package/dist/src/highlight/highlights/highlightsRenderer.d.ts +2 -2
- package/dist/src/highlight/span/spansRenderer.d.ts +1 -1
- package/dist/src/highlight/viewport.d.ts +1 -1
- package/dist/src/model/w3c/W3CTextFormatAdapter.d.ts +2 -2
- package/dist/src/presence/PresencePainter.d.ts +2 -2
- package/dist/src/state/TextAnnotationStore.d.ts +1 -1
- package/dist/src/state/TextAnnotatorState.d.ts +2 -2
- package/dist/src/state/spatialTree.d.ts +2 -2
- package/dist/text-annotator.es.js +816 -796
- 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 +6 -6
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
const
|
|
1
|
+
const P = {
|
|
2
2
|
fill: "rgb(0, 128, 255)",
|
|
3
3
|
fillOpacity: 0.18
|
|
4
|
-
},
|
|
4
|
+
}, ot = {
|
|
5
5
|
fill: "rgb(0, 128, 255)",
|
|
6
6
|
fillOpacity: 0.45
|
|
7
7
|
}, qt = (t, e, n, o, i) => {
|
|
8
8
|
var a, s;
|
|
9
|
-
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ?
|
|
9
|
+
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? ot : P) : n : (s = t.state) != null && s.selected ? ot : P;
|
|
10
10
|
return o && o.paint(t, e) || r;
|
|
11
|
-
},
|
|
11
|
+
}, Vt = "not-annotatable", X = `.${Vt}`, jt = (t) => {
|
|
12
12
|
var n;
|
|
13
13
|
const e = t.commonAncestorContainer;
|
|
14
|
-
return e instanceof HTMLElement ? !e.closest(
|
|
14
|
+
return e instanceof HTMLElement ? !e.closest(X) : !((n = e.parentElement) != null && n.closest(X));
|
|
15
15
|
}, Gt = function* (t) {
|
|
16
16
|
const e = document.createNodeIterator(
|
|
17
17
|
t.commonAncestorContainer,
|
|
18
18
|
NodeFilter.SHOW_ELEMENT,
|
|
19
|
-
(o) => o instanceof HTMLElement && o.classList.contains(
|
|
19
|
+
(o) => o instanceof HTMLElement && o.classList.contains(Vt) && !o.parentElement.closest(X) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
|
|
20
20
|
);
|
|
21
21
|
let n;
|
|
22
22
|
for (; n = e.nextNode(); )
|
|
@@ -35,23 +35,23 @@ const H = {
|
|
|
35
35
|
o.setStartAfter(n), o.collapsed || e.push(o);
|
|
36
36
|
}
|
|
37
37
|
return e.length > 0 ? e : [t];
|
|
38
|
-
},
|
|
38
|
+
}, ft = (t) => {
|
|
39
39
|
const e = t.cloneContents();
|
|
40
|
-
return e.querySelectorAll(
|
|
40
|
+
return e.querySelectorAll(X).forEach((n) => n.remove()), e;
|
|
41
41
|
}, Qt = (t) => {
|
|
42
42
|
t.addEventListener("click", (e) => {
|
|
43
43
|
// Allow clicks within not-annotatable elements
|
|
44
|
-
!e.target.closest(
|
|
44
|
+
!e.target.closest(X) && !e.target.closest("a") && e.preventDefault();
|
|
45
45
|
});
|
|
46
|
-
},
|
|
46
|
+
}, gt = (t, e = 10) => {
|
|
47
47
|
let n;
|
|
48
48
|
return (...o) => {
|
|
49
49
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
50
50
|
};
|
|
51
51
|
}, Ln = (t) => {
|
|
52
52
|
const e = t.cloneContents();
|
|
53
|
-
return e.querySelectorAll(
|
|
54
|
-
},
|
|
53
|
+
return e.querySelectorAll(X).forEach((n) => n.remove()), e;
|
|
54
|
+
}, vt = (t, e) => {
|
|
55
55
|
const n = document.createNodeIterator(e);
|
|
56
56
|
let o = 0, i = n.nextNode();
|
|
57
57
|
for (; i !== null; ) {
|
|
@@ -59,7 +59,7 @@ const H = {
|
|
|
59
59
|
return o;
|
|
60
60
|
o += 1, i = n.nextNode();
|
|
61
61
|
}
|
|
62
|
-
},
|
|
62
|
+
}, yt = (t, e) => {
|
|
63
63
|
const n = document.createNodeIterator(e);
|
|
64
64
|
let o = null;
|
|
65
65
|
for (let i = 0; i < t + 1; i++)
|
|
@@ -72,31 +72,31 @@ const H = {
|
|
|
72
72
|
startOffset: o,
|
|
73
73
|
endContainer: i,
|
|
74
74
|
endOffset: r
|
|
75
|
-
} = t, a = Array.from(e.childNodes).map((
|
|
76
|
-
const
|
|
77
|
-
return
|
|
78
|
-
}), s =
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
return t.setStart(
|
|
83
|
-
},
|
|
84
|
-
const
|
|
85
|
-
return
|
|
75
|
+
} = t, a = Array.from(e.childNodes).map((c) => {
|
|
76
|
+
const g = c.cloneNode(!0);
|
|
77
|
+
return c.nodeName === "CANVAS" ? c : g;
|
|
78
|
+
}), s = vt(n, e), u = vt(i, e), h = () => {
|
|
79
|
+
const c = e;
|
|
80
|
+
c.replaceChildren(...a);
|
|
81
|
+
const g = yt(s, c), p = yt(u, c);
|
|
82
|
+
return t.setStart(g, o), t.setEnd(p, r), t;
|
|
83
|
+
}, m = (c) => {
|
|
84
|
+
const g = document.createElement("SPAN");
|
|
85
|
+
return c.surroundContents(g), g;
|
|
86
86
|
};
|
|
87
87
|
if (n === i)
|
|
88
88
|
throw "Not implemented";
|
|
89
89
|
{
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const
|
|
90
|
+
const c = document.createRange();
|
|
91
|
+
c.selectNodeContents(n), c.setStart(n, o);
|
|
92
|
+
const g = m(c), p = document.createRange();
|
|
93
93
|
p.selectNode(i), p.setEnd(i, r);
|
|
94
|
-
const
|
|
94
|
+
const x = m(p), f = Zt(t).reverse().map((l) => {
|
|
95
95
|
var y;
|
|
96
|
-
const
|
|
97
|
-
return (y =
|
|
96
|
+
const d = document.createElement("SPAN");
|
|
97
|
+
return (y = l.parentNode) == null || y.insertBefore(d, l), d.appendChild(l), d;
|
|
98
98
|
});
|
|
99
|
-
return { unwrap:
|
|
99
|
+
return { unwrap: h, nodes: [g, ...f, x] };
|
|
100
100
|
}
|
|
101
101
|
}, Zt = (t) => {
|
|
102
102
|
const {
|
|
@@ -120,14 +120,14 @@ const H = {
|
|
|
120
120
|
}, te = (t, e, n = 10, o) => {
|
|
121
121
|
const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
|
|
122
122
|
r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
123
|
-
const a =
|
|
123
|
+
const a = ft(r).textContent, s = document.createRange();
|
|
124
124
|
s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
|
|
125
|
-
const u =
|
|
125
|
+
const u = ft(s).textContent;
|
|
126
126
|
return {
|
|
127
127
|
prefix: a.substring(a.length - n),
|
|
128
128
|
suffix: u.substring(0, n)
|
|
129
129
|
};
|
|
130
|
-
},
|
|
130
|
+
}, $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ee = (t, e) => {
|
|
131
131
|
const n = (r) => Math.round(r * 10) / 10, o = {
|
|
132
132
|
top: n(t.top),
|
|
133
133
|
bottom: n(t.bottom),
|
|
@@ -178,50 +178,50 @@ const H = {
|
|
|
178
178
|
}, []), ie = (t, e, n) => {
|
|
179
179
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
180
180
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
181
|
-
const r =
|
|
181
|
+
const r = ft(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;
|
|
182
182
|
return n ? { quote: a, start: s, end: u, range: t, offsetReference: i } : { quote: a, start: s, end: u, range: t };
|
|
183
|
-
},
|
|
184
|
-
var
|
|
183
|
+
}, _t = (t, e) => {
|
|
184
|
+
var m, c;
|
|
185
185
|
const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
|
|
186
186
|
e,
|
|
187
187
|
NodeFilter.SHOW_TEXT,
|
|
188
|
-
(
|
|
188
|
+
(g) => {
|
|
189
189
|
var p;
|
|
190
|
-
return (p =
|
|
190
|
+
return (p = g.parentElement) != null && p.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
191
191
|
}
|
|
192
192
|
);
|
|
193
193
|
let a = 0;
|
|
194
194
|
const s = document.createRange();
|
|
195
195
|
let u = r.nextNode();
|
|
196
196
|
u === null && console.error("Could not revive annotation target. Content missing.");
|
|
197
|
-
let
|
|
197
|
+
let h = !i;
|
|
198
198
|
for (; u !== null; ) {
|
|
199
|
-
if (
|
|
200
|
-
const
|
|
201
|
-
if (a +
|
|
199
|
+
if (h || (h = i == null ? void 0 : i.contains(u)), h) {
|
|
200
|
+
const g = ((m = u.textContent) == null ? void 0 : m.length) || 0;
|
|
201
|
+
if (a + g > n) {
|
|
202
202
|
s.setStart(u, n - a);
|
|
203
203
|
break;
|
|
204
204
|
}
|
|
205
|
-
a +=
|
|
205
|
+
a += g;
|
|
206
206
|
}
|
|
207
207
|
u = r.nextNode();
|
|
208
208
|
}
|
|
209
209
|
for (; u !== null; ) {
|
|
210
|
-
const
|
|
211
|
-
if (a +
|
|
210
|
+
const g = ((c = u.textContent) == null ? void 0 : c.length) || 0;
|
|
211
|
+
if (a + g >= o) {
|
|
212
212
|
s.setEnd(u, o - a);
|
|
213
213
|
break;
|
|
214
214
|
}
|
|
215
|
-
a +=
|
|
215
|
+
a += g, u = r.nextNode();
|
|
216
216
|
}
|
|
217
217
|
return {
|
|
218
218
|
...t,
|
|
219
219
|
range: s
|
|
220
220
|
};
|
|
221
|
-
},
|
|
221
|
+
}, it = (t, e) => $(t.selector) ? t : {
|
|
222
222
|
...t,
|
|
223
|
-
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n :
|
|
224
|
-
},
|
|
223
|
+
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : _t(n, e))
|
|
224
|
+
}, rt = (t, e) => $(t.target.selector) ? t : { ...t, target: it(t.target, e) }, re = (t) => {
|
|
225
225
|
var i;
|
|
226
226
|
const { startContainer: e, endContainer: n } = t;
|
|
227
227
|
if (e.nodeType === Node.TEXT_NODE && n.nodeType === Node.TEXT_NODE)
|
|
@@ -244,90 +244,90 @@ const H = {
|
|
|
244
244
|
const i = o.map((r) => r.id);
|
|
245
245
|
(e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
|
|
246
246
|
};
|
|
247
|
-
},
|
|
247
|
+
}, mt = (t, e, n, o) => {
|
|
248
248
|
const { store: i, selection: r, hover: a } = e;
|
|
249
|
-
let s, u,
|
|
250
|
-
const
|
|
251
|
-
const { x:
|
|
252
|
-
|
|
249
|
+
let s, u, h;
|
|
250
|
+
const m = ae(n), c = (R) => {
|
|
251
|
+
const { x: M, y: v } = t.getBoundingClientRect(), w = i.getAt(R.clientX - M, R.clientY - v);
|
|
252
|
+
w && (!u || u(w)) ? a.current !== w.id && (t.classList.add("hovered"), a.set(w.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
253
253
|
};
|
|
254
|
-
t.addEventListener("pointermove",
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
const Ft =
|
|
259
|
-
return { annotation:
|
|
254
|
+
t.addEventListener("pointermove", c);
|
|
255
|
+
const g = (R = !1) => {
|
|
256
|
+
h && h.clear();
|
|
257
|
+
const M = se(t), { minX: v, minY: w, maxX: A, maxY: C } = M, L = u ? i.getIntersecting(v, w, A, C).filter(({ annotation: k }) => u(k)) : i.getIntersecting(v, w, A, C), O = r.selected.map(({ id: k }) => k), H = L.map(({ annotation: k, rects: zt }) => {
|
|
258
|
+
const Ft = O.includes(k.id), Wt = k.id === a.current;
|
|
259
|
+
return { annotation: k, rects: zt, state: { selected: Ft, hover: Wt } };
|
|
260
260
|
});
|
|
261
|
-
o.redraw(
|
|
262
|
-
}, p = (
|
|
263
|
-
|
|
264
|
-
},
|
|
265
|
-
s =
|
|
266
|
-
},
|
|
267
|
-
u =
|
|
268
|
-
},
|
|
269
|
-
i.observe(
|
|
270
|
-
const
|
|
271
|
-
document.addEventListener("scroll",
|
|
272
|
-
const y =
|
|
273
|
-
i.recalculatePositions(),
|
|
261
|
+
o.redraw(H, M, s, h, R), setTimeout(() => m(L.map(({ annotation: k }) => k)), 1);
|
|
262
|
+
}, p = (R) => {
|
|
263
|
+
h = R, g();
|
|
264
|
+
}, x = (R) => {
|
|
265
|
+
s = R, g();
|
|
266
|
+
}, b = (R) => {
|
|
267
|
+
u = R, g(!1);
|
|
268
|
+
}, f = () => g();
|
|
269
|
+
i.observe(f);
|
|
270
|
+
const l = r.subscribe(() => g()), d = () => g(!0);
|
|
271
|
+
document.addEventListener("scroll", d, { capture: !0, passive: !0 });
|
|
272
|
+
const y = gt(() => {
|
|
273
|
+
i.recalculatePositions(), h && h.reset(), g();
|
|
274
274
|
});
|
|
275
275
|
window.addEventListener("resize", y);
|
|
276
276
|
const T = new ResizeObserver(y);
|
|
277
277
|
T.observe(t);
|
|
278
|
-
const
|
|
279
|
-
|
|
278
|
+
const S = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((R) => {
|
|
279
|
+
R.every((v) => v.target === t || t.contains(v.target)) || g(!0);
|
|
280
280
|
});
|
|
281
|
-
return E.observe(document.body,
|
|
281
|
+
return E.observe(document.body, S), {
|
|
282
282
|
destroy: () => {
|
|
283
|
-
t.removeEventListener("pointermove",
|
|
283
|
+
t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(f), l(), document.removeEventListener("scroll", d), window.removeEventListener("resize", y), T.disconnect(), E.disconnect();
|
|
284
284
|
},
|
|
285
|
-
redraw:
|
|
286
|
-
setStyle:
|
|
287
|
-
setFilter:
|
|
285
|
+
redraw: g,
|
|
286
|
+
setStyle: x,
|
|
287
|
+
setFilter: b,
|
|
288
288
|
setPainter: p,
|
|
289
289
|
setVisible: o.setVisible
|
|
290
290
|
};
|
|
291
|
-
},
|
|
291
|
+
}, ce = () => {
|
|
292
292
|
const t = document.createElement("canvas");
|
|
293
293
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
|
|
294
|
-
},
|
|
294
|
+
}, le = (t, e) => {
|
|
295
295
|
t.width = window.innerWidth, t.height = window.innerHeight;
|
|
296
296
|
}, de = (t) => {
|
|
297
297
|
t.classList.add("r6o-annotatable");
|
|
298
|
-
const e =
|
|
298
|
+
const e = ce(), n = e.getContext("2d");
|
|
299
299
|
t.insertBefore(e, t.firstChild);
|
|
300
|
-
const o = (s, u,
|
|
301
|
-
const { width:
|
|
302
|
-
n.clearRect(-0.5, -0.5,
|
|
303
|
-
const { top: p, left:
|
|
304
|
-
s.forEach((
|
|
300
|
+
const o = (s, u, h, m) => requestAnimationFrame(() => {
|
|
301
|
+
const { width: c, height: g } = e;
|
|
302
|
+
n.clearRect(-0.5, -0.5, c + 1, g + 1), m && m.clear();
|
|
303
|
+
const { top: p, left: x } = u;
|
|
304
|
+
s.forEach((b) => {
|
|
305
305
|
var T;
|
|
306
|
-
const
|
|
307
|
-
x:
|
|
306
|
+
const f = h ? typeof h == "function" ? h(b.annotation, b.state) : h : (T = b.state) != null && T.selected ? ot : P, l = m && m.paint(b, u) || f, d = b.rects.map(({ x: S, y: E, width: N, height: R }) => ({
|
|
307
|
+
x: S + x,
|
|
308
308
|
y: E + p,
|
|
309
|
-
width:
|
|
310
|
-
height:
|
|
309
|
+
width: N,
|
|
310
|
+
height: R
|
|
311
311
|
}));
|
|
312
|
-
n.fillStyle =
|
|
312
|
+
n.fillStyle = l.fill, n.globalAlpha = l.fillOpacity || 1;
|
|
313
313
|
const y = 5;
|
|
314
|
-
if (
|
|
315
|
-
({ x:
|
|
316
|
-
|
|
314
|
+
if (d.forEach(
|
|
315
|
+
({ x: S, y: E, width: N, height: R }) => n.fillRect(
|
|
316
|
+
S,
|
|
317
317
|
E - y / 2,
|
|
318
|
-
|
|
319
|
-
|
|
318
|
+
N,
|
|
319
|
+
R + y
|
|
320
320
|
)
|
|
321
|
-
),
|
|
322
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
323
|
-
const
|
|
324
|
-
|
|
325
|
-
n.beginPath(), n.moveTo(E,
|
|
321
|
+
), l.underlineColor) {
|
|
322
|
+
n.globalAlpha = 1, n.strokeStyle = l.underlineColor, n.lineWidth = l.underlineThickness ?? 1;
|
|
323
|
+
const S = y / 2 + (l.underlineOffset ?? 0);
|
|
324
|
+
d.forEach(({ x: E, y: N, width: R, height: M }) => {
|
|
325
|
+
n.beginPath(), n.moveTo(E, N + M + S), n.lineTo(E + R, N + M + S), n.stroke();
|
|
326
326
|
});
|
|
327
327
|
}
|
|
328
328
|
});
|
|
329
|
-
}), i =
|
|
330
|
-
|
|
329
|
+
}), i = gt(() => {
|
|
330
|
+
le(e);
|
|
331
331
|
});
|
|
332
332
|
return window.addEventListener("resize", i), {
|
|
333
333
|
destroy: () => {
|
|
@@ -338,70 +338,70 @@ const H = {
|
|
|
338
338
|
},
|
|
339
339
|
redraw: o
|
|
340
340
|
};
|
|
341
|
-
}, ue = (t, e, n) =>
|
|
342
|
-
var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) },
|
|
341
|
+
}, ue = (t, e, n) => mt(t, e, n, de(t));
|
|
342
|
+
var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, Y = function(t) {
|
|
343
343
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
344
|
-
},
|
|
344
|
+
}, I = function(t, e, n) {
|
|
345
345
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
346
346
|
}, U = function(t, e, n) {
|
|
347
347
|
return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
|
|
348
348
|
}, Ut = function(t) {
|
|
349
349
|
return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
|
|
350
|
-
},
|
|
350
|
+
}, wt = function(t) {
|
|
351
351
|
return { r: U(t.r, 0, 255), g: U(t.g, 0, 255), b: U(t.b, 0, 255), a: U(t.a) };
|
|
352
|
-
},
|
|
353
|
-
return { r:
|
|
354
|
-
}, fe = /^#([0-9a-f]{3,8})$/i,
|
|
352
|
+
}, st = function(t) {
|
|
353
|
+
return { r: I(t.r), g: I(t.g), b: I(t.b), a: I(t.a, 3) };
|
|
354
|
+
}, fe = /^#([0-9a-f]{3,8})$/i, J = function(t) {
|
|
355
355
|
var e = t.toString(16);
|
|
356
356
|
return e.length < 2 ? "0" + e : e;
|
|
357
|
-
},
|
|
357
|
+
}, Dt = function(t) {
|
|
358
358
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), a = r - Math.min(e, n, o), s = a ? r === e ? (n - o) / a : r === n ? 2 + (o - e) / a : 4 + (e - n) / a : 0;
|
|
359
359
|
return { h: 60 * (s < 0 ? s + 6 : s), s: r ? a / r * 100 : 0, v: r / 255 * 100, a: i };
|
|
360
|
-
},
|
|
360
|
+
}, Xt = function(t) {
|
|
361
361
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
362
362
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
363
|
-
var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n),
|
|
364
|
-
return { r: 255 * [o, s, a, a, u, o][
|
|
365
|
-
}, yt = function(t) {
|
|
366
|
-
return { h: Ut(t.h), s: U(t.s, 0, 100), l: U(t.l, 0, 100), a: U(t.a) };
|
|
367
|
-
}, wt = function(t) {
|
|
368
|
-
return { h: O(t.h), s: O(t.s), l: O(t.l), a: O(t.a, 3) };
|
|
363
|
+
var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), h = r % 6;
|
|
364
|
+
return { r: 255 * [o, s, a, a, u, o][h], g: 255 * [u, o, o, s, a, a][h], b: 255 * [a, a, u, o, o, s][h], a: i };
|
|
369
365
|
}, xt = function(t) {
|
|
370
|
-
return
|
|
366
|
+
return { h: Ut(t.h), s: U(t.s, 0, 100), l: U(t.l, 0, 100), a: U(t.a) };
|
|
367
|
+
}, At = function(t) {
|
|
368
|
+
return { h: I(t.h), s: I(t.s), l: I(t.l), a: I(t.a, 3) };
|
|
369
|
+
}, Et = function(t) {
|
|
370
|
+
return Xt((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 }));
|
|
371
371
|
var e, n, o;
|
|
372
|
-
},
|
|
373
|
-
return { h: (e =
|
|
372
|
+
}, Q = function(t) {
|
|
373
|
+
return { h: (e = Dt(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 };
|
|
374
374
|
var e, n, o, i;
|
|
375
|
-
}, pe = /^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, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, be = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,
|
|
375
|
+
}, pe = /^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, me = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, be = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, St = { string: [[function(t) {
|
|
376
376
|
var e = fe.exec(t);
|
|
377
|
-
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 ?
|
|
377
|
+
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 ? I(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 ? I(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
378
378
|
}, "hex"], [function(t) {
|
|
379
379
|
var e = me.exec(t) || be.exec(t);
|
|
380
|
-
return e ? e[2] !== e[4] || e[4] !== e[6] ? null :
|
|
380
|
+
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : wt({ 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;
|
|
381
381
|
}, "rgb"], [function(t) {
|
|
382
382
|
var e = pe.exec(t) || ge.exec(t);
|
|
383
383
|
if (!e)
|
|
384
384
|
return null;
|
|
385
|
-
var n, o, i =
|
|
386
|
-
return
|
|
385
|
+
var n, o, i = xt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (he[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
|
|
386
|
+
return Et(i);
|
|
387
387
|
}, "hsl"]], object: [[function(t) {
|
|
388
388
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
|
|
389
|
-
return
|
|
389
|
+
return Y(e) && Y(n) && Y(o) ? wt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
|
|
390
390
|
}, "rgb"], [function(t) {
|
|
391
391
|
var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
|
|
392
|
-
if (!
|
|
392
|
+
if (!Y(e) || !Y(n) || !Y(o))
|
|
393
393
|
return null;
|
|
394
|
-
var a =
|
|
395
|
-
return
|
|
394
|
+
var a = xt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
|
|
395
|
+
return Et(a);
|
|
396
396
|
}, "hsl"], [function(t) {
|
|
397
397
|
var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
|
|
398
|
-
if (!
|
|
398
|
+
if (!Y(e) || !Y(n) || !Y(o))
|
|
399
399
|
return null;
|
|
400
400
|
var a = function(s) {
|
|
401
401
|
return { h: Ut(s.h), s: U(s.s, 0, 100), v: U(s.v, 0, 100), a: U(s.a) };
|
|
402
402
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
|
|
403
|
-
return
|
|
404
|
-
}, "hsv"]] },
|
|
403
|
+
return Xt(a);
|
|
404
|
+
}, "hsv"]] }, Ct = function(t, e) {
|
|
405
405
|
for (var n = 0; n < e.length; n++) {
|
|
406
406
|
var o = e[n][0](t);
|
|
407
407
|
if (o)
|
|
@@ -409,72 +409,72 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
|
|
|
409
409
|
}
|
|
410
410
|
return [null, void 0];
|
|
411
411
|
}, ve = function(t) {
|
|
412
|
-
return typeof t == "string" ?
|
|
413
|
-
},
|
|
414
|
-
var n =
|
|
412
|
+
return typeof t == "string" ? Ct(t.trim(), St.string) : typeof t == "object" && t !== null ? Ct(t, St.object) : [null, void 0];
|
|
413
|
+
}, at = function(t, e) {
|
|
414
|
+
var n = Q(t);
|
|
415
415
|
return { h: n.h, s: U(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
|
|
416
|
-
},
|
|
416
|
+
}, ct = function(t) {
|
|
417
417
|
return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
|
|
418
|
-
},
|
|
419
|
-
var n =
|
|
418
|
+
}, Tt = function(t, e) {
|
|
419
|
+
var n = Q(t);
|
|
420
420
|
return { h: n.h, s: n.s, l: U(n.l + 100 * e, 0, 100), a: n.a };
|
|
421
|
-
},
|
|
421
|
+
}, Nt = function() {
|
|
422
422
|
function t(e) {
|
|
423
423
|
this.parsed = ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
424
424
|
}
|
|
425
425
|
return t.prototype.isValid = function() {
|
|
426
426
|
return this.parsed !== null;
|
|
427
427
|
}, t.prototype.brightness = function() {
|
|
428
|
-
return
|
|
428
|
+
return I(ct(this.rgba), 2);
|
|
429
429
|
}, t.prototype.isDark = function() {
|
|
430
|
-
return
|
|
430
|
+
return ct(this.rgba) < 0.5;
|
|
431
431
|
}, t.prototype.isLight = function() {
|
|
432
|
-
return
|
|
432
|
+
return ct(this.rgba) >= 0.5;
|
|
433
433
|
}, t.prototype.toHex = function() {
|
|
434
|
-
return e =
|
|
434
|
+
return e = st(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? J(I(255 * r)) : "", "#" + J(n) + J(o) + J(i) + a;
|
|
435
435
|
var e, n, o, i, r, a;
|
|
436
436
|
}, t.prototype.toRgb = function() {
|
|
437
|
-
return
|
|
437
|
+
return st(this.rgba);
|
|
438
438
|
}, t.prototype.toRgbString = function() {
|
|
439
|
-
return e =
|
|
439
|
+
return e = st(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
|
|
440
440
|
var e, n, o, i, r;
|
|
441
441
|
}, t.prototype.toHsl = function() {
|
|
442
|
-
return
|
|
442
|
+
return At(Q(this.rgba));
|
|
443
443
|
}, t.prototype.toHslString = function() {
|
|
444
|
-
return e =
|
|
444
|
+
return e = At(Q(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
|
|
445
445
|
var e, n, o, i, r;
|
|
446
446
|
}, t.prototype.toHsv = function() {
|
|
447
|
-
return e =
|
|
447
|
+
return e = Dt(this.rgba), { h: I(e.h), s: I(e.s), v: I(e.v), a: I(e.a, 3) };
|
|
448
448
|
var e;
|
|
449
449
|
}, t.prototype.invert = function() {
|
|
450
|
-
return
|
|
450
|
+
return D({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
|
|
451
451
|
var e;
|
|
452
452
|
}, t.prototype.saturate = function(e) {
|
|
453
|
-
return e === void 0 && (e = 0.1),
|
|
453
|
+
return e === void 0 && (e = 0.1), D(at(this.rgba, e));
|
|
454
454
|
}, t.prototype.desaturate = function(e) {
|
|
455
|
-
return e === void 0 && (e = 0.1),
|
|
455
|
+
return e === void 0 && (e = 0.1), D(at(this.rgba, -e));
|
|
456
456
|
}, t.prototype.grayscale = function() {
|
|
457
|
-
return
|
|
457
|
+
return D(at(this.rgba, -1));
|
|
458
458
|
}, t.prototype.lighten = function(e) {
|
|
459
|
-
return e === void 0 && (e = 0.1),
|
|
459
|
+
return e === void 0 && (e = 0.1), D(Tt(this.rgba, e));
|
|
460
460
|
}, t.prototype.darken = function(e) {
|
|
461
|
-
return e === void 0 && (e = 0.1),
|
|
461
|
+
return e === void 0 && (e = 0.1), D(Tt(this.rgba, -e));
|
|
462
462
|
}, t.prototype.rotate = function(e) {
|
|
463
463
|
return e === void 0 && (e = 15), this.hue(this.hue() + e);
|
|
464
464
|
}, t.prototype.alpha = function(e) {
|
|
465
|
-
return typeof e == "number" ?
|
|
465
|
+
return typeof e == "number" ? D({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : I(this.rgba.a, 3);
|
|
466
466
|
var n;
|
|
467
467
|
}, t.prototype.hue = function(e) {
|
|
468
|
-
var n =
|
|
469
|
-
return typeof e == "number" ?
|
|
468
|
+
var n = Q(this.rgba);
|
|
469
|
+
return typeof e == "number" ? D({ h: e, s: n.s, l: n.l, a: n.a }) : I(n.h);
|
|
470
470
|
}, t.prototype.isEqual = function(e) {
|
|
471
|
-
return this.toHex() ===
|
|
471
|
+
return this.toHex() === D(e).toHex();
|
|
472
472
|
}, t;
|
|
473
|
-
}(),
|
|
474
|
-
return t instanceof
|
|
473
|
+
}(), D = function(t) {
|
|
474
|
+
return t instanceof Nt ? t : new Nt(t);
|
|
475
475
|
};
|
|
476
476
|
const ye = (t) => [
|
|
477
|
-
`background-color:${
|
|
477
|
+
`background-color:${D((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
|
|
478
478
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
479
479
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
480
480
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
@@ -492,23 +492,23 @@ const ye = (t) => [
|
|
|
492
492
|
},
|
|
493
493
|
redraw: (r, a, s, u) => {
|
|
494
494
|
u && u.clear();
|
|
495
|
-
const
|
|
496
|
-
Array.from(e).filter((
|
|
497
|
-
const
|
|
498
|
-
var
|
|
499
|
-
const
|
|
500
|
-
return `::highlight(_${
|
|
495
|
+
const h = new Set(r.map((c) => c.annotation.id));
|
|
496
|
+
Array.from(e).filter((c) => !h.has(c));
|
|
497
|
+
const m = r.map((c) => {
|
|
498
|
+
var x;
|
|
499
|
+
const g = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? ot : P, p = u && u.paint(c, a) || g;
|
|
500
|
+
return `::highlight(_${c.annotation.id}) { ${ye(p)} }`;
|
|
501
501
|
});
|
|
502
|
-
t.innerHTML =
|
|
503
|
-
`), CSS.highlights.clear(), r.forEach(({ annotation:
|
|
504
|
-
const
|
|
505
|
-
CSS.highlights.set(`_${
|
|
506
|
-
}), e =
|
|
502
|
+
t.innerHTML = m.join(`
|
|
503
|
+
`), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
|
|
504
|
+
const g = c.target.selector.map((x) => x.range), p = new Highlight(...g);
|
|
505
|
+
CSS.highlights.set(`_${c.id}`, p);
|
|
506
|
+
}), e = h;
|
|
507
507
|
}
|
|
508
508
|
};
|
|
509
|
-
}, xe = (t, e, n) =>
|
|
510
|
-
var
|
|
511
|
-
function
|
|
509
|
+
}, xe = (t, e, n) => mt(t, e, n, we());
|
|
510
|
+
var Rt = Object.prototype.hasOwnProperty;
|
|
511
|
+
function pt(t, e) {
|
|
512
512
|
var n, o;
|
|
513
513
|
if (t === e)
|
|
514
514
|
return !0;
|
|
@@ -519,14 +519,14 @@ function ht(t, e) {
|
|
|
519
519
|
return t.toString() === e.toString();
|
|
520
520
|
if (n === Array) {
|
|
521
521
|
if ((o = t.length) === e.length)
|
|
522
|
-
for (; o-- &&
|
|
522
|
+
for (; o-- && pt(t[o], e[o]); )
|
|
523
523
|
;
|
|
524
524
|
return o === -1;
|
|
525
525
|
}
|
|
526
526
|
if (!n || typeof t == "object") {
|
|
527
527
|
o = 0;
|
|
528
528
|
for (n in t)
|
|
529
|
-
if (
|
|
529
|
+
if (Rt.call(t, n) && ++o && !Rt.call(e, n) || !(n in e) || !pt(t[n], e[n]))
|
|
530
530
|
return !1;
|
|
531
531
|
return Object.keys(e).length === o;
|
|
532
532
|
}
|
|
@@ -545,51 +545,54 @@ const Ae = (t, e) => {
|
|
|
545
545
|
destroy: () => {
|
|
546
546
|
e.remove();
|
|
547
547
|
},
|
|
548
|
-
redraw: (a, s, u,
|
|
549
|
-
|
|
548
|
+
redraw: (a, s, u, h, m) => {
|
|
549
|
+
const g = !(pt(n, a) && m);
|
|
550
|
+
if (!h)
|
|
550
551
|
return;
|
|
551
|
-
e.innerHTML = "";
|
|
552
|
-
const
|
|
553
|
-
a.forEach((
|
|
554
|
-
|
|
555
|
-
const
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
552
|
+
g && (e.innerHTML = "");
|
|
553
|
+
const p = a.reduce((x, { rects: b }) => [...x, ...b], []);
|
|
554
|
+
a.forEach((x) => {
|
|
555
|
+
x.rects.map((b) => {
|
|
556
|
+
const f = Ae(b, p), l = qt(x, s, u, h, f);
|
|
557
|
+
if (g) {
|
|
558
|
+
const d = document.createElement("span");
|
|
559
|
+
d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`;
|
|
560
|
+
const y = D((l == null ? void 0 : l.fill) || P.fill).alpha((l == null ? void 0 : l.fillOpacity) === void 0 ? P.fillOpacity : l.fillOpacity).toHex();
|
|
561
|
+
d.style.backgroundColor = y, l.underlineStyle && (d.style.borderStyle = l.underlineStyle), l.underlineColor && (d.style.borderColor = l.underlineColor), l.underlineThickness && (d.style.borderBottomWidth = `${l.underlineThickness}px`), l.underlineOffset && (d.style.paddingBottom = `${l.underlineOffset}px`), e.appendChild(d);
|
|
562
|
+
}
|
|
559
563
|
});
|
|
560
|
-
return { id: p.annotation.id, spans: w };
|
|
561
564
|
}), n = a;
|
|
562
565
|
},
|
|
563
566
|
setVisible: (a) => {
|
|
564
567
|
a ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
565
568
|
}
|
|
566
569
|
};
|
|
567
|
-
}, Se = (t, e, n) =>
|
|
568
|
-
let
|
|
570
|
+
}, Se = (t, e, n) => mt(t, e, n, Ee(t));
|
|
571
|
+
let Z;
|
|
569
572
|
const Ce = new Uint8Array(16);
|
|
570
573
|
function Te() {
|
|
571
|
-
if (!
|
|
574
|
+
if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
|
|
572
575
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
573
|
-
return
|
|
576
|
+
return Z(Ce);
|
|
574
577
|
}
|
|
575
|
-
const
|
|
578
|
+
const V = [];
|
|
576
579
|
for (let t = 0; t < 256; ++t)
|
|
577
|
-
|
|
578
|
-
function
|
|
579
|
-
return
|
|
580
|
+
V.push((t + 256).toString(16).slice(1));
|
|
581
|
+
function Ne(t, e = 0) {
|
|
582
|
+
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]];
|
|
580
583
|
}
|
|
581
|
-
const
|
|
582
|
-
randomUUID:
|
|
584
|
+
const Re = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Lt = {
|
|
585
|
+
randomUUID: Re
|
|
583
586
|
};
|
|
584
|
-
function
|
|
585
|
-
if (
|
|
586
|
-
return
|
|
587
|
+
function kt(t, e, n) {
|
|
588
|
+
if (Lt.randomUUID && !e && !t)
|
|
589
|
+
return Lt.randomUUID();
|
|
587
590
|
t = t || {};
|
|
588
591
|
const o = t.random || (t.rng || Te)();
|
|
589
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
592
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ne(o);
|
|
590
593
|
}
|
|
591
|
-
var
|
|
592
|
-
function
|
|
594
|
+
var Bt = Object.prototype.hasOwnProperty;
|
|
595
|
+
function q(t, e) {
|
|
593
596
|
var n, o;
|
|
594
597
|
if (t === e)
|
|
595
598
|
return !0;
|
|
@@ -600,54 +603,54 @@ function F(t, e) {
|
|
|
600
603
|
return t.toString() === e.toString();
|
|
601
604
|
if (n === Array) {
|
|
602
605
|
if ((o = t.length) === e.length)
|
|
603
|
-
for (; o-- &&
|
|
606
|
+
for (; o-- && q(t[o], e[o]); )
|
|
604
607
|
;
|
|
605
608
|
return o === -1;
|
|
606
609
|
}
|
|
607
610
|
if (!n || typeof t == "object") {
|
|
608
611
|
o = 0;
|
|
609
612
|
for (n in t)
|
|
610
|
-
if (
|
|
613
|
+
if (Bt.call(t, n) && ++o && !Bt.call(e, n) || !(n in e) || !q(t[n], e[n]))
|
|
611
614
|
return !1;
|
|
612
615
|
return Object.keys(e).length === o;
|
|
613
616
|
}
|
|
614
617
|
}
|
|
615
618
|
return t !== t && e !== e;
|
|
616
619
|
}
|
|
617
|
-
function
|
|
620
|
+
function lt() {
|
|
618
621
|
}
|
|
619
622
|
function Le(t, e) {
|
|
620
623
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
621
624
|
}
|
|
622
|
-
const
|
|
623
|
-
function
|
|
625
|
+
const z = [];
|
|
626
|
+
function bt(t, e = lt) {
|
|
624
627
|
let n;
|
|
625
628
|
const o = /* @__PURE__ */ new Set();
|
|
626
629
|
function i(s) {
|
|
627
630
|
if (Le(t, s) && (t = s, n)) {
|
|
628
|
-
const u =
|
|
629
|
-
for (const
|
|
630
|
-
|
|
631
|
+
const u = !z.length;
|
|
632
|
+
for (const h of o)
|
|
633
|
+
h[1](), z.push(h, t);
|
|
631
634
|
if (u) {
|
|
632
|
-
for (let
|
|
633
|
-
|
|
634
|
-
|
|
635
|
+
for (let h = 0; h < z.length; h += 2)
|
|
636
|
+
z[h][0](z[h + 1]);
|
|
637
|
+
z.length = 0;
|
|
635
638
|
}
|
|
636
639
|
}
|
|
637
640
|
}
|
|
638
641
|
function r(s) {
|
|
639
642
|
i(s(t));
|
|
640
643
|
}
|
|
641
|
-
function a(s, u =
|
|
642
|
-
const
|
|
643
|
-
return o.add(
|
|
644
|
-
o.delete(
|
|
644
|
+
function a(s, u = lt) {
|
|
645
|
+
const h = [s, u];
|
|
646
|
+
return o.add(h), o.size === 1 && (n = e(i, r) || lt), s(t), () => {
|
|
647
|
+
o.delete(h), o.size === 0 && n && (n(), n = null);
|
|
645
648
|
};
|
|
646
649
|
}
|
|
647
650
|
return { set: i, update: r, subscribe: a };
|
|
648
651
|
}
|
|
649
652
|
const Be = (t) => {
|
|
650
|
-
const { subscribe: e, set: n } =
|
|
653
|
+
const { subscribe: e, set: n } = bt();
|
|
651
654
|
let o;
|
|
652
655
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
653
656
|
if (o) {
|
|
@@ -664,35 +667,35 @@ const Be = (t) => {
|
|
|
664
667
|
};
|
|
665
668
|
};
|
|
666
669
|
var Oe = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Oe || {});
|
|
667
|
-
const
|
|
668
|
-
const { subscribe: n, set: o } =
|
|
669
|
-
let i =
|
|
670
|
-
n((
|
|
671
|
-
const r = () => o(
|
|
672
|
-
var
|
|
673
|
-
return ((
|
|
674
|
-
}, s = (
|
|
670
|
+
const dt = { selected: [] }, Ie = (t, e = "EDIT") => {
|
|
671
|
+
const { subscribe: n, set: o } = bt(dt);
|
|
672
|
+
let i = dt;
|
|
673
|
+
n((c) => i = c);
|
|
674
|
+
const r = () => o(dt), a = () => {
|
|
675
|
+
var c;
|
|
676
|
+
return ((c = i.selected) == null ? void 0 : c.length) === 0;
|
|
677
|
+
}, s = (c) => {
|
|
675
678
|
if (i.selected.length === 0)
|
|
676
679
|
return !1;
|
|
677
|
-
const
|
|
678
|
-
return i.selected.some((p) => p.id ===
|
|
679
|
-
}, u = (
|
|
680
|
-
const p = t.getAnnotation(
|
|
680
|
+
const g = typeof c == "string" ? c : c.id;
|
|
681
|
+
return i.selected.some((p) => p.id === g);
|
|
682
|
+
}, u = (c, g) => {
|
|
683
|
+
const p = t.getAnnotation(c);
|
|
681
684
|
if (p) {
|
|
682
|
-
const
|
|
683
|
-
o(
|
|
685
|
+
const x = Me(p, e);
|
|
686
|
+
o(x === "EDIT" ? { selected: [{ id: c, editable: !0 }], pointerEvent: g } : x === "SELECT" ? { selected: [{ id: c }], pointerEvent: g } : { selected: [], pointerEvent: g });
|
|
684
687
|
} else
|
|
685
|
-
console.warn("Invalid selection: " +
|
|
686
|
-
},
|
|
687
|
-
const p = Array.isArray(
|
|
688
|
-
o({ selected:
|
|
689
|
-
},
|
|
688
|
+
console.warn("Invalid selection: " + c);
|
|
689
|
+
}, h = (c, g = !0) => {
|
|
690
|
+
const p = Array.isArray(c) ? c : [c], x = p.map((b) => t.getAnnotation(b)).filter(Boolean);
|
|
691
|
+
o({ selected: x.map(({ id: b }) => ({ id: b, editable: g })) }), x.length !== p.length && console.warn("Invalid selection", c);
|
|
692
|
+
}, m = (c) => {
|
|
690
693
|
if (i.selected.length === 0)
|
|
691
694
|
return !1;
|
|
692
|
-
const { selected:
|
|
693
|
-
|
|
695
|
+
const { selected: g } = i;
|
|
696
|
+
g.filter(({ id: p }) => c.includes(p)).length > 0 && o({ selected: g.filter(({ id: p }) => !c.includes(p)) });
|
|
694
697
|
};
|
|
695
|
-
return t.observe(({ changes:
|
|
698
|
+
return t.observe(({ changes: c }) => m((c.deleted || []).map((g) => g.id))), {
|
|
696
699
|
clear: r,
|
|
697
700
|
clickSelect: u,
|
|
698
701
|
get selected() {
|
|
@@ -703,35 +706,35 @@ const lt = { selected: [] }, Ie = (t, e = "EDIT") => {
|
|
|
703
706
|
},
|
|
704
707
|
isEmpty: a,
|
|
705
708
|
isSelected: s,
|
|
706
|
-
setSelected:
|
|
709
|
+
setSelected: h,
|
|
707
710
|
subscribe: n
|
|
708
711
|
};
|
|
709
712
|
}, Me = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT";
|
|
710
|
-
let
|
|
711
|
-
const
|
|
712
|
-
function
|
|
713
|
-
if (!
|
|
713
|
+
let tt;
|
|
714
|
+
const Ve = new Uint8Array(16);
|
|
715
|
+
function _e() {
|
|
716
|
+
if (!tt && (tt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !tt))
|
|
714
717
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
715
|
-
return
|
|
718
|
+
return tt(Ve);
|
|
716
719
|
}
|
|
717
|
-
const
|
|
720
|
+
const _ = [];
|
|
718
721
|
for (let t = 0; t < 256; ++t)
|
|
719
|
-
|
|
720
|
-
function
|
|
721
|
-
return
|
|
722
|
+
_.push((t + 256).toString(16).slice(1));
|
|
723
|
+
function Ue(t, e = 0) {
|
|
724
|
+
return _[t[e + 0]] + _[t[e + 1]] + _[t[e + 2]] + _[t[e + 3]] + "-" + _[t[e + 4]] + _[t[e + 5]] + "-" + _[t[e + 6]] + _[t[e + 7]] + "-" + _[t[e + 8]] + _[t[e + 9]] + "-" + _[t[e + 10]] + _[t[e + 11]] + _[t[e + 12]] + _[t[e + 13]] + _[t[e + 14]] + _[t[e + 15]];
|
|
722
725
|
}
|
|
723
|
-
const
|
|
724
|
-
randomUUID:
|
|
726
|
+
const De = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ot = {
|
|
727
|
+
randomUUID: De
|
|
725
728
|
};
|
|
726
|
-
function
|
|
727
|
-
if (
|
|
728
|
-
return
|
|
729
|
+
function Xe(t, e, n) {
|
|
730
|
+
if (Ot.randomUUID && !e && !t)
|
|
731
|
+
return Ot.randomUUID();
|
|
729
732
|
t = t || {};
|
|
730
|
-
const o = t.random || (t.rng ||
|
|
731
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
733
|
+
const o = t.random || (t.rng || _e)();
|
|
734
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ue(o);
|
|
732
735
|
}
|
|
733
736
|
const On = (t, e, n, o) => ({
|
|
734
|
-
id:
|
|
737
|
+
id: Xe(),
|
|
735
738
|
annotation: t.id,
|
|
736
739
|
created: n || /* @__PURE__ */ new Date(),
|
|
737
740
|
creator: o,
|
|
@@ -744,8 +747,8 @@ const On = (t, e, n, o) => ({
|
|
|
744
747
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
745
748
|
}, He = (t, e) => e.bodies.map((n) => {
|
|
746
749
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
747
|
-
return { newBody: n, oldBody: o && !
|
|
748
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), $e = (t, e) => !
|
|
750
|
+
return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
|
|
751
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), $e = (t, e) => !q(t.target, e.target), Yt = (t, e) => {
|
|
749
752
|
const n = ke(t, e), o = Ye(t, e), i = He(t, e);
|
|
750
753
|
return {
|
|
751
754
|
oldValue: t,
|
|
@@ -756,7 +759,7 @@ const On = (t, e, n, o) => ({
|
|
|
756
759
|
targetUpdated: $e(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
757
760
|
};
|
|
758
761
|
};
|
|
759
|
-
var
|
|
762
|
+
var B = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(B || {});
|
|
760
763
|
const Pe = (t, e) => {
|
|
761
764
|
var n, o;
|
|
762
765
|
const { changes: i, origin: r } = e;
|
|
@@ -765,8 +768,8 @@ const Pe = (t, e) => {
|
|
|
765
768
|
if (t.options.ignore) {
|
|
766
769
|
const { ignore: a } = t.options, s = (u) => u && u.length > 0;
|
|
767
770
|
if (!(s(i.created) || s(i.deleted))) {
|
|
768
|
-
const u = (n = i.updated) == null ? void 0 : n.some((
|
|
769
|
-
if (a === "BODY_ONLY" && u && !
|
|
771
|
+
const u = (n = i.updated) == null ? void 0 : n.some((m) => s(m.bodiesCreated) || s(m.bodiesDeleted) || s(m.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((m) => m.targetUpdated);
|
|
772
|
+
if (a === "BODY_ONLY" && u && !h || a === "TARGET_ONLY" && h && !u)
|
|
770
773
|
return !1;
|
|
771
774
|
}
|
|
772
775
|
}
|
|
@@ -780,207 +783,214 @@ const Pe = (t, e) => {
|
|
|
780
783
|
} else
|
|
781
784
|
return !0;
|
|
782
785
|
}, ze = (t, e) => {
|
|
783
|
-
const n = new Set((t.created || []).map((
|
|
784
|
-
...(t.created || []).filter((
|
|
786
|
+
const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), r = new Set((e.deleted || []).map((c) => c.id)), a = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), s = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), u = [
|
|
787
|
+
...(t.created || []).filter((c) => !r.has(c.id)).map((c) => a.has(c.id) ? e.updated.find(({ oldValue: g }) => g.id === c.id).newValue : c),
|
|
785
788
|
...e.created || []
|
|
786
|
-
],
|
|
787
|
-
...(t.deleted || []).filter((
|
|
788
|
-
...(e.deleted || []).filter((
|
|
789
|
-
],
|
|
790
|
-
...(t.updated || []).filter(({ newValue:
|
|
791
|
-
const { oldValue:
|
|
789
|
+
], h = [
|
|
790
|
+
...(t.deleted || []).filter((c) => !i.has(c.id)),
|
|
791
|
+
...(e.deleted || []).filter((c) => !n.has(c.id))
|
|
792
|
+
], m = [
|
|
793
|
+
...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
|
|
794
|
+
const { oldValue: g, newValue: p } = c;
|
|
792
795
|
if (a.has(p.id)) {
|
|
793
|
-
const
|
|
794
|
-
return
|
|
796
|
+
const x = e.updated.find((b) => b.oldValue.id === p.id).newValue;
|
|
797
|
+
return Yt(g, x);
|
|
795
798
|
} else
|
|
796
|
-
return
|
|
799
|
+
return c;
|
|
797
800
|
}),
|
|
798
|
-
...(e.updated || []).filter(({ oldValue:
|
|
801
|
+
...(e.updated || []).filter(({ oldValue: c }) => !s.has(c.id))
|
|
799
802
|
];
|
|
800
|
-
return { created: u, deleted:
|
|
803
|
+
return { created: u, deleted: h, updated: m };
|
|
801
804
|
}, Fe = (t) => t.id !== void 0, We = () => {
|
|
802
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
803
|
-
const
|
|
804
|
-
|
|
805
|
-
}, r = (
|
|
806
|
-
const
|
|
807
|
-
origin:
|
|
805
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (v, w = {}) => n.push({ onChange: v, options: w }), i = (v) => {
|
|
806
|
+
const w = n.findIndex((A) => A.onChange == v);
|
|
807
|
+
w > -1 && n.splice(w, 1);
|
|
808
|
+
}, r = (v, w) => {
|
|
809
|
+
const A = {
|
|
810
|
+
origin: v,
|
|
808
811
|
changes: {
|
|
809
|
-
created:
|
|
810
|
-
updated:
|
|
811
|
-
deleted:
|
|
812
|
+
created: w.created || [],
|
|
813
|
+
updated: w.updated || [],
|
|
814
|
+
deleted: w.deleted || []
|
|
812
815
|
},
|
|
813
816
|
state: [...t.values()]
|
|
814
817
|
};
|
|
815
|
-
n.forEach((
|
|
816
|
-
Pe(
|
|
818
|
+
n.forEach((C) => {
|
|
819
|
+
Pe(C, A) && C.onChange(A);
|
|
817
820
|
});
|
|
818
|
-
}, a = (
|
|
819
|
-
if (t.get(
|
|
820
|
-
throw Error(`Cannot add annotation ${
|
|
821
|
-
t.set(
|
|
822
|
-
}, s = (
|
|
823
|
-
const
|
|
824
|
-
if (
|
|
825
|
-
const
|
|
826
|
-
return
|
|
821
|
+
}, a = (v, w = B.LOCAL) => {
|
|
822
|
+
if (t.get(v.id))
|
|
823
|
+
throw Error(`Cannot add annotation ${v.id} - exists already`);
|
|
824
|
+
t.set(v.id, v), v.bodies.forEach((A) => e.set(A.id, v.id)), r(w, { created: [v] });
|
|
825
|
+
}, s = (v, w) => {
|
|
826
|
+
const A = typeof v == "string" ? w : v, C = typeof v == "string" ? v : v.id, L = t.get(C);
|
|
827
|
+
if (L) {
|
|
828
|
+
const O = Yt(L, A);
|
|
829
|
+
return C === A.id ? t.set(C, A) : (t.delete(C), t.set(A.id, A)), L.bodies.forEach((H) => e.delete(H.id)), A.bodies.forEach((H) => e.set(H.id, A.id)), O;
|
|
827
830
|
} else
|
|
828
|
-
console.warn(`Cannot update annotation ${
|
|
829
|
-
}, u = (
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
},
|
|
833
|
-
const
|
|
834
|
-
const
|
|
835
|
-
return
|
|
831
|
+
console.warn(`Cannot update annotation ${C} - does not exist`);
|
|
832
|
+
}, u = (v, w = B.LOCAL, A = B.LOCAL) => {
|
|
833
|
+
const C = Fe(w) ? A : w, L = s(v, w);
|
|
834
|
+
L && r(C, { updated: [L] });
|
|
835
|
+
}, h = (v, w = B.LOCAL) => {
|
|
836
|
+
const A = v.reduce((C, L) => {
|
|
837
|
+
const O = s(L);
|
|
838
|
+
return O ? [...C, O] : C;
|
|
836
839
|
}, []);
|
|
837
|
-
|
|
838
|
-
},
|
|
839
|
-
const
|
|
840
|
-
if (
|
|
841
|
-
const
|
|
842
|
-
...
|
|
843
|
-
bodies: [...
|
|
840
|
+
A.length > 0 && r(w, { updated: A });
|
|
841
|
+
}, m = (v, w = B.LOCAL) => {
|
|
842
|
+
const A = t.get(v.annotation);
|
|
843
|
+
if (A) {
|
|
844
|
+
const C = {
|
|
845
|
+
...A,
|
|
846
|
+
bodies: [...A.bodies, v]
|
|
844
847
|
};
|
|
845
|
-
t.set(
|
|
846
|
-
oldValue:
|
|
847
|
-
newValue:
|
|
848
|
-
bodiesCreated: [
|
|
848
|
+
t.set(A.id, C), e.set(v.id, C.id), r(w, { updated: [{
|
|
849
|
+
oldValue: A,
|
|
850
|
+
newValue: C,
|
|
851
|
+
bodiesCreated: [v]
|
|
849
852
|
}] });
|
|
850
853
|
} else
|
|
851
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
852
|
-
},
|
|
853
|
-
const
|
|
854
|
-
t.clear(), e.clear(), r(
|
|
855
|
-
}, p = (
|
|
856
|
-
if (
|
|
857
|
-
const
|
|
858
|
-
t.clear(), e.clear(),
|
|
859
|
-
t.set(
|
|
860
|
-
}), r(
|
|
854
|
+
console.warn(`Attempt to add body to missing annotation: ${v.annotation}`);
|
|
855
|
+
}, c = () => [...t.values()], g = (v = B.LOCAL) => {
|
|
856
|
+
const w = [...t.values()];
|
|
857
|
+
t.clear(), e.clear(), r(v, { deleted: w });
|
|
858
|
+
}, p = (v, w = !0, A = B.LOCAL) => {
|
|
859
|
+
if (w) {
|
|
860
|
+
const C = [...t.values()];
|
|
861
|
+
t.clear(), e.clear(), v.forEach((L) => {
|
|
862
|
+
t.set(L.id, L), L.bodies.forEach((O) => e.set(O.id, L.id));
|
|
863
|
+
}), r(A, { created: v, deleted: C });
|
|
861
864
|
} else {
|
|
862
|
-
const
|
|
863
|
-
const
|
|
864
|
-
return
|
|
865
|
+
const C = v.reduce((L, O) => {
|
|
866
|
+
const H = t.get(O.id);
|
|
867
|
+
return H ? [...L, H] : L;
|
|
865
868
|
}, []);
|
|
866
|
-
if (
|
|
867
|
-
throw Error(`Bulk insert would overwrite the following annotations: ${
|
|
868
|
-
|
|
869
|
-
t.set(
|
|
870
|
-
}), r(
|
|
869
|
+
if (C.length > 0)
|
|
870
|
+
throw Error(`Bulk insert would overwrite the following annotations: ${C.map((L) => L.id).join(", ")}`);
|
|
871
|
+
v.forEach((L) => {
|
|
872
|
+
t.set(L.id, L), L.bodies.forEach((O) => e.set(O.id, L.id));
|
|
873
|
+
}), r(A, { created: v });
|
|
871
874
|
}
|
|
872
|
-
},
|
|
873
|
-
const
|
|
874
|
-
if (
|
|
875
|
-
return t.delete(
|
|
876
|
-
console.warn(`Attempt to delete missing annotation: ${
|
|
877
|
-
},
|
|
878
|
-
const
|
|
879
|
-
|
|
880
|
-
},
|
|
881
|
-
const
|
|
882
|
-
const
|
|
883
|
-
return
|
|
875
|
+
}, x = (v) => {
|
|
876
|
+
const w = typeof v == "string" ? v : v.id, A = t.get(w);
|
|
877
|
+
if (A)
|
|
878
|
+
return t.delete(w), A.bodies.forEach((C) => e.delete(C.id)), A;
|
|
879
|
+
console.warn(`Attempt to delete missing annotation: ${w}`);
|
|
880
|
+
}, b = (v, w = B.LOCAL) => {
|
|
881
|
+
const A = x(v);
|
|
882
|
+
A && r(w, { deleted: [A] });
|
|
883
|
+
}, f = (v, w = B.LOCAL) => {
|
|
884
|
+
const A = v.reduce((C, L) => {
|
|
885
|
+
const O = x(L);
|
|
886
|
+
return O ? [...C, O] : C;
|
|
884
887
|
}, []);
|
|
885
|
-
|
|
886
|
-
},
|
|
887
|
-
const
|
|
888
|
-
if (
|
|
889
|
-
const
|
|
890
|
-
if (
|
|
891
|
-
e.delete(
|
|
892
|
-
const
|
|
893
|
-
...
|
|
894
|
-
bodies:
|
|
888
|
+
A.length > 0 && r(w, { deleted: A });
|
|
889
|
+
}, l = (v) => {
|
|
890
|
+
const w = t.get(v.annotation);
|
|
891
|
+
if (w) {
|
|
892
|
+
const A = w.bodies.find((C) => C.id === v.id);
|
|
893
|
+
if (A) {
|
|
894
|
+
e.delete(A.id);
|
|
895
|
+
const C = {
|
|
896
|
+
...w,
|
|
897
|
+
bodies: w.bodies.filter((L) => L.id !== v.id)
|
|
898
|
+
};
|
|
899
|
+
return t.set(w.id, C), {
|
|
900
|
+
oldValue: w,
|
|
901
|
+
newValue: C,
|
|
902
|
+
bodiesDeleted: [A]
|
|
895
903
|
};
|
|
896
|
-
t.set(x.id, N), r(A, { updated: [{
|
|
897
|
-
oldValue: x,
|
|
898
|
-
newValue: N,
|
|
899
|
-
bodiesDeleted: [S]
|
|
900
|
-
}] });
|
|
901
904
|
} else
|
|
902
|
-
console.warn(`Attempt to delete missing body ${
|
|
905
|
+
console.warn(`Attempt to delete missing body ${v.id} from annotation ${v.annotation}`);
|
|
903
906
|
} else
|
|
904
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
905
|
-
},
|
|
906
|
-
const A =
|
|
907
|
-
|
|
908
|
-
}, y = (
|
|
909
|
-
const A =
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
907
|
+
console.warn(`Attempt to delete body from missing annotation ${v.annotation}`);
|
|
908
|
+
}, d = (v, w = B.LOCAL) => {
|
|
909
|
+
const A = l(v);
|
|
910
|
+
A && r(w, { updated: [A] });
|
|
911
|
+
}, y = (v, w = B.LOCAL) => {
|
|
912
|
+
const A = v.map((C) => l(C)).filter(Boolean);
|
|
913
|
+
A.length > 0 && r(w, { updated: A });
|
|
914
|
+
}, T = (v) => {
|
|
915
|
+
const w = t.get(v);
|
|
916
|
+
return w ? { ...w } : void 0;
|
|
917
|
+
}, S = (v) => {
|
|
918
|
+
const w = e.get(v);
|
|
919
|
+
if (w) {
|
|
920
|
+
const A = T(w).bodies.find((C) => C.id === v);
|
|
921
|
+
if (A)
|
|
922
|
+
return A;
|
|
923
|
+
console.error(`Store integrity error: body ${v} in index, but not in annotation`);
|
|
915
924
|
} else
|
|
916
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
917
|
-
},
|
|
918
|
-
if (
|
|
925
|
+
console.warn(`Attempt to retrieve missing body: ${v}`);
|
|
926
|
+
}, E = (v, w) => {
|
|
927
|
+
if (v.annotation !== w.annotation)
|
|
919
928
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
920
|
-
const
|
|
921
|
-
if (
|
|
922
|
-
const
|
|
923
|
-
...
|
|
924
|
-
bodies:
|
|
929
|
+
const A = t.get(v.annotation);
|
|
930
|
+
if (A) {
|
|
931
|
+
const C = A.bodies.find((O) => O.id === v.id), L = {
|
|
932
|
+
...A,
|
|
933
|
+
bodies: A.bodies.map((O) => O.id === C.id ? w : O)
|
|
925
934
|
};
|
|
926
|
-
return t.set(
|
|
927
|
-
oldValue:
|
|
928
|
-
newValue:
|
|
929
|
-
bodiesUpdated: [{ oldBody:
|
|
935
|
+
return t.set(A.id, L), C.id !== w.id && (e.delete(C.id), e.set(w.id, L.id)), {
|
|
936
|
+
oldValue: A,
|
|
937
|
+
newValue: L,
|
|
938
|
+
bodiesUpdated: [{ oldBody: C, newBody: w }]
|
|
930
939
|
};
|
|
931
940
|
} else
|
|
932
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
933
|
-
},
|
|
934
|
-
const
|
|
935
|
-
|
|
936
|
-
},
|
|
937
|
-
const
|
|
938
|
-
r(
|
|
939
|
-
},
|
|
940
|
-
const
|
|
941
|
-
if (
|
|
942
|
-
const
|
|
943
|
-
...
|
|
941
|
+
console.warn(`Attempt to add body to missing annotation ${v.annotation}`);
|
|
942
|
+
}, N = (v, w, A = B.LOCAL) => {
|
|
943
|
+
const C = E(v, w);
|
|
944
|
+
C && r(A, { updated: [C] });
|
|
945
|
+
}, R = (v, w = B.LOCAL) => {
|
|
946
|
+
const A = v.map((C) => E({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
|
|
947
|
+
r(w, { updated: A });
|
|
948
|
+
}, M = (v) => {
|
|
949
|
+
const w = t.get(v.annotation);
|
|
950
|
+
if (w) {
|
|
951
|
+
const A = {
|
|
952
|
+
...w,
|
|
944
953
|
target: {
|
|
945
|
-
...
|
|
946
|
-
...
|
|
954
|
+
...w.target,
|
|
955
|
+
...v
|
|
947
956
|
}
|
|
948
957
|
};
|
|
949
|
-
return t.set(
|
|
950
|
-
oldValue:
|
|
951
|
-
newValue:
|
|
958
|
+
return t.set(w.id, A), {
|
|
959
|
+
oldValue: w,
|
|
960
|
+
newValue: A,
|
|
952
961
|
targetUpdated: {
|
|
953
|
-
oldTarget:
|
|
954
|
-
newTarget:
|
|
962
|
+
oldTarget: w.target,
|
|
963
|
+
newTarget: v
|
|
955
964
|
}
|
|
956
965
|
};
|
|
957
966
|
} else
|
|
958
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
967
|
+
console.warn(`Attempt to update target on missing annotation: ${v.annotation}`);
|
|
959
968
|
};
|
|
960
969
|
return {
|
|
961
970
|
addAnnotation: a,
|
|
962
|
-
addBody:
|
|
963
|
-
all:
|
|
971
|
+
addBody: m,
|
|
972
|
+
all: c,
|
|
964
973
|
bulkAddAnnotation: p,
|
|
965
|
-
bulkDeleteAnnotation:
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
974
|
+
bulkDeleteAnnotation: f,
|
|
975
|
+
bulkDeleteBodies: y,
|
|
976
|
+
bulkUpdateAnnotation: h,
|
|
977
|
+
bulkUpdateBodies: R,
|
|
978
|
+
bulkUpdateTargets: (v, w = B.LOCAL) => {
|
|
979
|
+
const A = v.map((C) => M(C)).filter(Boolean);
|
|
980
|
+
A.length > 0 && r(w, { updated: A });
|
|
971
981
|
},
|
|
972
|
-
clear:
|
|
973
|
-
deleteAnnotation:
|
|
982
|
+
clear: g,
|
|
983
|
+
deleteAnnotation: b,
|
|
974
984
|
deleteBody: d,
|
|
975
|
-
getAnnotation:
|
|
976
|
-
getBody:
|
|
985
|
+
getAnnotation: T,
|
|
986
|
+
getBody: S,
|
|
977
987
|
observe: o,
|
|
978
988
|
unobserve: i,
|
|
979
989
|
updateAnnotation: u,
|
|
980
|
-
updateBody:
|
|
981
|
-
updateTarget: (
|
|
982
|
-
const
|
|
983
|
-
|
|
990
|
+
updateBody: N,
|
|
991
|
+
updateTarget: (v, w = B.LOCAL) => {
|
|
992
|
+
const A = M(v);
|
|
993
|
+
A && r(w, { updated: [A] });
|
|
984
994
|
}
|
|
985
995
|
};
|
|
986
996
|
};
|
|
@@ -1003,110 +1013,110 @@ const je = 250, Ge = (t) => {
|
|
|
1003
1013
|
let o = -1, i = !1, r = 0;
|
|
1004
1014
|
const a = (p) => {
|
|
1005
1015
|
if (!i) {
|
|
1006
|
-
const { changes:
|
|
1007
|
-
if (
|
|
1008
|
-
n.splice(o + 1), n.push(
|
|
1016
|
+
const { changes: x } = p, b = performance.now();
|
|
1017
|
+
if (b - r > je)
|
|
1018
|
+
n.splice(o + 1), n.push(x), o = n.length - 1;
|
|
1009
1019
|
else {
|
|
1010
|
-
const
|
|
1011
|
-
n[
|
|
1020
|
+
const f = n.length - 1;
|
|
1021
|
+
n[f] = ze(n[f], x);
|
|
1012
1022
|
}
|
|
1013
|
-
r =
|
|
1023
|
+
r = b;
|
|
1014
1024
|
}
|
|
1015
1025
|
i = !1;
|
|
1016
1026
|
};
|
|
1017
|
-
t.observe(a, { origin:
|
|
1018
|
-
const s = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1),
|
|
1027
|
+
t.observe(a, { origin: B.LOCAL });
|
|
1028
|
+
const s = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: x }) => x)), m = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: x }) => x)), c = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
|
|
1019
1029
|
return {
|
|
1020
1030
|
canRedo: () => n.length - 1 > o,
|
|
1021
1031
|
canUndo: () => o > -1,
|
|
1022
1032
|
destroy: () => t.unobserve(a),
|
|
1023
|
-
on: (p,
|
|
1033
|
+
on: (p, x) => e.on(p, x),
|
|
1024
1034
|
redo: () => {
|
|
1025
1035
|
if (n.length - 1 > o) {
|
|
1026
1036
|
i = !0;
|
|
1027
|
-
const { created: p, updated:
|
|
1028
|
-
u(p),
|
|
1037
|
+
const { created: p, updated: x, deleted: b } = n[o + 1];
|
|
1038
|
+
u(p), m(x), g(b), e.emit("redo", n[o + 1]), o += 1;
|
|
1029
1039
|
}
|
|
1030
1040
|
},
|
|
1031
1041
|
undo: () => {
|
|
1032
1042
|
if (o > -1) {
|
|
1033
1043
|
i = !0;
|
|
1034
|
-
const { created: p, updated:
|
|
1035
|
-
s(p),
|
|
1044
|
+
const { created: p, updated: x, deleted: b } = n[o];
|
|
1045
|
+
s(p), h(x), c(b), e.emit("undo", n[o]), o -= 1;
|
|
1036
1046
|
}
|
|
1037
1047
|
}
|
|
1038
1048
|
};
|
|
1039
1049
|
}, Ke = () => {
|
|
1040
|
-
const { subscribe: t, set: e } =
|
|
1050
|
+
const { subscribe: t, set: e } = bt([]);
|
|
1041
1051
|
return {
|
|
1042
1052
|
subscribe: t,
|
|
1043
1053
|
set: e
|
|
1044
1054
|
};
|
|
1045
1055
|
}, Qe = (t, e, n, o) => {
|
|
1046
1056
|
const { store: i, selection: r, hover: a, viewport: s } = t, u = /* @__PURE__ */ new Map();
|
|
1047
|
-
let
|
|
1048
|
-
const
|
|
1049
|
-
u.has(
|
|
1050
|
-
},
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1053
|
-
}, p = (
|
|
1054
|
-
u.has(
|
|
1055
|
-
u.get(
|
|
1057
|
+
let h = [], m;
|
|
1058
|
+
const c = (b, f) => {
|
|
1059
|
+
u.has(b) ? u.get(b).push(f) : u.set(b, [f]);
|
|
1060
|
+
}, g = (b, f) => {
|
|
1061
|
+
const l = u.get(b);
|
|
1062
|
+
l && l.indexOf(f) > 0 && l.splice(l.indexOf(f), 1);
|
|
1063
|
+
}, p = (b, f, l) => {
|
|
1064
|
+
u.has(b) && setTimeout(() => {
|
|
1065
|
+
u.get(b).forEach((d) => {
|
|
1056
1066
|
if (n) {
|
|
1057
|
-
const y = Array.isArray(
|
|
1058
|
-
|
|
1067
|
+
const y = Array.isArray(f) ? f.map((S) => n.serialize(S)) : n.serialize(f), T = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;
|
|
1068
|
+
d(y, T);
|
|
1059
1069
|
} else
|
|
1060
|
-
|
|
1070
|
+
d(f, l);
|
|
1061
1071
|
});
|
|
1062
1072
|
}, 1);
|
|
1063
1073
|
};
|
|
1064
|
-
r.subscribe(({ selected:
|
|
1065
|
-
if (!(
|
|
1066
|
-
if (
|
|
1067
|
-
|
|
1068
|
-
else if (
|
|
1069
|
-
|
|
1070
|
-
const
|
|
1071
|
-
|
|
1072
|
-
}),
|
|
1074
|
+
r.subscribe(({ selected: b }) => {
|
|
1075
|
+
if (!(h.length === 0 && b.length === 0)) {
|
|
1076
|
+
if (h.length === 0 && b.length > 0)
|
|
1077
|
+
h = b.map(({ id: f }) => i.getAnnotation(f));
|
|
1078
|
+
else if (h.length > 0 && b.length === 0)
|
|
1079
|
+
h.forEach((f) => {
|
|
1080
|
+
const l = i.getAnnotation(f.id);
|
|
1081
|
+
l && !q(l, f) && p("updateAnnotation", l, f);
|
|
1082
|
+
}), h = [];
|
|
1073
1083
|
else {
|
|
1074
|
-
const
|
|
1075
|
-
|
|
1076
|
-
const y = i.getAnnotation(
|
|
1077
|
-
y && !
|
|
1078
|
-
}),
|
|
1084
|
+
const f = new Set(h.map((d) => d.id)), l = new Set(b.map(({ id: d }) => d));
|
|
1085
|
+
h.filter((d) => !l.has(d.id)).forEach((d) => {
|
|
1086
|
+
const y = i.getAnnotation(d.id);
|
|
1087
|
+
y && !q(y, d) && p("updateAnnotation", y, d);
|
|
1088
|
+
}), h = [
|
|
1079
1089
|
// Remove annotations that were deselected
|
|
1080
|
-
...
|
|
1090
|
+
...h.filter((d) => l.has(d.id)),
|
|
1081
1091
|
// Add editable annotations that were selected
|
|
1082
|
-
...
|
|
1092
|
+
...b.filter(({ id: d }) => !f.has(d)).map(({ id: d }) => i.getAnnotation(d))
|
|
1083
1093
|
];
|
|
1084
1094
|
}
|
|
1085
|
-
p("selectionChanged",
|
|
1095
|
+
p("selectionChanged", h);
|
|
1086
1096
|
}
|
|
1087
|
-
}), a.subscribe((
|
|
1088
|
-
!
|
|
1089
|
-
}), s == null || s.subscribe((
|
|
1090
|
-
const { created:
|
|
1091
|
-
(
|
|
1092
|
-
...
|
|
1093
|
-
...
|
|
1094
|
-
...
|
|
1095
|
-
].length > 0).forEach(({ oldValue:
|
|
1096
|
-
const T =
|
|
1097
|
-
|
|
1097
|
+
}), a.subscribe((b) => {
|
|
1098
|
+
!m && b ? p("mouseEnterAnnotation", i.getAnnotation(b)) : m && !b ? p("mouseLeaveAnnotation", i.getAnnotation(m)) : m && b && (p("mouseLeaveAnnotation", i.getAnnotation(m)), p("mouseEnterAnnotation", i.getAnnotation(b))), m = b;
|
|
1099
|
+
}), s == null || s.subscribe((b) => p("viewportIntersect", b.map((f) => i.getAnnotation(f)))), i.observe((b) => {
|
|
1100
|
+
const { created: f, deleted: l } = b.changes;
|
|
1101
|
+
(f || []).forEach((d) => p("createAnnotation", d)), (l || []).forEach((d) => p("deleteAnnotation", d)), (b.changes.updated || []).filter((d) => [
|
|
1102
|
+
...d.bodiesCreated || [],
|
|
1103
|
+
...d.bodiesDeleted || [],
|
|
1104
|
+
...d.bodiesUpdated || []
|
|
1105
|
+
].length > 0).forEach(({ oldValue: d, newValue: y }) => {
|
|
1106
|
+
const T = h.find((S) => S.id === d.id) || d;
|
|
1107
|
+
h = h.map((S) => S.id === d.id ? y : S), p("updateAnnotation", y, T);
|
|
1098
1108
|
});
|
|
1099
|
-
}, { origin:
|
|
1100
|
-
if (
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1109
|
+
}, { origin: B.LOCAL }), i.observe((b) => {
|
|
1110
|
+
if (h) {
|
|
1111
|
+
const f = new Set(h.map((d) => d.id)), l = (b.changes.updated || []).filter(({ newValue: d }) => f.has(d.id)).map(({ newValue: d }) => d);
|
|
1112
|
+
l.length > 0 && (h = h.map((d) => l.find((T) => T.id === d.id) || d));
|
|
1103
1113
|
}
|
|
1104
|
-
}, { origin:
|
|
1105
|
-
const
|
|
1106
|
-
const { updated:
|
|
1107
|
-
|
|
1114
|
+
}, { origin: B.REMOTE });
|
|
1115
|
+
const x = (b) => (f) => {
|
|
1116
|
+
const { updated: l } = f;
|
|
1117
|
+
b ? (l || []).forEach((d) => p("updateAnnotation", d.oldValue, d.newValue)) : (l || []).forEach((d) => p("updateAnnotation", d.newValue, d.oldValue));
|
|
1108
1118
|
};
|
|
1109
|
-
return e.on("undo",
|
|
1119
|
+
return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: c, off: g, emit: p };
|
|
1110
1120
|
}, Je = (t) => (e) => e.reduce((n, o) => {
|
|
1111
1121
|
const { parsed: i, error: r } = t.parse(o);
|
|
1112
1122
|
return r ? {
|
|
@@ -1119,44 +1129,44 @@ const je = 250, Ge = (t) => {
|
|
|
1119
1129
|
...n
|
|
1120
1130
|
};
|
|
1121
1131
|
}, { parsed: [], failed: [] }), Ze = (t, e, n) => {
|
|
1122
|
-
const { store: o, selection: i } = t, r = (
|
|
1132
|
+
const { store: o, selection: i } = t, r = (f) => {
|
|
1123
1133
|
if (n) {
|
|
1124
|
-
const { parsed:
|
|
1125
|
-
|
|
1134
|
+
const { parsed: l, error: d } = n.parse(f);
|
|
1135
|
+
l ? o.addAnnotation(l, B.REMOTE) : console.error(d);
|
|
1126
1136
|
} else
|
|
1127
|
-
o.addAnnotation(
|
|
1128
|
-
}, a = () => i.clear(), s = () => o.clear(), u = (
|
|
1129
|
-
const
|
|
1130
|
-
return n &&
|
|
1131
|
-
},
|
|
1132
|
-
var
|
|
1133
|
-
const
|
|
1134
|
-
return n ?
|
|
1135
|
-
},
|
|
1136
|
-
if (typeof
|
|
1137
|
-
const
|
|
1138
|
-
if (o.deleteAnnotation(
|
|
1139
|
-
return n ? n.serialize(
|
|
1137
|
+
o.addAnnotation(f, B.REMOTE);
|
|
1138
|
+
}, a = () => i.clear(), s = () => o.clear(), u = (f) => {
|
|
1139
|
+
const l = o.getAnnotation(f);
|
|
1140
|
+
return n && l ? n.serialize(l) : l;
|
|
1141
|
+
}, h = () => n ? o.all().map(n.serialize) : o.all(), m = () => {
|
|
1142
|
+
var f;
|
|
1143
|
+
const l = (((f = i.selected) == null ? void 0 : f.map((d) => d.id)) || []).map((d) => o.getAnnotation(d)).filter(Boolean);
|
|
1144
|
+
return n ? l.map(n.serialize) : l;
|
|
1145
|
+
}, c = (f, l = !0) => fetch(f).then((d) => d.json()).then((d) => (p(d, l), d)), g = (f) => {
|
|
1146
|
+
if (typeof f == "string") {
|
|
1147
|
+
const l = o.getAnnotation(f);
|
|
1148
|
+
if (o.deleteAnnotation(f), l)
|
|
1149
|
+
return n ? n.serialize(l) : l;
|
|
1140
1150
|
} else {
|
|
1141
|
-
const
|
|
1142
|
-
if (
|
|
1143
|
-
return o.deleteAnnotation(
|
|
1151
|
+
const l = n ? n.parse(f).parsed : f;
|
|
1152
|
+
if (l)
|
|
1153
|
+
return o.deleteAnnotation(l), f;
|
|
1144
1154
|
}
|
|
1145
|
-
}, p = (
|
|
1155
|
+
}, p = (f, l = !0) => {
|
|
1146
1156
|
if (n) {
|
|
1147
|
-
const { parsed:
|
|
1148
|
-
y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(
|
|
1157
|
+
const { parsed: d, failed: y } = Je(n)(f);
|
|
1158
|
+
y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(d, l, B.REMOTE);
|
|
1149
1159
|
} else
|
|
1150
|
-
o.bulkAddAnnotation(
|
|
1151
|
-
},
|
|
1152
|
-
|
|
1153
|
-
},
|
|
1160
|
+
o.bulkAddAnnotation(f, l, B.REMOTE);
|
|
1161
|
+
}, x = (f) => {
|
|
1162
|
+
f ? i.setSelected(f) : i.clear();
|
|
1163
|
+
}, b = (f) => {
|
|
1154
1164
|
if (n) {
|
|
1155
|
-
const
|
|
1156
|
-
return o.updateAnnotation(
|
|
1165
|
+
const l = n.parse(f).parsed, d = n.serialize(o.getAnnotation(l.id));
|
|
1166
|
+
return o.updateAnnotation(l), d;
|
|
1157
1167
|
} else {
|
|
1158
|
-
const
|
|
1159
|
-
return o.updateAnnotation(
|
|
1168
|
+
const l = o.getAnnotation(f.id);
|
|
1169
|
+
return o.updateAnnotation(f), l;
|
|
1160
1170
|
}
|
|
1161
1171
|
};
|
|
1162
1172
|
return {
|
|
@@ -1166,15 +1176,15 @@ const je = 250, Ge = (t) => {
|
|
|
1166
1176
|
canUndo: e.canUndo,
|
|
1167
1177
|
clearAnnotations: s,
|
|
1168
1178
|
getAnnotationById: u,
|
|
1169
|
-
getAnnotations:
|
|
1170
|
-
getSelected:
|
|
1171
|
-
loadAnnotations:
|
|
1179
|
+
getAnnotations: h,
|
|
1180
|
+
getSelected: m,
|
|
1181
|
+
loadAnnotations: c,
|
|
1172
1182
|
redo: e.redo,
|
|
1173
|
-
removeAnnotation:
|
|
1183
|
+
removeAnnotation: g,
|
|
1174
1184
|
setAnnotations: p,
|
|
1175
|
-
setSelected:
|
|
1185
|
+
setSelected: x,
|
|
1176
1186
|
undo: e.undo,
|
|
1177
|
-
updateAnnotation:
|
|
1187
|
+
updateAnnotation: b
|
|
1178
1188
|
};
|
|
1179
1189
|
}, tn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1180
1190
|
let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
|
|
@@ -1202,22 +1212,27 @@ const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1202
1212
|
n = (n << 5) - n + r, n |= 0;
|
|
1203
1213
|
}
|
|
1204
1214
|
return `${n}`;
|
|
1205
|
-
},
|
|
1206
|
-
const { id: o, type: i, purpose: r, value: a, created: s,
|
|
1215
|
+
}, Ht = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, cn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1216
|
+
const { id: o, type: i, purpose: r, value: a, created: s, modified: u, creator: h, ...m } = n;
|
|
1207
1217
|
return {
|
|
1208
1218
|
id: o || `temp-${an(n)}`,
|
|
1209
1219
|
annotation: e,
|
|
1210
1220
|
type: i,
|
|
1211
1221
|
purpose: r,
|
|
1212
1222
|
value: a,
|
|
1223
|
+
creator: Ht(h),
|
|
1213
1224
|
created: s ? new Date(s) : void 0,
|
|
1214
|
-
|
|
1215
|
-
...
|
|
1225
|
+
updated: u ? new Date(u) : void 0,
|
|
1226
|
+
...m
|
|
1216
1227
|
};
|
|
1217
|
-
}),
|
|
1218
|
-
var n
|
|
1219
|
-
const i
|
|
1220
|
-
|
|
1228
|
+
}), ln = (t) => t.map((e) => {
|
|
1229
|
+
var n;
|
|
1230
|
+
const { annotation: o, created: i, updated: r, ...a } = e, s = {
|
|
1231
|
+
...a,
|
|
1232
|
+
created: i == null ? void 0 : i.toISOString(),
|
|
1233
|
+
modified: r == null ? void 0 : r.toISOString()
|
|
1234
|
+
};
|
|
1235
|
+
return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
|
|
1221
1236
|
});
|
|
1222
1237
|
rn();
|
|
1223
1238
|
const In = (t, e) => ({
|
|
@@ -1231,43 +1246,43 @@ const In = (t, e) => ({
|
|
|
1231
1246
|
modified: i,
|
|
1232
1247
|
target: r
|
|
1233
1248
|
} = t, a = Array.isArray(r) ? r : [r], s = {
|
|
1234
|
-
creator:
|
|
1249
|
+
creator: Ht(n),
|
|
1235
1250
|
created: o ? new Date(o) : void 0,
|
|
1236
1251
|
updated: i ? new Date(i) : void 0,
|
|
1237
1252
|
annotation: e,
|
|
1238
1253
|
selector: []
|
|
1239
1254
|
};
|
|
1240
1255
|
for (const u of a) {
|
|
1241
|
-
const
|
|
1242
|
-
switch (
|
|
1256
|
+
const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((c, g) => {
|
|
1257
|
+
switch (g.type) {
|
|
1243
1258
|
case "TextQuoteSelector":
|
|
1244
|
-
|
|
1259
|
+
c.quote = g.exact;
|
|
1245
1260
|
break;
|
|
1246
1261
|
case "TextPositionSelector":
|
|
1247
|
-
|
|
1262
|
+
c.start = g.start, c.end = g.end;
|
|
1248
1263
|
break;
|
|
1249
1264
|
}
|
|
1250
|
-
return
|
|
1265
|
+
return c;
|
|
1251
1266
|
}, {});
|
|
1252
|
-
if (dn(
|
|
1253
|
-
s.selector.push({ id: u.id, ...
|
|
1267
|
+
if (dn(m))
|
|
1268
|
+
s.selector.push({ id: u.id, ...m });
|
|
1254
1269
|
else {
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
|
|
1270
|
+
const c = [
|
|
1271
|
+
m.start ? void 0 : "TextPositionSelector",
|
|
1272
|
+
m.quote ? void 0 : "TextQuoteSelector"
|
|
1258
1273
|
].filter(Boolean);
|
|
1259
|
-
return { error: Error(`Missing selector types: ${
|
|
1274
|
+
return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`) };
|
|
1260
1275
|
}
|
|
1261
1276
|
}
|
|
1262
1277
|
return { parsed: s };
|
|
1263
1278
|
}, hn = (t) => {
|
|
1264
|
-
const e = t.id ||
|
|
1279
|
+
const e = t.id || kt(), {
|
|
1265
1280
|
creator: n,
|
|
1266
1281
|
created: o,
|
|
1267
1282
|
modified: i,
|
|
1268
1283
|
body: r,
|
|
1269
1284
|
...a
|
|
1270
|
-
} = t, s =
|
|
1285
|
+
} = t, s = cn(r, e), u = un(t);
|
|
1271
1286
|
return "error" in u ? { error: u.error } : {
|
|
1272
1287
|
parsed: {
|
|
1273
1288
|
...a,
|
|
@@ -1281,22 +1296,22 @@ const In = (t, e) => ({
|
|
|
1281
1296
|
selector: a,
|
|
1282
1297
|
creator: s,
|
|
1283
1298
|
created: u,
|
|
1284
|
-
updated:
|
|
1285
|
-
...
|
|
1286
|
-
} = i,
|
|
1287
|
-
const { quote: p, start:
|
|
1299
|
+
updated: h,
|
|
1300
|
+
...m
|
|
1301
|
+
} = i, c = a.map((g) => {
|
|
1302
|
+
const { quote: p, start: x, end: b, range: f } = g, { prefix: l, suffix: d } = te(f, n), y = [{
|
|
1288
1303
|
type: "TextQuoteSelector",
|
|
1289
1304
|
exact: p,
|
|
1290
|
-
prefix:
|
|
1291
|
-
suffix:
|
|
1305
|
+
prefix: l,
|
|
1306
|
+
suffix: d
|
|
1292
1307
|
}, {
|
|
1293
1308
|
type: "TextPositionSelector",
|
|
1294
|
-
start:
|
|
1295
|
-
end:
|
|
1309
|
+
start: x,
|
|
1310
|
+
end: b
|
|
1296
1311
|
}];
|
|
1297
1312
|
return {
|
|
1298
|
-
...
|
|
1299
|
-
id:
|
|
1313
|
+
...m,
|
|
1314
|
+
id: g.id,
|
|
1300
1315
|
source: e,
|
|
1301
1316
|
selector: y
|
|
1302
1317
|
};
|
|
@@ -1306,33 +1321,33 @@ const In = (t, e) => ({
|
|
|
1306
1321
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1307
1322
|
id: t.id,
|
|
1308
1323
|
type: "Annotation",
|
|
1309
|
-
body:
|
|
1324
|
+
body: ln(t.bodies),
|
|
1310
1325
|
creator: s,
|
|
1311
1326
|
created: u == null ? void 0 : u.toISOString(),
|
|
1312
|
-
modified:
|
|
1313
|
-
target:
|
|
1327
|
+
modified: h == null ? void 0 : h.toISOString(),
|
|
1328
|
+
target: c
|
|
1314
1329
|
};
|
|
1315
1330
|
};
|
|
1316
1331
|
function pn(t, e, n, o, i) {
|
|
1317
|
-
|
|
1332
|
+
$t(t, e, n || 0, o || t.length - 1, i || gn);
|
|
1318
1333
|
}
|
|
1319
|
-
function
|
|
1334
|
+
function $t(t, e, n, o, i) {
|
|
1320
1335
|
for (; o > n; ) {
|
|
1321
1336
|
if (o - n > 600) {
|
|
1322
|
-
var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3),
|
|
1323
|
-
|
|
1337
|
+
var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), h = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - a * u / r + h)), c = Math.min(o, Math.floor(e + (r - a) * u / r + h));
|
|
1338
|
+
$t(t, e, m, c, i);
|
|
1324
1339
|
}
|
|
1325
|
-
var
|
|
1326
|
-
for (
|
|
1327
|
-
for (
|
|
1340
|
+
var g = t[e], p = n, x = o;
|
|
1341
|
+
for (j(t, n, e), i(t[o], g) > 0 && j(t, n, o); p < x; ) {
|
|
1342
|
+
for (j(t, p, x), p++, x--; i(t[p], g) < 0; )
|
|
1328
1343
|
p++;
|
|
1329
|
-
for (; i(t[
|
|
1330
|
-
|
|
1344
|
+
for (; i(t[x], g) > 0; )
|
|
1345
|
+
x--;
|
|
1331
1346
|
}
|
|
1332
|
-
i(t[n],
|
|
1347
|
+
i(t[n], g) === 0 ? j(t, n, x) : (x++, j(t, x, o)), x <= e && (n = x + 1), e <= x && (o = x - 1);
|
|
1333
1348
|
}
|
|
1334
1349
|
}
|
|
1335
|
-
function
|
|
1350
|
+
function j(t, e, n) {
|
|
1336
1351
|
var o = t[e];
|
|
1337
1352
|
t[e] = t[n], t[n] = o;
|
|
1338
1353
|
}
|
|
@@ -1349,13 +1364,13 @@ class mn {
|
|
|
1349
1364
|
search(e) {
|
|
1350
1365
|
let n = this.data;
|
|
1351
1366
|
const o = [];
|
|
1352
|
-
if (!
|
|
1367
|
+
if (!nt(e, n))
|
|
1353
1368
|
return o;
|
|
1354
1369
|
const i = this.toBBox, r = [];
|
|
1355
1370
|
for (; n; ) {
|
|
1356
1371
|
for (let a = 0; a < n.children.length; a++) {
|
|
1357
1372
|
const s = n.children[a], u = n.leaf ? i(s) : s;
|
|
1358
|
-
|
|
1373
|
+
nt(e, u) && (n.leaf ? o.push(s) : ht(e, u) ? this._all(s, o) : r.push(s));
|
|
1359
1374
|
}
|
|
1360
1375
|
n = r.pop();
|
|
1361
1376
|
}
|
|
@@ -1363,14 +1378,14 @@ class mn {
|
|
|
1363
1378
|
}
|
|
1364
1379
|
collides(e) {
|
|
1365
1380
|
let n = this.data;
|
|
1366
|
-
if (!
|
|
1381
|
+
if (!nt(e, n))
|
|
1367
1382
|
return !1;
|
|
1368
1383
|
const o = [];
|
|
1369
1384
|
for (; n; ) {
|
|
1370
1385
|
for (let i = 0; i < n.children.length; i++) {
|
|
1371
1386
|
const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;
|
|
1372
|
-
if (
|
|
1373
|
-
if (n.leaf ||
|
|
1387
|
+
if (nt(e, a)) {
|
|
1388
|
+
if (n.leaf || ht(e, a))
|
|
1374
1389
|
return !0;
|
|
1375
1390
|
o.push(r);
|
|
1376
1391
|
}
|
|
@@ -1405,21 +1420,21 @@ class mn {
|
|
|
1405
1420
|
return e && this._insert(e, this.data.height - 1), this;
|
|
1406
1421
|
}
|
|
1407
1422
|
clear() {
|
|
1408
|
-
return this.data =
|
|
1423
|
+
return this.data = W([]), this;
|
|
1409
1424
|
}
|
|
1410
1425
|
remove(e, n) {
|
|
1411
1426
|
if (!e)
|
|
1412
1427
|
return this;
|
|
1413
1428
|
let o = this.data;
|
|
1414
1429
|
const i = this.toBBox(e), r = [], a = [];
|
|
1415
|
-
let s, u,
|
|
1430
|
+
let s, u, h;
|
|
1416
1431
|
for (; o || r.length; ) {
|
|
1417
|
-
if (o || (o = r.pop(), u = r[r.length - 1], s = a.pop(),
|
|
1418
|
-
const
|
|
1419
|
-
if (
|
|
1420
|
-
return o.children.splice(
|
|
1432
|
+
if (o || (o = r.pop(), u = r[r.length - 1], s = a.pop(), h = !0), o.leaf) {
|
|
1433
|
+
const m = bn(e, o.children, n);
|
|
1434
|
+
if (m !== -1)
|
|
1435
|
+
return o.children.splice(m, 1), r.push(o), this._condense(r), this;
|
|
1421
1436
|
}
|
|
1422
|
-
!
|
|
1437
|
+
!h && !o.leaf && ht(o, i) ? (r.push(o), a.push(s), s = 0, u = o, o = o.children[0]) : u ? (s++, o = u.children[s], h = !1) : o = null;
|
|
1423
1438
|
}
|
|
1424
1439
|
return this;
|
|
1425
1440
|
}
|
|
@@ -1448,26 +1463,26 @@ class mn {
|
|
|
1448
1463
|
const r = o - n + 1;
|
|
1449
1464
|
let a = this._maxEntries, s;
|
|
1450
1465
|
if (r <= a)
|
|
1451
|
-
return s =
|
|
1452
|
-
i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s =
|
|
1453
|
-
const u = Math.ceil(r / a),
|
|
1454
|
-
|
|
1455
|
-
for (let
|
|
1456
|
-
const
|
|
1457
|
-
|
|
1458
|
-
for (let
|
|
1459
|
-
const p = Math.min(
|
|
1460
|
-
s.children.push(this._build(e,
|
|
1466
|
+
return s = W(e.slice(n, o + 1)), F(s, this.toBBox), s;
|
|
1467
|
+
i || (i = Math.ceil(Math.log(r) / Math.log(a)), a = Math.ceil(r / Math.pow(a, i - 1))), s = W([]), s.leaf = !1, s.height = i;
|
|
1468
|
+
const u = Math.ceil(r / a), h = u * Math.ceil(Math.sqrt(a));
|
|
1469
|
+
It(e, n, o, h, this.compareMinX);
|
|
1470
|
+
for (let m = n; m <= o; m += h) {
|
|
1471
|
+
const c = Math.min(m + h - 1, o);
|
|
1472
|
+
It(e, m, c, u, this.compareMinY);
|
|
1473
|
+
for (let g = m; g <= c; g += u) {
|
|
1474
|
+
const p = Math.min(g + u - 1, c);
|
|
1475
|
+
s.children.push(this._build(e, g, p, i - 1));
|
|
1461
1476
|
}
|
|
1462
1477
|
}
|
|
1463
|
-
return
|
|
1478
|
+
return F(s, this.toBBox), s;
|
|
1464
1479
|
}
|
|
1465
1480
|
_chooseSubtree(e, n, o, i) {
|
|
1466
1481
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1467
1482
|
let r = 1 / 0, a = 1 / 0, s;
|
|
1468
1483
|
for (let u = 0; u < n.children.length; u++) {
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1484
|
+
const h = n.children[u], m = ut(h), c = wn(e, h) - m;
|
|
1485
|
+
c < a ? (a = c, r = m < r ? m : r, s = h) : c === a && m < r && (r = m, s = h);
|
|
1471
1486
|
}
|
|
1472
1487
|
n = s || n.children[0];
|
|
1473
1488
|
}
|
|
@@ -1475,7 +1490,7 @@ class mn {
|
|
|
1475
1490
|
}
|
|
1476
1491
|
_insert(e, n, o) {
|
|
1477
1492
|
const i = o ? e : this.toBBox(e), r = [], a = this._chooseSubtree(i, this.data, n, r);
|
|
1478
|
-
for (a.children.push(e),
|
|
1493
|
+
for (a.children.push(e), K(a, i); n >= 0 && r[n].children.length > this._maxEntries; )
|
|
1479
1494
|
this._split(r, n), n--;
|
|
1480
1495
|
this._adjustParentBBoxes(i, r, n);
|
|
1481
1496
|
}
|
|
@@ -1483,17 +1498,17 @@ class mn {
|
|
|
1483
1498
|
_split(e, n) {
|
|
1484
1499
|
const o = e[n], i = o.children.length, r = this._minEntries;
|
|
1485
1500
|
this._chooseSplitAxis(o, r, i);
|
|
1486
|
-
const a = this._chooseSplitIndex(o, r, i), s =
|
|
1487
|
-
s.height = o.height, s.leaf = o.leaf,
|
|
1501
|
+
const a = this._chooseSplitIndex(o, r, i), s = W(o.children.splice(a, o.children.length - a));
|
|
1502
|
+
s.height = o.height, s.leaf = o.leaf, F(o, this.toBBox), F(s, this.toBBox), n ? e[n - 1].children.push(s) : this._splitRoot(o, s);
|
|
1488
1503
|
}
|
|
1489
1504
|
_splitRoot(e, n) {
|
|
1490
|
-
this.data =
|
|
1505
|
+
this.data = W([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, F(this.data, this.toBBox);
|
|
1491
1506
|
}
|
|
1492
1507
|
_chooseSplitIndex(e, n, o) {
|
|
1493
1508
|
let i, r = 1 / 0, a = 1 / 0;
|
|
1494
1509
|
for (let s = n; s <= o - n; s++) {
|
|
1495
|
-
const u =
|
|
1496
|
-
|
|
1510
|
+
const u = G(e, 0, s, this.toBBox), h = G(e, s, o, this.toBBox), m = xn(u, h), c = ut(u) + ut(h);
|
|
1511
|
+
m < r ? (r = m, i = s, a = c < a ? c : a) : m === r && c < a && (a = c, i = s);
|
|
1497
1512
|
}
|
|
1498
1513
|
return i || o - n;
|
|
1499
1514
|
}
|
|
@@ -1505,25 +1520,25 @@ class mn {
|
|
|
1505
1520
|
// total margin of all possible split distributions where each node is at least m full
|
|
1506
1521
|
_allDistMargin(e, n, o, i) {
|
|
1507
1522
|
e.children.sort(i);
|
|
1508
|
-
const r = this.toBBox, a =
|
|
1509
|
-
let u =
|
|
1510
|
-
for (let
|
|
1511
|
-
const
|
|
1512
|
-
|
|
1523
|
+
const r = this.toBBox, a = G(e, 0, n, r), s = G(e, o - n, o, r);
|
|
1524
|
+
let u = et(a) + et(s);
|
|
1525
|
+
for (let h = n; h < o - n; h++) {
|
|
1526
|
+
const m = e.children[h];
|
|
1527
|
+
K(a, e.leaf ? r(m) : m), u += et(a);
|
|
1513
1528
|
}
|
|
1514
|
-
for (let
|
|
1515
|
-
const
|
|
1516
|
-
|
|
1529
|
+
for (let h = o - n - 1; h >= n; h--) {
|
|
1530
|
+
const m = e.children[h];
|
|
1531
|
+
K(s, e.leaf ? r(m) : m), u += et(s);
|
|
1517
1532
|
}
|
|
1518
1533
|
return u;
|
|
1519
1534
|
}
|
|
1520
1535
|
_adjustParentBBoxes(e, n, o) {
|
|
1521
1536
|
for (let i = o; i >= 0; i--)
|
|
1522
|
-
|
|
1537
|
+
K(n[i], e);
|
|
1523
1538
|
}
|
|
1524
1539
|
_condense(e) {
|
|
1525
1540
|
for (let n = e.length - 1, o; n >= 0; n--)
|
|
1526
|
-
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() :
|
|
1541
|
+
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : F(e[n], this.toBBox);
|
|
1527
1542
|
}
|
|
1528
1543
|
}
|
|
1529
1544
|
function bn(t, e, n) {
|
|
@@ -1534,18 +1549,18 @@ function bn(t, e, n) {
|
|
|
1534
1549
|
return o;
|
|
1535
1550
|
return -1;
|
|
1536
1551
|
}
|
|
1537
|
-
function
|
|
1538
|
-
|
|
1552
|
+
function F(t, e) {
|
|
1553
|
+
G(t, 0, t.children.length, e, t);
|
|
1539
1554
|
}
|
|
1540
|
-
function
|
|
1541
|
-
i || (i =
|
|
1555
|
+
function G(t, e, n, o, i) {
|
|
1556
|
+
i || (i = W(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
|
|
1542
1557
|
for (let r = e; r < n; r++) {
|
|
1543
1558
|
const a = t.children[r];
|
|
1544
|
-
|
|
1559
|
+
K(i, t.leaf ? o(a) : a);
|
|
1545
1560
|
}
|
|
1546
1561
|
return i;
|
|
1547
1562
|
}
|
|
1548
|
-
function
|
|
1563
|
+
function K(t, e) {
|
|
1549
1564
|
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;
|
|
1550
1565
|
}
|
|
1551
1566
|
function vn(t, e) {
|
|
@@ -1554,10 +1569,10 @@ function vn(t, e) {
|
|
|
1554
1569
|
function yn(t, e) {
|
|
1555
1570
|
return t.minY - e.minY;
|
|
1556
1571
|
}
|
|
1557
|
-
function
|
|
1572
|
+
function ut(t) {
|
|
1558
1573
|
return (t.maxX - t.minX) * (t.maxY - t.minY);
|
|
1559
1574
|
}
|
|
1560
|
-
function
|
|
1575
|
+
function et(t) {
|
|
1561
1576
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1562
1577
|
}
|
|
1563
1578
|
function wn(t, e) {
|
|
@@ -1567,13 +1582,13 @@ function xn(t, e) {
|
|
|
1567
1582
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);
|
|
1568
1583
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1569
1584
|
}
|
|
1570
|
-
function
|
|
1585
|
+
function ht(t, e) {
|
|
1571
1586
|
return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
|
|
1572
1587
|
}
|
|
1573
|
-
function
|
|
1588
|
+
function nt(t, e) {
|
|
1574
1589
|
return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
|
|
1575
1590
|
}
|
|
1576
|
-
function
|
|
1591
|
+
function W(t) {
|
|
1577
1592
|
return {
|
|
1578
1593
|
children: t,
|
|
1579
1594
|
height: 1,
|
|
@@ -1584,7 +1599,7 @@ function z(t) {
|
|
|
1584
1599
|
maxY: -1 / 0
|
|
1585
1600
|
};
|
|
1586
1601
|
}
|
|
1587
|
-
function
|
|
1602
|
+
function It(t, e, n, o, i) {
|
|
1588
1603
|
const r = [e, n];
|
|
1589
1604
|
for (; r.length; ) {
|
|
1590
1605
|
if (n = r.pop(), e = r.pop(), n - e <= o)
|
|
@@ -1594,130 +1609,130 @@ function Bt(t, e, n, o, i) {
|
|
|
1594
1609
|
}
|
|
1595
1610
|
}
|
|
1596
1611
|
const An = (t, e) => {
|
|
1597
|
-
const n = new mn(), o = /* @__PURE__ */ new Map(), i = (
|
|
1598
|
-
const y =
|
|
1599
|
-
const
|
|
1600
|
-
return Array.from(
|
|
1601
|
-
}), T = oe(y).map(({ left:
|
|
1602
|
-
return T.map((
|
|
1603
|
-
const { x: E, y:
|
|
1612
|
+
const n = new mn(), o = /* @__PURE__ */ new Map(), i = (l, d) => {
|
|
1613
|
+
const y = l.selector.flatMap((S) => {
|
|
1614
|
+
const N = S.range instanceof Range && !S.range.collapsed && S.range.startContainer.nodeType === Node.TEXT_NODE && S.range.endContainer.nodeType === Node.TEXT_NODE ? S.range : _t(S, e).range;
|
|
1615
|
+
return Array.from(N.getClientRects());
|
|
1616
|
+
}), T = oe(y).map(({ left: S, top: E, right: N, bottom: R }) => new DOMRect(S - d.left, E - d.top, N - S, R - E));
|
|
1617
|
+
return T.map((S) => {
|
|
1618
|
+
const { x: E, y: N, width: R, height: M } = S;
|
|
1604
1619
|
return {
|
|
1605
1620
|
minX: E,
|
|
1606
|
-
minY:
|
|
1607
|
-
maxX: E +
|
|
1608
|
-
maxY:
|
|
1621
|
+
minY: N,
|
|
1622
|
+
maxX: E + R,
|
|
1623
|
+
maxY: N + M,
|
|
1609
1624
|
annotation: {
|
|
1610
|
-
id:
|
|
1625
|
+
id: l.annotation,
|
|
1611
1626
|
rects: T
|
|
1612
1627
|
}
|
|
1613
1628
|
};
|
|
1614
1629
|
});
|
|
1615
1630
|
}, r = () => [...o.values()], a = () => {
|
|
1616
1631
|
n.clear(), o.clear();
|
|
1617
|
-
}, s = (
|
|
1618
|
-
const
|
|
1619
|
-
|
|
1620
|
-
}, u = (
|
|
1621
|
-
const
|
|
1622
|
-
|
|
1623
|
-
},
|
|
1624
|
-
u(
|
|
1625
|
-
},
|
|
1626
|
-
|
|
1627
|
-
const y = e.getBoundingClientRect(), T =
|
|
1628
|
-
T.forEach(({ target: E, rects:
|
|
1629
|
-
const
|
|
1630
|
-
n.load(
|
|
1631
|
-
},
|
|
1632
|
+
}, s = (l) => {
|
|
1633
|
+
const d = i(l, e.getBoundingClientRect());
|
|
1634
|
+
d.forEach((y) => n.insert(y)), o.set(l.annotation, d);
|
|
1635
|
+
}, u = (l) => {
|
|
1636
|
+
const d = o.get(l.annotation);
|
|
1637
|
+
d && (d.forEach((y) => n.remove(y)), o.delete(l.annotation));
|
|
1638
|
+
}, h = (l) => {
|
|
1639
|
+
u(l), s(l);
|
|
1640
|
+
}, m = (l, d = !0) => {
|
|
1641
|
+
d && a();
|
|
1642
|
+
const y = e.getBoundingClientRect(), T = l.map((E) => ({ target: E, rects: i(E, y) }));
|
|
1643
|
+
T.forEach(({ target: E, rects: N }) => o.set(E.annotation, N));
|
|
1644
|
+
const S = T.reduce((E, { rects: N }) => [...E, ...N], []);
|
|
1645
|
+
n.load(S);
|
|
1646
|
+
}, c = (l, d) => {
|
|
1632
1647
|
const y = n.search({
|
|
1633
|
-
minX:
|
|
1634
|
-
minY:
|
|
1635
|
-
maxX:
|
|
1636
|
-
maxY:
|
|
1637
|
-
}), T = (
|
|
1648
|
+
minX: l,
|
|
1649
|
+
minY: d,
|
|
1650
|
+
maxX: l,
|
|
1651
|
+
maxY: d
|
|
1652
|
+
}), T = (S) => S.annotation.rects.reduce((E, N) => E + N.width * N.height, 0);
|
|
1638
1653
|
if (y.length > 0)
|
|
1639
|
-
return y.sort((
|
|
1640
|
-
},
|
|
1641
|
-
const
|
|
1642
|
-
if (
|
|
1654
|
+
return y.sort((S, E) => T(S) - T(E)), y[0].annotation.id;
|
|
1655
|
+
}, g = (l) => {
|
|
1656
|
+
const d = p(l);
|
|
1657
|
+
if (d.length === 0)
|
|
1643
1658
|
return;
|
|
1644
|
-
let y =
|
|
1645
|
-
for (let
|
|
1646
|
-
const
|
|
1647
|
-
y = Math.min(y,
|
|
1659
|
+
let y = d[0].left, T = d[0].top, S = d[0].right, E = d[0].bottom;
|
|
1660
|
+
for (let N = 1; N < d.length; N++) {
|
|
1661
|
+
const R = d[N];
|
|
1662
|
+
y = Math.min(y, R.left), T = Math.min(T, R.top), S = Math.max(S, R.right), E = Math.max(E, R.bottom);
|
|
1648
1663
|
}
|
|
1649
|
-
return new DOMRect(y, T,
|
|
1650
|
-
}, p = (
|
|
1651
|
-
const
|
|
1652
|
-
return
|
|
1664
|
+
return new DOMRect(y, T, S - y, E - T);
|
|
1665
|
+
}, p = (l) => {
|
|
1666
|
+
const d = o.get(l);
|
|
1667
|
+
return d ? d[0].annotation.rects : [];
|
|
1653
1668
|
};
|
|
1654
1669
|
return {
|
|
1655
1670
|
all: r,
|
|
1656
1671
|
clear: a,
|
|
1657
|
-
getAt:
|
|
1658
|
-
getAnnotationBounds:
|
|
1672
|
+
getAt: c,
|
|
1673
|
+
getAnnotationBounds: g,
|
|
1659
1674
|
getAnnotationRects: p,
|
|
1660
|
-
getIntersecting: (
|
|
1661
|
-
const
|
|
1662
|
-
return Array.from(E).map((
|
|
1663
|
-
annotation: t.getAnnotation(
|
|
1664
|
-
rects: p(
|
|
1665
|
-
})).filter((
|
|
1675
|
+
getIntersecting: (l, d, y, T) => {
|
|
1676
|
+
const S = n.search({ minX: l, minY: d, maxX: y, maxY: T }), E = new Set(S.reduce((N, R) => [...N, R.annotation.id], []));
|
|
1677
|
+
return Array.from(E).map((N) => ({
|
|
1678
|
+
annotation: t.getAnnotation(N),
|
|
1679
|
+
rects: p(N)
|
|
1680
|
+
})).filter((N) => !!N.annotation);
|
|
1666
1681
|
},
|
|
1667
1682
|
insert: s,
|
|
1668
|
-
recalculate: () =>
|
|
1683
|
+
recalculate: () => m(t.all().map((l) => l.target), !0),
|
|
1669
1684
|
remove: u,
|
|
1670
|
-
set:
|
|
1685
|
+
set: m,
|
|
1671
1686
|
size: () => n.all().length,
|
|
1672
|
-
update:
|
|
1687
|
+
update: h
|
|
1673
1688
|
};
|
|
1674
1689
|
}, En = (t, e) => {
|
|
1675
|
-
const n = We(), o = An(n, t), i = Ie(n, e), r = Be(n), a = Ke(), s = (
|
|
1676
|
-
const
|
|
1677
|
-
return
|
|
1678
|
-
}, u = (
|
|
1679
|
-
const
|
|
1680
|
-
return y.length > 0 ? (console.warn("Could not revive all targets for these annotations:", y), n.bulkAddAnnotation(
|
|
1681
|
-
},
|
|
1682
|
-
const
|
|
1683
|
-
return
|
|
1684
|
-
n.getAnnotation(y.id) ? n.updateAnnotation(y,
|
|
1685
|
-
}),
|
|
1686
|
-
},
|
|
1687
|
-
const
|
|
1688
|
-
n.updateTarget(
|
|
1689
|
-
},
|
|
1690
|
-
const
|
|
1691
|
-
n.bulkUpdateTargets(
|
|
1692
|
-
},
|
|
1693
|
-
const
|
|
1694
|
-
return
|
|
1695
|
-
}, p = (
|
|
1696
|
-
const y = o.getAnnotationRects(
|
|
1690
|
+
const n = We(), o = An(n, t), i = Ie(n, e), r = Be(n), a = Ke(), s = (b, f = B.LOCAL) => {
|
|
1691
|
+
const l = rt(b, t), d = $(l.target.selector);
|
|
1692
|
+
return d && n.addAnnotation(l, f), d;
|
|
1693
|
+
}, u = (b, f = !0, l = B.LOCAL) => {
|
|
1694
|
+
const d = b.map((T) => rt(T, t)), y = d.filter((T) => !$(T.target.selector));
|
|
1695
|
+
return y.length > 0 ? (console.warn("Could not revive all targets for these annotations:", y), n.bulkAddAnnotation(d, f, l), y) : (n.bulkAddAnnotation(d, f, l), []);
|
|
1696
|
+
}, h = (b, f = B.LOCAL) => {
|
|
1697
|
+
const l = b.map((y) => rt(y, t)), d = l.filter((y) => !$(y.target.selector));
|
|
1698
|
+
return d.length > 0 && console.warn("Could not revive all targets for these annotations:", d), l.forEach((y) => {
|
|
1699
|
+
n.getAnnotation(y.id) ? n.updateAnnotation(y, f) : n.addAnnotation(y, f);
|
|
1700
|
+
}), d;
|
|
1701
|
+
}, m = (b, f = B.LOCAL) => {
|
|
1702
|
+
const l = it(b, t);
|
|
1703
|
+
n.updateTarget(l, f);
|
|
1704
|
+
}, c = (b, f = B.LOCAL) => {
|
|
1705
|
+
const l = b.map((d) => it(d, t));
|
|
1706
|
+
n.bulkUpdateTargets(l, f);
|
|
1707
|
+
}, g = (b, f) => {
|
|
1708
|
+
const l = o.getAt(b, f);
|
|
1709
|
+
return l ? n.getAnnotation(l) : void 0;
|
|
1710
|
+
}, p = (b, f, l, d = 5) => {
|
|
1711
|
+
const y = o.getAnnotationRects(b);
|
|
1697
1712
|
if (y.length !== 0) {
|
|
1698
|
-
if (
|
|
1699
|
-
const T = y.find(({ top:
|
|
1713
|
+
if (f && l) {
|
|
1714
|
+
const T = y.find(({ top: S, right: E, bottom: N, left: R }) => f >= R - d && f <= E + d && l >= S - d && l <= N + d);
|
|
1700
1715
|
if (T)
|
|
1701
1716
|
return T;
|
|
1702
1717
|
}
|
|
1703
|
-
return o.getAnnotationBounds(
|
|
1718
|
+
return o.getAnnotationBounds(b);
|
|
1704
1719
|
}
|
|
1705
|
-
},
|
|
1706
|
-
return n.observe(({ changes:
|
|
1707
|
-
const
|
|
1708
|
-
|
|
1720
|
+
}, x = () => o.recalculate();
|
|
1721
|
+
return n.observe(({ changes: b }) => {
|
|
1722
|
+
const f = (b.created || []).filter((y) => $(y.target.selector)), l = (b.deleted || []).filter((y) => $(y.target.selector)), d = (b.updated || []).filter((y) => $(y.newValue.target.selector));
|
|
1723
|
+
f.length > 0 && o.set(f.map((y) => y.target), !1), (l == null ? void 0 : l.length) > 0 && l.forEach((y) => o.remove(y.target)), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: y }) => o.update(y.target));
|
|
1709
1724
|
}), {
|
|
1710
1725
|
store: {
|
|
1711
1726
|
...n,
|
|
1712
1727
|
addAnnotation: s,
|
|
1713
1728
|
bulkAddAnnotation: u,
|
|
1714
|
-
bulkUpdateTargets:
|
|
1715
|
-
bulkUpsertAnnotations:
|
|
1729
|
+
bulkUpdateTargets: c,
|
|
1730
|
+
bulkUpsertAnnotations: h,
|
|
1716
1731
|
getAnnotationBounds: p,
|
|
1717
|
-
getAt:
|
|
1732
|
+
getAt: g,
|
|
1718
1733
|
getIntersecting: o.getIntersecting,
|
|
1719
|
-
recalculatePositions:
|
|
1720
|
-
updateTarget:
|
|
1734
|
+
recalculatePositions: x,
|
|
1735
|
+
updateTarget: m
|
|
1721
1736
|
},
|
|
1722
1737
|
selection: i,
|
|
1723
1738
|
hover: r,
|
|
@@ -1731,150 +1746,155 @@ const An = (t, e) => {
|
|
|
1731
1746
|
}, Cn = (t, e, n = {}) => {
|
|
1732
1747
|
const o = Sn(), i = o.getContext("2d");
|
|
1733
1748
|
t.appendChild(o);
|
|
1734
|
-
const r = /* @__PURE__ */ new Map(), a = (
|
|
1735
|
-
return e.on("selectionChange", (
|
|
1736
|
-
a(
|
|
1749
|
+
const r = /* @__PURE__ */ new Map(), a = (c) => Array.from(r.entries()).filter(([g, p]) => p.presenceKey === c.presenceKey).map(([g, p]) => g);
|
|
1750
|
+
return e.on("selectionChange", (c, g) => {
|
|
1751
|
+
a(c).forEach((x) => r.delete(x)), g && g.forEach((x) => r.set(x, c));
|
|
1737
1752
|
}), {
|
|
1738
1753
|
clear: () => {
|
|
1739
|
-
const { width:
|
|
1740
|
-
i.clearRect(-0.5, -0.5,
|
|
1754
|
+
const { width: c, height: g } = o;
|
|
1755
|
+
i.clearRect(-0.5, -0.5, c + 1, g + 1);
|
|
1741
1756
|
},
|
|
1742
1757
|
destroy: () => {
|
|
1743
1758
|
o.remove();
|
|
1744
1759
|
},
|
|
1745
|
-
paint: (
|
|
1760
|
+
paint: (c, g, p) => {
|
|
1746
1761
|
n.font && (i.font = n.font);
|
|
1747
|
-
const
|
|
1748
|
-
if (
|
|
1749
|
-
const { height:
|
|
1750
|
-
i.fillStyle =
|
|
1751
|
-
const
|
|
1752
|
-
return i.fillRect(
|
|
1753
|
-
fill:
|
|
1762
|
+
const x = r.get(c.annotation.id);
|
|
1763
|
+
if (x) {
|
|
1764
|
+
const { height: b } = c.rects[0], f = c.rects[0].x + g.left, l = c.rects[0].y + g.top;
|
|
1765
|
+
i.fillStyle = x.appearance.color, i.fillRect(f - 2, l - 2.5, 2, b + 5);
|
|
1766
|
+
const d = i.measureText(x.appearance.label), y = d.width + 6, T = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1767
|
+
return i.fillRect(f - 2, l - 2.5 - T, y, T), i.fillStyle = "#fff", i.fillText(x.appearance.label, f + 1, l - S), {
|
|
1768
|
+
fill: x.appearance.color,
|
|
1754
1769
|
fillOpacity: p ? 0.45 : 0.18
|
|
1755
1770
|
};
|
|
1756
1771
|
}
|
|
1757
1772
|
},
|
|
1758
1773
|
reset: () => {
|
|
1759
1774
|
o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
|
|
1760
|
-
const
|
|
1761
|
-
|
|
1775
|
+
const c = o.getContext("2d");
|
|
1776
|
+
c.scale(2, 2), c.translate(0.5, 0.5);
|
|
1762
1777
|
}
|
|
1763
1778
|
};
|
|
1764
|
-
},
|
|
1779
|
+
}, Pt = (t) => {
|
|
1765
1780
|
if (t === null)
|
|
1766
1781
|
return document.scrollingElement;
|
|
1767
1782
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
1768
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
1783
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Pt(t.parentElement);
|
|
1769
1784
|
}, Tn = (t, e) => (n) => {
|
|
1770
1785
|
const o = (r) => {
|
|
1771
|
-
const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth,
|
|
1772
|
-
i.scroll({ top:
|
|
1773
|
-
}, i =
|
|
1786
|
+
const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: m, height: c } = e.getAnnotationBounds(n.id), g = h.top - a.top, p = h.left - a.left, x = i.parentElement ? i.scrollTop : 0, b = i.parentElement ? i.scrollLeft : 0, f = g + x - (s - c) / 2, l = p + b - (u - m) / 2;
|
|
1787
|
+
i.scroll({ top: f, left: l, behavior: "smooth" });
|
|
1788
|
+
}, i = Pt(t);
|
|
1774
1789
|
if (i) {
|
|
1775
1790
|
const r = e.getAnnotation(n.id), { range: a } = r.target.selector[0];
|
|
1776
1791
|
if (a && !a.collapsed)
|
|
1777
1792
|
return o(r.target), !0;
|
|
1778
1793
|
{
|
|
1779
|
-
const s =
|
|
1794
|
+
const s = it(r.target, t), { range: u } = s.selector[0];
|
|
1780
1795
|
if (u && !u.collapsed)
|
|
1781
1796
|
return o(s), !0;
|
|
1782
1797
|
}
|
|
1783
1798
|
}
|
|
1784
1799
|
return !1;
|
|
1785
|
-
},
|
|
1800
|
+
}, Nn = (t, e) => ({
|
|
1786
1801
|
...t,
|
|
1787
1802
|
annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled
|
|
1788
|
-
}),
|
|
1803
|
+
}), Rn = (t, e, n, o) => {
|
|
1789
1804
|
const { store: i, selection: r } = e;
|
|
1790
1805
|
let a, s;
|
|
1791
|
-
const u = (
|
|
1792
|
-
let
|
|
1793
|
-
const
|
|
1794
|
-
var
|
|
1795
|
-
if (!
|
|
1806
|
+
const u = (f) => a = f;
|
|
1807
|
+
let h = !1, m;
|
|
1808
|
+
const c = (f) => {
|
|
1809
|
+
var d;
|
|
1810
|
+
if (!h)
|
|
1796
1811
|
return;
|
|
1797
|
-
!((
|
|
1798
|
-
annotation:
|
|
1812
|
+
!((d = f.target.parentElement) != null && d.closest(X)) ? s = {
|
|
1813
|
+
annotation: kt(),
|
|
1799
1814
|
selector: [],
|
|
1800
1815
|
creator: a,
|
|
1801
1816
|
created: /* @__PURE__ */ new Date()
|
|
1802
1817
|
} : s = void 0;
|
|
1803
1818
|
};
|
|
1804
|
-
n && t.addEventListener("selectstart",
|
|
1805
|
-
const
|
|
1806
|
-
|
|
1807
|
-
|
|
1819
|
+
n && t.addEventListener("selectstart", c);
|
|
1820
|
+
const g = gt((f) => {
|
|
1821
|
+
var N, R;
|
|
1822
|
+
const l = document.getSelection();
|
|
1823
|
+
if (!!((R = (N = l.anchorNode) == null ? void 0 : N.parentElement) != null && R.closest(X))) {
|
|
1824
|
+
s = void 0;
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
if (f.timeStamp - ((m == null ? void 0 : m.timeStamp) || f.timeStamp) < 1e3 && !s && c(m), l.isCollapsed || !h || !s)
|
|
1808
1828
|
return;
|
|
1809
|
-
const
|
|
1810
|
-
(
|
|
1811
|
-
var
|
|
1812
|
-
return
|
|
1829
|
+
const y = l.getRangeAt(0), T = re(y.cloneRange()), S = Kt(T);
|
|
1830
|
+
(S.length !== s.selector.length || S.some((M, v) => {
|
|
1831
|
+
var w;
|
|
1832
|
+
return M.toString() !== ((w = s.selector[v]) == null ? void 0 : w.quote);
|
|
1813
1833
|
})) && (s = {
|
|
1814
1834
|
...s,
|
|
1815
|
-
selector:
|
|
1816
|
-
}, i.getAnnotation(s.annotation) ? i.updateTarget(s,
|
|
1835
|
+
selector: S.map((M) => ie(M, t, o))
|
|
1836
|
+
}, i.getAnnotation(s.annotation) ? i.updateTarget(s, B.LOCAL) : (i.addAnnotation({
|
|
1817
1837
|
id: s.annotation,
|
|
1818
1838
|
bodies: [],
|
|
1819
1839
|
target: s
|
|
1820
|
-
}), r.clickSelect(s.annotation,
|
|
1840
|
+
}), r.clickSelect(s.annotation, m)));
|
|
1821
1841
|
});
|
|
1822
|
-
n && document.addEventListener("selectionchange",
|
|
1823
|
-
const p = (
|
|
1824
|
-
const { target:
|
|
1825
|
-
|
|
1842
|
+
n && document.addEventListener("selectionchange", g);
|
|
1843
|
+
const p = (f) => {
|
|
1844
|
+
const { target: l, timeStamp: d, offsetX: y, offsetY: T, type: S } = f;
|
|
1845
|
+
m = { ...f, target: l, timeStamp: d, offsetX: y, offsetY: T, type: S }, h = f.button === 0;
|
|
1826
1846
|
};
|
|
1827
1847
|
t.addEventListener("pointerdown", p);
|
|
1828
|
-
const
|
|
1848
|
+
const x = (f) => {
|
|
1829
1849
|
var T;
|
|
1830
|
-
if (!!((T =
|
|
1850
|
+
if (!!((T = f.target.parentElement) != null && T.closest(X)) || !h)
|
|
1831
1851
|
return;
|
|
1832
|
-
const
|
|
1833
|
-
const { x:
|
|
1834
|
-
if (
|
|
1835
|
-
const { selected:
|
|
1836
|
-
(
|
|
1852
|
+
const d = () => {
|
|
1853
|
+
const { x: S, y: E } = t.getBoundingClientRect(), N = i.getAt(f.clientX - S, f.clientY - E);
|
|
1854
|
+
if (N) {
|
|
1855
|
+
const { selected: R } = r;
|
|
1856
|
+
(R.length !== 1 || R[0].id !== N.id) && r.clickSelect(N.id, f);
|
|
1837
1857
|
} else
|
|
1838
1858
|
r.isEmpty() || r.clear();
|
|
1839
|
-
}, y =
|
|
1840
|
-
document.getSelection().isCollapsed && y < 300 ? (s = void 0,
|
|
1859
|
+
}, y = f.timeStamp - m.timeStamp;
|
|
1860
|
+
document.getSelection().isCollapsed && y < 300 ? (s = void 0, d()) : s && r.clickSelect(s.annotation, f);
|
|
1841
1861
|
};
|
|
1842
|
-
return document.addEventListener("pointerup",
|
|
1862
|
+
return document.addEventListener("pointerup", x), {
|
|
1843
1863
|
destroy: () => {
|
|
1844
|
-
t.removeEventListener("selectstart",
|
|
1864
|
+
t.removeEventListener("selectstart", c), document.removeEventListener("selectionchange", g), t.removeEventListener("pointerdown", p), document.removeEventListener("pointerup", x);
|
|
1845
1865
|
},
|
|
1846
1866
|
setUser: u
|
|
1847
1867
|
};
|
|
1848
|
-
},
|
|
1868
|
+
}, Mt = "SPANS", Mn = (t, e = {}) => {
|
|
1849
1869
|
Qt(t);
|
|
1850
|
-
const n =
|
|
1870
|
+
const n = Nn(e, {
|
|
1851
1871
|
annotationEnabled: !0
|
|
1852
1872
|
}), o = En(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Ge(a), u = Qe(o, s, n.adapter);
|
|
1853
|
-
let
|
|
1854
|
-
const
|
|
1855
|
-
if (!
|
|
1856
|
-
throw `Unknown renderer implementation: ${
|
|
1857
|
-
console.debug(`Using ${
|
|
1858
|
-
const
|
|
1859
|
-
return
|
|
1873
|
+
let h = sn();
|
|
1874
|
+
const m = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Mt : n.renderer || Mt, c = m === "SPANS" ? Se(t, o, r) : m === "CSS_HIGHLIGHTS" ? xe(t, o, r) : m === "CANVAS" ? ue(t, o, r) : void 0;
|
|
1875
|
+
if (!c)
|
|
1876
|
+
throw `Unknown renderer implementation: ${m}`;
|
|
1877
|
+
console.debug(`Using ${m} renderer`), n.style && c.setStyle(n.style);
|
|
1878
|
+
const g = Rn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
|
|
1879
|
+
return g.setUser(h), {
|
|
1860
1880
|
...Ze(o, s, n.adapter),
|
|
1861
1881
|
destroy: () => {
|
|
1862
|
-
|
|
1882
|
+
c.destroy(), g.destroy(), s.destroy();
|
|
1863
1883
|
},
|
|
1864
1884
|
element: t,
|
|
1865
|
-
getUser: () =>
|
|
1866
|
-
setFilter: (E) =>
|
|
1867
|
-
setStyle: (E) =>
|
|
1885
|
+
getUser: () => h,
|
|
1886
|
+
setFilter: (E) => c.setFilter(E),
|
|
1887
|
+
setStyle: (E) => c.setStyle(E),
|
|
1868
1888
|
setUser: (E) => {
|
|
1869
|
-
|
|
1889
|
+
h = E, g.setUser(E);
|
|
1870
1890
|
},
|
|
1871
1891
|
setSelected: (E) => {
|
|
1872
1892
|
E ? i.setSelected(E) : i.clear();
|
|
1873
1893
|
},
|
|
1874
1894
|
setPresenceProvider: (E) => {
|
|
1875
|
-
E && (
|
|
1895
|
+
E && (c.setPainter(Cn(t, E, n.presence)), E.on("selectionChange", () => c.redraw()));
|
|
1876
1896
|
},
|
|
1877
|
-
setVisible: (E) =>
|
|
1897
|
+
setVisible: (E) => c.setVisible(E),
|
|
1878
1898
|
on: u.on,
|
|
1879
1899
|
off: u.off,
|
|
1880
1900
|
scrollIntoView: Tn(t, a),
|
|
@@ -1882,11 +1902,11 @@ const An = (t, e) => {
|
|
|
1882
1902
|
};
|
|
1883
1903
|
};
|
|
1884
1904
|
export {
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1905
|
+
ot as DEFAULT_SELECTED_STYLE,
|
|
1906
|
+
P as DEFAULT_STYLE,
|
|
1907
|
+
Vt as NOT_ANNOTATABLE_CLASS,
|
|
1908
|
+
X as NOT_ANNOTATABLE_SELECTOR,
|
|
1909
|
+
B as Origin,
|
|
1890
1910
|
Oe as PointerSelectAction,
|
|
1891
1911
|
In as W3CTextFormat,
|
|
1892
1912
|
Qt as cancelSingleClickEvents,
|
|
@@ -1897,20 +1917,20 @@ export {
|
|
|
1897
1917
|
Se as createSpansRenderer,
|
|
1898
1918
|
Mn as createTextAnnotator,
|
|
1899
1919
|
En as createTextAnnotatorState,
|
|
1900
|
-
|
|
1901
|
-
|
|
1920
|
+
gt as debounce,
|
|
1921
|
+
Nn as fillDefaults,
|
|
1902
1922
|
Ln as getAnnotatableFragment,
|
|
1903
1923
|
Bn as getClientRectsPonyfill,
|
|
1904
1924
|
te as getQuoteContext,
|
|
1905
|
-
|
|
1906
|
-
|
|
1925
|
+
ft as getRangeAnnotatableContents,
|
|
1926
|
+
$ as isRevived,
|
|
1907
1927
|
oe as mergeClientRects,
|
|
1908
1928
|
qt as paint,
|
|
1909
1929
|
hn as parseW3CTextAnnotation,
|
|
1910
1930
|
ie as rangeToSelector,
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1931
|
+
rt as reviveAnnotation,
|
|
1932
|
+
_t as reviveSelector,
|
|
1933
|
+
it as reviveTarget,
|
|
1914
1934
|
fn as serializeW3CTextAnnotation,
|
|
1915
1935
|
Kt as splitAnnotatableRanges,
|
|
1916
1936
|
re as trimRange
|