@soomo/text-annotator 3.0.0-staging.29 → 3.0.0-staging.30
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.
|
@@ -5,8 +5,8 @@ const P = {
|
|
|
5
5
|
fill: "rgb(0, 128, 255)",
|
|
6
6
|
fillOpacity: 0.45
|
|
7
7
|
}, Kt = (t, e, n, o, i) => {
|
|
8
|
-
var s,
|
|
9
|
-
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((s = t.state) != null && s.selected ? ot : P) : n : (
|
|
8
|
+
var s, a;
|
|
9
|
+
const r = n ? typeof n == "function" ? n(t.annotation, t.state, i) || ((s = t.state) != null && s.selected ? ot : P) : n : (a = t.state) != null && a.selected ? ot : P;
|
|
10
10
|
return o && o.paint(t, e) || r;
|
|
11
11
|
}, Yt = "not-annotatable", D = `.${Yt}`, Qt = (t) => {
|
|
12
12
|
var n;
|
|
@@ -72,30 +72,30 @@ const P = {
|
|
|
72
72
|
endContainer: i,
|
|
73
73
|
endOffset: r
|
|
74
74
|
} = t, s = Array.from(e.childNodes).map((l) => {
|
|
75
|
-
const
|
|
76
|
-
return l.nodeName === "CANVAS" ? l :
|
|
77
|
-
}),
|
|
75
|
+
const g = l.cloneNode(!0);
|
|
76
|
+
return l.nodeName === "CANVAS" ? l : g;
|
|
77
|
+
}), a = wt(n, e), u = wt(i, e), h = () => {
|
|
78
78
|
const l = e;
|
|
79
79
|
l.replaceChildren(...s);
|
|
80
|
-
const
|
|
81
|
-
return t.setStart(
|
|
80
|
+
const g = xt(a, l), p = xt(u, l);
|
|
81
|
+
return t.setStart(g, o), t.setEnd(p, r), t;
|
|
82
82
|
}, m = (l) => {
|
|
83
|
-
const
|
|
84
|
-
return l.surroundContents(
|
|
83
|
+
const g = document.createElement("SPAN");
|
|
84
|
+
return l.surroundContents(g), g;
|
|
85
85
|
};
|
|
86
86
|
if (n === i)
|
|
87
87
|
throw "Not implemented";
|
|
88
88
|
{
|
|
89
89
|
const l = document.createRange();
|
|
90
90
|
l.selectNodeContents(n), l.setStart(n, o);
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
const w = m(
|
|
94
|
-
var
|
|
95
|
-
const
|
|
96
|
-
return (
|
|
91
|
+
const g = m(l), p = document.createRange();
|
|
92
|
+
p.selectNode(i), p.setEnd(i, r);
|
|
93
|
+
const w = m(p), f = ne(t).reverse().map((d) => {
|
|
94
|
+
var v;
|
|
95
|
+
const c = document.createElement("SPAN");
|
|
96
|
+
return (v = d.parentNode) == null || v.insertBefore(c, d), c.appendChild(d), c;
|
|
97
97
|
});
|
|
98
|
-
return { unwrap: h, nodes: [
|
|
98
|
+
return { unwrap: h, nodes: [g, ...f, w] };
|
|
99
99
|
}
|
|
100
100
|
}, ne = (t) => {
|
|
101
101
|
const {
|
|
@@ -104,24 +104,24 @@ const P = {
|
|
|
104
104
|
endContainer: o
|
|
105
105
|
} = t, i = document.createNodeIterator(e, NodeFilter.SHOW_TEXT);
|
|
106
106
|
let r = i.nextNode(), s = !1;
|
|
107
|
-
const
|
|
107
|
+
const a = [];
|
|
108
108
|
for (; r != null; )
|
|
109
|
-
r === o && (s = !1), s &&
|
|
110
|
-
return
|
|
109
|
+
r === o && (s = !1), s && a.push(r), r === n && (s = !0), r = i.nextNode();
|
|
110
|
+
return a;
|
|
111
111
|
}, In = (t) => {
|
|
112
112
|
const { startContainer: e, endContainer: n } = t;
|
|
113
113
|
if (e === n)
|
|
114
114
|
return Array.from(t.getClientRects());
|
|
115
115
|
{
|
|
116
|
-
const { unwrap: o, nodes: i } = ee(t), r = i.reduce((s,
|
|
116
|
+
const { unwrap: o, nodes: i } = ee(t), r = i.reduce((s, a) => [...s, ...a.getClientRects()], []);
|
|
117
117
|
return o(), r;
|
|
118
118
|
}
|
|
119
119
|
}, oe = (t, e, n = 10, o) => {
|
|
120
120
|
const i = o ? t.startContainer.parentElement.closest(o) : e, r = document.createRange();
|
|
121
121
|
r.setStart(i, 0), r.setEnd(t.startContainer, t.startOffset);
|
|
122
|
-
const s = gt(r).textContent,
|
|
123
|
-
|
|
124
|
-
const u = gt(
|
|
122
|
+
const s = gt(r).textContent, a = document.createRange();
|
|
123
|
+
a.setStart(t.endContainer, t.endOffset), i === document.body ? a.setEnd(i, i.childNodes.length) : a.setEndAfter(i);
|
|
124
|
+
const u = gt(a).textContent;
|
|
125
125
|
return {
|
|
126
126
|
prefix: s.substring(s.length - n),
|
|
127
127
|
suffix: u.substring(0, n)
|
|
@@ -160,16 +160,16 @@ const P = {
|
|
|
160
160
|
for (const r of e) {
|
|
161
161
|
const s = se(n, r);
|
|
162
162
|
if (s === "inline-adjacent") {
|
|
163
|
-
o = o.map((
|
|
163
|
+
o = o.map((a) => a === r ? ae(n, r) : a), i = !0;
|
|
164
164
|
break;
|
|
165
165
|
} else if (s === "inline-contains") {
|
|
166
|
-
o = o.map((
|
|
166
|
+
o = o.map((a) => a === r ? n : a), i = !0;
|
|
167
167
|
break;
|
|
168
168
|
} else if (s === "inline-is-contained") {
|
|
169
169
|
i = !0;
|
|
170
170
|
break;
|
|
171
171
|
} else if (s === "block-contains" || s === "block-is-contained") {
|
|
172
|
-
n.width < r.width && (o = o.map((
|
|
172
|
+
n.width < r.width && (o = o.map((a) => a === r ? n : a)), i = !0;
|
|
173
173
|
break;
|
|
174
174
|
}
|
|
175
175
|
}
|
|
@@ -177,52 +177,52 @@ const P = {
|
|
|
177
177
|
}, []), le = (t, e, n) => {
|
|
178
178
|
const o = document.createRange(), i = n ? t.startContainer.parentElement.closest(n) : e;
|
|
179
179
|
o.setStart(i, 0), o.setEnd(t.startContainer, t.startOffset);
|
|
180
|
-
const r = gt(o).textContent, s = t.toString(),
|
|
181
|
-
return n ? { quote: s, start:
|
|
180
|
+
const r = gt(o).textContent, s = t.toString(), a = r.length || 0, u = a + s.length;
|
|
181
|
+
return n ? { quote: s, start: a, end: u, range: t, offsetReference: i } : { quote: s, start: a, end: u, range: t };
|
|
182
182
|
}, Dt = (t, e) => {
|
|
183
183
|
var m, l;
|
|
184
184
|
const { start: n, end: o } = t, i = t.offsetReference || e, r = document.createNodeIterator(
|
|
185
185
|
e,
|
|
186
186
|
NodeFilter.SHOW_TEXT,
|
|
187
|
-
(
|
|
188
|
-
var
|
|
189
|
-
return (
|
|
187
|
+
(g) => {
|
|
188
|
+
var p;
|
|
189
|
+
return (p = g.parentElement) != null && p.closest(D) ? NodeFilter.FILTER_SKIP : NodeFilter.FILTER_ACCEPT;
|
|
190
190
|
}
|
|
191
191
|
);
|
|
192
192
|
let s = 0;
|
|
193
|
-
const
|
|
193
|
+
const a = document.createRange();
|
|
194
194
|
let u = r.nextNode();
|
|
195
195
|
u === null && console.error("Could not revive annotation target. Content missing.");
|
|
196
196
|
let h = !i;
|
|
197
197
|
for (; u !== null; ) {
|
|
198
198
|
if (h || (h = i == null ? void 0 : i.contains(u)), h) {
|
|
199
|
-
const
|
|
200
|
-
if (s +
|
|
201
|
-
|
|
199
|
+
const g = ((m = u.textContent) == null ? void 0 : m.length) || 0;
|
|
200
|
+
if (s + g > n) {
|
|
201
|
+
a.setStart(u, n - s);
|
|
202
202
|
break;
|
|
203
203
|
}
|
|
204
|
-
s +=
|
|
204
|
+
s += g;
|
|
205
205
|
}
|
|
206
206
|
u = r.nextNode();
|
|
207
207
|
}
|
|
208
208
|
for (; u !== null; ) {
|
|
209
|
-
const
|
|
210
|
-
if (s +
|
|
211
|
-
|
|
209
|
+
const g = ((l = u.textContent) == null ? void 0 : l.length) || 0;
|
|
210
|
+
if (s + g >= o) {
|
|
211
|
+
a.setEnd(u, o - s);
|
|
212
212
|
break;
|
|
213
213
|
}
|
|
214
|
-
s +=
|
|
214
|
+
s += g, u = r.nextNode();
|
|
215
215
|
}
|
|
216
216
|
return {
|
|
217
217
|
...t,
|
|
218
|
-
range:
|
|
218
|
+
range: a
|
|
219
219
|
};
|
|
220
220
|
}, it = (t, e) => $(t.selector) ? t : {
|
|
221
221
|
...t,
|
|
222
222
|
selector: t.selector.map((n) => n.range instanceof Range && !n.range.collapsed ? n : Dt(n, e))
|
|
223
223
|
}, rt = (t, e) => $(t.target.selector) ? t : { ...t, target: it(t.target, e) }, de = (t) => {
|
|
224
|
-
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -e,
|
|
225
|
-
return { top: e, left: n, minX: r, minY: s, maxX:
|
|
224
|
+
const { top: e, left: n } = t.getBoundingClientRect(), { innerWidth: o, innerHeight: i } = window, r = -n, s = -e, a = o - n, u = i - e;
|
|
225
|
+
return { top: e, left: n, minX: r, minY: s, maxX: a, maxY: u };
|
|
226
226
|
}, ue = (t) => {
|
|
227
227
|
let e = /* @__PURE__ */ new Set();
|
|
228
228
|
return (o) => {
|
|
@@ -231,46 +231,46 @@ const P = {
|
|
|
231
231
|
};
|
|
232
232
|
}, vt = (t, e, n, o) => {
|
|
233
233
|
const { store: i, selection: r, hover: s } = e;
|
|
234
|
-
let
|
|
234
|
+
let a, u, h;
|
|
235
235
|
const m = ue(n), l = (B) => {
|
|
236
236
|
const { x: M, y: b } = t.getBoundingClientRect(), x = i.getAt(B.clientX - M, B.clientY - b, u);
|
|
237
237
|
x ? s.current !== x.id && (t.classList.add("hovered"), s.set(x.id)) : s.current && (t.classList.remove("hovered"), s.set(null));
|
|
238
238
|
};
|
|
239
239
|
t.addEventListener("pointermove", l);
|
|
240
|
-
const
|
|
240
|
+
const g = (B = !1) => {
|
|
241
241
|
h && h.clear();
|
|
242
242
|
const M = de(t), { minX: b, minY: x, maxX: A, maxY: S } = M, R = u ? i.getIntersecting(b, x, A, S).filter(({ annotation: _ }) => u(_)) : i.getIntersecting(b, x, A, S), O = r.selected.map(({ id: _ }) => _), H = R.map(({ annotation: _, rects: qt }) => {
|
|
243
243
|
const jt = O.includes(_.id), Gt = _.id === s.current;
|
|
244
244
|
return { annotation: _, rects: qt, state: { selected: jt, hover: Gt } };
|
|
245
245
|
});
|
|
246
|
-
o.redraw(H, M,
|
|
247
|
-
},
|
|
248
|
-
h = B,
|
|
246
|
+
o.redraw(H, M, a, h, B), setTimeout(() => m(R.map(({ annotation: _ }) => _)), 1);
|
|
247
|
+
}, p = (B) => {
|
|
248
|
+
h = B, g();
|
|
249
249
|
}, w = (B) => {
|
|
250
|
-
|
|
251
|
-
},
|
|
252
|
-
u = B,
|
|
253
|
-
},
|
|
254
|
-
i.observe(
|
|
255
|
-
const d = r.subscribe(() =>
|
|
256
|
-
document.addEventListener("scroll",
|
|
257
|
-
const
|
|
258
|
-
i.recalculatePositions(), h && h.reset(),
|
|
250
|
+
a = B, g();
|
|
251
|
+
}, y = (B) => {
|
|
252
|
+
u = B, g(!1);
|
|
253
|
+
}, f = () => g();
|
|
254
|
+
i.observe(f);
|
|
255
|
+
const d = r.subscribe(() => g()), c = () => g(!0);
|
|
256
|
+
document.addEventListener("scroll", c, { capture: !0, passive: !0 });
|
|
257
|
+
const v = bt(() => {
|
|
258
|
+
i.recalculatePositions(), h && h.reset(), g();
|
|
259
259
|
});
|
|
260
|
-
window.addEventListener("resize",
|
|
261
|
-
const E = new ResizeObserver(
|
|
260
|
+
window.addEventListener("resize", v);
|
|
261
|
+
const E = new ResizeObserver(v);
|
|
262
262
|
E.observe(t);
|
|
263
263
|
const L = { attributes: !0, childList: !0, subtree: !0 }, C = new MutationObserver((B) => {
|
|
264
|
-
B.every((b) => b.target === t || t.contains(b.target)) ||
|
|
264
|
+
B.every((b) => b.target === t || t.contains(b.target)) || g(!0);
|
|
265
265
|
});
|
|
266
266
|
return C.observe(document.body, L), {
|
|
267
267
|
destroy: () => {
|
|
268
|
-
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(
|
|
268
|
+
t.removeEventListener("pointermove", l), o.destroy(), i.unobserve(f), d(), document.removeEventListener("scroll", c), window.removeEventListener("resize", v), E.disconnect(), C.disconnect();
|
|
269
269
|
},
|
|
270
|
-
redraw:
|
|
270
|
+
redraw: g,
|
|
271
271
|
setStyle: w,
|
|
272
|
-
setFilter:
|
|
273
|
-
setPainter:
|
|
272
|
+
setFilter: y,
|
|
273
|
+
setPainter: p,
|
|
274
274
|
setVisible: o.setVisible
|
|
275
275
|
};
|
|
276
276
|
}, he = () => {
|
|
@@ -282,27 +282,27 @@ const P = {
|
|
|
282
282
|
t.classList.add("r6o-annotatable");
|
|
283
283
|
const e = he(), n = e.getContext("2d");
|
|
284
284
|
document.body.appendChild(e);
|
|
285
|
-
const o = (
|
|
286
|
-
const { width: l, height:
|
|
287
|
-
n.clearRect(-0.5, -0.5, l + 1,
|
|
288
|
-
const { top:
|
|
289
|
-
[...
|
|
290
|
-
const { annotation: { target: { created:
|
|
291
|
-
return
|
|
292
|
-
}).forEach((
|
|
285
|
+
const o = (a, u, h, m) => requestAnimationFrame(() => {
|
|
286
|
+
const { width: l, height: g } = e;
|
|
287
|
+
n.clearRect(-0.5, -0.5, l + 1, g + 1), m && m.clear();
|
|
288
|
+
const { top: p, left: w } = u;
|
|
289
|
+
[...a].sort((f, d) => {
|
|
290
|
+
const { annotation: { target: { created: c } } } = f, { annotation: { target: { created: v } } } = d;
|
|
291
|
+
return c.getTime() - v.getTime();
|
|
292
|
+
}).forEach((f) => {
|
|
293
293
|
var E;
|
|
294
|
-
const d = h ? typeof h == "function" ? h(
|
|
294
|
+
const d = h ? typeof h == "function" ? h(f.annotation, f.state) : h : (E = f.state) != null && E.selected ? ot : P, c = m && m.paint(f, u) || d, v = f.rects.map(({ x: L, y: C, width: T, height: B }) => ({
|
|
295
295
|
x: L + w,
|
|
296
|
-
y: C +
|
|
296
|
+
y: C + p,
|
|
297
297
|
width: T,
|
|
298
298
|
height: B
|
|
299
299
|
}));
|
|
300
|
-
if (n.fillStyle =
|
|
300
|
+
if (n.fillStyle = c.fill, n.globalAlpha = c.fillOpacity || 1, v.forEach(
|
|
301
301
|
({ x: L, y: C, width: T, height: B }) => n.fillRect(L, C, T, B)
|
|
302
|
-
),
|
|
303
|
-
n.globalAlpha = 1, n.strokeStyle =
|
|
304
|
-
const L =
|
|
305
|
-
|
|
302
|
+
), c.underlineColor) {
|
|
303
|
+
n.globalAlpha = 1, n.strokeStyle = c.underlineColor, n.lineWidth = c.underlineThickness ?? 1;
|
|
304
|
+
const L = c.underlineOffset ?? 0;
|
|
305
|
+
v.forEach(({ x: C, y: T, width: B, height: M }) => {
|
|
306
306
|
n.beginPath(), n.moveTo(C, T + M + L), n.lineTo(C + B, T + M + L), n.stroke();
|
|
307
307
|
});
|
|
308
308
|
}
|
|
@@ -314,7 +314,7 @@ const P = {
|
|
|
314
314
|
destroy: () => {
|
|
315
315
|
e.remove(), window.removeEventListener("resize", i);
|
|
316
316
|
},
|
|
317
|
-
setVisible: (
|
|
317
|
+
setVisible: (a) => {
|
|
318
318
|
console.log("setVisible not implemented on Canvas renderer");
|
|
319
319
|
},
|
|
320
320
|
redraw: o
|
|
@@ -336,13 +336,13 @@ var me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
|
|
|
336
336
|
var e = t.toString(16);
|
|
337
337
|
return e.length < 2 ? "0" + e : e;
|
|
338
338
|
}, Xt = function(t) {
|
|
339
|
-
var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), s = r - Math.min(e, n, o),
|
|
340
|
-
return { h: 60 * (
|
|
339
|
+
var e = t.r, n = t.g, o = t.b, i = t.a, r = Math.max(e, n, o), s = r - Math.min(e, n, o), a = s ? r === e ? (n - o) / s : r === n ? 2 + (o - e) / s : 4 + (e - n) / s : 0;
|
|
340
|
+
return { h: 60 * (a < 0 ? a + 6 : a), s: r ? s / r * 100 : 0, v: r / 255 * 100, a: i };
|
|
341
341
|
}, $t = function(t) {
|
|
342
342
|
var e = t.h, n = t.s, o = t.v, i = t.a;
|
|
343
343
|
e = e / 360 * 6, n /= 100, o /= 100;
|
|
344
|
-
var r = Math.floor(e), s = o * (1 - n),
|
|
345
|
-
return { r: 255 * [o,
|
|
344
|
+
var r = Math.floor(e), s = o * (1 - n), a = o * (1 - (e - r) * n), u = o * (1 - (1 - e + r) * n), h = r % 6;
|
|
345
|
+
return { r: 255 * [o, a, s, s, u, o][h], g: 255 * [u, o, o, a, s, s][h], b: 255 * [s, s, u, o, o, a][h], a: i };
|
|
346
346
|
}, Et = function(t) {
|
|
347
347
|
return { h: _t(t.h), s: k(t.s, 0, 100), l: k(t.l, 0, 100), a: k(t.a) };
|
|
348
348
|
}, St = function(t) {
|
|
@@ -375,8 +375,8 @@ var me = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) }, X = function(t) {
|
|
|
375
375
|
}, "hsl"], [function(t) {
|
|
376
376
|
var e = t.h, n = t.s, o = t.v, i = t.a, r = i === void 0 ? 1 : i;
|
|
377
377
|
if (!X(e) || !X(n) || !X(o)) return null;
|
|
378
|
-
var s = function(
|
|
379
|
-
return { h: _t(
|
|
378
|
+
var s = function(a) {
|
|
379
|
+
return { h: _t(a.h), s: k(a.s, 0, 100), v: k(a.v, 0, 100), a: k(a.a) };
|
|
380
380
|
}({ h: Number(e), s: Number(n), v: Number(o), a: Number(r) });
|
|
381
381
|
return $t(s);
|
|
382
382
|
}, "hsv"]] }, Bt = function(t, e) {
|
|
@@ -467,19 +467,19 @@ const Ee = (t) => [
|
|
|
467
467
|
setVisible: (r) => {
|
|
468
468
|
console.log("setVisible not implemented on CSS Custom Highlights renderer");
|
|
469
469
|
},
|
|
470
|
-
redraw: (r, s,
|
|
470
|
+
redraw: (r, s, a, u) => {
|
|
471
471
|
u && u.clear();
|
|
472
472
|
const h = new Set(r.map((l) => l.annotation.id));
|
|
473
473
|
Array.from(e).filter((l) => !h.has(l));
|
|
474
474
|
const m = r.map((l) => {
|
|
475
475
|
var w;
|
|
476
|
-
const
|
|
477
|
-
return `::highlight(_${l.annotation.id}) { ${Ee(
|
|
476
|
+
const g = a ? typeof a == "function" ? a(l.annotation, l.state) : a : (w = l.state) != null && w.selected ? ot : P, p = u && u.paint(l, s) || g;
|
|
477
|
+
return `::highlight(_${l.annotation.id}) { ${Ee(p)} }`;
|
|
478
478
|
});
|
|
479
479
|
t.innerHTML = m.join(`
|
|
480
480
|
`), CSS.highlights.clear(), r.forEach(({ annotation: l }) => {
|
|
481
|
-
const
|
|
482
|
-
CSS.highlights.set(`_${l.id}`,
|
|
481
|
+
const g = l.target.selector.map((w) => w.range), p = new Highlight(...g);
|
|
482
|
+
CSS.highlights.set(`_${l.id}`, p);
|
|
483
483
|
}), e = h;
|
|
484
484
|
}
|
|
485
485
|
};
|
|
@@ -506,8 +506,8 @@ function mt(t, e) {
|
|
|
506
506
|
return t !== t && e !== e;
|
|
507
507
|
}
|
|
508
508
|
const Le = (t, e) => {
|
|
509
|
-
const n = (
|
|
510
|
-
return
|
|
509
|
+
const n = (r, s) => r.x <= s.x + s.width && r.x + r.width >= s.x && r.y <= s.y + s.height && r.y + r.height >= s.y, o = (r) => r.rects.reduce((s, a) => s + a.width, 0), i = e.filter(({ rects: r }) => r.some((s) => n(t, s)));
|
|
510
|
+
return i.sort((r, s) => o(s) - o(r)), i.findIndex((r) => r.rects.includes(t));
|
|
511
511
|
}, Be = (t) => {
|
|
512
512
|
t.classList.add("r6o-annotatable");
|
|
513
513
|
const e = document.createElement("div");
|
|
@@ -517,20 +517,17 @@ const Le = (t, e) => {
|
|
|
517
517
|
destroy: () => {
|
|
518
518
|
e.remove();
|
|
519
519
|
},
|
|
520
|
-
redraw: (s,
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
if (p) {
|
|
529
|
-
const a = document.createElement("span");
|
|
530
|
-
a.className = "r6o-annotation", a.dataset.annotation = w.annotation.id, a.style.left = `${v.x}px`, a.style.top = `${v.y}px`, a.style.width = `${v.width}px`, a.style.height = `${v.height}px`, a.style.backgroundColor = Y((d == null ? void 0 : d.fill) || P.fill).alpha((d == null ? void 0 : d.fillOpacity) === void 0 ? P.fillOpacity : d.fillOpacity).toHex(), d.underlineStyle && (a.style.borderStyle = d.underlineStyle), d.underlineColor && (a.style.borderColor = d.underlineColor), d.underlineThickness && (a.style.borderBottomWidth = `${d.underlineThickness}px`), d.underlineOffset && (a.style.paddingBottom = `${d.underlineOffset}px`), e.appendChild(a);
|
|
520
|
+
redraw: (s, a, u, h, m) => {
|
|
521
|
+
const g = !(mt(n, s) && m);
|
|
522
|
+
!h && !g || (g && (e.innerHTML = ""), s.forEach((p) => {
|
|
523
|
+
p.rects.map((w) => {
|
|
524
|
+
const y = Le(w, s), f = Kt(p, a, u, h, y);
|
|
525
|
+
if (g) {
|
|
526
|
+
const d = document.createElement("span");
|
|
527
|
+
d.className = "r6o-annotation", d.dataset.annotation = p.annotation.id, d.style.left = `${w.x}px`, d.style.top = `${w.y}px`, d.style.width = `${w.width}px`, d.style.height = `${w.height}px`, d.style.backgroundColor = Y((f == null ? void 0 : f.fill) || P.fill).alpha((f == null ? void 0 : f.fillOpacity) === void 0 ? P.fillOpacity : f.fillOpacity).toHex(), f.underlineStyle && (d.style.borderStyle = f.underlineStyle), f.underlineColor && (d.style.borderColor = f.underlineColor), f.underlineThickness && (d.style.borderBottomWidth = `${f.underlineThickness}px`), f.underlineOffset && (d.style.paddingBottom = `${f.underlineOffset}px`), e.appendChild(d);
|
|
531
528
|
}
|
|
532
529
|
});
|
|
533
|
-
}), n = s;
|
|
530
|
+
}), n = s);
|
|
534
531
|
},
|
|
535
532
|
setVisible: (s) => {
|
|
536
533
|
s ? e.classList.remove("hidden") : e.classList.add("hidden");
|
|
@@ -590,8 +587,8 @@ const F = [];
|
|
|
590
587
|
function yt(t, e = dt) {
|
|
591
588
|
let n;
|
|
592
589
|
const o = /* @__PURE__ */ new Set();
|
|
593
|
-
function i(
|
|
594
|
-
if (Ie(t,
|
|
590
|
+
function i(a) {
|
|
591
|
+
if (Ie(t, a) && (t = a, n)) {
|
|
595
592
|
const u = !F.length;
|
|
596
593
|
for (const h of o)
|
|
597
594
|
h[1](), F.push(h, t);
|
|
@@ -602,12 +599,12 @@ function yt(t, e = dt) {
|
|
|
602
599
|
}
|
|
603
600
|
}
|
|
604
601
|
}
|
|
605
|
-
function r(
|
|
606
|
-
i(
|
|
602
|
+
function r(a) {
|
|
603
|
+
i(a(t));
|
|
607
604
|
}
|
|
608
|
-
function s(
|
|
609
|
-
const h = [
|
|
610
|
-
return o.add(h), o.size === 1 && (n = e(i, r) || dt),
|
|
605
|
+
function s(a, u = dt) {
|
|
606
|
+
const h = [a, u];
|
|
607
|
+
return o.add(h), o.size === 1 && (n = e(i, r) || dt), a(t), () => {
|
|
611
608
|
o.delete(h), o.size === 0 && n && (n(), n = null);
|
|
612
609
|
};
|
|
613
610
|
}
|
|
@@ -638,33 +635,33 @@ const ut = { selected: [] }, ke = (t, e = "EDIT") => {
|
|
|
638
635
|
const r = () => o(ut), s = () => {
|
|
639
636
|
var l;
|
|
640
637
|
return ((l = i.selected) == null ? void 0 : l.length) === 0;
|
|
641
|
-
},
|
|
638
|
+
}, a = (l) => {
|
|
642
639
|
if (i.selected.length === 0)
|
|
643
640
|
return !1;
|
|
644
|
-
const
|
|
645
|
-
return i.selected.some((
|
|
646
|
-
}, u = (l,
|
|
647
|
-
const
|
|
648
|
-
if (
|
|
649
|
-
const w = It(
|
|
650
|
-
o(w === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent:
|
|
641
|
+
const g = typeof l == "string" ? l : l.id;
|
|
642
|
+
return i.selected.some((p) => p.id === g);
|
|
643
|
+
}, u = (l, g) => {
|
|
644
|
+
const p = t.getAnnotation(l);
|
|
645
|
+
if (p) {
|
|
646
|
+
const w = It(p, e);
|
|
647
|
+
o(w === "EDIT" ? { selected: [{ id: l, editable: !0 }], pointerEvent: g } : w === "SELECT" ? { selected: [{ id: l }], pointerEvent: g } : { selected: [], pointerEvent: g });
|
|
651
648
|
} else
|
|
652
649
|
console.warn("Invalid selection: " + l);
|
|
653
|
-
}, h = (l,
|
|
654
|
-
const
|
|
650
|
+
}, h = (l, g) => {
|
|
651
|
+
const p = Array.isArray(l) ? l : [l], w = p.map((y) => t.getAnnotation(y)).filter(Boolean);
|
|
655
652
|
o({
|
|
656
|
-
selected: w.map((
|
|
657
|
-
const
|
|
658
|
-
return { id:
|
|
653
|
+
selected: w.map((y) => {
|
|
654
|
+
const f = g === void 0 ? It(y, e) === "EDIT" : g;
|
|
655
|
+
return { id: y.id, editable: f };
|
|
659
656
|
})
|
|
660
|
-
}), w.length !==
|
|
657
|
+
}), w.length !== p.length && console.warn("Invalid selection", l);
|
|
661
658
|
}, m = (l) => {
|
|
662
659
|
if (i.selected.length === 0)
|
|
663
660
|
return !1;
|
|
664
|
-
const { selected:
|
|
665
|
-
|
|
661
|
+
const { selected: g } = i;
|
|
662
|
+
g.filter(({ id: p }) => l.includes(p)).length > 0 && o({ selected: g.filter(({ id: p }) => !l.includes(p)) });
|
|
666
663
|
};
|
|
667
|
-
return t.observe(({ changes: l }) => m((l.deleted || []).map((
|
|
664
|
+
return t.observe(({ changes: l }) => m((l.deleted || []).map((g) => g.id))), {
|
|
668
665
|
clear: r,
|
|
669
666
|
clickSelect: u,
|
|
670
667
|
get selected() {
|
|
@@ -674,7 +671,7 @@ const ut = { selected: [] }, ke = (t, e = "EDIT") => {
|
|
|
674
671
|
return i ? i.pointerEvent : null;
|
|
675
672
|
},
|
|
676
673
|
isEmpty: s,
|
|
677
|
-
isSelected:
|
|
674
|
+
isSelected: a,
|
|
678
675
|
setSelected: h,
|
|
679
676
|
subscribe: n
|
|
680
677
|
};
|
|
@@ -735,39 +732,39 @@ const We = (t, e) => {
|
|
|
735
732
|
if (!(!t.options.origin || t.options.origin === r))
|
|
736
733
|
return !1;
|
|
737
734
|
if (t.options.ignore) {
|
|
738
|
-
const { ignore: s } = t.options,
|
|
739
|
-
if (!(
|
|
740
|
-
const u = (n = i.updated) == null ? void 0 : n.some((m) =>
|
|
735
|
+
const { ignore: s } = t.options, a = (u) => u && u.length > 0;
|
|
736
|
+
if (!(a(i.created) || a(i.deleted))) {
|
|
737
|
+
const u = (n = i.updated) == null ? void 0 : n.some((m) => a(m.bodiesCreated) || a(m.bodiesDeleted) || a(m.bodiesUpdated)), h = (o = i.updated) == null ? void 0 : o.some((m) => m.targetUpdated);
|
|
741
738
|
if (s === "BODY_ONLY" && u && !h || s === "TARGET_ONLY" && h && !u)
|
|
742
739
|
return !1;
|
|
743
740
|
}
|
|
744
741
|
}
|
|
745
742
|
if (t.options.annotations) {
|
|
746
743
|
const s = /* @__PURE__ */ new Set([
|
|
747
|
-
...(i.created || []).map((
|
|
748
|
-
...(i.deleted || []).map((
|
|
749
|
-
...(i.updated || []).map(({ oldValue:
|
|
744
|
+
...(i.created || []).map((a) => a.id),
|
|
745
|
+
...(i.deleted || []).map((a) => a.id),
|
|
746
|
+
...(i.updated || []).map(({ oldValue: a }) => a.id)
|
|
750
747
|
]);
|
|
751
|
-
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((
|
|
748
|
+
return !!(Array.isArray(t.options.annotations) ? t.options.annotations : [t.options.annotations]).find((a) => s.has(a));
|
|
752
749
|
} else
|
|
753
750
|
return !0;
|
|
754
751
|
}, qe = (t, e) => {
|
|
755
|
-
const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), s = new Set((e.updated || []).map(({ oldValue: l }) => l.id)),
|
|
756
|
-
...(t.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? e.updated.find(({ oldValue:
|
|
752
|
+
const n = new Set((t.created || []).map((l) => l.id)), o = new Set((t.updated || []).map(({ newValue: l }) => l.id)), i = new Set((e.created || []).map((l) => l.id)), r = new Set((e.deleted || []).map((l) => l.id)), s = new Set((e.updated || []).map(({ oldValue: l }) => l.id)), a = new Set((e.updated || []).filter(({ oldValue: l }) => n.has(l.id) || o.has(l.id)).map(({ oldValue: l }) => l.id)), u = [
|
|
753
|
+
...(t.created || []).filter((l) => !r.has(l.id)).map((l) => s.has(l.id) ? e.updated.find(({ oldValue: g }) => g.id === l.id).newValue : l),
|
|
757
754
|
...e.created || []
|
|
758
755
|
], h = [
|
|
759
756
|
...(t.deleted || []).filter((l) => !i.has(l.id)),
|
|
760
757
|
...(e.deleted || []).filter((l) => !n.has(l.id))
|
|
761
758
|
], m = [
|
|
762
759
|
...(t.updated || []).filter(({ newValue: l }) => !r.has(l.id)).map((l) => {
|
|
763
|
-
const { oldValue:
|
|
764
|
-
if (s.has(
|
|
765
|
-
const w = e.updated.find((
|
|
766
|
-
return Pt(
|
|
760
|
+
const { oldValue: g, newValue: p } = l;
|
|
761
|
+
if (s.has(p.id)) {
|
|
762
|
+
const w = e.updated.find((y) => y.oldValue.id === p.id).newValue;
|
|
763
|
+
return Pt(g, w);
|
|
767
764
|
} else
|
|
768
765
|
return l;
|
|
769
766
|
}),
|
|
770
|
-
...(e.updated || []).filter(({ oldValue: l }) => !
|
|
767
|
+
...(e.updated || []).filter(({ oldValue: l }) => !a.has(l.id))
|
|
771
768
|
];
|
|
772
769
|
return { created: u, deleted: h, updated: m };
|
|
773
770
|
}, je = (t) => t.id !== void 0, Ge = () => {
|
|
@@ -791,7 +788,7 @@ const We = (t, e) => {
|
|
|
791
788
|
if (t.get(b.id))
|
|
792
789
|
throw Error(`Cannot add annotation ${b.id} - exists already`);
|
|
793
790
|
t.set(b.id, b), b.bodies.forEach((A) => e.set(A.id, b.id)), r(x, { created: [b] });
|
|
794
|
-
},
|
|
791
|
+
}, a = (b, x) => {
|
|
795
792
|
const A = typeof b == "string" ? x : b, S = typeof b == "string" ? b : b.id, R = t.get(S);
|
|
796
793
|
if (R) {
|
|
797
794
|
const O = Pt(R, A);
|
|
@@ -799,11 +796,11 @@ const We = (t, e) => {
|
|
|
799
796
|
} else
|
|
800
797
|
console.warn(`Cannot update annotation ${S} - does not exist`);
|
|
801
798
|
}, u = (b, x = N.LOCAL, A = N.LOCAL) => {
|
|
802
|
-
const S = je(x) ? A : x, R =
|
|
799
|
+
const S = je(x) ? A : x, R = a(b, x);
|
|
803
800
|
R && r(S, { updated: [R] });
|
|
804
801
|
}, h = (b, x = N.LOCAL) => {
|
|
805
802
|
const A = b.reduce((S, R) => {
|
|
806
|
-
const O =
|
|
803
|
+
const O = a(R);
|
|
807
804
|
return O ? [...S, O] : S;
|
|
808
805
|
}, []);
|
|
809
806
|
A.length > 0 && r(x, { updated: A });
|
|
@@ -821,10 +818,10 @@ const We = (t, e) => {
|
|
|
821
818
|
}] });
|
|
822
819
|
} else
|
|
823
820
|
console.warn(`Attempt to add body to missing annotation: ${b.annotation}`);
|
|
824
|
-
}, l = () => [...t.values()],
|
|
821
|
+
}, l = () => [...t.values()], g = (b = N.LOCAL) => {
|
|
825
822
|
const x = [...t.values()];
|
|
826
823
|
t.clear(), e.clear(), r(b, { deleted: x });
|
|
827
|
-
},
|
|
824
|
+
}, p = (b, x = !0, A = N.LOCAL) => {
|
|
828
825
|
if (x) {
|
|
829
826
|
const S = [...t.values()];
|
|
830
827
|
t.clear(), e.clear(), b.forEach((R) => {
|
|
@@ -846,10 +843,10 @@ const We = (t, e) => {
|
|
|
846
843
|
if (A)
|
|
847
844
|
return t.delete(x), A.bodies.forEach((S) => e.delete(S.id)), A;
|
|
848
845
|
console.warn(`Attempt to delete missing annotation: ${x}`);
|
|
849
|
-
},
|
|
846
|
+
}, y = (b, x = N.LOCAL) => {
|
|
850
847
|
const A = w(b);
|
|
851
848
|
A && r(x, { deleted: [A] });
|
|
852
|
-
},
|
|
849
|
+
}, f = (b, x = N.LOCAL) => {
|
|
853
850
|
const A = b.reduce((S, R) => {
|
|
854
851
|
const O = w(R);
|
|
855
852
|
return O ? [...S, O] : S;
|
|
@@ -874,10 +871,10 @@ const We = (t, e) => {
|
|
|
874
871
|
console.warn(`Attempt to delete missing body ${b.id} from annotation ${b.annotation}`);
|
|
875
872
|
} else
|
|
876
873
|
console.warn(`Attempt to delete body from missing annotation ${b.annotation}`);
|
|
877
|
-
},
|
|
874
|
+
}, c = (b, x = N.LOCAL) => {
|
|
878
875
|
const A = d(b);
|
|
879
876
|
A && r(x, { updated: [A] });
|
|
880
|
-
},
|
|
877
|
+
}, v = (b, x = N.LOCAL) => {
|
|
881
878
|
const A = b.map((S) => d(S)).filter(Boolean);
|
|
882
879
|
A.length > 0 && r(x, { updated: A });
|
|
883
880
|
}, E = (b) => {
|
|
@@ -939,18 +936,18 @@ const We = (t, e) => {
|
|
|
939
936
|
addAnnotation: s,
|
|
940
937
|
addBody: m,
|
|
941
938
|
all: l,
|
|
942
|
-
bulkAddAnnotation:
|
|
943
|
-
bulkDeleteAnnotation:
|
|
944
|
-
bulkDeleteBodies:
|
|
939
|
+
bulkAddAnnotation: p,
|
|
940
|
+
bulkDeleteAnnotation: f,
|
|
941
|
+
bulkDeleteBodies: v,
|
|
945
942
|
bulkUpdateAnnotation: h,
|
|
946
943
|
bulkUpdateBodies: B,
|
|
947
944
|
bulkUpdateTargets: (b, x = N.LOCAL) => {
|
|
948
945
|
const A = b.map((S) => M(S)).filter(Boolean);
|
|
949
946
|
A.length > 0 && r(x, { updated: A });
|
|
950
947
|
},
|
|
951
|
-
clear:
|
|
952
|
-
deleteAnnotation:
|
|
953
|
-
deleteBody:
|
|
948
|
+
clear: g,
|
|
949
|
+
deleteAnnotation: y,
|
|
950
|
+
deleteBody: c,
|
|
954
951
|
getAnnotation: E,
|
|
955
952
|
getBody: L,
|
|
956
953
|
observe: o,
|
|
@@ -980,38 +977,38 @@ let Ke = () => ({
|
|
|
980
977
|
const Qe = 250, Je = (t) => {
|
|
981
978
|
const e = Ke(), n = [];
|
|
982
979
|
let o = -1, i = !1, r = 0;
|
|
983
|
-
const s = (
|
|
980
|
+
const s = (p) => {
|
|
984
981
|
if (!i) {
|
|
985
|
-
const { changes: w } =
|
|
986
|
-
if (
|
|
982
|
+
const { changes: w } = p, y = performance.now();
|
|
983
|
+
if (y - r > Qe)
|
|
987
984
|
n.splice(o + 1), n.push(w), o = n.length - 1;
|
|
988
985
|
else {
|
|
989
|
-
const
|
|
990
|
-
n[
|
|
986
|
+
const f = n.length - 1;
|
|
987
|
+
n[f] = qe(n[f], w);
|
|
991
988
|
}
|
|
992
|
-
r =
|
|
989
|
+
r = y;
|
|
993
990
|
}
|
|
994
991
|
i = !1;
|
|
995
992
|
};
|
|
996
993
|
t.observe(s, { origin: N.LOCAL });
|
|
997
|
-
const
|
|
994
|
+
const a = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p), u = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), h = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ oldValue: w }) => w)), m = (p) => p && p.length > 0 && t.bulkUpdateAnnotation(p.map(({ newValue: w }) => w)), l = (p) => p && p.length > 0 && t.bulkAddAnnotation(p, !1), g = (p) => p && p.length > 0 && t.bulkDeleteAnnotation(p);
|
|
998
995
|
return {
|
|
999
996
|
canRedo: () => n.length - 1 > o,
|
|
1000
997
|
canUndo: () => o > -1,
|
|
1001
998
|
destroy: () => t.unobserve(s),
|
|
1002
|
-
on: (
|
|
999
|
+
on: (p, w) => e.on(p, w),
|
|
1003
1000
|
redo: () => {
|
|
1004
1001
|
if (n.length - 1 > o) {
|
|
1005
1002
|
i = !0;
|
|
1006
|
-
const { created:
|
|
1007
|
-
u(
|
|
1003
|
+
const { created: p, updated: w, deleted: y } = n[o + 1];
|
|
1004
|
+
u(p), m(w), g(y), e.emit("redo", n[o + 1]), o += 1;
|
|
1008
1005
|
}
|
|
1009
1006
|
},
|
|
1010
1007
|
undo: () => {
|
|
1011
1008
|
if (o > -1) {
|
|
1012
1009
|
i = !0;
|
|
1013
|
-
const { created:
|
|
1014
|
-
|
|
1010
|
+
const { created: p, updated: w, deleted: y } = n[o];
|
|
1011
|
+
a(p), h(w), l(y), e.emit("undo", n[o]), o -= 1;
|
|
1015
1012
|
}
|
|
1016
1013
|
}
|
|
1017
1014
|
};
|
|
@@ -1022,73 +1019,73 @@ const Qe = 250, Je = (t) => {
|
|
|
1022
1019
|
set: e
|
|
1023
1020
|
};
|
|
1024
1021
|
}, tn = (t, e, n, o) => {
|
|
1025
|
-
const { store: i, selection: r, hover: s, viewport:
|
|
1022
|
+
const { store: i, selection: r, hover: s, viewport: a } = t, u = /* @__PURE__ */ new Map();
|
|
1026
1023
|
let h = [], m;
|
|
1027
|
-
const l = (
|
|
1028
|
-
u.has(
|
|
1029
|
-
},
|
|
1030
|
-
const d = u.get(
|
|
1024
|
+
const l = (y, f) => {
|
|
1025
|
+
u.has(y) ? u.get(y).push(f) : u.set(y, [f]);
|
|
1026
|
+
}, g = (y, f) => {
|
|
1027
|
+
const d = u.get(y);
|
|
1031
1028
|
if (d) {
|
|
1032
|
-
const
|
|
1033
|
-
|
|
1029
|
+
const c = d.indexOf(f);
|
|
1030
|
+
c !== -1 && d.splice(c, 1);
|
|
1034
1031
|
}
|
|
1035
|
-
},
|
|
1036
|
-
u.has(
|
|
1037
|
-
u.get(
|
|
1032
|
+
}, p = (y, f, d) => {
|
|
1033
|
+
u.has(y) && setTimeout(() => {
|
|
1034
|
+
u.get(y).forEach((c) => {
|
|
1038
1035
|
if (n) {
|
|
1039
|
-
const
|
|
1040
|
-
|
|
1036
|
+
const v = Array.isArray(f) ? f.map((L) => n.serialize(L)) : n.serialize(f), E = d ? d instanceof PointerEvent ? d : n.serialize(d) : void 0;
|
|
1037
|
+
c(v, E);
|
|
1041
1038
|
} else
|
|
1042
|
-
|
|
1039
|
+
c(f, d);
|
|
1043
1040
|
});
|
|
1044
1041
|
}, 1);
|
|
1045
1042
|
};
|
|
1046
|
-
r.subscribe(({ selected:
|
|
1047
|
-
if (!(h.length === 0 &&
|
|
1048
|
-
if (h.length === 0 &&
|
|
1049
|
-
h =
|
|
1050
|
-
else if (h.length > 0 &&
|
|
1051
|
-
h.forEach((
|
|
1052
|
-
const d = i.getAnnotation(
|
|
1053
|
-
d && !q(d,
|
|
1043
|
+
r.subscribe(({ selected: y }) => {
|
|
1044
|
+
if (!(h.length === 0 && y.length === 0)) {
|
|
1045
|
+
if (h.length === 0 && y.length > 0)
|
|
1046
|
+
h = y.map(({ id: f }) => i.getAnnotation(f));
|
|
1047
|
+
else if (h.length > 0 && y.length === 0)
|
|
1048
|
+
h.forEach((f) => {
|
|
1049
|
+
const d = i.getAnnotation(f.id);
|
|
1050
|
+
d && !q(d, f) && p("updateAnnotation", d, f);
|
|
1054
1051
|
}), h = [];
|
|
1055
1052
|
else {
|
|
1056
|
-
const
|
|
1057
|
-
h.filter((
|
|
1058
|
-
const
|
|
1059
|
-
|
|
1053
|
+
const f = new Set(h.map((c) => c.id)), d = new Set(y.map(({ id: c }) => c));
|
|
1054
|
+
h.filter((c) => !d.has(c.id)).forEach((c) => {
|
|
1055
|
+
const v = i.getAnnotation(c.id);
|
|
1056
|
+
v && !q(v, c) && p("updateAnnotation", v, c);
|
|
1060
1057
|
}), h = [
|
|
1061
1058
|
// Remove annotations that were deselected
|
|
1062
|
-
...h.filter((
|
|
1059
|
+
...h.filter((c) => d.has(c.id)),
|
|
1063
1060
|
// Add editable annotations that were selected
|
|
1064
|
-
...
|
|
1061
|
+
...y.filter(({ id: c }) => !f.has(c)).map(({ id: c }) => i.getAnnotation(c))
|
|
1065
1062
|
];
|
|
1066
1063
|
}
|
|
1067
|
-
|
|
1064
|
+
p("selectionChanged", h);
|
|
1068
1065
|
}
|
|
1069
|
-
}), s.subscribe((
|
|
1070
|
-
!m &&
|
|
1071
|
-
}),
|
|
1072
|
-
const { created:
|
|
1073
|
-
(
|
|
1074
|
-
...
|
|
1075
|
-
...
|
|
1076
|
-
...
|
|
1077
|
-
].length > 0).forEach(({ oldValue:
|
|
1078
|
-
const E = h.find((L) => L.id ===
|
|
1079
|
-
h = h.map((L) => L.id ===
|
|
1066
|
+
}), s.subscribe((y) => {
|
|
1067
|
+
!m && y ? p("mouseEnterAnnotation", i.getAnnotation(y)) : m && !y ? p("mouseLeaveAnnotation", i.getAnnotation(m)) : m && y && (p("mouseLeaveAnnotation", i.getAnnotation(m)), p("mouseEnterAnnotation", i.getAnnotation(y))), m = y;
|
|
1068
|
+
}), a == null || a.subscribe((y) => p("viewportIntersect", y.map((f) => i.getAnnotation(f)))), i.observe((y) => {
|
|
1069
|
+
const { created: f, deleted: d } = y.changes;
|
|
1070
|
+
(f || []).forEach((c) => p("createAnnotation", c)), (d || []).forEach((c) => p("deleteAnnotation", c)), (y.changes.updated || []).filter((c) => [
|
|
1071
|
+
...c.bodiesCreated || [],
|
|
1072
|
+
...c.bodiesDeleted || [],
|
|
1073
|
+
...c.bodiesUpdated || []
|
|
1074
|
+
].length > 0).forEach(({ oldValue: c, newValue: v }) => {
|
|
1075
|
+
const E = h.find((L) => L.id === c.id) || c;
|
|
1076
|
+
h = h.map((L) => L.id === c.id ? v : L), p("updateAnnotation", v, E);
|
|
1080
1077
|
});
|
|
1081
|
-
}, { origin: N.LOCAL }), i.observe((
|
|
1078
|
+
}, { origin: N.LOCAL }), i.observe((y) => {
|
|
1082
1079
|
if (h) {
|
|
1083
|
-
const
|
|
1084
|
-
d.length > 0 && (h = h.map((
|
|
1080
|
+
const f = new Set(h.map((c) => c.id)), d = (y.changes.updated || []).filter(({ newValue: c }) => f.has(c.id)).map(({ newValue: c }) => c);
|
|
1081
|
+
d.length > 0 && (h = h.map((c) => d.find((E) => E.id === c.id) || c));
|
|
1085
1082
|
}
|
|
1086
1083
|
}, { origin: N.REMOTE });
|
|
1087
|
-
const w = (
|
|
1088
|
-
const { updated: d } =
|
|
1089
|
-
|
|
1084
|
+
const w = (y) => (f) => {
|
|
1085
|
+
const { updated: d } = f;
|
|
1086
|
+
y ? (d || []).forEach((c) => p("updateAnnotation", c.oldValue, c.newValue)) : (d || []).forEach((c) => p("updateAnnotation", c.newValue, c.oldValue));
|
|
1090
1087
|
};
|
|
1091
|
-
return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: l, off:
|
|
1088
|
+
return e.on("undo", w(!0)), e.on("redo", w(!1)), { on: l, off: g, emit: p };
|
|
1092
1089
|
}, en = (t) => (e) => e.reduce((n, o) => {
|
|
1093
1090
|
const { parsed: i, error: r } = t.parse(o);
|
|
1094
1091
|
return r ? {
|
|
@@ -1101,44 +1098,44 @@ const Qe = 250, Je = (t) => {
|
|
|
1101
1098
|
...n
|
|
1102
1099
|
};
|
|
1103
1100
|
}, { parsed: [], failed: [] }), nn = (t, e, n) => {
|
|
1104
|
-
const { store: o, selection: i } = t, r = (
|
|
1101
|
+
const { store: o, selection: i } = t, r = (f) => {
|
|
1105
1102
|
if (n) {
|
|
1106
|
-
const { parsed: d, error:
|
|
1107
|
-
d ? o.addAnnotation(d, N.REMOTE) : console.error(
|
|
1103
|
+
const { parsed: d, error: c } = n.parse(f);
|
|
1104
|
+
d ? o.addAnnotation(d, N.REMOTE) : console.error(c);
|
|
1108
1105
|
} else
|
|
1109
|
-
o.addAnnotation(
|
|
1110
|
-
}, s = () => i.clear(),
|
|
1111
|
-
const d = o.getAnnotation(
|
|
1106
|
+
o.addAnnotation(f, N.REMOTE);
|
|
1107
|
+
}, s = () => i.clear(), a = () => o.clear(), u = (f) => {
|
|
1108
|
+
const d = o.getAnnotation(f);
|
|
1112
1109
|
return n && d ? n.serialize(d) : d;
|
|
1113
1110
|
}, h = () => n ? o.all().map(n.serialize) : o.all(), m = () => {
|
|
1114
|
-
var
|
|
1115
|
-
const d = (((
|
|
1111
|
+
var f;
|
|
1112
|
+
const d = (((f = i.selected) == null ? void 0 : f.map((c) => c.id)) || []).map((c) => o.getAnnotation(c)).filter(Boolean);
|
|
1116
1113
|
return n ? d.map(n.serialize) : d;
|
|
1117
|
-
}, l = (
|
|
1118
|
-
if (typeof
|
|
1119
|
-
const d = o.getAnnotation(
|
|
1120
|
-
if (o.deleteAnnotation(
|
|
1114
|
+
}, l = (f, d = !0) => fetch(f).then((c) => c.json()).then((c) => (p(c, d), c)), g = (f) => {
|
|
1115
|
+
if (typeof f == "string") {
|
|
1116
|
+
const d = o.getAnnotation(f);
|
|
1117
|
+
if (o.deleteAnnotation(f), d)
|
|
1121
1118
|
return n ? n.serialize(d) : d;
|
|
1122
1119
|
} else {
|
|
1123
|
-
const d = n ? n.parse(
|
|
1120
|
+
const d = n ? n.parse(f).parsed : f;
|
|
1124
1121
|
if (d)
|
|
1125
|
-
return o.deleteAnnotation(d),
|
|
1122
|
+
return o.deleteAnnotation(d), f;
|
|
1126
1123
|
}
|
|
1127
|
-
},
|
|
1124
|
+
}, p = (f, d = !0) => {
|
|
1128
1125
|
if (n) {
|
|
1129
|
-
const { parsed:
|
|
1130
|
-
|
|
1126
|
+
const { parsed: c, failed: v } = en(n)(f);
|
|
1127
|
+
v.length > 0 && console.warn(`Discarded ${v.length} invalid annotations`, v), o.bulkAddAnnotation(c, d, N.REMOTE);
|
|
1131
1128
|
} else
|
|
1132
|
-
o.bulkAddAnnotation(
|
|
1133
|
-
}, w = (
|
|
1134
|
-
|
|
1135
|
-
},
|
|
1129
|
+
o.bulkAddAnnotation(f, d, N.REMOTE);
|
|
1130
|
+
}, w = (f, d) => {
|
|
1131
|
+
f ? i.setSelected(f, d) : i.clear();
|
|
1132
|
+
}, y = (f) => {
|
|
1136
1133
|
if (n) {
|
|
1137
|
-
const d = n.parse(
|
|
1138
|
-
return o.updateAnnotation(d),
|
|
1134
|
+
const d = n.parse(f).parsed, c = n.serialize(o.getAnnotation(d.id));
|
|
1135
|
+
return o.updateAnnotation(d), c;
|
|
1139
1136
|
} else {
|
|
1140
|
-
const d = o.getAnnotation(
|
|
1141
|
-
return o.updateAnnotation(
|
|
1137
|
+
const d = o.getAnnotation(f.id);
|
|
1138
|
+
return o.updateAnnotation(f), d;
|
|
1142
1139
|
}
|
|
1143
1140
|
};
|
|
1144
1141
|
return {
|
|
@@ -1146,17 +1143,17 @@ const Qe = 250, Je = (t) => {
|
|
|
1146
1143
|
cancelSelected: s,
|
|
1147
1144
|
canRedo: e.canRedo,
|
|
1148
1145
|
canUndo: e.canUndo,
|
|
1149
|
-
clearAnnotations:
|
|
1146
|
+
clearAnnotations: a,
|
|
1150
1147
|
getAnnotationById: u,
|
|
1151
1148
|
getAnnotations: h,
|
|
1152
1149
|
getSelected: m,
|
|
1153
1150
|
loadAnnotations: l,
|
|
1154
1151
|
redo: e.redo,
|
|
1155
|
-
removeAnnotation:
|
|
1156
|
-
setAnnotations:
|
|
1152
|
+
removeAnnotation: g,
|
|
1153
|
+
setAnnotations: p,
|
|
1157
1154
|
setSelected: w,
|
|
1158
1155
|
undo: e.undo,
|
|
1159
|
-
updateAnnotation:
|
|
1156
|
+
updateAnnotation: y
|
|
1160
1157
|
};
|
|
1161
1158
|
}, on = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
1162
1159
|
let rn = (t) => crypto.getRandomValues(new Uint8Array(t)), sn = (t, e, n) => {
|
|
@@ -1164,9 +1161,9 @@ let rn = (t) => crypto.getRandomValues(new Uint8Array(t)), sn = (t, e, n) => {
|
|
|
1164
1161
|
return (r = e) => {
|
|
1165
1162
|
let s = "";
|
|
1166
1163
|
for (; ; ) {
|
|
1167
|
-
let
|
|
1164
|
+
let a = n(i), u = i;
|
|
1168
1165
|
for (; u--; )
|
|
1169
|
-
if (s += t[
|
|
1166
|
+
if (s += t[a[u] & o] || "", s.length === r) return s;
|
|
1170
1167
|
}
|
|
1171
1168
|
};
|
|
1172
1169
|
}, an = (t, e = 21) => sn(t, e, rn), cn = (t = 21) => {
|
|
@@ -1184,7 +1181,7 @@ const ln = () => ({ isGuest: !0, id: an("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1184
1181
|
}
|
|
1185
1182
|
return `${n}`;
|
|
1186
1183
|
}, Ft = (t) => t ? typeof t == "object" ? { ...t } : t : void 0, un = (t, e) => (Array.isArray(t) ? t : [t]).map((n) => {
|
|
1187
|
-
const { id: o, type: i, purpose: r, value: s, created:
|
|
1184
|
+
const { id: o, type: i, purpose: r, value: s, created: a, modified: u, creator: h, ...m } = n;
|
|
1188
1185
|
return {
|
|
1189
1186
|
id: o || `temp-${dn(n)}`,
|
|
1190
1187
|
annotation: e,
|
|
@@ -1192,18 +1189,18 @@ const ln = () => ({ isGuest: !0, id: an("1234567890abcdefghijklmnopqrstuvwxyzABC
|
|
|
1192
1189
|
purpose: r,
|
|
1193
1190
|
value: s,
|
|
1194
1191
|
creator: Ft(h),
|
|
1195
|
-
created:
|
|
1192
|
+
created: a ? new Date(a) : void 0,
|
|
1196
1193
|
updated: u ? new Date(u) : void 0,
|
|
1197
1194
|
...m
|
|
1198
1195
|
};
|
|
1199
1196
|
}), hn = (t) => t.map((e) => {
|
|
1200
1197
|
var n;
|
|
1201
|
-
const { annotation: o, created: i, updated: r, ...s } = e,
|
|
1198
|
+
const { annotation: o, created: i, updated: r, ...s } = e, a = {
|
|
1202
1199
|
...s,
|
|
1203
1200
|
created: i == null ? void 0 : i.toISOString(),
|
|
1204
1201
|
modified: r == null ? void 0 : r.toISOString()
|
|
1205
1202
|
};
|
|
1206
|
-
return (n =
|
|
1203
|
+
return (n = a.id) != null && n.startsWith("temp-") && delete a.id, a;
|
|
1207
1204
|
});
|
|
1208
1205
|
cn();
|
|
1209
1206
|
const Un = (t, e) => ({
|
|
@@ -1219,7 +1216,7 @@ const Un = (t, e) => ({
|
|
|
1219
1216
|
} = t, s = Array.isArray(r) ? r : [r];
|
|
1220
1217
|
if (s.length === 0)
|
|
1221
1218
|
return { error: Error(`No targets found for annotation: ${t.id}`) };
|
|
1222
|
-
const
|
|
1219
|
+
const a = {
|
|
1223
1220
|
creator: Ft(n),
|
|
1224
1221
|
created: o ? new Date(o) : void 0,
|
|
1225
1222
|
updated: i ? new Date(i) : void 0,
|
|
@@ -1228,19 +1225,19 @@ const Un = (t, e) => ({
|
|
|
1228
1225
|
styleClass: s[0].styleClass
|
|
1229
1226
|
};
|
|
1230
1227
|
for (const u of s) {
|
|
1231
|
-
const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l,
|
|
1232
|
-
switch (
|
|
1228
|
+
const m = (Array.isArray(u.selector) ? u.selector : [u.selector]).reduce((l, g) => {
|
|
1229
|
+
switch (g.type) {
|
|
1233
1230
|
case "TextQuoteSelector":
|
|
1234
|
-
l.quote =
|
|
1231
|
+
l.quote = g.exact;
|
|
1235
1232
|
break;
|
|
1236
1233
|
case "TextPositionSelector":
|
|
1237
|
-
l.start =
|
|
1234
|
+
l.start = g.start, l.end = g.end;
|
|
1238
1235
|
break;
|
|
1239
1236
|
}
|
|
1240
1237
|
return l;
|
|
1241
1238
|
}, {});
|
|
1242
1239
|
if (fn(m))
|
|
1243
|
-
|
|
1240
|
+
a.selector.push({ id: u.id, ...m });
|
|
1244
1241
|
else {
|
|
1245
1242
|
const l = [
|
|
1246
1243
|
m.start ? void 0 : "TextPositionSelector",
|
|
@@ -1249,7 +1246,7 @@ const Un = (t, e) => ({
|
|
|
1249
1246
|
return { error: Error(`Missing selector types: ${l.join(" and ")} for annotation: ${t.id}`) };
|
|
1250
1247
|
}
|
|
1251
1248
|
}
|
|
1252
|
-
return { parsed:
|
|
1249
|
+
return { parsed: a };
|
|
1253
1250
|
}, gn = (t) => {
|
|
1254
1251
|
const e = t.id || Ht(), {
|
|
1255
1252
|
creator: n,
|
|
@@ -1257,38 +1254,38 @@ const Un = (t, e) => ({
|
|
|
1257
1254
|
modified: i,
|
|
1258
1255
|
body: r,
|
|
1259
1256
|
...s
|
|
1260
|
-
} = t,
|
|
1257
|
+
} = t, a = un(r, e), u = pn(t);
|
|
1261
1258
|
return "error" in u ? { error: u.error } : {
|
|
1262
1259
|
parsed: {
|
|
1263
1260
|
...s,
|
|
1264
1261
|
id: e,
|
|
1265
|
-
bodies:
|
|
1262
|
+
bodies: a,
|
|
1266
1263
|
target: u.parsed
|
|
1267
1264
|
}
|
|
1268
1265
|
};
|
|
1269
1266
|
}, mn = (t, e, n) => {
|
|
1270
1267
|
const { bodies: o, target: i, ...r } = t, {
|
|
1271
1268
|
selector: s,
|
|
1272
|
-
creator:
|
|
1269
|
+
creator: a,
|
|
1273
1270
|
created: u,
|
|
1274
1271
|
updated: h,
|
|
1275
1272
|
...m
|
|
1276
|
-
} = i, l = s.map((
|
|
1277
|
-
const { quote:
|
|
1273
|
+
} = i, l = s.map((g) => {
|
|
1274
|
+
const { quote: p, start: w, end: y, range: f } = g, { prefix: d, suffix: c } = oe(f, n), v = [{
|
|
1278
1275
|
type: "TextQuoteSelector",
|
|
1279
|
-
exact:
|
|
1276
|
+
exact: p,
|
|
1280
1277
|
prefix: d,
|
|
1281
|
-
suffix:
|
|
1278
|
+
suffix: c
|
|
1282
1279
|
}, {
|
|
1283
1280
|
type: "TextPositionSelector",
|
|
1284
1281
|
start: w,
|
|
1285
|
-
end:
|
|
1282
|
+
end: y
|
|
1286
1283
|
}];
|
|
1287
1284
|
return {
|
|
1288
1285
|
...m,
|
|
1289
|
-
id:
|
|
1286
|
+
id: g.id,
|
|
1290
1287
|
source: e,
|
|
1291
|
-
selector:
|
|
1288
|
+
selector: v
|
|
1292
1289
|
};
|
|
1293
1290
|
});
|
|
1294
1291
|
return {
|
|
@@ -1297,7 +1294,7 @@ const Un = (t, e) => ({
|
|
|
1297
1294
|
id: t.id,
|
|
1298
1295
|
type: "Annotation",
|
|
1299
1296
|
body: hn(t.bodies),
|
|
1300
|
-
creator:
|
|
1297
|
+
creator: a,
|
|
1301
1298
|
created: u == null ? void 0 : u.toISOString(),
|
|
1302
1299
|
modified: h == null ? void 0 : h.toISOString(),
|
|
1303
1300
|
target: l
|
|
@@ -1309,15 +1306,15 @@ function bn(t, e, n, o, i) {
|
|
|
1309
1306
|
function zt(t, e, n, o, i) {
|
|
1310
1307
|
for (; o > n; ) {
|
|
1311
1308
|
if (o - n > 600) {
|
|
1312
|
-
var r = o - n + 1, s = e - n + 1,
|
|
1309
|
+
var r = o - n + 1, s = e - n + 1, a = Math.log(r), u = 0.5 * Math.exp(2 * a / 3), h = 0.5 * Math.sqrt(a * u * (r - u) / r) * (s - r / 2 < 0 ? -1 : 1), m = Math.max(n, Math.floor(e - s * u / r + h)), l = Math.min(o, Math.floor(e + (r - s) * u / r + h));
|
|
1313
1310
|
zt(t, e, m, l, i);
|
|
1314
1311
|
}
|
|
1315
|
-
var
|
|
1316
|
-
for (j(t, n, e), i(t[o],
|
|
1317
|
-
for (j(t,
|
|
1318
|
-
for (; i(t[w],
|
|
1312
|
+
var g = t[e], p = n, w = o;
|
|
1313
|
+
for (j(t, n, e), i(t[o], g) > 0 && j(t, n, o); p < w; ) {
|
|
1314
|
+
for (j(t, p, w), p++, w--; i(t[p], g) < 0; ) p++;
|
|
1315
|
+
for (; i(t[w], g) > 0; ) w--;
|
|
1319
1316
|
}
|
|
1320
|
-
i(t[n],
|
|
1317
|
+
i(t[n], g) === 0 ? j(t, n, w) : (w++, j(t, w, o)), w <= e && (n = w + 1), e <= w && (o = w - 1);
|
|
1321
1318
|
}
|
|
1322
1319
|
}
|
|
1323
1320
|
function j(t, e, n) {
|
|
@@ -1341,8 +1338,8 @@ class yn {
|
|
|
1341
1338
|
const i = this.toBBox, r = [];
|
|
1342
1339
|
for (; n; ) {
|
|
1343
1340
|
for (let s = 0; s < n.children.length; s++) {
|
|
1344
|
-
const
|
|
1345
|
-
nt(e, u) && (n.leaf ? o.push(
|
|
1341
|
+
const a = n.children[s], u = n.leaf ? i(a) : a;
|
|
1342
|
+
nt(e, u) && (n.leaf ? o.push(a) : pt(e, u) ? this._all(a, o) : r.push(a));
|
|
1346
1343
|
}
|
|
1347
1344
|
n = r.pop();
|
|
1348
1345
|
}
|
|
@@ -1395,14 +1392,14 @@ class yn {
|
|
|
1395
1392
|
if (!e) return this;
|
|
1396
1393
|
let o = this.data;
|
|
1397
1394
|
const i = this.toBBox(e), r = [], s = [];
|
|
1398
|
-
let
|
|
1395
|
+
let a, u, h;
|
|
1399
1396
|
for (; o || r.length; ) {
|
|
1400
|
-
if (o || (o = r.pop(), u = r[r.length - 1],
|
|
1397
|
+
if (o || (o = r.pop(), u = r[r.length - 1], a = s.pop(), h = !0), o.leaf) {
|
|
1401
1398
|
const m = wn(e, o.children, n);
|
|
1402
1399
|
if (m !== -1)
|
|
1403
1400
|
return o.children.splice(m, 1), r.push(o), this._condense(r), this;
|
|
1404
1401
|
}
|
|
1405
|
-
!h && !o.leaf && pt(o, i) ? (r.push(o), s.push(
|
|
1402
|
+
!h && !o.leaf && pt(o, i) ? (r.push(o), s.push(a), a = 0, u = o, o = o.children[0]) : u ? (a++, o = u.children[a], h = !1) : o = null;
|
|
1406
1403
|
}
|
|
1407
1404
|
return this;
|
|
1408
1405
|
}
|
|
@@ -1429,30 +1426,30 @@ class yn {
|
|
|
1429
1426
|
}
|
|
1430
1427
|
_build(e, n, o, i) {
|
|
1431
1428
|
const r = o - n + 1;
|
|
1432
|
-
let s = this._maxEntries,
|
|
1429
|
+
let s = this._maxEntries, a;
|
|
1433
1430
|
if (r <= s)
|
|
1434
|
-
return
|
|
1435
|
-
i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))),
|
|
1431
|
+
return a = W(e.slice(n, o + 1)), z(a, this.toBBox), a;
|
|
1432
|
+
i || (i = Math.ceil(Math.log(r) / Math.log(s)), s = Math.ceil(r / Math.pow(s, i - 1))), a = W([]), a.leaf = !1, a.height = i;
|
|
1436
1433
|
const u = Math.ceil(r / s), h = u * Math.ceil(Math.sqrt(s));
|
|
1437
1434
|
Ut(e, n, o, h, this.compareMinX);
|
|
1438
1435
|
for (let m = n; m <= o; m += h) {
|
|
1439
1436
|
const l = Math.min(m + h - 1, o);
|
|
1440
1437
|
Ut(e, m, l, u, this.compareMinY);
|
|
1441
|
-
for (let
|
|
1442
|
-
const
|
|
1443
|
-
|
|
1438
|
+
for (let g = m; g <= l; g += u) {
|
|
1439
|
+
const p = Math.min(g + u - 1, l);
|
|
1440
|
+
a.children.push(this._build(e, g, p, i - 1));
|
|
1444
1441
|
}
|
|
1445
1442
|
}
|
|
1446
|
-
return z(
|
|
1443
|
+
return z(a, this.toBBox), a;
|
|
1447
1444
|
}
|
|
1448
1445
|
_chooseSubtree(e, n, o, i) {
|
|
1449
1446
|
for (; i.push(n), !(n.leaf || i.length - 1 === o); ) {
|
|
1450
|
-
let r = 1 / 0, s = 1 / 0,
|
|
1447
|
+
let r = 1 / 0, s = 1 / 0, a;
|
|
1451
1448
|
for (let u = 0; u < n.children.length; u++) {
|
|
1452
1449
|
const h = n.children[u], m = ft(h), l = En(e, h) - m;
|
|
1453
|
-
l < s ? (s = l, r = m < r ? m : r,
|
|
1450
|
+
l < s ? (s = l, r = m < r ? m : r, a = h) : l === s && m < r && (r = m, a = h);
|
|
1454
1451
|
}
|
|
1455
|
-
n =
|
|
1452
|
+
n = a || n.children[0];
|
|
1456
1453
|
}
|
|
1457
1454
|
return n;
|
|
1458
1455
|
}
|
|
@@ -1466,37 +1463,37 @@ class yn {
|
|
|
1466
1463
|
_split(e, n) {
|
|
1467
1464
|
const o = e[n], i = o.children.length, r = this._minEntries;
|
|
1468
1465
|
this._chooseSplitAxis(o, r, i);
|
|
1469
|
-
const s = this._chooseSplitIndex(o, r, i),
|
|
1470
|
-
|
|
1466
|
+
const s = this._chooseSplitIndex(o, r, i), a = W(o.children.splice(s, o.children.length - s));
|
|
1467
|
+
a.height = o.height, a.leaf = o.leaf, z(o, this.toBBox), z(a, this.toBBox), n ? e[n - 1].children.push(a) : this._splitRoot(o, a);
|
|
1471
1468
|
}
|
|
1472
1469
|
_splitRoot(e, n) {
|
|
1473
1470
|
this.data = W([e, n]), this.data.height = e.height + 1, this.data.leaf = !1, z(this.data, this.toBBox);
|
|
1474
1471
|
}
|
|
1475
1472
|
_chooseSplitIndex(e, n, o) {
|
|
1476
1473
|
let i, r = 1 / 0, s = 1 / 0;
|
|
1477
|
-
for (let
|
|
1478
|
-
const u = G(e, 0,
|
|
1479
|
-
m < r ? (r = m, i =
|
|
1474
|
+
for (let a = n; a <= o - n; a++) {
|
|
1475
|
+
const u = G(e, 0, a, this.toBBox), h = G(e, a, o, this.toBBox), m = Sn(u, h), l = ft(u) + ft(h);
|
|
1476
|
+
m < r ? (r = m, i = a, s = l < s ? l : s) : m === r && l < s && (s = l, i = a);
|
|
1480
1477
|
}
|
|
1481
1478
|
return i || o - n;
|
|
1482
1479
|
}
|
|
1483
1480
|
// sorts node children by the best axis for split
|
|
1484
1481
|
_chooseSplitAxis(e, n, o) {
|
|
1485
|
-
const i = e.leaf ? this.compareMinX : xn, r = e.leaf ? this.compareMinY : An, s = this._allDistMargin(e, n, o, i),
|
|
1486
|
-
s <
|
|
1482
|
+
const i = e.leaf ? this.compareMinX : xn, r = e.leaf ? this.compareMinY : An, s = this._allDistMargin(e, n, o, i), a = this._allDistMargin(e, n, o, r);
|
|
1483
|
+
s < a && e.children.sort(i);
|
|
1487
1484
|
}
|
|
1488
1485
|
// total margin of all possible split distributions where each node is at least m full
|
|
1489
1486
|
_allDistMargin(e, n, o, i) {
|
|
1490
1487
|
e.children.sort(i);
|
|
1491
|
-
const r = this.toBBox, s = G(e, 0, n, r),
|
|
1492
|
-
let u = et(s) + et(
|
|
1488
|
+
const r = this.toBBox, s = G(e, 0, n, r), a = G(e, o - n, o, r);
|
|
1489
|
+
let u = et(s) + et(a);
|
|
1493
1490
|
for (let h = n; h < o - n; h++) {
|
|
1494
1491
|
const m = e.children[h];
|
|
1495
1492
|
K(s, e.leaf ? r(m) : m), u += et(s);
|
|
1496
1493
|
}
|
|
1497
1494
|
for (let h = o - n - 1; h >= n; h--) {
|
|
1498
1495
|
const m = e.children[h];
|
|
1499
|
-
K(
|
|
1496
|
+
K(a, e.leaf ? r(m) : m), u += et(a);
|
|
1500
1497
|
}
|
|
1501
1498
|
return u;
|
|
1502
1499
|
}
|
|
@@ -1574,11 +1571,11 @@ function Ut(t, e, n, o, i) {
|
|
|
1574
1571
|
}
|
|
1575
1572
|
}
|
|
1576
1573
|
const Cn = (t, e) => {
|
|
1577
|
-
const n = new yn(), o = /* @__PURE__ */ new Map(), i = (d,
|
|
1578
|
-
const
|
|
1574
|
+
const n = new yn(), o = /* @__PURE__ */ new Map(), i = (d, c) => {
|
|
1575
|
+
const v = d.selector.flatMap((L) => {
|
|
1579
1576
|
const C = $([L]) ? L.range : Dt(L, e).range;
|
|
1580
1577
|
return Array.from(C.getClientRects());
|
|
1581
|
-
}), E = ce(
|
|
1578
|
+
}), E = ce(v).map(({ left: L, top: C, right: T, bottom: B }) => new DOMRect(L - c.left, C - c.top, T - L, B - C));
|
|
1582
1579
|
return E.map((L) => {
|
|
1583
1580
|
const { x: C, y: T, width: B, height: M } = L;
|
|
1584
1581
|
return {
|
|
@@ -1594,56 +1591,56 @@ const Cn = (t, e) => {
|
|
|
1594
1591
|
});
|
|
1595
1592
|
}, r = () => [...o.values()], s = () => {
|
|
1596
1593
|
n.clear(), o.clear();
|
|
1597
|
-
},
|
|
1598
|
-
const
|
|
1599
|
-
|
|
1594
|
+
}, a = (d) => {
|
|
1595
|
+
const c = i(d, e.getBoundingClientRect());
|
|
1596
|
+
c.forEach((v) => n.insert(v)), o.set(d.annotation, c);
|
|
1600
1597
|
}, u = (d) => {
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1598
|
+
const c = o.get(d.annotation);
|
|
1599
|
+
c && (c.forEach((v) => n.remove(v)), o.delete(d.annotation));
|
|
1603
1600
|
}, h = (d) => {
|
|
1604
|
-
u(d),
|
|
1605
|
-
}, m = (d,
|
|
1606
|
-
|
|
1607
|
-
const
|
|
1601
|
+
u(d), a(d);
|
|
1602
|
+
}, m = (d, c = !0) => {
|
|
1603
|
+
c && s();
|
|
1604
|
+
const v = e.getBoundingClientRect(), E = d.map((C) => ({ target: C, rects: i(C, v) }));
|
|
1608
1605
|
E.forEach(({ target: C, rects: T }) => o.set(C.annotation, T));
|
|
1609
1606
|
const L = E.flatMap(({ rects: C }) => C);
|
|
1610
1607
|
n.load(L);
|
|
1611
|
-
}, l = (d,
|
|
1608
|
+
}, l = (d, c, v = !1) => {
|
|
1612
1609
|
const E = n.search({
|
|
1613
1610
|
minX: d,
|
|
1614
|
-
minY:
|
|
1611
|
+
minY: c,
|
|
1615
1612
|
maxX: d,
|
|
1616
|
-
maxY:
|
|
1613
|
+
maxY: c
|
|
1617
1614
|
}), L = (C) => C.annotation.rects.reduce((T, B) => T + B.width * B.height, 0);
|
|
1618
|
-
return E.length > 0 ? (E.sort((C, T) => L(C) - L(T)),
|
|
1619
|
-
},
|
|
1620
|
-
const
|
|
1621
|
-
if (
|
|
1615
|
+
return E.length > 0 ? (E.sort((C, T) => L(C) - L(T)), v ? E.map((C) => C.annotation.id) : [E[0].annotation.id]) : [];
|
|
1616
|
+
}, g = (d) => {
|
|
1617
|
+
const c = p(d);
|
|
1618
|
+
if (c.length === 0)
|
|
1622
1619
|
return;
|
|
1623
|
-
let
|
|
1624
|
-
for (let T = 1; T <
|
|
1625
|
-
const B =
|
|
1626
|
-
|
|
1620
|
+
let v = c[0].left, E = c[0].top, L = c[0].right, C = c[0].bottom;
|
|
1621
|
+
for (let T = 1; T < c.length; T++) {
|
|
1622
|
+
const B = c[T];
|
|
1623
|
+
v = Math.min(v, B.left), E = Math.min(E, B.top), L = Math.max(L, B.right), C = Math.max(C, B.bottom);
|
|
1627
1624
|
}
|
|
1628
|
-
return new DOMRect(
|
|
1629
|
-
},
|
|
1630
|
-
const
|
|
1631
|
-
return
|
|
1625
|
+
return new DOMRect(v, E, L - v, C - E);
|
|
1626
|
+
}, p = (d) => {
|
|
1627
|
+
const c = o.get(d);
|
|
1628
|
+
return c ? c[0].annotation.rects : [];
|
|
1632
1629
|
};
|
|
1633
1630
|
return {
|
|
1634
1631
|
all: r,
|
|
1635
1632
|
clear: s,
|
|
1636
1633
|
getAt: l,
|
|
1637
|
-
getAnnotationBounds:
|
|
1638
|
-
getAnnotationRects:
|
|
1639
|
-
getIntersecting: (d,
|
|
1640
|
-
const L = n.search({ minX: d, minY:
|
|
1634
|
+
getAnnotationBounds: g,
|
|
1635
|
+
getAnnotationRects: p,
|
|
1636
|
+
getIntersecting: (d, c, v, E) => {
|
|
1637
|
+
const L = n.search({ minX: d, minY: c, maxX: v, maxY: E }), C = new Set(L.map((T) => T.annotation.id));
|
|
1641
1638
|
return Array.from(C).map((T) => ({
|
|
1642
1639
|
annotation: t.getAnnotation(T),
|
|
1643
|
-
rects:
|
|
1640
|
+
rects: p(T)
|
|
1644
1641
|
})).filter((T) => !!T.annotation);
|
|
1645
1642
|
},
|
|
1646
|
-
insert:
|
|
1643
|
+
insert: a,
|
|
1647
1644
|
recalculate: () => m(t.all().map((d) => d.target), !0),
|
|
1648
1645
|
remove: u,
|
|
1649
1646
|
set: m,
|
|
@@ -1651,48 +1648,48 @@ const Cn = (t, e) => {
|
|
|
1651
1648
|
update: h
|
|
1652
1649
|
};
|
|
1653
1650
|
}, Ln = (t, e) => {
|
|
1654
|
-
const n = Ge(), o = Cn(n, t), i = ke(n, e), r = Ve(n), s = Ze(),
|
|
1655
|
-
const d = rt(
|
|
1656
|
-
return
|
|
1657
|
-
}, u = (
|
|
1658
|
-
const
|
|
1659
|
-
return
|
|
1660
|
-
}, h = (
|
|
1661
|
-
const d =
|
|
1662
|
-
return
|
|
1663
|
-
n.getAnnotation(
|
|
1664
|
-
}),
|
|
1665
|
-
}, m = (
|
|
1666
|
-
const d = it(
|
|
1667
|
-
n.updateTarget(d,
|
|
1668
|
-
}, l = (
|
|
1669
|
-
const d =
|
|
1670
|
-
n.bulkUpdateTargets(d,
|
|
1671
|
-
},
|
|
1672
|
-
const
|
|
1673
|
-
return
|
|
1674
|
-
},
|
|
1675
|
-
const
|
|
1676
|
-
if (
|
|
1677
|
-
if (
|
|
1678
|
-
const E =
|
|
1651
|
+
const n = Ge(), o = Cn(n, t), i = ke(n, e), r = Ve(n), s = Ze(), a = (y, f = N.LOCAL) => {
|
|
1652
|
+
const d = rt(y, t), c = $(d.target.selector);
|
|
1653
|
+
return c && n.addAnnotation(d, f), c;
|
|
1654
|
+
}, u = (y, f = !0, d = N.LOCAL) => {
|
|
1655
|
+
const c = y.map((E) => rt(E, t)), v = c.filter((E) => !$(E.target.selector));
|
|
1656
|
+
return v.length > 0 ? (console.warn("Could not revive all targets for these annotations:", v), n.bulkAddAnnotation(c, f, d), v) : (n.bulkAddAnnotation(c, f, d), []);
|
|
1657
|
+
}, h = (y, f = N.LOCAL) => {
|
|
1658
|
+
const d = y.map((v) => rt(v, t)), c = d.filter((v) => !$(v.target.selector));
|
|
1659
|
+
return c.length > 0 && console.warn("Could not revive all targets for these annotations:", c), d.forEach((v) => {
|
|
1660
|
+
n.getAnnotation(v.id) ? n.updateAnnotation(v, f) : n.addAnnotation(v, f);
|
|
1661
|
+
}), c;
|
|
1662
|
+
}, m = (y, f = N.LOCAL) => {
|
|
1663
|
+
const d = it(y, t);
|
|
1664
|
+
n.updateTarget(d, f);
|
|
1665
|
+
}, l = (y, f = N.LOCAL) => {
|
|
1666
|
+
const d = y.map((c) => it(c, t));
|
|
1667
|
+
n.bulkUpdateTargets(d, f);
|
|
1668
|
+
}, g = (y, f, d) => {
|
|
1669
|
+
const c = o.getAt(y, f, !!d).map((E) => n.getAnnotation(E)), v = d ? c.filter(d) : c;
|
|
1670
|
+
return v.length > 0 ? v[0] : void 0;
|
|
1671
|
+
}, p = (y, f, d, c = 5) => {
|
|
1672
|
+
const v = o.getAnnotationRects(y);
|
|
1673
|
+
if (v.length !== 0) {
|
|
1674
|
+
if (f && d) {
|
|
1675
|
+
const E = v.find(({ top: L, right: C, bottom: T, left: B }) => f >= B - c && f <= C + c && d >= L - c && d <= T + c);
|
|
1679
1676
|
if (E) return E;
|
|
1680
1677
|
}
|
|
1681
|
-
return o.getAnnotationBounds(
|
|
1678
|
+
return o.getAnnotationBounds(y);
|
|
1682
1679
|
}
|
|
1683
1680
|
}, w = () => o.recalculate();
|
|
1684
|
-
return n.observe(({ changes:
|
|
1685
|
-
const
|
|
1686
|
-
(
|
|
1681
|
+
return n.observe(({ changes: y }) => {
|
|
1682
|
+
const f = (y.deleted || []).filter((v) => $(v.target.selector)), d = (y.created || []).filter((v) => $(v.target.selector)), c = (y.updated || []).filter((v) => $(v.newValue.target.selector));
|
|
1683
|
+
(f == null ? void 0 : f.length) > 0 && f.forEach((v) => o.remove(v.target)), d.length > 0 && o.set(d.map((v) => v.target), !1), (c == null ? void 0 : c.length) > 0 && c.forEach(({ newValue: v }) => o.update(v.target));
|
|
1687
1684
|
}), {
|
|
1688
1685
|
store: {
|
|
1689
1686
|
...n,
|
|
1690
|
-
addAnnotation:
|
|
1687
|
+
addAnnotation: a,
|
|
1691
1688
|
bulkAddAnnotation: u,
|
|
1692
1689
|
bulkUpdateTargets: l,
|
|
1693
1690
|
bulkUpsertAnnotations: h,
|
|
1694
|
-
getAnnotationBounds:
|
|
1695
|
-
getAt:
|
|
1691
|
+
getAnnotationBounds: p,
|
|
1692
|
+
getAt: g,
|
|
1696
1693
|
getIntersecting: o.getIntersecting,
|
|
1697
1694
|
recalculatePositions: w,
|
|
1698
1695
|
updateTarget: m
|
|
@@ -1709,27 +1706,27 @@ const Cn = (t, e) => {
|
|
|
1709
1706
|
}, Tn = (t, e, n = {}) => {
|
|
1710
1707
|
const o = Bn(), i = o.getContext("2d");
|
|
1711
1708
|
document.body.appendChild(o);
|
|
1712
|
-
const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([
|
|
1713
|
-
return e.on("selectionChange", (l,
|
|
1714
|
-
s(l).forEach((w) => r.delete(w)),
|
|
1709
|
+
const r = /* @__PURE__ */ new Map(), s = (l) => Array.from(r.entries()).filter(([g, p]) => p.presenceKey === l.presenceKey).map(([g, p]) => g);
|
|
1710
|
+
return e.on("selectionChange", (l, g) => {
|
|
1711
|
+
s(l).forEach((w) => r.delete(w)), g && g.forEach((w) => r.set(w, l));
|
|
1715
1712
|
}), {
|
|
1716
1713
|
clear: () => {
|
|
1717
|
-
const { width: l, height:
|
|
1718
|
-
i.clearRect(-0.5, -0.5, l + 1,
|
|
1714
|
+
const { width: l, height: g } = o;
|
|
1715
|
+
i.clearRect(-0.5, -0.5, l + 1, g + 1);
|
|
1719
1716
|
},
|
|
1720
1717
|
destroy: () => {
|
|
1721
1718
|
o.remove();
|
|
1722
1719
|
},
|
|
1723
|
-
paint: (l,
|
|
1720
|
+
paint: (l, g, p) => {
|
|
1724
1721
|
n.font && (i.font = n.font);
|
|
1725
1722
|
const w = r.get(l.annotation.id);
|
|
1726
1723
|
if (w) {
|
|
1727
|
-
const { height:
|
|
1728
|
-
i.fillStyle = w.appearance.color, i.fillRect(
|
|
1729
|
-
const
|
|
1730
|
-
return i.fillRect(
|
|
1724
|
+
const { height: y } = l.rects[0], f = l.rects[0].x + g.left, d = l.rects[0].y + g.top;
|
|
1725
|
+
i.fillStyle = w.appearance.color, i.fillRect(f - 2, d - 2.5, 2, y + 5);
|
|
1726
|
+
const c = i.measureText(w.appearance.label), v = c.width + 6, E = c.actualBoundingBoxAscent + c.actualBoundingBoxDescent + 8, L = c.fontBoundingBoxAscent ? 8 : 6.5;
|
|
1727
|
+
return i.fillRect(f - 2, d - 2.5 - E, v, E), i.fillStyle = "#fff", i.fillText(w.appearance.label, f + 1, d - L), {
|
|
1731
1728
|
fill: w.appearance.color,
|
|
1732
|
-
fillOpacity:
|
|
1729
|
+
fillOpacity: p ? 0.45 : 0.18
|
|
1733
1730
|
};
|
|
1734
1731
|
}
|
|
1735
1732
|
},
|
|
@@ -1746,12 +1743,12 @@ const Cn = (t, e) => {
|
|
|
1746
1743
|
return e !== "visible" && e !== "hidden" && t.scrollHeight > t.clientHeight ? t : Wt(t.parentElement);
|
|
1747
1744
|
}, Rn = (t, e) => (n) => {
|
|
1748
1745
|
const o = typeof n == "string" ? n : n.id, i = (s) => {
|
|
1749
|
-
const
|
|
1750
|
-
r.scroll({ top: d, left:
|
|
1746
|
+
const a = r.getBoundingClientRect(), u = r.clientHeight, h = r.clientWidth, m = s.selector[0].range.getBoundingClientRect(), { width: l, height: g } = e.getAnnotationBounds(o), p = m.top - a.top, w = m.left - a.left, y = r.parentElement ? r.scrollTop : 0, f = r.parentElement ? r.scrollLeft : 0, d = p + y - (u - g) / 2, c = w + f - (h - l) / 2;
|
|
1747
|
+
r.scroll({ top: d, left: c, behavior: "smooth" });
|
|
1751
1748
|
}, r = Wt(t);
|
|
1752
1749
|
if (r) {
|
|
1753
|
-
const s = e.getAnnotation(o), { range:
|
|
1754
|
-
if (
|
|
1750
|
+
const s = e.getAnnotation(o), { range: a } = s.target.selector[0];
|
|
1751
|
+
if (a && !a.collapsed)
|
|
1755
1752
|
return i(s.target), !0;
|
|
1756
1753
|
{
|
|
1757
1754
|
const u = it(s.target, t), { range: h } = u.selector[0];
|
|
@@ -1766,30 +1763,30 @@ const Cn = (t, e) => {
|
|
|
1766
1763
|
user: t.user || e.user
|
|
1767
1764
|
}), Mn = (t, e, n, o) => {
|
|
1768
1765
|
let i;
|
|
1769
|
-
const r = (
|
|
1766
|
+
const r = (c) => i = c;
|
|
1770
1767
|
let s;
|
|
1771
|
-
const
|
|
1772
|
-
let m, l = !1,
|
|
1773
|
-
const
|
|
1768
|
+
const a = (c) => s = c, { store: u, selection: h } = e;
|
|
1769
|
+
let m, l = !1, g;
|
|
1770
|
+
const p = (c) => {
|
|
1774
1771
|
var E;
|
|
1775
1772
|
if (!l) return;
|
|
1776
|
-
!((E =
|
|
1773
|
+
!((E = c.target.parentElement) != null && E.closest(D)) ? m = {
|
|
1777
1774
|
annotation: Ht(),
|
|
1778
1775
|
selector: [],
|
|
1779
1776
|
creator: i,
|
|
1780
1777
|
created: /* @__PURE__ */ new Date()
|
|
1781
1778
|
} : m = void 0;
|
|
1782
1779
|
};
|
|
1783
|
-
n && t.addEventListener("selectstart",
|
|
1784
|
-
const w = bt((
|
|
1780
|
+
n && t.addEventListener("selectstart", p);
|
|
1781
|
+
const w = bt((c) => {
|
|
1785
1782
|
var B, M;
|
|
1786
|
-
const
|
|
1787
|
-
if (!!((M = (B =
|
|
1783
|
+
const v = document.getSelection();
|
|
1784
|
+
if (!!((M = (B = v.anchorNode) == null ? void 0 : B.parentElement) != null && M.closest(D))) {
|
|
1788
1785
|
m = void 0;
|
|
1789
1786
|
return;
|
|
1790
1787
|
}
|
|
1791
|
-
if (
|
|
1792
|
-
const L =
|
|
1788
|
+
if (c.timeStamp - ((g == null ? void 0 : g.timeStamp) || c.timeStamp) < 1e3 && !m && p(g), v.isCollapsed || !l || !m) return;
|
|
1789
|
+
const L = v.getRangeAt(0);
|
|
1793
1790
|
if (re(L)) return;
|
|
1794
1791
|
const C = Zt(L.cloneRange());
|
|
1795
1792
|
(C.length !== m.selector.length || C.some((b, x) => {
|
|
@@ -1803,32 +1800,32 @@ const Cn = (t, e) => {
|
|
|
1803
1800
|
id: m.annotation,
|
|
1804
1801
|
bodies: [],
|
|
1805
1802
|
target: m
|
|
1806
|
-
}, N.LOCAL), h.clickSelect(m.annotation,
|
|
1803
|
+
}, N.LOCAL), h.clickSelect(m.annotation, g)));
|
|
1807
1804
|
});
|
|
1808
1805
|
n && document.addEventListener("selectionchange", w);
|
|
1809
|
-
const
|
|
1810
|
-
const { target:
|
|
1811
|
-
|
|
1806
|
+
const y = (c) => {
|
|
1807
|
+
const { target: v, timeStamp: E, offsetX: L, offsetY: C, type: T } = c;
|
|
1808
|
+
g = { ...c, target: v, timeStamp: E, offsetX: L, offsetY: C, type: T }, l = c.button === 0;
|
|
1812
1809
|
};
|
|
1813
|
-
t.addEventListener("pointerdown",
|
|
1814
|
-
const
|
|
1810
|
+
t.addEventListener("pointerdown", y);
|
|
1811
|
+
const f = (c) => {
|
|
1815
1812
|
var C;
|
|
1816
|
-
if (!!((C =
|
|
1813
|
+
if (!!((C = c.target.parentElement) != null && C.closest(D)) || !l)
|
|
1817
1814
|
return;
|
|
1818
1815
|
const E = () => {
|
|
1819
|
-
const { x: T, y: B } = t.getBoundingClientRect(), M = u.getAt(
|
|
1816
|
+
const { x: T, y: B } = t.getBoundingClientRect(), M = u.getAt(c.clientX - T, c.clientY - B, s);
|
|
1820
1817
|
if (M) {
|
|
1821
1818
|
const { selected: b } = h;
|
|
1822
|
-
(b.length !== 1 || b[0].id !== M.id) && h.clickSelect(M.id,
|
|
1819
|
+
(b.length !== 1 || b[0].id !== M.id) && h.clickSelect(M.id, c);
|
|
1823
1820
|
} else h.isEmpty() || h.clear();
|
|
1824
|
-
}, L =
|
|
1825
|
-
document.getSelection().isCollapsed && L < 300 ? (m = void 0, E()) : m && h.clickSelect(m.annotation,
|
|
1821
|
+
}, L = c.timeStamp - g.timeStamp;
|
|
1822
|
+
document.getSelection().isCollapsed && L < 300 ? (m = void 0, E()) : m && h.clickSelect(m.annotation, c);
|
|
1826
1823
|
};
|
|
1827
|
-
return document.addEventListener("pointerup",
|
|
1824
|
+
return document.addEventListener("pointerup", f), {
|
|
1828
1825
|
destroy: () => {
|
|
1829
|
-
t.removeEventListener("selectstart",
|
|
1826
|
+
t.removeEventListener("selectstart", p), document.removeEventListener("selectionchange", w), t.removeEventListener("pointerdown", y), document.removeEventListener("pointerup", f);
|
|
1830
1827
|
},
|
|
1831
|
-
setFilter:
|
|
1828
|
+
setFilter: a,
|
|
1832
1829
|
setUser: r
|
|
1833
1830
|
};
|
|
1834
1831
|
}, kt = "SPANS", kn = (t, e = {}) => {
|
|
@@ -1836,36 +1833,35 @@ const Cn = (t, e) => {
|
|
|
1836
1833
|
const n = Nn(e, {
|
|
1837
1834
|
annotationEnabled: !0,
|
|
1838
1835
|
user: ln()
|
|
1839
|
-
}), o = Ln(t, n.pointerAction), { selection: i, viewport: r } = o, s = o.store,
|
|
1836
|
+
}), o = Ln(t, n.pointerAction), { selection: i, viewport: r } = o, s = o.store, a = Je(s), u = tn(o, a, n.adapter);
|
|
1840
1837
|
let h = n.user;
|
|
1841
1838
|
const m = n.renderer === "CSS_HIGHLIGHTS" ? CSS.highlights ? "CSS_HIGHLIGHTS" : kt : n.renderer || kt, l = m === "SPANS" ? Te(t, o, r) : m === "CSS_HIGHLIGHTS" ? Ce(t, o, r) : m === "CANVAS" ? ge(t, o, r) : void 0;
|
|
1842
1839
|
if (!l)
|
|
1843
1840
|
throw `Unknown renderer implementation: ${m}`;
|
|
1844
1841
|
console.debug(`Using ${m} renderer`), n.style && l.setStyle(n.style);
|
|
1845
|
-
const
|
|
1846
|
-
|
|
1847
|
-
const
|
|
1848
|
-
l.setFilter(E),
|
|
1849
|
-
},
|
|
1850
|
-
h = E,
|
|
1842
|
+
const g = Mn(t, o, n.annotationEnabled, n.offsetReferenceSelector);
|
|
1843
|
+
g.setUser(h);
|
|
1844
|
+
const p = nn(o, a, n.adapter), w = () => h, y = (E) => {
|
|
1845
|
+
l.setFilter(E), g.setFilter(E);
|
|
1846
|
+
}, f = (E) => {
|
|
1847
|
+
h = E, g.setUser(E);
|
|
1851
1848
|
}, d = (E) => {
|
|
1852
1849
|
E && (l.setPainter(Tn(t, E, n.presence)), E.on("selectionChange", () => l.redraw()));
|
|
1853
|
-
},
|
|
1850
|
+
}, c = (E) => {
|
|
1854
1851
|
E ? i.setSelected(E) : i.clear();
|
|
1855
1852
|
};
|
|
1856
1853
|
return {
|
|
1857
|
-
...
|
|
1854
|
+
...p,
|
|
1858
1855
|
destroy: () => {
|
|
1859
|
-
l.destroy(),
|
|
1856
|
+
l.destroy(), g.destroy(), a.destroy();
|
|
1860
1857
|
},
|
|
1861
1858
|
element: t,
|
|
1862
1859
|
getUser: w,
|
|
1863
|
-
setFilter:
|
|
1860
|
+
setFilter: y,
|
|
1864
1861
|
setStyle: l.setStyle.bind(l),
|
|
1865
1862
|
redraw: l.redraw.bind(l),
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
setSelected: a,
|
|
1863
|
+
setUser: f,
|
|
1864
|
+
setSelected: c,
|
|
1869
1865
|
setPresenceProvider: d,
|
|
1870
1866
|
setVisible: l.setVisible.bind(l),
|
|
1871
1867
|
on: u.on,
|