@readium/navigator 2.3.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -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 h = "";
350
+ let c = "";
351
351
  for (const m in a) {
352
352
  const y = a[m];
353
- h += `;${m}=${y}`;
353
+ c += `;${m}=${y}`;
354
354
  }
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;
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;
357
357
  }
358
358
  static parse(t) {
359
359
  return new g(t);
@@ -1473,7 +1473,7 @@ function _n(s, t, e) {
1473
1473
  return e.map((n) => {
1474
1474
  const r = Math.max(0, n.end - t.length - n.errors), o = Ke(s.slice(r, n.end));
1475
1475
  return {
1476
- start: ki(o, i, n.errors).reduce((l, h) => n.end - h.end < l ? n.end - h.end : l, n.end),
1476
+ start: ki(o, i, n.errors).reduce((l, c) => n.end - c.end < l ? n.end - c.end : l, n.end),
1477
1477
  end: n.end,
1478
1478
  errors: n.errors
1479
1479
  };
@@ -1484,10 +1484,10 @@ function ne(s) {
1484
1484
  }
1485
1485
  function Ze(s, t, e, i) {
1486
1486
  let n = s.P[e], r = s.M[e];
1487
- const o = i >>> 31, a = t[e] | o, l = a | r, h = (a & n) + n ^ n | a;
1488
- let c = r | ~(h | n), u = n & h;
1489
- const m = ne(c & s.lastRowMask[e]) - ne(u & s.lastRowMask[e]);
1490
- 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;
1487
+ const o = i >>> 31, a = t[e] | o, l = a | r, c = (a & n) + n ^ n | a;
1488
+ let h = r | ~(c | n), u = n & c;
1489
+ const m = ne(h & s.lastRowMask[e]) - ne(u & s.lastRowMask[e]);
1490
+ 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
1491
  }
1492
1492
  function ki(s, t, e) {
1493
1493
  if (t.length === 0)
@@ -1499,15 +1499,15 @@ function ki(s, t, e) {
1499
1499
  lastRowMask: new Uint32Array(r + 1)
1500
1500
  };
1501
1501
  o.lastRowMask.fill(1 << 31), o.lastRowMask[r] = 1 << (t.length - 1) % n;
1502
- const a = new Uint32Array(r + 1), l = /* @__PURE__ */ new Map(), h = [];
1502
+ const a = new Uint32Array(r + 1), l = /* @__PURE__ */ new Map(), c = [];
1503
1503
  for (let m = 0; m < 256; m++)
1504
- h.push(a);
1504
+ c.push(a);
1505
1505
  for (let m = 0; m < t.length; m += 1) {
1506
1506
  const y = t.charCodeAt(m);
1507
1507
  if (l.has(y))
1508
1508
  continue;
1509
1509
  const d = new Uint32Array(r + 1);
1510
- l.set(y, d), y < h.length && (h[y] = d);
1510
+ l.set(y, d), y < c.length && (c[y] = d);
1511
1511
  for (let p = 0; p <= r; p += 1) {
1512
1512
  d[p] = 0;
1513
1513
  for (let b = 0; b < n; b += 1) {
@@ -1518,37 +1518,37 @@ function ki(s, t, e) {
1518
1518
  }
1519
1519
  }
1520
1520
  }
1521
- let c = Math.max(0, Math.ceil(e / n) - 1);
1521
+ let h = Math.max(0, Math.ceil(e / n) - 1);
1522
1522
  const u = new Uint32Array(r + 1);
1523
- for (let m = 0; m <= c; m += 1)
1523
+ for (let m = 0; m <= h; m += 1)
1524
1524
  u[m] = (m + 1) * n;
1525
1525
  u[r] = t.length;
1526
- for (let m = 0; m <= c; m += 1)
1526
+ for (let m = 0; m <= h; m += 1)
1527
1527
  o.P[m] = -1, o.M[m] = 0;
1528
1528
  for (let m = 0; m < s.length; m += 1) {
1529
1529
  const y = s.charCodeAt(m);
1530
1530
  let d;
1531
- y < h.length ? d = h[y] : (d = l.get(y), typeof d > "u" && (d = a));
1531
+ y < c.length ? d = c[y] : (d = l.get(y), typeof d > "u" && (d = a));
1532
1532
  let p = 0;
1533
- for (let b = 0; b <= c; b += 1)
1533
+ for (let b = 0; b <= h; b += 1)
1534
1534
  p = Ze(o, d, b, p), u[b] += p;
1535
- if (u[c] - p <= e && c < r && (d[c + 1] & 1 || p < 0)) {
1536
- c += 1, o.P[c] = -1, o.M[c] = 0;
1535
+ if (u[h] - p <= e && h < r && (d[h + 1] & 1 || p < 0)) {
1536
+ h += 1, o.P[h] = -1, o.M[h] = 0;
1537
1537
  let b;
1538
- if (c === r) {
1538
+ if (h === r) {
1539
1539
  const v = t.length % n;
1540
1540
  b = v === 0 ? n : v;
1541
1541
  } else
1542
1542
  b = n;
1543
- u[c] = u[c - 1] + b - p + Ze(o, d, c, p);
1543
+ u[h] = u[h - 1] + b - p + Ze(o, d, h, p);
1544
1544
  } else
1545
- for (; c > 0 && u[c] >= e + n; )
1546
- c -= 1;
1547
- c === r && u[c] <= e && (u[c] < e && i.splice(0, i.length), i.push({
1545
+ for (; h > 0 && u[h] >= e + n; )
1546
+ h -= 1;
1547
+ h === r && u[h] <= e && (u[h] < e && i.splice(0, i.length), i.push({
1548
1548
  start: -1,
1549
1549
  end: m + 1,
1550
- errors: u[c]
1551
- }), e = u[c]);
1550
+ errors: u[h]
1551
+ }), e = u[h]);
1552
1552
  }
1553
1553
  return i;
1554
1554
  }
@@ -1618,8 +1618,8 @@ function Qe(s, t) {
1618
1618
  let o = -1;
1619
1619
  const a = () => {
1620
1620
  if (r = t === 1 ? e.nextNode() : e.previousNode(), r) {
1621
- const l = r.textContent, h = t === 1 ? 0 : l.length;
1622
- o = ue(l, h, t);
1621
+ const l = r.textContent, c = t === 1 ? 0 : l.length;
1622
+ o = ue(l, c, t);
1623
1623
  }
1624
1624
  };
1625
1625
  for (; r && o === -1 && r !== n; )
@@ -1978,24 +1978,24 @@ function Rn(s, t) {
1978
1978
  let e = s.getClientRects();
1979
1979
  e.length || s.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (e = s.commonAncestorContainer.getClientRects());
1980
1980
  const i = 1, n = [];
1981
- for (const h of e)
1981
+ for (const c of e)
1982
1982
  n.push({
1983
- bottom: h.bottom,
1984
- height: h.height,
1985
- left: h.left,
1986
- right: h.right,
1987
- top: h.top,
1988
- width: h.width
1983
+ bottom: c.bottom,
1984
+ height: c.height,
1985
+ left: c.left,
1986
+ right: c.right,
1987
+ top: c.top,
1988
+ width: c.width
1989
1989
  });
1990
1990
  const r = Mi(
1991
1991
  n,
1992
1992
  i
1993
1993
  ), o = On(r, i), a = Ui(o), l = 4;
1994
- for (let h = a.length - 1; h >= 0; h--) {
1995
- const c = a[h];
1996
- if (!(c.width * c.height > l))
1994
+ for (let c = a.length - 1; c >= 0; c--) {
1995
+ const h = a[c];
1996
+ if (!(h.width * h.height > l))
1997
1997
  if (a.length > 1)
1998
- a.splice(h, 1);
1998
+ a.splice(c, 1);
1999
1999
  else
2000
2000
  break;
2001
2001
  }
@@ -2060,10 +2060,10 @@ function Ui(s) {
2060
2060
  if (a.length === 1)
2061
2061
  r = a, o = i;
2062
2062
  else {
2063
- const h = ei(n, i);
2064
- a.length < h.length ? (r = a, o = i) : (r = h, o = n);
2063
+ const c = ei(n, i);
2064
+ a.length < c.length ? (r = a, o = i) : (r = c, o = n);
2065
2065
  }
2066
- const l = s.filter((h) => h !== o);
2066
+ const l = s.filter((c) => c !== o);
2067
2067
  return Array.prototype.push.apply(l, r), Ui(l);
2068
2068
  }
2069
2069
  }
@@ -2214,10 +2214,10 @@ const ct = { r: 255, g: 255, b: 255, a: 1 }, st = /* @__PURE__ */ new Map(), An
2214
2214
  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);
2215
2215
  const a = n.getImageData(r, o, 1, 1);
2216
2216
  yt = (yt + 1) % 25;
2217
- const [l, h, c, u] = a.data;
2217
+ const [l, c, h, u] = a.data;
2218
2218
  if (u === 0)
2219
2219
  return At(s, "Fully transparent color."), st.set(e, null), ct;
2220
- const m = { r: l, g: h, b: c, a: u / 255 };
2220
+ const m = { r: l, g: c, b: h, a: u / 255 };
2221
2221
  return st.set(e, m), m;
2222
2222
  } catch (r) {
2223
2223
  return At(s, `Error: ${r instanceof Error ? r.message : String(r)}`), st.set(e, null), ct;
@@ -2322,7 +2322,7 @@ class Nn {
2322
2322
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2323
2323
  "column-count"
2324
2324
  )
2325
- ), r = i / (n || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, l = o.scrollTop, h = (d, p, b) => {
2325
+ ), r = i / (n || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, l = o.scrollTop, c = (d, p, b) => {
2326
2326
  if (d.style.position = "absolute", t.decoration?.style?.width === "viewport") {
2327
2327
  d.style.width = `${i}px`, d.style.height = `${p.height}px`;
2328
2328
  let v = Math.floor(p.left / i) * i;
@@ -2335,7 +2335,7 @@ class Nn {
2335
2335
  d.style.left = `${v + a}px`, d.style.top = `${p.top + l}px`;
2336
2336
  } else
2337
2337
  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`;
2338
- }, c = t.range.getBoundingClientRect();
2338
+ }, h = t.range.getBoundingClientRect();
2339
2339
  let u = this.wnd.document.createElement("template");
2340
2340
  const m = this.getCurrentDarkMode();
2341
2341
  u.innerHTML = `
@@ -2355,7 +2355,7 @@ class Nn {
2355
2355
  const y = u.content.firstElementChild;
2356
2356
  if (t.decoration?.style?.layout === "bounds") {
2357
2357
  const d = y.cloneNode(!0);
2358
- d.style.setProperty("pointer-events", "none"), h(d, c, c), e.append(d);
2358
+ d.style.setProperty("pointer-events", "none"), c(d, h, h), e.append(d);
2359
2359
  } else {
2360
2360
  let d = Rn(
2361
2361
  t.range
@@ -2363,7 +2363,7 @@ class Nn {
2363
2363
  d = d.sort((p, b) => p.top < b.top ? -1 : p.top > b.top ? 1 : 0);
2364
2364
  for (let p of d) {
2365
2365
  const b = y.cloneNode(!0);
2366
- b.style.setProperty("pointer-events", "none"), h(b, p, c), e.append(b);
2366
+ b.style.setProperty("pointer-events", "none"), c(b, p, h), e.append(b);
2367
2367
  }
2368
2368
  }
2369
2369
  t.container = e, t.clickableElements = Array.from(
@@ -2451,8 +2451,8 @@ const vt = class vt extends ft {
2451
2451
  }), 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) => {
2452
2452
  i.some((r) => {
2453
2453
  if (r.type === "attributes" && r.attributeName === "style") {
2454
- 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");
2455
- return h !== c || u !== m;
2454
+ 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");
2455
+ return c !== h || u !== m;
2456
2456
  }
2457
2457
  return !1;
2458
2458
  }) && this.updateHighlightStyles();
@@ -2513,13 +2513,13 @@ function li(s) {
2513
2513
  if (!t)
2514
2514
  return !1;
2515
2515
  const e = s.document.querySelectorAll("div[id^='readium-virtual-page']");
2516
- for (const h of e)
2517
- h.remove();
2516
+ for (const c of e)
2517
+ c.remove();
2518
2518
  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;
2519
2519
  if (l > 0)
2520
- for (let h = 0; h < l; h++) {
2521
- const c = s.document.createElement("div");
2522
- 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);
2520
+ for (let c = 0; c < l; c++) {
2521
+ const h = s.document.createElement("div");
2522
+ 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);
2523
2523
  }
2524
2524
  return i !== l;
2525
2525
  }
@@ -2645,8 +2645,8 @@ class ze {
2645
2645
  }), this.history = this.history.filter((p) => r - p.timestamp < 2e3).slice(-(this.options.historySize || 20)), this.history.length < 3) return !1;
2646
2646
  if (n > this.options.maxVelocity)
2647
2647
  return this.resetAfterDetection(), !0;
2648
- 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;
2649
- if (c < this.options.minVariance && u < h * 0.1) {
2648
+ 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;
2649
+ if (h < this.options.minVariance && u < c * 0.1) {
2650
2650
  if (this.consistentScrollCount++, this.consistentScrollCount >= (this.options.maxConsistentScrolls || 10))
2651
2651
  return this.resetAfterDetection(), !0;
2652
2652
  } else
@@ -2701,11 +2701,11 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2701
2701
  }
2702
2702
  // Snaps the current offset to the page width.
2703
2703
  snapCurrentOffset(t = !1, e = !1) {
2704
- 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 = (
2704
+ 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 = (
2705
2705
  // The hurdle to overcome in order to change pages
2706
2706
  l * (this.wnd.innerWidth / 3) * (l * r > 0 ? 2 : 1)
2707
- ), c = this.snapOffset(a + h), u = c > this.scrollOffset() ? "right" : "left";
2708
- if (this.checkSuspiciousSnap(u, Math.abs(c - this.scrollOffset())), t && c !== this.scrollOffset()) {
2707
+ ), h = this.snapOffset(a + c), u = h > this.scrollOffset() ? "right" : "left";
2708
+ if (this.checkSuspiciousSnap(u, Math.abs(h - this.scrollOffset())), t && h !== this.scrollOffset()) {
2709
2709
  this.snappingCancelled = !1;
2710
2710
  const m = (b, v, L, Q) => L > Q ? v : b + (v - b) * Fn(L / Q), y = (
2711
2711
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
@@ -2715,13 +2715,13 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2715
2715
  const p = (b) => {
2716
2716
  if (this.snappingCancelled) return;
2717
2717
  d || (d = b);
2718
- const v = b - d, L = m(this.overscroll, 0, v, y), Q = m(i, c, v, y);
2719
- n.scrollLeft = Q, this.overscroll !== 0 && (n.style.transform = `translate3d(${-L}px, 0px, 0px)`), v < y ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), n.style.removeProperty("transform"), n.scrollLeft = c, e || this.reportProgress());
2718
+ const v = b - d, L = m(this.overscroll, 0, v, y), Q = m(i, h, v, y);
2719
+ n.scrollLeft = Q, this.overscroll !== 0 && (n.style.transform = `translate3d(${-L}px, 0px, 0px)`), v < y ? this.wnd.requestAnimationFrame(p) : (this.clearTouches(), n.style.removeProperty("transform"), n.scrollLeft = h, e || this.reportProgress());
2720
2720
  };
2721
2721
  this.wnd.requestAnimationFrame(p);
2722
2722
  } else
2723
2723
  n.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2724
- n.scrollLeft = c, this.clearTouches(), e || this.reportProgress();
2724
+ n.scrollLeft = h, this.clearTouches(), e || this.reportProgress();
2725
2725
  });
2726
2726
  }
2727
2727
  dragOffset() {
@@ -2828,8 +2828,8 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2828
2828
  }), this.resizeObserver.observe(t.document.body), this.mutationObserver = new MutationObserver((r) => {
2829
2829
  for (const o of r)
2830
2830
  if (o.target === this.wnd.document.documentElement) {
2831
- const a = o.oldValue, l = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, c = a?.match(h), u = l?.match(h);
2832
- (!c && !u || c && !u || c && u && c[1] !== u[1]) && (t.requestAnimationFrame(() => {
2831
+ const a = o.oldValue, l = o.target.getAttribute("style"), c = /transform\s*:\s*([^;]+)/, h = a?.match(c), u = l?.match(c);
2832
+ (!h && !u || h && !u || h && u && h[1] !== u[1]) && (t.requestAnimationFrame(() => {
2833
2833
  t && li(t);
2834
2834
  }), this.onWidthChange());
2835
2835
  } else
@@ -2851,8 +2851,8 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2851
2851
  }
2852
2852
  this.wnd.requestAnimationFrame(() => {
2853
2853
  this.cachedScrollWidth = this.doc().scrollWidth;
2854
- const l = this.cachedScrollWidth, h = nt(t) ? -1 : 1, c = l * a * h;
2855
- this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), A(this.wnd), o(!0);
2854
+ const l = this.cachedScrollWidth, c = nt(t) ? -1 : 1, h = l * a * c;
2855
+ this.doc().scrollLeft = this.snapOffset(h), this.reportProgress(), A(this.wnd), o(!0);
2856
2856
  });
2857
2857
  }), e.register("go_id", U.moduleName, (r, o) => {
2858
2858
  const a = t.document.getElementById(r);
@@ -2866,7 +2866,7 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2866
2866
  }), e.register("go_text", U.moduleName, (r, o) => {
2867
2867
  let a;
2868
2868
  Array.isArray(r) && (r.length > 1 && (a = r[1]), r = r[0]);
2869
- const l = rt.deserialize(r), h = Qt(this.wnd.document, new H({
2869
+ const l = rt.deserialize(r), c = Qt(this.wnd.document, new H({
2870
2870
  href: t.location.href,
2871
2871
  type: "text/html",
2872
2872
  text: l,
@@ -2876,12 +2876,12 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2876
2876
  ])
2877
2877
  }) : void 0
2878
2878
  }));
2879
- if (!h) {
2879
+ if (!c) {
2880
2880
  o(!1);
2881
2881
  return;
2882
2882
  }
2883
2883
  this.wnd.requestAnimationFrame(() => {
2884
- this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), o(!0);
2884
+ this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + t.scrollX), this.reportProgress(), A(this.wnd), o(!0);
2885
2885
  });
2886
2886
  }), e.register("go_end", U.moduleName, (r, o) => {
2887
2887
  const a = nt(t) ? -1 : 1;
@@ -2899,14 +2899,14 @@ const hi = "readium-column-snapper-style", Gn = 200, U = class U extends Et {
2899
2899
  }), e.register("go_prev", U.moduleName, (r, o) => {
2900
2900
  this.wnd.requestAnimationFrame(() => {
2901
2901
  this.cachedScrollWidth = this.doc().scrollWidth;
2902
- const a = t.scrollX - t.innerWidth, l = nt(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, h = n(Math.max(a, l));
2903
- h && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(h);
2902
+ const a = t.scrollX - t.innerWidth, l = nt(t) ? -(this.cachedScrollWidth - t.innerWidth) : 0, c = n(Math.max(a, l));
2903
+ c && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("left", this.wnd.innerWidth)), o(c);
2904
2904
  });
2905
2905
  }), e.register("go_next", U.moduleName, (r, o) => {
2906
2906
  this.wnd.requestAnimationFrame(() => {
2907
2907
  this.cachedScrollWidth = this.doc().scrollWidth;
2908
- const a = t.scrollX + t.innerWidth, l = nt(t) ? 0 : this.cachedScrollWidth - t.innerWidth, h = n(Math.min(a, l));
2909
- h && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(h);
2908
+ const a = t.scrollX + t.innerWidth, l = nt(t) ? 0 : this.cachedScrollWidth - t.innerWidth, c = n(Math.min(a, l));
2909
+ c && (this.reportProgress(), A(this.wnd), this.checkSuspiciousSnap("right", this.wnd.innerWidth)), o(c);
2910
2910
  });
2911
2911
  }), e.register("unfocus", U.moduleName, (r, o) => {
2912
2912
  this.snappingCancelled = !0, A(this.wnd), o(!0);
@@ -3210,10 +3210,10 @@ class jn {
3210
3210
  length: n,
3211
3211
  wasBlocked: !1
3212
3212
  }), !0;
3213
- const l = o - this.lastSelectionTime < 100 && n > this.lastSelectionLength * 1.5, h = Math.min(
3213
+ const l = o - this.lastSelectionTime < 100 && n > this.lastSelectionLength * 1.5, c = Math.min(
3214
3214
  r * this.options.maxSelectionPercent,
3215
3215
  this.options.absoluteMaxChars
3216
- ), c = this.isSuspiciousPattern(o), u = n > h || l || c;
3216
+ ), h = this.isSuspiciousPattern(o), u = n > c || l || h;
3217
3217
  return this.copyHistory.push({
3218
3218
  timestamp: o,
3219
3219
  length: n,
@@ -3292,13 +3292,13 @@ class Gi {
3292
3292
  createActivityEvent(t, e, i, n) {
3293
3293
  let r;
3294
3294
  if (n) {
3295
- const o = n.getSelection(), a = o?.toString() || "", h = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
3296
- h && a && (r = {
3295
+ const o = n.getSelection(), a = o?.toString() || "", c = (a && o?.rangeCount ? o.getRangeAt(0)?.getClientRects() : null)?.[0];
3296
+ c && a && (r = {
3297
3297
  text: a,
3298
- x: h.x,
3299
- y: h.y,
3300
- width: h.width,
3301
- height: h.height
3298
+ x: c.x,
3299
+ y: c.y,
3300
+ width: c.width,
3301
+ height: c.height
3302
3302
  });
3303
3303
  }
3304
3304
  return {
@@ -3324,8 +3324,8 @@ class Gi {
3324
3324
  r.push(...o.keyCombos.map((a) => ({
3325
3325
  ...a,
3326
3326
  handler: (l) => {
3327
- const h = o.type, c = this.createActivityEvent(l, h, t, n);
3328
- i(c);
3327
+ const c = o.type, h = this.createActivityEvent(l, c, t, n);
3328
+ i(h);
3329
3329
  }
3330
3330
  })));
3331
3331
  }), r;
@@ -3618,7 +3618,7 @@ const _t = class _t extends ft {
3618
3618
  ), Reflect.defineProperty(t.navigator, "epubReadingSystem", {
3619
3619
  value: {
3620
3620
  name: "readium-ts-toolkit",
3621
- version: "2.3.0",
3621
+ version: "2.3.1",
3622
3622
  hasFeature: (n, r = "") => {
3623
3623
  switch (n) {
3624
3624
  case "dom-manipulation":
@@ -3963,7 +3963,7 @@ class er {
3963
3963
  const o = r.keyCombos.filter(
3964
3964
  (a) => !i.some(
3965
3965
  (l) => l.keyCombos.some(
3966
- (h) => a.keyCode === h.keyCode && a.ctrl === h.ctrl && a.shift === h.shift && a.alt === h.alt && a.meta === h.meta
3966
+ (c) => a.keyCode === c.keyCode && a.ctrl === c.ctrl && a.shift === c.shift && a.alt === c.alt && a.meta === c.meta
3967
3967
  )
3968
3968
  )
3969
3969
  );
@@ -4215,12 +4215,12 @@ class Yi {
4215
4215
  else if (/^((Google )?Chrome OS|CrOS)$/.test(a)) o.ChromeOS = i(l);
4216
4216
  else if (/^(Linux|Ubuntu|X11)$/.test(a)) o.Linux = i(l);
4217
4217
  else return;
4218
- Object.keys(this.OS).forEach((h) => delete this.OS[h]), Object.assign(this.OS, o);
4218
+ Object.keys(this.OS).forEach((c) => delete this.OS[c]), Object.assign(this.OS, o);
4219
4219
  }
4220
4220
  })({})), this.UA = ((r) => {
4221
4221
  let o = !1;
4222
4222
  if (t && Array.isArray(t.brands)) {
4223
- const a = t.brands.reduce((l, h) => (l[h.brand] = [h.version * 1], l), {});
4223
+ const a = t.brands.reduce((l, c) => (l[c.brand] = [c.version * 1], l), {});
4224
4224
  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);
4225
4225
  }
4226
4226
  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;
@@ -4356,11 +4356,11 @@ class hr {
4356
4356
  if (r < 0) throw Error(`Locator not found in reading order: ${e.href}`);
4357
4357
  const o = n[r].href;
4358
4358
  this.inprogress.has(o) && await this.inprogress.get(o);
4359
- const a = new Promise(async (l, h) => {
4360
- const c = [], u = [];
4359
+ const a = new Promise(async (l, c) => {
4360
+ const h = [], u = [];
4361
4361
  t.readingOrder.items.forEach((d, p) => {
4362
- 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));
4363
- }), c.forEach(async (d) => {
4362
+ 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));
4363
+ }), h.forEach(async (d) => {
4364
4364
  u.includes(d) || this.pool.has(d) && (await this.pool.get(d)?.destroy(), this.pool.delete(d));
4365
4365
  }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((d) => {
4366
4366
  this.injector?.releaseBlobUrl?.(d), URL.revokeObjectURL(d);
@@ -4399,7 +4399,7 @@ class hr {
4399
4399
  try {
4400
4400
  await Promise.all(u.map((d) => m(d)));
4401
4401
  } catch (d) {
4402
- h(d);
4402
+ c(d);
4403
4403
  }
4404
4404
  const y = this.pool.get(o);
4405
4405
  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();
@@ -4456,33 +4456,33 @@ function cr() {
4456
4456
  throw new TypeError("Path must be a string. Received " + JSON.stringify(n));
4457
4457
  }
4458
4458
  function t(n, r) {
4459
- for (var o = "", a = 0, l = -1, h = 0, c, u = 0; u <= n.length; ++u) {
4459
+ for (var o = "", a = 0, l = -1, c = 0, h, u = 0; u <= n.length; ++u) {
4460
4460
  if (u < n.length)
4461
- c = n.charCodeAt(u);
4461
+ h = n.charCodeAt(u);
4462
4462
  else {
4463
- if (c === 47)
4463
+ if (h === 47)
4464
4464
  break;
4465
- c = 47;
4465
+ h = 47;
4466
4466
  }
4467
- if (c === 47) {
4468
- if (!(l === u - 1 || h === 1)) if (l !== u - 1 && h === 2) {
4467
+ if (h === 47) {
4468
+ if (!(l === u - 1 || c === 1)) if (l !== u - 1 && c === 2) {
4469
4469
  if (o.length < 2 || a !== 2 || o.charCodeAt(o.length - 1) !== 46 || o.charCodeAt(o.length - 2) !== 46) {
4470
4470
  if (o.length > 2) {
4471
4471
  var m = o.lastIndexOf("/");
4472
4472
  if (m !== o.length - 1) {
4473
- m === -1 ? (o = "", a = 0) : (o = o.slice(0, m), a = o.length - 1 - o.lastIndexOf("/")), l = u, h = 0;
4473
+ m === -1 ? (o = "", a = 0) : (o = o.slice(0, m), a = o.length - 1 - o.lastIndexOf("/")), l = u, c = 0;
4474
4474
  continue;
4475
4475
  }
4476
4476
  } else if (o.length === 2 || o.length === 1) {
4477
- o = "", a = 0, l = u, h = 0;
4477
+ o = "", a = 0, l = u, c = 0;
4478
4478
  continue;
4479
4479
  }
4480
4480
  }
4481
4481
  r && (o.length > 0 ? o += "/.." : o = "..", a = 2);
4482
4482
  } else
4483
4483
  o.length > 0 ? o += "/" + n.slice(l + 1, u) : o = n.slice(l + 1, u), a = u - l - 1;
4484
- l = u, h = 0;
4485
- } else c === 46 && h !== -1 ? ++h : h = -1;
4484
+ l = u, c = 0;
4485
+ } else h === 46 && c !== -1 ? ++c : c = -1;
4486
4486
  }
4487
4487
  return o;
4488
4488
  }
@@ -4494,8 +4494,8 @@ function cr() {
4494
4494
  // path.resolve([from ...], to)
4495
4495
  resolve: function() {
4496
4496
  for (var r = "", o = !1, a, l = arguments.length - 1; l >= -1 && !o; l--) {
4497
- var h;
4498
- 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);
4497
+ var c;
4498
+ 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);
4499
4499
  }
4500
4500
  return r = t(r, !o), o ? r.length > 0 ? "/" + r : "/" : r.length > 0 ? r : ".";
4501
4501
  },
@@ -4520,19 +4520,19 @@ function cr() {
4520
4520
  if (s(r), s(o), r === o || (r = i.resolve(r), o = i.resolve(o), r === o)) return "";
4521
4521
  for (var a = 1; a < r.length && r.charCodeAt(a) === 47; ++a)
4522
4522
  ;
4523
- for (var l = r.length, h = l - a, c = 1; c < o.length && o.charCodeAt(c) === 47; ++c)
4523
+ for (var l = r.length, c = l - a, h = 1; h < o.length && o.charCodeAt(h) === 47; ++h)
4524
4524
  ;
4525
- for (var u = o.length, m = u - c, y = h < m ? h : m, d = -1, p = 0; p <= y; ++p) {
4525
+ for (var u = o.length, m = u - h, y = c < m ? c : m, d = -1, p = 0; p <= y; ++p) {
4526
4526
  if (p === y) {
4527
4527
  if (m > y) {
4528
- if (o.charCodeAt(c + p) === 47)
4529
- return o.slice(c + p + 1);
4528
+ if (o.charCodeAt(h + p) === 47)
4529
+ return o.slice(h + p + 1);
4530
4530
  if (p === 0)
4531
- return o.slice(c + p);
4532
- } else h > y && (r.charCodeAt(a + p) === 47 ? d = p : p === 0 && (d = 0));
4531
+ return o.slice(h + p);
4532
+ } else c > y && (r.charCodeAt(a + p) === 47 ? d = p : p === 0 && (d = 0));
4533
4533
  break;
4534
4534
  }
4535
- var b = r.charCodeAt(a + p), v = o.charCodeAt(c + p);
4535
+ var b = r.charCodeAt(a + p), v = o.charCodeAt(h + p);
4536
4536
  if (b !== v)
4537
4537
  break;
4538
4538
  b === 47 && (d = p);
@@ -4540,68 +4540,68 @@ function cr() {
4540
4540
  var L = "";
4541
4541
  for (p = a + d + 1; p <= l; ++p)
4542
4542
  (p === l || r.charCodeAt(p) === 47) && (L.length === 0 ? L += ".." : L += "/..");
4543
- return L.length > 0 ? L + o.slice(c + d) : (c += d, o.charCodeAt(c) === 47 && ++c, o.slice(c));
4543
+ return L.length > 0 ? L + o.slice(h + d) : (h += d, o.charCodeAt(h) === 47 && ++h, o.slice(h));
4544
4544
  },
4545
4545
  _makeLong: function(r) {
4546
4546
  return r;
4547
4547
  },
4548
4548
  dirname: function(r) {
4549
4549
  if (s(r), r.length === 0) return ".";
4550
- for (var o = r.charCodeAt(0), a = o === 47, l = -1, h = !0, c = r.length - 1; c >= 1; --c)
4551
- if (o = r.charCodeAt(c), o === 47) {
4552
- if (!h) {
4553
- l = c;
4550
+ for (var o = r.charCodeAt(0), a = o === 47, l = -1, c = !0, h = r.length - 1; h >= 1; --h)
4551
+ if (o = r.charCodeAt(h), o === 47) {
4552
+ if (!c) {
4553
+ l = h;
4554
4554
  break;
4555
4555
  }
4556
4556
  } else
4557
- h = !1;
4557
+ c = !1;
4558
4558
  return l === -1 ? a ? "/" : "." : a && l === 1 ? "//" : r.slice(0, l);
4559
4559
  },
4560
4560
  basename: function(r, o) {
4561
4561
  if (o !== void 0 && typeof o != "string") throw new TypeError('"ext" argument must be a string');
4562
4562
  s(r);
4563
- var a = 0, l = -1, h = !0, c;
4563
+ var a = 0, l = -1, c = !0, h;
4564
4564
  if (o !== void 0 && o.length > 0 && o.length <= r.length) {
4565
4565
  if (o.length === r.length && o === r) return "";
4566
4566
  var u = o.length - 1, m = -1;
4567
- for (c = r.length - 1; c >= 0; --c) {
4568
- var y = r.charCodeAt(c);
4567
+ for (h = r.length - 1; h >= 0; --h) {
4568
+ var y = r.charCodeAt(h);
4569
4569
  if (y === 47) {
4570
- if (!h) {
4571
- a = c + 1;
4570
+ if (!c) {
4571
+ a = h + 1;
4572
4572
  break;
4573
4573
  }
4574
4574
  } else
4575
- m === -1 && (h = !1, m = c + 1), u >= 0 && (y === o.charCodeAt(u) ? --u === -1 && (l = c) : (u = -1, l = m));
4575
+ m === -1 && (c = !1, m = h + 1), u >= 0 && (y === o.charCodeAt(u) ? --u === -1 && (l = h) : (u = -1, l = m));
4576
4576
  }
4577
4577
  return a === l ? l = m : l === -1 && (l = r.length), r.slice(a, l);
4578
4578
  } else {
4579
- for (c = r.length - 1; c >= 0; --c)
4580
- if (r.charCodeAt(c) === 47) {
4581
- if (!h) {
4582
- a = c + 1;
4579
+ for (h = r.length - 1; h >= 0; --h)
4580
+ if (r.charCodeAt(h) === 47) {
4581
+ if (!c) {
4582
+ a = h + 1;
4583
4583
  break;
4584
4584
  }
4585
- } else l === -1 && (h = !1, l = c + 1);
4585
+ } else l === -1 && (c = !1, l = h + 1);
4586
4586
  return l === -1 ? "" : r.slice(a, l);
4587
4587
  }
4588
4588
  },
4589
4589
  extname: function(r) {
4590
4590
  s(r);
4591
- for (var o = -1, a = 0, l = -1, h = !0, c = 0, u = r.length - 1; u >= 0; --u) {
4591
+ for (var o = -1, a = 0, l = -1, c = !0, h = 0, u = r.length - 1; u >= 0; --u) {
4592
4592
  var m = r.charCodeAt(u);
4593
4593
  if (m === 47) {
4594
- if (!h) {
4594
+ if (!c) {
4595
4595
  a = u + 1;
4596
4596
  break;
4597
4597
  }
4598
4598
  continue;
4599
4599
  }
4600
- l === -1 && (h = !1, l = u + 1), m === 46 ? o === -1 ? o = u : c !== 1 && (c = 1) : o !== -1 && (c = -1);
4600
+ l === -1 && (c = !1, l = u + 1), m === 46 ? o === -1 ? o = u : h !== 1 && (h = 1) : o !== -1 && (h = -1);
4601
4601
  }
4602
4602
  return o === -1 || l === -1 || // We saw a non-dot character immediately before the dot
4603
- c === 0 || // The (right-most) trimmed path component is exactly '..'
4604
- c === 1 && o === l - 1 && o === a + 1 ? "" : r.slice(o, l);
4603
+ h === 0 || // The (right-most) trimmed path component is exactly '..'
4604
+ h === 1 && o === l - 1 && o === a + 1 ? "" : r.slice(o, l);
4605
4605
  },
4606
4606
  format: function(r) {
4607
4607
  if (r === null || typeof r != "object")
@@ -4612,9 +4612,9 @@ function cr() {
4612
4612
  s(r);
4613
4613
  var o = { root: "", dir: "", base: "", ext: "", name: "" };
4614
4614
  if (r.length === 0) return o;
4615
- var a = r.charCodeAt(0), l = a === 47, h;
4616
- l ? (o.root = "/", h = 1) : h = 0;
4617
- for (var c = -1, u = 0, m = -1, y = !0, d = r.length - 1, p = 0; d >= h; --d) {
4615
+ var a = r.charCodeAt(0), l = a === 47, c;
4616
+ l ? (o.root = "/", c = 1) : c = 0;
4617
+ for (var h = -1, u = 0, m = -1, y = !0, d = r.length - 1, p = 0; d >= c; --d) {
4618
4618
  if (a = r.charCodeAt(d), a === 47) {
4619
4619
  if (!y) {
4620
4620
  u = d + 1;
@@ -4622,11 +4622,11 @@ function cr() {
4622
4622
  }
4623
4623
  continue;
4624
4624
  }
4625
- m === -1 && (y = !1, m = d + 1), a === 46 ? c === -1 ? c = d : p !== 1 && (p = 1) : c !== -1 && (p = -1);
4625
+ m === -1 && (y = !1, m = d + 1), a === 46 ? h === -1 ? h = d : p !== 1 && (p = 1) : h !== -1 && (p = -1);
4626
4626
  }
4627
- return c === -1 || m === -1 || // We saw a non-dot character immediately before the dot
4627
+ return h === -1 || m === -1 || // We saw a non-dot character immediately before the dot
4628
4628
  p === 0 || // The (right-most) trimmed path component is exactly '..'
4629
- 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;
4629
+ 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;
4630
4630
  },
4631
4631
  sep: "/",
4632
4632
  delimiter: ":",
@@ -5257,8 +5257,8 @@ class tn {
5257
5257
  for (const { element: a, url: l } of i)
5258
5258
  try {
5259
5259
  a.remove(), await this.releaseBlobUrl(l);
5260
- } catch (h) {
5261
- console.error("Error during cleanup:", h);
5260
+ } catch (c) {
5261
+ console.error("Error during cleanup:", c);
5262
5262
  }
5263
5263
  throw o;
5264
5264
  }
@@ -5868,7 +5868,7 @@ class kr {
5868
5868
  * Stop detection and cleanup resources
5869
5869
  */
5870
5870
  destroy() {
5871
- this.intervalId && (clearInterval(this.intervalId), this.intervalId = void 0), this.workerConsole && this.workerConsole.destroy(), this.isOpen = !1, this.checkCount = 0;
5871
+ this.intervalId && (clearInterval(this.intervalId), this.intervalId = void 0), this.workerConsole && (this.workerConsole.destroy(), this.workerConsole = void 0), this.isOpen = !1, this.checkCount = 0;
5872
5872
  }
5873
5873
  }
5874
5874
  class Tr {
@@ -6067,13 +6067,13 @@ class Ur extends ji {
6067
6067
  this._contentProtection,
6068
6068
  r.keyboardPeripherals || []
6069
6069
  ), (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) => {
6070
- const h = l;
6071
- this.listeners.contentProtection(h.detail.type, h.detail);
6070
+ const { type: c, ...h } = l.detail;
6071
+ c === "context_menu" ? this.listeners.contextMenu(h) : this.listeners.contentProtection(c, h);
6072
6072
  }, window.addEventListener(Rt, this._suspiciousActivityListener)), this._keyboardPeripherals.length > 0 && (this._keyboardPeripheralsManager = new sn({
6073
6073
  keyboardPeripherals: this._keyboardPeripherals
6074
6074
  }), this._keyboardPeripheralListener = (l) => {
6075
- const h = l.detail;
6076
- this.listeners.peripheral(h);
6075
+ const c = l.detail;
6076
+ this.listeners.peripheral(c);
6077
6077
  }, window.addEventListener(Lt, this._keyboardPeripheralListener)), n && typeof n.copyWithLocations == "function") {
6078
6078
  this.currentLocation = n;
6079
6079
  const l = this.pub.readingOrder.findIndexWithHref(n.href);
@@ -6176,12 +6176,12 @@ class Ur extends ji {
6176
6176
  if (a.startsWith("http://") || a.startsWith("https://"))
6177
6177
  l = a;
6178
6178
  else if (this.currentLocation.href.startsWith("http://") || this.currentLocation.href.startsWith("https://")) {
6179
- const c = new URL(this.currentLocation.href);
6180
- l = new URL(a, c).href;
6179
+ const h = new URL(this.currentLocation.href);
6180
+ l = new URL(a, h).href;
6181
6181
  } else
6182
6182
  l = Vt.join(Vt.dirname(this.currentLocation.href), a);
6183
- const h = this.pub.readingOrder.findWithHref(l);
6184
- h ? this.goLink(h, !1, () => {
6183
+ const c = this.pub.readingOrder.findWithHref(l);
6184
+ c ? this.goLink(c, !1, () => {
6185
6185
  }) : (console.warn(`Internal link not found in readingOrder: ${l}`), this.listeners.handleLocator(new V({
6186
6186
  href: a
6187
6187
  }).locator));
@@ -6292,7 +6292,7 @@ class Ur extends ji {
6292
6292
  }
6293
6293
  async loadLocator(t, e) {
6294
6294
  let i = !1, n = typeof t.locations.getCssSelector == "function" && t.locations.getCssSelector();
6295
- if (t.text?.highlight ? i = await new Promise((l, h) => {
6295
+ if (t.text?.highlight ? i = await new Promise((l, c) => {
6296
6296
  this.framePool.currentFrames[0].msg.send(
6297
6297
  "go_text",
6298
6298
  n ? [
@@ -6300,9 +6300,9 @@ class Ur extends ji {
6300
6300
  n
6301
6301
  // Include CSS selector if it exists
6302
6302
  ] : t.text?.serialize(),
6303
- (c) => l(c)
6303
+ (h) => l(h)
6304
6304
  );
6305
- }) : n && (i = await new Promise((l, h) => {
6305
+ }) : n && (i = await new Promise((l, c) => {
6306
6306
  this.framePool.currentFrames[0].msg.send(
6307
6307
  "go_text",
6308
6308
  [
@@ -6311,22 +6311,22 @@ class Ur extends ji {
6311
6311
  n
6312
6312
  // Just CSS selector
6313
6313
  ],
6314
- (c) => l(c)
6314
+ (h) => l(h)
6315
6315
  );
6316
6316
  })), i) {
6317
6317
  e(i);
6318
6318
  return;
6319
6319
  }
6320
6320
  const r = typeof t.locations.htmlId == "function" && t.locations.htmlId();
6321
- if (r && (i = await new Promise((l, h) => {
6322
- this.framePool.currentFrames[0].msg.send("go_id", r, (c) => l(c));
6321
+ if (r && (i = await new Promise((l, c) => {
6322
+ this.framePool.currentFrames[0].msg.send("go_id", r, (h) => l(h));
6323
6323
  })), i) {
6324
6324
  e(i);
6325
6325
  return;
6326
6326
  }
6327
6327
  const o = t?.locations?.progression;
6328
- o && o > 0 ? i = await new Promise((l, h) => {
6329
- this.framePool.currentFrames[0].msg.send("go_progression", o, (c) => l(c));
6328
+ o && o > 0 ? i = await new Promise((l, c) => {
6329
+ this.framePool.currentFrames[0].msg.send("go_progression", o, (h) => l(h));
6330
6330
  }) : i = !0, e(i);
6331
6331
  }
6332
6332
  go(t, e, i) {
@@ -6424,21 +6424,21 @@ class on {
6424
6424
  ...e ? [e] : [],
6425
6425
  ...a
6426
6426
  ])].filter(Boolean);
6427
- if (o && !r && this.setProperties(o, t), t.body.querySelectorAll("img").forEach((c) => {
6428
- c.setAttribute("fetchpriority", "high");
6427
+ if (o && !r && this.setProperties(o, t), t.body.querySelectorAll("img").forEach((h) => {
6428
+ h.setAttribute("fetchpriority", "high");
6429
6429
  }), n.isHTML && this.pub.metadata.languages?.[0]) {
6430
- const c = this.pub.metadata.languages[0];
6430
+ const h = this.pub.metadata.languages[0];
6431
6431
  if (n === g.XHTML) {
6432
6432
  const u = document.documentElement.lang || document.documentElement.getAttribute("xml:lang"), m = document.body.lang || document.body.getAttribute("xml:lang");
6433
- 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));
6434
- } else n === g.HTML && !document.documentElement.lang && (document.documentElement.lang = c);
6433
+ 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));
6434
+ } else n === g.HTML && !document.documentElement.lang && (document.documentElement.lang = h);
6435
6435
  }
6436
6436
  if (i !== void 0) {
6437
- const c = t.createElement("base");
6438
- c.href = i, c.dataset.readium = "true", t.head.firstChild.before(c);
6437
+ const h = t.createElement("base");
6438
+ h.href = i, h.dataset.readium = "true", t.head.firstChild.before(h);
6439
6439
  }
6440
- const h = t.createElement("meta");
6441
- return h.httpEquiv = "Content-Security-Policy", h.content = Nr(l), h.dataset.readium = "true", t.head.firstChild.before(h), URL.createObjectURL(
6440
+ const c = t.createElement("meta");
6441
+ return c.httpEquiv = "Content-Security-Policy", c.content = Nr(l), c.dataset.readium = "true", t.head.firstChild.before(c), URL.createObjectURL(
6442
6442
  new Blob([new XMLSerializer().serializeToString(t)], {
6443
6443
  type: n.isHTML ? n.string : "application/xhtml+xml"
6444
6444
  // Fallback to XHTML
@@ -6565,14 +6565,14 @@ class Dr {
6565
6565
  }
6566
6566
  async update(t, e, i, n = !1) {
6567
6567
  let r = this.positions.findIndex((l) => l.locations.position === e.locations.position);
6568
- 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)}`);
6568
+ 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)}`);
6569
6569
  const o = this.positions[r].href;
6570
6570
  this.inprogress.has(o) && await this.inprogress.get(o);
6571
- const a = new Promise(async (l, h) => {
6572
- const c = [], u = [];
6571
+ const a = new Promise(async (l, c) => {
6572
+ const h = [], u = [];
6573
6573
  this.positions.forEach((d, p) => {
6574
- (p > r + vi || p < r - vi) && (c.includes(d.href) || c.push(d.href)), p < r + wi && p > r - wi && (u.includes(d.href) || u.push(d.href));
6575
- }), c.forEach(async (d) => {
6574
+ (p > r + vi || p < r - vi) && (h.includes(d.href) || h.push(d.href)), p < r + wi && p > r - wi && (u.includes(d.href) || u.push(d.href));
6575
+ }), h.forEach(async (d) => {
6576
6576
  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 }));
6577
6577
  }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((d) => {
6578
6578
  this.injector?.releaseBlobUrl?.(d), URL.revokeObjectURL(d);
@@ -6613,7 +6613,7 @@ class Dr {
6613
6613
  try {
6614
6614
  await Promise.all(u.map((d) => m(d)));
6615
6615
  } catch (d) {
6616
- h(d);
6616
+ c(d);
6617
6617
  }
6618
6618
  const y = this.pool.get(o);
6619
6619
  (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();
@@ -6864,15 +6864,15 @@ class Br {
6864
6864
  };
6865
6865
  let r, o, a, l;
6866
6866
  a = r = i, l = o = 1 - i;
6867
- const h = {
6867
+ const c = {
6868
6868
  X: null,
6869
6869
  Y: null
6870
6870
  };
6871
- 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, {
6871
+ 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, {
6872
6872
  Target: t.target,
6873
6873
  Coord: e,
6874
6874
  Ratio: n,
6875
- Division: h
6875
+ Division: c
6876
6876
  };
6877
6877
  }
6878
6878
  }
@@ -7050,10 +7050,10 @@ class Gr {
7050
7050
  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)}`;
7051
7051
  }
7052
7052
  l.X -= this.manager.width / 2, l.Y -= this.manager.height / 2;
7053
- let h = -l.X / r;
7054
- h += l.X / this.scale, this.pinch.target.X += h, l.X += this.pinch.target.X * this.scale / this.pinch.startScale;
7055
- let c = -l.Y / r;
7056
- c += l.Y / this.scale, this.pinch.target.Y += c, l.Y += this.pinch.target.Y * this.scale / this.pinch.startScale;
7053
+ let c = -l.X / r;
7054
+ c += l.X / this.scale, this.pinch.target.X += c, l.X += this.pinch.target.X * this.scale / this.pinch.startScale;
7055
+ let h = -l.Y / r;
7056
+ h += l.Y / this.scale, this.pinch.target.Y += h, l.Y += this.pinch.target.Y * this.scale / this.pinch.startScale;
7057
7057
  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;
7058
7058
  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)}`);
7059
7059
  }
@@ -7069,10 +7069,10 @@ Overscroll: ${this.pan.overscrollX.toFixed(2)},${this.pan.overscrollY.toFixed(2)
7069
7069
  }
7070
7070
  if (this.dragState > 0 && this.pan.letItGo) {
7071
7071
  this.pan.endX = e.X;
7072
- 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;
7072
+ 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;
7073
7073
  cancelAnimationFrame(this.moveFrame), this.moveFrame = requestAnimationFrame(() => {
7074
7074
  requestAnimationFrame(() => {
7075
- this.manager.spineElement.style.transform = `translate3d(${(this.manager.rtl ? 1 : -1) * h}px, 0, 0)`;
7075
+ this.manager.spineElement.style.transform = `translate3d(${(this.manager.rtl ? 1 : -1) * c}px, 0, 0)`;
7076
7076
  });
7077
7077
  });
7078
7078
  }
@@ -7376,11 +7376,11 @@ class Zr {
7376
7376
  this.perPage > 1 && r++;
7377
7377
  for (const l of o)
7378
7378
  await this.waitForItem(l.href);
7379
- const a = new Promise(async (l, h) => {
7380
- const c = [], u = [];
7379
+ const a = new Promise(async (l, c) => {
7380
+ const h = [], u = [];
7381
7381
  this.positions.forEach((d, p) => {
7382
- (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));
7383
- }), c.forEach(async (d) => {
7382
+ (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));
7383
+ }), h.forEach(async (d) => {
7384
7384
  u.includes(d) || this.pool.has(d) && (this.cancelShowing(d), await this.pool.get(d)?.unload());
7385
7385
  }), this.currentBaseURL !== void 0 && t.baseURL !== this.currentBaseURL && (this.blobs.forEach((d) => URL.revokeObjectURL(d)), this.blobs.clear()), this.currentBaseURL = t.baseURL;
7386
7386
  const m = async (d) => {
@@ -7413,7 +7413,7 @@ class Zr {
7413
7413
  try {
7414
7414
  await Promise.all(u.map((d) => m(d)));
7415
7415
  } catch (d) {
7416
- h(d);
7416
+ c(d);
7417
7417
  }
7418
7418
  const y = [];
7419
7419
  for (const d of o) {
@@ -8061,7 +8061,7 @@ class os {
8061
8061
  // TODO: As scroll shows, the effective line-length
8062
8062
  // should be the same as uncompensated when scale >= 1
8063
8063
  paginate(t, e, i) {
8064
- 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;
8064
+ 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;
8065
8065
  let u = 1, m = n;
8066
8066
  if (i === void 0)
8067
8067
  return {
@@ -8070,24 +8070,24 @@ class os {
8070
8070
  effectiveLineLength: Math.round(m / u * o)
8071
8071
  };
8072
8072
  if (i === null)
8073
- if (n >= a && h !== null) {
8073
+ if (n >= a && c !== null) {
8074
8074
  u = Math.floor(n / a);
8075
- const y = Math.round(u * (h * o));
8075
+ const y = Math.round(u * (c * o));
8076
8076
  m = Math.min(y, n);
8077
8077
  } else
8078
- m = c();
8078
+ m = h();
8079
8079
  else if (i > 1) {
8080
8080
  const y = Math.round(i * (l !== null ? l : a));
8081
8081
  if (n >= y)
8082
- if (u = i, h === null)
8082
+ if (u = i, c === null)
8083
8083
  m = n;
8084
8084
  else {
8085
- const d = Math.round(u * (h * o));
8085
+ const d = Math.round(u * (c * o));
8086
8086
  m = Math.min(d, n);
8087
8087
  }
8088
8088
  else if (l !== null && n < Math.round(i * l))
8089
8089
  if (u = Math.floor(n / l), u <= 1)
8090
- u = 1, m = c();
8090
+ u = 1, m = h();
8091
8091
  else {
8092
8092
  const d = Math.round(u * (a * o));
8093
8093
  m = Math.min(d, n);
@@ -8098,7 +8098,7 @@ class os {
8098
8098
  m = Math.min(d, n);
8099
8099
  }
8100
8100
  } else
8101
- u = 1, m = c();
8101
+ u = 1, m = h();
8102
8102
  return {
8103
8103
  colCount: u,
8104
8104
  effectiveContainerWidth: m,
@@ -8108,17 +8108,17 @@ class os {
8108
8108
  // This behaves as paginate where colCount = 1
8109
8109
  computeScrollLength(t, e) {
8110
8110
  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;
8111
- let l, h = i, c = Math.round(o * r);
8111
+ let l, c = i, h = Math.round(o * r);
8112
8112
  if (a === null)
8113
- c = i;
8113
+ h = i;
8114
8114
  else {
8115
8115
  const u = Math.min(Math.round(a * r), i);
8116
- c = e ? u : Math.round(u * r);
8116
+ h = e ? u : Math.round(u * r);
8117
8117
  }
8118
8118
  return {
8119
8119
  colCount: l,
8120
- effectiveContainerWidth: h,
8121
- effectiveLineLength: c
8120
+ effectiveContainerWidth: c,
8121
+ effectiveLineLength: h
8122
8122
  };
8123
8123
  }
8124
8124
  setContainerWidth() {
@@ -9476,14 +9476,14 @@ class ln extends ji {
9476
9476
  }), this._contentProtection = o.contentProtection || {}, this._keyboardPeripherals = this.mergeKeyboardPeripherals(
9477
9477
  this._contentProtection,
9478
9478
  o.keyboardPeripherals || []
9479
- ), (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) => {
9480
- const { type: c, ...u } = h.detail;
9481
- c === "context_menu" ? this.listeners.contextMenu(u) : this.listeners.contentProtection(c, u);
9479
+ ), (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) => {
9480
+ const { type: h, ...u } = c.detail;
9481
+ h === "context_menu" ? this.listeners.contextMenu(u) : this.listeners.contentProtection(h, u);
9482
9482
  }, window.addEventListener(Rt, this._suspiciousActivityListener)), this._keyboardPeripherals.length > 0 && (this._keyboardPeripheralsManager = new sn({
9483
9483
  keyboardPeripherals: this._keyboardPeripherals
9484
- }), this._keyboardPeripheralListener = (h) => {
9485
- const c = h.detail;
9486
- this.listeners.peripheral(c);
9484
+ }), this._keyboardPeripheralListener = (c) => {
9485
+ const h = c.detail;
9486
+ this.listeners.peripheral(h);
9487
9487
  }, window.addEventListener(Lt, this._keyboardPeripheralListener)), this.resizeObserver = new ResizeObserver(() => this.ownerWindow.requestAnimationFrame(async () => await this.resizeHandler())), this.resizeObserver.observe(this.container.parentElement || document.documentElement);
9488
9488
  }
9489
9489
  static determineLayout(t, e) {
@@ -9833,7 +9833,7 @@ class ln extends ji {
9833
9833
  }
9834
9834
  async loadLocator(t, e) {
9835
9835
  let i = !1, n = typeof t.locations.getCssSelector == "function" && t.locations.getCssSelector();
9836
- if (t.text?.highlight ? i = await new Promise((l, h) => {
9836
+ if (t.text?.highlight ? i = await new Promise((l, c) => {
9837
9837
  this._cframes[0].msg.send(
9838
9838
  "go_text",
9839
9839
  n ? [
@@ -9841,9 +9841,9 @@ class ln extends ji {
9841
9841
  n
9842
9842
  // Include CSS selector if it exists
9843
9843
  ] : t.text?.serialize(),
9844
- (c) => l(c)
9844
+ (h) => l(h)
9845
9845
  );
9846
- }) : n && (i = await new Promise((l, h) => {
9846
+ }) : n && (i = await new Promise((l, c) => {
9847
9847
  this._cframes[0].msg.send(
9848
9848
  "go_text",
9849
9849
  [
@@ -9852,22 +9852,22 @@ class ln extends ji {
9852
9852
  n
9853
9853
  // Just CSS selector
9854
9854
  ],
9855
- (c) => l(c)
9855
+ (h) => l(h)
9856
9856
  );
9857
9857
  })), i) {
9858
9858
  e(i);
9859
9859
  return;
9860
9860
  }
9861
9861
  const r = typeof t.locations.htmlId == "function" && t.locations.htmlId();
9862
- if (r && (i = await new Promise((l, h) => {
9863
- this._cframes[0].msg.send("go_id", r, (c) => l(c));
9862
+ if (r && (i = await new Promise((l, c) => {
9863
+ this._cframes[0].msg.send("go_id", r, (h) => l(h));
9864
9864
  })), i) {
9865
9865
  e(i);
9866
9866
  return;
9867
9867
  }
9868
9868
  const o = t?.locations?.progression;
9869
- o && o > 0 ? i = await new Promise((l, h) => {
9870
- this._cframes[0].msg.send("go_progression", o, (c) => l(c));
9869
+ o && o > 0 ? i = await new Promise((l, c) => {
9870
+ this._cframes[0].msg.send("go_progression", o, (h) => l(h));
9871
9871
  }) : i = !0, e(i);
9872
9872
  }
9873
9873
  go(t, e, i) {