@zinejs/core 0.7.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -284,25 +284,25 @@ var T = {
284
284
  css: async () => new (await (import("./cssRenderer-Deskm2ND.js"))).CssRenderer(),
285
285
  webgl2: async () => new (await (import("./webglRenderer-nGRruZk2.js"))).WebglRenderer()
286
286
  }, E = !0;
287
- function ee(e) {
287
+ function D(e) {
288
288
  return typeof e == "object" && !!e && !Array.isArray(e) && typeof e.mount == "function";
289
289
  }
290
- function te(e) {
290
+ function O(e) {
291
291
  return e.gpu && E ? ["webgl2", "css"] : ["css"];
292
292
  }
293
- function D() {
294
- return { gpu: O() };
293
+ function ee() {
294
+ return { gpu: te() };
295
295
  }
296
- function O() {
296
+ function te() {
297
297
  try {
298
298
  return !!document.createElement("canvas").getContext("webgl2");
299
299
  } catch {
300
300
  return !1;
301
301
  }
302
302
  }
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];
303
+ async function k(e = "auto", t = ee()) {
304
+ if (D(e)) return e;
305
+ let n = Array.isArray(e) ? e : e === "auto" ? O(t) : [e];
306
306
  for (let e of n) {
307
307
  if (e === "webgl2" && !t.gpu) continue;
308
308
  let n = T[e];
@@ -488,7 +488,7 @@ var J = class {
488
488
  pages: t.pages
489
489
  });
490
490
  let n = t.direction ?? "ltr";
491
- 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.#fe = t.loading ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#jt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
491
+ 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.#fe = t.loading ?? !0, this.#b = t.startPage, typeof this.#t.open != "function" && this.#Mt(), this.#k = t.flipDuration ?? 800, this.#A = t.zoom?.enabled ?? !0, this.#j = t.zoom?.wheel ?? !0;
492
492
  let r = t.zoom?.doubleClick, i = r === !1 ? [] : [...r ?? [
493
493
  1,
494
494
  2,
@@ -496,7 +496,7 @@ var J = class {
496
496
  ]].sort((e, t) => e - t);
497
497
  this.#M = i.length > 0 ? i : null, this.#N = t.zoom?.max ?? 4;
498
498
  let a = this.#A && this.#M !== null, o = t.zoom?.doubleClickInFlipZone ?? this.#u === "half";
499
- this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#ye = this.#Qe(t.renderer ?? "auto");
499
+ this.#f = this.#u !== "off" && a && o && t.clickFlipDelay !== 0, this.#p = this.#f ? t.clickFlipDelay ?? I : 0, this.#ye = this.#$e(t.renderer ?? "auto");
500
500
  }
501
501
  get ready() {
502
502
  return this.#ye;
@@ -510,6 +510,9 @@ var J = class {
510
510
  get container() {
511
511
  return this.#e;
512
512
  }
513
+ getPageBox() {
514
+ return this.#z?.measure().book ?? null;
515
+ }
513
516
  getSpreads() {
514
517
  return this.#T;
515
518
  }
@@ -526,7 +529,7 @@ var J = class {
526
529
  return this.#h;
527
530
  }
528
531
  setSpreadMode(e) {
529
- e !== this.#o && (this.#o = e, this.#_ = !1, this.#ht(), this.#gt());
532
+ e !== this.#o && (this.#o = e, this.#_ = !1, this.#gt(), this.#_t());
530
533
  }
531
534
  toggleSpreadMode() {
532
535
  this.setSpreadMode(this.#o === "single" ? this.#s === "single" ? "double" : this.#s : "single");
@@ -542,16 +545,16 @@ var J = class {
542
545
  if (this.#v = e, e) {
543
546
  let e = this.#z?.measure().containerWidth;
544
547
  if (e === void 0) return;
545
- this.#_ = !1, this.#mt(e);
548
+ this.#_ = !1, this.#ht(e);
546
549
  } else {
547
550
  if (!this.#_) return;
548
- this.#_ = !1, this.#ht();
551
+ this.#_ = !1, this.#gt();
549
552
  }
550
- this.#gt();
553
+ this.#_t();
551
554
  }
552
555
  }
553
556
  getPageImage(e) {
554
- return this.#Ot(e);
557
+ return this.#kt(e);
555
558
  }
556
559
  canFlipNext() {
557
560
  return this.#E + 1 < this.#T.length;
@@ -572,7 +575,7 @@ var J = class {
572
575
  return typeof this.#t.getOutline == "function" || typeof this.#t.getText == "function";
573
576
  }
574
577
  canPrint() {
575
- return typeof this.#t.getDownload == "function";
578
+ return typeof this.#t.getDownload == "function" && this.#e.ownerDocument?.defaultView?.navigator?.pdfViewerEnabled !== !1;
576
579
  }
577
580
  async print() {
578
581
  let e = await this.getSourceFile(), t = this.#e.ownerDocument;
@@ -614,8 +617,22 @@ var J = class {
614
617
  if (!e) return !1;
615
618
  let t = this.#e.ownerDocument;
616
619
  if (!t) return !1;
617
- let n = t.createElement("a");
618
- return n.href = e.url, n.download = e.filename, n.rel = "noopener", t.body.appendChild(n), n.click(), n.remove(), e.revoke && setTimeout(() => URL.revokeObjectURL(e.url), 1e4), !0;
620
+ let n = e.url, r = e.revoke ?? !1;
621
+ if (!r && this.#be(n, t)) try {
622
+ let e = await (await fetch(n)).blob();
623
+ n = URL.createObjectURL(e), r = !0;
624
+ } catch {}
625
+ let i = t.createElement("a");
626
+ return i.href = n, i.download = e.filename, i.rel = "noopener", t.body.appendChild(i), i.click(), i.remove(), r && setTimeout(() => URL.revokeObjectURL(n), 1e4), !0;
627
+ }
628
+ #be(e, t) {
629
+ let n = t.defaultView?.location?.href;
630
+ if (!n) return !1;
631
+ try {
632
+ return new URL(e, n).origin !== new URL(n).origin;
633
+ } catch {
634
+ return !1;
635
+ }
619
636
  }
620
637
  async search(e, t = {}) {
621
638
  let n = this.#t.getText, r = e.trim().toLowerCase();
@@ -641,29 +658,29 @@ var J = class {
641
658
  return a;
642
659
  }
643
660
  flipNext() {
644
- this.#be(1);
661
+ this.#xe(1);
645
662
  }
646
663
  flipPrev() {
647
- this.#be(-1);
664
+ this.#xe(-1);
648
665
  }
649
- #be(e) {
650
- this.#xe(() => this.#Ee(this.#E + e));
666
+ #xe(e) {
667
+ this.#Se(() => this.#De(this.#E + e));
651
668
  }
652
669
  flipTo(e) {
653
670
  let t = Y(e, 0, Math.max(0, this.#t.pageCount - 1));
654
- this.#xe(() => this.#Ee(this.#At(t)));
671
+ this.#Se(() => this.#De(this.#jt(t)));
655
672
  }
656
- #xe(e) {
657
- this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#Se(), e()) : this.#q = e;
673
+ #Se(e) {
674
+ this.#i.state === "idle" ? e() : this.#J ? (this.#q = null, this.#Ce(), e()) : this.#q = e;
658
675
  }
659
- #Se() {
676
+ #Ce() {
660
677
  let e = this.#J;
661
678
  e && (this.#J = null, this.#H !== null && (cancelAnimationFrame(this.#H), this.#H = null), this.#z?.setFlipProgress(e.toT, e.direction), e.onDone());
662
679
  }
663
- #Ce() {
680
+ #we() {
664
681
  let e = this.#q;
665
682
  if (!e) {
666
- this.#wt();
683
+ this.#Tt();
667
684
  return;
668
685
  }
669
686
  this.#q = null, e();
@@ -680,15 +697,15 @@ var J = class {
680
697
  x: r.containerWidth / 2,
681
698
  y: r.containerHeight / 2
682
699
  }, 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);
683
- [s, c] = this.#Te(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), o > 1 != n > 1 && this.#we(), this.#bt(), this.#n.emit("zoomChanged", { scale: n });
700
+ [s, c] = this.#Ee(s, c, n, r.containerWidth, r.containerHeight), this.#I = n, this.#L = s, this.#R = c, this.#z.setViewTransform(n, s, c), o > 1 != n > 1 && this.#Te(), this.#xt(), this.#n.emit("zoomChanged", { scale: n });
684
701
  }
685
702
  resetZoom() {
686
703
  this.setZoom(1);
687
704
  }
688
- #we() {
705
+ #Te() {
689
706
  this.#e.style.touchAction = this.#I > 1 ? "none" : "pan-y";
690
707
  }
691
- #Te(e, t, n, r, i) {
708
+ #Ee(e, t, n, r, i) {
692
709
  let a = typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1, o = (e) => Math.round(e * a) / a || 0, s = this.#z?.measure().screenAt?.(n) ?? {
693
710
  x: 0,
694
711
  y: 0,
@@ -701,29 +718,29 @@ var J = class {
701
718
  return this.#n.on(e, t);
702
719
  }
703
720
  destroy() {
704
- this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#Ue(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#nt(), this.#se?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#ve !== null && clearTimeout(this.#ve), this.#_e++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
721
+ this.#V = !0, this.#H !== null && cancelAnimationFrame(this.#H), this.#J = null, this.#q = null, this.#We(), this.#P?.disconnect(), this.#C?.stop(), this.#C = null, this.#w?.(), this.#x && x(), this.#de?.(), this.#rt(), this.#se?.(), this.#ne?.(), this.#ie?.(), this.#re?.(), this.#te?.(), this.#ve !== null && clearTimeout(this.#ve), this.#_e++, this.#z?.destroy(), this.#z = null, this.#t.destroy(), this.#n.clear();
705
722
  }
706
- #Ee(e) {
723
+ #De(e) {
707
724
  if (e < 0 || e >= this.#T.length || e === this.#E || this.#i.send("flip") === null) return;
708
- let t = e > this.#E ? "forward" : "backward", n = this.#je(e);
725
+ let t = e > this.#E ? "forward" : "backward", n = this.#Me(e);
709
726
  this.#n.emit("flipStart", {
710
727
  from: this.#D,
711
728
  to: n
712
- }), this.#De(e, t, n, ++this.#Y);
729
+ }), this.#Oe(e, t, n, ++this.#Y);
713
730
  }
714
- async #De(e, t, n, r) {
715
- let i = this.#T[e], a = i ? await this.#Dt(i) : {
731
+ async #Oe(e, t, n, r) {
732
+ let i = this.#T[e], a = i ? await this.#Ot(i) : {
716
733
  left: null,
717
734
  right: null
718
735
  };
719
736
  r === this.#Y && (this.#z?.beginFlip(this.#O, a, t, {
720
737
  fill: this.#h,
721
- curl: this.#ft(),
738
+ curl: this.#pt(),
722
739
  anchor: { y: this.#l }
723
- }), this.#Oe(0, 1, t, () => this.#Ae(e, n, a), () => this.#ke(n)));
740
+ }), this.#ke(0, 1, t, () => this.#je(e, n, a), () => this.#Ae(n)));
724
741
  }
