@soomo/text-annotator 3.0.0-staging.37 → 3.0.0-staging.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,24 +8,24 @@ const q = {
8
8
  var s, a;
9
9
  const r = n ? typeof n == "function" ? n(e.annotation, e.state, i) || ((s = e.state) != null && s.selected ? gt : q) : n : (a = e.state) != null && a.selected ? gt : q;
10
10
  return o && o.paint(e, t) || r;
11
- }, ne = "not-annotatable", X = `.${ne}`, Ce = (e) => {
11
+ }, ne = "not-annotatable", $ = `.${ne}`, Se = (e) => {
12
12
  var n;
13
13
  const t = e.commonAncestorContainer;
14
- return t instanceof HTMLElement ? !t.closest(X) : !((n = t.parentElement) != null && n.closest(X));
15
- }, xe = function* (e) {
14
+ return t instanceof HTMLElement ? !t.closest($) : !((n = t.parentElement) != null && n.closest($));
15
+ }, Ce = function* (e) {
16
16
  const t = document.createNodeIterator(
17
17
  e.commonAncestorContainer,
18
18
  NodeFilter.SHOW_ELEMENT,
19
- (o) => o instanceof HTMLElement && o.classList.contains(ne) && !o.parentElement.closest(X) && e.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
19
+ (o) => o instanceof HTMLElement && o.classList.contains(ne) && !o.parentElement.closest($) && e.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
20
20
  );
21
21
  let n;
22
22
  for (; n = t.nextNode(); )
23
23
  n instanceof HTMLElement && (yield n);
24
- }, Ee = (e) => {
25
- if (!Ce(e)) return [];
24
+ }, xe = (e) => {
25
+ if (!Se(e)) return [];
26
26
  const t = [];
27
27
  let n = null;
28
- for (const o of xe(e)) {
28
+ for (const o of Ce(e)) {
29
29
  let i;
30
30
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = e.cloneRange(), i.setEndBefore(o)), i.collapsed || t.push(i), n = o;
31
31
  }
@@ -36,20 +36,20 @@ const q = {
36
36
  return t.length > 0 ? t : [e];
37
37
  }, kt = (e) => {
38
38
  const t = e.cloneContents();
39
- return t.querySelectorAll(X).forEach((n) => n.remove()), t;
40
- }, Le = (e) => e.addEventListener("click", (t) => {
39
+ return t.querySelectorAll($).forEach((n) => n.remove()), t;
40
+ }, Ee = (e) => e.addEventListener("click", (t) => {
41
41
  // Allow clicks within not-annotatable elements
42
- !t.target.closest(X) && !t.target.closest("a") && t.preventDefault();
43
- }), Te = (e) => {
42
+ !t.target.closest($) && !t.target.closest("a") && t.preventDefault();
43
+ }), Le = (e) => {
44
44
  !e.hasAttribute("tabindex") && e.tabIndex < 0 && e.setAttribute("tabindex", "-1"), e.classList.add("no-focus-outline");
45
45
  }, Nt = (e, t = 10) => {
46
46
  let n;
47
47
  return (...o) => {
48
48
  clearTimeout(n), n = setTimeout(() => e.apply(void 0, o), t);
49
49
  };
50
- }, vo = (e) => {
50
+ }, So = (e) => {
51
51
  const t = e.cloneContents();
52
- return t.querySelectorAll(X).forEach((n) => n.remove()), t;
52
+ return t.querySelectorAll($).forEach((n) => n.remove()), t;
53
53
  }, Dt = (e, t) => {
54
54
  const n = document.createNodeIterator(t);
55
55
  let o = 0, i = n.nextNode();
@@ -64,7 +64,7 @@ const q = {
64
64
  for (let i = 0; i < e + 1; i++)
65
65
  o = n.nextNode();
66
66
  return o;
67
- }, Me = (e) => {
67
+ }, Te = (e) => {
68
68
  const {
69
69
  commonAncestorContainer: t,
70
70
  startContainer: n,
@@ -72,32 +72,32 @@ const q = {
72
72
  endContainer: i,
73
73
  endOffset: r
74
74
  } = e, s = Array.from(t.childNodes).map((l) => {
75
- const m = l.cloneNode(!0);
76
- return l.nodeName === "CANVAS" ? l : m;
75
+ const g = l.cloneNode(!0);
76
+ return l.nodeName === "CANVAS" ? l : g;
77
77
  }), a = Dt(n, t), d = Dt(i, t), f = () => {
78
78
  const l = t;
79
79
  l.replaceChildren(...s);
80
- const m = yt(a, l), c = yt(d, l);
81
- return e.setStart(m, o), e.setEnd(c, r), e;
82
- }, g = (l) => {
83
- const m = document.createElement("SPAN");
84
- return l.surroundContents(m), m;
80
+ const g = yt(a, l), c = yt(d, l);
81
+ return e.setStart(g, o), e.setEnd(c, r), e;
82
+ }, h = (l) => {
83
+ const g = document.createElement("SPAN");
84
+ return l.surroundContents(g), g;
85
85
  };
86
86
  if (n === i)
87
87
  throw "Not implemented";
88
88
  {
89
89
  const l = document.createRange();
90
90
  l.selectNodeContents(n), l.setStart(n, o);
91
- const m = g(l), c = document.createRange();
91
+ const g = h(l), c = document.createRange();
92
92
  c.selectNode(i), c.setEnd(i, r);
93
- const S = g(c), w = Be(e).reverse().map((p) => {
94
- var A;
93
+ const A = h(c), b = Me(e).reverse().map((p) => {
94
+ var w;
95
95
  const u = document.createElement("SPAN");
96
- return (A = p.parentNode) == null || A.insertBefore(u, p), u.appendChild(p), u;
96
+ return (w = p.parentNode) == null || w.insertBefore(u, p), u.appendChild(p), u;
97
97
  });
98
- return { unwrap: f, nodes: [m, ...w, S] };
98
+ return { unwrap: f, nodes: [g, ...b, A] };
99
99
  }
100
- }, Be = (e) => {
100
+ }, Me = (e) => {
101
101
  const {
102
102
  commonAncestorContainer: t,
103
103
  startContainer: n,
@@ -113,10 +113,10 @@ const q = {
113
113
  if (t === n)
114
114
  return Array.from(e.getClientRects());
115
115
  {
116
- const { unwrap: o, nodes: i } = Me(e), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
116
+ const { unwrap: o, nodes: i } = Te(e), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
117
117
  return o(), r;
118
118
  }
119
- }, Re = (e, t, n = 10, o) => {
119
+ }, Be = (e, t, n = 10, o) => {
120
120
  const i = o ? e.startContainer.parentElement.closest(o) : t, r = document.createRange();
121
121
  r.setStart(i, 0), r.setEnd(e.startContainer, e.startOffset);
122
122
  const s = kt(r).textContent, a = document.createRange();
@@ -126,7 +126,7 @@ const q = {
126
126
  prefix: s.substring(s.length - n),
127
127
  suffix: d.substring(0, n)
128
128
  };
129
- }, ke = /^\s*$/, Ve = (e) => ke.test(e.toString()), z = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), Oe = (e, t) => {
129
+ }, Re = /^\s*$/, ke = (e) => Re.test(e.toString()), z = (e) => e.every((t) => t.range instanceof Range && !t.range.collapsed), Ve = (e, t) => {
130
130
  const n = (r) => Math.round(r * 10) / 10, o = {
131
131
  top: n(e.top),
132
132
  bottom: n(e.bottom),
@@ -150,17 +150,17 @@ const q = {
150
150
  return "block-contains";
151
151
  } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
152
152
  return "block-is-contained";
153
- }, Ne = (e, t) => {
153
+ }, Oe = (e, t) => {
154
154
  const n = Math.min(e.left, t.left), o = Math.max(e.right, t.right), i = Math.min(e.top, t.top), r = Math.max(e.bottom, t.bottom);
155
155
  return new DOMRect(n, i, o - n, r - i);
156
- }, Ie = (e) => e.reduce((t, n) => {
156
+ }, Ne = (e) => e.reduce((t, n) => {
157
157
  if (n.width === 0 || n.height === 0)
158
158
  return t;
159
159
  let o = [...t], i = !1;
160
160
  for (const r of t) {
161
- const s = Oe(n, r);
161
+ const s = Ve(n, r);
162
162
  if (s === "inline-adjacent") {
163
- o = o.map((a) => a === r ? Ne(n, r) : a), i = !0;
163
+ o = o.map((a) => a === r ? Oe(n, r) : a), i = !0;
164
164
  break;
165
165
  } else if (s === "inline-contains") {
166
166
  o = o.map((a) => a === r ? n : a), i = !0;
@@ -181,19 +181,19 @@ const q = {
181
181
  for (let t = 0; t < this.length; t++)
182
182
  yield this.item(t);
183
183
  }
184
- }), Fe = (e, t, n) => {
184
+ }), Ie = (e, t, n) => {
185
185
  const o = document.createRange(), i = n ? e.startContainer.parentElement.closest(n) : t;
186
186
  o.setStart(i, 0), o.setEnd(e.startContainer, e.startOffset);
187
187
  const r = kt(o).textContent, s = e.toString(), a = r.length || 0, d = a + s.length;
188
188
  return n ? { quote: s, start: a, end: d, range: e, offsetReference: i } : { quote: s, start: a, end: d, range: e };
189
189
  }, oe = (e, t) => {
190
- var g, l;
190
+ var h, l;
191
191
  const { start: n, end: o } = e, i = e.offsetReference || t, r = document.createNodeIterator(
192
192
  t,
193
193
  NodeFilter.SHOW_TEXT,
194
- (m) => {
194
+ (g) => {
195
195
  var c;
196
- return (c = m.parentElement) != null && c.closest(X) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
196
+ return (c = g.parentElement) != null && c.closest($) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
197
197
  }
198
198
  );
199
199
  let s = 0;
@@ -203,22 +203,22 @@ const q = {
203
203
  let f = !i;
204
204
  for (; d !== null; ) {
205
205
  if (f || (f = i == null ? void 0 : i.contains(d)), f) {
206
- const m = ((g = d.textContent) == null ? void 0 : g.length) || 0;
207
- if (s + m > n) {
206
+ const g = ((h = d.textContent) == null ? void 0 : h.length) || 0;
207
+ if (s + g > n) {
208
208
  a.setStart(d, n - s);
209
209
  break;
210
210
  }
211
- s += m;
211
+ s += g;
212
212
  }
213
213
  d = r.nextNode();
214
214
  }
215
215
  for (; d !== null; ) {
216
- const m = ((l = d.textContent) == null ? void 0 : l.length) || 0;
217
- if (s + m >= o) {
216
+ const g = ((l = d.textContent) == null ? void 0 : l.length) || 0;
217
+ if (s + g >= o) {
218
218
  a.setEnd(d, o - s);
219
219
  break;
220
220
  }
221
- s += m, d = r.nextNode();
221
+ s += g, d = r.nextNode();
222
222
  }
223
223
  return {
224
224
  ...e,
@@ -227,16 +227,16 @@ const q = {
227
227
  }, mt = (e, t) => z(e.selector) ? e : {
228
228
  ...e,
229
229
  selector: e.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : oe(n, t))
230
- }, bt = (e, t) => z(e.target.selector) ? e : { ...e, target: mt(e.target, t) }, Pe = (e, t) => {
230
+ }, bt = (e, t) => z(e.target.selector) ? e : { ...e, target: mt(e.target, t) }, Fe = (e, t) => {
231
231
  const n = e.cloneRange();
232
232
  return t.contains(n.startContainer) || n.setStart(t, 0), t.contains(n.endContainer) || n.setEnd(t, t.childNodes.length), n;
233
- }, De = (e, t) => {
233
+ }, Pe = (e, t) => {
234
234
  const { left: n, top: o, right: i, bottom: r } = e;
235
235
  return new DOMRect(n - t.left, o - t.top, i - n, r - o);
236
236
  }, Eo = (e, t) => {
237
237
  const { left: n, top: o, right: i, bottom: r } = e;
238
238
  return new DOMRect(n + t.left, o + t.top, i - n, r - o);
239
- }, ye = (e) => ({
239
+ }, De = (e) => ({
240
240
  ...e,
241
241
  type: e.type,
242
242
  x: e.x,
@@ -262,7 +262,7 @@ const q = {
262
262
  pointerId: e.pointerId,
263
263
  pointerType: e.pointerType,
264
264
  timeStamp: e.timeStamp
265
- }), Ue = (e) => ({
265
+ }), ye = (e) => ({
266
266
  ...e,
267
267
  type: e.type,
268
268
  key: e.key,
@@ -278,10 +278,10 @@ const q = {
278
278
  defaultPrevented: e.defaultPrevented,
279
279
  detail: e.detail,
280
280
  timeStamp: e.timeStamp
281
- }), He = (e) => {
281
+ }), Ue = (e) => {
282
282
  const { top: t, left: n } = e.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -t, a = o - n, d = i - t;
283
283
  return { top: t, left: n, minX: r, minY: s, maxX: a, maxY: d };
284
- }, _e = (e) => {
284
+ }, He = (e) => {
285
285
  let t = /* @__PURE__ */ new Set();
286
286
  return (o) => {
287
287
  const i = o.map((r) => r.id);
@@ -290,83 +290,83 @@ const q = {
290
290
  }, It = (e, t, n, o) => {
291
291
  const { store: i, selection: r, hover: s } = t;
292
292
  let a, d, f;
293
- const g = _e(n), l = (T) => {
294
- const { x: M, y: b } = e.getBoundingClientRect(), C = i.getAt(T.clientX - M, T.clientY - b, d);
295
- C ? s.current !== C.id && (e.classList.add("hovered"), s.set(C.id)) : s.current && (e.classList.remove("hovered"), s.set(null));
293
+ const h = He(n), l = (T) => {
294
+ const { x: B, y: m } = e.getBoundingClientRect(), S = i.getAt(T.clientX - B, T.clientY - m, d);
295
+ S ? s.current !== S.id && (e.classList.add("hovered"), s.set(S.id)) : s.current && (e.classList.remove("hovered"), s.set(null));
296
296
  };
297
297
  e.addEventListener("pointermove", l);
298
- const m = (T = !1) => {
298
+ const g = (T = !1) => {
299
299
  f && f.clear();
300
- const M = He(e), { minX: b, minY: C, maxX: x, maxY: L } = M, R = d ? i.getIntersecting(b, C, x, L).filter(({ annotation: j }) => d(j)) : i.getIntersecting(b, C, x, L), I = r.selected.map(({ id: j }) => j), _ = R.map(({ annotation: j, rects: we }) => {
301
- const Ae = I.includes(j.id), Se = j.id === s.current;
302
- return { annotation: j, rects: we, state: { selected: Ae, hover: Se } };
300
+ const B = Ue(e), { minX: m, minY: S, maxX: E, maxY: L } = B, R = d ? i.getIntersecting(m, S, E, L).filter(({ annotation: U }) => d(U)) : i.getIntersecting(m, S, E, L), N = r.selected.map(({ id: U }) => U), X = R.map(({ annotation: U, rects: be }) => {
301
+ const we = N.includes(U.id), Ae = U.id === s.current;
302
+ return { annotation: U, rects: be, state: { selected: we, hover: Ae } };
303
303
  });
304
- o.redraw(_, M, a, f, T), setTimeout(() => g(R.map(({ annotation: j }) => j)), 1);
304
+ o.redraw(X, B, a, f, T), setTimeout(() => h(R.map(({ annotation: U }) => U)), 1);
305
305
  }, c = (T) => {
306
- f = T, m();
307
- }, S = (T) => {
308
- a = T, m();
309
- }, v = (T) => {
310
- d = T, m(!1);
311
- }, w = () => m();
312
- i.observe(w);
313
- const p = r.subscribe(() => m()), u = () => m(!0);
306
+ f = T, g();
307
+ }, A = (T) => {
308
+ a = T, g();
309
+ }, C = (T) => {
310
+ d = T, g(!1);
311
+ }, b = () => g();
312
+ i.observe(b);
313
+ const p = r.subscribe(() => g()), u = () => g(!0);
314
314
  document.addEventListener("scroll", u, { capture: !0, passive: !0 });
315
- const A = Nt(() => {
316
- i.recalculatePositions(), f && f.reset(), m();
315
+ const w = Nt(() => {
316
+ i.recalculatePositions(), f && f.reset(), g();
317
317
  });
318
- window.addEventListener("resize", A);
319
- const h = new ResizeObserver(A);
320
- h.observe(e);
321
- const E = { attributes: !0, childList: !0, subtree: !0 }, B = new MutationObserver((T) => {
322
- T.every((b) => b.target === e || e.contains(b.target)) || m(!0);
318
+ window.addEventListener("resize", w);
319
+ const x = new ResizeObserver(w);
320
+ x.observe(e);
321
+ const v = { attributes: !0, childList: !0, subtree: !0 }, M = new MutationObserver((T) => {
322
+ T.every((m) => m.target === e || e.contains(m.target)) || g(!0);
323
323
  });
324
- return B.observe(document.body, E), {
324
+ return M.observe(document.body, v), {
325
325
  destroy: () => {
326
- e.removeEventListener("pointermove", l), o.destroy(), i.unobserve(w), p(), document.removeEventListener("scroll", u), window.removeEventListener("resize", A), h.disconnect(), B.disconnect();
326
+ e.removeEventListener("pointermove", l), o.destroy(), i.unobserve(b), p(), document.removeEventListener("scroll", u), window.removeEventListener("resize", w), x.disconnect(), M.disconnect();
327
327
  },
328
- redraw: m,
329
- setStyle: S,
330
- setFilter: v,
328
+ redraw: g,
329
+ setStyle: A,
330
+ setFilter: C,
331
331
  setPainter: c,
332
332
  setVisible: o.setVisible
333
333
  };
334
- }, Ye = () => {
334
+ }, _e = () => {
335
335
  const e = document.createElement("canvas");
336
336
  return e.width = window.innerWidth, e.height = window.innerHeight, e.className = "r6o-canvas-highlight-layer bg", e;
337
- }, Xe = (e, t) => {
337
+ }, Ye = (e, t) => {
338
338
  e.width = window.innerWidth, e.height = window.innerHeight;
339
- }, $e = (e) => {
339
+ }, Xe = (e) => {
340
340
  e.classList.add("r6o-annotatable");
341
- const t = Ye(), n = t.getContext("2d");
341
+ const t = _e(), n = t.getContext("2d");
342
342
  document.body.appendChild(t);
343
- const o = (a, d, f, g) => requestAnimationFrame(() => {
344
- const { width: l, height: m } = t;
345
- n.clearRect(-0.5, -0.5, l + 1, m + 1), g && g.clear();
346
- const { top: c, left: S } = d;
347
- [...a].sort((w, p) => {
348
- const { annotation: { target: { created: u } } } = w, { annotation: { target: { created: A } } } = p;
349
- return u.getTime() - A.getTime();
350
- }).forEach((w) => {
351
- var h;
352
- const p = f ? typeof f == "function" ? f(w.annotation, w.state) : f : (h = w.state) != null && h.selected ? gt : q, u = g && g.paint(w, d) || p, A = w.rects.map(({ x: E, y: B, width: k, height: T }) => ({
353
- x: E + S,
354
- y: B + c,
343
+ const o = (a, d, f, h) => requestAnimationFrame(() => {
344
+ const { width: l, height: g } = t;
345
+ n.clearRect(-0.5, -0.5, l + 1, g + 1), h && h.clear();
346
+ const { top: c, left: A } = d;
347
+ [...a].sort((b, p) => {
348
+ const { annotation: { target: { created: u } } } = b, { annotation: { target: { created: w } } } = p;
349
+ return u.getTime() - w.getTime();
350
+ }).forEach((b) => {
351
+ var x;
352
+ const p = f ? typeof f == "function" ? f(b.annotation, b.state) : f : (x = b.state) != null && x.selected ? gt : q, u = h && h.paint(b, d) || p, w = b.rects.map(({ x: v, y: M, width: k, height: T }) => ({
353
+ x: v + A,
354
+ y: M + c,
355
355
  width: k,
356
356
  height: T
357
357
  }));
358
- if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, A.forEach(
359
- ({ x: E, y: B, width: k, height: T }) => n.fillRect(E, B, k, T)
358
+ if (n.fillStyle = u.fill, n.globalAlpha = u.fillOpacity || 1, w.forEach(
359
+ ({ x: v, y: M, width: k, height: T }) => n.fillRect(v, M, k, T)
360
360
  ), u.underlineColor) {
361
361
  n.globalAlpha = 1, n.strokeStyle = u.underlineColor, n.lineWidth = u.underlineThickness ?? 1;
362
- const E = u.underlineOffset ?? 0;
363
- A.forEach(({ x: B, y: k, width: T, height: M }) => {
364
- n.beginPath(), n.moveTo(B, k + M + E), n.lineTo(B + T, k + M + E), n.stroke();
362
+ const v = u.underlineOffset ?? 0;
363
+ w.forEach(({ x: M, y: k, width: T, height: B }) => {
364
+ n.beginPath(), n.moveTo(M, k + B + v), n.lineTo(M + T, k + B + v), n.stroke();
365
365
  });
366
366
  }
367
367
  });
368
368
  }), i = Nt(() => {
369
- Xe(t);
369
+ Ye(t);
370
370
  });
371
371
  return window.addEventListener("resize", i), {
372
372
  destroy: () => {
@@ -377,8 +377,8 @@ const q = {
377
377
  },
378
378
  redraw: o
379
379
  };
380
- }, je = (e, t, n) => It(e, t, n, $e(e));
381
- var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
380
+ }, $e = (e, t, n) => It(e, t, n, Xe(e));
381
+ var je = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
382
382
  return typeof e == "string" ? e.length > 0 : typeof e == "number";
383
383
  }, F = function(e, t, n) {
384
384
  return t === void 0 && (t = 0), n === void 0 && (n = Math.pow(10, t)), Math.round(n * e) / n + 0;
@@ -390,7 +390,7 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
390
390
  return { r: H(e.r, 0, 255), g: H(e.g, 0, 255), b: H(e.b, 0, 255), a: H(e.a) };
391
391
  }, wt = function(e) {
392
392
  return { r: F(e.r), g: F(e.g), b: F(e.b), a: F(e.a, 3) };
393
- }, We = /^#([0-9a-f]{3,8})$/i, ct = function(e) {
393
+ }, Ge = /^#([0-9a-f]{3,8})$/i, ct = function(e) {
394
394
  var t = e.toString(16);
395
395
  return t.length < 2 ? "0" + t : t;
396
396
  }, re = function(e) {
@@ -411,16 +411,16 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
411
411
  }, it = function(e) {
412
412
  return { h: (t = re(e)).h, s: (i = (200 - (n = t.s)) * (o = t.v) / 100) > 0 && i < 200 ? n * o / 100 / (i <= 100 ? i : 200 - i) * 100 : 0, l: i / 2, a: t.a };
413
413
  var t, n, o, i;
414
- }, ze = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qe = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ze = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Je = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Xt = { string: [[function(e) {
415
- var t = We.exec(e);
414
+ }, We = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ze = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Ze = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Xt = { string: [[function(e) {
415
+ var t = Ge.exec(e);
416
416
  return t ? (e = t[1]).length <= 4 ? { r: parseInt(e[0] + e[0], 16), g: parseInt(e[1] + e[1], 16), b: parseInt(e[2] + e[2], 16), a: e.length === 4 ? F(parseInt(e[3] + e[3], 16) / 255, 2) : 1 } : e.length === 6 || e.length === 8 ? { r: parseInt(e.substr(0, 2), 16), g: parseInt(e.substr(2, 2), 16), b: parseInt(e.substr(4, 2), 16), a: e.length === 8 ? F(parseInt(e.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
417
417
  }, "hex"], [function(e) {
418
- var t = Ze.exec(e) || Je.exec(e);
418
+ var t = qe.exec(e) || Ze.exec(e);
419
419
  return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Ut({ r: Number(t[1]) / (t[2] ? 100 / 255 : 1), g: Number(t[3]) / (t[4] ? 100 / 255 : 1), b: Number(t[5]) / (t[6] ? 100 / 255 : 1), a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1) }) : null;
420
420
  }, "rgb"], [function(e) {
421
- var t = ze.exec(e) || qe.exec(e);
421
+ var t = We.exec(e) || ze.exec(e);
422
422
  if (!t) return null;
423
- var n, o, i = Ht({ h: (n = t[1], o = t[2], o === void 0 && (o = "deg"), Number(n) * (Ge[o] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
423
+ var n, o, i = Ht({ h: (n = t[1], o = t[2], o === void 0 && (o = "deg"), Number(n) * (je[o] || 1)), s: Number(t[3]), l: Number(t[4]), a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1) });
424
424
  return Yt(i);
425
425
  }, "hsl"]], object: [[function(e) {
426
426
  var t = e.r, n = e.g, o = e.b, i = e.a, r = i === void 0 ? 1 : i;
@@ -443,28 +443,28 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
443
443
  if (o) return [o, t[n][1]];
444
444
  }
445
445
  return [null, void 0];
446
- }, Qe = function(e) {
446
+ }, Je = function(e) {
447
447
  return typeof e == "string" ? $t(e.trim(), Xt.string) : typeof e == "object" && e !== null ? $t(e, Xt.object) : [null, void 0];
448
448
  }, At = function(e, t) {
449
449
  var n = it(e);
450
450
  return { h: n.h, s: H(n.s + 100 * t, 0, 100), l: n.l, a: n.a };
451
- }, St = function(e) {
451
+ }, vt = function(e) {
452
452
  return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
453
453
  }, jt = function(e, t) {
454
454
  var n = it(e);
455
455
  return { h: n.h, s: n.s, l: H(n.l + 100 * t, 0, 100), a: n.a };
456
456
  }, Gt = function() {
457
457
  function e(t) {
458
- this.parsed = Qe(t)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
458
+ this.parsed = Je(t)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
459
459
  }
460
460
  return e.prototype.isValid = function() {
461
461
  return this.parsed !== null;
462
462
  }, e.prototype.brightness = function() {
463
- return F(St(this.rgba), 2);
463
+ return F(vt(this.rgba), 2);
464
464
  }, e.prototype.isDark = function() {
465
- return St(this.rgba) < 0.5;
465
+ return vt(this.rgba) < 0.5;
466
466
  }, e.prototype.isLight = function() {
467
- return St(this.rgba) >= 0.5;
467
+ return vt(this.rgba) >= 0.5;
468
468
  }, e.prototype.toHex = function() {
469
469
  return t = wt(this.rgba), n = t.r, o = t.g, i = t.b, s = (r = t.a) < 1 ? ct(F(255 * r)) : "", "#" + ct(n) + ct(o) + ct(i) + s;
470
470
  var t, n, o, i, r, s;
@@ -482,39 +482,39 @@ var Ge = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, G = function(e) {
482
482
  return t = re(this.rgba), { h: F(t.h), s: F(t.s), v: F(t.v), a: F(t.a, 3) };
483
483
  var t;
484
484
  }, e.prototype.invert = function() {
485
- return Y({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
485
+ return _({ r: 255 - (t = this.rgba).r, g: 255 - t.g, b: 255 - t.b, a: t.a });
486
486
  var t;
487
487
  }, e.prototype.saturate = function(t) {
488
- return t === void 0 && (t = 0.1), Y(At(this.rgba, t));
488
+ return t === void 0 && (t = 0.1), _(At(this.rgba, t));
489
489
  }, e.prototype.desaturate = function(t) {
490
- return t === void 0 && (t = 0.1), Y(At(this.rgba, -t));
490
+ return t === void 0 && (t = 0.1), _(At(this.rgba, -t));
491
491
  }, e.prototype.grayscale = function() {
492
- return Y(At(this.rgba, -1));
492
+ return _(At(this.rgba, -1));
493
493
  }, e.prototype.lighten = function(t) {
494
- return t === void 0 && (t = 0.1), Y(jt(this.rgba, t));
494
+ return t === void 0 && (t = 0.1), _(jt(this.rgba, t));
495
495
  }, e.prototype.darken = function(t) {
496
- return t === void 0 && (t = 0.1), Y(jt(this.rgba, -t));
496
+ return t === void 0 && (t = 0.1), _(jt(this.rgba, -t));
497
497
  }, e.prototype.rotate = function(t) {
498
498
  return t === void 0 && (t = 15), this.hue(this.hue() + t);
499
499
  }, e.prototype.alpha = function(t) {
500
- return typeof t == "number" ? Y({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) : F(this.rgba.a, 3);
500
+ return typeof t == "number" ? _({ r: (n = this.rgba).r, g: n.g, b: n.b, a: t }) : F(this.rgba.a, 3);
501
501
  var n;
502
502
  }, e.prototype.hue = function(t) {
503
503
  var n = it(this.rgba);
504
- return typeof t == "number" ? Y({ h: t, s: n.s, l: n.l, a: n.a }) : F(n.h);
504
+ return typeof t == "number" ? _({ h: t, s: n.s, l: n.l, a: n.a }) : F(n.h);
505
505
  }, e.prototype.isEqual = function(t) {
506
- return this.toHex() === Y(t).toHex();
506
+ return this.toHex() === _(t).toHex();
507
507
  }, e;
508
- }(), Y = function(e) {
508
+ }(), _ = function(e) {
509
509
  return e instanceof Gt ? e : new Gt(e);
510
510
  };
511
- const Ke = (e) => [
512
- `background-color:${Y((e == null ? void 0 : e.fill) || q.fill).alpha((e == null ? void 0 : e.fillOpacity) === void 0 ? q.fillOpacity : e.fillOpacity).toHex()}`,
511
+ const Qe = (e) => [
512
+ `background-color:${_((e == null ? void 0 : e.fill) || q.fill).alpha((e == null ? void 0 : e.fillOpacity) === void 0 ? q.fillOpacity : e.fillOpacity).toHex()}`,
513
513
  e != null && e.underlineThickness ? "text-decoration:underline" : void 0,
514
514
  e != null && e.underlineColor ? `text-decoration-color:${e.underlineColor}` : void 0,
515
515
  e != null && e.underlineOffset ? `text-underline-offset:${e.underlineOffset}px` : void 0,
516
516
  e != null && e.underlineThickness ? `text-decoration-thickness:${e.underlineThickness}px` : void 0
517
- ].filter(Boolean).join(";"), tn = () => {
517
+ ].filter(Boolean).join(";"), Ke = () => {
518
518
  const e = document.createElement("style");
519
519
  document.getElementsByTagName("head")[0].appendChild(e);
520
520
  let t = /* @__PURE__ */ new Set();
@@ -529,19 +529,19 @@ const Ke = (e) => [
529
529
  d && d.clear();
530
530
  const f = new Set(r.map((l) => l.annotation.id));
531
531
  Array.from(t).filter((l) => !f.has(l));
532
- const g = r.map((l) => {
533
- var S;
534
- const m = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (S = l.state) != null && S.selected ? gt : q, c = d && d.paint(l, s) || m;
535
- return `::highlight(_${l.annotation.id}) { ${Ke(c)} }`;
532
+ const h = r.map((l) => {
533
+ var A;
534
+ const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (A = l.state) != null && A.selected ? gt : q, c = d && d.paint(l, s) || g;
535
+ return `::highlight(_${l.annotation.id}) { ${Qe(c)} }`;
536
536
  });
537
- e.innerHTML = g.join(`
537
+ e.innerHTML = h.join(`
538
538
  `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
539
- const m = l.target.selector.map((S) => S.range), c = new Highlight(...m);
539
+ const g = l.target.selector.map((A) => A.range), c = new Highlight(...g);
540
540
  CSS.highlights.set(`_${l.id}`, c);
541
541
  }), t = f;
542
542
  }
543
543
  };
544
- }, en = (e, t, n) => It(e, t, n, tn());
544
+ }, tn = (e, t, n) => It(e, t, n, Ke());
545
545
  var Wt = Object.prototype.hasOwnProperty;
546
546
  function Vt(e, t) {
547
547
  var n, o;
@@ -563,10 +563,10 @@ function Vt(e, t) {
563
563
  }
564
564
  return e !== e && t !== t;
565
565
  }
566
- const nn = (e, t) => {
566
+ const en = (e, t) => {
567
567
  const n = (r, s) => r.x <= s.x + s.width && r.x + r.width >= s.x && r.y <= s.y + s.height && r.y + r.height >= s.y, o = (r) => r.rects.reduce((s, a) => s + a.width, 0), i = t.filter(({ rects: r }) => r.some((s) => n(e, s)));
568
568
  return i.sort((r, s) => o(s) - o(r)), i.findIndex((r) => r.rects.includes(e));
569
- }, on = (e) => {
569
+ }, nn = (e) => {
570
570
  e.classList.add("r6o-annotatable");
571
571
  const t = document.createElement("div");
572
572
  t.className = "r6o-span-highlight-layer", e.insertBefore(t, e.firstChild);
@@ -575,14 +575,14 @@ const nn = (e, t) => {
575
575
  destroy: () => {
576
576
  t.remove();
577
577
  },
578
- redraw: (s, a, d, f, g) => {
579
- const m = !(Vt(n, s) && g);
580
- !f && !m || (m && (t.innerHTML = ""), s.forEach((c) => {
581
- c.rects.map((S) => {
582
- const v = nn(S, s), w = ve(c, a, d, f, v);
583
- if (m) {
578
+ redraw: (s, a, d, f, h) => {
579
+ const g = !(Vt(n, s) && h);
580
+ !f && !g || (g && (t.innerHTML = ""), s.forEach((c) => {
581
+ c.rects.map((A) => {
582
+ const C = en(A, s), b = ve(c, a, d, f, C);
583
+ if (g) {
584
584
  const p = document.createElement("span");
585
- p.className = "r6o-annotation", p.dataset.annotation = c.annotation.id, p.style.left = `${S.x}px`, p.style.top = `${S.y}px`, p.style.width = `${S.width}px`, p.style.height = `${S.height}px`, p.style.backgroundColor = Y((w == null ? void 0 : w.fill) || q.fill).alpha((w == null ? void 0 : w.fillOpacity) === void 0 ? q.fillOpacity : w.fillOpacity).toHex(), w.underlineStyle && (p.style.borderStyle = w.underlineStyle), w.underlineColor && (p.style.borderColor = w.underlineColor), w.underlineThickness && (p.style.borderBottomWidth = `${w.underlineThickness}px`), w.underlineOffset && (p.style.paddingBottom = `${w.underlineOffset}px`), t.appendChild(p);
585
+ p.className = "r6o-annotation", p.dataset.annotation = c.annotation.id, p.style.left = `${A.x}px`, p.style.top = `${A.y}px`, p.style.width = `${A.width}px`, p.style.height = `${A.height}px`, p.style.backgroundColor = _((b == null ? void 0 : b.fill) || q.fill).alpha((b == null ? void 0 : b.fillOpacity) === void 0 ? q.fillOpacity : b.fillOpacity).toHex(), b.underlineStyle && (p.style.borderStyle = b.underlineStyle), b.underlineColor && (p.style.borderColor = b.underlineColor), b.underlineThickness && (p.style.borderBottomWidth = `${b.underlineThickness}px`), b.underlineOffset && (p.style.paddingBottom = `${b.underlineOffset}px`), t.appendChild(p);
586
586
  }
587
587
  });
588
588
  }), n = s);
@@ -591,29 +591,29 @@ const nn = (e, t) => {
591
591
  s ? t.classList.remove("hidden") : t.classList.add("hidden");
592
592
  }
593
593
  };
594
- }, rn = (e, t, n) => It(e, t, n, on(e));
594
+ }, on = (e, t, n) => It(e, t, n, nn(e));
595
595
  var P = [];
596
- for (var vt = 0; vt < 256; ++vt)
597
- P.push((vt + 256).toString(16).slice(1));
598
- function an(e, t = 0) {
596
+ for (var St = 0; St < 256; ++St)
597
+ P.push((St + 256).toString(16).slice(1));
598
+ function rn(e, t = 0) {
599
599
  return (P[e[t + 0]] + P[e[t + 1]] + P[e[t + 2]] + P[e[t + 3]] + "-" + P[e[t + 4]] + P[e[t + 5]] + "-" + P[e[t + 6]] + P[e[t + 7]] + "-" + P[e[t + 8]] + P[e[t + 9]] + "-" + P[e[t + 10]] + P[e[t + 11]] + P[e[t + 12]] + P[e[t + 13]] + P[e[t + 14]] + P[e[t + 15]]).toLowerCase();
600
600
  }
601
- var dt, sn = new Uint8Array(16);
602
- function ln() {
601
+ var dt, an = new Uint8Array(16);
602
+ function sn() {
603
603
  if (!dt && (dt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !dt))
604
604
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
605
- return dt(sn);
605
+ return dt(an);
606
606
  }
607
- var cn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
607
+ var ln = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
608
608
  const zt = {
609
- randomUUID: cn
609
+ randomUUID: ln
610
610
  };
611
611
  function se(e, t, n) {
612
612
  if (zt.randomUUID && !t && !e)
613
613
  return zt.randomUUID();
614
614
  e = e || {};
615
- var o = e.random || (e.rng || ln)();
616
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, an(o);
615
+ var o = e.random || (e.rng || sn)();
616
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, rn(o);
617
617
  }
618
618
  var qt = Object.prototype.hasOwnProperty;
619
619
  function K(e, t) {
@@ -638,7 +638,7 @@ function K(e, t) {
638
638
  }
639
639
  function Ct() {
640
640
  }
641
- function dn(e, t) {
641
+ function cn(e, t) {
642
642
  return e != e ? t == t : e !== t || e && typeof e == "object" || typeof e == "function";
643
643
  }
644
644
  const Z = [];
@@ -646,7 +646,7 @@ function Ft(e, t = Ct) {
646
646
  let n;
647
647
  const o = /* @__PURE__ */ new Set();
648
648
  function i(a) {
649
- if (dn(e, a) && (e = a, n)) {
649
+ if (cn(e, a) && (e = a, n)) {
650
650
  const d = !Z.length;
651
651
  for (const f of o)
652
652
  f[1](), Z.push(f, e);
@@ -668,7 +668,7 @@ function Ft(e, t = Ct) {
668
668
  }
669
669
  return { set: i, update: r, subscribe: s };
670
670
  }
671
- const un = (e) => {
671
+ const dn = (e) => {
672
672
  const { subscribe: t, set: n } = Ft();
673
673
  let o;
674
674
  return t((i) => o = i), e.observe(({ changes: i }) => {
@@ -685,8 +685,8 @@ const un = (e) => {
685
685
  set: n
686
686
  };
687
687
  };
688
- var fn = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(fn || {});
689
- const xt = { selected: [] }, pn = (e, t = "EDIT") => {
688
+ var un = /* @__PURE__ */ ((e) => (e.EDIT = "EDIT", e.SELECT = "SELECT", e.NONE = "NONE", e))(un || {});
689
+ const xt = { selected: [] }, fn = (e, t = "EDIT") => {
690
690
  const { subscribe: n, set: o } = Ft(xt);
691
691
  let i = t, r = xt;
692
692
  n((c) => r = c);
@@ -696,40 +696,40 @@ const xt = { selected: [] }, pn = (e, t = "EDIT") => {
696
696
  }, d = (c) => {
697
697
  if (a())
698
698
  return !1;
699
- const S = typeof c == "string" ? c : c.id;
700
- return r.selected.some((v) => v.id === S);
701
- }, f = (c, S) => {
702
- const v = e.getAnnotation(c);
703
- if (!v) {
699
+ const A = typeof c == "string" ? c : c.id;
700
+ return r.selected.some((C) => C.id === A);
701
+ }, f = (c, A) => {
702
+ const C = e.getAnnotation(c);
703
+ if (!C) {
704
704
  console.warn("Invalid selection: " + c);
705
705
  return;
706
706
  }
707
- switch (Zt(v, i)) {
707
+ switch (Zt(C, i)) {
708
708
  case "EDIT":
709
- o({ selected: [{ id: c, editable: !0 }], event: S });
709
+ o({ selected: [{ id: c, editable: !0 }], event: A });
710
710
  break;
711
711
  case "SELECT":
712
- o({ selected: [{ id: c }], event: S });
712
+ o({ selected: [{ id: c }], event: A });
713
713
  break;
714
714
  default:
715
- o({ selected: [], event: S });
715
+ o({ selected: [], event: A });
716
716
  }
717
- }, g = (c, S) => {
718
- const v = Array.isArray(c) ? c : [c], w = v.map((p) => e.getAnnotation(p)).filter((p) => !!p);
717
+ }, h = (c, A) => {
718
+ const C = Array.isArray(c) ? c : [c], b = C.map((p) => e.getAnnotation(p)).filter((p) => !!p);
719
719
  o({
720
- selected: w.map((p) => {
721
- const u = S === void 0 ? Zt(p, i) === "EDIT" : S;
720
+ selected: b.map((p) => {
721
+ const u = A === void 0 ? Zt(p, i) === "EDIT" : A;
722
722
  return { id: p.id, editable: u };
723
723
  })
724
- }), w.length !== v.length && console.warn("Invalid selection", c);
724
+ }), b.length !== C.length && console.warn("Invalid selection", c);
725
725
  }, l = (c) => {
726
726
  if (a())
727
727
  return !1;
728
- const { selected: S } = r;
729
- S.some(({ id: v }) => c.includes(v)) && o({ selected: S.filter(({ id: v }) => !c.includes(v)) });
730
- }, m = (c) => i = c;
728
+ const { selected: A } = r;
729
+ A.some(({ id: C }) => c.includes(C)) && o({ selected: A.filter(({ id: C }) => !c.includes(C)) });
730
+ }, g = (c) => i = c;
731
731
  return e.observe(
732
- ({ changes: c }) => l((c.deleted || []).map((S) => S.id))
732
+ ({ changes: c }) => l((c.deleted || []).map((A) => A.id))
733
733
  ), {
734
734
  get event() {
735
735
  return r ? r.event : null;
@@ -740,8 +740,8 @@ const xt = { selected: [] }, pn = (e, t = "EDIT") => {
740
740
  clear: s,
741
741
  isEmpty: a,
742
742
  isSelected: d,
743
- setSelected: g,
744
- setUserSelectAction: m,
743
+ setSelected: h,
744
+ setUserSelectAction: g,
745
745
  subscribe: n,
746
746
  userSelect: f
747
747
  };
@@ -749,54 +749,54 @@ const xt = { selected: [] }, pn = (e, t = "EDIT") => {
749
749
  var D = [];
750
750
  for (var Et = 0; Et < 256; ++Et)
751
751
  D.push((Et + 256).toString(16).slice(1));
752
- function hn(e, t = 0) {
752
+ function pn(e, t = 0) {
753
753
  return (D[e[t + 0]] + D[e[t + 1]] + D[e[t + 2]] + D[e[t + 3]] + "-" + D[e[t + 4]] + D[e[t + 5]] + "-" + D[e[t + 6]] + D[e[t + 7]] + "-" + D[e[t + 8]] + D[e[t + 9]] + "-" + D[e[t + 10]] + D[e[t + 11]] + D[e[t + 12]] + D[e[t + 13]] + D[e[t + 14]] + D[e[t + 15]]).toLowerCase();
754
754
  }
755
- var ut, gn = new Uint8Array(16);
756
- function mn() {
755
+ var ut, hn = new Uint8Array(16);
756
+ function gn() {
757
757
  if (!ut && (ut = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ut))
758
758
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
759
- return ut(gn);
759
+ return ut(hn);
760
760
  }
761
- var bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
761
+ var mn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
762
762
  const Jt = {
763
- randomUUID: bn
763
+ randomUUID: mn
764
764
  };
765
- function wn(e, t, n) {
765
+ function bn(e, t, n) {
766
766
  if (Jt.randomUUID && !t && !e)
767
767
  return Jt.randomUUID();
768
768
  e = e || {};
769
- var o = e.random || (e.rng || mn)();
770
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, hn(o);
769
+ var o = e.random || (e.rng || gn)();
770
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, pn(o);
771
771
  }
772
772
  const Lo = (e, t, n, o) => ({
773
- id: wn(),
773
+ id: bn(),
774
774
  annotation: typeof e == "string" ? e : e.id,
775
775
  created: n || /* @__PURE__ */ new Date(),
776
776
  creator: o,
777
777
  ...t
778
- }), An = (e, t) => {
778
+ }), wn = (e, t) => {
779
779
  const n = new Set(e.bodies.map((o) => o.id));
780
780
  return t.bodies.filter((o) => !n.has(o.id));
781
- }, Sn = (e, t) => {
781
+ }, An = (e, t) => {
782
782
  const n = new Set(t.bodies.map((o) => o.id));
783
783
  return e.bodies.filter((o) => !n.has(o.id));
784
784
  }, vn = (e, t) => t.bodies.map((n) => {
785
785
  const o = e.bodies.find((i) => i.id === n.id);
786
786
  return { newBody: n, oldBody: o && !K(o, n) ? o : void 0 };
787
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Cn = (e, t) => !K(e.target, t.target), le = (e, t) => {
788
- const n = An(e, t), o = Sn(e, t), i = vn(e, t);
787
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), Sn = (e, t) => !K(e.target, t.target), le = (e, t) => {
788
+ const n = wn(e, t), o = An(e, t), i = vn(e, t);
789
789
  return {
790
790
  oldValue: e,
791
791
  newValue: t,
792
792
  bodiesCreated: n.length > 0 ? n : void 0,
793
793
  bodiesDeleted: o.length > 0 ? o : void 0,
794
794
  bodiesUpdated: i.length > 0 ? i : void 0,
795
- targetUpdated: Cn(e, t) ? { oldTarget: e.target, newTarget: t.target } : void 0
795
+ targetUpdated: Sn(e, t) ? { oldTarget: e.target, newTarget: t.target } : void 0
796
796
  };
797
797
  };
798
798
  var V = /* @__PURE__ */ ((e) => (e.LOCAL = "LOCAL", e.REMOTE = "REMOTE", e))(V || {});
799
- const xn = (e, t) => {
799
+ const Cn = (e, t) => {
800
800
  var n, o;
801
801
  const { changes: i, origin: r } = t;
802
802
  if (!(!e.options.origin || e.options.origin === r))
@@ -804,7 +804,7 @@ const xn = (e, t) => {
804
804
  if (e.options.ignore) {
805
805
  const { ignore: s } = e.options, a = (d) => d && d.length > 0;
806
806
  if (!(a(i.created) || a(i.deleted))) {
807
- const d = (n = i.updated) == null ? void 0 : n.some((g) => a(g.bodiesCreated) || a(g.bodiesDeleted) || a(g.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((g) => g.targetUpdated);
807
+ const d = (n = i.updated) == null ? void 0 : n.some((h) => a(h.bodiesCreated) || a(h.bodiesDeleted) || a(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
808
808
  if (s === "BODY_ONLY" && d && !f || s === "TARGET_ONLY" && f && !d)
809
809
  return !1;
810
810
  }
@@ -818,219 +818,219 @@ const xn = (e, t) => {
818
818
  return !!(Array.isArray(e.options.annotations) ? e.options.annotations : [e.options.annotations]).find((a) => s.has(a));
819
819
  } else
820
820
  return !0;
821
- }, En = (e, t) => {
821
+ }, xn = (e, t) => {
822
822
  const n = new Set((e.created || []).map((l) => l.id)), o = new Set((e.updated || []).map(({ newValue: l }) => l.id)), i = new Set((t.created || []).map((l) => l.id)), r = new Set((t.deleted || []).map((l) => l.id)), s = new Set((t.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((t.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), d = [
823
- ...(e.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? t.updated.find(({ oldValue: m }) => m.id === l.id).newValue : l),
823
+ ...(e.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? t.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
824
824
  ...t.created || []
825
825
  ], f = [
826
826
  ...(e.deleted || []).filter((l) => !i.has(l.id)),
827
827
  ...(t.deleted || []).filter((l) => !n.has(l.id))
828
- ], g = [
828
+ ], h = [
829
829
  ...(e.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
830
- const { oldValue: m, newValue: c } = l;
830
+ const { oldValue: g, newValue: c } = l;
831
831
  if (s.has(c.id)) {
832
- const S = t.updated.find((v) => v.oldValue.id === c.id).newValue;
833
- return le(m, S);
832
+ const A = t.updated.find((C) => C.oldValue.id === c.id).newValue;
833
+ return le(g, A);
834
834
  } else
835
835
  return l;
836
836
  }),
837
837
  ...(t.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
838
838
  ];
839
- return { created: d, deleted: f, updated: g };
840
- }, Ln = (e) => e.id !== void 0, Tn = () => {
841
- const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (b, C = {}) => n.push({ onChange: b, options: C }), i = (b) => {
842
- const C = n.findIndex((x) => x.onChange == b);
843
- C > -1 && n.splice(C, 1);
844
- }, r = (b, C) => {
845
- const x = {
846
- origin: b,
839
+ return { created: d, deleted: f, updated: h };
840
+ }, En = (e) => e.id !== void 0, Ln = () => {
841
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Map(), n = [], o = (m, S = {}) => n.push({ onChange: m, options: S }), i = (m) => {
842
+ const S = n.findIndex((E) => E.onChange == m);
843
+ S > -1 && n.splice(S, 1);
844
+ }, r = (m, S) => {
845
+ const E = {
846
+ origin: m,
847
847
  changes: {
848
- created: C.created || [],
849
- updated: C.updated || [],
850
- deleted: C.deleted || []
848
+ created: S.created || [],
849
+ updated: S.updated || [],
850
+ deleted: S.deleted || []
851
851
  },
852
852
  state: [...e.values()]
853
853
  };
854
854
  n.forEach((L) => {
855
- xn(L, x) && L.onChange(x);
855
+ Cn(L, E) && L.onChange(E);
856
856
  });
857
- }, s = (b, C = V.LOCAL) => {
858
- if (e.get(b.id))
859
- throw Error(`Cannot add annotation ${b.id} - exists already`);
860
- e.set(b.id, b), b.bodies.forEach((x) => t.set(x.id, b.id)), r(C, { created: [b] });
861
- }, a = (b, C) => {
862
- const x = typeof b == "string" ? C : b, L = typeof b == "string" ? b : b.id, R = e.get(L);
857
+ }, s = (m, S = V.LOCAL) => {
858
+ if (e.get(m.id))
859
+ throw Error(`Cannot add annotation ${m.id} - exists already`);
860
+ e.set(m.id, m), m.bodies.forEach((E) => t.set(E.id, m.id)), r(S, { created: [m] });
861
+ }, a = (m, S) => {
862
+ const E = typeof m == "string" ? S : m, L = typeof m == "string" ? m : m.id, R = e.get(L);
863
863
  if (R) {
864
- const I = le(R, x);
865
- return L === x.id ? e.set(L, x) : (e.delete(L), e.set(x.id, x)), R.bodies.forEach((_) => t.delete(_.id)), x.bodies.forEach((_) => t.set(_.id, x.id)), I;
864
+ const N = le(R, E);
865
+ return L === E.id ? e.set(L, E) : (e.delete(L), e.set(E.id, E)), R.bodies.forEach((X) => t.delete(X.id)), E.bodies.forEach((X) => t.set(X.id, E.id)), N;
866
866
  } else
867
867
  console.warn(`Cannot update annotation ${L} - does not exist`);
868
- }, d = (b, C = V.LOCAL, x = V.LOCAL) => {
869
- const L = Ln(C) ? x : C, R = a(b, C);
868
+ }, d = (m, S = V.LOCAL, E = V.LOCAL) => {
869
+ const L = En(S) ? E : S, R = a(m, S);
870
870
  R && r(L, { updated: [R] });
871
- }, f = (b, C = V.LOCAL) => {
872
- const x = b.reduce((L, R) => {
873
- const I = a(R);
874
- return I ? [...L, I] : L;
871
+ }, f = (m, S = V.LOCAL) => {
872
+ const E = m.reduce((L, R) => {
873
+ const N = a(R);
874
+ return N ? [...L, N] : L;
875
875
  }, []);
876
- x.length > 0 && r(C, { updated: x });
877
- }, g = (b, C = V.LOCAL) => {
878
- const x = e.get(b.annotation);
879
- if (x) {
876
+ E.length > 0 && r(S, { updated: E });
877
+ }, h = (m, S = V.LOCAL) => {
878
+ const E = e.get(m.annotation);
879
+ if (E) {
880
880
  const L = {
881
- ...x,
882
- bodies: [...x.bodies, b]
881
+ ...E,
882
+ bodies: [...E.bodies, m]
883
883
  };
884
- e.set(x.id, L), t.set(b.id, L.id), r(C, { updated: [{
885
- oldValue: x,
884
+ e.set(E.id, L), t.set(m.id, L.id), r(S, { updated: [{
885
+ oldValue: E,
886
886
  newValue: L,
887
- bodiesCreated: [b]
887
+ bodiesCreated: [m]
888
888
  }] });
889
889
  } else
890
- console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
891
- }, l = () => [...e.values()], m = (b = V.LOCAL) => {
892
- const C = [...e.values()];
893
- e.clear(), t.clear(), r(b, { deleted: C });
894
- }, c = (b, C = !0, x = V.LOCAL) => {
895
- if (C) {
890
+ console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
891
+ }, l = () => [...e.values()], g = (m = V.LOCAL) => {
892
+ const S = [...e.values()];
893
+ e.clear(), t.clear(), r(m, { deleted: S });
894
+ }, c = (m, S = !0, E = V.LOCAL) => {
895
+ if (S) {
896
896
  const L = [...e.values()];
897
- e.clear(), t.clear(), b.forEach((R) => {
898
- e.set(R.id, R), R.bodies.forEach((I) => t.set(I.id, R.id));
899
- }), r(x, { created: b, deleted: L });
897
+ e.clear(), t.clear(), m.forEach((R) => {
898
+ e.set(R.id, R), R.bodies.forEach((N) => t.set(N.id, R.id));
899
+ }), r(E, { created: m, deleted: L });
900
900
  } else {
901
- const L = b.reduce((R, I) => {
902
- const _ = e.get(I.id);
903
- return _ ? [...R, _] : R;
901
+ const L = m.reduce((R, N) => {
902
+ const X = e.get(N.id);
903
+ return X ? [...R, X] : R;
904
904
  }, []);
905
905
  if (L.length > 0)
906
906
  throw Error(`Bulk insert would overwrite the following annotations: ${L.map((R) => R.id).join(", ")}`);
907
- b.forEach((R) => {
908
- e.set(R.id, R), R.bodies.forEach((I) => t.set(I.id, R.id));
909
- }), r(x, { created: b });
907
+ m.forEach((R) => {
908
+ e.set(R.id, R), R.bodies.forEach((N) => t.set(N.id, R.id));
909
+ }), r(E, { created: m });
910
910
  }
911
- }, S = (b) => {
912
- const C = typeof b == "string" ? b : b.id, x = e.get(C);
913
- if (x)
914
- return e.delete(C), x.bodies.forEach((L) => t.delete(L.id)), x;
915
- console.warn(`Attempt to delete missing annotation: ${C}`);
916
- }, v = (b, C = V.LOCAL) => {
917
- const x = S(b);
918
- x && r(C, { deleted: [x] });
919
- }, w = (b, C = V.LOCAL) => {
920
- const x = b.reduce((L, R) => {
921
- const I = S(R);
922
- return I ? [...L, I] : L;
911
+ }, A = (m) => {
912
+ const S = typeof m == "string" ? m : m.id, E = e.get(S);
913
+ if (E)
914
+ return e.delete(S), E.bodies.forEach((L) => t.delete(L.id)), E;
915
+ console.warn(`Attempt to delete missing annotation: ${S}`);
916
+ }, C = (m, S = V.LOCAL) => {
917
+ const E = A(m);
918
+ E && r(S, { deleted: [E] });
919
+ }, b = (m, S = V.LOCAL) => {
920
+ const E = m.reduce((L, R) => {
921
+ const N = A(R);
922
+ return N ? [...L, N] : L;
923
923
  }, []);
924
- x.length > 0 && r(C, { deleted: x });
925
- }, p = (b) => {
926
- const C = e.get(b.annotation);
927
- if (C) {
928
- const x = C.bodies.find((L) => L.id === b.id);
929
- if (x) {
930
- t.delete(x.id);
924
+ E.length > 0 && r(S, { deleted: E });
925
+ }, p = (m) => {
926
+ const S = e.get(m.annotation);
927
+ if (S) {
928
+ const E = S.bodies.find((L) => L.id === m.id);
929
+ if (E) {
930
+ t.delete(E.id);
931
931
  const L = {
932
- ...C,
933
- bodies: C.bodies.filter((R) => R.id !== b.id)
932
+ ...S,
933
+ bodies: S.bodies.filter((R) => R.id !== m.id)
934
934
  };
935
- return e.set(C.id, L), {
936
- oldValue: C,
935
+ return e.set(S.id, L), {
936
+ oldValue: S,
937
937
  newValue: L,
938
- bodiesDeleted: [x]
938
+ bodiesDeleted: [E]
939
939
  };
940
940
  } else
941
- console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
941
+ console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
942
942
  } else
943
- console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
944
- }, u = (b, C = V.LOCAL) => {
945
- const x = p(b);
946
- x && r(C, { updated: [x] });
947
- }, A = (b, C = V.LOCAL) => {
948
- const x = b.map((L) => p(L)).filter(Boolean);
949
- x.length > 0 && r(C, { updated: x });
950
- }, h = (b) => {
951
- const C = e.get(b);
952
- return C ? { ...C } : void 0;
953
- }, E = (b) => {
954
- const C = t.get(b);
955
- if (C) {
956
- const x = h(C).bodies.find((L) => L.id === b);
957
- if (x)
958
- return x;
959
- console.error(`Store integrity error: body ${b} in index, but not in annotation`);
943
+ console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
944
+ }, u = (m, S = V.LOCAL) => {
945
+ const E = p(m);
946
+ E && r(S, { updated: [E] });
947
+ }, w = (m, S = V.LOCAL) => {
948
+ const E = m.map((L) => p(L)).filter(Boolean);
949
+ E.length > 0 && r(S, { updated: E });
950
+ }, x = (m) => {
951
+ const S = e.get(m);
952
+ return S ? { ...S } : void 0;
953
+ }, v = (m) => {
954
+ const S = t.get(m);
955
+ if (S) {
956
+ const E = x(S).bodies.find((L) => L.id === m);
957
+ if (E)
958
+ return E;
959
+ console.error(`Store integrity error: body ${m} in index, but not in annotation`);
960
960
  } else
961
- console.warn(`Attempt to retrieve missing body: ${b}`);
962
- }, B = (b, C) => {
963
- if (b.annotation !== C.annotation)
961
+ console.warn(`Attempt to retrieve missing body: ${m}`);
962
+ }, M = (m, S) => {
963
+ if (m.annotation !== S.annotation)
964
964
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
965
- const x = e.get(b.annotation);
966
- if (x) {
967
- const L = x.bodies.find((I) => I.id === b.id), R = {
968
- ...x,
969
- bodies: x.bodies.map((I) => I.id === L.id ? C : I)
965
+ const E = e.get(m.annotation);
966
+ if (E) {
967
+ const L = E.bodies.find((N) => N.id === m.id), R = {
968
+ ...E,
969
+ bodies: E.bodies.map((N) => N.id === L.id ? S : N)
970
970
  };
971
- return e.set(x.id, R), L.id !== C.id && (t.delete(L.id), t.set(C.id, R.id)), {
972
- oldValue: x,
971
+ return e.set(E.id, R), L.id !== S.id && (t.delete(L.id), t.set(S.id, R.id)), {
972
+ oldValue: E,
973
973
  newValue: R,
974
- bodiesUpdated: [{ oldBody: L, newBody: C }]
974
+ bodiesUpdated: [{ oldBody: L, newBody: S }]
975
975
  };
976
976
  } else
977
- console.warn(`Attempt to add body to missing annotation ${b.annotation}`);
978
- }, k = (b, C, x = V.LOCAL) => {
979
- const L = B(b, C);
980
- L && r(x, { updated: [L] });
981
- }, T = (b, C = V.LOCAL) => {
982
- const x = b.map((L) => B({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
983
- r(C, { updated: x });
984
- }, M = (b) => {
985
- const C = e.get(b.annotation);
986
- if (C) {
987
- const x = {
988
- ...C,
977
+ console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
978
+ }, k = (m, S, E = V.LOCAL) => {
979
+ const L = M(m, S);
980
+ L && r(E, { updated: [L] });
981
+ }, T = (m, S = V.LOCAL) => {
982
+ const E = m.map((L) => M({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
983
+ r(S, { updated: E });
984
+ }, B = (m) => {
985
+ const S = e.get(m.annotation);
986
+ if (S) {
987
+ const E = {
988
+ ...S,
989
989
  target: {
990
- ...C.target,
991
- ...b
990
+ ...S.target,
991
+ ...m
992
992
  }
993
993
  };
994
- return e.set(C.id, x), {
995
- oldValue: C,
996
- newValue: x,
994
+ return e.set(S.id, E), {
995
+ oldValue: S,
996
+ newValue: E,
997
997
  targetUpdated: {
998
- oldTarget: C.target,
999
- newTarget: b
998
+ oldTarget: S.target,
999
+ newTarget: m
1000
1000
  }
1001
1001
  };
1002
1002
  } else
1003
- console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);
1003
+ console.warn(`Attempt to update target on missing annotation: ${m.annotation}`);
1004
1004
  };
1005
1005
  return {
1006
1006
  addAnnotation: s,
1007
- addBody: g,
1007
+ addBody: h,
1008
1008
  all: l,
1009
1009
  bulkAddAnnotation: c,
1010
- bulkDeleteAnnotation: w,
1011
- bulkDeleteBodies: A,
1010
+ bulkDeleteAnnotation: b,
1011
+ bulkDeleteBodies: w,
1012
1012
  bulkUpdateAnnotation: f,
1013
1013
  bulkUpdateBodies: T,
1014
- bulkUpdateTargets: (b, C = V.LOCAL) => {
1015
- const x = b.map((L) => M(L)).filter(Boolean);
1016
- x.length > 0 && r(C, { updated: x });
1014
+ bulkUpdateTargets: (m, S = V.LOCAL) => {
1015
+ const E = m.map((L) => B(L)).filter(Boolean);
1016
+ E.length > 0 && r(S, { updated: E });
1017
1017
  },
1018
- clear: m,
1019
- deleteAnnotation: v,
1018
+ clear: g,
1019
+ deleteAnnotation: C,
1020
1020
  deleteBody: u,
1021
- getAnnotation: h,
1022
- getBody: E,
1021
+ getAnnotation: x,
1022
+ getBody: v,
1023
1023
  observe: o,
1024
1024
  unobserve: i,
1025
1025
  updateAnnotation: d,
1026
1026
  updateBody: k,
1027
- updateTarget: (b, C = V.LOCAL) => {
1028
- const x = M(b);
1029
- x && r(C, { updated: [x] });
1027
+ updateTarget: (m, S = V.LOCAL) => {
1028
+ const E = B(m);
1029
+ E && r(S, { updated: [E] });
1030
1030
  }
1031
1031
  };
1032
1032
  };
1033
- let Mn = () => ({
1033
+ let Tn = () => ({
1034
1034
  emit(e, ...t) {
1035
1035
  for (let n = 0, o = this.events[e] || [], i = o.length; n < i; n++)
1036
1036
  o[n](...t);
@@ -1044,119 +1044,119 @@ let Mn = () => ({
1044
1044
  };
1045
1045
  }
1046
1046
  });
1047
- const Bn = 250, Rn = (e) => {
1048
- const t = Mn(), n = [];
1047
+ const Mn = 250, Bn = (e) => {
1048
+ const t = Tn(), n = [];
1049
1049
  let o = -1, i = !1, r = 0;
1050
1050
  const s = (c) => {
1051
1051
  if (!i) {
1052
- const { changes: S } = c, v = performance.now();
1053
- if (v - r > Bn)
1054
- n.splice(o + 1), n.push(S), o = n.length - 1;
1052
+ const { changes: A } = c, C = performance.now();
1053
+ if (C - r > Mn)
1054
+ n.splice(o + 1), n.push(A), o = n.length - 1;
1055
1055
  else {
1056
- const w = n.length - 1;
1057
- n[w] = En(n[w], S);
1056
+ const b = n.length - 1;
1057
+ n[b] = xn(n[b], A);
1058
1058
  }
1059
- r = v;
1059
+ r = C;
1060
1060
  }
1061
1061
  i = !1;
1062
1062
  };
1063
1063
  e.observe(s, { origin: V.LOCAL });
1064
- const a = (c) => c && c.length > 0 && e.bulkDeleteAnnotation(c), d = (c) => c && c.length > 0 && e.bulkAddAnnotation(c, !1), f = (c) => c && c.length > 0 && e.bulkUpdateAnnotation(c.map(({ oldValue: S }) => S)), g = (c) => c && c.length > 0 && e.bulkUpdateAnnotation(c.map(({ newValue: S }) => S)), l = (c) => c && c.length > 0 && e.bulkAddAnnotation(c, !1), m = (c) => c && c.length > 0 && e.bulkDeleteAnnotation(c);
1064
+ const a = (c) => c && c.length > 0 && e.bulkDeleteAnnotation(c), d = (c) => c && c.length > 0 && e.bulkAddAnnotation(c, !1), f = (c) => c && c.length > 0 && e.bulkUpdateAnnotation(c.map(({ oldValue: A }) => A)), h = (c) => c && c.length > 0 && e.bulkUpdateAnnotation(c.map(({ newValue: A }) => A)), l = (c) => c && c.length > 0 && e.bulkAddAnnotation(c, !1), g = (c) => c && c.length > 0 && e.bulkDeleteAnnotation(c);
1065
1065
  return {
1066
1066
  canRedo: () => n.length - 1 > o,
1067
1067
  canUndo: () => o > -1,
1068
1068
  destroy: () => e.unobserve(s),
1069
- on: (c, S) => t.on(c, S),
1069
+ on: (c, A) => t.on(c, A),
1070
1070
  redo: () => {
1071
1071
  if (n.length - 1 > o) {
1072
1072
  i = !0;
1073
- const { created: c, updated: S, deleted: v } = n[o + 1];
1074
- d(c), g(S), m(v), t.emit("redo", n[o + 1]), o += 1;
1073
+ const { created: c, updated: A, deleted: C } = n[o + 1];
1074
+ d(c), h(A), g(C), t.emit("redo", n[o + 1]), o += 1;
1075
1075
  }
1076
1076
  },
1077
1077
  undo: () => {
1078
1078
  if (o > -1) {
1079
1079
  i = !0;
1080
- const { created: c, updated: S, deleted: v } = n[o];
1081
- a(c), f(S), l(v), t.emit("undo", n[o]), o -= 1;
1080
+ const { created: c, updated: A, deleted: C } = n[o];
1081
+ a(c), f(A), l(C), t.emit("undo", n[o]), o -= 1;
1082
1082
  }
1083
1083
  }
1084
1084
  };
1085
- }, kn = () => {
1085
+ }, Rn = () => {
1086
1086
  const { subscribe: e, set: t } = Ft([]);
1087
1087
  return {
1088
1088
  subscribe: e,
1089
1089
  set: t
1090
1090
  };
1091
- }, Vn = (e, t, n, o) => {
1091
+ }, kn = (e, t, n, o) => {
1092
1092
  const { store: i, selection: r, hover: s, viewport: a } = e, d = /* @__PURE__ */ new Map();
1093
- let f = [], g;
1094
- const l = (v, w) => {
1095
- d.has(v) ? d.get(v).push(w) : d.set(v, [w]);
1096
- }, m = (v, w) => {
1097
- const p = d.get(v);
1093
+ let f = [], h;
1094
+ const l = (C, b) => {
1095
+ d.has(C) ? d.get(C).push(b) : d.set(C, [b]);
1096
+ }, g = (C, b) => {
1097
+ const p = d.get(C);
1098
1098
  if (p) {
1099
- const u = p.indexOf(w);
1099
+ const u = p.indexOf(b);
1100
1100
  u !== -1 && p.splice(u, 1);
1101
1101
  }
1102
- }, c = (v, w, p) => {
1103
- d.has(v) && setTimeout(() => {
1104
- d.get(v).forEach((u) => {
1102
+ }, c = (C, b, p) => {
1103
+ d.has(C) && setTimeout(() => {
1104
+ d.get(C).forEach((u) => {
1105
1105
  if (n) {
1106
- const A = Array.isArray(w) ? w.map((E) => n.serialize(E)) : n.serialize(w), h = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
1107
- u(A, h);
1106
+ const w = Array.isArray(b) ? b.map((v) => n.serialize(v)) : n.serialize(b), x = p ? p instanceof PointerEvent ? p : n.serialize(p) : void 0;
1107
+ u(w, x);
1108
1108
  } else
1109
- u(w, p);
1109
+ u(b, p);
1110
1110
  });
1111
1111
  }, 1);
1112
1112
  };
1113
- r.subscribe(({ selected: v }) => {
1114
- if (!(f.length === 0 && v.length === 0)) {
1115
- if (f.length === 0 && v.length > 0)
1116
- f = v.map(({ id: w }) => i.getAnnotation(w));
1117
- else if (f.length > 0 && v.length === 0)
1118
- f.forEach((w) => {
1119
- const p = i.getAnnotation(w.id);
1120
- p && !K(p, w) && c("updateAnnotation", p, w);
1113
+ r.subscribe(({ selected: C }) => {
1114
+ if (!(f.length === 0 && C.length === 0)) {
1115
+ if (f.length === 0 && C.length > 0)
1116
+ f = C.map(({ id: b }) => i.getAnnotation(b));
1117
+ else if (f.length > 0 && C.length === 0)
1118
+ f.forEach((b) => {
1119
+ const p = i.getAnnotation(b.id);
1120
+ p && !K(p, b) && c("updateAnnotation", p, b);
1121
1121
  }), f = [];
1122
1122
  else {
1123
- const w = new Set(f.map((u) => u.id)), p = new Set(v.map(({ id: u }) => u));
1123
+ const b = new Set(f.map((u) => u.id)), p = new Set(C.map(({ id: u }) => u));
1124
1124
  f.filter((u) => !p.has(u.id)).forEach((u) => {
1125
- const A = i.getAnnotation(u.id);
1126
- A && !K(A, u) && c("updateAnnotation", A, u);
1125
+ const w = i.getAnnotation(u.id);
1126
+ w && !K(w, u) && c("updateAnnotation", w, u);
1127
1127
  }), f = [
1128
1128
  // Remove annotations that were deselected
1129
1129
  ...f.filter((u) => p.has(u.id)),
1130
1130
  // Add editable annotations that were selected
1131
- ...v.filter(({ id: u }) => !w.has(u)).map(({ id: u }) => i.getAnnotation(u))
1131
+ ...C.filter(({ id: u }) => !b.has(u)).map(({ id: u }) => i.getAnnotation(u))
1132
1132
  ];
1133
1133
  }
1134
1134
  c("selectionChanged", f);
1135
1135
  }
1136
- }), s.subscribe((v) => {
1137
- !g && v ? c("mouseEnterAnnotation", i.getAnnotation(v)) : g && !v ? c("mouseLeaveAnnotation", i.getAnnotation(g)) : g && v && (c("mouseLeaveAnnotation", i.getAnnotation(g)), c("mouseEnterAnnotation", i.getAnnotation(v))), g = v;
1138
- }), a == null || a.subscribe((v) => c("viewportIntersect", v.map((w) => i.getAnnotation(w)))), i.observe((v) => {
1139
- const { created: w, deleted: p } = v.changes;
1140
- (w || []).forEach((u) => c("createAnnotation", u)), (p || []).forEach((u) => c("deleteAnnotation", u)), (v.changes.updated || []).filter((u) => [
1136
+ }), s.subscribe((C) => {
1137
+ !h && C ? c("mouseEnterAnnotation", i.getAnnotation(C)) : h && !C ? c("mouseLeaveAnnotation", i.getAnnotation(h)) : h && C && (c("mouseLeaveAnnotation", i.getAnnotation(h)), c("mouseEnterAnnotation", i.getAnnotation(C))), h = C;
1138
+ }), a == null || a.subscribe((C) => c("viewportIntersect", C.map((b) => i.getAnnotation(b)))), i.observe((C) => {
1139
+ const { created: b, deleted: p } = C.changes;
1140
+ (b || []).forEach((u) => c("createAnnotation", u)), (p || []).forEach((u) => c("deleteAnnotation", u)), (C.changes.updated || []).filter((u) => [
1141
1141
  ...u.bodiesCreated || [],
1142
1142
  ...u.bodiesDeleted || [],
1143
1143
  ...u.bodiesUpdated || []
1144
- ].length > 0).forEach(({ oldValue: u, newValue: A }) => {
1145
- const h = f.find((E) => E.id === u.id) || u;
1146
- f = f.map((E) => E.id === u.id ? A : E), c("updateAnnotation", A, h);
1144
+ ].length > 0).forEach(({ oldValue: u, newValue: w }) => {
1145
+ const x = f.find((v) => v.id === u.id) || u;
1146
+ f = f.map((v) => v.id === u.id ? w : v), c("updateAnnotation", w, x);
1147
1147
  });
1148
- }, { origin: V.LOCAL }), i.observe((v) => {
1148
+ }, { origin: V.LOCAL }), i.observe((C) => {
1149
1149
  if (f) {
1150
- const w = new Set(f.map((u) => u.id)), p = (v.changes.updated || []).filter(({ newValue: u }) => w.has(u.id)).map(({ newValue: u }) => u);
1151
- p.length > 0 && (f = f.map((u) => p.find((h) => h.id === u.id) || u));
1150
+ const b = new Set(f.map((u) => u.id)), p = (C.changes.updated || []).filter(({ newValue: u }) => b.has(u.id)).map(({ newValue: u }) => u);
1151
+ p.length > 0 && (f = f.map((u) => p.find((x) => x.id === u.id) || u));
1152
1152
  }
1153
1153
  }, { origin: V.REMOTE });
1154
- const S = (v) => (w) => {
1155
- const { updated: p } = w;
1156
- v ? (p || []).forEach((u) => c("updateAnnotation", u.oldValue, u.newValue)) : (p || []).forEach((u) => c("updateAnnotation", u.newValue, u.oldValue));
1154
+ const A = (C) => (b) => {
1155
+ const { updated: p } = b;
1156
+ C ? (p || []).forEach((u) => c("updateAnnotation", u.oldValue, u.newValue)) : (p || []).forEach((u) => c("updateAnnotation", u.newValue, u.oldValue));
1157
1157
  };
1158
- return t.on("undo", S(!0)), t.on("redo", S(!1)), { on: l, off: m, emit: c };
1159
- }, On = (e) => (t) => t.reduce((n, o) => {
1158
+ return t.on("undo", A(!0)), t.on("redo", A(!1)), { on: l, off: g, emit: c };
1159
+ }, Vn = (e) => (t) => t.reduce((n, o) => {
1160
1160
  const { parsed: i, error: r } = e.parse(o);
1161
1161
  return r ? {
1162
1162
  parsed: n.parsed,
@@ -1167,21 +1167,21 @@ const Bn = 250, Rn = (e) => {
1167
1167
  } : {
1168
1168
  ...n
1169
1169
  };
1170
- }, { parsed: [], failed: [] }), Nn = (e, t, n) => {
1170
+ }, { parsed: [], failed: [] }), On = (e, t, n) => {
1171
1171
  const { store: o, selection: i } = e, r = (p) => {
1172
1172
  if (n) {
1173
- const { parsed: u, error: A } = n.parse(p);
1174
- u ? o.addAnnotation(u, V.REMOTE) : console.error(A);
1173
+ const { parsed: u, error: w } = n.parse(p);
1174
+ u ? o.addAnnotation(u, V.REMOTE) : console.error(w);
1175
1175
  } else
1176
1176
  o.addAnnotation(p, V.REMOTE);
1177
1177
  }, s = () => i.clear(), a = () => o.clear(), d = (p) => {
1178
1178
  const u = o.getAnnotation(p);
1179
1179
  return n && u ? n.serialize(u) : u;
1180
- }, f = () => n ? o.all().map(n.serialize) : o.all(), g = () => {
1180
+ }, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1181
1181
  var p;
1182
- const u = (((p = i.selected) == null ? void 0 : p.map((A) => A.id)) || []).map((A) => o.getAnnotation(A)).filter(Boolean);
1182
+ const u = (((p = i.selected) == null ? void 0 : p.map((w) => w.id)) || []).map((w) => o.getAnnotation(w)).filter(Boolean);
1183
1183
  return n ? u.map(n.serialize) : u;
1184
- }, l = (p, u = !0) => fetch(p).then((A) => A.json()).then((A) => (c(A, u), A)), m = (p) => {
1184
+ }, l = (p, u = !0) => fetch(p).then((w) => w.json()).then((w) => (c(w, u), w)), g = (p) => {
1185
1185
  if (typeof p == "string") {
1186
1186
  const u = o.getAnnotation(p);
1187
1187
  if (o.deleteAnnotation(p), u)
@@ -1193,18 +1193,18 @@ const Bn = 250, Rn = (e) => {
1193
1193
  }
1194
1194
  }, c = (p, u = !0) => {
1195
1195
  if (n) {
1196
- const { parsed: A, failed: h } = On(n)(p);
1197
- h.length > 0 && console.warn(`Discarded ${h.length} invalid annotations`, h), o.bulkAddAnnotation(A, u, V.REMOTE);
1196
+ const { parsed: w, failed: x } = Vn(n)(p);
1197
+ x.length > 0 && console.warn(`Discarded ${x.length} invalid annotations`, x), o.bulkAddAnnotation(w, u, V.REMOTE);
1198
1198
  } else
1199
1199
  o.bulkAddAnnotation(p, u, V.REMOTE);
1200
- }, S = (p, u) => {
1200
+ }, A = (p, u) => {
1201
1201
  p ? i.setSelected(p, u) : i.clear();
1202
- }, v = (p) => {
1202
+ }, C = (p) => {
1203
1203
  i.clear(), i.setUserSelectAction(p);
1204
- }, w = (p) => {
1204
+ }, b = (p) => {
1205
1205
  if (n) {
1206
- const u = n.parse(p).parsed, A = n.serialize(o.getAnnotation(u.id));
1207
- return o.updateAnnotation(u), A;
1206
+ const u = n.parse(p).parsed, w = n.serialize(o.getAnnotation(u.id));
1207
+ return o.updateAnnotation(u), w;
1208
1208
  } else {
1209
1209
  const u = o.getAnnotation(p.id);
1210
1210
  return o.updateAnnotation(p), u;
@@ -1218,18 +1218,18 @@ const Bn = 250, Rn = (e) => {
1218
1218
  clearAnnotations: a,
1219
1219
  getAnnotationById: d,
1220
1220
  getAnnotations: f,
1221
- getSelected: g,
1221
+ getSelected: h,
1222
1222
  loadAnnotations: l,
1223
1223
  redo: t.redo,
1224
- removeAnnotation: m,
1224
+ removeAnnotation: g,
1225
1225
  setAnnotations: c,
1226
- setSelected: S,
1227
- setUserSelectAction: v,
1226
+ setSelected: A,
1227
+ setUserSelectAction: C,
1228
1228
  undo: t.undo,
1229
- updateAnnotation: w
1229
+ updateAnnotation: b
1230
1230
  };
1231
- }, In = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1232
- let Fn = (e) => crypto.getRandomValues(new Uint8Array(e)), Pn = (e, t, n) => {
1231
+ }, Nn = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1232
+ let In = (e) => crypto.getRandomValues(new Uint8Array(e)), Fn = (e, t, n) => {
1233
1233
  let o = (2 << Math.log(e.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * t / e.length);
1234
1234
  return (r = t) => {
1235
1235
  let s = "";
@@ -1239,13 +1239,13 @@ let Fn = (e) => crypto.getRandomValues(new Uint8Array(e)), Pn = (e, t, n) => {
1239
1239
  if (s += e[a[d] & o] || "", s.length === r) return s;
1240
1240
  }
1241
1241
  };
1242
- }, Dn = (e, t = 21) => Pn(e, t, Fn), yn = (e = 21) => {
1242
+ }, Pn = (e, t = 21) => Fn(e, t, In), Dn = (e = 21) => {
1243
1243
  let t = "", n = crypto.getRandomValues(new Uint8Array(e));
1244
1244
  for (; e--; )
1245
- t += In[n[e] & 63];
1245
+ t += Nn[n[e] & 63];
1246
1246
  return t;
1247
1247
  };
1248
- const Un = () => ({ isGuest: !0, id: Dn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Hn = (e) => {
1248
+ const yn = () => ({ isGuest: !0, id: Pn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Un = (e) => {
1249
1249
  const t = JSON.stringify(e);
1250
1250
  let n = 0;
1251
1251
  for (let o = 0, i = t.length; o < i; o++) {
@@ -1253,10 +1253,10 @@ const Un = () => ({ isGuest: !0, id: Dn("1234567890abcdefghijklmnopqrstuvwxyzABC
1253
1253
  n = (n << 5) - n + r, n |= 0;
1254
1254
  }
1255
1255
  return `${n}`;
1256
- }, ce = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, _n = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
1257
- const { id: o, type: i, purpose: r, value: s, created: a, modified: d, creator: f, ...g } = n;
1256
+ }, ce = (e) => e ? typeof e == "object" ? { ...e } : e : void 0, Hn = (e, t) => (Array.isArray(e) ? e : [e]).map((n) => {
1257
+ const { id: o, type: i, purpose: r, value: s, created: a, modified: d, creator: f, ...h } = n;
1258
1258
  return {
1259
- id: o || `temp-${Hn(n)}`,
1259
+ id: o || `temp-${Un(n)}`,
1260
1260
  annotation: t,
1261
1261
  type: i,
1262
1262
  purpose: r,
@@ -1264,9 +1264,9 @@ const Un = () => ({ isGuest: !0, id: Dn("1234567890abcdefghijklmnopqrstuvwxyzABC
1264
1264
  creator: ce(f),
1265
1265
  created: a ? new Date(a) : void 0,
1266
1266
  updated: d ? new Date(d) : void 0,
1267
- ...g
1267
+ ...h
1268
1268
  };
1269
- }), Yn = (e) => e.map((t) => {
1269
+ }), _n = (e) => e.map((t) => {
1270
1270
  var n;
1271
1271
  const { annotation: o, created: i, updated: r, ...s } = t, a = {
1272
1272
  ...s,
@@ -1275,11 +1275,11 @@ const Un = () => ({ isGuest: !0, id: Dn("1234567890abcdefghijklmnopqrstuvwxyzABC
1275
1275
  };
1276
1276
  return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
1277
1277
  });
1278
- yn();
1278
+ Dn();
1279
1279
  const To = (e, t) => ({
1280
- parse: (n) => jn(n),
1281
- serialize: (n) => Gn(n, e, t)
1282
- }), Xn = (e) => e.quote !== void 0 && e.start !== void 0 && e.end !== void 0, $n = (e) => {
1280
+ parse: (n) => $n(n),
1281
+ serialize: (n) => jn(n, e, t)
1282
+ }), Yn = (e) => e.quote !== void 0 && e.start !== void 0 && e.end !== void 0, Xn = (e) => {
1283
1283
  const {
1284
1284
  id: t,
1285
1285
  creator: n,
@@ -1298,36 +1298,36 @@ const To = (e, t) => ({
1298
1298
  styleClass: s[0].styleClass
1299
1299
  };
1300
1300
  for (const d of s) {
1301
- const g = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, m) => {
1302
- switch (m.type) {
1301
+ const h = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((l, g) => {
1302
+ switch (g.type) {
1303
1303
  case "TextQuoteSelector":
1304
- l.quote = m.exact;
1304
+ l.quote = g.exact;
1305
1305
  break;
1306
1306
  case "TextPositionSelector":
1307
- l.start = m.start, l.end = m.end;
1307
+ l.start = g.start, l.end = g.end;
1308
1308
  break;
1309
1309
  }
1310
1310
  return l;
1311
1311
  }, {});
1312
- if (Xn(g))
1313
- a.selector.push({ id: d.id, ...g });
1312
+ if (Yn(h))
1313
+ a.selector.push({ id: d.id, ...h });
1314
1314
  else {
1315
1315
  const l = [
1316
- g.start ? void 0 : "TextPositionSelector",
1317
- g.quote ? void 0 : "TextQuoteSelector"
1316
+ h.start ? void 0 : "TextPositionSelector",
1317
+ h.quote ? void 0 : "TextQuoteSelector"
1318
1318
  ].filter(Boolean);
1319
1319
  return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${e.id}`) };
1320
1320
  }
1321
1321
  }
1322
1322
  return { parsed: a };
1323
- }, jn = (e) => {
1323
+ }, $n = (e) => {
1324
1324
  const t = e.id || se(), {
1325
1325
  creator: n,
1326
1326
  created: o,
1327
1327
  modified: i,
1328
1328
  body: r,
1329
1329
  ...s
1330
- } = e, a = _n(r, t), d = $n(e);
1330
+ } = e, a = Hn(r, t), d = Xn(e);
1331
1331
  return "error" in d ? { error: d.error } : {
1332
1332
  parsed: {
1333
1333
  ...s,
@@ -1336,29 +1336,29 @@ const To = (e, t) => ({
1336
1336
  target: d.parsed
1337
1337
  }
1338
1338
  };
1339
- }, Gn = (e, t, n) => {
1339
+ }, jn = (e, t, n) => {
1340
1340
  const { bodies: o, target: i, ...r } = e, {
1341
1341
  selector: s,
1342
1342
  creator: a,
1343
1343
  created: d,
1344
1344
  updated: f,
1345
- ...g
1346
- } = i, l = s.map((m) => {
1347
- const { quote: c, start: S, end: v, range: w } = m, { prefix: p, suffix: u } = Re(w, n), A = [{
1345
+ ...h
1346
+ } = i, l = s.map((g) => {
1347
+ const { quote: c, start: A, end: C, range: b } = g, { prefix: p, suffix: u } = Be(b, n), w = [{
1348
1348
  type: "TextQuoteSelector",
1349
1349
  exact: c,
1350
1350
  prefix: p,
1351
1351
  suffix: u
1352
1352
  }, {
1353
1353
  type: "TextPositionSelector",
1354
- start: S,
1355
- end: v
1354
+ start: A,
1355
+ end: C
1356
1356
  }];
1357
1357
  return {
1358
- ...g,
1359
- id: m.id,
1358
+ ...h,
1359
+ id: g.id,
1360
1360
  source: t,
1361
- selector: A
1361
+ selector: w
1362
1362
  };
1363
1363
  });
1364
1364
  return {
@@ -1366,38 +1366,38 @@ const To = (e, t) => ({
1366
1366
  "@context": "http://www.w3.org/ns/anno.jsonld",
1367
1367
  id: e.id,
1368
1368
  type: "Annotation",
1369
- body: Yn(e.bodies),
1369
+ body: _n(e.bodies),
1370
1370
  creator: a,
1371
1371
  created: d == null ? void 0 : d.toISOString(),
1372
1372
  modified: f == null ? void 0 : f.toISOString(),
1373
1373
  target: l
1374
1374
  };
1375
1375
  };
1376
- function Wn(e, t, n, o, i) {
1377
- de(e, t, n || 0, o || e.length - 1, i || zn);
1376
+ function Gn(e, t, n, o, i) {
1377
+ de(e, t, n || 0, o || e.length - 1, i || Wn);
1378
1378
  }
1379
1379
  function de(e, t, n, o, i) {
1380
1380
  for (; o > n; ) {
1381
1381
  if (o - n > 600) {
1382
- var r = o - n + 1, s = t - n + 1, a = Math.log(r), d = 0.5 * Math.exp(2 * a / 3), f = 0.5 * Math.sqrt(a * d * (r - d) / r) * (s - r / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(t - s * d / r + f)), l = Math.min(o, Math.floor(t + (r - s) * d / r + f));
1383
- de(e, t, g, l, i);
1382
+ var r = o - n + 1, s = t - n + 1, a = Math.log(r), d = 0.5 * Math.exp(2 * a / 3), f = 0.5 * Math.sqrt(a * d * (r - d) / r) * (s - r / 2 < 0 ? -1 : 1), h = Math.max(n, Math.floor(t - s * d / r + f)), l = Math.min(o, Math.floor(t + (r - s) * d / r + f));
1383
+ de(e, t, h, l, i);
1384
1384
  }
1385
- var m = e[t], c = n, S = o;
1386
- for (tt(e, n, t), i(e[o], m) > 0 && tt(e, n, o); c < S; ) {
1387
- for (tt(e, c, S), c++, S--; i(e[c], m) < 0; ) c++;
1388
- for (; i(e[S], m) > 0; ) S--;
1385
+ var g = e[t], c = n, A = o;
1386
+ for (tt(e, n, t), i(e[o], g) > 0 && tt(e, n, o); c < A; ) {
1387
+ for (tt(e, c, A), c++, A--; i(e[c], g) < 0; ) c++;
1388
+ for (; i(e[A], g) > 0; ) A--;
1389
1389
  }
1390
- i(e[n], m) === 0 ? tt(e, n, S) : (S++, tt(e, S, o)), S <= t && (n = S + 1), t <= S && (o = S - 1);
1390
+ i(e[n], g) === 0 ? tt(e, n, A) : (A++, tt(e, A, o)), A <= t && (n = A + 1), t <= A && (o = A - 1);
1391
1391
  }
1392
1392
  }
1393
1393
  function tt(e, t, n) {
1394
1394
  var o = e[t];
1395
1395
  e[t] = e[n], e[n] = o;
1396
1396
  }
1397
- function zn(e, t) {
1397
+ function Wn(e, t) {
1398
1398
  return e < t ? -1 : e > t ? 1 : 0;
1399
1399
  }
1400
- class qn {
1400
+ class zn {
1401
1401
  constructor(t = 9) {
1402
1402
  this._maxEntries = Math.max(4, t), this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4)), this.clear();
1403
1403
  }
@@ -1468,9 +1468,9 @@ class qn {
1468
1468
  let a, d, f;
1469
1469
  for (; o || r.length; ) {
1470
1470
  if (o || (o = r.pop(), d = r[r.length - 1], a = s.pop(), f = !0), o.leaf) {
1471
- const g = Zn(t, o.children, n);
1472
- if (g !== -1)
1473
- return o.children.splice(g, 1), r.push(o), this._condense(r), this;
1471
+ const h = qn(t, o.children, n);
1472
+ if (h !== -1)
1473
+ return o.children.splice(h, 1), r.push(o), this._condense(r), this;
1474
1474
  }
1475
1475
  !f && !o.leaf && Tt(o, i) ? (r.push(o), s.push(a), a = 0, d = o, o = o.children[0]) : d ? (a++, o = d.children[a], f = !1) : o = null;
1476
1476
  }
@@ -1505,12 +1505,12 @@ class qn {
1505
1505
  i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = Q([]), a.leaf = !1, a.height = i;
1506
1506
  const d = Math.ceil(r / s), f = d * Math.ceil(Math.sqrt(s));
1507
1507
  Qt(t, n, o, f, this.compareMinX);
1508
- for (let g = n; g <= o; g += f) {
1509
- const l = Math.min(g + f - 1, o);
1510
- Qt(t, g, l, d, this.compareMinY);
1511
- for (let m = g; m <= l; m += d) {
1512
- const c = Math.min(m + d - 1, l);
1513
- a.children.push(this._build(t, m, c, i - 1));
1508
+ for (let h = n; h <= o; h += f) {
1509
+ const l = Math.min(h + f - 1, o);
1510
+ Qt(t, h, l, d, this.compareMinY);
1511
+ for (let g = h; g <= l; g += d) {
1512
+ const c = Math.min(g + d - 1, l);
1513
+ a.children.push(this._build(t, g, c, i - 1));
1514
1514
  }
1515
1515
  }
1516
1516
  return J(a, this.toBBox), a;
@@ -1519,8 +1519,8 @@ class qn {
1519
1519
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1520
1520
  let r = 1 / 0, s = 1 / 0, a;
1521
1521
  for (let d = 0; d < n.children.length; d++) {
1522
- const f = n.children[d], g = Lt(f), l = Kn(t, f) - g;
1523
- l < s ? (s = l, r = g < r ? g : r, a = f) : l === s && g < r && (r = g, a = f);
1522
+ const f = n.children[d], h = Lt(f), l = Qn(t, f) - h;
1523
+ l < s ? (s = l, r = h < r ? h : r, a = f) : l === s && h < r && (r = h, a = f);
1524
1524
  }
1525
1525
  n = a || n.children[0];
1526
1526
  }
@@ -1545,14 +1545,14 @@ class qn {
1545
1545
  _chooseSplitIndex(t, n, o) {
1546
1546
  let i, r = 1 / 0, s = 1 / 0;
1547
1547
  for (let a = n; a <= o - n; a++) {
1548
- const d = nt(t, 0, a, this.toBBox), f = nt(t, a, o, this.toBBox), g = to(d, f), l = Lt(d) + Lt(f);
1549
- g < r ? (r = g, i = a, s = l < s ? l : s) : g === r && l < s && (s = l, i = a);
1548
+ const d = nt(t, 0, a, this.toBBox), f = nt(t, a, o, this.toBBox), h = Kn(d, f), l = Lt(d) + Lt(f);
1549
+ h < r ? (r = h, i = a, s = l < s ? l : s) : h === r && l < s && (s = l, i = a);
1550
1550
  }
1551
1551
  return i || o - n;
1552
1552
  }
1553
1553
  // sorts node children by the best axis for split
1554
1554
  _chooseSplitAxis(t, n, o) {
1555
- const i = t.leaf ? this.compareMinX : Jn, r = t.leaf ? this.compareMinY : Qn, s = this._allDistMargin(t, n, o, i), a = this._allDistMargin(t, n, o, r);
1555
+ const i = t.leaf ? this.compareMinX : Zn, r = t.leaf ? this.compareMinY : Jn, s = this._allDistMargin(t, n, o, i), a = this._allDistMargin(t, n, o, r);
1556
1556
  s < a && t.children.sort(i);
1557
1557
  }
1558
1558
  // total margin of all possible split distributions where each node is at least m full
@@ -1561,12 +1561,12 @@ class qn {
1561
1561
  const r = this.toBBox, s = nt(t, 0, n, r), a = nt(t, o - n, o, r);
1562
1562
  let d = ft(s) + ft(a);
1563
1563
  for (let f = n; f < o - n; f++) {
1564
- const g = t.children[f];
1565
- ot(s, t.leaf ? r(g) : g), d += ft(s);
1564
+ const h = t.children[f];
1565
+ ot(s, t.leaf ? r(h) : h), d += ft(s);
1566
1566
  }
1567
1567
  for (let f = o - n - 1; f >= n; f--) {
1568
- const g = t.children[f];
1569
- ot(a, t.leaf ? r(g) : g), d += ft(a);
1568
+ const h = t.children[f];
1569
+ ot(a, t.leaf ? r(h) : h), d += ft(a);
1570
1570
  }
1571
1571
  return d;
1572
1572
  }
@@ -1579,7 +1579,7 @@ class qn {
1579
1579
  t[n].children.length === 0 ? n > 0 ? (o = t[n - 1].children, o.splice(o.indexOf(t[n]), 1)) : this.clear() : J(t[n], this.toBBox);
1580
1580
  }
1581
1581
  }
1582
- function Zn(e, t, n) {
1582
+ function qn(e, t, n) {
1583
1583
  if (!n) return t.indexOf(e);
1584
1584
  for (let o = 0; o < t.length; o++)
1585
1585
  if (n(e, t[o])) return o;
@@ -1599,10 +1599,10 @@ function nt(e, t, n, o, i) {
1599
1599
  function ot(e, t) {
1600
1600
  return e.minX = Math.min(e.minX, t.minX), e.minY = Math.min(e.minY, t.minY), e.maxX = Math.max(e.maxX, t.maxX), e.maxY = Math.max(e.maxY, t.maxY), e;
1601
1601
  }
1602
- function Jn(e, t) {
1602
+ function Zn(e, t) {
1603
1603
  return e.minX - t.minX;
1604
1604
  }
1605
- function Qn(e, t) {
1605
+ function Jn(e, t) {
1606
1606
  return e.minY - t.minY;
1607
1607
  }
1608
1608
  function Lt(e) {
@@ -1611,10 +1611,10 @@ function Lt(e) {
1611
1611
  function ft(e) {
1612
1612
  return e.maxX - e.minX + (e.maxY - e.minY);
1613
1613
  }
1614
- function Kn(e, t) {
1614
+ function Qn(e, t) {
1615
1615
  return (Math.max(t.maxX, e.maxX) - Math.min(t.minX, e.minX)) * (Math.max(t.maxY, e.maxY) - Math.min(t.minY, e.minY));
1616
1616
  }
1617
- function to(e, t) {
1617
+ function Kn(e, t) {
1618
1618
  const n = Math.max(e.minX, t.minX), o = Math.max(e.minY, t.minY), i = Math.min(e.maxX, t.maxX), r = Math.min(e.maxY, t.maxY);
1619
1619
  return Math.max(0, i - n) * Math.max(0, r - o);
1620
1620
  }
@@ -1640,10 +1640,10 @@ function Qt(e, t, n, o, i) {
1640
1640
  for (; r.length; ) {
1641
1641
  if (n = r.pop(), t = r.pop(), n - t <= o) continue;
1642
1642
  const s = t + Math.ceil((n - t) / o / 2) * o;
1643
- Wn(e, s, t, n, i), r.push(t, s, s, n);
1643
+ Gn(e, s, t, n, i), r.push(t, s, s, n);
1644
1644
  }
1645
1645
  }
1646
- let eo = () => ({
1646
+ let to = () => ({
1647
1647
  emit(e, ...t) {
1648
1648
  for (let n = 0, o = this.events[e] || [], i = o.length; n < i; n++)
1649
1649
  o[n](...t);
@@ -1657,120 +1657,120 @@ let eo = () => ({
1657
1657
  };
1658
1658
  }
1659
1659
  });
1660
- const no = (e, t) => {
1661
- const n = new qn(), o = /* @__PURE__ */ new Map(), i = eo(), r = (A, h) => {
1662
- const E = A.selector.flatMap((k) => {
1660
+ const eo = (e, t) => {
1661
+ const n = new zn(), o = /* @__PURE__ */ new Map(), i = to(), r = (w, x) => {
1662
+ const v = w.selector.flatMap((k) => {
1663
1663
  const T = z([k]) ? k.range : oe(k, t).range;
1664
1664
  return Array.from(T.getClientRects());
1665
- }), B = Ie(E).map((k) => De(k, h));
1666
- return B.map((k) => {
1667
- const { x: T, y: M, width: b, height: C } = k;
1665
+ }), M = Ne(v).map((k) => Pe(k, x));
1666
+ return M.map((k) => {
1667
+ const { x: T, y: B, width: m, height: S } = k;
1668
1668
  return {
1669
1669
  minX: T,
1670
- minY: M,
1671
- maxX: T + b,
1672
- maxY: M + C,
1670
+ minY: B,
1671
+ maxX: T + m,
1672
+ maxY: B + S,
1673
1673
  annotation: {
1674
- id: A.annotation,
1675
- rects: B
1674
+ id: w.annotation,
1675
+ rects: M
1676
1676
  }
1677
1677
  };
1678
1678
  });
1679
1679
  }, s = () => [...o.values()], a = () => {
1680
1680
  n.clear(), o.clear();
1681
- }, d = (A) => {
1682
- const h = r(A, t.getBoundingClientRect());
1683
- h.forEach((E) => n.insert(E)), o.set(A.annotation, h);
1684
- }, f = (A) => {
1685
- const h = o.get(A.annotation);
1686
- h && (h.forEach((E) => n.remove(E)), o.delete(A.annotation));
1687
- }, g = (A) => {
1688
- f(A), d(A);
1689
- }, l = (A, h = !0) => {
1690
- h && a();
1691
- const E = t.getBoundingClientRect(), B = A.map((T) => ({ target: T, rects: r(T, E) }));
1692
- B.forEach(({ target: T, rects: M }) => o.set(T.annotation, M));
1693
- const k = B.flatMap(({ rects: T }) => T);
1681
+ }, d = (w) => {
1682
+ const x = r(w, t.getBoundingClientRect());
1683
+ x.forEach((v) => n.insert(v)), o.set(w.annotation, x);
1684
+ }, f = (w) => {
1685
+ const x = o.get(w.annotation);
1686
+ x && (x.forEach((v) => n.remove(v)), o.delete(w.annotation));
1687
+ }, h = (w) => {
1688
+ f(w), d(w);
1689
+ }, l = (w, x = !0) => {
1690
+ x && a();
1691
+ const v = t.getBoundingClientRect(), M = w.map((T) => ({ target: T, rects: r(T, v) }));
1692
+ M.forEach(({ target: T, rects: B }) => o.set(T.annotation, B));
1693
+ const k = M.flatMap(({ rects: T }) => T);
1694
1694
  n.load(k);
1695
- }, m = (A, h, E = !1) => {
1696
- const B = n.search({
1697
- minX: A,
1698
- minY: h,
1699
- maxX: A,
1700
- maxY: h
1701
- }), k = (T) => T.annotation.rects.reduce((M, b) => M + b.width * b.height, 0);
1702
- return B.length > 0 ? (B.sort((T, M) => k(T) - k(M)), E ? B.map((T) => T.annotation.id) : [B[0].annotation.id]) : [];
1703
- }, c = (A) => {
1704
- const h = S(A);
1705
- if (h.length === 0)
1695
+ }, g = (w, x, v = !1) => {
1696
+ const M = n.search({
1697
+ minX: w,
1698
+ minY: x,
1699
+ maxX: w,
1700
+ maxY: x
1701
+ }), k = (T) => T.annotation.rects.reduce((B, m) => B + m.width * m.height, 0);
1702
+ return M.length > 0 ? (M.sort((T, B) => k(T) - k(B)), v ? M.map((T) => T.annotation.id) : [M[0].annotation.id]) : [];
1703
+ }, c = (w) => {
1704
+ const x = A(w);
1705
+ if (x.length === 0)
1706
1706
  return;
1707
- let E = h[0].left, B = h[0].top, k = h[0].right, T = h[0].bottom;
1708
- for (let M = 1; M < h.length; M++) {
1709
- const b = h[M];
1710
- E = Math.min(E, b.left), B = Math.min(B, b.top), k = Math.max(k, b.right), T = Math.max(T, b.bottom);
1707
+ let v = x[0].left, M = x[0].top, k = x[0].right, T = x[0].bottom;
1708
+ for (let B = 1; B < x.length; B++) {
1709
+ const m = x[B];
1710
+ v = Math.min(v, m.left), M = Math.min(M, m.top), k = Math.max(k, m.right), T = Math.max(T, m.bottom);
1711
1711
  }
1712
- return new DOMRect(E, B, k - E, T - B);
1713
- }, S = (A) => {
1714
- const h = o.get(A);
1715
- return h ? h[0].annotation.rects : [];
1712
+ return new DOMRect(v, M, k - v, T - M);
1713
+ }, A = (w) => {
1714
+ const x = o.get(w);
1715
+ return x ? x[0].annotation.rects : [];
1716
1716
  };
1717
1717
  return {
1718
1718
  all: s,
1719
1719
  clear: a,
1720
- getAt: m,
1720
+ getAt: g,
1721
1721
  getAnnotationBounds: c,
1722
- getAnnotationRects: S,
1723
- getIntersecting: (A, h, E, B) => {
1724
- const k = n.search({ minX: A, minY: h, maxX: E, maxY: B }), T = new Set(k.map((M) => M.annotation.id));
1725
- return Array.from(T).map((M) => ({
1726
- annotation: e.getAnnotation(M),
1727
- rects: S(M)
1728
- })).filter((M) => !!M.annotation);
1722
+ getAnnotationRects: A,
1723
+ getIntersecting: (w, x, v, M) => {
1724
+ const k = n.search({ minX: w, minY: x, maxX: v, maxY: M }), T = new Set(k.map((B) => B.annotation.id));
1725
+ return Array.from(T).map((B) => ({
1726
+ annotation: e.getAnnotation(B),
1727
+ rects: A(B)
1728
+ })).filter((B) => !!B.annotation);
1729
1729
  },
1730
1730
  insert: d,
1731
1731
  recalculate: () => {
1732
- l(e.all().map((A) => A.target), !0), i.emit("recalculate");
1732
+ l(e.all().map((w) => w.target), !0), i.emit("recalculate");
1733
1733
  },
1734
1734
  remove: f,
1735
1735
  set: l,
1736
1736
  size: () => n.all().length,
1737
- update: g,
1738
- on: (A, h) => i.on(A, h)
1737
+ update: h,
1738
+ on: (w, x) => i.on(w, x)
1739
1739
  };
1740
- }, oo = (e, t) => {
1741
- const n = Tn(), o = no(n, e), i = pn(n, t), r = un(n), s = kn(), a = (w, p = V.LOCAL) => {
1742
- const u = bt(w, e), A = z(u.target.selector);
1743
- return A && n.addAnnotation(u, p), A;
1744
- }, d = (w, p = !0, u = V.LOCAL) => {
1745
- const A = w.map((E) => bt(E, e)), h = A.filter((E) => !z(E.target.selector));
1746
- return h.length > 0 ? (console.warn("Could not revive all targets for these annotations:", h), n.bulkAddAnnotation(A, p, u), h) : (n.bulkAddAnnotation(A, p, u), []);
1747
- }, f = (w, p = V.LOCAL) => {
1748
- const u = w.map((h) => bt(h, e)), A = u.filter((h) => !z(h.target.selector));
1749
- return A.length > 0 && console.warn("Could not revive all targets for these annotations:", A), u.forEach((h) => {
1750
- n.getAnnotation(h.id) ? n.updateAnnotation(h, p) : n.addAnnotation(h, p);
1751
- }), A;
1752
- }, g = (w, p = V.LOCAL) => {
1753
- const u = mt(w, e);
1740
+ }, no = (e, t) => {
1741
+ const n = Ln(), o = eo(n, e), i = fn(n, t), r = dn(n), s = Rn(), a = (b, p = V.LOCAL) => {
1742
+ const u = bt(b, e), w = z(u.target.selector);
1743
+ return w && n.addAnnotation(u, p), w;
1744
+ }, d = (b, p = !0, u = V.LOCAL) => {
1745
+ const w = b.map((v) => bt(v, e)), x = w.filter((v) => !z(v.target.selector));
1746
+ return x.length > 0 ? (console.warn("Could not revive all targets for these annotations:", x), n.bulkAddAnnotation(w, p, u), x) : (n.bulkAddAnnotation(w, p, u), []);
1747
+ }, f = (b, p = V.LOCAL) => {
1748
+ const u = b.map((x) => bt(x, e)), w = u.filter((x) => !z(x.target.selector));
1749
+ return w.length > 0 && console.warn("Could not revive all targets for these annotations:", w), u.forEach((x) => {
1750
+ n.getAnnotation(x.id) ? n.updateAnnotation(x, p) : n.addAnnotation(x, p);
1751
+ }), w;
1752
+ }, h = (b, p = V.LOCAL) => {
1753
+ const u = mt(b, e);
1754
1754
  n.updateTarget(u, p);
1755
- }, l = (w, p = V.LOCAL) => {
1756
- const u = w.map((A) => mt(A, e));
1755
+ }, l = (b, p = V.LOCAL) => {
1756
+ const u = b.map((w) => mt(w, e));
1757
1757
  n.bulkUpdateTargets(u, p);
1758
- }, m = (w, p, u) => {
1759
- const A = o.getAt(w, p, !!u).map((E) => n.getAnnotation(E)), h = u ? A.filter(u) : A;
1760
- return h.length > 0 ? h[0] : void 0;
1761
- }, c = (w, p, u, A = 5) => {
1762
- const h = o.getAnnotationRects(w);
1763
- if (h.length !== 0) {
1758
+ }, g = (b, p, u) => {
1759
+ const w = o.getAt(b, p, !!u).map((v) => n.getAnnotation(v)), x = u ? w.filter(u) : w;
1760
+ return x.length > 0 ? x[0] : void 0;
1761
+ }, c = (b, p, u, w = 5) => {
1762
+ const x = o.getAnnotationRects(b);
1763
+ if (x.length !== 0) {
1764
1764
  if (p && u) {
1765
- const E = h.find(({ top: B, right: k, bottom: T, left: M }) => p >= M - A && p <= k + A && u >= B - A && u <= T + A);
1766
- if (E) return E;
1765
+ const v = x.find(({ top: M, right: k, bottom: T, left: B }) => p >= B - w && p <= k + w && u >= M - w && u <= T + w);
1766
+ if (v) return v;
1767
1767
  }
1768
- return o.getAnnotationBounds(w);
1768
+ return o.getAnnotationBounds(b);
1769
1769
  }
1770
- }, S = () => o.recalculate(), v = (w) => o.on("recalculate", w);
1771
- return n.observe(({ changes: w }) => {
1772
- const p = (w.deleted || []).filter((h) => z(h.target.selector)), u = (w.created || []).filter((h) => z(h.target.selector)), A = (w.updated || []).filter((h) => z(h.newValue.target.selector));
1773
- (p == null ? void 0 : p.length) > 0 && p.forEach((h) => o.remove(h.target)), u.length > 0 && o.set(u.map((h) => h.target), !1), (A == null ? void 0 : A.length) > 0 && A.forEach(({ newValue: h }) => o.update(h.target));
1770
+ }, A = () => o.recalculate(), C = (b) => o.on("recalculate", b);
1771
+ return n.observe(({ changes: b }) => {
1772
+ const p = (b.deleted || []).filter((x) => z(x.target.selector)), u = (b.created || []).filter((x) => z(x.target.selector)), w = (b.updated || []).filter((x) => z(x.newValue.target.selector));
1773
+ (p == null ? void 0 : p.length) > 0 && p.forEach((x) => o.remove(x.target)), u.length > 0 && o.set(u.map((x) => x.target), !1), (w == null ? void 0 : w.length) > 0 && w.forEach(({ newValue: x }) => o.update(x.target));
1774
1774
  }), {
1775
1775
  store: {
1776
1776
  ...n,
@@ -1779,45 +1779,45 @@ const no = (e, t) => {
1779
1779
  bulkUpdateTargets: l,
1780
1780
  bulkUpsertAnnotations: f,
1781
1781
  getAnnotationBounds: c,
1782
- getAt: m,
1782
+ getAt: g,
1783
1783
  getIntersecting: o.getIntersecting.bind(o),
1784
1784
  getAnnotationRects: o.getAnnotationRects.bind(o),
1785
- recalculatePositions: S,
1786
- onRecalculatePositions: v,
1787
- updateTarget: g
1785
+ recalculatePositions: A,
1786
+ onRecalculatePositions: C,
1787
+ updateTarget: h
1788
1788
  },
1789
1789
  selection: i,
1790
1790
  hover: r,
1791
1791
  viewport: s
1792
1792
  };
1793
- }, io = () => {
1793
+ }, oo = () => {
1794
1794
  const e = document.createElement("canvas");
1795
1795
  e.width = 2 * window.innerWidth, e.height = 2 * window.innerHeight, e.className = "r6o-presence-layer";
1796
1796
  const t = e.getContext("2d");
1797
1797
  return t.scale(2, 2), t.translate(0.5, 0.5), e;
1798
- }, ro = (e, t, n = {}) => {
1799
- const o = io(), i = o.getContext("2d");
1798
+ }, io = (e, t, n = {}) => {
1799
+ const o = oo(), i = o.getContext("2d");
1800
1800
  document.body.appendChild(o);
1801
- const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([m, c]) => c.presenceKey === l.presenceKey).map(([m, c]) => m);
1802
- return t.on("selectionChange", (l, m) => {
1803
- s(l).forEach((S) => r.delete(S)), m && m.forEach((S) => r.set(S, l));
1801
+ const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([g, c]) => c.presenceKey === l.presenceKey).map(([g, c]) => g);
1802
+ return t.on("selectionChange", (l, g) => {
1803
+ s(l).forEach((A) => r.delete(A)), g && g.forEach((A) => r.set(A, l));
1804
1804
  }), {
1805
1805
  clear: () => {
1806
- const { width: l, height: m } = o;
1807
- i.clearRect(-0.5, -0.5, l + 1, m + 1);
1806
+ const { width: l, height: g } = o;
1807
+ i.clearRect(-0.5, -0.5, l + 1, g + 1);
1808
1808
  },
1809
1809
  destroy: () => {
1810
1810
  o.remove();
1811
1811
  },
1812
- paint: (l, m, c) => {
1812
+ paint: (l, g, c) => {
1813
1813
  n.font && (i.font = n.font);
1814
- const S = r.get(l.annotation.id);
1815
- if (S) {
1816
- const { height: v } = l.rects[0], w = l.rects[0].x + m.left, p = l.rects[0].y + m.top;
1817
- i.fillStyle = S.appearance.color, i.fillRect(w - 2, p - 2.5, 2, v + 5);
1818
- const u = i.measureText(S.appearance.label), A = u.width + 6, h = u.actualBoundingBoxAscent + u.actualBoundingBoxDescent + 8, E = u.fontBoundingBoxAscent ? 8 : 6.5;
1819
- return i.fillRect(w - 2, p - 2.5 - h, A, h), i.fillStyle = "#fff", i.fillText(S.appearance.label, w + 1, p - E), {
1820
- fill: S.appearance.color,
1814
+ const A = r.get(l.annotation.id);
1815
+ if (A) {
1816
+ const { height: C } = l.rects[0], b = l.rects[0].x + g.left, p = l.rects[0].y + g.top;
1817
+ i.fillStyle = A.appearance.color, i.fillRect(b - 2, p - 2.5, 2, C + 5);
1818
+ const u = i.measureText(A.appearance.label), w = u.width + 6, x = u.actualBoundingBoxAscent + u.actualBoundingBoxDescent + 8, v = u.fontBoundingBoxAscent ? 8 : 6.5;
1819
+ return i.fillRect(b - 2, p - 2.5 - x, w, x), i.fillStyle = "#fff", i.fillText(A.appearance.label, b + 1, p - v), {
1820
+ fill: A.appearance.color,
1821
1821
  fillOpacity: c ? 0.45 : 0.18
1822
1822
  };
1823
1823
  }
@@ -1833,9 +1833,9 @@ const no = (e, t) => {
1833
1833
  return document.scrollingElement;
1834
1834
  const { overflowY: t } = window.getComputedStyle(e);
1835
1835
  return t !== "visible" && t !== "hidden" && e.scrollHeight > e.clientHeight ? e : ue(e.parentElement);
1836
- }, ao = (e, t) => (n) => {
1836
+ }, ro = (e, t) => (n) => {
1837
1837
  const o = typeof n == "string" ? n : n.id, i = (s) => {
1838
- const a = r.getBoundingClientRect(), d = r.clientHeight, f = r.clientWidth, g = s.selector[0].range.getBoundingClientRect(), { width: l, height: m } = t.getAnnotationBounds(o), c = g.top - a.top, S = g.left - a.left, v = r.parentElement ? r.scrollTop : 0, w = r.parentElement ? r.scrollLeft : 0, p = c + v - (d - m) / 2, u = S + w - (f - l) / 2;
1838
+ const a = r.getBoundingClientRect(), d = r.clientHeight, f = r.clientWidth, h = s.selector[0].range.getBoundingClientRect(), { width: l, height: g } = t.getAnnotationBounds(o), c = h.top - a.top, A = h.left - a.left, C = r.parentElement ? r.scrollTop : 0, b = r.parentElement ? r.scrollLeft : 0, p = c + C - (d - g) / 2, u = A + b - (f - l) / 2;
1839
1839
  r.scroll({ top: p, left: u, behavior: "smooth" });
1840
1840
  }, r = ue(e);
1841
1841
  if (r) {
@@ -1849,7 +1849,7 @@ const no = (e, t) => {
1849
1849
  }
1850
1850
  }
1851
1851
  return !1;
1852
- }, so = (e, t) => ({
1852
+ }, ao = (e, t) => ({
1853
1853
  ...e,
1854
1854
  annotatingEnabled: e.annotatingEnabled ?? t.annotatingEnabled,
1855
1855
  user: e.user || t.user
@@ -1873,7 +1873,7 @@ function pe(e) {
1873
1873
  t[n - 1] += ",", t.splice(n, 1), n = t.lastIndexOf("");
1874
1874
  return t;
1875
1875
  }
1876
- function lo(e, t) {
1876
+ function so(e, t) {
1877
1877
  const n = e.length >= t.length ? e : t, o = e.length >= t.length ? t : e;
1878
1878
  let i = !0;
1879
1879
  for (let r = 0; r < n.length; r++)
@@ -1932,7 +1932,7 @@ const at = {
1932
1932
  "[": 219,
1933
1933
  "]": 221,
1934
1934
  "\\": 220
1935
- }, $ = {
1935
+ }, j = {
1936
1936
  // shiftKey
1937
1937
  "⇧": 16,
1938
1938
  shift: 16,
@@ -1962,27 +1962,27 @@ const at = {
1962
1962
  18: !1,
1963
1963
  17: !1,
1964
1964
  91: !1
1965
- }, N = {};
1965
+ }, I = {};
1966
1966
  for (let e = 1; e < 20; e++)
1967
1967
  at["f".concat(e)] = 111 + e;
1968
1968
  let O = [], rt = null, he = "all";
1969
- const W = /* @__PURE__ */ new Map(), lt = (e) => at[e.toLowerCase()] || $[e.toLowerCase()] || e.toUpperCase().charCodeAt(0), co = (e) => Object.keys(at).find((t) => at[t] === e), uo = (e) => Object.keys($).find((t) => $[t] === e);
1969
+ const W = /* @__PURE__ */ new Map(), lt = (e) => at[e.toLowerCase()] || j[e.toLowerCase()] || e.toUpperCase().charCodeAt(0), lo = (e) => Object.keys(at).find((t) => at[t] === e), co = (e) => Object.keys(j).find((t) => j[t] === e);
1970
1970
  function ge(e) {
1971
1971
  he = e || "all";
1972
1972
  }
1973
1973
  function st() {
1974
1974
  return he || "all";
1975
1975
  }
1976
- function fo() {
1976
+ function uo() {
1977
1977
  return O.slice(0);
1978
1978
  }
1979
- function po() {
1980
- return O.map((e) => co(e) || uo(e) || String.fromCharCode(e));
1979
+ function fo() {
1980
+ return O.map((e) => lo(e) || co(e) || String.fromCharCode(e));
1981
1981
  }
1982
- function ho() {
1982
+ function po() {
1983
1983
  const e = [];
1984
- return Object.keys(N).forEach((t) => {
1985
- N[t].forEach((n) => {
1984
+ return Object.keys(I).forEach((t) => {
1985
+ I[t].forEach((n) => {
1986
1986
  let {
1987
1987
  key: o,
1988
1988
  scope: i,
@@ -1998,7 +1998,7 @@ function ho() {
1998
1998
  });
1999
1999
  }), e;
2000
2000
  }
2001
- function go(e) {
2001
+ function ho(e) {
2002
2002
  const t = e.target || e.srcElement, {
2003
2003
  tagName: n
2004
2004
  } = t;
@@ -2006,15 +2006,15 @@ function go(e) {
2006
2006
  const i = n === "INPUT" && !["checkbox", "radio", "range", "button", "file", "reset", "submit", "color"].includes(t.type);
2007
2007
  return (t.isContentEditable || (i || n === "TEXTAREA" || n === "SELECT") && !t.readOnly) && (o = !1), o;
2008
2008
  }
2009
- function mo(e) {
2009
+ function go(e) {
2010
2010
  return typeof e == "string" && (e = lt(e)), O.indexOf(e) !== -1;
2011
2011
  }
2012
- function bo(e, t) {
2012
+ function mo(e, t) {
2013
2013
  let n, o;
2014
2014
  e || (e = st());
2015
- for (const i in N)
2016
- if (Object.prototype.hasOwnProperty.call(N, i))
2017
- for (n = N[i], o = 0; o < n.length; )
2015
+ for (const i in I)
2016
+ if (Object.prototype.hasOwnProperty.call(I, i))
2017
+ for (n = I[i], o = 0; o < n.length; )
2018
2018
  n[o].scope === e ? n.splice(o, 1).forEach((s) => {
2019
2019
  let {
2020
2020
  element: a
@@ -2023,18 +2023,18 @@ function bo(e, t) {
2023
2023
  }) : o++;
2024
2024
  st() === e && ge(t || "all");
2025
2025
  }
2026
- function wo(e) {
2026
+ function bo(e) {
2027
2027
  let t = e.keyCode || e.which || e.charCode;
2028
2028
  const n = O.indexOf(t);
2029
2029
  if (n >= 0 && O.splice(n, 1), e.key && e.key.toLowerCase() === "meta" && O.splice(0, O.length), (t === 93 || t === 224) && (t = 91), t in y) {
2030
2030
  y[t] = !1;
2031
- for (const o in $) $[o] === t && (U[o] = !1);
2031
+ for (const o in j) j[o] === t && (Y[o] = !1);
2032
2032
  }
2033
2033
  }
2034
2034
  function me(e) {
2035
2035
  if (typeof e > "u")
2036
- Object.keys(N).forEach((i) => {
2037
- Array.isArray(N[i]) && N[i].forEach((r) => ht(r)), delete N[i];
2036
+ Object.keys(I).forEach((i) => {
2037
+ Array.isArray(I[i]) && I[i].forEach((r) => ht(r)), delete I[i];
2038
2038
  }), Pt(null);
2039
2039
  else if (Array.isArray(e))
2040
2040
  e.forEach((i) => {
@@ -2062,14 +2062,14 @@ const ht = (e) => {
2062
2062
  splitKey: i = "+"
2063
2063
  } = e;
2064
2064
  pe(t).forEach((s) => {
2065
- const a = s.split(i), d = a.length, f = a[d - 1], g = f === "*" ? "*" : lt(f);
2066
- if (!N[g]) return;
2065
+ const a = s.split(i), d = a.length, f = a[d - 1], h = f === "*" ? "*" : lt(f);
2066
+ if (!I[h]) return;
2067
2067
  n || (n = st());
2068
- const l = d > 1 ? fe($, a) : [], m = [];
2069
- N[g] = N[g].filter((c) => {
2070
- const v = (o ? c.method === o : !0) && c.scope === n && lo(c.mods, l);
2071
- return v && m.push(c.element), !v;
2072
- }), m.forEach((c) => Pt(c));
2068
+ const l = d > 1 ? fe(j, a) : [], g = [];
2069
+ I[h] = I[h].filter((c) => {
2070
+ const C = (o ? c.method === o : !0) && c.scope === n && so(c.mods, l);
2071
+ return C && g.push(c.element), !C;
2072
+ }), g.forEach((c) => Pt(c));
2073
2073
  });
2074
2074
  };
2075
2075
  function Kt(e, t, n, o) {
@@ -2084,16 +2084,16 @@ function Kt(e, t, n, o) {
2084
2084
  }
2085
2085
  }
2086
2086
  function te(e, t) {
2087
- const n = N["*"];
2087
+ const n = I["*"];
2088
2088
  let o = e.keyCode || e.which || e.charCode;
2089
- if (!U.filter.call(this, e)) return;
2089
+ if (!Y.filter.call(this, e)) return;
2090
2090
  if ((o === 93 || o === 224) && (o = 91), O.indexOf(o) === -1 && o !== 229 && O.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((a) => {
2091
2091
  const d = Ot[a];
2092
2092
  e[a] && O.indexOf(d) === -1 ? O.push(d) : !e[a] && O.indexOf(d) > -1 ? O.splice(O.indexOf(d), 1) : a === "metaKey" && e[a] && O.length === 3 && (e.ctrlKey || e.shiftKey || e.altKey || (O = O.slice(O.indexOf(d))));
2093
2093
  }), o in y) {
2094
2094
  y[o] = !0;
2095
- for (const a in $)
2096
- $[a] === o && (U[a] = !0);
2095
+ for (const a in j)
2096
+ j[a] === o && (Y[a] = !0);
2097
2097
  if (!n) return;
2098
2098
  }
2099
2099
  for (const a in y)
@@ -2103,24 +2103,24 @@ function te(e, t) {
2103
2103
  if (n)
2104
2104
  for (let a = 0; a < n.length; a++)
2105
2105
  n[a].scope === i && (e.type === "keydown" && n[a].keydown || e.type === "keyup" && n[a].keyup) && Kt(e, n[a], i, t);
2106
- if (!(o in N)) return;
2107
- const r = N[o], s = r.length;
2106
+ if (!(o in I)) return;
2107
+ const r = I[o], s = r.length;
2108
2108
  for (let a = 0; a < s; a++)
2109
2109
  if ((e.type === "keydown" && r[a].keydown || e.type === "keyup" && r[a].keyup) && r[a].key) {
2110
2110
  const d = r[a], {
2111
2111
  splitKey: f
2112
- } = d, g = d.key.split(f), l = [];
2113
- for (let m = 0; m < g.length; m++)
2114
- l.push(lt(g[m]));
2112
+ } = d, h = d.key.split(f), l = [];
2113
+ for (let g = 0; g < h.length; g++)
2114
+ l.push(lt(h[g]));
2115
2115
  l.sort().join("") === O.sort().join("") && Kt(e, d, i, t);
2116
2116
  }
2117
2117
  }
2118
- function U(e, t, n) {
2118
+ function Y(e, t, n) {
2119
2119
  O = [];
2120
2120
  const o = pe(e);
2121
- let i = [], r = "all", s = document, a = 0, d = !1, f = !0, g = "+", l = !1, m = !1;
2122
- for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (d = t.keyup), t.keydown !== void 0 && (f = t.keydown), t.capture !== void 0 && (l = t.capture), typeof t.splitKey == "string" && (g = t.splitKey), t.single === !0 && (m = !0)), typeof t == "string" && (r = t), m && me(e, r); a < o.length; a++)
2123
- e = o[a].split(g), i = [], e.length > 1 && (i = fe($, e)), e = e[e.length - 1], e = e === "*" ? "*" : lt(e), e in N || (N[e] = []), N[e].push({
2121
+ let i = [], r = "all", s = document, a = 0, d = !1, f = !0, h = "+", l = !1, g = !1;
2122
+ for (n === void 0 && typeof t == "function" && (n = t), Object.prototype.toString.call(t) === "[object Object]" && (t.scope && (r = t.scope), t.element && (s = t.element), t.keyup && (d = t.keyup), t.keydown !== void 0 && (f = t.keydown), t.capture !== void 0 && (l = t.capture), typeof t.splitKey == "string" && (h = t.splitKey), t.single === !0 && (g = !0)), typeof t == "string" && (r = t), g && me(e, r); a < o.length; a++)
2123
+ e = o[a].split(h), i = [], e.length > 1 && (i = fe(j, e)), e = e[e.length - 1], e = e === "*" ? "*" : lt(e), e in I || (I[e] = []), I[e].push({
2124
2124
  keyup: d,
2125
2125
  keydown: f,
2126
2126
  scope: r,
@@ -2128,23 +2128,23 @@ function U(e, t, n) {
2128
2128
  shortcut: o[a],
2129
2129
  method: n,
2130
2130
  key: o[a],
2131
- splitKey: g,
2131
+ splitKey: h,
2132
2132
  element: s
2133
2133
  });
2134
2134
  if (typeof s < "u" && window) {
2135
2135
  if (!W.has(s)) {
2136
2136
  const c = function() {
2137
- let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2138
- return te(v, s);
2139
- }, S = function() {
2140
- let v = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2141
- te(v, s), wo(v);
2137
+ let C = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2138
+ return te(C, s);
2139
+ }, A = function() {
2140
+ let C = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2141
+ te(C, s), bo(C);
2142
2142
  };
2143
2143
  W.set(s, {
2144
2144
  keydownListener: c,
2145
- keyupListenr: S,
2145
+ keyupListenr: A,
2146
2146
  capture: l
2147
- }), Bt(s, "keydown", c, l), Bt(s, "keyup", S, l);
2147
+ }), Bt(s, "keydown", c, l), Bt(s, "keyup", A, l);
2148
2148
  }
2149
2149
  if (!rt) {
2150
2150
  const c = () => {
@@ -2157,16 +2157,16 @@ function U(e, t, n) {
2157
2157
  }
2158
2158
  }
2159
2159
  }
2160
- function Ao(e) {
2160
+ function wo(e) {
2161
2161
  let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
2162
- Object.keys(N).forEach((n) => {
2163
- N[n].filter((i) => i.scope === t && i.shortcut === e).forEach((i) => {
2162
+ Object.keys(I).forEach((n) => {
2163
+ I[n].filter((i) => i.scope === t && i.shortcut === e).forEach((i) => {
2164
2164
  i && i.method && i.method();
2165
2165
  });
2166
2166
  });
2167
2167
  }
2168
2168
  function Pt(e) {
2169
- const t = Object.values(N).flat();
2169
+ const t = Object.values(I).flat();
2170
2170
  if (t.findIndex((o) => {
2171
2171
  let {
2172
2172
  element: i
@@ -2187,7 +2187,7 @@ function Pt(e) {
2187
2187
  capture: a
2188
2188
  } = W.get(i) || {};
2189
2189
  r && s && (et(i, "keyup", s, a), et(i, "keydown", r, a), W.delete(i));
2190
- }), W.clear(), Object.keys(N).forEach((i) => delete N[i]), rt)) {
2190
+ }), W.clear(), Object.keys(I).forEach((i) => delete I[i]), rt)) {
2191
2191
  const {
2192
2192
  listener: i,
2193
2193
  capture: r
@@ -2196,159 +2196,163 @@ function Pt(e) {
2196
2196
  }
2197
2197
  }
2198
2198
  const Rt = {
2199
- getPressedKeyString: po,
2199
+ getPressedKeyString: fo,
2200
2200
  setScope: ge,
2201
2201
  getScope: st,
2202
- deleteScope: bo,
2203
- getPressedKeyCodes: fo,
2204
- getAllKeyCodes: ho,
2205
- isPressed: mo,
2206
- filter: go,
2207
- trigger: Ao,
2202
+ deleteScope: mo,
2203
+ getPressedKeyCodes: uo,
2204
+ getAllKeyCodes: po,
2205
+ isPressed: go,
2206
+ filter: ho,
2207
+ trigger: wo,
2208
2208
  unbind: me,
2209
2209
  keyMap: at,
2210
- modifier: $,
2210
+ modifier: j,
2211
2211
  modifierMap: Ot
2212
2212
  };
2213
2213
  for (const e in Rt)
2214
- Object.prototype.hasOwnProperty.call(Rt, e) && (U[e] = Rt[e]);
2214
+ Object.prototype.hasOwnProperty.call(Rt, e) && (Y[e] = Rt[e]);
2215
2215
  if (typeof window < "u") {
2216
2216
  const e = window.hotkeys;
2217
- U.noConflict = (t) => (t && window.hotkeys === U && (window.hotkeys = e), U), window.hotkeys = U;
2217
+ Y.noConflict = (t) => (t && window.hotkeys === Y && (window.hotkeys = e), Y), window.hotkeys = Y;
2218
2218
  }
2219
- var be = {};
2219
+ var Ao = {};
2220
2220
  (function(e) {
2221
2221
  Object.defineProperty(e, "__esModule", { value: !0 }), function(t) {
2222
2222
  t.Unidentified = "Unidentified", t.Alt = "Alt", t.AltGraph = "AltGraph", t.CapsLock = "CapsLock", t.Control = "Control", t.Fn = "Fn", t.FnLock = "FnLock", t.Hyper = "Hyper", t.Meta = "Meta", t.NumLock = "NumLock", t.ScrollLock = "ScrollLock", t.Shift = "Shift", t.Super = "Super", t.Symbol = "Symbol", t.SymbolLock = "SymbolLock", t.Enter = "Enter", t.Tab = "Tab", t.ArrowDown = "ArrowDown", t.ArrowLeft = "ArrowLeft", t.ArrowRight = "ArrowRight", t.ArrowUp = "ArrowUp", t.End = "End", t.Home = "Home", t.PageDown = "PageDown", t.PageUp = "PageUp", t.Backspace = "Backspace", t.Clear = "Clear", t.Copy = "Copy", t.CrSel = "CrSel", t.Cut = "Cut", t.Delete = "Delete", t.EraseEof = "EraseEof", t.ExSel = "ExSel", t.Insert = "Insert", t.Paste = "Paste", t.Redo = "Redo", t.Undo = "Undo", t.Accept = "Accept", t.Again = "Again", t.Attn = "Attn", t.Cancel = "Cancel", t.ContextMenu = "ContextMenu", t.Escape = "Escape", t.Execute = "Execute", t.Find = "Find", t.Finish = "Finish", t.Help = "Help", t.Pause = "Pause", t.Play = "Play", t.Props = "Props", t.Select = "Select", t.ZoomIn = "ZoomIn", t.ZoomOut = "ZoomOut", t.BrightnessDown = "BrightnessDown", t.BrightnessUp = "BrightnessUp", t.Eject = "Eject", t.LogOff = "LogOff", t.Power = "Power", t.PowerOff = "PowerOff", t.PrintScreen = "PrintScreen", t.Hibernate = "Hibernate", t.Standby = "Standby", t.WakeUp = "WakeUp", t.AllCandidates = "AllCandidates", t.Alphanumeric = "Alphanumeric", t.CodeInput = "CodeInput", t.Compose = "Compose", t.Convert = "Convert", t.Dead = "Dead", t.FinalMode = "FinalMode", t.GroupFirst = "GroupFirst", t.GroupLast = "GroupLast", t.GroupNext = "GroupNext", t.GroupPrevious = "GroupPrevious", t.ModeChange = "ModeChange", t.NextCandidate = "NextCandidate", t.NonConvert = "NonConvert", t.PreviousCandidate = "PreviousCandidate", t.Process = "Process", t.SingleCandidate = "SingleCandidate", t.HangulMode = "HangulMode", t.HanjaMode = "HanjaMode", t.JunjaMode = "JunjaMode", t.Eisu = "Eisu", t.Hankaku = "Hankaku", t.Hiragana = "Hiragana", t.HiraganaKatakana = "HiraganaKatakana", t.KanaMode = "KanaMode", t.KanjiMode = "KanjiMode", t.Katakana = "Katakana", t.Romaji = "Romaji", t.Zenkaku = "Zenkaku", t.ZenkakuHanaku = "ZenkakuHanaku", t.F1 = "F1", t.F2 = "F2", t.F3 = "F3", t.F4 = "F4", t.F5 = "F5", t.F6 = "F6", t.F7 = "F7", t.F8 = "F8", t.F9 = "F9", t.F10 = "F10", t.F11 = "F11", t.F12 = "F12", t.F13 = "F13", t.F14 = "F14", t.F15 = "F15", t.F16 = "F16", t.F17 = "F17", t.F18 = "F18", t.F19 = "F19", t.F20 = "F20", t.Soft1 = "Soft1", t.Soft2 = "Soft2", t.Soft3 = "Soft3", t.Soft4 = "Soft4", t.AppSwitch = "AppSwitch", t.Call = "Call", t.Camera = "Camera", t.CameraFocus = "CameraFocus", t.EndCall = "EndCall", t.GoBack = "GoBack", t.GoHome = "GoHome", t.HeadsetHook = "HeadsetHook", t.LastNumberRedial = "LastNumberRedial", t.Notification = "Notification", t.MannerMode = "MannerMode", t.VoiceDial = "VoiceDial", t.ChannelDown = "ChannelDown", t.ChannelUp = "ChannelUp", t.MediaFastForward = "MediaFastForward", t.MediaPause = "MediaPause", t.MediaPlay = "MediaPlay", t.MediaPlayPause = "MediaPlayPause", t.MediaRecord = "MediaRecord", t.MediaRewind = "MediaRewind", t.MediaStop = "MediaStop", t.MediaTrackNext = "MediaTrackNext", t.MediaTrackPrevious = "MediaTrackPrevious", t.AudioBalanceLeft = "AudioBalanceLeft", t.AudioBalanceRight = "AudioBalanceRight", t.AudioBassDown = "AudioBassDown", t.AudioBassBoostDown = "AudioBassBoostDown", t.AudioBassBoostToggle = "AudioBassBoostToggle", t.AudioBassBoostUp = "AudioBassBoostUp", t.AudioBassUp = "AudioBassUp", t.AudioFaderFront = "AudioFaderFront", t.AudioFaderRear = "AudioFaderRear", t.AudioSurroundModeNext = "AudioSurroundModeNext", t.AudioTrebleDown = "AudioTrebleDown", t.AudioTrebleUp = "AudioTrebleUp", t.AudioVolumeDown = "AudioVolumeDown", t.AudioVolumeMute = "AudioVolumeMute", t.AudioVolumeUp = "AudioVolumeUp", t.MicrophoneToggle = "MicrophoneToggle", t.MicrophoneVolumeDown = "MicrophoneVolumeDown", t.MicrophoneVolumeMute = "MicrophoneVolumeMute", t.MicrophoneVolumeUp = "MicrophoneVolumeUp", t.TV = "TV", t.TV3DMode = "TV3DMode", t.TVAntennaCable = "TVAntennaCable", t.TVAudioDescription = "TVAudioDescription", t.TVAudioDescriptionMixDown = "TVAudioDescriptionMixDown", t.TVAudioDescriptionMixUp = "TVAudioDescriptionMixUp", t.TVContentsMenu = "TVContentsMenu", t.TVDataService = "TVDataService", t.TVInput = "TVInput", t.TVInputComponent1 = "TVInputComponent1", t.TVInputComponent2 = "TVInputComponent2", t.TVInputComposite1 = "TVInputComposite1", t.TVInputComposite2 = "TVInputComposite2", t.TVInputHDMI1 = "TVInputHDMI1", t.TVInputHDMI2 = "TVInputHDMI2", t.TVInputHDMI3 = "TVInputHDMI3", t.TVInputHDMI4 = "TVInputHDMI4", t.TVInputVGA1 = "TVInputVGA1", t.TVMediaContext = "TVMediaContext", t.TVNetwork = "TVNetwork", t.TVNumberEntry = "TVNumberEntry", t.TVPower = "TVPower", t.TVRadioService = "TVRadioService", t.TVSatellite = "TVSatellite", t.TVSatelliteBS = "TVSatelliteBS", t.TVSatelliteCS = "TVSatelliteCS", t.TVSatelliteToggle = "TVSatelliteToggle", t.TVTerrestrialAnalog = "TVTerrestrialAnalog", t.TVTerrestrialDigital = "TVTerrestrialDigital", t.TVTimer = "TVTimer", t.AVRInput = "AVRInput", t.AVRPower = "AVRPower", t.ColorF0Red = "ColorF0Red", t.ColorF1Green = "ColorF1Green", t.ColorF2Yellow = "ColorF2Yellow", t.ColorF3Blue = "ColorF3Blue", t.ColorF4Grey = "ColorF4Grey", t.ColorF5Brown = "ColorF5Brown", t.ClosedCaptionToggle = "ClosedCaptionToggle", t.Dimmer = "Dimmer", t.DisplaySwap = "DisplaySwap", t.DVR = "DVR", t.Exit = "Exit", t.FavoriteClear0 = "FavoriteClear0", t.FavoriteClear1 = "FavoriteClear1", t.FavoriteClear2 = "FavoriteClear2", t.FavoriteClear3 = "FavoriteClear3", t.FavoriteRecall0 = "FavoriteRecall0", t.FavoriteRecall1 = "FavoriteRecall1", t.FavoriteRecall2 = "FavoriteRecall2", t.FavoriteRecall3 = "FavoriteRecall3", t.FavoriteStore0 = "FavoriteStore0", t.FavoriteStore1 = "FavoriteStore1", t.FavoriteStore2 = "FavoriteStore2", t.FavoriteStore3 = "FavoriteStore3", t.Guide = "Guide", t.GuideNextDay = "GuideNextDay", t.GuidePreviousDay = "GuidePreviousDay", t.Info = "Info", t.InstantReplay = "InstantReplay", t.Link = "Link", t.ListProgram = "ListProgram", t.LiveContent = "LiveContent", t.Lock = "Lock", t.MediaApps = "MediaApps", t.MediaAudioTrack = "MediaAudioTrack", t.MediaLast = "MediaLast", t.MediaSkipBackward = "MediaSkipBackward", t.MediaSkipForward = "MediaSkipForward", t.MediaStepBackward = "MediaStepBackward", t.MediaStepForward = "MediaStepForward", t.MediaTopMenu = "MediaTopMenu", t.NavigateIn = "NavigateIn", t.NavigateNext = "NavigateNext", t.NavigateOut = "NavigateOut", t.NavigatePrevious = "NavigatePrevious", t.NextFavoriteChannel = "NextFavoriteChannel", t.NextUserProfile = "NextUserProfile", t.OnDemand = "OnDemand", t.Pairing = "Pairing", t.PinPDown = "PinPDown", t.PinPMove = "PinPMove", t.PinPToggle = "PinPToggle", t.PinPUp = "PinPUp", t.PlaySpeedDown = "PlaySpeedDown", t.PlaySpeedReset = "PlaySpeedReset", t.PlaySpeedUp = "PlaySpeedUp", t.RandomToggle = "RandomToggle", t.RcLowBattery = "RcLowBattery", t.RecordSpeedNext = "RecordSpeedNext", t.RfBypass = "RfBypass", t.ScanChannelsToggle = "ScanChannelsToggle", t.ScreenModeNext = "ScreenModeNext", t.Settings = "Settings", t.SplitScreenToggle = "SplitScreenToggle", t.STBInput = "STBInput", t.STBPower = "STBPower", t.Subtitle = "Subtitle", t.Teletext = "Teletext", t.VideoModeNext = "VideoModeNext", t.Wink = "Wink", t.ZoomToggle = "ZoomToggle", t.SpeechCorrectionList = "SpeechCorrectionList", t.SpeechInputToggle = "SpeechInputToggle", t.Close = "Close", t.New = "New", t.Open = "Open", t.Print = "Print", t.Save = "Save", t.SpellCheck = "SpellCheck", t.MailForward = "MailForward", t.MailReply = "MailReply", t.MailSend = "MailSend", t.LaunchCalculator = "LaunchCalculator", t.LaunchCalendar = "LaunchCalendar", t.LaunchContacts = "LaunchContacts", t.LaunchMail = "LaunchMail", t.LaunchMediaPlayer = "LaunchMediaPlayer", t.LaunchMusicPlayer = "LaunchMusicPlayer", t.LaunchMyComputer = "LaunchMyComputer", t.LaunchPhone = "LaunchPhone", t.LaunchScreenSaver = "LaunchScreenSaver", t.LaunchSpreadsheet = "LaunchSpreadsheet", t.LaunchWebBrowser = "LaunchWebBrowser", t.LaunchWebCam = "LaunchWebCam", t.LaunchWordProcessor = "LaunchWordProcessor", t.LaunchApplication1 = "LaunchApplication1", t.LaunchApplication2 = "LaunchApplication2", t.LaunchApplication3 = "LaunchApplication3", t.LaunchApplication4 = "LaunchApplication4", t.LaunchApplication5 = "LaunchApplication5", t.LaunchApplication6 = "LaunchApplication6", t.LaunchApplication7 = "LaunchApplication7", t.LaunchApplication8 = "LaunchApplication8", t.LaunchApplication9 = "LaunchApplication9", t.LaunchApplication10 = "LaunchApplication10", t.LaunchApplication11 = "LaunchApplication11", t.LaunchApplication12 = "LaunchApplication12", t.LaunchApplication13 = "LaunchApplication13", t.LaunchApplication14 = "LaunchApplication14", t.LaunchApplication15 = "LaunchApplication15", t.LaunchApplication16 = "LaunchApplication16", t.BrowserBack = "BrowserBack", t.BrowserFavorites = "BrowserFavorites", t.BrowserForward = "BrowserForward", t.BrowserHome = "BrowserHome", t.BrowserRefresh = "BrowserRefresh", t.BrowserSearch = "BrowserSearch", t.BrowserStop = "BrowserStop", t.Decimal = "Decimal", t.Key11 = "Key11", t.Key12 = "Key12", t.Multiply = "Multiply", t.Add = "Add", t.Divide = "Divide", t.Subtract = "Subtract", t.Separator = "Separator";
2223
2223
  }(e.Key || (e.Key = {}));
2224
- })(be);
2225
- const So = (e, t, n) => {
2224
+ })(Ao);
2225
+ const vo = (e, t, n) => {
2226
2226
  let o;
2227
- const i = (h) => o = h;
2227
+ const i = (v) => o = v;
2228
2228
  let r;
2229
- const s = (h) => r = h;
2229
+ const s = (v) => r = v;
2230
2230
  let a = !0;
2231
- const d = (h) => a = h, { store: f, selection: g } = t;
2232
- let l, m, c;
2233
- const S = (h) => {
2234
- var B;
2235
- if (!a || m === !1)
2231
+ const d = (v) => a = v, { store: f, selection: h } = t;
2232
+ let l, g, c;
2233
+ const A = (v) => {
2234
+ var k;
2235
+ if (!a || g === !1)
2236
2236
  return;
2237
- l = !((B = h.target.parentElement) != null && B.closest(X)) ? {
2237
+ l = !((k = v.target.parentElement) != null && k.closest($)) ? {
2238
2238
  annotation: se(),
2239
2239
  selector: [],
2240
2240
  creator: o,
2241
2241
  created: /* @__PURE__ */ new Date()
2242
2242
  } : void 0;
2243
2243
  };
2244
- e.addEventListener("selectstart", S);
2245
- const v = Nt((h) => {
2246
- var x, L;
2244
+ e.addEventListener("selectstart", A);
2245
+ const C = Nt((v) => {
2246
+ var L, R;
2247
2247
  if (!a) return;
2248
- const E = document.getSelection();
2249
- if (!!((L = (x = E.anchorNode) == null ? void 0 : x.parentElement) != null && L.closest(X))) {
2248
+ const M = document.getSelection();
2249
+ if (!!((R = (L = M.anchorNode) == null ? void 0 : L.parentElement) != null && R.closest($))) {
2250
2250
  l = void 0;
2251
2251
  return;
2252
2252
  }
2253
- if (h.timeStamp - ((c == null ? void 0 : c.timeStamp) || h.timeStamp) < 1e3 && !l && S(c || h), E.isCollapsed || !l || m === !1)
2253
+ if (v.timeStamp - ((c == null ? void 0 : c.timeStamp) || v.timeStamp) < 1e3 && !l && A(c || v), !l)
2254
2254
  return;
2255
- const T = E.getRangeAt(0), M = Pe(T, e);
2256
- if (Ve(M)) return;
2257
- const b = Ee(M.cloneRange());
2258
- (b.length !== l.selector.length || b.some((R, I) => {
2259
- var _;
2260
- return R.toString() !== ((_ = l.selector[I]) == null ? void 0 : _.quote);
2255
+ if (M.isCollapsed && f.getAnnotation(l.annotation)) {
2256
+ h.clear(), f.deleteAnnotation(l.annotation);
2257
+ return;
2258
+ }
2259
+ const B = M.getRangeAt(0), m = Fe(B, e);
2260
+ if (ke(m)) return;
2261
+ const S = xe(m.cloneRange());
2262
+ (S.length !== l.selector.length || S.some((N, X) => {
2263
+ var U;
2264
+ return N.toString() !== ((U = l.selector[X]) == null ? void 0 : U.quote);
2261
2265
  })) && (l = {
2262
2266
  ...l,
2263
- selector: b.map((R) => Fe(R, e, n)),
2267
+ selector: S.map((N) => Ie(N, e, n)),
2264
2268
  updated: /* @__PURE__ */ new Date()
2265
- }, f.getAnnotation(l.annotation) ? f.updateTarget(l, V.LOCAL) : (g.clear(), f.addAnnotation({
2269
+ }, f.getAnnotation(l.annotation) ? f.updateTarget(l, V.LOCAL) : (h.clear(), f.addAnnotation({
2266
2270
  id: l.annotation,
2267
2271
  bodies: [],
2268
2272
  target: l
2269
- }, V.LOCAL), g.userSelect(l.annotation, c)));
2273
+ }, V.LOCAL), h.userSelect(l.annotation, c)));
2270
2274
  });
2271
- document.addEventListener("selectionchange", v);
2272
- const w = (h) => {
2273
- c = ye(h), m = c.button === 0;
2275
+ document.addEventListener("selectionchange", C);
2276
+ const b = (v) => {
2277
+ c = De(v), g = c.button === 0;
2274
2278
  };
2275
- document.addEventListener("pointerdown", w);
2276
- const p = (h) => {
2277
- var T;
2278
- if (!!((T = h.target.parentElement) != null && T.closest(X)) || !m)
2279
+ document.addEventListener("pointerdown", b);
2280
+ const p = (v) => {
2281
+ var B;
2282
+ if (!!((B = v.target.parentElement) != null && B.closest($)) || !g)
2279
2283
  return;
2280
- const B = () => {
2281
- const { x: M, y: b } = e.getBoundingClientRect(), C = h.target instanceof Node && e.contains(h.target) && f.getAt(h.clientX - M, h.clientY - b, r);
2282
- if (C) {
2283
- const { selected: x } = g;
2284
- (x.length !== 1 || x[0].id !== C.id) && g.userSelect(C.id, h);
2285
- } else g.isEmpty() || g.clear();
2286
- }, k = h.timeStamp - c.timeStamp;
2284
+ const k = () => {
2285
+ const { x: m, y: S } = e.getBoundingClientRect(), E = v.target instanceof Node && e.contains(v.target) && f.getAt(v.clientX - m, v.clientY - S, r);
2286
+ if (E) {
2287
+ const { selected: L } = h;
2288
+ (L.length !== 1 || L[0].id !== E.id) && h.userSelect(E.id, v);
2289
+ } else h.isEmpty() || h.clear();
2290
+ }, T = v.timeStamp - c.timeStamp;
2287
2291
  setTimeout(() => {
2288
- const { isCollapsed: M } = document.getSelection();
2289
- M && k < 300 ? (l = void 0, B()) : l && g.userSelect(l.annotation, h);
2292
+ const { isCollapsed: m } = document.getSelection();
2293
+ m && T < 300 ? (l = void 0, k()) : l && h.userSelect(l.annotation, v);
2290
2294
  });
2291
2295
  };
2292
- document.addEventListener("pointerup", p), U("*", { element: e, keyup: !1, keydown: !0 }, (h, E) => {
2293
- h.repeat || (c = Ue(h));
2294
- }), U("*", { keyup: !0, keydown: !1 }, (h) => {
2295
- U.shift && h.key === be.Key.Shift && !h.repeat && l && g.userSelect(l.annotation, h);
2296
- });
2297
- let u = !1;
2298
- return U("ctrl+a, ⌘+a", { keyup: !1, keydown: !0 }, () => {
2299
- u = !0;
2300
- }), U("*", { keyup: !0, keydown: !1 }, (h) => {
2301
- u && !h.repeat && l && g.userSelect(l.annotation, h), u = !1;
2296
+ document.addEventListener("pointerup", p);
2297
+ const u = ["up", "down", "left", "right"], w = [
2298
+ ...u.map((v) => `shift+${v}`),
2299
+ "ctrl+a",
2300
+ "⌘+a"
2301
+ ];
2302
+ return Y(w.join(","), { element: e, keydown: !0, keyup: !1 }, (v) => {
2303
+ v.repeat || (c = ye(v));
2304
+ }), Y(u.join(","), { element: e, keydown: !0 }, (v) => {
2305
+ v.repeat || (l = void 0, h.clear());
2302
2306
  }), {
2303
2307
  destroy: () => {
2304
- e.removeEventListener("selectstart", S), document.removeEventListener("selectionchange", v), document.removeEventListener("pointerdown", w), document.removeEventListener("pointerup", p), U.unbind();
2308
+ e.removeEventListener("selectstart", A), document.removeEventListener("selectionchange", C), document.removeEventListener("pointerdown", b), document.removeEventListener("pointerup", p), Y.unbind();
2305
2309
  },
2306
2310
  setFilter: s,
2307
2311
  setUser: i,
2308
2312
  setAnnotatingEnabled: d
2309
2313
  };
2310
2314
  }, ee = "SPANS", Mo = (e, t = {}) => {
2311
- Le(e), Te(e);
2312
- const n = so(t, {
2315
+ Ee(e), Le(e);
2316
+ const n = ao(t, {
2313
2317
  annotatingEnabled: !0,
2314
- user: Un()
2315
- }), o = oo(e, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = Rn(s), d = Vn(o, a, n.adapter);
2318
+ user: yn()
2319
+ }), o = no(e, n.userSelectAction), { selection: i, viewport: r } = o, s = o.store, a = Bn(s), d = kn(o, a, n.adapter);
2316
2320
  let f = n.user;
2317
- const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee, l = g === "SPANS" ? rn(e, o, r) : g === "CSS_HIGHLIGHTS" ? en(e, o, r) : g === "CANVAS" ? je(e, o, r) : void 0;
2321
+ const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : ee : n.renderer || ee, l = h === "SPANS" ? on(e, o, r) : h === "CSS_HIGHLIGHTS" ? tn(e, o, r) : h === "CANVAS" ? $e(e, o, r) : void 0;
2318
2322
  if (!l)
2319
- throw `Unknown renderer implementation: ${g}`;
2320
- console.debug(`Using ${g} renderer`), n.style && l.setStyle(n.style);
2321
- const m = So(e, o, n.offsetReferenceSelector);
2322
- m.setUser(f), m.setAnnotatingEnabled(n.annotatingEnabled);
2323
- const c = Nn(o, a, n.adapter), S = () => f, v = (E) => {
2324
- m.setAnnotatingEnabled(E);
2325
- }, w = (E) => {
2326
- l.setFilter(E), m.setFilter(E);
2327
- }, p = (E) => {
2328
- f = E, m.setUser(E);
2329
- }, u = (E) => {
2330
- E && (l.setPainter(ro(e, E, n.presence)), E.on("selectionChange", () => l.redraw()));
2331
- }, A = (E) => {
2332
- E ? i.setSelected(E) : i.clear();
2323
+ throw `Unknown renderer implementation: ${h}`;
2324
+ console.debug(`Using ${h} renderer`), n.style && l.setStyle(n.style);
2325
+ const g = vo(e, o, n.offsetReferenceSelector);
2326
+ g.setUser(f), g.setAnnotatingEnabled(n.annotatingEnabled);
2327
+ const c = On(o, a, n.adapter), A = () => f, C = (v) => {
2328
+ g.setAnnotatingEnabled(v);
2329
+ }, b = (v) => {
2330
+ l.setFilter(v), g.setFilter(v);
2331
+ }, p = (v) => {
2332
+ f = v, g.setUser(v);
2333
+ }, u = (v) => {
2334
+ v && (l.setPainter(io(e, v, n.presence)), v.on("selectionChange", () => l.redraw()));
2335
+ }, w = (v) => {
2336
+ v ? i.setSelected(v) : i.clear();
2333
2337
  };
2334
2338
  return {
2335
2339
  ...c,
2336
2340
  destroy: () => {
2337
- l.destroy(), m.destroy(), a.destroy();
2341
+ l.destroy(), g.destroy(), a.destroy();
2338
2342
  },
2339
2343
  element: e,
2340
- getUser: S,
2341
- setAnnotatingEnabled: v,
2342
- setFilter: w,
2344
+ getUser: A,
2345
+ setAnnotatingEnabled: C,
2346
+ setFilter: b,
2343
2347
  setStyle: l.setStyle.bind(l),
2344
2348
  redraw: l.redraw.bind(l),
2345
2349
  setUser: p,
2346
- setSelected: A,
2350
+ setSelected: w,
2347
2351
  setPresenceProvider: u,
2348
2352
  setVisible: l.setVisible.bind(l),
2349
2353
  on: d.on,
2350
2354
  off: d.off,
2351
- scrollIntoView: ao(e, s),
2355
+ scrollIntoView: ro(e, s),
2352
2356
  state: o
2353
2357
  };
2354
2358
  };
@@ -2356,42 +2360,42 @@ export {
2356
2360
  gt as DEFAULT_SELECTED_STYLE,
2357
2361
  q as DEFAULT_STYLE,
2358
2362
  ne as NOT_ANNOTATABLE_CLASS,
2359
- X as NOT_ANNOTATABLE_SELECTOR,
2363
+ $ as NOT_ANNOTATABLE_SELECTOR,
2360
2364
  V as Origin,
2361
- fn as UserSelectAction,
2365
+ un as UserSelectAction,
2362
2366
  To as W3CTextFormat,
2363
- Le as cancelSingleClickEvents,
2364
- Ue as cloneKeyboardEvent,
2365
- ye as clonePointerEvent,
2367
+ Ee as cancelSingleClickEvents,
2368
+ ye as cloneKeyboardEvent,
2369
+ De as clonePointerEvent,
2366
2370
  Lo as createBody,
2367
- je as createCanvasRenderer,
2368
- en as createHighlightsRenderer,
2369
- tn as createRenderer,
2370
- rn as createSpansRenderer,
2371
+ $e as createCanvasRenderer,
2372
+ tn as createHighlightsRenderer,
2373
+ Ke as createRenderer,
2374
+ on as createSpansRenderer,
2371
2375
  Mo as createTextAnnotator,
2372
- oo as createTextAnnotatorState,
2376
+ no as createTextAnnotatorState,
2373
2377
  Nt as debounce,
2374
2378
  Eo as denormalizeRectWithOffset,
2375
- so as fillDefaults,
2376
- vo as getAnnotatableFragment,
2379
+ ao as fillDefaults,
2380
+ So as getAnnotatableFragment,
2377
2381
  Co as getClientRectsPonyfill,
2378
- Re as getQuoteContext,
2382
+ Be as getQuoteContext,
2379
2383
  kt as getRangeAnnotatableContents,
2380
2384
  z as isRevived,
2381
- Ve as isWhitespaceOrEmpty,
2382
- Ie as mergeClientRects,
2383
- De as normalizeRectWithOffset,
2385
+ ke as isWhitespaceOrEmpty,
2386
+ Ne as mergeClientRects,
2387
+ Pe as normalizeRectWithOffset,
2384
2388
  ve as paint,
2385
- jn as parseW3CTextAnnotation,
2386
- Te as programmaticallyFocusable,
2387
- Fe as rangeToSelector,
2389
+ $n as parseW3CTextAnnotation,
2390
+ Le as programmaticallyFocusable,
2391
+ Ie as rangeToSelector,
2388
2392
  bt as reviveAnnotation,
2389
2393
  oe as reviveSelector,
2390
2394
  mt as reviveTarget,
2391
- Gn as serializeW3CTextAnnotation,
2392
- Ee as splitAnnotatableRanges,
2395
+ jn as serializeW3CTextAnnotation,
2396
+ xe as splitAnnotatableRanges,
2393
2397
  xo as toDomRectList,
2394
- Pe as trimRangeToContainer,
2395
- ke as whitespaceOrEmptyRegex
2398
+ Fe as trimRangeToContainer,
2399
+ Re as whitespaceOrEmptyRegex
2396
2400
  };
2397
2401
  //# sourceMappingURL=text-annotator.es.js.map