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