725
- #Oe(e, t, n, r, i) {
726
- let a = this.#dt() * Math.abs(t - e);
742
+ #ke(e, t, n, r, i) {
743
+ let a = this.#ft() * Math.abs(t - e);
727
744
  if (a <= 0) {
728
745
  this.#z?.setFlipProgress(t, n), r();
729
746
  return;
@@ -741,22 +758,22 @@ var J = class {
741
758
  };
742
759
  this.#H = requestAnimationFrame(l);
743
760
  }
744
- #ke(e) {
745
- this.#D !== e && (this.#D = e, this.#ut(), this.#n.emit("pageChanged", { page: e }));
761
+ #Ae(e) {
762
+ this.#D !== e && (this.#D = e, this.#dt(), this.#n.emit("pageChanged", { page: e }));
746
763
  }
747
- #Ae(e, t, n) {
764
+ #je(e, t, n) {
748
765
  let r = this.#T[e];
749
- this.#E = e, this.#O = n, r && this.#_t(r, n), this.#kt(), this.#i.send("settle"), this.#oe = performance.now(), this.#ke(t), this.#n.emit("flipEnd", { page: t }), this.#Ce();
766
+ this.#E = e, this.#O = n, r && this.#vt(r, n), this.#At(), this.#i.send("settle"), this.#oe = performance.now(), this.#Ae(t), this.#n.emit("flipEnd", { page: t }), this.#we();
750
767
  }
