@recogito/text-annotator 3.0.0-rc.26 → 3.0.0-rc.27

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.
@@ -8,15 +8,15 @@ const H = {
8
8
  var a, s;
9
9
  const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? et : H) : n : (s = t.state) != null && s.selected ? et : H;
10
10
  return o && o.paint(t, e) || r;
11
- }, It = "not-annotatable", k = `.${It}`, jt = (t) => {
11
+ }, It = "not-annotatable", _ = `.${It}`, jt = (t) => {
12
12
  var n;
13
13
  const e = t.commonAncestorContainer;
14
- return e instanceof HTMLElement ? !e.closest(k) : !((n = e.parentElement) != null && n.closest(k));
14
+ return e instanceof HTMLElement ? !e.closest(_) : !((n = e.parentElement) != null && n.closest(_));
15
15
  }, Gt = function* (t) {
16
16
  const e = document.createNodeIterator(
17
17
  t.commonAncestorContainer,
18
18
  NodeFilter.SHOW_ELEMENT,
19
- (o) => o instanceof HTMLElement && o.classList.contains(It) && !o.parentElement.closest(k) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
19
+ (o) => o instanceof HTMLElement && o.classList.contains(It) && !o.parentElement.closest(_) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
20
20
  );
21
21
  let n;
22
22
  for (; n = e.nextNode(); )
@@ -37,11 +37,11 @@ const H = {
37
37
  return e.length > 0 ? e : [t];
38
38
  }, ut = (t) => {
39
39
  const e = t.cloneContents();
40
- return e.querySelectorAll(k).forEach((n) => n.remove()), e;
40
+ return e.querySelectorAll(_).forEach((n) => n.remove()), e;
41
41
  }, Qt = (t) => {
42
42
  t.addEventListener("click", (e) => {
43
43
  // Allow clicks within not-annotatable elements
44
- !e.target.closest(k) && !e.target.closest("a") && e.preventDefault();
44
+ !e.target.closest(_) && !e.target.closest("a") && e.preventDefault();
45
45
  });
46
46
  }, ft = (t, e = 10) => {
47
47
  let n;
@@ -50,7 +50,7 @@ const H = {
50
50
  };
51
51
  }, Ln = (t) => {
52
52
  const e = t.cloneContents();
53
- return e.querySelectorAll(k).forEach((n) => n.remove()), e;
53
+ return e.querySelectorAll(_).forEach((n) => n.remove()), e;
54
54
  }, mt = (t, e) => {
55
55
  const n = document.createNodeIterator(e);
56
56
  let o = 0, i = n.nextNode();
@@ -91,12 +91,12 @@ const H = {
91
91
  l.selectNodeContents(n), l.setStart(n, o);
92
92
  const m = b(l), p = document.createRange();
93
93
  p.selectNode(i), p.setEnd(i, r);
94
- const w = b(p), h = Zt(t).reverse().map((d) => {
94
+ const x = b(p), h = Zt(t).reverse().map((d) => {
95
95
  var y;
96
96
  const c = document.createElement("SPAN");
97
97
  return (y = d.parentNode) == null || y.insertBefore(c, d), c.appendChild(d), c;
98
98
  });
99
- return { unwrap: f, nodes: [m, ...h, w] };
99
+ return { unwrap: f, nodes: [m, ...h, x] };
100
100
  }
101
101
  }, Zt = (t) => {
102
102
  const {
@@ -187,7 +187,7 @@ const H = {
187
187
  NodeFilter.SHOW_TEXT,
188
188
  (m) => {
189
189
  var p;
190
- return (p = m.parentElement) != null && p.closest(k) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
190
+ return (p = m.parentElement) != null && p.closest(_) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
191
191
  }
192
192
  );
193
193
  let a = 0;
@@ -248,20 +248,20 @@ const H = {
248
248
  const { store: i, selection: r, hover: a } = e;
249
249
  let s, u, f;
250
250
  const b = ae(n), l = (g) => {
251
- const { x: A, y: x } = t.getBoundingClientRect(), S = i.getAt(g.clientX - A, g.clientY - x);
251
+ const { x: A, y: w } = t.getBoundingClientRect(), S = i.getAt(g.clientX - A, g.clientY - w);
252
252
  S && (!u || u(S)) ? a.current !== S.id && (t.classList.add("hovered"), a.set(S.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
253
253
  };
254
254
  t.addEventListener("pointermove", l);
255
255
  const m = (g = !1) => {
256
256
  f && f.clear();
257
- const A = se(t), { minX: x, minY: S, maxX: N, maxY: B } = A, _ = u ? i.getIntersecting(x, S, N, B).filter(({ annotation: X }) => u(X)) : i.getIntersecting(x, S, N, B), $t = r.selected.map(({ id: X }) => X), Pt = _.map(({ annotation: X, rects: zt }) => {
258
- const Ft = $t.includes(X.id), Wt = X.id === a.current;
259
- return { annotation: X, rects: zt, state: { selected: Ft, hover: Wt, custom: {} } };
257
+ const A = se(t), { minX: w, minY: S, maxX: R, maxY: B } = A, X = u ? i.getIntersecting(w, S, R, B).filter(({ annotation: D }) => u(D)) : i.getIntersecting(w, S, R, B), $t = r.selected.map(({ id: D }) => D), Pt = X.map(({ annotation: D, rects: zt }) => {
258
+ const Ft = $t.includes(D.id), Wt = D.id === a.current;
259
+ return { annotation: D, rects: zt, state: { selected: Ft, hover: Wt, custom: {} } };
260
260
  });
261
- o.redraw(Pt, A, s, f, g), setTimeout(() => b(_.map(({ annotation: X }) => X)), 1);
261
+ o.redraw(Pt, A, s, f, g), setTimeout(() => b(X.map(({ annotation: D }) => D)), 1);
262
262
  }, p = (g) => {
263
263
  f = g, m();
264
- }, w = (g) => {
264
+ }, x = (g) => {
265
265
  s = g, m();
266
266
  }, v = (g) => {
267
267
  u = g, m(!1);
@@ -276,14 +276,14 @@ const H = {
276
276
  const T = new ResizeObserver(y);
277
277
  T.observe(t);
278
278
  const C = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((g) => {
279
- g.every((x) => x.target === t || t.contains(x.target)) || m(!0);
279
+ g.every((w) => w.target === t || t.contains(w.target)) || m(!0);
280
280
  });
281
281
  return E.observe(document.body, C), {
282
282
  destroy: () => {
283
283
  t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(h), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", y), T.disconnect(), E.disconnect();
284
284
  },
285
285
  redraw: m,
286
- setStyle: w,
286
+ setStyle: x,
287
287
  setFilter: v,
288
288
  setPainter: p,
289
289
  setVisible: o.setVisible
@@ -300,29 +300,29 @@ const H = {
300
300
  const o = (s, u, f, b) => requestAnimationFrame(() => {
301
301
  const { width: l, height: m } = e;
302
302
  n.clearRect(-0.5, -0.5, l + 1, m + 1), b && b.clear();
303
- const { top: p, left: w } = u;
303
+ const { top: p, left: x } = u;
304
304
  s.forEach((v) => {
305
305
  var T;
306
- const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (T = v.state) != null && T.selected ? et : H, d = b && b.paint(v, u) || h, c = v.rects.map(({ x: C, y: E, width: R, height: g }) => ({
307
- x: C + w,
306
+ const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (T = v.state) != null && T.selected ? et : H, d = b && b.paint(v, u) || h, c = v.rects.map(({ x: C, y: E, width: N, height: g }) => ({
307
+ x: C + x,
308
308
  y: E + p,
309
- width: R,
309
+ width: N,
310
310
  height: g
311
311
  }));
312
312
  n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1;
313
313
  const y = 5;
314
314
  if (c.forEach(
315
- ({ x: C, y: E, width: R, height: g }) => n.fillRect(
315
+ ({ x: C, y: E, width: N, height: g }) => n.fillRect(
316
316
  C,
317
317
  E - y / 2,
318
- R,
318
+ N,
319
319
  g + y
320
320
  )
321
321
  ), d.underlineColor) {
322
322
  n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
323
323
  const C = y / 2 + (d.underlineOffset ?? 0);
324
- c.forEach(({ x: E, y: R, width: g, height: A }) => {
325
- n.beginPath(), n.moveTo(E, R + A + C), n.lineTo(E + g, R + A + C), n.stroke();
324
+ c.forEach(({ x: E, y: N, width: g, height: A }) => {
325
+ n.beginPath(), n.moveTo(E, N + A + C), n.lineTo(E + g, N + A + C), n.stroke();
326
326
  });
327
327
  }
328
328
  });
@@ -339,7 +339,7 @@ const H = {
339
339
  redraw: o
340
340
  };
341
341
  }, ue = (t, e, n) => pt(t, e, n, de(t));
342
- var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
342
+ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, k = function(t) {
343
343
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
344
344
  }, O = function(t, e, n) {
345
345
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
@@ -386,16 +386,16 @@ var he = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, D = function(t) {
386
386
  return xt(i);
387
387
  }, "hsl"]], object: [[function(t) {
388
388
  var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
389
- return D(e) && D(n) && D(o) ? vt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
389
+ return k(e) && k(n) && k(o) ? vt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
390
390
  }, "rgb"], [function(t) {
391
391
  var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
392
- if (!D(e) || !D(n) || !D(o))
392
+ if (!k(e) || !k(n) || !k(o))
393
393
  return null;
394
394
  var a = yt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
395
395
  return xt(a);
396
396
  }, "hsl"], [function(t) {
397
397
  var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
398
- if (!D(e) || !D(n) || !D(o))
398
+ if (!k(e) || !k(n) || !k(o))
399
399
  return null;
400
400
  var a = function(s) {
401
401
  return { h: Ut(s.h), s: U(s.s, 0, 100), v: U(s.v, 0, 100), a: U(s.a) };
@@ -495,13 +495,13 @@ const ye = (t) => [
495
495
  const f = new Set(r.map((l) => l.annotation.id));
496
496
  Array.from(e).filter((l) => !f.has(l));
497
497
  const b = r.map((l) => {
498
- var w;
499
- const m = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (w = l.state) != null && w.selected ? et : H, p = u && u.paint(l, a) || m;
498
+ var x;
499
+ const m = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (x = l.state) != null && x.selected ? et : H, p = u && u.paint(l, a) || m;
500
500
  return `::highlight(_${l.annotation.id}) { ${ye(p)} }`;
501
501
  });
502
502
  t.innerHTML = b.join(`
503
503
  `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
504
- const m = l.target.selector.map((w) => w.range), p = new Highlight(...m);
504
+ const m = l.target.selector.map((x) => x.range), p = new Highlight(...m);
505
505
  CSS.highlights.set(`_${l.id}`, p);
506
506
  }), e = f;
507
507
  }
@@ -549,15 +549,15 @@ const Ae = (t, e) => {
549
549
  if (ht(n, a) && b)
550
550
  return;
551
551
  e.innerHTML = "";
552
- const m = a.reduce((p, { rects: w }) => [...p, ...w], []);
552
+ const m = a.reduce((p, { rects: x }) => [...p, ...x], []);
553
553
  a.forEach((p) => {
554
- const w = p.rects.map((v) => {
554
+ const x = p.rects.map((v) => {
555
555
  const h = document.createElement("span");
556
556
  h.className = "r6o-annotation", h.dataset.annotation = p.annotation.id, h.style.left = `${v.x}px`, h.style.top = `${v.y}px`, h.style.width = `${v.width}px`, h.style.height = `${v.height}px`;
557
557
  const d = Ae(v, m), c = qt(p, s, u, f, d), y = V((c == null ? void 0 : c.fill) || H.fill).alpha((c == null ? void 0 : c.fillOpacity) === void 0 ? H.fillOpacity : c.fillOpacity).toHex();
558
558
  return h.style.backgroundColor = y, c.underlineStyle && (h.style.borderStyle = c.underlineStyle), c.underlineColor && (h.style.borderColor = c.underlineColor), c.underlineThickness && (h.style.borderBottomWidth = `${c.underlineThickness}px`), c.underlineOffset && (h.style.paddingBottom = `${c.underlineOffset}px`), e.appendChild(h), h;
559
559
  });
560
- return { id: p.annotation.id, spans: w };
560
+ return { id: p.annotation.id, spans: x };
561
561
  }), n = a;
562
562
  },
563
563
  setVisible: (a) => {
@@ -575,20 +575,20 @@ function Te() {
575
575
  const I = [];
576
576
  for (let t = 0; t < 256; ++t)
577
577
  I.push((t + 256).toString(16).slice(1));
578
- function Re(t, e = 0) {
578
+ function Ne(t, e = 0) {
579
579
  return I[t[e + 0]] + I[t[e + 1]] + I[t[e + 2]] + I[t[e + 3]] + "-" + I[t[e + 4]] + I[t[e + 5]] + "-" + I[t[e + 6]] + I[t[e + 7]] + "-" + I[t[e + 8]] + I[t[e + 9]] + "-" + I[t[e + 10]] + I[t[e + 11]] + I[t[e + 12]] + I[t[e + 13]] + I[t[e + 14]] + I[t[e + 15]];
580
580
  }
581
- const Ne = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Rt = {
582
- randomUUID: Ne
581
+ const Re = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Nt = {
582
+ randomUUID: Re
583
583
  };
584
584
  function Xt(t, e, n) {
585
- if (Rt.randomUUID && !e && !t)
586
- return Rt.randomUUID();
585
+ if (Nt.randomUUID && !e && !t)
586
+ return Nt.randomUUID();
587
587
  t = t || {};
588
588
  const o = t.random || (t.rng || Te)();
589
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Re(o);
589
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ne(o);
590
590
  }
591
- var Nt = Object.prototype.hasOwnProperty;
591
+ var Rt = Object.prototype.hasOwnProperty;
592
592
  function F(t, e) {
593
593
  var n, o;
594
594
  if (t === e)
@@ -607,7 +607,7 @@ function F(t, e) {
607
607
  if (!n || typeof t == "object") {
608
608
  o = 0;
609
609
  for (n in t)
610
- if (Nt.call(t, n) && ++o && !Nt.call(e, n) || !(n in e) || !F(t[n], e[n]))
610
+ if (Rt.call(t, n) && ++o && !Rt.call(e, n) || !(n in e) || !F(t[n], e[n]))
611
611
  return !1;
612
612
  return Object.keys(e).length === o;
613
613
  }
@@ -679,13 +679,13 @@ const lt = { selected: [] }, Ie = (t, e = "EDIT") => {
679
679
  }, u = (l, m) => {
680
680
  const p = t.getAnnotation(l);
681
681
  if (p) {
682
- const w = Me(p, e);
683
- o(w === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: m } : w === "SELECT" ? { selected: [{ id: l }], pointerEvent: m } : { selected: [], pointerEvent: m });
682
+ const x = Me(p, e);
683
+ o(x === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: m } : x === "SELECT" ? { selected: [{ id: l }], pointerEvent: m } : { selected: [], pointerEvent: m });
684
684
  } else
685
685
  console.warn("Invalid selection: " + l);
686
686
  }, f = (l, m = !0) => {
687
- const p = Array.isArray(l) ? l : [l], w = p.map((v) => t.getAnnotation(v)).filter(Boolean);
688
- o({ selected: w.map(({ id: v }) => ({ id: v, editable: m })) }), w.length !== p.length && console.warn("Invalid selection", l);
687
+ const p = Array.isArray(l) ? l : [l], x = p.map((v) => t.getAnnotation(v)).filter(Boolean);
688
+ o({ selected: x.map(({ id: v }) => ({ id: v, editable: m })) }), x.length !== p.length && console.warn("Invalid selection", l);
689
689
  }, b = (l) => {
690
690
  if (i.selected.length === 0)
691
691
  return !1;
@@ -790,8 +790,8 @@ const Pe = (t, e) => {
790
790
  ...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
791
791
  const { oldValue: m, newValue: p } = l;
792
792
  if (a.has(p.id)) {
793
- const w = e.updated.find((v) => v.oldValue.id === p.id).newValue;
794
- return Dt(m, w);
793
+ const x = e.updated.find((v) => v.oldValue.id === p.id).newValue;
794
+ return Dt(m, x);
795
795
  } else
796
796
  return l;
797
797
  }),
@@ -800,10 +800,10 @@ const Pe = (t, e) => {
800
800
  return { created: u, deleted: f, updated: b };
801
801
  }, Fe = (t) => t.id !== void 0, We = () => {
802
802
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (g, A = {}) => n.push({ onChange: g, options: A }), i = (g) => {
803
- const A = n.findIndex((x) => x.onChange == g);
803
+ const A = n.findIndex((w) => w.onChange == g);
804
804
  A > -1 && n.splice(A, 1);
805
805
  }, r = (g, A) => {
806
- const x = {
806
+ const w = {
807
807
  origin: g,
808
808
  changes: {
809
809
  created: A.created || [],
@@ -813,37 +813,37 @@ const Pe = (t, e) => {
813
813
  state: [...t.values()]
814
814
  };
815
815
  n.forEach((S) => {
816
- Pe(S, x) && S.onChange(x);
816
+ Pe(S, w) && S.onChange(w);
817
817
  });
818
818
  }, a = (g, A = L.LOCAL) => {
819
819
  if (t.get(g.id))
820
820
  throw Error(`Cannot add annotation ${g.id} - exists already`);
821
- t.set(g.id, g), g.bodies.forEach((x) => e.set(x.id, g.id)), r(A, { created: [g] });
821
+ t.set(g.id, g), g.bodies.forEach((w) => e.set(w.id, g.id)), r(A, { created: [g] });
822
822
  }, s = (g, A) => {
823
- const x = typeof g == "string" ? A : g, S = typeof g == "string" ? g : g.id, N = t.get(S);
824
- if (N) {
825
- const B = Dt(N, x);
826
- return S === x.id ? t.set(S, x) : (t.delete(S), t.set(x.id, x)), N.bodies.forEach((_) => e.delete(_.id)), x.bodies.forEach((_) => e.set(_.id, x.id)), B;
823
+ const w = typeof g == "string" ? A : g, S = typeof g == "string" ? g : g.id, R = t.get(S);
824
+ if (R) {
825
+ const B = Dt(R, w);
826
+ return S === w.id ? t.set(S, w) : (t.delete(S), t.set(w.id, w)), R.bodies.forEach((X) => e.delete(X.id)), w.bodies.forEach((X) => e.set(X.id, w.id)), B;
827
827
  } else
828
828
  console.warn(`Cannot update annotation ${S} - does not exist`);
829
- }, u = (g, A = L.LOCAL, x = L.LOCAL) => {
830
- const S = Fe(A) ? x : A, N = s(g, A);
831
- N && r(S, { updated: [N] });
829
+ }, u = (g, A = L.LOCAL, w = L.LOCAL) => {
830
+ const S = Fe(A) ? w : A, R = s(g, A);
831
+ R && r(S, { updated: [R] });
832
832
  }, f = (g, A = L.LOCAL) => {
833
- const x = g.reduce((S, N) => {
834
- const B = s(N);
833
+ const w = g.reduce((S, R) => {
834
+ const B = s(R);
835
835
  return B ? [...S, B] : S;
836
836
  }, []);
837
- x.length > 0 && r(A, { updated: x });
837
+ w.length > 0 && r(A, { updated: w });
838
838
  }, b = (g, A = L.LOCAL) => {
839
- const x = t.get(g.annotation);
840
- if (x) {
839
+ const w = t.get(g.annotation);
840
+ if (w) {
841
841
  const S = {
842
- ...x,
843
- bodies: [...x.bodies, g]
842
+ ...w,
843
+ bodies: [...w.bodies, g]
844
844
  };
845
- t.set(x.id, S), e.set(g.id, S.id), r(A, { updated: [{
846
- oldValue: x,
845
+ t.set(w.id, S), e.set(g.id, S.id), r(A, { updated: [{
846
+ oldValue: w,
847
847
  newValue: S,
848
848
  bodiesCreated: [g]
849
849
  }] });
@@ -852,50 +852,50 @@ const Pe = (t, e) => {
852
852
  }, l = () => [...t.values()], m = (g = L.LOCAL) => {
853
853
  const A = [...t.values()];
854
854
  t.clear(), e.clear(), r(g, { deleted: A });
855
- }, p = (g, A = !0, x = L.LOCAL) => {
855
+ }, p = (g, A = !0, w = L.LOCAL) => {
856
856
  if (A) {
857
857
  const S = [...t.values()];
858
- t.clear(), e.clear(), g.forEach((N) => {
859
- t.set(N.id, N), N.bodies.forEach((B) => e.set(B.id, N.id));
860
- }), r(x, { created: g, deleted: S });
858
+ t.clear(), e.clear(), g.forEach((R) => {
859
+ t.set(R.id, R), R.bodies.forEach((B) => e.set(B.id, R.id));
860
+ }), r(w, { created: g, deleted: S });
861
861
  } else {
862
- const S = g.reduce((N, B) => {
863
- const _ = t.get(B.id);
864
- return _ ? [...N, _] : N;
862
+ const S = g.reduce((R, B) => {
863
+ const X = t.get(B.id);
864
+ return X ? [...R, X] : R;
865
865
  }, []);
866
866
  if (S.length > 0)
867
- throw Error(`Bulk insert would overwrite the following annotations: ${S.map((N) => N.id).join(", ")}`);
868
- g.forEach((N) => {
869
- t.set(N.id, N), N.bodies.forEach((B) => e.set(B.id, N.id));
870
- }), r(x, { created: g });
867
+ throw Error(`Bulk insert would overwrite the following annotations: ${S.map((R) => R.id).join(", ")}`);
868
+ g.forEach((R) => {
869
+ t.set(R.id, R), R.bodies.forEach((B) => e.set(B.id, R.id));
870
+ }), r(w, { created: g });
871
871
  }
872
- }, w = (g) => {
873
- const A = typeof g == "string" ? g : g.id, x = t.get(A);
874
- if (x)
875
- return t.delete(A), x.bodies.forEach((S) => e.delete(S.id)), x;
872
+ }, x = (g) => {
873
+ const A = typeof g == "string" ? g : g.id, w = t.get(A);
874
+ if (w)
875
+ return t.delete(A), w.bodies.forEach((S) => e.delete(S.id)), w;
876
876
  console.warn(`Attempt to delete missing annotation: ${A}`);
877
877
  }, v = (g, A = L.LOCAL) => {
878
- const x = w(g);
879
- x && r(A, { deleted: [x] });
878
+ const w = x(g);
879
+ w && r(A, { deleted: [w] });
880
880
  }, h = (g, A = L.LOCAL) => {
881
- const x = g.reduce((S, N) => {
882
- const B = w(N);
881
+ const w = g.reduce((S, R) => {
882
+ const B = x(R);
883
883
  return B ? [...S, B] : S;
884
884
  }, []);
885
- x.length > 0 && r(A, { deleted: x });
885
+ w.length > 0 && r(A, { deleted: w });
886
886
  }, d = (g, A = L.LOCAL) => {
887
- const x = t.get(g.annotation);
888
- if (x) {
889
- const S = x.bodies.find((N) => N.id === g.id);
887
+ const w = t.get(g.annotation);
888
+ if (w) {
889
+ const S = w.bodies.find((R) => R.id === g.id);
890
890
  if (S) {
891
891
  e.delete(S.id);
892
- const N = {
893
- ...x,
894
- bodies: x.bodies.filter((B) => B.id !== g.id)
892
+ const R = {
893
+ ...w,
894
+ bodies: w.bodies.filter((B) => B.id !== g.id)
895
895
  };
896
- t.set(x.id, N), r(A, { updated: [{
897
- oldValue: x,
898
- newValue: N,
896
+ t.set(w.id, R), r(A, { updated: [{
897
+ oldValue: w,
898
+ newValue: R,
899
899
  bodiesDeleted: [S]
900
900
  }] });
901
901
  } else
@@ -908,47 +908,47 @@ const Pe = (t, e) => {
908
908
  }, y = (g) => {
909
909
  const A = e.get(g);
910
910
  if (A) {
911
- const x = c(A).bodies.find((S) => S.id === g);
912
- if (x)
913
- return x;
911
+ const w = c(A).bodies.find((S) => S.id === g);
912
+ if (w)
913
+ return w;
914
914
  console.error(`Store integrity error: body ${g} in index, but not in annotation`);
915
915
  } else
916
916
  console.warn(`Attempt to retrieve missing body: ${g}`);
917
917
  }, T = (g, A) => {
918
918
  if (g.annotation !== A.annotation)
919
919
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
920
- const x = t.get(g.annotation);
921
- if (x) {
922
- const S = x.bodies.find((B) => B.id === g.id), N = {
923
- ...x,
924
- bodies: x.bodies.map((B) => B.id === S.id ? A : B)
920
+ const w = t.get(g.annotation);
921
+ if (w) {
922
+ const S = w.bodies.find((B) => B.id === g.id), R = {
923
+ ...w,
924
+ bodies: w.bodies.map((B) => B.id === S.id ? A : B)
925
925
  };
926
- return t.set(x.id, N), S.id !== A.id && (e.delete(S.id), e.set(A.id, N.id)), {
927
- oldValue: x,
928
- newValue: N,
926
+ return t.set(w.id, R), S.id !== A.id && (e.delete(S.id), e.set(A.id, R.id)), {
927
+ oldValue: w,
928
+ newValue: R,
929
929
  bodiesUpdated: [{ oldBody: S, newBody: A }]
930
930
  };
931
931
  } else
932
932
  console.warn(`Attempt to add body to missing annotation ${g.annotation}`);
933
- }, C = (g, A, x = L.LOCAL) => {
933
+ }, C = (g, A, w = L.LOCAL) => {
934
934
  const S = T(g, A);
935
- S && r(x, { updated: [S] });
935
+ S && r(w, { updated: [S] });
936
936
  }, E = (g, A = L.LOCAL) => {
937
- const x = g.map((S) => T({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
938
- r(A, { updated: x });
939
- }, R = (g) => {
937
+ const w = g.map((S) => T({ id: S.id, annotation: S.annotation }, S)).filter(Boolean);
938
+ r(A, { updated: w });
939
+ }, N = (g) => {
940
940
  const A = t.get(g.annotation);
941
941
  if (A) {
942
- const x = {
942
+ const w = {
943
943
  ...A,
944
944
  target: {
945
945
  ...A.target,
946
946
  ...g
947
947
  }
948
948
  };
949
- return t.set(A.id, x), {
949
+ return t.set(A.id, w), {
950
950
  oldValue: A,
951
- newValue: x,
951
+ newValue: w,
952
952
  targetUpdated: {
953
953
  oldTarget: A.target,
954
954
  newTarget: g
@@ -966,8 +966,8 @@ const Pe = (t, e) => {
966
966
  bulkUpdateAnnotation: f,
967
967
  bulkUpdateBodies: E,
968
968
  bulkUpdateTargets: (g, A = L.LOCAL) => {
969
- const x = g.map((S) => R(S)).filter(Boolean);
970
- x.length > 0 && r(A, { updated: x });
969
+ const w = g.map((S) => N(S)).filter(Boolean);
970
+ w.length > 0 && r(A, { updated: w });
971
971
  },
972
972
  clear: m,
973
973
  deleteAnnotation: v,
@@ -979,8 +979,8 @@ const Pe = (t, e) => {
979
979
  updateAnnotation: u,
980
980
  updateBody: C,
981
981
  updateTarget: (g, A = L.LOCAL) => {
982
- const x = R(g);
983
- x && r(A, { updated: [x] });
982
+ const w = N(g);
983
+ w && r(A, { updated: [w] });
984
984
  }
985
985
  };
986
986
  };
@@ -1003,36 +1003,36 @@ const je = 250, Ge = (t) => {
1003
1003
  let o = -1, i = !1, r = 0;
1004
1004
  const a = (p) => {
1005
1005
  if (!i) {
1006
- const { changes: w } = p, v = performance.now();
1006
+ const { changes: x } = p, v = performance.now();
1007
1007
  if (v - r > je)
1008
- n.splice(o + 1), n.push(w), o = n.length - 1;
1008
+ n.splice(o + 1), n.push(x), o = n.length - 1;
1009
1009
  else {
1010
1010
  const h = n.length - 1;
1011
- n[h] = ze(n[h], w);
1011
+ n[h] = ze(n[h], x);
1012
1012
  }
1013
1013
  r = v;
1014
1014
  }
1015
1015
  i = !1;
1016
1016
  };
1017
1017
  t.observe(a, { origin: L.LOCAL });
1018
- const s = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: w }) => w)), b = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: w }) => w)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), m = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1018
+ const s = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: x }) => x)), b = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: x }) => x)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), m = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1019
1019
  return {
1020
1020
  canRedo: () => n.length - 1 > o,
1021
1021
  canUndo: () => o > -1,
1022
1022
  destroy: () => t.unobserve(a),
1023
- on: (p, w) => e.on(p, w),
1023
+ on: (p, x) => e.on(p, x),
1024
1024
  redo: () => {
1025
1025
  if (n.length - 1 > o) {
1026
1026
  i = !0;
1027
- const { created: p, updated: w, deleted: v } = n[o + 1];
1028
- u(p), b(w), m(v), e.emit("redo", n[o + 1]), o += 1;
1027
+ const { created: p, updated: x, deleted: v } = n[o + 1];
1028
+ u(p), b(x), m(v), e.emit("redo", n[o + 1]), o += 1;
1029
1029
  }
1030
1030
  },
1031
1031
  undo: () => {
1032
1032
  if (o > -1) {
1033
1033
  i = !0;
1034
- const { created: p, updated: w, deleted: v } = n[o];
1035
- s(p), f(w), l(v), e.emit("undo", n[o]), o -= 1;
1034
+ const { created: p, updated: x, deleted: v } = n[o];
1035
+ s(p), f(x), l(v), e.emit("undo", n[o]), o -= 1;
1036
1036
  }
1037
1037
  }
1038
1038
  };
@@ -1102,11 +1102,11 @@ const je = 250, Ge = (t) => {
1102
1102
  d.length > 0 && (f = f.map((c) => d.find((T) => T.id === c.id) || c));
1103
1103
  }
1104
1104
  }, { origin: L.REMOTE });
1105
- const w = (v) => (h) => {
1105
+ const x = (v) => (h) => {
1106
1106
  const { updated: d } = h;
1107
1107
  v ? (d || []).forEach((c) => p("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => p("updateAnnotation", c.newValue, c.oldValue));
1108
1108
  };
1109
- return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: l, off: m, emit: p };
1109
+ return e.on("undo", x(!0)), e.on("redo", x(!1)), { on: l, off: m, emit: p };
1110
1110
  }, Je = (t) => (e) => e.reduce((n, o) => {
1111
1111
  const { parsed: i, error: r } = t.parse(o);
1112
1112
  return r ? {
@@ -1148,7 +1148,7 @@ const je = 250, Ge = (t) => {
1148
1148
  y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(c, d, L.REMOTE);
1149
1149
  } else
1150
1150
  o.bulkAddAnnotation(h, d, L.REMOTE);
1151
- }, w = (h) => {
1151
+ }, x = (h) => {
1152
1152
  h ? i.setSelected(h) : i.clear();
1153
1153
  }, v = (h) => {
1154
1154
  if (n) {
@@ -1172,7 +1172,7 @@ const je = 250, Ge = (t) => {
1172
1172
  redo: e.redo,
1173
1173
  removeAnnotation: m,
1174
1174
  setAnnotations: p,
1175
- setSelected: w,
1175
+ setSelected: x,
1176
1176
  undo: e.undo,
1177
1177
  updateAnnotation: v
1178
1178
  };
@@ -1284,14 +1284,14 @@ const In = (t, e) => ({
1284
1284
  updated: f,
1285
1285
  ...b
1286
1286
  } = i, l = a.map((m) => {
1287
- const { quote: p, start: w, end: v, range: h } = m, { prefix: d, suffix: c } = te(h, n), y = [{
1287
+ const { quote: p, start: x, end: v, range: h } = m, { prefix: d, suffix: c } = te(h, n), y = [{
1288
1288
  type: "TextQuoteSelector",
1289
1289
  exact: p,
1290
1290
  prefix: d,
1291
1291
  suffix: c
1292
1292
  }, {
1293
1293
  type: "TextPositionSelector",
1294
- start: w,
1294
+ start: x,
1295
1295
  end: v
1296
1296
  }];
1297
1297
  return {
@@ -1322,14 +1322,14 @@ function Yt(t, e, n, o, i) {
1322
1322
  var r = o - n + 1, a = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), f = 0.5 * Math.sqrt(s * u * (r - u) / r) * (a - r / 2 < 0 ? -1 : 1), b = Math.max(n, Math.floor(e - a * u / r + f)), l = Math.min(o, Math.floor(e + (r - a) * u / r + f));
1323
1323
  Yt(t, e, b, l, i);
1324
1324
  }
1325
- var m = t[e], p = n, w = o;
1326
- for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); p < w; ) {
1327
- for (W(t, p, w), p++, w--; i(t[p], m) < 0; )
1325
+ var m = t[e], p = n, x = o;
1326
+ for (W(t, n, e), i(t[o], m) > 0 && W(t, n, o); p < x; ) {
1327
+ for (W(t, p, x), p++, x--; i(t[p], m) < 0; )
1328
1328
  p++;
1329
- for (; i(t[w], m) > 0; )
1330
- w--;
1329
+ for (; i(t[x], m) > 0; )
1330
+ x--;
1331
1331
  }
1332
- i(t[n], m) === 0 ? W(t, n, w) : (w++, W(t, w, o)), w <= e && (n = w + 1), e <= w && (o = w - 1);
1332
+ i(t[n], m) === 0 ? W(t, n, x) : (x++, W(t, x, o)), x <= e && (n = x + 1), e <= x && (o = x - 1);
1333
1333
  }
1334
1334
  }
1335
1335
  function W(t, e, n) {
@@ -1596,16 +1596,16 @@ function Bt(t, e, n, o, i) {
1596
1596
  const An = (t, e) => {
1597
1597
  const n = new mn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
1598
1598
  const y = d.selector.flatMap((C) => {
1599
- const R = C.range instanceof Range && !C.range.collapsed && C.range.startContainer.nodeType === Node.TEXT_NODE && C.range.endContainer.nodeType === Node.TEXT_NODE ? C.range : Mt(C, e).range;
1600
- return Array.from(R.getClientRects());
1601
- }), T = oe(y).map(({ left: C, top: E, right: R, bottom: g }) => new DOMRect(C - c.left, E - c.top, R - C, g - E));
1599
+ const N = C.range instanceof Range && !C.range.collapsed && C.range.startContainer.nodeType === Node.TEXT_NODE && C.range.endContainer.nodeType === Node.TEXT_NODE ? C.range : Mt(C, e).range;
1600
+ return Array.from(N.getClientRects());
1601
+ }), T = oe(y).map(({ left: C, top: E, right: N, bottom: g }) => new DOMRect(C - c.left, E - c.top, N - C, g - E));
1602
1602
  return T.map((C) => {
1603
- const { x: E, y: R, width: g, height: A } = C;
1603
+ const { x: E, y: N, width: g, height: A } = C;
1604
1604
  return {
1605
1605
  minX: E,
1606
- minY: R,
1606
+ minY: N,
1607
1607
  maxX: E + g,
1608
- maxY: R + A,
1608
+ maxY: N + A,
1609
1609
  annotation: {
1610
1610
  id: d.annotation,
1611
1611
  rects: T
@@ -1625,8 +1625,8 @@ const An = (t, e) => {
1625
1625
  }, b = (d, c = !0) => {
1626
1626
  c && a();
1627
1627
  const y = e.getBoundingClientRect(), T = d.map((E) => ({ target: E, rects: i(E, y) }));
1628
- T.forEach(({ target: E, rects: R }) => o.set(E.annotation, R));
1629
- const C = T.reduce((E, { rects: R }) => [...E, ...R], []);
1628
+ T.forEach(({ target: E, rects: N }) => o.set(E.annotation, N));
1629
+ const C = T.reduce((E, { rects: N }) => [...E, ...N], []);
1630
1630
  n.load(C);
1631
1631
  }, l = (d, c) => {
1632
1632
  const y = n.search({
@@ -1634,7 +1634,7 @@ const An = (t, e) => {
1634
1634
  minY: c,
1635
1635
  maxX: d,
1636
1636
  maxY: c
1637
- }), T = (C) => C.annotation.rects.reduce((E, R) => E + R.width * R.height, 0);
1637
+ }), T = (C) => C.annotation.rects.reduce((E, N) => E + N.width * N.height, 0);
1638
1638
  if (y.length > 0)
1639
1639
  return y.sort((C, E) => T(C) - T(E)), y[0].annotation.id;
1640
1640
  }, m = (d) => {
@@ -1642,8 +1642,8 @@ const An = (t, e) => {
1642
1642
  if (c.length === 0)
1643
1643
  return;
1644
1644
  let y = c[0].left, T = c[0].top, C = c[0].right, E = c[0].bottom;
1645
- for (let R = 1; R < c.length; R++) {
1646
- const g = c[R];
1645
+ for (let N = 1; N < c.length; N++) {
1646
+ const g = c[N];
1647
1647
  y = Math.min(y, g.left), T = Math.min(T, g.top), C = Math.max(C, g.right), E = Math.max(E, g.bottom);
1648
1648
  }
1649
1649
  return new DOMRect(y, T, C - y, E - T);
@@ -1658,11 +1658,11 @@ const An = (t, e) => {
1658
1658
  getAnnotationBounds: m,
1659
1659
  getAnnotationRects: p,
1660
1660
  getIntersecting: (d, c, y, T) => {
1661
- const C = n.search({ minX: d, minY: c, maxX: y, maxY: T }), E = new Set(C.reduce((R, g) => [...R, g.annotation.id], []));
1662
- return Array.from(E).map((R) => ({
1663
- annotation: t.getAnnotation(R),
1664
- rects: p(R)
1665
- })).filter((R) => !!R.annotation);
1661
+ const C = n.search({ minX: d, minY: c, maxX: y, maxY: T }), E = new Set(C.reduce((N, g) => [...N, g.annotation.id], []));
1662
+ return Array.from(E).map((N) => ({
1663
+ annotation: t.getAnnotation(N),
1664
+ rects: p(N)
1665
+ })).filter((N) => !!N.annotation);
1666
1666
  },
1667
1667
  insert: s,
1668
1668
  recalculate: () => b(t.all().map((d) => d.target), !0),
@@ -1696,13 +1696,13 @@ const An = (t, e) => {
1696
1696
  const y = o.getAnnotationRects(v);
1697
1697
  if (y.length !== 0) {
1698
1698
  if (h && d) {
1699
- const T = y.find(({ top: C, right: E, bottom: R, left: g }) => h >= g - c && h <= E + c && d >= C - c && d <= R + c);
1699
+ const T = y.find(({ top: C, right: E, bottom: N, left: g }) => h >= g - c && h <= E + c && d >= C - c && d <= N + c);
1700
1700
  if (T)
1701
1701
  return T;
1702
1702
  }
1703
1703
  return o.getAnnotationBounds(v);
1704
1704
  }
1705
- }, w = () => o.recalculate();
1705
+ }, x = () => o.recalculate();
1706
1706
  return n.observe(({ changes: v }) => {
1707
1707
  const h = (v.created || []).filter((y) => Y(y.target.selector)), d = (v.deleted || []).filter((y) => Y(y.target.selector)), c = (v.updated || []).filter((y) => Y(y.newValue.target.selector));
1708
1708
  h.length > 0 && o.set(h.map((y) => y.target), !1), (d == null ? void 0 : d.length) > 0 && d.forEach((y) => o.remove(y.target)), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: y }) => o.update(y.target));
@@ -1716,7 +1716,7 @@ const An = (t, e) => {
1716
1716
  getAnnotationBounds: p,
1717
1717
  getAt: m,
1718
1718
  getIntersecting: o.getIntersecting,
1719
- recalculatePositions: w,
1719
+ recalculatePositions: x,
1720
1720
  updateTarget: b
1721
1721
  },
1722
1722
  selection: i,
@@ -1733,7 +1733,7 @@ const An = (t, e) => {
1733
1733
  t.appendChild(o);
1734
1734
  const r = /* @__PURE__ */ new Map(), a = (l) => Array.from(r.entries()).filter(([m, p]) => p.presenceKey === l.presenceKey).map(([m, p]) => m);
1735
1735
  return e.on("selectionChange", (l, m) => {
1736
- a(l).forEach((w) => r.delete(w)), m && m.forEach((w) => r.set(w, l));
1736
+ a(l).forEach((x) => r.delete(x)), m && m.forEach((x) => r.set(x, l));
1737
1737
  }), {
1738
1738
  clear: () => {
1739
1739
  const { width: l, height: m } = o;
@@ -1744,13 +1744,13 @@ const An = (t, e) => {
1744
1744
  },
1745
1745
  paint: (l, m, p) => {
1746
1746
  n.font && (i.font = n.font);
1747
- const w = r.get(l.annotation.id);
1748
- if (w) {
1747
+ const x = r.get(l.annotation.id);
1748
+ if (x) {
1749
1749
  const { height: v } = l.rects[0], h = l.rects[0].x + m.left, d = l.rects[0].y + m.top;
1750
- i.fillStyle = w.appearance.color, i.fillRect(h - 2, d - 2.5, 2, v + 5);
1751
- const c = i.measureText(w.appearance.label), y = c.width + 6, T = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, C = c.fontBoundingBoxAscent ? 8 : 6.5;
1752
- return i.fillRect(h - 2, d - 2.5 - T, y, T), i.fillStyle = "#fff", i.fillText(w.appearance.label, h + 1, d - C), {
1753
- fill: w.appearance.color,
1750
+ i.fillStyle = x.appearance.color, i.fillRect(h - 2, d - 2.5, 2, v + 5);
1751
+ const c = i.measureText(x.appearance.label), y = c.width + 6, T = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, C = c.fontBoundingBoxAscent ? 8 : 6.5;
1752
+ return i.fillRect(h - 2, d - 2.5 - T, y, T), i.fillStyle = "#fff", i.fillText(x.appearance.label, h + 1, d - C), {
1753
+ fill: x.appearance.color,
1754
1754
  fillOpacity: p ? 0.45 : 0.18
1755
1755
  };
1756
1756
  }
@@ -1768,7 +1768,7 @@ const An = (t, e) => {
1768
1768
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Ht(t.parentElement);
1769
1769
  }, Tn = (t, e) => (n) => {
1770
1770
  const o = (r) => {
1771
- const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = f.top - a.top, p = f.left - a.left, w = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = m + w - (s - l) / 2, d = p + v - (u - b) / 2;
1771
+ const a = i.getBoundingClientRect(), s = i.clientHeight, u = i.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = f.top - a.top, p = f.left - a.left, x = i.parentElement ? i.scrollTop : 0, v = i.parentElement ? i.scrollLeft : 0, h = m + x - (s - l) / 2, d = p + v - (u - b) / 2;
1772
1772
  i.scroll({ top: h, left: d, behavior: "smooth" });
1773
1773
  }, i = Ht(t);
1774
1774
  if (i) {
@@ -1782,10 +1782,10 @@ const An = (t, e) => {
1782
1782
  }
1783
1783
  }
1784
1784
  return !1;
1785
- }, Rn = (t, e) => ({
1785
+ }, Nn = (t, e) => ({
1786
1786
  ...t,
1787
1787
  annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled
1788
- }), Nn = (t, e, n, o) => {
1788
+ }), Rn = (t, e, n, o) => {
1789
1789
  const { store: i, selection: r } = e;
1790
1790
  let a, s;
1791
1791
  const u = (h) => a = h;
@@ -1794,7 +1794,7 @@ const An = (t, e) => {
1794
1794
  var c;
1795
1795
  if (!f)
1796
1796
  return;
1797
- !((c = h.target.parentElement) != null && c.closest(k)) ? s = {
1797
+ !((c = h.target.parentElement) != null && c.closest(_)) ? s = {
1798
1798
  annotation: Xt(),
1799
1799
  selector: [],
1800
1800
  creator: a,
@@ -1803,16 +1803,21 @@ const An = (t, e) => {
1803
1803
  };
1804
1804
  n && t.addEventListener("selectstart", l);
1805
1805
  const m = ft((h) => {
1806
+ var N;
1806
1807
  const d = document.getSelection();
1808
+ if (!!((N = d.anchorNode.parentElement) != null && N.closest(_))) {
1809
+ s = void 0;
1810
+ return;
1811
+ }
1807
1812
  if (h.timeStamp - ((b == null ? void 0 : b.timeStamp) || h.timeStamp) < 1e3 && !s && l(b), d.isCollapsed || !f || !s)
1808
1813
  return;
1809
- const c = d.getRangeAt(0), y = re(c.cloneRange()), T = Kt(y);
1810
- (T.length !== s.selector.length || T.some((E, R) => {
1811
- var g;
1812
- return E.toString() !== ((g = s.selector[R]) == null ? void 0 : g.quote);
1814
+ const y = d.getRangeAt(0), T = re(y.cloneRange()), C = Kt(T);
1815
+ (C.length !== s.selector.length || C.some((g, A) => {
1816
+ var w;
1817
+ return g.toString() !== ((w = s.selector[A]) == null ? void 0 : w.quote);
1813
1818
  })) && (s = {
1814
1819
  ...s,
1815
- selector: T.map((E) => ie(E, t, o))
1820
+ selector: C.map((g) => ie(g, t, o))
1816
1821
  }, i.getAnnotation(s.annotation) ? i.updateTarget(s, L.LOCAL) : (i.addAnnotation({
1817
1822
  id: s.annotation,
1818
1823
  bodies: [],
@@ -1825,29 +1830,29 @@ const An = (t, e) => {
1825
1830
  b = { ...h, target: d, timeStamp: c, offsetX: y, offsetY: T, type: C }, f = h.button === 0;
1826
1831
  };
1827
1832
  t.addEventListener("pointerdown", p);
1828
- const w = (h) => {
1833
+ const x = (h) => {
1829
1834
  var T;
1830
- if (!!((T = h.target.parentElement) != null && T.closest(k)) || !f)
1835
+ if (!!((T = h.target.parentElement) != null && T.closest(_)) || !f)
1831
1836
  return;
1832
1837
  const c = () => {
1833
- const { x: C, y: E } = t.getBoundingClientRect(), R = i.getAt(h.clientX - C, h.clientY - E);
1834
- if (R) {
1838
+ const { x: C, y: E } = t.getBoundingClientRect(), N = i.getAt(h.clientX - C, h.clientY - E);
1839
+ if (N) {
1835
1840
  const { selected: g } = r;
1836
- (g.length !== 1 || g[0].id !== R.id) && r.clickSelect(R.id, h);
1841
+ (g.length !== 1 || g[0].id !== N.id) && r.clickSelect(N.id, h);
1837
1842
  } else
1838
1843
  r.isEmpty() || r.clear();
1839
1844
  }, y = h.timeStamp - b.timeStamp;
1840
1845
  document.getSelection().isCollapsed && y < 300 ? (s = void 0, c()) : s && r.clickSelect(s.annotation, h);
1841
1846
  };
1842
- return document.addEventListener("pointerup", w), {
1847
+ return document.addEventListener("pointerup", x), {
1843
1848
  destroy: () => {
1844
- t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", m), t.removeEventListener("pointerdown", p), document.removeEventListener("pointerup", w);
1849
+ t.removeEventListener("selectstart", l), document.removeEventListener("selectionchange", m), t.removeEventListener("pointerdown", p), document.removeEventListener("pointerup", x);
1845
1850
  },
1846
1851
  setUser: u
1847
1852
  };
1848
1853
  }, Ot = "SPANS", Mn = (t, e = {}) => {
1849
1854
  Qt(t);
1850
- const n = Rn(e, {
1855
+ const n = Nn(e, {
1851
1856
  annotationEnabled: !0
1852
1857
  }), o = En(t, n.pointerAction), { selection: i, viewport: r } = o, a = o.store, s = Ge(a), u = Qe(o, s, n.adapter);
1853
1858
  let f = sn();
@@ -1855,7 +1860,7 @@ const An = (t, e) => {
1855
1860
  if (!l)
1856
1861
  throw `Unknown renderer implementation: ${b}`;
1857
1862
  console.debug(`Using ${b} renderer`), n.style && l.setStyle(n.style);
1858
- const m = Nn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1863
+ const m = Rn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1859
1864
  return m.setUser(f), {
1860
1865
  ...Ze(o, s, n.adapter),
1861
1866
  destroy: () => {
@@ -1885,7 +1890,7 @@ export {
1885
1890
  et as DEFAULT_SELECTED_STYLE,
1886
1891
  H as DEFAULT_STYLE,
1887
1892
  It as NOT_ANNOTATABLE_CLASS,
1888
- k as NOT_ANNOTATABLE_SELECTOR,
1893
+ _ as NOT_ANNOTATABLE_SELECTOR,
1889
1894
  L as Origin,
1890
1895
  Oe as PointerSelectAction,
1891
1896
  In as W3CTextFormat,
@@ -1898,7 +1903,7 @@ export {
1898
1903
  Mn as createTextAnnotator,
1899
1904
  En as createTextAnnotatorState,
1900
1905
  ft as debounce,
1901
- Rn as fillDefaults,
1906
+ Nn as fillDefaults,
1902
1907
  Ln as getAnnotatableFragment,
1903
1908
  Bn as getClientRectsPonyfill,
1904
1909
  te as getQuoteContext,