@recogito/text-annotator 3.0.0-rc.53 → 3.0.0-rc.54

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.
@@ -7,7 +7,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
7
7
  }, Le = (t) => t.addEventListener("click", (e) => {
8
8
  // Allow clicks within not-annotatable elements
9
9
  !e.target.closest(tt) && !e.target.closest("a") && e.preventDefault();
10
- }), At = (t) => ({
10
+ }), xt = (t) => ({
11
11
  ...t,
12
12
  type: t.type,
13
13
  x: t.x,
@@ -56,7 +56,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
56
56
  return (...o) => {
57
57
  clearTimeout(n), n = setTimeout(() => t.apply(void 0, o), e);
58
58
  };
59
- }, Me = function* (t) {
59
+ }, Be = function* (t) {
60
60
  const e = document.createNodeIterator(
61
61
  t.commonAncestorContainer,
62
62
  NodeFilter.SHOW_ELEMENT,
@@ -65,11 +65,11 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
65
65
  let n;
66
66
  for (; n = e.nextNode(); )
67
67
  n instanceof HTMLElement && (yield n);
68
- }, Be = (t) => {
68
+ }, Me = (t) => {
69
69
  if (!Ce(t)) return [];
70
70
  const e = [];
71
71
  let n = null;
72
- for (const o of Me(t)) {
72
+ for (const o of Be(t)) {
73
73
  let i;
74
74
  n ? (i = document.createRange(), i.setStartAfter(n), i.setEndBefore(o)) : (i = t.cloneRange(), i.setEndBefore(o)), i.collapsed || e.push(i), n = o;
75
75
  }
@@ -78,18 +78,18 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
78
78
  o.setStartAfter(n), o.collapsed || e.push(o);
79
79
  }
80
80
  return e.length > 0 ? e : [t];
81
- }, Nt = (t) => {
81
+ }, Ut = (t) => {
82
82
  const e = t.cloneContents();
83
83
  return e.querySelectorAll(tt).forEach((n) => n.remove()), e;
84
84
  }, Re = (t, e, n = 10, o) => {
85
85
  const i = o ? t.startContainer.parentElement.closest(o) : e, s = document.createRange();
86
86
  s.setStart(i, 0), s.setEnd(t.startContainer, t.startOffset);
87
- const a = Nt(s).textContent, r = document.createRange();
87
+ const a = Ut(s).textContent, r = document.createRange();
88
88
  r.setStart(t.endContainer, t.endOffset), i === document.body ? r.setEnd(i, i.childNodes.length) : r.setEndAfter(i);
89
- const l = Nt(r).textContent;
89
+ const d = Ut(r).textContent;
90
90
  return {
91
91
  prefix: a.substring(a.length - n),
92
- suffix: l.substring(0, n)
92
+ suffix: d.substring(0, n)
93
93
  };
94
94
  }, F = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), ke = /^\s*$/, Ie = (t) => ke.test(t.toString()), _e = (t, e) => {
95
95
  const n = (s) => Math.round(s * 10) / 10, o = {
@@ -149,50 +149,50 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
149
149
  }), Ve = (t, e, n) => {
150
150
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
151
151
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
152
- const s = Nt(o).textContent, a = t.toString(), r = s.length || 0, l = r + a.length;
153
- return n ? { quote: a, start: r, end: l, range: t, offsetReference: i } : { quote: a, start: r, end: l, range: t };
152
+ const s = Ut(o).textContent, a = t.toString(), r = s.length || 0, d = r + a.length;
153
+ return n ? { quote: a, start: r, end: d, range: t, offsetReference: i } : { quote: a, start: r, end: d, range: t };
154
154
  }, ae = (t, e) => {
155
155
  var h, u;
156
156
  const { start: n, end: o } = t, i = t.offsetReference || e, s = document.createNodeIterator(
157
157
  e,
158
158
  NodeFilter.SHOW_TEXT,
159
- (p) => {
160
- var g;
161
- return (g = p.parentElement) != null && g.closest(tt) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
159
+ (g) => {
160
+ var v;
161
+ return (v = g.parentElement) != null && v.closest(tt) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
162
162
  }
163
163
  );
164
164
  let a = 0;
165
165
  const r = document.createRange();
166
- let l = s.nextNode();
167
- l === null && console.error("Could not revive annotation target. Content missing.");
166
+ let d = s.nextNode();
167
+ d === null && console.error("Could not revive annotation target. Content missing.");
168
168
  let f = !i;
169
- for (; l !== null; ) {
170
- if (f || (f = i == null ? void 0 : i.contains(l)), f) {
171
- const p = ((h = l.textContent) == null ? void 0 : h.length) || 0;
172
- if (a + p > n) {
173
- r.setStart(l, n - a);
169
+ for (; d !== null; ) {
170
+ if (f || (f = i == null ? void 0 : i.contains(d)), f) {
171
+ const g = ((h = d.textContent) == null ? void 0 : h.length) || 0;
172
+ if (a + g > n) {
173
+ r.setStart(d, n - a);
174
174
  break;
175
175
  }
176
- a += p;
176
+ a += g;
177
177
  }
178
- l = s.nextNode();
178
+ d = s.nextNode();
179
179
  }
180
- for (; l !== null; ) {
181
- const p = ((u = l.textContent) == null ? void 0 : u.length) || 0;
182
- if (a + p >= o) {
183
- r.setEnd(l, o - a);
180
+ for (; d !== null; ) {
181
+ const g = ((u = d.textContent) == null ? void 0 : u.length) || 0;
182
+ if (a + g >= o) {
183
+ r.setEnd(d, o - a);
184
184
  break;
185
185
  }
186
- a += p, l = s.nextNode();
186
+ a += g, d = s.nextNode();
187
187
  }
188
188
  return {
189
189
  ...t,
190
190
  range: r
191
191
  };
192
- }, bt = (t, e) => F(t.selector) ? t : {
192
+ }, wt = (t, e) => F(t.selector) ? t : {
193
193
  ...t,
194
194
  selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ae(n, e))
195
- }, xt = (t, e) => F(t.target.selector) ? t : { ...t, target: bt(t.target, e) }, Ye = (t, e) => {
195
+ }, vt = (t, e) => F(t.target.selector) ? t : { ...t, target: wt(t.target, e) }, Ye = (t, e) => {
196
196
  const n = t.cloneRange();
197
197
  return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
198
198
  }, ce = (t) => {
@@ -200,83 +200,83 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
200
200
  return document.scrollingElement;
201
201
  const { overflowY: e } = window.getComputedStyle(t);
202
202
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : ce(t.parentElement);
203
- }, Ke = (t, e) => (n) => {
203
+ }, De = (t, e) => (n) => {
204
204
  const o = typeof n == "string" ? n : n.id, i = (a) => {
205
- const r = s.getBoundingClientRect(), l = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: p } = e.getAnnotationBounds(o), g = h.top - r.top, y = h.left - r.left, b = s.parentElement ? s.scrollTop : 0, v = s.parentElement ? s.scrollLeft : 0, d = g + b - (l - p) / 2, c = y + v - (f - u) / 2;
206
- s.scroll({ top: d, left: c, behavior: "smooth" });
205
+ const r = s.getBoundingClientRect(), d = s.clientHeight, f = s.clientWidth, h = a.selector[0].range.getBoundingClientRect(), { width: u, height: g } = e.getAnnotationBounds(o), v = h.top - r.top, p = h.left - r.left, y = s.parentElement ? s.scrollTop : 0, x = s.parentElement ? s.scrollLeft : 0, l = v + y - (d - g) / 2, c = p + x - (f - u) / 2;
206
+ s.scroll({ top: l, left: c, behavior: "smooth" });
207
207
  }, s = ce(t);
208
208
  if (s) {
209
209
  const a = e.getAnnotation(o), { range: r } = a.target.selector[0];
210
210
  if (r && !r.collapsed)
211
211
  return i(a.target), !0;
212
212
  {
213
- const l = bt(a.target, t), { range: f } = l.selector[0];
213
+ const d = wt(a.target, t), { range: f } = d.selector[0];
214
214
  if (f && !f.collapsed)
215
- return i(l), !0;
215
+ return i(d), !0;
216
216
  }
217
217
  }
218
218
  return !1;
219
219
  }, W = {
220
220
  fill: "rgb(0, 128, 255)",
221
221
  fillOpacity: 0.18
222
- }, wt = {
222
+ }, At = {
223
223
  fill: "rgb(0, 128, 255)",
224
224
  fillOpacity: 0.45
225
- }, De = (t, e, n, o, i) => {
225
+ }, Ke = (t, e, n, o, i) => {
226
226
  var a, r;
227
- const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? wt : W) : n : (r = t.state) != null && r.selected ? wt : W;
227
+ const s = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? At : W) : n : (r = t.state) != null && r.selected ? At : W;
228
228
  return o && o.paint(t, e) || s;
229
229
  }, Xe = (t) => {
230
- const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n, l = i - e;
231
- return { top: e, left: n, minX: s, minY: a, maxX: r, maxY: l };
230
+ const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, s = -n, a = -e, r = o - n, d = i - e;
231
+ return { top: e, left: n, minX: s, minY: a, maxX: r, maxY: d };
232
232
  }, Pe = (t) => {
233
233
  let e = /* @__PURE__ */ new Set();
234
234
  return (o) => {
235
235
  const i = o.map((s) => s.id);
236
236
  (e.size !== i.length || i.some((s) => !e.has(s))) && t.set(i), e = new Set(i);
237
237
  };
238
- }, Kt = (t, e, n, o) => {
238
+ }, Dt = (t, e, n, o) => {
239
239
  const { store: i, selection: s, hover: a } = e;
240
- let r, l, f;
241
- const h = Pe(n), u = (M) => {
242
- const { x: T, y: m } = t.getBoundingClientRect(), x = i.getAt(M.clientX - T, M.clientY - m, !1, l);
243
- x ? a.current !== x.id && (t.classList.add("hovered"), a.set(x.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
240
+ let r, d, f;
241
+ const h = Pe(n), u = (B) => {
242
+ const { x: T, y: m } = t.getBoundingClientRect(), A = i.getAt(B.clientX - T, B.clientY - m, !1, d);
243
+ A ? a.current !== A.id && (t.classList.add("hovered"), a.set(A.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
244
244
  };
245
245
  t.addEventListener("pointermove", u);
246
- const p = (M = !1) => {
246
+ const g = (B = !1) => {
247
247
  f && f.clear();
248
- const T = Xe(t), { minX: m, minY: x, maxX: A, maxY: L } = T, B = l ? i.getIntersecting(m, x, A, L).filter(({ annotation: U }) => l(U)) : i.getIntersecting(m, x, A, L), R = s.selected.map(({ id: U }) => U), N = B.map(({ annotation: U, rects: et }) => {
248
+ const T = Xe(t), { minX: m, minY: A, maxX: w, maxY: L } = T, M = d ? i.getIntersecting(m, A, w, L).filter(({ annotation: U }) => d(U)) : i.getIntersecting(m, A, w, L), R = s.selected.map(({ id: U }) => U), N = M.map(({ annotation: U, rects: et }) => {
249
249
  const q = R.includes(U.id), Se = U.id === a.current;
250
250
  return { annotation: U, rects: et, state: { selected: q, hover: Se } };
251
251
  });
252
- o.redraw(N, T, r, f, M), setTimeout(() => h(B.map(({ annotation: U }) => U)), 1);
253
- }, g = (M) => {
254
- f = M, p();
255
- }, y = (M) => {
256
- r = M, p();
257
- }, b = (M) => {
258
- l = M, p(!1);
259
- }, v = () => p();
260
- i.observe(v);
261
- const d = s.subscribe(() => p()), c = () => p(!0);
252
+ o.redraw(N, T, r, f, B), setTimeout(() => h(M.map(({ annotation: U }) => U)), 1);
253
+ }, v = (B) => {
254
+ f = B, g();
255
+ }, p = (B) => {
256
+ r = B, g();
257
+ }, y = (B) => {
258
+ d = B, g(!1);
259
+ }, x = () => g();
260
+ i.observe(x);
261
+ const l = s.subscribe(() => g()), c = () => g(!0);
262
262
  document.addEventListener("scroll", c, { capture: !0, passive: !0 });
263
- const w = Yt(() => {
264
- i.recalculatePositions(), f && f.reset(), p();
263
+ const b = Yt(() => {
264
+ i.recalculatePositions(), f && f.reset(), g();
265
265
  });
266
- window.addEventListener("resize", w);
267
- const S = new ResizeObserver(w);
266
+ window.addEventListener("resize", b);
267
+ const S = new ResizeObserver(b);
268
268
  S.observe(t);
269
- const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((M) => {
270
- M.every((m) => m.target === t || t.contains(m.target)) || p(!0);
269
+ const E = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((B) => {
270
+ B.every((m) => m.target === t || t.contains(m.target)) || g(!0);
271
271
  });
272
272
  return C.observe(document.body, E), {
273
273
  destroy: () => {
274
- t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(v), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", w), S.disconnect(), C.disconnect();
274
+ t.removeEventListener("pointermove", u), o.destroy(), i.unobserve(x), l(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), S.disconnect(), C.disconnect();
275
275
  },
276
- redraw: p,
277
- setStyle: y,
278
- setFilter: b,
279
- setPainter: g,
276
+ redraw: g,
277
+ setStyle: p,
278
+ setFilter: y,
279
+ setPainter: v,
280
280
  setVisible: o.setVisible
281
281
  };
282
282
  }, $e = () => {
@@ -288,28 +288,28 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
288
288
  t.classList.add("r6o-annotatable");
289
289
  const e = $e(), n = e.getContext("2d");
290
290
  document.body.appendChild(e);
291
- const o = (r, l, f, h) => requestAnimationFrame(() => {
292
- const { width: u, height: p } = e;
293
- n.clearRect(-0.5, -0.5, u + 1, p + 1), h && h.clear();
294
- const { top: g, left: y } = l;
295
- [...r].sort((v, d) => {
296
- const { annotation: { target: { created: c } } } = v, { annotation: { target: { created: w } } } = d;
297
- return c.getTime() - w.getTime();
298
- }).forEach((v) => {
291
+ const o = (r, d, f, h) => requestAnimationFrame(() => {
292
+ const { width: u, height: g } = e;
293
+ n.clearRect(-0.5, -0.5, u + 1, g + 1), h && h.clear();
294
+ const { top: v, left: p } = d;
295
+ [...r].sort((x, l) => {
296
+ const { annotation: { target: { created: c } } } = x, { annotation: { target: { created: b } } } = l;
297
+ return c.getTime() - b.getTime();
298
+ }).forEach((x) => {
299
299
  var S;
300
- const d = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (S = v.state) != null && S.selected ? wt : W, c = h && h.paint(v, l) || d, w = v.rects.map(({ x: E, y: C, width: O, height: M }) => ({
301
- x: E + y,
302
- y: C + g,
300
+ const l = f ? typeof f == "function" ? f(x.annotation, x.state) : f : (S = x.state) != null && S.selected ? At : W, c = h && h.paint(x, d) || l, b = x.rects.map(({ x: E, y: C, width: O, height: B }) => ({
301
+ x: E + p,
302
+ y: C + v,
303
303
  width: O,
304
- height: M
304
+ height: B
305
305
  }));
306
- if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, w.forEach(
307
- ({ x: E, y: C, width: O, height: M }) => n.fillRect(E, C, O, M)
306
+ if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(
307
+ ({ x: E, y: C, width: O, height: B }) => n.fillRect(E, C, O, B)
308
308
  ), c.underlineColor) {
309
309
  n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
310
310
  const E = c.underlineOffset ?? 0;
311
- w.forEach(({ x: C, y: O, width: M, height: T }) => {
312
- n.beginPath(), n.moveTo(C, O + T + E), n.lineTo(C + M, O + T + E), n.stroke();
311
+ b.forEach(({ x: C, y: O, width: B, height: T }) => {
312
+ n.beginPath(), n.moveTo(C, O + T + E), n.lineTo(C + B, O + T + E), n.stroke();
313
313
  });
314
314
  }
315
315
  });
@@ -325,7 +325,7 @@ const re = "not-annotatable", tt = `.${re}`, it = (t) => {
325
325
  },
326
326
  redraw: o
327
327
  };
328
- }, ze = (t, e, n) => Kt(t, e, n, je(t));
328
+ }, ze = (t, e, n) => Dt(t, e, n, je(t));
329
329
  var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
330
330
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
331
331
  }, V = function(t, e, n) {
@@ -336,7 +336,7 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
336
336
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
337
337
  }, Pt = function(t) {
338
338
  return { r: X(t.r, 0, 255), g: X(t.g, 0, 255), b: X(t.b, 0, 255), a: X(t.a) };
339
- }, vt = function(t) {
339
+ }, Et = function(t) {
340
340
  return { r: V(t.r), g: V(t.g), b: V(t.b), a: V(t.a, 3) };
341
341
  }, We = /^#([0-9a-f]{3,8})$/i, ht = function(t) {
342
342
  var e = t.toString(16);
@@ -347,8 +347,8 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
347
347
  }, ue = function(t) {
348
348
  var e = t.h, n = t.s, o = t.v, i = t.a;
349
349
  e = e / 360 * 6, n /= 100, o /= 100;
350
- var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n), l = o * (1 - (1 - e + s) * n), f = s % 6;
351
- return { r: 255 * [o, r, a, a, l, o][f], g: 255 * [l, o, o, r, a, a][f], b: 255 * [a, a, l, o, o, r][f], a: i };
350
+ var s = Math.floor(e), a = o * (1 - n), r = o * (1 - (e - s) * n), d = o * (1 - (1 - e + s) * n), f = s % 6;
351
+ return { r: 255 * [o, r, a, a, d, o][f], g: 255 * [d, o, o, r, a, a][f], b: 255 * [a, a, d, o, o, r][f], a: i };
352
352
  }, $t = function(t) {
353
353
  return { h: le(t.h), s: X(t.s, 0, 100), l: X(t.l, 0, 100), a: X(t.a) };
354
354
  }, Ht = function(t) {
@@ -393,10 +393,10 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
393
393
  return [null, void 0];
394
394
  }, Ze = function(t) {
395
395
  return typeof t == "string" ? Ft(t.trim(), zt.string) : typeof t == "object" && t !== null ? Ft(t, zt.object) : [null, void 0];
396
- }, Et = function(t, e) {
396
+ }, St = function(t, e) {
397
397
  var n = at(t);
398
398
  return { h: n.h, s: X(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
399
- }, St = function(t) {
399
+ }, Ct = function(t) {
400
400
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
401
401
  }, Wt = function(t, e) {
402
402
  var n = at(t);
@@ -408,18 +408,18 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
408
408
  return t.prototype.isValid = function() {
409
409
  return this.parsed !== null;
410
410
  }, t.prototype.brightness = function() {
411
- return V(St(this.rgba), 2);
411
+ return V(Ct(this.rgba), 2);
412
412
  }, t.prototype.isDark = function() {
413
- return St(this.rgba) < 0.5;
413
+ return Ct(this.rgba) < 0.5;
414
414
  }, t.prototype.isLight = function() {
415
- return St(this.rgba) >= 0.5;
415
+ return Ct(this.rgba) >= 0.5;
416
416
  }, t.prototype.toHex = function() {
417
- return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? ht(V(255 * s)) : "", "#" + ht(n) + ht(o) + ht(i) + a;
417
+ return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, a = (s = e.a) < 1 ? ht(V(255 * s)) : "", "#" + ht(n) + ht(o) + ht(i) + a;
418
418
  var e, n, o, i, s, a;
419
419
  }, t.prototype.toRgb = function() {
420
- return vt(this.rgba);
420
+ return Et(this.rgba);
421
421
  }, t.prototype.toRgbString = function() {
422
- return e = vt(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
422
+ return e = Et(this.rgba), n = e.r, o = e.g, i = e.b, (s = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + s + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
423
423
  var e, n, o, i, s;
424
424
  }, t.prototype.toHsl = function() {
425
425
  return Ht(at(this.rgba));
@@ -433,11 +433,11 @@ var Fe = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, j = function(t) {
433
433
  return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
434
434
  var e;
435
435
  }, t.prototype.saturate = function(e) {
436
- return e === void 0 && (e = 0.1), $(Et(this.rgba, e));
436
+ return e === void 0 && (e = 0.1), $(St(this.rgba, e));
437
437
  }, t.prototype.desaturate = function(e) {
438
- return e === void 0 && (e = 0.1), $(Et(this.rgba, -e));
438
+ return e === void 0 && (e = 0.1), $(St(this.rgba, -e));
439
439
  }, t.prototype.grayscale = function() {
440
- return $(Et(this.rgba, -1));
440
+ return $(St(this.rgba, -1));
441
441
  }, t.prototype.lighten = function(e) {
442
442
  return e === void 0 && (e = 0.1), $(Wt(this.rgba, e));
443
443
  }, t.prototype.darken = function(e) {
@@ -473,25 +473,25 @@ const tn = (t) => [
473
473
  setVisible: (s) => {
474
474
  console.log("setVisible not implemented on CSS Custom Highlights renderer");
475
475
  },
476
- redraw: (s, a, r, l) => {
477
- l && l.clear();
476
+ redraw: (s, a, r, d) => {
477
+ d && d.clear();
478
478
  const f = new Set(s.map((u) => u.annotation.id));
479
479
  Array.from(e).filter((u) => !f.has(u));
480
480
  const h = s.map((u) => {
481
- var y;
482
- const p = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (y = u.state) != null && y.selected ? wt : W, g = l && l.paint(u, a) || p;
483
- return `::highlight(_${u.annotation.id}) { ${tn(g)} }`;
481
+ var p;
482
+ const g = r ? typeof r == "function" ? r(u.annotation, u.state) : r : (p = u.state) != null && p.selected ? At : W, v = d && d.paint(u, a) || g;
483
+ return `::highlight(_${u.annotation.id}) { ${tn(v)} }`;
484
484
  });
485
485
  t.innerHTML = h.join(`
486
486
  `), CSS.highlights.clear(), s.forEach(({ annotation: u }) => {
487
- const p = u.target.selector.map((y) => y.range), g = new Highlight(...p);
488
- CSS.highlights.set(`_${u.id}`, g);
487
+ const g = u.target.selector.map((p) => p.range), v = new Highlight(...g);
488
+ CSS.highlights.set(`_${u.id}`, v);
489
489
  }), e = f;
490
490
  }
491
491
  };
492
- }, nn = (t, e, n) => Kt(t, e, n, en());
492
+ }, nn = (t, e, n) => Dt(t, e, n, en());
493
493
  var Gt = Object.prototype.hasOwnProperty;
494
- function Ut(t, e) {
494
+ function Vt(t, e) {
495
495
  var n, o;
496
496
  if (t === e) return !0;
497
497
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -499,13 +499,13 @@ function Ut(t, e) {
499
499
  if (n === RegExp) return t.toString() === e.toString();
500
500
  if (n === Array) {
501
501
  if ((o = t.length) === e.length)
502
- for (; o-- && Ut(t[o], e[o]); ) ;
502
+ for (; o-- && Vt(t[o], e[o]); ) ;
503
503
  return o === -1;
504
504
  }
505
505
  if (!n || typeof t == "object") {
506
506
  o = 0;
507
507
  for (n in t)
508
- if (Gt.call(t, n) && ++o && !Gt.call(e, n) || !(n in e) || !Ut(t[n], e[n])) return !1;
508
+ if (Gt.call(t, n) && ++o && !Gt.call(e, n) || !(n in e) || !Vt(t[n], e[n])) return !1;
509
509
  return Object.keys(e).length === o;
510
510
  }
511
511
  }
@@ -523,18 +523,18 @@ const on = (t, e) => {
523
523
  destroy: () => {
524
524
  e.remove();
525
525
  },
526
- redraw: (a, r, l, f, h) => {
527
- const p = !(Ut(n, a) && h);
528
- if (!f && !p) return;
529
- p && (e.innerHTML = ""), [...a].sort((y, b) => {
530
- const { annotation: { target: { created: v } } } = y, { annotation: { target: { created: d } } } = b;
531
- return v && d ? v.getTime() - d.getTime() : 0;
532
- }).forEach((y) => {
533
- y.rects.map((b) => {
534
- const v = on(b, a), d = De(y, r, l, f, v);
535
- if (p) {
526
+ redraw: (a, r, d, f, h) => {
527
+ const g = !(Vt(n, a) && h);
528
+ if (!f && !g) return;
529
+ g && (e.innerHTML = ""), [...a].sort((p, y) => {
530
+ const { annotation: { target: { created: x } } } = p, { annotation: { target: { created: l } } } = y;
531
+ return x && l ? x.getTime() - l.getTime() : 0;
532
+ }).forEach((p) => {
533
+ p.rects.map((y) => {
534
+ const x = on(y, a), l = Ke(p, r, d, f, x);
535
+ if (g) {
536
536
  const c = document.createElement("span");
537
- c.className = "r6o-annotation", c.dataset.annotation = y.annotation.id, c.style.left = `${b.x}px`, c.style.top = `${b.y}px`, c.style.width = `${b.width}px`, c.style.height = `${b.height}px`, c.style.backgroundColor = $((d == null ? void 0 : d.fill) || W.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? W.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (c.style.borderStyle = d.underlineStyle), d.underlineColor && (c.style.borderColor = d.underlineColor), d.underlineThickness && (c.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (c.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(c);
537
+ c.className = "r6o-annotation", c.dataset.annotation = p.annotation.id, c.style.left = `${y.x}px`, c.style.top = `${y.y}px`, c.style.width = `${y.width}px`, c.style.height = `${y.height}px`, c.style.backgroundColor = $((l == null ? void 0 : l.fill) || W.fill).alpha((l == null ? void 0 : l.fillOpacity) === void 0 ? W.fillOpacity : l.fillOpacity).toHex(), l.underlineStyle && (c.style.borderStyle = l.underlineStyle), l.underlineColor && (c.style.borderColor = l.underlineColor), l.underlineThickness && (c.style.borderBottomWidth = `${l.underlineThickness}px`), l.underlineOffset && (c.style.paddingBottom = `${l.underlineOffset}px`), e.appendChild(c);
538
538
  }
539
539
  });
540
540
  }), n = a;
@@ -543,21 +543,21 @@ const on = (t, e) => {
543
543
  a ? e.classList.remove("hidden") : e.classList.add("hidden");
544
544
  }
545
545
  };
546
- }, rn = (t, e, n) => Kt(t, e, n, sn(t)), Y = [];
546
+ }, rn = (t, e, n) => Dt(t, e, n, sn(t)), Y = [];
547
547
  for (let t = 0; t < 256; ++t)
548
548
  Y.push((t + 256).toString(16).slice(1));
549
549
  function an(t, e = 0) {
550
550
  return (Y[t[e + 0]] + Y[t[e + 1]] + Y[t[e + 2]] + Y[t[e + 3]] + "-" + Y[t[e + 4]] + Y[t[e + 5]] + "-" + Y[t[e + 6]] + Y[t[e + 7]] + "-" + Y[t[e + 8]] + Y[t[e + 9]] + "-" + Y[t[e + 10]] + Y[t[e + 11]] + Y[t[e + 12]] + Y[t[e + 13]] + Y[t[e + 14]] + Y[t[e + 15]]).toLowerCase();
551
551
  }
552
- let Ct;
552
+ let Lt;
553
553
  const cn = new Uint8Array(16);
554
554
  function ln() {
555
- if (!Ct) {
555
+ if (!Lt) {
556
556
  if (typeof crypto > "u" || !crypto.getRandomValues)
557
557
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
558
- Ct = crypto.getRandomValues.bind(crypto);
558
+ Lt = crypto.getRandomValues.bind(crypto);
559
559
  }
560
- return Ct(cn);
560
+ return Lt(cn);
561
561
  }
562
562
  const dn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Qt = { randomUUID: dn };
563
563
  function fe(t, e, n) {
@@ -588,21 +588,21 @@ function G(t, e) {
588
588
  }
589
589
  return t !== t && e !== e;
590
590
  }
591
- function Lt() {
591
+ function Tt() {
592
592
  }
593
593
  function un(t, e) {
594
594
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
595
595
  }
596
596
  const Q = [];
597
- function Dt(t, e = Lt) {
597
+ function Kt(t, e = Tt) {
598
598
  let n;
599
599
  const o = /* @__PURE__ */ new Set();
600
600
  function i(r) {
601
601
  if (un(t, r) && (t = r, n)) {
602
- const l = !Q.length;
602
+ const d = !Q.length;
603
603
  for (const f of o)
604
604
  f[1](), Q.push(f, t);
605
- if (l) {
605
+ if (d) {
606
606
  for (let f = 0; f < Q.length; f += 2)
607
607
  Q[f][0](Q[f + 1]);
608
608
  Q.length = 0;
@@ -612,16 +612,16 @@ function Dt(t, e = Lt) {
612
612
  function s(r) {
613
613
  i(r(t));
614
614
  }
615
- function a(r, l = Lt) {
616
- const f = [r, l];
617
- return o.add(f), o.size === 1 && (n = e(i, s) || Lt), r(t), () => {
615
+ function a(r, d = Tt) {
616
+ const f = [r, d];
617
+ return o.add(f), o.size === 1 && (n = e(i, s) || Tt), r(t), () => {
618
618
  o.delete(f), o.size === 0 && n && (n(), n = null);
619
619
  };
620
620
  }
621
621
  return { set: i, update: s, subscribe: a };
622
622
  }
623
623
  const fn = (t) => {
624
- const { subscribe: e, set: n } = Dt();
624
+ const { subscribe: e, set: n } = Kt();
625
625
  let o;
626
626
  return e((i) => o = i), t.observe(({ changes: i }) => {
627
627
  if (o) {
@@ -638,56 +638,56 @@ const fn = (t) => {
638
638
  };
639
639
  };
640
640
  var hn = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(hn || {});
641
- const pt = { selected: [] }, pn = (t, e, n) => {
642
- const { subscribe: o, set: i } = Dt(pt);
643
- let s = e, a = pt;
644
- o((y) => a = y);
641
+ const gt = { selected: [] }, gn = (t, e, n) => {
642
+ const { subscribe: o, set: i } = Kt(gt);
643
+ let s = e, a = gt;
644
+ o((p) => a = p);
645
645
  const r = () => {
646
- G(a, pt) || i(pt);
647
- }, l = () => {
648
- var y;
649
- return ((y = a.selected) == null ? void 0 : y.length) === 0;
650
- }, f = (y) => {
651
- if (l())
646
+ G(a, gt) || i(gt);
647
+ }, d = () => {
648
+ var p;
649
+ return ((p = a.selected) == null ? void 0 : p.length) === 0;
650
+ }, f = (p) => {
651
+ if (d())
652
652
  return !1;
653
- const b = typeof y == "string" ? y : y.id;
654
- return a.selected.some((v) => v.id === b);
655
- }, h = (y, b) => {
656
- let v;
657
- if (Array.isArray(y)) {
658
- if (v = y.map((c) => t.getAnnotation(c)).filter(Boolean), v.length < y.length) {
659
- console.warn("Invalid selection: " + y.filter((c) => !v.some((w) => w.id === c)));
653
+ const y = typeof p == "string" ? p : p.id;
654
+ return a.selected.some((x) => x.id === y);
655
+ }, h = (p, y) => {
656
+ let x;
657
+ if (Array.isArray(p)) {
658
+ if (x = p.map((c) => t.getAnnotation(c)).filter(Boolean), x.length < p.length) {
659
+ console.warn("Invalid selection: " + p.filter((c) => !x.some((b) => b.id === c)));
660
660
  return;
661
661
  }
662
662
  } else {
663
- const c = t.getAnnotation(y);
663
+ const c = t.getAnnotation(p);
664
664
  if (!c) {
665
- console.warn("Invalid selection: " + y);
665
+ console.warn("Invalid selection: " + p);
666
666
  return;
667
667
  }
668
- v = [c];
668
+ x = [c];
669
669
  }
670
- const d = v.reduce((c, w) => {
671
- const S = Zt(w, s);
672
- return S === "EDIT" ? [...c, { id: w.id, editable: !0 }] : S === "SELECT" ? [...c, { id: w.id }] : c;
670
+ const l = x.reduce((c, b) => {
671
+ const S = Zt(b, s);
672
+ return S === "EDIT" ? [...c, { id: b.id, editable: !0 }] : S === "SELECT" ? [...c, { id: b.id }] : c;
673
673
  }, []);
674
- i({ selected: d, event: b });
675
- }, u = (y, b) => {
676
- const v = Array.isArray(y) ? y : [y], d = v.map((c) => t.getAnnotation(c)).filter((c) => !!c);
674
+ i({ selected: l, event: y });
675
+ }, u = (p, y) => {
676
+ const x = Array.isArray(p) ? p : [p], l = x.map((c) => t.getAnnotation(c)).filter((c) => !!c);
677
677
  i({
678
- selected: d.map((c) => {
679
- const w = b === void 0 ? Zt(c, s) === "EDIT" : b;
680
- return { id: c.id, editable: w };
678
+ selected: l.map((c) => {
679
+ const b = y === void 0 ? Zt(c, s) === "EDIT" : y;
680
+ return { id: c.id, editable: b };
681
681
  })
682
- }), d.length !== v.length && console.warn("Invalid selection", y);
683
- }, p = (y) => {
684
- if (l())
682
+ }), l.length !== x.length && console.warn("Invalid selection", p);
683
+ }, g = (p) => {
684
+ if (d())
685
685
  return !1;
686
- const { selected: b } = a;
687
- b.some(({ id: v }) => y.includes(v)) && i({ selected: b.filter(({ id: v }) => !y.includes(v)) });
688
- }, g = (y) => s = y;
686
+ const { selected: y } = a;
687
+ y.some(({ id: x }) => p.includes(x)) && i({ selected: y.filter(({ id: x }) => !p.includes(x)) });
688
+ }, v = (p) => s = p;
689
689
  return t.observe(
690
- ({ changes: y }) => p((y.deleted || []).map((b) => b.id))
690
+ ({ changes: p }) => g((p.deleted || []).map((y) => y.id))
691
691
  ), {
692
692
  get event() {
693
693
  return a ? a.event : null;
@@ -699,28 +699,28 @@ const pt = { selected: [] }, pn = (t, e, n) => {
699
699
  return s;
700
700
  },
701
701
  clear: r,
702
- isEmpty: l,
702
+ isEmpty: d,
703
703
  isSelected: f,
704
704
  setSelected: u,
705
- setUserSelectAction: g,
705
+ setUserSelectAction: v,
706
706
  subscribe: o,
707
707
  userSelect: h
708
708
  };
709
- }, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT", K = [];
709
+ }, Zt = (t, e, n) => typeof e == "function" ? e(t) : e || "EDIT", D = [];
710
710
  for (let t = 0; t < 256; ++t)
711
- K.push((t + 256).toString(16).slice(1));
712
- function gn(t, e = 0) {
713
- return (K[t[e + 0]] + K[t[e + 1]] + K[t[e + 2]] + K[t[e + 3]] + "-" + K[t[e + 4]] + K[t[e + 5]] + "-" + K[t[e + 6]] + K[t[e + 7]] + "-" + K[t[e + 8]] + K[t[e + 9]] + "-" + K[t[e + 10]] + K[t[e + 11]] + K[t[e + 12]] + K[t[e + 13]] + K[t[e + 14]] + K[t[e + 15]]).toLowerCase();
711
+ D.push((t + 256).toString(16).slice(1));
712
+ function pn(t, e = 0) {
713
+ return (D[t[e + 0]] + D[t[e + 1]] + D[t[e + 2]] + D[t[e + 3]] + "-" + D[t[e + 4]] + D[t[e + 5]] + "-" + D[t[e + 6]] + D[t[e + 7]] + "-" + D[t[e + 8]] + D[t[e + 9]] + "-" + D[t[e + 10]] + D[t[e + 11]] + D[t[e + 12]] + D[t[e + 13]] + D[t[e + 14]] + D[t[e + 15]]).toLowerCase();
714
714
  }
715
- let Tt;
715
+ let Ot;
716
716
  const mn = new Uint8Array(16);
717
717
  function yn() {
718
- if (!Tt) {
718
+ if (!Ot) {
719
719
  if (typeof crypto > "u" || !crypto.getRandomValues)
720
720
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
721
- Tt = crypto.getRandomValues.bind(crypto);
721
+ Ot = crypto.getRandomValues.bind(crypto);
722
722
  }
723
- return Tt(mn);
723
+ return Ot(mn);
724
724
  }
725
725
  const bn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), te = { randomUUID: bn };
726
726
  function he(t, e, n) {
@@ -728,9 +728,9 @@ function he(t, e, n) {
728
728
  return te.randomUUID();
729
729
  t = t || {};
730
730
  const o = t.random || (t.rng || yn)();
731
- return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, gn(o);
731
+ return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, pn(o);
732
732
  }
733
- const Ot = (t) => {
733
+ const Bt = (t) => {
734
734
  const e = (n) => {
735
735
  const o = { ...n };
736
736
  return n.created && typeof n.created == "string" && (o.created = new Date(n.created)), n.updated && typeof n.updated == "string" && (o.updated = new Date(n.updated)), o;
@@ -755,7 +755,7 @@ const Ot = (t) => {
755
755
  }, xn = (t, e) => e.bodies.map((n) => {
756
756
  const o = t.bodies.find((i) => i.id === n.id);
757
757
  return { newBody: n, oldBody: o && !G(o, n) ? o : void 0 };
758
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !G(t.target, e.target), pe = (t, e) => {
758
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), vn = (t, e) => !G(t.target, e.target), ge = (t, e) => {
759
759
  const n = wn(t, e), o = An(t, e), i = xn(t, e);
760
760
  return {
761
761
  oldValue: t,
@@ -773,10 +773,10 @@ const En = (t, e) => {
773
773
  if (!(t.options.origin ? t.options.origin === s : s !== "SILENT"))
774
774
  return !1;
775
775
  if (t.options.ignore) {
776
- const { ignore: a } = t.options, r = (l) => l && l.length > 0;
776
+ const { ignore: a } = t.options, r = (d) => d && d.length > 0;
777
777
  if (!(r(i.created) || r(i.deleted))) {
778
- const l = (n = i.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
779
- if (a === "BODY_ONLY" && l && !f || a === "TARGET_ONLY" && f && !l)
778
+ const d = (n = i.updated) == null ? void 0 : n.some((h) => r(h.bodiesCreated) || r(h.bodiesDeleted) || r(h.bodiesUpdated)), f = (o = i.updated) == null ? void 0 : o.some((h) => h.targetUpdated);
779
+ if (a === "BODY_ONLY" && d && !f || a === "TARGET_ONLY" && f && !d)
780
780
  return !1;
781
781
  }
782
782
  }
@@ -790,24 +790,24 @@ const En = (t, e) => {
790
790
  } else
791
791
  return !0;
792
792
  }, Sn = (t, e) => {
793
- const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), l = [
794
- ...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: p }) => p.id === u.id).newValue : u),
793
+ const n = new Set((t.created || []).map((u) => u.id)), o = new Set((t.updated || []).map(({ newValue: u }) => u.id)), i = new Set((e.created || []).map((u) => u.id)), s = new Set((e.deleted || []).map((u) => u.id)), a = new Set((e.updated || []).map(({ oldValue: u }) => u.id)), r = new Set((e.updated || []).filter(({ oldValue: u }) => n.has(u.id) || o.has(u.id)).map(({ oldValue: u }) => u.id)), d = [
794
+ ...(t.created || []).filter((u) => !s.has(u.id)).map((u) => a.has(u.id) ? e.updated.find(({ oldValue: g }) => g.id === u.id).newValue : u),
795
795
  ...e.created || []
796
796
  ], f = [
797
797
  ...(t.deleted || []).filter((u) => !i.has(u.id)),
798
798
  ...(e.deleted || []).filter((u) => !n.has(u.id))
799
799
  ], h = [
800
800
  ...(t.updated || []).filter(({ newValue: u }) => !s.has(u.id)).map((u) => {
801
- const { oldValue: p, newValue: g } = u;
802
- if (a.has(g.id)) {
803
- const y = e.updated.find((b) => b.oldValue.id === g.id).newValue;
804
- return pe(p, y);
801
+ const { oldValue: g, newValue: v } = u;
802
+ if (a.has(v.id)) {
803
+ const p = e.updated.find((y) => y.oldValue.id === v.id).newValue;
804
+ return ge(g, p);
805
805
  } else
806
806
  return u;
807
807
  }),
808
808
  ...(e.updated || []).filter(({ oldValue: u }) => !r.has(u.id))
809
809
  ];
810
- return { created: l, deleted: f, updated: h };
810
+ return { created: d, deleted: f, updated: h };
811
811
  }, Mt = (t) => {
812
812
  const e = t.id === void 0 ? he() : t.id;
813
813
  return {
@@ -823,170 +823,170 @@ const En = (t, e) => {
823
823
  }
824
824
  };
825
825
  }, Cn = (t) => t.id !== void 0, Ln = () => {
826
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, x = {}) => {
827
- n.push({ onChange: m, options: x });
826
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, A = {}) => {
827
+ n.push({ onChange: m, options: A });
828
828
  }, i = (m) => {
829
- const x = n.findIndex((A) => A.onChange == m);
830
- x > -1 && n.splice(x, 1);
831
- }, s = (m, x) => {
832
- const A = {
829
+ const A = n.findIndex((w) => w.onChange == m);
830
+ A > -1 && n.splice(A, 1);
831
+ }, s = (m, A) => {
832
+ const w = {
833
833
  origin: m,
834
834
  changes: {
835
- created: x.created || [],
836
- updated: x.updated || [],
837
- deleted: x.deleted || []
835
+ created: A.created || [],
836
+ updated: A.updated || [],
837
+ deleted: A.deleted || []
838
838
  },
839
839
  state: [...t.values()]
840
840
  };
841
841
  n.forEach((L) => {
842
- En(L, A) && L.onChange(A);
842
+ En(L, w) && L.onChange(w);
843
843
  });
844
- }, a = (m, x = k.LOCAL) => {
844
+ }, a = (m, A = k.LOCAL) => {
845
845
  if (m.id && t.get(m.id))
846
846
  throw Error(`Cannot add annotation ${m.id} - exists already`);
847
847
  {
848
- const A = Mt(m);
849
- t.set(A.id, A), A.bodies.forEach((L) => e.set(L.id, A.id)), s(x, { created: [A] });
848
+ const w = Mt(m);
849
+ t.set(w.id, w), w.bodies.forEach((L) => e.set(L.id, w.id)), s(A, { created: [w] });
850
850
  }
851
- }, r = (m, x) => {
852
- const A = Mt(typeof m == "string" ? x : m), L = typeof m == "string" ? m : m.id, B = L && t.get(L);
853
- if (B) {
854
- const R = pe(B, A);
855
- return L === A.id ? t.set(L, A) : (t.delete(L), t.set(A.id, A)), B.bodies.forEach((N) => e.delete(N.id)), A.bodies.forEach((N) => e.set(N.id, A.id)), R;
851
+ }, r = (m, A) => {
852
+ const w = Mt(typeof m == "string" ? A : m), L = typeof m == "string" ? m : m.id, M = L && t.get(L);
853
+ if (M) {
854
+ const R = ge(M, w);
855
+ return L === w.id ? t.set(L, w) : (t.delete(L), t.set(w.id, w)), M.bodies.forEach((N) => e.delete(N.id)), w.bodies.forEach((N) => e.set(N.id, w.id)), R;
856
856
  } else
857
857
  console.warn(`Cannot update annotation ${L} - does not exist`);
858
- }, l = (m, x = k.LOCAL, A = k.LOCAL) => {
859
- const L = Cn(x) ? A : x, B = r(m, x);
860
- B && s(L, { updated: [B] });
861
- }, f = (m, x = k.LOCAL) => {
862
- const A = m.reduce((L, B) => {
863
- const R = r(B);
858
+ }, d = (m, A = k.LOCAL, w = k.LOCAL) => {
859
+ const L = Cn(A) ? w : A, M = r(m, A);
860
+ M && s(L, { updated: [M] });
861
+ }, f = (m, A = k.LOCAL) => {
862
+ const w = m.reduce((L, M) => {
863
+ const R = r(M);
864
864
  return R ? [...L, R] : L;
865
865
  }, []);
866
- A.length > 0 && s(x, { updated: A });
867
- }, h = (m, x = k.LOCAL) => {
868
- const A = t.get(m.annotation);
869
- if (A) {
866
+ w.length > 0 && s(A, { updated: w });
867
+ }, h = (m, A = k.LOCAL) => {
868
+ const w = t.get(m.annotation);
869
+ if (w) {
870
870
  const L = {
871
- ...A,
872
- bodies: [...A.bodies, m]
871
+ ...w,
872
+ bodies: [...w.bodies, m]
873
873
  };
874
- t.set(A.id, L), e.set(m.id, L.id), s(x, { updated: [{
875
- oldValue: A,
874
+ t.set(w.id, L), e.set(m.id, L.id), s(A, { updated: [{
875
+ oldValue: w,
876
876
  newValue: L,
877
877
  bodiesCreated: [m]
878
878
  }] });
879
879
  } else
880
880
  console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
881
- }, u = () => [...t.values()], p = (m = k.LOCAL) => {
882
- const x = [...t.values()];
883
- t.clear(), e.clear(), s(m, { deleted: x });
884
- }, g = (m, x = !0, A = k.LOCAL) => {
881
+ }, u = () => [...t.values()], g = (m = k.LOCAL) => {
882
+ const A = [...t.values()];
883
+ t.clear(), e.clear(), s(m, { deleted: A });
884
+ }, v = (m, A = !0, w = k.LOCAL) => {
885
885
  const L = m.map(Mt);
886
- if (x) {
887
- const B = [...t.values()];
886
+ if (A) {
887
+ const M = [...t.values()];
888
888
  t.clear(), e.clear(), L.forEach((R) => {
889
889
  t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
890
- }), s(A, { created: L, deleted: B });
890
+ }), s(w, { created: L, deleted: M });
891
891
  } else {
892
- const B = m.reduce((R, N) => {
892
+ const M = m.reduce((R, N) => {
893
893
  const U = N.id && t.get(N.id);
894
894
  return U ? [...R, U] : R;
895
895
  }, []);
896
- if (B.length > 0)
897
- throw Error(`Bulk insert would overwrite the following annotations: ${B.map((R) => R.id).join(", ")}`);
896
+ if (M.length > 0)
897
+ throw Error(`Bulk insert would overwrite the following annotations: ${M.map((R) => R.id).join(", ")}`);
898
898
  L.forEach((R) => {
899
899
  t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
900
- }), s(A, { created: L });
900
+ }), s(w, { created: L });
901
901
  }
902
- }, y = (m) => {
903
- const x = typeof m == "string" ? m : m.id, A = t.get(x);
904
- if (A)
905
- return t.delete(x), A.bodies.forEach((L) => e.delete(L.id)), A;
906
- console.warn(`Attempt to delete missing annotation: ${x}`);
907
- }, b = (m, x = k.LOCAL) => {
908
- const A = y(m);
909
- A && s(x, { deleted: [A] });
910
- }, v = (m, x = k.LOCAL) => {
911
- const A = m.reduce((L, B) => {
912
- const R = y(B);
902
+ }, p = (m) => {
903
+ const A = typeof m == "string" ? m : m.id, w = t.get(A);
904
+ if (w)
905
+ return t.delete(A), w.bodies.forEach((L) => e.delete(L.id)), w;
906
+ console.warn(`Attempt to delete missing annotation: ${A}`);
907
+ }, y = (m, A = k.LOCAL) => {
908
+ const w = p(m);
909
+ w && s(A, { deleted: [w] });
910
+ }, x = (m, A = k.LOCAL) => {
911
+ const w = m.reduce((L, M) => {
912
+ const R = p(M);
913
913
  return R ? [...L, R] : L;
914
914
  }, []);
915
- A.length > 0 && s(x, { deleted: A });
916
- }, d = (m) => {
917
- const x = t.get(m.annotation);
918
- if (x) {
919
- const A = x.bodies.find((L) => L.id === m.id);
920
- if (A) {
921
- e.delete(A.id);
915
+ w.length > 0 && s(A, { deleted: w });
916
+ }, l = (m) => {
917
+ const A = t.get(m.annotation);
918
+ if (A) {
919
+ const w = A.bodies.find((L) => L.id === m.id);
920
+ if (w) {
921
+ e.delete(w.id);
922
922
  const L = {
923
- ...x,
924
- bodies: x.bodies.filter((B) => B.id !== m.id)
923
+ ...A,
924
+ bodies: A.bodies.filter((M) => M.id !== m.id)
925
925
  };
926
- return t.set(x.id, L), {
927
- oldValue: x,
926
+ return t.set(A.id, L), {
927
+ oldValue: A,
928
928
  newValue: L,
929
- bodiesDeleted: [A]
929
+ bodiesDeleted: [w]
930
930
  };
931
931
  } else
932
932
  console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
933
933
  } else
934
934
  console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
935
- }, c = (m, x = k.LOCAL) => {
936
- const A = d(m);
937
- A && s(x, { updated: [A] });
938
- }, w = (m, x = k.LOCAL) => {
939
- const A = m.map((L) => d(L)).filter(Boolean);
940
- A.length > 0 && s(x, { updated: A });
935
+ }, c = (m, A = k.LOCAL) => {
936
+ const w = l(m);
937
+ w && s(A, { updated: [w] });
938
+ }, b = (m, A = k.LOCAL) => {
939
+ const w = m.map((L) => l(L)).filter(Boolean);
940
+ w.length > 0 && s(A, { updated: w });
941
941
  }, S = (m) => {
942
- const x = t.get(m);
943
- return x ? { ...x } : void 0;
942
+ const A = t.get(m);
943
+ return A ? { ...A } : void 0;
944
944
  }, E = (m) => {
945
- const x = e.get(m);
946
- if (x) {
947
- const A = S(x).bodies.find((L) => L.id === m);
948
- if (A)
949
- return A;
945
+ const A = e.get(m);
946
+ if (A) {
947
+ const w = S(A).bodies.find((L) => L.id === m);
948
+ if (w)
949
+ return w;
950
950
  console.error(`Store integrity error: body ${m} in index, but not in annotation`);
951
951
  } else
952
952
  console.warn(`Attempt to retrieve missing body: ${m}`);
953
- }, C = (m, x) => {
954
- if (m.annotation !== x.annotation)
953
+ }, C = (m, A) => {
954
+ if (m.annotation !== A.annotation)
955
955
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
956
- const A = t.get(m.annotation);
957
- if (A) {
958
- const L = A.bodies.find((R) => R.id === m.id), B = {
959
- ...A,
960
- bodies: A.bodies.map((R) => R.id === L.id ? x : R)
956
+ const w = t.get(m.annotation);
957
+ if (w) {
958
+ const L = w.bodies.find((R) => R.id === m.id), M = {
959
+ ...w,
960
+ bodies: w.bodies.map((R) => R.id === L.id ? A : R)
961
961
  };
962
- return t.set(A.id, B), L.id !== x.id && (e.delete(L.id), e.set(x.id, B.id)), {
963
- oldValue: A,
964
- newValue: B,
965
- bodiesUpdated: [{ oldBody: L, newBody: x }]
962
+ return t.set(w.id, M), L.id !== A.id && (e.delete(L.id), e.set(A.id, M.id)), {
963
+ oldValue: w,
964
+ newValue: M,
965
+ bodiesUpdated: [{ oldBody: L, newBody: A }]
966
966
  };
967
967
  } else
968
968
  console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
969
- }, O = (m, x, A = k.LOCAL) => {
970
- const L = C(m, x);
971
- L && s(A, { updated: [L] });
972
- }, M = (m, x = k.LOCAL) => {
973
- const A = m.map((L) => C({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
974
- s(x, { updated: A });
969
+ }, O = (m, A, w = k.LOCAL) => {
970
+ const L = C(m, A);
971
+ L && s(w, { updated: [L] });
972
+ }, B = (m, A = k.LOCAL) => {
973
+ const w = m.map((L) => C({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
974
+ s(A, { updated: w });
975
975
  }, T = (m) => {
976
- const x = t.get(m.annotation);
977
- if (x) {
978
- const A = {
979
- ...x,
976
+ const A = t.get(m.annotation);
977
+ if (A) {
978
+ const w = {
979
+ ...A,
980
980
  target: {
981
- ...x.target,
981
+ ...A.target,
982
982
  ...m
983
983
  }
984
984
  };
985
- return t.set(x.id, A), {
986
- oldValue: x,
987
- newValue: A,
985
+ return t.set(A.id, w), {
986
+ oldValue: A,
987
+ newValue: w,
988
988
  targetUpdated: {
989
- oldTarget: x.target,
989
+ oldTarget: A.target,
990
990
  newTarget: m
991
991
  }
992
992
  };
@@ -997,27 +997,27 @@ const En = (t, e) => {
997
997
  addAnnotation: a,
998
998
  addBody: h,
999
999
  all: u,
1000
- bulkAddAnnotation: g,
1001
- bulkDeleteAnnotation: v,
1002
- bulkDeleteBodies: w,
1000
+ bulkAddAnnotation: v,
1001
+ bulkDeleteAnnotation: x,
1002
+ bulkDeleteBodies: b,
1003
1003
  bulkUpdateAnnotation: f,
1004
- bulkUpdateBodies: M,
1005
- bulkUpdateTargets: (m, x = k.LOCAL) => {
1006
- const A = m.map((L) => T(L)).filter(Boolean);
1007
- A.length > 0 && s(x, { updated: A });
1004
+ bulkUpdateBodies: B,
1005
+ bulkUpdateTargets: (m, A = k.LOCAL) => {
1006
+ const w = m.map((L) => T(L)).filter(Boolean);
1007
+ w.length > 0 && s(A, { updated: w });
1008
1008
  },
1009
- clear: p,
1010
- deleteAnnotation: b,
1009
+ clear: g,
1010
+ deleteAnnotation: y,
1011
1011
  deleteBody: c,
1012
1012
  getAnnotation: S,
1013
1013
  getBody: E,
1014
1014
  observe: o,
1015
1015
  unobserve: i,
1016
- updateAnnotation: l,
1016
+ updateAnnotation: d,
1017
1017
  updateBody: O,
1018
- updateTarget: (m, x = k.LOCAL) => {
1019
- const A = T(m);
1020
- A && s(x, { updated: [A] });
1018
+ updateTarget: (m, A = k.LOCAL) => {
1019
+ const w = T(m);
1020
+ w && s(A, { updated: [w] });
1021
1021
  }
1022
1022
  };
1023
1023
  };
@@ -1035,118 +1035,119 @@ let Tn = () => ({
1035
1035
  };
1036
1036
  }
1037
1037
  });
1038
- const On = 250, Mn = (t) => {
1039
- const e = Tn(), n = [];
1040
- let o = -1, i = !1, s = 0;
1041
- const a = (g) => {
1042
- if (!i) {
1043
- const { changes: y } = g, b = performance.now();
1044
- if (b - s > On)
1045
- n.splice(o + 1), n.push(y), o = n.length - 1;
1038
+ const On = 250, Bn = (t, e) => {
1039
+ const n = Tn(), o = [];
1040
+ let i = -1, s = !1, a = 0;
1041
+ const r = (p) => {
1042
+ if (!s) {
1043
+ const { changes: y } = p, x = performance.now();
1044
+ if (x - a > On)
1045
+ o.splice(i + 1), o.push(y), i = o.length - 1;
1046
1046
  else {
1047
- const v = n.length - 1;
1048
- n[v] = Sn(n[v], y);
1047
+ const l = o.length - 1;
1048
+ o[l] = Sn(o[l], y);
1049
1049
  }
1050
- s = b;
1050
+ a = x;
1051
1051
  }
1052
- i = !1;
1052
+ s = !1;
1053
1053
  };
1054
- t.observe(a, { origin: k.LOCAL });
1055
- const r = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g), l = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), f = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ oldValue: y }) => y)), h = (g) => g && g.length > 0 && t.bulkUpdateAnnotation(g.map(({ newValue: y }) => y)), u = (g) => g && g.length > 0 && t.bulkAddAnnotation(g, !1), p = (g) => g && g.length > 0 && t.bulkDeleteAnnotation(g);
1054
+ t.observe(r, { origin: k.LOCAL });
1055
+ const d = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), f = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: y }) => y)), u = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: y }) => y)), g = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), v = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
1056
1056
  return {
1057
- canRedo: () => n.length - 1 > o,
1058
- canUndo: () => o > -1,
1059
- destroy: () => t.unobserve(a),
1060
- on: (g, y) => e.on(g, y),
1057
+ canRedo: () => o.length - 1 > i,
1058
+ canUndo: () => i > -1,
1059
+ destroy: () => t.unobserve(r),
1060
+ getHistory: () => ({ changes: [...o], pointer: i }),
1061
+ on: (p, y) => n.on(p, y),
1061
1062
  redo: () => {
1062
- if (n.length - 1 > o) {
1063
- i = !0;
1064
- const { created: g, updated: y, deleted: b } = n[o + 1];
1065
- l(g), h(y), p(b), e.emit("redo", n[o + 1]), o += 1;
1063
+ if (o.length - 1 > i) {
1064
+ s = !0;
1065
+ const { created: p, updated: y, deleted: x } = o[i + 1];
1066
+ f(p), u(y), v(x), n.emit("redo", o[i + 1]), i += 1;
1066
1067
  }
1067
1068
  },
1068
1069
  undo: () => {
1069
- if (o > -1) {
1070
- i = !0;
1071
- const { created: g, updated: y, deleted: b } = n[o];
1072
- r(g), f(y), u(b), e.emit("undo", n[o]), o -= 1;
1070
+ if (i > -1) {
1071
+ s = !0;
1072
+ const { created: p, updated: y, deleted: x } = o[i];
1073
+ d(p), h(y), g(x), n.emit("undo", o[i]), i -= 1;
1073
1074
  }
1074
1075
  }
1075
1076
  };
1076
- }, Bn = () => {
1077
- const { subscribe: t, set: e } = Dt([]);
1077
+ }, Mn = () => {
1078
+ const { subscribe: t, set: e } = Kt([]);
1078
1079
  return {
1079
1080
  subscribe: t,
1080
1081
  set: e
1081
1082
  };
1082
1083
  }, Rn = (t, e, n, o) => {
1083
- const { hover: i, selection: s, store: a, viewport: r } = t, l = /* @__PURE__ */ new Map();
1084
+ const { hover: i, selection: s, store: a, viewport: r } = t, d = /* @__PURE__ */ new Map();
1084
1085
  let f = [], h;
1085
- const u = (b, v) => {
1086
- l.has(b) ? l.get(b).push(v) : l.set(b, [v]);
1087
- }, p = (b, v) => {
1088
- const d = l.get(b);
1089
- if (d) {
1090
- const c = d.indexOf(v);
1091
- c !== -1 && d.splice(c, 1);
1086
+ const u = (y, x) => {
1087
+ d.has(y) ? d.get(y).push(x) : d.set(y, [x]);
1088
+ }, g = (y, x) => {
1089
+ const l = d.get(y);
1090
+ if (l) {
1091
+ const c = l.indexOf(x);
1092
+ c !== -1 && l.splice(c, 1);
1092
1093
  }
1093
- }, g = (b, v, d) => {
1094
- l.has(b) && setTimeout(() => {
1095
- l.get(b).forEach((c) => {
1094
+ }, v = (y, x, l) => {
1095
+ d.has(y) && setTimeout(() => {
1096
+ d.get(y).forEach((c) => {
1096
1097
  if (n) {
1097
- const w = Array.isArray(v) ? v.map((E) => n.serialize(E)) : n.serialize(v), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1098
- c(w, S);
1098
+ const b = Array.isArray(x) ? x.map((E) => n.serialize(E)) : n.serialize(x), S = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;
1099
+ c(b, S);
1099
1100
  } else
1100
- c(v, d);
1101
+ c(x, l);
1101
1102
  });
1102
1103
  }, 1);
1103
1104
  };
1104
- s.subscribe(({ selected: b }) => {
1105
- if (!(f.length === 0 && b.length === 0)) {
1106
- if (f.length === 0 && b.length > 0)
1107
- f = b.map(({ id: v }) => a.getAnnotation(v));
1108
- else if (f.length > 0 && b.length === 0)
1109
- f.forEach((v) => {
1110
- const d = a.getAnnotation(v.id);
1111
- d && !G(d, v) && g("updateAnnotation", d, v);
1105
+ s.subscribe(({ selected: y }) => {
1106
+ if (!(f.length === 0 && y.length === 0)) {
1107
+ if (f.length === 0 && y.length > 0)
1108
+ f = y.map(({ id: x }) => a.getAnnotation(x));
1109
+ else if (f.length > 0 && y.length === 0)
1110
+ f.forEach((x) => {
1111
+ const l = a.getAnnotation(x.id);
1112
+ l && !G(l, x) && v("updateAnnotation", l, x);
1112
1113
  }), f = [];
1113
1114
  else {
1114
- const v = new Set(f.map((c) => c.id)), d = new Set(b.map(({ id: c }) => c));
1115
- f.filter((c) => !d.has(c.id)).forEach((c) => {
1116
- const w = a.getAnnotation(c.id);
1117
- w && !G(w, c) && g("updateAnnotation", w, c);
1115
+ const x = new Set(f.map((c) => c.id)), l = new Set(y.map(({ id: c }) => c));
1116
+ f.filter((c) => !l.has(c.id)).forEach((c) => {
1117
+ const b = a.getAnnotation(c.id);
1118
+ b && !G(b, c) && v("updateAnnotation", b, c);
1118
1119
  }), f = [
1119
1120
  // Remove annotations that were deselected
1120
- ...f.filter((c) => d.has(c.id)),
1121
+ ...f.filter((c) => l.has(c.id)),
1121
1122
  // Add editable annotations that were selected
1122
- ...b.filter(({ id: c }) => !v.has(c)).map(({ id: c }) => a.getAnnotation(c))
1123
+ ...y.filter(({ id: c }) => !x.has(c)).map(({ id: c }) => a.getAnnotation(c))
1123
1124
  ];
1124
1125
  }
1125
- g("selectionChanged", f);
1126
+ v("selectionChanged", f);
1126
1127
  }
1127
- }), i.subscribe((b) => {
1128
- !h && b ? g("mouseEnterAnnotation", a.getAnnotation(b)) : h && !b ? g("mouseLeaveAnnotation", a.getAnnotation(h)) : h && b && (g("mouseLeaveAnnotation", a.getAnnotation(h)), g("mouseEnterAnnotation", a.getAnnotation(b))), h = b;
1129
- }), r == null || r.subscribe((b) => g("viewportIntersect", b.map((v) => a.getAnnotation(v)))), a.observe((b) => {
1130
- const { created: v, deleted: d } = b.changes;
1131
- (v || []).forEach((c) => g("createAnnotation", c)), (d || []).forEach((c) => g("deleteAnnotation", c)), (b.changes.updated || []).filter((c) => [
1128
+ }), i.subscribe((y) => {
1129
+ !h && y ? v("mouseEnterAnnotation", a.getAnnotation(y)) : h && !y ? v("mouseLeaveAnnotation", a.getAnnotation(h)) : h && y && (v("mouseLeaveAnnotation", a.getAnnotation(h)), v("mouseEnterAnnotation", a.getAnnotation(y))), h = y;
1130
+ }), r == null || r.subscribe((y) => v("viewportIntersect", y.map((x) => a.getAnnotation(x)))), a.observe((y) => {
1131
+ const { created: x, deleted: l } = y.changes;
1132
+ (x || []).forEach((c) => v("createAnnotation", c)), (l || []).forEach((c) => v("deleteAnnotation", c)), (y.changes.updated || []).filter((c) => [
1132
1133
  ...c.bodiesCreated || [],
1133
1134
  ...c.bodiesDeleted || [],
1134
1135
  ...c.bodiesUpdated || []
1135
- ].length > 0).forEach(({ oldValue: c, newValue: w }) => {
1136
+ ].length > 0).forEach(({ oldValue: c, newValue: b }) => {
1136
1137
  const S = f.find((E) => E.id === c.id) || c;
1137
- f = f.map((E) => E.id === c.id ? w : E), g("updateAnnotation", w, S);
1138
+ f = f.map((E) => E.id === c.id ? b : E), v("updateAnnotation", b, S);
1138
1139
  });
1139
- }, { origin: k.LOCAL }), a.observe((b) => {
1140
+ }, { origin: k.LOCAL }), a.observe((y) => {
1140
1141
  if (f) {
1141
- const v = new Set(f.map((c) => c.id)), d = (b.changes.updated || []).filter(({ newValue: c }) => v.has(c.id)).map(({ newValue: c }) => c);
1142
- d.length > 0 && (f = f.map((c) => d.find((S) => S.id === c.id) || c));
1142
+ const x = new Set(f.map((c) => c.id)), l = (y.changes.updated || []).filter(({ newValue: c }) => x.has(c.id)).map(({ newValue: c }) => c);
1143
+ l.length > 0 && (f = f.map((c) => l.find((S) => S.id === c.id) || c));
1143
1144
  }
1144
1145
  }, { origin: k.REMOTE });
1145
- const y = (b) => (v) => {
1146
- const { updated: d } = v;
1147
- b ? (d || []).forEach((c) => g("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => g("updateAnnotation", c.newValue, c.oldValue));
1146
+ const p = (y) => (x) => {
1147
+ const { updated: l } = x;
1148
+ y ? (l || []).forEach((c) => v("updateAnnotation", c.oldValue, c.newValue)) : (l || []).forEach((c) => v("updateAnnotation", c.newValue, c.oldValue));
1148
1149
  };
1149
- return e.on("undo", y(!0)), e.on("redo", y(!1)), { on: u, off: p, emit: g };
1150
+ return e.on("undo", p(!0)), e.on("redo", p(!1)), { on: u, off: g, emit: v };
1150
1151
  }, kn = (t) => (e) => e.reduce((n, o) => {
1151
1152
  const { parsed: i, error: s } = t.parse(o);
1152
1153
  return s ? {
@@ -1159,46 +1160,46 @@ const On = 250, Mn = (t) => {
1159
1160
  ...n
1160
1161
  };
1161
1162
  }, { parsed: [], failed: [] }), In = (t, e, n) => {
1162
- const { store: o, selection: i } = t, s = (d) => {
1163
+ const { store: o, selection: i } = t, s = (l) => {
1163
1164
  if (n) {
1164
- const { parsed: c, error: w } = n.parse(d);
1165
- c ? o.addAnnotation(c, k.REMOTE) : console.error(w);
1165
+ const { parsed: c, error: b } = n.parse(l);
1166
+ c ? o.addAnnotation(c, k.REMOTE) : console.error(b);
1166
1167
  } else
1167
- o.addAnnotation(Ot(d), k.REMOTE);
1168
- }, a = () => i.clear(), r = () => o.clear(), l = (d) => {
1169
- const c = o.getAnnotation(d);
1168
+ o.addAnnotation(Bt(l), k.REMOTE);
1169
+ }, a = () => i.clear(), r = () => o.clear(), d = (l) => {
1170
+ const c = o.getAnnotation(l);
1170
1171
  return n && c ? n.serialize(c) : c;
1171
1172
  }, f = () => n ? o.all().map(n.serialize) : o.all(), h = () => {
1172
- var d;
1173
- const c = (((d = i.selected) == null ? void 0 : d.map((w) => w.id)) || []).map((w) => o.getAnnotation(w)).filter(Boolean);
1173
+ var l;
1174
+ const c = (((l = i.selected) == null ? void 0 : l.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
1174
1175
  return n ? c.map(n.serialize) : c;
1175
- }, u = (d, c = !0) => fetch(d).then((w) => w.json()).then((w) => (g(w, c), w)), p = (d) => {
1176
- if (typeof d == "string") {
1177
- const c = o.getAnnotation(d);
1178
- if (o.deleteAnnotation(d), c)
1176
+ }, u = (l, c = !0) => fetch(l).then((b) => b.json()).then((b) => (v(b, c), b)), g = (l) => {
1177
+ if (typeof l == "string") {
1178
+ const c = o.getAnnotation(l);
1179
+ if (o.deleteAnnotation(l), c)
1179
1180
  return n ? n.serialize(c) : c;
1180
1181
  } else {
1181
- const c = n ? n.parse(d).parsed : d;
1182
+ const c = n ? n.parse(l).parsed : l;
1182
1183
  if (c)
1183
- return o.deleteAnnotation(c), d;
1184
+ return o.deleteAnnotation(c), l;
1184
1185
  }
1185
- }, g = (d, c = !0) => {
1186
+ }, v = (l, c = !0) => {
1186
1187
  if (n) {
1187
- const w = n.parseAll || kn(n), { parsed: S, failed: E } = w(d);
1188
+ const b = n.parseAll || kn(n), { parsed: S, failed: E } = b(l);
1188
1189
  E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(S, c, k.REMOTE);
1189
1190
  } else
1190
- o.bulkAddAnnotation(d.map(Ot), c, k.REMOTE);
1191
- }, y = (d, c) => {
1192
- d ? i.setSelected(d, c) : i.clear();
1193
- }, b = (d) => {
1194
- i.clear(), i.setUserSelectAction(d);
1195
- }, v = (d) => {
1191
+ o.bulkAddAnnotation(l.map(Bt), c, k.REMOTE);
1192
+ }, p = (l, c) => {
1193
+ l ? i.setSelected(l, c) : i.clear();
1194
+ }, y = (l) => {
1195
+ i.clear(), i.setUserSelectAction(l);
1196
+ }, x = (l) => {
1196
1197
  if (n) {
1197
- const c = n.parse(d).parsed, w = n.serialize(o.getAnnotation(c.id));
1198
- return o.updateAnnotation(c), w;
1198
+ const c = n.parse(l).parsed, b = n.serialize(o.getAnnotation(c.id));
1199
+ return o.updateAnnotation(c), b;
1199
1200
  } else {
1200
- const c = o.getAnnotation(d.id);
1201
- return o.updateAnnotation(Ot(d)), c;
1201
+ const c = o.getAnnotation(l.id);
1202
+ return o.updateAnnotation(Bt(l)), c;
1202
1203
  }
1203
1204
  };
1204
1205
  return {
@@ -1207,17 +1208,18 @@ const On = 250, Mn = (t) => {
1207
1208
  canRedo: e.canRedo,
1208
1209
  canUndo: e.canUndo,
1209
1210
  clearAnnotations: r,
1210
- getAnnotationById: l,
1211
+ getAnnotationById: d,
1211
1212
  getAnnotations: f,
1213
+ getHistory: e.getHistory,
1212
1214
  getSelected: h,
1213
1215
  loadAnnotations: u,
1214
1216
  redo: e.redo,
1215
- removeAnnotation: p,
1216
- setAnnotations: g,
1217
- setSelected: y,
1218
- setUserSelectAction: b,
1217
+ removeAnnotation: g,
1218
+ setAnnotations: v,
1219
+ setSelected: p,
1220
+ setUserSelectAction: y,
1219
1221
  undo: e.undo,
1220
- updateAnnotation: v
1222
+ updateAnnotation: x
1221
1223
  };
1222
1224
  }, _n = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1223
1225
  let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
@@ -1225,18 +1227,18 @@ let Nn = (t) => crypto.getRandomValues(new Uint8Array(t)), Un = (t, e, n) => {
1225
1227
  return (s = e) => {
1226
1228
  let a = "";
1227
1229
  for (; ; ) {
1228
- let r = n(i), l = i;
1229
- for (; l--; )
1230
- if (a += t[r[l] & o] || "", a.length === s) return a;
1230
+ let r = n(i), d = i | 0;
1231
+ for (; d--; )
1232
+ if (a += t[r[d] & o] || "", a.length >= s) return a;
1231
1233
  }
1232
1234
  };
1233
- }, Vn = (t, e = 21) => Un(t, e, Nn), Yn = (t = 21) => {
1234
- let e = "", n = crypto.getRandomValues(new Uint8Array(t));
1235
+ }, Vn = (t, e = 21) => Un(t, e | 0, Nn), Yn = (t = 21) => {
1236
+ let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
1235
1237
  for (; t--; )
1236
1238
  e += _n[n[t] & 63];
1237
1239
  return e;
1238
1240
  };
1239
- const Kn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Dn = (t) => {
1241
+ const Dn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), Kn = (t) => {
1240
1242
  const e = JSON.stringify(t);
1241
1243
  let n = 0;
1242
1244
  for (let o = 0, i = e.length; o < i; o++) {
@@ -1244,17 +1246,17 @@ const Kn = () => ({ isGuest: !0, id: Vn("1234567890abcdefghijklmnopqrstuvwxyzABC
1244
1246
  n = (n << 5) - n + s, n |= 0;
1245
1247
  }
1246
1248
  return `${n}`;
1247
- }, ge = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1248
- const { id: o, type: i, purpose: s, value: a, created: r, modified: l, creator: f, ...h } = n;
1249
+ }, pe = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Xn = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1250
+ const { id: o, type: i, purpose: s, value: a, created: r, modified: d, creator: f, ...h } = n;
1249
1251
  return {
1250
- id: o || `temp-${Dn(n)}`,
1252
+ id: o || `temp-${Kn(n)}`,
1251
1253
  annotation: e,
1252
1254
  type: i,
1253
1255
  purpose: s,
1254
1256
  value: a,
1255
- creator: ge(f),
1257
+ creator: pe(f),
1256
1258
  created: r ? new Date(r) : void 0,
1257
- updated: l ? new Date(l) : void 0,
1259
+ updated: d ? new Date(d) : void 0,
1258
1260
  ...h
1259
1261
  };
1260
1262
  }), Pn = (t) => t.map((e) => {
@@ -1281,7 +1283,7 @@ const xo = (t, e) => ({
1281
1283
  if (a.length === 0)
1282
1284
  return { error: Error(`No targets found for annotation: ${t.id}`) };
1283
1285
  const r = {
1284
- creator: ge(n),
1286
+ creator: pe(n),
1285
1287
  created: o ? new Date(o) : void 0,
1286
1288
  updated: i ? new Date(i) : void 0,
1287
1289
  annotation: e,
@@ -1289,14 +1291,14 @@ const xo = (t, e) => ({
1289
1291
  // @ts-expect-error: `styleClass` is not part of the core `TextAnnotationTarget` type
1290
1292
  styleClass: "styleClass" in a[0] ? a[0].styleClass : void 0
1291
1293
  };
1292
- for (const l of a) {
1293
- const h = (Array.isArray(l.selector) ? l.selector : [l.selector]).reduce((u, p) => {
1294
- switch (p.type) {
1294
+ for (const d of a) {
1295
+ const h = (Array.isArray(d.selector) ? d.selector : [d.selector]).reduce((u, g) => {
1296
+ switch (g.type) {
1295
1297
  case "TextQuoteSelector":
1296
- u.quote = p.exact;
1298
+ u.quote = g.exact;
1297
1299
  break;
1298
1300
  case "TextPositionSelector":
1299
- u.start = p.start, u.end = p.end;
1301
+ u.start = g.start, u.end = g.end;
1300
1302
  break;
1301
1303
  }
1302
1304
  return u;
@@ -1305,9 +1307,9 @@ const xo = (t, e) => ({
1305
1307
  r.selector.push(
1306
1308
  {
1307
1309
  ...h,
1308
- id: l.id,
1310
+ id: d.id,
1309
1311
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1310
- scope: l.scope
1312
+ scope: d.scope
1311
1313
  }
1312
1314
  );
1313
1315
  else {
@@ -1326,38 +1328,38 @@ const xo = (t, e) => ({
1326
1328
  modified: i,
1327
1329
  body: s,
1328
1330
  ...a
1329
- } = t, r = Xn(s, e), l = Hn(t);
1330
- return "error" in l ? { error: l.error } : {
1331
+ } = t, r = Xn(s, e), d = Hn(t);
1332
+ return "error" in d ? { error: d.error } : {
1331
1333
  parsed: {
1332
1334
  ...a,
1333
1335
  id: e,
1334
1336
  bodies: r,
1335
- target: l.parsed
1337
+ target: d.parsed
1336
1338
  }
1337
1339
  };
1338
1340
  }, zn = (t, e, n) => {
1339
1341
  const { bodies: o, target: i, ...s } = t, {
1340
1342
  selector: a,
1341
1343
  creator: r,
1342
- created: l,
1344
+ created: d,
1343
1345
  updated: f,
1344
1346
  ...h
1345
- } = i, u = a.map((p) => {
1346
- const { id: g, quote: y, start: b, end: v, range: d } = p, { prefix: c, suffix: w } = Re(d, n), S = [{
1347
+ } = i, u = a.map((g) => {
1348
+ const { id: v, quote: p, start: y, end: x, range: l } = g, { prefix: c, suffix: b } = Re(l, n), S = [{
1347
1349
  type: "TextQuoteSelector",
1348
- exact: y,
1350
+ exact: p,
1349
1351
  prefix: c,
1350
- suffix: w
1352
+ suffix: b
1351
1353
  }, {
1352
1354
  type: "TextPositionSelector",
1353
- start: b,
1354
- end: v
1355
+ start: y,
1356
+ end: x
1355
1357
  }];
1356
1358
  return {
1357
1359
  ...h,
1358
- id: g,
1360
+ id: v,
1359
1361
  // @ts-expect-error: `scope` is not part of the core `TextSelector` type
1360
- scope: "scope" in p ? p.scope : void 0,
1362
+ scope: "scope" in g ? g.scope : void 0,
1361
1363
  source: e,
1362
1364
  selector: S
1363
1365
  };
@@ -1369,7 +1371,7 @@ const xo = (t, e) => ({
1369
1371
  type: "Annotation",
1370
1372
  body: Pn(t.bodies),
1371
1373
  creator: r,
1372
- created: l == null ? void 0 : l.toISOString(),
1374
+ created: d == null ? void 0 : d.toISOString(),
1373
1375
  modified: f == null ? void 0 : f.toISOString(),
1374
1376
  target: u
1375
1377
  };
@@ -1377,8 +1379,8 @@ const xo = (t, e) => ({
1377
1379
  function me(t, e, n = 0, o = t.length - 1, i = Fn) {
1378
1380
  for (; o > n; ) {
1379
1381
  if (o - n > 600) {
1380
- const l = o - n + 1, f = e - n + 1, h = Math.log(l), u = 0.5 * Math.exp(2 * h / 3), p = 0.5 * Math.sqrt(h * u * (l - u) / l) * (f - l / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - f * u / l + p)), y = Math.min(o, Math.floor(e + (l - f) * u / l + p));
1381
- me(t, e, g, y, i);
1382
+ const d = o - n + 1, f = e - n + 1, h = Math.log(d), u = 0.5 * Math.exp(2 * h / 3), g = 0.5 * Math.sqrt(h * u * (d - u) / d) * (f - d / 2 < 0 ? -1 : 1), v = Math.max(n, Math.floor(e - f * u / d + g)), p = Math.min(o, Math.floor(e + (d - f) * u / d + g));
1383
+ me(t, e, v, p, i);
1382
1384
  }
1383
1385
  const s = t[e];
1384
1386
  let a = n, r = o;
@@ -1410,8 +1412,8 @@ class Wn {
1410
1412
  const i = this.toBBox, s = [];
1411
1413
  for (; n; ) {
1412
1414
  for (let a = 0; a < n.children.length; a++) {
1413
- const r = n.children[a], l = n.leaf ? i(r) : r;
1414
- mt(e, l) && (n.leaf ? o.push(r) : Rt(e, l) ? this._all(r, o) : s.push(r));
1415
+ const r = n.children[a], d = n.leaf ? i(r) : r;
1416
+ mt(e, d) && (n.leaf ? o.push(r) : kt(e, d) ? this._all(r, o) : s.push(r));
1415
1417
  }
1416
1418
  n = s.pop();
1417
1419
  }
@@ -1425,7 +1427,7 @@ class Wn {
1425
1427
  for (let i = 0; i < n.children.length; i++) {
1426
1428
  const s = n.children[i], a = n.leaf ? this.toBBox(s) : s;
1427
1429
  if (mt(e, a)) {
1428
- if (n.leaf || Rt(e, a)) return !0;
1430
+ if (n.leaf || kt(e, a)) return !0;
1429
1431
  o.push(s);
1430
1432
  }
1431
1433
  }
@@ -1464,14 +1466,14 @@ class Wn {
1464
1466
  if (!e) return this;
1465
1467
  let o = this.data;
1466
1468
  const i = this.toBBox(e), s = [], a = [];
1467
- let r, l, f;
1469
+ let r, d, f;
1468
1470
  for (; o || s.length; ) {
1469
- if (o || (o = s.pop(), l = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
1471
+ if (o || (o = s.pop(), d = s[s.length - 1], r = a.pop(), f = !0), o.leaf) {
1470
1472
  const h = qn(e, o.children, n);
1471
1473
  if (h !== -1)
1472
1474
  return o.children.splice(h, 1), s.push(o), this._condense(s), this;
1473
1475
  }
1474
- !f && !o.leaf && Rt(o, i) ? (s.push(o), a.push(r), r = 0, l = o, o = o.children[0]) : l ? (r++, o = l.children[r], f = !1) : o = null;
1476
+ !f && !o.leaf && kt(o, i) ? (s.push(o), a.push(r), r = 0, d = o, o = o.children[0]) : d ? (r++, o = d.children[r], f = !1) : o = null;
1475
1477
  }
1476
1478
  return this;
1477
1479
  }
@@ -1502,14 +1504,14 @@ class Wn {
1502
1504
  if (s <= a)
1503
1505
  return r = Z(e.slice(n, o + 1)), J(r, this.toBBox), r;
1504
1506
  i || (i = Math.ceil(Math.log(s) / Math.log(a)), a = Math.ceil(s / Math.pow(a, i - 1))), r = Z([]), r.leaf = !1, r.height = i;
1505
- const l = Math.ceil(s / a), f = l * Math.ceil(Math.sqrt(a));
1507
+ const d = Math.ceil(s / a), f = d * Math.ceil(Math.sqrt(a));
1506
1508
  ee(e, n, o, f, this.compareMinX);
1507
1509
  for (let h = n; h <= o; h += f) {
1508
1510
  const u = Math.min(h + f - 1, o);
1509
- ee(e, h, u, l, this.compareMinY);
1510
- for (let p = h; p <= u; p += l) {
1511
- const g = Math.min(p + l - 1, u);
1512
- r.children.push(this._build(e, p, g, i - 1));
1511
+ ee(e, h, u, d, this.compareMinY);
1512
+ for (let g = h; g <= u; g += d) {
1513
+ const v = Math.min(g + d - 1, u);
1514
+ r.children.push(this._build(e, g, v, i - 1));
1513
1515
  }
1514
1516
  }
1515
1517
  return J(r, this.toBBox), r;
@@ -1517,8 +1519,8 @@ class Wn {
1517
1519
  _chooseSubtree(e, n, o, i) {
1518
1520
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1519
1521
  let s = 1 / 0, a = 1 / 0, r;
1520
- for (let l = 0; l < n.children.length; l++) {
1521
- const f = n.children[l], h = Bt(f), u = Jn(e, f) - h;
1522
+ for (let d = 0; d < n.children.length; d++) {
1523
+ const f = n.children[d], h = Rt(f), u = Jn(e, f) - h;
1522
1524
  u < a ? (a = u, s = h < s ? h : s, r = f) : u === a && h < s && (s = h, r = f);
1523
1525
  }
1524
1526
  n = r || n.children[0];
@@ -1544,7 +1546,7 @@ class Wn {
1544
1546
  _chooseSplitIndex(e, n, o) {
1545
1547
  let i, s = 1 / 0, a = 1 / 0;
1546
1548
  for (let r = n; r <= o - n; r++) {
1547
- const l = st(e, 0, r, this.toBBox), f = st(e, r, o, this.toBBox), h = Zn(l, f), u = Bt(l) + Bt(f);
1549
+ const d = st(e, 0, r, this.toBBox), f = st(e, r, o, this.toBBox), h = Zn(d, f), u = Rt(d) + Rt(f);
1548
1550
  h < s ? (s = h, i = r, a = u < a ? u : a) : h === s && u < a && (a = u, i = r);
1549
1551
  }
1550
1552
  return i || o - n;
@@ -1558,16 +1560,16 @@ class Wn {
1558
1560
  _allDistMargin(e, n, o, i) {
1559
1561
  e.children.sort(i);
1560
1562
  const s = this.toBBox, a = st(e, 0, n, s), r = st(e, o - n, o, s);
1561
- let l = gt(a) + gt(r);
1563
+ let d = pt(a) + pt(r);
1562
1564
  for (let f = n; f < o - n; f++) {
1563
1565
  const h = e.children[f];
1564
- rt(a, e.leaf ? s(h) : h), l += gt(a);
1566
+ rt(a, e.leaf ? s(h) : h), d += pt(a);
1565
1567
  }
1566
1568
  for (let f = o - n - 1; f >= n; f--) {
1567
1569
  const h = e.children[f];
1568
- rt(r, e.leaf ? s(h) : h), l += gt(r);
1570
+ rt(r, e.leaf ? s(h) : h), d += pt(r);
1569
1571
  }
1570
- return l;
1572
+ return d;
1571
1573
  }
1572
1574
  _adjustParentBBoxes(e, n, o) {
1573
1575
  for (let i = o; i >= 0; i--)
@@ -1604,10 +1606,10 @@ function Gn(t, e) {
1604
1606
  function Qn(t, e) {
1605
1607
  return t.minY - e.minY;
1606
1608
  }
1607
- function Bt(t) {
1609
+ function Rt(t) {
1608
1610
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1609
1611
  }
1610
- function gt(t) {
1612
+ function pt(t) {
1611
1613
  return t.maxX - t.minX + (t.maxY - t.minY);
1612
1614
  }
1613
1615
  function Jn(t, e) {
@@ -1617,7 +1619,7 @@ function Zn(t, e) {
1617
1619
  const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), i = Math.min(t.maxX, e.maxX), s = Math.min(t.maxY, e.maxY);
1618
1620
  return Math.max(0, i - n) * Math.max(0, s - o);
1619
1621
  }
1620
- function Rt(t, e) {
1622
+ function kt(t, e) {
1621
1623
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1622
1624
  }
1623
1625
  function mt(t, e) {
@@ -1643,129 +1645,129 @@ function ee(t, e, n, o, i) {
1643
1645
  }
1644
1646
  }
1645
1647
  const to = (t, e) => {
1646
- const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
1647
- const w = d.selector.flatMap((E) => {
1648
+ const n = new Wn(), o = /* @__PURE__ */ new Map(), i = (l, c) => {
1649
+ const b = l.selector.flatMap((E) => {
1648
1650
  const C = F([E]) ? E.range : ae(E, e).range;
1649
1651
  return Array.from(C.getClientRects());
1650
- }), S = Ue(w).map(({ left: E, top: C, right: O, bottom: M }) => new DOMRect(E - c.left, C - c.top, O - E, M - C));
1652
+ }), S = Ue(b).map(({ left: E, top: C, right: O, bottom: B }) => new DOMRect(E - c.left, C - c.top, O - E, B - C));
1651
1653
  return S.map((E) => {
1652
- const { x: C, y: O, width: M, height: T } = E;
1654
+ const { x: C, y: O, width: B, height: T } = E;
1653
1655
  return {
1654
1656
  minX: C,
1655
1657
  minY: O,
1656
- maxX: C + M,
1658
+ maxX: C + B,
1657
1659
  maxY: O + T,
1658
1660
  annotation: {
1659
- id: d.annotation,
1661
+ id: l.annotation,
1660
1662
  rects: S
1661
1663
  }
1662
1664
  };
1663
1665
  });
1664
1666
  }, s = () => [...o.values()], a = () => {
1665
1667
  n.clear(), o.clear();
1666
- }, r = (d) => {
1667
- const c = i(d, e.getBoundingClientRect());
1668
- c.length !== 0 && (c.forEach((w) => n.insert(w)), o.set(d.annotation, c));
1669
- }, l = (d) => {
1670
- const c = o.get(d.annotation);
1671
- c && (c.forEach((w) => n.remove(w)), o.delete(d.annotation));
1672
- }, f = (d) => {
1673
- l(d), r(d);
1674
- }, h = (d, c = !0) => {
1668
+ }, r = (l) => {
1669
+ const c = i(l, e.getBoundingClientRect());
1670
+ c.length !== 0 && (c.forEach((b) => n.insert(b)), o.set(l.annotation, c));
1671
+ }, d = (l) => {
1672
+ const c = o.get(l.annotation);
1673
+ c && (c.forEach((b) => n.remove(b)), o.delete(l.annotation));
1674
+ }, f = (l) => {
1675
+ d(l), r(l);
1676
+ }, h = (l, c = !0) => {
1675
1677
  c && a();
1676
- const w = e.getBoundingClientRect(), S = d.map((C) => ({ target: C, rects: i(C, w) }));
1678
+ const b = e.getBoundingClientRect(), S = l.map((C) => ({ target: C, rects: i(C, b) }));
1677
1679
  S.forEach(({ target: C, rects: O }) => {
1678
1680
  O.length > 0 && o.set(C.annotation, O);
1679
1681
  });
1680
1682
  const E = S.flatMap(({ rects: C }) => C);
1681
1683
  n.load(E);
1682
- }, u = (d, c, w = !1) => {
1684
+ }, u = (l, c, b = !1) => {
1683
1685
  const S = n.search({
1684
- minX: d,
1686
+ minX: l,
1685
1687
  minY: c,
1686
- maxX: d,
1688
+ maxX: l,
1687
1689
  maxY: c
1688
- }), E = (C) => C.annotation.rects.reduce((O, M) => O + M.width * M.height, 0);
1689
- return S.length > 0 ? (S.sort((C, O) => E(C) - E(O)), w ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
1690
- }, p = (d) => {
1691
- const c = g(d);
1690
+ }), E = (C) => C.annotation.rects.reduce((O, B) => O + B.width * B.height, 0);
1691
+ return S.length > 0 ? (S.sort((C, O) => E(C) - E(O)), b ? S.map((C) => C.annotation.id) : [S[0].annotation.id]) : [];
1692
+ }, g = (l) => {
1693
+ const c = v(l);
1692
1694
  if (c.length === 0)
1693
1695
  return;
1694
- let w = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
1696
+ let b = c[0].left, S = c[0].top, E = c[0].right, C = c[0].bottom;
1695
1697
  for (let O = 1; O < c.length; O++) {
1696
- const M = c[O];
1697
- w = Math.min(w, M.left), S = Math.min(S, M.top), E = Math.max(E, M.right), C = Math.max(C, M.bottom);
1698
+ const B = c[O];
1699
+ b = Math.min(b, B.left), S = Math.min(S, B.top), E = Math.max(E, B.right), C = Math.max(C, B.bottom);
1698
1700
  }
1699
- return new DOMRect(w, S, E - w, C - S);
1700
- }, g = (d) => {
1701
- const c = o.get(d);
1701
+ return new DOMRect(b, S, E - b, C - S);
1702
+ }, v = (l) => {
1703
+ const c = o.get(l);
1702
1704
  return c ? c[0].annotation.rects : [];
1703
1705
  };
1704
1706
  return {
1705
1707
  all: s,
1706
1708
  clear: a,
1707
1709
  getAt: u,
1708
- getAnnotationBounds: p,
1709
- getAnnotationRects: g,
1710
- getIntersecting: (d, c, w, S) => {
1711
- const E = n.search({ minX: d, minY: c, maxX: w, maxY: S }), C = new Set(E.map((O) => O.annotation.id));
1710
+ getAnnotationBounds: g,
1711
+ getAnnotationRects: v,
1712
+ getIntersecting: (l, c, b, S) => {
1713
+ const E = n.search({ minX: l, minY: c, maxX: b, maxY: S }), C = new Set(E.map((O) => O.annotation.id));
1712
1714
  return Array.from(C).map((O) => ({
1713
1715
  annotation: t.getAnnotation(O),
1714
- rects: g(O)
1716
+ rects: v(O)
1715
1717
  })).filter((O) => !!O.annotation);
1716
1718
  },
1717
1719
  insert: r,
1718
- recalculate: () => h(t.all().map((d) => d.target), !0),
1719
- remove: l,
1720
+ recalculate: () => h(t.all().map((l) => l.target), !0),
1721
+ remove: d,
1720
1722
  set: h,
1721
1723
  size: () => n.all().length,
1722
1724
  update: f
1723
1725
  };
1724
1726
  }, eo = (t, e) => {
1725
- const n = Ln(), o = to(n, t), i = pn(n);
1727
+ const n = Ln(), o = to(n, t), i = gn(n);
1726
1728
  i.setUserSelectAction(e);
1727
- const s = fn(n), a = Bn(), r = (d, c = k.LOCAL) => {
1728
- const w = xt(d, t), S = F(w.target.selector);
1729
- return S && n.addAnnotation(w, c), S;
1730
- }, l = (d, c = !0, w = k.LOCAL) => {
1731
- const S = d.map((C) => xt(C, t)), E = S.filter((C) => !F(C.target.selector));
1732
- return n.bulkAddAnnotation(S, c, w), E;
1733
- }, f = (d, c = k.LOCAL) => {
1734
- const w = d.map((E) => xt(E, t)), S = w.filter((E) => !F(E.target.selector));
1735
- return w.forEach((E) => {
1729
+ const s = fn(n), a = Mn(), r = (l, c = k.LOCAL) => {
1730
+ const b = vt(l, t), S = F(b.target.selector);
1731
+ return S && n.addAnnotation(b, c), S;
1732
+ }, d = (l, c = !0, b = k.LOCAL) => {
1733
+ const S = l.map((C) => vt(C, t)), E = S.filter((C) => !F(C.target.selector));
1734
+ return n.bulkAddAnnotation(S, c, b), E;
1735
+ }, f = (l, c = k.LOCAL) => {
1736
+ const b = l.map((E) => vt(E, t)), S = b.filter((E) => !F(E.target.selector));
1737
+ return b.forEach((E) => {
1736
1738
  n.getAnnotation(E.id) ? n.updateAnnotation(E, c) : n.addAnnotation(E, c);
1737
1739
  }), S;
1738
- }, h = (d, c = k.LOCAL) => {
1739
- const w = bt(d, t);
1740
- n.updateTarget(w, c);
1741
- }, u = (d, c = k.LOCAL) => {
1742
- const w = d.map((S) => bt(S, t));
1743
- n.bulkUpdateTargets(w, c);
1740
+ }, h = (l, c = k.LOCAL) => {
1741
+ const b = wt(l, t);
1742
+ n.updateTarget(b, c);
1743
+ }, u = (l, c = k.LOCAL) => {
1744
+ const b = l.map((S) => wt(S, t));
1745
+ n.bulkUpdateTargets(b, c);
1744
1746
  };
1745
- function p(d, c, w, S) {
1746
- const E = w || !!S, C = o.getAt(d, c, E).map((M) => n.getAnnotation(M)), O = S ? C.filter(S) : C;
1747
+ function g(l, c, b, S) {
1748
+ const E = b || !!S, C = o.getAt(l, c, E).map((B) => n.getAnnotation(B)), O = S ? C.filter(S) : C;
1747
1749
  if (O.length !== 0)
1748
- return w ? O : O[0];
1750
+ return b ? O : O[0];
1749
1751
  }
1750
- const g = (d) => {
1751
- if (o.getAnnotationRects(d).length !== 0)
1752
- return o.getAnnotationBounds(d);
1753
- }, y = (d, c, w, S) => o.getIntersecting(d, c, w, S), b = (d) => o.getAnnotationRects(d), v = () => o.recalculate();
1754
- return n.observe(({ changes: d }) => {
1755
- const c = (d.deleted || []).filter((E) => F(E.target.selector)), w = (d.created || []).filter((E) => F(E.target.selector)), S = (d.updated || []).filter((E) => F(E.newValue.target.selector));
1756
- (c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), w.length > 0 && o.set(w.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
1752
+ const v = (l) => {
1753
+ if (o.getAnnotationRects(l).length !== 0)
1754
+ return o.getAnnotationBounds(l);
1755
+ }, p = (l, c, b, S) => o.getIntersecting(l, c, b, S), y = (l) => o.getAnnotationRects(l), x = () => o.recalculate();
1756
+ return n.observe(({ changes: l }) => {
1757
+ const c = (l.deleted || []).filter((E) => F(E.target.selector)), b = (l.created || []).filter((E) => F(E.target.selector)), S = (l.updated || []).filter((E) => F(E.newValue.target.selector));
1758
+ (c == null ? void 0 : c.length) > 0 && c.forEach((E) => o.remove(E.target)), b.length > 0 && o.set(b.map((E) => E.target), !1), (S == null ? void 0 : S.length) > 0 && S.forEach(({ newValue: E }) => o.update(E.target));
1757
1759
  }), {
1758
1760
  store: {
1759
1761
  ...n,
1760
1762
  addAnnotation: r,
1761
- bulkAddAnnotation: l,
1763
+ bulkAddAnnotation: d,
1762
1764
  bulkUpdateTargets: u,
1763
1765
  bulkUpsertAnnotations: f,
1764
- getAnnotationBounds: g,
1765
- getAnnotationRects: b,
1766
- getIntersecting: y,
1767
- getAt: p,
1768
- recalculatePositions: v,
1766
+ getAnnotationBounds: v,
1767
+ getAnnotationRects: y,
1768
+ getIntersecting: p,
1769
+ getAt: g,
1770
+ recalculatePositions: x,
1769
1771
  updateTarget: h
1770
1772
  },
1771
1773
  selection: i,
@@ -1780,9 +1782,9 @@ const to = (t, e) => {
1780
1782
  }, oo = (t, e = {}) => {
1781
1783
  const n = no(), o = n.getContext("2d");
1782
1784
  document.body.appendChild(n);
1783
- const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u, p]) => p.presenceKey === h.presenceKey).map(([u, p]) => u);
1785
+ const i = /* @__PURE__ */ new Map(), s = (h) => Array.from(i.entries()).filter(([u, g]) => g.presenceKey === h.presenceKey).map(([u, g]) => u);
1784
1786
  return t.on("selectionChange", (h, u) => {
1785
- s(h).forEach((g) => i.delete(g)), u && u.forEach((g) => i.set(g, h));
1787
+ s(h).forEach((v) => i.delete(v)), u && u.forEach((v) => i.set(v, h));
1786
1788
  }), {
1787
1789
  clear: () => {
1788
1790
  const { width: h, height: u } = n;
@@ -1791,16 +1793,16 @@ const to = (t, e) => {
1791
1793
  destroy: () => {
1792
1794
  n.remove();
1793
1795
  },
1794
- paint: (h, u, p) => {
1796
+ paint: (h, u, g) => {
1795
1797
  e.font && (o.font = e.font);
1796
- const g = i.get(h.annotation.id);
1797
- if (g) {
1798
- const { height: y } = h.rects[0], b = h.rects[0].x + u.left, v = h.rects[0].y + u.top;
1799
- o.fillStyle = g.appearance.color, o.fillRect(b - 2, v - 2.5, 2, y + 5);
1800
- const d = o.measureText(g.appearance.label), c = d.width + 6, w = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, S = d.fontBoundingBoxAscent ? 8 : 6.5;
1801
- return o.fillRect(b - 2, v - 2.5 - w, c, w), o.fillStyle = "#fff", o.fillText(g.appearance.label, b + 1, v - S), {
1802
- fill: g.appearance.color,
1803
- fillOpacity: p ? 0.45 : 0.18
1798
+ const v = i.get(h.annotation.id);
1799
+ if (v) {
1800
+ const { height: p } = h.rects[0], y = h.rects[0].x + u.left, x = h.rects[0].y + u.top;
1801
+ o.fillStyle = v.appearance.color, o.fillRect(y - 2, x - 2.5, 2, p + 5);
1802
+ const l = o.measureText(v.appearance.label), c = l.width + 6, b = l.actualBoundingBoxAscent + l.actualBoundingBoxDescent + 8, S = l.fontBoundingBoxAscent ? 8 : 6.5;
1803
+ return o.fillRect(y - 2, x - 2.5 - b, c, b), o.fillStyle = "#fff", o.fillText(v.appearance.label, y + 1, x - S), {
1804
+ fill: v.appearance.color,
1805
+ fillOpacity: g ? 0.45 : 0.18
1804
1806
  };
1805
1807
  }
1806
1808
  },
@@ -1810,8 +1812,8 @@ const to = (t, e) => {
1810
1812
  h.scale(2, 2), h.translate(0.5, 0.5);
1811
1813
  }
1812
1814
  };
1813
- }, kt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1814
- function It(t, e, n, o) {
1815
+ }, It = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1816
+ function _t(t, e, n, o) {
1815
1817
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1816
1818
  }
1817
1819
  function ot(t, e, n, o) {
@@ -1882,9 +1884,9 @@ const lt = {
1882
1884
  ".": 190,
1883
1885
  "/": 191,
1884
1886
  "`": 192,
1885
- "-": kt ? 173 : 189,
1886
- "=": kt ? 61 : 187,
1887
- ";": kt ? 59 : 186,
1887
+ "-": It ? 173 : 189,
1888
+ "=": It ? 61 : 187,
1889
+ ";": It ? 59 : 186,
1888
1890
  "'": 222,
1889
1891
  "[": 219,
1890
1892
  "]": 221,
@@ -1905,7 +1907,7 @@ const lt = {
1905
1907
  "⌘": 91,
1906
1908
  cmd: 91,
1907
1909
  command: 91
1908
- }, Vt = {
1910
+ }, bt = {
1909
1911
  16: "shiftKey",
1910
1912
  18: "altKey",
1911
1913
  17: "ctrlKey",
@@ -1914,7 +1916,7 @@ const lt = {
1914
1916
  ctrlKey: 17,
1915
1917
  altKey: 18,
1916
1918
  metaKey: 91
1917
- }, D = {
1919
+ }, K = {
1918
1920
  16: !1,
1919
1921
  18: !1,
1920
1922
  17: !1,
@@ -1980,11 +1982,11 @@ function ho(t, e) {
1980
1982
  }) : o++;
1981
1983
  dt() === t && Ae(e || "all");
1982
1984
  }
1983
- function po(t) {
1985
+ function go(t) {
1984
1986
  let e = t.keyCode || t.which || t.charCode;
1985
1987
  const n = I.indexOf(e);
1986
- if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in D) {
1987
- D[e] = !1;
1988
+ if (n >= 0 && I.splice(n, 1), t.key && t.key.toLowerCase() === "meta" && I.splice(0, I.length), (e === 93 || e === 224) && (e = 91), e in K) {
1989
+ K[e] = !1;
1988
1990
  for (const o in H) H[o] === e && (P[o] = !1);
1989
1991
  }
1990
1992
  }
@@ -2019,14 +2021,14 @@ const yt = (t) => {
2019
2021
  splitKey: i = "+"
2020
2022
  } = t;
2021
2023
  be(e).forEach((a) => {
2022
- const r = a.split(i), l = r.length, f = r[l - 1], h = f === "*" ? "*" : ut(f);
2024
+ const r = a.split(i), d = r.length, f = r[d - 1], h = f === "*" ? "*" : ut(f);
2023
2025
  if (!_[h]) return;
2024
2026
  n || (n = dt());
2025
- const u = l > 1 ? ye(H, r) : [], p = [];
2026
- _[h] = _[h].filter((g) => {
2027
- const b = (o ? g.method === o : !0) && g.scope === n && io(g.mods, u);
2028
- return b && p.push(g.element), !b;
2029
- }), p.forEach((g) => Xt(g));
2027
+ const u = d > 1 ? ye(H, r) : [], g = [];
2028
+ _[h] = _[h].filter((v) => {
2029
+ const y = (o ? v.method === o : !0) && v.scope === n && io(v.mods, u);
2030
+ return y && g.push(v.element), !y;
2031
+ }), g.forEach((v) => Xt(v));
2030
2032
  });
2031
2033
  };
2032
2034
  function ne(t, e, n, o) {
@@ -2035,27 +2037,27 @@ function ne(t, e, n, o) {
2035
2037
  let i;
2036
2038
  if (e.scope === n || e.scope === "all") {
2037
2039
  i = e.mods.length > 0;
2038
- for (const s in D)
2039
- Object.prototype.hasOwnProperty.call(D, s) && (!D[s] && e.mods.indexOf(+s) > -1 || D[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2040
- (e.mods.length === 0 && !D[16] && !D[18] && !D[17] && !D[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2040
+ for (const s in K)
2041
+ Object.prototype.hasOwnProperty.call(K, s) && (!K[s] && e.mods.indexOf(+s) > -1 || K[s] && e.mods.indexOf(+s) === -1) && (i = !1);
2042
+ (e.mods.length === 0 && !K[16] && !K[18] && !K[17] && !K[91] || i || e.shortcut === "*") && (e.keys = [], e.keys = e.keys.concat(I), e.method(t, e) === !1 && (t.preventDefault ? t.preventDefault() : t.returnValue = !1, t.stopPropagation && t.stopPropagation(), t.cancelBubble && (t.cancelBubble = !0)));
2041
2043
  }
2042
2044
  }
2043
2045
  function oe(t, e) {
2044
2046
  const n = _["*"];
2045
2047
  let o = t.keyCode || t.which || t.charCode;
2046
2048
  if (!P.filter.call(this, t)) return;
2047
- if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((r) => {
2048
- const l = Vt[r];
2049
- t[r] && I.indexOf(l) === -1 ? I.push(l) : !t[r] && I.indexOf(l) > -1 ? I.splice(I.indexOf(l), 1) : r === "metaKey" && t[r] && I.length === 3 && (t.ctrlKey || t.shiftKey || t.altKey || (I = I.slice(I.indexOf(l))));
2050
- }), o in D) {
2051
- D[o] = !0;
2049
+ if ((o === 93 || o === 224) && (o = 91), I.indexOf(o) === -1 && o !== 229 && I.push(o), ["metaKey", "ctrlKey", "altKey", "shiftKey"].forEach((r) => {
2050
+ const d = bt[r];
2051
+ t[r] && I.indexOf(d) === -1 ? I.push(d) : !t[r] && I.indexOf(d) > -1 ? I.splice(I.indexOf(d), 1) : r === "metaKey" && t[r] && (I = I.filter((f) => f in bt || f === o));
2052
+ }), o in K) {
2053
+ K[o] = !0;
2052
2054
  for (const r in H)
2053
2055
  H[r] === o && (P[r] = !0);
2054
2056
  if (!n) return;
2055
2057
  }
2056
- for (const r in D)
2057
- Object.prototype.hasOwnProperty.call(D, r) && (D[r] = t[Vt[r]]);
2058
- t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), D[17] = !0, D[18] = !0);
2058
+ for (const r in K)
2059
+ Object.prototype.hasOwnProperty.call(K, r) && (K[r] = t[bt[r]]);
2060
+ t.getModifierState && !(t.altKey && !t.ctrlKey) && t.getModifierState("AltGraph") && (I.indexOf(17) === -1 && I.push(17), I.indexOf(18) === -1 && I.push(18), K[17] = !0, K[18] = !0);
2059
2061
  const i = dt();
2060
2062
  if (n)
2061
2063
  for (let r = 0; r < n.length; r++)
@@ -2064,21 +2066,21 @@ function oe(t, e) {
2064
2066
  const s = _[o], a = s.length;
2065
2067
  for (let r = 0; r < a; r++)
2066
2068
  if ((t.type === "keydown" && s[r].keydown || t.type === "keyup" && s[r].keyup) && s[r].key) {
2067
- const l = s[r], {
2069
+ const d = s[r], {
2068
2070
  splitKey: f
2069
- } = l, h = l.key.split(f), u = [];
2070
- for (let p = 0; p < h.length; p++)
2071
- u.push(ut(h[p]));
2072
- u.sort().join("") === I.sort().join("") && ne(t, l, i, e);
2071
+ } = d, h = d.key.split(f), u = [];
2072
+ for (let g = 0; g < h.length; g++)
2073
+ u.push(ut(h[g]));
2074
+ u.sort().join("") === I.sort().join("") && ne(t, d, i, e);
2073
2075
  }
2074
2076
  }
2075
2077
  function P(t, e, n) {
2076
2078
  I = [];
2077
2079
  const o = be(t);
2078
- let i = [], s = "all", a = document, r = 0, l = !1, f = !0, h = "+", u = !1, p = !1;
2079
- for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (l = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (p = !0)), typeof e == "string" && (s = e), p && xe(t, s); r < o.length; r++)
2080
+ let i = [], s = "all", a = document, r = 0, d = !1, f = !0, h = "+", u = !1, g = !1;
2081
+ for (n === void 0 && typeof e == "function" && (n = e), Object.prototype.toString.call(e) === "[object Object]" && (e.scope && (s = e.scope), e.element && (a = e.element), e.keyup && (d = e.keyup), e.keydown !== void 0 && (f = e.keydown), e.capture !== void 0 && (u = e.capture), typeof e.splitKey == "string" && (h = e.splitKey), e.single === !0 && (g = !0)), typeof e == "string" && (s = e), g && xe(t, s); r < o.length; r++)
2080
2082
  t = o[r].split(h), i = [], t.length > 1 && (i = ye(H, t)), t = t[t.length - 1], t = t === "*" ? "*" : ut(t), t in _ || (_[t] = []), _[t].push({
2081
- keyup: l,
2083
+ keyup: d,
2082
2084
  keydown: f,
2083
2085
  scope: s,
2084
2086
  mods: i,
@@ -2090,31 +2092,31 @@ function P(t, e, n) {
2090
2092
  });
2091
2093
  if (typeof a < "u" && window) {
2092
2094
  if (!z.has(a)) {
2093
- const g = function() {
2094
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2095
- return oe(b, a);
2096
- }, y = function() {
2097
- let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2098
- oe(b, a), po(b);
2095
+ const v = function() {
2096
+ let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2097
+ return oe(y, a);
2098
+ }, p = function() {
2099
+ let y = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2100
+ oe(y, a), go(y);
2099
2101
  };
2100
2102
  z.set(a, {
2101
- keydownListener: g,
2102
- keyupListenr: y,
2103
+ keydownListener: v,
2104
+ keyupListenr: p,
2103
2105
  capture: u
2104
- }), It(a, "keydown", g, u), It(a, "keyup", y, u);
2106
+ }), _t(a, "keydown", v, u), _t(a, "keyup", p, u);
2105
2107
  }
2106
2108
  if (!ct) {
2107
- const g = () => {
2109
+ const v = () => {
2108
2110
  I = [];
2109
2111
  };
2110
2112
  ct = {
2111
- listener: g,
2113
+ listener: v,
2112
2114
  capture: u
2113
- }, It(window, "focus", g, u);
2115
+ }, _t(window, "focus", v, u);
2114
2116
  }
2115
2117
  }
2116
2118
  }
2117
- function go(t) {
2119
+ function po(t) {
2118
2120
  let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "all";
2119
2121
  Object.keys(_).forEach((n) => {
2120
2122
  _[n].filter((i) => i.scope === e && i.shortcut === t).forEach((i) => {
@@ -2152,7 +2154,7 @@ function Xt(t) {
2152
2154
  ot(window, "focus", i, s), ct = null;
2153
2155
  }
2154
2156
  }
2155
- const _t = {
2157
+ const Nt = {
2156
2158
  getPressedKeyString: co,
2157
2159
  setScope: Ae,
2158
2160
  getScope: dt,
@@ -2161,14 +2163,14 @@ const _t = {
2161
2163
  getAllKeyCodes: lo,
2162
2164
  isPressed: fo,
2163
2165
  filter: uo,
2164
- trigger: go,
2166
+ trigger: po,
2165
2167
  unbind: xe,
2166
2168
  keyMap: lt,
2167
2169
  modifier: H,
2168
- modifierMap: Vt
2170
+ modifierMap: bt
2169
2171
  };
2170
- for (const t in _t)
2171
- Object.prototype.hasOwnProperty.call(_t, t) && (P[t] = _t[t]);
2172
+ for (const t in Nt)
2173
+ Object.prototype.hasOwnProperty.call(Nt, t) && (P[t] = Nt[t]);
2172
2174
  if (typeof window < "u") {
2173
2175
  const t = window.hotkeys;
2174
2176
  P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
@@ -2179,97 +2181,97 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2179
2181
  ], yo = (t, e, n) => {
2180
2182
  let o;
2181
2183
  const { annotatingEnabled: i, offsetReferenceSelector: s, selectionMode: a } = n, r = (T) => o = T;
2182
- let l;
2183
- const f = (T) => l = T, { store: h, selection: u } = e;
2184
- let p, g, y;
2185
- const b = (T) => {
2186
- g !== !1 && (p = it(T.target) ? void 0 : {
2184
+ let d;
2185
+ const f = (T) => d = T, { store: h, selection: u } = e;
2186
+ let g, v, p;
2187
+ const y = (T) => {
2188
+ v !== !1 && (g = it(T.target) ? void 0 : {
2187
2189
  annotation: fe(),
2188
2190
  selector: [],
2189
2191
  creator: o,
2190
2192
  created: /* @__PURE__ */ new Date()
2191
2193
  });
2192
- }, v = Yt((T) => {
2194
+ }, x = Yt((T) => {
2193
2195
  const m = document.getSelection();
2194
2196
  if (!(m != null && m.anchorNode))
2195
2197
  return;
2196
2198
  if (it(m.anchorNode)) {
2197
- p = void 0;
2199
+ g = void 0;
2198
2200
  return;
2199
2201
  }
2200
- const x = T.timeStamp - ((y == null ? void 0 : y.timeStamp) || T.timeStamp);
2201
- if ((y == null ? void 0 : y.type) === "pointerdown" && (x < 1e3 && !p || m.isCollapsed && x < ie) && b(y || T), !p) return;
2202
+ const A = T.timeStamp - ((p == null ? void 0 : p.timeStamp) || T.timeStamp);
2203
+ if ((p == null ? void 0 : p.type) === "pointerdown" && (A < 1e3 && !g || m.isCollapsed && A < ie) && y(p || T), !g) return;
2202
2204
  if (m.isCollapsed) {
2203
- h.getAnnotation(p.annotation) && (u.clear(), h.deleteAnnotation(p.annotation));
2205
+ h.getAnnotation(g.annotation) && (u.clear(), h.deleteAnnotation(g.annotation));
2204
2206
  return;
2205
2207
  }
2206
- const A = m.getRangeAt(0), L = Ye(A, t);
2208
+ const w = m.getRangeAt(0), L = Ye(w, t);
2207
2209
  if (Ie(L)) return;
2208
- const B = Be(L.cloneRange());
2209
- (B.length !== p.selector.length || B.some((N, U) => {
2210
+ const M = Me(L.cloneRange());
2211
+ (M.length !== g.selector.length || M.some((N, U) => {
2210
2212
  var et;
2211
- return N.toString() !== ((et = p.selector[U]) == null ? void 0 : et.quote);
2212
- })) && (p = {
2213
- ...p,
2214
- selector: B.map((N) => Ve(N, t, s)),
2213
+ return N.toString() !== ((et = g.selector[U]) == null ? void 0 : et.quote);
2214
+ })) && (g = {
2215
+ ...g,
2216
+ selector: M.map((N) => Ve(N, t, s)),
2215
2217
  updated: /* @__PURE__ */ new Date()
2216
- }, h.getAnnotation(p.annotation) ? h.updateTarget(p, k.LOCAL) : u.clear());
2217
- }), d = (T) => {
2218
- it(T.target) || (y = At(T), g = y.button === 0);
2218
+ }, h.getAnnotation(g.annotation) ? h.updateTarget(g, k.LOCAL) : u.clear());
2219
+ }), l = (T) => {
2220
+ it(T.target) || (p = xt(T), v = p.button === 0);
2219
2221
  }, c = (T) => {
2220
- if (it(T.target) || !g) return;
2222
+ if (it(T.target) || !v) return;
2221
2223
  const m = () => {
2222
- const { x: A, y: L } = t.getBoundingClientRect(), B = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - A, T.clientY - L, a === "all", l);
2223
- if (B) {
2224
- const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(B) ? B.map((q) => q.id) : [B.id];
2224
+ const { x: w, y: L } = t.getBoundingClientRect(), M = T.target instanceof Node && t.contains(T.target) && h.getAt(T.clientX - w, T.clientY - L, a === "all", d);
2225
+ if (M) {
2226
+ const { selected: R } = u, N = new Set(R.map((q) => q.id)), U = Array.isArray(M) ? M.map((q) => q.id) : [M.id];
2225
2227
  (N.size !== U.length || !U.every((q) => N.has(q))) && u.userSelect(U, T);
2226
2228
  } else
2227
2229
  u.clear();
2228
- }, x = T.timeStamp - y.timeStamp;
2230
+ }, A = T.timeStamp - p.timeStamp;
2229
2231
  setTimeout(() => {
2230
- const A = document.getSelection();
2231
- A != null && A.isCollapsed && x < ie ? (p = void 0, m()) : p && p.selector.length > 0 && (O(), u.userSelect(p.annotation, At(T)));
2232
+ const w = document.getSelection();
2233
+ w != null && w.isCollapsed && A < ie ? (g = void 0, m()) : g && g.selector.length > 0 && (O(), u.userSelect(g.annotation, xt(T)));
2232
2234
  });
2233
- }, w = (T) => {
2235
+ }, b = (T) => {
2234
2236
  const m = document.getSelection();
2235
- m != null && m.isCollapsed || ((!p || p.selector.length === 0) && v(T), O(), u.userSelect(p.annotation, At(T)));
2237
+ m != null && m.isCollapsed || ((!g || g.selector.length === 0) && x(T), O(), u.userSelect(g.annotation, xt(T)));
2236
2238
  }, S = (T) => {
2237
- T.key === "Shift" && p && (document.getSelection().isCollapsed || (O(), u.userSelect(p.annotation, ft(T))));
2239
+ T.key === "Shift" && g && (document.getSelection().isCollapsed || (O(), u.userSelect(g.annotation, ft(T))));
2238
2240
  }, E = (T) => {
2239
2241
  const m = () => setTimeout(() => {
2240
- (p == null ? void 0 : p.selector.length) > 0 && (u.clear(), h.addAnnotation({
2241
- id: p.annotation,
2242
+ (g == null ? void 0 : g.selector.length) > 0 && (u.clear(), h.addAnnotation({
2243
+ id: g.annotation,
2242
2244
  bodies: [],
2243
- target: p
2244
- }), u.userSelect(p.annotation, ft(T))), document.removeEventListener("selectionchange", m);
2245
+ target: g
2246
+ }), u.userSelect(g.annotation, ft(T))), document.removeEventListener("selectionchange", m);
2245
2247
  }, 100);
2246
- document.addEventListener("selectionchange", m), b(T);
2248
+ document.addEventListener("selectionchange", m), y(T);
2247
2249
  };
2248
2250
  P(mo.join(","), { element: t, keydown: !0, keyup: !1 }, (T) => {
2249
- T.repeat || (y = ft(T));
2251
+ T.repeat || (p = ft(T));
2250
2252
  }), P(Ee, { keydown: !0, keyup: !1 }, (T) => {
2251
- y = ft(T), E(T);
2253
+ p = ft(T), E(T);
2252
2254
  });
2253
2255
  const C = (T) => {
2254
- T.repeat || T.target !== t && T.target !== document.body || (p = void 0, u.clear());
2256
+ T.repeat || T.target !== t && T.target !== document.body || (g = void 0, u.clear());
2255
2257
  };
2256
2258
  P(ve.join(","), { keydown: !0, keyup: !1 }, C);
2257
2259
  const O = () => {
2258
- const T = h.getAnnotation(p.annotation);
2260
+ const T = h.getAnnotation(g.annotation);
2259
2261
  if (!T) {
2260
2262
  h.addAnnotation({
2261
- id: p.annotation,
2263
+ id: g.annotation,
2262
2264
  bodies: [],
2263
- target: p
2265
+ target: g
2264
2266
  });
2265
2267
  return;
2266
2268
  }
2267
- const { target: { updated: m } } = T, { updated: x } = p;
2268
- (!m || !x || m < x) && h.updateTarget(p);
2269
+ const { target: { updated: m } } = T, { updated: A } = g;
2270
+ (!m || !A || m < A) && h.updateTarget(g);
2269
2271
  };
2270
- return t.addEventListener("pointerdown", d), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", w), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", b), document.addEventListener("selectionchange", v)), {
2272
+ return t.addEventListener("pointerdown", l), document.addEventListener("pointerup", c), document.addEventListener("contextmenu", b), i && (t.addEventListener("keyup", S), t.addEventListener("selectstart", y), document.addEventListener("selectionchange", x)), {
2271
2273
  destroy: () => {
2272
- t.removeEventListener("pointerdown", d), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", w), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", b), document.removeEventListener("selectionchange", v), P.unbind();
2274
+ t.removeEventListener("pointerdown", l), document.removeEventListener("pointerup", c), document.removeEventListener("contextmenu", b), t.removeEventListener("keyup", S), t.removeEventListener("selectstart", y), document.removeEventListener("selectionchange", x), P.unbind();
2273
2275
  },
2274
2276
  setFilter: f,
2275
2277
  setUser: r
@@ -2282,27 +2284,27 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2282
2284
  Le(t), Oe(t);
2283
2285
  const n = bo(e, {
2284
2286
  annotatingEnabled: !0,
2285
- user: Kn()
2286
- }), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Mn(a), l = Rn(o, r, n.adapter);
2287
+ user: Dn()
2288
+ }), o = eo(t, n.userSelectAction), { selection: i, viewport: s } = o, a = o.store, r = Bn(a), d = Rn(o, r, n.adapter);
2287
2289
  let f = n.user;
2288
2290
  const h = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : se : n.renderer || se, u = h === "SPANS" ? rn(t, o, s) : h === "CSS_HIGHLIGHTS" ? nn(t, o, s) : h === "CANVAS" ? ze(t, o, s) : void 0;
2289
2291
  if (!u)
2290
2292
  throw `Unknown renderer implementation: ${h}`;
2291
2293
  console.debug(`Using ${h} renderer`), n.style && u.setStyle(n.style);
2292
- const p = yo(t, o, n);
2293
- return p.setUser(f), {
2294
+ const g = yo(t, o, n);
2295
+ return g.setUser(f), {
2294
2296
  ...In(o, r, n.adapter),
2295
2297
  destroy: () => {
2296
- u.destroy(), p.destroy(), r.destroy();
2298
+ u.destroy(), g.destroy(), r.destroy();
2297
2299
  },
2298
2300
  element: t,
2299
2301
  getUser: () => f,
2300
2302
  setFilter: (C) => {
2301
- u.setFilter(C), p.setFilter(C);
2303
+ u.setFilter(C), g.setFilter(C);
2302
2304
  },
2303
2305
  setStyle: (C) => u.setStyle(C),
2304
2306
  setUser: (C) => {
2305
- f = C, p.setUser(C);
2307
+ f = C, g.setUser(C);
2306
2308
  },
2307
2309
  setSelected: (C) => {
2308
2310
  C ? i.setSelected(C) : i.clear();
@@ -2311,14 +2313,14 @@ const ie = 300, ve = ["up", "down", "left", "right"], Ee = Te ? "⌘+a" : "ctrl+
2311
2313
  C && (u.setPainter(oo(C, n.presence)), C.on("selectionChange", () => u.redraw()));
2312
2314
  },
2313
2315
  setVisible: (C) => u.setVisible(C),
2314
- on: l.on,
2315
- off: l.off,
2316
- scrollIntoView: Ke(t, a),
2316
+ on: d.on,
2317
+ off: d.off,
2318
+ scrollIntoView: De(t, a),
2317
2319
  state: o
2318
2320
  };
2319
2321
  };
2320
2322
  export {
2321
- wt as DEFAULT_SELECTED_STYLE,
2323
+ At as DEFAULT_SELECTED_STYLE,
2322
2324
  W as DEFAULT_STYLE,
2323
2325
  re as NOT_ANNOTATABLE_CLASS,
2324
2326
  tt as NOT_ANNOTATABLE_SELECTOR,
@@ -2328,7 +2330,7 @@ export {
2328
2330
  xo as W3CTextFormat,
2329
2331
  Le as cancelSingleClickEvents,
2330
2332
  ft as cloneKeyboardEvent,
2331
- At as clonePointerEvent,
2333
+ xt as clonePointerEvent,
2332
2334
  Ao as createBody,
2333
2335
  ze as createCanvasRenderer,
2334
2336
  nn as createHighlightsRenderer,
@@ -2340,23 +2342,23 @@ export {
2340
2342
  Yt as debounce,
2341
2343
  bo as fillDefaults,
2342
2344
  Re as getQuoteContext,
2343
- Nt as getRangeAnnotatableContents,
2345
+ Ut as getRangeAnnotatableContents,
2344
2346
  Te as isMac,
2345
2347
  it as isNotAnnotatable,
2346
2348
  Ce as isRangeAnnotatable,
2347
2349
  F as isRevived,
2348
2350
  Ie as isWhitespaceOrEmpty,
2349
2351
  Ue as mergeClientRects,
2350
- De as paint,
2352
+ Ke as paint,
2351
2353
  jn as parseW3CTextAnnotation,
2352
2354
  Oe as programmaticallyFocusable,
2353
2355
  Ve as rangeToSelector,
2354
- xt as reviveAnnotation,
2356
+ vt as reviveAnnotation,
2355
2357
  ae as reviveSelector,
2356
- bt as reviveTarget,
2357
- Ke as scrollIntoView,
2358
+ wt as reviveTarget,
2359
+ De as scrollIntoView,
2358
2360
  zn as serializeW3CTextAnnotation,
2359
- Be as splitAnnotatableRanges,
2361
+ Me as splitAnnotatableRanges,
2360
2362
  wo as toDomRectList,
2361
2363
  Ye as trimRangeToContainer,
2362
2364
  ke as whitespaceOrEmptyRegex