751
- #je(e) {
768
+ #Me(e) {
752
769
  let t = this.#T[e];
753
770
  if (!t) return this.#D;
754
771
  let n = [t.left, t.right].filter((e) => e !== null);
755
772
  return n.length > 0 ? Math.min(...n) : this.#D;
756
773
  }
757
- #Me(e, t) {
774
+ #Ne(e, t) {
758
775
  if (this.#Z || !this.#z) return;
759
- if (this.#Ue(), this.#I > 1) {
776
+ if (this.#We(), this.#I > 1) {
760
777
  if (this.#i.send("panStart") === null) return;
761
778
  this.#X = {
762
779
  baseTx: this.#L,
@@ -764,7 +781,7 @@ var J = class {
764
781
  };
765
782
  return;
766
783
  }
767
- let n = this.#ze(), r = this.#Be(e, t);
784
+ let n = this.#Be(), r = this.#Ve(e, t);
768
785
  this.#G = r;
769
786
  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;
770
787
  if (this.#i.state !== "idle") {
@@ -772,7 +789,7 @@ var J = class {
772
789
  this.#W = null;
773
790
  return;
774
791
  }
775
- this.#Se();
792
+ this.#Ce();
776
793
  }
777
794
  if (!s) return;
778
795
  this.#l = Y(r.y / n.height, 0, 1);
@@ -780,11 +797,11 @@ var J = class {
780
797
  u < 0 || u >= this.#T.length || (this.#W = {
781
798
  direction: l ? "forward" : "backward",
782
799
  targetIndex: u,
783
- toPage: this.#je(u),
800
+ toPage: this.#Me(u),
784
801
  width: n.width
785
802
  });
786
803
  }
787
- #Ne() {
804
+ #Pe() {
788
805
  let e = this.#W;
789
806
  e && (this.#W = null, this.#i.send("grab") !== null && (this.#U = {
790
807
  direction: e.direction,
@@ -799,32 +816,32 @@ var J = class {
799
816
  }, this.#n.emit("flipStart", {
800
817
  from: this.#D,
801
818
  to: e.toPage
802
- }), this.#Pe(e.targetIndex, e.direction)));
819
+ }), this.#Fe(e.targetIndex, e.direction)));
803
820
  }
804
- async #Pe(e, t) {
805
- let n = this.#T[e], r = n ? await this.#Dt(n) : {
821
+ async #Fe(e, t) {
822
+ let n = this.#T[e], r = n ? await this.#Ot(n) : {
806
823
  left: null,
807
824
  right: null
808
825
  };
809
826
  this.#U?.targetIndex === e && (this.#U.toContent = r, this.#z?.beginFlip(this.#O, r, t, {
810
827
  fill: this.#h,
811
- curl: this.#ft(),
828
+ curl: this.#pt(),
812
829
  anchor: { y: this.#l }
813
830
  }), this.#z?.setFlipProgress(this.#U.t, t));
814
831
  }
