@zinejs/core 0.7.1 → 0.7.3

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
@@ -244,44 +244,33 @@ var _ = class {
244
244
  b: n
245
245
  };
246
246
  }
247
- };
248
- //#endregion
249
- //#region src/geometry/hitTest.ts
250
- function v(e, t, n) {
251
- let { width: r, height: i } = t;
252
- if (e.x < 0 || e.x > r || e.y < 0 || e.y > i) return "outside";
253
- let a = e.x <= n || e.x >= r - n, o = e.y <= n || e.y >= i - n;
254
- return a && o ? "corner" : "page";
247
+ }, v = "page", y = !1;
248
+ function b() {
249
+ return y ? !1 : (y = !0, !0);
255
250
  }
256
- //#endregion
257
- //#region src/engine/deeplink.ts
258
- var y = "page", b = !1;
259
251
  function x() {
260
- return b ? !1 : (b = !0, !0);
261
- }
262
- function S() {
263
- b = !1;
252
+ y = !1;
264
253
  }
265
- function C(e) {
266
- let t = new URLSearchParams(e.replace(/^#/, "")).get(y);
254
+ function S(e) {
255
+ let t = new URLSearchParams(e.replace(/^#/, "")).get(v);
267
256
  if (t === null) return null;
268
257
  let n = Number(t);
269
258
  return Number.isInteger(n) && n >= 1 ? n - 1 : null;
270
259
  }
271
- function w(e, t) {
260
+ function C(e, t) {
272
261
  let n = new URLSearchParams(e.replace(/^#/, ""));
273
- return n.set(y, String(t + 1)), `#${n.toString()}`;
262
+ return n.set(v, String(t + 1)), `#${n.toString()}`;
274
263
  }
275
- function T(e, t) {
264
+ function w(e, t) {
276
265
  let n = null, r = () => {
277
- let r = C(e.location.hash);
266
+ let r = S(e.location.hash);
278
267
  r === null || r === n || (n = r, t(r));
279
268
  };
280
269
  return e.addEventListener("hashchange", r), {
281
270
  push(t) {
282
271
  if (t === n) return;
283
272
  n = t;
284
- let r = w(e.location.hash, t);
273
+ let r = C(e.location.hash, t);
285
274
  r !== e.location.hash && e.history?.replaceState?.(e.history.state, "", r);
286
275
  },
287
276
  stop() {
@@ -291,49 +280,49 @@ function T(e, t) {
291
280
  }
292
281
  //#endregion
293
282
  //#region src/renderer/select.ts
294
- var E = {
283
+ var T = {
295
284
  css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
296
285
  webgl2: async () => new (await (import("./webglRenderer-D_XGumQT.js"))).WebglRenderer()
297
- }, D = !0;
298
- function O(e) {
286
+ }, E = !0;
287
+ function ee(e) {
299
288
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
300
289
  }
301
- function k(e) {
302
- return e.gpu && D ? ["webgl2", "css"] : ["css"];
290
+ function te(e) {
291
+ return e.gpu && E ? ["webgl2", "css"] : ["css"];
303
292
  }
304
- function A() {
305
- return { gpu: j() };
293
+ function D() {
294
+ return { gpu: O() };
306
295
  }
307
- function j() {
296
+ function O() {
308
297
  try {
309
298
  return !!document.createElement("canvas").getContext("webgl2");
310
299
  } catch {
311
300
  return !1;
312
301
  }
313
302
  }
314
- async function M(e = "auto", t = A()) {
315
- if (O(e)) return e;
316
- let n = Array.isArray(e) ? e : e === "auto" ? k(t) : [e];
303
+ async function k(e = "auto", t = D()) {
304
+ if (ee(e)) return e;
305
+ let n = Array.isArray(e) ? e : e === "auto" ? te(t) : [e];
317
306
  for (let e of n) {
318
307
  if (e === "webgl2" && !t.gpu) continue;
319
- let n = E[e];
308
+ let n = T[e];
320
309
  if (n) return n();
321
310
  }
322
311
  throw n.length === 1 && n[0] === "webgl2" && !t.gpu ? Error("renderer: 'webgl2' was forced but this device has no WebGL2. Use 'css' or 'auto'.") : Error(`renderer: none of [${n.join(", ")}] could be loaded — use 'css' or 'auto'.`);
323
312
  }
324
313
  //#endregion
325
314
  //#region src/source/compose.ts
326
- function N(e, t) {
315
+ function A(e, t) {
327
316
  let n = typeof t.frontCover == "string", r = typeof t.backCover == "string", i = t.pages != null && Object.keys(t.pages).length > 0;
328
- return !n && !r && !i ? e : new F(e, t);
317
+ return !n && !r && !i ? e : new M(e, t);
329
318
  }
330
- function P(e) {
319
+ function j(e) {
331
320
  return fetch(e).then((t) => {
332
321
  if (!t.ok) throw Error(`zine: could not load image "${e}" (HTTP ${t.status}).`);
333
322
  return t.blob();
334
323
  }).then((e) => createImageBitmap(e));
335
324
  }
336
- var F = class {
325
+ var M = class {
337
326
  #e;
338
327
  #t;
339
328
  #n;
@@ -401,16 +390,16 @@ var F = class {
401
390
  }
402
391
  #s(e) {
403
392
  let t = this.#a.get(e);
404
- return t === void 0 && (t = P(e).catch((t) => {
393
+ return t === void 0 && (t = j(e).catch((t) => {
405
394
  throw this.#a.delete(e), t;
406
395
  }), this.#a.set(e, t)), t;
407
396
  }
408
- }, I = .25, L = .0015, R = 6, z = 250, B = 1.55, V = 32, H = 60, U = 2.5, W = 120;
409
- function G(e, t, n) {
410
- let r = Math.max(0, t - V), i = Math.min(e.length, t + n + V), a = e.slice(r, i).replace(/\s+/g, " ").trim();
397
+ }, N = .25, P = .0015, F = 6, I = 250, L = 24, R = 2 * I, z = 1.55, B = 32, V = 60, H = 2.5, U = 1.5, W = 120, G = .85, K = .72;
398
+ function q(e, t, n) {
399
+ let r = Math.max(0, t - B), i = Math.min(e.length, t + n + B), a = e.slice(r, i).replace(/\s+/g, " ").trim();
411
400
  return `${r > 0 ? "…" : ""}${a}${i < e.length ? "…" : ""}`;
412
401
  }
413
- var K = class {
402
+ var J = class {
414
403
  #e;
415
404
  #t;
416
405
  #n = new l();
@@ -474,25 +463,27 @@ var K = class {
474
463
  #re = null;
475
464
  #ie = null;
476
465
  #ae = null;
477
- #oe = null;
478
- #se = /* @__PURE__ */ new Set();
479
- #ce;
480
- #le = null;
481
- #ue = 1;
482
- #de = 0;
483
- #fe = null;
484
- #pe;
466
+ #oe = -Infinity;
467
+ #se = null;
468
+ #ce = null;
469
+ #le = /* @__PURE__ */ new Set();
470
+ #ue;
471
+ #de = null;
472
+ #fe = 1;
473
+ #pe = 0;
474
+ #me = null;
475
+ #he;
485
476
  debug = { setFlipProgress: (e, t) => {
486
477
  this.#z?.setFlipProgress(e, t);
487
478
  } };
488
479
  constructor(e, t) {
489
- Q(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = N(t.source, {
480
+ re(e, t), this.#e = e, t.width !== void 0 && (e.style.width = `${t.width}px`), t.height !== void 0 && (e.style.height = `${t.height}px`), this.#t = A(t.source, {
490
481
  frontCover: t.frontCover,
491
482
  backCover: t.backCover,
492
483
  pages: t.pages
493
484
  });
494
485
  let n = t.direction ?? "ltr";
495
- this.#a = n, this.#x = (t.deepLink ?? !0) && x(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ce = t.controls ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#ht(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
486
+ this.#a = n, this.#x = (t.deepLink ?? !0) && b(), this.#S = t.disableContextMenu ?? !1, this.#o = t.spreadMode ?? "cover", this.#s = this.#o, this.#c = t.curl ?? "cone", this.#u = t.clickToFlip ?? "edge", this.#d = t.clickZoneSize ?? 64, this.#m = t.singlePageThreshold ?? 640, this.#v = t.responsiveSpread ?? !0, this.#ue = t.controls ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#xt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
496
487
  let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
497
488
  1,
498
489
  2,
@@ -500,10 +491,10 @@ var K = class {
500
491
  ]].sort((e, t) => e - t);
501
492
  this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
502
493
  let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
503
- this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? z : 0, this.#pe = this.#Ve(t.renderer ?? "auto");
494
+ this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#he = this.#Ke(t.renderer ?? "auto");
504
495
  }
505
496
  get ready() {
506
- return this.#pe;
497
+ return this.#he;
507
498
  }
508
499
  getPageCount() {
509
500
  return this.#t.pageCount;
@@ -530,7 +521,7 @@ var K = class {
530
521
  return this.#h;
531
522
  }
532
523
  setSpreadMode(e) {
533
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#et(), this.#tt());
524
+ e !== this.#o && (this.#o = e, this.#_ = !1, this.#at(), this.#ot());
534
525
  }
535
526
  toggleSpreadMode() {
536
527
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
@@ -546,16 +537,16 @@ var K = class {
546
537
  if (this.#v = e, e) {
547
538
  let e = this.#z?.measure().containerWidth;
548
539
  if (e === void 0) return;
549
- this.#_ = !1, this.#$e(e);
540
+ this.#_ = !1, this.#it(e);
550
541
  } else {
551
542
  if (!this.#_) return;
552
- this.#_ = !1, this.#et();
543
+ this.#_ = !1, this.#at();
553
544
  }
554
- this.#tt();
545
+ this.#ot();
555
546
  }
556
547
  }
557
548
  getPageImage(e) {
558
- return this.#ft(e);
549
+ return this.#vt(e);
559
550
  }
560
551
  canFlipNext() {
561
552
  return this.#E + 1 < this.#T.length;
@@ -603,11 +594,11 @@ var K = class {
603
594
  return typeof this.#t.getOutline == "function";
604
595
  }
605
596
  getOutline() {
606
- if (!this.#oe) {
597
+ if (!this.#ce) {
607
598
  let e = this.#t.getOutline;
608
- this.#oe = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
599
+ this.#ce = typeof e == "function" ? Promise.resolve(e.call(this.#t)).catch(() => []) : Promise.resolve([]);
609
600
  }
610
- return this.#oe;
601
+ return this.#ce;
611
602
  }
612
603
  async getSourceFile() {
613
604
  let e = this.#t.getDownload;
@@ -639,35 +630,35 @@ var K = class {
639
630
  let i = t.toLowerCase().indexOf(r);
640
631
  i < 0 || a.push({
641
632
  page: e,
642
- excerpt: G(t, i, r.length)
633
+ excerpt: q(t, i, r.length)
643
634
  });
644
635
  }
645
636
  return a;
646
637
  }
647
638
  flipNext() {
648
- this.#me(1);
639
+ this.#ge(1);
649
640
  }
650
641
  flipPrev() {
651
- this.#me(-1);
642
+ this.#ge(-1);
652
643
  }
653
- #me(e) {
654
- this.#he(() => this.#ye(this.#E + e));
644
+ #ge(e) {
645
+ this.#_e(() => this.#xe(this.#E + e));
655
646
  }
656
647
  flipTo(e) {
657
- let t = q(e, 0, Math.max(0, this.#t.pageCount - 1));
658
- this.#he(() => this.#ye(this.#mt(t)));
648
+ let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
649
+ this.#_e(() => this.#xe(this.#bt(t)));
659
650
  }
660
- #he(e) {
661
- this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#ge(), e()) : this.#q = e;
651
+ #_e(e) {
652
+ this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#ve(), e()) : this.#q = e;
662
653
  }
663
- #ge() {
654
+ #ve() {
664
655
  let e = this.#J;
665
656
  e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
666
657
  }
667
- #_e() {
658
+ #ye() {
668
659
  let e = this.#q;
669
660
  if (!e) {
670
- this.#ct();
661
+ this.#mt();
671
662
  return;
672
663
  }
673
664
  this.#q = null, e();
@@ -677,84 +668,87 @@ var K = class {
677
668
  }
678
669
  setZoom(e, t) {
679
670
  if (!this.#z || !this.#A) return;
680
- let n = q(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
671
+ let n = Y(e, 1, this.#N), r = this.#z.measure(), i = r.screenAt?.(this.#I), a = t ?? (i ? {
681
672
  x: i.x + this.#L + i.width / 2,
682
673
  y: i.y + this.#R + i.height / 2
683
674
  } : null) ?? {
684
675
  x: r.containerWidth / 2,
685
676
  y: r.containerHeight / 2
686
677
  }, o = this.#I, s = n === 1 ? 0 : a.x - n / o * (a.x - this.#L), c = n === 1 ? 0 : a.y - n / o * (a.y - this.#R);
687
- [s, c] = this.#ve(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), this.#at(), this.#n.emit("zoomChanged", { scale: n });
678
+ [s, c] = this.#be(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), this.#ut(), this.#n.emit("zoomChanged", { scale: n });
688
679
  }
689
680
  resetZoom() {
690
681
  this.setZoom(1);
691
682
  }
692
- #ve(e, t, n, r, i) {
683
+ #be(e, t, n, r, i) {
693
684
  let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
694
685
  x: 0,
695
686
  y: 0,
696
687
  width: r * n,
697
688
  height: i * n
698
- }, [c, l] = J(s.x, s.width, r), [u, d] = J(s.y, s.height, i);
699
- return [o(q(e, c, l)), o(q(t, u, d))];
689
+ }, [c, l] = X(s.x, s.width, r), [u, d] = X(s.y, s.height, i);
690
+ return [o(Y(e, c, l)), o(Y(t, u, d))];
700
691
  }
701
692
  on(e, t) {
702
693
  return this.#n.on(e, t);
703
694
  }
704
695
  destroy() {
705
- this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ne(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && S(), this.#le?.(), this.#ae?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#fe !== null && clearTimeout(this.#fe), this.#de++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
696
+ this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Le(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#se?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#me !== null && clearTimeout(this.#me), this.#pe++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
706
697
  }
707
- #ye(e) {
698
+ #xe(e) {
708
699
  if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
709
- let t = e > this.#E ? "forward" : "backward", n = this.#Ce(e);
700
+ let t = e > this.#E ? "forward" : "backward", n = this.#Ee(e);
710
701
  this.#n.emit("flipStart", {
711
702
  from: this.#D,
712
703
  to: n
713
- }), this.#be(e, t, n, ++this.#Y);
704
+ }), this.#Se(e, t, n, ++this.#Y);
714
705
  }
715
- async #be(e, t, n, r) {
716
- let i = this.#T[e], a = i ? await this.#dt(i) : {
706
+ async #Se(e, t, n, r) {
707
+ let i = this.#T[e], a = i ? await this.#_t(i) : {
717
708
  left: null,
718
709
  right: null
719
710
  };
720
711
  r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
721
712
  fill: this.#h,
722
- curl: this.#Ze(),
713
+ curl: this.#nt(),
723
714
  anchor: { y: this.#l }
724
- }), this.#xe(0, 1, t, () => this.#Se(e, n, a)));
715
+ }), this.#Ce(0, 1, t, () => this.#Te(e, n, a), () => this.#we(n)));
725
716
  }
726
- #xe(e, t, n, r) {
727
- let i = this.#Xe() * Math.abs(t - e);
728
- if (i <= 0) {
717
+ #Ce(e, t, n, r, i) {
718
+ let a = this.#tt() * Math.abs(t - e);
719
+ if (a <= 0) {
729
720
  this.#z?.setFlipProgress(t, n), r();
730
721
  return;
731
722
  }
732
- let a = {
723
+ let o = {
733
724
  toT: t,
734
725
  direction: n,
735
726
  onDone: r
736
727
  };
737
- this.#J = a;
738
- let o = performance.now(), s = (c) => {
739
- if (this.#J !== a) return;
740
- let l = Math.min(1, (c - o) / i), u = this.#h ? X(l) : Y(l);
741
- this.#z?.setFlipProgress(e + (t - e) * u, n), l < 1 ? this.#H = requestAnimationFrame(s) : (this.#H = null, this.#J = null, r());
728
+ this.#J = o;
729
+ let s = performance.now(), c = !1, l = (u) => {
730
+ if (this.#J !== o) return;
731
+ let d = Math.min(1, (u - s) / a), f = this.#h ? ne(d) : Z(d);
732
+ i && !c && f >= (this.#h ? K : G) && (c = !0, i()), d < 1 ? (this.#z?.setFlipProgress(e + (t - e) * f, n), this.#H = requestAnimationFrame(l)) : (this.#z?.setFlipProgress(t, n), this.#H = null, this.#J = null, r());
742
733
  };
743
- this.#H = requestAnimationFrame(s);
734
+ this.#H = requestAnimationFrame(l);
735
+ }
736
+ #we(e) {
737
+ this.#D !== e && (this.#D = e, this.#et(), this.#n.emit("pageChanged", { page: e }));
744
738
  }
745
- #Se(e, t, n) {
739
+ #Te(e, t, n) {
746
740
  let r = this.#T[e];
747
- this.#E = e, this.#D = t, this.#O = n, r && this.#nt(r, n), this.#pt(), this.#i.send("settle"), this.#Ye(), this.#n.emit("pageChanged", { page: t }), this.#n.emit("flipEnd", { page: t }), this.#_e();
741
+ this.#E = e, this.#O = n, r && this.#st(r, n), this.#yt(), this.#i.send("settle"), this.#oe = performance.now(), this.#we(t), this.#n.emit("flipEnd", { page: t }), this.#ye();
748
742
  }
749
- #Ce(e) {
743
+ #Ee(e) {
750
744
  let t = this.#T[e];
751
745
  if (!t) return this.#D;
752
746
  let n = [t.left, t.right].filter((e) => e !== null);
753
747
  return n.length > 0 ? Math.min(...n) : this.#D;
754
748
  }
755
- #we(e, t) {
749
+ #De(e, t) {
756
750
  if (this.#Z || !this.#z) return;
757
- if (this.#Ne(), this.#I > 1) {
751
+ if (this.#Le(), this.#I > 1) {
758
752
  if (this.#i.send("panStart") === null) return;
759
753
  this.#X = {
760
754
  baseTx: this.#L,
@@ -762,26 +756,27 @@ var K = class {
762
756
  };
763
757
  return;
764
758
  }
765
- let n = this.#Ae(), r = this.#je(e, t);
766
- if (this.#G = r, this.#i.state !== "idle") {
767
- this.#W = null;
768
- return;
759
+ let n = this.#Ne(), r = this.#Pe(e, t);
760
+ this.#G = r;
761
+ let i = Math.min(n.width, n.height) * N, a = r.x >= 0 && r.x <= n.width && r.y >= 0 && r.y <= n.height, o = r.x <= i || r.x >= n.width - i, s = a && o;
762
+ if (this.#i.state !== "idle") {
763
+ if (!this.#J || !s) {
764
+ this.#W = null;
765
+ return;
766
+ }
767
+ this.#ve();
769
768
  }
770
- let i = Math.min(n.width, n.height) * I;
771
- if (v(r, {
772
- width: n.width,
773
- height: n.height
774
- }, i) !== "corner") return;
775
- this.#l = q(r.y / n.height, 0, 1);
776
- let a = r.x > n.width / 2, o = this.#a === "rtl" ? !a : a, s = this.#E + (o ? 1 : -1);
777
- s < 0 || s >= this.#T.length || (this.#W = {
778
- direction: o ? "forward" : "backward",
779
- targetIndex: s,
780
- toPage: this.#Ce(s),
769
+ if (!s) return;
770
+ this.#l = Y(r.y / n.height, 0, 1);
771
+ let c = r.x > n.width / 2, l = this.#a === "rtl" ? !c : c, u = this.#E + (l ? 1 : -1);
772
+ u < 0 || u >= this.#T.length || (this.#W = {
773
+ direction: l ? "forward" : "backward",
774
+ targetIndex: u,
775
+ toPage: this.#Ee(u),
781
776
  width: n.width
782
777
  });
783
778
  }
784
- #Te() {
779
+ #Oe() {
785
780
  let e = this.#W;
786
781
  e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
787
782
  direction: e.direction,
@@ -796,32 +791,32 @@ var K = class {
796
791
  }, this.#n.emit("flipStart", {
797
792
  from: this.#D,
798
793
  to: e.toPage
799
- }), this.#Ee(e.targetIndex, e.direction)));
794
+ }), this.#ke(e.targetIndex, e.direction)));
800
795
  }
801
- async #Ee(e, t) {
802
- let n = this.#T[e], r = n ? await this.#dt(n) : {
796
+ async #ke(e, t) {
797
+ let n = this.#T[e], r = n ? await this.#_t(n) : {
803
798
  left: null,
804
799
  right: null
805
800
  };
806
801
  this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
807
802
  fill: this.#h,
808
- curl: this.#Ze(),
803
+ curl: this.#nt(),
809
804
  anchor: { y: this.#l }
810
805
  }), this.#z?.setFlipProgress(this.#U.t, t));
811
806
  }
812
- #De(e, t) {
807
+ #Ae(e, t) {
813
808
  if (this.#Z) return;
814
809
  if (this.#X) {
815
810
  if (!this.#z) return;
816
- let n = this.#z.measure(), [r, i] = this.#ve(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
817
- this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#at();
811
+ let n = this.#z.measure(), [r, i] = this.#be(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
812
+ this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#ut();
818
813
  return;
819
814
  }
820
- this.#W && Math.hypot(e, t) > R && this.#Te();
815
+ this.#W && Math.hypot(e, t) > F && this.#Oe();
821
816
  let n = this.#U;
822
- n && (n.t = q((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
817
+ n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
823
818
  }
824
- #Oe(e) {
819
+ #je(e) {
825
820
  if (this.#Z) return;
826
821
  if (this.#X) {
827
822
  this.#X = null, this.#i.send("panEnd");
@@ -829,30 +824,28 @@ var K = class {
829
824
  }
830
825
  let t = this.#U;
831
826
  if (!t) {
832
- this.#W = null, this.#ke(e);
827
+ this.#W = null, this.#Me(e);
833
828
  return;
834
829
  }
835
830
  this.#U = null, this.#i.send("release");
836
831
  let n = e.swipe && (t.direction === "forward" ? e.dx < 0 : e.dx > 0);
837
- t.t >= .5 || n ? this.#xe(t.t, 1, t.direction, () => this.#Se(t.targetIndex, t.toPage, t.toContent)) : this.#xe(t.t, 0, t.direction, () => this.#Pe());
838
- }
839
- #ke(e) {
840
- if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > R || Math.abs(e.dy) > R) return;
841
- let t = this.#Me(this.#G);
842
- if (!t) return;
843
- let n = t === "forward" ? 1 : -1;
844
- if (this.#E + n < 0 || this.#E + n >= this.#T.length) return;
845
- this.#l = q(this.#G.y / this.#Ae().height, 0, 1);
846
- let r = () => this.#ye(this.#E + n);
847
- if (this.#Ne(), this.#p <= 0) {
848
- this.#he(r);
832
+ t.t >= .5 || n ? this.#Ce(t.t, 1, t.direction, () => this.#Te(t.targetIndex, t.toPage, t.toContent), () => this.#we(t.toPage)) : this.#Ce(t.t, 0, t.direction, () => this.#Re());
833
+ }
834
+ #Me(e) {
835
+ if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
836
+ let t = this.#Fe(this.#G);
837
+ if (!t || !this.#Ie(t)) return;
838
+ this.#l = Y(this.#G.y / this.#Ne().height, 0, 1);
839
+ let n = t === "forward" ? 1 : -1, r = () => this.#xe(this.#E + n);
840
+ if (this.#Le(), this.#p <= 0) {
841
+ this.#_e(r);
849
842
  return;
850
843
  }
851
844
  this.#K = setTimeout(() => {
852
- this.#K = null, this.#he(r);
845
+ this.#K = null, this.#_e(r);
853
846
  }, this.#p);
854
847
  }
855
- #Ae() {
848
+ #Ne() {
856
849
  let e = this.#z.measure();
857
850
  return e.content ?? e.book ?? {
858
851
  x: 0,
@@ -861,36 +854,40 @@ var K = class {
861
854
  height: e.containerHeight
862
855
  };
863
856
  }
864
- #je(e, t) {
865
- let n = this.#e.getBoundingClientRect(), r = this.#Ae();
857
+ #Pe(e, t) {
858
+ let n = this.#e.getBoundingClientRect(), r = this.#Ne();
866
859
  return {
867
860
  x: e - n.left - r.x,
868
861
  y: t - n.top - r.y
869
862
  };
870
863
  }
871
- #Me(e) {
864
+ #Fe(e) {
872
865
  if (!this.#z) return null;
873
- let t = this.#Ae().width, n;
866
+ let t = this.#Ne().width, n;
874
867
  if (n = this.#u === "half" ? e.x > t / 2 ? "right" : "left" : e.x <= this.#d ? "left" : e.x >= t - this.#d ? "right" : null, !n) return null;
875
868
  let r = this.#a === "rtl" ? "left" : "right";
876
869
  return n === r ? "forward" : "backward";
877
870
  }
878
- #Ne() {
871
+ #Ie(e) {
872
+ let t = this.#E + (e === "forward" ? 1 : -1);
873
+ return t >= 0 && t < this.#T.length;
874
+ }
875
+ #Le() {
879
876
  this.#K !== null && (clearTimeout(this.#K), this.#K = null);
880
877
  }
881
- #Pe() {
878
+ #Re() {
882
879
  let e = this.#T[this.#E];
883
- e && this.#nt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#_e();
880
+ e && this.#st(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#ye();
884
881
  }
885
- #Fe() {
886
- if (this.#W = null, this.#Ne(), this.#U) {
882
+ #ze() {
883
+ if (this.#W = null, this.#Le(), this.#U) {
887
884
  this.#U = null, this.#i.send("release"), this.#i.send("settle");
888
885
  let e = this.#T[this.#E];
889
- e && this.#nt(e, this.#O);
886
+ e && this.#st(e, this.#O);
890
887
  } else this.#X && (this.#X = null, this.#i.send("panEnd"));
891
888
  this.#Z = !0, this.#Q = this.#I;
892
889
  }
893
- #Ie(e, t, n) {
890
+ #Be(e, t, n) {
894
891
  if (!this.#Z) return;
895
892
  let r = this.#e.getBoundingClientRect();
896
893
  this.setZoom(this.#Q * n, {
@@ -898,19 +895,19 @@ var K = class {
898
895
  y: t - r.top
899
896
  });
900
897
  }
901
- #Le() {
898
+ #Ve() {
902
899
  this.#Z = !1;
903
900
  }
904
- #Re() {
901
+ #He() {
905
902
  if (!this.#S) return;
906
903
  let e = (e) => e.preventDefault();
907
904
  this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
908
905
  }
909
- #ze() {
906
+ #Ue() {
910
907
  let e = (e) => {
911
908
  if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
912
909
  e.preventDefault();
913
- let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * L);
910
+ let t = this.#e.getBoundingClientRect(), n = Math.exp(-e.deltaY * P);
914
911
  this.setZoom(this.#I * n, {
915
912
  x: e.clientX - t.left,
916
913
  y: e.clientY - t.top
@@ -918,90 +915,102 @@ var K = class {
918
915
  };
919
916
  this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
920
917
  }
921
- #Be() {
918
+ #We() {
922
919
  let e = (e) => {
923
920
  let t = this.#M;
924
921
  if (!this.#A || t === null || !this.#z) return;
925
- if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
926
- let t = this.#je(e.clientX, e.clientY);
927
- if (this.#Me(t) !== null) return;
922
+ let n = performance.now(), r = this.#ae;
923
+ if (!(r !== null && n - r.t <= I && Math.hypot(e.clientX - r.x, e.clientY - r.y) <= L)) {
924
+ this.#ae = {
925
+ t: n,
926
+ x: e.clientX,
927
+ y: e.clientY
928
+ };
929
+ return;
928
930
  }
929
- this.#Ne(), e.preventDefault();
930
- let n = t.find((e) => e > this.#I + 1e-6) ?? t[0] ?? this.#I, r = this.#e.getBoundingClientRect();
931
- this.setZoom(n, {
932
- x: e.clientX - r.left,
933
- y: e.clientY - r.top
934
- });
931
+ this.#ae = null, this.#Ge(e.clientX, e.clientY, t);
935
932
  };
936
- this.#e.addEventListener("dblclick", e), this.#ie = () => this.#e.removeEventListener("dblclick", e);
933
+ this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
934
+ }
935
+ #Ge(e, t, n) {
936
+ if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
937
+ let n = this.#Pe(e, t), r = this.#Fe(n);
938
+ if (r !== null && (this.#Ie(r) || performance.now() - this.#oe <= R)) return;
939
+ }
940
+ this.#Le();
941
+ let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
942
+ this.setZoom(r, {
943
+ x: e - i.left,
944
+ y: t - i.top
945
+ });
937
946
  }
938
- async #Ve(e) {
939
- let t = M(e);
940
- typeof this.#t.open == "function" && (await this.#t.open(), this.#ht()), this.#t.prefetch([this.#D]);
941
- let n = await t, r = await this.#He(n);
942
- this.#z = r, this.#t.onPageUpdate?.((e) => this.#it(e)), this.#$e(r.measure().containerWidth);
947
+ async #Ke(e) {
948
+ let t = k(e);
949
+ typeof this.#t.open == "function" && (await this.#t.open(), this.#xt()), this.#t.prefetch([this.#D]);
950
+ let n = await t, r = await this.#qe(n);
951
+ this.#z = r, this.#t.onPageUpdate?.((e) => this.#lt(e)), this.#it(r.measure().containerWidth);
943
952
  let i = new m({
944
- onStart: (e) => this.#we(e.x, e.y),
945
- onMove: (e) => this.#De(e.dx, e.dy),
946
- onEnd: (e) => this.#Oe(e)
953
+ onStart: (e) => this.#De(e.x, e.y),
954
+ onMove: (e) => this.#Ae(e.dx, e.dy),
955
+ onEnd: (e) => this.#je(e)
947
956
  }), a = new _({
948
- onPinchStart: () => this.#Fe(),
949
- onPinchMove: (e) => this.#Ie(e.centerX, e.centerY, e.scale),
950
- onPinchEnd: () => this.#Le()
957
+ onPinchStart: () => this.#ze(),
958
+ onPinchMove: (e) => this.#Be(e.centerX, e.centerY, e.scale),
959
+ onPinchEnd: () => this.#Ve()
951
960
  });
952
961
  this.#te = h(this.#e, {
953
962
  pointer: i,
954
963
  pinch: a
955
- }), this.#ze(), this.#Be(), this.#Re(), this.#We(), this.#ae = this.#qe(), await this.#tt(), this.#lt(), this.#pt(), this.#Ye(), this.#Ke(), await this.#Ge(), this.#n.emit("ready");
964
+ }), this.#Ue(), this.#We(), this.#He(), this.#Ye(), this.#se = this.#Qe(), await this.#ot(), this.#ht(), this.#yt(), this.#et(), this.#Ze(), await this.#Xe(), this.#n.emit("ready");
956
965
  }
957
- async #He(e) {
966
+ async #qe(e) {
958
967
  try {
959
968
  return await e.mount(this.#e), e.onFatal?.(() => {
960
- this.#Ue();
969
+ this.#Je();
961
970
  }), e;
962
971
  } catch {
963
972
  e.destroy();
964
- let t = await M("css");
973
+ let t = await k("css");
965
974
  return await t.mount(this.#e), this.#B = !0, this.#n.emit("rendererFallback", {
966
975
  from: "webgl2",
967
976
  to: "css"
968
977
  }), t;
969
978
  }
970
979
  }
971
- async #Ue() {
980
+ async #Je() {
972
981
  if (this.#B || this.#V) return;
973
982
  this.#B = !0, this.#z?.destroy(), this.#z = null;
974
- let e = await M("css");
983
+ let e = await k("css");
975
984
  if (this.#V) {
976
985
  e.destroy();
977
986
  return;
978
987
  }
979
- await e.mount(this.#e), this.#z = e, this.#$e(e.measure().containerWidth), await this.#tt(), this.#n.emit("rendererFallback", {
988
+ await e.mount(this.#e), this.#z = e, this.#it(e.measure().containerWidth), await this.#ot(), this.#n.emit("rendererFallback", {
980
989
  from: "webgl2",
981
990
  to: "css"
982
991
  });
983
992
  }
984
- #We() {
993
+ #Ye() {
985
994
  if (typeof matchMedia != "function") return;
986
995
  let e = matchMedia("(prefers-reduced-motion: reduce)");
987
996
  this.#$ = e.matches, e.addEventListener?.("change", (e) => {
988
997
  this.#$ = e.matches;
989
998
  });
990
999
  }
991
- async #Ge() {
992
- if (this.#ce === !1 || this.#V) return;
1000
+ async #Xe() {
1001
+ if (this.#ue === !1 || this.#V) return;
993
1002
  let e = this.#e;
994
1003
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
995
- let { mountControls: t } = await import("./controls-BrPo8pKL.js");
1004
+ let { mountControls: t } = await import("./controls-Bj72hxVJ.js");
996
1005
  if (this.#V) return;
997
- let n = this.#ce === !0 ? {} : this.#ce;
998
- this.#le = t(this, e, n);
1006
+ let n = this.#ue === !0 ? {} : this.#ue;
1007
+ this.#de = t(this, e, n);
999
1008
  } catch {}
1000
1009
  }
1001
- #Ke() {
1010
+ #Ze() {
1002
1011
  if (!this.#x || globalThis.location === void 0) return;
1003
1012
  let e = globalThis;
1004
- this.#C = T(e, (e) => {
1013
+ this.#C = w(e, (e) => {
1005
1014
  e !== this.#D && this.flipTo(e);
1006
1015
  }), this.#C.push(this.#D), this.#w = this.#n.on("pageChanged", ({ page: e }) => {
1007
1016
  this.#C?.push(e);
@@ -1011,20 +1020,20 @@ var K = class {
1011
1020
  let t = globalThis.location?.href ?? "";
1012
1021
  if (!t) return "";
1013
1022
  let n = new URL(t);
1014
- return n.hash = w(n.hash, q(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1023
+ return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1015
1024
  }
1016
- #qe() {
1025
+ #Qe() {
1017
1026
  let e = this.#e, t = e.ownerDocument;
1018
1027
  if (!t || typeof e.setAttribute != "function") return null;
1019
1028
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
1020
- let n = (e) => this.#Je(e);
1029
+ let n = (e) => this.#$e(e);
1021
1030
  e.addEventListener("keydown", n);
1022
1031
  let r = t.createElement("div");
1023
1032
  return r.setAttribute("aria-live", "polite"), r.setAttribute("aria-atomic", "true"), r.style.cssText = "position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;", e.appendChild(r), this.#ee = r, () => {
1024
1033
  e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
1025
1034
  };
1026
1035
  }
1027
- #Je(e) {
1036
+ #$e(e) {
1028
1037
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
1029
1038
  switch (e.key) {
1030
1039
  case "ArrowRight":
@@ -1040,78 +1049,92 @@ var K = class {
1040
1049
  default: break;
1041
1050
  }
1042
1051
  }
1043
- #Ye() {
1052
+ #et() {
1044
1053
  this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1045
1054
  }
1046
- #Xe() {
1047
- return this.#$ ? W : this.#k * (this.#h ? B : 1);
1055
+ #tt() {
1056
+ return this.#$ ? W : this.#k * (this.#h ? z : 1);
1048
1057
  }
1049
- #Ze() {
1058
+ #nt() {
1050
1059
  return this.#$ ? "simple" : this.#c;
1051
1060
  }
1052
1061
  update() {
1053
- !this.#z || this.#i.state !== "idle" || (this.#$e(this.#z.measure().containerWidth), this.#tt());
1062
+ !this.#z || this.#i.state !== "idle" || (this.#it(this.#z.measure().containerWidth), this.#ot());
1054
1063
  }
1055
- #Qe() {
1064
+ #rt() {
1056
1065
  return this.#_ || this.#o === "single" ? "single" : this.#o;
1057
1066
  }
