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