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