@soomo/react-text-annotator 3.0.0-staging.38 → 3.0.0-staging.39

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.
Files changed (74) hide show
  1. package/dist/{TextAnnotatorPopup.d.ts → TextAnnotatorPopup/TextAnnotatorPopup.d.ts} +3 -2
  2. package/dist/TextAnnotatorPopup/TextAnnotatorPopup.d.ts.map +1 -0
  3. package/dist/TextAnnotatorPopup/index.d.ts +2 -0
  4. package/dist/TextAnnotatorPopup/index.d.ts.map +1 -0
  5. package/dist/hooks/index.d.ts +3 -0
  6. package/dist/hooks/index.d.ts.map +1 -0
  7. package/dist/hooks/useAnnouncePopupNavigation.d.ts +8 -0
  8. package/dist/hooks/useAnnouncePopupNavigation.d.ts.map +1 -0
  9. package/dist/hooks/useRestoreSelectionCaret.d.ts +13 -0
  10. package/dist/hooks/useRestoreSelectionCaret.d.ts.map +1 -0
  11. package/dist/index.d.ts +1 -0
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/react-text-annotator.css +30 -0
  14. package/dist/react-text-annotator.es.js +8 -4
  15. package/dist/react-text-annotator.es.js.map +1 -1
  16. package/dist/react-text-annotator.es11.js +445 -527
  17. package/dist/react-text-annotator.es11.js.map +1 -1
  18. package/dist/react-text-annotator.es12.js +60 -483
  19. package/dist/react-text-annotator.es12.js.map +1 -1
  20. package/dist/react-text-annotator.es13.js +38 -44
  21. package/dist/react-text-annotator.es13.js.map +1 -1
  22. package/dist/react-text-annotator.es14.js +1422 -118
  23. package/dist/react-text-annotator.es14.js.map +1 -1
  24. package/dist/react-text-annotator.es16.js +239 -29
  25. package/dist/react-text-annotator.es16.js.map +1 -1
  26. package/dist/react-text-annotator.es17.js +568 -897
  27. package/dist/react-text-annotator.es17.js.map +1 -1
  28. package/dist/react-text-annotator.es18.js +2 -2
  29. package/dist/react-text-annotator.es19.js +31 -2
  30. package/dist/react-text-annotator.es19.js.map +1 -1
  31. package/dist/react-text-annotator.es2.js +2 -2
  32. package/dist/react-text-annotator.es20.js +893 -109
  33. package/dist/react-text-annotator.es20.js.map +1 -1
  34. package/dist/react-text-annotator.es21.js +2 -309
  35. package/dist/react-text-annotator.es21.js.map +1 -1
  36. package/dist/react-text-annotator.es22.js +2 -58
  37. package/dist/react-text-annotator.es22.js.map +1 -1
  38. package/dist/react-text-annotator.es23.js +113 -19
  39. package/dist/react-text-annotator.es23.js.map +1 -1
  40. package/dist/react-text-annotator.es24.js +290 -130
  41. package/dist/react-text-annotator.es24.js.map +1 -1
  42. package/dist/react-text-annotator.es25.js +43 -545
  43. package/dist/react-text-annotator.es25.js.map +1 -1
  44. package/dist/react-text-annotator.es26.js +23 -0
  45. package/dist/react-text-annotator.es26.js.map +1 -0
  46. package/dist/react-text-annotator.es27.js +130 -0
  47. package/dist/react-text-annotator.es27.js.map +1 -0
  48. package/dist/react-text-annotator.es28.js +155 -0
  49. package/dist/react-text-annotator.es28.js.map +1 -0
  50. package/dist/react-text-annotator.es29.js +314 -0
  51. package/dist/react-text-annotator.es29.js.map +1 -0
  52. package/dist/react-text-annotator.es3.js +2 -2
  53. package/dist/react-text-annotator.es30.js +152 -0
  54. package/dist/react-text-annotator.es30.js.map +1 -0
  55. package/dist/react-text-annotator.es31.js +563 -0
  56. package/dist/react-text-annotator.es31.js.map +1 -0
  57. package/dist/react-text-annotator.es4.js +30 -23
  58. package/dist/react-text-annotator.es4.js.map +1 -1
  59. package/dist/react-text-annotator.es5.js +36 -78
  60. package/dist/react-text-annotator.es5.js.map +1 -1
  61. package/dist/react-text-annotator.es6.js +24 -178
  62. package/dist/react-text-annotator.es6.js.map +1 -1
  63. package/dist/react-text-annotator.es7.js +126 -10
  64. package/dist/react-text-annotator.es7.js.map +1 -1
  65. package/dist/react-text-annotator.es8.js +182 -0
  66. package/dist/react-text-annotator.es8.js.map +1 -0
  67. package/dist/react-text-annotator.es9.js +10 -670
  68. package/dist/react-text-annotator.es9.js.map +1 -1
  69. package/package.json +5 -3
  70. package/dist/TextAnnotatorPopup.d.ts.map +0 -1
  71. package/dist/react-text-annotator.es10.js +0 -244
  72. package/dist/react-text-annotator.es10.js.map +0 -1
  73. package/dist/react-text-annotator.es15.js +0 -5
  74. package/dist/react-text-annotator.es15.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-text-annotator.es8.js","sources":["../../../node_modules/@recogito/text-annotator/dist/text-annotator.es.js"],"sourcesContent":["const P = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.18\n}, ot = {\n fill: \"rgb(0, 128, 255)\",\n fillOpacity: 0.45\n}, Kt = (t, e, n, o, r) => {\n var s, a;\n const i = n ? typeof n == \"function\" ? n(t.annotation, t.state, r) || ((s = t.state) != null && s.selected ? ot : P) : n : (a = t.state) != null && a.selected ? ot : P;\n return o && o.paint(t, e) || i;\n}, Yt = \"not-annotatable\", D = `.${Yt}`, Qt = (t) => {\n var n;\n const e = t.commonAncestorContainer;\n return e instanceof HTMLElement ? !e.closest(D) : !((n = e.parentElement) != null && n.closest(D));\n}, Jt = function* (t) {\n const e = document.createNodeIterator(\n t.commonAncestorContainer,\n NodeFilter.SHOW_ELEMENT,\n (o) => o instanceof HTMLElement && o.classList.contains(Yt) && !o.parentElement.closest(D) && 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 r;\n n ? (r = document.createRange(), r.setStartAfter(n), r.setEndBefore(o)) : (r = t.cloneRange(), r.setEndBefore(o)), r.collapsed || e.push(r), 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}, pt = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(D).forEach((n) => n.remove()), e;\n}, te = (t) => {\n t.addEventListener(\"click\", (e) => {\n // Allow clicks within not-annotatable elements\n !e.target.closest(D) && !e.target.closest(\"a\") && e.preventDefault();\n });\n}, bt = (t, e = 10) => {\n let n;\n return (...o) => {\n clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);\n };\n}, On = (t) => {\n const e = t.cloneContents();\n return e.querySelectorAll(D).forEach((n) => n.remove()), e;\n}, wt = (t, e) => {\n const n = document.createNodeIterator(e);\n let o = 0, r = n.nextNode();\n for (; r !== null; ) {\n if (r === t)\n return o;\n o += 1, r = n.nextNode();\n }\n}, xt = (t, e) => {\n const n = document.createNodeIterator(e);\n let o = null;\n for (let r = 0; r < t + 1; r++)\n o = n.nextNode();\n return o;\n}, ee = (t) => {\n const {\n commonAncestorContainer: e,\n startContainer: n,\n startOffset: o,\n endContainer: r,\n endOffset: i\n } = t, s = Array.from(e.childNodes).map((d) => {\n const m = d.cloneNode(!0);\n return d.nodeName === \"CANVAS\" ? d : m;\n }), a = wt(n, e), u = wt(r, e), f = () => {\n const d = e;\n d.replaceChildren(...s);\n const m = xt(a, d), h = xt(u, d);\n return t.setStart(m, o), t.setEnd(h, i), t;\n }, g = (d) => {\n const m = document.createElement(\"SPAN\");\n return d.surroundContents(m), m;\n };\n if (n === r)\n throw \"Not implemented\";\n {\n const d = document.createRange();\n d.selectNodeContents(n), d.setStart(n, o);\n const m = g(d), h = document.createRange();\n h.selectNode(r), h.setEnd(r, i);\n const w = g(h), p = ne(t).reverse().map((l) => {\n var b;\n const c = document.createElement(\"SPAN\");\n return (b = l.parentNode) == null || b.insertBefore(c, l), c.appendChild(l), c;\n });\n return { unwrap: f, nodes: [m, ...p, w] };\n }\n}, ne = (t) => {\n const {\n commonAncestorContainer: e,\n startContainer: n,\n endContainer: o\n } = t, r = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);\n let i = r.nextNode(), s = !1;\n const a = [];\n for (; i != null; )\n i === o && (s = !1), s && a.push(i), i === n && (s = !0), i = r.nextNode();\n return a;\n}, In = (t) => {\n const { startContainer: e, endContainer: n } = t;\n if (e === n)\n return Array.from(t.getClientRects());\n {\n const { unwrap: o, nodes: r } = ee(t), i = r.reduce((s, a) => [...s, ...a.getClientRects()], []);\n return o(), i;\n }\n}, oe = (t, e, n = 10, o) => {\n const r = o ? t.startContainer.parentElement.closest(o) : e, i = document.createRange();\n i.setStart(r, 0), i.setEnd(t.startContainer, t.startOffset);\n const s = pt(i).textContent, a = document.createRange();\n a.setStart(t.endContainer, t.endOffset), r === document.body ? a.setEnd(r, r.childNodes.length) : a.setEndAfter(r);\n const u = pt(a).textContent;\n return {\n prefix: s.substring(s.length - n),\n suffix: u.substring(0, n)\n };\n}, re = /^\\s*$/, ie = (t) => re.test(t.toString()), $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), se = (t, e) => {\n const n = (i) => Math.round(i * 10) / 10, o = {\n top: n(t.top),\n bottom: n(t.bottom),\n left: n(t.left),\n right: n(t.right)\n }, r = {\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 - r.top) < 0.5 && Math.abs(o.bottom - r.bottom) < 0.5) {\n if (Math.abs(o.left - r.right) < 0.5 || Math.abs(o.right - r.left) < 0.5)\n return \"inline-adjacent\";\n if (o.left >= r.left && o.right <= r.right)\n return \"inline-is-contained\";\n if (o.left <= r.left && o.right >= r.right)\n return \"inline-contains\";\n } else if (o.top <= r.top && o.bottom >= r.bottom) {\n if (o.left <= r.left && o.right >= r.right)\n return \"block-contains\";\n } else if (o.top >= r.top && o.bottom <= r.bottom && o.left >= r.left && o.right <= r.right)\n return \"block-is-contained\";\n}, ae = (t, e) => {\n const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), r = Math.min(t.top, e.top), i = Math.max(t.bottom, e.bottom);\n return new DOMRect(n, r, o - n, i - r);\n}, ce = (t) => t.reduce((e, n) => {\n if (n.width === 0 || n.height === 0)\n return e;\n let o = [...e], r = !1;\n for (const i of e) {\n const s = se(n, i);\n if (s === \"inline-adjacent\") {\n o = o.map((a) => a === i ? ae(n, i) : a), r = !0;\n break;\n } else if (s === \"inline-contains\") {\n o = o.map((a) => a === i ? n : a), r = !0;\n break;\n } else if (s === \"inline-is-contained\") {\n r = !0;\n break;\n } else if (s === \"block-contains\" || s === \"block-is-contained\") {\n n.width < i.width && (o = o.map((a) => a === i ? n : a)), r = !0;\n break;\n }\n }\n return r ? o : [...o, n];\n}, []), le = (t, e, n) => {\n const o = document.createRange(), r = n ? t.startContainer.parentElement.closest(n) : e;\n o.setStart(r, 0), o.setEnd(t.startContainer, t.startOffset);\n const i = pt(o).textContent, s = t.toString(), a = i.length || 0, u = a + s.length;\n return n ? { quote: s, start: a, end: u, range: t, offsetReference: r } : { quote: s, start: a, end: u, range: t };\n}, Dt = (t, e) => {\n var g, d;\n const { start: n, end: o } = t, r = t.offsetReference || e, i = document.createNodeIterator(\n e,\n NodeFilter.SHOW_TEXT,\n (m) => {\n var h;\n return (h = m.parentElement) != null && h.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;\n }\n );\n let s = 0;\n const a = document.createRange();\n let u = i.nextNode();\n u === null && console.error(\"Could not revive annotation target. Content missing.\");\n let f = !r;\n for (; u !== null; ) {\n if (f || (f = r == null ? void 0 : r.contains(u)), f) {\n const m = ((g = u.textContent) == null ? void 0 : g.length) || 0;\n if (s + m > n) {\n a.setStart(u, n - s);\n break;\n }\n s += m;\n }\n u = i.nextNode();\n }\n for (; u !== null; ) {\n const m = ((d = u.textContent) == null ? void 0 : d.length) || 0;\n if (s + m >= o) {\n a.setEnd(u, o - s);\n break;\n }\n s += m, u = i.nextNode();\n }\n return {\n ...t,\n range: a\n };\n}, rt = (t, e) => $(t.selector) ? t : {\n ...t,\n selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Dt(n, e))\n}, it = (t, e) => $(t.target.selector) ? t : { ...t, target: rt(t.target, e) }, de = (t) => {\n const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: r } = window, i = -n, s = -e, a = o - n, u = r - e;\n return { top: e, left: n, minX: i, minY: s, maxX: a, maxY: u };\n}, ue = (t) => {\n let e = /* @__PURE__ */ new Set();\n return (o) => {\n const r = o.map((i) => i.id);\n (e.size !== r.length || r.some((i) => !e.has(i))) && t.set(r), e = new Set(r);\n };\n}, vt = (t, e, n, o) => {\n const { store: r, selection: i, hover: s } = e;\n let a, u, f;\n const g = ue(n), d = (B) => {\n const { x: M, y: v } = t.getBoundingClientRect(), x = r.getAt(B.clientX - M, B.clientY - v, u);\n x ? s.current !== x.id && (t.classList.add(\"hovered\"), s.set(x.id)) : s.current && (t.classList.remove(\"hovered\"), s.set(null));\n };\n t.addEventListener(\"pointermove\", d);\n const m = (B = !1) => {\n f && f.clear();\n const M = de(t), { minX: v, minY: x, maxX: A, maxY: C } = M, R = u ? r.getIntersecting(v, x, A, C).filter(({ annotation: _ }) => u(_)) : r.getIntersecting(v, x, A, C), O = i.selected.map(({ id: _ }) => _), H = R.map(({ annotation: _, rects: qt }) => {\n const jt = O.includes(_.id), Gt = _.id === s.current;\n return { annotation: _, rects: qt, state: { selected: jt, hover: Gt } };\n });\n o.redraw(H, M, a, f, B), setTimeout(() => g(R.map(({ annotation: _ }) => _)), 1);\n }, h = (B) => {\n f = B, m();\n }, w = (B) => {\n a = B, m();\n }, y = (B) => {\n u = B, m(!1);\n }, p = () => m();\n r.observe(p);\n const l = i.subscribe(() => m()), c = () => m(!0);\n document.addEventListener(\"scroll\", c, { capture: !0, passive: !0 });\n const b = bt(() => {\n r.recalculatePositions(), f && f.reset(), m();\n });\n window.addEventListener(\"resize\", b);\n const S = new ResizeObserver(b);\n S.observe(t);\n const L = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((B) => {\n B.every((v) => v.target === t || t.contains(v.target)) || m(!0);\n });\n return E.observe(document.body, L), {\n destroy: () => {\n t.removeEventListener(\"pointermove\", d), o.destroy(), r.unobserve(p), l(), document.removeEventListener(\"scroll\", c), window.removeEventListener(\"resize\", b), S.disconnect(), E.disconnect();\n },\n redraw: m,\n setStyle: w,\n setFilter: y,\n setPainter: h,\n setVisible: o.setVisible\n };\n}, he = () => {\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}, fe = (t, e) => {\n t.width = window.innerWidth, t.height = window.innerHeight;\n}, ge = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = he(), n = e.getContext(\"2d\");\n document.body.appendChild(e);\n const o = (a, u, f, g) => requestAnimationFrame(() => {\n const { width: d, height: m } = e;\n n.clearRect(-0.5, -0.5, d + 1, m + 1), g && g.clear();\n const { top: h, left: w } = u;\n [...a].sort((p, l) => {\n const { annotation: { target: { created: c } } } = p, { annotation: { target: { created: b } } } = l;\n return c.getTime() - b.getTime();\n }).forEach((p) => {\n var S;\n const l = f ? typeof f == \"function\" ? f(p.annotation, p.state) : f : (S = p.state) != null && S.selected ? ot : P, c = g && g.paint(p, u) || l, b = p.rects.map(({ x: L, y: E, width: T, height: B }) => ({\n x: L + w,\n y: E + h,\n width: T,\n height: B\n }));\n if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(\n ({ x: L, y: E, width: T, height: B }) => n.fillRect(L, E, T, B)\n ), c.underlineColor) {\n n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;\n const L = c.underlineOffset ?? 0;\n b.forEach(({ x: E, y: T, width: B, height: M }) => {\n n.beginPath(), n.moveTo(E, T + M + L), n.lineTo(E + B, T + M + L), n.stroke();\n });\n }\n });\n }), r = bt(() => {\n fe(e);\n });\n return window.addEventListener(\"resize\", r), {\n destroy: () => {\n e.remove(), window.removeEventListener(\"resize\", r);\n },\n setVisible: (a) => {\n console.log(\"setVisible not implemented on Canvas renderer\");\n },\n redraw: o\n };\n}, pe = (t, e, n) => vt(t, e, n, ge(t));\nvar me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {\n return typeof t == \"string\" ? t.length > 0 : typeof t == \"number\";\n}, I = function(t, e, n) {\n return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;\n}, 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}, _t = function(t) {\n return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;\n}, At = 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}, st = function(t) {\n return { r: I(t.r), g: I(t.g), b: I(t.b), a: I(t.a, 3) };\n}, be = /^#([0-9a-f]{3,8})$/i, J = function(t) {\n var e = t.toString(16);\n return e.length < 2 ? \"0\" + e : e;\n}, Xt = function(t) {\n var e = t.r, n = t.g, o = t.b, r = t.a, i = Math.max(e, n, o), s = i - Math.min(e, n, o), a = s ? i === e ? (n - o) / s : i === n ? 2 + (o - e) / s : 4 + (e - n) / s : 0;\n return { h: 60 * (a < 0 ? a + 6 : a), s: i ? s / i * 100 : 0, v: i / 255 * 100, a: r };\n}, $t = function(t) {\n var e = t.h, n = t.s, o = t.v, r = t.a;\n e = e / 360 * 6, n /= 100, o /= 100;\n var i = Math.floor(e), s = o * (1 - n), a = o * (1 - (e - i) * n), u = o * (1 - (1 - e + i) * n), f = i % 6;\n return { r: 255 * [o, a, s, s, u, o][f], g: 255 * [u, o, o, a, s, s][f], b: 255 * [s, s, u, o, o, a][f], a: r };\n}, Et = function(t) {\n return { h: _t(t.h), s: k(t.s, 0, 100), l: k(t.l, 0, 100), a: k(t.a) };\n}, St = function(t) {\n return { h: I(t.h), s: I(t.s), l: I(t.l), a: I(t.a, 3) };\n}, Ct = function(t) {\n return $t((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 = Xt(t)).h, s: (r = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && r < 200 ? n * o / 100 / (r <= 100 ? r : 200 - r) * 100 : 0, l: r / 2, a: e.a };\n var e, n, o, r;\n}, ve = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*,\\s*([+-]?\\d*\\.?\\d+)%\\s*(?:,\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, ye = /^hsla?\\(\\s*([+-]?\\d*\\.?\\d+)(deg|rad|grad|turn)?\\s+([+-]?\\d*\\.?\\d+)%\\s+([+-]?\\d*\\.?\\d+)%\\s*(?:\\/\\s*([+-]?\\d*\\.?\\d+)(%)?\\s*)?\\)$/i, we = /^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 = be.exec(t);\n return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? I(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? I(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;\n}, \"hex\"], [function(t) {\n var e = we.exec(t) || xe.exec(t);\n return e ? e[2] !== e[4] || e[4] !== e[6] ? null : At({ 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 = ve.exec(t) || ye.exec(t);\n if (!e) return null;\n var n, o, r = Et({ h: (n = e[1], o = e[2], o === void 0 && (o = \"deg\"), Number(n) * (me[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(r);\n}, \"hsl\"]], object: [[function(t) {\n var e = t.r, n = t.g, o = t.b, r = t.a, i = r === void 0 ? 1 : r;\n return X(e) && X(n) && X(o) ? At({ r: Number(e), g: Number(n), b: Number(o), a: Number(i) }) : null;\n}, \"rgb\"], [function(t) {\n var e = t.h, n = t.s, o = t.l, r = t.a, i = r === void 0 ? 1 : r;\n if (!X(e) || !X(n) || !X(o)) return null;\n var s = Et({ h: Number(e), s: Number(n), l: Number(o), a: Number(i) });\n return Ct(s);\n}, \"hsl\"], [function(t) {\n var e = t.h, n = t.s, o = t.v, r = t.a, i = r === void 0 ? 1 : r;\n if (!X(e) || !X(n) || !X(o)) return null;\n var s = function(a) {\n return { h: _t(a.h), s: k(a.s, 0, 100), v: k(a.v, 0, 100), a: k(a.a) };\n }({ h: Number(e), s: Number(n), v: Number(o), a: Number(i) });\n return $t(s);\n}, \"hsv\"]] }, Bt = 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}, Ae = function(t) {\n return typeof t == \"string\" ? Bt(t.trim(), Lt.string) : typeof t == \"object\" && t !== null ? Bt(t, Lt.object) : [null, void 0];\n}, at = 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}, ct = function(t) {\n return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;\n}, Tt = 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}, Rt = function() {\n function t(e) {\n this.parsed = Ae(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };\n }\n return t.prototype.isValid = function() {\n return this.parsed !== null;\n }, t.prototype.brightness = function() {\n return I(ct(this.rgba), 2);\n }, t.prototype.isDark = function() {\n return ct(this.rgba) < 0.5;\n }, t.prototype.isLight = function() {\n return ct(this.rgba) >= 0.5;\n }, t.prototype.toHex = function() {\n return e = st(this.rgba), n = e.r, o = e.g, r = e.b, s = (i = e.a) < 1 ? J(I(255 * i)) : \"\", \"#\" + J(n) + J(o) + J(r) + s;\n var e, n, o, r, i, s;\n }, t.prototype.toRgb = function() {\n return st(this.rgba);\n }, t.prototype.toRgbString = function() {\n return e = st(this.rgba), n = e.r, o = e.g, r = e.b, (i = e.a) < 1 ? \"rgba(\" + n + \", \" + o + \", \" + r + \", \" + i + \")\" : \"rgb(\" + n + \", \" + o + \", \" + r + \")\";\n var e, n, o, r, i;\n }, t.prototype.toHsl = function() {\n return St(Q(this.rgba));\n }, t.prototype.toHslString = function() {\n return e = St(Q(this.rgba)), n = e.h, o = e.s, r = e.l, (i = e.a) < 1 ? \"hsla(\" + n + \", \" + o + \"%, \" + r + \"%, \" + i + \")\" : \"hsl(\" + n + \", \" + o + \"%, \" + r + \"%)\";\n var e, n, o, r, i;\n }, t.prototype.toHsv = function() {\n return e = Xt(this.rgba), { h: I(e.h), s: I(e.s), v: I(e.v), a: I(e.a, 3) };\n var e;\n }, t.prototype.invert = function() {\n return Y({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });\n var e;\n }, t.prototype.saturate = function(e) {\n return e === void 0 && (e = 0.1), Y(at(this.rgba, e));\n }, t.prototype.desaturate = function(e) {\n return e === void 0 && (e = 0.1), Y(at(this.rgba, -e));\n }, t.prototype.grayscale = function() {\n return Y(at(this.rgba, -1));\n }, t.prototype.lighten = function(e) {\n return e === void 0 && (e = 0.1), Y(Tt(this.rgba, e));\n }, t.prototype.darken = function(e) {\n return e === void 0 && (e = 0.1), Y(Tt(this.rgba, -e));\n }, t.prototype.rotate = function(e) {\n return e === void 0 && (e = 15), this.hue(this.hue() + e);\n }, t.prototype.alpha = function(e) {\n return typeof e == \"number\" ? Y({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : I(this.rgba.a, 3);\n var n;\n }, t.prototype.hue = function(e) {\n var n = Q(this.rgba);\n return typeof e == \"number\" ? Y({ h: e, s: n.s, l: n.l, a: n.a }) : I(n.h);\n }, t.prototype.isEqual = function(e) {\n return this.toHex() === Y(e).toHex();\n }, t;\n}(), Y = function(t) {\n return t instanceof Rt ? t : new Rt(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(\";\"), Se = () => {\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: (i) => {\n console.log(\"setVisible not implemented on CSS Custom Highlights renderer\");\n },\n redraw: (i, s, a, u) => {\n u && u.clear();\n const f = new Set(i.map((d) => d.annotation.id));\n Array.from(e).filter((d) => !f.has(d));\n const g = i.map((d) => {\n var w;\n const m = a ? typeof a == \"function\" ? a(d.annotation, d.state) : a : (w = d.state) != null && w.selected ? ot : P, h = u && u.paint(d, s) || m;\n return `::highlight(_${d.annotation.id}) { ${Ee(h)} }`;\n });\n t.innerHTML = g.join(`\n`), CSS.highlights.clear(), i.forEach(({ annotation: d }) => {\n const m = d.target.selector.map((w) => w.range), h = new Highlight(...m);\n CSS.highlights.set(`_${d.id}`, h);\n }), e = f;\n }\n };\n}, Ce = (t, e, n) => vt(t, e, n, Se());\nvar Nt = Object.prototype.hasOwnProperty;\nfunction mt(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-- && mt(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 (Nt.call(t, n) && ++o && !Nt.call(e, n) || !(n in e) || !mt(t[n], e[n])) return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nconst Le = (t, e) => {\n const n = (i, s) => i.x <= s.x + s.width && i.x + i.width >= s.x && i.y <= s.y + s.height && i.y + i.height >= s.y, o = (i) => i.rects.reduce((s, a) => s + a.width, 0), r = e.filter(({ rects: i }) => i.some((s) => n(t, s)));\n return r.sort((i, s) => o(s) - o(i)), r.findIndex((i) => i.rects.includes(t));\n}, Be = (t) => {\n t.classList.add(\"r6o-annotatable\");\n const e = document.createElement(\"div\");\n e.className = \"r6o-span-highlight-layer\", t.insertBefore(e, t.firstChild);\n let n = [];\n return {\n destroy: () => {\n e.remove();\n },\n redraw: (s, a, u, f, g) => {\n const m = !(mt(n, s) && g);\n !f && !m || (m && (e.innerHTML = \"\"), s.forEach((h) => {\n h.rects.map((w) => {\n const y = Le(w, s), p = Kt(h, a, u, f, y);\n if (m) {\n const l = document.createElement(\"span\");\n l.className = \"r6o-annotation\", l.dataset.annotation = h.annotation.id, l.style.left = `${w.x}px`, l.style.top = `${w.y}px`, l.style.width = `${w.width}px`, l.style.height = `${w.height}px`, l.style.backgroundColor = Y((p == null ? void 0 : p.fill) || P.fill).alpha((p == null ? void 0 : p.fillOpacity) === void 0 ? P.fillOpacity : p.fillOpacity).toHex(), p.underlineStyle && (l.style.borderStyle = p.underlineStyle), p.underlineColor && (l.style.borderColor = p.underlineColor), p.underlineThickness && (l.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (l.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(l);\n }\n });\n }), n = s);\n },\n setVisible: (s) => {\n s ? e.classList.remove(\"hidden\") : e.classList.add(\"hidden\");\n }\n };\n}, Te = (t, e, n) => vt(t, e, n, Be(t));\nvar U = [];\nfor (var lt = 0; lt < 256; ++lt)\n U.push((lt + 256).toString(16).slice(1));\nfunction Re(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, Ne = new Uint8Array(16);\nfunction Me() {\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(Ne);\n}\nvar Oe = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Mt = {\n randomUUID: Oe\n};\nfunction Ht(t, e, n) {\n if (Mt.randomUUID && !e && !t)\n return Mt.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || Me)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Re(o);\n}\nvar Ot = Object.prototype.hasOwnProperty;\nfunction q(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-- && q(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 (Ot.call(t, n) && ++o && !Ot.call(e, n) || !(n in e) || !q(t[n], e[n])) return !1;\n return Object.keys(e).length === o;\n }\n }\n return t !== t && e !== e;\n}\nfunction dt() {\n}\nfunction Ie(t, e) {\n return t != t ? e == e : t !== e || t && typeof t == \"object\" || typeof t == \"function\";\n}\nconst F = [];\nfunction yt(t, e = dt) {\n let n;\n const o = /* @__PURE__ */ new Set();\n function r(a) {\n if (Ie(t, a) && (t = a, n)) {\n const u = !F.length;\n for (const f of o)\n f[1](), F.push(f, t);\n if (u) {\n for (let f = 0; f < F.length; f += 2)\n F[f][0](F[f + 1]);\n F.length = 0;\n }\n }\n }\n function i(a) {\n r(a(t));\n }\n function s(a, u = dt) {\n const f = [a, u];\n return o.add(f), o.size === 1 && (n = e(r, i) || dt), a(t), () => {\n o.delete(f), o.size === 0 && n && (n(), n = null);\n };\n }\n return { set: r, update: i, subscribe: s };\n}\nconst Ue = (t) => {\n const { subscribe: e, set: n } = yt();\n let o;\n return e((r) => o = r), t.observe(({ changes: r }) => {\n if (o) {\n (r.deleted || []).some((s) => s.id === o) && n(void 0);\n const i = (r.updated || []).find(({ oldValue: s }) => s.id === o);\n i && n(i.newValue.id);\n }\n }), {\n get current() {\n return o;\n },\n subscribe: e,\n set: n\n };\n};\nvar Ve = /* @__PURE__ */ ((t) => (t.EDIT = \"EDIT\", t.SELECT = \"SELECT\", t.NONE = \"NONE\", t))(Ve || {});\nconst ut = { selected: [] }, ke = (t, e = \"EDIT\") => {\n const { subscribe: n, set: o } = yt(ut);\n let r = e, i = ut;\n n((h) => i = h);\n const s = () => o(ut), a = () => {\n var h;\n return ((h = i.selected) == null ? void 0 : h.length) === 0;\n }, u = (h) => {\n if (a())\n return !1;\n const w = typeof h == \"string\" ? h : h.id;\n return i.selected.some((y) => y.id === w);\n }, f = (h, w) => {\n const y = t.getAnnotation(h);\n if (!y) {\n console.warn(\"Invalid selection: \" + h);\n return;\n }\n switch (It(y, r)) {\n case \"EDIT\":\n o({ selected: [{ id: h, editable: !0 }], event: w });\n break;\n case \"SELECT\":\n o({ selected: [{ id: h }], event: w });\n break;\n default:\n o({ selected: [], event: w });\n }\n }, g = (h, w) => {\n const y = Array.isArray(h) ? h : [h], p = y.map((l) => t.getAnnotation(l)).filter((l) => !!l);\n o({\n selected: p.map((l) => {\n const c = w === void 0 ? It(l, r) === \"EDIT\" : w;\n return { id: l.id, editable: c };\n })\n }), p.length !== y.length && console.warn(\"Invalid selection\", h);\n }, d = (h) => {\n if (a())\n return !1;\n const { selected: w } = i;\n w.some(({ id: y }) => h.includes(y)) && o({ selected: w.filter(({ id: y }) => !h.includes(y)) });\n }, m = (h) => r = h;\n return t.observe(\n ({ changes: h }) => d((h.deleted || []).map((w) => w.id))\n ), {\n get event() {\n return i ? i.event : null;\n },\n get selected() {\n return i ? [...i.selected] : null;\n },\n clear: s,\n isEmpty: a,\n isSelected: u,\n setSelected: g,\n setUserSelectAction: m,\n subscribe: n,\n userSelect: f\n };\n}, It = (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 Ye(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 tt, De = new Uint8Array(16);\nfunction _e() {\n if (!tt && (tt = typeof crypto < \"u\" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !tt))\n throw new Error(\"crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported\");\n return tt(De);\n}\nvar Xe = typeof crypto < \"u\" && crypto.randomUUID && crypto.randomUUID.bind(crypto);\nconst Ut = {\n randomUUID: Xe\n};\nfunction $e(t, e, n) {\n if (Ut.randomUUID && !e && !t)\n return Ut.randomUUID();\n t = t || {};\n var o = t.random || (t.rng || _e)();\n return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ye(o);\n}\nconst Un = (t, e, n, o) => ({\n id: $e(),\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}, Fe = (t, e) => e.bodies.map((n) => {\n const o = t.bodies.find((r) => r.id === n.id);\n return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };\n}).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), ze = (t, e) => !q(t.target, e.target), Pt = (t, e) => {\n const n = He(t, e), o = Pe(t, e), r = Fe(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: r.length > 0 ? r : void 0,\n targetUpdated: ze(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0\n };\n};\nvar N = /* @__PURE__ */ ((t) => (t.LOCAL = \"LOCAL\", t.REMOTE = \"REMOTE\", t))(N || {});\nconst We = (t, e) => {\n var n, o;\n const { changes: r, origin: i } = e;\n if (!(!t.options.origin || t.options.origin === i))\n return !1;\n if (t.options.ignore) {\n const { ignore: s } = t.options, a = (u) => u && u.length > 0;\n if (!(a(r.created) || a(r.deleted))) {\n const u = (n = r.updated) == null ? void 0 : n.some((g) => a(g.bodiesCreated) || a(g.bodiesDeleted) || a(g.bodiesUpdated)), f = (o = r.updated) == null ? void 0 : o.some((g) => g.targetUpdated);\n if (s === \"BODY_ONLY\" && u && !f || s === \"TARGET_ONLY\" && f && !u)\n return !1;\n }\n }\n if (t.options.annotations) {\n const s = /* @__PURE__ */ new Set([\n ...(r.created || []).map((a) => a.id),\n ...(r.deleted || []).map((a) => a.id),\n ...(r.updated || []).map(({ oldValue: a }) => a.id)\n ]);\n return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => s.has(a));\n } else\n return !0;\n}, qe = (t, e) => {\n const n = new Set((t.created || []).map((d) => d.id)), o = new Set((t.updated || []).map(({ newValue: d }) => d.id)), r = new Set((e.created || []).map((d) => d.id)), i = new Set((e.deleted || []).map((d) => d.id)), s = new Set((e.updated || []).map(({ oldValue: d }) => d.id)), a = new Set((e.updated || []).filter(({ oldValue: d }) => n.has(d.id) || o.has(d.id)).map(({ oldValue: d }) => d.id)), u = [\n ...(t.created || []).filter((d) => !i.has(d.id)).map((d) => s.has(d.id) ? e.updated.find(({ oldValue: m }) => m.id === d.id).newValue : d),\n ...e.created || []\n ], f = [\n ...(t.deleted || []).filter((d) => !r.has(d.id)),\n ...(e.deleted || []).filter((d) => !n.has(d.id))\n ], g = [\n ...(t.updated || []).filter(({ newValue: d }) => !i.has(d.id)).map((d) => {\n const { oldValue: m, newValue: h } = d;\n if (s.has(h.id)) {\n const w = e.updated.find((y) => y.oldValue.id === h.id).newValue;\n return Pt(m, w);\n } else\n return d;\n }),\n ...(e.updated || []).filter(({ oldValue: d }) => !a.has(d.id))\n ];\n return { created: u, deleted: f, updated: g };\n}, je = (t) => t.id !== void 0, Ge = () => {\n const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (v, x = {}) => n.push({ onChange: v, options: x }), r = (v) => {\n const x = n.findIndex((A) => A.onChange == v);\n x > -1 && n.splice(x, 1);\n }, i = (v, x) => {\n const A = {\n origin: v,\n changes: {\n created: x.created || [],\n updated: x.updated || [],\n deleted: x.deleted || []\n },\n state: [...t.values()]\n };\n n.forEach((C) => {\n We(C, A) && C.onChange(A);\n });\n }, s = (v, x = N.LOCAL) => {\n if (t.get(v.id))\n throw Error(`Cannot add annotation ${v.id} - exists already`);\n t.set(v.id, v), v.bodies.forEach((A) => e.set(A.id, v.id)), i(x, { created: [v] });\n }, a = (v, x) => {\n const A = typeof v == \"string\" ? x : v, C = typeof v == \"string\" ? v : v.id, R = t.get(C);\n if (R) {\n const O = Pt(R, A);\n return C === A.id ? t.set(C, A) : (t.delete(C), t.set(A.id, A)), R.bodies.forEach((H) => e.delete(H.id)), A.bodies.forEach((H) => e.set(H.id, A.id)), O;\n } else\n console.warn(`Cannot update annotation ${C} - does not exist`);\n }, u = (v, x = N.LOCAL, A = N.LOCAL) => {\n const C = je(x) ? A : x, R = a(v, x);\n R && i(C, { updated: [R] });\n }, f = (v, x = N.LOCAL) => {\n const A = v.reduce((C, R) => {\n const O = a(R);\n return O ? [...C, O] : C;\n }, []);\n A.length > 0 && i(x, { updated: A });\n }, g = (v, x = N.LOCAL) => {\n const A = t.get(v.annotation);\n if (A) {\n const C = {\n ...A,\n bodies: [...A.bodies, v]\n };\n t.set(A.id, C), e.set(v.id, C.id), i(x, { updated: [{\n oldValue: A,\n newValue: C,\n bodiesCreated: [v]\n }] });\n } else\n console.warn(`Attempt to add body to missing annotation: ${v.annotation}`);\n }, d = () => [...t.values()], m = (v = N.LOCAL) => {\n const x = [...t.values()];\n t.clear(), e.clear(), i(v, { deleted: x });\n }, h = (v, x = !0, A = N.LOCAL) => {\n if (x) {\n const C = [...t.values()];\n t.clear(), e.clear(), v.forEach((R) => {\n t.set(R.id, R), R.bodies.forEach((O) => e.set(O.id, R.id));\n }), i(A, { created: v, deleted: C });\n } else {\n const C = v.reduce((R, O) => {\n const H = t.get(O.id);\n return H ? [...R, H] : R;\n }, []);\n if (C.length > 0)\n throw Error(`Bulk insert would overwrite the following annotations: ${C.map((R) => R.id).join(\", \")}`);\n v.forEach((R) => {\n t.set(R.id, R), R.bodies.forEach((O) => e.set(O.id, R.id));\n }), i(A, { created: v });\n }\n }, w = (v) => {\n const x = typeof v == \"string\" ? v : v.id, A = t.get(x);\n if (A)\n return t.delete(x), A.bodies.forEach((C) => e.delete(C.id)), A;\n console.warn(`Attempt to delete missing annotation: ${x}`);\n }, y = (v, x = N.LOCAL) => {\n const A = w(v);\n A && i(x, { deleted: [A] });\n }, p = (v, x = N.LOCAL) => {\n const A = v.reduce((C, R) => {\n const O = w(R);\n return O ? [...C, O] : C;\n }, []);\n A.length > 0 && i(x, { deleted: A });\n }, l = (v) => {\n const x = t.get(v.annotation);\n if (x) {\n const A = x.bodies.find((C) => C.id === v.id);\n if (A) {\n e.delete(A.id);\n const C = {\n ...x,\n bodies: x.bodies.filter((R) => R.id !== v.id)\n };\n return t.set(x.id, C), {\n oldValue: x,\n newValue: C,\n bodiesDeleted: [A]\n };\n } else\n console.warn(`Attempt to delete missing body ${v.id} from annotation ${v.annotation}`);\n } else\n console.warn(`Attempt to delete body from missing annotation ${v.annotation}`);\n }, c = (v, x = N.LOCAL) => {\n const A = l(v);\n A && i(x, { updated: [A] });\n }, b = (v, x = N.LOCAL) => {\n const A = v.map((C) => l(C)).filter(Boolean);\n A.length > 0 && i(x, { updated: A });\n }, S = (v) => {\n const x = t.get(v);\n return x ? { ...x } : void 0;\n }, L = (v) => {\n const x = e.get(v);\n if (x) {\n const A = S(x).bodies.find((C) => C.id === v);\n if (A)\n return A;\n console.error(`Store integrity error: body ${v} in index, but not in annotation`);\n } else\n console.warn(`Attempt to retrieve missing body: ${v}`);\n }, E = (v, x) => {\n if (v.annotation !== x.annotation)\n throw \"Annotation integrity violation: annotation ID must be the same when updating bodies\";\n const A = t.get(v.annotation);\n if (A) {\n const C = A.bodies.find((O) => O.id === v.id), R = {\n ...A,\n bodies: A.bodies.map((O) => O.id === C.id ? x : O)\n };\n return t.set(A.id, R), C.id !== x.id && (e.delete(C.id), e.set(x.id, R.id)), {\n oldValue: A,\n newValue: R,\n bodiesUpdated: [{ oldBody: C, newBody: x }]\n };\n } else\n console.warn(`Attempt to add body to missing annotation ${v.annotation}`);\n }, T = (v, x, A = N.LOCAL) => {\n const C = E(v, x);\n C && i(A, { updated: [C] });\n }, B = (v, x = N.LOCAL) => {\n const A = v.map((C) => E({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);\n i(x, { updated: A });\n }, M = (v) => {\n const x = t.get(v.annotation);\n if (x) {\n const A = {\n ...x,\n target: {\n ...x.target,\n ...v\n }\n };\n return t.set(x.id, A), {\n oldValue: x,\n newValue: A,\n targetUpdated: {\n oldTarget: x.target,\n newTarget: v\n }\n };\n } else\n console.warn(`Attempt to update target on missing annotation: ${v.annotation}`);\n };\n return {\n addAnnotation: s,\n addBody: g,\n all: d,\n bulkAddAnnotation: h,\n bulkDeleteAnnotation: p,\n bulkDeleteBodies: b,\n bulkUpdateAnnotation: f,\n bulkUpdateBodies: B,\n bulkUpdateTargets: (v, x = N.LOCAL) => {\n const A = v.map((C) => M(C)).filter(Boolean);\n A.length > 0 && i(x, { updated: A });\n },\n clear: m,\n deleteAnnotation: y,\n deleteBody: c,\n getAnnotation: S,\n getBody: L,\n observe: o,\n unobserve: r,\n updateAnnotation: u,\n updateBody: T,\n updateTarget: (v, x = N.LOCAL) => {\n const A = M(v);\n A && i(x, { updated: [A] });\n }\n };\n};\nlet Ke = () => ({\n emit(t, ...e) {\n for (let n = 0, o = this.events[t] || [], r = o.length; n < r; 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((r) => e !== r);\n };\n }\n});\nconst Qe = 250, Je = (t) => {\n const e = Ke(), n = [];\n let o = -1, r = !1, i = 0;\n const s = (h) => {\n if (!r) {\n const { changes: w } = h, y = performance.now();\n if (y - i > Qe)\n n.splice(o + 1), n.push(w), o = n.length - 1;\n else {\n const p = n.length - 1;\n n[p] = qe(n[p], w);\n }\n i = y;\n }\n r = !1;\n };\n t.observe(s, { origin: N.LOCAL });\n const a = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), u = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), f = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: w }) => w)), g = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: w }) => w)), d = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), m = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h);\n return {\n canRedo: () => n.length - 1 > o,\n canUndo: () => o > -1,\n destroy: () => t.unobserve(s),\n on: (h, w) => e.on(h, w),\n redo: () => {\n if (n.length - 1 > o) {\n r = !0;\n const { created: h, updated: w, deleted: y } = n[o + 1];\n u(h), g(w), m(y), e.emit(\"redo\", n[o + 1]), o += 1;\n }\n },\n undo: () => {\n if (o > -1) {\n r = !0;\n const { created: h, updated: w, deleted: y } = n[o];\n a(h), f(w), d(y), e.emit(\"undo\", n[o]), o -= 1;\n }\n }\n };\n}, Ze = () => {\n const { subscribe: t, set: e } = yt([]);\n return {\n subscribe: t,\n set: e\n };\n}, tn = (t, e, n, o) => {\n const { store: r, selection: i, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();\n let f = [], g;\n const d = (y, p) => {\n u.has(y) ? u.get(y).push(p) : u.set(y, [p]);\n }, m = (y, p) => {\n const l = u.get(y);\n if (l) {\n const c = l.indexOf(p);\n c !== -1 && l.splice(c, 1);\n }\n }, h = (y, p, l) => {\n u.has(y) && setTimeout(() => {\n u.get(y).forEach((c) => {\n if (n) {\n const b = Array.isArray(p) ? p.map((L) => n.serialize(L)) : n.serialize(p), S = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;\n c(b, S);\n } else\n c(p, l);\n });\n }, 1);\n };\n i.subscribe(({ selected: y }) => {\n if (!(f.length === 0 && y.length === 0)) {\n if (f.length === 0 && y.length > 0)\n f = y.map(({ id: p }) => r.getAnnotation(p));\n else if (f.length > 0 && y.length === 0)\n f.forEach((p) => {\n const l = r.getAnnotation(p.id);\n l && !q(l, p) && h(\"updateAnnotation\", l, p);\n }), f = [];\n else {\n const p = new Set(f.map((c) => c.id)), l = new Set(y.map(({ id: c }) => c));\n f.filter((c) => !l.has(c.id)).forEach((c) => {\n const b = r.getAnnotation(c.id);\n b && !q(b, c) && h(\"updateAnnotation\", b, c);\n }), f = [\n // Remove annotations that were deselected\n ...f.filter((c) => l.has(c.id)),\n // Add editable annotations that were selected\n ...y.filter(({ id: c }) => !p.has(c)).map(({ id: c }) => r.getAnnotation(c))\n ];\n }\n h(\"selectionChanged\", f);\n }\n }), s.subscribe((y) => {\n !g && y ? h(\"mouseEnterAnnotation\", r.getAnnotation(y)) : g && !y ? h(\"mouseLeaveAnnotation\", r.getAnnotation(g)) : g && y && (h(\"mouseLeaveAnnotation\", r.getAnnotation(g)), h(\"mouseEnterAnnotation\", r.getAnnotation(y))), g = y;\n }), a == null || a.subscribe((y) => h(\"viewportIntersect\", y.map((p) => r.getAnnotation(p)))), r.observe((y) => {\n const { created: p, deleted: l } = y.changes;\n (p || []).forEach((c) => h(\"createAnnotation\", c)), (l || []).forEach((c) => h(\"deleteAnnotation\", c)), (y.changes.updated || []).filter((c) => [\n ...c.bodiesCreated || [],\n ...c.bodiesDeleted || [],\n ...c.bodiesUpdated || []\n ].length > 0).forEach(({ oldValue: c, newValue: b }) => {\n const S = f.find((L) => L.id === c.id) || c;\n f = f.map((L) => L.id === c.id ? b : L), h(\"updateAnnotation\", b, S);\n });\n }, { origin: N.LOCAL }), r.observe((y) => {\n if (f) {\n const p = new Set(f.map((c) => c.id)), l = (y.changes.updated || []).filter(({ newValue: c }) => p.has(c.id)).map(({ newValue: c }) => c);\n l.length > 0 && (f = f.map((c) => l.find((S) => S.id === c.id) || c));\n }\n }, { origin: N.REMOTE });\n const w = (y) => (p) => {\n const { updated: l } = p;\n y ? (l || []).forEach((c) => h(\"updateAnnotation\", c.oldValue, c.newValue)) : (l || []).forEach((c) => h(\"updateAnnotation\", c.newValue, c.oldValue));\n };\n return e.on(\"undo\", w(!0)), e.on(\"redo\", w(!1)), { on: d, off: m, emit: h };\n}, en = (t) => (e) => e.reduce((n, o) => {\n const { parsed: r, error: i } = t.parse(o);\n return i ? {\n parsed: n.parsed,\n failed: [...n.failed, o]\n } : r ? {\n parsed: [...n.parsed, r],\n failed: n.failed\n } : {\n ...n\n };\n}, { parsed: [], failed: [] }), nn = (t, e, n) => {\n const { store: o, selection: r } = t, i = (l) => {\n if (n) {\n const { parsed: c, error: b } = n.parse(l);\n c ? o.addAnnotation(c, N.REMOTE) : console.error(b);\n } else\n o.addAnnotation(l, N.REMOTE);\n }, s = () => r.clear(), a = () => o.clear(), u = (l) => {\n const c = o.getAnnotation(l);\n return n && c ? n.serialize(c) : c;\n }, f = () => n ? o.all().map(n.serialize) : o.all(), g = () => {\n var l;\n const c = (((l = r.selected) == null ? void 0 : l.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);\n return n ? c.map(n.serialize) : c;\n }, d = (l, c = !0) => fetch(l).then((b) => b.json()).then((b) => (h(b, c), b)), m = (l) => {\n if (typeof l == \"string\") {\n const c = o.getAnnotation(l);\n if (o.deleteAnnotation(l), c)\n return n ? n.serialize(c) : c;\n } else {\n const c = n ? n.parse(l).parsed : l;\n if (c)\n return o.deleteAnnotation(c), l;\n }\n }, h = (l, c = !0) => {\n if (n) {\n const { parsed: b, failed: S } = en(n)(l);\n S.length > 0 && console.warn(`Discarded ${S.length} invalid annotations`, S), o.bulkAddAnnotation(b, c, N.REMOTE);\n } else\n o.bulkAddAnnotation(l, c, N.REMOTE);\n }, w = (l, c) => {\n l ? r.setSelected(l, c) : r.clear();\n }, y = (l) => {\n r.clear(), r.setUserSelectAction(l);\n }, p = (l) => {\n if (n) {\n const c = n.parse(l).parsed, b = n.serialize(o.getAnnotation(c.id));\n return o.updateAnnotation(c), b;\n } else {\n const c = o.getAnnotation(l.id);\n return o.updateAnnotation(l), c;\n }\n };\n return {\n addAnnotation: i,\n cancelSelected: s,\n canRedo: e.canRedo,\n canUndo: e.canUndo,\n clearAnnotations: a,\n getAnnotationById: u,\n getAnnotations: f,\n getSelected: g,\n loadAnnotations: d,\n redo: e.redo,\n removeAnnotation: m,\n setAnnotations: h,\n setSelected: w,\n setUserSelectAction: y,\n undo: e.undo,\n updateAnnotation: p\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, r = -~(1.6 * o * e / t.length);\n return (i = e) => {\n let s = \"\";\n for (; ; ) {\n let a = n(r), u = r;\n for (; u--; )\n if (s += t[a[u] & o] || \"\", s.length === i) return s;\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, r = e.length; o < r; o++) {\n let i = e.charCodeAt(o);\n n = (n << 5) - n + i, 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: r, purpose: i, value: s, created: a, modified: u, creator: f, ...g } = n;\n return {\n id: o || `temp-${dn(n)}`,\n annotation: e,\n type: r,\n purpose: i,\n value: s,\n creator: Ft(f),\n created: a ? new Date(a) : void 0,\n updated: u ? new Date(u) : void 0,\n ...g\n };\n}), hn = (t) => t.map((e) => {\n var n;\n const { annotation: o, created: r, updated: i, ...s } = e, a = {\n ...s,\n created: r == null ? void 0 : r.toISOString(),\n modified: i == null ? void 0 : i.toISOString()\n };\n return (n = a.id) != null && n.startsWith(\"temp-\") && delete a.id, a;\n});\ncn();\nconst Vn = (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: r,\n target: i\n } = t, s = Array.isArray(i) ? i : [i], a = {\n creator: Ft(n),\n created: o ? new Date(o) : void 0,\n updated: r ? new Date(r) : void 0,\n annotation: e,\n selector: []\n };\n for (const u of s) {\n const g = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((d, m) => {\n switch (m.type) {\n case \"TextQuoteSelector\":\n d.quote = m.exact;\n break;\n case \"TextPositionSelector\":\n d.start = m.start, d.end = m.end;\n break;\n }\n return d;\n }, {});\n if (fn(g))\n a.selector.push({ id: u.id, ...g });\n else {\n const d = [\n g.start ? void 0 : \"TextPositionSelector\",\n g.quote ? void 0 : \"TextQuoteSelector\"\n ].filter(Boolean);\n return { error: Error(`Missing selector types: ${d.join(\" and \")} for annotation: ${t.id}`) };\n }\n }\n return { parsed: a };\n}, pn = (t) => {\n const e = t.id || Ht(), {\n creator: n,\n created: o,\n modified: r,\n body: i,\n ...s\n } = t, a = un(i, e), u = gn(t);\n return \"error\" in u ? { error: u.error } : {\n parsed: {\n ...s,\n id: e,\n bodies: a,\n target: u.parsed\n }\n };\n}, mn = (t, e, n) => {\n const { bodies: o, target: r, ...i } = t, {\n selector: s,\n creator: a,\n created: u,\n updated: f,\n ...g\n } = r, d = s.map((m) => {\n const { quote: h, start: w, end: y, range: p } = m, { prefix: l, suffix: c } = oe(p, n), b = [{\n type: \"TextQuoteSelector\",\n exact: h,\n prefix: l,\n suffix: c\n }, {\n type: \"TextPositionSelector\",\n start: w,\n end: y\n }];\n return {\n ...g,\n id: m.id,\n source: e,\n selector: b\n };\n });\n return {\n ...i,\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: u == null ? void 0 : u.toISOString(),\n modified: f == null ? void 0 : f.toISOString(),\n target: d\n };\n};\nfunction bn(t, e, n, o, r) {\n zt(t, e, n || 0, o || t.length - 1, r || vn);\n}\nfunction zt(t, e, n, o, r) {\n for (; o > n; ) {\n if (o - n > 600) {\n var i = o - n + 1, s = e - n + 1, a = Math.log(i), u = 0.5 * Math.exp(2 * a / 3), f = 0.5 * Math.sqrt(a * u * (i - u) / i) * (s - i / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - s * u / i + f)), d = Math.min(o, Math.floor(e + (i - s) * u / i + f));\n zt(t, e, g, d, r);\n }\n var m = t[e], h = n, w = o;\n for (j(t, n, e), r(t[o], m) > 0 && j(t, n, o); h < w; ) {\n for (j(t, h, w), h++, w--; r(t[h], m) < 0; ) h++;\n for (; r(t[w], m) > 0; ) w--;\n }\n r(t[n], m) === 0 ? j(t, n, w) : (w++, j(t, w, o)), w <= e && (n = w + 1), e <= w && (o = w - 1);\n }\n}\nfunction j(t, e, n) {\n var o = t[e];\n t[e] = t[n], t[n] = o;\n}\nfunction vn(t, e) {\n return t < e ? -1 : t > e ? 1 : 0;\n}\nclass yn {\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 (!nt(e, n)) return o;\n const r = this.toBBox, i = [];\n for (; n; ) {\n for (let s = 0; s < n.children.length; s++) {\n const a = n.children[s], u = n.leaf ? r(a) : a;\n nt(e, u) && (n.leaf ? o.push(a) : gt(e, u) ? this._all(a, o) : i.push(a));\n }\n n = i.pop();\n }\n return o;\n }\n collides(e) {\n let n = this.data;\n if (!nt(e, n)) return !1;\n const o = [];\n for (; n; ) {\n for (let r = 0; r < n.children.length; r++) {\n const i = n.children[r], s = n.leaf ? this.toBBox(i) : i;\n if (nt(e, s)) {\n if (n.leaf || gt(e, s)) return !0;\n o.push(i);\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 r = this.toBBox(e), i = [], s = [];\n let a, u, f;\n for (; o || i.length; ) {\n if (o || (o = i.pop(), u = i[i.length - 1], a = s.pop(), f = !0), o.leaf) {\n const g = wn(e, o.children, n);\n if (g !== -1)\n return o.children.splice(g, 1), i.push(o), this._condense(i), this;\n }\n !f && !o.leaf && gt(o, r) ? (i.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], f = !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, r) {\n const i = o - n + 1;\n let s = this._maxEntries, a;\n if (i <= s)\n return a = W(e.slice(n, o + 1)), z(a, this.toBBox), a;\n r || (r = Math.ceil(Math.log(i) / Math.log(s)), s = Math.ceil(i / Math.pow(s, r - 1))), a = W([]), a.leaf = !1, a.height = r;\n const u = Math.ceil(i / s), f = u * Math.ceil(Math.sqrt(s));\n Vt(e, n, o, f, this.compareMinX);\n for (let g = n; g <= o; g += f) {\n const d = Math.min(g + f - 1, o);\n Vt(e, g, d, u, this.compareMinY);\n for (let m = g; m <= d; m += u) {\n const h = Math.min(m + u - 1, d);\n a.children.push(this._build(e, m, h, r - 1));\n }\n }\n return z(a, this.toBBox), a;\n }\n _chooseSubtree(e, n, o, r) {\n for (; r.push(n), !(n.leaf || r.length - 1 === o); ) {\n let i = 1 / 0, s = 1 / 0, a;\n for (let u = 0; u < n.children.length; u++) {\n const f = n.children[u], g = ft(f), d = En(e, f) - g;\n d < s ? (s = d, i = g < i ? g : i, a = f) : d === s && g < i && (i = g, a = f);\n }\n n = a || n.children[0];\n }\n return n;\n }\n _insert(e, n, o) {\n const r = o ? e : this.toBBox(e), i = [], s = this._chooseSubtree(r, this.data, n, i);\n for (s.children.push(e), K(s, r); n >= 0 && i[n].children.length > this._maxEntries; )\n this._split(i, n), n--;\n this._adjustParentBBoxes(r, i, n);\n }\n // split overflowed node into two\n _split(e, n) {\n const o = e[n], r = o.children.length, i = this._minEntries;\n this._chooseSplitAxis(o, i, r);\n const s = this._chooseSplitIndex(o, i, r), a = W(o.children.splice(s, o.children.length - s));\n a.height = o.height, a.leaf = o.leaf, z(o, this.toBBox), z(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, z(this.data, this.toBBox);\n }\n _chooseSplitIndex(e, n, o) {\n let r, i = 1 / 0, s = 1 / 0;\n for (let a = n; a <= o - n; a++) {\n const u = G(e, 0, a, this.toBBox), f = G(e, a, o, this.toBBox), g = Sn(u, f), d = ft(u) + ft(f);\n g < i ? (i = g, r = a, s = d < s ? d : s) : g === i && d < s && (s = d, r = a);\n }\n return r || o - n;\n }\n // sorts node children by the best axis for split\n _chooseSplitAxis(e, n, o) {\n const r = e.leaf ? this.compareMinX : xn, i = e.leaf ? this.compareMinY : An, s = this._allDistMargin(e, n, o, r), a = this._allDistMargin(e, n, o, i);\n s < a && e.children.sort(r);\n }\n // total margin of all possible split distributions where each node is at least m full\n _allDistMargin(e, n, o, r) {\n e.children.sort(r);\n const i = this.toBBox, s = G(e, 0, n, i), a = G(e, o - n, o, i);\n let u = et(s) + et(a);\n for (let f = n; f < o - n; f++) {\n const g = e.children[f];\n K(s, e.leaf ? i(g) : g), u += et(s);\n }\n for (let f = o - n - 1; f >= n; f--) {\n const g = e.children[f];\n K(a, e.leaf ? i(g) : g), u += et(a);\n }\n return u;\n }\n _adjustParentBBoxes(e, n, o) {\n for (let r = o; r >= 0; r--)\n K(n[r], 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() : z(e[n], this.toBBox);\n }\n}\nfunction wn(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 z(t, e) {\n G(t, 0, t.children.length, e, t);\n}\nfunction G(t, e, n, o, r) {\n r || (r = W(null)), r.minX = 1 / 0, r.minY = 1 / 0, r.maxX = -1 / 0, r.maxY = -1 / 0;\n for (let i = e; i < n; i++) {\n const s = t.children[i];\n K(r, t.leaf ? o(s) : s);\n }\n return r;\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 xn(t, e) {\n return t.minX - e.minX;\n}\nfunction An(t, e) {\n return t.minY - e.minY;\n}\nfunction ft(t) {\n return (t.maxX - t.minX) * (t.maxY - t.minY);\n}\nfunction et(t) {\n return t.maxX - t.minX + (t.maxY - t.minY);\n}\nfunction En(t, e) {\n return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));\n}\nfunction Sn(t, e) {\n const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), r = Math.min(t.maxX, e.maxX), i = Math.min(t.maxY, e.maxY);\n return Math.max(0, r - n) * Math.max(0, i - o);\n}\nfunction gt(t, e) {\n return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;\n}\nfunction nt(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, r) {\n const i = [e, n];\n for (; i.length; ) {\n if (n = i.pop(), e = i.pop(), n - e <= o) continue;\n const s = e + Math.ceil((n - e) / o / 2) * o;\n bn(t, s, e, n, r), i.push(e, s, s, n);\n }\n}\nconst Cn = (t, e) => {\n const n = new yn(), o = /* @__PURE__ */ new Map(), r = (l, c) => {\n const b = l.selector.flatMap((L) => {\n const E = $([L]) ? L.range : Dt(L, e).range;\n return Array.from(E.getClientRects());\n }), S = ce(b).map(({ left: L, top: E, right: T, bottom: B }) => new DOMRect(L - c.left, E - c.top, T - L, B - E));\n return S.map((L) => {\n const { x: E, y: T, width: B, height: M } = L;\n return {\n minX: E,\n minY: T,\n maxX: E + B,\n maxY: T + M,\n annotation: {\n id: l.annotation,\n rects: S\n }\n };\n });\n }, i = () => [...o.values()], s = () => {\n n.clear(), o.clear();\n }, a = (l) => {\n const c = r(l, e.getBoundingClientRect());\n c.forEach((b) => n.insert(b)), o.set(l.annotation, c);\n }, u = (l) => {\n const c = o.get(l.annotation);\n c && (c.forEach((b) => n.remove(b)), o.delete(l.annotation));\n }, f = (l) => {\n u(l), a(l);\n }, g = (l, c = !0) => {\n c && s();\n const b = e.getBoundingClientRect(), S = l.map((E) => ({ target: E, rects: r(E, b) }));\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 }, d = (l, c, b = !1) => {\n const S = n.search({\n minX: l,\n minY: c,\n maxX: l,\n maxY: c\n }), L = (E) => E.annotation.rects.reduce((T, B) => T + B.width * B.height, 0);\n return S.length > 0 ? (S.sort((E, T) => L(E) - L(T)), b ? S.map((E) => E.annotation.id) : [S[0].annotation.id]) : [];\n }, m = (l) => {\n const c = h(l);\n if (c.length === 0)\n return;\n let b = c[0].left, S = c[0].top, L = c[0].right, E = c[0].bottom;\n for (let T = 1; T < c.length; T++) {\n const B = c[T];\n b = Math.min(b, B.left), S = Math.min(S, B.top), L = Math.max(L, B.right), E = Math.max(E, B.bottom);\n }\n return new DOMRect(b, S, L - b, E - S);\n }, h = (l) => {\n const c = o.get(l);\n return c ? c[0].annotation.rects : [];\n };\n return {\n all: i,\n clear: s,\n getAt: d,\n getAnnotationBounds: m,\n getAnnotationRects: h,\n getIntersecting: (l, c, b, S) => {\n const L = n.search({ minX: l, minY: c, maxX: b, 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: h(T)\n })).filter((T) => !!T.annotation);\n },\n insert: a,\n recalculate: () => g(t.all().map((l) => l.target), !0),\n remove: u,\n set: g,\n size: () => n.all().length,\n update: f\n };\n}, Ln = (t, e) => {\n const n = Ge(), o = Cn(n, t), r = ke(n, e), i = Ue(n), s = Ze(), a = (y, p = N.LOCAL) => {\n const l = it(y, t), c = $(l.target.selector);\n return c && n.addAnnotation(l, p), c;\n }, u = (y, p = !0, l = N.LOCAL) => {\n const c = y.map((S) => it(S, t)), b = c.filter((S) => !$(S.target.selector));\n return b.length > 0 ? (console.warn(\"Could not revive all targets for these annotations:\", b), n.bulkAddAnnotation(c, p, l), b) : (n.bulkAddAnnotation(c, p, l), []);\n }, f = (y, p = N.LOCAL) => {\n const l = y.map((b) => it(b, t)), c = l.filter((b) => !$(b.target.selector));\n return c.length > 0 && console.warn(\"Could not revive all targets for these annotations:\", c), l.forEach((b) => {\n n.getAnnotation(b.id) ? n.updateAnnotation(b, p) : n.addAnnotation(b, p);\n }), c;\n }, g = (y, p = N.LOCAL) => {\n const l = rt(y, t);\n n.updateTarget(l, p);\n }, d = (y, p = N.LOCAL) => {\n const l = y.map((c) => rt(c, t));\n n.bulkUpdateTargets(l, p);\n }, m = (y, p, l) => {\n const c = o.getAt(y, p, !!l).map((S) => n.getAnnotation(S)), b = l ? c.filter(l) : c;\n return b.length > 0 ? b[0] : void 0;\n }, h = (y, p, l, c = 5) => {\n const b = o.getAnnotationRects(y);\n if (b.length !== 0) {\n if (p && l) {\n const S = b.find(({ top: L, right: E, bottom: T, left: B }) => p >= B - c && p <= E + c && l >= L - c && l <= T + c);\n if (S) return S;\n }\n return o.getAnnotationBounds(y);\n }\n }, w = () => o.recalculate();\n return n.observe(({ changes: y }) => {\n const p = (y.deleted || []).filter((b) => $(b.target.selector)), l = (y.created || []).filter((b) => $(b.target.selector)), c = (y.updated || []).filter((b) => $(b.newValue.target.selector));\n (p == null ? void 0 : p.length) > 0 && p.forEach((b) => o.remove(b.target)), l.length > 0 && o.set(l.map((b) => b.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: b }) => o.update(b.target));\n }), {\n store: {\n ...n,\n addAnnotation: a,\n bulkAddAnnotation: u,\n bulkUpdateTargets: d,\n bulkUpsertAnnotations: f,\n getAnnotationBounds: h,\n getAt: m,\n getIntersecting: o.getIntersecting,\n recalculatePositions: w,\n updateTarget: g\n },\n selection: r,\n hover: i,\n viewport: s\n };\n}, Bn = () => {\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 = {}) => {\n const o = Bn(), r = o.getContext(\"2d\");\n document.body.appendChild(o);\n const i = /* @__PURE__ */ new Map(), s = (d) => Array.from(i.entries()).filter(([m, h]) => h.presenceKey === d.presenceKey).map(([m, h]) => m);\n return e.on(\"selectionChange\", (d, m) => {\n s(d).forEach((w) => i.delete(w)), m && m.forEach((w) => i.set(w, d));\n }), {\n clear: () => {\n const { width: d, height: m } = o;\n r.clearRect(-0.5, -0.5, d + 1, m + 1);\n },\n destroy: () => {\n o.remove();\n },\n paint: (d, m, h) => {\n n.font && (r.font = n.font);\n const w = i.get(d.annotation.id);\n if (w) {\n const { height: y } = d.rects[0], p = d.rects[0].x + m.left, l = d.rects[0].y + m.top;\n r.fillStyle = w.appearance.color, r.fillRect(p - 2, l - 2.5, 2, y + 5);\n const c = r.measureText(w.appearance.label), b = c.width + 6, S = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;\n return r.fillRect(p - 2, l - 2.5 - S, b, S), r.fillStyle = \"#fff\", r.fillText(w.appearance.label, p + 1, l - L), {\n fill: w.appearance.color,\n fillOpacity: h ? 0.45 : 0.18\n };\n }\n },\n reset: () => {\n o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;\n const d = o.getContext(\"2d\");\n d.scale(2, 2), d.translate(0.5, 0.5);\n }\n };\n}, Wt = (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 : Wt(t.parentElement);\n}, Rn = (t, e) => (n) => {\n const o = typeof n == \"string\" ? n : n.id, r = (s) => {\n const a = i.getBoundingClientRect(), u = i.clientHeight, f = i.clientWidth, g = s.selector[0].range.getBoundingClientRect(), { width: d, height: m } = e.getAnnotationBounds(o), h = g.top - a.top, w = g.left - a.left, y = i.parentElement ? i.scrollTop : 0, p = i.parentElement ? i.scrollLeft : 0, l = h + y - (u - m) / 2, c = w + p - (f - d) / 2;\n i.scroll({ top: l, left: c, behavior: \"smooth\" });\n }, i = Wt(t);\n if (i) {\n const s = e.getAnnotation(o), { range: a } = s.target.selector[0];\n if (a && !a.collapsed)\n return r(s.target), !0;\n {\n const u = rt(s.target, t), { range: f } = u.selector[0];\n if (f && !f.collapsed)\n return r(u), !0;\n }\n }\n return !1;\n}, Nn = (t, e) => ({\n ...t,\n annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled\n}), Mn = (t, e, n, o) => {\n let r;\n const i = (c) => r = c;\n let s;\n const a = (c) => s = c, { store: u, selection: f } = e;\n let g, d = !1, m;\n const h = (c) => {\n var S;\n if (!d) return;\n !((S = c.target.parentElement) != null && S.closest(D)) ? g = {\n annotation: Ht(),\n selector: [],\n creator: r,\n created: /* @__PURE__ */ new Date()\n } : g = void 0;\n };\n n && t.addEventListener(\"selectstart\", h);\n const w = bt((c) => {\n var B, M;\n const b = document.getSelection();\n if (!!((M = (B = b.anchorNode) == null ? void 0 : B.parentElement) != null && M.closest(D))) {\n g = void 0;\n return;\n }\n if (c.timeStamp - ((m == null ? void 0 : m.timeStamp) || c.timeStamp) < 1e3 && !g && h(m), b.isCollapsed || !d || !g) return;\n const L = b.getRangeAt(0);\n if (ie(L)) return;\n const E = Zt(L.cloneRange());\n (E.length !== g.selector.length || E.some((v, x) => {\n var A;\n return v.toString() !== ((A = g.selector[x]) == null ? void 0 : A.quote);\n })) && (g = {\n ...g,\n selector: E.map((v) => le(v, t, o)),\n updated: /* @__PURE__ */ new Date()\n }, u.getAnnotation(g.annotation) ? u.updateTarget(g, N.LOCAL) : (f.clear(), u.addAnnotation({\n id: g.annotation,\n bodies: [],\n target: g\n }), f.userSelect(g.annotation, m)));\n });\n n && document.addEventListener(\"selectionchange\", w);\n const y = (c) => {\n const { target: b, timeStamp: S, offsetX: L, offsetY: E, type: T } = c;\n m = { ...c, target: b, timeStamp: S, offsetX: L, offsetY: E, type: T }, d = c.button === 0;\n };\n t.addEventListener(\"pointerdown\", y);\n const p = (c) => {\n var E;\n if (!!((E = c.target.parentElement) != null && E.closest(D)) || !d)\n return;\n const S = () => {\n const { x: T, y: B } = t.getBoundingClientRect(), M = u.getAt(c.clientX - T, c.clientY - B, s);\n if (M) {\n const { selected: v } = f;\n (v.length !== 1 || v[0].id !== M.id) && f.userSelect(M.id, c);\n } else f.isEmpty() || f.clear();\n }, L = c.timeStamp - m.timeStamp;\n document.getSelection().isCollapsed && L < 300 ? (g = void 0, S()) : g && f.userSelect(g.annotation, c);\n };\n return document.addEventListener(\"pointerup\", p), {\n destroy: () => {\n t.removeEventListener(\"selectstart\", h), document.removeEventListener(\"selectionchange\", w), t.removeEventListener(\"pointerdown\", y), document.removeEventListener(\"pointerup\", p);\n },\n setFilter: a,\n setUser: i\n };\n}, kt = \"SPANS\", kn = (t, e = {}) => {\n te(t);\n const n = Nn(e, {\n annotatingEnabled: !0\n }), o = Ln(t, n.userAction), { selection: r, viewport: i } = o, s = o.store, a = Je(s), u = tn(o, a, n.adapter);\n let f = ln();\n const g = n.renderer === \"CSS_HIGHLIGHTS\" ? CSS.highlights ? \"CSS_HIGHLIGHTS\" : kt : n.renderer || kt, d = g === \"SPANS\" ? Te(t, o, i) : g === \"CSS_HIGHLIGHTS\" ? Ce(t, o, i) : g === \"CANVAS\" ? pe(t, o, i) : void 0;\n if (!d)\n throw `Unknown renderer implementation: ${g}`;\n console.debug(`Using ${g} renderer`), n.style && d.setStyle(n.style);\n const m = Mn(t, o, n.annotatingEnabled, n.offsetReferenceSelector);\n return m.setUser(f), {\n ...nn(o, a, n.adapter),\n destroy: () => {\n d.destroy(), m.destroy(), a.destroy();\n },\n element: t,\n getUser: () => f,\n setFilter: (E) => {\n d.setFilter(E), m.setFilter(E);\n },\n setStyle: (E) => d.setStyle(E),\n setUser: (E) => {\n f = E, m.setUser(E);\n },\n setSelected: (E) => {\n E ? r.setSelected(E) : r.clear();\n },\n setPresenceProvider: (E) => {\n E && (d.setPainter(Tn(t, E, n.presence)), E.on(\"selectionChange\", () => d.redraw()));\n },\n setVisible: (E) => d.setVisible(E),\n on: u.on,\n off: u.off,\n scrollIntoView: Rn(t, s),\n state: o\n };\n};\nexport {\n ot as DEFAULT_SELECTED_STYLE,\n P as DEFAULT_STYLE,\n Yt as NOT_ANNOTATABLE_CLASS,\n D as NOT_ANNOTATABLE_SELECTOR,\n N as Origin,\n Ve as UserSelectAction,\n Vn as W3CTextFormat,\n te as cancelSingleClickEvents,\n Un as createBody,\n pe as createCanvasRenderer,\n Ce as createHighlightsRenderer,\n Se as createRenderer,\n Te as createSpansRenderer,\n kn as createTextAnnotator,\n Ln as createTextAnnotatorState,\n bt as debounce,\n Nn as fillDefaults,\n On as getAnnotatableFragment,\n In as getClientRectsPonyfill,\n oe as getQuoteContext,\n pt as getRangeAnnotatableContents,\n $ as isRevived,\n ie as isWhitespaceOrEmpty,\n ce as mergeClientRects,\n Kt as paint,\n pn as parseW3CTextAnnotation,\n le as rangeToSelector,\n it as reviveAnnotation,\n Dt as reviveSelector,\n rt as reviveTarget,\n mn as serializeW3CTextAnnotation,\n Zt as splitAnnotatableRanges,\n re as whitespaceOrEmptyRegex\n};\n//# sourceMappingURL=text-annotator.es.js.map\n"],"names":[],"mappings":"AAAK,MAUF,KAAK,mBAAmB,IAAI,IAAI,EAAE,IA0BlC,KAAK,CAAC,MAAM;AACb,QAAM,IAAI,EAAE;AACZ,SAAO,EAAE,iBAAiB,CAAC,EAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,GAAG;AAC3D,GA+EG,KAAK,CAAC,GAAG,GAAG,IAAI,IAAI,MAAM;AAC3B,QAAM,IAAoD,GAAG,IAAI,SAAS,YAAW;AACrF,IAAE,SAAS,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,gBAAgB,EAAE,WAAW;AAC1D,QAAM,IAAI,GAAG,CAAC,EAAE,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