@recogito/text-annotator 3.0.0-rc.35 → 3.0.0-rc.37

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,10 +4,10 @@ const P = {
4
4
  }, ot = {
5
5
  fill: "rgb(0, 128, 255)",
6
6
  fillOpacity: 0.45
7
- }, Kt = (t, e, n, o, i) => {
8
- var c, s;
9
- const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((c = t.state) != null && c.selected ? ot : P) : n : (s = t.state) != null && s.selected ? ot : P;
10
- return o && o.paint(t, e) || r;
7
+ }, Kt = (t, e, n, o, r) => {
8
+ var s, a;
9
+ const i = n ? typeof n == "function" ? n(t.annotation, t.state, r) || ((s = t.state) != null && s.selected ? ot : P) : n : (a = t.state) != null && a.selected ? ot : P;
10
+ return o && o.paint(t, e) || i;
11
11
  }, Yt = "not-annotatable", D = `.${Yt}`, Qt = (t) => {
12
12
  var n;
13
13
  const e = t.commonAncestorContainer;
@@ -26,8 +26,8 @@ const P = {
26
26
  const e = [];
27
27
  let n = null;
28
28
  for (const o of Jt(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;
29
+ let r;
30
+ n ? (r = document.createRange(), r.setStartAfter(n), r.setEndBefore(o)) : (r = t.cloneRange(), r.setEndBefore(o)), r.collapsed || e.push(r), n = o;
31
31
  }
32
32
  if (n) {
33
33
  const o = t.cloneRange();
@@ -52,16 +52,16 @@ const P = {
52
52
  return e.querySelectorAll(D).forEach((n) => n.remove()), e;
53
53
  }, wt = (t, e) => {
54
54
  const n = document.createNodeIterator(e);
55
- let o = 0, i = n.nextNode();
56
- for (; i !== null; ) {
57
- if (i === t)
55
+ let o = 0, r = n.nextNode();
56
+ for (; r !== null; ) {
57
+ if (r === t)
58
58
  return o;
59
- o += 1, i = n.nextNode();
59
+ o += 1, r = n.nextNode();
60
60
  }
61
61
  }, xt = (t, e) => {
62
62
  const n = document.createNodeIterator(e);
63
63
  let o = null;
64
- for (let i = 0; i < t + 1; i++)
64
+ for (let r = 0; r < t + 1; r++)
65
65
  o = n.nextNode();
66
66
  return o;
67
67
  }, ee = (t) => {
@@ -69,259 +69,252 @@ const P = {
69
69
  commonAncestorContainer: e,
70
70
  startContainer: n,
71
71
  startOffset: o,
72
- endContainer: i,
73
- endOffset: r
74
- } = t, c = Array.from(e.childNodes).map((l) => {
75
- const g = l.cloneNode(!0);
76
- return l.nodeName === "CANVAS" ? l : g;
77
- }), s = wt(n, e), u = wt(i, e), h = () => {
78
- const l = e;
79
- l.replaceChildren(...c);
80
- const g = xt(s, l), f = xt(u, l);
81
- return t.setStart(g, o), t.setEnd(f, r), t;
82
- }, m = (l) => {
83
- const g = document.createElement("SPAN");
84
- return l.surroundContents(g), g;
72
+ endContainer: r,
73
+ endOffset: i
74
+ } = t, s = Array.from(e.childNodes).map((d) => {
75
+ const m = d.cloneNode(!0);
76
+ return d.nodeName === "CANVAS" ? d : m;
77
+ }), a = wt(n, e), u = wt(r, e), f = () => {
78
+ const d = e;
79
+ d.replaceChildren(...s);
80
+ const m = xt(a, d), h = xt(u, d);
81
+ return t.setStart(m, o), t.setEnd(h, i), t;
82
+ }, g = (d) => {
83
+ const m = document.createElement("SPAN");
84
+ return d.surroundContents(m), m;
85
85
  };
86
- if (n === i)
86
+ if (n === r)
87
87
  throw "Not implemented";
88
88
  {
89
- const l = document.createRange();
90
- l.selectNodeContents(n), l.setStart(n, o);
91
- const g = m(l), f = document.createRange();
92
- f.selectNode(i), f.setEnd(i, r);
93
- const w = m(f), p = ne(t).reverse().map((d) => {
94
- var y;
95
- const a = document.createElement("SPAN");
96
- return (y = d.parentNode) == null || y.insertBefore(a, d), a.appendChild(d), a;
89
+ const d = document.createRange();
90
+ d.selectNodeContents(n), d.setStart(n, o);
91
+ const m = g(d), h = document.createRange();
92
+ h.selectNode(r), h.setEnd(r, i);
93
+ const w = g(h), p = ne(t).reverse().map((l) => {
94
+ var b;
95
+ const c = document.createElement("SPAN");
96
+ return (b = l.parentNode) == null || b.insertBefore(c, l), c.appendChild(l), c;
97
97
  });
98
- return { unwrap: h, nodes: [g, ...p, w] };
98
+ return { unwrap: f, nodes: [m, ...p, w] };
99
99
  }
100
100
  }, ne = (t) => {
101
101
  const {
102
102
  commonAncestorContainer: e,
103
103
  startContainer: n,
104
104
  endContainer: o
105
- } = t, i = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);
106
- let r = i.nextNode(), c = !1;
107
- const s = [];
108
- for (; r != null; )
109
- r === o && (c = !1), c && s.push(r), r === n && (c = !0), r = i.nextNode();
110
- return s;
105
+ } = t, r = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);
106
+ let i = r.nextNode(), s = !1;
107
+ const a = [];
108
+ for (; i != null; )
109
+ i === o && (s = !1), s && a.push(i), i === n && (s = !0), i = r.nextNode();
110
+ return a;
111
111
  }, In = (t) => {
112
112
  const { startContainer: e, endContainer: n } = t;
113
113
  if (e === n)
114
114
  return Array.from(t.getClientRects());
115
115
  {
116
- const { unwrap: o, nodes: i } = ee(t), r = i.reduce((c, s) => [...c, ...s.getClientRects()], []);
117
- return o(), r;
116
+ const { unwrap: o, nodes: r } = ee(t), i = r.reduce((s, a) => [...s, ...a.getClientRects()], []);
117
+ return o(), i;
118
118
  }
119
119
  }, oe = (t, e, n = 10, o) => {
120
- const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
121
- r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
122
- const c = pt(r).textContent, s = document.createRange();
123
- s.setStart(t.endContainer, t.endOffset), i === document.body ? s.setEnd(i, i.childNodes.length) : s.setEndAfter(i);
124
- const u = pt(s).textContent;
120
+ const r = o ? t.startContainer.parentElement.closest(o) : e, i = document.createRange();
121
+ i.setStart(r, 0), i.setEnd(t.startContainer, t.startOffset);
122
+ const s = pt(i).textContent, a = document.createRange();
123
+ a.setStart(t.endContainer, t.endOffset), r === document.body ? a.setEnd(r, r.childNodes.length) : a.setEndAfter(r);
124
+ const u = pt(a).textContent;
125
125
  return {
126
- prefix: c.substring(c.length - n),
126
+ prefix: s.substring(s.length - n),
127
127
  suffix: u.substring(0, n)
128
128
  };
129
- }, ie = /^\s*$/, re = (t) => ie.test(t.toString()), $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), se = (t, e) => {
130
- const n = (r) => Math.round(r * 10) / 10, o = {
129
+ }, re = /^\s*$/, ie = (t) => re.test(t.toString()), $ = (t) => t.every((e) => e.range instanceof Range && !e.range.collapsed), se = (t, e) => {
130
+ const n = (i) => Math.round(i * 10) / 10, o = {
131
131
  top: n(t.top),
132
132
  bottom: n(t.bottom),
133
133
  left: n(t.left),
134
134
  right: n(t.right)
135
- }, i = {
135
+ }, r = {
136
136
  top: n(e.top),
137
137
  bottom: n(e.bottom),
138
138
  left: n(e.left),
139
139
  right: n(e.right)
140
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)
141
+ if (Math.abs(o.top - r.top) < 0.5 && Math.abs(o.bottom - r.bottom) < 0.5) {
142
+ if (Math.abs(o.left - r.right) < 0.5 || Math.abs(o.right - r.left) < 0.5)
143
143
  return "inline-adjacent";
144
- if (o.left >= i.left && o.right <= i.right)
144
+ if (o.left >= r.left && o.right <= r.right)
145
145
  return "inline-is-contained";
146
- if (o.left <= i.left && o.right >= i.right)
146
+ if (o.left <= r.left && o.right >= r.right)
147
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)
148
+ } else if (o.top <= r.top && o.bottom >= r.bottom) {
149
+ if (o.left <= r.left && o.right >= r.right)
150
150
  return "block-contains";
151
- } else if (o.top >= i.top && o.bottom <= i.bottom && o.left >= i.left && o.right <= i.right)
151
+ } else if (o.top >= r.top && o.bottom <= r.bottom && o.left >= r.left && o.right <= r.right)
152
152
  return "block-is-contained";
153
153
  }, ae = (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), r = Math.max(t.bottom, e.bottom);
155
- return new DOMRect(n, i, o - n, r - i);
154
+ const n = Math.min(t.left, e.left), o = Math.max(t.right, e.right), r = Math.min(t.top, e.top), i = Math.max(t.bottom, e.bottom);
155
+ return new DOMRect(n, r, o - n, i - r);
156
156
  }, ce = (t) => t.reduce((e, n) => {
157
157
  if (n.width === 0 || n.height === 0)
158
158
  return e;
159
- let o = [...e], i = !1;
160
- for (const r of e) {
161
- const c = se(n, r);
162
- if (c === "inline-adjacent") {
163
- o = o.map((s) => s === r ? ae(n, r) : s), i = !0;
159
+ let o = [...e], r = !1;
160
+ for (const i of e) {
161
+ const s = se(n, i);
162
+ if (s === "inline-adjacent") {
163
+ o = o.map((a) => a === i ? ae(n, i) : a), r = !0;
164
164
  break;
165
- } else if (c === "inline-contains") {
166
- o = o.map((s) => s === r ? n : s), i = !0;
165
+ } else if (s === "inline-contains") {
166
+ o = o.map((a) => a === i ? n : a), r = !0;
167
167
  break;
168
- } else if (c === "inline-is-contained") {
169
- i = !0;
168
+ } else if (s === "inline-is-contained") {
169
+ r = !0;
170
170
  break;
171
- } else if (c === "block-contains" || c === "block-is-contained") {
172
- n.width < r.width && (o = o.map((s) => s === r ? n : s)), i = !0;
171
+ } else if (s === "block-contains" || s === "block-is-contained") {
172
+ n.width < i.width && (o = o.map((a) => a === i ? n : a)), r = !0;
173
173
  break;
174
174
  }
175
175
  }
176
- return i ? o : [...o, n];
176
+ return r ? o : [...o, n];
177
177
  }, []), le = (t, e, n) => {
178
- const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
179
- o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
180
- const r = pt(o).textContent, c = t.toString(), s = r.length || 0, u = s + c.length;
181
- return n ? { quote: c, start: s, end: u, range: t, offsetReference: i } : { quote: c, start: s, end: u, range: t };
178
+ const o = document.createRange(), r = n ? t.startContainer.parentElement.closest(n) : e;
179
+ o.setStart(r, 0), o.setEnd(t.startContainer, t.startOffset);
180
+ const i = pt(o).textContent, s = t.toString(), a = i.length || 0, u = a + s.length;
181
+ return n ? { quote: s, start: a, end: u, range: t, offsetReference: r } : { quote: s, start: a, end: u, range: t };
182
182
  }, Dt = (t, e) => {
183
- var m, l;
184
- const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
183
+ var g, d;
184
+ const { start: n, end: o } = t, r = t.offsetReference || e, i = document.createNodeIterator(
185
185
  e,
186
186
  NodeFilter.SHOW_TEXT,
187
- (g) => {
188
- var f;
189
- return (f = g.parentElement) != null && f.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
187
+ (m) => {
188
+ var h;
189
+ return (h = m.parentElement) != null && h.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
190
190
  }
191
191
  );
192
- let c = 0;
193
- const s = document.createRange();
194
- let u = r.nextNode();
192
+ let s = 0;
193
+ const a = document.createRange();
194
+ let u = i.nextNode();
195
195
  u === null && console.error("Could not revive annotation target. Content missing.");
196
- let h = !i;
196
+ let f = !r;
197
197
  for (; u !== null; ) {
198
- if (h || (h = i == null ? void 0 : i.contains(u)), h) {
199
- const g = ((m = u.textContent) == null ? void 0 : m.length) || 0;
200
- if (c + g > n) {
201
- s.setStart(u, n - c);
198
+ if (f || (f = r == null ? void 0 : r.contains(u)), f) {
199
+ const m = ((g = u.textContent) == null ? void 0 : g.length) || 0;
200
+ if (s + m > n) {
201
+ a.setStart(u, n - s);
202
202
  break;
203
203
  }
204
- c += g;
204
+ s += m;
205
205
  }
206
- u = r.nextNode();
206
+ u = i.nextNode();
207
207
  }
208
208
  for (; u !== null; ) {
209
- const g = ((l = u.textContent) == null ? void 0 : l.length) || 0;
210
- if (c + g >= o) {
211
- s.setEnd(u, o - c);
209
+ const m = ((d = u.textContent) == null ? void 0 : d.length) || 0;
210
+ if (s + m >= o) {
211
+ a.setEnd(u, o - s);
212
212
  break;
213
213
  }
214
- c += g, u = r.nextNode();
214
+ s += m, u = i.nextNode();
215
215
  }
216
216
  return {
217
217
  ...t,
218
- range: s
218
+ range: a
219
219
  };
220
- }, it = (t, e) => $(t.selector) ? t : {
220
+ }, rt = (t, e) => $(t.selector) ? t : {
221
221
  ...t,
222
222
  selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Dt(n, e))
223
- }, rt = (t, e) => $(t.target.selector) ? t : { ...t, target: it(t.target, e) }, de = (t) => {
224
- const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, c = -e, s = o - n, u = i - e;
225
- return { top: e, left: n, minX: r, minY: c, maxX: s, maxY: u };
223
+ }, it = (t, e) => $(t.target.selector) ? t : { ...t, target: rt(t.target, e) }, de = (t) => {
224
+ const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: r } = window, i = -n, s = -e, a = o - n, u = r - e;
225
+ return { top: e, left: n, minX: i, minY: s, maxX: a, maxY: u };
226
226
  }, ue = (t) => {
227
227
  let e = /* @__PURE__ */ new Set();
228
228
  return (o) => {
229
- const i = o.map((r) => r.id);
230
- (e.size !== i.length || i.some((r) => !e.has(r))) && t.set(i), e = new Set(i);
229
+ const r = o.map((i) => i.id);
230
+ (e.size !== r.length || r.some((i) => !e.has(i))) && t.set(r), e = new Set(r);
231
231
  };
232
232
  }, vt = (t, e, n, o) => {
233
- const { store: i, selection: r, hover: c } = e;
234
- let s, u, h;
235
- const m = ue(n), l = (B) => {
236
- const { x: M, y: b } = t.getBoundingClientRect(), x = i.getAt(B.clientX - M, B.clientY - b, u);
237
- x ? c.current !== x.id && (t.classList.add("hovered"), c.set(x.id)) : c.current && (t.classList.remove("hovered"), c.set(null));
233
+ const { store: r, selection: i, hover: s } = e;
234
+ let a, u, f;
235
+ const g = ue(n), d = (B) => {
236
+ const { x: M, y: v } = t.getBoundingClientRect(), x = r.getAt(B.clientX - M, B.clientY - v, u);
237
+ x ? s.current !== x.id && (t.classList.add("hovered"), s.set(x.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
238
238
  };
239
- t.addEventListener("pointermove", l);
240
- const g = (B = !1) => {
241
- h && h.clear();
242
- const M = de(t), { minX: b, minY: x, maxX: A, maxY: C } = M, R = u ? i.getIntersecting(b, x, A, C).filter(({ annotation: _ }) => u(_)) : i.getIntersecting(b, x, A, C), O = r.selected.map(({ id: _ }) => _), H = R.map(({ annotation: _, rects: qt }) => {
243
- const jt = O.includes(_.id), Gt = _.id === c.current;
239
+ t.addEventListener("pointermove", d);
240
+ const m = (B = !1) => {
241
+ f && f.clear();
242
+ const M = de(t), { minX: v, minY: x, maxX: A, maxY: C } = M, R = u ? r.getIntersecting(v, x, A, C).filter(({ annotation: _ }) => u(_)) : r.getIntersecting(v, x, A, C), O = i.selected.map(({ id: _ }) => _), H = R.map(({ annotation: _, rects: qt }) => {
243
+ const jt = O.includes(_.id), Gt = _.id === s.current;
244
244
  return { annotation: _, rects: qt, state: { selected: jt, hover: Gt } };
245
245
  });
246
- o.redraw(H, M, s, h, B), setTimeout(() => m(R.map(({ annotation: _ }) => _)), 1);
247
- }, f = (B) => {
248
- h = B, g();
246
+ o.redraw(H, M, a, f, B), setTimeout(() => g(R.map(({ annotation: _ }) => _)), 1);
247
+ }, h = (B) => {
248
+ f = B, m();
249
249
  }, w = (B) => {
250
- s = B, g();
251
- }, v = (B) => {
252
- u = B, g(!1);
253
- }, p = () => g();
254
- i.observe(p);
255
- const d = r.subscribe(() => g()), a = () => g(!0);
256
- document.addEventListener("scroll", a, { capture: !0, passive: !0 });
257
- const y = bt(() => {
258
- i.recalculatePositions(), h && h.reset(), g();
250
+ a = B, m();
251
+ }, y = (B) => {
252
+ u = B, m(!1);
253
+ }, p = () => m();
254
+ r.observe(p);
255
+ const l = i.subscribe(() => m()), c = () => m(!0);
256
+ document.addEventListener("scroll", c, { capture: !0, passive: !0 });
257
+ const b = bt(() => {
258
+ r.recalculatePositions(), f && f.reset(), m();
259
259
  });
260
- window.addEventListener("resize", y);
261
- const S = new ResizeObserver(y);
260
+ window.addEventListener("resize", b);
261
+ const S = new ResizeObserver(b);
262
262
  S.observe(t);
263
263
  const L = { attributes: !0, childList: !0, subtree: !0 }, E = new MutationObserver((B) => {
264
- B.every((b) => b.target === t || t.contains(b.target)) || g(!0);
264
+ B.every((v) => v.target === t || t.contains(v.target)) || m(!0);
265
265
  });
266
266
  return E.observe(document.body, L), {
267
267
  destroy: () => {
268
- t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(p), d(), document.removeEventListener("scroll", a), window.removeEventListener("resize", y), S.disconnect(), E.disconnect();
268
+ t.removeEventListener("pointermove", d), o.destroy(), r.unobserve(p), l(), document.removeEventListener("scroll", c), window.removeEventListener("resize", b), S.disconnect(), E.disconnect();
269
269
  },
270
- redraw: g,
270
+ redraw: m,
271
271
  setStyle: w,
272
- setFilter: v,
273
- setPainter: f,
272
+ setFilter: y,
273
+ setPainter: h,
274
274
  setVisible: o.setVisible
275
275
  };
276
276
  }, he = () => {
277
277
  const t = document.createElement("canvas");
278
- return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-highlight-layer bg", t;
278
+ return t.width = window.innerWidth, t.height = window.innerHeight, t.className = "r6o-canvas-highlight-layer bg", t;
279
279
  }, fe = (t, e) => {
280
280
  t.width = window.innerWidth, t.height = window.innerHeight;
281
281
  }, ge = (t) => {
282
282
  t.classList.add("r6o-annotatable");
283
283
  const e = he(), n = e.getContext("2d");
284
- t.insertBefore(e, t.firstChild);
285
- const o = (s, u, h, m) => requestAnimationFrame(() => {
286
- const { width: l, height: g } = e;
287
- n.clearRect(-0.5, -0.5, l + 1, g + 1), m && m.clear();
288
- const { top: f, left: w } = u;
289
- [...s].sort((p, d) => {
290
- const { annotation: { target: { created: a } } } = p, { annotation: { target: { created: y } } } = d;
291
- return a.getTime() - y.getTime();
284
+ document.body.appendChild(e);
285
+ const o = (a, u, f, g) => requestAnimationFrame(() => {
286
+ const { width: d, height: m } = e;
287
+ n.clearRect(-0.5, -0.5, d + 1, m + 1), g && g.clear();
288
+ const { top: h, left: w } = u;
289
+ [...a].sort((p, l) => {
290
+ const { annotation: { target: { created: c } } } = p, { annotation: { target: { created: b } } } = l;
291
+ return c.getTime() - b.getTime();
292
292
  }).forEach((p) => {
293
- var L;
294
- const d = h ? typeof h == "function" ? h(p.annotation, p.state) : h : (L = p.state) != null && L.selected ? ot : P, a = m && m.paint(p, u) || d, y = p.rects.map(({ x: E, y: T, width: B, height: M }) => ({
295
- x: E + w,
296
- y: T + f,
297
- width: B,
298
- height: M
293
+ var S;
294
+ const l = f ? typeof f == "function" ? f(p.annotation, p.state) : f : (S = p.state) != null && S.selected ? ot : P, c = g && g.paint(p, u) || l, b = p.rects.map(({ x: L, y: E, width: T, height: B }) => ({
295
+ x: L + w,
296
+ y: E + h,
297
+ width: T,
298
+ height: B
299
299
  }));
300
- n.fillStyle = a.fill, n.globalAlpha = a.fillOpacity || 1;
301
- const S = 5;
302
- if (y.forEach(
303
- ({ x: E, y: T, width: B, height: M }) => n.fillRect(
304
- E,
305
- T - S / 2,
306
- B,
307
- M + S
308
- )
309
- ), a.underlineColor) {
310
- n.globalAlpha = 1, n.strokeStyle = a.underlineColor, n.lineWidth = a.underlineThickness ?? 1;
311
- const E = S / 2 + (a.underlineOffset ?? 0);
312
- y.forEach(({ x: T, y: B, width: M, height: b }) => {
313
- n.beginPath(), n.moveTo(T, B + b + E), n.lineTo(T + M, B + b + E), n.stroke();
300
+ if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, b.forEach(
301
+ ({ x: L, y: E, width: T, height: B }) => n.fillRect(L, E, T, B)
302
+ ), c.underlineColor) {
303
+ n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
304
+ const L = c.underlineOffset ?? 0;
305
+ b.forEach(({ x: E, y: T, width: B, height: M }) => {
306
+ n.beginPath(), n.moveTo(E, T + M + L), n.lineTo(E + B, T + M + L), n.stroke();
314
307
  });
315
308
  }
316
309
  });
317
- }), i = bt(() => {
310
+ }), r = bt(() => {
318
311
  fe(e);
319
312
  });
320
- return window.addEventListener("resize", i), {
313
+ return window.addEventListener("resize", r), {
321
314
  destroy: () => {
322
- t.removeChild(e), window.removeEventListener("resize", i);
315
+ e.remove(), window.removeEventListener("resize", r);
323
316
  },
324
- setVisible: (s) => {
317
+ setVisible: (a) => {
325
318
  console.log("setVisible not implemented on Canvas renderer");
326
319
  },
327
320
  redraw: o
@@ -343,13 +336,13 @@ var me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
343
336
  var e = t.toString(16);
344
337
  return e.length < 2 ? "0" + e : e;
345
338
  }, Xt = function(t) {
346
- var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), c = r - Math.min(e, n, o), s = c ? r === e ? (n - o) / c : r === n ? 2 + (o - e) / c : 4 + (e - n) / c : 0;
347
- return { h: 60 * (s < 0 ? s + 6 : s), s: r ? c / r * 100 : 0, v: r / 255 * 100, a: i };
339
+ var e = t.r, n = t.g, o = t.b, r = t.a, i = Math.max(e, n, o), s = i - Math.min(e, n, o), a = s ? i === e ? (n - o) / s : i === n ? 2 + (o - e) / s : 4 + (e - n) / s : 0;
340
+ return { h: 60 * (a < 0 ? a + 6 : a), s: i ? s / i * 100 : 0, v: i / 255 * 100, a: r };
348
341
  }, $t = function(t) {
349
- var e = t.h, n = t.s, o = t.v, i = t.a;
342
+ var e = t.h, n = t.s, o = t.v, r = t.a;
350
343
  e = e / 360 * 6, n /= 100, o /= 100;
351
- var r = Math.floor(e), c = o * (1 - n), s = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), h = r % 6;
352
- return { r: 255 * [o, s, c, c, u, o][h], g: 255 * [u, o, o, s, c, c][h], b: 255 * [c, c, u, o, o, s][h], a: i };
344
+ var i = Math.floor(e), s = o * (1 - n), a = o * (1 - (e - i) * n), u = o * (1 - (1 - e + i) * n), f = i % 6;
345
+ return { r: 255 * [o, a, s, s, u, o][f], g: 255 * [u, o, o, a, s, s][f], b: 255 * [s, s, u, o, o, a][f], a: r };
353
346
  }, Et = function(t) {
354
347
  return { h: _t(t.h), s: k(t.s, 0, 100), l: k(t.l, 0, 100), a: k(t.a) };
355
348
  }, St = function(t) {
@@ -358,8 +351,8 @@ var me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
358
351
  return $t((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 }));
359
352
  var e, n, o;
360
353
  }, Q = function(t) {
361
- return { h: (e = Xt(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 };
362
- var e, n, o, i;
354
+ return { h: (e = Xt(t)).h, s: (r = (200 - (n = e.s)) * (o = e.v) / 100) > 0 && r < 200 ? n * o / 100 / (r <= 100 ? r : 200 - r) * 100 : 0, l: r / 2, a: e.a };
355
+ var e, n, o, r;
363
356
  }, ve = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, ye = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, we = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, xe = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Lt = { string: [[function(t) {
364
357
  var e = be.exec(t);
365
358
  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 ? I(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 ? I(parseInt(t.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
@@ -369,23 +362,23 @@ var me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
369
362
  }, "rgb"], [function(t) {
370
363
  var e = ve.exec(t) || ye.exec(t);
371
364
  if (!e) return null;
372
- var n, o, i = Et({ 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) });
373
- return Ct(i);
365
+ var n, o, r = Et({ 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) });
366
+ return Ct(r);
374
367
  }, "hsl"]], object: [[function(t) {
375
- var e = t.r, n = t.g, o = t.b, i = t.a, r = i === void 0 ? 1 : i;
376
- return X(e) && X(n) && X(o) ? At({ r: Number(e), g: Number(n), b: Number(o), a: Number(r) }) : null;
368
+ var e = t.r, n = t.g, o = t.b, r = t.a, i = r === void 0 ? 1 : r;
369
+ return X(e) && X(n) && X(o) ? At({ r: Number(e), g: Number(n), b: Number(o), a: Number(i) }) : null;
377
370
  }, "rgb"], [function(t) {
378
- var e = t.h, n = t.s, o = t.l, i = t.a, r = i === void 0 ? 1 : i;
371
+ var e = t.h, n = t.s, o = t.l, r = t.a, i = r === void 0 ? 1 : r;
379
372
  if (!X(e) || !X(n) || !X(o)) return null;
380
- var c = Et({ h: Number(e), s: Number(n), l: Number(o), a: Number(r) });
381
- return Ct(c);
373
+ var s = Et({ h: Number(e), s: Number(n), l: Number(o), a: Number(i) });
374
+ return Ct(s);
382
375
  }, "hsl"], [function(t) {
383
- var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
376
+ var e = t.h, n = t.s, o = t.v, r = t.a, i = r === void 0 ? 1 : r;
384
377
  if (!X(e) || !X(n) || !X(o)) return null;
385
- var c = function(s) {
386
- return { h: _t(s.h), s: k(s.s, 0, 100), v: k(s.v, 0, 100), a: k(s.a) };
387
- }({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
388
- return $t(c);
378
+ var s = function(a) {
379
+ return { h: _t(a.h), s: k(a.s, 0, 100), v: k(a.v, 0, 100), a: k(a.a) };
380
+ }({ h: Number(e), s: Number(n), v: Number(o), a: Number(i) });
381
+ return $t(s);
389
382
  }, "hsv"]] }, Bt = function(t, e) {
390
383
  for (var n = 0; n < e.length; n++) {
391
384
  var o = e[n][0](t);
@@ -415,18 +408,18 @@ var me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
415
408
  }, t.prototype.isLight = function() {
416
409
  return ct(this.rgba) >= 0.5;
417
410
  }, t.prototype.toHex = function() {
418
- return e = st(this.rgba), n = e.r, o = e.g, i = e.b, c = (r = e.a) < 1 ? J(I(255 * r)) : "", "#" + J(n) + J(o) + J(i) + c;
419
- var e, n, o, i, r, c;
411
+ return e = st(this.rgba), n = e.r, o = e.g, r = e.b, s = (i = e.a) < 1 ? J(I(255 * i)) : "", "#" + J(n) + J(o) + J(r) + s;
412
+ var e, n, o, r, i, s;
420
413
  }, t.prototype.toRgb = function() {
421
414
  return st(this.rgba);
422
415
  }, t.prototype.toRgbString = function() {
423
- return e = st(this.rgba), n = e.r, o = e.g, i = e.b, (r = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + i + ", " + r + ")" : "rgb(" + n + ", " + o + ", " + i + ")";
424
- var e, n, o, i, r;
416
+ return e = st(this.rgba), n = e.r, o = e.g, r = e.b, (i = e.a) < 1 ? "rgba(" + n + ", " + o + ", " + r + ", " + i + ")" : "rgb(" + n + ", " + o + ", " + r + ")";
417
+ var e, n, o, r, i;
425
418
  }, t.prototype.toHsl = function() {
426
419
  return St(Q(this.rgba));
427
420
  }, t.prototype.toHslString = function() {
428
- return e = St(Q(this.rgba)), n = e.h, o = e.s, i = e.l, (r = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + i + "%, " + r + ")" : "hsl(" + n + ", " + o + "%, " + i + "%)";
429
- var e, n, o, i, r;
421
+ return e = St(Q(this.rgba)), n = e.h, o = e.s, r = e.l, (i = e.a) < 1 ? "hsla(" + n + ", " + o + "%, " + r + "%, " + i + ")" : "hsl(" + n + ", " + o + "%, " + r + "%)";
422
+ var e, n, o, r, i;
430
423
  }, t.prototype.toHsv = function() {
431
424
  return e = Xt(this.rgba), { h: I(e.h), s: I(e.s), v: I(e.v), a: I(e.a, 3) };
432
425
  var e;
@@ -471,23 +464,23 @@ const Ee = (t) => [
471
464
  destroy: () => {
472
465
  CSS.highlights.clear(), t.remove();
473
466
  },
474
- setVisible: (r) => {
467
+ setVisible: (i) => {
475
468
  console.log("setVisible not implemented on CSS Custom Highlights renderer");
476
469
  },
477
- redraw: (r, c, s, u) => {
470
+ redraw: (i, s, a, u) => {
478
471
  u && u.clear();
479
- const h = new Set(r.map((l) => l.annotation.id));
480
- Array.from(e).filter((l) => !h.has(l));
481
- const m = r.map((l) => {
472
+ const f = new Set(i.map((d) => d.annotation.id));
473
+ Array.from(e).filter((d) => !f.has(d));
474
+ const g = i.map((d) => {
482
475
  var w;
483
- const g = s ? typeof s == "function" ? s(l.annotation, l.state) : s : (w = l.state) != null && w.selected ? ot : P, f = u && u.paint(l, c) || g;
484
- return `::highlight(_${l.annotation.id}) { ${Ee(f)} }`;
476
+ const m = a ? typeof a == "function" ? a(d.annotation, d.state) : a : (w = d.state) != null && w.selected ? ot : P, h = u && u.paint(d, s) || m;
477
+ return `::highlight(_${d.annotation.id}) { ${Ee(h)} }`;
485
478
  });
486
- t.innerHTML = m.join(`
487
- `), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
488
- const g = l.target.selector.map((w) => w.range), f = new Highlight(...g);
489
- CSS.highlights.set(`_${l.id}`, f);
490
- }), e = h;
479
+ t.innerHTML = g.join(`
480
+ `), CSS.highlights.clear(), i.forEach(({ annotation: d }) => {
481
+ const m = d.target.selector.map((w) => w.range), h = new Highlight(...m);
482
+ CSS.highlights.set(`_${d.id}`, h);
483
+ }), e = f;
491
484
  }
492
485
  };
493
486
  }, Ce = (t, e, n) => vt(t, e, n, Se());
@@ -513,8 +506,8 @@ function mt(t, e) {
513
506
  return t !== t && e !== e;
514
507
  }
515
508
  const Le = (t, e) => {
516
- const n = (o, i) => o.x <= i.x + i.width && o.x + o.width >= i.x && o.y <= i.y + i.height && o.y + o.height >= i.y;
517
- return e.filter((o) => t !== o && n(t, o) && o.width > t.width).length;
509
+ const n = (i, s) => i.x <= s.x + s.width && i.x + i.width >= s.x && i.y <= s.y + s.height && i.y + i.height >= s.y, o = (i) => i.rects.reduce((s, a) => s + a.width, 0), r = e.filter(({ rects: i }) => i.some((s) => n(t, s)));
510
+ return r.sort((i, s) => o(s) - o(i)), r.findIndex((i) => i.rects.includes(t));
518
511
  }, Be = (t) => {
519
512
  t.classList.add("r6o-annotatable");
520
513
  const e = document.createElement("div");
@@ -524,33 +517,28 @@ const Le = (t, e) => {
524
517
  destroy: () => {
525
518
  e.remove();
526
519
  },
527
- redraw: (c, s, u, h, m) => {
528
- const g = !(mt(n, c) && m);
529
- if (!h && !g) return;
530
- g && (e.innerHTML = "");
531
- const f = c.reduce((w, { rects: v }) => [...w, ...v], []);
532
- c.forEach((w) => {
533
- w.rects.map((v) => {
534
- const p = Le(v, f), d = Kt(w, s, u, h, p);
535
- if (g) {
536
- const a = document.createElement("span");
537
- a.className = "r6o-annotation", a.dataset.annotation = w.annotation.id, a.style.left = `${v.x}px`, a.style.top = `${v.y}px`, a.style.width = `${v.width}px`, a.style.height = `${v.height}px`;
538
- const y = Y((d == null ? void 0 : d.fill) || P.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? P.fillOpacity : d.fillOpacity).toHex();
539
- a.style.backgroundColor = y, d.underlineStyle && (a.style.borderStyle = d.underlineStyle), d.underlineColor && (a.style.borderColor = d.underlineColor), d.underlineThickness && (a.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (a.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(a);
520
+ redraw: (s, a, u, f, g) => {
521
+ const m = !(mt(n, s) && g);
522
+ !f && !m || (m && (e.innerHTML = ""), s.forEach((h) => {
523
+ h.rects.map((w) => {
524
+ const y = Le(w, s), p = Kt(h, a, u, f, y);
525
+ if (m) {
526
+ const l = document.createElement("span");
527
+ l.className = "r6o-annotation", l.dataset.annotation = h.annotation.id, l.style.left = `${w.x}px`, l.style.top = `${w.y}px`, l.style.width = `${w.width}px`, l.style.height = `${w.height}px`, l.style.backgroundColor = Y((p == null ? void 0 : p.fill) || P.fill).alpha((p == null ? void 0 : p.fillOpacity) === void 0 ? P.fillOpacity : p.fillOpacity).toHex(), p.underlineStyle && (l.style.borderStyle = p.underlineStyle), p.underlineColor && (l.style.borderColor = p.underlineColor), p.underlineThickness && (l.style.borderBottomWidth = `${p.underlineThickness}px`), p.underlineOffset && (l.style.paddingBottom = `${p.underlineOffset}px`), e.appendChild(l);
540
528
  }
541
529
  });
542
- }), n = c;
530
+ }), n = s);
543
531
  },
544
- setVisible: (c) => {
545
- c ? e.classList.remove("hidden") : e.classList.add("hidden");
532
+ setVisible: (s) => {
533
+ s ? e.classList.remove("hidden") : e.classList.add("hidden");
546
534
  }
547
535
  };
548
536
  }, Te = (t, e, n) => vt(t, e, n, Be(t));
549
- var V = [];
537
+ var U = [];
550
538
  for (var lt = 0; lt < 256; ++lt)
551
- V.push((lt + 256).toString(16).slice(1));
539
+ U.push((lt + 256).toString(16).slice(1));
552
540
  function Re(t, e = 0) {
553
- 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();
541
+ 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();
554
542
  }
555
543
  var Z, Ne = new Uint8Array(16);
556
544
  function Me() {
@@ -599,37 +587,37 @@ const F = [];
599
587
  function yt(t, e = dt) {
600
588
  let n;
601
589
  const o = /* @__PURE__ */ new Set();
602
- function i(s) {
603
- if (Ie(t, s) && (t = s, n)) {
590
+ function r(a) {
591
+ if (Ie(t, a) && (t = a, n)) {
604
592
  const u = !F.length;
605
- for (const h of o)
606
- h[1](), F.push(h, t);
593
+ for (const f of o)
594
+ f[1](), F.push(f, t);
607
595
  if (u) {
608
- for (let h = 0; h < F.length; h += 2)
609
- F[h][0](F[h + 1]);
596
+ for (let f = 0; f < F.length; f += 2)
597
+ F[f][0](F[f + 1]);
610
598
  F.length = 0;
611
599
  }
612
600
  }
613
601
  }
614
- function r(s) {
615
- i(s(t));
602
+ function i(a) {
603
+ r(a(t));
616
604
  }
617
- function c(s, u = dt) {
618
- const h = [s, u];
619
- return o.add(h), o.size === 1 && (n = e(i, r) || dt), s(t), () => {
620
- o.delete(h), o.size === 0 && n && (n(), n = null);
605
+ function s(a, u = dt) {
606
+ const f = [a, u];
607
+ return o.add(f), o.size === 1 && (n = e(r, i) || dt), a(t), () => {
608
+ o.delete(f), o.size === 0 && n && (n(), n = null);
621
609
  };
622
610
  }
623
- return { set: i, update: r, subscribe: c };
611
+ return { set: r, update: i, subscribe: s };
624
612
  }
625
- const Ve = (t) => {
613
+ const Ue = (t) => {
626
614
  const { subscribe: e, set: n } = yt();
627
615
  let o;
628
- return e((i) => o = i), t.observe(({ changes: i }) => {
616
+ return e((r) => o = r), t.observe(({ changes: r }) => {
629
617
  if (o) {
630
- (i.deleted || []).some((c) => c.id === o) && n(void 0);
631
- const r = (i.updated || []).find(({ oldValue: c }) => c.id === o);
632
- r && n(r.newValue.id);
618
+ (r.deleted || []).some((s) => s.id === o) && n(void 0);
619
+ const i = (r.updated || []).find(({ oldValue: s }) => s.id === o);
620
+ i && n(i.newValue.id);
633
621
  }
634
622
  }), {
635
623
  get current() {
@@ -639,60 +627,72 @@ const Ve = (t) => {
639
627
  set: n
640
628
  };
641
629
  };
642
- var Ue = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Ue || {});
630
+ var Ve = /* @__PURE__ */ ((t) => (t.EDIT = "EDIT", t.SELECT = "SELECT", t.NONE = "NONE", t))(Ve || {});
643
631
  const ut = { selected: [] }, ke = (t, e = "EDIT") => {
644
632
  const { subscribe: n, set: o } = yt(ut);
645
- let i = ut;
646
- n((l) => i = l);
647
- const r = () => o(ut), c = () => {
648
- var l;
649
- return ((l = i.selected) == null ? void 0 : l.length) === 0;
650
- }, s = (l) => {
651
- if (i.selected.length === 0)
633
+ let r = e, i = ut;
634
+ n((h) => i = h);
635
+ const s = () => o(ut), a = () => {
636
+ var h;
637
+ return ((h = i.selected) == null ? void 0 : h.length) === 0;
638
+ }, u = (h) => {
639
+ if (a())
652
640
  return !1;
653
- const g = typeof l == "string" ? l : l.id;
654
- return i.selected.some((f) => f.id === g);
655
- }, u = (l, g) => {
656
- const f = t.getAnnotation(l);
657
- if (f) {
658
- const w = It(f, e);
659
- o(w === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: g } : w === "SELECT" ? { selected: [{ id: l }], pointerEvent: g } : { selected: [], pointerEvent: g });
660
- } else
661
- console.warn("Invalid selection: " + l);
662
- }, h = (l, g) => {
663
- const f = Array.isArray(l) ? l : [l], w = f.map((v) => t.getAnnotation(v)).filter(Boolean);
641
+ const w = typeof h == "string" ? h : h.id;
642
+ return i.selected.some((y) => y.id === w);
643
+ }, f = (h, w) => {
644
+ const y = t.getAnnotation(h);
645
+ if (!y) {
646
+ console.warn("Invalid selection: " + h);
647
+ return;
648
+ }
649
+ switch (It(y, r)) {
650
+ case "EDIT":
651
+ o({ selected: [{ id: h, editable: !0 }], event: w });
652
+ break;
653
+ case "SELECT":
654
+ o({ selected: [{ id: h }], event: w });
655
+ break;
656
+ default:
657
+ o({ selected: [], event: w });
658
+ }
659
+ }, g = (h, w) => {
660
+ const y = Array.isArray(h) ? h : [h], p = y.map((l) => t.getAnnotation(l)).filter((l) => !!l);
664
661
  o({
665
- selected: w.map((v) => {
666
- const p = g === void 0 ? It(v, e) === "EDIT" : g;
667
- return { id: v.id, editable: p };
662
+ selected: p.map((l) => {
663
+ const c = w === void 0 ? It(l, r) === "EDIT" : w;
664
+ return { id: l.id, editable: c };
668
665
  })
669
- }), w.length !== f.length && console.warn("Invalid selection", l);
670
- }, m = (l) => {
671
- if (i.selected.length === 0)
666
+ }), p.length !== y.length && console.warn("Invalid selection", h);
667
+ }, d = (h) => {
668
+ if (a())
672
669
  return !1;
673
- const { selected: g } = i;
674
- g.filter(({ id: f }) => l.includes(f)).length > 0 && o({ selected: g.filter(({ id: f }) => !l.includes(f)) });
675
- };
676
- return t.observe(({ changes: l }) => m((l.deleted || []).map((g) => g.id))), {
677
- clear: r,
678
- clickSelect: u,
670
+ const { selected: w } = i;
671
+ w.some(({ id: y }) => h.includes(y)) && o({ selected: w.filter(({ id: y }) => !h.includes(y)) });
672
+ }, m = (h) => r = h;
673
+ return t.observe(
674
+ ({ changes: h }) => d((h.deleted || []).map((w) => w.id))
675
+ ), {
676
+ get event() {
677
+ return i ? i.event : null;
678
+ },
679
679
  get selected() {
680
680
  return i ? [...i.selected] : null;
681
681
  },
682
- get pointerEvent() {
683
- return i ? i.pointerEvent : null;
684
- },
685
- isEmpty: c,
686
- isSelected: s,
687
- setSelected: h,
688
- subscribe: n
682
+ clear: s,
683
+ isEmpty: a,
684
+ isSelected: u,
685
+ setSelected: g,
686
+ setUserSelectAction: m,
687
+ subscribe: n,
688
+ userSelect: f
689
689
  };
690
- }, It = (t, e) => typeof e == "function" ? e(t) || "EDIT" : e || "EDIT";
691
- var U = [];
690
+ }, It = (t, e) => typeof e == "function" ? e(t) : e || "EDIT";
691
+ var V = [];
692
692
  for (var ht = 0; ht < 256; ++ht)
693
- U.push((ht + 256).toString(16).slice(1));
693
+ V.push((ht + 256).toString(16).slice(1));
694
694
  function Ye(t, e = 0) {
695
- 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();
695
+ 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();
696
696
  }
697
697
  var tt, De = new Uint8Array(16);
698
698
  function _e() {
@@ -701,19 +701,19 @@ function _e() {
701
701
  return tt(De);
702
702
  }
703
703
  var Xe = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
704
- const Vt = {
704
+ const Ut = {
705
705
  randomUUID: Xe
706
706
  };
707
707
  function $e(t, e, n) {
708
- if (Vt.randomUUID && !e && !t)
709
- return Vt.randomUUID();
708
+ if (Ut.randomUUID && !e && !t)
709
+ return Ut.randomUUID();
710
710
  t = t || {};
711
711
  var o = t.random || (t.rng || _e)();
712
712
  return o[6] = o[6] & 15 | 64, o[8] = o[8] & 63 | 128, Ye(o);
713
713
  }
714
- const Vn = (t, e, n, o) => ({
714
+ const Un = (t, e, n, o) => ({
715
715
  id: $e(),
716
- annotation: t.id,
716
+ annotation: typeof t == "string" ? t : t.id,
717
717
  created: n || /* @__PURE__ */ new Date(),
718
718
  creator: o,
719
719
  ...e
@@ -724,68 +724,68 @@ const Vn = (t, e, n, o) => ({
724
724
  const n = new Set(e.bodies.map((o) => o.id));
725
725
  return t.bodies.filter((o) => !n.has(o.id));
726
726
  }, Fe = (t, e) => e.bodies.map((n) => {
727
- const o = t.bodies.find((i) => i.id === n.id);
727
+ const o = t.bodies.find((r) => r.id === n.id);
728
728
  return { newBody: n, oldBody: o && !q(o, n) ? o : void 0 };
729
729
  }).filter(({ oldBody: n }) => n).map(({ oldBody: n, newBody: o }) => ({ oldBody: n, newBody: o })), ze = (t, e) => !q(t.target, e.target), Pt = (t, e) => {
730
- const n = He(t, e), o = Pe(t, e), i = Fe(t, e);
730
+ const n = He(t, e), o = Pe(t, e), r = Fe(t, e);
731
731
  return {
732
732
  oldValue: t,
733
733
  newValue: e,
734
734
  bodiesCreated: n.length > 0 ? n : void 0,
735
735
  bodiesDeleted: o.length > 0 ? o : void 0,
736
- bodiesUpdated: i.length > 0 ? i : void 0,
736
+ bodiesUpdated: r.length > 0 ? r : void 0,
737
737
  targetUpdated: ze(t, e) ? { oldTarget: t.target, newTarget: e.target } : void 0
738
738
  };
739
739
  };
740
740
  var N = /* @__PURE__ */ ((t) => (t.LOCAL = "LOCAL", t.REMOTE = "REMOTE", t))(N || {});
741
741
  const We = (t, e) => {
742
742
  var n, o;
743
- const { changes: i, origin: r } = e;
744
- if (!(!t.options.origin || t.options.origin === r))
743
+ const { changes: r, origin: i } = e;
744
+ if (!(!t.options.origin || t.options.origin === i))
745
745
  return !1;
746
746
  if (t.options.ignore) {
747
- const { ignore: c } = t.options, s = (u) => u && u.length > 0;
748
- if (!(s(i.created) || s(i.deleted))) {
749
- const u = (n = i.updated) == null ? void 0 : n.some((m) => s(m.bodiesCreated) || s(m.bodiesDeleted) || s(m.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((m) => m.targetUpdated);
750
- if (c === "BODY_ONLY" && u && !h || c === "TARGET_ONLY" && h && !u)
747
+ const { ignore: s } = t.options, a = (u) => u && u.length > 0;
748
+ if (!(a(r.created) || a(r.deleted))) {
749
+ const u = (n = r.updated) == null ? void 0 : n.some((g) => a(g.bodiesCreated) || a(g.bodiesDeleted) || a(g.bodiesUpdated)), f = (o = r.updated) == null ? void 0 : o.some((g) => g.targetUpdated);
750
+ if (s === "BODY_ONLY" && u && !f || s === "TARGET_ONLY" && f && !u)
751
751
  return !1;
752
752
  }
753
753
  }
754
754
  if (t.options.annotations) {
755
- const c = /* @__PURE__ */ new Set([
756
- ...(i.created || []).map((s) => s.id),
757
- ...(i.deleted || []).map((s) => s.id),
758
- ...(i.updated || []).map(({ oldValue: s }) => s.id)
755
+ const s = /* @__PURE__ */ new Set([
756
+ ...(r.created || []).map((a) => a.id),
757
+ ...(r.deleted || []).map((a) => a.id),
758
+ ...(r.updated || []).map(({ oldValue: a }) => a.id)
759
759
  ]);
760
- return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((s) => c.has(s));
760
+ return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => s.has(a));
761
761
  } else
762
762
  return !0;
763
763
  }, qe = (t, e) => {
764
- const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), c = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), s = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), u = [
765
- ...(t.created || []).filter((l) => !r.has(l.id)).map((l) => c.has(l.id) ? e.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
764
+ const n = new Set((t.created || []).map((d) => d.id)), o = new Set((t.updated || []).map(({ newValue: d }) => d.id)), r = new Set((e.created || []).map((d) => d.id)), i = new Set((e.deleted || []).map((d) => d.id)), s = new Set((e.updated || []).map(({ oldValue: d }) => d.id)), a = new Set((e.updated || []).filter(({ oldValue: d }) => n.has(d.id) || o.has(d.id)).map(({ oldValue: d }) => d.id)), u = [
765
+ ...(t.created || []).filter((d) => !i.has(d.id)).map((d) => s.has(d.id) ? e.updated.find(({ oldValue: m }) => m.id === d.id).newValue : d),
766
766
  ...e.created || []
767
- ], h = [
768
- ...(t.deleted || []).filter((l) => !i.has(l.id)),
769
- ...(e.deleted || []).filter((l) => !n.has(l.id))
770
- ], m = [
771
- ...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
772
- const { oldValue: g, newValue: f } = l;
773
- if (c.has(f.id)) {
774
- const w = e.updated.find((v) => v.oldValue.id === f.id).newValue;
775
- return Pt(g, w);
767
+ ], f = [
768
+ ...(t.deleted || []).filter((d) => !r.has(d.id)),
769
+ ...(e.deleted || []).filter((d) => !n.has(d.id))
770
+ ], g = [
771
+ ...(t.updated || []).filter(({ newValue: d }) => !i.has(d.id)).map((d) => {
772
+ const { oldValue: m, newValue: h } = d;
773
+ if (s.has(h.id)) {
774
+ const w = e.updated.find((y) => y.oldValue.id === h.id).newValue;
775
+ return Pt(m, w);
776
776
  } else
777
- return l;
777
+ return d;
778
778
  }),
779
- ...(e.updated || []).filter(({ oldValue: l }) => !s.has(l.id))
779
+ ...(e.updated || []).filter(({ oldValue: d }) => !a.has(d.id))
780
780
  ];
781
- return { created: u, deleted: h, updated: m };
781
+ return { created: u, deleted: f, updated: g };
782
782
  }, je = (t) => t.id !== void 0, Ge = () => {
783
- const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (b, x = {}) => n.push({ onChange: b, options: x }), i = (b) => {
784
- const x = n.findIndex((A) => A.onChange == b);
783
+ const t = /* @__PURE__ */ new Map(), e = /* @__PURE__ */ new Map(), n = [], o = (v, x = {}) => n.push({ onChange: v, options: x }), r = (v) => {
784
+ const x = n.findIndex((A) => A.onChange == v);
785
785
  x > -1 && n.splice(x, 1);
786
- }, r = (b, x) => {
786
+ }, i = (v, x) => {
787
787
  const A = {
788
- origin: b,
788
+ origin: v,
789
789
  changes: {
790
790
  created: x.created || [],
791
791
  updated: x.updated || [],
@@ -796,83 +796,83 @@ const We = (t, e) => {
796
796
  n.forEach((C) => {
797
797
  We(C, A) && C.onChange(A);
798
798
  });
799
- }, c = (b, x = N.LOCAL) => {
800
- if (t.get(b.id))
801
- throw Error(`Cannot add annotation ${b.id} - exists already`);
802
- t.set(b.id, b), b.bodies.forEach((A) => e.set(A.id, b.id)), r(x, { created: [b] });
803
- }, s = (b, x) => {
804
- const A = typeof b == "string" ? x : b, C = typeof b == "string" ? b : b.id, R = t.get(C);
799
+ }, s = (v, x = N.LOCAL) => {
800
+ if (t.get(v.id))
801
+ throw Error(`Cannot add annotation ${v.id} - exists already`);
802
+ t.set(v.id, v), v.bodies.forEach((A) => e.set(A.id, v.id)), i(x, { created: [v] });
803
+ }, a = (v, x) => {
804
+ const A = typeof v == "string" ? x : v, C = typeof v == "string" ? v : v.id, R = t.get(C);
805
805
  if (R) {
806
806
  const O = Pt(R, A);
807
807
  return C === A.id ? t.set(C, A) : (t.delete(C), t.set(A.id, A)), R.bodies.forEach((H) => e.delete(H.id)), A.bodies.forEach((H) => e.set(H.id, A.id)), O;
808
808
  } else
809
809
  console.warn(`Cannot update annotation ${C} - does not exist`);
810
- }, u = (b, x = N.LOCAL, A = N.LOCAL) => {
811
- const C = je(x) ? A : x, R = s(b, x);
812
- R && r(C, { updated: [R] });
813
- }, h = (b, x = N.LOCAL) => {
814
- const A = b.reduce((C, R) => {
815
- const O = s(R);
810
+ }, u = (v, x = N.LOCAL, A = N.LOCAL) => {
811
+ const C = je(x) ? A : x, R = a(v, x);
812
+ R && i(C, { updated: [R] });
813
+ }, f = (v, x = N.LOCAL) => {
814
+ const A = v.reduce((C, R) => {
815
+ const O = a(R);
816
816
  return O ? [...C, O] : C;
817
817
  }, []);
818
- A.length > 0 && r(x, { updated: A });
819
- }, m = (b, x = N.LOCAL) => {
820
- const A = t.get(b.annotation);
818
+ A.length > 0 && i(x, { updated: A });
819
+ }, g = (v, x = N.LOCAL) => {
820
+ const A = t.get(v.annotation);
821
821
  if (A) {
822
822
  const C = {
823
823
  ...A,
824
- bodies: [...A.bodies, b]
824
+ bodies: [...A.bodies, v]
825
825
  };
826
- t.set(A.id, C), e.set(b.id, C.id), r(x, { updated: [{
826
+ t.set(A.id, C), e.set(v.id, C.id), i(x, { updated: [{
827
827
  oldValue: A,
828
828
  newValue: C,
829
- bodiesCreated: [b]
829
+ bodiesCreated: [v]
830
830
  }] });
831
831
  } else
832
- console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
833
- }, l = () => [...t.values()], g = (b = N.LOCAL) => {
832
+ console.warn(`Attempt to add body to missing annotation: ${v.annotation}`);
833
+ }, d = () => [...t.values()], m = (v = N.LOCAL) => {
834
834
  const x = [...t.values()];
835
- t.clear(), e.clear(), r(b, { deleted: x });
836
- }, f = (b, x = !0, A = N.LOCAL) => {
835
+ t.clear(), e.clear(), i(v, { deleted: x });
836
+ }, h = (v, x = !0, A = N.LOCAL) => {
837
837
  if (x) {
838
838
  const C = [...t.values()];
839
- t.clear(), e.clear(), b.forEach((R) => {
839
+ t.clear(), e.clear(), v.forEach((R) => {
840
840
  t.set(R.id, R), R.bodies.forEach((O) => e.set(O.id, R.id));
841
- }), r(A, { created: b, deleted: C });
841
+ }), i(A, { created: v, deleted: C });
842
842
  } else {
843
- const C = b.reduce((R, O) => {
843
+ const C = v.reduce((R, O) => {
844
844
  const H = t.get(O.id);
845
845
  return H ? [...R, H] : R;
846
846
  }, []);
847
847
  if (C.length > 0)
848
848
  throw Error(`Bulk insert would overwrite the following annotations: ${C.map((R) => R.id).join(", ")}`);
849
- b.forEach((R) => {
849
+ v.forEach((R) => {
850
850
  t.set(R.id, R), R.bodies.forEach((O) => e.set(O.id, R.id));
851
- }), r(A, { created: b });
851
+ }), i(A, { created: v });
852
852
  }
853
- }, w = (b) => {
854
- const x = typeof b == "string" ? b : b.id, A = t.get(x);
853
+ }, w = (v) => {
854
+ const x = typeof v == "string" ? v : v.id, A = t.get(x);
855
855
  if (A)
856
856
  return t.delete(x), A.bodies.forEach((C) => e.delete(C.id)), A;
857
857
  console.warn(`Attempt to delete missing annotation: ${x}`);
858
- }, v = (b, x = N.LOCAL) => {
859
- const A = w(b);
860
- A && r(x, { deleted: [A] });
861
- }, p = (b, x = N.LOCAL) => {
862
- const A = b.reduce((C, R) => {
858
+ }, y = (v, x = N.LOCAL) => {
859
+ const A = w(v);
860
+ A && i(x, { deleted: [A] });
861
+ }, p = (v, x = N.LOCAL) => {
862
+ const A = v.reduce((C, R) => {
863
863
  const O = w(R);
864
864
  return O ? [...C, O] : C;
865
865
  }, []);
866
- A.length > 0 && r(x, { deleted: A });
867
- }, d = (b) => {
868
- const x = t.get(b.annotation);
866
+ A.length > 0 && i(x, { deleted: A });
867
+ }, l = (v) => {
868
+ const x = t.get(v.annotation);
869
869
  if (x) {
870
- const A = x.bodies.find((C) => C.id === b.id);
870
+ const A = x.bodies.find((C) => C.id === v.id);
871
871
  if (A) {
872
872
  e.delete(A.id);
873
873
  const C = {
874
874
  ...x,
875
- bodies: x.bodies.filter((R) => R.id !== b.id)
875
+ bodies: x.bodies.filter((R) => R.id !== v.id)
876
876
  };
877
877
  return t.set(x.id, C), {
878
878
  oldValue: x,
@@ -880,33 +880,33 @@ const We = (t, e) => {
880
880
  bodiesDeleted: [A]
881
881
  };
882
882
  } else
883
- console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
883
+ console.warn(`Attempt to delete missing body ${v.id} from annotation ${v.annotation}`);
884
884
  } else
885
- console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
886
- }, a = (b, x = N.LOCAL) => {
887
- const A = d(b);
888
- A && r(x, { updated: [A] });
889
- }, y = (b, x = N.LOCAL) => {
890
- const A = b.map((C) => d(C)).filter(Boolean);
891
- A.length > 0 && r(x, { updated: A });
892
- }, S = (b) => {
893
- const x = t.get(b);
885
+ console.warn(`Attempt to delete body from missing annotation ${v.annotation}`);
886
+ }, c = (v, x = N.LOCAL) => {
887
+ const A = l(v);
888
+ A && i(x, { updated: [A] });
889
+ }, b = (v, x = N.LOCAL) => {
890
+ const A = v.map((C) => l(C)).filter(Boolean);
891
+ A.length > 0 && i(x, { updated: A });
892
+ }, S = (v) => {
893
+ const x = t.get(v);
894
894
  return x ? { ...x } : void 0;
895
- }, L = (b) => {
896
- const x = e.get(b);
895
+ }, L = (v) => {
896
+ const x = e.get(v);
897
897
  if (x) {
898
- const A = S(x).bodies.find((C) => C.id === b);
898
+ const A = S(x).bodies.find((C) => C.id === v);
899
899
  if (A)
900
900
  return A;
901
- console.error(`Store integrity error: body ${b} in index, but not in annotation`);
901
+ console.error(`Store integrity error: body ${v} in index, but not in annotation`);
902
902
  } else
903
- console.warn(`Attempt to retrieve missing body: ${b}`);
904
- }, E = (b, x) => {
905
- if (b.annotation !== x.annotation)
903
+ console.warn(`Attempt to retrieve missing body: ${v}`);
904
+ }, E = (v, x) => {
905
+ if (v.annotation !== x.annotation)
906
906
  throw "Annotation integrity violation: annotation ID must be the same when updating bodies";
907
- const A = t.get(b.annotation);
907
+ const A = t.get(v.annotation);
908
908
  if (A) {
909
- const C = A.bodies.find((O) => O.id === b.id), R = {
909
+ const C = A.bodies.find((O) => O.id === v.id), R = {
910
910
  ...A,
911
911
  bodies: A.bodies.map((O) => O.id === C.id ? x : O)
912
912
  };
@@ -916,21 +916,21 @@ const We = (t, e) => {
916
916
  bodiesUpdated: [{ oldBody: C, newBody: x }]
917
917
  };
918
918
  } else
919
- console.warn(`Attempt to add body to missing annotation ${b.annotation}`);
920
- }, T = (b, x, A = N.LOCAL) => {
921
- const C = E(b, x);
922
- C && r(A, { updated: [C] });
923
- }, B = (b, x = N.LOCAL) => {
924
- const A = b.map((C) => E({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
925
- r(x, { updated: A });
926
- }, M = (b) => {
927
- const x = t.get(b.annotation);
919
+ console.warn(`Attempt to add body to missing annotation ${v.annotation}`);
920
+ }, T = (v, x, A = N.LOCAL) => {
921
+ const C = E(v, x);
922
+ C && i(A, { updated: [C] });
923
+ }, B = (v, x = N.LOCAL) => {
924
+ const A = v.map((C) => E({ id: C.id, annotation: C.annotation }, C)).filter(Boolean);
925
+ i(x, { updated: A });
926
+ }, M = (v) => {
927
+ const x = t.get(v.annotation);
928
928
  if (x) {
929
929
  const A = {
930
930
  ...x,
931
931
  target: {
932
932
  ...x.target,
933
- ...b
933
+ ...v
934
934
  }
935
935
  };
936
936
  return t.set(x.id, A), {
@@ -938,43 +938,43 @@ const We = (t, e) => {
938
938
  newValue: A,
939
939
  targetUpdated: {
940
940
  oldTarget: x.target,
941
- newTarget: b
941
+ newTarget: v
942
942
  }
943
943
  };
944
944
  } else
945
- console.warn(`Attempt to update target on missing annotation: ${b.annotation}`);
945
+ console.warn(`Attempt to update target on missing annotation: ${v.annotation}`);
946
946
  };
947
947
  return {
948
- addAnnotation: c,
949
- addBody: m,
950
- all: l,
951
- bulkAddAnnotation: f,
948
+ addAnnotation: s,
949
+ addBody: g,
950
+ all: d,
951
+ bulkAddAnnotation: h,
952
952
  bulkDeleteAnnotation: p,
953
- bulkDeleteBodies: y,
954
- bulkUpdateAnnotation: h,
953
+ bulkDeleteBodies: b,
954
+ bulkUpdateAnnotation: f,
955
955
  bulkUpdateBodies: B,
956
- bulkUpdateTargets: (b, x = N.LOCAL) => {
957
- const A = b.map((C) => M(C)).filter(Boolean);
958
- A.length > 0 && r(x, { updated: A });
956
+ bulkUpdateTargets: (v, x = N.LOCAL) => {
957
+ const A = v.map((C) => M(C)).filter(Boolean);
958
+ A.length > 0 && i(x, { updated: A });
959
959
  },
960
- clear: g,
961
- deleteAnnotation: v,
962
- deleteBody: a,
960
+ clear: m,
961
+ deleteAnnotation: y,
962
+ deleteBody: c,
963
963
  getAnnotation: S,
964
964
  getBody: L,
965
965
  observe: o,
966
- unobserve: i,
966
+ unobserve: r,
967
967
  updateAnnotation: u,
968
968
  updateBody: T,
969
- updateTarget: (b, x = N.LOCAL) => {
970
- const A = M(b);
971
- A && r(x, { updated: [A] });
969
+ updateTarget: (v, x = N.LOCAL) => {
970
+ const A = M(v);
971
+ A && i(x, { updated: [A] });
972
972
  }
973
973
  };
974
974
  };
975
975
  let Ke = () => ({
976
976
  emit(t, ...e) {
977
- for (let n = 0, o = this.events[t] || [], i = o.length; n < i; n++)
977
+ for (let n = 0, o = this.events[t] || [], r = o.length; n < r; n++)
978
978
  o[n](...e);
979
979
  },
980
980
  events: {},
@@ -982,45 +982,45 @@ let Ke = () => ({
982
982
  var n;
983
983
  return ((n = this.events)[t] || (n[t] = [])).push(e), () => {
984
984
  var o;
985
- this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((i) => e !== i);
985
+ this.events[t] = (o = this.events[t]) == null ? void 0 : o.filter((r) => e !== r);
986
986
  };
987
987
  }
988
988
  });
989
989
  const Qe = 250, Je = (t) => {
990
990
  const e = Ke(), n = [];
991
- let o = -1, i = !1, r = 0;
992
- const c = (f) => {
993
- if (!i) {
994
- const { changes: w } = f, v = performance.now();
995
- if (v - r > Qe)
991
+ let o = -1, r = !1, i = 0;
992
+ const s = (h) => {
993
+ if (!r) {
994
+ const { changes: w } = h, y = performance.now();
995
+ if (y - i > Qe)
996
996
  n.splice(o + 1), n.push(w), o = n.length - 1;
997
997
  else {
998
998
  const p = n.length - 1;
999
999
  n[p] = qe(n[p], w);
1000
1000
  }
1001
- r = v;
1001
+ i = y;
1002
1002
  }
1003
- i = !1;
1003
+ r = !1;
1004
1004
  };
1005
- t.observe(c, { origin: N.LOCAL });
1006
- const s = (f) => f && f.length > 0 && t.bulkDeleteAnnotation(f), u = (f) => f && f.length > 0 && t.bulkAddAnnotation(f, !1), h = (f) => f && f.length > 0 && t.bulkUpdateAnnotation(f.map(({ oldValue: w }) => w)), m = (f) => f && f.length > 0 && t.bulkUpdateAnnotation(f.map(({ newValue: w }) => w)), l = (f) => f && f.length > 0 && t.bulkAddAnnotation(f, !1), g = (f) => f && f.length > 0 && t.bulkDeleteAnnotation(f);
1005
+ t.observe(s, { origin: N.LOCAL });
1006
+ const a = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h), u = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), f = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ oldValue: w }) => w)), g = (h) => h && h.length > 0 && t.bulkUpdateAnnotation(h.map(({ newValue: w }) => w)), d = (h) => h && h.length > 0 && t.bulkAddAnnotation(h, !1), m = (h) => h && h.length > 0 && t.bulkDeleteAnnotation(h);
1007
1007
  return {
1008
1008
  canRedo: () => n.length - 1 > o,
1009
1009
  canUndo: () => o > -1,
1010
- destroy: () => t.unobserve(c),
1011
- on: (f, w) => e.on(f, w),
1010
+ destroy: () => t.unobserve(s),
1011
+ on: (h, w) => e.on(h, w),
1012
1012
  redo: () => {
1013
1013
  if (n.length - 1 > o) {
1014
- i = !0;
1015
- const { created: f, updated: w, deleted: v } = n[o + 1];
1016
- u(f), m(w), g(v), e.emit("redo", n[o + 1]), o += 1;
1014
+ r = !0;
1015
+ const { created: h, updated: w, deleted: y } = n[o + 1];
1016
+ u(h), g(w), m(y), e.emit("redo", n[o + 1]), o += 1;
1017
1017
  }
1018
1018
  },
1019
1019
  undo: () => {
1020
1020
  if (o > -1) {
1021
- i = !0;
1022
- const { created: f, updated: w, deleted: v } = n[o];
1023
- s(f), h(w), l(v), e.emit("undo", n[o]), o -= 1;
1021
+ r = !0;
1022
+ const { created: h, updated: w, deleted: y } = n[o];
1023
+ a(h), f(w), d(y), e.emit("undo", n[o]), o -= 1;
1024
1024
  }
1025
1025
  }
1026
1026
  };
@@ -1031,151 +1031,154 @@ const Qe = 250, Je = (t) => {
1031
1031
  set: e
1032
1032
  };
1033
1033
  }, tn = (t, e, n, o) => {
1034
- const { store: i, selection: r, hover: c, viewport: s } = t, u = /* @__PURE__ */ new Map();
1035
- let h = [], m;
1036
- const l = (v, p) => {
1037
- u.has(v) ? u.get(v).push(p) : u.set(v, [p]);
1038
- }, g = (v, p) => {
1039
- const d = u.get(v);
1040
- if (d) {
1041
- const a = d.indexOf(p);
1042
- a !== -1 && d.splice(a, 1);
1034
+ const { store: r, selection: i, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();
1035
+ let f = [], g;
1036
+ const d = (y, p) => {
1037
+ u.has(y) ? u.get(y).push(p) : u.set(y, [p]);
1038
+ }, m = (y, p) => {
1039
+ const l = u.get(y);
1040
+ if (l) {
1041
+ const c = l.indexOf(p);
1042
+ c !== -1 && l.splice(c, 1);
1043
1043
  }
1044
- }, f = (v, p, d) => {
1045
- u.has(v) && setTimeout(() => {
1046
- u.get(v).forEach((a) => {
1044
+ }, h = (y, p, l) => {
1045
+ u.has(y) && setTimeout(() => {
1046
+ u.get(y).forEach((c) => {
1047
1047
  if (n) {
1048
- const y = Array.isArray(p) ? p.map((L) => n.serialize(L)) : n.serialize(p), S = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
1049
- a(y, S);
1048
+ const b = Array.isArray(p) ? p.map((L) => n.serialize(L)) : n.serialize(p), S = l ? l instanceof PointerEvent ? l : n.serialize(l) : void 0;
1049
+ c(b, S);
1050
1050
  } else
1051
- a(p, d);
1051
+ c(p, l);
1052
1052
  });
1053
1053
  }, 1);
1054
1054
  };
1055
- r.subscribe(({ selected: v }) => {
1056
- if (!(h.length === 0 && v.length === 0)) {
1057
- if (h.length === 0 && v.length > 0)
1058
- h = v.map(({ id: p }) => i.getAnnotation(p));
1059
- else if (h.length > 0 && v.length === 0)
1060
- h.forEach((p) => {
1061
- const d = i.getAnnotation(p.id);
1062
- d && !q(d, p) && f("updateAnnotation", d, p);
1063
- }), h = [];
1055
+ i.subscribe(({ selected: y }) => {
1056
+ if (!(f.length === 0 && y.length === 0)) {
1057
+ if (f.length === 0 && y.length > 0)
1058
+ f = y.map(({ id: p }) => r.getAnnotation(p));
1059
+ else if (f.length > 0 && y.length === 0)
1060
+ f.forEach((p) => {
1061
+ const l = r.getAnnotation(p.id);
1062
+ l && !q(l, p) && h("updateAnnotation", l, p);
1063
+ }), f = [];
1064
1064
  else {
1065
- const p = new Set(h.map((a) => a.id)), d = new Set(v.map(({ id: a }) => a));
1066
- h.filter((a) => !d.has(a.id)).forEach((a) => {
1067
- const y = i.getAnnotation(a.id);
1068
- y && !q(y, a) && f("updateAnnotation", y, a);
1069
- }), h = [
1065
+ const p = new Set(f.map((c) => c.id)), l = new Set(y.map(({ id: c }) => c));
1066
+ f.filter((c) => !l.has(c.id)).forEach((c) => {
1067
+ const b = r.getAnnotation(c.id);
1068
+ b && !q(b, c) && h("updateAnnotation", b, c);
1069
+ }), f = [
1070
1070
  // Remove annotations that were deselected
1071
- ...h.filter((a) => d.has(a.id)),
1071
+ ...f.filter((c) => l.has(c.id)),
1072
1072
  // Add editable annotations that were selected
1073
- ...v.filter(({ id: a }) => !p.has(a)).map(({ id: a }) => i.getAnnotation(a))
1073
+ ...y.filter(({ id: c }) => !p.has(c)).map(({ id: c }) => r.getAnnotation(c))
1074
1074
  ];
1075
1075
  }
1076
- f("selectionChanged", h);
1076
+ h("selectionChanged", f);
1077
1077
  }
1078
- }), c.subscribe((v) => {
1079
- !m && v ? f("mouseEnterAnnotation", i.getAnnotation(v)) : m && !v ? f("mouseLeaveAnnotation", i.getAnnotation(m)) : m && v && (f("mouseLeaveAnnotation", i.getAnnotation(m)), f("mouseEnterAnnotation", i.getAnnotation(v))), m = v;
1080
- }), s == null || s.subscribe((v) => f("viewportIntersect", v.map((p) => i.getAnnotation(p)))), i.observe((v) => {
1081
- const { created: p, deleted: d } = v.changes;
1082
- (p || []).forEach((a) => f("createAnnotation", a)), (d || []).forEach((a) => f("deleteAnnotation", a)), (v.changes.updated || []).filter((a) => [
1083
- ...a.bodiesCreated || [],
1084
- ...a.bodiesDeleted || [],
1085
- ...a.bodiesUpdated || []
1086
- ].length > 0).forEach(({ oldValue: a, newValue: y }) => {
1087
- const S = h.find((L) => L.id === a.id) || a;
1088
- h = h.map((L) => L.id === a.id ? y : L), f("updateAnnotation", y, S);
1078
+ }), s.subscribe((y) => {
1079
+ !g && y ? h("mouseEnterAnnotation", r.getAnnotation(y)) : g && !y ? h("mouseLeaveAnnotation", r.getAnnotation(g)) : g && y && (h("mouseLeaveAnnotation", r.getAnnotation(g)), h("mouseEnterAnnotation", r.getAnnotation(y))), g = y;
1080
+ }), a == null || a.subscribe((y) => h("viewportIntersect", y.map((p) => r.getAnnotation(p)))), r.observe((y) => {
1081
+ const { created: p, deleted: l } = y.changes;
1082
+ (p || []).forEach((c) => h("createAnnotation", c)), (l || []).forEach((c) => h("deleteAnnotation", c)), (y.changes.updated || []).filter((c) => [
1083
+ ...c.bodiesCreated || [],
1084
+ ...c.bodiesDeleted || [],
1085
+ ...c.bodiesUpdated || []
1086
+ ].length > 0).forEach(({ oldValue: c, newValue: b }) => {
1087
+ const S = f.find((L) => L.id === c.id) || c;
1088
+ f = f.map((L) => L.id === c.id ? b : L), h("updateAnnotation", b, S);
1089
1089
  });
1090
- }, { origin: N.LOCAL }), i.observe((v) => {
1091
- if (h) {
1092
- const p = new Set(h.map((a) => a.id)), d = (v.changes.updated || []).filter(({ newValue: a }) => p.has(a.id)).map(({ newValue: a }) => a);
1093
- d.length > 0 && (h = h.map((a) => d.find((S) => S.id === a.id) || a));
1090
+ }, { origin: N.LOCAL }), r.observe((y) => {
1091
+ if (f) {
1092
+ const p = new Set(f.map((c) => c.id)), l = (y.changes.updated || []).filter(({ newValue: c }) => p.has(c.id)).map(({ newValue: c }) => c);
1093
+ l.length > 0 && (f = f.map((c) => l.find((S) => S.id === c.id) || c));
1094
1094
  }
1095
1095
  }, { origin: N.REMOTE });
1096
- const w = (v) => (p) => {
1097
- const { updated: d } = p;
1098
- v ? (d || []).forEach((a) => f("updateAnnotation", a.oldValue, a.newValue)) : (d || []).forEach((a) => f("updateAnnotation", a.newValue, a.oldValue));
1096
+ const w = (y) => (p) => {
1097
+ const { updated: l } = p;
1098
+ y ? (l || []).forEach((c) => h("updateAnnotation", c.oldValue, c.newValue)) : (l || []).forEach((c) => h("updateAnnotation", c.newValue, c.oldValue));
1099
1099
  };
1100
- return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: l, off: g, emit: f };
1100
+ return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: d, off: m, emit: h };
1101
1101
  }, en = (t) => (e) => e.reduce((n, o) => {
1102
- const { parsed: i, error: r } = t.parse(o);
1103
- return r ? {
1102
+ const { parsed: r, error: i } = t.parse(o);
1103
+ return i ? {
1104
1104
  parsed: n.parsed,
1105
1105
  failed: [...n.failed, o]
1106
- } : i ? {
1107
- parsed: [...n.parsed, i],
1106
+ } : r ? {
1107
+ parsed: [...n.parsed, r],
1108
1108
  failed: n.failed
1109
1109
  } : {
1110
1110
  ...n
1111
1111
  };
1112
1112
  }, { parsed: [], failed: [] }), nn = (t, e, n) => {
1113
- const { store: o, selection: i } = t, r = (p) => {
1113
+ const { store: o, selection: r } = t, i = (l) => {
1114
1114
  if (n) {
1115
- const { parsed: d, error: a } = n.parse(p);
1116
- d ? o.addAnnotation(d, N.REMOTE) : console.error(a);
1115
+ const { parsed: c, error: b } = n.parse(l);
1116
+ c ? o.addAnnotation(c, N.REMOTE) : console.error(b);
1117
1117
  } else
1118
- o.addAnnotation(p, N.REMOTE);
1119
- }, c = () => i.clear(), s = () => o.clear(), u = (p) => {
1120
- const d = o.getAnnotation(p);
1121
- return n && d ? n.serialize(d) : d;
1122
- }, h = () => n ? o.all().map(n.serialize) : o.all(), m = () => {
1123
- var p;
1124
- const d = (((p = i.selected) == null ? void 0 : p.map((a) => a.id)) || []).map((a) => o.getAnnotation(a)).filter(Boolean);
1125
- return n ? d.map(n.serialize) : d;
1126
- }, l = (p, d = !0) => fetch(p).then((a) => a.json()).then((a) => (f(a, d), a)), g = (p) => {
1127
- if (typeof p == "string") {
1128
- const d = o.getAnnotation(p);
1129
- if (o.deleteAnnotation(p), d)
1130
- return n ? n.serialize(d) : d;
1118
+ o.addAnnotation(l, N.REMOTE);
1119
+ }, s = () => r.clear(), a = () => o.clear(), u = (l) => {
1120
+ const c = o.getAnnotation(l);
1121
+ return n && c ? n.serialize(c) : c;
1122
+ }, f = () => n ? o.all().map(n.serialize) : o.all(), g = () => {
1123
+ var l;
1124
+ const c = (((l = r.selected) == null ? void 0 : l.map((b) => b.id)) || []).map((b) => o.getAnnotation(b)).filter(Boolean);
1125
+ return n ? c.map(n.serialize) : c;
1126
+ }, d = (l, c = !0) => fetch(l).then((b) => b.json()).then((b) => (h(b, c), b)), m = (l) => {
1127
+ if (typeof l == "string") {
1128
+ const c = o.getAnnotation(l);
1129
+ if (o.deleteAnnotation(l), c)
1130
+ return n ? n.serialize(c) : c;
1131
1131
  } else {
1132
- const d = n ? n.parse(p).parsed : p;
1133
- if (d)
1134
- return o.deleteAnnotation(d), p;
1132
+ const c = n ? n.parse(l).parsed : l;
1133
+ if (c)
1134
+ return o.deleteAnnotation(c), l;
1135
1135
  }
1136
- }, f = (p, d = !0) => {
1136
+ }, h = (l, c = !0) => {
1137
1137
  if (n) {
1138
- const { parsed: a, failed: y } = en(n)(p);
1139
- y.length > 0 && console.warn(`Discarded ${y.length} invalid annotations`, y), o.bulkAddAnnotation(a, d, N.REMOTE);
1138
+ const { parsed: b, failed: S } = en(n)(l);
1139
+ S.length > 0 && console.warn(`Discarded ${S.length} invalid annotations`, S), o.bulkAddAnnotation(b, c, N.REMOTE);
1140
1140
  } else
1141
- o.bulkAddAnnotation(p, d, N.REMOTE);
1142
- }, w = (p, d) => {
1143
- p ? i.setSelected(p, d) : i.clear();
1144
- }, v = (p) => {
1141
+ o.bulkAddAnnotation(l, c, N.REMOTE);
1142
+ }, w = (l, c) => {
1143
+ l ? r.setSelected(l, c) : r.clear();
1144
+ }, y = (l) => {
1145
+ r.clear(), r.setUserSelectAction(l);
1146
+ }, p = (l) => {
1145
1147
  if (n) {
1146
- const d = n.parse(p).parsed, a = n.serialize(o.getAnnotation(d.id));
1147
- return o.updateAnnotation(d), a;
1148
+ const c = n.parse(l).parsed, b = n.serialize(o.getAnnotation(c.id));
1149
+ return o.updateAnnotation(c), b;
1148
1150
  } else {
1149
- const d = o.getAnnotation(p.id);
1150
- return o.updateAnnotation(p), d;
1151
+ const c = o.getAnnotation(l.id);
1152
+ return o.updateAnnotation(l), c;
1151
1153
  }
1152
1154
  };
1153
1155
  return {
1154
- addAnnotation: r,
1155
- cancelSelected: c,
1156
+ addAnnotation: i,
1157
+ cancelSelected: s,
1156
1158
  canRedo: e.canRedo,
1157
1159
  canUndo: e.canUndo,
1158
- clearAnnotations: s,
1160
+ clearAnnotations: a,
1159
1161
  getAnnotationById: u,
1160
- getAnnotations: h,
1161
- getSelected: m,
1162
- loadAnnotations: l,
1162
+ getAnnotations: f,
1163
+ getSelected: g,
1164
+ loadAnnotations: d,
1163
1165
  redo: e.redo,
1164
- removeAnnotation: g,
1165
- setAnnotations: f,
1166
+ removeAnnotation: m,
1167
+ setAnnotations: h,
1166
1168
  setSelected: w,
1169
+ setUserSelectAction: y,
1167
1170
  undo: e.undo,
1168
- updateAnnotation: v
1171
+ updateAnnotation: p
1169
1172
  };
1170
1173
  }, on = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
1171
1174
  let rn = (t) => crypto.getRandomValues(new Uint8Array(t)), sn = (t, e, n) => {
1172
- let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, i = -~(1.6 * o * e / t.length);
1173
- return (r = e) => {
1174
- let c = "";
1175
+ let o = (2 << Math.log(t.length - 1) / Math.LN2) - 1, r = -~(1.6 * o * e / t.length);
1176
+ return (i = e) => {
1177
+ let s = "";
1175
1178
  for (; ; ) {
1176
- let s = n(i), u = i;
1179
+ let a = n(r), u = r;
1177
1180
  for (; u--; )
1178
- if (c += t[s[u] & o] || "", c.length === r) return c;
1181
+ if (s += t[a[u] & o] || "", s.length === i) return s;
1179
1182
  }
1180
1183
  };
1181
1184
  }, an = (t, e = 21) => sn(t, e, rn), cn = (t = 21) => {
@@ -1187,35 +1190,35 @@ let rn = (t) => crypto.getRandomValues(new Uint8Array(t)), sn = (t, e, n) => {
1187
1190
  const ln = () => ({ isGuest: !0, id: an("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_", 20)() }), dn = (t) => {
1188
1191
  const e = JSON.stringify(t);
1189
1192
  let n = 0;
1190
- for (let o = 0, i = e.length; o < i; o++) {
1191
- let r = e.charCodeAt(o);
1192
- n = (n << 5) - n + r, n |= 0;
1193
+ for (let o = 0, r = e.length; o < r; o++) {
1194
+ let i = e.charCodeAt(o);
1195
+ n = (n << 5) - n + i, n |= 0;
1193
1196
  }
1194
1197
  return `${n}`;
1195
1198
  }, Ft = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, un = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
1196
- const { id: o, type: i, purpose: r, value: c, created: s, modified: u, creator: h, ...m } = n;
1199
+ const { id: o, type: r, purpose: i, value: s, created: a, modified: u, creator: f, ...g } = n;
1197
1200
  return {
1198
1201
  id: o || `temp-${dn(n)}`,
1199
1202
  annotation: e,
1200
- type: i,
1201
- purpose: r,
1202
- value: c,
1203
- creator: Ft(h),
1204
- created: s ? new Date(s) : void 0,
1203
+ type: r,
1204
+ purpose: i,
1205
+ value: s,
1206
+ creator: Ft(f),
1207
+ created: a ? new Date(a) : void 0,
1205
1208
  updated: u ? new Date(u) : void 0,
1206
- ...m
1209
+ ...g
1207
1210
  };
1208
1211
  }), hn = (t) => t.map((e) => {
1209
1212
  var n;
1210
- const { annotation: o, created: i, updated: r, ...c } = e, s = {
1211
- ...c,
1212
- created: i == null ? void 0 : i.toISOString(),
1213
- modified: r == null ? void 0 : r.toISOString()
1213
+ const { annotation: o, created: r, updated: i, ...s } = e, a = {
1214
+ ...s,
1215
+ created: r == null ? void 0 : r.toISOString(),
1216
+ modified: i == null ? void 0 : i.toISOString()
1214
1217
  };
1215
- return (n = s.id) != null && n.startsWith("temp-") && delete s.id, s;
1218
+ return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
1216
1219
  });
1217
1220
  cn();
1218
- const Un = (t, e) => ({
1221
+ const Vn = (t, e) => ({
1219
1222
  parse: (n) => pn(n),
1220
1223
  serialize: (n) => mn(n, t, e)
1221
1224
  }), fn = (t) => t.quote !== void 0 && t.start !== void 0 && t.end !== void 0, gn = (t) => {
@@ -1223,106 +1226,106 @@ const Un = (t, e) => ({
1223
1226
  id: e,
1224
1227
  creator: n,
1225
1228
  created: o,
1226
- modified: i,
1227
- target: r
1228
- } = t, c = Array.isArray(r) ? r : [r], s = {
1229
+ modified: r,
1230
+ target: i
1231
+ } = t, s = Array.isArray(i) ? i : [i], a = {
1229
1232
  creator: Ft(n),
1230
1233
  created: o ? new Date(o) : void 0,
1231
- updated: i ? new Date(i) : void 0,
1234
+ updated: r ? new Date(r) : void 0,
1232
1235
  annotation: e,
1233
1236
  selector: []
1234
1237
  };
1235
- for (const u of c) {
1236
- const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l, g) => {
1237
- switch (g.type) {
1238
+ for (const u of s) {
1239
+ const g = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((d, m) => {
1240
+ switch (m.type) {
1238
1241
  case "TextQuoteSelector":
1239
- l.quote = g.exact;
1242
+ d.quote = m.exact;
1240
1243
  break;
1241
1244
  case "TextPositionSelector":
1242
- l.start = g.start, l.end = g.end;
1245
+ d.start = m.start, d.end = m.end;
1243
1246
  break;
1244
1247
  }
1245
- return l;
1248
+ return d;
1246
1249
  }, {});
1247
- if (fn(m))
1248
- s.selector.push({ id: u.id, ...m });
1250
+ if (fn(g))
1251
+ a.selector.push({ id: u.id, ...g });
1249
1252
  else {
1250
- const l = [
1251
- m.start ? void 0 : "TextPositionSelector",
1252
- m.quote ? void 0 : "TextQuoteSelector"
1253
+ const d = [
1254
+ g.start ? void 0 : "TextPositionSelector",
1255
+ g.quote ? void 0 : "TextQuoteSelector"
1253
1256
  ].filter(Boolean);
1254
- return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
1257
+ return { error: Error(`Missing selector types: ${d.join(" and ")} for annotation: ${t.id}`) };
1255
1258
  }
1256
1259
  }
1257
- return { parsed: s };
1260
+ return { parsed: a };
1258
1261
  }, pn = (t) => {
1259
1262
  const e = t.id || Ht(), {
1260
1263
  creator: n,
1261
1264
  created: o,
1262
- modified: i,
1263
- body: r,
1264
- ...c
1265
- } = t, s = un(r, e), u = gn(t);
1265
+ modified: r,
1266
+ body: i,
1267
+ ...s
1268
+ } = t, a = un(i, e), u = gn(t);
1266
1269
  return "error" in u ? { error: u.error } : {
1267
1270
  parsed: {
1268
- ...c,
1271
+ ...s,
1269
1272
  id: e,
1270
- bodies: s,
1273
+ bodies: a,
1271
1274
  target: u.parsed
1272
1275
  }
1273
1276
  };
1274
1277
  }, mn = (t, e, n) => {
1275
- const { bodies: o, target: i, ...r } = t, {
1276
- selector: c,
1277
- creator: s,
1278
+ const { bodies: o, target: r, ...i } = t, {
1279
+ selector: s,
1280
+ creator: a,
1278
1281
  created: u,
1279
- updated: h,
1280
- ...m
1281
- } = i, l = c.map((g) => {
1282
- const { quote: f, start: w, end: v, range: p } = g, { prefix: d, suffix: a } = oe(p, n), y = [{
1282
+ updated: f,
1283
+ ...g
1284
+ } = r, d = s.map((m) => {
1285
+ const { quote: h, start: w, end: y, range: p } = m, { prefix: l, suffix: c } = oe(p, n), b = [{
1283
1286
  type: "TextQuoteSelector",
1284
- exact: f,
1285
- prefix: d,
1286
- suffix: a
1287
+ exact: h,
1288
+ prefix: l,
1289
+ suffix: c
1287
1290
  }, {
1288
1291
  type: "TextPositionSelector",
1289
1292
  start: w,
1290
- end: v
1293
+ end: y
1291
1294
  }];
1292
1295
  return {
1293
- ...m,
1294
- id: g.id,
1296
+ ...g,
1297
+ id: m.id,
1295
1298
  source: e,
1296
- selector: y
1299
+ selector: b
1297
1300
  };
1298
1301
  });
1299
1302
  return {
1300
- ...r,
1303
+ ...i,
1301
1304
  "@context": "http://www.w3.org/ns/anno.jsonld",
1302
1305
  id: t.id,
1303
1306
  type: "Annotation",
1304
1307
  body: hn(t.bodies),
1305
- creator: s,
1308
+ creator: a,
1306
1309
  created: u == null ? void 0 : u.toISOString(),
1307
- modified: h == null ? void 0 : h.toISOString(),
1308
- target: l
1310
+ modified: f == null ? void 0 : f.toISOString(),
1311
+ target: d
1309
1312
  };
1310
1313
  };
1311
- function bn(t, e, n, o, i) {
1312
- zt(t, e, n || 0, o || t.length - 1, i || vn);
1314
+ function bn(t, e, n, o, r) {
1315
+ zt(t, e, n || 0, o || t.length - 1, r || vn);
1313
1316
  }
1314
- function zt(t, e, n, o, i) {
1317
+ function zt(t, e, n, o, r) {
1315
1318
  for (; o > n; ) {
1316
1319
  if (o - n > 600) {
1317
- var r = o - n + 1, c = e - n + 1, s = Math.log(r), u = 0.5 * Math.exp(2 * s / 3), h = 0.5 * Math.sqrt(s * u * (r - u) / r) * (c - r / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - c * u / r + h)), l = Math.min(o, Math.floor(e + (r - c) * u / r + h));
1318
- zt(t, e, m, l, i);
1320
+ var i = o - n + 1, s = e - n + 1, a = Math.log(i), u = 0.5 * Math.exp(2 * a / 3), f = 0.5 * Math.sqrt(a * u * (i - u) / i) * (s - i / 2 < 0 ? -1 : 1), g = Math.max(n, Math.floor(e - s * u / i + f)), d = Math.min(o, Math.floor(e + (i - s) * u / i + f));
1321
+ zt(t, e, g, d, r);
1319
1322
  }
1320
- var g = t[e], f = n, w = o;
1321
- for (j(t, n, e), i(t[o], g) > 0 && j(t, n, o); f < w; ) {
1322
- for (j(t, f, w), f++, w--; i(t[f], g) < 0; ) f++;
1323
- for (; i(t[w], g) > 0; ) w--;
1323
+ var m = t[e], h = n, w = o;
1324
+ for (j(t, n, e), r(t[o], m) > 0 && j(t, n, o); h < w; ) {
1325
+ for (j(t, h, w), h++, w--; r(t[h], m) < 0; ) h++;
1326
+ for (; r(t[w], m) > 0; ) w--;
1324
1327
  }
1325
- i(t[n], g) === 0 ? j(t, n, w) : (w++, j(t, w, o)), w <= e && (n = w + 1), e <= w && (o = w - 1);
1328
+ r(t[n], m) === 0 ? j(t, n, w) : (w++, j(t, w, o)), w <= e && (n = w + 1), e <= w && (o = w - 1);
1326
1329
  }
1327
1330
  }
1328
1331
  function j(t, e, n) {
@@ -1343,13 +1346,13 @@ class yn {
1343
1346
  let n = this.data;
1344
1347
  const o = [];
1345
1348
  if (!nt(e, n)) return o;
1346
- const i = this.toBBox, r = [];
1349
+ const r = this.toBBox, i = [];
1347
1350
  for (; n; ) {
1348
- for (let c = 0; c < n.children.length; c++) {
1349
- const s = n.children[c], u = n.leaf ? i(s) : s;
1350
- nt(e, u) && (n.leaf ? o.push(s) : gt(e, u) ? this._all(s, o) : r.push(s));
1351
+ for (let s = 0; s < n.children.length; s++) {
1352
+ const a = n.children[s], u = n.leaf ? r(a) : a;
1353
+ nt(e, u) && (n.leaf ? o.push(a) : gt(e, u) ? this._all(a, o) : i.push(a));
1351
1354
  }
1352
- n = r.pop();
1355
+ n = i.pop();
1353
1356
  }
1354
1357
  return o;
1355
1358
  }
@@ -1358,11 +1361,11 @@ class yn {
1358
1361
  if (!nt(e, n)) return !1;
1359
1362
  const o = [];
1360
1363
  for (; n; ) {
1361
- for (let i = 0; i < n.children.length; i++) {
1362
- const r = n.children[i], c = n.leaf ? this.toBBox(r) : r;
1363
- if (nt(e, c)) {
1364
- if (n.leaf || gt(e, c)) return !0;
1365
- o.push(r);
1364
+ for (let r = 0; r < n.children.length; r++) {
1365
+ const i = n.children[r], s = n.leaf ? this.toBBox(i) : i;
1366
+ if (nt(e, s)) {
1367
+ if (n.leaf || gt(e, s)) return !0;
1368
+ o.push(i);
1366
1369
  }
1367
1370
  }
1368
1371
  n = o.pop();
@@ -1399,15 +1402,15 @@ class yn {
1399
1402
  remove(e, n) {
1400
1403
  if (!e) return this;
1401
1404
  let o = this.data;
1402
- const i = this.toBBox(e), r = [], c = [];
1403
- let s, u, h;
1404
- for (; o || r.length; ) {
1405
- if (o || (o = r.pop(), u = r[r.length - 1], s = c.pop(), h = !0), o.leaf) {
1406
- const m = wn(e, o.children, n);
1407
- if (m !== -1)
1408
- return o.children.splice(m, 1), r.push(o), this._condense(r), this;
1405
+ const r = this.toBBox(e), i = [], s = [];
1406
+ let a, u, f;
1407
+ for (; o || i.length; ) {
1408
+ if (o || (o = i.pop(), u = i[i.length - 1], a = s.pop(), f = !0), o.leaf) {
1409
+ const g = wn(e, o.children, n);
1410
+ if (g !== -1)
1411
+ return o.children.splice(g, 1), i.push(o), this._condense(i), this;
1409
1412
  }
1410
- !h && !o.leaf && gt(o, i) ? (r.push(o), c.push(s), s = 0, u = o, o = o.children[0]) : u ? (s++, o = u.children[s], h = !1) : o = null;
1413
+ !f && !o.leaf && gt(o, r) ? (i.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], f = !1) : o = null;
1411
1414
  }
1412
1415
  return this;
1413
1416
  }
@@ -1432,82 +1435,82 @@ class yn {
1432
1435
  e.leaf ? n.push(...e.children) : o.push(...e.children), e = o.pop();
1433
1436
  return n;
1434
1437
  }
1435
- _build(e, n, o, i) {
1436
- const r = o - n + 1;
1437
- let c = this._maxEntries, s;
1438
- if (r <= c)
1439
- return s = W(e.slice(n, o + 1)), z(s, this.toBBox), s;
1440
- i || (i = Math.ceil(Math.log(r) / Math.log(c)), c = Math.ceil(r / Math.pow(c, i - 1))), s = W([]), s.leaf = !1, s.height = i;
1441
- const u = Math.ceil(r / c), h = u * Math.ceil(Math.sqrt(c));
1442
- Ut(e, n, o, h, this.compareMinX);
1443
- for (let m = n; m <= o; m += h) {
1444
- const l = Math.min(m + h - 1, o);
1445
- Ut(e, m, l, u, this.compareMinY);
1446
- for (let g = m; g <= l; g += u) {
1447
- const f = Math.min(g + u - 1, l);
1448
- s.children.push(this._build(e, g, f, i - 1));
1438
+ _build(e, n, o, r) {
1439
+ const i = o - n + 1;
1440
+ let s = this._maxEntries, a;
1441
+ if (i <= s)
1442
+ return a = W(e.slice(n, o + 1)), z(a, this.toBBox), a;
1443
+ r || (r = Math.ceil(Math.log(i) / Math.log(s)), s = Math.ceil(i / Math.pow(s, r - 1))), a = W([]), a.leaf = !1, a.height = r;
1444
+ const u = Math.ceil(i / s), f = u * Math.ceil(Math.sqrt(s));
1445
+ Vt(e, n, o, f, this.compareMinX);
1446
+ for (let g = n; g <= o; g += f) {
1447
+ const d = Math.min(g + f - 1, o);
1448
+ Vt(e, g, d, u, this.compareMinY);
1449
+ for (let m = g; m <= d; m += u) {
1450
+ const h = Math.min(m + u - 1, d);
1451
+ a.children.push(this._build(e, m, h, r - 1));
1449
1452
  }
1450
1453
  }
1451
- return z(s, this.toBBox), s;
1454
+ return z(a, this.toBBox), a;
1452
1455
  }
1453
- _chooseSubtree(e, n, o, i) {
1454
- for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
1455
- let r = 1 / 0, c = 1 / 0, s;
1456
+ _chooseSubtree(e, n, o, r) {
1457
+ for (; r.push(n), !(n.leaf || r.length - 1 === o); ) {
1458
+ let i = 1 / 0, s = 1 / 0, a;
1456
1459
  for (let u = 0; u < n.children.length; u++) {
1457
- const h = n.children[u], m = ft(h), l = En(e, h) - m;
1458
- l < c ? (c = l, r = m < r ? m : r, s = h) : l === c && m < r && (r = m, s = h);
1460
+ const f = n.children[u], g = ft(f), d = En(e, f) - g;
1461
+ d < s ? (s = d, i = g < i ? g : i, a = f) : d === s && g < i && (i = g, a = f);
1459
1462
  }
1460
- n = s || n.children[0];
1463
+ n = a || n.children[0];
1461
1464
  }
1462
1465
  return n;
1463
1466
  }
1464
1467
  _insert(e, n, o) {
1465
- const i = o ? e : this.toBBox(e), r = [], c = this._chooseSubtree(i, this.data, n, r);
1466
- for (c.children.push(e), K(c, i); n >= 0 && r[n].children.length > this._maxEntries; )
1467
- this._split(r, n), n--;
1468
- this._adjustParentBBoxes(i, r, n);
1468
+ const r = o ? e : this.toBBox(e), i = [], s = this._chooseSubtree(r, this.data, n, i);
1469
+ for (s.children.push(e), K(s, r); n >= 0 && i[n].children.length > this._maxEntries; )
1470
+ this._split(i, n), n--;
1471
+ this._adjustParentBBoxes(r, i, n);
1469
1472
  }
1470
1473
  // split overflowed node into two
1471
1474
  _split(e, n) {
1472
- const o = e[n], i = o.children.length, r = this._minEntries;
1473
- this._chooseSplitAxis(o, r, i);
1474
- const c = this._chooseSplitIndex(o, r, i), s = W(o.children.splice(c, o.children.length - c));
1475
- s.height = o.height, s.leaf = o.leaf, z(o, this.toBBox), z(s, this.toBBox), n ? e[n - 1].children.push(s) : this._splitRoot(o, s);
1475
+ const o = e[n], r = o.children.length, i = this._minEntries;
1476
+ this._chooseSplitAxis(o, i, r);
1477
+ const s = this._chooseSplitIndex(o, i, r), a = W(o.children.splice(s, o.children.length - s));
1478
+ a.height = o.height, a.leaf = o.leaf, z(o, this.toBBox), z(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
1476
1479
  }
1477
1480
  _splitRoot(e, n) {
1478
1481
  this.data = W([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, z(this.data, this.toBBox);
1479
1482
  }
1480
1483
  _chooseSplitIndex(e, n, o) {
1481
- let i, r = 1 / 0, c = 1 / 0;
1482
- for (let s = n; s <= o - n; s++) {
1483
- const u = G(e, 0, s, this.toBBox), h = G(e, s, o, this.toBBox), m = Sn(u, h), l = ft(u) + ft(h);
1484
- m < r ? (r = m, i = s, c = l < c ? l : c) : m === r && l < c && (c = l, i = s);
1484
+ let r, i = 1 / 0, s = 1 / 0;
1485
+ for (let a = n; a <= o - n; a++) {
1486
+ const u = G(e, 0, a, this.toBBox), f = G(e, a, o, this.toBBox), g = Sn(u, f), d = ft(u) + ft(f);
1487
+ g < i ? (i = g, r = a, s = d < s ? d : s) : g === i && d < s && (s = d, r = a);
1485
1488
  }
1486
- return i || o - n;
1489
+ return r || o - n;
1487
1490
  }
1488
1491
  // sorts node children by the best axis for split
1489
1492
  _chooseSplitAxis(e, n, o) {
1490
- const i = e.leaf ? this.compareMinX : xn, r = e.leaf ? this.compareMinY : An, c = this._allDistMargin(e, n, o, i), s = this._allDistMargin(e, n, o, r);
1491
- c < s && e.children.sort(i);
1493
+ const r = e.leaf ? this.compareMinX : xn, i = e.leaf ? this.compareMinY : An, s = this._allDistMargin(e, n, o, r), a = this._allDistMargin(e, n, o, i);
1494
+ s < a && e.children.sort(r);
1492
1495
  }
1493
1496
  // total margin of all possible split distributions where each node is at least m full
1494
- _allDistMargin(e, n, o, i) {
1495
- e.children.sort(i);
1496
- const r = this.toBBox, c = G(e, 0, n, r), s = G(e, o - n, o, r);
1497
- let u = et(c) + et(s);
1498
- for (let h = n; h < o - n; h++) {
1499
- const m = e.children[h];
1500
- K(c, e.leaf ? r(m) : m), u += et(c);
1497
+ _allDistMargin(e, n, o, r) {
1498
+ e.children.sort(r);
1499
+ const i = this.toBBox, s = G(e, 0, n, i), a = G(e, o - n, o, i);
1500
+ let u = et(s) + et(a);
1501
+ for (let f = n; f < o - n; f++) {
1502
+ const g = e.children[f];
1503
+ K(s, e.leaf ? i(g) : g), u += et(s);
1501
1504
  }
1502
- for (let h = o - n - 1; h >= n; h--) {
1503
- const m = e.children[h];
1504
- K(s, e.leaf ? r(m) : m), u += et(s);
1505
+ for (let f = o - n - 1; f >= n; f--) {
1506
+ const g = e.children[f];
1507
+ K(a, e.leaf ? i(g) : g), u += et(a);
1505
1508
  }
1506
1509
  return u;
1507
1510
  }
1508
1511
  _adjustParentBBoxes(e, n, o) {
1509
- for (let i = o; i >= 0; i--)
1510
- K(n[i], e);
1512
+ for (let r = o; r >= 0; r--)
1513
+ K(n[r], e);
1511
1514
  }
1512
1515
  _condense(e) {
1513
1516
  for (let n = e.length - 1, o; n >= 0; n--)
@@ -1523,13 +1526,13 @@ function wn(t, e, n) {
1523
1526
  function z(t, e) {
1524
1527
  G(t, 0, t.children.length, e, t);
1525
1528
  }
1526
- function G(t, e, n, o, i) {
1527
- i || (i = W(null)), i.minX = 1 / 0, i.minY = 1 / 0, i.maxX = -1 / 0, i.maxY = -1 / 0;
1528
- for (let r = e; r < n; r++) {
1529
- const c = t.children[r];
1530
- K(i, t.leaf ? o(c) : c);
1529
+ function G(t, e, n, o, r) {
1530
+ r || (r = W(null)), r.minX = 1 / 0, r.minY = 1 / 0, r.maxX = -1 / 0, r.maxY = -1 / 0;
1531
+ for (let i = e; i < n; i++) {
1532
+ const s = t.children[i];
1533
+ K(r, t.leaf ? o(s) : s);
1531
1534
  }
1532
- return i;
1535
+ return r;
1533
1536
  }
1534
1537
  function K(t, e) {
1535
1538
  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;
@@ -1550,8 +1553,8 @@ function En(t, e) {
1550
1553
  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));
1551
1554
  }
1552
1555
  function Sn(t, e) {
1553
- 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);
1554
- return Math.max(0, i - n) * Math.max(0, r - o);
1556
+ const n = Math.max(t.minX, e.minX), o = Math.max(t.minY, e.minY), r = Math.min(t.maxX, e.maxX), i = Math.min(t.maxY, e.maxY);
1557
+ return Math.max(0, r - n) * Math.max(0, i - o);
1555
1558
  }
1556
1559
  function gt(t, e) {
1557
1560
  return t.minX <= e.minX && t.minY <= e.minY && e.maxX <= t.maxX && e.maxY <= t.maxY;
@@ -1570,20 +1573,20 @@ function W(t) {
1570
1573
  maxY: -1 / 0
1571
1574
  };
1572
1575
  }
1573
- function Ut(t, e, n, o, i) {
1574
- const r = [e, n];
1575
- for (; r.length; ) {
1576
- if (n = r.pop(), e = r.pop(), n - e <= o) continue;
1577
- const c = e + Math.ceil((n - e) / o / 2) * o;
1578
- bn(t, c, e, n, i), r.push(e, c, c, n);
1576
+ function Vt(t, e, n, o, r) {
1577
+ const i = [e, n];
1578
+ for (; i.length; ) {
1579
+ if (n = i.pop(), e = i.pop(), n - e <= o) continue;
1580
+ const s = e + Math.ceil((n - e) / o / 2) * o;
1581
+ bn(t, s, e, n, r), i.push(e, s, s, n);
1579
1582
  }
1580
1583
  }
1581
1584
  const Cn = (t, e) => {
1582
- const n = new yn(), o = /* @__PURE__ */ new Map(), i = (d, a) => {
1583
- const y = d.selector.flatMap((L) => {
1585
+ const n = new yn(), o = /* @__PURE__ */ new Map(), r = (l, c) => {
1586
+ const b = l.selector.flatMap((L) => {
1584
1587
  const E = $([L]) ? L.range : Dt(L, e).range;
1585
1588
  return Array.from(E.getClientRects());
1586
- }), S = ce(y).map(({ left: L, top: E, right: T, bottom: B }) => new DOMRect(L - a.left, E - a.top, T - L, B - E));
1589
+ }), S = ce(b).map(({ left: L, top: E, right: T, bottom: B }) => new DOMRect(L - c.left, E - c.top, T - L, B - E));
1587
1590
  return S.map((L) => {
1588
1591
  const { x: E, y: T, width: B, height: M } = L;
1589
1592
  return {
@@ -1592,156 +1595,156 @@ const Cn = (t, e) => {
1592
1595
  maxX: E + B,
1593
1596
  maxY: T + M,
1594
1597
  annotation: {
1595
- id: d.annotation,
1598
+ id: l.annotation,
1596
1599
  rects: S
1597
1600
  }
1598
1601
  };
1599
1602
  });
1600
- }, r = () => [...o.values()], c = () => {
1603
+ }, i = () => [...o.values()], s = () => {
1601
1604
  n.clear(), o.clear();
1602
- }, s = (d) => {
1603
- const a = i(d, e.getBoundingClientRect());
1604
- a.forEach((y) => n.insert(y)), o.set(d.annotation, a);
1605
- }, u = (d) => {
1606
- const a = o.get(d.annotation);
1607
- a && (a.forEach((y) => n.remove(y)), o.delete(d.annotation));
1608
- }, h = (d) => {
1609
- u(d), s(d);
1610
- }, m = (d, a = !0) => {
1611
- a && c();
1612
- const y = e.getBoundingClientRect(), S = d.map((E) => ({ target: E, rects: i(E, y) }));
1605
+ }, a = (l) => {
1606
+ const c = r(l, e.getBoundingClientRect());
1607
+ c.forEach((b) => n.insert(b)), o.set(l.annotation, c);
1608
+ }, u = (l) => {
1609
+ const c = o.get(l.annotation);
1610
+ c && (c.forEach((b) => n.remove(b)), o.delete(l.annotation));
1611
+ }, f = (l) => {
1612
+ u(l), a(l);
1613
+ }, g = (l, c = !0) => {
1614
+ c && s();
1615
+ const b = e.getBoundingClientRect(), S = l.map((E) => ({ target: E, rects: r(E, b) }));
1613
1616
  S.forEach(({ target: E, rects: T }) => o.set(E.annotation, T));
1614
1617
  const L = S.flatMap(({ rects: E }) => E);
1615
1618
  n.load(L);
1616
- }, l = (d, a, y = !1) => {
1619
+ }, d = (l, c, b = !1) => {
1617
1620
  const S = n.search({
1618
- minX: d,
1619
- minY: a,
1620
- maxX: d,
1621
- maxY: a
1621
+ minX: l,
1622
+ minY: c,
1623
+ maxX: l,
1624
+ maxY: c
1622
1625
  }), L = (E) => E.annotation.rects.reduce((T, B) => T + B.width * B.height, 0);
1623
- return S.length > 0 ? (S.sort((E, T) => L(E) - L(T)), y ? S.map((E) => E.annotation.id) : [S[0].annotation.id]) : [];
1624
- }, g = (d) => {
1625
- const a = f(d);
1626
- if (a.length === 0)
1626
+ return S.length > 0 ? (S.sort((E, T) => L(E) - L(T)), b ? S.map((E) => E.annotation.id) : [S[0].annotation.id]) : [];
1627
+ }, m = (l) => {
1628
+ const c = h(l);
1629
+ if (c.length === 0)
1627
1630
  return;
1628
- let y = a[0].left, S = a[0].top, L = a[0].right, E = a[0].bottom;
1629
- for (let T = 1; T < a.length; T++) {
1630
- const B = a[T];
1631
- y = Math.min(y, B.left), S = Math.min(S, B.top), L = Math.max(L, B.right), E = Math.max(E, B.bottom);
1631
+ let b = c[0].left, S = c[0].top, L = c[0].right, E = c[0].bottom;
1632
+ for (let T = 1; T < c.length; T++) {
1633
+ const B = c[T];
1634
+ b = Math.min(b, B.left), S = Math.min(S, B.top), L = Math.max(L, B.right), E = Math.max(E, B.bottom);
1632
1635
  }
1633
- return new DOMRect(y, S, L - y, E - S);
1634
- }, f = (d) => {
1635
- const a = o.get(d);
1636
- return a ? a[0].annotation.rects : [];
1636
+ return new DOMRect(b, S, L - b, E - S);
1637
+ }, h = (l) => {
1638
+ const c = o.get(l);
1639
+ return c ? c[0].annotation.rects : [];
1637
1640
  };
1638
1641
  return {
1639
- all: r,
1640
- clear: c,
1641
- getAt: l,
1642
- getAnnotationBounds: g,
1643
- getAnnotationRects: f,
1644
- getIntersecting: (d, a, y, S) => {
1645
- const L = n.search({ minX: d, minY: a, maxX: y, maxY: S }), E = new Set(L.map((T) => T.annotation.id));
1642
+ all: i,
1643
+ clear: s,
1644
+ getAt: d,
1645
+ getAnnotationBounds: m,
1646
+ getAnnotationRects: h,
1647
+ getIntersecting: (l, c, b, S) => {
1648
+ const L = n.search({ minX: l, minY: c, maxX: b, maxY: S }), E = new Set(L.map((T) => T.annotation.id));
1646
1649
  return Array.from(E).map((T) => ({
1647
1650
  annotation: t.getAnnotation(T),
1648
- rects: f(T)
1651
+ rects: h(T)
1649
1652
  })).filter((T) => !!T.annotation);
1650
1653
  },
1651
- insert: s,
1652
- recalculate: () => m(t.all().map((d) => d.target), !0),
1654
+ insert: a,
1655
+ recalculate: () => g(t.all().map((l) => l.target), !0),
1653
1656
  remove: u,
1654
- set: m,
1657
+ set: g,
1655
1658
  size: () => n.all().length,
1656
- update: h
1659
+ update: f
1657
1660
  };
1658
1661
  }, Ln = (t, e) => {
1659
- const n = Ge(), o = Cn(n, t), i = ke(n, e), r = Ve(n), c = Ze(), s = (v, p = N.LOCAL) => {
1660
- const d = rt(v, t), a = $(d.target.selector);
1661
- return a && n.addAnnotation(d, p), a;
1662
- }, u = (v, p = !0, d = N.LOCAL) => {
1663
- const a = v.map((S) => rt(S, t)), y = a.filter((S) => !$(S.target.selector));
1664
- return y.length > 0 ? (console.warn("Could not revive all targets for these annotations:", y), n.bulkAddAnnotation(a, p, d), y) : (n.bulkAddAnnotation(a, p, d), []);
1665
- }, h = (v, p = N.LOCAL) => {
1666
- const d = v.map((y) => rt(y, t)), a = d.filter((y) => !$(y.target.selector));
1667
- return a.length > 0 && console.warn("Could not revive all targets for these annotations:", a), d.forEach((y) => {
1668
- n.getAnnotation(y.id) ? n.updateAnnotation(y, p) : n.addAnnotation(y, p);
1669
- }), a;
1670
- }, m = (v, p = N.LOCAL) => {
1671
- const d = it(v, t);
1672
- n.updateTarget(d, p);
1673
- }, l = (v, p = N.LOCAL) => {
1674
- const d = v.map((a) => it(a, t));
1675
- n.bulkUpdateTargets(d, p);
1676
- }, g = (v, p, d) => {
1677
- const a = o.getAt(v, p, !!d).map((S) => n.getAnnotation(S)), y = d ? a.filter(d) : a;
1678
- return y.length > 0 ? y[0] : void 0;
1679
- }, f = (v, p, d, a = 5) => {
1680
- const y = o.getAnnotationRects(v);
1681
- if (y.length !== 0) {
1682
- if (p && d) {
1683
- const S = y.find(({ top: L, right: E, bottom: T, left: B }) => p >= B - a && p <= E + a && d >= L - a && d <= T + a);
1662
+ const n = Ge(), o = Cn(n, t), r = ke(n, e), i = Ue(n), s = Ze(), a = (y, p = N.LOCAL) => {
1663
+ const l = it(y, t), c = $(l.target.selector);
1664
+ return c && n.addAnnotation(l, p), c;
1665
+ }, u = (y, p = !0, l = N.LOCAL) => {
1666
+ const c = y.map((S) => it(S, t)), b = c.filter((S) => !$(S.target.selector));
1667
+ return b.length > 0 ? (console.warn("Could not revive all targets for these annotations:", b), n.bulkAddAnnotation(c, p, l), b) : (n.bulkAddAnnotation(c, p, l), []);
1668
+ }, f = (y, p = N.LOCAL) => {
1669
+ const l = y.map((b) => it(b, t)), c = l.filter((b) => !$(b.target.selector));
1670
+ return c.length > 0 && console.warn("Could not revive all targets for these annotations:", c), l.forEach((b) => {
1671
+ n.getAnnotation(b.id) ? n.updateAnnotation(b, p) : n.addAnnotation(b, p);
1672
+ }), c;
1673
+ }, g = (y, p = N.LOCAL) => {
1674
+ const l = rt(y, t);
1675
+ n.updateTarget(l, p);
1676
+ }, d = (y, p = N.LOCAL) => {
1677
+ const l = y.map((c) => rt(c, t));
1678
+ n.bulkUpdateTargets(l, p);
1679
+ }, m = (y, p, l) => {
1680
+ const c = o.getAt(y, p, !!l).map((S) => n.getAnnotation(S)), b = l ? c.filter(l) : c;
1681
+ return b.length > 0 ? b[0] : void 0;
1682
+ }, h = (y, p, l, c = 5) => {
1683
+ const b = o.getAnnotationRects(y);
1684
+ if (b.length !== 0) {
1685
+ if (p && l) {
1686
+ const S = b.find(({ top: L, right: E, bottom: T, left: B }) => p >= B - c && p <= E + c && l >= L - c && l <= T + c);
1684
1687
  if (S) return S;
1685
1688
  }
1686
- return o.getAnnotationBounds(v);
1689
+ return o.getAnnotationBounds(y);
1687
1690
  }
1688
1691
  }, w = () => o.recalculate();
1689
- return n.observe(({ changes: v }) => {
1690
- const p = (v.deleted || []).filter((y) => $(y.target.selector)), d = (v.created || []).filter((y) => $(y.target.selector)), a = (v.updated || []).filter((y) => $(y.newValue.target.selector));
1691
- (p == null ? void 0 : p.length) > 0 && p.forEach((y) => o.remove(y.target)), d.length > 0 && o.set(d.map((y) => y.target), !1), (a == null ? void 0 : a.length) > 0 && a.forEach(({ newValue: y }) => o.update(y.target));
1692
+ return n.observe(({ changes: y }) => {
1693
+ const p = (y.deleted || []).filter((b) => $(b.target.selector)), l = (y.created || []).filter((b) => $(b.target.selector)), c = (y.updated || []).filter((b) => $(b.newValue.target.selector));
1694
+ (p == null ? void 0 : p.length) > 0 && p.forEach((b) => o.remove(b.target)), l.length > 0 && o.set(l.map((b) => b.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: b }) => o.update(b.target));
1692
1695
  }), {
1693
1696
  store: {
1694
1697
  ...n,
1695
- addAnnotation: s,
1698
+ addAnnotation: a,
1696
1699
  bulkAddAnnotation: u,
1697
- bulkUpdateTargets: l,
1698
- bulkUpsertAnnotations: h,
1699
- getAnnotationBounds: f,
1700
- getAt: g,
1700
+ bulkUpdateTargets: d,
1701
+ bulkUpsertAnnotations: f,
1702
+ getAnnotationBounds: h,
1703
+ getAt: m,
1701
1704
  getIntersecting: o.getIntersecting,
1702
1705
  recalculatePositions: w,
1703
- updateTarget: m
1706
+ updateTarget: g
1704
1707
  },
1705
- selection: i,
1706
- hover: r,
1707
- viewport: c
1708
+ selection: r,
1709
+ hover: i,
1710
+ viewport: s
1708
1711
  };
1709
1712
  }, Bn = () => {
1710
1713
  const t = document.createElement("canvas");
1711
- t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-highlight-layer presence";
1714
+ t.width = 2 * window.innerWidth, t.height = 2 * window.innerHeight, t.className = "r6o-presence-layer";
1712
1715
  const e = t.getContext("2d");
1713
1716
  return e.scale(2, 2), e.translate(0.5, 0.5), t;
1714
1717
  }, Tn = (t, e, n = {}) => {
1715
- const o = Bn(), i = o.getContext("2d");
1716
- t.appendChild(o);
1717
- const r = /* @__PURE__ */ new Map(), c = (l) => Array.from(r.entries()).filter(([g, f]) => f.presenceKey === l.presenceKey).map(([g, f]) => g);
1718
- return e.on("selectionChange", (l, g) => {
1719
- c(l).forEach((w) => r.delete(w)), g && g.forEach((w) => r.set(w, l));
1718
+ const o = Bn(), r = o.getContext("2d");
1719
+ document.body.appendChild(o);
1720
+ const i = /* @__PURE__ */ new Map(), s = (d) => Array.from(i.entries()).filter(([m, h]) => h.presenceKey === d.presenceKey).map(([m, h]) => m);
1721
+ return e.on("selectionChange", (d, m) => {
1722
+ s(d).forEach((w) => i.delete(w)), m && m.forEach((w) => i.set(w, d));
1720
1723
  }), {
1721
1724
  clear: () => {
1722
- const { width: l, height: g } = o;
1723
- i.clearRect(-0.5, -0.5, l + 1, g + 1);
1725
+ const { width: d, height: m } = o;
1726
+ r.clearRect(-0.5, -0.5, d + 1, m + 1);
1724
1727
  },
1725
1728
  destroy: () => {
1726
1729
  o.remove();
1727
1730
  },
1728
- paint: (l, g, f) => {
1729
- n.font && (i.font = n.font);
1730
- const w = r.get(l.annotation.id);
1731
+ paint: (d, m, h) => {
1732
+ n.font && (r.font = n.font);
1733
+ const w = i.get(d.annotation.id);
1731
1734
  if (w) {
1732
- const { height: v } = l.rects[0], p = l.rects[0].x + g.left, d = l.rects[0].y + g.top;
1733
- i.fillStyle = w.appearance.color, i.fillRect(p - 2, d - 2.5, 2, v + 5);
1734
- const a = i.measureText(w.appearance.label), y = a.width + 6, S = a.actualBoundingBoxAscent + a.actualBoundingBoxDescent + 8, L = a.fontBoundingBoxAscent ? 8 : 6.5;
1735
- return i.fillRect(p - 2, d - 2.5 - S, y, S), i.fillStyle = "#fff", i.fillText(w.appearance.label, p + 1, d - L), {
1735
+ const { height: y } = d.rects[0], p = d.rects[0].x + m.left, l = d.rects[0].y + m.top;
1736
+ r.fillStyle = w.appearance.color, r.fillRect(p - 2, l - 2.5, 2, y + 5);
1737
+ const c = r.measureText(w.appearance.label), b = c.width + 6, S = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;
1738
+ return r.fillRect(p - 2, l - 2.5 - S, b, S), r.fillStyle = "#fff", r.fillText(w.appearance.label, p + 1, l - L), {
1736
1739
  fill: w.appearance.color,
1737
- fillOpacity: f ? 0.45 : 0.18
1740
+ fillOpacity: h ? 0.45 : 0.18
1738
1741
  };
1739
1742
  }
1740
1743
  },
1741
1744
  reset: () => {
1742
1745
  o.width = 2 * window.innerWidth, o.height = 2 * window.innerHeight;
1743
- const l = o.getContext("2d");
1744
- l.scale(2, 2), l.translate(0.5, 0.5);
1746
+ const d = o.getContext("2d");
1747
+ d.scale(2, 2), d.translate(0.5, 0.5);
1745
1748
  }
1746
1749
  };
1747
1750
  }, Wt = (t) => {
@@ -1750,126 +1753,126 @@ const Cn = (t, e) => {
1750
1753
  const { overflowY: e } = window.getComputedStyle(t);
1751
1754
  return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Wt(t.parentElement);
1752
1755
  }, Rn = (t, e) => (n) => {
1753
- const o = typeof n == "string" ? n : n.id, i = (c) => {
1754
- const s = r.getBoundingClientRect(), u = r.clientHeight, h = r.clientWidth, m = c.selector[0].range.getBoundingClientRect(), { width: l, height: g } = e.getAnnotationBounds(o), f = m.top - s.top, w = m.left - s.left, v = r.parentElement ? r.scrollTop : 0, p = r.parentElement ? r.scrollLeft : 0, d = f + v - (u - g) / 2, a = w + p - (h - l) / 2;
1755
- r.scroll({ top: d, left: a, behavior: "smooth" });
1756
- }, r = Wt(t);
1757
- if (r) {
1758
- const c = e.getAnnotation(o), { range: s } = c.target.selector[0];
1759
- if (s && !s.collapsed)
1760
- return i(c.target), !0;
1756
+ const o = typeof n == "string" ? n : n.id, r = (s) => {
1757
+ const a = i.getBoundingClientRect(), u = i.clientHeight, f = i.clientWidth, g = s.selector[0].range.getBoundingClientRect(), { width: d, height: m } = e.getAnnotationBounds(o), h = g.top - a.top, w = g.left - a.left, y = i.parentElement ? i.scrollTop : 0, p = i.parentElement ? i.scrollLeft : 0, l = h + y - (u - m) / 2, c = w + p - (f - d) / 2;
1758
+ i.scroll({ top: l, left: c, behavior: "smooth" });
1759
+ }, i = Wt(t);
1760
+ if (i) {
1761
+ const s = e.getAnnotation(o), { range: a } = s.target.selector[0];
1762
+ if (a && !a.collapsed)
1763
+ return r(s.target), !0;
1761
1764
  {
1762
- const u = it(c.target, t), { range: h } = u.selector[0];
1763
- if (h && !h.collapsed)
1764
- return i(u), !0;
1765
+ const u = rt(s.target, t), { range: f } = u.selector[0];
1766
+ if (f && !f.collapsed)
1767
+ return r(u), !0;
1765
1768
  }
1766
1769
  }
1767
1770
  return !1;
1768
1771
  }, Nn = (t, e) => ({
1769
1772
  ...t,
1770
- annotationEnabled: t.annotationEnabled === void 0 ? e.annotationEnabled : t.annotationEnabled
1773
+ annotatingEnabled: t.annotatingEnabled ?? e.annotatingEnabled
1771
1774
  }), Mn = (t, e, n, o) => {
1772
- let i;
1773
- const r = (a) => i = a;
1774
- let c;
1775
- const s = (a) => c = a, { store: u, selection: h } = e;
1776
- let m, l = !1, g;
1777
- const f = (a) => {
1775
+ let r;
1776
+ const i = (c) => r = c;
1777
+ let s;
1778
+ const a = (c) => s = c, { store: u, selection: f } = e;
1779
+ let g, d = !1, m;
1780
+ const h = (c) => {
1778
1781
  var S;
1779
- if (!l) return;
1780
- !((S = a.target.parentElement) != null && S.closest(D)) ? m = {
1782
+ if (!d) return;
1783
+ !((S = c.target.parentElement) != null && S.closest(D)) ? g = {
1781
1784
  annotation: Ht(),
1782
1785
  selector: [],
1783
- creator: i,
1786
+ creator: r,
1784
1787
  created: /* @__PURE__ */ new Date()
1785
- } : m = void 0;
1788
+ } : g = void 0;
1786
1789
  };
1787
- n && t.addEventListener("selectstart", f);
1788
- const w = bt((a) => {
1790
+ n && t.addEventListener("selectstart", h);
1791
+ const w = bt((c) => {
1789
1792
  var B, M;
1790
- const y = document.getSelection();
1791
- if (!!((M = (B = y.anchorNode) == null ? void 0 : B.parentElement) != null && M.closest(D))) {
1792
- m = void 0;
1793
+ const b = document.getSelection();
1794
+ if (!!((M = (B = b.anchorNode) == null ? void 0 : B.parentElement) != null && M.closest(D))) {
1795
+ g = void 0;
1793
1796
  return;
1794
1797
  }
1795
- if (a.timeStamp - ((g == null ? void 0 : g.timeStamp) || a.timeStamp) < 1e3 && !m && f(g), y.isCollapsed || !l || !m) return;
1796
- const L = y.getRangeAt(0);
1797
- if (re(L)) return;
1798
+ if (c.timeStamp - ((m == null ? void 0 : m.timeStamp) || c.timeStamp) < 1e3 && !g && h(m), b.isCollapsed || !d || !g) return;
1799
+ const L = b.getRangeAt(0);
1800
+ if (ie(L)) return;
1798
1801
  const E = Zt(L.cloneRange());
1799
- (E.length !== m.selector.length || E.some((b, x) => {
1802
+ (E.length !== g.selector.length || E.some((v, x) => {
1800
1803
  var A;
1801
- return b.toString() !== ((A = m.selector[x]) == null ? void 0 : A.quote);
1802
- })) && (m = {
1803
- ...m,
1804
- selector: E.map((b) => le(b, t, o)),
1804
+ return v.toString() !== ((A = g.selector[x]) == null ? void 0 : A.quote);
1805
+ })) && (g = {
1806
+ ...g,
1807
+ selector: E.map((v) => le(v, t, o)),
1805
1808
  updated: /* @__PURE__ */ new Date()
1806
- }, u.getAnnotation(m.annotation) ? u.updateTarget(m, N.LOCAL) : (h.clear(), u.addAnnotation({
1807
- id: m.annotation,
1809
+ }, u.getAnnotation(g.annotation) ? u.updateTarget(g, N.LOCAL) : (f.clear(), u.addAnnotation({
1810
+ id: g.annotation,
1808
1811
  bodies: [],
1809
- target: m
1810
- }), h.clickSelect(m.annotation, g)));
1812
+ target: g
1813
+ }), f.userSelect(g.annotation, m)));
1811
1814
  });
1812
1815
  n && document.addEventListener("selectionchange", w);
1813
- const v = (a) => {
1814
- const { target: y, timeStamp: S, offsetX: L, offsetY: E, type: T } = a;
1815
- g = { ...a, target: y, timeStamp: S, offsetX: L, offsetY: E, type: T }, l = a.button === 0;
1816
+ const y = (c) => {
1817
+ const { target: b, timeStamp: S, offsetX: L, offsetY: E, type: T } = c;
1818
+ m = { ...c, target: b, timeStamp: S, offsetX: L, offsetY: E, type: T }, d = c.button === 0;
1816
1819
  };
1817
- t.addEventListener("pointerdown", v);
1818
- const p = (a) => {
1820
+ t.addEventListener("pointerdown", y);
1821
+ const p = (c) => {
1819
1822
  var E;
1820
- if (!!((E = a.target.parentElement) != null && E.closest(D)) || !l)
1823
+ if (!!((E = c.target.parentElement) != null && E.closest(D)) || !d)
1821
1824
  return;
1822
1825
  const S = () => {
1823
- const { x: T, y: B } = t.getBoundingClientRect(), M = u.getAt(a.clientX - T, a.clientY - B, c);
1826
+ const { x: T, y: B } = t.getBoundingClientRect(), M = u.getAt(c.clientX - T, c.clientY - B, s);
1824
1827
  if (M) {
1825
- const { selected: b } = h;
1826
- (b.length !== 1 || b[0].id !== M.id) && h.clickSelect(M.id, a);
1827
- } else h.isEmpty() || h.clear();
1828
- }, L = a.timeStamp - g.timeStamp;
1829
- document.getSelection().isCollapsed && L < 300 ? (m = void 0, S()) : m && h.clickSelect(m.annotation, a);
1828
+ const { selected: v } = f;
1829
+ (v.length !== 1 || v[0].id !== M.id) && f.userSelect(M.id, c);
1830
+ } else f.isEmpty() || f.clear();
1831
+ }, L = c.timeStamp - m.timeStamp;
1832
+ document.getSelection().isCollapsed && L < 300 ? (g = void 0, S()) : g && f.userSelect(g.annotation, c);
1830
1833
  };
1831
1834
  return document.addEventListener("pointerup", p), {
1832
1835
  destroy: () => {
1833
- t.removeEventListener("selectstart", f), document.removeEventListener("selectionchange", w), t.removeEventListener("pointerdown", v), document.removeEventListener("pointerup", p);
1836
+ t.removeEventListener("selectstart", h), document.removeEventListener("selectionchange", w), t.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", p);
1834
1837
  },
1835
- setFilter: s,
1836
- setUser: r
1838
+ setFilter: a,
1839
+ setUser: i
1837
1840
  };
1838
1841
  }, kt = "SPANS", kn = (t, e = {}) => {
1839
1842
  te(t);
1840
1843
  const n = Nn(e, {
1841
- annotationEnabled: !0
1842
- }), o = Ln(t, n.pointerAction), { selection: i, viewport: r } = o, c = o.store, s = Je(c), u = tn(o, s, n.adapter);
1843
- let h = ln();
1844
- const m = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : kt : n.renderer || kt, l = m === "SPANS" ? Te(t, o, r) : m === "CSS_HIGHLIGHTS" ? Ce(t, o, r) : m === "CANVAS" ? pe(t, o, r) : void 0;
1845
- if (!l)
1846
- throw `Unknown renderer implementation: ${m}`;
1847
- console.debug(`Using ${m} renderer`), n.style && l.setStyle(n.style);
1848
- const g = Mn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
1849
- return g.setUser(h), {
1850
- ...nn(o, s, n.adapter),
1844
+ annotatingEnabled: !0
1845
+ }), o = Ln(t, n.userAction), { selection: r, viewport: i } = o, s = o.store, a = Je(s), u = tn(o, a, n.adapter);
1846
+ let f = ln();
1847
+ const g = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : kt : n.renderer || kt, d = g === "SPANS" ? Te(t, o, i) : g === "CSS_HIGHLIGHTS" ? Ce(t, o, i) : g === "CANVAS" ? pe(t, o, i) : void 0;
1848
+ if (!d)
1849
+ throw `Unknown renderer implementation: ${g}`;
1850
+ console.debug(`Using ${g} renderer`), n.style && d.setStyle(n.style);
1851
+ const m = Mn(t, o, n.annotatingEnabled, n.offsetReferenceSelector);
1852
+ return m.setUser(f), {
1853
+ ...nn(o, a, n.adapter),
1851
1854
  destroy: () => {
1852
- l.destroy(), g.destroy(), s.destroy();
1855
+ d.destroy(), m.destroy(), a.destroy();
1853
1856
  },
1854
1857
  element: t,
1855
- getUser: () => h,
1858
+ getUser: () => f,
1856
1859
  setFilter: (E) => {
1857
- l.setFilter(E), g.setFilter(E);
1860
+ d.setFilter(E), m.setFilter(E);
1858
1861
  },
1859
- setStyle: (E) => l.setStyle(E),
1862
+ setStyle: (E) => d.setStyle(E),
1860
1863
  setUser: (E) => {
1861
- h = E, g.setUser(E);
1864
+ f = E, m.setUser(E);
1862
1865
  },
1863
1866
  setSelected: (E) => {
1864
- E ? i.setSelected(E) : i.clear();
1867
+ E ? r.setSelected(E) : r.clear();
1865
1868
  },
1866
1869
  setPresenceProvider: (E) => {
1867
- E && (l.setPainter(Tn(t, E, n.presence)), E.on("selectionChange", () => l.redraw()));
1870
+ E && (d.setPainter(Tn(t, E, n.presence)), E.on("selectionChange", () => d.redraw()));
1868
1871
  },
1869
- setVisible: (E) => l.setVisible(E),
1872
+ setVisible: (E) => d.setVisible(E),
1870
1873
  on: u.on,
1871
1874
  off: u.off,
1872
- scrollIntoView: Rn(t, c),
1875
+ scrollIntoView: Rn(t, s),
1873
1876
  state: o
1874
1877
  };
1875
1878
  };
@@ -1879,10 +1882,10 @@ export {
1879
1882
  Yt as NOT_ANNOTATABLE_CLASS,
1880
1883
  D as NOT_ANNOTATABLE_SELECTOR,
1881
1884
  N as Origin,
1882
- Ue as PointerSelectAction,
1883
- Un as W3CTextFormat,
1885
+ Ve as UserSelectAction,
1886
+ Vn as W3CTextFormat,
1884
1887
  te as cancelSingleClickEvents,
1885
- Vn as createBody,
1888
+ Un as createBody,
1886
1889
  pe as createCanvasRenderer,
1887
1890
  Ce as createHighlightsRenderer,
1888
1891
  Se as createRenderer,
@@ -1896,16 +1899,16 @@ export {
1896
1899
  oe as getQuoteContext,
1897
1900
  pt as getRangeAnnotatableContents,
1898
1901
  $ as isRevived,
1899
- re as isWhitespaceOrEmpty,
1902
+ ie as isWhitespaceOrEmpty,
1900
1903
  ce as mergeClientRects,
1901
1904
  Kt as paint,
1902
1905
  pn as parseW3CTextAnnotation,
1903
1906
  le as rangeToSelector,
1904
- rt as reviveAnnotation,
1907
+ it as reviveAnnotation,
1905
1908
  Dt as reviveSelector,
1906
- it as reviveTarget,
1909
+ rt as reviveTarget,
1907
1910
  mn as serializeW3CTextAnnotation,
1908
1911
  Zt as splitAnnotatableRanges,
1909
- ie as whitespaceOrEmptyRegex
1912
+ re as whitespaceOrEmptyRegex
1910
1913
  };
1911
1914
  //# sourceMappingURL=text-annotator.es.js.map