@readium/navigator-html-injectables 2.0.0-beta.7 → 2.1.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/index.js
CHANGED
|
@@ -1,70 +1,70 @@
|
|
|
1
|
-
const
|
|
2
|
-
class
|
|
3
|
-
constructor(
|
|
4
|
-
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd =
|
|
1
|
+
const ae = Math.pow(2, 32), vt = () => Math.round(Math.random() * ae).toString(36), le = () => `${Math.round(performance.now())}-${vt()}-${vt()}`, H = 1;
|
|
2
|
+
class he {
|
|
3
|
+
constructor(t) {
|
|
4
|
+
this.destination = null, this.registrar = /* @__PURE__ */ new Map(), this.origin = "", this.channelId = "", this.receiver = this.receive.bind(this), this.preLog = [], this.wnd = t, t.addEventListener("message", this.receiver);
|
|
5
5
|
}
|
|
6
|
-
receive(
|
|
7
|
-
if (
|
|
6
|
+
receive(t) {
|
|
7
|
+
if (t.source === null)
|
|
8
8
|
throw Error("Event source is null");
|
|
9
|
-
if (typeof
|
|
9
|
+
if (typeof t.data != "object")
|
|
10
10
|
return;
|
|
11
|
-
const
|
|
12
|
-
if (!(!("_readium" in
|
|
13
|
-
if (
|
|
11
|
+
const e = t.data;
|
|
12
|
+
if (!(!("_readium" in e) || !e._readium || e._readium <= 0)) {
|
|
13
|
+
if (e.key === "_ping") {
|
|
14
14
|
if (!this.destination) {
|
|
15
|
-
if (this.destination =
|
|
16
|
-
|
|
15
|
+
if (this.destination = t.source, this.origin = t.origin, this.channelId = e._channel, e._readium !== H) {
|
|
16
|
+
e._readium > H ? this.send("error", `received comms version ${e._readium} higher than ${H}`) : this.send("error", `received comms version ${e._readium} lower than ${H}`), this.destination = null, this.origin = "", this.channelId = "";
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
19
|
this.send("_pong", void 0), this.preLog.forEach((i) => this.send("log", i)), this.preLog = [];
|
|
20
20
|
}
|
|
21
21
|
return;
|
|
22
22
|
} else if (this.channelId) {
|
|
23
|
-
if (
|
|
23
|
+
if (e._channel !== this.channelId || t.origin !== this.origin)
|
|
24
24
|
return;
|
|
25
25
|
} else
|
|
26
26
|
return;
|
|
27
|
-
this.handle(
|
|
27
|
+
this.handle(e);
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
handle(
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
|
|
30
|
+
handle(t) {
|
|
31
|
+
const e = this.registrar.get(t.key);
|
|
32
|
+
if (!e || e.length === 0) {
|
|
33
|
+
t.strict && this.send("_unhandled", t);
|
|
34
34
|
return;
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
this.send("_ack",
|
|
36
|
+
e.forEach((i) => i.cb(t.data, (r) => {
|
|
37
|
+
this.send("_ack", r, t.id);
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
register(
|
|
41
|
-
Array.isArray(
|
|
42
|
-
const n = this.registrar.get(
|
|
40
|
+
register(t, e, i) {
|
|
41
|
+
Array.isArray(t) || (t = [t]), t.forEach((r) => {
|
|
42
|
+
const n = this.registrar.get(r);
|
|
43
43
|
if (n && n.length >= 0) {
|
|
44
|
-
if (n.find((l) => l.module ===
|
|
45
|
-
throw new Error(`Trying to register another callback for combination of event ${
|
|
44
|
+
if (n.find((l) => l.module === e))
|
|
45
|
+
throw new Error(`Trying to register another callback for combination of event ${r} and module ${e}`);
|
|
46
46
|
n.push({
|
|
47
47
|
cb: i,
|
|
48
|
-
module:
|
|
49
|
-
}), this.registrar.set(
|
|
48
|
+
module: e
|
|
49
|
+
}), this.registrar.set(r, n);
|
|
50
50
|
} else
|
|
51
|
-
this.registrar.set(
|
|
51
|
+
this.registrar.set(r, [{
|
|
52
52
|
cb: i,
|
|
53
|
-
module:
|
|
53
|
+
module: e
|
|
54
54
|
}]);
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
unregister(
|
|
58
|
-
Array.isArray(
|
|
59
|
-
const
|
|
60
|
-
!
|
|
57
|
+
unregister(t, e) {
|
|
58
|
+
Array.isArray(t) || (t = [t]), t.forEach((i) => {
|
|
59
|
+
const r = this.registrar.get(i);
|
|
60
|
+
!r || r.length === 0 || r.splice(r.findIndex((n) => n.module === e), 1);
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
unregisterAll(
|
|
64
|
-
this.registrar.forEach((
|
|
63
|
+
unregisterAll(t) {
|
|
64
|
+
this.registrar.forEach((e, i) => this.registrar.set(i, e.filter((r) => r.module !== t)));
|
|
65
65
|
}
|
|
66
|
-
log(...
|
|
67
|
-
this.destination ? this.send("log",
|
|
66
|
+
log(...t) {
|
|
67
|
+
this.destination ? this.send("log", t) : this.preLog.push(t);
|
|
68
68
|
}
|
|
69
69
|
get ready() {
|
|
70
70
|
return !!this.destination;
|
|
@@ -72,67 +72,111 @@ class at {
|
|
|
72
72
|
destroy() {
|
|
73
73
|
this.destination = null, this.channelId = "", this.preLog = [], this.registrar.clear(), this.wnd.removeEventListener("message", this.receiver);
|
|
74
74
|
}
|
|
75
|
-
send(
|
|
75
|
+
send(t, e, i = void 0, r = []) {
|
|
76
76
|
if (!this.destination)
|
|
77
77
|
throw Error("Attempted to send comms message before destination has been initialized");
|
|
78
78
|
const n = {
|
|
79
|
-
_readium:
|
|
79
|
+
_readium: H,
|
|
80
80
|
_channel: this.channelId,
|
|
81
|
-
id: i ??
|
|
81
|
+
id: i ?? le(),
|
|
82
82
|
// scrict,
|
|
83
|
-
key:
|
|
84
|
-
data:
|
|
83
|
+
key: t,
|
|
84
|
+
data: e
|
|
85
85
|
};
|
|
86
86
|
try {
|
|
87
87
|
this.destination.postMessage(n, {
|
|
88
88
|
targetOrigin: this.origin,
|
|
89
|
-
transfer:
|
|
89
|
+
transfer: r
|
|
90
90
|
});
|
|
91
91
|
} catch (o) {
|
|
92
|
-
if (
|
|
92
|
+
if (r.length > 0)
|
|
93
93
|
throw o;
|
|
94
|
-
this.destination.postMessage(n, this.origin,
|
|
94
|
+
this.destination.postMessage(n, this.origin, r);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
class
|
|
98
|
+
const L = class B {
|
|
99
|
+
constructor(t) {
|
|
100
|
+
if (typeof t == "string") {
|
|
101
|
+
if (!B.VALID_MODES.has(t.toLowerCase()))
|
|
102
|
+
return;
|
|
103
|
+
this.value = t.toLowerCase();
|
|
104
|
+
} else {
|
|
105
|
+
const e = t.filter(
|
|
106
|
+
(i) => B.VALID_MODES.has(i.toLowerCase())
|
|
107
|
+
);
|
|
108
|
+
if (e.length === 0)
|
|
109
|
+
return;
|
|
110
|
+
this.value = Array.from(new Set(e));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Parses a [PrimaryAccessMode] from its RWPM JSON representation.
|
|
115
|
+
*/
|
|
116
|
+
static deserialize(t) {
|
|
117
|
+
if (!t)
|
|
118
|
+
return;
|
|
119
|
+
if (typeof t == "string")
|
|
120
|
+
return new B(t);
|
|
121
|
+
if (!Array.isArray(t))
|
|
122
|
+
return;
|
|
123
|
+
const e = t.filter((i) => i ? B.VALID_MODES.has(i.toLowerCase()) : !1);
|
|
124
|
+
if (e.length !== 0)
|
|
125
|
+
return new B(e);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
|
|
129
|
+
*/
|
|
130
|
+
serialize() {
|
|
131
|
+
return this.value;
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
L.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]);
|
|
135
|
+
L.AUDITORY = new L("auditory");
|
|
136
|
+
L.TACTILE = new L("tactile");
|
|
137
|
+
L.TEXTUAL = new L("textual");
|
|
138
|
+
L.VISUAL = new L("visual");
|
|
139
|
+
class rt {
|
|
99
140
|
/**
|
|
100
141
|
* Creates a [Encryption].
|
|
101
142
|
*/
|
|
102
|
-
constructor(
|
|
103
|
-
this.algorithm =
|
|
143
|
+
constructor(t) {
|
|
144
|
+
this.algorithm = t.algorithm, this.compression = t.compression, this.originalLength = t.originalLength, this.profile = t.profile, this.scheme = t.scheme;
|
|
104
145
|
}
|
|
105
146
|
/**
|
|
106
147
|
* Parses a [Encryption] from its RWPM JSON representation.
|
|
107
148
|
*/
|
|
108
|
-
static deserialize(
|
|
109
|
-
if (
|
|
110
|
-
return new
|
|
111
|
-
algorithm:
|
|
112
|
-
compression:
|
|
113
|
-
originalLength:
|
|
114
|
-
profile:
|
|
115
|
-
scheme:
|
|
149
|
+
static deserialize(t) {
|
|
150
|
+
if (t && t.algorithm)
|
|
151
|
+
return new rt({
|
|
152
|
+
algorithm: t.algorithm,
|
|
153
|
+
compression: t.compression,
|
|
154
|
+
originalLength: t.originalLength,
|
|
155
|
+
profile: t.profile,
|
|
156
|
+
scheme: t.scheme
|
|
116
157
|
});
|
|
117
158
|
}
|
|
118
159
|
/**
|
|
119
160
|
* Serializes a [Encryption] to its RWPM JSON representation.
|
|
120
161
|
*/
|
|
121
162
|
serialize() {
|
|
122
|
-
const
|
|
123
|
-
return this.compression !== void 0 && (
|
|
163
|
+
const t = { algorithm: this.algorithm };
|
|
164
|
+
return this.compression !== void 0 && (t.compression = this.compression), this.originalLength !== void 0 && (t.originalLength = this.originalLength), this.profile !== void 0 && (t.profile = this.profile), this.scheme !== void 0 && (t.scheme = this.scheme), t;
|
|
124
165
|
}
|
|
125
166
|
}
|
|
126
|
-
class
|
|
127
|
-
constructor(
|
|
128
|
-
this.otherProperties =
|
|
167
|
+
class w {
|
|
168
|
+
constructor(t) {
|
|
169
|
+
this.otherProperties = t;
|
|
170
|
+
}
|
|
171
|
+
get page() {
|
|
172
|
+
return this.otherProperties.page;
|
|
129
173
|
}
|
|
130
174
|
/**
|
|
131
175
|
* Creates a [Properties] from its RWPM JSON representation.
|
|
132
176
|
*/
|
|
133
|
-
static deserialize(
|
|
134
|
-
if (
|
|
135
|
-
return new
|
|
177
|
+
static deserialize(t) {
|
|
178
|
+
if (t)
|
|
179
|
+
return new w(t);
|
|
136
180
|
}
|
|
137
181
|
/**
|
|
138
182
|
* Serializes a [Properties] to its RWPM JSON representation.
|
|
@@ -143,37 +187,50 @@ class b {
|
|
|
143
187
|
/**
|
|
144
188
|
* Makes a copy of this [Properties] after merging in the given additional other [properties].
|
|
145
189
|
*/
|
|
146
|
-
add(
|
|
147
|
-
const
|
|
148
|
-
for (const i in
|
|
149
|
-
|
|
150
|
-
return new
|
|
190
|
+
add(t) {
|
|
191
|
+
const e = Object.assign({}, this.otherProperties);
|
|
192
|
+
for (const i in t)
|
|
193
|
+
e[i] = t[i];
|
|
194
|
+
return new w(e);
|
|
151
195
|
}
|
|
152
196
|
}
|
|
153
|
-
Object.defineProperty(
|
|
197
|
+
Object.defineProperty(w.prototype, "encryption", {
|
|
154
198
|
get: function() {
|
|
155
|
-
return
|
|
199
|
+
return rt.deserialize(this.otherProperties.encrypted);
|
|
156
200
|
}
|
|
157
201
|
});
|
|
158
|
-
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return
|
|
163
|
-
}
|
|
202
|
+
function ce(s) {
|
|
203
|
+
return s && s instanceof Array ? s : void 0;
|
|
204
|
+
}
|
|
205
|
+
function Ut(s) {
|
|
206
|
+
return s && typeof s == "string" ? [s] : ce(s);
|
|
207
|
+
}
|
|
208
|
+
function bt(s) {
|
|
209
|
+
return typeof s == "string" ? new Date(s) : void 0;
|
|
210
|
+
}
|
|
211
|
+
function q(s) {
|
|
212
|
+
return isNaN(s) ? void 0 : s;
|
|
213
|
+
}
|
|
214
|
+
function T(s) {
|
|
215
|
+
return q(s) !== void 0 && Math.sign(s) >= 0 ? s : void 0;
|
|
216
|
+
}
|
|
217
|
+
function ue(s) {
|
|
218
|
+
const t = new Array();
|
|
219
|
+
return s.forEach((e) => t.push(e)), t;
|
|
220
|
+
}
|
|
164
221
|
class a {
|
|
165
222
|
/** Creates a MediaType object. */
|
|
166
|
-
constructor(
|
|
167
|
-
let
|
|
168
|
-
const n =
|
|
223
|
+
constructor(t) {
|
|
224
|
+
let e, i, r = t.mediaType.replace(/\s/g, "").split(";");
|
|
225
|
+
const n = r[0].split("/");
|
|
169
226
|
if (n.length === 2) {
|
|
170
|
-
if (
|
|
227
|
+
if (e = n[0].toLowerCase().trim(), i = n[1].toLowerCase().trim(), e.length === 0 || i.length === 0)
|
|
171
228
|
throw new Error("Invalid media type");
|
|
172
229
|
} else
|
|
173
230
|
throw new Error("Invalid media type");
|
|
174
231
|
const o = {};
|
|
175
|
-
for (let d = 1; d <
|
|
176
|
-
const f =
|
|
232
|
+
for (let d = 1; d < r.length; d++) {
|
|
233
|
+
const f = r[d].split("=");
|
|
177
234
|
if (f.length === 2) {
|
|
178
235
|
const g = f[0].toLocaleLowerCase(), m = g === "charset" ? f[1].toUpperCase() : f[1];
|
|
179
236
|
o[g] = m;
|
|
@@ -186,19 +243,19 @@ class a {
|
|
|
186
243
|
const f = l[d];
|
|
187
244
|
h += `;${d}=${f}`;
|
|
188
245
|
}
|
|
189
|
-
const u = `${
|
|
190
|
-
this.string = u, this.type =
|
|
246
|
+
const u = `${e}/${i}${h}`, p = l.encoding;
|
|
247
|
+
this.string = u, this.type = e, this.subtype = i, this.parameters = l, this.encoding = p, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
191
248
|
}
|
|
192
|
-
static parse(
|
|
193
|
-
return new a(
|
|
249
|
+
static parse(t) {
|
|
250
|
+
return new a(t);
|
|
194
251
|
}
|
|
195
252
|
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
|
|
196
253
|
* Gives a hint on the underlying structure of this media type.
|
|
197
254
|
* See. https://tools.ietf.org/html/rfc6838#section-4.2.8
|
|
198
255
|
*/
|
|
199
256
|
get structuredSyntaxSuffix() {
|
|
200
|
-
const
|
|
201
|
-
return
|
|
257
|
+
const t = this.subtype.split("+");
|
|
258
|
+
return t.length > 1 ? `+${t[t.length - 1]}` : void 0;
|
|
202
259
|
}
|
|
203
260
|
/** Parameter values might or might not be case-sensitive, depending on the semantics of
|
|
204
261
|
* the parameter name.
|
|
@@ -219,17 +276,17 @@ class a {
|
|
|
219
276
|
* - Order of parameters is ignored.
|
|
220
277
|
* - Wildcards are supported, meaning that `image/*` contains `image/png`
|
|
221
278
|
*/
|
|
222
|
-
contains(
|
|
223
|
-
const
|
|
224
|
-
if (!((this.type === "*" || this.type ===
|
|
279
|
+
contains(t) {
|
|
280
|
+
const e = typeof t == "string" ? a.parse({ mediaType: t }) : t;
|
|
281
|
+
if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
|
|
225
282
|
return !1;
|
|
226
283
|
const i = new Set(
|
|
227
284
|
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
|
|
228
|
-
),
|
|
229
|
-
Object.entries(
|
|
285
|
+
), r = new Set(
|
|
286
|
+
Object.entries(e.parameters).map(([n, o]) => `${n}=${o}`)
|
|
230
287
|
);
|
|
231
288
|
for (const n of Array.from(i.values()))
|
|
232
|
-
if (!
|
|
289
|
+
if (!r.has(n))
|
|
233
290
|
return !1;
|
|
234
291
|
return !0;
|
|
235
292
|
}
|
|
@@ -238,22 +295,22 @@ class a {
|
|
|
238
295
|
* For example, `text/html` matches `text/html;charset=utf-8`, but `text/html;charset=ascii`
|
|
239
296
|
* doesn't. This is basically like `contains`, but working in both direction.
|
|
240
297
|
*/
|
|
241
|
-
matches(
|
|
242
|
-
const
|
|
243
|
-
return this.contains(
|
|
298
|
+
matches(t) {
|
|
299
|
+
const e = typeof t == "string" ? a.parse({ mediaType: t }) : t;
|
|
300
|
+
return this.contains(e) || e.contains(this);
|
|
244
301
|
}
|
|
245
302
|
/**
|
|
246
303
|
* Returns whether this media type matches any of the [others] media types.
|
|
247
304
|
*/
|
|
248
|
-
matchesAny(...
|
|
249
|
-
for (const
|
|
250
|
-
if (this.matches(
|
|
305
|
+
matchesAny(...t) {
|
|
306
|
+
for (const e of t)
|
|
307
|
+
if (this.matches(e))
|
|
251
308
|
return !0;
|
|
252
309
|
return !1;
|
|
253
310
|
}
|
|
254
311
|
/** Checks the MediaType equals another one (comparing their string) */
|
|
255
|
-
equals(
|
|
256
|
-
return this.string ===
|
|
312
|
+
equals(t) {
|
|
313
|
+
return this.string === t.string;
|
|
257
314
|
}
|
|
258
315
|
/** Returns whether this media type is structured as a ZIP archive. */
|
|
259
316
|
get isZIP() {
|
|
@@ -616,80 +673,61 @@ class a {
|
|
|
616
673
|
});
|
|
617
674
|
}
|
|
618
675
|
}
|
|
619
|
-
class
|
|
620
|
-
constructor(
|
|
621
|
-
this.uri =
|
|
676
|
+
class Et {
|
|
677
|
+
constructor(t) {
|
|
678
|
+
this.uri = t, this.parameters = this.getParameters(t);
|
|
622
679
|
}
|
|
623
680
|
/**
|
|
624
681
|
* List of URI template parameter keys, if the [Link] is templated.
|
|
625
682
|
*/
|
|
626
|
-
getParameters(
|
|
627
|
-
const
|
|
683
|
+
getParameters(t) {
|
|
684
|
+
const e = /\{\??([^}]+)\}/g, i = t.match(e);
|
|
628
685
|
return i ? new Set(
|
|
629
|
-
i.join(",").replace(
|
|
686
|
+
i.join(",").replace(e, "$1").split(",").map((r) => r.trim())
|
|
630
687
|
) : /* @__PURE__ */ new Set();
|
|
631
688
|
}
|
|
632
689
|
/** Expands the URI by replacing the template variables by the given parameters.
|
|
633
690
|
* Any extra parameter is appended as query parameters.
|
|
634
691
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
635
692
|
*/
|
|
636
|
-
expand(
|
|
637
|
-
const
|
|
638
|
-
const o =
|
|
693
|
+
expand(t) {
|
|
694
|
+
const e = (r) => r.split(",").map((n) => {
|
|
695
|
+
const o = t[n];
|
|
639
696
|
return o ? encodeURIComponent(o) : "";
|
|
640
|
-
}).join(","), i = (
|
|
641
|
-
const o = n.split("=")[0], l =
|
|
697
|
+
}).join(","), i = (r) => "?" + r.split(",").map((n) => {
|
|
698
|
+
const o = n.split("=")[0], l = t[o];
|
|
642
699
|
return l ? `${o}=${encodeURIComponent(l)}` : "";
|
|
643
700
|
}).join("&");
|
|
644
|
-
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...
|
|
701
|
+
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...r) => r[1] ? i(r[2]) : e(r[2]));
|
|
645
702
|
}
|
|
646
703
|
}
|
|
647
|
-
|
|
648
|
-
return r && r instanceof Array ? r : void 0;
|
|
649
|
-
}
|
|
650
|
-
function We(r) {
|
|
651
|
-
return r && typeof r == "string" ? [r] : lt(r);
|
|
652
|
-
}
|
|
653
|
-
function ve(r) {
|
|
654
|
-
return typeof r == "string" ? new Date(r) : void 0;
|
|
655
|
-
}
|
|
656
|
-
function j(r) {
|
|
657
|
-
return isNaN(r) ? void 0 : r;
|
|
658
|
-
}
|
|
659
|
-
function C(r) {
|
|
660
|
-
return j(r) !== void 0 && Math.sign(r) >= 0 ? r : void 0;
|
|
661
|
-
}
|
|
662
|
-
function ht(r) {
|
|
663
|
-
const e = new Array();
|
|
664
|
-
return r.forEach((t) => e.push(t)), e;
|
|
665
|
-
}
|
|
666
|
-
class x {
|
|
704
|
+
class E {
|
|
667
705
|
/**
|
|
668
706
|
* Creates a [Locations].
|
|
669
707
|
*/
|
|
670
|
-
constructor(
|
|
671
|
-
this.fragments =
|
|
708
|
+
constructor(t) {
|
|
709
|
+
this.fragments = t.fragments ? t.fragments : new Array(), this.progression = t.progression, this.totalProgression = t.totalProgression, this.position = t.position, this.otherLocations = t.otherLocations;
|
|
672
710
|
}
|
|
673
711
|
/**
|
|
674
712
|
* Parses a [Locations] from its RWPM JSON representation.
|
|
675
713
|
*/
|
|
676
|
-
static deserialize(
|
|
677
|
-
if (!
|
|
714
|
+
static deserialize(t) {
|
|
715
|
+
if (!t)
|
|
678
716
|
return;
|
|
679
|
-
const
|
|
717
|
+
const e = q(t.progression), i = q(t.totalProgression), r = q(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
680
718
|
"fragment",
|
|
681
719
|
"fragments",
|
|
682
720
|
"progression",
|
|
683
721
|
"totalProgression",
|
|
684
722
|
"position"
|
|
685
723
|
]);
|
|
686
|
-
return Object.entries(
|
|
724
|
+
return Object.entries(t).forEach(([l, c]) => {
|
|
687
725
|
o.has(l) || n.set(l, c);
|
|
688
|
-
}), new
|
|
689
|
-
fragments:
|
|
690
|
-
progression:
|
|
726
|
+
}), new E({
|
|
727
|
+
fragments: Ut(t.fragments || t.fragment),
|
|
728
|
+
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
691
729
|
totalProgression: i !== void 0 && i >= 0 && i <= 1 ? i : void 0,
|
|
692
|
-
position:
|
|
730
|
+
position: r !== void 0 && r > 0 ? r : void 0,
|
|
693
731
|
otherLocations: n.size === 0 ? void 0 : n
|
|
694
732
|
});
|
|
695
733
|
}
|
|
@@ -697,110 +735,111 @@ class x {
|
|
|
697
735
|
* Serializes a [Locations] to its RWPM JSON representation.
|
|
698
736
|
*/
|
|
699
737
|
serialize() {
|
|
700
|
-
const
|
|
701
|
-
return this.fragments && (
|
|
738
|
+
const t = {};
|
|
739
|
+
return this.fragments && (t.fragments = this.fragments), this.progression !== void 0 && (t.progression = this.progression), this.totalProgression !== void 0 && (t.totalProgression = this.totalProgression), this.position !== void 0 && (t.position = this.position), this.otherLocations && this.otherLocations.forEach((e, i) => t[i] = e), t;
|
|
702
740
|
}
|
|
703
741
|
}
|
|
704
|
-
class
|
|
742
|
+
class $ {
|
|
705
743
|
/**
|
|
706
744
|
* Creates a [Text].
|
|
707
745
|
*/
|
|
708
|
-
constructor(
|
|
709
|
-
this.after =
|
|
746
|
+
constructor(t) {
|
|
747
|
+
this.after = t.after, this.before = t.before, this.highlight = t.highlight;
|
|
710
748
|
}
|
|
711
749
|
/**
|
|
712
750
|
* Parses a [Locations] from its RWPM JSON representation.
|
|
713
751
|
*/
|
|
714
|
-
static deserialize(
|
|
715
|
-
if (
|
|
716
|
-
return new
|
|
717
|
-
after:
|
|
718
|
-
before:
|
|
719
|
-
highlight:
|
|
752
|
+
static deserialize(t) {
|
|
753
|
+
if (t)
|
|
754
|
+
return new $({
|
|
755
|
+
after: t.after,
|
|
756
|
+
before: t.before,
|
|
757
|
+
highlight: t.highlight
|
|
720
758
|
});
|
|
721
759
|
}
|
|
722
760
|
/**
|
|
723
761
|
* Serializes a [Locations] to its RWPM JSON representation.
|
|
724
762
|
*/
|
|
725
763
|
serialize() {
|
|
726
|
-
const
|
|
727
|
-
return this.after !== void 0 && (
|
|
764
|
+
const t = {};
|
|
765
|
+
return this.after !== void 0 && (t.after = this.after), this.before !== void 0 && (t.before = this.before), this.highlight !== void 0 && (t.highlight = this.highlight), t;
|
|
728
766
|
}
|
|
729
767
|
}
|
|
730
|
-
class
|
|
768
|
+
class W {
|
|
731
769
|
/**
|
|
732
770
|
* Creates a [Locator].
|
|
733
771
|
*/
|
|
734
|
-
constructor(
|
|
735
|
-
this.href =
|
|
772
|
+
constructor(t) {
|
|
773
|
+
this.href = t.href, this.type = t.type, this.title = t.title, this.locations = t.locations ? t.locations : new E({}), this.text = t.text;
|
|
736
774
|
}
|
|
737
775
|
/**
|
|
738
776
|
* Parses a [Link] from its RWPM JSON representation.
|
|
739
777
|
*/
|
|
740
|
-
static deserialize(
|
|
741
|
-
if (
|
|
742
|
-
return new
|
|
743
|
-
href:
|
|
744
|
-
type:
|
|
745
|
-
title:
|
|
746
|
-
locations:
|
|
747
|
-
text:
|
|
778
|
+
static deserialize(t) {
|
|
779
|
+
if (t && t.href && t.type)
|
|
780
|
+
return new W({
|
|
781
|
+
href: t.href,
|
|
782
|
+
type: t.type,
|
|
783
|
+
title: t.title,
|
|
784
|
+
locations: E.deserialize(t.locations),
|
|
785
|
+
text: $.deserialize(t.text)
|
|
748
786
|
});
|
|
749
787
|
}
|
|
750
788
|
/**
|
|
751
789
|
* Serializes a [Link] to its RWPM JSON representation.
|
|
752
790
|
*/
|
|
753
791
|
serialize() {
|
|
754
|
-
const
|
|
755
|
-
return this.title !== void 0 && (
|
|
792
|
+
const t = { href: this.href, type: this.type };
|
|
793
|
+
return this.title !== void 0 && (t.title = this.title), this.locations && (t.locations = this.locations.serialize()), this.text && (t.text = this.text.serialize()), t;
|
|
756
794
|
}
|
|
757
795
|
/**
|
|
758
796
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
759
797
|
*/
|
|
760
|
-
copyWithLocations(
|
|
761
|
-
return new
|
|
798
|
+
copyWithLocations(t) {
|
|
799
|
+
return new W({
|
|
762
800
|
href: this.href,
|
|
763
801
|
type: this.type,
|
|
764
802
|
title: this.title,
|
|
765
803
|
text: this.text,
|
|
766
|
-
locations: new
|
|
804
|
+
locations: new E({ ...this.locations, ...t })
|
|
767
805
|
});
|
|
768
806
|
}
|
|
769
807
|
}
|
|
770
|
-
class
|
|
808
|
+
class k {
|
|
771
809
|
/**
|
|
772
810
|
* Creates a [Link].
|
|
773
811
|
*/
|
|
774
|
-
constructor(
|
|
775
|
-
this.href =
|
|
812
|
+
constructor(t) {
|
|
813
|
+
this.href = t.href, this.templated = t.templated, this.type = t.type, this.title = t.title, this.rels = t.rels, this.properties = t.properties, this.height = t.height, this.width = t.width, this.size = t.size, this.duration = t.duration, this.bitrate = t.bitrate, this.languages = t.languages, this.alternates = t.alternates, this.children = t.children;
|
|
776
814
|
}
|
|
777
815
|
/**
|
|
778
816
|
* Parses a [Link] from its RWPM JSON representation.
|
|
779
817
|
*/
|
|
780
|
-
static deserialize(
|
|
781
|
-
if (!(!
|
|
782
|
-
return new
|
|
783
|
-
href:
|
|
784
|
-
templated:
|
|
785
|
-
type:
|
|
786
|
-
title:
|
|
787
|
-
rels:
|
|
788
|
-
properties:
|
|
789
|
-
height:
|
|
790
|
-
width:
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
818
|
+
static deserialize(t) {
|
|
819
|
+
if (!(!t || typeof t.href != "string"))
|
|
820
|
+
return new k({
|
|
821
|
+
href: t.href,
|
|
822
|
+
templated: t.templated,
|
|
823
|
+
type: t.type,
|
|
824
|
+
title: t.title,
|
|
825
|
+
rels: t.rel ? t.rel instanceof Array ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
826
|
+
properties: w.deserialize(t.properties),
|
|
827
|
+
height: T(t.height),
|
|
828
|
+
width: T(t.width),
|
|
829
|
+
size: T(t.size),
|
|
830
|
+
duration: T(t.duration),
|
|
831
|
+
bitrate: T(t.bitrate),
|
|
832
|
+
languages: Ut(t.language),
|
|
833
|
+
alternates: _.deserialize(t.alternate),
|
|
834
|
+
children: _.deserialize(t.children)
|
|
796
835
|
});
|
|
797
836
|
}
|
|
798
837
|
/**
|
|
799
838
|
* Serializes a [Link] to its RWPM JSON representation.
|
|
800
839
|
*/
|
|
801
840
|
serialize() {
|
|
802
|
-
const
|
|
803
|
-
return this.templated !== void 0 && (
|
|
841
|
+
const t = { href: this.href };
|
|
842
|
+
return this.templated !== void 0 && (t.templated = this.templated), this.type !== void 0 && (t.type = this.type), this.title !== void 0 && (t.title = this.title), this.rels && (t.rel = ue(this.rels)), this.properties && (t.properties = this.properties.serialize()), this.height !== void 0 && (t.height = this.height), this.width !== void 0 && (t.width = this.width), this.size !== void 0 && (t.size = this.size), this.duration !== void 0 && (t.duration = this.duration), this.bitrate !== void 0 && (t.bitrate = this.bitrate), this.languages && (t.language = this.languages), this.alternates && (t.alternate = this.alternates.serialize()), this.children && (t.children = this.children.serialize()), t;
|
|
804
843
|
}
|
|
805
844
|
/** MediaType of the linked resource. */
|
|
806
845
|
get mediaType() {
|
|
@@ -809,163 +848,166 @@ class B {
|
|
|
809
848
|
/** Computes an absolute URL to the link, relative to the given `baseURL`.
|
|
810
849
|
* If the link's `href` is already absolute, the `baseURL` is ignored.
|
|
811
850
|
*/
|
|
812
|
-
toURL(
|
|
813
|
-
const
|
|
814
|
-
if (
|
|
851
|
+
toURL(t) {
|
|
852
|
+
const e = this.href.replace(/^(\/)/, "");
|
|
853
|
+
if (e.length === 0)
|
|
815
854
|
return;
|
|
816
|
-
let i =
|
|
817
|
-
return i.startsWith("/") && (i = "file://" + i), new URL(
|
|
855
|
+
let i = t || "/";
|
|
856
|
+
return i.startsWith("/") && (i = "file://" + i), new URL(e, i).href.replace(/^(file:\/\/)/, "");
|
|
818
857
|
}
|
|
819
858
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
820
859
|
get templateParameters() {
|
|
821
|
-
return this.templated ? new
|
|
860
|
+
return this.templated ? new Et(this.href).parameters : /* @__PURE__ */ new Set();
|
|
822
861
|
}
|
|
823
862
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
824
863
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
825
864
|
*/
|
|
826
|
-
expandTemplate(
|
|
827
|
-
return new
|
|
828
|
-
href: new
|
|
865
|
+
expandTemplate(t) {
|
|
866
|
+
return new k({
|
|
867
|
+
href: new Et(this.href).expand(t),
|
|
829
868
|
templated: !1
|
|
830
869
|
});
|
|
831
870
|
}
|
|
832
871
|
/**
|
|
833
872
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
834
873
|
*/
|
|
835
|
-
addProperties(
|
|
836
|
-
var
|
|
837
|
-
const i =
|
|
838
|
-
return i.properties = i.properties ? (
|
|
874
|
+
addProperties(t) {
|
|
875
|
+
var e;
|
|
876
|
+
const i = k.deserialize(this.serialize());
|
|
877
|
+
return i.properties = i.properties ? (e = i.properties) == null ? void 0 : e.add(t) : new w(t), i;
|
|
839
878
|
}
|
|
840
879
|
/**
|
|
841
880
|
* Creates a [Locator] from a reading order [Link].
|
|
842
881
|
*/
|
|
843
882
|
get locator() {
|
|
844
|
-
let
|
|
845
|
-
return new
|
|
846
|
-
href:
|
|
883
|
+
let t = this.href.split("#");
|
|
884
|
+
return new W({
|
|
885
|
+
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
|
|
847
886
|
type: this.type ?? "",
|
|
848
887
|
title: this.title,
|
|
849
|
-
locations: new
|
|
850
|
-
fragments:
|
|
888
|
+
locations: new E({
|
|
889
|
+
fragments: t.length > 1 && t[1] !== void 0 ? [t[1]] : []
|
|
851
890
|
})
|
|
852
891
|
});
|
|
853
892
|
}
|
|
854
893
|
}
|
|
855
|
-
class
|
|
894
|
+
class _ {
|
|
856
895
|
/**
|
|
857
896
|
* Creates a [Links].
|
|
858
897
|
*/
|
|
859
|
-
constructor(
|
|
860
|
-
this.items =
|
|
898
|
+
constructor(t) {
|
|
899
|
+
this.items = t;
|
|
861
900
|
}
|
|
862
901
|
/**
|
|
863
902
|
* Creates a list of [Link] from its RWPM JSON representation.
|
|
864
903
|
*/
|
|
865
|
-
static deserialize(
|
|
866
|
-
if (
|
|
867
|
-
return new
|
|
868
|
-
|
|
904
|
+
static deserialize(t) {
|
|
905
|
+
if (t && t instanceof Array)
|
|
906
|
+
return new _(
|
|
907
|
+
t.map((e) => k.deserialize(e)).filter((e) => e !== void 0)
|
|
869
908
|
);
|
|
870
909
|
}
|
|
871
910
|
/**
|
|
872
911
|
* Serializes an array of [Link] to its RWPM JSON representation.
|
|
873
912
|
*/
|
|
874
913
|
serialize() {
|
|
875
|
-
return this.items.map((
|
|
914
|
+
return this.items.map((t) => t.serialize());
|
|
876
915
|
}
|
|
877
916
|
/** Finds the first link with the given relation. */
|
|
878
|
-
findWithRel(
|
|
879
|
-
const
|
|
880
|
-
return this.items.find(
|
|
917
|
+
findWithRel(t) {
|
|
918
|
+
const e = (i) => i.rels && i.rels.has(t);
|
|
919
|
+
return this.items.find(e);
|
|
881
920
|
}
|
|
882
921
|
/** Finds all the links with the given relation. */
|
|
883
|
-
filterByRel(
|
|
884
|
-
const
|
|
885
|
-
return this.items.filter(
|
|
922
|
+
filterByRel(t) {
|
|
923
|
+
const e = (i) => i.rels && i.rels.has(t);
|
|
924
|
+
return this.items.filter(e);
|
|
886
925
|
}
|
|
887
926
|
/** Finds the first link matching the given HREF. */
|
|
888
|
-
findWithHref(
|
|
889
|
-
const
|
|
890
|
-
return this.items.find(
|
|
927
|
+
findWithHref(t) {
|
|
928
|
+
const e = (i) => i.href === t;
|
|
929
|
+
return this.items.find(e);
|
|
891
930
|
}
|
|
892
931
|
/** Finds the index of the first link matching the given HREF. */
|
|
893
|
-
findIndexWithHref(
|
|
894
|
-
const
|
|
895
|
-
return this.items.findIndex(
|
|
932
|
+
findIndexWithHref(t) {
|
|
933
|
+
const e = (i) => i.href === t;
|
|
934
|
+
return this.items.findIndex(e);
|
|
896
935
|
}
|
|
897
936
|
/** Finds the first link matching the given media type. */
|
|
898
|
-
findWithMediaType(
|
|
899
|
-
const
|
|
900
|
-
return this.items.find(
|
|
937
|
+
findWithMediaType(t) {
|
|
938
|
+
const e = (i) => i.mediaType.matches(t);
|
|
939
|
+
return this.items.find(e);
|
|
901
940
|
}
|
|
902
941
|
/** Finds all the links matching the given media type. */
|
|
903
|
-
filterByMediaType(
|
|
904
|
-
const
|
|
905
|
-
return this.items.filter(
|
|
942
|
+
filterByMediaType(t) {
|
|
943
|
+
const e = (i) => i.mediaType.matches(t);
|
|
944
|
+
return this.items.filter(e);
|
|
906
945
|
}
|
|
907
946
|
/** Finds all the links matching any of the given media types. */
|
|
908
|
-
filterByMediaTypes(
|
|
909
|
-
const
|
|
910
|
-
for (const
|
|
911
|
-
if (i.mediaType.matches(
|
|
947
|
+
filterByMediaTypes(t) {
|
|
948
|
+
const e = (i) => {
|
|
949
|
+
for (const r of t)
|
|
950
|
+
if (i.mediaType.matches(r))
|
|
912
951
|
return !0;
|
|
913
952
|
return !1;
|
|
914
953
|
};
|
|
915
|
-
return this.items.filter(
|
|
954
|
+
return this.items.filter(e);
|
|
916
955
|
}
|
|
917
956
|
/** Returns whether all the resources in the collection are audio clips. */
|
|
918
957
|
everyIsAudio() {
|
|
919
|
-
const
|
|
920
|
-
return this.items.length > 0 && this.items.every(
|
|
958
|
+
const t = (e) => e.mediaType.isAudio;
|
|
959
|
+
return this.items.length > 0 && this.items.every(t);
|
|
921
960
|
}
|
|
922
961
|
/** Returns whether all the resources in the collection are bitmaps. */
|
|
923
962
|
everyIsBitmap() {
|
|
924
|
-
const
|
|
925
|
-
return this.items.length > 0 && this.items.every(
|
|
963
|
+
const t = (e) => e.mediaType.isBitmap;
|
|
964
|
+
return this.items.length > 0 && this.items.every(t);
|
|
926
965
|
}
|
|
927
966
|
/** Returns whether all the resources in the collection are HTML documents. */
|
|
928
967
|
everyIsHTML() {
|
|
929
|
-
const
|
|
930
|
-
return this.items.length > 0 && this.items.every(
|
|
968
|
+
const t = (e) => e.mediaType.isHTML;
|
|
969
|
+
return this.items.length > 0 && this.items.every(t);
|
|
931
970
|
}
|
|
932
971
|
/** Returns whether all the resources in the collection are video clips. */
|
|
933
972
|
everyIsVideo() {
|
|
934
|
-
const
|
|
935
|
-
return this.items.length > 0 && this.items.every(
|
|
973
|
+
const t = (e) => e.mediaType.isVideo;
|
|
974
|
+
return this.items.length > 0 && this.items.every(t);
|
|
936
975
|
}
|
|
937
976
|
/** Returns whether all the resources in the collection are matching any of the given media types. */
|
|
938
|
-
everyMatchesMediaType(
|
|
939
|
-
return Array.isArray(
|
|
940
|
-
for (const i of
|
|
941
|
-
return
|
|
977
|
+
everyMatchesMediaType(t) {
|
|
978
|
+
return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
|
|
979
|
+
for (const i of t)
|
|
980
|
+
return e.mediaType.matches(i);
|
|
942
981
|
return !1;
|
|
943
|
-
}) : this.items.length > 0 && this.items.every((
|
|
982
|
+
}) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
|
|
944
983
|
}
|
|
945
984
|
filterLinksHasType() {
|
|
946
|
-
return this.items.filter((
|
|
985
|
+
return this.items.filter((t) => t.type);
|
|
947
986
|
}
|
|
948
987
|
}
|
|
949
|
-
|
|
988
|
+
w.prototype.getContains = function() {
|
|
989
|
+
return new Set(this.otherProperties.contains || []);
|
|
990
|
+
};
|
|
991
|
+
class X {
|
|
950
992
|
/**
|
|
951
993
|
* Creates a [DomRange].
|
|
952
994
|
*/
|
|
953
|
-
constructor(
|
|
954
|
-
this.cssSelector =
|
|
995
|
+
constructor(t) {
|
|
996
|
+
this.cssSelector = t.cssSelector, this.textNodeIndex = t.textNodeIndex, this.charOffset = t.charOffset;
|
|
955
997
|
}
|
|
956
998
|
/**
|
|
957
999
|
* Parses a [DomRangePoint] from its RWPM JSON representation.
|
|
958
1000
|
*/
|
|
959
|
-
static deserialize(
|
|
960
|
-
if (!(
|
|
1001
|
+
static deserialize(t) {
|
|
1002
|
+
if (!(t && t.cssSelector))
|
|
961
1003
|
return;
|
|
962
|
-
let
|
|
963
|
-
if (
|
|
1004
|
+
let e = T(t.textNodeIndex);
|
|
1005
|
+
if (e === void 0)
|
|
964
1006
|
return;
|
|
965
|
-
let i =
|
|
966
|
-
return i === void 0 && (i =
|
|
967
|
-
cssSelector:
|
|
968
|
-
textNodeIndex:
|
|
1007
|
+
let i = T(t.charOffset);
|
|
1008
|
+
return i === void 0 && (i = T(t.offset)), new X({
|
|
1009
|
+
cssSelector: t.cssSelector,
|
|
1010
|
+
textNodeIndex: e,
|
|
969
1011
|
charOffset: i
|
|
970
1012
|
});
|
|
971
1013
|
}
|
|
@@ -973,106 +1015,106 @@ class q {
|
|
|
973
1015
|
* Serializes a [DomRangePoint] to its RWPM JSON representation.
|
|
974
1016
|
*/
|
|
975
1017
|
serialize() {
|
|
976
|
-
const
|
|
1018
|
+
const t = {
|
|
977
1019
|
cssSelector: this.cssSelector,
|
|
978
1020
|
textNodeIndex: this.textNodeIndex
|
|
979
1021
|
};
|
|
980
|
-
return this.charOffset !== void 0 && (
|
|
1022
|
+
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
981
1023
|
}
|
|
982
1024
|
}
|
|
983
|
-
class
|
|
1025
|
+
class nt {
|
|
984
1026
|
/**
|
|
985
1027
|
* Creates a [DomRange].
|
|
986
1028
|
*/
|
|
987
|
-
constructor(
|
|
988
|
-
this.start =
|
|
1029
|
+
constructor(t) {
|
|
1030
|
+
this.start = t.start, this.end = t.end;
|
|
989
1031
|
}
|
|
990
1032
|
/**
|
|
991
1033
|
* Parses a [DomRange] from its RWPM JSON representation.
|
|
992
1034
|
*/
|
|
993
|
-
static deserialize(
|
|
994
|
-
if (!
|
|
1035
|
+
static deserialize(t) {
|
|
1036
|
+
if (!t)
|
|
995
1037
|
return;
|
|
996
|
-
let
|
|
997
|
-
if (
|
|
998
|
-
return new
|
|
999
|
-
start:
|
|
1000
|
-
end:
|
|
1038
|
+
let e = X.deserialize(t.start);
|
|
1039
|
+
if (e)
|
|
1040
|
+
return new nt({
|
|
1041
|
+
start: e,
|
|
1042
|
+
end: X.deserialize(t.end)
|
|
1001
1043
|
});
|
|
1002
1044
|
}
|
|
1003
1045
|
/**
|
|
1004
1046
|
* Serializes a [DomRange] to its RWPM JSON representation.
|
|
1005
1047
|
*/
|
|
1006
1048
|
serialize() {
|
|
1007
|
-
const
|
|
1008
|
-
return this.end && (
|
|
1049
|
+
const t = { start: this.start.serialize() };
|
|
1050
|
+
return this.end && (t.end = this.end.serialize()), t;
|
|
1009
1051
|
}
|
|
1010
1052
|
}
|
|
1011
|
-
|
|
1012
|
-
var
|
|
1013
|
-
return (
|
|
1053
|
+
E.prototype.getCssSelector = function() {
|
|
1054
|
+
var s;
|
|
1055
|
+
return (s = this.otherLocations) == null ? void 0 : s.get("cssSelector");
|
|
1014
1056
|
};
|
|
1015
|
-
|
|
1016
|
-
var
|
|
1017
|
-
return (
|
|
1057
|
+
E.prototype.getPartialCfi = function() {
|
|
1058
|
+
var s;
|
|
1059
|
+
return (s = this.otherLocations) == null ? void 0 : s.get("partialCfi");
|
|
1018
1060
|
};
|
|
1019
|
-
|
|
1020
|
-
var
|
|
1021
|
-
return
|
|
1061
|
+
E.prototype.getDomRange = function() {
|
|
1062
|
+
var s;
|
|
1063
|
+
return nt.deserialize((s = this.otherLocations) == null ? void 0 : s.get("domRange"));
|
|
1022
1064
|
};
|
|
1023
|
-
|
|
1065
|
+
E.prototype.fragmentParameters = function() {
|
|
1024
1066
|
return new Map(
|
|
1025
|
-
this.fragments.map((
|
|
1026
|
-
|
|
1027
|
-
|
|
1067
|
+
this.fragments.map((s) => s.startsWith("#") ? s.slice(1) : s).join("&").split("&").filter((s) => !s.startsWith("#")).map((s) => s.split("=")).filter((s) => s.length === 2).map((s) => [
|
|
1068
|
+
s[0].trim().toLowerCase(),
|
|
1069
|
+
s[1].trim()
|
|
1028
1070
|
])
|
|
1029
1071
|
);
|
|
1030
1072
|
};
|
|
1031
|
-
|
|
1073
|
+
E.prototype.htmlId = function() {
|
|
1032
1074
|
if (!this.fragments.length)
|
|
1033
1075
|
return;
|
|
1034
|
-
let
|
|
1035
|
-
if (!
|
|
1036
|
-
const
|
|
1037
|
-
|
|
1076
|
+
let s = this.fragments.find((t) => t.length && !t.includes("="));
|
|
1077
|
+
if (!s) {
|
|
1078
|
+
const t = this.fragmentParameters();
|
|
1079
|
+
t.has("id") ? s = t.get("id") : t.has("name") && (s = t.get("name"));
|
|
1038
1080
|
}
|
|
1039
|
-
return
|
|
1081
|
+
return s != null && s.startsWith("#") ? s.slice(1) : s;
|
|
1040
1082
|
};
|
|
1041
|
-
|
|
1042
|
-
const
|
|
1043
|
-
if (!isNaN(
|
|
1044
|
-
return
|
|
1083
|
+
E.prototype.page = function() {
|
|
1084
|
+
const s = parseInt(this.fragmentParameters().get("page"));
|
|
1085
|
+
if (!isNaN(s) && s >= 0)
|
|
1086
|
+
return s;
|
|
1045
1087
|
};
|
|
1046
|
-
|
|
1047
|
-
const
|
|
1048
|
-
if (!isNaN(
|
|
1049
|
-
return
|
|
1088
|
+
E.prototype.time = function() {
|
|
1089
|
+
const s = parseInt(this.fragmentParameters().get("t"));
|
|
1090
|
+
if (!isNaN(s))
|
|
1091
|
+
return s;
|
|
1050
1092
|
};
|
|
1051
|
-
|
|
1052
|
-
const
|
|
1053
|
-
if (!
|
|
1093
|
+
E.prototype.space = function() {
|
|
1094
|
+
const s = this.fragmentParameters();
|
|
1095
|
+
if (!s.has("xywh"))
|
|
1054
1096
|
return;
|
|
1055
|
-
const
|
|
1056
|
-
if (
|
|
1057
|
-
return
|
|
1097
|
+
const t = s.get("xywh").split(",").map((e) => parseInt(e));
|
|
1098
|
+
if (t.length === 4 && !t.some(isNaN))
|
|
1099
|
+
return t;
|
|
1058
1100
|
};
|
|
1059
|
-
class
|
|
1101
|
+
class ot {
|
|
1060
1102
|
/** Creates a [Price]. */
|
|
1061
|
-
constructor(
|
|
1062
|
-
this.currency =
|
|
1103
|
+
constructor(t) {
|
|
1104
|
+
this.currency = t.currency, this.value = t.value;
|
|
1063
1105
|
}
|
|
1064
1106
|
/**
|
|
1065
1107
|
* Parses a [Price] from its RWPM JSON representation.
|
|
1066
1108
|
*/
|
|
1067
|
-
static deserialize(
|
|
1068
|
-
if (!
|
|
1109
|
+
static deserialize(t) {
|
|
1110
|
+
if (!t)
|
|
1069
1111
|
return;
|
|
1070
|
-
let
|
|
1071
|
-
if (!(
|
|
1112
|
+
let e = t.currency;
|
|
1113
|
+
if (!(e && typeof e == "string" && e.length > 0))
|
|
1072
1114
|
return;
|
|
1073
|
-
let i =
|
|
1115
|
+
let i = T(t.value);
|
|
1074
1116
|
if (i !== void 0)
|
|
1075
|
-
return new
|
|
1117
|
+
return new ot({ currency: e, value: i });
|
|
1076
1118
|
}
|
|
1077
1119
|
/**
|
|
1078
1120
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1081,435 +1123,417 @@ class se {
|
|
|
1081
1123
|
return { currency: this.currency, value: this.value };
|
|
1082
1124
|
}
|
|
1083
1125
|
}
|
|
1084
|
-
class
|
|
1126
|
+
class V {
|
|
1085
1127
|
/** Creates a [Acquisition]. */
|
|
1086
|
-
constructor(
|
|
1087
|
-
this.type =
|
|
1128
|
+
constructor(t) {
|
|
1129
|
+
this.type = t.type, this.children = t.children;
|
|
1088
1130
|
}
|
|
1089
1131
|
/**
|
|
1090
1132
|
* Parses a [Acquisition] from its RWPM JSON representation.
|
|
1091
1133
|
*/
|
|
1092
|
-
static deserialize(
|
|
1093
|
-
if (
|
|
1094
|
-
return new
|
|
1095
|
-
type:
|
|
1096
|
-
children:
|
|
1134
|
+
static deserialize(t) {
|
|
1135
|
+
if (t && t.type)
|
|
1136
|
+
return new V({
|
|
1137
|
+
type: t.type,
|
|
1138
|
+
children: V.deserializeArray(t.children)
|
|
1097
1139
|
});
|
|
1098
1140
|
}
|
|
1099
|
-
static deserializeArray(
|
|
1100
|
-
if (
|
|
1101
|
-
return
|
|
1141
|
+
static deserializeArray(t) {
|
|
1142
|
+
if (t instanceof Array)
|
|
1143
|
+
return t.map((e) => V.deserialize(e)).filter((e) => e !== void 0);
|
|
1102
1144
|
}
|
|
1103
1145
|
/**
|
|
1104
1146
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
1105
1147
|
*/
|
|
1106
1148
|
serialize() {
|
|
1107
|
-
const
|
|
1108
|
-
return this.children && (
|
|
1149
|
+
const t = { type: this.type };
|
|
1150
|
+
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
|
|
1109
1151
|
}
|
|
1110
1152
|
}
|
|
1111
|
-
class
|
|
1153
|
+
class at {
|
|
1112
1154
|
/** Creates a [Price]. */
|
|
1113
|
-
constructor(
|
|
1114
|
-
this.total =
|
|
1155
|
+
constructor(t) {
|
|
1156
|
+
this.total = t.total, this.position = t.position;
|
|
1115
1157
|
}
|
|
1116
1158
|
/**
|
|
1117
1159
|
* Parses a [Holds] from its RWPM JSON representation.
|
|
1118
1160
|
*/
|
|
1119
|
-
static deserialize(
|
|
1120
|
-
if (
|
|
1121
|
-
return new
|
|
1122
|
-
total:
|
|
1123
|
-
position:
|
|
1161
|
+
static deserialize(t) {
|
|
1162
|
+
if (t)
|
|
1163
|
+
return new at({
|
|
1164
|
+
total: T(t.total),
|
|
1165
|
+
position: T(t.position)
|
|
1124
1166
|
});
|
|
1125
1167
|
}
|
|
1126
1168
|
/**
|
|
1127
1169
|
* Serializes a [Holds] to its RWPM JSON representation.
|
|
1128
1170
|
*/
|
|
1129
1171
|
serialize() {
|
|
1130
|
-
const
|
|
1131
|
-
return this.total !== void 0 && (
|
|
1172
|
+
const t = {};
|
|
1173
|
+
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
|
|
1132
1174
|
}
|
|
1133
1175
|
}
|
|
1134
|
-
class
|
|
1176
|
+
class lt {
|
|
1135
1177
|
/** Creates a [Copies]. */
|
|
1136
|
-
constructor(
|
|
1137
|
-
this.total =
|
|
1178
|
+
constructor(t) {
|
|
1179
|
+
this.total = t.total, this.available = t.available;
|
|
1138
1180
|
}
|
|
1139
1181
|
/**
|
|
1140
1182
|
* Parses a [Copies] from its RWPM JSON representation.
|
|
1141
1183
|
*/
|
|
1142
|
-
static deserialize(
|
|
1143
|
-
if (
|
|
1144
|
-
return new
|
|
1145
|
-
total:
|
|
1146
|
-
available:
|
|
1184
|
+
static deserialize(t) {
|
|
1185
|
+
if (t)
|
|
1186
|
+
return new lt({
|
|
1187
|
+
total: T(t.total),
|
|
1188
|
+
available: T(t.available)
|
|
1147
1189
|
});
|
|
1148
1190
|
}
|
|
1149
1191
|
/**
|
|
1150
1192
|
* Serializes a [Copies] to its RWPM JSON representation.
|
|
1151
1193
|
*/
|
|
1152
1194
|
serialize() {
|
|
1153
|
-
const
|
|
1154
|
-
return this.total !== void 0 && (
|
|
1195
|
+
const t = {};
|
|
1196
|
+
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
|
|
1155
1197
|
}
|
|
1156
1198
|
}
|
|
1157
|
-
class
|
|
1199
|
+
class ht {
|
|
1158
1200
|
/** Creates a [Availability]. */
|
|
1159
|
-
constructor(
|
|
1160
|
-
this.state =
|
|
1201
|
+
constructor(t) {
|
|
1202
|
+
this.state = t.state, this.since = t.since, this.until = t.until;
|
|
1161
1203
|
}
|
|
1162
1204
|
/**
|
|
1163
1205
|
* Parses a [Availability] from its RWPM JSON representation.
|
|
1164
1206
|
*/
|
|
1165
|
-
static deserialize(
|
|
1166
|
-
if (
|
|
1167
|
-
return new
|
|
1168
|
-
state:
|
|
1169
|
-
since:
|
|
1170
|
-
until:
|
|
1207
|
+
static deserialize(t) {
|
|
1208
|
+
if (t && t.state)
|
|
1209
|
+
return new ht({
|
|
1210
|
+
state: t.state,
|
|
1211
|
+
since: bt(t.since),
|
|
1212
|
+
until: bt(t.until)
|
|
1171
1213
|
});
|
|
1172
1214
|
}
|
|
1173
1215
|
/**
|
|
1174
1216
|
* Serializes a [Availability] to its RWPM JSON representation.
|
|
1175
1217
|
*/
|
|
1176
1218
|
serialize() {
|
|
1177
|
-
const
|
|
1178
|
-
return this.since !== void 0 && (
|
|
1219
|
+
const t = { state: this.state };
|
|
1220
|
+
return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
|
|
1179
1221
|
}
|
|
1180
1222
|
}
|
|
1181
|
-
|
|
1182
|
-
return
|
|
1183
|
-
};
|
|
1184
|
-
b.prototype.getPrice = function() {
|
|
1185
|
-
return se.deserialize(this.otherProperties.price);
|
|
1186
|
-
};
|
|
1187
|
-
b.prototype.getIndirectAcquisitions = function() {
|
|
1188
|
-
const r = this.otherProperties.indirectAcquisition;
|
|
1189
|
-
if (r && r instanceof Array)
|
|
1190
|
-
return r.map((e) => $.deserialize(e)).filter((e) => e !== void 0);
|
|
1191
|
-
};
|
|
1192
|
-
b.prototype.getHolds = function() {
|
|
1193
|
-
return ne.deserialize(this.otherProperties.holds);
|
|
1223
|
+
w.prototype.getNumberOfItems = function() {
|
|
1224
|
+
return T(this.otherProperties.numberOfItems);
|
|
1194
1225
|
};
|
|
1195
|
-
|
|
1196
|
-
return
|
|
1226
|
+
w.prototype.getPrice = function() {
|
|
1227
|
+
return ot.deserialize(this.otherProperties.price);
|
|
1197
1228
|
};
|
|
1198
|
-
|
|
1199
|
-
|
|
1229
|
+
w.prototype.getIndirectAcquisitions = function() {
|
|
1230
|
+
const s = this.otherProperties.indirectAcquisition;
|
|
1231
|
+
if (s && s instanceof Array)
|
|
1232
|
+
return s.map((t) => V.deserialize(t)).filter((t) => t !== void 0);
|
|
1200
1233
|
};
|
|
1201
|
-
|
|
1202
|
-
return
|
|
1234
|
+
w.prototype.getHolds = function() {
|
|
1235
|
+
return at.deserialize(this.otherProperties.holds);
|
|
1203
1236
|
};
|
|
1204
|
-
|
|
1205
|
-
return this.otherProperties.
|
|
1237
|
+
w.prototype.getCopies = function() {
|
|
1238
|
+
return lt.deserialize(this.otherProperties.copies);
|
|
1206
1239
|
};
|
|
1207
|
-
|
|
1208
|
-
return this.otherProperties.
|
|
1240
|
+
w.prototype.getAvailability = function() {
|
|
1241
|
+
return ht.deserialize(this.otherProperties.availability);
|
|
1209
1242
|
};
|
|
1210
|
-
|
|
1211
|
-
return this.otherProperties.
|
|
1243
|
+
w.prototype.getAuthenticate = function() {
|
|
1244
|
+
return k.deserialize(this.otherProperties.authenticate);
|
|
1212
1245
|
};
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
(
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
}
|
|
1238
|
-
function dt(r) {
|
|
1239
|
-
return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1240
|
-
}
|
|
1241
|
-
function pt(r) {
|
|
1242
|
-
const e = r.map((t) => {
|
|
1243
|
-
if (ut(t))
|
|
1244
|
-
return (i) => t.test(i);
|
|
1245
|
-
if (typeof t == "function")
|
|
1246
|
+
var z;
|
|
1247
|
+
(function(s) {
|
|
1248
|
+
s.NONE = "none", s.DESCENDANT = "descendant", s.CHILD = "child";
|
|
1249
|
+
})(z || (z = {}));
|
|
1250
|
+
var M;
|
|
1251
|
+
(function(s) {
|
|
1252
|
+
s.id = "id", s.class = "class", s.tag = "tag", s.attribute = "attribute", s.nthchild = "nthchild", s.nthoftype = "nthoftype";
|
|
1253
|
+
})(M || (M = {}));
|
|
1254
|
+
const de = "CssSelectorGenerator";
|
|
1255
|
+
function xt(s = "unknown problem", ...t) {
|
|
1256
|
+
console.warn(`${de}: ${s}`, ...t);
|
|
1257
|
+
}
|
|
1258
|
+
M.id, M.class, M.tag, M.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
|
|
1259
|
+
function pe(s) {
|
|
1260
|
+
return s instanceof RegExp;
|
|
1261
|
+
}
|
|
1262
|
+
function fe(s) {
|
|
1263
|
+
return s.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
1264
|
+
}
|
|
1265
|
+
function me(s) {
|
|
1266
|
+
const t = s.map((e) => {
|
|
1267
|
+
if (pe(e))
|
|
1268
|
+
return (i) => e.test(i);
|
|
1269
|
+
if (typeof e == "function")
|
|
1246
1270
|
return (i) => {
|
|
1247
|
-
const
|
|
1248
|
-
return typeof
|
|
1271
|
+
const r = e(i);
|
|
1272
|
+
return typeof r != "boolean" ? (xt("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : r;
|
|
1249
1273
|
};
|
|
1250
|
-
if (typeof
|
|
1251
|
-
const i = new RegExp("^" +
|
|
1252
|
-
return (
|
|
1274
|
+
if (typeof e == "string") {
|
|
1275
|
+
const i = new RegExp("^" + fe(e) + "$");
|
|
1276
|
+
return (r) => i.test(r);
|
|
1253
1277
|
}
|
|
1254
|
-
return
|
|
1278
|
+
return xt("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
1255
1279
|
});
|
|
1256
|
-
return (
|
|
1280
|
+
return (e) => t.some((i) => i(e));
|
|
1257
1281
|
}
|
|
1258
|
-
const
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1282
|
+
const ge = "", ye = " > ", ve = " ";
|
|
1283
|
+
z.NONE + "", z.NONE, z.DESCENDANT + "", z.DESCENDANT, z.CHILD + "", z.CHILD;
|
|
1284
|
+
M.nthoftype, M.tag, M.id, M.class, M.attribute, M.nthchild;
|
|
1285
|
+
me([
|
|
1262
1286
|
"class",
|
|
1263
1287
|
"id",
|
|
1264
1288
|
// Angular attributes
|
|
1265
1289
|
"ng-*"
|
|
1266
1290
|
]);
|
|
1267
|
-
class
|
|
1291
|
+
class K {
|
|
1268
1292
|
}
|
|
1269
|
-
function
|
|
1270
|
-
return
|
|
1293
|
+
function St(s) {
|
|
1294
|
+
return s.split("").reverse().join("");
|
|
1271
1295
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const i =
|
|
1274
|
-
return
|
|
1275
|
-
const n = Math.max(0,
|
|
1296
|
+
function be(s, t, e) {
|
|
1297
|
+
const i = St(t);
|
|
1298
|
+
return e.map((r) => {
|
|
1299
|
+
const n = Math.max(0, r.end - t.length - r.errors), o = St(s.slice(n, r.end));
|
|
1276
1300
|
return {
|
|
1277
|
-
start:
|
|
1278
|
-
end:
|
|
1279
|
-
errors:
|
|
1301
|
+
start: Bt(o, i, r.errors).reduce((c, h) => r.end - h.end < c ? r.end - h.end : c, r.end),
|
|
1302
|
+
end: r.end,
|
|
1303
|
+
errors: r.errors
|
|
1280
1304
|
};
|
|
1281
1305
|
});
|
|
1282
1306
|
}
|
|
1283
|
-
function
|
|
1284
|
-
return (
|
|
1307
|
+
function Q(s) {
|
|
1308
|
+
return (s | -s) >> 31 & 1;
|
|
1285
1309
|
}
|
|
1286
|
-
function
|
|
1287
|
-
let
|
|
1288
|
-
const o = i >>> 31, l = e
|
|
1289
|
-
let u = n | ~(h |
|
|
1290
|
-
const d =
|
|
1291
|
-
return u <<= 1, p <<= 1, p |= o, u |=
|
|
1310
|
+
function Tt(s, t, e, i) {
|
|
1311
|
+
let r = s.P[e], n = s.M[e];
|
|
1312
|
+
const o = i >>> 31, l = t[e] | o, c = l | n, h = (l & r) + r ^ r | l;
|
|
1313
|
+
let u = n | ~(h | r), p = r & h;
|
|
1314
|
+
const d = Q(u & s.lastRowMask[e]) - Q(p & s.lastRowMask[e]);
|
|
1315
|
+
return u <<= 1, p <<= 1, p |= o, u |= Q(i) - o, r = p | ~(c | u), n = u & c, s.P[e] = r, s.M[e] = n, d;
|
|
1292
1316
|
}
|
|
1293
|
-
function
|
|
1294
|
-
if (
|
|
1317
|
+
function Bt(s, t, e) {
|
|
1318
|
+
if (t.length === 0)
|
|
1295
1319
|
return [];
|
|
1296
|
-
|
|
1297
|
-
const i = [],
|
|
1320
|
+
e = Math.min(e, t.length);
|
|
1321
|
+
const i = [], r = 32, n = Math.ceil(t.length / r) - 1, o = {
|
|
1298
1322
|
P: new Uint32Array(n + 1),
|
|
1299
1323
|
M: new Uint32Array(n + 1),
|
|
1300
1324
|
lastRowMask: new Uint32Array(n + 1)
|
|
1301
1325
|
};
|
|
1302
|
-
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (
|
|
1326
|
+
o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (t.length - 1) % r;
|
|
1303
1327
|
const l = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), h = [];
|
|
1304
1328
|
for (let d = 0; d < 256; d++)
|
|
1305
1329
|
h.push(l);
|
|
1306
|
-
for (let d = 0; d <
|
|
1307
|
-
const f =
|
|
1330
|
+
for (let d = 0; d < t.length; d += 1) {
|
|
1331
|
+
const f = t.charCodeAt(d);
|
|
1308
1332
|
if (c.has(f))
|
|
1309
1333
|
continue;
|
|
1310
1334
|
const g = new Uint32Array(n + 1);
|
|
1311
1335
|
c.set(f, g), f < h.length && (h[f] = g);
|
|
1312
1336
|
for (let m = 0; m <= n; m += 1) {
|
|
1313
1337
|
g[m] = 0;
|
|
1314
|
-
for (let v = 0; v <
|
|
1315
|
-
const
|
|
1316
|
-
if (
|
|
1338
|
+
for (let v = 0; v < r; v += 1) {
|
|
1339
|
+
const x = m * r + v;
|
|
1340
|
+
if (x >= t.length)
|
|
1317
1341
|
continue;
|
|
1318
|
-
|
|
1342
|
+
t.charCodeAt(x) === f && (g[m] |= 1 << v);
|
|
1319
1343
|
}
|
|
1320
1344
|
}
|
|
1321
1345
|
}
|
|
1322
|
-
let u = Math.max(0, Math.ceil(
|
|
1346
|
+
let u = Math.max(0, Math.ceil(e / r) - 1);
|
|
1323
1347
|
const p = new Uint32Array(n + 1);
|
|
1324
1348
|
for (let d = 0; d <= u; d += 1)
|
|
1325
|
-
p[d] = (d + 1) *
|
|
1326
|
-
p[n] =
|
|
1349
|
+
p[d] = (d + 1) * r;
|
|
1350
|
+
p[n] = t.length;
|
|
1327
1351
|
for (let d = 0; d <= u; d += 1)
|
|
1328
1352
|
o.P[d] = -1, o.M[d] = 0;
|
|
1329
|
-
for (let d = 0; d <
|
|
1330
|
-
const f =
|
|
1353
|
+
for (let d = 0; d < s.length; d += 1) {
|
|
1354
|
+
const f = s.charCodeAt(d);
|
|
1331
1355
|
let g;
|
|
1332
1356
|
f < h.length ? g = h[f] : (g = c.get(f), typeof g > "u" && (g = l));
|
|
1333
1357
|
let m = 0;
|
|
1334
1358
|
for (let v = 0; v <= u; v += 1)
|
|
1335
|
-
m =
|
|
1336
|
-
if (p[u] - m <=
|
|
1359
|
+
m = Tt(o, g, v, m), p[v] += m;
|
|
1360
|
+
if (p[u] - m <= e && u < n && (g[u + 1] & 1 || m < 0)) {
|
|
1337
1361
|
u += 1, o.P[u] = -1, o.M[u] = 0;
|
|
1338
1362
|
let v;
|
|
1339
1363
|
if (u === n) {
|
|
1340
|
-
const
|
|
1341
|
-
v =
|
|
1364
|
+
const x = t.length % r;
|
|
1365
|
+
v = x === 0 ? r : x;
|
|
1342
1366
|
} else
|
|
1343
|
-
v =
|
|
1344
|
-
p[u] = p[u - 1] + v - m +
|
|
1367
|
+
v = r;
|
|
1368
|
+
p[u] = p[u - 1] + v - m + Tt(o, g, u, m);
|
|
1345
1369
|
} else
|
|
1346
|
-
for (; u > 0 && p[u] >=
|
|
1370
|
+
for (; u > 0 && p[u] >= e + r; )
|
|
1347
1371
|
u -= 1;
|
|
1348
|
-
u === n && p[u] <=
|
|
1372
|
+
u === n && p[u] <= e && (p[u] < e && i.splice(0, i.length), i.push({
|
|
1349
1373
|
start: -1,
|
|
1350
1374
|
end: d + 1,
|
|
1351
1375
|
errors: p[u]
|
|
1352
|
-
}),
|
|
1376
|
+
}), e = p[u]);
|
|
1353
1377
|
}
|
|
1354
1378
|
return i;
|
|
1355
1379
|
}
|
|
1356
|
-
function
|
|
1357
|
-
const i =
|
|
1358
|
-
return
|
|
1380
|
+
function Ee(s, t, e) {
|
|
1381
|
+
const i = Bt(s, t, e);
|
|
1382
|
+
return be(s, t, i);
|
|
1359
1383
|
}
|
|
1360
|
-
function
|
|
1384
|
+
function kt(s, t, e) {
|
|
1361
1385
|
let i = 0;
|
|
1362
|
-
const
|
|
1386
|
+
const r = [];
|
|
1363
1387
|
for (; i !== -1; )
|
|
1364
|
-
i =
|
|
1388
|
+
i = s.indexOf(t, i), i !== -1 && (r.push({
|
|
1365
1389
|
start: i,
|
|
1366
|
-
end: i +
|
|
1390
|
+
end: i + t.length,
|
|
1367
1391
|
errors: 0
|
|
1368
1392
|
}), i += 1);
|
|
1369
|
-
return
|
|
1393
|
+
return r.length > 0 ? r : Ee(s, t, e);
|
|
1370
1394
|
}
|
|
1371
|
-
function
|
|
1372
|
-
return
|
|
1395
|
+
function wt(s, t) {
|
|
1396
|
+
return t.length === 0 || s.length === 0 ? 0 : 1 - kt(s, t, t.length)[0].errors / t.length;
|
|
1373
1397
|
}
|
|
1374
|
-
function
|
|
1375
|
-
if (
|
|
1398
|
+
function xe(s, t, e = {}) {
|
|
1399
|
+
if (t.length === 0)
|
|
1376
1400
|
return null;
|
|
1377
|
-
const i = Math.min(256,
|
|
1378
|
-
if (
|
|
1401
|
+
const i = Math.min(256, t.length / 2), r = kt(s, t, i);
|
|
1402
|
+
if (r.length === 0)
|
|
1379
1403
|
return null;
|
|
1380
1404
|
const n = (l) => {
|
|
1381
|
-
const d = 1 - l.errors /
|
|
1382
|
-
|
|
1383
|
-
Math.max(0, l.start -
|
|
1405
|
+
const d = 1 - l.errors / t.length, f = e.prefix ? wt(
|
|
1406
|
+
s.slice(
|
|
1407
|
+
Math.max(0, l.start - e.prefix.length),
|
|
1384
1408
|
l.start
|
|
1385
1409
|
),
|
|
1386
|
-
|
|
1387
|
-
) : 1, g =
|
|
1388
|
-
|
|
1389
|
-
|
|
1410
|
+
e.prefix
|
|
1411
|
+
) : 1, g = e.suffix ? wt(
|
|
1412
|
+
s.slice(l.end, l.end + e.suffix.length),
|
|
1413
|
+
e.suffix
|
|
1390
1414
|
) : 1;
|
|
1391
1415
|
let m = 1;
|
|
1392
|
-
typeof
|
|
1393
|
-
const v = 50 * d + 20 * f + 20 * g + 2 * m,
|
|
1394
|
-
return v /
|
|
1395
|
-
}, o =
|
|
1416
|
+
typeof e.hint == "number" && (m = 1 - Math.abs(l.start - e.hint) / s.length);
|
|
1417
|
+
const v = 50 * d + 20 * f + 20 * g + 2 * m, x = 50 + 20 + 20 + 2;
|
|
1418
|
+
return v / x;
|
|
1419
|
+
}, o = r.map((l) => ({
|
|
1396
1420
|
start: l.start,
|
|
1397
1421
|
end: l.end,
|
|
1398
1422
|
score: n(l)
|
|
1399
1423
|
}));
|
|
1400
1424
|
return o.sort((l, c) => c.score - l.score), o[0];
|
|
1401
1425
|
}
|
|
1402
|
-
function
|
|
1403
|
-
const i =
|
|
1404
|
-
if (
|
|
1405
|
-
return
|
|
1406
|
-
let
|
|
1407
|
-
if (
|
|
1426
|
+
function tt(s, t, e) {
|
|
1427
|
+
const i = e === 1 ? t : t - 1;
|
|
1428
|
+
if (s.charAt(i).trim() !== "")
|
|
1429
|
+
return t;
|
|
1430
|
+
let r, n;
|
|
1431
|
+
if (e === 2 ? (r = s.substring(0, t), n = r.trimEnd()) : (r = s.substring(t), n = r.trimStart()), !n.length)
|
|
1408
1432
|
return -1;
|
|
1409
|
-
const o =
|
|
1410
|
-
return
|
|
1433
|
+
const o = r.length - n.length;
|
|
1434
|
+
return e === 2 ? t - o : t + o;
|
|
1411
1435
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const
|
|
1414
|
-
|
|
1436
|
+
function Ct(s, t) {
|
|
1437
|
+
const e = s.commonAncestorContainer.ownerDocument.createNodeIterator(
|
|
1438
|
+
s.commonAncestorContainer,
|
|
1415
1439
|
NodeFilter.SHOW_TEXT
|
|
1416
|
-
), i =
|
|
1417
|
-
let n =
|
|
1440
|
+
), i = t === 1 ? s.startContainer : s.endContainer, r = t === 1 ? s.endContainer : s.startContainer;
|
|
1441
|
+
let n = e.nextNode();
|
|
1418
1442
|
for (; n && n !== i; )
|
|
1419
|
-
n =
|
|
1420
|
-
|
|
1443
|
+
n = e.nextNode();
|
|
1444
|
+
t === 2 && (n = e.previousNode());
|
|
1421
1445
|
let o = -1;
|
|
1422
1446
|
const l = () => {
|
|
1423
|
-
if (n =
|
|
1424
|
-
const c = n.textContent, h =
|
|
1425
|
-
o =
|
|
1447
|
+
if (n = t === 1 ? e.nextNode() : e.previousNode(), n) {
|
|
1448
|
+
const c = n.textContent, h = t === 1 ? 0 : c.length;
|
|
1449
|
+
o = tt(c, h, t);
|
|
1426
1450
|
}
|
|
1427
1451
|
};
|
|
1428
|
-
for (; n && o === -1 && n !==
|
|
1452
|
+
for (; n && o === -1 && n !== r; )
|
|
1429
1453
|
l();
|
|
1430
1454
|
if (n && o >= 0)
|
|
1431
1455
|
return { node: n, offset: o };
|
|
1432
1456
|
throw new RangeError("No text nodes with non-whitespace text found in range");
|
|
1433
1457
|
}
|
|
1434
|
-
function
|
|
1435
|
-
if (!
|
|
1458
|
+
function Se(s) {
|
|
1459
|
+
if (!s.toString().trim().length)
|
|
1436
1460
|
throw new RangeError("Range contains no non-whitespace text");
|
|
1437
|
-
if (
|
|
1461
|
+
if (s.startContainer.nodeType !== Node.TEXT_NODE)
|
|
1438
1462
|
throw new RangeError("Range startContainer is not a text node");
|
|
1439
|
-
if (
|
|
1463
|
+
if (s.endContainer.nodeType !== Node.TEXT_NODE)
|
|
1440
1464
|
throw new RangeError("Range endContainer is not a text node");
|
|
1441
|
-
const
|
|
1442
|
-
let
|
|
1443
|
-
const
|
|
1444
|
-
start:
|
|
1445
|
-
|
|
1446
|
-
|
|
1465
|
+
const t = s.cloneRange();
|
|
1466
|
+
let e = !1, i = !1;
|
|
1467
|
+
const r = {
|
|
1468
|
+
start: tt(
|
|
1469
|
+
s.startContainer.textContent,
|
|
1470
|
+
s.startOffset,
|
|
1447
1471
|
1
|
|
1448
1472
|
/* Forwards */
|
|
1449
1473
|
),
|
|
1450
|
-
end:
|
|
1451
|
-
|
|
1452
|
-
|
|
1474
|
+
end: tt(
|
|
1475
|
+
s.endContainer.textContent,
|
|
1476
|
+
s.endOffset,
|
|
1453
1477
|
2
|
|
1454
1478
|
/* Backwards */
|
|
1455
1479
|
)
|
|
1456
1480
|
};
|
|
1457
|
-
if (
|
|
1458
|
-
return
|
|
1459
|
-
if (!
|
|
1460
|
-
const { node: n, offset: o } =
|
|
1461
|
-
|
|
1481
|
+
if (r.start >= 0 && (t.setStart(s.startContainer, r.start), e = !0), r.end > 0 && (t.setEnd(s.endContainer, r.end), i = !0), e && i)
|
|
1482
|
+
return t;
|
|
1483
|
+
if (!e) {
|
|
1484
|
+
const { node: n, offset: o } = Ct(
|
|
1485
|
+
t,
|
|
1462
1486
|
1
|
|
1463
1487
|
/* Forwards */
|
|
1464
1488
|
);
|
|
1465
|
-
n && o >= 0 &&
|
|
1489
|
+
n && o >= 0 && t.setStart(n, o);
|
|
1466
1490
|
}
|
|
1467
1491
|
if (!i) {
|
|
1468
|
-
const { node: n, offset: o } =
|
|
1469
|
-
|
|
1492
|
+
const { node: n, offset: o } = Ct(
|
|
1493
|
+
t,
|
|
1470
1494
|
2
|
|
1471
1495
|
/* Backwards */
|
|
1472
1496
|
);
|
|
1473
|
-
n && o > 0 &&
|
|
1497
|
+
n && o > 0 && t.setEnd(n, o);
|
|
1474
1498
|
}
|
|
1475
|
-
return
|
|
1499
|
+
return t;
|
|
1476
1500
|
}
|
|
1477
|
-
function
|
|
1478
|
-
var
|
|
1479
|
-
switch (
|
|
1501
|
+
function $t(s) {
|
|
1502
|
+
var t;
|
|
1503
|
+
switch (s.nodeType) {
|
|
1480
1504
|
case Node.ELEMENT_NODE:
|
|
1481
1505
|
case Node.TEXT_NODE:
|
|
1482
|
-
return ((
|
|
1506
|
+
return ((t = s.textContent) == null ? void 0 : t.length) ?? 0;
|
|
1483
1507
|
default:
|
|
1484
1508
|
return 0;
|
|
1485
1509
|
}
|
|
1486
1510
|
}
|
|
1487
|
-
function
|
|
1488
|
-
let
|
|
1489
|
-
for (;
|
|
1490
|
-
|
|
1491
|
-
return
|
|
1511
|
+
function Pt(s) {
|
|
1512
|
+
let t = s.previousSibling, e = 0;
|
|
1513
|
+
for (; t; )
|
|
1514
|
+
e += $t(t), t = t.previousSibling;
|
|
1515
|
+
return e;
|
|
1492
1516
|
}
|
|
1493
|
-
function
|
|
1494
|
-
let
|
|
1495
|
-
const i =
|
|
1496
|
-
|
|
1517
|
+
function Ht(s, ...t) {
|
|
1518
|
+
let e = t.shift();
|
|
1519
|
+
const i = s.ownerDocument.createNodeIterator(
|
|
1520
|
+
s,
|
|
1497
1521
|
NodeFilter.SHOW_TEXT
|
|
1498
|
-
),
|
|
1522
|
+
), r = [];
|
|
1499
1523
|
let n = i.nextNode(), o, l = 0;
|
|
1500
|
-
for (;
|
|
1501
|
-
o = n, l + o.data.length >
|
|
1502
|
-
for (;
|
|
1503
|
-
|
|
1504
|
-
if (
|
|
1524
|
+
for (; e !== void 0 && n; )
|
|
1525
|
+
o = n, l + o.data.length > e ? (r.push({ node: o, offset: e - l }), e = t.shift()) : (n = i.nextNode(), l += o.data.length);
|
|
1526
|
+
for (; e !== void 0 && o && l === e; )
|
|
1527
|
+
r.push({ node: o, offset: o.data.length }), e = t.shift();
|
|
1528
|
+
if (e !== void 0)
|
|
1505
1529
|
throw new RangeError("Offset exceeds text length");
|
|
1506
|
-
return
|
|
1530
|
+
return r;
|
|
1507
1531
|
}
|
|
1508
1532
|
class A {
|
|
1509
|
-
constructor(
|
|
1510
|
-
if (
|
|
1533
|
+
constructor(t, e) {
|
|
1534
|
+
if (e < 0)
|
|
1511
1535
|
throw new Error("Offset is invalid");
|
|
1512
|
-
this.element =
|
|
1536
|
+
this.element = t, this.offset = e;
|
|
1513
1537
|
}
|
|
1514
1538
|
/**
|
|
1515
1539
|
* Return a copy of this position with offset relative to a given ancestor
|
|
@@ -1517,13 +1541,13 @@ class A {
|
|
|
1517
1541
|
*
|
|
1518
1542
|
* @param parent - Ancestor of `this.element`
|
|
1519
1543
|
*/
|
|
1520
|
-
relativeTo(
|
|
1521
|
-
if (!
|
|
1544
|
+
relativeTo(t) {
|
|
1545
|
+
if (!t.contains(this.element))
|
|
1522
1546
|
throw new Error("Parent is not an ancestor of current element");
|
|
1523
|
-
let
|
|
1524
|
-
for (;
|
|
1525
|
-
i +=
|
|
1526
|
-
return new A(
|
|
1547
|
+
let e = this.element, i = this.offset;
|
|
1548
|
+
for (; e !== t; )
|
|
1549
|
+
i += Pt(e), e = e.parentElement;
|
|
1550
|
+
return new A(e, i);
|
|
1527
1551
|
}
|
|
1528
1552
|
/**
|
|
1529
1553
|
* Resolve the position to a specific text node and offset within that node.
|
|
@@ -1542,34 +1566,34 @@ class A {
|
|
|
1542
1566
|
*
|
|
1543
1567
|
* @throws {RangeError}
|
|
1544
1568
|
*/
|
|
1545
|
-
resolve(
|
|
1569
|
+
resolve(t = {}) {
|
|
1546
1570
|
try {
|
|
1547
|
-
return
|
|
1548
|
-
} catch (
|
|
1549
|
-
if (this.offset === 0 &&
|
|
1571
|
+
return Ht(this.element, this.offset)[0];
|
|
1572
|
+
} catch (e) {
|
|
1573
|
+
if (this.offset === 0 && t.direction !== void 0) {
|
|
1550
1574
|
const i = document.createTreeWalker(
|
|
1551
1575
|
this.element.getRootNode(),
|
|
1552
1576
|
NodeFilter.SHOW_TEXT
|
|
1553
1577
|
);
|
|
1554
1578
|
i.currentNode = this.element;
|
|
1555
|
-
const
|
|
1579
|
+
const r = t.direction === 1, n = r ? i.nextNode() : i.previousNode();
|
|
1556
1580
|
if (!n)
|
|
1557
|
-
throw
|
|
1558
|
-
return { node: n, offset:
|
|
1581
|
+
throw e;
|
|
1582
|
+
return { node: n, offset: r ? 0 : n.data.length };
|
|
1559
1583
|
} else
|
|
1560
|
-
throw
|
|
1584
|
+
throw e;
|
|
1561
1585
|
}
|
|
1562
1586
|
}
|
|
1563
1587
|
/**
|
|
1564
1588
|
* Construct a `TextPosition` that refers to the `offset`th character within
|
|
1565
1589
|
* `node`.
|
|
1566
1590
|
*/
|
|
1567
|
-
static fromCharOffset(
|
|
1568
|
-
switch (
|
|
1591
|
+
static fromCharOffset(t, e) {
|
|
1592
|
+
switch (t.nodeType) {
|
|
1569
1593
|
case Node.TEXT_NODE:
|
|
1570
|
-
return A.fromPoint(
|
|
1594
|
+
return A.fromPoint(t, e);
|
|
1571
1595
|
case Node.ELEMENT_NODE:
|
|
1572
|
-
return new A(
|
|
1596
|
+
return new A(t, e);
|
|
1573
1597
|
default:
|
|
1574
1598
|
throw new Error("Node is not an element or text node");
|
|
1575
1599
|
}
|
|
@@ -1580,42 +1604,42 @@ class A {
|
|
|
1580
1604
|
* @param node
|
|
1581
1605
|
* @param offset - Offset within the node
|
|
1582
1606
|
*/
|
|
1583
|
-
static fromPoint(
|
|
1584
|
-
switch (
|
|
1607
|
+
static fromPoint(t, e) {
|
|
1608
|
+
switch (t.nodeType) {
|
|
1585
1609
|
case Node.TEXT_NODE: {
|
|
1586
|
-
if (
|
|
1610
|
+
if (e < 0 || e > t.data.length)
|
|
1587
1611
|
throw new Error("Text node offset is out of range");
|
|
1588
|
-
if (!
|
|
1612
|
+
if (!t.parentElement)
|
|
1589
1613
|
throw new Error("Text node has no parent");
|
|
1590
|
-
const i =
|
|
1591
|
-
return new A(
|
|
1614
|
+
const i = Pt(t) + e;
|
|
1615
|
+
return new A(t.parentElement, i);
|
|
1592
1616
|
}
|
|
1593
1617
|
case Node.ELEMENT_NODE: {
|
|
1594
|
-
if (
|
|
1618
|
+
if (e < 0 || e > t.childNodes.length)
|
|
1595
1619
|
throw new Error("Child node offset is out of range");
|
|
1596
1620
|
let i = 0;
|
|
1597
|
-
for (let
|
|
1598
|
-
i +=
|
|
1599
|
-
return new A(
|
|
1621
|
+
for (let r = 0; r < e; r++)
|
|
1622
|
+
i += $t(t.childNodes[r]);
|
|
1623
|
+
return new A(t, i);
|
|
1600
1624
|
}
|
|
1601
1625
|
default:
|
|
1602
1626
|
throw new Error("Point is not in an element or text node");
|
|
1603
1627
|
}
|
|
1604
1628
|
}
|
|
1605
1629
|
}
|
|
1606
|
-
class
|
|
1607
|
-
constructor(
|
|
1608
|
-
this.start =
|
|
1630
|
+
class D {
|
|
1631
|
+
constructor(t, e) {
|
|
1632
|
+
this.start = t, this.end = e;
|
|
1609
1633
|
}
|
|
1610
1634
|
/**
|
|
1611
1635
|
* Create a new TextRange whose `start` and `end` are computed relative to
|
|
1612
1636
|
* `element`. `element` must be an ancestor of both `start.element` and
|
|
1613
1637
|
* `end.element`.
|
|
1614
1638
|
*/
|
|
1615
|
-
relativeTo(
|
|
1616
|
-
return new
|
|
1617
|
-
this.start.relativeTo(
|
|
1618
|
-
this.end.relativeTo(
|
|
1639
|
+
relativeTo(t) {
|
|
1640
|
+
return new D(
|
|
1641
|
+
this.start.relativeTo(t),
|
|
1642
|
+
this.end.relativeTo(t)
|
|
1619
1643
|
);
|
|
1620
1644
|
}
|
|
1621
1645
|
/**
|
|
@@ -1628,63 +1652,63 @@ class z {
|
|
|
1628
1652
|
* May throw if the `start` or `end` positions cannot be resolved to a range.
|
|
1629
1653
|
*/
|
|
1630
1654
|
toRange() {
|
|
1631
|
-
let
|
|
1632
|
-
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [
|
|
1655
|
+
let t, e;
|
|
1656
|
+
this.start.element === this.end.element && this.start.offset <= this.end.offset ? [t, e] = Ht(
|
|
1633
1657
|
this.start.element,
|
|
1634
1658
|
this.start.offset,
|
|
1635
1659
|
this.end.offset
|
|
1636
|
-
) : (
|
|
1660
|
+
) : (t = this.start.resolve({
|
|
1637
1661
|
direction: 1
|
|
1638
1662
|
/* FORWARDS */
|
|
1639
|
-
}),
|
|
1663
|
+
}), e = this.end.resolve({
|
|
1640
1664
|
direction: 2
|
|
1641
1665
|
/* BACKWARDS */
|
|
1642
1666
|
}));
|
|
1643
1667
|
const i = new Range();
|
|
1644
|
-
return i.setStart(
|
|
1668
|
+
return i.setStart(t.node, t.offset), i.setEnd(e.node, e.offset), i;
|
|
1645
1669
|
}
|
|
1646
1670
|
/**
|
|
1647
1671
|
* Create a TextRange from a (DOM) Range
|
|
1648
1672
|
*/
|
|
1649
|
-
static fromRange(
|
|
1650
|
-
const
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
), i = A.fromPoint(
|
|
1654
|
-
return new
|
|
1673
|
+
static fromRange(t) {
|
|
1674
|
+
const e = A.fromPoint(
|
|
1675
|
+
t.startContainer,
|
|
1676
|
+
t.startOffset
|
|
1677
|
+
), i = A.fromPoint(t.endContainer, t.endOffset);
|
|
1678
|
+
return new D(e, i);
|
|
1655
1679
|
}
|
|
1656
1680
|
/**
|
|
1657
1681
|
* Create a TextRange representing the `start`th to `end`th characters in
|
|
1658
1682
|
* `root`
|
|
1659
1683
|
*/
|
|
1660
|
-
static fromOffsets(
|
|
1661
|
-
return new
|
|
1662
|
-
new A(
|
|
1663
|
-
new A(
|
|
1684
|
+
static fromOffsets(t, e, i) {
|
|
1685
|
+
return new D(
|
|
1686
|
+
new A(t, e),
|
|
1687
|
+
new A(t, i)
|
|
1664
1688
|
);
|
|
1665
1689
|
}
|
|
1666
1690
|
/**
|
|
1667
1691
|
* Return a new Range representing `range` trimmed of any leading or trailing
|
|
1668
1692
|
* whitespace
|
|
1669
1693
|
*/
|
|
1670
|
-
static trimmedRange(
|
|
1671
|
-
return
|
|
1694
|
+
static trimmedRange(t) {
|
|
1695
|
+
return Se(D.fromRange(t).toRange());
|
|
1672
1696
|
}
|
|
1673
1697
|
}
|
|
1674
|
-
class
|
|
1675
|
-
constructor(
|
|
1676
|
-
this.root =
|
|
1698
|
+
class G {
|
|
1699
|
+
constructor(t, e, i) {
|
|
1700
|
+
this.root = t, this.start = e, this.end = i;
|
|
1677
1701
|
}
|
|
1678
|
-
static fromRange(
|
|
1679
|
-
const i =
|
|
1680
|
-
return new
|
|
1681
|
-
|
|
1702
|
+
static fromRange(t, e) {
|
|
1703
|
+
const i = D.fromRange(e).relativeTo(t);
|
|
1704
|
+
return new G(
|
|
1705
|
+
t,
|
|
1682
1706
|
i.start.offset,
|
|
1683
1707
|
i.end.offset
|
|
1684
1708
|
);
|
|
1685
1709
|
}
|
|
1686
|
-
static fromSelector(
|
|
1687
|
-
return new
|
|
1710
|
+
static fromSelector(t, e) {
|
|
1711
|
+
return new G(t, e.start, e.end);
|
|
1688
1712
|
}
|
|
1689
1713
|
toSelector() {
|
|
1690
1714
|
return {
|
|
@@ -1694,31 +1718,31 @@ class _ {
|
|
|
1694
1718
|
};
|
|
1695
1719
|
}
|
|
1696
1720
|
toRange() {
|
|
1697
|
-
return
|
|
1721
|
+
return D.fromOffsets(this.root, this.start, this.end).toRange();
|
|
1698
1722
|
}
|
|
1699
1723
|
}
|
|
1700
|
-
class
|
|
1724
|
+
class Y {
|
|
1701
1725
|
/**
|
|
1702
1726
|
* @param root - A root element from which to anchor.
|
|
1703
1727
|
*/
|
|
1704
|
-
constructor(
|
|
1705
|
-
this.root =
|
|
1728
|
+
constructor(t, e, i = {}) {
|
|
1729
|
+
this.root = t, this.exact = e, this.context = i;
|
|
1706
1730
|
}
|
|
1707
1731
|
/**
|
|
1708
1732
|
* Create a `TextQuoteAnchor` from a range.
|
|
1709
1733
|
*
|
|
1710
1734
|
* Will throw if `range` does not contain any text nodes.
|
|
1711
1735
|
*/
|
|
1712
|
-
static fromRange(
|
|
1713
|
-
const i =
|
|
1714
|
-
return new
|
|
1736
|
+
static fromRange(t, e) {
|
|
1737
|
+
const i = t.textContent, r = D.fromRange(e).relativeTo(t), n = r.start.offset, o = r.end.offset, l = 32;
|
|
1738
|
+
return new Y(t, i.slice(n, o), {
|
|
1715
1739
|
prefix: i.slice(Math.max(0, n - l), n),
|
|
1716
1740
|
suffix: i.slice(o, Math.min(i.length, o + l))
|
|
1717
1741
|
});
|
|
1718
1742
|
}
|
|
1719
|
-
static fromSelector(
|
|
1720
|
-
const { prefix: i, suffix:
|
|
1721
|
-
return new
|
|
1743
|
+
static fromSelector(t, e) {
|
|
1744
|
+
const { prefix: i, suffix: r } = e;
|
|
1745
|
+
return new Y(t, e.exact, { prefix: i, suffix: r });
|
|
1722
1746
|
}
|
|
1723
1747
|
toSelector() {
|
|
1724
1748
|
return {
|
|
@@ -1728,30 +1752,30 @@ class X {
|
|
|
1728
1752
|
suffix: this.context.suffix
|
|
1729
1753
|
};
|
|
1730
1754
|
}
|
|
1731
|
-
toRange(
|
|
1732
|
-
return this.toPositionAnchor(
|
|
1755
|
+
toRange(t = {}) {
|
|
1756
|
+
return this.toPositionAnchor(t).toRange();
|
|
1733
1757
|
}
|
|
1734
|
-
toPositionAnchor(
|
|
1735
|
-
const
|
|
1758
|
+
toPositionAnchor(t = {}) {
|
|
1759
|
+
const e = this.root.textContent, i = xe(e, this.exact, {
|
|
1736
1760
|
...this.context,
|
|
1737
|
-
hint:
|
|
1761
|
+
hint: t.hint
|
|
1738
1762
|
});
|
|
1739
1763
|
if (!i)
|
|
1740
1764
|
throw new Error("Quote not found");
|
|
1741
|
-
return new
|
|
1765
|
+
return new G(this.root, i.start, i.end);
|
|
1742
1766
|
}
|
|
1743
1767
|
}
|
|
1744
|
-
function
|
|
1745
|
-
const
|
|
1746
|
-
return
|
|
1768
|
+
function Te(s) {
|
|
1769
|
+
const t = s.tagName.toUpperCase();
|
|
1770
|
+
return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
|
|
1747
1771
|
}
|
|
1748
|
-
function
|
|
1772
|
+
function ct(s, t) {
|
|
1749
1773
|
try {
|
|
1750
|
-
const
|
|
1774
|
+
const e = t.locations, i = t.text;
|
|
1751
1775
|
if (i && i.highlight) {
|
|
1752
|
-
let
|
|
1753
|
-
|
|
1754
|
-
const n = new
|
|
1776
|
+
let r;
|
|
1777
|
+
e && e.getCssSelector() && (r = s.querySelector(e.getCssSelector())), r || (r = s.body);
|
|
1778
|
+
const n = new Y(r, i.highlight, {
|
|
1755
1779
|
prefix: i.before,
|
|
1756
1780
|
suffix: i.after
|
|
1757
1781
|
});
|
|
@@ -1761,29 +1785,29 @@ function le(r, e) {
|
|
|
1761
1785
|
return console.warn("Quote not found:", n), null;
|
|
1762
1786
|
}
|
|
1763
1787
|
}
|
|
1764
|
-
if (
|
|
1765
|
-
let
|
|
1766
|
-
if (!
|
|
1767
|
-
for (const n of
|
|
1768
|
-
if (
|
|
1788
|
+
if (e) {
|
|
1789
|
+
let r = null;
|
|
1790
|
+
if (!r && e.getCssSelector() && (r = s.querySelector(e.getCssSelector())), !r && e.fragments) {
|
|
1791
|
+
for (const n of e.fragments)
|
|
1792
|
+
if (r = s.getElementById(n), r)
|
|
1769
1793
|
break;
|
|
1770
1794
|
}
|
|
1771
|
-
if (
|
|
1772
|
-
const n =
|
|
1773
|
-
return
|
|
1795
|
+
if (r) {
|
|
1796
|
+
const n = s.createRange();
|
|
1797
|
+
return r.childNodes.length === 0 || Te(r) ? (n.selectNode(r), n) : (n.setStartBefore(r), n.setEndAfter(r), n);
|
|
1774
1798
|
}
|
|
1775
1799
|
}
|
|
1776
|
-
} catch (
|
|
1777
|
-
console.error(
|
|
1800
|
+
} catch (e) {
|
|
1801
|
+
console.error(e);
|
|
1778
1802
|
}
|
|
1779
1803
|
return null;
|
|
1780
1804
|
}
|
|
1781
|
-
function
|
|
1782
|
-
let
|
|
1783
|
-
|
|
1784
|
-
const i = 1,
|
|
1785
|
-
for (const h of
|
|
1786
|
-
|
|
1805
|
+
function we(s, t) {
|
|
1806
|
+
let e = s.getClientRects();
|
|
1807
|
+
e.length || s.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = s.commonAncestorContainer.getClientRects());
|
|
1808
|
+
const i = 1, r = [];
|
|
1809
|
+
for (const h of e)
|
|
1810
|
+
r.push({
|
|
1787
1811
|
bottom: h.bottom,
|
|
1788
1812
|
height: h.height,
|
|
1789
1813
|
left: h.left,
|
|
@@ -1791,11 +1815,11 @@ function St(r, e) {
|
|
|
1791
1815
|
top: h.top,
|
|
1792
1816
|
width: h.width
|
|
1793
1817
|
});
|
|
1794
|
-
const n =
|
|
1795
|
-
|
|
1818
|
+
const n = Vt(
|
|
1819
|
+
r,
|
|
1796
1820
|
i,
|
|
1797
|
-
|
|
1798
|
-
), o =
|
|
1821
|
+
t
|
|
1822
|
+
), o = Pe(n, i), l = jt(o), c = 2 * 2;
|
|
1799
1823
|
for (let h = l.length - 1; h >= 0; h--) {
|
|
1800
1824
|
const u = l[h];
|
|
1801
1825
|
if (!(u.width * u.height > c))
|
|
@@ -1806,231 +1830,231 @@ function St(r, e) {
|
|
|
1806
1830
|
}
|
|
1807
1831
|
return l;
|
|
1808
1832
|
}
|
|
1809
|
-
function
|
|
1810
|
-
for (let i = 0; i <
|
|
1811
|
-
for (let
|
|
1812
|
-
const n =
|
|
1833
|
+
function Vt(s, t, e) {
|
|
1834
|
+
for (let i = 0; i < s.length; i++)
|
|
1835
|
+
for (let r = i + 1; r < s.length; r++) {
|
|
1836
|
+
const n = s[i], o = s[r];
|
|
1813
1837
|
if (n === o)
|
|
1814
1838
|
continue;
|
|
1815
|
-
const l =
|
|
1816
|
-
if ((c && !
|
|
1817
|
-
const d =
|
|
1818
|
-
return d.push(f),
|
|
1839
|
+
const l = N(n.top, o.top, t) && N(n.bottom, o.bottom, t), c = N(n.left, o.left, t) && N(n.right, o.right, t);
|
|
1840
|
+
if ((c && !e || l && !c) && qt(n, o, t)) {
|
|
1841
|
+
const d = s.filter((g) => g !== n && g !== o), f = Ce(n, o);
|
|
1842
|
+
return d.push(f), Vt(
|
|
1819
1843
|
d,
|
|
1820
|
-
|
|
1821
|
-
|
|
1844
|
+
t,
|
|
1845
|
+
e
|
|
1822
1846
|
);
|
|
1823
1847
|
}
|
|
1824
1848
|
}
|
|
1825
|
-
return
|
|
1849
|
+
return s;
|
|
1826
1850
|
}
|
|
1827
|
-
function
|
|
1828
|
-
const
|
|
1851
|
+
function Ce(s, t) {
|
|
1852
|
+
const e = Math.min(s.left, t.left), i = Math.max(s.right, t.right), r = Math.min(s.top, t.top), n = Math.max(s.bottom, t.bottom);
|
|
1829
1853
|
return {
|
|
1830
1854
|
bottom: n,
|
|
1831
|
-
height: n -
|
|
1832
|
-
left:
|
|
1855
|
+
height: n - r,
|
|
1856
|
+
left: e,
|
|
1833
1857
|
right: i,
|
|
1834
|
-
top:
|
|
1835
|
-
width: i -
|
|
1858
|
+
top: r,
|
|
1859
|
+
width: i - e
|
|
1836
1860
|
};
|
|
1837
1861
|
}
|
|
1838
|
-
function
|
|
1839
|
-
const
|
|
1840
|
-
for (const i of
|
|
1862
|
+
function Pe(s, t) {
|
|
1863
|
+
const e = new Set(s);
|
|
1864
|
+
for (const i of s) {
|
|
1841
1865
|
if (!(i.width > 1 && i.height > 1)) {
|
|
1842
|
-
|
|
1866
|
+
e.delete(i);
|
|
1843
1867
|
continue;
|
|
1844
1868
|
}
|
|
1845
|
-
for (const n of
|
|
1846
|
-
if (i !== n &&
|
|
1847
|
-
|
|
1869
|
+
for (const n of s)
|
|
1870
|
+
if (i !== n && e.has(n) && Me(n, i, t)) {
|
|
1871
|
+
e.delete(i);
|
|
1848
1872
|
break;
|
|
1849
1873
|
}
|
|
1850
1874
|
}
|
|
1851
|
-
return Array.from(
|
|
1875
|
+
return Array.from(e);
|
|
1852
1876
|
}
|
|
1853
|
-
function
|
|
1854
|
-
return
|
|
1877
|
+
function Me(s, t, e) {
|
|
1878
|
+
return j(s, t.left, t.top, e) && j(s, t.right, t.top, e) && j(s, t.left, t.bottom, e) && j(s, t.right, t.bottom, e);
|
|
1855
1879
|
}
|
|
1856
|
-
function
|
|
1857
|
-
return (
|
|
1880
|
+
function j(s, t, e, i) {
|
|
1881
|
+
return (s.left < t || N(s.left, t, i)) && (s.right > t || N(s.right, t, i)) && (s.top < e || N(s.top, e, i)) && (s.bottom > e || N(s.bottom, e, i));
|
|
1858
1882
|
}
|
|
1859
|
-
function
|
|
1860
|
-
for (let
|
|
1861
|
-
for (let
|
|
1862
|
-
const i =
|
|
1863
|
-
if (i !==
|
|
1883
|
+
function jt(s) {
|
|
1884
|
+
for (let t = 0; t < s.length; t++)
|
|
1885
|
+
for (let e = t + 1; e < s.length; e++) {
|
|
1886
|
+
const i = s[t], r = s[e];
|
|
1887
|
+
if (i !== r && qt(i, r, -1)) {
|
|
1864
1888
|
let n = [], o;
|
|
1865
|
-
const l =
|
|
1889
|
+
const l = Mt(i, r);
|
|
1866
1890
|
if (l.length === 1)
|
|
1867
1891
|
n = l, o = i;
|
|
1868
1892
|
else {
|
|
1869
|
-
const h =
|
|
1870
|
-
l.length < h.length ? (n = l, o = i) : (n = h, o =
|
|
1893
|
+
const h = Mt(r, i);
|
|
1894
|
+
l.length < h.length ? (n = l, o = i) : (n = h, o = r);
|
|
1871
1895
|
}
|
|
1872
|
-
const c =
|
|
1873
|
-
return Array.prototype.push.apply(c, n),
|
|
1896
|
+
const c = s.filter((h) => h !== o);
|
|
1897
|
+
return Array.prototype.push.apply(c, n), jt(c);
|
|
1874
1898
|
}
|
|
1875
1899
|
}
|
|
1876
|
-
return
|
|
1900
|
+
return s;
|
|
1877
1901
|
}
|
|
1878
|
-
function
|
|
1879
|
-
const
|
|
1880
|
-
if (
|
|
1881
|
-
return [
|
|
1902
|
+
function Mt(s, t) {
|
|
1903
|
+
const e = Ne(t, s);
|
|
1904
|
+
if (e.height === 0 || e.width === 0)
|
|
1905
|
+
return [s];
|
|
1882
1906
|
const i = [];
|
|
1883
1907
|
{
|
|
1884
|
-
const
|
|
1885
|
-
bottom:
|
|
1908
|
+
const r = {
|
|
1909
|
+
bottom: s.bottom,
|
|
1886
1910
|
height: 0,
|
|
1887
|
-
left:
|
|
1888
|
-
right:
|
|
1889
|
-
top:
|
|
1911
|
+
left: s.left,
|
|
1912
|
+
right: e.left,
|
|
1913
|
+
top: s.top,
|
|
1890
1914
|
width: 0
|
|
1891
1915
|
};
|
|
1892
|
-
|
|
1916
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1893
1917
|
}
|
|
1894
1918
|
{
|
|
1895
|
-
const
|
|
1896
|
-
bottom:
|
|
1919
|
+
const r = {
|
|
1920
|
+
bottom: e.top,
|
|
1897
1921
|
height: 0,
|
|
1898
|
-
left:
|
|
1899
|
-
right:
|
|
1900
|
-
top:
|
|
1922
|
+
left: e.left,
|
|
1923
|
+
right: e.right,
|
|
1924
|
+
top: s.top,
|
|
1901
1925
|
width: 0
|
|
1902
1926
|
};
|
|
1903
|
-
|
|
1927
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1904
1928
|
}
|
|
1905
1929
|
{
|
|
1906
|
-
const
|
|
1907
|
-
bottom:
|
|
1930
|
+
const r = {
|
|
1931
|
+
bottom: s.bottom,
|
|
1908
1932
|
height: 0,
|
|
1909
|
-
left:
|
|
1910
|
-
right:
|
|
1911
|
-
top:
|
|
1933
|
+
left: e.left,
|
|
1934
|
+
right: e.right,
|
|
1935
|
+
top: e.bottom,
|
|
1912
1936
|
width: 0
|
|
1913
1937
|
};
|
|
1914
|
-
|
|
1938
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1915
1939
|
}
|
|
1916
1940
|
{
|
|
1917
|
-
const
|
|
1918
|
-
bottom:
|
|
1941
|
+
const r = {
|
|
1942
|
+
bottom: s.bottom,
|
|
1919
1943
|
height: 0,
|
|
1920
|
-
left:
|
|
1921
|
-
right:
|
|
1922
|
-
top:
|
|
1944
|
+
left: e.right,
|
|
1945
|
+
right: s.right,
|
|
1946
|
+
top: s.top,
|
|
1923
1947
|
width: 0
|
|
1924
1948
|
};
|
|
1925
|
-
|
|
1949
|
+
r.width = r.right - r.left, r.height = r.bottom - r.top, r.height !== 0 && r.width !== 0 && i.push(r);
|
|
1926
1950
|
}
|
|
1927
1951
|
return i;
|
|
1928
1952
|
}
|
|
1929
|
-
function
|
|
1930
|
-
const
|
|
1953
|
+
function Ne(s, t) {
|
|
1954
|
+
const e = Math.max(s.left, t.left), i = Math.min(s.right, t.right), r = Math.max(s.top, t.top), n = Math.min(s.bottom, t.bottom);
|
|
1931
1955
|
return {
|
|
1932
1956
|
bottom: n,
|
|
1933
|
-
height: Math.max(0, n -
|
|
1934
|
-
left:
|
|
1957
|
+
height: Math.max(0, n - r),
|
|
1958
|
+
left: e,
|
|
1935
1959
|
right: i,
|
|
1936
|
-
top:
|
|
1937
|
-
width: Math.max(0, i -
|
|
1960
|
+
top: r,
|
|
1961
|
+
width: Math.max(0, i - e)
|
|
1938
1962
|
};
|
|
1939
1963
|
}
|
|
1940
|
-
function
|
|
1941
|
-
return (
|
|
1964
|
+
function qt(s, t, e) {
|
|
1965
|
+
return (s.left < t.right || e >= 0 && N(s.left, t.right, e)) && (t.left < s.right || e >= 0 && N(t.left, s.right, e)) && (s.top < t.bottom || e >= 0 && N(s.top, t.bottom, e)) && (t.top < s.bottom || e >= 0 && N(t.top, s.bottom, e));
|
|
1942
1966
|
}
|
|
1943
|
-
function
|
|
1944
|
-
return Math.abs(
|
|
1967
|
+
function N(s, t, e) {
|
|
1968
|
+
return Math.abs(s - t) <= e;
|
|
1945
1969
|
}
|
|
1946
|
-
function
|
|
1947
|
-
const
|
|
1948
|
-
for (const i in
|
|
1949
|
-
Object.hasOwn(
|
|
1950
|
-
return
|
|
1970
|
+
function _t(s) {
|
|
1971
|
+
const t = {}, e = s.document.documentElement.style;
|
|
1972
|
+
for (const i in s.document.documentElement.style)
|
|
1973
|
+
Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
|
|
1974
|
+
return t;
|
|
1951
1975
|
}
|
|
1952
|
-
function
|
|
1953
|
-
const
|
|
1954
|
-
Object.keys(
|
|
1955
|
-
|
|
1956
|
-
}), Object.entries(
|
|
1957
|
-
|
|
1976
|
+
function Ae(s, t) {
|
|
1977
|
+
const e = _t(s);
|
|
1978
|
+
Object.keys(e).forEach((i) => {
|
|
1979
|
+
t.hasOwnProperty(i) || ut(s, i);
|
|
1980
|
+
}), Object.entries(t).forEach(([i, r]) => {
|
|
1981
|
+
e[i] !== r && Z(s, i, r);
|
|
1958
1982
|
});
|
|
1959
1983
|
}
|
|
1960
|
-
function
|
|
1961
|
-
return
|
|
1984
|
+
function Nt(s, t) {
|
|
1985
|
+
return s.document.documentElement.style.getPropertyValue(t);
|
|
1962
1986
|
}
|
|
1963
|
-
function
|
|
1964
|
-
|
|
1987
|
+
function Z(s, t, e) {
|
|
1988
|
+
s.document.documentElement.style.setProperty(t, e);
|
|
1965
1989
|
}
|
|
1966
|
-
function
|
|
1967
|
-
|
|
1990
|
+
function ut(s, t) {
|
|
1991
|
+
s.document.documentElement.style.removeProperty(t);
|
|
1968
1992
|
}
|
|
1969
|
-
const
|
|
1970
|
-
if (
|
|
1971
|
-
const
|
|
1972
|
-
if (
|
|
1993
|
+
const Oe = (s) => {
|
|
1994
|
+
if (s.startsWith("rgb")) {
|
|
1995
|
+
const t = s.match(/rgb\((\d+),\s(\d+),\s(\d+)(?:,\s(\d+))?\)/);
|
|
1996
|
+
if (t)
|
|
1973
1997
|
return {
|
|
1974
|
-
r: parseInt(
|
|
1975
|
-
g: parseInt(
|
|
1976
|
-
b: parseInt(
|
|
1977
|
-
a:
|
|
1998
|
+
r: parseInt(t[1], 10),
|
|
1999
|
+
g: parseInt(t[2], 10),
|
|
2000
|
+
b: parseInt(t[3], 10),
|
|
2001
|
+
a: t[4] ? parseInt(t[4], 10) / 255 : 1
|
|
1978
2002
|
};
|
|
1979
|
-
} else if (
|
|
1980
|
-
const
|
|
1981
|
-
if (
|
|
2003
|
+
} else if (s.startsWith("#")) {
|
|
2004
|
+
const t = s.slice(1);
|
|
2005
|
+
if (t.length === 3 || t.length === 4)
|
|
1982
2006
|
return {
|
|
1983
|
-
r: parseInt(
|
|
1984
|
-
g: parseInt(
|
|
1985
|
-
b: parseInt(
|
|
1986
|
-
a:
|
|
2007
|
+
r: parseInt(t[0] + t[0], 16) / 255,
|
|
2008
|
+
g: parseInt(t[1] + t[1], 16) / 255,
|
|
2009
|
+
b: parseInt(t[2] + t[2], 16) / 255,
|
|
2010
|
+
a: t.length === 4 ? parseInt(t[3] + t[3], 16) / 255 : 1
|
|
1987
2011
|
};
|
|
1988
|
-
if (
|
|
2012
|
+
if (t.length === 6 || t.length === 8)
|
|
1989
2013
|
return {
|
|
1990
|
-
r: parseInt(
|
|
1991
|
-
g: parseInt(
|
|
1992
|
-
b: parseInt(
|
|
1993
|
-
a:
|
|
2014
|
+
r: parseInt(t[0] + t[1], 16) / 255,
|
|
2015
|
+
g: parseInt(t[2] + t[3], 16) / 255,
|
|
2016
|
+
b: parseInt(t[4] + t[5], 16) / 255,
|
|
2017
|
+
a: t.length === 8 ? parseInt(t[6] + t[7], 16) / 255 : 1
|
|
1994
2018
|
};
|
|
1995
2019
|
}
|
|
1996
2020
|
return { r: 0, g: 0, b: 0, a: 1 };
|
|
1997
|
-
},
|
|
1998
|
-
const
|
|
1999
|
-
return
|
|
2021
|
+
}, Ie = (s) => 0.2126 * s.r * s.a + 0.7152 * s.g * s.a + 0.0722 * s.b * s.a, Le = (s) => {
|
|
2022
|
+
const t = Oe(s);
|
|
2023
|
+
return Ie(t) < 128;
|
|
2000
2024
|
};
|
|
2001
|
-
var
|
|
2002
|
-
const
|
|
2003
|
-
class
|
|
2025
|
+
var Re = /* @__PURE__ */ ((s) => (s.Wrap = "wrap", s.Viewport = "viewport", s.Bounds = "bounds", s.Page = "page", s))(Re || {}), ze = /* @__PURE__ */ ((s) => (s.Boxes = "boxes", s.Bounds = "bounds", s))(ze || {});
|
|
2026
|
+
const De = () => "Highlight" in window, At = ["IMG", "IMAGE", "AUDIO", "VIDEO", "SVG"];
|
|
2027
|
+
class We {
|
|
2004
2028
|
/**
|
|
2005
2029
|
* Creates a DecorationGroup object
|
|
2006
2030
|
* @param id Unique HTML ID-adhering name of the group
|
|
2007
2031
|
* @param name Human-readable name of the group
|
|
2008
2032
|
*/
|
|
2009
|
-
constructor(
|
|
2010
|
-
this.wnd =
|
|
2033
|
+
constructor(t, e, i, r) {
|
|
2034
|
+
this.wnd = t, this.comms = e, this.id = i, this.name = r, this.items = [], this.lastItemId = 0, this.container = void 0, this.activateable = !1, this.experimentalHighlights = !1, this.currentRender = 0, De() && (this.experimentalHighlights = !0, this.notTextFlag = /* @__PURE__ */ new Map());
|
|
2011
2035
|
}
|
|
2012
2036
|
get activeable() {
|
|
2013
2037
|
return this.activateable;
|
|
2014
2038
|
}
|
|
2015
|
-
set activeable(
|
|
2016
|
-
this.activateable =
|
|
2039
|
+
set activeable(t) {
|
|
2040
|
+
this.activateable = t;
|
|
2017
2041
|
}
|
|
2018
2042
|
/**
|
|
2019
2043
|
* Adds a new decoration to the group.
|
|
2020
2044
|
* @param decoration Decoration to add
|
|
2021
2045
|
*/
|
|
2022
|
-
add(
|
|
2046
|
+
add(t) {
|
|
2023
2047
|
var o, l, c, h;
|
|
2024
|
-
const
|
|
2048
|
+
const e = `${this.id}-${this.lastItemId++}`, i = ct(this.wnd.document, t.locator);
|
|
2025
2049
|
if (!i) {
|
|
2026
|
-
this.comms.log("Can't locate DOM range for decoration",
|
|
2050
|
+
this.comms.log("Can't locate DOM range for decoration", t);
|
|
2027
2051
|
return;
|
|
2028
2052
|
}
|
|
2029
|
-
const
|
|
2030
|
-
|
|
2053
|
+
const r = i.commonAncestorContainer;
|
|
2054
|
+
r.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (At.includes(r.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(e, !0)), r.querySelector(At.join(", ").toLowerCase()) && ((l = this.notTextFlag) == null || l.set(e, !0)), (((c = r.textContent) == null ? void 0 : c.trim()) || "").length === 0 && ((h = this.notTextFlag) == null || h.set(e, !0)));
|
|
2031
2055
|
const n = {
|
|
2032
|
-
decoration:
|
|
2033
|
-
id:
|
|
2056
|
+
decoration: t,
|
|
2057
|
+
id: e,
|
|
2034
2058
|
range: i
|
|
2035
2059
|
};
|
|
2036
2060
|
this.items.push(n), this.layout(n), this.renderLayout([n]);
|
|
@@ -2039,13 +2063,13 @@ class zt {
|
|
|
2039
2063
|
* Removes the decoration with given ID from the group.
|
|
2040
2064
|
* @param identifier ID of item to remove
|
|
2041
2065
|
*/
|
|
2042
|
-
remove(
|
|
2043
|
-
var
|
|
2044
|
-
const
|
|
2045
|
-
if (
|
|
2066
|
+
remove(t) {
|
|
2067
|
+
var r, n;
|
|
2068
|
+
const e = this.items.findIndex((o) => o.decoration.id === t);
|
|
2069
|
+
if (e < 0)
|
|
2046
2070
|
return;
|
|
2047
|
-
const i = this.items[
|
|
2048
|
-
if (this.items.splice(
|
|
2071
|
+
const i = this.items[e];
|
|
2072
|
+
if (this.items.splice(e, 1), i.clickableElements = void 0, i.container && (i.container.remove(), i.container = void 0), this.experimentalHighlights && !((r = this.notTextFlag) != null && r.has(i.id))) {
|
|
2049
2073
|
const o = this.wnd.CSS.highlights.get(this.id);
|
|
2050
2074
|
o == null || o.delete(i.range);
|
|
2051
2075
|
}
|
|
@@ -2055,68 +2079,68 @@ class zt {
|
|
|
2055
2079
|
* Notifies that the given decoration was modified and needs to be updated.
|
|
2056
2080
|
* @param decoration Decoration to update
|
|
2057
2081
|
*/
|
|
2058
|
-
update(
|
|
2059
|
-
this.remove(
|
|
2082
|
+
update(t) {
|
|
2083
|
+
this.remove(t.id), this.add(t);
|
|
2060
2084
|
}
|
|
2061
2085
|
/**
|
|
2062
2086
|
* Removes all decorations from this group.
|
|
2063
2087
|
*/
|
|
2064
2088
|
clear() {
|
|
2065
|
-
var
|
|
2066
|
-
this.clearContainer(), this.items.length = 0, (
|
|
2089
|
+
var t;
|
|
2090
|
+
this.clearContainer(), this.items.length = 0, (t = this.notTextFlag) == null || t.clear();
|
|
2067
2091
|
}
|
|
2068
2092
|
/**
|
|
2069
2093
|
* Recreates the decoration elements.
|
|
2070
2094
|
* To be called after reflowing the resource, for example.
|
|
2071
2095
|
*/
|
|
2072
2096
|
requestLayout() {
|
|
2073
|
-
this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((
|
|
2097
|
+
this.wnd.cancelAnimationFrame(this.currentRender), this.clearContainer(), this.items.forEach((t) => this.layout(t)), this.renderLayout(this.items);
|
|
2074
2098
|
}
|
|
2075
|
-
experimentalLayout(
|
|
2076
|
-
var
|
|
2077
|
-
const [
|
|
2078
|
-
i.add(
|
|
2099
|
+
experimentalLayout(t) {
|
|
2100
|
+
var r, n;
|
|
2101
|
+
const [e, i] = this.requireContainer(!0);
|
|
2102
|
+
i.add(t.range), e.innerHTML = `
|
|
2079
2103
|
::highlight(${this.id}) {
|
|
2080
2104
|
color: black;
|
|
2081
|
-
background-color: ${((n = (
|
|
2105
|
+
background-color: ${((n = (r = t.decoration) == null ? void 0 : r.style) == null ? void 0 : n.tint) ?? "yellow"};
|
|
2082
2106
|
}`;
|
|
2083
2107
|
}
|
|
2084
2108
|
/**
|
|
2085
2109
|
* Layouts a single DecorationItem.
|
|
2086
2110
|
* @param item
|
|
2087
2111
|
*/
|
|
2088
|
-
layout(
|
|
2089
|
-
var g, m, v,
|
|
2090
|
-
if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(
|
|
2091
|
-
return this.experimentalLayout(
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
const i = this.wnd.innerWidth,
|
|
2112
|
+
layout(t) {
|
|
2113
|
+
var g, m, v, x, O;
|
|
2114
|
+
if (this.experimentalHighlights && !((g = this.notTextFlag) != null && g.has(t.id)))
|
|
2115
|
+
return this.experimentalLayout(t);
|
|
2116
|
+
const e = this.wnd.document.createElement("div");
|
|
2117
|
+
e.setAttribute("id", t.id), e.style.setProperty("pointer-events", "none");
|
|
2118
|
+
const i = this.wnd.innerWidth, r = parseInt(
|
|
2095
2119
|
getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
|
|
2096
2120
|
"column-count"
|
|
2097
2121
|
)
|
|
2098
|
-
), n = i / (
|
|
2099
|
-
var
|
|
2100
|
-
if (y.style.position = "absolute", ((
|
|
2101
|
-
y.style.width = `${i}px`, y.style.height = `${
|
|
2102
|
-
let
|
|
2103
|
-
y.style.left = `${
|
|
2104
|
-
} else if (((
|
|
2105
|
-
y.style.width = `${I.width}px`, y.style.height = `${
|
|
2106
|
-
else if (((
|
|
2107
|
-
y.style.width = `${n}px`, y.style.height = `${
|
|
2108
|
-
let
|
|
2109
|
-
y.style.left = `${
|
|
2122
|
+
), n = i / (r || 1), o = this.wnd.document.scrollingElement, l = o.scrollLeft, c = o.scrollTop, h = (y, b, I) => {
|
|
2123
|
+
var dt, pt, ft, mt, gt, yt;
|
|
2124
|
+
if (y.style.position = "absolute", ((pt = (dt = t.decoration) == null ? void 0 : dt.style) == null ? void 0 : pt.width) === "viewport") {
|
|
2125
|
+
y.style.width = `${i}px`, y.style.height = `${b.height}px`;
|
|
2126
|
+
let J = Math.floor(b.left / i) * i;
|
|
2127
|
+
y.style.left = `${J + l}px`, y.style.top = `${b.top + c}px`;
|
|
2128
|
+
} else if (((mt = (ft = t.decoration) == null ? void 0 : ft.style) == null ? void 0 : mt.width) === "bounds")
|
|
2129
|
+
y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + l}px`, y.style.top = `${b.top + c}px`;
|
|
2130
|
+
else if (((yt = (gt = t.decoration) == null ? void 0 : gt.style) == null ? void 0 : yt.width) === "page") {
|
|
2131
|
+
y.style.width = `${n}px`, y.style.height = `${b.height}px`;
|
|
2132
|
+
let J = Math.floor(b.left / n) * n;
|
|
2133
|
+
y.style.left = `${J + l}px`, y.style.top = `${b.top + c}px`;
|
|
2110
2134
|
} else
|
|
2111
|
-
y.style.width = `${
|
|
2112
|
-
}, u =
|
|
2135
|
+
y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + l}px`, y.style.top = `${b.top + c}px`;
|
|
2136
|
+
}, u = t.range.getBoundingClientRect();
|
|
2113
2137
|
let p = this.wnd.document.createElement("template");
|
|
2114
|
-
const d =
|
|
2138
|
+
const d = Nt(this.wnd, "--USER__appearance") === "readium-night-on" || Le(Nt(this.wnd, "--USER__backgroundColor"));
|
|
2115
2139
|
p.innerHTML = `
|
|
2116
2140
|
<div
|
|
2117
2141
|
class="r2-highlight-0"
|
|
2118
2142
|
style="${[
|
|
2119
|
-
`background-color: ${((v = (m =
|
|
2143
|
+
`background-color: ${((v = (m = t.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
|
|
2120
2144
|
//"opacity: 0.3 !important",
|
|
2121
2145
|
`mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
|
|
2122
2146
|
"opacity: 1 !important",
|
|
@@ -2126,45 +2150,45 @@ class zt {
|
|
|
2126
2150
|
</div>
|
|
2127
2151
|
`.trim();
|
|
2128
2152
|
const f = p.content.firstElementChild;
|
|
2129
|
-
if (((O = (
|
|
2153
|
+
if (((O = (x = t.decoration) == null ? void 0 : x.style) == null ? void 0 : O.layout) === "bounds") {
|
|
2130
2154
|
const y = f.cloneNode(!0);
|
|
2131
|
-
y.style.setProperty("pointer-events", "none"), h(y, u, u),
|
|
2155
|
+
y.style.setProperty("pointer-events", "none"), h(y, u, u), e.append(y);
|
|
2132
2156
|
} else {
|
|
2133
|
-
let y =
|
|
2134
|
-
|
|
2157
|
+
let y = we(
|
|
2158
|
+
t.range,
|
|
2135
2159
|
!0
|
|
2136
2160
|
// doNotMergeHorizontallyAlignedRects
|
|
2137
2161
|
);
|
|
2138
|
-
y = y.sort((
|
|
2139
|
-
for (let
|
|
2162
|
+
y = y.sort((b, I) => b.top < I.top ? -1 : b.top > I.top ? 1 : 0);
|
|
2163
|
+
for (let b of y) {
|
|
2140
2164
|
const I = f.cloneNode(!0);
|
|
2141
|
-
I.style.setProperty("pointer-events", "none"), h(I,
|
|
2165
|
+
I.style.setProperty("pointer-events", "none"), h(I, b, u), e.append(I);
|
|
2142
2166
|
}
|
|
2143
2167
|
}
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
),
|
|
2168
|
+
t.container = e, t.clickableElements = Array.from(
|
|
2169
|
+
e.querySelectorAll("[data-activable='1']")
|
|
2170
|
+
), t.clickableElements.length || (t.clickableElements = Array.from(e.children));
|
|
2147
2171
|
}
|
|
2148
|
-
renderLayout(
|
|
2172
|
+
renderLayout(t) {
|
|
2149
2173
|
this.wnd.cancelAnimationFrame(this.currentRender), this.currentRender = this.wnd.requestAnimationFrame(() => {
|
|
2150
|
-
if (
|
|
2151
|
-
var
|
|
2152
|
-
return !this.experimentalHighlights || !!((
|
|
2153
|
-
}), !
|
|
2174
|
+
if (t = t.filter((i) => {
|
|
2175
|
+
var r;
|
|
2176
|
+
return !this.experimentalHighlights || !!((r = this.notTextFlag) != null && r.has(i.id));
|
|
2177
|
+
}), !t || t.length === 0)
|
|
2154
2178
|
return;
|
|
2155
|
-
this.requireContainer().append(...
|
|
2179
|
+
this.requireContainer().append(...t.map((i) => i.container).filter((i) => !!i));
|
|
2156
2180
|
});
|
|
2157
2181
|
}
|
|
2158
2182
|
/**
|
|
2159
2183
|
* Returns the group container element, after making sure it exists.
|
|
2160
2184
|
* @returns Group's container
|
|
2161
2185
|
*/
|
|
2162
|
-
requireContainer(
|
|
2163
|
-
if (
|
|
2164
|
-
let
|
|
2165
|
-
this.wnd.document.getElementById(`${this.id}-style`) ?
|
|
2186
|
+
requireContainer(t = !1) {
|
|
2187
|
+
if (t) {
|
|
2188
|
+
let e;
|
|
2189
|
+
this.wnd.document.getElementById(`${this.id}-style`) ? e = this.wnd.document.getElementById(`${this.id}-style`) : (e = this.wnd.document.createElement("style"), e.dataset.readium = "true", e.id = `${this.id}-style`, this.wnd.document.head.appendChild(e));
|
|
2166
2190
|
let i;
|
|
2167
|
-
return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [
|
|
2191
|
+
return this.wnd.CSS.highlights.has(this.id) ? i = this.wnd.CSS.highlights.get(this.id) : (i = new this.wnd.Highlight(), this.wnd.CSS.highlights.set(this.id, i)), [e, i];
|
|
2168
2192
|
}
|
|
2169
2193
|
return this.container || (this.container = this.wnd.document.createElement("div"), this.container.setAttribute("id", this.id), this.container.dataset.group = this.name, this.container.dataset.readium = "true", this.container.style.setProperty("pointer-events", "none"), this.container.style.display = "contents", this.wnd.document.body.append(this.container)), this.container;
|
|
2170
2194
|
}
|
|
@@ -2175,26 +2199,26 @@ class zt {
|
|
|
2175
2199
|
this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
|
|
2176
2200
|
}
|
|
2177
2201
|
}
|
|
2178
|
-
const
|
|
2202
|
+
const Xt = class et extends K {
|
|
2179
2203
|
constructor() {
|
|
2180
2204
|
super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
|
|
2181
2205
|
}
|
|
2182
2206
|
cleanup() {
|
|
2183
|
-
this.groups.forEach((
|
|
2207
|
+
this.groups.forEach((t) => t.clear()), this.groups.clear();
|
|
2184
2208
|
}
|
|
2185
2209
|
handleResize() {
|
|
2186
2210
|
this.wnd.clearTimeout(this.resizeFrame), this.resizeFrame = this.wnd.setTimeout(() => {
|
|
2187
|
-
this.groups.forEach((
|
|
2188
|
-
|
|
2211
|
+
this.groups.forEach((t) => {
|
|
2212
|
+
t.experimentalHighlights || t.requestLayout();
|
|
2189
2213
|
});
|
|
2190
2214
|
}, 50);
|
|
2191
2215
|
}
|
|
2192
|
-
mount(
|
|
2193
|
-
return this.wnd =
|
|
2216
|
+
mount(t, e) {
|
|
2217
|
+
return this.wnd = t, e.register("decorate", et.moduleName, (i, r) => {
|
|
2194
2218
|
const n = i;
|
|
2195
|
-
n.decoration && n.decoration.locator && (n.decoration.locator =
|
|
2196
|
-
e,
|
|
2219
|
+
n.decoration && n.decoration.locator && (n.decoration.locator = W.deserialize(n.decoration.locator)), this.groups.has(n.group) || this.groups.set(n.group, new We(
|
|
2197
2220
|
t,
|
|
2221
|
+
e,
|
|
2198
2222
|
`readium-decoration-${this.lastGroupId++}`,
|
|
2199
2223
|
n.group
|
|
2200
2224
|
));
|
|
@@ -2213,16 +2237,16 @@ const qe = class Q extends Y {
|
|
|
2213
2237
|
o == null || o.update(n.decoration);
|
|
2214
2238
|
break;
|
|
2215
2239
|
}
|
|
2216
|
-
|
|
2217
|
-
}), this.resizeObserver = new ResizeObserver(() =>
|
|
2240
|
+
r(!0);
|
|
2241
|
+
}), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), e.log("Decorator Mounted"), !0;
|
|
2218
2242
|
}
|
|
2219
|
-
unmount(
|
|
2220
|
-
return
|
|
2243
|
+
unmount(t, e) {
|
|
2244
|
+
return t.removeEventListener("orientationchange", this.handleResizer), t.removeEventListener("resize", this.handleResizer), e.unregisterAll(et.moduleName), this.resizeObserver.disconnect(), this.cleanup(), e.log("Decorator Unmounted"), !0;
|
|
2221
2245
|
}
|
|
2222
2246
|
};
|
|
2223
|
-
|
|
2224
|
-
let
|
|
2225
|
-
const
|
|
2247
|
+
Xt.moduleName = "decorator";
|
|
2248
|
+
let Fe = Xt;
|
|
2249
|
+
const Ot = "readium-snapper-style", Gt = class it extends K {
|
|
2226
2250
|
constructor() {
|
|
2227
2251
|
super(...arguments), this.protected = !1;
|
|
2228
2252
|
}
|
|
@@ -2233,62 +2257,62 @@ const Me = "readium-snapper-style", _e = class ee extends Y {
|
|
|
2233
2257
|
user-select: ${this.protected ? "none" : "auto"};
|
|
2234
2258
|
}`;
|
|
2235
2259
|
}
|
|
2236
|
-
mount(
|
|
2237
|
-
const i =
|
|
2238
|
-
return i.dataset.readium = "true", i.id =
|
|
2260
|
+
mount(t, e) {
|
|
2261
|
+
const i = t.document.createElement("style");
|
|
2262
|
+
return i.dataset.readium = "true", i.id = Ot, i.textContent = this.buildStyles(), t.document.head.appendChild(i), e.register("protect", it.moduleName, (r, n) => {
|
|
2239
2263
|
this.protected = !0, i.textContent = this.buildStyles(), n(!0);
|
|
2240
|
-
}),
|
|
2264
|
+
}), e.register("unprotect", it.moduleName, (r, n) => {
|
|
2241
2265
|
this.protected = !1, i.textContent = this.buildStyles(), n(!0);
|
|
2242
|
-
}),
|
|
2266
|
+
}), e.log("Snapper Mounted"), !0;
|
|
2243
2267
|
}
|
|
2244
|
-
unmount(
|
|
2268
|
+
unmount(t, e) {
|
|
2245
2269
|
var i;
|
|
2246
|
-
return (i =
|
|
2270
|
+
return (i = t.document.getElementById(Ot)) == null || i.remove(), e.log("Snapper Unmounted"), !0;
|
|
2247
2271
|
}
|
|
2248
2272
|
};
|
|
2249
|
-
|
|
2250
|
-
let
|
|
2251
|
-
function
|
|
2252
|
-
return
|
|
2273
|
+
Gt.moduleName = "snapper";
|
|
2274
|
+
let Yt = Gt;
|
|
2275
|
+
function F(s) {
|
|
2276
|
+
return s.document.body.dir.toLowerCase() === "rtl";
|
|
2253
2277
|
}
|
|
2254
|
-
function
|
|
2278
|
+
function Zt(s) {
|
|
2255
2279
|
return parseInt(
|
|
2256
|
-
|
|
2257
|
-
|
|
2280
|
+
s.getComputedStyle(
|
|
2281
|
+
s.document.documentElement
|
|
2258
2282
|
).getPropertyValue("column-count")
|
|
2259
2283
|
);
|
|
2260
2284
|
}
|
|
2261
|
-
function
|
|
2262
|
-
const
|
|
2263
|
-
return
|
|
2285
|
+
function It(s) {
|
|
2286
|
+
const t = getComputedStyle(s), e = parseFloat(t.paddingTop || "0"), i = parseFloat(t.paddingBottom || "0");
|
|
2287
|
+
return s.clientHeight - e - i;
|
|
2264
2288
|
}
|
|
2265
|
-
function
|
|
2266
|
-
const
|
|
2267
|
-
if (!
|
|
2289
|
+
function Lt(s) {
|
|
2290
|
+
const t = Zt(s);
|
|
2291
|
+
if (!t)
|
|
2268
2292
|
return !1;
|
|
2269
|
-
const
|
|
2270
|
-
for (const h of
|
|
2293
|
+
const e = s.document.querySelectorAll("div[id^='readium-virtual-page']");
|
|
2294
|
+
for (const h of e)
|
|
2271
2295
|
h.remove();
|
|
2272
|
-
const i =
|
|
2296
|
+
const i = e.length, r = s.document.scrollingElement.scrollWidth, n = s.visualViewport.width, l = Math.round(r / n * t) % t, c = t === 1 || l === 0 ? 0 : t - l;
|
|
2273
2297
|
if (c > 0)
|
|
2274
2298
|
for (let h = 0; h < c; h++) {
|
|
2275
|
-
const u =
|
|
2276
|
-
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height =
|
|
2299
|
+
const u = s.document.createElement("div");
|
|
2300
|
+
u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = It(s.document.documentElement) + "px"), u.innerHTML = "​", s.document.body.appendChild(u);
|
|
2277
2301
|
}
|
|
2278
2302
|
return i !== c;
|
|
2279
2303
|
}
|
|
2280
|
-
function
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2304
|
+
function Ue(s) {
|
|
2305
|
+
const t = s.document.createElement("style");
|
|
2306
|
+
t.appendChild(s.document.createTextNode("*{}")), s.document.body.appendChild(t), s.document.body.removeChild(t);
|
|
2283
2307
|
}
|
|
2284
|
-
function
|
|
2285
|
-
return
|
|
2308
|
+
function Be(s) {
|
|
2309
|
+
return s < 0.5 ? 2 * s * s : -1 + (4 - 2 * s) * s;
|
|
2286
2310
|
}
|
|
2287
|
-
function
|
|
2288
|
-
const
|
|
2289
|
-
|
|
2311
|
+
function S(s) {
|
|
2312
|
+
const t = s.getSelection();
|
|
2313
|
+
t && t.removeAllRanges();
|
|
2290
2314
|
}
|
|
2291
|
-
const
|
|
2315
|
+
const ke = [
|
|
2292
2316
|
"a",
|
|
2293
2317
|
"audio",
|
|
2294
2318
|
"button",
|
|
@@ -2302,57 +2326,57 @@ const Bt = [
|
|
|
2302
2326
|
"textarea",
|
|
2303
2327
|
"video"
|
|
2304
2328
|
];
|
|
2305
|
-
function
|
|
2306
|
-
var
|
|
2307
|
-
return
|
|
2329
|
+
function Kt(s) {
|
|
2330
|
+
var t;
|
|
2331
|
+
return ke.indexOf(s.nodeName.toLowerCase()) !== -1 || s.hasAttribute("contenteditable") && ((t = s.getAttribute("contenteditable")) == null ? void 0 : t.toLowerCase()) !== "false" ? s : s.parentElement ? Kt(s.parentElement) : null;
|
|
2308
2332
|
}
|
|
2309
|
-
function
|
|
2310
|
-
const
|
|
2333
|
+
function Jt(s, t) {
|
|
2334
|
+
const e = Qt(s, s.document.body, t), i = s._readium_cssSelectorGenerator.getCssSelector(e, {
|
|
2311
2335
|
selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
|
|
2312
2336
|
});
|
|
2313
|
-
return new
|
|
2337
|
+
return new W({
|
|
2314
2338
|
href: "#",
|
|
2315
2339
|
type: "application/xhtml+xml",
|
|
2316
|
-
locations: new
|
|
2340
|
+
locations: new E({
|
|
2317
2341
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2318
2342
|
["cssSelector", i]
|
|
2319
2343
|
])
|
|
2320
2344
|
}),
|
|
2321
|
-
text: new
|
|
2322
|
-
highlight:
|
|
2345
|
+
text: new $({
|
|
2346
|
+
highlight: e.textContent || void 0
|
|
2323
2347
|
})
|
|
2324
2348
|
});
|
|
2325
2349
|
}
|
|
2326
|
-
function
|
|
2327
|
-
for (var i = 0; i <
|
|
2328
|
-
const
|
|
2329
|
-
if (
|
|
2330
|
-
return
|
|
2350
|
+
function Qt(s, t, e) {
|
|
2351
|
+
for (var i = 0; i < t.children.length; i++) {
|
|
2352
|
+
const r = t.children[i];
|
|
2353
|
+
if (!Ve(r) && $e(s, r, e))
|
|
2354
|
+
return He(s, r) ? r : Qt(s, r, e);
|
|
2331
2355
|
}
|
|
2332
|
-
return
|
|
2356
|
+
return t;
|
|
2333
2357
|
}
|
|
2334
|
-
function
|
|
2335
|
-
if (
|
|
2358
|
+
function $e(s, t, e) {
|
|
2359
|
+
if (t === document.body || t === document.documentElement)
|
|
2336
2360
|
return !0;
|
|
2337
2361
|
if (!document || !document.documentElement || !document.body)
|
|
2338
2362
|
return !1;
|
|
2339
|
-
const i =
|
|
2340
|
-
return
|
|
2341
|
-
}
|
|
2342
|
-
function
|
|
2343
|
-
const
|
|
2344
|
-
return
|
|
2345
|
-
}
|
|
2346
|
-
function
|
|
2347
|
-
const
|
|
2348
|
-
if (
|
|
2349
|
-
const
|
|
2350
|
-
if (
|
|
2363
|
+
const i = t.getBoundingClientRect();
|
|
2364
|
+
return e ? i.bottom > 0 && i.top < s.innerHeight : i.right > 0 && i.left < s.innerWidth;
|
|
2365
|
+
}
|
|
2366
|
+
function He(s, t) {
|
|
2367
|
+
const e = t.getBoundingClientRect();
|
|
2368
|
+
return e.top >= 0 && e.left >= 0 && e.bottom <= s.innerHeight && e.right <= s.innerWidth;
|
|
2369
|
+
}
|
|
2370
|
+
function Ve(s) {
|
|
2371
|
+
const t = getComputedStyle(s);
|
|
2372
|
+
if (t) {
|
|
2373
|
+
const e = t.getPropertyValue("display");
|
|
2374
|
+
if (e != "block" && e != "list-item" || t.getPropertyValue("opacity") === "0")
|
|
2351
2375
|
return !0;
|
|
2352
2376
|
}
|
|
2353
2377
|
return !1;
|
|
2354
2378
|
}
|
|
2355
|
-
const
|
|
2379
|
+
const Rt = "readium-column-snapper-style", je = 200, te = class C extends Yt {
|
|
2356
2380
|
constructor() {
|
|
2357
2381
|
super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
|
|
2358
2382
|
}
|
|
@@ -2362,58 +2386,58 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2362
2386
|
scrollOffset() {
|
|
2363
2387
|
return this.doc().scrollLeft > 0 ? this.doc().scrollLeft : this.alreadyScrollLeft;
|
|
2364
2388
|
}
|
|
2365
|
-
snapOffset(
|
|
2366
|
-
const
|
|
2367
|
-
return
|
|
2389
|
+
snapOffset(t) {
|
|
2390
|
+
const e = t + (F(this.wnd) ? -1 : 1);
|
|
2391
|
+
return e - e % this.wnd.innerWidth;
|
|
2368
2392
|
}
|
|
2369
2393
|
reportProgress() {
|
|
2370
|
-
const
|
|
2394
|
+
const t = this.wnd.scrollX, e = this.cachedScrollWidth, i = Math.max(0, Math.min(1, t / e)), r = Math.max(0, Math.min(1, (t + this.wnd.innerWidth) / e));
|
|
2371
2395
|
this.comms.send("progress", {
|
|
2372
2396
|
start: i,
|
|
2373
|
-
end:
|
|
2397
|
+
end: r
|
|
2374
2398
|
});
|
|
2375
2399
|
}
|
|
2376
2400
|
shake() {
|
|
2377
2401
|
if (this.overscroll !== 0 || this.shakeTimeout !== 0)
|
|
2378
2402
|
return;
|
|
2379
|
-
const
|
|
2380
|
-
|
|
2381
|
-
const
|
|
2403
|
+
const t = this.doc();
|
|
2404
|
+
t.classList.add(F(this.wnd) ? "readium-bounce-l" : "readium-bounce-r");
|
|
2405
|
+
const e = this.scrollOffset();
|
|
2382
2406
|
this.shakeTimeout = this.wnd.setTimeout(() => {
|
|
2383
|
-
|
|
2407
|
+
t.classList.remove("readium-bounce-l"), t.classList.remove("readium-bounce-r"), this.shakeTimeout = 0, this.doc().scrollLeft = e;
|
|
2384
2408
|
}, 150);
|
|
2385
2409
|
}
|
|
2386
2410
|
// We have to cache this because during overscroll (transform, or left) the width is incorrect due to browser
|
|
2387
2411
|
takeOverSnap() {
|
|
2388
|
-
var
|
|
2412
|
+
var e;
|
|
2389
2413
|
this.snappingCancelled = !0, this.clearTouches();
|
|
2390
|
-
const
|
|
2391
|
-
this.overscroll = ((
|
|
2414
|
+
const t = this.doc();
|
|
2415
|
+
this.overscroll = ((e = t.style.transform) == null ? void 0 : e.length) > 12 ? parseFloat(t.style.transform.slice(12).split("px")[0]) : 0;
|
|
2392
2416
|
}
|
|
2393
2417
|
// Snaps the current offset to the page width.
|
|
2394
|
-
snapCurrentOffset(
|
|
2395
|
-
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft,
|
|
2418
|
+
snapCurrentOffset(t = !1, e = !1) {
|
|
2419
|
+
const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, r = this.doc(), n = this.dragOffset(), o = Zt(this.wnd), l = Math.min(Math.max(0, i), this.cachedScrollWidth), c = F(this.wnd) ? -1 : 1, h = (
|
|
2396
2420
|
// The hurdle to overcome in order to change pages
|
|
2397
2421
|
c * (this.wnd.innerWidth / 3) * (c * n > 0 ? 2 : 1)
|
|
2398
2422
|
), u = this.snapOffset(l + h);
|
|
2399
|
-
if (
|
|
2423
|
+
if (t && u !== this.scrollOffset()) {
|
|
2400
2424
|
this.snappingCancelled = !1;
|
|
2401
|
-
const p = (m, v,
|
|
2425
|
+
const p = (m, v, x, O) => x > O ? v : m + (v - m) * Be(x / O), d = (
|
|
2402
2426
|
/*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
|
|
2403
|
-
|
|
2427
|
+
je * o
|
|
2404
2428
|
);
|
|
2405
2429
|
let f;
|
|
2406
2430
|
const g = (m) => {
|
|
2407
2431
|
if (this.snappingCancelled)
|
|
2408
2432
|
return;
|
|
2409
2433
|
f || (f = m);
|
|
2410
|
-
const v = m - f,
|
|
2411
|
-
|
|
2434
|
+
const v = m - f, x = p(this.overscroll, 0, v, d), O = p(i, u, v, d);
|
|
2435
|
+
r.scrollLeft = O, this.overscroll !== 0 && (r.style.transform = `translate3d(${-x}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), r.style.removeProperty("transform"), r.scrollLeft = u, e || this.reportProgress());
|
|
2412
2436
|
};
|
|
2413
2437
|
this.wnd.requestAnimationFrame(g);
|
|
2414
2438
|
} else
|
|
2415
|
-
|
|
2416
|
-
|
|
2439
|
+
r.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
|
|
2440
|
+
r.scrollLeft = u, this.clearTouches(), e || this.reportProgress();
|
|
2417
2441
|
});
|
|
2418
2442
|
}
|
|
2419
2443
|
dragOffset() {
|
|
@@ -2422,43 +2446,43 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2422
2446
|
clearTouches() {
|
|
2423
2447
|
this.startingX = void 0, this.endingX = void 0, this.overscroll = 0;
|
|
2424
2448
|
}
|
|
2425
|
-
onTouchStart(
|
|
2426
|
-
switch (
|
|
2449
|
+
onTouchStart(t) {
|
|
2450
|
+
switch (t.stopPropagation(), this.takeOverSnap(), t.touches.length) {
|
|
2427
2451
|
case 1:
|
|
2428
2452
|
break;
|
|
2429
2453
|
case 2:
|
|
2430
|
-
this.onTouchEnd(
|
|
2454
|
+
this.onTouchEnd(t);
|
|
2431
2455
|
return;
|
|
2432
2456
|
default: {
|
|
2433
|
-
this.onTouchEnd(
|
|
2457
|
+
this.onTouchEnd(t), this.comms.send("tap_more", t.touches.length);
|
|
2434
2458
|
return;
|
|
2435
2459
|
}
|
|
2436
2460
|
}
|
|
2437
|
-
this.startingX =
|
|
2461
|
+
this.startingX = t.touches[0].clientX, this.alreadyScrollLeft = this.doc().scrollLeft, this.touchState = 1;
|
|
2438
2462
|
}
|
|
2439
|
-
onTouchEnd(
|
|
2463
|
+
onTouchEnd(t) {
|
|
2440
2464
|
if (this.touchState === 2) {
|
|
2441
|
-
const
|
|
2442
|
-
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(),
|
|
2465
|
+
const e = this.dragOffset(), i = this.scrollOffset();
|
|
2466
|
+
this.cachedScrollWidth <= this.wnd.innerWidth ? (this.reportProgress(), e > 5 && this.comms.send("no_more", void 0), e < -5 && this.comms.send("no_less", void 0)) : i < 5 && e < 5 ? (this.alreadyScrollLeft = 0, this.comms.send("no_less", void 0)) : this.cachedScrollWidth - i - this.wnd.innerWidth < 5 && e > 5 && (this.alreadyScrollLeft = this.cachedScrollWidth, this.comms.send("no_more", void 0)), this.snapCurrentOffset(!0), this.comms.send("swipe", e);
|
|
2443
2467
|
}
|
|
2444
2468
|
this.touchState = 0;
|
|
2445
2469
|
}
|
|
2446
2470
|
onWidthChange() {
|
|
2447
2471
|
this.cachedScrollWidth = this.doc().scrollWidth, this.comms.ready && this.snapCurrentOffset();
|
|
2448
2472
|
}
|
|
2449
|
-
onTouchMove(
|
|
2473
|
+
onTouchMove(t) {
|
|
2450
2474
|
if (this.touchState === 0)
|
|
2451
2475
|
return;
|
|
2452
|
-
this.touchState === 1 && (this.touchState = 2,
|
|
2453
|
-
const
|
|
2454
|
-
i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft +
|
|
2476
|
+
this.touchState === 1 && (this.touchState = 2, S(this.wnd)), this.endingX = t.touches[0].clientX;
|
|
2477
|
+
const e = this.dragOffset(), i = this.alreadyScrollLeft + e;
|
|
2478
|
+
i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + e);
|
|
2455
2479
|
}
|
|
2456
|
-
mount(
|
|
2457
|
-
if (this.wnd =
|
|
2480
|
+
mount(t, e) {
|
|
2481
|
+
if (this.wnd = t, this.comms = e, !super.mount(t, e))
|
|
2458
2482
|
return !1;
|
|
2459
|
-
|
|
2460
|
-
const i =
|
|
2461
|
-
i.dataset.readium = "true", i.id =
|
|
2483
|
+
t.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2484
|
+
const i = t.document.createElement("style");
|
|
2485
|
+
i.dataset.readium = "true", i.id = Rt, i.textContent = `
|
|
2462
2486
|
@keyframes readium-bounce-l-animation {
|
|
2463
2487
|
0%, 100% {transform: translate3d(0, 0, 0);}
|
|
2464
2488
|
50% {transform: translate3d(-50px, 0, 0);}
|
|
@@ -2492,54 +2516,54 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2492
2516
|
body::-webkit-scrollbar {
|
|
2493
2517
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2494
2518
|
}
|
|
2495
|
-
`,
|
|
2496
|
-
|
|
2497
|
-
|
|
2519
|
+
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2520
|
+
t.requestAnimationFrame(() => {
|
|
2521
|
+
t && Lt(t);
|
|
2498
2522
|
}), this.onWidthChange();
|
|
2499
|
-
}), this.resizeObserver.observe(
|
|
2523
|
+
}), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((n) => {
|
|
2500
2524
|
for (const o of n)
|
|
2501
2525
|
if (o.target === this.wnd.document.documentElement) {
|
|
2502
2526
|
const l = o.oldValue, c = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = l == null ? void 0 : l.match(h), p = c == null ? void 0 : c.match(h);
|
|
2503
|
-
(!u && !p || u && !p || u && p && u[1] !== p[1]) && (
|
|
2504
|
-
|
|
2527
|
+
(!u && !p || u && !p || u && p && u[1] !== p[1]) && (t.requestAnimationFrame(() => {
|
|
2528
|
+
t && Lt(t);
|
|
2505
2529
|
}), this.onWidthChange());
|
|
2506
2530
|
} else
|
|
2507
|
-
|
|
2508
|
-
}),
|
|
2509
|
-
const
|
|
2531
|
+
t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth);
|
|
2532
|
+
}), t.frameElement && this.mutationObserver.observe(t.frameElement, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document, { attributes: !0, attributeFilter: ["style"] }), this.mutationObserver.observe(t.document.documentElement, { attributes: !0, attributeFilter: ["style"] });
|
|
2533
|
+
const r = (n) => {
|
|
2510
2534
|
const o = this.doc().scrollLeft;
|
|
2511
2535
|
return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
|
|
2512
2536
|
};
|
|
2513
|
-
return
|
|
2537
|
+
return t.addEventListener("orientationchange", this.onWidthChanger), t.addEventListener("resize", this.onWidthChanger), t.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), e.register("go_progression", C.moduleName, (n, o) => {
|
|
2514
2538
|
const l = n;
|
|
2515
2539
|
if (l < 0 || l > 1) {
|
|
2516
|
-
|
|
2540
|
+
e.send("error", {
|
|
2517
2541
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2518
2542
|
}), o(!1);
|
|
2519
2543
|
return;
|
|
2520
2544
|
}
|
|
2521
2545
|
this.wnd.requestAnimationFrame(() => {
|
|
2522
2546
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2523
|
-
const c = this.cachedScrollWidth, h =
|
|
2524
|
-
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(),
|
|
2547
|
+
const c = this.cachedScrollWidth, h = F(t) ? -1 : 1, u = c * l * h;
|
|
2548
|
+
this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), S(this.wnd), o(!0);
|
|
2525
2549
|
});
|
|
2526
|
-
}),
|
|
2527
|
-
const l =
|
|
2550
|
+
}), e.register("go_id", C.moduleName, (n, o) => {
|
|
2551
|
+
const l = t.document.getElementById(n);
|
|
2528
2552
|
if (!l) {
|
|
2529
2553
|
o(!1);
|
|
2530
2554
|
return;
|
|
2531
2555
|
}
|
|
2532
2556
|
this.wnd.requestAnimationFrame(() => {
|
|
2533
|
-
this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left +
|
|
2557
|
+
this.doc().scrollLeft = this.snapOffset(l.getBoundingClientRect().left + t.scrollX), this.reportProgress(), S(this.wnd), o(!0);
|
|
2534
2558
|
});
|
|
2535
|
-
}),
|
|
2559
|
+
}), e.register("go_text", C.moduleName, (n, o) => {
|
|
2536
2560
|
let l;
|
|
2537
2561
|
Array.isArray(n) && (n.length > 1 && (l = n[1]), n = n[0]);
|
|
2538
|
-
const c =
|
|
2539
|
-
href:
|
|
2562
|
+
const c = $.deserialize(n), h = ct(this.wnd.document, new W({
|
|
2563
|
+
href: t.location.href,
|
|
2540
2564
|
type: "text/html",
|
|
2541
2565
|
text: c,
|
|
2542
|
-
locations: l ? new
|
|
2566
|
+
locations: l ? new E({
|
|
2543
2567
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2544
2568
|
["cssSelector", l]
|
|
2545
2569
|
])
|
|
@@ -2550,57 +2574,57 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
|
|
|
2550
2574
|
return;
|
|
2551
2575
|
}
|
|
2552
2576
|
this.wnd.requestAnimationFrame(() => {
|
|
2553
|
-
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left +
|
|
2577
|
+
this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), S(this.wnd), o(!0);
|
|
2554
2578
|
});
|
|
2555
|
-
}),
|
|
2556
|
-
const l =
|
|
2579
|
+
}), e.register("go_end", C.moduleName, (n, o) => {
|
|
2580
|
+
const l = F(t) ? -1 : 1;
|
|
2557
2581
|
this.wnd.requestAnimationFrame(() => {
|
|
2558
2582
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2559
2583
|
const c = this.cachedScrollWidth * l;
|
|
2560
2584
|
if (this.doc().scrollLeft === c)
|
|
2561
2585
|
return o(!1);
|
|
2562
|
-
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(),
|
|
2586
|
+
this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), S(this.wnd), o(!0);
|
|
2563
2587
|
});
|
|
2564
|
-
}),
|
|
2588
|
+
}), e.register("go_start", C.moduleName, (n, o) => {
|
|
2565
2589
|
this.wnd.requestAnimationFrame(() => {
|
|
2566
2590
|
if (this.doc().scrollLeft === 0)
|
|
2567
2591
|
return o(!1);
|
|
2568
|
-
this.doc().scrollLeft = 0, this.reportProgress(),
|
|
2592
|
+
this.doc().scrollLeft = 0, this.reportProgress(), S(this.wnd), o(!0);
|
|
2569
2593
|
});
|
|
2570
|
-
}),
|
|
2594
|
+
}), e.register("go_prev", C.moduleName, (n, o) => {
|
|
2571
2595
|
this.wnd.requestAnimationFrame(() => {
|
|
2572
2596
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2573
|
-
const l =
|
|
2574
|
-
h && (this.reportProgress(),
|
|
2597
|
+
const l = t.scrollX - t.innerWidth, c = F(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = r(Math.max(l, c));
|
|
2598
|
+
h && (this.reportProgress(), S(this.wnd)), o(h);
|
|
2575
2599
|
});
|
|
2576
|
-
}),
|
|
2600
|
+
}), e.register("go_next", C.moduleName, (n, o) => {
|
|
2577
2601
|
this.wnd.requestAnimationFrame(() => {
|
|
2578
2602
|
this.cachedScrollWidth = this.doc().scrollWidth;
|
|
2579
|
-
const l =
|
|
2580
|
-
h && (this.reportProgress(),
|
|
2603
|
+
const l = t.scrollX + t.innerWidth, c = F(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = r(Math.min(l, c));
|
|
2604
|
+
h && (this.reportProgress(), S(this.wnd)), o(h);
|
|
2581
2605
|
});
|
|
2582
|
-
}),
|
|
2583
|
-
this.snappingCancelled = !0,
|
|
2584
|
-
}),
|
|
2606
|
+
}), e.register("unfocus", C.moduleName, (n, o) => {
|
|
2607
|
+
this.snappingCancelled = !0, S(this.wnd), o(!0);
|
|
2608
|
+
}), e.register("shake", C.moduleName, (n, o) => {
|
|
2585
2609
|
this.shake(), o(!0);
|
|
2586
|
-
}),
|
|
2610
|
+
}), e.register("focus", C.moduleName, (n, o) => {
|
|
2587
2611
|
this.wnd.requestAnimationFrame(() => {
|
|
2588
2612
|
this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
|
|
2589
2613
|
});
|
|
2590
|
-
}),
|
|
2591
|
-
const l =
|
|
2614
|
+
}), e.register("first_visible_locator", C.moduleName, (n, o) => {
|
|
2615
|
+
const l = Jt(t, !1);
|
|
2592
2616
|
this.comms.send("first_visible_locator", l.serialize()), o(!0);
|
|
2593
|
-
}),
|
|
2594
|
-
}),
|
|
2617
|
+
}), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
|
|
2618
|
+
}), e.log("ColumnSnapper Mounted"), !0;
|
|
2595
2619
|
}
|
|
2596
|
-
unmount(
|
|
2620
|
+
unmount(t, e) {
|
|
2597
2621
|
var i;
|
|
2598
|
-
return this.snappingCancelled = !0,
|
|
2622
|
+
return this.snappingCancelled = !0, e.unregisterAll(C.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), t.removeEventListener("touchstart", this.onTouchStarter), t.removeEventListener("touchend", this.onTouchEnder), t.removeEventListener("touchmove", this.onTouchMover), t.removeEventListener("orientationchange", this.onWidthChanger), t.removeEventListener("resize", this.onWidthChanger), (i = t.document.getElementById(Rt)) == null || i.remove(), e.log("ColumnSnapper Unmounted"), super.unmount(t, e);
|
|
2599
2623
|
}
|
|
2600
2624
|
};
|
|
2601
|
-
|
|
2602
|
-
let
|
|
2603
|
-
const
|
|
2625
|
+
te.moduleName = "column_snapper";
|
|
2626
|
+
let qe = te;
|
|
2627
|
+
const zt = "readium-scroll-snapper-style", ee = class P extends Yt {
|
|
2604
2628
|
constructor() {
|
|
2605
2629
|
super(...arguments), this.initialScrollHandled = !1, this.isScrolling = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce = null, this.handleScroll = () => {
|
|
2606
2630
|
if (this.comms.ready && !this.isResizing) {
|
|
@@ -2610,8 +2634,8 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
|
|
|
2610
2634
|
}
|
|
2611
2635
|
this.isScrolling || (this.isScrolling = !0, this.wnd.requestAnimationFrame(() => {
|
|
2612
2636
|
this.reportProgress();
|
|
2613
|
-
const
|
|
2614
|
-
this.lastScrollTop =
|
|
2637
|
+
const t = this.doc().scrollTop, e = t - this.lastScrollTop;
|
|
2638
|
+
this.lastScrollTop = t, this.comms.send("scroll", e), this.isScrolling = !1;
|
|
2615
2639
|
}));
|
|
2616
2640
|
}
|
|
2617
2641
|
};
|
|
@@ -2622,16 +2646,16 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
|
|
|
2622
2646
|
reportProgress() {
|
|
2623
2647
|
if (!this.comms.ready)
|
|
2624
2648
|
return;
|
|
2625
|
-
const
|
|
2649
|
+
const t = Math.ceil(this.doc().scrollTop), e = this.doc().scrollHeight, i = this.wnd.innerHeight, r = Math.max(0, Math.min(1, t / e)), n = Math.max(0, Math.min(1, (t + i) / e));
|
|
2626
2650
|
this.comms.send("progress", {
|
|
2627
|
-
start:
|
|
2651
|
+
start: r,
|
|
2628
2652
|
end: n
|
|
2629
2653
|
});
|
|
2630
2654
|
}
|
|
2631
|
-
mount(
|
|
2632
|
-
this.wnd =
|
|
2633
|
-
const i =
|
|
2634
|
-
return i.dataset.readium = "true", i.id =
|
|
2655
|
+
mount(t, e) {
|
|
2656
|
+
this.wnd = t, this.comms = e, this.initialScrollHandled = !1, this.lastScrollTop = 0, this.isResizing = !1, this.resizeDebounce && (this.wnd.clearTimeout(this.resizeDebounce), this.resizeDebounce = null), t.navigator.epubReadingSystem.layoutStyle = "scrolling";
|
|
2657
|
+
const i = t.document.createElement("style");
|
|
2658
|
+
return i.dataset.readium = "true", i.id = zt, i.textContent = `
|
|
2635
2659
|
* {
|
|
2636
2660
|
scrollbar-width: none; /* for Firefox */
|
|
2637
2661
|
}
|
|
@@ -2639,42 +2663,42 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
|
|
|
2639
2663
|
body::-webkit-scrollbar {
|
|
2640
2664
|
display: none; /* for Chrome, Safari, and Opera */
|
|
2641
2665
|
}
|
|
2642
|
-
`,
|
|
2666
|
+
`, t.document.head.appendChild(i), this.resizeObserver = new ResizeObserver(() => {
|
|
2643
2667
|
this.resizeDebounce && this.wnd.clearTimeout(this.resizeDebounce), this.isResizing = !0, this.resizeDebounce = this.wnd.setTimeout(() => {
|
|
2644
2668
|
this.isResizing = !1, this.resizeDebounce = null, this.reportProgress();
|
|
2645
2669
|
}, 50);
|
|
2646
|
-
}), this.resizeObserver.observe(
|
|
2647
|
-
|
|
2648
|
-
const
|
|
2649
|
-
|
|
2650
|
-
}),
|
|
2651
|
-
const o =
|
|
2670
|
+
}), this.resizeObserver.observe(t.document.body), t.addEventListener("scroll", this.handleScroll, { passive: !0 }), e.register("force_webkit_recalc", P.moduleName, () => {
|
|
2671
|
+
Ue(this.wnd);
|
|
2672
|
+
const r = this.doc().scrollTop;
|
|
2673
|
+
r > 1 ? this.doc().scrollTop = r - 1 : this.doc().scrollTop = r + 1, this.doc().scrollTop = r;
|
|
2674
|
+
}), e.register("go_progression", P.moduleName, (r, n) => {
|
|
2675
|
+
const o = r;
|
|
2652
2676
|
if (o < 0 || o > 1) {
|
|
2653
|
-
|
|
2677
|
+
e.send("error", {
|
|
2654
2678
|
message: "go_progression must be given a position from 0.0 to 1.0"
|
|
2655
2679
|
}), n(!1);
|
|
2656
2680
|
return;
|
|
2657
2681
|
}
|
|
2658
2682
|
this.wnd.requestAnimationFrame(() => {
|
|
2659
|
-
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(),
|
|
2683
|
+
this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress(), S(this.wnd), n(!0);
|
|
2660
2684
|
});
|
|
2661
|
-
}),
|
|
2662
|
-
const o =
|
|
2685
|
+
}), e.register("go_id", P.moduleName, (r, n) => {
|
|
2686
|
+
const o = t.document.getElementById(r);
|
|
2663
2687
|
if (!o) {
|
|
2664
2688
|
n(!1);
|
|
2665
2689
|
return;
|
|
2666
2690
|
}
|
|
2667
2691
|
this.wnd.requestAnimationFrame(() => {
|
|
2668
|
-
this.doc().scrollTop = o.getBoundingClientRect().top +
|
|
2692
|
+
this.doc().scrollTop = o.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
|
|
2669
2693
|
});
|
|
2670
|
-
}),
|
|
2694
|
+
}), e.register("go_text", P.moduleName, (r, n) => {
|
|
2671
2695
|
let o;
|
|
2672
|
-
Array.isArray(
|
|
2673
|
-
const l =
|
|
2674
|
-
href:
|
|
2696
|
+
Array.isArray(r) && (r.length > 1 && (o = r[1]), r = r[0]);
|
|
2697
|
+
const l = $.deserialize(r), c = ct(this.wnd.document, new W({
|
|
2698
|
+
href: t.location.href,
|
|
2675
2699
|
type: "text/html",
|
|
2676
2700
|
text: l,
|
|
2677
|
-
locations: o ? new
|
|
2701
|
+
locations: o ? new E({
|
|
2678
2702
|
otherLocations: /* @__PURE__ */ new Map([
|
|
2679
2703
|
["cssSelector", o]
|
|
2680
2704
|
])
|
|
@@ -2685,48 +2709,48 @@ const Le = "readium-scroll-snapper-style", Qe = class P extends Xe {
|
|
|
2685
2709
|
return;
|
|
2686
2710
|
}
|
|
2687
2711
|
this.wnd.requestAnimationFrame(() => {
|
|
2688
|
-
this.doc().scrollTop = c.getBoundingClientRect().top +
|
|
2712
|
+
this.doc().scrollTop = c.getBoundingClientRect().top + t.scrollY - t.innerHeight / 2, this.reportProgress(), S(this.wnd), n(!0);
|
|
2689
2713
|
});
|
|
2690
|
-
}),
|
|
2714
|
+
}), e.register("go_start", P.moduleName, (r, n) => {
|
|
2691
2715
|
if (this.doc().scrollTop === 0)
|
|
2692
2716
|
return n(!1);
|
|
2693
2717
|
this.doc().scrollTop = 0, this.reportProgress(), n(!0);
|
|
2694
|
-
}),
|
|
2718
|
+
}), e.register("go_end", P.moduleName, (r, n) => {
|
|
2695
2719
|
if (this.doc().scrollTop === this.doc().scrollHeight - this.doc().offsetHeight)
|
|
2696
2720
|
return n(!1);
|
|
2697
2721
|
this.doc().scrollTop = this.doc().scrollHeight - this.doc().offsetHeight, this.reportProgress(), n(!0);
|
|
2698
|
-
}),
|
|
2699
|
-
|
|
2700
|
-
}),
|
|
2722
|
+
}), e.register("unfocus", P.moduleName, (r, n) => {
|
|
2723
|
+
S(this.wnd), n(!0);
|
|
2724
|
+
}), e.register([
|
|
2701
2725
|
"go_next",
|
|
2702
2726
|
"go_prev"
|
|
2703
|
-
], P.moduleName, (
|
|
2727
|
+
], P.moduleName, (r, n) => n(!1)), e.register("focus", P.moduleName, (r, n) => {
|
|
2704
2728
|
this.reportProgress(), n(!0);
|
|
2705
|
-
}),
|
|
2706
|
-
const o =
|
|
2729
|
+
}), e.register("first_visible_locator", P.moduleName, (r, n) => {
|
|
2730
|
+
const o = Jt(t, !0);
|
|
2707
2731
|
this.comms.send("first_visible_locator", o.serialize()), n(!0);
|
|
2708
|
-
}),
|
|
2732
|
+
}), e.log("ScrollSnapper Mounted"), !0;
|
|
2709
2733
|
}
|
|
2710
|
-
unmount(
|
|
2734
|
+
unmount(t, e) {
|
|
2711
2735
|
var i;
|
|
2712
|
-
return
|
|
2736
|
+
return e.unregisterAll(P.moduleName), this.resizeObserver.disconnect(), this.handleScroll && t.removeEventListener("scroll", this.handleScroll), (i = t.document.getElementById(zt)) == null || i.remove(), e.log("ScrollSnapper Unmounted"), !0;
|
|
2713
2737
|
}
|
|
2714
2738
|
};
|
|
2715
|
-
|
|
2716
|
-
let
|
|
2717
|
-
class
|
|
2739
|
+
ee.moduleName = "scroll_snapper";
|
|
2740
|
+
let _e = ee;
|
|
2741
|
+
class ie extends K {
|
|
2718
2742
|
constructor() {
|
|
2719
2743
|
super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);
|
|
2720
2744
|
}
|
|
2721
|
-
onPointUp(
|
|
2722
|
-
var
|
|
2723
|
-
const
|
|
2724
|
-
if (
|
|
2725
|
-
const h = (n =
|
|
2745
|
+
onPointUp(t) {
|
|
2746
|
+
var r, n, o, l, c;
|
|
2747
|
+
const e = this.wnd.getSelection();
|
|
2748
|
+
if (e && ((r = e.toString()) == null ? void 0 : r.length) > 0) {
|
|
2749
|
+
const h = (n = e.getRangeAt(0)) == null ? void 0 : n.getClientRects();
|
|
2726
2750
|
if (!h || h.length === 0)
|
|
2727
2751
|
return;
|
|
2728
2752
|
const u = h[0], p = {
|
|
2729
|
-
text:
|
|
2753
|
+
text: e.toString(),
|
|
2730
2754
|
x: u.x,
|
|
2731
2755
|
y: u.y,
|
|
2732
2756
|
width: u.width,
|
|
@@ -2739,22 +2763,22 @@ class et extends Y {
|
|
|
2739
2763
|
this.pointerMoved = !1;
|
|
2740
2764
|
return;
|
|
2741
2765
|
}
|
|
2742
|
-
if (!(
|
|
2766
|
+
if (!(e != null && e.isCollapsed) || !t.isPrimary)
|
|
2743
2767
|
return;
|
|
2744
2768
|
const i = this.wnd.devicePixelRatio;
|
|
2745
|
-
|
|
2746
|
-
defaultPrevented:
|
|
2747
|
-
x:
|
|
2748
|
-
y:
|
|
2769
|
+
t.preventDefault(), this.comms.send(t.pointerType === "touch" ? "tap" : "click", {
|
|
2770
|
+
defaultPrevented: t.defaultPrevented,
|
|
2771
|
+
x: t.clientX * i,
|
|
2772
|
+
y: t.clientY * i,
|
|
2749
2773
|
targetFrameSrc: this.wnd.location.href,
|
|
2750
|
-
targetElement:
|
|
2751
|
-
interactiveElement: (c =
|
|
2752
|
-
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(
|
|
2774
|
+
targetElement: t.target.outerHTML,
|
|
2775
|
+
interactiveElement: (c = Kt(t.target)) == null ? void 0 : c.outerHTML,
|
|
2776
|
+
cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(t.target)
|
|
2753
2777
|
}), this.pointerMoved = !1;
|
|
2754
2778
|
}
|
|
2755
|
-
onPointMove(
|
|
2756
|
-
if (
|
|
2757
|
-
(Math.abs(
|
|
2779
|
+
onPointMove(t) {
|
|
2780
|
+
if (t.movementY !== void 0 && t.movementX !== void 0) {
|
|
2781
|
+
(Math.abs(t.movementX) > 1 || Math.abs(t.movementY) > 1) && (this.pointerMoved = !0);
|
|
2758
2782
|
return;
|
|
2759
2783
|
}
|
|
2760
2784
|
this.pointerMoved = !0;
|
|
@@ -2762,86 +2786,86 @@ class et extends Y {
|
|
|
2762
2786
|
onPointDown() {
|
|
2763
2787
|
this.pointerMoved = !1;
|
|
2764
2788
|
}
|
|
2765
|
-
onContext(
|
|
2766
|
-
this.onPointUp(
|
|
2789
|
+
onContext(t) {
|
|
2790
|
+
this.onPointUp(t), this.pointerMoved = !1;
|
|
2767
2791
|
}
|
|
2768
|
-
onClick(
|
|
2769
|
-
if (
|
|
2770
|
-
const
|
|
2792
|
+
onClick(t) {
|
|
2793
|
+
if (t.preventDefault(), !t.isTrusted) {
|
|
2794
|
+
const e = new PointerEvent("pointerup", {
|
|
2771
2795
|
isPrimary: !0,
|
|
2772
2796
|
pointerType: "mouse",
|
|
2773
2797
|
// Not really a better choice than this
|
|
2774
|
-
clientX:
|
|
2775
|
-
clientY:
|
|
2798
|
+
clientX: t.clientX,
|
|
2799
|
+
clientY: t.clientY
|
|
2776
2800
|
});
|
|
2777
|
-
Object.defineProperty(
|
|
2801
|
+
Object.defineProperty(e, "target", { writable: !1, value: t.target }), Object.defineProperty(e, "defaultPrevented", { writable: !1, value: t.defaultPrevented }), this.onPointUp(e);
|
|
2778
2802
|
}
|
|
2779
2803
|
}
|
|
2780
|
-
mount(
|
|
2781
|
-
return this.wnd =
|
|
2804
|
+
mount(t, e) {
|
|
2805
|
+
return this.wnd = t, this.comms = e, t.document.addEventListener("pointerdown", this.onPointerDown), t.document.addEventListener("pointerup", this.onPointerUp), t.document.addEventListener("contextmenu", this.onContextMenu), t.document.addEventListener("pointermove", this.onPointerMove), t.document.addEventListener("click", this.onClicker), e.log("Peripherals Mounted"), !0;
|
|
2782
2806
|
}
|
|
2783
|
-
unmount(
|
|
2784
|
-
return
|
|
2807
|
+
unmount(t, e) {
|
|
2808
|
+
return t.document.removeEventListener("pointerdown", this.onPointerDown), t.document.removeEventListener("pointerup", this.onPointerUp), t.document.removeEventListener("contextmenu", this.onContextMenu), t.document.removeEventListener("pointermove", this.onPointerMove), t.document.removeEventListener("click", this.onClicker), e.log("Peripherals Unmounted"), !0;
|
|
2785
2809
|
}
|
|
2786
2810
|
}
|
|
2787
|
-
|
|
2788
|
-
const
|
|
2811
|
+
ie.moduleName = "peripherals";
|
|
2812
|
+
const se = class st extends K {
|
|
2789
2813
|
constructor() {
|
|
2790
2814
|
super(...arguments), this.mediaPlayingCount = 0, this.allAnimations = /* @__PURE__ */ new Set();
|
|
2791
2815
|
}
|
|
2792
|
-
wndOnErr(
|
|
2793
|
-
var
|
|
2794
|
-
(
|
|
2795
|
-
message:
|
|
2796
|
-
filename:
|
|
2797
|
-
lineno:
|
|
2798
|
-
colno:
|
|
2816
|
+
wndOnErr(t) {
|
|
2817
|
+
var e;
|
|
2818
|
+
(e = this.comms) == null || e.send("error", {
|
|
2819
|
+
message: t.message,
|
|
2820
|
+
filename: t.filename,
|
|
2821
|
+
lineno: t.lineno,
|
|
2822
|
+
colno: t.colno
|
|
2799
2823
|
});
|
|
2800
2824
|
}
|
|
2801
|
-
unblock(
|
|
2802
|
-
var
|
|
2803
|
-
for (
|
|
2804
|
-
const i =
|
|
2825
|
+
unblock(t) {
|
|
2826
|
+
var e;
|
|
2827
|
+
for (t._readium_blockEvents = !1; ((e = t._readium_blockedEvents) == null ? void 0 : e.length) > 0; ) {
|
|
2828
|
+
const i = t._readium_blockedEvents.shift();
|
|
2805
2829
|
switch (i[0]) {
|
|
2806
2830
|
case 0:
|
|
2807
2831
|
Reflect.apply(i[1], i[2], i[3]);
|
|
2808
2832
|
break;
|
|
2809
2833
|
case 1:
|
|
2810
|
-
const
|
|
2811
|
-
|
|
2812
|
-
const o = new Event(
|
|
2813
|
-
bubbles:
|
|
2814
|
-
cancelable:
|
|
2834
|
+
const r = i[1], n = i[2];
|
|
2835
|
+
t.removeEventListener(r.type, t._readium_eventBlocker, !0);
|
|
2836
|
+
const o = new Event(r.type, {
|
|
2837
|
+
bubbles: r.bubbles,
|
|
2838
|
+
cancelable: r.cancelable
|
|
2815
2839
|
});
|
|
2816
|
-
n ? n.dispatchEvent(o) :
|
|
2840
|
+
n ? n.dispatchEvent(o) : t.dispatchEvent(o);
|
|
2817
2841
|
break;
|
|
2818
2842
|
}
|
|
2819
2843
|
}
|
|
2820
2844
|
}
|
|
2821
2845
|
onMediaPlayEvent() {
|
|
2822
|
-
var
|
|
2823
|
-
this.mediaPlayingCount++, (
|
|
2846
|
+
var t;
|
|
2847
|
+
this.mediaPlayingCount++, (t = this.comms) == null || t.send("media_play", this.mediaPlayingCount);
|
|
2824
2848
|
}
|
|
2825
2849
|
onMediaPauseEvent() {
|
|
2826
|
-
var
|
|
2827
|
-
this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (
|
|
2850
|
+
var t;
|
|
2851
|
+
this.mediaPlayingCount > 0 && this.mediaPlayingCount--, (t = this.comms) == null || t.send("media_pause", this.mediaPlayingCount);
|
|
2828
2852
|
}
|
|
2829
|
-
pauseAllMedia(
|
|
2830
|
-
const
|
|
2831
|
-
for (let i = 0; i <
|
|
2832
|
-
|
|
2853
|
+
pauseAllMedia(t) {
|
|
2854
|
+
const e = t.document.querySelectorAll("audio,video");
|
|
2855
|
+
for (let i = 0; i < e.length; i++)
|
|
2856
|
+
e[i].pause();
|
|
2833
2857
|
}
|
|
2834
|
-
mount(
|
|
2835
|
-
this.comms =
|
|
2858
|
+
mount(t, e) {
|
|
2859
|
+
this.comms = e, t.addEventListener(
|
|
2836
2860
|
"error",
|
|
2837
2861
|
this.wndOnErr,
|
|
2838
2862
|
!1
|
|
2839
|
-
), Reflect.defineProperty(
|
|
2863
|
+
), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
|
|
2840
2864
|
value: {
|
|
2841
2865
|
name: "readium-ts-toolkit",
|
|
2842
|
-
version: "2.
|
|
2843
|
-
hasFeature: (
|
|
2844
|
-
switch (
|
|
2866
|
+
version: "2.1.0",
|
|
2867
|
+
hasFeature: (r, n = "") => {
|
|
2868
|
+
switch (r) {
|
|
2845
2869
|
case "dom-manipulation":
|
|
2846
2870
|
return !0;
|
|
2847
2871
|
case "layout-changes":
|
|
@@ -2862,73 +2886,73 @@ const tt = class te extends Y {
|
|
|
2862
2886
|
}
|
|
2863
2887
|
},
|
|
2864
2888
|
writable: !1
|
|
2865
|
-
}), "getAnimations" in
|
|
2866
|
-
|
|
2867
|
-
}),
|
|
2889
|
+
}), "getAnimations" in t.document && t.document.getAnimations().forEach((r) => {
|
|
2890
|
+
r.cancel(), this.allAnimations.add(r);
|
|
2891
|
+
}), e.register("activate", st.moduleName, (r, n) => {
|
|
2868
2892
|
this.allAnimations.forEach((o) => {
|
|
2869
2893
|
o.cancel(), o.play();
|
|
2870
2894
|
}), n(!0);
|
|
2871
|
-
}),
|
|
2872
|
-
this.pauseAllMedia(
|
|
2895
|
+
}), e.register("unfocus", st.moduleName, (r, n) => {
|
|
2896
|
+
this.pauseAllMedia(t), this.allAnimations.forEach((o) => o.pause()), n(!0);
|
|
2873
2897
|
});
|
|
2874
|
-
const i =
|
|
2875
|
-
for (let
|
|
2876
|
-
const n = i[
|
|
2898
|
+
const i = t.document.querySelectorAll("audio,video");
|
|
2899
|
+
for (let r = 0; r < i.length; r++) {
|
|
2900
|
+
const n = i[r];
|
|
2877
2901
|
n.addEventListener("play", this.onMediaPlayEvent, {
|
|
2878
2902
|
passive: !0
|
|
2879
2903
|
}), n.addEventListener("pause", this.onMediaPauseEvent, {
|
|
2880
2904
|
passive: !0
|
|
2881
2905
|
});
|
|
2882
2906
|
}
|
|
2883
|
-
return
|
|
2907
|
+
return e.log("Setup Mounted"), !0;
|
|
2884
2908
|
}
|
|
2885
|
-
unmount(
|
|
2886
|
-
return
|
|
2909
|
+
unmount(t, e) {
|
|
2910
|
+
return t.removeEventListener("error", this.wndOnErr), t.removeEventListener("play", this.onMediaPlayEvent), t.removeEventListener("pause", this.onMediaPauseEvent), this.allAnimations.forEach((i) => i.cancel()), this.allAnimations.clear(), e.log("Setup Unmounted"), !0;
|
|
2887
2911
|
}
|
|
2888
2912
|
};
|
|
2889
|
-
|
|
2890
|
-
let
|
|
2891
|
-
const
|
|
2892
|
-
onViewportWidthChanged(
|
|
2893
|
-
const
|
|
2894
|
-
|
|
2895
|
-
}
|
|
2896
|
-
mount(
|
|
2897
|
-
if (!super.mount(
|
|
2913
|
+
se.moduleName = "setup";
|
|
2914
|
+
let re = se;
|
|
2915
|
+
const Dt = "readium-viewport", ne = class U extends re {
|
|
2916
|
+
onViewportWidthChanged(t) {
|
|
2917
|
+
const e = t.target;
|
|
2918
|
+
Z(e, "--RS__viewportWidth", `${e.innerWidth}px`);
|
|
2919
|
+
}
|
|
2920
|
+
mount(t, e) {
|
|
2921
|
+
if (!super.mount(t, e))
|
|
2898
2922
|
return !1;
|
|
2899
|
-
const i =
|
|
2900
|
-
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id",
|
|
2923
|
+
const i = t.document.createElement("meta");
|
|
2924
|
+
return i.dataset.readium = "true", i.setAttribute("name", "viewport"), i.setAttribute("id", Dt), i.setAttribute(
|
|
2901
2925
|
"content",
|
|
2902
2926
|
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no"
|
|
2903
|
-
),
|
|
2904
|
-
target:
|
|
2905
|
-
}),
|
|
2906
|
-
|
|
2907
|
-
}),
|
|
2908
|
-
|
|
2909
|
-
}),
|
|
2910
|
-
const o =
|
|
2911
|
-
|
|
2912
|
-
}),
|
|
2913
|
-
|
|
2914
|
-
}),
|
|
2915
|
-
this.unblock(
|
|
2916
|
-
}),
|
|
2917
|
-
}
|
|
2918
|
-
unmount(
|
|
2927
|
+
), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
|
|
2928
|
+
target: t
|
|
2929
|
+
}), e.register("get_properties", U.moduleName, (r, n) => {
|
|
2930
|
+
_t(t), n(!0);
|
|
2931
|
+
}), e.register("update_properties", U.moduleName, (r, n) => {
|
|
2932
|
+
r["--RS__viewportWidth"] = `${t.innerWidth}px`, Ae(t, r), n(!0);
|
|
2933
|
+
}), e.register("set_property", U.moduleName, (r, n) => {
|
|
2934
|
+
const o = r;
|
|
2935
|
+
Z(t, o[0], o[1]), n(!0);
|
|
2936
|
+
}), e.register("remove_property", U.moduleName, (r, n) => {
|
|
2937
|
+
ut(t, r), n(!0);
|
|
2938
|
+
}), e.register("activate", U.moduleName, (r, n) => {
|
|
2939
|
+
this.unblock(t), n(!0);
|
|
2940
|
+
}), e.log("ReflowableSetup Mounted"), !0;
|
|
2941
|
+
}
|
|
2942
|
+
unmount(t, e) {
|
|
2919
2943
|
var i;
|
|
2920
|
-
return
|
|
2944
|
+
return e.unregisterAll(U.moduleName), (i = t.document.head.querySelector(`#${Dt}`)) == null || i.remove(), t.removeEventListener("orientationchange", this.onViewportWidthChanged), e.log("ReflowableSetup Unmounted"), super.unmount(t, e);
|
|
2921
2945
|
}
|
|
2922
2946
|
};
|
|
2923
|
-
|
|
2924
|
-
let
|
|
2925
|
-
const
|
|
2926
|
-
mount(
|
|
2927
|
-
if (!super.mount(
|
|
2947
|
+
ne.moduleName = "reflowable_setup";
|
|
2948
|
+
let Xe = ne;
|
|
2949
|
+
const Wt = "readium-fixed-style", oe = class R extends re {
|
|
2950
|
+
mount(t, e) {
|
|
2951
|
+
if (!super.mount(t, e))
|
|
2928
2952
|
return !1;
|
|
2929
|
-
|
|
2930
|
-
const i =
|
|
2931
|
-
return i.id =
|
|
2953
|
+
t.navigator.epubReadingSystem.layoutStyle = "paginated";
|
|
2954
|
+
const i = t.document.createElement("style");
|
|
2955
|
+
return i.id = Wt, i.dataset.readium = "true", i.textContent = `
|
|
2932
2956
|
html, body {
|
|
2933
2957
|
text-size-adjust: none;
|
|
2934
2958
|
-ms-text-size-adjust: none;
|
|
@@ -2940,14 +2964,14 @@ const ze = "readium-fixed-style", st = class L extends it {
|
|
|
2940
2964
|
min-height: 100%;
|
|
2941
2965
|
|
|
2942
2966
|
/*cursor: var() TODO*/
|
|
2943
|
-
}`,
|
|
2944
|
-
const o =
|
|
2945
|
-
|
|
2946
|
-
}),
|
|
2947
|
-
|
|
2948
|
-
}),
|
|
2949
|
-
|
|
2950
|
-
}),
|
|
2967
|
+
}`, t.document.head.appendChild(i), e.register("set_property", R.moduleName, (r, n) => {
|
|
2968
|
+
const o = r;
|
|
2969
|
+
Z(t, o[0], o[1]), n(!0);
|
|
2970
|
+
}), e.register("remove_property", R.moduleName, (r, n) => {
|
|
2971
|
+
ut(t, r), n(!0);
|
|
2972
|
+
}), e.register("first_visible_locator", R.moduleName, (r, n) => n(!1)), e.register("unfocus", R.moduleName, (r, n) => {
|
|
2973
|
+
S(t), n(!0);
|
|
2974
|
+
}), e.register([
|
|
2951
2975
|
"focus",
|
|
2952
2976
|
"go_next",
|
|
2953
2977
|
"go_prev",
|
|
@@ -2956,97 +2980,97 @@ const ze = "readium-fixed-style", st = class L extends it {
|
|
|
2956
2980
|
"go_start",
|
|
2957
2981
|
"go_text",
|
|
2958
2982
|
"go_progression"
|
|
2959
|
-
],
|
|
2960
|
-
this.unblock(
|
|
2961
|
-
}),
|
|
2983
|
+
], R.moduleName, (r, n) => n(!0)), e.register("activate", R.moduleName, (r, n) => {
|
|
2984
|
+
this.unblock(t), n(!0);
|
|
2985
|
+
}), e.log("FixedSetup Mounted"), !0;
|
|
2962
2986
|
}
|
|
2963
|
-
unmount(
|
|
2987
|
+
unmount(t, e) {
|
|
2964
2988
|
var i;
|
|
2965
|
-
return
|
|
2989
|
+
return e.unregisterAll(R.moduleName), (i = t.document.getElementById(Wt)) == null || i.remove(), e.log("FixedSetup Unmounted"), super.unmount(t, e);
|
|
2966
2990
|
}
|
|
2967
2991
|
};
|
|
2968
|
-
|
|
2969
|
-
let
|
|
2970
|
-
const
|
|
2992
|
+
oe.moduleName = "fixed_setup";
|
|
2993
|
+
let Ge = oe;
|
|
2994
|
+
const Ye = [
|
|
2971
2995
|
"fixed_setup",
|
|
2972
2996
|
"decorator",
|
|
2973
2997
|
"peripherals"
|
|
2974
|
-
],
|
|
2998
|
+
], Ze = [
|
|
2975
2999
|
"reflowable_setup",
|
|
2976
3000
|
"decorator",
|
|
2977
3001
|
"peripherals",
|
|
2978
3002
|
"column_snapper",
|
|
2979
3003
|
"scroll_snapper"
|
|
2980
|
-
],
|
|
3004
|
+
], Ft = new Map([
|
|
2981
3005
|
// All modules go here
|
|
2982
|
-
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
].map((
|
|
2989
|
-
class
|
|
3006
|
+
Ge,
|
|
3007
|
+
Xe,
|
|
3008
|
+
ie,
|
|
3009
|
+
Fe,
|
|
3010
|
+
qe,
|
|
3011
|
+
_e
|
|
3012
|
+
].map((s) => [s.moduleName, s]));
|
|
3013
|
+
class Ke {
|
|
2990
3014
|
/**
|
|
2991
3015
|
* @param wnd Window instance to operate on
|
|
2992
3016
|
* @param initialModules List of initial modules to load
|
|
2993
3017
|
*/
|
|
2994
|
-
constructor(
|
|
2995
|
-
this.loadedModules = [], this.wnd =
|
|
2996
|
-
const i = [...new Set(
|
|
3018
|
+
constructor(t = window, e = []) {
|
|
3019
|
+
this.loadedModules = [], this.wnd = t, this.comms = new he(t);
|
|
3020
|
+
const i = [...new Set(e)];
|
|
2997
3021
|
if (i.length) {
|
|
2998
|
-
if (typeof
|
|
3022
|
+
if (typeof t > "u")
|
|
2999
3023
|
throw Error("Loader is not in a web browser");
|
|
3000
|
-
|
|
3001
|
-
const n = this.loadModule(
|
|
3024
|
+
t.parent !== t && this.comms.log("Loader is probably in a frame"), this.loadedModules = i.map((r) => {
|
|
3025
|
+
const n = this.loadModule(r);
|
|
3002
3026
|
if (n)
|
|
3003
3027
|
return n.mount(this.wnd, this.comms), n;
|
|
3004
|
-
}).filter((
|
|
3028
|
+
}).filter((r) => r !== void 0);
|
|
3005
3029
|
}
|
|
3006
3030
|
}
|
|
3007
|
-
loadModule(
|
|
3008
|
-
const
|
|
3009
|
-
return
|
|
3031
|
+
loadModule(t) {
|
|
3032
|
+
const e = Ft.get(t);
|
|
3033
|
+
return e === void 0 ? (this.comms.log(`Module "${name}" does not exist in the library`), e) : new e();
|
|
3010
3034
|
}
|
|
3011
3035
|
/**
|
|
3012
3036
|
* Add a module by name
|
|
3013
3037
|
* @param moduleName Module name
|
|
3014
3038
|
* @returns Success
|
|
3015
3039
|
*/
|
|
3016
|
-
addModule(
|
|
3017
|
-
const
|
|
3018
|
-
return !
|
|
3040
|
+
addModule(t) {
|
|
3041
|
+
const e = this.loadModule(t);
|
|
3042
|
+
return !e || !e.mount(this.wnd, this.comms) ? !1 : (this.loadedModules.push(e), !0);
|
|
3019
3043
|
}
|
|
3020
3044
|
/**
|
|
3021
3045
|
* Remove a module by name
|
|
3022
3046
|
* @param moduleName Module name
|
|
3023
3047
|
* @returns Success
|
|
3024
3048
|
*/
|
|
3025
|
-
removeModule(
|
|
3026
|
-
const
|
|
3027
|
-
if (
|
|
3028
|
-
return this.comms.log(`Module "${
|
|
3029
|
-
const i = this.loadedModules.findIndex((
|
|
3049
|
+
removeModule(t) {
|
|
3050
|
+
const e = Ft.get(t);
|
|
3051
|
+
if (e === void 0)
|
|
3052
|
+
return this.comms.log(`Module "${t}" does not exist in the library`), !1;
|
|
3053
|
+
const i = this.loadedModules.findIndex((r) => r instanceof e);
|
|
3030
3054
|
return i < 0 ? !1 : (this.loadedModules[i].unmount(this.wnd, this.comms), this.loadedModules.splice(i, 1), !0);
|
|
3031
3055
|
}
|
|
3032
3056
|
/**
|
|
3033
3057
|
* Unmount and remove all modules
|
|
3034
3058
|
*/
|
|
3035
3059
|
destroy() {
|
|
3036
|
-
this.comms.destroy(), this.loadedModules.forEach((
|
|
3060
|
+
this.comms.destroy(), this.loadedModules.forEach((t) => t.unmount(this.wnd, this.comms)), this.loadedModules = [];
|
|
3037
3061
|
}
|
|
3038
3062
|
}
|
|
3039
3063
|
export {
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3064
|
+
H as COMMS_VERSION,
|
|
3065
|
+
he as Comms,
|
|
3066
|
+
Fe as Decorator,
|
|
3067
|
+
Ye as FXLModules,
|
|
3068
|
+
ze as Layout,
|
|
3069
|
+
Ke as Loader,
|
|
3070
|
+
K as Module,
|
|
3071
|
+
Ft as ModuleLibrary,
|
|
3072
|
+
ie as Peripherals,
|
|
3073
|
+
Ze as ReflowableModules,
|
|
3074
|
+
Re as Width,
|
|
3075
|
+
le as mid
|
|
3052
3076
|
};
|