@soomo/text-annotator 3.0.0-staging.44 → 3.0.0-staging.46

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