@soomo/react-text-annotator 3.0.0-staging.59 → 3.0.0-staging.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/TextAnnotator.d.ts.map +1 -1
- package/dist/react-text-annotator.es10.js +5 -5
- package/dist/react-text-annotator.es11.js +1445 -61
- package/dist/react-text-annotator.es11.js.map +1 -1
- package/dist/react-text-annotator.es13.js +196 -1418
- package/dist/react-text-annotator.es13.js.map +1 -1
- package/dist/react-text-annotator.es14.js +588 -0
- package/dist/react-text-annotator.es14.js.map +1 -0
- package/dist/react-text-annotator.es15.js +57 -234
- package/dist/react-text-annotator.es15.js.map +1 -1
- package/dist/react-text-annotator.es16.js +33 -557
- package/dist/react-text-annotator.es16.js.map +1 -1
- package/dist/react-text-annotator.es18.js +1 -1
- package/dist/react-text-annotator.es19.js +1 -1
- package/dist/react-text-annotator.es20.js +2 -114
- package/dist/react-text-annotator.es20.js.map +1 -1
- package/dist/react-text-annotator.es21.js +2 -309
- package/dist/react-text-annotator.es21.js.map +1 -1
- package/dist/react-text-annotator.es22.js +109 -53
- package/dist/react-text-annotator.es22.js.map +1 -1
- package/dist/react-text-annotator.es23.js +306 -17
- package/dist/react-text-annotator.es23.js.map +1 -1
- package/dist/react-text-annotator.es24.js +58 -2
- package/dist/react-text-annotator.es24.js.map +1 -1
- package/dist/react-text-annotator.es25.js +20 -2
- package/dist/react-text-annotator.es25.js.map +1 -1
- package/dist/react-text-annotator.es27.js +13 -1
- package/dist/react-text-annotator.es27.js.map +1 -1
- package/dist/react-text-annotator.es30.js +8 -5
- package/dist/react-text-annotator.es30.js.map +1 -1
- package/dist/react-text-annotator.es4.js +2 -2
- package/dist/react-text-annotator.es5.js.map +1 -1
- package/dist/react-text-annotator.es6.js +3 -3
- package/dist/react-text-annotator.es7.js +51 -51
- package/dist/react-text-annotator.es7.js.map +1 -1
- package/package.json +9 -9
- package/dist/react-text-annotator.es12.js +0 -48
- package/dist/react-text-annotator.es12.js.map +0 -1
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
const
|
|
1
|
+
const _t = "not-annotatable", X = `.${_t}`, 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
|
-
const i = e,
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const d = bt(
|
|
5
|
+
const i = e, s = document.createRange();
|
|
6
|
+
s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
|
|
7
|
+
const r = bt(s).textContent, c = document.createRange();
|
|
8
|
+
c.setStart(t.endContainer, t.endOffset), i === document.body ? c.setEnd(i, i.childNodes.length) : c.setEndAfter(i);
|
|
9
|
+
const d = bt(c).textContent;
|
|
10
10
|
return {
|
|
11
|
-
prefix:
|
|
11
|
+
prefix: r.substring(r.length - n),
|
|
12
12
|
suffix: d.substring(0, n)
|
|
13
13
|
};
|
|
14
14
|
};
|
|
@@ -50,31 +50,31 @@ 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++) {
|
|
53
|
-
let
|
|
54
|
-
n = (n << 5) - n +
|
|
53
|
+
let s = e.charCodeAt(o);
|
|
54
|
+
n = (n << 5) - n + s, n |= 0;
|
|
55
55
|
}
|
|
56
56
|
return `${n}`;
|
|
57
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:
|
|
58
|
+
const { id: o, type: i, purpose: s, value: r, created: c, modified: d, creator: u, ...f } = n;
|
|
59
59
|
return {
|
|
60
60
|
id: o || `temp-${dn(n)}`,
|
|
61
61
|
annotation: e,
|
|
62
62
|
type: i,
|
|
63
|
-
purpose:
|
|
64
|
-
value:
|
|
63
|
+
purpose: s,
|
|
64
|
+
value: r,
|
|
65
65
|
creator: Ft(u),
|
|
66
|
-
created:
|
|
66
|
+
created: c ? new Date(c) : void 0,
|
|
67
67
|
updated: d ? new Date(d) : void 0,
|
|
68
|
-
...
|
|
68
|
+
...f
|
|
69
69
|
};
|
|
70
70
|
}), hn = (t) => t.map((e) => {
|
|
71
71
|
var n;
|
|
72
|
-
const { annotation: o, created: i, updated:
|
|
73
|
-
...
|
|
72
|
+
const { annotation: o, created: i, updated: s, ...r } = e, c = {
|
|
73
|
+
...r,
|
|
74
74
|
created: i == null ? void 0 : i.toISOString(),
|
|
75
|
-
modified:
|
|
75
|
+
modified: s == null ? void 0 : s.toISOString()
|
|
76
76
|
};
|
|
77
|
-
return (n =
|
|
77
|
+
return (n = c.id) != null && n.startsWith("temp-") && delete c.id, c;
|
|
78
78
|
});
|
|
79
79
|
cn();
|
|
80
80
|
const In = (t, e) => ({
|
|
@@ -86,92 +86,92 @@ const In = (t, e) => ({
|
|
|
86
86
|
creator: n,
|
|
87
87
|
created: o,
|
|
88
88
|
modified: i,
|
|
89
|
-
target:
|
|
90
|
-
} = t,
|
|
89
|
+
target: s
|
|
90
|
+
} = t, r = Array.isArray(s) ? s : [s], c = {
|
|
91
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 d of
|
|
98
|
-
const
|
|
99
|
-
switch (
|
|
97
|
+
for (const d of r) {
|
|
98
|
+
const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((h, y) => {
|
|
99
|
+
switch (y.type) {
|
|
100
100
|
case "TextQuoteSelector":
|
|
101
|
-
h.quote =
|
|
101
|
+
h.quote = y.exact;
|
|
102
102
|
break;
|
|
103
103
|
case "TextPositionSelector":
|
|
104
|
-
h.start =
|
|
104
|
+
h.start = y.start, h.end = y.end;
|
|
105
105
|
break;
|
|
106
106
|
}
|
|
107
107
|
return h;
|
|
108
108
|
}, {});
|
|
109
|
-
if (fn(
|
|
110
|
-
|
|
109
|
+
if (fn(f))
|
|
110
|
+
c.selector.push({ id: d.id, ...f });
|
|
111
111
|
else {
|
|
112
112
|
const h = [
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
f.start ? void 0 : "TextPositionSelector",
|
|
114
|
+
f.quote ? void 0 : "TextQuoteSelector"
|
|
115
115
|
].filter(Boolean);
|
|
116
116
|
return { error: Error(`Missing selector types: ${h.join(" and ")} for annotation: ${t.id}`) };
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
return { parsed:
|
|
119
|
+
return { parsed: c };
|
|
120
120
|
}, pn = (t) => {
|
|
121
121
|
const e = t.id || Pt(), {
|
|
122
122
|
creator: n,
|
|
123
123
|
created: o,
|
|
124
124
|
modified: i,
|
|
125
|
-
body:
|
|
126
|
-
...
|
|
127
|
-
} = t,
|
|
125
|
+
body: s,
|
|
126
|
+
...r
|
|
127
|
+
} = t, c = un(s, e), d = gn(t);
|
|
128
128
|
return "error" in d ? { error: d.error } : {
|
|
129
129
|
parsed: {
|
|
130
|
-
...
|
|
130
|
+
...r,
|
|
131
131
|
id: e,
|
|
132
|
-
bodies:
|
|
132
|
+
bodies: c,
|
|
133
133
|
target: d.parsed
|
|
134
134
|
}
|
|
135
135
|
};
|
|
136
136
|
}, mn = (t, e, n) => {
|
|
137
|
-
const { bodies: o, target: i, ...
|
|
138
|
-
selector:
|
|
139
|
-
creator:
|
|
137
|
+
const { bodies: o, target: i, ...s } = t, {
|
|
138
|
+
selector: r,
|
|
139
|
+
creator: c,
|
|
140
140
|
created: d,
|
|
141
141
|
updated: u,
|
|
142
|
-
...
|
|
143
|
-
} = i, h =
|
|
144
|
-
const { quote:
|
|
142
|
+
...f
|
|
143
|
+
} = i, h = r.map((y) => {
|
|
144
|
+
const { quote: g, start: x, end: v, range: p } = y, { prefix: l, suffix: a } = ee(p, n), m = [{
|
|
145
145
|
type: "TextQuoteSelector",
|
|
146
|
-
exact:
|
|
146
|
+
exact: g,
|
|
147
147
|
prefix: l,
|
|
148
|
-
suffix:
|
|
148
|
+
suffix: a
|
|
149
149
|
}, {
|
|
150
150
|
type: "TextPositionSelector",
|
|
151
|
-
start:
|
|
152
|
-
end:
|
|
151
|
+
start: x,
|
|
152
|
+
end: v
|
|
153
153
|
}];
|
|
154
154
|
return {
|
|
155
|
-
...
|
|
156
|
-
id:
|
|
155
|
+
...f,
|
|
156
|
+
id: y.id,
|
|
157
157
|
source: e,
|
|
158
|
-
selector:
|
|
158
|
+
selector: m
|
|
159
159
|
};
|
|
160
160
|
});
|
|
161
161
|
return {
|
|
162
|
-
...
|
|
162
|
+
...s,
|
|
163
163
|
"@context": "http://www.w3.org/ns/anno.jsonld",
|
|
164
164
|
id: t.id,
|
|
165
165
|
type: "Annotation",
|
|
166
166
|
body: hn(t.bodies),
|
|
167
|
-
creator:
|
|
167
|
+
creator: c,
|
|
168
168
|
created: d == null ? void 0 : d.toISOString(),
|
|
169
169
|
modified: u == null ? void 0 : u.toISOString(),
|
|
170
170
|
target: h
|
|
171
171
|
};
|
|
172
172
|
};
|
|
173
173
|
export {
|
|
174
|
-
|
|
174
|
+
_t as NOT_ANNOTATABLE_CLASS,
|
|
175
175
|
X as NOT_ANNOTATABLE_SELECTOR,
|
|
176
176
|
In as W3CTextFormat,
|
|
177
177
|
ee as getQuoteContext,
|
|
@@ -1 +1 @@
|
|
|
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=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,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 _t = \"not-annotatable\", X = `.${_t}`, 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(_t) && !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, s = document.createRange();\n s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);\n const r = bt(s).textContent, c = document.createRange();\n c.setStart(t.endContainer, t.endOffset), i === document.body ? c.setEnd(i, i.childNodes.length) : c.setEndAfter(i);\n const d = bt(c).textContent;\n return {\n prefix: r.substring(r.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 = (s) => Math.round(s * 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}, se = (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), s = Math.max(t.bottom, e.bottom);\n return new DOMRect(n, i, o - n, s - i);\n}, re = (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 s of e) {\n const r = ie(n, s);\n if (r === \"inline-adjacent\") {\n o = o.map((c) => c === s ? se(n, s) : c), i = !0;\n break;\n } else if (r === \"inline-contains\") {\n o = o.map((c) => c === s ? n : c), i = !0;\n break;\n } else if (r === \"inline-is-contained\") {\n i = !0;\n break;\n } else if (r === \"block-contains\" || r === \"block-is-contained\") {\n n.width < s.width && (o = o.map((c) => c === s ? n : c)), 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 s = bt(o).textContent, r = t.toString(), c = s.length || 0, d = c + r.length;\n return n ? { quote: r, start: c, end: d, range: t, offsetReference: i } : { quote: r, start: c, end: d, range: t };\n}, kt = (t, e) => {\n var f, h;\n const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(\n e,\n NodeFilter.SHOW_TEXT,\n (y) => {\n var g;\n return (g = y.parentElement) != null && g.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;\n }\n );\n let r = 0;\n const c = document.createRange();\n let d = s.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 y = ((f = d.textContent) == null ? void 0 : f.length) || 0;\n if (r + y > n) {\n c.setStart(d, n - r);\n break;\n }\n r += y;\n }\n d = s.nextNode();\n }\n for (; d !== null; ) {\n const y = ((h = d.textContent) == null ? void 0 : h.length) || 0;\n if (r + y >= o) {\n c.setEnd(d, o - r);\n break;\n }\n r += y, d = s.nextNode();\n }\n return {\n ...t,\n range: c\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 : kt(n, e))\n}, rt = (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 = (r) => {\n const c = s.getBoundingClientRect(), d = s.clientHeight, u = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: h, height: y } = e.getAnnotationBounds(o), g = f.top - c.top, x = f.left - c.left, v = s.parentElement ? s.scrollTop : 0, p = s.parentElement ? s.scrollLeft : 0, l = g + v - (d - y) / 2, a = x + p - (u - h) / 2;\n s.scroll({ top: l, left: a, behavior: \"smooth\" });\n }, s = Yt(t);\n if (s) {\n const r = e.getAnnotation(o), { range: c } = r.target.selector[0];\n if (c && !c.collapsed)\n return i(r.target), !0;\n {\n const d = it(r.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}, st = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.45\n}, de = (t, e, n, o, i) => {\n var r, c;\n const s = n ? typeof n == \"function\" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? st : P) : n : (c = t.state) != null && c.selected ? st : P;\n return o && o.paint(t, e) || s;\n}, ue = (t) => {\n const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, c = o - n, d = i - e;\n return { top: e, left: n, minX: s, minY: r, maxX: c, maxY: d };\n}, he = (t) => {\n let e = /* @__PURE__ */ new Set();\n return (o) => {\n const i = o.map((s) => s.id);\n (e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);\n };\n}, wt = (t, e, n, o) => {\n const { store: i, selection: s, hover: r } = e;\n let c, d, u;\n const f = he(n), h = (R) => {\n const { x: I, y: b } = t.getBoundingClientRect(), A = i.getAt(R.clientX - I, R.clientY - b, d);\n A ? r.current !== A.id && (t.classList.add(\"hovered\"), r.set(A.id)) : r.current && (t.classList.remove(\"hovered\"), r.set(null));\n };\n t.addEventListener(\"pointermove\", h);\n const y = (R = !1) => {\n u && u.clear();\n const I = ue(t), { minX: b, minY: A, maxX: w, maxY: C } = I, O = d ? i.getIntersecting(b, A, w, C).filter(({ annotation: _ }) => d(_)) : i.getIntersecting(b, A, w, C), B = s.selected.map(({ id: _ }) => _), D = O.map(({ annotation: _, rects: qt }) => {\n const Gt = B.includes(_.id), Kt = _.id === r.current;\n return { annotation: _, rects: qt, state: { selected: Gt, hover: Kt } };\n });\n o.redraw(D, I, c, u, R), setTimeout(() => f(O.map(({ annotation: _ }) => _)), 1);\n }, g = (R) => {\n u = R, y();\n }, x = (R) => {\n c = R, y();\n }, v = (R) => {\n d = R, y(!1);\n }, p = () => y();\n i.observe(p);\n const l = s.subscribe(() => y()), a = () => y(!0);\n document.addEventListener(\"scroll\", a, { capture: !0, passive: !0 });\n const m = yt(() => {\n i.recalculatePositions(), u && u.reset(), y();\n });\n window.addEventListener(\"resize\", m);\n const S = new ResizeObserver(m);\n S.observe(t);\n const L = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((R) => {\n R.every((b) => b.target === t || t.contains(b.target)) || y(!0);\n });\n return E.observe(document.body, L), {\n destroy: () => {\n t.removeEventListener(\"pointermove\", h), o.destroy(), i.unobserve(p), l(), document.removeEventListener(\"scroll\", a), window.removeEventListener(\"resize\", m), S.disconnect(), E.disconnect();\n },\n redraw: y,\n setStyle: x,\n setFilter: v,\n setPainter: g,\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 = (c, d, u, f) => requestAnimationFrame(() => {\n const { width: h, height: y } = e;\n n.clearRect(-0.5, -0.5, h + 1, y + 1), f && f.clear();\n const { top: g, left: x } = d;\n [...c].sort((p, l) => {\n const { annotation: { target: { created: a } } } = p, { annotation: { target: { created: m } } } = l;\n return a.getTime() - m.getTime();\n }).forEach((p) => {\n var S;\n const l = u ? typeof u == \"function\" ? u(p.annotation, p.state) : u : (S = p.state) != null && S.selected ? st : P, a = f && f.paint(p, d) || l, m = p.rects.map(({ x: L, y: E, width: T, height: R }) => ({\n x: L + x,\n y: E + g,\n width: T,\n height: R\n }));\n if (n.fillStyle = a.fill, n.globalAlpha = a.fillOpacity || 1, m.forEach(\n ({ x: L, y: E, width: T, height: R }) => n.fillRect(L, E, T, R)\n ), a.underlineColor) {\n n.globalAlpha = 1, n.strokeStyle = a.underlineColor, n.lineWidth = a.underlineThickness ?? 1;\n const L = a.underlineOffset ?? 0;\n m.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: (c) => {\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}, k = 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: k(t.r, 0, 255), g: k(t.g, 0, 255), b: k(t.b, 0, 255), a: k(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, s = Math.max(e, n, o), r = s - Math.min(e, n, o), c = r ? s === e ? (n - o) / r : s === n ? 2 + (o - e) / r : 4 + (e - n) / r : 0;\n return { h: 60 * (c < 0 ? c + 6 : c), s: s ? r / s * 100 : 0, v: s / 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 s = Math.floor(e), r = o * (1 - n), c = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), u = s % 6;\n return { r: 255 * [o, c, r, r, d, o][u], g: 255 * [d, o, o, c, r, r][u], b: 255 * [r, r, d, o, o, c][u], a: i };\n}, St = function(t) {\n return { h: Xt(t.h), s: k(t.s, 0, 100), l: k(t.l, 0, 100), a: k(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, s = i === void 0 ? 1 : i;\n return $(e) && $(n) && $(o) ? xt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;\n}, \"rgb\"], [function(t) {\n var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;\n if (!$(e) || !$(n) || !$(o)) return null;\n var r = St({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });\n return Ct(r);\n}, \"hsl\"], [function(t) {\n var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;\n if (!$(e) || !$(n) || !$(o)) return null;\n var r = function(c) {\n return { h: Xt(c.h), s: k(c.s, 0, 100), v: k(c.v, 0, 100), a: k(c.a) };\n }({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });\n return Ht(r);\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: k(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: k(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, r = (s = e.a) < 1 ? J(N(255 * s)) : \"\", \"#\" + J(n) + J(o) + J(i) + r;\n var e, n, o, i, s, r;\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, (s = e.a) < 1 ? \"rgba(\" + n + \", \" + o + \", \" + i + \", \" + s + \")\" : \"rgb(\" + n + \", \" + o + \", \" + i + \")\";\n var e, n, o, i, s;\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, (s = e.a) < 1 ? \"hsla(\" + n + \", \" + o + \"%, \" + i + \"%, \" + s + \")\" : \"hsl(\" + n + \", \" + o + \"%, \" + i + \"%)\";\n var e, n, o, i, s;\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: (s) => {\n console.log(\"setVisible not implemented on CSS Custom Highlights renderer\");\n },\n redraw: (s, r, c, d) => {\n d && d.clear();\n const u = new Set(s.map((h) => h.annotation.id));\n Array.from(e).filter((h) => !u.has(h));\n const f = s.map((h) => {\n var x;\n const y = c ? typeof c == \"function\" ? c(h.annotation, h.state) : c : (x = h.state) != null && x.selected ? st : P, g = d && d.paint(h, r) || y;\n return `::highlight(_${h.annotation.id}) { ${Ee(g)} }`;\n });\n t.innerHTML = f.join(`\n`), CSS.highlights.clear(), s.forEach(({ annotation: h }) => {\n const y = h.target.selector.map((x) => x.range), g = new Highlight(...y);\n CSS.highlights.set(`_${h.id}`, g);\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 = (s, r) => s.x <= r.x + r.width && s.x + s.width >= r.x && s.y <= r.y + r.height && s.y + s.height >= r.y, o = (s) => s.rects.reduce((r, c) => r + c.width, 0), i = e.filter(({ rects: s }) => s.some((r) => n(t, r)));\n return i.sort((s, r) => o(r) - o(s)), i.findIndex((s) => s.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: (r, c, d, u, f) => {\n const y = !(vt(n, r) && f);\n if (!u && !y) return;\n y && (e.innerHTML = \"\"), [...r].sort((x, v) => {\n const { annotation: { target: { created: p } } } = x, { annotation: { target: { created: l } } } = v;\n return p && l ? p.getTime() - l.getTime() : 0;\n }).forEach((x) => {\n x.rects.map((v) => {\n const p = Te(v, r), l = de(x, c, d, u, p);\n if (y) {\n const a = document.createElement(\"span\");\n a.className = \"r6o-annotation\", a.dataset.annotation = x.annotation.id, a.style.left = `${v.x}px`, a.style.top = `${v.y}px`, a.style.width = `${v.width}px`, a.style.height = `${v.height}px`, a.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 && (a.style.borderStyle = l.underlineStyle), l.underlineColor && (a.style.borderColor = l.underlineColor), l.underlineThickness && (a.style.borderBottomWidth = `${l.underlineThickness}px`), l.underlineOffset && (a.style.paddingBottom = `${l.underlineOffset}px`), e.appendChild(a);\n }\n });\n }), n = r;\n },\n setVisible: (r) => {\n r ? 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 j(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-- && j(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) || !j(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 z = [];\nfunction At(t, e = ut) {\n let n;\n const o = /* @__PURE__ */ new Set();\n function i(c) {\n if (Ue(t, c) && (t = c, n)) {\n const d = !z.length;\n for (const u of o)\n u[1](), z.push(u, t);\n if (d) {\n for (let u = 0; u < z.length; u += 2)\n z[u][0](z[u + 1]);\n z.length = 0;\n }\n }\n }\n function s(c) {\n i(c(t));\n }\n function r(c, d = ut) {\n const u = [c, d];\n return o.add(u), o.size === 1 && (n = e(i, s) || ut), c(t), () => {\n o.delete(u), o.size === 0 && n && (n(), n = null);\n };\n }\n return { set: i, update: s, subscribe: r };\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((r) => r.id === o) && n(void 0);\n const s = (i.updated || []).find(({ oldValue: r }) => r.id === o);\n s && n(s.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: [] }, _e = (t, e, n) => {\n const { subscribe: o, set: i } = At(tt);\n let s = e, r = tt;\n o((x) => r = x);\n const c = () => {\n j(r, tt) || i(tt);\n }, d = () => {\n var x;\n return ((x = r.selected) == null ? void 0 : x.length) === 0;\n }, u = (x) => {\n if (d())\n return !1;\n const v = typeof x == \"string\" ? x : x.id;\n return r.selected.some((p) => p.id === v);\n }, f = (x, v) => {\n const p = t.getAnnotation(x);\n if (!p) {\n console.warn(\"Invalid selection: \" + x);\n return;\n }\n switch (Nt(p, s)) {\n case \"EDIT\":\n i({ selected: [{ id: x, editable: !0 }], event: v });\n break;\n case \"SELECT\":\n i({ selected: [{ id: x }], event: v });\n break;\n default:\n i({ selected: [], event: v });\n }\n }, h = (x, v) => {\n const p = Array.isArray(x) ? x : [x], l = p.map((a) => t.getAnnotation(a)).filter((a) => !!a);\n i({\n selected: l.map((a) => {\n const m = v === void 0 ? Nt(a, s) === \"EDIT\" : v;\n return { id: a.id, editable: m };\n })\n }), l.length !== p.length && console.warn(\"Invalid selection\", x);\n }, y = (x) => {\n if (d())\n return !1;\n const { selected: v } = r;\n v.some(({ id: p }) => x.includes(p)) && i({ selected: v.filter(({ id: p }) => !x.includes(p)) });\n }, g = (x) => s = x;\n return t.observe(\n ({ changes: x }) => y((x.deleted || []).map((v) => v.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 s;\n },\n clear: c,\n isEmpty: d,\n isSelected: u,\n setSelected: h,\n setUserSelectAction: g,\n subscribe: o,\n userSelect: f\n };\n}, Nt = (t, e, n) => 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 ke(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 jt(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, ke(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: jt(),\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}, je = (t, e) => e.bodies.map((n) => {\n const o = t.bodies.find((i) => i.id === n.id);\n return { newBody: n, oldBody: o && !j(o, n) ? o : void 0 };\n}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), ze = (t, e) => !j(t.target, e.target), zt = (t, e) => {\n const n = He(t, e), o = Pe(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: ze(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: s } = e;\n if (!(t.options.origin ? t.options.origin === s : s !== \"SILENT\"))\n return !1;\n if (t.options.ignore) {\n const { ignore: r } = t.options, c = (d) => d && d.length > 0;\n if (!(c(i.created) || c(i.deleted))) {\n const d = (n = i.updated) == null ? void 0 : n.some((f) => c(f.bodiesCreated) || c(f.bodiesDeleted) || c(f.bodiesUpdated)), u = (o = i.updated) == null ? void 0 : o.some((f) => f.targetUpdated);\n if (r === \"BODY_ONLY\" && d && !u || r === \"TARGET_ONLY\" && u && !d)\n return !1;\n }\n }\n if (t.options.annotations) {\n const r = /* @__PURE__ */ new Set([\n ...(i.created || []).map((c) => c.id),\n ...(i.deleted || []).map((c) => c.id),\n ...(i.updated || []).map(({ oldValue: c }) => c.id)\n ]);\n return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((c) => r.has(c));\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)), s = new Set((e.deleted || []).map((h) => h.id)), r = new Set((e.updated || []).map(({ oldValue: h }) => h.id)), c = 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) => !s.has(h.id)).map((h) => r.has(h.id) ? e.updated.find(({ oldValue: y }) => y.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 ], f = [\n ...(t.updated || []).filter(({ newValue: h }) => !s.has(h.id)).map((h) => {\n const { oldValue: y, newValue: g } = h;\n if (r.has(g.id)) {\n const x = e.updated.find((v) => v.oldValue.id === g.id).newValue;\n return zt(y, x);\n } else\n return h;\n }),\n ...(e.updated || []).filter(({ oldValue: h }) => !c.has(h.id))\n ];\n return { created: d, deleted: u, updated: f };\n}, gt = (t) => {\n const e = t.id === void 0 ? jt() : 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 = (b, A = {}) => {\n n.push({ onChange: b, options: A });\n }, i = (b) => {\n const A = n.findIndex((w) => w.onChange == b);\n A > -1 && n.splice(A, 1);\n }, s = (b, A) => {\n const w = {\n origin: b,\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 }, r = (b, A = M.LOCAL) => {\n if (b.id && t.get(b.id))\n throw Error(`Cannot add annotation ${b.id} - exists already`);\n {\n const w = gt(b);\n t.set(w.id, w), w.bodies.forEach((C) => e.set(C.id, w.id)), s(A, { created: [w] });\n }\n }, c = (b, A) => {\n const w = gt(typeof b == \"string\" ? A : b), C = typeof b == \"string\" ? b : b.id, O = C && t.get(C);\n if (O) {\n const B = zt(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 = (b, A = M.LOCAL, w = M.LOCAL) => {\n const C = qe(A) ? w : A, O = c(b, A);\n O && s(C, { updated: [O] });\n }, u = (b, A = M.LOCAL) => {\n const w = b.reduce((C, O) => {\n const B = c(O);\n return B ? [...C, B] : C;\n }, []);\n w.length > 0 && s(A, { updated: w });\n }, f = (b, A = M.LOCAL) => {\n const w = t.get(b.annotation);\n if (w) {\n const C = {\n ...w,\n bodies: [...w.bodies, b]\n };\n t.set(w.id, C), e.set(b.id, C.id), s(A, { updated: [{\n oldValue: w,\n newValue: C,\n bodiesCreated: [b]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);\n }, h = () => [...t.values()], y = (b = M.LOCAL) => {\n const A = [...t.values()];\n t.clear(), e.clear(), s(b, { deleted: A });\n }, g = (b, A = !0, w = M.LOCAL) => {\n const C = b.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 }), s(w, { created: C, deleted: O });\n } else {\n const O = b.reduce((B, D) => {\n const _ = D.id && t.get(D.id);\n return _ ? [...B, _] : 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 }), s(w, { created: C });\n }\n }, x = (b) => {\n const A = typeof b == \"string\" ? b : b.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 }, v = (b, A = M.LOCAL) => {\n const w = x(b);\n w && s(A, { deleted: [w] });\n }, p = (b, A = M.LOCAL) => {\n const w = b.reduce((C, O) => {\n const B = x(O);\n return B ? [...C, B] : C;\n }, []);\n w.length > 0 && s(A, { deleted: w });\n }, l = (b) => {\n const A = t.get(b.annotation);\n if (A) {\n const w = A.bodies.find((C) => C.id === b.id);\n if (w) {\n e.delete(w.id);\n const C = {\n ...A,\n bodies: A.bodies.filter((O) => O.id !== b.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 ${b.id} from annotation ${b.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);\n }, a = (b, A = M.LOCAL) => {\n const w = l(b);\n w && s(A, { updated: [w] });\n }, m = (b, A = M.LOCAL) => {\n const w = b.map((C) => l(C)).filter(Boolean);\n w.length > 0 && s(A, { updated: w });\n }, S = (b) => {\n const A = t.get(b);\n return A ? { ...A } : void 0;\n }, L = (b) => {\n const A = e.get(b);\n if (A) {\n const w = S(A).bodies.find((C) => C.id === b);\n if (w)\n return w;\n console.error(`Store integrity error: body ${b} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${b}`);\n }, E = (b, A) => {\n if (b.annotation !== A.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const w = t.get(b.annotation);\n if (w) {\n const C = w.bodies.find((B) => B.id === b.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 ${b.annotation}`);\n }, T = (b, A, w = M.LOCAL) => {\n const C = E(b, A);\n C && s(w, { updated: [C] });\n }, R = (b, A = M.LOCAL) => {\n const w = b.map((C) => E({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);\n s(A, { updated: w });\n }, I = (b) => {\n const A = t.get(b.annotation);\n if (A) {\n const w = {\n ...A,\n target: {\n ...A.target,\n ...b\n }\n };\n return t.set(A.id, w), {\n oldValue: A,\n newValue: w,\n targetUpdated: {\n oldTarget: A.target,\n newTarget: b\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);\n };\n return {\n addAnnotation: r,\n addBody: f,\n all: h,\n bulkAddAnnotation: g,\n bulkDeleteAnnotation: p,\n bulkDeleteBodies: m,\n bulkUpdateAnnotation: u,\n bulkUpdateBodies: R,\n bulkUpdateTargets: (b, A = M.LOCAL) => {\n const w = b.map((C) => I(C)).filter(Boolean);\n w.length > 0 && s(A, { updated: w });\n },\n clear: y,\n deleteAnnotation: v,\n deleteBody: a,\n getAnnotation: S,\n getBody: L,\n observe: o,\n unobserve: i,\n updateAnnotation: d,\n updateBody: T,\n updateTarget: (b, A = M.LOCAL) => {\n const w = I(b);\n w && s(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, s = 0;\n const r = (g) => {\n if (!i) {\n const { changes: x } = g, v = performance.now();\n if (v - s > Qe)\n n.splice(o + 1), n.push(x), o = n.length - 1;\n else {\n const p = n.length - 1;\n n[p] = We(n[p], x);\n }\n s = v;\n }\n i = !1;\n };\n t.observe(r, { origin: M.LOCAL });\n const c = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), d = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), u = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: x }) => x)), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: x }) => x)), h = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), y = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);\n return {\n canRedo: () => n.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => t.unobserve(r),\n on: (g, x) => e.on(g, x),\n redo: () => {\n if (n.length - 1 > o) {\n i = !0;\n const { created: g, updated: x, deleted: v } = n[o + 1];\n d(g), f(x), y(v), e.emit(\"redo\", n[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n i = !0;\n const { created: g, updated: x, deleted: v } = n[o];\n c(g), u(x), h(v), 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 { hover: i, selection: s, store: r, viewport: c } = t, d = /* @__PURE__ */ new Map();\n let u = [], f;\n const h = (v, p) => {\n d.has(v) ? d.get(v).push(p) : d.set(v, [p]);\n }, y = (v, p) => {\n const l = d.get(v);\n if (l) {\n const a = l.indexOf(p);\n a !== -1 && l.splice(a, 1);\n }\n }, g = (v, p, l) => {\n d.has(v) && setTimeout(() => {\n d.get(v).forEach((a) => {\n if (n) {\n const m = Array.isArray(p) ? p.map((L) => n.serialize(L)) : n.serialize(p), S = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;\n a(m, S);\n } else\n a(p, l);\n });\n }, 1);\n };\n s.subscribe(({ selected: v }) => {\n if (!(u.length === 0 && v.length === 0)) {\n if (u.length === 0 && v.length > 0)\n u = v.map(({ id: p }) => r.getAnnotation(p));\n else if (u.length > 0 && v.length === 0)\n u.forEach((p) => {\n const l = r.getAnnotation(p.id);\n l && !j(l, p) && g(\"updateAnnotation\", l, p);\n }), u = [];\n else {\n const p = new Set(u.map((a) => a.id)), l = new Set(v.map(({ id: a }) => a));\n u.filter((a) => !l.has(a.id)).forEach((a) => {\n const m = r.getAnnotation(a.id);\n m && !j(m, a) && g(\"updateAnnotation\", m, a);\n }), u = [\n // Remove annotations that were deselected\n ...u.filter((a) => l.has(a.id)),\n // Add editable annotations that were selected\n ...v.filter(({ id: a }) => !p.has(a)).map(({ id: a }) => r.getAnnotation(a))\n ];\n }\n g(\"selectionChanged\", u);\n }\n }), i.subscribe((v) => {\n !f && v ? g(\"mouseEnterAnnotation\", r.getAnnotation(v)) : f && !v ? g(\"mouseLeaveAnnotation\", r.getAnnotation(f)) : f && v && (g(\"mouseLeaveAnnotation\", r.getAnnotation(f)), g(\"mouseEnterAnnotation\", r.getAnnotation(v))), f = v;\n }), c == null || c.subscribe((v) => g(\"viewportIntersect\", v.map((p) => r.getAnnotation(p)))), r.observe((v) => {\n const { created: p, deleted: l } = v.changes;\n (p || []).forEach((a) => g(\"createAnnotation\", a)), (l || []).forEach((a) => g(\"deleteAnnotation\", a)), (v.changes.updated || []).filter((a) => [\n ...a.bodiesCreated || [],\n ...a.bodiesDeleted || [],\n ...a.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: a, newValue: m }) => {\n const S = u.find((L) => L.id === a.id) || a;\n u = u.map((L) => L.id === a.id ? m : L), g(\"updateAnnotation\", m, S);\n });\n }, { origin: M.LOCAL }), r.observe((v) => {\n if (u) {\n const p = new Set(u.map((a) => a.id)), l = (v.changes.updated || []).filter(({ newValue: a }) => p.has(a.id)).map(({ newValue: a }) => a);\n l.length > 0 && (u = u.map((a) => l.find((S) => S.id === a.id) || a));\n }\n }, { origin: M.REMOTE });\n const x = (v) => (p) => {\n const { updated: l } = p;\n v ? (l || []).forEach((a) => g(\"updateAnnotation\", a.oldValue, a.newValue)) : (l || []).forEach((a) => g(\"updateAnnotation\", a.newValue, a.oldValue));\n };\n return e.on(\"undo\", x(!0)), e.on(\"redo\", x(!1)), { on: h, off: y, emit: g };\n}, en = (t) => (e) => e.reduce((n, o) => {\n const { parsed: i, error: s } = t.parse(o);\n return s ? {\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, s = (l) => {\n if (n) {\n const { parsed: a, error: m } = n.parse(l);\n a ? o.addAnnotation(a, M.REMOTE) : console.error(m);\n } else\n o.addAnnotation(ft(l), M.REMOTE);\n }, r = () => i.clear(), c = () => o.clear(), d = (l) => {\n const a = o.getAnnotation(l);\n return n && a ? n.serialize(a) : a;\n }, u = () => n ? o.all().map(n.serialize) : o.all(), f = () => {\n var l;\n const a = (((l = i.selected) == null ? void 0 : l.map((m) => m.id)) || []).map((m) => o.getAnnotation(m)).filter(Boolean);\n return n ? a.map(n.serialize) : a;\n }, h = (l, a = !0) => fetch(l).then((m) => m.json()).then((m) => (g(m, a), m)), y = (l) => {\n if (typeof l == \"string\") {\n const a = o.getAnnotation(l);\n if (o.deleteAnnotation(l), a)\n return n ? n.serialize(a) : a;\n } else {\n const a = n ? n.parse(l).parsed : l;\n if (a)\n return o.deleteAnnotation(a), l;\n }\n }, g = (l, a = !0) => {\n if (n) {\n const m = n.parseAll || en(n), { parsed: S, failed: L } = m(l);\n L.length > 0 && console.warn(`Discarded ${L.length} invalid annotations`, L), o.bulkAddAnnotation(S, a, M.REMOTE);\n } else\n o.bulkAddAnnotation(l.map(ft), a, M.REMOTE);\n }, x = (l, a) => {\n l ? i.setSelected(l, a) : i.clear();\n }, v = (l) => {\n i.clear(), i.setUserSelectAction(l);\n }, p = (l) => {\n if (n) {\n const a = n.parse(l).parsed, m = n.serialize(o.getAnnotation(a.id));\n return o.updateAnnotation(a), m;\n } else {\n const a = o.getAnnotation(l.id);\n return o.updateAnnotation(ft(l)), a;\n }\n };\n return {\n addAnnotation: s,\n cancelSelected: r,\n canRedo: e.canRedo,\n canUndo: e.canUndo,\n clearAnnotations: c,\n getAnnotationById: d,\n getAnnotations: u,\n getSelected: f,\n loadAnnotations: h,\n redo: e.redo,\n removeAnnotation: y,\n setAnnotations: g,\n setSelected: x,\n setUserSelectAction: v,\n undo: e.undo,\n updateAnnotation: p\n };\n}, on = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nlet sn = (t) => crypto.getRandomValues(new Uint8Array(t)), rn = (t, e, n) => {\n let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);\n return (s = e) => {\n let r = \"\";\n for (; ; ) {\n let c = n(i), d = i;\n for (; d--; )\n if (r += t[c[d] & o] || \"\", r.length === s) return r;\n }\n };\n}, an = (t, e = 21) => rn(t, e, sn), 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 s = e.charCodeAt(o);\n n = (n << 5) - n + s, 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: s, value: r, created: c, modified: d, creator: u, ...f } = n;\n return {\n id: o || `temp-${dn(n)}`,\n annotation: e,\n type: i,\n purpose: s,\n value: r,\n creator: Ft(u),\n created: c ? new Date(c) : void 0,\n updated: d ? new Date(d) : void 0,\n ...f\n };\n}), hn = (t) => t.map((e) => {\n var n;\n const { annotation: o, created: i, updated: s, ...r } = e, c = {\n ...r,\n created: i == null ? void 0 : i.toISOString(),\n modified: s == null ? void 0 : s.toISOString()\n };\n return (n = c.id) != null && n.startsWith(\"temp-\") && delete c.id, c;\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: s\n } = t, r = Array.isArray(s) ? s : [s], c = {\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 r) {\n const f = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((h, y) => {\n switch (y.type) {\n case \"TextQuoteSelector\":\n h.quote = y.exact;\n break;\n case \"TextPositionSelector\":\n h.start = y.start, h.end = y.end;\n break;\n }\n return h;\n }, {});\n if (fn(f))\n c.selector.push({ id: d.id, ...f });\n else {\n const h = [\n f.start ? void 0 : \"TextPositionSelector\",\n f.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: c };\n}, pn = (t) => {\n const e = t.id || Pt(), {\n creator: n,\n created: o,\n modified: i,\n body: s,\n ...r\n } = t, c = un(s, e), d = gn(t);\n return \"error\" in d ? { error: d.error } : {\n parsed: {\n ...r,\n id: e,\n bodies: c,\n target: d.parsed\n }\n };\n}, mn = (t, e, n) => {\n const { bodies: o, target: i, ...s } = t, {\n selector: r,\n creator: c,\n created: d,\n updated: u,\n ...f\n } = i, h = r.map((y) => {\n const { quote: g, start: x, end: v, range: p } = y, { prefix: l, suffix: a } = ee(p, n), m = [{\n type: \"TextQuoteSelector\",\n exact: g,\n prefix: l,\n suffix: a\n }, {\n type: \"TextPositionSelector\",\n start: x,\n end: v\n }];\n return {\n ...f,\n id: y.id,\n source: e,\n selector: m\n };\n });\n return {\n ...s,\n \"@context\": \"http://www.w3.org/ns/anno.jsonld\",\n id: t.id,\n type: \"Annotation\",\n body: hn(t.bodies),\n creator: c,\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, f = Math.log(d), h = 0.5 * Math.exp(2 * f / 3), y = 0.5 * Math.sqrt(f * h * (d - h) / d) * (u - d / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - u * h / d + y)), x = Math.min(o, Math.floor(e + (d - u) * h / d + y));\n Wt(t, e, g, x, i);\n }\n const s = t[e];\n let r = n, c = o;\n for (q(t, n, e), i(t[o], s) > 0 && q(t, n, o); r < c; ) {\n for (q(t, r, c), r++, c--; i(t[r], s) < 0; ) r++;\n for (; i(t[c], s) > 0; ) c--;\n }\n i(t[n], s) === 0 ? q(t, n, c) : (c++, q(t, c, o)), c <= e && (n = c + 1), e <= c && (o = c - 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, s = [];\n for (; n; ) {\n for (let r = 0; r < n.children.length; r++) {\n const c = n.children[r], d = n.leaf ? i(c) : c;\n ot(e, d) && (n.leaf ? o.push(c) : mt(e, d) ? this._all(c, o) : s.push(c));\n }\n n = s.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 s = n.children[i], r = n.leaf ? this.toBBox(s) : s;\n if (ot(e, r)) {\n if (n.leaf || mt(e, r)) return !0;\n o.push(s);\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), s = [], r = [];\n let c, d, u;\n for (; o || s.length; ) {\n if (o || (o = s.pop(), d = s[s.length - 1], c = r.pop(), u = !0), o.leaf) {\n const f = yn(e, o.children, n);\n if (f !== -1)\n return o.children.splice(f, 1), s.push(o), this._condense(s), this;\n }\n !u && !o.leaf && mt(o, i) ? (s.push(o), r.push(c), c = 0, d = o, o = o.children[0]) : d ? (c++, o = d.children[c], 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 s = o - n + 1;\n let r = this._maxEntries, c;\n if (s <= r)\n return c = W(e.slice(n, o + 1)), F(c, this.toBBox), c;\n i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), c = W([]), c.leaf = !1, c.height = i;\n const d = Math.ceil(s / r), u = d * Math.ceil(Math.sqrt(r));\n Vt(e, n, o, u, this.compareMinX);\n for (let f = n; f <= o; f += u) {\n const h = Math.min(f + u - 1, o);\n Vt(e, f, h, d, this.compareMinY);\n for (let y = f; y <= h; y += d) {\n const g = Math.min(y + d - 1, h);\n c.children.push(this._build(e, y, g, i - 1));\n }\n }\n return F(c, this.toBBox), c;\n }\n _chooseSubtree(e, n, o, i) {\n for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {\n let s = 1 / 0, r = 1 / 0, c;\n for (let d = 0; d < n.children.length; d++) {\n const u = n.children[d], f = pt(u), h = xn(e, u) - f;\n h < r ? (r = h, s = f < s ? f : s, c = u) : h === r && f < s && (s = f, c = u);\n }\n n = c || n.children[0];\n }\n return n;\n }\n _insert(e, n, o) {\n const i = o ? e : this.toBBox(e), s = [], r = this._chooseSubtree(i, this.data, n, s);\n for (r.children.push(e), K(r, i); n >= 0 && s[n].children.length > this._maxEntries; )\n this._split(s, n), n--;\n this._adjustParentBBoxes(i, s, n);\n }\n // split overflowed node into two\n _split(e, n) {\n const o = e[n], i = o.children.length, s = this._minEntries;\n this._chooseSplitAxis(o, s, i);\n const r = this._chooseSplitIndex(o, s, i), c = W(o.children.splice(r, o.children.length - r));\n c.height = o.height, c.leaf = o.leaf, F(o, this.toBBox), F(c, this.toBBox), n ? e[n - 1].children.push(c) : this._splitRoot(o, c);\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, s = 1 / 0, r = 1 / 0;\n for (let c = n; c <= o - n; c++) {\n const d = G(e, 0, c, this.toBBox), u = G(e, c, o, this.toBBox), f = Sn(d, u), h = pt(d) + pt(u);\n f < s ? (s = f, i = c, r = h < r ? h : r) : f === s && h < r && (r = h, i = c);\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, s = e.leaf ? this.compareMinY : An, r = this._allDistMargin(e, n, o, i), c = this._allDistMargin(e, n, o, s);\n r < c && 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 s = this.toBBox, r = G(e, 0, n, s), c = G(e, o - n, o, s);\n let d = nt(r) + nt(c);\n for (let u = n; u < o - n; u++) {\n const f = e.children[u];\n K(r, e.leaf ? s(f) : f), d += nt(r);\n }\n for (let u = o - n - 1; u >= n; u--) {\n const f = e.children[u];\n K(c, e.leaf ? s(f) : f), d += nt(c);\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 s = e; s < n; s++) {\n const r = t.children[s];\n K(i, t.leaf ? o(r) : r);\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), s = Math.min(t.maxY, e.maxY);\n return Math.max(0, i - n) * Math.max(0, s - 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 s = [e, n];\n for (; s.length; ) {\n if (n = s.pop(), e = s.pop(), n - e <= o) continue;\n const r = e + Math.ceil((n - e) / o / 2) * o;\n Wt(t, r, e, n, i), s.push(e, r, r, n);\n }\n}\nconst En = (t, e) => {\n const n = new vn(), o = /* @__PURE__ */ new Map(), i = (l, a) => {\n const m = l.selector.flatMap((L) => {\n const E = H([L]) ? L.range : kt(L, e).range;\n return Array.from(E.getClientRects());\n }), S = re(m).map(({ left: L, top: E, right: T, bottom: R }) => new DOMRect(L - a.left, E - a.top, T - L, R - E));\n return S.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: S\n }\n };\n });\n }, s = () => [...o.values()], r = () => {\n n.clear(), o.clear();\n }, c = (l) => {\n const a = i(l, e.getBoundingClientRect());\n a.forEach((m) => n.insert(m)), o.set(l.annotation, a);\n }, d = (l) => {\n const a = o.get(l.annotation);\n a && (a.forEach((m) => n.remove(m)), o.delete(l.annotation));\n }, u = (l) => {\n d(l), c(l);\n }, f = (l, a = !0) => {\n a && r();\n const m = e.getBoundingClientRect(), S = l.map((E) => ({ target: E, rects: i(E, m) }));\n S.forEach(({ target: E, rects: T }) => o.set(E.annotation, T));\n const L = S.flatMap(({ rects: E }) => E);\n n.load(L);\n }, h = (l, a, m = !1) => {\n const S = n.search({\n minX: l,\n minY: a,\n maxX: l,\n maxY: a\n }), L = (E) => E.annotation.rects.reduce((T, R) => T + R.width * R.height, 0);\n return S.length > 0 ? (S.sort((E, T) => L(E) - L(T)), m ? S.map((E) => E.annotation.id) : [S[0].annotation.id]) : [];\n }, y = (l) => {\n const a = g(l);\n if (a.length === 0)\n return;\n let m = a[0].left, S = a[0].top, L = a[0].right, E = a[0].bottom;\n for (let T = 1; T < a.length; T++) {\n const R = a[T];\n m = Math.min(m, R.left), S = Math.min(S, R.top), L = Math.max(L, R.right), E = Math.max(E, R.bottom);\n }\n return new DOMRect(m, S, L - m, E - S);\n }, g = (l) => {\n const a = o.get(l);\n return a ? a[0].annotation.rects : [];\n };\n return {\n all: s,\n clear: r,\n getAt: h,\n getAnnotationBounds: y,\n getAnnotationRects: g,\n getIntersecting: (l, a, m, S) => {\n const L = n.search({ minX: l, minY: a, maxX: m, maxY: S }), E = new Set(L.map((T) => T.annotation.id));\n return Array.from(E).map((T) => ({\n annotation: t.getAnnotation(T),\n rects: g(T)\n })).filter((T) => !!T.annotation);\n },\n insert: c,\n recalculate: () => f(t.all().map((l) => l.target), !0),\n remove: d,\n set: f,\n size: () => n.all().length,\n update: u\n };\n}, Cn = (t, e) => {\n const n = Ge(), o = En(n, t), i = _e(n);\n i.setUserSelectAction(e);\n const s = Ve(n), r = Ze(), c = (p, l = M.LOCAL) => {\n const a = rt(p, t), m = H(a.target.selector);\n return m && n.addAnnotation(a, l), m;\n }, d = (p, l = !0, a = M.LOCAL) => {\n const m = p.map((L) => rt(L, t)), S = m.filter((L) => !H(L.target.selector));\n return S.length > 0 ? (console.warn(\"Could not revive all targets for these annotations:\", S), n.bulkAddAnnotation(m, l, a), S) : (n.bulkAddAnnotation(m, l, a), []);\n }, u = (p, l = M.LOCAL) => {\n const a = p.map((S) => rt(S, t)), m = a.filter((S) => !H(S.target.selector));\n return m.length > 0 && console.warn(\"Could not revive all targets for these annotations:\", m), a.forEach((S) => {\n n.getAnnotation(S.id) ? n.updateAnnotation(S, l) : n.addAnnotation(S, l);\n }), m;\n }, f = (p, l = M.LOCAL) => {\n const a = it(p, t);\n n.updateTarget(a, l);\n }, h = (p, l = M.LOCAL) => {\n const a = p.map((m) => it(m, t));\n n.bulkUpdateTargets(a, l);\n }, y = (p, l, a) => {\n const m = o.getAt(p, l, !!a).map((L) => n.getAnnotation(L)), S = a ? m.filter(a) : m;\n return S.length > 0 ? S[0] : void 0;\n }, g = (p, l, a, m = 5) => {\n const S = o.getAnnotationRects(p);\n if (S.length !== 0) {\n if (l && a) {\n const L = S.find(({ top: E, right: T, bottom: R, left: I }) => l >= I - m && l <= T + m && a >= E - m && a <= R + m);\n if (L) return L;\n }\n return o.getAnnotationBounds(p);\n }\n }, x = (p) => o.getAnnotationRects(p), v = () => o.recalculate();\n return n.observe(({ changes: p }) => {\n const l = (p.deleted || []).filter((S) => H(S.target.selector)), a = (p.created || []).filter((S) => H(S.target.selector)), m = (p.updated || []).filter((S) => H(S.newValue.target.selector));\n (l == null ? void 0 : l.length) > 0 && l.forEach((S) => o.remove(S.target)), a.length > 0 && o.set(a.map((S) => S.target), !1), (m == null ? void 0 : m.length) > 0 && m.forEach(({ newValue: S }) => o.update(S.target));\n }), {\n store: {\n ...n,\n addAnnotation: c,\n bulkAddAnnotation: d,\n bulkUpdateTargets: h,\n bulkUpsertAnnotations: u,\n getAnnotationBounds: g,\n getAnnotationRects: x,\n getAt: y,\n getIntersecting: o.getIntersecting,\n recalculatePositions: v,\n updateTarget: f\n },\n selection: i,\n hover: s,\n viewport: r\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(), s = (f) => Array.from(i.entries()).filter(([h, y]) => y.presenceKey === f.presenceKey).map(([h, y]) => h);\n return t.on(\"selectionChange\", (f, h) => {\n s(f).forEach((g) => i.delete(g)), h && h.forEach((g) => i.set(g, f));\n }), {\n clear: () => {\n const { width: f, height: h } = n;\n o.clearRect(-0.5, -0.5, f + 1, h + 1);\n },\n destroy: () => {\n n.remove();\n },\n paint: (f, h, y) => {\n e.font && (o.font = e.font);\n const g = i.get(f.annotation.id);\n if (g) {\n const { height: x } = f.rects[0], v = f.rects[0].x + h.left, p = f.rects[0].y + h.top;\n o.fillStyle = g.appearance.color, o.fillRect(v - 2, p - 2.5, 2, x + 5);\n const l = o.measureText(g.appearance.label), a = l.width + 6, m = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, S = l.fontBoundingBoxAscent ? 8 : 6.5;\n return o.fillRect(v - 2, p - 2.5 - m, a, m), o.fillStyle = \"#fff\", o.fillText(g.appearance.label, v + 1, p - S), {\n fill: g.appearance.color,\n fillOpacity: y ? 0.45 : 0.18\n };\n }\n },\n reset: () => {\n n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;\n const f = n.getContext(\"2d\");\n f.scale(2, 2), f.translate(0.5, 0.5);\n }\n };\n}, Rn = (t, e, n, o) => {\n let i;\n const s = (a) => i = a;\n let r;\n const c = (a) => r = a, { store: d, selection: u } = e;\n let f, h = !1, y;\n const g = (a) => {\n var S;\n if (!h) return;\n !((S = a.target.parentElement) != null && S.closest(X)) ? f = {\n annotation: Pt(),\n selector: [],\n creator: i,\n created: /* @__PURE__ */ new Date()\n } : f = void 0;\n }, x = yt((a) => {\n var b, A;\n const m = document.getSelection();\n if (!!((A = (b = m.anchorNode) == null ? void 0 : b.parentElement) != null && A.closest(X))) {\n f = void 0;\n return;\n }\n if (a.timeStamp - ((y == null ? void 0 : y.timeStamp) || a.timeStamp) < 1e3 && !f && g(y), m.isCollapsed || !h || !f) return;\n const E = m.getRangeAt(0), T = ce(E, t);\n if (oe(T)) return;\n const R = Zt(T.cloneRange());\n (R.length !== f.selector.length || R.some((w, C) => {\n var O;\n return w.toString() !== ((O = f.selector[C]) == null ? void 0 : O.quote);\n })) && (f = {\n ...f,\n selector: R.map((w) => ae(w, t, o)),\n updated: /* @__PURE__ */ new Date()\n }, d.getAnnotation(f.annotation) ? d.updateTarget(f, M.LOCAL) : (u.clear(), d.addAnnotation({\n id: f.annotation,\n bodies: [],\n target: f\n }), u.userSelect(f.annotation, y)));\n }), v = (a) => {\n const { target: m, timeStamp: S, offsetX: L, offsetY: E, type: T } = a;\n y = { ...a, target: m, timeStamp: S, offsetX: L, offsetY: E, type: T }, h = a.button === 0;\n }, p = (a) => {\n var E;\n if (!!((E = a.target.parentElement) != null && E.closest(X)) || !h)\n return;\n const S = () => {\n const { x: T, y: R } = t.getBoundingClientRect(), I = a.target instanceof Node && t.contains(a.target) && d.getAt(a.clientX - T, a.clientY - R, r);\n if (I) {\n const { selected: b } = u;\n (b.length !== 1 || b[0].id !== I.id) && u.userSelect(I.id, a);\n } else u.isEmpty() || u.clear();\n }, L = a.timeStamp - y.timeStamp;\n setTimeout(() => {\n const T = document.getSelection();\n T != null && T.isCollapsed && L < 300 ? (f = void 0, S()) : f && u.userSelect(f.annotation, a);\n });\n };\n return t.addEventListener(\"pointerdown\", v), document.addEventListener(\"pointerup\", p), n && (t.addEventListener(\"selectstart\", g), document.addEventListener(\"selectionchange\", x)), {\n destroy: () => {\n t.removeEventListener(\"pointerdown\", v), document.removeEventListener(\"pointerup\", p), t.removeEventListener(\"selectstart\", g), document.removeEventListener(\"selectionchange\", x);\n },\n setFilter: c,\n setUser: s\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: s } = o, r = o.store, c = Je(r), d = tn(o, c, n.adapter);\n let u = n.user;\n const f = n.renderer === \"CSS_HIGHLIGHTS\" ? CSS.highlights ? \"CSS_HIGHLIGHTS\" : Dt : n.renderer || Dt, h = f === \"SPANS\" ? Be(t, o, s) : f === \"CSS_HIGHLIGHTS\" ? Le(t, o, s) : f === \"CANVAS\" ? me(t, o, s) : void 0;\n if (!h)\n throw `Unknown renderer implementation: ${f}`;\n console.debug(`Using ${f} renderer`), n.style && h.setStyle(n.style);\n const y = Rn(t, o, n.annotatingEnabled, n.offsetReferenceSelector);\n return y.setUser(u), {\n ...nn(o, c, n.adapter),\n destroy: () => {\n h.destroy(), y.destroy(), c.destroy();\n },\n element: t,\n getUser: () => u,\n setFilter: (E) => {\n h.setFilter(E), y.setFilter(E);\n },\n setStyle: (E) => h.setStyle(E),\n setUser: (E) => {\n u = E, y.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, r),\n state: o\n };\n};\nexport {\n st as DEFAULT_SELECTED_STYLE,\n P as DEFAULT_STYLE,\n _t 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 re as mergeClientRects,\n de as paint,\n pn as parseW3CTextAnnotation,\n ae as rangeToSelector,\n rt as reviveAnnotation,\n kt 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,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,UAA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AA,IACT,GAAG;AAAA,EACJ,IAAG,GAAG,IAAI,EAAE,IAAI,CAAC,MAAM;AACtB,UAAM,EAAE,OAAO,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,MAAM,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]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soomo/react-text-annotator",
|
|
3
|
-
"version": "3.0.0-staging.
|
|
3
|
+
"version": "3.0.0-staging.60",
|
|
4
4
|
"description": "Recogito Text Annotator React bindings",
|
|
5
5
|
"author": "Rainer Simon",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
"@vitejs/plugin-react": "^4.3.1",
|
|
29
29
|
"react": "^18.3.1",
|
|
30
30
|
"react-dom": "^18.3.1",
|
|
31
|
-
"typescript": "5.
|
|
32
|
-
"vite": "^5.4.
|
|
33
|
-
"vite-plugin-dts": "^4.1
|
|
31
|
+
"typescript": "5.6.2",
|
|
32
|
+
"vite": "^5.4.6",
|
|
33
|
+
"vite-plugin-dts": "^4.2.1",
|
|
34
34
|
"vite-tsconfig-paths": "^5.0.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@annotorious/core": "^3.0.
|
|
48
|
-
"@annotorious/react": "^3.0.
|
|
49
|
-
"@floating-ui/react": "^0.26.
|
|
50
|
-
"@soomo/text-annotator": "3.0.0-staging.59",
|
|
47
|
+
"@annotorious/core": "^3.0.8",
|
|
48
|
+
"@annotorious/react": "^3.0.8",
|
|
49
|
+
"@floating-ui/react": "^0.26.24",
|
|
51
50
|
"@react-aria/live-announcer": "^3.3.4",
|
|
52
|
-
"@
|
|
51
|
+
"@soomo/text-annotator": "3.0.0-staging.60",
|
|
52
|
+
"@recogito/text-annotator-tei": "3.0.0-rc.46",
|
|
53
53
|
"CETEIcean": "^1.9.3",
|
|
54
54
|
"unique-random": "^4.0.0"
|
|
55
55
|
}
|