815
- #Fe(e, t) {
832
+ #Ie(e, t) {
816
833
  if (this.#Z) return;
817
834
  if (this.#X) {
818
835
  if (!this.#z) return;
819
- let n = this.#z.measure(), [r, i] = this.#Te(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
820
- this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#bt();
836
+ let n = this.#z.measure(), [r, i] = this.#Ee(this.#X.baseTx + e, this.#X.baseTy + t, this.#I, n.containerWidth, n.containerHeight);
837
+ this.#L = r, this.#R = i, this.#z.setViewTransform(this.#I, r, i), this.#xt();
821
838
  return;
822
839
  }
823
- this.#W && Math.hypot(e, t) > F && this.#Ne();
840
+ this.#W && Math.hypot(e, t) > F && this.#Pe();
824
841
  let n = this.#U;
825
842
  n && (n.t = Y((n.direction === "forward" ? -e : e) / n.width, 0, 1), this.#z?.setFlipProgress(n.t, n.direction));
826
843
  }
827
- #Ie(e) {
844
+ #Le(e) {
828
845
  if (this.#Z) return;
829
846
  if (this.#X) {
830
847
  this.#X = null, this.#i.send("panEnd");
@@ -832,35 +849,35 @@ var J = class {
832
849
  }
833
850
  let t = this.#U;
834
851
  if (!t) {
835
- this.#W = null, this.#Le(e) || this.#Re(e);
852
+ this.#W = null, this.#Re(e) || this.#ze(e);
836
853
  return;
837
854
  }
838
855
  this.#U = null, this.#i.send("release");
839
856
  let n = e.swipe && Math.abs(e.vx) > Math.abs(e.vy), r = t.direction === "forward" ? e.vx < 0 : e.vx > 0, i = n && r, a = n && !r;
840
- i || t.t >= .5 && !a ? this.#Oe(t.t, 1, t.direction, () => this.#Ae(t.targetIndex, t.toPage, t.toContent), () => this.#ke(t.toPage)) : this.#Oe(t.t, 0, t.direction, () => this.#We());
857
+ i || t.t >= .5 && !a ? this.#ke(t.t, 1, t.direction, () => this.#je(t.targetIndex, t.toPage, t.toContent), () => this.#Ae(t.toPage)) : this.#ke(t.t, 0, t.direction, () => this.#Ge());
841
858
  }
842
- #Le(e) {
859
+ #Re(e) {
843
860
  if (this.#I > 1 || !e.swipe || Math.abs(e.dx) <= Math.abs(e.dy)) return !1;
844
861
  let t = this.#a === "rtl" ? e.dx > 0 : e.dx < 0, n = t ? "forward" : "backward";
845
- if (!this.#He(n)) return !1;
862
+ if (!this.#Ue(n)) return !1;
846
863
  let r = t ? 1 : -1;
847
- return this.#xe(() => this.#Ee(this.#E + r)), !0;
864
+ return this.#Se(() => this.#De(this.#E + r)), !0;
848
865
  }
849
- #Re(e) {
866
+ #ze(e) {
850
867
  if (this.#u === "off" || this.#I > 1 || !this.#G || Math.abs(e.dx) > F || Math.abs(e.dy) > F) return;
851
- let t = this.#Ve(this.#G);
852
- if (!t || !this.#He(t)) return;
853
- this.#l = Y(this.#G.y / this.#ze().height, 0, 1);
854
- let n = t === "forward" ? 1 : -1, r = () => this.#Ee(this.#E + n);
855
- if (this.#Ue(), this.#p <= 0) {
856
- this.#xe(r);
868
+ let t = this.#He(this.#G);
869
+ if (!t || !this.#Ue(t)) return;
870
+ this.#l = Y(this.#G.y / this.#Be().height, 0, 1);
871
+ let n = t === "forward" ? 1 : -1, r = () => this.#De(this.#E + n);
872
+ if (this.#We(), this.#p <= 0) {
873
+ this.#Se(r);
857
874
  return;
858
875
  }
859
876
  this.#K = setTimeout(() => {
860
- this.#K = null, this.#xe(r);
877
+ this.#K = null, this.#Se(r);
861
878
  }, this.#p);
862
879
  }
863
- #ze() {
880
+ #Be() {
864
881
  let e = this.#z.measure();
865
882
  return e.content ?? e.book ?? {
866
883
  x: 0,
@@ -869,40 +886,40 @@ var J = class {
869
886
  height: e.containerHeight
870
887
  };
871
888
  }
872
- #Be(e, t) {
873
- let n = this.#e.getBoundingClientRect(), r = this.#ze();
889
+ #Ve(e, t) {
890
+ let n = this.#e.getBoundingClientRect(), r = this.#Be();
874
891
  return {
875
892
  x: e - n.left - r.x,
876
893
  y: t - n.top - r.y
877
894
  };
878
895
  }
879
- #Ve(e) {
896
+ #He(e) {
880
897
  if (!this.#z) return null;
881
- let t = this.#ze().width, n;
898
+ let t = this.#Be().width, n;
882
899
  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;
883
900
  let r = this.#a === "rtl" ? "left" : "right";
884
901
  return n === r ? "forward" : "backward";
885
902
  }
886
- #He(e) {
903
+ #Ue(e) {
887
904
  let t = this.#E + (e === "forward" ? 1 : -1);
888
905
  return t >= 0 && t < this.#T.length;
889
906
  }
890
- #Ue() {
907
+ #We() {
891
908
  this.#K !== null && (clearTimeout(this.#K), this.#K = null);
892
909
  }
893
- #We() {
910
+ #Ge() {
894
911
  let e = this.#T[this.#E];
895
- e && this.#_t(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#Ce();
912
+ e && this.#vt(e, this.#O), this.#i.send("settle"), this.#n.emit("flipEnd", { page: this.#D }), this.#we();
896
913
  }
897
- #Ge() {
898
- if (this.#W = null, this.#Ue(), this.#U) {
914
+ #Ke() {
915
+ if (this.#W = null, this.#We(), this.#U) {
899
916
  this.#U = null, this.#i.send("release"), this.#i.send("settle");
900
917
  let e = this.#T[this.#E];
901
- e && this.#_t(e, this.#O);
918
+ e && this.#vt(e, this.#O);
902
919
  } else this.#X && (this.#X = null, this.#i.send("panEnd"));
903
920
  this.#Z = !0, this.#Q = this.#I;
904
921
  }
905
- #Ke(e, t, n) {
922
+ #qe(e, t, n) {
906
923
  if (!this.#Z) return;
907
924
  let r = this.#e.getBoundingClientRect();
908
925
  this.setZoom(this.#Q * n, {
@@ -910,15 +927,15 @@ var J = class {
910
927
  y: t - r.top
911
928
  });
912
929
  }
913
- #qe() {
930
+ #Je() {
914
931
  this.#Z = !1;
915
932
  }
916
- #Je() {
933
+ #Ye() {
917
934
  if (!this.#S) return;
918
935
  let e = (e) => e.preventDefault();
919
936
  this.#e.addEventListener("contextmenu", e), this.#re = () => this.#e.removeEventListener("contextmenu", e);
920
937
  }
921
- #Ye() {
938
+ #Xe() {
922
939
  let e = (e) => {
923
940
  if (!this.#j || !this.#A || !(e.ctrlKey || e.metaKey)) return;
924
941
  e.preventDefault();
@@ -930,7 +947,7 @@ var J = class {
930
947
  };
931
948
  this.#e.addEventListener("wheel", e, { passive: !1 }), this.#ne = () => this.#e.removeEventListener("wheel", e);
932
949
  }
933
- #Xe() {
950
+ #Ze() {
934
951
  let e = (e) => {
935
952
  let t = this.#M;
936
953
  if (!this.#A || t === null || !this.#z) return;
@@ -943,54 +960,54 @@ var J = class {
943
960
  };
944
961
  return;
945
962
  }
946
- this.#ae = null, this.#Ze(e.clientX, e.clientY, t);
963
+ this.#ae = null, this.#Qe(e.clientX, e.clientY, t);
947
964
  };
948
965
  this.#e.addEventListener("click", e), this.#ie = () => this.#e.removeEventListener("click", e);
949
966
  }
950
- #Ze(e, t, n) {
967
+ #Qe(e, t, n) {
951
968
  if (this.#I <= 1 && this.#u !== "off" && !this.#f) {
952
- let n = this.#Be(e, t), r = this.#Ve(n);
953
- if (r !== null && this.#He(r) || this.#i.state === "animating" || performance.now() - this.#oe <= R) return;
969
+ let n = this.#Ve(e, t), r = this.#He(n);
970
+ if (r !== null && this.#Ue(r) || this.#i.state === "animating" || performance.now() - this.#oe <= R) return;
954
971
  }
955
- this.#Ue();
972
+ this.#We();
956
973
  let r = n.find((e) => e > this.#I + 1e-6) ?? n[0] ?? this.#I, i = this.#e.getBoundingClientRect();
957
974
  this.setZoom(r, {
958
975
  x: e - i.left,
959
976
  y: t - i.top
960
977
  });
961
978
  }
962
- async #Qe(e) {
979
+ async #$e(e) {
963
980
  let t = k(e);
964
- if (this.#t.onProgress?.((e) => this.#$e(e)), typeof this.#t.open == "function") {
965
- this.#et();
981
+ if (this.#t.onProgress?.((e) => this.#et(e)), typeof this.#t.open == "function") {
982
+ this.#tt();
966
983
  try {
967
- await this.#t.open(), this.#jt();
984
+ await this.#t.open(), this.#Mt();
968
985
  } catch (e) {
969
- throw this.#nt(), e;
986
+ throw this.#rt(), e;
970
987
  }
971
- this.#tt("preparing");
988
+ this.#nt("preparing");
972
989
  }
973
990
  this.#t.prefetch([this.#D]);
974
- let n = await t, r = await this.#rt(n);
975
- this.#z = r, this.#t.onPageUpdate?.((e) => this.#yt(e)), this.#mt(r.measure().containerWidth);
991
+ let n = await t, r = await this.#it(n);
992
+ this.#z = r, this.#t.onPageUpdate?.((e) => this.#bt(e)), this.#ht(r.measure().containerWidth);
976
993
  let i = new m({
977
- onStart: (e) => this.#Me(e.x, e.y),
978
- onMove: (e) => this.#Fe(e.dx, e.dy),
979
- onEnd: (e) => this.#Ie(e)
994
+ onStart: (e) => this.#Ne(e.x, e.y),
995
+ onMove: (e) => this.#Ie(e.dx, e.dy),
996
+ onEnd: (e) => this.#Le(e)
980
997
  }), a = new _({
981
- onPinchStart: () => this.#Ge(),
982
- onPinchMove: (e) => this.#Ke(e.centerX, e.centerY, e.scale),
983
- onPinchEnd: () => this.#qe()
998
+ onPinchStart: () => this.#Ke(),
999
+ onPinchMove: (e) => this.#qe(e.centerX, e.centerY, e.scale),
1000
+ onPinchEnd: () => this.#Je()
984
1001
  });
985
1002
  this.#te = h(this.#e, {
986
1003
  pointer: i,
987
1004
  pinch: a
988
- }), this.#we(), this.#Ye(), this.#Xe(), this.#Je(), this.#at(), this.#se = this.#ct(), await this.#gt(), this.#nt(), this.#Tt(), this.#kt(), this.#ut(), this.#st(), await this.#ot(), this.#n.emit("ready");
1005
+ }), this.#Te(), this.#Xe(), this.#Ze(), this.#Ye(), this.#ot(), this.#se = this.#lt(), await this.#_t(), this.#rt(), this.#Et(), this.#At(), this.#dt(), this.#ct(), await this.#st(), this.#n.emit("ready");
989
1006
  }
