@prose-reader/core 1.226.0 → 1.227.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import { switchMap as P, of as w, fromEvent as G, take as he, map as b, from as
2
2
  import { Report as ei, isShallowEqual as N, shallowMergeIfDefined as vt, getParentPath as ii, parseContentType as ni, detectMimeTypeFromName as Lt, arrayEqual as oi } from "@prose-reader/shared";
3
3
  import { isShallowEqual as Rs } from "@prose-reader/shared";
4
4
  import { switchMap as X, first as ye, map as q, distinctUntilChanged as Z, startWith as Se, shareReplay as bt, tap as z, pairwise as si, take as ri, takeUntil as J, filter as Q, debounceTime as ai, skip as ci, mergeMap as ui, catchError as Qt, withLatestFrom as di } from "rxjs/operators";
5
- import { generate as Vt, parse as be, isIndirectionOnly as li, isParsedCfiRange as gi, resolve as pi } from "@prose-reader/cfi";
5
+ import { generate as Vt, parse as be, isIndirectionOnly as li, isParsedCfiRange as pi, resolve as gi } from "@prose-reader/cfi";
6
6
  const te = (e, t) => {
7
7
  const i = new RegExp(`${t}\\s*=\\s*([0-9.]+)`, "i"), n = e.match(i) || [], o = n[1] || "0";
8
8
  return n && Number.parseFloat(o) || 0;
@@ -304,41 +304,41 @@ const Ct = ({
304
304
  const { clientX: d, clientY: l } = Ct({
305
305
  position: e,
306
306
  frameElement: r
307
- }), g = new PointerEvent(e.type, {
307
+ }), p = new PointerEvent(e.type, {
308
308
  ...e,
309
309
  pointerId: e.pointerId,
310
310
  clientX: d,
311
311
  clientY: l
312
312
  });
313
- return Object.defineProperty(g, "target", {
313
+ return Object.defineProperty(p, "target", {
314
314
  value: t.target,
315
315
  enumerable: !0
316
- }), g;
316
+ }), p;
317
317
  }
318
318
  if (Ti(e)) {
319
319
  const { clientX: d, clientY: l } = Ct({
320
320
  position: e,
321
321
  frameElement: r
322
- }), g = new MouseEvent(e.type, {
322
+ }), p = new MouseEvent(e.type, {
323
323
  ...e,
324
324
  clientX: d,
325
325
  clientY: l
326
326
  });
327
- return Object.defineProperty(g, "target", {
327
+ return Object.defineProperty(p, "target", {
328
328
  value: t.target,
329
329
  enumerable: !0
330
- }), g;
330
+ }), p;
331
331
  }
332
332
  if (Fi(e)) {
333
- const d = Array.from(e.touches).map((g) => {
334
- const { clientX: p, clientY: h } = Ct({
335
- position: g,
333
+ const d = Array.from(e.touches).map((p) => {
334
+ const { clientX: g, clientY: h } = Ct({
335
+ position: p,
336
336
  frameElement: r
337
337
  });
338
338
  return new Touch({
339
- identifier: g.identifier,
340
- target: g.target,
341
- clientX: p,
339
+ identifier: p.identifier,
340
+ target: p.target,
341
+ clientX: g,
342
342
  clientY: h
343
343
  });
344
344
  }), l = new TouchEvent(e.type, {
@@ -374,16 +374,16 @@ const Ct = ({
374
374
  const a = Oi.map((c) => {
375
375
  var d;
376
376
  const u = (l) => {
377
- var p;
378
- let g = l;
379
- if (Bt(l) && (g = new PointerEvent(l.type, l)), g !== l) {
377
+ var g;
378
+ let p = l;
379
+ if (Bt(l) && (p = new PointerEvent(l.type, l)), p !== l) {
380
380
  const h = Ai(
381
- g,
381
+ p,
382
382
  l,
383
383
  i.spine.locator,
384
384
  i.context
385
385
  );
386
- (p = i.context.state.containerElement) == null || p.dispatchEvent(
386
+ (g = i.context.state.containerElement) == null || g.dispatchEvent(
387
387
  h
388
388
  );
389
389
  }
@@ -559,24 +559,24 @@ const Wi = (e) => (t) => {
559
559
  ${c.values.fontWeight !== "publisher" ? `font-weight: ${c.values.fontWeight} !important;` : ""}
560
560
  ${c.values.fontJustification !== "publisher" ? `text-align: ${c.values.fontJustification} !important;` : ""}
561
561
  }
562
- `, d = (g) => {
563
- a.spineItemsManager.items.forEach((p) => {
564
- if (p.renditionLayout !== "pre-paginated") {
565
- const h = p.renderer.getDocumentFrame();
562
+ `, d = (p) => {
563
+ a.spineItemsManager.items.forEach((g) => {
564
+ if (g.renditionLayout !== "pre-paginated") {
565
+ const h = g.renderer.getDocumentFrame();
566
566
  h && ot(h, "prose-reader-fonts", u());
567
567
  }
568
- }), g && a.layout();
568
+ }), p && a.layout();
569
569
  };
570
- a.hookManager.register("item.onDocumentLoad", ({ itemId: g }) => {
571
- const p = a.spineItemsManager.get(g);
572
- if ((p == null ? void 0 : p.renditionLayout) !== "pre-paginated") {
573
- const h = p == null ? void 0 : p.renderer.getDocumentFrame();
570
+ a.hookManager.register("item.onDocumentLoad", ({ itemId: p }) => {
571
+ const g = a.spineItemsManager.get(p);
572
+ if ((g == null ? void 0 : g.renditionLayout) !== "pre-paginated") {
573
+ const h = g == null ? void 0 : g.renderer.getDocumentFrame();
574
574
  h && ot(h, "prose-reader-fonts", u());
575
575
  }
576
576
  });
577
- const l = (g) => g.pipe(
577
+ const l = (p) => p.pipe(
578
578
  si(),
579
- b(([p, h]) => h.fontScale !== p.fontScale || h.lineHeight !== p.lineHeight)
579
+ b(([g, h]) => h.fontScale !== g.fontScale || h.lineHeight !== g.lineHeight)
580
580
  );
581
581
  return c.values$.pipe(
582
582
  l,
@@ -823,7 +823,7 @@ const Le = (e, t) => {
823
823
  if (e.defaultView && c instanceof e.defaultView.CSSFontFaceRule) {
824
824
  const u = c.style.getPropertyValue("src");
825
825
  if (u.match(/url\(['"]?([^'"]+)['"]?\)/g)) {
826
- const l = u.split(",").map((h) => h.trim()), g = await Promise.all(
826
+ const l = u.split(",").map((h) => h.trim()), p = await Promise.all(
827
827
  l.map(async (h) => {
828
828
  var S, I;
829
829
  if (h.startsWith("local("))
@@ -850,11 +850,11 @@ const Le = (e, t) => {
850
850
  }
851
851
  return h;
852
852
  })
853
- ), p = c.cssText.replace(
853
+ ), g = c.cssText.replace(
854
854
  /src:\s*[^;]+;/,
855
- `src: ${g.join(", ")};`
855
+ `src: ${p.join(", ")};`
856
856
  );
857
- s.deleteRule(a), s.insertRule(p, a);
857
+ s.deleteRule(a), s.insertRule(g, a);
858
858
  }
859
859
  }
860
860
  }
@@ -882,7 +882,7 @@ const Le = (e, t) => {
882
882
  if (t.hasAttribute("src"))
883
883
  t.setAttribute("src", d);
884
884
  else if (t.hasAttribute("href") && (t.setAttribute("href", d), e != null && e.defaultView && t instanceof e.defaultView.HTMLLinkElement))
885
- return new et((g) => {
885
+ return new et((p) => {
886
886
  t.onload = async () => {
887
887
  try {
888
888
  t.sheet && await Ei(
@@ -891,11 +891,11 @@ const Le = (e, t) => {
891
891
  i,
892
892
  n,
893
893
  o
894
- ), g.next(), g.complete();
895
- } catch (p) {
896
- g.error(p);
894
+ ), p.next(), p.complete();
895
+ } catch (g) {
896
+ p.error(g);
897
897
  }
898
- }, t.onerror = g.error;
898
+ }, t.onerror = p.error;
899
899
  });
900
900
  return w(null);
901
901
  })
@@ -921,7 +921,7 @@ const Le = (e, t) => {
921
921
  })
922
922
  ), Xi = (e) => {
923
923
  Mi(e == null ? void 0 : e.contentDocument);
924
- }, qi = [".xhtml", ".html", ".htm"], gt = "prose-reader", Yi = (e) => new Promise((t, i) => {
924
+ }, qi = [".xhtml", ".html", ".htm"], pt = "prose-reader", Yi = (e) => new Promise((t, i) => {
925
925
  const n = new Image();
926
926
  n.src = e, n.onload = () => {
927
927
  t({ height: n.naturalHeight, width: n.naturalWidth });
@@ -1095,7 +1095,7 @@ const Le = (e, t) => {
1095
1095
  }) => {
1096
1096
  const c = e * o;
1097
1097
  if (s != null && s.contentDocument && (s != null && s.contentWindow)) {
1098
- const { viewportDimensions: u, computedScale: d = 1 } = Ce({ frameElement: s, pageHeight: n, pageWidth: o }) ?? {}, l = o, g = n, p = Ki(
1098
+ const { viewportDimensions: u, computedScale: d = 1 } = Ce({ frameElement: s, pageHeight: n, pageWidth: o }) ?? {}, l = o, p = n, g = Ki(
1099
1099
  {
1100
1100
  ...Qi({ pageHeight: n, pageWidth: o }),
1101
1101
  enableTouch: a,
@@ -1103,12 +1103,12 @@ const Le = (e, t) => {
1103
1103
  },
1104
1104
  u
1105
1105
  );
1106
- if (ot(s, "prose-reader-css", p), u ? ne(s, {
1106
+ if (ot(s, "prose-reader-css", g), u ? ne(s, {
1107
1107
  width: u.width ?? 1,
1108
1108
  height: u.height ?? 1
1109
1109
  }) : ne(s, {
1110
1110
  width: l,
1111
- height: g
1111
+ height: p
1112
1112
  }), u) {
1113
1113
  s == null || s.style.setProperty("position", "absolute"), s == null || s.style.setProperty("top", "50%"), i === "left" ? (s == null || s.style.setProperty("right", "0"), s == null || s.style.removeProperty("left")) : t === "before" && r ? (s == null || s.style.setProperty("right", "50%"), s == null || s.style.removeProperty("left")) : i === "right" ? (s == null || s.style.setProperty("left", "0"), s == null || s.style.removeProperty("right")) : (s == null || s.style.setProperty(
1114
1114
  "left",
@@ -1124,7 +1124,7 @@ const Le = (e, t) => {
1124
1124
  );
1125
1125
  } else
1126
1126
  t === "before" ? r ? s == null || s.style.setProperty("margin-right", `${o}px`) : s == null || s.style.setProperty("margin-left", `${o}px`) : (s == null || s.style.removeProperty("margin-left"), s == null || s.style.removeProperty("margin-right"));
1127
- return { width: c, height: g };
1127
+ return { width: c, height: p };
1128
1128
  }
1129
1129
  return { width: c, height: n };
1130
1130
  }, en = () => `
@@ -1265,9 +1265,9 @@ const Le = (e, t) => {
1265
1265
  isUsingVerticalWriting: d
1266
1266
  }) => {
1267
1267
  const l = s * t;
1268
- let g = o;
1269
- const p = (n == null ? void 0 : n.renditionLayout) === "reflowable" && (n == null ? void 0 : n.renditionFlow) === "scrolled-continuous", h = p ? Math.min(400, e) : e;
1270
- i == null || i.style.setProperty("width", `${t}px`), p || i == null || i.style.setProperty("height", `${h}px`);
1268
+ let p = o;
1269
+ const g = (n == null ? void 0 : n.renditionLayout) === "reflowable" && (n == null ? void 0 : n.renditionFlow) === "scrolled-continuous", h = g ? Math.min(400, e) : e;
1270
+ i == null || i.style.setProperty("width", `${t}px`), g || i == null || i.style.setProperty("height", `${h}px`);
1271
1271
  const { viewportDimensions: m, computedScale: y = 1 } = Ce({
1272
1272
  frameElement: i,
1273
1273
  pageHeight: h,
@@ -1310,7 +1310,7 @@ const Le = (e, t) => {
1310
1310
  height: x
1311
1311
  });
1312
1312
  else if ((n == null ? void 0 : n.renditionFlow) === "scrolled-continuous")
1313
- x = i.contentDocument.body.scrollHeight, g = x, It(i, {
1313
+ x = i.contentDocument.body.scrollHeight, p = x, It(i, {
1314
1314
  width: l,
1315
1315
  height: x
1316
1316
  });
@@ -1328,8 +1328,8 @@ const Le = (e, t) => {
1328
1328
  }
1329
1329
  return {
1330
1330
  width: l,
1331
- height: g || h,
1332
- latestContentHeightWhenLoaded: g
1331
+ height: p || h,
1332
+ latestContentHeightWhenLoaded: p
1333
1333
  };
1334
1334
  };
1335
1335
  class an extends mt {
@@ -1378,7 +1378,7 @@ class an extends mt {
1378
1378
  if (!r) return w(void 0);
1379
1379
  const a = !!((d = this.writingMode) != null && d.startsWith("vertical"));
1380
1380
  if (this.item.renditionLayout === "pre-paginated" || !this.item.renditionLayout && ((l = this.context.manifest) == null ? void 0 : l.renditionLayout) === "pre-paginated") {
1381
- const g = tn({
1381
+ const p = tn({
1382
1382
  blankPagePosition: i,
1383
1383
  enableTouch: this.settings.values.computedPageTurnMode !== "scrollable",
1384
1384
  frameElement: r,
@@ -1388,7 +1388,7 @@ class an extends mt {
1388
1388
  pageWidth: o,
1389
1389
  spreadPosition: n
1390
1390
  });
1391
- return w(g);
1391
+ return w(p);
1392
1392
  }
1393
1393
  const { latestContentHeightWhenLoaded: c, ...u } = rn({
1394
1394
  pageHeight: s,
@@ -1562,11 +1562,11 @@ const dn = (e) => {
1562
1562
  }
1563
1563
  }
1564
1564
  );
1565
- }, gn = (e, t) => t.pipe(
1565
+ }, pn = (e, t) => t.pipe(
1566
1566
  T((i) => {
1567
1567
  e.viewport.value.element.style.transition = "transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)", e.settings.values.computedPageTurnMode === "scrollable" ? e.viewport.value.element.style.transformOrigin = "top" : e.viewport.value.element.style.transformOrigin = "center", i === "thumbnails" ? e.viewport.value.element.style.transform = "scale(0.5)" : e.viewport.value.element.style.transform = "scale(1)", e.layout();
1568
1568
  })
1569
- ), pn = (e) => (t) => {
1569
+ ), gn = (e) => (t) => {
1570
1570
  const {
1571
1571
  pageHorizontalMargin: i,
1572
1572
  pageVerticalMargin: n,
@@ -1658,23 +1658,23 @@ const dn = (e) => {
1658
1658
  }),
1659
1659
  J(r.$.destroy$)
1660
1660
  ).subscribe();
1661
- const g = r.spineItemsObserver.itemIsReady$.pipe(
1661
+ const p = r.spineItemsObserver.itemIsReady$.pipe(
1662
1662
  z(({ item: m, isReady: y }) => {
1663
1663
  const f = "prose-spineItem-ready";
1664
1664
  y ? m.containerElement.classList.add(f) : m.containerElement.classList.remove(f);
1665
1665
  })
1666
- ), p = gn(
1666
+ ), g = pn(
1667
1667
  r,
1668
1668
  a.watch("viewportMode")
1669
1669
  ), h = r.spine.pages.pipe(
1670
1670
  bt({ refCount: !0, bufferSize: 1 })
1671
1671
  );
1672
1672
  return v(
1673
- g,
1673
+ p,
1674
1674
  c,
1675
1675
  l,
1676
1676
  d,
1677
- p,
1677
+ g,
1678
1678
  h
1679
1679
  ).pipe(J(r.$.destroy$)).subscribe(), {
1680
1680
  ...r,
@@ -1685,7 +1685,7 @@ const dn = (e) => {
1685
1685
  layout$: r.spine.layout$,
1686
1686
  layoutInfo$: h
1687
1687
  };
1688
- }, hn = `${gt}-enhancer-loading`, Re = `${hn}-container`, mn = (e, t) => {
1688
+ }, hn = `${pt}-enhancer-loading`, Re = `${hn}-container`, mn = (e, t) => {
1689
1689
  const i = e.ownerDocument.createElement("div");
1690
1690
  return i.classList.add(Re), i.style.cssText = `
1691
1691
  height: 100%;
@@ -1724,16 +1724,16 @@ const dn = (e) => {
1724
1724
  const { loadingElementCreate: i = fn } = t, n = e(t), o = (c) => w(
1725
1725
  c.reduce((u, { item: d, element: l }) => {
1726
1726
  l.style.zIndex = "0";
1727
- const g = l.querySelector(
1727
+ const p = l.querySelector(
1728
1728
  `.${Re}`
1729
1729
  );
1730
- if (g instanceof HTMLElement)
1731
- return u[d.id] = g, u;
1732
- const p = i({
1730
+ if (p instanceof HTMLElement)
1731
+ return u[d.id] = p, u;
1732
+ const g = i({
1733
1733
  container: mn(l, n.context),
1734
1734
  item: d
1735
1735
  });
1736
- return l.appendChild(p), u[d.id] = p, u;
1736
+ return l.appendChild(g), u[d.id] = g, u;
1737
1737
  }, {})
1738
1738
  ), s = (c) => B([n.spine.layout$, n.theme.$.theme$]).pipe(
1739
1739
  q(([, u]) => ({
@@ -1751,11 +1751,11 @@ const dn = (e) => {
1751
1751
  })
1752
1752
  ), r = (c) => n.spineItemsObserver.itemIsReady$.pipe(
1753
1753
  z(({ item: u, isReady: d }) => {
1754
- var l, g;
1754
+ var l, p;
1755
1755
  (l = c[u.item.id]) == null || l.style.setProperty(
1756
1756
  "visibility",
1757
1757
  d ? "hidden" : "visible"
1758
- ), (g = c[u.item.id]) == null || g.style.setProperty(
1758
+ ), (p = c[u.item.id]) == null || p.style.setProperty(
1759
1759
  "z-index",
1760
1760
  d ? "0" : "1"
1761
1761
  );
@@ -1875,13 +1875,13 @@ const bn = (e) => (t) => {
1875
1875
  return i.hookManager.register(
1876
1876
  "item.onDocumentLoad",
1877
1877
  ({ destroy: r, itemId: a }) => {
1878
- var l, g;
1878
+ var l, p;
1879
1879
  const c = (l = i.spineItemsManager.get(a)) == null ? void 0 : l.renderer.getDocumentFrame();
1880
1880
  if (!c) return;
1881
1881
  n.observe(c);
1882
- const u = (g = c.contentDocument) == null ? void 0 : g.body.getElementsByTagName("video"), d = Array.from(u || []).map((p) => (o.observe(p), () => o.unobserve(p)));
1882
+ const u = (p = c.contentDocument) == null ? void 0 : p.body.getElementsByTagName("video"), d = Array.from(u || []).map((g) => (o.observe(g), () => o.unobserve(g)));
1883
1883
  r(() => {
1884
- n.unobserve(c), d.forEach((p) => p());
1884
+ n.unobserve(c), d.forEach((g) => g());
1885
1885
  });
1886
1886
  }
1887
1887
  ), {
@@ -2208,14 +2208,14 @@ class Fn {
2208
2208
  goToNextSpineItem() {
2209
2209
  const { endIndex: t = 0 } = this.reader.spine.locator.getVisibleSpineItemsFromPosition({
2210
2210
  position: this.reader.navigation.getNavigation().position,
2211
- threshold: 0.5
2211
+ threshold: { type: "percentage", value: 0.5 }
2212
2212
  }) || {};
2213
2213
  this.goToSpineItem({ indexOrId: t + 1 });
2214
2214
  }
2215
2215
  goToPreviousSpineItem() {
2216
2216
  const { beginIndex: t = 0 } = this.reader.spine.locator.getVisibleSpineItemsFromPosition({
2217
2217
  position: this.reader.navigation.getNavigation().position,
2218
- threshold: 0.5
2218
+ threshold: { type: "percentage", value: 0.5 }
2219
2219
  }) ?? {};
2220
2220
  this.goToSpineItem({ indexOrId: t - 1 });
2221
2221
  }
@@ -2327,13 +2327,13 @@ class Ln {
2327
2327
  n && ((r = this.unlock) == null || r.call(this), this.unlock = this.reader.navigation.lock(), this.lastDelta = { x: 0, y: 0 }, this.lastStartPosition = this.reader.navigation.controlledNavigationController.viewportPosition, this.lastPosition = this.lastStartPosition);
2328
2328
  let s = this.reader.navigation.getNavigation().position;
2329
2329
  if (t) {
2330
- const d = this.reader.viewport.absoluteViewport.width / this.reader.viewport.relativeViewport.width, l = Math.floor(t.x) - (((a = this.lastDelta) == null ? void 0 : a.x) || 0), g = Math.floor(t.y) - (((c = this.lastDelta) == null ? void 0 : c.y) || 0), p = Math.floor(
2330
+ const d = this.reader.viewport.absoluteViewport.width / this.reader.viewport.relativeViewport.width, l = Math.floor(t.x) - (((a = this.lastDelta) == null ? void 0 : a.x) || 0), p = Math.floor(t.y) - (((c = this.lastDelta) == null ? void 0 : c.y) || 0), g = Math.floor(
2331
2331
  o === "horizontal" ? this.lastPosition.x - l / d : 0
2332
2332
  ), h = Math.floor(
2333
- o === "horizontal" ? 0 : this.lastPosition.y - g / d
2333
+ o === "horizontal" ? 0 : this.lastPosition.y - p / d
2334
2334
  );
2335
2335
  s = new M({
2336
- x: p,
2336
+ x: g,
2337
2337
  y: h
2338
2338
  }), this.lastDelta = t;
2339
2339
  } else
@@ -2474,7 +2474,7 @@ const Mn = (e) => e.pagination.state$.pipe(
2474
2474
  return li(t);
2475
2475
  }, Dn = (e) => Array.isArray(e) ? e[0] && re(e[0]) ? e[0] : void 0 : e.parent[0] && re(e.parent[0]) ? e.parent[0] : void 0, Zt = (e) => {
2476
2476
  var a, c, u, d;
2477
- const t = be(e), n = (Dn(t) ?? [])[1], s = ((n == null ? void 0 : n.index) ?? 2) / 2 - 1, r = gi(t) ? (c = (a = t.end.at(-1)) == null ? void 0 : a.at(-1)) == null ? void 0 : c.offset : (d = (u = t.at(-1)) == null ? void 0 : u.at(-1)) == null ? void 0 : d.offset;
2477
+ const t = be(e), n = (Dn(t) ?? [])[1], s = ((n == null ? void 0 : n.index) ?? 2) / 2 - 1, r = pi(t) ? (c = (a = t.end.at(-1)) == null ? void 0 : a.at(-1)) == null ? void 0 : c.offset : (d = (u = t.at(-1)) == null ? void 0 : u.at(-1)) == null ? void 0 : d.offset;
2478
2478
  return {
2479
2479
  cleanedCfi: e,
2480
2480
  itemIndex: s,
@@ -2493,7 +2493,7 @@ const Mn = (e) => e.pagination.state$.pipe(
2493
2493
  const a = (s = o.contentWindow) == null ? void 0 : s.document;
2494
2494
  if (a)
2495
2495
  try {
2496
- const c = pi(e, a, {
2496
+ const c = gi(e, a, {
2497
2497
  throwOnError: !0
2498
2498
  });
2499
2499
  return {
@@ -2564,10 +2564,10 @@ class Vn {
2564
2564
  meta: On(this.reader, i)
2565
2565
  };
2566
2566
  return ee(() => {
2567
- var p;
2568
- const s = (p = this.reader.cfi.parseCfi(
2567
+ var g;
2568
+ const s = (g = this.reader.cfi.parseCfi(
2569
2569
  o.meta.cfi
2570
- )) == null ? void 0 : p.itemIndex, r = this.reader.spineItemsManager.get(s), a = (r == null ? void 0 : r.renditionLayout) === "reflowable", c = n.mode === "shallow" || !a || !r ? () => {
2570
+ )) == null ? void 0 : g.itemIndex, r = this.reader.spineItemsManager.get(s), a = (r == null ? void 0 : r.renditionLayout) === "reflowable", c = n.mode === "shallow" || !a || !r ? () => {
2571
2571
  } : this.reader.spine.spineItemsLoader.forceOpen([r.index]), u = "cfi" in i ? i.cfi : void 0, d = u ? this.locatorsByKey.get(u) : void 0, l = (h) => h.pipe(
2572
2572
  ut(() => {
2573
2573
  u && this.deregisterMemoizedStream(u), setTimeout(() => {
@@ -2584,7 +2584,7 @@ class Vn {
2584
2584
  }))
2585
2585
  )
2586
2586
  );
2587
- const g = this.reader.spine.layout$.pipe(
2587
+ const p = this.reader.spine.layout$.pipe(
2588
2588
  St(10),
2589
2589
  nt(o),
2590
2590
  Je((h) => Nn(h.meta, this.reader).pipe(
@@ -2597,8 +2597,8 @@ class Vn {
2597
2597
  );
2598
2598
  return u && this.locatorsByKey.set(u, {
2599
2599
  observerCount: 1,
2600
- consolidate$: g
2601
- }), l(g);
2600
+ consolidate$: p
2601
+ }), l(p);
2602
2602
  });
2603
2603
  };
2604
2604
  }
@@ -2620,10 +2620,10 @@ const Oe = (e, t, i) => {
2620
2620
  a.lastIndexOf("/")
2621
2621
  ), u = e.substring(0, e.lastIndexOf("/")), d = e.endsWith(a), l = u !== "" && u.endsWith(c);
2622
2622
  if (d || l) {
2623
- const p = i.spineItems.findIndex(
2623
+ const g = i.spineItems.findIndex(
2624
2624
  (f) => f.href === s.href
2625
2625
  );
2626
- if (n < p) return o;
2626
+ if (n < g) return o;
2627
2627
  const m = {
2628
2628
  title: s.title,
2629
2629
  path: s.path
@@ -2668,10 +2668,10 @@ const Oe = (e, t, i) => {
2668
2668
  D(e.layoutInfo$),
2669
2669
  b(([s, r]) => {
2670
2670
  var f, S, I, x, $, F, A;
2671
- const a = e.context, c = ((f = a.manifest) == null ? void 0 : f.renditionLayout) === "pre-paginated", u = ((S = a.manifest) == null ? void 0 : S.spineItems.length) || 0, d = ((I = a.manifest) == null ? void 0 : I.spineItems.slice(0, t).reduce((O, _) => O + (_.progressionWeight ?? 0), 0)) || 0, l = e.spineItemsManager.getSpineItemIndex(o) ?? 0, g = ((x = e.context.manifest) == null ? void 0 : x.spineItems.length) ?? 0, p = r.pages.filter((O) => O.itemIndex === l).length ?? 0, h = ((F = ($ = a.manifest) == null ? void 0 : $.spineItems[t]) == null ? void 0 : F.progressionWeight) ?? // if no progressionWeight is defined we "assume" the document weight to be
2671
+ const a = e.context, c = ((f = a.manifest) == null ? void 0 : f.renditionLayout) === "pre-paginated", u = ((S = a.manifest) == null ? void 0 : S.spineItems.length) || 0, d = ((I = a.manifest) == null ? void 0 : I.spineItems.slice(0, t).reduce((O, _) => O + (_.progressionWeight ?? 0), 0)) || 0, l = e.spineItemsManager.getSpineItemIndex(o) ?? 0, p = ((x = e.context.manifest) == null ? void 0 : x.spineItems.length) ?? 0, g = r.pages.filter((O) => O.itemIndex === l).length ?? 0, h = ((F = ($ = a.manifest) == null ? void 0 : $.spineItems[t]) == null ? void 0 : F.progressionWeight) ?? // if no progressionWeight is defined we "assume" the document weight to be
2672
2672
  // relative to the total number of documents
2673
- (l + 1) / g;
2674
- let m = (i + 1) * (h / p);
2673
+ (l + 1) / p;
2674
+ let m = (i + 1) * (h / g);
2675
2675
  !c && o.renditionLayout === "reflowable" && !s && (m = 0);
2676
2676
  let y = d + m;
2677
2677
  return ((A = a.manifest) == null ? void 0 : A.renditionFlow) === "scrolled-continuous" && (s ? m = Un(
@@ -2682,7 +2682,7 @@ const Oe = (e, t, i) => {
2682
2682
  d,
2683
2683
  h,
2684
2684
  m
2685
- )), t === u - 1 && i === p - 1 && y > 0.99 ? 1 : y;
2685
+ )), t === u - 1 && i === g - 1 && y > 0.99 ? 1 : y;
2686
2686
  })
2687
2687
  ), En = (e) => e.spine.layout$.pipe(
2688
2688
  St(10, rt),
@@ -2827,16 +2827,16 @@ const Oe = (e, t, i) => {
2827
2827
  }, Yn = (e) => ({
2828
2828
  put: (s, r) => new Promise((a, c) => {
2829
2829
  const u = e.transaction(["store"], "readwrite");
2830
- u.onerror = (g) => {
2831
- c(g);
2830
+ u.onerror = (p) => {
2831
+ c(p);
2832
2832
  }, u.oncomplete = () => {
2833
2833
  a();
2834
2834
  };
2835
2835
  const l = u.objectStore("store").put(r, s);
2836
2836
  l.onsuccess = () => {
2837
2837
  a();
2838
- }, l.onerror = (g) => {
2839
- c(g);
2838
+ }, l.onerror = (p) => {
2839
+ c(p);
2840
2840
  };
2841
2841
  }),
2842
2842
  keys: () => new Promise((s, r) => {
@@ -2872,8 +2872,8 @@ const Oe = (e, t, i) => {
2872
2872
  }, c.oncomplete = () => {
2873
2873
  r();
2874
2874
  }, c.onabort = () => {
2875
- var g;
2876
- const l = d.error ? d.error : (g = d.transaction) == null ? void 0 : g.error;
2875
+ var p;
2876
+ const l = d.error ? d.error : (p = d.transaction) == null ? void 0 : p.error;
2877
2877
  a(l);
2878
2878
  };
2879
2879
  })
@@ -2892,17 +2892,17 @@ const Oe = (e, t, i) => {
2892
2892
  var u, d;
2893
2893
  if (typeof c == "string" || typeof c == "object") {
2894
2894
  const l = typeof c == "object" ? c.id : c;
2895
- return (u = e.manifest) == null ? void 0 : u.spineItems.find((g) => g.id === l);
2895
+ return (u = e.manifest) == null ? void 0 : u.spineItems.find((p) => p.id === l);
2896
2896
  }
2897
2897
  return (d = e.manifest) == null ? void 0 : d.spineItems[c];
2898
2898
  }, o = async (c, u) => {
2899
2899
  const d = n(c);
2900
2900
  if (!d) return new Response("Item not found", { status: 404 });
2901
- const g = await (await Rt("prose-reader")).get(`${t}_${d.id}`);
2902
- if (g)
2903
- return new Response(g, { status: 200 });
2904
- const p = u && await u(d) || await fetch(d.href);
2905
- return s(d, p.clone()), p;
2901
+ const p = await (await Rt("prose-reader")).get(`${t}_${d.id}`);
2902
+ if (p)
2903
+ return new Response(p, { status: 200 });
2904
+ const g = u && await u(d) || await fetch(d.href);
2905
+ return s(d, g.clone()), g;
2906
2906
  }, s = (c, u) => {
2907
2907
  i.next({ id: c, data: u });
2908
2908
  };
@@ -2912,7 +2912,7 @@ const Oe = (e, t, i) => {
2912
2912
  return d ? W(
2913
2913
  Qe([Rt("prose-reader"), W(u.blob())])
2914
2914
  ).pipe(
2915
- X(([l, g]) => W(l.put(`${t}_${d.id}`, g))),
2915
+ X(([l, p]) => W(l.put(`${t}_${d.id}`, p))),
2916
2916
  Qt((l) => (V.error(l), K))
2917
2917
  ) : K;
2918
2918
  }),
@@ -3091,14 +3091,14 @@ const to = (e) => e.loaded$.pipe(
3091
3091
  let n;
3092
3092
  const o = i.spineItemsManager.items$.pipe(
3093
3093
  P((d) => {
3094
- const l = d.map((g) => {
3095
- const p = i.spineItemsManager.getSpineItemIndex(g) ?? 0;
3096
- return to(g).pipe(
3094
+ const l = d.map((p) => {
3095
+ const g = i.spineItemsManager.getSpineItemIndex(p) ?? 0;
3096
+ return to(p).pipe(
3097
3097
  b((h) => {
3098
3098
  if (h)
3099
3099
  return {
3100
3100
  ...h,
3101
- itemIndex: p
3101
+ itemIndex: g
3102
3102
  };
3103
3103
  })
3104
3104
  );
@@ -3366,7 +3366,7 @@ const ao = (e) => (t) => {
3366
3366
  }
3367
3367
  };
3368
3368
  }, Ve = (e) => (e == null ? void 0 : e.renditionLayout) === "pre-paginated" || (e == null ? void 0 : e.spineItems.every((t) => t.renditionLayout === "pre-paginated"));
3369
- class pt extends et {
3369
+ class gt extends et {
3370
3370
  constructor(t) {
3371
3371
  super((i) => this.stateSubject.pipe(L(this.destroy$)).subscribe(i)), this.destroy$ = new U(), this.stateSubject = new k(t);
3372
3372
  }
@@ -3413,7 +3413,7 @@ const uo = ({
3413
3413
  const { height: n, width: o } = t, s = o > n;
3414
3414
  return i || (e == null ? void 0 : e.renditionFlow) === "scrolled-continuous" ? !1 : !s && (e == null ? void 0 : e.renditionSpread) === "portrait" ? !0 : s && ((e == null ? void 0 : e.renditionSpread) === void 0 || (e == null ? void 0 : e.renditionSpread) === "auto" || (e == null ? void 0 : e.renditionSpread) === "landscape" || (e == null ? void 0 : e.renditionSpread) === "both");
3415
3415
  };
3416
- class lo extends pt {
3416
+ class lo extends gt {
3417
3417
  constructor() {
3418
3418
  super({
3419
3419
  marginBottom: 0,
@@ -3493,7 +3493,7 @@ class lo extends pt {
3493
3493
  };
3494
3494
  }
3495
3495
  }
3496
- class go extends pt {
3496
+ class po extends gt {
3497
3497
  constructor(t, i) {
3498
3498
  super({
3499
3499
  supportedPageTurnAnimation: ["fade", "none", "slide"],
@@ -3529,7 +3529,7 @@ class go extends pt {
3529
3529
  ).subscribe(this.next.bind(this));
3530
3530
  }
3531
3531
  }
3532
- class po {
3532
+ class go {
3533
3533
  constructor() {
3534
3534
  this._hooks = [], this._hookExecutions = [];
3535
3535
  }
@@ -3560,8 +3560,8 @@ class po {
3560
3560
  (r) => t === r.name
3561
3561
  ).map((r) => {
3562
3562
  let a = () => w(void 0);
3563
- const c = new U(), u = (g) => {
3564
- a = g;
3563
+ const c = new U(), u = (p) => {
3564
+ a = p;
3565
3565
  }, d = () => (c.next(), c.complete(), a() ?? w(void 0)), l = r.runFn({
3566
3566
  // biome-ignore lint/suspicious/noExplicitAny: TODO
3567
3567
  ...n,
@@ -3741,23 +3741,23 @@ const ho = () => (e) => e.pipe(
3741
3741
  spineItem: c,
3742
3742
  cfi: u,
3743
3743
  directionFromLastNavigation: d
3744
- } = r, { navigationSnapThreshold: l, computedPageTurnMode: g } = e.values;
3744
+ } = r, { navigationSnapThreshold: l, computedPageTurnMode: p } = e.values;
3745
3745
  if (c !== void 0) {
3746
- const p = t.get(c);
3747
- if (p) return p;
3746
+ const g = t.get(c);
3747
+ if (g) return g;
3748
3748
  }
3749
3749
  if (typeof c == "number")
3750
3750
  return c > t.items.length - 1 ? t.get(t.items.length - 1) : t.get(0);
3751
3751
  if (u) {
3752
- const p = t.getSpineItemFromCfi(u);
3753
- if (p) return p;
3752
+ const g = t.getSpineItemFromCfi(u);
3753
+ if (g) return g;
3754
3754
  }
3755
- if (a && g === "controlled") {
3756
- const { beginIndex: p, endIndex: h } = n.getVisibleSpineItemsFromPosition({
3755
+ if (a && p === "controlled") {
3756
+ const { beginIndex: g, endIndex: h } = n.getVisibleSpineItemsFromPosition({
3757
3757
  position: a,
3758
3758
  threshold: l,
3759
3759
  restrictToScreen: !1
3760
- }) ?? {}, m = (d === "forward" || d === "anchor" ? h : p) ?? p, y = t.get(m);
3760
+ }) ?? {}, m = (d === "forward" || d === "anchor" ? h : g) ?? g, y = t.get(m);
3761
3761
  if (!y) return;
3762
3762
  const { endPageIndex: f, beginPageIndex: S } = n.getVisiblePagesFromViewportPosition({
3763
3763
  position: a,
@@ -3774,7 +3774,7 @@ const ho = () => (e) => e.pipe(
3774
3774
  }), F = d === "forward" || d === "anchor" ? $ == null ? void 0 : $.beginIndex : $ == null ? void 0 : $.endIndex;
3775
3775
  return t.get(F);
3776
3776
  }
3777
- return a && g === "scrollable" ? n.getSpineItemFromPosition(a) : t.get(0);
3777
+ return a && p === "scrollable" ? n.getSpineItemFromPosition(a) : t.get(0);
3778
3778
  };
3779
3779
  return o.pipe(
3780
3780
  b(({ navigation: r, ...a }) => {
@@ -3826,13 +3826,13 @@ const ho = () => (e) => e.pipe(
3826
3826
  spineItem: u,
3827
3827
  threshold: a,
3828
3828
  restrictToScreen: !1
3829
- }) ?? {}, g = (r.directionFromLastNavigation === "forward" || r.directionFromLastNavigation === "anchor" ? d : l) ?? 0, p = n.getNavigationForSpineItemPage({
3830
- pageIndex: g,
3829
+ }) ?? {}, p = (r.directionFromLastNavigation === "forward" || r.directionFromLastNavigation === "anchor" ? d : l) ?? 0, g = n.getNavigationForSpineItemPage({
3830
+ pageIndex: p,
3831
3831
  spineItemId: u
3832
3832
  }), h = i.getVisiblePagesFromViewportPosition({
3833
- position: p,
3833
+ position: g,
3834
3834
  spineItem: u,
3835
- threshold: 0,
3835
+ threshold: { type: "percentage", value: 0 },
3836
3836
  restrictToScreen: !0
3837
3837
  }), m = (r.directionFromLastNavigation === "forward" || r.directionFromLastNavigation === "anchor" ? h == null ? void 0 : h.beginPageIndex : h == null ? void 0 : h.endPageIndex) ?? 0;
3838
3838
  return i.spineItemLocator.getSpineItemPositionFromPageIndex({
@@ -3884,7 +3884,7 @@ const ho = () => (e) => e.pipe(
3884
3884
  return s ? s.isReady$.pipe(
3885
3885
  H(),
3886
3886
  b((r) => {
3887
- var p, h;
3887
+ var g, h;
3888
3888
  const a = o.getSpineItemSpineLayoutInfo(s), c = e.isPositionWithinSpineItem(
3889
3889
  t.position,
3890
3890
  s
@@ -3898,17 +3898,17 @@ const ho = () => (e) => e.pipe(
3898
3898
  if (m)
3899
3899
  return m.position;
3900
3900
  }
3901
- const g = t.cfi ?? t.paginationBeginCfi;
3902
- if (g !== void 0 && !zt(g) && (u || d || // when spine item is ready dimensions may have not changed but the position
3901
+ const p = t.cfi ?? t.paginationBeginCfi;
3902
+ if (p !== void 0 && !zt(p) && (u || d || // when spine item is ready dimensions may have not changed but the position
3903
3903
  // of dom elements may have!
3904
3904
  r && !t.spineItemIsReady)) {
3905
- const m = i.getNavigationForCfi(g);
3905
+ const m = i.getNavigationForCfi(p);
3906
3906
  if (m)
3907
3907
  return m;
3908
3908
  }
3909
3909
  if (c && l && t.directionFromLastNavigation === "backward") {
3910
3910
  const m = new C({
3911
- x: (((p = t.positionInSpineItem) == null ? void 0 : p.x) ?? 0) + u,
3911
+ x: (((g = t.positionInSpineItem) == null ? void 0 : g.x) ?? 0) + u,
3912
3912
  y: (((h = t.positionInSpineItem) == null ? void 0 : h.y) ?? 0) + d
3913
3913
  });
3914
3914
  return i.getNavigationFromSpineItemPosition({
@@ -3954,7 +3954,7 @@ const ho = () => (e) => e.pipe(
3954
3954
  if (u === e.spineItemTop && c === e.spineItemHeight && !d)
3955
3955
  return o.getNavigationForSpineIndexOrId(a);
3956
3956
  if (u !== e.spineItemTop) {
3957
- const g = t.getSafeSpineItemPositionFromUnsafeSpineItemPosition(
3957
+ const p = t.getSafeSpineItemPositionFromUnsafeSpineItemPosition(
3958
3958
  e.positionInSpineItem ?? new C({
3959
3959
  x: 0,
3960
3960
  y: 0
@@ -3962,18 +3962,18 @@ const ho = () => (e) => e.pipe(
3962
3962
  a
3963
3963
  );
3964
3964
  return t.getSpinePositionFromSpineItemPosition({
3965
- spineItemPosition: g,
3965
+ spineItemPosition: p,
3966
3966
  spineItem: a
3967
3967
  });
3968
3968
  }
3969
3969
  if (u === e.spineItemTop && c !== e.spineItemHeight) {
3970
- const g = (e.spineItemHeight ?? l.y) - l.y, p = new C({
3971
- y: e.directionFromLastNavigation === "backward" ? c - g : l.y,
3970
+ const p = (e.spineItemHeight ?? l.y) - l.y, g = new C({
3971
+ y: e.directionFromLastNavigation === "backward" ? c - p : l.y,
3972
3972
  x: e.position.x
3973
3973
  });
3974
3974
  if (d) {
3975
3975
  const h = t.getSafeSpineItemPositionFromUnsafeSpineItemPosition(
3976
- p,
3976
+ g,
3977
3977
  a
3978
3978
  );
3979
3979
  return t.getSpinePositionFromSpineItemPosition({
@@ -3984,7 +3984,7 @@ const ho = () => (e) => e.pipe(
3984
3984
  if (!d) {
3985
3985
  if (!(e.position.y < u)) {
3986
3986
  const m = new C({
3987
- y: c - g,
3987
+ y: c - p,
3988
3988
  x: e.position.x
3989
3989
  });
3990
3990
  return t.getSpinePositionFromSpineItemPosition({
@@ -4172,7 +4172,7 @@ class Fo extends Y {
4172
4172
  v(d, u)
4173
4173
  )
4174
4174
  ))
4175
- ), g = v(
4175
+ ), p = v(
4176
4176
  l,
4177
4177
  d
4178
4178
  ).pipe(
@@ -4217,14 +4217,14 @@ class Fo extends Y {
4217
4217
  }),
4218
4218
  b(({ navigation: f }) => f),
4219
4219
  j()
4220
- ), p = mo(
4220
+ ), g = mo(
4221
4221
  i,
4222
4222
  this.navigationSubject,
4223
4223
  a
4224
4224
  ), h = v(
4225
- g,
4225
+ p,
4226
4226
  u,
4227
- p
4227
+ g
4228
4228
  ), m = (f) => f.pipe(
4229
4229
  T(([S, I]) => {
4230
4230
  To.info(
@@ -4353,7 +4353,7 @@ class Do extends Y {
4353
4353
  height: 100%;
4354
4354
  width: 100%;
4355
4355
  position: relative;
4356
- `, l.className = `${gt}-controlled-navigator`, l.innerHTML = "", l.appendChild(d), this.viewport.value.element.appendChild(l), this.element$.next(l);
4356
+ `, l.className = `${pt}-controlled-navigator`, l.innerHTML = "", l.appendChild(d), this.viewport.value.element.appendChild(l), this.element$.next(l);
4357
4357
  })
4358
4358
  ), a = t.watch([
4359
4359
  "computedPageTurnDirection",
@@ -4392,7 +4392,7 @@ class Do extends Y {
4392
4392
  w(null).pipe(
4393
4393
  $t(() => {
4394
4394
  if ((d == null ? void 0 : d.type) !== "manualAdjust") return w(!1);
4395
- const g = d.animation === "snap" ? t.values.snapAnimationDuration : t.values.computedPageTurnAnimationDuration, p = d.animation === "snap" ? "slide" : t.values.computedPageTurnAnimation;
4395
+ const p = d.animation === "snap" ? t.values.snapAnimationDuration : t.values.computedPageTurnAnimationDuration, g = d.animation === "snap" ? "slide" : t.values.computedPageTurnAnimation;
4396
4396
  return w(d).pipe(
4397
4397
  /**
4398
4398
  * @important
@@ -4405,12 +4405,12 @@ class Do extends Y {
4405
4405
  d.shouldAnimate ? wt(1, rt) : Pt,
4406
4406
  T((h) => {
4407
4407
  const m = this.element$.getValue();
4408
- h.shouldAnimate ? p === "fade" ? (m.style.setProperty(
4408
+ h.shouldAnimate ? g === "fade" ? (m.style.setProperty(
4409
4409
  "transition",
4410
- `opacity ${g / 2}ms`
4411
- ), m.style.setProperty("opacity", "0")) : (d.animation === "snap" || p === "slide") && (m.style.setProperty(
4410
+ `opacity ${p / 2}ms`
4411
+ ), m.style.setProperty("opacity", "0")) : (d.animation === "snap" || g === "slide") && (m.style.setProperty(
4412
4412
  "transition",
4413
- `transform ${g}ms`
4413
+ `transform ${p}ms`
4414
4414
  ), m.style.setProperty("opacity", "1")) : (m.style.setProperty("transition", "none"), m.style.setProperty("opacity", "1"));
4415
4415
  }),
4416
4416
  /**
@@ -4422,16 +4422,16 @@ class Do extends Y {
4422
4422
  * not the value set by `setProperty`
4423
4423
  */
4424
4424
  T((h) => {
4425
- p !== "fade" && this.setViewportPosition(h.position);
4425
+ g !== "fade" && this.setViewportPosition(h.position);
4426
4426
  }),
4427
- d.shouldAnimate ? wt(g / 2, rt) : Pt,
4427
+ d.shouldAnimate ? wt(p / 2, rt) : Pt,
4428
4428
  T((h) => {
4429
4429
  const m = this.element$.getValue();
4430
- p === "fade" && (this.setViewportPosition(h.position), m.style.setProperty("opacity", "1"));
4430
+ g === "fade" && (this.setViewportPosition(h.position), m.style.setProperty("opacity", "1"));
4431
4431
  }),
4432
- d.shouldAnimate ? wt(g / 2, rt) : Pt,
4432
+ d.shouldAnimate ? wt(p / 2, rt) : Pt,
4433
4433
  T((h) => {
4434
- p === "fade" && this.setViewportPosition(h.position);
4434
+ g === "fade" && this.setViewportPosition(h.position);
4435
4435
  })
4436
4436
  );
4437
4437
  }),
@@ -4470,13 +4470,13 @@ class Do extends Y {
4470
4470
  return Ro(o);
4471
4471
  }
4472
4472
  }
4473
- class Oo extends pt {
4473
+ class Oo extends gt {
4474
4474
  constructor(t, i, n, o, s) {
4475
4475
  super({
4476
4476
  element: void 0
4477
4477
  }), this.viewport = t, this.settings = i, this.hookManager = n, this.spine = o, this.context = s, this.navigateSubject = new U(), this.scrollingSubject = new k(!1), this.isScrolling$ = this.scrollingSubject.asObservable(), this.setViewportPosition = ({ position: l }) => {
4478
- const g = this.value.element;
4479
- this.scrollingSubject.next(!0), g == null || g.scrollTo({
4478
+ const p = this.value.element;
4479
+ this.scrollingSubject.next(!0), p == null || p.scrollTo({
4480
4480
  left: l.x,
4481
4481
  top: l.y,
4482
4482
  behavior: "instant"
@@ -4491,21 +4491,21 @@ class Oo extends pt {
4491
4491
  _t(["rootElement"]),
4492
4492
  T(({ rootElement: l }) => {
4493
4493
  if (!l) return;
4494
- const g = document.createElement("div");
4495
- g.style.cssText = `
4494
+ const p = document.createElement("div");
4495
+ p.style.cssText = `
4496
4496
  height: 100%;
4497
4497
  width: 100%;
4498
4498
  position: relative;
4499
4499
  overflow-y: scroll;
4500
4500
  overflow-x: hidden;
4501
- `, g.className = `${gt}-scroll-navigator`, g.appendChild(this.viewport.value.element), l.appendChild(g), this.update({ element: g });
4501
+ `, p.className = `${pt}-scroll-navigator`, p.appendChild(this.viewport.value.element), l.appendChild(p), this.update({ element: p });
4502
4502
  })
4503
4503
  ), a = B([
4504
4504
  i.watch(["computedPageTurnMode"]),
4505
4505
  this.watch("element")
4506
4506
  ]).pipe(
4507
- T(([{ computedPageTurnMode: l }, g]) => {
4508
- g && (l === "scrollable" ? g.style.display = "block" : g.style.display = "contents");
4507
+ T(([{ computedPageTurnMode: l }, p]) => {
4508
+ p && (l === "scrollable" ? p.style.display = "block" : p.style.display = "contents");
4509
4509
  })
4510
4510
  ), c = this.navigateSubject.pipe(T(this.setViewportPosition));
4511
4511
  this.isNavigating$ = this.navigateSubject.pipe(
@@ -4531,7 +4531,7 @@ class Oo extends pt {
4531
4531
  this.isScrolling$
4532
4532
  ]).pipe(
4533
4533
  b(
4534
- ([l, g]) => l || g
4534
+ ([l, p]) => l || p
4535
4535
  ),
4536
4536
  tt(1)
4537
4537
  );
@@ -4540,12 +4540,12 @@ class Oo extends pt {
4540
4540
  P(
4541
4541
  (l) => i.watch(["computedPageTurnMode"]).pipe(
4542
4542
  P(
4543
- ({ computedPageTurnMode: g }) => g === "controlled" ? lt : G(l, "scroll").pipe(
4543
+ ({ computedPageTurnMode: p }) => p === "controlled" ? lt : G(l, "scroll").pipe(
4544
4544
  D(d),
4545
4545
  R(
4546
- ([, p]) => !p
4546
+ ([, g]) => !g
4547
4547
  ),
4548
- b(([p]) => p)
4548
+ b(([g]) => g)
4549
4549
  )
4550
4550
  )
4551
4551
  )
@@ -4571,7 +4571,7 @@ class Oo extends pt {
4571
4571
  }) : new M({ x: 0, y: 0 });
4572
4572
  }
4573
4573
  }
4574
- const ge = (e, t, i) => {
4574
+ const pe = (e, t, i) => {
4575
4575
  const n = i - e, o = i * (t * e) / (i || 1);
4576
4576
  return Math.max(0, Math.min(n, o));
4577
4577
  }, Ut = (e, t) => (t || 0) === 0 || (e || 0) === 0 ? 1 : Math.floor(Math.max(1, e / t)), xt = (e, t, i) => {
@@ -4596,7 +4596,7 @@ const ge = (e, t, i) => {
4596
4596
  isUsingVerticalWriting: n
4597
4597
  }) => {
4598
4598
  if (n) {
4599
- const s = ge(
4599
+ const s = pe(
4600
4600
  i.getPageSize().height,
4601
4601
  e,
4602
4602
  t.height
@@ -4606,7 +4606,7 @@ const ge = (e, t, i) => {
4606
4606
  y: s
4607
4607
  });
4608
4608
  }
4609
- const o = ge(
4609
+ const o = pe(
4610
4610
  i.getPageSize().width,
4611
4611
  e,
4612
4612
  t.width
@@ -4635,7 +4635,7 @@ const ge = (e, t, i) => {
4635
4635
  position: d,
4636
4636
  isUsingVerticalWriting: l
4637
4637
  }) => {
4638
- const g = e.getPageSize().width, p = e.getPageSize().height, h = i({
4638
+ const p = e.getPageSize().width, g = e.getPageSize().height, h = i({
4639
4639
  spineItemPosition: d,
4640
4640
  itemHeight: u,
4641
4641
  itemWidth: c
@@ -4646,7 +4646,7 @@ const ge = (e, t, i) => {
4646
4646
  context: e,
4647
4647
  settings: t
4648
4648
  });
4649
- return l ? a(d.y, p, y) : a(m, g, y);
4649
+ return l ? a(d.y, g, y) : a(m, p, y);
4650
4650
  }, o = (c, u, d) => {
4651
4651
  var h;
4652
4652
  let l;
@@ -4656,12 +4656,12 @@ const ge = (e, t, i) => {
4656
4656
  const m = c ? $i(c, u) : void 0;
4657
4657
  l = (m == null ? void 0 : m.getBoundingClientRect().x) || l;
4658
4658
  }
4659
- const g = ((h = d.layout.layoutInfo) == null ? void 0 : h.width) || 0, p = e.getPageSize().width;
4659
+ const p = ((h = d.layout.layoutInfo) == null ? void 0 : h.width) || 0, g = e.getPageSize().width;
4660
4660
  if (l !== void 0) {
4661
4661
  const m = xt(
4662
4662
  l,
4663
- p,
4664
- g
4663
+ g,
4664
+ p
4665
4665
  );
4666
4666
  return new C({ x: m, y: 0 });
4667
4667
  }
@@ -4680,18 +4680,18 @@ const ge = (e, t, i) => {
4680
4680
  )
4681
4681
  });
4682
4682
  }, r = (c, u, d) => {
4683
- const l = o(c, u, d), { height: g, width: p } = d.layout.layoutInfo;
4683
+ const l = o(c, u, d), { height: p, width: g } = d.layout.layoutInfo;
4684
4684
  return l ? n({
4685
4685
  isUsingVerticalWriting: !!d.isUsingVerticalWriting(),
4686
4686
  position: l,
4687
- itemHeight: g,
4688
- itemWidth: p
4687
+ itemHeight: p,
4688
+ itemWidth: g
4689
4689
  }) : void 0;
4690
4690
  }, a = (c, u, d) => {
4691
- const l = [...Array(d)].map((g, p) => p * u);
4691
+ const l = [...Array(d)].map((p, g) => g * u);
4692
4692
  return c <= 0 ? 0 : c >= d * u ? d - 1 : Math.max(
4693
4693
  0,
4694
- l.findIndex((g) => c < g + u)
4694
+ l.findIndex((p) => c < p + u)
4695
4695
  );
4696
4696
  };
4697
4697
  return {
@@ -4739,7 +4739,7 @@ const ge = (e, t, i) => {
4739
4739
  }) => {
4740
4740
  const s = e % n !== 0 ? e - i : e;
4741
4741
  return new M({ x: s, y: t });
4742
- }, pe = ({
4742
+ }, ge = ({
4743
4743
  position: e,
4744
4744
  isRTL: t,
4745
4745
  pageSizeHeight: i,
@@ -4930,39 +4930,39 @@ const ge = (e, t, i) => {
4930
4930
  }) => {
4931
4931
  const s = Vo({ context: e, settings: n });
4932
4932
  return {
4933
- getNavigationForUrl: (g) => Uo({
4933
+ getNavigationForUrl: (p) => Uo({
4934
4934
  context: e,
4935
4935
  spineItemsManager: t,
4936
4936
  spineLocator: i,
4937
- url: g,
4937
+ url: p,
4938
4938
  pageSizeWidth: e.getPageSize().width,
4939
4939
  visibleAreaRectWidth: e.state.visibleAreaRect.width
4940
4940
  }),
4941
- getNavigationForSpineItemPage: (g) => jo({
4942
- ...g,
4941
+ getNavigationForSpineItemPage: (p) => jo({
4942
+ ...p,
4943
4943
  context: e,
4944
4944
  spineItemsManager: t,
4945
4945
  spineItemNavigationResolver: s,
4946
4946
  spineLocator: i
4947
4947
  }),
4948
- getNavigationFromSpineItemPosition: (g) => Ho({
4949
- ...g,
4948
+ getNavigationFromSpineItemPosition: (p) => Ho({
4949
+ ...p,
4950
4950
  spineItemLocator: i.spineItemLocator,
4951
4951
  spineLocator: i,
4952
4952
  context: e
4953
4953
  }),
4954
- getNavigationForCfi: (g) => {
4955
- const p = t.getSpineItemFromCfi(g), { node: h, offset: m = 0 } = De({
4956
- cfi: g,
4954
+ getNavigationForCfi: (p) => {
4955
+ const g = t.getSpineItemFromCfi(p), { node: h, offset: m = 0 } = De({
4956
+ cfi: p,
4957
4957
  spineItemsManager: t
4958
4958
  }) || {};
4959
- if (!p) {
4960
- V.warn(Eo, `unable to detect item id from cfi ${g}`);
4959
+ if (!g) {
4960
+ V.warn(Eo, `unable to detect item id from cfi ${p}`);
4961
4961
  return;
4962
4962
  }
4963
- const y = h ? s.getNavigationFromNode(p, h, m) : new C({ x: 0, y: 0 }), f = i.getSpinePositionFromSpineItemPosition({
4963
+ const y = h ? s.getNavigationFromNode(g, h, m) : new C({ x: 0, y: 0 }), f = i.getSpinePositionFromSpineItemPosition({
4964
4964
  spineItemPosition: y,
4965
- spineItem: p
4965
+ spineItem: g
4966
4966
  });
4967
4967
  return it({
4968
4968
  position: f,
@@ -4970,10 +4970,10 @@ const ge = (e, t, i) => {
4970
4970
  visibleAreaRectWidth: e.state.visibleAreaRect.width
4971
4971
  });
4972
4972
  },
4973
- getNavigationForLastPage: (g) => {
4974
- const p = s.getNavigationForLastPage(g), h = i.getSpinePositionFromSpineItemPosition({
4975
- spineItemPosition: p,
4976
- spineItem: g
4973
+ getNavigationForLastPage: (p) => {
4974
+ const g = s.getNavigationForLastPage(p), h = i.getSpinePositionFromSpineItemPosition({
4975
+ spineItemPosition: g,
4976
+ spineItem: p
4977
4977
  });
4978
4978
  return it({
4979
4979
  position: h,
@@ -4981,10 +4981,10 @@ const ge = (e, t, i) => {
4981
4981
  visibleAreaRectWidth: e.state.visibleAreaRect.width
4982
4982
  });
4983
4983
  },
4984
- getNavigationForSpineIndexOrId: (g) => {
4985
- const p = t.get(g);
4986
- if (p) {
4987
- const h = i.getSpinePositionFromSpineItem(p);
4984
+ getNavigationForSpineIndexOrId: (p) => {
4985
+ const g = t.get(p);
4986
+ if (g) {
4987
+ const h = i.getSpinePositionFromSpineItem(g);
4988
4988
  return it({
4989
4989
  position: h,
4990
4990
  pageSizeWidth: e.getPageSize().width,
@@ -4993,14 +4993,14 @@ const ge = (e, t, i) => {
4993
4993
  }
4994
4994
  return new M({ x: 0, y: 0 });
4995
4995
  },
4996
- getNavigationForPosition: (g) => Ht({
4997
- viewportPosition: g,
4996
+ getNavigationForPosition: (p) => Ht({
4997
+ viewportPosition: p,
4998
4998
  context: e,
4999
4999
  spineItemNavigationResolver: s,
5000
5000
  spineLocator: i
5001
5001
  }),
5002
- getMostPredominantNavigationForPosition: (g) => {
5003
- const p = n.values.computedPageTurnDirection, h = 0.5, m = p === "horizontal" ? g.x + e.state.visibleAreaRect.width * h : 0, y = p === "horizontal" ? 0 : g.y + e.state.visibleAreaRect.height * h, f = pe({
5002
+ getMostPredominantNavigationForPosition: (p) => {
5003
+ const g = n.values.computedPageTurnDirection, h = 0.5, m = g === "horizontal" ? p.x + e.state.visibleAreaRect.width * h : 0, y = g === "horizontal" ? 0 : p.y + e.state.visibleAreaRect.height * h, f = ge({
5004
5004
  position: new M({
5005
5005
  x: m,
5006
5006
  y
@@ -5018,18 +5018,18 @@ const ge = (e, t, i) => {
5018
5018
  viewportPosition: f
5019
5019
  });
5020
5020
  },
5021
- getAdjustedPositionWithSafeEdge: (g) => pe({
5022
- position: g,
5021
+ getAdjustedPositionWithSafeEdge: (p) => ge({
5022
+ position: p,
5023
5023
  isRTL: e.isRTL(),
5024
5024
  pageSizeHeight: e.getPageSize().height,
5025
5025
  visibleAreaRectWidth: e.state.visibleAreaRect.width,
5026
5026
  spineItemsManager: t,
5027
5027
  spine: o
5028
5028
  }),
5029
- isNavigationGoingForwardFrom: (g, p) => n.values.computedPageTurnDirection === "vertical" ? g.y > p.y : g.x > p.x,
5030
- arePositionsDifferent: (g, p) => g.x !== p.x || g.y !== p.y,
5031
- getAdjustedPositionForSpread: (g) => it({
5032
- position: g,
5029
+ isNavigationGoingForwardFrom: (p, g) => n.values.computedPageTurnDirection === "vertical" ? p.y > g.y : p.x > g.x,
5030
+ arePositionsDifferent: (p, g) => p.x !== g.x || p.y !== g.y,
5031
+ getAdjustedPositionForSpread: (p) => it({
5032
+ position: p,
5033
5033
  pageSizeWidth: e.getPageSize().width,
5034
5034
  visibleAreaRectWidth: e.state.visibleAreaRect.width
5035
5035
  }),
@@ -5067,13 +5067,13 @@ const ge = (e, t, i) => {
5067
5067
  n,
5068
5068
  d,
5069
5069
  a
5070
- ), g = v(
5070
+ ), p = v(
5071
5071
  r,
5072
5072
  l.navigation$
5073
- ), p = new Fo(
5073
+ ), g = new Fo(
5074
5074
  o,
5075
5075
  t,
5076
- g,
5076
+ p,
5077
5077
  u,
5078
5078
  d,
5079
5079
  c,
@@ -5083,7 +5083,7 @@ const ge = (e, t, i) => {
5083
5083
  u.isNavigating$,
5084
5084
  d.isNavigating$,
5085
5085
  a.isLocked$,
5086
- p.locker.isLocked$
5086
+ g.locker.isLocked$
5087
5087
  ]).pipe(
5088
5088
  q((f) => f.some((S) => S) ? "busy" : "free"),
5089
5089
  Z(),
@@ -5091,10 +5091,10 @@ const ge = (e, t, i) => {
5091
5091
  );
5092
5092
  return {
5093
5093
  destroy: () => {
5094
- l.destroy(), u.destroy(), p.destroy();
5094
+ l.destroy(), u.destroy(), g.destroy();
5095
5095
  },
5096
- getNavigation: () => p.navigation,
5097
- internalNavigator: p,
5096
+ getNavigation: () => g.navigation,
5097
+ internalNavigator: g,
5098
5098
  scrollNavigationController: d,
5099
5099
  controlledNavigationController: u,
5100
5100
  locker: a,
@@ -5106,10 +5106,10 @@ const ge = (e, t, i) => {
5106
5106
  return a.lock();
5107
5107
  },
5108
5108
  navigationResolver: c,
5109
- navigation$: p.navigation$
5109
+ navigation$: g.navigation$
5110
5110
  };
5111
5111
  };
5112
- class Xo extends pt {
5112
+ class Xo extends gt {
5113
5113
  constructor(t, i) {
5114
5114
  super({
5115
5115
  beginPageIndexInSpineItem: void 0,
@@ -5141,19 +5141,19 @@ class qo extends Y {
5141
5141
  }) => this.spine.locator.getVisiblePagesFromViewportPosition({
5142
5142
  spineItem: u,
5143
5143
  position: d,
5144
- threshold: 0.5
5144
+ threshold: { type: "percentage", value: 0.5 }
5145
5145
  });
5146
5146
  return this.context.bridgeEvent.navigationUnlocked$.pipe(
5147
5147
  he(1),
5148
5148
  D(this.context.bridgeEvent.navigation$),
5149
5149
  T(([, u]) => {
5150
5150
  const { position: d } = u, l = this.pagination.value, {
5151
- beginIndex: g,
5152
- endIndex: p
5151
+ beginIndex: p,
5152
+ endIndex: g
5153
5153
  } = this.spine.locator.getVisibleSpineItemsFromPosition({
5154
5154
  position: d,
5155
- threshold: 0.5
5156
- }) ?? {}, h = this.spineItemsManager.get(g), m = this.spineItemsManager.get(p);
5155
+ threshold: { type: "percentage", value: 0.5 }
5156
+ }) ?? {}, h = this.spineItemsManager.get(p), m = this.spineItemsManager.get(g);
5157
5157
  if (!h || !m) return;
5158
5158
  const y = l.beginCfi, f = l.endCfi, { beginPageIndex: S = 0 } = c({
5159
5159
  spineItem: h,
@@ -5161,16 +5161,16 @@ class qo extends Y {
5161
5161
  }) ?? {}, { endPageIndex: I = 0 } = c({
5162
5162
  spineItem: m,
5163
5163
  position: d
5164
- }) ?? {}, x = y === void 0 || zt(y) || l.beginSpineItemIndex !== g, $ = l.endSpineItemIndex !== p || f === void 0 || zt(f), F = x ? ft(h.item) : y, A = $ ? ft(m.item) : f, O = h.numberOfPages, _ = m.numberOfPages;
5164
+ }) ?? {}, x = y === void 0 || zt(y) || l.beginSpineItemIndex !== p, $ = l.endSpineItemIndex !== g || f === void 0 || zt(f), F = x ? ft(h.item) : y, A = $ ? ft(m.item) : f, O = h.numberOfPages, _ = m.numberOfPages;
5165
5165
  this.pagination.update({
5166
5166
  beginCfi: F,
5167
5167
  beginNumberOfPagesInSpineItem: O,
5168
5168
  beginPageIndexInSpineItem: S,
5169
- beginSpineItemIndex: g,
5169
+ beginSpineItemIndex: p,
5170
5170
  endCfi: A,
5171
5171
  endNumberOfPagesInSpineItem: _,
5172
5172
  endPageIndexInSpineItem: I,
5173
- endSpineItemIndex: p,
5173
+ endSpineItemIndex: g,
5174
5174
  navigationId: u.id
5175
5175
  });
5176
5176
  })
@@ -5187,16 +5187,16 @@ class qo extends Y {
5187
5187
  } = this.pagination.value;
5188
5188
  if (d === void 0 || l === void 0 || c === void 0 || u === void 0)
5189
5189
  return;
5190
- const g = this.spineItemsManager.get(c), p = this.spineItemsManager.get(u);
5191
- g === void 0 || p === void 0 || this.pagination.update({
5190
+ const p = this.spineItemsManager.get(c), g = this.spineItemsManager.get(u);
5191
+ p === void 0 || g === void 0 || this.pagination.update({
5192
5192
  beginCfi: Wt({
5193
5193
  pageIndex: d,
5194
- spineItem: g,
5194
+ spineItem: p,
5195
5195
  spine: this.spine
5196
5196
  }),
5197
5197
  endCfi: Wt({
5198
5198
  pageIndex: l,
5199
- spineItem: p,
5199
+ spineItem: g,
5200
5200
  spine: this.spine
5201
5201
  })
5202
5202
  });
@@ -5290,7 +5290,7 @@ class Zo extends Yo {
5290
5290
  pageTurnAnimationDuration: void 0,
5291
5291
  pageTurnMode: "controlled",
5292
5292
  snapAnimationDuration: 300,
5293
- navigationSnapThreshold: 0.3,
5293
+ navigationSnapThreshold: { type: "pixels", value: 80 },
5294
5294
  numberOfAdjacentSpineItemToPreLoad: 3
5295
5295
  };
5296
5296
  }
@@ -5306,7 +5306,7 @@ class Go extends Y {
5306
5306
  const l = N(
5307
5307
  (x = this.lastLayout) == null ? void 0 : x.pageSize,
5308
5308
  this.context.getPageSize()
5309
- ) ? this.lastLayout : void 0, { width: g, height: p } = l ?? {}, { width: h = g, height: m = p } = d ?? {}, { width: y, height: f } = this.context.getPageSize(), S = this.validateDimension(
5309
+ ) ? this.lastLayout : void 0, { width: p, height: g } = l ?? {}, { width: h = p, height: m = g } = d ?? {}, { width: y, height: f } = this.context.getPageSize(), S = this.validateDimension(
5310
5310
  h ?? y,
5311
5311
  y,
5312
5312
  c
@@ -5353,9 +5353,9 @@ class Go extends Y {
5353
5353
  l.pipe(
5354
5354
  this.applyDimsAfterLayout(a),
5355
5355
  b(
5356
- (g) => ({
5356
+ (p) => ({
5357
5357
  type: "end",
5358
- data: g
5358
+ data: p
5359
5359
  })
5360
5360
  )
5361
5361
  )
@@ -5404,10 +5404,10 @@ class Ue extends Y {
5404
5404
  constructor(t, i, n, o, s, r) {
5405
5405
  var u, d;
5406
5406
  super(), this.item = t, this.parentElement = i, this.context = n, this.settings = o, this.hookManager = s, this.index = r, this.getBoundingRectOfElementFromSelector = (l) => {
5407
- var p, h, m, y;
5408
- const g = this.renderer.getDocumentFrame();
5409
- if (g && g instanceof HTMLIFrameElement && l)
5410
- return l.startsWith("#") ? (h = (p = g.contentDocument) == null ? void 0 : p.getElementById(l.replace("#", ""))) == null ? void 0 : h.getBoundingClientRect() : (y = (m = g.contentDocument) == null ? void 0 : m.querySelector(l)) == null ? void 0 : y.getBoundingClientRect();
5407
+ var g, h, m, y;
5408
+ const p = this.renderer.getDocumentFrame();
5409
+ if (p && p instanceof HTMLIFrameElement && l)
5410
+ return l.startsWith("#") ? (h = (g = p.contentDocument) == null ? void 0 : g.getElementById(l.replace("#", ""))) == null ? void 0 : h.getBoundingClientRect() : (y = (m = p.contentDocument) == null ? void 0 : m.querySelector(l)) == null ? void 0 : y.getBoundingClientRect();
5411
5411
  }, this.load = () => {
5412
5412
  this.renderer.load();
5413
5413
  }, this.unload = () => {
@@ -5441,7 +5441,7 @@ class Ue extends Y {
5441
5441
  this.settings
5442
5442
  ), this.isReady$ = this.layout.layoutProcess$.pipe(
5443
5443
  di(this.renderer.isLoaded$),
5444
- q(([l, g]) => !!(l.type === "end" && g)),
5444
+ q(([l, p]) => !!(l.type === "end" && p)),
5445
5445
  Se(!1),
5446
5446
  Z(),
5447
5447
  z((l) => {
@@ -5522,13 +5522,13 @@ const Ko = (e, t, i) => {
5522
5522
  bottom: e.y + t.height,
5523
5523
  right: e.x + t.width
5524
5524
  });
5525
- class es extends pt {
5525
+ class es extends gt {
5526
5526
  constructor(t, i, n, o, s, r) {
5527
5527
  super({ pages: [] }), this.spineLayout = t, this.spineItemsManager = i, this.spineItemLocator = n, this.context = o, this.locator = s, this.viewport = r, this.layout$ = t.layout$.pipe(
5528
5528
  D(r),
5529
5529
  P(([, { pageSize: a }]) => {
5530
5530
  const c = i.items.reduce(
5531
- (d, l, g) => {
5531
+ (d, l, p) => {
5532
5532
  const h = new Array(l.numberOfPages).fill(void 0).map((m, y) => {
5533
5533
  const f = n.getSpineItemPositionFromPageIndex({
5534
5534
  spineItem: l,
@@ -5552,7 +5552,7 @@ class es extends pt {
5552
5552
  x: f.x,
5553
5553
  y: f.y
5554
5554
  }),
5555
- itemIndex: g,
5555
+ itemIndex: p,
5556
5556
  absolutePageIndex: d.length + y,
5557
5557
  spineItem: l,
5558
5558
  pageIndex: y
@@ -5564,8 +5564,8 @@ class es extends pt {
5564
5564
  );
5565
5565
  return B(
5566
5566
  c.map((d) => {
5567
- const { spineItem: l, ...g } = d;
5568
- return new et((p) => {
5567
+ const { spineItem: l, ...p } = d;
5568
+ return new et((g) => {
5569
5569
  var y, f;
5570
5570
  const h = (y = d.spineItem.renderer) == null ? void 0 : y.getDocumentFrame();
5571
5571
  let m;
@@ -5573,7 +5573,7 @@ class es extends pt {
5573
5573
  h.contentWindow.document.body !== null && (m = vi(
5574
5574
  h.contentWindow.document,
5575
5575
  d.layout
5576
- )), p.next({ ...g, firstVisibleNode: m });
5576
+ )), g.next({ ...p, firstVisibleNode: m });
5577
5577
  });
5578
5578
  })
5579
5579
  );
@@ -5625,10 +5625,10 @@ const ns = ({
5625
5625
  viewport: c
5626
5626
  }) => {
5627
5627
  let u = i.getPageSize().width, d = "none";
5628
- const l = e % c.absoluteViewport.width === 0, g = r === n.items.length - 1;
5628
+ const l = e % c.absoluteViewport.width === 0, p = r === n.items.length - 1;
5629
5629
  if (i.state.isUsingSpreadMode) {
5630
- !o && a.renditionLayout === "reflowable" && !g && (u = i.getPageSize().width * 2), !o && a.renditionLayout === "reflowable" && g && l && (u = i.getPageSize().width * 2);
5631
- const h = l && g && o;
5630
+ !o && a.renditionLayout === "reflowable" && !p && (u = i.getPageSize().width * 2), !o && a.renditionLayout === "reflowable" && p && l && (u = i.getPageSize().width * 2);
5631
+ const h = l && p && o;
5632
5632
  a.item.pageSpreadRight && l && !i.isRTL() || a.item.pageSpreadLeft && l && i.isRTL() ? (d = "before", u = i.getPageSize().width * 2) : h && (i.isRTL() ? d = "before" : d = "after", u = i.getPageSize().width * 2);
5633
5633
  }
5634
5634
  return a.layout.layout({
@@ -5727,15 +5727,15 @@ class os extends Y {
5727
5727
  ti(
5728
5728
  (u, d, l) => u.pipe(
5729
5729
  Kt(
5730
- ({ horizontalOffset: g, verticalOffset: p }) => ns({
5730
+ ({ horizontalOffset: p, verticalOffset: g }) => ns({
5731
5731
  context: this.context,
5732
- horizontalOffset: g,
5732
+ horizontalOffset: p,
5733
5733
  index: l,
5734
5734
  isGloballyPrePaginated: a,
5735
5735
  item: d,
5736
5736
  settings: this.settings,
5737
5737
  spineItemsManager: this.spineItemsManager,
5738
- verticalOffset: p,
5738
+ verticalOffset: g,
5739
5739
  viewport: o
5740
5740
  }).pipe(
5741
5741
  b(
@@ -5806,11 +5806,11 @@ class ss extends Y {
5806
5806
  Mt(this.context.bridgeEvent.viewportFree$),
5807
5807
  D(this.context.bridgeEvent.navigation$, r),
5808
5808
  b(([, u, d]) => {
5809
- const { numberOfAdjacentSpineItemToPreLoad: l } = o.values, { beginIndex: g = 0, endIndex: p = 0 } = n.getVisibleSpineItemsFromPosition({
5809
+ const { numberOfAdjacentSpineItemToPreLoad: l } = o.values, { beginIndex: p = 0, endIndex: g = 0 } = n.getVisibleSpineItemsFromPosition({
5810
5810
  position: u.position,
5811
- threshold: 0,
5811
+ threshold: { type: "percentage", value: 0 },
5812
5812
  useAbsoluteViewport: !1
5813
- }) || {}, h = g - l, m = p + l, y = Array.from(
5813
+ }) || {}, h = p - l, m = g + l, y = Array.from(
5814
5814
  { length: m - h + 1 },
5815
5815
  (S, I) => h + I
5816
5816
  ), f = [...d, ...y];
@@ -5901,15 +5901,15 @@ const cs = ({
5901
5901
  threshold: o
5902
5902
  }) => {
5903
5903
  const s = i / t, r = n / e;
5904
- return s >= o && r >= o;
5904
+ return o.type === "percentage" ? s >= o.value && r >= o.value : i >= o.value && n >= o.value;
5905
5905
  }, ds = ({
5906
5906
  visibleWidthOfItem: e,
5907
5907
  visibleHeightOfItem: t,
5908
5908
  threshold: i,
5909
5909
  viewportPosition: n
5910
5910
  }) => {
5911
- const o = e / n.width;
5912
- return t / n.height >= i && o >= i;
5911
+ const o = e / n.width, s = t / n.height;
5912
+ return i.type === "percentage" ? s >= i.value && o >= i.value : t >= i.value && e >= i.value;
5913
5913
  }, Ee = ({
5914
5914
  itemPosition: {
5915
5915
  bottom: e,
@@ -5923,21 +5923,21 @@ const cs = ({
5923
5923
  viewportPosition: a,
5924
5924
  restrictToScreen: c
5925
5925
  }) => {
5926
- const u = a.x, d = a.x + (a.width - 1), l = a.y, g = Math.max(
5926
+ const u = a.x, d = a.x + (a.width - 1), l = a.y, p = Math.max(
5927
5927
  a.y + (a.height - 1),
5928
5928
  0
5929
- ), p = Math.max(
5929
+ ), g = Math.max(
5930
5930
  0,
5931
5931
  Math.min(i, d) - Math.max(t, u)
5932
5932
  ), h = Math.max(
5933
5933
  0,
5934
- Math.min(e, g) - Math.max(n, l)
5934
+ Math.min(e, p) - Math.max(n, l)
5935
5935
  );
5936
- if (p <= 0 || h <= 0) return { visible: !1 };
5936
+ if (g <= 0 || h <= 0) return { visible: !1 };
5937
5937
  const y = ds({
5938
5938
  threshold: r,
5939
5939
  visibleHeightOfItem: h,
5940
- visibleWidthOfItem: p,
5940
+ visibleWidthOfItem: g,
5941
5941
  viewportPosition: a
5942
5942
  });
5943
5943
  return c ? { visible: y } : {
@@ -5946,7 +5946,7 @@ const cs = ({
5946
5946
  itemWidth: o,
5947
5947
  threshold: r,
5948
5948
  visibleHeightOfItem: h,
5949
- visibleWidthOfItem: p
5949
+ visibleWidthOfItem: g
5950
5950
  }) || y
5951
5951
  };
5952
5952
  }, ls = ({
@@ -5992,7 +5992,7 @@ const cs = ({
5992
5992
  }) => new M({
5993
5993
  x: t + e.x,
5994
5994
  y: i + e.y
5995
- }), gs = ({
5995
+ }), ps = ({
5996
5996
  position: e,
5997
5997
  threshold: t,
5998
5998
  restrictToScreen: i,
@@ -6027,12 +6027,12 @@ const cs = ({
6027
6027
  []
6028
6028
  ), d = u[0] ?? c, l = u[u.length - 1] ?? d;
6029
6029
  if (!d || !l) return;
6030
- const g = n.getSpineItemIndex(d), p = n.getSpineItemIndex(l);
6030
+ const p = n.getSpineItemIndex(d), g = n.getSpineItemIndex(l);
6031
6031
  return {
6032
- beginIndex: g ?? 0,
6033
- endIndex: p ?? 0
6032
+ beginIndex: p ?? 0,
6033
+ endIndex: g ?? 0
6034
6034
  };
6035
- }, ps = ({
6035
+ }, gs = ({
6036
6036
  spineItemsManager: e,
6037
6037
  context: t,
6038
6038
  spineItemLocator: i,
@@ -6040,7 +6040,7 @@ const cs = ({
6040
6040
  spineLayout: o,
6041
6041
  viewport: s
6042
6042
  }) => {
6043
- const r = (p, h) => {
6043
+ const r = (g, h) => {
6044
6044
  const { left: m, top: y } = o.getSpineItemSpineLayoutInfo(h);
6045
6045
  return new C({
6046
6046
  /**
@@ -6050,28 +6050,28 @@ const cs = ({
6050
6050
  * 400 - 600 = -200.
6051
6051
  * However we can assume we are at 0, because we in fact can see the beginning of the item
6052
6052
  */
6053
- x: Math.max(p.x - m, 0),
6054
- y: Math.max(p.y - y, 0)
6053
+ x: Math.max(g.x - m, 0),
6054
+ y: Math.max(g.y - y, 0)
6055
6055
  });
6056
- }, a = (p) => Dt({
6056
+ }, a = (g) => Dt({
6057
6057
  spineItemPosition: new C({ x: 0, y: 0 }),
6058
- itemLayout: o.getSpineItemSpineLayoutInfo(p)
6059
- }), c = (p) => e.items.find((h) => h.renderer.getDocumentFrame() === p), u = (p, h, m) => {
6058
+ itemLayout: o.getSpineItemSpineLayoutInfo(g)
6059
+ }), c = (g) => e.items.find((h) => h.renderer.getDocumentFrame() === g), u = (g, h, m) => {
6060
6060
  if (typeof m == "number") {
6061
6061
  const y = e.get(m);
6062
6062
  return y ? i.getSpineItemPageIndexFromNode(
6063
- p,
6063
+ g,
6064
6064
  h || 0,
6065
6065
  y
6066
6066
  ) : void 0;
6067
6067
  }
6068
6068
  return i.getSpineItemPageIndexFromNode(
6069
- p,
6069
+ g,
6070
6070
  h || 0,
6071
6071
  m
6072
6072
  );
6073
6073
  }, d = ({
6074
- position: p,
6074
+ position: g,
6075
6075
  threshold: h,
6076
6076
  spineItem: m,
6077
6077
  restrictToScreen: y,
@@ -6100,7 +6100,7 @@ const cs = ({
6100
6100
  }).reduce(
6101
6101
  (O, { absolutePosition: _, index: dt }) => {
6102
6102
  const at = f ? S.absoluteViewport : S.relativeViewport, _e = He(
6103
- p,
6103
+ g,
6104
6104
  S.absoluteViewport,
6105
6105
  at
6106
6106
  ), Xe = yt.from(
@@ -6124,54 +6124,54 @@ const cs = ({
6124
6124
  };
6125
6125
  return {
6126
6126
  getSpinePositionFromSpineItemPosition: ({
6127
- spineItem: p,
6127
+ spineItem: g,
6128
6128
  spineItemPosition: h
6129
6129
  }) => {
6130
- const m = o.getSpineItemSpineLayoutInfo(p);
6130
+ const m = o.getSpineItemSpineLayoutInfo(g);
6131
6131
  return Dt({
6132
6132
  itemLayout: m,
6133
6133
  spineItemPosition: h
6134
6134
  });
6135
6135
  },
6136
- getAbsolutePageIndexFromPageIndex: (p) => cs({
6137
- ...p,
6136
+ getAbsolutePageIndexFromPageIndex: (g) => cs({
6137
+ ...g,
6138
6138
  spineItemsManager: e
6139
6139
  }),
6140
- getSpineInfoFromAbsolutePageIndex: (p) => ls({
6141
- ...p,
6140
+ getSpineInfoFromAbsolutePageIndex: (g) => ls({
6141
+ ...g,
6142
6142
  spineItemsManager: e
6143
6143
  }),
6144
6144
  getSpinePositionFromSpineItem: a,
6145
6145
  getSpineItemPositionFromSpinePosition: r,
6146
- getSpineItemFromPosition: (p) => Be({
6147
- position: p,
6146
+ getSpineItemFromPosition: (g) => Be({
6147
+ position: g,
6148
6148
  settings: n,
6149
6149
  spineItemsManager: e,
6150
6150
  spineLayout: o
6151
6151
  }),
6152
6152
  getSpineItemFromIframe: c,
6153
6153
  getSpineItemPageIndexFromNode: u,
6154
- getVisibleSpineItemsFromPosition: (p) => gs({
6154
+ getVisibleSpineItemsFromPosition: (g) => ps({
6155
6155
  settings: n,
6156
6156
  spineItemsManager: e,
6157
6157
  spineLayout: o,
6158
6158
  viewport: s,
6159
- ...p
6159
+ ...g
6160
6160
  }),
6161
- getVisiblePagesFromViewportPosition: (p) => d({
6162
- ...p,
6161
+ getVisiblePagesFromViewportPosition: (g) => d({
6162
+ ...g,
6163
6163
  viewport: s
6164
6164
  }),
6165
- isPositionWithinSpineItem: (p, h) => {
6165
+ isPositionWithinSpineItem: (g, h) => {
6166
6166
  const { bottom: m, left: y, right: f, top: S } = o.getSpineItemSpineLayoutInfo(h);
6167
- return p.x >= y && p.x <= f && p.y <= m && p.y >= S;
6167
+ return g.x >= y && g.x <= f && g.y <= m && g.y >= S;
6168
6168
  },
6169
6169
  spineItemLocator: i,
6170
- getSafeSpineItemPositionFromUnsafeSpineItemPosition: (p, h) => {
6170
+ getSafeSpineItemPositionFromUnsafeSpineItemPosition: (g, h) => {
6171
6171
  const { height: m, width: y } = o.getSpineItemSpineLayoutInfo(h);
6172
6172
  return new C({
6173
- x: Math.min(Math.max(0, p.x), y),
6174
- y: Math.min(Math.max(0, p.y), m)
6173
+ x: Math.min(Math.max(0, g.x), y),
6174
+ y: Math.min(Math.max(0, g.y), m)
6175
6175
  });
6176
6176
  }
6177
6177
  };
@@ -6183,7 +6183,7 @@ class hs extends Y {
6183
6183
  i,
6184
6184
  r,
6185
6185
  c
6186
- ), this.locator = ps({
6186
+ ), this.locator = gs({
6187
6187
  context: i,
6188
6188
  spineItemsManager: o,
6189
6189
  spineItemLocator: s,
@@ -6210,9 +6210,9 @@ class hs extends Y {
6210
6210
  const u = i.manifest$.pipe(
6211
6211
  z((l) => {
6212
6212
  this.spineItemsManager.destroyItems();
6213
- const g = l.spineItems.map(
6214
- (p, h) => new Ue(
6215
- p,
6213
+ const p = l.spineItems.map(
6214
+ (g, h) => new Ue(
6215
+ g,
6216
6216
  this.elementSubject.getValue(),
6217
6217
  this.context,
6218
6218
  this.settings,
@@ -6220,15 +6220,15 @@ class hs extends Y {
6220
6220
  h
6221
6221
  )
6222
6222
  );
6223
- this.spineItemsManager.addMany(g);
6223
+ this.spineItemsManager.addMany(p);
6224
6224
  })
6225
6225
  ), d = t.pipe(
6226
6226
  z((l) => {
6227
- const g = l.ownerDocument.createElement("div");
6228
- g.style.cssText = `
6227
+ const p = l.ownerDocument.createElement("div");
6228
+ p.style.cssText = `
6229
6229
  height: 100%;
6230
6230
  position: relative;
6231
- `, g.className = `${gt}-spine`, this.elementSubject.next(g);
6231
+ `, p.className = `${pt}-spine`, this.elementSubject.next(p);
6232
6232
  })
6233
6233
  );
6234
6234
  v(u, d).pipe(J(this.destroy$)).subscribe();
@@ -6290,7 +6290,7 @@ class ms extends Y {
6290
6290
  this.orderedSpineItemsSubject.value.forEach((t) => t.destroy());
6291
6291
  }
6292
6292
  }
6293
- class fs extends pt {
6293
+ class fs extends gt {
6294
6294
  constructor(t) {
6295
6295
  const i = document.createElement("div");
6296
6296
  i.style.cssText = `
@@ -6299,7 +6299,7 @@ class fs extends pt {
6299
6299
  -transform: scale(0.2);
6300
6300
  height: 100%;
6301
6301
  width: 100%;
6302
- `, i.className = `${gt}-viewport`, super({
6302
+ `, i.className = `${pt}-viewport`, super({
6303
6303
  element: i,
6304
6304
  pageSize: {
6305
6305
  width: 1,
@@ -6346,12 +6346,12 @@ class fs extends pt {
6346
6346
  }
6347
6347
  }
6348
6348
  const ys = (e) => {
6349
- const t = new U(), i = new po(), n = new lo(), o = new Zo(e, n), s = new go(n, o), r = new ms(n, o), a = new k(
6349
+ const t = new U(), i = new go(), n = new lo(), o = new Zo(e, n), s = new po(n, o), r = new ms(n, o), a = new k(
6350
6350
  void 0
6351
6351
  ), c = new fs(n), u = a.pipe(Q(ct)), d = ze({
6352
6352
  context: n,
6353
6353
  settings: o
6354
- }), l = new Xo(n, r), g = new hs(
6354
+ }), l = new Xo(n, r), p = new hs(
6355
6355
  u,
6356
6356
  n,
6357
6357
  l,
@@ -6360,21 +6360,21 @@ const ys = (e) => {
6360
6360
  o,
6361
6361
  i,
6362
6362
  c
6363
- ), p = _o({
6363
+ ), g = _o({
6364
6364
  context: n,
6365
6365
  spineItemsManager: r,
6366
6366
  hookManager: i,
6367
- spine: g,
6367
+ spine: p,
6368
6368
  settings: o,
6369
6369
  viewport: c
6370
6370
  }), h = new qo(
6371
6371
  n,
6372
6372
  l,
6373
6373
  r,
6374
- g,
6374
+ p,
6375
6375
  d
6376
6376
  );
6377
- p.viewportState$.subscribe(n.bridgeEvent.viewportStateSubject), p.navigation$.subscribe(n.bridgeEvent.navigationSubject), p.locker.isLocked$.subscribe(
6377
+ g.viewportState$.subscribe(n.bridgeEvent.viewportStateSubject), g.navigation$.subscribe(n.bridgeEvent.navigationSubject), g.locker.isLocked$.subscribe(
6378
6378
  n.bridgeEvent.navigationIsLockedSubject
6379
6379
  ), l.subscribe(n.bridgeEvent.paginationSubject);
6380
6380
  const m = () => {
@@ -6394,7 +6394,7 @@ const ys = (e) => {
6394
6394
  width: x.width,
6395
6395
  height: x.height
6396
6396
  }
6397
- }), g.layout();
6397
+ }), p.layout();
6398
6398
  }, y = (S) => {
6399
6399
  var F;
6400
6400
  const { containerElement: I, manifest: x } = S;
@@ -6412,23 +6412,23 @@ const ys = (e) => {
6412
6412
  }), m();
6413
6413
  }, f = () => {
6414
6414
  var S;
6415
- r.destroy(), h.destroy(), o.destroy(), l.destroy(), n.destroy(), p.destroy(), g.destroy(), (S = a.getValue()) == null || S.remove(), s.destroy(), t.next(), t.complete(), c.destroy();
6415
+ r.destroy(), h.destroy(), o.destroy(), l.destroy(), n.destroy(), g.destroy(), p.destroy(), (S = a.getValue()) == null || S.remove(), s.destroy(), t.next(), t.complete(), c.destroy();
6416
6416
  };
6417
6417
  return {
6418
6418
  context: n,
6419
- spine: g,
6419
+ spine: p,
6420
6420
  hookManager: i,
6421
6421
  cfi: {
6422
6422
  generateCfiFromRange: An,
6423
6423
  parseCfi: Zt,
6424
6424
  generateCfiForSpineItemPage: (S) => Wt({
6425
6425
  ...S,
6426
- spine: g
6426
+ spine: p
6427
6427
  }),
6428
6428
  resolveCfi: (S) => De({ ...S, spineItemsManager: r })
6429
6429
  },
6430
- navigation: p,
6431
- spineItemsObserver: g.spineItemsObserver,
6430
+ navigation: g,
6431
+ spineItemsObserver: p.spineItemsObserver,
6432
6432
  spineItemsManager: r,
6433
6433
  layout: m,
6434
6434
  load: y,
@@ -6465,7 +6465,7 @@ const ys = (e) => {
6465
6465
  return t.style.cssText = `
6466
6466
  background-color: white;
6467
6467
  position: relative;
6468
- `, t.className = `${gt}-reader`, t;
6468
+ `, t.className = `${pt}-reader`, t;
6469
6469
  }, Fs = (
6470
6470
  //__
6471
6471
  eo(
@@ -6483,7 +6483,7 @@ const ys = (e) => {
6483
6483
  bi(
6484
6484
  io(
6485
6485
  qn(
6486
- pn(
6486
+ gn(
6487
6487
  Ni(
6488
6488
  // __
6489
6489
  ys
@@ -6510,8 +6510,8 @@ export {
6510
6510
  Do as ControlledNavigationController,
6511
6511
  Y as DestroyableClass,
6512
6512
  mt as DocumentRenderer,
6513
- go as Features,
6514
- po as HookManager,
6513
+ po as Features,
6514
+ go as HookManager,
6515
6515
  Fo as InternalNavigator,
6516
6516
  qt as LayoutEntry,
6517
6517
  je as Locker,
@@ -6550,7 +6550,7 @@ export {
6550
6550
  Ci as isHtmlTagElement,
6551
6551
  zt as isRootCfi,
6552
6552
  Rs as isShallowEqual,
6553
- pn as layoutEnhancer,
6553
+ gn as layoutEnhancer,
6554
6554
  xe as mapKeysTo,
6555
6555
  vs as observeIntersection,
6556
6556
  ie as observeMutation,