@readium/shared 1.2.0 → 1.2.1
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 +1936 -697
- package/dist/index.umd.cjs +3 -2
- package/package.json +2 -2
- package/src/fetcher/index.ts +2 -1
- package/src/publication/index.ts +1 -0
- package/types/src/fetcher/index.d.ts +2 -1
- package/types/src/publication/index.d.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class Ae {
|
|
2
2
|
close() {
|
|
3
3
|
}
|
|
4
4
|
links() {
|
|
@@ -8,7 +8,7 @@ class kt {
|
|
|
8
8
|
throw Error("This is an empty fetcher");
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
class
|
|
11
|
+
class mr {
|
|
12
12
|
constructor(t, e) {
|
|
13
13
|
this.client = t || window.fetch.bind(window), this.baseUrl = e;
|
|
14
14
|
}
|
|
@@ -19,14 +19,14 @@ class ne {
|
|
|
19
19
|
const e = t.toURL(this.baseUrl);
|
|
20
20
|
if (e === void 0)
|
|
21
21
|
throw Error(`Invalid HREF: ${t.href}`);
|
|
22
|
-
return new
|
|
22
|
+
return new Se(this.client, t, e);
|
|
23
23
|
}
|
|
24
24
|
close() {
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
class
|
|
28
|
-
constructor(t, e,
|
|
29
|
-
this.client = t || window.fetch.bind(window), this._link = e, this.url =
|
|
27
|
+
class Se {
|
|
28
|
+
constructor(t, e, r) {
|
|
29
|
+
this.client = t || window.fetch.bind(window), this._link = e, this.url = r;
|
|
30
30
|
}
|
|
31
31
|
/** Cached HEAD response to get the expected content length and other metadata. */
|
|
32
32
|
async headResponse() {
|
|
@@ -90,7 +90,23 @@ class St {
|
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
class
|
|
93
|
+
class Er {
|
|
94
|
+
constructor(t, e) {
|
|
95
|
+
this.start = t, this.endInclusive = e;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
class br {
|
|
99
|
+
readAsString() {
|
|
100
|
+
return this.read().then((t) => t === void 0 ? t : new TextDecoder().decode(t));
|
|
101
|
+
}
|
|
102
|
+
readAsJSON() {
|
|
103
|
+
return this.readAsString().then((t) => t === void 0 ? t : JSON.parse(t));
|
|
104
|
+
}
|
|
105
|
+
readAsXML() {
|
|
106
|
+
return this.readAsString().then((t) => t === void 0 ? t : new DOMParser().parseFromString(t, "text/xml"));
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
class ht {
|
|
94
110
|
/**
|
|
95
111
|
* Creates a [Encryption].
|
|
96
112
|
*/
|
|
@@ -102,7 +118,7 @@ class M {
|
|
|
102
118
|
*/
|
|
103
119
|
static deserialize(t) {
|
|
104
120
|
if (t && t.algorithm)
|
|
105
|
-
return new
|
|
121
|
+
return new ht({
|
|
106
122
|
algorithm: t.algorithm,
|
|
107
123
|
compression: t.compression,
|
|
108
124
|
originalLength: t.originalLength,
|
|
@@ -118,7 +134,7 @@ class M {
|
|
|
118
134
|
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;
|
|
119
135
|
}
|
|
120
136
|
}
|
|
121
|
-
class
|
|
137
|
+
class m {
|
|
122
138
|
constructor(t) {
|
|
123
139
|
this.otherProperties = t;
|
|
124
140
|
}
|
|
@@ -127,7 +143,7 @@ class g {
|
|
|
127
143
|
*/
|
|
128
144
|
static deserialize(t) {
|
|
129
145
|
if (t)
|
|
130
|
-
return new
|
|
146
|
+
return new m(t);
|
|
131
147
|
}
|
|
132
148
|
/**
|
|
133
149
|
* Serializes a [Properties] to its RWPM JSON representation.
|
|
@@ -140,18 +156,18 @@ class g {
|
|
|
140
156
|
*/
|
|
141
157
|
add(t) {
|
|
142
158
|
const e = Object.assign({}, this.otherProperties);
|
|
143
|
-
for (const
|
|
144
|
-
e[
|
|
145
|
-
return new
|
|
159
|
+
for (const r in t)
|
|
160
|
+
e[r] = t[r];
|
|
161
|
+
return new m(e);
|
|
146
162
|
}
|
|
147
163
|
}
|
|
148
|
-
Object.defineProperty(
|
|
164
|
+
Object.defineProperty(m.prototype, "encryption", {
|
|
149
165
|
get: function() {
|
|
150
|
-
return
|
|
166
|
+
return ht.deserialize(this.otherProperties.encrypted);
|
|
151
167
|
}
|
|
152
168
|
});
|
|
153
|
-
var
|
|
154
|
-
class
|
|
169
|
+
var Rt = /* @__PURE__ */ ((i) => (i.fixed = "fixed", i.reflowable = "reflowable", i))(Rt || {}), Ie = /* @__PURE__ */ ((i) => (i.auto = "auto", i.landscape = "landscape", i.portrait = "portrait", i))(Ie || {}), Te = /* @__PURE__ */ ((i) => (i.auto = "auto", i.clipped = "clipped", i.paginated = "paginated", i.scrolled = "scrolled", i))(Te || {}), H = /* @__PURE__ */ ((i) => (i.left = "left", i.right = "right", i.center = "center", i))(H || {}), ze = /* @__PURE__ */ ((i) => (i.auto = "auto", i.both = "both", i.none = "none", i.landscape = "landscape", i))(ze || {}), ve = /* @__PURE__ */ ((i) => (i.contain = "contain", i.cover = "cover", i.width = "width", i.height = "height", i))(ve || {});
|
|
170
|
+
class _ {
|
|
155
171
|
/** Creates a [Presentation]. */
|
|
156
172
|
constructor(t) {
|
|
157
173
|
this.clipped = t.clipped, this.fit = t.fit, this.orientation = t.orientation, this.spread = t.spread, this.layout = t.layout, this.continuous = t.continuous, this.overflow = t.overflow;
|
|
@@ -162,7 +178,7 @@ class J {
|
|
|
162
178
|
*/
|
|
163
179
|
static deserialize(t) {
|
|
164
180
|
if (t)
|
|
165
|
-
return new
|
|
181
|
+
return new _({
|
|
166
182
|
clipped: t.clipped,
|
|
167
183
|
continuous: t.continuous,
|
|
168
184
|
fit: t.fit,
|
|
@@ -180,46 +196,46 @@ class J {
|
|
|
180
196
|
return this.clipped !== void 0 && (t.clipped = this.clipped), this.continuous !== void 0 && (t.continuous = this.continuous), this.fit !== void 0 && (t.fit = this.fit), this.orientation !== void 0 && (t.orientation = this.orientation), this.overflow !== void 0 && (t.overflow = this.overflow), this.spread !== void 0 && (t.spread = this.spread), this.layout !== void 0 && (t.layout = this.layout), t;
|
|
181
197
|
}
|
|
182
198
|
}
|
|
183
|
-
|
|
199
|
+
_.prototype.layoutOf = function(i) {
|
|
184
200
|
var t;
|
|
185
|
-
return ((t =
|
|
201
|
+
return ((t = i.properties) == null ? void 0 : t.getLayout()) || this.layout || Rt.reflowable;
|
|
186
202
|
};
|
|
187
|
-
|
|
203
|
+
m.prototype.getContains = function() {
|
|
188
204
|
return new Set(this.otherProperties.contains || []);
|
|
189
205
|
};
|
|
190
|
-
|
|
206
|
+
m.prototype.getLayout = function() {
|
|
191
207
|
return this.otherProperties.layout;
|
|
192
208
|
};
|
|
193
|
-
class
|
|
209
|
+
class a {
|
|
194
210
|
/** Creates a MediaType object. */
|
|
195
211
|
constructor(t) {
|
|
196
|
-
let e,
|
|
197
|
-
const
|
|
198
|
-
if (
|
|
199
|
-
if (e =
|
|
212
|
+
let e, r, s = t.mediaType.replace(/\s/g, "").split(";");
|
|
213
|
+
const n = s[0].split("/");
|
|
214
|
+
if (n.length === 2) {
|
|
215
|
+
if (e = n[0].toLowerCase().trim(), r = n[1].toLowerCase().trim(), e.length === 0 || r.length === 0)
|
|
200
216
|
throw new Error("Invalid media type");
|
|
201
217
|
} else
|
|
202
218
|
throw new Error("Invalid media type");
|
|
203
219
|
const o = {};
|
|
204
|
-
for (let
|
|
205
|
-
const d = s[
|
|
220
|
+
for (let f = 1; f < s.length; f++) {
|
|
221
|
+
const d = s[f].split("=");
|
|
206
222
|
if (d.length === 2) {
|
|
207
|
-
const
|
|
208
|
-
o[
|
|
223
|
+
const I = d[0].toLocaleLowerCase(), L = I === "charset" ? d[1].toUpperCase() : d[1];
|
|
224
|
+
o[I] = L;
|
|
209
225
|
}
|
|
210
226
|
}
|
|
211
|
-
const l = {},
|
|
212
|
-
|
|
213
|
-
let
|
|
214
|
-
for (const
|
|
215
|
-
const d = l[
|
|
216
|
-
|
|
227
|
+
const l = {}, c = Object.keys(o);
|
|
228
|
+
c.sort((f, d) => f.localeCompare(d)), c.forEach((f) => l[f] = o[f]);
|
|
229
|
+
let h = "";
|
|
230
|
+
for (const f in l) {
|
|
231
|
+
const d = l[f];
|
|
232
|
+
h += `;${f}=${d}`;
|
|
217
233
|
}
|
|
218
|
-
const
|
|
219
|
-
this.string =
|
|
234
|
+
const u = `${e}/${r}${h}`, p = l.encoding;
|
|
235
|
+
this.string = u, this.type = e, this.subtype = r, this.parameters = l, this.encoding = p, this.name = t.name, this.fileExtension = t.fileExtension;
|
|
220
236
|
}
|
|
221
237
|
static parse(t) {
|
|
222
|
-
return new
|
|
238
|
+
return new a(t);
|
|
223
239
|
}
|
|
224
240
|
/** Structured syntax suffix, e.g. `+zip` in `application/epub+zip`.
|
|
225
241
|
* Gives a hint on the underlying structure of this media type.
|
|
@@ -249,16 +265,16 @@ class n {
|
|
|
249
265
|
* - Wildcards are supported, meaning that `image/*` contains `image/png`
|
|
250
266
|
*/
|
|
251
267
|
contains(t) {
|
|
252
|
-
const e = typeof t == "string" ?
|
|
268
|
+
const e = typeof t == "string" ? a.parse({ mediaType: t }) : t;
|
|
253
269
|
if (!((this.type === "*" || this.type === e.type) && (this.subtype === "*" || this.subtype === e.subtype)))
|
|
254
270
|
return !1;
|
|
255
|
-
const
|
|
256
|
-
Object.entries(this.parameters).map(([
|
|
271
|
+
const r = new Set(
|
|
272
|
+
Object.entries(this.parameters).map(([n, o]) => `${n}=${o}`)
|
|
257
273
|
), s = new Set(
|
|
258
|
-
Object.entries(e.parameters).map(([
|
|
274
|
+
Object.entries(e.parameters).map(([n, o]) => `${n}=${o}`)
|
|
259
275
|
);
|
|
260
|
-
for (const
|
|
261
|
-
if (!s.has(
|
|
276
|
+
for (const n of Array.from(r.values()))
|
|
277
|
+
if (!s.has(n))
|
|
262
278
|
return !1;
|
|
263
279
|
return !0;
|
|
264
280
|
}
|
|
@@ -268,7 +284,7 @@ class n {
|
|
|
268
284
|
* doesn't. This is basically like `contains`, but working in both direction.
|
|
269
285
|
*/
|
|
270
286
|
matches(t) {
|
|
271
|
-
const e = typeof t == "string" ?
|
|
287
|
+
const e = typeof t == "string" ? a.parse({ mediaType: t }) : t;
|
|
272
288
|
return this.contains(e) || e.contains(this);
|
|
273
289
|
}
|
|
274
290
|
/**
|
|
@@ -287,38 +303,38 @@ class n {
|
|
|
287
303
|
/** Returns whether this media type is structured as a ZIP archive. */
|
|
288
304
|
get isZIP() {
|
|
289
305
|
return this.matchesAny(
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
306
|
+
a.ZIP,
|
|
307
|
+
a.LCP_PROTECTED_AUDIOBOOK,
|
|
308
|
+
a.LCP_PROTECTED_PDF
|
|
293
309
|
) || this.structuredSyntaxSuffix === "+zip";
|
|
294
310
|
}
|
|
295
311
|
/** Returns whether this media type is structured as a JSON file. */
|
|
296
312
|
get isJSON() {
|
|
297
|
-
return this.matchesAny(
|
|
313
|
+
return this.matchesAny(a.JSON) || this.structuredSyntaxSuffix === "+json";
|
|
298
314
|
}
|
|
299
315
|
/** Returns whether this media type is of an OPDS feed. */
|
|
300
316
|
get isOPDS() {
|
|
301
317
|
return this.matchesAny(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
318
|
+
a.OPDS1,
|
|
319
|
+
a.OPDS1_ENTRY,
|
|
320
|
+
a.OPDS2,
|
|
321
|
+
a.OPDS2_PUBLICATION,
|
|
322
|
+
a.OPDS_AUTHENTICATION
|
|
307
323
|
) || this.structuredSyntaxSuffix === "+json";
|
|
308
324
|
}
|
|
309
325
|
/** Returns whether this media type is of an HTML document. */
|
|
310
326
|
get isHTML() {
|
|
311
|
-
return this.matchesAny(
|
|
327
|
+
return this.matchesAny(a.HTML, a.XHTML);
|
|
312
328
|
}
|
|
313
329
|
/** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
|
|
314
330
|
get isBitmap() {
|
|
315
331
|
return this.matchesAny(
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
332
|
+
a.BMP,
|
|
333
|
+
a.GIF,
|
|
334
|
+
a.JPEG,
|
|
335
|
+
a.PNG,
|
|
336
|
+
a.TIFF,
|
|
337
|
+
a.WEBP
|
|
322
338
|
);
|
|
323
339
|
}
|
|
324
340
|
/** Returns whether this media type is of an audio clip. */
|
|
@@ -332,320 +348,320 @@ class n {
|
|
|
332
348
|
/** Returns whether this media type is of a Readium Web Publication Manifest. */
|
|
333
349
|
get isRWPM() {
|
|
334
350
|
return this.matchesAny(
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
351
|
+
a.READIUM_AUDIOBOOK_MANIFEST,
|
|
352
|
+
a.DIVINA_MANIFEST,
|
|
353
|
+
a.READIUM_WEBPUB_MANIFEST
|
|
338
354
|
);
|
|
339
355
|
}
|
|
340
356
|
/** Returns whether this media type is of a publication file. */
|
|
341
357
|
get isPublication() {
|
|
342
358
|
return this.matchesAny(
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
359
|
+
a.READIUM_AUDIOBOOK,
|
|
360
|
+
a.READIUM_AUDIOBOOK_MANIFEST,
|
|
361
|
+
a.CBZ,
|
|
362
|
+
a.DIVINA,
|
|
363
|
+
a.DIVINA_MANIFEST,
|
|
364
|
+
a.EPUB,
|
|
365
|
+
a.LCP_PROTECTED_AUDIOBOOK,
|
|
366
|
+
a.LCP_PROTECTED_PDF,
|
|
367
|
+
a.LPF,
|
|
368
|
+
a.PDF,
|
|
369
|
+
a.W3C_WPUB_MANIFEST,
|
|
370
|
+
a.READIUM_WEBPUB,
|
|
371
|
+
a.READIUM_WEBPUB_MANIFEST,
|
|
372
|
+
a.ZAB
|
|
357
373
|
);
|
|
358
374
|
}
|
|
359
375
|
// Known Media Types
|
|
360
376
|
static get AAC() {
|
|
361
|
-
return
|
|
377
|
+
return a.parse({ mediaType: "audio/aac", fileExtension: "aac" });
|
|
362
378
|
}
|
|
363
379
|
static get ACSM() {
|
|
364
|
-
return
|
|
380
|
+
return a.parse({
|
|
365
381
|
mediaType: "application/vnd.adobe.adept+xml",
|
|
366
382
|
name: "Adobe Content Server Message",
|
|
367
383
|
fileExtension: "acsm"
|
|
368
384
|
});
|
|
369
385
|
}
|
|
370
386
|
static get AIFF() {
|
|
371
|
-
return
|
|
387
|
+
return a.parse({ mediaType: "audio/aiff", fileExtension: "aiff" });
|
|
372
388
|
}
|
|
373
389
|
static get AVI() {
|
|
374
|
-
return
|
|
390
|
+
return a.parse({
|
|
375
391
|
mediaType: "video/x-msvideo",
|
|
376
392
|
fileExtension: "avi"
|
|
377
393
|
});
|
|
378
394
|
}
|
|
379
395
|
static get BINARY() {
|
|
380
|
-
return
|
|
396
|
+
return a.parse({ mediaType: "application/octet-stream" });
|
|
381
397
|
}
|
|
382
398
|
static get BMP() {
|
|
383
|
-
return
|
|
399
|
+
return a.parse({ mediaType: "image/bmp", fileExtension: "bmp" });
|
|
384
400
|
}
|
|
385
401
|
static get CBZ() {
|
|
386
|
-
return
|
|
402
|
+
return a.parse({
|
|
387
403
|
mediaType: "application/vnd.comicbook+zip",
|
|
388
404
|
name: "Comic Book Archive",
|
|
389
405
|
fileExtension: "cbz"
|
|
390
406
|
});
|
|
391
407
|
}
|
|
392
408
|
static get CSS() {
|
|
393
|
-
return
|
|
409
|
+
return a.parse({ mediaType: "text/css", fileExtension: "css" });
|
|
394
410
|
}
|
|
395
411
|
static get DIVINA() {
|
|
396
|
-
return
|
|
412
|
+
return a.parse({
|
|
397
413
|
mediaType: "application/divina+zip",
|
|
398
414
|
name: "Digital Visual Narratives",
|
|
399
415
|
fileExtension: "divina"
|
|
400
416
|
});
|
|
401
417
|
}
|
|
402
418
|
static get DIVINA_MANIFEST() {
|
|
403
|
-
return
|
|
419
|
+
return a.parse({
|
|
404
420
|
mediaType: "application/divina+json",
|
|
405
421
|
name: "Digital Visual Narratives",
|
|
406
422
|
fileExtension: "json"
|
|
407
423
|
});
|
|
408
424
|
}
|
|
409
425
|
static get EPUB() {
|
|
410
|
-
return
|
|
426
|
+
return a.parse({
|
|
411
427
|
mediaType: "application/epub+zip",
|
|
412
428
|
name: "EPUB",
|
|
413
429
|
fileExtension: "epub"
|
|
414
430
|
});
|
|
415
431
|
}
|
|
416
432
|
static get GIF() {
|
|
417
|
-
return
|
|
433
|
+
return a.parse({ mediaType: "image/gif", fileExtension: "gif" });
|
|
418
434
|
}
|
|
419
435
|
static get GZ() {
|
|
420
|
-
return
|
|
436
|
+
return a.parse({
|
|
421
437
|
mediaType: "application/gzip",
|
|
422
438
|
fileExtension: "gz"
|
|
423
439
|
});
|
|
424
440
|
}
|
|
425
441
|
static get HTML() {
|
|
426
|
-
return
|
|
442
|
+
return a.parse({ mediaType: "text/html", fileExtension: "html" });
|
|
427
443
|
}
|
|
428
444
|
static get JAVASCRIPT() {
|
|
429
|
-
return
|
|
445
|
+
return a.parse({
|
|
430
446
|
mediaType: "text/javascript",
|
|
431
447
|
fileExtension: "js"
|
|
432
448
|
});
|
|
433
449
|
}
|
|
434
450
|
static get JPEG() {
|
|
435
|
-
return
|
|
451
|
+
return a.parse({ mediaType: "image/jpeg", fileExtension: "jpeg" });
|
|
436
452
|
}
|
|
437
453
|
static get JSON() {
|
|
438
|
-
return
|
|
454
|
+
return a.parse({ mediaType: "application/json" });
|
|
439
455
|
}
|
|
440
456
|
static get LCP_LICENSE_DOCUMENT() {
|
|
441
|
-
return
|
|
457
|
+
return a.parse({
|
|
442
458
|
mediaType: "application/vnd.readium.lcp.license.v1.0+json",
|
|
443
459
|
name: "LCP License",
|
|
444
460
|
fileExtension: "lcpl"
|
|
445
461
|
});
|
|
446
462
|
}
|
|
447
463
|
static get LCP_PROTECTED_AUDIOBOOK() {
|
|
448
|
-
return
|
|
464
|
+
return a.parse({
|
|
449
465
|
mediaType: "application/audiobook+lcp",
|
|
450
466
|
name: "LCP Protected Audiobook",
|
|
451
467
|
fileExtension: "lcpa"
|
|
452
468
|
});
|
|
453
469
|
}
|
|
454
470
|
static get LCP_PROTECTED_PDF() {
|
|
455
|
-
return
|
|
471
|
+
return a.parse({
|
|
456
472
|
mediaType: "application/pdf+lcp",
|
|
457
473
|
name: "LCP Protected PDF",
|
|
458
474
|
fileExtension: "lcpdf"
|
|
459
475
|
});
|
|
460
476
|
}
|
|
461
477
|
static get LCP_STATUS_DOCUMENT() {
|
|
462
|
-
return
|
|
478
|
+
return a.parse({
|
|
463
479
|
mediaType: "application/vnd.readium.license.status.v1.0+json"
|
|
464
480
|
});
|
|
465
481
|
}
|
|
466
482
|
static get LPF() {
|
|
467
|
-
return
|
|
483
|
+
return a.parse({
|
|
468
484
|
mediaType: "application/lpf+zip",
|
|
469
485
|
fileExtension: "lpf"
|
|
470
486
|
});
|
|
471
487
|
}
|
|
472
488
|
static get MP3() {
|
|
473
|
-
return
|
|
489
|
+
return a.parse({ mediaType: "audio/mpeg", fileExtension: "mp3" });
|
|
474
490
|
}
|
|
475
491
|
static get MPEG() {
|
|
476
|
-
return
|
|
492
|
+
return a.parse({ mediaType: "video/mpeg", fileExtension: "mpeg" });
|
|
477
493
|
}
|
|
478
494
|
static get NCX() {
|
|
479
|
-
return
|
|
495
|
+
return a.parse({
|
|
480
496
|
mediaType: "application/x-dtbncx+xml",
|
|
481
497
|
fileExtension: "ncx"
|
|
482
498
|
});
|
|
483
499
|
}
|
|
484
500
|
static get OGG() {
|
|
485
|
-
return
|
|
501
|
+
return a.parse({ mediaType: "audio/ogg", fileExtension: "oga" });
|
|
486
502
|
}
|
|
487
503
|
static get OGV() {
|
|
488
|
-
return
|
|
504
|
+
return a.parse({ mediaType: "video/ogg", fileExtension: "ogv" });
|
|
489
505
|
}
|
|
490
506
|
static get OPDS1() {
|
|
491
|
-
return
|
|
507
|
+
return a.parse({
|
|
492
508
|
mediaType: "application/atom+xml;profile=opds-catalog"
|
|
493
509
|
});
|
|
494
510
|
}
|
|
495
511
|
static get OPDS1_ENTRY() {
|
|
496
|
-
return
|
|
512
|
+
return a.parse({
|
|
497
513
|
mediaType: "application/atom+xml;type=entry;profile=opds-catalog"
|
|
498
514
|
});
|
|
499
515
|
}
|
|
500
516
|
static get OPDS2() {
|
|
501
|
-
return
|
|
517
|
+
return a.parse({ mediaType: "application/opds+json" });
|
|
502
518
|
}
|
|
503
519
|
static get OPDS2_PUBLICATION() {
|
|
504
|
-
return
|
|
520
|
+
return a.parse({ mediaType: "application/opds-publication+json" });
|
|
505
521
|
}
|
|
506
522
|
static get OPDS_AUTHENTICATION() {
|
|
507
|
-
return
|
|
523
|
+
return a.parse({
|
|
508
524
|
mediaType: "application/opds-authentication+json"
|
|
509
525
|
});
|
|
510
526
|
}
|
|
511
527
|
static get OPUS() {
|
|
512
|
-
return
|
|
528
|
+
return a.parse({ mediaType: "audio/opus", fileExtension: "opus" });
|
|
513
529
|
}
|
|
514
530
|
static get OTF() {
|
|
515
|
-
return
|
|
531
|
+
return a.parse({ mediaType: "font/otf", fileExtension: "otf" });
|
|
516
532
|
}
|
|
517
533
|
static get PDF() {
|
|
518
|
-
return
|
|
534
|
+
return a.parse({
|
|
519
535
|
mediaType: "application/pdf",
|
|
520
536
|
name: "PDF",
|
|
521
537
|
fileExtension: "pdf"
|
|
522
538
|
});
|
|
523
539
|
}
|
|
524
540
|
static get PNG() {
|
|
525
|
-
return
|
|
541
|
+
return a.parse({ mediaType: "image/png", fileExtension: "png" });
|
|
526
542
|
}
|
|
527
543
|
static get READIUM_AUDIOBOOK() {
|
|
528
|
-
return
|
|
544
|
+
return a.parse({
|
|
529
545
|
mediaType: "application/audiobook+zip",
|
|
530
546
|
name: "Readium Audiobook",
|
|
531
547
|
fileExtension: "audiobook"
|
|
532
548
|
});
|
|
533
549
|
}
|
|
534
550
|
static get READIUM_AUDIOBOOK_MANIFEST() {
|
|
535
|
-
return
|
|
551
|
+
return a.parse({
|
|
536
552
|
mediaType: "application/audiobook+json",
|
|
537
553
|
name: "Readium Audiobook",
|
|
538
554
|
fileExtension: "json"
|
|
539
555
|
});
|
|
540
556
|
}
|
|
541
557
|
static get READIUM_CONTENT_DOCUMENT() {
|
|
542
|
-
return
|
|
558
|
+
return a.parse({
|
|
543
559
|
mediaType: "application/vnd.readium.content+json",
|
|
544
560
|
name: "Readium Content Document",
|
|
545
561
|
fileExtension: "json"
|
|
546
562
|
});
|
|
547
563
|
}
|
|
548
564
|
static get READIUM_GUIDED_NAVIGATION_DOCUMENT() {
|
|
549
|
-
return
|
|
565
|
+
return a.parse({
|
|
550
566
|
mediaType: "application/guided-navigation+json",
|
|
551
567
|
name: "Readium Guided Navigation Document",
|
|
552
568
|
fileExtension: "json"
|
|
553
569
|
});
|
|
554
570
|
}
|
|
555
571
|
static get READIUM_POSITION_LIST() {
|
|
556
|
-
return
|
|
572
|
+
return a.parse({
|
|
557
573
|
mediaType: "application/vnd.readium.position-list+json",
|
|
558
574
|
name: "Readium Position List",
|
|
559
575
|
fileExtension: "json"
|
|
560
576
|
});
|
|
561
577
|
}
|
|
562
578
|
static get READIUM_WEBPUB() {
|
|
563
|
-
return
|
|
579
|
+
return a.parse({
|
|
564
580
|
mediaType: "application/webpub+zip",
|
|
565
581
|
name: "Readium Web Publication",
|
|
566
582
|
fileExtension: "webpub"
|
|
567
583
|
});
|
|
568
584
|
}
|
|
569
585
|
static get READIUM_WEBPUB_MANIFEST() {
|
|
570
|
-
return
|
|
586
|
+
return a.parse({
|
|
571
587
|
mediaType: "application/webpub+json",
|
|
572
588
|
name: "Readium Web Publication",
|
|
573
589
|
fileExtension: "json"
|
|
574
590
|
});
|
|
575
591
|
}
|
|
576
592
|
static get SMIL() {
|
|
577
|
-
return
|
|
593
|
+
return a.parse({
|
|
578
594
|
mediaType: "application/smil+xml",
|
|
579
595
|
fileExtension: "smil"
|
|
580
596
|
});
|
|
581
597
|
}
|
|
582
598
|
static get SVG() {
|
|
583
|
-
return
|
|
599
|
+
return a.parse({
|
|
584
600
|
mediaType: "image/svg+xml",
|
|
585
601
|
fileExtension: "svg"
|
|
586
602
|
});
|
|
587
603
|
}
|
|
588
604
|
static get TEXT() {
|
|
589
|
-
return
|
|
605
|
+
return a.parse({ mediaType: "text/plain", fileExtension: "txt" });
|
|
590
606
|
}
|
|
591
607
|
static get TIFF() {
|
|
592
|
-
return
|
|
608
|
+
return a.parse({ mediaType: "image/tiff", fileExtension: "tiff" });
|
|
593
609
|
}
|
|
594
610
|
static get TTF() {
|
|
595
|
-
return
|
|
611
|
+
return a.parse({ mediaType: "font/ttf", fileExtension: "ttf" });
|
|
596
612
|
}
|
|
597
613
|
static get W3C_WPUB_MANIFEST() {
|
|
598
|
-
return
|
|
614
|
+
return a.parse({
|
|
599
615
|
mediaType: "application/x.readium.w3c.wpub+json",
|
|
600
616
|
name: "Web Publication",
|
|
601
617
|
fileExtension: "json"
|
|
602
618
|
});
|
|
603
619
|
}
|
|
604
620
|
static get WAV() {
|
|
605
|
-
return
|
|
621
|
+
return a.parse({ mediaType: "audio/wav", fileExtension: "wav" });
|
|
606
622
|
}
|
|
607
623
|
static get WEBM_AUDIO() {
|
|
608
|
-
return
|
|
624
|
+
return a.parse({ mediaType: "audio/webm", fileExtension: "webm" });
|
|
609
625
|
}
|
|
610
626
|
static get WEBM_VIDEO() {
|
|
611
|
-
return
|
|
627
|
+
return a.parse({ mediaType: "video/webm", fileExtension: "webm" });
|
|
612
628
|
}
|
|
613
629
|
static get WEBP() {
|
|
614
|
-
return
|
|
630
|
+
return a.parse({ mediaType: "image/webp", fileExtension: "webp" });
|
|
615
631
|
}
|
|
616
632
|
static get WOFF() {
|
|
617
|
-
return
|
|
633
|
+
return a.parse({ mediaType: "font/woff", fileExtension: "woff" });
|
|
618
634
|
}
|
|
619
635
|
static get WOFF2() {
|
|
620
|
-
return
|
|
636
|
+
return a.parse({ mediaType: "font/woff2", fileExtension: "woff2" });
|
|
621
637
|
}
|
|
622
638
|
static get XHTML() {
|
|
623
|
-
return
|
|
639
|
+
return a.parse({
|
|
624
640
|
mediaType: "application/xhtml+xml",
|
|
625
641
|
fileExtension: "xhtml"
|
|
626
642
|
});
|
|
627
643
|
}
|
|
628
644
|
static get XML() {
|
|
629
|
-
return
|
|
645
|
+
return a.parse({
|
|
630
646
|
mediaType: "application/xml",
|
|
631
647
|
fileExtension: "xml"
|
|
632
648
|
});
|
|
633
649
|
}
|
|
634
650
|
static get ZAB() {
|
|
635
|
-
return
|
|
651
|
+
return a.parse({
|
|
636
652
|
mediaType: "application/x.readium.zab+zip",
|
|
637
653
|
name: "Zipped Audio Book",
|
|
638
654
|
fileExtension: "zab"
|
|
639
655
|
});
|
|
640
656
|
}
|
|
641
657
|
static get ZIP() {
|
|
642
|
-
return
|
|
658
|
+
return a.parse({
|
|
643
659
|
mediaType: "application/zip",
|
|
644
660
|
fileExtension: "zip"
|
|
645
661
|
});
|
|
646
662
|
}
|
|
647
663
|
}
|
|
648
|
-
class
|
|
664
|
+
class J {
|
|
649
665
|
constructor(t) {
|
|
650
666
|
this.uri = t, this.parameters = this.getParameters(t);
|
|
651
667
|
}
|
|
@@ -653,9 +669,9 @@ class B {
|
|
|
653
669
|
* List of URI template parameter keys, if the [Link] is templated.
|
|
654
670
|
*/
|
|
655
671
|
getParameters(t) {
|
|
656
|
-
const e = /\{\??([^}]+)\}/g,
|
|
657
|
-
return
|
|
658
|
-
|
|
672
|
+
const e = /\{\??([^}]+)\}/g, r = t.match(e);
|
|
673
|
+
return r ? new Set(
|
|
674
|
+
r.join(",").replace(e, "$1").split(",").map((s) => s.trim())
|
|
659
675
|
) : /* @__PURE__ */ new Set();
|
|
660
676
|
}
|
|
661
677
|
/** Expands the URI by replacing the template variables by the given parameters.
|
|
@@ -663,34 +679,34 @@ class B {
|
|
|
663
679
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
664
680
|
*/
|
|
665
681
|
expand(t) {
|
|
666
|
-
const e = (s) => s.split(",").map((
|
|
667
|
-
const o = t[
|
|
682
|
+
const e = (s) => s.split(",").map((n) => {
|
|
683
|
+
const o = t[n];
|
|
668
684
|
return o ? encodeURIComponent(o) : "";
|
|
669
|
-
}).join(","),
|
|
670
|
-
const o =
|
|
685
|
+
}).join(","), r = (s) => "?" + s.split(",").map((n) => {
|
|
686
|
+
const o = n.split("=")[0], l = t[o];
|
|
671
687
|
return l ? `${o}=${encodeURIComponent(l)}` : "";
|
|
672
688
|
}).join("&");
|
|
673
|
-
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ?
|
|
689
|
+
return this.uri.replace(/\{(\??)([^}]+)\}/g, (...s) => s[1] ? r(s[2]) : e(s[2]));
|
|
674
690
|
}
|
|
675
691
|
}
|
|
676
|
-
function
|
|
677
|
-
return
|
|
692
|
+
function Oe(i) {
|
|
693
|
+
return i && i instanceof Array ? i : void 0;
|
|
678
694
|
}
|
|
679
|
-
function
|
|
680
|
-
return
|
|
695
|
+
function R(i) {
|
|
696
|
+
return i && typeof i == "string" ? [i] : Oe(i);
|
|
681
697
|
}
|
|
682
|
-
function
|
|
683
|
-
return typeof
|
|
698
|
+
function Y(i) {
|
|
699
|
+
return typeof i == "string" ? new Date(i) : void 0;
|
|
684
700
|
}
|
|
685
|
-
function
|
|
686
|
-
return isNaN(
|
|
701
|
+
function C(i) {
|
|
702
|
+
return isNaN(i) ? void 0 : i;
|
|
687
703
|
}
|
|
688
|
-
function y(
|
|
689
|
-
return
|
|
704
|
+
function y(i) {
|
|
705
|
+
return C(i) !== void 0 && Math.sign(i) >= 0 ? i : void 0;
|
|
690
706
|
}
|
|
691
|
-
function
|
|
707
|
+
function ut(i) {
|
|
692
708
|
const t = new Array();
|
|
693
|
-
return
|
|
709
|
+
return i.forEach((e) => t.push(e)), t;
|
|
694
710
|
}
|
|
695
711
|
class E {
|
|
696
712
|
/**
|
|
@@ -705,21 +721,21 @@ class E {
|
|
|
705
721
|
static deserialize(t) {
|
|
706
722
|
if (!t)
|
|
707
723
|
return;
|
|
708
|
-
const e =
|
|
724
|
+
const e = C(t.progression), r = C(t.totalProgression), s = C(t.position), n = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Set([
|
|
709
725
|
"fragment",
|
|
710
726
|
"fragments",
|
|
711
727
|
"progression",
|
|
712
728
|
"totalProgression",
|
|
713
729
|
"position"
|
|
714
730
|
]);
|
|
715
|
-
return Object.entries(t).forEach(([l,
|
|
716
|
-
o.has(l) ||
|
|
731
|
+
return Object.entries(t).forEach(([l, c]) => {
|
|
732
|
+
o.has(l) || n.set(l, c);
|
|
717
733
|
}), new E({
|
|
718
|
-
fragments:
|
|
734
|
+
fragments: R(t.fragments || t.fragment),
|
|
719
735
|
progression: e !== void 0 && e >= 0 && e <= 1 ? e : void 0,
|
|
720
|
-
totalProgression:
|
|
736
|
+
totalProgression: r !== void 0 && r >= 0 && r <= 1 ? r : void 0,
|
|
721
737
|
position: s !== void 0 && s > 0 ? s : void 0,
|
|
722
|
-
otherLocations:
|
|
738
|
+
otherLocations: n.size === 0 ? void 0 : n
|
|
723
739
|
});
|
|
724
740
|
}
|
|
725
741
|
/**
|
|
@@ -727,10 +743,10 @@ class E {
|
|
|
727
743
|
*/
|
|
728
744
|
serialize() {
|
|
729
745
|
const t = {};
|
|
730
|
-
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,
|
|
746
|
+
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, r) => t[r] = e), t;
|
|
731
747
|
}
|
|
732
748
|
}
|
|
733
|
-
class
|
|
749
|
+
class M {
|
|
734
750
|
/**
|
|
735
751
|
* Creates a [Text].
|
|
736
752
|
*/
|
|
@@ -742,7 +758,7 @@ class Y {
|
|
|
742
758
|
*/
|
|
743
759
|
static deserialize(t) {
|
|
744
760
|
if (t)
|
|
745
|
-
return new
|
|
761
|
+
return new M({
|
|
746
762
|
after: t.after,
|
|
747
763
|
before: t.before,
|
|
748
764
|
highlight: t.highlight
|
|
@@ -756,7 +772,7 @@ class Y {
|
|
|
756
772
|
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;
|
|
757
773
|
}
|
|
758
774
|
}
|
|
759
|
-
class
|
|
775
|
+
class A {
|
|
760
776
|
/**
|
|
761
777
|
* Creates a [Locator].
|
|
762
778
|
*/
|
|
@@ -768,12 +784,12 @@ class P {
|
|
|
768
784
|
*/
|
|
769
785
|
static deserialize(t) {
|
|
770
786
|
if (t && t.href && t.type)
|
|
771
|
-
return new
|
|
787
|
+
return new A({
|
|
772
788
|
href: t.href,
|
|
773
789
|
type: t.type,
|
|
774
790
|
title: t.title,
|
|
775
791
|
locations: E.deserialize(t.locations),
|
|
776
|
-
text:
|
|
792
|
+
text: M.deserialize(t.text)
|
|
777
793
|
});
|
|
778
794
|
}
|
|
779
795
|
/**
|
|
@@ -787,7 +803,7 @@ class P {
|
|
|
787
803
|
* Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
|
|
788
804
|
*/
|
|
789
805
|
copyWithLocations(t) {
|
|
790
|
-
return new
|
|
806
|
+
return new A({
|
|
791
807
|
href: this.href,
|
|
792
808
|
type: this.type,
|
|
793
809
|
title: this.title,
|
|
@@ -796,7 +812,7 @@ class P {
|
|
|
796
812
|
});
|
|
797
813
|
}
|
|
798
814
|
}
|
|
799
|
-
class
|
|
815
|
+
class S {
|
|
800
816
|
/**
|
|
801
817
|
* Creates a [Link].
|
|
802
818
|
*/
|
|
@@ -808,20 +824,20 @@ class w {
|
|
|
808
824
|
*/
|
|
809
825
|
static deserialize(t) {
|
|
810
826
|
if (t && t.href && typeof t.href == "string")
|
|
811
|
-
return new
|
|
827
|
+
return new S({
|
|
812
828
|
href: t.href,
|
|
813
829
|
templated: t.templated,
|
|
814
830
|
type: t.type,
|
|
815
831
|
title: t.title,
|
|
816
832
|
rels: t.rel ? t.rel instanceof Array ? new Set(t.rel) : /* @__PURE__ */ new Set([t.rel]) : void 0,
|
|
817
|
-
properties:
|
|
833
|
+
properties: m.deserialize(t.properties),
|
|
818
834
|
height: y(t.height),
|
|
819
835
|
width: y(t.width),
|
|
820
836
|
duration: y(t.duration),
|
|
821
837
|
bitrate: y(t.bitrate),
|
|
822
|
-
languages:
|
|
823
|
-
alternates:
|
|
824
|
-
children:
|
|
838
|
+
languages: R(t.language),
|
|
839
|
+
alternates: x.deserialize(t.alternate),
|
|
840
|
+
children: x.deserialize(t.children)
|
|
825
841
|
});
|
|
826
842
|
}
|
|
827
843
|
/**
|
|
@@ -829,11 +845,11 @@ class w {
|
|
|
829
845
|
*/
|
|
830
846
|
serialize() {
|
|
831
847
|
const t = { href: this.href };
|
|
832
|
-
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 =
|
|
848
|
+
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 = ut(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.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;
|
|
833
849
|
}
|
|
834
850
|
/** MediaType of the linked resource. */
|
|
835
851
|
get mediaType() {
|
|
836
|
-
return this.type !== void 0 ?
|
|
852
|
+
return this.type !== void 0 ? a.parse({ mediaType: this.type }) : a.BINARY;
|
|
837
853
|
}
|
|
838
854
|
/** Computes an absolute URL to the link, relative to the given `baseURL`.
|
|
839
855
|
* If the link's `href` is already absolute, the `baseURL` is ignored.
|
|
@@ -842,19 +858,19 @@ class w {
|
|
|
842
858
|
const e = this.href.replace(/^(\/)/, "");
|
|
843
859
|
if (e.length === 0)
|
|
844
860
|
return;
|
|
845
|
-
let
|
|
846
|
-
return
|
|
861
|
+
let r = t || "/";
|
|
862
|
+
return r.startsWith("/") && (r = "file://" + r), new URL(e, r).href.replace(/^(file:\/\/)/, "");
|
|
847
863
|
}
|
|
848
864
|
/** List of URI template parameter keys, if the `Link` is templated. */
|
|
849
865
|
get templateParameters() {
|
|
850
|
-
return this.templated ? new
|
|
866
|
+
return this.templated ? new J(this.href).parameters : /* @__PURE__ */ new Set();
|
|
851
867
|
}
|
|
852
868
|
/** Expands the `Link`'s HREF by replacing URI template variables by the given parameters.
|
|
853
869
|
* See RFC 6570 on URI template: https://tools.ietf.org/html/rfc6570
|
|
854
870
|
*/
|
|
855
871
|
expandTemplate(t) {
|
|
856
|
-
return new
|
|
857
|
-
href: new
|
|
872
|
+
return new S({
|
|
873
|
+
href: new J(this.href).expand(t),
|
|
858
874
|
templated: !1
|
|
859
875
|
});
|
|
860
876
|
}
|
|
@@ -862,16 +878,16 @@ class w {
|
|
|
862
878
|
* Makes a copy of this [Link] after merging in the given additional other [properties].
|
|
863
879
|
*/
|
|
864
880
|
addProperties(t) {
|
|
865
|
-
var
|
|
866
|
-
const e =
|
|
867
|
-
return e.properties = e.properties ? (
|
|
881
|
+
var r;
|
|
882
|
+
const e = S.deserialize(this.serialize());
|
|
883
|
+
return e.properties = e.properties ? (r = e.properties) == null ? void 0 : r.add(t) : new m(t), e;
|
|
868
884
|
}
|
|
869
885
|
/**
|
|
870
886
|
* Creates a [Locator] from a reading order [Link].
|
|
871
887
|
*/
|
|
872
888
|
get locator() {
|
|
873
889
|
let t = this.href.split("#");
|
|
874
|
-
return new
|
|
890
|
+
return new A({
|
|
875
891
|
href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
|
|
876
892
|
type: this.type ?? "",
|
|
877
893
|
title: this.title,
|
|
@@ -881,7 +897,7 @@ class w {
|
|
|
881
897
|
});
|
|
882
898
|
}
|
|
883
899
|
}
|
|
884
|
-
class
|
|
900
|
+
class x {
|
|
885
901
|
/**
|
|
886
902
|
* Creates a [Links].
|
|
887
903
|
*/
|
|
@@ -893,8 +909,8 @@ class b {
|
|
|
893
909
|
*/
|
|
894
910
|
static deserialize(t) {
|
|
895
911
|
if (t && t instanceof Array)
|
|
896
|
-
return new
|
|
897
|
-
t.map((e) =>
|
|
912
|
+
return new x(
|
|
913
|
+
t.map((e) => S.deserialize(e)).filter((e) => e !== void 0)
|
|
898
914
|
);
|
|
899
915
|
}
|
|
900
916
|
/**
|
|
@@ -905,39 +921,39 @@ class b {
|
|
|
905
921
|
}
|
|
906
922
|
/** Finds the first link with the given relation. */
|
|
907
923
|
findWithRel(t) {
|
|
908
|
-
const e = (
|
|
924
|
+
const e = (r) => r.rels && r.rels.has(t);
|
|
909
925
|
return this.items.find(e);
|
|
910
926
|
}
|
|
911
927
|
/** Finds all the links with the given relation. */
|
|
912
928
|
filterByRel(t) {
|
|
913
|
-
const e = (
|
|
929
|
+
const e = (r) => r.rels && r.rels.has(t);
|
|
914
930
|
return this.items.filter(e);
|
|
915
931
|
}
|
|
916
932
|
/** Finds the first link matching the given HREF. */
|
|
917
933
|
findWithHref(t) {
|
|
918
|
-
const e = (
|
|
934
|
+
const e = (r) => r.href === t;
|
|
919
935
|
return this.items.find(e);
|
|
920
936
|
}
|
|
921
937
|
/** Finds the index of the first link matching the given HREF. */
|
|
922
938
|
findIndexWithHref(t) {
|
|
923
|
-
const e = (
|
|
939
|
+
const e = (r) => r.href === t;
|
|
924
940
|
return this.items.findIndex(e);
|
|
925
941
|
}
|
|
926
942
|
/** Finds the first link matching the given media type. */
|
|
927
943
|
findWithMediaType(t) {
|
|
928
|
-
const e = (
|
|
944
|
+
const e = (r) => r.mediaType.matches(t);
|
|
929
945
|
return this.items.find(e);
|
|
930
946
|
}
|
|
931
947
|
/** Finds all the links matching the given media type. */
|
|
932
948
|
filterByMediaType(t) {
|
|
933
|
-
const e = (
|
|
949
|
+
const e = (r) => r.mediaType.matches(t);
|
|
934
950
|
return this.items.filter(e);
|
|
935
951
|
}
|
|
936
952
|
/** Finds all the links matching any of the given media types. */
|
|
937
953
|
filterByMediaTypes(t) {
|
|
938
|
-
const e = (
|
|
954
|
+
const e = (r) => {
|
|
939
955
|
for (const s of t)
|
|
940
|
-
if (
|
|
956
|
+
if (r.mediaType.matches(s))
|
|
941
957
|
return !0;
|
|
942
958
|
return !1;
|
|
943
959
|
};
|
|
@@ -966,8 +982,8 @@ class b {
|
|
|
966
982
|
/** Returns whether all the resources in the collection are matching any of the given media types. */
|
|
967
983
|
everyMatchesMediaType(t) {
|
|
968
984
|
return Array.isArray(t) ? this.items.length > 0 && this.items.every((e) => {
|
|
969
|
-
for (const
|
|
970
|
-
return e.mediaType.matches(
|
|
985
|
+
for (const r of t)
|
|
986
|
+
return e.mediaType.matches(r);
|
|
971
987
|
return !1;
|
|
972
988
|
}) : this.items.length > 0 && this.items.every((e) => e.mediaType.matches(t));
|
|
973
989
|
}
|
|
@@ -975,15 +991,15 @@ class b {
|
|
|
975
991
|
return this.items.filter((t) => t.type);
|
|
976
992
|
}
|
|
977
993
|
}
|
|
978
|
-
class
|
|
994
|
+
class ft {
|
|
979
995
|
constructor(t) {
|
|
980
996
|
this.links = t.links, this.guided = t.guided;
|
|
981
997
|
}
|
|
982
998
|
static deserialize(t) {
|
|
983
999
|
if (t)
|
|
984
|
-
return new
|
|
985
|
-
links:
|
|
986
|
-
guided:
|
|
1000
|
+
return new ft({
|
|
1001
|
+
links: x.deserialize(t.links),
|
|
1002
|
+
guided: k.deserializeArray(t.guided)
|
|
987
1003
|
});
|
|
988
1004
|
}
|
|
989
1005
|
serialize() {
|
|
@@ -991,7 +1007,7 @@ class Q {
|
|
|
991
1007
|
return this.links !== void 0 && (t.links = this.links.serialize()), this.guided !== void 0 && (t.guided = this.guided.map((e) => e.serialize())), t;
|
|
992
1008
|
}
|
|
993
1009
|
}
|
|
994
|
-
class
|
|
1010
|
+
class k {
|
|
995
1011
|
/**
|
|
996
1012
|
* Creates a [GuidedNavigation] object.
|
|
997
1013
|
*/
|
|
@@ -1005,11 +1021,11 @@ class L {
|
|
|
1005
1021
|
*/
|
|
1006
1022
|
static deserialize(t) {
|
|
1007
1023
|
if (t)
|
|
1008
|
-
return new
|
|
1024
|
+
return new k({
|
|
1009
1025
|
audioref: t.audioref,
|
|
1010
|
-
children:
|
|
1026
|
+
children: k.deserializeArray(t.children),
|
|
1011
1027
|
imgref: t.imgref,
|
|
1012
|
-
role: t.role ? new Set(
|
|
1028
|
+
role: t.role ? new Set(R(t.role)) : void 0,
|
|
1013
1029
|
text: t.text,
|
|
1014
1030
|
textref: t.textref
|
|
1015
1031
|
});
|
|
@@ -1019,14 +1035,14 @@ class L {
|
|
|
1019
1035
|
*/
|
|
1020
1036
|
static deserializeArray(t) {
|
|
1021
1037
|
if (t instanceof Array)
|
|
1022
|
-
return t.map((e) =>
|
|
1038
|
+
return t.map((e) => k.deserialize(e)).filter((e) => e !== void 0);
|
|
1023
1039
|
}
|
|
1024
1040
|
/**
|
|
1025
1041
|
* Serializes a [GuidedNavigationObject] to its RWPM JSON representation.
|
|
1026
1042
|
*/
|
|
1027
1043
|
serialize() {
|
|
1028
1044
|
const t = {};
|
|
1029
|
-
return this.audioref !== void 0 && (t.audioref = this.audioref), this.children !== void 0 && (t.children = this.children.map((e) => e.serialize())), this.imgref !== void 0 && (t.imgref = this.imgref), this.role !== void 0 && (t.role =
|
|
1045
|
+
return this.audioref !== void 0 && (t.audioref = this.audioref), this.children !== void 0 && (t.children = this.children.map((e) => e.serialize())), this.imgref !== void 0 && (t.imgref = this.imgref), this.role !== void 0 && (t.role = ut(this.role)), this.text !== void 0 && (t.text = this.text), this.textref !== void 0 && (t.textref = this.textref), t;
|
|
1030
1046
|
}
|
|
1031
1047
|
get audioFile() {
|
|
1032
1048
|
var t;
|
|
@@ -1050,32 +1066,32 @@ class L {
|
|
|
1050
1066
|
const t = this.audioFile;
|
|
1051
1067
|
if (!t)
|
|
1052
1068
|
return;
|
|
1053
|
-
const e = this.audioTime,
|
|
1069
|
+
const e = this.audioTime, r = {
|
|
1054
1070
|
audioResource: t,
|
|
1055
1071
|
fragmentId: this.fragmentId
|
|
1056
1072
|
};
|
|
1057
1073
|
if (!e)
|
|
1058
|
-
return
|
|
1074
|
+
return r;
|
|
1059
1075
|
const s = this.parseTimer(e);
|
|
1060
|
-
return
|
|
1076
|
+
return r.start = s[0], r.end = s[1], r;
|
|
1061
1077
|
}
|
|
1062
1078
|
parseTimer(t) {
|
|
1063
1079
|
if (!t || !t.startsWith("t="))
|
|
1064
1080
|
return [void 0, void 0];
|
|
1065
|
-
const e = t.substring(2).split(",").map((
|
|
1081
|
+
const e = t.substring(2).split(",").map((r) => parseFloat(r));
|
|
1066
1082
|
return e.length === 1 ? [isNaN(e[0]) ? void 0 : e[0], void 0] : e.length > 2 ? [void 0, void 0] : [isNaN(e[0]) ? void 0 : e[0], isNaN(e[1]) ? void 0 : e[1]];
|
|
1067
1083
|
}
|
|
1068
1084
|
}
|
|
1069
|
-
function
|
|
1070
|
-
return t.length > 1 ? t.indexOf(
|
|
1085
|
+
function Ne(i, t) {
|
|
1086
|
+
return t.length > 1 ? t.indexOf(i.slice(-1)) > -1 : i.slice(-1) === t;
|
|
1071
1087
|
}
|
|
1072
|
-
function
|
|
1073
|
-
return
|
|
1088
|
+
function Pe(i, t) {
|
|
1089
|
+
return i.slice(i.length - t.length) === t;
|
|
1074
1090
|
}
|
|
1075
|
-
const
|
|
1076
|
-
endsWith:
|
|
1077
|
-
endsWithChar:
|
|
1078
|
-
},
|
|
1091
|
+
const et = {
|
|
1092
|
+
endsWith: Pe,
|
|
1093
|
+
endsWithChar: Ne
|
|
1094
|
+
}, Ce = [
|
|
1079
1095
|
"ie",
|
|
1080
1096
|
"eg",
|
|
1081
1097
|
"ext",
|
|
@@ -1167,218 +1183,218 @@ const Z = {
|
|
|
1167
1183
|
"Fri",
|
|
1168
1184
|
"Sat"
|
|
1169
1185
|
];
|
|
1170
|
-
function
|
|
1171
|
-
return /^[A-Z][a-z].*/.test(
|
|
1186
|
+
function Lt(i) {
|
|
1187
|
+
return /^[A-Z][a-z].*/.test(i) || st(i);
|
|
1172
1188
|
}
|
|
1173
|
-
function
|
|
1174
|
-
return
|
|
1189
|
+
function Re(i) {
|
|
1190
|
+
return Lt(i) || /``|"|'/.test(i.substring(0, 2));
|
|
1175
1191
|
}
|
|
1176
|
-
function
|
|
1177
|
-
return ~
|
|
1192
|
+
function Le(i) {
|
|
1193
|
+
return ~Ce.indexOf(i.replace(/\W+/g, ""));
|
|
1178
1194
|
}
|
|
1179
|
-
function
|
|
1180
|
-
if (
|
|
1195
|
+
function ke(i, t) {
|
|
1196
|
+
if (i === "a.m." || i === "p.m.") {
|
|
1181
1197
|
var e = t.replace(/\W+/g, "").slice(-3).toLowerCase();
|
|
1182
1198
|
if (e === "day")
|
|
1183
1199
|
return !0;
|
|
1184
1200
|
}
|
|
1185
1201
|
return !1;
|
|
1186
1202
|
}
|
|
1187
|
-
function
|
|
1188
|
-
var t =
|
|
1203
|
+
function St(i) {
|
|
1204
|
+
var t = i.replace(/[\(\)\[\]\{\}]/g, "").match(/(.\.)*/);
|
|
1189
1205
|
return t && t[0].length > 0;
|
|
1190
1206
|
}
|
|
1191
|
-
function
|
|
1192
|
-
return
|
|
1207
|
+
function It(i) {
|
|
1208
|
+
return i.length <= 3 ? !0 : Lt(i);
|
|
1193
1209
|
}
|
|
1194
|
-
function
|
|
1195
|
-
return t && (
|
|
1210
|
+
function st(i, t) {
|
|
1211
|
+
return t && (i = i.slice(t - 1, t + 2)), !isNaN(Number(i));
|
|
1196
1212
|
}
|
|
1197
|
-
function
|
|
1198
|
-
return
|
|
1213
|
+
function De(i) {
|
|
1214
|
+
return i.match(/^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:\(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*\)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/);
|
|
1199
1215
|
}
|
|
1200
|
-
function
|
|
1201
|
-
return
|
|
1216
|
+
function Ue(i) {
|
|
1217
|
+
return i.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
|
|
1202
1218
|
}
|
|
1203
|
-
function
|
|
1219
|
+
function Be(i) {
|
|
1204
1220
|
var t = 0;
|
|
1205
|
-
if ((t =
|
|
1206
|
-
var e =
|
|
1221
|
+
if ((t = i.indexOf(".")) > -1 || (t = i.indexOf("!")) > -1 || (t = i.indexOf("?")) > -1) {
|
|
1222
|
+
var e = i.charAt(t + 1);
|
|
1207
1223
|
if (e.match(/[a-zA-Z].*/))
|
|
1208
|
-
return [
|
|
1224
|
+
return [i.slice(0, t), i.charAt(t), i.slice(t + 1)];
|
|
1209
1225
|
}
|
|
1210
1226
|
return !1;
|
|
1211
1227
|
}
|
|
1212
|
-
function
|
|
1213
|
-
return
|
|
1228
|
+
function Fe(i) {
|
|
1229
|
+
return i === "." || i === "!" || i === "?";
|
|
1214
1230
|
}
|
|
1215
|
-
function
|
|
1231
|
+
function We(i, t) {
|
|
1216
1232
|
t = Object.assign(t || {}, {
|
|
1217
1233
|
newlineBoundary: t && t.newlineBoundary || !0
|
|
1218
1234
|
});
|
|
1219
1235
|
var e = /\s/;
|
|
1220
|
-
return
|
|
1236
|
+
return i.serie(
|
|
1221
1237
|
// Split into words
|
|
1222
|
-
|
|
1238
|
+
i.re(e, { split: !0 }),
|
|
1223
1239
|
// Merge words as sentences
|
|
1224
|
-
|
|
1225
|
-
var
|
|
1226
|
-
return !e.test(
|
|
1240
|
+
i.splitAndMerge(function(r, s, n, o, l, c) {
|
|
1241
|
+
var h, u = [r, null], p = r, f = c.slice(l + 1).find(function(I) {
|
|
1242
|
+
return !e.test(I.value);
|
|
1227
1243
|
});
|
|
1228
|
-
if (
|
|
1229
|
-
` && t.newlineBoundary ||
|
|
1230
|
-
return
|
|
1231
|
-
if (
|
|
1232
|
-
if (
|
|
1233
|
-
if (
|
|
1234
|
-
return
|
|
1235
|
-
if (
|
|
1236
|
-
if (
|
|
1237
|
-
return
|
|
1238
|
-
} else if (
|
|
1239
|
-
return
|
|
1244
|
+
if (r === `
|
|
1245
|
+
` && t.newlineBoundary || Fe(r) || et.endsWithChar(r, "?!"))
|
|
1246
|
+
return u;
|
|
1247
|
+
if (et.endsWithChar(r, ".")) {
|
|
1248
|
+
if (f) {
|
|
1249
|
+
if (r.length === 2 && isNaN(r.charAt(0)) && r.match(/[a-zA-Z]/) || Le(r))
|
|
1250
|
+
return p;
|
|
1251
|
+
if (Re(f.value)) {
|
|
1252
|
+
if (ke(r, f.value) || st(f.value) && It(r))
|
|
1253
|
+
return p;
|
|
1254
|
+
} else if (et.endsWith(r, "..") || St(r) || It(r))
|
|
1255
|
+
return p;
|
|
1240
1256
|
}
|
|
1241
|
-
return
|
|
1257
|
+
return u;
|
|
1242
1258
|
}
|
|
1243
1259
|
let d;
|
|
1244
|
-
return (d =
|
|
1245
|
-
|
|
1260
|
+
return (d = r.indexOf(".")) > -1 && (st(r, d) || St(r) || Ue(r) || De(r)) ? p : (h = Be(r)) ? [
|
|
1261
|
+
h[0] + h[1],
|
|
1246
1262
|
null,
|
|
1247
|
-
|
|
1248
|
-
] :
|
|
1263
|
+
h[2]
|
|
1264
|
+
] : p;
|
|
1249
1265
|
}),
|
|
1250
1266
|
// Filter empty sentences
|
|
1251
|
-
|
|
1252
|
-
return
|
|
1267
|
+
i.filter(function(r) {
|
|
1268
|
+
return r.trim() != "";
|
|
1253
1269
|
})
|
|
1254
1270
|
);
|
|
1255
1271
|
}
|
|
1256
|
-
const
|
|
1257
|
-
function
|
|
1272
|
+
const Me = (i, ...t) => (...e) => i(...t, ...e);
|
|
1273
|
+
function $e(i) {
|
|
1258
1274
|
return {
|
|
1259
|
-
sentences:
|
|
1275
|
+
sentences: Me(We, i)
|
|
1260
1276
|
};
|
|
1261
1277
|
}
|
|
1262
|
-
function
|
|
1263
|
-
return t ?
|
|
1278
|
+
function Ge(i, t) {
|
|
1279
|
+
return t ? i.reduce(function(e, r) {
|
|
1264
1280
|
var s = [
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1281
|
+
r.index,
|
|
1282
|
+
r.offset,
|
|
1283
|
+
r.value
|
|
1268
1284
|
].join("-");
|
|
1269
1285
|
return [e, s].join(":");
|
|
1270
1286
|
}, t) : null;
|
|
1271
1287
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const { index: t, offset: e, value:
|
|
1288
|
+
function He(i) {
|
|
1289
|
+
const { index: t, offset: e, value: r, ...s } = i;
|
|
1274
1290
|
return s;
|
|
1275
1291
|
}
|
|
1276
|
-
function
|
|
1292
|
+
function Ve(i, t) {
|
|
1277
1293
|
var e = 0;
|
|
1278
|
-
return Array.isArray(t) || (t = [t]), t.map(function(
|
|
1279
|
-
return
|
|
1280
|
-
value:
|
|
1294
|
+
return Array.isArray(t) || (t = [t]), t.map(function(r) {
|
|
1295
|
+
return r === null ? null : (typeof r == "string" && (r = {
|
|
1296
|
+
value: r,
|
|
1281
1297
|
index: e,
|
|
1282
|
-
offset:
|
|
1283
|
-
}), typeof
|
|
1298
|
+
offset: r.length
|
|
1299
|
+
}), typeof r == "object" && (r.index = r.index || 0, e = e + r.index + r.offset, r.index = i.index + r.index, r.offset = r.offset || r.value.length), r);
|
|
1284
1300
|
});
|
|
1285
1301
|
}
|
|
1286
|
-
function
|
|
1287
|
-
var
|
|
1288
|
-
if (
|
|
1302
|
+
function Je(i, t) {
|
|
1303
|
+
var n;
|
|
1304
|
+
if (i.length == 0)
|
|
1289
1305
|
return null;
|
|
1290
|
-
var e = "",
|
|
1291
|
-
return
|
|
1292
|
-
var
|
|
1293
|
-
|
|
1294
|
-
var
|
|
1295
|
-
e = e + new Array(
|
|
1296
|
-
var
|
|
1297
|
-
|
|
1306
|
+
var e = "", r = 0, s = (n = i[0]) == null ? void 0 : n.index;
|
|
1307
|
+
return i.forEach(function(o, l) {
|
|
1308
|
+
var c = i[l - 1];
|
|
1309
|
+
i[l + 1];
|
|
1310
|
+
var h = c ? o.index + 1 - (c.index + c.offset) : 0;
|
|
1311
|
+
e = e + new Array(h).join(t) + o.value;
|
|
1312
|
+
var u = o.index - s + o.offset;
|
|
1313
|
+
u > r && (r = u);
|
|
1298
1314
|
}), {
|
|
1299
1315
|
// Index equal is the one from the first token
|
|
1300
1316
|
index: s,
|
|
1301
1317
|
value: e,
|
|
1302
|
-
offset: Math.max(
|
|
1318
|
+
offset: Math.max(r, e.length)
|
|
1303
1319
|
};
|
|
1304
1320
|
}
|
|
1305
|
-
const
|
|
1306
|
-
tokensId:
|
|
1307
|
-
normalize:
|
|
1308
|
-
properties:
|
|
1309
|
-
merge:
|
|
1321
|
+
const D = {
|
|
1322
|
+
tokensId: Ge,
|
|
1323
|
+
normalize: Ve,
|
|
1324
|
+
properties: He,
|
|
1325
|
+
merge: Je
|
|
1310
1326
|
};
|
|
1311
|
-
var
|
|
1312
|
-
"([^" +
|
|
1327
|
+
var Ye = ' \r\n !"#$%&()*+,-.\\/:;<=>?@[\\]^_`{|}~', qe = new RegExp(
|
|
1328
|
+
"([^" + Ye + "]+)"
|
|
1313
1329
|
);
|
|
1314
|
-
function
|
|
1315
|
-
if (!(this instanceof
|
|
1316
|
-
return new
|
|
1330
|
+
function w(i) {
|
|
1331
|
+
if (!(this instanceof w))
|
|
1332
|
+
return new w(i);
|
|
1317
1333
|
this.opts = Object.assign({
|
|
1318
1334
|
cacheGet: function(t) {
|
|
1319
1335
|
return null;
|
|
1320
1336
|
},
|
|
1321
1337
|
cacheSet: function(t, e) {
|
|
1322
1338
|
}
|
|
1323
|
-
},
|
|
1339
|
+
}, i);
|
|
1324
1340
|
}
|
|
1325
|
-
|
|
1326
|
-
var
|
|
1327
|
-
return e = Object.assign({ preserveProperties: !0, cache: () => null }, e), function(s,
|
|
1341
|
+
w.prototype.split = function(t, e = {}) {
|
|
1342
|
+
var r = this;
|
|
1343
|
+
return e = Object.assign({ preserveProperties: !0, cache: () => null }, e), function(s, n) {
|
|
1328
1344
|
if (arguments.length === 6)
|
|
1329
1345
|
return t.apply(null, arguments);
|
|
1330
|
-
var o, l,
|
|
1346
|
+
var o, l, c;
|
|
1331
1347
|
if (s === void 0)
|
|
1332
1348
|
return [];
|
|
1333
1349
|
if (typeof s == "string" ? s = [{
|
|
1334
1350
|
value: s,
|
|
1335
1351
|
index: 0,
|
|
1336
1352
|
offset: s.length
|
|
1337
|
-
}] : Array.isArray(s) || (s = [s]), l =
|
|
1338
|
-
return
|
|
1339
|
-
var
|
|
1340
|
-
var
|
|
1341
|
-
|
|
1342
|
-
Object.assign({},
|
|
1353
|
+
}] : Array.isArray(s) || (s = [s]), l = D.tokensId(s, e.cache()), l && (c = r.opts.cacheGet(l), c))
|
|
1354
|
+
return c;
|
|
1355
|
+
var h = s.map(function(u, p) {
|
|
1356
|
+
var f = s[p + 1], d = t(
|
|
1357
|
+
u.value,
|
|
1358
|
+
Object.assign({}, u),
|
|
1343
1359
|
o ? Object.assign({}, o) : null,
|
|
1344
|
-
|
|
1345
|
-
|
|
1360
|
+
f ? Object.assign({}, f) : null,
|
|
1361
|
+
p,
|
|
1346
1362
|
s
|
|
1347
1363
|
) || [];
|
|
1348
|
-
if (d =
|
|
1349
|
-
var
|
|
1350
|
-
d = d.map(function(
|
|
1351
|
-
return Object.assign({},
|
|
1364
|
+
if (d = D.normalize(u, d), e.preserveProperties) {
|
|
1365
|
+
var I = D.properties(u);
|
|
1366
|
+
d = d.map(function(L) {
|
|
1367
|
+
return Object.assign({}, L, I);
|
|
1352
1368
|
});
|
|
1353
1369
|
}
|
|
1354
|
-
return o =
|
|
1370
|
+
return o = u, d;
|
|
1355
1371
|
}).filter(Boolean).flat();
|
|
1356
|
-
return l &&
|
|
1372
|
+
return l && r.opts.cacheSet(l, h), h;
|
|
1357
1373
|
};
|
|
1358
1374
|
};
|
|
1359
|
-
|
|
1360
|
-
return e = Object.assign({ split: !1 }, e), this.split(function(
|
|
1361
|
-
for (var
|
|
1362
|
-
var
|
|
1363
|
-
if (e.split &&
|
|
1364
|
-
var d =
|
|
1375
|
+
w.prototype.re = function(t, e = {}) {
|
|
1376
|
+
return e = Object.assign({ split: !1 }, e), this.split(function(r, s) {
|
|
1377
|
+
for (var n = r, o = [], l, c = 0; l = t.exec(r); ) {
|
|
1378
|
+
var h = l.index, u = c + h, p = l[0] || "", f = p.length;
|
|
1379
|
+
if (e.split && c < u) {
|
|
1380
|
+
var d = n.slice(c, u);
|
|
1365
1381
|
o.push({
|
|
1366
1382
|
value: d,
|
|
1367
|
-
index:
|
|
1383
|
+
index: c,
|
|
1368
1384
|
offset: d.length
|
|
1369
1385
|
});
|
|
1370
1386
|
}
|
|
1371
1387
|
o.push({
|
|
1372
|
-
value:
|
|
1373
|
-
index:
|
|
1374
|
-
offset:
|
|
1388
|
+
value: p,
|
|
1389
|
+
index: u,
|
|
1390
|
+
offset: f,
|
|
1375
1391
|
match: l
|
|
1376
|
-
}),
|
|
1392
|
+
}), r = r.slice(h + f), c = u + f;
|
|
1377
1393
|
}
|
|
1378
|
-
return e.split &&
|
|
1379
|
-
value:
|
|
1380
|
-
index:
|
|
1381
|
-
offset:
|
|
1394
|
+
return e.split && r && o.push({
|
|
1395
|
+
value: r,
|
|
1396
|
+
index: c,
|
|
1397
|
+
offset: r.length
|
|
1382
1398
|
}), o;
|
|
1383
1399
|
}, {
|
|
1384
1400
|
cache: function() {
|
|
@@ -1386,81 +1402,81 @@ z.prototype.re = function(t, e = {}) {
|
|
|
1386
1402
|
}
|
|
1387
1403
|
});
|
|
1388
1404
|
};
|
|
1389
|
-
|
|
1390
|
-
var
|
|
1405
|
+
w.prototype.splitAndMerge = function(t, e = {}) {
|
|
1406
|
+
var r = this;
|
|
1391
1407
|
return e = Object.assign({ mergeWith: "" }, e), function(s) {
|
|
1392
|
-
var
|
|
1408
|
+
var n = [], o = [];
|
|
1393
1409
|
function l() {
|
|
1394
1410
|
if (o.length != 0) {
|
|
1395
|
-
var
|
|
1396
|
-
|
|
1411
|
+
var c = D.merge(o, e.mergeWith);
|
|
1412
|
+
n.push(c), o = [];
|
|
1397
1413
|
}
|
|
1398
1414
|
}
|
|
1399
|
-
return
|
|
1400
|
-
var
|
|
1401
|
-
|
|
1402
|
-
|
|
1415
|
+
return r.split(function(c, h) {
|
|
1416
|
+
var u = t.apply(null, arguments);
|
|
1417
|
+
u = D.normalize(h, u), u.forEach(function(p) {
|
|
1418
|
+
p === null ? l() : o.push(p);
|
|
1403
1419
|
});
|
|
1404
|
-
})(s), l(),
|
|
1420
|
+
})(s), l(), n;
|
|
1405
1421
|
};
|
|
1406
1422
|
};
|
|
1407
|
-
|
|
1408
|
-
return this.split(function(e,
|
|
1423
|
+
w.prototype.filter = function(t) {
|
|
1424
|
+
return this.split(function(e, r) {
|
|
1409
1425
|
if (t.apply(null, arguments))
|
|
1410
1426
|
return {
|
|
1411
|
-
value:
|
|
1427
|
+
value: r.value,
|
|
1412
1428
|
index: 0,
|
|
1413
|
-
offset:
|
|
1429
|
+
offset: r.offset
|
|
1414
1430
|
};
|
|
1415
1431
|
});
|
|
1416
1432
|
};
|
|
1417
|
-
|
|
1418
|
-
return this.split(function(e,
|
|
1433
|
+
w.prototype.extend = function(t) {
|
|
1434
|
+
return this.split(function(e, r) {
|
|
1419
1435
|
var s = typeof t == "function" ? t.apply(null, arguments) : t;
|
|
1420
1436
|
return Object.assign({
|
|
1421
|
-
value:
|
|
1437
|
+
value: r.value,
|
|
1422
1438
|
index: 0,
|
|
1423
|
-
offset:
|
|
1439
|
+
offset: r.offset
|
|
1424
1440
|
}, s);
|
|
1425
1441
|
});
|
|
1426
1442
|
};
|
|
1427
|
-
|
|
1428
|
-
return this.split(function(e,
|
|
1429
|
-
if (
|
|
1443
|
+
w.prototype.ifthen = function(i, t) {
|
|
1444
|
+
return this.split(function(e, r) {
|
|
1445
|
+
if (i.apply(null, arguments))
|
|
1430
1446
|
return t.apply(null, arguments);
|
|
1431
|
-
const { index: s, ...
|
|
1432
|
-
return
|
|
1447
|
+
const { index: s, ...n } = r;
|
|
1448
|
+
return n;
|
|
1433
1449
|
});
|
|
1434
1450
|
};
|
|
1435
|
-
|
|
1436
|
-
return this.filter(function(e,
|
|
1451
|
+
w.prototype.test = function(t) {
|
|
1452
|
+
return this.filter(function(e, r) {
|
|
1437
1453
|
return t.test(e);
|
|
1438
1454
|
}, {
|
|
1439
1455
|
cache: t.toString()
|
|
1440
1456
|
});
|
|
1441
1457
|
};
|
|
1442
|
-
|
|
1443
|
-
const e = t.reduce((
|
|
1458
|
+
w.prototype.flow = function(...t) {
|
|
1459
|
+
const e = t.reduce((r, s) => (...n) => s(r(...n)));
|
|
1444
1460
|
return this.split(e);
|
|
1445
1461
|
};
|
|
1446
|
-
|
|
1447
|
-
return t.reduce((e,
|
|
1462
|
+
w.prototype.serie = function(...t) {
|
|
1463
|
+
return t.reduce((e, r) => (...s) => r(e(...s)));
|
|
1448
1464
|
};
|
|
1449
|
-
|
|
1450
|
-
return this.splitAndMerge((
|
|
1465
|
+
w.prototype.merge = function() {
|
|
1466
|
+
return this.splitAndMerge((i) => [i]);
|
|
1451
1467
|
};
|
|
1452
|
-
|
|
1468
|
+
w.prototype.sections = function() {
|
|
1453
1469
|
return this.re(/([^\n\.,;!?]+)/i, { split: !1 });
|
|
1454
1470
|
};
|
|
1455
|
-
|
|
1456
|
-
return this.re(
|
|
1471
|
+
w.prototype.words = function() {
|
|
1472
|
+
return this.re(qe);
|
|
1457
1473
|
};
|
|
1458
|
-
|
|
1474
|
+
w.prototype.characters = function() {
|
|
1459
1475
|
return this.re(/[^\s]/);
|
|
1460
1476
|
};
|
|
1461
|
-
var
|
|
1462
|
-
const
|
|
1463
|
-
class
|
|
1477
|
+
var Ke = /* @__PURE__ */ ((i) => (i.Word = "word", i.Sentence = "sentence", i.Paragraph = "paragraph", i))(Ke || {});
|
|
1478
|
+
const Ze = (i, t) => "Segmenter" in Intl ? new Xe(i, t) : new Qe(i, t);
|
|
1479
|
+
class Xe {
|
|
1464
1480
|
constructor(t, e) {
|
|
1465
1481
|
if (this.unit = e, t = t ?? (navigator == null ? void 0 : navigator.language), !("Segmenter" in Intl))
|
|
1466
1482
|
throw new Error("Intl.Segmenter is not supported in this environment");
|
|
@@ -1471,21 +1487,21 @@ class ee {
|
|
|
1471
1487
|
});
|
|
1472
1488
|
}
|
|
1473
1489
|
tokenize(t) {
|
|
1474
|
-
const e = this.segmenter.segment(t),
|
|
1490
|
+
const e = this.segmenter.segment(t), r = [];
|
|
1475
1491
|
for (let s of e) {
|
|
1476
1492
|
if (this.unit === "word" && s.isWordLike === !1)
|
|
1477
1493
|
continue;
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1494
|
+
const n = kt(s.segment);
|
|
1495
|
+
n !== null && r.push([s.index, s.index + n.length]);
|
|
1480
1496
|
}
|
|
1481
|
-
return
|
|
1497
|
+
return r;
|
|
1482
1498
|
}
|
|
1483
1499
|
}
|
|
1484
|
-
class
|
|
1500
|
+
class Qe {
|
|
1485
1501
|
constructor(t, e) {
|
|
1486
1502
|
if (this.unit = e, t = t ?? (navigator == null ? void 0 : navigator.language), this.isEnglish = t.toLowerCase().split("-")[0] === "en", e === "paragraph")
|
|
1487
1503
|
throw new Error("NaiveTextTokenizer does not handle TextUnit.Paragraph");
|
|
1488
|
-
this.tokenizer = new
|
|
1504
|
+
this.tokenizer = new w();
|
|
1489
1505
|
}
|
|
1490
1506
|
tokenize(t) {
|
|
1491
1507
|
let e = [];
|
|
@@ -1494,29 +1510,29 @@ class ie {
|
|
|
1494
1510
|
e = this.tokenizer.words()(t);
|
|
1495
1511
|
break;
|
|
1496
1512
|
case "sentence":
|
|
1497
|
-
this.isEnglish ? e =
|
|
1513
|
+
this.isEnglish ? e = $e(this.tokenizer).sentences()(t) : e = this.tokenizer.sections()(t);
|
|
1498
1514
|
break;
|
|
1499
1515
|
default:
|
|
1500
1516
|
e = [];
|
|
1501
1517
|
}
|
|
1502
1518
|
if (!e)
|
|
1503
1519
|
return [];
|
|
1504
|
-
const
|
|
1520
|
+
const r = [];
|
|
1505
1521
|
return e.forEach((s) => {
|
|
1506
1522
|
if (s.value.length === 0)
|
|
1507
1523
|
return;
|
|
1508
|
-
const
|
|
1509
|
-
|
|
1510
|
-
}),
|
|
1524
|
+
const n = kt(s.value);
|
|
1525
|
+
n !== null && r.push([s.index, s.index + n.length]);
|
|
1526
|
+
}), r;
|
|
1511
1527
|
}
|
|
1512
1528
|
}
|
|
1513
|
-
const
|
|
1514
|
-
const t =
|
|
1515
|
-
return t.length === 0 || t.match(
|
|
1529
|
+
const _e = new RegExp("[\\p{L}\\p{N}]+", "u"), kt = (i) => {
|
|
1530
|
+
const t = i.trimEnd();
|
|
1531
|
+
return t.length === 0 || t.match(_e) === null ? null : t;
|
|
1516
1532
|
};
|
|
1517
|
-
class
|
|
1533
|
+
class N {
|
|
1518
1534
|
constructor(t) {
|
|
1519
|
-
this.fetcher = new
|
|
1535
|
+
this.fetcher = new Ae(), t.fetcher && (this.fetcher = t.fetcher), this.manifest = t.manifest, this.context = t.manifest.context, this.metadata = t.manifest.metadata, this.links = t.manifest.links, this.readingOrder = t.manifest.readingOrder, this.resources = t.manifest.resources, this.tableOfContents = t.manifest.tableOfContents, this.subcollections = t.manifest.subcollections;
|
|
1520
1536
|
}
|
|
1521
1537
|
/** The URL where this publication is served, computed from the `Link` with `self` relation.
|
|
1522
1538
|
* e.g. https://provider.com/pub1293/manifest.json gives https://provider.com/pub1293/
|
|
@@ -1533,8 +1549,8 @@ class I {
|
|
|
1533
1549
|
* empty list.
|
|
1534
1550
|
*/
|
|
1535
1551
|
linksWithRole(t) {
|
|
1536
|
-
var
|
|
1537
|
-
const e = (
|
|
1552
|
+
var r;
|
|
1553
|
+
const e = (r = this.subcollections) == null ? void 0 : r.get(t);
|
|
1538
1554
|
return e && e.length > 0 ? e[0].links : void 0;
|
|
1539
1555
|
}
|
|
1540
1556
|
/** Finds all the links with the given relation in the publication's links. */
|
|
@@ -1556,7 +1572,7 @@ class I {
|
|
|
1556
1572
|
const e = await this.get(
|
|
1557
1573
|
t
|
|
1558
1574
|
).readAsJSON();
|
|
1559
|
-
return e.total ? e.positions.map((
|
|
1575
|
+
return e.total ? e.positions.map((r) => A.deserialize(r)).filter((r) => r !== void 0) : [];
|
|
1560
1576
|
}
|
|
1561
1577
|
async guideForLink(t) {
|
|
1562
1578
|
const e = (o) => {
|
|
@@ -1565,24 +1581,24 @@ class I {
|
|
|
1565
1581
|
"application/guided-navigation+json"
|
|
1566
1582
|
);
|
|
1567
1583
|
};
|
|
1568
|
-
let
|
|
1569
|
-
if (!
|
|
1584
|
+
let r = e(t);
|
|
1585
|
+
if (!r) {
|
|
1570
1586
|
const o = this.linkWithHref(t.href);
|
|
1571
|
-
o !== void 0 && (
|
|
1587
|
+
o !== void 0 && (r = e(o));
|
|
1572
1588
|
}
|
|
1573
|
-
if (
|
|
1589
|
+
if (r || (r = this.manifest.links.findWithMediaType(
|
|
1574
1590
|
"application/guided-navigation+json"
|
|
1575
|
-
)), !
|
|
1591
|
+
)), !r)
|
|
1576
1592
|
return;
|
|
1577
|
-
let s =
|
|
1578
|
-
if (
|
|
1579
|
-
const o = new
|
|
1580
|
-
o.parameters.has("ref") && (l.ref = t.href), s = new
|
|
1593
|
+
let s = r.href;
|
|
1594
|
+
if (r.templated) {
|
|
1595
|
+
const o = new J(s), l = {};
|
|
1596
|
+
o.parameters.has("ref") && (l.ref = t.href), s = new J(s).expand(l);
|
|
1581
1597
|
}
|
|
1582
|
-
const
|
|
1598
|
+
const n = await this.get(new S({
|
|
1583
1599
|
href: s
|
|
1584
1600
|
})).readAsJSON();
|
|
1585
|
-
return
|
|
1601
|
+
return ft.deserialize(n);
|
|
1586
1602
|
}
|
|
1587
1603
|
/**
|
|
1588
1604
|
* Returns the resource targeted by the given non-templated [link].
|
|
@@ -1591,25 +1607,25 @@ class I {
|
|
|
1591
1607
|
return this.fetcher.get(t);
|
|
1592
1608
|
}
|
|
1593
1609
|
}
|
|
1594
|
-
|
|
1610
|
+
N.prototype.getPageList = function() {
|
|
1595
1611
|
return this.linksWithRole("pageList");
|
|
1596
1612
|
};
|
|
1597
|
-
|
|
1613
|
+
N.prototype.getLandmarks = function() {
|
|
1598
1614
|
return this.linksWithRole("landmarks");
|
|
1599
1615
|
};
|
|
1600
|
-
|
|
1616
|
+
N.prototype.getListOfAudioClips = function() {
|
|
1601
1617
|
return this.linksWithRole("loa");
|
|
1602
1618
|
};
|
|
1603
|
-
|
|
1619
|
+
N.prototype.getListOfIllustrations = function() {
|
|
1604
1620
|
return this.linksWithRole("loi");
|
|
1605
1621
|
};
|
|
1606
|
-
|
|
1622
|
+
N.prototype.getListOfTables = function() {
|
|
1607
1623
|
return this.linksWithRole("lot");
|
|
1608
1624
|
};
|
|
1609
|
-
|
|
1625
|
+
N.prototype.getListOfVideoClips = function() {
|
|
1610
1626
|
return this.linksWithRole("lov");
|
|
1611
1627
|
};
|
|
1612
|
-
class
|
|
1628
|
+
class q {
|
|
1613
1629
|
/**
|
|
1614
1630
|
* Creates a [DomRange].
|
|
1615
1631
|
*/
|
|
@@ -1625,11 +1641,11 @@ class G {
|
|
|
1625
1641
|
let e = y(t.textNodeIndex);
|
|
1626
1642
|
if (e === void 0)
|
|
1627
1643
|
return;
|
|
1628
|
-
let
|
|
1629
|
-
return
|
|
1644
|
+
let r = y(t.charOffset);
|
|
1645
|
+
return r === void 0 && (r = y(t.offset)), new q({
|
|
1630
1646
|
cssSelector: t.cssSelector,
|
|
1631
1647
|
textNodeIndex: e,
|
|
1632
|
-
charOffset:
|
|
1648
|
+
charOffset: r
|
|
1633
1649
|
});
|
|
1634
1650
|
}
|
|
1635
1651
|
/**
|
|
@@ -1643,7 +1659,7 @@ class G {
|
|
|
1643
1659
|
return this.charOffset !== void 0 && (t.charOffset = this.charOffset), t;
|
|
1644
1660
|
}
|
|
1645
1661
|
}
|
|
1646
|
-
class
|
|
1662
|
+
class pt {
|
|
1647
1663
|
/**
|
|
1648
1664
|
* Creates a [DomRange].
|
|
1649
1665
|
*/
|
|
@@ -1656,11 +1672,11 @@ class _ {
|
|
|
1656
1672
|
static deserialize(t) {
|
|
1657
1673
|
if (!t)
|
|
1658
1674
|
return;
|
|
1659
|
-
let e =
|
|
1675
|
+
let e = q.deserialize(t.start);
|
|
1660
1676
|
if (e)
|
|
1661
|
-
return new
|
|
1677
|
+
return new pt({
|
|
1662
1678
|
start: e,
|
|
1663
|
-
end:
|
|
1679
|
+
end: q.deserialize(t.end)
|
|
1664
1680
|
});
|
|
1665
1681
|
}
|
|
1666
1682
|
/**
|
|
@@ -1672,54 +1688,54 @@ class _ {
|
|
|
1672
1688
|
}
|
|
1673
1689
|
}
|
|
1674
1690
|
E.prototype.getCssSelector = function() {
|
|
1675
|
-
var
|
|
1676
|
-
return (
|
|
1691
|
+
var i;
|
|
1692
|
+
return (i = this.otherLocations) == null ? void 0 : i.get("cssSelector");
|
|
1677
1693
|
};
|
|
1678
1694
|
E.prototype.getPartialCfi = function() {
|
|
1679
|
-
var
|
|
1680
|
-
return (
|
|
1695
|
+
var i;
|
|
1696
|
+
return (i = this.otherLocations) == null ? void 0 : i.get("partialCfi");
|
|
1681
1697
|
};
|
|
1682
1698
|
E.prototype.getDomRange = function() {
|
|
1683
|
-
var
|
|
1684
|
-
return
|
|
1699
|
+
var i;
|
|
1700
|
+
return pt.deserialize((i = this.otherLocations) == null ? void 0 : i.get("domRange"));
|
|
1685
1701
|
};
|
|
1686
1702
|
E.prototype.fragmentParameters = function() {
|
|
1687
1703
|
return new Map(
|
|
1688
|
-
this.fragments.map((
|
|
1689
|
-
|
|
1690
|
-
|
|
1704
|
+
this.fragments.map((i) => i.startsWith("#") ? i.slice(1) : i).join("&").split("&").filter((i) => !i.startsWith("#")).map((i) => i.split("=")).filter((i) => i.length === 2).map((i) => [
|
|
1705
|
+
i[0].trim().toLowerCase(),
|
|
1706
|
+
i[1].trim()
|
|
1691
1707
|
])
|
|
1692
1708
|
);
|
|
1693
1709
|
};
|
|
1694
1710
|
E.prototype.htmlId = function() {
|
|
1695
1711
|
if (!this.fragments.length)
|
|
1696
1712
|
return;
|
|
1697
|
-
let
|
|
1698
|
-
if (!
|
|
1713
|
+
let i = this.fragments.find((t) => t.length && !t.includes("="));
|
|
1714
|
+
if (!i) {
|
|
1699
1715
|
const t = this.fragmentParameters();
|
|
1700
|
-
t.has("id") ?
|
|
1716
|
+
t.has("id") ? i = t.get("id") : t.has("name") && (i = t.get("name"));
|
|
1701
1717
|
}
|
|
1702
|
-
return
|
|
1718
|
+
return i != null && i.startsWith("#") ? i.slice(1) : i;
|
|
1703
1719
|
};
|
|
1704
1720
|
E.prototype.page = function() {
|
|
1705
|
-
const
|
|
1706
|
-
if (!isNaN(
|
|
1707
|
-
return
|
|
1721
|
+
const i = parseInt(this.fragmentParameters().get("page"));
|
|
1722
|
+
if (!isNaN(i) && i >= 0)
|
|
1723
|
+
return i;
|
|
1708
1724
|
};
|
|
1709
1725
|
E.prototype.time = function() {
|
|
1710
|
-
const
|
|
1711
|
-
if (!isNaN(
|
|
1712
|
-
return
|
|
1726
|
+
const i = parseInt(this.fragmentParameters().get("t"));
|
|
1727
|
+
if (!isNaN(i))
|
|
1728
|
+
return i;
|
|
1713
1729
|
};
|
|
1714
1730
|
E.prototype.space = function() {
|
|
1715
|
-
const
|
|
1716
|
-
if (!
|
|
1731
|
+
const i = this.fragmentParameters();
|
|
1732
|
+
if (!i.has("xywh"))
|
|
1717
1733
|
return;
|
|
1718
|
-
const t =
|
|
1734
|
+
const t = i.get("xywh").split(",").map((e) => parseInt(e));
|
|
1719
1735
|
if (t.length === 4 && !t.some(isNaN))
|
|
1720
1736
|
return t;
|
|
1721
1737
|
};
|
|
1722
|
-
class
|
|
1738
|
+
class dt {
|
|
1723
1739
|
/** Creates a [Price]. */
|
|
1724
1740
|
constructor(t) {
|
|
1725
1741
|
this.currency = t.currency, this.value = t.value;
|
|
@@ -1733,9 +1749,9 @@ class j {
|
|
|
1733
1749
|
let e = t.currency;
|
|
1734
1750
|
if (!(e && typeof e == "string" && e.length > 0))
|
|
1735
1751
|
return;
|
|
1736
|
-
let
|
|
1737
|
-
if (
|
|
1738
|
-
return new
|
|
1752
|
+
let r = y(t.value);
|
|
1753
|
+
if (r !== void 0)
|
|
1754
|
+
return new dt({ currency: e, value: r });
|
|
1739
1755
|
}
|
|
1740
1756
|
/**
|
|
1741
1757
|
* Serializes a [Price] to its RWPM JSON representation.
|
|
@@ -1744,7 +1760,7 @@ class j {
|
|
|
1744
1760
|
return { currency: this.currency, value: this.value };
|
|
1745
1761
|
}
|
|
1746
1762
|
}
|
|
1747
|
-
class
|
|
1763
|
+
class U {
|
|
1748
1764
|
/** Creates a [Acquisition]. */
|
|
1749
1765
|
constructor(t) {
|
|
1750
1766
|
this.type = t.type, this.children = t.children;
|
|
@@ -1754,14 +1770,14 @@ class D {
|
|
|
1754
1770
|
*/
|
|
1755
1771
|
static deserialize(t) {
|
|
1756
1772
|
if (t && t.type)
|
|
1757
|
-
return new
|
|
1773
|
+
return new U({
|
|
1758
1774
|
type: t.type,
|
|
1759
|
-
children:
|
|
1775
|
+
children: U.deserializeArray(t.children)
|
|
1760
1776
|
});
|
|
1761
1777
|
}
|
|
1762
1778
|
static deserializeArray(t) {
|
|
1763
1779
|
if (t instanceof Array)
|
|
1764
|
-
return t.map((e) =>
|
|
1780
|
+
return t.map((e) => U.deserialize(e)).filter((e) => e !== void 0);
|
|
1765
1781
|
}
|
|
1766
1782
|
/**
|
|
1767
1783
|
* Serializes a [Acquisition] to its RWPM JSON representation.
|
|
@@ -1771,7 +1787,7 @@ class D {
|
|
|
1771
1787
|
return this.children && (t.children = this.children.map((e) => e.serialize())), t;
|
|
1772
1788
|
}
|
|
1773
1789
|
}
|
|
1774
|
-
class
|
|
1790
|
+
class gt {
|
|
1775
1791
|
/** Creates a [Price]. */
|
|
1776
1792
|
constructor(t) {
|
|
1777
1793
|
this.total = t.total, this.position = t.position;
|
|
@@ -1781,7 +1797,7 @@ class tt {
|
|
|
1781
1797
|
*/
|
|
1782
1798
|
static deserialize(t) {
|
|
1783
1799
|
if (t)
|
|
1784
|
-
return new
|
|
1800
|
+
return new gt({
|
|
1785
1801
|
total: y(t.total),
|
|
1786
1802
|
position: y(t.position)
|
|
1787
1803
|
});
|
|
@@ -1794,7 +1810,7 @@ class tt {
|
|
|
1794
1810
|
return this.total !== void 0 && (t.total = this.total), this.position !== void 0 && (t.position = this.position), t;
|
|
1795
1811
|
}
|
|
1796
1812
|
}
|
|
1797
|
-
class
|
|
1813
|
+
class mt {
|
|
1798
1814
|
/** Creates a [Copies]. */
|
|
1799
1815
|
constructor(t) {
|
|
1800
1816
|
this.total = t.total, this.available = t.available;
|
|
@@ -1804,7 +1820,7 @@ class et {
|
|
|
1804
1820
|
*/
|
|
1805
1821
|
static deserialize(t) {
|
|
1806
1822
|
if (t)
|
|
1807
|
-
return new
|
|
1823
|
+
return new mt({
|
|
1808
1824
|
total: y(t.total),
|
|
1809
1825
|
available: y(t.available)
|
|
1810
1826
|
});
|
|
@@ -1817,8 +1833,8 @@ class et {
|
|
|
1817
1833
|
return this.total !== void 0 && (t.total = this.total), this.available !== void 0 && (t.available = this.available), t;
|
|
1818
1834
|
}
|
|
1819
1835
|
}
|
|
1820
|
-
var
|
|
1821
|
-
class
|
|
1836
|
+
var je = /* @__PURE__ */ ((i) => (i.available = "available", i.reserved = "reserved", i.ready = "ready", i))(je || {});
|
|
1837
|
+
class Et {
|
|
1822
1838
|
/** Creates a [Availability]. */
|
|
1823
1839
|
constructor(t) {
|
|
1824
1840
|
this.state = t.state, this.since = t.since, this.until = t.until;
|
|
@@ -1828,10 +1844,10 @@ class it {
|
|
|
1828
1844
|
*/
|
|
1829
1845
|
static deserialize(t) {
|
|
1830
1846
|
if (t && t.state)
|
|
1831
|
-
return new
|
|
1847
|
+
return new Et({
|
|
1832
1848
|
state: t.state,
|
|
1833
|
-
since:
|
|
1834
|
-
until:
|
|
1849
|
+
since: Y(t.since),
|
|
1850
|
+
until: Y(t.until)
|
|
1835
1851
|
});
|
|
1836
1852
|
}
|
|
1837
1853
|
/**
|
|
@@ -1842,39 +1858,39 @@ class it {
|
|
|
1842
1858
|
return this.since !== void 0 && (t.since = this.since.toISOString()), this.until !== void 0 && (t.until = this.until.toISOString()), t;
|
|
1843
1859
|
}
|
|
1844
1860
|
}
|
|
1845
|
-
|
|
1861
|
+
m.prototype.getNumberOfItems = function() {
|
|
1846
1862
|
return y(this.otherProperties.numberOfItems);
|
|
1847
1863
|
};
|
|
1848
|
-
|
|
1849
|
-
return
|
|
1864
|
+
m.prototype.getPrice = function() {
|
|
1865
|
+
return dt.deserialize(this.otherProperties.price);
|
|
1850
1866
|
};
|
|
1851
|
-
|
|
1852
|
-
const
|
|
1853
|
-
if (
|
|
1854
|
-
return
|
|
1867
|
+
m.prototype.getIndirectAcquisitions = function() {
|
|
1868
|
+
const i = this.otherProperties.indirectAcquisition;
|
|
1869
|
+
if (i && i instanceof Array)
|
|
1870
|
+
return i.map((t) => U.deserialize(t)).filter((t) => t !== void 0);
|
|
1855
1871
|
};
|
|
1856
|
-
|
|
1857
|
-
return
|
|
1872
|
+
m.prototype.getHolds = function() {
|
|
1873
|
+
return gt.deserialize(this.otherProperties.holds);
|
|
1858
1874
|
};
|
|
1859
|
-
|
|
1860
|
-
return
|
|
1875
|
+
m.prototype.getCopies = function() {
|
|
1876
|
+
return mt.deserialize(this.otherProperties.copies);
|
|
1861
1877
|
};
|
|
1862
|
-
|
|
1863
|
-
return
|
|
1878
|
+
m.prototype.getAvailability = function() {
|
|
1879
|
+
return Et.deserialize(this.otherProperties.availability);
|
|
1864
1880
|
};
|
|
1865
|
-
|
|
1866
|
-
return
|
|
1881
|
+
m.prototype.getAuthenticate = function() {
|
|
1882
|
+
return S.deserialize(this.otherProperties.authenticate);
|
|
1867
1883
|
};
|
|
1868
|
-
|
|
1884
|
+
N.prototype.getImages = function() {
|
|
1869
1885
|
return this.linksWithRole("images");
|
|
1870
1886
|
};
|
|
1871
|
-
const
|
|
1887
|
+
const bt = class P {
|
|
1872
1888
|
/**
|
|
1873
1889
|
* translations can be a string or a collection of language/translation pairs,
|
|
1874
1890
|
* for a single string the language is assumed to be undefined
|
|
1875
1891
|
*/
|
|
1876
1892
|
constructor(t) {
|
|
1877
|
-
this.translations = typeof t == "string" ? { [
|
|
1893
|
+
this.translations = typeof t == "string" ? { [P.UNDEFINED_LANGUAGE]: t } : t;
|
|
1878
1894
|
}
|
|
1879
1895
|
/**
|
|
1880
1896
|
* Parses a [LocalizedString] from its RWPM JSON representation.
|
|
@@ -1898,7 +1914,7 @@ const rt = class k {
|
|
|
1898
1914
|
*/
|
|
1899
1915
|
static deserialize(t) {
|
|
1900
1916
|
if (t && (typeof t == "string" || t.constructor === Object))
|
|
1901
|
-
return new
|
|
1917
|
+
return new P(t);
|
|
1902
1918
|
}
|
|
1903
1919
|
serialize() {
|
|
1904
1920
|
return this.translations;
|
|
@@ -1912,13 +1928,13 @@ const rt = class k {
|
|
|
1912
1928
|
* 4. returns empty string
|
|
1913
1929
|
*/
|
|
1914
1930
|
getTranslation(t) {
|
|
1915
|
-
return this.translations[t ||
|
|
1931
|
+
return this.translations[t || P.UNDEFINED_LANGUAGE] || this.translations[P.UNDEFINED_LANGUAGE] || this.translations[P.LANGUAGE_EN] || (Object.values(this.translations).length === 0 ? "" : Object.values(this.translations)[0]);
|
|
1916
1932
|
}
|
|
1917
1933
|
};
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
let O =
|
|
1921
|
-
class
|
|
1934
|
+
bt.UNDEFINED_LANGUAGE = "undefined";
|
|
1935
|
+
bt.LANGUAGE_EN = "en";
|
|
1936
|
+
let O = bt;
|
|
1937
|
+
class K {
|
|
1922
1938
|
/**
|
|
1923
1939
|
* Creates a [Contributor] object.
|
|
1924
1940
|
*/
|
|
@@ -1932,15 +1948,15 @@ class H {
|
|
|
1932
1948
|
*/
|
|
1933
1949
|
static deserialize(t) {
|
|
1934
1950
|
if (t)
|
|
1935
|
-
return typeof t == "string" ? new
|
|
1951
|
+
return typeof t == "string" ? new K({
|
|
1936
1952
|
name: O.deserialize(t)
|
|
1937
|
-
}) : t.name ? new
|
|
1953
|
+
}) : t.name ? new K({
|
|
1938
1954
|
name: O.deserialize(t.name),
|
|
1939
1955
|
sortAs: t.sortAs,
|
|
1940
1956
|
identifier: t.identifier,
|
|
1941
|
-
roles: t.role ? new Set(
|
|
1942
|
-
links:
|
|
1943
|
-
position:
|
|
1957
|
+
roles: t.role ? new Set(R(t.role)) : void 0,
|
|
1958
|
+
links: x.deserialize(t.links),
|
|
1959
|
+
position: C(t.position)
|
|
1944
1960
|
}) : void 0;
|
|
1945
1961
|
}
|
|
1946
1962
|
/**
|
|
@@ -1948,10 +1964,10 @@ class H {
|
|
|
1948
1964
|
*/
|
|
1949
1965
|
serialize() {
|
|
1950
1966
|
const t = { name: this.name.serialize() };
|
|
1951
|
-
return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.identifier !== void 0 && (t.identifier = this.identifier), this.roles && (t.role =
|
|
1967
|
+
return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.identifier !== void 0 && (t.identifier = this.identifier), this.roles && (t.role = ut(this.roles)), this.links && (t.links = this.links.serialize()), this.position !== void 0 && (t.position = this.position), t;
|
|
1952
1968
|
}
|
|
1953
1969
|
}
|
|
1954
|
-
class
|
|
1970
|
+
class b {
|
|
1955
1971
|
/**
|
|
1956
1972
|
* Creates a [Contributors] object.
|
|
1957
1973
|
*/
|
|
@@ -1966,8 +1982,8 @@ class m {
|
|
|
1966
1982
|
if (!t)
|
|
1967
1983
|
return;
|
|
1968
1984
|
const e = t instanceof Array ? t : [t];
|
|
1969
|
-
return new
|
|
1970
|
-
e.map((
|
|
1985
|
+
return new b(
|
|
1986
|
+
e.map((r) => K.deserialize(r)).filter((r) => r !== void 0)
|
|
1971
1987
|
);
|
|
1972
1988
|
}
|
|
1973
1989
|
/**
|
|
@@ -1977,7 +1993,7 @@ class m {
|
|
|
1977
1993
|
return this.items.map((t) => t.serialize());
|
|
1978
1994
|
}
|
|
1979
1995
|
}
|
|
1980
|
-
class
|
|
1996
|
+
class B {
|
|
1981
1997
|
/** Creates an Array of [Subject]. */
|
|
1982
1998
|
constructor(t) {
|
|
1983
1999
|
this.items = t && t.items ? t.items : /* @__PURE__ */ new Map();
|
|
@@ -1989,10 +2005,10 @@ class R {
|
|
|
1989
2005
|
if (!(t && t instanceof Object))
|
|
1990
2006
|
return;
|
|
1991
2007
|
const e = /* @__PURE__ */ new Map();
|
|
1992
|
-
return Object.entries(t).forEach(([
|
|
1993
|
-
const
|
|
1994
|
-
|
|
1995
|
-
}), new
|
|
2008
|
+
return Object.entries(t).forEach(([r, s]) => {
|
|
2009
|
+
const n = b.deserialize(s);
|
|
2010
|
+
n && n.items.length > 0 && e.set(r, n);
|
|
2011
|
+
}), new B({ items: e });
|
|
1996
2012
|
}
|
|
1997
2013
|
/**
|
|
1998
2014
|
* Serializes a [BelongsTo] to its RWPM JSON representation.
|
|
@@ -2000,25 +2016,25 @@ class R {
|
|
|
2000
2016
|
serialize() {
|
|
2001
2017
|
const t = {};
|
|
2002
2018
|
return this.items.forEach(
|
|
2003
|
-
(e,
|
|
2019
|
+
(e, r) => t[r] = e.serialize()
|
|
2004
2020
|
), t;
|
|
2005
2021
|
}
|
|
2006
2022
|
}
|
|
2007
|
-
var
|
|
2008
|
-
function
|
|
2009
|
-
switch (
|
|
2023
|
+
var z = /* @__PURE__ */ ((i) => (i.auto = "auto", i.btt = "btt", i.ltr = "ltr", i.rtl = "rtl", i.ttb = "ttb", i))(z || {});
|
|
2024
|
+
function xr(i) {
|
|
2025
|
+
switch (i) {
|
|
2010
2026
|
case "auto":
|
|
2011
2027
|
case "ttb":
|
|
2012
2028
|
case "ltr":
|
|
2013
|
-
return
|
|
2029
|
+
return H.left;
|
|
2014
2030
|
case "rtl":
|
|
2015
2031
|
case "btt":
|
|
2016
|
-
return
|
|
2032
|
+
return H.right;
|
|
2017
2033
|
default:
|
|
2018
|
-
return
|
|
2034
|
+
return H.left;
|
|
2019
2035
|
}
|
|
2020
2036
|
}
|
|
2021
|
-
class
|
|
2037
|
+
class Z {
|
|
2022
2038
|
/** Creates a [Subject]. */
|
|
2023
2039
|
constructor(t) {
|
|
2024
2040
|
this.name = t.name, this.sortAs = t.sortAs, this.code = t.code, this.scheme = t.scheme, this.links = t.links;
|
|
@@ -2030,14 +2046,14 @@ class $ {
|
|
|
2030
2046
|
*/
|
|
2031
2047
|
static deserialize(t) {
|
|
2032
2048
|
if (t)
|
|
2033
|
-
return typeof t == "string" ? new
|
|
2049
|
+
return typeof t == "string" ? new Z({
|
|
2034
2050
|
name: O.deserialize(t)
|
|
2035
|
-
}) : t.name ? new
|
|
2051
|
+
}) : t.name ? new Z({
|
|
2036
2052
|
name: O.deserialize(t.name),
|
|
2037
2053
|
sortAs: t.sortAs,
|
|
2038
2054
|
code: t.code,
|
|
2039
2055
|
scheme: t.scheme,
|
|
2040
|
-
links:
|
|
2056
|
+
links: x.deserialize(t.links)
|
|
2041
2057
|
}) : void 0;
|
|
2042
2058
|
}
|
|
2043
2059
|
/**
|
|
@@ -2048,7 +2064,7 @@ class $ {
|
|
|
2048
2064
|
return this.sortAs !== void 0 && (t.sortAs = this.sortAs), this.code !== void 0 && (t.code = this.code), this.scheme !== void 0 && (t.scheme = this.scheme), this.links && (t.links = this.links.serialize()), t;
|
|
2049
2065
|
}
|
|
2050
2066
|
}
|
|
2051
|
-
class
|
|
2067
|
+
class xt {
|
|
2052
2068
|
/** Creates an Array of [Subject]. */
|
|
2053
2069
|
constructor(t) {
|
|
2054
2070
|
this.items = t;
|
|
@@ -2060,8 +2076,8 @@ class st {
|
|
|
2060
2076
|
if (!t)
|
|
2061
2077
|
return;
|
|
2062
2078
|
const e = t instanceof Array ? t : [t];
|
|
2063
|
-
return new
|
|
2064
|
-
e.map((
|
|
2079
|
+
return new xt(
|
|
2080
|
+
e.map((r) => Z.deserialize(r)).filter((r) => r !== void 0)
|
|
2065
2081
|
);
|
|
2066
2082
|
}
|
|
2067
2083
|
/**
|
|
@@ -2071,10 +2087,10 @@ class st {
|
|
|
2071
2087
|
return this.items.map((t) => t.serialize());
|
|
2072
2088
|
}
|
|
2073
2089
|
}
|
|
2074
|
-
const
|
|
2090
|
+
const Dt = class nt {
|
|
2075
2091
|
/** Creates [Metadata] object */
|
|
2076
2092
|
constructor(t) {
|
|
2077
|
-
this.title = t.title, this.typeUri = t.typeUri, this.identifier = t.identifier, this.subtitle = t.subtitle, this.sortAs = t.sortAs, this.artists = t.artists, this.authors = t.authors, this.colorists = t.colorists, this.contributors = t.contributors, this.editors = t.editors, this.illustrators = t.illustrators, this.inkers = t.inkers, this.letterers = t.letterers, this.narrators = t.narrators, this.pencilers = t.pencilers, this.translators = t.translators, this.languages = t.languages, this.description = t.description, this.publishers = t.publishers, this.imprints = t.imprints, this.published = t.published, this.modified = t.modified, this.subjects = t.subjects, this.belongsTo = t.belongsTo, this.belongsToCollections = t.belongsToCollections, this.belongsToSeries = t.belongsToSeries, this.belongsToCollections && this.belongsToCollections.items.length > 0 && (this.belongsTo || (this.belongsTo = new
|
|
2093
|
+
this.title = t.title, this.typeUri = t.typeUri, this.identifier = t.identifier, this.subtitle = t.subtitle, this.sortAs = t.sortAs, this.artists = t.artists, this.authors = t.authors, this.colorists = t.colorists, this.contributors = t.contributors, this.editors = t.editors, this.illustrators = t.illustrators, this.inkers = t.inkers, this.letterers = t.letterers, this.narrators = t.narrators, this.pencilers = t.pencilers, this.translators = t.translators, this.languages = t.languages, this.description = t.description, this.publishers = t.publishers, this.imprints = t.imprints, this.published = t.published, this.modified = t.modified, this.subjects = t.subjects, this.belongsTo = t.belongsTo, this.belongsToCollections = t.belongsToCollections, this.belongsToSeries = t.belongsToSeries, this.belongsToCollections && this.belongsToCollections.items.length > 0 && (this.belongsTo || (this.belongsTo = new B()), this.belongsTo.items.set("collection", this.belongsToCollections)), this.belongsToSeries && this.belongsToSeries.items.length > 0 && (this.belongsTo || (this.belongsTo = new B()), this.belongsTo.items.set("series", this.belongsToSeries)), this.readingProgression = t.readingProgression, this.duration = t.duration, this.numberOfPages = t.numberOfPages, this.otherMetadata = t.otherMetadata;
|
|
2078
2094
|
}
|
|
2079
2095
|
/**
|
|
2080
2096
|
* Parses a [Metadata] from its RWPM JSON representation.
|
|
@@ -2084,37 +2100,37 @@ const ct = class q {
|
|
|
2084
2100
|
static deserialize(t) {
|
|
2085
2101
|
if (!(t && t.title))
|
|
2086
2102
|
return;
|
|
2087
|
-
const e = O.deserialize(t.title),
|
|
2088
|
-
let
|
|
2089
|
-
return
|
|
2103
|
+
const e = O.deserialize(t.title), r = t["@type"], s = t.identifier, n = O.deserialize(t.subtitle), o = O.deserialize(t.sortAs), l = b.deserialize(t.artist), c = b.deserialize(t.author), h = b.deserialize(t.colorist), u = b.deserialize(t.contributor), p = b.deserialize(t.editor), f = b.deserialize(t.illustrator), d = b.deserialize(t.inker), I = b.deserialize(t.letterer), L = b.deserialize(t.narrator), le = b.deserialize(t.penciler), ce = b.deserialize(t.translator), he = R(t.language), ue = t.description, fe = b.deserialize(t.publisher), pe = b.deserialize(t.imprint), de = Y(t.published), ge = Y(t.modified), me = xt.deserialize(t.subject), Ee = B.deserialize(t.belongsTo), be = t.readingProgression, xe = y(t.duration), we = y(t.numberOfPages);
|
|
2104
|
+
let G = Object.assign({}, t);
|
|
2105
|
+
return nt.mappedProperties.forEach((ye) => delete G[ye]), Object.keys(G).length === 0 && (G = void 0), new nt({
|
|
2090
2106
|
title: e,
|
|
2091
|
-
typeUri:
|
|
2107
|
+
typeUri: r,
|
|
2092
2108
|
identifier: s,
|
|
2093
|
-
subtitle:
|
|
2109
|
+
subtitle: n,
|
|
2094
2110
|
sortAs: o,
|
|
2095
2111
|
artists: l,
|
|
2096
|
-
authors:
|
|
2097
|
-
colorists:
|
|
2098
|
-
contributors:
|
|
2099
|
-
editors:
|
|
2100
|
-
illustrators:
|
|
2112
|
+
authors: c,
|
|
2113
|
+
colorists: h,
|
|
2114
|
+
contributors: u,
|
|
2115
|
+
editors: p,
|
|
2116
|
+
illustrators: f,
|
|
2101
2117
|
inkers: d,
|
|
2102
|
-
letterers:
|
|
2103
|
-
narrators:
|
|
2104
|
-
pencilers:
|
|
2105
|
-
translators:
|
|
2106
|
-
languages:
|
|
2107
|
-
description:
|
|
2108
|
-
publishers:
|
|
2109
|
-
imprints:
|
|
2110
|
-
published:
|
|
2111
|
-
modified:
|
|
2112
|
-
subjects:
|
|
2113
|
-
belongsTo:
|
|
2114
|
-
readingProgression:
|
|
2115
|
-
duration:
|
|
2116
|
-
numberOfPages:
|
|
2117
|
-
otherMetadata:
|
|
2118
|
+
letterers: I,
|
|
2119
|
+
narrators: L,
|
|
2120
|
+
pencilers: le,
|
|
2121
|
+
translators: ce,
|
|
2122
|
+
languages: he,
|
|
2123
|
+
description: ue,
|
|
2124
|
+
publishers: fe,
|
|
2125
|
+
imprints: pe,
|
|
2126
|
+
published: de,
|
|
2127
|
+
modified: ge,
|
|
2128
|
+
subjects: me,
|
|
2129
|
+
belongsTo: Ee,
|
|
2130
|
+
readingProgression: be,
|
|
2131
|
+
duration: xe,
|
|
2132
|
+
numberOfPages: we,
|
|
2133
|
+
otherMetadata: G
|
|
2118
2134
|
});
|
|
2119
2135
|
}
|
|
2120
2136
|
/**
|
|
@@ -2124,7 +2140,7 @@ const ct = class q {
|
|
|
2124
2140
|
const t = { title: this.title.serialize() };
|
|
2125
2141
|
if (this.typeUri !== void 0 && (t["@type"] = this.typeUri), this.identifier !== void 0 && (t.identifier = this.identifier), this.subtitle && (t.subtitle = this.subtitle.serialize()), this.sortAs && (t.sortAs = this.sortAs.serialize()), this.editors && (t.editor = this.editors.serialize()), this.artists && (t.artist = this.artists.serialize()), this.authors && (t.author = this.authors.serialize()), this.colorists && (t.colorist = this.colorists.serialize()), this.contributors && (t.contributor = this.contributors.serialize()), this.illustrators && (t.illustrator = this.illustrators.serialize()), this.letterers && (t.letterer = this.letterers.serialize()), this.narrators && (t.narrator = this.narrators.serialize()), this.pencilers && (t.penciler = this.pencilers.serialize()), this.translators && (t.translator = this.translators.serialize()), this.inkers && (t.inker = this.inkers.serialize()), this.languages && (t.language = this.languages), this.description !== void 0 && (t.description = this.description), this.publishers && (t.publisher = this.publishers.serialize()), this.imprints && (t.imprint = this.imprints.serialize()), this.published !== void 0 && (t.published = this.published.toISOString()), this.modified !== void 0 && (t.modified = this.modified.toISOString()), this.subjects && (t.subject = this.subjects.serialize()), this.belongsTo && (t.belongsTo = this.belongsTo.serialize()), this.readingProgression && (t.readingProgression = this.readingProgression), this.duration !== void 0 && (t.duration = this.duration), this.numberOfPages !== void 0 && (t.numberOfPages = this.numberOfPages), this.otherMetadata) {
|
|
2126
2142
|
const e = this.otherMetadata;
|
|
2127
|
-
Object.keys(e).forEach((
|
|
2143
|
+
Object.keys(e).forEach((r) => t[r] = e[r]);
|
|
2128
2144
|
}
|
|
2129
2145
|
return t;
|
|
2130
2146
|
}
|
|
@@ -2135,27 +2151,27 @@ const ct = class q {
|
|
|
2135
2151
|
* See this issue for more details: https://github.com/readium/architecture/issues/113
|
|
2136
2152
|
*/
|
|
2137
2153
|
get effectiveReadingProgression() {
|
|
2138
|
-
var
|
|
2139
|
-
if (this.readingProgression && this.readingProgression !==
|
|
2154
|
+
var r;
|
|
2155
|
+
if (this.readingProgression && this.readingProgression !== z.auto)
|
|
2140
2156
|
return this.readingProgression;
|
|
2141
|
-
if (((
|
|
2142
|
-
return
|
|
2157
|
+
if (((r = this.languages) == null ? void 0 : r.length) !== 1)
|
|
2158
|
+
return z.ltr;
|
|
2143
2159
|
const t = this.languages[0].toLowerCase();
|
|
2144
2160
|
if (t === "zh-hant" || t === "zh-tw")
|
|
2145
|
-
return
|
|
2161
|
+
return z.rtl;
|
|
2146
2162
|
switch (t.split("-")[0]) {
|
|
2147
2163
|
case "ar":
|
|
2148
|
-
return
|
|
2164
|
+
return z.rtl;
|
|
2149
2165
|
case "fa":
|
|
2150
|
-
return
|
|
2166
|
+
return z.rtl;
|
|
2151
2167
|
case "he":
|
|
2152
|
-
return
|
|
2168
|
+
return z.rtl;
|
|
2153
2169
|
default:
|
|
2154
|
-
return
|
|
2170
|
+
return z.ltr;
|
|
2155
2171
|
}
|
|
2156
2172
|
}
|
|
2157
2173
|
};
|
|
2158
|
-
|
|
2174
|
+
Dt.mappedProperties = [
|
|
2159
2175
|
"title",
|
|
2160
2176
|
"@type",
|
|
2161
2177
|
"identifier",
|
|
@@ -2184,32 +2200,1231 @@ ct.mappedProperties = [
|
|
|
2184
2200
|
"duration",
|
|
2185
2201
|
"numberOfPages"
|
|
2186
2202
|
];
|
|
2187
|
-
let
|
|
2188
|
-
|
|
2203
|
+
let Ut = Dt;
|
|
2204
|
+
Ut.prototype.getPresentation = function() {
|
|
2189
2205
|
var t, e;
|
|
2190
|
-
const
|
|
2191
|
-
if (
|
|
2192
|
-
return
|
|
2206
|
+
const i = ((t = this.otherMetadata) == null ? void 0 : t.presentation) || ((e = this.otherMetadata) == null ? void 0 : e.rendition);
|
|
2207
|
+
if (i)
|
|
2208
|
+
return _.deserialize(i);
|
|
2193
2209
|
};
|
|
2194
|
-
|
|
2210
|
+
m.prototype.getClipped = function() {
|
|
2195
2211
|
return this.otherProperties.clipped;
|
|
2196
2212
|
};
|
|
2197
|
-
|
|
2213
|
+
m.prototype.getFit = function() {
|
|
2198
2214
|
return this.otherProperties.fit;
|
|
2199
2215
|
};
|
|
2200
|
-
|
|
2216
|
+
m.prototype.getOrientation = function() {
|
|
2201
2217
|
return this.otherProperties.orientation;
|
|
2202
2218
|
};
|
|
2203
|
-
|
|
2219
|
+
m.prototype.getOverflow = function() {
|
|
2204
2220
|
return this.otherProperties.overflow;
|
|
2205
2221
|
};
|
|
2206
|
-
|
|
2222
|
+
m.prototype.getPage = function() {
|
|
2207
2223
|
return this.otherProperties.page || void 0;
|
|
2208
2224
|
};
|
|
2209
|
-
|
|
2225
|
+
m.prototype.getSpread = function() {
|
|
2210
2226
|
return this.otherProperties.spread || void 0;
|
|
2211
2227
|
};
|
|
2212
|
-
class
|
|
2228
|
+
class wr {
|
|
2229
|
+
/**
|
|
2230
|
+
* Extracts the full raw text, or returns null if no text content can be found.
|
|
2231
|
+
* @param separator Separator to use between individual elements. Defaults to newline.
|
|
2232
|
+
*/
|
|
2233
|
+
text(t = `
|
|
2234
|
+
`) {
|
|
2235
|
+
return this.elements().map((e) => e == null ? void 0 : e.text).filter((e) => e !== void 0 && e.length > 0).join(t);
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Returns all the elements as a list.
|
|
2239
|
+
*/
|
|
2240
|
+
elements() {
|
|
2241
|
+
const t = [], e = this.iterator();
|
|
2242
|
+
for (; e.hasNext(); )
|
|
2243
|
+
t.push(e.next());
|
|
2244
|
+
return t;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
class Tt {
|
|
2248
|
+
constructor(t, e) {
|
|
2249
|
+
this.key = t, this.value = e;
|
|
2250
|
+
}
|
|
2251
|
+
}
|
|
2252
|
+
var ot = /* @__PURE__ */ ((i) => (i.ACCESSIBILITY_LABEL = "accessibilityLabel", i.LANGUAGE = "language", i))(ot || {});
|
|
2253
|
+
class Bt {
|
|
2254
|
+
constructor(t = []) {
|
|
2255
|
+
this._attributes = t;
|
|
2256
|
+
}
|
|
2257
|
+
get language() {
|
|
2258
|
+
return this.attribute(
|
|
2259
|
+
"language"
|
|
2260
|
+
/* LANGUAGE */
|
|
2261
|
+
);
|
|
2262
|
+
}
|
|
2263
|
+
get accessibilityLabel() {
|
|
2264
|
+
return this.attribute(
|
|
2265
|
+
"accessibilityLabel"
|
|
2266
|
+
/* ACCESSIBILITY_LABEL */
|
|
2267
|
+
);
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Gets the first attribute with the given [key].
|
|
2271
|
+
*/
|
|
2272
|
+
attribute(t) {
|
|
2273
|
+
var e;
|
|
2274
|
+
return (e = this._attributes.find((r) => r.key === t)) == null ? void 0 : e.value;
|
|
2275
|
+
}
|
|
2276
|
+
/**
|
|
2277
|
+
* Gets all the attributes with the given [key].
|
|
2278
|
+
*/
|
|
2279
|
+
attributes(t) {
|
|
2280
|
+
return this._attributes.filter((e) => e.key === t).map((e) => e.value);
|
|
2281
|
+
}
|
|
2282
|
+
}
|
|
2283
|
+
class Ft extends Bt {
|
|
2284
|
+
constructor(t, e = []) {
|
|
2285
|
+
super(e), this.locator = t;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
class j extends Ft {
|
|
2289
|
+
/**
|
|
2290
|
+
* Human-readable text representation for this element.
|
|
2291
|
+
*/
|
|
2292
|
+
get text() {
|
|
2293
|
+
return this.accessibilityLabel;
|
|
2294
|
+
}
|
|
2295
|
+
}
|
|
2296
|
+
class ti extends j {
|
|
2297
|
+
constructor(t, e, r = []) {
|
|
2298
|
+
super(t, r), this.embeddedLink = e;
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
class ei extends j {
|
|
2302
|
+
constructor(t, e, r = []) {
|
|
2303
|
+
super(t, r), this.embeddedLink = e;
|
|
2304
|
+
}
|
|
2305
|
+
}
|
|
2306
|
+
class ii extends j {
|
|
2307
|
+
constructor(t, e, r, s = []) {
|
|
2308
|
+
super(t, s), this.embeddedLink = e, this.caption = r;
|
|
2309
|
+
}
|
|
2310
|
+
get text() {
|
|
2311
|
+
var t;
|
|
2312
|
+
return (((t = this.caption) == null ? void 0 : t.length) || 0) > 0 ? this.caption : super.text;
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
class Wt extends Bt {
|
|
2316
|
+
constructor(t, e, r = []) {
|
|
2317
|
+
super(r), this.locator = t, this.text = e;
|
|
2318
|
+
}
|
|
2319
|
+
}
|
|
2320
|
+
class at extends j {
|
|
2321
|
+
constructor(t, e, r, s = []) {
|
|
2322
|
+
super(t, s), this.role = e, this.segments = r;
|
|
2323
|
+
}
|
|
2324
|
+
get text() {
|
|
2325
|
+
return this.segments.map((t) => t.text).join("");
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
class ri {
|
|
2329
|
+
constructor(t) {
|
|
2330
|
+
this.level = t;
|
|
2331
|
+
}
|
|
2332
|
+
get role() {
|
|
2333
|
+
return `heading-${this.level}`;
|
|
2334
|
+
}
|
|
2335
|
+
}
|
|
2336
|
+
const si = {
|
|
2337
|
+
role: "body"
|
|
2338
|
+
}, ni = {
|
|
2339
|
+
role: "footnote"
|
|
2340
|
+
};
|
|
2341
|
+
class oi {
|
|
2342
|
+
constructor(t, e) {
|
|
2343
|
+
this.referenceUrl = t, this.referenceTitle = e, this.role = "quote";
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
class yr {
|
|
2347
|
+
/**
|
|
2348
|
+
*
|
|
2349
|
+
* @param defaultLanguage The default assumed language
|
|
2350
|
+
* @param unit The unit of the produced [Locator]s.
|
|
2351
|
+
* @param contextSnippetLength Length of `before` and `after` snippets in the produced [Locator]s.
|
|
2352
|
+
* @param textTokenizerFactory Factory to create a [TextTokenizer] from, using the specified language and unit.
|
|
2353
|
+
*/
|
|
2354
|
+
constructor(t, e, r = 50, s = (n) => Ze(n, e)) {
|
|
2355
|
+
this.defaultLanguage = t, this.contextSnippetLength = r, this.textTokenizerFactory = s;
|
|
2356
|
+
}
|
|
2357
|
+
tokenize(t) {
|
|
2358
|
+
return t instanceof at ? [
|
|
2359
|
+
new at(
|
|
2360
|
+
t.locator,
|
|
2361
|
+
t.role,
|
|
2362
|
+
t.segments.map((e) => this.tokenizeSegment(e)).flat()
|
|
2363
|
+
)
|
|
2364
|
+
] : [t];
|
|
2365
|
+
}
|
|
2366
|
+
tokenizeSegment(t) {
|
|
2367
|
+
return this.textTokenizerFactory(t.language ?? this.defaultLanguage).tokenize(t.text).map((e) => new Wt(
|
|
2368
|
+
new A({
|
|
2369
|
+
href: t.locator.href,
|
|
2370
|
+
type: t.locator.type,
|
|
2371
|
+
title: t.locator.title,
|
|
2372
|
+
locations: t.locator.locations,
|
|
2373
|
+
text: this.extractTextContextIn(t.text, e)
|
|
2374
|
+
}),
|
|
2375
|
+
t.text.substring(e[0], e[1]),
|
|
2376
|
+
t._attributes
|
|
2377
|
+
));
|
|
2378
|
+
}
|
|
2379
|
+
extractTextContextIn(t, e) {
|
|
2380
|
+
const r = t.substring(e[1], e[1] + this.contextSnippetLength), s = t.substring(e[0] - this.contextSnippetLength, e[0]);
|
|
2381
|
+
return new M({
|
|
2382
|
+
after: r.length > 0 ? r : void 0,
|
|
2383
|
+
before: s.length > 0 ? s : void 0,
|
|
2384
|
+
highlight: t.substring(e[0], e[1])
|
|
2385
|
+
});
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2388
|
+
class F extends Error {
|
|
2389
|
+
constructor(t) {
|
|
2390
|
+
super(t);
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
class wt {
|
|
2394
|
+
/**
|
|
2395
|
+
* Advances to the next item and returns it, or null if we reached the end.
|
|
2396
|
+
*/
|
|
2397
|
+
async nextOrNull() {
|
|
2398
|
+
return await this.hasNext() ? this.next() : null;
|
|
2399
|
+
}
|
|
2400
|
+
/**
|
|
2401
|
+
* Advances to the previous item and returns it, or null if we reached the beginning.
|
|
2402
|
+
*/
|
|
2403
|
+
async previousOrNull() {
|
|
2404
|
+
return await this.hasPrevious() ? this.previous() : null;
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
let ai = class {
|
|
2408
|
+
constructor(t, e) {
|
|
2409
|
+
this.element = t, this.direction = e;
|
|
2410
|
+
}
|
|
2411
|
+
};
|
|
2412
|
+
class Sr extends wt {
|
|
2413
|
+
constructor(t, e, r) {
|
|
2414
|
+
super(), this.publication = t, this.startLocator = e, this.resourceContentIteratorFactories = r, this._currentIterator = null, this.currentElement = null;
|
|
2415
|
+
}
|
|
2416
|
+
async hasPrevious() {
|
|
2417
|
+
return this.currentElement = await this.nextIn(
|
|
2418
|
+
-1
|
|
2419
|
+
/* Backward */
|
|
2420
|
+
), this.currentElement !== null;
|
|
2421
|
+
}
|
|
2422
|
+
previous() {
|
|
2423
|
+
var t;
|
|
2424
|
+
if (((t = this.currentElement) == null ? void 0 : t.direction) !== -1)
|
|
2425
|
+
throw new F("Called previous() without a successful call to hasPrevious() first");
|
|
2426
|
+
return this.currentElement.element;
|
|
2427
|
+
}
|
|
2428
|
+
async hasNext() {
|
|
2429
|
+
return this.currentElement = await this.nextIn(
|
|
2430
|
+
1
|
|
2431
|
+
/* Forward */
|
|
2432
|
+
), this.currentElement !== null;
|
|
2433
|
+
}
|
|
2434
|
+
next() {
|
|
2435
|
+
var t;
|
|
2436
|
+
if (((t = this.currentElement) == null ? void 0 : t.direction) !== 1)
|
|
2437
|
+
throw new F("Called next() without a successful call to hasNext() first");
|
|
2438
|
+
return this.currentElement.element;
|
|
2439
|
+
}
|
|
2440
|
+
async nextIn(t) {
|
|
2441
|
+
const e = this.currentIterator;
|
|
2442
|
+
if (!e)
|
|
2443
|
+
return null;
|
|
2444
|
+
const r = await e.nextContentIn(t);
|
|
2445
|
+
if (!r) {
|
|
2446
|
+
const s = this.nextIteratorIn(t, e.index);
|
|
2447
|
+
return s ? (this._currentIterator = s, this.nextIn(t)) : null;
|
|
2448
|
+
}
|
|
2449
|
+
return new ai(r, t);
|
|
2450
|
+
}
|
|
2451
|
+
/**
|
|
2452
|
+
* Returns the [Iterator] for the current [Resource] in the reading order.
|
|
2453
|
+
*/
|
|
2454
|
+
get currentIterator() {
|
|
2455
|
+
return this._currentIterator || (this._currentIterator = this.initialIterator()), this._currentIterator;
|
|
2456
|
+
}
|
|
2457
|
+
/**
|
|
2458
|
+
* Returns the first iterator starting at [startLocator] or the beginning of the publication.
|
|
2459
|
+
*/
|
|
2460
|
+
initialIterator() {
|
|
2461
|
+
const t = this.startLocator ? this.publication.readingOrder.findIndexWithHref(this.startLocator.href) : 0, e = this.startLocator || 0;
|
|
2462
|
+
return this.loadIteratorAt(t, e) ?? this.nextIteratorIn(1, t);
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* Returns the next resource iterator in the given [direction], starting from [fromIndex].
|
|
2466
|
+
*/
|
|
2467
|
+
nextIteratorIn(t, e) {
|
|
2468
|
+
const r = e + t;
|
|
2469
|
+
if (r < 0 || r >= this.publication.manifest.readingOrder.items.length)
|
|
2470
|
+
return null;
|
|
2471
|
+
const s = t === 1 ? 0 : 1;
|
|
2472
|
+
return this.loadIteratorAt(r, s) ?? this.nextIteratorIn(t, r);
|
|
2473
|
+
}
|
|
2474
|
+
/**
|
|
2475
|
+
* Loads the iterator at the given [index] in the reading order.
|
|
2476
|
+
* The [location] will be used to compute the starting [Locator] for the iterator.
|
|
2477
|
+
*/
|
|
2478
|
+
loadIteratorAt(t, e) {
|
|
2479
|
+
var o;
|
|
2480
|
+
const r = this.publication.readingOrder.items[t], s = typeof e == "number" ? (o = this.publication.manifest.locatorFromLink(r)) == null ? void 0 : o.copyWithLocations({
|
|
2481
|
+
progression: e
|
|
2482
|
+
}) : e;
|
|
2483
|
+
if (!s)
|
|
2484
|
+
return null;
|
|
2485
|
+
const n = this.publication.get(r);
|
|
2486
|
+
for (const l of this.resourceContentIteratorFactories)
|
|
2487
|
+
l(n, s);
|
|
2488
|
+
return null;
|
|
2489
|
+
}
|
|
2490
|
+
}
|
|
2491
|
+
class it extends Ft {
|
|
2492
|
+
constructor(t, e, r = []) {
|
|
2493
|
+
super(t, r), this.element = e;
|
|
2494
|
+
}
|
|
2495
|
+
get text() {
|
|
2496
|
+
return this.element.text;
|
|
2497
|
+
}
|
|
2498
|
+
}
|
|
2499
|
+
class zt {
|
|
2500
|
+
constructor(t, e) {
|
|
2501
|
+
this.element = t, this.direction = e;
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
class Ir extends wt {
|
|
2505
|
+
constructor(t, e) {
|
|
2506
|
+
var s, n;
|
|
2507
|
+
super(), this.pageContent = t, this.startLocator = e, this.pageContentFiltered = [], this.currentElement = null, this.currentProgression = 0, this.currentElementIndex = 0;
|
|
2508
|
+
const r = this.pageContent.filter(
|
|
2509
|
+
(o) => (o == null ? void 0 : o.str) !== " " && (o == null ? void 0 : o.str) !== ""
|
|
2510
|
+
);
|
|
2511
|
+
if (this.pageContentFiltered = r.map((o) => new it(o.locator, {
|
|
2512
|
+
index: r.indexOf(o),
|
|
2513
|
+
text: o.str,
|
|
2514
|
+
readingDirection: o.dir
|
|
2515
|
+
})), this.startLocator && (this.currentProgression = ((n = (s = this.startLocator) == null ? void 0 : s.locations) == null ? void 0 : n.progression) || 0, this.updateElementIndex()), this.pageContentFiltered.length > 0) {
|
|
2516
|
+
const o = this.currentElementIndex;
|
|
2517
|
+
(o || o === 0) && (this.currentElement = new zt(
|
|
2518
|
+
this.pageContentFiltered[o],
|
|
2519
|
+
1
|
|
2520
|
+
/* Forward */
|
|
2521
|
+
));
|
|
2522
|
+
}
|
|
2523
|
+
}
|
|
2524
|
+
// Returns the current element to be read.
|
|
2525
|
+
current() {
|
|
2526
|
+
return this.currentElement ? this.currentElement.element : null;
|
|
2527
|
+
}
|
|
2528
|
+
async hasPrevious() {
|
|
2529
|
+
var t;
|
|
2530
|
+
return (t = this.currentElement) == null || t.direction, this.nextIn(
|
|
2531
|
+
-1
|
|
2532
|
+
/* Backward */
|
|
2533
|
+
) !== null;
|
|
2534
|
+
}
|
|
2535
|
+
previous() {
|
|
2536
|
+
if (!this.currentElement)
|
|
2537
|
+
throw new F("Called next() without a successful call to hasNext() first");
|
|
2538
|
+
if (this.currentElement = this.nextIn(
|
|
2539
|
+
-1
|
|
2540
|
+
/* Backward */
|
|
2541
|
+
), this.currentElementIndex && this.currentElementIndex > 0) {
|
|
2542
|
+
const t = this.currentElementIndex - 1;
|
|
2543
|
+
this.currentProgression = t / this.pageContentFiltered.length * 100, this.currentElementIndex = t;
|
|
2544
|
+
}
|
|
2545
|
+
return this.currentElement ? this.currentElement.element : new it(new A({ href: "", type: "" }), { index: -1, text: "" });
|
|
2546
|
+
}
|
|
2547
|
+
async hasNext() {
|
|
2548
|
+
var t;
|
|
2549
|
+
return (t = this.currentElement) == null || t.direction, this.nextIn(
|
|
2550
|
+
1
|
|
2551
|
+
/* Forward */
|
|
2552
|
+
) !== null;
|
|
2553
|
+
}
|
|
2554
|
+
next() {
|
|
2555
|
+
this.currentElement = this.nextIn(
|
|
2556
|
+
1
|
|
2557
|
+
/* Forward */
|
|
2558
|
+
);
|
|
2559
|
+
const t = this.currentElementIndex;
|
|
2560
|
+
if (t !== null && t >= 0 && t < this.pageContentFiltered.length - 1) {
|
|
2561
|
+
const e = t + 1;
|
|
2562
|
+
this.currentProgression = e / this.pageContentFiltered.length * 100, this.currentElementIndex = e;
|
|
2563
|
+
}
|
|
2564
|
+
return this.currentElement ? this.currentElement.element : new it(new A({ href: "", type: "" }), { index: -1, text: "" });
|
|
2565
|
+
}
|
|
2566
|
+
nextIn(t) {
|
|
2567
|
+
const e = this.currentElementIndex;
|
|
2568
|
+
if (e === null || e === this.pageContentFiltered.length - 1 && t === 1 || e === 0 && t === -1)
|
|
2569
|
+
return null;
|
|
2570
|
+
const r = this.pageContentFiltered[e + t];
|
|
2571
|
+
return r ? new zt(r, t) : null;
|
|
2572
|
+
}
|
|
2573
|
+
/**
|
|
2574
|
+
* Updates the current [PDFReadableElement] position in the pageContentFiltered array
|
|
2575
|
+
* based on the current progression value.
|
|
2576
|
+
*/
|
|
2577
|
+
updateElementIndex() {
|
|
2578
|
+
return this.currentProgression === 0 ? 0 : this.currentProgression < 0 || this.currentProgression >= 100 ? null : Math.floor(this.currentProgression * this.pageContentFiltered.length / 100);
|
|
2579
|
+
}
|
|
2580
|
+
}
|
|
2581
|
+
const li = [
|
|
2582
|
+
"OBJECT",
|
|
2583
|
+
"BASE",
|
|
2584
|
+
"FONT",
|
|
2585
|
+
"TT",
|
|
2586
|
+
"I",
|
|
2587
|
+
"B",
|
|
2588
|
+
"U",
|
|
2589
|
+
"BIG",
|
|
2590
|
+
"SMALL",
|
|
2591
|
+
"EM",
|
|
2592
|
+
"STRONG",
|
|
2593
|
+
"DFN",
|
|
2594
|
+
"CODE",
|
|
2595
|
+
"SAMP",
|
|
2596
|
+
"KBD",
|
|
2597
|
+
"VAR",
|
|
2598
|
+
"CITE",
|
|
2599
|
+
"ABBR",
|
|
2600
|
+
"TIME",
|
|
2601
|
+
"ACRONYM",
|
|
2602
|
+
"MARK",
|
|
2603
|
+
"RUBY",
|
|
2604
|
+
"RT",
|
|
2605
|
+
"RP",
|
|
2606
|
+
"RTC",
|
|
2607
|
+
"A",
|
|
2608
|
+
"IMG",
|
|
2609
|
+
"BR",
|
|
2610
|
+
"WBR",
|
|
2611
|
+
"MAP",
|
|
2612
|
+
"Q",
|
|
2613
|
+
"SUB",
|
|
2614
|
+
"SUP",
|
|
2615
|
+
"BDO",
|
|
2616
|
+
"IFRAME",
|
|
2617
|
+
"EMBED",
|
|
2618
|
+
"SPAN",
|
|
2619
|
+
"INPUT",
|
|
2620
|
+
"SELECT",
|
|
2621
|
+
"TEXTAREA",
|
|
2622
|
+
"LABEL",
|
|
2623
|
+
"BUTTON",
|
|
2624
|
+
"OPTGROUP",
|
|
2625
|
+
"OPTION",
|
|
2626
|
+
"LEGEND",
|
|
2627
|
+
"DATALIST",
|
|
2628
|
+
"KEYGEN",
|
|
2629
|
+
"OUTPUT",
|
|
2630
|
+
"PROGRESS",
|
|
2631
|
+
"METER",
|
|
2632
|
+
"AREA",
|
|
2633
|
+
"PARAM",
|
|
2634
|
+
"SOURCE",
|
|
2635
|
+
"TRACK",
|
|
2636
|
+
"SUMMARY",
|
|
2637
|
+
"COMMAND",
|
|
2638
|
+
"DEVICE",
|
|
2639
|
+
"BASEFONT",
|
|
2640
|
+
"BGSOUND",
|
|
2641
|
+
"MENUITEM",
|
|
2642
|
+
"DATA",
|
|
2643
|
+
"BDI",
|
|
2644
|
+
"S",
|
|
2645
|
+
"STRIKE",
|
|
2646
|
+
"NOBR",
|
|
2647
|
+
"RB"
|
|
2648
|
+
];
|
|
2649
|
+
function vt(i) {
|
|
2650
|
+
return li.includes(i.nodeName.toUpperCase());
|
|
2651
|
+
}
|
|
2652
|
+
function rt(i, t) {
|
|
2653
|
+
const e = i.getAttribute("src");
|
|
2654
|
+
if (!(e != null && e.length))
|
|
2655
|
+
return null;
|
|
2656
|
+
try {
|
|
2657
|
+
return new URL(e, t).toString();
|
|
2658
|
+
} catch {
|
|
2659
|
+
return e;
|
|
2660
|
+
}
|
|
2661
|
+
}
|
|
2662
|
+
const W = "[\\s\\u0085\\u00A0\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]", ci = new RegExp(`^${W}+$`, "g"), hi = new RegExp(`^${W}+|${W}+$/g`, "g"), Mt = new RegExp(`^${W}+`, "g"), $t = new RegExp(`${W}+$`, "g"), V = (i) => (
|
|
2663
|
+
// Normal spaces, \t, \n, \v, \f, \r, U+0085, U+00A0, U+2000 to U+200A, U+2028, U+2029, U+202F, U+205F, U+3000
|
|
2664
|
+
i != null && i.length ? ci.test(i) : !0
|
|
2665
|
+
), Gt = (i) => i.replace(hi, ""), ui = (i) => i.replace(Mt, ""), fi = (i) => i.replace($t, ""), Ot = (i, t = "") => {
|
|
2666
|
+
var e, r;
|
|
2667
|
+
return new M({
|
|
2668
|
+
before: t + (((e = Mt.exec(i)) == null ? void 0 : e[0]) ?? ""),
|
|
2669
|
+
highlight: Gt(i),
|
|
2670
|
+
after: ((r = $t.exec(i)) == null ? void 0 : r[0]) ?? ""
|
|
2671
|
+
});
|
|
2672
|
+
};
|
|
2673
|
+
function pi(i) {
|
|
2674
|
+
for (; i; ) {
|
|
2675
|
+
let t = i.getAttribute("lang") || i.getAttributeNS("http://www.w3.org/1999/xhtml", "lang") || i.getAttributeNS("http://www.w3.org/XML/1998/namespace", "lang");
|
|
2676
|
+
if (t)
|
|
2677
|
+
return t;
|
|
2678
|
+
i = i.parentElement;
|
|
2679
|
+
}
|
|
2680
|
+
return null;
|
|
2681
|
+
}
|
|
2682
|
+
function di(i, t) {
|
|
2683
|
+
const e = i.length > 0 && i[i.length - 1] === " ";
|
|
2684
|
+
let r = !1, s = !1;
|
|
2685
|
+
for (let n = 0; n < t.length; n++)
|
|
2686
|
+
if (V(t[n])) {
|
|
2687
|
+
if (e && !s || r)
|
|
2688
|
+
continue;
|
|
2689
|
+
i += " ", r = !0;
|
|
2690
|
+
} else {
|
|
2691
|
+
const o = t.charCodeAt(n);
|
|
2692
|
+
o !== 8203 && o !== 173 && (i += t[n], r = !1, s = !0);
|
|
2693
|
+
}
|
|
2694
|
+
return i;
|
|
2695
|
+
}
|
|
2696
|
+
function yt(i) {
|
|
2697
|
+
return i && i instanceof Element;
|
|
2698
|
+
}
|
|
2699
|
+
var T;
|
|
2700
|
+
(function(i) {
|
|
2701
|
+
i.NONE = "none", i.DESCENDANT = "descendant", i.CHILD = "child";
|
|
2702
|
+
})(T || (T = {}));
|
|
2703
|
+
var g;
|
|
2704
|
+
(function(i) {
|
|
2705
|
+
i.id = "id", i.class = "class", i.tag = "tag", i.attribute = "attribute", i.nthchild = "nthchild", i.nthoftype = "nthoftype";
|
|
2706
|
+
})(g || (g = {}));
|
|
2707
|
+
function gi(i, t) {
|
|
2708
|
+
return Object.values(i).includes(t);
|
|
2709
|
+
}
|
|
2710
|
+
const mi = "CssSelectorGenerator";
|
|
2711
|
+
function X(i = "unknown problem", ...t) {
|
|
2712
|
+
console.warn(`${mi}: ${i}`, ...t);
|
|
2713
|
+
}
|
|
2714
|
+
const Ei = {
|
|
2715
|
+
selectors: [
|
|
2716
|
+
g.id,
|
|
2717
|
+
g.class,
|
|
2718
|
+
g.tag,
|
|
2719
|
+
g.attribute
|
|
2720
|
+
],
|
|
2721
|
+
// if set to true, always include tag name
|
|
2722
|
+
includeTag: !1,
|
|
2723
|
+
whitelist: [],
|
|
2724
|
+
blacklist: [],
|
|
2725
|
+
combineWithinSelector: !0,
|
|
2726
|
+
combineBetweenSelectors: !0,
|
|
2727
|
+
root: null,
|
|
2728
|
+
maxCombinations: Number.POSITIVE_INFINITY,
|
|
2729
|
+
maxCandidates: Number.POSITIVE_INFINITY
|
|
2730
|
+
};
|
|
2731
|
+
function bi(i) {
|
|
2732
|
+
return Array.isArray(i) ? i.filter((t) => gi(g, t)) : [];
|
|
2733
|
+
}
|
|
2734
|
+
function Ht(i) {
|
|
2735
|
+
return i instanceof RegExp;
|
|
2736
|
+
}
|
|
2737
|
+
function xi(i) {
|
|
2738
|
+
return ["string", "function"].includes(typeof i) || Ht(i);
|
|
2739
|
+
}
|
|
2740
|
+
function Nt(i) {
|
|
2741
|
+
return Array.isArray(i) ? i.filter(xi) : [];
|
|
2742
|
+
}
|
|
2743
|
+
function wi(i) {
|
|
2744
|
+
return i instanceof Node;
|
|
2745
|
+
}
|
|
2746
|
+
function Pt(i) {
|
|
2747
|
+
const t = [
|
|
2748
|
+
Node.DOCUMENT_NODE,
|
|
2749
|
+
Node.DOCUMENT_FRAGMENT_NODE,
|
|
2750
|
+
Node.ELEMENT_NODE
|
|
2751
|
+
];
|
|
2752
|
+
return wi(i) && t.includes(i.nodeType);
|
|
2753
|
+
}
|
|
2754
|
+
function Vt(i, t) {
|
|
2755
|
+
if (Pt(i))
|
|
2756
|
+
return i.contains(t) || X("element root mismatch", "Provided root does not contain the element. This will most likely result in producing a fallback selector using element's real root node. If you plan to use the selector using provided root (e.g. `root.querySelector`), it will nto work as intended."), i;
|
|
2757
|
+
const e = t.getRootNode({ composed: !1 });
|
|
2758
|
+
return Pt(e) ? (e !== document && X("shadow root inferred", "You did not provide a root and the element is a child of Shadow DOM. This will produce a selector using ShadowRoot as a root. If you plan to use the selector using document as a root (e.g. `document.querySelector`), it will not work as intended."), e) : t.ownerDocument.querySelector(":root");
|
|
2759
|
+
}
|
|
2760
|
+
function Ct(i) {
|
|
2761
|
+
return typeof i == "number" ? i : Number.POSITIVE_INFINITY;
|
|
2762
|
+
}
|
|
2763
|
+
function yi(i, t = {}) {
|
|
2764
|
+
const e = Object.assign(Object.assign({}, Ei), t);
|
|
2765
|
+
return {
|
|
2766
|
+
selectors: bi(e.selectors),
|
|
2767
|
+
whitelist: Nt(e.whitelist),
|
|
2768
|
+
blacklist: Nt(e.blacklist),
|
|
2769
|
+
root: Vt(e.root, i),
|
|
2770
|
+
combineWithinSelector: !!e.combineWithinSelector,
|
|
2771
|
+
combineBetweenSelectors: !!e.combineBetweenSelectors,
|
|
2772
|
+
includeTag: !!e.includeTag,
|
|
2773
|
+
maxCombinations: Ct(e.maxCombinations),
|
|
2774
|
+
maxCandidates: Ct(e.maxCandidates)
|
|
2775
|
+
};
|
|
2776
|
+
}
|
|
2777
|
+
function $(i = []) {
|
|
2778
|
+
const [t = [], ...e] = i;
|
|
2779
|
+
return e.length === 0 ? t : e.reduce((r, s) => r.filter((n) => s.includes(n)), t);
|
|
2780
|
+
}
|
|
2781
|
+
function Jt(i) {
|
|
2782
|
+
return [].concat(...i);
|
|
2783
|
+
}
|
|
2784
|
+
function Ai(i) {
|
|
2785
|
+
return i.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
|
|
2786
|
+
}
|
|
2787
|
+
function lt(i) {
|
|
2788
|
+
const t = i.map((e) => {
|
|
2789
|
+
if (Ht(e))
|
|
2790
|
+
return (r) => e.test(r);
|
|
2791
|
+
if (typeof e == "function")
|
|
2792
|
+
return (r) => {
|
|
2793
|
+
const s = e(r);
|
|
2794
|
+
return typeof s != "boolean" ? (X("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", e), !1) : s;
|
|
2795
|
+
};
|
|
2796
|
+
if (typeof e == "string") {
|
|
2797
|
+
const r = new RegExp("^" + Ai(e) + "$");
|
|
2798
|
+
return (s) => r.test(s);
|
|
2799
|
+
}
|
|
2800
|
+
return X("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", e), () => !1;
|
|
2801
|
+
});
|
|
2802
|
+
return (e) => t.some((r) => r(e));
|
|
2803
|
+
}
|
|
2804
|
+
function At(i, t, e) {
|
|
2805
|
+
const r = Array.from(Vt(e, i[0]).querySelectorAll(t));
|
|
2806
|
+
return r.length === i.length && i.every((s) => r.includes(s));
|
|
2807
|
+
}
|
|
2808
|
+
function Yt(i, t) {
|
|
2809
|
+
t = t ?? Ii(i);
|
|
2810
|
+
const e = [];
|
|
2811
|
+
let r = i;
|
|
2812
|
+
for (; yt(r) && r !== t; )
|
|
2813
|
+
e.push(r), r = r.parentElement;
|
|
2814
|
+
return e;
|
|
2815
|
+
}
|
|
2816
|
+
function Si(i, t) {
|
|
2817
|
+
return $(i.map((e) => Yt(e, t)));
|
|
2818
|
+
}
|
|
2819
|
+
function Ii(i) {
|
|
2820
|
+
return i.ownerDocument.querySelector(":root");
|
|
2821
|
+
}
|
|
2822
|
+
const Ti = "", qt = " > ", Kt = " ", zi = {
|
|
2823
|
+
[T.NONE]: {
|
|
2824
|
+
type: T.NONE,
|
|
2825
|
+
value: Ti
|
|
2826
|
+
},
|
|
2827
|
+
[T.DESCENDANT]: {
|
|
2828
|
+
type: T.DESCENDANT,
|
|
2829
|
+
value: qt
|
|
2830
|
+
},
|
|
2831
|
+
[T.CHILD]: {
|
|
2832
|
+
type: T.CHILD,
|
|
2833
|
+
value: Kt
|
|
2834
|
+
}
|
|
2835
|
+
}, Zt = ", ", vi = new RegExp([
|
|
2836
|
+
"^$",
|
|
2837
|
+
"\\s"
|
|
2838
|
+
// contains whitespace
|
|
2839
|
+
].join("|")), Oi = new RegExp([
|
|
2840
|
+
"^$"
|
|
2841
|
+
// empty or not set
|
|
2842
|
+
].join("|")), Xt = [
|
|
2843
|
+
g.nthoftype,
|
|
2844
|
+
g.tag,
|
|
2845
|
+
g.id,
|
|
2846
|
+
g.class,
|
|
2847
|
+
g.attribute,
|
|
2848
|
+
g.nthchild
|
|
2849
|
+
], Ni = lt([
|
|
2850
|
+
"class",
|
|
2851
|
+
"id",
|
|
2852
|
+
// Angular attributes
|
|
2853
|
+
"ng-*"
|
|
2854
|
+
]);
|
|
2855
|
+
function Pi({ nodeName: i }) {
|
|
2856
|
+
return `[${i}]`;
|
|
2857
|
+
}
|
|
2858
|
+
function Ci({ nodeName: i, nodeValue: t }) {
|
|
2859
|
+
return `[${i}='${tt(t)}']`;
|
|
2860
|
+
}
|
|
2861
|
+
function Ri({ nodeName: i }, t) {
|
|
2862
|
+
const e = t.tagName.toLowerCase();
|
|
2863
|
+
return ["input", "option"].includes(e) && i === "value" ? !1 : !Ni(i);
|
|
2864
|
+
}
|
|
2865
|
+
function Qt(i) {
|
|
2866
|
+
const t = Array.from(i.attributes).filter((e) => Ri(e, i));
|
|
2867
|
+
return [
|
|
2868
|
+
...t.map(Pi),
|
|
2869
|
+
...t.map(Ci)
|
|
2870
|
+
];
|
|
2871
|
+
}
|
|
2872
|
+
function Li(i) {
|
|
2873
|
+
const t = i.map(Qt);
|
|
2874
|
+
return $(t);
|
|
2875
|
+
}
|
|
2876
|
+
function _t(i) {
|
|
2877
|
+
return (i.getAttribute("class") || "").trim().split(/\s+/).filter((t) => !Oi.test(t)).map((t) => `.${tt(t)}`);
|
|
2878
|
+
}
|
|
2879
|
+
function ki(i) {
|
|
2880
|
+
const t = i.map(_t);
|
|
2881
|
+
return $(t);
|
|
2882
|
+
}
|
|
2883
|
+
function jt(i) {
|
|
2884
|
+
const t = i.getAttribute("id") || "", e = `#${tt(t)}`, r = i.getRootNode({ composed: !1 });
|
|
2885
|
+
return !vi.test(t) && At([i], e, r) ? [e] : [];
|
|
2886
|
+
}
|
|
2887
|
+
function Di(i) {
|
|
2888
|
+
return i.length === 0 || i.length > 1 ? [] : jt(i[0]);
|
|
2889
|
+
}
|
|
2890
|
+
function te(i) {
|
|
2891
|
+
const t = i.parentNode;
|
|
2892
|
+
if (t) {
|
|
2893
|
+
const r = Array.from(t.childNodes).filter(yt).indexOf(i);
|
|
2894
|
+
if (r > -1)
|
|
2895
|
+
return [`:nth-child(${r + 1})`];
|
|
2896
|
+
}
|
|
2897
|
+
return [];
|
|
2898
|
+
}
|
|
2899
|
+
function Ui(i) {
|
|
2900
|
+
return $(i.map(te));
|
|
2901
|
+
}
|
|
2902
|
+
function ee(i) {
|
|
2903
|
+
return [
|
|
2904
|
+
tt(i.tagName.toLowerCase())
|
|
2905
|
+
];
|
|
2906
|
+
}
|
|
2907
|
+
function ie(i) {
|
|
2908
|
+
const t = [
|
|
2909
|
+
...new Set(Jt(i.map(ee)))
|
|
2910
|
+
];
|
|
2911
|
+
return t.length === 0 || t.length > 1 ? [] : [t[0]];
|
|
2912
|
+
}
|
|
2913
|
+
function re(i) {
|
|
2914
|
+
const t = ie([i])[0], e = i.parentElement;
|
|
2915
|
+
if (e) {
|
|
2916
|
+
const s = Array.from(e.children).filter((n) => n.tagName.toLowerCase() === t).indexOf(i);
|
|
2917
|
+
if (s > -1)
|
|
2918
|
+
return [`${t}:nth-of-type(${s + 1})`];
|
|
2919
|
+
}
|
|
2920
|
+
return [];
|
|
2921
|
+
}
|
|
2922
|
+
function Bi(i) {
|
|
2923
|
+
return $(i.map(re));
|
|
2924
|
+
}
|
|
2925
|
+
function se(i = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
|
|
2926
|
+
const e = [];
|
|
2927
|
+
let r = 0, s = ct(1);
|
|
2928
|
+
for (; s.length <= i.length && r < t; )
|
|
2929
|
+
r += 1, e.push(s.map((n) => i[n])), s = Fi(s, i.length - 1);
|
|
2930
|
+
return e;
|
|
2931
|
+
}
|
|
2932
|
+
function Fi(i = [], t = 0) {
|
|
2933
|
+
const e = i.length;
|
|
2934
|
+
if (e === 0)
|
|
2935
|
+
return [];
|
|
2936
|
+
const r = [...i];
|
|
2937
|
+
r[e - 1] += 1;
|
|
2938
|
+
for (let s = e - 1; s >= 0; s--)
|
|
2939
|
+
if (r[s] > t) {
|
|
2940
|
+
if (s === 0)
|
|
2941
|
+
return ct(e + 1);
|
|
2942
|
+
r[s - 1]++, r[s] = r[s - 1] + 1;
|
|
2943
|
+
}
|
|
2944
|
+
return r[e - 1] > t ? ct(e + 1) : r;
|
|
2945
|
+
}
|
|
2946
|
+
function ct(i = 1) {
|
|
2947
|
+
return Array.from(Array(i).keys());
|
|
2948
|
+
}
|
|
2949
|
+
function Wi(i = {}) {
|
|
2950
|
+
let t = [];
|
|
2951
|
+
return Object.entries(i).forEach(([e, r]) => {
|
|
2952
|
+
t = r.flatMap((s) => t.length === 0 ? [{ [e]: s }] : t.map((n) => Object.assign(Object.assign({}, n), { [e]: s })));
|
|
2953
|
+
}), t;
|
|
2954
|
+
}
|
|
2955
|
+
const Mi = ":".charCodeAt(0).toString(16).toUpperCase(), $i = /[ !"#$%&'()\[\]{|}<>*+,./;=?@^`~\\]/;
|
|
2956
|
+
function tt(i = "") {
|
|
2957
|
+
var t, e;
|
|
2958
|
+
return (e = (t = CSS == null ? void 0 : CSS.escape) === null || t === void 0 ? void 0 : t.call(CSS, i)) !== null && e !== void 0 ? e : Gi(i);
|
|
2959
|
+
}
|
|
2960
|
+
function Gi(i = "") {
|
|
2961
|
+
return i.split("").map((t) => t === ":" ? `\\${Mi} ` : $i.test(t) ? `\\${t}` : escape(t).replace(/%/g, "\\")).join("");
|
|
2962
|
+
}
|
|
2963
|
+
const Hi = {
|
|
2964
|
+
tag: ie,
|
|
2965
|
+
id: Di,
|
|
2966
|
+
class: ki,
|
|
2967
|
+
attribute: Li,
|
|
2968
|
+
nthchild: Ui,
|
|
2969
|
+
nthoftype: Bi
|
|
2970
|
+
}, Vi = {
|
|
2971
|
+
tag: ee,
|
|
2972
|
+
id: jt,
|
|
2973
|
+
class: _t,
|
|
2974
|
+
attribute: Qt,
|
|
2975
|
+
nthchild: te,
|
|
2976
|
+
nthoftype: re
|
|
2977
|
+
};
|
|
2978
|
+
function Ji(i, t) {
|
|
2979
|
+
return Vi[t](i);
|
|
2980
|
+
}
|
|
2981
|
+
function Yi(i, t) {
|
|
2982
|
+
var e;
|
|
2983
|
+
return ((e = Hi[t]) !== null && e !== void 0 ? e : () => [])(i);
|
|
2984
|
+
}
|
|
2985
|
+
function qi(i = [], t, e) {
|
|
2986
|
+
return i.filter((r) => e(r) || !t(r));
|
|
2987
|
+
}
|
|
2988
|
+
function Ki(i = [], t) {
|
|
2989
|
+
return i.sort((e, r) => {
|
|
2990
|
+
const s = t(e), n = t(r);
|
|
2991
|
+
return s && !n ? -1 : !s && n ? 1 : 0;
|
|
2992
|
+
});
|
|
2993
|
+
}
|
|
2994
|
+
function Zi(i, t, e) {
|
|
2995
|
+
const r = Xi(i, e), s = tr(r, e), n = Jt(s);
|
|
2996
|
+
return [...new Set(n)];
|
|
2997
|
+
}
|
|
2998
|
+
function Xi(i, t) {
|
|
2999
|
+
const { blacklist: e, whitelist: r, combineWithinSelector: s, maxCombinations: n } = t, o = lt(e), l = lt(r), c = (h, u) => {
|
|
3000
|
+
const p = Yi(i, u), f = qi(p, o, l), d = Ki(f, l);
|
|
3001
|
+
return h[u] = s ? se(d, { maxResults: n }) : d.map((I) => [I]), h;
|
|
3002
|
+
};
|
|
3003
|
+
return Qi(t).reduce(c, {});
|
|
3004
|
+
}
|
|
3005
|
+
function Qi(i) {
|
|
3006
|
+
const { selectors: t, includeTag: e } = i, r = [].concat(t);
|
|
3007
|
+
return e && !r.includes("tag") && r.push("tag"), r;
|
|
3008
|
+
}
|
|
3009
|
+
function _i(i) {
|
|
3010
|
+
return i.includes(g.tag) || i.includes(g.nthoftype) ? [...i] : [...i, g.tag];
|
|
3011
|
+
}
|
|
3012
|
+
function ji(i) {
|
|
3013
|
+
const { selectors: t, combineBetweenSelectors: e, includeTag: r, maxCandidates: s } = i, n = e ? se(t, { maxResults: s }) : t.map((o) => [o]);
|
|
3014
|
+
return r ? n.map(_i) : n;
|
|
3015
|
+
}
|
|
3016
|
+
function tr(i, t) {
|
|
3017
|
+
return ji(t).map((e) => er(e, i)).filter((e) => e.length > 0);
|
|
3018
|
+
}
|
|
3019
|
+
function er(i, t) {
|
|
3020
|
+
const e = {};
|
|
3021
|
+
return i.forEach((s) => {
|
|
3022
|
+
const n = t[s];
|
|
3023
|
+
n.length > 0 && (e[s] = n);
|
|
3024
|
+
}), Wi(e).map(rr);
|
|
3025
|
+
}
|
|
3026
|
+
function ir(i, t) {
|
|
3027
|
+
return t[i] ? t[i].join("") : "";
|
|
3028
|
+
}
|
|
3029
|
+
function rr(i = {}) {
|
|
3030
|
+
const t = [...Xt];
|
|
3031
|
+
return i[g.tag] && i[g.nthoftype] && t.splice(t.indexOf(g.tag), 1), t.map((e) => ir(e, i)).join("");
|
|
3032
|
+
}
|
|
3033
|
+
function sr(i, t) {
|
|
3034
|
+
return [
|
|
3035
|
+
...i.map((e) => t + Kt + e),
|
|
3036
|
+
...i.map((e) => t + qt + e)
|
|
3037
|
+
];
|
|
3038
|
+
}
|
|
3039
|
+
function nr(i, t) {
|
|
3040
|
+
return t === "" ? i : sr(i, t);
|
|
3041
|
+
}
|
|
3042
|
+
function or(i, t, e = "", r) {
|
|
3043
|
+
const s = Zi(i, r.root, r), n = nr(s, e);
|
|
3044
|
+
for (const o of n)
|
|
3045
|
+
if (At(i, o, r.root))
|
|
3046
|
+
return o;
|
|
3047
|
+
return null;
|
|
3048
|
+
}
|
|
3049
|
+
function ar(i, t, e = "", r) {
|
|
3050
|
+
if (i.length === 0)
|
|
3051
|
+
return null;
|
|
3052
|
+
const s = [
|
|
3053
|
+
i.length > 1 ? i : [],
|
|
3054
|
+
...Si(i, t).map((n) => [n])
|
|
3055
|
+
];
|
|
3056
|
+
for (const n of s) {
|
|
3057
|
+
const o = or(n, t, e, r);
|
|
3058
|
+
if (o)
|
|
3059
|
+
return {
|
|
3060
|
+
foundElements: n,
|
|
3061
|
+
selector: o
|
|
3062
|
+
};
|
|
3063
|
+
}
|
|
3064
|
+
return null;
|
|
3065
|
+
}
|
|
3066
|
+
function lr(i) {
|
|
3067
|
+
const t = (Array.isArray(i) ? i : [i]).filter(yt);
|
|
3068
|
+
return [...new Set(t)];
|
|
3069
|
+
}
|
|
3070
|
+
function cr(i) {
|
|
3071
|
+
return {
|
|
3072
|
+
value: i,
|
|
3073
|
+
include: !1
|
|
3074
|
+
};
|
|
3075
|
+
}
|
|
3076
|
+
function hr(i, t, e = T.NONE) {
|
|
3077
|
+
const r = {};
|
|
3078
|
+
return t.forEach((s) => {
|
|
3079
|
+
Reflect.set(r, s, Ji(i, s).map(cr));
|
|
3080
|
+
}), {
|
|
3081
|
+
element: i,
|
|
3082
|
+
operator: zi[e],
|
|
3083
|
+
selectors: r
|
|
3084
|
+
};
|
|
3085
|
+
}
|
|
3086
|
+
function ur({ selectors: i, operator: t }) {
|
|
3087
|
+
let e = [...Xt];
|
|
3088
|
+
i[g.tag] && i[g.nthoftype] && (e = e.filter((s) => s !== g.tag));
|
|
3089
|
+
let r = "";
|
|
3090
|
+
return e.forEach((s) => {
|
|
3091
|
+
(i[s] || []).forEach(({ value: o, include: l }) => {
|
|
3092
|
+
l && (r += o);
|
|
3093
|
+
});
|
|
3094
|
+
}), t.value + r;
|
|
3095
|
+
}
|
|
3096
|
+
function fr(i) {
|
|
3097
|
+
return [":root", ...Yt(i).reverse().map((r) => {
|
|
3098
|
+
const s = hr(r, [g.nthchild], T.DESCENDANT);
|
|
3099
|
+
return s.selectors.nthchild.forEach((n) => {
|
|
3100
|
+
n.include = !0;
|
|
3101
|
+
}), s;
|
|
3102
|
+
}).map(ur)].join("");
|
|
3103
|
+
}
|
|
3104
|
+
function pr(i) {
|
|
3105
|
+
return i.map(fr).join(Zt);
|
|
3106
|
+
}
|
|
3107
|
+
function ne(i, t = {}) {
|
|
3108
|
+
const e = lr(i), r = yi(e[0], t);
|
|
3109
|
+
let s = "", n = r.root;
|
|
3110
|
+
function o() {
|
|
3111
|
+
return ar(e, n, s, r);
|
|
3112
|
+
}
|
|
3113
|
+
let l = o();
|
|
3114
|
+
for (; l; ) {
|
|
3115
|
+
const { foundElements: c, selector: h } = l;
|
|
3116
|
+
if (At(e, h, r.root))
|
|
3117
|
+
return h;
|
|
3118
|
+
n = c[0], s = h, l = o();
|
|
3119
|
+
}
|
|
3120
|
+
return e.length > 1 ? e.map((c) => ne(c, r)).join(Zt) : pr(e);
|
|
3121
|
+
}
|
|
3122
|
+
class Tr extends wt {
|
|
3123
|
+
constructor(t, e, r = 50) {
|
|
3124
|
+
super(), this.resource = t, this.locator = e, this.beforeMaxLength = r, this.currentElement = null, this.currentIndex = null, this.parsedElementRecipes = null, this.parser = null;
|
|
3125
|
+
}
|
|
3126
|
+
async hasPrevious() {
|
|
3127
|
+
var s;
|
|
3128
|
+
if (((s = this.currentElement) == null ? void 0 : s.delta) === -1)
|
|
3129
|
+
return !0;
|
|
3130
|
+
const t = await this.elements(), e = (this.currentIndex ?? t.startIndex) - 1, r = t.elements.at(e);
|
|
3131
|
+
return r ? (this.currentIndex = e, this.currentElement = {
|
|
3132
|
+
delta: -1,
|
|
3133
|
+
element: this.parser.executeRecipe(r)
|
|
3134
|
+
}, !0) : !1;
|
|
3135
|
+
}
|
|
3136
|
+
previous() {
|
|
3137
|
+
if (!this.currentElement || this.currentElement.delta !== -1)
|
|
3138
|
+
throw new F("Called previous() without a successful call to hasPrevious() first");
|
|
3139
|
+
const t = this.currentElement.element;
|
|
3140
|
+
return this.currentElement = null, t;
|
|
3141
|
+
}
|
|
3142
|
+
async hasNext() {
|
|
3143
|
+
var s;
|
|
3144
|
+
if (((s = this.currentElement) == null ? void 0 : s.delta) === 1)
|
|
3145
|
+
return !0;
|
|
3146
|
+
const t = await this.elements(), e = (this.currentIndex ?? t.startIndex - 1) + 1, r = t.elements.at(e);
|
|
3147
|
+
return r ? (this.currentIndex = e, this.currentElement = {
|
|
3148
|
+
delta: 1,
|
|
3149
|
+
element: this.parser.executeRecipe(r)
|
|
3150
|
+
}, !0) : !1;
|
|
3151
|
+
}
|
|
3152
|
+
next() {
|
|
3153
|
+
if (!this.currentElement || this.currentElement.delta !== 1)
|
|
3154
|
+
throw new F("Called next() without a successful call to hasNext() first");
|
|
3155
|
+
const t = this.currentElement.element;
|
|
3156
|
+
return this.currentElement = null, t;
|
|
3157
|
+
}
|
|
3158
|
+
async elements() {
|
|
3159
|
+
return this.parsedElementRecipes ?? (this.parsedElementRecipes = await this.parseElements()), this.parsedElementRecipes;
|
|
3160
|
+
}
|
|
3161
|
+
async parseElements() {
|
|
3162
|
+
const t = await this.resource.readAsString(), e = new DOMParser().parseFromString(t, this.locator.type);
|
|
3163
|
+
return this.parser = new gr(
|
|
3164
|
+
e,
|
|
3165
|
+
this.locator,
|
|
3166
|
+
this.locator.locations.getCssSelector() ? e.querySelector(this.locator.locations.getCssSelector()) : null,
|
|
3167
|
+
this.beforeMaxLength
|
|
3168
|
+
), dr(this.parser, e.body), this.parser.result();
|
|
3169
|
+
}
|
|
3170
|
+
}
|
|
3171
|
+
function dr(i, t) {
|
|
3172
|
+
let e = t, r = 0;
|
|
3173
|
+
for (; e != null; )
|
|
3174
|
+
if (i.head(e, r), e.firstChild != null)
|
|
3175
|
+
e = e.firstChild, r++;
|
|
3176
|
+
else {
|
|
3177
|
+
for (; (e == null ? void 0 : e.nextSibling) == null && r > 0; )
|
|
3178
|
+
e && i.tail(e, r), e = (e == null ? void 0 : e.parentNode) || null, r--;
|
|
3179
|
+
if (e && i.tail(e, r), e === t)
|
|
3180
|
+
break;
|
|
3181
|
+
e = (e == null ? void 0 : e.nextSibling) || null;
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
class gr {
|
|
3185
|
+
constructor(t, e, r, s) {
|
|
3186
|
+
this.doc = t, this.baseLocator = e, this.startElement = r, this.beforeMaxLength = s, this.elementRecipes = [], this.startIndex = 0, this.segmentRecipesAcc = [], this.textAcc = "", this.wholeRawTextAcc = null, this.elementRawTextAcc = "", this.rawTextAcc = "", this.currentLanguage = null, this.breadcrumbs = [], this.recipeCssSelectorCache = /* @__PURE__ */ new WeakMap();
|
|
3187
|
+
}
|
|
3188
|
+
result() {
|
|
3189
|
+
return {
|
|
3190
|
+
elements: this.elementRecipes,
|
|
3191
|
+
startIndex: this.baseLocator.locations.progression === 1 ? this.elementRecipes.length : this.startIndex
|
|
3192
|
+
};
|
|
3193
|
+
}
|
|
3194
|
+
executeRecipe(t) {
|
|
3195
|
+
var r;
|
|
3196
|
+
const e = t.recipe.cssSelectorNode ? this.cssSelector(t.recipe.cssSelectorNode) : null;
|
|
3197
|
+
if (t.type === 1) {
|
|
3198
|
+
const s = t.recipe;
|
|
3199
|
+
return new ii(
|
|
3200
|
+
new A({
|
|
3201
|
+
href: this.baseLocator.href,
|
|
3202
|
+
type: this.baseLocator.type,
|
|
3203
|
+
title: this.baseLocator.title,
|
|
3204
|
+
locations: new E(e ? {
|
|
3205
|
+
otherLocations: /* @__PURE__ */ new Map([
|
|
3206
|
+
["cssSelector", e]
|
|
3207
|
+
])
|
|
3208
|
+
} : {})
|
|
3209
|
+
}),
|
|
3210
|
+
new S({
|
|
3211
|
+
href: s.href
|
|
3212
|
+
}),
|
|
3213
|
+
s.caption,
|
|
3214
|
+
s.attributes
|
|
3215
|
+
);
|
|
3216
|
+
} else if (t.type === 2 || t.type === 3) {
|
|
3217
|
+
const s = new A({
|
|
3218
|
+
href: this.baseLocator.href,
|
|
3219
|
+
type: this.baseLocator.type,
|
|
3220
|
+
title: this.baseLocator.title,
|
|
3221
|
+
locations: new E(e ? {
|
|
3222
|
+
otherLocations: /* @__PURE__ */ new Map([
|
|
3223
|
+
["cssSelector", e]
|
|
3224
|
+
])
|
|
3225
|
+
} : {})
|
|
3226
|
+
}), n = t.recipe;
|
|
3227
|
+
return t.type === 3 ? new ei(
|
|
3228
|
+
s,
|
|
3229
|
+
n.link
|
|
3230
|
+
) : new ti(
|
|
3231
|
+
s,
|
|
3232
|
+
n.link
|
|
3233
|
+
);
|
|
3234
|
+
} else if (t.type === 0) {
|
|
3235
|
+
const s = t.recipe, n = s.segments.map((o) => {
|
|
3236
|
+
var c;
|
|
3237
|
+
const l = o.cssSelectorNode ? this.cssSelector(o.cssSelectorNode) : null;
|
|
3238
|
+
return new Wt(
|
|
3239
|
+
new A({
|
|
3240
|
+
href: this.baseLocator.href,
|
|
3241
|
+
type: this.baseLocator.type,
|
|
3242
|
+
title: this.baseLocator.title,
|
|
3243
|
+
text: Ot(o.text, (c = this.wholeRawTextAcc) == null ? void 0 : c.substring(o.beforeRange[0], o.beforeRange[1])),
|
|
3244
|
+
locations: new E(l ? {
|
|
3245
|
+
otherLocations: /* @__PURE__ */ new Map([
|
|
3246
|
+
["cssSelector", l]
|
|
3247
|
+
])
|
|
3248
|
+
} : {})
|
|
3249
|
+
}),
|
|
3250
|
+
o.text,
|
|
3251
|
+
o.attributes
|
|
3252
|
+
);
|
|
3253
|
+
});
|
|
3254
|
+
return new at(
|
|
3255
|
+
new A({
|
|
3256
|
+
href: this.baseLocator.href,
|
|
3257
|
+
type: this.baseLocator.type,
|
|
3258
|
+
title: this.baseLocator.title,
|
|
3259
|
+
text: Ot(s.text, n.length && ((r = n[0].locator.text) == null ? void 0 : r.before) || ""),
|
|
3260
|
+
locations: new E(e ? {
|
|
3261
|
+
otherLocations: /* @__PURE__ */ new Map([
|
|
3262
|
+
["cssSelector", e]
|
|
3263
|
+
])
|
|
3264
|
+
} : {})
|
|
3265
|
+
}),
|
|
3266
|
+
s.role,
|
|
3267
|
+
n
|
|
3268
|
+
);
|
|
3269
|
+
} else
|
|
3270
|
+
throw new Error("Unknown recipe type");
|
|
3271
|
+
}
|
|
3272
|
+
cssSelector(t) {
|
|
3273
|
+
const e = t, r = this.recipeCssSelectorCache.get(e);
|
|
3274
|
+
if (r)
|
|
3275
|
+
return r;
|
|
3276
|
+
const s = /* @__PURE__ */ new Map();
|
|
3277
|
+
let n = e;
|
|
3278
|
+
for (; n && n !== this.doc.body; ) {
|
|
3279
|
+
for (let l = 0; l < n.attributes.length; l++) {
|
|
3280
|
+
const c = n.attributes[l];
|
|
3281
|
+
c.prefix && (s.has(n) ? s.set(n, s.get(n).concat([c])) : s.set(n, [c]), n.attributes.removeNamedItem(c.name));
|
|
3282
|
+
}
|
|
3283
|
+
n = n.parentElement;
|
|
3284
|
+
}
|
|
3285
|
+
const o = ne(e, {
|
|
3286
|
+
root: this.doc
|
|
3287
|
+
});
|
|
3288
|
+
return s.forEach((l, c) => l.forEach((h) => c.attributes.setNamedItem(h))), this.recipeCssSelectorCache.set(e, o), o;
|
|
3289
|
+
}
|
|
3290
|
+
// Implements NodeTraversor
|
|
3291
|
+
head(t, e) {
|
|
3292
|
+
if (t.nodeType == Node.ELEMENT_NODE) {
|
|
3293
|
+
const r = !vt(t);
|
|
3294
|
+
r && (this.flushText(), this.breadcrumbs.push(t));
|
|
3295
|
+
const s = t.nodeName.toUpperCase();
|
|
3296
|
+
if (s === "BR")
|
|
3297
|
+
this.flushText();
|
|
3298
|
+
else if (s === "IMG" || s === "AUDIO" || s === "VIDEO")
|
|
3299
|
+
if (this.flushText(), s === "IMG") {
|
|
3300
|
+
const n = t, o = rt(n, this.baseLocator.href);
|
|
3301
|
+
let l = n.getAttribute("alt");
|
|
3302
|
+
l != null && l.length || (l = n.getAttribute("title")), o != null && this.elementRecipes.push({
|
|
3303
|
+
type: 1,
|
|
3304
|
+
recipe: {
|
|
3305
|
+
href: o,
|
|
3306
|
+
caption: void 0,
|
|
3307
|
+
// FIXME: Get the caption from figcaption
|
|
3308
|
+
cssSelectorNode: t,
|
|
3309
|
+
attributes: l != null && l.length ? [new Tt(
|
|
3310
|
+
ot.ACCESSIBILITY_LABEL,
|
|
3311
|
+
l
|
|
3312
|
+
)] : []
|
|
3313
|
+
}
|
|
3314
|
+
});
|
|
3315
|
+
} else {
|
|
3316
|
+
const n = t, o = rt(n, this.baseLocator.href);
|
|
3317
|
+
let l;
|
|
3318
|
+
if (o != null)
|
|
3319
|
+
l = new S({
|
|
3320
|
+
href: o
|
|
3321
|
+
});
|
|
3322
|
+
else {
|
|
3323
|
+
const c = [...n.getElementsByTagName("source")].map((h) => {
|
|
3324
|
+
const u = rt(h, this.baseLocator.href);
|
|
3325
|
+
return u ? new S({
|
|
3326
|
+
href: u,
|
|
3327
|
+
type: h.getAttribute("type") || void 0
|
|
3328
|
+
}) : null;
|
|
3329
|
+
}).filter((h) => !!h);
|
|
3330
|
+
c.length > 0 && (l = new S({
|
|
3331
|
+
href: c[0].href,
|
|
3332
|
+
type: c[0].type,
|
|
3333
|
+
alternates: c.length > 1 ? new x(c.slice(1)) : void 0
|
|
3334
|
+
}));
|
|
3335
|
+
}
|
|
3336
|
+
l && (s === "AUDIO" ? this.elementRecipes.push({
|
|
3337
|
+
type: 2,
|
|
3338
|
+
recipe: {
|
|
3339
|
+
cssSelectorNode: t,
|
|
3340
|
+
link: l
|
|
3341
|
+
}
|
|
3342
|
+
}) : s === "VIDEO" && this.elementRecipes.push({
|
|
3343
|
+
type: 3,
|
|
3344
|
+
recipe: {
|
|
3345
|
+
cssSelectorNode: t,
|
|
3346
|
+
link: l
|
|
3347
|
+
}
|
|
3348
|
+
}));
|
|
3349
|
+
}
|
|
3350
|
+
r && this.flushText();
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
// Implements NodeTraversor
|
|
3354
|
+
tail(t, e) {
|
|
3355
|
+
if (t.nodeType === Node.TEXT_NODE && !V(t.textContent)) {
|
|
3356
|
+
const r = pi(t.parentElement);
|
|
3357
|
+
this.currentLanguage !== r && (this.flushSegment(), this.currentLanguage = r), this.rawTextAcc += t.textContent, this.textAcc = di(this.textAcc, t.textContent);
|
|
3358
|
+
} else if (t.nodeType === Node.ELEMENT_NODE && !vt(t)) {
|
|
3359
|
+
if (!this.breadcrumbs.length || this.breadcrumbs.at(-1) !== t)
|
|
3360
|
+
throw new Error("HTMLContentIterator: breadcrumbs mismatch");
|
|
3361
|
+
this.flushText(), this.breadcrumbs.pop();
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
flushText() {
|
|
3365
|
+
var e;
|
|
3366
|
+
if (this.flushSegment(), this.startIndex === 0 && this.startElement && this.breadcrumbs.length && this.breadcrumbs.at(-1) === this.startElement && (this.startIndex = this.elementRecipes.length), !this.segmentRecipesAcc.length)
|
|
3367
|
+
return;
|
|
3368
|
+
this.segmentRecipesAcc[this.segmentRecipesAcc.length - 1].text = fi(
|
|
3369
|
+
this.segmentRecipesAcc[this.segmentRecipesAcc.length - 1].text
|
|
3370
|
+
);
|
|
3371
|
+
let t = si;
|
|
3372
|
+
if (this.breadcrumbs.length > 0) {
|
|
3373
|
+
const r = this.breadcrumbs.at(-1);
|
|
3374
|
+
if (r.getAttributeNS("http://www.idpf.org/2007/ops", "type") === "footnote")
|
|
3375
|
+
t = ni;
|
|
3376
|
+
else
|
|
3377
|
+
switch (r.nodeName.toUpperCase()) {
|
|
3378
|
+
case "H1":
|
|
3379
|
+
case "H2":
|
|
3380
|
+
case "H3":
|
|
3381
|
+
case "H4":
|
|
3382
|
+
case "H5":
|
|
3383
|
+
case "H6":
|
|
3384
|
+
t = new ri(parseInt(r.nodeName[1]));
|
|
3385
|
+
break;
|
|
3386
|
+
case "BLOCKQUOTE":
|
|
3387
|
+
case "Q":
|
|
3388
|
+
t = new oi(
|
|
3389
|
+
(e = r.getAttribute("cite")) != null && e.length || 0 > 0 ? new URL(r.getAttribute("cite")) : void 0,
|
|
3390
|
+
r.getAttribute("title") || void 0
|
|
3391
|
+
);
|
|
3392
|
+
break;
|
|
3393
|
+
}
|
|
3394
|
+
}
|
|
3395
|
+
this.elementRecipes.push({
|
|
3396
|
+
type: 0,
|
|
3397
|
+
recipe: {
|
|
3398
|
+
text: this.elementRawTextAcc,
|
|
3399
|
+
role: t,
|
|
3400
|
+
segments: [...this.segmentRecipesAcc],
|
|
3401
|
+
cssSelectorNode: this.breadcrumbs.at(-1)
|
|
3402
|
+
}
|
|
3403
|
+
}), this.elementRawTextAcc = "", this.segmentRecipesAcc = [];
|
|
3404
|
+
}
|
|
3405
|
+
flushSegment() {
|
|
3406
|
+
let t = this.textAcc;
|
|
3407
|
+
const e = Gt(t);
|
|
3408
|
+
if (!V(e)) {
|
|
3409
|
+
if (!this.segmentRecipesAcc.length) {
|
|
3410
|
+
t = ui(t);
|
|
3411
|
+
const r = t.length && V(t[t.length - 1]) ? t[t.length - 1] : "";
|
|
3412
|
+
t = e + r;
|
|
3413
|
+
}
|
|
3414
|
+
this.segmentRecipesAcc.push({
|
|
3415
|
+
text: t,
|
|
3416
|
+
attributes: this.currentLanguage ? [new Tt(
|
|
3417
|
+
ot.LANGUAGE,
|
|
3418
|
+
this.currentLanguage
|
|
3419
|
+
)] : [],
|
|
3420
|
+
beforeRange: this.wholeRawTextAcc ? [this.wholeRawTextAcc.length - this.beforeMaxLength, this.wholeRawTextAcc.length] : [0, 0],
|
|
3421
|
+
cssSelectorNode: this.breadcrumbs.at(-1)
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3424
|
+
this.rawTextAcc.length && (this.wholeRawTextAcc = (this.wholeRawTextAcc || "") + this.rawTextAcc, this.elementRawTextAcc += this.rawTextAcc), this.rawTextAcc = "", this.textAcc = "";
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
class Q {
|
|
2213
3428
|
/**
|
|
2214
3429
|
* Creates a [LocatorMetadata].
|
|
2215
3430
|
*/
|
|
@@ -2222,12 +3437,12 @@ class V {
|
|
|
2222
3437
|
static deserialize(t) {
|
|
2223
3438
|
if (!t)
|
|
2224
3439
|
return;
|
|
2225
|
-
const e = /* @__PURE__ */ new Map(),
|
|
2226
|
-
return Object.entries(t).forEach(([s,
|
|
2227
|
-
|
|
2228
|
-
}), new
|
|
3440
|
+
const e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set(["title", "numberOfItems"]);
|
|
3441
|
+
return Object.entries(t).forEach(([s, n]) => {
|
|
3442
|
+
r.has(s) || e.set(s, n);
|
|
3443
|
+
}), new Q({
|
|
2229
3444
|
title: O.deserialize(t.title),
|
|
2230
|
-
numberOfItems:
|
|
3445
|
+
numberOfItems: C(t.numberOfItems),
|
|
2231
3446
|
otherMetadata: e.size === 0 ? void 0 : e
|
|
2232
3447
|
});
|
|
2233
3448
|
}
|
|
@@ -2236,15 +3451,15 @@ class V {
|
|
|
2236
3451
|
*/
|
|
2237
3452
|
serialize() {
|
|
2238
3453
|
const t = {};
|
|
2239
|
-
return this.title && (t.title = this.title.serialize()), this.numberOfItems !== void 0 && (t.numberOfItems = this.numberOfItems), this.otherMetadata && this.otherMetadata.forEach((e,
|
|
3454
|
+
return this.title && (t.title = this.title.serialize()), this.numberOfItems !== void 0 && (t.numberOfItems = this.numberOfItems), this.otherMetadata && this.otherMetadata.forEach((e, r) => t[r] = e), t;
|
|
2240
3455
|
}
|
|
2241
3456
|
}
|
|
2242
|
-
class
|
|
3457
|
+
class oe {
|
|
2243
3458
|
/**
|
|
2244
3459
|
* Creates a [LocatorCollection].
|
|
2245
3460
|
*/
|
|
2246
3461
|
constructor(t) {
|
|
2247
|
-
this.metadata = t.metadata ?? new
|
|
3462
|
+
this.metadata = t.metadata ?? new Q({}), this.links = t.links ?? new x([]), this.locators = t.locators ?? [];
|
|
2248
3463
|
}
|
|
2249
3464
|
/**
|
|
2250
3465
|
* Parses a [LocatorCollection] from its RWPM JSON representation.
|
|
@@ -2252,10 +3467,10 @@ class ut {
|
|
|
2252
3467
|
static deserialize(t) {
|
|
2253
3468
|
if (!t)
|
|
2254
3469
|
return;
|
|
2255
|
-
let e,
|
|
2256
|
-
return
|
|
2257
|
-
metadata:
|
|
2258
|
-
links:
|
|
3470
|
+
let e, r = t.locators;
|
|
3471
|
+
return r && r instanceof Array && (e = r.map((s) => A.deserialize(s)).filter((s) => s !== void 0)), new oe({
|
|
3472
|
+
metadata: Q.deserialize(t.metadata),
|
|
3473
|
+
links: x.deserialize(t.links),
|
|
2259
3474
|
locators: e
|
|
2260
3475
|
});
|
|
2261
3476
|
}
|
|
@@ -2271,7 +3486,7 @@ class ut {
|
|
|
2271
3486
|
return this.links && this.links.items.length > 0 && (t.links = this.links.serialize()), this.locators && (t.locators = this.locators.map((e) => e.serialize())), t;
|
|
2272
3487
|
}
|
|
2273
3488
|
}
|
|
2274
|
-
class
|
|
3489
|
+
class v {
|
|
2275
3490
|
/**
|
|
2276
3491
|
* Creates a [PublicationCollection].
|
|
2277
3492
|
*/
|
|
@@ -2284,18 +3499,18 @@ class A {
|
|
|
2284
3499
|
static deserialize(t) {
|
|
2285
3500
|
if (!t)
|
|
2286
3501
|
return;
|
|
2287
|
-
let e,
|
|
3502
|
+
let e, r, s;
|
|
2288
3503
|
if (t instanceof Array)
|
|
2289
|
-
e =
|
|
3504
|
+
e = x.deserialize(t);
|
|
2290
3505
|
else if (t instanceof Object)
|
|
2291
|
-
e =
|
|
2292
|
-
|
|
2293
|
-
}), s =
|
|
3506
|
+
e = x.deserialize(t.links), r = /* @__PURE__ */ new Map(), t.metadata && Object.entries(t.metadata).forEach(([n, o]) => {
|
|
3507
|
+
r == null || r.set(n, o);
|
|
3508
|
+
}), s = v.deserializeCollections(t);
|
|
2294
3509
|
else
|
|
2295
3510
|
return;
|
|
2296
3511
|
if (!(!e || e.items.length === 0))
|
|
2297
|
-
return new
|
|
2298
|
-
metadata:
|
|
3512
|
+
return new v({
|
|
3513
|
+
metadata: r != null && r.size ? r : void 0,
|
|
2299
3514
|
links: e,
|
|
2300
3515
|
subcollections: s != null && s.size ? s : void 0
|
|
2301
3516
|
});
|
|
@@ -2308,17 +3523,17 @@ class A {
|
|
|
2308
3523
|
if (!t)
|
|
2309
3524
|
return;
|
|
2310
3525
|
const e = /* @__PURE__ */ new Map();
|
|
2311
|
-
return Object.entries(t).forEach(([
|
|
2312
|
-
if (
|
|
2313
|
-
const
|
|
2314
|
-
if (
|
|
3526
|
+
return Object.entries(t).forEach(([r, s]) => {
|
|
3527
|
+
if (r !== "links" && r !== "metadata") {
|
|
3528
|
+
const n = v.deserialize(s);
|
|
3529
|
+
if (n) {
|
|
2315
3530
|
const o = new Array();
|
|
2316
|
-
o.push(
|
|
3531
|
+
o.push(n), e.set(r, o);
|
|
2317
3532
|
} else if (s instanceof Array) {
|
|
2318
3533
|
const o = s.map(
|
|
2319
|
-
(l) =>
|
|
3534
|
+
(l) => v.deserialize(l)
|
|
2320
3535
|
).filter((l) => l !== void 0);
|
|
2321
|
-
e.set(
|
|
3536
|
+
e.set(r, o);
|
|
2322
3537
|
}
|
|
2323
3538
|
}
|
|
2324
3539
|
}), e.size ? e : void 0;
|
|
@@ -2329,18 +3544,18 @@ class A {
|
|
|
2329
3544
|
serialize() {
|
|
2330
3545
|
const t = {};
|
|
2331
3546
|
return this.metadata && (t.metadata = {}, this.metadata.forEach(
|
|
2332
|
-
(e,
|
|
2333
|
-
)), this.links.items.length && (t.links = this.links.serialize()),
|
|
3547
|
+
(e, r) => t.metadata[r] = e
|
|
3548
|
+
)), this.links.items.length && (t.links = this.links.serialize()), v.serializeCollection(t, this.subcollections), t;
|
|
2334
3549
|
}
|
|
2335
3550
|
static serializeCollection(t, e) {
|
|
2336
3551
|
e && e.size > 0 && e.forEach(
|
|
2337
|
-
(
|
|
2338
|
-
|
|
3552
|
+
(r, s) => {
|
|
3553
|
+
r.length === 1 ? t[s] = r[0].serialize() : t[s] = r.map((n) => n.serialize());
|
|
2339
3554
|
}
|
|
2340
3555
|
);
|
|
2341
3556
|
}
|
|
2342
3557
|
}
|
|
2343
|
-
class
|
|
3558
|
+
class ae {
|
|
2344
3559
|
constructor(t) {
|
|
2345
3560
|
this.context = t.context, this.metadata = t.metadata, this.links = t.links, this.readingOrder = t.readingOrder, this.resources = t.resources, this.tableOfContents = t.tableOfContents, this.subcollections = t.subcollections;
|
|
2346
3561
|
}
|
|
@@ -2353,24 +3568,24 @@ class pt {
|
|
|
2353
3568
|
static deserialize(t) {
|
|
2354
3569
|
if (!t)
|
|
2355
3570
|
return;
|
|
2356
|
-
const e =
|
|
3571
|
+
const e = Ut.deserialize(t.metadata);
|
|
2357
3572
|
if (!e)
|
|
2358
3573
|
return;
|
|
2359
|
-
const
|
|
2360
|
-
if (!
|
|
3574
|
+
const r = x.deserialize(t.links);
|
|
3575
|
+
if (!r)
|
|
2361
3576
|
return;
|
|
2362
|
-
const s =
|
|
3577
|
+
const s = x.deserialize(
|
|
2363
3578
|
t.readingOrder ? t.readingOrder : t.spine
|
|
2364
3579
|
);
|
|
2365
3580
|
if (s)
|
|
2366
|
-
return new
|
|
2367
|
-
context:
|
|
3581
|
+
return new ae({
|
|
3582
|
+
context: R(t["@context"]),
|
|
2368
3583
|
metadata: e,
|
|
2369
|
-
links:
|
|
3584
|
+
links: r,
|
|
2370
3585
|
readingOrder: s,
|
|
2371
|
-
resources:
|
|
2372
|
-
tableOfContents:
|
|
2373
|
-
subcollections:
|
|
3586
|
+
resources: x.deserialize(t.resources),
|
|
3587
|
+
tableOfContents: x.deserialize(t.toc),
|
|
3588
|
+
subcollections: v.deserializeCollections({
|
|
2374
3589
|
sub: t.sub
|
|
2375
3590
|
})
|
|
2376
3591
|
});
|
|
@@ -2380,38 +3595,38 @@ class pt {
|
|
|
2380
3595
|
*/
|
|
2381
3596
|
serialize() {
|
|
2382
3597
|
const t = {};
|
|
2383
|
-
return this.context !== void 0 && (t["@context"] = this.context), t.metadata = this.metadata.serialize(), t.links = this.links.serialize(), t.readingOrder = this.readingOrder.serialize(), this.resources && (t.resources = this.resources.serialize()), this.tableOfContents && (t.toc = this.tableOfContents.serialize()),
|
|
3598
|
+
return this.context !== void 0 && (t["@context"] = this.context), t.metadata = this.metadata.serialize(), t.links = this.links.serialize(), t.readingOrder = this.readingOrder.serialize(), this.resources && (t.resources = this.resources.serialize()), this.tableOfContents && (t.toc = this.tableOfContents.serialize()), v.serializeCollection(t, this.subcollections), t;
|
|
2384
3599
|
}
|
|
2385
3600
|
/** Finds the first link with the given relation in the manifest's links. */
|
|
2386
3601
|
linkWithRel(t) {
|
|
2387
3602
|
const e = new Array();
|
|
2388
3603
|
e.push(this.readingOrder), this.resources && e.push(this.resources), e.push(this.links);
|
|
2389
|
-
let
|
|
3604
|
+
let r;
|
|
2390
3605
|
for (const s of e)
|
|
2391
|
-
if (
|
|
2392
|
-
return
|
|
2393
|
-
return
|
|
3606
|
+
if (r = s.findWithRel(t), r !== void 0)
|
|
3607
|
+
return r;
|
|
3608
|
+
return r;
|
|
2394
3609
|
}
|
|
2395
3610
|
/** Finds all the links with the given relation in the manifest's links. */
|
|
2396
3611
|
linksWithRel(t) {
|
|
2397
3612
|
const e = [];
|
|
2398
|
-
return e.push(this.readingOrder.filterByRel(t)), this.resources && e.push(this.resources.filterByRel(t)), e.push(this.links.filterByRel(t)), e.reduce((
|
|
3613
|
+
return e.push(this.readingOrder.filterByRel(t)), this.resources && e.push(this.resources.filterByRel(t)), e.push(this.links.filterByRel(t)), e.reduce((r, s) => r.concat(s), []);
|
|
2399
3614
|
}
|
|
2400
3615
|
/**
|
|
2401
3616
|
* Creates a new [Locator] object from a [Link] to a resource of this manifest.
|
|
2402
3617
|
* Returns null if the resource is not found in this manifest.
|
|
2403
3618
|
*/
|
|
2404
3619
|
locatorFromLink(t) {
|
|
2405
|
-
const e = t.href.split("#"),
|
|
3620
|
+
const e = t.href.split("#"), r = e.length == 2 ? e[0] : t.href, s = this.linkWithHref(r);
|
|
2406
3621
|
if (!s)
|
|
2407
3622
|
return;
|
|
2408
|
-
const
|
|
2409
|
-
if (!
|
|
3623
|
+
const n = s.type;
|
|
3624
|
+
if (!n)
|
|
2410
3625
|
return;
|
|
2411
3626
|
const o = e.length == 2 ? e[1] : void 0;
|
|
2412
|
-
return new
|
|
2413
|
-
href:
|
|
2414
|
-
type:
|
|
3627
|
+
return new A({
|
|
3628
|
+
href: r,
|
|
3629
|
+
type: n,
|
|
2415
3630
|
title: s.title ?? t.title,
|
|
2416
3631
|
locations: new E({
|
|
2417
3632
|
fragments: o ? [o] : void 0,
|
|
@@ -2422,26 +3637,26 @@ class pt {
|
|
|
2422
3637
|
/** Finds the first Link having the given `href` in the publication's links. */
|
|
2423
3638
|
linkWithHref(t) {
|
|
2424
3639
|
const e = (l) => {
|
|
2425
|
-
let
|
|
2426
|
-
for (const
|
|
2427
|
-
if (
|
|
2428
|
-
return
|
|
2429
|
-
const
|
|
2430
|
-
return l.forEach((
|
|
2431
|
-
const
|
|
2432
|
-
for (const
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
}),
|
|
2436
|
-
},
|
|
2437
|
-
|
|
2438
|
-
const s = e(
|
|
3640
|
+
let c;
|
|
3641
|
+
for (const u of l)
|
|
3642
|
+
if (c = u.findWithHref(t), c !== void 0)
|
|
3643
|
+
return c;
|
|
3644
|
+
const h = new Array();
|
|
3645
|
+
return l.forEach((u) => {
|
|
3646
|
+
const p = [];
|
|
3647
|
+
for (const f of u.items)
|
|
3648
|
+
f.alternates && p.push(f.alternates), f.children && p.push(f.children);
|
|
3649
|
+
h.push(...p);
|
|
3650
|
+
}), h.length > 0 && (c = e(h)), c;
|
|
3651
|
+
}, r = [];
|
|
3652
|
+
r.push(this.readingOrder), this.resources && r.push(this.resources), r.push(this.links);
|
|
3653
|
+
const s = e(r);
|
|
2439
3654
|
if (s !== void 0)
|
|
2440
3655
|
return s;
|
|
2441
|
-
const
|
|
2442
|
-
if (
|
|
3656
|
+
const n = t.split(/[#]/);
|
|
3657
|
+
if (n.length < 2)
|
|
2443
3658
|
return;
|
|
2444
|
-
const o =
|
|
3659
|
+
const o = n[0];
|
|
2445
3660
|
return this.linkWithHref(o);
|
|
2446
3661
|
}
|
|
2447
3662
|
/** The URL where this publication is served, computed from the `Link` with `self` relation.
|
|
@@ -2454,7 +3669,7 @@ class pt {
|
|
|
2454
3669
|
if (t) {
|
|
2455
3670
|
let e = t.href;
|
|
2456
3671
|
if (e) {
|
|
2457
|
-
const
|
|
3672
|
+
const r = e.lastIndexOf("/"), s = r === -1 ? void 0 : e.substring(r + 1);
|
|
2458
3673
|
e = e.replace(new RegExp("/?$query$"), ""), e = e.replace(new RegExp("//$"), ""), s && (e = e.replace(new RegExp(s + "$"), ""));
|
|
2459
3674
|
}
|
|
2460
3675
|
return e;
|
|
@@ -2466,71 +3681,95 @@ class pt {
|
|
|
2466
3681
|
setSelfLink(t) {
|
|
2467
3682
|
this.links.items = this.links.items.filter(
|
|
2468
3683
|
(e) => {
|
|
2469
|
-
var
|
|
2470
|
-
return e.rels === void 0 || !((
|
|
3684
|
+
var r;
|
|
3685
|
+
return e.rels === void 0 || !((r = e.rels) != null && r.has("self"));
|
|
2471
3686
|
}
|
|
2472
3687
|
), this.links.items.push(
|
|
2473
|
-
new
|
|
3688
|
+
new S({
|
|
2474
3689
|
href: t,
|
|
2475
|
-
type:
|
|
3690
|
+
type: a.READIUM_WEBPUB_MANIFEST.string,
|
|
2476
3691
|
rels: /* @__PURE__ */ new Set(["self"])
|
|
2477
3692
|
})
|
|
2478
3693
|
);
|
|
2479
3694
|
}
|
|
2480
3695
|
}
|
|
2481
3696
|
export {
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
3697
|
+
U as Acquisition,
|
|
3698
|
+
Tt as Attribute,
|
|
3699
|
+
ot as AttributeKeys,
|
|
3700
|
+
Bt as AttributesHolder,
|
|
3701
|
+
ti as AudioElement,
|
|
3702
|
+
Et as Availability,
|
|
3703
|
+
je as AvailabilityStatus,
|
|
3704
|
+
B as BelongsTo,
|
|
3705
|
+
si as Body,
|
|
3706
|
+
wr as Content,
|
|
3707
|
+
Ft as ContentElement,
|
|
3708
|
+
K as Contributor,
|
|
3709
|
+
b as Contributors,
|
|
3710
|
+
mt as Copies,
|
|
3711
|
+
Ze as DefaultTextContentTokenizer,
|
|
3712
|
+
pt as DomRange,
|
|
3713
|
+
q as DomRangePoint,
|
|
3714
|
+
Rt as EPUBLayout,
|
|
3715
|
+
Ae as EmptyFetcher,
|
|
3716
|
+
ht as Encryption,
|
|
3717
|
+
ve as Fit,
|
|
3718
|
+
ni as Footnote,
|
|
3719
|
+
ft as GuidedNavigationDocument,
|
|
3720
|
+
k as GuidedNavigationObject,
|
|
3721
|
+
Tr as HTMLResourceContentIterator,
|
|
3722
|
+
ri as Heading,
|
|
3723
|
+
gt as Holds,
|
|
3724
|
+
mr as HttpFetcher,
|
|
3725
|
+
Se as HttpResource,
|
|
3726
|
+
F as IllegalStateError,
|
|
3727
|
+
ii as ImageElement,
|
|
3728
|
+
Xe as IntlTextTokenizer,
|
|
3729
|
+
wt as Iterator,
|
|
3730
|
+
S as Link,
|
|
3731
|
+
x as Links,
|
|
2504
3732
|
O as LocalizedString,
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
3733
|
+
A as Locator,
|
|
3734
|
+
oe as LocatorCollection,
|
|
3735
|
+
Q as LocatorCollectionMetadata,
|
|
2508
3736
|
E as LocatorLocations,
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
3737
|
+
M as LocatorText,
|
|
3738
|
+
ae as Manifest,
|
|
3739
|
+
a as MediaType,
|
|
3740
|
+
Ut as Metadata,
|
|
3741
|
+
Qe as NaiveTextTokenizer,
|
|
3742
|
+
Er as NumberRange,
|
|
3743
|
+
Ie as Orientation,
|
|
3744
|
+
Te as Overflow,
|
|
3745
|
+
it as PDFContentElement,
|
|
3746
|
+
H as Page,
|
|
3747
|
+
Ir as PageContentIteratorPDF,
|
|
3748
|
+
_ as Presentation,
|
|
3749
|
+
dt as Price,
|
|
3750
|
+
m as Properties,
|
|
3751
|
+
N as Publication,
|
|
3752
|
+
v as PublicationCollection,
|
|
3753
|
+
Sr as PublicationContentIterator,
|
|
3754
|
+
z as ReadingProgression,
|
|
3755
|
+
br as Resource,
|
|
3756
|
+
ze as Spread,
|
|
3757
|
+
Z as Subject,
|
|
3758
|
+
xt as Subjects,
|
|
3759
|
+
yr as TextContentTokenizer,
|
|
3760
|
+
at as TextElement,
|
|
3761
|
+
oi as TextQuote,
|
|
3762
|
+
Wt as TextSegment,
|
|
3763
|
+
Ke as TextUnit,
|
|
3764
|
+
j as TextualElement,
|
|
3765
|
+
J as URITemplate,
|
|
3766
|
+
ei as VideoElement,
|
|
3767
|
+
Oe as arrayfromJSON,
|
|
3768
|
+
R as arrayfromJSONorString,
|
|
3769
|
+
Y as datefromJSON,
|
|
3770
|
+
xr as leadingPage,
|
|
3771
|
+
C as numberfromJSON,
|
|
2533
3772
|
y as positiveNumberfromJSON,
|
|
2534
|
-
|
|
2535
|
-
|
|
3773
|
+
ut as setToArray,
|
|
3774
|
+
kt as speakableToken
|
|
2536
3775
|
};
|