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