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