990
- #$e(e) {
1007
+ #et(e) {
991
1008
  this.#me = e, this.#n.emit("progress", e), this.#pe?.update(e);
992
1009
  }
993
- async #et() {
1010
+ async #tt() {
994
1011
  if (this.#fe === !1 || this.#V) return;
995
1012
  let e = this.#e;
996
1013
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
@@ -999,16 +1016,16 @@ var J = class {
999
1016
  this.#pe = t(e), this.#me && this.#pe.update(this.#me), this.#he === "preparing" && this.#pe.preparing();
1000
1017
  } catch {}
1001
1018
  }
1002
- #tt(e) {
1019
+ #nt(e) {
1003
1020
  this.#he !== "done" && (this.#he = e, this.#pe?.preparing());
1004
1021
  }
1005
- #nt() {
1022
+ #rt() {
1006
1023
  this.#he = "done", this.#pe?.destroy(), this.#pe = null;
1007
1024
  }
1008
- async #rt(e) {
1025
+ async #it(e) {
1009
1026
  try {
1010
1027
  return await e.mount(this.#e), e.onFatal?.(() => {
1011
- this.#it();
1028
+ this.#at();
1012
1029
  }), e;
1013
1030
  } catch {
1014
1031
  e.destroy();
@@ -1019,7 +1036,7 @@ var J = class {
1019
1036
  }), t;
