@recogito/text-annotator 3.0.0-rc.20 → 3.0.0-rc.21

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.
@@ -1,4 +1,4 @@
1
- const D = {
1
+ const H = {
2
2
  fill: "rgb(0, 128, 255)",
3
3
  fillOpacity: 0.18
4
4
  }, dt = {
@@ -6,22 +6,22 @@ const D = {
6
6
  fillOpacity: 0.45
7
7
  }, zt = (t, e, n, o, i) => {
8
8
  var s;
9
- const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (s = t.state) != null && s.selected ? dt : D;
9
+ const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) : n : (s = t.state) != null && s.selected ? dt : H;
10
10
  return o && o.paint(t, e) || r;
11
11
  }, ut = (t, e = 10) => {
12
12
  let n;
13
13
  return (...o) => {
14
14
  clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
15
15
  };
16
- }, Nt = "not-annotatable", H = `.${Nt}`, Ft = (t) => {
16
+ }, Nt = "not-annotatable", Y = `.${Nt}`, Ft = (t) => {
17
17
  var n;
18
18
  const e = t.commonAncestorContainer;
19
- return e instanceof HTMLElement ? !e.closest(H) : !((n = e.parentElement) != null && n.closest(H));
19
+ return e instanceof HTMLElement ? !e.closest(Y) : !((n = e.parentElement) != null && n.closest(Y));
20
20
  }, Wt = function* (t) {
21
21
  const e = document.createNodeIterator(
22
22
  t.commonAncestorContainer,
23
23
  NodeFilter.SHOW_ELEMENT,
24
- (o) => o instanceof HTMLElement && o.classList.contains(Nt) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
24
+ (o) => o instanceof HTMLElement && o.classList.contains(Nt) && !o.parentElement.closest(Y) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
25
25
  );
26
26
  let n;
27
27
  for (; n = e.nextNode(); )
@@ -40,12 +40,12 @@ const D = {
40
40
  o.setStartAfter(n), o.collapsed || e.push(o);
41
41
  }
42
42
  return e.length > 0 ? e : [t];
43
- }, ct = (t) => {
43
+ }, lt = (t) => {
44
44
  const e = t.cloneContents();
45
- return e.querySelectorAll(H).forEach((n) => n.remove()), e;
45
+ return e.querySelectorAll(Y).forEach((n) => n.remove()), e;
46
46
  }, wn = (t) => {
47
47
  const e = t.cloneContents();
48
- return e.querySelectorAll(H).forEach((n) => n.remove()), e;
48
+ return e.querySelectorAll(Y).forEach((n) => n.remove()), e;
49
49
  }, gt = (t, e) => {
50
50
  const n = document.createNodeIterator(e);
51
51
  let o = 0, i = n.nextNode();
@@ -67,29 +67,29 @@ const D = {
67
67
  startOffset: o,
68
68
  endContainer: i,
69
69
  endOffset: r
70
- } = t, s = Array.from(e.childNodes).map((c) => {
71
- const m = c.cloneNode(!0);
72
- return c.nodeName === "CANVAS" ? c : m;
70
+ } = t, s = Array.from(e.childNodes).map((l) => {
71
+ const m = l.cloneNode(!0);
72
+ return l.nodeName === "CANVAS" ? l : m;
73
73
  }), a = gt(n, e), u = gt(i, e), h = () => {
74
- const c = e;
75
- c.replaceChildren(...s);
76
- const m = pt(a, c), g = pt(u, c);
74
+ const l = e;
75
+ l.replaceChildren(...s);
76
+ const m = pt(a, l), g = pt(u, l);
77
77
  return t.setStart(m, o), t.setEnd(g, r), t;
78
- }, v = (c) => {
78
+ }, b = (l) => {
79
79
  const m = document.createElement("SPAN");
80
- return c.surroundContents(m), m;
80
+ return l.surroundContents(m), m;
81
81
  };
82
82
  if (n === i)
83
83
  throw "Not implemented";
84
84
  {
85
- const c = document.createRange();
86
- c.selectNodeContents(n), c.setStart(n, o);
87
- const m = v(c), g = document.createRange();
85
+ const l = document.createRange();
86
+ l.selectNodeContents(n), l.setStart(n, o);
87
+ const m = b(l), g = document.createRange();
88
88
  g.selectNode(i), g.setEnd(i, r);
89
- const y = v(g), w = Gt(t).reverse().map((l) => {
89
+ const y = b(g), w = Gt(t).reverse().map((c) => {
90
90
  var f;
91
91
  const d = document.createElement("SPAN");
92
- return (f = l.parentNode) == null || f.insertBefore(d, l), d.appendChild(l), d;
92
+ return (f = c.parentNode) == null || f.insertBefore(d, c), d.appendChild(c), d;
93
93
  });
94
94
  return { unwrap: h, nodes: [m, ...w, y] };
95
95
  }
@@ -115,9 +115,9 @@ const D = {
115
115
  }, Kt = (t, e, n = 10, o) => {
116
116
  const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
117
117
  r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
118
- const s = ct(r).textContent, a = document.createRange();
118
+ const s = lt(r).textContent, a = document.createRange();
119
119
  a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
120
- const u = ct(a).textContent;
120
+ const u = lt(a).textContent;
121
121
  return {
122
122
  prefix: s.substring(s.length - n),
123
123
  suffix: u.substring(0, n)
@@ -173,16 +173,16 @@ const D = {
173
173
  }, []), te = (t, e, n) => {
174
174
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
175
175
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
176
- const r = ct(o).textContent, s = t.toString(), a = r.length || 0, u = a + s.length;
176
+ const r = lt(o).textContent, s = t.toString(), a = r.length || 0, u = a + s.length;
177
177
  return n ? { quote: s, start: a, end: u, range: t, offsetReference: i } : { quote: s, start: a, end: u, range: t };
178
178
  }, Bt = (t, e) => {
179
- var v, c;
179
+ var b, l;
180
180
  const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
181
181
  e,
182
182
  NodeFilter.SHOW_TEXT,
183
183
  (m) => {
184
184
  var g;
185
- return (g = m.parentElement) != null && g.closest(H) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
185
+ return (g = m.parentElement) != null && g.closest(Y) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
186
186
  }
187
187
  );
188
188
  let s = 0;
@@ -192,7 +192,7 @@ const D = {
192
192
  let h = !i;
193
193
  for (; u !== null; ) {
194
194
  if (h || (h = i == null ? void 0 : i.contains(u)), h) {
195
- const m = ((v = u.textContent) == null ? void 0 : v.length) || 0;
195
+ const m = ((b = u.textContent) == null ? void 0 : b.length) || 0;
196
196
  if (s + m > n) {
197
197
  a.setStart(u, n - s);
198
198
  break;
@@ -202,7 +202,7 @@ const D = {
202
202
  u = r.nextNode();
203
203
  }
204
204
  for (; u !== null; ) {
205
- const m = ((c = u.textContent) == null ? void 0 : c.length) || 0;
205
+ const m = ((l = u.textContent) == null ? void 0 : l.length) || 0;
206
206
  if (s + m >= o) {
207
207
  a.setEnd(u, o - s);
208
208
  break;
@@ -242,40 +242,40 @@ const D = {
242
242
  }, ht = (t, e, n, o) => {
243
243
  const { store: i, selection: r, hover: s } = e;
244
244
  let a, u, h;
245
- const v = oe(n), c = (p) => {
245
+ const b = oe(n), l = (p) => {
246
246
  const { x: S, y: E } = t.getBoundingClientRect(), C = i.getAt(p.clientX - S, p.clientY - E);
247
247
  C && (!u || u(C)) ? s.current !== C.id && (t.classList.add("hovered"), s.set(C.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
248
248
  };
249
- t.addEventListener("pointermove", c);
250
- const m = (p = !0) => {
249
+ t.addEventListener("pointermove", l);
250
+ const m = (p = !1) => {
251
251
  h && h.clear();
252
252
  const S = ne(t), { minX: E, minY: C, maxX: L, maxY: B } = S, _ = u ? i.getIntersecting(E, C, L, B).filter(({ annotation: U }) => u(U)) : i.getIntersecting(E, C, L, B), Yt = r.selected.map(({ id: U }) => U), Dt = _.map(({ annotation: U, rects: Ht }) => {
253
253
  const $t = Yt.includes(U.id), Pt = U.id === s.current;
254
254
  return { annotation: U, rects: Ht, state: { selected: $t, hover: Pt, custom: {} } };
255
255
  });
256
- o.redraw(Dt, S, a, h, p), setTimeout(() => v(_.map(({ annotation: U }) => U)), 1);
256
+ o.redraw(Dt, S, a, h, p), setTimeout(() => b(_.map(({ annotation: U }) => U)), 1);
257
257
  }, g = (p) => {
258
258
  h = p, m();
259
259
  }, y = (p) => {
260
260
  a = p, m();
261
261
  }, x = (p) => {
262
- u = p, m();
262
+ u = p, m(!1);
263
263
  }, w = () => m();
264
264
  i.observe(w);
265
- const l = r.subscribe(() => m()), d = () => m(!0);
265
+ const c = r.subscribe(() => m()), d = () => m(!0);
266
266
  document.addEventListener("scroll", d, { capture: !0, passive: !0 });
267
267
  const f = ut(() => {
268
268
  i.recalculatePositions(), h && h.reset(), m();
269
269
  });
270
270
  window.addEventListener("resize", f);
271
- const b = new ResizeObserver(f);
272
- b.observe(t);
271
+ const v = new ResizeObserver(f);
272
+ v.observe(t);
273
273
  const A = { attributes: !0, childList: !0, subtree: !0 }, R = new MutationObserver((p) => {
274
274
  p.every((E) => E.target === t || t.contains(E.target)) || m(!0);
275
275
  });
276
276
  return R.observe(document.body, A), {
277
277
  destroy: () => {
278
- t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(w), l(), document.removeEventListener("scroll", d), window.removeEventListener("resize", f), b.disconnect(), R.disconnect();
278
+ t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(w), c(), document.removeEventListener("scroll", d), window.removeEventListener("resize", f), v.disconnect(), R.disconnect();
279
279
  },
280
280
  redraw: m,
281
281
  setStyle: y,
@@ -295,20 +295,20 @@ const D = {
295
295
  t.classList.add("r6o-annotatable");
296
296
  const e = ie(), n = e.getContext("2d");
297
297
  t.insertBefore(e, t.firstChild);
298
- const o = (a, u, h, v) => requestAnimationFrame(() => {
299
- const { width: c, height: m } = e;
300
- n.clearRect(-0.5, -0.5, c + 1, m + 1), v && v.clear();
298
+ const o = (a, u, h, b) => requestAnimationFrame(() => {
299
+ const { width: l, height: m } = e;
300
+ n.clearRect(-0.5, -0.5, l + 1, m + 1), b && b.clear();
301
301
  const { top: g, left: y } = u;
302
302
  a.forEach((x) => {
303
303
  var f;
304
- const w = h ? typeof h == "function" ? h(x.annotation, x.state) : h : (f = x.state) != null && f.selected ? dt : D, l = v && v.paint(x, u) || w, d = x.rects.map(({ x: b, y: A, width: R, height: T }) => ({
305
- x: b + y,
304
+ const w = h ? typeof h == "function" ? h(x.annotation, x.state) : h : (f = x.state) != null && f.selected ? dt : H, c = b && b.paint(x, u) || w, d = x.rects.map(({ x: v, y: A, width: R, height: T }) => ({
305
+ x: v + y,
306
306
  y: A + g,
307
307
  width: R,
308
308
  height: T
309
309
  }));
310
- n.fillStyle = l.fill, n.globalAlpha = l.fillOpacity || 1, d.forEach(({ x: b, y: A, width: R, height: T }) => n.fillRect(b, A - 2.5, R, T + 5)), l.underlineColor && (n.globalAlpha = 1, n.strokeStyle = l.underlineColor, d.forEach(({ x: b, y: A, width: R, height: T }) => {
311
- n.beginPath(), n.moveTo(b, A + T + 4), n.lineTo(b + R, A + T + 4), n.stroke();
310
+ n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, d.forEach(({ x: v, y: A, width: R, height: T }) => n.fillRect(v, A - 2.5, R, T + 5)), c.underlineColor && (n.globalAlpha = 1, n.strokeStyle = c.underlineColor, d.forEach(({ x: v, y: A, width: R, height: T }) => {
311
+ n.beginPath(), n.moveTo(v, A + T + 4), n.lineTo(v + R, A + T + 4), n.stroke();
312
312
  }));
313
313
  });
314
314
  }), i = ut(() => {
@@ -324,7 +324,7 @@ const D = {
324
324
  redraw: o
325
325
  };
326
326
  }, ae = (t, e, n) => ht(t, e, n, se(t));
327
- var ce = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
327
+ var le = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
328
328
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
329
329
  }, O = function(t, e, n) {
330
330
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
@@ -336,7 +336,7 @@ var ce = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
336
336
  return { r: I(t.r, 0, 255), g: I(t.g, 0, 255), b: I(t.b, 0, 255), a: I(t.a) };
337
337
  }, et = function(t) {
338
338
  return { r: O(t.r), g: O(t.g), b: O(t.b), a: O(t.a, 3) };
339
- }, le = /^#([0-9a-f]{3,8})$/i, G = function(t) {
339
+ }, ce = /^#([0-9a-f]{3,8})$/i, G = function(t) {
340
340
  var e = t.toString(16);
341
341
  return e.length < 2 ? "0" + e : e;
342
342
  }, Mt = function(t) {
@@ -358,7 +358,7 @@ var ce = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
358
358
  return { h: (e = Mt(t)).h, s: (i = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: e.a };
359
359
  var e, n, o, i;
360
360
  }, de = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ue = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, he = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, fe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, yt = { string: [[function(t) {
361
- var e = le.exec(t);
361
+ var e = ce.exec(t);
362
362
  return e ? (t = e[1]).length <= 4 ? { r: parseInt(t[0] + t[0], 16), g: parseInt(t[1] + t[1], 16), b: parseInt(t[2] + t[2], 16), a: t.length === 4 ? O(parseInt(t[3] + t[3], 16) / 255, 2) : 1 } : t.length === 6 || t.length === 8 ? { r: parseInt(t.substr(0, 2), 16), g: parseInt(t.substr(2, 2), 16), b: parseInt(t.substr(4, 2), 16), a: t.length === 8 ? O(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
363
363
  }, "hex"], [function(t) {
364
364
  var e = he.exec(t) || fe.exec(t);
@@ -367,7 +367,7 @@ var ce = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
367
367
  var e = de.exec(t) || ue.exec(t);
368
368
  if (!e)
369
369
  return null;
370
- var n, o, i = bt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (ce[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
370
+ var n, o, i = bt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (le[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
371
371
  return wt(i);
372
372
  }, "hsl"]], object: [[function(t) {
373
373
  var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
@@ -459,7 +459,7 @@ var ce = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
459
459
  return t instanceof Et ? t : new Et(t);
460
460
  };
461
461
  const pe = (t) => [
462
- `background-color:${V((t == null ? void 0 : t.fill) || D.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? D.fillOpacity : t.fillOpacity).toHex()}`,
462
+ `background-color:${V((t == null ? void 0 : t.fill) || H.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? H.fillOpacity : t.fillOpacity).toHex()}`,
463
463
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
464
464
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
465
465
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
@@ -477,23 +477,23 @@ const pe = (t) => [
477
477
  },
478
478
  redraw: (r, s, a, u) => {
479
479
  u && u.clear();
480
- const h = new Set(r.map((c) => c.annotation.id));
481
- Array.from(e).filter((c) => !h.has(c));
482
- const v = r.map((c) => {
480
+ const h = new Set(r.map((l) => l.annotation.id));
481
+ Array.from(e).filter((l) => !h.has(l));
482
+ const b = r.map((l) => {
483
483
  var y;
484
- const m = a ? typeof a == "function" ? a(c.annotation, c.state) : a : (y = c.state) != null && y.selected ? dt : D, g = u && u.paint(c, s) || m;
485
- return `::highlight(_${c.annotation.id}) { ${pe(g)} }`;
484
+ const m = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (y = l.state) != null && y.selected ? dt : H, g = u && u.paint(l, s) || m;
485
+ return `::highlight(_${l.annotation.id}) { ${pe(g)} }`;
486
486
  });
487
- t.innerHTML = v.join(`
488
- `), CSS.highlights.clear(), r.forEach(({ annotation: c }) => {
489
- const m = c.target.selector.map((y) => y.range), g = new Highlight(...m);
490
- CSS.highlights.set(`_${c.id}`, g);
487
+ t.innerHTML = b.join(`
488
+ `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
489
+ const m = l.target.selector.map((y) => y.range), g = new Highlight(...m);
490
+ CSS.highlights.set(`_${l.id}`, g);
491
491
  }), e = h;
492
492
  }
493
493
  };
494
494
  }, be = (t, e, n) => ht(t, e, n, me());
495
495
  var St = Object.prototype.hasOwnProperty;
496
- function lt(t, e) {
496
+ function ct(t, e) {
497
497
  var n, o;
498
498
  if (t === e)
499
499
  return !0;
@@ -504,14 +504,14 @@ function lt(t, e) {
504
504
  return t.toString() === e.toString();
505
505
  if (n === Array) {
506
506
  if ((o = t.length) === e.length)
507
- for (; o-- && lt(t[o], e[o]); )
507
+ for (; o-- && ct(t[o], e[o]); )
508
508
  ;
509
509
  return o === -1;
510
510
  }
511
511
  if (!n || typeof t == "object") {
512
512
  o = 0;
513
513
  for (n in t)
514
- if (St.call(t, n) && ++o && !St.call(e, n) || !(n in e) || !lt(t[n], e[n]))
514
+ if (St.call(t, n) && ++o && !St.call(e, n) || !(n in e) || !ct(t[n], e[n]))
515
515
  return !1;
516
516
  return Object.keys(e).length === o;
517
517
  }
@@ -530,8 +530,8 @@ const ve = (t, e) => {
530
530
  destroy: () => {
531
531
  e.remove();
532
532
  },
533
- redraw: (s, a, u, h, v) => {
534
- if (lt(n, s) && v)
533
+ redraw: (s, a, u, h, b) => {
534
+ if (console.log("redraw, lazy =", b), ct(n, s) && b)
535
535
  return;
536
536
  e.innerHTML = "";
537
537
  const m = s.reduce((g, { rects: y }) => [...g, ...y], []);
@@ -539,7 +539,7 @@ const ve = (t, e) => {
539
539
  const y = g.rects.map((x) => {
540
540
  const w = document.createElement("span");
541
541
  w.className = "r6o-annotation", w.dataset.annotation = g.annotation.id, w.style.left = `${x.x}px`, w.style.top = `${x.y}px`, w.style.width = `${x.width}px`, w.style.height = `${x.height}px`;
542
- const l = ve(x, m), d = zt(g, a, u, h, l), f = V((d == null ? void 0 : d.fill) || D.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? D.fillOpacity : d.fillOpacity).toHex();
542
+ const c = ve(x, m), d = zt(g, a, u, h, c), f = V((d == null ? void 0 : d.fill) || H.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? H.fillOpacity : d.fillOpacity).toHex();
543
543
  return w.style.backgroundColor = f, d.underlineStyle && (w.style.borderStyle = d.underlineStyle), d.underlineColor && (w.style.borderColor = d.underlineColor), d.underlineThickness && (w.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (w.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(w), w;
544
544
  });
545
545
  return { id: g.annotation.id, spans: y };
@@ -580,7 +580,7 @@ function Vt(t, e, n) {
580
580
  return Ee(o);
581
581
  }
582
582
  var Tt = Object.prototype.hasOwnProperty;
583
- function Y(t, e) {
583
+ function D(t, e) {
584
584
  var n, o;
585
585
  if (t === e)
586
586
  return !0;
@@ -591,14 +591,14 @@ function Y(t, e) {
591
591
  return t.toString() === e.toString();
592
592
  if (n === Array) {
593
593
  if ((o = t.length) === e.length)
594
- for (; o-- && Y(t[o], e[o]); )
594
+ for (; o-- && D(t[o], e[o]); )
595
595
  ;
596
596
  return o === -1;
597
597
  }
598
598
  if (!n || typeof t == "object") {
599
599
  o = 0;
600
600
  for (n in t)
601
- if (Tt.call(t, n) && ++o && !Tt.call(e, n) || !(n in e) || !Y(t[n], e[n]))
601
+ if (Tt.call(t, n) && ++o && !Tt.call(e, n) || !(n in e) || !D(t[n], e[n]))
602
602
  return !1;
603
603
  return Object.keys(e).length === o;
604
604
  }
@@ -656,32 +656,32 @@ const Te = (t) => {
656
656
  }, rt = { selected: [] }, Re = (t, e = "EDIT") => {
657
657
  const { subscribe: n, set: o } = ft(rt);
658
658
  let i = rt;
659
- n((c) => i = c);
659
+ n((l) => i = l);
660
660
  const r = () => o(rt), s = () => {
661
- var c;
662
- return ((c = i.selected) == null ? void 0 : c.length) === 0;
663
- }, a = (c) => {
661
+ var l;
662
+ return ((l = i.selected) == null ? void 0 : l.length) === 0;
663
+ }, a = (l) => {
664
664
  if (i.selected.length === 0)
665
665
  return !1;
666
- const m = typeof c == "string" ? c : c.id;
666
+ const m = typeof l == "string" ? l : l.id;
667
667
  return i.selected.some((g) => g.id === m);
668
- }, u = (c, m) => {
669
- const g = t.getAnnotation(c);
668
+ }, u = (l, m) => {
669
+ const g = t.getAnnotation(l);
670
670
  if (g) {
671
671
  const y = Le(g, e);
672
- o(y === "EDIT" ? { selected: [{ id: c, editable: !0 }], pointerEvent: m } : y === "SELECT" ? { selected: [{ id: c }], pointerEvent: m } : { selected: [], pointerEvent: m });
672
+ o(y === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: m } : y === "SELECT" ? { selected: [{ id: l }], pointerEvent: m } : { selected: [], pointerEvent: m });
673
673
  } else
674
- console.warn("Invalid selection: " + c);
675
- }, h = (c, m = !0) => {
676
- const g = Array.isArray(c) ? c : [c], y = g.map((x) => t.getAnnotation(x)).filter(Boolean);
677
- o({ selected: y.map(({ id: x }) => ({ id: x, editable: m })) }), y.length !== g.length && console.warn("Invalid selection", c);
678
- }, v = (c) => {
674
+ console.warn("Invalid selection: " + l);
675
+ }, h = (l, m = !0) => {
676
+ const g = Array.isArray(l) ? l : [l], y = g.map((x) => t.getAnnotation(x)).filter(Boolean);
677
+ o({ selected: y.map(({ id: x }) => ({ id: x, editable: m })) }), y.length !== g.length && console.warn("Invalid selection", l);
678
+ }, b = (l) => {
679
679
  if (i.selected.length === 0)
680
680
  return !1;
681
681
  const { selected: m } = i;
682
- m.filter(({ id: g }) => c.includes(g)).length > 0 && o({ selected: m.filter(({ id: g }) => !c.includes(g)) });
682
+ m.filter(({ id: g }) => l.includes(g)).length > 0 && o({ selected: m.filter(({ id: g }) => !l.includes(g)) });
683
683
  };
684
- return t.observe(({ changes: c }) => v((c.deleted || []).map((m) => m.id))), {
684
+ return t.observe(({ changes: l }) => b((l.deleted || []).map((m) => m.id))), {
685
685
  clear: r,
686
686
  clickSelect: u,
687
687
  get selected() {
@@ -707,8 +707,8 @@ const Be = (t, e) => {
707
707
  return t.bodies.filter((o) => !n.has(o.id));
708
708
  }, Me = (t, e) => e.bodies.map((n) => {
709
709
  const o = t.bodies.find((i) => i.id === n.id);
710
- return { newBody: n, oldBody: o && !Y(o, n) ? o : void 0 };
711
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Ie = (t, e) => !Y(t.target, e.target), _t = (t, e) => {
710
+ return { newBody: n, oldBody: o && !D(o, n) ? o : void 0 };
711
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Ie = (t, e) => !D(t.target, e.target), _t = (t, e) => {
712
712
  const n = Be(t, e), o = Oe(t, e), i = Me(t, e);
713
713
  return {
714
714
  oldValue: t,
@@ -728,7 +728,7 @@ const Ve = (t, e) => {
728
728
  if (t.options.ignore) {
729
729
  const { ignore: s } = t.options, a = (u) => u && u.length > 0;
730
730
  if (!(a(i.created) || a(i.deleted))) {
731
- const u = (n = i.updated) == null ? void 0 : n.some((v) => a(v.bodiesCreated) || a(v.bodiesDeleted) || a(v.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((v) => v.targetUpdated);
731
+ const u = (n = i.updated) == null ? void 0 : n.some((b) => a(b.bodiesCreated) || a(b.bodiesDeleted) || a(b.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((b) => b.targetUpdated);
732
732
  if (s === "BODY_ONLY" && u && !h || s === "TARGET_ONLY" && h && !u)
733
733
  return !1;
734
734
  }
@@ -743,24 +743,24 @@ const Ve = (t, e) => {
743
743
  } else
744
744
  return !0;
745
745
  }, _e = (t, e) => {
746
- const n = new Set((t.created || []).map((c) => c.id)), o = new Set((t.updated || []).map(({ newValue: c }) => c.id)), i = new Set((e.created || []).map((c) => c.id)), r = new Set((e.deleted || []).map((c) => c.id)), s = new Set((e.updated || []).map(({ oldValue: c }) => c.id)), a = new Set((e.updated || []).filter(({ oldValue: c }) => n.has(c.id) || o.has(c.id)).map(({ oldValue: c }) => c.id)), u = [
747
- ...(t.created || []).filter((c) => !r.has(c.id)).map((c) => s.has(c.id) ? e.updated.find(({ oldValue: m }) => m.id === c.id).newValue : c),
746
+ const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), s = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), u = [
747
+ ...(t.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? e.updated.find(({ oldValue: m }) => m.id === l.id).newValue : l),
748
748
  ...e.created || []
749
749
  ], h = [
750
- ...(t.deleted || []).filter((c) => !i.has(c.id)),
751
- ...(e.deleted || []).filter((c) => !n.has(c.id))
752
- ], v = [
753
- ...(t.updated || []).filter(({ newValue: c }) => !r.has(c.id)).map((c) => {
754
- const { oldValue: m, newValue: g } = c;
750
+ ...(t.deleted || []).filter((l) => !i.has(l.id)),
751
+ ...(e.deleted || []).filter((l) => !n.has(l.id))
752
+ ], b = [
753
+ ...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
754
+ const { oldValue: m, newValue: g } = l;
755
755
  if (s.has(g.id)) {
756
756
  const y = e.updated.find((x) => x.oldValue.id === g.id).newValue;
757
757
  return _t(m, y);
758
758
  } else
759
- return c;
759
+ return l;
760
760
  }),
761
- ...(e.updated || []).filter(({ oldValue: c }) => !a.has(c.id))
761
+ ...(e.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
762
762
  ];
763
- return { created: u, deleted: h, updated: v };
763
+ return { created: u, deleted: h, updated: b };
764
764
  }, Ue = (t) => t.id !== void 0, Xe = () => {
765
765
  const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (p, S = {}) => n.push({ onChange: p, options: S }), i = (p) => {
766
766
  const S = n.findIndex((E) => E.onChange == p);
@@ -798,7 +798,7 @@ const Ve = (t, e) => {
798
798
  return B ? [...C, B] : C;
799
799
  }, []);
800
800
  E.length > 0 && r(S, { updated: E });
801
- }, v = (p, S = N.LOCAL) => {
801
+ }, b = (p, S = N.LOCAL) => {
802
802
  const E = t.get(p.annotation);
803
803
  if (E) {
804
804
  const C = {
@@ -812,7 +812,7 @@ const Ve = (t, e) => {
812
812
  }] });
813
813
  } else
814
814
  console.warn(`Attempt to add body to missing annotation: ${p.annotation}`);
815
- }, c = () => [...t.values()], m = (p = N.LOCAL) => {
815
+ }, l = () => [...t.values()], m = (p = N.LOCAL) => {
816
816
  const S = [...t.values()];
817
817
  t.clear(), e.clear(), r(p, { deleted: S });
818
818
  }, g = (p, S = !0, E = N.LOCAL) => {
@@ -846,7 +846,7 @@ const Ve = (t, e) => {
846
846
  return B ? [...C, B] : C;
847
847
  }, []);
848
848
  E.length > 0 && r(S, { deleted: E });
849
- }, l = (p, S = N.LOCAL) => {
849
+ }, c = (p, S = N.LOCAL) => {
850
850
  const E = t.get(p.annotation);
851
851
  if (E) {
852
852
  const C = E.bodies.find((L) => L.id === p.id);
@@ -877,7 +877,7 @@ const Ve = (t, e) => {
877
877
  console.error(`Store integrity error: body ${p} in index, but not in annotation`);
878
878
  } else
879
879
  console.warn(`Attempt to retrieve missing body: ${p}`);
880
- }, b = (p, S) => {
880
+ }, v = (p, S) => {
881
881
  if (p.annotation !== S.annotation)
882
882
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
883
883
  const E = t.get(p.annotation);
@@ -894,10 +894,10 @@ const Ve = (t, e) => {
894
894
  } else
895
895
  console.warn(`Attempt to add body to missing annotation ${p.annotation}`);
896
896
  }, A = (p, S, E = N.LOCAL) => {
897
- const C = b(p, S);
897
+ const C = v(p, S);
898
898
  C && r(E, { updated: [C] });
899
899
  }, R = (p, S = N.LOCAL) => {
900
- const E = p.map((C) => b({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
900
+ const E = p.map((C) => v({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
901
901
  r(S, { updated: E });
902
902
  }, T = (p) => {
903
903
  const S = t.get(p.annotation);
@@ -922,8 +922,8 @@ const Ve = (t, e) => {
922
922
  };
923
923
  return {
924
924
  addAnnotation: s,
925
- addBody: v,
926
- all: c,
925
+ addBody: b,
926
+ all: l,
927
927
  bulkAddAnnotation: g,
928
928
  bulkDeleteAnnotation: w,
929
929
  bulkUpdateAnnotation: h,
@@ -934,7 +934,7 @@ const Ve = (t, e) => {
934
934
  },
935
935
  clear: m,
936
936
  deleteAnnotation: x,
937
- deleteBody: l,
937
+ deleteBody: c,
938
938
  getAnnotation: d,
939
939
  getBody: f,
940
940
  observe: o,
@@ -978,7 +978,7 @@ const Ye = 250, De = (t) => {
978
978
  i = !1;
979
979
  };
980
980
  t.observe(s, { origin: N.LOCAL });
981
- const a = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), v = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), c = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), m = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
981
+ const a = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), b = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), m = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
982
982
  return {
983
983
  canRedo: () => n.length - 1 > o,
984
984
  canUndo: () => o > -1,
@@ -988,14 +988,14 @@ const Ye = 250, De = (t) => {
988
988
  if (n.length - 1 > o) {
989
989
  i = !0;
990
990
  const { created: g, updated: y, deleted: x } = n[o + 1];
991
- u(g), v(y), m(x), e.emit("redo", n[o + 1]), o += 1;
991
+ u(g), b(y), m(x), e.emit("redo", n[o + 1]), o += 1;
992
992
  }
993
993
  },
994
994
  undo: () => {
995
995
  if (o > -1) {
996
996
  i = !0;
997
997
  const { created: g, updated: y, deleted: x } = n[o];
998
- a(g), h(y), c(x), e.emit("undo", n[o]), o -= 1;
998
+ a(g), h(y), l(x), e.emit("undo", n[o]), o -= 1;
999
999
  }
1000
1000
  }
1001
1001
  };
@@ -1007,74 +1007,74 @@ const Ye = 250, De = (t) => {
1007
1007
  };
1008
1008
  }, $e = (t, e, n, o) => {
1009
1009
  const { store: i, selection: r, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();
1010
- let h = [], v, c;
1011
- const m = (l, d) => {
1012
- u.has(l) ? u.get(l).push(d) : u.set(l, [d]);
1013
- }, g = (l, d) => {
1014
- const f = u.get(l);
1010
+ let h = [], b, l;
1011
+ const m = (c, d) => {
1012
+ u.has(c) ? u.get(c).push(d) : u.set(c, [d]);
1013
+ }, g = (c, d) => {
1014
+ const f = u.get(c);
1015
1015
  f && f.indexOf(d) > 0 && f.splice(f.indexOf(d), 1);
1016
- }, y = (l, d, f) => {
1017
- u.has(l) && setTimeout(() => {
1018
- u.get(l).forEach((b) => {
1016
+ }, y = (c, d, f) => {
1017
+ u.has(c) && setTimeout(() => {
1018
+ u.get(c).forEach((v) => {
1019
1019
  if (n) {
1020
1020
  const A = Array.isArray(d) ? d.map((T) => n.serialize(T)) : n.serialize(d), R = f ? f instanceof PointerEvent ? f : n.serialize(f) : void 0;
1021
- b(A, R);
1021
+ v(A, R);
1022
1022
  } else
1023
- b(d, f);
1023
+ v(d, f);
1024
1024
  });
1025
1025
  }, 1);
1026
1026
  }, x = () => {
1027
- const { selected: l } = r, d = (l || []).map(({ id: f }) => i.getAnnotation(f));
1027
+ const { selected: c } = r, d = (c || []).map(({ id: f }) => i.getAnnotation(f));
1028
1028
  d.forEach((f) => {
1029
- const b = h.find((A) => A.id === f.id);
1030
- (!b || !Y(b, f)) && y("updateAnnotation", f, b);
1029
+ const v = h.find((A) => A.id === f.id);
1030
+ (!v || !D(v, f)) && y("updateAnnotation", f, v);
1031
1031
  }), h = h.map((f) => d.find(({ id: A }) => A === f.id) || f);
1032
1032
  };
1033
- r.subscribe(({ selected: l }) => {
1034
- if (!(h.length === 0 && l.length === 0)) {
1035
- if (h.length === 0 && l.length > 0)
1036
- h = l.map(({ id: d }) => i.getAnnotation(d));
1037
- else if (h.length > 0 && l.length === 0)
1033
+ r.subscribe(({ selected: c }) => {
1034
+ if (!(h.length === 0 && c.length === 0)) {
1035
+ if (h.length === 0 && c.length > 0)
1036
+ h = c.map(({ id: d }) => i.getAnnotation(d));
1037
+ else if (h.length > 0 && c.length === 0)
1038
1038
  h.forEach((d) => {
1039
1039
  const f = i.getAnnotation(d.id);
1040
- f && !Y(f, d) && y("updateAnnotation", f, d);
1040
+ f && !D(f, d) && y("updateAnnotation", f, d);
1041
1041
  }), h = [];
1042
1042
  else {
1043
- const d = new Set(h.map((b) => b.id)), f = new Set(l.map(({ id: b }) => b));
1044
- h.filter((b) => !f.has(b.id)).forEach((b) => {
1045
- const A = i.getAnnotation(b.id);
1046
- A && !Y(A, b) && y("updateAnnotation", A, b);
1043
+ const d = new Set(h.map((v) => v.id)), f = new Set(c.map(({ id: v }) => v));
1044
+ h.filter((v) => !f.has(v.id)).forEach((v) => {
1045
+ const A = i.getAnnotation(v.id);
1046
+ A && !D(A, v) && y("updateAnnotation", A, v);
1047
1047
  }), h = [
1048
1048
  // Remove annotations that were deselected
1049
- ...h.filter((b) => f.has(b.id)),
1049
+ ...h.filter((v) => f.has(v.id)),
1050
1050
  // Add editable annotations that were selected
1051
- ...l.filter(({ id: b }) => !d.has(b)).map(({ id: b }) => i.getAnnotation(b))
1051
+ ...c.filter(({ id: v }) => !d.has(v)).map(({ id: v }) => i.getAnnotation(v))
1052
1052
  ];
1053
1053
  }
1054
1054
  y("selectionChanged", h);
1055
1055
  }
1056
- }), s.subscribe((l) => {
1057
- !v && l ? y("mouseEnterAnnotation", i.getAnnotation(l)) : v && !l ? y("mouseLeaveAnnotation", i.getAnnotation(v)) : v && l && (y("mouseLeaveAnnotation", i.getAnnotation(v)), y("mouseEnterAnnotation", i.getAnnotation(l))), v = l;
1058
- }), a == null || a.subscribe((l) => y("viewportIntersect", l.map((d) => i.getAnnotation(d)))), i.observe((l) => {
1059
- o && (c && clearTimeout(c), c = setTimeout(x, 1e3));
1060
- const { created: d, deleted: f } = l.changes;
1061
- (d || []).forEach((b) => y("createAnnotation", b)), (f || []).forEach((b) => y("deleteAnnotation", b)), (l.changes.updated || []).filter((b) => [
1062
- ...b.bodiesCreated || [],
1063
- ...b.bodiesDeleted || [],
1064
- ...b.bodiesUpdated || []
1065
- ].length > 0).forEach(({ oldValue: b, newValue: A }) => {
1066
- const R = h.find((T) => T.id === b.id) || b;
1067
- h = h.map((T) => T.id === b.id ? A : T), y("updateAnnotation", A, R);
1056
+ }), s.subscribe((c) => {
1057
+ !b && c ? y("mouseEnterAnnotation", i.getAnnotation(c)) : b && !c ? y("mouseLeaveAnnotation", i.getAnnotation(b)) : b && c && (y("mouseLeaveAnnotation", i.getAnnotation(b)), y("mouseEnterAnnotation", i.getAnnotation(c))), b = c;
1058
+ }), a == null || a.subscribe((c) => y("viewportIntersect", c.map((d) => i.getAnnotation(d)))), i.observe((c) => {
1059
+ o && (l && clearTimeout(l), l = setTimeout(x, 1e3));
1060
+ const { created: d, deleted: f } = c.changes;
1061
+ (d || []).forEach((v) => y("createAnnotation", v)), (f || []).forEach((v) => y("deleteAnnotation", v)), (c.changes.updated || []).filter((v) => [
1062
+ ...v.bodiesCreated || [],
1063
+ ...v.bodiesDeleted || [],
1064
+ ...v.bodiesUpdated || []
1065
+ ].length > 0).forEach(({ oldValue: v, newValue: A }) => {
1066
+ const R = h.find((T) => T.id === v.id) || v;
1067
+ h = h.map((T) => T.id === v.id ? A : T), y("updateAnnotation", A, R);
1068
1068
  });
1069
- }, { origin: N.LOCAL }), i.observe((l) => {
1069
+ }, { origin: N.LOCAL }), i.observe((c) => {
1070
1070
  if (h) {
1071
- const d = new Set(h.map((b) => b.id)), f = (l.changes.updated || []).filter(({ newValue: b }) => d.has(b.id)).map(({ newValue: b }) => b);
1072
- f.length > 0 && (h = h.map((b) => f.find((R) => R.id === b.id) || b));
1071
+ const d = new Set(h.map((v) => v.id)), f = (c.changes.updated || []).filter(({ newValue: v }) => d.has(v.id)).map(({ newValue: v }) => v);
1072
+ f.length > 0 && (h = h.map((v) => f.find((R) => R.id === v.id) || v));
1073
1073
  }
1074
1074
  }, { origin: N.REMOTE });
1075
- const w = (l) => (d) => {
1075
+ const w = (c) => (d) => {
1076
1076
  const { updated: f } = d;
1077
- l ? (f || []).forEach((b) => y("updateAnnotation", b.oldValue, b.newValue)) : (f || []).forEach((b) => y("updateAnnotation", b.newValue, b.oldValue));
1077
+ c ? (f || []).forEach((v) => y("updateAnnotation", v.oldValue, v.newValue)) : (f || []).forEach((v) => y("updateAnnotation", v.newValue, v.oldValue));
1078
1078
  };
1079
1079
  return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: m, off: g, emit: y };
1080
1080
  }, Pe = (t) => (e) => e.reduce((n, o) => {
@@ -1091,42 +1091,42 @@ const Ye = 250, De = (t) => {
1091
1091
  }, { parsed: [], failed: [] }), ze = (t, e, n) => {
1092
1092
  const { store: o, selection: i } = t, r = (w) => {
1093
1093
  if (n) {
1094
- const { parsed: l, error: d } = n.parse(w);
1095
- l ? o.addAnnotation(l, N.REMOTE) : console.error(d);
1094
+ const { parsed: c, error: d } = n.parse(w);
1095
+ c ? o.addAnnotation(c, N.REMOTE) : console.error(d);
1096
1096
  } else
1097
1097
  o.addAnnotation(w, N.REMOTE);
1098
1098
  }, s = () => i.clear(), a = () => o.clear(), u = (w) => {
1099
- const l = o.getAnnotation(w);
1100
- return n && l ? n.serialize(l) : l;
1101
- }, h = () => n ? o.all().map(n.serialize) : o.all(), v = () => {
1099
+ const c = o.getAnnotation(w);
1100
+ return n && c ? n.serialize(c) : c;
1101
+ }, h = () => n ? o.all().map(n.serialize) : o.all(), b = () => {
1102
1102
  var w;
1103
- const l = (((w = i.selected) == null ? void 0 : w.map((d) => d.id)) || []).map((d) => o.getAnnotation(d)).filter(Boolean);
1104
- return n ? l.map(n.serialize) : l;
1105
- }, c = (w, l = !0) => fetch(w).then((d) => d.json()).then((d) => (g(d, l), d)), m = (w) => {
1103
+ const c = (((w = i.selected) == null ? void 0 : w.map((d) => d.id)) || []).map((d) => o.getAnnotation(d)).filter(Boolean);
1104
+ return n ? c.map(n.serialize) : c;
1105
+ }, l = (w, c = !0) => fetch(w).then((d) => d.json()).then((d) => (g(d, c), d)), m = (w) => {
1106
1106
  if (typeof w == "string") {
1107
- const l = o.getAnnotation(w);
1108
- if (o.deleteAnnotation(w), l)
1109
- return n ? n.serialize(l) : l;
1107
+ const c = o.getAnnotation(w);
1108
+ if (o.deleteAnnotation(w), c)
1109
+ return n ? n.serialize(c) : c;
1110
1110
  } else {
1111
- const l = n ? n.parse(w).parsed : w;
1112
- if (l)
1113
- return o.deleteAnnotation(l), w;
1111
+ const c = n ? n.parse(w).parsed : w;
1112
+ if (c)
1113
+ return o.deleteAnnotation(c), w;
1114
1114
  }
1115
- }, g = (w, l = !0) => {
1115
+ }, g = (w, c = !0) => {
1116
1116
  if (n) {
1117
1117
  const { parsed: d, failed: f } = Pe(n)(w);
1118
- f.length > 0 && console.warn(`Discarded ${f.length} invalid annotations`, f), o.bulkAddAnnotation(d, l, N.REMOTE);
1118
+ f.length > 0 && console.warn(`Discarded ${f.length} invalid annotations`, f), o.bulkAddAnnotation(d, c, N.REMOTE);
1119
1119
  } else
1120
- o.bulkAddAnnotation(w, l, N.REMOTE);
1120
+ o.bulkAddAnnotation(w, c, N.REMOTE);
1121
1121
  }, y = (w) => {
1122
1122
  w ? i.setSelected(w) : i.clear();
1123
1123
  }, x = (w) => {
1124
1124
  if (n) {
1125
- const l = n.parse(w).parsed, d = n.serialize(o.getAnnotation(l.id));
1126
- return o.updateAnnotation(l), d;
1125
+ const c = n.parse(w).parsed, d = n.serialize(o.getAnnotation(c.id));
1126
+ return o.updateAnnotation(c), d;
1127
1127
  } else {
1128
- const l = o.getAnnotation(w.id);
1129
- return o.updateAnnotation(w), l;
1128
+ const c = o.getAnnotation(w.id);
1129
+ return o.updateAnnotation(w), c;
1130
1130
  }
1131
1131
  };
1132
1132
  return {
@@ -1137,8 +1137,8 @@ const Ye = 250, De = (t) => {
1137
1137
  clearAnnotations: a,
1138
1138
  getAnnotationById: u,
1139
1139
  getAnnotations: h,
1140
- getSelected: v,
1141
- loadAnnotations: c,
1140
+ getSelected: b,
1141
+ loadAnnotations: l,
1142
1142
  redo: e.redo,
1143
1143
  removeAnnotation: m,
1144
1144
  setAnnotations: g,
@@ -1208,25 +1208,25 @@ const xn = (t, e) => ({
1208
1208
  selector: []
1209
1209
  };
1210
1210
  for (const u of s) {
1211
- const v = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((c, m) => {
1211
+ const b = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l, m) => {
1212
1212
  switch (m.type) {
1213
1213
  case "TextQuoteSelector":
1214
- c.quote = m.exact;
1214
+ l.quote = m.exact;
1215
1215
  break;
1216
1216
  case "TextPositionSelector":
1217
- c.start = m.start, c.end = m.end;
1217
+ l.start = m.start, l.end = m.end;
1218
1218
  break;
1219
1219
  }
1220
- return c;
1220
+ return l;
1221
1221
  }, {});
1222
- if (tn(v))
1223
- a.selector.push({ id: u.id, ...v });
1222
+ if (tn(b))
1223
+ a.selector.push({ id: u.id, ...b });
1224
1224
  else {
1225
- const c = [
1226
- v.start ? void 0 : "TextPositionSelector",
1227
- v.quote ? void 0 : "TextQuoteSelector"
1225
+ const l = [
1226
+ b.start ? void 0 : "TextPositionSelector",
1227
+ b.quote ? void 0 : "TextQuoteSelector"
1228
1228
  ].filter(Boolean);
1229
- return { error: Error(`Missing selector types: ${c.join(" and ")} for annotation: ${t.id}`) };
1229
+ return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
1230
1230
  }
1231
1231
  }
1232
1232
  return { parsed: a };
@@ -1252,12 +1252,12 @@ const xn = (t, e) => ({
1252
1252
  creator: a,
1253
1253
  created: u,
1254
1254
  updated: h,
1255
- ...v
1256
- } = i, c = s.map((m) => {
1257
- const { quote: g, start: y, end: x, range: w } = m, { prefix: l, suffix: d } = Kt(w, n), f = [{
1255
+ ...b
1256
+ } = i, l = s.map((m) => {
1257
+ const { quote: g, start: y, end: x, range: w } = m, { prefix: c, suffix: d } = Kt(w, n), f = [{
1258
1258
  type: "TextQuoteSelector",
1259
1259
  exact: g,
1260
- prefix: l,
1260
+ prefix: c,
1261
1261
  suffix: d
1262
1262
  }, {
1263
1263
  type: "TextPositionSelector",
@@ -1265,7 +1265,7 @@ const xn = (t, e) => ({
1265
1265
  end: x
1266
1266
  }];
1267
1267
  return {
1268
- ...v,
1268
+ ...b,
1269
1269
  id: m.id,
1270
1270
  source: e,
1271
1271
  selector: f
@@ -1280,7 +1280,7 @@ const xn = (t, e) => ({
1280
1280
  creator: a,
1281
1281
  created: u == null ? void 0 : u.toISOString(),
1282
1282
  modified: h == null ? void 0 : h.toISOString(),
1283
- target: c
1283
+ target: l
1284
1284
  };
1285
1285
  };
1286
1286
  function rn(t, e, n, o, i) {
@@ -1289,8 +1289,8 @@ function rn(t, e, n, o, i) {
1289
1289
  function Xt(t, e, n, o, i) {
1290
1290
  for (; o > n; ) {
1291
1291
  if (o - n > 600) {
1292
- var r = o - n + 1, s = e - n + 1, a = Math.log(r), u = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * u * (r - u) / r) * (s - r / 2 < 0 ? -1 : 1), v = Math.max(n, Math.floor(e - s * u / r + h)), c = Math.min(o, Math.floor(e + (r - s) * u / r + h));
1293
- Xt(t, e, v, c, i);
1292
+ var r = o - n + 1, s = e - n + 1, a = Math.log(r), u = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * u * (r - u) / r) * (s - r / 2 < 0 ? -1 : 1), b = Math.max(n, Math.floor(e - s * u / r + h)), l = Math.min(o, Math.floor(e + (r - s) * u / r + h));
1293
+ Xt(t, e, b, l, i);
1294
1294
  }
1295
1295
  var m = t[e], g = n, y = o;
1296
1296
  for (F(t, n, e), i(t[o], m) > 0 && F(t, n, o); g < y; ) {
@@ -1385,9 +1385,9 @@ class an {
1385
1385
  let a, u, h;
1386
1386
  for (; o || r.length; ) {
1387
1387
  if (o || (o = r.pop(), u = r[r.length - 1], a = s.pop(), h = !0), o.leaf) {
1388
- const v = cn(e, o.children, n);
1389
- if (v !== -1)
1390
- return o.children.splice(v, 1), r.push(o), this._condense(r), this;
1388
+ const b = ln(e, o.children, n);
1389
+ if (b !== -1)
1390
+ return o.children.splice(b, 1), r.push(o), this._condense(r), this;
1391
1391
  }
1392
1392
  !h && !o.leaf && at(o, i) ? (r.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], h = !1) : o = null;
1393
1393
  }
@@ -1422,11 +1422,11 @@ class an {
1422
1422
  i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = z([]), a.leaf = !1, a.height = i;
1423
1423
  const u = Math.ceil(r / s), h = u * Math.ceil(Math.sqrt(s));
1424
1424
  Rt(e, n, o, h, this.compareMinX);
1425
- for (let v = n; v <= o; v += h) {
1426
- const c = Math.min(v + h - 1, o);
1427
- Rt(e, v, c, u, this.compareMinY);
1428
- for (let m = v; m <= c; m += u) {
1429
- const g = Math.min(m + u - 1, c);
1425
+ for (let b = n; b <= o; b += h) {
1426
+ const l = Math.min(b + h - 1, o);
1427
+ Rt(e, b, l, u, this.compareMinY);
1428
+ for (let m = b; m <= l; m += u) {
1429
+ const g = Math.min(m + u - 1, l);
1430
1430
  a.children.push(this._build(e, m, g, i - 1));
1431
1431
  }
1432
1432
  }
@@ -1436,8 +1436,8 @@ class an {
1436
1436
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1437
1437
  let r = 1 / 0, s = 1 / 0, a;
1438
1438
  for (let u = 0; u < n.children.length; u++) {
1439
- const h = n.children[u], v = st(h), c = un(e, h) - v;
1440
- c < s ? (s = c, r = v < r ? v : r, a = h) : c === s && v < r && (r = v, a = h);
1439
+ const h = n.children[u], b = st(h), l = un(e, h) - b;
1440
+ l < s ? (s = l, r = b < r ? b : r, a = h) : l === s && b < r && (r = b, a = h);
1441
1441
  }
1442
1442
  n = a || n.children[0];
1443
1443
  }
@@ -1462,14 +1462,14 @@ class an {
1462
1462
  _chooseSplitIndex(e, n, o) {
1463
1463
  let i, r = 1 / 0, s = 1 / 0;
1464
1464
  for (let a = n; a <= o - n; a++) {
1465
- const u = W(e, 0, a, this.toBBox), h = W(e, a, o, this.toBBox), v = hn(u, h), c = st(u) + st(h);
1466
- v < r ? (r = v, i = a, s = c < s ? c : s) : v === r && c < s && (s = c, i = a);
1465
+ const u = W(e, 0, a, this.toBBox), h = W(e, a, o, this.toBBox), b = hn(u, h), l = st(u) + st(h);
1466
+ b < r ? (r = b, i = a, s = l < s ? l : s) : b === r && l < s && (s = l, i = a);
1467
1467
  }
1468
1468
  return i || o - n;
1469
1469
  }
1470
1470
  // sorts node children by the best axis for split
1471
1471
  _chooseSplitAxis(e, n, o) {
1472
- const i = e.leaf ? this.compareMinX : ln, r = e.leaf ? this.compareMinY : dn, s = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);
1472
+ const i = e.leaf ? this.compareMinX : cn, r = e.leaf ? this.compareMinY : dn, s = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);
1473
1473
  s < a && e.children.sort(i);
1474
1474
  }
1475
1475
  // total margin of all possible split distributions where each node is at least m full
@@ -1478,12 +1478,12 @@ class an {
1478
1478
  const r = this.toBBox, s = W(e, 0, n, r), a = W(e, o - n, o, r);
1479
1479
  let u = Q(s) + Q(a);
1480
1480
  for (let h = n; h < o - n; h++) {
1481
- const v = e.children[h];
1482
- q(s, e.leaf ? r(v) : v), u += Q(s);
1481
+ const b = e.children[h];
1482
+ q(s, e.leaf ? r(b) : b), u += Q(s);
1483
1483
  }
1484
1484
  for (let h = o - n - 1; h >= n; h--) {
1485
- const v = e.children[h];
1486
- q(a, e.leaf ? r(v) : v), u += Q(a);
1485
+ const b = e.children[h];
1486
+ q(a, e.leaf ? r(b) : b), u += Q(a);
1487
1487
  }
1488
1488
  return u;
1489
1489
  }
@@ -1496,7 +1496,7 @@ class an {
1496
1496
  e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : P(e[n], this.toBBox);
1497
1497
  }
1498
1498
  }
1499
- function cn(t, e, n) {
1499
+ function ln(t, e, n) {
1500
1500
  if (!n)
1501
1501
  return e.indexOf(t);
1502
1502
  for (let o = 0; o < e.length; o++)
@@ -1518,7 +1518,7 @@ function W(t, e, n, o, i) {
1518
1518
  function q(t, e) {
1519
1519
  return t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY), t;
1520
1520
  }
1521
- function ln(t, e) {
1521
+ function cn(t, e) {
1522
1522
  return t.minX - e.minX;
1523
1523
  }
1524
1524
  function dn(t, e) {
@@ -1564,12 +1564,12 @@ function Rt(t, e, n, o, i) {
1564
1564
  }
1565
1565
  }
1566
1566
  const fn = (t, e) => {
1567
- const n = new an(), o = /* @__PURE__ */ new Map(), i = (l, d) => {
1568
- const f = l.selector.flatMap((A) => {
1567
+ const n = new an(), o = /* @__PURE__ */ new Map(), i = (c, d) => {
1568
+ const f = c.selector.flatMap((A) => {
1569
1569
  const T = A.range instanceof Range && !A.range.collapsed && A.range.startContainer.nodeType === Node.TEXT_NODE && A.range.endContainer.nodeType === Node.TEXT_NODE ? A.range : Bt(A, e).range;
1570
1570
  return Array.from(T.getClientRects());
1571
- }), b = Zt(f).map(({ left: A, top: R, right: T, bottom: p }) => new DOMRect(A - d.left, R - d.top, T - A, p - R));
1572
- return b.map((A) => {
1571
+ }), v = Zt(f).map(({ left: A, top: R, right: T, bottom: p }) => new DOMRect(A - d.left, R - d.top, T - A, p - R));
1572
+ return v.map((A) => {
1573
1573
  const { x: R, y: T, width: p, height: S } = A;
1574
1574
  return {
1575
1575
  minX: R,
@@ -1577,117 +1577,117 @@ const fn = (t, e) => {
1577
1577
  maxX: R + p,
1578
1578
  maxY: T + S,
1579
1579
  annotation: {
1580
- id: l.annotation,
1581
- rects: b
1580
+ id: c.annotation,
1581
+ rects: v
1582
1582
  }
1583
1583
  };
1584
1584
  });
1585
1585
  }, r = () => [...o.values()], s = () => {
1586
1586
  n.clear(), o.clear();
1587
- }, a = (l) => {
1588
- const d = i(l, e.getBoundingClientRect());
1589
- d.forEach((f) => n.insert(f)), o.set(l.annotation, d);
1590
- }, u = (l) => {
1591
- const d = o.get(l.annotation);
1592
- d && (d.forEach((f) => n.remove(f)), o.delete(l.annotation));
1593
- }, h = (l) => {
1594
- u(l), a(l);
1595
- }, v = (l, d = !0) => {
1587
+ }, a = (c) => {
1588
+ const d = i(c, e.getBoundingClientRect());
1589
+ d.forEach((f) => n.insert(f)), o.set(c.annotation, d);
1590
+ }, u = (c) => {
1591
+ const d = o.get(c.annotation);
1592
+ d && (d.forEach((f) => n.remove(f)), o.delete(c.annotation));
1593
+ }, h = (c) => {
1594
+ u(c), a(c);
1595
+ }, b = (c, d = !0) => {
1596
1596
  d && s();
1597
- const f = e.getBoundingClientRect(), b = l.map((R) => ({ target: R, rects: i(R, f) }));
1598
- b.forEach(({ target: R, rects: T }) => o.set(R.annotation, T));
1599
- const A = b.reduce((R, { rects: T }) => [...R, ...T], []);
1597
+ const f = e.getBoundingClientRect(), v = c.map((R) => ({ target: R, rects: i(R, f) }));
1598
+ v.forEach(({ target: R, rects: T }) => o.set(R.annotation, T));
1599
+ const A = v.reduce((R, { rects: T }) => [...R, ...T], []);
1600
1600
  n.load(A);
1601
- }, c = (l, d) => {
1601
+ }, l = (c, d) => {
1602
1602
  const f = n.search({
1603
- minX: l,
1603
+ minX: c,
1604
1604
  minY: d,
1605
- maxX: l,
1605
+ maxX: c,
1606
1606
  maxY: d
1607
- }), b = (A) => A.annotation.rects.reduce((R, T) => R + T.width * T.height, 0);
1607
+ }), v = (A) => A.annotation.rects.reduce((R, T) => R + T.width * T.height, 0);
1608
1608
  if (f.length > 0)
1609
- return f.sort((A, R) => b(A) - b(R)), f[0].annotation.id;
1610
- }, m = (l) => {
1611
- const d = g(l);
1609
+ return f.sort((A, R) => v(A) - v(R)), f[0].annotation.id;
1610
+ }, m = (c) => {
1611
+ const d = g(c);
1612
1612
  if (d.length === 0)
1613
1613
  return;
1614
- let f = d[0].left, b = d[0].top, A = d[0].right, R = d[0].bottom;
1614
+ let f = d[0].left, v = d[0].top, A = d[0].right, R = d[0].bottom;
1615
1615
  for (let T = 1; T < d.length; T++) {
1616
1616
  const p = d[T];
1617
- f = Math.min(f, p.left), b = Math.min(b, p.top), A = Math.max(A, p.right), R = Math.max(R, p.bottom);
1617
+ f = Math.min(f, p.left), v = Math.min(v, p.top), A = Math.max(A, p.right), R = Math.max(R, p.bottom);
1618
1618
  }
1619
- return new DOMRect(f, b, A - f, R - b);
1620
- }, g = (l) => {
1621
- const d = o.get(l);
1619
+ return new DOMRect(f, v, A - f, R - v);
1620
+ }, g = (c) => {
1621
+ const d = o.get(c);
1622
1622
  return d ? d[0].annotation.rects : [];
1623
1623
  };
1624
1624
  return {
1625
1625
  all: r,
1626
1626
  clear: s,
1627
- getAt: c,
1627
+ getAt: l,
1628
1628
  getAnnotationBounds: m,
1629
1629
  getAnnotationRects: g,
1630
- getIntersecting: (l, d, f, b) => {
1631
- const A = n.search({ minX: l, minY: d, maxX: f, maxY: b }), R = new Set(A.reduce((T, p) => [...T, p.annotation.id], []));
1630
+ getIntersecting: (c, d, f, v) => {
1631
+ const A = n.search({ minX: c, minY: d, maxX: f, maxY: v }), R = new Set(A.reduce((T, p) => [...T, p.annotation.id], []));
1632
1632
  return Array.from(R).map((T) => ({
1633
1633
  annotation: t.getAnnotation(T),
1634
1634
  rects: g(T)
1635
1635
  })).filter((T) => !!T.annotation);
1636
1636
  },
1637
1637
  insert: a,
1638
- recalculate: () => v(t.all().map((l) => l.target), !0),
1638
+ recalculate: () => b(t.all().map((c) => c.target), !0),
1639
1639
  remove: u,
1640
- set: v,
1640
+ set: b,
1641
1641
  size: () => n.all().length,
1642
1642
  update: h
1643
1643
  };
1644
1644
  }, gn = (t, e) => {
1645
1645
  const n = Xe(), o = fn(n, t), i = Re(n, e), r = Te(n), s = He(), a = (x, w = N.LOCAL) => {
1646
- const l = tt(x, t), d = k(l.target.selector);
1647
- return d && n.addAnnotation(l, w), d;
1648
- }, u = (x, w = !0, l = N.LOCAL) => {
1649
- const d = x.map((b) => tt(b, t)), f = d.filter((b) => !k(b.target.selector));
1650
- return f.length > 0 ? (console.warn("Could not revive all targets for these annotations:", f), n.bulkAddAnnotation(d, w, l), f) : (n.bulkAddAnnotation(d, w, l), []);
1646
+ const c = tt(x, t), d = k(c.target.selector);
1647
+ return d && n.addAnnotation(c, w), d;
1648
+ }, u = (x, w = !0, c = N.LOCAL) => {
1649
+ const d = x.map((v) => tt(v, t)), f = d.filter((v) => !k(v.target.selector));
1650
+ return f.length > 0 ? (console.warn("Could not revive all targets for these annotations:", f), n.bulkAddAnnotation(d, w, c), f) : (n.bulkAddAnnotation(d, w, c), []);
1651
1651
  }, h = (x, w = N.LOCAL) => {
1652
- const l = x.map((f) => tt(f, t)), d = l.filter((f) => !k(f.target.selector));
1653
- return d.length > 0 && console.warn("Could not revive all targets for these annotations:", d), l.forEach((f) => {
1652
+ const c = x.map((f) => tt(f, t)), d = c.filter((f) => !k(f.target.selector));
1653
+ return d.length > 0 && console.warn("Could not revive all targets for these annotations:", d), c.forEach((f) => {
1654
1654
  n.getAnnotation(f.id) ? n.updateAnnotation(f, w) : n.addAnnotation(f, w);
1655
1655
  }), d;
1656
- }, v = (x, w = N.LOCAL) => {
1657
- const l = Z(x, t);
1658
- n.updateTarget(l, w);
1659
- }, c = (x, w = N.LOCAL) => {
1660
- const l = x.map((d) => Z(d, t));
1661
- n.bulkUpdateTargets(l, w);
1656
+ }, b = (x, w = N.LOCAL) => {
1657
+ const c = Z(x, t);
1658
+ n.updateTarget(c, w);
1659
+ }, l = (x, w = N.LOCAL) => {
1660
+ const c = x.map((d) => Z(d, t));
1661
+ n.bulkUpdateTargets(c, w);
1662
1662
  }, m = (x, w) => {
1663
- const l = o.getAt(x, w);
1664
- return l ? n.getAnnotation(l) : void 0;
1665
- }, g = (x, w, l, d = 5) => {
1663
+ const c = o.getAt(x, w);
1664
+ return c ? n.getAnnotation(c) : void 0;
1665
+ }, g = (x, w, c, d = 5) => {
1666
1666
  const f = o.getAnnotationRects(x);
1667
1667
  if (f.length !== 0) {
1668
- if (w && l) {
1669
- const b = f.find(({ top: A, right: R, bottom: T, left: p }) => w >= p - d && w <= R + d && l >= A - d && l <= T + d);
1670
- if (b)
1671
- return b;
1668
+ if (w && c) {
1669
+ const v = f.find(({ top: A, right: R, bottom: T, left: p }) => w >= p - d && w <= R + d && c >= A - d && c <= T + d);
1670
+ if (v)
1671
+ return v;
1672
1672
  }
1673
1673
  return o.getAnnotationBounds(x);
1674
1674
  }
1675
1675
  }, y = () => o.recalculate();
1676
1676
  return n.observe(({ changes: x }) => {
1677
- const w = (x.created || []).filter((f) => k(f.target.selector)), l = (x.deleted || []).filter((f) => k(f.target.selector)), d = (x.updated || []).filter((f) => k(f.newValue.target.selector));
1678
- w.length > 0 && o.set(w.map((f) => f.target), !1), (l == null ? void 0 : l.length) > 0 && l.forEach((f) => o.remove(f.target)), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: f }) => o.update(f.target));
1677
+ const w = (x.created || []).filter((f) => k(f.target.selector)), c = (x.deleted || []).filter((f) => k(f.target.selector)), d = (x.updated || []).filter((f) => k(f.newValue.target.selector));
1678
+ w.length > 0 && o.set(w.map((f) => f.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach((f) => o.remove(f.target)), (d == null ? void 0 : d.length) > 0 && d.forEach(({ newValue: f }) => o.update(f.target));
1679
1679
  }), {
1680
1680
  store: {
1681
1681
  ...n,
1682
1682
  addAnnotation: a,
1683
1683
  bulkAddAnnotation: u,
1684
- bulkUpdateTargets: c,
1684
+ bulkUpdateTargets: l,
1685
1685
  bulkUpsertAnnotations: h,
1686
1686
  getAnnotationBounds: g,
1687
1687
  getAt: m,
1688
1688
  getIntersecting: o.getIntersecting,
1689
1689
  recalculatePositions: y,
1690
- updateTarget: v
1690
+ updateTarget: b
1691
1691
  },
1692
1692
  selection: i,
1693
1693
  hover: r,
@@ -1701,25 +1701,25 @@ const fn = (t, e) => {
1701
1701
  }, mn = (t, e, n = {}) => {
1702
1702
  const o = pn(), i = o.getContext("2d");
1703
1703
  t.appendChild(o);
1704
- const r = /* @__PURE__ */ new Map(), s = (c) => Array.from(r.entries()).filter(([m, g]) => g.presenceKey === c.presenceKey).map(([m, g]) => m);
1705
- return e.on("selectionChange", (c, m) => {
1706
- s(c).forEach((y) => r.delete(y)), m && m.forEach((y) => r.set(y, c));
1704
+ const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([m, g]) => g.presenceKey === l.presenceKey).map(([m, g]) => m);
1705
+ return e.on("selectionChange", (l, m) => {
1706
+ s(l).forEach((y) => r.delete(y)), m && m.forEach((y) => r.set(y, l));
1707
1707
  }), {
1708
1708
  clear: () => {
1709
- const { width: c, height: m } = o;
1710
- i.clearRect(-0.5, -0.5, c + 1, m + 1);
1709
+ const { width: l, height: m } = o;
1710
+ i.clearRect(-0.5, -0.5, l + 1, m + 1);
1711
1711
  },
1712
1712
  destroy: () => {
1713
1713
  o.remove();
1714
1714
  },
1715
- paint: (c, m, g) => {
1715
+ paint: (l, m, g) => {
1716
1716
  n.font && (i.font = n.font);
1717
- const y = r.get(c.annotation.id);
1717
+ const y = r.get(l.annotation.id);
1718
1718
  if (y) {
1719
- const { height: x } = c.rects[0], w = c.rects[0].x + m.left, l = c.rects[0].y + m.top;
1720
- i.fillStyle = y.appearance.color, i.fillRect(w - 2, l - 2.5, 2, x + 5);
1721
- const d = i.measureText(y.appearance.label), f = d.width + 6, b = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, A = d.fontBoundingBoxAscent ? 8 : 6.5;
1722
- return i.fillRect(w - 2, l - 2.5 - b, f, b), i.fillStyle = "#fff", i.fillText(y.appearance.label, w + 1, l - A), {
1719
+ const { height: x } = l.rects[0], w = l.rects[0].x + m.left, c = l.rects[0].y + m.top;
1720
+ i.fillStyle = y.appearance.color, i.fillRect(w - 2, c - 2.5, 2, x + 5);
1721
+ const d = i.measureText(y.appearance.label), f = d.width + 6, v = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, A = d.fontBoundingBoxAscent ? 8 : 6.5;
1722
+ return i.fillRect(w - 2, c - 2.5 - v, f, v), i.fillStyle = "#fff", i.fillText(y.appearance.label, w + 1, c - A), {
1723
1723
  fill: y.appearance.color,
1724
1724
  fillOpacity: g ? 0.45 : 0.18
1725
1725
  };
@@ -1727,8 +1727,8 @@ const fn = (t, e) => {
1727
1727
  },
1728
1728
  reset: () => {
1729
1729
  o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
1730
- const c = o.getContext("2d");
1731
- c.scale(2, 2), c.translate(0.5, 0.5);
1730
+ const l = o.getContext("2d");
1731
+ l.scale(2, 2), l.translate(0.5, 0.5);
1732
1732
  }
1733
1733
  };
1734
1734
  }, kt = (t) => {
@@ -1738,8 +1738,8 @@ const fn = (t, e) => {
1738
1738
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : kt(t.parentElement);
1739
1739
  }, bn = (t, e) => (n) => {
1740
1740
  const o = (r) => {
1741
- const s = i.getBoundingClientRect(), a = i.clientHeight, u = i.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: v, height: c } = e.getAnnotationBounds(n.id), m = h.top - s.top, g = h.left - s.left, y = i.parentElement ? i.scrollTop : 0, x = i.parentElement ? i.scrollLeft : 0, w = m + y - (a - c) / 2, l = g + x - (u - v) / 2;
1742
- i.scroll({ top: w, left: l, behavior: "smooth" });
1741
+ const s = i.getBoundingClientRect(), a = i.clientHeight, u = i.clientWidth, h = r.selector[0].range.getBoundingClientRect(), { width: b, height: l } = e.getAnnotationBounds(n.id), m = h.top - s.top, g = h.left - s.left, y = i.parentElement ? i.scrollTop : 0, x = i.parentElement ? i.scrollLeft : 0, w = m + y - (a - l) / 2, c = g + x - (u - b) / 2;
1742
+ i.scroll({ top: w, left: c, behavior: "smooth" });
1743
1743
  }, i = kt(t);
1744
1744
  if (i) {
1745
1745
  const r = e.getAnnotation(n.id), { range: s } = r.target.selector[0];
@@ -1757,23 +1757,23 @@ const fn = (t, e) => {
1757
1757
  let r, s;
1758
1758
  const a = (x) => r = x;
1759
1759
  let u = !1, h;
1760
- const v = (x) => {
1761
- var l;
1760
+ const b = (x) => {
1761
+ var c;
1762
1762
  if (!u)
1763
1763
  return;
1764
- !((l = x.target.parentElement) != null && l.closest(H)) ? s = {
1764
+ !((c = x.target.parentElement) != null && c.closest(Y)) ? s = {
1765
1765
  annotation: Vt(),
1766
1766
  selector: [],
1767
1767
  creator: r,
1768
1768
  created: /* @__PURE__ */ new Date()
1769
1769
  } : s = void 0;
1770
1770
  };
1771
- t.addEventListener("selectstart", v);
1772
- const c = ut((x) => {
1771
+ t.addEventListener("selectstart", b);
1772
+ const l = ut((x) => {
1773
1773
  const w = document.getSelection();
1774
- if (x.timeStamp - ((h == null ? void 0 : h.timeStamp) || x.timeStamp) < 1e3 && !s && v(h), w.isCollapsed || !u || !s)
1774
+ if (x.timeStamp - ((h == null ? void 0 : h.timeStamp) || x.timeStamp) < 1e3 && !s && b(h), w.isCollapsed || !u || !s)
1775
1775
  return;
1776
- const l = w.getRangeAt(0), d = ee(l.cloneRange()), f = qt(d);
1776
+ const c = w.getRangeAt(0), d = ee(c.cloneRange()), f = qt(d);
1777
1777
  (f.length !== s.selector.length || f.some((A, R) => {
1778
1778
  var T;
1779
1779
  return A.toString() !== ((T = s.selector[R]) == null ? void 0 : T.quote);
@@ -1786,29 +1786,29 @@ const fn = (t, e) => {
1786
1786
  target: s
1787
1787
  }), i.clickSelect(s.annotation, h)));
1788
1788
  });
1789
- document.addEventListener("selectionchange", c);
1789
+ document.addEventListener("selectionchange", l);
1790
1790
  const m = (x) => {
1791
- const { target: w, timeStamp: l, offsetX: d, offsetY: f, type: b } = x;
1792
- h = { ...x, target: w, timeStamp: l, offsetX: d, offsetY: f, type: b }, u = x.button === 0;
1791
+ const { target: w, timeStamp: c, offsetX: d, offsetY: f, type: v } = x;
1792
+ h = { ...x, target: w, timeStamp: c, offsetX: d, offsetY: f, type: v }, u = x.button === 0;
1793
1793
  };
1794
1794
  t.addEventListener("pointerdown", m);
1795
1795
  const g = (x) => {
1796
1796
  var f;
1797
- if (!!((f = x.target.parentElement) != null && f.closest(H)) || !u)
1797
+ if (!!((f = x.target.parentElement) != null && f.closest(Y)) || !u)
1798
1798
  return;
1799
- const l = () => {
1800
- const { x: b, y: A } = t.getBoundingClientRect(), R = o.getAt(x.clientX - b, x.clientY - A);
1799
+ const c = () => {
1800
+ const { x: v, y: A } = t.getBoundingClientRect(), R = o.getAt(x.clientX - v, x.clientY - A);
1801
1801
  if (R) {
1802
1802
  const { selected: T } = i;
1803
1803
  (T.length !== 1 || T[0].id !== R.id) && i.clickSelect(R.id, x);
1804
1804
  } else
1805
1805
  i.isEmpty() || i.clear();
1806
1806
  }, d = x.timeStamp - h.timeStamp;
1807
- document.getSelection().isCollapsed && d < 300 ? (s = void 0, l()) : s && i.clickSelect(s.annotation, x);
1807
+ document.getSelection().isCollapsed && d < 300 ? (s = void 0, c()) : s && i.clickSelect(s.annotation, x);
1808
1808
  };
1809
1809
  return document.addEventListener("pointerup", g), {
1810
1810
  destroy: () => {
1811
- t.removeEventListener("selectstart", v), document.removeEventListener("selectionchange", c), t.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", g);
1811
+ t.removeEventListener("selectstart", b), document.removeEventListener("selectionchange", l), t.removeEventListener("pointerdown", m), document.removeEventListener("pointerup", g);
1812
1812
  },
1813
1813
  setUser: a
1814
1814
  };
@@ -1820,30 +1820,30 @@ const fn = (t, e) => {
1820
1820
  e.adapter
1821
1821
  );
1822
1822
  let u = Ke();
1823
- const h = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Lt : e.renderer || Lt, v = h === "SPANS" ? ye(t, n, i) : h === "CSS_HIGHLIGHTS" ? be(t, n, i) : h === "CANVAS" ? ae(t, n, i) : void 0;
1824
- if (!v)
1823
+ const h = e.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : Lt : e.renderer || Lt, b = h === "SPANS" ? ye(t, n, i) : h === "CSS_HIGHLIGHTS" ? be(t, n, i) : h === "CANVAS" ? ae(t, n, i) : void 0;
1824
+ if (!b)
1825
1825
  throw `Unknown renderer implementation: ${h}`;
1826
- console.debug(`Using ${h} renderer`), e.style && v.setStyle(e.style);
1827
- const c = vn(t, n, e.offsetReferenceSelector);
1828
- return c.setUser(u), {
1826
+ console.debug(`Using ${h} renderer`), e.style && b.setStyle(e.style);
1827
+ const l = vn(t, n, e.offsetReferenceSelector);
1828
+ return l.setUser(u), {
1829
1829
  ...ze(n, s, e.adapter),
1830
1830
  destroy: () => {
1831
- v.destroy(), c.destroy(), s.destroy();
1831
+ b.destroy(), l.destroy(), s.destroy();
1832
1832
  },
1833
1833
  element: t,
1834
1834
  getUser: () => u,
1835
- setFilter: (A) => v.setFilter(A),
1836
- setStyle: (A) => v.setStyle(A),
1835
+ setFilter: (A) => b.setFilter(A),
1836
+ setStyle: (A) => b.setStyle(A),
1837
1837
  setUser: (A) => {
1838
- u = A, c.setUser(A);
1838
+ u = A, l.setUser(A);
1839
1839
  },
1840
1840
  setSelected: (A) => {
1841
1841
  A ? o.setSelected(A) : o.clear();
1842
1842
  },
1843
1843
  setPresenceProvider: (A) => {
1844
- A && (v.setPainter(mn(t, A, e.presence)), A.on("selectionChange", () => v.redraw()));
1844
+ A && (b.setPainter(mn(t, A, e.presence)), A.on("selectionChange", () => b.redraw()));
1845
1845
  },
1846
- setVisible: (A) => v.setVisible(A),
1846
+ setVisible: (A) => b.setVisible(A),
1847
1847
  on: a.on,
1848
1848
  off: a.off,
1849
1849
  scrollIntoView: bn(t, r),
@@ -1852,9 +1852,9 @@ const fn = (t, e) => {
1852
1852
  };
1853
1853
  export {
1854
1854
  dt as DEFAULT_SELECTED_STYLE,
1855
- D as DEFAULT_STYLE,
1855
+ H as DEFAULT_STYLE,
1856
1856
  Nt as NOT_ANNOTATABLE_CLASS,
1857
- H as NOT_ANNOTATABLE_SELECTOR,
1857
+ Y as NOT_ANNOTATABLE_SELECTOR,
1858
1858
  N as Origin,
1859
1859
  xn as W3CTextFormat,
1860
1860
  ae as createCanvasRenderer,
@@ -1867,7 +1867,7 @@ export {
1867
1867
  wn as getAnnotatableFragment,
1868
1868
  yn as getClientRectsPonyfill,
1869
1869
  Kt as getQuoteContext,
1870
- ct as getRangeAnnotatableContents,
1870
+ lt as getRangeAnnotatableContents,
1871
1871
  k as isRevived,
1872
1872
  Zt as mergeClientRects,
1873
1873
  zt as paint,