1058
- #$e(e) {
1067
+ #it(e) {
1059
1068
  let t = this.#v && o(e, this.#m);
1060
- t !== this.#_ && (this.#_ = t, this.#et());
1069
+ t !== this.#_ && (this.#_ = t, this.#at());
1061
1070
  }
1062
- #et() {
1063
- let e = this.#Qe(), t = e !== this.#g;
1071
+ #at() {
1072
+ let e = this.#rt(), t = e !== this.#g;
1064
1073
  this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1065
1074
  direction: this.#a,
1066
1075
  mode: e
1067
- }), this.#E = this.#mt(this.#D), t && this.#n.emit("spreadChanged", {
1076
+ }), this.#E = this.#bt(this.#D), t && this.#n.emit("spreadChanged", {
1068
1077
  mode: e,
1069
1078
  singlePage: this.#h
1070
1079
  });
1071
1080
  }
1072
- async #tt() {
1081
+ async #ot() {
1073
1082
  let e = this.#T[this.#E];
1074
- !e || !this.#z || (this.#O = await this.#dt(e), this.#nt(e, this.#O));
1083
+ !e || !this.#z || (this.#O = await this.#_t(e), this.#st(e, this.#O));
1075
1084
  }
1076
- #nt(e, t) {
1077
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#rt(), this.#ue = 1, this.#at();
1085
+ #st(e, t) {
1086
+ this.#z?.renderSpread(e, t, { fill: this.#h }), this.#ct(), this.#fe = 1, this.#ut();
1078
1087
  }