1020
1037
  }
1021
1038
  }
1022
- async #it() {
1039
+ async #at() {
1023
1040
  if (this.#B || this.#V) return;
1024
1041
  this.#B = !0, this.#z?.destroy(), this.#z = null;
1025
1042
  let e = await k("css");
@@ -1027,29 +1044,29 @@ var J = class {
1027
1044
  e.destroy();
1028
1045
  return;
1029
1046
  }
1030
- await e.mount(this.#e), this.#z = e, this.#mt(e.measure().containerWidth), await this.#gt(), this.#n.emit("rendererFallback", {
1047
+ await e.mount(this.#e), this.#z = e, this.#ht(e.measure().containerWidth), await this.#_t(), this.#n.emit("rendererFallback", {
1031
1048
  from: "webgl2",
1032
1049
  to: "css"
1033
1050
  });
1034
1051
  }
1035
- #at() {
1052
+ #ot() {
1036
1053
  if (typeof matchMedia != "function") return;
1037
1054
  let e = matchMedia("(prefers-reduced-motion: reduce)");
1038
1055
  this.#$ = e.matches, e.addEventListener?.("change", (e) => {
1039
1056
  this.#$ = e.matches;
1040
1057
  });
1041
1058
  }
1042
- async #ot() {
1059
+ async #st() {
1043
1060
  if (this.#ue === !1 || this.#V) return;
1044
1061
  let e = this.#e;
1045
1062
  if (!(!e.ownerDocument || typeof e.appendChild != "function")) try {
1046
- let { mountControls: t } = await import("./controls-Bj72hxVJ.js");
1063
+ let { mountControls: t } = await import("./controls-Djjk8Yac.js");
1047
1064
  if (this.#V) return;
1048
1065
  let n = this.#ue === !0 ? {} : this.#ue;
1049
1066
  this.#de = t(this, e, n);
1050
1067
  } catch {}
1051
1068
  }
1052
- #st() {
1069
+ #ct() {
1053
1070
  if (!this.#x || globalThis.location === void 0) return;
1054
1071
  let e = globalThis;
1055
1072
  this.#C = w(e, (e) => {
@@ -1064,18 +1081,18 @@ var J = class {
1064
1081
  let n = new URL(t);
1065
1082
  return n.hash = C(n.hash, Y(e, 0, Math.max(0, this.#t.pageCount - 1))), n.toString();
1066
1083
  }
1067
- #ct() {
1084
+ #lt() {
1068
1085
  let e = this.#e, t = e.ownerDocument;
1069
1086
  if (!t || typeof e.setAttribute != "function") return null;
1070
1087
  e.hasAttribute("tabindex") || (e.tabIndex = 0), e.setAttribute("aria-roledescription", "flipbook");
1071
- let n = (e) => this.#lt(e);
1088
+ let n = (e) => this.#ut(e);
1072
1089
  e.addEventListener("keydown", n);
1073
1090
  let r = t.createElement("div");
1074
1091
  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, () => {
1075
1092
  e.removeEventListener("keydown", n), r.remove(), this.#ee = null;
1076
1093
  };
1077
1094
  }
1078
- #lt(e) {
1095
+ #ut(e) {
1079
1096
  let t = this.#a === "rtl" ? "ArrowLeft" : "ArrowRight";
1080
1097
  switch (e.key) {
1081
1098
  case "ArrowRight":
@@ -1091,70 +1108,70 @@ var J = class {
1091
1108
  default: break;
1092
1109
  }
1093
1110
  }
1094
- #ut() {
1111
+ #dt() {
1095
1112
  this.#ee && (this.#ee.textContent = `Page ${this.#D + 1} of ${this.#t.pageCount}`);
1096
1113
  }
1097
- #dt() {
1114
+ #ft() {
1098
1115
  return this.#$ ? W : this.#k * (this.#h ? z : 1);
1099
1116
  }
1100
- #ft() {
1117
+ #pt() {
1101
1118
  return this.#$ ? "simple" : this.#c;
1102
1119
  }
1103
1120
  update() {
1104
- !this.#z || this.#i.state !== "idle" || (this.#mt(this.#z.measure().containerWidth), this.#gt());
1121
+ !this.#z || this.#i.state !== "idle" || (this.#ht(this.#z.measure().containerWidth), this.#_t());
1105
1122
  }
1106
- #pt() {
1123
+ #mt() {
1107
1124
  return this.#_ || this.#o === "single" ? "single" : this.#o;
1108
1125
  }
