@soomo/text-annotator 3.0.0-staging.48 → 3.0.0-staging.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
1
  const q = {
2
2
  fill: "rgb(0, 128, 255)",
3
3
  fillOpacity: 0.18
4
- }, gt = {
4
+ }, mt = {
5
5
  fill: "rgb(0, 128, 255)",
6
6
  fillOpacity: 0.45
7
7
  }, Ae = (t, e, n, o, i) => {
8
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;
9
+ const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((a = t.state) != null && a.selected ? mt : q) : n : (s = t.state) != null && s.selected ? mt : q;
10
10
  return o && o.paint(t, e) || r;
11
11
  };
12
12
  function Ee(t) {
13
13
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
14
14
  }
15
- var Nt = { exports: {} };
16
- function oe(t, e = 100, n = {}) {
15
+ var It = { exports: {} };
16
+ function ie(t, e = 100, n = {}) {
17
17
  if (typeof t != "function")
18
18
  throw new TypeError(`Expected the first parameter to be a function, got \`${typeof t}\`.`);
19
19
  if (e < 0)
@@ -43,10 +43,10 @@ function oe(t, e = 100, n = {}) {
43
43
  l = f(), c.clear();
44
44
  }, c;
45
45
  }
46
- Nt.exports.debounce = oe;
47
- Nt.exports = oe;
48
- var Se = Nt.exports;
49
- const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
46
+ It.exports.debounce = ie;
47
+ It.exports = ie;
48
+ var Se = It.exports;
49
+ const _t = /* @__PURE__ */ Ee(Se), Ce = (t) => {
50
50
  const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, a = -e, s = o - n, l = i - e;
51
51
  return { top: e, left: n, minX: r, minY: a, maxX: s, maxY: l };
52
52
  }, Le = (t) => {
@@ -55,43 +55,43 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
55
55
  const i = o.map((r) => r.id);
56
56
  (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
57
57
  };
58
- }, _t = (t, e, n, o) => {
58
+ }, Ut = (t, e, n, o) => {
59
59
  const { store: i, selection: r, hover: a } = e;
60
60
  let s, l, f;
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));
61
+ const g = Le(n), c = (O) => {
62
+ const { x: B, y: m } = t.getBoundingClientRect(), w = i.getAt(O.clientX - B, O.clientY - m, l);
63
+ w ? a.current !== w.id && (t.classList.add("hovered"), a.set(w.id)) : a.current && (t.classList.remove("hovered"), a.set(null));
64
64
  };
65
65
  t.addEventListener("pointermove", c);
66
- const p = (L = !1) => {
66
+ const p = (O = !1) => {
67
67
  f && f.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 } };
68
+ const B = Ce(t), { minX: m, minY: w, maxX: E, maxY: L } = B, T = l ? i.getIntersecting(m, w, E, L).filter(({ annotation: P }) => l(P)) : i.getIntersecting(m, w, E, L), N = r.selected.map(({ id: P }) => P), K = T.map(({ annotation: P, rects: lt }) => {
69
+ const ve = N.includes(P.id), xe = P.id === a.current;
70
+ return { annotation: P, rects: lt, state: { selected: ve, hover: xe } };
71
71
  });
72
- o.redraw($, T, s, f, L), setTimeout(() => g(R.map(({ annotation: Y }) => Y)), 1);
73
- }, u = (L) => {
74
- f = L, p();
75
- }, x = (L) => {
76
- s = L, p();
77
- }, b = (L) => {
78
- l = L, p(!1);
72
+ o.redraw(K, B, s, f, O), setTimeout(() => g(T.map(({ annotation: P }) => P)), 1);
73
+ }, u = (O) => {
74
+ f = O, p();
75
+ }, x = (O) => {
76
+ s = O, p();
77
+ }, b = (O) => {
78
+ l = O, p(!1);
79
79
  }, v = () => p();
80
80
  i.observe(v);
81
81
  const h = r.subscribe(() => p()), d = () => p(!0);
82
82
  document.addEventListener("scroll", d, { capture: !0, passive: !0 });
83
- const y = It(() => {
83
+ const y = _t(() => {
84
84
  i.recalculatePositions(), f && f.reset(), p();
85
85
  }, 10);
86
86
  window.addEventListener("resize", y);
87
- const E = new ResizeObserver(y);
88
- E.observe(t);
89
- const w = { attributes: !0, childList: !0, subtree: !0 }, O = new MutationObserver((L) => {
90
- L.every((m) => m.target === t || t.contains(m.target)) || p(!0);
87
+ const A = new ResizeObserver(y);
88
+ A.observe(t);
89
+ const C = { attributes: !0, childList: !0, subtree: !0 }, S = new MutationObserver((O) => {
90
+ O.every((m) => m.target === t || t.contains(m.target)) || p(!0);
91
91
  });
92
- return O.observe(document.body, w), {
92
+ return S.observe(document.body, C), {
93
93
  destroy: () => {
94
- t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(v), h(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), E.disconnect(), O.disconnect();
94
+ t.removeEventListener("pointermove", c), o.destroy(), i.unobserve(v), h(), document.removeEventListener("scroll", d), y.clear(), window.removeEventListener("resize", y), A.disconnect(), S.disconnect();
95
95
  },
96
96
  redraw: p,
97
97
  setStyle: x,
@@ -116,24 +116,24 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
116
116
  const { annotation: { target: { created: d } } } = v, { annotation: { target: { created: y } } } = h;
117
117
  return d.getTime() - y.getTime();
118
118
  }).forEach((v) => {
119
- var E;
120
- const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (E = v.state) != null && E.selected ? gt : q, d = g && g.paint(v, l) || h, y = v.rects.map(({ x: w, y: O, width: B, height: L }) => ({
121
- x: w + x,
122
- y: O + u,
123
- width: B,
124
- height: L
119
+ var A;
120
+ const h = f ? typeof f == "function" ? f(v.annotation, v.state) : f : (A = v.state) != null && A.selected ? mt : q, d = g && g.paint(v, l) || h, y = v.rects.map(({ x: C, y: S, width: R, height: O }) => ({
121
+ x: C + x,
122
+ y: S + u,
123
+ width: R,
124
+ height: O
125
125
  }));
126
126
  if (n.fillStyle = d.fill, n.globalAlpha = d.fillOpacity || 1, y.forEach(
127
- ({ x: w, y: O, width: B, height: L }) => n.fillRect(w, O, B, L)
127
+ ({ x: C, y: S, width: R, height: O }) => n.fillRect(C, S, R, O)
128
128
  ), d.underlineColor) {
129
129
  n.globalAlpha = 1, n.strokeStyle = d.underlineColor, n.lineWidth = d.underlineThickness ?? 1;
130
- const w = d.underlineOffset ?? 0;
131
- y.forEach(({ x: O, y: B, width: L, height: T }) => {
132
- n.beginPath(), n.moveTo(O, B + T + w), n.lineTo(O + L, B + T + w), n.stroke();
130
+ const C = d.underlineOffset ?? 0;
131
+ y.forEach(({ x: S, y: R, width: O, height: B }) => {
132
+ n.beginPath(), n.moveTo(S, R + B + C), n.lineTo(S + O, R + B + C), n.stroke();
133
133
  });
134
134
  }
135
135
  });
136
- }), i = It(() => Te(e), 10);
136
+ }), i = _t(() => Te(e), 10);
137
137
  return window.addEventListener("resize", i), {
138
138
  destroy: () => {
139
139
  e.remove(), i.clear(), window.removeEventListener("resize", i);
@@ -143,144 +143,144 @@ const It = /* @__PURE__ */ Ee(Se), Ce = (t) => {
143
143
  },
144
144
  redraw: o
145
145
  };
146
- }, Be = (t, e, n) => _t(t, e, n, Re(t));
146
+ }, Be = (t, e, n) => Ut(t, e, n, Re(t));
147
147
  var Me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, z = function(t) {
148
148
  return typeof t == "string" ? t.length > 0 : typeof t == "number";
149
149
  }, _ = function(t, e, n) {
150
150
  return e === void 0 && (e = 0), n === void 0 && (n = Math.pow(10, e)), Math.round(n * t) / n + 0;
151
- }, K = function(t, e, n) {
151
+ }, Y = function(t, e, n) {
152
152
  return e === void 0 && (e = 0), n === void 0 && (n = 1), t > n ? n : t > e ? t : e;
153
- }, ie = function(t) {
153
+ }, re = function(t) {
154
154
  return (t = isFinite(t) ? t % 360 : 0) > 0 ? t : t + 360;
155
- }, Dt = function(t) {
156
- return { r: K(t.r, 0, 255), g: K(t.g, 0, 255), b: K(t.b, 0, 255), a: K(t.a) };
157
- }, yt = function(t) {
155
+ }, Kt = function(t) {
156
+ return { r: Y(t.r, 0, 255), g: Y(t.g, 0, 255), b: Y(t.b, 0, 255), a: Y(t.a) };
157
+ }, bt = function(t) {
158
158
  return { r: _(t.r), g: _(t.g), b: _(t.b), a: _(t.a, 3) };
159
- }, ke = /^#([0-9a-f]{3,8})$/i, lt = function(t) {
159
+ }, ke = /^#([0-9a-f]{3,8})$/i, dt = function(t) {
160
160
  var e = t.toString(16);
161
161
  return e.length < 2 ? "0" + e : e;
162
- }, re = function(t) {
162
+ }, se = function(t) {
163
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
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) {
165
+ }, ae = function(t) {
166
166
  var e = t.h, n = t.s, o = t.v, i = t.a;
167
167
  e = e / 360 * 6, n /= 100, o /= 100;
168
168
  var r = Math.floor(e), a = o * (1 - n), s = o * (1 - (e - r) * n), l = o * (1 - (1 - e + r) * n), f = r % 6;
169
169
  return { r: 255 * [o, s, a, a, l, o][f], g: 255 * [l, o, o, s, a, a][f], b: 255 * [a, a, l, o, o, s][f], a: i };
170
170
  }, Yt = function(t) {
171
- return { h: ie(t.h), s: K(t.s, 0, 100), l: K(t.l, 0, 100), a: K(t.a) };
172
- }, Kt = function(t) {
173
- return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
171
+ return { h: re(t.h), s: Y(t.s, 0, 100), l: Y(t.l, 0, 100), a: Y(t.a) };
174
172
  }, 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 }));
173
+ return { h: _(t.h), s: _(t.s), l: _(t.l), a: _(t.a, 3) };
174
+ }, Pt = function(t) {
175
+ return ae((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 }));
176
176
  var e, n, o;
