@recogito/text-annotator 3.4.0 → 3.4.1

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