1079
- #rt() {
1088
+ #ct() {
1080
1089
  let e = this.#z?.measure().book;
1081
1090
  if (!e || e.width <= 0 || e.height <= 0) return;
1082
1091
  let t = (e.width / e.height).toFixed(4);
1083
1092
  t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1084
1093
  }
1085
- #it(e) {
1094
+ #lt(e) {
1086
1095
  if (this.#i.state !== "idle") {
1087
- this.#se.add(e);
1096
+ this.#le.add(e);
1088
1097
  return;
1089
1098
  }
1090
1099
  let t = this.#T[this.#E];
1091
- t && (t.left === e || t.right === e) && this.#tt();
1100
+ t && (t.left === e || t.right === e) && this.#ot();
1092
1101
  }
1093
- #at() {
1094
- this.#fe !== null && clearTimeout(this.#fe);
1095
- let e = this.#ot();
1096
- if (e !== this.#ue) {
1102
+ #ut() {
1103
+ this.#me !== null && clearTimeout(this.#me);
1104
+ let e = this.#ft();
1105
+ if (e !== this.#fe) {
1097
1106
  if (e === 1) {
1098
- this.#de++, this.#ue = 1, this.#tt();
1107
+ this.#pe++, this.#fe = 1, this.#ot();
1099
1108
  return;
1100
1109
  }
1101
- this.#fe = setTimeout(() => {
1102
- this.#fe = null, this.#st();
1103
- }, H);
1110
+ this.#me = setTimeout(() => {
1111
+ this.#me = null, this.#pt();
1112
+ }, V);
1113
+ }
1114
+ }
1115
+ #dt() {
1116
+ let e = this.#z?.measure(), t = e?.content ?? e?.book;
1117
+ if (!t || t.width <= 0) return 1;
1118
+ let n = this.#O, r = +!!n.left + +!!n.right;
1119
+ if (r === 0) return 1;
1120
+ let i = t.width / r, a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = 0;
1121
+ for (let e of [n.left, n.right]) {
1122
+ if (!e || e.width <= 0) continue;
1123
+ let t = e.width / this.#fe;
1124
+ o = Math.max(o, i * a / t);
1104
1125
  }