177
177
  }, it = function(t) {
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 };
178
+ 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 };
179
179
  var e, n, o, i;
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) {
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, $t = { string: [[function(t) {
181
181
  var e = ke.exec(t);
182
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;
183
183
  }, "hex"], [function(t) {
184
184
  var e = _e.exec(t) || Ue.exec(t);
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;
185
+ return e ? e[2] !== e[4] || e[4] !== e[6] ? null : Kt({ 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;
186
186
  }, "rgb"], [function(t) {
187
187
  var e = Ne.exec(t) || Ie.exec(t);
188
188
  if (!e) return null;
189
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);
190
+ return Pt(i);
191
191
  }, "hsl"]], object: [[function(t) {
192
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;
193
+ return z(e) && z(n) && z(o) ? Kt({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
194
194
  }, "rgb"], [function(t) {
195
195
  var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
196
196
  if (!z(e) || !z(n) || !z(o)) return null;
197
197
  var a = Yt({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
198
- return Xt(a);
198
+ return Pt(a);
199
199
  }, "hsl"], [function(t) {
200
200
  var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
201
201
  if (!z(e) || !z(n) || !z(o)) return null;
202
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) };
203
+ return { h: re(s.h), s: Y(s.s, 0, 100), v: Y(s.v, 0, 100), a: Y(s.a) };
204
204
  }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
205
- return se(a);
206
- }, "hsv"]] }, $t = function(t, e) {
205
+ return ae(a);
206
+ }, "hsv"]] }, Ht = function(t, e) {
207
207
  for (var n = 0; n < e.length; n++) {
208
208
  var o = e[n][0](t);
209
209
  if (o) return [o, e[n][1]];
210
210
  }
211
211
  return [null, void 0];
212
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) {
213
+ return typeof t == "string" ? Ht(t.trim(), $t.string) : typeof t == "object" && t !== null ? Ht(t, $t.object) : [null, void 0];
214
+ }, wt = function(t, e) {
215
215
  var n = it(t);
216
- return { h: n.h, s: K(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
217
- }, wt = function(t) {
216
+ return { h: n.h, s: Y(n.s + 100 * e, 0, 100), l: n.l, a: n.a };
217
+ }, vt = function(t) {
218
218
  return (299 * t.r + 587 * t.g + 114 * t.b) / 1e3 / 255;
219
- }, Ht = function(t, e) {
219
+ }, jt = function(t, e) {
220
220
  var n = it(t);
221
- return { h: n.h, s: n.s, l: K(n.l + 100 * e, 0, 100), a: n.a };
222
- }, jt = function() {
221
+ return { h: n.h, s: n.s, l: Y(n.l + 100 * e, 0, 100), a: n.a };
222
+ }, zt = function() {
223
223
  function t(e) {
224
224
  this.parsed = Ve(e)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
225
225
  }
226
226
  return t.prototype.isValid = function() {
227
227
  return this.parsed !== null;
228
228
  }, t.prototype.brightness = function() {
229
- return _(wt(this.rgba), 2);
229
+ return _(vt(this.rgba), 2);
230
230
  }, t.prototype.isDark = function() {
231
- return wt(this.rgba) < 0.5;
231
+ return vt(this.rgba) < 0.5;
232
232
  }, t.prototype.isLight = function() {
233
- return wt(this.rgba) >= 0.5;
233
+ return vt(this.rgba) >= 0.5;
234
234
  }, t.prototype.toHex = function() {
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;
235
+ return e = bt(this.rgba), n = e.r, o = e.g, i = e.b, a = (r = e.a) < 1 ? dt(_(255 * r)) : "", "#" + dt(n) + dt(o) + dt(i) + a;
236
236
  var e, n, o, i, r, a;
237
237
  }, t.prototype.toRgb = function() {
238
- return yt(this.rgba);
238
+ return bt(this.rgba);
239
239
  }, t.prototype.toRgbString = function() {
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 + ")";
240
+ return e = bt(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
241
  var e, n, o, i, r;
242
242
  }, t.prototype.toHsl = function() {
243
- return Kt(it(this.rgba));
243
+ return Xt(it(this.rgba));
244
244
  }, t.prototype.toHslString = function() {
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 + "%)";
245
+ return e = Xt(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
246
  var e, n, o, i, r;
247
247
  }, t.prototype.toHsv = function() {
248
- return e = re(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
248
+ return e = se(this.rgba), { h: _(e.h), s: _(e.s), v: _(e.v), a: _(e.a, 3) };
249
249
  var e;
250
250
  }, t.prototype.invert = function() {
251
- return X({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
251
+ return $({ r: 255 - (e = this.rgba).r, g: 255 - e.g, b: 255 - e.b, a: e.a });
252
252
  var e;
253
253
  }, t.prototype.saturate = function(e) {
254
- return e === void 0 && (e = 0.1), X(bt(this.rgba, e));
254
+ return e === void 0 && (e = 0.1), $(wt(this.rgba, e));
255
255
  }, t.prototype.desaturate = function(e) {
256
- return e === void 0 && (e = 0.1), X(bt(this.rgba, -e));
256
+ return e === void 0 && (e = 0.1), $(wt(this.rgba, -e));
257
257
  }, t.prototype.grayscale = function() {
258
- return X(bt(this.rgba, -1));
258
+ return $(wt(this.rgba, -1));
259
259
  }, t.prototype.lighten = function(e) {
260
- return e === void 0 && (e = 0.1), X(Ht(this.rgba, e));
260
+ return e === void 0 && (e = 0.1), $(jt(this.rgba, e));
261
261
  }, t.prototype.darken = function(e) {
262
- return e === void 0 && (e = 0.1), X(Ht(this.rgba, -e));
262
+ return e === void 0 && (e = 0.1), $(jt(this.rgba, -e));
263
263
  }, t.prototype.rotate = function(e) {
264
264
  return e === void 0 && (e = 15), this.hue(this.hue() + e);
265
265
  }, t.prototype.alpha = function(e) {
266
- return typeof e == "number" ? X({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
266
+ return typeof e == "number" ? $({ r: (n = this.rgba).r, g: n.g, b: n.b, a: e }) : _(this.rgba.a, 3);
267
267
  var n;
268
268
  }, t.prototype.hue = function(e) {
269
269
  var n = it(this.rgba);
270
- return typeof e == "number" ? X({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
270
+ return typeof e == "number" ? $({ h: e, s: n.s, l: n.l, a: n.a }) : _(n.h);
271
271
  }, t.prototype.isEqual = function(e) {
272
- return this.toHex() === X(e).toHex();
272
+ return this.toHex() === $(e).toHex();
273
273
  }, t;
274
- }(), X = function(t) {
275
- return t instanceof jt ? t : new jt(t);
274
+ }(), $ = function(t) {
275
+ return t instanceof zt ? t : new zt(t);
276
276
  };
277
277
  const De = (t) => [
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()}`,
278
+ `background-color:${$((t == null ? void 0 : t.fill) || q.fill).alpha((t == null ? void 0 : t.fillOpacity) === void 0 ? q.fillOpacity : t.fillOpacity).toHex()}`,
279
279
  t != null && t.underlineThickness ? "text-decoration:underline" : void 0,
280
280
  t != null && t.underlineColor ? `text-decoration-color:${t.underlineColor}` : void 0,
281
281
  t != null && t.underlineOffset ? `text-underline-offset:${t.underlineOffset}px` : void 0,
282
282
  t != null && t.underlineThickness ? `text-decoration-thickness:${t.underlineThickness}px` : void 0
283
- ].filter(Boolean).join(";"), Ye = () => {
283
+ ].filter(Boolean).join(";"), Ke = () => {
284
284
  const t = document.createElement("style");
285
285
  document.getElementsByTagName("head")[0].appendChild(t);
286
286
  let e = /* @__PURE__ */ new Set();
@@ -297,7 +297,7 @@ const De = (t) => [
297
297
  Array.from(e).filter((c) => !f.has(c));
298
298
  const g = r.map((c) => {
299
299
  var x;
300
- const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? gt : q, u = l && l.paint(c, a) || p;
300
+ const p = s ? typeof s == "function" ? s(c.annotation, c.state) : s : (x = c.state) != null && x.selected ? mt : q, u = l && l.paint(c, a) || p;
301
301
  return `::highlight(_${c.annotation.id}) { ${De(u)} }`;
302
302
  });
303
303
  t.innerHTML = g.join(`
@@ -307,9 +307,9 @@ const De = (t) => [
307
307
  }), e = f;
308
308
  }
309
309
  };
310
- }, Ke = (t, e, n) => _t(t, e, n, Ye());
311
- var zt = Object.prototype.hasOwnProperty;
312
- function Bt(t, e) {
310
+ }, Ye = (t, e, n) => Ut(t, e, n, Ke());
311
+ var Ft = Object.prototype.hasOwnProperty;
312
+ function Mt(t, e) {
313
313
  var n, o;
314
314
  if (t === e) return !0;
315
315
  if (t && e && (n = t.constructor) === e.constructor) {
@@ -317,13 +317,13 @@ function Bt(t, e) {
317
317
  if (n === RegExp) return t.toString() === e.toString();
318
318
  if (n === Array) {
319
319
  if ((o = t.length) === e.length)
320
- for (; o-- && Bt(t[o], e[o]); ) ;
320
+ for (; o-- && Mt(t[o], e[o]); ) ;
321
321
  return o === -1;
322
322
  }
323
323
  if (!n || typeof t == "object") {
324
324
  o = 0;
325
325
  for (n in t)
326
- if (zt.call(t, n) && ++o && !zt.call(e, n) || !(n in e) || !Bt(t[n], e[n])) return !1;
326
+ if (Ft.call(t, n) && ++o && !Ft.call(e, n) || !(n in e) || !Mt(t[n], e[n])) return !1;
327
327
  return Object.keys(e).length === o;
328
328
  }
329
329
  }
@@ -342,7 +342,7 @@ const Xe = (t, e) => {
342
342
  e.remove();
343
343
  },
344
344
  redraw: (a, s, l, f, g) => {
345
- const p = !(Bt(n, a) && g);
345
+ const p = !(Mt(n, a) && g);
346
346
  if (!f && !p) return;
347
347
  p && (e.innerHTML = ""), [...a].sort((x, b) => {
348
348
  const { annotation: { target: { created: v } } } = x, { annotation: { target: { created: h } } } = b;
@@ -352,7 +352,7 @@ const Xe = (t, e) => {
352
352
  const v = Xe(b, a), h = Ae(x, s, l, f, v);
353
353
  if (p) {
354
354
  const d = document.createElement("span");
355
- d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = X((h == null ? void 0 : h.fill) || q.fill).alpha((h == null ? void 0 : h.fillOpacity) === void 0 ? q.fillOpacity : h.fillOpacity).toHex(), h.underlineStyle && (d.style.borderStyle = h.underlineStyle), h.underlineColor && (d.style.borderColor = h.underlineColor), h.underlineThickness && (d.style.borderBottomWidth = `${h.underlineThickness}px`), h.underlineOffset && (d.style.paddingBottom = `${h.underlineOffset}px`), e.appendChild(d);
355
+ d.className = "r6o-annotation", d.dataset.annotation = x.annotation.id, d.style.left = `${b.x}px`, d.style.top = `${b.y}px`, d.style.width = `${b.width}px`, d.style.height = `${b.height}px`, d.style.backgroundColor = $((h == null ? void 0 : h.fill) || q.fill).alpha((h == null ? void 0 : h.fillOpacity) === void 0 ? q.fillOpacity : h.fillOpacity).toHex(), h.underlineStyle && (d.style.borderStyle = h.underlineStyle), h.underlineColor && (d.style.borderColor = h.underlineColor), h.underlineThickness && (d.style.borderBottomWidth = `${h.underlineThickness}px`), h.underlineOffset && (d.style.paddingBottom = `${h.underlineOffset}px`), e.appendChild(d);
356
356
  }
357
357
  });
358
358
  }), n = a;
@@ -361,31 +361,31 @@ const Xe = (t, e) => {
361
361
  a ? e.classList.remove("hidden") : e.classList.add("hidden");
362
362
  }
363
363
  };
364
- }, $e = (t, e, n) => _t(t, e, n, Pe(t));
364
+ }, $e = (t, e, n) => Ut(t, e, n, Pe(t));
365
365
  var U = [];
366
- for (var vt = 0; vt < 256; ++vt)
367
- U.push((vt + 256).toString(16).slice(1));
366
+ for (var xt = 0; xt < 256; ++xt)
367
+ U.push((xt + 256).toString(16).slice(1));
368
368
  function He(t, e = 0) {
369
369
  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();
370
370
  }
371
- var dt, je = new Uint8Array(16);
371
+ var ut, je = new Uint8Array(16);
372
372
  function ze() {
373
- if (!dt && (dt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !dt))
373
+ if (!ut && (ut = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ut))
374
374
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
375
- return dt(je);
375
+ return ut(je);
376
376
  }
377
377
  var Fe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
378
- const Ft = {
378
+ const Wt = {
379
379
  randomUUID: Fe
380
380
  };
381
- function ae(t, e, n) {
382
- if (Ft.randomUUID && !e && !t)
383
- return Ft.randomUUID();
381
+ function ce(t, e, n) {
382
+ if (Wt.randomUUID && !e && !t)
383
+ return Wt.randomUUID();
384
384
  t = t || {};
385
385
  var o = t.random || (t.rng || ze)();
386
386
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, He(o);
387
387
  }
388
- var Wt = Object.prototype.hasOwnProperty;
388
+ var qt = Object.prototype.hasOwnProperty;
389
389
  function Z(t, e) {
390
390
  var n, o;
391
391
  if (t === e) return !0;
@@ -400,19 +400,19 @@ function Z(t, e) {
400
400
  if (!n || typeof t == "object") {
401
401
  o = 0;
402
402
  for (n in t)
403
- if (Wt.call(t, n) && ++o && !Wt.call(e, n) || !(n in e) || !Z(t[n], e[n])) return !1;
403
+ if (qt.call(t, n) && ++o && !qt.call(e, n) || !(n in e) || !Z(t[n], e[n])) return !1;
404
404
  return Object.keys(e).length === o;
405
405
  }
406
406
  }
407
407
  return t !== t && e !== e;
408
408
  }
409
- function xt() {
409
+ function At() {
410
410
  }
411
411
  function We(t, e) {
412
412
  return t != t ? e == e : t !== e || t && typeof t == "object" || typeof t == "function";
413
413
  }
414
414
  const G = [];
415
- function Ut(t, e = xt) {
415
+ function Vt(t, e = At) {
416
416
  let n;
417
417
  const o = /* @__PURE__ */ new Set();
418
418
  function i(s) {
@@ -430,16 +430,16 @@ function Ut(t, e = xt) {
430
430
  function r(s) {
431
431
  i(s(t));
432
432
  }
433
- function a(s, l = xt) {
433
+ function a(s, l = At) {
434
434
  const f = [s, l];
435
- return o.add(f), o.size === 1 && (n = e(i, r) || xt), s(t), () => {
435
+ return o.add(f), o.size === 1 && (n = e(i, r) || At), s(t), () => {
436
436
  o.delete(f), o.size === 0 && n && (n(), n = null);
437
437
  };
438
438
  }
439
439
  return { set: i, update: r, subscribe: a };
440
440
  }
441
441
  const qe = (t) => {
442
- const { subscribe: e, set: n } = Ut();
442
+ const { subscribe: e, set: n } = Vt();
443
443
  let o;
444
444
  return e((i) => o = i), t.observe(({ changes: i }) => {
445
445
  if (o) {
@@ -456,11 +456,11 @@ const qe = (t) => {
456
456
  };
457
457
  };
458
458
  var Ge = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Ge || {});
459
- const At = { selected: [] }, Qe = (t, e = "EDIT") => {
460
- const { subscribe: n, set: o } = Ut(At);
461
- let i = e, r = At;
459
+ const Et = { selected: [] }, Qe = (t, e = "EDIT") => {
460
+ const { subscribe: n, set: o } = Vt(Et);
461
+ let i = e, r = Et;
462
462
  n((u) => r = u);
463
- const a = () => o(At), s = () => {
463
+ const a = () => o(Et), s = () => {
464
464
  var u;
465
465
  return ((u = r.selected) == null ? void 0 : u.length) === 0;
466
466
  }, l = (u) => {
@@ -474,7 +474,7 @@ const At = { selected: [] }, Qe = (t, e = "EDIT") => {
474
474
  console.warn("Invalid selection: " + u);
475
475
  return;
476
476
  }
477
- switch (qt(b, i)) {
477
+ switch (Gt(b, i)) {
478
478
  case "EDIT":
479
479
  o({ selected: [{ id: u, editable: !0 }], event: x });
480
480
  break;
@@ -488,7 +488,7 @@ const At = { selected: [] }, Qe = (t, e = "EDIT") => {
488
488
  const b = Array.isArray(u) ? u : [u], v = b.map((h) => t.getAnnotation(h)).filter((h) => !!h);
489
489
  o({
490
490
  selected: v.map((h) => {
491
- const d = x === void 0 ? qt(h, i) === "EDIT" : x;
491
+ const d = x === void 0 ? Gt(h, i) === "EDIT" : x;
492
492
  return { id: h.id, editable: d };
493
493
  })
494
494
  }), v.length !== b.length && console.warn("Invalid selection", u);
@@ -515,26 +515,26 @@ const At = { selected: [] }, Qe = (t, e = "EDIT") => {
515
515
  subscribe: n,
516
516
  userSelect: f
517
517
  };
518
- }, qt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
518
+ }, Gt = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
519
519
  var V = [];
520
- for (var Et = 0; Et < 256; ++Et)
521
- V.push((Et + 256).toString(16).slice(1));
520
+ for (var St = 0; St < 256; ++St)
521
+ V.push((St + 256).toString(16).slice(1));
522
522
  function Je(t, e = 0) {
523
523
  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();
524
524
  }
525
- var ut, Ze = new Uint8Array(16);
525
+ var ft, Ze = new Uint8Array(16);
526
526
  function tn() {
527
- if (!ut && (ut = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ut))
527
+ if (!ft && (ft = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ft))
528
528
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
529
- return ut(Ze);
529
+ return ft(Ze);
530
530
  }
531
531
  var en = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
532
- const Gt = {
532
+ const Qt = {
533
533
  randomUUID: en
534
534
  };
535
535
  function nn(t, e, n) {
536
- if (Gt.randomUUID && !e && !t)
537
- return Gt.randomUUID();
536
+ if (Qt.randomUUID && !e && !t)
537
+ return Qt.randomUUID();
538
538
  t = t || {};
539
539
  var o = t.random || (t.rng || tn)();
540
540
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Je(o);
@@ -554,7 +554,7 @@ const Eo = (t, e, n, o) => ({
554
554
  }, sn = (t, e) => e.bodies.map((n) => {
555
555
  const o = t.bodies.find((i) => i.id === n.id);
556
556
  return { newBody: n, oldBody: o && !Z(o, n) ? o : void 0 };
557
- }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), an = (t, e) => !Z(t.target, e.target), ce = (t, e) => {
557
+ }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), an = (t, e) => !Z(t.target, e.target), le = (t, e) => {
558
558
  const n = on(t, e), o = rn(t, e), i = sn(t, e);
559
559
  return {
560
560
  oldValue: t,
@@ -600,7 +600,7 @@ const cn = (t, e) => {
600
600
  const { oldValue: p, newValue: u } = c;
601
601
  if (a.has(u.id)) {
602
602
  const x = e.updated.find((b) => b.oldValue.id === u.id).newValue;
603
- return ce(p, x);
603
+ return le(p, x);
604
604
  } else
605
605
  return c;
606
606
  }),
@@ -608,164 +608,164 @@ const cn = (t, e) => {
608
608
  ];
609
609
  return { created: l, deleted: f, updated: g };
610
610
  }, dn = (t) => t.id !== void 0, un = () => {
611
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, A = {}) => n.push({ onChange: m, options: A }), i = (m) => {
612
- const A = n.findIndex((S) => S.onChange == m);
613
- A > -1 && n.splice(A, 1);
614
- }, r = (m, A) => {
615
- const S = {
611
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (m, w = {}) => n.push({ onChange: m, options: w }), i = (m) => {
612
+ const w = n.findIndex((E) => E.onChange == m);
613
+ w > -1 && n.splice(w, 1);
614
+ }, r = (m, w) => {
615
+ const E = {
616
616
  origin: m,
617
617
  changes: {
618
- created: A.created || [],
619
- updated: A.updated || [],
620
- deleted: A.deleted || []
618
+ created: w.created || [],
619
+ updated: w.updated || [],
620
+ deleted: w.deleted || []
621
621
  },
622
622
  state: [...t.values()]
623
623
  };
624
- n.forEach((C) => {
625
- cn(C, S) && C.onChange(S);
624
+ n.forEach((L) => {
625
+ cn(L, E) && L.onChange(E);
626
626
  });
627
- }, a = (m, A = M.LOCAL) => {
627
+ }, a = (m, w = M.LOCAL) => {
628
628
  if (t.get(m.id))
629
629
  throw Error(`Cannot add annotation ${m.id} - exists already`);
630
- t.set(m.id, m), m.bodies.forEach((S) => e.set(S.id, m.id)), r(A, { created: [m] });
631
- }, s = (m, A) => {
632
- const S = typeof m == "string" ? A : m, C = typeof m == "string" ? m : m.id, R = t.get(C);
633
- if (R) {
634
- const N = ce(R, S);
635
- 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;
630
+ t.set(m.id, m), m.bodies.forEach((E) => e.set(E.id, m.id)), r(w, { created: [m] });
631
+ }, s = (m, w) => {
632
+ const E = typeof m == "string" ? w : m, L = typeof m == "string" ? m : m.id, T = t.get(L);
633
+ if (T) {
634
+ const N = le(T, E);
635
+ return L === E.id ? t.set(L, E) : (t.delete(L), t.set(E.id, E)), T.bodies.forEach((K) => e.delete(K.id)), E.bodies.forEach((K) => e.set(K.id, E.id)), N;
636
636
  } else
637
- console.warn(`Cannot update annotation ${C} - does not exist`);
638
- }, l = (m, A = M.LOCAL, S = M.LOCAL) => {
639
- const C = dn(A) ? S : A, R = s(m, A);
640
- R && r(C, { updated: [R] });
641
- }, f = (m, A = M.LOCAL) => {
642
- const S = m.reduce((C, R) => {
643
- const N = s(R);
644
- return N ? [...C, N] : C;
637
+ console.warn(`Cannot update annotation ${L} - does not exist`);
638
+ }, l = (m, w = M.LOCAL, E = M.LOCAL) => {
639
+ const L = dn(w) ? E : w, T = s(m, w);
640
+ T && r(L, { updated: [T] });
641
+ }, f = (m, w = M.LOCAL) => {
642
+ const E = m.reduce((L, T) => {
643
+ const N = s(T);
644
+ return N ? [...L, N] : L;
645
645
  }, []);
646
- S.length > 0 && r(A, { updated: S });
647
- }, g = (m, A = M.LOCAL) => {
648
- const S = t.get(m.annotation);
649
- if (S) {
650
- const C = {
651
- ...S,
652
- bodies: [...S.bodies, m]
646
+ E.length > 0 && r(w, { updated: E });
647
+ }, g = (m, w = M.LOCAL) => {
648
+ const E = t.get(m.annotation);
649
+ if (E) {
650
+ const L = {
651
+ ...E,
652
+ bodies: [...E.bodies, m]
653
653
  };
654
- t.set(S.id, C), e.set(m.id, C.id), r(A, { updated: [{
655
- oldValue: S,
656
- newValue: C,
654
+ t.set(E.id, L), e.set(m.id, L.id), r(w, { updated: [{
655
+ oldValue: E,
656
+ newValue: L,
657
657
  bodiesCreated: [m]
658
658
  }] });
659
659
  } else
660
660
  console.warn(`Attempt to add body to missing annotation: ${m.annotation}`);
661
661
  }, c = () => [...t.values()], p = (m = M.LOCAL) => {
662
- const A = [...t.values()];
663
- t.clear(), e.clear(), r(m, { deleted: A });
664
- }, u = (m, A = !0, S = M.LOCAL) => {
665
- if (A) {
666
- const C = [...t.values()];
667
- t.clear(), e.clear(), m.forEach((R) => {
668
- t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
669
- }), r(S, { created: m, deleted: C });
662
+ const w = [...t.values()];
663
+ t.clear(), e.clear(), r(m, { deleted: w });
664
+ }, u = (m, w = !0, E = M.LOCAL) => {
665
+ if (w) {
666
+ const L = [...t.values()];
667
+ t.clear(), e.clear(), m.forEach((T) => {
668
+ t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
669
+ }), r(E, { created: m, deleted: L });
670
670
  } else {
671
- const C = m.reduce((R, N) => {
672
- const $ = t.get(N.id);
673
- return $ ? [...R, $] : R;
671
+ const L = m.reduce((T, N) => {
672
+ const K = t.get(N.id);
673
+ return K ? [...T, K] : T;
674
674
  }, []);
675
- if (C.length > 0)
676
- throw Error(`Bulk insert would overwrite the following annotations: ${C.map((R) => R.id).join(", ")}`);
677
- m.forEach((R) => {
678
- t.set(R.id, R), R.bodies.forEach((N) => e.set(N.id, R.id));
679
- }), r(S, { created: m });
675
+ if (L.length > 0)
676
+ throw Error(`Bulk insert would overwrite the following annotations: ${L.map((T) => T.id).join(", ")}`);
677
+ m.forEach((T) => {
678
+ t.set(T.id, T), T.bodies.forEach((N) => e.set(N.id, T.id));
679
+ }), r(E, { created: m });
680
680
  }
681
681
  }, x = (m) => {
682
- const A = typeof m == "string" ? m : m.id, S = t.get(A);
683
- if (S)
684
- return t.delete(A), S.bodies.forEach((C) => e.delete(C.id)), S;
685
- console.warn(`Attempt to delete missing annotation: ${A}`);
686
- }, b = (m, A = M.LOCAL) => {
687
- const S = x(m);
688
- S && r(A, { deleted: [S] });
689
- }, v = (m, A = M.LOCAL) => {
690
- const S = m.reduce((C, R) => {
691
- const N = x(R);
692
- return N ? [...C, N] : C;
682
+ const w = typeof m == "string" ? m : m.id, E = t.get(w);
683
+ if (E)
684
+ return t.delete(w), E.bodies.forEach((L) => e.delete(L.id)), E;
685
+ console.warn(`Attempt to delete missing annotation: ${w}`);
686
+ }, b = (m, w = M.LOCAL) => {
687
+ const E = x(m);
688
+ E && r(w, { deleted: [E] });
689
+ }, v = (m, w = M.LOCAL) => {
690
+ const E = m.reduce((L, T) => {
691
+ const N = x(T);
692
+ return N ? [...L, N] : L;
693
693
  }, []);
694
- S.length > 0 && r(A, { deleted: S });
694
+ E.length > 0 && r(w, { deleted: E });
695
695
  }, h = (m) => {
696
- const A = t.get(m.annotation);
697
- if (A) {
698
- const S = A.bodies.find((C) => C.id === m.id);
699
- if (S) {
700
- e.delete(S.id);
701
- const C = {
702
- ...A,
703
- bodies: A.bodies.filter((R) => R.id !== m.id)
696
+ const w = t.get(m.annotation);
697
+ if (w) {
698
+ const E = w.bodies.find((L) => L.id === m.id);
699
+ if (E) {
700
+ e.delete(E.id);
701
+ const L = {
702
+ ...w,
703
+ bodies: w.bodies.filter((T) => T.id !== m.id)
704
704
  };
705
- return t.set(A.id, C), {
706
- oldValue: A,
707
- newValue: C,
708
- bodiesDeleted: [S]
705
+ return t.set(w.id, L), {
706
+ oldValue: w,
707
+ newValue: L,
708
+ bodiesDeleted: [E]
709
709
  };
710
710
  } else
711
711
  console.warn(`Attempt to delete missing body ${m.id} from annotation ${m.annotation}`);
712
712
  } else
713
713
  console.warn(`Attempt to delete body from missing annotation ${m.annotation}`);
714
- }, d = (m, A = M.LOCAL) => {
715
- const S = h(m);
716
- S && r(A, { updated: [S] });
717
- }, y = (m, A = M.LOCAL) => {
718
- const S = m.map((C) => h(C)).filter(Boolean);
719
- S.length > 0 && r(A, { updated: S });
720
- }, E = (m) => {
721
- const A = t.get(m);
722
- return A ? { ...A } : void 0;
723
- }, w = (m) => {
724
- const A = e.get(m);
725
- if (A) {
726
- const S = E(A).bodies.find((C) => C.id === m);
727
- if (S)
728
- return S;
714
+ }, d = (m, w = M.LOCAL) => {
715
+ const E = h(m);
716
+ E && r(w, { updated: [E] });
717
+ }, y = (m, w = M.LOCAL) => {
718
+ const E = m.map((L) => h(L)).filter(Boolean);
719
+ E.length > 0 && r(w, { updated: E });
720
+ }, A = (m) => {
721
+ const w = t.get(m);
722
+ return w ? { ...w } : void 0;
723
+ }, C = (m) => {
724
+ const w = e.get(m);
725
+ if (w) {
726
+ const E = A(w).bodies.find((L) => L.id === m);
727
+ if (E)
728
+ return E;
729
729
  console.error(`Store integrity error: body ${m} in index, but not in annotation`);
730
730
  } else
731
731
  console.warn(`Attempt to retrieve missing body: ${m}`);
732
- }, O = (m, A) => {
733
- if (m.annotation !== A.annotation)
732
+ }, S = (m, w) => {
733
+ if (m.annotation !== w.annotation)
734
734
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
735
- const S = t.get(m.annotation);
736
- if (S) {
737
- const C = S.bodies.find((N) => N.id === m.id), R = {
738
- ...S,
739
- bodies: S.bodies.map((N) => N.id === C.id ? A : N)
735
+ const E = t.get(m.annotation);
736
+ if (E) {
737
+ const L = E.bodies.find((N) => N.id === m.id), T = {
738
+ ...E,
739
+ bodies: E.bodies.map((N) => N.id === L.id ? w : N)
740
740
  };
741
- return t.set(S.id, R), C.id !== A.id && (e.delete(C.id), e.set(A.id, R.id)), {
742
- oldValue: S,
743
- newValue: R,
744
- bodiesUpdated: [{ oldBody: C, newBody: A }]
741
+ return t.set(E.id, T), L.id !== w.id && (e.delete(L.id), e.set(w.id, T.id)), {
742
+ oldValue: E,
743
+ newValue: T,
744
+ bodiesUpdated: [{ oldBody: L, newBody: w }]
745
745
  };
746
746
  } else
747
747
  console.warn(`Attempt to add body to missing annotation ${m.annotation}`);
748
- }, B = (m, A, S = M.LOCAL) => {
749
- const C = O(m, A);
750
- C && r(S, { updated: [C] });
751
- }, L = (m, A = M.LOCAL) => {
752
- const S = m.map((C) => O({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
753
- r(A, { updated: S });
754
- }, T = (m) => {
755
- const A = t.get(m.annotation);
756
- if (A) {
757
- const S = {
758
- ...A,
748
+ }, R = (m, w, E = M.LOCAL) => {
749
+ const L = S(m, w);
750
+ L && r(E, { updated: [L] });
751
+ }, O = (m, w = M.LOCAL) => {
752
+ const E = m.map((L) => S({ id: L.id, annotation: L.annotation }, L)).filter(Boolean);
753
+ r(w, { updated: E });
754
+ }, B = (m) => {
755
+ const w = t.get(m.annotation);
756
+ if (w) {
757
+ const E = {
758
+ ...w,
759
759
  target: {
760
- ...A.target,
760
+ ...w.target,
761
761
  ...m
762
762
  }
763
763
  };
764
- return t.set(A.id, S), {
765
- oldValue: A,
766
- newValue: S,
764
+ return t.set(w.id, E), {
765
+ oldValue: w,
766
+ newValue: E,
767
767
  targetUpdated: {
768
- oldTarget: A.target,
768
+ oldTarget: w.target,
769
769
  newTarget: m
770
770
  }
771
771
  };
@@ -780,23 +780,23 @@ const cn = (t, e) => {
780
780
  bulkDeleteAnnotation: v,
781
781
  bulkDeleteBodies: y,
782
782
  bulkUpdateAnnotation: f,
783
- bulkUpdateBodies: L,
784
- bulkUpdateTargets: (m, A = M.LOCAL) => {
785
- const S = m.map((C) => T(C)).filter(Boolean);
786
- S.length > 0 && r(A, { updated: S });
783
+ bulkUpdateBodies: O,
784
+ bulkUpdateTargets: (m, w = M.LOCAL) => {
785
+ const E = m.map((L) => B(L)).filter(Boolean);
786
+ E.length > 0 && r(w, { updated: E });
787
787
  },
788
788
  clear: p,
789
789
  deleteAnnotation: b,
790
790
  deleteBody: d,
791
- getAnnotation: E,
792
- getBody: w,
791
+ getAnnotation: A,
792
+ getBody: C,
793
793
  observe: o,
794
794
  unobserve: i,
795
795
  updateAnnotation: l,
796
- updateBody: B,
797
- updateTarget: (m, A = M.LOCAL) => {
798
- const S = T(m);
799
- S && r(A, { updated: [S] });
796
+ updateBody: R,
797
+ updateTarget: (m, w = M.LOCAL) => {
798
+ const E = B(m);
799
+ E && r(w, { updated: [E] });
800
800
  }
801
801
  };
802
802
  };
@@ -853,7 +853,7 @@ const hn = 250, pn = (t) => {
853
853
  }
854
854
  };
855
855
  }, gn = () => {
856
- const { subscribe: t, set: e } = Ut([]);
856
+ const { subscribe: t, set: e } = Vt([]);
857
857
  return {
858
858
  subscribe: t,
859
859
  set: e
@@ -873,8 +873,8 @@ const hn = 250, pn = (t) => {
873
873
  l.has(b) && setTimeout(() => {
874
874
  l.get(b).forEach((d) => {
875
875
  if (n) {
876
- const y = Array.isArray(v) ? v.map((w) => n.serialize(w)) : n.serialize(v), E = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
877
- d(y, E);
876
+ const y = Array.isArray(v) ? v.map((C) => n.serialize(C)) : n.serialize(v), A = h ? h instanceof PointerEvent ? h : n.serialize(h) : void 0;
877
+ d(y, A);
878
878
  } else
879
879
  d(v, h);
880
880
  });
@@ -912,13 +912,13 @@ const hn = 250, pn = (t) => {
912
912
  ...d.bodiesDeleted || [],
913
913
  ...d.bodiesUpdated || []
914
914
  ].length > 0).forEach(({ oldValue: d, newValue: y }) => {
915
- const E = f.find((w) => w.id === d.id) || d;
916
- f = f.map((w) => w.id === d.id ? y : w), u("updateAnnotation", y, E);
915
+ const A = f.find((C) => C.id === d.id) || d;
916
+ f = f.map((C) => C.id === d.id ? y : C), u("updateAnnotation", y, A);
917
917
  });
918
918
  }, { origin: M.LOCAL }), i.observe((b) => {
919
919
  if (f) {
920
920
  const v = new Set(f.map((d) => d.id)), h = (b.changes.updated || []).filter(({ newValue: d }) => v.has(d.id)).map(({ newValue: d }) => d);
921
- h.length > 0 && (f = f.map((d) => h.find((E) => E.id === d.id) || d));
921
+ h.length > 0 && (f = f.map((d) => h.find((A) => A.id === d.id) || d));
922
922
  }
923
923
  }, { origin: M.REMOTE });
924
924
  const x = (b) => (v) => {
@@ -963,8 +963,8 @@ const hn = 250, pn = (t) => {
963
963
  }
964
964
  }, u = (h, d = !0) => {
965
965
  if (n) {
966
- const { parsed: y, failed: E } = yn(n)(h);
967
- E.length > 0 && console.warn(`Discarded ${E.length} invalid annotations`, E), o.bulkAddAnnotation(y, d, M.REMOTE);
966
+ const { parsed: y, failed: A } = yn(n)(h);
967
+ A.length > 0 && console.warn(`Discarded ${A.length} invalid annotations`, A), o.bulkAddAnnotation(y, d, M.REMOTE);
968
968
  } else
969
969
  o.bulkAddAnnotation(h, d, M.REMOTE);
970
970
  }, x = (h, d) => {
@@ -1023,7 +1023,7 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
1023
1023
  n = (n << 5) - n + r, n |= 0;
1024
1024
  }
1025
1025
  return `${n}`;
1026
- }, le = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Ln = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1026
+ }, de = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, Ln = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1027
1027
  const { id: o, type: i, purpose: r, value: a, created: s, modified: l, creator: f, ...g } = n;
1028
1028
  return {
1029
1029
  id: o || `temp-${Cn(n)}`,
@@ -1031,7 +1031,7 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
1031
1031
  type: i,
1032
1032
  purpose: r,
1033
1033
  value: a,
1034
- creator: le(f),
1034
+ creator: de(f),
1035
1035
  created: s ? new Date(s) : void 0,
1036
1036
  updated: l ? new Date(l) : void 0,
1037
1037
  ...g
@@ -1046,7 +1046,7 @@ const Sn = () => ({ isGuest: !0, id: An("1234567890abcdefghijklmnopqrstuvwxyzABC
1046
1046
  return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
1047
1047
  });
1048
1048
  En();
1049
- const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1049
+ const ue = "not-annotatable", H = `.${ue}`, Tn = (t) => {
1050
1050
  var n;
1051
1051
  const e = t.commonAncestorContainer;
1052
1052
  return e instanceof HTMLElement ? !e.closest(H) : !((n = e.parentElement) != null && n.closest(H));
@@ -1054,7 +1054,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1054
1054
  const e = document.createNodeIterator(
1055
1055
  t.commonAncestorContainer,
1056
1056
  NodeFilter.SHOW_ELEMENT,
1057
- (o) => o instanceof HTMLElement && o.classList.contains(de) && !o.parentElement.closest(H) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
1057
+ (o) => o instanceof HTMLElement && o.classList.contains(ue) && !o.parentElement.closest(H) && t.intersectsNode(o) ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP
1058
1058
  );
1059
1059
  let n;
1060
1060
  for (; n = e.nextNode(); )
@@ -1072,7 +1072,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1072
1072
  o.setStartAfter(n), o.collapsed || e.push(o);
1073
1073
  }
1074
1074
  return e.length > 0 ? e : [t];
1075
- }, Mt = (t) => {
1075
+ }, kt = (t) => {
1076
1076
  const e = t.cloneContents();
1077
1077
  return e.querySelectorAll(H).forEach((n) => n.remove()), e;
1078
1078
  }, Mn = (t) => t.addEventListener("click", (e) => {
@@ -1083,7 +1083,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1083
1083
  }, So = (t) => {
1084
1084
  const e = t.cloneContents();
1085
1085
  return e.querySelectorAll(H).forEach((n) => n.remove()), e;
1086
- }, Qt = (t, e) => {
1086
+ }, Jt = (t, e) => {
1087
1087
  const n = document.createNodeIterator(e);
1088
1088
  let o = 0, i = n.nextNode();
1089
1089
  for (; i !== null; ) {
@@ -1091,7 +1091,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1091
1091
  return o;
1092
1092
  o += 1, i = n.nextNode();
1093
1093
  }
1094
- }, Jt = (t, e) => {
1094
+ }, Zt = (t, e) => {
1095
1095
  const n = document.createNodeIterator(e);
1096
1096
  let o = null;
1097
1097
  for (let i = 0; i < t + 1; i++)
@@ -1107,10 +1107,10 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1107
1107
  } = t, a = Array.from(e.childNodes).map((c) => {
1108
1108
  const p = c.cloneNode(!0);
1109
1109
  return c.nodeName === "CANVAS" ? c : p;
1110
- }), s = Qt(n, e), l = Qt(i, e), f = () => {
1110
+ }), s = Jt(n, e), l = Jt(i, e), f = () => {
1111
1111
  const c = e;
1112
1112
  c.replaceChildren(...a);
1113
- const p = Jt(s, c), u = Jt(l, c);
1113
+ const p = Zt(s, c), u = Zt(l, c);
1114
1114
  return t.setStart(p, o), t.setEnd(u, r), t;
1115
1115
  }, g = (c) => {
1116
1116
  const p = document.createElement("SPAN");
@@ -1152,9 +1152,9 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1152
1152
  }, _n = (t, e, n = 10, o) => {
1153
1153
  const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
1154
1154
  r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
1155
- const a = Mt(r).textContent, s = document.createRange();
1155
+ const a = kt(r).textContent, s = document.createRange();
1156
1156
  s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
1157
- const l = Mt(s).textContent;
1157
+ const l = kt(s).textContent;
1158
1158
  return {
1159
1159
  prefix: a.substring(a.length - n),
1160
1160
  suffix: l.substring(0, n)
@@ -1183,17 +1183,17 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1183
1183
  return "block-contains";
1184
1184
  } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
1185
1185
  return "block-is-contained";
1186
- }, Yn = (t, e) => {
1186
+ }, Kn = (t, e) => {
1187
1187
  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);
1188
1188
  return new DOMRect(n, i, o - n, r - i);
1189
- }, Kn = (t) => t.reduce((e, n) => {
1189
+ }, Yn = (t) => t.reduce((e, n) => {
1190
1190
  if (n.width === 0 || n.height === 0)
1191
1191
  return e;
1192
1192
  let o = [...e], i = !1;
1193
1193
  for (const r of e) {
1194
1194
  const a = Dn(n, r);
1195
1195
  if (a === "inline-adjacent") {
1196
- o = o.map((s) => s === r ? Yn(n, r) : s), i = !0;
1196
+ o = o.map((s) => s === r ? Kn(n, r) : s), i = !0;
1197
1197
  break;
1198
1198
  } else if (a === "inline-contains") {
1199
1199
  o = o.map((s) => s === r ? n : s), i = !0;
@@ -1217,9 +1217,9 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1217
1217
  }), Xn = (t, e, n) => {
1218
1218
  const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
1219
1219
  o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
1220
- const r = Mt(o).textContent, a = t.toString(), s = r.length || 0, l = s + a.length;
1220
+ const r = kt(o).textContent, a = t.toString(), s = r.length || 0, l = s + a.length;
1221
1221
  return n ? { quote: a, start: s, end: l, range: t, offsetReference: i } : { quote: a, start: s, end: l, range: t };
1222
- }, ue = (t, e) => {
1222
+ }, fe = (t, e) => {
1223
1223
  var g, c;
1224
1224
  const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
1225
1225
  e,
@@ -1257,10 +1257,10 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1257
1257
  ...t,
1258
1258
  range: s
1259
1259
  };
1260
- }, mt = (t, e) => W(t.selector) ? t : {
1260
+ }, yt = (t, e) => W(t.selector) ? t : {
1261
1261
  ...t,
1262
- selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : ue(n, e))
1263
- }, St = (t, e) => W(t.target.selector) ? t : { ...t, target: mt(t.target, e) }, Pn = (t, e) => {
1262
+ selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : fe(n, e))
1263
+ }, Ct = (t, e) => W(t.target.selector) ? t : { ...t, target: yt(t.target, e) }, Pn = (t, e) => {
1264
1264
  const n = t.cloneRange();
1265
1265
  return e.contains(n.startContainer) || n.setStart(e, 0), e.contains(n.endContainer) || n.setEnd(e, e.childNodes.length), n;
1266
1266
  }, $n = (t, e) => {
@@ -1325,7 +1325,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1325
1325
  if (a.length === 0)
1326
1326
  return { error: Error(`No targets found for annotation: ${t.id}`) };
1327
1327
  const s = {
1328
- creator: le(n),
1328
+ creator: de(n),
1329
1329
  created: o ? new Date(o) : void 0,
1330
1330
  updated: i ? new Date(i) : void 0,
1331
1331
  annotation: e,
@@ -1356,7 +1356,7 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1356
1356
  }
1357
1357
  return { parsed: s };
1358
1358
  }, Wn = (t) => {
1359
- const e = t.id || ae(), {
1359
+ const e = t.id || ce(), {
1360
1360
  creator: n,
1361
1361
  created: o,
1362
1362
  modified: i,
@@ -1408,11 +1408,11 @@ const de = "not-annotatable", H = `.${de}`, Tn = (t) => {
1408
1408
  target: c
1409
1409
  };
1410
1410
  };
1411
- function fe(t, e, n = 0, o = t.length - 1, i = Gn) {
1411
+ function he(t, e, n = 0, o = t.length - 1, i = Gn) {
1412
1412
  for (; o > n; ) {
1413
1413
  if (o - n > 600) {
1414
1414
  const l = o - n + 1, f = 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) * (f - l / 2 < 0 ? -1 : 1), u = Math.max(n, Math.floor(e - f * c / l + p)), x = Math.min(o, Math.floor(e + (l - f) * c / l + p));
1415
- fe(t, e, u, x, i);
1415
+ he(t, e, u, x, i);
1416
1416
  }
1417
1417
  const r = t[e];
1418
1418
  let a = n, s = o;
@@ -1440,12 +1440,12 @@ class Qn {
1440
1440
  search(e) {
1441
1441
  let n = this.data;
1442
1442
  const o = [];
1443
- if (!ht(e, n)) return o;
1443
+ if (!pt(e, n)) return o;
1444
1444
  const i = this.toBBox, r = [];
1445
1445
  for (; n; ) {
1446
1446
  for (let a = 0; a < n.children.length; a++) {
1447
1447
  const s = n.children[a], l = n.leaf ? i(s) : s;
1448
- ht(e, l) && (n.leaf ? o.push(s) : Lt(e, l) ? this._all(s, o) : r.push(s));
1448
+ pt(e, l) && (n.leaf ? o.push(s) : Ot(e, l) ? this._all(s, o) : r.push(s));
1449
1449
  }
1450
1450
  n = r.pop();
1451
1451
  }
@@ -1453,13 +1453,13 @@ class Qn {
1453
1453
  }
1454
1454
  collides(e) {
1455
1455
  let n = this.data;
1456
- if (!ht(e, n)) return !1;
1456
+ if (!pt(e, n)) return !1;
1457
1457
  const o = [];
1458
1458
  for (; n; ) {
1459
1459
  for (let i = 0; i < n.children.length; i++) {
1460
1460
  const r = n.children[i], a = n.leaf ? this.toBBox(r) : r;
1461
- if (ht(e, a)) {
1462
- if (n.leaf || Lt(e, a)) return !0;
1461
+ if (pt(e, a)) {
1462
+ if (n.leaf || Ot(e, a)) return !0;
1463
1463
  o.push(r);
1464
1464
  }
1465
1465
  }
@@ -1505,7 +1505,7 @@ class Qn {
1505
1505
  if (g !== -1)
1506
1506
  return o.children.splice(g, 1), r.push(o), this._condense(r), this;
1507
1507
  }
1508
- !f && !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], f = !1) : o = null;
1508
+ !f && !o.leaf && Ot(o, i) ? (r.push(o), a.push(s), s = 0, l = o, o = o.children[0]) : l ? (s++, o = l.children[s], f = !1) : o = null;
1509
1509
  }
1510
1510
  return this;
1511
1511
  }
@@ -1537,10 +1537,10 @@ class Qn {
1537
1537
  return s = J(e.slice(n, o + 1)), Q(s, this.toBBox), s;
1538
1538
  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;
1539
1539
  const l = Math.ceil(r / a), f = l * Math.ceil(Math.sqrt(a));
1540
- Zt(e, n, o, f, this.compareMinX);
1540
+ te(e, n, o, f, this.compareMinX);
1541
1541
  for (let g = n; g <= o; g += f) {
1542
1542
  const c = Math.min(g + f - 1, o);
1543
- Zt(e, g, c, l, this.compareMinY);
1543
+ te(e, g, c, l, this.compareMinY);
1544
1544
  for (let p = g; p <= c; p += l) {
1545
1545
  const u = Math.min(p + l - 1, c);
1546
1546
  s.children.push(this._build(e, p, u, i - 1));
@@ -1552,7 +1552,7 @@ class Qn {
1552
1552
  for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1553
1553
  let r = 1 / 0, a = 1 / 0, s;
1554
1554
  for (let l = 0; l < n.children.length; l++) {
1555
- const f = n.children[l], g = Ct(f), c = eo(e, f) - g;
1555
+ const f = n.children[l], g = Lt(f), c = eo(e, f) - g;
1556
1556
  c < a ? (a = c, r = g < r ? g : r, s = f) : c === a && g < r && (r = g, s = f);
1557
1557
  }
1558
1558
  n = s || n.children[0];
@@ -1578,7 +1578,7 @@ class Qn {
1578
1578
  _chooseSplitIndex(e, n, o) {
1579
1579
  let i, r = 1 / 0, a = 1 / 0;
1580
1580
  for (let s = n; s <= o - n; s++) {
1581
- const l = nt(e, 0, s, this.toBBox), f = nt(e, s, o, this.toBBox), g = no(l, f), c = Ct(l) + Ct(f);
1581
+ const l = nt(e, 0, s, this.toBBox), f = nt(e, s, o, this.toBBox), g = no(l, f), c = Lt(l) + Lt(f);
1582
1582
  g < r ? (r = g, i = s, a = c < a ? c : a) : g === r && c < a && (a = c, i = s);
1583
1583
  }
1584
1584
  return i || o - n;
@@ -1592,14 +1592,14 @@ class Qn {
1592
1592
  _allDistMargin(e, n, o, i) {
1593
1593
  e.children.sort(i);
1594
1594
  const r = this.toBBox, a = nt(e, 0, n, r), s = nt(e, o - n, o, r);
1595
- let l = ft(a) + ft(s);
1595
+ let l = ht(a) + ht(s);
1596
1596
  for (let f = n; f < o - n; f++) {
1597
1597
  const g = e.children[f];
1598
- ot(a, e.leaf ? r(g) : g), l += ft(a);
1598
+ ot(a, e.leaf ? r(g) : g), l += ht(a);
1599
1599
  }
1600
1600
  for (let f = o - n - 1; f >= n; f--) {
1601
1601
  const g = e.children[f];
1602
- ot(s, e.leaf ? r(g) : g), l += ft(s);
1602
+ ot(s, e.leaf ? r(g) : g), l += ht(s);
1603
1603
  }
1604
1604
  return l;
1605
1605
  }
@@ -1638,10 +1638,10 @@ function Zn(t, e) {
1638
1638
  function to(t, e) {
1639
1639
  return t.minY - e.minY;
1640
1640
  }
1641
- function Ct(t) {
1641
+ function Lt(t) {
1642
1642
  return (t.maxX - t.minX) * (t.maxY - t.minY);
1643
1643
  }
1644
- function ft(t) {
1644
+ function ht(t) {
1645
1645
  return t.maxX - t.minX + (t.maxY - t.minY);
1646
1646
  }
1647
1647
  function eo(t, e) {
@@ -1651,10 +1651,10 @@ function no(t, e) {
1651
1651
  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);
1652
1652
  return Math.max(0, i - n) * Math.max(0, r - o);
1653
1653
  }
1654
- function Lt(t, e) {
1654
+ function Ot(t, e) {
1655
1655
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
1656
1656
  }
1657
- function ht(t, e) {
1657
+ function pt(t, e) {
1658
1658
  return e.minX <= t.maxX && e.minY <= t.maxY && e.maxX >= t.minX && e.maxY >= t.minY;
1659
1659
  }
1660
1660
  function J(t) {
@@ -1668,12 +1668,12 @@ function J(t) {
1668
1668
  maxY: -1 / 0
1669
1669
  };
1670
1670
  }
1671
- function Zt(t, e, n, o, i) {
1671
+ function te(t, e, n, o, i) {
1672
1672
  const r = [e, n];
1673
1673
  for (; r.length; ) {
1674
1674
  if (n = r.pop(), e = r.pop(), n - e <= o) continue;
1675
1675
  const a = e + Math.ceil((n - e) / o / 2) * o;
1676
- fe(t, a, e, n, i), r.push(e, a, a, n);
1676
+ he(t, a, e, n, i), r.push(e, a, a, n);
1677
1677
  }
1678
1678
  }
1679
1679
  let oo = () => ({
@@ -1691,61 +1691,61 @@ let oo = () => ({
1691
1691
  }
1692
1692
  });
1693
1693
  const io = (t, e) => {
1694
- const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(), r = (y, E) => {
1695
- const w = y.selector.flatMap((B) => {
1696
- const L = W([B]) ? B.range : ue(B, e).range;
1697
- return Array.from(L.getClientRects());
1698
- }), O = Kn(w).map((B) => $n(B, E));
1699
- return O.map((B) => {
1700
- const { x: L, y: T, width: m, height: A } = B;
1694
+ const n = new Qn(), o = /* @__PURE__ */ new Map(), i = oo(), r = (y, A) => {
1695
+ const C = y.selector.flatMap((R) => {
1696
+ const O = W([R]) ? R.range : fe(R, e).range;
1697
+ return Array.from(O.getClientRects());
1698
+ }), S = Yn(C).map((R) => $n(R, A));
1699
+ return S.map((R) => {
1700
+ const { x: O, y: B, width: m, height: w } = R;
1701
1701
  return {
1702
- minX: L,
1703
- minY: T,
1704
- maxX: L + m,
1705
- maxY: T + A,
1702
+ minX: O,
1703
+ minY: B,
1704
+ maxX: O + m,
1705
+ maxY: B + w,
1706
1706
  annotation: {
1707
1707
  id: y.annotation,
1708
- rects: O
1708
+ rects: S
1709
1709
  }
1710
1710
  };
1711
1711
  });
1712
1712
  }, a = () => [...o.values()], s = () => {
1713
1713
  n.clear(), o.clear();
1714
1714
  }, l = (y) => {
1715
- const E = r(y, e.getBoundingClientRect());
1716
- E.forEach((w) => n.insert(w)), o.set(y.annotation, E);
1715
+ const A = r(y, e.getBoundingClientRect());
1716
+ A.forEach((C) => n.insert(C)), o.set(y.annotation, A);
1717
1717
  }, f = (y) => {
1718
- const E = o.get(y.annotation);
1719
- E && (E.forEach((w) => n.remove(w)), o.delete(y.annotation));
1718
+ const A = o.get(y.annotation);
1719
+ A && (A.forEach((C) => n.remove(C)), o.delete(y.annotation));
1720
1720
  }, g = (y) => {
1721
1721
  f(y), l(y);
1722
- }, c = (y, E = !0) => {
1723
- E && s();
1724
- const w = e.getBoundingClientRect(), O = y.map((L) => ({ target: L, rects: r(L, w) }));
1725
- O.forEach(({ target: L, rects: T }) => o.set(L.annotation, T));
1726
- const B = O.flatMap(({ rects: L }) => L);
1727
- n.load(B);
1728
- }, p = (y, E, w = !1) => {
1729
- const O = n.search({
1722
+ }, c = (y, A = !0) => {
1723
+ A && s();
1724
+ const C = e.getBoundingClientRect(), S = y.map((O) => ({ target: O, rects: r(O, C) }));
1725
+ S.forEach(({ target: O, rects: B }) => o.set(O.annotation, B));
1726
+ const R = S.flatMap(({ rects: O }) => O);
1727
+ n.load(R);
1728
+ }, p = (y, A, C = !1) => {
1729
+ const S = n.search({
1730
1730
  minX: y,
1731
- minY: E,
1731
+ minY: A,
1732
1732
  maxX: y,
1733
- maxY: E
1734
- }), B = (L) => L.annotation.rects.reduce((T, m) => T + m.width * m.height, 0);
1735
- return O.length > 0 ? (O.sort((L, T) => B(L) - B(T)), w ? O.map((L) => L.annotation.id) : [O[0].annotation.id]) : [];
1733
+ maxY: A
1734
+ }), R = (O) => O.annotation.rects.reduce((B, m) => B + m.width * m.height, 0);
1735
+ return S.length > 0 ? (S.sort((O, B) => R(O) - R(B)), C ? S.map((O) => O.annotation.id) : [S[0].annotation.id]) : [];
1736
1736
  }, u = (y) => {
1737
- const E = x(y);
1738
- if (E.length === 0)
1737
+ const A = x(y);
1738
+ if (A.length === 0)
1739
1739
  return;
1740
- let w = E[0].left, O = E[0].top, B = E[0].right, L = E[0].bottom;
1741
- for (let T = 1; T < E.length; T++) {
1742
- const m = E[T];
1743
- w = Math.min(w, m.left), O = Math.min(O, m.top), B = Math.max(B, m.right), L = Math.max(L, m.bottom);
1740
+ let C = A[0].left, S = A[0].top, R = A[0].right, O = A[0].bottom;
1741
+ for (let B = 1; B < A.length; B++) {
1742
+ const m = A[B];
1743
+ C = Math.min(C, m.left), S = Math.min(S, m.top), R = Math.max(R, m.right), O = Math.max(O, m.bottom);
1744
1744
  }
1745
- return new DOMRect(w, O, B - w, L - O);
1745
+ return new DOMRect(C, S, R - C, O - S);
1746
1746
  }, x = (y) => {
1747
- const E = o.get(y);
1748
- return E ? E[0].annotation.rects : [];
1747
+ const A = o.get(y);
1748
+ return A ? A[0].annotation.rects : [];
1749
1749
  };
1750
1750
  return {
1751
1751
  all: a,
@@ -1753,12 +1753,12 @@ const io = (t, e) => {
1753
1753
  getAt: p,
1754
1754
  getAnnotationBounds: u,
1755
1755
  getAnnotationRects: x,
1756
- getIntersecting: (y, E, w, O) => {
1757
- const B = n.search({ minX: y, minY: E, maxX: w, maxY: O }), L = new Set(B.map((T) => T.annotation.id));
1758
- return Array.from(L).map((T) => ({
1759
- annotation: t.getAnnotation(T),
1760
- rects: x(T)
1761
- })).filter((T) => !!T.annotation);
1756
+ getIntersecting: (y, A, C, S) => {
1757
+ const R = n.search({ minX: y, minY: A, maxX: C, maxY: S }), O = new Set(R.map((B) => B.annotation.id));
1758
+ return Array.from(O).map((B) => ({
1759
+ annotation: t.getAnnotation(B),
1760
+ rects: x(B)
1761
+ })).filter((B) => !!B.annotation);
1762
1762
  },
1763
1763
  insert: l,
1764
1764
  recalculate: () => {
@@ -1768,42 +1768,42 @@ const io = (t, e) => {
1768
1768
  set: c,
1769
1769
  size: () => n.all().length,
1770
1770
  update: g,
1771
- on: (y, E) => i.on(y, E)
1771
+ on: (y, A) => i.on(y, A)
1772
1772
  };
1773
1773
  }, ro = (t, e) => {
1774
1774
  const n = un(), o = io(n, t), i = Qe(n, e), r = qe(n), a = gn(), s = (v, h = M.LOCAL) => {
1775
- const d = St(v, t), y = W(d.target.selector);
1775
+ const d = Ct(v, t), y = W(d.target.selector);
1776
1776
  return y && n.addAnnotation(d, h), y;
1777
1777
  }, l = (v, h = !0, d = M.LOCAL) => {
1778
- const y = v.map((w) => St(w, t)), E = y.filter((w) => !W(w.target.selector));
1779
- return E.length > 0 ? (console.warn("Could not revive all targets for these annotations:", E), n.bulkAddAnnotation(y, h, d), E) : (n.bulkAddAnnotation(y, h, d), []);
1778
+ const y = v.map((C) => Ct(C, t)), A = y.filter((C) => !W(C.target.selector));
1779
+ return A.length > 0 ? (console.warn("Could not revive all targets for these annotations:", A), n.bulkAddAnnotation(y, h, d), A) : (n.bulkAddAnnotation(y, h, d), []);
1780
1780
  }, f = (v, h = M.LOCAL) => {
1781
- const d = v.map((E) => St(E, t)), y = d.filter((E) => !W(E.target.selector));
1782
- return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y), d.forEach((E) => {
1783
- n.getAnnotation(E.id) ? n.updateAnnotation(E, h) : n.addAnnotation(E, h);
1781
+ const d = v.map((A) => Ct(A, t)), y = d.filter((A) => !W(A.target.selector));
1782
+ return y.length > 0 && console.warn("Could not revive all targets for these annotations:", y), d.forEach((A) => {
1783
+ n.getAnnotation(A.id) ? n.updateAnnotation(A, h) : n.addAnnotation(A, h);
1784
1784
  }), y;
1785
1785
  }, g = (v, h = M.LOCAL) => {
1786
- const d = mt(v, t);
1786
+ const d = yt(v, t);
1787
1787
  n.updateTarget(d, h);
1788
1788
  }, c = (v, h = M.LOCAL) => {
1789
- const d = v.map((y) => mt(y, t));
1789
+ const d = v.map((y) => yt(y, t));
1790
1790
  n.bulkUpdateTargets(d, h);
1791
1791
  }, p = (v, h, d) => {
1792
- const y = o.getAt(v, h, !!d).map((w) => n.getAnnotation(w)), E = d ? y.filter(d) : y;
1793
- return E.length > 0 ? E[0] : void 0;
1792
+ const y = o.getAt(v, h, !!d).map((C) => n.getAnnotation(C)), A = d ? y.filter(d) : y;
1793
+ return A.length > 0 ? A[0] : void 0;
1794
1794
  }, u = (v, h, d, y = 5) => {
1795
- const E = o.getAnnotationRects(v);
1796
- if (E.length !== 0) {
1795
+ const A = o.getAnnotationRects(v);
1796
+ if (A.length !== 0) {
1797
1797
  if (h && d) {
1798
- const w = E.find(({ top: O, right: B, bottom: L, left: T }) => h >= T - y && h <= B + y && d >= O - y && d <= L + y);
1799
- if (w) return w;
1798
+ const C = A.find(({ top: S, right: R, bottom: O, left: B }) => h >= B - y && h <= R + y && d >= S - y && d <= O + y);
1799
+ if (C) return C;
1800
1800
  }
1801
1801
  return o.getAnnotationBounds(v);
1802
1802
  }
1803
1803
  }, x = () => o.recalculate(), b = (v) => o.on("recalculate", v);
1804
1804
  return n.observe(({ changes: v }) => {
1805
- const h = (v.deleted || []).filter((E) => W(E.target.selector)), d = (v.created || []).filter((E) => W(E.target.selector)), y = (v.updated || []).filter((E) => W(E.newValue.target.selector));
1806
- (h == null ? void 0 : h.length) > 0 && h.forEach((E) => o.remove(E.target)), d.length > 0 && o.set(d.map((E) => E.target), !1), (y == null ? void 0 : y.length) > 0 && y.forEach(({ newValue: E }) => o.update(E.target));
1805
+ const h = (v.deleted || []).filter((A) => W(A.target.selector)), d = (v.created || []).filter((A) => W(A.target.selector)), y = (v.updated || []).filter((A) => W(A.newValue.target.selector));
1806
+ (h == null ? void 0 : h.length) > 0 && h.forEach((A) => o.remove(A.target)), d.length > 0 && o.set(d.map((A) => A.target), !1), (y == null ? void 0 : y.length) > 0 && y.forEach(({ newValue: A }) => o.update(A.target));
1807
1807
  }), {
1808
1808
  store: {
1809
1809
  ...n,
@@ -1848,8 +1848,8 @@ const io = (t, e) => {
1848
1848
  if (x) {
1849
1849
  const { height: b } = c.rects[0], v = c.rects[0].x + p.left, h = c.rects[0].y + p.top;
1850
1850
  i.fillStyle = x.appearance.color, i.fillRect(v - 2, h - 2.5, 2, b + 5);
1851
- const d = i.measureText(x.appearance.label), y = d.width + 6, E = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, w = d.fontBoundingBoxAscent ? 8 : 6.5;
1852
- return i.fillRect(v - 2, h - 2.5 - E, y, E), i.fillStyle = "#fff", i.fillText(x.appearance.label, v + 1, h - w), {
1851
+ const d = i.measureText(x.appearance.label), y = d.width + 6, A = d.actualBoundingBoxAscent + d.actualBoundingBoxDescent + 8, C = d.fontBoundingBoxAscent ? 8 : 6.5;
1852
+ return i.fillRect(v - 2, h - 2.5 - A, y, A), i.fillStyle = "#fff", i.fillText(x.appearance.label, v + 1, h - C), {
1853
1853
  fill: x.appearance.color,
1854
1854
  fillOpacity: u ? 0.45 : 0.18
1855
1855
  };
@@ -1861,22 +1861,22 @@ const io = (t, e) => {
1861
1861
  c.scale(2, 2), c.translate(0.5, 0.5);
1862
1862
  }
1863
1863
  };
1864
- }, he = (t) => {
1864
+ }, pe = (t) => {
1865
1865
  if (t === null)
1866
1866
  return document.scrollingElement;
1867
1867
  const { overflowY: e } = window.getComputedStyle(t);
1868
- return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : he(t.parentElement);
1868
+ return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : pe(t.parentElement);
1869
1869
  }, co = (t, e) => (n) => {
1870
1870
  const o = typeof n == "string" ? n : n.id, i = (a) => {
1871
1871
  const s = r.getBoundingClientRect(), l = r.clientHeight, f = r.clientWidth, g = a.selector[0].range.getBoundingClientRect(), { width: c, height: p } = e.getAnnotationBounds(o), u = g.top - s.top, x = g.left - s.left, b = r.parentElement ? r.scrollTop : 0, v = r.parentElement ? r.scrollLeft : 0, h = u + b - (l - p) / 2, d = x + v - (f - c) / 2;
1872
1872
  r.scroll({ top: h, left: d, behavior: "smooth" });
1873
- }, r = he(t);
1873
+ }, r = pe(t);
1874
1874
  if (r) {
1875
1875
  const a = e.getAnnotation(o), { range: s } = a.target.selector[0];
1876
1876
  if (s && !s.collapsed)
1877
1877
  return i(a.target), !0;
1878
1878
  {
1879
- const l = mt(a.target, t), { range: f } = l.selector[0];
1879
+ const l = yt(a.target, t), { range: f } = l.selector[0];
1880
1880
  if (f && !f.collapsed)
1881
1881
  return i(l), !0;
1882
1882
  }
@@ -1886,19 +1886,19 @@ const io = (t, e) => {
1886
1886
  ...t,
1887
1887
  annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled,
1888
1888
  user: t.user || e.user
1889
- }), Ot = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1890
- function Tt(t, e, n, o) {
1889
+ }), Tt = typeof navigator < "u" ? navigator.userAgent.toLowerCase().indexOf("firefox") > 0 : !1;
1890
+ function Rt(t, e, n, o) {
1891
1891
  t.addEventListener ? t.addEventListener(e, n, o) : t.attachEvent && t.attachEvent("on".concat(e), n);
1892
1892
  }
1893
1893
  function et(t, e, n, o) {
1894
1894
  t.removeEventListener ? t.removeEventListener(e, n, o) : t.detachEvent && t.detachEvent("on".concat(e), n);
1895
1895
  }
1896
- function pe(t, e) {
1896
+ function ge(t, e) {
1897
1897
  const n = e.slice(0, e.length - 1);
1898
1898
  for (let o = 0; o < n.length; o++) n[o] = t[n[o].toLowerCase()];
1899
1899
  return n;
1900
1900
  }
1901
- function ge(t) {
1901
+ function me(t) {
1902
1902
  typeof t != "string" && (t = ""), t = t.replace(/\s/g, "");
1903
1903
  const e = t.split(",");
1904
1904
  let n = e.lastIndexOf("");
@@ -1958,9 +1958,9 @@ const st = {
1958
1958
  ".": 190,
1959
1959
  "/": 191,
1960
1960
  "`": 192,
1961
- "-": Ot ? 173 : 189,
1962
- "=": Ot ? 61 : 187,
1963
- ";": Ot ? 59 : 186,
1961
+ "-": Tt ? 173 : 189,
1962
+ "=": Tt ? 61 : 187,
1963
+ ";": Tt ? 59 : 186,
1964
1964
  "'": 222,
1965
1965
  "[": 219,
1966
1966
  "]": 221,
@@ -1981,7 +1981,7 @@ const st = {
1981
1981
  "⌘": 91,
1982
1982
  cmd: 91,
1983
1983
  command: 91
1984
- }, kt = {
1984
+ }, Nt = {
1985
1985
  16: "shiftKey",
1986
1986
  18: "altKey",
1987
1987
  17: "ctrlKey",
@@ -1998,13 +1998,13 @@ const st = {
1998
1998
  }, I = {};
1999
1999
  for (let t = 1; t < 20; t++)
2000
2000
  st["f".concat(t)] = 111 + t;
2001
- let k = [], rt = null, me = "all";
2001
+ let k = [], rt = null, ye = "all";
2002
2002
  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);
2003
- function ye(t) {
2004
- me = t || "all";
2003
+ function be(t) {
2004
+ ye = t || "all";
2005
2005
  }
2006
2006
  function at() {
2007
- return me || "all";
2007
+ return ye || "all";
2008
2008
  }
2009
2009
  function po() {
2010
2010
  return k.slice(0);
@@ -2052,34 +2052,34 @@ function wo(t, e) {
2052
2052
  let {
2053
2053
  element: s
2054
2054
  } = a;
2055
- return Vt(s);
2055
+ return Dt(s);
2056
2056
  }) : o++;
2057
- at() === t && ye(e || "all");
2057
+ at() === t && be(e || "all");
2058
2058
  }
2059
2059
  function vo(t) {
2060
2060
  let e = t.keyCode || t.which || t.charCode;
2061
2061
  const n = k.indexOf(e);
2062
2062
  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) {
2063
2063
  D[e] = !1;
2064
- for (const o in j) j[o] === e && (P[o] = !1);
2064
+ for (const o in j) j[o] === e && (X[o] = !1);
2065
2065
  }
2066
2066
  }
2067
- function be(t) {
2067
+ function we(t) {
2068
2068
  if (typeof t > "u")
2069
2069
  Object.keys(I).forEach((i) => {
2070
- Array.isArray(I[i]) && I[i].forEach((r) => pt(r)), delete I[i];
2071
- }), Vt(null);
2070
+ Array.isArray(I[i]) && I[i].forEach((r) => gt(r)), delete I[i];
2071
+ }), Dt(null);
2072
2072
  else if (Array.isArray(t))
2073
2073
  t.forEach((i) => {
2074
- i.key && pt(i);
2074
+ i.key && gt(i);
2075
2075
  });
2076
2076
  else if (typeof t == "object")
2077
- t.key && pt(t);
2077
+ t.key && gt(t);
2078
2078
  else if (typeof t == "string") {
2079
2079
  for (var e = arguments.length, n = new Array(e > 1 ? e - 1 : 0), o = 1; o < e; o++)
2080
2080
  n[o - 1] = arguments[o];
2081
2081
  let [i, r] = n;
2082
- typeof i == "function" && (r = i, i = ""), pt({
2082
+ typeof i == "function" && (r = i, i = ""), gt({
2083
2083
  key: t,
2084
2084
  scope: i,
2085
2085
  method: r,
@@ -2087,25 +2087,25 @@ function be(t) {
2087
2087
  });
2088
2088
  }
2089
2089
  }
2090
- const pt = (t) => {
2090
+ const gt = (t) => {
2091
2091
  let {
2092
2092
  key: e,
2093
2093
  scope: n,
2094
2094
  method: o,
2095
2095
  splitKey: i = "+"
2096
2096
  } = t;
2097
- ge(e).forEach((a) => {
2097
+ me(e).forEach((a) => {
2098
2098
  const s = a.split(i), l = s.length, f = s[l - 1], g = f === "*" ? "*" : ct(f);
2099
2099
  if (!I[g]) return;
2100
2100
  n || (n = at());
2101
- const c = l > 1 ? pe(j, s) : [], p = [];
2101
+ const c = l > 1 ? ge(j, s) : [], p = [];
2102
2102
  I[g] = I[g].filter((u) => {
2103
2103
  const b = (o ? u.method === o : !0) && u.scope === n && uo(u.mods, c);
2104
2104
  return b && p.push(u.element), !b;
2105
- }), p.forEach((u) => Vt(u));
2105
+ }), p.forEach((u) => Dt(u));
2106
2106
  });
2107
2107
  };
2108
- function te(t, e, n, o) {
2108
+ function ee(t, e, n, o) {
2109
2109
  if (e.element !== o)
2110
2110
  return;
2111
2111
  let i;
@@ -2116,26 +2116,26 @@ function te(t, e, n, o) {
2116
2116
  (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)));
2117
2117
  }
2118
2118
  }
2119
- function ee(t, e) {
2119
+ function ne(t, e) {
2120
2120
  const n = I["*"];
2121
2121
  let o = t.keyCode || t.which || t.charCode;
2122
- if (!P.filter.call(this, t)) return;
2122
+ if (!X.filter.call(this, t)) return;
2123
2123
  if ((o === 93 || o === 224) && (o = 91), k.indexOf(o) === -1 && o !== 229 && k.push(o), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach((s) => {
2124
- const l = kt[s];
2124
+ const l = Nt[s];
2125
2125
  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))));
2126
2126
  }), o in D) {
2127
2127
  D[o] = !0;
2128
2128
  for (const s in j)
2129
- j[s] === o && (P[s] = !0);
2129
+ j[s] === o && (X[s] = !0);
2130
2130
  if (!n) return;
2131
2131
  }
2132
2132
  for (const s in D)
2133
- Object.prototype.hasOwnProperty.call(D, s) && (D[s] = t[kt[s]]);
2133
+ Object.prototype.hasOwnProperty.call(D, s) && (D[s] = t[Nt[s]]);
2134
2134
  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);
2135
2135
  const i = at();
2136
2136
  if (n)
2137
2137
  for (let s = 0; s < n.length; s++)
2138
- n[s].scope === i && (t.type === "keydown" && n[s].keydown || t.type === "keyup" && n[s].keyup) && te(t, n[s], i, e);
2138
+ n[s].scope === i && (t.type === "keydown" && n[s].keydown || t.type === "keyup" && n[s].keyup) && ee(t, n[s], i, e);
2139
2139
  if (!(o in I)) return;
2140
2140
  const r = I[o], a = r.length;
2141
2141
  for (let s = 0; s < a; s++)
@@ -2145,15 +2145,15 @@ function ee(t, e) {
2145
2145
  } = l, g = l.key.split(f), c = [];
2146
2146
  for (let p = 0; p < g.length; p++)
2147
2147
  c.push(ct(g[p]));
2148
- c.sort().join("") === k.sort().join("") && te(t, l, i, e);
2148
+ c.sort().join("") === k.sort().join("") && ee(t, l, i, e);
2149
2149
  }
2150
2150
  }
2151
- function P(t, e, n) {
2151
+ function X(t, e, n) {
2152
2152
  k = [];
2153
- const o = ge(t);
2153
+ const o = me(t);
2154
2154
  let i = [], r = "all", a = document, s = 0, l = !1, f = !0, g = "+", c = !1, p = !1;
2155
- 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 && (f = 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++)
2156
- 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({
2155
+ 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 && (f = 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 && we(t, r); s < o.length; s++)
2156
+ t = o[s].split(g), i = [], t.length > 1 && (i = ge(j, t)), t = t[t.length - 1], t = t === "*" ? "*" : ct(t), t in I || (I[t] = []), I[t].push({
2157
2157
  keyup: l,
2158
2158
  keydown: f,
2159
2159
  scope: r,
@@ -2168,16 +2168,16 @@ function P(t, e, n) {
2168
2168
  if (!F.has(a)) {
2169
2169
  const u = function() {
2170
2170
  let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2171
- return ee(b, a);
2171
+ return ne(b, a);
2172
2172
  }, x = function() {
2173
2173
  let b = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : window.event;
2174
- ee(b, a), vo(b);
2174
+ ne(b, a), vo(b);
2175
2175
  };
2176
2176
  F.set(a, {
2177
2177
  keydownListener: u,
2178
2178
  keyupListenr: x,
2179
2179
  capture: c
2180
- }), Tt(a, "keydown", u, c), Tt(a, "keyup", x, c);
2180
+ }), Rt(a, "keydown", u, c), Rt(a, "keyup", x, c);
2181
2181
  }
2182
2182
  if (!rt) {
2183
2183
  const u = () => {
@@ -2186,7 +2186,7 @@ function P(t, e, n) {
2186
2186
  rt = {
2187
2187
  listener: u,
2188
2188
  capture: c
2189
- }, Tt(window, "focus", u, c);
2189
+ }, Rt(window, "focus", u, c);
2190
2190
  }
2191
2191
  }
2192
2192
  }
@@ -2198,7 +2198,7 @@ function xo(t) {
2198
2198
  });
2199
2199
  });
2200
2200
  }
2201
- function Vt(t) {
2201
+ function Dt(t) {
2202
2202
  const e = Object.values(I).flat();
2203
2203
  if (e.findIndex((o) => {
2204
2204
  let {
@@ -2228,9 +2228,9 @@ function Vt(t) {
2228
2228
  et(window, "focus", i, r), rt = null;
2229
2229
  }
2230
2230
  }
2231
- const Rt = {
2231
+ const Bt = {
2232
2232
  getPressedKeyString: go,
2233
- setScope: ye,
2233
+ setScope: be,
2234
2234
  getScope: at,
2235
2235
  deleteScope: wo,
2236
2236
  getPressedKeyCodes: po,
@@ -2238,61 +2238,61 @@ const Rt = {
2238
2238
  isPressed: bo,
2239
2239
  filter: yo,
2240
2240
  trigger: xo,
2241
- unbind: be,
2241
+ unbind: we,
2242
2242
  keyMap: st,
2243
2243
  modifier: j,
2244
- modifierMap: kt
2244
+ modifierMap: Nt
2245
2245
  };
2246
- for (const t in Rt)
2247
- Object.prototype.hasOwnProperty.call(Rt, t) && (P[t] = Rt[t]);
2246
+ for (const t in Bt)
2247
+ Object.prototype.hasOwnProperty.call(Bt, t) && (X[t] = Bt[t]);
2248
2248
  if (typeof window < "u") {
2249
2249
  const t = window.hotkeys;
2250
- P.noConflict = (e) => (e && window.hotkeys === P && (window.hotkeys = t), P), window.hotkeys = P;
2250
+ X.noConflict = (e) => (e && window.hotkeys === X && (window.hotkeys = t), X), window.hotkeys = X;
2251
2251
  }
2252
2252
  const Ao = (t, e, n) => {
2253
2253
  let o;
2254
- const i = (w) => o = w;
2254
+ const i = (S) => o = S;
2255
2255
  let r;
2256
- const a = (w) => r = w;
2256
+ const a = (S) => r = S;
2257
2257
  let s = !0;
2258
- const l = (w) => {
2259
- s = w, b.clear(), w || (c = void 0, p = void 0, u = void 0);
2258
+ const l = (S) => {
2259
+ s = S, b.clear(), S || (c = void 0, p = void 0, u = void 0);
2260
2260
  }, { store: f, selection: g } = e;
2261
2261
  let c, p, u;
2262
- const x = (w) => {
2263
- var B;
2262
+ const x = (S) => {
2263
+ var O;
2264
2264
  if (!s || p === !1)
2265
2265
  return;
2266
- c = !((B = w.target.parentElement) != null && B.closest(H)) ? {
2267
- annotation: ae(),
2266
+ c = !((O = S.target.parentElement) != null && O.closest(H)) ? {
2267
+ annotation: ce(),
2268
2268
  selector: [],
2269
2269
  creator: o,
2270
2270
  created: /* @__PURE__ */ new Date()
2271
2271
  } : void 0;
2272
2272
  };
2273
2273
  t.addEventListener("selectstart", x);
2274
- const b = It((w) => {
2275
- var C, R;
2274
+ const b = _t((S) => {
2275
+ var T, N;
2276
2276
  if (!s) return;
2277
- const O = document.getSelection();
2278
- if (!!((R = (C = O.anchorNode) == null ? void 0 : C.parentElement) != null && R.closest(H))) {
2277
+ const R = document.getSelection();
2278
+ if (!!((N = (T = R.anchorNode) == null ? void 0 : T.parentElement) != null && N.closest(H))) {
2279
2279
  c = void 0;
2280
2280
  return;
2281
2281
  }
2282
- if (w.timeStamp - ((u == null ? void 0 : u.timeStamp) || w.timeStamp) < 1e3 && !c && x(u || w), !c) return;
2283
- if (O.isCollapsed) {
2282
+ if (S.timeStamp - ((u == null ? void 0 : u.timeStamp) || S.timeStamp) < 1e3 && !c && x(u || S), !c) return;
2283
+ if (R.isCollapsed) {
2284
2284
  f.getAnnotation(c.annotation) && (g.clear(), f.deleteAnnotation(c.annotation));
2285
2285
  return;
2286
2286
  }
2287
- const T = O.getRangeAt(0), m = Pn(T, t);
2288
- if (Vn(m)) return;
2289
- const A = Bn(m.cloneRange());
2290
- (A.length !== c.selector.length || A.some((N, $) => {
2291
- var Y;
2292
- return N.toString() !== ((Y = c.selector[$]) == null ? void 0 : Y.quote);
2287
+ const m = R.getRangeAt(0), w = Pn(m, t);
2288
+ if (Vn(w)) return;
2289
+ const E = Bn(w.cloneRange());
2290
+ (E.length !== c.selector.length || E.some((K, P) => {
2291
+ var lt;
2292
+ return K.toString() !== ((lt = c.selector[P]) == null ? void 0 : lt.quote);
2293
2293
  })) && (c = {
2294
2294
  ...c,
2295
- selector: A.map((N) => Xn(N, t, n)),
2295
+ selector: E.map((K) => Xn(K, t, n)),
2296
2296
  updated: /* @__PURE__ */ new Date()
2297
2297
  }, f.getAnnotation(c.annotation) ? f.updateTarget(c, M.LOCAL) : (g.clear(), f.addAnnotation({
2298
2298
  id: c.annotation,
@@ -2301,69 +2301,71 @@ const Ao = (t, e, n) => {
2301
2301
  }, M.LOCAL), g.userSelect(c.annotation, u)));
2302
2302
  }, 10);
2303
2303
  document.addEventListener("selectionchange", b);
2304
- const v = (w) => {
2305
- u = Hn(w), p = u.button === 0, c = void 0;
2304
+ const v = (S) => {
2305
+ u = Hn(S), p = u.button === 0, c = void 0;
2306
2306
  };
2307
2307
  document.addEventListener("pointerdown", v);
2308
- const h = (w) => {
2309
- var T;
2310
- if (!!((T = w.target.parentElement) != null && T.closest(H)) || !p)
2308
+ const h = (S) => {
2309
+ var m;
2310
+ if (!!((m = S.target.parentElement) != null && m.closest(H)) || !p)
2311
2311
  return;
2312
- const B = () => {
2313
- const { x: m, y: A } = t.getBoundingClientRect(), S = w.target instanceof Node && t.contains(w.target) && f.getAt(w.clientX - m, w.clientY - A, r);
2314
- if (S) {
2315
- const { selected: C } = g;
2316
- (C.length !== 1 || C[0].id !== S.id) && g.userSelect(S.id, w);
2312
+ const O = () => {
2313
+ const { x: w, y: E } = t.getBoundingClientRect(), L = S.target instanceof Node && t.contains(S.target) && f.getAt(S.clientX - w, S.clientY - E, r);
2314
+ if (L) {
2315
+ const { selected: T } = g;
2316
+ (T.length !== 1 || T[0].id !== L.id) && g.userSelect(L.id, S);
2317
2317
  } else g.isEmpty() || g.clear();
2318
- }, L = w.timeStamp - u.timeStamp;
2318
+ }, B = S.timeStamp - u.timeStamp;
2319
2319
  setTimeout(() => {
2320
- const m = document.getSelection();
2321
- m != null && m.isCollapsed && L < 300 ? B() : c && g.userSelect(c.annotation, w);
2320
+ const w = document.getSelection();
2321
+ w != null && w.isCollapsed && B < 300 ? O() : c && g.userSelect(c.annotation, S);
2322
2322
  });
2323
2323
  };
2324
2324
  document.addEventListener("pointerup", h);
2325
2325
  const d = ["up", "down", "left", "right"], y = [
2326
- ...d.map((w) => `shift+${w}`),
2326
+ ...d.map((S) => `shift+${S}`),
2327
2327
  "ctrl+a",
2328
2328
  "⌘+a"
2329
2329
  ];
2330
- return P(y.join(","), { element: t, keydown: !0, keyup: !1 }, (w) => {
2331
- w.repeat || (u = jn(w));
2332
- }), P(d.join(","), { element: t, keydown: !0, keyup: !1 }, (w) => {
2333
- w.repeat || (c = void 0, g.clear());
2334
- }), {
2330
+ X(y.join(","), { element: t, keydown: !0, keyup: !1 }, (S) => {
2331
+ S.repeat || (u = jn(S));
2332
+ });
2333
+ const A = (S) => {
2334
+ S.repeat || (c = void 0, g.clear());
2335
+ };
2336
+ return X(d.join(","), { element: document.body, keydown: !0, keyup: !1 }, A), X(d.join(","), { element: t, keydown: !0, keyup: !1 }, A), {
2335
2337
  destroy: () => {
2336
- c = void 0, p = void 0, u = void 0, b.clear(), t.removeEventListener("selectstart", x), document.removeEventListener("selectionchange", b), document.removeEventListener("pointerdown", v), document.removeEventListener("pointerup", h), P.unbind();
2338
+ c = void 0, p = void 0, u = void 0, b.clear(), t.removeEventListener("selectstart", x), document.removeEventListener("selectionchange", b), document.removeEventListener("pointerdown", v), document.removeEventListener("pointerup", h), X.unbind();
2337
2339
  },
2338
2340
  setFilter: a,
2339
2341
  setUser: i,
2340
2342
  setAnnotatingEnabled: l
2341
2343
  };
2342
- }, ne = "SPANS", Ro = (t, e = {}) => {
2344
+ }, oe = "SPANS", Ro = (t, e = {}) => {
2343
2345
  Mn(t), kn(t);
2344
2346
  const n = lo(e, {
2345
2347
  annotatingEnabled: !0,
2346
2348
  user: Sn()
2347
2349
  }), o = ro(t, n.userSelectAction), { selection: i, viewport: r } = o, a = o.store, s = pn(a), l = mn(o, s, n.adapter);
2348
2350
  let f = n.user;
2349
- 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;
2351
+ const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : oe : n.renderer || oe, c = g === "SPANS" ? $e(t, o, r) : g === "CSS_HIGHLIGHTS" ? Ye(t, o, r) : g === "CANVAS" ? Be(t, o, r) : void 0;
2350
2352
  if (!c)
2351
2353
  throw `Unknown renderer implementation: ${g}`;
2352
2354
  console.debug(`Using ${g} renderer`), n.style && c.setStyle(n.style);
2353
2355
  const p = Ao(t, o, n.offsetReferenceSelector);
2354
2356
  p.setUser(f), p.setAnnotatingEnabled(n.annotatingEnabled);
2355
- const u = bn(o, s, n.adapter), x = () => f, b = (w) => {
2357
+ const u = bn(o, s, n.adapter), x = () => f, b = (C) => {
2356
2358
  p.setAnnotatingEnabled(
2357
- w === void 0 ? !0 : w
2359
+ C === void 0 ? !0 : C
2358
2360
  );
2359
- }, v = (w) => {
2360
- c.setFilter(w), p.setFilter(w);
2361
- }, h = (w) => {
2362
- f = w, p.setUser(w);
2363
- }, d = (w) => {
2364
- w && (c.setPainter(ao(t, w, n.presence)), w.on("selectionChange", () => c.redraw()));
2365
- }, y = (w) => {
2366
- w ? i.setSelected(w) : i.clear();
2361
+ }, v = (C) => {
2362
+ c.setFilter(C), p.setFilter(C);
2363
+ }, h = (C) => {
2364
+ f = C, p.setUser(C);
2365
+ }, d = (C) => {
2366
+ C && (c.setPainter(ao(t, C, n.presence)), C.on("selectionChange", () => c.redraw()));
2367
+ }, y = (C) => {
2368
+ C ? i.setSelected(C) : i.clear();
2367
2369
  };
2368
2370
  return {
2369
2371
  ...u,
@@ -2387,9 +2389,9 @@ const Ao = (t, e, n) => {
2387
2389
  };
2388
2390
  };
2389
2391
  export {
2390
- gt as DEFAULT_SELECTED_STYLE,
2392
+ mt as DEFAULT_SELECTED_STYLE,
2391
2393
  q as DEFAULT_STYLE,
2392
- de as NOT_ANNOTATABLE_CLASS,
2394
+ ue as NOT_ANNOTATABLE_CLASS,
2393
2395
  H as NOT_ANNOTATABLE_SELECTOR,
2394
2396
  M as Origin,
2395
2397
  Ge as UserSelectAction,
@@ -2399,8 +2401,8 @@ export {
2399
2401
  Hn as clonePointerEvent,
2400
2402
  Eo as createBody,
2401
2403
  Be as createCanvasRenderer,
2402
- Ke as createHighlightsRenderer,
2403
- Ye as createRenderer,
2404
+ Ye as createHighlightsRenderer,
2405
+ Ke as createRenderer,
2404
2406
  $e as createSpansRenderer,
2405
2407
  Ro as createTextAnnotator,
2406
2408
  ro as createTextAnnotatorState,
@@ -2409,18 +2411,18 @@ export {
2409
2411
  So as getAnnotatableFragment,
2410
2412
  Co as getClientRectsPonyfill,
2411
2413
  _n as getQuoteContext,
2412
- Mt as getRangeAnnotatableContents,
2414
+ kt as getRangeAnnotatableContents,
2413
2415
  W as isRevived,
2414
2416
  Vn as isWhitespaceOrEmpty,
2415
- Kn as mergeClientRects,
2417
+ Yn as mergeClientRects,
2416
2418
  $n as normalizeRectWithOffset,
2417
2419
  Ae as paint,
2418
2420
  Wn as parseW3CTextAnnotation,
2419
2421
  kn as programmaticallyFocusable,
2420
2422
  Xn as rangeToSelector,
2421
- St as reviveAnnotation,
2422
- ue as reviveSelector,
2423
- mt as reviveTarget,
2423
+ Ct as reviveAnnotation,
2424
+ fe as reviveSelector,
2425
+ yt as reviveTarget,
2424
2426
  qn as serializeW3CTextAnnotation,
2425
2427
  Bn as splitAnnotatableRanges,
2426
2428
  Lo as toDomRectList,