@recogito/text-annotator 3.4.9 → 4.0.0-beta

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 (124) hide show
  1. package/dist/index.d.ts +409 -11
  2. package/dist/model/core/index.d.ts +1 -1
  3. package/dist/model/w3c/index.d.ts +2 -2
  4. package/dist/{src/model/w3c/W3CTextFormatAdapter.d.ts → model/w3c/w3c-text-format-adapter.d.ts} +2 -2
  5. package/dist/rendering/base-renderer.d.ts +31 -0
  6. package/dist/{src/highlight/HighlightStyle.d.ts → rendering/highlight-style.d.ts} +4 -1
  7. package/dist/{src/highlight/Highlight.d.ts → rendering/highlight.d.ts} +2 -1
  8. package/dist/rendering/index.d.ts +4 -0
  9. package/dist/rendering/renderer-css-highlight/css-highlight-renderer.d.ts +6 -0
  10. package/dist/rendering/renderer-css-highlight/index.d.ts +1 -0
  11. package/dist/rendering/renderer-inline-markup/index.d.ts +0 -0
  12. package/dist/rendering/renderer-spans/index.d.ts +1 -0
  13. package/dist/rendering/renderer-spans/spans-renderer.d.ts +2 -0
  14. package/dist/{SelectionHandler.d.ts → selection-handler.d.ts} +5 -5
  15. package/dist/src/index.d.ts +8 -7
  16. package/dist/state/index.d.ts +2 -2
  17. package/dist/state/{spatialTree.d.ts → spatial-tree.d.ts} +4 -4
  18. package/dist/{src/state/TextAnnotationStore.d.ts → state/text-annotation-store.d.ts} +3 -0
  19. package/dist/{src/state/TextAnnotatorState.d.ts → state/text-annotator-state.d.ts} +2 -2
  20. package/dist/{src/TextAnnotatorOptions.d.ts → text-annotator-options.d.ts} +4 -5
  21. package/dist/text-annotator.css +1 -1
  22. package/dist/{TextAnnotator.d.ts → text-annotator.d.ts} +7 -8
  23. package/dist/text-annotator.es.js +740 -825
  24. package/dist/text-annotator.es.js.map +1 -1
  25. package/dist/text-annotator.umd.js +2 -2
  26. package/dist/text-annotator.umd.js.map +1 -1
  27. package/dist/utils/annotation/index.d.ts +4 -0
  28. package/dist/{src/utils/rangeToSelector.d.ts → utils/annotation/range-to-selector.d.ts} +1 -1
  29. package/dist/{src/utils/reviveSelector.d.ts → utils/annotation/revive-annotation.d.ts} +4 -1
  30. package/dist/{api/scrollIntoView.d.ts → utils/annotation/scroll-into-view.d.ts} +2 -2
  31. package/dist/utils/dom/index.d.ts +7 -0
  32. package/dist/utils/events/index.d.ts +3 -0
  33. package/dist/utils/highlight/compute-z-index.d.ts +3 -0
  34. package/dist/utils/highlight/index.d.ts +4 -0
  35. package/package.json +2 -2
  36. package/dist/TextAnnotatorOptions.d.ts +0 -35
  37. package/dist/api/index.d.ts +0 -1
  38. package/dist/highlight/Highlight.d.ts +0 -5
  39. package/dist/highlight/HighlightPainter.d.ts +0 -11
  40. package/dist/highlight/HighlightStyle.d.ts +0 -11
  41. package/dist/highlight/Renderer.d.ts +0 -22
  42. package/dist/highlight/RendererImplementation.d.ts +0 -9
  43. package/dist/highlight/baseRenderer.d.ts +0 -22
  44. package/dist/highlight/canvas/canvasRenderer.d.ts +0 -5
  45. package/dist/highlight/canvas/index.d.ts +0 -1
  46. package/dist/highlight/color.d.ts +0 -2
  47. package/dist/highlight/highlights/highlightsRenderer.d.ts +0 -6
  48. package/dist/highlight/highlights/index.d.ts +0 -1
  49. package/dist/highlight/index.d.ts +0 -8
  50. package/dist/highlight/span/color.d.ts +0 -2
  51. package/dist/highlight/span/index.d.ts +0 -2
  52. package/dist/highlight/span/spansRenderer.d.ts +0 -3
  53. package/dist/highlight/viewport.d.ts +0 -12
  54. package/dist/model/core/TextAnnotation.d.ts +0 -15
  55. package/dist/model/w3c/W3CTextAnnotation.d.ts +0 -34
  56. package/dist/model/w3c/W3CTextFormatAdapter.d.ts +0 -12
  57. package/dist/presence/PresencePainter.d.ts +0 -5
  58. package/dist/presence/PresencePainterOptions.d.ts +0 -3
  59. package/dist/presence/index.d.ts +0 -2
  60. package/dist/src/SelectionHandler.d.ts +0 -9
  61. package/dist/src/TextAnnotator.d.ts +0 -12
  62. package/dist/src/api/index.d.ts +0 -1
  63. package/dist/src/api/scrollIntoView.d.ts +0 -3
  64. package/dist/src/highlight/HighlightPainter.d.ts +0 -11
  65. package/dist/src/highlight/baseRenderer.d.ts +0 -20
  66. package/dist/src/highlight/canvas/canvasRenderer.d.ts +0 -4
  67. package/dist/src/highlight/canvas/index.d.ts +0 -1
  68. package/dist/src/highlight/highlights/highlightsRenderer.d.ts +0 -6
  69. package/dist/src/highlight/highlights/index.d.ts +0 -1
  70. package/dist/src/highlight/index.d.ts +0 -6
  71. package/dist/src/highlight/span/color.d.ts +0 -2
  72. package/dist/src/highlight/span/index.d.ts +0 -1
  73. package/dist/src/highlight/span/spansRenderer.d.ts +0 -4
  74. package/dist/src/model/core/index.d.ts +0 -1
  75. package/dist/src/model/index.d.ts +0 -2
  76. package/dist/src/model/w3c/index.d.ts +0 -2
  77. package/dist/src/presence/PresencePainter.d.ts +0 -4
  78. package/dist/src/presence/PresencePainterOptions.d.ts +0 -3
  79. package/dist/src/presence/index.d.ts +0 -2
  80. package/dist/src/state/index.d.ts +0 -2
  81. package/dist/src/state/spatialTree.d.ts +0 -28
  82. package/dist/src/utils/index.d.ts +0 -17
  83. package/dist/src/utils/isRevived.d.ts +0 -2
  84. package/dist/src/utils/isWhitespaceOrEmpty.d.ts +0 -2
  85. package/dist/src/utils/reviveAnnotation.d.ts +0 -2
  86. package/dist/src/utils/reviveTarget.d.ts +0 -2
  87. package/dist/state/TextAnnotationStore.d.ts +0 -28
  88. package/dist/state/TextAnnotatorState.d.ts +0 -12
  89. package/dist/test/model/w3c/W3CTextFormatAdapter.test.d.ts +0 -1
  90. package/dist/test/model/w3c/fixtures.d.ts +0 -3
  91. package/dist/utils/cancelSingleClickEvents.d.ts +0 -6
  92. package/dist/utils/cloneEvents.d.ts +0 -11
  93. package/dist/utils/debounce.d.ts +0 -1
  94. package/dist/utils/device.d.ts +0 -1
  95. package/dist/utils/getHighlightClientRects.d.ts +0 -1
  96. package/dist/utils/getQuoteContext.d.ts +0 -4
  97. package/dist/utils/index.d.ts +0 -19
  98. package/dist/utils/isNotAnnotatable.d.ts +0 -4
  99. package/dist/utils/isRevived.d.ts +0 -2
  100. package/dist/utils/mergeClientRects.d.ts +0 -2
  101. package/dist/utils/programmaticallyFocusable.d.ts +0 -6
  102. package/dist/utils/rangeToSelector.d.ts +0 -2
  103. package/dist/utils/reviveAnnotation.d.ts +0 -2
  104. package/dist/utils/reviveSelector.d.ts +0 -11
  105. package/dist/utils/reviveTarget.d.ts +0 -2
  106. package/dist/utils/splitAnnotatableRanges.d.ts +0 -5
  107. package/dist/utils/trimRangeToContainer.d.ts +0 -1
  108. /package/dist/{src/model/core/TextAnnotation.d.ts → model/core/text-annotation.d.ts} +0 -0
  109. /package/dist/{src/model/w3c/W3CTextAnnotation.d.ts → model/w3c/w3c-text-annotation.d.ts} +0 -0
  110. /package/dist/{src/highlight → rendering}/viewport.d.ts +0 -0
  111. /package/dist/{src/utils/getQuoteContext.d.ts → utils/annotation/get-quote-context.d.ts} +0 -0
  112. /package/dist/{src/utils → utils/dom}/device.d.ts +0 -0
  113. /package/dist/{src/utils/isNotAnnotatable.d.ts → utils/dom/is-not-annotatable.d.ts} +0 -0
  114. /package/dist/utils/{isWhitespaceOrEmpty.d.ts → dom/is-whitespace-or-empty.d.ts} +0 -0
  115. /package/dist/utils/{mergeRanges.d.ts → dom/merge-ranges.d.ts} +0 -0
  116. /package/dist/{src/utils/programmaticallyFocusable.d.ts → utils/dom/programmatically-focusable.d.ts} +0 -0
  117. /package/dist/{src/utils/splitAnnotatableRanges.d.ts → utils/dom/split-annotatable-ranges.d.ts} +0 -0
  118. /package/dist/{src/utils/trimRangeToContainer.d.ts → utils/dom/trim-range-to-container.d.ts} +0 -0
  119. /package/dist/{src/utils/cancelSingleClickEvents.d.ts → utils/events/cancel-single-click-events.d.ts} +0 -0
  120. /package/dist/{src/utils/cloneEvents.d.ts → utils/events/clone-events.d.ts} +0 -0
  121. /package/dist/{src/utils → utils/events}/debounce.d.ts +0 -0
  122. /package/dist/{src/utils/getHighlightClientRects.d.ts → utils/highlight/get-highlight-client-rects.d.ts} +0 -0
  123. /package/dist/{src/utils/mergeClientRects.d.ts → utils/highlight/merge-client-rects.d.ts} +0 -0
  124. /package/dist/utils/{rectsToBounds.d.ts → highlight/rects-to-bounds.d.ts} +0 -0
@@ -1,983 +1,898 @@
1
- import { UAParser as be } from "ua-parser-js";
2
- import { OS as Ee } from "ua-parser-js/enums";
3
- import le from "debounce";
4
- import { UserSelectAction as Ce, serializeW3CBodies as Se, parseW3CBodies as Ae, parseW3CUser as we, createStore as Re, createSelectionState as Te, createHoverState as ve, createViewportState as xe, Origin as K, createAnonymousGuest as Le, createUndoStack as Ne, createLifecycleObserver as Oe, createBaseAnnotator as Be } from "@annotorious/core";
5
- import { Origin as Ft, UserSelectAction as Vt, createBody as Yt } from "@annotorious/core";
6
- import { colord as ne } from "colord";
7
- import { dequal as ke } from "dequal/lite";
8
- import { v4 as de } from "uuid";
9
- import Me from "rbush";
10
- import { createNanoEvents as Ie } from "nanoevents";
1
+ import { createNanoEvents as at } from "nanoevents";
2
+ import { UserSelectAction as Et, serializeW3CBodies as bt, parseW3CBodies as Ct, parseW3CUser as At, createStore as Tt, createSelectionState as Rt, createHoverState as vt, createViewportState as wt, Origin as F, createAnonymousGuest as xt, createUndoStack as Lt, createLifecycleObserver as Nt, createBaseAnnotator as Ot } from "@annotorious/core";
3
+ import { Origin as He, UserSelectAction as Pe, createBody as Ue } from "@annotorious/core";
4
+ import { UAParser as kt } from "ua-parser-js";
5
+ import { OSName as Mt } from "ua-parser-js/enums";
6
+ import { colord as et } from "colord";
7
+ import { v4 as lt } from "uuid";
8
+ import Bt from "rbush";
9
+ import It from "debounce";
11
10
  import q from "hotkeys-js";
