@soomo/react-text-annotator 3.0.0-staging.57 → 3.0.0-staging.59
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.
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
const
|
|
1
|
+
const kt = "not-annotatable", X = `.${kt}`, bt = (t) => {
|
|
2
2
|
const e = t.cloneContents();
|
|
3
3
|
return e.querySelectorAll(X).forEach((n) => n.remove()), e;
|
|
4
|
-
},
|
|
4
|
+
}, ee = (t, e, n = 10, o) => {
|
|
5
5
|
const i = e, r = document.createRange();
|
|
6
6
|
r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
7
|
-
const
|
|
7
|
+
const c = bt(r).textContent, a = document.createRange();
|
|
8
8
|
a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
9
|
-
const
|
|
9
|
+
const d = bt(a).textContent;
|
|
10
10
|
return {
|
|
11
|
-
prefix:
|
|
12
|
-
suffix:
|
|
11
|
+
prefix: c.substring(c.length - n),
|
|
12
|
+
suffix: d.substring(0, n)
|
|
13
13
|
};
|
|
14
14
|
};
|
|
15
15
|
var U = [];
|
|
16
16
|
for (var dt = 0; dt < 256; ++dt)
|
|
17
17
|
U.push((dt + 256).toString(16).slice(1));
|
|
18
|
-
function
|
|
18
|
+
function Me(t, e = 0) {
|
|
19
19
|
return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
|
|
20
20
|
}
|
|
21
|
-
var Z,
|
|
22
|
-
function
|
|
21
|
+
var Z, Oe = new Uint8Array(16);
|
|
22
|
+
function Ie() {
|
|
23
23
|
if (!Z && (Z = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))
|
|
24
24
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
25
|
-
return Z(
|
|
25
|
+
return Z(Oe);
|
|
26
26
|
}
|
|
27
|
-
var
|
|
27
|
+
var Ne = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
28
28
|
const Ot = {
|
|
29
|
-
randomUUID:
|
|
29
|
+
randomUUID: Ne
|
|
30
30
|
};
|
|
31
31
|
function Pt(t, e, n) {
|
|
32
32
|
if (Ot.randomUUID && !e && !t)
|
|
33
33
|
return Ot.randomUUID();
|
|
34
34
|
t = t || {};
|
|
35
|
-
var o = t.random || (t.rng ||
|
|
36
|
-
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128,
|
|
35
|
+
var o = t.random || (t.rng || Ie)();
|
|
36
|
+
return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Me(o);
|
|
37
37
|
}
|
|
38
38
|
var V = [];
|
|
39
39
|
for (var ht = 0; ht < 256; ++ht)
|
|
40
40
|
V.push((ht + 256).toString(16).slice(1));
|
|
41
41
|
typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
42
|
-
const
|
|
43
|
-
let
|
|
42
|
+
const on = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
43
|
+
let cn = (t = 21) => {
|
|
44
44
|
let e = "", n = crypto.getRandomValues(new Uint8Array(t));
|
|
45
45
|
for (; t--; )
|
|
46
|
-
e +=
|
|
46
|
+
e += on[n[t] & 63];
|
|
47
47
|
return e;
|
|
48
48
|
};
|
|
49
|
-
const
|
|
49
|
+
const dn = (t) => {
|
|
50
50
|
const e = JSON.stringify(t);
|
|
51
51
|
let n = 0;
|
|
52
52
|
for (let o = 0, i = e.length; o < i; o++) {
|
|
@@ -54,108 +54,108 @@ const hn = (t) => {
|
|
|
54
54
|
n = (n << 5) - n + r, n |= 0;
|
|
55
55
|
}
|
|
56
56
|
return `${n}`;
|
|
57
|
-
},
|
|
58
|
-
const { id: o, type: i, purpose: r, value:
|
|
57
|
+
}, Ft = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, un = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
58
|
+
const { id: o, type: i, purpose: r, value: c, created: a, modified: d, creator: u, ...g } = n;
|
|
59
59
|
return {
|
|
60
|
-
id: o || `temp-${
|
|
60
|
+
id: o || `temp-${dn(n)}`,
|
|
61
61
|
annotation: e,
|
|
62
62
|
type: i,
|
|
63
63
|
purpose: r,
|
|
64
|
-
value:
|
|
65
|
-
creator:
|
|
64
|
+
value: c,
|
|
65
|
+
creator: Ft(u),
|
|
66
66
|
created: a ? new Date(a) : void 0,
|
|
67
|
-
updated:
|
|
67
|
+
updated: d ? new Date(d) : void 0,
|
|
68
68
|
...g
|
|
69
69
|
};
|
|
70
|
-
}),
|
|
70
|
+
}), hn = (t) => t.map((e) => {
|
|
71
71
|
var n;
|
|
72
|
-
const { annotation: o, created: i, updated: r, ...
|
|
73
|
-
...
|
|
72
|
+
const { annotation: o, created: i, updated: r, ...c } = e, a = {
|
|
73
|
+
...c,
|
|
74
74
|
created: i == null ? void 0 : i.toISOString(),
|
|
75
75
|
modified: r == null ? void 0 : r.toISOString()
|
|
76
76
|
};
|
|
77
77
|
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
78
78
|
});
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
parse: (n) =>
|
|
82
|
-
serialize: (n) =>
|
|
83
|
-
}),
|
|
79
|
+
cn();
|
|
80
|
+
const In = (t, e) => ({
|
|
81
|
+
parse: (n) => pn(n),
|
|
82
|
+
serialize: (n) => mn(n, t, e)
|
|
83
|
+
}), fn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, gn = (t) => {
|
|
84
84
|
const {
|
|
85
85
|
id: e,
|
|
86
86
|
creator: n,
|
|
87
87
|
created: o,
|
|
88
88
|
modified: i,
|
|
89
89
|
target: r
|
|
90
|
-
} = t,
|
|
91
|
-
creator:
|
|
90
|
+
} = t, c = Array.isArray(r) ? r : [r], a = {
|
|
91
|
+
creator: Ft(n),
|
|
92
92
|
created: o ? new Date(o) : void 0,
|
|
93
93
|
updated: i ? new Date(i) : void 0,
|
|
94
94
|
annotation: e,
|
|
95
95
|
selector: []
|
|
96
96
|
};
|
|
97
|
-
for (const
|
|
98
|
-
const g = (Array.isArray(
|
|
99
|
-
switch (
|
|
97
|
+
for (const d of c) {
|
|
98
|
+
const g = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((h, v) => {
|
|
99
|
+
switch (v.type) {
|
|
100
100
|
case "TextQuoteSelector":
|
|
101
|
-
|
|
101
|
+
h.quote = v.exact;
|
|
102
102
|
break;
|
|
103
103
|
case "TextPositionSelector":
|
|
104
|
-
|
|
104
|
+
h.start = v.start, h.end = v.end;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
|
-
return
|
|
107
|
+
return h;
|
|
108
108
|
}, {});
|
|
109
|
-
if (
|
|
110
|
-
a.selector.push({ id:
|
|
109
|
+
if (fn(g))
|
|
110
|
+
a.selector.push({ id: d.id, ...g });
|
|
111
111
|
else {
|
|
112
|
-
const
|
|
112
|
+
const h = [
|
|
113
113
|
g.start ? void 0 : "TextPositionSelector",
|
|
114
114
|
g.quote ? void 0 : "TextQuoteSelector"
|
|
115
115
|
].filter(Boolean);
|
|
116
|
-
return { error: Error(`Missing selector types: ${
|
|
116
|
+
return { error: Error(`Missing selector types: ${h.join(" and ")} for annotation: ${t.id}`) };
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
return { parsed: a };
|
|
120
|
-
},
|
|
120
|
+
}, pn = (t) => {
|
|
121
121
|
const e = t.id || Pt(), {
|
|
122
122
|
creator: n,
|
|
123
123
|
created: o,
|
|
124
124
|
modified: i,
|
|
125
125
|
body: r,
|
|
126
|
-
...
|
|
127
|
-
} = t, a =
|
|
128
|
-
return "error" in
|
|
126
|
+
...c
|
|
127
|
+
} = t, a = un(r, e), d = gn(t);
|
|
128
|
+
return "error" in d ? { error: d.error } : {
|
|
129
129
|
parsed: {
|
|
130
|
-
...
|
|
130
|
+
...c,
|
|
131
131
|
id: e,
|
|
132
132
|
bodies: a,
|
|
133
|
-
target:
|
|
133
|
+
target: d.parsed
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
|
-
},
|
|
136
|
+
}, mn = (t, e, n) => {
|
|
137
137
|
const { bodies: o, target: i, ...r } = t, {
|
|
138
|
-
selector:
|
|
138
|
+
selector: c,
|
|
139
139
|
creator: a,
|
|
140
|
-
created:
|
|
141
|
-
updated:
|
|
140
|
+
created: d,
|
|
141
|
+
updated: u,
|
|
142
142
|
...g
|
|
143
|
-
} = i,
|
|
144
|
-
const { quote: f, start:
|
|
143
|
+
} = i, h = c.map((v) => {
|
|
144
|
+
const { quote: f, start: S, end: y, range: b } = v, { prefix: l, suffix: s } = ee(b, n), p = [{
|
|
145
145
|
type: "TextQuoteSelector",
|
|
146
146
|
exact: f,
|
|
147
147
|
prefix: l,
|
|
148
|
-
suffix:
|
|
148
|
+
suffix: s
|
|
149
149
|
}, {
|
|
150
150
|
type: "TextPositionSelector",
|
|
151
|
-
start:
|
|
152
|
-
end:
|
|
151
|
+
start: S,
|
|
152
|
+
end: y
|
|
153
153
|
}];
|
|
154
154
|
return {
|
|
155
155
|
...g,
|
|
156
|
-
id:
|
|
156
|
+
id: v.id,
|
|
157
157
|
source: e,
|
|
158
|
-
selector:
|
|
158
|
+
selector: p
|
|
159
159
|
};
|
|
160
160
|
});
|
|
161
161
|
return {
|
|
@@ -163,20 +163,20 @@ const kn = (t, e) => ({
|
|
|
163
163
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
164
164
|
id: t.id,
|
|
165
165
|
type: "Annotation",
|
|
166
|
-
body:
|
|
166
|
+
body: hn(t.bodies),
|
|
167
167
|
creator: a,
|
|
168
|
-
created:
|
|
169
|
-
modified:
|
|
170
|
-
target:
|
|
168
|
+
created: d == null ? void 0 : d.toISOString(),
|
|
169
|
+
modified: u == null ? void 0 : u.toISOString(),
|
|
170
|
+
target: h
|
|
171
171
|
};
|
|
172
172
|
};
|
|
173
173
|
export {
|
|
174
|
-
|
|
174
|
+
kt as NOT_ANNOTATABLE_CLASS,
|
|
175
175
|
X as NOT_ANNOTATABLE_SELECTOR,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
176
|
+
In as W3CTextFormat,
|
|
177
|
+
ee as getQuoteContext,
|
|
178
|
+
bt as getRangeAnnotatableContents,
|
|
179
|
+
pn as parseW3CTextAnnotation,
|
|
180
|
+
mn as serializeW3CTextAnnotation
|
|
181
181
|
};
|
|
182
182
|
//# sourceMappingURL=react-text-annotator.es7.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react-text-annotator.es7.js","sources":["../../../node_modules/@recogito/text-annotator/dist/text-annotator.es.js"],"sourcesContent":["const P = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.18\n}, it = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.45\n}, Jt = (t, e, n, o, i) => {\n var s, a;\n const r = n ? typeof n == \"function\" ? n(t.annotation, t.state, i) || ((s = t.state) != null && s.selected ? it : P) : n : (a = t.state) != null && a.selected ? it : P;\n return o && o.paint(t, e) || r;\n}, Dt = \"not-annotatable\", X = `.${Dt}`, Zt = (t) => {\n var n;\n const e = t.commonAncestorContainer;\n return e instanceof HTMLElement ? !e.closest(X) : !((n = e.parentElement) != null && n.closest(X));\n}, te = function* (t) {\n const e = document.createNodeIterator(\n t.commonAncestorContainer,\n NodeFilter.SHOW_ELEMENT,\n (o) => o instanceof HTMLElement && o.classList.contains(Dt) && !o.parentElement.closest(X) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n );\n let n;\n for (; n = e.nextNode(); )\n n instanceof HTMLElement && (yield n);\n}, ee = (t) => {\n if (!Zt(t)) return [];\n const e = [];\n let n = null;\n for (const o of te(t)) {\n let i;\n n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;\n }\n if (n) {\n const o = t.cloneRange();\n o.setStartAfter(n), o.collapsed || e.push(o);\n }\n return e.length > 0 ? e : [t];\n}, mt = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(X).forEach((n) => n.remove()), e;\n}, ne = (t) => {\n t.addEventListener(\"click\", (e) => {\n // Allow clicks within not-annotatable elements\n !e.target.closest(X) && !e.target.closest(\"a\") && e.preventDefault();\n });\n}, vt = (t, e = 10) => {\n let n;\n return (...o) => {\n clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);\n };\n}, In = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(X).forEach((n) => n.remove()), e;\n}, xt = (t, e) => {\n const n = document.createNodeIterator(e);\n let o = 0, i = n.nextNode();\n for (; i !== null; ) {\n if (i === t)\n return o;\n o += 1, i = n.nextNode();\n }\n}, At = (t, e) => {\n const n = document.createNodeIterator(e);\n let o = null;\n for (let i = 0; i < t + 1; i++)\n o = n.nextNode();\n return o;\n}, oe = (t) => {\n const {\n commonAncestorContainer: e,\n startContainer: n,\n startOffset: o,\n endContainer: i,\n endOffset: r\n } = t, s = Array.from(e.childNodes).map((d) => {\n const b = d.cloneNode(!0);\n return d.nodeName === \"CANVAS\" ? d : b;\n }), a = xt(n, e), u = xt(i, e), h = () => {\n const d = e;\n d.replaceChildren(...s);\n const b = At(a, d), f = At(u, d);\n return t.setStart(b, o), t.setEnd(f, r), t;\n }, g = (d) => {\n const b = document.createElement(\"SPAN\");\n return d.surroundContents(b), b;\n };\n if (n === i)\n throw \"Not implemented\";\n {\n const d = document.createRange();\n d.selectNodeContents(n), d.setStart(n, o);\n const b = g(d), f = document.createRange();\n f.selectNode(i), f.setEnd(i, r);\n const A = g(f), p = ie(t).reverse().map((l) => {\n var m;\n const c = document.createElement(\"SPAN\");\n return (m = l.parentNode) == null || m.insertBefore(c, l), c.appendChild(l), c;\n });\n return { unwrap: h, nodes: [b, ...p, A] };\n }\n}, ie = (t) => {\n const {\n commonAncestorContainer: e,\n startContainer: n,\n endContainer: o\n } = t, i = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);\n let r = i.nextNode(), s = !1;\n const a = [];\n for (; r != null; )\n r === o && (s = !1), s && a.push(r), r === n && (s = !0), r = i.nextNode();\n return a;\n}, Un = (t) => {\n const { startContainer: e, endContainer: n } = t;\n if (e === n)\n return Array.from(t.getClientRects());\n {\n const { unwrap: o, nodes: i } = oe(t), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);\n return o(), r;\n }\n}, re = (t, e, n = 10, o) => {\n const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();\n r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);\n const s = mt(r).textContent, a = document.createRange();\n a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);\n const u = mt(a).textContent;\n return {\n prefix: s.substring(s.length - n),\n suffix: u.substring(0, n)\n };\n}, se = /^\\s*$/, ae = (t) => se.test(t.toString()), H = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ce = (t, e) => {\n const n = (r) => Math.round(r * 10) / 10, o = {\n top: n(t.top),\n bottom: n(t.bottom),\n left: n(t.left),\n right: n(t.right)\n }, i = {\n top: n(e.top),\n bottom: n(e.bottom),\n left: n(e.left),\n right: n(e.right)\n };\n if (Math.abs(o.top - i.top) < 0.5 && Math.abs(o.bottom - i.bottom) < 0.5) {\n if (Math.abs(o.left - i.right) < 0.5 || Math.abs(o.right - i.left) < 0.5)\n return \"inline-adjacent\";\n if (o.left >= i.left && o.right <= i.right)\n return \"inline-is-contained\";\n if (o.left <= i.left && o.right >= i.right)\n return \"inline-contains\";\n } else if (o.top <= i.top && o.bottom >= i.bottom) {\n if (o.left <= i.left && o.right >= i.right)\n return \"block-contains\";\n } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)\n return \"block-is-contained\";\n}, le = (t, e) => {\n 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);\n return new DOMRect(n, i, o - n, r - i);\n}, de = (t) => t.reduce((e, n) => {\n if (n.width === 0 || n.height === 0)\n return e;\n let o = [...e], i = !1;\n for (const r of e) {\n const s = ce(n, r);\n if (s === \"inline-adjacent\") {\n o = o.map((a) => a === r ? le(n, r) : a), i = !0;\n break;\n } else if (s === \"inline-contains\") {\n o = o.map((a) => a === r ? n : a), i = !0;\n break;\n } else if (s === \"inline-is-contained\") {\n i = !0;\n break;\n } else if (s === \"block-contains\" || s === \"block-is-contained\") {\n n.width < r.width && (o = o.map((a) => a === r ? n : a)), i = !0;\n break;\n }\n }\n return i ? o : [...o, n];\n}, []), ue = (t, e, n) => {\n const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;\n o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);\n const r = mt(o).textContent, s = t.toString(), a = r.length || 0, u = a + s.length;\n return n ? { quote: s, start: a, end: u, range: t, offsetReference: i } : { quote: s, start: a, end: u, range: t };\n}, Yt = (t, e) => {\n var g, d;\n const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(\n e,\n NodeFilter.SHOW_TEXT,\n (b) => {\n var f;\n return (f = b.parentElement) != null && f.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;\n }\n );\n let s = 0;\n const a = document.createRange();\n let u = r.nextNode();\n u === null && console.error(\"Could not revive annotation target. Content missing.\");\n let h = !i;\n for (; u !== null; ) {\n if (h || (h = i == null ? void 0 : i.contains(u)), h) {\n const b = ((g = u.textContent) == null ? void 0 : g.length) || 0;\n if (s + b > n) {\n a.setStart(u, n - s);\n break;\n }\n s += b;\n }\n u = r.nextNode();\n }\n for (; u !== null; ) {\n const b = ((d = u.textContent) == null ? void 0 : d.length) || 0;\n if (s + b >= o) {\n a.setEnd(u, o - s);\n break;\n }\n s += b, u = r.nextNode();\n }\n return {\n ...t,\n range: a\n };\n}, rt = (t, e) => H(t.selector) ? t : {\n ...t,\n selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Yt(n, e))\n}, st = (t, e) => H(t.target.selector) ? t : { ...t, target: rt(t.target, e) }, he = (t, e) => {\n const n = t.cloneRange();\n return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;\n}, fe = (t) => {\n const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -e, a = o - n, u = i - e;\n return { top: e, left: n, minX: r, minY: s, maxX: a, maxY: u };\n}, ge = (t) => {\n let e = /* @__PURE__ */ new Set();\n return (o) => {\n const i = o.map((r) => r.id);\n (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);\n };\n}, yt = (t, e, n, o) => {\n const { store: i, selection: r, hover: s } = e;\n let a, u, h;\n const g = ge(n), d = (R) => {\n const { x: O, y } = t.getBoundingClientRect(), x = i.getAt(R.clientX - O, R.clientY - y, u);\n x ? s.current !== x.id && (t.classList.add(\"hovered\"), s.set(x.id)) : s.current && (t.classList.remove(\"hovered\"), s.set(null));\n };\n t.addEventListener(\"pointermove\", d);\n const b = (R = !1) => {\n h && h.clear();\n const O = fe(t), { minX: y, minY: x, maxX: w, maxY: E } = O, M = u ? i.getIntersecting(y, x, w, E).filter(({ annotation: _ }) => u(_)) : i.getIntersecting(y, x, w, E), B = r.selected.map(({ id: _ }) => _), k = M.map(({ annotation: _, rects: Gt }) => {\n const Kt = B.includes(_.id), Qt = _.id === s.current;\n return { annotation: _, rects: Gt, state: { selected: Kt, hover: Qt } };\n });\n o.redraw(k, O, a, h, R), setTimeout(() => g(M.map(({ annotation: _ }) => _)), 1);\n }, f = (R) => {\n h = R, b();\n }, A = (R) => {\n a = R, b();\n }, v = (R) => {\n u = R, b(!1);\n }, p = () => b();\n i.observe(p);\n const l = r.subscribe(() => b()), c = () => b(!0);\n document.addEventListener(\"scroll\", c, { capture: !0, passive: !0 });\n const m = vt(() => {\n i.recalculatePositions(), h && h.reset(), b();\n });\n window.addEventListener(\"resize\", m);\n const C = new ResizeObserver(m);\n C.observe(t);\n const L = { attributes: !0, childList: !0, subtree: !0 }, S = new MutationObserver((R) => {\n R.every((y) => y.target === t || t.contains(y.target)) || b(!0);\n });\n return S.observe(document.body, L), {\n destroy: () => {\n t.removeEventListener(\"pointermove\", d), o.destroy(), i.unobserve(p), l(), document.removeEventListener(\"scroll\", c), window.removeEventListener(\"resize\", m), C.disconnect(), S.disconnect();\n },\n redraw: b,\n setStyle: A,\n setFilter: v,\n setPainter: f,\n setVisible: o.setVisible\n };\n}, pe = () => {\n const t = document.createElement(\"canvas\");\n return t.width = window.innerWidth, t.height = window.innerHeight, t.className = \"r6o-canvas-highlight-layer bg\", t;\n}, me = (t, e) => {\n t.width = window.innerWidth, t.height = window.innerHeight;\n}, be = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = pe(), n = e.getContext(\"2d\");\n document.body.appendChild(e);\n const o = (a, u, h, g) => requestAnimationFrame(() => {\n const { width: d, height: b } = e;\n n.clearRect(-0.5, -0.5, d + 1, b + 1), g && g.clear();\n const { top: f, left: A } = u;\n [...a].sort((p, l) => {\n const { annotation: { target: { created: c } } } = p, { annotation: { target: { created: m } } } = l;\n return c.getTime() - m.getTime();\n }).forEach((p) => {\n var C;\n const l = h ? typeof h == \"function\" ? h(p.annotation, p.state) : h : (C = p.state) != null && C.selected ? it : P, c = g && g.paint(p, u) || l, m = p.rects.map(({ x: L, y: S, width: T, height: R }) => ({\n x: L + A,\n y: S + f,\n width: T,\n height: R\n }));\n if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, m.forEach(\n ({ x: L, y: S, width: T, height: R }) => n.fillRect(L, S, T, R)\n ), c.underlineColor) {\n n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;\n const L = c.underlineOffset ?? 0;\n m.forEach(({ x: S, y: T, width: R, height: O }) => {\n n.beginPath(), n.moveTo(S, T + O + L), n.lineTo(S + R, T + O + L), n.stroke();\n });\n }\n });\n }), i = vt(() => {\n me(e);\n });\n return window.addEventListener(\"resize\", i), {\n destroy: () => {\n e.remove(), window.removeEventListener(\"resize\", i);\n },\n setVisible: (a) => {\n console.log(\"setVisible not implemented on Canvas renderer\");\n },\n redraw: o\n };\n}, ve = (t, e, n) => yt(t, e, n, be(t));\nvar ye = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {\n return typeof t == \"string\" ? t.length > 0 : typeof t == \"number\";\n}, I = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;\n}, D = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;\n}, Xt = function(t) {\n return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;\n}, St = function(t) {\n return { r: D(t.r, 0, 255), g: D(t.g, 0, 255), b: D(t.b, 0, 255), a: D(t.a) };\n}, at = function(t) {\n return { r: I(t.r), g: I(t.g), b: I(t.b), a: I(t.a, 3) };\n}, we = /^#([0-9a-f]{3,8})$/i, J = function(t) {\n var e = t.toString(16);\n return e.length < 2 ? \"0\" + e : e;\n}, $t = function(t) {\n var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), s = r - Math.min(e, n, o), a = s ? r === e ? (n - o) / s : r === n ? 2 + (o - e) / s : 4 + (e - n) / s : 0;\n return { h: 60 * (a < 0 ? a + 6 : a), s: r ? s / r * 100 : 0, v: r / 255 * 100, a: i };\n}, Ht = function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a;\n e = e / 360 * 6, n /= 100, o /= 100;\n var r = Math.floor(e), s = o * (1 - n), a = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), h = r % 6;\n return { r: 255 * [o, a, s, s, u, o][h], g: 255 * [u, o, o, a, s, s][h], b: 255 * [s, s, u, o, o, a][h], a: i };\n}, Et = function(t) {\n return { h: Xt(t.h), s: D(t.s, 0, 100), l: D(t.l, 0, 100), a: D(t.a) };\n}, Ct = function(t) {\n return { h: I(t.h), s: I(t.s), l: I(t.l), a: I(t.a, 3) };\n}, Lt = function(t) {\n return Ht((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 }));\n var e, n, o;\n}, Q = function(t) {\n return { h: (e = $t(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 };\n var e, n, o, i;\n}, xe = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Ae = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s+([+-]?\\d*\\.?\\d+)%\\s+([+-]?\\d*\\.?\\d+)%\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Se = /^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Ee = /^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Tt = { string: [[function(t) {\n var e = we.exec(t);\n 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;\n}, \"hex\"], [function(t) {\n var e = Se.exec(t) || Ee.exec(t);\n return e ? e[2] !== e[4] || e[4] !== e[6] ? null : St({ 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;\n}, \"rgb\"], [function(t) {\n var e = xe.exec(t) || Ae.exec(t);\n if (!e) return null;\n var n, o, i = Et({ h: (n = e[1], o = e[2], o === void 0 && (o = \"deg\"), Number(n) * (ye[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });\n return Lt(i);\n}, \"hsl\"]], object: [[function(t) {\n var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;\n return $(e) && $(n) && $(o) ? St({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;\n}, \"rgb\"], [function(t) {\n var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;\n if (!$(e) || !$(n) || !$(o)) return null;\n var s = Et({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });\n return Lt(s);\n}, \"hsl\"], [function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;\n if (!$(e) || !$(n) || !$(o)) return null;\n var s = function(a) {\n return { h: Xt(a.h), s: D(a.s, 0, 100), v: D(a.v, 0, 100), a: D(a.a) };\n }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });\n return Ht(s);\n}, \"hsv\"]] }, Rt = function(t, e) {\n for (var n = 0; n < e.length; n++) {\n var o = e[n][0](t);\n if (o) return [o, e[n][1]];\n }\n return [null, void 0];\n}, Ce = function(t) {\n return typeof t == \"string\" ? Rt(t.trim(), Tt.string) : typeof t == \"object\" && t !== null ? Rt(t, Tt.object) : [null, void 0];\n}, ct = function(t, e) {\n var n = Q(t);\n return { h: n.h, s: D(n.s + 100 * e, 0, 100), l: n.l, a: n.a };\n}, lt = function(t) {\n return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;\n}, Bt = function(t, e) {\n var n = Q(t);\n return { h: n.h, s: n.s, l: D(n.l + 100 * e, 0, 100), a: n.a };\n}, Nt = function() {\n function t(e) {\n this.parsed = Ce(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };\n }\n return t.prototype.isValid = function() {\n return this.parsed !== null;\n }, t.prototype.brightness = function() {\n return I(lt(this.rgba), 2);\n }, t.prototype.isDark = function() {\n return lt(this.rgba) < 0.5;\n }, t.prototype.isLight = function() {\n return lt(this.rgba) >= 0.5;\n }, t.prototype.toHex = function() {\n return e = at(this.rgba), n = e.r, o = e.g, i = e.b, s = (r = e.a) < 1 ? J(I(255 * r)) : \"\", \"#\" + J(n) + J(o) + J(i) + s;\n var e, n, o, i, r, s;\n }, t.prototype.toRgb = function() {\n return at(this.rgba);\n }, t.prototype.toRgbString = function() {\n return e = at(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? \"rgba(\" + n + \", \" + o + \", \" + i + \", \" + r + \")\" : \"rgb(\" + n + \", \" + o + \", \" + i + \")\";\n var e, n, o, i, r;\n }, t.prototype.toHsl = function() {\n return Ct(Q(this.rgba));\n }, t.prototype.toHslString = function() {\n return e = Ct(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 + \"%)\";\n var e, n, o, i, r;\n }, t.prototype.toHsv = function() {\n return e = $t(this.rgba), { h: I(e.h), s: I(e.s), v: I(e.v), a: I(e.a, 3) };\n var e;\n }, t.prototype.invert = function() {\n return Y({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });\n var e;\n }, t.prototype.saturate = function(e) {\n return e === void 0 && (e = 0.1), Y(ct(this.rgba, e));\n }, t.prototype.desaturate = function(e) {\n return e === void 0 && (e = 0.1), Y(ct(this.rgba, -e));\n }, t.prototype.grayscale = function() {\n return Y(ct(this.rgba, -1));\n }, t.prototype.lighten = function(e) {\n return e === void 0 && (e = 0.1), Y(Bt(this.rgba, e));\n }, t.prototype.darken = function(e) {\n return e === void 0 && (e = 0.1), Y(Bt(this.rgba, -e));\n }, t.prototype.rotate = function(e) {\n return e === void 0 && (e = 15), this.hue(this.hue() + e);\n }, t.prototype.alpha = function(e) {\n return typeof e == \"number\" ? Y({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : I(this.rgba.a, 3);\n var n;\n }, t.prototype.hue = function(e) {\n var n = Q(this.rgba);\n return typeof e == \"number\" ? Y({ h: e, s: n.s, l: n.l, a: n.a }) : I(n.h);\n }, t.prototype.isEqual = function(e) {\n return this.toHex() === Y(e).toHex();\n }, t;\n}(), Y = function(t) {\n return t instanceof Nt ? t : new Nt(t);\n};\nconst Le = (t) => [\n `background-color:${Y((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,\n t != null && t.underlineThickness ? \"text-decoration:underline\" : void 0,\n t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,\n t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,\n t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0\n].filter(Boolean).join(\";\"), Te = () => {\n const t = document.createElement(\"style\");\n document.getElementsByTagName(\"head\")[0].appendChild(t);\n let e = /* @__PURE__ */ new Set();\n return {\n destroy: () => {\n CSS.highlights.clear(), t.remove();\n },\n setVisible: (r) => {\n console.log(\"setVisible not implemented on CSS Custom Highlights renderer\");\n },\n redraw: (r, s, a, u) => {\n u && u.clear();\n const h = new Set(r.map((d) => d.annotation.id));\n Array.from(e).filter((d) => !h.has(d));\n const g = r.map((d) => {\n var A;\n const b = a ? typeof a == \"function\" ? a(d.annotation, d.state) : a : (A = d.state) != null && A.selected ? it : P, f = u && u.paint(d, s) || b;\n return `::highlight(_${d.annotation.id}) { ${Le(f)} }`;\n });\n t.innerHTML = g.join(`\n`), CSS.highlights.clear(), r.forEach(({ annotation: d }) => {\n const b = d.target.selector.map((A) => A.range), f = new Highlight(...b);\n CSS.highlights.set(`_${d.id}`, f);\n }), e = h;\n }\n };\n}, Re = (t, e, n) => yt(t, e, n, Te());\nvar Mt = Object.prototype.hasOwnProperty;\nfunction bt(t, e) {\n var n, o;\n if (t === e) return !0;\n if (t && e && (n = t.constructor) === e.constructor) {\n if (n === Date) return t.getTime() === e.getTime();\n if (n === RegExp) return t.toString() === e.toString();\n if (n === Array) {\n if ((o = t.length) === e.length)\n for (; o-- && bt(t[o], e[o]); ) ;\n return o === -1;\n }\n if (!n || typeof t == \"object\") {\n o = 0;\n for (n in t)\n if (Mt.call(t, n) && ++o && !Mt.call(e, n) || !(n in e) || !bt(t[n], e[n])) return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nconst Be = (t, e) => {\n const n = (r, s) => r.x <= s.x + s.width && r.x + r.width >= s.x && r.y <= s.y + s.height && r.y + r.height >= s.y, o = (r) => r.rects.reduce((s, a) => s + a.width, 0), i = e.filter(({ rects: r }) => r.some((s) => n(t, s)));\n return i.sort((r, s) => o(s) - o(r)), i.findIndex((r) => r.rects.includes(t));\n}, Ne = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = document.createElement(\"div\");\n e.className = \"r6o-span-highlight-layer\", t.insertBefore(e, t.firstChild);\n let n = [];\n return {\n destroy: () => {\n e.remove();\n },\n redraw: (s, a, u, h, g) => {\n const b = !(bt(n, s) && g);\n !h && !b || (b && (e.innerHTML = \"\"), s.forEach((f) => {\n f.rects.map((A) => {\n const v = Be(A, s), p = Jt(f, a, u, h, v);\n if (b) {\n const l = document.createElement(\"span\");\n l.className = \"r6o-annotation\", l.dataset.annotation = f.annotation.id, l.style.left = `${A.x}px`, l.style.top = `${A.y}px`, l.style.width = `${A.width}px`, l.style.height = `${A.height}px`, l.style.backgroundColor = Y((p == null ? void 0 : p.fill) || P.fill).alpha((p == null ? void 0 : p.fillOpacity) === void 0 ? P.fillOpacity : p.fillOpacity).toHex(), p.underlineStyle && (l.style.borderStyle = p.underlineStyle), p.underlineColor && (l.style.borderColor = p.underlineColor), p.underlineThickness && (l.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (l.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(l);\n }\n });\n }), n = s);\n },\n setVisible: (s) => {\n s ? e.classList.remove(\"hidden\") : e.classList.add(\"hidden\");\n }\n };\n}, Me = (t, e, n) => yt(t, e, n, Ne(t));\nvar U = [];\nfor (var dt = 0; dt < 256; ++dt)\n U.push((dt + 256).toString(16).slice(1));\nfunction Oe(t, e = 0) {\n return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + \"-\" + U[t[e + 4]] + U[t[e + 5]] + \"-\" + U[t[e + 6]] + U[t[e + 7]] + \"-\" + U[t[e + 8]] + U[t[e + 9]] + \"-\" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();\n}\nvar Z, Ie = new Uint8Array(16);\nfunction Ue() {\n if (!Z && (Z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return Z(Ie);\n}\nvar Ve = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Ot = {\n randomUUID: Ve\n};\nfunction Pt(t, e, n) {\n if (Ot.randomUUID && !e && !t)\n return Ot.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || Ue)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Oe(o);\n}\nvar It = Object.prototype.hasOwnProperty;\nfunction z(t, e) {\n var n, o;\n if (t === e) return !0;\n if (t && e && (n = t.constructor) === e.constructor) {\n if (n === Date) return t.getTime() === e.getTime();\n if (n === RegExp) return t.toString() === e.toString();\n if (n === Array) {\n if ((o = t.length) === e.length)\n for (; o-- && z(t[o], e[o]); ) ;\n return o === -1;\n }\n if (!n || typeof t == \"object\") {\n o = 0;\n for (n in t)\n if (It.call(t, n) && ++o && !It.call(e, n) || !(n in e) || !z(t[n], e[n])) return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nfunction ut() {\n}\nfunction ke(t, e) {\n return t != t ? e == e : t !== e || t && typeof t == \"object\" || typeof t == \"function\";\n}\nconst F = [];\nfunction wt(t, e = ut) {\n let n;\n const o = /* @__PURE__ */ new Set();\n function i(a) {\n if (ke(t, a) && (t = a, n)) {\n const u = !F.length;\n for (const h of o)\n h[1](), F.push(h, t);\n if (u) {\n for (let h = 0; h < F.length; h += 2)\n F[h][0](F[h + 1]);\n F.length = 0;\n }\n }\n }\n function r(a) {\n i(a(t));\n }\n function s(a, u = ut) {\n const h = [a, u];\n return o.add(h), o.size === 1 && (n = e(i, r) || ut), a(t), () => {\n o.delete(h), o.size === 0 && n && (n(), n = null);\n };\n }\n return { set: i, update: r, subscribe: s };\n}\nconst _e = (t) => {\n const { subscribe: e, set: n } = wt();\n let o;\n return e((i) => o = i), t.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((s) => s.id === o) && n(void 0);\n const r = (i.updated || []).find(({ oldValue: s }) => s.id === o);\n r && n(r.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: e,\n set: n\n };\n};\nvar De = /* @__PURE__ */ ((t) => (t.EDIT = \"EDIT\", t.SELECT = \"SELECT\", t.NONE = \"NONE\", t))(De || {});\nconst tt = { selected: [] }, Ye = (t, e) => {\n const { subscribe: n, set: o } = wt(tt);\n let i = e, r = tt;\n n((f) => r = f);\n const s = () => {\n z(r, tt) || o(tt);\n }, a = () => {\n var f;\n return ((f = r.selected) == null ? void 0 : f.length) === 0;\n }, u = (f) => {\n if (a())\n return !1;\n const A = typeof f == \"string\" ? f : f.id;\n return r.selected.some((v) => v.id === A);\n }, h = (f, A) => {\n const v = t.getAnnotation(f);\n if (!v) {\n console.warn(\"Invalid selection: \" + f);\n return;\n }\n switch (Ut(v, i)) {\n case \"EDIT\":\n o({ selected: [{ id: f, editable: !0 }], event: A });\n break;\n case \"SELECT\":\n o({ selected: [{ id: f }], event: A });\n break;\n default:\n o({ selected: [], event: A });\n }\n }, g = (f, A) => {\n const v = Array.isArray(f) ? f : [f], p = v.map((l) => t.getAnnotation(l)).filter((l) => !!l);\n o({\n selected: p.map((l) => {\n const c = A === void 0 ? Ut(l, i) === \"EDIT\" : A;\n return { id: l.id, editable: c };\n })\n }), p.length !== v.length && console.warn(\"Invalid selection\", f);\n }, d = (f) => {\n if (a())\n return !1;\n const { selected: A } = r;\n A.some(({ id: v }) => f.includes(v)) && o({ selected: A.filter(({ id: v }) => !f.includes(v)) });\n }, b = (f) => i = f;\n return t.observe(\n ({ changes: f }) => d((f.deleted || []).map((A) => A.id))\n ), {\n get event() {\n return r ? r.event : null;\n },\n get selected() {\n return r ? [...r.selected] : null;\n },\n get userSelectAction() {\n return i;\n },\n clear: s,\n isEmpty: a,\n isSelected: u,\n setSelected: g,\n setUserSelectAction: b,\n subscribe: n,\n userSelect: h\n };\n}, Ut = (t, e) => typeof e == \"function\" ? e(t) : e || \"EDIT\";\nvar V = [];\nfor (var ht = 0; ht < 256; ++ht)\n V.push((ht + 256).toString(16).slice(1));\nfunction Xe(t, e = 0) {\n return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + \"-\" + V[t[e + 4]] + V[t[e + 5]] + \"-\" + V[t[e + 6]] + V[t[e + 7]] + \"-\" + V[t[e + 8]] + V[t[e + 9]] + \"-\" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();\n}\nvar et, $e = new Uint8Array(16);\nfunction He() {\n if (!et && (et = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !et))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return et($e);\n}\nvar Pe = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Vt = {\n randomUUID: Pe\n};\nfunction zt(t, e, n) {\n if (Vt.randomUUID && !e && !t)\n return Vt.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || He)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Xe(o);\n}\nconst Vn = (t, e, n, o) => ({\n id: zt(),\n annotation: typeof t == \"string\" ? t : t.id,\n created: n || /* @__PURE__ */ new Date(),\n creator: o,\n ...e\n}), ze = (t, e) => {\n const n = new Set(t.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !n.has(o.id));\n}, Fe = (t, e) => {\n const n = new Set(e.bodies.map((o) => o.id));\n return t.bodies.filter((o) => !n.has(o.id));\n}, je = (t, e) => e.bodies.map((n) => {\n const o = t.bodies.find((i) => i.id === n.id);\n return { newBody: n, oldBody: o && !z(o, n) ? o : void 0 };\n}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), We = (t, e) => !z(t.target, e.target), Ft = (t, e) => {\n const n = ze(t, e), o = Fe(t, e), i = je(t, e);\n return {\n oldValue: t,\n newValue: e,\n bodiesCreated: n.length > 0 ? n : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: We(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0\n };\n};\nvar N = /* @__PURE__ */ ((t) => (t.LOCAL = \"LOCAL\", t.REMOTE = \"REMOTE\", t))(N || {});\nconst qe = (t, e) => {\n var n, o;\n const { changes: i, origin: r } = e;\n if (!(!t.options.origin || t.options.origin === r))\n return !1;\n if (t.options.ignore) {\n const { ignore: s } = t.options, a = (u) => u && u.length > 0;\n if (!(a(i.created) || a(i.deleted))) {\n const u = (n = i.updated) == null ? void 0 : n.some((g) => a(g.bodiesCreated) || a(g.bodiesDeleted) || a(g.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((g) => g.targetUpdated);\n if (s === \"BODY_ONLY\" && u && !h || s === \"TARGET_ONLY\" && h && !u)\n return !1;\n }\n }\n if (t.options.annotations) {\n const s = /* @__PURE__ */ new Set([\n ...(i.created || []).map((a) => a.id),\n ...(i.deleted || []).map((a) => a.id),\n ...(i.updated || []).map(({ oldValue: a }) => a.id)\n ]);\n return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => s.has(a));\n } else\n return !0;\n}, Ge = (t, e) => {\n const n = new Set((t.created || []).map((d) => d.id)), o = new Set((t.updated || []).map(({ newValue: d }) => d.id)), i = new Set((e.created || []).map((d) => d.id)), r = new Set((e.deleted || []).map((d) => d.id)), s = new Set((e.updated || []).map(({ oldValue: d }) => d.id)), a = new Set((e.updated || []).filter(({ oldValue: d }) => n.has(d.id) || o.has(d.id)).map(({ oldValue: d }) => d.id)), u = [\n ...(t.created || []).filter((d) => !r.has(d.id)).map((d) => s.has(d.id) ? e.updated.find(({ oldValue: b }) => b.id === d.id).newValue : d),\n ...e.created || []\n ], h = [\n ...(t.deleted || []).filter((d) => !i.has(d.id)),\n ...(e.deleted || []).filter((d) => !n.has(d.id))\n ], g = [\n ...(t.updated || []).filter(({ newValue: d }) => !r.has(d.id)).map((d) => {\n const { oldValue: b, newValue: f } = d;\n if (s.has(f.id)) {\n const A = e.updated.find((v) => v.oldValue.id === f.id).newValue;\n return Ft(b, A);\n } else\n return d;\n }),\n ...(e.updated || []).filter(({ oldValue: d }) => !a.has(d.id))\n ];\n return { created: u, deleted: h, updated: g };\n}, ft = (t) => {\n const e = t.id === void 0 ? zt() : t.id;\n return {\n ...t,\n id: e,\n bodies: t.bodies === void 0 ? [] : t.bodies.map((n) => ({\n ...n,\n annotation: e\n })),\n target: {\n ...t.target,\n annotation: e\n }\n };\n}, Ke = (t) => t.id !== void 0, Qe = () => {\n const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (y, x = {}) => n.push({ onChange: y, options: x }), i = (y) => {\n const x = n.findIndex((w) => w.onChange == y);\n x > -1 && n.splice(x, 1);\n }, r = (y, x) => {\n const w = {\n origin: y,\n changes: {\n created: x.created || [],\n updated: x.updated || [],\n deleted: x.deleted || []\n },\n state: [...t.values()]\n };\n n.forEach((E) => {\n qe(E, w) && E.onChange(w);\n });\n }, s = (y, x = N.LOCAL) => {\n if (y.id && t.get(y.id))\n throw Error(`Cannot add annotation ${y.id} - exists already`);\n {\n const w = ft(y);\n t.set(w.id, w), w.bodies.forEach((E) => e.set(E.id, w.id)), r(x, { created: [w] });\n }\n }, a = (y, x) => {\n const w = ft(typeof y == \"string\" ? x : y), E = typeof y == \"string\" ? y : y.id, M = E && t.get(E);\n if (M) {\n const B = Ft(M, w);\n return E === w.id ? t.set(E, w) : (t.delete(E), t.set(w.id, w)), M.bodies.forEach((k) => e.delete(k.id)), w.bodies.forEach((k) => e.set(k.id, w.id)), B;\n } else\n console.warn(`Cannot update annotation ${E} - does not exist`);\n }, u = (y, x = N.LOCAL, w = N.LOCAL) => {\n const E = Ke(x) ? w : x, M = a(y, x);\n M && r(E, { updated: [M] });\n }, h = (y, x = N.LOCAL) => {\n const w = y.reduce((E, M) => {\n const B = a(M);\n return B ? [...E, B] : E;\n }, []);\n w.length > 0 && r(x, { updated: w });\n }, g = (y, x = N.LOCAL) => {\n const w = t.get(y.annotation);\n if (w) {\n const E = {\n ...w,\n bodies: [...w.bodies, y]\n };\n t.set(w.id, E), e.set(y.id, E.id), r(x, { updated: [{\n oldValue: w,\n newValue: E,\n bodiesCreated: [y]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${y.annotation}`);\n }, d = () => [...t.values()], b = (y = N.LOCAL) => {\n const x = [...t.values()];\n t.clear(), e.clear(), r(y, { deleted: x });\n }, f = (y, x = !0, w = N.LOCAL) => {\n const E = y.map(ft);\n if (x) {\n const M = [...t.values()];\n t.clear(), e.clear(), E.forEach((B) => {\n t.set(B.id, B), B.bodies.forEach((k) => e.set(k.id, B.id));\n }), r(w, { created: E, deleted: M });\n } else {\n const M = y.reduce((B, k) => {\n const _ = k.id && t.get(k.id);\n return _ ? [...B, _] : B;\n }, []);\n if (M.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${M.map((B) => B.id).join(\", \")}`);\n E.forEach((B) => {\n t.set(B.id, B), B.bodies.forEach((k) => e.set(k.id, B.id));\n }), r(w, { created: E });\n }\n }, A = (y) => {\n const x = typeof y == \"string\" ? y : y.id, w = t.get(x);\n if (w)\n return t.delete(x), w.bodies.forEach((E) => e.delete(E.id)), w;\n console.warn(`Attempt to delete missing annotation: ${x}`);\n }, v = (y, x = N.LOCAL) => {\n const w = A(y);\n w && r(x, { deleted: [w] });\n }, p = (y, x = N.LOCAL) => {\n const w = y.reduce((E, M) => {\n const B = A(M);\n return B ? [...E, B] : E;\n }, []);\n w.length > 0 && r(x, { deleted: w });\n }, l = (y) => {\n const x = t.get(y.annotation);\n if (x) {\n const w = x.bodies.find((E) => E.id === y.id);\n if (w) {\n e.delete(w.id);\n const E = {\n ...x,\n bodies: x.bodies.filter((M) => M.id !== y.id)\n };\n return t.set(x.id, E), {\n oldValue: x,\n newValue: E,\n bodiesDeleted: [w]\n };\n } else\n console.warn(`Attempt to delete missing body ${y.id} from annotation ${y.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${y.annotation}`);\n }, c = (y, x = N.LOCAL) => {\n const w = l(y);\n w && r(x, { updated: [w] });\n }, m = (y, x = N.LOCAL) => {\n const w = y.map((E) => l(E)).filter(Boolean);\n w.length > 0 && r(x, { updated: w });\n }, C = (y) => {\n const x = t.get(y);\n return x ? { ...x } : void 0;\n }, L = (y) => {\n const x = e.get(y);\n if (x) {\n const w = C(x).bodies.find((E) => E.id === y);\n if (w)\n return w;\n console.error(`Store integrity error: body ${y} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${y}`);\n }, S = (y, x) => {\n if (y.annotation !== x.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const w = t.get(y.annotation);\n if (w) {\n const E = w.bodies.find((B) => B.id === y.id), M = {\n ...w,\n bodies: w.bodies.map((B) => B.id === E.id ? x : B)\n };\n return t.set(w.id, M), E.id !== x.id && (e.delete(E.id), e.set(x.id, M.id)), {\n oldValue: w,\n newValue: M,\n bodiesUpdated: [{ oldBody: E, newBody: x }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${y.annotation}`);\n }, T = (y, x, w = N.LOCAL) => {\n const E = S(y, x);\n E && r(w, { updated: [E] });\n }, R = (y, x = N.LOCAL) => {\n const w = y.map((E) => S({ id: E.id, annotation: E.annotation }, E)).filter(Boolean);\n r(x, { updated: w });\n }, O = (y) => {\n const x = t.get(y.annotation);\n if (x) {\n const w = {\n ...x,\n target: {\n ...x.target,\n ...y\n }\n };\n return t.set(x.id, w), {\n oldValue: x,\n newValue: w,\n targetUpdated: {\n oldTarget: x.target,\n newTarget: y\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${y.annotation}`);\n };\n return {\n addAnnotation: s,\n addBody: g,\n all: d,\n bulkAddAnnotation: f,\n bulkDeleteAnnotation: p,\n bulkDeleteBodies: m,\n bulkUpdateAnnotation: h,\n bulkUpdateBodies: R,\n bulkUpdateTargets: (y, x = N.LOCAL) => {\n const w = y.map((E) => O(E)).filter(Boolean);\n w.length > 0 && r(x, { updated: w });\n },\n clear: b,\n deleteAnnotation: v,\n deleteBody: c,\n getAnnotation: C,\n getBody: L,\n observe: o,\n unobserve: i,\n updateAnnotation: u,\n updateBody: T,\n updateTarget: (y, x = N.LOCAL) => {\n const w = O(y);\n w && r(x, { updated: [w] });\n }\n };\n};\nlet Je = () => ({\n emit(t, ...e) {\n for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)\n o[n](...e);\n },\n events: {},\n on(t, e) {\n var n;\n return ((n = this.events)[t] || (n[t] = [])).push(e), () => {\n var o;\n this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((i) => e !== i);\n };\n }\n});\nconst Ze = 250, tn = (t) => {\n const e = Je(), n = [];\n let o = -1, i = !1, r = 0;\n const s = (f) => {\n if (!i) {\n const { changes: A } = f, v = performance.now();\n if (v - r > Ze)\n n.splice(o + 1), n.push(A), o = n.length - 1;\n else {\n const p = n.length - 1;\n n[p] = Ge(n[p], A);\n }\n r = v;\n }\n i = !1;\n };\n t.observe(s, { origin: N.LOCAL });\n const a = (f) => f && f.length > 0 && t.bulkDeleteAnnotation(f), u = (f) => f && f.length > 0 && t.bulkAddAnnotation(f, !1), h = (f) => f && f.length > 0 && t.bulkUpdateAnnotation(f.map(({ oldValue: A }) => A)), g = (f) => f && f.length > 0 && t.bulkUpdateAnnotation(f.map(({ newValue: A }) => A)), d = (f) => f && f.length > 0 && t.bulkAddAnnotation(f, !1), b = (f) => f && f.length > 0 && t.bulkDeleteAnnotation(f);\n return {\n canRedo: () => n.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => t.unobserve(s),\n on: (f, A) => e.on(f, A),\n redo: () => {\n if (n.length - 1 > o) {\n i = !0;\n const { created: f, updated: A, deleted: v } = n[o + 1];\n u(f), g(A), b(v), e.emit(\"redo\", n[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: f, updated: A, deleted: v } = n[o];\n a(f), h(A), d(v), e.emit(\"undo\", n[o]), o -= 1;\n }\n }\n };\n}, en = () => {\n const { subscribe: t, set: e } = wt([]);\n return {\n subscribe: t,\n set: e\n };\n}, nn = (t, e, n, o) => {\n const { store: i, selection: r, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();\n let h = [], g;\n const d = (v, p) => {\n u.has(v) ? u.get(v).push(p) : u.set(v, [p]);\n }, b = (v, p) => {\n const l = u.get(v);\n if (l) {\n const c = l.indexOf(p);\n c !== -1 && l.splice(c, 1);\n }\n }, f = (v, p, l) => {\n u.has(v) && setTimeout(() => {\n u.get(v).forEach((c) => {\n if (n) {\n const m = Array.isArray(p) ? p.map((L) => n.serialize(L)) : n.serialize(p), C = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;\n c(m, C);\n } else\n c(p, l);\n });\n }, 1);\n };\n r.subscribe(({ selected: v }) => {\n if (!(h.length === 0 && v.length === 0)) {\n if (h.length === 0 && v.length > 0)\n h = v.map(({ id: p }) => i.getAnnotation(p));\n else if (h.length > 0 && v.length === 0)\n h.forEach((p) => {\n const l = i.getAnnotation(p.id);\n l && !z(l, p) && f(\"updateAnnotation\", l, p);\n }), h = [];\n else {\n const p = new Set(h.map((c) => c.id)), l = new Set(v.map(({ id: c }) => c));\n h.filter((c) => !l.has(c.id)).forEach((c) => {\n const m = i.getAnnotation(c.id);\n m && !z(m, c) && f(\"updateAnnotation\", m, c);\n }), h = [\n // Remove annotations that were deselected\n ...h.filter((c) => l.has(c.id)),\n // Add editable annotations that were selected\n ...v.filter(({ id: c }) => !p.has(c)).map(({ id: c }) => i.getAnnotation(c))\n ];\n }\n f(\"selectionChanged\", h);\n }\n }), s.subscribe((v) => {\n !g && v ? f(\"mouseEnterAnnotation\", i.getAnnotation(v)) : g && !v ? f(\"mouseLeaveAnnotation\", i.getAnnotation(g)) : g && v && (f(\"mouseLeaveAnnotation\", i.getAnnotation(g)), f(\"mouseEnterAnnotation\", i.getAnnotation(v))), g = v;\n }), a == null || a.subscribe((v) => f(\"viewportIntersect\", v.map((p) => i.getAnnotation(p)))), i.observe((v) => {\n const { created: p, deleted: l } = v.changes;\n (p || []).forEach((c) => f(\"createAnnotation\", c)), (l || []).forEach((c) => f(\"deleteAnnotation\", c)), (v.changes.updated || []).filter((c) => [\n ...c.bodiesCreated || [],\n ...c.bodiesDeleted || [],\n ...c.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: c, newValue: m }) => {\n const C = h.find((L) => L.id === c.id) || c;\n h = h.map((L) => L.id === c.id ? m : L), f(\"updateAnnotation\", m, C);\n });\n }, { origin: N.LOCAL }), i.observe((v) => {\n if (h) {\n const p = new Set(h.map((c) => c.id)), l = (v.changes.updated || []).filter(({ newValue: c }) => p.has(c.id)).map(({ newValue: c }) => c);\n l.length > 0 && (h = h.map((c) => l.find((C) => C.id === c.id) || c));\n }\n }, { origin: N.REMOTE });\n const A = (v) => (p) => {\n const { updated: l } = p;\n v ? (l || []).forEach((c) => f(\"updateAnnotation\", c.oldValue, c.newValue)) : (l || []).forEach((c) => f(\"updateAnnotation\", c.newValue, c.oldValue));\n };\n return e.on(\"undo\", A(!0)), e.on(\"redo\", A(!1)), { on: d, off: b, emit: f };\n}, on = (t) => (e) => e.reduce((n, o) => {\n const { parsed: i, error: r } = t.parse(o);\n return r ? {\n parsed: n.parsed,\n failed: [...n.failed, o]\n } : i ? {\n parsed: [...n.parsed, i],\n failed: n.failed\n } : {\n ...n\n };\n}, { parsed: [], failed: [] }), rn = (t, e, n) => {\n const { store: o, selection: i } = t, r = (l) => {\n if (n) {\n const { parsed: c, error: m } = n.parse(l);\n c ? o.addAnnotation(c, N.REMOTE) : console.error(m);\n } else\n o.addAnnotation(l, N.REMOTE);\n }, s = () => i.clear(), a = () => o.clear(), u = (l) => {\n const c = o.getAnnotation(l);\n return n && c ? n.serialize(c) : c;\n }, h = () => n ? o.all().map(n.serialize) : o.all(), g = () => {\n var l;\n const c = (((l = i.selected) == null ? void 0 : l.map((m) => m.id)) || []).map((m) => o.getAnnotation(m)).filter(Boolean);\n return n ? c.map(n.serialize) : c;\n }, d = (l, c = !0) => fetch(l).then((m) => m.json()).then((m) => (f(m, c), m)), b = (l) => {\n if (typeof l == \"string\") {\n const c = o.getAnnotation(l);\n if (o.deleteAnnotation(l), c)\n return n ? n.serialize(c) : c;\n } else {\n const c = n ? n.parse(l).parsed : l;\n if (c)\n return o.deleteAnnotation(c), l;\n }\n }, f = (l, c = !0) => {\n if (n) {\n const { parsed: m, failed: C } = on(n)(l);\n C.length > 0 && console.warn(`Discarded ${C.length} invalid annotations`, C), o.bulkAddAnnotation(m, c, N.REMOTE);\n } else\n o.bulkAddAnnotation(l, c, N.REMOTE);\n }, A = (l, c) => {\n l ? i.setSelected(l, c) : i.clear();\n }, v = (l) => {\n i.clear(), i.setUserSelectAction(l);\n }, p = (l) => {\n if (n) {\n const c = n.parse(l).parsed, m = n.serialize(o.getAnnotation(c.id));\n return o.updateAnnotation(c), m;\n } else {\n const c = o.getAnnotation(l.id);\n return o.updateAnnotation(l), c;\n }\n };\n return {\n addAnnotation: r,\n cancelSelected: s,\n canRedo: e.canRedo,\n canUndo: e.canUndo,\n clearAnnotations: a,\n getAnnotationById: u,\n getAnnotations: h,\n getSelected: g,\n loadAnnotations: d,\n redo: e.redo,\n removeAnnotation: b,\n setAnnotations: f,\n setSelected: A,\n setUserSelectAction: v,\n undo: e.undo,\n updateAnnotation: p\n };\n}, sn = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nlet an = (t) => crypto.getRandomValues(new Uint8Array(t)), cn = (t, e, n) => {\n let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);\n return (r = e) => {\n let s = \"\";\n for (; ; ) {\n let a = n(i), u = i;\n for (; u--; )\n if (s += t[a[u] & o] || \"\", s.length === r) return s;\n }\n };\n}, ln = (t, e = 21) => cn(t, e, an), dn = (t = 21) => {\n let e = \"\", n = crypto.getRandomValues(new Uint8Array(t));\n for (; t--; )\n e += sn[n[t] & 63];\n return e;\n};\nconst un = () => ({ isGuest: !0, id: ln(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), hn = (t) => {\n const e = JSON.stringify(t);\n let n = 0;\n for (let o = 0, i = e.length; o < i; o++) {\n let r = e.charCodeAt(o);\n n = (n << 5) - n + r, n |= 0;\n }\n return `${n}`;\n}, jt = (t) => t ? typeof t == \"object\" ? { ...t } : t : void 0, fn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {\n const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: h, ...g } = n;\n return {\n id: o || `temp-${hn(n)}`,\n annotation: e,\n type: i,\n purpose: r,\n value: s,\n creator: jt(h),\n created: a ? new Date(a) : void 0,\n updated: u ? new Date(u) : void 0,\n ...g\n };\n}), gn = (t) => t.map((e) => {\n var n;\n const { annotation: o, created: i, updated: r, ...s } = e, a = {\n ...s,\n created: i == null ? void 0 : i.toISOString(),\n modified: r == null ? void 0 : r.toISOString()\n };\n return (n = a.id) != null && n.startsWith(\"temp-\") && delete a.id, a;\n});\ndn();\nconst kn = (t, e) => ({\n parse: (n) => bn(n),\n serialize: (n) => vn(n, t, e)\n}), pn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, mn = (t) => {\n const {\n id: e,\n creator: n,\n created: o,\n modified: i,\n target: r\n } = t, s = Array.isArray(r) ? r : [r], a = {\n creator: jt(n),\n created: o ? new Date(o) : void 0,\n updated: i ? new Date(i) : void 0,\n annotation: e,\n selector: []\n };\n for (const u of s) {\n const g = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((d, b) => {\n switch (b.type) {\n case \"TextQuoteSelector\":\n d.quote = b.exact;\n break;\n case \"TextPositionSelector\":\n d.start = b.start, d.end = b.end;\n break;\n }\n return d;\n }, {});\n if (pn(g))\n a.selector.push({ id: u.id, ...g });\n else {\n const d = [\n g.start ? void 0 : \"TextPositionSelector\",\n g.quote ? void 0 : \"TextQuoteSelector\"\n ].filter(Boolean);\n return { error: Error(`Missing selector types: ${d.join(\" and \")} for annotation: ${t.id}`) };\n }\n }\n return { parsed: a };\n}, bn = (t) => {\n const e = t.id || Pt(), {\n creator: n,\n created: o,\n modified: i,\n body: r,\n ...s\n } = t, a = fn(r, e), u = mn(t);\n return \"error\" in u ? { error: u.error } : {\n parsed: {\n ...s,\n id: e,\n bodies: a,\n target: u.parsed\n }\n };\n}, vn = (t, e, n) => {\n const { bodies: o, target: i, ...r } = t, {\n selector: s,\n creator: a,\n created: u,\n updated: h,\n ...g\n } = i, d = s.map((b) => {\n const { quote: f, start: A, end: v, range: p } = b, { prefix: l, suffix: c } = re(p, n), m = [{\n type: \"TextQuoteSelector\",\n exact: f,\n prefix: l,\n suffix: c\n }, {\n type: \"TextPositionSelector\",\n start: A,\n end: v\n }];\n return {\n ...g,\n id: b.id,\n source: e,\n selector: m\n };\n });\n return {\n ...r,\n \"@context\": \"http://www.w3.org/ns/anno.jsonld\",\n id: t.id,\n type: \"Annotation\",\n body: gn(t.bodies),\n creator: a,\n created: u == null ? void 0 : u.toISOString(),\n modified: h == null ? void 0 : h.toISOString(),\n target: d\n };\n};\nfunction Wt(t, e, n = 0, o = t.length - 1, i = yn) {\n for (; o > n; ) {\n if (o - n > 600) {\n const u = o - n + 1, h = e - n + 1, g = Math.log(u), d = 0.5 * Math.exp(2 * g / 3), b = 0.5 * Math.sqrt(g * d * (u - d) / u) * (h - u / 2 < 0 ? -1 : 1), f = Math.max(n, Math.floor(e - h * d / u + b)), A = Math.min(o, Math.floor(e + (u - h) * d / u + b));\n Wt(t, e, f, A, i);\n }\n const r = t[e];\n let s = n, a = o;\n for (q(t, n, e), i(t[o], r) > 0 && q(t, n, o); s < a; ) {\n for (q(t, s, a), s++, a--; i(t[s], r) < 0; ) s++;\n for (; i(t[a], r) > 0; ) a--;\n }\n i(t[n], r) === 0 ? q(t, n, a) : (a++, q(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);\n }\n}\nfunction q(t, e, n) {\n const o = t[e];\n t[e] = t[n], t[n] = o;\n}\nfunction yn(t, e) {\n return t < e ? -1 : t > e ? 1 : 0;\n}\nclass wn {\n constructor(e = 9) {\n this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();\n }\n all() {\n return this._all(this.data, []);\n }\n search(e) {\n let n = this.data;\n const o = [];\n if (!ot(e, n)) return o;\n const i = this.toBBox, r = [];\n for (; n; ) {\n for (let s = 0; s < n.children.length; s++) {\n const a = n.children[s], u = n.leaf ? i(a) : a;\n ot(e, u) && (n.leaf ? o.push(a) : pt(e, u) ? this._all(a, o) : r.push(a));\n }\n n = r.pop();\n }\n return o;\n }\n collides(e) {\n let n = this.data;\n if (!ot(e, n)) return !1;\n const o = [];\n for (; n; ) {\n for (let i = 0; i < n.children.length; i++) {\n const r = n.children[i], s = n.leaf ? this.toBBox(r) : r;\n if (ot(e, s)) {\n if (n.leaf || pt(e, s)) return !0;\n o.push(r);\n }\n }\n n = o.pop();\n }\n return !1;\n }\n load(e) {\n if (!(e && e.length)) return this;\n if (e.length < this._minEntries) {\n for (let o = 0; o < e.length; o++)\n this.insert(e[o]);\n return this;\n }\n let n = this._build(e.slice(), 0, e.length - 1, 0);\n if (!this.data.children.length)\n this.data = n;\n else if (this.data.height === n.height)\n this._splitRoot(this.data, n);\n else {\n if (this.data.height < n.height) {\n const o = this.data;\n this.data = n, n = o;\n }\n this._insert(n, this.data.height - n.height - 1, !0);\n }\n return this;\n }\n insert(e) {\n return e && this._insert(e, this.data.height - 1), this;\n }\n clear() {\n return this.data = W([]), this;\n }\n remove(e, n) {\n if (!e) return this;\n let o = this.data;\n const i = this.toBBox(e), r = [], s = [];\n let a, u, h;\n for (; o || r.length; ) {\n if (o || (o = r.pop(), u = r[r.length - 1], a = s.pop(), h = !0), o.leaf) {\n const g = xn(e, o.children, n);\n if (g !== -1)\n return o.children.splice(g, 1), r.push(o), this._condense(r), this;\n }\n !h && !o.leaf && pt(o, i) ? (r.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], h = !1) : o = null;\n }\n return this;\n }\n toBBox(e) {\n return e;\n }\n compareMinX(e, n) {\n return e.minX - n.minX;\n }\n compareMinY(e, n) {\n return e.minY - n.minY;\n }\n toJSON() {\n return this.data;\n }\n fromJSON(e) {\n return this.data = e, this;\n }\n _all(e, n) {\n const o = [];\n for (; e; )\n e.leaf ? n.push(...e.children) : o.push(...e.children), e = o.pop();\n return n;\n }\n _build(e, n, o, i) {\n const r = o - n + 1;\n let s = this._maxEntries, a;\n if (r <= s)\n return a = W(e.slice(n, o + 1)), j(a, this.toBBox), a;\n i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = W([]), a.leaf = !1, a.height = i;\n const u = Math.ceil(r / s), h = u * Math.ceil(Math.sqrt(s));\n kt(e, n, o, h, this.compareMinX);\n for (let g = n; g <= o; g += h) {\n const d = Math.min(g + h - 1, o);\n kt(e, g, d, u, this.compareMinY);\n for (let b = g; b <= d; b += u) {\n const f = Math.min(b + u - 1, d);\n a.children.push(this._build(e, b, f, i - 1));\n }\n }\n return j(a, this.toBBox), a;\n }\n _chooseSubtree(e, n, o, i) {\n for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {\n let r = 1 / 0, s = 1 / 0, a;\n for (let u = 0; u < n.children.length; u++) {\n const h = n.children[u], g = gt(h), d = En(e, h) - g;\n d < s ? (s = d, r = g < r ? g : r, a = h) : d === s && g < r && (r = g, a = h);\n }\n n = a || n.children[0];\n }\n return n;\n }\n _insert(e, n, o) {\n const i = o ? e : this.toBBox(e), r = [], s = this._chooseSubtree(i, this.data, n, r);\n for (s.children.push(e), K(s, i); n >= 0 && r[n].children.length > this._maxEntries; )\n this._split(r, n), n--;\n this._adjustParentBBoxes(i, r, n);\n }\n // split overflowed node into two\n _split(e, n) {\n const o = e[n], i = o.children.length, r = this._minEntries;\n this._chooseSplitAxis(o, r, i);\n const s = this._chooseSplitIndex(o, r, i), a = W(o.children.splice(s, o.children.length - s));\n a.height = o.height, a.leaf = o.leaf, j(o, this.toBBox), j(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);\n }\n _splitRoot(e, n) {\n this.data = W([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, j(this.data, this.toBBox);\n }\n _chooseSplitIndex(e, n, o) {\n let i, r = 1 / 0, s = 1 / 0;\n for (let a = n; a <= o - n; a++) {\n const u = G(e, 0, a, this.toBBox), h = G(e, a, o, this.toBBox), g = Cn(u, h), d = gt(u) + gt(h);\n g < r ? (r = g, i = a, s = d < s ? d : s) : g === r && d < s && (s = d, i = a);\n }\n return i || o - n;\n }\n // sorts node children by the best axis for split\n _chooseSplitAxis(e, n, o) {\n const i = e.leaf ? this.compareMinX : An, r = e.leaf ? this.compareMinY : Sn, s = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);\n s < a && e.children.sort(i);\n }\n // total margin of all possible split distributions where each node is at least m full\n _allDistMargin(e, n, o, i) {\n e.children.sort(i);\n const r = this.toBBox, s = G(e, 0, n, r), a = G(e, o - n, o, r);\n let u = nt(s) + nt(a);\n for (let h = n; h < o - n; h++) {\n const g = e.children[h];\n K(s, e.leaf ? r(g) : g), u += nt(s);\n }\n for (let h = o - n - 1; h >= n; h--) {\n const g = e.children[h];\n K(a, e.leaf ? r(g) : g), u += nt(a);\n }\n return u;\n }\n _adjustParentBBoxes(e, n, o) {\n for (let i = o; i >= 0; i--)\n K(n[i], e);\n }\n _condense(e) {\n for (let n = e.length - 1, o; n >= 0; n--)\n e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : j(e[n], this.toBBox);\n }\n}\nfunction xn(t, e, n) {\n if (!n) return e.indexOf(t);\n for (let o = 0; o < e.length; o++)\n if (n(t, e[o])) return o;\n return -1;\n}\nfunction j(t, e) {\n G(t, 0, t.children.length, e, t);\n}\nfunction G(t, e, n, o, i) {\n i || (i = W(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;\n for (let r = e; r < n; r++) {\n const s = t.children[r];\n K(i, t.leaf ? o(s) : s);\n }\n return i;\n}\nfunction K(t, e) {\n 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;\n}\nfunction An(t, e) {\n return t.minX - e.minX;\n}\nfunction Sn(t, e) {\n return t.minY - e.minY;\n}\nfunction gt(t) {\n return (t.maxX - t.minX) * (t.maxY - t.minY);\n}\nfunction nt(t) {\n return t.maxX - t.minX + (t.maxY - t.minY);\n}\nfunction En(t, e) {\n 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));\n}\nfunction Cn(t, e) {\n 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);\n return Math.max(0, i - n) * Math.max(0, r - o);\n}\nfunction pt(t, e) {\n return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;\n}\nfunction ot(t, e) {\n return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;\n}\nfunction W(t) {\n return {\n children: t,\n height: 1,\n leaf: !0,\n minX: 1 / 0,\n minY: 1 / 0,\n maxX: -1 / 0,\n maxY: -1 / 0\n };\n}\nfunction kt(t, e, n, o, i) {\n const r = [e, n];\n for (; r.length; ) {\n if (n = r.pop(), e = r.pop(), n - e <= o) continue;\n const s = e + Math.ceil((n - e) / o / 2) * o;\n Wt(t, s, e, n, i), r.push(e, s, s, n);\n }\n}\nconst Ln = (t, e) => {\n const n = new wn(), o = /* @__PURE__ */ new Map(), i = (l, c) => {\n const m = l.selector.flatMap((L) => {\n const S = H([L]) ? L.range : Yt(L, e).range;\n return Array.from(S.getClientRects());\n }), C = de(m).map(({ left: L, top: S, right: T, bottom: R }) => new DOMRect(L - c.left, S - c.top, T - L, R - S));\n return C.map((L) => {\n const { x: S, y: T, width: R, height: O } = L;\n return {\n minX: S,\n minY: T,\n maxX: S + R,\n maxY: T + O,\n annotation: {\n id: l.annotation,\n rects: C\n }\n };\n });\n }, r = () => [...o.values()], s = () => {\n n.clear(), o.clear();\n }, a = (l) => {\n const c = i(l, e.getBoundingClientRect());\n c.forEach((m) => n.insert(m)), o.set(l.annotation, c);\n }, u = (l) => {\n const c = o.get(l.annotation);\n c && (c.forEach((m) => n.remove(m)), o.delete(l.annotation));\n }, h = (l) => {\n u(l), a(l);\n }, g = (l, c = !0) => {\n c && s();\n const m = e.getBoundingClientRect(), C = l.map((S) => ({ target: S, rects: i(S, m) }));\n C.forEach(({ target: S, rects: T }) => o.set(S.annotation, T));\n const L = C.flatMap(({ rects: S }) => S);\n n.load(L);\n }, d = (l, c, m = !1) => {\n const C = n.search({\n minX: l,\n minY: c,\n maxX: l,\n maxY: c\n }), L = (S) => S.annotation.rects.reduce((T, R) => T + R.width * R.height, 0);\n return C.length > 0 ? (C.sort((S, T) => L(S) - L(T)), m ? C.map((S) => S.annotation.id) : [C[0].annotation.id]) : [];\n }, b = (l) => {\n const c = f(l);\n if (c.length === 0)\n return;\n let m = c[0].left, C = c[0].top, L = c[0].right, S = c[0].bottom;\n for (let T = 1; T < c.length; T++) {\n const R = c[T];\n m = Math.min(m, R.left), C = Math.min(C, R.top), L = Math.max(L, R.right), S = Math.max(S, R.bottom);\n }\n return new DOMRect(m, C, L - m, S - C);\n }, f = (l) => {\n const c = o.get(l);\n return c ? c[0].annotation.rects : [];\n };\n return {\n all: r,\n clear: s,\n getAt: d,\n getAnnotationBounds: b,\n getAnnotationRects: f,\n getIntersecting: (l, c, m, C) => {\n const L = n.search({ minX: l, minY: c, maxX: m, maxY: C }), S = new Set(L.map((T) => T.annotation.id));\n return Array.from(S).map((T) => ({\n annotation: t.getAnnotation(T),\n rects: f(T)\n })).filter((T) => !!T.annotation);\n },\n insert: a,\n recalculate: () => g(t.all().map((l) => l.target), !0),\n remove: u,\n set: g,\n size: () => n.all().length,\n update: h\n };\n}, Tn = (t, e) => {\n const n = Qe(), o = Ln(n, t), i = Ye(n);\n i.setUserSelectAction(e);\n const r = _e(n), s = en(), a = (v, p = N.LOCAL) => {\n const l = st(v, t), c = H(l.target.selector);\n return c && n.addAnnotation(l, p), c;\n }, u = (v, p = !0, l = N.LOCAL) => {\n const c = v.map((C) => st(C, t)), m = c.filter((C) => !H(C.target.selector));\n return m.length > 0 ? (console.warn(\"Could not revive all targets for these annotations:\", m), n.bulkAddAnnotation(c, p, l), m) : (n.bulkAddAnnotation(c, p, l), []);\n }, h = (v, p = N.LOCAL) => {\n const l = v.map((m) => st(m, t)), c = l.filter((m) => !H(m.target.selector));\n return c.length > 0 && console.warn(\"Could not revive all targets for these annotations:\", c), l.forEach((m) => {\n n.getAnnotation(m.id) ? n.updateAnnotation(m, p) : n.addAnnotation(m, p);\n }), c;\n }, g = (v, p = N.LOCAL) => {\n const l = rt(v, t);\n n.updateTarget(l, p);\n }, d = (v, p = N.LOCAL) => {\n const l = v.map((c) => rt(c, t));\n n.bulkUpdateTargets(l, p);\n }, b = (v, p, l) => {\n const c = o.getAt(v, p, !!l).map((C) => n.getAnnotation(C)), m = l ? c.filter(l) : c;\n return m.length > 0 ? m[0] : void 0;\n }, f = (v, p, l, c = 5) => {\n const m = o.getAnnotationRects(v);\n if (m.length !== 0) {\n if (p && l) {\n const C = m.find(({ top: L, right: S, bottom: T, left: R }) => p >= R - c && p <= S + c && l >= L - c && l <= T + c);\n if (C) return C;\n }\n return o.getAnnotationBounds(v);\n }\n }, A = () => o.recalculate();\n return n.observe(({ changes: v }) => {\n const p = (v.deleted || []).filter((m) => H(m.target.selector)), l = (v.created || []).filter((m) => H(m.target.selector)), c = (v.updated || []).filter((m) => H(m.newValue.target.selector));\n (p == null ? void 0 : p.length) > 0 && p.forEach((m) => o.remove(m.target)), l.length > 0 && o.set(l.map((m) => m.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: m }) => o.update(m.target));\n }), {\n store: {\n ...n,\n addAnnotation: a,\n bulkAddAnnotation: u,\n bulkUpdateTargets: d,\n bulkUpsertAnnotations: h,\n getAnnotationBounds: f,\n getAt: b,\n getIntersecting: o.getIntersecting,\n recalculatePositions: A,\n updateTarget: g\n },\n selection: i,\n hover: r,\n viewport: s\n };\n}, Rn = () => {\n const t = document.createElement(\"canvas\");\n t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = \"r6o-presence-layer\";\n const e = t.getContext(\"2d\");\n return e.scale(2, 2), e.translate(0.5, 0.5), t;\n}, Bn = (t, e, n = {}) => {\n const o = Rn(), i = o.getContext(\"2d\");\n document.body.appendChild(o);\n const r = /* @__PURE__ */ new Map(), s = (d) => Array.from(r.entries()).filter(([b, f]) => f.presenceKey === d.presenceKey).map(([b, f]) => b);\n return e.on(\"selectionChange\", (d, b) => {\n s(d).forEach((A) => r.delete(A)), b && b.forEach((A) => r.set(A, d));\n }), {\n clear: () => {\n const { width: d, height: b } = o;\n i.clearRect(-0.5, -0.5, d + 1, b + 1);\n },\n destroy: () => {\n o.remove();\n },\n paint: (d, b, f) => {\n n.font && (i.font = n.font);\n const A = r.get(d.annotation.id);\n if (A) {\n const { height: v } = d.rects[0], p = d.rects[0].x + b.left, l = d.rects[0].y + b.top;\n i.fillStyle = A.appearance.color, i.fillRect(p - 2, l - 2.5, 2, v + 5);\n const c = i.measureText(A.appearance.label), m = c.width + 6, C = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;\n return i.fillRect(p - 2, l - 2.5 - C, m, C), i.fillStyle = \"#fff\", i.fillText(A.appearance.label, p + 1, l - L), {\n fill: A.appearance.color,\n fillOpacity: f ? 0.45 : 0.18\n };\n }\n },\n reset: () => {\n o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;\n const d = o.getContext(\"2d\");\n d.scale(2, 2), d.translate(0.5, 0.5);\n }\n };\n}, qt = (t) => {\n if (t === null)\n return document.scrollingElement;\n const { overflowY: e } = window.getComputedStyle(t);\n return e !== \"visible\" && e !== \"hidden\" && t.scrollHeight > t.clientHeight ? t : qt(t.parentElement);\n}, Nn = (t, e) => (n) => {\n const o = typeof n == \"string\" ? n : n.id, i = (s) => {\n const a = r.getBoundingClientRect(), u = r.clientHeight, h = r.clientWidth, g = s.selector[0].range.getBoundingClientRect(), { width: d, height: b } = e.getAnnotationBounds(o), f = g.top - a.top, A = g.left - a.left, v = r.parentElement ? r.scrollTop : 0, p = r.parentElement ? r.scrollLeft : 0, l = f + v - (u - b) / 2, c = A + p - (h - d) / 2;\n r.scroll({ top: l, left: c, behavior: \"smooth\" });\n }, r = qt(t);\n if (r) {\n const s = e.getAnnotation(o), { range: a } = s.target.selector[0];\n if (a && !a.collapsed)\n return i(s.target), !0;\n {\n const u = rt(s.target, t), { range: h } = u.selector[0];\n if (h && !h.collapsed)\n return i(u), !0;\n }\n }\n return !1;\n}, Mn = (t, e) => ({\n ...t,\n annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,\n user: t.user || e.user\n}), On = (t, e, n, o) => {\n let i;\n const r = (c) => i = c;\n let s;\n const a = (c) => s = c, { store: u, selection: h } = e;\n let g, d = !1, b;\n const f = (c) => {\n var C;\n if (!d) return;\n !((C = c.target.parentElement) != null && C.closest(X)) ? g = {\n annotation: Pt(),\n selector: [],\n creator: i,\n created: /* @__PURE__ */ new Date()\n } : g = void 0;\n };\n n && t.addEventListener(\"selectstart\", f);\n const A = vt((c) => {\n var y, x;\n const m = document.getSelection();\n if (!!((x = (y = m.anchorNode) == null ? void 0 : y.parentElement) != null && x.closest(X))) {\n g = void 0;\n return;\n }\n if (c.timeStamp - ((b == null ? void 0 : b.timeStamp) || c.timeStamp) < 1e3 && !g && f(b), m.isCollapsed || !d || !g) return;\n const S = m.getRangeAt(0), T = he(S, t);\n if (ae(T)) return;\n const R = ee(T.cloneRange());\n (R.length !== g.selector.length || R.some((w, E) => {\n var M;\n return w.toString() !== ((M = g.selector[E]) == null ? void 0 : M.quote);\n })) && (g = {\n ...g,\n selector: R.map((w) => ue(w, t, o)),\n updated: /* @__PURE__ */ new Date()\n }, u.getAnnotation(g.annotation) ? u.updateTarget(g, N.LOCAL) : (h.clear(), u.addAnnotation({\n id: g.annotation,\n bodies: [],\n target: g\n }), h.userSelect(g.annotation, b)));\n });\n n && document.addEventListener(\"selectionchange\", A);\n const v = (c) => {\n const { target: m, timeStamp: C, offsetX: L, offsetY: S, type: T } = c;\n b = { ...c, target: m, timeStamp: C, offsetX: L, offsetY: S, type: T }, d = c.button === 0;\n };\n t.addEventListener(\"pointerdown\", v);\n const p = (c) => {\n var S;\n if (!!((S = c.target.parentElement) != null && S.closest(X)) || !d)\n return;\n const C = () => {\n const { x: T, y: R } = t.getBoundingClientRect(), O = c.target instanceof Node && t.contains(c.target) && u.getAt(c.clientX - T, c.clientY - R, s);\n if (O) {\n const { selected: y } = h;\n (y.length !== 1 || y[0].id !== O.id) && h.userSelect(O.id, c);\n } else h.isEmpty() || h.clear();\n }, L = c.timeStamp - b.timeStamp;\n document.getSelection().isCollapsed && L < 300 ? (g = void 0, C()) : g && h.userSelect(g.annotation, c);\n };\n return document.addEventListener(\"pointerup\", p), {\n destroy: () => {\n t.removeEventListener(\"selectstart\", f), document.removeEventListener(\"selectionchange\", A), t.removeEventListener(\"pointerdown\", v), document.removeEventListener(\"pointerup\", p);\n },\n setFilter: a,\n setUser: r\n };\n}, _t = \"SPANS\", _n = (t, e = {}) => {\n ne(t);\n const n = Mn(e, {\n annotatingEnabled: !0,\n user: un()\n }), o = Tn(t, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = tn(s), u = nn(o, a, n.adapter);\n let h = n.user;\n const g = n.renderer === \"CSS_HIGHLIGHTS\" ? CSS.highlights ? \"CSS_HIGHLIGHTS\" : _t : n.renderer || _t, d = g === \"SPANS\" ? Me(t, o, r) : g === \"CSS_HIGHLIGHTS\" ? Re(t, o, r) : g === \"CANVAS\" ? ve(t, o, r) : void 0;\n if (!d)\n throw `Unknown renderer implementation: ${g}`;\n console.debug(`Using ${g} renderer`), n.style && d.setStyle(n.style);\n const b = On(t, o, n.annotatingEnabled, n.offsetReferenceSelector);\n return b.setUser(h), {\n ...rn(o, a, n.adapter),\n destroy: () => {\n d.destroy(), b.destroy(), a.destroy();\n },\n element: t,\n getUser: () => h,\n setFilter: (S) => {\n d.setFilter(S), b.setFilter(S);\n },\n setStyle: (S) => d.setStyle(S),\n setUser: (S) => {\n h = S, b.setUser(S);\n },\n setSelected: (S) => {\n S ? i.setSelected(S) : i.clear();\n },\n setPresenceProvider: (S) => {\n S && (d.setPainter(Bn(t, S, n.presence)), S.on(\"selectionChange\", () => d.redraw()));\n },\n setVisible: (S) => d.setVisible(S),\n on: u.on,\n off: u.off,\n scrollIntoView: Nn(t, s),\n state: o\n };\n};\nexport {\n it as DEFAULT_SELECTED_STYLE,\n P as DEFAULT_STYLE,\n Dt as NOT_ANNOTATABLE_CLASS,\n X as NOT_ANNOTATABLE_SELECTOR,\n N as Origin,\n De as UserSelectAction,\n kn as W3CTextFormat,\n ne as cancelSingleClickEvents,\n Vn as createBody,\n ve as createCanvasRenderer,\n Re as createHighlightsRenderer,\n Te as createRenderer,\n Me as createSpansRenderer,\n _n as createTextAnnotator,\n Tn as createTextAnnotatorState,\n vt as debounce,\n Mn as fillDefaults,\n In as getAnnotatableFragment,\n Un as getClientRectsPonyfill,\n re as getQuoteContext,\n mt as getRangeAnnotatableContents,\n H as isRevived,\n ae as isWhitespaceOrEmpty,\n de as mergeClientRects,\n Jt as paint,\n bn as parseW3CTextAnnotation,\n ue as rangeToSelector,\n st as reviveAnnotation,\n Yt as reviveSelector,\n rt as reviveTarget,\n vn as serializeW3CTextAnnotation,\n ee as splitAnnotatableRanges,\n he as trimRangeToContainer,\n se as whitespaceOrEmptyRegex\n};\n//# sourceMappingURL=text-annotator.es.js.map\n"],"names":[],"mappings":"AAAK,MAUF,KAAK,mBAAmB,IAAI,IAAI,EAAE,IA0BlC,KAAK,CAAC,MAAM;AACb,QAAM,IAAI,EAAE;AACZ,SAAO,EAAE,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG;AAC3D,GA+EG,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI,MAAM;AAC3B,QAAM,IAAoD,GAAG,IAAI,SAAS,YAAW;AACrF,IAAE,SAAS,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW;AAC1D,QAAM,IAAI,GAAG,CAAC,EAAE,aAAa,IAAI,SAAS;AAC1C,IAAE,SAAS,EAAE,cAAc,EAAE,SAAS,GAAG,MAAM,SAAS,OAAO,EAAE,OAAO,GAAG,EAAE,WAAW,MAAM,IAAI,EAAE,YAAY,CAAC;AACjH,QAAM,IAAI,GAAG,CAAC,EAAE;AAChB,SAAO;AAAA,IACL,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;AAAA,IAChC,QAAQ,EAAE,UAAU,GAAG,CAAC;AAAA,EAC5B;AACA;AA2ZA,IAAI,IAAI,CAAA;AACR,SAAS,KAAK,GAAG,KAAK,KAAK,EAAE;AAC3B,IAAE,MAAM,KAAK,KAAK,SAAS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GAAG,EAAE,QAAQ,GAAG,QAAQ,EAAG,IAAG,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;AAAA,MAC5F,MAAM;AAAA,MACN,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,QAAQ;AAAA,IACd,GAAO;AAAA,MACD,MAAM;AAAA,MACN,OAAO;AAAA,MACP,KAAK;AAAA,IACX,CAAK;AACD,WAAO;AAAA,MACL,GAAG;AAAA,MACH,IAAI,EAAE;AAAA,MACN,QAAQ;AAAA,MACR,UAAU;AAAA,IAChB;AAAA,EACA,CAAG;AACD,SAAO;AAAA,IACL,GAAG;AAAA,IACH,YAAY;AAAA,IACZ,IAAI,EAAE;AAAA,IACN,MAAM;AAAA,IACN,MAAM,GAAG,EAAE,MAAM;AAAA,IACjB,SAAS;AAAA,IACT,SAAS,KAAK,OAAO,SAAS,EAAE,YAAa;AAAA,IAC7C,UAAU,KAAK,OAAO,SAAS,EAAE,YAAa;AAAA,IAC9C,QAAQ;AAAA,EACZ;AACA;","x_google_ignoreList":[0]}
|
|
1
|
+
{"version":3,"file":"react-text-annotator.es7.js","sources":["../../../node_modules/@recogito/text-annotator/dist/text-annotator.es.js"],"sourcesContent":["const kt = \"not-annotatable\", X = `.${kt}`, Qt = (t) => {\n var n;\n const e = t.commonAncestorContainer;\n return e instanceof HTMLElement ? !e.closest(X) : !((n = e.parentElement) != null && n.closest(X));\n}, Jt = function* (t) {\n const e = document.createNodeIterator(\n t.commonAncestorContainer,\n NodeFilter.SHOW_ELEMENT,\n (o) => o instanceof HTMLElement && o.classList.contains(kt) && !o.parentElement.closest(X) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP\n );\n let n;\n for (; n = e.nextNode(); )\n n instanceof HTMLElement && (yield n);\n}, Zt = (t) => {\n if (!Qt(t)) return [];\n const e = [];\n let n = null;\n for (const o of Jt(t)) {\n let i;\n n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;\n }\n if (n) {\n const o = t.cloneRange();\n o.setStartAfter(n), o.collapsed || e.push(o);\n }\n return e.length > 0 ? e : [t];\n}, bt = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(X).forEach((n) => n.remove()), e;\n}, te = (t) => {\n t.addEventListener(\"click\", (e) => {\n // Allow clicks within not-annotatable elements\n !e.target.closest(X) && !e.target.closest(\"a\") && e.preventDefault();\n });\n}, yt = (t, e = 10) => {\n let n;\n return (...o) => {\n clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);\n };\n}, Mn = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(X).forEach((n) => n.remove()), e;\n}, ee = (t, e, n = 10, o) => {\n const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();\n r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);\n const c = bt(r).textContent, a = document.createRange();\n a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);\n const d = bt(a).textContent;\n return {\n prefix: c.substring(c.length - n),\n suffix: d.substring(0, n)\n };\n}, ne = /^\\s*$/, oe = (t) => ne.test(t.toString()), H = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ie = (t, e) => {\n const n = (r) => Math.round(r * 10) / 10, o = {\n top: n(t.top),\n bottom: n(t.bottom),\n left: n(t.left),\n right: n(t.right)\n }, i = {\n top: n(e.top),\n bottom: n(e.bottom),\n left: n(e.left),\n right: n(e.right)\n };\n if (Math.abs(o.top - i.top) < 0.5 && Math.abs(o.bottom - i.bottom) < 0.5) {\n if (Math.abs(o.left - i.right) < 0.5 || Math.abs(o.right - i.left) < 0.5)\n return \"inline-adjacent\";\n if (o.left >= i.left && o.right <= i.right)\n return \"inline-is-contained\";\n if (o.left <= i.left && o.right >= i.right)\n return \"inline-contains\";\n } else if (o.top <= i.top && o.bottom >= i.bottom) {\n if (o.left <= i.left && o.right >= i.right)\n return \"block-contains\";\n } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)\n return \"block-is-contained\";\n}, re = (t, e) => {\n 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);\n return new DOMRect(n, i, o - n, r - i);\n}, se = (t) => t.reduce((e, n) => {\n if (n.width === 0 || n.height === 0)\n return e;\n let o = [...e], i = !1;\n for (const r of e) {\n const c = ie(n, r);\n if (c === \"inline-adjacent\") {\n o = o.map((a) => a === r ? re(n, r) : a), i = !0;\n break;\n } else if (c === \"inline-contains\") {\n o = o.map((a) => a === r ? n : a), i = !0;\n break;\n } else if (c === \"inline-is-contained\") {\n i = !0;\n break;\n } else if (c === \"block-contains\" || c === \"block-is-contained\") {\n n.width < r.width && (o = o.map((a) => a === r ? n : a)), i = !0;\n break;\n }\n }\n return i ? o : [...o, n];\n}, []), ae = (t, e, n) => {\n const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;\n o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);\n const r = bt(o).textContent, c = t.toString(), a = r.length || 0, d = a + c.length;\n return n ? { quote: c, start: a, end: d, range: t, offsetReference: i } : { quote: c, start: a, end: d, range: t };\n}, _t = (t, e) => {\n var g, h;\n const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(\n e,\n NodeFilter.SHOW_TEXT,\n (v) => {\n var f;\n return (f = v.parentElement) != null && f.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;\n }\n );\n let c = 0;\n const a = document.createRange();\n let d = r.nextNode();\n d === null && console.error(\"Could not revive annotation target. Content missing.\");\n let u = !i;\n for (; d !== null; ) {\n if (u || (u = i == null ? void 0 : i.contains(d)), u) {\n const v = ((g = d.textContent) == null ? void 0 : g.length) || 0;\n if (c + v > n) {\n a.setStart(d, n - c);\n break;\n }\n c += v;\n }\n d = r.nextNode();\n }\n for (; d !== null; ) {\n const v = ((h = d.textContent) == null ? void 0 : h.length) || 0;\n if (c + v >= o) {\n a.setEnd(d, o - c);\n break;\n }\n c += v, d = r.nextNode();\n }\n return {\n ...t,\n range: a\n };\n}, it = (t, e) => H(t.selector) ? t : {\n ...t,\n selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : _t(n, e))\n}, st = (t, e) => H(t.target.selector) ? t : { ...t, target: it(t.target, e) }, ce = (t, e) => {\n const n = t.cloneRange();\n return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;\n}, Yt = (t) => {\n if (t === null)\n return document.scrollingElement;\n const { overflowY: e } = window.getComputedStyle(t);\n return e !== \"visible\" && e !== \"hidden\" && t.scrollHeight > t.clientHeight ? t : Yt(t.parentElement);\n}, le = (t, e) => (n) => {\n const o = typeof n == \"string\" ? n : n.id, i = (c) => {\n const a = r.getBoundingClientRect(), d = r.clientHeight, u = r.clientWidth, g = c.selector[0].range.getBoundingClientRect(), { width: h, height: v } = e.getAnnotationBounds(o), f = g.top - a.top, S = g.left - a.left, y = r.parentElement ? r.scrollTop : 0, b = r.parentElement ? r.scrollLeft : 0, l = f + y - (d - v) / 2, s = S + b - (u - h) / 2;\n r.scroll({ top: l, left: s, behavior: \"smooth\" });\n }, r = Yt(t);\n if (r) {\n const c = e.getAnnotation(o), { range: a } = c.target.selector[0];\n if (a && !a.collapsed)\n return i(c.target), !0;\n {\n const d = it(c.target, t), { range: u } = d.selector[0];\n if (u && !u.collapsed)\n return i(d), !0;\n }\n }\n return !1;\n}, P = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.18\n}, rt = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.45\n}, de = (t, e, n, o, i) => {\n var c, a;\n const r = n ? typeof n == \"function\" ? n(t.annotation, t.state, i) || ((c = t.state) != null && c.selected ? rt : P) : n : (a = t.state) != null && a.selected ? rt : P;\n return o && o.paint(t, e) || r;\n}, ue = (t) => {\n const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, c = -e, a = o - n, d = i - e;\n return { top: e, left: n, minX: r, minY: c, maxX: a, maxY: d };\n}, he = (t) => {\n let e = /* @__PURE__ */ new Set();\n return (o) => {\n const i = o.map((r) => r.id);\n (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);\n };\n}, wt = (t, e, n, o) => {\n const { store: i, selection: r, hover: c } = e;\n let a, d, u;\n const g = he(n), h = (R) => {\n const { x: I, y: m } = t.getBoundingClientRect(), A = i.getAt(R.clientX - I, R.clientY - m, d);\n A ? c.current !== A.id && (t.classList.add(\"hovered\"), c.set(A.id)) : c.current && (t.classList.remove(\"hovered\"), c.set(null));\n };\n t.addEventListener(\"pointermove\", h);\n const v = (R = !1) => {\n u && u.clear();\n const I = ue(t), { minX: m, minY: A, maxX: w, maxY: C } = I, O = d ? i.getIntersecting(m, A, w, C).filter(({ annotation: k }) => d(k)) : i.getIntersecting(m, A, w, C), B = r.selected.map(({ id: k }) => k), D = O.map(({ annotation: k, rects: qt }) => {\n const Gt = B.includes(k.id), Kt = k.id === c.current;\n return { annotation: k, rects: qt, state: { selected: Gt, hover: Kt } };\n });\n o.redraw(D, I, a, u, R), setTimeout(() => g(O.map(({ annotation: k }) => k)), 1);\n }, f = (R) => {\n u = R, v();\n }, S = (R) => {\n a = R, v();\n }, y = (R) => {\n d = R, v(!1);\n }, b = () => v();\n i.observe(b);\n const l = r.subscribe(() => v()), s = () => v(!0);\n document.addEventListener(\"scroll\", s, { capture: !0, passive: !0 });\n const p = yt(() => {\n i.recalculatePositions(), u && u.reset(), v();\n });\n window.addEventListener(\"resize\", p);\n const x = new ResizeObserver(p);\n x.observe(t);\n const L = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((R) => {\n R.every((m) => m.target === t || t.contains(m.target)) || v(!0);\n });\n return E.observe(document.body, L), {\n destroy: () => {\n t.removeEventListener(\"pointermove\", h), o.destroy(), i.unobserve(b), l(), document.removeEventListener(\"scroll\", s), window.removeEventListener(\"resize\", p), x.disconnect(), E.disconnect();\n },\n redraw: v,\n setStyle: S,\n setFilter: y,\n setPainter: f,\n setVisible: o.setVisible\n };\n}, fe = () => {\n const t = document.createElement(\"canvas\");\n return t.width = window.innerWidth, t.height = window.innerHeight, t.className = \"r6o-canvas-highlight-layer bg\", t;\n}, ge = (t, e) => {\n t.width = window.innerWidth, t.height = window.innerHeight;\n}, pe = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = fe(), n = e.getContext(\"2d\");\n document.body.appendChild(e);\n const o = (a, d, u, g) => requestAnimationFrame(() => {\n const { width: h, height: v } = e;\n n.clearRect(-0.5, -0.5, h + 1, v + 1), g && g.clear();\n const { top: f, left: S } = d;\n [...a].sort((b, l) => {\n const { annotation: { target: { created: s } } } = b, { annotation: { target: { created: p } } } = l;\n return s.getTime() - p.getTime();\n }).forEach((b) => {\n var x;\n const l = u ? typeof u == \"function\" ? u(b.annotation, b.state) : u : (x = b.state) != null && x.selected ? rt : P, s = g && g.paint(b, d) || l, p = b.rects.map(({ x: L, y: E, width: T, height: R }) => ({\n x: L + S,\n y: E + f,\n width: T,\n height: R\n }));\n if (n.fillStyle = s.fill, n.globalAlpha = s.fillOpacity || 1, p.forEach(\n ({ x: L, y: E, width: T, height: R }) => n.fillRect(L, E, T, R)\n ), s.underlineColor) {\n n.globalAlpha = 1, n.strokeStyle = s.underlineColor, n.lineWidth = s.underlineThickness ?? 1;\n const L = s.underlineOffset ?? 0;\n p.forEach(({ x: E, y: T, width: R, height: I }) => {\n n.beginPath(), n.moveTo(E, T + I + L), n.lineTo(E + R, T + I + L), n.stroke();\n });\n }\n });\n }), i = yt(() => {\n ge(e);\n });\n return window.addEventListener(\"resize\", i), {\n destroy: () => {\n e.remove(), window.removeEventListener(\"resize\", i);\n },\n setVisible: (a) => {\n console.log(\"setVisible not implemented on Canvas renderer\");\n },\n redraw: o\n };\n}, me = (t, e, n) => wt(t, e, n, pe(t));\nvar be = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, $ = function(t) {\n return typeof t == \"string\" ? t.length > 0 : typeof t == \"number\";\n}, N = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;\n}, _ = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;\n}, Xt = function(t) {\n return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;\n}, xt = function(t) {\n return { r: _(t.r, 0, 255), g: _(t.g, 0, 255), b: _(t.b, 0, 255), a: _(t.a) };\n}, at = function(t) {\n return { r: N(t.r), g: N(t.g), b: N(t.b), a: N(t.a, 3) };\n}, ve = /^#([0-9a-f]{3,8})$/i, J = function(t) {\n var e = t.toString(16);\n return e.length < 2 ? \"0\" + e : e;\n}, $t = function(t) {\n var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), c = r - Math.min(e, n, o), a = c ? r === e ? (n - o) / c : r === n ? 2 + (o - e) / c : 4 + (e - n) / c : 0;\n return { h: 60 * (a < 0 ? a + 6 : a), s: r ? c / r * 100 : 0, v: r / 255 * 100, a: i };\n}, Ht = function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a;\n e = e / 360 * 6, n /= 100, o /= 100;\n var r = Math.floor(e), c = o * (1 - n), a = o * (1 - (e - r) * n), d = o * (1 - (1 - e + r) * n), u = r % 6;\n return { r: 255 * [o, a, c, c, d, o][u], g: 255 * [d, o, o, a, c, c][u], b: 255 * [c, c, d, o, o, a][u], a: i };\n}, St = function(t) {\n return { h: Xt(t.h), s: _(t.s, 0, 100), l: _(t.l, 0, 100), a: _(t.a) };\n}, Et = function(t) {\n return { h: N(t.h), s: N(t.s), l: N(t.l), a: N(t.a, 3) };\n}, Ct = function(t) {\n return Ht((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 }));\n var e, n, o;\n}, Q = function(t) {\n return { h: (e = $t(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 };\n var e, n, o, i;\n}, ye = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, we = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s+([+-]?\\d*\\.?\\d+)%\\s+([+-]?\\d*\\.?\\d+)%\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Ae = /^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, xe = /^rgba?\\(\\s*([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s+([+-]?\\d*\\.?\\d+)(%)?\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, Lt = { string: [[function(t) {\n var e = ve.exec(t);\n 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 ? N(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 ? N(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;\n}, \"hex\"], [function(t) {\n var e = Ae.exec(t) || xe.exec(t);\n return e ? e[2] !== e[4] || e[4] !== e[6] ? null : xt({ 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;\n}, \"rgb\"], [function(t) {\n var e = ye.exec(t) || we.exec(t);\n if (!e) return null;\n var n, o, i = St({ h: (n = e[1], o = e[2], o === void 0 && (o = \"deg\"), Number(n) * (be[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });\n return Ct(i);\n}, \"hsl\"]], object: [[function(t) {\n var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;\n return $(e) && $(n) && $(o) ? xt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;\n}, \"rgb\"], [function(t) {\n var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;\n if (!$(e) || !$(n) || !$(o)) return null;\n var c = St({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });\n return Ct(c);\n}, \"hsl\"], [function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;\n if (!$(e) || !$(n) || !$(o)) return null;\n var c = function(a) {\n return { h: Xt(a.h), s: _(a.s, 0, 100), v: _(a.v, 0, 100), a: _(a.a) };\n }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });\n return Ht(c);\n}, \"hsv\"]] }, Tt = function(t, e) {\n for (var n = 0; n < e.length; n++) {\n var o = e[n][0](t);\n if (o) return [o, e[n][1]];\n }\n return [null, void 0];\n}, Se = function(t) {\n return typeof t == \"string\" ? Tt(t.trim(), Lt.string) : typeof t == \"object\" && t !== null ? Tt(t, Lt.object) : [null, void 0];\n}, ct = function(t, e) {\n var n = Q(t);\n return { h: n.h, s: _(n.s + 100 * e, 0, 100), l: n.l, a: n.a };\n}, lt = function(t) {\n return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;\n}, Rt = function(t, e) {\n var n = Q(t);\n return { h: n.h, s: n.s, l: _(n.l + 100 * e, 0, 100), a: n.a };\n}, Bt = function() {\n function t(e) {\n this.parsed = Se(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };\n }\n return t.prototype.isValid = function() {\n return this.parsed !== null;\n }, t.prototype.brightness = function() {\n return N(lt(this.rgba), 2);\n }, t.prototype.isDark = function() {\n return lt(this.rgba) < 0.5;\n }, t.prototype.isLight = function() {\n return lt(this.rgba) >= 0.5;\n }, t.prototype.toHex = function() {\n return e = at(this.rgba), n = e.r, o = e.g, i = e.b, c = (r = e.a) < 1 ? J(N(255 * r)) : \"\", \"#\" + J(n) + J(o) + J(i) + c;\n var e, n, o, i, r, c;\n }, t.prototype.toRgb = function() {\n return at(this.rgba);\n }, t.prototype.toRgbString = function() {\n return e = at(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? \"rgba(\" + n + \", \" + o + \", \" + i + \", \" + r + \")\" : \"rgb(\" + n + \", \" + o + \", \" + i + \")\";\n var e, n, o, i, r;\n }, t.prototype.toHsl = function() {\n return Et(Q(this.rgba));\n }, t.prototype.toHslString = function() {\n return e = Et(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 + \"%)\";\n var e, n, o, i, r;\n }, t.prototype.toHsv = function() {\n return e = $t(this.rgba), { h: N(e.h), s: N(e.s), v: N(e.v), a: N(e.a, 3) };\n var e;\n }, t.prototype.invert = function() {\n return Y({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });\n var e;\n }, t.prototype.saturate = function(e) {\n return e === void 0 && (e = 0.1), Y(ct(this.rgba, e));\n }, t.prototype.desaturate = function(e) {\n return e === void 0 && (e = 0.1), Y(ct(this.rgba, -e));\n }, t.prototype.grayscale = function() {\n return Y(ct(this.rgba, -1));\n }, t.prototype.lighten = function(e) {\n return e === void 0 && (e = 0.1), Y(Rt(this.rgba, e));\n }, t.prototype.darken = function(e) {\n return e === void 0 && (e = 0.1), Y(Rt(this.rgba, -e));\n }, t.prototype.rotate = function(e) {\n return e === void 0 && (e = 15), this.hue(this.hue() + e);\n }, t.prototype.alpha = function(e) {\n return typeof e == \"number\" ? Y({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : N(this.rgba.a, 3);\n var n;\n }, t.prototype.hue = function(e) {\n var n = Q(this.rgba);\n return typeof e == \"number\" ? Y({ h: e, s: n.s, l: n.l, a: n.a }) : N(n.h);\n }, t.prototype.isEqual = function(e) {\n return this.toHex() === Y(e).toHex();\n }, t;\n}(), Y = function(t) {\n return t instanceof Bt ? t : new Bt(t);\n};\nconst Ee = (t) => [\n `background-color:${Y((t == null ? void 0 : t.fill) || P.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,\n t != null && t.underlineThickness ? \"text-decoration:underline\" : void 0,\n t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,\n t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,\n t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0\n].filter(Boolean).join(\";\"), Ce = () => {\n const t = document.createElement(\"style\");\n document.getElementsByTagName(\"head\")[0].appendChild(t);\n let e = /* @__PURE__ */ new Set();\n return {\n destroy: () => {\n CSS.highlights.clear(), t.remove();\n },\n setVisible: (r) => {\n console.log(\"setVisible not implemented on CSS Custom Highlights renderer\");\n },\n redraw: (r, c, a, d) => {\n d && d.clear();\n const u = new Set(r.map((h) => h.annotation.id));\n Array.from(e).filter((h) => !u.has(h));\n const g = r.map((h) => {\n var S;\n const v = a ? typeof a == \"function\" ? a(h.annotation, h.state) : a : (S = h.state) != null && S.selected ? rt : P, f = d && d.paint(h, c) || v;\n return `::highlight(_${h.annotation.id}) { ${Ee(f)} }`;\n });\n t.innerHTML = g.join(`\n`), CSS.highlights.clear(), r.forEach(({ annotation: h }) => {\n const v = h.target.selector.map((S) => S.range), f = new Highlight(...v);\n CSS.highlights.set(`_${h.id}`, f);\n }), e = u;\n }\n };\n}, Le = (t, e, n) => wt(t, e, n, Ce());\nvar Mt = Object.prototype.hasOwnProperty;\nfunction vt(t, e) {\n var n, o;\n if (t === e) return !0;\n if (t && e && (n = t.constructor) === e.constructor) {\n if (n === Date) return t.getTime() === e.getTime();\n if (n === RegExp) return t.toString() === e.toString();\n if (n === Array) {\n if ((o = t.length) === e.length)\n for (; o-- && vt(t[o], e[o]); ) ;\n return o === -1;\n }\n if (!n || typeof t == \"object\") {\n o = 0;\n for (n in t)\n if (Mt.call(t, n) && ++o && !Mt.call(e, n) || !(n in e) || !vt(t[n], e[n])) return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nconst Te = (t, e) => {\n const n = (r, c) => r.x <= c.x + c.width && r.x + r.width >= c.x && r.y <= c.y + c.height && r.y + r.height >= c.y, o = (r) => r.rects.reduce((c, a) => c + a.width, 0), i = e.filter(({ rects: r }) => r.some((c) => n(t, c)));\n return i.sort((r, c) => o(c) - o(r)), i.findIndex((r) => r.rects.includes(t));\n}, Re = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = document.createElement(\"div\");\n e.className = \"r6o-span-highlight-layer\", t.insertBefore(e, t.firstChild);\n let n = [];\n return {\n destroy: () => {\n e.remove();\n },\n redraw: (c, a, d, u, g) => {\n const v = !(vt(n, c) && g);\n if (!u && !v) return;\n v && (e.innerHTML = \"\"), [...c].sort((S, y) => {\n const { annotation: { target: { created: b } } } = S, { annotation: { target: { created: l } } } = y;\n return b && l ? b.getTime() - l.getTime() : 0;\n }).forEach((S) => {\n S.rects.map((y) => {\n const b = Te(y, c), l = de(S, a, d, u, b);\n if (v) {\n const s = document.createElement(\"span\");\n s.className = \"r6o-annotation\", s.dataset.annotation = S.annotation.id, s.style.left = `${y.x}px`, s.style.top = `${y.y}px`, s.style.width = `${y.width}px`, s.style.height = `${y.height}px`, s.style.backgroundColor = Y((l == null ? void 0 : l.fill) || P.fill).alpha((l == null ? void 0 : l.fillOpacity) === void 0 ? P.fillOpacity : l.fillOpacity).toHex(), l.underlineStyle && (s.style.borderStyle = l.underlineStyle), l.underlineColor && (s.style.borderColor = l.underlineColor), l.underlineThickness && (s.style.borderBottomWidth = `${l.underlineThickness}px`), l.underlineOffset && (s.style.paddingBottom = `${l.underlineOffset}px`), e.appendChild(s);\n }\n });\n }), n = c;\n },\n setVisible: (c) => {\n c ? e.classList.remove(\"hidden\") : e.classList.add(\"hidden\");\n }\n };\n}, Be = (t, e, n) => wt(t, e, n, Re(t));\nvar U = [];\nfor (var dt = 0; dt < 256; ++dt)\n U.push((dt + 256).toString(16).slice(1));\nfunction Me(t, e = 0) {\n return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + \"-\" + U[t[e + 4]] + U[t[e + 5]] + \"-\" + U[t[e + 6]] + U[t[e + 7]] + \"-\" + U[t[e + 8]] + U[t[e + 9]] + \"-\" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();\n}\nvar Z, Oe = new Uint8Array(16);\nfunction Ie() {\n if (!Z && (Z = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !Z))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return Z(Oe);\n}\nvar Ne = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Ot = {\n randomUUID: Ne\n};\nfunction Pt(t, e, n) {\n if (Ot.randomUUID && !e && !t)\n return Ot.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || Ie)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Me(o);\n}\nvar It = Object.prototype.hasOwnProperty;\nfunction z(t, e) {\n var n, o;\n if (t === e) return !0;\n if (t && e && (n = t.constructor) === e.constructor) {\n if (n === Date) return t.getTime() === e.getTime();\n if (n === RegExp) return t.toString() === e.toString();\n if (n === Array) {\n if ((o = t.length) === e.length)\n for (; o-- && z(t[o], e[o]); ) ;\n return o === -1;\n }\n if (!n || typeof t == \"object\") {\n o = 0;\n for (n in t)\n if (It.call(t, n) && ++o && !It.call(e, n) || !(n in e) || !z(t[n], e[n])) return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nfunction ut() {\n}\nfunction Ue(t, e) {\n return t != t ? e == e : t !== e || t && typeof t == \"object\" || typeof t == \"function\";\n}\nconst j = [];\nfunction At(t, e = ut) {\n let n;\n const o = /* @__PURE__ */ new Set();\n function i(a) {\n if (Ue(t, a) && (t = a, n)) {\n const d = !j.length;\n for (const u of o)\n u[1](), j.push(u, t);\n if (d) {\n for (let u = 0; u < j.length; u += 2)\n j[u][0](j[u + 1]);\n j.length = 0;\n }\n }\n }\n function r(a) {\n i(a(t));\n }\n function c(a, d = ut) {\n const u = [a, d];\n return o.add(u), o.size === 1 && (n = e(i, r) || ut), a(t), () => {\n o.delete(u), o.size === 0 && n && (n(), n = null);\n };\n }\n return { set: i, update: r, subscribe: c };\n}\nconst Ve = (t) => {\n const { subscribe: e, set: n } = At();\n let o;\n return e((i) => o = i), t.observe(({ changes: i }) => {\n if (o) {\n (i.deleted || []).some((c) => c.id === o) && n(void 0);\n const r = (i.updated || []).find(({ oldValue: c }) => c.id === o);\n r && n(r.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: e,\n set: n\n };\n};\nvar De = /* @__PURE__ */ ((t) => (t.EDIT = \"EDIT\", t.SELECT = \"SELECT\", t.NONE = \"NONE\", t))(De || {});\nconst tt = { selected: [] }, ke = (t, e) => {\n const { subscribe: n, set: o } = At(tt);\n let i = e, r = tt;\n n((f) => r = f);\n const c = () => {\n z(r, tt) || o(tt);\n }, a = () => {\n var f;\n return ((f = r.selected) == null ? void 0 : f.length) === 0;\n }, d = (f) => {\n if (a())\n return !1;\n const S = typeof f == \"string\" ? f : f.id;\n return r.selected.some((y) => y.id === S);\n }, u = (f, S) => {\n const y = t.getAnnotation(f);\n if (!y) {\n console.warn(\"Invalid selection: \" + f);\n return;\n }\n switch (Nt(y, i)) {\n case \"EDIT\":\n o({ selected: [{ id: f, editable: !0 }], event: S });\n break;\n case \"SELECT\":\n o({ selected: [{ id: f }], event: S });\n break;\n default:\n o({ selected: [], event: S });\n }\n }, g = (f, S) => {\n const y = Array.isArray(f) ? f : [f], b = y.map((l) => t.getAnnotation(l)).filter((l) => !!l);\n o({\n selected: b.map((l) => {\n const s = S === void 0 ? Nt(l, i) === \"EDIT\" : S;\n return { id: l.id, editable: s };\n })\n }), b.length !== y.length && console.warn(\"Invalid selection\", f);\n }, h = (f) => {\n if (a())\n return !1;\n const { selected: S } = r;\n S.some(({ id: y }) => f.includes(y)) && o({ selected: S.filter(({ id: y }) => !f.includes(y)) });\n }, v = (f) => i = f;\n return t.observe(\n ({ changes: f }) => h((f.deleted || []).map((S) => S.id))\n ), {\n get event() {\n return r ? r.event : null;\n },\n get selected() {\n return r ? [...r.selected] : null;\n },\n get userSelectAction() {\n return i;\n },\n clear: c,\n isEmpty: a,\n isSelected: d,\n setSelected: g,\n setUserSelectAction: v,\n subscribe: n,\n userSelect: u\n };\n}, Nt = (t, e) => typeof e == \"function\" ? e(t) : e || \"EDIT\";\nvar V = [];\nfor (var ht = 0; ht < 256; ++ht)\n V.push((ht + 256).toString(16).slice(1));\nfunction _e(t, e = 0) {\n return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + \"-\" + V[t[e + 4]] + V[t[e + 5]] + \"-\" + V[t[e + 6]] + V[t[e + 7]] + \"-\" + V[t[e + 8]] + V[t[e + 9]] + \"-\" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();\n}\nvar et, Ye = new Uint8Array(16);\nfunction Xe() {\n if (!et && (et = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !et))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return et(Ye);\n}\nvar $e = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Ut = {\n randomUUID: $e\n};\nfunction zt(t, e, n) {\n if (Ut.randomUUID && !e && !t)\n return Ut.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || Xe)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, _e(o);\n}\nconst ft = (t) => {\n const e = (n) => {\n const o = { ...n };\n return n.created && typeof n.created == \"string\" && (o.created = new Date(n.created)), n.updated && typeof n.updated == \"string\" && (o.updated = new Date(n.updated)), o;\n };\n return {\n ...t,\n bodies: (t.bodies || []).map(e),\n target: e(t.target)\n };\n}, On = (t, e, n, o) => ({\n id: zt(),\n annotation: typeof t == \"string\" ? t : t.id,\n created: n || /* @__PURE__ */ new Date(),\n creator: o,\n ...e\n}), He = (t, e) => {\n const n = new Set(t.bodies.map((o) => o.id));\n return e.bodies.filter((o) => !n.has(o.id));\n}, Pe = (t, e) => {\n const n = new Set(e.bodies.map((o) => o.id));\n return t.bodies.filter((o) => !n.has(o.id));\n}, ze = (t, e) => e.bodies.map((n) => {\n const o = t.bodies.find((i) => i.id === n.id);\n return { newBody: n, oldBody: o && !z(o, n) ? o : void 0 };\n}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), je = (t, e) => !z(t.target, e.target), jt = (t, e) => {\n const n = He(t, e), o = Pe(t, e), i = ze(t, e);\n return {\n oldValue: t,\n newValue: e,\n bodiesCreated: n.length > 0 ? n : void 0,\n bodiesDeleted: o.length > 0 ? o : void 0,\n bodiesUpdated: i.length > 0 ? i : void 0,\n targetUpdated: je(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0\n };\n};\nvar M = /* @__PURE__ */ ((t) => (t.LOCAL = \"LOCAL\", t.REMOTE = \"REMOTE\", t.SILENT = \"SILENT\", t))(M || {});\nconst Fe = (t, e) => {\n var n, o;\n const { changes: i, origin: r } = e;\n if (!(t.options.origin ? t.options.origin === r : r !== \"SILENT\"))\n return !1;\n if (t.options.ignore) {\n const { ignore: c } = t.options, a = (d) => d && d.length > 0;\n if (!(a(i.created) || a(i.deleted))) {\n const d = (n = i.updated) == null ? void 0 : n.some((g) => a(g.bodiesCreated) || a(g.bodiesDeleted) || a(g.bodiesUpdated)), u = (o = i.updated) == null ? void 0 : o.some((g) => g.targetUpdated);\n if (c === \"BODY_ONLY\" && d && !u || c === \"TARGET_ONLY\" && u && !d)\n return !1;\n }\n }\n if (t.options.annotations) {\n const c = /* @__PURE__ */ new Set([\n ...(i.created || []).map((a) => a.id),\n ...(i.deleted || []).map((a) => a.id),\n ...(i.updated || []).map(({ oldValue: a }) => a.id)\n ]);\n return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => c.has(a));\n } else\n return !0;\n}, We = (t, e) => {\n const n = new Set((t.created || []).map((h) => h.id)), o = new Set((t.updated || []).map(({ newValue: h }) => h.id)), i = new Set((e.created || []).map((h) => h.id)), r = new Set((e.deleted || []).map((h) => h.id)), c = new Set((e.updated || []).map(({ oldValue: h }) => h.id)), a = new Set((e.updated || []).filter(({ oldValue: h }) => n.has(h.id) || o.has(h.id)).map(({ oldValue: h }) => h.id)), d = [\n ...(t.created || []).filter((h) => !r.has(h.id)).map((h) => c.has(h.id) ? e.updated.find(({ oldValue: v }) => v.id === h.id).newValue : h),\n ...e.created || []\n ], u = [\n ...(t.deleted || []).filter((h) => !i.has(h.id)),\n ...(e.deleted || []).filter((h) => !n.has(h.id))\n ], g = [\n ...(t.updated || []).filter(({ newValue: h }) => !r.has(h.id)).map((h) => {\n const { oldValue: v, newValue: f } = h;\n if (c.has(f.id)) {\n const S = e.updated.find((y) => y.oldValue.id === f.id).newValue;\n return jt(v, S);\n } else\n return h;\n }),\n ...(e.updated || []).filter(({ oldValue: h }) => !a.has(h.id))\n ];\n return { created: d, deleted: u, updated: g };\n}, gt = (t) => {\n const e = t.id === void 0 ? zt() : t.id;\n return {\n ...t,\n id: e,\n bodies: t.bodies === void 0 ? [] : t.bodies.map((n) => ({\n ...n,\n annotation: e\n })),\n target: {\n ...t.target,\n annotation: e\n }\n };\n}, qe = (t) => t.id !== void 0, Ge = () => {\n const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, A = {}) => {\n n.push({ onChange: m, options: A });\n }, i = (m) => {\n const A = n.findIndex((w) => w.onChange == m);\n A > -1 && n.splice(A, 1);\n }, r = (m, A) => {\n const w = {\n origin: m,\n changes: {\n created: A.created || [],\n updated: A.updated || [],\n deleted: A.deleted || []\n },\n state: [...t.values()]\n };\n n.forEach((C) => {\n Fe(C, w) && C.onChange(w);\n });\n }, c = (m, A = M.LOCAL) => {\n if (m.id && t.get(m.id))\n throw Error(`Cannot add annotation ${m.id} - exists already`);\n {\n const w = gt(m);\n t.set(w.id, w), w.bodies.forEach((C) => e.set(C.id, w.id)), r(A, { created: [w] });\n }\n }, a = (m, A) => {\n const w = gt(typeof m == \"string\" ? A : m), C = typeof m == \"string\" ? m : m.id, O = C && t.get(C);\n if (O) {\n const B = jt(O, w);\n return C === w.id ? t.set(C, w) : (t.delete(C), t.set(w.id, w)), O.bodies.forEach((D) => e.delete(D.id)), w.bodies.forEach((D) => e.set(D.id, w.id)), B;\n } else\n console.warn(`Cannot update annotation ${C} - does not exist`);\n }, d = (m, A = M.LOCAL, w = M.LOCAL) => {\n const C = qe(A) ? w : A, O = a(m, A);\n O && r(C, { updated: [O] });\n }, u = (m, A = M.LOCAL) => {\n const w = m.reduce((C, O) => {\n const B = a(O);\n return B ? [...C, B] : C;\n }, []);\n w.length > 0 && r(A, { updated: w });\n }, g = (m, A = M.LOCAL) => {\n const w = t.get(m.annotation);\n if (w) {\n const C = {\n ...w,\n bodies: [...w.bodies, m]\n };\n t.set(w.id, C), e.set(m.id, C.id), r(A, { updated: [{\n oldValue: w,\n newValue: C,\n bodiesCreated: [m]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);\n }, h = () => [...t.values()], v = (m = M.LOCAL) => {\n const A = [...t.values()];\n t.clear(), e.clear(), r(m, { deleted: A });\n }, f = (m, A = !0, w = M.LOCAL) => {\n const C = m.map(gt);\n if (A) {\n const O = [...t.values()];\n t.clear(), e.clear(), C.forEach((B) => {\n t.set(B.id, B), B.bodies.forEach((D) => e.set(D.id, B.id));\n }), r(w, { created: C, deleted: O });\n } else {\n const O = m.reduce((B, D) => {\n const k = D.id && t.get(D.id);\n return k ? [...B, k] : B;\n }, []);\n if (O.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${O.map((B) => B.id).join(\", \")}`);\n C.forEach((B) => {\n t.set(B.id, B), B.bodies.forEach((D) => e.set(D.id, B.id));\n }), r(w, { created: C });\n }\n }, S = (m) => {\n const A = typeof m == \"string\" ? m : m.id, w = t.get(A);\n if (w)\n return t.delete(A), w.bodies.forEach((C) => e.delete(C.id)), w;\n console.warn(`Attempt to delete missing annotation: ${A}`);\n }, y = (m, A = M.LOCAL) => {\n const w = S(m);\n w && r(A, { deleted: [w] });\n }, b = (m, A = M.LOCAL) => {\n const w = m.reduce((C, O) => {\n const B = S(O);\n return B ? [...C, B] : C;\n }, []);\n w.length > 0 && r(A, { deleted: w });\n }, l = (m) => {\n const A = t.get(m.annotation);\n if (A) {\n const w = A.bodies.find((C) => C.id === m.id);\n if (w) {\n e.delete(w.id);\n const C = {\n ...A,\n bodies: A.bodies.filter((O) => O.id !== m.id)\n };\n return t.set(A.id, C), {\n oldValue: A,\n newValue: C,\n bodiesDeleted: [w]\n };\n } else\n console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);\n }, s = (m, A = M.LOCAL) => {\n const w = l(m);\n w && r(A, { updated: [w] });\n }, p = (m, A = M.LOCAL) => {\n const w = m.map((C) => l(C)).filter(Boolean);\n w.length > 0 && r(A, { updated: w });\n }, x = (m) => {\n const A = t.get(m);\n return A ? { ...A } : void 0;\n }, L = (m) => {\n const A = e.get(m);\n if (A) {\n const w = x(A).bodies.find((C) => C.id === m);\n if (w)\n return w;\n console.error(`Store integrity error: body ${m} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${m}`);\n }, E = (m, A) => {\n if (m.annotation !== A.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const w = t.get(m.annotation);\n if (w) {\n const C = w.bodies.find((B) => B.id === m.id), O = {\n ...w,\n bodies: w.bodies.map((B) => B.id === C.id ? A : B)\n };\n return t.set(w.id, O), C.id !== A.id && (e.delete(C.id), e.set(A.id, O.id)), {\n oldValue: w,\n newValue: O,\n bodiesUpdated: [{ oldBody: C, newBody: A }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${m.annotation}`);\n }, T = (m, A, w = M.LOCAL) => {\n const C = E(m, A);\n C && r(w, { updated: [C] });\n }, R = (m, A = M.LOCAL) => {\n const w = m.map((C) => E({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);\n r(A, { updated: w });\n }, I = (m) => {\n const A = t.get(m.annotation);\n if (A) {\n const w = {\n ...A,\n target: {\n ...A.target,\n ...m\n }\n };\n return t.set(A.id, w), {\n oldValue: A,\n newValue: w,\n targetUpdated: {\n oldTarget: A.target,\n newTarget: m\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${m.annotation}`);\n };\n return {\n addAnnotation: c,\n addBody: g,\n all: h,\n bulkAddAnnotation: f,\n bulkDeleteAnnotation: b,\n bulkDeleteBodies: p,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: R,\n bulkUpdateTargets: (m, A = M.LOCAL) => {\n const w = m.map((C) => I(C)).filter(Boolean);\n w.length > 0 && r(A, { updated: w });\n },\n clear: v,\n deleteAnnotation: y,\n deleteBody: s,\n getAnnotation: x,\n getBody: L,\n observe: o,\n unobserve: i,\n updateAnnotation: d,\n updateBody: T,\n updateTarget: (m, A = M.LOCAL) => {\n const w = I(m);\n w && r(A, { updated: [w] });\n }\n };\n};\nlet Ke = () => ({\n emit(t, ...e) {\n for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)\n o[n](...e);\n },\n events: {},\n on(t, e) {\n var n;\n return ((n = this.events)[t] || (n[t] = [])).push(e), () => {\n var o;\n this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((i) => e !== i);\n };\n }\n});\nconst Qe = 250, Je = (t) => {\n const e = Ke(), n = [];\n let o = -1, i = !1, r = 0;\n const c = (f) => {\n if (!i) {\n const { changes: S } = f, y = performance.now();\n if (y - r > Qe)\n n.splice(o + 1), n.push(S), o = n.length - 1;\n else {\n const b = n.length - 1;\n n[b] = We(n[b], S);\n }\n r = y;\n }\n i = !1;\n };\n t.observe(c, { origin: M.LOCAL });\n const a = (f) => f && f.length > 0 && t.bulkDeleteAnnotation(f), d = (f) => f && f.length > 0 && t.bulkAddAnnotation(f, !1), u = (f) => f && f.length > 0 && t.bulkUpdateAnnotation(f.map(({ oldValue: S }) => S)), g = (f) => f && f.length > 0 && t.bulkUpdateAnnotation(f.map(({ newValue: S }) => S)), h = (f) => f && f.length > 0 && t.bulkAddAnnotation(f, !1), v = (f) => f && f.length > 0 && t.bulkDeleteAnnotation(f);\n return {\n canRedo: () => n.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => t.unobserve(c),\n on: (f, S) => e.on(f, S),\n redo: () => {\n if (n.length - 1 > o) {\n i = !0;\n const { created: f, updated: S, deleted: y } = n[o + 1];\n d(f), g(S), v(y), e.emit(\"redo\", n[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: f, updated: S, deleted: y } = n[o];\n a(f), u(S), h(y), e.emit(\"undo\", n[o]), o -= 1;\n }\n }\n };\n}, Ze = () => {\n const { subscribe: t, set: e } = At([]);\n return {\n subscribe: t,\n set: e\n };\n}, tn = (t, e, n, o) => {\n const { store: i, selection: r, hover: c, viewport: a } = t, d = /* @__PURE__ */ new Map();\n let u = [], g;\n const h = (y, b) => {\n d.has(y) ? d.get(y).push(b) : d.set(y, [b]);\n }, v = (y, b) => {\n const l = d.get(y);\n if (l) {\n const s = l.indexOf(b);\n s !== -1 && l.splice(s, 1);\n }\n }, f = (y, b, l) => {\n d.has(y) && setTimeout(() => {\n d.get(y).forEach((s) => {\n if (n) {\n const p = Array.isArray(b) ? b.map((L) => n.serialize(L)) : n.serialize(b), x = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;\n s(p, x);\n } else\n s(b, l);\n });\n }, 1);\n };\n r.subscribe(({ selected: y }) => {\n if (!(u.length === 0 && y.length === 0)) {\n if (u.length === 0 && y.length > 0)\n u = y.map(({ id: b }) => i.getAnnotation(b));\n else if (u.length > 0 && y.length === 0)\n u.forEach((b) => {\n const l = i.getAnnotation(b.id);\n l && !z(l, b) && f(\"updateAnnotation\", l, b);\n }), u = [];\n else {\n const b = new Set(u.map((s) => s.id)), l = new Set(y.map(({ id: s }) => s));\n u.filter((s) => !l.has(s.id)).forEach((s) => {\n const p = i.getAnnotation(s.id);\n p && !z(p, s) && f(\"updateAnnotation\", p, s);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((s) => l.has(s.id)),\n // Add editable annotations that were selected\n ...y.filter(({ id: s }) => !b.has(s)).map(({ id: s }) => i.getAnnotation(s))\n ];\n }\n f(\"selectionChanged\", u);\n }\n }), c.subscribe((y) => {\n !g && y ? f(\"mouseEnterAnnotation\", i.getAnnotation(y)) : g && !y ? f(\"mouseLeaveAnnotation\", i.getAnnotation(g)) : g && y && (f(\"mouseLeaveAnnotation\", i.getAnnotation(g)), f(\"mouseEnterAnnotation\", i.getAnnotation(y))), g = y;\n }), a == null || a.subscribe((y) => f(\"viewportIntersect\", y.map((b) => i.getAnnotation(b)))), i.observe((y) => {\n const { created: b, deleted: l } = y.changes;\n (b || []).forEach((s) => f(\"createAnnotation\", s)), (l || []).forEach((s) => f(\"deleteAnnotation\", s)), (y.changes.updated || []).filter((s) => [\n ...s.bodiesCreated || [],\n ...s.bodiesDeleted || [],\n ...s.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: s, newValue: p }) => {\n const x = u.find((L) => L.id === s.id) || s;\n u = u.map((L) => L.id === s.id ? p : L), f(\"updateAnnotation\", p, x);\n });\n }, { origin: M.LOCAL }), i.observe((y) => {\n if (u) {\n const b = new Set(u.map((s) => s.id)), l = (y.changes.updated || []).filter(({ newValue: s }) => b.has(s.id)).map(({ newValue: s }) => s);\n l.length > 0 && (u = u.map((s) => l.find((x) => x.id === s.id) || s));\n }\n }, { origin: M.REMOTE });\n const S = (y) => (b) => {\n const { updated: l } = b;\n y ? (l || []).forEach((s) => f(\"updateAnnotation\", s.oldValue, s.newValue)) : (l || []).forEach((s) => f(\"updateAnnotation\", s.newValue, s.oldValue));\n };\n return e.on(\"undo\", S(!0)), e.on(\"redo\", S(!1)), { on: h, off: v, emit: f };\n}, en = (t) => (e) => e.reduce((n, o) => {\n const { parsed: i, error: r } = t.parse(o);\n return r ? {\n parsed: n.parsed,\n failed: [...n.failed, o]\n } : i ? {\n parsed: [...n.parsed, i],\n failed: n.failed\n } : {\n ...n\n };\n}, { parsed: [], failed: [] }), nn = (t, e, n) => {\n const { store: o, selection: i } = t, r = (l) => {\n if (n) {\n const { parsed: s, error: p } = n.parse(l);\n s ? o.addAnnotation(s, M.REMOTE) : console.error(p);\n } else\n o.addAnnotation(ft(l), M.REMOTE);\n }, c = () => i.clear(), a = () => o.clear(), d = (l) => {\n const s = o.getAnnotation(l);\n return n && s ? n.serialize(s) : s;\n }, u = () => n ? o.all().map(n.serialize) : o.all(), g = () => {\n var l;\n const s = (((l = i.selected) == null ? void 0 : l.map((p) => p.id)) || []).map((p) => o.getAnnotation(p)).filter(Boolean);\n return n ? s.map(n.serialize) : s;\n }, h = (l, s = !0) => fetch(l).then((p) => p.json()).then((p) => (f(p, s), p)), v = (l) => {\n if (typeof l == \"string\") {\n const s = o.getAnnotation(l);\n if (o.deleteAnnotation(l), s)\n return n ? n.serialize(s) : s;\n } else {\n const s = n ? n.parse(l).parsed : l;\n if (s)\n return o.deleteAnnotation(s), l;\n }\n }, f = (l, s = !0) => {\n if (n) {\n const p = n.parseAll || en(n), { parsed: x, failed: L } = p(l);\n L.length > 0 && console.warn(`Discarded ${L.length} invalid annotations`, L), o.bulkAddAnnotation(x, s, M.REMOTE);\n } else\n o.bulkAddAnnotation(l.map(ft), s, M.REMOTE);\n }, S = (l, s) => {\n l ? i.setSelected(l, s) : i.clear();\n }, y = (l) => {\n i.clear(), i.setUserSelectAction(l);\n }, b = (l) => {\n if (n) {\n const s = n.parse(l).parsed, p = n.serialize(o.getAnnotation(s.id));\n return o.updateAnnotation(s), p;\n } else {\n const s = o.getAnnotation(l.id);\n return o.updateAnnotation(ft(l)), s;\n }\n };\n return {\n addAnnotation: r,\n cancelSelected: c,\n canRedo: e.canRedo,\n canUndo: e.canUndo,\n clearAnnotations: a,\n getAnnotationById: d,\n getAnnotations: u,\n getSelected: g,\n loadAnnotations: h,\n redo: e.redo,\n removeAnnotation: v,\n setAnnotations: f,\n setSelected: S,\n setUserSelectAction: y,\n undo: e.undo,\n updateAnnotation: b\n };\n}, on = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nlet rn = (t) => crypto.getRandomValues(new Uint8Array(t)), sn = (t, e, n) => {\n let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);\n return (r = e) => {\n let c = \"\";\n for (; ; ) {\n let a = n(i), d = i;\n for (; d--; )\n if (c += t[a[d] & o] || \"\", c.length === r) return c;\n }\n };\n}, an = (t, e = 21) => sn(t, e, rn), cn = (t = 21) => {\n let e = \"\", n = crypto.getRandomValues(new Uint8Array(t));\n for (; t--; )\n e += on[n[t] & 63];\n return e;\n};\nconst ln = () => ({ isGuest: !0, id: an(\"1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_\", 20)() }), dn = (t) => {\n const e = JSON.stringify(t);\n let n = 0;\n for (let o = 0, i = e.length; o < i; o++) {\n let r = e.charCodeAt(o);\n n = (n << 5) - n + r, n |= 0;\n }\n return `${n}`;\n}, Ft = (t) => t ? typeof t == \"object\" ? { ...t } : t : void 0, un = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {\n const { id: o, type: i, purpose: r, value: c, created: a, modified: d, creator: u, ...g } = n;\n return {\n id: o || `temp-${dn(n)}`,\n annotation: e,\n type: i,\n purpose: r,\n value: c,\n creator: Ft(u),\n created: a ? new Date(a) : void 0,\n updated: d ? new Date(d) : void 0,\n ...g\n };\n}), hn = (t) => t.map((e) => {\n var n;\n const { annotation: o, created: i, updated: r, ...c } = e, a = {\n ...c,\n created: i == null ? void 0 : i.toISOString(),\n modified: r == null ? void 0 : r.toISOString()\n };\n return (n = a.id) != null && n.startsWith(\"temp-\") && delete a.id, a;\n});\ncn();\nconst In = (t, e) => ({\n parse: (n) => pn(n),\n serialize: (n) => mn(n, t, e)\n}), fn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, gn = (t) => {\n const {\n id: e,\n creator: n,\n created: o,\n modified: i,\n target: r\n } = t, c = Array.isArray(r) ? r : [r], a = {\n creator: Ft(n),\n created: o ? new Date(o) : void 0,\n updated: i ? new Date(i) : void 0,\n annotation: e,\n selector: []\n };\n for (const d of c) {\n const g = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((h, v) => {\n switch (v.type) {\n case \"TextQuoteSelector\":\n h.quote = v.exact;\n break;\n case \"TextPositionSelector\":\n h.start = v.start, h.end = v.end;\n break;\n }\n return h;\n }, {});\n if (fn(g))\n a.selector.push({ id: d.id, ...g });\n else {\n const h = [\n g.start ? void 0 : \"TextPositionSelector\",\n g.quote ? void 0 : \"TextQuoteSelector\"\n ].filter(Boolean);\n return { error: Error(`Missing selector types: ${h.join(\" and \")} for annotation: ${t.id}`) };\n }\n }\n return { parsed: a };\n}, pn = (t) => {\n const e = t.id || Pt(), {\n creator: n,\n created: o,\n modified: i,\n body: r,\n ...c\n } = t, a = un(r, e), d = gn(t);\n return \"error\" in d ? { error: d.error } : {\n parsed: {\n ...c,\n id: e,\n bodies: a,\n target: d.parsed\n }\n };\n}, mn = (t, e, n) => {\n const { bodies: o, target: i, ...r } = t, {\n selector: c,\n creator: a,\n created: d,\n updated: u,\n ...g\n } = i, h = c.map((v) => {\n const { quote: f, start: S, end: y, range: b } = v, { prefix: l, suffix: s } = ee(b, n), p = [{\n type: \"TextQuoteSelector\",\n exact: f,\n prefix: l,\n suffix: s\n }, {\n type: \"TextPositionSelector\",\n start: S,\n end: y\n }];\n return {\n ...g,\n id: v.id,\n source: e,\n selector: p\n };\n });\n return {\n ...r,\n \"@context\": \"http://www.w3.org/ns/anno.jsonld\",\n id: t.id,\n type: \"Annotation\",\n body: hn(t.bodies),\n creator: a,\n created: d == null ? void 0 : d.toISOString(),\n modified: u == null ? void 0 : u.toISOString(),\n target: h\n };\n};\nfunction Wt(t, e, n = 0, o = t.length - 1, i = bn) {\n for (; o > n; ) {\n if (o - n > 600) {\n const d = o - n + 1, u = e - n + 1, g = Math.log(d), h = 0.5 * Math.exp(2 * g / 3), v = 0.5 * Math.sqrt(g * h * (d - h) / d) * (u - d / 2 < 0 ? -1 : 1), f = Math.max(n, Math.floor(e - u * h / d + v)), S = Math.min(o, Math.floor(e + (d - u) * h / d + v));\n Wt(t, e, f, S, i);\n }\n const r = t[e];\n let c = n, a = o;\n for (q(t, n, e), i(t[o], r) > 0 && q(t, n, o); c < a; ) {\n for (q(t, c, a), c++, a--; i(t[c], r) < 0; ) c++;\n for (; i(t[a], r) > 0; ) a--;\n }\n i(t[n], r) === 0 ? q(t, n, a) : (a++, q(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);\n }\n}\nfunction q(t, e, n) {\n const o = t[e];\n t[e] = t[n], t[n] = o;\n}\nfunction bn(t, e) {\n return t < e ? -1 : t > e ? 1 : 0;\n}\nclass vn {\n constructor(e = 9) {\n this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();\n }\n all() {\n return this._all(this.data, []);\n }\n search(e) {\n let n = this.data;\n const o = [];\n if (!ot(e, n)) return o;\n const i = this.toBBox, r = [];\n for (; n; ) {\n for (let c = 0; c < n.children.length; c++) {\n const a = n.children[c], d = n.leaf ? i(a) : a;\n ot(e, d) && (n.leaf ? o.push(a) : mt(e, d) ? this._all(a, o) : r.push(a));\n }\n n = r.pop();\n }\n return o;\n }\n collides(e) {\n let n = this.data;\n if (!ot(e, n)) return !1;\n const o = [];\n for (; n; ) {\n for (let i = 0; i < n.children.length; i++) {\n const r = n.children[i], c = n.leaf ? this.toBBox(r) : r;\n if (ot(e, c)) {\n if (n.leaf || mt(e, c)) return !0;\n o.push(r);\n }\n }\n n = o.pop();\n }\n return !1;\n }\n load(e) {\n if (!(e && e.length)) return this;\n if (e.length < this._minEntries) {\n for (let o = 0; o < e.length; o++)\n this.insert(e[o]);\n return this;\n }\n let n = this._build(e.slice(), 0, e.length - 1, 0);\n if (!this.data.children.length)\n this.data = n;\n else if (this.data.height === n.height)\n this._splitRoot(this.data, n);\n else {\n if (this.data.height < n.height) {\n const o = this.data;\n this.data = n, n = o;\n }\n this._insert(n, this.data.height - n.height - 1, !0);\n }\n return this;\n }\n insert(e) {\n return e && this._insert(e, this.data.height - 1), this;\n }\n clear() {\n return this.data = W([]), this;\n }\n remove(e, n) {\n if (!e) return this;\n let o = this.data;\n const i = this.toBBox(e), r = [], c = [];\n let a, d, u;\n for (; o || r.length; ) {\n if (o || (o = r.pop(), d = r[r.length - 1], a = c.pop(), u = !0), o.leaf) {\n const g = yn(e, o.children, n);\n if (g !== -1)\n return o.children.splice(g, 1), r.push(o), this._condense(r), this;\n }\n !u && !o.leaf && mt(o, i) ? (r.push(o), c.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], u = !1) : o = null;\n }\n return this;\n }\n toBBox(e) {\n return e;\n }\n compareMinX(e, n) {\n return e.minX - n.minX;\n }\n compareMinY(e, n) {\n return e.minY - n.minY;\n }\n toJSON() {\n return this.data;\n }\n fromJSON(e) {\n return this.data = e, this;\n }\n _all(e, n) {\n const o = [];\n for (; e; )\n e.leaf ? n.push(...e.children) : o.push(...e.children), e = o.pop();\n return n;\n }\n _build(e, n, o, i) {\n const r = o - n + 1;\n let c = this._maxEntries, a;\n if (r <= c)\n return a = W(e.slice(n, o + 1)), F(a, this.toBBox), a;\n i || (i = Math.ceil(Math.log(r) / Math.log(c)), c = Math.ceil(r / Math.pow(c, i - 1))), a = W([]), a.leaf = !1, a.height = i;\n const d = Math.ceil(r / c), u = d * Math.ceil(Math.sqrt(c));\n Vt(e, n, o, u, this.compareMinX);\n for (let g = n; g <= o; g += u) {\n const h = Math.min(g + u - 1, o);\n Vt(e, g, h, d, this.compareMinY);\n for (let v = g; v <= h; v += d) {\n const f = Math.min(v + d - 1, h);\n a.children.push(this._build(e, v, f, i - 1));\n }\n }\n return F(a, this.toBBox), a;\n }\n _chooseSubtree(e, n, o, i) {\n for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {\n let r = 1 / 0, c = 1 / 0, a;\n for (let d = 0; d < n.children.length; d++) {\n const u = n.children[d], g = pt(u), h = xn(e, u) - g;\n h < c ? (c = h, r = g < r ? g : r, a = u) : h === c && g < r && (r = g, a = u);\n }\n n = a || n.children[0];\n }\n return n;\n }\n _insert(e, n, o) {\n const i = o ? e : this.toBBox(e), r = [], c = this._chooseSubtree(i, this.data, n, r);\n for (c.children.push(e), K(c, i); n >= 0 && r[n].children.length > this._maxEntries; )\n this._split(r, n), n--;\n this._adjustParentBBoxes(i, r, n);\n }\n // split overflowed node into two\n _split(e, n) {\n const o = e[n], i = o.children.length, r = this._minEntries;\n this._chooseSplitAxis(o, r, i);\n const c = this._chooseSplitIndex(o, r, i), a = W(o.children.splice(c, o.children.length - c));\n a.height = o.height, a.leaf = o.leaf, F(o, this.toBBox), F(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);\n }\n _splitRoot(e, n) {\n this.data = W([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, F(this.data, this.toBBox);\n }\n _chooseSplitIndex(e, n, o) {\n let i, r = 1 / 0, c = 1 / 0;\n for (let a = n; a <= o - n; a++) {\n const d = G(e, 0, a, this.toBBox), u = G(e, a, o, this.toBBox), g = Sn(d, u), h = pt(d) + pt(u);\n g < r ? (r = g, i = a, c = h < c ? h : c) : g === r && h < c && (c = h, i = a);\n }\n return i || o - n;\n }\n // sorts node children by the best axis for split\n _chooseSplitAxis(e, n, o) {\n const i = e.leaf ? this.compareMinX : wn, r = e.leaf ? this.compareMinY : An, c = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);\n c < a && e.children.sort(i);\n }\n // total margin of all possible split distributions where each node is at least m full\n _allDistMargin(e, n, o, i) {\n e.children.sort(i);\n const r = this.toBBox, c = G(e, 0, n, r), a = G(e, o - n, o, r);\n let d = nt(c) + nt(a);\n for (let u = n; u < o - n; u++) {\n const g = e.children[u];\n K(c, e.leaf ? r(g) : g), d += nt(c);\n }\n for (let u = o - n - 1; u >= n; u--) {\n const g = e.children[u];\n K(a, e.leaf ? r(g) : g), d += nt(a);\n }\n return d;\n }\n _adjustParentBBoxes(e, n, o) {\n for (let i = o; i >= 0; i--)\n K(n[i], e);\n }\n _condense(e) {\n for (let n = e.length - 1, o; n >= 0; n--)\n 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);\n }\n}\nfunction yn(t, e, n) {\n if (!n) return e.indexOf(t);\n for (let o = 0; o < e.length; o++)\n if (n(t, e[o])) return o;\n return -1;\n}\nfunction F(t, e) {\n G(t, 0, t.children.length, e, t);\n}\nfunction G(t, e, n, o, i) {\n i || (i = W(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;\n for (let r = e; r < n; r++) {\n const c = t.children[r];\n K(i, t.leaf ? o(c) : c);\n }\n return i;\n}\nfunction K(t, e) {\n 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;\n}\nfunction wn(t, e) {\n return t.minX - e.minX;\n}\nfunction An(t, e) {\n return t.minY - e.minY;\n}\nfunction pt(t) {\n return (t.maxX - t.minX) * (t.maxY - t.minY);\n}\nfunction nt(t) {\n return t.maxX - t.minX + (t.maxY - t.minY);\n}\nfunction xn(t, e) {\n 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));\n}\nfunction Sn(t, e) {\n 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);\n return Math.max(0, i - n) * Math.max(0, r - o);\n}\nfunction mt(t, e) {\n return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;\n}\nfunction ot(t, e) {\n return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;\n}\nfunction W(t) {\n return {\n children: t,\n height: 1,\n leaf: !0,\n minX: 1 / 0,\n minY: 1 / 0,\n maxX: -1 / 0,\n maxY: -1 / 0\n };\n}\nfunction Vt(t, e, n, o, i) {\n const r = [e, n];\n for (; r.length; ) {\n if (n = r.pop(), e = r.pop(), n - e <= o) continue;\n const c = e + Math.ceil((n - e) / o / 2) * o;\n Wt(t, c, e, n, i), r.push(e, c, c, n);\n }\n}\nconst En = (t, e) => {\n const n = new vn(), o = /* @__PURE__ */ new Map(), i = (l, s) => {\n const p = l.selector.flatMap((L) => {\n const E = H([L]) ? L.range : _t(L, e).range;\n return Array.from(E.getClientRects());\n }), x = se(p).map(({ left: L, top: E, right: T, bottom: R }) => new DOMRect(L - s.left, E - s.top, T - L, R - E));\n return x.map((L) => {\n const { x: E, y: T, width: R, height: I } = L;\n return {\n minX: E,\n minY: T,\n maxX: E + R,\n maxY: T + I,\n annotation: {\n id: l.annotation,\n rects: x\n }\n };\n });\n }, r = () => [...o.values()], c = () => {\n n.clear(), o.clear();\n }, a = (l) => {\n const s = i(l, e.getBoundingClientRect());\n s.forEach((p) => n.insert(p)), o.set(l.annotation, s);\n }, d = (l) => {\n const s = o.get(l.annotation);\n s && (s.forEach((p) => n.remove(p)), o.delete(l.annotation));\n }, u = (l) => {\n d(l), a(l);\n }, g = (l, s = !0) => {\n s && c();\n const p = e.getBoundingClientRect(), x = l.map((E) => ({ target: E, rects: i(E, p) }));\n x.forEach(({ target: E, rects: T }) => o.set(E.annotation, T));\n const L = x.flatMap(({ rects: E }) => E);\n n.load(L);\n }, h = (l, s, p = !1) => {\n const x = n.search({\n minX: l,\n minY: s,\n maxX: l,\n maxY: s\n }), L = (E) => E.annotation.rects.reduce((T, R) => T + R.width * R.height, 0);\n return x.length > 0 ? (x.sort((E, T) => L(E) - L(T)), p ? x.map((E) => E.annotation.id) : [x[0].annotation.id]) : [];\n }, v = (l) => {\n const s = f(l);\n if (s.length === 0)\n return;\n let p = s[0].left, x = s[0].top, L = s[0].right, E = s[0].bottom;\n for (let T = 1; T < s.length; T++) {\n const R = s[T];\n p = Math.min(p, R.left), x = Math.min(x, R.top), L = Math.max(L, R.right), E = Math.max(E, R.bottom);\n }\n return new DOMRect(p, x, L - p, E - x);\n }, f = (l) => {\n const s = o.get(l);\n return s ? s[0].annotation.rects : [];\n };\n return {\n all: r,\n clear: c,\n getAt: h,\n getAnnotationBounds: v,\n getAnnotationRects: f,\n getIntersecting: (l, s, p, x) => {\n const L = n.search({ minX: l, minY: s, maxX: p, maxY: x }), E = new Set(L.map((T) => T.annotation.id));\n return Array.from(E).map((T) => ({\n annotation: t.getAnnotation(T),\n rects: f(T)\n })).filter((T) => !!T.annotation);\n },\n insert: a,\n recalculate: () => g(t.all().map((l) => l.target), !0),\n remove: d,\n set: g,\n size: () => n.all().length,\n update: u\n };\n}, Cn = (t, e) => {\n const n = Ge(), o = En(n, t), i = ke(n);\n i.setUserSelectAction(e);\n const r = Ve(n), c = Ze(), a = (b, l = M.LOCAL) => {\n const s = st(b, t), p = H(s.target.selector);\n return p && n.addAnnotation(s, l), p;\n }, d = (b, l = !0, s = M.LOCAL) => {\n const p = b.map((L) => st(L, t)), x = p.filter((L) => !H(L.target.selector));\n return x.length > 0 ? (console.warn(\"Could not revive all targets for these annotations:\", x), n.bulkAddAnnotation(p, l, s), x) : (n.bulkAddAnnotation(p, l, s), []);\n }, u = (b, l = M.LOCAL) => {\n const s = b.map((x) => st(x, t)), p = s.filter((x) => !H(x.target.selector));\n return p.length > 0 && console.warn(\"Could not revive all targets for these annotations:\", p), s.forEach((x) => {\n n.getAnnotation(x.id) ? n.updateAnnotation(x, l) : n.addAnnotation(x, l);\n }), p;\n }, g = (b, l = M.LOCAL) => {\n const s = it(b, t);\n n.updateTarget(s, l);\n }, h = (b, l = M.LOCAL) => {\n const s = b.map((p) => it(p, t));\n n.bulkUpdateTargets(s, l);\n }, v = (b, l, s) => {\n const p = o.getAt(b, l, !!s).map((L) => n.getAnnotation(L)), x = s ? p.filter(s) : p;\n return x.length > 0 ? x[0] : void 0;\n }, f = (b, l, s, p = 5) => {\n const x = o.getAnnotationRects(b);\n if (x.length !== 0) {\n if (l && s) {\n const L = x.find(({ top: E, right: T, bottom: R, left: I }) => l >= I - p && l <= T + p && s >= E - p && s <= R + p);\n if (L) return L;\n }\n return o.getAnnotationBounds(b);\n }\n }, S = (b) => o.getAnnotationRects(b), y = () => o.recalculate();\n return n.observe(({ changes: b }) => {\n const l = (b.deleted || []).filter((x) => H(x.target.selector)), s = (b.created || []).filter((x) => H(x.target.selector)), p = (b.updated || []).filter((x) => H(x.newValue.target.selector));\n (l == null ? void 0 : l.length) > 0 && l.forEach((x) => o.remove(x.target)), s.length > 0 && o.set(s.map((x) => x.target), !1), (p == null ? void 0 : p.length) > 0 && p.forEach(({ newValue: x }) => o.update(x.target));\n }), {\n store: {\n ...n,\n addAnnotation: a,\n bulkAddAnnotation: d,\n bulkUpdateTargets: h,\n bulkUpsertAnnotations: u,\n getAnnotationBounds: f,\n getAnnotationRects: S,\n getAt: v,\n getIntersecting: o.getIntersecting,\n recalculatePositions: y,\n updateTarget: g\n },\n selection: i,\n hover: r,\n viewport: c\n };\n}, Ln = () => {\n const t = document.createElement(\"canvas\");\n t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = \"r6o-presence-layer\";\n const e = t.getContext(\"2d\");\n return e.scale(2, 2), e.translate(0.5, 0.5), t;\n}, Tn = (t, e = {}) => {\n const n = Ln(), o = n.getContext(\"2d\");\n document.body.appendChild(n);\n const i = /* @__PURE__ */ new Map(), r = (g) => Array.from(i.entries()).filter(([h, v]) => v.presenceKey === g.presenceKey).map(([h, v]) => h);\n return t.on(\"selectionChange\", (g, h) => {\n r(g).forEach((f) => i.delete(f)), h && h.forEach((f) => i.set(f, g));\n }), {\n clear: () => {\n const { width: g, height: h } = n;\n o.clearRect(-0.5, -0.5, g + 1, h + 1);\n },\n destroy: () => {\n n.remove();\n },\n paint: (g, h, v) => {\n e.font && (o.font = e.font);\n const f = i.get(g.annotation.id);\n if (f) {\n const { height: S } = g.rects[0], y = g.rects[0].x + h.left, b = g.rects[0].y + h.top;\n o.fillStyle = f.appearance.color, o.fillRect(y - 2, b - 2.5, 2, S + 5);\n const l = o.measureText(f.appearance.label), s = l.width + 6, p = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, x = l.fontBoundingBoxAscent ? 8 : 6.5;\n return o.fillRect(y - 2, b - 2.5 - p, s, p), o.fillStyle = \"#fff\", o.fillText(f.appearance.label, y + 1, b - x), {\n fill: f.appearance.color,\n fillOpacity: v ? 0.45 : 0.18\n };\n }\n },\n reset: () => {\n n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;\n const g = n.getContext(\"2d\");\n g.scale(2, 2), g.translate(0.5, 0.5);\n }\n };\n}, Rn = (t, e, n, o) => {\n let i;\n const r = (s) => i = s;\n let c;\n const a = (s) => c = s, { store: d, selection: u } = e;\n let g, h = !1, v;\n const f = (s) => {\n var x;\n if (!h) return;\n !((x = s.target.parentElement) != null && x.closest(X)) ? g = {\n annotation: Pt(),\n selector: [],\n creator: i,\n created: /* @__PURE__ */ new Date()\n } : g = void 0;\n }, S = yt((s) => {\n var m, A;\n const p = document.getSelection();\n if (!!((A = (m = p.anchorNode) == null ? void 0 : m.parentElement) != null && A.closest(X))) {\n g = void 0;\n return;\n }\n if (s.timeStamp - ((v == null ? void 0 : v.timeStamp) || s.timeStamp) < 1e3 && !g && f(v), p.isCollapsed || !h || !g) return;\n const E = p.getRangeAt(0), T = ce(E, t);\n if (oe(T)) return;\n const R = Zt(T.cloneRange());\n (R.length !== g.selector.length || R.some((w, C) => {\n var O;\n return w.toString() !== ((O = g.selector[C]) == null ? void 0 : O.quote);\n })) && (g = {\n ...g,\n selector: R.map((w) => ae(w, t, o)),\n updated: /* @__PURE__ */ new Date()\n }, d.getAnnotation(g.annotation) ? d.updateTarget(g, M.LOCAL) : (u.clear(), d.addAnnotation({\n id: g.annotation,\n bodies: [],\n target: g\n }), u.userSelect(g.annotation, v)));\n }), y = (s) => {\n const { target: p, timeStamp: x, offsetX: L, offsetY: E, type: T } = s;\n v = { ...s, target: p, timeStamp: x, offsetX: L, offsetY: E, type: T }, h = s.button === 0;\n }, b = (s) => {\n var E;\n if (!!((E = s.target.parentElement) != null && E.closest(X)) || !h)\n return;\n const x = () => {\n const { x: T, y: R } = t.getBoundingClientRect(), I = s.target instanceof Node && t.contains(s.target) && d.getAt(s.clientX - T, s.clientY - R, c);\n if (I) {\n const { selected: m } = u;\n (m.length !== 1 || m[0].id !== I.id) && u.userSelect(I.id, s);\n } else u.isEmpty() || u.clear();\n }, L = s.timeStamp - v.timeStamp;\n setTimeout(() => {\n const T = document.getSelection();\n T != null && T.isCollapsed && L < 300 ? (g = void 0, x()) : g && u.userSelect(g.annotation, s);\n });\n };\n return t.addEventListener(\"pointerdown\", y), document.addEventListener(\"pointerup\", b), n && (t.addEventListener(\"selectstart\", f), document.addEventListener(\"selectionchange\", S)), {\n destroy: () => {\n t.removeEventListener(\"pointerdown\", y), document.removeEventListener(\"pointerup\", b), t.removeEventListener(\"selectstart\", f), document.removeEventListener(\"selectionchange\", S);\n },\n setFilter: a,\n setUser: r\n };\n}, Bn = (t, e) => ({\n ...t,\n annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,\n user: t.user || e.user\n}), Dt = \"SPANS\", Nn = (t, e = {}) => {\n te(t);\n const n = Bn(e, {\n annotatingEnabled: !0,\n user: ln()\n }), o = Cn(t, n.userSelectAction), { selection: i, viewport: r } = o, c = o.store, a = Je(c), d = tn(o, a, n.adapter);\n let u = n.user;\n const g = n.renderer === \"CSS_HIGHLIGHTS\" ? CSS.highlights ? \"CSS_HIGHLIGHTS\" : Dt : n.renderer || Dt, h = g === \"SPANS\" ? Be(t, o, r) : g === \"CSS_HIGHLIGHTS\" ? Le(t, o, r) : g === \"CANVAS\" ? me(t, o, r) : void 0;\n if (!h)\n throw `Unknown renderer implementation: ${g}`;\n console.debug(`Using ${g} renderer`), n.style && h.setStyle(n.style);\n const v = Rn(t, o, n.annotatingEnabled, n.offsetReferenceSelector);\n return v.setUser(u), {\n ...nn(o, a, n.adapter),\n destroy: () => {\n h.destroy(), v.destroy(), a.destroy();\n },\n element: t,\n getUser: () => u,\n setFilter: (E) => {\n h.setFilter(E), v.setFilter(E);\n },\n setStyle: (E) => h.setStyle(E),\n setUser: (E) => {\n u = E, v.setUser(E);\n },\n setSelected: (E) => {\n E ? i.setSelected(E) : i.clear();\n },\n setPresenceProvider: (E) => {\n E && (h.setPainter(Tn(E, n.presence)), E.on(\"selectionChange\", () => h.redraw()));\n },\n setVisible: (E) => h.setVisible(E),\n on: d.on,\n off: d.off,\n scrollIntoView: le(t, c),\n state: o\n };\n};\nexport {\n rt as DEFAULT_SELECTED_STYLE,\n P as DEFAULT_STYLE,\n kt as NOT_ANNOTATABLE_CLASS,\n X as NOT_ANNOTATABLE_SELECTOR,\n M as Origin,\n Rn as SelectionHandler,\n De as UserSelectAction,\n In as W3CTextFormat,\n te as cancelSingleClickEvents,\n On as createBody,\n me as createCanvasRenderer,\n Le as createHighlightsRenderer,\n Tn as createPresencePainter,\n Ce as createRenderer,\n Be as createSpansRenderer,\n Nn as createTextAnnotator,\n Cn as createTextAnnotatorState,\n yt as debounce,\n Bn as fillDefaults,\n Mn as getAnnotatableFragment,\n ee as getQuoteContext,\n bt as getRangeAnnotatableContents,\n H as isRevived,\n oe as isWhitespaceOrEmpty,\n se as mergeClientRects,\n de as paint,\n pn as parseW3CTextAnnotation,\n ae as rangeToSelector,\n st as reviveAnnotation,\n _t as reviveSelector,\n it as reviveTarget,\n le as scrollIntoView,\n mn as serializeW3CTextAnnotation,\n Zt as splitAnnotatableRanges,\n ce as trimRangeToContainer,\n ne as whitespaceOrEmptyRegex\n};\n//# sourceMappingURL=text-annotator.es.js.map\n"],"names":[],"mappings":"AAAK,MAAC,KAAK,mBAAmB,IAAI,IAAI,EAAE,IA0BrC,KAAK,CAAC,MAAM;AACb,QAAM,IAAI,EAAE;AACZ,SAAO,EAAE,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG;AAC3D,GAaG,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI,MAAM;AAC3B,QAAM,IAAoD,GA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|
{
|
|
2
2
|
"name": "@soomo/react-text-annotator",
|
|
3
|
-
"version": "3.0.0-staging.
|
|
3
|
+
"version": "3.0.0-staging.59",
|
|
4
4
|
"description": "Recogito Text Annotator React bindings",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
"react": "^18.3.1",
|
|
30
30
|
"react-dom": "^18.3.1",
|
|
31
31
|
"typescript": "5.5.4",
|
|
32
|
-
"vite": "^5.4.
|
|
32
|
+
"vite": "^5.4.3",
|
|
33
33
|
"vite-plugin-dts": "^4.1.0",
|
|
34
34
|
"vite-tsconfig-paths": "^5.0.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"openseadragon": "^3.0.0 || ^4.0.0",
|
|
37
|
+
"openseadragon": "^3.0.0 || ^4.0.0 || ^5.0.0",
|
|
38
38
|
"react": "16.8.0 || >=17.x || >=18.x",
|
|
39
39
|
"react-dom": "16.8.0 || >=17.x || >=18.x"
|
|
40
40
|
},
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@annotorious/core": "^3.0.
|
|
48
|
-
"@annotorious/react": "^3.0.
|
|
47
|
+
"@annotorious/core": "^3.0.5",
|
|
48
|
+
"@annotorious/react": "^3.0.5",
|
|
49
49
|
"@floating-ui/react": "^0.26.23",
|
|
50
|
-
"@soomo/text-annotator": "3.0.0-staging.
|
|
50
|
+
"@soomo/text-annotator": "3.0.0-staging.59",
|
|
51
51
|
"@react-aria/live-announcer": "^3.3.4",
|
|
52
|
-
"@recogito/text-annotator-tei": "3.0.0-rc.
|
|
52
|
+
"@recogito/text-annotator-tei": "3.0.0-rc.45",
|
|
53
53
|
"CETEIcean": "^1.9.3",
|
|
54
54
|
"unique-random": "^4.0.0"
|
|
55
55
|
}
|