1126
+ return o === 0 ? 1 : o;
1105
1127
  }
1106
- #ot() {
1107
- return this.#I <= 1 ? 1 : Math.min(Math.ceil(this.#I * 2) / 2, U);
1128
+ #ft() {
1129
+ let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#dt() * Math.max(t, e);
1130
+ return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
1108
1131
  }
1109
- async #st() {
1132
+ async #pt() {
1110
1133
  let e = this.#T[this.#E];
1111
1134
  if (!this.#z || !e) return;
1112
- let t = this.#ot();
1113
- if (t === 1 || t === this.#ue) return;
1114
- let n = ++this.#de, r = {
1135
+ let t = this.#ft();
1136
+ if (t === 1 || t === this.#fe || this.#i.state !== "idle") return;
1137
+ let n = ++this.#pe, r = {
1115
1138
  x: 0,
1116
1139
  y: 0,
1117
1140
  width: 1,
@@ -1130,34 +1153,34 @@ var K = class {
1130
1153
  }), null;
1131
1154
  }
1132
1155
  }));
1133
- if (n !== this.#de || this.#ot() !== t) return;
1156
+ if (n !== this.#pe || this.#ft() !== t || this.#i.state !== "idle") return;
1134
1157
  let a = i[0] ?? null, o = i[1] ?? null;
1135
- a === this.#O.left && o === this.#O.right || (this.#ue = t, this.#O = {
1158
+ a === this.#O.left && o === this.#O.right || (this.#fe = t, this.#O = {
1136
1159
  left: a,
1137
1160
  right: o
1138
1161
  }, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
1139
1162
  }
