@readium/navigator 2.4.0-beta.6 → 2.4.0-beta.7

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
@@ -56,15 +56,15 @@ const C = class C {
56
56
  };
57
57
  C.AUDITORY = new C("auditory"), C.CHART_ON_VISUAL = new C("chartOnVisual"), C.CHEM_ON_VISUAL = new C("chemOnVisual"), C.COLOR_DEPENDENT = new C("colorDependent"), C.DIAGRAM_ON_VISUAL = new C("diagramOnVisual"), C.MATH_ON_VISUAL = new C("mathOnVisual"), C.MUSIC_ON_VISUAL = new C("musicOnVisual"), C.TACTILE = new C("tactile"), C.TEXT_ON_VISUAL = new C("textOnVisual"), C.TEXTUAL = new C("textual"), C.VISUAL = new C("visual");
58
58
  let $e = C;
59
- const N = class N {
59
+ const F = class F {
60
60
  constructor(t) {
61
61
  if (typeof t == "string") {
62
- if (!N.VALID_MODES.has(t.toLowerCase()))
62
+ if (!F.VALID_MODES.has(t.toLowerCase()))
63
63
  return;
64
64
  this.value = t.toLowerCase();
65
65
  } else {
66
66
  const e = t.filter(
67
- (i) => N.VALID_MODES.has(i.toLowerCase())
67
+ (i) => F.VALID_MODES.has(i.toLowerCase())
68
68
  );
69
69
  if (e.length === 0)
70
70
  return;
@@ -77,11 +77,11 @@ const N = class N {
77
77
  static deserialize(t) {
78
78
  if (!t) return;
79
79
  if (typeof t == "string")
80
- return new N(t);
80
+ return new F(t);
81
81
  if (!Array.isArray(t)) return;
82
- const e = t.filter((i) => i ? N.VALID_MODES.has(i.toLowerCase()) : !1);
82
+ const e = t.filter((i) => i ? F.VALID_MODES.has(i.toLowerCase()) : !1);
83
83
  if (e.length !== 0)
84
- return new N(e);
84
+ return new F(e);
85
85
  }
86
86
  /**
87
87
  * Serializes a [PrimaryAccessMode] to its RWPM JSON representation.
@@ -90,8 +90,8 @@ const N = class N {
90
90
  return this.value;
91
91
  }
92
92
  };
93
- N.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), N.AUDITORY = new N("auditory"), N.TACTILE = new N("tactile"), N.TEXTUAL = new N("textual"), N.VISUAL = new N("visual");
94
- let Xe = N;
93
+ F.VALID_MODES = /* @__PURE__ */ new Set(["auditory", "tactile", "textual", "visual"]), F.AUDITORY = new F("auditory"), F.TACTILE = new F("tactile"), F.TEXTUAL = new F("textual"), F.VISUAL = new F("visual");
94
+ let Xe = F;
95
95
  const f = class f {
96
96
  constructor(t) {
97
97
  this.value = t;
@@ -877,7 +877,7 @@ class at {
877
877
  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;
878
878
  }
879
879
  }
880
- class F {
880
+ class N {
881
881
  /**
882
882
  * Creates a [Locator].
883
883
  */
@@ -889,7 +889,7 @@ class F {
889
889
  */
890
890
  static deserialize(t) {
891
891
  if (t && t.href && t.type)
892
- return new F({
892
+ return new N({
893
893
  href: t.href,
894
894
  type: t.type,
895
895
  title: t.title,
@@ -908,7 +908,7 @@ class F {
908
908
  * Shortcut to get a copy of the [Locator] with different [Locations] sub-properties.
909
909
  */
910
910
  copyWithLocations(t) {
911
- return new F({
911
+ return new N({
912
912
  href: this.href,
913
913
  type: this.type,
914
914
  title: this.title,
@@ -991,7 +991,7 @@ class j {
991
991
  */
992
992
  get locator() {
993
993
  let t = this.href.split("#");
994
- return new F({
994
+ return new N({
995
995
  href: t.length > 0 && t[0] !== void 0 ? t[0] : this.href,
996
996
  type: this.type ?? "",
997
997
  title: this.title,
@@ -1632,7 +1632,7 @@ function oi(s, t) {
1632
1632
  return { node: r, offset: o };
1633
1633
  throw new RangeError("No text nodes with non-whitespace text found in range");
1634
1634
  }
1635
- function Fn(s) {
1635
+ function Nn(s) {
1636
1636
  if (!s.toString().trim().length)
1637
1637
  throw new RangeError("Range contains no non-whitespace text");
1638
1638
  if (s.startContainer.nodeType !== Node.TEXT_NODE)
@@ -1868,7 +1868,7 @@ class tt {
1868
1868
  * whitespace
1869
1869
  */
1870
1870
  static trimmedRange(t) {
1871
- return Fn(tt.fromRange(t).toRange());
1871
+ return Nn(tt.fromRange(t).toRange());
1872
1872
  }
1873
1873
  }
1874
1874
  class Wt {
@@ -1941,7 +1941,7 @@ class Ht {
1941
1941
  return new Wt(this.root, i.start, i.end);
1942
1942
  }
1943
1943
  }
1944
- function Nn(s) {
1944
+ function Fn(s) {
1945
1945
  const t = s.tagName.toUpperCase();
1946
1946
  return t === "IMG" || t === "VIDEO" || t === "AUDIO" || t === "IFRAME" || t === "OBJECT" || t === "EMBED" || t === "CANVAS";
1947
1947
  }
@@ -1970,7 +1970,7 @@ function ie(s, t) {
1970
1970
  }
1971
1971
  if (n) {
1972
1972
  const r = s.createRange();
1973
- return n.childNodes.length === 0 || Nn(n) ? (r.selectNode(n), r) : (r.setStartBefore(n), r.setEndAfter(n), r);
1973
+ return n.childNodes.length === 0 || Fn(n) ? (r.selectNode(n), r) : (r.setStartBefore(n), r.setEndAfter(n), r);
1974
1974
  }
1975
1975
  }
1976
1976
  } catch (e) {
@@ -2141,14 +2141,14 @@ function Xi(s, t, e) {
2141
2141
  function V(s, t, e) {
2142
2142
  return Math.abs(s - t) <= e;
2143
2143
  }
2144
- function Fe(s) {
2144
+ function Ne(s) {
2145
2145
  const t = {}, e = s.document.documentElement.style;
2146
2146
  for (const i in s.document.documentElement.style)
2147
2147
  Object.hasOwn(e, i) && !Number.isNaN(Number.parseInt(i)) && (t[e[i]] = e.getPropertyValue(e[i]));
2148
2148
  return t;
2149
2149
  }
2150
2150
  function Yi(s, t) {
2151
- const e = Fe(s);
2151
+ const e = Ne(s);
2152
2152
  Object.keys(e).forEach((i) => {
2153
2153
  t.hasOwnProperty(i) || ne(s, i);
2154
2154
  }), Object.entries(t).forEach(([i, n]) => {
@@ -2430,7 +2430,7 @@ const Pt = class Pt extends bt {
2430
2430
  mount(t, e) {
2431
2431
  return this.wnd = t, e.register("decorate", Pt.moduleName, (i, n) => {
2432
2432
  const r = i;
2433
- r.decoration && r.decoration.locator && (r.decoration.locator = F.deserialize(r.decoration.locator)), this.groups.has(r.group) || this.groups.set(r.group, new $n(
2433
+ r.decoration && r.decoration.locator && (r.decoration.locator = N.deserialize(r.decoration.locator)), this.groups.has(r.group) || this.groups.set(r.group, new $n(
2434
2434
  t,
2435
2435
  e,
2436
2436
  `readium-decoration-${this.lastGroupId++}`,
@@ -2555,11 +2555,11 @@ const Yn = [
2555
2555
  function Zi(s) {
2556
2556
  return Yn.indexOf(s.nodeName.toLowerCase()) !== -1 || s.hasAttribute("contenteditable") && s.getAttribute("contenteditable")?.toLowerCase() !== "false" ? s : s.parentElement ? Zi(s.parentElement) : null;
2557
2557
  }
2558
- function Ne(s, t) {
2558
+ function Fe(s, t) {
2559
2559
  const e = Ji(s, s.document.body, t), i = s._readium_cssSelectorGenerator.getCssSelector(e, {
2560
2560
  selectors: ["tag", "id", "class", "nthchild", "nthoftype", "attribute"]
2561
2561
  });
2562
- return new F({
2562
+ return new N({
2563
2563
  href: "#",
2564
2564
  type: "application/xhtml+xml",
2565
2565
  locations: new E({
@@ -2870,7 +2870,7 @@ const fi = "readium-column-snapper-style", tr = 200, U = class U extends Rt {
2870
2870
  }), e.register("go_text", U.moduleName, (r, o) => {
2871
2871
  let a;
2872
2872
  Array.isArray(r) && (r.length > 1 && (a = r[1]), r = r[0]);
2873
- const l = at.deserialize(r), h = ie(this.wnd.document, new F({
2873
+ const l = at.deserialize(r), h = ie(this.wnd.document, new N({
2874
2874
  href: t.location.href,
2875
2875
  type: "text/html",
2876
2876
  text: l,
@@ -2921,7 +2921,7 @@ const fi = "readium-column-snapper-style", tr = 200, U = class U extends Rt {
2921
2921
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2922
2922
  });
2923
2923
  }), e.register("first_visible_locator", U.moduleName, (r, o) => {
2924
- const a = Ne(t, !1);
2924
+ const a = Fe(t, !1);
2925
2925
  this.comms.send("first_visible_locator", a.serialize()), o(!0);
2926
2926
  }), t.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), t.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), t.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), t.document.addEventListener("touchstart", () => {
2927
2927
  }), e.log("ColumnSnapper Mounted"), !0;
@@ -3022,7 +3022,7 @@ const yi = "readium-scroll-snapper-style", W = class W extends Rt {
3022
3022
  }), e.register("go_text", W.moduleName, (n, r) => {
3023
3023
  let o;
3024
3024
  Array.isArray(n) && (n.length > 1 && (o = n[1]), n = n[0]);
3025
- const a = at.deserialize(n), l = ie(this.wnd.document, new F({
3025
+ const a = at.deserialize(n), l = ie(this.wnd.document, new N({
3026
3026
  href: t.location.href,
3027
3027
  type: "text/html",
3028
3028
  text: a,
@@ -3055,7 +3055,7 @@ const yi = "readium-scroll-snapper-style", W = class W extends Rt {
3055
3055
  ], W.moduleName, (n, r) => r(!1)), e.register("focus", W.moduleName, (n, r) => {
3056
3056
  this.reportProgress(), r(!0);
3057
3057
  }), e.register("first_visible_locator", W.moduleName, (n, r) => {
3058
- const o = Ne(t, !0);
3058
+ const o = Fe(t, !0);
3059
3059
  this.comms.send("first_visible_locator", o.serialize()), r(!0);
3060
3060
  }), e.log("ScrollSnapper Mounted"), !0;
3061
3061
  }
@@ -3145,7 +3145,7 @@ const H = class H extends Rt {
3145
3145
  }), e.register("go_text", H.moduleName, (i, n) => {
3146
3146
  let r;
3147
3147
  Array.isArray(i) && (i.length > 1 && (r = i[1]), i = i[0]);
3148
- const o = at.deserialize(i), a = ie(this.wnd.document, new F({
3148
+ const o = at.deserialize(i), a = ie(this.wnd.document, new N({
3149
3149
  href: t.location.href,
3150
3150
  type: "text/html",
3151
3151
  text: o,
@@ -3178,7 +3178,7 @@ const H = class H extends Rt {
3178
3178
  ], H.moduleName, (i, n) => n(!1)), e.register("focus", H.moduleName, (i, n) => {
3179
3179
  this.reportProgress(), n(!0);
3180
3180
  }), e.register("first_visible_locator", H.moduleName, (i, n) => {
3181
- const r = Ne(t, !0);
3181
+ const r = Fe(t, !0);
3182
3182
  e.send("first_visible_locator", r.serialize()), n(!0);
3183
3183
  }), e.log("WebPubSnapper Mounted"), !0;
3184
3184
  }
@@ -3622,7 +3622,7 @@ const Ct = class Ct extends bt {
3622
3622
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3623
3623
  value: {
3624
3624
  name: "readium-ts-toolkit",
3625
- version: "2.4.0-beta.6",
3625
+ version: "2.4.0-beta.7",
3626
3626
  hasFeature: (n, r = "") => {
3627
3627
  switch (n) {
3628
3628
  case "dom-manipulation":
@@ -3685,7 +3685,7 @@ const Si = "readium-viewport", K = class K extends Bt {
3685
3685
  ), t.document.head.appendChild(i), t.addEventListener("orientationchange", this.onViewportWidthChanged), t.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
3686
3686
  target: t
3687
3687
  }), e.register("get_properties", K.moduleName, (n, r) => {
3688
- Fe(t), r(!0);
3688
+ Ne(t), r(!0);
3689
3689
  }), e.register("update_properties", K.moduleName, (n, r) => {
3690
3690
  n["--RS__viewportWidth"] = `${t.innerWidth}px`, Yi(t, n), r(!0);
3691
3691
  }), e.register("set_property", K.moduleName, (n, r) => {
@@ -3761,7 +3761,7 @@ const Z = class Z extends bt {
3761
3761
  this.wndOnErr,
3762
3762
  !1
3763
3763
  ), e.register("get_properties", Z.moduleName, (i, n) => {
3764
- Fe(t), n(!0);
3764
+ Ne(t), n(!0);
3765
3765
  }), e.register("update_properties", Z.moduleName, (i, n) => {
3766
3766
  Yi(t, i), n(!0);
3767
3767
  }), e.register("set_property", Z.moduleName, (i, n) => {
@@ -5311,7 +5311,7 @@ class pn {
5311
5311
  }
5312
5312
  }
5313
5313
  }
5314
- const yt = (s) => s.replace(/\/\/.*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n/g, "").replace(/\s+/g, " "), Ft = (s) => s.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, "").replace(/ {2,}/g, " "), Or = `/*!
5314
+ const yt = (s) => s.replace(/\/\/.*/g, "").replace(/\/\*[\s\S]*?\*\//g, "").replace(/\n/g, "").replace(/\s+/g, " "), Nt = (s) => s.replace(/\/\*(?:(?!\*\/)[\s\S])*\*\/|[\r\n\t]+/g, "").replace(/ {2,}/g, " "), Or = `/*!
5315
5315
  * Readium CSS v.2.0.0
5316
5316
  * Copyright (c) 2017–2026. Readium Foundation. All rights reserved.
5317
5317
  * Use of this source code is governed by a BSD-style license which is detailed in the
@@ -5633,7 +5633,7 @@ function Ar(s) {
5633
5633
  id: "readium-css-webpub",
5634
5634
  as: "link",
5635
5635
  target: "head",
5636
- blob: new Blob([Ft(Or)], { type: "text/css" }),
5636
+ blob: new Blob([Nt(Or)], { type: "text/css" }),
5637
5637
  rel: "stylesheet"
5638
5638
  }
5639
5639
  ];
@@ -5678,10 +5678,10 @@ class zr {
5678
5678
  }
5679
5679
  }
5680
5680
  let Mr = 0;
5681
- function Fr() {
5681
+ function Nr() {
5682
5682
  return ++Mr;
5683
5683
  }
5684
- const Nr = `
5684
+ const Fr = `
5685
5685
  onmessage = function(event) {
5686
5686
  var action = event.data;
5687
5687
  var startTime = performance.now()
@@ -5702,7 +5702,7 @@ onmessage = function(event) {
5702
5702
  }, this.log = (...i) => this.send("log", ...i), this.table = (...i) => this.send("table", ...i), this.clear = (...i) => this.send("clear", ...i);
5703
5703
  }
5704
5704
  async send(t, ...e) {
5705
- const i = Fr();
5705
+ const i = Nr();
5706
5706
  return new Promise((n, r) => {
5707
5707
  this.callbacks.set(i, n), this.worker.postMessage({
5708
5708
  id: i,
@@ -5717,7 +5717,7 @@ onmessage = function(event) {
5717
5717
  this.worker.terminate(), URL.revokeObjectURL(this.blobUrl);
5718
5718
  }
5719
5719
  };
5720
- Ve.workerScript = Nr;
5720
+ Ve.workerScript = Fr;
5721
5721
  let ee = Ve;
5722
5722
  function De(s) {
5723
5723
  return typeof window < "u" && console ? console[s] : (...t) => {
@@ -6153,9 +6153,9 @@ class Gr extends rn {
6153
6153
  this.listeners.frameLoaded(this.framePool.currentFrames[0].iframe.contentWindow), this.listeners.positionChanged(this.currentLocation);
6154
6154
  break;
6155
6155
  case "first_visible_locator":
6156
- const i = F.deserialize(e);
6156
+ const i = N.deserialize(e);
6157
6157
  if (!i) break;
6158
- this.currentLocation = new F({
6158
+ this.currentLocation = new N({
6159
6159
  href: this.currentLocation.href,
6160
6160
  type: this.currentLocation.type,
6161
6161
  title: this.currentLocation.title,
@@ -6363,7 +6363,7 @@ class Gr extends rn {
6363
6363
  if (!e)
6364
6364
  throw new Error("No current resource available");
6365
6365
  const n = this.currentLocation && this.currentLocation.href === e.href && this.currentLocation.locations.progression ? this.currentLocation.locations.progression : 0;
6366
- return this.pub.manifest.locatorFromLink(e) || new F({
6366
+ return this.pub.manifest.locatorFromLink(e) || new N({
6367
6367
  href: e.href,
6368
6368
  type: e.type || "text/html",
6369
6369
  locations: new E({
@@ -7983,7 +7983,7 @@ class Mi {
7983
7983
  this.backgroundColor = t.backgroundColor || e.backgroundColor || null, this.blendFilter = typeof t.blendFilter == "boolean" ? t.blendFilter : e.blendFilter ?? null, this.columnCount = t.columnCount !== void 0 ? t.columnCount : e.columnCount !== void 0 ? e.columnCount : null, this.constraint = t.constraint || e.constraint, this.darkenFilter = typeof t.darkenFilter == "boolean" ? t.darkenFilter : e.darkenFilter ?? null, this.deprecatedFontSize = typeof t.deprecatedFontSize == "boolean" ? t.deprecatedFontSize : e.deprecatedFontSize ?? null, this.fontFamily = t.fontFamily || e.fontFamily || null, this.fontSize = t.fontSize !== void 0 ? t.fontSize : e.fontSize !== void 0 ? e.fontSize : null, this.fontSizeNormalize = typeof t.fontSizeNormalize == "boolean" ? t.fontSizeNormalize : e.fontSizeNormalize ?? null, this.fontOpticalSizing = typeof t.fontOpticalSizing == "boolean" ? t.fontOpticalSizing : e.fontOpticalSizing ?? null, this.fontWeight = t.fontWeight !== void 0 ? t.fontWeight : e.fontWeight !== void 0 ? e.fontWeight : null, this.fontWidth = t.fontWidth !== void 0 ? t.fontWidth : e.fontWidth !== void 0 ? e.fontWidth : null, this.hyphens = typeof t.hyphens == "boolean" ? t.hyphens : e.hyphens ?? null, this.invertFilter = typeof t.invertFilter == "boolean" ? t.invertFilter : e.invertFilter ?? null, this.invertGaijiFilter = typeof t.invertGaijiFilter == "boolean" ? t.invertGaijiFilter : e.invertGaijiFilter ?? null, this.iOSPatch = this.deprecatedFontSize || t.iOSPatch === !1 ? !1 : t.iOSPatch === !0 ? (T.OS.iOS || T.OS.iPadOS) && T.iOSRequest === "mobile" : e.iOSPatch, this.iPadOSPatch = this.deprecatedFontSize || t.iPadOSPatch === !1 ? !1 : t.iPadOSPatch === !0 ? T.OS.iPadOS && T.iOSRequest === "desktop" : e.iPadOSPatch, this.letterSpacing = t.letterSpacing !== void 0 ? t.letterSpacing : e.letterSpacing !== void 0 ? e.letterSpacing : null, this.ligatures = typeof t.ligatures == "boolean" ? t.ligatures : e.ligatures ?? null, this.lineHeight = t.lineHeight !== void 0 ? t.lineHeight : e.lineHeight !== void 0 ? e.lineHeight : null, this.linkColor = t.linkColor || e.linkColor || null, this.maximalLineLength = t.maximalLineLength === null ? null : t.maximalLineLength || e.maximalLineLength || null, this.minimalLineLength = t.minimalLineLength === null ? null : t.minimalLineLength || e.minimalLineLength || null, this.noRuby = typeof t.noRuby == "boolean" ? t.noRuby : e.noRuby ?? null, this.optimalLineLength = t.optimalLineLength || e.optimalLineLength, this.pageGutter = t.pageGutter !== void 0 ? t.pageGutter : e.pageGutter !== void 0 ? e.pageGutter : null, this.paragraphIndent = t.paragraphIndent !== void 0 ? t.paragraphIndent : e.paragraphIndent !== void 0 ? e.paragraphIndent : null, this.paragraphSpacing = t.paragraphSpacing !== void 0 ? t.paragraphSpacing : e.paragraphSpacing !== void 0 ? e.paragraphSpacing : null, this.scroll = typeof t.scroll == "boolean" ? t.scroll : e.scroll ?? null, this.scrollPaddingTop = t.scrollPaddingTop !== void 0 ? t.scrollPaddingTop : e.scrollPaddingTop !== void 0 ? e.scrollPaddingTop : null, this.scrollPaddingBottom = t.scrollPaddingBottom !== void 0 ? t.scrollPaddingBottom : e.scrollPaddingBottom !== void 0 ? e.scrollPaddingBottom : null, this.scrollPaddingLeft = t.scrollPaddingLeft !== void 0 ? t.scrollPaddingLeft : e.scrollPaddingLeft !== void 0 ? e.scrollPaddingLeft : null, this.scrollPaddingRight = t.scrollPaddingRight !== void 0 ? t.scrollPaddingRight : e.scrollPaddingRight !== void 0 ? e.scrollPaddingRight : null, this.selectionBackgroundColor = t.selectionBackgroundColor || e.selectionBackgroundColor || null, this.selectionTextColor = t.selectionTextColor || e.selectionTextColor || null, this.textAlign = t.textAlign || e.textAlign || null, this.textColor = t.textColor || e.textColor || null, this.textNormalization = typeof t.textNormalization == "boolean" ? t.textNormalization : e.textNormalization ?? null, this.visitedColor = t.visitedColor || e.visitedColor || null, this.wordSpacing = t.wordSpacing !== void 0 ? t.wordSpacing : e.wordSpacing !== void 0 ? e.wordSpacing : null, this.experiments = e.experiments || null;
7984
7984
  }
7985
7985
  }
7986
- function Nt(s) {
7986
+ function Ft(s) {
7987
7987
  const t = getComputedStyle(s), e = parseFloat(t.paddingLeft || "0"), i = parseFloat(t.paddingRight || "0");
7988
7988
  return s.clientWidth - e - i;
7989
7989
  }
@@ -8009,7 +8009,7 @@ class gs extends re {
8009
8009
  }
8010
8010
  class fs {
8011
8011
  constructor(t) {
8012
- this.rsProperties = t.rsProperties, this.userProperties = t.userProperties, this.lineLengths = t.lineLengths, this.container = t.container, this.containerParent = t.container.parentElement || document.documentElement, this.constraint = t.constraint, this.cachedColCount = t.userProperties.colCount, this.effectiveContainerWidth = Nt(this.containerParent);
8012
+ this.rsProperties = t.rsProperties, this.userProperties = t.userProperties, this.lineLengths = t.lineLengths, this.container = t.container, this.containerParent = t.container.parentElement || document.documentElement, this.constraint = t.constraint, this.cachedColCount = t.userProperties.colCount, this.effectiveContainerWidth = Ft(this.containerParent);
8013
8013
  }
8014
8014
  update(t) {
8015
8015
  this.cachedColCount = t.columnCount, t.constraint !== this.constraint && (this.constraint = t.constraint), t.pageGutter !== this.rsProperties.pageGutter && (this.rsProperties.pageGutter = t.pageGutter), t.scrollPaddingBottom !== this.rsProperties.scrollPaddingBottom && (this.rsProperties.scrollPaddingBottom = t.scrollPaddingBottom), t.scrollPaddingLeft !== this.rsProperties.scrollPaddingLeft && (this.rsProperties.scrollPaddingLeft = t.scrollPaddingLeft), t.scrollPaddingRight !== this.rsProperties.scrollPaddingRight && (this.rsProperties.scrollPaddingRight = t.scrollPaddingRight), t.scrollPaddingTop !== this.rsProperties.scrollPaddingTop && (this.rsProperties.scrollPaddingTop = t.scrollPaddingTop), t.experiments !== this.rsProperties.experiments && (this.rsProperties.experiments = t.experiments), this.lineLengths.update({
@@ -8076,7 +8076,7 @@ class fs {
8076
8076
  // TODO: As scroll shows, the effective line-length
8077
8077
  // should be the same as uncompensated when scale >= 1
8078
8078
  paginate(t, e, i) {
8079
- const n = Math.round(Nt(this.containerParent) - this.constraint), r = this.getCompensatedMetrics(t, e), { zoomCompensation: o, optimal: a, minimal: l, maximal: h } = r, c = () => n >= a && h !== null ? Math.min(Math.round(h * o), n) : n;
8079
+ const n = Math.round(Ft(this.containerParent) - this.constraint), r = this.getCompensatedMetrics(t, e), { zoomCompensation: o, optimal: a, minimal: l, maximal: h } = r, c = () => n >= a && h !== null ? Math.min(Math.round(h * o), n) : n;
8080
8080
  let u = 1, m = n;
8081
8081
  if (i === void 0)
8082
8082
  return {
@@ -8122,7 +8122,7 @@ class fs {
8122
8122
  }
8123
8123
  // This behaves as paginate where colCount = 1
8124
8124
  computeScrollLength(t, e) {
8125
- const i = Math.round(Nt(this.containerParent) - this.constraint), n = this.getCompensatedMetrics(t && (t < 1 || e) ? t : 1, e), r = n.zoomCompensation, o = n.optimal, a = n.maximal;
8125
+ const i = Math.round(Ft(this.containerParent) - this.constraint), n = this.getCompensatedMetrics(t && (t < 1 || e) ? t : 1, e), r = n.zoomCompensation, o = n.optimal, a = n.maximal;
8126
8126
  let l, h = i, c = Math.round(o * r);
8127
8127
  if (a === null)
8128
8128
  c = i;
@@ -9409,7 +9409,7 @@ function ws(s, t) {
9409
9409
  id: "readium-css-before",
9410
9410
  as: "link",
9411
9411
  target: "head",
9412
- blob: new Blob([Ft(Ss)], { type: "text/css" }),
9412
+ blob: new Blob([Nt(Ss)], { type: "text/css" }),
9413
9413
  rel: "stylesheet"
9414
9414
  }), o.unshift(
9415
9415
  // Readium CSS Default - only for reflowable AND no existing styles
@@ -9417,7 +9417,7 @@ function ws(s, t) {
9417
9417
  id: "readium-css-default",
9418
9418
  as: "link",
9419
9419
  target: "head",
9420
- blob: new Blob([Ft(bs)], { type: "text/css" }),
9420
+ blob: new Blob([Nt(bs)], { type: "text/css" }),
9421
9421
  rel: "stylesheet",
9422
9422
  condition: (a) => !(a.querySelector("link[rel='stylesheet']") || a.querySelector("style") || a.querySelector("[style]:not([style=''])"))
9423
9423
  },
@@ -9426,7 +9426,7 @@ function ws(s, t) {
9426
9426
  id: "readium-css-after",
9427
9427
  as: "link",
9428
9428
  target: "head",
9429
- blob: new Blob([Ft(ys)], { type: "text/css" }),
9429
+ blob: new Blob([Nt(ys)], { type: "text/css" }),
9430
9430
  rel: "stylesheet"
9431
9431
  }
9432
9432
  )), [
@@ -9571,7 +9571,7 @@ class Sn extends rn {
9571
9571
  async resizeHandler() {
9572
9572
  const t = this.container.parentElement || document.documentElement;
9573
9573
  if (this._layout === S.fixed)
9574
- this.container.style.width = `${Nt(t) - this._settings.constraint}px`, this.framePool.resizeHandler();
9574
+ this.container.style.width = `${Ft(t) - this._settings.constraint}px`, this.framePool.resizeHandler();
9575
9575
  else {
9576
9576
  const e = this._css.userProperties.colCount, i = this._css.userProperties.lineLength;
9577
9577
  this._css.resizeHandler(), (this._css.userProperties.view !== "scroll" && e !== this._css.userProperties.colCount || i !== this._css.userProperties.lineLength) && await this.commitCSS(this._css);
@@ -9608,9 +9608,9 @@ class Sn extends rn {
9608
9608
  this.listeners.frameLoaded(this._cframes[0].iframe.contentWindow), this.listeners.positionChanged(this.currentLocation);
9609
9609
  break;
9610
9610
  case "first_visible_locator":
9611
- const i = F.deserialize(e);
9611
+ const i = N.deserialize(e);
9612
9612
  if (!i) break;
9613
- this.currentLocation = new F({
9613
+ this.currentLocation = new N({
9614
9614
  href: this.currentLocation.href,
9615
9615
  type: this.currentLocation.type,
9616
9616
  title: this.currentLocation.title,
@@ -10103,22 +10103,6 @@ class Es {
10103
10103
  (i) => i !== e
10104
10104
  ));
10105
10105
  }
10106
- /**
10107
- * Load the audio resource at the given URL.
10108
- * @param url The URL of the audio resource.
10109
- * */
10110
- loadAudio(t) {
10111
- if (this.mediaElement.pause(), this.mediaElement.removeAttribute("src"), this.mediaElement.load(), this.isLoadingValue = !0, this.isLoadedValue = !1, this.isPlayingValue = !1, this.isPausedValue = !1, this.webAudioActive) {
10112
- this.mediaElement.crossOrigin = "anonymous", this.mediaElement.src = t, this.mediaElement.load(), this.mediaElement.playbackRate = this.currentPlaybackRate;
10113
- const e = () => {
10114
- this.mediaElement.removeEventListener("error", i), this.mediaElement.removeEventListener("canplaythrough", n);
10115
- }, i = () => {
10116
- e(), this.deactivateWebAudio(), this.mediaElement.removeAttribute("crossOrigin"), this.mediaElement.src = t, this.mediaElement.load(), this.mediaElement.playbackRate = this.currentPlaybackRate;
10117
- }, n = () => e();
10118
- this.mediaElement.addEventListener("error", i), this.mediaElement.addEventListener("canplaythrough", n);
10119
- } else
10120
- this.mediaElement.src = t, this.mediaElement.load(), this.mediaElement.playbackRate = this.currentPlaybackRate;
10121
- }
10122
10106
  deactivateWebAudio() {
10123
10107
  this.worklet && (this.worklet.destroy(), this.worklet = null), this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.gainNode && (this.gainNode.disconnect(), this.gainNode = null), this.webAudioActive = !1;
10124
10108
  }
@@ -10127,7 +10111,14 @@ class Es {
10127
10111
  * @param element The HTML audio element to use.
10128
10112
  */
10129
10113
  setMediaElement(t) {
10130
- this.mediaElement.pause(), this.isPlayingValue = !1, this.isPausedValue = !1, this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.mediaElement.removeEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.removeEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.removeEventListener("error", this.boundOnError), this.mediaElement.removeEventListener("ended", this.boundOnEnded), this.mediaElement.removeEventListener("stalled", this.boundOnStalled), this.mediaElement.removeEventListener("emptied", this.boundOnEmptied), this.mediaElement.removeEventListener("suspend", this.boundOnSuspend), this.mediaElement.removeEventListener("waiting", this.boundOnWaiting), this.mediaElement.removeEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.removeEventListener("seeking", this.boundOnSeeking), this.mediaElement.removeEventListener("seeked", this.boundOnSeeked), this.mediaElement.removeEventListener("play", this.boundOnPlay), this.mediaElement.removeEventListener("playing", this.boundOnPlaying), this.mediaElement.removeEventListener("pause", this.boundOnPause), this.mediaElement.removeEventListener("progress", this.boundOnProgress), this.mediaElement = t, this.mediaElement.addEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.addEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.addEventListener("error", this.boundOnError), this.mediaElement.addEventListener("ended", this.boundOnEnded), this.mediaElement.addEventListener("stalled", this.boundOnStalled), this.mediaElement.addEventListener("emptied", this.boundOnEmptied), this.mediaElement.addEventListener("suspend", this.boundOnSuspend), this.mediaElement.addEventListener("waiting", this.boundOnWaiting), this.mediaElement.addEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.addEventListener("seeking", this.boundOnSeeking), this.mediaElement.addEventListener("seeked", this.boundOnSeeked), this.mediaElement.addEventListener("play", this.boundOnPlay), this.mediaElement.addEventListener("playing", this.boundOnPlaying), this.mediaElement.addEventListener("pause", this.boundOnPause), this.mediaElement.addEventListener("progress", this.boundOnProgress), this.mediaElement.volume = this.isMutedValue ? 0 : this.currentVolume, this.mediaElement.playbackRate = this.currentPlaybackRate, this.mediaElement.readyState >= 1 && this.onLoadedMetadata(new Event("loadedmetadata")), this.mediaElement.seekable.length > 0 && this.onProgress(), this.mediaElement.readyState >= 4 ? this.onCanPlayThrough() : (this.isLoadingValue = !0, this.isLoadedValue = !1);
10114
+ if (this.mediaElement.removeEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.removeEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.removeEventListener("error", this.boundOnError), this.mediaElement.removeEventListener("ended", this.boundOnEnded), this.mediaElement.removeEventListener("stalled", this.boundOnStalled), this.mediaElement.removeEventListener("emptied", this.boundOnEmptied), this.mediaElement.removeEventListener("suspend", this.boundOnSuspend), this.mediaElement.removeEventListener("waiting", this.boundOnWaiting), this.mediaElement.removeEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.removeEventListener("seeking", this.boundOnSeeking), this.mediaElement.removeEventListener("seeked", this.boundOnSeeked), this.mediaElement.removeEventListener("play", this.boundOnPlay), this.mediaElement.removeEventListener("playing", this.boundOnPlaying), this.mediaElement.removeEventListener("pause", this.boundOnPause), this.mediaElement.removeEventListener("progress", this.boundOnProgress), this.mediaElement.pause(), this.isPlayingValue = !1, this.isPausedValue = !1, this.sourceNode && (this.sourceNode.disconnect(), this.sourceNode = null), this.mediaElement = t, this.mediaElement.addEventListener("canplaythrough", this.boundOnCanPlayThrough), this.mediaElement.addEventListener("timeupdate", this.boundOnTimeUpdate), this.mediaElement.addEventListener("error", this.boundOnError), this.mediaElement.addEventListener("ended", this.boundOnEnded), this.mediaElement.addEventListener("stalled", this.boundOnStalled), this.mediaElement.addEventListener("emptied", this.boundOnEmptied), this.mediaElement.addEventListener("suspend", this.boundOnSuspend), this.mediaElement.addEventListener("waiting", this.boundOnWaiting), this.mediaElement.addEventListener("loadedmetadata", this.boundOnLoadedMetadata), this.mediaElement.addEventListener("seeking", this.boundOnSeeking), this.mediaElement.addEventListener("seeked", this.boundOnSeeked), this.mediaElement.addEventListener("play", this.boundOnPlay), this.mediaElement.addEventListener("playing", this.boundOnPlaying), this.mediaElement.addEventListener("pause", this.boundOnPause), this.mediaElement.addEventListener("progress", this.boundOnProgress), this.mediaElement.volume = this.isMutedValue ? 0 : this.currentVolume, this.mediaElement.playbackRate = this.currentPlaybackRate, this.webAudioActive)
10115
+ try {
10116
+ const e = this.getOrCreateAudioContext();
10117
+ this.sourceNode = new MediaElementAudioSourceNode(e, { mediaElement: this.mediaElement }), this.gainNode || (this.gainNode = e.createGain(), this.gainNode.connect(e.destination)), this.worklet?.workletNode ? this.sourceNode.connect(this.worklet.workletNode) : this.sourceNode.connect(this.gainNode);
10118
+ } catch {
10119
+ this.deactivateWebAudio();
10120
+ }
10121
+ this.mediaElement.readyState >= 1 && this.onLoadedMetadata(new Event("loadedmetadata")), this.mediaElement.seekable.length > 0 && this.onProgress(), this.mediaElement.readyState >= 4 ? this.onCanPlayThrough() : (this.isLoadingValue = !0, this.isLoadedValue = !1);
10131
10122
  }
10132
10123
  // Ensure AudioContext is running
10133
10124
  async ensureAudioContextRunning() {
@@ -10356,12 +10347,12 @@ class Cs {
10356
10347
  this.volume = M(t.volume, Qt.range) ?? 1, this.playbackRate = M(t.playbackRate, te.range) ?? 1, this.preservePitch = P(t.preservePitch) ?? !0, this.skipBackwardInterval = M(t.skipBackwardInterval, et.range) ?? 10, this.skipForwardInterval = M(t.skipForwardInterval, et.range) ?? 10, this.pollInterval = w(t.pollInterval) ?? 1e3, this.autoPlay = P(t.autoPlay) ?? !0, this.enableMediaSession = P(t.enableMediaSession) ?? !0;
10357
10348
  }
10358
10349
  }
10359
- class Fi {
10350
+ class Ni {
10360
10351
  constructor(t, e) {
10361
10352
  this.volume = t.volume ?? e.volume, this.playbackRate = t.playbackRate ?? e.playbackRate, this.preservePitch = t.preservePitch ?? e.preservePitch, this.skipBackwardInterval = t.skipBackwardInterval ?? e.skipBackwardInterval, this.skipForwardInterval = t.skipForwardInterval ?? e.skipForwardInterval, this.pollInterval = t.pollInterval ?? e.pollInterval, this.autoPlay = t.autoPlay ?? e.autoPlay, this.enableMediaSession = t.enableMediaSession ?? e.enableMediaSession;
10362
10353
  }
10363
10354
  }
10364
- class Ni {
10355
+ class Fi {
10365
10356
  constructor(t, e) {
10366
10357
  this.preferences = t, this.settings = e;
10367
10358
  }
@@ -10501,7 +10492,7 @@ class xs {
10501
10492
  */
10502
10493
  ensure(t) {
10503
10494
  let e = this.pool.get(t);
10504
- return e || (e = document.createElement("audio"), e.preload = "auto", e.src = t, e.load(), this.pool.set(t, e)), e;
10495
+ return e || (e = document.createElement("audio"), e.preload = "auto", this._audioEngine.isWebAudioActive && (e.crossOrigin = "anonymous"), e.src = t, e.load(), this.pool.set(t, e)), e;
10505
10496
  }
10506
10497
  /**
10507
10498
  * Updates the pool around the given index: ensures elements exist within
@@ -10522,7 +10513,7 @@ class xs {
10522
10513
  */
10523
10514
  setCurrentAudio(t, e) {
10524
10515
  const i = this.pickPlayableHref(this._publication.readingOrder.items[t]), n = this.ensure(i);
10525
- this.audioEngine.isWebAudioActive ? (this.audioEngine.setMediaElement(n), this.audioEngine.loadAudio(i)) : this.audioEngine.setMediaElement(n), this.pool.delete(i), this.update(t);
10516
+ this.audioEngine.setMediaElement(n), this.pool.delete(i), this.update(t);
10526
10517
  }
10527
10518
  destroy() {
10528
10519
  this.audioEngine.stop();
@@ -10607,11 +10598,11 @@ class As extends dr {
10607
10598
  preferences: {},
10608
10599
  defaults: {}
10609
10600
  }) {
10610
- if (super(), this.positionPollInterval = null, this.navigationId = 0, this._preferencesEditor = null, this._mediaSessionEnabled = !1, this._navigatorProtector = null, this._keyboardPeripheralsManager = null, this._suspiciousActivityListener = null, this._keyboardPeripheralListener = null, this.pub = t, this.listeners = Os(e), this._preferences = new oe(n.preferences), this._defaults = new Cs(n.defaults), this._settings = new Fi(this._preferences, this._defaults), i)
10601
+ if (super(), this.positionPollInterval = null, this.navigationId = 0, this._playIntent = !1, this._preferencesEditor = null, this._mediaSessionEnabled = !1, this._navigatorProtector = null, this._keyboardPeripheralsManager = null, this._suspiciousActivityListener = null, this._keyboardPeripheralListener = null, this.pub = t, this.listeners = Os(e), this._preferences = new oe(n.preferences), this._defaults = new Cs(n.defaults), this._settings = new Ni(this._preferences, this._defaults), i)
10611
10602
  this.currentLocation = this.ensureLocatorLocations(i);
10612
10603
  else {
10613
10604
  const u = this.pub.readingOrder.items[0];
10614
- this.currentLocation = new F({
10605
+ this.currentLocation = new N({
10615
10606
  href: u.href,
10616
10607
  type: u.type || "audio/mpeg",
10617
10608
  title: u.title,
@@ -10652,19 +10643,19 @@ class As extends dr {
10652
10643
  return this._settings;
10653
10644
  }
10654
10645
  get preferencesEditor() {
10655
- return this._preferencesEditor === null && (this._preferencesEditor = new Ni(this._preferences, this.settings)), this._preferencesEditor;
10646
+ return this._preferencesEditor === null && (this._preferencesEditor = new Fi(this._preferences, this.settings)), this._preferencesEditor;
10656
10647
  }
10657
10648
  async submitPreferences(t) {
10658
10649
  this._preferences = this._preferences.merging(t), this.applyPreferences();
10659
10650
  }
10660
10651
  applyPreferences() {
10661
- this._settings = new Fi(this._preferences, this._defaults), this._preferencesEditor !== null && (this._preferencesEditor = new Ni(this._preferences, this.settings)), this.pool.audioEngine.setVolume(this._settings.volume), this.pool.audioEngine.setPlaybackRate(this._settings.playbackRate, this._settings.preservePitch), this._settings.enableMediaSession && !this._mediaSessionEnabled ? (this._mediaSessionEnabled = !0, this.setupMediaSession()) : !this._settings.enableMediaSession && this._mediaSessionEnabled && (this._mediaSessionEnabled = !1, this.destroyMediaSession());
10652
+ this._settings = new Ni(this._preferences, this._defaults), this._preferencesEditor !== null && (this._preferencesEditor = new Fi(this._preferences, this.settings)), this.pool.audioEngine.setVolume(this._settings.volume), this.pool.audioEngine.setPlaybackRate(this._settings.playbackRate, this._settings.preservePitch), this._settings.enableMediaSession && !this._mediaSessionEnabled ? (this._mediaSessionEnabled = !0, this.setupMediaSession()) : !this._settings.enableMediaSession && this._mediaSessionEnabled && (this._mediaSessionEnabled = !1, this.destroyMediaSession());
10662
10653
  }
10663
10654
  get publication() {
10664
10655
  return this.pub;
10665
10656
  }
10666
10657
  ensureLocatorLocations(t) {
10667
- return new F({
10658
+ return new N({
10668
10659
  ...t,
10669
10660
  locations: t.locations instanceof E ? t.locations : t.locations ? new E(t.locations) : void 0
10670
10661
  });
@@ -10697,7 +10688,7 @@ class As extends dr {
10697
10688
  const i = this.pub.readingOrder.items[t];
10698
10689
  if (!i) throw new Error(`Invalid track index: ${t}`);
10699
10690
  const n = this.pool.audioEngine.duration();
10700
- return new F({
10691
+ return new N({
10701
10692
  href: i.href,
10702
10693
  type: i.type || "audio/mpeg",
10703
10694
  title: i.title,
@@ -10805,9 +10796,9 @@ class As extends dr {
10805
10796
  i(!1);
10806
10797
  return;
10807
10798
  }
10808
- const a = ++this.navigationId, l = r >= this.currentTrackIndex() ? "forward" : "backward", h = this.isPlaying;
10809
- if (this.stopPositionPolling(), this.pool.setCurrentAudio(r, l), this.currentLocation = t.copyWithLocations(t.locations), await this.waitForLoadedAndSeeked(o, a), a !== this.navigationId) return;
10810
- this.listeners.trackLoaded(this.pool.audioEngine.getMediaElement()), this.listeners.positionChanged(this.currentLocator), this._settings.enableMediaSession && this.updateMediaSessionMetadata(), h && this.play(), i(!0);
10799
+ const a = ++this.navigationId, l = r >= this.currentTrackIndex() ? "forward" : "backward", h = this.isPlaying || this._playIntent;
10800
+ if (this._playIntent = h, this.stopPositionPolling(), this.pool.setCurrentAudio(r, l), this.currentLocation = t.copyWithLocations(t.locations), await this.waitForLoadedAndSeeked(o, a), a !== this.navigationId) return;
10801
+ this.listeners.trackLoaded(this.pool.audioEngine.getMediaElement()), this.listeners.positionChanged(this.currentLocator), this._settings.enableMediaSession && this.updateMediaSessionMetadata(), h && this.play(), this._playIntent = !1, i(!0);
10811
10802
  } catch (n) {
10812
10803
  console.error("Failed to go to locator:", n), i(!1);
10813
10804
  }
@@ -10896,8 +10887,8 @@ export {
10896
10887
  Cs as AudioDefaults,
10897
10888
  As as AudioNavigator,
10898
10889
  oe as AudioPreferences,
10899
- Ni as AudioPreferencesEditor,
10900
- Fi as AudioSettings,
10890
+ Fi as AudioPreferencesEditor,
10891
+ Ni as AudioSettings,
10901
10892
  O as BooleanPreference,
10902
10893
  cn as EnumPreference,
10903
10894
  ls as EpubDefaults,