@readium/shared 2.2.0-alpha.1 → 2.2.0-beta.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 CHANGED
@@ -84,7 +84,7 @@ class ei {
84
84
  );
85
85
  return new DOMParser().parseFromString(
86
86
  await t.text(),
87
- this._link.mediaType.isHTML ? this._link.mediaType.string : "text/xml"
87
+ "application/xml"
88
88
  );
89
89
  }
90
90
  }
@@ -101,10 +101,10 @@ class ir {
101
101
  return this.readAsString().then((t) => t === void 0 ? t : JSON.parse(t));
102
102
  }
103
103
  readAsXML() {
104
- return this.link().then((t) => this.readAsString().then((e) => e === void 0 ? e : new DOMParser().parseFromString(e, t.mediaType.isHTML ? t.mediaType.string : "text/xml")));
104
+ return this.readAsString().then((t) => t === void 0 ? t : new DOMParser().parseFromString(t, "text/xml"));
105
105
  }
106
106
  }
107
- class _ {
107
+ class V {
108
108
  constructor(t = {}) {
109
109
  this.conformsTo = t.conformsTo ?? [], this.certification = t.certification ?? null, this.summary = t.summary ?? null, this.accessMode = t.accessMode ?? [], this.accessModeSufficient = t.accessModeSufficient ?? [], this.feature = t.feature ?? [], this.hazard = t.hazard ?? [], this.exemption = t.exemption ?? [];
110
110
  }
@@ -114,13 +114,13 @@ class _ {
114
114
  static deserialize(t) {
115
115
  if (!t || typeof t != "object") return;
116
116
  const e = t;
117
- return new _({
117
+ return new V({
118
118
  conformsTo: e.conformsTo ? e.conformsTo.map((i) => Tt.deserialize(i)).filter((i) => i !== void 0) : void 0,
119
119
  certification: e.certification ? Pt.deserialize(e.certification) : void 0,
120
120
  summary: e.summary,
121
121
  accessMode: e.accessMode ? e.accessMode.map((i) => R.deserialize(i)).filter((i) => i !== void 0) : void 0,
122
122
  accessModeSufficient: e.accessModeSufficient ? e.accessModeSufficient.map((i) => It.deserialize(i)).filter((i) => i !== void 0) : void 0,
123
- feature: e.feature ? e.feature.map((i) => A.deserialize(i)).filter((i) => i !== void 0) : void 0,
123
+ feature: e.feature ? e.feature.map((i) => v.deserialize(i)).filter((i) => i !== void 0) : void 0,
124
124
  hazard: e.hazard ? e.hazard.map((i) => P.deserialize(i)).filter((i) => i !== void 0) : void 0,
125
125
  exemption: e.exemption ? e.exemption.map((i) => xt.deserialize(i)).filter((i) => i !== void 0) : void 0
126
126
  });
@@ -269,7 +269,7 @@ const l = class l {
269
269
  }
270
270
  };
271
271
  l.NONE = new l("none"), l.ANNOTATIONS = new l("annotations"), l.ARIA = new l("ARIA"), l.INDEX = new l("index"), l.PAGE_BREAK_MARKERS = new l("pageBreakMarkers"), l.PAGE_NAVIGATION = new l("pageNavigation"), l.PRINT_PAGE_NUMBERS = new l("printPageNumbers"), l.READING_ORDER = new l("readingOrder"), l.STRUCTURAL_NAVIGATION = new l("structuralNavigation"), l.TABLE_OF_CONTENTS = new l("tableOfContents"), l.TAGGED_PDF = new l("taggedPDF"), l.ALTERNATIVE_TEXT = new l("alternativeText"), l.AUDIO_DESCRIPTION = new l("audioDescription"), l.CAPTIONS = new l("captions"), l.CLOSED_CAPTIONS = new l("closedCaptions"), l.DESCRIBED_MATH = new l("describedMath"), l.LONG_DESCRIPTION = new l("longDescription"), l.OPEN_CAPTIONS = new l("openCaptions"), l.SIGN_LANGUAGE = new l("signLanguage"), l.TRANSCRIPT = new l("transcript"), l.DISPLAY_TRANSFORMABILITY = new l("displayTransformability"), l.SYNCHRONIZED_AUDIO_TEXT = new l("synchronizedAudioText"), l.TIMING_CONTROL = new l("timingControl"), l.UNLOCKED = new l("unlocked"), l.CHEM_ML = new l("ChemML"), l.LATEX = new l("latex"), l.LATEX_CHEMISTRY = new l("latex-chemistry"), l.MATH_ML = new l("MathML"), l.MATH_ML_CHEMISTRY = new l("MathML-chemistry"), l.TTS_MARKUP = new l("ttsMarkup"), l.HIGH_CONTRAST_AUDIO = new l("highContrastAudio"), l.HIGH_CONTRAST_DISPLAY = new l("highContrastDisplay"), l.LARGE_PRINT = new l("largePrint"), l.BRAILLE = new l("braille"), l.TACTILE_GRAPHIC = new l("tactileGraphic"), l.TACTILE_OBJECT = new l("tactileObject"), l.FULL_RUBY_ANNOTATIONS = new l("fullRubyAnnotations"), l.HORIZONTAL_WRITING = new l("horizontalWriting"), l.RUBY_ANNOTATIONS = new l("rubyAnnotations"), l.VERTICAL_WRITING = new l("verticalWriting"), l.WITH_ADDITIONAL_WORD_SEGMENTATION = new l("withAdditionalWordSegmentation"), l.WITHOUT_ADDITIONAL_WORD_SEGMENTATION = new l("withoutAdditionalWordSegmentation");
272
- let A = l;
272
+ let v = l;
273
273
  const w = class w {
274
274
  constructor(t) {
275
275
  this.value = t;
@@ -438,7 +438,7 @@ class kt {
438
438
  });
439
439
  }
440
440
  static fromPublication(t) {
441
- const e = t.metadata.accessibility ?? new _(), i = e.feature ?? [], r = t.metadata.layout === $.fixed, n = i.some((d) => d.value === A.DISPLAY_TRANSFORMABILITY.value) ? "modifiable" : r ? "unmodifiable" : "unknown", a = e.accessMode ?? [], o = e.accessModeSufficient ?? [], h = a.length > 0 && a.every((d) => d.value === R.TEXTUAL.value) || o.some((d) => {
441
+ const e = t.metadata.accessibility ?? new V(), i = e.feature ?? [], r = t.metadata.layout === $.fixed, n = i.some((d) => d.value === v.DISPLAY_TRANSFORMABILITY.value) ? "modifiable" : r ? "unmodifiable" : "unknown", a = e.accessMode ?? [], o = e.accessModeSufficient ?? [], h = a.length > 0 && a.every((d) => d.value === R.TEXTUAL.value) || o.some((d) => {
442
442
  const I = d.value;
443
443
  return Array.isArray(I) ? I.every((B) => B === R.TEXTUAL.value) : I === R.TEXTUAL.value;
444
444
  }), m = a.some((d) => d.value === R.TEXTUAL.value) || o.some((d) => {
@@ -448,18 +448,18 @@ class kt {
448
448
  const I = d.value;
449
449
  return Array.isArray(I) ? I.some((B) => B === R.TEXTUAL.value) : I === R.TEXTUAL.value;
450
450
  }), u = i.some((d) => [
451
- A.LONG_DESCRIPTION.value,
452
- A.ALTERNATIVE_TEXT.value,
453
- A.DESCRIBED_MATH.value,
454
- A.TRANSCRIPT.value
455
- ].includes(d.value)), g = h ? "readable" : m || u ? "notFully" : p ? "unreadable" : "noMetadata", v = u, C = i.some((d) => d.value === A.SYNCHRONIZED_AUDIO_TEXT.value) ? "synchronized" : o.some((d) => {
451
+ v.LONG_DESCRIPTION.value,
452
+ v.ALTERNATIVE_TEXT.value,
453
+ v.DESCRIBED_MATH.value,
454
+ v.TRANSCRIPT.value
455
+ ].includes(d.value)), g = h ? "readable" : m || u ? "notFully" : p ? "unreadable" : "noMetadata", A = u, C = i.some((d) => d.value === v.SYNCHRONIZED_AUDIO_TEXT.value) ? "synchronized" : o.some((d) => {
456
456
  const I = d.value;
457
457
  return Array.isArray(I) ? I.some((B) => B === R.AUDITORY.value) : I === R.AUDITORY.value;
458
458
  }) ? "audioOnly" : a.some((d) => d.value === R.AUDITORY.value) ? "audioComplementary" : "noMetadata";
459
459
  return new kt(
460
460
  n,
461
461
  g,
462
- v,
462
+ A,
463
463
  C
464
464
  );
465
465
  }
@@ -510,12 +510,12 @@ class Dt {
510
510
  }
511
511
  }
512
512
  static fromPublication(t) {
513
- const i = (t.metadata.accessibility ?? new _()).feature ?? [];
513
+ const i = (t.metadata.accessibility ?? new V()).feature ?? [];
514
514
  return new Dt(
515
- i.some((r) => r.value === A.TABLE_OF_CONTENTS.value),
516
- i.some((r) => r.value === A.INDEX.value),
517
- i.some((r) => r.value === A.STRUCTURAL_NAVIGATION.value),
518
- i.some((r) => r.value === A.PAGE_NAVIGATION.value)
515
+ i.some((r) => r.value === v.TABLE_OF_CONTENTS.value),
516
+ i.some((r) => r.value === v.INDEX.value),
517
+ i.some((r) => r.value === v.STRUCTURAL_NAVIGATION.value),
518
+ i.some((r) => r.value === v.PAGE_NAVIGATION.value)
519
519
  );
520
520
  }
521
521
  }
@@ -606,23 +606,23 @@ class Ut {
606
606
  }
607
607
  }
608
608
  static fromPublication(t) {
609
- const i = (t.metadata.accessibility ?? new _()).feature ?? [];
609
+ const i = (t.metadata.accessibility ?? new V()).feature ?? [];
610
610
  return new Ut(
611
- i.some((r) => r.value === A.LONG_DESCRIPTION.value),
612
- i.some((r) => r.value === A.DESCRIBED_MATH.value),
613
- i.some((r) => r.value === A.MATH_ML.value),
614
- i.some((r) => r.value === A.LATEX.value),
615
- i.some((r) => r.value === A.MATH_ML_CHEMISTRY.value),
616
- i.some((r) => r.value === A.LATEX_CHEMISTRY.value),
617
- i.some((r) => r.value === A.CLOSED_CAPTIONS.value),
618
- i.some((r) => r.value === A.OPEN_CAPTIONS.value),
619
- i.some((r) => r.value === A.TRANSCRIPT.value)
611
+ i.some((r) => r.value === v.LONG_DESCRIPTION.value),
612
+ i.some((r) => r.value === v.DESCRIBED_MATH.value),
613
+ i.some((r) => r.value === v.MATH_ML.value),
614
+ i.some((r) => r.value === v.LATEX.value),
615
+ i.some((r) => r.value === v.MATH_ML_CHEMISTRY.value),
616
+ i.some((r) => r.value === v.LATEX_CHEMISTRY.value),
617
+ i.some((r) => r.value === v.CLOSED_CAPTIONS.value),
618
+ i.some((r) => r.value === v.OPEN_CAPTIONS.value),
619
+ i.some((r) => r.value === v.TRANSCRIPT.value)
620
620
  );
621
621
  }
622
622
  }
623
623
  class Mt {
624
- constructor(t = !1, e = !1, i = !1, r = !1, n = !1, a = !1, o = !1, h = !1, m = !1, p = !1, u = !1, g = !1, v = !1) {
625
- this.id = "additional-accessibility-information.title", this.pageBreakMarkers = t, this.aria = e, this.audioDescriptions = i, this.braille = r, this.rubyAnnotations = n, this.fullRubyAnnotations = a, this.highAudioContrast = o, this.highDisplayContrast = h, this.largePrint = m, this.signLanguage = p, this.tactileGraphics = u, this.tactileObjects = g, this.textToSpeechHinting = v, this.noMetadata = !t && !e && !i && !r && !n && !a && !o && !h && !m && !p && !u && !g && !v, this.shouldDisplay = !this.noMetadata;
624
+ constructor(t = !1, e = !1, i = !1, r = !1, n = !1, a = !1, o = !1, h = !1, m = !1, p = !1, u = !1, g = !1, A = !1) {
625
+ this.id = "additional-accessibility-information.title", this.pageBreakMarkers = t, this.aria = e, this.audioDescriptions = i, this.braille = r, this.rubyAnnotations = n, this.fullRubyAnnotations = a, this.highAudioContrast = o, this.highDisplayContrast = h, this.largePrint = m, this.signLanguage = p, this.tactileGraphics = u, this.tactileObjects = g, this.textToSpeechHinting = A, this.noMetadata = !t && !e && !i && !r && !n && !a && !o && !h && !m && !p && !u && !g && !A, this.shouldDisplay = !this.noMetadata;
626
626
  const C = f.getString(this.id);
627
627
  if (this.title = C.compact, this.statements = [], t) {
628
628
  const d = f.getString("additional-accessibility-information.page-breaks");
@@ -720,7 +720,7 @@ class Mt {
720
720
  descriptiveString: d.descriptive
721
721
  });
722
722
  }
723
- if (v) {
723
+ if (A) {
724
724
  const d = f.getString("additional-accessibility-information.text-to-speech-hinting");
725
725
  this.statements.push({
726
726
  id: "additional-accessibility-information.text-to-speech-hinting",
@@ -730,21 +730,21 @@ class Mt {
730
730
  }
731
731
  }
732
732
  static fromPublication(t) {
733
- const i = (t.metadata.accessibility ?? new _()).feature ?? [];
733
+ const i = (t.metadata.accessibility ?? new V()).feature ?? [];
734
734
  return new Mt(
735
- i.some((r) => r.value === A.PAGE_BREAK_MARKERS.value || r.value === A.PRINT_PAGE_NUMBERS.value),
736
- i.some((r) => r.value === A.ARIA.value),
737
- i.some((r) => r.value === A.AUDIO_DESCRIPTION.value),
738
- i.some((r) => r.value === A.BRAILLE.value),
739
- i.some((r) => r.value === A.RUBY_ANNOTATIONS.value),
740
- i.some((r) => r.value === A.FULL_RUBY_ANNOTATIONS.value),
741
- i.some((r) => r.value === A.HIGH_CONTRAST_AUDIO.value),
742
- i.some((r) => r.value === A.HIGH_CONTRAST_DISPLAY.value),
743
- i.some((r) => r.value === A.LARGE_PRINT.value),
744
- i.some((r) => r.value === A.SIGN_LANGUAGE.value),
745
- i.some((r) => r.value === A.TACTILE_GRAPHIC.value),
746
- i.some((r) => r.value === A.TACTILE_OBJECT.value),
747
- i.some((r) => r.value === A.TTS_MARKUP.value)
735
+ i.some((r) => r.value === v.PAGE_BREAK_MARKERS.value || r.value === v.PRINT_PAGE_NUMBERS.value),
736
+ i.some((r) => r.value === v.ARIA.value),
737
+ i.some((r) => r.value === v.AUDIO_DESCRIPTION.value),
738
+ i.some((r) => r.value === v.BRAILLE.value),
739
+ i.some((r) => r.value === v.RUBY_ANNOTATIONS.value),
740
+ i.some((r) => r.value === v.FULL_RUBY_ANNOTATIONS.value),
741
+ i.some((r) => r.value === v.HIGH_CONTRAST_AUDIO.value),
742
+ i.some((r) => r.value === v.HIGH_CONTRAST_DISPLAY.value),
743
+ i.some((r) => r.value === v.LARGE_PRINT.value),
744
+ i.some((r) => r.value === v.SIGN_LANGUAGE.value),
745
+ i.some((r) => r.value === v.TACTILE_GRAPHIC.value),
746
+ i.some((r) => r.value === v.TACTILE_OBJECT.value),
747
+ i.some((r) => r.value === v.TTS_MARKUP.value)
748
748
  );
749
749
  }
750
750
  }
@@ -1031,7 +1031,7 @@ Object.defineProperty(D.prototype, "encryption", {
1031
1031
  return Ft.deserialize(this.otherProperties.encrypted);
1032
1032
  }
1033
1033
  });
1034
- class _t {
1034
+ class Vt {
1035
1035
  /** Creates a MediaOverlay object */
1036
1036
  constructor(t) {
1037
1037
  this.activeClass = t.activeClass, this.playbackActiveClass = t.playbackActiveClass;
@@ -1041,7 +1041,7 @@ class _t {
1041
1041
  */
1042
1042
  static deserialize(t) {
1043
1043
  if (t)
1044
- return new _t({
1044
+ return new Vt({
1045
1045
  activeClass: t.activeClass,
1046
1046
  playbackActiveClass: t.playbackActiveClass
1047
1047
  });
@@ -1114,18 +1114,18 @@ class c {
1114
1114
  throw new Error("Invalid media type");
1115
1115
  const a = {};
1116
1116
  for (let g = 1; g < r.length; g++) {
1117
- const v = r[g].split("=");
1118
- if (v.length === 2) {
1119
- const C = v[0].toLocaleLowerCase(), d = C === "charset" ? v[1].toUpperCase() : v[1];
1117
+ const A = r[g].split("=");
1118
+ if (A.length === 2) {
1119
+ const C = A[0].toLocaleLowerCase(), d = C === "charset" ? A[1].toUpperCase() : A[1];
1120
1120
  a[C] = d;
1121
1121
  }
1122
1122
  }
1123
1123
  const o = {}, h = Object.keys(a);
1124
- h.sort((g, v) => g.localeCompare(v)), h.forEach((g) => o[g] = a[g]);
1124
+ h.sort((g, A) => g.localeCompare(A)), h.forEach((g) => o[g] = a[g]);
1125
1125
  let m = "";
1126
1126
  for (const g in o) {
1127
- const v = o[g];
1128
- m += `;${g}=${v}`;
1127
+ const A = o[g];
1128
+ m += `;${g}=${A}`;
1129
1129
  }
1130
1130
  const p = `${e}/${i}${m}`, u = o.encoding;
1131
1131
  this.string = p, this.type = e, this.subtype = i, this.parameters = o, this.encoding = u, this.name = t.name, this.fileExtension = t.fileExtension;
@@ -1225,6 +1225,7 @@ class c {
1225
1225
  /** Returns whether this media type is of a bitmap image, so excluding vectorial formats. */
1226
1226
  get isBitmap() {
1227
1227
  return this.matchesAny(
1228
+ c.AVIF,
1228
1229
  c.BMP,
1229
1230
  c.GIF,
1230
1231
  c.JPEG,
@@ -1288,6 +1289,9 @@ class c {
1288
1289
  fileExtension: "avi"
1289
1290
  });
1290
1291
  }
1292
+ static get AVIF() {
1293
+ return c.parse({ mediaType: "image/avif", fileExtension: "avif" });
1294
+ }
1291
1295
  static get BINARY() {
1292
1296
  return c.parse({ mediaType: "application/octet-stream" });
1293
1297
  }
@@ -2034,7 +2038,7 @@ class dt {
2034
2038
  return this.sortAs !== void 0 && (t.sortAs = this.sortAs.serialize()), this.code !== void 0 && (t.code = this.code), this.scheme !== void 0 && (t.scheme = this.scheme), this.links && (t.links = this.links.serialize()), t;
2035
2039
  }
2036
2040
  }
2037
- class Vt {
2041
+ class _t {
2038
2042
  /** Creates an Array of [Subject]. */
2039
2043
  constructor(t) {
2040
2044
  this.items = t;
@@ -2045,7 +2049,7 @@ class Vt {
2045
2049
  static deserialize(t) {
2046
2050
  if (!t) return;
2047
2051
  const e = Array.isArray(t) ? t : [t];
2048
- return new Vt(
2052
+ return new _t(
2049
2053
  e.map((i) => dt.deserialize(i)).filter((i) => i !== void 0)
2050
2054
  );
2051
2055
  }
@@ -2092,7 +2096,7 @@ const tt = class tt {
2092
2096
  */
2093
2097
  static deserialize(t) {
2094
2098
  if (!(t && t.title)) return;
2095
- const e = M.deserialize(t.title), i = t["@type"], r = F(t.conformsTo), n = t.identifier, a = Z.deserialize(t.altIdentifier), o = M.deserialize(t.subtitle), h = M.deserialize(t.sortAs), m = N.deserialize(t.artist), p = N.deserialize(t.author), u = N.deserialize(t.colorist), g = N.deserialize(t.contributor), v = N.deserialize(t.editor), C = N.deserialize(t.illustrator), d = N.deserialize(t.inker), I = N.deserialize(t.letterer), B = N.deserialize(t.narrator), Me = N.deserialize(t.penciler), Be = N.deserialize(t.translator), Ge = F(t.language), We = t.description, He = N.deserialize(t.publisher), Fe = N.deserialize(t.imprint), _e = ct(t.published), Ve = ct(t.modified), Ye = Vt.deserialize(t.subject), $e = q.deserialize(t.belongsTo), Xe = _.deserialize(t.accessibility), Ke = t.layout, Ze = t.readingProgression, Je = L(t.duration), qe = L(t.numberOfPages), Qe = Yt.deserialize(t.tdm);
2099
+ const e = M.deserialize(t.title), i = t["@type"], r = F(t.conformsTo), n = t.identifier, a = Z.deserialize(t.altIdentifier), o = M.deserialize(t.subtitle), h = M.deserialize(t.sortAs), m = N.deserialize(t.artist), p = N.deserialize(t.author), u = N.deserialize(t.colorist), g = N.deserialize(t.contributor), A = N.deserialize(t.editor), C = N.deserialize(t.illustrator), d = N.deserialize(t.inker), I = N.deserialize(t.letterer), B = N.deserialize(t.narrator), Me = N.deserialize(t.penciler), Be = N.deserialize(t.translator), Ge = F(t.language), We = t.description, He = N.deserialize(t.publisher), Fe = N.deserialize(t.imprint), Ve = ct(t.published), _e = ct(t.modified), Ye = _t.deserialize(t.subject), $e = q.deserialize(t.belongsTo), Xe = V.deserialize(t.accessibility), Ke = t.layout, Ze = t.readingProgression, Je = L(t.duration), qe = L(t.numberOfPages), Qe = Yt.deserialize(t.tdm);
2096
2100
  let at = Object.assign({}, t);
2097
2101
  return tt.mappedProperties.forEach((je) => delete at[je]), Object.keys(at).length === 0 && (at = void 0), new tt({
2098
2102
  title: e,
@@ -2106,7 +2110,7 @@ const tt = class tt {
2106
2110
  authors: p,
2107
2111
  colorists: u,
2108
2112
  contributors: g,
2109
- editors: v,
2113
+ editors: A,
2110
2114
  illustrators: C,
2111
2115
  inkers: d,
2112
2116
  letterers: I,
@@ -2117,8 +2121,8 @@ const tt = class tt {
2117
2121
  description: We,
2118
2122
  publishers: He,
2119
2123
  imprints: Fe,
2120
- published: _e,
2121
- modified: Ve,
2124
+ published: Ve,
2125
+ modified: _e,
2122
2126
  subjects: Ye,
2123
2127
  belongsTo: $e,
2124
2128
  layout: Ke,
@@ -2230,7 +2234,7 @@ let ft = tt;
2230
2234
  ft.prototype.getMediaOverlay = function() {
2231
2235
  const s = this.otherMetadata?.mediaOverlay;
2232
2236
  if (s)
2233
- return _t.deserialize(s);
2237
+ return Vt.deserialize(s);
2234
2238
  };
2235
2239
  D.prototype.getContains = function() {
2236
2240
  return new Set(this.otherProperties.contains || []);
@@ -2500,10 +2504,10 @@ function Lt(s, t) {
2500
2504
  function bi(s) {
2501
2505
  return s.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+))?$/);
2502
2506
  }
2503
- function Ai(s) {
2507
+ function vi(s) {
2504
2508
  return s.match(/[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/);
2505
2509
  }
2506
- function vi(s) {
2510
+ function Ai(s) {
2507
2511
  var t = 0;
2508
2512
  if ((t = s.indexOf(".")) > -1 || (t = s.indexOf("!")) > -1 || (t = s.indexOf("?")) > -1) {
2509
2513
  var e = s.charAt(t + 1);
@@ -2543,8 +2547,8 @@ function wi(s, t) {
2543
2547
  }
2544
2548
  return p;
2545
2549
  }
2546
- let v;
2547
- return (v = i.indexOf(".")) > -1 && (Lt(i, v) || re(i) || Ai(i) || bi(i)) ? u : (m = vi(i)) ? [
2550
+ let A;
2551
+ return (A = i.indexOf(".")) > -1 && (Lt(i, A) || re(i) || vi(i) || bi(i)) ? u : (m = Ai(i)) ? [
2548
2552
  m[0] + m[1],
2549
2553
  null,
2550
2554
  m[2]
@@ -2635,7 +2639,7 @@ z.prototype.split = function(t, e = {}) {
2635
2639
  }] : Array.isArray(r) || (r = [r]), o = Q.tokensId(r, e.cache()), o && (h = i.opts.cacheGet(o), h))
2636
2640
  return h;
2637
2641
  var m = r.map(function(p, u) {
2638
- var g = r[u + 1], v = t(
2642
+ var g = r[u + 1], A = t(
2639
2643
  p.value,
2640
2644
  Object.assign({}, p),
2641
2645
  a ? Object.assign({}, a) : null,
@@ -2643,13 +2647,13 @@ z.prototype.split = function(t, e = {}) {
2643
2647
  u,
2644
2648
  r
2645
2649
  ) || [];
2646
- if (v = Q.normalize(p, v), e.preserveProperties) {
2650
+ if (A = Q.normalize(p, A), e.preserveProperties) {
2647
2651
  var C = Q.properties(p);
2648
- v = v.map(function(d) {
2652
+ A = A.map(function(d) {
2649
2653
  return Object.assign({}, d, C);
2650
2654
  });
2651
2655
  }
2652
- return a = p, v;
2656
+ return a = p, A;
2653
2657
  }).filter(Boolean).flat();
2654
2658
  return o && i.opts.cacheSet(o, m), m;
2655
2659
  };
@@ -2659,11 +2663,11 @@ z.prototype.re = function(t, e = {}) {
2659
2663
  for (var n = i, a = [], o, h = 0; o = t.exec(i); ) {
2660
2664
  var m = o.index, p = h + m, u = o[0] || "", g = u.length;
2661
2665
  if (e.split && h < p) {
2662
- var v = n.slice(h, p);
2666
+ var A = n.slice(h, p);
2663
2667
  a.push({
2664
- value: v,
2668
+ value: A,
2665
2669
  index: h,
2666
- offset: v.length
2670
+ offset: A.length
2667
2671
  });
2668
2672
  }
2669
2673
  a.push({
@@ -2806,7 +2810,7 @@ const ki = new RegExp("[\\p{L}\\p{N}]+", "u"), fe = (s) => {
2806
2810
  const t = s.trimEnd();
2807
2811
  return t.length === 0 || t.match(ki) === null ? null : t;
2808
2812
  };
2809
- class V {
2813
+ class _ {
2810
2814
  constructor(t) {
2811
2815
  this.fetcher = new ti(), 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.toc = t.manifest.toc, this.subcollections = t.manifest.subcollections;
2812
2816
  }
@@ -2838,6 +2842,28 @@ class V {
2838
2842
  linkWithRel(t) {
2839
2843
  return this.manifest.linkWithRel(t);
2840
2844
  }
2845
+ /**
2846
+ * Gets the cover image for the publication.
2847
+ * First looks for rel='cover' in links/resources/readingOrder,
2848
+ * then falls back to any image (JPEG, PNG, GIF, AVIF, SVG) as bitmap fallback.
2849
+ */
2850
+ getCover() {
2851
+ const t = [
2852
+ this.links,
2853
+ this.resources,
2854
+ this.readingOrder
2855
+ ].filter(Boolean);
2856
+ for (const e of t) {
2857
+ const i = e.items.find((r) => r.rels?.has("cover"));
2858
+ if (i) return i;
2859
+ }
2860
+ for (const e of t) {
2861
+ const i = e.items.find(
2862
+ (r) => r.mediaType.isBitmap || r.mediaType.matches(c.SVG)
2863
+ );
2864
+ if (i) return i;
2865
+ }
2866
+ }
2841
2867
  async positionsFromManifest() {
2842
2868
  const t = this.manifest.links.findWithMediaType(
2843
2869
  "application/vnd.readium.position-list+json"
@@ -2877,22 +2903,22 @@ class V {
2877
2903
  return this.fetcher.get(t);
2878
2904
  }
2879
2905
  }
2880
- V.prototype.getPageList = function() {
2906
+ _.prototype.getPageList = function() {
2881
2907
  return this.linksWithRole("pageList");
2882
2908
  };
2883
- V.prototype.getLandmarks = function() {
2909
+ _.prototype.getLandmarks = function() {
2884
2910
  return this.linksWithRole("landmarks");
2885
2911
  };
2886
- V.prototype.getListOfAudioClips = function() {
2912
+ _.prototype.getListOfAudioClips = function() {
2887
2913
  return this.linksWithRole("loa");
2888
2914
  };
2889
- V.prototype.getListOfIllustrations = function() {
2915
+ _.prototype.getListOfIllustrations = function() {
2890
2916
  return this.linksWithRole("loi");
2891
2917
  };
2892
- V.prototype.getListOfTables = function() {
2918
+ _.prototype.getListOfTables = function() {
2893
2919
  return this.linksWithRole("lot");
2894
2920
  };
2895
- V.prototype.getListOfVideoClips = function() {
2921
+ _.prototype.getListOfVideoClips = function() {
2896
2922
  return this.linksWithRole("lov");
2897
2923
  };
2898
2924
  class mt {
@@ -2995,10 +3021,6 @@ T.prototype.space = function() {
2995
3021
  if (t.length === 4 && !t.some(isNaN))
2996
3022
  return t;
2997
3023
  };
2998
- T.prototype.text = function() {
2999
- const s = this.fragmentParameters();
3000
- console.log(s);
3001
- };
3002
3024
  class Kt {
3003
3025
  /** Creates a [Price]. */
3004
3026
  constructor(t) {
@@ -3144,7 +3166,7 @@ D.prototype.getAvailability = function() {
3144
3166
  D.prototype.getAuthenticate = function() {
3145
3167
  return U.deserialize(this.otherProperties.authenticate);
3146
3168
  };
3147
- V.prototype.getImages = function() {
3169
+ _.prototype.getImages = function() {
3148
3170
  return this.linksWithRole("images");
3149
3171
  };
3150
3172
  class nr {
@@ -3206,7 +3228,7 @@ class me extends pe {
3206
3228
  super(e), this.locator = t;
3207
3229
  }
3208
3230
  }
3209
- class vt extends me {
3231
+ class At extends me {
3210
3232
  /**
3211
3233
  * Human-readable text representation for this element.
3212
3234
  */
@@ -3214,17 +3236,17 @@ class vt extends me {
3214
3236
  return this.accessibilityLabel;
3215
3237
  }
3216
3238
  }
3217
- class Ui extends vt {
3239
+ class Ui extends At {
3218
3240
  constructor(t, e, i = []) {
3219
3241
  super(t, i), this.embeddedLink = e;
3220
3242
  }
3221
3243
  }
3222
- class Mi extends vt {
3244
+ class Mi extends At {
3223
3245
  constructor(t, e, i = []) {
3224
3246
  super(t, i), this.embeddedLink = e;
3225
3247
  }
3226
3248
  }
3227
- class Bi extends vt {
3249
+ class Bi extends At {
3228
3250
  constructor(t, e, i, r = []) {
3229
3251
  super(t, r), this.embeddedLink = e, this.caption = i;
3230
3252
  }
@@ -3237,7 +3259,7 @@ class ge extends pe {
3237
3259
  super(i), this.locator = t, this.text = e;
3238
3260
  }
3239
3261
  }
3240
- class zt extends vt {
3262
+ class zt extends At {
3241
3263
  constructor(t, e, i, r = []) {
3242
3264
  super(t, r), this.role = e, this.segments = i;
3243
3265
  }
@@ -3324,7 +3346,7 @@ class Qt {
3324
3346
  return await this.hasPrevious() ? this.previous() : null;
3325
3347
  }
3326
3348
  }
3327
- let _i = class {
3349
+ let Vi = class {
3328
3350
  constructor(t, e) {
3329
3351
  this.element = t, this.direction = e;
3330
3352
  }
@@ -3361,7 +3383,7 @@ class cr extends Qt {
3361
3383
  const r = this.nextIteratorIn(t, e.index);
3362
3384
  return r ? (this._currentIterator = r, this.nextIn(t)) : null;
3363
3385
  }
3364
- return new _i(i, t);
3386
+ return new Vi(i, t);
3365
3387
  }
3366
3388
  /**
3367
3389
  * Returns the [Iterator] for the current [Resource] in the reading order.
@@ -3485,7 +3507,7 @@ class lr extends Qt {
3485
3507
  return this.currentProgression === 0 ? 0 : this.currentProgression < 0 || this.currentProgression >= 100 ? null : Math.floor(this.currentProgression * this.pageContentFiltered.length / 100);
3486
3508
  }
3487
3509
  }
3488
- const Vi = [
3510
+ const _i = [
3489
3511
  "OBJECT",
3490
3512
  "BASE",
3491
3513
  "FONT",
@@ -3554,7 +3576,7 @@ const Vi = [
3554
3576
  "RB"
3555
3577
  ];
3556
3578
  function ce(s) {
3557
- return Vi.includes(s.nodeName.toUpperCase());
3579
+ return _i.includes(s.nodeName.toUpperCase());
3558
3580
  }
3559
3581
  function St(s, t) {
3560
3582
  const e = s.getAttribute("src");
@@ -3565,13 +3587,13 @@ function St(s, t) {
3565
3587
  return e;
3566
3588
  }
3567
3589
  }
3568
- const it = "[\\s\\u0085\\u00A0\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]", Yi = new RegExp(`^${it}+$`, "g"), $i = new RegExp(`^${it}+|${it}+$/g`, "g"), be = new RegExp(`^${it}+`, "g"), Ae = new RegExp(`${it}+$`, "g"), ot = (s) => (
3590
+ const it = "[\\s\\u0085\\u00A0\\u2000-\\u200A\\u2028\\u2029\\u202F\\u205F\\u3000]", Yi = new RegExp(`^${it}+$`, "g"), $i = new RegExp(`^${it}+|${it}+$/g`, "g"), be = new RegExp(`^${it}+`, "g"), ve = new RegExp(`${it}+$`, "g"), ot = (s) => (
3569
3591
  // 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
3570
3592
  s?.length ? Yi.test(s) : !0
3571
- ), ve = (s) => s.replace($i, ""), Xi = (s) => s.replace(be, ""), Ki = (s) => s.replace(Ae, ""), le = (s, t = "") => new rt({
3593
+ ), Ae = (s) => s.replace($i, ""), Xi = (s) => s.replace(be, ""), Ki = (s) => s.replace(ve, ""), le = (s, t = "") => new rt({
3572
3594
  before: t + (be.exec(s)?.[0] ?? ""),
3573
- highlight: ve(s),
3574
- after: Ae.exec(s)?.[0] ?? ""
3595
+ highlight: Ae(s),
3596
+ after: ve.exec(s)?.[0] ?? ""
3575
3597
  });
3576
3598
  function Zi(s) {
3577
3599
  for (; s; ) {
@@ -3828,7 +3850,7 @@ function Ce(s) {
3828
3850
  }
3829
3851
  return [];
3830
3852
  }
3831
- function As(s) {
3853
+ function vs(s) {
3832
3854
  return nt(s.map(Ce));
3833
3855
  }
3834
3856
  function* Pe(s = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
@@ -3836,7 +3858,7 @@ function* Pe(s = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
3836
3858
  for (; i.length <= s.length && e < t; )
3837
3859
  e += 1, yield i.map((n) => s[n]), i = ys(i, s.length - 1);
3838
3860
  }
3839
- function vs(s = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
3861
+ function As(s = [], { maxResults: t = Number.POSITIVE_INFINITY } = {}) {
3840
3862
  return Array.from(Pe(s, { maxResults: t }));
3841
3863
  }
3842
3864
  function ys(s = [], t = 0) {
@@ -3893,7 +3915,7 @@ const Is = {
3893
3915
  class: ms,
3894
3916
  attribute: ps,
3895
3917
  nthchild: bs,
3896
- nthoftype: As
3918
+ nthoftype: vs
3897
3919
  }, xs = {
3898
3920
  tag: ze,
3899
3921
  id: Le,
@@ -3925,8 +3947,8 @@ function* Rs(s, t) {
3925
3947
  }
3926
3948
  function Cs(s, t) {
3927
3949
  const { blacklist: e, whitelist: i, combineWithinSelector: r, maxCombinations: n } = t, a = Rt(e), o = Rt(i), h = (m, p) => {
3928
- const u = Ls(s, p), g = Os(u, a, o), v = zs(g, o);
3929
- return m[p] = r ? Array.from(Pe(v, { maxResults: n })) : v.map((C) => [C]), m;
3950
+ const u = Ls(s, p), g = Os(u, a, o), A = zs(g, o);
3951
+ return m[p] = r ? Array.from(Pe(A, { maxResults: n })) : A.map((C) => [C]), m;
3930
3952
  };
3931
3953
  return Ps(t).reduce(h, {});
3932
3954
  }
@@ -3938,7 +3960,7 @@ function ks(s) {
3938
3960
  return s.includes(E.tag) || s.includes(E.nthoftype) ? [...s] : [...s, E.tag];
3939
3961
  }
3940
3962
  function Ds(s) {
3941
- const { selectors: t, combineBetweenSelectors: e, includeTag: i, maxCandidates: r } = s, n = e ? vs(t, { maxResults: r }) : t.map((a) => [a]);
3963
+ const { selectors: t, combineBetweenSelectors: e, includeTag: i, maxCandidates: r } = s, n = e ? As(t, { maxResults: r }) : t.map((a) => [a]);
3942
3964
  return i ? n.map(ks) : n;
3943
3965
  }
3944
3966
  function* Us(s, t) {
@@ -3979,7 +4001,7 @@ function* Fs(s, t, e = "", i) {
3979
4001
  for (const n of Hs(r, e))
3980
4002
  jt(s, n, t) && (yield n);
3981
4003
  }
3982
- function* _s(s, t, e = "", i) {
4004
+ function* Vs(s, t, e = "", i) {
3983
4005
  if (s.length === 0)
3984
4006
  return null;
3985
4007
  const r = [
@@ -3993,11 +4015,11 @@ function* _s(s, t, e = "", i) {
3993
4015
  selector: a
3994
4016
  };
3995
4017
  }
3996
- function* Vs({ elements: s, root: t, rootSelector: e = "", options: i }) {
4018
+ function* _s({ elements: s, root: t, rootSelector: e = "", options: i }) {
3997
4019
  let r = t, n = e, a = !0;
3998
4020
  for (; a; ) {
3999
4021
  let o = !1;
4000
- for (const h of _s(s, r, n, i)) {
4022
+ for (const h of Vs(s, r, n, i)) {
4001
4023
  const { foundElements: m, selector: p } = h;
4002
4024
  if (o = !0, jt(s, p, t))
4003
4025
  yield p;
@@ -4065,7 +4087,7 @@ function* qs(s, t = {}) {
4065
4087
  var e;
4066
4088
  const i = Ys(s), r = ss(i[0], t), n = (e = r.root) !== null && e !== void 0 ? e : te(i[0]);
4067
4089
  let a = 0;
4068
- for (const o of Vs({
4090
+ for (const o of _s({
4069
4091
  elements: i,
4070
4092
  options: r,
4071
4093
  root: n,
@@ -4348,7 +4370,7 @@ class js {
4348
4370
  }
4349
4371
  flushSegment() {
4350
4372
  let t = this.textAcc;
4351
- const e = ve(t);
4373
+ const e = Ae(t);
4352
4374
  if (!ot(e)) {
4353
4375
  if (!this.segmentRecipesAcc.length) {
4354
4376
  t = Xi(t);
@@ -4368,7 +4390,7 @@ class js {
4368
4390
  this.rawTextAcc.length && (this.wholeRawTextAcc = (this.wholeRawTextAcc || "") + this.rawTextAcc, this.elementRawTextAcc += this.rawTextAcc), this.rawTextAcc = "", this.textAcc = "";
4369
4391
  }
4370
4392
  }
4371
- class At {
4393
+ class vt {
4372
4394
  /**
4373
4395
  * Creates a [LocatorMetadata].
4374
4396
  */
@@ -4383,7 +4405,7 @@ class At {
4383
4405
  const e = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(["title", "numberOfItems"]);
4384
4406
  return Object.entries(t).forEach(([r, n]) => {
4385
4407
  i.has(r) || e.set(r, n);
4386
- }), new At({
4408
+ }), new vt({
4387
4409
  title: M.deserialize(t.title),
4388
4410
  numberOfItems: K(t.numberOfItems),
4389
4411
  otherMetadata: e.size === 0 ? void 0 : e
@@ -4402,7 +4424,7 @@ class De {
4402
4424
  * Creates a [LocatorCollection].
4403
4425
  */
4404
4426
  constructor(t) {
4405
- this.metadata = t.metadata ?? new At({}), this.links = t.links ?? new O([]), this.locators = t.locators ?? [];
4427
+ this.metadata = t.metadata ?? new vt({}), this.links = t.links ?? new O([]), this.locators = t.locators ?? [];
4406
4428
  }
4407
4429
  /**
4408
4430
  * Parses a [LocatorCollection] from its RWPM JSON representation.
@@ -4411,7 +4433,7 @@ class De {
4411
4433
  if (!t) return;
4412
4434
  let e, i = t.locators;
4413
4435
  return i && Array.isArray(i) && (e = i.map((r) => k.deserialize(r)).filter((r) => r !== void 0)), new De({
4414
- metadata: At.deserialize(t.metadata),
4436
+ metadata: vt.deserialize(t.metadata),
4415
4437
  links: O.deserialize(t.links),
4416
4438
  locators: e
4417
4439
  });
@@ -4626,7 +4648,7 @@ class Ue {
4626
4648
  }
4627
4649
  export {
4628
4650
  R as AccessMode,
4629
- _ as Accessibility,
4651
+ V as Accessibility,
4630
4652
  sr as AccessibilityMetadataDisplayGuide,
4631
4653
  Tt as AccessibilityProfile,
4632
4654
  Ht as AccessibilitySummary,
@@ -4654,7 +4676,7 @@ export {
4654
4676
  ti as EmptyFetcher,
4655
4677
  Ft as Encryption,
4656
4678
  xt as Exemption,
4657
- A as Feature,
4679
+ v as Feature,
4658
4680
  Hi as Footnote,
4659
4681
  $t as GuidedNavigationDocument,
4660
4682
  X as GuidedNavigationObject,
@@ -4679,11 +4701,11 @@ export {
4679
4701
  M as LocalizedString,
4680
4702
  k as Locator,
4681
4703
  De as LocatorCollection,
4682
- At as LocatorCollectionMetadata,
4704
+ vt as LocatorCollectionMetadata,
4683
4705
  T as LocatorLocations,
4684
4706
  rt as LocatorText,
4685
4707
  Ue as Manifest,
4686
- _t as MediaOverlay,
4708
+ Vt as MediaOverlay,
4687
4709
  c as MediaType,
4688
4710
  ft as Metadata,
4689
4711
  Pi as NaiveTextTokenizer,
@@ -4698,7 +4720,7 @@ export {
4698
4720
  It as PrimaryAccessMode,
4699
4721
  J as Profile,
4700
4722
  D as Properties,
4701
- V as Publication,
4723
+ _ as Publication,
4702
4724
  W as PublicationCollection,
4703
4725
  cr as PublicationContentIterator,
4704
4726
  H as ReadingProgression,
@@ -4706,7 +4728,7 @@ export {
4706
4728
  Ut as RichContent,
4707
4729
  oi as RichContentType,
4708
4730
  dt as Subject,
4709
- Vt as Subjects,
4731
+ _t as Subjects,
4710
4732
  Yt as TDM,
4711
4733
  hi as TDMReservation,
4712
4734
  ar as TextContentTokenizer,
@@ -4714,7 +4736,7 @@ export {
4714
4736
  Fi as TextQuote,
4715
4737
  ge as TextSegment,
4716
4738
  zi as TextUnit,
4717
- vt as TextualElement,
4739
+ At as TextualElement,
4718
4740
  ht as URITemplate,
4719
4741
  Mi as VideoElement,
4720
4742
  ri as VisualAdjustments,