@soomo/text-annotator 3.1.0-staging.14 → 3.1.0-staging.16

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,28 +1,28 @@
1
- const ae = "not-annotatable", Z = `.${ae}`, nt = (t) => {
1
+ const de = "not-annotatable", et = `.${de}`, st = (t) => {
2
2
  var n;
3
- return !!(t instanceof HTMLElement ? t.closest(Z) : (n = t.parentElement) == null ? void 0 : n.closest(Z));
4
- }, Re = (t) => {
3
+ return !!(t instanceof HTMLElement ? t.closest(et) : (n = t.parentElement) == null ? void 0 : n.closest(et));
4
+ }, Me = (t) => {
5
5
  const e = t.commonAncestorContainer;
6
- return !nt(e);
7
- }, Me = (t) => t.addEventListener("click", (e) => {
6
+ return !st(e);
7
+ }, Be = (t) => t.addEventListener("click", (e) => {
8
8
  // Allow clicks within not-annotatable elements
9
- !e.target.closest(Z) && !e.target.closest("a") && e.preventDefault();
10
- }), Be = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), ke = (t) => {
9
+ !e.target.closest(et) && !e.target.closest("a") && e.preventDefault();
10
+ }), ke = /mac/i.test(navigator.userAgentData ? navigator.userAgentData.platform : navigator.platform), Ie = (t) => {
11
11
  !t.hasAttribute("tabindex") && t.tabIndex < 0 && t.setAttribute("tabindex", "-1"), t.classList.add("no-focus-outline");
12
- }, Ie = function* (t) {
12
+ }, Ne = function* (t) {
13
13
  const e = document.createNodeIterator(
14
14
  t.commonAncestorContainer,
15
15
  NodeFilter.SHOW_ELEMENT,
16
- (o) => o instanceof HTMLElement && o.classList.contains(ae) && !o.parentElement.closest(Z) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
16
+ (o) => o instanceof HTMLElement && o.classList.contains(de) && !o.parentElement.closest(et) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
17
17
  );
18
18
  let n;
19
19
  for (; n = e.nextNode(); )
20
20
  n instanceof HTMLElement && (yield n);
21
- }, Ne = (t) => {
22
- if (!Re(t)) return [];
21
+ }, _e = (t) => {
22
+ if (!Me(t)) return [];
23
23
  const e = [];
24
24
  let n = null;
25
- for (const o of Ie(t)) {
25
+ for (const o of Ne(t)) {
26
26
  let i;
27
27
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
28
28
  }
@@ -31,20 +31,20 @@ const ae = "not-annotatable", Z = `.${ae}`, nt = (t) => {
31
31
  o.setStartAfter(n), o.collapsed || e.push(o);
32
32
  }
33
33
  return e.length > 0 ? e : [t];
34
- }, _t = (t) => {
34
+ }, Vt = (t) => {
35
35
  const e = t.cloneContents();
36
- return e.querySelectorAll(Z).forEach((n) => n.remove()), e;
37
- }, _e = (t, e, n = 10, o) => {
36
+ return e.querySelectorAll(et).forEach((n) => n.remove()), e;
37
+ }, Ue = (t, e, n = 10, o) => {
38
38
  const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
39
39
  s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
40
- const r = _t(s).textContent, a = document.createRange();
40
+ const r = Vt(s).textContent, a = document.createRange();
41
41
  a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
42
- const l = _t(a).textContent;
42
+ const l = Vt(a).textContent;
43
43
  return {
44
44
  prefix: r.substring(r.length - n),
45
45
  suffix: l.substring(0, n)
46
46
  };
47
- }, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), Ue = /^\s*$/, De = (t) => Ue.test(t.toString()), Ve = (t, e) => {
47
+ }, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), De = /^\s*$/, Ve = (t) => De.test(t.toString()), Ye = (t, e) => {
48
48
  const n = (s) => Math.round(s * 10) / 10, o = {
49
49
  top: n(t.top),
50
50
  bottom: n(t.bottom),
@@ -71,12 +71,12 @@ const ae = "not-annotatable", Z = `.${ae}`, nt = (t) => {
71
71
  }, Ke = (t, e) => {
72
72
  const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), i = Math.min(t.top, e.top), s = Math.max(t.bottom, e.bottom);
73
73
  return new DOMRect(n, i, o - n, s - i);
74
- }, Ye = (t) => t.reduce((e, n) => {
74
+ }, Xe = (t) => t.reduce((e, n) => {
75
75
  if (n.width === 0 || n.height === 0)
76
76
  return e;
77
77
  let o = [...e], i = !1;
78
78
  for (const s of e) {
79
- const r = Ve(n, s);
79
+ const r = Ye(n, s);
80
80
  if (r === "inline-adjacent") {
81
81
  o = o.map((a) => a === s ? Ke(n, s) : a), i = !0;
82
82
  break;
@@ -92,73 +92,73 @@ const ae = "not-annotatable", Z = `.${ae}`, nt = (t) => {
92
92
  }
93
93
  }
94
94
  return i ? o : [...o, n];
95
- }, []), Ro = (t) => ({
95
+ }, []), Mo = (t) => ({
96
96
  length: t.length,
97
97
  item: (e) => t[e],
98
98
  [Symbol.iterator]: function* () {
99
99
  for (let e = 0; e < this.length; e++)
100
100
  yield this.item(e);
101
101
  }
102
- }), Xe = (t, e, n) => {
102
+ }), Pe = (t, e, n) => {
103
103
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
104
104
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
105
- const s = _t(o).textContent, r = t.toString(), a = s.length || 0, l = a + r.length;
105
+ const s = Vt(o).textContent, r = t.toString(), a = s.length || 0, l = a + r.length;
106
106
  return n ? { quote: r, start: a, end: l, range: t, offsetReference: i } : { quote: r, start: a, end: l, range: t };
107
- }, ce = (t, e) => {
108
- var f, d;
107
+ }, ue = (t, e) => {
108
+ var p, d;
109
109
  const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
110
110
  e,
111
111
  NodeFilter.SHOW_TEXT,
112
- (m) => {
113
- var p;
114
- return (p = m.parentElement) != null && p.closest(Z) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
112
+ (h) => {
113
+ var g;
114
+ return (g = h.parentElement) != null && g.closest(et) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
115
115
  }
116
116
  );
117
117
  let r = 0;
118
118
  const a = document.createRange();
119
119
  let l = s.nextNode();
120
120
  l === null && console.error("Could not revive annotation target. Content missing.");
121
- let c = !i;
121
+ let f = !i;
122
122
  for (; l !== null; ) {
123
- if (c || (c = i == null ? void 0 : i.contains(l)), c) {
124
- const m = ((f = l.textContent) == null ? void 0 : f.length) || 0;
125
- if (r + m > n) {
123
+ if (f || (f = i == null ? void 0 : i.contains(l)), f) {
124
+ const h = ((p = l.textContent) == null ? void 0 : p.length) || 0;
125
+ if (r + h > n) {
126
126
  a.setStart(l, n - r);
127
127
  break;
128
128
  }
129
- r += m;
129
+ r += h;
130
130
  }
131
131
  l = s.nextNode();
132
132
  }
133
133
  for (; l !== null; ) {
134
- const m = ((d = l.textContent) == null ? void 0 : d.length) || 0;
135
- if (r + m >= o) {
134
+ const h = ((d = l.textContent) == null ? void 0 : d.length) || 0;
135
+ if (r + h >= o) {
136
136
  a.setEnd(l, o - r);
137
137
  break;
138
138
  }
139
- r += m, l = s.nextNode();
139
+ r += h, l = s.nextNode();
140
140
  }
141
141
  return {
142
142
  ...t,
143
143
  range: a
144
144
  };
145
- }, bt = (t, e) => F(t.selector) ? t : {
145
+ }, At = (t, e) => F(t.selector) ? t : {
146
146
  ...t,
147
- selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ce(n, e))
148
- }, vt = (t, e) => F(t.target.selector) ? t : { ...t, target: bt(t.target, e) }, le = (t, e) => {
147
+ selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ue(n, e))
148
+ }, Et = (t, e) => F(t.target.selector) ? t : { ...t, target: At(t.target, e) }, fe = (t, e) => {
149
149
  if (t.isEqualNode(e))
150
150
  return !0;
151
151
  for (let n of t.childNodes)
152
- if (le(n, e))
152
+ if (fe(n, e))
153
153
  return !0;
154
154
  return !1;
155
- }, Pe = (t, e) => {
156
- const n = t.cloneContents();
157
- return le(n, e);
158
155
  }, $e = (t, e) => {
156
+ const n = t.cloneContents();
157
+ return fe(n, e);
158
+ }, je = (t, e) => {
159
159
  const n = t.cloneRange(), o = e.contains(n.startContainer), i = e.contains(n.endContainer);
160
- return !o && !i && !Pe(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
161
- }, At = (t) => ({
160
+ return !o && !i && !$e(n, e) ? (n.collapse(), n) : (o || n.setStart(e, 0), i || n.setEnd(e, e.childNodes.length), n);
161
+ }, St = (t) => ({
162
162
  ...t,
163
163
  type: t.type,
164
164
  x: t.x,
@@ -184,7 +184,7 @@ const ae = "not-annotatable", Z = `.${ae}`, nt = (t) => {
184
184
  pointerId: t.pointerId,
185
185
  pointerType: t.pointerType,
186
186
  timeStamp: t.timeStamp
187
- }), ut = (t) => ({
187
+ }), pt = (t) => ({
188
188
  ...t,
189
189
  type: t.type,
190
190
  key: t.key,
@@ -200,169 +200,169 @@ const ae = "not-annotatable", Z = `.${ae}`, nt = (t) => {
200
200
  defaultPrevented: t.defaultPrevented,
201
201
  detail: t.detail,
202
202
  timeStamp: t.timeStamp
203
- }), je = (t, e) => {
203
+ }), He = (t, e) => {
204
204
  const { left: n, top: o, right: i, bottom: s } = t;
205
205
  return new DOMRect(n - e.left, o - e.top, i - n, s - o);
206
- }, Mo = (t, e) => {
206
+ }, Bo = (t, e) => {
207
207
  const { left: n, top: o, right: i, bottom: s } = t;
208
208
  return new DOMRect(n + e.left, o + e.top, i - n, s - o);
209
- }, de = (t) => {
209
+ }, he = (t) => {
210
210
  if (t === null)
211
211
  return document.scrollingElement;
212
212
  const { overflowY: e } = window.getComputedStyle(t);
213
- return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : de(t.parentElement);
214
- }, He = (t, e) => (n) => {
213
+ return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : he(t.parentElement);
214
+ }, ze = (t, e) => (n) => {
215
215
  const o = typeof n == "string" ? n : n.id, i = (r) => {
216
- const a = s.getBoundingClientRect(), l = s.clientHeight, c = s.clientWidth, f = r.selector[0].range.getBoundingClientRect(), { width: d, height: m } = e.getAnnotationBounds(o), p = f.top - a.top, w = f.left - a.left, b = s.parentElement ? s.scrollTop : 0, C = s.parentElement ? s.scrollLeft : 0, g = p + b - (l - m) / 2, u = w + C - (c - d) / 2;
217
- s.scroll({ top: g, left: u, behavior: "smooth" });
218
- }, s = de(t);
216
+ const a = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, p = r.selector[0].range.getBoundingClientRect(), { width: d, height: h } = e.getAnnotationBounds(o), g = p.top - a.top, b = p.left - a.left, A = s.parentElement ? s.scrollTop : 0, C = s.parentElement ? s.scrollLeft : 0, m = g + A - (l - h) / 2, c = b + C - (f - d) / 2;
217
+ s.scroll({ top: m, left: c, behavior: "smooth" });
218
+ }, s = he(t);
219
219
  if (s) {
220
220
  const r = e.getAnnotation(o), { range: a } = r.target.selector[0];
221
221
  if (a && !a.collapsed)
222
222
  return i(r.target), !0;
223
223
  {
224
- const l = bt(r.target, t), { range: c } = l.selector[0];
225
- if (c && !c.collapsed)
224
+ const l = At(r.target, t), { range: f } = l.selector[0];
225
+ if (f && !f.collapsed)
226
226
  return i(l), !0;
227
227
  }
228
228
  }
229
229
  return !1;
230
- }, W = {
230
+ }, q = {
231
231
  fill: "rgb(0, 128, 255)",
232
232
  fillOpacity: 0.18
233
- }, wt = {
233
+ }, xt = {
234
234
  fill: "rgb(0, 128, 255)",
235
235
  fillOpacity: 0.45
236
- }, ze = (t, e, n, o, i) => {
236
+ }, Fe = (t, e, n, o, i) => {
237
237
  var r, a;
238
- const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? wt : W) : n : (a = t.state) != null && a.selected ? wt : W;
238
+ const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((r = t.state) != null && r.selected ? xt : q) : n : (a = t.state) != null && a.selected ? xt : q;
239
239
  return o && o.paint(t, e) || s;
240
240
  };
241
- function Fe(t) {
241
+ function We(t) {
242
242
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
243
243
  }
244
- var Vt = { exports: {} };
245
- function ue(t, e = 100, n = {}) {
244
+ var Xt = { exports: {} };
245
+ function pe(t, e = 100, n = {}) {
246
246
  if (typeof t != "function")
247
247
  throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
248
248
  if (e < 0)
249
249
  throw new RangeError("`wait` must not be negative.");
250
250
  const { immediate: o } = typeof n == "boolean" ? { immediate: n } : n;
251
251
  let i, s, r, a, l;
252
- function c() {
253
- const m = i, p = s;
254
- return i = void 0, s = void 0, l = t.apply(m, p), l;
255
- }
256
252
  function f() {
257
- const m = Date.now() - a;
258
- m < e && m >= 0 ? r = setTimeout(f, e - m) : (r = void 0, o || (l = c()));
253
+ const h = i, g = s;
254
+ return i = void 0, s = void 0, l = t.apply(h, g), l;
255
+ }
256
+ function p() {
257
+ const h = Date.now() - a;
258
+ h < e && h >= 0 ? r = setTimeout(p, e - h) : (r = void 0, o || (l = f()));
259
259
  }
260
- const d = function(...m) {
260
+ const d = function(...h) {
261
261
  if (i && this !== i && Object.getPrototypeOf(this) === Object.getPrototypeOf(i))
262
262
  throw new Error("Debounced method called with different contexts of the same prototype.");
263
- i = this, s = m, a = Date.now();
264
- const p = o && !r;
265
- return r || (r = setTimeout(f, e)), p && (l = c()), l;
263
+ i = this, s = h, a = Date.now();
264
+ const g = o && !r;
265
+ return r || (r = setTimeout(p, e)), g && (l = f()), l;
266
266
  };
267
267
  return d.clear = () => {
268
268
  r && (clearTimeout(r), r = void 0);
269
269
  }, d.flush = () => {
270
270
  r && d.trigger();
271
271
  }, d.trigger = () => {
272
- l = c(), d.clear();
272
+ l = f(), d.clear();
273
273
  }, d;
274
274
  }
275
- Vt.exports.debounce = ue;
276
- Vt.exports = ue;
277
- var We = Vt.exports;
278
- const Kt = /* @__PURE__ */ Fe(We), qe = (t) => {
275
+ Xt.exports.debounce = pe;
276
+ Xt.exports = pe;
277
+ var qe = Xt.exports;
278
+ const Pt = /* @__PURE__ */ We(qe), Ge = (t) => {
279
279
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, r = -e, a = o - n, l = i - e;
280
280
  return { top: e, left: n, minX: s, minY: r, maxX: a, maxY: l };
281
- }, Ge = (t) => {
281
+ }, Qe = (t) => {
282
282
  let e = /* @__PURE__ */ new Set();
283
283
  return (o) => {
284
284
  const i = o.map((s) => s.id);
285
285
  (e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
286
286
  };
287
- }, Yt = (t, e, n, o) => {
287
+ }, $t = (t, e, n, o) => {
288
288
  const { store: i, selection: s, hover: r } = e;
289
- let a, l, c;
290
- const f = Ge(n), d = (T) => {
291
- const { x, y: h } = t.getBoundingClientRect(), v = i.getAt(T.clientX - x, T.clientY - h, l);
289
+ let a, l, f;
290
+ const p = Qe(n), d = (T) => {
291
+ const { x: M, y: w } = t.getBoundingClientRect(), v = i.getAt(T.clientX - M, T.clientY - w, !1, l);
292
292
  v ? r.current !== v.id && (t.classList.add("hovered"), r.set(v.id)) : r.current && (t.classList.remove("hovered"), r.set(null));
293
293
  };
294
294
  t.addEventListener("pointermove", d);
295
- const m = (T = !1) => {
296
- c && c.clear();
297
- const x = qe(t), { minX: h, minY: v, maxX: A, maxY: L } = x, M = l ? i.getIntersecting(h, v, A, L).filter(({ annotation: Y }) => l(Y)) : i.getIntersecting(h, v, A, L), B = s.selected.map(({ id: Y }) => Y), K = M.map(({ annotation: Y, rects: dt }) => {
298
- const Oe = B.includes(Y.id), Te = Y.id === r.current;
299
- return { annotation: Y, rects: dt, state: { selected: Oe, hover: Te } };
295
+ const h = (T = !1) => {
296
+ f && f.clear();
297
+ const M = Ge(t), { minX: w, minY: v, maxX: u, maxY: E } = M, B = l ? i.getIntersecting(w, v, u, E).filter(({ annotation: _ }) => l(_)) : i.getIntersecting(w, v, u, E), R = s.selected.map(({ id: _ }) => _), U = B.map(({ annotation: _, rects: ht }) => {
298
+ const W = R.includes(_.id), G = _.id === r.current;
299
+ return { annotation: _, rects: ht, state: { selected: W, hover: G } };
300
300
  });
301
- o.redraw(K, x, a, c, T), setTimeout(() => f(M.map(({ annotation: Y }) => Y)), 1);
302
- }, p = (T) => {
303
- c = T, m();
304
- }, w = (T) => {
305
- a = T, m();
301
+ o.redraw(U, M, a, f, T), setTimeout(() => p(B.map(({ annotation: _ }) => _)), 1);
302
+ }, g = (T) => {
303
+ f = T, h();
306
304
  }, b = (T) => {
307
- l = T, m(!1);
308
- }, C = () => m();
305
+ a = T, h();
306
+ }, A = (T) => {
307
+ l = T, h(!1);
308
+ }, C = () => h();
309
309
  i.observe(C);
310
- const g = s.subscribe(() => m()), u = () => m(!0);
311
- document.addEventListener("scroll", u, { capture: !0, passive: !0 });
312
- const y = Kt(() => {
313
- i.recalculatePositions(), c == null || c.reset(), m();
310
+ const m = s.subscribe(() => h()), c = () => h(!0);
311
+ document.addEventListener("scroll", c, { capture: !0, passive: !0 });
312
+ const y = Pt(() => {
313
+ i.recalculatePositions(), f == null || f.reset(), h();
314
314
  }, 10);
315
315
  window.addEventListener("resize", y);
316
316
  const S = new ResizeObserver(y);
317
317
  S.observe(t);
318
- const E = { attributes: !0, childList: !0, subtree: !0 }, O = new MutationObserver((T) => {
319
- T.every((h) => h.target === t || t.contains(h.target)) || m(!0);
318
+ const x = { attributes: !0, childList: !0, subtree: !0 }, L = new MutationObserver((T) => {
319
+ T.every((w) => w.target === t || t.contains(w.target)) || h(!0);
320
320
  });
321
- return O.observe(document.body, E), {
321
+ return L.observe(document.body, x), {
322
322
  destroy: () => {
323
- t.removeEventListener("pointermove", d), o.destroy(), i.unobserve(C), g(), document.removeEventListener("scroll", u), y.clear(), window.removeEventListener("resize", y), S.disconnect(), O.disconnect();
323
+ t.removeEventListener("pointermove", d), o.destroy(), i.unobserve(C), m(), document.removeEventListener("scroll", c), y.clear(), window.removeEventListener("resize", y), S.disconnect(), L.disconnect();
324
324
  },
325
- redraw: m,
326
- setStyle: w,
327
- setFilter: b,
328
- setPainter: p,
325
+ redraw: h,
326
+ setStyle: b,
327
+ setFilter: A,
328
+ setPainter: g,
329
329
  setVisible: o.setVisible
330
330
  };
331
- }, Qe = () => {
331
+ }, Je = () => {
332
332
  const t = document.createElement("canvas");
333
333
  return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
334
- }, Je = (t, e) => {
334
+ }, Ze = (t, e) => {
335
335
  t.width = window.innerWidth, t.height = window.innerHeight;
336
- }, Ze = (t) => {
336
+ }, tn = (t) => {
337
337
  t.classList.add("r6o-annotatable");
338
- const e = Qe(), n = e.getContext("2d");
338
+ const e = Je(), n = e.getContext("2d");
339
339
  document.body.appendChild(e);
340
- const o = (a, l, c, f) => requestAnimationFrame(() => {
341
- const { width: d, height: m } = e;
342
- n.clearRect(-0.5, -0.5, d + 1, m + 1), f && f.clear();
343
- const { top: p, left: w } = l;
344
- [...a].sort((C, g) => {
345
- const { annotation: { target: { created: u } } } = C, { annotation: { target: { created: y } } } = g;
346
- return u.getTime() - y.getTime();
340
+ const o = (a, l, f, p) => requestAnimationFrame(() => {
341
+ const { width: d, height: h } = e;
342
+ n.clearRect(-0.5, -0.5, d + 1, h + 1), p && p.clear();
343
+ const { top: g, left: b } = l;
344
+ [...a].sort((C, m) => {
345
+ const { annotation: { target: { created: c } } } = C, { annotation: { target: { created: y } } } = m;
346
+ return c.getTime() - y.getTime();
347
347
  }).forEach((C) => {
348
348
  var S;
349
- const g = c ? typeof c == "function" ? c(C.annotation, C.state) : c : (S = C.state) != null && S.selected ? wt : W, u = f && f.paint(C, l) || g, y = C.rects.map(({ x: E, y: O, width: R, height: T }) => ({
350
- x: E + w,
351
- y: O + p,
352
- width: R,
349
+ const m = f ? typeof f == "function" ? f(C.annotation, C.state) : f : (S = C.state) != null && S.selected ? xt : q, c = p && p.paint(C, l) || m, y = C.rects.map(({ x, y: L, width: O, height: T }) => ({
350
+ x: x + b,
351
+ y: L + g,
352
+ width: O,
353
353
  height: T
354
354
  }));
355
- if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, y.forEach(
356
- ({ x: E, y: O, width: R, height: T }) => n.fillRect(E, O, R, T)
357
- ), u.underlineColor) {
358
- n.globalAlpha = 1, n.strokeStyle = u.underlineColor, n.lineWidth = u.underlineThickness ?? 1;
359
- const E = u.underlineOffset ?? 0;
360
- y.forEach(({ x: O, y: R, width: T, height: x }) => {
361
- n.beginPath(), n.moveTo(O, R + x + E), n.lineTo(O + T, R + x + E), n.stroke();
355
+ if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, y.forEach(
356
+ ({ x, y: L, width: O, height: T }) => n.fillRect(x, L, O, T)
357
+ ), c.underlineColor) {
358
+ n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
359
+ const x = c.underlineOffset ?? 0;
360
+ y.forEach(({ x: L, y: O, width: T, height: M }) => {
361
+ n.beginPath(), n.moveTo(L, O + M + x), n.lineTo(L + T, O + M + x), n.stroke();
362
362
  });
363
363
  }
364
364
  });
365
- }), i = Kt(() => Je(e), 10);
365
+ }), i = Pt(() => Ze(e), 10);
366
366
  return window.addEventListener("resize", i), {
367
367
  destroy: () => {
368
368
  e.remove(), i.clear(), window.removeEventListener("resize", i);
@@ -372,144 +372,144 @@ const Kt = /* @__PURE__ */ Fe(We), qe = (t) => {
372
372
  },
373
373
  redraw: o
374
374
  };
375
- }, tn = (t, e, n) => Yt(t, e, n, Ze(t));
376
- var en = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
375
+ }, en = (t, e, n) => $t(t, e, n, tn(t));
376
+ var nn = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, H = function(t) {
377
377
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
378
- }, _ = function(t, e, n) {
378
+ }, D = function(t, e, n) {
379
379
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
380
380
  }, X = function(t, e, n) {
381
381
  return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
382
- }, fe = function(t) {
382
+ }, ge = function(t) {
383
383
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
384
- }, $t = function(t) {
384
+ }, zt = function(t) {
385
385
  return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
386
- }, xt = function(t) {
387
- return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
388
- }, nn = /^#([0-9a-f]{3,8})$/i, ft = function(t) {
386
+ }, Ct = function(t) {
387
+ return { r: D(t.r), g: D(t.g), b: D(t.b), a: D(t.a, 3) };
388
+ }, on = /^#([0-9a-f]{3,8})$/i, gt = function(t) {
389
389
  var e = t.toString(16);
390
390
  return e.length < 2 ? "0" + e : e;
391
- }, he = function(t) {
391
+ }, me = function(t) {
392
392
  var e = t.r, n = t.g, o = t.b, i = t.a, s = Math.max(e, n, o), r = s - Math.min(e, n, o), a = r ? s === e ? (n - o) / r : s === n ? 2 + (o - e) / r : 4 + (e - n) / r : 0;
393
393
  return { h: 60 * (a < 0 ? a + 6 : a), s: s ? r / s * 100 : 0, v: s / 255 * 100, a: i };
394
- }, pe = function(t) {
394
+ }, ye = function(t) {
395
395
  var e = t.h, n = t.s, o = t.v, i = t.a;
396
396
  e = e / 360 * 6, n /= 100, o /= 100;
397
- var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), c = s % 6;
398
- return { r: 255 * [o, a, r, r, l, o][c], g: 255 * [l, o, o, a, r, r][c], b: 255 * [r, r, l, o, o, a][c], a: i };
399
- }, jt = function(t) {
400
- return { h: fe(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
401
- }, Ht = function(t) {
402
- return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
403
- }, zt = function(t) {
404
- return pe((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
397
+ var s = Math.floor(e), r = o * (1 - n), a = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), f = s % 6;
398
+ return { r: 255 * [o, a, r, r, l, o][f], g: 255 * [l, o, o, a, r, r][f], b: 255 * [r, r, l, o, o, a][f], a: i };
399
+ }, Ft = function(t) {
400
+ return { h: ge(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
401
+ }, Wt = function(t) {
402
+ return { h: D(t.h), s: D(t.s), l: D(t.l), a: D(t.a, 3) };
403
+ }, qt = function(t) {
404
+ return ye((n = (e = t).s, { h: e.h, s: (n *= ((o = e.l) < 50 ? o : 100 - o) / 100) > 0 ? 2 * n / (o + n) * 100 : 0, v: o + n, a: e.a }));
405
405
  var e, n, o;
406
- }, st = function(t) {
407
- return { h: (e = he(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 };
406
+ }, ct = function(t) {
407
+ return { h: (e = me(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 };
408
408
  var e, n, o, i;
409
- }, on = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ft = { string: [[function(t) {
410
- var e = nn.exec(t);
411
- 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 ? _(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 ? _(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
409
+ }, sn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, rn = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, an = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, cn = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Gt = { string: [[function(t) {
410
+ var e = on.exec(t);
411
+ 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 ? D(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 ? D(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
412
412
  }, "hex"], [function(t) {
413
- var e = rn.exec(t) || an.exec(t);
414
- return e ? e[2] !== e[4] || e[4] !== e[6] ? null : $t({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
413
+ var e = an.exec(t) || cn.exec(t);
414
+ return e ? e[2] !== e[4] || e[4] !== e[6] ? null : zt({ r: Number(e[1]) / (e[2] ? 100 / 255 : 1), g: Number(e[3]) / (e[4] ? 100 / 255 : 1), b: Number(e[5]) / (e[6] ? 100 / 255 : 1), a: e[7] === void 0 ? 1 : Number(e[7]) / (e[8] ? 100 : 1) }) : null;
415
415
  }, "rgb"], [function(t) {
416
- var e = on.exec(t) || sn.exec(t);
416
+ var e = sn.exec(t) || rn.exec(t);
417
417
  if (!e) return null;
418
- var n, o, i = jt({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (en[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
419
- return zt(i);
418
+ var n, o, i = Ft({ h: (n = e[1], o = e[2], o === void 0 && (o = "deg"), Number(n) * (nn[o] || 1)), s: Number(e[3]), l: Number(e[4]), a: e[5] === void 0 ? 1 : Number(e[5]) / (e[6] ? 100 : 1) });
419
+ return qt(i);
420
420
  }, "hsl"]], object: [[function(t) {
421
421
  var e = t.r, n = t.g, o = t.b, i = t.a, s = i === void 0 ? 1 : i;
422
- return H(e) && H(n) && H(o) ? $t({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
422
+ return H(e) && H(n) && H(o) ? zt({ r: Number(e), g: Number(n), b: Number(o), a: Number(s) }) : null;
423
423
  }, "rgb"], [function(t) {
424
424
  var e = t.h, n = t.s, o = t.l, i = t.a, s = i === void 0 ? 1 : i;
425
425
  if (!H(e) || !H(n) || !H(o)) return null;
426
- var r = jt({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
427
- return zt(r);
426
+ var r = Ft({ h: Number(e), s: Number(n), l: Number(o), a: Number(s) });
427
+ return qt(r);
428
428
  }, "hsl"], [function(t) {
429
429
  var e = t.h, n = t.s, o = t.v, i = t.a, s = i === void 0 ? 1 : i;
430
430
  if (!H(e) || !H(n) || !H(o)) return null;
431
431
  var r = function(a) {
432
- return { h: fe(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
432
+ return { h: ge(a.h), s: X(a.s, 0, 100), v: X(a.v, 0, 100), a: X(a.a) };
433
433
  }({ h: Number(e), s: Number(n), v: Number(o), a: Number(s) });
434
- return pe(r);
435
- }, "hsv"]] }, Wt = function(t, e) {
434
+ return ye(r);
435
+ }, "hsv"]] }, Qt = function(t, e) {
436
436
  for (var n = 0; n < e.length; n++) {
437
437
  var o = e[n][0](t);
438
438
  if (o) return [o, e[n][1]];
439
439
  }
440
440
  return [null, void 0];
441
- }, cn = function(t) {
442
- return typeof t == "string" ? Wt(t.trim(), Ft.string) : typeof t == "object" && t !== null ? Wt(t, Ft.object) : [null, void 0];
443
- }, Et = function(t, e) {
444
- var n = st(t);
441
+ }, ln = function(t) {
442
+ return typeof t == "string" ? Qt(t.trim(), Gt.string) : typeof t == "object" && t !== null ? Qt(t, Gt.object) : [null, void 0];
443
+ }, Lt = function(t, e) {
444
+ var n = ct(t);
445
445
  return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
446
- }, St = function(t) {
446
+ }, Tt = function(t) {
447
447
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
448
- }, qt = function(t, e) {
449
- var n = st(t);
448
+ }, Jt = function(t, e) {
449
+ var n = ct(t);
450
450
  return { h: n.h, s: n.s, l: X(n.l + 100 * e, 0, 100), a: n.a };
451
- }, Gt = function() {
451
+ }, Zt = function() {
452
452
  function t(e) {
453
- this.parsed = cn(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
453
+ this.parsed = ln(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
454
454
  }
455
455
  return t.prototype.isValid = function() {
456
456
  return this.parsed !== null;
457
457
  }, t.prototype.brightness = function() {
458
- return _(St(this.rgba), 2);
458
+ return D(Tt(this.rgba), 2);
459
459
  }, t.prototype.isDark = function() {
460
- return St(this.rgba) < 0.5;
460
+ return Tt(this.rgba) < 0.5;
461
461
  }, t.prototype.isLight = function() {
462
- return St(this.rgba) >= 0.5;
462
+ return Tt(this.rgba) >= 0.5;
463
463
  }, t.prototype.toHex = function() {
464
- return e = xt(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? ft(_(255 * s)) : "", "#" + ft(n) + ft(o) + ft(i) + r;
464
+ return e = Ct(this.rgba), n = e.r, o = e.g, i = e.b, r = (s = e.a) < 1 ? gt(D(255 * s)) : "", "#" + gt(n) + gt(o) + gt(i) + r;
465
465
  var e, n, o, i, s, r;
466
466
  }, t.prototype.toRgb = function() {
467
- return xt(this.rgba);
467
+ return Ct(this.rgba);
468
468
  }, t.prototype.toRgbString = function() {
469
- return e = xt(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
469
+ return e = Ct(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
470
470
  var e, n, o, i, s;
471
471
  }, t.prototype.toHsl = function() {
472
- return Ht(st(this.rgba));
472
+ return Wt(ct(this.rgba));
473
473
  }, t.prototype.toHslString = function() {
474
- return e = Ht(st(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
474
+ return e = Wt(ct(this.rgba)), n = e.h, o = e.s, i = e.l, (s = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + s + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
475
475
  var e, n, o, i, s;
476
476
  }, t.prototype.toHsv = function() {
477
- return e = he(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
477
+ return e = me(this.rgba), { h: D(e.h), s: D(e.s), v: D(e.v), a: D(e.a, 3) };
478
478
  var e;
479
479
  }, t.prototype.invert = function() {
480
480
  return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
481
481
  var e;
482
482
  }, t.prototype.saturate = function(e) {
483
- return e === void 0 && (e = 0.1), $(Et(this.rgba, e));
483
+ return e === void 0 && (e = 0.1), $(Lt(this.rgba, e));
484
484
  }, t.prototype.desaturate = function(e) {
485
- return e === void 0 && (e = 0.1), $(Et(this.rgba, -e));
485
+ return e === void 0 && (e = 0.1), $(Lt(this.rgba, -e));
486
486
  }, t.prototype.grayscale = function() {
487
- return $(Et(this.rgba, -1));
487
+ return $(Lt(this.rgba, -1));
488
488
  }, t.prototype.lighten = function(e) {
489
- return e === void 0 && (e = 0.1), $(qt(this.rgba, e));
489
+ return e === void 0 && (e = 0.1), $(Jt(this.rgba, e));
490
490
  }, t.prototype.darken = function(e) {
491
- return e === void 0 && (e = 0.1), $(qt(this.rgba, -e));
491
+ return e === void 0 && (e = 0.1), $(Jt(this.rgba, -e));
492
492
  }, t.prototype.rotate = function(e) {
493
493
  return e === void 0 && (e = 15), this.hue(this.hue() + e);
494
494
  }, t.prototype.alpha = function(e) {
495
- return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
495
+ return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : D(this.rgba.a, 3);
496
496
  var n;
497
497
  }, t.prototype.hue = function(e) {
498
- var n = st(this.rgba);
499
- return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
498
+ var n = ct(this.rgba);
499
+ return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : D(n.h);
500
500
  }, t.prototype.isEqual = function(e) {
501
501
  return this.toHex() === $(e).toHex();
502
502
  }, t;
503
503
  }(), $ = function(t) {
504
- return t instanceof Gt ? t : new Gt(t);
504
+ return t instanceof Zt ? t : new Zt(t);
505
505
  };
506
- const ln = (t) => [
507
- `background-color:${$((t == null ? void 0 : t.fill) || W.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? W.fillOpacity : t.fillOpacity).toHex()}`,
506
+ const dn = (t) => [
507
+ `background-color:${$((t == null ? void 0 : t.fill) || q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? q.fillOpacity : t.fillOpacity).toHex()}`,
508
508
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
509
509
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
510
510
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
511
511
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
512
- ].filter(Boolean).join(";"), dn = () => {
512
+ ].filter(Boolean).join(";"), un = () => {
513
513
  const t = document.createElement("style");
514
514
  document.getElementsByTagName("head")[0].appendChild(t);
515
515
  let e = /* @__PURE__ */ new Set();
@@ -522,23 +522,23 @@ const ln = (t) => [
522
522
  },
523
523
  redraw: (s, r, a, l) => {
524
524
  l && l.clear();
525
- const c = new Set(s.map((d) => d.annotation.id));
526
- Array.from(e).filter((d) => !c.has(d));
527
- const f = s.map((d) => {
528
- var w;
529
- const m = a ? typeof a == "function" ? a(d.annotation, d.state) : a : (w = d.state) != null && w.selected ? wt : W, p = l && l.paint(d, r) || m;
530
- return `::highlight(_${d.annotation.id}) { ${ln(p)} }`;
525
+ const f = new Set(s.map((d) => d.annotation.id));
526
+ Array.from(e).filter((d) => !f.has(d));
527
+ const p = s.map((d) => {
528
+ var b;
529
+ const h = a ? typeof a == "function" ? a(d.annotation, d.state) : a : (b = d.state) != null && b.selected ? xt : q, g = l && l.paint(d, r) || h;
530
+ return `::highlight(_${d.annotation.id}) { ${dn(g)} }`;
531
531
  });
532
- t.innerHTML = f.join(`
532
+ t.innerHTML = p.join(`
533
533
  `), CSS.highlights.clear(), s.forEach(({ annotation: d }) => {
534
- const m = d.target.selector.map((w) => w.range), p = new Highlight(...m);
535
- CSS.highlights.set(`_${d.id}`, p);
536
- }), e = c;
534
+ const h = d.target.selector.map((b) => b.range), g = new Highlight(...h);
535
+ CSS.highlights.set(`_${d.id}`, g);
536
+ }), e = f;
537
537
  }
538
538
  };
539
- }, un = (t, e, n) => Yt(t, e, n, dn());
540
- var Qt = Object.prototype.hasOwnProperty;
541
- function Ut(t, e) {
539
+ }, fn = (t, e, n) => $t(t, e, n, un());
540
+ var te = Object.prototype.hasOwnProperty;
541
+ function Yt(t, e) {
542
542
  var n, o;
543
543
  if (t === e) return !0;
544
544
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -546,22 +546,22 @@ function Ut(t, e) {
546
546
  if (n === RegExp) return t.toString() === e.toString();
547
547
  if (n === Array) {
548
548
  if ((o = t.length) === e.length)
549
- for (; o-- && Ut(t[o], e[o]); ) ;
549
+ for (; o-- && Yt(t[o], e[o]); ) ;
550
550
  return o === -1;
551
551
  }
552
552
  if (!n || typeof t == "object") {
553
553
  o = 0;
554
554
  for (n in t)
555
- if (Qt.call(t, n) && ++o && !Qt.call(e, n) || !(n in e) || !Ut(t[n], e[n])) return !1;
555
+ if (te.call(t, n) && ++o && !te.call(e, n) || !(n in e) || !Yt(t[n], e[n])) return !1;
556
556
  return Object.keys(e).length === o;
557
557
  }
558
558
  }
559
559
  return t !== t && e !== e;
560
560
  }
561
- const fn = (t, e) => {
561
+ const hn = (t, e) => {
562
562
  const n = (s, r) => s.x <= r.x + r.width && s.x + s.width >= r.x && s.y <= r.y + r.height && s.y + s.height >= r.y, o = (s) => s.rects.reduce((r, a) => r + a.width, 0), i = e.filter(({ rects: s }) => s.some((r) => n(t, r)));
563
563
  return i.sort((s, r) => o(r) - o(s)), i.findIndex((s) => s.rects.includes(t));
564
- }, hn = (t) => {
564
+ }, pn = (t) => {
565
565
  t.classList.add("r6o-annotatable");
566
566
  const e = document.createElement("div");
567
567
  e.className = "r6o-span-highlight-layer", t.insertBefore(e, t.firstChild);
@@ -570,18 +570,18 @@ const fn = (t, e) => {
570
570
  destroy: () => {
571
571
  e.remove();
572
572
  },
573
- redraw: (r, a, l, c, f) => {
574
- const m = !(Ut(n, r) && f);
575
- if (!c && !m) return;
576
- m && (e.innerHTML = ""), [...r].sort((w, b) => {
577
- const { annotation: { target: { created: C } } } = w, { annotation: { target: { created: g } } } = b;
578
- return C && g ? C.getTime() - g.getTime() : 0;
579
- }).forEach((w) => {
580
- w.rects.map((b) => {
581
- const C = fn(b, r), g = ze(w, a, l, c, C);
582
- if (m) {
583
- const u = document.createElement("span");
584
- u.className = "r6o-annotation", u.dataset.annotation = w.annotation.id, u.style.left = `${b.x}px`, u.style.top = `${b.y}px`, u.style.width = `${b.width}px`, u.style.height = `${b.height}px`, u.style.backgroundColor = $((g == null ? void 0 : g.fill) || W.fill).alpha((g == null ? void 0 : g.fillOpacity) === void 0 ? W.fillOpacity : g.fillOpacity).toHex(), g.underlineStyle && (u.style.borderStyle = g.underlineStyle), g.underlineColor && (u.style.borderColor = g.underlineColor), g.underlineThickness && (u.style.borderBottomWidth = `${g.underlineThickness}px`), g.underlineOffset && (u.style.paddingBottom = `${g.underlineOffset}px`), e.appendChild(u);
573
+ redraw: (r, a, l, f, p) => {
574
+ const h = !(Yt(n, r) && p);
575
+ if (!f && !h) return;
576
+ h && (e.innerHTML = ""), [...r].sort((b, A) => {
577
+ const { annotation: { target: { created: C } } } = b, { annotation: { target: { created: m } } } = A;
578
+ return C && m ? C.getTime() - m.getTime() : 0;
579
+ }).forEach((b) => {
580
+ b.rects.map((A) => {
581
+ const C = hn(A, r), m = Fe(b, a, l, f, C);
582
+ if (h) {
583
+ const c = document.createElement("span");
584
+ c.className = "r6o-annotation", c.dataset.annotation = b.annotation.id, c.style.left = `${A.x}px`, c.style.top = `${A.y}px`, c.style.width = `${A.width}px`, c.style.height = `${A.height}px`, c.style.backgroundColor = $((m == null ? void 0 : m.fill) || q.fill).alpha((m == null ? void 0 : m.fillOpacity) === void 0 ? q.fillOpacity : m.fillOpacity).toHex(), m.underlineStyle && (c.style.borderStyle = m.underlineStyle), m.underlineColor && (c.style.borderColor = m.underlineColor), m.underlineThickness && (c.style.borderBottomWidth = `${m.underlineThickness}px`), m.underlineOffset && (c.style.paddingBottom = `${m.underlineOffset}px`), e.appendChild(c);
585
585
  }
586
586
  });
587
587
  }), n = r;
@@ -590,32 +590,32 @@ const fn = (t, e) => {
590
590
  r ? e.classList.remove("hidden") : e.classList.add("hidden");
591
591
  }
592
592
  };
593
- }, pn = (t, e, n) => Yt(t, e, n, hn(t)), U = [];
593
+ }, gn = (t, e, n) => $t(t, e, n, pn(t)), V = [];
594
594
  for (let t = 0; t < 256; ++t)
595
- U.push((t + 256).toString(16).slice(1));
596
- function gn(t, e = 0) {
597
- return (U[t[e + 0]] + U[t[e + 1]] + U[t[e + 2]] + U[t[e + 3]] + "-" + U[t[e + 4]] + U[t[e + 5]] + "-" + U[t[e + 6]] + U[t[e + 7]] + "-" + U[t[e + 8]] + U[t[e + 9]] + "-" + U[t[e + 10]] + U[t[e + 11]] + U[t[e + 12]] + U[t[e + 13]] + U[t[e + 14]] + U[t[e + 15]]).toLowerCase();
595
+ V.push((t + 256).toString(16).slice(1));
596
+ function mn(t, e = 0) {
597
+ return (V[t[e + 0]] + V[t[e + 1]] + V[t[e + 2]] + V[t[e + 3]] + "-" + V[t[e + 4]] + V[t[e + 5]] + "-" + V[t[e + 6]] + V[t[e + 7]] + "-" + V[t[e + 8]] + V[t[e + 9]] + "-" + V[t[e + 10]] + V[t[e + 11]] + V[t[e + 12]] + V[t[e + 13]] + V[t[e + 14]] + V[t[e + 15]]).toLowerCase();
598
598
  }
599
- let Ct;
600
- const mn = new Uint8Array(16);
601
- function yn() {
602
- if (!Ct) {
599
+ let Ot;
600
+ const yn = new Uint8Array(16);
601
+ function bn() {
602
+ if (!Ot) {
603
603
  if (typeof crypto > "u" || !crypto.getRandomValues)
604
604
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
605
- Ct = crypto.getRandomValues.bind(crypto);
605
+ Ot = crypto.getRandomValues.bind(crypto);
606
606
  }
607
- return Ct(mn);
607
+ return Ot(yn);
608
608
  }
609
- const bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Jt = { randomUUID: bn };
610
- function ge(t, e, n) {
611
- if (Jt.randomUUID && !e && !t)
612
- return Jt.randomUUID();
609
+ const wn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ee = { randomUUID: wn };
610
+ function be(t, e, n) {
611
+ if (ee.randomUUID && !e && !t)
612
+ return ee.randomUUID();
613
613
  t = t || {};
614
- const o = t.random || (t.rng || yn)();
615
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, gn(o);
614
+ const o = t.random || (t.rng || bn)();
615
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, mn(o);
616
616
  }
617
- var Zt = Object.prototype.hasOwnProperty;
618
- function q(t, e) {
617
+ var ne = Object.prototype.hasOwnProperty;
618
+ function Q(t, e) {
619
619
  var n, o;
620
620
  if (t === e) return !0;
621
621
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -623,52 +623,52 @@ function q(t, e) {
623
623
  if (n === RegExp) return t.toString() === e.toString();
624
624
  if (n === Array) {
625
625
  if ((o = t.length) === e.length)
626
- for (; o-- && q(t[o], e[o]); ) ;
626
+ for (; o-- && Q(t[o], e[o]); ) ;
627
627
  return o === -1;
628
628
  }
629
629
  if (!n || typeof t == "object") {
630
630
  o = 0;
631
631
  for (n in t)
632
- if (Zt.call(t, n) && ++o && !Zt.call(e, n) || !(n in e) || !q(t[n], e[n])) return !1;
632
+ if (ne.call(t, n) && ++o && !ne.call(e, n) || !(n in e) || !Q(t[n], e[n])) return !1;
633
633
  return Object.keys(e).length === o;
634
634
  }
635
635
  }
636
636
  return t !== t && e !== e;
637
637
  }
638
- function Lt() {
638
+ function Rt() {
639
639
  }
640
- function wn(t, e) {
640
+ function An(t, e) {
641
641
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
642
642
  }
643
- const G = [];
644
- function Xt(t, e = Lt) {
643
+ const J = [];
644
+ function jt(t, e = Rt) {
645
645
  let n;
646
646
  const o = /* @__PURE__ */ new Set();
647
647
  function i(a) {
648
- if (wn(t, a) && (t = a, n)) {
649
- const l = !G.length;
650
- for (const c of o)
651
- c[1](), G.push(c, t);
648
+ if (An(t, a) && (t = a, n)) {
649
+ const l = !J.length;
650
+ for (const f of o)
651
+ f[1](), J.push(f, t);
652
652
  if (l) {
653
- for (let c = 0; c < G.length; c += 2)
654
- G[c][0](G[c + 1]);
655
- G.length = 0;
653
+ for (let f = 0; f < J.length; f += 2)
654
+ J[f][0](J[f + 1]);
655
+ J.length = 0;
656
656
  }
657
657
  }
658
658
  }
659
659
  function s(a) {
660
660
  i(a(t));
661
661
  }
662
- function r(a, l = Lt) {
663
- const c = [a, l];
664
- return o.add(c), o.size === 1 && (n = e(i, s) || Lt), a(t), () => {
665
- o.delete(c), o.size === 0 && n && (n(), n = null);
662
+ function r(a, l = Rt) {
663
+ const f = [a, l];
664
+ return o.add(f), o.size === 1 && (n = e(i, s) || Rt), a(t), () => {
665
+ o.delete(f), o.size === 0 && n && (n(), n = null);
666
666
  };
667
667
  }
668
668
  return { set: i, update: s, subscribe: r };
669
669
  }
670
- const vn = (t) => {
671
- const { subscribe: e, set: n } = Xt();
670
+ const xn = (t) => {
671
+ const { subscribe: e, set: n } = jt();
672
672
  let o;
673
673
  return e((i) => o = i), t.observe(({ changes: i }) => {
674
674
  if (o) {
@@ -684,53 +684,57 @@ const vn = (t) => {
684
684
  set: n
685
685
  };
686
686
  };
687
- var An = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(An || {});
688
- const ht = { selected: [] }, xn = (t, e, n) => {
689
- const { subscribe: o, set: i } = Xt(ht);
690
- let s = e, r = ht;
691
- o((w) => r = w);
687
+ var vn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(vn || {});
688
+ const mt = { selected: [] }, En = (t, e, n) => {
689
+ const { subscribe: o, set: i } = jt(mt);
690
+ let s = e, r = mt;
691
+ o((b) => r = b);
692
692
  const a = () => {
693
- q(r, ht) || i(ht);
693
+ Q(r, mt) || i(mt);
694
694
  }, l = () => {
695
- var w;
696
- return ((w = r.selected) == null ? void 0 : w.length) === 0;
697
- }, c = (w) => {
695
+ var b;
696
+ return ((b = r.selected) == null ? void 0 : b.length) === 0;
697
+ }, f = (b) => {
698
698
  if (l())
699
699
  return !1;
700
- const b = typeof w == "string" ? w : w.id;
701
- return r.selected.some((C) => C.id === b);
702
- }, f = (w, b) => {
703
- const C = t.getAnnotation(w);
704
- if (!C) {
705
- console.warn("Invalid selection: " + w);
706
- return;
707
- }
708
- switch (te(C, s)) {
709
- case "EDIT":
710
- i({ selected: [{ id: w, editable: !0 }], event: b });
711
- break;
712
- case "SELECT":
713
- i({ selected: [{ id: w }], event: b });
714
- break;
715
- default:
716
- i({ selected: [], event: b });
700
+ const A = typeof b == "string" ? b : b.id;
701
+ return r.selected.some((C) => C.id === A);
702
+ }, p = (b, A) => {
703
+ let C;
704
+ if (Array.isArray(b)) {
705
+ if (C = b.map((c) => t.getAnnotation(c)).filter(Boolean), C.length < b.length) {
706
+ console.warn("Invalid selection: " + b.filter((c) => !C.some((y) => y.id === c)));
707
+ return;
708
+ }
709
+ } else {
710
+ const c = t.getAnnotation(b);
711
+ if (!c) {
712
+ console.warn("Invalid selection: " + b);
713
+ return;
714
+ }
715
+ C = [c];
717
716
  }
718
- }, d = (w, b) => {
719
- const C = Array.isArray(w) ? w : [w], g = C.map((u) => t.getAnnotation(u)).filter((u) => !!u);
717
+ const m = C.reduce((c, y) => {
718
+ const S = oe(y, s);
719
+ return S === "EDIT" ? [...c, { id: y.id, editable: !0 }] : S === "SELECT" ? [...c, { id: y.id }] : c;
720
+ }, []);
721
+ i({ selected: m, event: A });
722
+ }, d = (b, A) => {
723
+ const C = Array.isArray(b) ? b : [b], m = C.map((c) => t.getAnnotation(c)).filter((c) => !!c);
720
724
  i({
721
- selected: g.map((u) => {
722
- const y = b === void 0 ? te(u, s) === "EDIT" : b;
723
- return { id: u.id, editable: y };
725
+ selected: m.map((c) => {
726
+ const y = A === void 0 ? oe(c, s) === "EDIT" : A;
727
+ return { id: c.id, editable: y };
724
728
  })
725
- }), g.length !== C.length && console.warn("Invalid selection", w);
726
- }, m = (w) => {
729
+ }), m.length !== C.length && console.warn("Invalid selection", b);
730
+ }, h = (b) => {
727
731
  if (l())
728
732
  return !1;
729
- const { selected: b } = r;
730
- b.some(({ id: C }) => w.includes(C)) && i({ selected: b.filter(({ id: C }) => !w.includes(C)) });
731
- }, p = (w) => s = w;
733
+ const { selected: A } = r;
734
+ A.some(({ id: C }) => b.includes(C)) && i({ selected: A.filter(({ id: C }) => !b.includes(C)) });
735
+ }, g = (b) => s = b;
732
736
  return t.observe(
733
- ({ changes: w }) => m((w.deleted || []).map((b) => b.id))
737
+ ({ changes: b }) => h((b.deleted || []).map((A) => A.id))
734
738
  ), {
735
739
  get event() {
736
740
  return r ? r.event : null;
@@ -743,37 +747,37 @@ const ht = { selected: [] }, xn = (t, e, n) => {
743
747
  },
744
748
  clear: a,
745
749
  isEmpty: l,
746
- isSelected: c,
750
+ isSelected: f,
747
751
  setSelected: d,
748
- setUserSelectAction: p,
752
+ setUserSelectAction: g,
749
753
  subscribe: o,
750
- userSelect: f
754
+ userSelect: p
751
755
  };
752
- }, te = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT";
753
- var D = [];
754
- for (var Ot = 0; Ot < 256; ++Ot)
755
- D.push((Ot + 256).toString(16).slice(1));
756
- function En(t, e = 0) {
757
- return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + "-" + D[t[e + 4]] + D[t[e + 5]] + "-" + D[t[e + 6]] + D[t[e + 7]] + "-" + D[t[e + 8]] + D[t[e + 9]] + "-" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();
756
+ }, oe = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT", Y = [];
757
+ for (let t = 0; t < 256; ++t)
758
+ Y.push((t + 256).toString(16).slice(1));
759
+ function Sn(t, e = 0) {
760
+ return (Y[t[e + 0]] + Y[t[e + 1]] + Y[t[e + 2]] + Y[t[e + 3]] + "-" + Y[t[e + 4]] + Y[t[e + 5]] + "-" + Y[t[e + 6]] + Y[t[e + 7]] + "-" + Y[t[e + 8]] + Y[t[e + 9]] + "-" + Y[t[e + 10]] + Y[t[e + 11]] + Y[t[e + 12]] + Y[t[e + 13]] + Y[t[e + 14]] + Y[t[e + 15]]).toLowerCase();
758
761
  }
759
- var pt, Sn = new Uint8Array(16);
760
- function Cn() {
761
- if (!pt && (pt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !pt))
762
- throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
763
- return pt(Sn);
762
+ let Mt;
763
+ const Cn = new Uint8Array(16);
764
+ function Ln() {
765
+ if (!Mt) {
766
+ if (typeof crypto > "u" || !crypto.getRandomValues)
767
+ throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
768
+ Mt = crypto.getRandomValues.bind(crypto);
769
+ }
770
+ return Mt(Cn);
764
771
  }
765
- var Ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
766
- const ee = {
767
- randomUUID: Ln
768
- };
769
- function me(t, e, n) {
770
- if (ee.randomUUID && !e && !t)
771
- return ee.randomUUID();
772
+ const Tn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ie = { randomUUID: Tn };
773
+ function we(t, e, n) {
774
+ if (ie.randomUUID && !e && !t)
775
+ return ie.randomUUID();
772
776
  t = t || {};
773
- var o = t.random || (t.rng || Cn)();
774
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, En(o);
777
+ const o = t.random || (t.rng || Ln)();
778
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Sn(o);
775
779
  }
776
- const Tt = (t) => {
780
+ const Bt = (t) => {
777
781
  const e = (n) => {
778
782
  const o = { ...n };
779
783
  return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
@@ -783,8 +787,8 @@ const Tt = (t) => {
783
787
  bodies: (t.bodies || []).map(e),
784
788
  target: e(t.target)
785
789
  };
786
- }, Bo = (t, e, n, o) => ({
787
- id: me(),
790
+ }, ko = (t, e, n, o) => ({
791
+ id: we(),
788
792
  annotation: typeof t == "string" ? t : t.id,
789
793
  created: n || /* @__PURE__ */ new Date(),
790
794
  creator: o,
@@ -792,25 +796,25 @@ const Tt = (t) => {
792
796
  }), On = (t, e) => {
793
797
  const n = new Set(t.bodies.map((o) => o.id));
794
798
  return e.bodies.filter((o) => !n.has(o.id));
795
- }, Tn = (t, e) => {
799
+ }, Rn = (t, e) => {
796
800
  const n = new Set(e.bodies.map((o) => o.id));
797
801
  return t.bodies.filter((o) => !n.has(o.id));
798
- }, Rn = (t, e) => e.bodies.map((n) => {
802
+ }, Mn = (t, e) => e.bodies.map((n) => {
799
803
  const o = t.bodies.find((i) => i.id === n.id);
800
- return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
801
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Mn = (t, e) => !q(t.target, e.target), ye = (t, e) => {
802
- const n = On(t, e), o = Tn(t, e), i = Rn(t, e);
804
+ return { newBody: n, oldBody: o && !Q(o, n) ? o : void 0 };
805
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Bn = (t, e) => !Q(t.target, e.target), Ae = (t, e) => {
806
+ const n = On(t, e), o = Rn(t, e), i = Mn(t, e);
803
807
  return {
804
808
  oldValue: t,
805
809
  newValue: e,
806
810
  bodiesCreated: n.length > 0 ? n : void 0,
807
811
  bodiesDeleted: o.length > 0 ? o : void 0,
808
812
  bodiesUpdated: i.length > 0 ? i : void 0,
809
- targetUpdated: Mn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
813
+ targetUpdated: Bn(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
810
814
  };
811
815
  };
812
816
  var k = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t.SILENT = "SILENT", t))(k || {});
813
- const Bn = (t, e) => {
817
+ const kn = (t, e) => {
814
818
  var n, o;
815
819
  const { changes: i, origin: s } = e;
816
820
  if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
@@ -818,8 +822,8 @@ const Bn = (t, e) => {
818
822
  if (t.options.ignore) {
819
823
  const { ignore: r } = t.options, a = (l) => l && l.length > 0;
820
824
  if (!(a(i.created) || a(i.deleted))) {
821
- const l = (n = i.updated) == null ? void 0 : n.some((f) => a(f.bodiesCreated) || a(f.bodiesDeleted) || a(f.bodiesUpdated)), c = (o = i.updated) == null ? void 0 : o.some((f) => f.targetUpdated);
822
- if (r === "BODY_ONLY" && l && !c || r === "TARGET_ONLY" && c && !l)
825
+ const l = (n = i.updated) == null ? void 0 : n.some((p) => a(p.bodiesCreated) || a(p.bodiesDeleted) || a(p.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((p) => p.targetUpdated);
826
+ if (r === "BODY_ONLY" && l && !f || r === "TARGET_ONLY" && f && !l)
823
827
  return !1;
824
828
  }
825
829
  }
@@ -832,27 +836,27 @@ const Bn = (t, e) => {
832
836
  return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => r.has(a));
833
837
  } else
834
838
  return !0;
835
- }, kn = (t, e) => {
839
+ }, In = (t, e) => {
836
840
  const n = new Set((t.created || []).map((d) => d.id)), o = new Set((t.updated || []).map(({ newValue: d }) => d.id)), i = new Set((e.created || []).map((d) => d.id)), s = new Set((e.deleted || []).map((d) => d.id)), r = new Set((e.updated || []).map(({ oldValue: d }) => d.id)), a = new Set((e.updated || []).filter(({ oldValue: d }) => n.has(d.id) || o.has(d.id)).map(({ oldValue: d }) => d.id)), l = [
837
- ...(t.created || []).filter((d) => !s.has(d.id)).map((d) => r.has(d.id) ? e.updated.find(({ oldValue: m }) => m.id === d.id).newValue : d),
841
+ ...(t.created || []).filter((d) => !s.has(d.id)).map((d) => r.has(d.id) ? e.updated.find(({ oldValue: h }) => h.id === d.id).newValue : d),
838
842
  ...e.created || []
839
- ], c = [
843
+ ], f = [
840
844
  ...(t.deleted || []).filter((d) => !i.has(d.id)),
841
845
  ...(e.deleted || []).filter((d) => !n.has(d.id))
842
- ], f = [
846
+ ], p = [
843
847
  ...(t.updated || []).filter(({ newValue: d }) => !s.has(d.id)).map((d) => {
844
- const { oldValue: m, newValue: p } = d;
845
- if (r.has(p.id)) {
846
- const w = e.updated.find((b) => b.oldValue.id === p.id).newValue;
847
- return ye(m, w);
848
+ const { oldValue: h, newValue: g } = d;
849
+ if (r.has(g.id)) {
850
+ const b = e.updated.find((A) => A.oldValue.id === g.id).newValue;
851
+ return Ae(h, b);
848
852
  } else
849
853
  return d;
850
854
  }),
851
855
  ...(e.updated || []).filter(({ oldValue: d }) => !a.has(d.id))
852
856
  ];
853
- return { created: l, deleted: c, updated: f };
854
- }, Rt = (t) => {
855
- const e = t.id === void 0 ? me() : t.id;
857
+ return { created: l, deleted: f, updated: p };
858
+ }, kt = (t) => {
859
+ const e = t.id === void 0 ? we() : t.id;
856
860
  return {
857
861
  ...t,
858
862
  id: e,
@@ -865,15 +869,15 @@ const Bn = (t, e) => {
865
869
  annotation: e
866
870
  }
867
871
  };
868
- }, In = (t) => t.id !== void 0, Nn = () => {
869
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (h, v = {}) => {
870
- n.push({ onChange: h, options: v });
871
- }, i = (h) => {
872
- const v = n.findIndex((A) => A.onChange == h);
872
+ }, Nn = (t) => t.id !== void 0, _n = () => {
873
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (w, v = {}) => {
874
+ n.push({ onChange: w, options: v });
875
+ }, i = (w) => {
876
+ const v = n.findIndex((u) => u.onChange == w);
873
877
  v > -1 && n.splice(v, 1);
874
- }, s = (h, v) => {
875
- const A = {
876
- origin: h,
878
+ }, s = (w, v) => {
879
+ const u = {
880
+ origin: w,
877
881
  changes: {
878
882
  created: v.created || [],
879
883
  updated: v.updated || [],
@@ -881,193 +885,193 @@ const Bn = (t, e) => {
881
885
  },
882
886
  state: [...t.values()]
883
887
  };
884
- n.forEach((L) => {
885
- Bn(L, A) && L.onChange(A);
888
+ n.forEach((E) => {
889
+ kn(E, u) && E.onChange(u);
886
890
  });
887
- }, r = (h, v = k.LOCAL) => {
888
- if (h.id && t.get(h.id))
889
- throw Error(`Cannot add annotation ${h.id} - exists already`);
891
+ }, r = (w, v = k.LOCAL) => {
892
+ if (w.id && t.get(w.id))
893
+ throw Error(`Cannot add annotation ${w.id} - exists already`);
890
894
  {
891
- const A = Rt(h);
892
- t.set(A.id, A), A.bodies.forEach((L) => e.set(L.id, A.id)), s(v, { created: [A] });
895
+ const u = kt(w);
896
+ t.set(u.id, u), u.bodies.forEach((E) => e.set(E.id, u.id)), s(v, { created: [u] });
893
897
  }
894
- }, a = (h, v) => {
895
- const A = Rt(typeof h == "string" ? v : h), L = typeof h == "string" ? h : h.id, M = L && t.get(L);
896
- if (M) {
897
- const B = ye(M, A);
898
- return L === A.id ? t.set(L, A) : (t.delete(L), t.set(A.id, A)), M.bodies.forEach((K) => e.delete(K.id)), A.bodies.forEach((K) => e.set(K.id, A.id)), B;
898
+ }, a = (w, v) => {
899
+ const u = kt(typeof w == "string" ? v : w), E = typeof w == "string" ? w : w.id, B = E && t.get(E);
900
+ if (B) {
901
+ const R = Ae(B, u);
902
+ return E === u.id ? t.set(E, u) : (t.delete(E), t.set(u.id, u)), B.bodies.forEach((U) => e.delete(U.id)), u.bodies.forEach((U) => e.set(U.id, u.id)), R;
899
903
  } else
900
- console.warn(`Cannot update annotation ${L} - does not exist`);
901
- }, l = (h, v = k.LOCAL, A = k.LOCAL) => {
902
- const L = In(v) ? A : v, M = a(h, v);
903
- M && s(L, { updated: [M] });
904
- }, c = (h, v = k.LOCAL) => {
905
- const A = h.reduce((L, M) => {
906
- const B = a(M);
907
- return B ? [...L, B] : L;
904
+ console.warn(`Cannot update annotation ${E} - does not exist`);
905
+ }, l = (w, v = k.LOCAL, u = k.LOCAL) => {
906
+ const E = Nn(v) ? u : v, B = a(w, v);
907
+ B && s(E, { updated: [B] });
908
+ }, f = (w, v = k.LOCAL) => {
909
+ const u = w.reduce((E, B) => {
910
+ const R = a(B);
911
+ return R ? [...E, R] : E;
908
912
  }, []);
909
- A.length > 0 && s(v, { updated: A });
910
- }, f = (h, v = k.LOCAL) => {
911
- const A = t.get(h.annotation);
912
- if (A) {
913
- const L = {
914
- ...A,
915
- bodies: [...A.bodies, h]
913
+ u.length > 0 && s(v, { updated: u });
914
+ }, p = (w, v = k.LOCAL) => {
915
+ const u = t.get(w.annotation);
916
+ if (u) {
917
+ const E = {
918
+ ...u,
919
+ bodies: [...u.bodies, w]
916
920
  };
917
- t.set(A.id, L), e.set(h.id, L.id), s(v, { updated: [{
918
- oldValue: A,
919
- newValue: L,
920
- bodiesCreated: [h]
921
+ t.set(u.id, E), e.set(w.id, E.id), s(v, { updated: [{
922
+ oldValue: u,
923
+ newValue: E,
924
+ bodiesCreated: [w]
921
925
  }] });
922
926
  } else
923
- console.warn(`Attempt to add body to missing annotation: ${h.annotation}`);
924
- }, d = () => [...t.values()], m = (h = k.LOCAL) => {
927
+ console.warn(`Attempt to add body to missing annotation: ${w.annotation}`);
928
+ }, d = () => [...t.values()], h = (w = k.LOCAL) => {
925
929
  const v = [...t.values()];
926
- t.clear(), e.clear(), s(h, { deleted: v });
927
- }, p = (h, v = !0, A = k.LOCAL) => {
928
- const L = h.map(Rt);
930
+ t.clear(), e.clear(), s(w, { deleted: v });
931
+ }, g = (w, v = !0, u = k.LOCAL) => {
932
+ const E = w.map(kt);
929
933
  if (v) {
930
- const M = [...t.values()];
931
- t.clear(), e.clear(), L.forEach((B) => {
932
- t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
933
- }), s(A, { created: L, deleted: M });
934
+ const B = [...t.values()];
935
+ t.clear(), e.clear(), E.forEach((R) => {
936
+ t.set(R.id, R), R.bodies.forEach((U) => e.set(U.id, R.id));
937
+ }), s(u, { created: E, deleted: B });
934
938
  } else {
935
- const M = h.reduce((B, K) => {
936
- const Y = K.id && t.get(K.id);
937
- return Y ? [...B, Y] : B;
939
+ const B = w.reduce((R, U) => {
940
+ const _ = U.id && t.get(U.id);
941
+ return _ ? [...R, _] : R;
938
942
  }, []);
939
- if (M.length > 0)
940
- throw Error(`Bulk insert would overwrite the following annotations: ${M.map((B) => B.id).join(", ")}`);
941
- L.forEach((B) => {
942
- t.set(B.id, B), B.bodies.forEach((K) => e.set(K.id, B.id));
943
- }), s(A, { created: L });
943
+ if (B.length > 0)
944
+ throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
945
+ E.forEach((R) => {
946
+ t.set(R.id, R), R.bodies.forEach((U) => e.set(U.id, R.id));
947
+ }), s(u, { created: E });
944
948
  }
945
- }, w = (h) => {
946
- const v = typeof h == "string" ? h : h.id, A = t.get(v);
947
- if (A)
948
- return t.delete(v), A.bodies.forEach((L) => e.delete(L.id)), A;
949
+ }, b = (w) => {
950
+ const v = typeof w == "string" ? w : w.id, u = t.get(v);
951
+ if (u)
952
+ return t.delete(v), u.bodies.forEach((E) => e.delete(E.id)), u;
949
953
  console.warn(`Attempt to delete missing annotation: ${v}`);
950
- }, b = (h, v = k.LOCAL) => {
951
- const A = w(h);
952
- A && s(v, { deleted: [A] });
953
- }, C = (h, v = k.LOCAL) => {
954
- const A = h.reduce((L, M) => {
955
- const B = w(M);
956
- return B ? [...L, B] : L;
954
+ }, A = (w, v = k.LOCAL) => {
955
+ const u = b(w);
956
+ u && s(v, { deleted: [u] });
957
+ }, C = (w, v = k.LOCAL) => {
958
+ const u = w.reduce((E, B) => {
959
+ const R = b(B);
960
+ return R ? [...E, R] : E;
957
961
  }, []);
958
- A.length > 0 && s(v, { deleted: A });
959
- }, g = (h) => {
960
- const v = t.get(h.annotation);
962
+ u.length > 0 && s(v, { deleted: u });
963
+ }, m = (w) => {
964
+ const v = t.get(w.annotation);
961
965
  if (v) {
962
- const A = v.bodies.find((L) => L.id === h.id);
963
- if (A) {
964
- e.delete(A.id);
965
- const L = {
966
+ const u = v.bodies.find((E) => E.id === w.id);
967
+ if (u) {
968
+ e.delete(u.id);
969
+ const E = {
966
970
  ...v,
967
- bodies: v.bodies.filter((M) => M.id !== h.id)
971
+ bodies: v.bodies.filter((B) => B.id !== w.id)
968
972
  };
969
- return t.set(v.id, L), {
973
+ return t.set(v.id, E), {
970
974
  oldValue: v,
971
- newValue: L,
972
- bodiesDeleted: [A]
975
+ newValue: E,
976
+ bodiesDeleted: [u]
973
977
  };
974
978
  } else
975
- console.warn(`Attempt to delete missing body ${h.id} from annotation ${h.annotation}`);
979
+ console.warn(`Attempt to delete missing body ${w.id} from annotation ${w.annotation}`);
976
980
  } else
977
- console.warn(`Attempt to delete body from missing annotation ${h.annotation}`);
978
- }, u = (h, v = k.LOCAL) => {
979
- const A = g(h);
980
- A && s(v, { updated: [A] });
981
- }, y = (h, v = k.LOCAL) => {
982
- const A = h.map((L) => g(L)).filter(Boolean);
983
- A.length > 0 && s(v, { updated: A });
984
- }, S = (h) => {
985
- const v = t.get(h);
981
+ console.warn(`Attempt to delete body from missing annotation ${w.annotation}`);
982
+ }, c = (w, v = k.LOCAL) => {
983
+ const u = m(w);
984
+ u && s(v, { updated: [u] });
985
+ }, y = (w, v = k.LOCAL) => {
986
+ const u = w.map((E) => m(E)).filter(Boolean);
987
+ u.length > 0 && s(v, { updated: u });
988
+ }, S = (w) => {
989
+ const v = t.get(w);
986
990
  return v ? { ...v } : void 0;
987
- }, E = (h) => {
988
- const v = e.get(h);
991
+ }, x = (w) => {
992
+ const v = e.get(w);
989
993
  if (v) {
990
- const A = S(v).bodies.find((L) => L.id === h);
991
- if (A)
992
- return A;
993
- console.error(`Store integrity error: body ${h} in index, but not in annotation`);
994
+ const u = S(v).bodies.find((E) => E.id === w);
995
+ if (u)
996
+ return u;
997
+ console.error(`Store integrity error: body ${w} in index, but not in annotation`);
994
998
  } else
995
- console.warn(`Attempt to retrieve missing body: ${h}`);
996
- }, O = (h, v) => {
997
- if (h.annotation !== v.annotation)
999
+ console.warn(`Attempt to retrieve missing body: ${w}`);
1000
+ }, L = (w, v) => {
1001
+ if (w.annotation !== v.annotation)
998
1002
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
999
- const A = t.get(h.annotation);
1000
- if (A) {
1001
- const L = A.bodies.find((B) => B.id === h.id), M = {
1002
- ...A,
1003
- bodies: A.bodies.map((B) => B.id === L.id ? v : B)
1003
+ const u = t.get(w.annotation);
1004
+ if (u) {
1005
+ const E = u.bodies.find((R) => R.id === w.id), B = {
1006
+ ...u,
1007
+ bodies: u.bodies.map((R) => R.id === E.id ? v : R)
1004
1008
  };
1005
- return t.set(A.id, M), L.id !== v.id && (e.delete(L.id), e.set(v.id, M.id)), {
1006
- oldValue: A,
1007
- newValue: M,
1008
- bodiesUpdated: [{ oldBody: L, newBody: v }]
1009
+ return t.set(u.id, B), E.id !== v.id && (e.delete(E.id), e.set(v.id, B.id)), {
1010
+ oldValue: u,
1011
+ newValue: B,
1012
+ bodiesUpdated: [{ oldBody: E, newBody: v }]
1009
1013
  };
1010
1014
  } else
1011
- console.warn(`Attempt to add body to missing annotation ${h.annotation}`);
1012
- }, R = (h, v, A = k.LOCAL) => {
1013
- const L = O(h, v);
1014
- L && s(A, { updated: [L] });
1015
- }, T = (h, v = k.LOCAL) => {
1016
- const A = h.map((L) => O({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
1017
- s(v, { updated: A });
1018
- }, x = (h) => {
1019
- const v = t.get(h.annotation);
1015
+ console.warn(`Attempt to add body to missing annotation ${w.annotation}`);
1016
+ }, O = (w, v, u = k.LOCAL) => {
1017
+ const E = L(w, v);
1018
+ E && s(u, { updated: [E] });
1019
+ }, T = (w, v = k.LOCAL) => {
1020
+ const u = w.map((E) => L({ id: E.id, annotation: E.annotation }, E)).filter(Boolean);
1021
+ s(v, { updated: u });
1022
+ }, M = (w) => {
1023
+ const v = t.get(w.annotation);
1020
1024
  if (v) {
1021
- const A = {
1025
+ const u = {
1022
1026
  ...v,
1023
1027
  target: {
1024
1028
  ...v.target,
1025
- ...h
1029
+ ...w
1026
1030
  }
1027
1031
  };
1028
- return t.set(v.id, A), {
1032
+ return t.set(v.id, u), {
1029
1033
  oldValue: v,
1030
- newValue: A,
1034
+ newValue: u,
1031
1035
  targetUpdated: {
1032
1036
  oldTarget: v.target,
1033
- newTarget: h
1037
+ newTarget: w
1034
1038
  }
1035
1039
  };
1036
1040
  } else
1037
- console.warn(`Attempt to update target on missing annotation: ${h.annotation}`);
1041
+ console.warn(`Attempt to update target on missing annotation: ${w.annotation}`);
1038
1042
  };
1039
1043
  return {
1040
1044
  addAnnotation: r,
1041
- addBody: f,
1045
+ addBody: p,
1042
1046
  all: d,
1043
- bulkAddAnnotation: p,
1047
+ bulkAddAnnotation: g,
1044
1048
  bulkDeleteAnnotation: C,
1045
1049
  bulkDeleteBodies: y,
1046
- bulkUpdateAnnotation: c,
1050
+ bulkUpdateAnnotation: f,
1047
1051
  bulkUpdateBodies: T,
1048
- bulkUpdateTargets: (h, v = k.LOCAL) => {
1049
- const A = h.map((L) => x(L)).filter(Boolean);
1050
- A.length > 0 && s(v, { updated: A });
1052
+ bulkUpdateTargets: (w, v = k.LOCAL) => {
1053
+ const u = w.map((E) => M(E)).filter(Boolean);
1054
+ u.length > 0 && s(v, { updated: u });
1051
1055
  },
1052
- clear: m,
1053
- deleteAnnotation: b,
1054
- deleteBody: u,
1056
+ clear: h,
1057
+ deleteAnnotation: A,
1058
+ deleteBody: c,
1055
1059
  getAnnotation: S,
1056
- getBody: E,
1060
+ getBody: x,
1057
1061
  observe: o,
1058
1062
  unobserve: i,
1059
1063
  updateAnnotation: l,
1060
- updateBody: R,
1061
- updateTarget: (h, v = k.LOCAL) => {
1062
- const A = x(h);
1063
- A && s(v, { updated: [A] });
1064
+ updateBody: O,
1065
+ updateTarget: (w, v = k.LOCAL) => {
1066
+ const u = M(w);
1067
+ u && s(v, { updated: [u] });
1064
1068
  }
1065
1069
  };
1066
1070
  };
1067
- let _n = () => ({
1071
+ let Un = () => ({
1068
1072
  emit(t, ...e) {
1069
- for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
1070
- o[n](...e);
1073
+ for (let n = this.events[t] || [], o = 0, i = n.length; o < i; o++)
1074
+ n[o](...e);
1071
1075
  },
1072
1076
  events: {},
1073
1077
  on(t, e) {
@@ -1078,119 +1082,119 @@ let _n = () => ({
1078
1082
  };
1079
1083
  }
1080
1084
  });
1081
- const Un = 250, Dn = (t) => {
1082
- const e = _n(), n = [];
1085
+ const Dn = 250, Vn = (t) => {
1086
+ const e = Un(), n = [];
1083
1087
  let o = -1, i = !1, s = 0;
1084
- const r = (p) => {
1088
+ const r = (g) => {
1085
1089
  if (!i) {
1086
- const { changes: w } = p, b = performance.now();
1087
- if (b - s > Un)
1088
- n.splice(o + 1), n.push(w), o = n.length - 1;
1090
+ const { changes: b } = g, A = performance.now();
1091
+ if (A - s > Dn)
1092
+ n.splice(o + 1), n.push(b), o = n.length - 1;
1089
1093
  else {
1090
1094
  const C = n.length - 1;
1091
- n[C] = kn(n[C], w);
1095
+ n[C] = In(n[C], b);
1092
1096
  }
1093
- s = b;
1097
+ s = A;
1094
1098
  }
1095
1099
  i = !1;
1096
1100
  };
1097
1101
  t.observe(r, { origin: k.LOCAL });
1098
- const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), c = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: w }) => w)), f = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: w }) => w)), d = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), m = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1102
+ const a = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: b }) => b)), p = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: b }) => b)), d = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), h = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1099
1103
  return {
1100
1104
  canRedo: () => n.length - 1 > o,
1101
1105
  canUndo: () => o > -1,
1102
1106
  destroy: () => t.unobserve(r),
1103
- on: (p, w) => e.on(p, w),
1107
+ on: (g, b) => e.on(g, b),
1104
1108
  redo: () => {
1105
1109
  if (n.length - 1 > o) {
1106
1110
  i = !0;
1107
- const { created: p, updated: w, deleted: b } = n[o + 1];
1108
- l(p), f(w), m(b), e.emit("redo", n[o + 1]), o += 1;
1111
+ const { created: g, updated: b, deleted: A } = n[o + 1];
1112
+ l(g), p(b), h(A), e.emit("redo", n[o + 1]), o += 1;
1109
1113
  }
1110
1114
  },
1111
1115
  undo: () => {
1112
1116
  if (o > -1) {
1113
1117
  i = !0;
1114
- const { created: p, updated: w, deleted: b } = n[o];
1115
- a(p), c(w), d(b), e.emit("undo", n[o]), o -= 1;
1118
+ const { created: g, updated: b, deleted: A } = n[o];
1119
+ a(g), f(b), d(A), e.emit("undo", n[o]), o -= 1;
1116
1120
  }
1117
1121
  }
1118
1122
  };
1119
- }, Vn = () => {
1120
- const { subscribe: t, set: e } = Xt([]);
1123
+ }, Yn = () => {
1124
+ const { subscribe: t, set: e } = jt([]);
1121
1125
  return {
1122
1126
  subscribe: t,
1123
1127
  set: e
1124
1128
  };
1125
1129
  }, Kn = (t, e, n, o) => {
1126
1130
  const { hover: i, selection: s, store: r, viewport: a } = t, l = /* @__PURE__ */ new Map();
1127
- let c = [], f;
1128
- const d = (b, C) => {
1129
- l.has(b) ? l.get(b).push(C) : l.set(b, [C]);
1130
- }, m = (b, C) => {
1131
- const g = l.get(b);
1132
- if (g) {
1133
- const u = g.indexOf(C);
1134
- u !== -1 && g.splice(u, 1);
1131
+ let f = [], p;
1132
+ const d = (A, C) => {
1133
+ l.has(A) ? l.get(A).push(C) : l.set(A, [C]);
1134
+ }, h = (A, C) => {
1135
+ const m = l.get(A);
1136
+ if (m) {
1137
+ const c = m.indexOf(C);
1138
+ c !== -1 && m.splice(c, 1);
1135
1139
  }
1136
- }, p = (b, C, g) => {
1137
- l.has(b) && setTimeout(() => {
1138
- l.get(b).forEach((u) => {
1140
+ }, g = (A, C, m) => {
1141
+ l.has(A) && setTimeout(() => {
1142
+ l.get(A).forEach((c) => {
1139
1143
  if (n) {
1140
- const y = Array.isArray(C) ? C.map((E) => n.serialize(E)) : n.serialize(C), S = g ? g instanceof PointerEvent ? g : n.serialize(g) : void 0;
1141
- u(y, S);
1144
+ const y = Array.isArray(C) ? C.map((x) => n.serialize(x)) : n.serialize(C), S = m ? m instanceof PointerEvent ? m : n.serialize(m) : void 0;
1145
+ c(y, S);
1142
1146
  } else
1143
- u(C, g);
1147
+ c(C, m);
1144
1148
  });
1145
1149
  }, 1);
1146
1150
  };
1147
- s.subscribe(({ selected: b }) => {
1148
- if (!(c.length === 0 && b.length === 0)) {
1149
- if (c.length === 0 && b.length > 0)
1150
- c = b.map(({ id: C }) => r.getAnnotation(C));
1151
- else if (c.length > 0 && b.length === 0)
1152
- c.forEach((C) => {
1153
- const g = r.getAnnotation(C.id);
1154
- g && !q(g, C) && p("updateAnnotation", g, C);
1155
- }), c = [];
1151
+ s.subscribe(({ selected: A }) => {
1152
+ if (!(f.length === 0 && A.length === 0)) {
1153
+ if (f.length === 0 && A.length > 0)
1154
+ f = A.map(({ id: C }) => r.getAnnotation(C));
1155
+ else if (f.length > 0 && A.length === 0)
1156
+ f.forEach((C) => {
1157
+ const m = r.getAnnotation(C.id);
1158
+ m && !Q(m, C) && g("updateAnnotation", m, C);
1159
+ }), f = [];
1156
1160
  else {
1157
- const C = new Set(c.map((u) => u.id)), g = new Set(b.map(({ id: u }) => u));
1158
- c.filter((u) => !g.has(u.id)).forEach((u) => {
1159
- const y = r.getAnnotation(u.id);
1160
- y && !q(y, u) && p("updateAnnotation", y, u);
1161
- }), c = [
1161
+ const C = new Set(f.map((c) => c.id)), m = new Set(A.map(({ id: c }) => c));
1162
+ f.filter((c) => !m.has(c.id)).forEach((c) => {
1163
+ const y = r.getAnnotation(c.id);
1164
+ y && !Q(y, c) && g("updateAnnotation", y, c);
1165
+ }), f = [
1162
1166
  // Remove annotations that were deselected
1163
- ...c.filter((u) => g.has(u.id)),
1167
+ ...f.filter((c) => m.has(c.id)),
1164
1168
  // Add editable annotations that were selected
1165
- ...b.filter(({ id: u }) => !C.has(u)).map(({ id: u }) => r.getAnnotation(u))
1169
+ ...A.filter(({ id: c }) => !C.has(c)).map(({ id: c }) => r.getAnnotation(c))
1166
1170
  ];
1167
1171
  }
1168
- p("selectionChanged", c);
1172
+ g("selectionChanged", f);
1169
1173
  }
1170
- }), i.subscribe((b) => {
1171
- !f && b ? p("mouseEnterAnnotation", r.getAnnotation(b)) : f && !b ? p("mouseLeaveAnnotation", r.getAnnotation(f)) : f && b && (p("mouseLeaveAnnotation", r.getAnnotation(f)), p("mouseEnterAnnotation", r.getAnnotation(b))), f = b;
1172
- }), a == null || a.subscribe((b) => p("viewportIntersect", b.map((C) => r.getAnnotation(C)))), r.observe((b) => {
1173
- const { created: C, deleted: g } = b.changes;
1174
- (C || []).forEach((u) => p("createAnnotation", u)), (g || []).forEach((u) => p("deleteAnnotation", u)), (b.changes.updated || []).filter((u) => [
1175
- ...u.bodiesCreated || [],
1176
- ...u.bodiesDeleted || [],
1177
- ...u.bodiesUpdated || []
1178
- ].length > 0).forEach(({ oldValue: u, newValue: y }) => {
1179
- const S = c.find((E) => E.id === u.id) || u;
1180
- c = c.map((E) => E.id === u.id ? y : E), p("updateAnnotation", y, S);
1174
+ }), i.subscribe((A) => {
1175
+ !p && A ? g("mouseEnterAnnotation", r.getAnnotation(A)) : p && !A ? g("mouseLeaveAnnotation", r.getAnnotation(p)) : p && A && (g("mouseLeaveAnnotation", r.getAnnotation(p)), g("mouseEnterAnnotation", r.getAnnotation(A))), p = A;
1176
+ }), a == null || a.subscribe((A) => g("viewportIntersect", A.map((C) => r.getAnnotation(C)))), r.observe((A) => {
1177
+ const { created: C, deleted: m } = A.changes;
1178
+ (C || []).forEach((c) => g("createAnnotation", c)), (m || []).forEach((c) => g("deleteAnnotation", c)), (A.changes.updated || []).filter((c) => [
1179
+ ...c.bodiesCreated || [],
1180
+ ...c.bodiesDeleted || [],
1181
+ ...c.bodiesUpdated || []
1182
+ ].length > 0).forEach(({ oldValue: c, newValue: y }) => {
1183
+ const S = f.find((x) => x.id === c.id) || c;
1184
+ f = f.map((x) => x.id === c.id ? y : x), g("updateAnnotation", y, S);
1181
1185
  });
1182
- }, { origin: k.LOCAL }), r.observe((b) => {
1183
- if (c) {
1184
- const C = new Set(c.map((u) => u.id)), g = (b.changes.updated || []).filter(({ newValue: u }) => C.has(u.id)).map(({ newValue: u }) => u);
1185
- g.length > 0 && (c = c.map((u) => g.find((S) => S.id === u.id) || u));
1186
+ }, { origin: k.LOCAL }), r.observe((A) => {
1187
+ if (f) {
1188
+ const C = new Set(f.map((c) => c.id)), m = (A.changes.updated || []).filter(({ newValue: c }) => C.has(c.id)).map(({ newValue: c }) => c);
1189
+ m.length > 0 && (f = f.map((c) => m.find((S) => S.id === c.id) || c));
1186
1190
  }
1187
1191
  }, { origin: k.REMOTE });
1188
- const w = (b) => (C) => {
1189
- const { updated: g } = C;
1190
- b ? (g || []).forEach((u) => p("updateAnnotation", u.oldValue, u.newValue)) : (g || []).forEach((u) => p("updateAnnotation", u.newValue, u.oldValue));
1192
+ const b = (A) => (C) => {
1193
+ const { updated: m } = C;
1194
+ A ? (m || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (m || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
1191
1195
  };
1192
- return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: d, off: m, emit: p };
1193
- }, Yn = (t) => (e) => e.reduce((n, o) => {
1196
+ return e.on("undo", b(!0)), e.on("redo", b(!1)), { on: d, off: h, emit: g };
1197
+ }, Xn = (t) => (e) => e.reduce((n, o) => {
1194
1198
  const { parsed: i, error: s } = t.parse(o);
1195
1199
  return s ? {
1196
1200
  parsed: n.parsed,
@@ -1201,47 +1205,47 @@ const Un = 250, Dn = (t) => {
1201
1205
  } : {
1202
1206
  ...n
1203
1207
  };
1204
- }, { parsed: [], failed: [] }), Xn = (t, e, n) => {
1205
- const { store: o, selection: i } = t, s = (g) => {
1208
+ }, { parsed: [], failed: [] }), Pn = (t, e, n) => {
1209
+ const { store: o, selection: i } = t, s = (m) => {
1206
1210
  if (n) {
1207
- const { parsed: u, error: y } = n.parse(g);
1208
- u ? o.addAnnotation(u, k.REMOTE) : console.error(y);
1211
+ const { parsed: c, error: y } = n.parse(m);
1212
+ c ? o.addAnnotation(c, k.REMOTE) : console.error(y);
1209
1213
  } else
1210
- o.addAnnotation(Tt(g), k.REMOTE);
1211
- }, r = () => i.clear(), a = () => o.clear(), l = (g) => {
1212
- const u = o.getAnnotation(g);
1213
- return n && u ? n.serialize(u) : u;
1214
- }, c = () => n ? o.all().map(n.serialize) : o.all(), f = () => {
1215
- var g;
1216
- const u = (((g = i.selected) == null ? void 0 : g.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
1217
- return n ? u.map(n.serialize) : u;
1218
- }, d = (g, u = !0) => fetch(g).then((y) => y.json()).then((y) => (p(y, u), y)), m = (g) => {
1219
- if (typeof g == "string") {
1220
- const u = o.getAnnotation(g);
1221
- if (o.deleteAnnotation(g), u)
1222
- return n ? n.serialize(u) : u;
1214
+ o.addAnnotation(Bt(m), k.REMOTE);
1215
+ }, r = () => i.clear(), a = () => o.clear(), l = (m) => {
1216
+ const c = o.getAnnotation(m);
1217
+ return n && c ? n.serialize(c) : c;
1218
+ }, f = () => n ? o.all().map(n.serialize) : o.all(), p = () => {
1219
+ var m;
1220
+ const c = (((m = i.selected) == null ? void 0 : m.map((y) => y.id)) || []).map((y) => o.getAnnotation(y)).filter(Boolean);
1221
+ return n ? c.map(n.serialize) : c;
1222
+ }, d = (m, c = !0) => fetch(m).then((y) => y.json()).then((y) => (g(y, c), y)), h = (m) => {
1223
+ if (typeof m == "string") {
1224
+ const c = o.getAnnotation(m);
1225
+ if (o.deleteAnnotation(m), c)
1226
+ return n ? n.serialize(c) : c;
1223
1227
  } else {
1224
- const u = n ? n.parse(g).parsed : g;
1225
- if (u)
1226
- return o.deleteAnnotation(u), g;
1228
+ const c = n ? n.parse(m).parsed : m;
1229
+ if (c)
1230
+ return o.deleteAnnotation(c), m;
1227
1231
  }
1228
- }, p = (g, u = !0) => {
1232
+ }, g = (m, c = !0) => {
1229
1233
  if (n) {
1230
- const y = n.parseAll || Yn(n), { parsed: S, failed: E } = y(g);
1231
- E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(S, u, k.REMOTE);
1234
+ const y = n.parseAll || Xn(n), { parsed: S, failed: x } = y(m);
1235
+ x.length > 0 && console.warn(`Discarded ${x.length} invalid annotations`, x), o.bulkAddAnnotation(S, c, k.REMOTE);
1232
1236
  } else
1233
- o.bulkAddAnnotation(g.map(Tt), u, k.REMOTE);
1234
- }, w = (g, u) => {
1235
- g ? i.setSelected(g, u) : i.clear();
1236
- }, b = (g) => {
1237
- i.clear(), i.setUserSelectAction(g);
1238
- }, C = (g) => {
1237
+ o.bulkAddAnnotation(m.map(Bt), c, k.REMOTE);
1238
+ }, b = (m, c) => {
1239
+ m ? i.setSelected(m, c) : i.clear();
1240
+ }, A = (m) => {
1241
+ i.clear(), i.setUserSelectAction(m);
1242
+ }, C = (m) => {
1239
1243
  if (n) {
1240
- const u = n.parse(g).parsed, y = n.serialize(o.getAnnotation(u.id));
1241
- return o.updateAnnotation(u), y;
1244
+ const c = n.parse(m).parsed, y = n.serialize(o.getAnnotation(c.id));
1245
+ return o.updateAnnotation(c), y;
1242
1246
  } else {
1243
- const u = o.getAnnotation(g.id);
1244
- return o.updateAnnotation(Tt(g)), u;
1247
+ const c = o.getAnnotation(m.id);
1248
+ return o.updateAnnotation(Bt(m)), c;
1245
1249
  }
1246
1250
  };
1247
1251
  return {
@@ -1251,20 +1255,20 @@ const Un = 250, Dn = (t) => {
1251
1255
  canUndo: e.canUndo,
1252
1256
  clearAnnotations: a,
1253
1257
  getAnnotationById: l,
1254
- getAnnotations: c,
1255
- getSelected: f,
1258
+ getAnnotations: f,
1259
+ getSelected: p,
1256
1260
  loadAnnotations: d,
1257
1261
  redo: e.redo,
1258
- removeAnnotation: m,
1259
- setAnnotations: p,
1260
- setSelected: w,
1261
- setUserSelectAction: b,
1262
+ removeAnnotation: h,
1263
+ setAnnotations: g,
1264
+ setSelected: b,
1265
+ setUserSelectAction: A,
1262
1266
  undo: e.undo,
1263
1267
  updateAnnotation: C
1264
1268
  };
1265
- }, Pn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1266
- let $n = (t) => crypto.getRandomValues(new Uint8Array(t)), jn = (t, e, n) => {
1267
- let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
1269
+ }, $n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1270
+ let jn = (t) => crypto.getRandomValues(new Uint8Array(t)), Hn = (t, e, n) => {
1271
+ let o = (2 << Math.log2(t.length - 1)) - 1, i = -~(1.6 * o * e / t.length);
1268
1272
  return (s = e) => {
1269
1273
  let r = "";
1270
1274
  for (; ; ) {
@@ -1273,13 +1277,13 @@ let $n = (t) => crypto.getRandomValues(new Uint8Array(t)), jn = (t, e, n) => {
1273
1277
  if (r += t[a[l] & o] || "", r.length === s) return r;
1274
1278
  }
1275
1279
  };
1276
- }, Hn = (t, e = 21) => jn(t, e, $n), zn = (t = 21) => {
1280
+ }, zn = (t, e = 21) => Hn(t, e, jn), Fn = (t = 21) => {
1277
1281
  let e = "", n = crypto.getRandomValues(new Uint8Array(t));
1278
1282
  for (; t--; )
1279
- e += Pn[n[t] & 63];
1283
+ e += $n[n[t] & 63];
1280
1284
  return e;
1281
1285
  };
1282
- const Fn = () => ({ isGuest: !0, id: Hn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Wn = (t) => {
1286
+ const Wn = () => ({ isGuest: !0, id: zn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), qn = (t) => {
1283
1287
  const e = JSON.stringify(t);
1284
1288
  let n = 0;
1285
1289
  for (let o = 0, i = e.length; o < i; o++) {
@@ -1287,20 +1291,20 @@ const Fn = () => ({ isGuest: !0, id: Hn("1234567890abcdefghijklmnopqrstuvwxyzABC
1287
1291
  n = (n << 5) - n + s, n |= 0;
1288
1292
  }
1289
1293
  return `${n}`;
1290
- }, be = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, qn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1291
- const { id: o, type: i, purpose: s, value: r, created: a, modified: l, creator: c, ...f } = n;
1294
+ }, xe = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Gn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1295
+ const { id: o, type: i, purpose: s, value: r, created: a, modified: l, creator: f, ...p } = n;
1292
1296
  return {
1293
- id: o || `temp-${Wn(n)}`,
1297
+ id: o || `temp-${qn(n)}`,
1294
1298
  annotation: e,
1295
1299
  type: i,
1296
1300
  purpose: s,
1297
1301
  value: r,
1298
- creator: be(c),
1302
+ creator: xe(f),
1299
1303
  created: a ? new Date(a) : void 0,
1300
1304
  updated: l ? new Date(l) : void 0,
1301
- ...f
1305
+ ...p
1302
1306
  };
1303
- }), Gn = (t) => t.map((e) => {
1307
+ }), Qn = (t) => t.map((e) => {
1304
1308
  var n;
1305
1309
  const { annotation: o, created: i, updated: s, ...r } = e, a = {
1306
1310
  ...r,
@@ -1309,11 +1313,11 @@ const Fn = () => ({ isGuest: !0, id: Hn("1234567890abcdefghijklmnopqrstuvwxyzABC
1309
1313
  };
1310
1314
  return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
1311
1315
  });
1312
- zn();
1313
- const ko = (t, e) => ({
1314
- parse: (n) => Zn(n),
1315
- serialize: (n) => to(n, t, e)
1316
- }), Qn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Jn = (t) => {
1316
+ Fn();
1317
+ const Io = (t, e) => ({
1318
+ parse: (n) => to(n),
1319
+ serialize: (n) => eo(n, t, e)
1320
+ }), Jn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, Zn = (t) => {
1317
1321
  const {
1318
1322
  id: e,
1319
1323
  creator: n,
@@ -1324,7 +1328,7 @@ const ko = (t, e) => ({
1324
1328
  if (r.length === 0)
1325
1329
  return { error: Error(`No targets found for annotation: ${t.id}`) };
1326
1330
  const a = {
1327
- creator: be(n),
1331
+ creator: xe(n),
1328
1332
  created: o ? new Date(o) : void 0,
1329
1333
  updated: i ? new Date(i) : void 0,
1330
1334
  annotation: e,
@@ -1333,21 +1337,21 @@ const ko = (t, e) => ({
1333
1337
  styleClass: "styleClass" in r[0] ? r[0].styleClass : void 0
1334
1338
  };
1335
1339
  for (const l of r) {
1336
- const f = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((d, m) => {
1337
- switch (m.type) {
1340
+ const p = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((d, h) => {
1341
+ switch (h.type) {
1338
1342
  case "TextQuoteSelector":
1339
- d.quote = m.exact;
1343
+ d.quote = h.exact;
1340
1344
  break;
1341
1345
  case "TextPositionSelector":
1342
- d.start = m.start, d.end = m.end;
1346
+ d.start = h.start, d.end = h.end;
1343
1347
  break;
1344
1348
  }
1345
1349
  return d;
1346
1350
  }, {});
1347
- if (Qn(f))
1351
+ if (Jn(p))
1348
1352
  a.selector.push(
1349
1353
  {
1350
- ...f,
1354
+ ...p,
1351
1355
  id: l.id,
1352
1356
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1353
1357
  scope: l.scope
@@ -1355,21 +1359,21 @@ const ko = (t, e) => ({
1355
1359
  );
1356
1360
  else {
1357
1361
  const d = [
1358
- f.start ? void 0 : "TextPositionSelector",
1359
- f.quote ? void 0 : "TextQuoteSelector"
1362
+ p.start ? void 0 : "TextPositionSelector",
1363
+ p.quote ? void 0 : "TextQuoteSelector"
1360
1364
  ].filter(Boolean);
1361
1365
  return { error: Error(`Missing selector types: ${d.join(" and ")} for annotation: ${t.id}`) };
1362
1366
  }
1363
1367
  }
1364
1368
  return { parsed: a };
1365
- }, Zn = (t) => {
1366
- const e = t.id || ge(), {
1369
+ }, to = (t) => {
1370
+ const e = t.id || be(), {
1367
1371
  creator: n,
1368
1372
  created: o,
1369
1373
  modified: i,
1370
1374
  body: s,
1371
1375
  ...r
1372
- } = t, a = qn(s, e), l = Jn(t);
1376
+ } = t, a = Gn(s, e), l = Zn(t);
1373
1377
  return "error" in l ? { error: l.error } : {
1374
1378
  parsed: {
1375
1379
  ...r,
@@ -1378,29 +1382,29 @@ const ko = (t, e) => ({
1378
1382
  target: l.parsed
1379
1383
  }
1380
1384
  };
1381
- }, to = (t, e, n) => {
1385
+ }, eo = (t, e, n) => {
1382
1386
  const { bodies: o, target: i, ...s } = t, {
1383
1387
  selector: r,
1384
1388
  creator: a,
1385
1389
  created: l,
1386
- updated: c,
1387
- ...f
1388
- } = i, d = r.map((m) => {
1389
- const { id: p, quote: w, start: b, end: C, range: g } = m, { prefix: u, suffix: y } = _e(g, n), S = [{
1390
+ updated: f,
1391
+ ...p
1392
+ } = i, d = r.map((h) => {
1393
+ const { id: g, quote: b, start: A, end: C, range: m } = h, { prefix: c, suffix: y } = Ue(m, n), S = [{
1390
1394
  type: "TextQuoteSelector",
1391
- exact: w,
1392
- prefix: u,
1395
+ exact: b,
1396
+ prefix: c,
1393
1397
  suffix: y
1394
1398
  }, {
1395
1399
  type: "TextPositionSelector",
1396
- start: b,
1400
+ start: A,
1397
1401
  end: C
1398
1402
  }];
1399
1403
  return {
1400
- ...f,
1401
- id: p,
1402
- // @ts-expect-error: `scope` is not part of the core `TextAnnotationTarget` type
1403
- scope: "scope" in m ? m.scope : void 0,
1404
+ ...p,
1405
+ id: g,
1406
+ // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1407
+ scope: "scope" in h ? h.scope : void 0,
1404
1408
  source: e,
1405
1409
  selector: S
1406
1410
  };
@@ -1410,36 +1414,36 @@ const ko = (t, e) => ({
1410
1414
  "@context": "http://www.w3.org/ns/anno.jsonld",
1411
1415
  id: t.id,
1412
1416
  type: "Annotation",
1413
- body: Gn(t.bodies),
1417
+ body: Qn(t.bodies),
1414
1418
  creator: a,
1415
1419
  created: l == null ? void 0 : l.toISOString(),
1416
- modified: c == null ? void 0 : c.toISOString(),
1420
+ modified: f == null ? void 0 : f.toISOString(),
1417
1421
  target: d
1418
1422
  };
1419
1423
  };
1420
- function we(t, e, n = 0, o = t.length - 1, i = eo) {
1424
+ function ve(t, e, n = 0, o = t.length - 1, i = no) {
1421
1425
  for (; o > n; ) {
1422
1426
  if (o - n > 600) {
1423
- const l = o - n + 1, c = e - n + 1, f = Math.log(l), d = 0.5 * Math.exp(2 * f / 3), m = 0.5 * Math.sqrt(f * d * (l - d) / l) * (c - l / 2 < 0 ? -1 : 1), p = Math.max(n, Math.floor(e - c * d / l + m)), w = Math.min(o, Math.floor(e + (l - c) * d / l + m));
1424
- we(t, e, p, w, i);
1427
+ const l = o - n + 1, f = e - n + 1, p = Math.log(l), d = 0.5 * Math.exp(2 * p / 3), h = 0.5 * Math.sqrt(p * d * (l - d) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * d / l + h)), b = Math.min(o, Math.floor(e + (l - f) * d / l + h));
1428
+ ve(t, e, g, b, i);
1425
1429
  }
1426
1430
  const s = t[e];
1427
1431
  let r = n, a = o;
1428
- for (tt(t, n, e), i(t[o], s) > 0 && tt(t, n, o); r < a; ) {
1429
- for (tt(t, r, a), r++, a--; i(t[r], s) < 0; ) r++;
1432
+ for (ot(t, n, e), i(t[o], s) > 0 && ot(t, n, o); r < a; ) {
1433
+ for (ot(t, r, a), r++, a--; i(t[r], s) < 0; ) r++;
1430
1434
  for (; i(t[a], s) > 0; ) a--;
1431
1435
  }
1432
- i(t[n], s) === 0 ? tt(t, n, a) : (a++, tt(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);
1436
+ i(t[n], s) === 0 ? ot(t, n, a) : (a++, ot(t, a, o)), a <= e && (n = a + 1), e <= a && (o = a - 1);
1433
1437
  }
1434
1438
  }
1435
- function tt(t, e, n) {
1439
+ function ot(t, e, n) {
1436
1440
  const o = t[e];
1437
1441
  t[e] = t[n], t[n] = o;
1438
1442
  }
1439
- function eo(t, e) {
1443
+ function no(t, e) {
1440
1444
  return t < e ? -1 : t > e ? 1 : 0;
1441
1445
  }
1442
- class no {
1446
+ class oo {
1443
1447
  constructor(e = 9) {
1444
1448
  this._maxEntries = Math.max(4, e), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
1445
1449
  }
@@ -1449,12 +1453,12 @@ class no {
1449
1453
  search(e) {
1450
1454
  let n = this.data;
1451
1455
  const o = [];
1452
- if (!mt(e, n)) return o;
1456
+ if (!bt(e, n)) return o;
1453
1457
  const i = this.toBBox, s = [];
1454
1458
  for (; n; ) {
1455
1459
  for (let r = 0; r < n.children.length; r++) {
1456
1460
  const a = n.children[r], l = n.leaf ? i(a) : a;
1457
- mt(e, l) && (n.leaf ? o.push(a) : Bt(e, l) ? this._all(a, o) : s.push(a));
1461
+ bt(e, l) && (n.leaf ? o.push(a) : Nt(e, l) ? this._all(a, o) : s.push(a));
1458
1462
  }
1459
1463
  n = s.pop();
1460
1464
  }
@@ -1462,13 +1466,13 @@ class no {
1462
1466
  }
1463
1467
  collides(e) {
1464
1468
  let n = this.data;
1465
- if (!mt(e, n)) return !1;
1469
+ if (!bt(e, n)) return !1;
1466
1470
  const o = [];
1467
1471
  for (; n; ) {
1468
1472
  for (let i = 0; i < n.children.length; i++) {
1469
1473
  const s = n.children[i], r = n.leaf ? this.toBBox(s) : s;
1470
- if (mt(e, r)) {
1471
- if (n.leaf || Bt(e, r)) return !0;
1474
+ if (bt(e, r)) {
1475
+ if (n.leaf || Nt(e, r)) return !0;
1472
1476
  o.push(s);
1473
1477
  }
1474
1478
  }
@@ -1501,20 +1505,20 @@ class no {
1501
1505
  return e && this._insert(e, this.data.height - 1), this;
1502
1506
  }
1503
1507
  clear() {
1504
- return this.data = J([]), this;
1508
+ return this.data = tt([]), this;
1505
1509
  }
1506
1510
  remove(e, n) {
1507
1511
  if (!e) return this;
1508
1512
  let o = this.data;
1509
1513
  const i = this.toBBox(e), s = [], r = [];
1510
- let a, l, c;
1514
+ let a, l, f;
1511
1515
  for (; o || s.length; ) {
1512
- if (o || (o = s.pop(), l = s[s.length - 1], a = r.pop(), c = !0), o.leaf) {
1513
- const f = oo(e, o.children, n);
1514
- if (f !== -1)
1515
- return o.children.splice(f, 1), s.push(o), this._condense(s), this;
1516
+ if (o || (o = s.pop(), l = s[s.length - 1], a = r.pop(), f = !0), o.leaf) {
1517
+ const p = io(e, o.children, n);
1518
+ if (p !== -1)
1519
+ return o.children.splice(p, 1), s.push(o), this._condense(s), this;
1516
1520
  }
1517
- !c && !o.leaf && Bt(o, i) ? (s.push(o), r.push(a), a = 0, l = o, o = o.children[0]) : l ? (a++, o = l.children[a], c = !1) : o = null;
1521
+ !f && !o.leaf && Nt(o, i) ? (s.push(o), r.push(a), a = 0, l = o, o = o.children[0]) : l ? (a++, o = l.children[a], f = !1) : o = null;
1518
1522
  }
1519
1523
  return this;
1520
1524
  }
@@ -1543,26 +1547,26 @@ class no {
1543
1547
  const s = o - n + 1;
1544
1548
  let r = this._maxEntries, a;
1545
1549
  if (s <= r)
1546
- return a = J(e.slice(n, o + 1)), Q(a, this.toBBox), a;
1547
- i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = J([]), a.leaf = !1, a.height = i;
1548
- const l = Math.ceil(s / r), c = l * Math.ceil(Math.sqrt(r));
1549
- ne(e, n, o, c, this.compareMinX);
1550
- for (let f = n; f <= o; f += c) {
1551
- const d = Math.min(f + c - 1, o);
1552
- ne(e, f, d, l, this.compareMinY);
1553
- for (let m = f; m <= d; m += l) {
1554
- const p = Math.min(m + l - 1, d);
1555
- a.children.push(this._build(e, m, p, i - 1));
1550
+ return a = tt(e.slice(n, o + 1)), Z(a, this.toBBox), a;
1551
+ i || (i = Math.ceil(Math.log(s) / Math.log(r)), r = Math.ceil(s / Math.pow(r, i - 1))), a = tt([]), a.leaf = !1, a.height = i;
1552
+ const l = Math.ceil(s / r), f = l * Math.ceil(Math.sqrt(r));
1553
+ se(e, n, o, f, this.compareMinX);
1554
+ for (let p = n; p <= o; p += f) {
1555
+ const d = Math.min(p + f - 1, o);
1556
+ se(e, p, d, l, this.compareMinY);
1557
+ for (let h = p; h <= d; h += l) {
1558
+ const g = Math.min(h + l - 1, d);
1559
+ a.children.push(this._build(e, h, g, i - 1));
1556
1560
  }
1557
1561
  }
1558
- return Q(a, this.toBBox), a;
1562
+ return Z(a, this.toBBox), a;
1559
1563
  }
1560
1564
  _chooseSubtree(e, n, o, i) {
1561
1565
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1562
1566
  let s = 1 / 0, r = 1 / 0, a;
1563
1567
  for (let l = 0; l < n.children.length; l++) {
1564
- const c = n.children[l], f = Mt(c), d = ro(e, c) - f;
1565
- d < r ? (r = d, s = f < s ? f : s, a = c) : d === r && f < s && (s = f, a = c);
1568
+ const f = n.children[l], p = It(f), d = ao(e, f) - p;
1569
+ d < r ? (r = d, s = p < s ? p : s, a = f) : d === r && p < s && (s = p, a = f);
1566
1570
  }
1567
1571
  n = a || n.children[0];
1568
1572
  }
@@ -1570,7 +1574,7 @@ class no {
1570
1574
  }
1571
1575
  _insert(e, n, o) {
1572
1576
  const i = o ? e : this.toBBox(e), s = [], r = this._chooseSubtree(i, this.data, n, s);
1573
- for (r.children.push(e), it(r, i); n >= 0 && s[n].children.length > this._maxEntries; )
1577
+ for (r.children.push(e), at(r, i); n >= 0 && s[n].children.length > this._maxEntries; )
1574
1578
  this._split(s, n), n--;
1575
1579
  this._adjustParentBBoxes(i, s, n);
1576
1580
  }
@@ -1578,95 +1582,95 @@ class no {
1578
1582
  _split(e, n) {
1579
1583
  const o = e[n], i = o.children.length, s = this._minEntries;
1580
1584
  this._chooseSplitAxis(o, s, i);
1581
- const r = this._chooseSplitIndex(o, s, i), a = J(o.children.splice(r, o.children.length - r));
1582
- a.height = o.height, a.leaf = o.leaf, Q(o, this.toBBox), Q(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
1585
+ const r = this._chooseSplitIndex(o, s, i), a = tt(o.children.splice(r, o.children.length - r));
1586
+ a.height = o.height, a.leaf = o.leaf, Z(o, this.toBBox), Z(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
1583
1587
  }
1584
1588
  _splitRoot(e, n) {
1585
- this.data = J([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, Q(this.data, this.toBBox);
1589
+ this.data = tt([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, Z(this.data, this.toBBox);
1586
1590
  }
1587
1591
  _chooseSplitIndex(e, n, o) {
1588
1592
  let i, s = 1 / 0, r = 1 / 0;
1589
1593
  for (let a = n; a <= o - n; a++) {
1590
- const l = ot(e, 0, a, this.toBBox), c = ot(e, a, o, this.toBBox), f = ao(l, c), d = Mt(l) + Mt(c);
1591
- f < s ? (s = f, i = a, r = d < r ? d : r) : f === s && d < r && (r = d, i = a);
1594
+ const l = rt(e, 0, a, this.toBBox), f = rt(e, a, o, this.toBBox), p = co(l, f), d = It(l) + It(f);
1595
+ p < s ? (s = p, i = a, r = d < r ? d : r) : p === s && d < r && (r = d, i = a);
1592
1596
  }
1593
1597
  return i || o - n;
1594
1598
  }
1595
1599
  // sorts node children by the best axis for split
1596
1600
  _chooseSplitAxis(e, n, o) {
1597
- const i = e.leaf ? this.compareMinX : io, s = e.leaf ? this.compareMinY : so, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
1601
+ const i = e.leaf ? this.compareMinX : so, s = e.leaf ? this.compareMinY : ro, r = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, s);
1598
1602
  r < a && e.children.sort(i);
1599
1603
  }
1600
1604
  // total margin of all possible split distributions where each node is at least m full
1601
1605
  _allDistMargin(e, n, o, i) {
1602
1606
  e.children.sort(i);
1603
- const s = this.toBBox, r = ot(e, 0, n, s), a = ot(e, o - n, o, s);
1604
- let l = gt(r) + gt(a);
1605
- for (let c = n; c < o - n; c++) {
1606
- const f = e.children[c];
1607
- it(r, e.leaf ? s(f) : f), l += gt(r);
1607
+ const s = this.toBBox, r = rt(e, 0, n, s), a = rt(e, o - n, o, s);
1608
+ let l = yt(r) + yt(a);
1609
+ for (let f = n; f < o - n; f++) {
1610
+ const p = e.children[f];
1611
+ at(r, e.leaf ? s(p) : p), l += yt(r);
1608
1612
  }
1609
- for (let c = o - n - 1; c >= n; c--) {
1610
- const f = e.children[c];
1611
- it(a, e.leaf ? s(f) : f), l += gt(a);
1613
+ for (let f = o - n - 1; f >= n; f--) {
1614
+ const p = e.children[f];
1615
+ at(a, e.leaf ? s(p) : p), l += yt(a);
1612
1616
  }
1613
1617
  return l;
1614
1618
  }
1615
1619
  _adjustParentBBoxes(e, n, o) {
1616
1620
  for (let i = o; i >= 0; i--)
1617
- it(n[i], e);
1621
+ at(n[i], e);
1618
1622
  }
1619
1623
  _condense(e) {
1620
1624
  for (let n = e.length - 1, o; n >= 0; n--)
1621
- e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : Q(e[n], this.toBBox);
1625
+ e[n].children.length === 0 ? n > 0 ? (o = e[n - 1].children, o.splice(o.indexOf(e[n]), 1)) : this.clear() : Z(e[n], this.toBBox);
1622
1626
  }
1623
1627
  }
1624
- function oo(t, e, n) {
1628
+ function io(t, e, n) {
1625
1629
  if (!n) return e.indexOf(t);
1626
1630
  for (let o = 0; o < e.length; o++)
1627
1631
  if (n(t, e[o])) return o;
1628
1632
  return -1;
1629
1633
  }
1630
- function Q(t, e) {
1631
- ot(t, 0, t.children.length, e, t);
1634
+ function Z(t, e) {
1635
+ rt(t, 0, t.children.length, e, t);
1632
1636
  }
1633
- function ot(t, e, n, o, i) {
1634
- i || (i = J(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1637
+ function rt(t, e, n, o, i) {
1638
+ i || (i = tt(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1635
1639
  for (let s = e; s < n; s++) {
1636
1640
  const r = t.children[s];
1637
- it(i, t.leaf ? o(r) : r);
1641
+ at(i, t.leaf ? o(r) : r);
1638
1642
  }
1639
1643
  return i;
1640
1644
  }
1641
- function it(t, e) {
1645
+ function at(t, e) {
1642
1646
  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;
1643
1647
  }
1644
- function io(t, e) {
1648
+ function so(t, e) {
1645
1649
  return t.minX - e.minX;
1646
1650
  }
1647
- function so(t, e) {
1651
+ function ro(t, e) {
1648
1652
  return t.minY - e.minY;
1649
1653
  }
1650
- function Mt(t) {
1654
+ function It(t) {
1651
1655
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1652
1656
  }
1653
- function gt(t) {
1657
+ function yt(t) {
1654
1658
  return t.maxX - t.minX + (t.maxY - t.minY);
1655
1659
  }
1656
- function ro(t, e) {
1660
+ function ao(t, e) {
1657
1661
  return (Math.max(e.maxX, t.maxX) - Math.min(e.minX, t.minX)) * (Math.max(e.maxY, t.maxY) - Math.min(e.minY, t.minY));
1658
1662
  }
1659
- function ao(t, e) {
1663
+ function co(t, e) {
1660
1664
  const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
1661
1665
  return Math.max(0, i - n) * Math.max(0, s - o);
1662
1666
  }
1663
- function Bt(t, e) {
1667
+ function Nt(t, e) {
1664
1668
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1665
1669
  }
1666
- function mt(t, e) {
1670
+ function bt(t, e) {
1667
1671
  return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
1668
1672
  }
1669
- function J(t) {
1673
+ function tt(t) {
1670
1674
  return {
1671
1675
  children: t,
1672
1676
  height: 1,
@@ -1677,15 +1681,15 @@ function J(t) {
1677
1681
  maxY: -1 / 0
1678
1682
  };
1679
1683
  }
1680
- function ne(t, e, n, o, i) {
1684
+ function se(t, e, n, o, i) {
1681
1685
  const s = [e, n];
1682
1686
  for (; s.length; ) {
1683
1687
  if (n = s.pop(), e = s.pop(), n - e <= o) continue;
1684
1688
  const r = e + Math.ceil((n - e) / o / 2) * o;
1685
- we(t, r, e, n, i), s.push(e, r, r, n);
1689
+ ve(t, r, e, n, i), s.push(e, r, r, n);
1686
1690
  }
1687
1691
  }
1688
- let co = () => ({
1692
+ let lo = () => ({
1689
1693
  emit(t, ...e) {
1690
1694
  for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
1691
1695
  o[n](...e);
@@ -1699,22 +1703,22 @@ let co = () => ({
1699
1703
  };
1700
1704
  }
1701
1705
  });
1702
- const lo = (t, e) => {
1703
- const n = new no(), o = /* @__PURE__ */ new Map(), i = co(), s = (y, S) => {
1704
- const E = y.selector.flatMap((R) => {
1705
- const T = F([R]) ? R.range : ce(R, e).range;
1706
+ const uo = (t, e) => {
1707
+ const n = new oo(), o = /* @__PURE__ */ new Map(), i = lo(), s = (y, S) => {
1708
+ const x = y.selector.flatMap((O) => {
1709
+ const T = F([O]) ? O.range : ue(O, e).range;
1706
1710
  return Array.from(T.getClientRects());
1707
- }), O = Ye(E).map((R) => je(R, S));
1708
- return O.map((R) => {
1709
- const { x: T, y: x, width: h, height: v } = R;
1711
+ }), L = Xe(x).map((O) => He(O, S));
1712
+ return L.map((O) => {
1713
+ const { x: T, y: M, width: w, height: v } = O;
1710
1714
  return {
1711
1715
  minX: T,
1712
- minY: x,
1713
- maxX: T + h,
1714
- maxY: x + v,
1716
+ minY: M,
1717
+ maxX: T + w,
1718
+ maxY: M + v,
1715
1719
  annotation: {
1716
1720
  id: y.annotation,
1717
- rects: O
1721
+ rects: L
1718
1722
  }
1719
1723
  };
1720
1724
  });
@@ -1722,169 +1726,172 @@ const lo = (t, e) => {
1722
1726
  n.clear(), o.clear();
1723
1727
  }, l = (y) => {
1724
1728
  const S = s(y, e.getBoundingClientRect());
1725
- S.forEach((E) => n.insert(E)), o.set(y.annotation, S);
1726
- }, c = (y) => {
1727
- const S = o.get(y.annotation);
1728
- S && (S.forEach((E) => n.remove(E)), o.delete(y.annotation));
1729
+ S.forEach((x) => n.insert(x)), o.set(y.annotation, S);
1729
1730
  }, f = (y) => {
1730
- c(y), l(y);
1731
+ const S = o.get(y.annotation);
1732
+ S && (S.forEach((x) => n.remove(x)), o.delete(y.annotation));
1733
+ }, p = (y) => {
1734
+ f(y), l(y);
1731
1735
  }, d = (y, S = !0) => {
1732
1736
  S && a();
1733
- const E = e.getBoundingClientRect(), O = y.map((T) => ({ target: T, rects: s(T, E) }));
1734
- O.forEach(({ target: T, rects: x }) => o.set(T.annotation, x));
1735
- const R = O.flatMap(({ rects: T }) => T);
1736
- n.load(R);
1737
- }, m = (y, S, E = !1) => {
1738
- const O = n.search({
1737
+ const x = e.getBoundingClientRect(), L = y.map((T) => ({ target: T, rects: s(T, x) }));
1738
+ L.forEach(({ target: T, rects: M }) => o.set(T.annotation, M));
1739
+ const O = L.flatMap(({ rects: T }) => T);
1740
+ n.load(O);
1741
+ }, h = (y, S, x = !1) => {
1742
+ const L = n.search({
1739
1743
  minX: y,
1740
1744
  minY: S,
1741
1745
  maxX: y,
1742
1746
  maxY: S
1743
- }), R = (T) => T.annotation.rects.reduce((x, h) => x + h.width * h.height, 0);
1744
- return O.length > 0 ? (O.sort((T, x) => R(T) - R(x)), E ? O.map((T) => T.annotation.id) : [O[0].annotation.id]) : [];
1745
- }, p = (y) => {
1746
- const S = w(y);
1747
+ }), O = (T) => T.annotation.rects.reduce((M, w) => M + w.width * w.height, 0);
1748
+ return L.length > 0 ? (L.sort((T, M) => O(T) - O(M)), x ? L.map((T) => T.annotation.id) : [L[0].annotation.id]) : [];
1749
+ }, g = (y) => {
1750
+ const S = b(y);
1747
1751
  if (S.length === 0)
1748
1752
  return;
1749
- let E = S[0].left, O = S[0].top, R = S[0].right, T = S[0].bottom;
1750
- for (let x = 1; x < S.length; x++) {
1751
- const h = S[x];
1752
- E = Math.min(E, h.left), O = Math.min(O, h.top), R = Math.max(R, h.right), T = Math.max(T, h.bottom);
1753
+ let x = S[0].left, L = S[0].top, O = S[0].right, T = S[0].bottom;
1754
+ for (let M = 1; M < S.length; M++) {
1755
+ const w = S[M];
1756
+ x = Math.min(x, w.left), L = Math.min(L, w.top), O = Math.max(O, w.right), T = Math.max(T, w.bottom);
1753
1757
  }
1754
- return new DOMRect(E, O, R - E, T - O);
1755
- }, w = (y) => {
1758
+ return new DOMRect(x, L, O - x, T - L);
1759
+ }, b = (y) => {
1756
1760
  const S = o.get(y);
1757
1761
  return S[0] ? S[0].annotation.rects : [];
1758
1762
  };
1759
1763
  return {
1760
1764
  all: r,
1761
1765
  clear: a,
1762
- getAt: m,
1763
- getAnnotationBounds: p,
1764
- getAnnotationRects: w,
1765
- getIntersecting: (y, S, E, O) => {
1766
- const R = n.search({ minX: y, minY: S, maxX: E, maxY: O }), T = new Set(R.map((x) => x.annotation.id));
1767
- return Array.from(T).map((x) => ({
1768
- annotation: t.getAnnotation(x),
1769
- rects: w(x)
1770
- })).filter((x) => !!x.annotation);
1766
+ getAt: h,
1767
+ getAnnotationBounds: g,
1768
+ getAnnotationRects: b,
1769
+ getIntersecting: (y, S, x, L) => {
1770
+ const O = n.search({ minX: y, minY: S, maxX: x, maxY: L }), T = new Set(O.map((M) => M.annotation.id));
1771
+ return Array.from(T).map((M) => ({
1772
+ annotation: t.getAnnotation(M),
1773
+ rects: b(M)
1774
+ })).filter((M) => !!M.annotation);
1771
1775
  },
1772
1776
  insert: l,
1773
1777
  recalculate: () => {
1774
1778
  d(t.all().map((y) => y.target), !0), i.emit("recalculate");
1775
1779
  },
1776
- remove: c,
1780
+ remove: f,
1777
1781
  set: d,
1778
1782
  size: () => n.all().length,
1779
- update: f,
1783
+ update: p,
1780
1784
  on: (y, S) => i.on(y, S)
1781
1785
  };
1782
- }, uo = (t, e) => {
1783
- const n = Nn(), o = lo(n, t), i = xn(n);
1786
+ }, fo = (t, e) => {
1787
+ const n = _n(), o = uo(n, t), i = En(n);
1784
1788
  i.setUserSelectAction(e);
1785
- const s = vn(n), r = Vn(), a = (u, y = k.LOCAL) => {
1786
- const S = vt(u, t), E = F(S.target.selector);
1787
- return E && n.addAnnotation(S, y), E;
1788
- }, l = (u, y = !0, S = k.LOCAL) => {
1789
- const E = u.map((R) => vt(R, t)), O = E.filter((R) => !F(R.target.selector));
1790
- return O.length > 0 ? (console.warn("Could not revive all targets for these annotations:", O), n.bulkAddAnnotation(E, y, S), O) : (n.bulkAddAnnotation(E, y, S), []);
1791
- }, c = (u, y = k.LOCAL) => {
1792
- const S = u.map((O) => vt(O, t)), E = S.filter((O) => !F(O.target.selector));
1793
- return E.length > 0 && console.warn("Could not revive all targets for these annotations:", E), S.forEach((O) => {
1794
- n.getAnnotation(O.id) ? n.updateAnnotation(O, y) : n.addAnnotation(O, y);
1795
- }), E;
1796
- }, f = (u, y = k.LOCAL) => {
1797
- const S = bt(u, t);
1789
+ const s = xn(n), r = Yn(), a = (c, y = k.LOCAL) => {
1790
+ const S = Et(c, t), x = F(S.target.selector);
1791
+ return x && n.addAnnotation(S, y), x;
1792
+ }, l = (c, y = !0, S = k.LOCAL) => {
1793
+ const x = c.map((O) => Et(O, t)), L = x.filter((O) => !F(O.target.selector));
1794
+ return n.bulkAddAnnotation(x, y, S), L;
1795
+ }, f = (c, y = k.LOCAL) => {
1796
+ const S = c.map((L) => Et(L, t)), x = S.filter((L) => !F(L.target.selector));
1797
+ return S.forEach((L) => {
1798
+ n.getAnnotation(L.id) ? n.updateAnnotation(L, y) : n.addAnnotation(L, y);
1799
+ }), x;
1800
+ }, p = (c, y = k.LOCAL) => {
1801
+ const S = At(c, t);
1798
1802
  n.updateTarget(S, y);
1799
- }, d = (u, y = k.LOCAL) => {
1800
- const S = u.map((E) => bt(E, t));
1803
+ }, d = (c, y = k.LOCAL) => {
1804
+ const S = c.map((x) => At(x, t));
1801
1805
  n.bulkUpdateTargets(S, y);
1802
- }, m = (u, y, S) => {
1803
- const E = o.getAt(u, y, !!S).map((R) => n.getAnnotation(R)), O = S ? E.filter(S) : E;
1804
- return O.length > 0 ? O[0] : void 0;
1805
- }, p = (u, y, S, E = 5) => {
1806
- const O = o.getAnnotationRects(u);
1807
- if (O.length !== 0) {
1806
+ };
1807
+ function h(c, y, S, x) {
1808
+ const L = S || !!x, O = o.getAt(c, y, L).map((M) => n.getAnnotation(M)), T = x ? O.filter(x) : O;
1809
+ if (T.length !== 0)
1810
+ return S ? T : T[0];
1811
+ }
1812
+ const g = (c, y, S, x = 5) => {
1813
+ const L = o.getAnnotationRects(c);
1814
+ if (L.length !== 0) {
1808
1815
  if (y && S) {
1809
- const R = O.find(({ top: T, right: x, bottom: h, left: v }) => y >= v - E && y <= x + E && S >= T - E && S <= h + E);
1810
- if (R) return R;
1816
+ const O = L.find(({ top: T, right: M, bottom: w, left: v }) => y >= v - x && y <= M + x && S >= T - x && S <= w + x);
1817
+ if (O) return O;
1811
1818
  }
1812
- return o.getAnnotationBounds(u);
1819
+ return o.getAnnotationBounds(c);
1813
1820
  }
1814
- }, w = (u, y, S, E) => o.getIntersecting(u, y, S, E), b = (u) => o.getAnnotationRects(u), C = () => o.recalculate(), g = (u) => o.on("recalculate", u);
1815
- return n.observe(({ changes: u }) => {
1816
- const y = (u.deleted || []).filter((O) => F(O.target.selector)), S = (u.created || []).filter((O) => F(O.target.selector)), E = (u.updated || []).filter((O) => F(O.newValue.target.selector));
1817
- (y == null ? void 0 : y.length) > 0 && y.forEach((O) => o.remove(O.target)), S.length > 0 && o.set(S.map((O) => O.target), !1), (E == null ? void 0 : E.length) > 0 && E.forEach(({ newValue: O }) => o.update(O.target));
1821
+ }, b = (c, y, S, x) => o.getIntersecting(c, y, S, x), A = (c) => o.getAnnotationRects(c), C = () => o.recalculate(), m = (c) => o.on("recalculate", c);
1822
+ return n.observe(({ changes: c }) => {
1823
+ const y = (c.deleted || []).filter((L) => F(L.target.selector)), S = (c.created || []).filter((L) => F(L.target.selector)), x = (c.updated || []).filter((L) => F(L.newValue.target.selector));
1824
+ (y == null ? void 0 : y.length) > 0 && y.forEach((L) => o.remove(L.target)), S.length > 0 && o.set(S.map((L) => L.target), !1), (x == null ? void 0 : x.length) > 0 && x.forEach(({ newValue: L }) => o.update(L.target));
1818
1825
  }), {
1819
1826
  store: {
1820
1827
  ...n,
1821
1828
  addAnnotation: a,
1822
1829
  bulkAddAnnotation: l,
1823
1830
  bulkUpdateTargets: d,
1824
- bulkUpsertAnnotations: c,
1825
- getAnnotationBounds: p,
1826
- getAnnotationRects: b,
1827
- getIntersecting: w,
1828
- getAt: m,
1831
+ bulkUpsertAnnotations: f,
1832
+ getAnnotationBounds: g,
1833
+ getAnnotationRects: A,
1834
+ getIntersecting: b,
1835
+ getAt: h,
1829
1836
  recalculatePositions: C,
1830
- onRecalculatePositions: g,
1831
- updateTarget: f
1837
+ onRecalculatePositions: m,
1838
+ updateTarget: p
1832
1839
  },
1833
1840
  selection: i,
1834
1841
  hover: s,
1835
1842
  viewport: r
1836
1843
  };
1837
- }, fo = () => {
1844
+ }, ho = () => {
1838
1845
  const t = document.createElement("canvas");
1839
1846
  t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
1840
1847
  const e = t.getContext("2d");
1841
1848
  return e.scale(2, 2), e.translate(0.5, 0.5), t;
1842
- }, ho = (t, e = {}) => {
1843
- const n = fo(), o = n.getContext("2d");
1849
+ }, po = (t, e = {}) => {
1850
+ const n = ho(), o = n.getContext("2d");
1844
1851
  document.body.appendChild(n);
1845
- const i = /* @__PURE__ */ new Map(), s = (f) => Array.from(i.entries()).filter(([d, m]) => m.presenceKey === f.presenceKey).map(([d, m]) => d);
1846
- return t.on("selectionChange", (f, d) => {
1847
- s(f).forEach((p) => i.delete(p)), d && d.forEach((p) => i.set(p, f));
1852
+ const i = /* @__PURE__ */ new Map(), s = (p) => Array.from(i.entries()).filter(([d, h]) => h.presenceKey === p.presenceKey).map(([d, h]) => d);
1853
+ return t.on("selectionChange", (p, d) => {
1854
+ s(p).forEach((g) => i.delete(g)), d && d.forEach((g) => i.set(g, p));
1848
1855
  }), {
1849
1856
  clear: () => {
1850
- const { width: f, height: d } = n;
1851
- o.clearRect(-0.5, -0.5, f + 1, d + 1);
1857
+ const { width: p, height: d } = n;
1858
+ o.clearRect(-0.5, -0.5, p + 1, d + 1);
1852
1859
  },
1853
1860
  destroy: () => {
1854
1861
  n.remove();
1855
1862
  },
1856
- paint: (f, d, m) => {
1863
+ paint: (p, d, h) => {
1857
1864
  e.font && (o.font = e.font);
1858
- const p = i.get(f.annotation.id);
1859
- if (p) {
1860
- const { height: w } = f.rects[0], b = f.rects[0].x + d.left, C = f.rects[0].y + d.top;
1861
- o.fillStyle = p.appearance.color, o.fillRect(b - 2, C - 2.5, 2, w + 5);
1862
- const g = o.measureText(p.appearance.label), u = g.width + 6, y = g.actualBoundingBoxAscent + g.actualBoundingBoxDescent + 8, S = g.fontBoundingBoxAscent ? 8 : 6.5;
1863
- return o.fillRect(b - 2, C - 2.5 - y, u, y), o.fillStyle = "#fff", o.fillText(p.appearance.label, b + 1, C - S), {
1864
- fill: p.appearance.color,
1865
- fillOpacity: m ? 0.45 : 0.18
1865
+ const g = i.get(p.annotation.id);
1866
+ if (g) {
1867
+ const { height: b } = p.rects[0], A = p.rects[0].x + d.left, C = p.rects[0].y + d.top;
1868
+ o.fillStyle = g.appearance.color, o.fillRect(A - 2, C - 2.5, 2, b + 5);
1869
+ const m = o.measureText(g.appearance.label), c = m.width + 6, y = m.actualBoundingBoxAscent + m.actualBoundingBoxDescent + 8, S = m.fontBoundingBoxAscent ? 8 : 6.5;
1870
+ return o.fillRect(A - 2, C - 2.5 - y, c, y), o.fillStyle = "#fff", o.fillText(g.appearance.label, A + 1, C - S), {
1871
+ fill: g.appearance.color,
1872
+ fillOpacity: h ? 0.45 : 0.18
1866
1873
  };
1867
1874
  }
1868
1875
  },
1869
1876
  reset: () => {
1870
1877
  n.width = 2 * window.innerWidth, n.height = 2 * window.innerHeight;
1871
- const f = n.getContext("2d");
1872
- f.scale(2, 2), f.translate(0.5, 0.5);
1878
+ const p = n.getContext("2d");
1879
+ p.scale(2, 2), p.translate(0.5, 0.5);
1873
1880
  }
1874
1881
  };
1875
- }, kt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1876
- function It(t, e, n, o) {
1882
+ }, _t = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1883
+ function Ut(t, e, n, o) {
1877
1884
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1878
1885
  }
1879
- function et(t, e, n, o) {
1886
+ function it(t, e, n, o) {
1880
1887
  t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
1881
1888
  }
1882
- function ve(t, e) {
1889
+ function Ee(t, e) {
1883
1890
  const n = e.slice(0, e.length - 1);
1884
1891
  for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
1885
1892
  return n;
1886
1893
  }
1887
- function Ae(t) {
1894
+ function Se(t) {
1888
1895
  typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
1889
1896
  const e = t.split(",");
1890
1897
  let n = e.lastIndexOf("");
@@ -1892,14 +1899,14 @@ function Ae(t) {
1892
1899
  e[n - 1] += ",", e.splice(n, 1), n = e.lastIndexOf("");
1893
1900
  return e;
1894
1901
  }
1895
- function po(t, e) {
1902
+ function go(t, e) {
1896
1903
  const n = t.length >= e.length ? t : e, o = t.length >= e.length ? e : t;
1897
1904
  let i = !0;
1898
1905
  for (let s = 0; s < n.length; s++)
1899
1906
  o.indexOf(n[s]) === -1 && (i = !1);
1900
1907
  return i;
1901
1908
  }
1902
- const at = {
1909
+ const dt = {
1903
1910
  backspace: 8,
1904
1911
  "⌫": 8,
1905
1912
  tab: 9,
@@ -1944,9 +1951,9 @@ const at = {
1944
1951
  ".": 190,
1945
1952
  "/": 191,
1946
1953
  "`": 192,
1947
- "-": kt ? 173 : 189,
1948
- "=": kt ? 61 : 187,
1949
- ";": kt ? 59 : 186,
1954
+ "-": _t ? 173 : 189,
1955
+ "=": _t ? 61 : 187,
1956
+ ";": _t ? 59 : 186,
1950
1957
  "'": 222,
1951
1958
  "[": 219,
1952
1959
  "]": 221,
@@ -1967,7 +1974,7 @@ const at = {
1967
1974
  "⌘": 91,
1968
1975
  cmd: 91,
1969
1976
  command: 91
1970
- }, Dt = {
1977
+ }, Kt = {
1971
1978
  16: "shiftKey",
1972
1979
  18: "altKey",
1973
1980
  17: "ctrlKey",
@@ -1976,29 +1983,29 @@ const at = {
1976
1983
  ctrlKey: 17,
1977
1984
  altKey: 18,
1978
1985
  metaKey: 91
1979
- }, V = {
1986
+ }, K = {
1980
1987
  16: !1,
1981
1988
  18: !1,
1982
1989
  17: !1,
1983
1990
  91: !1
1984
1991
  }, N = {};
1985
1992
  for (let t = 1; t < 20; t++)
1986
- at["f".concat(t)] = 111 + t;
1987
- let I = [], rt = null, xe = "all";
1988
- const z = /* @__PURE__ */ new Map(), lt = (t) => at[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), go = (t) => Object.keys(at).find((e) => at[e] === t), mo = (t) => Object.keys(j).find((e) => j[e] === t);
1989
- function Ee(t) {
1990
- xe = t || "all";
1993
+ dt["f".concat(t)] = 111 + t;
1994
+ let I = [], lt = null, Ce = "all";
1995
+ const z = /* @__PURE__ */ new Map(), ft = (t) => dt[t.toLowerCase()] || j[t.toLowerCase()] || t.toUpperCase().charCodeAt(0), mo = (t) => Object.keys(dt).find((e) => dt[e] === t), yo = (t) => Object.keys(j).find((e) => j[e] === t);
1996
+ function Le(t) {
1997
+ Ce = t || "all";
1991
1998
  }
1992
- function ct() {
1993
- return xe || "all";
1994
- }
1995
- function yo() {
1996
- return I.slice(0);
1999
+ function ut() {
2000
+ return Ce || "all";
1997
2001
  }
1998
2002
  function bo() {
1999
- return I.map((t) => go(t) || mo(t) || String.fromCharCode(t));
2003
+ return I.slice(0);
2000
2004
  }
2001
2005
  function wo() {
2006
+ return I.map((t) => mo(t) || yo(t) || String.fromCharCode(t));
2007
+ }
2008
+ function Ao() {
2002
2009
  const t = [];
2003
2010
  return Object.keys(N).forEach((e) => {
2004
2011
  N[e].forEach((n) => {
@@ -2012,12 +2019,12 @@ function wo() {
2012
2019
  scope: i,
2013
2020
  shortcut: r,
2014
2021
  mods: s,
2015
- keys: o.split("+").map((a) => lt(a))
2022
+ keys: o.split("+").map((a) => ft(a))
2016
2023
  });
2017
2024
  });
2018
2025
  }), t;
2019
2026
  }
2020
- function vo(t) {
2027
+ function xo(t) {
2021
2028
  const e = t.target || t.srcElement, {
2022
2029
  tagName: n
2023
2030
  } = e;
@@ -2025,12 +2032,12 @@ function vo(t) {
2025
2032
  const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(e.type);
2026
2033
  return (e.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !e.readOnly) && (o = !1), o;
2027
2034
  }
2028
- function Ao(t) {
2029
- return typeof t == "string" && (t = lt(t)), I.indexOf(t) !== -1;
2035
+ function vo(t) {
2036
+ return typeof t == "string" && (t = ft(t)), I.indexOf(t) !== -1;
2030
2037
  }
2031
- function xo(t, e) {
2038
+ function Eo(t, e) {
2032
2039
  let n, o;
2033
- t || (t = ct());
2040
+ t || (t = ut());
2034
2041
  for (const i in N)
2035
2042
  if (Object.prototype.hasOwnProperty.call(N, i))
2036
2043
  for (n = N[i], o = 0; o < n.length; )
@@ -2038,34 +2045,34 @@ function xo(t, e) {
2038
2045
  let {
2039
2046
  element: a
2040
2047
  } = r;
2041
- return Pt(a);
2048
+ return Ht(a);
2042
2049
  }) : o++;
2043
- ct() === t && Ee(e || "all");
2050
+ ut() === t && Le(e || "all");
2044
2051
  }
2045
- function Eo(t) {
2052
+ function So(t) {
2046
2053
  let e = t.keyCode || t.which || t.charCode;
2047
2054
  const n = I.indexOf(e);
2048
- if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in V) {
2049
- V[e] = !1;
2055
+ if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in K) {
2056
+ K[e] = !1;
2050
2057
  for (const o in j) j[o] === e && (P[o] = !1);
2051
2058
  }
2052
2059
  }
2053
- function Se(t) {
2060
+ function Te(t) {
2054
2061
  if (typeof t > "u")
2055
2062
  Object.keys(N).forEach((i) => {
2056
- Array.isArray(N[i]) && N[i].forEach((s) => yt(s)), delete N[i];
2057
- }), Pt(null);
2063
+ Array.isArray(N[i]) && N[i].forEach((s) => wt(s)), delete N[i];
2064
+ }), Ht(null);
2058
2065
  else if (Array.isArray(t))
2059
2066
  t.forEach((i) => {
2060
- i.key && yt(i);
2067
+ i.key && wt(i);
2061
2068
  });
2062
2069
  else if (typeof t == "object")
2063
- t.key && yt(t);
2070
+ t.key && wt(t);
2064
2071
  else if (typeof t == "string") {
2065
2072
  for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
2066
2073
  n[o - 1] = arguments[o];
2067
2074
  let [i, s] = n;
2068
- typeof i == "function" && (s = i, i = ""), yt({
2075
+ typeof i == "function" && (s = i, i = ""), wt({
2069
2076
  key: t,
2070
2077
  scope: i,
2071
2078
  method: s,
@@ -2073,110 +2080,110 @@ function Se(t) {
2073
2080
  });
2074
2081
  }
2075
2082
  }
2076
- const yt = (t) => {
2083
+ const wt = (t) => {
2077
2084
  let {
2078
2085
  key: e,
2079
2086
  scope: n,
2080
2087
  method: o,
2081
2088
  splitKey: i = "+"
2082
2089
  } = t;
2083
- Ae(e).forEach((r) => {
2084
- const a = r.split(i), l = a.length, c = a[l - 1], f = c === "*" ? "*" : lt(c);
2085
- if (!N[f]) return;
2086
- n || (n = ct());
2087
- const d = l > 1 ? ve(j, a) : [], m = [];
2088
- N[f] = N[f].filter((p) => {
2089
- const b = (o ? p.method === o : !0) && p.scope === n && po(p.mods, d);
2090
- return b && m.push(p.element), !b;
2091
- }), m.forEach((p) => Pt(p));
2090
+ Se(e).forEach((r) => {
2091
+ const a = r.split(i), l = a.length, f = a[l - 1], p = f === "*" ? "*" : ft(f);
2092
+ if (!N[p]) return;
2093
+ n || (n = ut());
2094
+ const d = l > 1 ? Ee(j, a) : [], h = [];
2095
+ N[p] = N[p].filter((g) => {
2096
+ const A = (o ? g.method === o : !0) && g.scope === n && go(g.mods, d);
2097
+ return A && h.push(g.element), !A;
2098
+ }), h.forEach((g) => Ht(g));
2092
2099
  });
2093
2100
  };
2094
- function oe(t, e, n, o) {
2101
+ function re(t, e, n, o) {
2095
2102
  if (e.element !== o)
2096
2103
  return;
2097
2104
  let i;
2098
2105
  if (e.scope === n || e.scope === "all") {
2099
2106
  i = e.mods.length > 0;
2100
- for (const s in V)
2101
- Object.prototype.hasOwnProperty.call(V, s) && (!V[s] && e.mods.indexOf(+s) > -1 || V[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2102
- (e.mods.length === 0 && !V[16] && !V[18] && !V[17] && !V[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2107
+ for (const s in K)
2108
+ Object.prototype.hasOwnProperty.call(K, s) && (!K[s] && e.mods.indexOf(+s) > -1 || K[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2109
+ (e.mods.length === 0 && !K[16] && !K[18] && !K[17] && !K[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2103
2110
  }
2104
2111
  }
2105
- function ie(t, e) {
2112
+ function ae(t, e) {
2106
2113
  const n = N["*"];
2107
2114
  let o = t.keyCode || t.which || t.charCode;
2108
2115
  if (!P.filter.call(this, t)) return;
2109
2116
  if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
2110
- const l = Dt[a];
2117
+ const l = Kt[a];
2111
2118
  t[a] && I.indexOf(l) === -1 ? I.push(l) : !t[a] && I.indexOf(l) > -1 ? I.splice(I.indexOf(l), 1) : a === "metaKey" && t[a] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(l))));
2112
- }), o in V) {
2113
- V[o] = !0;
2119
+ }), o in K) {
2120
+ K[o] = !0;
2114
2121
  for (const a in j)
2115
2122
  j[a] === o && (P[a] = !0);
2116
2123
  if (!n) return;
2117
2124
  }
2118
- for (const a in V)
2119
- Object.prototype.hasOwnProperty.call(V, a) && (V[a] = t[Dt[a]]);
2120
- t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), V[17] = !0, V[18] = !0);
2121
- const i = ct();
2125
+ for (const a in K)
2126
+ Object.prototype.hasOwnProperty.call(K, a) && (K[a] = t[Kt[a]]);
2127
+ t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), K[17] = !0, K[18] = !0);
2128
+ const i = ut();
2122
2129
  if (n)
2123
2130
  for (let a = 0; a < n.length; a++)
2124
- n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && oe(t, n[a], i, e);
2131
+ n[a].scope === i && (t.type === "keydown" && n[a].keydown || t.type === "keyup" && n[a].keyup) && re(t, n[a], i, e);
2125
2132
  if (!(o in N)) return;
2126
2133
  const s = N[o], r = s.length;
2127
2134
  for (let a = 0; a < r; a++)
2128
2135
  if ((t.type === "keydown" && s[a].keydown || t.type === "keyup" && s[a].keyup) && s[a].key) {
2129
2136
  const l = s[a], {
2130
- splitKey: c
2131
- } = l, f = l.key.split(c), d = [];
2132
- for (let m = 0; m < f.length; m++)
2133
- d.push(lt(f[m]));
2134
- d.sort().join("") === I.sort().join("") && oe(t, l, i, e);
2137
+ splitKey: f
2138
+ } = l, p = l.key.split(f), d = [];
2139
+ for (let h = 0; h < p.length; h++)
2140
+ d.push(ft(p[h]));
2141
+ d.sort().join("") === I.sort().join("") && re(t, l, i, e);
2135
2142
  }
2136
2143
  }
2137
2144
  function P(t, e, n) {
2138
2145
  I = [];
2139
- const o = Ae(t);
2140
- let i = [], s = "all", r = document, a = 0, l = !1, c = !0, f = "+", d = !1, m = !1;
2141
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (c = e.keydown), e.capture !== void 0 && (d = e.capture), typeof e.splitKey == "string" && (f = e.splitKey), e.single === !0 && (m = !0)), typeof e == "string" && (s = e), m && Se(t, s); a < o.length; a++)
2142
- t = o[a].split(f), i = [], t.length > 1 && (i = ve(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : lt(t), t in N || (N[t] = []), N[t].push({
2146
+ const o = Se(t);
2147
+ let i = [], s = "all", r = document, a = 0, l = !1, f = !0, p = "+", d = !1, h = !1;
2148
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (r = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (d = e.capture), typeof e.splitKey == "string" && (p = e.splitKey), e.single === !0 && (h = !0)), typeof e == "string" && (s = e), h && Te(t, s); a < o.length; a++)
2149
+ t = o[a].split(p), i = [], t.length > 1 && (i = Ee(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : ft(t), t in N || (N[t] = []), N[t].push({
2143
2150
  keyup: l,
2144
- keydown: c,
2151
+ keydown: f,
2145
2152
  scope: s,
2146
2153
  mods: i,
2147
2154
  shortcut: o[a],
2148
2155
  method: n,
2149
2156
  key: o[a],
2150
- splitKey: f,
2157
+ splitKey: p,
2151
2158
  element: r
2152
2159
  });
2153
2160
  if (typeof r < "u" && window) {
2154
2161
  if (!z.has(r)) {
2155
- const p = function() {
2156
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2157
- return ie(b, r);
2158
- }, w = function() {
2159
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2160
- ie(b, r), Eo(b);
2162
+ const g = function() {
2163
+ let A = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2164
+ return ae(A, r);
2165
+ }, b = function() {
2166
+ let A = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2167
+ ae(A, r), So(A);
2161
2168
  };
2162
2169
  z.set(r, {
2163
- keydownListener: p,
2164
- keyupListenr: w,
2170
+ keydownListener: g,
2171
+ keyupListenr: b,
2165
2172
  capture: d
2166
- }), It(r, "keydown", p, d), It(r, "keyup", w, d);
2173
+ }), Ut(r, "keydown", g, d), Ut(r, "keyup", b, d);
2167
2174
  }
2168
- if (!rt) {
2169
- const p = () => {
2175
+ if (!lt) {
2176
+ const g = () => {
2170
2177
  I = [];
2171
2178
  };
2172
- rt = {
2173
- listener: p,
2179
+ lt = {
2180
+ listener: g,
2174
2181
  capture: d
2175
- }, It(window, "focus", p, d);
2182
+ }, Ut(window, "focus", g, d);
2176
2183
  }
2177
2184
  }
2178
2185
  }
2179
- function So(t) {
2186
+ function Co(t) {
2180
2187
  let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
2181
2188
  Object.keys(N).forEach((n) => {
2182
2189
  N[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
@@ -2184,7 +2191,7 @@ function So(t) {
2184
2191
  });
2185
2192
  });
2186
2193
  }
2187
- function Pt(t) {
2194
+ function Ht(t) {
2188
2195
  const e = Object.values(N).flat();
2189
2196
  if (e.findIndex((o) => {
2190
2197
  let {
@@ -2197,7 +2204,7 @@ function Pt(t) {
2197
2204
  keyupListenr: i,
2198
2205
  capture: s
2199
2206
  } = z.get(t) || {};
2200
- o && i && (et(t, "keyup", i, s), et(t, "keydown", o, s), z.delete(t));
2207
+ o && i && (it(t, "keyup", i, s), it(t, "keydown", o, s), z.delete(t));
2201
2208
  }
2202
2209
  if ((e.length <= 0 || z.size <= 0) && (Object.keys(z).forEach((i) => {
2203
2210
  const {
@@ -2205,246 +2212,254 @@ function Pt(t) {
2205
2212
  keyupListenr: r,
2206
2213
  capture: a
2207
2214
  } = z.get(i) || {};
2208
- s && r && (et(i, "keyup", r, a), et(i, "keydown", s, a), z.delete(i));
2209
- }), z.clear(), Object.keys(N).forEach((i) => delete N[i]), rt)) {
2215
+ s && r && (it(i, "keyup", r, a), it(i, "keydown", s, a), z.delete(i));
2216
+ }), z.clear(), Object.keys(N).forEach((i) => delete N[i]), lt)) {
2210
2217
  const {
2211
2218
  listener: i,
2212
2219
  capture: s
2213
- } = rt;
2214
- et(window, "focus", i, s), rt = null;
2220
+ } = lt;
2221
+ it(window, "focus", i, s), lt = null;
2215
2222
  }
2216
2223
  }
2217
- const Nt = {
2218
- getPressedKeyString: bo,
2219
- setScope: Ee,
2220
- getScope: ct,
2221
- deleteScope: xo,
2222
- getPressedKeyCodes: yo,
2223
- getAllKeyCodes: wo,
2224
- isPressed: Ao,
2225
- filter: vo,
2226
- trigger: So,
2227
- unbind: Se,
2228
- keyMap: at,
2224
+ const Dt = {
2225
+ getPressedKeyString: wo,
2226
+ setScope: Le,
2227
+ getScope: ut,
2228
+ deleteScope: Eo,
2229
+ getPressedKeyCodes: bo,
2230
+ getAllKeyCodes: Ao,
2231
+ isPressed: vo,
2232
+ filter: xo,
2233
+ trigger: Co,
2234
+ unbind: Te,
2235
+ keyMap: dt,
2229
2236
  modifier: j,
2230
- modifierMap: Dt
2237
+ modifierMap: Kt
2231
2238
  };
2232
- for (const t in Nt)
2233
- Object.prototype.hasOwnProperty.call(Nt, t) && (P[t] = Nt[t]);
2239
+ for (const t in Dt)
2240
+ Object.prototype.hasOwnProperty.call(Dt, t) && (P[t] = Dt[t]);
2234
2241
  if (typeof window < "u") {
2235
2242
  const t = window.hotkeys;
2236
2243
  P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
2237
2244
  }
2238
- async function Co(t, e, n = () => !1) {
2245
+ async function Lo(t, e, n = () => !1) {
2239
2246
  do {
2240
2247
  if (await t(), await n()) break;
2241
2248
  const o = e;
2242
2249
  await new Promise((i) => setTimeout(i, Math.max(0, o)));
2243
2250
  } while (!await n());
2244
2251
  }
2245
- const se = 300, Ce = ["up", "down", "left", "right"], Le = Be ? "⌘+a" : "ctrl+a", Lo = [
2246
- ...Ce.map((t) => `shift+${t}`),
2247
- Le
2252
+ const ce = 300, Oe = ["up", "down", "left", "right"], Re = ke ? "⌘+a" : "ctrl+a", To = [
2253
+ ...Oe.map((t) => `shift+${t}`),
2254
+ Re
2248
2255
  ], Oo = (t, e, n) => {
2249
2256
  const { store: o, selection: i } = e;
2250
2257
  let s;
2251
- const r = (x) => s = x;
2252
- let a;
2253
- const l = (x) => a = x;
2254
- let c, f, d, m = !0;
2255
- const p = (x) => {
2256
- m = x, b.clear(), x || (c = void 0, d = void 0);
2257
- }, w = (x) => {
2258
- m && f !== !1 && (c = nt(x.target) ? void 0 : {
2259
- annotation: ge(),
2258
+ const { annotatingEnabled: r, offsetReferenceSelector: a, selectionMode: l } = n, f = (u) => s = u;
2259
+ let p;
2260
+ const d = (u) => p = u;
2261
+ let h, g, b, A = r;
2262
+ const C = (u) => {
2263
+ A = u, c.clear(), u || (h = void 0, g = void 0, b = void 0);
2264
+ }, m = (u) => {
2265
+ A && g !== !1 && (h = st(u.target) ? void 0 : {
2266
+ annotation: be(),
2260
2267
  selector: [],
2261
2268
  creator: s,
2262
2269
  created: /* @__PURE__ */ new Date()
2263
2270
  });
2264
- }, b = Kt((x) => {
2265
- if (!m) return;
2266
- const h = document.getSelection();
2267
- if (!(h != null && h.anchorNode))
2271
+ }, c = Pt((u) => {
2272
+ if (!A) return;
2273
+ const E = document.getSelection();
2274
+ if (!(E != null && E.anchorNode))
2268
2275
  return;
2269
- if (nt(h.anchorNode)) {
2270
- c = void 0;
2276
+ if (st(E.anchorNode)) {
2277
+ h = void 0;
2271
2278
  return;
2272
2279
  }
2273
- const v = x.timeStamp - ((d == null ? void 0 : d.timeStamp) || x.timeStamp);
2274
- if ((d == null ? void 0 : d.type) === "pointerdown" && (v < 1e3 && !c || h.isCollapsed && v < se) && w(d || x), !c) return;
2275
- if (h.isCollapsed) {
2276
- o.getAnnotation(c.annotation) && (i.clear(), o.deleteAnnotation(c.annotation));
2280
+ const B = u.timeStamp - ((b == null ? void 0 : b.timeStamp) || u.timeStamp);
2281
+ if ((b == null ? void 0 : b.type) === "pointerdown" && (B < 1e3 && !h || E.isCollapsed && B < ce) && m(b || u), !h) return;
2282
+ if (E.isCollapsed) {
2283
+ o.getAnnotation(h.annotation) && (i.clear(), o.deleteAnnotation(h.annotation));
2277
2284
  return;
2278
2285
  }
2279
- const A = h.getRangeAt(0), L = $e(A, t);
2280
- if (De(L)) return;
2281
- const M = Ne(L.cloneRange());
2282
- (M.length !== c.selector.length || M.some((K, Y) => {
2283
- var dt;
2284
- return K.toString() !== ((dt = c.selector[Y]) == null ? void 0 : dt.quote);
2285
- })) && (c = {
2286
- ...c,
2287
- selector: M.map((K) => Xe(K, t, n)),
2286
+ const R = E.getRangeAt(0), U = je(R, t);
2287
+ if (Ve(U)) return;
2288
+ const _ = _e(U.cloneRange());
2289
+ (_.length !== h.selector.length || _.some((W, G) => {
2290
+ var vt;
2291
+ return W.toString() !== ((vt = h.selector[G]) == null ? void 0 : vt.quote);
2292
+ })) && (h = {
2293
+ ...h,
2294
+ selector: _.map((W) => Pe(W, t, a)),
2288
2295
  updated: /* @__PURE__ */ new Date()
2289
- }, o.getAnnotation(c.annotation) ? o.updateTarget(c, k.LOCAL) : i.clear());
2290
- }, 10), C = (x) => {
2291
- nt(x.target) || (d = At(x), f = d.button === 0);
2292
- }, g = () => {
2293
- o.getAnnotation(c.annotation) ? o.updateTarget(c) : o.addAnnotation({
2294
- id: c.annotation,
2295
- bodies: [],
2296
- target: c
2297
- });
2298
- }, u = async (x) => {
2299
- if (nt(x.target) || !f) return;
2300
- const h = () => {
2301
- const { x: A, y: L } = t.getBoundingClientRect(), M = x.target instanceof Node && t.contains(x.target) && o.getAt(x.clientX - A, x.clientY - L, a);
2302
- if (M) {
2303
- const { selected: B } = i;
2304
- (B.length !== 1 || B[0].id !== M.id) && i.userSelect(M.id, x);
2296
+ }, o.getAnnotation(h.annotation) ? o.updateTarget(h, k.LOCAL) : i.clear());
2297
+ }, 10), y = (u) => {
2298
+ st(u.target) || (b = St(u), g = b.button === 0);
2299
+ }, S = async (u) => {
2300
+ if (st(u.target) || !g) return;
2301
+ const E = () => {
2302
+ const { x: R, y: U } = t.getBoundingClientRect(), _ = u.target instanceof Node && t.contains(u.target) && o.getAt(u.clientX - R, u.clientY - U, l === "all", p);
2303
+ if (_) {
2304
+ const { selected: ht } = i, W = new Set(ht.map((nt) => nt.id)), G = Array.isArray(_) ? _.map((nt) => nt.id) : [_.id];
2305
+ (W.size !== G.length || !G.every((nt) => W.has(nt))) && i.userSelect(G, u);
2305
2306
  } else
2306
2307
  i.clear();
2307
2308
  };
2308
- if (x.timeStamp - d.timeStamp < se) {
2309
- await y();
2310
- const A = document.getSelection();
2311
- if (A != null && A.isCollapsed) {
2312
- c = void 0, h();
2309
+ if (u.timeStamp - b.timeStamp < ce) {
2310
+ await x();
2311
+ const R = document.getSelection();
2312
+ if (R != null && R.isCollapsed) {
2313
+ h = void 0, E();
2313
2314
  return;
2314
2315
  }
2315
2316
  }
2316
- c && c.selector.length > 0 && (i.clear(), g(), i.userSelect(c.annotation, At(x)));
2317
- }, y = async () => {
2318
- const x = document.getSelection();
2319
- let h = !1, v = x == null ? void 0 : x.isCollapsed;
2320
- const A = () => v || h, L = 1;
2321
- return setTimeout(() => h = !0, 50), Co(() => v = x == null ? void 0 : x.isCollapsed, L, A);
2322
- }, S = (x) => {
2323
- const h = document.getSelection();
2324
- h != null && h.isCollapsed || ((!c || c.selector.length === 0) && b(x), g(), i.userSelect(c.annotation, At(x)));
2325
- }, E = (x) => {
2326
- m && x.key === "Shift" && c && (document.getSelection().isCollapsed || (i.clear(), g(), i.userSelect(c.annotation, ut(x))));
2327
- }, O = (x) => {
2328
- const h = () => setTimeout(() => {
2329
- (c == null ? void 0 : c.selector.length) > 0 && (i.clear(), o.addAnnotation({
2330
- id: c.annotation,
2317
+ h && h.selector.length > 0 && (i.clear(), w(), i.userSelect(h.annotation, St(u)));
2318
+ }, x = async () => {
2319
+ const u = document.getSelection();
2320
+ let E = !1, B = u == null ? void 0 : u.isCollapsed;
2321
+ const R = () => B || E, U = 1;
2322
+ return setTimeout(() => E = !0, 50), Lo(() => B = u == null ? void 0 : u.isCollapsed, U, R);
2323
+ }, L = (u) => {
2324
+ const E = document.getSelection();
2325
+ E != null && E.isCollapsed || ((!h || h.selector.length === 0) && c(u), w(), i.userSelect(h.annotation, St(u)));
2326
+ }, O = (u) => {
2327
+ A && u.key === "Shift" && h && (document.getSelection().isCollapsed || (i.clear(), w(), i.userSelect(h.annotation, pt(u))));
2328
+ }, T = (u) => {
2329
+ const E = () => setTimeout(() => {
2330
+ (h == null ? void 0 : h.selector.length) > 0 && (i.clear(), o.addAnnotation({
2331
+ id: h.annotation,
2331
2332
  bodies: [],
2332
- target: c
2333
- }), i.userSelect(c.annotation, ut(x))), document.removeEventListener("selectionchange", h);
2333
+ target: h
2334
+ }), i.userSelect(h.annotation, pt(u))), document.removeEventListener("selectionchange", E);
2334
2335
  }, 100);
2335
- document.addEventListener("selectionchange", h), w(x);
2336
+ document.addEventListener("selectionchange", E), m(u);
2336
2337
  };
2337
- P(Lo.join(","), { element: t, keydown: !0, keyup: !1 }, (x) => {
2338
- x.repeat || (d = ut(x));
2339
- }), P(Le, { keydown: !0, keyup: !1 }, (x) => {
2340
- d = ut(x), O(x);
2338
+ P(To.join(","), { element: t, keydown: !0, keyup: !1 }, (u) => {
2339
+ u.repeat || (b = pt(u));
2340
+ }), P(Re, { keydown: !0, keyup: !1 }, (u) => {
2341
+ b = pt(u), T(u);
2341
2342
  });
2342
- const R = (x) => {
2343
- x.repeat || x.target !== t && x.target !== document.body || (c = void 0, i.clear());
2343
+ const M = (u) => {
2344
+ u.repeat || u.target !== t && u.target !== document.body || (h = void 0, i.clear());
2345
+ };
2346
+ P(Oe.join(","), { keydown: !0, keyup: !1 }, M);
2347
+ const w = () => {
2348
+ const u = o.getAnnotation(h.annotation);
2349
+ if (!u) {
2350
+ o.addAnnotation({
2351
+ id: h.annotation,
2352
+ bodies: [],
2353
+ target: h
2354
+ });
2355
+ return;
2356
+ }
2357
+ const { target: { updated: E } } = u, { updated: B } = h;
2358
+ (!E || !B || E < B) && o.updateTarget(h);
2344
2359
  };
2345
- return P(Ce.join(","), { keydown: !0, keyup: !1 }, R), document.addEventListener("pointerdown", C), document.addEventListener("pointerup", u), document.addEventListener("contextmenu", S), t.addEventListener("keyup", E), t.addEventListener("selectstart", w), document.addEventListener("selectionchange", b), {
2360
+ return document.addEventListener("pointerdown", y), document.addEventListener("pointerup", S), document.addEventListener("contextmenu", L), t.addEventListener("keyup", O), t.addEventListener("selectstart", m), document.addEventListener("selectionchange", c), {
2346
2361
  destroy: () => {
2347
- c = void 0, f = void 0, d = void 0, b.clear(), document.removeEventListener("pointerdown", C), document.removeEventListener("pointerup", u), document.removeEventListener("contextmenu", S), t.removeEventListener("keyup", E), t.removeEventListener("selectstart", w), document.removeEventListener("selectionchange", b), P.unbind();
2362
+ h = void 0, g = void 0, b = void 0, c.clear(), document.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", S), document.removeEventListener("contextmenu", L), t.removeEventListener("keyup", O), t.removeEventListener("selectstart", m), document.removeEventListener("selectionchange", c), P.unbind();
2348
2363
  },
2349
- setFilter: l,
2350
- setUser: r,
2351
- setAnnotatingEnabled: p
2364
+ setFilter: d,
2365
+ setUser: f,
2366
+ setAnnotatingEnabled: C
2352
2367
  };
2353
- }, To = (t, e) => ({
2368
+ }, Ro = (t, e) => ({
2354
2369
  ...t,
2355
2370
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
2356
2371
  user: t.user || e.user
2357
- }), re = "SPANS", Io = (t, e = {}) => {
2358
- Me(t), ke(t);
2359
- const n = To(e, {
2372
+ }), le = "SPANS", No = (t, e = {}) => {
2373
+ Be(t), Ie(t);
2374
+ const n = Ro(e, {
2360
2375
  annotatingEnabled: !0,
2361
- user: Fn()
2362
- }), o = uo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Dn(r), l = Kn(o, a, n.adapter);
2363
- let c = n.user;
2364
- const f = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : re : n.renderer || re, d = f === "SPANS" ? pn(t, o, s) : f === "CSS_HIGHLIGHTS" ? un(t, o, s) : f === "CANVAS" ? tn(t, o, s) : void 0;
2376
+ user: Wn()
2377
+ }), o = fo(t, n.userSelectAction), { selection: i, viewport: s } = o, r = o.store, a = Vn(r), l = Kn(o, a, n.adapter);
2378
+ let f = n.user;
2379
+ const p = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : le : n.renderer || le, d = p === "SPANS" ? gn(t, o, s) : p === "CSS_HIGHLIGHTS" ? fn(t, o, s) : p === "CANVAS" ? en(t, o, s) : void 0;
2365
2380
  if (!d)
2366
- throw `Unknown renderer implementation: ${f}`;
2367
- console.debug(`Using ${f} renderer`), n.style && d.setStyle(n.style);
2368
- const m = Oo(t, o, n.offsetReferenceSelector);
2369
- m.setUser(c), m.setAnnotatingEnabled(n.annotatingEnabled);
2370
- const p = Xn(o, a, n.adapter), w = () => c, b = (E) => {
2371
- m.setAnnotatingEnabled(
2372
- E === void 0 ? !0 : E
2381
+ throw `Unknown renderer implementation: ${p}`;
2382
+ console.debug(`Using ${p} renderer`), n.style && d.setStyle(n.style);
2383
+ const h = Oo(t, o, n);
2384
+ h.setUser(f), h.setAnnotatingEnabled(n.annotatingEnabled);
2385
+ const g = Pn(o, a, n.adapter), b = () => f, A = (x) => {
2386
+ h.setAnnotatingEnabled(
2387
+ x === void 0 ? !0 : x
2373
2388
  );
2374
- }, C = (E) => {
2375
- d.setFilter(E), m.setFilter(E);
2376
- }, g = (E) => {
2377
- c = E, m.setUser(E);
2378
- }, u = (E) => {
2379
- E && (d.setPainter(ho(E, n.presence)), E.on("selectionChange", () => d.redraw()));
2380
- }, y = (E) => {
2381
- E ? i.setSelected(E) : i.clear();
2389
+ }, C = (x) => {
2390
+ d.setFilter(x), h.setFilter(x);
2391
+ }, m = (x) => {
2392
+ f = x, h.setUser(x);
2393
+ }, c = (x) => {
2394
+ x && (d.setPainter(po(x, n.presence)), x.on("selectionChange", () => d.redraw()));
2395
+ }, y = (x) => {
2396
+ x ? i.setSelected(x) : i.clear();
2382
2397
  };
2383
2398
  return {
2384
- ...p,
2399
+ ...g,
2385
2400
  destroy: () => {
2386
- d.destroy(), m.destroy(), a.destroy();
2401
+ d.destroy(), h.destroy(), a.destroy();
2387
2402
  },
2388
2403
  element: t,
2389
- getUser: w,
2390
- setAnnotatingEnabled: b,
2404
+ getUser: b,
2405
+ setAnnotatingEnabled: A,
2391
2406
  setFilter: C,
2392
2407
  setStyle: d.setStyle.bind(d),
2393
2408
  redraw: d.redraw.bind(d),
2394
- setUser: g,
2409
+ setUser: m,
2395
2410
  setSelected: y,
2396
- setPresenceProvider: u,
2411
+ setPresenceProvider: c,
2397
2412
  setVisible: d.setVisible.bind(d),
2398
2413
  on: l.on,
2399
2414
  off: l.off,
2400
- scrollIntoView: He(t, r),
2415
+ scrollIntoView: ze(t, r),
2401
2416
  state: o
2402
2417
  };
2403
2418
  };
2404
2419
  export {
2405
- wt as DEFAULT_SELECTED_STYLE,
2406
- W as DEFAULT_STYLE,
2407
- ae as NOT_ANNOTATABLE_CLASS,
2408
- Z as NOT_ANNOTATABLE_SELECTOR,
2420
+ xt as DEFAULT_SELECTED_STYLE,
2421
+ q as DEFAULT_STYLE,
2422
+ de as NOT_ANNOTATABLE_CLASS,
2423
+ et as NOT_ANNOTATABLE_SELECTOR,
2409
2424
  k as Origin,
2410
- An as UserSelectAction,
2411
- ko as W3CTextFormat,
2412
- Me as cancelSingleClickEvents,
2413
- ut as cloneKeyboardEvent,
2414
- At as clonePointerEvent,
2415
- Bo as createBody,
2416
- tn as createCanvasRenderer,
2417
- un as createHighlightsRenderer,
2418
- ho as createPresencePainter,
2419
- dn as createRenderer,
2425
+ vn as UserSelectAction,
2426
+ Io as W3CTextFormat,
2427
+ Be as cancelSingleClickEvents,
2428
+ pt as cloneKeyboardEvent,
2429
+ St as clonePointerEvent,
2430
+ ko as createBody,
2431
+ en as createCanvasRenderer,
2432
+ fn as createHighlightsRenderer,
2433
+ po as createPresencePainter,
2434
+ un as createRenderer,
2420
2435
  Oo as createSelectionHandler,
2421
- pn as createSpansRenderer,
2422
- Io as createTextAnnotator,
2423
- uo as createTextAnnotatorState,
2424
- Mo as denormalizeRectWithOffset,
2425
- To as fillDefaults,
2426
- _e as getQuoteContext,
2427
- _t as getRangeAnnotatableContents,
2428
- Be as isMac,
2429
- nt as isNotAnnotatable,
2430
- Re as isRangeAnnotatable,
2436
+ gn as createSpansRenderer,
2437
+ No as createTextAnnotator,
2438
+ fo as createTextAnnotatorState,
2439
+ Bo as denormalizeRectWithOffset,
2440
+ Ro as fillDefaults,
2441
+ Ue as getQuoteContext,
2442
+ Vt as getRangeAnnotatableContents,
2443
+ ke as isMac,
2444
+ st as isNotAnnotatable,
2445
+ Me as isRangeAnnotatable,
2431
2446
  F as isRevived,
2432
- De as isWhitespaceOrEmpty,
2433
- Ye as mergeClientRects,
2434
- je as normalizeRectWithOffset,
2435
- ze as paint,
2436
- Zn as parseW3CTextAnnotation,
2437
- ke as programmaticallyFocusable,
2438
- Pe as rangeContains,
2439
- Xe as rangeToSelector,
2440
- vt as reviveAnnotation,
2441
- ce as reviveSelector,
2442
- bt as reviveTarget,
2443
- He as scrollIntoView,
2444
- to as serializeW3CTextAnnotation,
2445
- Ne as splitAnnotatableRanges,
2446
- Ro as toDomRectList,
2447
- $e as trimRangeToContainer,
2448
- Ue as whitespaceOrEmptyRegex
2447
+ Ve as isWhitespaceOrEmpty,
2448
+ Xe as mergeClientRects,
2449
+ He as normalizeRectWithOffset,
2450
+ Fe as paint,
2451
+ to as parseW3CTextAnnotation,
2452
+ Ie as programmaticallyFocusable,
2453
+ $e as rangeContains,
2454
+ Pe as rangeToSelector,
2455
+ Et as reviveAnnotation,
2456
+ ue as reviveSelector,
2457
+ At as reviveTarget,
2458
+ ze as scrollIntoView,
2459
+ eo as serializeW3CTextAnnotation,
2460
+ _e as splitAnnotatableRanges,
2461
+ Mo as toDomRectList,
2462
+ je as trimRangeToContainer,
2463
+ De as whitespaceOrEmptyRegex
2449
2464
  };
2450
2465
  //# sourceMappingURL=text-annotator.es.js.map