@soomo/text-annotator 3.0.0-staging.6 → 3.0.0-staging.8
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.
|
@@ -4,7 +4,7 @@ const $ = {
|
|
|
4
4
|
}, ht = {
|
|
5
5
|
fill: "rgb(0, 128, 255)",
|
|
6
6
|
fillOpacity: 0.45
|
|
7
|
-
},
|
|
7
|
+
}, qt = (t, e, n, o, i) => {
|
|
8
8
|
var a;
|
|
9
9
|
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (a = t.state) != null && a.selected ? ht : $;
|
|
10
10
|
return o && o.paint(t, e) || r;
|
|
@@ -13,11 +13,11 @@ const $ = {
|
|
|
13
13
|
return (...o) => {
|
|
14
14
|
clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
|
|
15
15
|
};
|
|
16
|
-
}, Ot = "not-annotatable", D = `.${Ot}`,
|
|
16
|
+
}, Ot = "not-annotatable", D = `.${Ot}`, jt = (t) => {
|
|
17
17
|
var n;
|
|
18
18
|
const e = t.commonAncestorContainer;
|
|
19
19
|
return e instanceof HTMLElement ? !e.closest(D) : !((n = e.parentElement) != null && n.closest(D));
|
|
20
|
-
},
|
|
20
|
+
}, Gt = function* (t) {
|
|
21
21
|
const e = document.createNodeIterator(
|
|
22
22
|
t.commonAncestorContainer,
|
|
23
23
|
NodeFilter.SHOW_ELEMENT,
|
|
@@ -26,12 +26,12 @@ const $ = {
|
|
|
26
26
|
let n;
|
|
27
27
|
for (; n = e.nextNode(); )
|
|
28
28
|
n instanceof HTMLElement && (yield n);
|
|
29
|
-
},
|
|
30
|
-
if (!
|
|
29
|
+
}, Kt = (t) => {
|
|
30
|
+
if (!jt(t))
|
|
31
31
|
return [];
|
|
32
32
|
const e = [];
|
|
33
33
|
let n = null;
|
|
34
|
-
for (const o of
|
|
34
|
+
for (const o of Gt(t)) {
|
|
35
35
|
let i;
|
|
36
36
|
n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
|
|
37
37
|
}
|
|
@@ -43,7 +43,7 @@ const $ = {
|
|
|
43
43
|
}, dt = (t) => {
|
|
44
44
|
const e = t.cloneContents();
|
|
45
45
|
return e.querySelectorAll(D).forEach((n) => n.remove()), e;
|
|
46
|
-
},
|
|
46
|
+
}, Rn = (t) => {
|
|
47
47
|
const e = t.cloneContents();
|
|
48
48
|
return e.querySelectorAll(D).forEach((n) => n.remove()), e;
|
|
49
49
|
}, mt = (t, e) => {
|
|
@@ -60,7 +60,7 @@ const $ = {
|
|
|
60
60
|
for (let i = 0; i < t + 1; i++)
|
|
61
61
|
o = n.nextNode();
|
|
62
62
|
return o;
|
|
63
|
-
},
|
|
63
|
+
}, Qt = (t) => {
|
|
64
64
|
const {
|
|
65
65
|
commonAncestorContainer: e,
|
|
66
66
|
startContainer: n,
|
|
@@ -73,8 +73,8 @@ const $ = {
|
|
|
73
73
|
}), s = mt(n, e), u = mt(i, e), f = () => {
|
|
74
74
|
const l = e;
|
|
75
75
|
l.replaceChildren(...a);
|
|
76
|
-
const m = bt(s, l),
|
|
77
|
-
return t.setStart(m, o), t.setEnd(
|
|
76
|
+
const m = bt(s, l), g = bt(u, l);
|
|
77
|
+
return t.setStart(m, o), t.setEnd(g, r), t;
|
|
78
78
|
}, b = (l) => {
|
|
79
79
|
const m = document.createElement("SPAN");
|
|
80
80
|
return l.surroundContents(m), m;
|
|
@@ -84,16 +84,16 @@ const $ = {
|
|
|
84
84
|
{
|
|
85
85
|
const l = document.createRange();
|
|
86
86
|
l.selectNodeContents(n), l.setStart(n, o);
|
|
87
|
-
const m = b(l),
|
|
88
|
-
|
|
89
|
-
const y = b(
|
|
87
|
+
const m = b(l), g = document.createRange();
|
|
88
|
+
g.selectNode(i), g.setEnd(i, r);
|
|
89
|
+
const y = b(g), h = Jt(t).reverse().map((d) => {
|
|
90
90
|
var w;
|
|
91
91
|
const c = document.createElement("SPAN");
|
|
92
92
|
return (w = d.parentNode) == null || w.insertBefore(c, d), c.appendChild(d), c;
|
|
93
93
|
});
|
|
94
94
|
return { unwrap: f, nodes: [m, ...h, y] };
|
|
95
95
|
}
|
|
96
|
-
},
|
|
96
|
+
}, Jt = (t) => {
|
|
97
97
|
const {
|
|
98
98
|
commonAncestorContainer: e,
|
|
99
99
|
startContainer: n,
|
|
@@ -104,15 +104,15 @@ const $ = {
|
|
|
104
104
|
for (; r != null; )
|
|
105
105
|
r === o && (a = !1), a && s.push(r), r === n && (a = !0), r = i.nextNode();
|
|
106
106
|
return s;
|
|
107
|
-
},
|
|
107
|
+
}, In = (t) => {
|
|
108
108
|
const { startContainer: e, endContainer: n } = t;
|
|
109
109
|
if (e === n)
|
|
110
110
|
return Array.from(t.getClientRects());
|
|
111
111
|
{
|
|
112
|
-
const { unwrap: o, nodes: i } =
|
|
112
|
+
const { unwrap: o, nodes: i } = Qt(t), r = i.reduce((a, s) => [...a, ...s.getClientRects()], []);
|
|
113
113
|
return o(), r;
|
|
114
114
|
}
|
|
115
|
-
},
|
|
115
|
+
}, Zt = (t, e, n = 10, o) => {
|
|
116
116
|
const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
|
|
117
117
|
r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
118
118
|
const a = dt(r).textContent, s = document.createRange();
|
|
@@ -122,7 +122,7 @@ const $ = {
|
|
|
122
122
|
prefix: a.substring(a.length - n),
|
|
123
123
|
suffix: u.substring(0, n)
|
|
124
124
|
};
|
|
125
|
-
},
|
|
125
|
+
}, te = /^\s*$/, ee = (t) => te.test(t.toString()), X = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ne = (t, e) => {
|
|
126
126
|
const n = (r) => Math.round(r * 10) / 10, o = {
|
|
127
127
|
top: n(t.top),
|
|
128
128
|
bottom: n(t.bottom),
|
|
@@ -146,17 +146,17 @@ const $ = {
|
|
|
146
146
|
return "block-contains";
|
|
147
147
|
} else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
|
|
148
148
|
return "block-is-contained";
|
|
149
|
-
},
|
|
149
|
+
}, oe = (t, e) => {
|
|
150
150
|
const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), r = Math.max(t.bottom, e.bottom);
|
|
151
151
|
return new DOMRect(n, i, o - n, r - i);
|
|
152
|
-
},
|
|
152
|
+
}, ie = (t) => t.reduce((e, n) => {
|
|
153
153
|
if (n.width === 0 || n.height === 0)
|
|
154
154
|
return e;
|
|
155
155
|
let o = [...e], i = !1;
|
|
156
156
|
for (const r of e) {
|
|
157
|
-
const a =
|
|
157
|
+
const a = ne(n, r);
|
|
158
158
|
if (a === "inline-adjacent") {
|
|
159
|
-
o = o.map((s) => s === r ?
|
|
159
|
+
o = o.map((s) => s === r ? oe(n, r) : s), i = !0;
|
|
160
160
|
break;
|
|
161
161
|
} else if (a === "inline-contains") {
|
|
162
162
|
o = o.map((s) => s === r ? n : s), i = !0;
|
|
@@ -170,7 +170,7 @@ const $ = {
|
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
172
|
return i ? o : [...o, n];
|
|
173
|
-
}, []),
|
|
173
|
+
}, []), re = (t, e, n) => {
|
|
174
174
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
175
175
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
176
176
|
const r = dt(o).textContent, a = t.toString(), s = r.length || 0, u = s + a.length;
|
|
@@ -181,8 +181,8 @@ const $ = {
|
|
|
181
181
|
e,
|
|
182
182
|
NodeFilter.SHOW_TEXT,
|
|
183
183
|
(m) => {
|
|
184
|
-
var
|
|
185
|
-
return (
|
|
184
|
+
var g;
|
|
185
|
+
return (g = m.parentElement) != null && g.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
186
186
|
}
|
|
187
187
|
);
|
|
188
188
|
let a = 0;
|
|
@@ -216,36 +216,36 @@ const $ = {
|
|
|
216
216
|
}, et = (t, e) => X(t.selector) ? t : {
|
|
217
217
|
...t,
|
|
218
218
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Nt(n, e))
|
|
219
|
-
}, nt = (t, e) => X(t.target.selector) ? t : { ...t, target: et(t.target, e) },
|
|
219
|
+
}, nt = (t, e) => X(t.target.selector) ? t : { ...t, target: et(t.target, e) }, se = (t) => {
|
|
220
220
|
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, u = i - e;
|
|
221
221
|
return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: u };
|
|
222
|
-
},
|
|
222
|
+
}, ae = (t) => {
|
|
223
223
|
let e = /* @__PURE__ */ new Set();
|
|
224
224
|
return (o) => {
|
|
225
225
|
const i = o.map((r) => r.id);
|
|
226
226
|
(e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
|
|
227
227
|
};
|
|
228
|
-
},
|
|
228
|
+
}, gt = (t, e, n, o) => {
|
|
229
229
|
const { store: i, selection: r, hover: a } = e;
|
|
230
230
|
let s, u, f;
|
|
231
|
-
const b =
|
|
232
|
-
const { x: A, y: x } = t.getBoundingClientRect(), S = i.getAt(
|
|
231
|
+
const b = ae(n), l = (p) => {
|
|
232
|
+
const { x: A, y: x } = t.getBoundingClientRect(), S = i.getAt(p.clientX - A, p.clientY - x);
|
|
233
233
|
S && (!u || u(S)) ? a.current !== S.id && (t.classList.add("hovered"), a.set(S.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
|
|
234
234
|
};
|
|
235
235
|
t.addEventListener("pointermove", l);
|
|
236
|
-
const m = (
|
|
236
|
+
const m = (p = !1) => {
|
|
237
237
|
f && f.clear();
|
|
238
|
-
const A =
|
|
239
|
-
const
|
|
240
|
-
return { annotation: Y, rects:
|
|
238
|
+
const A = se(t), { minX: x, minY: S, maxX: B, maxY: I } = A, k = u ? i.getIntersecting(x, S, B, I).filter(({ annotation: Y }) => u(Y)) : i.getIntersecting(x, S, B, I), Ht = r.selected.map(({ id: Y }) => Y), Pt = k.map(({ annotation: Y, rects: zt }) => {
|
|
239
|
+
const Ft = Ht.includes(Y.id), Wt = Y.id === a.current;
|
|
240
|
+
return { annotation: Y, rects: zt, state: { selected: Ft, hover: Wt, custom: {} } };
|
|
241
241
|
});
|
|
242
|
-
o.redraw(
|
|
243
|
-
},
|
|
244
|
-
f =
|
|
245
|
-
}, y = (
|
|
246
|
-
s =
|
|
247
|
-
}, v = (
|
|
248
|
-
u =
|
|
242
|
+
o.redraw(Pt, A, s, f, p), setTimeout(() => b(k.map(({ annotation: Y }) => Y)), 1);
|
|
243
|
+
}, g = (p) => {
|
|
244
|
+
f = p, m();
|
|
245
|
+
}, y = (p) => {
|
|
246
|
+
s = p, m();
|
|
247
|
+
}, v = (p) => {
|
|
248
|
+
u = p, m(!1);
|
|
249
249
|
}, h = () => m();
|
|
250
250
|
i.observe(h);
|
|
251
251
|
const d = r.subscribe(() => m()), c = () => m(!0);
|
|
@@ -256,8 +256,8 @@ const $ = {
|
|
|
256
256
|
window.addEventListener("resize", w);
|
|
257
257
|
const L = new ResizeObserver(w);
|
|
258
258
|
L.observe(t);
|
|
259
|
-
const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((
|
|
260
|
-
|
|
259
|
+
const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((p) => {
|
|
260
|
+
p.every((x) => x.target === t || t.contains(x.target)) || m(!0);
|
|
261
261
|
});
|
|
262
262
|
return E.observe(document.body, C), {
|
|
263
263
|
destroy: () => {
|
|
@@ -266,49 +266,49 @@ const $ = {
|
|
|
266
266
|
redraw: m,
|
|
267
267
|
setStyle: y,
|
|
268
268
|
setFilter: v,
|
|
269
|
-
setPainter:
|
|
269
|
+
setPainter: g,
|
|
270
270
|
setVisible: o.setVisible
|
|
271
271
|
};
|
|
272
|
-
},
|
|
272
|
+
}, le = () => {
|
|
273
273
|
const t = document.createElement("canvas");
|
|
274
274
|
return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
|
|
275
|
-
},
|
|
275
|
+
}, ce = (t, e) => {
|
|
276
276
|
t.width = window.innerWidth, t.height = window.innerHeight;
|
|
277
|
-
},
|
|
277
|
+
}, de = (t) => {
|
|
278
278
|
t.classList.add("r6o-annotatable");
|
|
279
|
-
const e =
|
|
279
|
+
const e = le(), n = e.getContext("2d");
|
|
280
280
|
t.insertBefore(e, t.firstChild);
|
|
281
281
|
const o = (s, u, f, b) => requestAnimationFrame(() => {
|
|
282
282
|
const { width: l, height: m } = e;
|
|
283
283
|
n.clearRect(-0.5, -0.5, l + 1, m + 1), b && b.clear();
|
|
284
|
-
const { top:
|
|
284
|
+
const { top: g, left: y } = u;
|
|
285
285
|
s.forEach((v) => {
|
|
286
286
|
var L;
|
|
287
|
-
const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (L = v.state) != null && L.selected ? ht : $, d = b && b.paint(v, u) || h, c = v.rects.map(({ x: C, y: E, width: T, height:
|
|
287
|
+
const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (L = v.state) != null && L.selected ? ht : $, d = b && b.paint(v, u) || h, c = v.rects.map(({ x: C, y: E, width: T, height: p }) => ({
|
|
288
288
|
x: C + y,
|
|
289
|
-
y: E +
|
|
289
|
+
y: E + g,
|
|
290
290
|
width: T,
|
|
291
|
-
height:
|
|
291
|
+
height: p
|
|
292
292
|
}));
|
|
293
293
|
n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1;
|
|
294
294
|
const w = 5;
|
|
295
295
|
if (c.forEach(
|
|
296
|
-
({ x: C, y: E, width: T, height:
|
|
296
|
+
({ x: C, y: E, width: T, height: p }) => n.fillRect(
|
|
297
297
|
C,
|
|
298
298
|
E - w / 2,
|
|
299
299
|
T,
|
|
300
|
-
|
|
300
|
+
p + w
|
|
301
301
|
)
|
|
302
302
|
), d.underlineColor) {
|
|
303
303
|
n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
|
|
304
304
|
const C = w / 2 + (d.underlineOffset ?? 0);
|
|
305
|
-
c.forEach(({ x: E, y: T, width:
|
|
306
|
-
n.beginPath(), n.moveTo(E, T + A + C), n.lineTo(E +
|
|
305
|
+
c.forEach(({ x: E, y: T, width: p, height: A }) => {
|
|
306
|
+
n.beginPath(), n.moveTo(E, T + A + C), n.lineTo(E + p, T + A + C), n.stroke();
|
|
307
307
|
});
|
|
308
308
|
}
|
|
309
309
|
});
|
|
310
310
|
}), i = ft(() => {
|
|
311
|
-
|
|
311
|
+
ce(e);
|
|
312
312
|
});
|
|
313
313
|
return window.addEventListener("resize", i), {
|
|
314
314
|
destroy: () => {
|
|
@@ -319,8 +319,8 @@ const $ = {
|
|
|
319
319
|
},
|
|
320
320
|
redraw: o
|
|
321
321
|
};
|
|
322
|
-
},
|
|
323
|
-
var
|
|
322
|
+
}, ue = (t, e, n) => gt(t, e, n, de(t));
|
|
323
|
+
var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
|
|
324
324
|
return typeof t == "string" ? t.length > 0 : typeof t == "number";
|
|
325
325
|
}, M = function(t, e, n) {
|
|
326
326
|
return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
|
|
@@ -332,7 +332,7 @@ var fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
|
|
|
332
332
|
return { r: U(t.r, 0, 255), g: U(t.g, 0, 255), b: U(t.b, 0, 255), a: U(t.a) };
|
|
333
333
|
}, ot = function(t) {
|
|
334
334
|
return { r: M(t.r), g: M(t.g), b: M(t.b), a: M(t.a, 3) };
|
|
335
|
-
},
|
|
335
|
+
}, fe = /^#([0-9a-f]{3,8})$/i, K = function(t) {
|
|
336
336
|
var e = t.toString(16);
|
|
337
337
|
return e.length < 2 ? "0" + e : e;
|
|
338
338
|
}, Vt = function(t) {
|
|
@@ -353,17 +353,17 @@ var fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
|
|
|
353
353
|
}, G = function(t) {
|
|
354
354
|
return { h: (e = Vt(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
|
|
355
355
|
var e, n, o, i;
|
|
356
|
-
}, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,
|
|
357
|
-
var e =
|
|
356
|
+
}, ge = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, pe = /^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, At = { string: [[function(t) {
|
|
357
|
+
var e = fe.exec(t);
|
|
358
358
|
return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? M(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 ? M(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
|
|
359
359
|
}, "hex"], [function(t) {
|
|
360
|
-
var e =
|
|
360
|
+
var e = me.exec(t) || be.exec(t);
|
|
361
361
|
return e ? e[2] !== e[4] || e[4] !== e[6] ? null : vt({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
|
|
362
362
|
}, "rgb"], [function(t) {
|
|
363
|
-
var e = ge.exec(t) ||
|
|
363
|
+
var e = ge.exec(t) || pe.exec(t);
|
|
364
364
|
if (!e)
|
|
365
365
|
return null;
|
|
366
|
-
var n, o, i = wt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (
|
|
366
|
+
var n, o, i = wt({ 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) });
|
|
367
367
|
return xt(i);
|
|
368
368
|
}, "hsl"]], object: [[function(t) {
|
|
369
369
|
var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
|
|
@@ -389,7 +389,7 @@ var fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
|
|
|
389
389
|
return [o, e[n][1]];
|
|
390
390
|
}
|
|
391
391
|
return [null, void 0];
|
|
392
|
-
},
|
|
392
|
+
}, ve = function(t) {
|
|
393
393
|
return typeof t == "string" ? Et(t.trim(), At.string) : typeof t == "object" && t !== null ? Et(t, At.object) : [null, void 0];
|
|
394
394
|
}, it = function(t, e) {
|
|
395
395
|
var n = G(t);
|
|
@@ -401,7 +401,7 @@ var fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
|
|
|
401
401
|
return { h: n.h, s: n.s, l: U(n.l + 100 * e, 0, 100), a: n.a };
|
|
402
402
|
}, Ct = function() {
|
|
403
403
|
function t(e) {
|
|
404
|
-
this.parsed =
|
|
404
|
+
this.parsed = ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
|
|
405
405
|
}
|
|
406
406
|
return t.prototype.isValid = function() {
|
|
407
407
|
return this.parsed !== null;
|
|
@@ -454,13 +454,13 @@ var fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, _ = function(t) {
|
|
|
454
454
|
}(), V = function(t) {
|
|
455
455
|
return t instanceof Ct ? t : new Ct(t);
|
|
456
456
|
};
|
|
457
|
-
const
|
|
457
|
+
const we = (t) => [
|
|
458
458
|
`background-color:${V((t == null ? void 0 : t.fill) || $.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? $.fillOpacity : t.fillOpacity).toHex()}`,
|
|
459
459
|
t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
|
|
460
460
|
t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
|
|
461
461
|
t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
|
|
462
462
|
t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
|
|
463
|
-
].filter(Boolean).join(";"),
|
|
463
|
+
].filter(Boolean).join(";"), ye = () => {
|
|
464
464
|
const t = document.createElement("style");
|
|
465
465
|
document.getElementsByTagName("head")[0].appendChild(t);
|
|
466
466
|
let e = /* @__PURE__ */ new Set();
|
|
@@ -477,17 +477,17 @@ const ye = (t) => [
|
|
|
477
477
|
Array.from(e).filter((l) => !f.has(l));
|
|
478
478
|
const b = r.map((l) => {
|
|
479
479
|
var y;
|
|
480
|
-
const m = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (y = l.state) != null && y.selected ? ht : $,
|
|
481
|
-
return `::highlight(_${l.annotation.id}) { ${
|
|
480
|
+
const m = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (y = l.state) != null && y.selected ? ht : $, g = u && u.paint(l, a) || m;
|
|
481
|
+
return `::highlight(_${l.annotation.id}) { ${we(g)} }`;
|
|
482
482
|
});
|
|
483
483
|
t.innerHTML = b.join(`
|
|
484
484
|
`), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
|
|
485
|
-
const m = l.target.selector.map((y) => y.range),
|
|
486
|
-
CSS.highlights.set(`_${l.id}`,
|
|
485
|
+
const m = l.target.selector.map((y) => y.range), g = new Highlight(...m);
|
|
486
|
+
CSS.highlights.set(`_${l.id}`, g);
|
|
487
487
|
}), e = f;
|
|
488
488
|
}
|
|
489
489
|
};
|
|
490
|
-
},
|
|
490
|
+
}, xe = (t, e, n) => gt(t, e, n, ye());
|
|
491
491
|
var Lt = Object.prototype.hasOwnProperty;
|
|
492
492
|
function ut(t, e) {
|
|
493
493
|
var n, o;
|
|
@@ -514,10 +514,10 @@ function ut(t, e) {
|
|
|
514
514
|
}
|
|
515
515
|
return t !== t && e !== e;
|
|
516
516
|
}
|
|
517
|
-
const
|
|
517
|
+
const Ae = (t, e) => {
|
|
518
518
|
const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y;
|
|
519
519
|
return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;
|
|
520
|
-
},
|
|
520
|
+
}, Ee = (t) => {
|
|
521
521
|
t.classList.add("r6o-annotatable");
|
|
522
522
|
const e = document.createElement("div");
|
|
523
523
|
e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
|
|
@@ -530,44 +530,44 @@ const Ee = (t, e) => {
|
|
|
530
530
|
if (ut(n, a) && b)
|
|
531
531
|
return;
|
|
532
532
|
e.innerHTML = "";
|
|
533
|
-
const m = a.reduce((
|
|
534
|
-
a.forEach((
|
|
535
|
-
const y =
|
|
533
|
+
const m = a.reduce((g, { rects: y }) => [...g, ...y], []);
|
|
534
|
+
a.forEach((g) => {
|
|
535
|
+
const y = g.rects.map((v) => {
|
|
536
536
|
const h = document.createElement("span");
|
|
537
|
-
h.className = "r6o-annotation", h.dataset.annotation =
|
|
538
|
-
const d =
|
|
537
|
+
h.className = "r6o-annotation", h.dataset.annotation = g.annotation.id, h.style.left = `${v.x}px`, h.style.top = `${v.y}px`, h.style.width = `${v.width}px`, h.style.height = `${v.height}px`;
|
|
538
|
+
const d = Ae(v, m), c = qt(g, s, u, f, d), w = V((c == null ? void 0 : c.fill) || $.fill).alpha((c == null ? void 0 : c.fillOpacity) === void 0 ? $.fillOpacity : c.fillOpacity).toHex();
|
|
539
539
|
return h.style.backgroundColor = w, c.underlineStyle && (h.style.borderStyle = c.underlineStyle), c.underlineColor && (h.style.borderColor = c.underlineColor), c.underlineThickness && (h.style.borderBottomWidth = `${c.underlineThickness}px`), c.underlineOffset && (h.style.paddingBottom = `${c.underlineOffset}px`), e.appendChild(h), h;
|
|
540
540
|
});
|
|
541
|
-
return { id:
|
|
541
|
+
return { id: g.annotation.id, spans: y };
|
|
542
542
|
}), n = a;
|
|
543
543
|
},
|
|
544
544
|
setVisible: (a) => {
|
|
545
545
|
a ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
546
546
|
}
|
|
547
547
|
};
|
|
548
|
-
},
|
|
548
|
+
}, Se = (t, e, n) => gt(t, e, n, Ee(t));
|
|
549
549
|
let Q;
|
|
550
|
-
const
|
|
551
|
-
function
|
|
550
|
+
const Ce = new Uint8Array(16);
|
|
551
|
+
function Le() {
|
|
552
552
|
if (!Q && (Q = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Q))
|
|
553
553
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
554
|
-
return Q(
|
|
554
|
+
return Q(Ce);
|
|
555
555
|
}
|
|
556
556
|
const O = [];
|
|
557
557
|
for (let t = 0; t < 256; ++t)
|
|
558
558
|
O.push((t + 256).toString(16).slice(1));
|
|
559
|
-
function
|
|
559
|
+
function Te(t, e = 0) {
|
|
560
560
|
return O[t[e + 0]] + O[t[e + 1]] + O[t[e + 2]] + O[t[e + 3]] + "-" + O[t[e + 4]] + O[t[e + 5]] + "-" + O[t[e + 6]] + O[t[e + 7]] + "-" + O[t[e + 8]] + O[t[e + 9]] + "-" + O[t[e + 10]] + O[t[e + 11]] + O[t[e + 12]] + O[t[e + 13]] + O[t[e + 14]] + O[t[e + 15]];
|
|
561
561
|
}
|
|
562
|
-
const
|
|
563
|
-
randomUUID:
|
|
562
|
+
const Be = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Tt = {
|
|
563
|
+
randomUUID: Be
|
|
564
564
|
};
|
|
565
565
|
function Yt(t, e, n) {
|
|
566
566
|
if (Tt.randomUUID && !e && !t)
|
|
567
567
|
return Tt.randomUUID();
|
|
568
568
|
t = t || {};
|
|
569
|
-
const o = t.random || (t.rng ||
|
|
570
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
569
|
+
const o = t.random || (t.rng || Le)();
|
|
570
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Te(o);
|
|
571
571
|
}
|
|
572
572
|
var Bt = Object.prototype.hasOwnProperty;
|
|
573
573
|
function F(t, e) {
|
|
@@ -597,15 +597,15 @@ function F(t, e) {
|
|
|
597
597
|
}
|
|
598
598
|
function st() {
|
|
599
599
|
}
|
|
600
|
-
function
|
|
600
|
+
function Re(t, e) {
|
|
601
601
|
return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
|
|
602
602
|
}
|
|
603
603
|
const H = [];
|
|
604
|
-
function
|
|
604
|
+
function pt(t, e = st) {
|
|
605
605
|
let n;
|
|
606
606
|
const o = /* @__PURE__ */ new Set();
|
|
607
607
|
function i(s) {
|
|
608
|
-
if (
|
|
608
|
+
if (Re(t, s) && (t = s, n)) {
|
|
609
609
|
const u = !H.length;
|
|
610
610
|
for (const f of o)
|
|
611
611
|
f[1](), H.push(f, t);
|
|
@@ -627,8 +627,8 @@ function gt(t, e = st) {
|
|
|
627
627
|
}
|
|
628
628
|
return { set: i, update: r, subscribe: a };
|
|
629
629
|
}
|
|
630
|
-
const
|
|
631
|
-
const { subscribe: e, set: n } =
|
|
630
|
+
const Ie = (t) => {
|
|
631
|
+
const { subscribe: e, set: n } = pt();
|
|
632
632
|
let o;
|
|
633
633
|
return e((i) => o = i), t.observe(({ changes: i }) => {
|
|
634
634
|
if (o) {
|
|
@@ -644,9 +644,9 @@ const Me = (t) => {
|
|
|
644
644
|
set: n
|
|
645
645
|
};
|
|
646
646
|
};
|
|
647
|
-
var
|
|
647
|
+
var Me = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Me || {});
|
|
648
648
|
const at = { selected: [] }, Oe = (t, e = "EDIT") => {
|
|
649
|
-
const { subscribe: n, set: o } =
|
|
649
|
+
const { subscribe: n, set: o } = pt(at);
|
|
650
650
|
let i = at;
|
|
651
651
|
n((l) => i = l);
|
|
652
652
|
const r = () => o(at), a = () => {
|
|
@@ -656,22 +656,22 @@ const at = { selected: [] }, Oe = (t, e = "EDIT") => {
|
|
|
656
656
|
if (i.selected.length === 0)
|
|
657
657
|
return !1;
|
|
658
658
|
const m = typeof l == "string" ? l : l.id;
|
|
659
|
-
return i.selected.some((
|
|
659
|
+
return i.selected.some((g) => g.id === m);
|
|
660
660
|
}, u = (l, m) => {
|
|
661
|
-
const
|
|
662
|
-
if (
|
|
663
|
-
const y = Ne(
|
|
661
|
+
const g = t.getAnnotation(l);
|
|
662
|
+
if (g) {
|
|
663
|
+
const y = Ne(g, e);
|
|
664
664
|
o(y === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: m } : y === "SELECT" ? { selected: [{ id: l }], pointerEvent: m } : { selected: [], pointerEvent: m });
|
|
665
665
|
} else
|
|
666
666
|
console.warn("Invalid selection: " + l);
|
|
667
667
|
}, f = (l, m = !0) => {
|
|
668
|
-
const
|
|
669
|
-
o({ selected: y.map(({ id: v }) => ({ id: v, editable: m })) }), y.length !==
|
|
668
|
+
const g = Array.isArray(l) ? l : [l], y = g.map((v) => t.getAnnotation(v)).filter(Boolean);
|
|
669
|
+
o({ selected: y.map(({ id: v }) => ({ id: v, editable: m })) }), y.length !== g.length && console.warn("Invalid selection", l);
|
|
670
670
|
}, b = (l) => {
|
|
671
671
|
if (i.selected.length === 0)
|
|
672
672
|
return !1;
|
|
673
673
|
const { selected: m } = i;
|
|
674
|
-
m.filter(({ id:
|
|
674
|
+
m.filter(({ id: g }) => l.includes(g)).length > 0 && o({ selected: m.filter(({ id: g }) => !l.includes(g)) });
|
|
675
675
|
};
|
|
676
676
|
return t.observe(({ changes: l }) => b((l.deleted || []).map((m) => m.id))), {
|
|
677
677
|
clear: r,
|
|
@@ -711,34 +711,34 @@ function _e(t, e, n) {
|
|
|
711
711
|
const o = t.random || (t.rng || Ve)();
|
|
712
712
|
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, ke(o);
|
|
713
713
|
}
|
|
714
|
-
const
|
|
714
|
+
const Mn = (t, e, n, o) => ({
|
|
715
715
|
id: _e(),
|
|
716
716
|
annotation: t.id,
|
|
717
717
|
created: n || /* @__PURE__ */ new Date(),
|
|
718
718
|
creator: o,
|
|
719
719
|
...e
|
|
720
|
-
}),
|
|
720
|
+
}), Xe = (t, e) => {
|
|
721
721
|
const n = new Set(t.bodies.map((o) => o.id));
|
|
722
722
|
return e.bodies.filter((o) => !n.has(o.id));
|
|
723
|
-
},
|
|
723
|
+
}, De = (t, e) => {
|
|
724
724
|
const n = new Set(e.bodies.map((o) => o.id));
|
|
725
725
|
return t.bodies.filter((o) => !n.has(o.id));
|
|
726
|
-
},
|
|
726
|
+
}, $e = (t, e) => e.bodies.map((n) => {
|
|
727
727
|
const o = t.bodies.find((i) => i.id === n.id);
|
|
728
728
|
return { newBody: n, oldBody: o && !F(o, n) ? o : void 0 };
|
|
729
|
-
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })),
|
|
730
|
-
const n =
|
|
729
|
+
}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), He = (t, e) => !F(t.target, e.target), _t = (t, e) => {
|
|
730
|
+
const n = Xe(t, e), o = De(t, e), i = $e(t, e);
|
|
731
731
|
return {
|
|
732
732
|
oldValue: t,
|
|
733
733
|
newValue: e,
|
|
734
734
|
bodiesCreated: n.length > 0 ? n : void 0,
|
|
735
735
|
bodiesDeleted: o.length > 0 ? o : void 0,
|
|
736
736
|
bodiesUpdated: i.length > 0 ? i : void 0,
|
|
737
|
-
targetUpdated:
|
|
737
|
+
targetUpdated: He(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
|
|
738
738
|
};
|
|
739
739
|
};
|
|
740
740
|
var R = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(R || {});
|
|
741
|
-
const
|
|
741
|
+
const Pe = (t, e) => {
|
|
742
742
|
var n, o;
|
|
743
743
|
const { changes: i, origin: r } = e;
|
|
744
744
|
if (!(!t.options.origin || t.options.origin === r))
|
|
@@ -760,7 +760,7 @@ const ze = (t, e) => {
|
|
|
760
760
|
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => a.has(s));
|
|
761
761
|
} else
|
|
762
762
|
return !0;
|
|
763
|
-
},
|
|
763
|
+
}, ze = (t, e) => {
|
|
764
764
|
const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), a = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), s = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), u = [
|
|
765
765
|
...(t.created || []).filter((l) => !r.has(l.id)).map((l) => a.has(l.id) ? e.updated.find(({ oldValue: m }) => m.id === l.id).newValue : l),
|
|
766
766
|
...e.created || []
|
|
@@ -769,23 +769,23 @@ const ze = (t, e) => {
|
|
|
769
769
|
...(e.deleted || []).filter((l) => !n.has(l.id))
|
|
770
770
|
], b = [
|
|
771
771
|
...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
|
|
772
|
-
const { oldValue: m, newValue:
|
|
773
|
-
if (a.has(
|
|
774
|
-
const y = e.updated.find((v) => v.oldValue.id ===
|
|
775
|
-
return
|
|
772
|
+
const { oldValue: m, newValue: g } = l;
|
|
773
|
+
if (a.has(g.id)) {
|
|
774
|
+
const y = e.updated.find((v) => v.oldValue.id === g.id).newValue;
|
|
775
|
+
return _t(m, y);
|
|
776
776
|
} else
|
|
777
777
|
return l;
|
|
778
778
|
}),
|
|
779
779
|
...(e.updated || []).filter(({ oldValue: l }) => !s.has(l.id))
|
|
780
780
|
];
|
|
781
781
|
return { created: u, deleted: f, updated: b };
|
|
782
|
-
},
|
|
783
|
-
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (
|
|
784
|
-
const A = n.findIndex((x) => x.onChange ==
|
|
782
|
+
}, Fe = (t) => t.id !== void 0, We = () => {
|
|
783
|
+
const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (p, A = {}) => n.push({ onChange: p, options: A }), i = (p) => {
|
|
784
|
+
const A = n.findIndex((x) => x.onChange == p);
|
|
785
785
|
A > -1 && n.splice(A, 1);
|
|
786
|
-
}, r = (
|
|
786
|
+
}, r = (p, A) => {
|
|
787
787
|
const x = {
|
|
788
|
-
origin:
|
|
788
|
+
origin: p,
|
|
789
789
|
changes: {
|
|
790
790
|
created: A.created || [],
|
|
791
791
|
updated: A.updated || [],
|
|
@@ -794,85 +794,85 @@ const ze = (t, e) => {
|
|
|
794
794
|
state: [...t.values()]
|
|
795
795
|
};
|
|
796
796
|
n.forEach((S) => {
|
|
797
|
-
|
|
797
|
+
Pe(S, x) && S.onChange(x);
|
|
798
798
|
});
|
|
799
|
-
}, a = (
|
|
800
|
-
if (t.get(
|
|
801
|
-
throw Error(`Cannot add annotation ${
|
|
802
|
-
t.set(
|
|
803
|
-
}, s = (
|
|
804
|
-
const x = typeof
|
|
799
|
+
}, a = (p, A = R.LOCAL) => {
|
|
800
|
+
if (t.get(p.id))
|
|
801
|
+
throw Error(`Cannot add annotation ${p.id} - exists already`);
|
|
802
|
+
t.set(p.id, p), p.bodies.forEach((x) => e.set(x.id, p.id)), r(A, { created: [p] });
|
|
803
|
+
}, s = (p, A) => {
|
|
804
|
+
const x = typeof p == "string" ? A : p, S = typeof p == "string" ? p : p.id, B = t.get(S);
|
|
805
805
|
if (B) {
|
|
806
|
-
const I =
|
|
806
|
+
const I = _t(B, x);
|
|
807
807
|
return S === x.id ? t.set(S, x) : (t.delete(S), t.set(x.id, x)), B.bodies.forEach((k) => e.delete(k.id)), x.bodies.forEach((k) => e.set(k.id, x.id)), I;
|
|
808
808
|
} else
|
|
809
809
|
console.warn(`Cannot update annotation ${S} - does not exist`);
|
|
810
|
-
}, u = (
|
|
811
|
-
const S =
|
|
810
|
+
}, u = (p, A = R.LOCAL, x = R.LOCAL) => {
|
|
811
|
+
const S = Fe(A) ? x : A, B = s(p, A);
|
|
812
812
|
B && r(S, { updated: [B] });
|
|
813
|
-
}, f = (
|
|
814
|
-
const x =
|
|
813
|
+
}, f = (p, A = R.LOCAL) => {
|
|
814
|
+
const x = p.reduce((S, B) => {
|
|
815
815
|
const I = s(B);
|
|
816
816
|
return I ? [...S, I] : S;
|
|
817
817
|
}, []);
|
|
818
818
|
x.length > 0 && r(A, { updated: x });
|
|
819
|
-
}, b = (
|
|
820
|
-
const x = t.get(
|
|
819
|
+
}, b = (p, A = R.LOCAL) => {
|
|
820
|
+
const x = t.get(p.annotation);
|
|
821
821
|
if (x) {
|
|
822
822
|
const S = {
|
|
823
823
|
...x,
|
|
824
|
-
bodies: [...x.bodies,
|
|
824
|
+
bodies: [...x.bodies, p]
|
|
825
825
|
};
|
|
826
|
-
t.set(x.id, S), e.set(
|
|
826
|
+
t.set(x.id, S), e.set(p.id, S.id), r(A, { updated: [{
|
|
827
827
|
oldValue: x,
|
|
828
828
|
newValue: S,
|
|
829
|
-
bodiesCreated: [
|
|
829
|
+
bodiesCreated: [p]
|
|
830
830
|
}] });
|
|
831
831
|
} else
|
|
832
|
-
console.warn(`Attempt to add body to missing annotation: ${
|
|
833
|
-
}, l = () => [...t.values()], m = (
|
|
832
|
+
console.warn(`Attempt to add body to missing annotation: ${p.annotation}`);
|
|
833
|
+
}, l = () => [...t.values()], m = (p = R.LOCAL) => {
|
|
834
834
|
const A = [...t.values()];
|
|
835
|
-
t.clear(), e.clear(), r(
|
|
836
|
-
},
|
|
835
|
+
t.clear(), e.clear(), r(p, { deleted: A });
|
|
836
|
+
}, g = (p, A = !0, x = R.LOCAL) => {
|
|
837
837
|
if (A) {
|
|
838
838
|
const S = [...t.values()];
|
|
839
|
-
t.clear(), e.clear(),
|
|
839
|
+
t.clear(), e.clear(), p.forEach((B) => {
|
|
840
840
|
t.set(B.id, B), B.bodies.forEach((I) => e.set(I.id, B.id));
|
|
841
|
-
}), r(x, { created:
|
|
841
|
+
}), r(x, { created: p, deleted: S });
|
|
842
842
|
} else {
|
|
843
|
-
const S =
|
|
843
|
+
const S = p.reduce((B, I) => {
|
|
844
844
|
const k = t.get(I.id);
|
|
845
845
|
return k ? [...B, k] : B;
|
|
846
846
|
}, []);
|
|
847
847
|
if (S.length > 0)
|
|
848
848
|
throw Error(`Bulk insert would overwrite the following annotations: ${S.map((B) => B.id).join(", ")}`);
|
|
849
|
-
|
|
849
|
+
p.forEach((B) => {
|
|
850
850
|
t.set(B.id, B), B.bodies.forEach((I) => e.set(I.id, B.id));
|
|
851
|
-
}), r(x, { created:
|
|
851
|
+
}), r(x, { created: p });
|
|
852
852
|
}
|
|
853
|
-
}, y = (
|
|
854
|
-
const A = typeof
|
|
853
|
+
}, y = (p) => {
|
|
854
|
+
const A = typeof p == "string" ? p : p.id, x = t.get(A);
|
|
855
855
|
if (x)
|
|
856
856
|
return t.delete(A), x.bodies.forEach((S) => e.delete(S.id)), x;
|
|
857
857
|
console.warn(`Attempt to delete missing annotation: ${A}`);
|
|
858
|
-
}, v = (
|
|
859
|
-
const x = y(
|
|
858
|
+
}, v = (p, A = R.LOCAL) => {
|
|
859
|
+
const x = y(p);
|
|
860
860
|
x && r(A, { deleted: [x] });
|
|
861
|
-
}, h = (
|
|
862
|
-
const x =
|
|
861
|
+
}, h = (p, A = R.LOCAL) => {
|
|
862
|
+
const x = p.reduce((S, B) => {
|
|
863
863
|
const I = y(B);
|
|
864
864
|
return I ? [...S, I] : S;
|
|
865
865
|
}, []);
|
|
866
866
|
x.length > 0 && r(A, { deleted: x });
|
|
867
|
-
}, d = (
|
|
868
|
-
const x = t.get(
|
|
867
|
+
}, d = (p, A = R.LOCAL) => {
|
|
868
|
+
const x = t.get(p.annotation);
|
|
869
869
|
if (x) {
|
|
870
|
-
const S = x.bodies.find((B) => B.id ===
|
|
870
|
+
const S = x.bodies.find((B) => B.id === p.id);
|
|
871
871
|
if (S) {
|
|
872
872
|
e.delete(S.id);
|
|
873
873
|
const B = {
|
|
874
874
|
...x,
|
|
875
|
-
bodies: x.bodies.filter((I) => I.id !==
|
|
875
|
+
bodies: x.bodies.filter((I) => I.id !== p.id)
|
|
876
876
|
};
|
|
877
877
|
t.set(x.id, B), r(A, { updated: [{
|
|
878
878
|
oldValue: x,
|
|
@@ -880,27 +880,27 @@ const ze = (t, e) => {
|
|
|
880
880
|
bodiesDeleted: [S]
|
|
881
881
|
}] });
|
|
882
882
|
} else
|
|
883
|
-
console.warn(`Attempt to delete missing body ${
|
|
883
|
+
console.warn(`Attempt to delete missing body ${p.id} from annotation ${p.annotation}`);
|
|
884
884
|
} else
|
|
885
|
-
console.warn(`Attempt to delete body from missing annotation ${
|
|
886
|
-
}, c = (
|
|
887
|
-
const A = t.get(
|
|
885
|
+
console.warn(`Attempt to delete body from missing annotation ${p.annotation}`);
|
|
886
|
+
}, c = (p) => {
|
|
887
|
+
const A = t.get(p);
|
|
888
888
|
return A ? { ...A } : void 0;
|
|
889
|
-
}, w = (
|
|
890
|
-
const A = e.get(
|
|
889
|
+
}, w = (p) => {
|
|
890
|
+
const A = e.get(p);
|
|
891
891
|
if (A) {
|
|
892
|
-
const x = c(A).bodies.find((S) => S.id ===
|
|
892
|
+
const x = c(A).bodies.find((S) => S.id === p);
|
|
893
893
|
if (x)
|
|
894
894
|
return x;
|
|
895
|
-
console.error(`Store integrity error: body ${
|
|
895
|
+
console.error(`Store integrity error: body ${p} in index, but not in annotation`);
|
|
896
896
|
} else
|
|
897
|
-
console.warn(`Attempt to retrieve missing body: ${
|
|
898
|
-
}, L = (
|
|
899
|
-
if (
|
|
897
|
+
console.warn(`Attempt to retrieve missing body: ${p}`);
|
|
898
|
+
}, L = (p, A) => {
|
|
899
|
+
if (p.annotation !== A.annotation)
|
|
900
900
|
throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
|
|
901
|
-
const x = t.get(
|
|
901
|
+
const x = t.get(p.annotation);
|
|
902
902
|
if (x) {
|
|
903
|
-
const S = x.bodies.find((I) => I.id ===
|
|
903
|
+
const S = x.bodies.find((I) => I.id === p.id), B = {
|
|
904
904
|
...x,
|
|
905
905
|
bodies: x.bodies.map((I) => I.id === S.id ? A : I)
|
|
906
906
|
};
|
|
@@ -910,21 +910,21 @@ const ze = (t, e) => {
|
|
|
910
910
|
bodiesUpdated: [{ oldBody: S, newBody: A }]
|
|
911
911
|
};
|
|
912
912
|
} else
|
|
913
|
-
console.warn(`Attempt to add body to missing annotation ${
|
|
914
|
-
}, C = (
|
|
915
|
-
const S = L(
|
|
913
|
+
console.warn(`Attempt to add body to missing annotation ${p.annotation}`);
|
|
914
|
+
}, C = (p, A, x = R.LOCAL) => {
|
|
915
|
+
const S = L(p, A);
|
|
916
916
|
S && r(x, { updated: [S] });
|
|
917
|
-
}, E = (
|
|
918
|
-
const x =
|
|
917
|
+
}, E = (p, A = R.LOCAL) => {
|
|
918
|
+
const x = p.map((S) => L({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
|
|
919
919
|
r(A, { updated: x });
|
|
920
|
-
}, T = (
|
|
921
|
-
const A = t.get(
|
|
920
|
+
}, T = (p) => {
|
|
921
|
+
const A = t.get(p.annotation);
|
|
922
922
|
if (A) {
|
|
923
923
|
const x = {
|
|
924
924
|
...A,
|
|
925
925
|
target: {
|
|
926
926
|
...A.target,
|
|
927
|
-
...
|
|
927
|
+
...p
|
|
928
928
|
}
|
|
929
929
|
};
|
|
930
930
|
return t.set(A.id, x), {
|
|
@@ -932,22 +932,22 @@ const ze = (t, e) => {
|
|
|
932
932
|
newValue: x,
|
|
933
933
|
targetUpdated: {
|
|
934
934
|
oldTarget: A.target,
|
|
935
|
-
newTarget:
|
|
935
|
+
newTarget: p
|
|
936
936
|
}
|
|
937
937
|
};
|
|
938
938
|
} else
|
|
939
|
-
console.warn(`Attempt to update target on missing annotation: ${
|
|
939
|
+
console.warn(`Attempt to update target on missing annotation: ${p.annotation}`);
|
|
940
940
|
};
|
|
941
941
|
return {
|
|
942
942
|
addAnnotation: a,
|
|
943
943
|
addBody: b,
|
|
944
944
|
all: l,
|
|
945
|
-
bulkAddAnnotation:
|
|
945
|
+
bulkAddAnnotation: g,
|
|
946
946
|
bulkDeleteAnnotation: h,
|
|
947
947
|
bulkUpdateAnnotation: f,
|
|
948
948
|
bulkUpdateBodies: E,
|
|
949
|
-
bulkUpdateTargets: (
|
|
950
|
-
const x =
|
|
949
|
+
bulkUpdateTargets: (p, A = R.LOCAL) => {
|
|
950
|
+
const x = p.map((S) => T(S)).filter(Boolean);
|
|
951
951
|
x.length > 0 && r(A, { updated: x });
|
|
952
952
|
},
|
|
953
953
|
clear: m,
|
|
@@ -959,13 +959,13 @@ const ze = (t, e) => {
|
|
|
959
959
|
unobserve: i,
|
|
960
960
|
updateAnnotation: u,
|
|
961
961
|
updateBody: C,
|
|
962
|
-
updateTarget: (
|
|
963
|
-
const x = T(
|
|
962
|
+
updateTarget: (p, A = R.LOCAL) => {
|
|
963
|
+
const x = T(p);
|
|
964
964
|
x && r(A, { updated: [x] });
|
|
965
965
|
}
|
|
966
966
|
};
|
|
967
967
|
};
|
|
968
|
-
let
|
|
968
|
+
let qe = () => ({
|
|
969
969
|
emit(t, ...e) {
|
|
970
970
|
for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
|
|
971
971
|
o[n](...e);
|
|
@@ -979,51 +979,51 @@ let je = () => ({
|
|
|
979
979
|
};
|
|
980
980
|
}
|
|
981
981
|
});
|
|
982
|
-
const
|
|
983
|
-
const e =
|
|
982
|
+
const je = 250, Ge = (t) => {
|
|
983
|
+
const e = qe(), n = [];
|
|
984
984
|
let o = -1, i = !1, r = 0;
|
|
985
|
-
const a = (
|
|
985
|
+
const a = (g) => {
|
|
986
986
|
if (!i) {
|
|
987
|
-
const { changes: y } =
|
|
988
|
-
if (v - r >
|
|
987
|
+
const { changes: y } = g, v = performance.now();
|
|
988
|
+
if (v - r > je)
|
|
989
989
|
n.splice(o + 1), n.push(y), o = n.length - 1;
|
|
990
990
|
else {
|
|
991
991
|
const h = n.length - 1;
|
|
992
|
-
n[h] =
|
|
992
|
+
n[h] = ze(n[h], y);
|
|
993
993
|
}
|
|
994
994
|
r = v;
|
|
995
995
|
}
|
|
996
996
|
i = !1;
|
|
997
997
|
};
|
|
998
998
|
t.observe(a, { origin: R.LOCAL });
|
|
999
|
-
const s = (
|
|
999
|
+
const s = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), b = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), m = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
|
|
1000
1000
|
return {
|
|
1001
1001
|
canRedo: () => n.length - 1 > o,
|
|
1002
1002
|
canUndo: () => o > -1,
|
|
1003
1003
|
destroy: () => t.unobserve(a),
|
|
1004
|
-
on: (
|
|
1004
|
+
on: (g, y) => e.on(g, y),
|
|
1005
1005
|
redo: () => {
|
|
1006
1006
|
if (n.length - 1 > o) {
|
|
1007
1007
|
i = !0;
|
|
1008
|
-
const { created:
|
|
1009
|
-
u(
|
|
1008
|
+
const { created: g, updated: y, deleted: v } = n[o + 1];
|
|
1009
|
+
u(g), b(y), m(v), e.emit("redo", n[o + 1]), o += 1;
|
|
1010
1010
|
}
|
|
1011
1011
|
},
|
|
1012
1012
|
undo: () => {
|
|
1013
1013
|
if (o > -1) {
|
|
1014
1014
|
i = !0;
|
|
1015
|
-
const { created:
|
|
1016
|
-
s(
|
|
1015
|
+
const { created: g, updated: y, deleted: v } = n[o];
|
|
1016
|
+
s(g), f(y), l(v), e.emit("undo", n[o]), o -= 1;
|
|
1017
1017
|
}
|
|
1018
1018
|
}
|
|
1019
1019
|
};
|
|
1020
|
-
},
|
|
1021
|
-
const { subscribe: t, set: e } =
|
|
1020
|
+
}, Ke = () => {
|
|
1021
|
+
const { subscribe: t, set: e } = pt([]);
|
|
1022
1022
|
return {
|
|
1023
1023
|
subscribe: t,
|
|
1024
1024
|
set: e
|
|
1025
1025
|
};
|
|
1026
|
-
},
|
|
1026
|
+
}, Qe = (t, e, n, o) => {
|
|
1027
1027
|
const { store: i, selection: r, hover: a, viewport: s } = t, u = /* @__PURE__ */ new Map();
|
|
1028
1028
|
let f = [], b;
|
|
1029
1029
|
const l = (v, h) => {
|
|
@@ -1031,7 +1031,7 @@ const Ge = 250, Ke = (t) => {
|
|
|
1031
1031
|
}, m = (v, h) => {
|
|
1032
1032
|
const d = u.get(v);
|
|
1033
1033
|
d && d.indexOf(h) > 0 && d.splice(d.indexOf(h), 1);
|
|
1034
|
-
},
|
|
1034
|
+
}, g = (v, h, d) => {
|
|
1035
1035
|
u.has(v) && setTimeout(() => {
|
|
1036
1036
|
u.get(v).forEach((c) => {
|
|
1037
1037
|
if (n) {
|
|
@@ -1049,13 +1049,13 @@ const Ge = 250, Ke = (t) => {
|
|
|
1049
1049
|
else if (f.length > 0 && v.length === 0)
|
|
1050
1050
|
f.forEach((h) => {
|
|
1051
1051
|
const d = i.getAnnotation(h.id);
|
|
1052
|
-
d && !F(d, h) &&
|
|
1052
|
+
d && !F(d, h) && g("updateAnnotation", d, h);
|
|
1053
1053
|
}), f = [];
|
|
1054
1054
|
else {
|
|
1055
1055
|
const h = new Set(f.map((c) => c.id)), d = new Set(v.map(({ id: c }) => c));
|
|
1056
1056
|
f.filter((c) => !d.has(c.id)).forEach((c) => {
|
|
1057
1057
|
const w = i.getAnnotation(c.id);
|
|
1058
|
-
w && !F(w, c) &&
|
|
1058
|
+
w && !F(w, c) && g("updateAnnotation", w, c);
|
|
1059
1059
|
}), f = [
|
|
1060
1060
|
// Remove annotations that were deselected
|
|
1061
1061
|
...f.filter((c) => d.has(c.id)),
|
|
@@ -1063,19 +1063,19 @@ const Ge = 250, Ke = (t) => {
|
|
|
1063
1063
|
...v.filter(({ id: c }) => !h.has(c)).map(({ id: c }) => i.getAnnotation(c))
|
|
1064
1064
|
];
|
|
1065
1065
|
}
|
|
1066
|
-
|
|
1066
|
+
g("selectionChanged", f);
|
|
1067
1067
|
}
|
|
1068
1068
|
}), a.subscribe((v) => {
|
|
1069
|
-
!b && v ?
|
|
1070
|
-
}), s == null || s.subscribe((v) =>
|
|
1069
|
+
!b && v ? g("mouseEnterAnnotation", i.getAnnotation(v)) : b && !v ? g("mouseLeaveAnnotation", i.getAnnotation(b)) : b && v && (g("mouseLeaveAnnotation", i.getAnnotation(b)), g("mouseEnterAnnotation", i.getAnnotation(v))), b = v;
|
|
1070
|
+
}), s == null || s.subscribe((v) => g("viewportIntersect", v.map((h) => i.getAnnotation(h)))), i.observe((v) => {
|
|
1071
1071
|
const { created: h, deleted: d } = v.changes;
|
|
1072
|
-
(h || []).forEach((c) =>
|
|
1072
|
+
(h || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (v.changes.updated || []).filter((c) => [
|
|
1073
1073
|
...c.bodiesCreated || [],
|
|
1074
1074
|
...c.bodiesDeleted || [],
|
|
1075
1075
|
...c.bodiesUpdated || []
|
|
1076
1076
|
].length > 0).forEach(({ oldValue: c, newValue: w }) => {
|
|
1077
1077
|
const L = f.find((C) => C.id === c.id) || c;
|
|
1078
|
-
f = f.map((C) => C.id === c.id ? w : C),
|
|
1078
|
+
f = f.map((C) => C.id === c.id ? w : C), g("updateAnnotation", w, L);
|
|
1079
1079
|
});
|
|
1080
1080
|
}, { origin: R.LOCAL }), i.observe((v) => {
|
|
1081
1081
|
if (f) {
|
|
@@ -1085,10 +1085,10 @@ const Ge = 250, Ke = (t) => {
|
|
|
1085
1085
|
}, { origin: R.REMOTE });
|
|
1086
1086
|
const y = (v) => (h) => {
|
|
1087
1087
|
const { updated: d } = h;
|
|
1088
|
-
v ? (d || []).forEach((c) =>
|
|
1088
|
+
v ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
|
|
1089
1089
|
};
|
|
1090
|
-
return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: l, off: m, emit:
|
|
1091
|
-
},
|
|
1090
|
+
return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: l, off: m, emit: g };
|
|
1091
|
+
}, Je = (t) => (e) => e.reduce((n, o) => {
|
|
1092
1092
|
const { parsed: i, error: r } = t.parse(o);
|
|
1093
1093
|
return r ? {
|
|
1094
1094
|
parsed: n.parsed,
|
|
@@ -1099,7 +1099,7 @@ const Ge = 250, Ke = (t) => {
|
|
|
1099
1099
|
} : {
|
|
1100
1100
|
...n
|
|
1101
1101
|
};
|
|
1102
|
-
}, { parsed: [], failed: [] }),
|
|
1102
|
+
}, { parsed: [], failed: [] }), Ze = (t, e, n) => {
|
|
1103
1103
|
const { store: o, selection: i } = t, r = (h) => {
|
|
1104
1104
|
if (n) {
|
|
1105
1105
|
const { parsed: d, error: c } = n.parse(h);
|
|
@@ -1113,7 +1113,7 @@ const Ge = 250, Ke = (t) => {
|
|
|
1113
1113
|
var h;
|
|
1114
1114
|
const d = (((h = i.selected) == null ? void 0 : h.map((c) => c.id)) || []).map((c) => o.getAnnotation(c)).filter(Boolean);
|
|
1115
1115
|
return n ? d.map(n.serialize) : d;
|
|
1116
|
-
}, l = (h, d = !0) => fetch(h).then((c) => c.json()).then((c) => (
|
|
1116
|
+
}, l = (h, d = !0) => fetch(h).then((c) => c.json()).then((c) => (g(c, d), c)), m = (h) => {
|
|
1117
1117
|
if (typeof h == "string") {
|
|
1118
1118
|
const d = o.getAnnotation(h);
|
|
1119
1119
|
if (o.deleteAnnotation(h), d)
|
|
@@ -1123,9 +1123,9 @@ const Ge = 250, Ke = (t) => {
|
|
|
1123
1123
|
if (d)
|
|
1124
1124
|
return o.deleteAnnotation(d), h;
|
|
1125
1125
|
}
|
|
1126
|
-
},
|
|
1126
|
+
}, g = (h, d = !0) => {
|
|
1127
1127
|
if (n) {
|
|
1128
|
-
const { parsed: c, failed: w } =
|
|
1128
|
+
const { parsed: c, failed: w } = Je(n)(h);
|
|
1129
1129
|
w.length > 0 && console.warn(`Discarded ${w.length} invalid annotations`, w), o.bulkAddAnnotation(c, d, R.REMOTE);
|
|
1130
1130
|
} else
|
|
1131
1131
|
o.bulkAddAnnotation(h, d, R.REMOTE);
|
|
@@ -1152,13 +1152,13 @@ const Ge = 250, Ke = (t) => {
|
|
|
1152
1152
|
loadAnnotations: l,
|
|
1153
1153
|
redo: e.redo,
|
|
1154
1154
|
removeAnnotation: m,
|
|
1155
|
-
setAnnotations:
|
|
1155
|
+
setAnnotations: g,
|
|
1156
1156
|
setSelected: y,
|
|
1157
1157
|
undo: e.undo,
|
|
1158
1158
|
updateAnnotation: v
|
|
1159
1159
|
};
|
|
1160
|
-
},
|
|
1161
|
-
let
|
|
1160
|
+
}, tn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1161
|
+
let en = (t) => crypto.getRandomValues(new Uint8Array(t)), nn = (t, e, n) => {
|
|
1162
1162
|
let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
|
|
1163
1163
|
return (r = e) => {
|
|
1164
1164
|
let a = "";
|
|
@@ -1169,13 +1169,13 @@ let nn = (t) => crypto.getRandomValues(new Uint8Array(t)), on = (t, e, n) => {
|
|
|
1169
1169
|
return a;
|
|
1170
1170
|
}
|
|
1171
1171
|
};
|
|
1172
|
-
},
|
|
1172
|
+
}, on = (t, e = 21) => nn(t, e, en), rn = (t = 21) => {
|
|
1173
1173
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
1174
1174
|
for (; t--; )
|
|
1175
|
-
e +=
|
|
1175
|
+
e += tn[n[t] & 63];
|
|
1176
1176
|
return e;
|
|
1177
1177
|
};
|
|
1178
|
-
const
|
|
1178
|
+
const sn = () => ({ isGuest: !0, id: on("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), an = (t) => {
|
|
1179
1179
|
const e = JSON.stringify(t);
|
|
1180
1180
|
let n = 0;
|
|
1181
1181
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -1183,28 +1183,28 @@ const an = () => ({ isGuest: !0, id: rn("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1183
1183
|
n = (n << 5) - n + r, n |= 0;
|
|
1184
1184
|
}
|
|
1185
1185
|
return `${n}`;
|
|
1186
|
-
},
|
|
1186
|
+
}, Xt = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, ln = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1187
1187
|
const { id: o, type: i, purpose: r, value: a, created: s, creator: u, ...f } = n;
|
|
1188
1188
|
return {
|
|
1189
|
-
id: o || `temp-${
|
|
1189
|
+
id: o || `temp-${an(n)}`,
|
|
1190
1190
|
annotation: e,
|
|
1191
1191
|
type: i,
|
|
1192
1192
|
purpose: r,
|
|
1193
1193
|
value: a,
|
|
1194
1194
|
created: s ? new Date(s) : void 0,
|
|
1195
|
-
creator:
|
|
1195
|
+
creator: Xt(u),
|
|
1196
1196
|
...f
|
|
1197
1197
|
};
|
|
1198
|
-
}),
|
|
1198
|
+
}), cn = (t) => t.map((e) => {
|
|
1199
1199
|
var n, o;
|
|
1200
1200
|
const i = { ...e };
|
|
1201
1201
|
return delete i.annotation, (n = i.id) != null && n.startsWith("temp-") && delete i.id, { ...i, created: (o = i.created) == null ? void 0 : o.toISOString() };
|
|
1202
1202
|
});
|
|
1203
|
-
|
|
1203
|
+
rn();
|
|
1204
1204
|
const On = (t, e) => ({
|
|
1205
|
-
parse: (n) =>
|
|
1206
|
-
serialize: (n) =>
|
|
1207
|
-
}),
|
|
1205
|
+
parse: (n) => hn(n),
|
|
1206
|
+
serialize: (n) => fn(n, t, e)
|
|
1207
|
+
}), dn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, un = (t) => {
|
|
1208
1208
|
const {
|
|
1209
1209
|
id: e,
|
|
1210
1210
|
creator: n,
|
|
@@ -1215,7 +1215,7 @@ const On = (t, e) => ({
|
|
|
1215
1215
|
if (a.length === 0)
|
|
1216
1216
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1217
1217
|
const s = {
|
|
1218
|
-
creator:
|
|
1218
|
+
creator: Xt(n),
|
|
1219
1219
|
created: o ? new Date(o) : void 0,
|
|
1220
1220
|
updated: i ? new Date(i) : void 0,
|
|
1221
1221
|
annotation: e,
|
|
@@ -1234,7 +1234,7 @@ const On = (t, e) => ({
|
|
|
1234
1234
|
}
|
|
1235
1235
|
return l;
|
|
1236
1236
|
}, {});
|
|
1237
|
-
if (
|
|
1237
|
+
if (dn(b))
|
|
1238
1238
|
s.selector.push({ id: u.id, ...b });
|
|
1239
1239
|
else {
|
|
1240
1240
|
const l = [
|
|
@@ -1245,14 +1245,14 @@ const On = (t, e) => ({
|
|
|
1245
1245
|
}
|
|
1246
1246
|
}
|
|
1247
1247
|
return { parsed: s };
|
|
1248
|
-
},
|
|
1248
|
+
}, hn = (t) => {
|
|
1249
1249
|
const e = t.id || Yt(), {
|
|
1250
1250
|
creator: n,
|
|
1251
1251
|
created: o,
|
|
1252
1252
|
modified: i,
|
|
1253
1253
|
body: r,
|
|
1254
1254
|
...a
|
|
1255
|
-
} = t, s =
|
|
1255
|
+
} = t, s = ln(r, e), u = un(t);
|
|
1256
1256
|
return "error" in u ? { error: u.error } : {
|
|
1257
1257
|
parsed: {
|
|
1258
1258
|
...a,
|
|
@@ -1261,7 +1261,7 @@ const On = (t, e) => ({
|
|
|
1261
1261
|
target: u.parsed
|
|
1262
1262
|
}
|
|
1263
1263
|
};
|
|
1264
|
-
},
|
|
1264
|
+
}, fn = (t, e, n) => {
|
|
1265
1265
|
const { bodies: o, target: i, ...r } = t, {
|
|
1266
1266
|
selector: a,
|
|
1267
1267
|
creator: s,
|
|
@@ -1269,9 +1269,9 @@ const On = (t, e) => ({
|
|
|
1269
1269
|
updated: f,
|
|
1270
1270
|
...b
|
|
1271
1271
|
} = i, l = a.map((m) => {
|
|
1272
|
-
const { quote:
|
|
1272
|
+
const { quote: g, start: y, end: v, range: h } = m, { prefix: d, suffix: c } = Zt(h, n), w = [{
|
|
1273
1273
|
type: "TextQuoteSelector",
|
|
1274
|
-
exact:
|
|
1274
|
+
exact: g,
|
|
1275
1275
|
prefix: d,
|
|
1276
1276
|
suffix: c
|
|
1277
1277
|
}, {
|
|
@@ -1291,7 +1291,7 @@ const On = (t, e) => ({
|
|
|
1291
1291
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
1292
1292
|
id: t.id,
|
|
1293
1293
|
type: "Annotation",
|
|
1294
|
-
body:
|
|
1294
|
+
body: cn(t.bodies),
|
|
1295
1295
|
creator: s,
|
|
1296
1296
|
created: u == null ? void 0 : u.toISOString(),
|
|
1297
1297
|
modified: f == null ? void 0 : f.toISOString(),
|
|
@@ -1299,18 +1299,18 @@ const On = (t, e) => ({
|
|
|
1299
1299
|
};
|
|
1300
1300
|
};
|
|
1301
1301
|
function gn(t, e, n, o, i) {
|
|
1302
|
-
|
|
1302
|
+
Dt(t, e, n || 0, o || t.length - 1, i || pn);
|
|
1303
1303
|
}
|
|
1304
|
-
function
|
|
1304
|
+
function Dt(t, e, n, o, i) {
|
|
1305
1305
|
for (; o > n; ) {
|
|
1306
1306
|
if (o - n > 600) {
|
|
1307
1307
|
var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), f = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), b = Math.max(n, Math.floor(e - a * u / r + f)), l = Math.min(o, Math.floor(e + (r - a) * u / r + f));
|
|
1308
|
-
|
|
1308
|
+
Dt(t, e, b, l, i);
|
|
1309
1309
|
}
|
|
1310
|
-
var m = t[e],
|
|
1311
|
-
for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o);
|
|
1312
|
-
for (W(t,
|
|
1313
|
-
|
|
1310
|
+
var m = t[e], g = n, y = o;
|
|
1311
|
+
for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); g < y; ) {
|
|
1312
|
+
for (W(t, g, y), g++, y--; i(t[g], m) < 0; )
|
|
1313
|
+
g++;
|
|
1314
1314
|
for (; i(t[y], m) > 0; )
|
|
1315
1315
|
y--;
|
|
1316
1316
|
}
|
|
@@ -1321,10 +1321,10 @@ function W(t, e, n) {
|
|
|
1321
1321
|
var o = t[e];
|
|
1322
1322
|
t[e] = t[n], t[n] = o;
|
|
1323
1323
|
}
|
|
1324
|
-
function
|
|
1324
|
+
function pn(t, e) {
|
|
1325
1325
|
return t < e ? -1 : t > e ? 1 : 0;
|
|
1326
1326
|
}
|
|
1327
|
-
class
|
|
1327
|
+
class mn {
|
|
1328
1328
|
constructor(e = 9) {
|
|
1329
1329
|
this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
|
|
1330
1330
|
}
|
|
@@ -1400,7 +1400,7 @@ class bn {
|
|
|
1400
1400
|
let s, u, f;
|
|
1401
1401
|
for (; o || r.length; ) {
|
|
1402
1402
|
if (o || (o = r.pop(), u = r[r.length - 1], s = a.pop(), f = !0), o.leaf) {
|
|
1403
|
-
const b =
|
|
1403
|
+
const b = bn(e, o.children, n);
|
|
1404
1404
|
if (b !== -1)
|
|
1405
1405
|
return o.children.splice(b, 1), r.push(o), this._condense(r), this;
|
|
1406
1406
|
}
|
|
@@ -1441,8 +1441,8 @@ class bn {
|
|
|
1441
1441
|
const l = Math.min(b + f - 1, o);
|
|
1442
1442
|
It(e, b, l, u, this.compareMinY);
|
|
1443
1443
|
for (let m = b; m <= l; m += u) {
|
|
1444
|
-
const
|
|
1445
|
-
s.children.push(this._build(e, m,
|
|
1444
|
+
const g = Math.min(m + u - 1, l);
|
|
1445
|
+
s.children.push(this._build(e, m, g, i - 1));
|
|
1446
1446
|
}
|
|
1447
1447
|
}
|
|
1448
1448
|
return P(s, this.toBBox), s;
|
|
@@ -1451,7 +1451,7 @@ class bn {
|
|
|
1451
1451
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1452
1452
|
let r = 1 / 0, a = 1 / 0, s;
|
|
1453
1453
|
for (let u = 0; u < n.children.length; u++) {
|
|
1454
|
-
const f = n.children[u], b = lt(f), l =
|
|
1454
|
+
const f = n.children[u], b = lt(f), l = yn(e, f) - b;
|
|
1455
1455
|
l < a ? (a = l, r = b < r ? b : r, s = f) : l === a && b < r && (r = b, s = f);
|
|
1456
1456
|
}
|
|
1457
1457
|
n = s || n.children[0];
|
|
@@ -1477,14 +1477,14 @@ class bn {
|
|
|
1477
1477
|
_chooseSplitIndex(e, n, o) {
|
|
1478
1478
|
let i, r = 1 / 0, a = 1 / 0;
|
|
1479
1479
|
for (let s = n; s <= o - n; s++) {
|
|
1480
|
-
const u = q(e, 0, s, this.toBBox), f = q(e, s, o, this.toBBox), b =
|
|
1480
|
+
const u = q(e, 0, s, this.toBBox), f = q(e, s, o, this.toBBox), b = xn(u, f), l = lt(u) + lt(f);
|
|
1481
1481
|
b < r ? (r = b, i = s, a = l < a ? l : a) : b === r && l < a && (a = l, i = s);
|
|
1482
1482
|
}
|
|
1483
1483
|
return i || o - n;
|
|
1484
1484
|
}
|
|
1485
1485
|
// sorts node children by the best axis for split
|
|
1486
1486
|
_chooseSplitAxis(e, n, o) {
|
|
1487
|
-
const i = e.leaf ? this.compareMinX :
|
|
1487
|
+
const i = e.leaf ? this.compareMinX : vn, r = e.leaf ? this.compareMinY : wn, a = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
|
|
1488
1488
|
a < s && e.children.sort(i);
|
|
1489
1489
|
}
|
|
1490
1490
|
// total margin of all possible split distributions where each node is at least m full
|
|
@@ -1511,7 +1511,7 @@ class bn {
|
|
|
1511
1511
|
e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : P(e[n], this.toBBox);
|
|
1512
1512
|
}
|
|
1513
1513
|
}
|
|
1514
|
-
function
|
|
1514
|
+
function bn(t, e, n) {
|
|
1515
1515
|
if (!n)
|
|
1516
1516
|
return e.indexOf(t);
|
|
1517
1517
|
for (let o = 0; o < e.length; o++)
|
|
@@ -1533,10 +1533,10 @@ function q(t, e, n, o, i) {
|
|
|
1533
1533
|
function j(t, e) {
|
|
1534
1534
|
return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
|
|
1535
1535
|
}
|
|
1536
|
-
function
|
|
1536
|
+
function vn(t, e) {
|
|
1537
1537
|
return t.minX - e.minX;
|
|
1538
1538
|
}
|
|
1539
|
-
function
|
|
1539
|
+
function wn(t, e) {
|
|
1540
1540
|
return t.minY - e.minY;
|
|
1541
1541
|
}
|
|
1542
1542
|
function lt(t) {
|
|
@@ -1545,10 +1545,10 @@ function lt(t) {
|
|
|
1545
1545
|
function Z(t) {
|
|
1546
1546
|
return t.maxX - t.minX + (t.maxY - t.minY);
|
|
1547
1547
|
}
|
|
1548
|
-
function
|
|
1548
|
+
function yn(t, e) {
|
|
1549
1549
|
return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
|
|
1550
1550
|
}
|
|
1551
|
-
function
|
|
1551
|
+
function xn(t, e) {
|
|
1552
1552
|
const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), r = Math.min(t.maxY, e.maxY);
|
|
1553
1553
|
return Math.max(0, i - n) * Math.max(0, r - o);
|
|
1554
1554
|
}
|
|
@@ -1578,18 +1578,18 @@ function It(t, e, n, o, i) {
|
|
|
1578
1578
|
gn(t, a, e, n, i), r.push(e, a, a, n);
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
1581
|
-
const
|
|
1582
|
-
const n = new
|
|
1581
|
+
const An = (t, e) => {
|
|
1582
|
+
const n = new mn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
|
|
1583
1583
|
const w = d.selector.flatMap((C) => {
|
|
1584
1584
|
const E = X([C]) ? C.range : Nt(C, e).range;
|
|
1585
1585
|
return Array.from(E.getClientRects());
|
|
1586
|
-
}), L =
|
|
1586
|
+
}), L = ie(w).map(({ left: C, top: E, right: T, bottom: p }) => new DOMRect(C - c.left, E - c.top, T - C, p - E));
|
|
1587
1587
|
return L.map((C) => {
|
|
1588
|
-
const { x: E, y: T, width:
|
|
1588
|
+
const { x: E, y: T, width: p, height: A } = C;
|
|
1589
1589
|
return {
|
|
1590
1590
|
minX: E,
|
|
1591
1591
|
minY: T,
|
|
1592
|
-
maxX: E +
|
|
1592
|
+
maxX: E + p,
|
|
1593
1593
|
maxY: T + A,
|
|
1594
1594
|
annotation: {
|
|
1595
1595
|
id: d.annotation,
|
|
@@ -1623,16 +1623,16 @@ const En = (t, e) => {
|
|
|
1623
1623
|
if (w.length > 0)
|
|
1624
1624
|
return w.sort((C, E) => L(C) - L(E)), w[0].annotation.id;
|
|
1625
1625
|
}, m = (d) => {
|
|
1626
|
-
const c =
|
|
1626
|
+
const c = g(d);
|
|
1627
1627
|
if (c.length === 0)
|
|
1628
1628
|
return;
|
|
1629
1629
|
let w = c[0].left, L = c[0].top, C = c[0].right, E = c[0].bottom;
|
|
1630
1630
|
for (let T = 1; T < c.length; T++) {
|
|
1631
|
-
const
|
|
1632
|
-
w = Math.min(w,
|
|
1631
|
+
const p = c[T];
|
|
1632
|
+
w = Math.min(w, p.left), L = Math.min(L, p.top), C = Math.max(C, p.right), E = Math.max(E, p.bottom);
|
|
1633
1633
|
}
|
|
1634
1634
|
return new DOMRect(w, L, C - w, E - L);
|
|
1635
|
-
},
|
|
1635
|
+
}, g = (d) => {
|
|
1636
1636
|
const c = o.get(d);
|
|
1637
1637
|
return c ? c[0].annotation.rects : [];
|
|
1638
1638
|
};
|
|
@@ -1641,12 +1641,12 @@ const En = (t, e) => {
|
|
|
1641
1641
|
clear: a,
|
|
1642
1642
|
getAt: l,
|
|
1643
1643
|
getAnnotationBounds: m,
|
|
1644
|
-
getAnnotationRects:
|
|
1644
|
+
getAnnotationRects: g,
|
|
1645
1645
|
getIntersecting: (d, c, w, L) => {
|
|
1646
|
-
const C = n.search({ minX: d, minY: c, maxX: w, maxY: L }), E = new Set(C.reduce((T,
|
|
1646
|
+
const C = n.search({ minX: d, minY: c, maxX: w, maxY: L }), E = new Set(C.reduce((T, p) => [...T, p.annotation.id], []));
|
|
1647
1647
|
return Array.from(E).map((T) => ({
|
|
1648
1648
|
annotation: t.getAnnotation(T),
|
|
1649
|
-
rects:
|
|
1649
|
+
rects: g(T)
|
|
1650
1650
|
})).filter((T) => !!T.annotation);
|
|
1651
1651
|
},
|
|
1652
1652
|
insert: s,
|
|
@@ -1656,8 +1656,8 @@ const En = (t, e) => {
|
|
|
1656
1656
|
size: () => n.all().length,
|
|
1657
1657
|
update: f
|
|
1658
1658
|
};
|
|
1659
|
-
},
|
|
1660
|
-
const n =
|
|
1659
|
+
}, En = (t, e) => {
|
|
1660
|
+
const n = We(), o = An(n, t), i = Oe(n, e), r = Ie(n), a = Ke(), s = (v, h = R.LOCAL) => {
|
|
1661
1661
|
const d = nt(v, t), c = X(d.target.selector);
|
|
1662
1662
|
return c && n.addAnnotation(d, h), c;
|
|
1663
1663
|
}, u = (v, h = !0, d = R.LOCAL) => {
|
|
@@ -1677,11 +1677,11 @@ const En = (t, e) => {
|
|
|
1677
1677
|
}, m = (v, h) => {
|
|
1678
1678
|
const d = o.getAt(v, h);
|
|
1679
1679
|
return d ? n.getAnnotation(d) : void 0;
|
|
1680
|
-
},
|
|
1680
|
+
}, g = (v, h, d, c = 5) => {
|
|
1681
1681
|
const w = o.getAnnotationRects(v);
|
|
1682
1682
|
if (w.length !== 0) {
|
|
1683
1683
|
if (h && d) {
|
|
1684
|
-
const L = w.find(({ top: C, right: E, bottom: T, left:
|
|
1684
|
+
const L = w.find(({ top: C, right: E, bottom: T, left: p }) => h >= p - c && h <= E + c && d >= C - c && d <= T + c);
|
|
1685
1685
|
if (L)
|
|
1686
1686
|
return L;
|
|
1687
1687
|
}
|
|
@@ -1698,7 +1698,7 @@ const En = (t, e) => {
|
|
|
1698
1698
|
bulkAddAnnotation: u,
|
|
1699
1699
|
bulkUpdateTargets: l,
|
|
1700
1700
|
bulkUpsertAnnotations: f,
|
|
1701
|
-
getAnnotationBounds:
|
|
1701
|
+
getAnnotationBounds: g,
|
|
1702
1702
|
getAt: m,
|
|
1703
1703
|
getIntersecting: o.getIntersecting,
|
|
1704
1704
|
recalculatePositions: y,
|
|
@@ -1708,15 +1708,15 @@ const En = (t, e) => {
|
|
|
1708
1708
|
hover: r,
|
|
1709
1709
|
viewport: a
|
|
1710
1710
|
};
|
|
1711
|
-
},
|
|
1711
|
+
}, Sn = () => {
|
|
1712
1712
|
const t = document.createElement("canvas");
|
|
1713
1713
|
t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-highlight-layer presence";
|
|
1714
1714
|
const e = t.getContext("2d");
|
|
1715
1715
|
return e.scale(2, 2), e.translate(0.5, 0.5), t;
|
|
1716
|
-
},
|
|
1717
|
-
const o =
|
|
1716
|
+
}, Cn = (t, e, n = {}) => {
|
|
1717
|
+
const o = Sn(), i = o.getContext("2d");
|
|
1718
1718
|
t.appendChild(o);
|
|
1719
|
-
const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([m,
|
|
1719
|
+
const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([m, g]) => g.presenceKey === l.presenceKey).map(([m, g]) => m);
|
|
1720
1720
|
return e.on("selectionChange", (l, m) => {
|
|
1721
1721
|
a(l).forEach((y) => r.delete(y)), m && m.forEach((y) => r.set(y, l));
|
|
1722
1722
|
}), {
|
|
@@ -1727,7 +1727,7 @@ const En = (t, e) => {
|
|
|
1727
1727
|
destroy: () => {
|
|
1728
1728
|
o.remove();
|
|
1729
1729
|
},
|
|
1730
|
-
paint: (l, m,
|
|
1730
|
+
paint: (l, m, g) => {
|
|
1731
1731
|
n.font && (i.font = n.font);
|
|
1732
1732
|
const y = r.get(l.annotation.id);
|
|
1733
1733
|
if (y) {
|
|
@@ -1736,7 +1736,7 @@ const En = (t, e) => {
|
|
|
1736
1736
|
const c = i.measureText(y.appearance.label), w = c.width + 6, L = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, C = c.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1737
1737
|
return i.fillRect(h - 2, d - 2.5 - L, w, L), i.fillStyle = "#fff", i.fillText(y.appearance.label, h + 1, d - C), {
|
|
1738
1738
|
fill: y.appearance.color,
|
|
1739
|
-
fillOpacity:
|
|
1739
|
+
fillOpacity: g ? 0.45 : 0.18
|
|
1740
1740
|
};
|
|
1741
1741
|
}
|
|
1742
1742
|
},
|
|
@@ -1746,16 +1746,16 @@ const En = (t, e) => {
|
|
|
1746
1746
|
l.scale(2, 2), l.translate(0.5, 0.5);
|
|
1747
1747
|
}
|
|
1748
1748
|
};
|
|
1749
|
-
},
|
|
1749
|
+
}, $t = (t) => {
|
|
1750
1750
|
if (t === null)
|
|
1751
1751
|
return document.scrollingElement;
|
|
1752
1752
|
const { overflowY: e } = window.getComputedStyle(t);
|
|
1753
|
-
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t :
|
|
1754
|
-
},
|
|
1753
|
+
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : $t(t.parentElement);
|
|
1754
|
+
}, Ln = (t, e) => (n) => {
|
|
1755
1755
|
const o = (r) => {
|
|
1756
|
-
const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = f.top - a.top,
|
|
1756
|
+
const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = f.top - a.top, g = f.left - a.left, y = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = m + y - (s - l) / 2, d = g + v - (u - b) / 2;
|
|
1757
1757
|
i.scroll({ top: h, left: d, behavior: "smooth" });
|
|
1758
|
-
}, i =
|
|
1758
|
+
}, i = $t(t);
|
|
1759
1759
|
if (i) {
|
|
1760
1760
|
const r = e.getAnnotation(n.id), { range: a } = r.target.selector[0];
|
|
1761
1761
|
if (a && !a.collapsed)
|
|
@@ -1767,10 +1767,10 @@ const En = (t, e) => {
|
|
|
1767
1767
|
}
|
|
1768
1768
|
}
|
|
1769
1769
|
return !1;
|
|
1770
|
-
},
|
|
1770
|
+
}, Tn = (t, e) => ({
|
|
1771
1771
|
...t,
|
|
1772
1772
|
annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled
|
|
1773
|
-
}),
|
|
1773
|
+
}), Bn = (t, e, n, o) => {
|
|
1774
1774
|
const { store: i, selection: r } = e;
|
|
1775
1775
|
let a, s;
|
|
1776
1776
|
const u = (h) => a = h;
|
|
@@ -1792,15 +1792,15 @@ const En = (t, e) => {
|
|
|
1792
1792
|
if (h.timeStamp - ((b == null ? void 0 : b.timeStamp) || h.timeStamp) < 1e3 && !s && l(b), d.isCollapsed || !f || !s)
|
|
1793
1793
|
return;
|
|
1794
1794
|
const c = d.getRangeAt(0);
|
|
1795
|
-
if (
|
|
1795
|
+
if (ee(c))
|
|
1796
1796
|
return;
|
|
1797
|
-
const w =
|
|
1797
|
+
const w = Kt(c.cloneRange());
|
|
1798
1798
|
(w.length !== s.selector.length || w.some((C, E) => {
|
|
1799
1799
|
var T;
|
|
1800
1800
|
return C.toString() !== ((T = s.selector[E]) == null ? void 0 : T.quote);
|
|
1801
1801
|
})) && (s = {
|
|
1802
1802
|
...s,
|
|
1803
|
-
selector: w.map((C) =>
|
|
1803
|
+
selector: w.map((C) => re(C, t, o))
|
|
1804
1804
|
}, i.getAnnotation(s.annotation) ? i.updateTarget(s, R.LOCAL) : (i.addAnnotation({
|
|
1805
1805
|
id: s.annotation,
|
|
1806
1806
|
bodies: [],
|
|
@@ -1808,11 +1808,11 @@ const En = (t, e) => {
|
|
|
1808
1808
|
}, R.LOCAL), r.clickSelect(s.annotation, b)));
|
|
1809
1809
|
});
|
|
1810
1810
|
n && document.addEventListener("selectionchange", m);
|
|
1811
|
-
const
|
|
1811
|
+
const g = (h) => {
|
|
1812
1812
|
const { target: d, timeStamp: c, offsetX: w, offsetY: L, type: C } = h;
|
|
1813
1813
|
b = { ...h, target: d, timeStamp: c, offsetX: w, offsetY: L, type: C }, f = h.button === 0;
|
|
1814
1814
|
};
|
|
1815
|
-
t.addEventListener("pointerdown",
|
|
1815
|
+
t.addEventListener("pointerdown", g);
|
|
1816
1816
|
const y = (h) => {
|
|
1817
1817
|
var L;
|
|
1818
1818
|
if (!!((L = h.target.parentElement) != null && L.closest(D)) || !f)
|
|
@@ -1820,8 +1820,8 @@ const En = (t, e) => {
|
|
|
1820
1820
|
const c = () => {
|
|
1821
1821
|
const { x: C, y: E } = t.getBoundingClientRect(), T = i.getAt(h.clientX - C, h.clientY - E);
|
|
1822
1822
|
if (T) {
|
|
1823
|
-
const { selected:
|
|
1824
|
-
(
|
|
1823
|
+
const { selected: p } = r;
|
|
1824
|
+
(p.length !== 1 || p[0].id !== T.id) && r.clickSelect(T.id, h);
|
|
1825
1825
|
} else
|
|
1826
1826
|
r.isEmpty() || r.clear();
|
|
1827
1827
|
}, w = h.timeStamp - b.timeStamp;
|
|
@@ -1829,23 +1829,25 @@ const En = (t, e) => {
|
|
|
1829
1829
|
};
|
|
1830
1830
|
return document.addEventListener("pointerup", y), {
|
|
1831
1831
|
destroy: () => {
|
|
1832
|
-
t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", m), t.removeEventListener("pointerdown",
|
|
1832
|
+
t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", m), t.removeEventListener("pointerdown", g), document.removeEventListener("pointerup", y);
|
|
1833
1833
|
},
|
|
1834
1834
|
setUser: u
|
|
1835
1835
|
};
|
|
1836
1836
|
}, Mt = "SPANS", Nn = (t, e = {}) => {
|
|
1837
|
-
t.addEventListener("click", (E) =>
|
|
1838
|
-
|
|
1837
|
+
t.addEventListener("click", (E) => {
|
|
1838
|
+
!E.target.closest(D) && !E.target.closest("a") && E.preventDefault();
|
|
1839
|
+
});
|
|
1840
|
+
const n = Tn(e, {
|
|
1839
1841
|
annotationEnabled: !0
|
|
1840
|
-
}), o =
|
|
1841
|
-
let f =
|
|
1842
|
-
const b = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Mt : n.renderer || Mt, l = b === "SPANS" ?
|
|
1842
|
+
}), o = En(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Ge(a), u = Qe(o, s, n.adapter);
|
|
1843
|
+
let f = sn();
|
|
1844
|
+
const b = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Mt : n.renderer || Mt, l = b === "SPANS" ? Se(t, o, r) : b === "CSS_HIGHLIGHTS" ? xe(t, o, r) : b === "CANVAS" ? ue(t, o, r) : void 0;
|
|
1843
1845
|
if (!l)
|
|
1844
1846
|
throw `Unknown renderer implementation: ${b}`;
|
|
1845
1847
|
console.debug(`Using ${b} renderer`), n.style && l.setStyle(n.style);
|
|
1846
|
-
const m =
|
|
1848
|
+
const m = Bn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
|
|
1847
1849
|
return m.setUser(f), {
|
|
1848
|
-
...
|
|
1850
|
+
...Ze(o, s, n.adapter),
|
|
1849
1851
|
destroy: () => {
|
|
1850
1852
|
l.destroy(), m.destroy(), s.destroy();
|
|
1851
1853
|
},
|
|
@@ -1860,47 +1862,47 @@ const En = (t, e) => {
|
|
|
1860
1862
|
E ? i.setSelected(E) : i.clear();
|
|
1861
1863
|
},
|
|
1862
1864
|
setPresenceProvider: (E) => {
|
|
1863
|
-
E && (l.setPainter(
|
|
1865
|
+
E && (l.setPainter(Cn(t, E, n.presence)), E.on("selectionChange", () => l.redraw()));
|
|
1864
1866
|
},
|
|
1865
1867
|
setVisible: (E) => l.setVisible(E),
|
|
1866
1868
|
on: u.on,
|
|
1867
1869
|
off: u.off,
|
|
1868
|
-
scrollIntoView:
|
|
1870
|
+
scrollIntoView: Ln(t, a),
|
|
1869
1871
|
state: o
|
|
1870
1872
|
};
|
|
1871
|
-
}
|
|
1873
|
+
};
|
|
1872
1874
|
export {
|
|
1873
1875
|
ht as DEFAULT_SELECTED_STYLE,
|
|
1874
1876
|
$ as DEFAULT_STYLE,
|
|
1875
1877
|
Ot as NOT_ANNOTATABLE_CLASS,
|
|
1876
1878
|
D as NOT_ANNOTATABLE_SELECTOR,
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
+
R as Origin,
|
|
1880
|
+
Me as PointerSelectAction,
|
|
1879
1881
|
On as W3CTextFormat,
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1882
|
+
Mn as createBody,
|
|
1883
|
+
ue as createCanvasRenderer,
|
|
1884
|
+
xe as createHighlightsRenderer,
|
|
1885
|
+
ye as createRenderer,
|
|
1886
|
+
Se as createSpansRenderer,
|
|
1885
1887
|
Nn as createTextAnnotator,
|
|
1886
|
-
|
|
1888
|
+
En as createTextAnnotatorState,
|
|
1887
1889
|
ft as debounce,
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1890
|
+
Tn as fillDefaults,
|
|
1891
|
+
Rn as getAnnotatableFragment,
|
|
1892
|
+
In as getClientRectsPonyfill,
|
|
1893
|
+
Zt as getQuoteContext,
|
|
1892
1894
|
dt as getRangeAnnotatableContents,
|
|
1893
1895
|
X as isRevived,
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1896
|
+
ee as isWhitespaceOrEmpty,
|
|
1897
|
+
ie as mergeClientRects,
|
|
1898
|
+
qt as paint,
|
|
1899
|
+
hn as parseW3CTextAnnotation,
|
|
1900
|
+
re as rangeToSelector,
|
|
1899
1901
|
nt as reviveAnnotation,
|
|
1900
1902
|
Nt as reviveSelector,
|
|
1901
1903
|
et as reviveTarget,
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1904
|
+
fn as serializeW3CTextAnnotation,
|
|
1905
|
+
Kt as splitAnnotatableRanges,
|
|
1906
|
+
te as whitespaceOrEmptyRegex
|
|
1905
1907
|
};
|
|
1906
1908
|
//# sourceMappingURL=text-annotator.es.js.map
|