1109
- #mt(e) {
1126
+ #ht(e) {
1110
1127
  let t = this.#v && o(e, this.#m);
1111
- t !== this.#_ && (this.#_ = t, this.#ht());
1128
+ t !== this.#_ && (this.#_ = t, this.#gt());
1112
1129
  }
1113
- #ht() {
1114
- let e = this.#pt(), t = e !== this.#g;
1130
+ #gt() {
1131
+ let e = this.#mt(), t = e !== this.#g;
1115
1132
  this.#g = e, this.#h = e === "single", this.#T = a(this.#t.pageCount, {
1116
1133
  direction: this.#a,
1117
1134
  mode: e
1118
- }), this.#E = this.#At(this.#D), t && this.#n.emit("spreadChanged", {
1135
+ }), this.#E = this.#jt(this.#D), t && this.#n.emit("spreadChanged", {
1119
1136
  mode: e,
1120
1137
  singlePage: this.#h
1121
1138
  });
1122
1139
  }
1123
- async #gt() {
1140
+ async #_t() {
1124
1141
  let e = this.#T[this.#E];
1125
- !e || !this.#z || (this.#O = await this.#Dt(e), this.#_t(e, this.#O));
1142
+ !e || !this.#z || (this.#O = await this.#Ot(e), this.#vt(e, this.#O));
1126
1143
  }
1127
- #_t(e, t) {
1128
- this.#z?.renderSpread(e, t, { fill: this.#h }), this.#vt(), this.#ge = 1, this.#bt();
1144
+ #vt(e, t) {
1145
+ this.#z?.renderSpread(e, t, { fill: this.#h }), this.#yt(), this.#ge = 1, this.#xt();
1129
1146
  }
1130
- #vt() {
1147
+ #yt() {
1131
1148
  let e = this.#z?.measure().book;
1132
1149
  if (!e || e.width <= 0 || e.height <= 0) return;
1133
1150
  let t = (e.width / e.height).toFixed(4);
1134
1151
  t !== this.#y && (this.#y = t, this.#e.style.aspectRatio = t);
1135
1152
  }
1136
- #yt(e) {
1153
+ #bt(e) {
1137
1154
  if (this.#i.state !== "idle") {
1138
1155
  this.#le.add(e);
1139
1156
  return;
1140
1157
  }
1141
1158
  let t = this.#T[this.#E];
1142
- t && (t.left === e || t.right === e) && this.#gt();
1159
+ t && (t.left === e || t.right === e) && this.#_t();
1143
1160
  }
1144
- #bt() {
1161
+ #xt() {
1145
1162
  this.#ve !== null && clearTimeout(this.#ve);
1146
- let e = this.#St();
1163
+ let e = this.#Ct();
1147
1164
  if (e !== this.#ge) {
1148
1165
  if (e === 1) {
1149
- this.#_e++, this.#ge = 1, this.#gt();
1166
+ this.#_e++, this.#ge = 1, this.#_t();
1150
1167
  return;
1151
1168
  }
1152
1169
  this.#ve = setTimeout(() => {
1153
- this.#ve = null, this.#Ct();
1170
+ this.#ve = null, this.#wt();
1154
1171
  }, V);
1155
1172
  }
1156
1173
  }
1157
- #xt() {
1174
+ #St() {
1158
1175
  let e = this.#z?.measure(), t = e?.content ?? e?.book;
1159
1176
  if (!t || t.width <= 0) return 1;
1160
1177
  let n = this.#O, r = +!!n.left + +!!n.right;
@@ -1167,14 +1184,14 @@ var J = class {
1167
1184
  }
1168
1185
  return o === 0 ? 1 : o;
1169
1186
  }
1170
- #St() {
1171
- let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#xt() * Math.max(t, e);
1187
+ #Ct() {
1188
+ let e = Math.max(1, U / (typeof devicePixelRatio == "number" && devicePixelRatio > 0 ? devicePixelRatio : 1)), t = this.#I <= 1 ? 1 : this.#I, n = this.#St() * Math.max(t, e);
1172
1189
  return n <= 1.001 ? 1 : Math.min(Math.ceil(n * 2) / 2, H);
1173
1190
  }
1174
- async #Ct() {
1191
+ async #wt() {
1175
1192
  let e = this.#T[this.#E];
1176
1193
  if (!this.#z || !e) return;
1177
- let t = this.#St();
1194
+ let t = this.#Ct();
1178
1195
  if (t === 1 || t === this.#ge || this.#i.state !== "idle") return;
1179
1196
  let n = ++this.#_e, r = {
1180
1197
  x: 0,
@@ -1195,34 +1212,34 @@ var J = class {
1195
1212
  }), null;
1196
1213
  }
1197
1214
  }));