12
- import { poll as _e } from "poll";
13
- const ue = "not-annotatable", W = `.${ue}`, G = (e, t) => e.contains(t) ? !!(t instanceof HTMLElement ? t.closest(W) : t.parentElement?.closest(W)) : !0, He = (e, t) => {
14
- const n = t.commonAncestorContainer;
15
- return !G(e, n);
16
- }, Pe = (e) => e.addEventListener("click", (t) => {
17
- // Allow clicks within not-annotatable elements
18
- !t.target.closest(W) && !t.target.closest("a") && t.preventDefault();
19
- }), J = (e) => ({
20
- ...e,
21
- type: e.type,
22
- x: e.x,
23
- y: e.y,
24
- clientX: e.clientX,
25
- clientY: e.clientY,
26
- offsetX: e.offsetX,
27
- offsetY: e.offsetY,
28
- screenX: e.screenX,
29
- screenY: e.screenY,
30
- isPrimary: e.isPrimary,
31
- altKey: e.altKey,
32
- ctrlKey: e.ctrlKey,
33
- metaKey: e.metaKey,
34
- shiftKey: e.shiftKey,
35
- button: e.button,
36
- buttons: e.buttons,
37
- currentTarget: e.currentTarget,
38
- target: e.target,
39
- defaultPrevented: e.defaultPrevented,
40
- detail: e.detail,
41
- eventPhase: e.eventPhase,
42
- pointerId: e.pointerId,
43
- pointerType: e.pointerType,
44
- timeStamp: e.timeStamp
45
- }), j = (e) => ({
46
- ...e,
47
- type: e.type,
48
- key: e.key,
49
- code: e.code,
50
- location: e.location,
51
- repeat: e.repeat,
52
- altKey: e.altKey,
53
- ctrlKey: e.ctrlKey,
54
- metaKey: e.metaKey,
55
- shiftKey: e.shiftKey,
56
- currentTarget: e.currentTarget,
57
- target: e.target,
58
- defaultPrevented: e.defaultPrevented,
59
- detail: e.detail,
60
- timeStamp: e.timeStamp
61
- }), ee = (e, t = 10) => {
62
- let n;
63
- return ((...r) => {
64
- clearTimeout(n), n = setTimeout(() => e.apply(void 0, r), t);
11
+ import { poll as _t } from "poll";
12
+ import { dequal as Dt } from "dequal/lite";
13
+ const Ht = kt(), dt = Ht.os.is(Mt.MACOS), ut = "not-annotatable", $ = `.${ut}`, G = (t, e) => t.contains(e) ? !!(e instanceof HTMLElement ? e.closest($) : e.parentElement?.closest($)) : !0, Pt = (t, e) => {
14
+ const o = e.commonAncestorContainer;
15
+ return !G(t, o);
16
+ }, ft = /^\s*$/, Ut = (t) => ft.test(t.toString()), Oe = (t) => ft.test(t.textContent || ""), Kt = (t) => {
17
+ if (t.length === 0) return [];
18
+ if (t.length === 1) return [t[0]];
19
+ t.sort((s, n) => {
20
+ const r = s.compareBoundaryPoints(Range.START_TO_START, n);
21
+ return r !== 0 ? r : s.compareBoundaryPoints(Range.END_TO_END, n);
65
22
  });
66
- }, De = be(), fe = De.os.is(Ee.MACOS), Ue = (e) => {
67
- !e.hasAttribute("tabindex") && e.tabIndex < 0 && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
68
- }, Ke = (e) => {
69
- const t = [], n = document.createNodeIterator(
70
- e.commonAncestorContainer,
71
- NodeFilter.SHOW_TEXT
72
- );
73
- let r;
74
- for (; r = n.nextNode(); )
75
- e.intersectsNode(r) && t.push(r);
76
- if (t.length < 2)
77
- return Array.from(e.getClientRects());
78
- {
79
- const s = t[0], o = t[t.length - 1], i = document.createRange();
80
- if (i.selectNode(s), e.startContainer.nodeType === Node.TEXT_NODE)
81
- i.setStart(s, e.startOffset);
82
- else {
83
- const f = e.startContainer.childNodes[e.startOffset];
84
- f ? i.setStartBefore(f) : i.setStartAfter(e.startContainer);
85
- }
86
- const c = document.createRange();
87
- if (c.selectNode(o), e.endContainer.nodeType === Node.TEXT_NODE)
88
- c.setEnd(o, e.endOffset);
89
- else {
90
- const f = e.endContainer.childNodes[e.endOffset];
91
- f ? c.setEndBefore(f) : c.setEndAfter(e.endContainer);
92
- }
93
- const l = (f) => {
94
- const d = document.createRange();
95
- return d.selectNode(f), Array.from(d.getClientRects());
96
- };
97
- return [
98
- ...Array.from(i.getClientRects()),
99
- ...t.slice(1, -1).flatMap(l),
100
- ...Array.from(c.getClientRects())
101
- ];
102
- }
103
- }, We = function* (e) {
104
- const t = document.createNodeIterator(
105
- e.commonAncestorContainer,
23
+ const [e, ...o] = t, i = o.reduce((s, n) => s.current.compareBoundaryPoints(Range.START_TO_END, n) >= 0 ? (s.current.compareBoundaryPoints(Range.END_TO_END, n) < 0 && s.current.setEnd(n.endContainer, n.endOffset), s) : (s.merged.push(s.current), s.current = n.cloneRange(), s), { merged: [], current: e.cloneRange() });
24
+ return [...i.merged, i.current];
25
+ }, Ft = (t) => {
26
+ !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
27
+ }, $t = function* (t) {
28
+ const e = document.createNodeIterator(
29
+ t.commonAncestorContainer,
106
30
  NodeFilter.SHOW_ELEMENT,
107
- (r) => r instanceof HTMLElement && r.classList.contains(ue) && !r.parentElement.closest(W) && e.intersectsNode(r) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
31
+ (i) => i instanceof HTMLElement && i.classList.contains(ut) && !i.parentElement.closest($) && t.intersectsNode(i) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
108
32
  );
109
- let n;
110
- for (; n = t.nextNode(); )
111
- n instanceof HTMLElement && (yield n);
112
- }, $e = (e, t) => {
113
- if (!He(e, t)) return [];
114
- const n = [];
115
- let r = null;
116
- for (const s of We(t)) {
117
- let o;
118
- r ? (o = document.createRange(), o.setStartAfter(r), o.setEndBefore(s)) : (o = t.cloneRange(), o.setEndBefore(s)), o.collapsed || n.push(o), r = s;
33
+ let o;
34
+ for (; o = e.nextNode(); )
35
+ o instanceof HTMLElement && (yield o);
36
+ }, Yt = (t, e) => {
37
+ if (!Pt(t, e)) return [];
38
+ const o = [];
39
+ let i = null;
40
+ for (const s of $t(e)) {
41
+ let n;
42
+ i ? (n = document.createRange(), n.setStartAfter(i), n.setEndBefore(s)) : (n = e.cloneRange(), n.setEndBefore(s)), n.collapsed || o.push(n), i = s;
119
43
  }
120
- if (r) {
121
- const s = t.cloneRange();
122
- s.setStartAfter(r), s.collapsed || n.push(s);
44
+ if (i) {
45
+ const s = e.cloneRange();
46
+ s.setStartAfter(i), s.collapsed || o.push(s);
123
47
  }
124
- return n.length > 0 ? n : [t];
125
- }, oe = (e) => {
126
- const t = e.cloneContents();
127
- return t.querySelectorAll(W).forEach((n) => n.remove()), t;
128
- }, Fe = (e, t, n = 10, r) => {
129
- const s = r ? e.startContainer.parentElement.closest(r) : t, o = document.createRange();
130
- o.setStart(s, 0), o.setEnd(e.startContainer, e.startOffset);
131
- const i = oe(o).textContent, c = document.createRange();
132
- c.setStart(e.endContainer, e.endOffset), s === document.body ? c.setEnd(s, s.childNodes.length) : c.setEndAfter(s);
133
- const l = oe(c).textContent;
134
- return {
135
- prefix: i.substring(i.length - n),
136
- suffix: l.substring(0, n)
48
+ return o.length > 0 ? o : [e];
49
+ }, nt = (t) => {
50
+ const e = t.cloneContents();
51
+ return e.querySelectorAll($).forEach((o) => o.remove()), e;
52
+ }, Wt = (t, e) => {
53
+ const o = t.cloneRange();
54
+ return e.contains(o.startContainer) || o.setStart(e, 0), e.contains(o.endContainer) || o.setEnd(e, e.childNodes.length), o;
55
+ }, Xt = (t) => t.addEventListener("click", (e) => {
56
+ // Allow clicks within not-annotatable elements
57
+ !e.target.closest($) && !e.target.closest("a") && e.preventDefault();
58
+ }), Z = (t) => ({
59
+ ...t,
60
+ type: t.type,
61
+ x: t.x,
62
+ y: t.y,
63
+ clientX: t.clientX,
64
+ clientY: t.clientY,
65
+ offsetX: t.offsetX,
66
+ offsetY: t.offsetY,
67
+ screenX: t.screenX,
68
+ screenY: t.screenY,
69
+ isPrimary: t.isPrimary,
70
+ altKey: t.altKey,
71
+ ctrlKey: t.ctrlKey,
72
+ metaKey: t.metaKey,
73
+ shiftKey: t.shiftKey,
74
+ button: t.button,
75
+ buttons: t.buttons,
76
+ currentTarget: t.currentTarget,
77
+ target: t.target,
78
+ defaultPrevented: t.defaultPrevented,
79
+ detail: t.detail,
80
+ eventPhase: t.eventPhase,
81
+ pointerId: t.pointerId,
82
+ pointerType: t.pointerType,
83
+ timeStamp: t.timeStamp
84
+ }), j = (t) => ({
85
+ ...t,
86
+ type: t.type,
87
+ key: t.key,
88
+ code: t.code,
89
+ location: t.location,
90
+ repeat: t.repeat,
91
+ altKey: t.altKey,
92
+ ctrlKey: t.ctrlKey,
93
+ metaKey: t.metaKey,
94
+ shiftKey: t.shiftKey,
95
+ currentTarget: t.currentTarget,
96
+ target: t.target,
97
+ defaultPrevented: t.defaultPrevented,
98
+ detail: t.detail,
99
+ timeStamp: t.timeStamp
100
+ }), J = (t, e = 10) => {
101
+ let o;
102
+ return ((...i) => {
103
+ clearTimeout(o), o = setTimeout(() => t.apply(void 0, i), e);
104
+ });
105
+ }, gt = (t, e, o, i) => {
106
+ const { store: s, selection: n, hover: r } = o, c = at();
107
+ let d;
108
+ const f = /* @__PURE__ */ new Map();
109
+ let p;
110
+ const C = qt(i), h = (y) => {
111
+ const { x: b, y: O } = e.getBoundingClientRect(), B = s.getAt(y.clientX - b, y.clientY - O, !1, p);
112
+ B && o.selection.evalSelectAction(B) !== Et.NONE ? r.current !== B.id && (e.classList.add("hovered"), r.set(B.id)) : r.current && (e.classList.remove("hovered"), r.set(null));
137
113
  };
138
- }, I = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), ge = /^\s*$/, Ve = (e) => ge.test(e.toString()), Ht = (e) => ge.test(e.textContent || ""), Ye = (e, t, n, r) => {
139
- const s = (c) => Math.round(c * 10) / 10, o = {
140
- top: s(e.top),
141
- bottom: s(e.bottom),
142
- left: s(e.left),
143
- right: s(e.right)
144
- }, i = {
145
- top: s(t.top),
146
- bottom: s(t.bottom),
147
- left: s(t.left),
148
- right: s(t.right)
114
+ e.addEventListener("pointermove", h);
115
+ const T = J((y = !1) => requestAnimationFrame(() => {
116
+ const b = zt(e), { minX: O, minY: B, maxX: X, maxY: V } = b, K = p ? s.getIntersecting(O, B, X, V).filter(({ annotation: S }) => p(S)) : s.getIntersecting(O, B, X, V), st = n.selected.map(({ id: S }) => S), g = K.map(({ annotation: S, rects: M }) => {
117
+ const U = st.includes(S.id), I = S.id === r.current;
118
+ return {
119
+ annotation: S,
120
+ rects: M,
121
+ state: { selected: U, hovered: I }
122
+ };
123
+ });
124
+ t.redraw(g, b, d, f, y), setTimeout(() => {
125
+ C(K.map(({ annotation: S }) => S)), c.emit("onRedraw");
126
+ }, 1);
127
+ }), 10), u = (y, b) => {
128
+ b ? y ? f.set(b, y) : f.delete(b) : d = y, T(!0);
129
+ }, L = (y) => {
130
+ p = y, T(!1);
131
+ }, x = (y, b) => c.on(y, b), v = () => {
132
+ T();
149
133
  };
150
- if (Math.abs(o.top - i.top) < r && Math.abs(o.bottom - i.bottom) < r) {
151
- if (Math.abs(o.left - i.right) < n || Math.abs(o.right - i.left) < n)
152
- return "inline-adjacent";
153
- if (o.left >= i.left && o.right <= i.right)
154
- return "inline-is-contained";
155
- if (o.left <= i.left && o.right >= i.right)
156
- return "inline-contains";
157
- } else if (o.top <= i.top && o.bottom >= i.bottom) {
158
- if (o.left <= i.left && o.right >= i.right)
159
- return "block-contains";
160
- } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
161
- return "block-is-contained";
162
- }, Xe = (e, t) => {
163
- const n = Math.min(e.left, t.left), r = Math.max(e.right, t.right), s = Math.min(e.top, t.top), o = Math.max(e.bottom, t.bottom);
164
- return new DOMRect(n, s, r - n, o - s);
165
- }, ze = (e, t = 0.5, n = 0.5) => e.reduce((r, s) => {
166
- if (s.width === 0 || s.height === 0)
167
- return r;
168
- let o = [...r], i = !1;
169
- for (const c of r) {
170
- const l = Ye(s, c, t, n);
171
- if (l === "inline-adjacent") {
172
- o = o.map((f) => f === c ? Xe(s, c) : f), i = !0;
173
- break;
174
- } else if (l === "inline-contains") {
175
- o = o.map((f) => f === c ? s : f), i = !0;
176
- break;
177
- } else if (l === "inline-is-contained") {
178
- i = !0;
179
- break;
180
- } else if (l === "block-contains" || l === "block-is-contained") {
181
- s.width < c.width && (o = o.map((f) => f === c ? s : f)), s.width === c.width && s.height < c.width && (o = o.map((f) => f === c ? s : f)), i = !0;
182
- break;
183
- }
184
- }
185
- return i ? o : [...o, s];
186
- }, []), Pt = (e) => ({
187
- length: e.length,
188
- item: (t) => e[t],
189
- [Symbol.iterator]: function* () {
190
- for (let t = 0; t < this.length; t++)
191
- yield this.item(t);
192
- }
193
- }), qe = (e) => {
194
- if (e.length === 0) return [];
195
- if (e.length === 1) return [e[0]];
196
- e.sort((s, o) => {
197
- const i = s.compareBoundaryPoints(Range.START_TO_START, o);
198
- return i !== 0 ? i : s.compareBoundaryPoints(Range.END_TO_END, o);
199
- });
200
- const [t, ...n] = e, r = n.reduce((s, o) => s.current.compareBoundaryPoints(Range.START_TO_END, o) >= 0 ? (s.current.compareBoundaryPoints(Range.END_TO_END, o) < 0 && s.current.setEnd(o.endContainer, o.endOffset), s) : (s.merged.push(s.current), s.current = o.cloneRange(), s), { merged: [], current: t.cloneRange() });
201
- return [...r.merged, r.current];
202
- }, je = (e, t, n) => {
203
- const r = document.createRange(), s = n ? e.startContainer.parentElement.closest(n) : t;
204
- r.setStart(s, 0), r.setEnd(e.startContainer, e.startOffset);
205
- const o = oe(r).textContent, i = e.toString(), c = o.length || 0, l = c + i.length;
206
- return n ? { quote: i, start: c, end: l, range: e, offsetReference: s } : { quote: i, start: c, end: l, range: e };
207
- }, Ge = (e, t) => {
208
- const { left: n, top: r, right: s, bottom: o } = e;
209
- return new DOMRect(n - t.left, r - t.top, s - n, o - r);
210
- }, Dt = (e, t) => {
211
- const { left: n, top: r, right: s, bottom: o } = e;
212
- return new DOMRect(n + t.left, r + t.top, s - n, o - r);
213
- }, me = (e, t) => {
214
- const { start: n, end: r } = e, s = e.offsetReference || t, o = document.createNodeIterator(
215
- t,
134
+ s.observe(v);
135
+ const m = n.subscribe(() => {
136
+ T();
137
+ }), E = r.subscribe(() => {
138
+ T();
139
+ }), w = () => {
140
+ T(!0);
141
+ };
142
+ document.addEventListener("scroll", w, { capture: !0, passive: !0 });
143
+ const a = J(() => {
144
+ s.recalculatePositions(), T();
145
+ }, 10);
146
+ window.addEventListener("resize", a);
147
+ const l = new ResizeObserver(a);
148
+ l.observe(e);
149
+ const A = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver(J((y) => {
150
+ y.every((O) => O.target === e || e.contains(O.target)) || T(!0);
151
+ }, 150));
152
+ return R.observe(document.body, A), {
153
+ destroy: () => {
154
+ e.removeEventListener("pointermove", h), t.destroy(), s.unobserve(v), m(), E(), document.removeEventListener("scroll", w), window.removeEventListener("resize", a), l.disconnect(), R.disconnect();
155
+ },
156
+ on: x,
157
+ redraw: T,
158
+ setStyle: u,
159
+ setFilter: L,
160
+ setVisible: t.setVisible.bind(t)
161
+ };
162
+ }, P = {
163
+ fill: "rgb(0, 128, 255)",
164
+ fillOpacity: 0.18
165
+ }, ot = {
166
+ fill: "rgb(0, 128, 255)",
167
+ fillOpacity: 0.45
168
+ }, Vt = (t) => t?.fillOpacity !== void 0 ? et(t?.fill || P.fill).alpha(t.fillOpacity).toHex() : t?.fill ? t.fill : et(P.fill).alpha(P.fillOpacity).toHex(), mt = (t, e, o) => e ? typeof e == "function" ? e(t.annotation, t.state, o) || (t.state?.selected ? ot : P) : e : t.state?.selected ? ot : P, zt = (t) => {
169
+ const { top: e, left: o } = t.getBoundingClientRect(), { innerWidth: i, innerHeight: s } = window, n = -o, r = -e, c = i - o, d = s - e;
170
+ return { top: e, left: o, minX: n, minY: r, maxX: c, maxY: d };
171
+ }, qt = (t) => {
172
+ let e = /* @__PURE__ */ new Set();
173
+ return (i) => {
174
+ const s = i.map((n) => n.id);
175
+ (e.size !== s.length || s.some((n) => !e.has(n))) && t.set(s), e = new Set(s);
176
+ };
177
+ }, jt = (t, e, o = 10, i) => {
178
+ const s = i ? t.startContainer.parentElement.closest(i) : e, n = document.createRange();
179
+ n.setStart(s, 0), n.setEnd(t.startContainer, t.startOffset);
180
+ const r = nt(n).textContent, c = document.createRange();
181
+ c.setStart(t.endContainer, t.endOffset), s === document.body ? c.setEnd(s, s.childNodes.length) : c.setEndAfter(s);
182
+ const d = nt(c).textContent;
183
+ return {
184
+ prefix: r.substring(r.length - o),
185
+ suffix: d.substring(0, o)
186
+ };
187
+ }, Gt = (t, e, o) => {
188
+ const i = document.createRange(), s = o ? t.startContainer.parentElement.closest(o) : e;
189
+ i.setStart(s, 0), i.setEnd(t.startContainer, t.startOffset);
190
+ const n = nt(i).textContent, r = t.toString(), c = n.length || 0, d = c + r.length;
191
+ return o ? { quote: r, start: c, end: d, range: t, offsetReference: s } : { quote: r, start: c, end: d, range: t };
192
+ }, D = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), pt = (t, e) => {
193
+ const { start: o, end: i } = t, s = t.offsetReference || e, n = document.createNodeIterator(
194
+ e,
216
195
  NodeFilter.SHOW_TEXT,
217
- (d) => d.parentElement?.closest(W) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT
196
+ (p) => p.parentElement?.closest($) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT
218
197
  );
219
- let i = 0;
198
+ let r = 0;
220
199
  const c = document.createRange();
221
- let l = o.nextNode();
222
- l === null && console.error("Could not revive annotation target. Content missing.");
200
+ let d = n.nextNode();
201
+ d === null && console.error("Could not revive annotation target. Content missing.");
223
202
  let f = !s;
224
- for (; l !== null; ) {
225
- if (f ||= typeof s?.contains == "function" ? s.contains(l) : !1, f) {
226
- const d = l.textContent?.length || 0;
227
- if (i + d > n) {
228
- c.setStart(l, n - i);
203
+ for (; d !== null; ) {
204
+ if (f ||= typeof s?.contains == "function" ? s.contains(d) : !1, f) {
205
+ const p = d.textContent?.length || 0;
206
+ if (r + p > o) {
207
+ c.setStart(d, o - r);
229
208
  break;
230
209
  }
231
- i += d;
210
+ r += p;
232
211
  }
233
- l = o.nextNode();
212
+ d = n.nextNode();
234
213
  }
235
- for (; l !== null; ) {
236
- const d = l.textContent?.length || 0;
237
- if (i + d >= r) {
238
- c.setEnd(l, r - i);
214
+ for (; d !== null; ) {
215
+ const p = d.textContent?.length || 0;
216
+ if (r + p >= i) {
217
+ c.setEnd(d, i - r);
239
218
  break;
240
219
  }
241
- i += d, l = o.nextNode();
220
+ r += p, d = n.nextNode();
242
221
  }
243
222
  return {
244
- ...e,
223
+ ...t,
245
224
  range: c
246
225
  };
247
- }, Q = (e, t) => I(e.selector) ? e : {
248
- ...e,
249
- selector: e.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : me(n, t))
250
- }, te = (e, t) => I(e.target.selector) ? e : { ...e, target: Q(e.target, t) }, Qe = (e, t) => {
251
- const n = e.cloneRange();
252
- return t.contains(n.startContainer) || n.setStart(t, 0), t.contains(n.endContainer) || n.setEnd(t, t.childNodes.length), n;
253
- }, pe = (e) => {
254
- if (!e)
226
+ }, Q = (t, e) => D(t.selector) ? t : {
227
+ ...t,
228
+ selector: t.selector.map((o) => o.range instanceof Range && !o.range.collapsed ? o : pt(o, e))
229
+ }, tt = (t, e) => D(t.target.selector) ? t : { ...t, target: Q(t.target, e) }, ht = (t) => {
230
+ if (!t)
255
231
  return document.scrollingElement;
256
- const { overflowY: t } = window.getComputedStyle(e);
257
- return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e : pe(e.parentElement);
258
- }, ie = (e, t, n) => {
259
- const r = n.getBoundingClientRect(), s = n.clientHeight, o = n.clientWidth, i = t.selector[0].range.getBoundingClientRect(), { width: c, height: l } = e.getAnnotationBounds(t.annotation), f = i.top - r.top, d = i.left - r.left, u = n.parentElement ? n.scrollTop : 0, y = n.parentElement ? n.scrollLeft : 0, w = f + u - (s - l) / 2, g = d + y - (o - c) / 2;
260
- n.scroll({ top: w, left: g, behavior: "smooth" });
261
- }, Ze = (e, t) => (n, r) => {
262
- const s = typeof n == "string" ? n : n.id, o = r ? typeof r == "string" ? document.getElementById(r) : r : pe(e);
263
- if (!o)
264
- return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: e }), !1;
265
- const i = t.getAnnotation(s);
266
- if (!i)
232
+ const { overflowY: e } = window.getComputedStyle(t);
233
+ return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ht(t.parentElement);
234
+ }, rt = (t, e, o) => {
235
+ const i = o.getBoundingClientRect(), s = o.clientHeight, n = o.clientWidth, r = e.selector[0].range.getBoundingClientRect(), { width: c, height: d } = t.getAnnotationBounds(e.annotation), f = r.top - i.top, p = r.left - i.left, C = o.parentElement ? o.scrollTop : 0, h = o.parentElement ? o.scrollLeft : 0, T = f + C - (s - d) / 2, u = p + h - (n - c) / 2;
236
+ o.scroll({ top: T, left: u, behavior: "smooth" });
237
+ }, Qt = (t, e) => (o, i) => {
238
+ const s = typeof o == "string" ? o : o.id, n = i ? typeof i == "string" ? document.getElementById(i) : i : ht(t);
239
+ if (!n)
240
+ return console.warn(`The scroll parent is missing for the annotation: ${s}`, { container: t }), !1;
241
+ const r = e.getAnnotation(s);
242
+ if (!r)
267
243
  return console.warn(`The annotation is missing in the store: ${s}`), !1;
268
- const { range: c } = i.target.selector[0];
244
+ const { range: c } = r.target.selector[0];
269
245
  if (c && !c.collapsed)
270
- return ie(t, i.target, o), !0;
271
- const l = Q(i.target, e), { range: f } = l.selector[0];
272
- return f && !f.collapsed ? (ie(t, l, o), !0) : !1;
273
- }, _ = {
274
- fill: "rgb(0, 128, 255)",
275
- fillOpacity: 0.18
276
- }, Z = {
277
- fill: "rgb(0, 128, 255)",
278
- fillOpacity: 0.45
279
- }, Je = (e) => {
280
- const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: r, innerHeight: s } = window, o = -n, i = -t, c = r - n, l = s - t;
281
- return { top: t, left: n, minX: o, minY: i, maxX: c, maxY: l };
282
- }, et = (e) => {
283
- let t = /* @__PURE__ */ new Set();
284
- return (r) => {
285
- const s = r.map((o) => o.id);
286
- (t.size !== s.length || s.some((o) => !t.has(o))) && e.set(s), t = new Set(s);
287
- };
288
- }, se = (e, t, n, r) => {
289
- const { store: s, selection: o, hover: i } = t;
290
- let c, l, f;
291
- const d = et(n), u = (A) => {
292
- const { x: v, y: N } = e.getBoundingClientRect(), O = s.getAt(A.clientX - v, A.clientY - N, !1, l);
293
- O && t.selection.evalSelectAction(O) !== Ce.NONE ? i.current !== O.id && (e.classList.add("hovered"), i.set(O.id)) : i.current && (e.classList.remove("hovered"), i.set(null));
294
- };
295
- e.addEventListener("pointermove", u);
296
- const y = ee((A = !1) => requestAnimationFrame(() => {
297
- f && f.clear();
298
- const v = Je(e), { minX: N, minY: O, maxX: D, maxY: Y } = v, X = l ? s.getIntersecting(N, O, D, Y).filter(({ annotation: h }) => l(h)) : s.getIntersecting(N, O, D, Y), $ = o.selected.map(({ id: h }) => h), re = X.map(({ annotation: h, rects: T }) => {
299
- const k = $.includes(h.id), U = h.id === i.current;
300
- return {
301
- annotation: h,
302
- rects: T,
303
- state: { selected: k, hovered: U }
304
- };
305
- });
306
- r.redraw(re, v, c, f, A), setTimeout(() => d(X.map(({ annotation: h }) => h)), 1);
307
- }), 10), w = (A) => {
308
- f = A, y();
309
- }, g = (A) => {
310
- c = A, y();
311
- }, x = (A) => {
312
- l = A, y(!1);
313
- }, R = () => y();
314
- s.observe(R);
315
- const b = o.subscribe(() => y()), p = i.subscribe(() => y()), S = () => y(!0);
316
- document.addEventListener("scroll", S, { capture: !0, passive: !0 });
317
- const E = ee(() => {
318
- s.recalculatePositions(), f?.reset(), y();
319
- }, 10);
320
- window.addEventListener("resize", E);
321
- const m = new ResizeObserver(E);
322
- m.observe(e);
323
- const a = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver(ee((A) => {
324
- A.every((N) => N.target === e || e.contains(N.target)) || y(!0);
325
- }, 150));
326
- return C.observe(document.body, a), {
327
- destroy: () => {
328
- e.removeEventListener("pointermove", u), r.destroy(), s.unobserve(R), b(), p(), document.removeEventListener("scroll", S), window.removeEventListener("resize", E), m.disconnect(), C.disconnect();
329
- },
330
- redraw: y,
331
- setStyle: g,
332
- setFilter: x,
333
- setPainter: w,
334
- setVisible: r.setVisible
335
- };
336
- }, tt = () => {
337
- const e = document.createElement("canvas");
338
- return e.width = window.innerWidth, e.height = window.innerHeight, e.className = "r6o-canvas-highlight-layer bg", e;
339
- }, nt = (e, t) => {
340
- e.width = window.innerWidth, e.height = window.innerHeight;
341
- }, ot = (e) => {
342
- console.warn('WARNING! Canvas renderer is deprecated and will be removed in the next major release. Please use the default "SPANS" renderer instead.'), e.classList.add("r6o-annotatable");
343
- const t = tt(), n = t.getContext("2d");
344
- document.body.appendChild(t);
345
- const r = (c, l, f, d) => requestAnimationFrame(() => {
346
- const { width: u, height: y } = t;
347
- n.clearRect(-0.5, -0.5, u + 1, y + 1), d && d.clear();
348
- const { top: w, left: g } = l;
349
- [...c].sort((R, b) => {
350
- const { annotation: { target: { created: p } } } = R, { annotation: { target: { created: S } } } = b;
351
- return p.getTime() - S.getTime();
352
- }).forEach((R) => {
353
- const b = f ? typeof f == "function" ? f(R.annotation, R.state) : f : R.state?.selected ? Z : _, p = d && d.paint(R, l) || b, S = R.rects.map(({ x: E, y: m, width: a, height: C }) => ({
354
- x: E + g,
355
- y: m + w,
356
- width: a,
357
- height: C
358
- }));
359
- if (n.fillStyle = p.fill, n.globalAlpha = p.fillOpacity || 1, S.forEach(
360
- ({ x: E, y: m, width: a, height: C }) => n.fillRect(E, m, a, C)
361
- ), p.underlineColor) {
362
- n.globalAlpha = 1, n.strokeStyle = p.underlineColor, n.lineWidth = p.underlineThickness ?? 1;
363
- const E = p.underlineOffset ?? 0;
364
- S.forEach(({ x: m, y: a, width: C, height: L }) => {
365
- n.beginPath(), n.moveTo(m, a + L + E), n.lineTo(m + C, a + L + E), n.stroke();
366
- });
367
- }
368
- });
369
- }), s = le(() => nt(t), 10);
370
- return window.addEventListener("resize", s), {
371
- destroy: () => {
372
- t.remove(), s.clear(), window.removeEventListener("resize", s);
373
- },
374
- setVisible: (c) => {
375
- console.log("setVisible not implemented on Canvas renderer");
376
- },
377
- redraw: r
378
- };
379
- }, st = (e, t, n) => se(e, t, n, ot(e)), rt = (e) => [
380
- `background-color:${ne(e?.fill || _.fill).alpha(e?.fillOpacity === void 0 ? _.fillOpacity : e.fillOpacity).toHex()}`,
381
- e?.underlineThickness ? "text-decoration:underline" : void 0,
382
- e?.underlineColor ? `text-decoration-color:${e.underlineColor}` : void 0,
383
- e?.underlineOffset ? `text-underline-offset:${e.underlineOffset}px` : void 0,
384
- e?.underlineThickness ? `text-decoration-thickness:${e.underlineThickness}px` : void 0
385
- ].filter(Boolean).join(";"), it = () => {
386
- const e = document.createElement("style");
387
- document.getElementsByTagName("head")[0].appendChild(e);
388
- let t = /* @__PURE__ */ new Set();
389
- return {
390
- destroy: () => {
391
- CSS.highlights.clear(), e.remove();
392
- },
393
- setVisible: (o) => {
394
- console.log("setVisible not implemented on CSS Custom Highlights renderer");
395
- },
396
- redraw: (o, i, c, l) => {
397
- l && l.clear();
398
- const f = new Set(o.map((u) => u.annotation.id));
399
- Array.from(t).filter((u) => !f.has(u));
400
- const d = o.map((u) => {
401
- const y = c ? typeof c == "function" ? c(u.annotation, u.state) : c : u.state?.selected ? Z : _, w = l && l.paint(u, i) || y;
402
- return `::highlight(_${u.annotation.id}) { ${rt(w)} }`;
403
- });
404
- e.innerHTML = d.join(`
405
- `), CSS.highlights.clear(), o.forEach(({ annotation: u }) => {
406
- const y = u.target.selector.map((g) => g.range), w = new Highlight(...y);
407
- CSS.highlights.set(`_${u.id}`, w);
408
- }), t = f;
409
- }
410
- };
411
- }, at = (e, t, n) => se(e, t, n, it()), ct = (e) => e?.fillOpacity !== void 0 ? ne(e?.fill || _.fill).alpha(e.fillOpacity).toHex() : e?.fill ? e.fill : ne(_.fill).alpha(_.fillOpacity).toHex(), lt = (e, t, n, r, s) => {
412
- const o = n ? typeof n == "function" ? n(e.annotation, e.state, s) || (e.state?.selected ? Z : _) : n : e.state?.selected ? Z : _;
413
- return r && r.paint(e, t) || o;
414
- }, dt = (e, t) => {
415
- const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y, r = (o) => o.rects.reduce((i, c) => i + c.width, 0), s = t.filter(({ rects: o }) => o.some((i) => n(e, i)));
416
- return s.sort((o, i) => r(i) - r(o)), s.findIndex((o) => o.rects.includes(e));
417
- }, ut = (e) => {
418
- e.classList.add("r6o-annotatable");
419
- const t = document.createElement("div");
420
- t.className = "r6o-span-highlight-layer", e.insertBefore(t, e.firstChild);
421
- let n = [];
422
- return {
423
- destroy: () => {
424
- t.remove();
425
- },
426
- redraw: (i, c, l, f, d) => {
427
- const y = !(ke(n, i) && d);
428
- if (!f && !y) return;
429
- y && (t.innerHTML = ""), [...i].sort((g, x) => {
430
- const { annotation: { target: { created: R } } } = g, { annotation: { target: { created: b } } } = x;
431
- return R && b ? R.getTime() - b.getTime() : 0;
432
- }).forEach((g) => {
433
- g.rects.map((x) => {
434
- const R = dt(x, i), b = lt(g, c, l, f, R);
435
- if (y) {
436
- const p = document.createElement("span");
437
- p.className = "r6o-annotation", p.dataset.annotation = g.annotation.id, p.style.left = `${x.x}px`, p.style.top = `${x.y}px`, p.style.width = `${x.width}px`, p.style.height = `${x.height}px`, p.style.backgroundColor = ct(b), b.underlineStyle && (p.style.borderStyle = b.underlineStyle), b.underlineColor && (p.style.borderColor = b.underlineColor), b.underlineThickness && (p.style.borderBottomWidth = `${b.underlineThickness}px`), b.underlineOffset && (p.style.paddingBottom = `${b.underlineOffset}px`), t.appendChild(p);
438
- }
439
- });
440
- }), n = i;
441
- },
442
- setVisible: (i) => {
443
- i ? t.classList.remove("hidden") : t.classList.add("hidden");
444
- }
445
- };
446
- }, ft = (e, t, n) => se(e, t, n, ut(e)), Ut = (e, t) => ({
447
- parse: (n) => pt(n),
448
- serialize: (n) => ht(n, e, t)
449
- }), gt = (e) => e.quote !== void 0 && e.start !== void 0 && e.end !== void 0, mt = (e) => {
246
+ return rt(e, r.target, n), !0;
247
+ const d = Q(r.target, t), { range: f } = d.selector[0];
248
+ return f && !f.collapsed ? (rt(e, d, n), !0) : !1;
249
+ }, ke = (t, e) => ({
250
+ parse: (o) => te(o),
251
+ serialize: (o) => ee(o, t, e)
252
+ }), Zt = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Jt = (t) => {
450
253
  const {
451
- id: t,
452
- creator: n,
453
- created: r,
254
+ id: e,
255
+ creator: o,
256
+ created: i,
454
257
  modified: s,
455
- target: o
456
- } = e, i = Array.isArray(o) ? o : [o];
457
- if (i.length === 0)
458
- return { error: Error(`No targets found for annotation: ${e.id}`) };
258
+ target: n
259
+ } = t, r = Array.isArray(n) ? n : [n];
260
+ if (r.length === 0)
261
+ return { error: Error(`No targets found for annotation: ${t.id}`) };
459
262
  const c = {
460
- creator: we(n),
461
- created: r ? new Date(r) : void 0,
263
+ creator: At(o),
264
+ created: i ? new Date(i) : void 0,
462
265
  updated: s ? new Date(s) : void 0,
463
- annotation: t,
266
+ annotation: e,
464
267
  selector: [],
465
268
  // @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
466
- styleClass: "styleClass" in i[0] ? i[0].styleClass : void 0
269
+ styleClass: "styleClass" in r[0] ? r[0].styleClass : void 0
467
270
  };
468
- for (const l of i) {
469
- const d = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, y) => {
470
- switch (y.type) {
271
+ for (const d of r) {
272
+ const p = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((C, h) => {
273
+ switch (h.type) {
471
274
  case "TextQuoteSelector":
472
- u.quote = y.exact;
275
+ C.quote = h.exact;
473
276
  break;
474
277
  case "TextPositionSelector":
475
- u.start = y.start, u.end = y.end;
278
+ C.start = h.start, C.end = h.end;
476
279
  break;
477
280
  }
478
- return u;
281
+ return C;
479
282
  }, {});
480
- if (gt(d))
283
+ if (Zt(p))
481
284
  c.selector.push(
482
285
  {
483
- ...d,
484
- id: l.id,
286
+ ...p,
287
+ id: d.id,
485
288
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
486
- scope: l.scope
289
+ scope: d.scope
487
290
  }
488
291
  );
489
292
  else {
490
- const u = [
491
- d.start ? void 0 : "TextPositionSelector",
492
- d.quote ? void 0 : "TextQuoteSelector"
293
+ const C = [
294
+ p.start ? void 0 : "TextPositionSelector",
295
+ p.quote ? void 0 : "TextQuoteSelector"
493
296
  ].filter(Boolean);
494
- return { error: Error(`Missing selector types: ${u.join(" and ")} for annotation: ${e.id}`) };
297
+ return { error: Error(`Missing selector types: ${C.join(" and ")} for annotation: ${t.id}`) };
495
298
  }
496
299
  }
497
300
  return { parsed: c };
498
- }, pt = (e) => {
499
- const t = e.id || de(), {
500
- creator: n,
501
- created: r,
301
+ }, te = (t) => {
302
+ const e = t.id || lt(), {
303
+ creator: o,
304
+ created: i,
502
305
  modified: s,
503
- body: o,
504
- ...i
505
- } = e, c = Ae(o, t), l = mt(e);
506
- return "error" in l ? { error: l.error } : {
306
+ body: n,
307
+ ...r
308
+ } = t, c = Ct(n, e), d = Jt(t);
309
+ return "error" in d ? { error: d.error } : {
507
310
  parsed: {
508
- ...i,
509
- id: t,
311
+ ...r,
312
+ id: e,
510
313
  bodies: c,
511
- target: l.parsed
314
+ target: d.parsed
512
315
  }
513
316
  };
514
- }, ht = (e, t, n) => {
515
- const { bodies: r, target: s, ...o } = e, {
516
- selector: i,
317
+ }, ee = (t, e, o) => {
318
+ const { bodies: i, target: s, ...n } = t, {
319
+ selector: r,
517
320
  creator: c,
518
- created: l,
321
+ created: d,
519
322
  updated: f,
520
- ...d
521
- } = s, u = i.map((y) => {
522
- const { id: w, quote: g, start: x, end: R, range: b } = y, p = {
323
+ ...p
324
+ } = s, C = r.map((h) => {
325
+ const { id: T, quote: u, start: L, end: x, range: v } = h, m = {
523
326
  type: "TextQuoteSelector",
524
- exact: g
327
+ exact: u
525
328
  };
526
- if (n) {
527
- const { prefix: E, suffix: m } = Fe(b, n);
528
- p.prefix = E, p.suffix = m;
329
+ if (o) {
330
+ const { prefix: w, suffix: a } = jt(v, o);
331
+ m.prefix = w, m.suffix = a;
529
332
  }
530
- const S = {
333
+ const E = {
531
334
  type: "TextPositionSelector",
532
- start: x,
533
- end: R
335
+ start: L,
336
+ end: x
534
337
  };
535
338
  return {
536
- ...d,
537
- id: w,
339
+ ...p,
340
+ id: T,
538
341
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
539
- scope: "scope" in y ? y.scope : void 0,
540
- source: t,
541
- selector: [p, S]
342
+ scope: "scope" in h ? h.scope : void 0,
343
+ source: e,
344
+ selector: [m, E]
542
345
  };
543
346
  });
544
347
  return {
545
- ...o,
348
+ ...n,
546
349
  "@context": "http://www.w3.org/ns/anno.jsonld",
547
- id: e.id,
350
+ id: t.id,
548
351
  type: "Annotation",
549
- body: Se(e.bodies),
352
+ body: bt(t.bodies),
550
353
  creator: c,
551
- created: l?.toISOString(),
354
+ created: d?.toISOString(),
552
355
  modified: f?.toISOString(),
553
- target: u
356
+ target: C
554
357
  };
555
- }, yt = () => {
556
- const e = document.createElement("canvas");
557
- e.width = 2 * window.innerWidth, e.height = 2 * window.innerHeight, e.className = "r6o-presence-layer";
558
- const t = e.getContext("2d");
559
- return t.scale(2, 2), t.translate(0.5, 0.5), e;
560
- }, bt = (e, t = {}) => {
561
- const n = yt(), r = n.getContext("2d");
562
- document.body.appendChild(n);
563
- const s = /* @__PURE__ */ new Map(), o = (d) => Array.from(s.entries()).filter(([u, y]) => y.presenceKey === d.presenceKey).map(([u, y]) => u);
564
- return e.on("selectionChange", (d, u) => {
565
- o(d).forEach((w) => s.delete(w)), u && u.forEach((w) => s.set(w, d));
566
- }), {
567
- clear: () => {
568
- const { width: d, height: u } = n;
569
- r.clearRect(-0.5, -0.5, d + 1, u + 1);
570
- },
571
- destroy: () => {
572
- n.remove();
573
- },
574
- paint: (d, u, y) => {
575
- t.font && (r.font = t.font);
576
- const w = s.get(d.annotation.id);
577
- if (w) {
578
- const { height: g } = d.rects[0], x = d.rects[0].x + u.left, R = d.rects[0].y + u.top;
579
- r.fillStyle = w.appearance.color, r.fillRect(x - 2, R - 2.5, 2, g + 5);
580
- const b = r.measureText(w.appearance.label), p = b.width + 6, S = b.actualBoundingBoxAscent + b.actualBoundingBoxDescent + 8, E = b.fontBoundingBoxAscent ? 8 : 6.5;
581
- return r.fillRect(x - 2, R - 2.5 - S, p, S), r.fillStyle = "#fff", r.fillText(w.appearance.label, x + 1, R - E), {
582
- fill: w.appearance.color,
583
- fillOpacity: y ? 0.45 : 0.18
584
- };
585
- }
586
- },
587
- reset: () => {
588
- n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
589
- const d = n.getContext("2d");
590
- d.scale(2, 2), d.translate(0.5, 0.5);
358
+ }, ne = (t, e) => {
359
+ const o = (n, r) => n.x <= r.x + r.width && n.x + n.width >= r.x && n.y <= r.y + r.height && n.y + n.height >= r.y, i = (n) => n.rects.reduce((r, c) => r + c.width, 0), s = e.filter(({ rects: n }) => n.some((r) => o(t, r)));
360
+ return s.sort((n, r) => i(r) - i(n)), s.findIndex((n) => n.rects.includes(t));
361
+ }, oe = (t) => {
362
+ const e = [], o = document.createNodeIterator(
363
+ t.commonAncestorContainer,
364
+ NodeFilter.SHOW_TEXT
365
+ );
366
+ let i;
367
+ for (; i = o.nextNode(); )
368
+ t.intersectsNode(i) && e.push(i);
369
+ if (e.length < 2)
370
+ return Array.from(t.getClientRects());
371
+ {
372
+ const s = e[0], n = e[e.length - 1], r = document.createRange();
373
+ if (r.selectNode(s), t.startContainer.nodeType === Node.TEXT_NODE)
374
+ r.setStart(s, t.startOffset);
375
+ else {
376
+ const f = t.startContainer.childNodes[t.startOffset];
377
+ f ? r.setStartBefore(f) : r.setStartAfter(t.startContainer);
378
+ }
379
+ const c = document.createRange();
380
+ if (c.selectNode(n), t.endContainer.nodeType === Node.TEXT_NODE)
381
+ c.setEnd(n, t.endOffset);
382
+ else {
383
+ const f = t.endContainer.childNodes[t.endOffset];
384
+ f ? c.setEndBefore(f) : c.setEndAfter(t.endContainer);
591
385
  }
386
+ const d = (f) => {
387
+ const p = document.createRange();
388
+ return p.selectNode(f), Array.from(p.getClientRects());
389
+ };
390
+ return [
391
+ ...Array.from(r.getClientRects()),
392
+ ...e.slice(1, -1).flatMap(d),
393
+ ...Array.from(c.getClientRects())
394
+ ];
395
+ }
396
+ }, se = (t, e, o, i) => {
397
+ const s = (c) => Math.round(c * 10) / 10, n = {
398
+ top: s(t.top),
399
+ bottom: s(t.bottom),
400
+ left: s(t.left),
401
+ right: s(t.right)
402
+ }, r = {
403
+ top: s(e.top),
404
+ bottom: s(e.bottom),
405
+ left: s(e.left),
406
+ right: s(e.right)
592
407
  };
593
- }, Et = (e, t, n, r) => {
594
- const s = new Me(), o = /* @__PURE__ */ new Map(), i = Ie(), c = (m, a) => {
595
- const C = m.selector.flatMap((A) => {
596
- const v = I([A]) ? A.range : me(A, t).range;
597
- return Ke(v);
598
- }), L = ze(C, n, r).map((A) => Ge(A, a));
599
- return L.map((A) => {
600
- const { x: v, y: N, width: O, height: D } = A;
408
+ if (Math.abs(n.top - r.top) < i && Math.abs(n.bottom - r.bottom) < i) {
409
+ if (Math.abs(n.left - r.right) < o || Math.abs(n.right - r.left) < o)
410
+ return "inline-adjacent";
411
+ if (n.left >= r.left && n.right <= r.right)
412
+ return "inline-is-contained";
413
+ if (n.left <= r.left && n.right >= r.right)
414
+ return "inline-contains";
415
+ } else if (n.top <= r.top && n.bottom >= r.bottom) {
416
+ if (n.left <= r.left && n.right >= r.right)
417
+ return "block-contains";
418
+ } else if (n.top >= r.top && n.bottom <= r.bottom && n.left >= r.left && n.right <= r.right)
419
+ return "block-is-contained";
420
+ }, re = (t, e) => {
421
+ const o = Math.min(t.left, e.left), i = Math.max(t.right, e.right), s = Math.min(t.top, e.top), n = Math.max(t.bottom, e.bottom);
422
+ return new DOMRect(o, s, i - o, n - s);
423
+ }, ie = (t, e = 0.5, o = 0.5) => t.reduce((i, s) => {
424
+ if (s.width === 0 || s.height === 0)
425
+ return i;
426
+ let n = [...i], r = !1;
427
+ for (const c of i) {
428
+ const d = se(s, c, e, o);
429
+ if (d === "inline-adjacent") {
430
+ n = n.map((f) => f === c ? re(s, c) : f), r = !0;
431
+ break;
432
+ } else if (d === "inline-contains") {
433
+ n = n.map((f) => f === c ? s : f), r = !0;
434
+ break;
435
+ } else if (d === "inline-is-contained") {
436
+ r = !0;
437
+ break;
438
+ } else if (d === "block-contains" || d === "block-is-contained") {
439
+ s.width < c.width && (n = n.map((f) => f === c ? s : f)), s.width === c.width && s.height < c.width && (n = n.map((f) => f === c ? s : f)), r = !0;
440
+ break;
441
+ }
442
+ }
443
+ return r ? n : [...n, s];
444
+ }, []), Me = (t) => ({
445
+ length: t.length,
446
+ item: (e) => t[e],
447
+ [Symbol.iterator]: function* () {
448
+ for (let e = 0; e < this.length; e++)
449
+ yield this.item(e);
450
+ }
451
+ }), ce = (t, e) => {
452
+ const { left: o, top: i, right: s, bottom: n } = t;
453
+ return new DOMRect(o - e.left, i - e.top, s - o, n - i);
454
+ }, Be = (t, e) => {
455
+ const { left: o, top: i, right: s, bottom: n } = t;
456
+ return new DOMRect(o + e.left, i + e.top, s - o, n - i);
457
+ }, ae = (t, e, o, i) => {
458
+ const s = new Bt(), n = /* @__PURE__ */ new Map(), r = at(), c = (a, l) => {
459
+ const A = a.selector.flatMap((N) => {
460
+ const y = D([N]) ? N.range : pt(N, e).range;
461
+ return oe(y);
462
+ }), R = ie(A, o, i).map((N) => ce(N, l));
463
+ return R.map((N) => {
464
+ const { x: y, y: b, width: O, height: B } = N;
601
465
  return {
602
- minX: v,
603
- minY: N,
604
- maxX: v + O,
605
- maxY: N + D,
466
+ minX: y,
467
+ minY: b,
468
+ maxX: y + O,
469
+ maxY: b + B,
606
470
  annotation: {
607
- id: m.annotation,
608
- rects: L
471
+ id: a.annotation,
472
+ rects: R
609
473
  }
610
474
  };
611
475
  });
612
- }, l = () => [...o.values()], f = () => {
613
- s.clear(), o.clear();
614
- }, d = (m) => {
615
- const a = c(m, t.getBoundingClientRect());
616
- a.length !== 0 && (a.forEach((C) => s.insert(C)), o.set(m.annotation, a));
617
- }, u = (m) => {
618
- const a = o.get(m.annotation);
619
- a && (a.forEach((C) => s.remove(C)), o.delete(m.annotation));
620
- }, y = (m) => {
621
- u(m), d(m);
622
- }, w = (m, a = !0) => {
623
- a && f();
624
- const C = t.getBoundingClientRect(), L = m.map((v) => ({ target: v, rects: c(v, C) }));
625
- L.forEach(({ target: v, rects: N }) => {
626
- N.length > 0 && o.set(v.annotation, N);
476
+ }, d = () => [...n.values()], f = () => {
477
+ s.clear(), n.clear();
478
+ }, p = (a) => {
479
+ const l = c(a, e.getBoundingClientRect());
480
+ l.length !== 0 && (l.forEach((A) => s.insert(A)), n.set(a.annotation, l));
481
+ }, C = (a) => {
482
+ const l = n.get(a.annotation);
483
+ l && (l.forEach((A) => s.remove(A)), n.delete(a.annotation));
484
+ }, h = (a) => {
485
+ C(a), p(a);
486
+ }, T = (a, l = !0) => {
487
+ l && f();
488
+ const A = e.getBoundingClientRect(), R = a.map((y) => ({ target: y, rects: c(y, A) }));
489
+ R.forEach(({ target: y, rects: b }) => {
490
+ b.length > 0 && n.set(y.annotation, b);
627
491
  });
628
- const A = L.flatMap(({ rects: v }) => v);
629
- s.load(A);
630
- }, g = (m, a, C = !1) => {
631
- const L = s.search({
632
- minX: m,
633
- minY: a,
634
- maxX: m,
635
- maxY: a
636
- }), A = (v) => v.annotation.rects.reduce((N, O) => N + O.width * O.height, 0);
637
- return L.length > 0 ? (L.sort((v, N) => A(v) - A(N)), C ? L.map((v) => v.annotation.id) : [L[0].annotation.id]) : [];
638
- }, x = (m) => {
639
- const a = R(m);
640
- if (a.length === 0)
492
+ const N = R.flatMap(({ rects: y }) => y);
493
+ s.load(N);
494
+ }, u = (a, l, A = !1) => {
495
+ const R = s.search({
496
+ minX: a,
497
+ minY: l,
498
+ maxX: a,
499
+ maxY: l
500
+ }), N = (y) => y.annotation.rects.reduce((b, O) => b + O.width * O.height, 0);
501
+ return R.length > 0 ? (R.sort((y, b) => N(y) - N(b)), A ? R.map((y) => y.annotation.id) : [R[0].annotation.id]) : [];
502
+ }, L = (a) => {
503
+ const l = x(a);
504
+ if (l.length === 0)
641
505
  return;
642
- let C = a[0].left, L = a[0].top, A = a[0].right, v = a[0].bottom;
643
- for (let N = 1; N < a.length; N++) {
644
- const O = a[N];
645
- C = Math.min(C, O.left), L = Math.min(L, O.top), A = Math.max(A, O.right), v = Math.max(v, O.bottom);
506
+ let A = l[0].left, R = l[0].top, N = l[0].right, y = l[0].bottom;
507
+ for (let b = 1; b < l.length; b++) {
508
+ const O = l[b];
509
+ A = Math.min(A, O.left), R = Math.min(R, O.top), N = Math.max(N, O.right), y = Math.max(y, O.bottom);
646
510
  }
647
- return new DOMRect(C, L, A - C, v - L);
648
- }, R = (m) => {
649
- const a = o.get(m);
650
- return a ? a[0].annotation.rects : [];
511
+ return new DOMRect(A, R, N - A, y - R);
512
+ }, x = (a) => {
513
+ const l = n.get(a);
514
+ return l ? l[0].annotation.rects : [];
651
515
  };
652
516
  return {
653
- all: l,
517
+ all: d,
654
518
  clear: f,
655
- getAt: g,
656
- getAnnotationBounds: x,
657
- getAnnotationRects: R,
658
- getIntersecting: (m, a, C, L) => {
659
- const A = s.search({ minX: m, minY: a, maxX: C, maxY: L }), v = new Set(A.map((N) => N.annotation.id));
660
- return Array.from(v).map((N) => ({
661
- annotation: e.getAnnotation(N),
662
- rects: R(N)
663
- })).filter((N) => !!N.annotation);
519
+ getAt: u,
520
+ getAnnotationBounds: L,
521
+ getAnnotationRects: x,
522
+ getIntersecting: (a, l, A, R) => {
523
+ const N = s.search({ minX: a, minY: l, maxX: A, maxY: R }), y = new Set(N.map((b) => b.annotation.id));
524
+ return Array.from(y).map((b) => ({
525
+ annotation: t.getAnnotation(b),
526
+ rects: x(b)
527
+ })).filter((b) => !!b.annotation);
664
528
  },
665
- insert: d,
529
+ insert: p,
666
530
  recalculate: () => {
667
- w(e.all().map((m) => m.target), !0), i.emit("recalculate");
531
+ T(t.all().map((a) => a.target), !0), r.emit("recalculate");
668
532
  },
669
- remove: u,
670
- set: w,
533
+ remove: C,
534
+ set: T,
671
535
  size: () => s.all().length,
672
- update: y,
673
- on: (m, a) => i.on(m, a)
536
+ update: h,
537
+ on: (a, l) => r.on(a, l)
674
538
  };
675
- }, Ct = (e, t) => {
676
- const n = Re(), r = Et(n, e, t.mergeHighlights?.horizontalTolerance, t.mergeHighlights?.verticalTolerance), s = Te(n, t.userSelectAction, t.adapter), o = ve(n), i = xe(), c = (p, S = K.LOCAL) => {
677
- const E = te(p, e), m = I(E.target.selector);
678
- return m && n.addAnnotation(E, S), m;
679
- }, l = (p, S = !0, E = K.LOCAL) => {
680
- const m = p.map((C) => te(C, e)), a = m.filter((C) => !I(C.target.selector));
681
- return n.bulkAddAnnotations(m, S, E), a;
682
- }, f = (p, S = K.LOCAL) => {
683
- const E = p.map((a) => te(a, e)), m = E.filter((a) => !I(a.target.selector));
684
- return E.forEach((a) => {
685
- n.getAnnotation(a.id) ? n.updateAnnotation(a, S) : n.addAnnotation(a, S);
686
- }), m;
687
- }, d = (p, S = K.LOCAL) => {
688
- const E = Q(p, e);
689
- n.updateTarget(E, S);
690
- }, u = (p, S = K.LOCAL) => {
691
- const E = p.map((m) => Q(m, e));
692
- n.bulkUpdateTargets(E, S);
539
+ }, le = (t, e) => {
540
+ const o = Tt(), i = ae(o, t, e.mergeHighlights?.horizontalTolerance, e.mergeHighlights?.verticalTolerance), s = Rt(o, e.userSelectAction, e.adapter), n = vt(o), r = wt(), c = (m, E = F.LOCAL) => {
541
+ const w = tt(m, t), a = D(w.target.selector);
542
+ return a && o.addAnnotation(w, E), a;
543
+ }, d = (m, E = !0, w = F.LOCAL) => {
544
+ const a = m.map((A) => tt(A, t)), l = a.filter((A) => !D(A.target.selector));
545
+ return o.bulkAddAnnotations(a, E, w), l;
546
+ }, f = (m, E = F.LOCAL) => {
547
+ const w = m.map((l) => tt(l, t)), a = w.filter((l) => !D(l.target.selector));
548
+ return w.forEach((l) => {
549
+ o.getAnnotation(l.id) ? o.updateAnnotation(l, E) : o.addAnnotation(l, E);
550
+ }), a;
551
+ }, p = (m, E = F.LOCAL) => {
552
+ const w = Q(m, t);
553
+ o.updateTarget(w, E);
554
+ }, C = (m, E = F.LOCAL) => {
555
+ const w = m.map((a) => Q(a, t));
556
+ o.bulkUpdateTargets(w, E);
693
557
  };
694
- function y(p, S, E, m) {
695
- const a = E || !!m, C = r.getAt(p, S, a).map((A) => n.getAnnotation(A)), L = m ? C.filter(m) : C;
696
- if (L.length !== 0)
697
- return E ? L : L[0];
558
+ function h(m, E, w, a) {
559
+ const l = w || !!a, A = i.getAt(m, E, l).map((N) => o.getAnnotation(N)), R = a ? A.filter(a) : A;
560
+ if (R.length !== 0)
561
+ return w ? R : R[0];
698
562
  }
699
- const w = (p) => r.getAnnotationRects(p).length > 0 ? r.getAnnotationBounds(p) : void 0, g = (p, S, E, m) => r.getIntersecting(p, S, E, m), x = (p) => r.getAnnotationRects(p), R = () => r.recalculate(), b = (p) => r.on("recalculate", p);
700
- return n.observe(({ changes: p }) => {
701
- const S = (p.deleted || []).filter((a) => I(a.target.selector)), E = (p.created || []).filter((a) => I(a.target.selector)), m = (p.updated || []).filter((a) => I(a.newValue.target.selector));
702
- S?.length > 0 && S.forEach((a) => r.remove(a.target)), E.length > 0 && r.set(E.map((a) => a.target), !1), m?.length > 0 && m.forEach(({ newValue: a }) => r.update(a.target));
563
+ const T = (m) => i.getAnnotationRects(m).length > 0 ? i.getAnnotationBounds(m) : void 0, u = (m, E, w, a) => i.getIntersecting(m, E, w, a), L = (m) => i.getAnnotationRects(m), x = () => i.recalculate(), v = (m) => i.on("recalculate", m);
564
+ return o.observe(({ changes: m }) => {
565
+ const E = (m.deleted || []).filter((l) => D(l.target.selector)), w = (m.created || []).filter((l) => D(l.target.selector)), a = (m.updated || []).filter((l) => D(l.newValue.target.selector));
566
+ E?.length > 0 && E.forEach((l) => i.remove(l.target)), w.length > 0 && i.set(w.map((l) => l.target), !1), a?.length > 0 && a.forEach(({ newValue: l }) => i.update(l.target));
703
567
  }), {
704
568
  store: {
705
- ...n,
569
+ ...o,
706
570
  addAnnotation: c,
707
- bulkAddAnnotations: l,
708
- bulkUpdateTargets: u,
571
+ bulkAddAnnotations: d,
572
+ bulkUpdateTargets: C,
709
573
  bulkUpsertAnnotations: f,
710
- getAnnotationBounds: w,
711
- getAnnotationRects: x,
712
- getIntersecting: g,
713
- getAt: y,
714
- recalculatePositions: R,
715
- onRecalculatePositions: b,
716
- updateTarget: d
574
+ getAnnotationBounds: T,
575
+ getAnnotationRects: L,
576
+ getIntersecting: u,
577
+ getAt: h,
578
+ recalculatePositions: x,
579
+ onRecalculatePositions: v,
580
+ updateTarget: p
717
581
  },
718
582
  selection: s,
719
- hover: o,
720
- viewport: i
583
+ hover: n,
584
+ viewport: r
721
585
  };
722
- }, ae = 300, he = ["up", "down", "left", "right"], ye = fe ? "⌘+a" : "ctrl+a", St = [
723
- ...he.map((e) => `shift+${e}`),
724
- ye
725
- ], At = (e, t, n, r) => {
726
- const { store: s, selection: o } = t;
727
- let i;
586
+ }, it = 300, yt = ["up", "down", "left", "right"], St = dt ? "⌘+a" : "ctrl+a", de = [
587
+ ...yt.map((t) => `shift+${t}`),
588
+ St
589
+ ], ue = (t, e, o, i) => {
590
+ const { store: s, selection: n } = e;
591
+ let r;
728
592
  const {
729
593
  annotatingEnabled: c,
730
- offsetReferenceSelector: l,
594
+ offsetReferenceSelector: d,
731
595
  selectionMode: f,
732
- dismissOnNotAnnotatable: d = "NEVER"
733
- } = r;
734
- let u, y = c, w = "CREATE_NEW", g, x, R, b;
735
- const p = (h) => {
736
- y = h, L.clear(), h || (x = void 0, g = void 0, R = void 0, b = void 0);
737
- }, S = (h) => w = h || "CREATE_NEW", E = (h) => u = h, m = (h) => i = h, a = (h) => {
738
- if (w === "ADD_TO_CURRENT")
596
+ dismissOnNotAnnotatable: p = "NEVER"
597
+ } = i;
598
+ let C, h = c, T = "CREATE_NEW", u, L, x, v;
599
+ const m = (g) => {
600
+ h = g, R.clear(), g || (L = void 0, u = void 0, x = void 0, v = void 0);
601
+ }, E = (g) => T = g || "CREATE_NEW", w = (g) => C = g, a = (g) => r = g, l = (g) => {
602
+ if (T === "ADD_TO_CURRENT")
739
603
  return !0;
740
- if (r.allowModifierSelect) {
741
- const T = h;
742
- return fe ? T.metaKey : T.ctrlKey;
604
+ if (i.allowModifierSelect) {
605
+ const S = g;
606
+ return dt ? S.metaKey : S.ctrlKey;
743
607
  } else
744
608
  return !1;
745
- }, C = () => {
746
- if (!y || R === !1) return;
747
- const { selected: h } = o;
748
- if ((a(b) || w === "REPLACE_CURRENT") && h.length === 1 && h[0].editable) {
749
- const k = s.getAnnotation(h[0].id);
750
- if (k?.target) {
751
- x = k.target, g = {
752
- annotation: k.id,
609
+ }, A = () => {
610
+ if (!h || x === !1) return;
611
+ const { selected: g } = n;
612
+ if ((l(v) || T === "REPLACE_CURRENT") && g.length === 1 && g[0].editable) {
613
+ const M = s.getAnnotation(g[0].id);
614
+ if (M?.target) {
615
+ L = M.target, u = {
616
+ annotation: M.id,
753
617
  selector: [],
754
- created: x.created,
755
- creator: x.creator,
618
+ created: L.created,
619
+ creator: L.creator,
756
620
  updated: /* @__PURE__ */ new Date(),
757
- updatedBy: i
621
+ updatedBy: r
758
622
  };
759
623
  return;
760
624
  }
761
625
  }
762
- x = void 0, g = {
763
- annotation: de(),
626
+ L = void 0, u = {
627
+ annotation: lt(),
764
628
  selector: [],
765
629
  created: /* @__PURE__ */ new Date(),
766
- creator: i
630
+ creator: r
767
631
  };
768
- }, L = le((h) => {
769
- if (!y) return;
770
- const T = document.getSelection();
771
- if (!T?.anchorNode) return;
772
- const k = Array.from(Array(T.rangeCount).keys()).map((B) => T.getRangeAt(B));
773
- if (!k.some((B) => B.intersectsNode(e))) {
774
- g = void 0;
632
+ }, R = It((g) => {
633
+ if (!h) return;
634
+ const S = document.getSelection();
635
+ if (!S?.anchorNode) return;
636
+ const M = Array.from(Array(S.rangeCount).keys()).map((k) => S.getRangeAt(k));
637
+ if (!M.some((k) => k.intersectsNode(t))) {
638
+ u = void 0;
775
639
  return;
776
640
  }
777
- const U = h.timeStamp - (b?.timeStamp || h.timeStamp);
778
- if (b?.type === "pointerdown" && (U < 1e3 && !g || T.isCollapsed && U < ae) && C(), g || C(), T.isCollapsed) {
779
- s.getAnnotation(g.annotation) && !(a(b) || w === "REPLACE_CURRENT") && (o.clear(), s.deleteAnnotation(g.annotation));
641
+ const U = g.timeStamp - (v?.timeStamp || g.timeStamp);
642
+ if (v?.type === "pointerdown" && (U < 1e3 && !u || S.isCollapsed && U < it) && A(), u || A(), S.isCollapsed) {
643
+ s.getAnnotation(u.annotation) && !(l(v) || T === "REPLACE_CURRENT") && (n.clear(), s.deleteAnnotation(u.annotation));
780
644
  return;
781
645
  }
782
- const H = k.map((B) => Qe(B, e));
783
- if (H.every((B) => Ve(B))) return;
784
- const M = H.flatMap((B) => $e(e, B.cloneRange()));
785
- if (!(M.length > 0 && !g || M.length !== g.selector.length || M.some((B, F) => B.toString() !== g.selector[F]?.quote))) return;
786
- const z = a(b) && x ? qe([
787
- ...x.selector.map((B) => B.range),
788
- ...M
789
- ]) : M;
790
- g = {
791
- ...g,
792
- selector: z.map((B) => je(B, e, l)),
646
+ const I = M.map((k) => Wt(k, t));
647
+ if (I.every((k) => Ut(k))) return;
648
+ const _ = I.flatMap((k) => Yt(t, k.cloneRange()));
649
+ if (!(_.length > 0 && !u || _.length !== u.selector.length || _.some((k, Y) => k.toString() !== u.selector[Y]?.quote))) return;
650
+ const z = l(v) && L ? Kt([
651
+ ...L.selector.map((k) => k.range),
652
+ ..._
653
+ ]) : _;
654
+ u = {
655
+ ...u,
656
+ selector: z.map((k) => Gt(k, t, d)),
793
657
  updated: /* @__PURE__ */ new Date()
794
- }, !(a(b) || w === "REPLACE_CURRENT") && (s.getAnnotation(g.annotation) ? s.updateTarget(g, K.LOCAL) : o.clear());
795
- }, 10), A = (h) => {
796
- b = J(h), R = b.button === 0;
797
- }, v = async (h) => {
798
- if (!R) return;
799
- const T = J(h), k = () => {
800
- const { x: H, y: M } = e.getBoundingClientRect();
801
- if (G(e, T.target)) {
802
- (typeof d == "function" ? d(T, e) : d === "ALWAYS") && o.clear();
658
+ }, !(l(v) || T === "REPLACE_CURRENT") && (s.getAnnotation(u.annotation) ? s.updateTarget(u, F.LOCAL) : n.clear());
659
+ }, 10), N = (g) => {
660
+ v = Z(g), x = v.button === 0;
661
+ }, y = async (g) => {
662
+ if (!x) return;
663
+ const S = Z(g), M = () => {
664
+ const { x: I, y: _ } = t.getBoundingClientRect();
665
+ if (G(t, S.target)) {
666
+ (typeof p == "function" ? p(S, t) : p === "ALWAYS") && n.clear();
803
667
  return;
804
668
  }
805
- const P = T.target instanceof Node && e.contains(T.target) && s.getAt(
806
- T.clientX - H,
807
- T.clientY - M,
669
+ const H = S.target instanceof Node && t.contains(S.target) && s.getAt(
670
+ S.clientX - I,
671
+ S.clientY - _,
808
672
  f === "all",
809
- u
673
+ C
810
674
  );
811
- if (P) {
812
- const { selected: z } = o, B = new Set(z.map((V) => V.id)), F = Array.isArray(P) ? P.map((V) => V.id) : [P.id];
813
- (B.size !== F.length || !F.every((V) => B.has(V))) && (n.emit("clickAnnotation", P), o.userSelect(F, T));
675
+ if (H) {
676
+ const { selected: z } = n, k = new Set(z.map((W) => W.id)), Y = Array.isArray(H) ? H.map((W) => W.id) : [H.id];
677
+ (k.size !== Y.length || !Y.every((W) => k.has(W))) && (o.emit("clickAnnotation", H), n.userSelect(Y, S));
814
678
  } else
815
- o.clear();
679
+ n.clear();
816
680
  };
817
- if (T.timeStamp - b.timeStamp < ae) {
818
- await N();
819
- const H = document.getSelection(), M = G(e, b.target), P = G(e, T.target);
820
- if (H?.isCollapsed || M && P) {
821
- g = void 0, k();
681
+ if (S.timeStamp - v.timeStamp < it) {
682
+ await b();
683
+ const I = document.getSelection(), _ = G(t, v.target), H = G(t, S.target);
684
+ if (I?.isCollapsed || _ && H) {
685
+ u = void 0, M();
822
686
  return;
823
687
  }
824
688
  }
825
- g && g.selector.length > 0 && ($(), o.userSelect(g.annotation, T));
826
- }, N = async () => {
827
- const h = document.getSelection();
828
- let T = !1, k = h?.isCollapsed;
829
- const U = () => k || T, H = 1;
830
- return setTimeout(() => T = !0, 50), _e(() => k = h?.isCollapsed, H, U);
831
- }, O = (h) => {
832
- document.getSelection()?.isCollapsed || ((!g || g.selector.length === 0) && L(h), g && ($(), o.userSelect(g.annotation, J(h))));
833
- }, D = (h) => {
834
- y && h.key === "Shift" && g && (document.getSelection().isCollapsed || ($(), o.userSelect(g.annotation, j(h))));
835
- }, Y = (h) => {
836
- const T = () => setTimeout(() => {
837
- g?.selector.length > 0 && (o.clear(), s.addAnnotation({
838
- id: g.annotation,
689
+ u && u.selector.length > 0 && (K(), n.userSelect(u.annotation, S));
690
+ }, b = async () => {
691
+ const g = document.getSelection();
692
+ let S = !1, M = g?.isCollapsed;
693
+ const U = () => M || S, I = 1;
694
+ return setTimeout(() => S = !0, 50), _t(() => M = g?.isCollapsed, I, U);
695
+ }, O = (g) => {
696
+ document.getSelection()?.isCollapsed || ((!u || u.selector.length === 0) && R(g), u && (K(), n.userSelect(u.annotation, Z(g))));
697
+ }, B = (g) => {
698
+ h && g.key === "Shift" && u && (document.getSelection().isCollapsed || (K(), n.userSelect(u.annotation, j(g))));
699
+ }, X = (g) => {
700
+ const S = () => setTimeout(() => {
701
+ u?.selector.length > 0 && (n.clear(), s.addAnnotation({
702
+ id: u.annotation,
839
703
  bodies: [],
840
- target: g
841
- }), o.userSelect(g.annotation, j(h))), document.removeEventListener("selectionchange", T);
704
+ target: u
705
+ }), n.userSelect(u.annotation, j(g))), document.removeEventListener("selectionchange", S);
842
706
  }, 100);
843
- document.addEventListener("selectionchange", T), C();
707
+ document.addEventListener("selectionchange", S), A();
844
708
  };
845
- q(St.join(","), { element: e, keydown: !0, keyup: !1 }, (h) => {
846
- h.repeat || (b = j(h));
847
- }), q(ye, { keydown: !0, keyup: !1 }, (h) => {
848
- b = j(h), Y(h);
709
+ q(de.join(","), { element: t, keydown: !0, keyup: !1 }, (g) => {
710
+ g.repeat || (v = j(g));
711
+ }), q(St, { keydown: !0, keyup: !1 }, (g) => {
712
+ v = j(g), X(g);
849
713
  });
850
- const X = (h) => {
851
- h.repeat || h.target !== e && h.target !== document.body || (g = void 0, o.clear());
714
+ const V = (g) => {
715
+ g.repeat || g.target !== t && g.target !== document.body || (u = void 0, n.clear());
852
716
  };
853
- q(he.join(","), { keydown: !0, keyup: !1 }, X);
854
- const $ = () => {
855
- const h = s.getAnnotation(g.annotation);
856
- if (!h)
717
+ q(yt.join(","), { keydown: !0, keyup: !1 }, V);
718
+ const K = () => {
719
+ const g = s.getAnnotation(u.annotation);
720
+ if (!g)
857
721
  s.addAnnotation({
858
- id: g.annotation,
722
+ id: u.annotation,
859
723
  bodies: [],
860
- target: g
724
+ target: u
861
725
  });
862
726
  else {
863
- const { target: { updated: T } } = h, { updated: k } = g;
864
- (!T || !k || T < k) && s.updateTarget(g);
727
+ const { target: { updated: S } } = g, { updated: M } = u;
728
+ (!S || !M || S < M) && s.updateTarget(u);
865
729
  }
866
730
  };
867
- return document.addEventListener("pointerdown", A), document.addEventListener("pointerup", v), document.addEventListener("contextmenu", O), e.addEventListener("keyup", D), e.addEventListener("selectstart", C), document.addEventListener("selectionchange", L), {
731
+ return document.addEventListener("pointerdown", N), document.addEventListener("pointerup", y), document.addEventListener("contextmenu", O), t.addEventListener("keyup", B), t.addEventListener("selectstart", A), document.addEventListener("selectionchange", R), {
868
732
  destroy: () => {
869
- g = void 0, x = void 0, R = void 0, b = void 0, L.clear(), document.removeEventListener("pointerdown", A), document.removeEventListener("pointerup", v), document.removeEventListener("contextmenu", O), e.removeEventListener("keyup", D), e.removeEventListener("selectstart", C), document.removeEventListener("selectionchange", L), q.unbind();
733
+ u = void 0, L = void 0, x = void 0, v = void 0, R.clear(), document.removeEventListener("pointerdown", N), document.removeEventListener("pointerup", y), document.removeEventListener("contextmenu", O), t.removeEventListener("keyup", B), t.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", R), q.unbind();
870
734
  },
871
- setFilter: E,
872
- setUser: m,
873
- setAnnotatingEnabled: p,
874
- setAnnotatingMode: S
735
+ setFilter: w,
736
+ setUser: a,
737
+ setAnnotatingEnabled: m,
738
+ setAnnotatingMode: E
739
+ };
740
+ }, fe = (t) => {
741
+ t.classList.add("r6o-annotatable");
742
+ const e = document.createElement("div");
743
+ e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
744
+ let o = [];
745
+ return {
746
+ destroy: () => {
747
+ e.remove();
748
+ },
749
+ redraw: (r, c, d, f, p) => {
750
+ if (!(!Dt(o, r) || p)) return;
751
+ e.innerHTML = "", [...r].sort((u, L) => {
752
+ const { annotation: { target: { created: x } } } = u, { annotation: { target: { created: v } } } = L;
753
+ return x && v ? x.getTime() - v.getTime() : 0;
754
+ }).forEach((u) => {
755
+ const L = f.get(u.annotation.id) || d;
756
+ u.rects.map((x) => {
757
+ const v = ne(x, r), m = mt(u, L, v), E = document.createElement("span");
758
+ E.className = "r6o-annotation", E.dataset.annotation = u.annotation.id, E.style.left = `${x.x}px`, E.style.top = `${x.y}px`, E.style.width = `${x.width}px`, E.style.height = `${x.height}px`, E.style.backgroundColor = Vt(m), m.underlineStyle && (E.style.borderStyle = m.underlineStyle), m.underlineColor && (E.style.borderColor = m.underlineColor), m.underlineThickness && (E.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (E.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(E);
759
+ });
760
+ }), o = r;
761
+ },
762
+ setVisible: (r) => {
763
+ r ? e.classList.remove("hidden") : e.classList.add("hidden");
764
+ }
875
765
  };
876
- }, wt = (e, t) => ({
877
- ...e,
878
- annotatingEnabled: e.annotatingEnabled ?? t.annotatingEnabled,
879
- user: e.user || t.user
880
- }), ce = "SPANS", Kt = (e, t = {}) => {
881
- Pe(e), Ue(e);
882
- const n = wt(t, {
766
+ }, ge = (t, e, o) => gt(fe(t), t, e, o), me = (t) => [
767
+ `background-color:${et(t?.fill || P.fill).alpha(t?.fillOpacity === void 0 ? P.fillOpacity : t.fillOpacity).toHex()}`,
768
+ t?.underlineThickness ? "text-decoration:underline" : void 0,
769
+ t?.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
770
+ t?.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
771
+ t?.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
772
+ ].filter(Boolean).join(";"), pe = () => {
773
+ const t = document.createElement("style");
774
+ document.getElementsByTagName("head")[0].appendChild(t);
775
+ let e = /* @__PURE__ */ new Set();
776
+ return {
777
+ destroy: () => {
778
+ CSS.highlights.clear(), t.remove();
779
+ },
780
+ setVisible: (n) => {
781
+ console.log("setVisible not implemented on CSS Custom Highlights renderer");
782
+ },
783
+ redraw: (n, r, c, d, f) => {
784
+ const p = new Set(n.map((h) => h.annotation.id));
785
+ Array.from(e).filter((h) => !p.has(h));
786
+ const C = n.map((h) => {
787
+ c ? typeof c == "function" && c(h.annotation, h.state) : h.state?.selected;
788
+ const T = mt(h, c);
789
+ return `::highlight(_${h.annotation.id}) { ${me(T)} }`;
790
+ });
791
+ t.innerHTML = C.join(`
792
+ `), CSS.highlights.clear(), n.forEach(({ annotation: h }) => {
793
+ const T = h.target.selector.map((L) => L.range), u = new Highlight(...T);
794
+ CSS.highlights.set(`_${h.id}`, u);
795
+ }), e = p;
796
+ }
797
+ };
798
+ }, he = (t, e, o) => gt(pe(), t, e, o), ye = (t, e) => ({
799
+ ...t,
800
+ annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
801
+ user: t.user || e.user
802
+ }), ct = "SPANS", Ie = (t, e = {}) => {
803
+ Xt(t), Ft(t);
804
+ const o = ye(e, {
883
805
  annotatingEnabled: !0,
884
- user: Le()
885
- }), r = Ct(e, n), { selection: s, viewport: o } = r, i = r.store, c = Ne(i), l = Oe(r, c, n.adapter);
886
- let f = n.user;
887
- const d = typeof n.renderer != "function" ? n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ce : n.renderer || ce : null, u = d === null ? n.renderer(e, r, o) : d === "SPANS" ? ft(e, r, o) : d === "CSS_HIGHLIGHTS" ? at(e, r, o) : d === "CANVAS" ? st(e, r, o) : void 0;
888
- if (!u)
889
- throw `Unknown renderer implementation: ${n.renderer}`;
890
- console.debug(d ? `Using ${d} renderer` : "Using custom renderer implementation"), n.style && u.setStyle(n.style);
891
- const y = At(e, r, l, n);
892
- y.setUser(f);
893
- const w = Be(r, c, n.adapter), g = () => f, x = (a) => {
894
- y.setAnnotatingEnabled(
806
+ user: xt()
807
+ }), i = le(t, o), { selection: s, viewport: n } = i, r = i.store, c = Lt(r), d = Nt(i, c, o.adapter);
808
+ let f = o.user;
809
+ const p = typeof o.renderer != "function" ? o.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ct : o.renderer || ct : null, C = p === null ? o.renderer(t, i, n) : p === "SPANS" ? ge(t, i, n) : p === "CSS_HIGHLIGHTS" ? he(t, i, n) : void 0;
810
+ if (!C)
811
+ throw `Unknown renderer implementation: ${o.renderer}`;
812
+ console.debug(p ? `Using ${p} renderer` : "Using custom renderer implementation"), o.style && C.setStyle(o.style);
813
+ const h = ue(t, i, d, o);
814
+ h.setUser(f);
815
+ const T = Ot(i, c, o.adapter), u = () => f, L = (a) => {
816
+ h.setAnnotatingEnabled(
895
817
  a === void 0 ? !0 : a
896
818
  );
897
- }, R = (a) => {
898
- y.setAnnotatingMode(a);
899
- }, b = (a) => {
900
- u.setFilter(a), y.setFilter(a);
901
- }, p = (a) => {
902
- f = a, y.setUser(a);
903
- }, S = (a) => {
904
- a && (u.setPainter(bt(a, n.presence)), a.on("selectionChange", () => u.redraw()));
819
+ }, x = (a) => {
820
+ h.setAnnotatingMode(a);
821
+ }, v = (a) => {
822
+ C.setFilter(a), h.setFilter(a);
823
+ }, m = (a) => {
824
+ f = a, h.setUser(a);
905
825
  }, E = (a) => {
906
826
  a ? s.setSelected(a) : s.clear();
907
827
  };
908
828
  return {
909
- ...w,
829
+ ...T,
910
830
  destroy: () => {
911
- u.destroy(), y.destroy(), c.destroy();
831
+ C.destroy(), h.destroy(), c.destroy();
912
832
  },
913
- element: e,
914
- getUser: g,
915
- setAnnotatingEnabled: x,
916
- setAnnotatingMode: R,
917
- setFilter: b,
918
- setStyle: u.setStyle.bind(u),
919
- redraw: u.redraw.bind(u),
920
- setUser: p,
833
+ element: t,
834
+ getUser: u,
835
+ renderer: C,
836
+ setAnnotatingEnabled: L,
837
+ setAnnotatingMode: x,
838
+ setFilter: v,
839
+ setStyle: C.setStyle.bind(C),
840
+ setUser: m,
921
841
  setSelected: E,
922
- setPresenceProvider: S,
923
- setVisible: u.setVisible.bind(u),
924
- on: l.on,
925
- off: l.off,
926
- scrollIntoView: Ze(e, i),
927
- state: r
842
+ setVisible: C.setVisible.bind(C),
843
+ on: d.on,
844
+ off: d.off,
845
+ scrollIntoView: Qt(t, r),
846
+ state: i
928
847
  };
929
848
  };
930
849
  export {
931
- Z as DEFAULT_SELECTED_STYLE,
932
- _ as DEFAULT_STYLE,
933
- ue as NOT_ANNOTATABLE_CLASS,
934
- W as NOT_ANNOTATABLE_SELECTOR,
935
- Ft as Origin,
936
- Vt as UserSelectAction,
937
- Ut as W3CTextFormat,
938
- Pe as cancelSingleClickEvents,
850
+ ot as DEFAULT_SELECTED_STYLE,
851
+ P as DEFAULT_STYLE,
852
+ ut as NOT_ANNOTATABLE_CLASS,
853
+ $ as NOT_ANNOTATABLE_SELECTOR,
854
+ He as Origin,
855
+ Pe as UserSelectAction,
856
+ ke as W3CTextFormat,
857
+ Xt as cancelSingleClickEvents,
939
858
  j as cloneKeyboardEvent,
940
- J as clonePointerEvent,
941
- se as createBaseRenderer,
942
- Yt as createBody,
943
- st as createCanvasRenderer,
944
- at as createHighlightsRenderer,
945
- bt as createPresencePainter,
946
- it as createRenderer,
947
- At as createSelectionHandler,
948
- ft as createSpansRenderer,
949
- Kt as createTextAnnotator,
950
- Ct as createTextAnnotatorState,
951
- ee as debounce,
952
- wt as fillDefaults,
953
- ct as getBackgroundColor,
954
- Ke as getHighlightClientRects,
955
- Fe as getQuoteContext,
956
- oe as getRangeAnnotatableContents,
957
- Je as getViewportBounds,
958
- fe as isMac,
959
- Ht as isNodeWhitespaceOrEmpty,
859
+ Z as clonePointerEvent,
860
+ mt as computeStyle,
861
+ ne as computeZIndex,
862
+ Ue as createBody,
863
+ gt as createRenderer,
864
+ ue as createSelectionHandler,
865
+ Ie as createTextAnnotator,
866
+ le as createTextAnnotatorState,
867
+ J as debounce,
868
+ ye as fillDefaults,
869
+ Vt as getBackgroundColor,
870
+ oe as getHighlightClientRects,
871
+ jt as getQuoteContext,
872
+ nt as getRangeAnnotatableContents,
873
+ zt as getViewportBounds,
874
+ dt as isMac,
875
+ Oe as isNodeWhitespaceOrEmpty,
960
876
  G as isNotAnnotatable,
961
- He as isRangeAnnotatable,
962
- Ve as isRangeWhitespaceOrEmpty,
963
- I as isRevived,
964
- ze as mergeClientRects,
965
- qe as mergeRanges,
966
- lt as paint,
967
- pt as parseW3CTextAnnotation,
968
- Ue as programmaticallyFocusable,
969
- je as rangeToSelector,
970
- te as reviveAnnotation,
971
- me as reviveSelector,
877
+ Pt as isRangeAnnotatable,
878
+ Ut as isRangeWhitespaceOrEmpty,
879
+ D as isRevived,
880
+ ie as mergeClientRects,
881
+ Kt as mergeRanges,
882
+ te as parseW3CTextAnnotation,
883
+ Ft as programmaticallyFocusable,
884
+ Gt as rangeToSelector,
885
+ tt as reviveAnnotation,
886
+ pt as reviveSelector,
972
887
  Q as reviveTarget,
973
- Ze as scrollIntoView,
974
- ht as serializeW3CTextAnnotation,
975
- $e as splitAnnotatableRanges,
976
- Pt as toDomRectList,
977
- Ge as toParentBounds,
978
- Dt as toViewportBounds,
979
- et as trackViewport,
980
- Qe as trimRangeToContainer,
981
- ge as whitespaceOrEmptyRegex
888
+ Qt as scrollIntoView,
889
+ ee as serializeW3CTextAnnotation,
890
+ Yt as splitAnnotatableRanges,
891
+ Me as toDomRectList,
892
+ ce as toParentBounds,
893
+ Be as toViewportBounds,
894
+ qt as trackViewport,
895
+ Wt as trimRangeToContainer,
896
+ ft as whitespaceOrEmptyRegex
982
897
  };
983
898
  //# sourceMappingURL=text-annotator.es.js.map