1140
- #ct() {
1141
- if (this.#se.size === 0) return;
1142
- let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#se.has(e));
1143
- this.#se.clear(), t && this.#tt();
1163
+ #mt() {
1164
+ if (this.#le.size === 0) return;
1165
+ let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
1166
+ this.#le.clear(), t && this.#ot();
1144
1167
  }
1145
- #lt() {
1146
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#ut()), this.#P.observe(this.#e));
1168
+ #ht() {
1169
+ typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#gt()), this.#P.observe(this.#e));
1147
1170
  }
1148
- #ut() {
1171
+ #gt() {
1149
1172
  this.#F || (this.#F = !0, requestAnimationFrame(() => {
1150
1173
  this.#F = !1, this.update();
1151
1174
  }));
1152
1175
  }
1153
- async #dt(e) {
1154
- let [t, n] = await Promise.all([this.#ft(e.left), this.#ft(e.right)]);
1176
+ async #_t(e) {
1177
+ let [t, n] = await Promise.all([this.#vt(e.left), this.#vt(e.right)]);
1155
1178
  return {
1156
1179
  left: t,
1157
1180
  right: n
1158
1181
  };
1159
1182
  }
1160
- async #ft(e) {
1183
+ async #vt(e) {
1161
1184
  if (e === null) return null;
1162
1185
  try {
1163
1186
  return await this.#t.get(e);
@@ -1168,7 +1191,7 @@ var K = class {
1168
1191
  }), null;
1169
1192
  }
1170
1193
  }
1171
- #pt() {
1194
+ #yt() {
1172
1195
  let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1173
1196
  for (let n of e) {
1174
1197
  let e = this.#T[n];
@@ -1176,45 +1199,45 @@ var K = class {
1176
1199
  }
1177
1200
  this.#t.prefetch(t);
1178
1201
  }
1179
- #mt(e) {
1202
+ #bt(e) {
1180
1203
  let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1181
1204
  return t === -1 ? 0 : t;
1182
1205
  }
