@readium/navigator-html-injectables 2.0.0-beta.1 → 2.0.0-beta.2

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
@@ -172,22 +172,22 @@ class l {
172
172
  } else
173
173
  throw new Error("Invalid media type");
174
174
  const o = {};
175
- for (let u = 1; u < s.length; u++) {
176
- const f = s[u].split("=");
175
+ for (let d = 1; d < s.length; d++) {
176
+ const f = s[d].split("=");
177
177
  if (f.length === 2) {
178
178
  const g = f[0].toLocaleLowerCase(), m = g === "charset" ? f[1].toUpperCase() : f[1];
179
179
  o[g] = m;
180
180
  }
181
181
  }
182
- const a = {}, h = Object.keys(o);
183
- h.sort((u, f) => u.localeCompare(f)), h.forEach((u) => a[u] = o[u]);
184
- let c = "";
185
- for (const u in a) {
186
- const f = a[u];
187
- c += `;${u}=${f}`;
182
+ const a = {}, c = Object.keys(o);
183
+ c.sort((d, f) => d.localeCompare(f)), c.forEach((d) => a[d] = o[d]);
184
+ let h = "";
185
+ for (const d in a) {
186
+ const f = a[d];
187
+ h += `;${d}=${f}`;
188
188
  }
189
- const d = `${t}/${i}${c}`, p = a.encoding;
190
- this.string = d, this.type = t, this.subtype = i, this.parameters = a, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
189
+ const u = `${t}/${i}${h}`, p = a.encoding;
190
+ this.string = u, this.type = t, this.subtype = i, this.parameters = a, this.encoding = p, this.name = e.name, this.fileExtension = e.fileExtension;
191
191
  }
192
192
  static parse(e) {
193
193
  return new l(e);
@@ -683,8 +683,8 @@ class x {
683
683
  "totalProgression",
684
684
  "position"
685
685
  ]);
686
- return Object.entries(e).forEach(([a, h]) => {
687
- o.has(a) || n.set(a, h);
686
+ return Object.entries(e).forEach(([a, c]) => {
687
+ o.has(a) || n.set(a, c);
688
688
  }), new x({
689
689
  fragments: We(e.fragments || e.fragment),
690
690
  progression: t !== void 0 && t >= 0 && t <= 1 ? t : void 0,
@@ -791,8 +791,8 @@ class B {
791
791
  duration: C(e.duration),
792
792
  bitrate: C(e.bitrate),
793
793
  languages: We(e.language),
794
- alternates: q.deserialize(e.alternate),
795
- children: q.deserialize(e.children)
794
+ alternates: V.deserialize(e.alternate),
795
+ children: V.deserialize(e.children)
796
796
  });
797
797
  }
798
798
  /**
@@ -852,7 +852,7 @@ class B {
852
852
  });
853
853
  }
854
854
  }
855
- class q {
855
+ class V {
856
856
  /**
857
857
  * Creates a [Links].
858
858
  */
@@ -864,7 +864,7 @@ class q {
864
864
  */
865
865
  static deserialize(e) {
866
866
  if (e && e instanceof Array)
867
- return new q(
867
+ return new V(
868
868
  e.map((t) => B.deserialize(t)).filter((t) => t !== void 0)
869
869
  );
870
870
  }
@@ -946,7 +946,7 @@ class q {
946
946
  return this.items.filter((e) => e.type);
947
947
  }
948
948
  }
949
- class V {
949
+ class q {
950
950
  /**
951
951
  * Creates a [DomRange].
952
952
  */
@@ -963,7 +963,7 @@ class V {
963
963
  if (t === void 0)
964
964
  return;
965
965
  let i = C(e.charOffset);
966
- return i === void 0 && (i = C(e.offset)), new V({
966
+ return i === void 0 && (i = C(e.offset)), new q({
967
967
  cssSelector: e.cssSelector,
968
968
  textNodeIndex: t,
969
969
  charOffset: i
@@ -993,11 +993,11 @@ class re {
993
993
  static deserialize(e) {
994
994
  if (!e)
995
995
  return;
996
- let t = V.deserialize(e.start);
996
+ let t = q.deserialize(e.start);
997
997
  if (t)
998
998
  return new re({
999
999
  start: t,
1000
- end: V.deserialize(e.end)
1000
+ end: q.deserialize(e.end)
1001
1001
  });
1002
1002
  }
1003
1003
  /**
@@ -1232,15 +1232,15 @@ function Ee(r = "unknown problem", ...e) {
1232
1232
  console.warn(`${ct}: ${r}`, ...e);
1233
1233
  }
1234
1234
  P.id, P.class, P.tag, P.attribute, Number.POSITIVE_INFINITY, Number.POSITIVE_INFINITY;
1235
- function dt(r) {
1235
+ function ut(r) {
1236
1236
  return r instanceof RegExp;
1237
1237
  }
1238
- function ut(r) {
1238
+ function dt(r) {
1239
1239
  return r.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".+");
1240
1240
  }
1241
1241
  function pt(r) {
1242
1242
  const e = r.map((t) => {
1243
- if (dt(t))
1243
+ if (ut(t))
1244
1244
  return (i) => t.test(i);
1245
1245
  if (typeof t == "function")
1246
1246
  return (i) => {
@@ -1248,7 +1248,7 @@ function pt(r) {
1248
1248
  return typeof s != "boolean" ? (Ee("pattern matcher function invalid", "Provided pattern matching function does not return boolean. It's result will be ignored.", t), !1) : s;
1249
1249
  };
1250
1250
  if (typeof t == "string") {
1251
- const i = new RegExp("^" + ut(t) + "$");
1251
+ const i = new RegExp("^" + dt(t) + "$");
1252
1252
  return (s) => i.test(s);
1253
1253
  }
1254
1254
  return Ee("pattern matcher invalid", "Pattern matching only accepts strings, regular expressions and/or functions. This item is invalid and will be ignored.", t), () => !1;
@@ -1274,7 +1274,7 @@ function yt(r, e, t) {
1274
1274
  return t.map((s) => {
1275
1275
  const n = Math.max(0, s.end - e.length - s.errors), o = be(r.slice(n, s.end));
1276
1276
  return {
1277
- start: Fe(o, i, s.errors).reduce((h, c) => s.end - c.end < h ? s.end - c.end : h, s.end),
1277
+ start: Fe(o, i, s.errors).reduce((c, h) => s.end - h.end < c ? s.end - h.end : c, s.end),
1278
1278
  end: s.end,
1279
1279
  errors: s.errors
1280
1280
  };
@@ -1285,10 +1285,10 @@ function Z(r) {
1285
1285
  }
1286
1286
  function xe(r, e, t, i) {
1287
1287
  let s = r.P[t], n = r.M[t];
1288
- const o = i >>> 31, a = e[t] | o, h = a | n, c = (a & s) + s ^ s | a;
1289
- let d = n | ~(c | s), p = s & c;
1290
- const u = Z(d & r.lastRowMask[t]) - Z(p & r.lastRowMask[t]);
1291
- return d <<= 1, p <<= 1, p |= o, d |= Z(i) - o, s = p | ~(h | d), n = d & h, r.P[t] = s, r.M[t] = n, u;
1288
+ const o = i >>> 31, a = e[t] | o, c = a | n, h = (a & s) + s ^ s | a;
1289
+ let u = n | ~(h | s), p = s & h;
1290
+ const d = Z(u & r.lastRowMask[t]) - Z(p & r.lastRowMask[t]);
1291
+ return u <<= 1, p <<= 1, p |= o, u |= Z(i) - o, s = p | ~(c | u), n = u & c, r.P[t] = s, r.M[t] = n, d;
1292
1292
  }
1293
1293
  function Fe(r, e, t) {
1294
1294
  if (e.length === 0)
@@ -1300,15 +1300,15 @@ function Fe(r, e, t) {
1300
1300
  lastRowMask: new Uint32Array(n + 1)
1301
1301
  };
1302
1302
  o.lastRowMask.fill(1 << 31), o.lastRowMask[n] = 1 << (e.length - 1) % s;
1303
- const a = new Uint32Array(n + 1), h = /* @__PURE__ */ new Map(), c = [];
1304
- for (let u = 0; u < 256; u++)
1305
- c.push(a);
1306
- for (let u = 0; u < e.length; u += 1) {
1307
- const f = e.charCodeAt(u);
1308
- if (h.has(f))
1303
+ const a = new Uint32Array(n + 1), c = /* @__PURE__ */ new Map(), h = [];
1304
+ for (let d = 0; d < 256; d++)
1305
+ h.push(a);
1306
+ for (let d = 0; d < e.length; d += 1) {
1307
+ const f = e.charCodeAt(d);
1308
+ if (c.has(f))
1309
1309
  continue;
1310
1310
  const g = new Uint32Array(n + 1);
1311
- h.set(f, g), f < c.length && (c[f] = g);
1311
+ c.set(f, g), f < h.length && (h[f] = g);
1312
1312
  for (let m = 0; m <= n; m += 1) {
1313
1313
  g[m] = 0;
1314
1314
  for (let v = 0; v < s; v += 1) {
@@ -1319,37 +1319,37 @@ function Fe(r, e, t) {
1319
1319
  }
1320
1320
  }
1321
1321
  }
1322
- let d = Math.max(0, Math.ceil(t / s) - 1);
1322
+ let u = Math.max(0, Math.ceil(t / s) - 1);
1323
1323
  const p = new Uint32Array(n + 1);
1324
- for (let u = 0; u <= d; u += 1)
1325
- p[u] = (u + 1) * s;
1324
+ for (let d = 0; d <= u; d += 1)
1325
+ p[d] = (d + 1) * s;
1326
1326
  p[n] = e.length;
1327
- for (let u = 0; u <= d; u += 1)
1328
- o.P[u] = -1, o.M[u] = 0;
1329
- for (let u = 0; u < r.length; u += 1) {
1330
- const f = r.charCodeAt(u);
1327
+ for (let d = 0; d <= u; d += 1)
1328
+ o.P[d] = -1, o.M[d] = 0;
1329
+ for (let d = 0; d < r.length; d += 1) {
1330
+ const f = r.charCodeAt(d);
1331
1331
  let g;
1332
- f < c.length ? g = c[f] : (g = h.get(f), typeof g > "u" && (g = a));
1332
+ f < h.length ? g = h[f] : (g = c.get(f), typeof g > "u" && (g = a));
1333
1333
  let m = 0;
1334
- for (let v = 0; v <= d; v += 1)
1334
+ for (let v = 0; v <= u; v += 1)
1335
1335
  m = xe(o, g, v, m), p[v] += m;
1336
- if (p[d] - m <= t && d < n && (g[d + 1] & 1 || m < 0)) {
1337
- d += 1, o.P[d] = -1, o.M[d] = 0;
1336
+ if (p[u] - m <= t && u < n && (g[u + 1] & 1 || m < 0)) {
1337
+ u += 1, o.P[u] = -1, o.M[u] = 0;
1338
1338
  let v;
1339
- if (d === n) {
1339
+ if (u === n) {
1340
1340
  const S = e.length % s;
1341
1341
  v = S === 0 ? s : S;
1342
1342
  } else
1343
1343
  v = s;
1344
- p[d] = p[d - 1] + v - m + xe(o, g, d, m);
1344
+ p[u] = p[u - 1] + v - m + xe(o, g, u, m);
1345
1345
  } else
1346
- for (; d > 0 && p[d] >= t + s; )
1347
- d -= 1;
1348
- d === n && p[d] <= t && (p[d] < t && i.splice(0, i.length), i.push({
1346
+ for (; u > 0 && p[u] >= t + s; )
1347
+ u -= 1;
1348
+ u === n && p[u] <= t && (p[u] < t && i.splice(0, i.length), i.push({
1349
1349
  start: -1,
1350
- end: u + 1,
1351
- errors: p[d]
1352
- }), t = p[d]);
1350
+ end: d + 1,
1351
+ errors: p[u]
1352
+ }), t = p[u]);
1353
1353
  }
1354
1354
  return i;
1355
1355
  }
@@ -1378,7 +1378,7 @@ function Et(r, e, t = {}) {
1378
1378
  if (s.length === 0)
1379
1379
  return null;
1380
1380
  const n = (a) => {
1381
- const u = 1 - a.errors / e.length, f = t.prefix ? Se(
1381
+ const d = 1 - a.errors / e.length, f = t.prefix ? Se(
1382
1382
  r.slice(
1383
1383
  Math.max(0, a.start - t.prefix.length),
1384
1384
  a.start
@@ -1390,14 +1390,14 @@ function Et(r, e, t = {}) {
1390
1390
  ) : 1;
1391
1391
  let m = 1;
1392
1392
  typeof t.hint == "number" && (m = 1 - Math.abs(a.start - t.hint) / r.length);
1393
- const v = 50 * u + 20 * f + 20 * g + 2 * m, S = 50 + 20 + 20 + 2;
1393
+ const v = 50 * d + 20 * f + 20 * g + 2 * m, S = 50 + 20 + 20 + 2;
1394
1394
  return v / S;
1395
1395
  }, o = s.map((a) => ({
1396
1396
  start: a.start,
1397
1397
  end: a.end,
1398
1398
  score: n(a)
1399
1399
  }));
1400
- return o.sort((a, h) => h.score - a.score), o[0];
1400
+ return o.sort((a, c) => c.score - a.score), o[0];
1401
1401
  }
1402
1402
  function J(r, e, t) {
1403
1403
  const i = t === 1 ? e : e - 1;
@@ -1409,7 +1409,7 @@ function J(r, e, t) {
1409
1409
  const o = s.length - n.length;
1410
1410
  return t === 2 ? e - o : e + o;
1411
1411
  }
1412
- function Te(r, e) {
1412
+ function we(r, e) {
1413
1413
  const t = r.commonAncestorContainer.ownerDocument.createNodeIterator(
1414
1414
  r.commonAncestorContainer,
1415
1415
  NodeFilter.SHOW_TEXT
@@ -1421,8 +1421,8 @@ function Te(r, e) {
1421
1421
  let o = -1;
1422
1422
  const a = () => {
1423
1423
  if (n = e === 1 ? t.nextNode() : t.previousNode(), n) {
1424
- const h = n.textContent, c = e === 1 ? 0 : h.length;
1425
- o = J(h, c, e);
1424
+ const c = n.textContent, h = e === 1 ? 0 : c.length;
1425
+ o = J(c, h, e);
1426
1426
  }
1427
1427
  };
1428
1428
  for (; n && o === -1 && n !== s; )
@@ -1457,7 +1457,7 @@ function bt(r) {
1457
1457
  if (s.start >= 0 && (e.setStart(r.startContainer, s.start), t = !0), s.end > 0 && (e.setEnd(r.endContainer, s.end), i = !0), t && i)
1458
1458
  return e;
1459
1459
  if (!t) {
1460
- const { node: n, offset: o } = Te(
1460
+ const { node: n, offset: o } = we(
1461
1461
  e,
1462
1462
  1
1463
1463
  /* Forwards */
@@ -1465,7 +1465,7 @@ function bt(r) {
1465
1465
  n && o >= 0 && e.setStart(n, o);
1466
1466
  }
1467
1467
  if (!i) {
1468
- const { node: n, offset: o } = Te(
1468
+ const { node: n, offset: o } = we(
1469
1469
  e,
1470
1470
  2
1471
1471
  /* Backwards */
@@ -1484,7 +1484,7 @@ function Ue(r) {
1484
1484
  return 0;
1485
1485
  }
1486
1486
  }
1487
- function we(r) {
1487
+ function Te(r) {
1488
1488
  let e = r.previousSibling, t = 0;
1489
1489
  for (; e; )
1490
1490
  t += Ue(e), e = e.previousSibling;
@@ -1522,7 +1522,7 @@ class M {
1522
1522
  throw new Error("Parent is not an ancestor of current element");
1523
1523
  let t = this.element, i = this.offset;
1524
1524
  for (; t !== e; )
1525
- i += we(t), t = t.parentElement;
1525
+ i += Te(t), t = t.parentElement;
1526
1526
  return new M(t, i);
1527
1527
  }
1528
1528
  /**
@@ -1587,7 +1587,7 @@ class M {
1587
1587
  throw new Error("Text node offset is out of range");
1588
1588
  if (!e.parentElement)
1589
1589
  throw new Error("Text node has no parent");
1590
- const i = we(e) + t;
1590
+ const i = Te(e) + t;
1591
1591
  return new M(e.parentElement, i);
1592
1592
  }
1593
1593
  case Node.ELEMENT_NODE: {
@@ -1782,25 +1782,25 @@ function St(r, e) {
1782
1782
  let t = r.getClientRects();
1783
1783
  t.length || r.commonAncestorContainer.nodeType === Node.ELEMENT_NODE && (t = r.commonAncestorContainer.getClientRects());
1784
1784
  const i = 1, s = [];
1785
- for (const c of t)
1785
+ for (const h of t)
1786
1786
  s.push({
1787
- bottom: c.bottom,
1788
- height: c.height,
1789
- left: c.left,
1790
- right: c.right,
1791
- top: c.top,
1792
- width: c.width
1787
+ bottom: h.bottom,
1788
+ height: h.height,
1789
+ left: h.left,
1790
+ right: h.right,
1791
+ top: h.top,
1792
+ width: h.width
1793
1793
  });
1794
1794
  const n = He(
1795
1795
  s,
1796
1796
  i,
1797
1797
  e
1798
- ), o = wt(n, i), a = $e(o), h = 2 * 2;
1799
- for (let c = a.length - 1; c >= 0; c--) {
1800
- const d = a[c];
1801
- if (!(d.width * d.height > h))
1798
+ ), o = Tt(n, i), a = $e(o), c = 2 * 2;
1799
+ for (let h = a.length - 1; h >= 0; h--) {
1800
+ const u = a[h];
1801
+ if (!(u.width * u.height > c))
1802
1802
  if (a.length > 1)
1803
- a.splice(c, 1);
1803
+ a.splice(h, 1);
1804
1804
  else
1805
1805
  break;
1806
1806
  }
@@ -1812,11 +1812,11 @@ function He(r, e, t) {
1812
1812
  const n = r[i], o = r[s];
1813
1813
  if (n === o)
1814
1814
  continue;
1815
- const a = N(n.top, o.top, e) && N(n.bottom, o.bottom, e), h = N(n.left, o.left, e) && N(n.right, o.right, e);
1816
- if ((h && !t || a && !h) && je(n, o, e)) {
1817
- const u = r.filter((g) => g !== n && g !== o), f = Tt(n, o);
1818
- return u.push(f), He(
1819
- u,
1815
+ const a = N(n.top, o.top, e) && N(n.bottom, o.bottom, e), c = N(n.left, o.left, e) && N(n.right, o.right, e);
1816
+ if ((c && !t || a && !c) && je(n, o, e)) {
1817
+ const d = r.filter((g) => g !== n && g !== o), f = wt(n, o);
1818
+ return d.push(f), He(
1819
+ d,
1820
1820
  e,
1821
1821
  t
1822
1822
  );
@@ -1824,7 +1824,7 @@ function He(r, e, t) {
1824
1824
  }
1825
1825
  return r;
1826
1826
  }
1827
- function Tt(r, e) {
1827
+ function wt(r, e) {
1828
1828
  const t = Math.min(r.left, e.left), i = Math.max(r.right, e.right), s = Math.min(r.top, e.top), n = Math.max(r.bottom, e.bottom);
1829
1829
  return {
1830
1830
  bottom: n,
@@ -1835,7 +1835,7 @@ function Tt(r, e) {
1835
1835
  width: i - t
1836
1836
  };
1837
1837
  }
1838
- function wt(r, e) {
1838
+ function Tt(r, e) {
1839
1839
  const t = new Set(r);
1840
1840
  for (const i of r) {
1841
1841
  if (!(i.width > 1 && i.height > 1)) {
@@ -1866,11 +1866,11 @@ function $e(r) {
1866
1866
  if (a.length === 1)
1867
1867
  n = a, o = i;
1868
1868
  else {
1869
- const c = Ce(s, i);
1870
- a.length < c.length ? (n = a, o = i) : (n = c, o = s);
1869
+ const h = Ce(s, i);
1870
+ a.length < h.length ? (n = a, o = i) : (n = h, o = s);
1871
1871
  }
1872
- const h = r.filter((c) => c !== o);
1873
- return Array.prototype.push.apply(h, n), $e(h);
1872
+ const c = r.filter((h) => h !== o);
1873
+ return Array.prototype.push.apply(c, n), $e(c);
1874
1874
  }
1875
1875
  }
1876
1876
  return r;
@@ -1943,14 +1943,14 @@ function je(r, e, t) {
1943
1943
  function N(r, e, t) {
1944
1944
  return Math.abs(r - e) <= t;
1945
1945
  }
1946
- function qe(r) {
1946
+ function Ve(r) {
1947
1947
  const e = {}, t = r.document.documentElement.style;
1948
1948
  for (const i in r.document.documentElement.style)
1949
1949
  Object.hasOwn(t, i) && !Number.isNaN(Number.parseInt(i)) && (e[t[i]] = t.getPropertyValue(t[i]));
1950
1950
  return e;
1951
1951
  }
1952
1952
  function Nt(r, e) {
1953
- const t = qe(r);
1953
+ const t = Ve(r);
1954
1954
  Object.keys(t).forEach((i) => {
1955
1955
  e.hasOwnProperty(i) || he(r, i);
1956
1956
  }), Object.entries(e).forEach(([i, s]) => {
@@ -2020,14 +2020,14 @@ class zt {
2020
2020
  * @param decoration Decoration to add
2021
2021
  */
2022
2022
  add(e) {
2023
- var o, a, h, c;
2023
+ var o, a, c, h;
2024
2024
  const t = `${this.id}-${this.lastItemId++}`, i = le(this.wnd.document, e.locator);
2025
2025
  if (!i) {
2026
2026
  this.comms.log("Can't locate DOM range for decoration", e);
2027
2027
  return;
2028
2028
  }
2029
2029
  const s = i.commonAncestorContainer;
2030
- s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((a = this.notTextFlag) == null || a.set(t, !0)), (((h = s.textContent) == null ? void 0 : h.trim()) || "").length === 0 && ((c = this.notTextFlag) == null || c.set(t, !0)));
2030
+ s.nodeType !== Node.TEXT_NODE && this.experimentalHighlights && (Ne.includes(s.nodeName.toUpperCase()) && ((o = this.notTextFlag) == null || o.set(t, !0)), s.querySelector(Ne.join(", ").toLowerCase()) && ((a = this.notTextFlag) == null || a.set(t, !0)), (((c = s.textContent) == null ? void 0 : c.trim()) || "").length === 0 && ((h = this.notTextFlag) == null || h.set(t, !0)));
2031
2031
  const n = {
2032
2032
  decoration: e,
2033
2033
  id: t,
@@ -2095,30 +2095,30 @@ class zt {
2095
2095
  getComputedStyle(this.wnd.document.documentElement).getPropertyValue(
2096
2096
  "column-count"
2097
2097
  )
2098
- ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, h = o.scrollTop, c = (y, b, I) => {
2099
- var ce, de, ue, pe, fe, me;
2100
- if (y.style.position = "absolute", ((de = (ce = e.decoration) == null ? void 0 : ce.style) == null ? void 0 : de.width) === "viewport") {
2098
+ ), n = i / (s || 1), o = this.wnd.document.scrollingElement, a = o.scrollLeft, c = o.scrollTop, h = (y, b, I) => {
2099
+ var ce, ue, de, pe, fe, me;
2100
+ if (y.style.position = "absolute", ((ue = (ce = e.decoration) == null ? void 0 : ce.style) == null ? void 0 : ue.width) === "viewport") {
2101
2101
  y.style.width = `${i}px`, y.style.height = `${b.height}px`;
2102
2102
  let K = Math.floor(b.left / i) * i;
2103
- y.style.left = `${K + a}px`, y.style.top = `${b.top + h}px`;
2104
- } else if (((pe = (ue = e.decoration) == null ? void 0 : ue.style) == null ? void 0 : pe.width) === "bounds")
2105
- y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + a}px`, y.style.top = `${b.top + h}px`;
2103
+ y.style.left = `${K + a}px`, y.style.top = `${b.top + c}px`;
2104
+ } else if (((pe = (de = e.decoration) == null ? void 0 : de.style) == null ? void 0 : pe.width) === "bounds")
2105
+ y.style.width = `${I.width}px`, y.style.height = `${b.height}px`, y.style.left = `${I.left + a}px`, y.style.top = `${b.top + c}px`;
2106
2106
  else if (((me = (fe = e.decoration) == null ? void 0 : fe.style) == null ? void 0 : me.width) === "page") {
2107
2107
  y.style.width = `${n}px`, y.style.height = `${b.height}px`;
2108
2108
  let K = Math.floor(b.left / n) * n;
2109
- y.style.left = `${K + a}px`, y.style.top = `${b.top + h}px`;
2109
+ y.style.left = `${K + a}px`, y.style.top = `${b.top + c}px`;
2110
2110
  } else
2111
- y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + a}px`, y.style.top = `${b.top + h}px`;
2112
- }, d = e.range.getBoundingClientRect();
2111
+ y.style.width = `${b.width}px`, y.style.height = `${b.height}px`, y.style.left = `${b.left + a}px`, y.style.top = `${b.top + c}px`;
2112
+ }, u = e.range.getBoundingClientRect();
2113
2113
  let p = this.wnd.document.createElement("template");
2114
- const u = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
2114
+ const d = Pe(this.wnd, "--USER__appearance") === "readium-night-on" || Ot(Pe(this.wnd, "--USER__backgroundColor"));
2115
2115
  p.innerHTML = `
2116
2116
  <div
2117
2117
  class="r2-highlight-0"
2118
2118
  style="${[
2119
2119
  `background-color: ${((v = (m = e.decoration) == null ? void 0 : m.style) == null ? void 0 : v.tint) ?? "yellow"} !important`,
2120
2120
  //"opacity: 0.3 !important",
2121
- `mix-blend-mode: ${u ? "exclusion" : "multiply"} !important`,
2121
+ `mix-blend-mode: ${d ? "exclusion" : "multiply"} !important`,
2122
2122
  "opacity: 1 !important",
2123
2123
  "box-sizing: border-box !important"
2124
2124
  ].join("; ")}"
@@ -2128,7 +2128,7 @@ class zt {
2128
2128
  const f = p.content.firstElementChild;
2129
2129
  if (((O = (S = e.decoration) == null ? void 0 : S.style) == null ? void 0 : O.layout) === "bounds") {
2130
2130
  const y = f.cloneNode(!0);
2131
- y.style.setProperty("pointer-events", "none"), c(y, d, d), t.append(y);
2131
+ y.style.setProperty("pointer-events", "none"), h(y, u, u), t.append(y);
2132
2132
  } else {
2133
2133
  let y = St(
2134
2134
  e.range,
@@ -2138,7 +2138,7 @@ class zt {
2138
2138
  y = y.sort((b, I) => b.top < I.top ? -1 : b.top > I.top ? 1 : 0);
2139
2139
  for (let b of y) {
2140
2140
  const I = f.cloneNode(!0);
2141
- I.style.setProperty("pointer-events", "none"), c(I, b, d), t.append(I);
2141
+ I.style.setProperty("pointer-events", "none"), h(I, b, u), t.append(I);
2142
2142
  }
2143
2143
  }
2144
2144
  e.container = t, e.clickableElements = Array.from(
@@ -2175,7 +2175,7 @@ class zt {
2175
2175
  this.experimentalHighlights && this.wnd.CSS.highlights.delete(this.id), this.container && (this.container.remove(), this.container = void 0);
2176
2176
  }
2177
2177
  }
2178
- const Ve = class Q extends Y {
2178
+ const qe = class Q extends Y {
2179
2179
  constructor() {
2180
2180
  super(...arguments), this.resizeFrame = 0, this.lastGroupId = 0, this.groups = /* @__PURE__ */ new Map(), this.handleResizer = this.handleResize.bind(this);
2181
2181
  }
@@ -2220,8 +2220,8 @@ const Ve = class Q extends Y {
2220
2220
  return e.removeEventListener("orientationchange", this.handleResizer), e.removeEventListener("resize", this.handleResizer), t.unregisterAll(Q.moduleName), this.resizeObserver.disconnect(), this.cleanup(), t.log("Decorator Unmounted"), !0;
2221
2221
  }
2222
2222
  };
2223
- Ve.moduleName = "decorator";
2224
- let Dt = Ve;
2223
+ qe.moduleName = "decorator";
2224
+ let Dt = qe;
2225
2225
  const Ae = "readium-snapper-style", _e = class ee extends Y {
2226
2226
  constructor() {
2227
2227
  super(...arguments), this.protected = !1;
@@ -2263,20 +2263,24 @@ function Me(r) {
2263
2263
  return r.clientHeight - t - i;
2264
2264
  }
2265
2265
  function Oe(r) {
2266
- const e = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2267
- for (const a of e)
2268
- a.remove();
2269
- const t = Ge(r), i = r.document.scrollingElement.scrollWidth, s = Math.ceil(i / r.innerWidth) * t, n = Math.round(i / r.innerWidth * t), o = t === 1 ? 0 : s - n;
2270
- if (o > 0)
2271
- for (let a = 0; a < o; a++) {
2272
- const h = r.document.createElement("div");
2273
- h.setAttribute("id", `readium-virtual-page-${a}`), 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 = Me(r.document.documentElement) + "px"), h.innerHTML = "&#8203;", r.document.body.appendChild(h);
2266
+ const e = Ge(r);
2267
+ if (!e)
2268
+ return !1;
2269
+ const t = r.document.querySelectorAll("div[id^='readium-virtual-page']");
2270
+ for (const h of t)
2271
+ h.remove();
2272
+ const i = t.length, s = r.document.scrollingElement.scrollWidth, n = r.visualViewport.width, a = Math.round(s / n * e) % e, c = e === 1 || a === 0 ? 0 : e - a;
2273
+ if (c > 0)
2274
+ for (let h = 0; h < c; h++) {
2275
+ const u = r.document.createElement("div");
2276
+ u.setAttribute("id", `readium-virtual-page-${h}`), u.dataset.readium = "true", CSS.supports("break-before", "column") ? u.style.breakBefore = "column" : (CSS.supports("break-inside", "avoid-column") && (u.style.breakInside = "avoid-column"), u.style.height = Me(r.document.documentElement) + "px"), u.innerHTML = "&#8203;", r.document.body.appendChild(u);
2274
2277
  }
2278
+ return i !== c;
2275
2279
  }
2276
2280
  function Wt(r) {
2277
2281
  return r < 0.5 ? 2 * r * r : -1 + (4 - 2 * r) * r;
2278
2282
  }
2279
- function T(r) {
2283
+ function w(r) {
2280
2284
  const e = r.getSelection();
2281
2285
  e && e.removeAllRanges();
2282
2286
  }
@@ -2344,7 +2348,7 @@ function kt(r) {
2344
2348
  }
2345
2349
  return !1;
2346
2350
  }
2347
- const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2351
+ const Ie = "readium-column-snapper-style", Ht = 200, Je = class T extends Xe {
2348
2352
  constructor() {
2349
2353
  super(...arguments), this.shakeTimeout = 0, this.snappingCancelled = !1, this.alreadyScrollLeft = 0, this.overscroll = 0, this.cachedScrollWidth = 0, this.touchState = 0, this.startingX = void 0, this.endingX = void 0, this.onTouchStarter = this.onTouchStart.bind(this), this.onTouchEnder = this.onTouchEnd.bind(this), this.onWidthChanger = this.onWidthChange.bind(this), this.onTouchMover = this.onTouchMove.bind(this);
2350
2354
  }
@@ -2380,13 +2384,13 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2380
2384
  }
2381
2385
  // Snaps the current offset to the page width.
2382
2386
  snapCurrentOffset(e = !1, t = !1) {
2383
- const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ge(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), h = W(this.wnd) ? -1 : 1, c = (
2387
+ const i = this.wnd.scrollX > 0 ? this.wnd.scrollX : this.alreadyScrollLeft, s = this.doc(), n = this.dragOffset(), o = Ge(this.wnd), a = Math.min(Math.max(0, i), this.cachedScrollWidth), c = W(this.wnd) ? -1 : 1, h = (
2384
2388
  // The hurdle to overcome in order to change pages
2385
- h * (this.wnd.innerWidth / 3) * (h * n > 0 ? 2 : 1)
2386
- ), d = this.snapOffset(a + c);
2387
- if (e && d !== this.scrollOffset()) {
2389
+ c * (this.wnd.innerWidth / 3) * (c * n > 0 ? 2 : 1)
2390
+ ), u = this.snapOffset(a + h);
2391
+ if (e && u !== this.scrollOffset()) {
2388
2392
  this.snappingCancelled = !1;
2389
- const p = (m, v, S, O) => S > O ? v : m + (v - m) * Wt(S / O), u = (
2393
+ const p = (m, v, S, O) => S > O ? v : m + (v - m) * Wt(S / O), d = (
2390
2394
  /*Math.abs(startX - (this.useTransform ? currentOffset : 0)) < 10 ? 1 : */
2391
2395
  Ht * o
2392
2396
  );
@@ -2395,13 +2399,13 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2395
2399
  if (this.snappingCancelled)
2396
2400
  return;
2397
2401
  f || (f = m);
2398
- const v = m - f, S = p(this.overscroll, 0, v, u), O = p(i, d, v, u);
2399
- s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < u ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = d, t || this.reportProgress());
2402
+ const v = m - f, S = p(this.overscroll, 0, v, d), O = p(i, u, v, d);
2403
+ s.scrollLeft = O, this.overscroll !== 0 && (s.style.transform = `translate3d(${-S}px, 0px, 0px)`), v < d ? this.wnd.requestAnimationFrame(g) : (this.clearTouches(), s.style.removeProperty("transform"), s.scrollLeft = u, t || this.reportProgress());
2400
2404
  };
2401
2405
  this.wnd.requestAnimationFrame(g);
2402
2406
  } else
2403
2407
  s.style.removeProperty("transform"), this.wnd.requestAnimationFrame(() => {
2404
- s.scrollLeft = d, this.clearTouches(), t || this.reportProgress();
2408
+ s.scrollLeft = u, this.clearTouches(), t || this.reportProgress();
2405
2409
  });
2406
2410
  }
2407
2411
  dragOffset() {
@@ -2437,7 +2441,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2437
2441
  onTouchMove(e) {
2438
2442
  if (this.touchState === 0)
2439
2443
  return;
2440
- this.touchState === 1 && (this.touchState = 2, T(this.wnd)), this.endingX = e.touches[0].clientX;
2444
+ this.touchState === 1 && (this.touchState = 2, w(this.wnd)), this.endingX = e.touches[0].clientX;
2441
2445
  const t = this.dragOffset(), i = this.alreadyScrollLeft + t;
2442
2446
  i < 0 ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-this.overscroll}px, 0px, 0px)`) : i + this.wnd.innerWidth > this.cachedScrollWidth ? (this.overscroll = i, this.doc().style.transform = `translate3d(${-i}px, 0px, 0px)`) : (this.overscroll = 0, this.doc().style.removeProperty("transform"), this.doc().scrollLeft = this.alreadyScrollLeft + t);
2443
2447
  }
@@ -2487,8 +2491,8 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2487
2491
  }), this.resizeObserver.observe(e.document.body), this.mutationObserver = new MutationObserver((n) => {
2488
2492
  for (const o of n)
2489
2493
  if (o.target === this.wnd.document.documentElement) {
2490
- const a = o.oldValue, h = o.target.getAttribute("style"), c = /transform\s*:\s*([^;]+)/, d = a == null ? void 0 : a.match(c), p = h == null ? void 0 : h.match(c);
2491
- (!d && !p || d && !p || d && p && d[1] !== p[1]) && (e.requestAnimationFrame(() => {
2494
+ const a = o.oldValue, c = o.target.getAttribute("style"), h = /transform\s*:\s*([^;]+)/, u = a == null ? void 0 : a.match(h), p = c == null ? void 0 : c.match(h);
2495
+ (!u && !p || u && !p || u && p && u[1] !== p[1]) && (e.requestAnimationFrame(() => {
2492
2496
  e && Oe(e);
2493
2497
  }), this.onWidthChange());
2494
2498
  } else
@@ -2498,7 +2502,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2498
2502
  const o = this.doc().scrollLeft;
2499
2503
  return this.doc().scrollLeft = this.snapOffset(n), o !== this.doc().scrollLeft;
2500
2504
  };
2501
- return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", w.moduleName, (n, o) => {
2505
+ return e.addEventListener("orientationchange", this.onWidthChanger), e.addEventListener("resize", this.onWidthChanger), e.requestAnimationFrame(() => this.cachedScrollWidth = this.doc().scrollWidth), t.register("go_progression", T.moduleName, (n, o) => {
2502
2506
  const a = n;
2503
2507
  if (a < 0 || a > 1) {
2504
2508
  t.send("error", {
@@ -2508,74 +2512,74 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2508
2512
  }
2509
2513
  this.wnd.requestAnimationFrame(() => {
2510
2514
  this.cachedScrollWidth = this.doc().scrollWidth;
2511
- const h = this.cachedScrollWidth, c = W(e) ? -1 : 1, d = h * a * c;
2512
- this.doc().scrollLeft = this.snapOffset(d), this.reportProgress(), T(this.wnd), o(!0);
2515
+ const c = this.cachedScrollWidth, h = W(e) ? -1 : 1, u = c * a * h;
2516
+ this.doc().scrollLeft = this.snapOffset(u), this.reportProgress(), w(this.wnd), o(!0);
2513
2517
  });
2514
- }), t.register("go_id", w.moduleName, (n, o) => {
2518
+ }), t.register("go_id", T.moduleName, (n, o) => {
2515
2519
  const a = e.document.getElementById(n);
2516
2520
  if (!a) {
2517
2521
  o(!1);
2518
2522
  return;
2519
2523
  }
2520
2524
  this.wnd.requestAnimationFrame(() => {
2521
- this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2525
+ this.doc().scrollLeft = this.snapOffset(a.getBoundingClientRect().left + e.scrollX), this.reportProgress(), w(this.wnd), o(!0);
2522
2526
  });
2523
- }), t.register("go_text", w.moduleName, (n, o) => {
2527
+ }), t.register("go_text", T.moduleName, (n, o) => {
2524
2528
  let a;
2525
2529
  Array.isArray(n) && (n.length > 1 && (a = n[1]), n = n[0]);
2526
- const h = U.deserialize(n), c = le(this.wnd.document, new D({
2530
+ const c = U.deserialize(n), h = le(this.wnd.document, new D({
2527
2531
  href: e.location.href,
2528
2532
  type: "text/html",
2529
- text: h,
2533
+ text: c,
2530
2534
  locations: a ? new x({
2531
2535
  otherLocations: /* @__PURE__ */ new Map([
2532
2536
  ["cssSelector", a]
2533
2537
  ])
2534
2538
  }) : void 0
2535
2539
  }));
2536
- if (!c) {
2540
+ if (!h) {
2537
2541
  o(!1);
2538
2542
  return;
2539
2543
  }
2540
2544
  this.wnd.requestAnimationFrame(() => {
2541
- this.doc().scrollLeft = this.snapOffset(c.getBoundingClientRect().left + e.scrollX), this.reportProgress(), T(this.wnd), o(!0);
2545
+ this.doc().scrollLeft = this.snapOffset(h.getBoundingClientRect().left + e.scrollX), this.reportProgress(), w(this.wnd), o(!0);
2542
2546
  });
2543
- }), t.register("go_end", w.moduleName, (n, o) => {
2547
+ }), t.register("go_end", T.moduleName, (n, o) => {
2544
2548
  const a = W(e) ? -1 : 1;
2545
2549
  this.wnd.requestAnimationFrame(() => {
2546
2550
  this.cachedScrollWidth = this.doc().scrollWidth;
2547
- const h = this.cachedScrollWidth * a;
2548
- if (this.doc().scrollLeft === h)
2551
+ const c = this.cachedScrollWidth * a;
2552
+ if (this.doc().scrollLeft === c)
2549
2553
  return o(!1);
2550
- this.doc().scrollLeft = this.snapOffset(h), this.reportProgress(), T(this.wnd), o(!0);
2554
+ this.doc().scrollLeft = this.snapOffset(c), this.reportProgress(), w(this.wnd), o(!0);
2551
2555
  });
2552
- }), t.register("go_start", w.moduleName, (n, o) => {
2556
+ }), t.register("go_start", T.moduleName, (n, o) => {
2553
2557
  this.wnd.requestAnimationFrame(() => {
2554
2558
  if (this.doc().scrollLeft === 0)
2555
2559
  return o(!1);
2556
- this.doc().scrollLeft = 0, this.reportProgress(), T(this.wnd), o(!0);
2560
+ this.doc().scrollLeft = 0, this.reportProgress(), w(this.wnd), o(!0);
2557
2561
  });
2558
- }), t.register("go_prev", w.moduleName, (n, o) => {
2562
+ }), t.register("go_prev", T.moduleName, (n, o) => {
2559
2563
  this.wnd.requestAnimationFrame(() => {
2560
2564
  this.cachedScrollWidth = this.doc().scrollWidth;
2561
- const a = e.scrollX - e.innerWidth, h = W(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, c = s(Math.max(a, h));
2562
- c && (this.reportProgress(), T(this.wnd)), o(c);
2565
+ const a = e.scrollX - e.innerWidth, c = W(e) ? -(this.cachedScrollWidth - e.innerWidth) : 0, h = s(Math.max(a, c));
2566
+ h && (this.reportProgress(), w(this.wnd)), o(h);
2563
2567
  });
2564
- }), t.register("go_next", w.moduleName, (n, o) => {
2568
+ }), t.register("go_next", T.moduleName, (n, o) => {
2565
2569
  this.wnd.requestAnimationFrame(() => {
2566
2570
  this.cachedScrollWidth = this.doc().scrollWidth;
2567
- const a = e.scrollX + e.innerWidth, h = W(e) ? 0 : this.cachedScrollWidth - e.innerWidth, c = s(Math.min(a, h));
2568
- c && (this.reportProgress(), T(this.wnd)), o(c);
2571
+ const a = e.scrollX + e.innerWidth, c = W(e) ? 0 : this.cachedScrollWidth - e.innerWidth, h = s(Math.min(a, c));
2572
+ h && (this.reportProgress(), w(this.wnd)), o(h);
2569
2573
  });
2570
- }), t.register("unfocus", w.moduleName, (n, o) => {
2571
- this.snappingCancelled = !0, T(this.wnd), o(!0);
2572
- }), t.register("shake", w.moduleName, (n, o) => {
2574
+ }), t.register("unfocus", T.moduleName, (n, o) => {
2575
+ this.snappingCancelled = !0, w(this.wnd), o(!0);
2576
+ }), t.register("shake", T.moduleName, (n, o) => {
2573
2577
  this.shake(), o(!0);
2574
- }), t.register("focus", w.moduleName, (n, o) => {
2578
+ }), t.register("focus", T.moduleName, (n, o) => {
2575
2579
  this.wnd.requestAnimationFrame(() => {
2576
2580
  this.cachedScrollWidth = this.doc().scrollWidth, this.snapCurrentOffset(!1, !0), this.reportProgress(), o(!0);
2577
2581
  });
2578
- }), t.register("first_visible_locator", w.moduleName, (n, o) => {
2582
+ }), t.register("first_visible_locator", T.moduleName, (n, o) => {
2579
2583
  const a = Ke(e, !1);
2580
2584
  this.comms.send("first_visible_locator", a.serialize()), o(!0);
2581
2585
  }), e.addEventListener("touchstart", this.onTouchStarter, { passive: !0 }), e.addEventListener("touchend", this.onTouchEnder, { passive: !0 }), e.addEventListener("touchmove", this.onTouchMover, { passive: !0 }), e.document.addEventListener("touchstart", () => {
@@ -2583,7 +2587,7 @@ const Ie = "readium-column-snapper-style", Ht = 200, Je = class w extends Xe {
2583
2587
  }
2584
2588
  unmount(e, t) {
2585
2589
  var i;
2586
- return this.snappingCancelled = !0, t.unregisterAll(w.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), (i = e.document.getElementById(Ie)) == null || i.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2590
+ return this.snappingCancelled = !0, t.unregisterAll(T.moduleName), this.resizeObserver.disconnect(), this.mutationObserver.disconnect(), e.removeEventListener("touchstart", this.onTouchStarter), e.removeEventListener("touchend", this.onTouchEnder), e.removeEventListener("touchmove", this.onTouchMover), e.removeEventListener("orientationchange", this.onWidthChanger), e.removeEventListener("resize", this.onWidthChanger), (i = e.document.getElementById(Ie)) == null || i.remove(), t.log("ColumnSnapper Unmounted"), super.unmount(e, t);
2587
2591
  }
2588
2592
  };
2589
2593
  Je.moduleName = "column_snapper";
@@ -2627,7 +2631,7 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
2627
2631
  return;
2628
2632
  }
2629
2633
  this.wnd.requestAnimationFrame(() => {
2630
- this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
2634
+ this.doc().scrollTop = this.doc().offsetHeight * o, this.reportProgress({ progress: o, reference: this.wnd.innerHeight / this.doc().scrollHeight }), w(this.wnd), n(!0);
2631
2635
  });
2632
2636
  }), t.register("go_id", A.moduleName, (s, n) => {
2633
2637
  const o = e.document.getElementById(s);
@@ -2638,12 +2642,12 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
2638
2642
  this.wnd.requestAnimationFrame(() => {
2639
2643
  this.doc().scrollTop = o.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
2640
2644
  const a = this.doc().scrollTop / this.doc().offsetHeight;
2641
- this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
2645
+ this.reportProgress({ progress: a, reference: this.wnd.innerHeight / this.doc().scrollHeight }), w(this.wnd), n(!0);
2642
2646
  });
2643
2647
  }), t.register("go_text", A.moduleName, (s, n) => {
2644
2648
  let o;
2645
2649
  Array.isArray(s) && (s.length > 1 && (o = s[1]), s = s[0]);
2646
- const a = U.deserialize(s), h = le(this.wnd.document, new D({
2650
+ const a = U.deserialize(s), c = le(this.wnd.document, new D({
2647
2651
  href: e.location.href,
2648
2652
  type: "text/html",
2649
2653
  text: a,
@@ -2653,14 +2657,14 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
2653
2657
  ])
2654
2658
  }) : void 0
2655
2659
  }));
2656
- if (!h) {
2660
+ if (!c) {
2657
2661
  n(!1);
2658
2662
  return;
2659
2663
  }
2660
2664
  this.wnd.requestAnimationFrame(() => {
2661
- this.doc().scrollTop = h.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
2662
- const c = this.doc().scrollTop / this.doc().offsetHeight;
2663
- this.reportProgress({ progress: c, reference: this.wnd.innerHeight / this.doc().scrollHeight }), T(this.wnd), n(!0);
2665
+ this.doc().scrollTop = c.getBoundingClientRect().top + e.scrollY - e.innerHeight / 2;
2666
+ const h = this.doc().scrollTop / this.doc().offsetHeight;
2667
+ this.reportProgress({ progress: h, reference: this.wnd.innerHeight / this.doc().scrollHeight }), w(this.wnd), n(!0);
2664
2668
  });
2665
2669
  }), t.register("go_start", A.moduleName, (s, n) => {
2666
2670
  if (this.doc().scrollTop === 0)
@@ -2671,7 +2675,7 @@ const Le = "readium-scroll-snapper-style", Qe = class A extends Xe {
2671
2675
  return n(!1);
2672
2676
  this.doc().scrollTop = 0, this.reportProgress({ progress: 0, reference: this.wnd.innerHeight / this.doc().scrollHeight }), n(!0);
2673
2677
  }), t.register("unfocus", A.moduleName, (s, n) => {
2674
- T(this.wnd), n(!0);
2678
+ w(this.wnd), n(!0);
2675
2679
  }), t.register([
2676
2680
  "go_next",
2677
2681
  "go_prev"
@@ -2695,18 +2699,18 @@ class et extends Y {
2695
2699
  super(...arguments), this.pointerMoved = !1, this.onPointerUp = this.onPointUp.bind(this), this.onPointerMove = this.onPointMove.bind(this), this.onPointerDown = this.onPointDown.bind(this), this.onContextMenu = this.onContext.bind(this), this.onClicker = this.onClick.bind(this);
2696
2700
  }
2697
2701
  onPointUp(e) {
2698
- var s, n, o, a, h;
2702
+ var s, n, o, a, c;
2699
2703
  const t = this.wnd.getSelection();
2700
2704
  if (t && ((s = t.toString()) == null ? void 0 : s.length) > 0) {
2701
- const c = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
2702
- if (!c || c.length === 0)
2705
+ const h = (n = t.getRangeAt(0)) == null ? void 0 : n.getClientRects();
2706
+ if (!h || h.length === 0)
2703
2707
  return;
2704
- const d = c[0], p = {
2708
+ const u = h[0], p = {
2705
2709
  text: t.toString(),
2706
- x: d.x,
2707
- y: d.y,
2708
- width: d.width,
2709
- height: d.height,
2710
+ x: u.x,
2711
+ y: u.y,
2712
+ width: u.width,
2713
+ height: u.height,
2710
2714
  targetFrameSrc: (a = (o = this.wnd) == null ? void 0 : o.location) == null ? void 0 : a.href
2711
2715
  };
2712
2716
  this.comms.send("text_selected", p);
@@ -2724,7 +2728,7 @@ class et extends Y {
2724
2728
  y: e.clientY * i,
2725
2729
  targetFrameSrc: this.wnd.location.href,
2726
2730
  targetElement: e.target.outerHTML,
2727
- interactiveElement: (h = Ye(e.target)) == null ? void 0 : h.outerHTML,
2731
+ interactiveElement: (c = Ye(e.target)) == null ? void 0 : c.outerHTML,
2728
2732
  cssSelector: this.wnd._readium_cssSelectorGenerator.getCssSelector(e.target)
2729
2733
  }), this.pointerMoved = !1;
2730
2734
  }
@@ -2815,7 +2819,7 @@ const tt = class te extends Y {
2815
2819
  ), Reflect.defineProperty(e.navigator, "epubReadingSystem", {
2816
2820
  value: {
2817
2821
  name: "readium-ts-toolkit",
2818
- version: "2.0.0-beta.1",
2822
+ version: "2.0.0-beta.2",
2819
2823
  hasFeature: (s, n = "") => {
2820
2824
  switch (s) {
2821
2825
  case "dom-manipulation":
@@ -2879,7 +2883,7 @@ const Re = "readium-viewport", rt = class F extends it {
2879
2883
  ), e.document.head.appendChild(i), e.addEventListener("orientationchange", this.onViewportWidthChanged), e.addEventListener("resize", this.onViewportWidthChanged), this.onViewportWidthChanged({
2880
2884
  target: e
2881
2885
  }), t.register("get_properties", F.moduleName, (s, n) => {
2882
- qe(e), n(!0);
2886
+ Ve(e), n(!0);
2883
2887
  }), t.register("update_properties", F.moduleName, (s, n) => {
2884
2888
  s["--RS__viewportWidth"] = `${e.innerWidth}px`, Nt(e, s), n(!0);
2885
2889
  }), t.register("set_property", F.moduleName, (s, n) => {
@@ -2897,7 +2901,7 @@ const Re = "readium-viewport", rt = class F extends it {
2897
2901
  }
2898
2902
  };
2899
2903
  rt.moduleName = "reflowable_setup";
2900
- let qt = rt;
2904
+ let Vt = rt;
2901
2905
  const ze = "readium-fixed-style", st = class L extends it {
2902
2906
  mount(e, t) {
2903
2907
  if (!super.mount(e, t))
@@ -2922,7 +2926,7 @@ const ze = "readium-fixed-style", st = class L extends it {
2922
2926
  }), t.register("remove_property", L.moduleName, (s, n) => {
2923
2927
  he(e, s), n(!0);
2924
2928
  }), t.register("first_visible_locator", L.moduleName, (s, n) => n(!1)), t.register("unfocus", L.moduleName, (s, n) => {
2925
- T(e), n(!0);
2929
+ w(e), n(!0);
2926
2930
  }), t.register([
2927
2931
  "focus",
2928
2932
  "go_next",
@@ -2942,7 +2946,7 @@ const ze = "readium-fixed-style", st = class L extends it {
2942
2946
  }
2943
2947
  };
2944
2948
  st.moduleName = "fixed_setup";
2945
- let Vt = st;
2949
+ let qt = st;
2946
2950
  const _t = [
2947
2951
  "fixed_setup",
2948
2952
  "decorator",
@@ -2955,8 +2959,8 @@ const _t = [
2955
2959
  "scroll_snapper"
2956
2960
  ], De = new Map([
2957
2961
  // All modules go here
2958
- Vt,
2959
2962
  qt,
2963
+ Vt,
2960
2964
  et,
2961
2965
  Dt,
2962
2966
  $t,