1198
- if (n !== this.#_e || this.#St() !== t || this.#i.state !== "idle") return;
1215
+ if (n !== this.#_e || this.#Ct() !== t || this.#i.state !== "idle") return;
1199
1216
  let a = i[0] ?? null, o = i[1] ?? null;
1200
1217
  a === this.#O.left && o === this.#O.right || (this.#ge = t, this.#O = {
1201
1218
  left: a,
1202
1219
  right: o
1203
1220
  }, this.#z.renderSpread(e, this.#O, { fill: this.#h }));
1204
1221
  }
1205
- #wt() {
1222
+ #Tt() {
1206
1223
  if (this.#le.size === 0) return;
1207
1224
  let e = this.#T[this.#E], t = e !== void 0 && [e.left, e.right].some((e) => e !== null && this.#le.has(e));
1208
- this.#le.clear(), t && this.#gt();
1209
- }
1210
- #Tt() {
1211
- typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Et()), this.#P.observe(this.#e));
1225
+ this.#le.clear(), t && this.#_t();
1212
1226
  }
1213
1227
  #Et() {
1228
+ typeof ResizeObserver > "u" || (this.#P = new ResizeObserver(() => this.#Dt()), this.#P.observe(this.#e));
1229
+ }
1230
+ #Dt() {
1214
1231
  this.#F || (this.#F = !0, requestAnimationFrame(() => {
1215
1232
  this.#F = !1, this.update();
1216
1233
  }));
1217
1234
  }
1218
- async #Dt(e) {
1219
- let [t, n] = await Promise.all([this.#Ot(e.left), this.#Ot(e.right)]);
1235
+ async #Ot(e) {
1236
+ let [t, n] = await Promise.all([this.#kt(e.left), this.#kt(e.right)]);
1220
1237
  return {
1221
1238
  left: t,
1222
1239
  right: n
1223
1240
  };
1224
1241
  }
1225
- async #Ot(e) {
1242
+ async #kt(e) {
1226
1243
  if (e === null) return null;
1227
1244
  try {
1228
1245
  return await this.#t.get(e);
@@ -1233,7 +1250,7 @@ var J = class {
1233
1250
  }), null;
1234
1251
  }
1235
1252
  }
1236
- #kt() {
1253
+ #At() {
1237
1254
  let { toMount: e } = this.#r.update(this.#E, this.#T.length), t = [];
1238
1255
  for (let n of e) {
1239
1256
  let e = this.#T[n];
@@ -1241,22 +1258,22 @@ var J = class {
1241
1258
  }
1242
1259
  this.#t.prefetch(t);
1243
1260
  }
1244
- #At(e) {
1261
+ #jt(e) {
1245
1262
  let t = this.#T.findIndex((t) => t.left === e || t.right === e);
1246
1263
  return t === -1 ? 0 : t;
1247
1264
  }
1248
- #jt() {
1265
+ #Mt() {
1249
1266
  let e = this.#t.pageCount;
1250
1267
  if (!Number.isInteger(e) || e < 1) throw Error(`Zine: source has ${e} pages; a Source must have at least 1 page.`);
1251
1268
  let t = this.#b;
1252
1269
  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}).`);
1253
- let n = this.#pt();
1270
+ let n = this.#mt();
1254
1271
  this.#h = n === "single", this.#T = a(e, {
1255
1272
  direction: this.#a,
1256
1273
  mode: n
1257
1274
  });
1258
1275
  let r = this.#x ? S(globalThis.location?.hash ?? "") : null;
1259
- this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#At(this.#D);
1276
+ this.#D = Y(r ?? t ?? 0, 0, e - 1), this.#E = this.#jt(this.#D);
1260
1277
  }
1261
1278
  };
1262
1279
  function Y(e, t, n) {
@@ -1315,19 +1332,27 @@ function re(n, r) {
1315
1332
  "left",
1316
1333
  "right"
1317
1334
  ].includes(d)) throw Error(`Zine: controls.position must be 'top', 'bottom', 'left', or 'right'; got ${JSON.stringify(d)}.`);
1318
- let f = i.spreadMode;
1335
+ let f = u?.colorScheme;
1319
1336
  if (f !== void 0 && ![
1337
+ "light",
1338
+ "dark",
1339
+ "auto"
1340
+ ].includes(f)) throw Error(`Zine: controls.colorScheme must be 'light', 'dark', or 'auto'; got ${JSON.stringify(f)}.`);
1341
+ let p = u?.arrows;
1342
+ if (p !== void 0 && typeof p != "boolean" && !["desktop", "mobile"].includes(p)) throw Error(`Zine: controls.arrows must be a boolean, 'desktop', or 'mobile'; got ${JSON.stringify(p)}.`);
1343
+ let m = i.spreadMode;
1344
+ if (m !== void 0 && ![
1320
1345
  "double",
1321
1346
  "single",
1322
1347
  "cover",
1323
1348
  "book"
1324
- ].includes(f)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(f)}.`);
1349
+ ].includes(m)) throw Error(`Zine: spreadMode must be 'double', 'single', 'cover', or 'book'; got ${JSON.stringify(m)}.`);
1325
1350
  for (let e of ["frontCover", "backCover"]) {
1326
1351
  let t = i[e];
1327
1352
  if (t !== void 0 && typeof t != "string") throw Error(`Zine: ${e} must be an image URL string; got ${JSON.stringify(t)}.`);
1328
1353
  }
1329
- let p = i.pages;
1330
- 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.");
1354
+ let h = i.pages;
1355
+ if (h !== void 0 && (typeof h != "object" || !h || Array.isArray(h))) throw Error("Zine: pages must be an object mapping page indices to image URLs.");
1331
1356
  $(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);
1332
1357
  }
1333
1358
  function $(e, t, n) {