1183
- #ht() {
1206
+ #xt() {
1184
1207
  let e = this.#t.pageCount;
1185
1208
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1186
1209
  let t = this.#b;
1187
1210
  if (t !== void 0 && (!Number.isInteger(t) || t < 0 || t >= e)) throw Error(`Zine: startPage ${JSON.stringify(t)} is out of range for a ${e}-page book (valid 0..${e - 1}).`);
1188
- let n = this.#Qe();
1211
+ let n = this.#rt();
1189
1212
  this.#h = n === "single", this.#T = a(e, {
1190
1213
  direction: this.#a,
1191
1214
  mode: n
1192
1215
  });
1193
- let r = this.#x ? C(globalThis.location?.hash ?? "") : null;
1194
- this.#D = q(r ?? t ?? 0, 0, e - 1), this.#E = this.#mt(this.#D);
1216
+ let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1217
+ this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#bt(this.#D);
1195
1218
  }
1196
1219
  };
1197
- function q(e, t, n) {
1220
+ function Y(e, t, n) {
1198
1221
  return e < t ? t : e > n ? n : e;
1199
1222
  }
1200
- function J(e, t, n) {
1223
+ function X(e, t, n) {
1201
1224
  if (t <= n) {
1202
1225
  let r = (n - t) / 2 - e;
1203
1226
  return [r, r];
1204
1227
  }
1205
1228
  return [n - (e + t), -e];
1206
1229
  }
1207
- function Y(e) {
1230
+ function Z(e) {
1208
1231
  return e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
1209
1232
  }
1210
- function X(e) {
1211
- return 1 - (1 - Y(e)) ** 1.3;
1233
+ function ne(e) {
1234
+ return 1 - (1 - Z(e)) ** 1.3;
1212
1235
  }
1213
- function Z(e) {
1236
+ function Q(e) {
1214
1237
  return e === null ? "null" : Array.isArray(e) ? "array" : typeof e;
1215
1238
  }
1216
- function Q(n, r) {
1217
- if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Z(n)}.`);
1239
+ function re(n, r) {
1240
+ if (typeof n != "object" || !n || typeof n.appendChild != "function" || typeof n.addEventListener != "function") throw Error(`Zine: container must be a DOM element; received ${Q(n)}.`);
1218
1241
  if (typeof r != "object" || !r) throw Error("Zine: an options object with a `source` is required.");
1219
1242
  let i = r, a = i.source;
1220
1243
  if (typeof a != "object" || !a || typeof a.get != "function" || typeof a.pageCount != "number") throw Error("Zine: `source` is required and must be a Source, e.g. new ImageSource(urls).");
@@ -1239,9 +1262,9 @@ function Q(n, r) {
1239
1262
  "deepLink",
1240
1263
  "disableContextMenu",
1241
1264
  "responsiveSpread"
1242
- ]) if (i[e] !== void 0 && typeof i[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Z(i[e])}.`);
1265
+ ]) if (i[e] !== void 0 && typeof i[e] != "boolean") throw Error(`Zine: ${e} must be a boolean; got ${Q(i[e])}.`);
1243
1266
  let u = i.controls;
1244
- if (u !== void 0 && typeof u != "boolean" && (typeof u != "object" || !u)) throw Error(`Zine: controls must be a boolean or an options object; got ${Z(u)}.`);
1267
+ if (u !== void 0 && typeof u != "boolean" && (typeof u != "object" || !u)) throw Error(`Zine: controls must be a boolean or an options object; got ${Q(u)}.`);
1245
1268
  let d = u?.position;
1246
1269
  if (d !== void 0 && ![
1247
1270
  "top",
@@ -1262,12 +1285,12 @@ function Q(n, r) {
1262
1285
  }
1263
1286
  let p = i.pages;
1264
1287
  if (p !== void 0 && (typeof p != "object" || !p || Array.isArray(p))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1265
- $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ee(i.zoom), te(i.renderer);
1288
+ $(i.width, "width", 1), $(i.height, "height", 1), $(i.flipDuration, "flipDuration", 0), $(i.clickZoneSize, "clickZoneSize", 0), $(i.clickFlipDelay, "clickFlipDelay", 0), $(i.singlePageThreshold, "singlePageThreshold", 0), ie(i.zoom), ae(i.renderer);
1266
1289
  }
1267
1290
  function $(e, t, n) {
1268
1291
  if (e !== void 0 && (typeof e != "number" || !Number.isFinite(e) || e < n)) throw Error(`Zine: ${t} must be a number >= ${n}; got ${JSON.stringify(e)}.`);
1269
1292
  }
1270
- function ee(e) {
1293
+ function ie(e) {
1271
1294
  if (e === void 0) return;
1272
1295
  if (typeof e != "object" || !e || Array.isArray(e)) throw Error("Zine: zoom must be an object, e.g. { max: 4 }.");
1273
1296
  let t = e;
@@ -1280,7 +1303,7 @@ function ee(e) {
1280
1303
  }
1281
1304
  $(t.max, "zoom.max", 1);
1282
1305
  }
1283
- function te(e) {
1306
+ function ae(e) {
1284
1307
  if (e !== void 0) {
1285
1308
  if (typeof e == "string") {
1286
1309
  if (e !== "auto" && e !== "css" && e !== "webgl2") throw Error(`Zine: renderer '${e}' is not recognized; use 'auto', 'css', 'webgl2', an array of those, or a custom Renderer.`);
@@ -1295,7 +1318,7 @@ function te(e) {
1295
1318
  }
1296
1319
  //#endregion
1297
1320
  //#region src/source/imageSource.ts
1298
- var ne = class {
1321
+ var oe = class {
1299
1322
  pageCount;
1300
1323
  fit;
1301
1324
  #e;
@@ -1332,6 +1355,6 @@ var ne = class {
1332
1355
  }
1333
1356
  };
1334
1357
  //#endregion
1335
- export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, ne as ImageSource, K as Zine, n as defineControl, r as getControl };
1358
+ export { t as CURL_TYPES, i as DEFAULT_ITEMS, e as IMPORTABLE_CURLS, oe as ImageSource, J as Zine, n as defineControl, r as getControl };
1336
1359
 
1337
1360
  //# sourceMappingURL=index.js.map