@readium/navigator 2.4.0-alpha.4 → 2.4.0-alpha.6

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
@@ -347,13 +347,13 @@ class g {
347
347
  }
348
348
  const a = {}, l = Object.keys(o);
349
349
  l.sort((m, y) => m.localeCompare(y)), l.forEach((m) => a[m] = o[m]);
350
- let c = "";
350
+ let h = "";
351
351
  for (const m in a) {
352
352
  const y = a[m];
353
- c += `;${m}=${y}`;
353
+ h += `;${m}=${y}`;
354
354
  }
355
- const h = `${e}/${i}${c}`, u = a.encoding;
356
- this.string = h, this.type = e, this.subtype = i, this.parameters = a, this.encoding = u, this.name = t.name, this.fileExtension = t.fileExtension;
355
+ const c = `${e}/${i}${h}`, u = a.encoding;
356
+ this.string = c, this.type = e, this.subtype = i, this.parameters = a, this.encoding = u, this.name = t.name, this.fileExtension = t.fileExtension;
357
357
  }
358
358
  static parse(t) {
359
359
  return new g(t);
@@ -1477,7 +1477,7 @@ function _n(s, t, e) {
1477
1477
  return e.map((n) => {
1478
1478
  const r = Math.max(0, n.end - t.length - n.errors), o = Ke(s.slice(r, n.end));
1479
1479
  return {
1480
- start: ki(o, i, n.errors).reduce((l, c) => n.end - c.end < l ? n.end - c.end : l, n.end),
1480
+ start: ki(o, i, n.errors).reduce((l, h) => n.end - h.end < l ? n.end - h.end : l, n.end),
1481
1481
  end: n.end,
1482
1482
  errors: n.errors
1483
1483
  };
@@ -1488,10 +1488,10 @@ function ne(s) {
1488
1488
  }
1489
1489
  function Ze(s, t, e, i) {
1490
1490
  let n = s.P[e], r = s.M[e];
1491
- const o = i >>> 31, a = t[e] | o, l = a | r, c = (a & n) + n ^ n | a;
1492
- let h = r | ~(c | n), u = n & c;
1493
- const m = ne(h & s.lastRowMask[e]) - ne(u & s.lastRowMask[e]);
1494
- return h <<= 1, u <<= 1, u |= o, h |= ne(i) - o, n = u | ~(l | h), r = h & l, s.P[e] = n, s.M[e] = r, m;
1491
+ const o = i >>> 31, a = t[e] | o, l = a | r, h = (a & n) + n ^ n | a;
1492
+ let c = r | ~(h | n), u = n & h;
1493
+ const m = ne(c & s.lastRowMask[e]) - ne(u & s.lastRowMask[e]);
1494
+ return c <<= 1, u <<= 1, u |= o, c |= ne(i) - o, n = u | ~(l | c), r = c & l, s.P[e] = n, s.M[e] = r, m;
1495
1495
  }
1496
1496
  function ki(s, t, e) {
1497
1497
  if (t.length === 0)
@@ -1503,15 +1503,15 @@ function ki(s, t, e) {
1503
1503
  lastRowMask: new Uint32Array(r + 1)
1504
1504
  };
1505
1505
  o.lastRowMask.fill(1 << 31), o.lastRowMask[r] = 1 << (t.length - 1) % n;
1506
- const a = new Uint32Array(r + 1), l = /* @__PURE__ */ new Map(), c = [];
1506
+ const a = new Uint32Array(r + 1), l = /* @__PURE__ */ new Map(), h = [];
1507
1507
  for (let m = 0; m < 256; m++)
1508
- c.push(a);
1508
+ h.push(a);
1509
1509
  for (let m = 0; m < t.length; m += 1) {
1510
1510
  const y = t.charCodeAt(m);
1511
1511
  if (l.has(y))
1512
1512
  continue;
1513
1513
  const d = new Uint32Array(r + 1);
1514
- l.set(y, d), y < c.length && (c[y] = d);
1514
+ l.set(y, d), y < h.length && (h[y] = d);
1515
1515
  for (let p = 0; p <= r; p += 1) {
1516
1516
  d[p] = 0;
1517
1517
  for (let b = 0; b < n; b += 1) {
@@ -1522,37 +1522,37 @@ function ki(s, t, e) {
1522
1522
  }
1523
1523
  }
1524
1524
  }
1525
- let h = Math.max(0, Math.ceil(e / n) - 1);
1525
+ let c = Math.max(0, Math.ceil(e / n) - 1);
1526
1526
  const u = new Uint32Array(r + 1);
1527
- for (let m = 0; m <= h; m += 1)
1527
+ for (let m = 0; m <= c; m += 1)
1528
1528
  u[m] = (m + 1) * n;
1529
1529
  u[r] = t.length;
1530
- for (let m = 0; m <= h; m += 1)
1530
+ for (let m = 0; m <= c; m += 1)
1531
1531
  o.P[m] = -1, o.M[m] = 0;
1532
1532
  for (let m = 0; m < s.length; m += 1) {
1533
1533
  const y = s.charCodeAt(m);
1534
1534
  let d;
1535
- y < c.length ? d = c[y] : (d = l.get(y), typeof d > "u" && (d = a));
1535
+ y < h.length ? d = h[y] : (d = l.get(y), typeof d > "u" && (d = a));
1536
1536
  let p = 0;
1537
- for (let b = 0; b <= h; b += 1)
1537
+ for (let b = 0; b <= c; b += 1)
1538
1538
  p = Ze(o, d, b, p), u[b] += p;
1539
- if (u[h] - p <= e && h < r && (d[h + 1] & 1 || p < 0)) {
1540
- h += 1, o.P[h] = -1, o.M[h] = 0;
1539
+ if (u[c] - p <= e && c < r && (d[c + 1] & 1 || p < 0)) {
1540
+ c += 1, o.P[c] = -1, o.M[c] = 0;
1541
1541
  let b;
1542
- if (h === r) {
1542
+ if (c === r) {
1543
1543
  const _ = t.length % n;
1544
1544
  b = _ === 0 ? n : _;
1545
1545
  } else
1546
1546
  b = n;
1547
- u[h] = u[h - 1] + b - p + Ze(o, d, h, p);
1547
+ u[c] = u[c - 1] + b - p + Ze(o, d, c, p);
1548
1548
  } else
1549
- for (; h > 0 && u[h] >= e + n; )
1550
- h -= 1;
1551
- h === r && u[h] <= e && (u[h] < e && i.splice(0, i.length), i.push({
1549
+ for (; c > 0 && u[c] >= e + n; )
1550
+ c -= 1;
1551
+ c === r && u[c] <= e && (u[c] < e && i.splice(0, i.length), i.push({
1552
1552
  start: -1,
1553
1553
  end: m + 1,
1554
- errors: u[h]
1555
- }), e = u[h]);
1554
+ errors: u[c]
1555
+ }), e = u[c]);
1556
1556
  }
1557
1557
  return i;
1558
1558
  }
@@ -1622,8 +1622,8 @@ function Qe(s, t) {
1622
1622
  let o = -1;
1623
1623
  const a = () => {
1624
1624
  if (r = t === 1 ? e.nextNode() : e.previousNode(), r) {
1625
- const l = r.textContent, c = t === 1 ? 0 : l.length;
1626
- o = ue(l, c, t);
1625
+ const l = r.textContent, h = t === 1 ? 0 : l.length;
1626
+ o = ue(l, h, t);
1627
1627
  }
1628
1628
  };
1629
1629
  for (; r && o === -1 && r !== n; )
@@ -1982,24 +1982,24 @@ function Rn(s, t) {
1982
1982
  let e = s.getClientRects();
1983
1983
  e.length || s.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = s.commonAncestorContainer.getClientRects());
1984
1984
  const i = 1, n = [];
1985
- for (const c of e)
1985
+ for (const h of e)
1986
1986
  n.push({
1987
- bottom: c.bottom,
1988
- height: c.height,
1989
- left: c.left,
1990
- right: c.right,
1991
- top: c.top,
1992
- width: c.width
1987
+ bottom: h.bottom,
1988
+ height: h.height,
1989
+ left: h.left,
1990
+ right: h.right,
1991
+ top: h.top,
1992
+ width: h.width
1993
1993
  });
1994
1994
  const r = Mi(
1995
1995
  n,
1996
1996
  i
1997
1997
  ), o = On(r, i), a = Ui(o), l = 4;
1998
- for (let c = a.length - 1; c >= 0; c--) {
1999
- const h = a[c];
2000
- if (!(h.width * h.height > l))
1998
+ for (let h = a.length - 1; h >= 0; h--) {
1999
+ const c = a[h];
2000
+ if (!(c.width * c.height > l))
2001
2001
  if (a.length > 1)
2002
- a.splice(c, 1);
2002
+ a.splice(h, 1);
2003
2003
  else
2004
2004
  break;
2005
2005
  }
@@ -2064,10 +2064,10 @@ function Ui(s) {
2064
2064
  if (a.length === 1)
2065
2065
  r = a, o = i;
2066
2066
  else {
2067
- const c = ei(n, i);
2068
- a.length < c.length ? (r = a, o = i) : (r = c, o = n);
2067
+ const h = ei(n, i);
2068
+ a.length < h.length ? (r = a, o = i) : (r = h, o = n);
2069
2069
  }
2070
- const l = s.filter((c) => c !== o);
2070
+ const l = s.filter((h) => h !== o);
2071
2071
  return Array.prototype.push.apply(l, r), Ui(l);
2072
2072
  }
2073
2073
  }
@@ -2218,10 +2218,10 @@ const ct = { r: 255, g: 255, b: 255, a: 1 }, st = /* @__PURE__ */ new Map(), An
2218
2218
  n.clearRect(r, o, 1, 1), t && (n.fillStyle = t, n.fillRect(r, o, 1, 1)), n.fillStyle = s, n.fillRect(r, o, 1, 1);
2219
2219
  const a = n.getImageData(r, o, 1, 1);
2220
2220
  yt = (yt + 1) % 25;
2221
- const [l, c, h, u] = a.data;
2221
+ const [l, h, c, u] = a.data;
2222
2222
  if (u === 0)
2223
2223
  return At(s, "Fully transparent color."), st.set(e, null), ct;
2224
- const m = { r: l, g: c, b: h, a: u / 255 };
2224
+ const m = { r: l, g: h, b: c, a: u / 255 };
2225
2225
  return st.set(e, m), m;
2226
2226
  } catch (r) {
2227
2227
  return At(s, `Error: ${r instanceof Error ? r.message : String(r)}`), st.set(e, null), ct;
@@ -2326,7 +2326,7 @@ class Nn {
2326
2326
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2327
2327
  "column-count"
2328
2328
  )
2329
- ), r = i / (n || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, l = o.scrollTop, c = (d, p, b) => {
2329
+ ), r = i / (n || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, l = o.scrollTop, h = (d, p, b) => {
2330
2330
  if (d.style.position = "absolute", t.decoration?.style?.width === "viewport") {
2331
2331
  d.style.width = `${i}px`, d.style.height = `${p.height}px`;
2332
2332
  let _ = Math.floor(p.left / i) * i;
@@ -2339,7 +2339,7 @@ class Nn {
2339
2339
  d.style.left = `${_ + a}px`, d.style.top = `${p.top + l}px`;
2340
2340
  } else
2341
2341
  d.style.width = `${p.width}px`, d.style.height = `${p.height}px`, d.style.left = `${p.left + a}px`, d.style.top = `${p.top + l}px`;
2342
- }, h = t.range.getBoundingClientRect();
2342
+ }, c = t.range.getBoundingClientRect();
2343
2343
  let u = this.wnd.document.createElement("template");
2344
2344
  const m = this.getCurrentDarkMode();
2345
2345
  u.innerHTML = `
@@ -2359,7 +2359,7 @@ class Nn {
2359
2359
  const y = u.content.firstElementChild;
2360
2360
  if (t.decoration?.style?.layout === "bounds") {
2361
2361
  const d = y.cloneNode(!0);
2362
- d.style.setProperty("pointer-events", "none"), c(d, h, h), e.append(d);
2362
+ d.style.setProperty("pointer-events", "none"), h(d, c, c), e.append(d);
2363
2363
  } else {
2364
2364
  let d = Rn(
2365
2365
  t.range
@@ -2367,7 +2367,7 @@ class Nn {
2367
2367
  d = d.sort((p, b) => p.top < b.top ? -1 : p.top > b.top ? 1 : 0);
2368
2368
  for (let p of d) {
2369
2369
  const b = y.cloneNode(!0);
2370
- b.style.setProperty("pointer-events", "none"), c(b, p, h), e.append(b);
2370
+ b.style.setProperty("pointer-events", "none"), h(b, p, c), e.append(b);
2371
2371
  }
2372
2372
  }
2373
2373
  t.container = e, t.clickableElements = Array.from(
@@ -2455,8 +2455,8 @@ const wt = class wt extends ft {
2455
2455
  }), this.resizeObserver = new ResizeObserver(() => t.requestAnimationFrame(() => this.handleResize())), this.resizeObserver.observe(t.document.body), t.addEventListener("orientationchange", this.handleResizer), t.addEventListener("resize", this.handleResizer), this.backgroundObserver = new MutationObserver((i) => {
2456
2456
  i.some((r) => {
2457
2457
  if (r.type === "attributes" && r.attributeName === "style") {
2458
- const o = r.target, a = r.oldValue, l = o.getAttribute("style"), c = this.extractCustomProperty(a, "--USER__appearance"), h = this.extractCustomProperty(l, "--USER__appearance"), u = this.extractCustomProperty(a, "--USER__backgroundColor"), m = this.extractCustomProperty(l, "--USER__backgroundColor");
2459
- return c !== h || u !== m;
2458
+ const o = r.target, a = r.oldValue, l = o.getAttribute("style"), h = this.extractCustomProperty(a, "--USER__appearance"), c = this.extractCustomProperty(l, "--USER__appearance"), u = this.extractCustomProperty(a, "--USER__backgroundColor"), m = this.extractCustomProperty(l, "--USER__backgroundColor");
2459
+ return h !== c || u !== m;
2460
2460
  }
2461
2461
  return !1;
2462
2462
  }) && this.updateHighlightStyles();
@@ -2517,13 +2517,13 @@ function li(s) {
2517
2517
  if (!t)
2518
2518
  return !1;
2519
2519
  const e = s.document.querySelectorAll("div[id^='readium-virtual-page']");
2520
- for (const c of e)
2521
- c.remove();
2520
+ for (const h of e)
2521
+ h.remove();
2522
2522
  const i = e.length, n = s.document.scrollingElement.scrollWidth, r = s.visualViewport.width, a = Math.round(n / r * t) % t, l = t === 1 || a === 0 ? 0 : t - a;
2523
2523
  if (l > 0)
2524
- for (let c = 0; c < l; c++) {
2525
- const h = s.document.createElement("div");
2526
- h.setAttribute("id", `readium-virtual-page-${c}`), h.dataset.readium = "true", CSS.supports("break-before", "column") ? h.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (h.style.breakInside = "avoid-column"), h.style.height = ai(s.document.documentElement) + "px"), h.innerHTML = "&#8203;", s.document.body.appendChild(h);
2524
+ for (let h = 0; h < l; h++) {
2525
+ const c = s.document.createElement("div");
2526
+ c.setAttribute("id", `readium-virtual-page-${h}`), c.dataset.readium = "true", CSS.supports("break-before", "column") ? c.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (c.style.breakInside = "avoid-column"), c.style.height = ai(s.document.documentElement) + "px"), c.innerHTML = "&#8203;", s.document.body.appendChild(c);
2527
2527
  }
2528
2528
  return i !== l;
2529
2529
  }
@@ -2649,8 +2649,8 @@ class ze {
2649
2649
  }), this.history = this.history.filter((p) => r - p.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
2650
2650
  if (n > this.options.maxVelocity)
2651
2651
  return this.resetAfterDetection(), !0;
2652
- const o = this.history.map((p) => p.velocity), a = this.history.map((p) => p.distance), l = o.reduce((p, b) => p + b, 0) / o.length, c = a.reduce((p, b) => p + b, 0) / a.length, h = o.reduce((p, b) => p + Math.pow(b - l, 2), 0) / o.length, u = a.reduce((p, b) => p + Math.pow(b - c, 2), 0) / a.length;
2653
- if (h < this.options.minVariance && u < c * 0.1) {
2652
+ const o = this.history.map((p) => p.velocity), a = this.history.map((p) => p.distance), l = o.reduce((p, b) => p + b, 0) / o.length, h = a.reduce((p, b) => p + b, 0) / a.length, c = o.reduce((p, b) => p + Math.pow(b - l, 2), 0) / o.length, u = a.reduce((p, b) => p + Math.pow(b - h, 2), 0) / a.length;
2653
+ if (c < this.options.minVariance && u < h * 0.1) {
2654
2654
  if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
2655
2655
  return this.resetAfterDetection(), !0;
2656
2656
  } else
@@ -2705,11 +2705,11 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2705
2705
  }
2706
2706
  // Snaps the current offset to the page width.
2707
2707
  snapCurrentOffset(t = !1, e = !1) {
2708
- const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, n = this.doc(), r = this.dragOffset(), o = Di(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), l = nt(this.wnd) ? -1 : 1, c = (
2708
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, n = this.doc(), r = this.dragOffset(), o = Di(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), l = nt(this.wnd) ? -1 : 1, h = (
2709
2709
  // The hurdle to overcome in order to change pages
2710
2710
  l * (this.wnd.innerWidth / 3) * (l * r > 0 ? 2 : 1)
2711
- ), h = this.snapOffset(a + c), u = h > this.scrollOffset() ? "right" : "left";
2712
- if (this.checkSuspiciousSnap(u, Math.abs(h - this.scrollOffset())), t && h !== this.scrollOffset()) {
2711
+ ), c = this.snapOffset(a + h), u = c > this.scrollOffset() ? "right" : "left";
2712
+ if (this.checkSuspiciousSnap(u, Math.abs(c - this.scrollOffset())), t && c !== this.scrollOffset()) {
2713
2713
  this.snappingCancelled = !1;
2714
2714
  const m = (b, _, z, Q) => z > Q ? _ : b + (_ - b) * Fn(z / Q), y = (
2715
2715
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
@@ -2719,13 +2719,13 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2719
2719
  const p = (b) => {
2720
2720
  if (this.snappingCancelled) return;
2721
2721
  d || (d = b);
2722
- const _ = b - d, z = m(this.overscroll, 0, _, y), Q = m(i, h, _, y);
2723
- n.scrollLeft = Q, this.overscroll !== 0 && (n.style.transform = `translate3d(${-z}px, 0px, 0px)`), _ < y ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), n.style.removeProperty("transform"), n.scrollLeft = h, e || this.reportProgress());
2722
+ const _ = b - d, z = m(this.overscroll, 0, _, y), Q = m(i, c, _, y);
2723
+ n.scrollLeft = Q, this.overscroll !== 0 && (n.style.transform = `translate3d(${-z}px, 0px, 0px)`), _ < y ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), n.style.removeProperty("transform"), n.scrollLeft = c, e || this.reportProgress());
2724
2724
  };
2725
2725
  this.wnd.requestAnimationFrame(p);
2726
2726
  } else
2727
2727
  n.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2728
- n.scrollLeft = h, this.clearTouches(), e || this.reportProgress();
2728
+ n.scrollLeft = c, this.clearTouches(), e || this.reportProgress();
2729
2729
  });
2730
2730
  }
2731
2731
  dragOffset() {
@@ -2832,8 +2832,8 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2832
2832
  }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((r) => {
2833
2833
  for (const o of r)
2834
2834
  if (o.target === this.wnd.document.documentElement) {
2835
- const a = o.oldValue, l = o.target.getAttribute("style"), c = /transform\s*:\s*([^;]+)/, h = a?.match(c), u = l?.match(c);
2836
- (!h && !u || h && !u || h && u && h[1] !== u[1]) && (t.requestAnimationFrame(() => {
2835
+ const a = o.oldValue, l = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = a?.match(h), u = l?.match(h);
2836
+ (!c && !u || c && !u || c && u && c[1] !== u[1]) && (t.requestAnimationFrame(() => {
2837
2837
  t && li(t);
2838
2838
  }), this.onWidthChange());
2839
2839
  } else
@@ -2855,8 +2855,8 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2855
2855
  }
2856
2856
  this.wnd.requestAnimationFrame(() => {
2857
2857
  this.cachedScrollWidth = this.doc().scrollWidth;
2858
- const l = this.cachedScrollWidth, c = nt(t) ? -1 : 1, h = l * a * c;
2859
- this.doc().scrollLeft = this.snapOffset(h), this.reportProgress(), T(this.wnd), o(!0);
2858
+ const l = this.cachedScrollWidth, h = nt(t) ? -1 : 1, c = l * a * h;
2859
+ this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), T(this.wnd), o(!0);
2860
2860
  });
2861
2861
  }), e.register("go_id", U.moduleName, (r, o) => {
2862
2862
  const a = t.document.getElementById(r);
@@ -2870,7 +2870,7 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
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 = rt.deserialize(r), c = Qt(this.wnd.document, new H({
2873
+ const l = rt.deserialize(r), h = Qt(this.wnd.document, new H({
2874
2874
  href: t.location.href,
2875
2875
  type: "text/html",
2876
2876
  text: l,
@@ -2880,12 +2880,12 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2880
2880
  ])
2881
2881
  }) : void 0
2882
2882
  }));
2883
- if (!c) {
2883
+ if (!h) {
2884
2884
  o(!1);
2885
2885
  return;
2886
2886
  }
2887
2887
  this.wnd.requestAnimationFrame(() => {
2888
- this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2888
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2889
2889
  });
2890
2890
  }), e.register("go_end", U.moduleName, (r, o) => {
2891
2891
  const a = nt(t) ? -1 : 1;
@@ -2903,14 +2903,14 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2903
2903
  }), e.register("go_prev", U.moduleName, (r, o) => {
2904
2904
  this.wnd.requestAnimationFrame(() => {
2905
2905
  this.cachedScrollWidth = this.doc().scrollWidth;
2906
- const a = t.scrollX - t.innerWidth, l = nt(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, c = n(Math.max(a, l));
2907
- c && (this.reportProgress(), T(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(c);
2906
+ const a = t.scrollX - t.innerWidth, l = nt(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = n(Math.max(a, l));
2907
+ h && (this.reportProgress(), T(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(h);
2908
2908
  });
2909
2909
  }), e.register("go_next", U.moduleName, (r, o) => {
2910
2910
  this.wnd.requestAnimationFrame(() => {
2911
2911
  this.cachedScrollWidth = this.doc().scrollWidth;
2912
- const a = t.scrollX + t.innerWidth, l = nt(t) ? 0 : this.cachedScrollWidth - t.innerWidth, c = n(Math.min(a, l));
2913
- c && (this.reportProgress(), T(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(c);
2912
+ const a = t.scrollX + t.innerWidth, l = nt(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = n(Math.min(a, l));
2913
+ h && (this.reportProgress(), T(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(h);
2914
2914
  });
2915
2915
  }), e.register("unfocus", U.moduleName, (r, o) => {
2916
2916
  this.snappingCancelled = !0, T(this.wnd), o(!0);
@@ -3214,10 +3214,10 @@ class jn {
3214
3214
  length: n,
3215
3215
  wasBlocked: !1
3216
3216
  }), !0;
3217
- const l = o - this.lastSelectionTime < 100 && n > this.lastSelectionLength * 1.5, c = Math.min(
3217
+ const l = o - this.lastSelectionTime < 100 && n > this.lastSelectionLength * 1.5, h = Math.min(
3218
3218
  r * this.options.maxSelectionPercent,
3219
3219
  this.options.absoluteMaxChars
3220
- ), h = this.isSuspiciousPattern(o), u = n > c || l || h;
3220
+ ), c = this.isSuspiciousPattern(o), u = n > h || l || c;
3221
3221
  return this.copyHistory.push({
3222
3222
  timestamp: o,
3223
3223
  length: n,
@@ -3296,13 +3296,13 @@ class Gi {
3296
3296
  createActivityEvent(t, e, i, n) {
3297
3297
  let r;
3298
3298
  if (n) {
3299
- const o = n.getSelection(), a = o?.toString() || "", c = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
3300
- c && a && (r = {
3299
+ const o = n.getSelection(), a = o?.toString() || "", h = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
3300
+ h && a && (r = {
3301
3301
  text: a,
3302
- x: c.x,
3303
- y: c.y,
3304
- width: c.width,
3305
- height: c.height
3302
+ x: h.x,
3303
+ y: h.y,
3304
+ width: h.width,
3305
+ height: h.height
3306
3306
  });
3307
3307
  }
3308
3308
  return {
@@ -3328,8 +3328,8 @@ class Gi {
3328
3328
  r.push(...o.keyCombos.map((a) => ({
3329
3329
  ...a,
3330
3330
  handler: (l) => {
3331
- const c = o.type, h = this.createActivityEvent(l, c, t, n);
3332
- i(h);
3331
+ const h = o.type, c = this.createActivityEvent(l, h, t, n);
3332
+ i(c);
3333
3333
  }
3334
3334
  })));
3335
3335
  }), r;
@@ -3622,7 +3622,7 @@ const _t = class _t extends ft {
3622
3622
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3623
3623
  value: {
3624
3624
  name: "readium-ts-toolkit",
3625
- version: "2.4.0-alpha.4",
3625
+ version: "2.4.0-alpha.6",
3626
3626
  hasFeature: (n, r = "") => {
3627
3627
  switch (n) {
3628
3628
  case "dom-manipulation":
@@ -3967,7 +3967,7 @@ class er {
3967
3967
  const o = r.keyCombos.filter(
3968
3968
  (a) => !i.some(
3969
3969
  (l) => l.keyCombos.some(
3970
- (c) => a.keyCode === c.keyCode && a.ctrl === c.ctrl && a.shift === c.shift && a.alt === c.alt && a.meta === c.meta
3970
+ (h) => a.keyCode === h.keyCode && a.ctrl === h.ctrl && a.shift === h.shift && a.alt === h.alt && a.meta === h.meta
3971
3971
  )
3972
3972
  )
3973
3973
  );
@@ -4219,12 +4219,12 @@ class Yi {
4219
4219
  else if (/^((Google )?Chrome OS|CrOS)$/.test(a)) o.ChromeOS = i(l);
4220
4220
  else if (/^(Linux|Ubuntu|X11)$/.test(a)) o.Linux = i(l);
4221
4221
  else return;
4222
- Object.keys(this.OS).forEach((c) => delete this.OS[c]), Object.assign(this.OS, o);
4222
+ Object.keys(this.OS).forEach((h) => delete this.OS[h]), Object.assign(this.OS, o);
4223
4223
  }
4224
4224
  })({})), this.UA = ((r) => {
4225
4225
  let o = !1;
4226
4226
  if (t && Array.isArray(t.brands)) {
4227
- const a = t.brands.reduce((l, c) => (l[c.brand] = [c.version * 1], l), {});
4227
+ const a = t.brands.reduce((l, h) => (l[h.brand] = [h.version * 1], l), {});
4228
4228
  a["Google Chrome"] ? (o = !0, r.Blink = r.Chromium = a.Chromium || [], r.Chrome = a["Google Chrome"]) : a["Microsoft Edge"] ? (o = !0, r.Blink = r.Chromium = a.Chromium || [], r.Edge = a["Microsoft Edge"]) : a.Opera && (o = !0, r.Blink = r.Chromium = a.Chromium || [], r.Opera = a.Opera);
4229
4229
  }
4230
4230
  return o || (/ Gecko\/\d/.test(e) ? (r.Gecko = n("rv"), / Waterfox\/\d/.test(e) ? r.Waterfox = n("Waterfox") : / Firefox\/\d/.test(e) && (r.Firefox = n("Firefox"))) : / Edge\/\d/.test(e) ? (r.EdgeHTML = n("Edge"), r.Edge = r.EdgeHTML) : / Chrom(ium|e)\/\d/.test(e) ? (r.Blink = r.Chromium = ((a) => a[0] ? a : n("Chrome"))(n("Chromium")), / EdgA?\/\d/.test(e) ? r.Edge = ((a) => a[0] ? a : n("Edg"))(n("EdgA")) : / OPR\/\d/.test(e) ? r.Opera = n("OPR") : / Vivaldi\/\d/.test(e) ? r.Vivaldi = n("Vivaldi") : / Silk\/\d/.test(e) ? r.Silk = n("Silk") : / UCBrowser\/\d/.test(e) ? r.UCBrowser = n("UCBrowser") : / Phoebe\/\d/.test(e) ? r.Phoebe = n("Phoebe") : r.Chrome = ((a) => a[0] ? a : r.Chromium)(n("Chrome"))) : / AppleWebKit\/\d/.test(e) ? (r.WebKit = n("AppleWebKit"), / CriOS \d/.test(e) ? r.Chrome = n("CriOS") : / FxiOS \d/.test(e) ? r.Firefox = n("FxiOS") : / EdgiOS\/\d/.test(e) ? r.Edge = n("EdgiOS") : / Version\/\d/.test(e) && (r.Safari = n("Version"))) : / Trident\/\d/.test(e) && (r.Trident = n("Trident"), r.InternetExplorer = ((a) => a[0] ? a : n("MSIE"))(n("rv")))), /[\[; ]FB(AN|_IAB)\//.test(e) && (r.Facebook = n("FBAV")), / Line\/\d/.test(e) && (r.LINE = n("Line")), r;
@@ -4360,11 +4360,11 @@ class hr {
4360
4360
  if (r < 0) throw Error(`Locator not found in reading order: ${e.href}`);
4361
4361
  const o = n[r].href;
4362
4362
  this.inprogress.has(o) && await this.inprogress.get(o);
4363
- const a = new Promise(async (l, c) => {
4364
- const h = [], u = [];
4363
+ const a = new Promise(async (l, h) => {
4364
+ const c = [], u = [];
4365
4365
  t.readingOrder.items.forEach((d, p) => {
4366
- p !== r && p !== r - 1 && p !== r + 1 && (h.includes(d.href) || h.push(d.href)), p === r && (u.includes(d.href) || u.push(d.href));
4367
- }), h.forEach(async (d) => {
4366
+ p !== r && p !== r - 1 && p !== r + 1 && (c.includes(d.href) || c.push(d.href)), p === r && (u.includes(d.href) || u.push(d.href));
4367
+ }), c.forEach(async (d) => {
4368
4368
  u.includes(d) || this.pool.has(d) && (await this.pool.get(d)?.destroy(), this.pool.delete(d));
4369
4369
  }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((d) => {
4370
4370
  this.injector?.releaseBlobUrl?.(d), URL.revokeObjectURL(d);
@@ -4403,7 +4403,7 @@ class hr {
4403
4403
  try {
4404
4404
  await Promise.all(u.map((d) => m(d)));
4405
4405
  } catch (d) {
4406
- c(d);
4406
+ h(d);
4407
4407
  }
4408
4408
  const y = this.pool.get(o);
4409
4409
  y?.source !== this._currentFrame?.source && (await this._currentFrame?.hide(), y && await y.load(i), y && await y.show(e.locations.progression), this._currentFrame = y), l();
@@ -4460,33 +4460,33 @@ function cr() {
4460
4460
  throw new TypeError("Path must be a string. Received " + JSON.stringify(n));
4461
4461
  }
4462
4462
  function t(n, r) {
4463
- for (var o = "", a = 0, l = -1, c = 0, h, u = 0; u <= n.length; ++u) {
4463
+ for (var o = "", a = 0, l = -1, h = 0, c, u = 0; u <= n.length; ++u) {
4464
4464
  if (u < n.length)
4465
- h = n.charCodeAt(u);
4465
+ c = n.charCodeAt(u);
4466
4466
  else {
4467
- if (h === 47)
4467
+ if (c === 47)
4468
4468
  break;
4469
- h = 47;
4469
+ c = 47;
4470
4470
  }
4471
- if (h === 47) {
4472
- if (!(l === u - 1 || c === 1)) if (l !== u - 1 && c === 2) {
4471
+ if (c === 47) {
4472
+ if (!(l === u - 1 || h === 1)) if (l !== u - 1 && h === 2) {
4473
4473
  if (o.length < 2 || a !== 2 || o.charCodeAt(o.length - 1) !== 46 || o.charCodeAt(o.length - 2) !== 46) {
4474
4474
  if (o.length > 2) {
4475
4475
  var m = o.lastIndexOf("/");
4476
4476
  if (m !== o.length - 1) {
4477
- m === -1 ? (o = "", a = 0) : (o = o.slice(0, m), a = o.length - 1 - o.lastIndexOf("/")), l = u, c = 0;
4477
+ m === -1 ? (o = "", a = 0) : (o = o.slice(0, m), a = o.length - 1 - o.lastIndexOf("/")), l = u, h = 0;
4478
4478
  continue;
4479
4479
  }
4480
4480
  } else if (o.length === 2 || o.length === 1) {
4481
- o = "", a = 0, l = u, c = 0;
4481
+ o = "", a = 0, l = u, h = 0;
4482
4482
  continue;
4483
4483
  }
4484
4484
  }
4485
4485
  r && (o.length > 0 ? o += "/.." : o = "..", a = 2);
4486
4486
  } else
4487
4487
  o.length > 0 ? o += "/" + n.slice(l + 1, u) : o = n.slice(l + 1, u), a = u - l - 1;
4488
- l = u, c = 0;
4489
- } else h === 46 && c !== -1 ? ++c : c = -1;
4488
+ l = u, h = 0;
4489
+ } else c === 46 && h !== -1 ? ++h : h = -1;
4490
4490
  }
4491
4491
  return o;
4492
4492
  }
@@ -4498,8 +4498,8 @@ function cr() {
4498
4498
  // path.resolve([from ...], to)
4499
4499
  resolve: function() {
4500
4500
  for (var r = "", o = !1, a, l = arguments.length - 1; l >= -1 && !o; l--) {
4501
- var c;
4502
- l >= 0 ? c = arguments[l] : (a === void 0 && (a = process.cwd()), c = a), s(c), c.length !== 0 && (r = c + "/" + r, o = c.charCodeAt(0) === 47);
4501
+ var h;
4502
+ l >= 0 ? h = arguments[l] : (a === void 0 && (a = process.cwd()), h = a), s(h), h.length !== 0 && (r = h + "/" + r, o = h.charCodeAt(0) === 47);
4503
4503
  }
4504
4504
  return r = t(r, !o), o ? r.length > 0 ? "/" + r : "/" : r.length > 0 ? r : ".";
4505
4505
  },
@@ -4524,19 +4524,19 @@ function cr() {
4524
4524
  if (s(r), s(o), r === o || (r = i.resolve(r), o = i.resolve(o), r === o)) return "";
4525
4525
  for (var a = 1; a < r.length && r.charCodeAt(a) === 47; ++a)
4526
4526
  ;
4527
- for (var l = r.length, c = l - a, h = 1; h < o.length && o.charCodeAt(h) === 47; ++h)
4527
+ for (var l = r.length, h = l - a, c = 1; c < o.length && o.charCodeAt(c) === 47; ++c)
4528
4528
  ;
4529
- for (var u = o.length, m = u - h, y = c < m ? c : m, d = -1, p = 0; p <= y; ++p) {
4529
+ for (var u = o.length, m = u - c, y = h < m ? h : m, d = -1, p = 0; p <= y; ++p) {
4530
4530
  if (p === y) {
4531
4531
  if (m > y) {
4532
- if (o.charCodeAt(h + p) === 47)
4533
- return o.slice(h + p + 1);
4532
+ if (o.charCodeAt(c + p) === 47)
4533
+ return o.slice(c + p + 1);
4534
4534
  if (p === 0)
4535
- return o.slice(h + p);
4536
- } else c > y && (r.charCodeAt(a + p) === 47 ? d = p : p === 0 && (d = 0));
4535
+ return o.slice(c + p);
4536
+ } else h > y && (r.charCodeAt(a + p) === 47 ? d = p : p === 0 && (d = 0));
4537
4537
  break;
4538
4538
  }
4539
- var b = r.charCodeAt(a + p), _ = o.charCodeAt(h + p);
4539
+ var b = r.charCodeAt(a + p), _ = o.charCodeAt(c + p);
4540
4540
  if (b !== _)
4541
4541
  break;
4542
4542
  b === 47 && (d = p);
@@ -4544,68 +4544,68 @@ function cr() {
4544
4544
  var z = "";
4545
4545
  for (p = a + d + 1; p <= l; ++p)
4546
4546
  (p === l || r.charCodeAt(p) === 47) && (z.length === 0 ? z += ".." : z += "/..");
4547
- return z.length > 0 ? z + o.slice(h + d) : (h += d, o.charCodeAt(h) === 47 && ++h, o.slice(h));
4547
+ return z.length > 0 ? z + o.slice(c + d) : (c += d, o.charCodeAt(c) === 47 && ++c, o.slice(c));
4548
4548
  },
4549
4549
  _makeLong: function(r) {
4550
4550
  return r;
4551
4551
  },
4552
4552
  dirname: function(r) {
4553
4553
  if (s(r), r.length === 0) return ".";
4554
- for (var o = r.charCodeAt(0), a = o === 47, l = -1, c = !0, h = r.length - 1; h >= 1; --h)
4555
- if (o = r.charCodeAt(h), o === 47) {
4556
- if (!c) {
4557
- l = h;
4554
+ for (var o = r.charCodeAt(0), a = o === 47, l = -1, h = !0, c = r.length - 1; c >= 1; --c)
4555
+ if (o = r.charCodeAt(c), o === 47) {
4556
+ if (!h) {
4557
+ l = c;
4558
4558
  break;
4559
4559
  }
4560
4560
  } else
4561
- c = !1;
4561
+ h = !1;
4562
4562
  return l === -1 ? a ? "/" : "." : a && l === 1 ? "//" : r.slice(0, l);
4563
4563
  },
4564
4564
  basename: function(r, o) {
4565
4565
  if (o !== void 0 && typeof o != "string") throw new TypeError('"ext" argument must be a string');
4566
4566
  s(r);
4567
- var a = 0, l = -1, c = !0, h;
4567
+ var a = 0, l = -1, h = !0, c;
4568
4568
  if (o !== void 0 && o.length > 0 && o.length <= r.length) {
4569
4569
  if (o.length === r.length && o === r) return "";
4570
4570
  var u = o.length - 1, m = -1;
4571
- for (h = r.length - 1; h >= 0; --h) {
4572
- var y = r.charCodeAt(h);
4571
+ for (c = r.length - 1; c >= 0; --c) {
4572
+ var y = r.charCodeAt(c);
4573
4573
  if (y === 47) {
4574
- if (!c) {
4575
- a = h + 1;
4574
+ if (!h) {
4575
+ a = c + 1;
4576
4576
  break;
4577
4577
  }
4578
4578
  } else
4579
- m === -1 && (c = !1, m = h + 1), u >= 0 && (y === o.charCodeAt(u) ? --u === -1 && (l = h) : (u = -1, l = m));
4579
+ m === -1 && (h = !1, m = c + 1), u >= 0 && (y === o.charCodeAt(u) ? --u === -1 && (l = c) : (u = -1, l = m));
4580
4580
  }
4581
4581
  return a === l ? l = m : l === -1 && (l = r.length), r.slice(a, l);
4582
4582
  } else {
4583
- for (h = r.length - 1; h >= 0; --h)
4584
- if (r.charCodeAt(h) === 47) {
4585
- if (!c) {
4586
- a = h + 1;
4583
+ for (c = r.length - 1; c >= 0; --c)
4584
+ if (r.charCodeAt(c) === 47) {
4585
+ if (!h) {
4586
+ a = c + 1;
4587
4587
  break;
4588
4588
  }
4589
- } else l === -1 && (c = !1, l = h + 1);
4589
+ } else l === -1 && (h = !1, l = c + 1);
4590
4590
  return l === -1 ? "" : r.slice(a, l);
4591
4591
  }
4592
4592
  },
4593
4593
  extname: function(r) {
4594
4594
  s(r);
4595
- for (var o = -1, a = 0, l = -1, c = !0, h = 0, u = r.length - 1; u >= 0; --u) {
4595
+ for (var o = -1, a = 0, l = -1, h = !0, c = 0, u = r.length - 1; u >= 0; --u) {
4596
4596
  var m = r.charCodeAt(u);
4597
4597
  if (m === 47) {
4598
- if (!c) {
4598
+ if (!h) {
4599
4599
  a = u + 1;
4600
4600
  break;
4601
4601
  }
4602
4602
  continue;
4603
4603
  }
4604
- l === -1 && (c = !1, l = u + 1), m === 46 ? o === -1 ? o = u : h !== 1 && (h = 1) : o !== -1 && (h = -1);
4604
+ l === -1 && (h = !1, l = u + 1), m === 46 ? o === -1 ? o = u : c !== 1 && (c = 1) : o !== -1 && (c = -1);
4605
4605
  }
4606
4606
  return o === -1 || l === -1 || // We saw a non-dot character immediately before the dot
4607
- h === 0 || // The (right-most) trimmed path component is exactly '..'
4608
- h === 1 && o === l - 1 && o === a + 1 ? "" : r.slice(o, l);
4607
+ c === 0 || // The (right-most) trimmed path component is exactly '..'
4608
+ c === 1 && o === l - 1 && o === a + 1 ? "" : r.slice(o, l);
4609
4609
  },
4610
4610
  format: function(r) {
4611
4611
  if (r === null || typeof r != "object")
@@ -4616,9 +4616,9 @@ function cr() {
4616
4616
  s(r);
4617
4617
  var o = { root: "", dir: "", base: "", ext: "", name: "" };
4618
4618
  if (r.length === 0) return o;
4619
- var a = r.charCodeAt(0), l = a === 47, c;
4620
- l ? (o.root = "/", c = 1) : c = 0;
4621
- for (var h = -1, u = 0, m = -1, y = !0, d = r.length - 1, p = 0; d >= c; --d) {
4619
+ var a = r.charCodeAt(0), l = a === 47, h;
4620
+ l ? (o.root = "/", h = 1) : h = 0;
4621
+ for (var c = -1, u = 0, m = -1, y = !0, d = r.length - 1, p = 0; d >= h; --d) {
4622
4622
  if (a = r.charCodeAt(d), a === 47) {
4623
4623
  if (!y) {
4624
4624
  u = d + 1;
@@ -4626,11 +4626,11 @@ function cr() {
4626
4626
  }
4627
4627
  continue;
4628
4628
  }
4629
- m === -1 && (y = !1, m = d + 1), a === 46 ? h === -1 ? h = d : p !== 1 && (p = 1) : h !== -1 && (p = -1);
4629
+ m === -1 && (y = !1, m = d + 1), a === 46 ? c === -1 ? c = d : p !== 1 && (p = 1) : c !== -1 && (p = -1);
4630
4630
  }
4631
- return h === -1 || m === -1 || // We saw a non-dot character immediately before the dot
4631
+ return c === -1 || m === -1 || // We saw a non-dot character immediately before the dot
4632
4632
  p === 0 || // The (right-most) trimmed path component is exactly '..'
4633
- p === 1 && h === m - 1 && h === u + 1 ? m !== -1 && (u === 0 && l ? o.base = o.name = r.slice(1, m) : o.base = o.name = r.slice(u, m)) : (u === 0 && l ? (o.name = r.slice(1, h), o.base = r.slice(1, m)) : (o.name = r.slice(u, h), o.base = r.slice(u, m)), o.ext = r.slice(h, m)), u > 0 ? o.dir = r.slice(0, u - 1) : l && (o.dir = "/"), o;
4633
+ p === 1 && c === m - 1 && c === u + 1 ? m !== -1 && (u === 0 && l ? o.base = o.name = r.slice(1, m) : o.base = o.name = r.slice(u, m)) : (u === 0 && l ? (o.name = r.slice(1, c), o.base = r.slice(1, m)) : (o.name = r.slice(u, c), o.base = r.slice(u, m)), o.ext = r.slice(c, m)), u > 0 ? o.dir = r.slice(0, u - 1) : l && (o.dir = "/"), o;
4634
4634
  },
4635
4635
  sep: "/",
4636
4636
  delimiter: ":",
@@ -5261,8 +5261,8 @@ class tn {
5261
5261
  for (const { element: a, url: l } of i)
5262
5262
  try {
5263
5263
  a.remove(), await this.releaseBlobUrl(l);
5264
- } catch (c) {
5265
- console.error("Error during cleanup:", c);
5264
+ } catch (h) {
5265
+ console.error("Error during cleanup:", h);
5266
5266
  }
5267
5267
  throw o;
5268
5268
  }
@@ -6071,13 +6071,13 @@ class Ur extends ji {
6071
6071
  this._contentProtection,
6072
6072
  r.keyboardPeripherals || []
6073
6073
  ), (this._contentProtection.disableContextMenu || this._contentProtection.checkAutomation || this._contentProtection.checkIFrameEmbedding || this._contentProtection.monitorDevTools || this._contentProtection.protectPrinting?.disable) && (this._navigatorProtector = new rn(this._contentProtection), this._suspiciousActivityListener = (l) => {
6074
- const c = l;
6075
- this.listeners.contentProtection(c.detail.type, c.detail);
6074
+ const h = l;
6075
+ this.listeners.contentProtection(h.detail.type, h.detail);
6076
6076
  }, window.addEventListener(Rt, this._suspiciousActivityListener)), this._keyboardPeripherals.length > 0 && (this._keyboardPeripheralsManager = new sn({
6077
6077
  keyboardPeripherals: this._keyboardPeripherals
6078
6078
  }), this._keyboardPeripheralListener = (l) => {
6079
- const c = l.detail;
6080
- this.listeners.peripheral(c);
6079
+ const h = l.detail;
6080
+ this.listeners.peripheral(h);
6081
6081
  }, window.addEventListener(Lt, this._keyboardPeripheralListener)), n && typeof n.copyWithLocations == "function") {
6082
6082
  this.currentLocation = n;
6083
6083
  const l = this.pub.readingOrder.findIndexWithHref(n.href);
@@ -6180,12 +6180,12 @@ class Ur extends ji {
6180
6180
  if (a.startsWith("http://") || a.startsWith("https://"))
6181
6181
  l = a;
6182
6182
  else if (this.currentLocation.href.startsWith("http://") || this.currentLocation.href.startsWith("https://")) {
6183
- const h = new URL(this.currentLocation.href);
6184
- l = new URL(a, h).href;
6183
+ const c = new URL(this.currentLocation.href);
6184
+ l = new URL(a, c).href;
6185
6185
  } else
6186
6186
  l = Vt.join(Vt.dirname(this.currentLocation.href), a);
6187
- const c = this.pub.readingOrder.findWithHref(l);
6188
- c ? this.goLink(c, !1, () => {
6187
+ const h = this.pub.readingOrder.findWithHref(l);
6188
+ h ? this.goLink(h, !1, () => {
6189
6189
  }) : (console.warn(`Internal link not found in readingOrder: ${l}`), this.listeners.handleLocator(new B({
6190
6190
  href: a
6191
6191
  }).locator));
@@ -6296,7 +6296,7 @@ class Ur extends ji {
6296
6296
  }
6297
6297
  async loadLocator(t, e) {
6298
6298
  let i = !1, n = typeof t.locations.getCssSelector == "function" && t.locations.getCssSelector();
6299
- if (t.text?.highlight ? i = await new Promise((l, c) => {
6299
+ if (t.text?.highlight ? i = await new Promise((l, h) => {
6300
6300
  this.framePool.currentFrames[0].msg.send(
6301
6301
  "go_text",
6302
6302
  n ? [
@@ -6304,9 +6304,9 @@ class Ur extends ji {
6304
6304
  n
6305
6305
  // Include CSS selector if it exists
6306
6306
  ] : t.text?.serialize(),
6307
- (h) => l(h)
6307
+ (c) => l(c)
6308
6308
  );
6309
- }) : n && (i = await new Promise((l, c) => {
6309
+ }) : n && (i = await new Promise((l, h) => {
6310
6310
  this.framePool.currentFrames[0].msg.send(
6311
6311
  "go_text",
6312
6312
  [
@@ -6315,22 +6315,22 @@ class Ur extends ji {
6315
6315
  n
6316
6316
  // Just CSS selector
6317
6317
  ],
6318
- (h) => l(h)
6318
+ (c) => l(c)
6319
6319
  );
6320
6320
  })), i) {
6321
6321
  e(i);
6322
6322
  return;
6323
6323
  }
6324
6324
  const r = typeof t.locations.htmlId == "function" && t.locations.htmlId();
6325
- if (r && (i = await new Promise((l, c) => {
6326
- this.framePool.currentFrames[0].msg.send("go_id", r, (h) => l(h));
6325
+ if (r && (i = await new Promise((l, h) => {
6326
+ this.framePool.currentFrames[0].msg.send("go_id", r, (c) => l(c));
6327
6327
  })), i) {
6328
6328
  e(i);
6329
6329
  return;
6330
6330
  }
6331
6331
  const o = t?.locations?.progression;
6332
- o && o > 0 ? i = await new Promise((l, c) => {
6333
- this.framePool.currentFrames[0].msg.send("go_progression", o, (h) => l(h));
6332
+ o && o > 0 ? i = await new Promise((l, h) => {
6333
+ this.framePool.currentFrames[0].msg.send("go_progression", o, (c) => l(c));
6334
6334
  }) : i = !0, e(i);
6335
6335
  }
6336
6336
  go(t, e, i) {
@@ -6399,6 +6399,8 @@ class on {
6399
6399
  if (this.currentUrl) return this.currentUrl;
6400
6400
  this.currentResource = this.pub.get(this.item);
6401
6401
  const e = await this.currentResource.link();
6402
+ if (!this.currentResource)
6403
+ return "about:blank";
6402
6404
  if (e.mediaType.isHTML) {
6403
6405
  const i = await this.buildHtmlFrame(t);
6404
6406
  return this.currentUrl = i, i;
@@ -6409,6 +6411,7 @@ class on {
6409
6411
  throw Error("Unsupported frame mediatype " + e.mediaType.string);
6410
6412
  }
6411
6413
  async buildHtmlFrame(t = !1) {
6414
+ if (!this.currentResource) throw new Error("No resource loaded");
6412
6415
  const e = await this.currentResource.link(), i = await this.currentResource.readAsString();
6413
6416
  if (!i) throw new Error(`Failed reading item ${e.href}`);
6414
6417
  const n = new DOMParser().parseFromString(
@@ -6422,6 +6425,7 @@ class on {
6422
6425
  return this.injector && await this.injector.injectForDocument(n, e), this.finalizeDOM(n, this.pub.baseURL, e.toURL(this.baseURL) || "", e.mediaType, t, this.cssProperties);
6423
6426
  }
6424
6427
  async buildImageFrame() {
6428
+ if (!this.currentResource) throw new Error("No resource loaded");
6425
6429
  const t = await this.currentResource.link(), e = t.toURL(this.baseURL) || "", i = document.implementation.createHTMLDocument(t.title || t.href);
6426
6430
  if ((t?.height || 0) > 0 && (t?.width || 0) > 0) {
6427
6431
  const o = i.createElement("meta");
@@ -6453,21 +6457,21 @@ class on {
6453
6457
  ...e ? [e] : [],
6454
6458
  ...a
6455
6459
  ])].filter(Boolean);
6456
- if (o && !r && this.setProperties(o, t), t.body.querySelectorAll("img").forEach((h) => {
6457
- h.setAttribute("fetchpriority", "high"), h.setAttribute("referrerpolicy", "origin");
6460
+ if (o && !r && this.setProperties(o, t), t.body.querySelectorAll("img").forEach((c) => {
6461
+ c.setAttribute("fetchpriority", "high"), c.setAttribute("referrerpolicy", "origin");
6458
6462
  }), n.isHTML && this.pub.metadata.languages?.[0]) {
6459
- const h = this.pub.metadata.languages[0];
6463
+ const c = this.pub.metadata.languages[0];
6460
6464
  if (n === g.XHTML) {
6461
6465
  const u = document.documentElement.lang || document.documentElement.getAttribute("xml:lang"), m = document.body.lang || document.body.getAttribute("xml:lang");
6462
- m && !u ? (document.documentElement.lang = m, document.documentElement.setAttribute("xml:lang", m), document.body.removeAttribute("xml:lang"), document.body.removeAttribute("lang")) : u || (document.documentElement.lang = h, document.documentElement.setAttribute("xml:lang", h));
6463
- } else n === g.HTML && !document.documentElement.lang && (document.documentElement.lang = h);
6466
+ m && !u ? (document.documentElement.lang = m, document.documentElement.setAttribute("xml:lang", m), document.body.removeAttribute("xml:lang"), document.body.removeAttribute("lang")) : u || (document.documentElement.lang = c, document.documentElement.setAttribute("xml:lang", c));
6467
+ } else n === g.HTML && !document.documentElement.lang && (document.documentElement.lang = c);
6464
6468
  }
6465
6469
  if (i !== void 0) {
6466
- const h = t.createElement("base");
6467
- h.href = i, h.dataset.readium = "true", t.head.firstChild.before(h);
6470
+ const c = t.createElement("base");
6471
+ c.href = i, c.dataset.readium = "true", t.head.firstChild.before(c);
6468
6472
  }
6469
- const c = t.createElement("meta");
6470
- return c.httpEquiv = "Content-Security-Policy", c.content = Nr(l), c.dataset.readium = "true", t.head.firstChild.before(c), URL.createObjectURL(
6473
+ const h = t.createElement("meta");
6474
+ return h.httpEquiv = "Content-Security-Policy", h.content = Nr(l), h.dataset.readium = "true", t.head.firstChild.before(h), URL.createObjectURL(
6471
6475
  new Blob([new XMLSerializer().serializeToString(t)], {
6472
6476
  type: n.isHTML ? n.string : "application/xhtml+xml"
6473
6477
  // Fallback to XHTML
@@ -6592,14 +6596,14 @@ class Dr {
6592
6596
  }
6593
6597
  async update(t, e, i, n = !1) {
6594
6598
  let r = this.positions.findIndex((l) => l.locations.position === e.locations.position);
6595
- if (r < 0) throw Error(`Locator not found in position list: ${e.locations.position} > ${this.positions.reduce((l, c) => c.locations.position || 0 > l ? c.locations.position || 0 : l, 0)}`);
6599
+ if (r < 0) throw Error(`Locator not found in position list: ${e.locations.position} > ${this.positions.reduce((l, h) => h.locations.position || 0 > l ? h.locations.position || 0 : l, 0)}`);
6596
6600
  const o = this.positions[r].href;
6597
6601
  this.inprogress.has(o) && await this.inprogress.get(o);
6598
- const a = new Promise(async (l, c) => {
6599
- const h = [], u = [];
6602
+ const a = new Promise(async (l, h) => {
6603
+ const c = [], u = [];
6600
6604
  this.positions.forEach((d, p) => {
6601
- (p > r + wi || p < r - wi) && (h.includes(d.href) || h.push(d.href)), p < r + vi && p > r - vi && (u.includes(d.href) || u.push(d.href));
6602
- }), h.forEach(async (d) => {
6605
+ (p > r + wi || p < r - wi) && (c.includes(d.href) || c.push(d.href)), p < r + vi && p > r - vi && (u.includes(d.href) || u.push(d.href));
6606
+ }), c.forEach(async (d) => {
6603
6607
  u.includes(d) || this.pool.has(d) && (await this.pool.get(d)?.destroy(), this.pool.delete(d), this.pendingUpdates.has(d) && this.pendingUpdates.set(d, { inPool: !1 }));
6604
6608
  }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((d) => d.reset()), this.blobs.clear()), this.currentBaseURL = t.baseURL;
6605
6609
  const m = async (d) => {
@@ -6633,7 +6637,7 @@ class Dr {
6633
6637
  try {
6634
6638
  await Promise.all(u.map((d) => m(d)));
6635
6639
  } catch (d) {
6636
- c(d);
6640
+ h(d);
6637
6641
  }
6638
6642
  const y = this.pool.get(o);
6639
6643
  (y?.source !== this._currentFrame?.source || n) && (await this._currentFrame?.hide(), y && await y.load(i), y && await y.show(e.locations.progression), this._currentFrame = y), l();
@@ -6683,10 +6687,10 @@ class Dr {
6683
6687
  }
6684
6688
  class Ir {
6685
6689
  constructor(t, e, i, n = {}, r = []) {
6686
- this.currModules = [], this.cachedPage = void 0, this.peripherals = t, this.debugHref = i, this.contentProtectionConfig = { ...n }, this.keyboardPeripheralsConfig = [...r], this.frame = document.createElement("iframe"), this.frame.sandbox.value = "allow-same-origin allow-scripts", this.frame.classList.add("readium-navigator-iframe"), this.frame.classList.add("blank"), this.frame.scrolling = "no", this.frame.style.visibility = "hidden", this.frame.style.setProperty("aria-hidden", "true"), this.frame.style.display = "none", this.frame.style.position = "absolute", this.frame.style.pointerEvents = "none", this.frame.style.transformOrigin = "0 0", this.frame.style.transform = "scale(1)", this.frame.style.background = "#fff", this.frame.style.touchAction = "none", this.frame.dataset.originalHref = i, this.source = "about:blank", this.wrapper = document.createElement("div"), this.wrapper.style.position = "relative", this.wrapper.style.float = this.wrapper.style.cssFloat = e === F.rtl ? "right" : "left", this.wrapper.appendChild(this.frame);
6690
+ this.frameIsAppended = !1, this.currModules = [], this.cachedPage = void 0, this.peripherals = t, this.debugHref = i, this.contentProtectionConfig = { ...n }, this.keyboardPeripheralsConfig = [...r], this.frame = document.createElement("iframe"), this.frame.sandbox.value = "allow-same-origin allow-scripts", this.frame.classList.add("readium-navigator-iframe"), this.frame.classList.add("blank"), this.frame.scrolling = "no", this.frame.style.visibility = "hidden", this.frame.style.setProperty("aria-hidden", "true"), this.frame.style.display = "none", this.frame.style.position = "absolute", this.frame.style.pointerEvents = "none", this.frame.style.transformOrigin = "0 0", this.frame.style.transform = "scale(1)", this.frame.style.background = "#fff", this.frame.style.touchAction = "none", this.frame.dataset.originalHref = i, this.source = "about:blank", this.wrapper = document.createElement("div"), this.wrapper.style.position = "relative", this.wrapper.style.float = this.wrapper.style.cssFloat = e === F.rtl ? "right" : "left";
6687
6691
  }
6688
6692
  async load(t, e) {
6689
- return this.source === e && this.loadPromise && [...this.currModules].sort().join("|") === [...t].sort().join("|") ? this.loadPromise : (this.loaded && this.source !== e && this.window.stop(), this.source = e, this.loadPromise = new Promise((i, n) => {
6693
+ return this.frameIsAppended || (this.wrapper.appendChild(this.frame), this.frameIsAppended = !0), this.source === e && this.loadPromise && [...this.currModules].sort().join("|") === [...t].sort().join("|") ? this.loadPromise : (this.loaded && this.source !== e && this.window.stop(), this.source = e, this.loadPromise = new Promise((i, n) => {
6690
6694
  if (this.loader && this.loaded) {
6691
6695
  const r = this.frame.contentWindow;
6692
6696
  if ([...this.currModules].sort().join("|") === [...t].sort().join("|")) {
@@ -6884,15 +6888,15 @@ class Br {
6884
6888
  };
6885
6889
  let r, o, a, l;
6886
6890
  a = r = i, l = o = 1 - i;
6887
- const c = {
6891
+ const h = {
6888
6892
  X: null,
6889
6893
  Y: null
6890
6894
  };
6891
- return n.X < a ? c.X = 0 : l < n.X ? c.X = 2 : c.X = 1, n.Y < r ? c.Y = 0 : o < n.Y ? c.Y = 2 : c.Y = 1, {
6895
+ return n.X < a ? h.X = 0 : l < n.X ? h.X = 2 : h.X = 1, n.Y < r ? h.Y = 0 : o < n.Y ? h.Y = 2 : h.Y = 1, {
6892
6896
  Target: t.target,
6893
6897
  Coord: e,
6894
6898
  Ratio: n,
6895
- Division: c
6899
+ Division: h
6896
6900
  };
6897
6901
  }
6898
6902
  }
@@ -7070,10 +7074,10 @@ class Gr {
7070
7074
  this.debugger.DOM.touch2.style.top = `${y.Y - 10}px`, this.debugger.DOM.touch2.style.left = `${y.X - 10}px`, this.debugger.DOM.touch2.innerText = `${y.X.toFixed(2)},${y.Y.toFixed(2)}`;
7071
7075
  }
7072
7076
  l.X -= this.manager.width / 2, l.Y -= this.manager.height / 2;
7073
- let c = -l.X / r;
7074
- c += l.X / this.scale, this.pinch.target.X += c, l.X += this.pinch.target.X * this.scale / this.pinch.startScale;
7075
- let h = -l.Y / r;
7076
- h += l.Y / this.scale, this.pinch.target.Y += h, l.Y += this.pinch.target.Y * this.scale / this.pinch.startScale;
7077
+ let h = -l.X / r;
7078
+ h += l.X / this.scale, this.pinch.target.X += h, l.X += this.pinch.target.X * this.scale / this.pinch.startScale;
7079
+ let c = -l.Y / r;
7080
+ c += l.Y / this.scale, this.pinch.target.Y += c, l.Y += this.pinch.target.Y * this.scale / this.pinch.startScale;
7077
7081
  let u = (l.X - (this.pan.startX - this.manager.width / 2)) * 1 / this.scale, m = (l.Y - (this.pan.startY - this.manager.height / 2)) * 1 / this.scale;
7078
7082
  this.pan.translateX = u, this.pan.translateY = m, this.debugger?.show && (this.debugger.DOM.pinchTarget.style.left = `${this.pinch.target.X * this.scale / this.pinch.startScale - 5 + this.manager.width / 2}px`, this.debugger.DOM.pinchTarget.style.top = `${this.pinch.target.Y * this.scale / this.pinch.startScale - 5 + this.manager.height / 2}px`, this.debugger.DOM.pinchTarget.innerText = `${(this.pinch.target.X * this.scale / this.pinch.startScale).toFixed(2)},${(this.pinch.target.Y * this.scale / this.pinch.startScale).toFixed(2)}`);
7079
7083
  }
@@ -7089,10 +7093,10 @@ Overscroll: ${this.pan.overscrollX.toFixed(2)},${this.pan.overscrollY.toFixed(2)
7089
7093
  }
7090
7094
  if (this.dragState > 0 && this.pan.letItGo) {
7091
7095
  this.pan.endX = e.X;
7092
- const a = this.manager.currentSlide * (this.manager.width / this.manager.perPage), l = this.pan.endX - this.pan.startX, c = this.manager.rtl ? a + l : a - l;
7096
+ const a = this.manager.currentSlide * (this.manager.width / this.manager.perPage), l = this.pan.endX - this.pan.startX, h = this.manager.rtl ? a + l : a - l;
7093
7097
  cancelAnimationFrame(this.moveFrame), this.moveFrame = requestAnimationFrame(() => {
7094
7098
  requestAnimationFrame(() => {
7095
- this.manager.spineElement.style.transform = `translate3d(${(this.manager.rtl ? 1 : -1) * c}px, 0, 0)`;
7099
+ this.manager.spineElement.style.transform = `translate3d(${(this.manager.rtl ? 1 : -1) * h}px, 0, 0)`;
7096
7100
  });
7097
7101
  });
7098
7102
  }
@@ -7186,10 +7190,12 @@ class Zr {
7186
7190
  constructor(t, e, i, n, r, o) {
7187
7191
  if (this.pool = /* @__PURE__ */ new Map(), this.blobs = /* @__PURE__ */ new Map(), this.inprogress = /* @__PURE__ */ new Map(), this.delayedShow = /* @__PURE__ */ new Map(), this.delayedTimeout = /* @__PURE__ */ new Map(), this.previousFrames = [], this.injector = null, this.width = 0, this.height = 0, this.transform = "", this.currentSlide = 0, this.spread = !0, this.orientationInternal = -1, this.container = t, this.positions = e, this.pub = i, this.injector = n ?? null, this.contentProtectionConfig = r || {}, this.keyboardPeripheralsConfig = o || [], this.spreadPresentation = i.metadata.otherMetadata?.spread || Ee.auto, this.pub.metadata.effectiveReadingProgression !== F.rtl && this.pub.metadata.effectiveReadingProgression !== F.ltr)
7188
7192
  throw Error("Unsupported reading progression for EPUB");
7189
- this.spreader = new jr(this.pub), this.containerHeightCached = t.clientHeight, this.bookElement = document.createElement("div"), this.bookElement.ariaLabel = "Book", this.bookElement.tabIndex = -1, this.updateBookStyle(!0), this.spineElement = document.createElement("div"), this.spineElement.ariaLabel = "Spine", this.bookElement.appendChild(this.spineElement), this.container.appendChild(this.bookElement), this.updateSpineStyle(!0), this.peripherals = new Gr(this), this.pub.readingOrder.items.forEach((a) => {
7190
- const l = new Ir(this.peripherals, this.pub.metadata.effectiveReadingProgression, a.href, this.contentProtectionConfig, this.keyboardPeripheralsConfig);
7191
- this.spineElement.appendChild(l.element), this.pool.set(a.href, l), l.width = 100 / this.length * (a.properties?.otherProperties.orientation === Pe.landscape || a.properties?.otherProperties.addBlank ? this.perPage : 1), l.height = this.height;
7192
- });
7193
+ this.spreader = new jr(this.pub), this.containerHeightCached = t.clientHeight, this.bookElement = document.createElement("div"), this.bookElement.ariaLabel = "Book", this.bookElement.tabIndex = -1, this.updateBookStyle(!0), this.spineElement = document.createElement("div"), this.spineElement.ariaLabel = "Spine", this.bookElement.appendChild(this.spineElement), this.container.appendChild(this.bookElement), this.updateSpineStyle(!0), this.peripherals = new Gr(this);
7194
+ const a = document.createDocumentFragment();
7195
+ this.pub.readingOrder.items.forEach((l) => {
7196
+ const h = new Ir(this.peripherals, this.pub.metadata.effectiveReadingProgression, l.href, this.contentProtectionConfig, this.keyboardPeripheralsConfig);
7197
+ this.pool.set(l.href, h), h.width = 100 / this.length * (l.properties?.otherProperties.orientation === Pe.landscape || l.properties?.otherProperties.addBlank ? this.perPage : 1), h.height = this.height, a.appendChild(h.wrapper);
7198
+ }), this.spineElement.appendChild(a);
7193
7199
  }
7194
7200
  set listener(t) {
7195
7201
  this._listener = t;
@@ -7396,11 +7402,11 @@ class Zr {
7396
7402
  this.perPage > 1 && r++;
7397
7403
  for (const l of o)
7398
7404
  await this.waitForItem(l.href);
7399
- const a = new Promise(async (l, c) => {
7400
- const h = [], u = [];
7405
+ const a = new Promise(async (l, h) => {
7406
+ const c = [], u = [];
7401
7407
  this.positions.forEach((d, p) => {
7402
- (p > r + Ei || p < r - Ei) && (h.includes(d.href) || h.push(d.href)), p < r + Ci && p > r - Ci && (u.includes(d.href) || u.push(d.href));
7403
- }), h.forEach(async (d) => {
7408
+ (p > r + Ei || p < r - Ei) && (c.includes(d.href) || c.push(d.href)), p < r + Ci && p > r - Ci && (u.includes(d.href) || u.push(d.href));
7409
+ }), c.forEach(async (d) => {
7404
7410
  u.includes(d) || this.pool.has(d) && (this.cancelShowing(d), await this.pool.get(d)?.unload(), this.blobs.get(d)?.reset());
7405
7411
  }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((d) => d.reset()), this.blobs.clear()), this.currentBaseURL = t.baseURL;
7406
7412
  const m = async (d) => {
@@ -7427,7 +7433,7 @@ class Zr {
7427
7433
  try {
7428
7434
  await Promise.all(u.map((d) => m(d)));
7429
7435
  } catch (d) {
7430
- c(d);
7436
+ h(d);
7431
7437
  }
7432
7438
  const y = [];
7433
7439
  for (const d of o) {
@@ -8075,7 +8081,7 @@ class os {
8075
8081
  // TODO: As scroll shows, the effective line-length
8076
8082
  // should be the same as uncompensated when scale >= 1
8077
8083
  paginate(t, e, i) {
8078
- const n = Math.round(Ut(this.containerParent) - this.constraint), r = this.getCompensatedMetrics(t, e), { zoomCompensation: o, optimal: a, minimal: l, maximal: c } = r, h = () => n >= a && c !== null ? Math.min(Math.round(c * o), n) : n;
8084
+ const n = Math.round(Ut(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
8085
  let u = 1, m = n;
8080
8086
  if (i === void 0)
8081
8087
  return {
@@ -8084,24 +8090,24 @@ class os {
8084
8090
  effectiveLineLength: Math.round(m / u * o)
8085
8091
  };
8086
8092
  if (i === null)
8087
- if (n >= a && c !== null) {
8093
+ if (n >= a && h !== null) {
8088
8094
  u = Math.floor(n / a);
8089
- const y = Math.round(u * (c * o));
8095
+ const y = Math.round(u * (h * o));
8090
8096
  m = Math.min(y, n);
8091
8097
  } else
8092
- m = h();
8098
+ m = c();
8093
8099
  else if (i > 1) {
8094
8100
  const y = Math.round(i * (l !== null ? l : a));
8095
8101
  if (n >= y)
8096
- if (u = i, c === null)
8102
+ if (u = i, h === null)
8097
8103
  m = n;
8098
8104
  else {
8099
- const d = Math.round(u * (c * o));
8105
+ const d = Math.round(u * (h * o));
8100
8106
  m = Math.min(d, n);
8101
8107
  }
8102
8108
  else if (l !== null && n < Math.round(i * l))
8103
8109
  if (u = Math.floor(n / l), u <= 1)
8104
- u = 1, m = h();
8110
+ u = 1, m = c();
8105
8111
  else {
8106
8112
  const d = Math.round(u * (a * o));
8107
8113
  m = Math.min(d, n);
@@ -8112,7 +8118,7 @@ class os {
8112
8118
  m = Math.min(d, n);
8113
8119
  }
8114
8120
  } else
8115
- u = 1, m = h();
8121
+ u = 1, m = c();
8116
8122
  return {
8117
8123
  colCount: u,
8118
8124
  effectiveContainerWidth: m,
@@ -8122,17 +8128,17 @@ class os {
8122
8128
  // This behaves as paginate where colCount = 1
8123
8129
  computeScrollLength(t, e) {
8124
8130
  const i = Math.round(Ut(this.containerParent) - this.constraint), n = this.getCompensatedMetrics(t && (t < 1 || e) ? t : 1, e), r = n.zoomCompensation, o = n.optimal, a = n.maximal;
8125
- let l, c = i, h = Math.round(o * r);
8131
+ let l, h = i, c = Math.round(o * r);
8126
8132
  if (a === null)
8127
- h = i;
8133
+ c = i;
8128
8134
  else {
8129
8135
  const u = Math.min(Math.round(a * r), i);
8130
- h = e ? u : Math.round(u * r);
8136
+ c = e ? u : Math.round(u * r);
8131
8137
  }
8132
8138
  return {
8133
8139
  colCount: l,
8134
- effectiveContainerWidth: c,
8135
- effectiveLineLength: h
8140
+ effectiveContainerWidth: h,
8141
+ effectiveLineLength: c
8136
8142
  };
8137
8143
  }
8138
8144
  setContainerWidth() {
@@ -9490,14 +9496,14 @@ class ln extends ji {
9490
9496
  }), this._contentProtection = o.contentProtection || {}, this._keyboardPeripherals = this.mergeKeyboardPeripherals(
9491
9497
  this._contentProtection,
9492
9498
  o.keyboardPeripherals || []
9493
- ), (this._contentProtection.disableContextMenu || this._contentProtection.checkAutomation || this._contentProtection.checkIFrameEmbedding || this._contentProtection.monitorDevTools || this._contentProtection.protectPrinting?.disable) && (this._navigatorProtector = new rn(this._contentProtection), this._suspiciousActivityListener = (c) => {
9494
- const { type: h, ...u } = c.detail;
9495
- h === "context_menu" ? this.listeners.contextMenu(u) : this.listeners.contentProtection(h, u);
9499
+ ), (this._contentProtection.disableContextMenu || this._contentProtection.checkAutomation || this._contentProtection.checkIFrameEmbedding || this._contentProtection.monitorDevTools || this._contentProtection.protectPrinting?.disable) && (this._navigatorProtector = new rn(this._contentProtection), this._suspiciousActivityListener = (h) => {
9500
+ const { type: c, ...u } = h.detail;
9501
+ c === "context_menu" ? this.listeners.contextMenu(u) : this.listeners.contentProtection(c, u);
9496
9502
  }, window.addEventListener(Rt, this._suspiciousActivityListener)), this._keyboardPeripherals.length > 0 && (this._keyboardPeripheralsManager = new sn({
9497
9503
  keyboardPeripherals: this._keyboardPeripherals
9498
- }), this._keyboardPeripheralListener = (c) => {
9499
- const h = c.detail;
9500
- this.listeners.peripheral(h);
9504
+ }), this._keyboardPeripheralListener = (h) => {
9505
+ const c = h.detail;
9506
+ this.listeners.peripheral(c);
9501
9507
  }, window.addEventListener(Lt, this._keyboardPeripheralListener)), this.resizeObserver = new ResizeObserver(() => this.ownerWindow.requestAnimationFrame(async () => await this.resizeHandler())), this.resizeObserver.observe(this.container.parentElement || document.documentElement);
9502
9508
  }
9503
9509
  static determineLayout(t, e) {
@@ -9847,7 +9853,7 @@ class ln extends ji {
9847
9853
  }
9848
9854
  async loadLocator(t, e) {
9849
9855
  let i = !1, n = typeof t.locations.getCssSelector == "function" && t.locations.getCssSelector();
9850
- if (t.text?.highlight ? i = await new Promise((l, c) => {
9856
+ if (t.text?.highlight ? i = await new Promise((l, h) => {
9851
9857
  this._cframes[0].msg.send(
9852
9858
  "go_text",
9853
9859
  n ? [
@@ -9855,9 +9861,9 @@ class ln extends ji {
9855
9861
  n
9856
9862
  // Include CSS selector if it exists
9857
9863
  ] : t.text?.serialize(),
9858
- (h) => l(h)
9864
+ (c) => l(c)
9859
9865
  );
9860
- }) : n && (i = await new Promise((l, c) => {
9866
+ }) : n && (i = await new Promise((l, h) => {
9861
9867
  this._cframes[0].msg.send(
9862
9868
  "go_text",
9863
9869
  [
@@ -9866,22 +9872,22 @@ class ln extends ji {
9866
9872
  n
9867
9873
  // Just CSS selector
9868
9874
  ],
9869
- (h) => l(h)
9875
+ (c) => l(c)
9870
9876
  );
9871
9877
  })), i) {
9872
9878
  e(i);
9873
9879
  return;
9874
9880
  }
9875
9881
  const r = typeof t.locations.htmlId == "function" && t.locations.htmlId();
9876
- if (r && (i = await new Promise((l, c) => {
9877
- this._cframes[0].msg.send("go_id", r, (h) => l(h));
9882
+ if (r && (i = await new Promise((l, h) => {
9883
+ this._cframes[0].msg.send("go_id", r, (c) => l(c));
9878
9884
  })), i) {
9879
9885
  e(i);
9880
9886
  return;
9881
9887
  }
9882
9888
  const o = t?.locations?.progression;
9883
- o && o > 0 ? i = await new Promise((l, c) => {
9884
- this._cframes[0].msg.send("go_progression", o, (h) => l(h));
9889
+ o && o > 0 ? i = await new Promise((l, h) => {
9890
+ this._cframes[0].msg.send("go_progression", o, (c) => l(c));
9885
9891
  }) : i = !0, e(i);
9886
9892
  }
9887
9893
  go(t, e, i) {